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
@@ -0,0 +1,36 @@
1
+ export { browserViewsStore } from "./browser-views-store.js";
2
+ export type { BrowserViewsStoreOptions } from "./browser-views-store.js";
3
+ export { fetchSource } from "./source.js";
4
+ export { List } from "./list.js";
5
+ export type { ListAnswerState } from "./answer.js";
6
+ export { ListBulkBar } from "./bulk-bar.js";
7
+ export type { ListBulkBarProps } from "./bulk-bar.js";
8
+ export type { ListChange } from "../grid/core/commit-model.js";
9
+ export type { ListColumnOverride } from "./columns.js";
10
+ export type { ListColumnsOverride } from "./columns.js";
11
+ export type { ListData } from "./root.js";
12
+ export type { ListFieldsRegistry } from "./columns.js";
13
+ export { ListFill } from "./slot.js";
14
+ export type { ListFillProps } from "./slot.js";
15
+ export { ListGrid } from "./grid.js";
16
+ export type { ListGridProps } from "./grid.js";
17
+ export type { ListMenus } from "./menu.js";
18
+ export type { ListProps } from "./list.js";
19
+ export { ListRoot } from "./root.js";
20
+ export type { ListRootProps } from "./root.js";
21
+ export type { ListSave } from "../grid/core/commit-model.js";
22
+ export { ListSlot } from "./slot.js";
23
+ export type { ListSlotProps } from "./slot.js";
24
+ export type { ListSource } from "./source.js";
25
+ export type { ListState } from "./store.js";
26
+ export { ListToolbar } from "./toolbar.js";
27
+ export type { ListToolbarProps } from "./toolbar.js";
28
+ export { menu } from "./menu.js";
29
+ export type { MenuPlace } from "./menu.js";
30
+ export type { ListViewsOptions } from "./root.js";
31
+ export type { ListViewsState } from "./views.js";
32
+ export type { SavedViewInput } from "./views-store.js";
33
+ export { useList } from "./root.js";
34
+ export type { ViewDraft } from "./views-store.js";
35
+ export type { ViewSeed } from "./views-store.js";
36
+ export type { ViewsStore } from "./views-store.js";
@@ -0,0 +1,11 @@
1
+ export { browserViewsStore } from "./browser-views-store.js";
2
+ export { fetchSource } from "./source.js";
3
+ export { List } from "./list.js";
4
+ export { ListBulkBar } from "./bulk-bar.js";
5
+ export { ListFill } from "./slot.js";
6
+ export { ListGrid } from "./grid.js";
7
+ export { ListRoot } from "./root.js";
8
+ export { ListSlot } from "./slot.js";
9
+ export { ListToolbar } from "./toolbar.js";
10
+ export { menu } from "./menu.js";
11
+ export { useList } from "./root.js";
@@ -0,0 +1,8 @@
1
+ import { type ListSettings } from "viewkitjs/fields/query";
2
+ import type { ListStore } from "./store.js";
3
+ /** The device key the open view is kept under, per list. */
4
+ export declare const openViewKey: (listId: string) => string;
5
+ /** The address follows the list (on), and the list the browser's back and forward. */
6
+ export declare function useListLink(store: ListStore, on: boolean, defaults: ListSettings): void;
7
+ /** The open view, kept on the device as it changes. */
8
+ export declare function useKeptView(store: ListStore, listId: string, on: boolean): void;
@@ -0,0 +1,78 @@
1
+ import { useContext, useEffect } from "react";
2
+ import { readListLink, writeListLink } from "viewkitjs/fields/query";
3
+ import { ViewsContext } from "../provider/context.js";
4
+ export const openViewKey = (listId) => `vk:list-open:${listId}`;
5
+ export function useListLink(store, on, defaults) {
6
+ const toast = useContext(ViewsContext)?.ports.toast.error;
7
+ useEffect(() => {
8
+ if (!on || typeof window === "undefined")
9
+ return;
10
+ let said;
11
+ const say = (problem) => {
12
+ if (!problem || problem === said)
13
+ return;
14
+ said = problem;
15
+ toast?.(problem);
16
+ };
17
+ say(readListLink(window.location.search).problem);
18
+ let written = window.location.search;
19
+ const listPart = (search) => {
20
+ const { view, change } = readListLink(search);
21
+ return JSON.stringify([view ?? null, change]);
22
+ };
23
+ let listSays = listPart(written);
24
+ const write = () => {
25
+ const state = store.get();
26
+ const views = state.views;
27
+ if (!views?.ready)
28
+ return;
29
+ const view = views.list.find((v) => v.id === views.open);
30
+ const { params, problem } = writeListLink(window.location.search, { ...(views.open !== null && { view: views.open }), base: view?.settings ?? defaults, settings: state.view.settings }, { carryChanges: true });
31
+ say(problem);
32
+ const query = params.toString();
33
+ const next = query ? `?${query}` : "";
34
+ written = next;
35
+ listSays = listPart(next);
36
+ if (next === window.location.search)
37
+ return;
38
+ window.history.replaceState(window.history.state, "", `${window.location.pathname}${next}${window.location.hash}`);
39
+ };
40
+ const off = store.subscribe(write);
41
+ write();
42
+ const onPop = () => {
43
+ if (window.location.search === written)
44
+ return;
45
+ written = window.location.search;
46
+ if (listPart(written) === listSays)
47
+ return;
48
+ listSays = listPart(written);
49
+ const reading = readListLink(window.location.search);
50
+ say(reading.problem);
51
+ const views = store.get().views;
52
+ const id = reading.view ?? views?.list[0]?.id;
53
+ if (id)
54
+ views?.openView(id, reading.change);
55
+ };
56
+ window.addEventListener("popstate", onPop);
57
+ return () => {
58
+ off();
59
+ window.removeEventListener("popstate", onPop);
60
+ };
61
+ }, [store, on, defaults, toast]);
62
+ }
63
+ export function useKeptView(store, listId, on) {
64
+ const prefs = useContext(ViewsContext)?.ports.viewPrefs;
65
+ useEffect(() => {
66
+ if (!on || !prefs)
67
+ return;
68
+ let kept = store.get().views?.open;
69
+ return store.subscribe(() => {
70
+ const views = store.get().views;
71
+ if (!views?.ready || views.open === kept)
72
+ return;
73
+ kept = views.open;
74
+ if (kept)
75
+ prefs.set(openViewKey(listId), kept);
76
+ });
77
+ }, [store, listId, prefs, on]);
78
+ }
@@ -0,0 +1,70 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ListRow, ListSettings } from "viewkitjs/fields/query";
3
+ import type { GridTableProps } from "../grid/chrome/grid-table-props.js";
4
+ import type { ListSave } from "../grid/core/commit-model.js";
5
+ import type { ToolbarParts } from "../panels/react/toolbar/ReadyToolbar.js";
6
+ import type { QuickFiltersConfig } from "../panels/quick/model.js";
7
+ import type { ViewsMenuItem } from "../provider/components.js";
8
+ import { type ListBulkBarProps } from "./bulk-bar.js";
9
+ import type { ListColumnsOverride, ListFieldsRegistry } from "./columns.js";
10
+ import { type ListGridProps } from "./grid.js";
11
+ import type { ListMenus } from "./menu.js";
12
+ import { type ListViewsOptions } from "./root.js";
13
+ import { type ListToolbarProps } from "./toolbar.js";
14
+ import type { ListSource } from "./source.js";
15
+ import type { ViewsStore } from "./views-store.js";
16
+ export type ListProps<Row extends ListRow> = ListPropsCommon<Row> & ({
17
+ /** The rows, the app's own flat `{ id, ...values }`; the list filters, sorts and groups them. */
18
+ rows: readonly Row[];
19
+ source?: undefined;
20
+ } | {
21
+ /** Where the rows come from: one list request in, its answer out (`fetchSource`, or a server action). */
22
+ source: ListSource<Row>;
23
+ rows?: undefined;
24
+ });
25
+ type ListPropsCommon<Row extends ListRow> = {
26
+ /** The list's id: its saved views, the person's draft and layer, and its open view are kept under it. */
27
+ id: string;
28
+ /** The list's fields (`defineFields`): every field a column, in its order, bound by its key. */
29
+ fields: ListFieldsRegistry;
30
+ /** A source's page: how many rows each request asks for. Default 50, held between 1 and 1000. */
31
+ pageSize?: number;
32
+ /** One save per record. None: a read-only list. */
33
+ save?: ListSave<Row>;
34
+ /** Columns changed by their field's key: width, header, hidden, `editable: false`, or the app's own `bind`. Keep it
35
+ * stable (a module constant, or `useMemo`): a new object re-binds the fields and re-answers the rows. */
36
+ columns?: ListColumnsOverride<Row>;
37
+ /** A store, or options: `{ seed }` (the app's own views), `{ records }` (the delete question's noun), `{ store }`.
38
+ * Default: the browser's store. */
39
+ views?: ViewsStore | ListViewsOptions;
40
+ /** What a list with no saved view shows; default the fields' columns over `LIST_SETTINGS_DEFAULTS`. */
41
+ defaults?: ListSettings;
42
+ /** The toolbar's form on a computer, as `ListRoot` takes them. */
43
+ sortFilter?: "right" | "bar";
44
+ bar?: "added" | "always";
45
+ /** Every menu as data: `column`, `row` and `group` reach the grid, `view`, `add` and `more` the toolbar. */
46
+ menus?: ListMenus<Row>;
47
+ /** Where each of the toolbar's parts stands (`ReadyToolbar`'s `toolbarParts`). */
48
+ toolbarParts?: ToolbarParts;
49
+ /** The address carries the open view and what changed. Default true; `false` leaves the address alone (a second list
50
+ * on the same page). */
51
+ link?: boolean;
52
+ /** `edit: false`: every cell read-only. `share: false`: no "Save for everyone". */
53
+ can?: {
54
+ edit?: boolean;
55
+ share?: boolean;
56
+ };
57
+ onOpenRow?: GridTableProps<Row>["onOpenRow"];
58
+ rowHref?: (row: Row) => string | undefined;
59
+ rowWritable?: (row: Row) => boolean;
60
+ onAdd?: () => void;
61
+ addItems?: ViewsMenuItem[];
62
+ quickFilters?: QuickFiltersConfig;
63
+ /** Any other prop of the toolbar, the grid or the bulk bar. */
64
+ toolbar?: Partial<ListToolbarProps<Row>>;
65
+ grid?: ListGridProps<Row>;
66
+ bulk?: ListBulkBarProps;
67
+ className?: string;
68
+ };
69
+ export declare function List<Row extends ListRow>({ id, fields, rows, source, pageSize, save, columns, views, defaults, sortFilter, bar, menus, toolbarParts, link, can, onOpenRow, rowHref, rowWritable, onAdd, addItems, quickFilters, toolbar, grid, bulk, className, }: ListProps<Row>): ReactNode;
70
+ export {};
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ListBulkBar } from "./bulk-bar.js";
4
+ import { ListGrid } from "./grid.js";
5
+ import { ListRoot } from "./root.js";
6
+ import { ListToolbar } from "./toolbar.js";
7
+ function handed(from) {
8
+ return Object.fromEntries(Object.entries(from).filter(([, value]) => value !== undefined));
9
+ }
10
+ export function List({ id, fields, rows, source, pageSize, save, columns, views, defaults, sortFilter, bar, menus, toolbarParts, link = true, can, onOpenRow, rowHref, rowWritable, onAdd, addItems, quickFilters, toolbar, grid, bulk, className, }) {
11
+ const toolbarMenus = { ...toolbar?.menus, ...handed({ view: menus?.view, add: menus?.add, more: menus?.more }) };
12
+ const gridMenus = { ...grid?.menus, ...handed({ column: menus?.column, row: menus?.row, group: menus?.group }) };
13
+ return (_jsx(ListRoot, { id: id, fields: fields, ...(source ? { source, pageSize } : { rows }), quickFilters: quickFilters, save: save, columns: columns, views: views, defaults: defaults, sortFilter: sortFilter, bar: bar, can: can, link: link, children: _jsxs("div", { "data-slot": "vk-list", className: className, children: [_jsx(ListToolbar, { ...toolbar, ...handed({ toolbarParts, onAdd, addItems, quickFilters }), menus: toolbarMenus }), _jsx(ListGrid, { ...grid, ...handed({ onOpenRow, rowHref, rowWritable }), menus: gridMenus, children: grid?.children ?? _jsx(ListBulkBar, { ...bulk }) })] }) }));
14
+ }
@@ -0,0 +1,31 @@
1
+ import type { GridMenus } from "../grid/chrome/grid-table-props.js";
2
+ import type { ToolbarMenus } from "../panels/react/toolbar/ReadyToolbar.js";
3
+ import type { ViewsMenuItem } from "../provider/components.js";
4
+ /** Every menu of a list as data: the grid's (`column`, `row`, `group`, which `GridTable` takes as `menus`) and the toolbar's
5
+ * (`view`, `add`, `more`, which `ReadyToolbar` and `ListToolbar` take as `menus`). Each is handed its default items and hands
6
+ * back the items it shows; a menu with no function is as ViewKit draws it. */
7
+ export type ListMenus<Row> = GridMenus<Row> & ToolbarMenus;
8
+ /** Where a row goes: right after the row of that key, or right before it. */
9
+ export type MenuPlace = {
10
+ after: string;
11
+ } | {
12
+ before: string;
13
+ };
14
+ /** What the helpers reshape: a keyed row, perhaps opening a block, perhaps holding rows of its own. */
15
+ type Keyed<T> = {
16
+ key: string;
17
+ separatorBefore?: boolean;
18
+ children?: T[];
19
+ };
20
+ declare function drop<T extends Keyed<T>>(items: T[], ...keys: string[]): T[];
21
+ declare function rename(items: ViewsMenuItem[], key: string, label: string): ViewsMenuItem[];
22
+ declare function add<T extends Keyed<T>>(items: T[], item: T, place?: MenuPlace): T[];
23
+ declare function move<T extends Keyed<T>>(items: T[], key: string, place: MenuPlace): T[];
24
+ /** The four changes an app's menu function makes to the items it is handed. */
25
+ export declare const menu: {
26
+ drop: typeof drop;
27
+ rename: typeof rename;
28
+ add: typeof add;
29
+ move: typeof move;
30
+ };
31
+ export {};
@@ -0,0 +1,76 @@
1
+ const bare = (item) => {
2
+ if (!item.separatorBefore)
3
+ return item;
4
+ const { separatorBefore: _, ...rest } = item;
5
+ return rest;
6
+ };
7
+ const lead = (items) => (items[0]?.separatorBefore ? [bare(items[0]), ...items.slice(1)] : items);
8
+ function inList(items, key, edit) {
9
+ const at = items.findIndex((item) => item.key === key);
10
+ if (at >= 0)
11
+ return edit(items, at);
12
+ for (let i = 0; i < items.length; i++) {
13
+ const children = items[i].children;
14
+ const changed = children ? inList(children, key, edit) : null;
15
+ if (changed)
16
+ return [...items.slice(0, i), { ...items[i], children: changed }, ...items.slice(i + 1)];
17
+ }
18
+ return null;
19
+ }
20
+ const find = (items, key) => {
21
+ for (const item of items) {
22
+ if (item.key === key)
23
+ return item;
24
+ const inner = item.children && find(item.children, key);
25
+ if (inner)
26
+ return inner;
27
+ }
28
+ return undefined;
29
+ };
30
+ function drop(items, ...keys) {
31
+ const gone = new Set(keys);
32
+ const walk = (list) => {
33
+ const out = [];
34
+ let carry = false;
35
+ for (const item of list) {
36
+ if (gone.has(item.key)) {
37
+ carry ||= !!item.separatorBefore;
38
+ continue;
39
+ }
40
+ const children = item.children && walk(item.children);
41
+ if (item.children?.length && !children?.length) {
42
+ carry ||= !!item.separatorBefore;
43
+ continue;
44
+ }
45
+ let next = children ? { ...item, children } : item;
46
+ if (carry && !next.separatorBefore)
47
+ next = { ...next, separatorBefore: true };
48
+ carry = false;
49
+ out.push(next);
50
+ }
51
+ return lead(out);
52
+ };
53
+ return walk(items);
54
+ }
55
+ function rename(items, key, label) {
56
+ return inList(items, key, (list, at) => [...list.slice(0, at), { ...list[at], label }, ...list.slice(at + 1)]) ?? items;
57
+ }
58
+ function add(items, item, place) {
59
+ const placed = place &&
60
+ inList(items, "after" in place ? place.after : place.before, (list, at) => {
61
+ if ("after" in place)
62
+ return [...list.slice(0, at + 1), item, ...list.slice(at + 1)];
63
+ const anchor = list[at];
64
+ const taken = anchor.separatorBefore ? { ...item, separatorBefore: true } : bare(item);
65
+ return lead([...list.slice(0, at), taken, bare(anchor), ...list.slice(at + 1)]);
66
+ });
67
+ return placed ?? lead([...items, item]);
68
+ }
69
+ function move(items, key, place) {
70
+ const anchor = "after" in place ? place.after : place.before;
71
+ const item = find(items, key);
72
+ if (!item || anchor === key || !find(items, anchor) || find(item.children ?? [], anchor))
73
+ return items;
74
+ return add(drop(items, key), bare(item), place);
75
+ }
76
+ export const menu = { drop, rename, add, move };
@@ -0,0 +1,6 @@
1
+ import type { ToolbarPart } from "../panels/react/toolbar/Toolbar.js";
2
+ import type { ToolbarPartPlace, ToolbarParts, ToolbarPartsContext } from "../panels/react/toolbar/ReadyToolbar.js";
3
+ /** Each part's place, in the order the form draws them: the row's start and end, then the bar's (a kit phone's one line). */
4
+ export declare function placesOf(parts: readonly ToolbarPart[], ctx: ToolbarPartsContext): ToolbarPartPlace[];
5
+ /** The form's parts as the app's `toolbarParts` places them. */
6
+ export declare function applyParts(parts: readonly ToolbarPart[], place: ToolbarParts, ctx: ToolbarPartsContext): readonly ToolbarPart[];
@@ -0,0 +1,66 @@
1
+ import { arrangeToolbar } from "../panels/toolbar/model.js";
2
+ const kitPhone = (ctx) => ctx.arrangement === "kit" && ctx.phone;
3
+ const lineOf = (part) => ((part.line ?? 1) === 2 ? "bar" : "row");
4
+ export function placesOf(parts, ctx) {
5
+ const byKey = new Map(parts.map((part) => [part.key, part]));
6
+ const place = (part, line) => ({
7
+ key: part.key,
8
+ line,
9
+ side: part.side ?? "start",
10
+ words: part.words ?? "both",
11
+ });
12
+ if (kitPhone(ctx)) {
13
+ const [line] = arrangeToolbar(parts, "phone", { fold: true });
14
+ const slots = line ? [...line.start, ...line.end] : [];
15
+ return slots.flatMap((slot) => {
16
+ const part = byKey.get(slot.key);
17
+ return part ? [place(part, part.key === "new" && part.foot !== false ? "foot" : "row")] : [];
18
+ });
19
+ }
20
+ const drawn = (line, side) => parts.filter((part) => lineOf(part) === line && (part.side ?? "start") === side).map((part) => place(part, line));
21
+ return [...drawn("row", "start"), ...drawn("row", "end"), ...drawn("bar", "start"), ...drawn("bar", "end")];
22
+ }
23
+ const samePlaces = (a, b) => a.length === b.length &&
24
+ a.every((p, i) => p.key === b[i].key &&
25
+ p.line === b[i].line &&
26
+ p.side === b[i].side &&
27
+ p.words === b[i].words &&
28
+ p.node === undefined &&
29
+ p.className === undefined &&
30
+ p.button === undefined);
31
+ export function applyParts(parts, place, ctx) {
32
+ const given = placesOf(parts, ctx);
33
+ const back = place(given, ctx);
34
+ if (samePlaces(back, given))
35
+ return parts;
36
+ const byKey = new Map(parts.map((part) => [part.key, part]));
37
+ const seen = new Set();
38
+ const one = kitPhone(ctx);
39
+ return back.flatMap((at) => {
40
+ if (seen.has(at.key))
41
+ return [];
42
+ seen.add(at.key);
43
+ const part = byKey.get(at.key);
44
+ const line = !one && at.line === "bar" ? 2 : 1;
45
+ const look = { ...(at.className && { className: at.className }), ...(at.button && { button: at.button }) };
46
+ if (!part)
47
+ return at.node === undefined ? [] : [{ key: at.key, line, side: at.side, words: at.words, node: at.node, ...look }];
48
+ const own = part.words ?? "both";
49
+ const next = { ...part, ...look };
50
+ if (line !== (part.line ?? 1))
51
+ next.line = line;
52
+ if (at.side !== (part.side ?? "start"))
53
+ next.side = at.side;
54
+ if (at.words !== own)
55
+ next.words = at.words;
56
+ if (at.words === "both" && own === "icon" && !part.shed)
57
+ next.shed = true;
58
+ if (one && part.key === "new") {
59
+ if (at.line === "foot")
60
+ delete next.foot;
61
+ else
62
+ next.foot = false;
63
+ }
64
+ return [next];
65
+ });
66
+ }
@@ -0,0 +1,11 @@
1
+ import type { ListStore } from "./store.js";
2
+ export type ListRegistry = {
3
+ subscribe: (listener: () => void) => () => void;
4
+ store: (id: string) => ListStore | undefined;
5
+ addStore: (id: string, store: ListStore) => () => void;
6
+ slot: (name: string) => HTMLElement | undefined;
7
+ addSlot: (name: string, element: HTMLElement) => () => void;
8
+ };
9
+ export declare function createListRegistry(): ListRegistry;
10
+ /** The registry of the `ViewsProvider` around a part; null outside one. */
11
+ export declare const ListRegistryContext: import("react").Context<ListRegistry | null>;
@@ -0,0 +1,31 @@
1
+ import { createContext } from "react";
2
+ export function createListRegistry() {
3
+ const stores = new Map();
4
+ const slots = new Map();
5
+ const listeners = new Set();
6
+ const tell = () => {
7
+ for (const listener of [...listeners])
8
+ listener();
9
+ };
10
+ const add = (map) => (key, value) => {
11
+ map.set(key, value);
12
+ tell();
13
+ return () => {
14
+ if (map.get(key) !== value)
15
+ return;
16
+ map.delete(key);
17
+ tell();
18
+ };
19
+ };
20
+ return {
21
+ subscribe: (listener) => {
22
+ listeners.add(listener);
23
+ return () => listeners.delete(listener);
24
+ },
25
+ store: (id) => stores.get(id),
26
+ addStore: add(stores),
27
+ slot: (name) => slots.get(name),
28
+ addSlot: add(slots),
29
+ };
30
+ }
31
+ export const ListRegistryContext = createContext(null);
@@ -0,0 +1,46 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ListLinkReading, ListSettings } from "viewkitjs/fields/query";
3
+ import type { ToolbarPanelState } from "../panels/react/toolbar/panel-state.js";
4
+ import { type ListState, type ListStore, type ListSync } from "./store.js";
5
+ import type { ViewSeed, ViewsStore } from "./views-store.js";
6
+ /** The root's saved views: a store, or the browser store with the app's own views for this list. */
7
+ export type ListViewsOptions = {
8
+ store?: ViewsStore;
9
+ /** The app's own views for this list, on the browser store (ignored with `store`): listed first, shared, read-only. */
10
+ seed?: readonly ViewSeed[];
11
+ /** What the list holds, in the delete question's line ("deals"). Default "records". */
12
+ records?: string;
13
+ };
14
+ /** The list root's props: its id, and either its settings and layer as the app holds them (memory mode: what
15
+ * `useListSettingsState` returns, with the shared view), or no settings, and the root keeps them through a store. A
16
+ * root keeps the mode it mounted in. Either way, the toolbar's `sortFilter` and `bar`. */
17
+ export type ListRootModes = ListSync | {
18
+ settings?: undefined;
19
+ /** Where the list's saved views are kept: a store, or options; default `browserViewsStore()`. */
20
+ views?: ViewsStore | ListViewsOptions;
21
+ /** What a list with no saved view shows, and a new view's start. Default `LIST_SETTINGS_DEFAULTS`. */
22
+ defaults?: ListSettings;
23
+ /** `true`: the address carries the open view and what changed: read as the list opens (its view and change win
24
+ * over the draft), written in place as it changes, read again on the browser's back and forward. A reading
25
+ * (`readListLink`): opened, never written. Absent or `false`: the address is left alone. Either way the open
26
+ * view is kept on the device, opened again where no link names one. */
27
+ link?: boolean | ListLinkReading;
28
+ sortFilter?: ListSync["sortFilter"];
29
+ bar?: ListSync["bar"];
30
+ };
31
+ /** The base root's props: its id, its mode, and `share: false` (no "Save for everyone", store mode). Not on the door. */
32
+ export type ListRootBaseProps = {
33
+ id: string;
34
+ children?: ReactNode;
35
+ share?: boolean;
36
+ } & ListRootModes;
37
+ export declare function ListRootBase({ id, children, share, ...props }: ListRootBaseProps): ReactNode;
38
+ /** The store of the list root around this part (not on the door). */
39
+ export declare function useListStore(): ListStore;
40
+ /** What this part selects of its list's state: it re-renders only when that changes (by `equal`, `Object.is` by
41
+ * default). Select an action as it stands (`useList((s) => s.openPanel)`): actions never change. Handed an `id` first,
42
+ * it reads the root of that id from anywhere under the `ViewsProvider` (VK-740): `undefined` while none stands. */
43
+ export declare function useList<T>(select: (state: ListState) => T, equal?: (a: T, b: T) => boolean): T;
44
+ export declare function useList<T>(id: string, select: (state: ListState) => T, equal?: (a: T, b: T) => boolean): T | undefined;
45
+ /** One of the root's panels as a part's open state and page, by its key (not on the door). */
46
+ export declare function useListPanel(key: string): ToolbarPanelState;
@@ -0,0 +1,137 @@
1
+ "use client";
2
+ import { createContext, createElement, useCallback, useContext, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
3
+ import { LIST_SETTINGS_DEFAULTS, readListLink } from "viewkitjs/fields/query";
4
+ import { ListRadioContext, ToolbarRadioContext, useToolbarRadioState } from "../panels/react/toolbar/context.js";
5
+ import { ListRegistryContext } from "./registry.js";
6
+ import { ViewsContext } from "../provider/context.js";
7
+ import { browserViewsStore } from "./browser-views-store.js";
8
+ import { openViewKey, useKeptView, useListLink } from "./link.js";
9
+ import { createListStore } from "./store.js";
10
+ import { createListViews } from "./views.js";
11
+ const ListStoreContext = createContext(null);
12
+ export function ListRootBase({ id, children, share, ...props }) {
13
+ const mode = useStoreMode(id, props, share);
14
+ const extra = { sortFilter: props.sortFilter, bar: props.bar };
15
+ const sync = mode ? mode.views.sync(extra) : props;
16
+ const [store] = useState(() => createListStore(id, sync));
17
+ useListLink(store, !!mode && props.link === true, mode?.defaults ?? LIST_SETTINGS_DEFAULTS);
18
+ useKeptView(store, id, !!mode);
19
+ store.sync(sync);
20
+ useLayoutEffect(() => store.flush());
21
+ useStoreViews(mode, store, extra);
22
+ const registry = useContext(ListRegistryContext);
23
+ useLayoutEffect(() => registry?.addStore(store.get().id, store), [registry, store]);
24
+ const radio = useToolbarRadioState();
25
+ return createElement(ListStoreContext.Provider, { value: store }, createElement(ListRadioContext.Provider, { value: radio }, createElement(ToolbarRadioContext.Provider, { value: radio }, children)));
26
+ }
27
+ export function useListStore() {
28
+ const store = useContext(ListStoreContext);
29
+ if (!store)
30
+ throw new Error("useList reads a list's state, and needs a ListRoot around it");
31
+ return store;
32
+ }
33
+ export function useList(...args) {
34
+ const byId = typeof args[0] === "string" ? args[0] : null;
35
+ const [select, equal = Object.is] = (byId === null ? args : args.slice(1));
36
+ const inside = useContext(ListStoreContext);
37
+ const registry = useContext(ListRegistryContext);
38
+ if (byId === null && !inside)
39
+ throw new Error("useList reads a list's state, and needs a ListRoot around it");
40
+ if (byId !== null && !registry)
41
+ throw new Error("useList(id, select) reads a list by its id, and needs a ViewsProvider around it");
42
+ const storeOf = () => (byId === null ? (inside ?? undefined) : registry?.store(byId));
43
+ const subscribe = useCallback((listener) => {
44
+ if (byId === null || !registry)
45
+ return inside ? inside.subscribe(listener) : () => { };
46
+ let off = registry.store(byId)?.subscribe(listener) ?? (() => { });
47
+ const offRegistry = registry.subscribe(() => {
48
+ off();
49
+ off = registry.store(byId)?.subscribe(listener) ?? (() => { });
50
+ listener();
51
+ });
52
+ return () => {
53
+ offRegistry();
54
+ off();
55
+ };
56
+ }, [byId, registry, inside]);
57
+ const memo = useRef(null);
58
+ const read = () => {
59
+ const state = storeOf()?.get();
60
+ if (!state) {
61
+ memo.current = null;
62
+ return undefined;
63
+ }
64
+ const last = memo.current;
65
+ if (last && last.state === state && last.select === select)
66
+ return last.value;
67
+ const value = select(state);
68
+ if (last && equal(last.value, value)) {
69
+ memo.current = { state, select, value: last.value };
70
+ return last.value;
71
+ }
72
+ memo.current = { state, select, value };
73
+ return value;
74
+ };
75
+ return useSyncExternalStore(subscribe, read, read);
76
+ }
77
+ export function useListPanel(key) {
78
+ const store = useListStore();
79
+ const open = useList((s) => s.panels.open === key);
80
+ const page = useList((s) => s.panels.pages[key] ?? null);
81
+ const onOpenChange = useCallback((next) => (next ? store.get().openPanel(key) : store.get().closePanel(key)), [store, key]);
82
+ const onPageChange = useCallback((next) => store.get().setPage(key, next), [store, key]);
83
+ return useMemo(() => ({ open, onOpenChange, page, onPageChange }), [open, onOpenChange, page, onPageChange]);
84
+ }
85
+ function useStoreMode(id, props, share) {
86
+ const prefs = useContext(ViewsContext)?.ports.viewPrefs;
87
+ const [mode] = useState(() => {
88
+ if (props.settings !== undefined)
89
+ return null;
90
+ const own = props;
91
+ const given = own.views;
92
+ const options = given && "list" in given ? { store: given } : (given ?? {});
93
+ const store = options.store ?? browserViewsStore(options.seed ? { seed: { [id]: options.seed } } : undefined);
94
+ let on = { change: () => { }, error: () => { } };
95
+ const defaults = own.defaults ?? LIST_SETTINGS_DEFAULTS;
96
+ const link = own.link === true ? (typeof window === "undefined" ? undefined : readListLink(window.location.search)) : own.link || undefined;
97
+ const kept = prefs?.get(openViewKey(id));
98
+ const views = createListViews({
99
+ id,
100
+ store,
101
+ defaults,
102
+ ...(link && { link }),
103
+ ...(kept !== undefined && { kept }),
104
+ ...(share === false && { share: false }),
105
+ ...(options.records !== undefined && { records: options.records }),
106
+ onChange: () => on.change(),
107
+ onError: (message) => on.error(message),
108
+ });
109
+ return { views, wire: (next) => void (on = next), defaults };
110
+ });
111
+ return mode;
112
+ }
113
+ function useStoreViews(mode, store, extra) {
114
+ const toast = useContext(ViewsContext)?.ports.toast.error;
115
+ useLayoutEffect(() => {
116
+ if (!mode)
117
+ return;
118
+ mode.wire({
119
+ change: () => {
120
+ store.sync(mode.views.sync(extra));
121
+ store.patch({ views: mode.views.state() });
122
+ store.flush();
123
+ },
124
+ error: (message) => toast?.(message),
125
+ });
126
+ });
127
+ const [, settle] = useState(0);
128
+ useLayoutEffect(() => {
129
+ if (!mode)
130
+ return;
131
+ store.patch({ views: mode.views.state() });
132
+ const stop = mode.views.start();
133
+ if (mode.views.state().ready)
134
+ settle((n) => n + 1);
135
+ return stop;
136
+ }, [mode, store]);
137
+ }