@viewkitjs/views 0.4.0 → 0.6.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 (447) hide show
  1. package/CHANGELOG.md +768 -0
  2. package/README.md +5 -3
  3. package/dist/atoms/Avatar.d.ts +2 -0
  4. package/dist/atoms/Avatar.js +13 -0
  5. package/dist/atoms/CellMore.d.ts +2 -0
  6. package/dist/atoms/CellMore.js +4 -0
  7. package/dist/atoms/DisabledReason.d.ts +11 -0
  8. package/dist/atoms/DisabledReason.js +10 -0
  9. package/dist/atoms/DrillRows.d.ts +3 -0
  10. package/dist/atoms/DrillRows.js +27 -0
  11. package/dist/atoms/Loading.d.ts +6 -0
  12. package/dist/atoms/Loading.js +4 -1
  13. package/dist/atoms/PanelRows.d.ts +5 -0
  14. package/dist/atoms/PanelRows.js +38 -0
  15. package/dist/atoms/PanelSearch.d.ts +2 -0
  16. package/dist/atoms/PanelSearch.js +21 -0
  17. package/dist/atoms/Pill.d.ts +2 -0
  18. package/dist/atoms/Pill.js +25 -0
  19. package/dist/atoms/RangeCalendar.d.ts +8 -0
  20. package/dist/atoms/RangeCalendar.js +30 -0
  21. package/dist/atoms/RelationRoles.js +2 -2
  22. package/dist/atoms/SelectionSheet.d.ts +3 -0
  23. package/dist/atoms/SelectionSheet.js +31 -0
  24. package/dist/atoms/ToolbarButton.d.ts +2 -0
  25. package/dist/atoms/ToolbarButton.js +18 -0
  26. package/dist/atoms/defaults.js +22 -0
  27. package/dist/atoms/types.d.ts +257 -1
  28. package/dist/cells/cell-format.d.ts +10 -1
  29. package/dist/cells/cell-title.d.ts +5 -1
  30. package/dist/cells/cell-title.js +2 -2
  31. package/dist/cells/cell-values.js +22 -7
  32. package/dist/cells/relation-wrap.js +1 -1
  33. package/dist/contract.d.ts +515 -18
  34. package/dist/contract.js +660 -5
  35. package/dist/display/actor.js +1 -1
  36. package/dist/display/boolean.js +5 -0
  37. package/dist/display/entity-chip.d.ts +12 -9
  38. package/dist/display/entity-chip.js +4 -5
  39. package/dist/display/fit-values.d.ts +34 -0
  40. package/dist/display/fit-values.js +45 -0
  41. package/dist/display/location.js +1 -1
  42. package/dist/display/multi-value.js +72 -8
  43. package/dist/display/options.d.ts +9 -1
  44. package/dist/display/relation.js +1 -1
  45. package/dist/display/rich-text.js +17 -6
  46. package/dist/display/select.js +6 -4
  47. package/dist/display/status-steps.d.ts +8 -0
  48. package/dist/display/status-steps.js +18 -0
  49. package/dist/display/viewer.js +1 -0
  50. package/dist/editors/BodyFrame.d.ts +29 -0
  51. package/dist/editors/BodyFrame.js +80 -0
  52. package/dist/editors/DateEditor.js +13 -17
  53. package/dist/editors/LocationEditor.d.ts +2 -0
  54. package/dist/editors/LocationEditor.js +29 -5
  55. package/dist/editors/NameEditor.d.ts +2 -0
  56. package/dist/editors/NameEditor.js +27 -7
  57. package/dist/editors/NumberEditor.d.ts +18 -0
  58. package/dist/editors/NumberEditor.js +29 -2
  59. package/dist/editors/RangeEditor.d.ts +2 -0
  60. package/dist/editors/RangeEditor.js +29 -4
  61. package/dist/editors/SelectEditor.d.ts +5 -0
  62. package/dist/editors/SelectEditor.js +3 -2
  63. package/dist/editors/TextEditor.d.ts +11 -1
  64. package/dist/editors/TextEditor.js +25 -8
  65. package/dist/editors/ValueListEditor.d.ts +7 -0
  66. package/dist/editors/ValueListEditor.js +60 -48
  67. package/dist/editors/body-panel.d.ts +7 -0
  68. package/dist/editors/body-panel.js +8 -0
  69. package/dist/editors/edit-session.d.ts +20 -3
  70. package/dist/editors/edit-session.js +43 -3
  71. package/dist/editors/leave-scope.d.ts +23 -0
  72. package/dist/editors/leave-scope.js +28 -0
  73. package/dist/editors/number-body.d.ts +29 -0
  74. package/dist/editors/number-body.js +37 -0
  75. package/dist/editors/parts-body.d.ts +66 -0
  76. package/dist/editors/parts-body.js +114 -0
  77. package/dist/editors/tab-ends.d.ts +5 -0
  78. package/dist/editors/tab-ends.js +7 -0
  79. package/dist/editors/text-body.d.ts +16 -0
  80. package/dist/editors/text-body.js +30 -0
  81. package/dist/editors/values-body.d.ts +47 -0
  82. package/dist/editors/values-body.js +140 -0
  83. package/dist/field-row/FieldRow.d.ts +7 -0
  84. package/dist/field-row/FieldRow.js +44 -24
  85. package/dist/field-row/FieldRowLane.js +12 -4
  86. package/dist/field-row/editors/RowChipsEditor.js +3 -1
  87. package/dist/field-row/editors/RowEditor.js +2 -1
  88. package/dist/field-row/editors/RowNameEditor.d.ts +5 -2
  89. package/dist/field-row/editors/RowNameEditor.js +12 -5
  90. package/dist/field-row/editors/RowNumberEditor.js +18 -2
  91. package/dist/field-row/editors/RowPlaceEditor.js +4 -2
  92. package/dist/field-row/editors/RowRangeEditor.d.ts +5 -2
  93. package/dist/field-row/editors/RowRangeEditor.js +13 -6
  94. package/dist/field-row/editors/RowRelationEditor.js +5 -2
  95. package/dist/field-row/editors/RowSelectEditor.js +4 -1
  96. package/dist/field-row/editors/RowTextEditor.d.ts +1 -1
  97. package/dist/field-row/editors/RowTextEditor.js +12 -3
  98. package/dist/field-row/editors/RowValueListEditor.d.ts +2 -1
  99. package/dist/field-row/editors/RowValueListEditor.js +17 -4
  100. package/dist/field-row/editors/host.d.ts +3 -0
  101. package/dist/field-row/editors/row-session.d.ts +12 -1
  102. package/dist/field-row/editors/row-session.js +52 -2
  103. package/dist/field-row/field-row-button.d.ts +40 -0
  104. package/dist/field-row/field-row-button.js +18 -0
  105. package/dist/field-row/field-row-checkbox.d.ts +9 -0
  106. package/dist/field-row/field-row-checkbox.js +7 -0
  107. package/dist/figures.d.ts +5 -48
  108. package/dist/figures.js +1 -63
  109. package/dist/filters/filter-model.d.ts +2 -0
  110. package/dist/grid/chrome/GridAddColumn.js +17 -3
  111. package/dist/grid/chrome/GridAggregateMenu.d.ts +2 -0
  112. package/dist/grid/chrome/GridAggregateMenu.js +2 -0
  113. package/dist/grid/chrome/GridCellEditors.js +16 -6
  114. package/dist/grid/chrome/GridCellOutline.d.ts +7 -4
  115. package/dist/grid/chrome/GridCellOutline.js +4 -2
  116. package/dist/grid/chrome/GridChipsEditor.js +3 -1
  117. package/dist/grid/chrome/GridColumnMenu.d.ts +7 -4
  118. package/dist/grid/chrome/GridColumnMenu.js +5 -3
  119. package/dist/grid/chrome/GridColumnSortSection.d.ts +23 -3
  120. package/dist/grid/chrome/GridColumnSortSection.js +18 -1
  121. package/dist/grid/chrome/GridFooter.d.ts +4 -1
  122. package/dist/grid/chrome/GridFooter.js +6 -4
  123. package/dist/grid/chrome/GridGroupMenu.d.ts +7 -3
  124. package/dist/grid/chrome/GridGroupMenu.js +30 -8
  125. package/dist/grid/chrome/GridHeader.d.ts +5 -1
  126. package/dist/grid/chrome/GridHeader.js +9 -5
  127. package/dist/grid/chrome/GridLongTextEditor.js +15 -11
  128. package/dist/grid/chrome/GridNameEditor.js +4 -2
  129. package/dist/grid/chrome/GridNumberEditor.d.ts +8 -1
  130. package/dist/grid/chrome/GridNumberEditor.js +15 -3
  131. package/dist/grid/chrome/GridPager.d.ts +7 -0
  132. package/dist/grid/chrome/GridPager.js +34 -0
  133. package/dist/grid/chrome/GridPlaceEditor.js +4 -2
  134. package/dist/grid/chrome/GridRangeEditor.js +12 -4
  135. package/dist/grid/chrome/GridRelationEditor.js +5 -2
  136. package/dist/grid/chrome/GridRow.js +18 -6
  137. package/dist/grid/chrome/GridRowActions.d.ts +8 -3
  138. package/dist/grid/chrome/GridRowActions.js +16 -6
  139. package/dist/grid/chrome/GridRowCells.js +23 -7
  140. package/dist/grid/chrome/GridRowGlyph.d.ts +3 -1
  141. package/dist/grid/chrome/GridRowGlyph.js +7 -2
  142. package/dist/grid/chrome/GridSelectEditor.js +6 -3
  143. package/dist/grid/chrome/GridStructure.d.ts +6 -1
  144. package/dist/grid/chrome/GridStructure.js +32 -8
  145. package/dist/grid/chrome/GridTable.js +36 -24
  146. package/dist/grid/chrome/GridTableSurface.d.ts +5 -1
  147. package/dist/grid/chrome/GridTableSurface.js +5 -2
  148. package/dist/grid/chrome/GridTextEditor.d.ts +5 -1
  149. package/dist/grid/chrome/GridTextEditor.js +13 -3
  150. package/dist/grid/chrome/GridValueListEditor.d.ts +12 -4
  151. package/dist/grid/chrome/GridValueListEditor.js +11 -3
  152. package/dist/grid/chrome/StuckMarker.d.ts +3 -1
  153. package/dist/grid/chrome/StuckMarker.js +6 -2
  154. package/dist/grid/chrome/cells.d.ts +4 -2
  155. package/dist/grid/chrome/cells.js +2 -2
  156. package/dist/grid/chrome/grid-add-column-items.d.ts +1 -1
  157. package/dist/grid/chrome/grid-add-column-items.js +8 -1
  158. package/dist/grid/chrome/grid-button.d.ts +32 -0
  159. package/dist/grid/chrome/grid-button.js +12 -0
  160. package/dist/grid/chrome/grid-cell-classes.d.ts +38 -0
  161. package/dist/grid/chrome/grid-cell-classes.js +30 -0
  162. package/dist/grid/chrome/grid-column-menu-items.d.ts +3 -0
  163. package/dist/grid/chrome/grid-column-menu-items.js +32 -3
  164. package/dist/grid/chrome/grid-columns-template.d.ts +27 -0
  165. package/dist/grid/chrome/grid-columns-template.js +13 -0
  166. package/dist/grid/chrome/grid-edit-session.d.ts +4 -1
  167. package/dist/grid/chrome/grid-edit-session.js +11 -1
  168. package/dist/grid/chrome/grid-group-menu-items.d.ts +8 -1
  169. package/dist/grid/chrome/grid-group-menu-items.js +17 -0
  170. package/dist/grid/chrome/grid-group-menu-parts.d.ts +10 -6
  171. package/dist/grid/chrome/grid-group-menu-parts.js +4 -2
  172. package/dist/grid/chrome/grid-hover.d.ts +4 -1
  173. package/dist/grid/chrome/grid-hover.js +16 -6
  174. package/dist/grid/chrome/grid-pages.d.ts +15 -0
  175. package/dist/grid/chrome/grid-pages.js +9 -0
  176. package/dist/grid/chrome/grid-row-menu-items.js +18 -10
  177. package/dist/grid/chrome/grid-row-props.d.ts +6 -2
  178. package/dist/grid/chrome/grid-row-window.d.ts +7 -0
  179. package/dist/grid/chrome/grid-row-window.js +35 -1
  180. package/dist/grid/chrome/grid-table-props.d.ts +38 -4
  181. package/dist/grid/chrome/useGridColumnLayout.d.ts +3 -1
  182. package/dist/grid/chrome/useGridColumnLayout.js +29 -9
  183. package/dist/grid/chrome/useGridPartColumns.js +1 -1
  184. package/dist/grid/chrome/useGridScrollArea.js +2 -0
  185. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -0
  186. package/dist/grid/chrome/useGridTableInteractionModel.js +5 -3
  187. package/dist/grid/chrome/useGridTableSelection.d.ts +3 -1
  188. package/dist/grid/chrome/useGridTableSelection.js +2 -2
  189. package/dist/grid/chrome/useHeaderDragReorder.js +2 -0
  190. package/dist/grid/core/editing-controller.d.ts +36 -11
  191. package/dist/grid/core/editing-controller.js +92 -25
  192. package/dist/grid/core/grid-aria.d.ts +4 -0
  193. package/dist/grid/core/grid-aria.js +6 -4
  194. package/dist/grid/core/grid-focus.d.ts +6 -0
  195. package/dist/grid/core/grid-focus.js +28 -5
  196. package/dist/grid/core/useGridEditing.d.ts +11 -2
  197. package/dist/grid/core/useGridEditing.js +9 -5
  198. package/dist/grid/core/write-states.d.ts +20 -0
  199. package/dist/grid/core/write-states.js +21 -0
  200. package/dist/grid/grid-format-props.d.ts +26 -0
  201. package/dist/grid/grid-format-props.js +65 -0
  202. package/dist/grid/index.d.ts +3 -1
  203. package/dist/grid/index.js +1 -0
  204. package/dist/grid/useGridTablePrefs.d.ts +20 -21
  205. package/dist/grid/useGridTablePrefs.js +6 -58
  206. package/dist/grid/useGridTableSettings.d.ts +60 -0
  207. package/dist/grid/useGridTableSettings.js +61 -0
  208. package/dist/grouping/sort-groups.d.ts +6 -7
  209. package/dist/internal/count.d.ts +3 -0
  210. package/dist/internal/count.js +3 -0
  211. package/dist/model/aggregates.d.ts +3 -3
  212. package/dist/model/aggregates.js +17 -71
  213. package/dist/model/body-frame.d.ts +16 -0
  214. package/dist/model/body-frame.js +5 -0
  215. package/dist/model/column-capabilities.d.ts +4 -1
  216. package/dist/model/column-capabilities.js +4 -1
  217. package/dist/model/column-filters.d.ts +7 -4
  218. package/dist/model/column-filters.js +26 -18
  219. package/dist/model/column-inspect.d.ts +3 -2
  220. package/dist/model/column-inspect.js +3 -1
  221. package/dist/model/column-order.d.ts +2 -2
  222. package/dist/model/column-schema.d.ts +6 -7
  223. package/dist/model/column-sort.d.ts +11 -0
  224. package/dist/model/column-sort.js +14 -0
  225. package/dist/model/column-state.d.ts +3 -20
  226. package/dist/model/column-state.js +1 -4
  227. package/dist/model/column-types.d.ts +1 -15
  228. package/dist/model/column-types.js +1 -1
  229. package/dist/model/one-value.d.ts +6 -0
  230. package/dist/model/one-value.js +5 -0
  231. package/dist/model/part-columns.d.ts +1 -6
  232. package/dist/model/part-columns.js +1 -1
  233. package/dist/model/part-rows.d.ts +2 -9
  234. package/dist/model/part-rows.js +1 -10
  235. package/dist/model/part-write.js +1 -1
  236. package/dist/model/place-parts.d.ts +6 -0
  237. package/dist/model/place-parts.js +14 -0
  238. package/dist/model/preferences.d.ts +3 -23
  239. package/dist/model/preferences.js +1 -17
  240. package/dist/model/prefs-buckets.d.ts +0 -27
  241. package/dist/model/prefs-buckets.js +1 -1
  242. package/dist/model/relation-filters.d.ts +13 -3
  243. package/dist/model/relation-filters.js +9 -4
  244. package/dist/model/row-icon.d.ts +17 -11
  245. package/dist/model/settings-columns.d.ts +34 -0
  246. package/dist/model/settings-columns.js +146 -0
  247. package/dist/model/settings-look.d.ts +17 -0
  248. package/dist/model/settings-look.js +23 -0
  249. package/dist/model/view-rules.d.ts +32 -6
  250. package/dist/model/view-rules.js +99 -23
  251. package/dist/panels/availability.d.ts +26 -0
  252. package/dist/panels/availability.js +28 -0
  253. package/dist/panels/filter/DateFilterBody.d.ts +42 -0
  254. package/dist/panels/filter/DateFilterBody.js +64 -0
  255. package/dist/panels/filter/DateFilterCalendar.d.ts +19 -0
  256. package/dist/panels/filter/DateFilterCalendar.js +37 -0
  257. package/dist/panels/filter/DateFilterInput.d.ts +16 -0
  258. package/dist/panels/filter/DateFilterInput.js +37 -0
  259. package/dist/panels/filter/FilterIcon.d.ts +7 -0
  260. package/dist/panels/filter/FilterIcon.js +15 -0
  261. package/dist/panels/filter/MenuSelect.d.ts +12 -0
  262. package/dist/panels/filter/MenuSelect.js +34 -0
  263. package/dist/panels/filter/NumberFilterBody.d.ts +21 -0
  264. package/dist/panels/filter/NumberFilterBody.js +76 -0
  265. package/dist/panels/filter/RangeFilterBody.d.ts +19 -0
  266. package/dist/panels/filter/RangeFilterBody.js +71 -0
  267. package/dist/panels/filter/RelationFilterBody.d.ts +17 -0
  268. package/dist/panels/filter/RelationFilterBody.js +20 -0
  269. package/dist/panels/filter/TextFilterBody.d.ts +31 -0
  270. package/dist/panels/filter/TextFilterBody.js +44 -0
  271. package/dist/panels/filter/TimeScopeDetail.d.ts +6 -0
  272. package/dist/panels/filter/TimeScopeDetail.js +47 -0
  273. package/dist/panels/filter/details.d.ts +17 -0
  274. package/dist/panels/filter/details.js +73 -0
  275. package/dist/panels/filter/filter-list.d.ts +23 -0
  276. package/dist/panels/filter/filter-list.js +38 -0
  277. package/dist/panels/group-sort.d.ts +24 -0
  278. package/dist/panels/group-sort.js +58 -0
  279. package/dist/panels/index.d.ts +24 -0
  280. package/dist/panels/index.js +17 -0
  281. package/dist/panels/labels.d.ts +37 -0
  282. package/dist/panels/labels.js +166 -0
  283. package/dist/panels/model.d.ts +343 -0
  284. package/dist/panels/model.js +77 -0
  285. package/dist/panels/react/GroupBucketsList.d.ts +16 -0
  286. package/dist/panels/react/GroupBucketsList.js +38 -0
  287. package/dist/panels/react/LayoutColumnsList.d.ts +24 -0
  288. package/dist/panels/react/LayoutColumnsList.js +71 -0
  289. package/dist/panels/react/PopoverColumnDetail.d.ts +11 -0
  290. package/dist/panels/react/PopoverColumnDetail.js +24 -0
  291. package/dist/panels/react/chrome.d.ts +17 -0
  292. package/dist/panels/react/chrome.js +8 -0
  293. package/dist/panels/react/column-refusals.d.ts +7 -0
  294. package/dist/panels/react/column-refusals.js +14 -0
  295. package/dist/panels/react/customize.d.ts +26 -0
  296. package/dist/panels/react/customize.js +98 -0
  297. package/dist/panels/react/drag.d.ts +2 -0
  298. package/dist/panels/react/drag.js +6 -0
  299. package/dist/panels/react/field-editor.d.ts +10 -0
  300. package/dist/panels/react/field-editor.js +1 -0
  301. package/dist/panels/react/filter-panel.d.ts +15 -0
  302. package/dist/panels/react/filter-panel.js +48 -0
  303. package/dist/panels/react/layout-detail.d.ts +4 -0
  304. package/dist/panels/react/layout-detail.js +21 -0
  305. package/dist/panels/react/order-details.d.ts +32 -0
  306. package/dist/panels/react/order-details.js +81 -0
  307. package/dist/panels/react/panel-header.d.ts +10 -0
  308. package/dist/panels/react/panel-header.js +12 -0
  309. package/dist/panels/react/panel-sheet.d.ts +19 -0
  310. package/dist/panels/react/panel-sheet.js +22 -0
  311. package/dist/panels/react/popover.d.ts +71 -0
  312. package/dist/panels/react/popover.js +47 -0
  313. package/dist/panels/react/root-list.d.ts +6 -0
  314. package/dist/panels/react/root-list.js +31 -0
  315. package/dist/panels/react/toolbar/ReadyToolbar.d.ts +42 -0
  316. package/dist/panels/react/toolbar/ReadyToolbar.js +92 -0
  317. package/dist/panels/react/toolbar/Toolbar.d.ts +16 -0
  318. package/dist/panels/react/toolbar/Toolbar.js +34 -0
  319. package/dist/panels/react/toolbar/ToolbarButton.d.ts +5 -0
  320. package/dist/panels/react/toolbar/ToolbarButton.js +9 -0
  321. package/dist/panels/react/toolbar/ToolbarFilter.d.ts +19 -0
  322. package/dist/panels/react/toolbar/ToolbarFilter.js +32 -0
  323. package/dist/panels/react/toolbar/ToolbarNew.d.ts +12 -0
  324. package/dist/panels/react/toolbar/ToolbarNew.js +21 -0
  325. package/dist/panels/react/toolbar/ToolbarOptions.d.ts +25 -0
  326. package/dist/panels/react/toolbar/ToolbarOptions.js +33 -0
  327. package/dist/panels/react/toolbar/ToolbarSearch.d.ts +9 -0
  328. package/dist/panels/react/toolbar/ToolbarSearch.js +41 -0
  329. package/dist/panels/react/toolbar/ToolbarSort.d.ts +12 -0
  330. package/dist/panels/react/toolbar/ToolbarSort.js +16 -0
  331. package/dist/panels/react/toolbar/ToolbarViews.d.ts +13 -0
  332. package/dist/panels/react/toolbar/ToolbarViews.js +24 -0
  333. package/dist/panels/react/toolbar/context.d.ts +29 -0
  334. package/dist/panels/react/toolbar/context.js +49 -0
  335. package/dist/panels/react/toolbar/panel-part.d.ts +37 -0
  336. package/dist/panels/react/toolbar/panel-part.js +37 -0
  337. package/dist/panels/react/toolbar/panel-state.d.ts +9 -0
  338. package/dist/panels/react/toolbar/panel-state.js +12 -0
  339. package/dist/panels/react/toolbar/use-box-narrow.d.ts +2 -0
  340. package/dist/panels/react/toolbar/use-box-narrow.js +18 -0
  341. package/dist/panels/react/toolbar/use-list-settings-state.d.ts +10 -0
  342. package/dist/panels/react/toolbar/use-list-settings-state.js +10 -0
  343. package/dist/panels/react/view-actions.d.ts +4 -0
  344. package/dist/panels/react/view-actions.js +37 -0
  345. package/dist/panels/react/view-footer.d.ts +16 -0
  346. package/dist/panels/react/view-footer.js +11 -0
  347. package/dist/panels/react/views-row/FoldingViewRow.d.ts +4 -0
  348. package/dist/panels/react/views-row/FoldingViewRow.js +105 -0
  349. package/dist/panels/react/views-row/HScrollRow.d.ts +7 -0
  350. package/dist/panels/react/views-row/HScrollRow.js +42 -0
  351. package/dist/panels/react/views-row/PillGroup.d.ts +30 -0
  352. package/dist/panels/react/views-row/PillGroup.js +86 -0
  353. package/dist/panels/react/views-row/ViewAxes.d.ts +6 -0
  354. package/dist/panels/react/views-row/ViewAxes.js +16 -0
  355. package/dist/panels/react/views-row/ViewCreatePill.d.ts +7 -0
  356. package/dist/panels/react/views-row/ViewCreatePill.js +11 -0
  357. package/dist/panels/react/views-row/ViewPicker.d.ts +5 -0
  358. package/dist/panels/react/views-row/ViewPicker.js +65 -0
  359. package/dist/panels/react/views-row/ViewPickerRow.d.ts +7 -0
  360. package/dist/panels/react/views-row/ViewPickerRow.js +18 -0
  361. package/dist/panels/react/views-row/ViewTabs.d.ts +31 -0
  362. package/dist/panels/react/views-row/ViewTabs.js +29 -0
  363. package/dist/panels/react/views-row/menu-classes.d.ts +6 -0
  364. package/dist/panels/react/views-row/menu-classes.js +3 -0
  365. package/dist/panels/react/views-row/use-anchored-toggle.d.ts +19 -0
  366. package/dist/panels/react/views-row/use-anchored-toggle.js +31 -0
  367. package/dist/panels/react.d.ts +51 -0
  368. package/dist/panels/react.js +43 -0
  369. package/dist/panels/settings/axes.d.ts +28 -0
  370. package/dist/panels/settings/axes.js +71 -0
  371. package/dist/panels/settings/filters.d.ts +5 -0
  372. package/dist/panels/settings/filters.js +62 -0
  373. package/dist/panels/settings/group-buckets.d.ts +23 -0
  374. package/dist/panels/settings/group-buckets.js +73 -0
  375. package/dist/panels/settings/input.d.ts +69 -0
  376. package/dist/panels/settings/input.js +1 -0
  377. package/dist/panels/settings/layout.d.ts +5 -0
  378. package/dist/panels/settings/layout.js +244 -0
  379. package/dist/panels/settings/order.d.ts +19 -0
  380. package/dist/panels/settings/order.js +271 -0
  381. package/dist/panels/settings/settings-panels.d.ts +17 -0
  382. package/dist/panels/settings/settings-panels.js +28 -0
  383. package/dist/panels/toolbar/clear.d.ts +9 -0
  384. package/dist/panels/toolbar/clear.js +26 -0
  385. package/dist/panels/toolbar/counts.d.ts +15 -0
  386. package/dist/panels/toolbar/counts.js +21 -0
  387. package/dist/panels/toolbar/edit-view.d.ts +5 -0
  388. package/dist/panels/toolbar/edit-view.js +18 -0
  389. package/dist/panels/toolbar/model.d.ts +34 -0
  390. package/dist/panels/toolbar/model.js +52 -0
  391. package/dist/panels/use-filter-opened.d.ts +8 -0
  392. package/dist/panels/use-filter-opened.js +11 -0
  393. package/dist/panels/view-state.d.ts +38 -0
  394. package/dist/panels/view-state.js +1 -0
  395. package/dist/panels/views-row/model.d.ts +131 -0
  396. package/dist/panels/views-row/model.js +14 -0
  397. package/dist/provider/ViewsProvider.d.ts +50 -6
  398. package/dist/provider/ViewsProvider.js +33 -2
  399. package/dist/provider/components.d.ts +274 -11
  400. package/dist/provider/context.d.ts +23 -2
  401. package/dist/provider/desktop.d.ts +3 -0
  402. package/dist/provider/desktop.js +7 -4
  403. package/dist/react.d.ts +5 -2
  404. package/dist/selection/SelectionBar.d.ts +18 -0
  405. package/dist/selection/SelectionBar.js +98 -0
  406. package/dist/selection/SelectionBarPhone.d.ts +3 -0
  407. package/dist/selection/SelectionBarPhone.js +14 -0
  408. package/dist/selection/bar-overflow.d.ts +12 -0
  409. package/dist/selection/bar-overflow.js +55 -0
  410. package/dist/selection/bar-parts.d.ts +17 -0
  411. package/dist/selection/bar-parts.js +19 -0
  412. package/dist/selection/index.d.ts +2 -0
  413. package/dist/selection/index.js +1 -0
  414. package/dist/selection/types.d.ts +3 -2
  415. package/dist/selection/useListSelectionShortcuts.d.ts +3 -2
  416. package/dist/selection/useListSelectionShortcuts.js +1 -1
  417. package/dist/selection/verbs.d.ts +41 -0
  418. package/dist/selection/verbs.js +1 -0
  419. package/docs/contract.md +355 -35
  420. package/docs/getting-started.md +1 -1
  421. package/docs/guides/atoms.md +39 -6
  422. package/docs/guides/columns.md +1 -1
  423. package/docs/guides/display.md +3 -2
  424. package/docs/guides/editors.md +4 -3
  425. package/docs/guides/selection.md +35 -21
  426. package/docs/guides/the-grid.md +24 -13
  427. package/docs/guides/the-provider.md +24 -6
  428. package/docs/index.md +2 -0
  429. package/docs/install.md +3 -1
  430. package/docs/reference/cells.md +1 -1
  431. package/docs/reference/display.md +5 -4
  432. package/docs/reference/editors-location.md +3 -1
  433. package/docs/reference/editors-name.md +3 -1
  434. package/docs/reference/editors-number.md +1 -0
  435. package/docs/reference/editors-range.md +3 -1
  436. package/docs/reference/editors-session.md +1 -0
  437. package/docs/reference/editors-text.md +2 -2
  438. package/docs/reference/editors-value-list.md +1 -1
  439. package/docs/reference/field-row.md +2 -2
  440. package/docs/reference/grid.md +10 -7
  441. package/docs/reference/panels-react.md +101 -0
  442. package/docs/reference/panels.md +123 -0
  443. package/docs/reference/react.md +45 -12
  444. package/docs/reference/selection.md +11 -3
  445. package/docs/reference/views.md +41 -38
  446. package/package.json +33 -4
  447. package/skills/views/SKILL.md +5 -4
@@ -1,39 +1,39 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from "react";
4
- import { acceptFieldCommit, phoneText, valueItems, valueKey, } from "@viewkitjs/fields";
4
+ import { acceptFieldCommit, } from "@viewkitjs/fields";
5
5
  import { cx } from "../internal/cx.js";
6
6
  import { ELEMENT_RESET } from "../internal/reset.js";
7
7
  import { useViews } from "../provider/context.js";
8
8
  import { OpenValueAction, isOpenableType } from "./open-value.js";
9
9
  import { EDITOR_INNER_ESCAPE } from "./EditorPanel.js";
10
- function textOf(value) {
11
- if (typeof value === "string")
12
- return value;
13
- return phoneText(value, null) || String(value);
14
- }
15
- export const ValueListEditor = forwardRef(function ValueListEditor({ field, initial, labels = true, allowEmpty = false, region, openLinks = false, escapeKeeps = false, onRequestClose }, ref) {
10
+ import { BodyFrame } from "./BodyFrame.js";
11
+ import { usePickerForm } from "./picker-slot.js";
12
+ import { bodyLines, mergeValueLines, openedItems, resolveValueRows, storedByText, valueText, } from "./values-body.js";
13
+ export const ValueListEditor = forwardRef(function ValueListEditor({ field, initial, labels = true, allowEmpty = false, region, openLinks = false, escapeKeeps = false, label, holds = "several", seed, onRequestClose, }, ref) {
16
14
  const views = useViews();
17
15
  const words = views.messages;
18
16
  const { Row } = views.atoms;
19
- const { Input } = views.components;
17
+ const { Input, ValuesBody } = views.components;
20
18
  const Add = views.icons.add;
21
19
  const Remove = views.icons.close;
22
20
  const boxRef = useRef(null);
23
- const [opened] = useState(() => {
24
- const items = valueItems(initial);
25
- const main = items.find((item) => item.main);
26
- const one = items.map((item) => ({ ...item, label: item.label?.trim() || null, main: item === main }));
27
- const first = one.find((item) => item.main);
28
- return first ? [first, ...one.filter((item) => item !== first)] : one;
29
- });
21
+ const [opened] = useState(() => openedItems(initial));
30
22
  const nextId = useRef(Math.max(opened.length, 1));
31
23
  const [rows, setRows] = useState(() => opened.length === 0
32
- ? [{ id: 0, text: "", label: "", main: true }]
24
+ ? [{ id: 0, text: seed ?? "", label: "", main: true }]
33
25
  : opened.map((item, index) => {
34
- const text = textOf(item.value);
35
- return { id: index, text, label: item.label ?? "", main: item.main, stored: { value: item.value, text } };
26
+ const text = valueText(item.value);
27
+ const row = {
28
+ id: index,
29
+ text,
30
+ label: item.label ?? "",
31
+ main: item.main,
32
+ stored: { value: item.value, text },
33
+ };
34
+ return index === 0 && seed !== undefined ? { ...row, text: seed } : row;
36
35
  }));
36
+ const one = holds === "one";
37
37
  const rowsRef = useRef(rows);
38
38
  const update = (next) => {
39
39
  rowsRef.current = next;
@@ -87,36 +87,38 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
87
87
  update(rowsRef.current.map((each) => (each.id === id ? { ...each, error } : each)));
88
88
  return error === undefined;
89
89
  };
90
- const resolveClose = (reason) => {
91
- if (reason === "escape")
92
- return { kind: "cancel" };
93
- const kept = rowsRef.current.filter((row) => row.text.trim() !== "");
94
- const items = kept.map((row) => ({
95
- value: untouched(row) ? row.stored.value : row.text.trim(),
96
- label: labels && row.label.trim() !== "" ? row.label.trim() : null,
97
- main: row.main,
90
+ const resolveClose = (reason) => resolveValueRows(reason, rowsRef.current, opened, labels, allowEmpty);
91
+ const form = usePickerForm();
92
+ const keepsLabels = labels && holds !== "one";
93
+ const [lines, setLines] = useState(() => {
94
+ const start = opened.map((item, index) => ({
95
+ id: index,
96
+ text: valueText(item.value),
97
+ label: item.label ?? "",
98
+ main: item.main,
98
99
  }));
99
- if (items.length > 0 && !items.some((item) => item.main))
100
- items[0] = { ...items[0], main: true };
101
- const main = items.find((item) => item.main);
102
- const next = main ? [main, ...items.filter((item) => item !== main)] : items;
103
- const same = next.length === opened.length &&
104
- next.every((item, at) => {
105
- const was = opened[at];
106
- return (valueKey(item.value) === valueKey(was.value) &&
107
- item.label === (labels ? was.label : null) &&
108
- item.main === was.main);
109
- });
110
- if (same)
111
- return { kind: "noop" };
112
- if (next.length === 0)
113
- return allowEmpty ? { kind: "commit", payload: null } : { kind: "cancel" };
114
- return { kind: "commit", payload: next };
115
- };
116
- useImperativeHandle(ref, () => ({ resolveClose }));
100
+ if (seed === undefined)
101
+ return start;
102
+ return start.length === 0
103
+ ? [{ id: 0, text: seed, label: "", main: true }]
104
+ : start.map((line, at) => (at === 0 ? { ...line, text: seed } : line));
105
+ });
106
+ const linesRef = useRef(lines);
107
+ const nextLineId = useRef(Math.max(lines.length, 1));
108
+ useImperativeHandle(ref, () => ({
109
+ resolveClose: ValuesBody
110
+ ? (reason) => resolveValueRows(reason, storedByText(linesRef.current, opened, field.type, region), opened, keepsLabels, allowEmpty)
111
+ : resolveClose,
112
+ }));
117
113
  const set = (id, change) => update(rowsRef.current.map((row) => (row.id === id ? { ...row, ...change } : row)));
118
114
  const makeMain = (id) => update(rowsRef.current.map((row) => ({ ...row, main: row.id === id })));
119
115
  const remove = (id) => {
116
+ if (one) {
117
+ const blank = { id: nextId.current++, text: "", label: "", main: true };
118
+ focusRow.current = blank.id;
119
+ update([blank]);
120
+ return;
121
+ }
120
122
  const at = rowsRef.current.findIndex((row) => row.id === id);
121
123
  const left = rowsRef.current.filter((row) => row.id !== id);
122
124
  const next = left[at];
@@ -202,6 +204,16 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
202
204
  if (!boxRef.current?.contains(to))
203
205
  onRequestClose("blur");
204
206
  };
207
+ if (ValuesBody) {
208
+ const shown = lines;
209
+ const take = (next) => {
210
+ linesRef.current = mergeValueLines(linesRef.current, shown, next, () => nextLineId.current++);
211
+ setLines(linesRef.current);
212
+ };
213
+ return (_jsx(BodyFrame, { slot: "vk-values-body", innerEscape: escapeKeeps, onRequestClose: onRequestClose, children: _jsx(ValuesBody, { label: label ?? field.label, kind: field.type, value: bodyLines(lines), onValueChange: take, onDone: () => onRequestClose("enter"), check: (text) => text.trim() === "" || opened.some((item) => valueText(item.value) === text)
214
+ ? null
215
+ : check({ id: -1, text, label: "", main: false }), labels: keepsLabels, holds: holds, ...(field.type === "phone" && region ? { region } : {}), empty: allowEmpty, typed: seed, autoFocus: true, form: form }) }));
216
+ }
205
217
  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)";
206
218
  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)";
207
219
  return (_jsxs("div", { ref: boxRef, ...(escapeKeeps ? { [EDITOR_INNER_ESCAPE]: "" } : {}), onMouseDown: (e) => {
@@ -209,17 +221,17 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
209
221
  e.preventDefault();
210
222
  }, className: "flex w-full min-w-0 flex-col gap-0.5", children: [rows.map((row) => {
211
223
  const shown = row.text.trim() || field.label;
212
- return (_jsxs("div", { "data-row": true, className: "flex flex-col", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [_jsx("button", { type: "button", "data-walk": true, "aria-pressed": row.main, "aria-label": row.main
224
+ return (_jsxs("div", { "data-row": true, className: "flex flex-col", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [!one && (_jsx("button", { type: "button", "data-walk": true, "aria-pressed": row.main, "aria-label": row.main
213
225
  ? words({ key: "views.editors.values-main" })
214
226
  : words({ key: "views.editors.values-make-main", values: { value: shown } }), title: row.main ? words({ key: "views.editors.values-main" }) : undefined, onClick: (e) => {
215
227
  e.stopPropagation();
216
228
  makeMain(row.id);
217
- }, onKeyDown: (e) => buttonKeys(row.id, () => makeMain(row.id))(e), onKeyUp: noSpaceClick, onBlur: (e) => blur(row.id)(e), className: cx(ELEMENT_RESET, 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) => {
229
+ }, onKeyDown: (e) => buttonKeys(row.id, () => makeMain(row.id))(e), onKeyUp: noSpaceClick, onBlur: (e) => blur(row.id)(e), className: cx(ELEMENT_RESET, 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 && !one && (_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) => {
218
230
  e.stopPropagation();
219
231
  remove(row.id);
220
232
  }, onKeyDown: (e) => buttonKeys(row.id, () => remove(row.id))(e), onKeyUp: noSpaceClick, onBlur: (e) => blur(row.id)(e), className: cx(ELEMENT_RESET, 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));
221
- }), _jsx("div", { ref: addRef, onKeyDown: addKeys, onBlur: (e) => {
233
+ }), !one && (_jsx("div", { ref: addRef, onKeyDown: addKeys, onBlur: (e) => {
222
234
  if (!boxRef.current?.contains(e.relatedTarget))
223
235
  onRequestClose("blur");
224
- }, children: _jsx(Row, { tone: "muted", size: "compact", leading: _jsx(Add, { className: "size-3.5" }), label: words({ key: "views.editors.values-add" }), onMouseDown: (e) => e.preventDefault(), onClick: add }) })] }));
236
+ }, children: _jsx(Row, { tone: "muted", size: "compact", leading: _jsx(Add, { className: "size-3.5" }), label: words({ key: "views.editors.values-add" }), onMouseDown: (e) => e.preventDefault(), onClick: add }) }))] }));
225
237
  });
@@ -0,0 +1,7 @@
1
+ import { bodyPanel, type ViewsBodyKind } from "../model/body-frame.js";
2
+ /**
3
+ * What a pick or body editor's host hands its popover: the provider's `bodyFrame` read against whether the app handed
4
+ * the body this editor opens (`Picker`, `PartsBody` or `ValuesBody`). `viewkit` is ViewKit's width and padding, `kept`
5
+ * what isn't look. Spread `data` into the panel's `panelData`. The package's own; no entry point exports it.
6
+ */
7
+ export declare function useBodyPanel(body: ViewsBodyKind, viewkit: string, kept: string): ReturnType<typeof bodyPanel>;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { bodyPanel } from "../model/body-frame.js";
3
+ import { useViews } from "../provider/context.js";
4
+ export function useBodyPanel(body, viewkit, kept) {
5
+ const { bodyFrame, components } = useViews();
6
+ const handed = body === "picker" ? components.Picker : body === "parts" ? components.PartsBody : components.ValuesBody;
7
+ return bodyPanel(bodyFrame, handed ? body : null, viewkit, kept);
8
+ }
@@ -17,6 +17,13 @@ export { useEscapeRule, type EditEscape } from "./escape-rule.js";
17
17
  * The package's, behind its own door (`@viewkitjs/views/editors/session`), so both
18
18
  * host families reach it without reaching each other, and without loading the five
19
19
  * editors the `./editors` registry does.
20
+ *
21
+ * AND IT LEAVES. A session still open when its page goes (`pagehide`: a reload, a closed tab, a removed frame, Back to
22
+ * another document), or when the grid or field row around it goes (`./leave-scope.ts`), is left by its `leave` rule:
23
+ * `"outside"` asks the editor as a press outside does, so its draft is written by the editor's own rule; `"discard"`,
24
+ * the default, asks nothing, which is what a host of an app's own and a phone's sheet keep. Either way an answer
25
+ * already given and waiting out the exit is finished at once, inside the event: no React cleanup runs on a page that
26
+ * is discarded. A write that must outlive the page is the app's to send (`keepalive`, a beacon).
20
27
  */
21
28
  /** The slice of a core's handle this needs: one synchronous, idempotent answer. */
22
29
  type ResolvableHandle<P> = {
@@ -35,9 +42,9 @@ type ResolvableHandle<P> = {
35
42
  * A host that admits the answer synchronously clears this UI-only timer on
36
43
  * unmount: the write already belongs to its coordinator. The deferred mode
37
44
  * keeps the timer because its answer still carries the write. It stays for
38
- * compatibility, for an app that opens it, and in this package only the grid's
39
- * name editor (`GridNameEditor`) still does. New hosts should prefer
40
- * synchronous admission.
45
+ * compatibility, for an app that opens it; no host in this package does. New
46
+ * hosts should prefer synchronous admission. Either way, a session that leaves
47
+ * (its page or its surface going) finishes a waiting answer at once.
41
48
  */
42
49
  export declare const EDITOR_EXIT_MS = 160;
43
50
  /**
@@ -62,12 +69,19 @@ type AnchoredEditSessionBase<P> = {
62
69
  * it is the discard, so a phone's sheet keeps nothing. Default `cancel`: Escape answers a cancel without
63
70
  * asking the editor. A host reads it for its field's type with `useEscapeRule`. */
64
71
  escape?: EditEscape;
72
+ /** What the page going (`pagehide`), or the grid or field row around the session going, does to a session still
73
+ * open: `"outside"` asks the editor as a press outside does, so its draft is written by its own rule; `"discard"`
74
+ * asks nothing, as a phone's sheet throws away every way out but ✓. Either way an answer already given and
75
+ * waiting out the exit is finished at once. Read once, when the session opens. Default `"discard"`: a host of
76
+ * your own keeps 0.5.0's behaviour unless it asks for `"outside"`. */
77
+ leave?: "outside" | "discard";
65
78
  };
66
79
  type DeferredResolution<P> = AnchoredEditSessionBase<P> & {
67
80
  /** Compatibility mode: the answer, including persistence, follows the exit. */
68
81
  onDone: (resolution: CloseResolution<unknown>) => void;
69
82
  onAttempt?: never;
70
83
  onClose?: never;
84
+ onLeave?: never;
71
85
  };
72
86
  /** The host's answer to an attempt. A refusal may say why; the session hands the reason back as `refusal`. */
73
87
  export type EditSessionAttempt = {
@@ -91,6 +105,9 @@ type AdmittedResolution<P> = AnchoredEditSessionBase<P> & {
91
105
  onAttempt: (resolution: CloseResolution<unknown>) => EditSessionAttempt;
92
106
  /** Finish only the visual close after the exit gap. */
93
107
  onClose: () => void;
108
+ /** Called once as the session leaves, before it asks or finishes anything: the page or the surface is going, and
109
+ * no focus is to move. */
110
+ onLeave?: () => void;
94
111
  onDone?: never;
95
112
  };
96
113
  export declare function useAnchoredEditSession<P>(args: DeferredResolution<P> | AdmittedResolution<P>): EditSession;
@@ -1,11 +1,13 @@
1
1
  "use client";
2
- import { useContext, useEffect, useRef, useState } from "react";
2
+ import { useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
3
3
  import { ViewsContext } from "../provider/context.js";
4
4
  import { DEFAULT_DESKTOP_QUERY, isDesktopNow } from "../provider/desktop.js";
5
+ import { EditLeaveContext } from "./leave-scope.js";
5
6
  export { useEscapeRule } from "./escape-rule.js";
6
7
  export const EDITOR_EXIT_MS = 160;
7
8
  export function useAnchoredEditSession(args) {
8
9
  const { editorRef, mapPayload, exitMs = EDITOR_EXIT_MS, escape = "cancel" } = args;
10
+ const [leaveMode] = useState(() => args.leave ?? "discard");
9
11
  const desktopQuery = useContext(ViewsContext)?.desktopQuery ?? DEFAULT_DESKTOP_QUERY;
10
12
  const [keeps] = useState(() => escape === "keep" && isDesktopNow(desktopQuery));
11
13
  const [open, setOpen] = useState(true);
@@ -13,6 +15,7 @@ export function useAnchoredEditSession(args) {
13
15
  const closedRef = useRef(false);
14
16
  const refusedRef = useRef(false);
15
17
  const timerRef = useRef(null);
18
+ const finishRef = useRef(null);
16
19
  const admitted = args.onAttempt !== undefined;
17
20
  useEffect(() => () => {
18
21
  if (admitted && timerRef.current !== null)
@@ -46,12 +49,49 @@ export function useAnchoredEditSession(args) {
46
49
  return;
47
50
  }
48
51
  setOpen(false);
49
- timerRef.current = window.setTimeout(args.onClose, exitMs);
52
+ wait(args.onClose);
50
53
  return;
51
54
  }
52
55
  closedRef.current = true;
53
56
  setOpen(false);
54
- timerRef.current = window.setTimeout(() => args.onDone(answer), exitMs);
57
+ const onDone = args.onDone;
58
+ wait(() => onDone(answer));
55
59
  };
60
+ const wait = (finish) => {
61
+ finishRef.current = finish;
62
+ timerRef.current = window.setTimeout(() => {
63
+ timerRef.current = null;
64
+ finishRef.current = null;
65
+ finish();
66
+ }, exitMs);
67
+ };
68
+ const leave = () => {
69
+ const waiting = timerRef.current !== null;
70
+ if (closedRef.current && !waiting)
71
+ return;
72
+ if (!closedRef.current && leaveMode === "discard" && !waiting)
73
+ return;
74
+ args.onLeave?.();
75
+ if (!closedRef.current && leaveMode === "outside")
76
+ close("outside");
77
+ if (timerRef.current !== null) {
78
+ window.clearTimeout(timerRef.current);
79
+ timerRef.current = null;
80
+ const finish = finishRef.current;
81
+ finishRef.current = null;
82
+ finish?.();
83
+ }
84
+ };
85
+ const leaveRef = useRef(leave);
86
+ useLayoutEffect(() => {
87
+ leaveRef.current = leave;
88
+ });
89
+ useEffect(() => {
90
+ const onHide = () => leaveRef.current();
91
+ window.addEventListener("pagehide", onHide);
92
+ return () => window.removeEventListener("pagehide", onHide);
93
+ }, []);
94
+ const scope = useContext(EditLeaveContext);
95
+ useLayoutEffect(() => scope?.add(() => leaveRef.current()), [scope]);
56
96
  return { open, close, refusal, keeps };
57
97
  }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * THE LEAVE SCOPE — what a surface that holds editors (the grid, a field row) gives the edit sessions inside it, so
3
+ * that a session still open when the surface goes is left as the page going would leave it (`useAnchoredEditSession`'s
4
+ * `leave`): its editor asked as for a press outside, or asked nothing in a phone's sheet.
5
+ *
6
+ * It sits in the surface, never in an editor's host, and that is the whole rule:
7
+ *
8
+ * - The surface's layout cleanup runs before its descendants' (React tears a tree down from its root), so each
9
+ * editor's handle (`useImperativeHandle`) is still attached when its session asks it.
10
+ * - A surface ends an edit by unmounting the editor alone (the grid's Escape on the cell, a row gone stale), and the
11
+ * scope does not go then: that edit stays a discard. Only the surface itself going leaves.
12
+ * - StrictMode rehearses a component's effects at its own first mount. The surface mounts with no editor open, so its
13
+ * rehearsal leaves an empty scope; an editor host mounted later rehearses only its own add and remove.
14
+ *
15
+ * Internal: no package door exports it.
16
+ */
17
+ export type EditLeaveScope = {
18
+ add: (leave: () => void) => () => void;
19
+ };
20
+ export declare const EditLeaveContext: import("react").Context<EditLeaveScope | null>;
21
+ /** For a surface that holds editors: provide it through `EditLeaveContext`; its layout cleanup leaves every session
22
+ * still added. */
23
+ export declare function useEditLeaveScope(): EditLeaveScope;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { createContext, useLayoutEffect, useRef, useState } from "react";
3
+ export const EditLeaveContext = createContext(null);
4
+ export function useEditLeaveScope() {
5
+ const leaves = useRef(new Set());
6
+ const [scope] = useState(() => ({
7
+ add: (leave) => {
8
+ leaves.current.add(leave);
9
+ return () => {
10
+ leaves.current.delete(leave);
11
+ };
12
+ },
13
+ }));
14
+ useLayoutEffect(() => () => {
15
+ let failure = null;
16
+ for (const leave of [...leaves.current]) {
17
+ try {
18
+ leave();
19
+ }
20
+ catch (error) {
21
+ failure ??= { error };
22
+ }
23
+ }
24
+ if (failure)
25
+ throw failure.error;
26
+ }, []);
27
+ return scope;
28
+ }
@@ -0,0 +1,29 @@
1
+ import { type CloseReason, type CloseResolution, type FieldDef, type NumberCommit } from "@viewkitjs/fields";
2
+ /** A number body's draft: the value (null empty; `NaN` unreadable) and its unit. */
3
+ export type NumberDraft = {
4
+ value: number | null;
5
+ unit: string | undefined;
6
+ };
7
+ /** The kit's word for a number field's type. */
8
+ export declare function numberBodyKind(type: "number" | "percent" | "currency"): "number" | "money" | "percent";
9
+ /** The lowest and highest a field may hold, as its schema reads them: a percent 0 and 100 unless its validation says
10
+ * otherwise; a number or money its validation's `min` and `max`; each left out where unstated. */
11
+ export declare function numberBounds(field: FieldDef): {
12
+ min?: number;
13
+ max?: number;
14
+ };
15
+ /** A body's change against the draft it was drawn with: null when it is no change (`null` and `undefined` one value;
16
+ * `NaN` equal only to `NaN`), else the new draft. A unit outside `units` (or any unit with no `units`) is ignored: the
17
+ * drawn unit stays. */
18
+ export declare function numberChange(drawn: NumberDraft, next: {
19
+ value: number | null | undefined;
20
+ unit: string | undefined;
21
+ }, units: readonly string[] | undefined): NumberDraft | null;
22
+ /** A number body's close, as `NumberEditor`'s own `resolveClose` for the same values: escape cancels; `NaN` (unreadable)
23
+ * cancels; a null draft cancels unless `allowEmpty`, then is a noop when `initial` was not finite and the unit is
24
+ * unchanged, else commits `{ value: null, unit }`; a non-finite value cancels; the value rounded to `decimals` equal
25
+ * to `initial` rounded with the same unit is a noop; else it commits `{ value: rounded, unit }`. */
26
+ export declare function resolveNumberBody(reason: CloseReason, draft: NumberDraft, initial: number, initialUnit: string | undefined, opts: {
27
+ decimals: number;
28
+ allowEmpty: boolean;
29
+ }): CloseResolution<NumberCommit>;
@@ -0,0 +1,37 @@
1
+ import { presentedDef, roundTo, } from "@viewkitjs/fields";
2
+ export function numberBodyKind(type) {
3
+ return type === "currency" ? "money" : type;
4
+ }
5
+ export function numberBounds(field) {
6
+ const def = presentedDef(field);
7
+ const stated = "validation" in def && def.validation && typeof def.validation === "object" ? def.validation : {};
8
+ const v = { ...(def.type === "percent" ? { min: 0, max: 100 } : {}), ...stated };
9
+ return {
10
+ ...(typeof v.min === "number" ? { min: v.min } : {}),
11
+ ...(typeof v.max === "number" ? { max: v.max } : {}),
12
+ };
13
+ }
14
+ const empty = (value) => (value === undefined ? null : value);
15
+ export function numberChange(drawn, next, units) {
16
+ const value = empty(next.value);
17
+ const unit = next.unit !== undefined && units?.includes(next.unit) ? next.unit : drawn.unit;
18
+ return Object.is(value, drawn.value) && unit === drawn.unit ? null : { value, unit };
19
+ }
20
+ export function resolveNumberBody(reason, draft, initial, initialUnit, opts) {
21
+ if (reason === "escape")
22
+ return { kind: "cancel" };
23
+ const { value, unit } = draft;
24
+ if (value === null) {
25
+ if (!opts.allowEmpty)
26
+ return { kind: "cancel" };
27
+ if (!Number.isFinite(initial) && unit === initialUnit)
28
+ return { kind: "noop" };
29
+ return { kind: "commit", payload: { value: null, unit } };
30
+ }
31
+ if (!Number.isFinite(value))
32
+ return { kind: "cancel" };
33
+ const rounded = roundTo(value, opts.decimals);
34
+ if (rounded === roundTo(initial, opts.decimals) && unit === initialUnit)
35
+ return { kind: "noop" };
36
+ return { kind: "commit", payload: { value: rounded, unit } };
37
+ }
@@ -0,0 +1,66 @@
1
+ import { type CloseReason, type CloseResolution, type LocationPart, type NameValue, type RangeValue } from "@viewkitjs/fields";
2
+ import type { PlaceRegion } from "@viewkitjs/fields/places";
3
+ /** The full name the parts give: the present ones, trimmed, joined by a space. */
4
+ export declare function fromParts(given: string, family: string): string;
5
+ /**
6
+ * A change merged against what the body was last drawn with: a key handed as drawn keeps the draft's (a change the
7
+ * draft took since, in the same tick, survives a body still holding its old props); a key handed differently is the
8
+ * person's change. The keys compared are those of `shown` and `next` together, so a key the body leaves out that it
9
+ * was drawn with is a change to empty. `same` defaults to `===`.
10
+ */
11
+ export declare function mergeParts<T extends Record<string, unknown>>(draft: T, shown: T, next: T, same?: (a: unknown, b: unknown) => boolean): T;
12
+ /** A place's sameness for `mergeParts`: `""`, `null`, `undefined` and a missing key are one value (empty). */
13
+ export declare function samePlacePart(a: unknown, b: unknown): boolean;
14
+ /** NameEditor's state: the parts, the full name typed or stored, whether it is the person's own, and whether a part
15
+ * was edited (until then the full name is the stored one, so an untouched editor writes nothing). */
16
+ export type NameBodyDraft = {
17
+ given: string;
18
+ family: string;
19
+ typedFull: string;
20
+ ownFull: boolean;
21
+ partsEdited: boolean;
22
+ };
23
+ /** NameEditor's opening state: the seed replaces the given name and counts as an edit; a stored full name the parts
24
+ * would not give is its own. */
25
+ export declare function nameBodyStart(initial: NameValue | null, seed?: string): NameBodyDraft;
26
+ /** What the body is drawn with: `full` by the rule, the parts' own once one is edited unless a name of its own. */
27
+ export declare function nameBodyValue(draft: NameBodyDraft): {
28
+ given: string;
29
+ family: string;
30
+ full: string;
31
+ };
32
+ /** A merged change applied: a changed part marks the parts edited; a changed full name makes it the person's own. */
33
+ export declare function takeNameParts(draft: NameBodyDraft, merged: {
34
+ given: string;
35
+ family: string;
36
+ full: string;
37
+ }): NameBodyDraft;
38
+ /** NameEditor's close over the body's draft: Escape throws it away, the same name writes nothing, every box cleared
39
+ * is a clear only where the host allows one. */
40
+ export declare function resolveNameBody(reason: CloseReason, draft: NameBodyDraft, initial: NameValue | null, allowEmpty: boolean): CloseResolution<NameValue | null>;
41
+ export type PlaceBodyDraft = Partial<Record<LocationPart, string | null>>;
42
+ /**
43
+ * A merged change applied. The region's code is the editor's, never taken as handed: a new country clears the region
44
+ * and its code (unless the same change sets a region, which is read against the new country); a changed region named
45
+ * in the country's list takes that region's label and code, any other has none; a change that leaves the region keeps
46
+ * the code it had, so a stored code survives a part typed before the list loads. A field that doesn't take
47
+ * `regionCode` never gets one.
48
+ */
49
+ export declare function takePlaceParts(draft: PlaceBodyDraft, merged: PlaceBodyDraft, ctx: {
50
+ parts: readonly LocationPart[];
51
+ regions: readonly PlaceRegion[] | null;
52
+ labelOf: (region: PlaceRegion) => string;
53
+ }): PlaceBodyDraft;
54
+ /** The draft as the body is handed it: strings only, empty parts left out. */
55
+ export declare function placeBodyValue(draft: PlaceBodyDraft): Partial<Record<LocationPart, string>>;
56
+ /** The two ends, and whether the text that opened the editor was no number and nothing has been handed since. */
57
+ export type RangeBodyDraft = {
58
+ low: number | null;
59
+ high: number | null;
60
+ unread: boolean;
61
+ };
62
+ /** The seed as the low end where it reads as a number (`parse`), else the ends kept and `unread` set. */
63
+ export declare function rangeBodyStart(initial: RangeValue | null, seed: string | undefined, parse: (raw: string) => number | null | undefined): RangeBodyDraft;
64
+ /** RangeEditor's close over the body's draft: both ends rounded to `decimals`; ends as they opened write nothing;
65
+ * both empty is a clear only where the host allows one; an unread seed throws the edit away. */
66
+ export declare function resolveRangeBody(reason: CloseReason, draft: RangeBodyDraft, initial: RangeValue | null, decimals: number, allowEmpty: boolean): CloseResolution<RangeValue>;
@@ -0,0 +1,114 @@
1
+ import { isEmptyName, roundTo, sameName, tidyName, } from "@viewkitjs/fields";
2
+ export function fromParts(given, family) {
3
+ return [given.trim(), family.trim()].filter(Boolean).join(" ");
4
+ }
5
+ export function mergeParts(draft, shown, next, same = Object.is) {
6
+ const merged = { ...draft };
7
+ for (const key of new Set([...Object.keys(shown), ...Object.keys(next)])) {
8
+ if (!same(next[key], shown[key]))
9
+ merged[key] = next[key];
10
+ }
11
+ return merged;
12
+ }
13
+ export function samePlacePart(a, b) {
14
+ const empty = (value) => value == null || value === "";
15
+ if (empty(a) && empty(b))
16
+ return true;
17
+ return a === b;
18
+ }
19
+ export function nameBodyStart(initial, seed) {
20
+ const stored = initial?.full?.trim() ?? "";
21
+ return {
22
+ given: seed ?? initial?.given ?? "",
23
+ family: initial?.family ?? "",
24
+ typedFull: initial?.full ?? "",
25
+ ownFull: stored !== "" && stored !== fromParts(initial?.given ?? "", initial?.family ?? ""),
26
+ partsEdited: seed !== undefined,
27
+ };
28
+ }
29
+ export function nameBodyValue(draft) {
30
+ const full = draft.ownFull || !draft.partsEdited ? draft.typedFull : fromParts(draft.given, draft.family);
31
+ return { given: draft.given, family: draft.family, full };
32
+ }
33
+ export function takeNameParts(draft, merged) {
34
+ const next = { ...draft, given: merged.given, family: merged.family };
35
+ if (merged.given !== draft.given || merged.family !== draft.family)
36
+ next.partsEdited = true;
37
+ if (merged.full !== nameBodyValue(draft).full) {
38
+ next.ownFull = true;
39
+ next.typedFull = merged.full;
40
+ }
41
+ return next;
42
+ }
43
+ export function resolveNameBody(reason, draft, initial, allowEmpty) {
44
+ if (reason === "escape")
45
+ return { kind: "cancel" };
46
+ const next = tidyName(nameBodyValue(draft));
47
+ if (sameName(next, initial))
48
+ return { kind: "noop" };
49
+ if (isEmptyName(next))
50
+ return allowEmpty ? { kind: "commit", payload: null } : { kind: "cancel" };
51
+ return { kind: "commit", payload: next };
52
+ }
53
+ function regionNamed(text, regions, labelOf) {
54
+ const needle = text?.trim().toLowerCase() ?? "";
55
+ if (needle === "" || !regions)
56
+ return undefined;
57
+ return regions.find((region) => region.code?.toLowerCase() === needle ||
58
+ labelOf(region).toLowerCase() === needle ||
59
+ region.name.toLowerCase() === needle ||
60
+ region.latinName?.toLowerCase() === needle);
61
+ }
62
+ export function takePlaceParts(draft, merged, ctx) {
63
+ const next = { ...merged, regionCode: draft.regionCode ?? null };
64
+ const takesCode = ctx.parts.includes("regionCode");
65
+ if (!takesCode)
66
+ delete next.regionCode;
67
+ const countryChanged = !samePlacePart(merged.countryCode, draft.countryCode);
68
+ const regionChanged = !samePlacePart(merged.region, draft.region);
69
+ if (countryChanged && !regionChanged) {
70
+ if (ctx.parts.includes("region"))
71
+ next.region = null;
72
+ if (takesCode)
73
+ next.regionCode = null;
74
+ return next;
75
+ }
76
+ if (!countryChanged && !regionChanged)
77
+ return next;
78
+ const found = countryChanged ? undefined : regionNamed(merged.region, ctx.regions, ctx.labelOf);
79
+ if (found)
80
+ next.region = ctx.labelOf(found);
81
+ if (takesCode)
82
+ next.regionCode = found?.code ?? null;
83
+ return next;
84
+ }
85
+ export function placeBodyValue(draft) {
86
+ const value = {};
87
+ for (const [part, text] of Object.entries(draft)) {
88
+ if (typeof text === "string" && text !== "")
89
+ value[part] = text;
90
+ }
91
+ return value;
92
+ }
93
+ export function rangeBodyStart(initial, seed, parse) {
94
+ const ends = { low: initial?.low ?? null, high: initial?.high ?? null };
95
+ if (seed === undefined)
96
+ return { ...ends, unread: false };
97
+ const low = parse(seed);
98
+ return typeof low === "number" ? { ...ends, low, unread: false } : { ...ends, unread: true };
99
+ }
100
+ export function resolveRangeBody(reason, draft, initial, decimals, allowEmpty) {
101
+ if (reason === "escape" || draft.unread)
102
+ return { kind: "cancel" };
103
+ const readable = (n) => n === null || Number.isFinite(n);
104
+ if (!readable(draft.low) || !readable(draft.high))
105
+ return { kind: "cancel" };
106
+ const at = (n) => (n == null ? null : roundTo(n, decimals));
107
+ const low = at(draft.low);
108
+ const high = at(draft.high);
109
+ if (low === at(initial?.low) && high === at(initial?.high))
110
+ return { kind: "noop" };
111
+ if (low === null && high === null && !allowEmpty)
112
+ return { kind: "cancel" };
113
+ return { kind: "commit", payload: { low, high } };
114
+ }
@@ -0,0 +1,5 @@
1
+ /** The first and last controls Tab reaches inside `root`. */
2
+ export declare function tabEnds(root: HTMLElement): {
3
+ first: Element | undefined;
4
+ last: Element | undefined;
5
+ };
@@ -0,0 +1,7 @@
1
+ const FOCUSABLE = "input, select, textarea, button, a[href], [tabindex]";
2
+ export function tabEnds(root) {
3
+ const reachable = Array.from(root.querySelectorAll(FOCUSABLE)).filter((element) => element.tabIndex >= 0 &&
4
+ !element.disabled &&
5
+ element.closest("[hidden], [inert]") === null);
6
+ return { first: reachable[0], last: reachable.at(-1) };
7
+ }