viewkitjs 0.31.0 → 0.33.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 (449) hide show
  1. package/CHANGELOG.md +198 -0
  2. package/MIGRATION.md +40 -6
  3. package/README.md +1 -1
  4. package/fields/dist/index.d.ts +1 -1
  5. package/fields/dist/index.js +1 -1
  6. package/fields/dist/query/evaluate.d.ts +7 -0
  7. package/fields/dist/query/exact-number.d.ts +8 -2
  8. package/fields/dist/query/exact-number.js +14 -1
  9. package/fields/dist/query/index.d.ts +2 -0
  10. package/fields/dist/query/index.js +2 -0
  11. package/fields/dist/query/list-request.d.ts +148 -0
  12. package/fields/dist/query/list-request.js +125 -0
  13. package/fields/dist/query/saved-view.d.ts +15 -0
  14. package/fields/dist/query/saved-view.js +11 -0
  15. package/fields/dist/query/settings.d.ts +9 -0
  16. package/fields/dist/query/settings.js +9 -0
  17. package/fields/dist/query/sort.js +13 -10
  18. package/fields/dist/registry.js +5 -1
  19. package/fields/dist/types.d.ts +4 -1
  20. package/fields/dist/zod.d.ts +5 -0
  21. package/fields/dist/zod.js +10 -1
  22. package/fields/docs/guides/contact-values.md +12 -0
  23. package/fields/docs/guides/field-types.md +1 -1
  24. package/fields/docs/guides/queries.md +3 -1
  25. package/fields/docs/reference/fields.md +1 -0
  26. package/fields/docs/reference/query.md +66 -0
  27. package/package.json +5 -1
  28. package/postgres/README.md +1 -0
  29. package/postgres/dist/check.js +4 -1
  30. package/postgres/dist/definitions/formula-forms.js +3 -1
  31. package/postgres/dist/definitions/money.js +2 -1
  32. package/postgres/dist/handler.d.ts +53 -0
  33. package/postgres/dist/handler.js +211 -0
  34. package/postgres/dist/ids.d.ts +1 -1
  35. package/postgres/dist/ids.js +19 -1
  36. package/postgres/dist/index.d.ts +1 -0
  37. package/postgres/dist/index.js +1 -0
  38. package/postgres/dist/limits.d.ts +3 -1
  39. package/postgres/dist/limits.js +1 -1
  40. package/postgres/dist/list-fields.d.ts +10 -0
  41. package/postgres/dist/list-fields.js +36 -0
  42. package/postgres/dist/page.js +6 -3
  43. package/postgres/dist/readable.d.ts +4 -0
  44. package/postgres/dist/readable.js +4 -0
  45. package/postgres/dist/refusals.d.ts +9 -2
  46. package/postgres/dist/refusals.js +6 -0
  47. package/postgres/dist/rules.d.ts +15 -1
  48. package/postgres/dist/rules.js +16 -0
  49. package/postgres/dist/sort.js +7 -2
  50. package/postgres/docs/guides/definitions.md +1 -1
  51. package/postgres/docs/guides/field-map.md +3 -3
  52. package/postgres/docs/guides/list-handler.md +99 -0
  53. package/postgres/docs/index.md +1 -0
  54. package/postgres/docs/reference/definitions.md +1 -1
  55. package/postgres/docs/reference/postgres.md +12 -4
  56. package/views/README.md +2 -2
  57. package/views/dist/atoms/RowMenu.d.ts +7 -0
  58. package/views/dist/atoms/RowMenu.js +18 -16
  59. package/views/dist/atoms/ToolbarButton.d.ts +1 -1
  60. package/views/dist/atoms/ToolbarButton.js +4 -3
  61. package/views/dist/atoms/carried.d.ts +5 -0
  62. package/views/dist/atoms/carried.js +7 -0
  63. package/views/dist/atoms/frame-parts.d.ts +6 -0
  64. package/views/dist/atoms/frame-parts.js +15 -0
  65. package/views/dist/atoms/types.d.ts +19 -7
  66. package/views/dist/cells/cell-title.d.ts +3 -1
  67. package/views/dist/cells/cell-title.js +2 -2
  68. package/views/dist/cells/cell-values.js +2 -2
  69. package/views/dist/contract.d.ts +56 -11
  70. package/views/dist/contract.js +148 -0
  71. package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
  72. package/views/dist/controls/atoms.d.ts +2 -0
  73. package/views/dist/controls/atoms.js +2 -0
  74. package/views/dist/controls/avatar/avatar.d.ts +3 -3
  75. package/views/dist/controls/avatar/avatar.js +1 -1
  76. package/views/dist/controls/avatar/tokens.d.ts +44 -0
  77. package/views/dist/controls/avatar/tokens.js +11 -0
  78. package/views/dist/controls/avatar.css +22 -5
  79. package/views/dist/controls/button/map-button.js +2 -0
  80. package/views/dist/controls/checkbox/checkbox.d.ts +3 -2
  81. package/views/dist/controls/checkbox/checkbox.js +2 -2
  82. package/views/dist/controls/choice/tokens.d.ts +0 -4
  83. package/views/dist/controls/choice/tokens.js +0 -1
  84. package/views/dist/controls/choice.css +3 -3
  85. package/views/dist/controls/compound-editor/compound-editor.d.ts +1 -1
  86. package/views/dist/controls/compound-editor/name-parts.js +4 -4
  87. package/views/dist/controls/compound-editor/place-parts.js +19 -19
  88. package/views/dist/controls/compound-editor/range-parts.js +14 -14
  89. package/views/dist/controls/compound-editor/row.d.ts +3 -1
  90. package/views/dist/controls/compound-editor/row.js +2 -2
  91. package/views/dist/controls/controls.d.ts +8 -0
  92. package/views/dist/controls/controls.js +12 -2
  93. package/views/dist/controls/customize/customize.js +37 -35
  94. package/views/dist/controls/customize/map-customize-body.d.ts +2 -0
  95. package/views/dist/controls/customize/map-customize-body.js +5 -1
  96. package/views/dist/controls/date-editor/date-days.js +2 -2
  97. package/views/dist/controls/date-editor/date-editor.js +18 -18
  98. package/views/dist/controls/date-editor/date-parts.js +6 -6
  99. package/views/dist/controls/date-editor/map-calendar.js +1 -1
  100. package/views/dist/controls/date-editor.css +2 -2
  101. package/views/dist/controls/field/field.d.ts +22 -4
  102. package/views/dist/controls/field/field.js +63 -5
  103. package/views/dist/controls/field/tokens.d.ts +4 -0
  104. package/views/dist/controls/field/tokens.js +1 -0
  105. package/views/dist/controls/field.css +41 -16
  106. package/views/dist/controls/filter-editor/block.d.ts +2 -2
  107. package/views/dist/controls/filter-editor/block.js +5 -5
  108. package/views/dist/controls/filter-editor/filter-editor.js +31 -33
  109. package/views/dist/controls/filter-editor/how.d.ts +3 -1
  110. package/views/dist/controls/filter-editor/map-filter-body.d.ts +1 -0
  111. package/views/dist/controls/filter-editor/map-filter-body.js +7 -3
  112. package/views/dist/controls/filter-editor/map-rules.js +1 -1
  113. package/views/dist/controls/filter-editor/parts.js +2 -1
  114. package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
  115. package/views/dist/controls/glyphs/glyphs.js +173 -0
  116. package/views/dist/controls/group-editor/group-editor.js +15 -13
  117. package/views/dist/controls/index.d.ts +4 -1
  118. package/views/dist/controls/index.js +3 -1
  119. package/views/dist/controls/input/input.js +6 -3
  120. package/views/dist/controls/input/map-input.js +2 -0
  121. package/views/dist/controls/input/tokens.d.ts +4 -0
  122. package/views/dist/controls/input/tokens.js +1 -0
  123. package/views/dist/controls/input.css +31 -3
  124. package/views/dist/controls/internal/editor-parts.js +1 -1
  125. package/views/dist/controls/internal/icons.js +10 -0
  126. package/views/dist/controls/internal/keep-focus.d.ts +2 -0
  127. package/views/dist/controls/internal/keep-focus.js +17 -0
  128. package/views/dist/controls/internal/map-panel-controls.d.ts +8 -0
  129. package/views/dist/controls/internal/map-panel-controls.js +20 -0
  130. package/views/dist/controls/internal/panel-controls.d.ts +50 -0
  131. package/views/dist/controls/internal/panel-controls.js +197 -0
  132. package/views/dist/controls/internal/part-slot.d.ts +12 -0
  133. package/views/dist/controls/internal/part-slot.js +5 -0
  134. package/views/dist/controls/internal/watch-frame.d.ts +2 -0
  135. package/views/dist/controls/internal/watch-frame.js +33 -0
  136. package/views/dist/controls/links-editor/links-editor.d.ts +1 -1
  137. package/views/dist/controls/links-editor/links-editor.js +27 -27
  138. package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
  139. package/views/dist/controls/markdown/map-markdown.js +5 -0
  140. package/views/dist/controls/menu/map-menu.d.ts +2 -2
  141. package/views/dist/controls/menu/map-menu.js +15 -12
  142. package/views/dist/controls/menu/menu.d.ts +2 -0
  143. package/views/dist/controls/menu/menu.js +3 -3
  144. package/views/dist/controls/menu-list/menu-list.d.ts +17 -4
  145. package/views/dist/controls/menu-list/menu-list.js +27 -25
  146. package/views/dist/controls/modal/modal.js +5 -1
  147. package/views/dist/controls/notice/notice.d.ts +3 -1
  148. package/views/dist/controls/notice/notice.js +2 -2
  149. package/views/dist/controls/number-editor/number-editor.d.ts +1 -1
  150. package/views/dist/controls/number-editor/number-editor.js +13 -13
  151. package/views/dist/controls/number-field/number-field.js +5 -3
  152. package/views/dist/controls/pane/pane.d.ts +4 -2
  153. package/views/dist/controls/pane/pane.js +6 -5
  154. package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
  155. package/views/dist/controls/phone-header/header-bar.js +2 -2
  156. package/views/dist/controls/phone-header.css +11 -1
  157. package/views/dist/controls/picker/map-picker.js +3 -0
  158. package/views/dist/controls/picker/picker.d.ts +16 -0
  159. package/views/dist/controls/picker/picker.js +61 -40
  160. package/views/dist/controls/picker/rows.d.ts +4 -0
  161. package/views/dist/controls/picker.css +2 -0
  162. package/views/dist/controls/popover/map-popover.d.ts +1 -1
  163. package/views/dist/controls/popover/map-popover.js +4 -2
  164. package/views/dist/controls/popover/popover.js +2 -1
  165. package/views/dist/controls/quick-filters/quick-filters.js +4 -4
  166. package/views/dist/controls/radio/radio.d.ts +8 -3
  167. package/views/dist/controls/radio/radio.js +22 -5
  168. package/views/dist/controls/radio/tokens.d.ts +44 -0
  169. package/views/dist/controls/radio/tokens.js +11 -0
  170. package/views/dist/controls/radio.css +79 -1
  171. package/views/dist/controls/select/map-select.d.ts +3 -0
  172. package/views/dist/controls/select/map-select.js +8 -0
  173. package/views/dist/controls/select/select.d.ts +7 -0
  174. package/views/dist/controls/select/select.js +12 -6
  175. package/views/dist/controls/select/tokens.d.ts +8 -0
  176. package/views/dist/controls/select/tokens.js +2 -0
  177. package/views/dist/controls/select.css +17 -0
  178. package/views/dist/controls/setting-row/looks.d.ts +1 -1
  179. package/views/dist/controls/setting-row/looks.js +9 -4
  180. package/views/dist/controls/setting-row/setting-row.d.ts +45 -10
  181. package/views/dist/controls/setting-row/setting-row.js +82 -15
  182. package/views/dist/controls/setting-row/tokens.d.ts +74 -2
  183. package/views/dist/controls/setting-row/tokens.js +19 -1
  184. package/views/dist/controls/setting-row.css +135 -14
  185. package/views/dist/controls/sheet/bottom-sheet.d.ts +14 -2
  186. package/views/dist/controls/sheet/bottom-sheet.js +6 -3
  187. package/views/dist/controls/sheet/map-sheet.js +1 -1
  188. package/views/dist/controls/sheet.css +4 -1
  189. package/views/dist/controls/sort-editor/map-sort-body.d.ts +1 -0
  190. package/views/dist/controls/sort-editor/map-sort-body.js +7 -3
  191. package/views/dist/controls/sort-editor/sort-editor.js +25 -26
  192. package/views/dist/controls/sort-editor.css +13 -2
  193. package/views/dist/controls/switch-row/tokens.d.ts +0 -12
  194. package/views/dist/controls/switch-row/tokens.js +0 -3
  195. package/views/dist/controls/switch-row.css +3 -7
  196. package/views/dist/controls/switch.css +17 -7
  197. package/views/dist/controls/tag/tag.d.ts +3 -1
  198. package/views/dist/controls/tag/tag.js +2 -2
  199. package/views/dist/controls/tag/tokens.d.ts +4 -0
  200. package/views/dist/controls/tag/tokens.js +1 -0
  201. package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
  202. package/views/dist/controls/tag-field/tag-field.js +11 -5
  203. package/views/dist/controls/tag-field/tokens.d.ts +16 -0
  204. package/views/dist/controls/tag-field/tokens.js +4 -0
  205. package/views/dist/controls/tag-field.css +19 -0
  206. package/views/dist/controls/tag.css +2 -0
  207. package/views/dist/controls/text-editor/text-editor.d.ts +1 -1
  208. package/views/dist/controls/text-editor/text-editor.js +8 -8
  209. package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
  210. package/views/dist/controls/toolbar/toolbar.js +22 -15
  211. package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
  212. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +52 -0
  213. package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
  214. package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
  215. package/views/dist/controls/toolbar-button.css +4 -0
  216. package/views/dist/controls/toolbar.css +5 -0
  217. package/views/dist/controls/values-editor/values-editor.d.ts +1 -1
  218. package/views/dist/controls/values-editor/values-editor.js +22 -22
  219. package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
  220. package/views/dist/controls/views-list/map-view-menu.js +25 -0
  221. package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
  222. package/views/dist/controls/views-list/map-views-list-body.js +39 -21
  223. package/views/dist/controls/views-list/rules.d.ts +2 -0
  224. package/views/dist/controls/views-list/view-menu.d.ts +7 -0
  225. package/views/dist/controls/views-list/view-menu.js +33 -29
  226. package/views/dist/controls/views-list/views-list.js +4 -4
  227. package/views/dist/controls/views-list/words.d.ts +2 -0
  228. package/views/dist/controls/views-list/words.js +1 -1
  229. package/views/dist/editors/EditorPanel.js +3 -2
  230. package/views/dist/editors/edit-session.js +2 -5
  231. package/views/dist/field-row/FieldRow.d.ts +4 -2
  232. package/views/dist/field-row/FieldRow.js +80 -20
  233. package/views/dist/field-row/FieldRowLane.d.ts +7 -2
  234. package/views/dist/field-row/FieldRowLane.js +4 -3
  235. package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
  236. package/views/dist/field-row/editors/RowEditor.js +31 -1
  237. package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
  238. package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
  239. package/views/dist/field-row/field-row-button.d.ts +5 -0
  240. package/views/dist/field-row/field-row-button.js +2 -0
  241. package/views/dist/fields/binding.d.ts +3 -2
  242. package/views/dist/fields/binding.js +38 -5
  243. package/views/dist/fields/money.d.ts +5 -2
  244. package/views/dist/fields/money.js +14 -2
  245. package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
  246. package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
  247. package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
  248. package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
  249. package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
  250. package/views/dist/grid/chrome/GridHeader.js +2 -2
  251. package/views/dist/grid/chrome/GridRow.js +6 -5
  252. package/views/dist/grid/chrome/GridRowCells.js +6 -9
  253. package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
  254. package/views/dist/grid/chrome/GridStructure.js +4 -4
  255. package/views/dist/grid/chrome/GridTable.js +9 -3
  256. package/views/dist/grid/chrome/cell-clipboard.d.ts +4 -2
  257. package/views/dist/grid/chrome/cell-clipboard.js +2 -2
  258. package/views/dist/grid/chrome/cells.js +3 -1
  259. package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
  260. package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
  261. package/views/dist/grid/chrome/grid-row-menu-items.js +93 -7
  262. package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
  263. package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
  264. package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
  265. package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
  266. package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
  267. package/views/dist/grid/chrome/useGridKeyboard.d.ts +7 -2
  268. package/views/dist/grid/chrome/useGridKeyboard.js +43 -14
  269. package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
  270. package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
  271. package/views/dist/grid/chrome/useGridTableInteractionModel.js +20 -7
  272. package/views/dist/grid/core/clipboard-model.d.ts +3 -1
  273. package/views/dist/grid/core/clipboard-model.js +9 -8
  274. package/views/dist/grid/core/commit-model.d.ts +20 -2
  275. package/views/dist/grid/core/editing-controller.d.ts +21 -0
  276. package/views/dist/grid/core/editing-controller.js +194 -42
  277. package/views/dist/grid/core/editing-model.d.ts +3 -0
  278. package/views/dist/grid/core/editing-model.js +3 -0
  279. package/views/dist/grid/core/edits-sink.d.ts +19 -0
  280. package/views/dist/grid/core/edits-sink.js +2 -0
  281. package/views/dist/grid/core/save-path.d.ts +24 -0
  282. package/views/dist/grid/core/save-path.js +122 -0
  283. package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
  284. package/views/dist/grid/core/spreadsheet-operations.js +24 -1
  285. package/views/dist/grid/core/useGridEditing.d.ts +5 -0
  286. package/views/dist/grid/core/useGridEditing.js +6 -0
  287. package/views/dist/grid/index.d.ts +3 -2
  288. package/views/dist/grid/index.js +1 -0
  289. package/views/dist/internal/field-rows.d.ts +26 -0
  290. package/views/dist/internal/field-rows.js +8 -0
  291. package/views/dist/internal/page-close.d.ts +7 -0
  292. package/views/dist/internal/page-close.js +43 -0
  293. package/views/dist/list/answer.d.ts +40 -0
  294. package/views/dist/list/answer.js +43 -0
  295. package/views/dist/list/browser-views-store.d.ts +10 -0
  296. package/views/dist/list/browser-views-store.js +182 -0
  297. package/views/dist/list/bulk-bar.d.ts +7 -0
  298. package/views/dist/list/bulk-bar.js +10 -0
  299. package/views/dist/list/columns.d.ts +24 -0
  300. package/views/dist/list/columns.js +27 -0
  301. package/views/dist/list/edits.d.ts +19 -0
  302. package/views/dist/list/edits.js +56 -0
  303. package/views/dist/list/grid.d.ts +11 -0
  304. package/views/dist/list/grid.js +76 -0
  305. package/views/dist/list/index.d.ts +36 -0
  306. package/views/dist/list/index.js +11 -0
  307. package/views/dist/list/link.d.ts +8 -0
  308. package/views/dist/list/link.js +78 -0
  309. package/views/dist/list/list.d.ts +70 -0
  310. package/views/dist/list/list.js +14 -0
  311. package/views/dist/list/menu.d.ts +31 -0
  312. package/views/dist/list/menu.js +76 -0
  313. package/views/dist/list/parts.d.ts +6 -0
  314. package/views/dist/list/parts.js +66 -0
  315. package/views/dist/list/registry.d.ts +11 -0
  316. package/views/dist/list/registry.js +31 -0
  317. package/views/dist/list/root-base.d.ts +46 -0
  318. package/views/dist/list/root-base.js +137 -0
  319. package/views/dist/list/root.d.ts +41 -0
  320. package/views/dist/list/root.js +168 -0
  321. package/views/dist/list/slot.d.ts +14 -0
  322. package/views/dist/list/slot.js +22 -0
  323. package/views/dist/list/source-answers.d.ts +39 -0
  324. package/views/dist/list/source-answers.js +225 -0
  325. package/views/dist/list/source.d.ts +11 -0
  326. package/views/dist/list/source.js +31 -0
  327. package/views/dist/list/store.d.ts +119 -0
  328. package/views/dist/list/store.js +146 -0
  329. package/views/dist/list/toolbar.d.ts +7 -0
  330. package/views/dist/list/toolbar.js +371 -0
  331. package/views/dist/list/views-axis.d.ts +5 -0
  332. package/views/dist/list/views-axis.js +98 -0
  333. package/views/dist/list/views-store.d.ts +41 -0
  334. package/views/dist/list/views-store.js +1 -0
  335. package/views/dist/list/views.d.ts +72 -0
  336. package/views/dist/list/views.js +411 -0
  337. package/views/dist/model/column-capabilities.d.ts +13 -0
  338. package/views/dist/model/column-capabilities.js +23 -2
  339. package/views/dist/model/column-schema.d.ts +11 -1
  340. package/views/dist/model/preferences.js +1 -1
  341. package/views/dist/model/prefs-buckets.js +1 -1
  342. package/views/dist/model/view-rules.js +1 -0
  343. package/views/dist/panels/index.d.ts +3 -1
  344. package/views/dist/panels/index.js +1 -0
  345. package/views/dist/panels/model.d.ts +2 -0
  346. package/views/dist/panels/react/customize-body.js +1 -0
  347. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +47 -4
  348. package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
  349. package/views/dist/panels/react/toolbar/Toolbar.d.ts +17 -2
  350. package/views/dist/panels/react/toolbar/Toolbar.js +43 -23
  351. package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
  352. package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
  353. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -4
  354. package/views/dist/panels/react/toolbar/ToolbarButton.js +7 -1
  355. package/views/dist/panels/react/toolbar/ToolbarFilter.js +1 -1
  356. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -1
  357. package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +1 -1
  358. package/views/dist/panels/react/toolbar/ToolbarFilters.js +2 -2
  359. package/views/dist/panels/react/toolbar/ToolbarNew.js +2 -2
  360. package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
  361. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
  362. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
  363. package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
  364. package/views/dist/panels/react/toolbar/ToolbarSort.js +2 -2
  365. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
  366. package/views/dist/panels/react/toolbar/context.d.ts +20 -3
  367. package/views/dist/panels/react/toolbar/context.js +3 -1
  368. package/views/dist/panels/react/toolbar/panel-part.d.ts +4 -1
  369. package/views/dist/panels/react/toolbar/panel-part.js +5 -3
  370. package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
  371. package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
  372. package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
  373. package/views/dist/panels/react/views-row/PillGroup.js +16 -7
  374. package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
  375. package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
  376. package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
  377. package/views/dist/panels/react.d.ts +2 -2
  378. package/views/dist/panels/settings/filter-groups.js +6 -1
  379. package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
  380. package/views/dist/panels/toolbar/edit-view.js +14 -0
  381. package/views/dist/panels/toolbar/model.d.ts +5 -0
  382. package/views/dist/panels/toolbar/model.js +7 -3
  383. package/views/dist/panels/view-state.d.ts +5 -3
  384. package/views/dist/panels/views-row/model.d.ts +19 -2
  385. package/views/dist/panels/views-row/model.js +14 -0
  386. package/views/dist/provider/ViewsProvider.d.ts +21 -8
  387. package/views/dist/provider/ViewsProvider.js +40 -5
  388. package/views/dist/provider/components.d.ts +102 -2
  389. package/views/dist/provider/components.js +1 -1
  390. package/views/dist/provider/context.d.ts +6 -2
  391. package/views/dist/provider/context.js +1 -1
  392. package/views/dist/provider/own-control.d.ts +4 -0
  393. package/views/dist/provider/own-control.js +7 -0
  394. package/views/dist/provider/ports.d.ts +19 -12
  395. package/views/dist/provider/ports.js +69 -1
  396. package/views/dist/provider/select-items.d.ts +3 -0
  397. package/views/dist/provider/select-items.js +6 -0
  398. package/views/dist/react.d.ts +4 -2
  399. package/views/dist/react.js +2 -0
  400. package/views/dist/styles.css +503 -136
  401. package/views/dist/styles.unlayered.css +503 -136
  402. package/views/docs/contract.md +292 -34
  403. package/views/docs/controls/avatar.md +11 -0
  404. package/views/docs/controls/choice.md +0 -1
  405. package/views/docs/controls/compound-editor.md +4 -0
  406. package/views/docs/controls/customize.md +6 -0
  407. package/views/docs/controls/date-editor.md +4 -0
  408. package/views/docs/controls/field.md +7 -0
  409. package/views/docs/controls/filter-editor.md +8 -0
  410. package/views/docs/controls/group-editor.md +6 -0
  411. package/views/docs/controls/input.md +5 -0
  412. package/views/docs/controls/links-editor.md +4 -0
  413. package/views/docs/controls/menu-list.md +8 -0
  414. package/views/docs/controls/menu.md +4 -0
  415. package/views/docs/controls/notice.md +4 -0
  416. package/views/docs/controls/number-editor.md +4 -0
  417. package/views/docs/controls/pane.md +4 -0
  418. package/views/docs/controls/picker.md +8 -0
  419. package/views/docs/controls/quick-filters.md +6 -0
  420. package/views/docs/controls/radio.md +20 -1
  421. package/views/docs/controls/select.md +10 -0
  422. package/views/docs/controls/setting-row.md +18 -0
  423. package/views/docs/controls/sheet.md +4 -0
  424. package/views/docs/controls/sort-editor.md +8 -0
  425. package/views/docs/controls/switch-row.md +0 -3
  426. package/views/docs/controls/tag-field.md +4 -0
  427. package/views/docs/controls/tag.md +1 -0
  428. package/views/docs/controls/text-editor.md +4 -0
  429. package/views/docs/controls/values-editor.md +4 -0
  430. package/views/docs/controls/views-list.md +6 -0
  431. package/views/docs/getting-started.md +2 -2
  432. package/views/docs/guides/atoms.md +2 -2
  433. package/views/docs/guides/columns.md +1 -1
  434. package/views/docs/guides/ports.md +1 -1
  435. package/views/docs/guides/the-grid.md +36 -9
  436. package/views/docs/guides/the-provider.md +22 -3
  437. package/views/docs/index.md +1 -0
  438. package/views/docs/reference/controls.md +41 -29
  439. package/views/docs/reference/editors-session.md +1 -1
  440. package/views/docs/reference/field-row.md +9 -1
  441. package/views/docs/reference/grid.md +15 -9
  442. package/views/docs/reference/list.md +357 -0
  443. package/views/docs/reference/looks.md +1 -1
  444. package/views/docs/reference/panels-react.md +17 -12
  445. package/views/docs/reference/panels.md +8 -5
  446. package/views/docs/reference/react.md +24 -16
  447. package/views/docs/reference/views.md +10 -6
  448. package/views/docs/reshaping.md +6 -1
  449. package/views/skills/views/SKILL.md +9 -6
@@ -76,6 +76,9 @@ export function useGridEditing(onCellCommit, onCellsCommit, onRefused, keepsSent
76
76
  const undo = useCallback((resolveRow, onApply) => applyHistory("undo", resolveRow, onApply), [applyHistory]);
77
77
  const redo = useCallback((resolveRow, onApply) => applyHistory("redo", resolveRow, onApply), [applyHistory]);
78
78
  const reconcile = useCallback((matchedKeys) => controller.reconcile(matchedKeys), [controller]);
79
+ const canUndo = useCallback(() => controller.canUndo(), [controller]);
80
+ const canRedo = useCallback(() => controller.canRedo(), [controller]);
81
+ const saving = useCallback(() => controller.saving(), [controller]);
79
82
  const hasInflight = useCallback((rowId, columnId) => controller.hasInflight(rowId, columnId), [controller]);
80
83
  const pendingBaseline = useCallback((rowId, columnId) => controller.pendingBaseline(rowId, columnId), [controller]);
81
84
  const pendingOf = useCallback((rowId) => controller.getPendingByRow().get(rowId), [controller]);
@@ -99,6 +102,9 @@ export function useGridEditing(onCellCommit, onCellsCommit, onRefused, keepsSent
99
102
  undo,
100
103
  redo,
101
104
  reconcile,
105
+ canUndo,
106
+ canRedo,
107
+ saving,
102
108
  hasInflight,
103
109
  pendingBaseline,
104
110
  sent,
@@ -15,8 +15,9 @@ export type { GridGroupByState, GridSortState } from "./chrome/GridColumnMenu.js
15
15
  export type { GridGroupSortOption } from "./chrome/GridGroupMenu.js";
16
16
  export type { GridGroupMenuPart } from "./chrome/grid-group-menu-parts.js";
17
17
  export type { GridRowOpenedFrom } from "./core/row-opened-from.js";
18
- export type { GridCellAt, GridCellPick, GridDeclaredFigure, GridDrawnFigure, GridGroupFigure, GridPages, GroupCountNoun, } from "./chrome/grid-table-props.js";
19
- export type { GridCellCommitFn, GridCellsCommitFn, GridCommitContext, GridCommitOutcome, } from "./core/commit-model.js";
18
+ export type { GridCellAt, GridCellPick, GridDeclaredFigure, GridDrawnFigure, GridGroupFigure, GridMenus, GridPages, GroupCountNoun, } from "./chrome/grid-table-props.js";
19
+ export type { GridCellCommitFn, GridCellsCommitFn, GridCommitContext, GridCommitOutcome, ListChange, ListSave, } from "./core/commit-model.js";
20
+ export { gridSave, type GridSaveOptions } from "./core/save-path.js";
20
21
  export { deriveGridRelationValues, deriveGridSelectValues } from "./core/column-values.js";
21
22
  export { cellCopyText, cellEditBaseline } from "./core/clipboard-model.js";
22
23
  export { GRID_TITLE_LINK_CLASS } from "./chrome/grid-cell-classes.js";
@@ -1,6 +1,7 @@
1
1
  export { useGridTablePrefs } from "./useGridTablePrefs.js";
2
2
  export { useGridTableSettings } from "./useGridTableSettings.js";
3
3
  export { GridTable } from "./chrome/GridTable.js";
4
+ export { gridSave } from "./core/save-path.js";
4
5
  export { deriveGridRelationValues, deriveGridSelectValues } from "./core/column-values.js";
5
6
  export { cellCopyText, cellEditBaseline } from "./core/clipboard-model.js";
6
7
  export { GRID_TITLE_LINK_CLASS } from "./chrome/grid-cell-classes.js";
@@ -0,0 +1,26 @@
1
+ import * as React from "react";
2
+ /** Field rows' card, as a Field in it sees it: where its note and error go, under the card. */
3
+ export interface FieldRowsCard {
4
+ /** A Field joins the card as it comes, and leaves it as it goes: the foot keeps its Fields' notes in that order, the rows'. */
5
+ enter(id: string): () => void;
6
+ /** A Field says whether it has a note or an error to show under the card; the card draws its foot while any does. */
7
+ need(id: string, on: boolean): void;
8
+ /** The Field's own place in the foot, once drawn: it portals its note and error into it. */
9
+ slot(id: string): HTMLElement | null;
10
+ }
11
+ export declare const FieldRowsCardContext: React.Context<FieldRowsCard | null>;
12
+ /** True inside a computer's SettingRows whose Fields option is At the end (VK-985): a Field placed in it is one of its rows, its
13
+ * control at the row's end. */
14
+ export declare const SettingRowField: React.Context<boolean>;
15
+ /** What stands at the end of such a Field row, and the row's name when its label is words: a RadioGroup there draws as a Select
16
+ * of its Radios, named by it. */
17
+ export declare const AtSettingRowEnd: React.Context<{
18
+ name?: string;
19
+ } | null>;
20
+ /** True inside a Field drawn as a row of Field rows: its Input or InputGroup stands typed in place, with no box. */
21
+ export declare const InFieldRow: React.Context<boolean>;
22
+ /** A place of its own: what it holds stands as it does anywhere else, no row of a Field rows card around it, whatever holds it.
23
+ * A popup, an editor and a record's row are each one (React's context reaches through a portal). */
24
+ export declare function OutOfFieldRows({ children }: {
25
+ children?: React.ReactNode;
26
+ }): React.ReactNode;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ export const FieldRowsCardContext = React.createContext(null);
3
+ export const SettingRowField = React.createContext(false);
4
+ export const AtSettingRowEnd = React.createContext(null);
5
+ export const InFieldRow = React.createContext(false);
6
+ export function OutOfFieldRows({ children }) {
7
+ return React.createElement(FieldRowsCardContext.Provider, { value: null }, React.createElement(InFieldRow.Provider, { value: false }, React.createElement(SettingRowField.Provider, { value: false }, React.createElement(AtSettingRowEnd.Provider, { value: null }, children))));
8
+ }
@@ -0,0 +1,7 @@
1
+ export type PageClosePhase = "drafts" | "sends";
2
+ /** Whether the page is going: from its `pagehide` until a `pageshow` brings it back (the back-forward cache). False
3
+ * where there is no window. */
4
+ export declare function isPageClosing(): boolean;
5
+ /** Calls `flush` inside the page's `pagehide`, synchronously, in the order the flushes were added: every `"drafts"`
6
+ * flush, then every `"sends"` one. Returns what takes it off. Nothing where there is no window. */
7
+ export declare function onPageClose(flush: () => void, phase?: PageClosePhase): () => void;
@@ -0,0 +1,43 @@
1
+ let closing = false;
2
+ let listening = false;
3
+ const flushes = { drafts: [], sends: [] };
4
+ function onHide() {
5
+ closing = true;
6
+ for (const phase of ["drafts", "sends"]) {
7
+ for (const flush of [...flushes[phase]]) {
8
+ try {
9
+ flush();
10
+ }
11
+ catch (error) {
12
+ queueMicrotask(() => {
13
+ throw error;
14
+ });
15
+ }
16
+ }
17
+ }
18
+ }
19
+ function onShow() {
20
+ closing = false;
21
+ }
22
+ function listen() {
23
+ if (listening || typeof window === "undefined")
24
+ return;
25
+ listening = true;
26
+ window.addEventListener("pagehide", onHide, { capture: true });
27
+ window.addEventListener("pageshow", onShow, { capture: true });
28
+ }
29
+ export function isPageClosing() {
30
+ listen();
31
+ return closing;
32
+ }
33
+ export function onPageClose(flush, phase = "sends") {
34
+ listen();
35
+ if (typeof window === "undefined")
36
+ return () => { };
37
+ flushes[phase].push(flush);
38
+ return () => {
39
+ const at = flushes[phase].indexOf(flush);
40
+ if (at >= 0)
41
+ flushes[phase].splice(at, 1);
42
+ };
43
+ }
@@ -0,0 +1,40 @@
1
+ import type { FieldConventions } from "viewkitjs/fields";
2
+ import { type ListHold, type ListRow, type ListSettings, type ListTotal } from "viewkitjs/fields/query";
3
+ import type { ListGroup } from "../grouping/types.js";
4
+ import type { FieldBinding } from "../fields/binding.js";
5
+ import type { ListColumn } from "../model/column-schema.js";
6
+ import type { PanelGroupHead, SettingsPanelsInput } from "../panels/settings/input.js";
7
+ import type { ListFieldsRegistry } from "./columns.js";
8
+ /** The values a list's filter offers. */
9
+ export type ListFilterValues = NonNullable<SettingsPanelsInput<ListRow>["filterData"]>;
10
+ /** The rows a list shows, as its root keeps them. */
11
+ export type ListAnswerState<Row extends ListRow = ListRow> = {
12
+ /** The groups the grid draws (one group keyed "all" with label null when the list isn't grouped). */
13
+ groups: ListGroup<Row>[];
14
+ grouped: boolean;
15
+ /** Every bucket's head, hidden ones included, for the group panel. */
16
+ groupHeads: PanelGroupHead[];
17
+ /** The rows in hand, in the order drawn: the selection's order. */
18
+ ids: readonly string[];
19
+ /** How many rows match (rows in memory: `{ count, exact: true }`); null while unknown. */
20
+ total: ListTotal | null;
21
+ /** The values the filter offers. */
22
+ filterValues: ListFilterValues;
23
+ /** A source's first page is out, for the newest settings (always false in memory). */
24
+ loading: boolean;
25
+ /** The source's refusal, in its own words; null, none. */
26
+ refused: string | null;
27
+ /** What there is still to load: the ungrouped list's next page, and each group's (a source's; none in memory). */
28
+ more: {
29
+ rows: boolean;
30
+ groups: Readonly<Record<string, boolean>>;
31
+ };
32
+ /** The rows come a page at a time, from a source: the rows in hand aren't every matching row. */
33
+ paged: boolean;
34
+ /** Each saved view's count, where a source answered them; null, none. */
35
+ viewCounts: Readonly<Record<string, number>> | null;
36
+ /** Each quick filter's values counted, by field and value, where a source answered them; null, none. */
37
+ holdCounts: Readonly<Record<string, Readonly<Record<string, number>>>> | null;
38
+ };
39
+ /** What a list's settings ask of the rows it holds. */
40
+ export declare function answerInMemory<Row extends ListRow>(rows: readonly Row[], settings: ListSettings, fields: ListFieldsRegistry, columns: ListColumn<Row>[], conventions?: FieldConventions, bindings?: Readonly<Record<string, FieldBinding<Row>>>, hold?: ListHold): ListAnswerState<Row>;
@@ -0,0 +1,43 @@
1
+ import { evaluateView } from "viewkitjs/fields/query";
2
+ import { deriveGridSelectValues } from "../grid/core/column-values.js";
3
+ const NO_MORE = { rows: false, groups: {} };
4
+ export function answerInMemory(rows, settings, fields, columns, conventions, bindings, hold) {
5
+ const keys = Object.keys(fields);
6
+ const { rows: kept, buckets } = evaluateView(rows, {
7
+ filter: settings.filter,
8
+ search: settings.search ? { text: settings.search, fields: keys } : undefined,
9
+ sorts: settings.sorts,
10
+ group: settings.group,
11
+ ...(hold?.length && { hold }),
12
+ ...(settings.rowOrderMode && { rowOrderMode: settings.rowOrderMode }),
13
+ ...(settings.itemPositions && { itemPositions: settings.itemPositions }),
14
+ }, {
15
+ fieldOf: (key) => fields[key],
16
+ read: (row, key) => {
17
+ const binding = bindings?.[key];
18
+ return binding ? binding.read(row) : row[key];
19
+ },
20
+ }, { ...(conventions && { conventions }), rowId: (row) => row.id });
21
+ const groups = buckets
22
+ ? buckets.filter((bucket) => !bucket.hidden).map((bucket) => ({ key: bucket.key, label: bucket.label, items: bucket.items }))
23
+ : [{ key: "all", label: null, items: kept }];
24
+ return {
25
+ groups,
26
+ grouped: !!buckets,
27
+ groupHeads: (buckets ?? []).map((bucket) => ({
28
+ key: bucket.key,
29
+ label: bucket.label,
30
+ count: bucket.items.length,
31
+ hidden: bucket.hidden,
32
+ })),
33
+ ids: groups.flatMap((group) => group.items.map((row) => row.id)),
34
+ total: { count: kept.length, exact: true },
35
+ filterValues: { selectValues: deriveGridSelectValues(columns, rows), relationValues: {} },
36
+ loading: false,
37
+ refused: null,
38
+ more: NO_MORE,
39
+ paged: false,
40
+ viewCounts: null,
41
+ holdCounts: null,
42
+ };
43
+ }
@@ -0,0 +1,10 @@
1
+ import type { ViewSeed, ViewsStore } from "./views-store.js";
2
+ export type BrowserViewsStoreOptions = {
3
+ /** The entries' prefix: a list's entry is `${key}:${listId}`. Default "vk:views". */
4
+ key?: string;
5
+ /** The app's own views, by list id: listed first, shared, read-only. */
6
+ seed?: Readonly<Record<string, readonly ViewSeed[]>>;
7
+ /** Where it keeps them; default `window.localStorage` where there is one. `null`: in memory, for the page's life. */
8
+ storage?: Pick<Storage, "getItem" | "setItem"> | null;
9
+ };
10
+ export declare function browserViewsStore(options?: BrowserViewsStoreOptions): ViewsStore;
@@ -0,0 +1,182 @@
1
+ import { listPersonalLayerSchema, listSettingsChangeSchema, savedViewSchema, settingsForSaving, } from "viewkitjs/fields/query";
2
+ const EPOCH = "1970-01-01T00:00:00.000Z";
3
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4
+ function readEntry(raw) {
5
+ const entry = { views: [], drafts: {}, layer: {} };
6
+ if (!raw)
7
+ return entry;
8
+ let held;
9
+ try {
10
+ held = JSON.parse(raw);
11
+ }
12
+ catch {
13
+ return entry;
14
+ }
15
+ if (!isObject(held) || held.v !== 1)
16
+ return entry;
17
+ if (Array.isArray(held.views)) {
18
+ for (const view of held.views) {
19
+ const read = savedViewSchema.safeParse(view);
20
+ if (read.success && read.data.scope === "personal" && !read.data.readOnly)
21
+ entry.views.push(read.data);
22
+ }
23
+ }
24
+ if (isObject(held.drafts)) {
25
+ for (const [id, draft] of Object.entries(held.drafts)) {
26
+ if (!isObject(draft) || typeof draft.base !== "string")
27
+ continue;
28
+ const change = listSettingsChangeSchema.safeParse(draft.change);
29
+ if (!change.success)
30
+ continue;
31
+ const { search: _search, ...kept } = change.data;
32
+ entry.drafts[id] = { change: kept, base: draft.base };
33
+ }
34
+ }
35
+ const layer = listPersonalLayerSchema.safeParse(held.layer);
36
+ if (layer.success)
37
+ entry.layer = layer.data;
38
+ return entry;
39
+ }
40
+ function refused(what, error) {
41
+ const issue = error.issues[0];
42
+ const where = issue?.path.length ? ` (${issue.path.map(String).join(".")})` : "";
43
+ return new Error(`${what}: ${issue?.message ?? "it doesn't read"}${where}`);
44
+ }
45
+ function defaultStorage() {
46
+ try {
47
+ return typeof window === "undefined" ? null : window.localStorage;
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ export function browserViewsStore(options = {}) {
54
+ const prefix = options.key ?? "vk:views";
55
+ const storage = options.storage === undefined ? defaultStorage() : options.storage;
56
+ const kept = new Map();
57
+ const readers = new Map();
58
+ const keyOf = (listId) => `${prefix}:${listId}`;
59
+ const raw = (key) => {
60
+ if (kept.has(key))
61
+ return kept.get(key);
62
+ try {
63
+ return storage?.getItem(key) ?? null;
64
+ }
65
+ catch {
66
+ return null;
67
+ }
68
+ };
69
+ const read = (listId) => readEntry(raw(keyOf(listId)));
70
+ const write = (listId, entry) => {
71
+ const key = keyOf(listId);
72
+ const text = JSON.stringify({ v: 1, ...entry });
73
+ try {
74
+ if (!storage)
75
+ throw new Error("no storage");
76
+ storage.setItem(key, text);
77
+ kept.delete(key);
78
+ }
79
+ catch {
80
+ kept.set(key, text);
81
+ }
82
+ for (const reader of [...(readers.get(listId) ?? [])])
83
+ reader();
84
+ };
85
+ const seedsOf = (listId) => (options.seed?.[listId] ?? []).map((seed, position) => ({
86
+ id: seed.id,
87
+ name: seed.name,
88
+ scope: "shared",
89
+ settings: settingsForSaving(seed.settings),
90
+ position,
91
+ updatedAt: EPOCH,
92
+ readOnly: true,
93
+ }));
94
+ const byPosition = (a, b) => a.position - b.position;
95
+ return {
96
+ list: (listId) => [...seedsOf(listId), ...read(listId).views.sort(byPosition)],
97
+ save: (listId, view) => {
98
+ if (view.scope !== "personal")
99
+ throw new Error("the browser store keeps only a person's own views");
100
+ if (view.id !== undefined && seedsOf(listId).some((seed) => seed.id === view.id)) {
101
+ throw new Error(`${view.id} is declared by the app and can't be changed`);
102
+ }
103
+ const entry = read(listId);
104
+ const was = view.id === undefined ? undefined : entry.views.find((held) => held.id === view.id);
105
+ const last = entry.views.reduce((most, held) => Math.max(most, held.position), -1);
106
+ let stamp = Date.now();
107
+ if (was && stamp <= Date.parse(was.updatedAt))
108
+ stamp = Date.parse(was.updatedAt) + 1;
109
+ const checked = savedViewSchema.safeParse({
110
+ id: view.id ?? globalThis.crypto.randomUUID(),
111
+ name: view.name,
112
+ scope: "personal",
113
+ settings: settingsForSaving(view.settings),
114
+ position: view.id !== undefined ? view.position : last + 1,
115
+ updatedAt: new Date(stamp).toISOString(),
116
+ });
117
+ if (!checked.success)
118
+ throw refused("This view can't be saved", checked.error);
119
+ const saved = checked.data;
120
+ entry.views = was ? entry.views.map((held) => (held.id === saved.id ? saved : held)) : [...entry.views, saved];
121
+ write(listId, entry);
122
+ return saved;
123
+ },
124
+ remove: (listId, id) => {
125
+ const entry = read(listId);
126
+ entry.views = entry.views.filter((held) => held.id !== id);
127
+ delete entry.drafts[id];
128
+ write(listId, entry);
129
+ },
130
+ reorder: (listId, scope, ids) => {
131
+ if (scope !== "personal")
132
+ return;
133
+ const entry = read(listId);
134
+ entry.views = entry.views.map((held) => (ids.includes(held.id) ? { ...held, position: ids.indexOf(held.id) } : held));
135
+ write(listId, entry);
136
+ },
137
+ subscribe: (listId, onChange) => {
138
+ const own = readers.get(listId) ?? new Set();
139
+ readers.set(listId, own);
140
+ own.add(onChange);
141
+ const key = keyOf(listId);
142
+ const heard = (event) => {
143
+ if (event.key === null || event.key === key)
144
+ onChange();
145
+ };
146
+ if (typeof window !== "undefined")
147
+ window.addEventListener("storage", heard);
148
+ return () => {
149
+ own.delete(onChange);
150
+ if (typeof window !== "undefined")
151
+ window.removeEventListener("storage", heard);
152
+ };
153
+ },
154
+ draft: {
155
+ get: (listId, viewId) => read(listId).drafts[viewId] ?? null,
156
+ set: (listId, viewId, draft) => {
157
+ const entry = read(listId);
158
+ if (draft) {
159
+ const checked = listSettingsChangeSchema.safeParse(draft.change);
160
+ if (!checked.success)
161
+ throw refused("This change can't be kept", checked.error);
162
+ const { search: _search, ...change } = checked.data;
163
+ entry.drafts[viewId] = { change, base: draft.base };
164
+ }
165
+ else
166
+ delete entry.drafts[viewId];
167
+ write(listId, entry);
168
+ },
169
+ },
170
+ layer: {
171
+ get: (listId) => read(listId).layer,
172
+ set: (listId, layer) => {
173
+ const checked = listPersonalLayerSchema.safeParse(layer);
174
+ if (!checked.success)
175
+ throw refused("These widths and folds can't be kept", checked.error);
176
+ const entry = read(listId);
177
+ entry.layer = checked.data;
178
+ write(listId, entry);
179
+ },
180
+ },
181
+ };
182
+ }
@@ -0,0 +1,7 @@
1
+ import type { ReactNode } from "react";
2
+ import { type SelectionBarProps } from "../selection/SelectionBar.js";
3
+ /** `SelectionBar`'s props but the count and the clear, which the root holds; `verbs` default none. */
4
+ export type ListBulkBarProps = Omit<SelectionBarProps, "count" | "onClear" | "verbs"> & {
5
+ verbs?: SelectionBarProps["verbs"];
6
+ };
7
+ export declare function ListBulkBar({ verbs, ...own }: ListBulkBarProps): ReactNode;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { SelectionBar } from "../selection/SelectionBar.js";
4
+ import { useList } from "./root.js";
5
+ const NONE = [];
6
+ export function ListBulkBar({ verbs = NONE, ...own }) {
7
+ const count = useList((s) => s.selection.count) ?? 0;
8
+ const select = useList((s) => s.select);
9
+ return _jsx(SelectionBar, { ...own, verbs: verbs, count: count, onClear: () => select([]) });
10
+ }
@@ -0,0 +1,24 @@
1
+ import type { FieldDef } from "viewkitjs/fields";
2
+ import { type ListRow, type ListSettings } from "viewkitjs/fields/query";
3
+ import { type FieldBinding, type FieldBindingSpec } from "../fields/binding.js";
4
+ import type { ListColumn } from "../model/column-schema.js";
5
+ /** A list's fields: what `defineFields` returns. */
6
+ export type ListFieldsRegistry = Readonly<Record<string, FieldDef>>;
7
+ /** One column's change over what the fields give it. `editable: false` only takes an edit away. `bind`: how the field
8
+ * reads and writes the row, where its key doesn't say (`bindFields`' spec); absent, bound by its key. */
9
+ export type ListColumnOverride<Row = ListRow> = {
10
+ width?: number;
11
+ hidden?: boolean;
12
+ editable?: boolean;
13
+ header?: string;
14
+ bind?: FieldBindingSpec<Row, FieldDef>;
15
+ };
16
+ /** Columns changed by their field's key. */
17
+ export type ListColumnsOverride<Row = ListRow> = Readonly<Record<string, ListColumnOverride<Row>>>;
18
+ export type ListColumnsOf<Row> = {
19
+ columns: ListColumn<Row>[];
20
+ bindings: Readonly<Record<string, FieldBinding<Row>>>;
21
+ /** `LIST_SETTINGS_DEFAULTS` with every field's column, in the registry's order, `visible: !hidden`. */
22
+ defaults: ListSettings;
23
+ };
24
+ export declare function columnsOf<Row extends ListRow>(fields: ListFieldsRegistry, overrides: ListColumnsOverride<Row> | undefined, writable: boolean): ListColumnsOf<Row>;
@@ -0,0 +1,27 @@
1
+ import { LIST_SETTINGS_DEFAULTS } from "viewkitjs/fields/query";
2
+ import { bindFields } from "../fields/binding.js";
3
+ import { columnFrom } from "../model/column-from.js";
4
+ export function columnsOf(fields, overrides, writable) {
5
+ const keys = Object.keys(fields);
6
+ const specs = {};
7
+ for (const key of keys) {
8
+ const bind = overrides?.[key]?.bind;
9
+ if (bind)
10
+ specs[key] = bind;
11
+ }
12
+ const bindings = bindFields(fields, specs);
13
+ const columns = keys.map((key) => {
14
+ const own = overrides?.[key];
15
+ return columnFrom(bindings[key], {
16
+ id: key,
17
+ ...(own?.width !== undefined && { width: own.width }),
18
+ ...(own?.header !== undefined && { header: own.header }),
19
+ ...((!writable || own?.editable === false) && { editable: false }),
20
+ });
21
+ });
22
+ const defaults = {
23
+ ...LIST_SETTINGS_DEFAULTS,
24
+ columns: keys.map((key) => ({ key, visible: !overrides?.[key]?.hidden })),
25
+ };
26
+ return { columns, bindings, defaults };
27
+ }
@@ -0,0 +1,19 @@
1
+ import type { ListRow } from "viewkitjs/fields/query";
2
+ import type { FieldBinding } from "../fields/binding.js";
3
+ import type { GridCellCommitFn, GridCellsCommitFn, ListSave } from "../grid/core/commit-model.js";
4
+ import type { GridEditsSink } from "../grid/core/edits-sink.js";
5
+ import type { ListStore } from "./store.js";
6
+ export type ListCommits<Row> = {
7
+ onCellCommit: GridCellCommitFn<Row>;
8
+ onCellsCommit: GridCellsCommitFn<Row>;
9
+ };
10
+ /** The root's commits, for the grid under it; null where the list doesn't write. */
11
+ export declare const ListCommitsContext: import("react").Context<ListCommits<ListRow> | null>;
12
+ /** The root's sink, for the grid under it. */
13
+ export declare const ListEditsSinkContext: import("react").Context<GridEditsSink | null>;
14
+ /** `gridSave` made once over the latest `save` and the latest bindings: its queues live in what one call returns.
15
+ * Null when the list doesn't write (no `save`, or `can.edit` false). */
16
+ export declare function useListCommits<Row extends ListRow>(save: ListSave<Row> | undefined, writable: boolean, bindings: Readonly<Record<string, FieldBinding<Row>>> | null): ListCommits<Row> | null;
17
+ /** The sink the root hands its grid: the grid's undo and redo wired into the store, its edits' state patched in on each
18
+ * change, and all of it let go when the grid leaves. */
19
+ export declare function useListEditsSink(store: ListStore): GridEditsSink;
@@ -0,0 +1,56 @@
1
+ import { createContext, useMemo, useRef, useLayoutEffect, useState } from "react";
2
+ import { gridSave } from "../grid/core/save-path.js";
3
+ export const ListCommitsContext = createContext(null);
4
+ export const ListEditsSinkContext = createContext(null);
5
+ const NO_EDITS = { saving: false, canUndo: false, canRedo: false };
6
+ function valuesOf(bindings, row, columnId, value) {
7
+ const write = bindings[columnId]?.write;
8
+ if (!write)
9
+ throw new Error(`${columnId} can't be edited`);
10
+ const patch = write(row, value);
11
+ if ("skip" in patch)
12
+ throw new Error(patch.reason ?? "This change can't be saved.");
13
+ return patch.body;
14
+ }
15
+ export function useListCommits(save, writable, bindings) {
16
+ const latest = useRef({ save, bindings });
17
+ useLayoutEffect(() => {
18
+ latest.current = { save, bindings };
19
+ });
20
+ const [commits] = useState(() => commitsOver(latest));
21
+ return writable && !!save && !!bindings ? commits : null;
22
+ }
23
+ function commitsOver(latest) {
24
+ return gridSave((change) => latest.current.save?.(change) ?? Promise.reject(new Error("This list no longer saves.")), {
25
+ getRowId: (row) => row.id,
26
+ values: (row, columnId, value) => valuesOf(latest.current.bindings ?? {}, row, columnId, value),
27
+ read: (row, columnId) => {
28
+ const binding = latest.current.bindings?.[columnId];
29
+ return binding ? binding.read(row) : row[columnId];
30
+ },
31
+ });
32
+ }
33
+ export function useListEditsSink(store) {
34
+ return useMemo(() => editsSinkOf(store), [store]);
35
+ }
36
+ function editsSinkOf(store) {
37
+ let handle = null;
38
+ return {
39
+ attach: (next) => {
40
+ handle = next;
41
+ store.wire({ undo: () => void next.undo(), redo: () => void next.redo() });
42
+ store.patch({ edits: next.state() });
43
+ return () => {
44
+ if (handle !== next)
45
+ return;
46
+ handle = null;
47
+ store.wire({ undo: undefined, redo: undefined });
48
+ store.patch({ edits: NO_EDITS });
49
+ };
50
+ },
51
+ changed: () => {
52
+ if (handle)
53
+ store.patch({ edits: handle.state() });
54
+ },
55
+ };
56
+ }
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ListRow } from "viewkitjs/fields/query";
3
+ import type { GridTableProps } from "../grid/chrome/grid-table-props.js";
4
+ /** What the root draws for the grid: every `GridTable` prop is the app's to hand too, and wins over the root's. A
5
+ * `selection` handed is the app's own: the root's picks then stop following the grid, and the children (`ListBulkBar`)
6
+ * aren't drawn. */
7
+ export type ListGridProps<Row extends ListRow> = Partial<GridTableProps<Row>> & {
8
+ /** Drawn where the grid places its selection bar (`ListBulkBar`). */
9
+ children?: ReactNode;
10
+ };
11
+ export declare function ListGrid<Row extends ListRow>({ children, ...own }: ListGridProps<Row>): ReactNode;
@@ -0,0 +1,76 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useCallback, useContext, useLayoutEffect, useMemo, useState } from "react";
4
+ import { GridTable } from "../grid/chrome/GridTable.js";
5
+ import { GridEditsSinkContext } from "../grid/core/edits-sink.js";
6
+ import { useGridTableSettings } from "../grid/useGridTableSettings.js";
7
+ import { LIST_VIEW_PREF_DEFAULTS } from "../model/preferences.js";
8
+ import { settingsPanels } from "../panels/settings/settings-panels.js";
9
+ import { useViews } from "../provider/context.js";
10
+ import { ListCommitsContext, ListEditsSinkContext } from "./edits.js";
11
+ import { useList, useListStore } from "./root.js";
12
+ const FORMATS = {
13
+ gridOptionColors: LIST_VIEW_PREF_DEFAULTS.gridOptionColors,
14
+ gridDateStyles: LIST_VIEW_PREF_DEFAULTS.gridDateStyles,
15
+ gridDurationStyles: LIST_VIEW_PREF_DEFAULTS.gridDurationStyles,
16
+ gridShowTime: LIST_VIEW_PREF_DEFAULTS.gridShowTime,
17
+ gridPercentDisplays: LIST_VIEW_PREF_DEFAULTS.gridPercentDisplays,
18
+ gridDecimals: LIST_VIEW_PREF_DEFAULTS.gridDecimals,
19
+ gridCurrencies: LIST_VIEW_PREF_DEFAULTS.gridCurrencies,
20
+ };
21
+ const getRowId = (row) => row.id;
22
+ const noop = () => { };
23
+ export function ListGrid({ children, ...own }) {
24
+ const store = useListStore();
25
+ const answer = useList((s) => s.answer);
26
+ const rootColumns = useList((s) => s.columns);
27
+ const settings = useList((s) => s.view.settings);
28
+ const layer = useList((s) => s.view.layer);
29
+ const onChange = useList((s) => s.setSettings);
30
+ const onLayerChange = useList((s) => s.setLayer);
31
+ const commits = useContext(ListCommitsContext);
32
+ const sink = useContext(ListEditsSinkContext);
33
+ const handedColumns = own.columns;
34
+ const columns = useMemo(() => handedColumns ?? rootColumns ?? [], [handedColumns, rootColumns]);
35
+ const [formats, setFormatsState] = useState(FORMATS);
36
+ const setFormats = useCallback((patch) => setFormatsState((held) => ({ ...held, ...patch })), []);
37
+ const { gridProps } = useGridTableSettings({ settings, layer, columns, onChange, onLayerChange, formats, setFormats });
38
+ const panels = useMemo(() => settingsPanels({ settings, layer, columns, onChange, onLayerChange, severalSorts: true }), [settings, layer, columns, onChange, onLayerChange]);
39
+ const folded = useMemo(() => new Set(layer.folded ?? []), [layer.folded]);
40
+ const toggleGroup = useCallback((key) => onLayerChange({ folded: folded.has(key) ? [...folded].filter((held) => held !== key) : [...folded, key] }), [folded, onLayerChange]);
41
+ const resetKey = useMemo(() => JSON.stringify([settings.search ?? "", settings.filter, settings.group]), [settings.search, settings.filter, settings.group]);
42
+ const ids = answer?.ids;
43
+ const orderedIds = useMemo(() => (ids ? [...ids] : []), [ids]);
44
+ const selection = useMemo(() => ({
45
+ orderedIds,
46
+ resetKey,
47
+ ...(answer?.paged && { retention: "external" }),
48
+ renderBar: (sel) => (_jsx(PublishSelection, { sel: sel, store: store, children: children })),
49
+ }), [orderedIds, resetKey, store, children, answer?.paged]);
50
+ const { LoadMore } = useViews().atoms;
51
+ const loadMore = useList((s) => s.loadMore);
52
+ const loadGroup = useList((s) => s.loadGroup);
53
+ const more = answer?.more;
54
+ const sourced = useMemo(() => ({
55
+ ...(more?.rows && { loadMore: { hasMore: true, onReveal: loadMore } }),
56
+ ...(more && Object.values(more.groups).some(Boolean) && {
57
+ renderGroupFooter: (group) => more.groups[group.key] && !folded.has(group.key) ? _jsx(LoadMore, { onReveal: () => loadGroup(group.key) }) : null,
58
+ }),
59
+ }), [more, loadMore, loadGroup, folded, LoadMore]);
60
+ if (!answer)
61
+ return null;
62
+ return (_jsx(GridEditsSinkContext.Provider, { value: sink, children: _jsx(GridTable, { ...gridProps, groups: answer.groups, grouped: answer.grouped, getRowId: getRowId, columns: columns, sort: panels.sort, groupBy: panels.groupBy, sortMark: true, isCollapsed: (key) => folded.has(key), onToggleGroup: toggleGroup, onOpenRow: noop, ...commits, selection: selection, ...sourced, ...(answer.refused !== null && { emptyState: answer.refused }), ...(answer.loading && answer.ids.length === 0 && { transitionPending: true }), ...own }) }));
63
+ }
64
+ function PublishSelection({ sel, store, children }) {
65
+ const ids = useMemo(() => [...sel.selectedIds], [sel.selectedIds]);
66
+ useLayoutEffect(() => {
67
+ store.patch({ selection: { ids, all: false, count: ids.length } });
68
+ }, [store, ids]);
69
+ useLayoutEffect(() => () => store.patch({ selection: { ids: [], all: false, count: 0 } }), [store]);
70
+ const { selectAll, setSelected } = sel;
71
+ useLayoutEffect(() => {
72
+ store.wire({ select: (next) => (next === "all" ? selectAll() : setSelected([...next])) });
73
+ return () => store.wire({ select: undefined });
74
+ }, [store, selectAll, setSelected]);
75
+ return children ?? null;
76
+ }