@viewkitjs/views 0.1.0 → 0.3.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 (390) hide show
  1. package/CHANGELOG.md +767 -1
  2. package/README.md +92 -41
  3. package/dist/atoms/LoadMore.js +11 -1
  4. package/dist/atoms/Row.js +1 -1
  5. package/dist/atoms/RowMenu.d.ts +1 -1
  6. package/dist/atoms/RowMenu.js +20 -6
  7. package/dist/atoms/types.d.ts +4 -4
  8. package/dist/cells/cell-format.d.ts +3 -3
  9. package/dist/cells/cell-title.d.ts +1 -2
  10. package/dist/cells/cell-title.js +2 -2
  11. package/dist/cells/cell-values.js +6 -3
  12. package/dist/contract.d.ts +79 -8
  13. package/dist/contract.js +55 -8
  14. package/dist/display/converted.d.ts +19 -0
  15. package/dist/display/converted.js +12 -0
  16. package/dist/display/format.d.ts +16 -1
  17. package/dist/display/format.js +10 -1
  18. package/dist/display/index.d.ts +2 -1
  19. package/dist/display/index.js +2 -1
  20. package/dist/display/link-click.d.ts +11 -0
  21. package/dist/display/link-click.js +3 -0
  22. package/dist/display/link.js +12 -6
  23. package/dist/display/location.d.ts +4 -3
  24. package/dist/display/location.js +12 -5
  25. package/dist/display/multi-value.d.ts +1 -1
  26. package/dist/display/multi-value.js +1 -1
  27. package/dist/display/options.d.ts +8 -2
  28. package/dist/display/percent.js +10 -3
  29. package/dist/display/phone.d.ts +2 -1
  30. package/dist/display/phone.js +11 -2
  31. package/dist/display/relation.js +1 -1
  32. package/dist/editors/ChipsEditor.d.ts +9 -4
  33. package/dist/editors/ChipsEditor.js +7 -3
  34. package/dist/editors/DateEditor.d.ts +21 -6
  35. package/dist/editors/DateEditor.js +118 -30
  36. package/dist/editors/EditorPanel.d.ts +61 -0
  37. package/dist/editors/EditorPanel.js +54 -0
  38. package/dist/editors/LocationEditor.d.ts +3 -0
  39. package/dist/editors/LocationEditor.js +28 -21
  40. package/dist/editors/NameEditor.d.ts +3 -0
  41. package/dist/editors/NameEditor.js +15 -10
  42. package/dist/editors/NumberEditor.d.ts +3 -0
  43. package/dist/editors/NumberEditor.js +7 -7
  44. package/dist/editors/RangeEditor.d.ts +16 -1
  45. package/dist/editors/RangeEditor.js +22 -6
  46. package/dist/editors/RelationEditor.d.ts +13 -28
  47. package/dist/editors/RelationEditor.js +17 -40
  48. package/dist/editors/RelationSetEditor.d.ts +53 -0
  49. package/dist/editors/RelationSetEditor.js +112 -0
  50. package/dist/editors/SelectEditor.d.ts +21 -3
  51. package/dist/editors/SelectEditor.js +55 -9
  52. package/dist/editors/TextEditor.d.ts +51 -0
  53. package/dist/editors/TextEditor.js +81 -0
  54. package/dist/editors/ValueListEditor.d.ts +5 -2
  55. package/dist/editors/ValueListEditor.js +11 -9
  56. package/dist/editors/edit-cores.d.ts +13 -10
  57. package/dist/editors/edit-cores.js +7 -6
  58. package/dist/editors/edit-session.d.ts +21 -11
  59. package/dist/editors/edit-session.js +19 -5
  60. package/dist/editors/keep-inside.d.ts +12 -0
  61. package/dist/editors/keep-inside.js +20 -0
  62. package/dist/editors/open-value.d.ts +21 -0
  63. package/dist/editors/open-value.js +36 -0
  64. package/dist/editors/open-values.d.ts +4 -0
  65. package/dist/editors/open-values.js +7 -0
  66. package/dist/editors/relation-kinds.d.ts +7 -0
  67. package/dist/editors/relation-kinds.js +21 -0
  68. package/dist/editors/relation-panel.d.ts +69 -0
  69. package/dist/editors/relation-panel.js +40 -0
  70. package/dist/field-row/FieldNoteLine.d.ts +14 -0
  71. package/dist/field-row/FieldNoteLine.js +14 -0
  72. package/dist/field-row/FieldRow.d.ts +73 -0
  73. package/dist/field-row/FieldRow.js +157 -0
  74. package/dist/field-row/FieldRowLane.d.ts +19 -0
  75. package/dist/field-row/FieldRowLane.js +11 -0
  76. package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
  77. package/dist/field-row/editors/RowChipsEditor.js +25 -0
  78. package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
  79. package/dist/field-row/editors/RowDateEditor.js +18 -0
  80. package/dist/field-row/editors/RowEditor.d.ts +39 -0
  81. package/dist/field-row/editors/RowEditor.js +64 -0
  82. package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
  83. package/dist/field-row/editors/RowNameEditor.js +15 -0
  84. package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
  85. package/dist/field-row/editors/RowNumberEditor.js +18 -0
  86. package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
  87. package/dist/field-row/editors/RowPlaceEditor.js +18 -0
  88. package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
  89. package/dist/field-row/editors/RowRangeEditor.js +15 -0
  90. package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
  91. package/dist/field-row/editors/RowRelationEditor.js +77 -0
  92. package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
  93. package/dist/field-row/editors/RowSelectEditor.js +23 -0
  94. package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
  95. package/dist/field-row/editors/RowTextEditor.js +16 -0
  96. package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
  97. package/dist/field-row/editors/RowValueListEditor.js +21 -0
  98. package/dist/field-row/editors/host.d.ts +59 -0
  99. package/dist/field-row/editors/host.js +1 -0
  100. package/dist/field-row/editors/row-session.d.ts +49 -0
  101. package/dist/field-row/editors/row-session.js +49 -0
  102. package/dist/field-row/index.d.ts +5 -0
  103. package/dist/field-row/index.js +5 -0
  104. package/dist/field-row/row-target.d.ts +20 -0
  105. package/dist/field-row/row-target.js +3 -0
  106. package/dist/field-row/useFieldWrite.d.ts +45 -0
  107. package/dist/field-row/useFieldWrite.js +190 -0
  108. package/dist/field-row/useRowSettlement.d.ts +33 -0
  109. package/dist/field-row/useRowSettlement.js +23 -0
  110. package/dist/fields/binding.d.ts +7 -2
  111. package/dist/fields/binding.js +13 -6
  112. package/dist/fields/currency.d.ts +0 -10
  113. package/dist/fields/currency.js +0 -14
  114. package/dist/fields/edit-core-types.d.ts +9 -9
  115. package/dist/fields/edit-core-types.js +6 -6
  116. package/dist/fields/money.d.ts +6 -0
  117. package/dist/fields/money.js +11 -0
  118. package/dist/fields/number-edit.d.ts +6 -0
  119. package/dist/fields/number-edit.js +4 -0
  120. package/dist/fields/prepare-write.js +6 -1
  121. package/dist/fields/relation-source-types.d.ts +12 -0
  122. package/dist/fields/write-target.d.ts +50 -0
  123. package/dist/fields/write-target.js +10 -0
  124. package/dist/filters/filter-model.d.ts +0 -1
  125. package/dist/filters/registry.d.ts +3 -36
  126. package/dist/filters/registry.js +0 -38
  127. package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
  128. package/dist/grid/chrome/GridAddColumn.js +29 -0
  129. package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
  130. package/dist/grid/chrome/GridAggregateMenu.js +29 -0
  131. package/dist/grid/chrome/GridCellEditors.d.ts +71 -0
  132. package/dist/grid/chrome/GridCellEditors.js +126 -0
  133. package/dist/grid/chrome/GridCellOutline.d.ts +49 -0
  134. package/dist/grid/chrome/GridCellOutline.js +16 -0
  135. package/dist/grid/chrome/GridChipsEditor.d.ts +38 -0
  136. package/dist/grid/chrome/GridChipsEditor.js +35 -0
  137. package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
  138. package/dist/grid/chrome/GridColumnColorSection.js +40 -0
  139. package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
  140. package/dist/grid/chrome/GridColumnDateSection.js +23 -0
  141. package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
  142. package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
  143. package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
  144. package/dist/grid/chrome/GridColumnMenu.js +103 -0
  145. package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
  146. package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
  147. package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
  148. package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
  149. package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
  150. package/dist/grid/chrome/GridColumnSortSection.js +16 -0
  151. package/dist/grid/chrome/GridDateEditor.d.ts +34 -0
  152. package/dist/grid/chrome/GridDateEditor.js +19 -0
  153. package/dist/grid/chrome/GridFlyout.d.ts +44 -0
  154. package/dist/grid/chrome/GridFlyout.js +80 -0
  155. package/dist/grid/chrome/GridFooter.d.ts +33 -0
  156. package/dist/grid/chrome/GridFooter.js +85 -0
  157. package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
  158. package/dist/grid/chrome/GridGroupMenu.js +64 -0
  159. package/dist/grid/chrome/GridHeader.d.ts +66 -0
  160. package/dist/grid/chrome/GridHeader.js +42 -0
  161. package/dist/grid/chrome/GridLongTextEditor.d.ts +55 -0
  162. package/dist/grid/chrome/GridLongTextEditor.js +69 -0
  163. package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
  164. package/dist/grid/chrome/GridMenuRow.js +15 -0
  165. package/dist/grid/chrome/GridNameEditor.d.ts +24 -0
  166. package/dist/grid/chrome/GridNameEditor.js +21 -0
  167. package/dist/grid/chrome/GridNumberEditor.d.ts +49 -0
  168. package/dist/grid/chrome/GridNumberEditor.js +51 -0
  169. package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
  170. package/dist/grid/chrome/GridPlaceEditor.js +22 -0
  171. package/dist/grid/chrome/GridRangeEditor.d.ts +30 -0
  172. package/dist/grid/chrome/GridRangeEditor.js +21 -0
  173. package/dist/grid/chrome/GridRelationEditor.d.ts +45 -0
  174. package/dist/grid/chrome/GridRelationEditor.js +92 -0
  175. package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
  176. package/dist/grid/chrome/GridResizeHandle.js +19 -0
  177. package/dist/grid/chrome/GridRow.d.ts +31 -0
  178. package/dist/grid/chrome/GridRow.js +179 -0
  179. package/dist/grid/chrome/GridRowActions.d.ts +32 -0
  180. package/dist/grid/chrome/GridRowActions.js +25 -0
  181. package/dist/grid/chrome/GridRowCells.d.ts +4 -0
  182. package/dist/grid/chrome/GridRowCells.js +128 -0
  183. package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
  184. package/dist/grid/chrome/GridRowGlyph.js +13 -0
  185. package/dist/grid/chrome/GridSelectEditor.d.ts +33 -0
  186. package/dist/grid/chrome/GridSelectEditor.js +43 -0
  187. package/dist/grid/chrome/GridStructure.d.ts +47 -0
  188. package/dist/grid/chrome/GridStructure.js +41 -0
  189. package/dist/grid/chrome/GridTable.d.ts +4 -0
  190. package/dist/grid/chrome/GridTable.js +192 -0
  191. package/dist/grid/chrome/GridTableSurface.d.ts +52 -0
  192. package/dist/grid/chrome/GridTableSurface.js +15 -0
  193. package/dist/grid/chrome/GridTextEditor.d.ts +45 -0
  194. package/dist/grid/chrome/GridTextEditor.js +38 -0
  195. package/dist/grid/chrome/GridValueListEditor.d.ts +30 -0
  196. package/dist/grid/chrome/GridValueListEditor.js +19 -0
  197. package/dist/grid/chrome/StuckMarker.d.ts +16 -0
  198. package/dist/grid/chrome/StuckMarker.js +34 -0
  199. package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
  200. package/dist/grid/chrome/cell-clipboard.js +28 -0
  201. package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
  202. package/dist/grid/chrome/cell-cut-off.js +20 -0
  203. package/dist/grid/chrome/cells.d.ts +21 -0
  204. package/dist/grid/chrome/cells.js +19 -0
  205. package/dist/grid/chrome/checks.d.ts +32 -0
  206. package/dist/grid/chrome/checks.js +32 -0
  207. package/dist/grid/chrome/column-glyph.d.ts +14 -0
  208. package/dist/grid/chrome/column-glyph.js +44 -0
  209. package/dist/grid/chrome/editors.d.ts +9 -0
  210. package/dist/grid/chrome/editors.js +10 -0
  211. package/dist/grid/chrome/grid-cell-classes.d.ts +53 -0
  212. package/dist/grid/chrome/grid-cell-classes.js +32 -0
  213. package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
  214. package/dist/grid/chrome/grid-cell-link.js +9 -0
  215. package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
  216. package/dist/grid/chrome/grid-edit-session.js +118 -0
  217. package/dist/grid/chrome/grid-hover.d.ts +60 -0
  218. package/dist/grid/chrome/grid-hover.js +81 -0
  219. package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
  220. package/dist/grid/chrome/grid-menu-focus.js +93 -0
  221. package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
  222. package/dist/grid/chrome/grid-menu-search.js +7 -0
  223. package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
  224. package/dist/grid/chrome/grid-row-menu-key.js +36 -0
  225. package/dist/grid/chrome/grid-row-props.d.ts +143 -0
  226. package/dist/grid/chrome/grid-row-props.js +1 -0
  227. package/dist/grid/chrome/grid-row-window.d.ts +61 -0
  228. package/dist/grid/chrome/grid-row-window.js +212 -0
  229. package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
  230. package/dist/grid/chrome/grid-scroll-owner.js +75 -0
  231. package/dist/grid/chrome/grid-styles.d.ts +40 -0
  232. package/dist/grid/chrome/grid-styles.js +9 -0
  233. package/dist/grid/chrome/grid-table-props.d.ts +172 -0
  234. package/dist/grid/chrome/grid-table-props.js +1 -0
  235. package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
  236. package/dist/grid/chrome/useGridBatchApi.js +35 -0
  237. package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
  238. package/dist/grid/chrome/useGridColumnLayout.js +206 -0
  239. package/dist/grid/chrome/useGridFocus.d.ts +45 -0
  240. package/dist/grid/chrome/useGridFocus.js +122 -0
  241. package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
  242. package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
  243. package/dist/grid/chrome/useGridKeyboard.d.ts +64 -0
  244. package/dist/grid/chrome/useGridKeyboard.js +450 -0
  245. package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
  246. package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
  247. package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
  248. package/dist/grid/chrome/useGridRailReveal.js +67 -0
  249. package/dist/grid/chrome/useGridRangeActions.d.ts +51 -0
  250. package/dist/grid/chrome/useGridRangeActions.js +195 -0
  251. package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
  252. package/dist/grid/chrome/useGridRangeGestures.js +237 -0
  253. package/dist/grid/chrome/useGridRowContextMenu.d.ts +37 -0
  254. package/dist/grid/chrome/useGridRowContextMenu.js +153 -0
  255. package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -0
  256. package/dist/grid/chrome/useGridScaleStyles.js +28 -0
  257. package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
  258. package/dist/grid/chrome/useGridScrollArea.js +65 -0
  259. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +78 -0
  260. package/dist/grid/chrome/useGridTableInteractionModel.js +249 -0
  261. package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
  262. package/dist/grid/chrome/useGridTableSelection.js +55 -0
  263. package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
  264. package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
  265. package/dist/grid/core/clipboard-model.d.ts +83 -0
  266. package/dist/grid/core/clipboard-model.js +291 -0
  267. package/dist/grid/core/column-values.d.ts +27 -0
  268. package/dist/grid/core/column-values.js +76 -0
  269. package/dist/grid/core/commit-model.d.ts +41 -0
  270. package/dist/grid/core/commit-model.js +3 -0
  271. package/dist/grid/core/coordinates.d.ts +48 -0
  272. package/dist/grid/core/coordinates.js +27 -0
  273. package/dist/grid/core/edge-scroll.d.ts +21 -0
  274. package/dist/grid/core/edge-scroll.js +23 -0
  275. package/dist/grid/core/edit-values.d.ts +9 -0
  276. package/dist/grid/core/edit-values.js +1 -0
  277. package/dist/grid/core/editing-controller.d.ts +60 -0
  278. package/dist/grid/core/editing-controller.js +266 -0
  279. package/dist/grid/core/editing-model.d.ts +87 -0
  280. package/dist/grid/core/editing-model.js +148 -0
  281. package/dist/grid/core/flat-rows.d.ts +35 -0
  282. package/dist/grid/core/flat-rows.js +20 -0
  283. package/dist/grid/core/grid-aria.d.ts +27 -0
  284. package/dist/grid/core/grid-aria.js +39 -0
  285. package/dist/grid/core/grid-focus.d.ts +54 -0
  286. package/dist/grid/core/grid-focus.js +148 -0
  287. package/dist/grid/core/grid-scale.d.ts +14 -0
  288. package/dist/grid/core/grid-scale.js +8 -0
  289. package/dist/grid/core/nav.d.ts +94 -0
  290. package/dist/grid/core/nav.js +92 -0
  291. package/dist/grid/core/pending-reconciliation.d.ts +53 -0
  292. package/dist/grid/core/pending-reconciliation.js +51 -0
  293. package/dist/grid/core/range-model.d.ts +25 -0
  294. package/dist/grid/core/range-model.js +59 -0
  295. package/dist/grid/core/row-window.d.ts +40 -0
  296. package/dist/grid/core/row-window.js +43 -0
  297. package/dist/grid/core/spreadsheet-operations.d.ts +101 -0
  298. package/dist/grid/core/spreadsheet-operations.js +280 -0
  299. package/dist/grid/core/useGridEditing.d.ts +46 -0
  300. package/dist/grid/core/useGridEditing.js +93 -0
  301. package/dist/grid/core/useGridRange.d.ts +20 -0
  302. package/dist/grid/core/useGridRange.js +24 -0
  303. package/dist/grid/core/value-equality.d.ts +54 -0
  304. package/dist/grid/core/value-equality.js +80 -0
  305. package/dist/grid/index.d.ts +18 -0
  306. package/dist/grid/index.js +5 -0
  307. package/dist/grid/useGridTablePrefs.d.ts +49 -0
  308. package/dist/grid/useGridTablePrefs.js +99 -0
  309. package/dist/index.d.ts +1 -1
  310. package/dist/index.js +1 -1
  311. package/dist/internal/viewport.d.ts +3 -0
  312. package/dist/internal/viewport.js +15 -0
  313. package/dist/model/column-capabilities.d.ts +3 -2
  314. package/dist/model/column-capabilities.js +28 -8
  315. package/dist/model/column-from.js +3 -0
  316. package/dist/model/column-inspect.d.ts +10 -2
  317. package/dist/model/column-inspect.js +9 -0
  318. package/dist/model/column-schema.d.ts +6 -1
  319. package/dist/model/column-state.d.ts +1 -1
  320. package/dist/model/column-types.d.ts +3 -1
  321. package/dist/model/column-types.js +1 -1
  322. package/dist/model/density.js +3 -3
  323. package/dist/model/filter-capabilities.d.ts +1 -1
  324. package/dist/model/filter-capabilities.js +1 -1
  325. package/dist/model/index.d.ts +4 -6
  326. package/dist/model/index.js +0 -1
  327. package/dist/model/preferences.d.ts +7 -7
  328. package/dist/model/preferences.js +0 -1
  329. package/dist/model/prefs-buckets.d.ts +0 -1
  330. package/dist/model/prefs-buckets.js +0 -3
  331. package/dist/model/render-count.d.ts +6 -0
  332. package/dist/model/render-count.js +11 -0
  333. package/dist/provider/ViewsProvider.d.ts +6 -2
  334. package/dist/provider/ViewsProvider.js +12 -2
  335. package/dist/provider/components.d.ts +35 -9
  336. package/dist/provider/components.js +4 -2
  337. package/dist/provider/context.d.ts +8 -4
  338. package/dist/provider/desktop.d.ts +9 -0
  339. package/dist/provider/desktop.js +22 -0
  340. package/dist/provider/menu-groups.d.ts +8 -0
  341. package/dist/provider/menu-groups.js +38 -0
  342. package/dist/provider/plain-input.d.ts +8 -0
  343. package/dist/provider/plain-input.js +5 -0
  344. package/dist/provider/ports.d.ts +22 -0
  345. package/dist/provider/ports.js +1 -0
  346. package/dist/react.d.ts +3 -2
  347. package/dist/react.js +1 -0
  348. package/dist/selection/SelectCheckbox.d.ts +3 -1
  349. package/dist/selection/SelectCheckbox.js +2 -2
  350. package/dist/selection/useCheckDragSelect.js +6 -5
  351. package/docs/contract.md +202 -72
  352. package/docs/getting-started.md +250 -0
  353. package/docs/guides/atoms.md +245 -0
  354. package/docs/guides/cells.md +302 -0
  355. package/docs/guides/columns.md +413 -0
  356. package/docs/guides/display.md +204 -0
  357. package/docs/guides/editors.md +462 -0
  358. package/docs/guides/ports.md +246 -0
  359. package/docs/guides/selection.md +270 -0
  360. package/docs/guides/the-grid.md +696 -0
  361. package/docs/guides/the-provider.md +448 -0
  362. package/docs/index.md +52 -0
  363. package/docs/install.md +9 -47
  364. package/docs/reference/cells.md +28 -0
  365. package/docs/reference/display.md +44 -0
  366. package/docs/reference/editors-chips.md +6 -0
  367. package/docs/reference/editors-date.md +6 -0
  368. package/docs/reference/editors-location.md +10 -0
  369. package/docs/reference/editors-name.md +6 -0
  370. package/docs/reference/editors-number.md +11 -0
  371. package/docs/reference/editors-open-values.md +10 -0
  372. package/docs/reference/editors-panel.md +12 -0
  373. package/docs/reference/editors-range.md +6 -0
  374. package/docs/reference/editors-relation.md +12 -0
  375. package/docs/reference/editors-select.md +9 -0
  376. package/docs/reference/editors-session.md +11 -0
  377. package/docs/reference/editors-text.md +9 -0
  378. package/docs/reference/editors-value-list.md +6 -0
  379. package/docs/reference/editors.md +5 -0
  380. package/docs/reference/field-row.md +16 -0
  381. package/docs/reference/grid.md +39 -0
  382. package/docs/reference/react.md +89 -0
  383. package/docs/reference/selection.md +33 -0
  384. package/docs/reference/views.md +622 -0
  385. package/package.json +27 -4
  386. package/skills/views/SKILL.md +20 -5
  387. package/dist/filters/types.d.ts +0 -27
  388. package/dist/filters/types.js +0 -1
  389. package/dist/model/filter-pushdown.d.ts +0 -106
  390. package/dist/model/filter-pushdown.js +0 -147
@@ -0,0 +1,103 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cloneElement, useState, } from "react";
4
+ import { columnGroupable } from "../../model/column-order.js";
5
+ import { columnLabel } from "../../model/column-capabilities.js";
6
+ import { columnKnobs } from "../../model/column-knobs.js";
7
+ import { effectiveSortKey } from "../../model/column-sort.js";
8
+ import { fieldKeyOf } from "../../model/view-rules.js";
9
+ import { useViews } from "../../provider/context.js";
10
+ import { GridColumnColorSection } from "./GridColumnColorSection.js";
11
+ import { GridColumnDateSection } from "./GridColumnDateSection.js";
12
+ import { GridColumnDurationSection } from "./GridColumnDurationSection.js";
13
+ import { GridColumnNumberSection } from "./GridColumnNumberSection.js";
14
+ import { GridColumnPercentSection } from "./GridColumnPercentSection.js";
15
+ import { GridColumnSortSection } from "./GridColumnSortSection.js";
16
+ import { insideGridFlyout, useGridFlyouts } from "./GridFlyout.js";
17
+ import { GridMenuRow, GridMenuSeparator } from "./GridMenuRow.js";
18
+ import { gridMenuArrows, useGridMenuFocus } from "./grid-menu-focus.js";
19
+ export function gridColumnMenuEnabled(col) {
20
+ return !col.actions;
21
+ }
22
+ export function GridColumnMenu({ column, values, viewBacked = false, sort, groupBy, optionColors, onOptionColorChange, dateStyle, onDateStyleChange, durationStyle, onDurationStyleChange, showTime, onShowTimeChange, percentDisplay, onPercentDisplayChange, numberFormat, onNumberFormatChange, onMoveLeft, onMoveRight, onHide, formatsWritable = true, renderColumnMenuRows, children, }) {
23
+ const [open, setOpen] = useState(false);
24
+ const flyouts = useGridFlyouts();
25
+ const [anchor, setAnchor] = useState(null);
26
+ const menuFocus = useGridMenuFocus(open, anchor);
27
+ const { atoms, components, messages } = useViews();
28
+ const { Popover } = components;
29
+ const { List } = atoms;
30
+ const key = fieldKeyOf(column);
31
+ const sortKey = effectiveSortKey(column, viewBacked);
32
+ const sortable = !!(sortKey && sort);
33
+ const groupable = !!groupBy && viewBacked && columnGroupable(column);
34
+ const grouped = groupable && groupBy.fieldKey === column.field.key;
35
+ const knobs = columnKnobs(column);
36
+ const canPercent = formatsWritable && knobs.has("percentDisplay") && !!onPercentDisplayChange;
37
+ const canDate = formatsWritable && knobs.has("dateStyle") && !!onDateStyleChange;
38
+ const canDuration = formatsWritable && knobs.has("durationStyle") && !!onDurationStyleChange;
39
+ const canDecimals = formatsWritable && knobs.has("decimals") && !!onNumberFormatChange;
40
+ const canCurrency = knobs.has("currency") && !!onNumberFormatChange;
41
+ const canColor = formatsWritable &&
42
+ (column.type === "select" || column.type === "multiselect") &&
43
+ !column.render &&
44
+ !!onOptionColorChange &&
45
+ values.length > 0;
46
+ const canMove = !!onMoveLeft || !!onMoveRight;
47
+ const close = () => {
48
+ flyouts.close();
49
+ setOpen(false);
50
+ };
51
+ const handleOpenChange = (next) => (next ? setOpen(true) : close());
52
+ const editorRows = renderColumnMenuRows?.(key, close) ?? null;
53
+ const hasContent = sortable ||
54
+ groupable ||
55
+ canPercent ||
56
+ canDate ||
57
+ canDuration ||
58
+ canDecimals ||
59
+ canCurrency ||
60
+ canColor ||
61
+ canMove ||
62
+ !!editorRows ||
63
+ !!onHide;
64
+ if (!hasContent)
65
+ return _jsx(_Fragment, { children: children });
66
+ const canKnobs = canPercent || canDate || canDuration || canDecimals || canCurrency;
67
+ const present = [sortable, groupable, canKnobs, canColor, canMove, !!editorRows, !!onHide];
68
+ const divider = (i) => (present.slice(0, i).some(Boolean) ? _jsx(GridMenuSeparator, {}) : null);
69
+ const trigger = cloneElement(children, {
70
+ ref: setAnchor,
71
+ onClick: (event) => {
72
+ children.props.onClick?.(event);
73
+ if (open)
74
+ close();
75
+ else {
76
+ menuFocus.noteOpen(event);
77
+ setOpen(true);
78
+ }
79
+ },
80
+ role: children.props.role ?? "button",
81
+ "aria-haspopup": "dialog",
82
+ "aria-expanded": open,
83
+ });
84
+ return (_jsxs(_Fragment, { children: [trigger, _jsx(Popover, { open: open, onOpenChange: handleOpenChange, anchor: anchor, side: "bottom", align: "start", sideOffset: 2, initialFocus: menuFocus.initialFocus, chrome: "menu", panelData: { "data-slot": "vk-grid-column-menu" }, className: "w-52", onOutsidePress: (event) => anchor?.contains(event.target) || insideGridFlyout(event) ? false : undefined, children: _jsx("div", { onPointerOver: flyouts.onListPointerOver, onKeyDown: gridMenuArrows, children: _jsxs(List, { children: [sortable && (_jsxs(_Fragment, { children: [divider(0), _jsx(GridColumnSortSection, { sortKey: sortKey, value: sort.value, dir: sort.dir, onChange: sort.onChange, onClose: close })] })), groupable && (_jsxs(_Fragment, { children: [divider(1), grouped ? (_jsx(GridMenuRow, { label: messages({ key: "views.menus.ungroup" }), icon: "group", active: true, onClick: () => {
85
+ groupBy.onChange(null);
86
+ close();
87
+ } })) : (_jsx(GridMenuRow, { label: messages({
88
+ key: "views.menus.group-by",
89
+ values: { field: columnLabel(column) },
90
+ }), icon: "group", onClick: () => {
91
+ groupBy.onChange(column.field.key);
92
+ close();
93
+ } }))] })), canKnobs && divider(2), canPercent && (_jsx(GridColumnPercentSection, { column: column, fieldKey: key, percentDisplay: percentDisplay, onPercentDisplayChange: onPercentDisplayChange, flyouts: flyouts, onClose: close })), canDate && (_jsx(GridColumnDateSection, { column: column, dateStyle: dateStyle, onDateStyleChange: onDateStyleChange, showTime: showTime, onShowTimeChange: knobs.has("showTime") ? onShowTimeChange : undefined, flyouts: flyouts, onClose: close })), canDuration && (_jsx(GridColumnDurationSection, { column: column, durationStyle: durationStyle, onDurationStyleChange: onDurationStyleChange, flyouts: flyouts, onClose: close })), (canDecimals || canCurrency) && (_jsx(GridColumnNumberSection, { column: column, fieldKey: key, decimals: canDecimals, currency: canCurrency, numberFormat: numberFormat, onNumberFormatChange: onNumberFormatChange, flyouts: flyouts, onClose: close })), canColor && (_jsxs(_Fragment, { children: [divider(3), _jsx(GridColumnColorSection, { column: column, values: values, optionColors: optionColors, flyouts: flyouts, onOptionColorChange: onOptionColorChange, onClose: close })] })), canMove && (_jsxs(_Fragment, { children: [divider(4), onMoveLeft && (_jsx(GridMenuRow, { label: messages({ key: "views.menus.move-left" }), icon: "moveLeft", onClick: () => {
94
+ onMoveLeft();
95
+ close();
96
+ } })), onMoveRight && (_jsx(GridMenuRow, { label: messages({ key: "views.menus.move-right" }), icon: "moveRight", onClick: () => {
97
+ onMoveRight();
98
+ close();
99
+ } }))] })), editorRows && (_jsxs(_Fragment, { children: [divider(5), editorRows] })), onHide && (_jsxs(_Fragment, { children: [divider(6), _jsx(GridMenuRow, { label: messages({ key: "views.menus.hide-column" }), icon: "hide", onClick: () => {
100
+ onHide();
101
+ close();
102
+ } })] }))] }) }) })] }));
103
+ }
@@ -0,0 +1,25 @@
1
+ import type { ListColumn } from "../../model/column-schema.js";
2
+ import type { ListNumberFormatState } from "../../model/column-format.js";
3
+ import { type GridFlyouts } from "./GridFlyout.js";
4
+ /**
5
+ * The number rows in the header menu — Decimals, and Currency on a column
6
+ * whose binding states rates (Original · EUR · USD · RON), each one row whose
7
+ * choices fly out. Lifted out of GridColumnMenu for the line ceiling; the
8
+ * policy is split, not raise. Writes under the FIELD key.
9
+ */
10
+ export declare function GridColumnNumberSection<Row>({ column, fieldKey, decimals, currency, numberFormat, onNumberFormatChange, flyouts, onClose, }: {
11
+ column: ListColumn<Row>;
12
+ fieldKey: string;
13
+ /** Offer the Decimals row. */
14
+ decimals: boolean;
15
+ /** Offer the Currency row (the column carries rates — `columnKnobs`). */
16
+ currency: boolean;
17
+ numberFormat?: ListNumberFormatState;
18
+ /** `decimals: null` = the field's own (Automatic). */
19
+ onNumberFormatChange: (key: string, patch: {
20
+ decimals?: number | null;
21
+ currency?: string;
22
+ }) => void;
23
+ flyouts: GridFlyouts;
24
+ onClose: () => void;
25
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { LIST_DECIMALS_CHOICES } from "../../model/column-state.js";
4
+ import { useViews } from "../../provider/context.js";
5
+ import { GridFlyoutRow } from "./GridFlyout.js";
6
+ import { KnobGlyph } from "./GridMenuRow.js";
7
+ const DECIMALS_SAMPLE = 1234.567;
8
+ const AUTOMATIC_SAMPLE = String(Number(DECIMALS_SAMPLE.toFixed(2)));
9
+ export function GridColumnNumberSection({ column, fieldKey, decimals, currency, numberFormat, onNumberFormatChange, flyouts, onClose, }) {
10
+ const chosen = numberFormat?.decimals ?? undefined;
11
+ const declared = column.format?.decimals;
12
+ const shown = chosen ?? declared;
13
+ const currencyOptions = numberFormat?.currencyOptions ?? [];
14
+ const { atoms, messages } = useViews();
15
+ const { Row } = atoms;
16
+ const automatic = messages({ key: "views.menus.automatic" });
17
+ return (_jsxs(_Fragment, { children: [decimals && (_jsxs(GridFlyoutRow, { id: "decimals", flyouts: flyouts, label: messages({ key: "views.menus.decimals" }), detail: shown ?? automatic, leading: _jsx(KnobGlyph, { name: "number" }), children: [_jsx(Row, { chosen: chosen === undefined, label: automatic, detail: _jsx("span", { className: "tabular-nums", children: declared === undefined ? AUTOMATIC_SAMPLE : DECIMALS_SAMPLE.toFixed(declared) }), onClick: () => {
18
+ onNumberFormatChange(fieldKey, { decimals: null });
19
+ onClose();
20
+ } }), LIST_DECIMALS_CHOICES.map((d) => (_jsx(Row, { chosen: chosen === d, label: d, detail: _jsx("span", { className: "tabular-nums", children: DECIMALS_SAMPLE.toFixed(d) }), onClick: () => {
21
+ onNumberFormatChange(fieldKey, { decimals: d });
22
+ onClose();
23
+ } }, d)))] })), currency && currencyOptions.length > 0 && (_jsx(GridFlyoutRow, { id: "currency", flyouts: flyouts, label: messages({ key: "views.menus.currency" }), detail: currencyOptions.find((c) => c.value === numberFormat?.currency)?.label, leading: _jsx(KnobGlyph, { name: "currency" }), children: currencyOptions.map((c) => (_jsx(Row, { chosen: numberFormat?.currency === c.value, label: c.label, onClick: () => {
24
+ onNumberFormatChange(fieldKey, { currency: c.value });
25
+ onClose();
26
+ } }, c.value))) }))] }));
27
+ }
@@ -0,0 +1,15 @@
1
+ import type { PercentDisplay } from "@viewkitjs/fields";
2
+ import type { ListColumn } from "../../model/column-schema.js";
3
+ import { type GridFlyouts } from "./GridFlyout.js";
4
+ /** The percent row in the header menu — how the figure is drawn, one row
5
+ * whose choices fly out. Split out of GridColumnMenu for the line ceiling;
6
+ * the policy is split, not raise. */
7
+ export declare function GridColumnPercentSection<Row>({ column, percentDisplay, onPercentDisplayChange, fieldKey, flyouts, onClose, }: {
8
+ column: ListColumn<Row>;
9
+ /** The workspace's choice for this field, when one is stored. */
10
+ percentDisplay?: PercentDisplay;
11
+ onPercentDisplayChange: (fieldKey: string, display: PercentDisplay) => void;
12
+ fieldKey: string;
13
+ flyouts: GridFlyouts;
14
+ onClose: () => void;
15
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useViews } from "../../provider/context.js";
4
+ import { GridFlyoutRow } from "./GridFlyout.js";
5
+ import { KnobGlyph } from "./GridMenuRow.js";
6
+ const DISPLAYS = ["text", "bar", "ring"];
7
+ export function GridColumnPercentSection({ column, percentDisplay, onPercentDisplayChange, fieldKey, flyouts, onClose, }) {
8
+ const active = percentDisplay ?? column.format?.percentDisplay ?? "text";
9
+ const { atoms, messages } = useViews();
10
+ const { Row } = atoms;
11
+ const displayLabel = (display) => messages({ key: "views.menus.percent-display-option", values: { display } });
12
+ return (_jsx(GridFlyoutRow, { id: "percent-display", flyouts: flyouts, label: messages({ key: "views.menus.percent-display" }), detail: displayLabel(active), leading: _jsx(KnobGlyph, { name: "progress" }), children: DISPLAYS.map((display) => (_jsx(Row, { chosen: active === display, label: displayLabel(display), onClick: () => {
13
+ onPercentDisplayChange(fieldKey, display);
14
+ onClose();
15
+ } }, display))) }));
16
+ }
@@ -0,0 +1,18 @@
1
+ import type { OrderDir } from "../../grouping/sort-groups.js";
2
+ /**
3
+ * The sort rows in the header menu — ascending, descending, and Clear sort
4
+ * while this column IS the sort. Split out of GridColumnMenu for the line
5
+ * ceiling; the policy is split, not raise.
6
+ */
7
+ export declare function GridColumnSortSection({ sortKey, value, dir, onChange, onClose, }: {
8
+ /** The key this column sorts by (`effectiveSortKey`). */
9
+ sortKey: string;
10
+ /** The list's current sort key and direction. */
11
+ value: string;
12
+ dir: OrderDir;
13
+ onChange: (next: {
14
+ value: string;
15
+ dir: OrderDir;
16
+ }) => void;
17
+ onClose: () => void;
18
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useViews } from "../../provider/context.js";
4
+ import { GridMenuRow } from "./GridMenuRow.js";
5
+ export function GridColumnSortSection({ sortKey, value, dir, onChange, onClose, }) {
6
+ const { messages } = useViews();
7
+ const active = value === sortKey;
8
+ const pick = (next) => {
9
+ onChange({ value: sortKey, dir: next });
10
+ onClose();
11
+ };
12
+ return (_jsxs(_Fragment, { children: [_jsx(GridMenuRow, { label: messages({ key: "views.menus.sort-asc" }), icon: "sortRowsUp", active: active && dir === "asc", onClick: () => pick("asc") }), _jsx(GridMenuRow, { label: messages({ key: "views.menus.sort-desc" }), icon: "sortRowsDown", active: active && dir === "desc", onClick: () => pick("desc") }), active && (_jsx(GridMenuRow, { label: messages({ key: "views.menus.sort-clear" }), icon: "clearSort", onClick: () => {
13
+ onChange({ value: "", dir: "asc" });
14
+ onClose();
15
+ } }))] }));
16
+ }
@@ -0,0 +1,34 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * The GRID's host around the shared `DateEditor` (`@viewkitjs/views/editors/date`) —
4
+ * the editing core is one component across every surface. The edit session owns the
5
+ * one-answer guard and the exit gap, and the core answers what the close means
6
+ * (`resolveClose`); the editor panel opens the popover on a desktop and the sheet on a
7
+ * phone. This host owns the anchor on the cell rect and the payload's shape. Time is
8
+ * present in the payload ("YYYY-MM-DDTHH:MM") unless the column is a calendar-day
9
+ * field (`dayOnly`): then the panel has no time box, a day click saves, and the
10
+ * payload is the day. The column's Show-time setting is display only. A cleared
11
+ * date commits "", which the app's write maps to its empty value.
12
+ */
13
+ export declare function GridDateEditor({ title, initial, dayOnly, clearable, seed, refuse, onCommit, onCancel, onTab, }: {
14
+ /** The field's name: the sheet's title on a phone. */
15
+ title: ReactNode;
16
+ /** The stored value (ISO string) — selects the day + opening month. */
17
+ initial?: string;
18
+ /** The column presents a calendar-day field (`date`): the commit is the day
19
+ * alone — the shape the row stores and the write gate judges through
20
+ * `zodFor` — the panel draws no time box, and a day click saves. */
21
+ dayOnly?: boolean;
22
+ /** The column may be emptied: the panel ends with a Clear row, which commits "". */
23
+ clearable?: boolean;
24
+ /** The character typed on the cell that opened the editor: the date box starts with it. */
25
+ seed?: string;
26
+ /** "YYYY-MM-DDTHH:MM" (local); "YYYY-MM-DD" when `dayOnly`; "" for a clear. */
27
+ onCommit: (value: string) => void;
28
+ onCancel: () => void;
29
+ /** The grid's judgement of a value before it is written: its reason when it would refuse it.
30
+ * A refused value keeps the editor open with that reason. */
31
+ refuse?: (value: string) => string | null;
32
+ /** After a Tab out of the panel saves: move to the next cell, or the one before on Shift-Tab. */
33
+ onTab?: (backwards: boolean) => void;
34
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { DateEditor } from "../../editors/DateEditor.js";
5
+ import { EditorPanel } from "../../editors/EditorPanel.js";
6
+ import { useGridEditSession } from "./grid-edit-session.js";
7
+ export function GridDateEditor({ title, initial, dayOnly = false, clearable = false, seed, refuse, onCommit, onCancel, onTab, }) {
8
+ const editorRef = useRef(null);
9
+ const anchorRef = useRef(null);
10
+ const { session, close, sheet } = useGridEditSession({
11
+ editorRef,
12
+ mapPayload: dayOnly ? (payload) => payload.slice(0, 10) : undefined,
13
+ refuse: refuse && ((value) => refuse(value)),
14
+ onCommit: (value) => onCommit(value),
15
+ onCancel,
16
+ onTab,
17
+ });
18
+ return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 w-auto", children: _jsx(DateEditor, { ref: editorRef, initial: initial, dayOnly: dayOnly, clearable: clearable, seed: seed, focusDate: !sheet, onRequestClose: close }) })] }));
19
+ }
@@ -0,0 +1,44 @@
1
+ import { type PointerEvent as ReactPointerEvent, type ReactElement, type ReactNode } from "react";
2
+ /** How long the pointer rests on a row before its flyout opens: a sweep down the list opens none. */
3
+ export declare const GRID_FLYOUT_HOVER_MS = 150;
4
+ export type GridFlyouts = {
5
+ /** The flyout showing now, by row id. */
6
+ openId: string | null;
7
+ /** Opens `id` after the hover delay; `null` closes whatever is open. */
8
+ hoverTo: (id: string | null) => void;
9
+ /** Drops a pending hover; an open flyout stays (the pointer is usually on its way in). */
10
+ cancelHover: () => void;
11
+ toggle: (id: string) => void;
12
+ /** Opens `id` at once, dropping a pending hover; never closes it. */
13
+ open: (id: string) => void;
14
+ close: () => void;
15
+ /** For the list that holds the rows: resting on a plain row closes the open flyout. */
16
+ onListPointerOver: (event: ReactPointerEvent<HTMLElement>) => void;
17
+ /** A flyout row hands its pointer events here, its popup's too through the React tree, so the list leaves them be. */
18
+ claim: (event: ReactPointerEvent<HTMLElement>) => void;
19
+ };
20
+ /**
21
+ * THE FLYOUTS' STATE — one open at a time across every `GridFlyoutRow` in a menu. The menu
22
+ * that holds the rows owns it and calls `close()` when it closes itself.
23
+ */
24
+ export declare function useGridFlyouts(): GridFlyouts;
25
+ /** Whether a press landed inside a grid flyout, read from its slot: the menu that opened it stays open. */
26
+ export declare function insideGridFlyout(event: Event): boolean;
27
+ /**
28
+ * A menu row that opens its choices BESIDE the menu: the map's Popover anchored on the row.
29
+ * A resting pointer opens it after a short delay; a mouse click opens it at once and never
30
+ * closes it (the hover usually got there first); a tap toggles it, the only way in on a phone.
31
+ * The row and its popup sit inside one element, so the popup's pointer events reach `claim`
32
+ * through the React tree, and the menu's list leaves the flyout open while the pointer is in it.
33
+ */
34
+ export declare function GridFlyoutRow({ id, flyouts, label, detail, leading, title, children, }: {
35
+ id: string;
36
+ flyouts: GridFlyouts;
37
+ label: ReactNode;
38
+ /** The current choice, the row's right-hand detail. */
39
+ detail?: ReactNode;
40
+ leading?: ReactNode;
41
+ title?: string;
42
+ /** The flyout's rows. */
43
+ children: ReactNode;
44
+ }): ReactElement;
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState, } from "react";
4
+ import { useViews } from "../../provider/context.js";
5
+ export const GRID_FLYOUT_HOVER_MS = 150;
6
+ export function useGridFlyouts() {
7
+ const [openId, setOpenId] = useState(null);
8
+ const timerRef = useRef(null);
9
+ const claimed = useRef(new WeakSet());
10
+ const cancelHover = () => {
11
+ if (timerRef.current != null) {
12
+ window.clearTimeout(timerRef.current);
13
+ timerRef.current = null;
14
+ }
15
+ };
16
+ useEffect(() => cancelHover, []);
17
+ const hoverTo = (id) => {
18
+ cancelHover();
19
+ timerRef.current = window.setTimeout(() => {
20
+ timerRef.current = null;
21
+ setOpenId(id);
22
+ }, GRID_FLYOUT_HOVER_MS);
23
+ };
24
+ return {
25
+ openId,
26
+ hoverTo,
27
+ cancelHover,
28
+ toggle: (id) => {
29
+ cancelHover();
30
+ setOpenId((current) => (current === id ? null : id));
31
+ },
32
+ open: (id) => {
33
+ cancelHover();
34
+ setOpenId(id);
35
+ },
36
+ close: () => {
37
+ cancelHover();
38
+ setOpenId(null);
39
+ },
40
+ onListPointerOver: (event) => {
41
+ if (claimed.current.has(event.nativeEvent))
42
+ return;
43
+ if (openId != null)
44
+ hoverTo(null);
45
+ },
46
+ claim: (event) => {
47
+ claimed.current.add(event.nativeEvent);
48
+ },
49
+ };
50
+ }
51
+ export function insideGridFlyout(event) {
52
+ const target = event.target;
53
+ return target?.closest?.('[data-slot="vk-grid-flyout"]') != null;
54
+ }
55
+ export function GridFlyoutRow({ id, flyouts, label, detail, leading, title, children, }) {
56
+ const { atoms, components, icons } = useViews();
57
+ const { Row, List } = atoms;
58
+ const { Popover } = components;
59
+ const ChevronRight = icons.chevronRight;
60
+ const anchor = useRef(null);
61
+ const pressedWith = useRef(null);
62
+ const open = flyouts.openId === id;
63
+ return (_jsxs("div", { ref: anchor, onPointerOver: flyouts.claim, onPointerDown: (event) => {
64
+ if (anchor.current?.contains(event.target))
65
+ pressedWith.current = event.pointerType;
66
+ }, onMouseEnter: () => flyouts.hoverTo(id), onMouseLeave: () => {
67
+ pressedWith.current = null;
68
+ flyouts.cancelHover();
69
+ }, children: [_jsx(Row, { label: label, detail: detail, leading: leading, title: title, opens: true, open: open, trailing: _jsx(ChevronRight, { className: "size-3.5 shrink-0 text-(color:--vk-fg-subtlest)" }), onClick: () => {
70
+ const pointer = pressedWith.current;
71
+ pressedWith.current = null;
72
+ if (pointer === "mouse")
73
+ flyouts.open(id);
74
+ else
75
+ flyouts.toggle(id);
76
+ } }), _jsx(Popover, { open: open, onOpenChange: (next) => {
77
+ if (!next && flyouts.openId === id)
78
+ flyouts.close();
79
+ }, anchor: anchor, side: "right", align: "start", sideOffset: -2, alignOffset: -4, initialFocus: false, chrome: "menu", panelData: { "data-slot": "vk-grid-flyout" }, className: "min-w-32 max-w-80", onOutsidePress: (event) => anchor.current?.contains(event.target) ? false : undefined, children: _jsx(List, { children: children }) })] }));
80
+ }
@@ -0,0 +1,33 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ListGroup } from "../../grouping/types.js";
3
+ import { type DisplayCurrency } from "../../fields/currency.js";
4
+ import type { ListAggregateKind, ListColumn } from "../../model/column-schema.js";
5
+ import type { ListNumberFormatOverrides } from "../../model/column-format.js";
6
+ /** Whether a group's footer row is drawn: when its figures can be picked, or the host hands in one of its own. The
7
+ * keyboard and the screen reader's row numbers ask the same question the footer does. */
8
+ export declare function gridFooterShown({ interactive, hostCells, }: {
9
+ interactive: boolean;
10
+ hostCells: readonly ReactNode[];
11
+ }): boolean;
12
+ export declare function GridFooter<Row>({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked, frozenCount, frozenLeft, continuation, defaultCurrency, ariaRowIndex, ariaLevel, ariaColOffset, }: {
13
+ /** What a screen reader reads (`core/grid-aria.ts`): the row's number, its level in a tree grid, and the columns
14
+ * before the first data column (the checkbox lane). */
15
+ ariaRowIndex?: number;
16
+ ariaLevel?: number;
17
+ ariaColOffset?: number;
18
+ group: ListGroup<Row>;
19
+ columns: ListColumn<Row>[];
20
+ selecting: boolean;
21
+ aggregates?: Record<string, ListAggregateKind>;
22
+ numberFormats?: ListNumberFormatOverrides;
23
+ renderAggregate?: (columnId: string, group: ListGroup<Row>) => ReactNode;
24
+ onAggregateChange?: (columnId: string, kind: ListAggregateKind) => void;
25
+ viewBacked?: boolean;
26
+ /** How many LEADING columns are pinned to the left edge (0 = nothing). */
27
+ frozenCount?: number;
28
+ /** Sticky `left` for the frozen column at visible index i. */
29
+ frozenLeft?: (i: number) => string;
30
+ continuation?: ReactNode;
31
+ /** The reader's default currency (the host's answer): a money column read in Original totals in it. */
32
+ defaultCurrency?: DisplayCurrency;
33
+ }): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
@@ -0,0 +1,85 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { cx } from "../../internal/cx.js";
4
+ import { CellSuffix } from "../../display/format.js";
5
+ import { figureFor, ratioFigure } from "../../figures.js";
6
+ import { aggregateLabel, aggregateOptions, computeAggregate, figureKeyOf, moneyFigureCode, moneyTotal, resolveAggregateKind, } from "../../model/aggregates.js";
7
+ import { DEFAULT_DISPLAY_CURRENCY } from "../../fields/currency.js";
8
+ import { fieldTypeOf } from "../../model/field-type-of.js";
9
+ import { fieldKeyOf } from "../../model/view-rules.js";
10
+ import { formatNumber } from "./cells.js";
11
+ import { useCellFormat } from "../../cells/use-cell-format.js";
12
+ import { useViews } from "../../provider/context.js";
13
+ import { GridAggregateMenu } from "./GridAggregateMenu.js";
14
+ import { GridRailSpacer } from "./checks.js";
15
+ import { GRID_CHROME_FOCUS, GRID_CONTENT_PAD, GRID_GROUND } from "./grid-styles.js";
16
+ import { gridFocusOnPress } from "./useGridFocus.js";
17
+ export function gridFooterShown({ interactive, hostCells, }) {
18
+ return interactive || hostCells.some((cell) => cell != null);
19
+ }
20
+ export function GridFooter({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked = false, frozenCount = 0, frozenLeft, continuation, defaultCurrency = DEFAULT_DISPLAY_CURRENCY, ariaRowIndex, ariaLevel, ariaColOffset = 0, }) {
21
+ const interactive = !!onAggregateChange;
22
+ const cellFormat = useCellFormat();
23
+ const { messages } = useViews();
24
+ const hostCells = columns.map((column) => renderAggregate?.(column.id, group) ?? null);
25
+ const sourced = group.figures
26
+ ? { totalled: new Set(Object.keys(group.figures.fields)), defaultCurrency }
27
+ : undefined;
28
+ if (!gridFooterShown({ interactive, hostCells }))
29
+ return continuation;
30
+ const footer = (_jsxs("div", { "data-slot": "vk-grid-footer", "data-group-key": group.key, role: "row", "aria-rowindex": ariaRowIndex, "aria-level": ariaLevel, className: cx("grid grid-cols-(--vk-cols)", GRID_CONTENT_PAD), children: [_jsx(GridRailSpacer, { selecting: selecting }), columns.map((column, index) => {
31
+ const kind = resolveAggregateKind(column, aggregates, sourced);
32
+ const columnInteractive = interactive && (!viewBacked || column.field != null);
33
+ const host = hostCells[index];
34
+ const ratioParts = column.field?.type === "formula" ? column.field.ratio : undefined;
35
+ const fromSource = host == null && kind !== "none" && group.figures
36
+ ? kind === "ratio" && ratioParts
37
+ ? ratioFigure(group.figures, ratioParts.numerator, ratioParts.denominator)
38
+ : figureFor(kind, group.figures, figureKeyOf(column, defaultCurrency))
39
+ : undefined;
40
+ const money = host == null && kind !== "none" && !group.figures
41
+ ? moneyTotal(kind, column, group.items, defaultCurrency)
42
+ : undefined;
43
+ const computed = host == null && kind !== "none" && !group.figures && money === undefined
44
+ ? computeAggregate(kind, column, group.items)
45
+ : null;
46
+ const countLike = kind === "count" || kind === "filled" || kind === "unique";
47
+ const decimals = numberFormats?.[fieldKeyOf(column)]?.decimals;
48
+ const sourceCode = fromSource != null && !countLike && fieldTypeOf(column) === "currency"
49
+ ? moneyFigureCode(column, defaultCurrency)
50
+ : undefined;
51
+ const value = host != null
52
+ ? host
53
+ : fromSource !== undefined
54
+ ? fromSource == null || sourceCode === null
55
+ ? null
56
+ : countLike
57
+ ? String(fromSource)
58
+ : formatNumber(fromSource, column, {
59
+ ...cellFormat,
60
+ decimals,
61
+ currency: sourceCode,
62
+ })
63
+ : money
64
+ ? formatNumber(money.amount, column, {
65
+ ...cellFormat,
66
+ decimals,
67
+ currency: money.code,
68
+ })
69
+ : computed != null
70
+ ? countLike
71
+ ? String(computed)
72
+ : formatNumber(computed, column, { ...cellFormat, decimals })
73
+ : null;
74
+ const label = host == null && kind !== "none" ? aggregateLabel(kind, messages) : null;
75
+ const suffix = host == null && column.aggregateSuffix && !countLike && kind !== "ratio"
76
+ ? column.aggregateSuffix
77
+ : null;
78
+ const frozen = index < frozenCount && !!frozenLeft;
79
+ const cell = (_jsx("div", { "data-slot": "vk-grid-footer-cell", "data-footcell": column.id, role: "gridcell", "aria-colindex": ariaColOffset + index + 1, tabIndex: -1, onPointerDown: (event) => gridFocusOnPress(event, "[data-footcell]"), style: frozen ? { left: frozenLeft(index) } : undefined, className: cx("group/gridagg flex h-(--vk-footer-h) min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap px-(--vk-px)", GRID_CHROME_FOCUS, column.align === "right" && "justify-end", column.align === "center" && "justify-center", columnInteractive && "cursor-pointer select-none hover:bg-(color:--vk-hovered)", frozen ? cx("sticky z-7", GRID_GROUND) : "relative"), children: value != null ? (_jsxs(_Fragment, { children: [label && (_jsx("span", { className: "text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest)", children: label })), _jsxs("span", { className: "text-(length:--vk-text) font-medium tabular-nums", children: [value, suffix && _jsx(CellSuffix, { children: suffix })] })] })) : columnInteractive ? (_jsx("span", { className: "text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest) opacity-0 group-hover/gridagg:opacity-100", children: messages({ key: "views.grid.figure-pick" }) })) : null }, column.id));
80
+ if (!columnInteractive)
81
+ return cell;
82
+ return (_jsx(GridAggregateMenu, { column: column, options: aggregateOptions(column, sourced), current: kind, onChange: (next) => onAggregateChange(column.id, next), align: column.align === "right" ? "end" : column.align === "center" ? "center" : "start", children: cell }, column.id));
83
+ }), _jsx("div", { "data-slot": "vk-grid-tail", "aria-hidden": true, className: "h-(--vk-footer-h)" })] }));
84
+ return (_jsxs(_Fragment, { children: [footer, continuation] }));
85
+ }
@@ -0,0 +1,37 @@
1
+ import { type ReactNode } from "react";
2
+ import type { OrderDir } from "../../grouping/sort-groups.js";
3
+ import type { GridSortState } from "./GridColumnMenu.js";
4
+ import type { ListGroupSummaryPart } from "../../model/preferences.js";
5
+ /** A sortable column, mirrored from the list's SortConfig options. */
6
+ export type GridGroupSortOption = {
7
+ value: string;
8
+ label: string;
9
+ defaultDir?: OrderDir;
10
+ };
11
+ /**
12
+ * The group-header `…` menu — a second remote for the list's row sort (all
13
+ * groups at once), surfaced on the group band. Reveals on hover of the group
14
+ * label; opens the map's popover, in its slot, of the same sortable columns the
15
+ * view-options Sort panel drives. Clicks stop propagation so the group's
16
+ * collapse toggle stays put.
17
+ */
18
+ export declare function GridGroupMenu({ sort, sortOptions, summary, onSummaryChange, figures, onHide, }: {
19
+ /** Absent when the list offers no row sort here — the menu then carries only
20
+ * what else it has (Hide group). */
21
+ sort?: GridSortState;
22
+ sortOptions: GridGroupSortOption[];
23
+ /** Hides this group in the view — what the host's group panel's eye does.
24
+ * Absent where a list cannot hide one. */
25
+ onHide?: () => void;
26
+ /** Which figures the group header shows next to the name. A SET — count and
27
+ * total answer different questions and are wanted together. */
28
+ summary?: ListGroupSummaryPart[];
29
+ onSummaryChange?: (part: ListGroupSummaryPart, next: boolean) => void;
30
+ /** The figures the header can show beside its count, in the list's order, each named by its COLUMN — "People",
31
+ * not "Total". A generic label made the option unreadable: you could not tell what a group would show
32
+ * without picking it and looking. None: no Show rows. */
33
+ figures?: {
34
+ part: ListGroupSummaryPart;
35
+ label: ReactNode;
36
+ }[];
37
+ }): import("react/jsx-runtime").JSX.Element;