viewkitjs 0.27.0 → 0.29.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 (469) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/MIGRATION.md +123 -5
  3. package/fields/dist/derived.d.ts +2 -1
  4. package/fields/dist/derived.js +9 -3
  5. package/fields/dist/entities.js +41 -3
  6. package/fields/dist/index.d.ts +1 -1
  7. package/fields/dist/index.js +1 -1
  8. package/fields/dist/messages.d.ts +8 -2
  9. package/fields/dist/messages.js +3 -0
  10. package/fields/dist/range.d.ts +6 -0
  11. package/fields/dist/range.js +8 -0
  12. package/fields/dist/registry.js +11 -1
  13. package/fields/dist/spec-changes.js +1 -0
  14. package/fields/dist/types.d.ts +23 -1
  15. package/fields/docs/guides/derived-fields.md +7 -5
  16. package/fields/docs/guides/field-types.md +2 -2
  17. package/fields/docs/guides/the-index.md +1 -1
  18. package/fields/docs/reference/fields.md +3 -1
  19. package/fields/docs/reference/types.md +3 -1
  20. package/fields/skills/viewkit/SKILL.md +1 -1
  21. package/package.json +2 -1
  22. package/postgres/dist/definitions/build.js +29 -5
  23. package/postgres/dist/definitions/label.d.ts +7 -0
  24. package/postgres/dist/definitions/label.js +9 -1
  25. package/postgres/dist/definitions/lookup.js +6 -2
  26. package/postgres/dist/definitions/place.d.ts +6 -3
  27. package/postgres/dist/definitions/rollup.js +5 -1
  28. package/postgres/dist/definitions/storage.d.ts +15 -0
  29. package/postgres/dist/definitions/storage.js +52 -1
  30. package/postgres/dist/definitions/stored.js +21 -0
  31. package/postgres/dist/phone.d.ts +13 -1
  32. package/postgres/dist/phone.js +23 -3
  33. package/postgres/dist/search-indexes.d.ts +6 -1
  34. package/postgres/dist/search-indexes.js +71 -25
  35. package/postgres/dist/search.js +3 -3
  36. package/postgres/docs/guides/definitions.md +22 -5
  37. package/postgres/docs/guides/field-map.md +5 -4
  38. package/postgres/docs/reference/definitions.md +3 -3
  39. package/postgres/docs/reference/postgres.md +1 -1
  40. package/views/dist/cells/cell-format.d.ts +3 -1
  41. package/views/dist/cells/cell-format.js +3 -3
  42. package/views/dist/cells/cell-values.js +9 -10
  43. package/views/dist/cells/use-cell-format.d.ts +8 -1
  44. package/views/dist/cells/use-cell-format.js +13 -2
  45. package/views/dist/contract.d.ts +218 -5
  46. package/views/dist/contract.js +233 -1
  47. package/views/dist/controls/alert/alert.d.ts +46 -0
  48. package/views/dist/controls/alert/alert.js +11 -0
  49. package/views/dist/controls/alert/looks.d.ts +4 -0
  50. package/views/dist/controls/alert/looks.js +19 -0
  51. package/views/dist/controls/alert/tokens.d.ts +92 -0
  52. package/views/dist/controls/alert/tokens.js +25 -0
  53. package/views/dist/controls/alert-dialog/alert-dialog.d.ts +50 -0
  54. package/views/dist/controls/alert-dialog/alert-dialog.js +67 -0
  55. package/views/dist/controls/alert-dialog/confirm.d.ts +13 -0
  56. package/views/dist/controls/alert-dialog/confirm.js +11 -0
  57. package/views/dist/controls/alert-dialog/looks.d.ts +4 -0
  58. package/views/dist/controls/alert-dialog/looks.js +17 -0
  59. package/views/dist/controls/alert-dialog/tokens.d.ts +119 -0
  60. package/views/dist/controls/alert-dialog/tokens.js +32 -0
  61. package/views/dist/controls/alert-dialog.css +95 -0
  62. package/views/dist/controls/alert.css +51 -0
  63. package/views/dist/controls/bulk-bar/bulk-bar-of.d.ts +66 -0
  64. package/views/dist/controls/bulk-bar/bulk-bar-of.js +22 -0
  65. package/views/dist/controls/bulk-bar/bulk-bar.d.ts +40 -0
  66. package/views/dist/controls/bulk-bar/bulk-bar.js +278 -0
  67. package/views/dist/controls/bulk-bar/looks.d.ts +10 -0
  68. package/views/dist/controls/bulk-bar/looks.js +14 -0
  69. package/views/dist/controls/bulk-bar/map-selection-bar.d.ts +19 -0
  70. package/views/dist/controls/bulk-bar/map-selection-bar.js +57 -0
  71. package/views/dist/controls/bulk-bar/tokens.d.ts +136 -0
  72. package/views/dist/controls/bulk-bar/tokens.js +36 -0
  73. package/views/dist/controls/bulk-bar/words.d.ts +50 -0
  74. package/views/dist/controls/bulk-bar/words.js +19 -0
  75. package/views/dist/controls/bulk-bar.css +96 -0
  76. package/views/dist/controls/button/button.js +3 -1
  77. package/views/dist/controls/button.css +5 -4
  78. package/views/dist/controls/checkbox/checkbox.js +3 -1
  79. package/views/dist/controls/checkbox.css +1 -1
  80. package/views/dist/controls/choice/tokens.d.ts +79 -0
  81. package/views/dist/controls/choice/tokens.js +22 -0
  82. package/views/dist/controls/choice.css +31 -0
  83. package/views/dist/controls/collapsible/collapsible.d.ts +39 -0
  84. package/views/dist/controls/collapsible/collapsible.js +18 -0
  85. package/views/dist/controls/collapsible/looks.d.ts +4 -0
  86. package/views/dist/controls/collapsible/looks.js +5 -0
  87. package/views/dist/controls/collapsible/map-collapse.d.ts +2 -0
  88. package/views/dist/controls/collapsible/map-collapse.js +6 -0
  89. package/views/dist/controls/collapsible/tokens.d.ts +68 -0
  90. package/views/dist/controls/collapsible/tokens.js +19 -0
  91. package/views/dist/controls/collapsible.css +83 -0
  92. package/views/dist/controls/compound-editor/looks.js +1 -1
  93. package/views/dist/controls/compound-editor/place-parts.js +5 -1
  94. package/views/dist/controls/controls.d.ts +19 -0
  95. package/views/dist/controls/controls.js +17 -0
  96. package/views/dist/controls/customize/customize.d.ts +125 -0
  97. package/views/dist/controls/customize/customize.js +243 -0
  98. package/views/dist/controls/customize/glide.d.ts +10 -0
  99. package/views/dist/controls/customize/glide.js +55 -0
  100. package/views/dist/controls/customize/looks.d.ts +13 -0
  101. package/views/dist/controls/customize/looks.js +11 -0
  102. package/views/dist/controls/customize/map-customize-body.d.ts +18 -0
  103. package/views/dist/controls/customize/map-customize-body.js +160 -0
  104. package/views/dist/controls/customize/rules.d.ts +23 -0
  105. package/views/dist/controls/customize/rules.js +19 -0
  106. package/views/dist/controls/customize/tokens.d.ts +40 -0
  107. package/views/dist/controls/customize/tokens.js +12 -0
  108. package/views/dist/controls/customize/words.d.ts +58 -0
  109. package/views/dist/controls/customize/words.js +37 -0
  110. package/views/dist/controls/customize.css +54 -0
  111. package/views/dist/controls/date-editor/date-editor.d.ts +2 -1
  112. package/views/dist/controls/date-editor/looks.js +1 -1
  113. package/views/dist/controls/date-editor/map-calendar.js +3 -1
  114. package/views/dist/controls/filter-editor/block.d.ts +31 -0
  115. package/views/dist/controls/filter-editor/block.js +27 -0
  116. package/views/dist/controls/filter-editor/filter-editor.d.ts +58 -0
  117. package/views/dist/controls/filter-editor/filter-editor.js +250 -0
  118. package/views/dist/controls/filter-editor/how.d.ts +23 -0
  119. package/views/dist/controls/filter-editor/how.js +14 -0
  120. package/views/dist/controls/filter-editor/map-filter-body.d.ts +33 -0
  121. package/views/dist/controls/filter-editor/map-filter-body.js +190 -0
  122. package/views/dist/controls/filter-editor/map-rules.d.ts +101 -0
  123. package/views/dist/controls/filter-editor/map-rules.js +304 -0
  124. package/views/dist/controls/filter-editor/parts.d.ts +46 -0
  125. package/views/dist/controls/filter-editor/parts.js +75 -0
  126. package/views/dist/controls/filter-editor/rules.d.ts +142 -0
  127. package/views/dist/controls/filter-editor/rules.js +201 -0
  128. package/views/dist/controls/filter-editor/tokens.d.ts +83 -0
  129. package/views/dist/controls/filter-editor/tokens.js +23 -0
  130. package/views/dist/controls/filter-editor/words.d.ts +74 -0
  131. package/views/dist/controls/filter-editor/words.js +46 -0
  132. package/views/dist/controls/filter-editor.css +142 -0
  133. package/views/dist/controls/group-editor/group-editor.d.ts +56 -0
  134. package/views/dist/controls/group-editor/group-editor.js +126 -0
  135. package/views/dist/controls/group-editor/map-group-body.d.ts +19 -0
  136. package/views/dist/controls/group-editor/map-group-body.js +106 -0
  137. package/views/dist/controls/group-editor/rules.d.ts +48 -0
  138. package/views/dist/controls/group-editor/rules.js +41 -0
  139. package/views/dist/controls/group-editor/tokens.d.ts +15 -0
  140. package/views/dist/controls/group-editor/tokens.js +6 -0
  141. package/views/dist/controls/group-editor/words.d.ts +39 -0
  142. package/views/dist/controls/group-editor/words.js +21 -0
  143. package/views/dist/controls/group-editor.css +20 -0
  144. package/views/dist/controls/index.d.ts +45 -3
  145. package/views/dist/controls/index.js +44 -3
  146. package/views/dist/controls/inline-input/looks.js +1 -1
  147. package/views/dist/controls/input/input.js +10 -4
  148. package/views/dist/controls/internal/editor-parts.d.ts +8 -1
  149. package/views/dist/controls/internal/editor-parts.js +5 -0
  150. package/views/dist/controls/internal/phone.d.ts +5 -4
  151. package/views/dist/controls/internal/phone.js +7 -7
  152. package/views/dist/controls/internal/scroll.js +5 -1
  153. package/views/dist/controls/internal/step-return.d.ts +9 -0
  154. package/views/dist/controls/internal/step-return.js +27 -0
  155. package/views/dist/controls/internal/typed-run.d.ts +2 -0
  156. package/views/dist/controls/internal/typed-run.js +5 -0
  157. package/views/dist/controls/links-editor/links-editor.d.ts +5 -3
  158. package/views/dist/controls/links-editor/links-editor.js +38 -17
  159. package/views/dist/controls/links-editor/map-links-body.js +4 -1
  160. package/views/dist/controls/links-editor.css +1 -1
  161. package/views/dist/controls/menu/map-menu.js +2 -2
  162. package/views/dist/controls/menu-list/menu-list.d.ts +17 -2
  163. package/views/dist/controls/menu-list/menu-list.js +25 -16
  164. package/views/dist/controls/modal/looks.d.ts +4 -0
  165. package/views/dist/controls/modal/looks.js +25 -0
  166. package/views/dist/controls/modal/modal.d.ts +69 -0
  167. package/views/dist/controls/modal/modal.js +62 -0
  168. package/views/dist/controls/modal/tokens.d.ts +192 -0
  169. package/views/dist/controls/modal/tokens.js +50 -0
  170. package/views/dist/controls/modal.css +130 -0
  171. package/views/dist/controls/notice/notice.d.ts +49 -0
  172. package/views/dist/controls/notice/notice.js +35 -0
  173. package/views/dist/controls/notice/tokens.d.ts +99 -0
  174. package/views/dist/controls/notice/tokens.js +27 -0
  175. package/views/dist/controls/notice.css +100 -0
  176. package/views/dist/controls/number-editor/looks.js +1 -1
  177. package/views/dist/controls/number-editor/number-editor.js +1 -1
  178. package/views/dist/controls/option/option.js +3 -1
  179. package/views/dist/controls/option.css +1 -1
  180. package/views/dist/controls/pane/looks.d.ts +4 -0
  181. package/views/dist/controls/pane/looks.js +11 -0
  182. package/views/dist/controls/pane/pane.d.ts +67 -0
  183. package/views/dist/controls/pane/pane.js +99 -0
  184. package/views/dist/controls/pane/state.d.ts +14 -0
  185. package/views/dist/controls/pane/state.js +7 -0
  186. package/views/dist/controls/pane/tokens.d.ts +79 -0
  187. package/views/dist/controls/pane/tokens.js +22 -0
  188. package/views/dist/controls/pane.css +104 -0
  189. package/views/dist/controls/picker/looks.js +1 -1
  190. package/views/dist/controls/picker/map-picker.d.ts +6 -2
  191. package/views/dist/controls/picker/map-picker.js +4 -2
  192. package/views/dist/controls/picker/picker.d.ts +7 -0
  193. package/views/dist/controls/picker/picker.js +57 -8
  194. package/views/dist/controls/picker/rows.d.ts +4 -2
  195. package/views/dist/controls/picker/rows.js +4 -3
  196. package/views/dist/controls/popover/map-popover.d.ts +1 -1
  197. package/views/dist/controls/popover/map-popover.js +2 -2
  198. package/views/dist/controls/popover/popover.js +2 -1
  199. package/views/dist/controls/popover.css +3 -0
  200. package/views/dist/controls/ports-host/map-ports-host.d.ts +7 -0
  201. package/views/dist/controls/ports-host/map-ports-host.js +43 -0
  202. package/views/dist/controls/press/tokens.d.ts +8 -0
  203. package/views/dist/controls/press/tokens.js +4 -0
  204. package/views/dist/controls/press.css +44 -0
  205. package/views/dist/controls/quick-filters/looks.d.ts +11 -0
  206. package/views/dist/controls/quick-filters/looks.js +9 -0
  207. package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +31 -0
  208. package/views/dist/controls/quick-filters/map-quick-filters-body.js +56 -0
  209. package/views/dist/controls/quick-filters/quick-filters.d.ts +37 -0
  210. package/views/dist/controls/quick-filters/quick-filters.js +89 -0
  211. package/views/dist/controls/quick-filters/reminder.d.ts +18 -0
  212. package/views/dist/controls/quick-filters/reminder.js +41 -0
  213. package/views/dist/controls/quick-filters/rules.d.ts +89 -0
  214. package/views/dist/controls/quick-filters/rules.js +52 -0
  215. package/views/dist/controls/quick-filters/tokens.d.ts +112 -0
  216. package/views/dist/controls/quick-filters/tokens.js +30 -0
  217. package/views/dist/controls/quick-filters/words.d.ts +25 -0
  218. package/views/dist/controls/quick-filters/words.js +13 -0
  219. package/views/dist/controls/quick-filters.css +118 -0
  220. package/views/dist/controls/sheet/bottom-sheet.d.ts +9 -4
  221. package/views/dist/controls/sheet/bottom-sheet.js +4 -4
  222. package/views/dist/controls/sheet/map-sheet.d.ts +4 -1
  223. package/views/dist/controls/sheet/map-sheet.js +19 -6
  224. package/views/dist/controls/sheet/sheet-parts.d.ts +10 -0
  225. package/views/dist/controls/sheet/sheet-parts.js +2 -0
  226. package/views/dist/controls/sort-editor/map-sort-body.d.ts +9 -0
  227. package/views/dist/controls/sort-editor/map-sort-body.js +81 -0
  228. package/views/dist/controls/sort-editor/rules.d.ts +48 -0
  229. package/views/dist/controls/sort-editor/rules.js +24 -0
  230. package/views/dist/controls/sort-editor/sort-editor.d.ts +58 -0
  231. package/views/dist/controls/sort-editor/sort-editor.js +180 -0
  232. package/views/dist/controls/sort-editor/tokens.d.ts +79 -0
  233. package/views/dist/controls/sort-editor/tokens.js +22 -0
  234. package/views/dist/controls/sort-editor/words.d.ts +48 -0
  235. package/views/dist/controls/sort-editor/words.js +25 -0
  236. package/views/dist/controls/sort-editor.css +96 -0
  237. package/views/dist/controls/switch-row/switch-row.d.ts +15 -0
  238. package/views/dist/controls/switch-row/switch-row.js +9 -0
  239. package/views/dist/controls/switch-row/tokens.d.ts +51 -0
  240. package/views/dist/controls/switch-row/tokens.js +15 -0
  241. package/views/dist/controls/switch-row.css +39 -0
  242. package/views/dist/controls/switch.css +1 -1
  243. package/views/dist/controls/tag/tag.js +3 -1
  244. package/views/dist/controls/tag-field/tag-field.d.ts +20 -0
  245. package/views/dist/controls/tag-field/tag-field.js +19 -0
  246. package/views/dist/controls/tag-field/tokens.d.ts +7 -0
  247. package/views/dist/controls/tag-field/tokens.js +4 -0
  248. package/views/dist/controls/tag-field.css +13 -0
  249. package/views/dist/controls/text-editor/looks.js +1 -1
  250. package/views/dist/controls/text-editor/text-editor.js +1 -5
  251. package/views/dist/controls/toast/toast.d.ts +79 -0
  252. package/views/dist/controls/toast/toast.js +101 -0
  253. package/views/dist/controls/toast/tokens.d.ts +100 -0
  254. package/views/dist/controls/toast/tokens.js +27 -0
  255. package/views/dist/controls/toast.css +93 -0
  256. package/views/dist/controls/tokens.js +38 -0
  257. package/views/dist/controls/toolbar/keys.d.ts +3 -0
  258. package/views/dist/controls/toolbar/keys.js +11 -0
  259. package/views/dist/controls/toolbar/looks.d.ts +10 -0
  260. package/views/dist/controls/toolbar/looks.js +40 -0
  261. package/views/dist/controls/toolbar/tokens.d.ts +28 -0
  262. package/views/dist/controls/toolbar/tokens.js +9 -0
  263. package/views/dist/controls/toolbar/toolbar.d.ts +111 -0
  264. package/views/dist/controls/toolbar/toolbar.js +370 -0
  265. package/views/dist/controls/toolbar/words.d.ts +28 -0
  266. package/views/dist/controls/toolbar/words.js +17 -0
  267. package/views/dist/controls/toolbar-button/looks.d.ts +4 -0
  268. package/views/dist/controls/toolbar-button/looks.js +21 -0
  269. package/views/dist/controls/toolbar-button/tokens.d.ts +103 -0
  270. package/views/dist/controls/toolbar-button/tokens.js +28 -0
  271. package/views/dist/controls/toolbar-button/toolbar-button.d.ts +66 -0
  272. package/views/dist/controls/toolbar-button/toolbar-button.js +51 -0
  273. package/views/dist/controls/toolbar-button.css +75 -0
  274. package/views/dist/controls/toolbar.css +65 -0
  275. package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
  276. package/views/dist/controls/tooltip/map-tooltip.js +2 -2
  277. package/views/dist/controls/tooltip/tooltip.d.ts +3 -1
  278. package/views/dist/controls/tooltip/tooltip.js +2 -2
  279. package/views/dist/controls/values-editor/looks.js +1 -1
  280. package/views/dist/controls/values-editor/values-editor.js +7 -1
  281. package/views/dist/controls/views-list/map-views-list-body.d.ts +4 -1
  282. package/views/dist/controls/views-list/map-views-list-body.js +128 -4
  283. package/views/dist/controls/views-list/rules.d.ts +26 -0
  284. package/views/dist/controls/views-list/rules.js +63 -0
  285. package/views/dist/controls/views-list/view-menu.d.ts +84 -0
  286. package/views/dist/controls/views-list/view-menu.js +201 -0
  287. package/views/dist/controls/views-list/views-list.d.ts +8 -1
  288. package/views/dist/controls/views-list/views-list.js +18 -3
  289. package/views/dist/controls/views-list/words.d.ts +54 -0
  290. package/views/dist/controls/views-list/words.js +10 -1
  291. package/views/dist/controls/views-list.css +5 -1
  292. package/views/dist/display/date.js +5 -5
  293. package/views/dist/display/format.d.ts +6 -0
  294. package/views/dist/display/format.js +13 -2
  295. package/views/dist/display/index.d.ts +1 -1
  296. package/views/dist/display/index.js +1 -1
  297. package/views/dist/display/options.d.ts +3 -1
  298. package/views/dist/display/range.d.ts +2 -1
  299. package/views/dist/display/range.js +4 -1
  300. package/views/dist/display/use-display-options.d.ts +3 -0
  301. package/views/dist/display/use-display-options.js +10 -2
  302. package/views/dist/display/viewer.d.ts +1 -1
  303. package/views/dist/display/viewer.js +1 -1
  304. package/views/dist/editors/DateEditor.js +11 -9
  305. package/views/dist/editors/relation-panel.js +7 -1
  306. package/views/dist/editors/relation-picker.d.ts +2 -1
  307. package/views/dist/editors/relation-picker.js +4 -3
  308. package/views/dist/editors/relation-source.d.ts +4 -1
  309. package/views/dist/editors/relation-source.js +5 -2
  310. package/views/dist/field-row/editors/RowNumberEditor.js +2 -2
  311. package/views/dist/fields/number-edit.d.ts +6 -0
  312. package/views/dist/fields/number-edit.js +8 -1
  313. package/views/dist/grid/chrome/GridCellEditors.js +2 -2
  314. package/views/dist/grid/chrome/GridColumnDateSection.d.ts +4 -3
  315. package/views/dist/grid/chrome/GridColumnDateSection.js +4 -4
  316. package/views/dist/grid/chrome/GridColumnDurationSection.js +2 -2
  317. package/views/dist/grid/chrome/GridColumnMenu.js +6 -4
  318. package/views/dist/grid/chrome/GridFooter.js +2 -2
  319. package/views/dist/grid/chrome/GridHeader.js +2 -1
  320. package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
  321. package/views/dist/grid/chrome/GridRowCells.js +2 -1
  322. package/views/dist/grid/chrome/GridTextEditor.js +2 -2
  323. package/views/dist/grid/chrome/grid-column-menu-items.js +4 -2
  324. package/views/dist/grid/chrome/grid-editor-layer.d.ts +5 -1
  325. package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
  326. package/views/dist/grid/chrome/grid-fitted-box.d.ts +7 -1
  327. package/views/dist/grid/chrome/grid-fitted-box.js +4 -4
  328. package/views/dist/grid/chrome/useGridBandFigures.js +2 -2
  329. package/views/dist/grid/chrome/useGridFittedWidths.d.ts +3 -0
  330. package/views/dist/grid/chrome/useGridFittedWidths.js +9 -3
  331. package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
  332. package/views/dist/grid/chrome/useGridKeyboard.js +5 -2
  333. package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -1
  334. package/views/dist/grid/core/clipboard-model.js +9 -4
  335. package/views/dist/grid/core/commit-model.d.ts +7 -0
  336. package/views/dist/grid/core/commit-model.js +5 -1
  337. package/views/dist/grid/core/editing-controller.js +10 -2
  338. package/views/dist/grid/core/editing-model.js +3 -7
  339. package/views/dist/grid/core/undo-owner.d.ts +6 -0
  340. package/views/dist/grid/core/undo-owner.js +13 -0
  341. package/views/dist/grid/core/useGridEditing.d.ts +2 -0
  342. package/views/dist/grid/core/useGridEditing.js +4 -0
  343. package/views/dist/grid/grid.css +240 -0
  344. package/views/dist/grid/looks.d.ts +5 -1
  345. package/views/dist/grid/looks.js +20 -12
  346. package/views/dist/grid-tokens.d.ts +109 -0
  347. package/views/dist/grid-tokens.js +29 -0
  348. package/views/dist/looks/index.d.ts +10 -0
  349. package/views/dist/looks/index.js +10 -0
  350. package/views/dist/looks/pieces.js +20 -0
  351. package/views/dist/model/column-capabilities.d.ts +2 -0
  352. package/views/dist/model/column-filters.d.ts +2 -1
  353. package/views/dist/model/column-from.js +2 -2
  354. package/views/dist/model/relation-filters.d.ts +2 -0
  355. package/views/dist/panels/index.d.ts +2 -2
  356. package/views/dist/panels/index.js +2 -2
  357. package/views/dist/panels/labels.d.ts +4 -0
  358. package/views/dist/panels/labels.js +8 -0
  359. package/views/dist/panels/model.d.ts +14 -1
  360. package/views/dist/panels/quick/model.d.ts +4 -0
  361. package/views/dist/panels/react/customize-body.d.ts +12 -5
  362. package/views/dist/panels/react/customize-body.js +41 -13
  363. package/views/dist/panels/react/customize.d.ts +8 -1
  364. package/views/dist/panels/react/customize.js +11 -6
  365. package/views/dist/panels/react/filter/FilterEditor.js +6 -6
  366. package/views/dist/panels/react/filter/FilterFieldList.js +10 -2
  367. package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +8 -2
  368. package/views/dist/panels/react/filter/PhoneFilterEditor.js +12 -9
  369. package/views/dist/panels/react/filter/filter-body.d.ts +8 -5
  370. package/views/dist/panels/react/filter/filter-body.js +21 -7
  371. package/views/dist/panels/react/filter/filter-part-body.d.ts +4 -1
  372. package/views/dist/panels/react/filter/filter-part-body.js +3 -1
  373. package/views/dist/panels/react/panel-sheet.d.ts +5 -1
  374. package/views/dist/panels/react/panel-sheet.js +6 -2
  375. package/views/dist/panels/react/panel-step.d.ts +15 -0
  376. package/views/dist/panels/react/panel-step.js +27 -0
  377. package/views/dist/panels/react/quick/QuickFiltersPanel.js +1 -0
  378. package/views/dist/panels/react/sort/SortEditor.d.ts +4 -0
  379. package/views/dist/panels/react/sort/SortEditor.js +5 -2
  380. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +18 -0
  381. package/views/dist/panels/react/toolbar/ReadyToolbar.js +93 -4
  382. package/views/dist/panels/react/toolbar/Toolbar.js +1 -1
  383. package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
  384. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +15 -5
  385. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +16 -0
  386. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +50 -0
  387. package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +3 -1
  388. package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +4 -1
  389. package/views/dist/panels/react/toolbar/ToolbarFilters.js +38 -23
  390. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +12 -4
  391. package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -2
  392. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +4 -1
  393. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +2 -2
  394. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
  395. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +15 -6
  396. package/views/dist/panels/react/toolbar/panel-part.d.ts +5 -1
  397. package/views/dist/panels/react/toolbar/panel-part.js +2 -2
  398. package/views/dist/panels/react/toolbar/use-filter-add.d.ts +16 -0
  399. package/views/dist/panels/react/toolbar/use-filter-add.js +32 -0
  400. package/views/dist/panels/react/view-footer.d.ts +1 -1
  401. package/views/dist/panels/react/views-row/ViewPicker.js +25 -4
  402. package/views/dist/panels/react.d.ts +1 -0
  403. package/views/dist/panels/react.js +1 -0
  404. package/views/dist/panels/settings/filter-groups.d.ts +3 -0
  405. package/views/dist/panels/settings/filter-groups.js +72 -7
  406. package/views/dist/panels/settings/filters.d.ts +5 -0
  407. package/views/dist/panels/settings/filters.js +12 -6
  408. package/views/dist/panels/settings/group-buckets.js +1 -0
  409. package/views/dist/panels/views-row/model.d.ts +10 -1
  410. package/views/dist/provider/ViewsProvider.d.ts +7 -1
  411. package/views/dist/provider/ViewsProvider.js +50 -6
  412. package/views/dist/provider/components.d.ts +178 -11
  413. package/views/dist/provider/context.d.ts +6 -0
  414. package/views/dist/provider/moment.d.ts +6 -0
  415. package/views/dist/provider/moment.js +10 -0
  416. package/views/dist/provider/ports.d.ts +18 -6
  417. package/views/dist/provider/ports.js +2 -1
  418. package/views/dist/react.d.ts +2 -2
  419. package/views/dist/react.js +1 -1
  420. package/views/dist/selection/SelectionBar.d.ts +2 -16
  421. package/views/dist/selection/SelectionBar.js +4 -1
  422. package/views/dist/selection/bar-props.d.ts +26 -0
  423. package/views/dist/selection/bar-props.js +1 -0
  424. package/views/dist/selection/index.d.ts +1 -1
  425. package/views/dist/selection/verbs.d.ts +32 -5
  426. package/views/dist/styles.css +1499 -73
  427. package/views/dist/styles.unlayered.css +1497 -70
  428. package/views/docs/contract.md +56 -23
  429. package/views/docs/controls/alert-dialog.md +37 -0
  430. package/views/docs/controls/alert.md +30 -0
  431. package/views/docs/controls/bulk-bar.md +41 -0
  432. package/views/docs/controls/choice.md +25 -0
  433. package/views/docs/controls/collapsible.md +22 -0
  434. package/views/docs/controls/customize.md +17 -0
  435. package/views/docs/controls/filter-editor.md +28 -0
  436. package/views/docs/controls/group-editor.md +11 -0
  437. package/views/docs/controls/modal.md +55 -0
  438. package/views/docs/controls/notice.md +32 -0
  439. package/views/docs/controls/pane.md +25 -0
  440. package/views/docs/controls/popover.md +2 -0
  441. package/views/docs/controls/press.md +9 -0
  442. package/views/docs/controls/quick-filters.md +35 -0
  443. package/views/docs/controls/radio.md +1 -1
  444. package/views/docs/controls/sort-editor.md +27 -0
  445. package/views/docs/controls/switch-row.md +18 -0
  446. package/views/docs/controls/tag-field.md +7 -0
  447. package/views/docs/controls/toast.md +32 -0
  448. package/views/docs/controls/toolbar-button.md +31 -0
  449. package/views/docs/controls/toolbar.md +14 -0
  450. package/views/docs/guides/atoms.md +2 -2
  451. package/views/docs/guides/cells.md +3 -3
  452. package/views/docs/guides/display.md +3 -3
  453. package/views/docs/guides/looks.md +8 -2
  454. package/views/docs/guides/ports.md +6 -6
  455. package/views/docs/guides/selection.md +5 -1
  456. package/views/docs/guides/the-grid.md +2 -2
  457. package/views/docs/guides/the-provider.md +21 -2
  458. package/views/docs/install.md +4 -1
  459. package/views/docs/reference/cells.md +3 -3
  460. package/views/docs/reference/controls.md +403 -16
  461. package/views/docs/reference/display.md +3 -2
  462. package/views/docs/reference/editors-relation.md +1 -1
  463. package/views/docs/reference/looks.md +35 -11
  464. package/views/docs/reference/panels-react.md +11 -10
  465. package/views/docs/reference/panels.md +9 -7
  466. package/views/docs/reference/react.md +20 -13
  467. package/views/docs/reference/selection.md +4 -2
  468. package/views/docs/reference/views.md +8 -6
  469. package/views/skills/views/SKILL.md +2 -2
@@ -0,0 +1,101 @@
1
+ import type { FieldType } from "viewkitjs/fields";
2
+ import type { FilterGroup, FilterNode, FilterRelationRule, FilterRule } from "viewkitjs/fields/query";
3
+ import type { ViewsFilterBodyField } from "../../provider/components.js";
4
+ import { type PickerItem } from "../picker/rows.js";
5
+ import { type FieldType as KitType, type FilterField } from "./how.js";
6
+ import { type FilterAside, type FilterGroup as KitGroup } from "./rules.js";
7
+ /** One node the kit can't draw, with the kit item it followed in its group (null: it stood first). */
8
+ export type KeptNode = {
9
+ node: FilterNode;
10
+ after: string | null;
11
+ };
12
+ /** What the kit can't draw, by the id of the kit group it stood in, with that group's parent, its join, and the ids of the items the
13
+ * kit read in it, in order (where a kept node whose item is gone goes: after the nearest earlier one still there). */
14
+ export type Kept = Record<string, {
15
+ parent: string | null;
16
+ op: FilterGroup["op"];
17
+ nodes: KeptNode[];
18
+ order: string[];
19
+ }>;
20
+ /** The ViewKit node each rule the kit draws but can't word stood for (a set-aside rule, a `vk:` way), by its kit id. */
21
+ export type Raw = ReadonlyMap<string, RawNode>;
22
+ /** The node a kit rule stood for, and the relation's field key when it stood inside a block (its where). */
23
+ export type RawNode = {
24
+ node: FilterRule | FilterRelationRule;
25
+ relation?: string;
26
+ };
27
+ /** A set-aside rule in words: its field's name, why, and whether Put back fits. `relation`: the relation's field key, for a far rule. */
28
+ export type AsideWords = (rule: FilterRule | FilterRelationRule, relation?: string) => FilterAside;
29
+ /** The kit types whose value is picked from choices. */
30
+ export declare const CHOICE: ReadonlySet<KitType>;
31
+ /** A field's type as the kit's filter editor draws it; null for one it doesn't (a place whole, a lookup…), whose rules are ViewKit's to
32
+ * word (`own:`). */
33
+ export declare const kitTypeOf: (type: FieldType) => KitType | null;
34
+ /** A part's type as the kit draws it, by fields' operators for it (operatorsFor): a place's city, region and postal code are words;
35
+ * its country, compared as options, a choice of country names (VK-735); a range's end is a number. ViewKit hands a part with its whole field's
36
+ * type; any other type ignores its part. */
37
+ export declare function kitPartTypeOf(type: FieldType, part: string | undefined): KitType | null;
38
+ /** Where a kit field's rule goes in ViewKit's filter: its field, its part, and for a related record's field, the relation's field key. */
39
+ export type FieldAt = {
40
+ fieldKey: string;
41
+ part?: string;
42
+ relation?: string;
43
+ };
44
+ /** The kit's fields, and where each one's rule goes (a part the kit lists no field for, too: its rules are ViewKit's to word). */
45
+ export type KitFields = {
46
+ fields: FilterField[];
47
+ at: ReadonlyMap<string, FieldAt>;
48
+ /** Each relation's kit field (its Related records row), by ViewKit's field key. */
49
+ relations: ReadonlyMap<string, string>;
50
+ };
51
+ /** A field's values to pick from, by its key, and for a related record's field, its relation's; a part's (a place's country) by
52
+ * its part. */
53
+ export type ChoicesOf = (fieldKey: string, relation?: string, part?: string) => PickerItem[] | undefined;
54
+ /** The heading the related records stand under, ViewKit's own English (views.panels.related-records). */
55
+ export declare const RELATED = "Related records";
56
+ /** A related record's field as one value of the kit's: the relation's row and the far field's key; and back. */
57
+ export declare const pathOf: (relationKey: string, farKey: string) => string;
58
+ export declare const pathParts: (value: string) => [string, string?];
59
+ /** The fields ViewKit hands as the kit's filter editor takes them: each of a type it draws, a part by its own type, a choice's values
60
+ * from `choices` (a choice with none stays a field, its value ViewKit's to draw), a yes/no's Checked and Unchecked; then each
61
+ * relation under Related records, its far fields one level in. A place's part the kit draws no type for is no field of the kit's,
62
+ * but its place is known, so a rule on it is ViewKit's to word. Open on a relation's where (`relation`, its field key), that
63
+ * relation's far fields alone, as plain fields. */
64
+ export declare function kitFieldsOf(fields: readonly ViewsFilterBodyField[], choices: ChoicesOf, relation?: string): KitFields;
65
+ /** The field a rule the kit has no type for names: ViewKit's to word (`own:<fieldKey>~<part>`). */
66
+ export declare const OWN_FIELD = "own:";
67
+ /** The way of a relation rule drawn as one row (set aside, or on a relation the fields don't list). */
68
+ export declare const RELATION_WAY = "vk:relation";
69
+ /** The kit's filter as a level of ViewKit's: its join (`not` again where the level read excluded its matches), its rules in fields'
70
+ * operators, its groups, each rule the kit can't word as the node it was read from (`raw`), and what was kept back in each group in
71
+ * its place, a group the kit took away handing its kept to the nearest one left. */
72
+ export declare function viewKitFilterOf(filter: KitGroup, fields: KitFields, kept: Kept, raw?: Raw): FilterGroup;
73
+ /** A level of ViewKit's filter as the kit's: its rules and groups, ids `root`, then `v1`… and `r1`… in reading order; a set-aside rule
74
+ * carrying its words (`asideWords`), a rule on a way or a place's part the kit can't word on its `vk:` way, each with the node it was
75
+ * read from in `raw`. A `not` group is a kit group that excludes its matches (`exclude`, joined by And), or a date's "is not" an
76
+ * older view holds; the level itself too. A relation rule with "any" and one plain rule in its where, on a far field, is the kit's
77
+ * rule on its path, as drawn flat; any other a block (`relation`), its where's rules on its relation's fields; one set aside, or on
78
+ * a relation the fields don't list, one row in its words (VK-827). A rule on a field the kit has no type for is ViewKit's to word
79
+ * (`own:`). What is kept by the group it stands in, with the item it followed, is left to a group holding nothing and a relation
80
+ * rule inside a where, which fields refuses: nothing a person's filter holds is out of sight. */
81
+ export declare function kitFilterOf(level: FilterGroup, fields: KitFields, asideWords?: AsideWords): {
82
+ filter: KitGroup;
83
+ kept: Kept;
84
+ raw: Map<string, RawNode>;
85
+ };
86
+ /** What one level was written from: the kit's rules, what it kept, and the nodes of the rules it can't word. */
87
+ type Read = {
88
+ filter: KitGroup;
89
+ kept: Kept;
90
+ raw: Raw;
91
+ };
92
+ /** The levels one filter body wrote holding a rule written as nothing (a yes/no with nothing picked): kept by that body alone, so
93
+ * the same level written elsewhere (an unfiltered view, a filter on Stage alone) never shows the rule. */
94
+ export type Written = Map<string, Read>;
95
+ /** The kit's rules for a level ViewKit hands: those that wrote it (in the body's own `own` first), else the level read afresh. */
96
+ export declare function rulesFor(level: FilterGroup, fields: KitFields, own?: Written, asideWords?: AsideWords): Read;
97
+ /** The kit's rules as the level to hand ViewKit, remembered as the rules that wrote it, the latest for a level written twice: in
98
+ * the body's own `own` where a rule was written as nothing, else for every list. The body keeps only its latest write, so a blank
99
+ * it wrote earlier never comes back when its level does. */
100
+ export declare function writeRules(filter: KitGroup, fields: KitFields, kept: Kept, own?: Written, raw?: Raw): FilterGroup;
101
+ export {};
@@ -0,0 +1,304 @@
1
+ import { findItem } from "../picker/rows.js";
2
+ import { CHECKED } from "./how.js";
3
+ import { isOwnWay, isPair, OWN_WAY, rulesOf } from "./rules.js";
4
+ const TYPES = {
5
+ status: "status", select: "select", multiselect: "select", user: "person", actor: "person", relation: "record",
6
+ number: "number", currency: "number", percent: "number",
7
+ text: "text", email: "text", url: "text", domain: "text", phone: "text", name: "text",
8
+ date: "date", datetime: "date", boolean: "checkbox", range: "range", rich_text: "longtext",
9
+ };
10
+ export const CHOICE = new Set(["status", "select", "person", "record"]);
11
+ export const kitTypeOf = (type) => TYPES[type] ?? null;
12
+ export function kitPartTypeOf(type, part) {
13
+ if (part === undefined)
14
+ return kitTypeOf(type);
15
+ if (type === "location")
16
+ return part === "city" || part === "region" || part === "postalCode" ? "text" : part === "countryCode" ? "select" : null;
17
+ if (type === "range")
18
+ return "number";
19
+ return kitTypeOf(type);
20
+ }
21
+ export const RELATED = "Related records";
22
+ const SEP = "\u0000";
23
+ export const pathOf = (relationKey, farKey) => `${relationKey}${SEP}${farKey}`;
24
+ export const pathParts = (value) => {
25
+ const at = value.indexOf(SEP);
26
+ return at < 0 ? [value] : [value.slice(0, at), value.slice(at + 1)];
27
+ };
28
+ const placeOf = (a) => [a.relation ?? "", a.fieldKey, a.part ?? ""].join(SEP);
29
+ export function kitFieldsOf(fields, choices, relation) {
30
+ const at = new Map();
31
+ const field = (f, value, place, from) => {
32
+ const type = kitPartTypeOf(f.type, f.part);
33
+ if (f.disabled !== undefined)
34
+ return [{ value, label: f.label, type: type ?? "text", disabled: true, line: f.disabled }];
35
+ if (!type) {
36
+ if (f.part !== undefined)
37
+ at.set(value, place);
38
+ return [];
39
+ }
40
+ const values = type === "checkbox" ? CHECKED : CHOICE.has(type) ? choices(f.fieldKey, from, f.part) : undefined;
41
+ at.set(value, place);
42
+ return [{ value, label: f.label, type, ...(values ? { choices: values } : {}) }];
43
+ };
44
+ const own = (f, from) => field(f, f.key, { fieldKey: f.fieldKey, ...(f.part !== undefined ? { part: f.part } : {}) }, from);
45
+ const relations = new Map();
46
+ if (relation !== undefined)
47
+ return { fields: (fields.find((f) => f.far && f.fieldKey === relation)?.far ?? []).flatMap((f) => own(f, relation)), at, relations };
48
+ const list = fields.filter((f) => !f.far).flatMap((f) => own(f));
49
+ const related = fields.filter((f) => f.far).flatMap((r) => {
50
+ const level = (r.far ?? []).flatMap((f) => field(f, pathOf(r.key, f.key), { fieldKey: f.fieldKey, ...(f.part !== undefined ? { part: f.part } : {}), relation: r.fieldKey }, r.fieldKey));
51
+ if (!level.length)
52
+ return [];
53
+ relations.set(r.fieldKey, r.key);
54
+ return [{ value: r.key, label: r.label, type: "record", group: RELATED, level }];
55
+ });
56
+ return { fields: [...list, ...related], at, relations };
57
+ }
58
+ const none = { write: () => null, read: () => null };
59
+ const list = (v) => (Array.isArray(v) ? v.map(String) : typeof v === "string" ? [v] : []);
60
+ const one = { write: (v) => (typeof v === "string" ? [v] : []), read: (v) => (Array.isArray(v) && typeof v[0] === "string" ? v[0] : null) };
61
+ const several = { write: list, read: list };
62
+ const words = { write: (v) => (typeof v === "string" ? v : ""), read: (v) => (typeof v === "string" && v ? v : null) };
63
+ const figure = { write: (v) => (typeof v === "number" ? v : null), read: (v) => (typeof v === "number" ? v : null) };
64
+ const day = { write: (v) => (typeof v === "string" && v ? v : null), read: (v) => (typeof v === "string" && v ? v : null) };
65
+ const end = (n) => (typeof n === "number" ? n : null);
66
+ const pair = {
67
+ write: (v) => (isPair(v) ? [v[0], v[1]] : [null, null]),
68
+ read: (v) => { if (!Array.isArray(v))
69
+ return null; const p = [end(v[0]), end(v[1])]; return p[0] === null && p[1] === null ? null : p; },
70
+ };
71
+ const yesNo = { write: (v) => (v === "true" ? true : v === "false" ? false : undefined), read: (v) => (typeof v === "boolean" ? String(v) : null) };
72
+ const EMPTINESS = [{ how: "empty", operator: "is_empty", ...none }, { how: "not-empty", operator: "is_not_empty", ...none }];
73
+ const WAYS = {
74
+ ...Object.fromEntries(["status", "select", "person", "record"].map((t) => [t, [
75
+ { how: "is-any-of", operator: "is_any_of", ...several }, { how: "is-none-of", operator: "is_none_of", ...several },
76
+ { how: "is", operator: "is_any_of", ...one }, { how: "is-not", operator: "is_none_of", ...one }, ...EMPTINESS
77
+ ]])),
78
+ number: [{ how: "is", operator: "eq", ...figure }, { how: "is-not", operator: "neq", ...figure }, { how: "less-than", operator: "lt", ...figure },
79
+ { how: "greater-than", operator: "gt", ...figure }, ...EMPTINESS],
80
+ text: [{ how: "contains", operator: "contains", ...words }, { how: "does-not-contain", operator: "not_contains", ...words },
81
+ { how: "starts-with", operator: "starts_with", ...words }, { how: "ends-with", operator: "ends_with", ...words },
82
+ { how: "is", operator: "is", ...words }, { how: "is-not", operator: "is_not", ...words }, ...EMPTINESS],
83
+ longtext: [{ how: "contains", operator: "contains", ...words }, { how: "does-not-contain", operator: "not_contains", ...words }, ...EMPTINESS],
84
+ date: [{ how: "is", operator: "is", ...day }, { how: "is-not", operator: "is_not", ...day }, { how: "before", operator: "is_before", ...day },
85
+ { how: "after", operator: "is_after", ...day }, ...EMPTINESS],
86
+ checkbox: [{ how: "is", operator: "is", ...yesNo }],
87
+ range: [{ how: "any-part-between", operator: "overlaps", ...pair }, { how: "entirely-within", operator: "within", ...pair }, { how: "includes", operator: "includes", ...figure },
88
+ { how: "at-least", operator: "at_least", ...figure }, { how: "at-most", operator: "at_most", ...figure }, ...EMPTINESS],
89
+ };
90
+ const ASIDE_FIELD = "aside:";
91
+ export const OWN_FIELD = "own:";
92
+ export const RELATION_WAY = `${OWN_WAY}relation`;
93
+ const typeOf = (f, key) => findItem(f.fields, key)?.item.type;
94
+ const isGroup = (n) => "op" in n;
95
+ const isKitGroup = (x) => "rules" in x;
96
+ const isRelation = (n) => "quantifier" in n;
97
+ const plainRule = (n) => !isGroup(n) && !isRelation(n) && !n.setAside;
98
+ const groupIds = (g) => [g.id, ...g.rules.flatMap((r) => (isKitGroup(r) ? groupIds(r) : []))];
99
+ const holds = (g, id) => g.rules.some((r) => r.id === id || (isKitGroup(r) && holds(r, id)));
100
+ const itemFor = (g, id) => g.rules.find((r) => r.id === id || (isKitGroup(r) && holds(r, id)));
101
+ function anchorIn(g, order, after) {
102
+ if (after === null)
103
+ return null;
104
+ const here = itemFor(g, after);
105
+ if (here)
106
+ return here.id;
107
+ for (let i = order.indexOf(after) - 1; i >= 0; i--) {
108
+ const earlier = itemFor(g, order[i]);
109
+ if (earlier)
110
+ return earlier.id;
111
+ }
112
+ return null;
113
+ }
114
+ export function viewKitFilterOf(filter, fields, kept, raw = new Map()) {
115
+ const here = new Set(groupIds(filter)), orphans = {};
116
+ for (const [id, k] of Object.entries(kept)) {
117
+ if (here.has(id) || !k.nodes.length)
118
+ continue;
119
+ let to = k.parent;
120
+ while (to && !here.has(to))
121
+ to = kept[to]?.parent ?? null;
122
+ (orphans[to ?? filter.id] ??= []).push({ op: k.op, items: k.nodes.map((n) => n.node) });
123
+ }
124
+ return levelOf(filter, fields, kept, raw, orphans);
125
+ }
126
+ function withoutAside(n) {
127
+ const { setAside: _gone, ...rest } = n;
128
+ return isRelation(n) ? { ...rest, where: { ...n.where, items: n.where.items.map((i) => (isGroup(i) || isRelation(i) ? i : withoutAside(i))) } } : rest;
129
+ }
130
+ function ruleNodes(x, fields, raw, inRelation) {
131
+ const held = raw.get(x.id)?.node;
132
+ const was = held && inRelation !== undefined && isRelation(held) && held.fieldKey === inRelation ? held.where.items[0] : held;
133
+ if (was && x.aside)
134
+ return [was];
135
+ if (was && isOwnWay(x.how))
136
+ return [withoutAside(was)];
137
+ const type = typeOf(fields, x.field), place = fields.at.get(x.field);
138
+ const way = type && WAYS[type].find((w) => w.how === x.how);
139
+ const value = way && way.write(x.value);
140
+ if (!way || !place || value === undefined)
141
+ return [];
142
+ const rule = { fieldKey: place.fieldKey, ...(place.part !== undefined ? { part: place.part } : {}), operator: way.operator, value };
143
+ return [place.relation !== undefined && place.relation !== inRelation ? { fieldKey: place.relation, quantifier: "any", where: { op: "and", items: [rule] } } : rule];
144
+ }
145
+ const relationKeyOf = (fields, field) => [...fields.relations].find(([, value]) => value === field)?.[0];
146
+ function levelOf(filter, fields, kept, raw, orphans, inRelation) {
147
+ const k = kept[filter.id];
148
+ const after = new Map();
149
+ for (const n of k?.nodes ?? []) {
150
+ const at = anchorIn(filter, k?.order ?? [], n.after);
151
+ after.set(at, [...(after.get(at) ?? []), n.node]);
152
+ }
153
+ const items = [...(after.get(null) ?? [])];
154
+ for (const x of filter.rules) {
155
+ items.push(...(isKitGroup(x) ? groupNodes(x, fields, kept, raw, orphans, inRelation) : ruleNodes(x, fields, raw, inRelation)), ...(after.get(x.id) ?? []));
156
+ }
157
+ return { op: filter.exclude ? "not" : filter.join, items: [...items, ...(orphans[filter.id] ?? [])] };
158
+ }
159
+ function groupNodes(x, fields, kept, raw, orphans, inRelation) {
160
+ if (!x.relation)
161
+ return [levelOf(x, fields, kept, raw, orphans, inRelation)];
162
+ const key = relationKeyOf(fields, x.relation.field);
163
+ if (key === undefined)
164
+ return [];
165
+ const where = levelOf(x, fields, kept, raw, orphans, key);
166
+ return [{ fieldKey: key, quantifier: x.relation.quantifier, where: { op: where.op === "or" ? "or" : "and", items: where.items } }];
167
+ }
168
+ export function kitFilterOf(level, fields, asideWords) {
169
+ const kept = {}, raw = new Map();
170
+ let groups = 0, rules = 0;
171
+ const back = new Map([...fields.at].map(([value, place]) => [placeOf(place), value]));
172
+ const valueOf = (n, relation) => back.get(placeOf({ fieldKey: n.fieldKey, ...(n.part !== undefined ? { part: n.part } : {}), ...(relation !== undefined ? { relation } : {}) }));
173
+ const hold = (id, node, inBlock) => raw.set(id, isRelation(node) || inBlock === undefined ? { node } : { node, relation: inBlock });
174
+ const read = (n, relation, how) => {
175
+ const value = valueOf(n, relation), type = value && typeOf(fields, value), way = type && WAYS[type].find(how ?? ((w) => w.operator === n.operator));
176
+ return value && way ? { id: `r${++rules}`, field: value, how: way.how, value: way.read(n.value) } : null;
177
+ };
178
+ const readOwn = (n, node, relation, inBlock) => {
179
+ const value = valueOf(n, relation);
180
+ if (!value)
181
+ return null;
182
+ const id = `r${++rules}`;
183
+ hold(id, node, inBlock);
184
+ return { id, field: value, how: `${OWN_WAY}${n.operator}`, value: null };
185
+ };
186
+ const readTheirs = (n, inBlock) => {
187
+ const id = `r${++rules}`;
188
+ hold(id, n, inBlock);
189
+ return { id, field: `${OWN_FIELD}${n.fieldKey}${n.part !== undefined ? `~${n.part}` : ""}`, how: `${OWN_WAY}${n.operator}`, value: null };
190
+ };
191
+ const readAside = (n, relation, node = n, inBlock) => {
192
+ const value = valueOf(n, relation), type = value && typeOf(fields, value), way = type && WAYS[type].find((w) => w.operator === n.operator);
193
+ const id = `r${++rules}`;
194
+ hold(id, node, inBlock);
195
+ return {
196
+ id, field: value ?? `${ASIDE_FIELD}${n.fieldKey}${n.part !== undefined ? `~${n.part}` : ""}`,
197
+ how: way ? way.how : `${OWN_WAY}${n.operator}`, value: way ? way.read(n.value) : null,
198
+ aside: asideWords?.(n, relation) ?? { label: n.fieldKey, why: "", putBack: false },
199
+ };
200
+ };
201
+ const readAsideRelation = (n) => {
202
+ const id = `r${++rules}`;
203
+ hold(id, n);
204
+ return { id, field: `${ASIDE_FIELD}${n.fieldKey}`, how: RELATION_WAY, value: null, aside: asideWords?.(n) ?? { label: n.fieldKey, why: "", putBack: false } };
205
+ };
206
+ const dateIsNot = (n, relation) => {
207
+ const [only] = n.items;
208
+ if (n.op !== "not" || n.items.length !== 1 || !only || !plainRule(only) || only.operator !== "is")
209
+ return null;
210
+ const value = valueOf(only, relation);
211
+ return value && typeOf(fields, value) === "date" ? read(only, relation, (w) => w.how === "is-not") : null;
212
+ };
213
+ const walk = (g, id, parent, inBlock) => {
214
+ const out = [];
215
+ const place = () => (kept[id] ??= { parent, op: g.op, nodes: [], order: [] });
216
+ const keep = (n) => { place().nodes.push({ node: n, after: out.at(-1)?.id ?? null }); };
217
+ for (const n of g.items) {
218
+ if (isGroup(n)) {
219
+ const not = dateIsNot(n, inBlock);
220
+ if (not) {
221
+ out.push(not);
222
+ continue;
223
+ }
224
+ const inner = walk(n, `v${++groups}`, id, inBlock);
225
+ if (inner.rules.length)
226
+ out.push(inner);
227
+ else {
228
+ delete kept[inner.id];
229
+ keep(n);
230
+ }
231
+ continue;
232
+ }
233
+ if (isRelation(n)) {
234
+ if (inBlock !== undefined) {
235
+ keep(n);
236
+ continue;
237
+ }
238
+ const [only] = n.where.items;
239
+ const one = n.quantifier === "any" && n.where.items.length === 1 && !!only && !isGroup(only) && !isRelation(only) && only.part === undefined;
240
+ const aside = one && (n.setAside || only.setAside) ? readAside({ ...only, ...(only.setAside ?? n.setAside ? { setAside: only.setAside ?? n.setAside } : {}) }, n.fieldKey, n) : null;
241
+ const flat = aside ?? (one && plainRule(only) ? read(only, n.fieldKey) ?? readOwn(only, n, n.fieldKey) : null);
242
+ if (flat) {
243
+ out.push(flat);
244
+ continue;
245
+ }
246
+ const relation = fields.relations.get(n.fieldKey);
247
+ if (n.setAside || relation === undefined) {
248
+ out.push(readAsideRelation(n));
249
+ continue;
250
+ }
251
+ const block = walk(n.where, `v${++groups}`, id, n.fieldKey);
252
+ out.push({ ...block, relation: { field: relation, quantifier: n.quantifier } });
253
+ continue;
254
+ }
255
+ out.push(n.setAside ? readAside(n, inBlock, n, inBlock) : read(n, inBlock) ?? readOwn(n, n, inBlock, inBlock) ?? readTheirs(n, inBlock));
256
+ }
257
+ if (kept[id])
258
+ kept[id].order = out.map((x) => x.id);
259
+ return { id, join: g.op === "or" ? "or" : "and", rules: out, ...(g.op === "not" ? { exclude: true } : {}) };
260
+ };
261
+ return { filter: walk(level, "root", null), kept, raw };
262
+ }
263
+ function settled(filter, kept) {
264
+ const here = new Set(groupIds(filter)), out = {}, landing = {};
265
+ for (const [id, k] of Object.entries(kept)) {
266
+ if (here.has(id) || !k.nodes.length)
267
+ continue;
268
+ let to = k.parent;
269
+ while (to && !here.has(to))
270
+ to = kept[to]?.parent ?? null;
271
+ (landing[to ?? filter.id] ??= []).push({ op: k.op, items: k.nodes.map((n) => n.node) });
272
+ }
273
+ const walk = (g, parent) => {
274
+ const k = kept[g.id], last = g.rules.at(-1)?.id ?? null;
275
+ const nodes = [...(k?.nodes ?? []).map((n) => ({ node: n.node, after: anchorIn(g, k?.order ?? [], n.after) })), ...(landing[g.id] ?? []).map((node) => ({ node, after: last }))];
276
+ if (k || nodes.length)
277
+ out[g.id] = { parent, op: k?.op ?? g.join, nodes, order: g.rules.map((r) => r.id) };
278
+ for (const r of g.rules)
279
+ if (isKitGroup(r))
280
+ walk(r, g.id);
281
+ };
282
+ walk(filter, null);
283
+ return out;
284
+ }
285
+ const WRITTEN = new Map();
286
+ const WRITTEN_MAX = 50;
287
+ function writesNothing(filter, fields) {
288
+ return rulesOf(filter).some((r) => { const type = typeOf(fields, r.field), way = type && WAYS[type].find((w) => w.how === r.how); return !!way && fields.at.has(r.field) && way.write(r.value) === undefined; });
289
+ }
290
+ export function rulesFor(level, fields, own, asideWords) {
291
+ const key = JSON.stringify(level);
292
+ return own?.get(key) ?? WRITTEN.get(key) ?? kitFilterOf(level, fields, asideWords);
293
+ }
294
+ export function writeRules(filter, fields, kept, own, raw = new Map()) {
295
+ const level = viewKitFilterOf(filter, fields, kept, raw), key = JSON.stringify(level), at = writesNothing(filter, fields) ? own : WRITTEN;
296
+ own?.clear();
297
+ if (!at)
298
+ return level;
299
+ at.delete(key);
300
+ at.set(key, { filter, kept: settled(filter, kept), raw });
301
+ if (at.size > WRITTEN_MAX)
302
+ at.delete(at.keys().next().value);
303
+ return level;
304
+ }
@@ -0,0 +1,46 @@
1
+ import * as React from "react";
2
+ import type { FilterOwn } from "./filter-editor.js";
3
+ import { type FilterField } from "./how.js";
4
+ import { type FilterGroup, type FilterRule } from "./rules.js";
5
+ import { type FilterEditorWords } from "./words.js";
6
+ /** Which part of a filter was pressed: its field, how it compares, or its value. */
7
+ export type FilterPart = "field" | "how" | "value";
8
+ export interface FilterPartProps {
9
+ /** The part pressed. */
10
+ part: FilterPart;
11
+ /** The filter's rule, by its id; none for Filter and +, which add one. */
12
+ rule?: string;
13
+ /** What it is, to a screen reader ("Filter"). */
14
+ label: string;
15
+ /** The fields a list filters by, each typed, a choice's values with it. */
16
+ fields: FilterField[];
17
+ /** The view's filter. */
18
+ filter: FilterGroup;
19
+ /** Each change, as it is made: a filter added, its field, its way or its value changed. A rule's change comes as a change to the
20
+ * filter as it stands when it lands, so a value typed and kept as its editor leaves the page changes nothing where its rule is
21
+ * gone and never brings an earlier filter back. */
22
+ onFilterChange: (filter: FilterGroup | ((now: FilterGroup) => FilterGroup)) => void;
23
+ /** The job is done and the Popover closes: a field or a way picked, one value picked, Enter in a typed value. */
24
+ onDone: () => void;
25
+ /** ViewKit's own words and value body for a rule the kit has no box for; null where the kit draws it. */
26
+ own?: (rule: FilterRule) => FilterOwn | null;
27
+ /** Which form its lists take; the computer's unless said. */
28
+ form?: "computer" | "phone";
29
+ /** Its words; English unless handed. */
30
+ words?: Partial<FilterEditorWords>;
31
+ }
32
+ /** What the fields' search says. */
33
+ export declare const FILTER_SEARCH: string;
34
+ /** What a filter's value says on the bar while it has none, by its field's type. */
35
+ export declare function valuePlaceholder(field: FilterField, w?: FilterEditorWords): string;
36
+ /** The body a Popover holds under the part of a filter pressed: the fields, its type's ways, or its value in its type's own. */
37
+ export declare function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFilterChange, onDone, own, form, words: given }: FilterPartProps): import("react/jsx-runtime").JSX.Element | null;
38
+ /** A range's From and To: two Number fields, an en dash between, each named by its end; either may be left empty. */
39
+ export declare function PairValue({ name, value, onValue, size, onKeyDown, words: given }: {
40
+ name: string;
41
+ value: [number | null, number | null];
42
+ onValue: (v: [number | null, number | null]) => void;
43
+ size?: "sm" | "lg";
44
+ onKeyDown?: (e: React.KeyboardEvent) => void;
45
+ words?: Partial<FilterEditorWords>;
46
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { DateEditor } from "../date-editor/date-editor.js";
4
+ import { Input } from "../input/input.js";
5
+ import { NumberField } from "../number-field/number-field.js";
6
+ import { Picker } from "../picker/picker.js";
7
+ import { itemLabel } from "../picker/rows.js";
8
+ import { HOW, wayOf } from "./how.js";
9
+ import { addRule, changeRule, fieldOf, isOwnWay, isPair, rulesOf } from "./rules.js";
10
+ import { filterWords, FILTER_EDITOR_WORDS } from "./words.js";
11
+ export const FILTER_SEARCH = FILTER_EDITOR_WORDS.search;
12
+ export function valuePlaceholder(field, w = FILTER_EDITOR_WORDS) {
13
+ if (field.choices)
14
+ return w.choose;
15
+ return field.type === "number" || field.type === "range" ? w.typeNumber : field.type === "date" ? w.chooseDate : w.typeValue;
16
+ }
17
+ export function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFilterChange, onDone, own, form = "computer", words: given }) {
18
+ const w = filterWords(given), words = w.picker ? { words: w.picker } : {};
19
+ const r = ruleId ? rulesOf(filter).find((x) => x.id === ruleId) : undefined;
20
+ const field = r && fieldOf(fields, r.field), name = r ? itemLabel(fields, r.field) : label;
21
+ const set = (change) => { if (r)
22
+ onFilterChange((now) => (rulesOf(now).some((x) => x.id === r.id) ? changeRule(now, r.id, change, fields) : now)); };
23
+ if (part === "field")
24
+ return (_jsx(Picker, { label: r ? name : label, items: fields, value: r?.field ?? null, search: w.search, searchShown: true, form: form, onDone: onDone, ...words, onValueChange: (v) => {
25
+ if (typeof v !== "string")
26
+ return;
27
+ if (!r) {
28
+ const added = addRule(filter, v, fields);
29
+ if (added.id)
30
+ onFilterChange(added.filter);
31
+ }
32
+ else if (v !== r.field)
33
+ set({ field: v });
34
+ } }));
35
+ if (!r)
36
+ return null;
37
+ const theirs = part === "value" ? own?.(r) : null;
38
+ if (theirs)
39
+ return _jsx(_Fragment, { children: theirs.body });
40
+ if (!field)
41
+ return null;
42
+ const takes = wayOf(field.type, r.how)?.takes;
43
+ if (part === "how") {
44
+ const ways = HOW[field.type].map((x) => ({ value: x.value, label: w.way(x.value), divider: x.value === "empty" }));
45
+ return _jsx(Picker, { label: w.howOf(name), items: ways, value: isOwnWay(r.how) ? null : r.how, searchShown: false, form: form, onDone: onDone, ...words, onValueChange: (v) => { if (typeof v === "string" && v !== r.how)
46
+ set({ how: v }); } });
47
+ }
48
+ if (!takes || takes === "none")
49
+ return null;
50
+ if (field.choices) {
51
+ const several = takes === "several", value = several ? (Array.isArray(r.value) && !isPair(r.value) ? r.value : []) : typeof r.value === "string" ? r.value : null;
52
+ return _jsx(Picker, { label: name, items: field.choices, multiple: several, value: value, form: form, onDone: onDone, ...words, onValueChange: (v) => set({ value: several ? (Array.isArray(v) ? v : []) : typeof v === "string" ? v : null }) });
53
+ }
54
+ if (takes === "two")
55
+ return _jsx(PairValue, { name: name, value: isPair(r.value) ? r.value : [null, null], onValue: (v) => set({ value: v }), words: w, onKeyDown: (e) => { if (e.key === "Enter") {
56
+ e.preventDefault();
57
+ onDone();
58
+ } } });
59
+ if (field.type === "date")
60
+ return _jsx(DateEditor, { label: name, value: typeof r.value === "string" ? r.value : null, onValueChange: (v) => set({ value: v }), onDone: onDone, form: form });
61
+ return _jsx(TypedValue, { rule: r, field: field, name: name, set: set, onDone: onDone, w: w });
62
+ }
63
+ export function PairValue({ name, value, onValue, size, onKeyDown, words: given }) {
64
+ const w = filterWords(given), [from, to] = value;
65
+ return (_jsxs("div", { className: "o-filter-editor-pair", children: [_jsx(NumberField, { size: size, steppers: false, "aria-label": w.fromOf(name), placeholder: w.from, value: from, onValueChange: (v) => onValue([v ?? null, to]), onKeyDown: onKeyDown }), _jsx("span", { className: "o-filter-editor-dash", "aria-hidden": "true", children: "\u2013" }), _jsx(NumberField, { size: size, steppers: false, "aria-label": w.toOf(name), placeholder: w.to, value: to, onValueChange: (v) => onValue([from, v ?? null]), onKeyDown: onKeyDown })] }));
66
+ }
67
+ function TypedValue({ rule: r, field, name, set, onDone, w }) {
68
+ const enter = (e) => { if (e.key === "Enter") {
69
+ e.preventDefault();
70
+ onDone();
71
+ } };
72
+ return field.type === "number" || field.type === "range"
73
+ ? _jsx(NumberField, { "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "number" ? r.value : null, onValueChange: (v) => set({ value: v ?? null }), onKeyDown: enter })
74
+ : _jsx(Input, { "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "string" ? r.value : "", onChange: (e) => set({ value: e.target.value }), onKeyDown: enter });
75
+ }