viewkitjs 0.26.0 → 0.28.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 (294) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/MIGRATION.md +122 -7
  3. package/package.json +1 -1
  4. package/views/dist/cells/cell-format.d.ts +3 -1
  5. package/views/dist/cells/cell-format.js +2 -2
  6. package/views/dist/cells/use-cell-format.d.ts +8 -1
  7. package/views/dist/cells/use-cell-format.js +13 -2
  8. package/views/dist/contract.d.ts +240 -3
  9. package/views/dist/contract.js +238 -0
  10. package/views/dist/controls/alert/alert.d.ts +46 -0
  11. package/views/dist/controls/alert/alert.js +11 -0
  12. package/views/dist/controls/alert/looks.d.ts +4 -0
  13. package/views/dist/controls/alert/looks.js +19 -0
  14. package/views/dist/controls/alert/tokens.d.ts +92 -0
  15. package/views/dist/controls/alert/tokens.js +25 -0
  16. package/views/dist/controls/alert-dialog/alert-dialog.d.ts +50 -0
  17. package/views/dist/controls/alert-dialog/alert-dialog.js +67 -0
  18. package/views/dist/controls/alert-dialog/confirm.d.ts +13 -0
  19. package/views/dist/controls/alert-dialog/confirm.js +11 -0
  20. package/views/dist/controls/alert-dialog/looks.d.ts +4 -0
  21. package/views/dist/controls/alert-dialog/looks.js +17 -0
  22. package/views/dist/controls/alert-dialog/tokens.d.ts +119 -0
  23. package/views/dist/controls/alert-dialog/tokens.js +32 -0
  24. package/views/dist/controls/alert-dialog.css +95 -0
  25. package/views/dist/controls/alert.css +51 -0
  26. package/views/dist/controls/collapsible/collapsible.d.ts +39 -0
  27. package/views/dist/controls/collapsible/collapsible.js +18 -0
  28. package/views/dist/controls/collapsible/looks.d.ts +4 -0
  29. package/views/dist/controls/collapsible/looks.js +5 -0
  30. package/views/dist/controls/collapsible/map-collapse.d.ts +2 -0
  31. package/views/dist/controls/collapsible/map-collapse.js +6 -0
  32. package/views/dist/controls/collapsible/tokens.d.ts +68 -0
  33. package/views/dist/controls/collapsible/tokens.js +19 -0
  34. package/views/dist/controls/collapsible.css +83 -0
  35. package/views/dist/controls/compound-editor/map-parts-body.js +2 -1
  36. package/views/dist/controls/compound-editor/name-parts.js +10 -2
  37. package/views/dist/controls/compound-editor/place-parts.js +5 -1
  38. package/views/dist/controls/compound-editor/place.d.ts +2 -1
  39. package/views/dist/controls/compound-editor/place.js +2 -0
  40. package/views/dist/controls/controls.d.ts +17 -0
  41. package/views/dist/controls/controls.js +17 -0
  42. package/views/dist/controls/date-editor/date-editor.d.ts +2 -1
  43. package/views/dist/controls/date-editor/map-calendar.js +3 -1
  44. package/views/dist/controls/filter-editor/filter-editor.d.ts +56 -0
  45. package/views/dist/controls/filter-editor/filter-editor.js +208 -0
  46. package/views/dist/controls/filter-editor/how.d.ts +23 -0
  47. package/views/dist/controls/filter-editor/how.js +13 -0
  48. package/views/dist/controls/filter-editor/map-filter-body.d.ts +18 -0
  49. package/views/dist/controls/filter-editor/map-filter-body.js +164 -0
  50. package/views/dist/controls/filter-editor/map-rules.d.ts +85 -0
  51. package/views/dist/controls/filter-editor/map-rules.js +273 -0
  52. package/views/dist/controls/filter-editor/parts.d.ts +46 -0
  53. package/views/dist/controls/filter-editor/parts.js +75 -0
  54. package/views/dist/controls/filter-editor/rules.d.ts +104 -0
  55. package/views/dist/controls/filter-editor/rules.js +148 -0
  56. package/views/dist/controls/filter-editor/tokens.d.ts +83 -0
  57. package/views/dist/controls/filter-editor/tokens.js +23 -0
  58. package/views/dist/controls/filter-editor/words.d.ts +59 -0
  59. package/views/dist/controls/filter-editor/words.js +40 -0
  60. package/views/dist/controls/filter-editor.css +124 -0
  61. package/views/dist/controls/group-editor/group-editor.d.ts +56 -0
  62. package/views/dist/controls/group-editor/group-editor.js +126 -0
  63. package/views/dist/controls/group-editor/map-group-body.d.ts +19 -0
  64. package/views/dist/controls/group-editor/map-group-body.js +106 -0
  65. package/views/dist/controls/group-editor/rules.d.ts +48 -0
  66. package/views/dist/controls/group-editor/rules.js +41 -0
  67. package/views/dist/controls/group-editor/tokens.d.ts +15 -0
  68. package/views/dist/controls/group-editor/tokens.js +6 -0
  69. package/views/dist/controls/group-editor/words.d.ts +39 -0
  70. package/views/dist/controls/group-editor/words.js +21 -0
  71. package/views/dist/controls/group-editor.css +20 -0
  72. package/views/dist/controls/index.d.ts +35 -1
  73. package/views/dist/controls/index.js +35 -1
  74. package/views/dist/controls/internal/editor-parts.d.ts +47 -0
  75. package/views/dist/controls/internal/editor-parts.js +48 -0
  76. package/views/dist/controls/internal/step-return.d.ts +9 -0
  77. package/views/dist/controls/internal/step-return.js +27 -0
  78. package/views/dist/controls/links-editor/links-editor.d.ts +80 -0
  79. package/views/dist/controls/links-editor/links-editor.js +329 -0
  80. package/views/dist/controls/links-editor/links.d.ts +62 -0
  81. package/views/dist/controls/links-editor/links.js +50 -0
  82. package/views/dist/controls/links-editor/map-links-body.d.ts +10 -0
  83. package/views/dist/controls/links-editor/map-links-body.js +74 -0
  84. package/views/dist/controls/links-editor/tokens.d.ts +71 -0
  85. package/views/dist/controls/links-editor/tokens.js +20 -0
  86. package/views/dist/controls/links-editor/words.d.ts +56 -0
  87. package/views/dist/controls/links-editor/words.js +33 -0
  88. package/views/dist/controls/links-editor.css +132 -0
  89. package/views/dist/controls/menu-list/menu-list.d.ts +17 -2
  90. package/views/dist/controls/menu-list/menu-list.js +25 -16
  91. package/views/dist/controls/modal/looks.d.ts +4 -0
  92. package/views/dist/controls/modal/looks.js +25 -0
  93. package/views/dist/controls/modal/modal.d.ts +69 -0
  94. package/views/dist/controls/modal/modal.js +62 -0
  95. package/views/dist/controls/modal/tokens.d.ts +192 -0
  96. package/views/dist/controls/modal/tokens.js +50 -0
  97. package/views/dist/controls/modal.css +130 -0
  98. package/views/dist/controls/notice/notice.d.ts +49 -0
  99. package/views/dist/controls/notice/notice.js +35 -0
  100. package/views/dist/controls/notice/tokens.d.ts +99 -0
  101. package/views/dist/controls/notice/tokens.js +27 -0
  102. package/views/dist/controls/notice.css +100 -0
  103. package/views/dist/controls/number-editor/format.d.ts +31 -0
  104. package/views/dist/controls/number-editor/format.js +79 -0
  105. package/views/dist/controls/number-editor/looks.d.ts +14 -0
  106. package/views/dist/controls/number-editor/looks.js +17 -0
  107. package/views/dist/controls/number-editor/map-number-body.d.ts +16 -0
  108. package/views/dist/controls/number-editor/map-number-body.js +57 -0
  109. package/views/dist/controls/number-editor/number-editor.d.ts +72 -0
  110. package/views/dist/controls/number-editor/number-editor.js +202 -0
  111. package/views/dist/controls/number-editor/tokens.d.ts +28 -0
  112. package/views/dist/controls/number-editor/tokens.js +9 -0
  113. package/views/dist/controls/number-editor/words.d.ts +23 -0
  114. package/views/dist/controls/number-editor/words.js +13 -0
  115. package/views/dist/controls/number-editor.css +37 -0
  116. package/views/dist/controls/number-field/number-field.js +57 -5
  117. package/views/dist/controls/pane/looks.d.ts +4 -0
  118. package/views/dist/controls/pane/looks.js +11 -0
  119. package/views/dist/controls/pane/pane.d.ts +63 -0
  120. package/views/dist/controls/pane/pane.js +98 -0
  121. package/views/dist/controls/pane/state.d.ts +14 -0
  122. package/views/dist/controls/pane/state.js +7 -0
  123. package/views/dist/controls/pane/tokens.d.ts +79 -0
  124. package/views/dist/controls/pane/tokens.js +22 -0
  125. package/views/dist/controls/pane.css +104 -0
  126. package/views/dist/controls/picker/rows.d.ts +4 -2
  127. package/views/dist/controls/picker/rows.js +4 -3
  128. package/views/dist/controls/radio/radio.d.ts +33 -0
  129. package/views/dist/controls/radio/radio.js +19 -0
  130. package/views/dist/controls/radio/tokens.d.ts +127 -0
  131. package/views/dist/controls/radio/tokens.js +34 -0
  132. package/views/dist/controls/radio.css +104 -0
  133. package/views/dist/controls/sort-editor/map-sort-body.d.ts +9 -0
  134. package/views/dist/controls/sort-editor/map-sort-body.js +81 -0
  135. package/views/dist/controls/sort-editor/rules.d.ts +48 -0
  136. package/views/dist/controls/sort-editor/rules.js +24 -0
  137. package/views/dist/controls/sort-editor/sort-editor.d.ts +58 -0
  138. package/views/dist/controls/sort-editor/sort-editor.js +180 -0
  139. package/views/dist/controls/sort-editor/tokens.d.ts +79 -0
  140. package/views/dist/controls/sort-editor/tokens.js +22 -0
  141. package/views/dist/controls/sort-editor/words.d.ts +48 -0
  142. package/views/dist/controls/sort-editor/words.js +25 -0
  143. package/views/dist/controls/sort-editor.css +96 -0
  144. package/views/dist/controls/text-editor/phone-number.d.ts +4 -0
  145. package/views/dist/controls/text-editor/phone-number.js +20 -0
  146. package/views/dist/controls/text-editor/text-editor.js +2 -19
  147. package/views/dist/controls/toast/toast.d.ts +75 -0
  148. package/views/dist/controls/toast/toast.js +99 -0
  149. package/views/dist/controls/toast/tokens.d.ts +100 -0
  150. package/views/dist/controls/toast/tokens.js +27 -0
  151. package/views/dist/controls/toast.css +93 -0
  152. package/views/dist/controls/tokens.js +30 -0
  153. package/views/dist/controls/values-editor/looks.d.ts +16 -0
  154. package/views/dist/controls/values-editor/looks.js +19 -0
  155. package/views/dist/controls/values-editor/map-values-body.d.ts +12 -0
  156. package/views/dist/controls/values-editor/map-values-body.js +71 -0
  157. package/views/dist/controls/values-editor/tokens.d.ts +132 -0
  158. package/views/dist/controls/values-editor/tokens.js +35 -0
  159. package/views/dist/controls/values-editor/values-editor.d.ts +62 -0
  160. package/views/dist/controls/values-editor/values-editor.js +441 -0
  161. package/views/dist/controls/values-editor/values.d.ts +71 -0
  162. package/views/dist/controls/values-editor/values.js +59 -0
  163. package/views/dist/controls/values-editor/words.d.ts +50 -0
  164. package/views/dist/controls/values-editor/words.js +29 -0
  165. package/views/dist/controls/values-editor.css +207 -0
  166. package/views/dist/controls/views-list/looks.d.ts +13 -0
  167. package/views/dist/controls/views-list/looks.js +12 -0
  168. package/views/dist/controls/views-list/map-views-list-body.d.ts +19 -0
  169. package/views/dist/controls/views-list/map-views-list-body.js +65 -0
  170. package/views/dist/controls/views-list/rules.d.ts +72 -0
  171. package/views/dist/controls/views-list/rules.js +4 -0
  172. package/views/dist/controls/views-list/tokens.d.ts +11 -0
  173. package/views/dist/controls/views-list/tokens.js +5 -0
  174. package/views/dist/controls/views-list/views-list.d.ts +44 -0
  175. package/views/dist/controls/views-list/views-list.js +57 -0
  176. package/views/dist/controls/views-list/words.d.ts +22 -0
  177. package/views/dist/controls/views-list/words.js +3 -0
  178. package/views/dist/controls/views-list.css +8 -0
  179. package/views/dist/display/date.js +2 -2
  180. package/views/dist/display/format.js +10 -2
  181. package/views/dist/display/options.d.ts +3 -1
  182. package/views/dist/display/use-display-options.d.ts +3 -0
  183. package/views/dist/display/use-display-options.js +10 -2
  184. package/views/dist/display/viewer.d.ts +1 -1
  185. package/views/dist/display/viewer.js +1 -1
  186. package/views/dist/editors/DateEditor.js +11 -9
  187. package/views/dist/editors/NumberEditor.js +3 -1
  188. package/views/dist/editors/relation-panel.js +7 -1
  189. package/views/dist/editors/relation-picker.d.ts +2 -1
  190. package/views/dist/editors/relation-picker.js +4 -3
  191. package/views/dist/editors/relation-source.d.ts +4 -1
  192. package/views/dist/editors/relation-source.js +5 -2
  193. package/views/dist/field-row/editors/RowNumberEditor.js +2 -2
  194. package/views/dist/fields/number-edit.d.ts +6 -0
  195. package/views/dist/fields/number-edit.js +8 -1
  196. package/views/dist/grid/chrome/GridCellEditors.js +3 -3
  197. package/views/dist/grid/chrome/GridColumnDateSection.d.ts +4 -3
  198. package/views/dist/grid/chrome/GridColumnDateSection.js +4 -4
  199. package/views/dist/grid/chrome/GridColumnDurationSection.js +2 -2
  200. package/views/dist/grid/chrome/GridColumnMenu.js +6 -4
  201. package/views/dist/grid/chrome/GridDateEditor.d.ts +3 -1
  202. package/views/dist/grid/chrome/GridDateEditor.js +2 -1
  203. package/views/dist/grid/chrome/GridFooter.js +2 -2
  204. package/views/dist/grid/chrome/grid-column-menu-items.js +4 -2
  205. package/views/dist/grid/chrome/useGridBandFigures.js +2 -2
  206. package/views/dist/grid/chrome/useGridFittedWidths.d.ts +3 -0
  207. package/views/dist/grid/chrome/useGridFittedWidths.js +9 -3
  208. package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
  209. package/views/dist/grid/chrome/useGridKeyboard.js +5 -2
  210. package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -1
  211. package/views/dist/grid/core/commit-model.d.ts +7 -0
  212. package/views/dist/grid/core/commit-model.js +5 -1
  213. package/views/dist/grid/core/editing-controller.js +10 -2
  214. package/views/dist/grid/core/editing-model.js +3 -7
  215. package/views/dist/grid/core/undo-owner.d.ts +6 -0
  216. package/views/dist/grid/core/undo-owner.js +13 -0
  217. package/views/dist/grid/core/useGridEditing.d.ts +2 -0
  218. package/views/dist/grid/core/useGridEditing.js +4 -0
  219. package/views/dist/looks/index.d.ts +8 -0
  220. package/views/dist/looks/index.js +8 -0
  221. package/views/dist/looks/pieces.js +16 -0
  222. package/views/dist/panels/model.d.ts +6 -1
  223. package/views/dist/panels/react/customize-body.d.ts +4 -2
  224. package/views/dist/panels/react/customize-body.js +3 -3
  225. package/views/dist/panels/react/customize.js +4 -2
  226. package/views/dist/panels/react/filter/FilterEditor.js +2 -2
  227. package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +8 -2
  228. package/views/dist/panels/react/filter/PhoneFilterEditor.js +9 -6
  229. package/views/dist/panels/react/filter/filter-body.d.ts +8 -5
  230. package/views/dist/panels/react/filter/filter-body.js +17 -6
  231. package/views/dist/panels/react/filter/filter-part-body.d.ts +4 -1
  232. package/views/dist/panels/react/filter/filter-part-body.js +3 -1
  233. package/views/dist/panels/react/panel-sheet.d.ts +5 -1
  234. package/views/dist/panels/react/panel-sheet.js +6 -2
  235. package/views/dist/panels/react/panel-step.d.ts +12 -0
  236. package/views/dist/panels/react/panel-step.js +26 -0
  237. package/views/dist/panels/react/sort/SortEditor.d.ts +4 -0
  238. package/views/dist/panels/react/sort/SortEditor.js +5 -2
  239. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +8 -0
  240. package/views/dist/panels/react/toolbar/ReadyToolbar.js +84 -2
  241. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +2 -2
  242. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +16 -0
  243. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +49 -0
  244. package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +3 -1
  245. package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +4 -1
  246. package/views/dist/panels/react/toolbar/ToolbarFilters.js +36 -21
  247. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +4 -1
  248. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +2 -2
  249. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
  250. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +15 -6
  251. package/views/dist/panels/react/toolbar/panel-part.d.ts +5 -1
  252. package/views/dist/panels/react/toolbar/panel-part.js +2 -2
  253. package/views/dist/panels/react/toolbar/use-filter-add.d.ts +16 -0
  254. package/views/dist/panels/react/toolbar/use-filter-add.js +32 -0
  255. package/views/dist/panels/react.d.ts +1 -0
  256. package/views/dist/panels/react.js +1 -0
  257. package/views/dist/panels/settings/filter-groups.js +35 -1
  258. package/views/dist/panels/settings/group-buckets.js +1 -0
  259. package/views/dist/provider/ViewsProvider.d.ts +7 -1
  260. package/views/dist/provider/ViewsProvider.js +23 -3
  261. package/views/dist/provider/components.d.ts +34 -4
  262. package/views/dist/provider/moment.d.ts +6 -0
  263. package/views/dist/provider/moment.js +10 -0
  264. package/views/dist/styles.css +1276 -51
  265. package/views/dist/styles.unlayered.css +1277 -51
  266. package/views/docs/contract.md +23 -15
  267. package/views/docs/controls/alert-dialog.md +37 -0
  268. package/views/docs/controls/alert.md +30 -0
  269. package/views/docs/controls/collapsible.md +22 -0
  270. package/views/docs/controls/filter-editor.md +28 -0
  271. package/views/docs/controls/group-editor.md +11 -0
  272. package/views/docs/controls/links-editor.md +25 -0
  273. package/views/docs/controls/modal.md +55 -0
  274. package/views/docs/controls/notice.md +32 -0
  275. package/views/docs/controls/number-editor.md +12 -0
  276. package/views/docs/controls/pane.md +25 -0
  277. package/views/docs/controls/radio.md +39 -0
  278. package/views/docs/controls/sort-editor.md +27 -0
  279. package/views/docs/controls/toast.md +32 -0
  280. package/views/docs/controls/values-editor.md +40 -0
  281. package/views/docs/controls/views-list.md +8 -0
  282. package/views/docs/guides/cells.md +1 -1
  283. package/views/docs/guides/display.md +1 -1
  284. package/views/docs/guides/the-grid.md +1 -1
  285. package/views/docs/guides/the-provider.md +19 -0
  286. package/views/docs/reference/cells.md +2 -2
  287. package/views/docs/reference/controls.md +326 -8
  288. package/views/docs/reference/display.md +2 -2
  289. package/views/docs/reference/editors-relation.md +1 -1
  290. package/views/docs/reference/looks.md +20 -3
  291. package/views/docs/reference/panels-react.md +7 -6
  292. package/views/docs/reference/panels.md +1 -1
  293. package/views/docs/reference/react.md +8 -8
  294. package/views/docs/reference/views.md +1 -0
@@ -0,0 +1,83 @@
1
+ /* The Collapsible. Every value it draws with is a public name (controls/collapsible/tokens.ts); this file only says which
2
+ name each part takes. Base UI marks the trigger data-panel-open while its part is open, and data-disabled; the part data-open or
3
+ data-closed, and data-starting-style and data-ending-style as it comes and goes, and gives it its height to move
4
+ to as --collapsible-panel-height. Its options (looks.ts) are data attributes on the frame or the app around
5
+ it: data-collapsible-content and data-collapsible-curve.
6
+
7
+ The rules sit in the components layer, so a utility class on it still wins. */
8
+ @layer components {
9
+
10
+ /* ── The curve everything of it moves on: ease-out, or under Curve › Sharp ease-out-sharp ──────────── */
11
+ [data-collapsible-curve="sharp"] :is(.o-collapsible-trigger, .o-collapsible-panel) { --o-collapsible-ease: var(--vk-ease-out-sharp); }
12
+
13
+ /* ── The trigger, plain (its look belongs to the place it stands in, and none wears a ground under the pointer): a chevron
14
+ before its name, text-sm at medium weight, 32 high, 44 on a phone, where a row you press is a 44px target. Under the pointer its chevron takes the text's colour; its focus
15
+ ringed. The chevron turns down while the part is open, on the part's curve and in a short part's own times:
16
+ duration-base opening, duration-fast closing ────────────────────────────────────────────────────────────────── */
17
+ .o-collapsible-trigger {
18
+ --collapsible-trigger-h: calc(var(--vk-spacing) * 8);
19
+ display: inline-flex; align-items: center; gap: calc(var(--vk-spacing) * 1.5); box-sizing: border-box;
20
+ min-height: var(--collapsible-trigger-h); margin: 0; padding: 0;
21
+ border: 0; border-radius: var(--vk-radius-sm); background-color: transparent;
22
+ color: var(--vk-fg); font: inherit; font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm));
23
+ font-weight: var(--vk-font-weight-medium); text-align: left; cursor: pointer; outline: none; user-select: none;
24
+ -webkit-tap-highlight-color: transparent;
25
+ }
26
+ .o-collapsible-trigger:where([data-vk-phone], [data-vk-phone] *) { --collapsible-trigger-h: calc(var(--vk-spacing) * 11); }
27
+ .o-collapsible-trigger:focus-visible { outline: var(--vk-focus-width) solid var(--vk-border-brand); outline-offset: var(--vk-focus-offset); }
28
+ .o-collapsible-trigger[data-disabled] { color: var(--vk-fg-disabled); cursor: not-allowed; }
29
+ .o-collapsible-chevron {
30
+ flex: none; width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4);
31
+ fill: none; stroke: var(--vk-fg-subtle); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
32
+ transition: rotate var(--vk-duration-fast) var(--o-collapsible-ease, var(--vk-ease-out)), stroke var(--vk-duration-fast) var(--vk-ease-out);
33
+ }
34
+ .o-collapsible-trigger[data-panel-open] .o-collapsible-chevron { rotate: 90deg; transition-duration: var(--vk-duration-base), var(--vk-duration-fast); }
35
+ /* A hover only on a screen with a pointer. */
36
+ @media (hover: hover) { .o-collapsible-trigger:not([data-disabled]):hover .o-collapsible-chevron { stroke: var(--vk-fg); } }
37
+ .o-collapsible-trigger[data-disabled] .o-collapsible-chevron { stroke: var(--vk-fg-disabled); }
38
+
39
+ /* ── The part: the box that crops it while its height moves, from nothing to what it holds. It crops without
40
+ scrolling (clip, never hidden), so what sticks inside it, a grid's frozen columns, still
41
+ sticks to the scroller beyond it. Both ways it eases out: it answers the press at once and settles, as
42
+ shadcn's and Base UI's own do. Its time follows its height, between the motion names: opening from duration-base
43
+ to duration-slow, closing from duration-fast to duration-base, the longest reached at 600px tall (spacing × 150),
44
+ so a short part moves as it always did and a tall one no longer snaps. The height is Base UI's, read as a length
45
+ (--o-collapsible-h, registered at the file's end: at rest Base UI says auto, which reads as none); how far along
46
+ that 600px it stands is --o-collapsible-part, 0 to 1. A browser that can't divide one length by another keeps the
47
+ two plain times. An app's own time (durationMs) sets --o-collapsible-time for both ──────────────────────────── */
48
+ .o-collapsible-panel {
49
+ --o-collapsible-open: var(--vk-duration-base); --o-collapsible-close: var(--vk-duration-fast);
50
+ box-sizing: border-box; overflow: clip; height: var(--collapsible-panel-height);
51
+ transition: height var(--o-collapsible-time, var(--o-collapsible-open)) var(--o-collapsible-ease, var(--vk-ease-out));
52
+ }
53
+ @supports (width: calc(tan(atan2(1px, 1px)) * 1px)) {
54
+ .o-collapsible-panel {
55
+ --o-collapsible-h: var(--collapsible-panel-height);
56
+ --o-collapsible-part: min(1, tan(atan2(var(--o-collapsible-h), calc(var(--vk-spacing) * 150))));
57
+ --o-collapsible-open: calc(var(--vk-duration-base) + (var(--vk-duration-slow) - var(--vk-duration-base)) * var(--o-collapsible-part));
58
+ --o-collapsible-close: calc(var(--vk-duration-fast) + (var(--vk-duration-base) - var(--vk-duration-fast)) * var(--o-collapsible-part));
59
+ }
60
+ }
61
+ .o-collapsible-panel[data-ending-style] { transition-duration: var(--o-collapsible-time, var(--o-collapsible-close)); }
62
+ .o-collapsible-panel:is([data-starting-style], [data-ending-style]) { height: 0; }
63
+
64
+ /* ── Content: how what it holds comes and goes. Fades, the default (what nothing set draws), unless a frame picks Stands still, which draws nothing here (the box
65
+ crops it as it moves), or Slides out. Fades: it comes in with the height, in the height's own time and on its curve, and goes in
66
+ half the closing time, so the moving edge passes over nothing and never cuts a line of text. Slides out: it is
67
+ anchored to the part's lower edge, so it comes out from under its trigger and goes back under it. The part's
68
+ times reach what it holds as the variables above, which it inherits ─────────────────────────────────────────── */
69
+ .o-collapsible-body:not([data-collapsible-content="still"] *, [data-collapsible-content="slide"] *) { transition: opacity var(--o-collapsible-time, var(--o-collapsible-open)) var(--o-collapsible-ease, var(--vk-ease-out)); }
70
+ .o-collapsible-panel[data-ending-style] > .o-collapsible-body:not([data-collapsible-content="still"] *, [data-collapsible-content="slide"] *) { transition-duration: calc(var(--o-collapsible-time, var(--o-collapsible-close)) * 0.5); }
71
+ .o-collapsible-panel:is([data-starting-style], [data-ending-style]) > .o-collapsible-body:not([data-collapsible-content="still"] *, [data-collapsible-content="slide"] *) { opacity: 0; }
72
+ [data-collapsible-content="slide"] .o-collapsible-panel:not([hidden]) { display: flex; flex-direction: column; justify-content: flex-end; }
73
+ [data-collapsible-content="slide"] .o-collapsible-body { flex: none; }
74
+
75
+ /* Under reduced motion it opens and closes at once, whatever time an app gave it, and what it holds with it, framed or not: the
76
+ fade is the default with no frame, so these match every body, at the fade rules' own weight, later. */
77
+ @media (prefers-reduced-motion: reduce) {
78
+ .o-collapsible-panel, .o-collapsible-panel[data-ending-style], .o-collapsible-chevron, .o-collapsible-trigger[data-panel-open] .o-collapsible-chevron,
79
+ :root .o-collapsible-body, :root .o-collapsible-panel[data-ending-style] > .o-collapsible-body { transition: none; }
80
+ }
81
+ }
82
+ /* The part's height as a length, so a time can be worked out from it: Base UI's auto, at rest, reads as none. */
83
+ @property --o-collapsible-h { syntax: "<length>"; inherits: false; initial-value: 0px; }
@@ -52,7 +52,8 @@ export function compoundEditorWordsOf(say) {
52
52
  export function partsBodyPropsOf(p, words) {
53
53
  const common = { label: p.label, autoFocus: p.autoFocus, form: p.form, draft: "shell", ...(words ? { words } : {}) };
54
54
  if (p.kind === "name")
55
- return { ...common, kind: "name", value: p.value, empty: p.empty, onValueChange: (v) => p.onValueChange(v ?? NO_NAME), onDone: () => p.onDone() };
55
+ return { ...common, kind: "name", value: p.value, empty: p.empty, ...(p.typed !== undefined ? { typing: { given: p.value.given } } : {}),
56
+ onValueChange: (v) => p.onValueChange(v ?? NO_NAME), onDone: () => p.onDone() };
56
57
  if (p.kind === "place")
57
58
  return { ...common, kind: "place", value: codelessRegion(p), parts: [...p.parts], required: [...p.required], countries: placeCountriesOf(p),
58
59
  ...(p.opens ? { opens: p.opens } : {}), onValueChange: (v) => p.onValueChange(v ?? {}), onDone: () => p.onDone() };
@@ -33,10 +33,18 @@ export function useNameParts(props, worn, wornAt) {
33
33
  const joined = fullOf(given, family), own = !!line?.trim() && line.trim() !== joined;
34
34
  const next = shownAs ? nameOf(given, family, line) : keptName(value, given, family);
35
35
  const note = !shell && next === null && !empty && value ? `A person needs a name. Closing keeps ${value.full}.` : null;
36
- const [opened, setOpened] = React.useState(value);
36
+ const [opened, setOpened] = React.useState(typing ? null : value);
37
37
  const typedLine = shownAs ? (line != null ? (line.trim() ? line : joined) : null) : (keptName(opened, given, family)?.full ?? joined);
38
38
  const handed = nameHanded(value ?? NO_NAME, given, family, typedLine);
39
- useShellHand(shell, handed, value ?? NO_NAME, (a, b) => sameNameEcho(a, b) && (typedLine == null || a.full === b.full), onValueChange, (v) => { setNow(startOf(v)); setOpened(v); });
39
+ const handNow = useShellHand(shell, handed, value ?? NO_NAME, (a, b) => sameNameEcho(a, b) && (typedLine == null || a.full === b.full), onValueChange, (v) => { setNow(startOf(v)); setOpened(v); });
40
+ const typedHanded = React.useRef(false);
41
+ React.useEffect(() => {
42
+ if (typedHanded.current || !shell || !typing)
43
+ return;
44
+ typedHanded.current = true;
45
+ if (handed.full !== (value ?? NO_NAME).full)
46
+ handNow(handed);
47
+ }, [shell, typing, handed, value, handNow]);
40
48
  const settled = React.useRef(false), last = React.useRef(null);
41
49
  const first = useFocusFirst(autoFocus);
42
50
  const part = (key, v) => setNow((d) => ({ ...d, [key]: v, line: d.line != null && (!d.line.trim() || d.line.trim() === fullOf(d.given, d.family)) ? null : d.line }));
@@ -12,6 +12,7 @@ import { countriesOf, PLACE_PARTS, placeOf, regionFor, rowsOf, streetOf, streetP
12
12
  import { QuietField, PartsRow, MIHAI_CARD } from "./row.js";
13
13
  import { blurKeeps, useHeldFocus, useShellHand } from "./keeping.js";
14
14
  import { phoneMark, usePhoneForm } from "../internal/phone.js";
15
+ import { useStepReturn } from "../internal/step-return.js";
15
16
  import { samePlaceEcho } from "./shell.js";
16
17
  import { compoundWords } from "./words.js";
17
18
  const glyph = (paths, className) => (_jsx("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) }));
@@ -86,8 +87,11 @@ export function usePlaceParts(props, worn, wornAt) {
86
87
  }
87
88
  swapping.current = true;
88
89
  setList(null);
89
- setFocusTo(phone && !first ? null : "first");
90
+ setFocusTo(phone ? null : "first");
91
+ if (phone)
92
+ requestAnimationFrame(() => { swapping.current = false; });
90
93
  };
94
+ useStepReturn(root, phone && list ? [list === "countries" ? '[data-pick="country"]:is(button), [data-pick="country"] button' : '[data-pick="region"]:is(button), [data-pick="region"] button'] : []);
91
95
  const pickCountry = (code) => setDraft((d) => {
92
96
  if ((d.countryCode ?? "") === code)
93
97
  return d;
@@ -34,7 +34,8 @@ export declare const ATTIO_ROWS: PlacePart[][];
34
34
  * in one row. In Attio's: the same rows for every country, each kept to the field's parts, line 2 riding in line 1's box. */
35
35
  export declare function rowsOf(country: Country | undefined, parts: PlacePart[], held?: PlaceValue, order?: PlaceOrder): PlacePart[][];
36
36
  /** A part's words for a country: the field's own for it, else the editor's for it, else Attio's words in Attio's look, or
37
- * the editor's, the short ones on a phone where they are long; each of those last the app's where `words` hands them. */
37
+ * the editor's, the short ones on a phone where they are long; each of those last the app's where `words` hands them.
38
+ * In Attio's look the street is one box holding both lines, so it takes Attio's word whatever the country (VK-806). */
38
39
  export declare function wordOf(country: Country | undefined, part: PlacePart, o?: {
39
40
  phone?: boolean;
40
41
  attio?: boolean;
@@ -23,6 +23,8 @@ export function rowsOf(country, parts, held, order = "country") {
23
23
  return parts.includes("line1") ? kept : kept.length ? [kept.flat()] : [];
24
24
  }
25
25
  export function wordOf(country, part, o = {}) {
26
+ if (o.attio && (part === "line1" || part === "line2"))
27
+ return o.words?.attio?.[part] ?? ATTIO_WORDS[part];
26
28
  const own = country?.words?.[part] ?? (country && KNOWN[country.code]?.words?.[part]);
27
29
  if (own != null)
28
30
  return own;
@@ -5,12 +5,20 @@ import { MapSheet } from "./sheet/map-sheet.js";
5
5
  import { MapCheckbox } from "./checkbox/map-checkbox.js";
6
6
  import { MapInput } from "./input/map-input.js";
7
7
  import { MapMenu } from "./menu/map-menu.js";
8
+ import { MapSortBody } from "./sort-editor/map-sort-body.js";
9
+ import { MapViewsListBody } from "./views-list/map-views-list-body.js";
10
+ import { MapFilterBody, MapFilterPartBody } from "./filter-editor/map-filter-body.js";
11
+ import { MapGroupBody } from "./group-editor/map-group-body.js";
12
+ import { MapCollapse } from "./collapsible/map-collapse.js";
8
13
  import { MapTextBody } from "./text-editor/map-text-body.js";
9
14
  import { MapPicker } from "./picker/map-picker.js";
10
15
  import { MapFieldsBody } from "./picker/map-fields-body.js";
11
16
  import { MapDateBody } from "./date-editor/map-date-body.js";
12
17
  import { MapCalendar } from "./date-editor/map-calendar.js";
13
18
  import { MapPartsBody } from "./compound-editor/map-parts-body.js";
19
+ import { MapNumberBody } from "./number-editor/map-number-body.js";
20
+ import { MapValuesBody } from "./values-editor/map-values-body.js";
21
+ import { MapLinksBody } from "./links-editor/map-links-body.js";
14
22
  export declare const CONTROLS: {
15
23
  Button: typeof MapButton;
16
24
  Tooltip: typeof MapTooltip;
@@ -19,10 +27,19 @@ export declare const CONTROLS: {
19
27
  Input: typeof MapInput;
20
28
  Checkbox: typeof MapCheckbox;
21
29
  Menu: typeof MapMenu;
30
+ SortBody: typeof MapSortBody;
31
+ ViewsListBody: typeof MapViewsListBody;
32
+ FilterBody: typeof MapFilterBody;
33
+ FilterPartBody: typeof MapFilterPartBody;
34
+ GroupBody: typeof MapGroupBody;
35
+ Collapse: typeof MapCollapse;
22
36
  TextBody: typeof MapTextBody;
23
37
  Picker: typeof MapPicker;
24
38
  FieldsBody: typeof MapFieldsBody;
25
39
  DateBody: typeof MapDateBody;
26
40
  Calendar: typeof MapCalendar;
27
41
  PartsBody: typeof MapPartsBody;
42
+ NumberBody: typeof MapNumberBody;
43
+ ValuesBody: typeof MapValuesBody;
44
+ LinksBody: typeof MapLinksBody;
28
45
  };
@@ -5,12 +5,20 @@ import { MapSheet } from "./sheet/map-sheet.js";
5
5
  import { MapCheckbox } from "./checkbox/map-checkbox.js";
6
6
  import { MapInput } from "./input/map-input.js";
7
7
  import { MapMenu } from "./menu/map-menu.js";
8
+ import { MapSortBody } from "./sort-editor/map-sort-body.js";
9
+ import { MapViewsListBody } from "./views-list/map-views-list-body.js";
10
+ import { MapFilterBody, MapFilterPartBody } from "./filter-editor/map-filter-body.js";
11
+ import { MapGroupBody } from "./group-editor/map-group-body.js";
12
+ import { MapCollapse } from "./collapsible/map-collapse.js";
8
13
  import { MapTextBody } from "./text-editor/map-text-body.js";
9
14
  import { MapPicker } from "./picker/map-picker.js";
10
15
  import { MapFieldsBody } from "./picker/map-fields-body.js";
11
16
  import { MapDateBody } from "./date-editor/map-date-body.js";
12
17
  import { MapCalendar } from "./date-editor/map-calendar.js";
13
18
  import { MapPartsBody } from "./compound-editor/map-parts-body.js";
19
+ import { MapNumberBody } from "./number-editor/map-number-body.js";
20
+ import { MapValuesBody } from "./values-editor/map-values-body.js";
21
+ import { MapLinksBody } from "./links-editor/map-links-body.js";
14
22
  export const CONTROLS = {
15
23
  Button: MapButton,
16
24
  Tooltip: MapTooltip,
@@ -19,10 +27,19 @@ export const CONTROLS = {
19
27
  Input: MapInput,
20
28
  Checkbox: MapCheckbox,
21
29
  Menu: MapMenu,
30
+ SortBody: MapSortBody,
31
+ ViewsListBody: MapViewsListBody,
32
+ FilterBody: MapFilterBody,
33
+ FilterPartBody: MapFilterPartBody,
34
+ GroupBody: MapGroupBody,
35
+ Collapse: MapCollapse,
22
36
  TextBody: MapTextBody,
23
37
  Picker: MapPicker,
24
38
  FieldsBody: MapFieldsBody,
25
39
  DateBody: MapDateBody,
26
40
  Calendar: MapCalendar,
27
41
  PartsBody: MapPartsBody,
42
+ NumberBody: MapNumberBody,
43
+ ValuesBody: MapValuesBody,
44
+ LinksBody: MapLinksBody,
28
45
  };
@@ -22,7 +22,8 @@ export interface DateEditorProps {
22
22
  days?: "any" | "from-today" | "until-today";
23
23
  /** The quick picks that fit the field; left out, Today, Tomorrow and Next week, and No date where it may be empty. */
24
24
  picks?: DatePick[];
25
- /** Today, for a page that shows a fixed day; left out, this browser's own. */
25
+ /** Today: ViewKit's date body hands the provider's moment; a page that shows a fixed day hands that one; left out, this
26
+ * browser's own. */
26
27
  today?: string;
27
28
  /** What was typed on what opened it: the line starts with it, and says at once when it isn't a date. */
28
29
  typed?: string;
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { cx } from "../../internal/cx.js";
5
5
  import { useViews } from "../../provider/context.js";
6
+ import { useMoment } from "../../provider/moment.js";
6
7
  import { Button } from "../button/button.js";
7
8
  import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
8
9
  import { addMonths, dateNames, parts, todayOf } from "./calendar.js";
@@ -12,11 +13,12 @@ import { dateEditorWordsOf } from "./map-date-body.js";
12
13
  import { dateWords } from "./words.js";
13
14
  export function MapCalendar({ value, onChange, min, max, month, onMonthChange, className }) {
14
15
  const { conventions } = useViews();
16
+ const now = useMoment();
15
17
  const w = React.useMemo(() => dateWords(dateEditorWordsOf(conventions.messages)), [conventions.messages]);
16
18
  const names = dateNames(conventions.language);
17
19
  const [wornRef, worn] = useDateEditorWorn();
18
20
  const host = React.useContext(PhoneHost), small = usePhone(), phone = Boolean(host) || small;
19
- const today = todayOf();
21
+ const today = todayOf(now ?? undefined);
20
22
  const [key, setKey] = React.useState(value ?? (month ? `${month}-01` : today));
21
23
  const [held, setHeld] = React.useState({ value, month });
22
24
  if (held.value !== value || held.month !== month) {
@@ -0,0 +1,56 @@
1
+ import * as React from "react";
2
+ import type { SheetHeadProps } from "../sheet/bottom-sheet.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
+ export type { FilterField, FieldType } from "./how.js";
7
+ export type { FilterAside, FilterGroup, FilterRule } from "./rules.js";
8
+ /** ViewKit's own words and value body for a rule the kit has no box of its own for: its field's words, its way's word, its value's
9
+ * words (null with none yet), and its value body (null where it takes none). */
10
+ export interface FilterOwn {
11
+ field: string;
12
+ way: string;
13
+ value: string | null;
14
+ body: React.ReactNode | null;
15
+ }
16
+ export interface FilterEditorProps {
17
+ /** What it filters, as its shell names it ("Filter"): the Sheet's title on a phone, and the rules' name to a screen reader. */
18
+ label: string;
19
+ /** The fields a list filters by, each typed, a choice's values with it; one leading one level in (a deal's Company) holds its own. */
20
+ fields: FilterField[];
21
+ /** The view's filter: its rules, joined by its join, groups in it. */
22
+ filter: FilterGroup;
23
+ /** Each change, as it is made: a rule added, changed or taken away, a join turned, a group made. */
24
+ onFilterChange: (filter: FilterGroup) => void;
25
+ /** The rule it opens at, its value open: a rule just added. */
26
+ at?: string;
27
+ /** The ids already taken outside `filter`, which a rule or group it makes never repeats. */
28
+ ids?: string[];
29
+ /** How many levels deep its rules may stand, its own the first: three unless said; an advanced filter's editor two. */
30
+ levels?: number;
31
+ /** Which form; by default the phone's in a phone's window or in a PhoneHost screen, else the computer's. `narrow`, on a computer
32
+ * in a narrow place (Customize's Filter, in the Pane): the phone's structure at a computer's sizes. */
33
+ form?: "computer" | "phone" | "narrow";
34
+ /** The job is done and what holds it closes: on a computer the last rule taken away or Clear all filters; on a phone ✓, or ✕
35
+ * once the filter is back. */
36
+ onDone?: () => void;
37
+ /** For a page that shows a state, standing still: `at`'s value list stands open under its box (on a phone, its step), and nothing
38
+ * takes the focus. */
39
+ standing?: boolean;
40
+ /** ViewKit's own words and value body for a rule the kit has no box for (set aside, a way only ViewKit words, a field the kit
41
+ * doesn't list, a choice with no values); null where the kit draws the rule itself. */
42
+ own?: (rule: FilterRule) => FilterOwn | null;
43
+ /** Its words; English unless handed. */
44
+ words?: Partial<FilterEditorWords>;
45
+ }
46
+ export interface FilterEditorParts {
47
+ body: React.ReactNode;
48
+ /** On a phone, the Sheet head's ✕ and ✓, or on a step its Back (`onBack`) alone; {} on a computer and in the narrow form. */
49
+ head: Pick<SheetHeadProps, "close" | "left" | "right" | "onBack">;
50
+ /** On a phone's step, its title: Add filter, Field, how a field compares, or the field's name; absent off a step. */
51
+ title?: string;
52
+ }
53
+ /** The filter editor's state and the parts a shell pours in. */
54
+ export declare function useFilterEditor(props: FilterEditorProps): FilterEditorParts;
55
+ /** The body alone, for a shell that holds only a body (the Popover). */
56
+ export declare function FilterEditor(props: FilterEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,208 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Button } from "../button/button.js";
5
+ import { cellText } from "../date-editor/calendar.js";
6
+ import { DateEditor, useDateEditor } from "../date-editor/date-editor.js";
7
+ import { asSelect, DOTS, DOTS_LOOK, DOTS_UP, glyph, MORE_LOOK, PLUS, TRASH, useDecide, useStandingRoom } from "../internal/editor-parts.js";
8
+ import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
9
+ import { openerAt, useStepReturn } from "../internal/step-return.js";
10
+ import { Input } from "../input/input.js";
11
+ import { Menu } from "../menu/menu.js";
12
+ import { NumberField } from "../number-field/number-field.js";
13
+ import { Picker, usePicker } from "../picker/picker.js";
14
+ import { itemLabel } from "../picker/rows.js";
15
+ import { Popover } from "../popover/popover.js";
16
+ import { Select } from "../select/select.js";
17
+ import { Tooltip } from "../tooltip/tooltip.js";
18
+ import { HOW, wayOf } from "./how.js";
19
+ import { PairValue } from "./parts.js";
20
+ import { addRule, canGroup, changeRule, clearAll, fieldOf, isGroup, isOwnWay, isPair, isWhole, putBack, removeRule, rulesOf, setJoin, toGroup } from "./rules.js";
21
+ import { filterWords } from "./words.js";
22
+ const GROUP = ["M4 7a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v10a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3z", "M8 9h8", "M8 13h5"];
23
+ const TURNS = ["M7 4l-3 3l3 3", "M4 7h13", "M17 20l3 -3l-3 -3", "M20 17h-13"];
24
+ function DateValue({ name, value, onValue, open, onOpenChange, phone, size, placeholder }) {
25
+ const box = React.useRef(null);
26
+ return (_jsxs("div", { ref: box, className: "o-filter-editor-date", children: [_jsx(Input, { readOnly: true, size: size, "aria-label": name, "aria-haspopup": "dialog", "aria-expanded": open, placeholder: placeholder, value: value ? cellText(value, value) : "", className: "o-filter-editor-date-box", onClick: () => onOpenChange(!open), onKeyDown: (e) => { if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
27
+ e.preventDefault();
28
+ onOpenChange(true);
29
+ } } }), !phone && (_jsx(Popover, { open: open, onOpenChange: (o) => onOpenChange(o), anchor: box, className: "w-fit", "aria-label": name, children: _jsx(DateEditor, { label: name, value: value, onValueChange: onValue, onDone: () => onOpenChange(false), form: "computer" }) }))] }));
30
+ }
31
+ function DateStep({ name, value, onValue, onDone }) {
32
+ return _jsx(_Fragment, { children: useDateEditor({ label: name, value, onValueChange: onValue, onDone, form: "phone", draft: "shell" }).body });
33
+ }
34
+ function OwnValue({ name, own, open, onOpenChange, phone, size, placeholder }) {
35
+ const box = React.useRef(null), takes = own.body != null;
36
+ return (_jsxs("div", { ref: box, className: "o-filter-editor-own", children: [_jsx(Input, { readOnly: true, size: size, "aria-label": name, "aria-haspopup": takes ? "dialog" : undefined, "aria-expanded": takes ? open : undefined, placeholder: placeholder, value: own.value ?? "", disabled: !takes, className: "o-filter-editor-own-box", onClick: () => { if (takes)
37
+ onOpenChange(!open); }, onKeyDown: (e) => { if (takes && (e.key === "Enter" || e.key === " " || e.key === "ArrowDown")) {
38
+ e.preventDefault();
39
+ onOpenChange(true);
40
+ } } }), !phone && takes && (_jsx(Popover, { open: open, onOpenChange: (o) => onOpenChange(o), anchor: box, className: "w-fit", "aria-label": name, children: own.body }))] }));
41
+ }
42
+ export function useFilterEditor(props) {
43
+ const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels } = props;
44
+ const w = filterWords(props.words), words = w.picker ? { words: w.picker } : {};
45
+ const screen = React.useContext(PhoneHost), small = usePhone(), way = props.form ?? (screen || small ? "phone" : "computer");
46
+ const phone = way === "phone", stacked = phone || way === "narrow";
47
+ const now = React.useRef(filter);
48
+ React.useLayoutEffect(() => { now.current = filter; });
49
+ const change = (next) => { now.current = next; onFilterChange(next); };
50
+ const nameOf = (field) => itemLabel(fields, field);
51
+ const ownOf = (r) => props.own?.(r) ?? null;
52
+ const labelOf = (r) => r.aside?.label ?? (fieldOf(fields, r.field) ? nameOf(r.field) : ownOf(r)?.field ?? nameOf(r.field));
53
+ const listed = (r) => {
54
+ const f = r && fieldOf(fields, r.field), takes = f && r && wayOf(f.type, r.how)?.takes;
55
+ return !!r && !r.aside && (ownOf(r)?.body != null || (!!takes && takes !== "none" && (!!f?.choices || f?.type === "date")));
56
+ };
57
+ const pointAt = (id, v) => change(changeRule(putBack(now.current, id), id, { field: v }, fields));
58
+ const [open, setOpen] = React.useState(phone ? null : props.at ?? null);
59
+ const atListed = (f) => !!props.at && listed(rulesOf(f).find((x) => x.id === props.at));
60
+ const [step, setStep] = React.useState(() => (phone && props.at && atListed(filter) ? { list: "value", rule: props.at } : null));
61
+ React.useEffect(() => { if (props.at) {
62
+ if (!phone)
63
+ setOpen(props.at);
64
+ else if (atListed(now.current))
65
+ setStep({ list: "value", rule: props.at });
66
+ } }, [props.at]);
67
+ const [root, setRoot] = React.useState(null);
68
+ React.useLayoutEffect(() => {
69
+ if (standing || !open || !root)
70
+ return;
71
+ const r = rulesOf(now.current).find((x) => x.id === open), field = r && fieldOf(fields, r.field), takes = field && r && wayOf(field.type, r.how)?.takes;
72
+ const box = root.querySelector(`[data-value-of="${open}"]`);
73
+ if (r && ownOf(r)?.body != null)
74
+ return;
75
+ if (!r || !field || !takes || takes === "none")
76
+ return void setOpen(null);
77
+ if (field.choices || field.type === "date")
78
+ return void box?.querySelector(".o-select-field")?.focus({ preventScroll: true });
79
+ box?.querySelector("input")?.focus({ preventScroll: true });
80
+ setOpen(null);
81
+ }, [open, root, standing]);
82
+ const opener = (id) => (o) => setOpen((x) => (o ? id : x === id ? null : x));
83
+ const back = () => setStep(null);
84
+ useStepReturn(root, !phone || !step ? [] : [step.list === "add" ? ((group) => openerAt(() => `[data-add-to="${CSS.escape(group)}"]`))(step.group)
85
+ : ((id, list) => openerAt(() => (list === "value" ? `[data-value-of="${CSS.escape(id)}"] :is(.o-select-field, input, button)`
86
+ : `.o-filter-editor-rule[data-rule="${CSS.escape(id)}"] .o-filter-editor-${list} .o-select-field`)))(step.rule, step.list)]);
87
+ const add = (group, field) => {
88
+ if (typeof field !== "string")
89
+ return;
90
+ const { filter: next, id } = addRule(now.current, field, fields, group, ids);
91
+ if (!id)
92
+ return;
93
+ change(next);
94
+ if (!phone)
95
+ return void setOpen(id);
96
+ setStep(listed(rulesOf(next).find((x) => x.id === id)) ? { list: "value", rule: id } : null);
97
+ };
98
+ const remove = (id) => {
99
+ root?.focus({ preventScroll: true });
100
+ const next = removeRule(now.current, id);
101
+ change(next);
102
+ if (way === "computer" && !next.rules.length)
103
+ onDone?.();
104
+ };
105
+ const clear = () => { change(clearAll(now.current)); if (way === "computer")
106
+ onDone?.(); };
107
+ const set = (id) => (v) => change(changeRule(now.current, id, { value: v }, fields));
108
+ const decide = useDecide(now, change, onDone, { close: w.close, save: w.save }), placed = decide.place;
109
+ const placeRoot = React.useCallback((el) => { setRoot(el); placed(el); }, [placed]);
110
+ const room = useStandingRoom(root, "[data-filter-shown]", phone, [standing, props.at]);
111
+ const [adding, setAdding] = React.useState(null);
112
+ const addButton = (group, kind, size) => (_jsx(Button, { kind: kind, size: size, icon: glyph(PLUS), className: "o-filter-editor-add", "data-add-to": group, "aria-haspopup": "dialog", "aria-expanded": phone ? step?.list === "add" && step.group === group : adding?.group === group, onClick: (e) => { const at = e.currentTarget; if (phone)
113
+ setStep({ list: "add", group });
114
+ else
115
+ setAdding((a) => (a?.group === group ? null : { group, at })); }, children: w.add }));
116
+ const stepRule = step && step.list !== "add" ? rulesOf(filter).find((x) => x.id === step.rule) : undefined;
117
+ const stepField = stepRule ? fieldOf(fields, stepRule.field) : undefined;
118
+ React.useEffect(() => { if (step && step.list !== "add" && !stepRule)
119
+ setStep(null); }, [step, stepRule]);
120
+ const stepTakes = stepRule && stepField ? wayOf(stepField.type, stepRule.how)?.takes : undefined;
121
+ const stepOwn = stepRule && step?.list === "value" ? ownOf(stepRule) : null;
122
+ const stepDate = !!stepRule && step?.list === "value" && !stepOwn && stepField?.type === "date";
123
+ const several = stepTakes === "several";
124
+ const stepValue = stepRule && stepField?.choices ? (several ? (Array.isArray(stepRule.value) && !isPair(stepRule.value) ? stepRule.value : []) : typeof stepRule.value === "string" ? stepRule.value : null) : null;
125
+ const waysOf = (f) => HOW[f.type].map((x) => ({ value: x.value, label: w.way(x.value), divider: x.takes === "none" && x.value === "empty" }));
126
+ const stepList = usePicker(step?.list === "how" && stepRule && stepField
127
+ ? { label: w.howOf(nameOf(stepRule.field)), items: waysOf(stepField), value: isOwnWay(stepRule.how) ? null : stepRule.how, searchShown: false, fromHeld: true, form: "phone", onDone: back,
128
+ onValueChange: (v) => { if (typeof v === "string" && v !== stepRule.how)
129
+ change(changeRule(now.current, stepRule.id, { how: v }, fields)); back(); }, ...words }
130
+ : step?.list === "value" && stepRule && stepField?.choices
131
+ ? { label: nameOf(stepRule.field), items: stepField.choices, multiple: several, value: stepValue, searchShown: false, fromHeld: true, form: "phone", onDone: back, draft: "shell",
132
+ onValueChange: (v) => { set(stepRule.id)(several ? (Array.isArray(v) ? v : []) : typeof v === "string" ? v : null); if (!several)
133
+ back(); }, ...words }
134
+ : { label: step?.list === "field" ? w.field : w.add, items: fields, value: step?.list === "field" && stepRule ? stepRule.field : null, search: w.search, searchShown: true, form: "phone",
135
+ onDone: () => setStep((s) => (s?.list === "add" || s?.list === "field" ? null : s)),
136
+ onValueChange: (v) => {
137
+ if (typeof v !== "string")
138
+ return;
139
+ if (step?.list === "field" && stepRule) {
140
+ if (v !== stepRule.field || stepRule.aside)
141
+ pointAt(stepRule.id, v);
142
+ back();
143
+ }
144
+ else if (step?.list === "add")
145
+ add(step.group, v);
146
+ }, ...words });
147
+ const stepTitle = phone && step ? (step.list === "add" ? w.add : !stepRule ? undefined : step.list === "field" ? w.field : step.list === "how" ? w.howOf(labelOf(stepRule)) : labelOf(stepRule)) : undefined;
148
+ const stepBody = stepOwn ? stepOwn.body
149
+ : stepDate && stepRule ? _jsx(DateStep, { name: labelOf(stepRule), value: typeof stepRule.value === "string" ? stepRule.value : null, onValue: set(stepRule.id), onDone: back })
150
+ : stepList.body;
151
+ const size = phone ? "lg" : "sm";
152
+ const fieldItems = asSelect(fields);
153
+ const stepOf = (s) => (phone ? { open: false, onOpenChange: (o) => { if (o)
154
+ setStep(s); } } : {});
155
+ const valueBox = (r, field, takes, own) => {
156
+ const isOpen = open === r.id, onOpenChange = opener(r.id), name = labelOf(r);
157
+ if (own)
158
+ return _jsx(OwnValue, { name: name, own: own, open: !standing && isOpen, onOpenChange: phone ? (o) => { if (o)
159
+ setStep({ list: "value", rule: r.id }); } : onOpenChange, phone: phone, size: size, placeholder: w.choose });
160
+ if (field.choices) {
161
+ const several = takes === "several", value = several ? (Array.isArray(r.value) && !isPair(r.value) ? r.value : []) : typeof r.value === "string" ? r.value : null;
162
+ const pick = (v) => set(r.id)(several ? (Array.isArray(v) ? v : []) : typeof v === "string" ? v : null);
163
+ return _jsxs(_Fragment, { children: [_jsx(Select, { size: size, listWidth: "rows", "aria-label": name, placeholder: w.choose, multiple: several, items: asSelect(field.choices), value: value, "data-force": standing && isOpen ? "focus" : undefined, ...(phone ? stepOf({ list: "value", rule: r.id }) : standing ? {} : { open: isOpen, onOpenChange }), onValueChange: pick }), standing && isOpen && !phone && (_jsx("div", { className: "o-filter-editor-shown o-list o-smooth o-smooth-ease", "data-filter-shown": "list", ...phoneMark(small), children: _jsx(Picker, { label: name, items: field.choices, multiple: several, value: value, onValueChange: pick, searchShown: false, form: "computer", standing: true, ...words }) }))] });
164
+ }
165
+ if (takes === "two")
166
+ return _jsx(PairValue, { name: name, value: isPair(r.value) ? r.value : [null, null], onValue: set(r.id), size: size, words: w });
167
+ if (field.type === "date")
168
+ return _jsx(DateValue, { name: name, value: typeof r.value === "string" ? r.value : null, onValue: set(r.id), open: !standing && isOpen, onOpenChange: phone ? (o) => { if (o)
169
+ setStep({ list: "value", rule: r.id }); } : onOpenChange, phone: phone, size: size, placeholder: w.chooseDate });
170
+ if (field.type === "number" || field.type === "range")
171
+ return _jsx(NumberField, { size: size, steppers: false, "aria-label": name, placeholder: w.typeNumber, value: typeof r.value === "number" ? r.value : null, onValueChange: (v) => set(r.id)(v ?? null) });
172
+ return _jsx(Input, { size: size, "aria-label": name, placeholder: w.typeValue, value: typeof r.value === "string" ? r.value : "", onChange: (e) => set(r.id)(e.target.value) });
173
+ };
174
+ const ruleRow = (r) => {
175
+ const field = fieldOf(fields, r.field), own = ownOf(r), aside = r.aside, name = labelOf(r);
176
+ const kitWay = field ? wayOf(field.type, r.how) : undefined, takes = kitWay ? kitWay.takes : own && !aside && own.body != null ? "one" : undefined;
177
+ const ways = field ? waysOf(field) : [];
178
+ const entries = aside
179
+ ? [{ icon: null, label: aside.why, disabled: aside.why },
180
+ ...(aside.putBack ? [{ icon: null, label: w.putBack, onSelect: () => change(putBack(now.current, r.id)) }] : []),
181
+ { icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id) }]
182
+ : [...(canGroup(filter, r.id, levels) ? [{ icon: glyph(GROUP), label: w.toGroup, onSelect: () => change(toGroup(now.current, r.id, ids, levels)) }] : []),
183
+ { icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id) }];
184
+ const why = (node) => (aside ? _jsx(Tooltip, { label: aside.why, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: node }) }) : node);
185
+ const wayPlaceholder = own && !kitWay ? own.way : w.way(r.how);
186
+ return (_jsxs("div", { className: "o-filter-editor-rule", "data-rule": r.id, "data-whole": (field || own) && isWhole(r, fields) ? "" : undefined, "data-set-aside": aside || (!field && !own) ? "" : undefined, "data-aside": aside ? "" : undefined, children: [_jsxs("div", { className: "o-filter-editor-boxes", children: [_jsx("div", { className: "o-filter-editor-field", children: why(_jsx(Select, { size: size, listWidth: "rows", "aria-label": w.field, items: fieldItems, value: field && !aside ? r.field : null, placeholder: name, search: w.search, ...stepOf({ list: "field", rule: r.id }), onValueChange: (v) => { if (typeof v === "string" && (v !== r.field || aside))
187
+ pointAt(r.id, v); } })) }), _jsx("div", { className: "o-filter-editor-how", children: why(_jsx(Select, { size: size, listWidth: "rows", "aria-label": w.how, items: ways, value: field && kitWay && !aside ? r.how : null, placeholder: wayPlaceholder, disabled: !!aside || (!field && !!own), ...(field || !own ? stepOf({ list: "how", rule: r.id }) : {}), onValueChange: (v) => { if (typeof v === "string" && v !== r.how)
188
+ change(changeRule(now.current, r.id, { how: v }, fields)); } })) }), aside && own?.value != null && (_jsx("div", { className: "o-filter-editor-value", "data-value-of": r.id, "data-value-box": "own", children: why(_jsx(Input, { readOnly: true, disabled: true, size: size, "aria-label": name, value: own.value, className: "o-filter-editor-own-box" })) })), !aside && takes && takes !== "none" && (field || own) && (_jsx("div", { className: "o-filter-editor-value", "data-value-of": r.id, "data-value-box": own ? "own" : field?.choices ? "choice" : takes === "two" ? "pair" : field?.type === "date" ? "date" : "typed", children: valueBox(r, field ?? { value: r.field, label: name, type: "text" }, takes, own) }))] }), _jsx(Menu, { label: w.ruleOf(name), align: "end", entries: entries, trigger: phone ? _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-filter-editor-more", "aria-label": w.ruleOf(name), icon: glyph(DOTS) })
189
+ : _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-filter-editor-more", "aria-label": w.ruleOf(name), icon: glyph(DOTS_UP) }) })] }));
190
+ };
191
+ const lead = (g, i) => i === 0 ? _jsx("span", { className: "o-filter-editor-where", children: w.where })
192
+ : i === 1 ? _jsx(Button, { kind: "outline", size: "sm", className: "o-filter-editor-join", iconEnd: glyph(TURNS), onClick: () => change(setJoin(now.current, g.id, g.join === "and" ? "or" : "and")), children: w.join(g.join) })
193
+ : _jsx("span", { className: "o-filter-editor-joined", children: w.join(g.join) });
194
+ const level = (g, depth) => (_jsx("div", { className: "o-filter-editor-rules", role: "list", "aria-label": depth ? w.group : label, children: g.rules.map((item, i) => (_jsxs("div", { role: "listitem", className: "o-filter-editor-item", children: [lead(g, i), isGroup(item) ? (_jsxs("div", { className: "o-filter-editor-group", "data-group": item.id, children: [level(item, depth + 1), _jsxs("div", { className: "o-filter-editor-foot", children: [addButton(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"), _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-delete", onClick: () => remove(item.id), children: w.deleteGroup })] })] })) : ruleRow(item)] }, item.id))) }));
195
+ const addingPopover = !standing && (_jsx(Popover, { open: !!adding, onOpenChange: (o) => { if (!o)
196
+ setAdding(null); }, anchor: adding?.at, className: "w-fit min-w-[calc(var(--vk-spacing,var(--spacing))*48)]", "aria-label": w.add, children: adding && _jsx(Picker, { label: w.add, items: fields, value: null, onValueChange: (v) => add(adding.group, v), onDone: () => setAdding(null), search: w.search, searchShown: true, form: "computer", ...words }) }));
197
+ if (stacked) {
198
+ const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-kit": "filter-editor", "data-filter-form": way, role: phone ? undefined : "group", "aria-label": phone ? undefined : label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-filter-step": stepTitle !== undefined ? step?.list : undefined, children: stepTitle !== undefined ? stepBody : _jsxs(_Fragment, { children: [filter.rules.length ? level(filter, 0)
199
+ : _jsxs("div", { className: "o-filter-editor-none", children: [_jsx("p", { className: "o-filter-editor-none-head", children: w.none }), _jsx("p", { className: "o-filter-editor-none-line", children: w.noneLine })] }), _jsxs("div", { className: "o-filter-editor-acts", children: [addButton(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"), filter.rules.length > 0 && _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-clear", onClick: clear, children: w.clearAll })] }), !phone && addingPopover] }) }));
200
+ return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
201
+ }
202
+ const fieldsAlone = !filter.rules.length;
203
+ const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-kit": "filter-editor", "data-filter-form": "computer", role: "group", "aria-label": label, tabIndex: -1, "data-filter-fields": fieldsAlone ? "" : undefined, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: !fieldsAlone ? _jsxs(_Fragment, { children: [level(filter, 0), _jsxs("div", { className: "o-filter-editor-foot", children: [addButton(filter.id, "outline", "sm"), _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", onClick: clear, children: w.clearAllFilters })] }), addingPopover] }) : (_jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words })) }));
204
+ return { body, head: {} };
205
+ }
206
+ export function FilterEditor(props) {
207
+ return _jsx(_Fragment, { children: useFilterEditor(props).body });
208
+ }
@@ -0,0 +1,23 @@
1
+ import type { PickerItem } from "../picker/rows.js";
2
+ export type FieldType = "status" | "select" | "person" | "record" | "number" | "text" | "date" | "checkbox" | "range";
3
+ /** What a way takes: one value, several (a choice's), two (a range's From and To), or none. */
4
+ export type Takes = "one" | "several" | "two" | "none";
5
+ /** One way a type compares: its value in a rule, its words, what it takes. */
6
+ export interface FilterWay {
7
+ value: string;
8
+ label: string;
9
+ takes: Takes;
10
+ }
11
+ /** A field a list filters by: the Picker's item, with its type; a choice's values (a stage's, a person's, a record's), each a
12
+ * Picker's item with its mark; a related record's fields one level in (a deal's Company), each typed too. */
13
+ export interface FilterField extends PickerItem {
14
+ type: FieldType;
15
+ choices?: PickerItem[];
16
+ level?: FilterField[];
17
+ }
18
+ /** Each type's ways, in the order they are offered; the first is a new rule's. */
19
+ export declare const HOW: Record<FieldType, FilterWay[]>;
20
+ /** A yes/no's values, ViewKit's words for them: a yes/no field carries them as its choices. */
21
+ export declare const CHECKED: PickerItem[];
22
+ /** A type's way by its value, or nothing where the type has no such way. */
23
+ export declare const wayOf: (type: FieldType, how: string) => FilterWay | undefined;
@@ -0,0 +1,13 @@
1
+ const way = (label, takes) => ({ value: label.replace(/ /g, "-"), label, takes });
2
+ const EMPTINESS = [way("empty", "none"), way("not empty", "none")];
3
+ const CHOICE = [way("is", "one"), way("is not", "one"), way("is any of", "several"), way("is none of", "several"), ...EMPTINESS];
4
+ export const HOW = {
5
+ status: CHOICE, select: CHOICE, person: CHOICE, record: CHOICE,
6
+ number: [way("is", "one"), way("is not", "one"), way("less than", "one"), way("greater than", "one"), ...EMPTINESS],
7
+ text: [way("contains", "one"), way("does not contain", "one"), way("starts with", "one"), way("ends with", "one"), way("is", "one"), way("is not", "one"), ...EMPTINESS],
8
+ date: [way("is", "one"), way("is not", "one"), way("before", "one"), way("after", "one"), ...EMPTINESS],
9
+ checkbox: [way("is", "one")],
10
+ range: [way("any part between", "two"), way("entirely within", "two"), way("includes", "one"), way("at least", "one"), way("at most", "one"), ...EMPTINESS],
11
+ };
12
+ export const CHECKED = [{ value: "true", label: "Checked" }, { value: "false", label: "Unchecked" }];
13
+ export const wayOf = (type, how) => HOW[type].find((w) => w.value === how);
@@ -0,0 +1,18 @@
1
+ import type { FilterRule as ViewKitRule } from "viewkitjs/fields/query";
2
+ import { type ViewsMessageResolver } from "../../contract.js";
3
+ import type { ViewsFilterBodyProps, ViewsFilterPartBodyProps } from "../../provider/components.js";
4
+ import { type ChoicesOf, type KitFields } from "./map-rules.js";
5
+ import { type FilterGroup as KitGroup } from "./rules.js";
6
+ import type { FilterEditorWords } from "./words.js";
7
+ /** The filter editor's words in the app's messages. */
8
+ export declare function filterWordsOf(say: ViewsMessageResolver): FilterEditorWords;
9
+ export declare function MapFilterBody(props: ViewsFilterBodyProps): import("react/jsx-runtime").JSX.Element;
10
+ /** The rule as a one-rule kit filter, with the kit's fields for it; null where the kit draws no rule of it, or where a choice has no
11
+ * values to offer, which ViewKit's own body then draws. */
12
+ export declare function partOf(rule: ViewKitRule, field: ViewsFilterPartBodyProps["field"], choices: ChoicesOf): {
13
+ kit: KitFields;
14
+ filter: KitGroup;
15
+ } | null;
16
+ /** The kit filter's one rule as ViewKit's, naming the field and part the rule handed did; null where it holds none. */
17
+ export declare function ruleBack(next: KitGroup, rule: ViewKitRule, kit: KitFields): ViewKitRule | null;
18
+ export declare function MapFilterPartBody(props: ViewsFilterPartBodyProps): import("react/jsx-runtime").JSX.Element;