@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
@@ -5,20 +5,20 @@ import { formatNumberText, parseNumber, roundTo, } from "@viewkitjs/fields";
5
5
  import { durationUnitToMs, formatDurationInput, msToDurationUnit, parseDurationInput, } from "@viewkitjs/fields/query";
6
6
  import { cx } from "../internal/cx.js";
7
7
  import { useViews } from "../provider/context.js";
8
- export const NumberEditor = forwardRef(function NumberEditor({ initial, seed, unit, unitOptions, decimals = 2, durationUnit, allowEmpty = false, unitLeft = false, align = "end", conventions, onRequestClose, }, ref) {
8
+ export const NumberEditor = forwardRef(function NumberEditor({ initial, seed, unit, unitOptions, code, decimals = 2, durationUnit, allowEmpty = false, unitLeft = false, align = "end", conventions, onRequestClose, }, ref) {
9
9
  const inputRef = useRef(null);
10
10
  const chipRef = useRef(null);
11
11
  const [currentUnit, setCurrentUnit] = useState(unit);
12
12
  const [unitOpen, setUnitOpen] = useState(false);
13
13
  const views = useViews();
14
14
  const cv = conventions ?? views.conventions;
15
- const { Popover } = views.components;
15
+ const { Popover, Input } = views.components;
16
16
  const { List, Row } = views.atoms;
17
17
  useEffect(() => {
18
18
  const el = inputRef.current;
19
19
  if (!el)
20
20
  return;
21
- el.focus();
21
+ el.focus({ preventScroll: true });
22
22
  const len = el.value.length;
23
23
  el.setSelectionRange(len, len);
24
24
  }, []);
@@ -58,7 +58,7 @@ export const NumberEditor = forwardRef(function NumberEditor({ initial, seed, un
58
58
  return { kind: "commit", payload: { value: parsed, unit: currentUnit } };
59
59
  };
60
60
  useImperativeHandle(ref, () => ({ resolveClose }));
61
- return (_jsxs("span", { className: "flex h-full w-full min-w-0 items-center gap-1.5", children: [_jsx("input", { ref: inputRef, defaultValue: seed ?? initialText, inputMode: durationUnit ? "text" : "decimal", onKeyDown: (e) => {
61
+ return (_jsxs("span", { className: "flex h-full w-full min-w-0 items-center gap-1.5", children: [_jsx(Input, { ref: inputRef, defaultValue: seed ?? initialText, inputMode: durationUnit ? "text" : "decimal", onKeyDown: (e) => {
62
62
  e.stopPropagation();
63
63
  if (e.key === "Enter") {
64
64
  e.preventDefault();
@@ -74,13 +74,13 @@ export const NumberEditor = forwardRef(function NumberEditor({ initial, seed, un
74
74
  }, onBlur: () => {
75
75
  if (!unitOpen)
76
76
  onRequestClose("blur");
77
- }, onClick: (e) => e.stopPropagation(), className: cx("h-full min-w-0 select-text bg-transparent tabular-nums text-(length:--grid-text) text-(color:--vk-fg) outline-hidden", align === "start" ? "w-40 flex-none text-left" : "w-full flex-1 text-right") }), unit &&
78
- (unitOptions && unitOptions.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("button", { ref: chipRef, type: "button", tabIndex: -1, onMouseDown: (e) => e.preventDefault(), onClick: (e) => {
77
+ }, onClick: (e) => e.stopPropagation(), className: cx("h-full min-w-0 select-text bg-transparent tabular-nums text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", align === "start" ? "w-40 flex-none text-left" : "w-full flex-1 text-right") }), (unit ?? code) &&
78
+ (unit && unitOptions && unitOptions.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("button", { ref: chipRef, type: "button", tabIndex: -1, onMouseDown: (e) => e.preventDefault(), onClick: (e) => {
79
79
  e.stopPropagation();
80
80
  setUnitOpen((o) => !o);
81
81
  }, className: cx("shrink-0 text-xs font-normal text-(color:--vk-fg-subtle) transition-colors hover:text-(color:--vk-fg)", unitLeft && "order-first"), children: currentUnit }), _jsx(Popover, { open: unitOpen, onOpenChange: (next) => setUnitOpen(next), anchor: chipRef, side: "bottom", align: unitLeft ? "start" : "end", sideOffset: 6, initialFocus: false, onOutsidePress: (event) => (chipRef.current?.contains(event.target) ? false : undefined), onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "w-24", children: _jsx(List, { children: unitOptions.map((u) => (_jsx(Row, { label: u, chosen: u === currentUnit, onMouseDown: (e) => e.preventDefault(), onClick: () => {
82
82
  setCurrentUnit(u);
83
83
  setUnitOpen(false);
84
84
  inputRef.current?.focus();
85
- } }, u))) }) })] })) : (_jsx("span", { className: cx("shrink-0 text-xs font-normal text-(color:--vk-fg-subtlest)", unitLeft && "order-first"), children: unit })))] }));
85
+ } }, u))) }) })] })) : (_jsx("span", { className: cx("shrink-0 text-xs font-normal text-(color:--vk-fg-subtlest)", unitLeft && "order-first"), children: unit ?? code })))] }));
86
86
  });
@@ -1,9 +1,16 @@
1
- import { type CloseReason, type CloseResolution, type FieldConventions, type RangeValue } from "@viewkitjs/fields";
1
+ import { type CloseReason, type CloseResolution, type FieldConventions, type RangePreset, type RangeValue } from "@viewkitjs/fields";
2
2
  /**
3
3
  * A RANGE — two number boxes, low and high, inline like the number core. Tab
4
4
  * moves from low to high inside the editor; a blur that lands on the other box
5
5
  * is not a close. An empty box is an open end; two empty boxes are a clear,
6
6
  * committed only when the host allows one.
7
+ *
8
+ * A field that names its bands (`presets`, such as a company's 1–10 or 11–50
9
+ * people) lists them under the boxes: on the desktop in a small menu that opens
10
+ * with the editor, in a sheet or a panel in the editor's own column. A click on a
11
+ * band writes its two ends into the boxes and closes as a pick, so the band is
12
+ * read, compared and judged exactly as typed ends are. The boxes stay, so a value
13
+ * between bands is still typed.
7
14
  */
8
15
  export type RangeEditorHandle = {
9
16
  resolveClose: (reason: CloseReason) => CloseResolution<RangeValue>;
@@ -18,5 +25,13 @@ export declare const RangeEditor: import("react").ForwardRefExoticComponent<{
18
25
  suffix?: string;
19
26
  align?: "start" | "end";
20
27
  conventions?: FieldConventions;
28
+ /** The field's bands (`presets`): listed under the two boxes, and a click saves that band. */
29
+ bands?: readonly RangePreset[];
30
+ /** Where the bands are listed. `popover` (the default): a small menu under the boxes, for an
31
+ * editor typed where its value stands. `below`: in the editor's own column, for an editor
32
+ * that already sits in a sheet or a panel. */
33
+ bandsAt?: "popover" | "below";
34
+ /** Classes for the box that holds the two inputs: the host's frame, such as a sheet's field. */
35
+ boxClassName?: string;
21
36
  onRequestClose: (reason: CloseReason) => void;
22
37
  } & import("react").RefAttributes<RangeEditorHandle>>;
@@ -4,9 +4,12 @@ import { forwardRef, useEffect, useImperativeHandle, useRef, } from "react";
4
4
  import { formatNumberText, parseNumber, roundTo, } from "@viewkitjs/fields";
5
5
  import { cx } from "../internal/cx.js";
6
6
  import { useViews } from "../provider/context.js";
7
- export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, decimals = 0, allowEmpty = false, suffix, align = "end", conventions, onRequestClose, }, ref) {
7
+ export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, decimals = 0, allowEmpty = false, suffix, align = "end", conventions, bands, bandsAt = "popover", boxClassName, onRequestClose, }, ref) {
8
8
  const views = useViews();
9
+ const { Input, Popover } = views.components;
10
+ const { List, Row } = views.atoms;
9
11
  const cv = conventions ?? views.conventions;
12
+ const rootRef = useRef(null);
10
13
  const boxRef = useRef(null);
11
14
  const lowRef = useRef(null);
12
15
  const highRef = useRef(null);
@@ -14,7 +17,7 @@ export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, deci
14
17
  const el = lowRef.current;
15
18
  if (!el)
16
19
  return;
17
- el.focus();
20
+ el.focus({ preventScroll: true });
18
21
  el.setSelectionRange(el.value.length, el.value.length);
19
22
  }, []);
20
23
  const parse = (raw) => {
@@ -59,12 +62,25 @@ export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, deci
59
62
  }
60
63
  };
61
64
  const blur = (e) => {
62
- if (!boxRef.current?.contains(e.relatedTarget))
65
+ if (!rootRef.current?.contains(e.relatedTarget))
63
66
  onRequestClose("blur");
64
67
  };
65
- const input = cx("h-full w-16 min-w-0 flex-none select-text bg-transparent tabular-nums text-(length:--grid-text) text-(color:--vk-fg) outline-hidden", align === "end" ? "text-right" : "text-left");
66
- return (_jsxs("span", { ref: boxRef, onMouseDown: (e) => {
68
+ const pickBand = (band) => {
69
+ if (lowRef.current)
70
+ lowRef.current.value = text(band.low);
71
+ if (highRef.current)
72
+ highRef.current.value = text(band.high);
73
+ onRequestClose("pick");
74
+ };
75
+ const held = (band) => {
76
+ const at = (n) => (n == null ? null : roundTo(n, decimals));
77
+ return initial != null && at(initial.low) === band.low && at(initial.high) === band.high;
78
+ };
79
+ const bandList = bands && bands.length > 0 ? (_jsx(List, { children: bands.map((band) => (_jsx(Row, { label: band.label, chosen: held(band), onMouseDown: (e) => e.preventDefault(), onClick: () => pickBand(band) }, band.key))) })) : null;
80
+ const input = cx("h-full w-16 min-w-0 shrink select-text bg-transparent tabular-nums text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", align === "end" ? "text-right" : "text-left");
81
+ const below = bandList !== null && bandsAt === "below";
82
+ return (_jsxs("span", { ref: rootRef, onMouseDown: (e) => {
67
83
  if (!(e.target instanceof HTMLInputElement))
68
84
  e.preventDefault();
69
- }, className: cx("flex h-full w-full min-w-0 items-center gap-1.5", align === "end" && "justify-end"), children: [_jsx("input", { ref: lowRef, defaultValue: seed ?? text(initial?.low), inputMode: "decimal", "aria-label": views.messages({ key: "views.editors.range-low" }), placeholder: views.messages({ key: "views.editors.range-low" }), onKeyDown: keys("low"), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }), _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: "\u2013" }), _jsx("input", { ref: highRef, defaultValue: text(initial?.high), inputMode: "decimal", "aria-label": views.messages({ key: "views.editors.range-high" }), placeholder: views.messages({ key: "views.editors.range-high" }), onKeyDown: keys("high"), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }), suffix && _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtlest)", children: suffix })] }));
85
+ }, className: below ? "flex w-full min-w-0 flex-col gap-1" : "contents", children: [_jsxs("span", { ref: boxRef, className: cx("flex h-full w-full min-w-0 items-center gap-1.5", align === "end" && "justify-end", boxClassName), children: [_jsx(Input, { ref: lowRef, defaultValue: seed ?? text(initial?.low), inputMode: "decimal", "aria-label": views.messages({ key: "views.editors.range-low" }), placeholder: views.messages({ key: "views.editors.range-low" }), onKeyDown: keys("low"), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }), _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: "\u2013" }), _jsx(Input, { ref: highRef, defaultValue: text(initial?.high), inputMode: "decimal", "aria-label": views.messages({ key: "views.editors.range-high" }), placeholder: views.messages({ key: "views.editors.range-high" }), onKeyDown: keys("high"), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }), suffix && _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtlest)", children: suffix })] }), below && bandList, bandList !== null && !below && (_jsx(Popover, { open: true, onOpenChange: () => { }, anchor: boxRef, side: "bottom", align: align === "end" ? "end" : "start", sideOffset: 6, initialFocus: false, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "w-40", children: bandList }))] }));
70
86
  });
@@ -1,8 +1,11 @@
1
1
  import { type ReactNode } from "react";
2
2
  import type { CloseReason, CloseResolution, FieldMessageResolver } from "@viewkitjs/fields";
3
- import { type RelationSource } from "./relation-source.js";
3
+ import { type RelationCreate } from "./relation-panel.js";
4
+ import type { RelationSource } from "./relation-source.js";
4
5
  export { RELATION_PAGE_SIZE, RELATION_SEARCH_DEBOUNCE_MS } from "./relation-source.js";
5
6
  export type { RelationCandidate, RelationSearch, RelationSource } from "./relation-source.js";
7
+ export type { RelationCreate } from "./relation-panel.js";
8
+ export { RelationSetEditor, type RelationSetEditorHandle, type RelationSetItem, } from "./RelationSetEditor.js";
6
9
  /**
7
10
  * THE relation-picking core — search the candidates, pick one, it REPLACES the
8
11
  * link. Many-to-one, so there is nothing to accumulate.
@@ -10,34 +13,11 @@ export type { RelationCandidate, RelationSearch, RelationSource } from "./relati
10
13
  * Built from the app's command list (the components map) rather than a
11
14
  * combobox: a combobox owns a trigger button, and a cell editor has none — it
12
15
  * is already open, anchored over a value that is already on screen. The host
13
- * owns that mounting behaviour; what lives here is the panel, the search, and
14
- * what a close MEANS for a relation: a pick is the commit, everything else
15
- * discards. The panel also carries the way OUT when the row isn't there — the
16
- * host's pinned create rows — and wears the kind's glyph the host names.
17
- *
18
- * The candidates are the HOST's, through a discriminated source: a STATIC list
19
- * (every subscription you could link to, preloaded — the grid's shape, and any
20
- * small set's) or a REMOTE search over thousands of rows (a client, a person,
21
- * a deal). The core owns the remote branch's choreography — when to ask, what
22
- * to drop, what to show meanwhile — and never the asking itself: the search
23
- * function is the host's, which is what keeps workspace tenancy in the host's
24
- * closure and in the routes.
25
- */
26
- /**
27
- * A pinned row under the list for "it isn't in the list yet": the host opens
28
- * its own create form with what was typed already filled. Pinned rather than
29
- * appended to the results, because an affordance that only appears below a
30
- * scrolled list is one nobody finds — and a button rather than a command item,
31
- * because the filter would hide an item with no label to match while a query
32
- * is typed, which is exactly when the row is wanted. A click is a `pick` that
33
- * resolves `noop`: the host closes, nothing is written, then `onCreate` runs.
16
+ * owns that mounting behaviour; what lives here is what a close MEANS for a
17
+ * relation: a pick is the commit, everything else discards. The list itself —
18
+ * the search, the candidates, the host's pinned create rows — is the shared
19
+ * `RelationPanel`.
34
20
  */
35
- export type RelationCreate = {
36
- /** The row's words; receives the trimmed query. */
37
- label: (query: string) => string;
38
- /** Runs AFTER the host has been asked to close, with the trimmed query. */
39
- onCreate: (query: string) => void;
40
- };
41
21
  export type RelationEditorHandle = {
42
22
  /** What this close means. Synchronous, idempotent, no timer — the host
43
23
  * closes, waits its own exit gap, then applies the answer. */
@@ -62,4 +42,9 @@ export declare const RelationEditor: import("react").ForwardRefExoticComponent<{
62
42
  message?: FieldMessageResolver;
63
43
  /** The pinned create rows, in order. */
64
44
  creates?: RelationCreate[];
45
+ /** The text the search opens with: a letter typed on the cell that opened it. */
46
+ seed?: string;
47
+ /** Put the caret in the search as the panel opens, without scrolling. Default false: a host whose surface puts
48
+ * focus there itself, or never should (a phone's sheet opens with the keyboard down), leaves it off. */
49
+ focusSearch?: boolean;
65
50
  } & import("react").RefAttributes<RelationEditorHandle>>;
@@ -1,21 +1,23 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useImperativeHandle, useRef, useState } from "react";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from "react";
4
4
  import { useViews } from "../provider/context.js";
5
- import { EndOfListSentinel, useRemotePage } from "./relation-source.js";
5
+ import { RelationPanel } from "./relation-panel.js";
6
6
  export { RELATION_PAGE_SIZE, RELATION_SEARCH_DEBOUNCE_MS } from "./relation-source.js";
7
- export const RelationEditor = forwardRef(function RelationEditor({ candidates, initial, clearable, onRequestClose, kindGlyph, noneLabel, message, creates }, ref) {
7
+ export { RelationSetEditor, } from "./RelationSetEditor.js";
8
+ export const RelationEditor = forwardRef(function RelationEditor({ candidates, initial, clearable, onRequestClose, kindGlyph, noneLabel, message, creates, seed, focusSearch = false, }, ref) {
8
9
  const [picked, setPicked] = useState(undefined);
9
10
  const pickedRef = useRef(undefined);
10
- const [query, setQuery] = useState("");
11
- const remote = candidates.kind === "remote";
12
- const page = useRemotePage(candidates, query);
13
- const rows = candidates.kind === "static" ? candidates.items : page.items;
11
+ const [query, setQuery] = useState(seed ?? "");
12
+ const searchRef = useRef(null);
14
13
  const views = useViews();
15
14
  const words = message ?? views.conventions.messages;
16
15
  const { Command } = views.components;
17
- const { List, Row, RowContent } = views.atoms;
18
- const Add = views.icons.add;
16
+ const { RowContent } = views.atoms;
17
+ useEffect(() => {
18
+ if (focusSearch)
19
+ searchRef.current?.focus({ preventScroll: true });
20
+ }, []);
19
21
  const resolveClose = (reason) => {
20
22
  if (reason !== "pick")
21
23
  return { kind: "cancel" };
@@ -31,34 +33,9 @@ export const RelationEditor = forwardRef(function RelationEditor({ candidates, i
31
33
  onRequestClose("pick");
32
34
  };
33
35
  const current = picked === undefined ? initial : picked;
34
- const glyphs = kindGlyph != null || rows.some((candidate) => candidate.icon != null);
35
- const glyph = (node) => node != null ? (_jsx("span", { className: "flex size-3.5 items-center justify-center [&>svg]:size-3.5", children: node })) : undefined;
36
- const none = clearable && (!remote || query === "");
37
- const status = !remote
38
- ? null
39
- : page.failed && rows.length === 0
40
- ? words({ key: "editor.search-failed" })
41
- : page.searching
42
- ? words({ key: "editor.searching" })
43
- : rows.length === 0 && !page.loadingMore
44
- ? words({ key: "editor.nothing-matches" })
45
- : null;
46
- const moreStatus = !remote
47
- ? null
48
- : page.loadingMore
49
- ? words({ key: "editor.loading-more" })
50
- : page.failed && rows.length > 0
51
- ? words({ key: "editor.search-failed" })
52
- : null;
53
- const paging = remote && !page.exhausted && rows.length > 0;
54
- return (_jsxs(Command.Root, { shouldFilter: !remote, filter: remote
55
- ? undefined
56
- : (value, search) => {
57
- const label = rows.find((candidate) => candidate.id === value)?.label ?? "";
58
- return label.toLowerCase().includes(search.toLowerCase()) ? 1 : 0;
59
- }, children: [_jsx(Command.Input, { placeholder: words({ key: "editor.search" }), className: "h-9 text-[13px]", value: query, onValueChange: setQuery }), _jsxs(Command.List, { className: "max-h-72 overscroll-contain scrollbar-overlay", children: [remote ? (status && (_jsx("div", { role: "status", className: "py-4 text-center text-xs text-(color:--vk-fg-subtle)", children: status }))) : (_jsx(Command.Empty, { className: "py-4 text-center text-xs text-(color:--vk-fg-subtle)", children: words({ key: "editor.nothing-matches" }) })), _jsx(Command.Group, { className: "p-0", children: _jsxs(List, { children: [none && (_jsx(Command.Item, { value: "__none__", onSelect: () => pick(null), chosen: current == null, children: _jsx(RowContent, { size: "compact", leadingLane: glyphs, label: noneLabel ?? words({ key: "relation.none" }), tone: current == null ? "default" : "muted", chosen: current == null, chosenTint: false }) })), rows.map((candidate) => (_jsx(Command.Item, { value: candidate.id, onSelect: () => pick(candidate.id), chosen: candidate.id === current, children: _jsx(RowContent, { size: "compact", leading: glyph(candidate.icon ?? kindGlyph), leadingLane: glyphs, label: candidate.label, description: candidate.sublabel, trailing: candidate.badge ? (_jsx("span", { className: "ml-2 shrink-0 rounded-sm border border-(color:--vk-border) px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-(color:--vk-fg-subtle)", children: candidate.badge })) : undefined, chosen: candidate.id === current, chosenTint: false }) }, candidate.id)))] }) }), paging && _jsx(EndOfListSentinel, { onReveal: page.loadMore }), moreStatus && (_jsx("div", { role: "status", className: "py-3 text-center text-xs text-(color:--vk-fg-subtle)", children: moreStatus }))] }), creates && creates.length > 0 && (_jsx("div", { className: "border-t border-(color:--vk-border)", children: creates.map((create, index) => (_jsx(Row, { size: "compact", tone: "muted", leading: _jsx(Add, { className: "h-3.5 w-3.5 shrink-0" }), label: create.label(query.trim()), onClick: () => {
60
- const typed = query.trim();
61
- onRequestClose("pick");
62
- create.onCreate(typed);
63
- } }, index))) }))] }));
36
+ const none = clearable && (candidates.kind !== "remote" || query === "");
37
+ return (_jsx(RelationPanel, { candidates: candidates, query: query, onQueryChange: setQuery, searchRef: searchRef, kindGlyph: kindGlyph, message: message, creates: creates, onCreate: (create, typed) => {
38
+ onRequestClose("pick");
39
+ create.onCreate(typed);
40
+ }, isChosen: (id) => id === current, startOn: seed ? undefined : (initial ?? undefined), onSelect: (candidate) => pick(candidate.id), before: ({ glyphs }) => none && (_jsx(Command.Item, { value: "__none__", onSelect: () => pick(null), chosen: current == null, children: _jsx(RowContent, { size: "compact", leadingLane: glyphs, label: noneLabel ?? words({ key: "relation.none" }), tone: current == null ? "default" : "muted", chosen: current == null, chosenTint: false }) })) }));
64
41
  });
@@ -0,0 +1,53 @@
1
+ import { type ReactNode } from "react";
2
+ import type { CloseReason, CloseResolution, FieldMessageResolver, RelationDraftLink } from "@viewkitjs/fields";
3
+ import { type RelationCreate } from "./relation-panel.js";
4
+ import type { RelationSource } from "./relation-source.js";
5
+ /** One linked record as the several-records core holds it: the link, and what its row shows. */
6
+ export type RelationSetItem = RelationDraftLink & {
7
+ label: string;
8
+ icon?: ReactNode;
9
+ };
10
+ export type RelationSetEditorHandle = {
11
+ /** What this close means. Synchronous, idempotent, no timer — the host
12
+ * closes, waits its own exit gap, then applies the answer. */
13
+ resolveClose: (reason: CloseReason) => CloseResolution<RelationDraftLink[]>;
14
+ };
15
+ /**
16
+ * THE core for a relation holding several records: search the candidates, and
17
+ * every click adds a record to the set or takes it out, with the list kept
18
+ * open; Enter toggles the highlighted row, as a click does. The set leaves as
19
+ * ONE change: a click outside, the sheet's ✓, Tab or Shift-Tab commit what it
20
+ * holds, as pick many does; Escape and the sheet's ✕ throw it away.
21
+ *
22
+ * The linked records are drawn first, chosen, whatever page the search holds —
23
+ * a remote list may not hold them at all. Where the field leads by a flag the
24
+ * first is the lead: it carries the lead's mark and every other linked record
25
+ * a way to become it; a record added joins at the end, so the lead stays until
26
+ * another is marked, and removing the lead passes it to the next; Space on a
27
+ * highlighted linked record, with the search empty, makes it the lead, as its
28
+ * Make lead button does. A link keeps the role it was stored with; a new one
29
+ * has none.
30
+ *
31
+ * The highlight opens on the first linked record. Until it leaves that record,
32
+ * by a key, by typing or by the pointer, an Enter does nothing, so the first
33
+ * linked record is never taken out unasked.
34
+ */
35
+ export declare const RelationSetEditor: import("react").ForwardRefExoticComponent<{
36
+ candidates: RelationSource;
37
+ /** The linked records, in their stored order. */
38
+ initial: readonly RelationSetItem[];
39
+ /** The field leads by a flag: one link is marked lead. Default false. */
40
+ lead?: boolean;
41
+ /** Tab, Shift-Tab, and a create row: the host closes, then asks `resolveClose`. */
42
+ onRequestClose: (reason: CloseReason) => void;
43
+ /** The kind's glyph, from the host, worn by every record that brought no icon of its own. */
44
+ kindGlyph?: ReactNode;
45
+ /** The host's words for this panel (fields' messages); default: the provider's conventions. */
46
+ message?: FieldMessageResolver;
47
+ /** The pinned create rows, in order. A click saves the set as it stands, then opens the host's form. */
48
+ creates?: RelationCreate[];
49
+ /** The text the search opens with: a letter typed on the cell that opened it. */
50
+ seed?: string;
51
+ /** Put the caret in the search as the panel opens, without scrolling. Default false. */
52
+ focusSearch?: boolean;
53
+ } & import("react").RefAttributes<RelationSetEditorHandle>>;
@@ -0,0 +1,112 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from "react";
4
+ import { useViews } from "../provider/context.js";
5
+ import { RelationPanel } from "./relation-panel.js";
6
+ function opening(items, lead) {
7
+ if (!lead)
8
+ return [...items];
9
+ const marked = items.findIndex((item) => item.primary);
10
+ const first = marked < 0 ? 0 : marked;
11
+ const ordered = items.length === 0 ? [] : [items[first], ...items.filter((_, index) => index !== first)];
12
+ return ordered.map((item, index) => ({ ...item, primary: index === 0 }));
13
+ }
14
+ function linksOf(items, lead) {
15
+ return items.map((item, index) => ({
16
+ id: item.id,
17
+ ...(item.kind !== undefined ? { kind: item.kind } : {}),
18
+ ...(item.role !== undefined ? { role: item.role } : {}),
19
+ ...(lead ? { primary: index === 0 } : {}),
20
+ }));
21
+ }
22
+ function highlightedIn(search) {
23
+ const row = search.getAttribute("aria-activedescendant");
24
+ if (!row)
25
+ return undefined;
26
+ return search.ownerDocument.getElementById(row)?.getAttribute("data-value") ?? undefined;
27
+ }
28
+ export const RelationSetEditor = forwardRef(function RelationSetEditor({ candidates, initial, lead = false, onRequestClose, kindGlyph, message, creates, seed, focusSearch = false, }, ref) {
29
+ const [start] = useState(() => opening(initial, lead));
30
+ const [draft, setDraft] = useState(start);
31
+ const draftRef = useRef(draft);
32
+ const [query, setQuery] = useState(seed ?? "");
33
+ const searchRef = useRef(null);
34
+ const views = useViews();
35
+ const words = message ?? views.conventions.messages;
36
+ const { Command, Button } = views.components;
37
+ const { RowContent } = views.atoms;
38
+ useEffect(() => {
39
+ if (focusSearch)
40
+ searchRef.current?.focus({ preventScroll: true });
41
+ }, []);
42
+ const movedRef = useRef(false);
43
+ const openedOn = start[0]?.id;
44
+ const change = (next) => {
45
+ const marked = lead ? next.map((item, index) => ({ ...item, primary: index === 0 })) : next;
46
+ draftRef.current = marked;
47
+ setDraft(marked);
48
+ if (focusSearch)
49
+ searchRef.current?.focus({ preventScroll: true });
50
+ };
51
+ const resolveClose = (reason) => {
52
+ if (reason === "escape")
53
+ return { kind: "cancel" };
54
+ const now = draftRef.current;
55
+ const same = now.length === start.length && now.every((item, index) => item.id === start[index].id);
56
+ return same ? { kind: "noop" } : { kind: "commit", payload: linksOf(now, lead) };
57
+ };
58
+ useImperativeHandle(ref, () => ({ resolveClose }));
59
+ const linked = new Set(draft.map((item) => item.id));
60
+ const remove = (id) => change(draftRef.current.filter((item) => item.id !== id));
61
+ const makeLead = (id) => {
62
+ const item = draftRef.current.find((each) => each.id === id);
63
+ if (item)
64
+ change([item, ...draftRef.current.filter((each) => each.id !== id)]);
65
+ };
66
+ const typed = query.trim().toLowerCase();
67
+ const shown = candidates.kind === "remote" && typed !== ""
68
+ ? draft.filter((item) => item.label.toLowerCase().includes(typed))
69
+ : draft;
70
+ return (_jsx(RelationPanel, { candidates: candidates, query: query, onQueryChange: (next) => {
71
+ movedRef.current = true;
72
+ setQuery(next);
73
+ }, searchRef: searchRef, onSearchKeyDown: (event) => {
74
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key))
75
+ movedRef.current = true;
76
+ if (event.key === "Enter" && !movedRef.current && query === "" && openedOn !== undefined) {
77
+ const now = highlightedIn(event.currentTarget);
78
+ if (now === undefined || now === openedOn) {
79
+ event.preventDefault();
80
+ event.stopPropagation();
81
+ return;
82
+ }
83
+ }
84
+ if (event.key === " " && lead && query === "") {
85
+ const now = highlightedIn(event.currentTarget);
86
+ if (now !== undefined && linked.has(now)) {
87
+ event.preventDefault();
88
+ makeLead(now);
89
+ return;
90
+ }
91
+ }
92
+ if (event.key === "Tab") {
93
+ event.preventDefault();
94
+ onRequestClose(event.shiftKey ? "shift-tab" : "tab");
95
+ }
96
+ }, kindGlyph: kindGlyph, message: message, creates: creates, onCreate: (create, text) => {
97
+ onRequestClose("pick");
98
+ create.onCreate(text);
99
+ }, labels: new Map(draft.map((item) => [item.id, item.label])), drawsBefore: shown.length > 0, hide: (id) => linked.has(id), isChosen: (id) => linked.has(id), onSelect: (candidate) => {
100
+ if (linked.has(candidate.id))
101
+ return remove(candidate.id);
102
+ change([
103
+ ...draftRef.current,
104
+ {
105
+ id: candidate.id,
106
+ label: candidate.label,
107
+ ...(candidate.kind !== undefined ? { kind: candidate.kind } : {}),
108
+ ...(candidate.icon != null ? { icon: candidate.icon } : {}),
109
+ },
110
+ ]);
111
+ }, before: ({ glyphs, glyph }) => shown.map((item) => (_jsx(Command.Item, { value: item.id, onSelect: () => remove(item.id), chosen: true, children: _jsx(RowContent, { size: "compact", leading: glyph(item.icon ?? kindGlyph), leadingLane: glyphs, label: item.label, trailing: !lead ? undefined : item.id === draft[0]?.id ? (_jsx("span", { "data-slot": "vk-relation-lead", className: "ml-2 shrink-0 text-[11px] text-(color:--vk-fg-subtle)", children: words({ key: "relation.lead" }) })) : (_jsx("span", { className: "ml-2 shrink-0", onMouseDown: (event) => event.preventDefault(), onClick: (event) => event.stopPropagation(), children: _jsx(Button, { variant: "ghost", size: "sm", className: "h-6 px-1.5 text-[11px]", onClick: () => makeLead(item.id), children: words({ key: "relation.make-lead" }) }) })), chosen: true, chosenTint: false }) }, item.id))) }));
112
+ });
@@ -31,6 +31,9 @@ export type PickerOption = {
31
31
  /** The option's glyph (the app's own name), drawn by the app's AppIcon before its label. */
32
32
  icon?: string;
33
33
  };
34
+ /** A closed list longer than this opens with a search on top; this many or fewer stay a plain list (decided
35
+ * 10 Nov): a short list reads at a glance, and a search over four options is one more thing in the way. */
36
+ export declare const SELECT_SEARCH_PAST = 8;
34
37
  export type SelectEditorHandle = {
35
38
  /** What this close means. Synchronous, idempotent, no timer — the host
36
39
  * closes, waits its own exit gap, then applies the answer. */
@@ -54,6 +57,17 @@ export declare const SelectEditor: import("react").ForwardRefExoticComponent<{
54
57
  * text when no option's value is it (POR-898: Enter picks the first match). Picking that row commits the
55
58
  * trimmed text. */
56
59
  creatable?: boolean;
60
+ /** The text the search opens with (a letter typed on the cell that opened it), when the panel shows a search:
61
+ * an open select, or a closed list past `SELECT_SEARCH_PAST` options. A plain list ignores it. */
62
+ seed?: string;
63
+ /** Put the caret in the search when the panel opens with one, without scrolling. Default false: a host whose
64
+ * surface never moves focus (a drawer row on a desktop) leaves it off. */
65
+ focusSearch?: boolean;
66
+ /** Opened from the keyboard: a plain list puts the focus on the row it holds (None when it may be emptied and
67
+ * holds nothing, else its first row), so an Enter at once changes nothing; ↓ and ↑ walk its rows, round at either
68
+ * end, and Enter picks the focused one. Default false: a list opened by a pointer moves no focus. A list with a
69
+ * search ignores it, and `focusSearch` gives that one the keys. */
70
+ focusList?: boolean;
57
71
  } & import("react").RefAttributes<SelectEditorHandle>>;
58
72
  /**
59
73
  * A select field's options, dressed the way its cells are drawn — so what you
@@ -62,11 +76,15 @@ export declare const SelectEditor: import("react").ForwardRefExoticComponent<{
62
76
  * Archived options never reach a picker (`optionsOf`). A status keeps its
63
77
  * semantic slots; a select gets the category-colour chain — the workspace's
64
78
  * `optionColors` first, then the field's own, then the derived hue — which is
65
- * the same colour the grid draws. `extraValues` are values the rows hold that
66
- * no option names: offered so a stray value can be picked back, drawn as its
67
- * raw code (a registry never invents a label); an archived value stays out.
79
+ * the same colour the grid draws. `extraValues` are an open select's values, the
80
+ * ones its records hold: drawn as their raw code (a registry never invents a
81
+ * label); an archived value stays out. `current` is the value the surface holds:
82
+ * offered last when no active option is it, a stray or an archived option, so
83
+ * its own list shows it checked. A closed list offers a stray only there, never
84
+ * to the other rows (decided 10 Nov).
68
85
  */
69
86
  export declare function pickerOptionsFromField(field: FieldDefOf<"select" | "status">, opts?: {
70
87
  optionColors?: Record<string, CategoryColor>;
71
88
  extraValues?: readonly string[];
89
+ current?: string | null;
72
90
  }): PickerOption[];
@@ -1,13 +1,17 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useImperativeHandle, useRef, useState } from "react";
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
4
4
  import { resolveCategoryColor } from "@viewkitjs/fields/design/category-colors";
5
5
  import { optionsOf, } from "@viewkitjs/fields";
6
6
  import { useViews } from "../provider/context.js";
7
- export const SelectEditor = forwardRef(function SelectEditor({ options, initial, clearable = false, onRequestClose, message, creatable = false }, ref) {
7
+ export const SELECT_SEARCH_PAST = 8;
8
+ export const SelectEditor = forwardRef(function SelectEditor({ options, initial, clearable = false, onRequestClose, message, creatable = false, seed, focusSearch = false, focusList = false, }, ref) {
9
+ const searchable = creatable || options.length > SELECT_SEARCH_PAST;
8
10
  const [picked, setPicked] = useState(null);
9
11
  const pickedRef = useRef(null);
10
- const [query, setQuery] = useState("");
12
+ const [query, setQuery] = useState(searchable ? (seed ?? "") : "");
13
+ const searchRef = useRef(null);
14
+ const listRef = useRef(null);
11
15
  const views = useViews();
12
16
  const words = message ?? views.conventions.messages;
13
17
  const { List, Row, RowContent, StatusBadge, Tag } = views.atoms;
@@ -27,27 +31,66 @@ export const SelectEditor = forwardRef(function SelectEditor({ options, initial,
27
31
  ? [{ value: "", label: words({ key: "relation.none" }) }, ...options]
28
32
  : options;
29
33
  const current = picked ?? initial ?? (clearable ? "" : undefined);
34
+ useEffect(() => {
35
+ if (searchable) {
36
+ if (focusSearch)
37
+ searchRef.current?.focus({ preventScroll: true });
38
+ return;
39
+ }
40
+ if (!focusList)
41
+ return;
42
+ const at = rows.findIndex((option) => option.value === current);
43
+ const buttons = listButtons(listRef.current);
44
+ (buttons[at] ?? buttons[0])?.focus({ preventScroll: true });
45
+ }, []);
30
46
  const choose = (value) => {
31
47
  pickedRef.current = value;
32
48
  setPicked(value);
33
49
  onRequestClose("pick");
34
50
  };
35
51
  const badge = (option) => option.slot ? (_jsx(StatusBadge, { slot: option.slot, label: option.label, leading: glyph(option.icon) })) : option.color ? (_jsx(Tag, { label: option.label, color: option.color, leading: glyph(option.icon) })) : (option.label);
36
- if (creatable) {
52
+ if (searchable) {
37
53
  const typed = query.trim();
38
54
  const needle = typed.toLowerCase();
39
55
  const shown = (typed === "" ? rows : options).filter((option) => needle === "" || option.label.toLowerCase().includes(needle));
40
- const useTyped = typed !== "" && !options.some((option) => option.value.toLowerCase() === needle);
56
+ const useTyped = creatable && typed !== "" && !options.some((option) => option.value.toLowerCase() === needle);
57
+ const itemValue = (value) => (value === "" ? noneValue(options) : value);
58
+ const startOn = clearable && !seed?.trim() ? itemValue(initial ?? "") : undefined;
41
59
  const useRow = useTyped && (_jsx(Command.Item, { value: `__use__${typed}`, onSelect: () => choose(typed), children: _jsx(RowContent, { size: "compact", tone: "muted", leading: _jsx(Add, { className: "h-3.5 w-3.5 shrink-0" }), label: words({ key: "editor.use-value", values: { value: typed } }) }) }));
42
- return (_jsxs(Command.Root, { shouldFilter: false, loop: true, children: [_jsx(Command.Input, { placeholder: words({ key: "editor.search" }), className: "h-9 text-[13px]", value: query, onValueChange: setQuery }), _jsxs(Command.List, { className: "max-h-72 overscroll-contain scrollbar-overlay", children: [!useTyped && shown.length === 0 && (_jsx(Command.Empty, { className: "py-4 text-center text-xs text-(color:--vk-fg-subtle)", children: words({ key: "editor.nothing-matches" }) })), _jsx(Command.Group, { className: "p-0", children: _jsxs(List, { children: [shown.map((option) => (_jsx(Command.Item, { value: option.value, onSelect: () => choose(option.value), chosen: current === option.value, children: _jsx(RowContent, { size: option.slot || option.color ? undefined : "compact", leading: option.slot || option.color ? undefined : glyph(option.icon), label: badge(option), chosen: current === option.value, chosenTint: false }) }, option.value))), useRow] }) })] })] }));
60
+ return (_jsxs(Command.Root, { shouldFilter: false, loop: true, defaultValue: startOn, children: [_jsx(Command.Input, { ref: searchRef, placeholder: words({ key: "editor.search" }), className: "h-9 text-[13px]", value: query, onValueChange: setQuery }), _jsxs(Command.List, { className: "max-h-72 overscroll-contain scrollbar-overlay", children: [!useTyped && shown.length === 0 && (_jsx(Command.Empty, { className: "py-4 text-center text-xs text-(color:--vk-fg-subtle)", children: words({ key: "editor.nothing-matches" }) })), _jsx(Command.Group, { className: "p-0", children: _jsxs(List, { children: [shown.map((option) => (_jsx(Command.Item, { value: itemValue(option.value), onSelect: () => choose(option.value), chosen: current === option.value, children: _jsx(RowContent, { size: option.slot || option.color ? undefined : "compact", leading: option.slot || option.color ? undefined : glyph(option.icon), label: badge(option), chosen: current === option.value, chosenTint: false }) }, option.value))), useRow] }) })] })] }));
43
61
  }
44
- return (_jsx(List, { className: "max-h-72 overflow-y-auto overscroll-contain scrollbar-overlay", children: rows.map((option) => (_jsx(Row, { chosen: current === option.value, chosenTint: false, size: option.slot || option.color ? undefined : "compact", leading: option.slot || option.color ? undefined : glyph(option.icon), label: badge(option), onClick: () => choose(option.value) }, option.value))) }));
62
+ return (_jsx("div", { ref: listRef, className: "contents", onKeyDown: walkRows, children: _jsx(List, { className: "max-h-72 overflow-y-auto overscroll-contain scrollbar-overlay", children: rows.map((option) => (_jsx(Row, { chosen: current === option.value, chosenTint: false, size: option.slot || option.color ? undefined : "compact", leading: option.slot || option.color ? undefined : glyph(option.icon), label: badge(option), onClick: () => choose(option.value) }, option.value))) }) }));
45
63
  });
64
+ function listButtons(box) {
65
+ return box ? [...box.querySelectorAll("button:not(:disabled)")] : [];
66
+ }
67
+ function walkRows(event) {
68
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp")
69
+ return;
70
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
71
+ return;
72
+ const rows = listButtons(event.currentTarget);
73
+ const at = rows.indexOf(document.activeElement);
74
+ if (rows.length === 0 || at < 0)
75
+ return;
76
+ event.preventDefault();
77
+ const step = event.key === "ArrowDown" ? 1 : -1;
78
+ rows[(at + step + rows.length) % rows.length].focus();
79
+ }
80
+ function noneValue(options) {
81
+ let value = "__none__";
82
+ while (options.some((option) => option.value === value))
83
+ value = `_${value}`;
84
+ return value;
85
+ }
46
86
  export function pickerOptionsFromField(field, opts = {}) {
47
87
  const active = [...optionsOf(field)];
48
88
  const declared = new Set(active.map((o) => o.value));
49
89
  const archived = new Set(field.options.filter((o) => o.archived).map((o) => o.value));
50
- const extras = (opts.extraValues ?? []).filter((v) => !declared.has(v) && !archived.has(v));
90
+ const extras = [...new Set(opts.extraValues ?? [])].filter((v) => !declared.has(v) && !archived.has(v));
91
+ const current = opts.current;
92
+ if (current && !declared.has(current) && !extras.includes(current))
93
+ extras.push(current);
51
94
  const dress = (value, label) => {
52
95
  const option = field.options.find((o) => o.value === value);
53
96
  const dressed = field.type === "status"
@@ -55,5 +98,8 @@ export function pickerOptionsFromField(field, opts = {}) {
55
98
  : { value, label, color: resolveCategoryColor(value, active, opts.optionColors) };
56
99
  return option?.icon ? { ...dressed, icon: option.icon } : dressed;
57
100
  };
58
- return [...active.map((o) => dress(o.value, o.label)), ...extras.map((v) => dress(v, v))];
101
+ return [
102
+ ...active.map((o) => dress(o.value, o.label)),
103
+ ...extras.map((v) => dress(v, field.options.find((o) => o.value === v)?.label ?? v)),
104
+ ];
59
105
  }