viewkitjs 0.29.0 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/CHANGELOG.md +127 -6
  2. package/MIGRATION.md +97 -8
  3. package/package.json +1 -1
  4. package/views/dist/cells/cell-format.d.ts +2 -2
  5. package/views/dist/cells/cell-values.js +0 -2
  6. package/views/dist/contract.d.ts +15 -18
  7. package/views/dist/contract.js +13 -27
  8. package/views/dist/controls/button/map-button.d.ts +5 -3
  9. package/views/dist/controls/button/map-button.js +14 -7
  10. package/views/dist/controls/controls.d.ts +2 -4
  11. package/views/dist/controls/controls.js +2 -2
  12. package/views/dist/controls/customize/customize.d.ts +51 -0
  13. package/views/dist/controls/customize/customize.js +128 -23
  14. package/views/dist/controls/customize/map-customize-body.d.ts +0 -3
  15. package/views/dist/controls/customize/map-customize-body.js +46 -11
  16. package/views/dist/controls/customize/map-ranges.d.ts +23 -0
  17. package/views/dist/controls/customize/map-ranges.js +41 -0
  18. package/views/dist/controls/customize/rules.d.ts +17 -1
  19. package/views/dist/controls/customize/rules.js +2 -0
  20. package/views/dist/controls/customize/words.d.ts +7 -0
  21. package/views/dist/controls/customize/words.js +5 -0
  22. package/views/dist/controls/customize.css +3 -0
  23. package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
  24. package/views/dist/controls/filter-editor/filter-editor.js +1 -0
  25. package/views/dist/controls/filter-editor/rules.d.ts +1 -2
  26. package/views/dist/controls/index.d.ts +8 -8
  27. package/views/dist/controls/index.js +8 -8
  28. package/views/dist/controls/menu-list/menu-list.d.ts +16 -1
  29. package/views/dist/controls/menu-list/menu-list.js +26 -8
  30. package/views/dist/controls/menu-list.css +8 -0
  31. package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +1 -1
  32. package/views/dist/controls/quick-filters/map-quick-filters-body.js +6 -3
  33. package/views/dist/controls/sheet/map-sheet.js +1 -1
  34. package/views/dist/controls/text-editor/map-text-body.d.ts +1 -1
  35. package/views/dist/controls/text-editor/map-text-body.js +2 -2
  36. package/views/dist/controls/text-editor/text-editor.d.ts +3 -0
  37. package/views/dist/controls/text-editor/text-editor.js +16 -2
  38. package/views/dist/controls/text-editor.css +11 -0
  39. package/views/dist/controls/values-editor/values.js +6 -2
  40. package/views/dist/display/options.d.ts +1 -1
  41. package/views/dist/display/rich-text.js +0 -1
  42. package/views/dist/editors/ChipsEditor.d.ts +4 -5
  43. package/views/dist/editors/ChipsEditor.js +12 -78
  44. package/views/dist/editors/DateEditor.d.ts +12 -16
  45. package/views/dist/editors/DateEditor.js +40 -191
  46. package/views/dist/editors/EditorPanel.d.ts +2 -6
  47. package/views/dist/editors/EditorPanel.js +2 -2
  48. package/views/dist/editors/LocationEditor.d.ts +11 -19
  49. package/views/dist/editors/LocationEditor.js +19 -211
  50. package/views/dist/editors/NameEditor.d.ts +8 -16
  51. package/views/dist/editors/NameEditor.js +11 -100
  52. package/views/dist/editors/NumberEditor.d.ts +14 -21
  53. package/views/dist/editors/NumberEditor.js +22 -49
  54. package/views/dist/editors/RangeEditor.d.ts +9 -33
  55. package/views/dist/editors/RangeEditor.js +12 -97
  56. package/views/dist/editors/RelationEditor.d.ts +6 -9
  57. package/views/dist/editors/RelationEditor.js +11 -30
  58. package/views/dist/editors/RelationSetEditor.d.ts +13 -24
  59. package/views/dist/editors/RelationSetEditor.js +33 -101
  60. package/views/dist/editors/SelectEditor.d.ts +15 -17
  61. package/views/dist/editors/SelectEditor.js +15 -94
  62. package/views/dist/editors/TextEditor.d.ts +23 -26
  63. package/views/dist/editors/TextEditor.js +11 -48
  64. package/views/dist/editors/ValueListEditor.d.ts +14 -23
  65. package/views/dist/editors/ValueListEditor.js +16 -202
  66. package/views/dist/editors/body-panel.d.ts +13 -7
  67. package/views/dist/editors/body-panel.js +3 -7
  68. package/views/dist/editors/edit-cores.d.ts +15 -15
  69. package/views/dist/editors/edit-cores.js +14 -14
  70. package/views/dist/editors/number-body.d.ts +1 -1
  71. package/views/dist/editors/number-step.d.ts +0 -34
  72. package/views/dist/editors/number-step.js +0 -37
  73. package/views/dist/editors/option-add-flow.d.ts +1 -13
  74. package/views/dist/editors/option-add-flow.js +0 -22
  75. package/views/dist/editors/relation-links-body.d.ts +2 -3
  76. package/views/dist/editors/relation-picker.d.ts +13 -3
  77. package/views/dist/editors/relation-source.d.ts +0 -22
  78. package/views/dist/editors/relation-source.js +0 -21
  79. package/views/dist/field-row/FieldRow.js +5 -6
  80. package/views/dist/field-row/FieldRowLane.js +0 -1
  81. package/views/dist/field-row/editors/RowChipsEditor.js +2 -2
  82. package/views/dist/field-row/editors/RowDateEditor.d.ts +2 -2
  83. package/views/dist/field-row/editors/RowDateEditor.js +2 -2
  84. package/views/dist/field-row/editors/RowNameEditor.d.ts +2 -5
  85. package/views/dist/field-row/editors/RowNameEditor.js +7 -12
  86. package/views/dist/field-row/editors/RowNumberEditor.d.ts +1 -1
  87. package/views/dist/field-row/editors/RowNumberEditor.js +4 -4
  88. package/views/dist/field-row/editors/RowPlaceEditor.js +3 -3
  89. package/views/dist/field-row/editors/RowRangeEditor.d.ts +2 -5
  90. package/views/dist/field-row/editors/RowRangeEditor.js +7 -14
  91. package/views/dist/field-row/editors/RowRelationEditor.js +3 -3
  92. package/views/dist/field-row/editors/RowSelectEditor.js +2 -2
  93. package/views/dist/field-row/editors/RowTextEditor.d.ts +1 -1
  94. package/views/dist/field-row/editors/RowTextEditor.js +3 -4
  95. package/views/dist/field-row/editors/RowValueListEditor.js +5 -5
  96. package/views/dist/field-row/field-row-button.d.ts +6 -9
  97. package/views/dist/field-row/field-row-button.js +1 -6
  98. package/views/dist/field-row/field-row-checkbox.d.ts +1 -1
  99. package/views/dist/field-row/row-target.d.ts +0 -7
  100. package/views/dist/field-row/row-target.js +0 -2
  101. package/views/dist/grid/chrome/GridAddColumn.d.ts +2 -1
  102. package/views/dist/grid/chrome/GridAddColumn.js +8 -66
  103. package/views/dist/grid/chrome/GridAggregateMenu.d.ts +5 -7
  104. package/views/dist/grid/chrome/GridAggregateMenu.js +20 -39
  105. package/views/dist/grid/chrome/GridCellEditors.d.ts +2 -2
  106. package/views/dist/grid/chrome/GridCellEditors.js +12 -12
  107. package/views/dist/grid/chrome/GridChipsEditor.js +3 -3
  108. package/views/dist/grid/chrome/GridColumnMenu.d.ts +11 -12
  109. package/views/dist/grid/chrome/GridColumnMenu.js +32 -93
  110. package/views/dist/grid/chrome/GridDateEditor.d.ts +6 -6
  111. package/views/dist/grid/chrome/GridDateEditor.js +3 -3
  112. package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -6
  113. package/views/dist/grid/chrome/GridGroupMenu.js +21 -62
  114. package/views/dist/grid/chrome/GridHeader.d.ts +1 -2
  115. package/views/dist/grid/chrome/GridHeader.js +2 -2
  116. package/views/dist/grid/chrome/GridLongTextEditor.d.ts +17 -38
  117. package/views/dist/grid/chrome/GridLongTextEditor.js +6 -7
  118. package/views/dist/grid/chrome/GridNameEditor.js +4 -4
  119. package/views/dist/grid/chrome/GridNumberEditor.d.ts +4 -5
  120. package/views/dist/grid/chrome/GridNumberEditor.js +3 -4
  121. package/views/dist/grid/chrome/GridPlaceEditor.d.ts +2 -5
  122. package/views/dist/grid/chrome/GridPlaceEditor.js +5 -5
  123. package/views/dist/grid/chrome/GridRangeEditor.d.ts +6 -12
  124. package/views/dist/grid/chrome/GridRangeEditor.js +7 -15
  125. package/views/dist/grid/chrome/GridRelationEditor.js +5 -5
  126. package/views/dist/grid/chrome/GridRow.js +0 -3
  127. package/views/dist/grid/chrome/GridRowActions.d.ts +1 -1
  128. package/views/dist/grid/chrome/GridRowActions.js +0 -5
  129. package/views/dist/grid/chrome/GridRowCells.js +9 -6
  130. package/views/dist/grid/chrome/GridSelectEditor.js +3 -3
  131. package/views/dist/grid/chrome/GridStructure.js +0 -1
  132. package/views/dist/grid/chrome/GridTable.js +1 -1
  133. package/views/dist/grid/chrome/GridTextEditor.d.ts +5 -7
  134. package/views/dist/grid/chrome/GridTextEditor.js +4 -17
  135. package/views/dist/grid/chrome/GridValueListEditor.js +4 -4
  136. package/views/dist/grid/chrome/grid-body-place.d.ts +2 -3
  137. package/views/dist/grid/chrome/grid-body-place.js +4 -8
  138. package/views/dist/grid/chrome/grid-button.d.ts +7 -10
  139. package/views/dist/grid/chrome/grid-button.js +1 -6
  140. package/views/dist/grid/chrome/grid-cell-classes.js +1 -1
  141. package/views/dist/grid/chrome/grid-column-menu-items.d.ts +4 -4
  142. package/views/dist/grid/chrome/grid-column-menu-items.js +10 -6
  143. package/views/dist/grid/chrome/grid-group-menu-parts.d.ts +5 -9
  144. package/views/dist/grid/chrome/grid-group-menu-parts.js +1 -3
  145. package/views/dist/grid/chrome/grid-hover.js +0 -1
  146. package/views/dist/grid/chrome/grid-menu-focus.d.ts +7 -31
  147. package/views/dist/grid/chrome/grid-menu-focus.js +7 -47
  148. package/views/dist/grid/chrome/grid-styles.d.ts +0 -3
  149. package/views/dist/grid/chrome/grid-styles.js +0 -1
  150. package/views/dist/grid/chrome/grid-table-props.d.ts +6 -10
  151. package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -4
  152. package/views/dist/grid/core/editing-controller.d.ts +2 -1
  153. package/views/dist/grid/core/editing-controller.js +10 -2
  154. package/views/dist/grid/core/refusal-sentence.d.ts +3 -0
  155. package/views/dist/grid/core/refusal-sentence.js +2 -2
  156. package/views/dist/grid/core/write-states.d.ts +3 -1
  157. package/views/dist/grid/core/write-states.js +6 -2
  158. package/views/dist/grid/grid.css +1 -1
  159. package/views/dist/model/body-frame.d.ts +0 -32
  160. package/views/dist/model/body-frame.js +1 -15
  161. package/views/dist/model/column-inspect.d.ts +5 -5
  162. package/views/dist/model/column-inspect.js +2 -2
  163. package/views/dist/panels/customize-body.d.ts +1 -10
  164. package/views/dist/panels/customize-body.js +0 -3
  165. package/views/dist/panels/filter/MenuSelect.js +0 -5
  166. package/views/dist/panels/filter/RangeFilterBody.js +0 -1
  167. package/views/dist/panels/filter/details.d.ts +1 -5
  168. package/views/dist/panels/filter/details.js +0 -13
  169. package/views/dist/panels/filter/filter-list.d.ts +0 -1
  170. package/views/dist/panels/filter/filter-list.js +1 -1
  171. package/views/dist/panels/panel-button.d.ts +10 -12
  172. package/views/dist/panels/panel-button.js +1 -6
  173. package/views/dist/panels/react/chrome.d.ts +0 -17
  174. package/views/dist/panels/react/chrome.js +0 -8
  175. package/views/dist/panels/react/customize-body.d.ts +9 -12
  176. package/views/dist/panels/react/customize-body.js +57 -11
  177. package/views/dist/panels/react/customize.d.ts +9 -12
  178. package/views/dist/panels/react/customize.js +3 -112
  179. package/views/dist/panels/react/filter/FilterEditor.d.ts +4 -18
  180. package/views/dist/panels/react/filter/FilterEditor.js +6 -330
  181. package/views/dist/panels/react/filter/FilterFieldList.d.ts +1 -1
  182. package/views/dist/panels/react/filter/FilterFieldList.js +27 -59
  183. package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +1 -11
  184. package/views/dist/panels/react/filter/PhoneFilterEditor.js +8 -144
  185. package/views/dist/panels/react/filter/editor-ctx.d.ts +1 -33
  186. package/views/dist/panels/react/filter/editor-ctx.js +5 -33
  187. package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -6
  188. package/views/dist/panels/react/filter/filter-part-body.js +0 -5
  189. package/views/dist/panels/react/filter/rule-writes.d.ts +1 -26
  190. package/views/dist/panels/react/filter/rule-writes.js +4 -95
  191. package/views/dist/panels/react/order-details.d.ts +1 -26
  192. package/views/dist/panels/react/order-details.js +3 -69
  193. package/views/dist/panels/react/panel-header.js +0 -1
  194. package/views/dist/panels/react/popover.d.ts +4 -7
  195. package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +2 -4
  196. package/views/dist/panels/react/quick/QuickFiltersPanel.js +16 -137
  197. package/views/dist/panels/react/sort/SortEditor.d.ts +4 -4
  198. package/views/dist/panels/react/sort/SortEditor.js +8 -245
  199. package/views/dist/panels/react/sort/SortFieldList.d.ts +1 -1
  200. package/views/dist/panels/react/sort/SortFieldList.js +11 -25
  201. package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +2 -2
  202. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -16
  203. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
  204. package/views/dist/panels/react/toolbar/ToolbarSave.js +0 -4
  205. package/views/dist/panels/react/toolbar/ToolbarSearch.js +0 -1
  206. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -3
  207. package/views/dist/panels/react/view-actions.js +0 -1
  208. package/views/dist/panels/react/views-row/FoldingViewRow.js +5 -9
  209. package/views/dist/panels/react/views-row/ViewCreatePill.js +0 -1
  210. package/views/dist/panels/react/views-row/ViewPicker.js +7 -43
  211. package/views/dist/panels/react/views-row/ViewPickerRow.js +0 -2
  212. package/views/dist/panels/react/views-row/menu-classes.d.ts +0 -4
  213. package/views/dist/panels/react/views-row/menu-classes.js +0 -2
  214. package/views/dist/panels/react.d.ts +5 -12
  215. package/views/dist/panels/react.js +5 -12
  216. package/views/dist/provider/ViewsProvider.d.ts +2 -46
  217. package/views/dist/provider/ViewsProvider.js +2 -22
  218. package/views/dist/provider/components.d.ts +153 -106
  219. package/views/dist/provider/context.d.ts +1 -21
  220. package/views/dist/provider/missing-slot.d.ts +3 -7
  221. package/views/dist/provider/missing-slot.js +2 -9
  222. package/views/dist/react.d.ts +1 -2
  223. package/views/dist/selection/SelectionBar.js +2 -3
  224. package/views/dist/styles.css +40 -168
  225. package/views/dist/styles.unlayered.css +40 -168
  226. package/views/docs/contract.md +99 -123
  227. package/views/docs/getting-started.md +222 -2
  228. package/views/docs/guides/cells.md +222 -2
  229. package/views/docs/guides/display.md +1 -1
  230. package/views/docs/guides/editors.md +235 -20
  231. package/views/docs/guides/ports.md +1 -1
  232. package/views/docs/guides/selection.md +1 -1
  233. package/views/docs/guides/the-grid.md +14 -16
  234. package/views/docs/guides/the-provider.md +9 -15
  235. package/views/docs/reference/cells.md +1 -1
  236. package/views/docs/reference/controls.md +28 -15
  237. package/views/docs/reference/editors-chips.md +2 -2
  238. package/views/docs/reference/editors-date.md +4 -4
  239. package/views/docs/reference/editors-location.md +4 -7
  240. package/views/docs/reference/editors-name.md +3 -5
  241. package/views/docs/reference/editors-number.md +10 -10
  242. package/views/docs/reference/editors-panel.md +3 -3
  243. package/views/docs/reference/editors-range.md +3 -5
  244. package/views/docs/reference/editors-relation.md +4 -4
  245. package/views/docs/reference/editors-select.md +3 -3
  246. package/views/docs/reference/editors-text.md +3 -4
  247. package/views/docs/reference/editors-value-list.md +3 -3
  248. package/views/docs/reference/field-row.md +1 -1
  249. package/views/docs/reference/grid.md +2 -2
  250. package/views/docs/reference/panels-react.md +20 -34
  251. package/views/docs/reference/react.md +11 -18
  252. package/views/docs/reference/views.md +5 -5
  253. package/views/skills/views/SKILL.md +1 -1
  254. package/views/dist/editors/relation-panel.d.ts +0 -69
  255. package/views/dist/editors/relation-panel.js +0 -46
  256. package/views/dist/grid/chrome/GridColumnColorSection.d.ts +0 -13
  257. package/views/dist/grid/chrome/GridColumnColorSection.js +0 -40
  258. package/views/dist/grid/chrome/GridColumnDateSection.d.ts +0 -28
  259. package/views/dist/grid/chrome/GridColumnDateSection.js +0 -23
  260. package/views/dist/grid/chrome/GridColumnDurationSection.d.ts +0 -23
  261. package/views/dist/grid/chrome/GridColumnDurationSection.js +0 -24
  262. package/views/dist/grid/chrome/GridColumnNumberSection.d.ts +0 -29
  263. package/views/dist/grid/chrome/GridColumnNumberSection.js +0 -27
  264. package/views/dist/grid/chrome/GridColumnPercentSection.d.ts +0 -16
  265. package/views/dist/grid/chrome/GridColumnPercentSection.js +0 -16
  266. package/views/dist/grid/chrome/GridColumnSortSection.d.ts +0 -38
  267. package/views/dist/grid/chrome/GridColumnSortSection.js +0 -33
  268. package/views/dist/grid/chrome/GridFlyout.d.ts +0 -44
  269. package/views/dist/grid/chrome/GridFlyout.js +0 -80
  270. package/views/dist/grid/chrome/GridMenuRow.d.ts +0 -15
  271. package/views/dist/grid/chrome/GridMenuRow.js +0 -15
  272. package/views/dist/grid/chrome/grid-menu-search.d.ts +0 -7
  273. package/views/dist/grid/chrome/grid-menu-search.js +0 -7
  274. package/views/dist/panels/react/GroupBucketsList.d.ts +0 -16
  275. package/views/dist/panels/react/GroupBucketsList.js +0 -44
  276. package/views/dist/panels/react/LayoutColumnsList.d.ts +0 -24
  277. package/views/dist/panels/react/LayoutColumnsList.js +0 -101
  278. package/views/dist/panels/react/PopoverColumnDetail.d.ts +0 -11
  279. package/views/dist/panels/react/PopoverColumnDetail.js +0 -24
  280. package/views/dist/panels/react/drag.d.ts +0 -2
  281. package/views/dist/panels/react/drag.js +0 -5
  282. package/views/dist/panels/react/layout-detail.d.ts +0 -4
  283. package/views/dist/panels/react/layout-detail.js +0 -29
  284. package/views/dist/panels/react/root-list.d.ts +0 -6
  285. package/views/dist/panels/react/root-list.js +0 -31
  286. package/views/dist/panels/react/sort/use-sort-drag.d.ts +0 -17
  287. package/views/dist/panels/react/sort/use-sort-drag.js +0 -39
  288. package/views/dist/panels/react/view-footer.d.ts +0 -20
  289. package/views/dist/panels/react/view-footer.js +0 -41
@@ -14,7 +14,7 @@ import { Radio, RadioGroup } from "../radio/radio.js";
14
14
  import { SheetStep } from "../sheet/bottom-sheet.js";
15
15
  import { reduced, slideTime, useGlide } from "./glide.js";
16
16
  import { CUSTOMIZE_ATTRS, customizeWornOf } from "./looks.js";
17
- import { columnsSay, findColumns, moveColumn, setShown } from "./rules.js";
17
+ import { columnOpens, columnOpensBySettings, columnsSay, findColumns, moveColumn, setShown } from "./rules.js";
18
18
  import { customizeWords } from "./words.js";
19
19
  export function useCustomizeWorn() {
20
20
  const [el, setEl] = React.useState(null), [worn, setWorn] = React.useState(() => customizeWornOf(null));
@@ -40,7 +40,7 @@ const LAYOUT_MARKS = {
40
40
  };
41
41
  export const layoutMark = (id) => (LAYOUT_MARKS[id] ? glyph([LAYOUT_MARKS[id]]) : undefined);
42
42
  export function useCustomize(props) {
43
- const { view, onViewChange, layouts, filter, sort, group, changed = false, onReset, onSave, pending = false, stale = false, exportCount, onCopyLink, onExport, toggles, layoutSettings, columnsReset, onClose, onScreenChange } = props;
43
+ const { view, onViewChange, layouts, filter, sort, group, changed = false, onReset, onSave, pending = false, stale = false, exportCount, onCopyLink, onExport, toggles, layoutSettings, columnsReset, onLineChange, columnsFoot, fields = [], foldFields = false, onClose, onScreenChange } = props;
44
44
  const w = customizeWords(props.words);
45
45
  const host = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (host || small ? "phone" : "computer")) === "phone";
46
46
  const inPane = React.useContext(InPane);
@@ -53,9 +53,11 @@ export function useCustomize(props) {
53
53
  const SCREEN_OF = { [w.layout]: "layout", [w.columns]: "columns", [w.filter]: "filter", [w.sort]: "sort", [w.group]: "group" };
54
54
  const handed = { filter, sort, group };
55
55
  const hasLayout = layouts.length > 0 || !!layoutSettings, hasColumns = view.columns.length > 0;
56
- const opens = (to) => to === "list" || (to === "layout" ? hasLayout : to === "columns" ? hasColumns : handed[to]?.opens != null);
56
+ const folded = foldFields && !filter && fields.length > 0;
57
+ const opens = (to) => to === "list" || (to === "layout" ? hasLayout : to === "columns" ? hasColumns : to === "filter" && folded ? true : handed[to]?.opens != null);
57
58
  const [screen, setScreen] = React.useState(() => (props.screen && opens(props.screen) ? props.screen : "list")), [back, setBack] = React.useState(false);
58
- const [choosing, setChoosing] = React.useState(null);
59
+ const [choosing, setChoosing] = React.useState(null), [column, setColumn] = React.useState(null);
60
+ const [fieldKey, setFieldKey] = React.useState(null);
59
61
  const [find, setFind] = React.useState("");
60
62
  const [focusTo, setFocusTo] = React.useState(null), root = React.useRef(null), backButton = React.useRef(null);
61
63
  const go = (to) => {
@@ -64,11 +66,13 @@ export function useCustomize(props) {
64
66
  setBack(false);
65
67
  setScreen(to);
66
68
  setChoosing(null);
69
+ setColumn(null);
70
+ setFieldKey(null);
67
71
  setFocusTo("back");
68
72
  setFind("");
69
73
  onScreenChange?.(to);
70
74
  };
71
- const goBack = () => { const from = screen; setBack(true); setScreen("list"); setChoosing(null); setFocusTo(from === "list" ? null : NAMES[from]); setFind(""); onScreenChange?.("list"); };
75
+ const goBack = () => { const from = screen; setBack(true); setScreen("list"); setChoosing(null); setColumn(null); setFieldKey(null); setFocusTo(from === "list" ? null : NAMES[from]); setFind(""); onScreenChange?.("list"); };
72
76
  React.useLayoutEffect(() => {
73
77
  if (!focusTo || phone)
74
78
  return;
@@ -123,20 +127,85 @@ export function useCustomize(props) {
123
127
  ? [...toggleRows(toggles.filter((t) => !t.section)),
124
128
  ...sectionsOfToggles(toggles).map((s) => ({ kind: "group", heading: s, entries: toggleRows(toggles.filter((t) => t.section === s)) }))]
125
129
  : [{ kind: "check", label: w.showCounts, checked: view.counts, onCheckedChange: (c) => change({ ...latest.view, counts: c }) }];
130
+ const fieldRows = new Map();
131
+ const fieldRow = (f) => {
132
+ const entry = f.disabled != null
133
+ ? { icon: f.icon ?? null, label: f.label, disabled: f.disabled }
134
+ : { kind: "actions", icon: f.icon ?? null, label: f.label, detail: f.says, inForce: f.inForce, entries: [] };
135
+ if (f.disabled == null)
136
+ fieldRows.set(entry, f.key);
137
+ return entry;
138
+ };
139
+ const fieldEntries = (fs, line = false) => {
140
+ const heads = [...new Set(fs.flatMap((f) => (f.section ? [f.section] : [])))];
141
+ return [...fs.filter((f) => !f.section).map(fieldRow),
142
+ ...heads.map((s) => ({ kind: "group", heading: s, entries: fs.filter((f) => f.section === s).map(fieldRow) })),
143
+ ...(line && heads.length ? [{ kind: "separator" }] : [])];
144
+ };
145
+ const filterFields = fields.filter((f) => f.place === "filters"), afterFields = fields.filter((f) => f.place === "after");
146
+ const inForceFields = filterFields.filter((f) => f.inForce).length;
147
+ const foldedFilter = folded ? { says: inForceFields ? String(inForceFields) : w.none, inForce: inForceFields > 0 } : undefined;
126
148
  const sections = [
127
149
  ...(hasLayout ? [{ kind: "actions", icon: layout?.mark, label: w.layout, detail: layout?.name, entries: [] }] : []),
128
150
  ...(hasColumns ? [{ kind: "actions", icon: COLUMNS, label: w.columns, detail: columnsSay(view.columns, w), entries: [] }] : []),
129
- ...section(w.filter, _jsx(Icon, { name: "filter" }), filter), ...section(w.sort, _jsx(Icon, { name: "sort" }), sort), ...section(w.group, GROUP, group),
151
+ ...(folded ? [] : fieldEntries(filterFields, true)),
152
+ ...section(w.filter, _jsx(Icon, { name: "filter" }), filter ?? foldedFilter), ...section(w.sort, _jsx(Icon, { name: "sort" }), sort), ...section(w.group, GROUP, group),
153
+ ...(folded ? [] : fieldEntries(afterFields)),
130
154
  ...(checks.length ? [{ kind: "separator" }, ...checks] : []),
131
155
  ];
132
- const opened = (e) => { if ("label" in e && SCREEN_OF[e.label])
156
+ const field = screen === "filter" && fieldKey ? fields.find((f) => f.key === fieldKey && f.disabled == null) : undefined;
157
+ React.useLayoutEffect(() => {
158
+ if (!fieldKey || field)
159
+ return;
160
+ setFieldKey(null);
161
+ setBack(true);
162
+ if (!folded) {
163
+ setScreen("list");
164
+ onScreenChange?.("list");
165
+ }
166
+ }, [fieldKey, field, folded, onScreenChange]);
167
+ const openField = (key) => {
168
+ const f = fields.find((x) => x.key === key);
169
+ if (!f || f.disabled != null)
170
+ return;
171
+ setBack(false);
172
+ setScreen("filter");
173
+ setFieldKey(key);
174
+ setChoosing(null);
175
+ setColumn(null);
176
+ setFocusTo("back");
177
+ setFind("");
178
+ if (screen !== "filter")
179
+ onScreenChange?.("filter");
180
+ f.onOpen?.();
181
+ };
182
+ const backFromField = () => {
183
+ const label = field?.label ?? null;
184
+ setBack(true);
185
+ setFieldKey(null);
186
+ setFocusTo(label);
187
+ if (!folded) {
188
+ setScreen("list");
189
+ onScreenChange?.("list");
190
+ }
191
+ };
192
+ const opened = (e) => { const key = fieldRows.get(e); if (key) {
193
+ openField(key);
194
+ return;
195
+ } if ("label" in e && SCREEN_OF[e.label])
133
196
  go(SCREEN_OF[e.label]); };
134
197
  const footer = [
135
198
  ...(onCopyLink ? [{ icon: _jsx(Icon, { name: "link" }), label: w.copyLink, onSelect: onCopyLink }] : []),
136
199
  ...(onExport ? [{ icon: _jsx(Icon, { name: "export" }), label: w.export, ...(exportCount != null ? { count: exportCount } : {}), onSelect: onExport }] : []),
137
200
  ];
138
201
  const words = (size) => (_jsxs(_Fragment, { children: [stale && _jsx(Notice, { className: "o-customize-stale", children: w.stale }), _jsxs("div", { className: "o-customize-words", children: [_jsx(Button, { kind: "link", size: size, onClick: onReset, disabled: pending, children: w.reset }), onSave && _jsx(Button, { kind: "link", size: size, onClick: onSave, disabled: pending, children: w.save })] })] }));
139
- const allChoices = layoutSettings ? [...layoutSettings.choices, ...(layoutSettings.personal?.choices ?? [])] : [];
202
+ const col = screen === "columns" && column ? view.columns.find((c) => c.id === column && columnOpens(c)) : undefined;
203
+ React.useLayoutEffect(() => { if (column && !col) {
204
+ setColumn(null);
205
+ setChoosing(null);
206
+ setBack(true);
207
+ } }, [column, col]);
208
+ const allChoices = screen === "layout" ? (layoutSettings ? [...layoutSettings.choices, ...(layoutSettings.personal?.choices ?? [])] : []) : col?.settings?.choices ?? [];
140
209
  const choiceRows = new Map();
141
210
  const choiceOpened = (e) => { const c = choiceRows.get(e); if (c) {
142
211
  setBack(false);
@@ -151,7 +220,7 @@ export function useCustomize(props) {
151
220
  choiceRows.set(entry, c);
152
221
  return entry;
153
222
  };
154
- const choice = screen === "layout" ? allChoices.find((c) => c.key === choosing) : undefined;
223
+ const choice = allChoices.find((c) => c.key === choosing);
155
224
  const backFromChoice = () => { setBack(true); setFocusTo(choice?.label ?? null); setChoosing(null); };
156
225
  const choiceLevel = choice && (() => {
157
226
  const rows = [{ kind: "pick", value: choice.value, choices: choice.options.map((o) => ({ value: o.value, label: o.label })),
@@ -160,11 +229,11 @@ export function useCustomize(props) {
160
229
  return phone ? _jsx(MenuList, { label: choice.label, entries: rows, words: w.rows }) : _jsx(MenuListPanelRows, { label: choice.label, entries: rows, words: w.rows });
161
230
  })();
162
231
  const heading = (label, act) => (_jsxs("div", { className: "o-customize-heading", children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: label }), act?.map((a) => _jsx(Button, { kind: "link", size: "line", onClick: a.onPress, children: a.label }, a.label))] }));
163
- const ownSettings = (settings, name) => {
232
+ const ownSettings = (settings, name, lead = [], own) => {
164
233
  const bare = settings.toggles.filter((t) => !t.section), sectioned = sectionsOfToggles(settings.toggles);
165
- const first = [...settings.choices.map(choiceRow), ...toggleRows(bare)];
234
+ const first = [...lead, ...settings.choices.map(choiceRow), ...toggleRows(bare)];
166
235
  const you = settings.personal, yours = you ? [...you.choices.map(choiceRow), ...toggleRows(you.toggles), ...(you.onReset ? [{ icon: null, label: w.personalReset, onSelect: you.onReset }] : [])] : [];
167
- return _jsxs(_Fragment, { children: [first.length > 0 && _jsxs(_Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: name }), rowsList(w.layoutSettings(name), first)] }), sectioned.map((s) => _jsxs(React.Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: s }), rowsList(s, toggleRows(settings.toggles.filter((t) => t.section === s)))] }, s)), you && yours.length > 0 && _jsxs(_Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: you.label }), rowsList(you.label, yours)] })] });
236
+ return _jsxs(_Fragment, { children: [first.length > 0 && _jsxs(_Fragment, { children: [!own && _jsx("p", { className: "o-list-heading o-customize-heading-words", children: name }), rowsList(own?.list ?? w.layoutSettings(name), first)] }), sectioned.map((s) => _jsxs(React.Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: s }), rowsList(s, toggleRows(settings.toggles.filter((t) => t.section === s)))] }, s)), you && yours.length > 0 && _jsxs(_Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: you.label }), rowsList(you.label, yours)] })] });
168
237
  };
169
238
  const layoutScreen = (_jsxs(_Fragment, { children: [_jsx(RadioGroup, { tiles: true, "aria-label": w.layout, value: view.layout, onValueChange: (v) => { if (typeof v === "string")
170
239
  change({ ...latest.view, layout: v }); }, children: layouts.map((l) => _jsx(Radio, { value: l.id, mark: l.mark, label: l.name, disabled: l.later }, l.id)) }), layoutSettings ? ownSettings(layoutSettings, layout?.name ?? w.layout) : layout?.id === "table" && _jsxs(_Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: layout.name }), rowsList(w.layoutSettings(layout.name), [
@@ -174,10 +243,23 @@ export function useCustomize(props) {
174
243
  const searching = find.trim() !== "", eyes = worn.columns === "eye";
175
244
  const found = findColumns(view.columns, find);
176
245
  const gripped = (columns, shown) => (searching || (!shown && !eyes) ? [] : columns.filter((c) => c.shown === shown && !c.locked));
246
+ const columnRows = new Map();
247
+ const openColumn = (id) => { setBack(false); setColumn(id); setChoosing(null); setFocusTo("back"); setFind(""); };
248
+ const columnOpened = (e) => { const id = columnRows.get(e); if (id)
249
+ openColumn(id); };
250
+ const lineMark = glyph(["M9 10l-5 5l5 5", "M20 4v7a4 4 0 0 1 -4 4h-12"]);
177
251
  const block = (shown) => {
178
252
  const grips = new Set(gripped(found, shown).map((c) => c.id));
179
- return found.filter((c) => c.shown === shown).map((c) => ({ kind: "check", label: c.label, icon: c.mark, checked: held[c.id] ?? c.shown, grip: grips.has(c.id),
180
- disabled: c.locked ? w.alwaysShown : undefined, onCheckedChange: (on) => press([c.id], on) }));
253
+ return found.filter((c) => c.shown === shown).map((c) => {
254
+ const entry = { kind: "check", label: c.label, icon: c.mark, checked: held[c.id] ?? c.shown, grip: grips.has(c.id),
255
+ disabled: c.locked ? w.alwaysShown : undefined, onCheckedChange: (on) => press([c.id], on),
256
+ ...(columnOpens(c) && { opens: w.columnSettings(c.label) }),
257
+ ...(c.line && { toggle: { icon: lineMark, label: c.line.on ? w.newLineOn(c.label) : w.newLineStart(c.label), on: c.line.on, onPress: () => onLineChange?.(c.id),
258
+ ...(c.line.refused && { disabled: c.line.refused }) } }) };
259
+ if (columnOpens(c))
260
+ columnRows.set(entry, c.id);
261
+ return entry;
262
+ });
181
263
  };
182
264
  const moveIn = (shown) => (from, to) => {
183
265
  const g = gripped(latest.view.columns, shown);
@@ -186,8 +268,8 @@ export function useCustomize(props) {
186
268
  };
187
269
  const ticks = eyes ? "eye" : "switch";
188
270
  const rowsOf = (label, shown) => phone
189
- ? _jsx(MenuList, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), words: w.rows })
190
- : _jsx(MenuListPanelRows, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), words: w.rows });
271
+ ? _jsx(MenuList, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen: columnOpened, words: w.rows })
272
+ : _jsx(MenuListPanelRows, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen: columnOpened, words: w.rows });
191
273
  const canHide = view.columns.some((c) => c.shown && !c.locked), canShow = view.columns.some((c) => !c.shown);
192
274
  const shownHere = found.some((c) => c.shown), hiddenHere = found.some((c) => !c.shown);
193
275
  const typed = (e) => setFind(e.target.value);
@@ -197,26 +279,49 @@ export function useCustomize(props) {
197
279
  ...(!searching && canHide ? [{ label: w.hideAll, onPress: () => press(latest.view.columns.filter((c) => c.shown && !c.locked).map((c) => c.id), false) }] : []),
198
280
  ...(!searching && columnsReset ? [{ label: w.columnsReset, onPress: columnsReset }] : []),
199
281
  ];
200
- const columnsScreen = (_jsxs(_Fragment, { children: [phone && columnsSearch, shownHere && _jsxs(_Fragment, { children: [heading(w.shownHeading, shownActs), rowsOf(w.shownHeading, true)] }), hiddenHere && _jsxs(_Fragment, { children: [heading(w.hiddenHeading, !searching && canShow ? [{ label: w.showAll, onPress: () => press(latest.view.columns.filter((c) => !c.shown).map((c) => c.id), true) }] : undefined), rowsOf(w.hiddenHeading, false)] }), !found.length && _jsx("p", { className: "o-customize-none", children: w.noColumn(find.trim()) })] }));
282
+ const columnsScreen = (_jsxs(_Fragment, { children: [phone && columnsSearch, shownHere && _jsxs(_Fragment, { children: [heading(w.shownHeading, shownActs), rowsOf(w.shownHeading, true)] }), hiddenHere && _jsxs(_Fragment, { children: [heading(w.hiddenHeading, !searching && canShow ? [{ label: w.showAll, onPress: () => press(latest.view.columns.filter((c) => !c.shown).map((c) => c.id), true) }] : undefined), rowsOf(w.hiddenHeading, false)] }), !found.length && _jsx("p", { className: "o-customize-none", children: w.noColumn(find.trim()) }), columnsFoot != null && _jsx("div", { className: "o-customize-foot-rows", children: columnsFoot })] }));
283
+ const backFromColumn = () => { setBack(true); setFocusTo(col?.label ?? null); setColumn(null); setChoosing(null); };
284
+ const columnLevel = col && (_jsxs(_Fragment, { children: [ownSettings(col.settings ?? { choices: [], toggles: [] }, col.label, col.locked ? [] : [{ kind: "check", label: w.columnShown, checked: held[col.id] ?? col.shown, onCheckedChange: (on) => press([col.id], on) }], { list: w.columnSettings(col.label) }), col.rows != null && _jsxs("div", { className: "o-customize-rows", children: [(!col.locked || columnOpensBySettings(col)) && _jsx("div", { role: "separator", className: "o-list-sep" }), col.rows] })] }));
285
+ const rowsOfField = (label, rows) => (phone
286
+ ? _jsx(MenuList, { label: label, entries: rows, words: w.rows }) : _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "box", words: w.rows }));
287
+ const fieldScreen = field && (() => {
288
+ const o = field.opens;
289
+ if ("pick" in o)
290
+ return o.pick.choices.length === 0 ? _jsx("p", { className: "o-customize-none", children: w.nothingToPick })
291
+ : rowsOfField(field.label, [{ kind: "pick", value: o.pick.value, choices: o.pick.choices, onChoose: (v) => { if (v !== o.pick.value)
292
+ o.pick.onChoose(v); backFromField(); } }]);
293
+ if ("check" in o)
294
+ return o.check.choices.length === 0 ? _jsx("p", { className: "o-customize-none", children: w.nothingToPick })
295
+ : rowsOfField(field.label, o.check.choices.map((c) => ({ kind: "check", label: c.label, ...(c.mark != null && { icon: c.mark }), checked: o.check.values.includes(c.value),
296
+ onCheckedChange: (on) => o.check.onChange(on ? [...o.check.values, c.value] : o.check.values.filter((v) => v !== c.value)) })));
297
+ return typeof o.body === "function" ? o.body(backFromField) : o.body;
298
+ })();
299
+ const foldedScreen = folded && _jsx(_Fragment, { children: phone
300
+ ? _jsx(MenuList, { label: w.filter, entries: [...fieldEntries(filterFields), ...fieldEntries(afterFields)], onOpen: opened, words: w.rows })
301
+ : _jsx(MenuListPanelRows, { label: w.filter, entries: [...fieldEntries(filterFields), ...fieldEntries(afterFields)], onOpen: opened, words: w.rows }) });
201
302
  const content = screen === "list"
202
303
  ? phone ? _jsx(MenuList, { label: w.list, entries: sections, onOpen: opened, words: w.rows }) : _jsx(MenuListPanelRows, { label: w.list, entries: sections, ticks: "switch", onOpen: opened, words: w.rows })
203
- : screen === "layout" ? choiceLevel ?? layoutScreen : screen === "columns" ? columnsScreen : handed[screen]?.opens;
304
+ : screen === "layout" ? choiceLevel ?? layoutScreen : screen === "columns" ? choiceLevel ?? columnLevel ?? columnsScreen
305
+ : screen === "filter" && (field || folded) ? fieldScreen ?? foldedScreen : handed[screen]?.opens;
204
306
  const form = phone ? "phone" : "computer";
205
- const level = choice ? { name: choice.label, back: backFromChoice } : screen !== "list" ? handed[screen]?.level ?? null : null, backTo = level?.back ?? goBack;
307
+ const fieldLevel = field && "body" in field.opens ? field.opens.level ?? null : null;
308
+ const level = choice ? { name: choice.label, back: backFromChoice } : col ? { name: col.label, back: backFromColumn }
309
+ : field ? fieldLevel ?? { name: field.label, back: backFromField } : screen !== "list" ? handed[screen]?.level ?? null : null, backTo = level?.back ?? goBack;
206
310
  const named = worn.head === "name" && view.name !== "";
207
311
  const name = screen === "list" ? (named ? view.name : w.title) : level?.name ?? NAMES[screen];
208
312
  const titled = !named;
313
+ const step = choice ? (col ? `columns:${col.id}:${choice.key}` : `layout:${choice.key}`) : col ? `columns:${col.id}` : field ? `field:${field.key}` : screen;
209
314
  if (phone) {
210
- const body = (_jsx("div", { ref: placeRoot, className: "o-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(SheetStep, { step: choice ? `layout:${choice.key}` : screen, back: back, children: _jsx("div", { className: "o-customize-step", children: content }) }) }));
315
+ const body = (_jsx("div", { ref: placeRoot, className: "o-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(SheetStep, { step: step, back: back, children: _jsx("div", { className: "o-customize-step", children: content }) }) }));
211
316
  const foot = screen === "list" && (changed || footer.length) ? (_jsxs("div", { className: "o-customize-foot", ...MENU_LIST_CARD_FRAME, children: [changed && words("44"), footer.length > 0 && _jsx(MenuList, { label: w.share, entries: footer, words: w.rows })] })) : undefined;
212
- return { body, title: name, head: screen === "list" ? { close: true } : { onBack: backTo, close: titled }, foot };
317
+ return { body, title: name, head: screen === "list" ? { close: true } : { onBack: backTo, close: titled }, foot, level };
213
318
  }
214
319
  const title = (words) => (inPane ? _jsx(PaneTitle, { children: words }) : _jsx("h2", { className: "o-pane-title", children: words }));
215
320
  const xButton = (extra) => _jsx(Button, { kind: "quiet", shape: "icon", size: "sm", "aria-label": w.close, icon: _jsx(Icon, { name: "x" }), ...extra });
216
321
  const close = inPane ? _jsx(PaneClose, { render: xButton() }) : onClose ? xButton({ onClick: onClose }) : null;
217
322
  const head = screen !== "list" ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-screen", children: [_jsx(Button, { ref: backButton, kind: "quiet", shape: "icon", size: "sm", "aria-label": w.back, icon: _jsx(Icon, { name: "left" }), onClick: backTo }), _jsx("span", { className: "o-customize-title", children: title(name) }), titled && close] })) : titled ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-title", children: [_jsx("span", { className: "o-customize-title", children: title(w.title) }), close] })) : (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-name", children: [hasLayout && _jsx(Button, { kind: "outline", shape: "icon", size: "sm", "aria-label": w.layoutButton(layout?.name ?? ""), icon: layout?.mark, onClick: () => go("layout") }), _jsx(ViewName, { name: view.name, label: w.viewName, onRename: (n) => change({ ...latest.view, name: n }) })] }));
218
- const parts = (_jsxs(_Fragment, { children: [head, screen === "columns" && columnsSearch, _jsx(PaneBody, { children: _jsx("div", { ref: placeRoot, className: "o-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: content }) }), screen === "list" && changed && words("xs"), footer.length > 0 && _jsx(PaneFoot, { children: _jsx(MenuListPanelRows, { label: w.share, entries: footer, words: w.rows }) })] }));
219
- return { body: inPane ? parts : _jsx("div", { className: "o-customize-frame", children: parts }), title: name, head: {} };
323
+ const parts = (_jsxs(_Fragment, { children: [head, screen === "columns" && !col && columnsSearch, _jsx(PaneBody, { children: _jsx("div", { ref: placeRoot, className: "o-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(React.Fragment, { children: content }, step) }) }), screen === "list" && changed && words("xs"), footer.length > 0 && _jsx(PaneFoot, { children: _jsx(MenuListPanelRows, { label: w.share, entries: footer, words: w.rows }) })] }));
324
+ return { body: inPane ? parts : _jsx("div", { className: "o-customize-frame", children: parts }), title: name, head: {}, level };
220
325
  }
221
326
  function ViewName({ name, label, onRename }) {
222
327
  const [draft, setDraft] = React.useState(name);
@@ -12,7 +12,4 @@ export declare function customizeWordsOf(say: ViewsMessageResolver): CustomizeWo
12
12
  * refused one writes nothing) and its columns that differs. Columns, one or several shown or hidden (Hide all, Show all) or moved,
13
13
  * through ViewKit's own, in one change. */
14
14
  export declare function customizeWriteOf(p: ViewsCustomizeBodyProps, own: CustomizeBodyOwn, now: CustomizeView, next: CustomizeView): (() => void) | null;
15
- /** What the kit's Customize can't draw, which ViewKit's own Customize does: a column with its own settings, the field editor's rows,
16
- * a card layout's line breaks. */
17
- export declare function customizeStepsAside(p: ViewsCustomizeBodyProps): boolean;
18
15
  export declare function MapCustomizeBody(props: ViewsCustomizeBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { resolveViewsMessage } from "../../contract.js";
5
5
  import { ViewsContext } from "../../provider/context.js";
@@ -18,6 +18,7 @@ import { sortEditorPropsOf, sortEditorWordsOf } from "../sort-editor/map-sort-bo
18
18
  import { sortLabel } from "../sort-editor/rules.js";
19
19
  import { useSortEditor } from "../sort-editor/sort-editor.js";
20
20
  import { layoutMark, useCustomize } from "./customize.js";
21
+ import { DateRangeBody, useTimeRange } from "./map-ranges.js";
21
22
  const BACK = ["M5 12l14 0", "M5 12l6 6", "M5 12l6 -6"];
22
23
  export function customizeWordsOf(say) {
23
24
  return {
@@ -55,6 +56,11 @@ export function customizeWordsOf(say) {
55
56
  columnsReset: say({ key: "views.panels.columns-reset" }),
56
57
  toggleReset: (label) => say({ key: "views.panels.toggle-reset", values: { label } }),
57
58
  stale: say({ key: "views.panels.view-stale" }),
59
+ columnShown: say({ key: "views.panels.customize-shown-fields" }),
60
+ columnSettings: (label) => say({ key: "views.panels.column-settings", values: { label } }),
61
+ newLineOn: (label) => say({ key: "views.panels.new-line-on", values: { label } }),
62
+ newLineStart: (label) => say({ key: "views.panels.new-line-start", values: { label } }),
63
+ nothingToPick: say({ key: "views.panels.filter-no-options" }),
58
64
  rows: {
59
65
  move: (label) => say({ key: "views.panels.sort-move", values: { label } }),
60
66
  howKeys: say({ key: "views.panels.list-move-keys" }),
@@ -65,7 +71,18 @@ export function customizeWordsOf(say) {
65
71
  },
66
72
  };
67
73
  }
68
- const columnsOf = (p) => (p.columns?.items ?? []).map((c) => ({ id: c.id, label: c.label, shown: !c.hidden, locked: !c.hideable || !!c.fixed, mark: c.icon }));
74
+ const columnsOf = (p, say) => {
75
+ const cols = p.columns;
76
+ return (cols?.items ?? []).map((c) => {
77
+ const rows = cols?.columnMenu?.(c.id, p.onDone);
78
+ const settings = c.settings && (c.settings.choices.length > 0 || c.settings.toggles.length > 0)
79
+ ? { choices: c.settings.choices.map(choiceOf), toggles: c.settings.toggles.map(toggleOf) } : undefined;
80
+ const refused = c.hidden ? say({ key: "views.panels.new-line-hidden" }) : c.id === cols?.firstFieldId ? say({ key: "views.panels.new-line-first" }) : undefined;
81
+ return { id: c.id, label: c.label, shown: !c.hidden, locked: !c.hideable || !!c.fixed, mark: c.icon,
82
+ ...(settings && { settings }), ...(rows != null && { rows }),
83
+ ...(cols?.onStartsLineChange && { line: { on: !!c.startsLine, ...(refused && { refused }) } }) };
84
+ });
85
+ };
69
86
  export function customizeWriteOf(p, own, now, next) {
70
87
  if (next.name !== now.name)
71
88
  return own.onRename ? () => own.onRename(next.name) : null;
@@ -80,11 +97,6 @@ export function customizeWriteOf(p, own, now, next) {
80
97
  return null;
81
98
  return () => viewKit.onColumnsChange(next.columns.map((c) => ({ id: c.id, hidden: !c.shown })));
82
99
  }
83
- export function customizeStepsAside(p) {
84
- const cols = p.columns;
85
- return !!cols && (cols.items.some((c) => !!c.settings && (c.settings.choices.length > 0 || c.settings.toggles.length > 0))
86
- || !!cols.columnMenu || cols.footer != null || !!cols.onStartsLineChange);
87
- }
88
100
  const toggleOf = (t) => ({ key: t.key, label: t.label, value: t.value, onChange: t.onChange, ...(t.icon != null && { icon: t.icon }), ...(t.reset && { reset: t.reset }), ...(t.section && { section: t.section }) });
89
101
  const choiceOf = (c) => ({ key: c.key, label: c.label, value: c.value, options: [...c.options], onChange: c.onChange });
90
102
  function layoutSettingsOf(layout) {
@@ -126,15 +138,33 @@ export function MapCustomizeBody(props) {
126
138
  const grouping = useGroupEditor(groupProps);
127
139
  const group = p.group && { says: groupLabel(groupProps.group, groupProps.fields, w.none), inForce: p.group.group.value !== "none",
128
140
  opens: grouping.body, level: grouping.level };
129
- const view = { name: onRename ? name ?? "" : "", layout: p.layout?.value ?? "", columns: columnsOf(p), counts: false, freeze: false, wrap: false };
141
+ const view = { name: onRename ? name ?? "" : "", layout: p.layout?.value ?? "", columns: columnsOf(p, say), counts: false, freeze: false, wrap: false };
130
142
  const shared = p.view, kit = p.foot === "kit";
131
143
  const foot = shared ? (shared.changes > 0 && p.foot !== "none" ? {
132
144
  changed: true, onReset: shared.onReset, ...(shared.canPublish && { onSave: shared.onPublish }), pending: shared.pending, stale: shared.stale,
133
145
  words: { reset: say({ key: kit ? "views.panels.view-clear" : "views.panels.view-reset" }), save: say({ key: kit ? "views.panels.view-save" : "views.panels.view-publish" }) },
134
146
  } : {}) : p.onClear && p.foot !== "none" ? { changed: true, onReset: p.onClear, words: { reset: say({ key: "views.panels.view-clear" }) } } : {};
135
147
  const { words: footWords, ...footProps } = foot;
136
- const level = p.page === "group" ? group?.level : p.page === "sort" ? sort?.level : p.page === "filter" ? filter?.level : null;
137
- useToldStep({ head: { onBack: phone ? level?.back : undefined }, title: level?.name }, p.onStepChange);
148
+ const timeField = p.fields?.items.find((f) => f.time);
149
+ const timeRange = useTimeRange(timeField?.time, timeField?.label ?? "", phone);
150
+ const fields = (p.fields?.items ?? []).map((f) => {
151
+ const base = { key: f.key, label: f.label, ...(f.icon != null && { icon: f.icon }), ...(f.section !== undefined && { section: f.section }), says: f.says,
152
+ inForce: f.inForce, ...(f.disabled !== undefined && { disabled: f.disabled }), place: f.place, ...(f.onOpen && { onOpen: f.onOpen }) };
153
+ const choices = (os) => os.map((o) => ({ value: o.value, label: o.label, ...(o.mark != null && { mark: o.mark }) }));
154
+ if (f.pick)
155
+ return { ...base, opens: { pick: { value: f.pick.value, choices: choices(f.pick.options), onChoose: f.pick.onChange } } };
156
+ if (f.check) {
157
+ const check = f.check;
158
+ return { ...base, opens: { check: { values: [...check.value], choices: choices(check.options), onChange: (v) => check.onChange(v) } } };
159
+ }
160
+ if (f.time && f === timeField) {
161
+ const onOpen = f.onOpen;
162
+ return { ...base, onOpen: () => { timeRange.open(); onOpen?.(); }, opens: { body: timeRange.body, level: timeRange.level } };
163
+ }
164
+ if (f.dates)
165
+ return { ...base, opens: { body: _jsx(DateRangeBody, { dates: f.dates, clear: say({ key: "views.panels.date-range-clear" }), phone: phone }) } };
166
+ return { ...base, opens: { body: f.body ?? null } };
167
+ });
138
168
  const parts = useCustomize({
139
169
  view, onViewChange: (next) => customizeWriteOf(p, { onRename }, view, next)?.(),
140
170
  layouts: [...(p.layout?.options ?? []).map((o) => ({ id: o.value, name: o.label, mark: layoutMark(o.value) })),
@@ -143,12 +173,17 @@ export function MapCustomizeBody(props) {
143
173
  toggles: p.toggles.map(toggleOf),
144
174
  ...(p.layout && { layoutSettings: layoutSettingsOf(p.layout) }),
145
175
  ...(p.columns?.reset && { columnsReset: p.columns.reset }),
176
+ ...(p.columns?.onStartsLineChange && { onLineChange: p.columns.onStartsLineChange }),
177
+ ...(p.columns?.footer != null && { columnsFoot: p.columns.footer }),
178
+ ...(fields.length > 0 && { fields, foldFields: p.fields.folded }),
146
179
  ...footProps,
147
180
  ...(exportCount !== undefined && { exportCount }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }),
148
181
  onClose: p.onDone, onScreenChange: p.onPageChange, screen: p.page, form: p.form,
149
182
  words: { ...w, ...(p.layout && { layout: p.layout.label }), ...(p.columns && { columns: p.columns.label }),
150
183
  ...(p.layout && p.layout.value !== "table" && { shownHeading: say({ key: "views.panels.customize-shown-fields" }) }), ...footWords },
151
184
  });
185
+ const told = parts.level;
186
+ useToldStep({ head: { onBack: phone ? told?.back : undefined }, title: told?.name }, p.onStepChange);
152
187
  const setParts = React.useContext(SheetPartsFrom);
153
188
  React.useLayoutEffect(() => { if (phone && setParts)
154
189
  setParts({ title: parts.title, head: parts.head, foot: parts.foot }); });
@@ -156,5 +191,5 @@ export function MapCustomizeBody(props) {
156
191
  if (!phone || setParts)
157
192
  return _jsx(_Fragment, { children: parts.body });
158
193
  const { onBack, close } = parts.head;
159
- return (_jsxs(_Fragment, { children: [_jsx(HeaderBar, { className: "o-customize-own-head", title: parts.title, left: onBack ? _jsx(SheetButton, { "aria-label": w.back, className: "o-sheet-back", icon: glyph(BACK), onClick: onBack }) : close ? _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: p.onDone }) : _jsx("span", {}), right: close && onBack ? _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: p.onDone }) : _jsx("span", {}) }), parts.body, parts.foot] }));
194
+ return (_jsxs(_Fragment, { children: [_jsx(HeaderBar, { className: "o-sheet-row o-customize-own-head", title: parts.title, left: onBack ? _jsx(SheetButton, { "aria-label": w.back, className: "o-sheet-back", icon: glyph(BACK), onClick: onBack }) : close ? _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: p.onDone }) : _jsx("span", {}), right: close && onBack ? _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: p.onDone }) : _jsx("span", {}) }), parts.body, parts.foot] }));
160
195
  }
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import type { ViewsCustomizeField } from "../../provider/components.js";
3
+ type Time = NonNullable<ViewsCustomizeField["time"]>;
4
+ type Dates = NonNullable<ViewsCustomizeField["dates"]>;
5
+ /** The time range's screen: its presets (a pick writes and goes back), and Custom opening a level with the month. `level` is the
6
+ * level it stands on while Custom's month shows; `open`, told as its screen opens, starts it on the month while a custom range is
7
+ * in force (as the older page did), else on the presets, so the level never outlives its screen. Called for one time range,
8
+ * whether or not its screen shows, so it holds still. */
9
+ export declare function useTimeRange(time: Time | undefined, label: string, phone: boolean): {
10
+ body: (done: () => void) => React.ReactNode;
11
+ level: {
12
+ name: string;
13
+ back: () => void;
14
+ } | null;
15
+ open: () => void;
16
+ };
17
+ /** A date range's screen: its month, and Clear while a range stands. */
18
+ export declare function DateRangeBody({ dates, clear, phone }: {
19
+ dates: Dates;
20
+ clear: string;
21
+ phone: boolean;
22
+ }): import("react/jsx-runtime").JSX.Element;
23
+ export {};
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { ViewsContext } from "../../provider/context.js";
5
+ import { MenuList, MenuListPanelRows } from "../menu-list/menu-list.js";
6
+ const CUSTOM = "\u0000custom";
7
+ function Month({ from, to, onSelect, minNights }) {
8
+ const views = React.useContext(ViewsContext);
9
+ if (!views)
10
+ return null;
11
+ const RangeCalendar = views.atoms.RangeCalendar;
12
+ return _jsx(RangeCalendar, { mode: "range", from: from, to: to, onSelect: onSelect, locale: views.conventions.locale, ...(minNights !== undefined && { minNights }) });
13
+ }
14
+ export function useTimeRange(time, label, phone) {
15
+ const [custom, setCustom] = React.useState(false);
16
+ const back = React.useCallback(() => setCustom(false), []);
17
+ const on = time?.custom?.on === true;
18
+ const open = React.useCallback(() => setCustom(on), [on]);
19
+ const level = time?.custom && custom ? { name: time.custom.label, back } : null;
20
+ const body = (done) => {
21
+ if (!time)
22
+ return null;
23
+ if (time.custom && custom)
24
+ return _jsx(Month, { from: time.custom.from, to: time.custom.to, minNights: 1, onSelect: time.custom.onPress });
25
+ const c = time.custom;
26
+ const rows = [{ kind: "pick", value: c?.on ? CUSTOM : time.value,
27
+ choices: [...time.options.map((o) => ({ value: o.value, label: o.label })), ...(c ? [{ value: CUSTOM, label: c.label, ...(c.says !== undefined && { detail: c.says }) }] : [])],
28
+ onChoose: (v) => { if (v === CUSTOM) {
29
+ setCustom(true);
30
+ return;
31
+ } if (v !== time.value)
32
+ time.onChange(v); done(); } }];
33
+ return phone ? _jsx(MenuList, { label: label, entries: rows }) : _jsx(MenuListPanelRows, { label: label, entries: rows });
34
+ };
35
+ return { body, level, open };
36
+ }
37
+ export function DateRangeBody({ dates, clear, phone }) {
38
+ const standing = dates.from != null || dates.to != null;
39
+ const rows = [{ icon: null, label: clear, onSelect: () => dates.onChange({ from: null, to: null }) }];
40
+ return (_jsxs(_Fragment, { children: [_jsx(Month, { from: dates.from, to: dates.to, onSelect: (next) => dates.onChange(next) }), standing && (phone ? _jsx(MenuList, { label: clear, entries: rows }) : _jsx(MenuListPanelRows, { label: clear, entries: rows }))] }));
41
+ }
@@ -1,13 +1,29 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { CustomizeChoice, CustomizeToggle } from "./customize.js";
2
3
  import type { CustomizeWords } from "./words.js";
3
- /** A column of the view: its id, its name, whether it is shown, whether it is locked (always shown, never moved), its type's mark. */
4
+ /** A column of the view: its id, its name, whether it is shown, whether it is locked (always shown, never moved), its type's mark;
5
+ * and what opens one level in from its row (VK-890): its own settings, and the app's rows for its field (Edit field, Archive
6
+ * field) under them. On a card layout, `line`: whether it starts a new line on the card, and why it can't where it can't. */
4
7
  export interface CustomizeColumn {
5
8
  id: string;
6
9
  label: string;
7
10
  shown: boolean;
8
11
  locked?: boolean;
9
12
  mark?: ReactNode;
13
+ settings?: {
14
+ choices: CustomizeChoice[];
15
+ toggles: CustomizeToggle[];
16
+ };
17
+ rows?: ReactNode;
18
+ line?: {
19
+ on: boolean;
20
+ refused?: string;
21
+ };
10
22
  }
23
+ /** Whether a column opens a level of its own: it has a choice, a toggle or the app's rows. */
24
+ export declare const columnOpens: (c: CustomizeColumn) => boolean;
25
+ /** Whether a column has settings of its own: a choice or a toggle. */
26
+ export declare const columnOpensBySettings: (c: CustomizeColumn) => boolean;
11
27
  /** What the Columns section says on Customize's list: how many are shown ("6 shown"), in the handed words. */
12
28
  export declare const columnsSay: (columns: CustomizeColumn[], words?: Pick<CustomizeWords, "shown">) => string;
13
29
  /** The columns with one shown or hidden, in its place; a locked column stays shown. */
@@ -1,3 +1,5 @@
1
+ export const columnOpens = (c) => columnOpensBySettings(c) || !(c.rows == null || typeof c.rows === "boolean" || c.rows === "");
2
+ export const columnOpensBySettings = (c) => (c.settings?.choices.length ?? 0) > 0 || (c.settings?.toggles.length ?? 0) > 0;
1
3
  export const columnsSay = (columns, words) => {
2
4
  const n = columns.filter((c) => c.shown).length;
3
5
  return words ? words.shown(n) : `${n} shown`;
@@ -50,6 +50,13 @@ export interface CustomizeWords {
50
50
  toggleReset: (label: string) => string;
51
51
  /** The shared view moved after the reader's changes began. */
52
52
  stale: string;
53
+ /** A column's own level (VK-890): its Shown row, the name of the › that opens it, and its new-line Toggle's two names. */
54
+ columnShown: string;
55
+ columnSettings: (label: string) => string;
56
+ newLineOn: (label: string) => string;
57
+ newLineStart: (label: string) => string;
58
+ /** A per-field filter's screen with nothing to pick (VK-891). */
59
+ nothingToPick: string;
53
60
  /** The rows' own words (the Menu list's: a column's grip, how the columns move, a Switch's two words). */
54
61
  rows?: Partial<MenuListWords>;
55
62
  }
@@ -33,5 +33,10 @@ export const CUSTOMIZE_WORDS = {
33
33
  columnsReset: "Reset columns",
34
34
  toggleReset: (label) => `Reset ${label}`,
35
35
  stale: "Everyone's view changed since you started.",
36
+ columnShown: "Shown",
37
+ columnSettings: (label) => `${label} settings`,
38
+ newLineOn: (label) => `${label} starts a new line`,
39
+ newLineStart: (label) => `Start a new line at ${label}`,
40
+ nothingToPick: "Nothing to pick",
36
41
  };
37
42
  export const customizeWords = (given) => (given ? { ...CUSTOMIZE_WORDS, ...given } : CUSTOMIZE_WORDS);
@@ -46,6 +46,9 @@
46
46
  [data-customize-form="phone"] .o-customize-heading-words { margin-top: calc(var(--vk-spacing) * 2); padding: 0 calc(var(--vk-spacing) * 1); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
47
47
  [data-customize-form="phone"] .o-customize-heading > .o-customize-heading-words { padding: 0; }
48
48
 
49
+ /* ── A column's own level (VK-890): the app's rows for its field under its settings, a line over them; the app's rows under Columns' ── */
50
+ .o-customize-rows, .o-customize-foot-rows { display: flex; flex-direction: column; min-width: 0; }
51
+
49
52
  /* ── Nothing found by a search ── */
50
53
  .o-customize-none { margin: 0; padding: calc(var(--vk-spacing) * 2); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); color: var(--vk-fg-subtle); }
51
54
 
@@ -54,5 +54,7 @@ export interface FilterEditorParts {
54
54
  }
55
55
  /** The filter editor's state and the parts a shell pours in. */
56
56
  export declare function useFilterEditor(props: FilterEditorProps): FilterEditorParts;
57
+ /** @deprecated `useFilterEditor`, under the name the controls door gave it until the panels' older filter editor took a host's name. */
58
+ export declare const useFilterEditorParts: typeof useFilterEditor;
57
59
  /** The body alone, for a shell that holds only a body (the Popover). */
58
60
  export declare function FilterEditor(props: FilterEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -245,6 +245,7 @@ export function useFilterEditor(props) {
245
245
  const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-kit": "filter-editor", "data-filter-form": "computer", role: "group", "aria-label": label, tabIndex: -1, "data-filter-fields": fieldsAlone ? "" : undefined, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: !fieldsAlone ? _jsxs(_Fragment, { children: [top, level(filter, 0), _jsxs("div", { className: "o-filter-editor-foot", children: [addButton(filter.id, "outline", "sm"), _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", onClick: clear, children: w.clearAllFilters }), props.excludable && groupMore(filter)] }), addingPopover] }) : (_jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words })) }));
246
246
  return { body, head: {} };
247
247
  }
248
+ export const useFilterEditorParts = useFilterEditor;
248
249
  export function FilterEditor(props) {
249
250
  return _jsx(_Fragment, { children: useFilterEditor(props).body });
250
251
  }
@@ -96,8 +96,7 @@ export declare const setQuantifier: (f: FilterGroup, id: string, quantifier: Qua
96
96
  /** The rule `ruleId`, on a related field and not inside a block, turned into a block of that relation with `quantifier`, holding
97
97
  * it, its id never one in the filter or in `taken`; anything else, or a rule `levels` deep, stays. "any" changes nothing. */
98
98
  export declare function toBlock(f: FilterGroup, ruleId: string, quantifier: Quantifier, fields: FilterField[], taken?: readonly string[], levels?: number): FilterGroup;
99
- /** Whether Every fits a block's rules: at least one of them, at any depth, is whole (isWhole) and not set aside, as ViewKit's
100
- * everyBlocked counts. */
99
+ /** Whether Every fits a block's rules: at least one of them, at any depth, is whole (isWhole) and not set aside. */
101
100
  export declare const everyFits: (rules: FilterItem[], fields: FilterField[]) => boolean;
102
101
  /** A set-aside rule put back: its `aside` dropped, so it is written as a rule again; anything else stays. */
103
102
  export declare function putBack(f: FilterGroup, id: string): FilterGroup;