@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,216 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { GRID_GROUND } from "./grid-styles.js";
4
+ const SETTLE_MS = 150;
5
+ const EASE = "cubic-bezier(0.2, 0.7, 0.3, 1)";
6
+ const EDGE_PX = 56;
7
+ const EDGE_MAX_SPEED = 16;
8
+ export function useHeaderDragReorder({ enabled, ids, scrollXRef, getScroller, canDrag, onReorder, }) {
9
+ const dragRef = useRef(null);
10
+ const armRef = useRef(null);
11
+ const movedRef = useRef(false);
12
+ const [drag, setDrag] = useState(null);
13
+ const idsRef = useRef(ids);
14
+ const onReorderRef = useRef(onReorder);
15
+ useEffect(() => {
16
+ idsRef.current = ids;
17
+ onReorderRef.current = onReorder;
18
+ });
19
+ const finish = useCallback((commit) => {
20
+ const d = dragRef.current;
21
+ if (!d || d.settling)
22
+ return;
23
+ d.settling = true;
24
+ if (d.raf != null)
25
+ cancelAnimationFrame(d.raf);
26
+ d.raf = null;
27
+ const ins = commit ? d.ins : d.from;
28
+ let dxFinal = 0;
29
+ if (ins > d.from) {
30
+ for (let j = d.from + 1; j <= ins; j++)
31
+ dxFinal += d.geom[j].width;
32
+ }
33
+ else if (ins < d.from) {
34
+ for (let j = ins; j < d.from; j++)
35
+ dxFinal -= d.geom[j].width;
36
+ }
37
+ if (!commit && dragRef.current) {
38
+ setDrag({ id: d.id, from: d.from, ins: d.from });
39
+ }
40
+ d.el.style.transition = `transform ${SETTLE_MS}ms ${EASE}`;
41
+ d.el.style.setProperty("--vk-drag-shift", `${dxFinal}px`);
42
+ window.setTimeout(() => {
43
+ d.el.style.transition = "";
44
+ d.el.style.removeProperty("--vk-drag-shift");
45
+ d.el.style.willChange = "";
46
+ d.el.classList.remove("z-20", GRID_GROUND, "shadow-md");
47
+ document.body.style.cursor = "";
48
+ document.body.style.userSelect = "";
49
+ dragRef.current = null;
50
+ if (commit && ins !== d.from) {
51
+ const next = [...idsRef.current];
52
+ next.splice(d.from, 1);
53
+ next.splice(ins, 0, d.id);
54
+ onReorderRef.current(d.id, next);
55
+ }
56
+ setDrag(null);
57
+ }, SETTLE_MS + 20);
58
+ }, []);
59
+ const tickRef = useRef(() => { });
60
+ const tick = useCallback(() => {
61
+ const d = dragRef.current;
62
+ if (!d || d.settling)
63
+ return;
64
+ const scroller = getScroller();
65
+ if (scroller) {
66
+ const w = window.innerWidth;
67
+ let v = 0;
68
+ if (d.lastClientX < EDGE_PX) {
69
+ v = -Math.ceil(((EDGE_PX - d.lastClientX) / EDGE_PX) * EDGE_MAX_SPEED);
70
+ }
71
+ else if (d.lastClientX > w - EDGE_PX) {
72
+ v = Math.ceil(((d.lastClientX - (w - EDGE_PX)) / EDGE_PX) * EDGE_MAX_SPEED);
73
+ }
74
+ if (v !== 0)
75
+ scroller.scrollLeft += v;
76
+ }
77
+ const dx = d.lastClientX - d.startX + (scrollXRef.current - d.startScrollX);
78
+ d.el.style.setProperty("--vk-drag-shift", `${dx}px`);
79
+ const x = d.geom[d.from].center + dx;
80
+ let ins = d.from;
81
+ for (let j = 0; j < d.geom.length; j++) {
82
+ if (j === d.from)
83
+ continue;
84
+ if (j < d.from && x < d.geom[j].center)
85
+ ins = Math.min(ins, j);
86
+ if (j > d.from && x > d.geom[j].center)
87
+ ins = Math.max(ins, j);
88
+ }
89
+ if (ins !== d.ins) {
90
+ d.ins = ins;
91
+ setDrag({ id: d.id, from: d.from, ins });
92
+ }
93
+ d.raf = requestAnimationFrame(() => tickRef.current());
94
+ }, [getScroller, scrollXRef]);
95
+ useEffect(() => {
96
+ tickRef.current = tick;
97
+ }, [tick]);
98
+ const onCellPointerDown = useCallback((id, index) => (e) => {
99
+ if (!enabled || e.button !== 0 || e.pointerType !== "mouse")
100
+ return;
101
+ if (idsRef.current.length < 2)
102
+ return;
103
+ if (canDrag && !canDrag(id))
104
+ return;
105
+ movedRef.current = false;
106
+ armRef.current = {
107
+ id,
108
+ index,
109
+ el: e.currentTarget,
110
+ startX: e.clientX,
111
+ startY: e.clientY,
112
+ };
113
+ }, [canDrag, enabled]);
114
+ const onCellPointerMove = useCallback((e) => {
115
+ const d = dragRef.current;
116
+ if (d && e.pointerId === d.pointerId) {
117
+ d.lastClientX = e.clientX;
118
+ return;
119
+ }
120
+ const a = armRef.current;
121
+ if (!a || d)
122
+ return;
123
+ if (!(e.buttons & 1)) {
124
+ armRef.current = null;
125
+ return;
126
+ }
127
+ if (Math.abs(e.clientX - a.startX) <= 4)
128
+ return;
129
+ const el = a.el;
130
+ const strip = el.parentElement;
131
+ if (!strip)
132
+ return;
133
+ const byId = new Map();
134
+ for (const c of Array.from(strip.querySelectorAll("[data-headcell]"))) {
135
+ byId.set(c.dataset.headcell ?? "", c);
136
+ }
137
+ armRef.current = null;
138
+ movedRef.current = true;
139
+ const geom = idsRef.current.map((cid) => {
140
+ const c = byId.get(cid);
141
+ const left = c?.offsetLeft ?? 0;
142
+ const width = c?.offsetWidth ?? 0;
143
+ return { id: cid, left, width, center: left + width / 2 };
144
+ });
145
+ el.setPointerCapture(e.pointerId);
146
+ el.style.willChange = "transform";
147
+ el.classList.add("z-20", GRID_GROUND, "shadow-md");
148
+ document.body.style.cursor = "grabbing";
149
+ document.body.style.userSelect = "none";
150
+ dragRef.current = {
151
+ id: a.id,
152
+ from: a.index,
153
+ ins: a.index,
154
+ el,
155
+ pointerId: e.pointerId,
156
+ startX: a.startX,
157
+ startScrollX: scrollXRef.current,
158
+ geom,
159
+ lastClientX: e.clientX,
160
+ raf: null,
161
+ settling: false,
162
+ };
163
+ setDrag({ id: a.id, from: a.index, ins: a.index });
164
+ dragRef.current.raf = requestAnimationFrame(() => tickRef.current());
165
+ }, [scrollXRef]);
166
+ const onCellPointerUp = useCallback((e) => {
167
+ armRef.current = null;
168
+ const d = dragRef.current;
169
+ if (d && e.pointerId === d.pointerId)
170
+ finish(true);
171
+ }, [finish]);
172
+ const onCellPointerCancel = useCallback(() => {
173
+ armRef.current = null;
174
+ finish(false);
175
+ }, [finish]);
176
+ const onCellClickCapture = useCallback((e) => {
177
+ if (!movedRef.current)
178
+ return;
179
+ movedRef.current = false;
180
+ e.preventDefault();
181
+ e.stopPropagation();
182
+ }, []);
183
+ useEffect(() => {
184
+ if (!drag)
185
+ return;
186
+ const onKey = (e) => {
187
+ if (e.key === "Escape")
188
+ finish(false);
189
+ };
190
+ window.addEventListener("keydown", onKey);
191
+ return () => window.removeEventListener("keydown", onKey);
192
+ }, [drag, finish]);
193
+ const cellStyle = useCallback((id, index) => {
194
+ const d = dragRef.current;
195
+ if (!drag || !d || id === drag.id)
196
+ return undefined;
197
+ const w = d.geom[drag.from]?.width ?? 0;
198
+ let shift = 0;
199
+ if (drag.from < index && index <= drag.ins)
200
+ shift = -w;
201
+ else if (drag.ins <= index && index < drag.from)
202
+ shift = w;
203
+ return {
204
+ ["--vk-drag-shift"]: `${shift}px`,
205
+ transition: `transform ${SETTLE_MS}ms ${EASE}`,
206
+ };
207
+ }, [drag]);
208
+ return {
209
+ cellStyle,
210
+ onCellPointerDown,
211
+ onCellPointerMove,
212
+ onCellPointerUp,
213
+ onCellPointerCancel,
214
+ onCellClickCapture,
215
+ };
216
+ }
@@ -0,0 +1,83 @@
1
+ import { type FieldConventions } from "@viewkitjs/fields";
2
+ import type { ListColumn, ListColumnType } from "../../model/column-schema.js";
3
+ import { type ViewsMessageResolver } from "../../contract.js";
4
+ export type GridClipboardCell = {
5
+ text: string;
6
+ value: unknown;
7
+ type?: ListColumnType;
8
+ unit?: string;
9
+ };
10
+ export type GridCellClipboard = GridClipboardCell & {
11
+ /** Range values in visible row/column order. */
12
+ matrix?: GridClipboardCell[][];
13
+ };
14
+ export type GridPasteSource = {
15
+ text: string;
16
+ value?: unknown;
17
+ type?: ListColumnType;
18
+ unit?: string;
19
+ };
20
+ type GridPasteResult = {
21
+ ok: true;
22
+ next: unknown;
23
+ overlay: boolean;
24
+ } | {
25
+ ok: false;
26
+ reason: string;
27
+ };
28
+ /** Pending value → raw edit accessor → display accessor. */
29
+ export declare function cellEditBaseline<Row>(col: ListColumn<Row>, row: Row, pendingByCol?: Readonly<Record<string, unknown>>): unknown;
30
+ export declare function cellCopyText<Row>(col: ListColumn<Row>, baseline: unknown): string;
31
+ /** Parse external plain text as a spreadsheet matrix. */
32
+ export declare function parseTsvText(text: string): {
33
+ text: string;
34
+ }[][];
35
+ /** Current value converted to the host commit payload shape. */
36
+ export declare function cellPrevPayload<Row>(col: ListColumn<Row>, baseline: unknown, unit?: string): unknown;
37
+ /** The undo value of a write that empties a cell (a cut, Delete, Clear, a range
38
+ * clear), in the commit payload's shape: what the cell holds, as the host's
39
+ * handler takes it back. */
40
+ export declare function cellClearPrev<Row>(col: ListColumn<Row>, row: Row, pendingByCol?: Readonly<Record<string, unknown>>): unknown;
41
+ /**
42
+ * The unit a pasted or filled figure lands in. A money cell copied from a record
43
+ * in one currency never lands in a record that holds another: the copied amount
44
+ * means nothing in the target's currency, and carrying the currency over would
45
+ * re-denominate the record. So it is refused, and the currency is carried only
46
+ * into a record that has none of its own (`holdsCurrency` false). A unit the
47
+ * column doesn't offer is not carried; the target keeps its own. A paste and a
48
+ * fill both land through here.
49
+ */
50
+ export declare function pasteUnit(sourceUnit: string | undefined, currentUnit: string | undefined, allowed: readonly string[] | undefined, holdsCurrency: boolean): {
51
+ unit: string | undefined;
52
+ } | {
53
+ refuse: string;
54
+ };
55
+ /** Whether a row holds a currency of its own. A money column reads it off the
56
+ * rates — a null map is the database's answer that the row has none — never off
57
+ * `editUnit`, which a host may fill with a default. Any other column: yes. */
58
+ export declare function rowHoldsCurrency<Row>(col: ListColumn<Row>, row: Row): boolean;
59
+ /**
60
+ * Whether a paste or a fill into this column paints its value at once, as an overlay over the cell. Only a value the
61
+ * refetch compares equal to (`looselyEqualValue`) may: a text, an option's key, a yes/no, a list of strings. A figure
62
+ * commits `{ value, unit }`, a date a day or a minute string the row stores in its own shape, a relation an id against
63
+ * a resolved object, a range an object, a list of several values its items: none reads equal to what the row holds,
64
+ * so an overlay would draw the payload ("[object Object]") and the settled write would read as changed elsewhere.
65
+ * Those skip it, as the editors do, and the refetch repaints the cell.
66
+ */
67
+ export declare function gridPasteOverlay<Row>(col: ListColumn<Row>): boolean;
68
+ /** Coerce one clipboard value into the target column's commit payload. The conventions and the
69
+ * messages are the caller's — the app's, from the provider: a paste reads a number and a date the
70
+ * way the person writes them, and refuses in their words. */
71
+ export declare function coercePaste<Row>(col: ListColumn<Row>, source: GridPasteSource, opts: {
72
+ conventions: FieldConventions;
73
+ messages?: ViewsMessageResolver;
74
+ currentUnit?: string;
75
+ /** Whether the target row holds a currency of its own (`rowHoldsCurrency`). Absent: it does. */
76
+ holdsCurrency?: boolean;
77
+ values?: readonly string[];
78
+ /** The target row's country, where a phone pasted without its country code is read (`ListColumn.region`). */
79
+ region?: string | null;
80
+ }): GridPasteResult;
81
+ /** Plain TSV form used for the system clipboard. */
82
+ export declare function serializeClipboardMatrix(matrix: readonly (readonly GridClipboardCell[])[]): string;
83
+ export {};
@@ -0,0 +1,291 @@
1
+ import { actorLabel, formatLocalMinute, isActorValue, isBreakdown, isRangeValue, isValueItem, listValues, locationText, nameText, parseNumber, rangeText, relationIdOf, relationKey, } from "@viewkitjs/fields";
2
+ import { phoneText } from "@viewkitjs/fields/phone";
3
+ import { fromDayKey, msToDurationUnit, parseDateInput, parseDurationInput } from "@viewkitjs/fields/query";
4
+ import { GRID_TYPE_RULES, gridPasteKind } from "../../model/column-types.js";
5
+ import { resolveViewsMessage } from "../../contract.js";
6
+ import { gridNormalizeWrite } from "../../model/column-capabilities.js";
7
+ import { prettifyOptionValue } from "../../model/column-state.js";
8
+ import { fieldTypeOf, temporalKindOf } from "../../model/field-type-of.js";
9
+ export function cellEditBaseline(col, row, pendingByCol) {
10
+ return pendingByCol && col.id in pendingByCol
11
+ ? pendingByCol[col.id]
12
+ : (col.editAccessor ?? col.accessor)?.(row);
13
+ }
14
+ export function cellCopyText(col, baseline) {
15
+ if (baseline == null)
16
+ return "";
17
+ if (Array.isArray(baseline))
18
+ return (baseline.some(isValueItem) ? listValues(baseline) : baseline)
19
+ .map((entry) => cellValueText(col, entry))
20
+ .join(", ");
21
+ return cellValueText(col, baseline);
22
+ }
23
+ function cellValueText(col, value) {
24
+ if (value == null)
25
+ return "";
26
+ if (isValueItem(value))
27
+ return cellValueText(col, value.value);
28
+ if (fieldTypeOf(col) === "location")
29
+ return locationText(value);
30
+ if (fieldTypeOf(col) === "name")
31
+ return nameText(value);
32
+ if (fieldTypeOf(col) === "phone") {
33
+ const text = phoneText(value);
34
+ if (text)
35
+ return text;
36
+ }
37
+ if (isRangeValue(value)) {
38
+ const field = col.field?.type === "range" ? col.field : { key: "", label: "", type: "range", of: "number" };
39
+ return rangeText(field, value);
40
+ }
41
+ if (isActorValue(value))
42
+ return actorLabel(value);
43
+ if (isBreakdown(value))
44
+ return value.headline == null ? "" : String(value.headline);
45
+ if (typeof value === "string" && (col.type === "select" || col.type === "status" || col.type === "multiselect")) {
46
+ return optionLabelOf(col, value);
47
+ }
48
+ const relation = value;
49
+ if (relationKey(value) != null)
50
+ return String(relation.label);
51
+ const ref = typeof value === "object" ? relationIdOf(value) : null;
52
+ if (ref)
53
+ return ref;
54
+ return String(value);
55
+ }
56
+ function optionLabelOf(col, value) {
57
+ const option = col.options?.find((candidate) => candidate.value === value);
58
+ if (!option)
59
+ return value;
60
+ return option.label ?? prettifyOptionValue(value);
61
+ }
62
+ function matchOption(col, text, value, offered) {
63
+ const keys = offered ?? (col.options ?? []).filter((option) => !option.archived).map((option) => option.value);
64
+ const labelled = (col.options ?? [])
65
+ .filter((option) => keys.includes(option.value))
66
+ .map((option) => ({ key: option.value, label: optionLabelOf(col, option.value) }));
67
+ const one = (found) => found.length === 0 ? undefined : found.length === 1 ? { key: found[0] } : { ambiguous: true };
68
+ if (typeof value === "string" && keys.includes(value))
69
+ return { key: value };
70
+ const folded = text.toLowerCase();
71
+ return (one(labelled.filter((option) => option.label === text).map((option) => option.key)) ??
72
+ one(keys.filter((key) => key === text)) ??
73
+ one(labelled.filter((option) => option.label.toLowerCase() === folded).map((option) => option.key)) ??
74
+ one(keys.filter((key) => key.toLowerCase() === folded)));
75
+ }
76
+ export function parseTsvText(text) {
77
+ const normalized = text.replace(/\r/g, "");
78
+ if (normalized === "")
79
+ return [];
80
+ const lines = normalized.split("\n");
81
+ if (lines.length > 1 && lines[lines.length - 1] === "")
82
+ lines.pop();
83
+ return lines.map((line) => line.split("\t").map((cell) => ({ text: cell })));
84
+ }
85
+ function toLocalMinuteString(date) {
86
+ return formatLocalMinute(date);
87
+ }
88
+ export function cellPrevPayload(col, baseline, unit) {
89
+ const type = fieldTypeOf(col);
90
+ if (type === "number" || type === "percent" || type === "currency") {
91
+ if (baseline == null || baseline === "")
92
+ return null;
93
+ const parsed = typeof baseline === "number" ? baseline : Number(baseline ?? 0);
94
+ const payload = {
95
+ value: Number.isFinite(parsed) ? parsed : 0,
96
+ unit,
97
+ };
98
+ return payload;
99
+ }
100
+ if (col.type === "date" || col.type === "datetime") {
101
+ if (temporalKindOf(col) === "date") {
102
+ return typeof baseline === "string" && fromDayKey(baseline) ? baseline : undefined;
103
+ }
104
+ const date = new Date(String(baseline ?? ""));
105
+ return Number.isNaN(date.getTime()) ? undefined : toLocalMinuteString(date);
106
+ }
107
+ return baseline;
108
+ }
109
+ export function cellClearPrev(col, row, pendingByCol) {
110
+ return cellPrevPayload(col, cellEditBaseline(col, row, pendingByCol), col.editUnit?.value(row));
111
+ }
112
+ export function pasteUnit(sourceUnit, currentUnit, allowed, holdsCurrency) {
113
+ const compatible = sourceUnit != null && (!allowed || allowed.includes(sourceUnit));
114
+ if (!compatible)
115
+ return { unit: currentUnit };
116
+ if (holdsCurrency && currentUnit != null && sourceUnit !== currentUnit)
117
+ return { refuse: currentUnit };
118
+ return { unit: sourceUnit };
119
+ }
120
+ export function rowHoldsCurrency(col, row) {
121
+ return col.money ? col.money.rates(row) !== null : true;
122
+ }
123
+ export function gridPasteOverlay(col) {
124
+ const kind = gridPasteKind(col);
125
+ if (kind === "text" || kind === "option" || kind === "boolean")
126
+ return true;
127
+ if (kind === "list")
128
+ return !col.multiple;
129
+ return false;
130
+ }
131
+ export function coercePaste(col, source, opts) {
132
+ const messages = opts.messages ?? resolveViewsMessage;
133
+ const write = { messages, region: opts.region };
134
+ const empty = { ok: false, reason: messages({ key: "views.grid.paste-empty" }) };
135
+ const refused = { ok: false, reason: messages({ key: "views.grid.paste-refused" }) };
136
+ const overlay = gridPasteOverlay(col);
137
+ const kind = gridPasteKind(col);
138
+ if (kind == null)
139
+ return refused;
140
+ switch (kind) {
141
+ case "text": {
142
+ const next = source.text.trim();
143
+ if (next === "" && !col.clearable)
144
+ return empty;
145
+ const vetted = gridNormalizeWrite(col, next, opts.conventions, write);
146
+ if (!vetted.ok)
147
+ return { ok: false, reason: vetted.reason };
148
+ return { ok: true, next: vetted.value, overlay };
149
+ }
150
+ case "option": {
151
+ const value = source.text.trim();
152
+ if (!value)
153
+ return empty;
154
+ const match = matchOption(col, value, source.value, opts.values);
155
+ if (!match)
156
+ return { ok: false, reason: messages({ key: "views.grid.paste-not-option", values: { value } }) };
157
+ if ("ambiguous" in match) {
158
+ return { ok: false, reason: messages({ key: "views.grid.paste-ambiguous-option", values: { value } }) };
159
+ }
160
+ return { ok: true, next: match.key, overlay };
161
+ }
162
+ case "number": {
163
+ const duration = col.format?.style === "duration";
164
+ const readDuration = (text) => {
165
+ const ms = parseDurationInput(text, opts.conventions);
166
+ return ms == null ? null : msToDurationUnit(ms, col.format?.unit ?? "ms");
167
+ };
168
+ const value = typeof source.value === "number" &&
169
+ source.type != null &&
170
+ GRID_TYPE_RULES[source.type]?.paste === "number"
171
+ ? source.value
172
+ : duration
173
+ ? readDuration(source.text)
174
+ :
175
+ parseNumber(source.text, opts.conventions);
176
+ if (value == null) {
177
+ return {
178
+ ok: false,
179
+ reason: messages({ key: duration ? "views.grid.paste-not-duration" : "views.grid.paste-not-number" }),
180
+ };
181
+ }
182
+ const unit = pasteUnit(source.unit, opts.currentUnit, col.editUnit?.options, fieldTypeOf(col) === "currency" && (opts.holdsCurrency ?? true));
183
+ if ("refuse" in unit) {
184
+ return { ok: false, reason: messages({ key: "views.grid.paste-other-currency", values: { currency: unit.refuse } }) };
185
+ }
186
+ const next = { value, unit: unit.unit };
187
+ return { ok: true, next, overlay };
188
+ }
189
+ case "date": {
190
+ if (temporalKindOf(col) === "date") {
191
+ const day = parseDateInput(source.text);
192
+ return day
193
+ ? { ok: true, next: day, overlay }
194
+ : { ok: false, reason: messages({ key: "views.grid.paste-not-date" }) };
195
+ }
196
+ const time = Date.parse(source.text.trim());
197
+ if (Number.isNaN(time))
198
+ return { ok: false, reason: messages({ key: "views.grid.paste-not-date" }) };
199
+ return { ok: true, next: toLocalMinuteString(new Date(time)), overlay };
200
+ }
201
+ case "boolean": {
202
+ const raw = source.type === "boolean" ? source.value : source.text;
203
+ const res = gridNormalizeWrite(col, raw, opts.conventions, write);
204
+ if (!res.ok)
205
+ return { ok: false, reason: res.reason };
206
+ return { ok: true, next: res.value, overlay };
207
+ }
208
+ case "relation": {
209
+ const text = source.text.trim();
210
+ if (text === "") {
211
+ if (!col.clearable)
212
+ return empty;
213
+ return { ok: true, next: null, overlay };
214
+ }
215
+ if (col.relation?.source?.kind === "remote") {
216
+ const id = relationKey(source.value);
217
+ return id
218
+ ? { ok: true, next: id, overlay }
219
+ : { ok: false, reason: messages({ key: "views.grid.paste-pick", values: { value: text } }) };
220
+ }
221
+ const candidates = col.relation?.options ?? [];
222
+ const byId = relationKey(source.value);
223
+ const exact = byId ? candidates.find((option) => option.id === byId) : undefined;
224
+ const matched = exact ?? candidates.find((option) => option.label.toLowerCase() === text.toLowerCase());
225
+ if (!matched)
226
+ return { ok: false, reason: messages({ key: "views.grid.paste-not-linkable", values: { value: text } }) };
227
+ return { ok: true, next: matched.id, overlay };
228
+ }
229
+ case "list": {
230
+ const pasted = Array.isArray(source.value)
231
+ ? source.value
232
+ : col.options?.length
233
+ ? source.text.split(",").map((raw, _index, entries) => {
234
+ const entry = raw.trim();
235
+ const value = entries.length === 1 ? source.value : undefined;
236
+ const match = matchOption(col, entry, value, opts.values);
237
+ return match && "key" in match ? match.key : entry;
238
+ })
239
+ : source.text;
240
+ const vetted = gridNormalizeWrite(col, pasted, opts.conventions, write);
241
+ if (!vetted.ok)
242
+ return { ok: false, reason: vetted.reason };
243
+ const values = (Array.isArray(vetted.value) ? vetted.value : []);
244
+ if (values.length === 0 && !col.clearable)
245
+ return empty;
246
+ return { ok: true, next: vetted.value, overlay };
247
+ }
248
+ case "range": {
249
+ if (isRangeValue(source.value))
250
+ return { ok: true, next: source.value, overlay };
251
+ const text = source.text.trim();
252
+ if (text === "") {
253
+ if (!col.clearable)
254
+ return empty;
255
+ return { ok: true, next: { low: null, high: null }, overlay };
256
+ }
257
+ const range = parseRangeText(text, opts.conventions);
258
+ if (!range)
259
+ return { ok: false, reason: messages({ key: "views.grid.paste-not-range" }) };
260
+ return { ok: true, next: range, overlay };
261
+ }
262
+ case "none":
263
+ return refused;
264
+ }
265
+ }
266
+ function parseRangeText(text, cv) {
267
+ const num = (part) => parseNumber(part, cv);
268
+ const upTo = /^up\s+to\s+(.+)$/i.exec(text);
269
+ if (upTo) {
270
+ const high = num(upTo[1]);
271
+ return high == null ? null : { low: null, high };
272
+ }
273
+ const andUp = /^(.+?)\s*\+$/.exec(text);
274
+ if (andUp) {
275
+ const low = num(andUp[1]);
276
+ return low == null ? null : { low, high: null };
277
+ }
278
+ const pair = /^(.+?)\s*(?:–|—|\s+to\s+|(?<=\d)(?:-|\s+-\s+)(?=\d))\s*(.+)$/i.exec(text);
279
+ if (pair) {
280
+ const low = num(pair[1]);
281
+ const high = num(pair[2]);
282
+ return low == null || high == null ? null : { low, high };
283
+ }
284
+ const one = num(text);
285
+ return one == null ? null : { low: one, high: one };
286
+ }
287
+ export function serializeClipboardMatrix(matrix) {
288
+ return matrix
289
+ .map((row) => row.map((cell) => cell.text.replace(/[\t\n\r]+/g, " ")).join("\t"))
290
+ .join("\n");
291
+ }
@@ -0,0 +1,27 @@
1
+ import type { ListColumn, ListRelationValue } from "../../model/column-schema.js";
2
+ /**
3
+ * The values a select / status / multiselect column offers, per column. The
4
+ * cell picker and the chips editor read the default (archived out — spec §7,
5
+ * "archived leaves every picker"); the Filter panel asks for `includeArchived`
6
+ * so a row still holding a retired value can be found.
7
+ */
8
+ export declare function deriveGridSelectValues<Row>(columns: readonly ListColumn<Row>[], rows: readonly Row[], opts?: {
9
+ includeArchived?: boolean;
10
+ }): Record<string, string[]>;
11
+ /**
12
+ * The relations actually PRESENT in the loaded rows, per column — the Filter
13
+ * panel's option list.
14
+ *
15
+ * The sibling of `deriveGridSelectValues`, and separate from it for one reason:
16
+ * a select's value IS its label, while a relation's value is an id that means
17
+ * nothing on screen. So this collects pairs, and everything downstream matches
18
+ * on `id` and shows `label`.
19
+ *
20
+ * Note what it deliberately does NOT read: `col.relation.options`, the pickable
21
+ * candidates. Those are every entity you could LINK to — 70 subscriptions here,
22
+ * thousands of companies on a leads table — and putting them in the filter
23
+ * would make the panel a directory of things the table mostly doesn't contain.
24
+ * The question a filter answers is "which of the ones I can see", so the rows
25
+ * are the right source, and it costs nothing however large the entity table is.
26
+ */
27
+ export declare function deriveGridRelationValues<Row>(columns: readonly ListColumn<Row>[], rows: readonly Row[]): Record<string, ListRelationValue[]>;