@viewkitjs/views 0.1.0 → 0.2.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 (246) hide show
  1. package/CHANGELOG.md +196 -1
  2. package/README.md +90 -41
  3. package/dist/atoms/Row.js +1 -1
  4. package/dist/atoms/RowMenu.d.ts +1 -1
  5. package/dist/atoms/RowMenu.js +15 -4
  6. package/dist/atoms/types.d.ts +4 -4
  7. package/dist/contract.d.ts +37 -7
  8. package/dist/contract.js +24 -5
  9. package/dist/display/format.d.ts +16 -1
  10. package/dist/display/format.js +10 -1
  11. package/dist/display/index.d.ts +1 -1
  12. package/dist/display/index.js +1 -1
  13. package/dist/display/link.js +5 -3
  14. package/dist/display/location.d.ts +4 -3
  15. package/dist/display/location.js +12 -5
  16. package/dist/display/options.d.ts +1 -1
  17. package/dist/display/percent.js +10 -3
  18. package/dist/display/phone.d.ts +2 -1
  19. package/dist/display/phone.js +8 -1
  20. package/dist/display/relation.js +1 -1
  21. package/dist/editors/ChipsEditor.js +1 -1
  22. package/dist/editors/LocationEditor.js +16 -17
  23. package/dist/editors/NameEditor.js +5 -4
  24. package/dist/editors/NumberEditor.js +2 -2
  25. package/dist/editors/RangeEditor.js +2 -2
  26. package/dist/editors/ValueListEditor.d.ts +2 -2
  27. package/dist/editors/ValueListEditor.js +8 -8
  28. package/dist/editors/edit-cores.d.ts +1 -1
  29. package/dist/fields/binding.d.ts +1 -1
  30. package/dist/fields/currency.d.ts +0 -10
  31. package/dist/fields/currency.js +0 -14
  32. package/dist/fields/money.d.ts +1 -0
  33. package/dist/fields/money.js +1 -0
  34. package/dist/filters/filter-model.d.ts +0 -1
  35. package/dist/filters/registry.d.ts +3 -36
  36. package/dist/filters/registry.js +0 -38
  37. package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
  38. package/dist/grid/chrome/GridAddColumn.js +29 -0
  39. package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
  40. package/dist/grid/chrome/GridAggregateMenu.js +27 -0
  41. package/dist/grid/chrome/GridCellEditors.d.ts +64 -0
  42. package/dist/grid/chrome/GridCellEditors.js +55 -0
  43. package/dist/grid/chrome/GridCellOutline.d.ts +70 -0
  44. package/dist/grid/chrome/GridCellOutline.js +21 -0
  45. package/dist/grid/chrome/GridChipsEditor.d.ts +28 -0
  46. package/dist/grid/chrome/GridChipsEditor.js +40 -0
  47. package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
  48. package/dist/grid/chrome/GridColumnColorSection.js +40 -0
  49. package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
  50. package/dist/grid/chrome/GridColumnDateSection.js +23 -0
  51. package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
  52. package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
  53. package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
  54. package/dist/grid/chrome/GridColumnMenu.js +99 -0
  55. package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
  56. package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
  57. package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
  58. package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
  59. package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
  60. package/dist/grid/chrome/GridColumnSortSection.js +16 -0
  61. package/dist/grid/chrome/GridDateEditor.d.ts +22 -0
  62. package/dist/grid/chrome/GridDateEditor.js +31 -0
  63. package/dist/grid/chrome/GridFlyout.d.ts +44 -0
  64. package/dist/grid/chrome/GridFlyout.js +80 -0
  65. package/dist/grid/chrome/GridFooter.d.ts +23 -0
  66. package/dist/grid/chrome/GridFooter.js +81 -0
  67. package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
  68. package/dist/grid/chrome/GridGroupMenu.js +57 -0
  69. package/dist/grid/chrome/GridHeader.d.ts +61 -0
  70. package/dist/grid/chrome/GridHeader.js +37 -0
  71. package/dist/grid/chrome/GridLongTextEditor.d.ts +36 -0
  72. package/dist/grid/chrome/GridLongTextEditor.js +127 -0
  73. package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
  74. package/dist/grid/chrome/GridMenuRow.js +15 -0
  75. package/dist/grid/chrome/GridNameEditor.d.ts +19 -0
  76. package/dist/grid/chrome/GridNameEditor.js +36 -0
  77. package/dist/grid/chrome/GridNumberEditor.d.ts +35 -0
  78. package/dist/grid/chrome/GridNumberEditor.js +25 -0
  79. package/dist/grid/chrome/GridRangeEditor.d.ts +20 -0
  80. package/dist/grid/chrome/GridRangeEditor.js +25 -0
  81. package/dist/grid/chrome/GridRelationEditor.d.ts +21 -0
  82. package/dist/grid/chrome/GridRelationEditor.js +30 -0
  83. package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
  84. package/dist/grid/chrome/GridResizeHandle.js +19 -0
  85. package/dist/grid/chrome/GridRow.d.ts +25 -0
  86. package/dist/grid/chrome/GridRow.js +136 -0
  87. package/dist/grid/chrome/GridRowActions.d.ts +32 -0
  88. package/dist/grid/chrome/GridRowActions.js +25 -0
  89. package/dist/grid/chrome/GridRowCells.d.ts +4 -0
  90. package/dist/grid/chrome/GridRowCells.js +133 -0
  91. package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
  92. package/dist/grid/chrome/GridRowGlyph.js +13 -0
  93. package/dist/grid/chrome/GridSelectEditor.d.ts +18 -0
  94. package/dist/grid/chrome/GridSelectEditor.js +49 -0
  95. package/dist/grid/chrome/GridStructure.d.ts +48 -0
  96. package/dist/grid/chrome/GridStructure.js +45 -0
  97. package/dist/grid/chrome/GridTable.d.ts +4 -0
  98. package/dist/grid/chrome/GridTable.js +125 -0
  99. package/dist/grid/chrome/GridTableSurface.d.ts +15 -0
  100. package/dist/grid/chrome/GridTableSurface.js +6 -0
  101. package/dist/grid/chrome/GridTextEditor.d.ts +11 -0
  102. package/dist/grid/chrome/GridTextEditor.js +40 -0
  103. package/dist/grid/chrome/GridValueListEditor.d.ts +18 -0
  104. package/dist/grid/chrome/GridValueListEditor.js +36 -0
  105. package/dist/grid/chrome/StuckMarker.d.ts +16 -0
  106. package/dist/grid/chrome/StuckMarker.js +34 -0
  107. package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
  108. package/dist/grid/chrome/cell-clipboard.js +28 -0
  109. package/dist/grid/chrome/cells.d.ts +21 -0
  110. package/dist/grid/chrome/cells.js +20 -0
  111. package/dist/grid/chrome/checks.d.ts +35 -0
  112. package/dist/grid/chrome/checks.js +22 -0
  113. package/dist/grid/chrome/column-glyph.d.ts +14 -0
  114. package/dist/grid/chrome/column-glyph.js +44 -0
  115. package/dist/grid/chrome/editors.d.ts +9 -0
  116. package/dist/grid/chrome/editors.js +10 -0
  117. package/dist/grid/chrome/grid-cell-classes.d.ts +59 -0
  118. package/dist/grid/chrome/grid-cell-classes.js +30 -0
  119. package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
  120. package/dist/grid/chrome/grid-menu-search.js +7 -0
  121. package/dist/grid/chrome/grid-row-props.d.ts +131 -0
  122. package/dist/grid/chrome/grid-row-props.js +1 -0
  123. package/dist/grid/chrome/grid-styles.d.ts +37 -0
  124. package/dist/grid/chrome/grid-styles.js +8 -0
  125. package/dist/grid/chrome/grid-table-props.d.ts +173 -0
  126. package/dist/grid/chrome/grid-table-props.js +1 -0
  127. package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
  128. package/dist/grid/chrome/useGridBatchApi.js +35 -0
  129. package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
  130. package/dist/grid/chrome/useGridColumnLayout.js +206 -0
  131. package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
  132. package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
  133. package/dist/grid/chrome/useGridKeyboard.d.ts +47 -0
  134. package/dist/grid/chrome/useGridKeyboard.js +274 -0
  135. package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
  136. package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
  137. package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
  138. package/dist/grid/chrome/useGridRailReveal.js +67 -0
  139. package/dist/grid/chrome/useGridRangeActions.d.ts +49 -0
  140. package/dist/grid/chrome/useGridRangeActions.js +188 -0
  141. package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
  142. package/dist/grid/chrome/useGridRangeGestures.js +190 -0
  143. package/dist/grid/chrome/useGridRowContextMenu.d.ts +35 -0
  144. package/dist/grid/chrome/useGridRowContextMenu.js +127 -0
  145. package/dist/grid/chrome/useGridScaleStyles.d.ts +1 -0
  146. package/dist/grid/chrome/useGridScaleStyles.js +29 -0
  147. package/dist/grid/chrome/useGridScrollSync.d.ts +38 -0
  148. package/dist/grid/chrome/useGridScrollSync.js +176 -0
  149. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +55 -0
  150. package/dist/grid/chrome/useGridTableInteractionModel.js +197 -0
  151. package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
  152. package/dist/grid/chrome/useGridTableSelection.js +55 -0
  153. package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
  154. package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
  155. package/dist/grid/core/clipboard-model.d.ts +81 -0
  156. package/dist/grid/core/clipboard-model.js +291 -0
  157. package/dist/grid/core/column-values.d.ts +27 -0
  158. package/dist/grid/core/column-values.js +76 -0
  159. package/dist/grid/core/commit-model.d.ts +34 -0
  160. package/dist/grid/core/commit-model.js +3 -0
  161. package/dist/grid/core/coordinates.d.ts +48 -0
  162. package/dist/grid/core/coordinates.js +27 -0
  163. package/dist/grid/core/edit-values.d.ts +9 -0
  164. package/dist/grid/core/edit-values.js +1 -0
  165. package/dist/grid/core/editing-controller.d.ts +59 -0
  166. package/dist/grid/core/editing-controller.js +240 -0
  167. package/dist/grid/core/editing-model.d.ts +78 -0
  168. package/dist/grid/core/editing-model.js +136 -0
  169. package/dist/grid/core/grid-scale.d.ts +14 -0
  170. package/dist/grid/core/grid-scale.js +8 -0
  171. package/dist/grid/core/nav.d.ts +94 -0
  172. package/dist/grid/core/nav.js +92 -0
  173. package/dist/grid/core/pending-reconciliation.d.ts +50 -0
  174. package/dist/grid/core/pending-reconciliation.js +49 -0
  175. package/dist/grid/core/range-model.d.ts +25 -0
  176. package/dist/grid/core/range-model.js +59 -0
  177. package/dist/grid/core/spreadsheet-operations.d.ts +85 -0
  178. package/dist/grid/core/spreadsheet-operations.js +253 -0
  179. package/dist/grid/core/useGridEditing.d.ts +43 -0
  180. package/dist/grid/core/useGridEditing.js +90 -0
  181. package/dist/grid/core/useGridRange.d.ts +20 -0
  182. package/dist/grid/core/useGridRange.js +24 -0
  183. package/dist/grid/core/value-equality.d.ts +32 -0
  184. package/dist/grid/core/value-equality.js +34 -0
  185. package/dist/grid/index.d.ts +18 -0
  186. package/dist/grid/index.js +5 -0
  187. package/dist/grid/useGridTablePrefs.d.ts +50 -0
  188. package/dist/grid/useGridTablePrefs.js +101 -0
  189. package/dist/index.d.ts +0 -1
  190. package/dist/index.js +0 -1
  191. package/dist/internal/viewport.d.ts +5 -0
  192. package/dist/internal/viewport.js +29 -0
  193. package/dist/model/column-capabilities.d.ts +2 -2
  194. package/dist/model/column-state.d.ts +1 -1
  195. package/dist/model/density.js +3 -3
  196. package/dist/model/filter-capabilities.d.ts +1 -1
  197. package/dist/model/filter-capabilities.js +1 -1
  198. package/dist/model/index.d.ts +4 -6
  199. package/dist/model/index.js +0 -1
  200. package/dist/model/preferences.d.ts +7 -3
  201. package/dist/provider/ViewsProvider.d.ts +1 -1
  202. package/dist/provider/ViewsProvider.js +5 -1
  203. package/dist/provider/components.d.ts +16 -8
  204. package/dist/provider/context.d.ts +3 -2
  205. package/dist/provider/menu-groups.d.ts +8 -0
  206. package/dist/provider/menu-groups.js +38 -0
  207. package/dist/provider/ports.d.ts +22 -0
  208. package/dist/provider/ports.js +1 -0
  209. package/dist/react.d.ts +1 -1
  210. package/docs/contract.md +128 -56
  211. package/docs/getting-started.md +250 -0
  212. package/docs/guides/atoms.md +245 -0
  213. package/docs/guides/cells.md +302 -0
  214. package/docs/guides/columns.md +412 -0
  215. package/docs/guides/display.md +203 -0
  216. package/docs/guides/editors.md +404 -0
  217. package/docs/guides/ports.md +246 -0
  218. package/docs/guides/selection.md +270 -0
  219. package/docs/guides/the-grid.md +677 -0
  220. package/docs/guides/the-provider.md +446 -0
  221. package/docs/index.md +50 -0
  222. package/docs/install.md +9 -47
  223. package/docs/reference/cells.md +28 -0
  224. package/docs/reference/display.md +42 -0
  225. package/docs/reference/editors-chips.md +6 -0
  226. package/docs/reference/editors-date.md +6 -0
  227. package/docs/reference/editors-location.md +10 -0
  228. package/docs/reference/editors-name.md +6 -0
  229. package/docs/reference/editors-number.md +11 -0
  230. package/docs/reference/editors-open-values.md +9 -0
  231. package/docs/reference/editors-range.md +6 -0
  232. package/docs/reference/editors-relation.md +9 -0
  233. package/docs/reference/editors-select.md +8 -0
  234. package/docs/reference/editors-session.md +9 -0
  235. package/docs/reference/editors-value-list.md +6 -0
  236. package/docs/reference/editors.md +5 -0
  237. package/docs/reference/grid.md +39 -0
  238. package/docs/reference/react.md +86 -0
  239. package/docs/reference/selection.md +33 -0
  240. package/docs/reference/views.md +601 -0
  241. package/package.json +7 -3
  242. package/skills/views/SKILL.md +20 -5
  243. package/dist/filters/types.d.ts +0 -27
  244. package/dist/filters/types.js +0 -1
  245. package/dist/model/filter-pushdown.d.ts +0 -106
  246. package/dist/model/filter-pushdown.js +0 -147
@@ -0,0 +1,101 @@
1
+ "use client";
2
+ import { useCallback, useMemo } from "react";
3
+ import { fieldKeyOf } from "../model/view-rules.js";
4
+ import { GRID_SCALE_MULTIPLIER } from "./core/grid-scale.js";
5
+ import { normalizeGroupSummary, setAggregate, setDateStyle, setCurrency, setDecimals, setDurationStyle, setOptionColor, setPercentDisplay, setShowTime, } from "../model/preferences.js";
6
+ import { moneyReadingOf } from "../fields/money.js";
7
+ import { isMoneyReading, MONEY_READING_OPTIONS } from "../fields/currency.js";
8
+ export function useGridTablePrefs({ prefs, setPrefs, columns, viewBacked = false, }) {
9
+ const { gridVerticalBorders, gridRowIcon, gridFreezeIdentity, gridWrapCells, gridAlwaysCheckboxes, gridOptionColors, gridDateStyles, gridDurationStyles, gridShowTime, gridPercentDisplays, gridDecimals, gridCurrencies, gridAggregates, gridColumns, gridScale, groupSummary, } = prefs;
10
+ const onOptionColorChange = useCallback((key, value, color) => {
11
+ setPrefs({ gridOptionColors: setOptionColor(gridOptionColors, key, value, color) });
12
+ }, [gridOptionColors, setPrefs]);
13
+ const onDateStyleChange = useCallback((key, style) => setPrefs({ gridDateStyles: setDateStyle(gridDateStyles, key, style) }), [gridDateStyles, setPrefs]);
14
+ const onDurationStyleChange = useCallback((key, style) => setPrefs({ gridDurationStyles: setDurationStyle(gridDurationStyles, key, style) }), [gridDurationStyles, setPrefs]);
15
+ const onShowTimeChange = useCallback((key, show) => setPrefs({ gridShowTime: setShowTime(gridShowTime, key, show) }), [gridShowTime, setPrefs]);
16
+ const onPercentDisplayChange = useCallback((key, display) => setPrefs({ gridPercentDisplays: setPercentDisplay(gridPercentDisplays, key, display) }), [gridPercentDisplays, setPrefs]);
17
+ const onColumnStateChange = useCallback((next) => setPrefs({ gridColumns: next }), [setPrefs]);
18
+ const summaryParts = useMemo(() => normalizeGroupSummary(groupSummary), [groupSummary]);
19
+ const onGroupSummaryChange = useCallback((part, next) => setPrefs({
20
+ groupSummary: next
21
+ ? Array.from(new Set([...normalizeGroupSummary(groupSummary), part]))
22
+ : normalizeGroupSummary(groupSummary).filter((p) => p !== part),
23
+ }), [groupSummary, setPrefs]);
24
+ const onAggregateChange = useCallback((columnId, kind) => setPrefs({ gridAggregates: setAggregate(gridAggregates, columnId, kind) }), [gridAggregates, setPrefs]);
25
+ const numberFormats = useMemo(() => {
26
+ const out = {};
27
+ for (const col of columns) {
28
+ const key = fieldKeyOf(col);
29
+ const reading = moneyReadingOf(col);
30
+ if (gridDecimals[key] === undefined && !reading)
31
+ continue;
32
+ out[key] = {
33
+ decimals: gridDecimals[key],
34
+ ...(reading ? { currency: reading, currencyOptions: MONEY_READING_OPTIONS } : {}),
35
+ };
36
+ }
37
+ return out;
38
+ }, [columns, gridDecimals]);
39
+ const onNumberFormatChange = useCallback((key, patch) => {
40
+ if (patch.currency != null && isMoneyReading(patch.currency))
41
+ setPrefs({ gridCurrencies: setCurrency(gridCurrencies, key, patch.currency) });
42
+ if (patch.decimals === null)
43
+ setPrefs({ gridDecimals: { [key]: null } });
44
+ else if (patch.decimals !== undefined)
45
+ setPrefs({ gridDecimals: setDecimals(gridDecimals, key, patch.decimals) });
46
+ }, [gridCurrencies, gridDecimals, setPrefs]);
47
+ const gridProps = useMemo(() => ({
48
+ verticalBorders: gridVerticalBorders,
49
+ showRowIcon: gridRowIcon,
50
+ freezeIdentity: gridFreezeIdentity,
51
+ wrapCells: gridWrapCells,
52
+ alwaysCheckboxes: gridAlwaysCheckboxes,
53
+ scale: GRID_SCALE_MULTIPLIER[gridScale],
54
+ optionColors: gridOptionColors,
55
+ onOptionColorChange,
56
+ dateStyles: gridDateStyles,
57
+ onDateStyleChange,
58
+ durationStyles: gridDurationStyles,
59
+ onDurationStyleChange,
60
+ showTimeOverrides: gridShowTime,
61
+ onShowTimeChange,
62
+ percentDisplays: gridPercentDisplays,
63
+ onPercentDisplayChange,
64
+ columnState: gridColumns,
65
+ onColumnStateChange,
66
+ groupSummary: summaryParts,
67
+ onGroupSummaryChange,
68
+ aggregates: gridAggregates,
69
+ onAggregateChange,
70
+ viewBacked,
71
+ numberFormats,
72
+ onNumberFormatChange,
73
+ }), [
74
+ gridVerticalBorders,
75
+ gridRowIcon,
76
+ gridFreezeIdentity,
77
+ gridWrapCells,
78
+ gridAlwaysCheckboxes,
79
+ gridScale,
80
+ gridOptionColors,
81
+ onOptionColorChange,
82
+ gridDateStyles,
83
+ onDateStyleChange,
84
+ gridDurationStyles,
85
+ onDurationStyleChange,
86
+ gridShowTime,
87
+ onShowTimeChange,
88
+ gridPercentDisplays,
89
+ onPercentDisplayChange,
90
+ gridColumns,
91
+ onColumnStateChange,
92
+ summaryParts,
93
+ onGroupSummaryChange,
94
+ gridAggregates,
95
+ onAggregateChange,
96
+ viewBacked,
97
+ numberFormats,
98
+ onNumberFormatChange,
99
+ ]);
100
+ return { gridProps };
101
+ }
package/dist/index.d.ts CHANGED
@@ -6,7 +6,6 @@ export * from "./model/column-format.js";
6
6
  export * from "./model/column-inspect.js";
7
7
  export * from "./model/column-money.js";
8
8
  export * from "./filters/registry.js";
9
- export * from "./filters/types.js";
10
9
  export * from "./filters/text-filter.js";
11
10
  export * from "./filters/number-filter.js";
12
11
  export * from "./filters/range-filter.js";
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ export * from "./model/column-format.js";
6
6
  export * from "./model/column-inspect.js";
7
7
  export * from "./model/column-money.js";
8
8
  export * from "./filters/registry.js";
9
- export * from "./filters/types.js";
10
9
  export * from "./filters/text-filter.js";
11
10
  export * from "./filters/number-filter.js";
12
11
  export * from "./filters/range-filter.js";
@@ -0,0 +1,5 @@
1
+ /** True below 768px wide, from the first effect on; false during a server render. */
2
+ export declare function useIsMobile(): boolean;
3
+ /** True when the primary input can hover (a mouse, a trackpad); true during a server render, so
4
+ * the hover-capable rendering is what the server sends. */
5
+ export declare function useHasHover(): boolean;
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ const MOBILE_BREAKPOINT = 768;
4
+ export function useIsMobile() {
5
+ const [isMobile, setIsMobile] = useState(undefined);
6
+ useEffect(() => {
7
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
8
+ const onChange = () => {
9
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
10
+ };
11
+ mql.addEventListener("change", onChange);
12
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
13
+ return () => mql.removeEventListener("change", onChange);
14
+ }, []);
15
+ return !!isMobile;
16
+ }
17
+ export function useHasHover() {
18
+ const [hasHover, setHasHover] = useState(true);
19
+ useEffect(() => {
20
+ if (typeof window === "undefined" || !window.matchMedia)
21
+ return;
22
+ const mq = window.matchMedia("(hover: hover) and (pointer: fine)");
23
+ setHasHover(mq.matches);
24
+ const handler = (e) => setHasHover(e.matches);
25
+ mq.addEventListener("change", handler);
26
+ return () => mq.removeEventListener("change", handler);
27
+ }, []);
28
+ return hasHover;
29
+ }
@@ -153,8 +153,8 @@ export type GridWriteResult = {
153
153
  export declare function gridNormalizeWrite<Row>(col: ListColumn<Row>, next: unknown, conventions: FieldConventions,
154
154
  /** `region`: the record's country, where a phone typed without its country code is read. A host whose rows carry
155
155
  * a country passes the row's here; absent, the conventions' region reads it. `messages`: the app's words for a
156
- * refusal, the package's English when absent. `stored`: the cell's value before this edit, as stored; a phone
157
- * that comes back as it is here is kept, never read again (fields' `stored`). */
156
+ * refusal, the package's English when absent. `stored`: the cell's value before this edit, as stored; a value
157
+ * fields keeps by `stored` (a phone, a url) that comes back as it is here is kept, never read again. */
158
158
  options?: {
159
159
  region?: string | null;
160
160
  messages?: ViewsMessageResolver;
@@ -36,7 +36,7 @@ export declare const LIST_DEFAULT_MIN_WIDTH = 60;
36
36
  /**
37
37
  * The density vocabulary, shared by every view. How a view SPENDS it differs —
38
38
  * the grid multiplies its pixel scale, the rows views widen their padding — so
39
- * only the names live here; see `grid-table/core/grid-scale.ts`.
39
+ * only the names live here; see `grid/core/grid-scale.ts`.
40
40
  */
41
41
  export type ListDensity = "compact" | "default" | "spacious";
42
42
  /**
@@ -6,8 +6,8 @@ const DENSITY = {
6
6
  export function densityStyle(density) {
7
7
  const spec = DENSITY[density] ?? DENSITY.default;
8
8
  return {
9
- "--dt-row-py": spec.py,
10
- "--dt-head-mb": spec.headMb,
11
- "--dt-row-gap": spec.gap,
9
+ "--vk-row-py": spec.py,
10
+ "--vk-head-mb": spec.headMb,
11
+ "--vk-row-gap": spec.gap,
12
12
  };
13
13
  }
@@ -1 +1 @@
1
- export { ListFilterCapabilityError, validateFilterCapabilities, type ListFilterCapability, type ListFilterCapabilities, } from "../filters/registry.js";
1
+ export { type ListFilterCapability, type ListFilterCapabilities } from "../filters/registry.js";
@@ -1 +1 @@
1
- export { ListFilterCapabilityError, validateFilterCapabilities, } from "../filters/registry.js";
1
+ export {};
@@ -3,17 +3,16 @@
3
3
  *
4
4
  * What a list's columns ARE (`column-schema`), what may be DONE to them
5
5
  * (`column-capabilities`), which of them are shown and in what order
6
- * (`column-state`), how they narrow a cohort (`column-filters`,
7
- * `filter-pushdown`), and what a user has persisted about them
8
- * (`preferences`).
6
+ * (`column-state`), how they narrow a cohort (`column-filters`), and what a
7
+ * user has persisted about them (`preferences`).
9
8
  *
10
- * It lives OUTSIDE `grid-table/` because none of it is about a spreadsheet.
9
+ * It lives OUTSIDE `grid/` because none of it is about a spreadsheet.
11
10
  * A table view reads the same schema to align its columns; a card view reads
12
11
  * it to find the title field; a board would read a `select` column's `options`
13
12
  * to get its lanes; and all of them must ask `column-capabilities` before a
14
13
  * write, or a workspace lock would protect the grid and nothing else.
15
14
  *
16
- * What stayed behind in `grid-table/` is what only a spreadsheet does: cell
15
+ * What stayed behind in `grid/` is what only a spreadsheet does: cell
17
16
  * editors, range selection, clipboard, keyboard navigation, and the pixel
18
17
  * scale (`core/grid-scale.ts`).
19
18
  */
@@ -29,7 +28,6 @@ export * from "./column-types.js";
29
28
  export * from "./column-capabilities.js";
30
29
  export * from "./column-warnings.js";
31
30
  export * from "./column-filters.js";
32
- export * from "./filter-pushdown.js";
33
31
  export * from "./filter-capabilities.js";
34
32
  export * from "./preferences.js";
35
33
  export * from "./view-rules.js";
@@ -10,7 +10,6 @@ export * from "./column-types.js";
10
10
  export * from "./column-capabilities.js";
11
11
  export * from "./column-warnings.js";
12
12
  export * from "./column-filters.js";
13
- export * from "./filter-pushdown.js";
14
13
  export * from "./filter-capabilities.js";
15
14
  export * from "./preferences.js";
16
15
  export * from "./view-rules.js";
@@ -132,8 +132,10 @@ export declare function isGroupSummaryPart(value: unknown): value is ListGroupSu
132
132
  *
133
133
  * It was a single `"count" | "total"` before, so every persisted blob out there
134
134
  * still holds a bare string — parsed here rather than migrated, because a view
135
- * pref is not worth a migration and an unrecognised value should degrade to the
136
- * default instead of rendering nothing.
135
+ * pref is not worth a migration. Keeps the parts it recognises and drops the
136
+ * rest, so a value it cannot read comes back as `[]`, a bare group name, never
137
+ * the default: a caller with no stored value applies
138
+ * `LIST_VIEW_PREF_DEFAULTS.groupSummary` itself before calling.
137
139
  */
138
140
  export declare function normalizeGroupSummary(value: unknown): ListGroupSummaryPart[];
139
141
  export declare const LIST_VIEW_PREF_DEFAULTS: ListViewPrefs;
@@ -141,7 +143,9 @@ export declare const LIST_VIEW_PREF_DEFAULTS: ListViewPrefs;
141
143
  export declare function setFilterRule(current: ListFilterRuleState, columnId: string, rule: ListFilterRule | null): ListFilterRuleState;
142
144
  export declare function setOptionColor(current: ListOptionColorOverrides, columnId: string, value: string, color: ListSelectColor | null): ListOptionColorOverrides;
143
145
  export declare function setDateStyle(current: ListDateStyleOverrides, columnId: string, style: ListDateStyle): ListDateStyleOverrides;
144
- /** Set one column's duration rendering, keeping the map sparse. */
146
+ /** Set one column's duration rendering. Always writes the entry, the column's
147
+ * own style included: unlike `setFilterRule` and `setOptionColor`, it never
148
+ * drops one. */
145
149
  export declare function setDurationStyle(current: ListDurationStyleOverrides, columnId: string, style: ListDurationStyle): ListDurationStyleOverrides;
146
150
  export declare function setShowTime(current: ListShowTimeOverrides, columnId: string, show: boolean): ListShowTimeOverrides;
147
151
  export declare function setPercentDisplay(current: ListPercentDisplayOverrides, key: string, display: PercentDisplay): ListPercentDisplayOverrides;
@@ -5,7 +5,7 @@ import type { ViewsAtoms } from "../atoms/types.js";
5
5
  import type { FieldPresentation } from "../display/options.js";
6
6
  import type { ViewsComponents } from "./components.js";
7
7
  import type { ViewsIcons } from "./icons.js";
8
- import type { ViewsPorts } from "./ports.js";
8
+ import { type ViewsPorts } from "./ports.js";
9
9
  export { useViews, type ViewsContextValue } from "./context.js";
10
10
  export type ViewsProviderProps = {
11
11
  components: ViewsComponents;
@@ -4,9 +4,13 @@ import { useMemo } 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 { withSettledGroups } from "./menu-groups.js";
8
+ import { browserConfirm } from "./ports.js";
7
9
  export { useViews } from "./context.js";
8
10
  export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, }) {
9
11
  const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
10
- const value = useMemo(() => ({ components, atoms: merged, conventions, icons, ports, messages, presentation }), [components, merged, conventions, icons, ports, messages, presentation]);
12
+ const settled = useMemo(() => ({ ...components, Menu: withSettledGroups(components.Menu) }), [components]);
13
+ const resolved = useMemo(() => (ports.confirm ? ports : { ...ports, confirm: browserConfirm }), [ports]);
14
+ const value = useMemo(() => ({ components: settled, atoms: merged, conventions, icons, ports: resolved, messages, presentation }), [settled, merged, conventions, icons, resolved, messages, presentation]);
11
15
  return _jsx(ViewsContext.Provider, { value: value, children: children });
12
16
  }
@@ -32,7 +32,8 @@ export type ViewsPopoverProps = {
32
32
  sideOffset?: number;
33
33
  alignOffset?: number;
34
34
  /** False keeps focus where it was when the popup opens (an editor that owns
35
- * its own input). Default true. */
35
+ * its own input); that editor focuses its input with `preventScroll`, so the
36
+ * page stays where it is however the popup places itself. Default true. */
36
37
  initialFocus?: boolean;
37
38
  /** Called on a press outside the popup before it closes; return false to keep it open.
38
39
  * `event` is the pointer press, with its `target` where the press landed, also when the
@@ -42,8 +43,9 @@ export type ViewsPopoverProps = {
42
43
  /** Called on Escape before the popup closes; return false to keep it open. */
43
44
  onEscape?: (event: KeyboardEvent) => void | false;
44
45
  /** The popup's look. `panel` is the app's card popover; `menu` is its menu
45
- * panel, for a popover that holds a list (no inset: the list carries its
46
- * own). Default `panel`. */
46
+ * panel's surface, for a popover that holds a list: no inset (the list
47
+ * carries its own) and no card width (it is as wide as its list). Default
48
+ * `panel`. */
47
49
  chrome?: "panel" | "menu";
48
50
  /** A click inside the popup. A popup is a portal, so its clicks still bubble
49
51
  * through the React tree to the anchor's row; the rendering stops them here. */
@@ -93,7 +95,8 @@ export type ViewsMenuItem = {
93
95
  /** A checkable row: the app draws its tick. A checkable row closes the menu like any row. */
94
96
  checked?: boolean;
95
97
  /** A group: its rows drawn in place under this row's label, never a flyout. A group row is a
96
- * label, not a target: its own `onSelect`, `href` and `checked` are ignored. */
98
+ * label, not a target: its own `onSelect`, `href` and `checked` are ignored. A disabled group
99
+ * disables every row under it: the provider hands the app's `Menu` those rows already `disabled`. */
97
100
  children?: ViewsMenuItem[];
98
101
  separatorBefore?: boolean;
99
102
  /** A keyboard hint drawn at the row's end, never bound by the menu. */
@@ -101,6 +104,8 @@ export type ViewsMenuItem = {
101
104
  /** A link item: the row is an anchor and `onSelect` still fires. */
102
105
  href?: string;
103
106
  };
107
+ /** Opens at `anchor`, with no trigger child and no flyouts: on Base UI, the menu's root,
108
+ * positioner and popup, the anchor handed to the positioner. */
104
109
  export type ViewsMenuProps = {
105
110
  open: boolean;
106
111
  onOpenChange: ViewsOpenChange;
@@ -152,8 +157,9 @@ export type ViewsCommandParts = {
152
157
  value: string;
153
158
  onSelect: (value: string) => void;
154
159
  disabled?: boolean;
155
- /** The value this item stands for is the current one: the app draws its chosen mark on
156
- * the item (the row inside draws the check). */
160
+ /** The value this item stands for is the current one. The app colours the item as its
161
+ * chosen row; the check is the package's, drawn by the row inside, so the item draws no
162
+ * tick of its own. */
157
163
  chosen?: boolean;
158
164
  children: ReactNode;
159
165
  className?: string;
@@ -186,7 +192,7 @@ export type ViewsCollapseProps = {
186
192
  clipClassName?: string;
187
193
  durationMs?: number;
188
194
  };
189
- /** A phone sheet. An app whose sheet has no snap points ignores `snap`. */
195
+ /** A phone sheet. `snap` is a hint: an app whose sheet has no snap points ignores it. */
190
196
  export type ViewsSheetProps = {
191
197
  open: boolean;
192
198
  onOpenChange: ViewsOpenChange;
@@ -207,7 +213,9 @@ export type ViewsComponents = {
207
213
  Collapse: ComponentType<ViewsCollapseProps>;
208
214
  Sheet: ComponentType<ViewsSheetProps>;
209
215
  /** The app's own icon component by the app's own names, for glyphs a host
210
- * declares (`rowIcon`, a binding's `icon`). Semantic glyphs use `icons`. */
216
+ * declares (`rowIcon`, a binding's `icon`). It draws on the first paint,
217
+ * because rows are measured as they mount: map the names from a static
218
+ * record, never icons loaded on demand. Semantic glyphs use `icons`. */
211
219
  AppIcon: ComponentType<{
212
220
  name: string;
213
221
  className?: string;
@@ -4,12 +4,13 @@ import type { ViewsAtoms } from "../atoms/types.js";
4
4
  import type { FieldPresentation } from "../display/options.js";
5
5
  import type { ViewsComponents } from "./components.js";
6
6
  import type { ViewsIcons } from "./icons.js";
7
- import type { ViewsPorts } from "./ports.js";
7
+ import type { ViewsResolvedPorts } from "./ports.js";
8
8
  export type ViewsContextValue = {
9
9
  components: ViewsComponents;
10
10
  atoms: ViewsAtoms;
11
11
  icons: ViewsIcons;
12
- ports: ViewsPorts;
12
+ /** The app's ports, with `confirm` always a function (the browser's where the app handed none). */
13
+ ports: ViewsResolvedPorts;
13
14
  messages: ViewsMessageResolver;
14
15
  conventions: FieldConventions;
15
16
  /** The app's formatting: given the package's defaults, return the app's. */
@@ -0,0 +1,8 @@
1
+ import { type ComponentType } from "react";
2
+ import type { ViewsMenuItem, ViewsMenuProps } from "./components.js";
3
+ /** The items with every row under a disabled group marked `disabled`, at every depth. Only the
4
+ * path to a disabled group is copied; with none, the same array comes back. */
5
+ export declare function settleMenuGroups(items: ViewsMenuItem[]): ViewsMenuItem[];
6
+ /** The app's Menu, handed its items settled. One wrapper per app Menu, so an open menu never
7
+ * remounts; a wrapper handed in again (a nested provider) comes back as it is. */
8
+ export declare function withSettledGroups(Menu: ComponentType<ViewsMenuProps>): ComponentType<ViewsMenuProps>;
@@ -0,0 +1,38 @@
1
+ import { createElement, useMemo } from "react";
2
+ function disableAll(items) {
3
+ return items.map((item) => ({
4
+ ...item,
5
+ disabled: true,
6
+ ...(item.children && { children: disableAll(item.children) }),
7
+ }));
8
+ }
9
+ export function settleMenuGroups(items) {
10
+ let changed = false;
11
+ const settled = items.map((item) => {
12
+ if (!item.children || item.children.length === 0)
13
+ return item;
14
+ const children = item.disabled ? disableAll(item.children) : settleMenuGroups(item.children);
15
+ if (children === item.children)
16
+ return item;
17
+ changed = true;
18
+ return { ...item, children };
19
+ });
20
+ return changed ? settled : items;
21
+ }
22
+ const wrappers = new WeakMap();
23
+ const settledMenus = new WeakSet();
24
+ export function withSettledGroups(Menu) {
25
+ if (settledMenus.has(Menu))
26
+ return Menu;
27
+ const known = wrappers.get(Menu);
28
+ if (known)
29
+ return known;
30
+ function SettledMenu(props) {
31
+ const items = useMemo(() => settleMenuGroups(props.items), [props.items]);
32
+ return createElement(Menu, { ...props, items });
33
+ }
34
+ SettledMenu.displayName = `Settled(${Menu.displayName ?? (Menu.name || "Menu")})`;
35
+ wrappers.set(Menu, SettledMenu);
36
+ settledMenus.add(SettledMenu);
37
+ return SettledMenu;
38
+ }
@@ -25,11 +25,33 @@ export type ViewsPrefsPort = {
25
25
  set: <T>(key: string, value: T) => void;
26
26
  subscribe: (key: string, listener: () => void) => () => void;
27
27
  };
28
+ /** A question asked before an act, for the person to answer: the app's own dialog, or the browser's. */
29
+ export type ViewsConfirmRequest = {
30
+ /** The question, worded by the package's message (a row's Delete: `views.menus.row-delete-confirm`). */
31
+ message: string;
32
+ /** The yes button's words (a row's Delete: `views.menus.row-delete`). */
33
+ confirmLabel: string;
34
+ /** What the act is done to, as the host names it (a row's `deleteLabel`). Absent when it names nothing. */
35
+ subject?: string;
36
+ /** The act removes something: the app draws its destructive look. */
37
+ destructive?: boolean;
38
+ };
39
+ /** Resolves to whether the person said yes. */
40
+ export type ViewsConfirmPort = (request: ViewsConfirmRequest) => Promise<boolean>;
28
41
  export type ViewsPorts = {
29
42
  toast: ViewsToastPort;
30
43
  haptics: ViewsHapticsPort;
31
44
  clipboard: ViewsClipboardPort;
32
45
  viewPrefs: ViewsPrefsPort;
46
+ /** Asks before a destructive act (a row's Delete). Absent: the browser's own confirm with `message`. */
47
+ confirm?: ViewsConfirmPort;
48
+ };
49
+ /** The ports as the provider hands them on: `confirm` always there, the browser's where the app
50
+ * handed none. */
51
+ export type ViewsResolvedPorts = ViewsPorts & {
52
+ confirm: ViewsConfirmPort;
33
53
  };
54
+ /** The browser's own dialog, read when it is asked, so a server render never reaches `window`. */
55
+ export declare const browserConfirm: ViewsConfirmPort;
34
56
  /** Ports that do nothing: a server render, a test, an app without a device. */
35
57
  export declare const NOOP_PORTS: ViewsPorts;
@@ -1,3 +1,4 @@
1
+ export const browserConfirm = async ({ message }) => window.confirm(message);
1
2
  const _portsMatchContract = true;
2
3
  void _portsMatchContract;
3
4
  export const NOOP_PORTS = {
package/dist/react.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { ViewsContextValue, ViewsProviderProps } from "./provider/ViewsProv
3
3
  export type { ViewsAlign, ViewsAnchor, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsMenuItem, ViewsMenuProps, ViewsOpenChange, ViewsPopoverProps, ViewsSheetProps, ViewsSide, ViewsTooltipProps, } from "./provider/components.js";
4
4
  export type { ViewsIconProps, ViewsIcons } from "./provider/icons.js";
5
5
  export { NOOP_PORTS } from "./provider/ports.js";
6
- export type { ViewsClipboardPort, ViewsHapticsPort, ViewsPorts, ViewsPrefsPort, ViewsToastPort, } from "./provider/ports.js";
6
+ export type { ViewsClipboardPort, ViewsConfirmPort, ViewsConfirmRequest, ViewsHapticsPort, ViewsPorts, ViewsPrefsPort, ViewsResolvedPorts, ViewsToastPort, } from "./provider/ports.js";
7
7
  export { DEFAULT_VIEWS_ATOMS } from "./atoms/defaults.js";
8
8
  export type { ViewsAtoms, ViewsCommandMenuProps, ViewsRowMenuItem, ViewsRowMenuProps, ViewsListProps, ViewsRelationLinkProps, ViewsLoadingProps, ViewsLoadMoreProps, ViewsPlatformMarkProps, ViewsRowContentProps, ViewsRowProps, ViewsStatusBadgeProps, ViewsStatusMarkerProps, ViewsTagProps, ViewsTickBoxProps, } from "./atoms/types.js";
9
9
  export type { ComponentName, PortName, ViewsIconName, ViewsMessage, ViewsMessageResolver } from "./contract.js";