@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,51 @@
1
+ import { type CSSProperties } from "react";
2
+ import { type CloseReason, type CloseResolution } from "@viewkitjs/fields";
3
+ /**
4
+ * THE TEXT EDITOR — one box for every text-like value: text, a link, an email, a phone, a domain,
5
+ * long text and rich text (VK-218). It owns what every surface used to write for itself and got
6
+ * different: what was typed is tidied (trimmed; rich text tidied only at its edges, so its first
7
+ * line keeps its indent), an unchanged value closes as no save, each type brings its own phone
8
+ * keyboard, and the keys mean the same everywhere: Escape throws the edit away, Enter closes a line
9
+ * (a paragraph takes it as a newline and closes on ⌘ or Ctrl Enter), Tab and Shift-Tab close with
10
+ * their reason, and leaving the box closes it unless the host says otherwise.
11
+ *
12
+ * Its host (a grid cell, a field row, a card) owns where it opens, the session, and the write: a
13
+ * host in a popover or a sheet passes `closeOnBlur={false}`, because there leaving the box to tap
14
+ * ✕ or ✓ is not a close. A line draws through the app's `Input`; a paragraph is the package's own
15
+ * textarea.
16
+ */
17
+ export type TextEditorType = "text" | "url" | "domain" | "email" | "phone" | "rich_text";
18
+ /** The native input type per text type: the phone keyboard it brings. */
19
+ export declare const TEXT_INPUT_TYPE: Readonly<Record<TextEditorType, "text" | "url" | "email" | "tel">>;
20
+ export type TextEditorHandle = {
21
+ resolveClose: (reason: CloseReason) => CloseResolution<string>;
22
+ };
23
+ export type TextEditorProps = {
24
+ type: TextEditorType;
25
+ /** The stored value ("" when unset): what the dirty check compares against. */
26
+ initial: string;
27
+ /** Type-to-replace: the draft opens on this instead, the caret after it. */
28
+ seed?: string;
29
+ /** A paragraph: a textarea, Enter a newline, ⌘ or Ctrl Enter closes with "enter". Default: rich text is one, the rest a line. */
30
+ multiline?: boolean;
31
+ /** A line shown whole: a textarea that wraps and grows like a paragraph, but Enter closes and a
32
+ * newline is a space. For a host that opens a cut-off line to be read in full. Default false. */
33
+ wraps?: boolean;
34
+ /** Shown, selectable, never written: every close resolves `noop`. */
35
+ readOnly?: boolean;
36
+ /** Whether leaving the box closes with "blur". Default true; a host inside a popover or a sheet passes false. */
37
+ closeOnBlur?: boolean;
38
+ label?: string;
39
+ /** Handed to the app's `Input`; a line only. Default "bare". */
40
+ chrome?: "bare" | "field";
41
+ /** A paragraph: the rows it opens at (default 1). It grows with its text to `maxLines` (default 12),
42
+ * then scrolls; `maxLines` no greater than `rows` keeps it at `rows`. */
43
+ rows?: number;
44
+ maxLines?: number;
45
+ className?: string;
46
+ style?: CSSProperties;
47
+ /** Set on the box, over `{ "data-slot": "vk-text-editor" }`, for the host's own selectors. */
48
+ boxData?: Readonly<Record<`data-${string}`, string>>;
49
+ onRequestClose: (reason: CloseReason) => void;
50
+ };
51
+ export declare const TextEditor: import("react").ForwardRefExoticComponent<TextEditorProps & import("react").RefAttributes<TextEditorHandle>>;
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef, useCallback, useImperativeHandle, useRef, } from "react";
4
+ import { normalizeMarkdown } from "@viewkitjs/fields";
5
+ import { useViews } from "../provider/context.js";
6
+ export const TEXT_INPUT_TYPE = {
7
+ text: "text",
8
+ url: "url",
9
+ domain: "url",
10
+ email: "email",
11
+ phone: "tel",
12
+ rich_text: "text",
13
+ };
14
+ export const TextEditor = forwardRef(function TextEditor({ type, initial, seed, multiline = type === "rich_text", wraps = false, readOnly = false, closeOnBlur = true, label, chrome = "bare", rows = 1, maxLines = 12, className, style, boxData, onRequestClose, }, ref) {
15
+ const { Input } = useViews().components;
16
+ const boxRef = useRef(null);
17
+ const area = multiline || wraps;
18
+ const grows = area && maxLines > rows;
19
+ const tidy = (text) => type === "rich_text"
20
+ ? normalizeMarkdown(text)
21
+ : (wraps && !multiline ? text.replace(/\s*\n\s*/g, " ") : text).trim();
22
+ const resolveClose = (reason) => {
23
+ if (readOnly)
24
+ return { kind: "noop" };
25
+ if (reason === "escape")
26
+ return { kind: "cancel" };
27
+ const next = tidy(boxRef.current?.value ?? seed ?? initial);
28
+ return next === tidy(initial) ? { kind: "noop" } : { kind: "commit", payload: next };
29
+ };
30
+ useImperativeHandle(ref, () => ({ resolveClose }));
31
+ const attach = useCallback((el) => {
32
+ boxRef.current = el;
33
+ if (!el)
34
+ return;
35
+ el.focus({ preventScroll: true });
36
+ try {
37
+ el.setSelectionRange(el.value.length, el.value.length);
38
+ }
39
+ catch {
40
+ }
41
+ if (grows)
42
+ grow(el, maxLines);
43
+ }, [grows, maxLines]);
44
+ const onKeyDown = (event) => {
45
+ event.stopPropagation();
46
+ if (event.nativeEvent.isComposing)
47
+ return;
48
+ if (event.key === "Escape") {
49
+ event.preventDefault();
50
+ onRequestClose("escape");
51
+ }
52
+ else if (event.key === "Enter" && (!multiline || event.metaKey || event.ctrlKey)) {
53
+ event.preventDefault();
54
+ onRequestClose("enter");
55
+ }
56
+ else if (event.key === "Tab") {
57
+ event.preventDefault();
58
+ onRequestClose(event.shiftKey ? "shift-tab" : "tab");
59
+ }
60
+ };
61
+ const shared = {
62
+ "data-slot": "vk-text-editor",
63
+ ...boxData,
64
+ "aria-label": label,
65
+ defaultValue: seed ?? initial,
66
+ readOnly,
67
+ onKeyDown,
68
+ onBlur: closeOnBlur ? () => onRequestClose("blur") : undefined,
69
+ onClick: (event) => event.stopPropagation(),
70
+ className,
71
+ style,
72
+ };
73
+ return area ? (_jsx("textarea", { ...shared, ref: attach, rows: rows, onInput: grows ? (event) => grow(event.currentTarget, maxLines) : undefined })) : (_jsx(Input, { ...shared, ref: attach, type: TEXT_INPUT_TYPE[type], chrome: chrome }));
74
+ });
75
+ function grow(el, maxLines) {
76
+ el.style.height = "auto";
77
+ const style = getComputedStyle(el);
78
+ const line = parseFloat(style.lineHeight) || 22;
79
+ const pad = (parseFloat(style.paddingTop) || 0) + (parseFloat(style.paddingBottom) || 0);
80
+ el.style.height = `${Math.min(el.scrollHeight, line * maxLines + pad)}px`;
81
+ }
@@ -15,8 +15,8 @@ import { type CloseReason, type CloseResolution, type FieldDefOf, type MultipleT
15
15
  * It is a draft, like the chips editor: the whole list commits ONCE when the
16
16
  * host closes it, the main one first. Escape discards; any other close keeps
17
17
  * what was built; closed untouched it writes nothing. A row left untouched
18
- * keeps its stored value as stored, so a phone kept as typed is not rewritten
19
- * by opening the editor. A row typed in commits its text, which the field's
18
+ * keeps its stored value as stored, so a value fields keeps by `stored` (a
19
+ * phone, a url) is not rewritten by opening the editor. A row typed in commits its text, which the field's
20
20
  * commit reads; a row whose reason still shows is refused there.
21
21
  */
22
22
  export type ValueListEditorHandle = {
@@ -34,5 +34,8 @@ export declare const ValueListEditor: import("react").ForwardRefExoticComponent<
34
34
  allowEmpty?: boolean;
35
35
  /** The record's country, where a phone typed without its country code is read; else the conventions' region. */
36
36
  region?: string | null;
37
+ /** Each stored value carries its open action beside it: mail, call or browse. A row typed over has none
38
+ * until it is saved. The grid asks for it in a phone's sheet, where a tap on the cell edits it. Default false. */
39
+ openLinks?: boolean;
37
40
  onRequestClose: (reason: CloseReason) => void;
38
41
  } & import("react").RefAttributes<ValueListEditorHandle>>;
@@ -4,19 +4,20 @@ import { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from "r
4
4
  import { acceptFieldCommit, phoneText, valueItems, valueKey, } from "@viewkitjs/fields";
5
5
  import { cx } from "../internal/cx.js";
6
6
  import { useViews } from "../provider/context.js";
7
+ import { OpenValueAction, isOpenableType } from "./open-value.js";
7
8
  function textOf(value) {
8
9
  if (typeof value === "string")
9
10
  return value;
10
11
  return phoneText(value, null) || String(value);
11
12
  }
12
- export const ValueListEditor = forwardRef(function ValueListEditor({ field, initial, labels = true, allowEmpty = false, region, onRequestClose }, ref) {
13
+ export const ValueListEditor = forwardRef(function ValueListEditor({ field, initial, labels = true, allowEmpty = false, region, openLinks = false, onRequestClose }, ref) {
13
14
  const views = useViews();
14
15
  const words = views.messages;
15
16
  const { Row } = views.atoms;
17
+ const { Input } = views.components;
16
18
  const Add = views.icons.add;
17
19
  const Remove = views.icons.close;
18
20
  const boxRef = useRef(null);
19
- const nextId = useRef(0);
20
21
  const [opened] = useState(() => {
21
22
  const items = valueItems(initial);
22
23
  const main = items.find((item) => item.main);
@@ -24,11 +25,12 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
24
25
  const first = one.find((item) => item.main);
25
26
  return first ? [first, ...one.filter((item) => item !== first)] : one;
26
27
  });
28
+ const nextId = useRef(Math.max(opened.length, 1));
27
29
  const [rows, setRows] = useState(() => opened.length === 0
28
- ? [{ id: nextId.current++, text: "", label: "", main: true }]
29
- : opened.map((item) => {
30
+ ? [{ id: 0, text: "", label: "", main: true }]
31
+ : opened.map((item, index) => {
30
32
  const text = textOf(item.value);
31
- return { id: nextId.current++, text, label: item.label ?? "", main: item.main, stored: { value: item.value, text } };
33
+ return { id: index, text, label: item.label ?? "", main: item.main, stored: { value: item.value, text } };
32
34
  }));
33
35
  const rowsRef = useRef(rows);
34
36
  const update = (next) => {
@@ -40,7 +42,7 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
40
42
  const addRef = useRef(null);
41
43
  useEffect(() => {
42
44
  const first = boxRef.current?.querySelector("input[data-value]");
43
- first?.focus();
45
+ first?.focus({ preventScroll: true });
44
46
  }, []);
45
47
  useEffect(() => {
46
48
  if (focusAdd.current)
@@ -194,7 +196,7 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
194
196
  if (!boxRef.current?.contains(to))
195
197
  onRequestClose("blur");
196
198
  };
197
- const input = "h-7 min-w-0 select-text rounded-md bg-transparent px-1.5 text-[length:var(--grid-text,0.8125rem)] text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtle) focus:bg-(color:--vk-hovered)";
199
+ const input = "h-7 min-w-0 select-text rounded-md bg-transparent px-1.5 text-[length:var(--vk-text,0.8125rem)] text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtle) focus:bg-(color:--vk-hovered)";
198
200
  const iconButton = "flex size-6 shrink-0 items-center justify-center rounded-md text-(color:--vk-fg-subtle) transition-colors hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg)";
199
201
  return (_jsxs("div", { ref: boxRef, onMouseDown: (e) => {
200
202
  if (!(e.target instanceof HTMLInputElement))
@@ -206,10 +208,10 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
206
208
  : words({ key: "views.editors.values-make-main", values: { value: shown } }), title: row.main ? words({ key: "views.editors.values-main" }) : undefined, onClick: (e) => {
207
209
  e.stopPropagation();
208
210
  makeMain(row.id);
209
- }, onKeyDown: buttonKeys(row.id, () => makeMain(row.id)), onKeyUp: noSpaceClick, onBlur: blur(row.id), className: iconButton, children: _jsx("span", { className: cx("size-2.5 rounded-full border border-(color:--vk-fg-subtle)", row.main && "border-(color:--vk-fg-brand) bg-(color:--vk-fg-brand)") }) }), _jsx("input", { "data-walk": true, "data-value": row.id, value: row.text, "aria-label": field.label, placeholder: field.label, "aria-invalid": row.error ? true : undefined, onChange: (e) => set(row.id, { text: e.target.value, error: undefined }), onKeyDown: keys(row.id), onBlur: blur(row.id), onClick: (e) => e.stopPropagation(), className: cx(input, "flex-1") }), labels && (_jsx("input", { "data-walk": true, value: row.label, "aria-label": words({ key: "views.editors.values-label" }), placeholder: words({ key: "views.editors.values-label" }), onChange: (e) => set(row.id, { label: e.target.value }), onKeyDown: keys(row.id), onBlur: blur(row.id), onClick: (e) => e.stopPropagation(), className: cx(input, "w-24") })), _jsx("button", { type: "button", "data-walk": true, "aria-label": words({ key: "views.editors.values-remove", values: { value: shown } }), onClick: (e) => {
211
+ }, onKeyDown: (e) => buttonKeys(row.id, () => makeMain(row.id))(e), onKeyUp: noSpaceClick, onBlur: (e) => blur(row.id)(e), className: iconButton, children: _jsx("span", { className: cx("size-2.5 rounded-full border border-(color:--vk-fg-subtle)", row.main && "border-(color:--vk-fg-brand) bg-(color:--vk-fg-brand)") }) }), _jsx(Input, { "data-walk": true, "data-value": row.id, value: row.text, "aria-label": field.label, placeholder: field.label, "aria-invalid": row.error ? true : undefined, onChange: (e) => set(row.id, { text: e.target.value, error: undefined }), onKeyDown: keys(row.id), onBlur: (e) => blur(row.id)(e), onClick: (e) => e.stopPropagation(), className: cx(input, "flex-1") }), labels && (_jsx(Input, { "data-walk": true, value: row.label, "aria-label": words({ key: "views.editors.values-label" }), placeholder: words({ key: "views.editors.values-label" }), onChange: (e) => set(row.id, { label: e.target.value }), onKeyDown: keys(row.id), onBlur: (e) => blur(row.id)(e), onClick: (e) => e.stopPropagation(), className: cx(input, "w-24") })), openLinks && untouched(row) && isOpenableType(field.type) && (_jsx(OpenValueAction, { type: field.type, value: row.stored.value, label: row.text })), _jsx("button", { type: "button", "data-walk": true, "aria-label": words({ key: "views.editors.values-remove", values: { value: shown } }), onClick: (e) => {
210
212
  e.stopPropagation();
211
213
  remove(row.id);
212
- }, onKeyDown: buttonKeys(row.id, () => remove(row.id)), onKeyUp: noSpaceClick, onBlur: blur(row.id), className: iconButton, children: _jsx(Remove, { className: "size-3.5" }) })] }), row.error && (_jsx("p", { role: "alert", className: "px-8 pb-1 text-xs text-(color:--vk-danger)", children: row.error }))] }, row.id));
214
+ }, onKeyDown: (e) => buttonKeys(row.id, () => remove(row.id))(e), onKeyUp: noSpaceClick, onBlur: (e) => blur(row.id)(e), className: iconButton, children: _jsx(Remove, { className: "size-3.5" }) })] }), row.error && (_jsx("p", { role: "alert", className: "px-8 pb-1 text-xs text-(color:--vk-danger)", children: row.error }))] }, row.id));
213
215
  }), _jsx("div", { ref: addRef, onKeyDown: addKeys, onBlur: (e) => {
214
216
  if (!boxRef.current?.contains(e.relatedTarget))
215
217
  onRequestClose("blur");
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ONE EDITOR PER STORAGE TYPE, and the table that picks between them — the EDIT
3
- * twin of `DISPLAY_CORES` (spec §3.4), the same idea for the other family.
3
+ * twin of `DISPLAY_CORES` (docs/guides/editors.md), the same idea for the other family.
4
4
  *
5
5
  * The dispatch is a mapped record over `FieldType` for one reason: a type added
6
6
  * to the union with no answer here fails to COMPILE. A host that imports the
@@ -8,9 +8,11 @@
8
8
  * compiles perfectly clean, and the first sign of it is a field that won't open
9
9
  * in front of someone.
10
10
  *
11
- * THE MEMBERS THAT ARE `null` are an answer rather than a gap. `text`,
12
- * `url`, `email` and `phone` have no panel, no draft and no parsing: a bare
13
- * input the host already owns is the whole editor. `boolean` commits straight
11
+ * `text`, `url`, `domain`, `email`, `phone` and `rich_text` are the TEXT core,
12
+ * `TextEditor`: one box, typed where the value stands, that every host mounts
13
+ * instead of writing its own (VK-218); rich text is typed as its markdown.
14
+ *
15
+ * THE MEMBERS THAT ARE `null` are an answer rather than a gap. `boolean` commits straight
14
16
  * from its display control — the checkbox IS the edit, so there is nothing to
15
17
  * mount, which is why `GRID_TYPE_RULES.boolean.editor` is `null` too.
16
18
  * `actor` is set by the system.
@@ -42,6 +44,7 @@ import { NumberEditor, type NumberEditorHandle } from "./NumberEditor.js";
42
44
  import { RangeEditor, type RangeEditorHandle } from "./RangeEditor.js";
43
45
  import { RelationEditor, type RelationEditorHandle } from "./RelationEditor.js";
44
46
  import { SelectEditor, type SelectEditorHandle } from "./SelectEditor.js";
47
+ import { TextEditor, type TextEditorHandle } from "./TextEditor.js";
45
48
  /** The props a `forwardRef` component declares — its ref attributes included,
46
49
  * which is how the handle below stays part of the comparison. */
47
50
  type PropsOf<C> = C extends ForwardRefExoticComponent<infer P> ? P : never;
@@ -68,14 +71,14 @@ export declare const EDIT_CORES: {
68
71
  range: Core<typeof RangeEditor, RangeEditorHandle>;
69
72
  name: Core<typeof NameEditor, NameEditorHandle>;
70
73
  location: Core<typeof LocationEditor, LocationEditorHandle>;
71
- text: null;
72
- url: null;
73
- domain: null;
74
- email: null;
75
- phone: null;
74
+ text: Core<typeof TextEditor, TextEditorHandle>;
75
+ url: Core<typeof TextEditor, TextEditorHandle>;
76
+ domain: Core<typeof TextEditor, TextEditorHandle>;
77
+ email: Core<typeof TextEditor, TextEditorHandle>;
78
+ phone: Core<typeof TextEditor, TextEditorHandle>;
76
79
  boolean: null;
77
80
  actor: null;
78
- rich_text: null;
81
+ rich_text: Core<typeof TextEditor, TextEditorHandle>;
79
82
  lookup: null;
80
83
  rollup: null;
81
84
  formula: null;
@@ -7,6 +7,7 @@ import { NumberEditor } from "./NumberEditor.js";
7
7
  import { RangeEditor } from "./RangeEditor.js";
8
8
  import { RelationEditor } from "./RelationEditor.js";
9
9
  import { SelectEditor } from "./SelectEditor.js";
10
+ import { TextEditor } from "./TextEditor.js";
10
11
  export const EDIT_CORES = {
11
12
  date: DateEditor,
12
13
  datetime: DateEditor,
@@ -20,15 +21,15 @@ export const EDIT_CORES = {
20
21
  currency: NumberEditor,
21
22
  range: RangeEditor,
22
23
  name: NameEditor,
23
- text: null,
24
- url: null,
25
- domain: null,
26
- email: null,
27
- phone: null,
24
+ text: TextEditor,
25
+ url: TextEditor,
26
+ domain: TextEditor,
27
+ email: TextEditor,
28
+ phone: TextEditor,
28
29
  boolean: null,
29
30
  location: LocationEditor,
30
31
  actor: null,
31
- rich_text: null,
32
+ rich_text: TextEditor,
32
33
  lookup: null,
33
34
  rollup: null,
34
35
  formula: null,
@@ -31,9 +31,11 @@ type ResolvableHandle<P> = {
31
31
  * callback cannot fire twice or land in a session that has already reopened.
32
32
  *
33
33
  * A host that admits the answer synchronously clears this UI-only timer on
34
- * unmount: the write already belongs to its coordinator. The legacy deferred
35
- * mode used by card hosts keeps the timer because their answer still carries
36
- * the write. New hosts should prefer synchronous admission.
34
+ * unmount: the write already belongs to its coordinator. The deferred mode
35
+ * keeps the timer because its answer still carries the write. It stays for
36
+ * compatibility, for an app that opens it, and in this package only the grid's
37
+ * name editor (`GridNameEditor`) still does. New hosts should prefer
38
+ * synchronous admission.
37
39
  */
38
40
  export declare const EDITOR_EXIT_MS = 160;
39
41
  /**
@@ -42,7 +44,7 @@ export declare const EDITOR_EXIT_MS = 160;
42
44
  *
43
45
  * `close(reason)` is the ONE door: Radix's dismiss, the core's own
44
46
  * `onRequestClose`, and a host's keyboard handler all land here, and only the
45
- * first counts. `mapPayload` is the host's one chance to reshape a commit
47
+ * first counts. `close("escape")` answers a cancel without asking the editor. `mapPayload` is the host's one chance to reshape a commit
46
48
  * before it leaves (a select's empty string becoming `null`, a day field's
47
49
  * timestamp trimmed to its date) — applied to a commit alone, never to a cancel
48
50
  * or a noop, which carry no payload to reshape.
@@ -58,17 +60,25 @@ type DeferredResolution<P> = AnchoredEditSessionBase<P> & {
58
60
  onAttempt?: never;
59
61
  onClose?: never;
60
62
  };
63
+ /** The host's answer to an attempt. A refusal may say why; the session hands the reason back as `refusal`. */
64
+ export type EditSessionAttempt = {
65
+ accepted: boolean;
66
+ reason?: string;
67
+ };
68
+ /** What a session hands its host, and what `EditorPanel` takes. */
69
+ export type EditSession = {
70
+ open: boolean;
71
+ close: (reason: CloseReason) => void;
72
+ /** The reason the host gave for the last refused attempt, until the next attempt; `null`
73
+ * otherwise, and always in the deferred mode. */
74
+ refusal: string | null;
75
+ };
61
76
  type AdmittedResolution<P> = AnchoredEditSessionBase<P> & {
62
77
  /** Ask synchronously whether this answer may close. Refusal is nonterminal. */
63
- onAttempt: (resolution: CloseResolution<unknown>) => {
64
- accepted: boolean;
65
- };
78
+ onAttempt: (resolution: CloseResolution<unknown>) => EditSessionAttempt;
66
79
  /** Finish only the visual close after the exit gap. */
67
80
  onClose: () => void;
68
81
  onDone?: never;
69
82
  };
70
- export declare function useAnchoredEditSession<P>(args: DeferredResolution<P> | AdmittedResolution<P>): {
71
- open: boolean;
72
- close: (reason: CloseReason) => void;
73
- };
83
+ export declare function useAnchoredEditSession<P>(args: DeferredResolution<P> | AdmittedResolution<P>): EditSession;
74
84
  export {};
@@ -4,6 +4,7 @@ export const EDITOR_EXIT_MS = 160;
4
4
  export function useAnchoredEditSession(args) {
5
5
  const { editorRef, mapPayload, exitMs = EDITOR_EXIT_MS } = args;
6
6
  const [open, setOpen] = useState(true);
7
+ const [refusal, setRefusal] = useState(null);
7
8
  const closedRef = useRef(false);
8
9
  const timerRef = useRef(null);
9
10
  const admitted = args.onAttempt !== undefined;
@@ -14,15 +15,28 @@ export function useAnchoredEditSession(args) {
14
15
  const close = (reason) => {
15
16
  if (closedRef.current)
16
17
  return;
17
- const resolution = editorRef.current?.resolveClose(reason) ?? { kind: "noop" };
18
+ const resolution = reason === "escape"
19
+ ? { kind: "cancel" }
20
+ : (editorRef.current?.resolveClose(reason) ?? { kind: "noop" });
18
21
  const answer = resolution.kind === "commit" && mapPayload
19
22
  ? { kind: "commit", payload: mapPayload(resolution.payload) }
20
23
  : resolution;
21
24
  if (args.onAttempt) {
22
- const attempt = args.onAttempt(answer);
23
- if (!attempt.accepted)
24
- return;
25
+ setRefusal(null);
25
26
  closedRef.current = true;
27
+ let attempt;
28
+ try {
29
+ attempt = args.onAttempt(answer);
30
+ }
31
+ catch (error) {
32
+ closedRef.current = false;
33
+ throw error;
34
+ }
35
+ if (!attempt.accepted) {
36
+ closedRef.current = false;
37
+ setRefusal(attempt.reason ?? null);
38
+ return;
39
+ }
26
40
  setOpen(false);
27
41
  timerRef.current = window.setTimeout(args.onClose, exitMs);
28
42
  return;
@@ -31,5 +45,5 @@ export function useAnchoredEditSession(args) {
31
45
  setOpen(false);
32
46
  timerRef.current = window.setTimeout(() => args.onDone(answer), exitMs);
33
47
  };
34
- return { open, close };
48
+ return { open, close, refusal };
35
49
  }
@@ -0,0 +1,12 @@
1
+ import { type RefObject } from "react";
2
+ /**
3
+ * KEEP A LINE UNDER A BOX INSIDE WHAT SHOWS IT — for what an in-place editor hangs under its value's box (the figure a
4
+ * converted amount shows, a refusal): placed from the box's left, on one line. Near the right edge of the window, or of
5
+ * the scroller the box sits in, it would run out of sight; there it is marked `data-side="end"`, and its class ends it
6
+ * at the box's right instead (`data-[side=end]:left-auto data-[side=end]:right-0`). Elsewhere it is `start`.
7
+ *
8
+ * Measured after every render, as a passive effect: the panel brings an in-place box into view as it opens (a layout
9
+ * effect of its own, which runs after this line's would), so the line is measured where the box ends up. An editor
10
+ * opens on a key or a press, whose passive effects run before the browser paints.
11
+ */
12
+ export declare function useKeepInside(ref: RefObject<HTMLElement | null>): void;
@@ -0,0 +1,20 @@
1
+ import { useEffect } from "react";
2
+ export function useKeepInside(ref) {
3
+ useEffect(() => {
4
+ const element = ref.current;
5
+ if (!element)
6
+ return;
7
+ element.dataset.side = "start";
8
+ if (element.getBoundingClientRect().right > visibleRight(element))
9
+ element.dataset.side = "end";
10
+ });
11
+ }
12
+ function visibleRight(element) {
13
+ let right = window.innerWidth;
14
+ for (let parent = element.parentElement; parent; parent = parent.parentElement) {
15
+ if (getComputedStyle(parent).overflowX !== "visible") {
16
+ right = Math.min(right, parent.getBoundingClientRect().right);
17
+ }
18
+ }
19
+ return right;
20
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * THE OPEN ACTION — what opens a stored email, phone, link or domain from inside its editor: a mail to the
4
+ * address, a call to the number, the site in the browser. A grid's cell draws its value as part of the cell, so a
5
+ * tap on it edits; where that edit opens in a phone's sheet, this action beside each value is how the person
6
+ * follows it. It opens what is stored, never a draft: a value typed over has none until it is saved.
7
+ */
8
+ /** The types a value of which opens somewhere. */
9
+ export type OpenableType = "email" | "phone" | "url" | "domain";
10
+ export declare function isOpenableType(type: string | undefined): type is OpenableType;
11
+ /** Where a stored value opens: `mailto:` an address, the `tel:` that dials a phone, the web address a link or a
12
+ * domain goes to; null for nothing, or for a link whose scheme would only make it dangerous. */
13
+ export declare function openValueHref(type: OpenableType, value: unknown): string | null;
14
+ /** The open action for one stored value, or nothing when it opens nowhere. `label` names the value to a reader. */
15
+ export declare function OpenValueAction({ type, value, label, compact, }: {
16
+ type: OpenableType;
17
+ value: unknown;
18
+ label: string;
19
+ /** Sized to a field row's line (28px, pulled back as the row's target is) rather than an editor's box. */
20
+ compact?: boolean;
21
+ }): ReactNode;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { phoneHref } from "@viewkitjs/fields";
4
+ import { webHref } from "../display/web-href.js";
5
+ import { cx } from "../internal/cx.js";
6
+ import { useViews } from "../provider/context.js";
7
+ const OPENABLE = new Set(["email", "phone", "url", "domain"]);
8
+ export function isOpenableType(type) {
9
+ return type !== undefined && OPENABLE.has(type);
10
+ }
11
+ export function openValueHref(type, value) {
12
+ if (value == null)
13
+ return null;
14
+ if (type === "phone")
15
+ return phoneHref(value);
16
+ const text = String(value).trim();
17
+ if (text === "")
18
+ return null;
19
+ if (type === "email")
20
+ return `mailto:${text}`;
21
+ return webHref(text);
22
+ }
23
+ export function OpenValueAction({ type, value, label, compact = false, }) {
24
+ const views = useViews();
25
+ const href = openValueHref(type, value);
26
+ if (href === null)
27
+ return null;
28
+ const Icon = type === "email" ? views.icons.email : type === "phone" ? views.icons.phone : views.icons.url;
29
+ const web = type === "url" || type === "domain";
30
+ const name = views.messages(type === "email"
31
+ ? { key: "views.editors.open-email", values: { value: label } }
32
+ : type === "phone"
33
+ ? { key: "views.editors.open-phone", values: { value: label } }
34
+ : { key: "views.editors.open-link", values: { value: label } });
35
+ return (_jsx("a", { href: href, ...(web ? { target: "_blank", rel: "noopener noreferrer" } : {}), "aria-label": name, title: name, "data-no-nav": true, onClick: (event) => event.stopPropagation(), className: cx("flex shrink-0 items-center justify-center rounded-md text-(color:--vk-fg-subtle) transition-colors hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg)", compact ? "-my-1 size-7" : "size-8"), children: _jsx(Icon, { className: "size-4" }) }));
36
+ }
@@ -26,3 +26,7 @@ export declare function useOpenValues(field: FieldDef | undefined): readonly str
26
26
  /** What an editor offers, each value once: the declared options, then the values the list answered, then those seen
27
27
  * on screen. */
28
28
  export declare function offeredValues(field: FieldDef, known: readonly string[], seen?: readonly string[]): string[];
29
+ /** Whether an editor of this field takes a value typed in that no option names (a Use row, an Add row): an open
30
+ * select (`vocabulary: "custom-values"`), and a multiselect that is not closed. The same line the field's rule
31
+ * draws, so an editor never offers a value its write would refuse. A closed list only filters. */
32
+ export declare function takesNewValues(field: FieldDef): boolean;
@@ -24,3 +24,10 @@ export function offeredValues(field, known, seen = []) {
24
24
  const declared = "options" in field ? optionValues(field) : [];
25
25
  return [...new Set([...declared, ...known, ...seen])];
26
26
  }
27
+ export function takesNewValues(field) {
28
+ if (field.type === "select")
29
+ return field.vocabulary === "custom-values";
30
+ if (field.type === "multiselect")
31
+ return field.vocabulary !== "closed";
32
+ return false;
33
+ }
@@ -0,0 +1,7 @@
1
+ import type { RelationSource } from "../fields/relation-source-types.js";
2
+ /**
3
+ * The candidates, remembering the kind of each one a remote search returned, so a pick of one id still knows what
4
+ * it points at; a static list is asked directly. A relation of several kinds stores its pick as a ref, and the ref
5
+ * needs the kind the picked record has.
6
+ */
7
+ export declare function useKnownKinds(candidates: RelationSource): [RelationSource, (id: string) => string | undefined];
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { useMemo, useRef } from "react";
3
+ export function useKnownKinds(candidates) {
4
+ const seen = useRef(new Map());
5
+ const source = useMemo(() => candidates.kind === "static"
6
+ ? candidates
7
+ : {
8
+ ...candidates,
9
+ search: async (query, signal, offset) => {
10
+ const items = await candidates.search(query, signal, offset);
11
+ for (const item of items)
12
+ if (item.kind !== undefined)
13
+ seen.current.set(item.id, item.kind);
14
+ return items;
15
+ },
16
+ }, [candidates]);
17
+ const kindOf = (id) => candidates.kind === "static"
18
+ ? candidates.items.find((item) => item.id === id)?.kind
19
+ : seen.current.get(id);
20
+ return [source, kindOf];
21
+ }
@@ -0,0 +1,69 @@
1
+ import type { KeyboardEvent as ReactKeyboardEvent, ReactNode, Ref } from "react";
2
+ import type { FieldMessageResolver } from "@viewkitjs/fields";
3
+ import { type RelationCandidate, type RelationSource } from "./relation-source.js";
4
+ /**
5
+ * A pinned row under the list for "it isn't in the list yet": the host opens
6
+ * its own create form with what was typed already filled. Pinned rather than
7
+ * appended to the results, because an affordance that only appears below a
8
+ * scrolled list is one nobody finds — and a button rather than a command item,
9
+ * because the filter would hide an item with no label to match while a query
10
+ * is typed, which is exactly when the row is wanted. A click asks the host to
11
+ * close (the core says what that close means), then `onCreate` runs.
12
+ */
13
+ export type RelationCreate = {
14
+ /** The row's words; receives the trimmed query. */
15
+ label: (query: string) => string;
16
+ /** Runs AFTER the host has been asked to close, with the trimmed query. */
17
+ onCreate: (query: string) => void;
18
+ };
19
+ /** The glyph lane every row of one panel shares, so each label starts at the same x. */
20
+ export type RelationLane = {
21
+ /** Draw the lane: the host named the kind's glyph, or a candidate carries its own. */
22
+ glyphs: boolean;
23
+ /** A glyph sized to the lane, or nothing. */
24
+ glyph: (node?: ReactNode) => ReactNode;
25
+ };
26
+ /**
27
+ * THE list a relation picker shows — one panel under the pick-one core and the
28
+ * several-records core. It holds the search box, what the remote branch is
29
+ * doing (a first page loading or failed, an empty answer, the next page), the
30
+ * candidates with their glyph lane, paging at the end of the list, and the
31
+ * pinned create rows. What a click MEANS is the core's: this panel only says
32
+ * which candidate was chosen, and draws, above the candidates, whatever rows
33
+ * the core puts there (the None row, the linked records).
34
+ *
35
+ * The candidates are the HOST's, through a discriminated source: a STATIC list
36
+ * (every subscription you could link to, preloaded — the grid's shape, and any
37
+ * small set's) or a REMOTE search over thousands of rows (a client, a person,
38
+ * a deal). The panel owns the remote branch's choreography — when to ask, what
39
+ * to drop, what to show meanwhile — and never the asking itself: the search
40
+ * function is the host's, which is what keeps workspace tenancy in the host's
41
+ * closure and in the routes.
42
+ */
43
+ export declare function RelationPanel({ candidates, query, onQueryChange, searchRef, onSearchKeyDown, before, drawsBefore, labels, hide, isChosen, onSelect, kindGlyph, message, creates, onCreate, startOn, }: {
44
+ candidates: RelationSource;
45
+ /** The typed query, controlled by the core: the remote search reads it, the create rows name it. */
46
+ query: string;
47
+ onQueryChange: (query: string) => void;
48
+ searchRef?: Ref<HTMLInputElement>;
49
+ onSearchKeyDown?: (event: ReactKeyboardEvent<HTMLInputElement>) => void;
50
+ /** Rows drawn above the candidates, in the same list and lane. */
51
+ before?: (lane: RelationLane) => ReactNode;
52
+ /** The rows drawn above are on screen: a remote search that found nothing doesn't say "nothing matches" over them. */
53
+ drawsBefore?: boolean;
54
+ /** Labels for the rows drawn above, so a static search matches them as it matches a candidate. */
55
+ labels?: ReadonlyMap<string, string>;
56
+ /** A candidate already drawn above: left out of the candidates. */
57
+ hide?: (id: string) => boolean;
58
+ isChosen: (id: string) => boolean;
59
+ onSelect: (candidate: RelationCandidate) => void;
60
+ /** The kind's glyph, from the host. Worn by every candidate that brought no icon of its own; given, the glyph
61
+ * lane is always drawn. */
62
+ kindGlyph?: ReactNode;
63
+ message?: FieldMessageResolver;
64
+ creates?: RelationCreate[];
65
+ /** A create row was clicked, with the trimmed query. */
66
+ onCreate: (create: RelationCreate, query: string) => void;
67
+ /** The row highlighted as the list opens, by its value (a candidate's id); without it, the first row. */
68
+ startOn?: string;
69
+ }): import("react/jsx-runtime").JSX.Element;