viewkitjs 0.27.0 → 0.28.0

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 (229) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/MIGRATION.md +40 -3
  3. package/package.json +1 -1
  4. package/views/dist/cells/cell-format.d.ts +3 -1
  5. package/views/dist/cells/cell-format.js +2 -2
  6. package/views/dist/cells/use-cell-format.d.ts +8 -1
  7. package/views/dist/cells/use-cell-format.js +13 -2
  8. package/views/dist/contract.d.ts +70 -3
  9. package/views/dist/contract.js +76 -0
  10. package/views/dist/controls/alert/alert.d.ts +46 -0
  11. package/views/dist/controls/alert/alert.js +11 -0
  12. package/views/dist/controls/alert/looks.d.ts +4 -0
  13. package/views/dist/controls/alert/looks.js +19 -0
  14. package/views/dist/controls/alert/tokens.d.ts +92 -0
  15. package/views/dist/controls/alert/tokens.js +25 -0
  16. package/views/dist/controls/alert-dialog/alert-dialog.d.ts +50 -0
  17. package/views/dist/controls/alert-dialog/alert-dialog.js +67 -0
  18. package/views/dist/controls/alert-dialog/confirm.d.ts +13 -0
  19. package/views/dist/controls/alert-dialog/confirm.js +11 -0
  20. package/views/dist/controls/alert-dialog/looks.d.ts +4 -0
  21. package/views/dist/controls/alert-dialog/looks.js +17 -0
  22. package/views/dist/controls/alert-dialog/tokens.d.ts +119 -0
  23. package/views/dist/controls/alert-dialog/tokens.js +32 -0
  24. package/views/dist/controls/alert-dialog.css +95 -0
  25. package/views/dist/controls/alert.css +51 -0
  26. package/views/dist/controls/collapsible/collapsible.d.ts +39 -0
  27. package/views/dist/controls/collapsible/collapsible.js +18 -0
  28. package/views/dist/controls/collapsible/looks.d.ts +4 -0
  29. package/views/dist/controls/collapsible/looks.js +5 -0
  30. package/views/dist/controls/collapsible/map-collapse.d.ts +2 -0
  31. package/views/dist/controls/collapsible/map-collapse.js +6 -0
  32. package/views/dist/controls/collapsible/tokens.d.ts +68 -0
  33. package/views/dist/controls/collapsible/tokens.js +19 -0
  34. package/views/dist/controls/collapsible.css +83 -0
  35. package/views/dist/controls/compound-editor/place-parts.js +5 -1
  36. package/views/dist/controls/controls.d.ts +9 -0
  37. package/views/dist/controls/controls.js +9 -0
  38. package/views/dist/controls/date-editor/date-editor.d.ts +2 -1
  39. package/views/dist/controls/date-editor/map-calendar.js +3 -1
  40. package/views/dist/controls/filter-editor/filter-editor.d.ts +56 -0
  41. package/views/dist/controls/filter-editor/filter-editor.js +208 -0
  42. package/views/dist/controls/filter-editor/how.d.ts +23 -0
  43. package/views/dist/controls/filter-editor/how.js +13 -0
  44. package/views/dist/controls/filter-editor/map-filter-body.d.ts +18 -0
  45. package/views/dist/controls/filter-editor/map-filter-body.js +164 -0
  46. package/views/dist/controls/filter-editor/map-rules.d.ts +85 -0
  47. package/views/dist/controls/filter-editor/map-rules.js +273 -0
  48. package/views/dist/controls/filter-editor/parts.d.ts +46 -0
  49. package/views/dist/controls/filter-editor/parts.js +75 -0
  50. package/views/dist/controls/filter-editor/rules.d.ts +104 -0
  51. package/views/dist/controls/filter-editor/rules.js +148 -0
  52. package/views/dist/controls/filter-editor/tokens.d.ts +83 -0
  53. package/views/dist/controls/filter-editor/tokens.js +23 -0
  54. package/views/dist/controls/filter-editor/words.d.ts +59 -0
  55. package/views/dist/controls/filter-editor/words.js +40 -0
  56. package/views/dist/controls/filter-editor.css +124 -0
  57. package/views/dist/controls/group-editor/group-editor.d.ts +56 -0
  58. package/views/dist/controls/group-editor/group-editor.js +126 -0
  59. package/views/dist/controls/group-editor/map-group-body.d.ts +19 -0
  60. package/views/dist/controls/group-editor/map-group-body.js +106 -0
  61. package/views/dist/controls/group-editor/rules.d.ts +48 -0
  62. package/views/dist/controls/group-editor/rules.js +41 -0
  63. package/views/dist/controls/group-editor/tokens.d.ts +15 -0
  64. package/views/dist/controls/group-editor/tokens.js +6 -0
  65. package/views/dist/controls/group-editor/words.d.ts +39 -0
  66. package/views/dist/controls/group-editor/words.js +21 -0
  67. package/views/dist/controls/group-editor.css +20 -0
  68. package/views/dist/controls/index.d.ts +19 -1
  69. package/views/dist/controls/index.js +19 -1
  70. package/views/dist/controls/internal/editor-parts.d.ts +8 -1
  71. package/views/dist/controls/internal/editor-parts.js +5 -0
  72. package/views/dist/controls/internal/step-return.d.ts +9 -0
  73. package/views/dist/controls/internal/step-return.js +27 -0
  74. package/views/dist/controls/links-editor/links-editor.d.ts +5 -3
  75. package/views/dist/controls/links-editor/links-editor.js +38 -17
  76. package/views/dist/controls/links-editor/map-links-body.js +4 -1
  77. package/views/dist/controls/links-editor.css +1 -1
  78. package/views/dist/controls/menu-list/menu-list.d.ts +17 -2
  79. package/views/dist/controls/menu-list/menu-list.js +25 -16
  80. package/views/dist/controls/modal/looks.d.ts +4 -0
  81. package/views/dist/controls/modal/looks.js +25 -0
  82. package/views/dist/controls/modal/modal.d.ts +69 -0
  83. package/views/dist/controls/modal/modal.js +62 -0
  84. package/views/dist/controls/modal/tokens.d.ts +192 -0
  85. package/views/dist/controls/modal/tokens.js +50 -0
  86. package/views/dist/controls/modal.css +130 -0
  87. package/views/dist/controls/notice/notice.d.ts +49 -0
  88. package/views/dist/controls/notice/notice.js +35 -0
  89. package/views/dist/controls/notice/tokens.d.ts +99 -0
  90. package/views/dist/controls/notice/tokens.js +27 -0
  91. package/views/dist/controls/notice.css +100 -0
  92. package/views/dist/controls/number-editor/number-editor.js +1 -1
  93. package/views/dist/controls/pane/looks.d.ts +4 -0
  94. package/views/dist/controls/pane/looks.js +11 -0
  95. package/views/dist/controls/pane/pane.d.ts +63 -0
  96. package/views/dist/controls/pane/pane.js +98 -0
  97. package/views/dist/controls/pane/state.d.ts +14 -0
  98. package/views/dist/controls/pane/state.js +7 -0
  99. package/views/dist/controls/pane/tokens.d.ts +79 -0
  100. package/views/dist/controls/pane/tokens.js +22 -0
  101. package/views/dist/controls/pane.css +104 -0
  102. package/views/dist/controls/picker/rows.d.ts +4 -2
  103. package/views/dist/controls/picker/rows.js +4 -3
  104. package/views/dist/controls/sort-editor/map-sort-body.d.ts +9 -0
  105. package/views/dist/controls/sort-editor/map-sort-body.js +81 -0
  106. package/views/dist/controls/sort-editor/rules.d.ts +48 -0
  107. package/views/dist/controls/sort-editor/rules.js +24 -0
  108. package/views/dist/controls/sort-editor/sort-editor.d.ts +58 -0
  109. package/views/dist/controls/sort-editor/sort-editor.js +180 -0
  110. package/views/dist/controls/sort-editor/tokens.d.ts +79 -0
  111. package/views/dist/controls/sort-editor/tokens.js +22 -0
  112. package/views/dist/controls/sort-editor/words.d.ts +48 -0
  113. package/views/dist/controls/sort-editor/words.js +25 -0
  114. package/views/dist/controls/sort-editor.css +96 -0
  115. package/views/dist/controls/toast/toast.d.ts +75 -0
  116. package/views/dist/controls/toast/toast.js +99 -0
  117. package/views/dist/controls/toast/tokens.d.ts +100 -0
  118. package/views/dist/controls/toast/tokens.js +27 -0
  119. package/views/dist/controls/toast.css +93 -0
  120. package/views/dist/controls/tokens.js +20 -0
  121. package/views/dist/controls/values-editor/values-editor.js +7 -1
  122. package/views/dist/display/date.js +2 -2
  123. package/views/dist/display/format.js +10 -2
  124. package/views/dist/display/options.d.ts +3 -1
  125. package/views/dist/display/use-display-options.d.ts +3 -0
  126. package/views/dist/display/use-display-options.js +10 -2
  127. package/views/dist/display/viewer.d.ts +1 -1
  128. package/views/dist/display/viewer.js +1 -1
  129. package/views/dist/editors/DateEditor.js +11 -9
  130. package/views/dist/editors/relation-panel.js +7 -1
  131. package/views/dist/editors/relation-picker.d.ts +2 -1
  132. package/views/dist/editors/relation-picker.js +4 -3
  133. package/views/dist/editors/relation-source.d.ts +4 -1
  134. package/views/dist/editors/relation-source.js +5 -2
  135. package/views/dist/field-row/editors/RowNumberEditor.js +2 -2
  136. package/views/dist/fields/number-edit.d.ts +6 -0
  137. package/views/dist/fields/number-edit.js +8 -1
  138. package/views/dist/grid/chrome/GridCellEditors.js +2 -2
  139. package/views/dist/grid/chrome/GridColumnDateSection.d.ts +4 -3
  140. package/views/dist/grid/chrome/GridColumnDateSection.js +4 -4
  141. package/views/dist/grid/chrome/GridColumnDurationSection.js +2 -2
  142. package/views/dist/grid/chrome/GridColumnMenu.js +6 -4
  143. package/views/dist/grid/chrome/GridFooter.js +2 -2
  144. package/views/dist/grid/chrome/grid-column-menu-items.js +4 -2
  145. package/views/dist/grid/chrome/useGridBandFigures.js +2 -2
  146. package/views/dist/grid/chrome/useGridFittedWidths.d.ts +3 -0
  147. package/views/dist/grid/chrome/useGridFittedWidths.js +9 -3
  148. package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
  149. package/views/dist/grid/chrome/useGridKeyboard.js +5 -2
  150. package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -1
  151. package/views/dist/grid/core/commit-model.d.ts +7 -0
  152. package/views/dist/grid/core/commit-model.js +5 -1
  153. package/views/dist/grid/core/editing-controller.js +10 -2
  154. package/views/dist/grid/core/editing-model.js +3 -7
  155. package/views/dist/grid/core/undo-owner.d.ts +6 -0
  156. package/views/dist/grid/core/undo-owner.js +13 -0
  157. package/views/dist/grid/core/useGridEditing.d.ts +2 -0
  158. package/views/dist/grid/core/useGridEditing.js +4 -0
  159. package/views/dist/looks/index.d.ts +5 -0
  160. package/views/dist/looks/index.js +5 -0
  161. package/views/dist/looks/pieces.js +10 -0
  162. package/views/dist/panels/model.d.ts +6 -1
  163. package/views/dist/panels/react/customize-body.d.ts +4 -2
  164. package/views/dist/panels/react/customize-body.js +3 -3
  165. package/views/dist/panels/react/customize.js +4 -2
  166. package/views/dist/panels/react/filter/FilterEditor.js +2 -2
  167. package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +8 -2
  168. package/views/dist/panels/react/filter/PhoneFilterEditor.js +9 -6
  169. package/views/dist/panels/react/filter/filter-body.d.ts +8 -5
  170. package/views/dist/panels/react/filter/filter-body.js +17 -6
  171. package/views/dist/panels/react/filter/filter-part-body.d.ts +4 -1
  172. package/views/dist/panels/react/filter/filter-part-body.js +3 -1
  173. package/views/dist/panels/react/panel-sheet.d.ts +5 -1
  174. package/views/dist/panels/react/panel-sheet.js +6 -2
  175. package/views/dist/panels/react/panel-step.d.ts +12 -0
  176. package/views/dist/panels/react/panel-step.js +26 -0
  177. package/views/dist/panels/react/sort/SortEditor.d.ts +4 -0
  178. package/views/dist/panels/react/sort/SortEditor.js +5 -2
  179. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +8 -0
  180. package/views/dist/panels/react/toolbar/ReadyToolbar.js +84 -2
  181. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +2 -2
  182. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +16 -0
  183. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +49 -0
  184. package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +3 -1
  185. package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +4 -1
  186. package/views/dist/panels/react/toolbar/ToolbarFilters.js +36 -21
  187. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +4 -1
  188. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +2 -2
  189. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
  190. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +15 -6
  191. package/views/dist/panels/react/toolbar/panel-part.d.ts +5 -1
  192. package/views/dist/panels/react/toolbar/panel-part.js +2 -2
  193. package/views/dist/panels/react/toolbar/use-filter-add.d.ts +16 -0
  194. package/views/dist/panels/react/toolbar/use-filter-add.js +32 -0
  195. package/views/dist/panels/react.d.ts +1 -0
  196. package/views/dist/panels/react.js +1 -0
  197. package/views/dist/panels/settings/filter-groups.js +35 -1
  198. package/views/dist/panels/settings/group-buckets.js +1 -0
  199. package/views/dist/provider/ViewsProvider.d.ts +7 -1
  200. package/views/dist/provider/ViewsProvider.js +23 -3
  201. package/views/dist/provider/components.d.ts +30 -4
  202. package/views/dist/provider/moment.d.ts +6 -0
  203. package/views/dist/provider/moment.js +10 -0
  204. package/views/dist/styles.css +847 -52
  205. package/views/dist/styles.unlayered.css +848 -52
  206. package/views/docs/contract.md +15 -9
  207. package/views/docs/controls/alert-dialog.md +37 -0
  208. package/views/docs/controls/alert.md +30 -0
  209. package/views/docs/controls/collapsible.md +22 -0
  210. package/views/docs/controls/filter-editor.md +28 -0
  211. package/views/docs/controls/group-editor.md +11 -0
  212. package/views/docs/controls/modal.md +55 -0
  213. package/views/docs/controls/notice.md +32 -0
  214. package/views/docs/controls/pane.md +25 -0
  215. package/views/docs/controls/sort-editor.md +27 -0
  216. package/views/docs/controls/toast.md +32 -0
  217. package/views/docs/guides/cells.md +1 -1
  218. package/views/docs/guides/display.md +1 -1
  219. package/views/docs/guides/the-grid.md +1 -1
  220. package/views/docs/guides/the-provider.md +19 -0
  221. package/views/docs/reference/cells.md +2 -2
  222. package/views/docs/reference/controls.md +213 -7
  223. package/views/docs/reference/display.md +2 -2
  224. package/views/docs/reference/editors-relation.md +1 -1
  225. package/views/docs/reference/looks.md +10 -0
  226. package/views/docs/reference/panels-react.md +7 -6
  227. package/views/docs/reference/panels.md +1 -1
  228. package/views/docs/reference/react.md +7 -7
  229. package/views/docs/reference/views.md +1 -0
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { useViews } from "../../../provider/context.js";
3
+ import { addOnBar, barAddRefusal } from "../../../filters/filter-tree.js";
4
+ import { heldUntilWhole, newRelationRuleFor, newRuleFor } from "../../settings/filter-groups.js";
5
+ export function useFilterAdd({ filterTree, hold, write, }) {
6
+ const { messages } = useViews();
7
+ const refusal = barAddRefusal(filterTree.tree);
8
+ const reason = refusal === "or-full"
9
+ ? messages({ key: "views.panels.filter-or-full" })
10
+ : refusal === "too-many"
11
+ ? messages({ key: "views.panels.filter-too-many" })
12
+ : undefined;
13
+ const onPick = (picked, far) => {
14
+ const node = far ? newRelationRuleFor(picked, far) : newRuleFor(picked);
15
+ if (heldUntilWhole(far ?? picked)) {
16
+ hold({ container: [], node });
17
+ return;
18
+ }
19
+ const edit = (current) => {
20
+ const out = addOnBar(current, node);
21
+ return "tree" in out ? out.tree : null;
22
+ };
23
+ if (write) {
24
+ write(edit);
25
+ return;
26
+ }
27
+ const next = edit(filterTree.tree);
28
+ if (next)
29
+ filterTree.onChange(next);
30
+ };
31
+ return { refusal, reason, onPick };
32
+ }
@@ -51,6 +51,7 @@ export { QuickFiltersPanel } from "./react/quick/QuickFiltersPanel.js";
51
51
  export { QuickFiltersReminder } from "./react/quick/QuickFiltersReminder.js";
52
52
  export { ToolbarAdvancedFilters } from "./react/toolbar/ToolbarAdvancedFilters.js";
53
53
  export { ToolbarFilters, foldableFilters } from "./react/toolbar/ToolbarFilters.js";
54
+ export { ToolbarFilterAdd } from "./react/toolbar/ToolbarFilterAdd.js";
54
55
  export type { Pending } from "./react/filter/editor-ctx.js";
55
56
  export { FilterEditor } from "./react/filter/FilterEditor.js";
56
57
  export { PhoneFilterEditor, usePhoneFilterEditor } from "./react/filter/PhoneFilterEditor.js";
@@ -46,6 +46,7 @@ export { QuickFiltersPanel } from "./react/quick/QuickFiltersPanel.js";
46
46
  export { QuickFiltersReminder } from "./react/quick/QuickFiltersReminder.js";
47
47
  export { ToolbarAdvancedFilters } from "./react/toolbar/ToolbarAdvancedFilters.js";
48
48
  export { ToolbarFilters, foldableFilters } from "./react/toolbar/ToolbarFilters.js";
49
+ export { ToolbarFilterAdd } from "./react/toolbar/ToolbarFilterAdd.js";
49
50
  export { FilterEditor } from "./react/filter/FilterEditor.js";
50
51
  export { PhoneFilterEditor, usePhoneFilterEditor } from "./react/filter/PhoneFilterEditor.js";
51
52
  export { FilterFieldList } from "./react/filter/FilterFieldList.js";
@@ -4,7 +4,7 @@ import { resolveViewsMessage } from "../../contract.js";
4
4
  import { columnLabel } from "../../model/column-capabilities.js";
5
5
  import { booleanFilterOptions, buildColumnFilters } from "../../model/column-filters.js";
6
6
  import { columnMark } from "../../model/column-mark.js";
7
- import { farWhereInputs, relationFilterKey } from "../../model/relation-filters.js";
7
+ import { farPathOf, farWhereInputs, relationFilterKey } from "../../model/relation-filters.js";
8
8
  import { columnStateOf } from "../../model/settings-columns.js";
9
9
  import { fieldKeyOf, fromListFilterRule, toListFilterRule } from "../../model/view-rules.js";
10
10
  const TEXT_TYPES = new Set([
@@ -227,12 +227,46 @@ export function settingsFilterTree(input, write) {
227
227
  });
228
228
  return built.find((config) => config.key === key) ?? null;
229
229
  };
230
+ const optionsOf = (fieldKey, part, relation) => {
231
+ const target = relation !== undefined ? relationFilters?.targets[relation] : undefined;
232
+ if (relation !== undefined && !target)
233
+ return undefined;
234
+ const column = relation !== undefined && target
235
+ ? farWhereInputs(relation, target, relationFilters?.farValues).columns.find((c) => c.id === fieldKey)
236
+ : whole.find((c) => fieldKeyOf(c) === fieldKey);
237
+ const type = column?.field ? valueTypeOf(column.field) : undefined;
238
+ if (!column || !type || part !== undefined || !CHOICE_TYPES.has(type))
239
+ return undefined;
240
+ const config = valueOf({ fieldKey, operator: "is_any_of", value: [] }, () => { }, relation);
241
+ if (!config || config.editor !== undefined || !("options" in config))
242
+ return undefined;
243
+ const declared = column.field.options ?? [];
244
+ const held = relation !== undefined
245
+ ? relationFilters?.farValues?.values[farPathOf(relation, fieldKey)] !== undefined || declared.length > 0
246
+ : filterData?.knownValues?.[column.id] !== undefined;
247
+ if (config.onOpen && !held)
248
+ return undefined;
249
+ const kind = column.field.relation?.kind;
250
+ return config.options.map((o) => {
251
+ const d = declared.find((x) => x.value === o.value);
252
+ return {
253
+ value: o.value,
254
+ label: o.label,
255
+ ...(d?.slot !== undefined ? { slot: d.slot } : {}),
256
+ ...(d?.color !== undefined ? { color: d.color } : {}),
257
+ ...(d?.icon !== undefined ? { icon: d.icon } : {}),
258
+ ...(type === "user" || type === "actor" ? { avatarUrl: null } : {}),
259
+ ...(type === "relation" ? { avatarUrl: null, ...(kind ? { kind } : {}) } : {}),
260
+ };
261
+ });
262
+ };
230
263
  return {
231
264
  tree: input.settings.filter,
232
265
  fields: filterEditorFields(input),
233
266
  ...(input.goneFields ? { gone: input.goneFields } : {}),
234
267
  onChange: write,
235
268
  valueOf,
269
+ optionsOf,
236
270
  };
237
271
  }
238
272
  export function filterPartChangeFits(field, was, next) {
@@ -23,6 +23,7 @@ export function groupEntries(heads, group) {
23
23
  label: head.label,
24
24
  empty: head.hidden && !hiddenByReader.has(head.key),
25
25
  hidden: hiddenByReader.has(head.key),
26
+ count: head.count,
26
27
  }));
27
28
  return [...entries.filter((entry) => !entry.hidden), ...entries.filter((entry) => entry.hidden)];
28
29
  }
@@ -98,6 +98,12 @@ export type ViewsProviderProps = {
98
98
  * week from today). The date editor hands exactly these to your `DateBody`, and its own panel draws the same.
99
99
  * Default: `today`, `tomorrow` and `next-monday`, as on 0.5.0. Pass a module-level array. */
100
100
  datePicks?: ViewsDatePicks;
101
+ /** The moment every date counts from: relative dates, the column menu's samples, the date editors' quick days and
102
+ * today. Hand the server's, and the server and the browser draw the same text on first load. Absent, the provider
103
+ * reads the clock just after the page loads, then once a minute and when the tab comes back into view, never
104
+ * while rendering; until the first read a date that needs it draws its full form. A moment you hand is kept as it is:
105
+ * hand a new one to move it. */
106
+ now?: Date;
101
107
  children: ReactNode;
102
108
  };
103
- export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, desktopQuery, sheetActions, escape, oneValue, sayRefusals, menus, gridButtons, severalValues, gridCheckboxes, fieldRowButtons, fieldRowCheckboxes, panelButtons, bodyFrame, gridBodyPlace, selectionBar, datePicks, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
109
+ export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, desktopQuery, sheetActions, escape, oneValue, sayRefusals, menus, gridButtons, severalValues, gridCheckboxes, fieldRowButtons, fieldRowCheckboxes, panelButtons, bodyFrame, gridBodyPlace, selectionBar, datePicks, now, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,10 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useMemo } from "react";
3
+ import { useEffect, useMemo, useState } from "react";
4
4
  import { resolveViewsMessage } from "../contract.js";
5
5
  import { DEFAULT_VIEWS_ATOMS } from "../atoms/defaults.js";
6
6
  import { ViewsContext } from "./context.js";
7
+ import { HasMomentContext, MomentContext } from "./moment.js";
7
8
  import { PlainInput } from "./plain-input.js";
8
9
  import { missingComponent, missingParts } from "./missing-slot.js";
9
10
  import { withSettledGroups } from "./menu-groups.js";
@@ -12,7 +13,26 @@ import { browserConfirm } from "./ports.js";
12
13
  export { useViews } from "./context.js";
13
14
  const MISSING_COMMAND_PARTS = missingParts("Command");
14
15
  const MISSING_CALENDAR_COMPONENT = missingComponent("Calendar");
15
- export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, oneValue, sayRefusals = false, menus = "popover", gridButtons = "own", severalValues = "fit", gridCheckboxes = "own", fieldRowButtons = "own", fieldRowCheckboxes = "own", panelButtons = "own", bodyFrame = "views", gridBodyPlace = "under", selectionBar, datePicks, }) {
16
+ export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, oneValue, sayRefusals = false, menus = "popover", gridButtons = "own", severalValues = "fit", gridCheckboxes = "own", fieldRowButtons = "own", fieldRowCheckboxes = "own", panelButtons = "own", bodyFrame = "views", gridBodyPlace = "under", selectionBar, datePicks, now, }) {
17
+ const [readNow, setReadNow] = useState(null);
18
+ useEffect(() => {
19
+ if (now)
20
+ return;
21
+ const read = () => setReadNow(new Date());
22
+ const onVisible = () => {
23
+ if (document.visibilityState !== "hidden")
24
+ read();
25
+ };
26
+ read();
27
+ const minute = setInterval(read, 60_000);
28
+ document.addEventListener("visibilitychange", onVisible);
29
+ return () => {
30
+ clearInterval(minute);
31
+ document.removeEventListener("visibilitychange", onVisible);
32
+ };
33
+ }, [now]);
34
+ const nowTime = now?.getTime();
35
+ const moment = useMemo(() => (nowTime != null ? new Date(nowTime) : readNow), [nowTime, readNow]);
16
36
  const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
17
37
  const settled = useMemo(() => ({
18
38
  ...components,
@@ -71,5 +91,5 @@ export function ViewsProvider({ children, components, conventions, icons, ports,
71
91
  selectionBar,
72
92
  datePicks,
73
93
  ]);
74
- return (_jsx(ViewsContext.Provider, { value: value, children: _jsx(PhoneLine.Provider, { value: desktopQuery, children: children }) }));
94
+ return (_jsx(ViewsContext.Provider, { value: value, children: _jsx(MomentContext.Provider, { value: moment, children: _jsx(HasMomentContext.Provider, { value: moment != null, children: _jsx(PhoneLine.Provider, { value: desktopQuery, children: children }) }) }) }));
75
95
  }
@@ -738,6 +738,11 @@ export type ViewsSortBodyProps = {
738
738
  * set-aside sorts back to what they were as it opened) and ✓, for your body's own head. Absent on a computer, and
739
739
  * under `head`, where the sheet holds them. */
740
740
  actions?: ViewsSheetActions;
741
+ /** On a phone: tell the sheet you stand on a step of your own (Add sort's fields, a rule's direction), and hand `null`
742
+ * once you are back. Under `sheetActions: "head"` the sheet's head shows the step's title and Back in ✕'s place, and
743
+ * ✓; under `bar` your own head does. Escape calls `onBack`; a swipe still closes the whole sheet, keeping the rules.
744
+ * Absent on a computer. */
745
+ onStepChange?: (step: ViewsBodyStep | null) => void;
741
746
  };
742
747
  /** The quick filters' body, which your app draws (`QuickFiltersBody`): what the quick filters' button opens on a
743
748
  * computer and in the phone's Sheet, in place of ViewKit's own panel. A panel's body, as every panel's: handed the
@@ -800,6 +805,10 @@ export type ViewsFilterBodyField = {
800
805
  type: keyof typeof FILTER_OPERATORS;
801
806
  /** A relation's far fields, one level in: a rule on one is a relation rule (any, none or every where …). */
802
807
  far?: readonly ViewsFilterBodyField[];
808
+ /** A choice field's values (a status's, a select's, a person's, a record's), each as the Picker draws it, where ViewKit holds
809
+ * them as the list opens: your body may list them in the rule's value box. Absent where its values are read on demand, or the
810
+ * field is no choice: open `ruleValue` there. */
811
+ options?: readonly ViewsPickerItem[];
803
812
  };
804
813
  /** The filter editor's body, which your app draws (`FilterBody`): what an advanced filter's pill opens on a computer and
805
814
  * Filter opens in the phone's Sheet, in place of ViewKit's own. A panel's body, as every panel's: handed the level it is
@@ -848,6 +857,18 @@ export type ViewsFilterBodyProps = {
848
857
  * it was as the sheet opened) and ✓, for your body's own head. Absent on a computer, and under `head`, where the
849
858
  * sheet holds them. */
850
859
  actions?: ViewsSheetActions;
860
+ /** ViewKit's own words for a rule, as the filter bar words it: its field, its way and its value (null with none yet). For a
861
+ * rule your body has no words of its own for (set aside, a way you don't draw). `relation`: the relation's field key, for a
862
+ * far rule. */
863
+ ruleWords?: (rule: FilterRule, relation?: string) => {
864
+ field: string;
865
+ way: string;
866
+ value: string | null;
867
+ };
868
+ /** On a phone: tell the sheet you stand on a step of your own (a box's list, Add filter's fields), and hand null once you
869
+ * are back. The sheet's head shows the step's title, Back in ✕'s place and ✓; Escape calls onBack; a swipe still closes
870
+ * the whole sheet, keeping the filter. Absent on a computer. */
871
+ onStepChange?: (step: ViewsBodyStep | null) => void;
851
872
  };
852
873
  /** A field as the field list's body is handed it (`ViewsFieldsBodyProps.fields`). */
853
874
  export type ViewsFieldsBodyField = {
@@ -1012,12 +1033,14 @@ export type ViewsGroupDimension = {
1012
1033
  defaultGranularity?: string;
1013
1034
  };
1014
1035
  /** One group of the field grouped by, as the group body is handed it: its key, its words ("" for the empty group),
1015
- * whether it is empty (Hide empty groups hides it) and whether the reader hid it. It carries no count. */
1036
+ * whether it is empty (Hide empty groups hides it), whether the reader hid it, and how many records it holds, where the
1037
+ * list counts them. */
1016
1038
  export type ViewsGroupEntry = {
1017
1039
  key: string;
1018
1040
  label: string;
1019
1041
  empty: boolean;
1020
1042
  hidden: boolean;
1043
+ count?: number;
1021
1044
  };
1022
1045
  /** A list's group as one value, what a group body is handed and hands back whole. */
1023
1046
  export type ViewsGroupValue = {
@@ -1060,6 +1083,9 @@ export type ViewsGroupBodyProps = {
1060
1083
  onDone: () => void;
1061
1084
  /** On a phone where the sheet's head doesn't draw it: its ✕. Inside Customize, whose own head holds the ✕, absent. */
1062
1085
  actions?: ViewsSheetActions;
1086
+ /** Tell what holds you that you stand on a level of your own (Group by's fields, an order's choices): its head shows the
1087
+ * level's name and its Back calls onBack; hand null once you are back. On a computer and a phone. */
1088
+ onStepChange?: (step: ViewsBodyStep | null) => void;
1063
1089
  };
1064
1090
  /** Where a Customize body stands: its list, or a section's page. */
1065
1091
  export type ViewsCustomizePage = "list" | "layout" | "columns" | "filter" | "sort" | "group";
@@ -1179,11 +1205,11 @@ export type ViewsCustomizeBodyProps = {
1179
1205
  columns?: ViewsCustomizeColumns;
1180
1206
  /** The filter as and/or groups, as `FilterBody` is handed it on a phone: the whole filter, 3 levels deep. Where a list's
1181
1207
  * filter is only per-field values (no filter tree), ViewKit draws its own Customize instead of the body. */
1182
- filter?: Omit<ViewsFilterBodyProps, "form" | "onDone" | "actions">;
1208
+ filter?: Omit<ViewsFilterBodyProps, "form" | "onDone" | "actions" | "onStepChange">;
1183
1209
  /** The sort, as `SortBody` is handed it: a list with one sort as one rule, `max` 1. */
1184
- sort?: Omit<ViewsSortBodyProps, "form" | "onDone" | "actions">;
1210
+ sort?: Omit<ViewsSortBodyProps, "form" | "onDone" | "actions" | "onStepChange">;
1185
1211
  /** The group, as `GroupBody` is handed it. */
1186
- group?: Omit<ViewsGroupBodyProps, "form" | "onDone" | "actions">;
1212
+ group?: Omit<ViewsGroupBodyProps, "form" | "onDone" | "actions" | "onStepChange">;
1187
1213
  /** The list's own toggles, Show counts among them (read from the view). */
1188
1214
  toggles: readonly ViewsCustomizeToggle[];
1189
1215
  /** On a shared view: how far the reader has drifted from it, and Reset and Set default for everyone. */
@@ -0,0 +1,6 @@
1
+ /** The provider's moment (`ViewsProvider`'s `now`, or its read of the clock after mount); null until it has one. */
2
+ export declare const MomentContext: import("react").Context<Date | null>;
3
+ /** Whether the provider has a moment yet. */
4
+ export declare const HasMomentContext: import("react").Context<boolean>;
5
+ export declare function useMoment(): Date | null;
6
+ export declare function useHasMoment(): boolean;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { createContext, useContext } from "react";
3
+ export const MomentContext = createContext(null);
4
+ export const HasMomentContext = createContext(false);
5
+ export function useMoment() {
6
+ return useContext(MomentContext);
7
+ }
8
+ export function useHasMoment() {
9
+ return useContext(HasMomentContext);
10
+ }