viewkitjs 0.28.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 (305) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/MIGRATION.md +85 -4
  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.js +2 -2
  41. package/views/dist/cells/cell-values.js +9 -10
  42. package/views/dist/contract.d.ts +149 -3
  43. package/views/dist/contract.js +157 -1
  44. package/views/dist/controls/bulk-bar/bulk-bar-of.d.ts +66 -0
  45. package/views/dist/controls/bulk-bar/bulk-bar-of.js +22 -0
  46. package/views/dist/controls/bulk-bar/bulk-bar.d.ts +40 -0
  47. package/views/dist/controls/bulk-bar/bulk-bar.js +278 -0
  48. package/views/dist/controls/bulk-bar/looks.d.ts +10 -0
  49. package/views/dist/controls/bulk-bar/looks.js +14 -0
  50. package/views/dist/controls/bulk-bar/map-selection-bar.d.ts +19 -0
  51. package/views/dist/controls/bulk-bar/map-selection-bar.js +57 -0
  52. package/views/dist/controls/bulk-bar/tokens.d.ts +136 -0
  53. package/views/dist/controls/bulk-bar/tokens.js +36 -0
  54. package/views/dist/controls/bulk-bar/words.d.ts +50 -0
  55. package/views/dist/controls/bulk-bar/words.js +19 -0
  56. package/views/dist/controls/bulk-bar.css +96 -0
  57. package/views/dist/controls/button/button.js +3 -1
  58. package/views/dist/controls/button.css +5 -4
  59. package/views/dist/controls/checkbox/checkbox.js +3 -1
  60. package/views/dist/controls/checkbox.css +1 -1
  61. package/views/dist/controls/choice/tokens.d.ts +79 -0
  62. package/views/dist/controls/choice/tokens.js +22 -0
  63. package/views/dist/controls/choice.css +31 -0
  64. package/views/dist/controls/compound-editor/looks.js +1 -1
  65. package/views/dist/controls/controls.d.ts +10 -0
  66. package/views/dist/controls/controls.js +8 -0
  67. package/views/dist/controls/customize/customize.d.ts +125 -0
  68. package/views/dist/controls/customize/customize.js +243 -0
  69. package/views/dist/controls/customize/glide.d.ts +10 -0
  70. package/views/dist/controls/customize/glide.js +55 -0
  71. package/views/dist/controls/customize/looks.d.ts +13 -0
  72. package/views/dist/controls/customize/looks.js +11 -0
  73. package/views/dist/controls/customize/map-customize-body.d.ts +18 -0
  74. package/views/dist/controls/customize/map-customize-body.js +160 -0
  75. package/views/dist/controls/customize/rules.d.ts +23 -0
  76. package/views/dist/controls/customize/rules.js +19 -0
  77. package/views/dist/controls/customize/tokens.d.ts +40 -0
  78. package/views/dist/controls/customize/tokens.js +12 -0
  79. package/views/dist/controls/customize/words.d.ts +58 -0
  80. package/views/dist/controls/customize/words.js +37 -0
  81. package/views/dist/controls/customize.css +54 -0
  82. package/views/dist/controls/date-editor/looks.js +1 -1
  83. package/views/dist/controls/filter-editor/block.d.ts +31 -0
  84. package/views/dist/controls/filter-editor/block.js +27 -0
  85. package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
  86. package/views/dist/controls/filter-editor/filter-editor.js +85 -43
  87. package/views/dist/controls/filter-editor/how.d.ts +1 -1
  88. package/views/dist/controls/filter-editor/how.js +1 -0
  89. package/views/dist/controls/filter-editor/map-filter-body.d.ts +16 -1
  90. package/views/dist/controls/filter-editor/map-filter-body.js +39 -13
  91. package/views/dist/controls/filter-editor/map-rules.d.ts +27 -11
  92. package/views/dist/controls/filter-editor/map-rules.js +73 -42
  93. package/views/dist/controls/filter-editor/rules.d.ts +43 -5
  94. package/views/dist/controls/filter-editor/rules.js +55 -2
  95. package/views/dist/controls/filter-editor/words.d.ts +15 -0
  96. package/views/dist/controls/filter-editor/words.js +6 -0
  97. package/views/dist/controls/filter-editor.css +18 -0
  98. package/views/dist/controls/index.d.ts +26 -2
  99. package/views/dist/controls/index.js +25 -2
  100. package/views/dist/controls/inline-input/looks.js +1 -1
  101. package/views/dist/controls/input/input.js +10 -4
  102. package/views/dist/controls/internal/phone.d.ts +5 -4
  103. package/views/dist/controls/internal/phone.js +7 -7
  104. package/views/dist/controls/internal/scroll.js +5 -1
  105. package/views/dist/controls/internal/typed-run.d.ts +2 -0
  106. package/views/dist/controls/internal/typed-run.js +5 -0
  107. package/views/dist/controls/menu/map-menu.js +2 -2
  108. package/views/dist/controls/number-editor/looks.js +1 -1
  109. package/views/dist/controls/option/option.js +3 -1
  110. package/views/dist/controls/option.css +1 -1
  111. package/views/dist/controls/pane/pane.d.ts +4 -0
  112. package/views/dist/controls/pane/pane.js +2 -1
  113. package/views/dist/controls/picker/looks.js +1 -1
  114. package/views/dist/controls/picker/map-picker.d.ts +6 -2
  115. package/views/dist/controls/picker/map-picker.js +4 -2
  116. package/views/dist/controls/picker/picker.d.ts +7 -0
  117. package/views/dist/controls/picker/picker.js +57 -8
  118. package/views/dist/controls/popover/map-popover.d.ts +1 -1
  119. package/views/dist/controls/popover/map-popover.js +2 -2
  120. package/views/dist/controls/popover/popover.js +2 -1
  121. package/views/dist/controls/popover.css +3 -0
  122. package/views/dist/controls/ports-host/map-ports-host.d.ts +7 -0
  123. package/views/dist/controls/ports-host/map-ports-host.js +43 -0
  124. package/views/dist/controls/press/tokens.d.ts +8 -0
  125. package/views/dist/controls/press/tokens.js +4 -0
  126. package/views/dist/controls/press.css +44 -0
  127. package/views/dist/controls/quick-filters/looks.d.ts +11 -0
  128. package/views/dist/controls/quick-filters/looks.js +9 -0
  129. package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +31 -0
  130. package/views/dist/controls/quick-filters/map-quick-filters-body.js +56 -0
  131. package/views/dist/controls/quick-filters/quick-filters.d.ts +37 -0
  132. package/views/dist/controls/quick-filters/quick-filters.js +89 -0
  133. package/views/dist/controls/quick-filters/reminder.d.ts +18 -0
  134. package/views/dist/controls/quick-filters/reminder.js +41 -0
  135. package/views/dist/controls/quick-filters/rules.d.ts +89 -0
  136. package/views/dist/controls/quick-filters/rules.js +52 -0
  137. package/views/dist/controls/quick-filters/tokens.d.ts +112 -0
  138. package/views/dist/controls/quick-filters/tokens.js +30 -0
  139. package/views/dist/controls/quick-filters/words.d.ts +25 -0
  140. package/views/dist/controls/quick-filters/words.js +13 -0
  141. package/views/dist/controls/quick-filters.css +118 -0
  142. package/views/dist/controls/sheet/bottom-sheet.d.ts +9 -4
  143. package/views/dist/controls/sheet/bottom-sheet.js +4 -4
  144. package/views/dist/controls/sheet/map-sheet.d.ts +4 -1
  145. package/views/dist/controls/sheet/map-sheet.js +19 -6
  146. package/views/dist/controls/sheet/sheet-parts.d.ts +10 -0
  147. package/views/dist/controls/sheet/sheet-parts.js +2 -0
  148. package/views/dist/controls/switch-row/switch-row.d.ts +15 -0
  149. package/views/dist/controls/switch-row/switch-row.js +9 -0
  150. package/views/dist/controls/switch-row/tokens.d.ts +51 -0
  151. package/views/dist/controls/switch-row/tokens.js +15 -0
  152. package/views/dist/controls/switch-row.css +39 -0
  153. package/views/dist/controls/switch.css +1 -1
  154. package/views/dist/controls/tag/tag.js +3 -1
  155. package/views/dist/controls/tag-field/tag-field.d.ts +20 -0
  156. package/views/dist/controls/tag-field/tag-field.js +19 -0
  157. package/views/dist/controls/tag-field/tokens.d.ts +7 -0
  158. package/views/dist/controls/tag-field/tokens.js +4 -0
  159. package/views/dist/controls/tag-field.css +13 -0
  160. package/views/dist/controls/text-editor/looks.js +1 -1
  161. package/views/dist/controls/text-editor/text-editor.js +1 -5
  162. package/views/dist/controls/toast/toast.d.ts +5 -1
  163. package/views/dist/controls/toast/toast.js +5 -3
  164. package/views/dist/controls/tokens.js +18 -0
  165. package/views/dist/controls/toolbar/keys.d.ts +3 -0
  166. package/views/dist/controls/toolbar/keys.js +11 -0
  167. package/views/dist/controls/toolbar/looks.d.ts +10 -0
  168. package/views/dist/controls/toolbar/looks.js +40 -0
  169. package/views/dist/controls/toolbar/tokens.d.ts +28 -0
  170. package/views/dist/controls/toolbar/tokens.js +9 -0
  171. package/views/dist/controls/toolbar/toolbar.d.ts +111 -0
  172. package/views/dist/controls/toolbar/toolbar.js +370 -0
  173. package/views/dist/controls/toolbar/words.d.ts +28 -0
  174. package/views/dist/controls/toolbar/words.js +17 -0
  175. package/views/dist/controls/toolbar-button/looks.d.ts +4 -0
  176. package/views/dist/controls/toolbar-button/looks.js +21 -0
  177. package/views/dist/controls/toolbar-button/tokens.d.ts +103 -0
  178. package/views/dist/controls/toolbar-button/tokens.js +28 -0
  179. package/views/dist/controls/toolbar-button/toolbar-button.d.ts +66 -0
  180. package/views/dist/controls/toolbar-button/toolbar-button.js +51 -0
  181. package/views/dist/controls/toolbar-button.css +75 -0
  182. package/views/dist/controls/toolbar.css +65 -0
  183. package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
  184. package/views/dist/controls/tooltip/map-tooltip.js +2 -2
  185. package/views/dist/controls/tooltip/tooltip.d.ts +3 -1
  186. package/views/dist/controls/tooltip/tooltip.js +2 -2
  187. package/views/dist/controls/values-editor/looks.js +1 -1
  188. package/views/dist/controls/views-list/map-views-list-body.d.ts +4 -1
  189. package/views/dist/controls/views-list/map-views-list-body.js +128 -4
  190. package/views/dist/controls/views-list/rules.d.ts +26 -0
  191. package/views/dist/controls/views-list/rules.js +63 -0
  192. package/views/dist/controls/views-list/view-menu.d.ts +84 -0
  193. package/views/dist/controls/views-list/view-menu.js +201 -0
  194. package/views/dist/controls/views-list/views-list.d.ts +8 -1
  195. package/views/dist/controls/views-list/views-list.js +18 -3
  196. package/views/dist/controls/views-list/words.d.ts +54 -0
  197. package/views/dist/controls/views-list/words.js +10 -1
  198. package/views/dist/controls/views-list.css +5 -1
  199. package/views/dist/display/date.js +3 -3
  200. package/views/dist/display/format.d.ts +6 -0
  201. package/views/dist/display/format.js +3 -0
  202. package/views/dist/display/index.d.ts +1 -1
  203. package/views/dist/display/index.js +1 -1
  204. package/views/dist/display/range.d.ts +2 -1
  205. package/views/dist/display/range.js +4 -1
  206. package/views/dist/grid/chrome/GridHeader.js +2 -1
  207. package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
  208. package/views/dist/grid/chrome/GridRowCells.js +2 -1
  209. package/views/dist/grid/chrome/GridTextEditor.js +2 -2
  210. package/views/dist/grid/chrome/grid-editor-layer.d.ts +5 -1
  211. package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
  212. package/views/dist/grid/chrome/grid-fitted-box.d.ts +7 -1
  213. package/views/dist/grid/chrome/grid-fitted-box.js +4 -4
  214. package/views/dist/grid/core/clipboard-model.js +9 -4
  215. package/views/dist/grid/grid.css +240 -0
  216. package/views/dist/grid/looks.d.ts +5 -1
  217. package/views/dist/grid/looks.js +20 -12
  218. package/views/dist/grid-tokens.d.ts +109 -0
  219. package/views/dist/grid-tokens.js +29 -0
  220. package/views/dist/looks/index.d.ts +5 -0
  221. package/views/dist/looks/index.js +5 -0
  222. package/views/dist/looks/pieces.js +10 -0
  223. package/views/dist/model/column-capabilities.d.ts +2 -0
  224. package/views/dist/model/column-filters.d.ts +2 -1
  225. package/views/dist/model/column-from.js +2 -2
  226. package/views/dist/model/relation-filters.d.ts +2 -0
  227. package/views/dist/panels/index.d.ts +2 -2
  228. package/views/dist/panels/index.js +2 -2
  229. package/views/dist/panels/labels.d.ts +4 -0
  230. package/views/dist/panels/labels.js +8 -0
  231. package/views/dist/panels/model.d.ts +10 -2
  232. package/views/dist/panels/quick/model.d.ts +4 -0
  233. package/views/dist/panels/react/customize-body.d.ts +9 -4
  234. package/views/dist/panels/react/customize-body.js +39 -11
  235. package/views/dist/panels/react/customize.d.ts +8 -1
  236. package/views/dist/panels/react/customize.js +9 -6
  237. package/views/dist/panels/react/filter/FilterEditor.js +4 -4
  238. package/views/dist/panels/react/filter/FilterFieldList.js +10 -2
  239. package/views/dist/panels/react/filter/PhoneFilterEditor.js +3 -3
  240. package/views/dist/panels/react/filter/filter-body.js +5 -2
  241. package/views/dist/panels/react/panel-step.d.ts +3 -0
  242. package/views/dist/panels/react/panel-step.js +2 -1
  243. package/views/dist/panels/react/quick/QuickFiltersPanel.js +1 -0
  244. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -3
  245. package/views/dist/panels/react/toolbar/ReadyToolbar.js +10 -3
  246. package/views/dist/panels/react/toolbar/Toolbar.js +1 -1
  247. package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
  248. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +13 -3
  249. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -1
  250. package/views/dist/panels/react/toolbar/ToolbarFilters.js +3 -3
  251. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +12 -4
  252. package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -2
  253. package/views/dist/panels/react/view-footer.d.ts +1 -1
  254. package/views/dist/panels/react/views-row/ViewPicker.js +25 -4
  255. package/views/dist/panels/settings/filter-groups.d.ts +3 -0
  256. package/views/dist/panels/settings/filter-groups.js +40 -9
  257. package/views/dist/panels/settings/filters.d.ts +5 -0
  258. package/views/dist/panels/settings/filters.js +12 -6
  259. package/views/dist/panels/views-row/model.d.ts +10 -1
  260. package/views/dist/provider/ViewsProvider.js +29 -5
  261. package/views/dist/provider/components.d.ts +149 -8
  262. package/views/dist/provider/context.d.ts +6 -0
  263. package/views/dist/provider/ports.d.ts +18 -6
  264. package/views/dist/provider/ports.js +2 -1
  265. package/views/dist/react.d.ts +2 -2
  266. package/views/dist/react.js +1 -1
  267. package/views/dist/selection/SelectionBar.d.ts +2 -16
  268. package/views/dist/selection/SelectionBar.js +4 -1
  269. package/views/dist/selection/bar-props.d.ts +26 -0
  270. package/views/dist/selection/bar-props.js +1 -0
  271. package/views/dist/selection/index.d.ts +1 -1
  272. package/views/dist/selection/verbs.d.ts +32 -5
  273. package/views/dist/styles.css +656 -25
  274. package/views/dist/styles.unlayered.css +653 -22
  275. package/views/docs/contract.md +44 -17
  276. package/views/docs/controls/bulk-bar.md +41 -0
  277. package/views/docs/controls/choice.md +25 -0
  278. package/views/docs/controls/customize.md +17 -0
  279. package/views/docs/controls/popover.md +2 -0
  280. package/views/docs/controls/press.md +9 -0
  281. package/views/docs/controls/quick-filters.md +35 -0
  282. package/views/docs/controls/radio.md +1 -1
  283. package/views/docs/controls/switch-row.md +18 -0
  284. package/views/docs/controls/tag-field.md +7 -0
  285. package/views/docs/controls/toolbar-button.md +31 -0
  286. package/views/docs/controls/toolbar.md +14 -0
  287. package/views/docs/guides/atoms.md +2 -2
  288. package/views/docs/guides/cells.md +2 -2
  289. package/views/docs/guides/display.md +2 -2
  290. package/views/docs/guides/looks.md +8 -2
  291. package/views/docs/guides/ports.md +6 -6
  292. package/views/docs/guides/selection.md +5 -1
  293. package/views/docs/guides/the-grid.md +1 -1
  294. package/views/docs/guides/the-provider.md +2 -2
  295. package/views/docs/install.md +4 -1
  296. package/views/docs/reference/cells.md +1 -1
  297. package/views/docs/reference/controls.md +194 -13
  298. package/views/docs/reference/display.md +1 -0
  299. package/views/docs/reference/looks.md +25 -11
  300. package/views/docs/reference/panels-react.md +7 -7
  301. package/views/docs/reference/panels.md +8 -6
  302. package/views/docs/reference/react.md +13 -6
  303. package/views/docs/reference/selection.md +4 -2
  304. package/views/docs/reference/views.md +7 -6
  305. package/views/skills/views/SKILL.md +2 -2
@@ -0,0 +1,370 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { flushSync } from "react-dom";
5
+ import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
6
+ import { cx as cn } from "../../internal/cx.js";
7
+ import { Button, ButtonGroup } from "../button/button.js";
8
+ import { Input, InputGroup, InputGroupAddon, InputGroupButton } from "../input/input.js";
9
+ import { Icon } from "../internal/icons.js";
10
+ import { PhoneHost, usePhone } from "../internal/phone.js";
11
+ import { Menu } from "../menu/menu.js";
12
+ import { ToggleGroup } from "../toggle/toggle.js";
13
+ import { InToolbar, ToolbarButtonControl as ToolbarButton, useToolbarButtonWorn } from "../toolbar-button/toolbar-button.js";
14
+ import { lineKeys } from "./keys.js";
15
+ import { TOOLBAR_ATTRS, toolbarWornOf } from "./looks.js";
16
+ import { TOOLBAR_WORDS, toolbarWords } from "./words.js";
17
+ const BUTTON_SIZE = { "28": "xs", "32": "sm", "36": "md", "44": "44" };
18
+ const INPUT_SIZE = { "28": "xs", "32": "sm", "36": "md", "44": "lg" };
19
+ const SMALLER = { "28": "28", "32": "28", "36": "32", "44": "36" };
20
+ const KIND_OF_GROUND = { ghost: "quiet", bordered: "outline", filled: "soft" };
21
+ const put = (p, at) => (typeof p === "function" ? p(at) : p);
22
+ const TOOLBAR_DEF = toolbarWornOf(null);
23
+ const OPTION_IDS = Object.keys(TOOLBAR_DEF);
24
+ const samePicks = (a, b) => OPTION_IDS.every((id) => a[id] === b[id]);
25
+ export function useToolbarWorn(el) {
26
+ const [picks, setPicks] = React.useState(TOOLBAR_DEF);
27
+ React.useLayoutEffect(() => {
28
+ const read = () => setPicks((was) => { const now = toolbarWornOf(el); return samePicks(was, now) ? was : now; });
29
+ read();
30
+ const watch = new MutationObserver(read);
31
+ watch.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: TOOLBAR_ATTRS });
32
+ return () => watch.disconnect();
33
+ }, [el]);
34
+ return picks;
35
+ }
36
+ const Said = React.createContext(TOOLBAR_WORDS);
37
+ const InSearch = React.createContext(null);
38
+ function onTheRight(node, words) {
39
+ return flat(node).map((el, i) => (isToolbarButton(el) ? React.cloneElement(el, { key: el.key ?? `r${i}`, words }) : el));
40
+ }
41
+ const isToolbarButton = (el) => el.type === ToolbarButton;
42
+ const isFolds = (el) => el.type === ToolbarFolds;
43
+ export function ToolbarFolds({ children }) {
44
+ return children(0);
45
+ }
46
+ const isButton = (el) => el.type === Button;
47
+ const words = (n) => (typeof n === "string" || typeof n === "number" ? String(n) : null);
48
+ const flat = (nodes) => React.Children.toArray(nodes).flatMap((n) => !React.isValidElement(n) ? [] : n.type === React.Fragment ? flat(n.props.children) : [n]);
49
+ const itemsOf = (nodes, line) => {
50
+ const items = flat(nodes), keys = lineKeys(items.map((el) => el.key), line);
51
+ return items.map((el, i) => React.cloneElement(el, { key: keys[i] }));
52
+ };
53
+ function sheds(el) {
54
+ if (isToolbarButton(el))
55
+ return el.props.icon != null && el.props.words == null;
56
+ if (isButton(el))
57
+ return el.props.icon != null && el.props.shape == null && words(el.props.children) != null;
58
+ return false;
59
+ }
60
+ const isGroup = (el) => el.type === ButtonGroup;
61
+ const isTab = (el) => !!el && isToolbarButton(el) && el.props.current !== undefined;
62
+ const isJoined = (el) => isGroup(el) && !!el.props["aria-label"] && flat(el.props.children).some(isToolbarButton);
63
+ const folds = (el) => (isToolbarButton(el) && !el.props.stays)
64
+ || (isJoined(el) && el.props["data-open"] == null);
65
+ const isFilter = (el) => !!el && (isJoined(el) || (isToolbarButton(el) && !!el.props.filter));
66
+ function stepsOf(items) {
67
+ const from = (test, to) => items.flatMap((el, i) => (test(el) ? [{ i, to }] : [])).reverse();
68
+ const held = (kind) => (el, i) => isFolds(el) && el.props.kind === kind ? Array.from({ length: Math.max(0, el.props.count) }, () => ({ i, to: "fold" })) : [];
69
+ const fromWith = (test, kind) => items.flatMap((el, i) => (test(el) ? [{ i, to: "fold" }] : held(kind)(el, i))).reverse();
70
+ return [...from(sheds, "icon"), ...fromWith((el) => folds(el) && isTab(el), "tabs"), ...fromWith((el) => folds(el) && isFilter(el), "filters"),
71
+ ...from((el) => folds(el) && !isTab(el) && !isFilter(el), "fold")];
72
+ }
73
+ export const toolbarSteps = stepsOf;
74
+ function overflows(line) {
75
+ const box = line.getBoundingClientRect(), style = getComputedStyle(line), scale = line.offsetWidth ? box.width / line.offsetWidth : 1;
76
+ const edge = box.right - (parseFloat(style.paddingRight) + parseFloat(style.borderRightWidth)) * scale;
77
+ let far = -Infinity;
78
+ for (const child of line.children) {
79
+ if (!(child instanceof HTMLElement) || child.hidden)
80
+ continue;
81
+ const at = getComputedStyle(child).position;
82
+ if (at === "absolute" || at === "fixed")
83
+ continue;
84
+ const r = child.getBoundingClientRect();
85
+ if (r.width || r.height)
86
+ far = Math.max(far, r.right);
87
+ }
88
+ return far > edge + 0.5;
89
+ }
90
+ const HOLDING_OPEN = ":is([data-more], [data-more-tabs], [data-more-filters])[aria-expanded='true'], .o-toolbar-folds [aria-expanded='true']";
91
+ function useGiveWay(line, max, on, holds = false) {
92
+ const [fit, setFit] = React.useState({ stage: 0, mode: "done" });
93
+ const held = React.useRef(holds);
94
+ const stage = Math.min(fit.stage, max);
95
+ const ours = React.useRef(false), now = React.useRef(fit), latest = React.useRef({ stage, max });
96
+ React.useLayoutEffect(() => { held.current = holds; now.current = fit; latest.current = { stage, max }; });
97
+ const set = React.useCallback((next) => {
98
+ if (now.current.stage === next.stage && now.current.mode === next.mode)
99
+ return;
100
+ ours.current = true;
101
+ now.current = next;
102
+ setFit(next);
103
+ }, []);
104
+ const look = React.useCallback((at, top) => {
105
+ if (!line || held.current || line.querySelector(HOLDING_OPEN))
106
+ return;
107
+ if (overflows(line)) {
108
+ if (at < top)
109
+ set({ stage: at + 1, mode: "climb" });
110
+ }
111
+ else if (at > 0)
112
+ set({ stage: at - 1, mode: "probe" });
113
+ }, [line, set]);
114
+ React.useLayoutEffect(() => {
115
+ if (!line || !on)
116
+ return;
117
+ if (!ours.current) {
118
+ look(stage, max);
119
+ return;
120
+ }
121
+ ours.current = false;
122
+ if (fit.mode === "climb") {
123
+ if (overflows(line) && stage < max)
124
+ set({ stage: stage + 1, mode: "climb" });
125
+ else
126
+ set({ stage, mode: "done" });
127
+ }
128
+ else if (fit.mode === "probe") {
129
+ if (overflows(line))
130
+ set({ stage: stage + 1, mode: "done" });
131
+ else if (stage > 0)
132
+ set({ stage: stage - 1, mode: "probe" });
133
+ else
134
+ set({ stage, mode: "done" });
135
+ }
136
+ });
137
+ React.useEffect(() => {
138
+ if (!line || !on)
139
+ return;
140
+ let width = -1;
141
+ const again = () => flushSync(() => look(latest.current.stage, latest.current.max));
142
+ const sized = new ResizeObserver(([e]) => { const w = e.contentRect.width; if (w !== width) {
143
+ width = w;
144
+ again();
145
+ } });
146
+ sized.observe(line);
147
+ const picks = new MutationObserver((ms) => { if (ms.some((m) => m.attributeName?.startsWith("data-") && m.oldValue !== m.target.getAttribute(m.attributeName)))
148
+ again(); });
149
+ for (let up = line.parentElement?.parentElement; up; up = up.parentElement)
150
+ picks.observe(up, { attributes: true, attributeOldValue: true });
151
+ const menus = new MutationObserver((ms) => { if (ms.some((m) => m.oldValue === "true" && m.target.getAttribute("aria-expanded") !== "true"))
152
+ again(); });
153
+ menus.observe(line, { attributes: true, attributeOldValue: true, attributeFilter: ["aria-expanded"], subtree: true });
154
+ const fonts = document.fonts;
155
+ fonts?.addEventListener?.("loadingdone", again);
156
+ return () => { sized.disconnect(); picks.disconnect(); menus.disconnect(); fonts?.removeEventListener?.("loadingdone", again); };
157
+ }, [line, on, look]);
158
+ return stage;
159
+ }
160
+ export function ToolbarControl({ label, children, bar, barLabel: barNamed, words: given, views, settings, search, add, sort, filter, filters, save, quick, added = false, picks: said, size, barSize, spacing, fold = true, holds = false, form, onMoreViews, moreViewsOpen, className, style, onKeyDown, ...props }) {
161
+ const spoken = toolbarWords(given), barLabel = barNamed ?? spoken.bar;
162
+ const host = React.useContext(PhoneHost), narrow = usePhone();
163
+ const phone = form ? form === "phone" : host != null || narrow;
164
+ const [root, setRoot] = React.useState(null);
165
+ const worn = useToolbarButtonWorn(root, phone), framed = useToolbarWorn(root);
166
+ const picks = { ...framed, ...said };
167
+ const [searching, setSearching] = React.useState(false);
168
+ const height = phone ? worn.size : size ?? worn.size;
169
+ const barHeight = phone ? height : barSize ?? SMALLER[height];
170
+ const listed = [views, settings, search, add, sort, filter, filters, save, quick].some((p) => p != null);
171
+ let lines;
172
+ if (!listed) {
173
+ const row = itemsOf(children, "row"), under = itemsOf(bar, "bar");
174
+ lines = phone
175
+ ? [{ id: "row", items: under.length ? [...row.slice(0, 1), ...under, ...row.slice(1)] : row, size: height, label }]
176
+ : [{ id: "row", items: row, size: height, label }, ...(under.length ? [{ id: "bar", items: under, size: barHeight, label: barLabel }] : [])];
177
+ }
178
+ else {
179
+ const searchForm = phone ? picks.searchphone : picks.search;
180
+ const opens = searchForm === "button";
181
+ const rightWords = picks.words === "both" ? "both" : "icon";
182
+ const searchEl = search && (_jsx(InSearch.Provider, { value: { form: opens ? "button" : "input", words: "icon", open: searching, setOpen: setSearching }, children: search }, "search"));
183
+ const spacer = (key) => _jsx(ToolbarSpacer, {}, key);
184
+ if (phone) {
185
+ const right = picks.sortfilterphone === "right";
186
+ const tools = [put(sort, "phone"), put(filter, "phone"), picks.quick === "button" ? put(quick, "phone") : null, put(settings, "phone")];
187
+ const viewsHere = put(views, "phone");
188
+ const line = opens && searching && searchEl
189
+ ? [React.isValidElement(viewsHere) && isToolbarButton(viewsHere) ? React.cloneElement(viewsHere, { words: "icon", iconEnd: undefined }) : viewsHere, searchEl]
190
+ : right
191
+ ? [viewsHere, children, spacer("sp"), ...tools, opens ? searchEl : null]
192
+ : [viewsHere, ...tools, children, opens ? searchEl : null];
193
+ lines = [
194
+ ...(!opens && searchEl ? [{ id: "search", items: itemsOf([searchEl], "search"), size: height, label: spoken.search }] : []),
195
+ { id: "row", items: itemsOf(line, "row"), size: height, label },
196
+ ];
197
+ }
198
+ else {
199
+ const onRight = picks.sortfilter === "right", settingsRight = picks.settings === "right";
200
+ const row = [
201
+ put(views, "row"), settingsRight ? null : put(settings, "row"), children, spacer("sp"),
202
+ ...(onRight ? [onTheRight(put(sort, "right"), rightWords), onTheRight(put(filter, "right"), rightWords)] : []),
203
+ picks.quick === "button" ? onTheRight(put(quick, "right"), "icon") : null, searchEl,
204
+ settingsRight ? onTheRight(put(settings, "right"), rightWords) : null, add && dressNew(add, picks.add, worn.ground),
205
+ ];
206
+ const shows = picks.sortfilter === "bar" || picks.bar === "always" || added;
207
+ const sortHere = put(sort, "bar"), filterHere = filters ?? put(filter, "bar");
208
+ const saveHere = picks.save === "bar" ? save : null;
209
+ const under = shows ? [sortHere, sortHere != null && filterHere != null ? _jsx(ToolbarSeparatorControl, {}, "sep") : null, filterHere, bar, ...(saveHere ? [spacer("bar-sp"), saveHere] : [])] : [];
210
+ const barItems = itemsOf(under, "bar");
211
+ lines = [{ id: "row", items: itemsOf(row, "row"), size: height, label }, ...(barItems.length ? [{ id: "bar", items: barItems, size: barHeight, label: barLabel }] : [])];
212
+ }
213
+ }
214
+ const ends = (e) => {
215
+ onKeyDown?.(e);
216
+ if ((e.key !== "Home" && e.key !== "End") || e.defaultPrevented)
217
+ return;
218
+ const t = e.target;
219
+ if (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t.isContentEditable)
220
+ return;
221
+ const stops = [...e.currentTarget.querySelectorAll("button:not(:disabled), input:not(:disabled), [role='button']:not([aria-disabled='true'])")]
222
+ .filter((s) => s.offsetParent !== null && !s.closest("[hidden], [inert]"));
223
+ const to = e.key === "Home" ? stops[0] : stops[stops.length - 1];
224
+ if (!to)
225
+ return;
226
+ e.preventDefault();
227
+ to.focus();
228
+ };
229
+ return (_jsx(BaseToolbar.Root, { ref: setRoot, "aria-label": label, orientation: "horizontal", className: cn("o-toolbar", className), "data-kit": "toolbar", "data-screen": phone ? "phone" : "computer", "data-size": height, "data-lines": listed && !phone ? picks.lines : undefined, style: spacing != null ? { ...style, "--toolbar-spacing": spacing } : style, onKeyDown: ends, ...props, children: _jsx(Said.Provider, { value: spoken, children: lines.map((l) => (_jsx(InToolbar.Provider, { value: { size: l.size, form: phone ? "phone" : "computer" }, children: _jsx(Line, { id: l.id, label: l.label, items: l.items, size: l.size, fold: fold, holds: holds, more: onMoreViews ? { press: onMoreViews, open: !!moreViewsOpen } : undefined }) }, l.id))) }) }));
230
+ }
231
+ function dressNew(el, form, ground) {
232
+ if (!isButton(el))
233
+ return el;
234
+ const p = el.props, said = words(p.children);
235
+ const kind = form.startsWith("primary") ? "primary" : form.startsWith("outline") ? "outline" : KIND_OF_GROUND[ground];
236
+ return React.cloneElement(el, { kind, ...(form.endsWith("-icon") ? { shape: "icon", children: undefined, "aria-label": p["aria-label"] ?? said ?? undefined } : {}) });
237
+ }
238
+ function Line({ id, label, items, size, fold, holds, more: moreViews }) {
239
+ const [line, setLine] = React.useState(null);
240
+ const said = React.useContext(Said);
241
+ const steps = fold ? stepsOf(items) : [];
242
+ const stage = useGiveWay(line, steps.length, fold, holds);
243
+ const iconAlone = new Set(), folded = new Set(), foldedIn = new Map();
244
+ for (const s of steps.slice(0, stage)) {
245
+ if (isFolds(items[s.i]))
246
+ foldedIn.set(s.i, (foldedIn.get(s.i) ?? 0) + 1);
247
+ else
248
+ (s.to === "icon" ? iconAlone : folded).add(s.i);
249
+ }
250
+ const tabFolded = [...folded].filter((i) => isTab(items[i])), filterFolded = [...folded].filter((i) => isFilter(items[i])).sort((a, b) => a - b);
251
+ const otherFolded = [...folded].filter((i) => !isTab(items[i]) && !isFilter(items[i]));
252
+ const last = (at) => (at.length ? Math.max(...at) : -1);
253
+ const moreAt = last(otherFolded), tabsAt = last(tabFolded), filtersAt = last(filterFolded);
254
+ const entryOf = (el, at) => {
255
+ if (isGroup(el)) {
256
+ const parts = flat(el.props.children).filter(isToolbarButton), presses = parts.find((b) => b.props.filter) ?? parts[0];
257
+ return [{ icon: null, label: el.props["aria-label"], ...(presses?.props.onClick ? { onSelect: () => pressAt(presses.props.onClick, line?.querySelector(at)) } : {}) }];
258
+ }
259
+ if (!isToolbarButton(el))
260
+ return [];
261
+ const p = el.props;
262
+ return [{ icon: p.icon ?? null, label: words(p.children) ?? p.label, count: p.count, disabled: p.disabled ? said.cantUse : undefined,
263
+ onSelect: () => pressAt(p.onClick, line?.querySelector(at)) }];
264
+ };
265
+ const more = (_jsx(Menu, { label: said.moreOf(label), align: "end", entries: otherFolded.flatMap((i) => entryOf(items[i], "[data-more]")), trigger: _jsx(ToolbarButton, { label: said.more, icon: _jsx(Icon, { name: "dots" }), words: "icon", stays: true, "data-more": "" }) }, "more"));
266
+ const firstTab = items.find(isTab);
267
+ const plusN = (p = {}) => (_jsx(ToolbarButton, { label: said.moreViews(tabFolded.length), words: "word", current: false, stays: true, "data-more-tabs": "", ground: firstTab?.props.ground, corners: firstTab?.props.corners, ...p, children: `+${tabFolded.length}` }, "more-tabs"));
268
+ const moreTabs = !tabFolded.length ? null : moreViews
269
+ ? plusN({ "aria-haspopup": "dialog", "aria-expanded": moreViews.open, onClick: (e) => moreViews.press(e.currentTarget) })
270
+ : _jsx(Menu, { label: said.moreViewsOf(label), align: "start", entries: tabFolded.flatMap((i) => entryOf(items[i], "[data-more-tabs]")), trigger: plusN() }, "more-tabs");
271
+ const n = filterFolded.length;
272
+ const moreFilters = n ? (_jsx(Menu, { label: said.moreFiltersOf(label), align: "start", entries: filterFolded.flatMap((i) => entryOf(items[i], "[data-more-filters]")), trigger: _jsx(ToolbarButton, { label: said.moreFiltersName(n), words: "word", ground: "filled", stays: true, "data-more-filters": "", children: said.moreFilters(n) }) }, "more-filters")) : null;
273
+ const drawn = [];
274
+ items.forEach((el, i) => {
275
+ if (folded.has(i)) {
276
+ if (i === moreAt)
277
+ drawn.push(more);
278
+ if (i === tabsAt)
279
+ drawn.push(moreTabs);
280
+ if (i === filtersAt)
281
+ drawn.push(moreFilters);
282
+ return;
283
+ }
284
+ if (isFolds(el)) {
285
+ drawn.push(_jsx("span", { className: "o-toolbar-folds", "data-folds": el.props.kind, children: el.props.children(foldedIn.get(i) ?? 0) }, el.key));
286
+ return;
287
+ }
288
+ drawn.push(dress(el, iconAlone.has(i), size));
289
+ });
290
+ const shown = drawn.filter((n, k) => {
291
+ if (!isSeparator(n))
292
+ return true;
293
+ const before = drawn.slice(0, k).filter((x) => !isSeparator(x)).length, after = drawn.slice(k + 1).filter((x) => !isSeparator(x)).length;
294
+ return before > 0 && after > 0 && !isSeparator(drawn[k - 1]);
295
+ });
296
+ return (_jsx("div", { ref: setLine, className: "o-toolbar-line", "data-line": id, "data-size": size, ...(id === "bar" ? { role: "group", "aria-label": label } : {}), children: shown }));
297
+ }
298
+ function pressAt(onClick, at) {
299
+ if (!onClick || !at)
300
+ return;
301
+ onClick({ currentTarget: at, target: at, preventDefault() { }, stopPropagation() { } });
302
+ }
303
+ function dress(el, alone, height) {
304
+ if (isToolbarButton(el))
305
+ return alone ? React.cloneElement(el, { words: "icon" }) : el;
306
+ if (isGroup(el) && !isJoined(el)) {
307
+ const inner = flat(el.props.children).map((c) => {
308
+ if (isButton(c))
309
+ return dress(c, false, height);
310
+ if (c.type === Menu) {
311
+ const trigger = c.props.trigger;
312
+ if (trigger && isButton(trigger)) {
313
+ const sized = React.cloneElement(trigger, { size: trigger.props.size ?? BUTTON_SIZE[height] });
314
+ return React.cloneElement(c, { trigger: _jsx(BaseToolbar.Button, { render: sized }) });
315
+ }
316
+ }
317
+ return c;
318
+ });
319
+ return React.cloneElement(el, {}, ...inner);
320
+ }
321
+ if (isButton(el)) {
322
+ const p = el.props, said = words(p.children);
323
+ const button = React.cloneElement(el, {
324
+ size: p.size ?? BUTTON_SIZE[height],
325
+ ...(alone ? { shape: "icon", children: undefined, "aria-label": p["aria-label"] ?? said ?? undefined } : {}),
326
+ });
327
+ return _jsx(BaseToolbar.Button, { render: button, disabled: p.disabled, focusableWhenDisabled: false }, el.key);
328
+ }
329
+ if (el.type === ToggleGroup) {
330
+ const p = el.props;
331
+ return p.size ? el : React.cloneElement(el, { size: BUTTON_SIZE[height] });
332
+ }
333
+ return el;
334
+ }
335
+ const isSeparator = (n) => React.isValidElement(n) && n.type === ToolbarSeparatorControl;
336
+ export function ToolbarSeparatorControl({ className }) {
337
+ const row = React.useContext(InToolbar);
338
+ return row ? _jsx(BaseToolbar.Separator, { className: cn("o-toolbar-sep", className) }) : _jsx("span", { role: "separator", className: cn("o-toolbar-sep", className) });
339
+ }
340
+ export function ToolbarSpacer() {
341
+ return _jsx("span", { className: "o-toolbar-spacer", "aria-hidden": "true" });
342
+ }
343
+ export const ToolbarInput = React.forwardRef(function ToolbarInput({ size, icon, className, onKeyDown, onBlur, ...props }, ref) {
344
+ const row = React.useContext(InToolbar), search = React.useContext(InSearch), said = React.useContext(Said);
345
+ const z = size ?? (row ? INPUT_SIZE[row.size] : undefined);
346
+ const opens = search?.form === "button" && icon != null;
347
+ const back = React.useRef(false), [iconEl, setIconEl] = React.useState(null);
348
+ React.useEffect(() => { if (iconEl && back.current) {
349
+ back.current = false;
350
+ iconEl.focus();
351
+ } }, [iconEl]);
352
+ const name = props["aria-label"] ?? props.placeholder ?? said.search;
353
+ if (opens && !search.open)
354
+ return _jsx(ToolbarButton, { ref: setIconEl, label: name, icon: icon, words: search.words, stays: true, onClick: () => search.setOpen(true), children: said.search });
355
+ const close = opens ? () => { if (props.value != null)
356
+ props.onValueChange?.("", undefined); search.setOpen(false); } : null;
357
+ const input = (_jsx(Input, { ref: ref, size: z, className: cn("o-toolbar-input", className), ...(row ? { render: _jsx(BaseToolbar.Input, {}) } : {}), ...(close ? { autoFocus: true } : {}), onKeyDown: (e) => { onKeyDown?.(e); if (close && e.key === "Escape") {
358
+ e.preventDefault();
359
+ back.current = true;
360
+ close();
361
+ } }, onBlur: (e) => {
362
+ onBlur?.(e);
363
+ const to = e.relatedTarget;
364
+ if (close && !e.currentTarget.value && !(to && e.currentTarget.closest(".o-input-group")?.contains(to)))
365
+ close();
366
+ }, ...props }));
367
+ if (icon == null)
368
+ return input;
369
+ return (_jsxs(InputGroup, { size: z, "data-open": close ? "" : undefined, children: [_jsx(InputGroupAddon, { side: "start", children: icon }), input, close && _jsx(InputGroupAddon, { side: "end", children: _jsx(InputGroupButton, { shape: "icon", "aria-label": said.close(name), icon: _jsx(Icon, { name: "x" }), onClick: close }) })] }));
370
+ });
@@ -0,0 +1,28 @@
1
+ export interface ToolbarWords {
2
+ /** The filter bar's name, to a screen reader. */
3
+ bar: string;
4
+ /** The search's button, shut: its word, and its name where its box names none. */
5
+ search: string;
6
+ /** The open search's ✕, named after the search. */
7
+ close: (name: string) => string;
8
+ /** ⋯, holding what folded. */
9
+ more: string;
10
+ /** ⋯'s Menu, named after the line's Toolbar. */
11
+ moreOf: (label: string) => string;
12
+ /** "+N" on the view tabs: its name. */
13
+ moreViews: (n: number) => string;
14
+ /** "+N"'s Menu. */
15
+ moreViewsOf: (label: string) => string;
16
+ /** "+N filters": what it says. */
17
+ moreFilters: (n: number) => string;
18
+ /** "+N filters": its name. */
19
+ moreFiltersName: (n: number) => string;
20
+ /** "+N filters"' Menu. */
21
+ moreFiltersOf: (label: string) => string;
22
+ /** Why a folded item that can't be used is greyed in the Menu holding it. */
23
+ cantUse: string;
24
+ }
25
+ /** The Toolbar's English words. */
26
+ export declare const TOOLBAR_WORDS: ToolbarWords;
27
+ /** The app's words over the English, each it leaves out the English. */
28
+ export declare function toolbarWords(given?: Partial<ToolbarWords>): ToolbarWords;
@@ -0,0 +1,17 @@
1
+ const filters = (n) => (n === 1 ? "filter" : "filters");
2
+ export const TOOLBAR_WORDS = {
3
+ bar: "Sort and filters",
4
+ search: "Search",
5
+ close: (name) => `Close ${name.toLowerCase()}`,
6
+ more: "More",
7
+ moreOf: (label) => `More of ${label}`,
8
+ moreViews: (n) => `${n} more views`,
9
+ moreViewsOf: (label) => `More views of ${label}`,
10
+ moreFilters: (n) => `+${n} ${filters(n)}`,
11
+ moreFiltersName: (n) => `${n} more ${filters(n)}`,
12
+ moreFiltersOf: (label) => `More filters of ${label}`,
13
+ cantUse: "Can't be used",
14
+ };
15
+ export function toolbarWords(given) {
16
+ return given ? { ...TOOLBAR_WORDS, ...given } : TOOLBAR_WORDS;
17
+ }
@@ -0,0 +1,4 @@
1
+ import type { PieceLooks } from "../../looks/looks.js";
2
+ export type ToolbarButtonOptionId = "ground" | "words" | "size" | "corners" | "groundphone" | "wordsphone" | "sizephone" | "cornersphone" | "smoothing" | "weight";
3
+ /** The toolbar button's options and looks. */
4
+ export declare const TOOLBAR_BUTTON_LOOKS: PieceLooks<ToolbarButtonOptionId>;
@@ -0,0 +1,21 @@
1
+ const GROUNDS = [{ id: "ghost", name: "Ghost" }, { id: "bordered", name: "Bordered" }, { id: "filled", name: "Filled" }];
2
+ const CORNERS = [{ id: "button", name: "The Button's" }, ...["xs", "sm", "md", "lg", "xl", "2xl", "full"].map((id) => ({ id, name: id === "full" ? "Full" : id }))];
3
+ const steps = (ids) => ids.map((id) => ({ id, name: id }));
4
+ const options = [
5
+ { id: "ground", name: "Ground", def: "bordered", device: "desktop", values: GROUNDS },
6
+ { id: "words", name: "Words", def: "both", device: "desktop", values: [{ id: "both", name: "Icon and word" }, { id: "icon", name: "Icon" }, { id: "word", name: "Word" }] },
7
+ { id: "size", name: "Size", def: "32", device: "desktop", kind: "steps", values: steps(["28", "32", "36"]) },
8
+ { id: "corners", name: "Corners", def: "button", device: "desktop", kind: "steps", values: CORNERS },
9
+ { id: "groundphone", name: "Ground", def: "filled", device: "phone", values: GROUNDS },
10
+ { id: "wordsphone", name: "Words", def: "icon", device: "phone", values: [{ id: "icon", name: "Icon" }, { id: "both", name: "Icon and word" }] },
11
+ { id: "sizephone", name: "Size", def: "36", device: "phone", kind: "steps", values: steps(["36", "44"]) },
12
+ { id: "cornersphone", name: "Corners", def: "full", device: "phone", kind: "steps", values: CORNERS },
13
+ { id: "smoothing", name: "Corner smoothing", def: "app", values: [{ id: "app", name: "The app's" }, { id: "smooth", name: "Smooth" }, { id: "round", name: "Round" }] },
14
+ { id: "weight", name: "Label weight", def: "button", values: [{ id: "button", name: "The Button's" }, { id: "medium", name: "Medium" }, { id: "semibold", name: "Semibold" }] },
15
+ ];
16
+ const DEFAULTS = Object.fromEntries(options.map((o) => [o.id, o.def]));
17
+ const looks = [
18
+ { id: "attio", name: "Attio", picks: DEFAULTS },
19
+ { id: "portal", name: "The portal's", picks: { ...DEFAULTS, ground: "ghost", words: "icon" } },
20
+ ];
21
+ export const TOOLBAR_BUTTON_LOOKS = { id: "toolbar-button", name: "Toolbar button", options, looks };
@@ -0,0 +1,103 @@
1
+ export declare const TOOLBAR_BUTTON_TOKENS: readonly [{
2
+ readonly name: "--vk-radius-xs";
3
+ readonly kind: "size";
4
+ readonly outright: "--radius-xs";
5
+ }, {
6
+ readonly name: "--vk-radius-sm";
7
+ readonly kind: "size";
8
+ readonly outright: "--radius-sm";
9
+ }, {
10
+ readonly name: "--vk-radius-md";
11
+ readonly kind: "size";
12
+ readonly outright: "--radius-md";
13
+ }, {
14
+ readonly name: "--vk-radius-lg";
15
+ readonly kind: "size";
16
+ readonly outright: "--radius-lg";
17
+ }, {
18
+ readonly name: "--vk-radius-xl";
19
+ readonly kind: "size";
20
+ readonly outright: "--radius-xl";
21
+ }, {
22
+ readonly name: "--vk-radius-2xl";
23
+ readonly kind: "size";
24
+ readonly outright: "--radius-2xl";
25
+ }, {
26
+ readonly name: "--vk-radius-full";
27
+ readonly kind: "size";
28
+ readonly outright: "--radius-full";
29
+ }, {
30
+ readonly name: "--vk-font-weight-medium";
31
+ readonly kind: "size";
32
+ readonly outright: "--font-weight-medium";
33
+ }, {
34
+ readonly name: "--vk-font-weight-semibold";
35
+ readonly kind: "size";
36
+ readonly outright: "--font-weight-semibold";
37
+ }, {
38
+ readonly name: "--vk-spacing";
39
+ readonly kind: "size";
40
+ readonly outright: "--spacing";
41
+ }, {
42
+ readonly name: "--vk-fg-subtle";
43
+ readonly kind: "colour";
44
+ readonly outright: "--text-subtle";
45
+ }, {
46
+ readonly name: "--vk-dot-size";
47
+ readonly kind: "size";
48
+ readonly outright: "--dot-size";
49
+ }, {
50
+ readonly name: "--vk-brand";
51
+ readonly kind: "colour";
52
+ readonly outright: "--background-brand-bold";
53
+ }, {
54
+ readonly name: "--vk-fg-accent";
55
+ readonly kind: "colour";
56
+ readonly outright: "--text-brand";
57
+ }, {
58
+ readonly name: "--vk-fg";
59
+ readonly kind: "colour";
60
+ readonly outright: "--text";
61
+ }, {
62
+ readonly name: "--vk-selected";
63
+ readonly kind: "colour";
64
+ readonly outright: "--surface-selected";
65
+ }, {
66
+ readonly name: "--vk-fg-selected";
67
+ readonly kind: "colour";
68
+ readonly outright: "--text-selected";
69
+ }, {
70
+ readonly name: "--vk-raised-selected";
71
+ readonly kind: "colour";
72
+ readonly outright: "--surface-raised-selected";
73
+ }, {
74
+ readonly name: "--vk-sunken-selected";
75
+ readonly kind: "colour";
76
+ readonly outright: "--surface-sunken-selected";
77
+ }, {
78
+ readonly name: "--vk-brand-subtlest";
79
+ readonly kind: "colour";
80
+ readonly outright: "--background-brand-subtlest";
81
+ }, {
82
+ readonly name: "--vk-border-bold";
83
+ readonly kind: "colour";
84
+ readonly outright: "--border-bold";
85
+ }, {
86
+ readonly name: "--vk-hovered";
87
+ readonly kind: "colour";
88
+ readonly outright: "--surface-hovered";
89
+ }, {
90
+ readonly name: "--vk-border-warning";
91
+ readonly kind: "colour";
92
+ readonly outright: "--border-warning";
93
+ }, {
94
+ readonly name: "--vk-warning";
95
+ readonly kind: "colour";
96
+ readonly outright: "--text-warning";
97
+ }, {
98
+ readonly name: "--vk-warning-subtlest";
99
+ readonly kind: "colour";
100
+ readonly outright: "--background-warning-subtlest";
101
+ }];
102
+ /** The toolbar button sets only the Button's own machinery (`--button-*`, the Button's private family): no family of its own. */
103
+ export declare const TOOLBAR_BUTTON_PRIVATE: readonly [];
@@ -0,0 +1,28 @@
1
+ export const TOOLBAR_BUTTON_TOKENS = [
2
+ { name: "--vk-radius-xs", kind: "size", outright: "--radius-xs" },
3
+ { name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
4
+ { name: "--vk-radius-md", kind: "size", outright: "--radius-md" },
5
+ { name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
6
+ { name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
7
+ { name: "--vk-radius-2xl", kind: "size", outright: "--radius-2xl" },
8
+ { name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
9
+ { name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
10
+ { name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
11
+ { name: "--vk-spacing", kind: "size", outright: "--spacing" },
12
+ { name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
13
+ { name: "--vk-dot-size", kind: "size", outright: "--dot-size" },
14
+ { name: "--vk-brand", kind: "colour", outright: "--background-brand-bold" },
15
+ { name: "--vk-fg-accent", kind: "colour", outright: "--text-brand" },
16
+ { name: "--vk-fg", kind: "colour", outright: "--text" },
17
+ { name: "--vk-selected", kind: "colour", outright: "--surface-selected" },
18
+ { name: "--vk-fg-selected", kind: "colour", outright: "--text-selected" },
19
+ { name: "--vk-raised-selected", kind: "colour", outright: "--surface-raised-selected" },
20
+ { name: "--vk-sunken-selected", kind: "colour", outright: "--surface-sunken-selected" },
21
+ { name: "--vk-brand-subtlest", kind: "colour", outright: "--background-brand-subtlest" },
22
+ { name: "--vk-border-bold", kind: "colour", outright: "--border-bold" },
23
+ { name: "--vk-hovered", kind: "colour", outright: "--surface-hovered" },
24
+ { name: "--vk-border-warning", kind: "colour", outright: "--border-warning" },
25
+ { name: "--vk-warning", kind: "colour", outright: "--text-warning" },
26
+ { name: "--vk-warning-subtlest", kind: "colour", outright: "--background-warning-subtlest" },
27
+ ];
28
+ export const TOOLBAR_BUTTON_PRIVATE = [];
@@ -0,0 +1,66 @@
1
+ import * as React from "react";
2
+ import { type ButtonProps } from "../button/button.js";
3
+ export type ToolbarButtonGround = "ghost" | "bordered" | "filled";
4
+ export type ToolbarButtonSmoothing = "app" | "smooth" | "round";
5
+ export type ToolbarButtonWords = "both" | "icon" | "word";
6
+ export type ToolbarButtonSize = "28" | "32" | "36" | "44";
7
+ type Worn = {
8
+ ground: ToolbarButtonGround;
9
+ words: ToolbarButtonWords;
10
+ size: ToolbarButtonSize;
11
+ corners: string;
12
+ smoothing: ToolbarButtonSmoothing;
13
+ };
14
+ /** The toolbar it stands in: the row's height and form, which it takes unless it says its own. */
15
+ export declare const InToolbar: React.Context<{
16
+ size: ToolbarButtonSize;
17
+ form: "computer" | "phone";
18
+ } | null>;
19
+ /** Its options as worn around `el`, kept up to date as the frame's attributes change: what a toolbar reads too, for its row's
20
+ * height. */
21
+ export declare function useToolbarButtonWorn(el: HTMLElement | null, phone: boolean): Worn;
22
+ export interface ToolbarButtonProps extends Omit<ButtonProps, "kind" | "size" | "shape" | "look" | "children"> {
23
+ /** Its name: its word, unless `children` says more, and its name to a screen reader when its icon stands alone. */
24
+ label: string;
25
+ /** What it says in place of its bare name ("Sorted by Amount"). */
26
+ children?: React.ReactNode;
27
+ /** A count at its end ("+1", "2"), shown whatever its words. */
28
+ count?: React.ReactNode;
29
+ /** A dot at its top end corner: something is applied, with no number (View settings with unsaved changes). */
30
+ dot?: boolean;
31
+ /** An empty place: its edge dashed, a place waiting to be filled (Filter before the first filter). */
32
+ empty?: boolean;
33
+ /** In the brand once used (a sort or a filter in force). */
34
+ lit?: boolean;
35
+ /** Set aside: what it names has left the list (a filter whose field is gone), its edge dashed and its words in the warning
36
+ * colours, no depth. */
37
+ aside?: boolean;
38
+ /** A filter on the filter bar: a toolbar button standing for a filter of its own (an advanced filter) folds into "+N
39
+ * filters", never into ⋯; inside a filter's joined buttons, the one a press on that filter in "+N filters" presses (its value),
40
+ * the first unless one says so. */
41
+ filter?: boolean;
42
+ /** Joined to its neighbours, as one of a filter's parts drawn one at a time: where it stands among them, its corners on the
43
+ * outer side alone and the edge between two drawn once, as a ButtonGroup's button. */
44
+ joined?: "start" | "middle" | "end";
45
+ /** A view tab: one of several where one is open. Given at all, it is a tab, its words subtle until the pointer comes; the open
46
+ * one (true) stands on its ground's selected step, unmoved by the pointer, and in the brand (`lit`) on the brand's subtlest
47
+ * ground, a phone's view chip. */
48
+ current?: boolean;
49
+ /** What it holds says, for itself, over what the frame picks: the view switcher keeps its word on a phone. */
50
+ ground?: ToolbarButtonGround;
51
+ words?: ToolbarButtonWords;
52
+ size?: ToolbarButtonSize;
53
+ /** Its corners: "button" (the Button's), a radius step, or "full" (the pill; its icon alone, the circle). */
54
+ corners?: "button" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "full";
55
+ smoothing?: ToolbarButtonSmoothing;
56
+ /** Which form; by default the toolbar's it stands in, else the phone's in a phone's window or in a PhoneHost screen, else the
57
+ * computer's. */
58
+ form?: "computer" | "phone";
59
+ /** In a toolbar: it never folds into ⋯ when the row is too narrow. */
60
+ stays?: boolean;
61
+ /** Disabled, it still takes the pointer and the focus, so a Tooltip round it says why (Sort at three: "Three at most"). */
62
+ focusableWhenDisabled?: boolean;
63
+ }
64
+ /** A button in a toolbar: its icon, its word or both, the Button's look unless set apart, with a count, a dot or an empty place. */
65
+ export declare const ToolbarButtonControl: React.ForwardRefExoticComponent<Omit<ToolbarButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
66
+ export {};