@grafctory/clay-widgets 0.0.0-stage → 0.5.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 (189) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +56 -2
  3. package/dist/content/empty.css +107 -0
  4. package/dist/content/empty.d.ts +40 -0
  5. package/dist/content/empty.d.ts.map +1 -0
  6. package/dist/content/empty.js +42 -0
  7. package/dist/content/empty.js.map +1 -0
  8. package/dist/content/heading.css +34 -0
  9. package/dist/content/heading.d.ts +45 -0
  10. package/dist/content/heading.d.ts.map +1 -0
  11. package/dist/content/heading.js +49 -0
  12. package/dist/content/heading.js.map +1 -0
  13. package/dist/content/image.css +198 -0
  14. package/dist/content/image.d.ts +77 -0
  15. package/dist/content/image.d.ts.map +1 -0
  16. package/dist/content/image.js +67 -0
  17. package/dist/content/image.js.map +1 -0
  18. package/dist/content/infobox.css +186 -0
  19. package/dist/content/infobox.d.ts +72 -0
  20. package/dist/content/infobox.d.ts.map +1 -0
  21. package/dist/content/infobox.js +63 -0
  22. package/dist/content/infobox.js.map +1 -0
  23. package/dist/content/pill.css +76 -0
  24. package/dist/content/pill.d.ts +57 -0
  25. package/dist/content/pill.d.ts.map +1 -0
  26. package/dist/content/pill.js +48 -0
  27. package/dist/content/pill.js.map +1 -0
  28. package/dist/content/text.css +44 -0
  29. package/dist/content/text.d.ts +30 -0
  30. package/dist/content/text.d.ts.map +1 -0
  31. package/dist/content/text.js +42 -0
  32. package/dist/content/text.js.map +1 -0
  33. package/dist/controls/button.css +469 -0
  34. package/dist/controls/button.d.ts +116 -0
  35. package/dist/controls/button.d.ts.map +1 -0
  36. package/dist/controls/button.js +61 -0
  37. package/dist/controls/button.js.map +1 -0
  38. package/dist/controls/checkbox.css +23 -0
  39. package/dist/controls/checkbox.d.ts +54 -0
  40. package/dist/controls/checkbox.d.ts.map +1 -0
  41. package/dist/controls/checkbox.js +49 -0
  42. package/dist/controls/checkbox.js.map +1 -0
  43. package/dist/controls/choice.css +288 -0
  44. package/dist/controls/choice.d.ts +63 -0
  45. package/dist/controls/choice.d.ts.map +1 -0
  46. package/dist/controls/choice.js +52 -0
  47. package/dist/controls/choice.js.map +1 -0
  48. package/dist/controls/fieldset.css +37 -0
  49. package/dist/controls/fieldset.d.ts +49 -0
  50. package/dist/controls/fieldset.d.ts.map +1 -0
  51. package/dist/controls/fieldset.js +51 -0
  52. package/dist/controls/fieldset.js.map +1 -0
  53. package/dist/controls/form.css +50 -0
  54. package/dist/controls/form.d.ts +64 -0
  55. package/dist/controls/form.d.ts.map +1 -0
  56. package/dist/controls/form.js +62 -0
  57. package/dist/controls/form.js.map +1 -0
  58. package/dist/controls/input.css +57 -0
  59. package/dist/controls/input.d.ts +129 -0
  60. package/dist/controls/input.d.ts.map +1 -0
  61. package/dist/controls/input.js +71 -0
  62. package/dist/controls/input.js.map +1 -0
  63. package/dist/controls/label.css +73 -0
  64. package/dist/controls/label.d.ts +76 -0
  65. package/dist/controls/label.d.ts.map +1 -0
  66. package/dist/controls/label.js +73 -0
  67. package/dist/controls/label.js.map +1 -0
  68. package/dist/controls/radio.css +23 -0
  69. package/dist/controls/radio.d.ts +60 -0
  70. package/dist/controls/radio.d.ts.map +1 -0
  71. package/dist/controls/radio.js +50 -0
  72. package/dist/controls/radio.js.map +1 -0
  73. package/dist/controls/select.css +37 -0
  74. package/dist/controls/select.d.ts +71 -0
  75. package/dist/controls/select.d.ts.map +1 -0
  76. package/dist/controls/select.js +59 -0
  77. package/dist/controls/select.js.map +1 -0
  78. package/dist/controls/switch.css +154 -0
  79. package/dist/controls/switch.d.ts +44 -0
  80. package/dist/controls/switch.d.ts.map +1 -0
  81. package/dist/controls/switch.js +48 -0
  82. package/dist/controls/switch.js.map +1 -0
  83. package/dist/controls/textarea.css +50 -0
  84. package/dist/controls/textarea.d.ts +106 -0
  85. package/dist/controls/textarea.d.ts.map +1 -0
  86. package/dist/controls/textarea.js +68 -0
  87. package/dist/controls/textarea.js.map +1 -0
  88. package/dist/glyphs/icon.core.d.ts +52 -0
  89. package/dist/glyphs/icon.core.d.ts.map +1 -0
  90. package/dist/glyphs/icon.core.js +67 -0
  91. package/dist/glyphs/icon.core.js.map +1 -0
  92. package/dist/glyphs/icon.css +32 -0
  93. package/dist/glyphs/icon.d.ts +152 -0
  94. package/dist/glyphs/icon.d.ts.map +1 -0
  95. package/dist/glyphs/icon.js +167 -0
  96. package/dist/glyphs/icon.js.map +1 -0
  97. package/dist/glyphs/icon.md +76 -0
  98. package/dist/glyphs/logo.css +73 -0
  99. package/dist/glyphs/logo.d.ts +27 -0
  100. package/dist/glyphs/logo.d.ts.map +1 -0
  101. package/dist/glyphs/logo.js +49 -0
  102. package/dist/glyphs/logo.js.map +1 -0
  103. package/dist/index.core.d.ts +18 -0
  104. package/dist/index.core.d.ts.map +1 -0
  105. package/dist/index.core.js +36 -0
  106. package/dist/index.core.js.map +1 -0
  107. package/dist/index.d.ts +65 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +95 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/layouts/card.css +190 -0
  112. package/dist/layouts/card.d.ts +75 -0
  113. package/dist/layouts/card.d.ts.map +1 -0
  114. package/dist/layouts/card.js +62 -0
  115. package/dist/layouts/card.js.map +1 -0
  116. package/dist/layouts/stack.css +58 -0
  117. package/dist/layouts/stack.d.ts +64 -0
  118. package/dist/layouts/stack.d.ts.map +1 -0
  119. package/dist/layouts/stack.js +69 -0
  120. package/dist/layouts/stack.js.map +1 -0
  121. package/dist/layouts/strip.css +58 -0
  122. package/dist/layouts/strip.d.ts +72 -0
  123. package/dist/layouts/strip.d.ts.map +1 -0
  124. package/dist/layouts/strip.js +73 -0
  125. package/dist/layouts/strip.js.map +1 -0
  126. package/dist/layouts/tabs.core.d.ts +73 -0
  127. package/dist/layouts/tabs.core.d.ts.map +1 -0
  128. package/dist/layouts/tabs.core.js +65 -0
  129. package/dist/layouts/tabs.core.js.map +1 -0
  130. package/dist/layouts/tabs.css +260 -0
  131. package/dist/layouts/tabs.d.ts +57 -0
  132. package/dist/layouts/tabs.d.ts.map +1 -0
  133. package/dist/layouts/tabs.js +128 -0
  134. package/dist/layouts/tabs.js.map +1 -0
  135. package/dist/layouts/tree.css +138 -0
  136. package/dist/layouts/tree.d.ts +46 -0
  137. package/dist/layouts/tree.d.ts.map +1 -0
  138. package/dist/layouts/tree.js +69 -0
  139. package/dist/layouts/tree.js.map +1 -0
  140. package/dist/navigation/link.css +229 -0
  141. package/dist/navigation/link.d.ts +89 -0
  142. package/dist/navigation/link.d.ts.map +1 -0
  143. package/dist/navigation/link.js +91 -0
  144. package/dist/navigation/link.js.map +1 -0
  145. package/dist/navigation/path.css +122 -0
  146. package/dist/navigation/path.d.ts +42 -0
  147. package/dist/navigation/path.d.ts.map +1 -0
  148. package/dist/navigation/path.js +49 -0
  149. package/dist/navigation/path.js.map +1 -0
  150. package/dist/navigation/toc.core.d.ts +111 -0
  151. package/dist/navigation/toc.core.d.ts.map +1 -0
  152. package/dist/navigation/toc.core.js +60 -0
  153. package/dist/navigation/toc.core.js.map +1 -0
  154. package/dist/navigation/toc.css +53 -0
  155. package/dist/navigation/toc.d.ts +112 -0
  156. package/dist/navigation/toc.d.ts.map +1 -0
  157. package/dist/navigation/toc.js +321 -0
  158. package/dist/navigation/toc.js.map +1 -0
  159. package/dist/scopes/guard.css +26 -0
  160. package/dist/scopes/guard.d.ts +37 -0
  161. package/dist/scopes/guard.d.ts.map +1 -0
  162. package/dist/scopes/guard.js +60 -0
  163. package/dist/scopes/guard.js.map +1 -0
  164. package/dist/scopes/style.css +26 -0
  165. package/dist/scopes/style.d.ts +68 -0
  166. package/dist/scopes/style.d.ts.map +1 -0
  167. package/dist/scopes/style.js +108 -0
  168. package/dist/scopes/style.js.map +1 -0
  169. package/dist/shells/tool.css +770 -0
  170. package/dist/shells/tool.d.ts +167 -0
  171. package/dist/shells/tool.d.ts.map +1 -0
  172. package/dist/shells/tool.js +286 -0
  173. package/dist/shells/tool.js.map +1 -0
  174. package/dist/signals/more.css +42 -0
  175. package/dist/signals/more.d.ts +28 -0
  176. package/dist/signals/more.d.ts.map +1 -0
  177. package/dist/signals/more.js +61 -0
  178. package/dist/signals/more.js.map +1 -0
  179. package/dist/signals/note.css +221 -0
  180. package/dist/signals/note.d.ts +83 -0
  181. package/dist/signals/note.d.ts.map +1 -0
  182. package/dist/signals/note.js +72 -0
  183. package/dist/signals/note.js.map +1 -0
  184. package/dist/signals/toasts.css +463 -0
  185. package/dist/signals/toasts.d.ts +68 -0
  186. package/dist/signals/toasts.d.ts.map +1 -0
  187. package/dist/signals/toasts.js +160 -0
  188. package/dist/signals/toasts.js.map +1 -0
  189. package/package.json +331 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip.d.ts","sourceRoot":"","sources":["../../src/layouts/strip.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,QAAQ,CAAC;AAC/D,OAAO,aAAa,CAAC;AAerB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,KAAK,CAAC,EAErB,IAAI,EAEJ,IAAY,EACZ,IAAY,EAEZ,KAAe,EACf,KAAe,EACf,KAAK,EAEL,QAAQ,EAER,EAAE;IAEF;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAGrC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAGxB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;IAE/D;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAA;IAE3D;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IAGf;;OAEG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAE5B;;;;;;;;;;;GAoBA"}
@@ -0,0 +1,73 @@
1
+ /*
2
+ * Copyright © 2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Horizontal strip.
18
+ *
19
+ * Lines up what it holds side by side, a spacing step apart and optionally on a surface of its own, so a screen lays
20
+ * out its parts and sets a toolbar or a row of tiles apart from the page without a rule of its own.
21
+ *
22
+ * @module strip
23
+ */
24
+ import { isString, opt } from "@grafctory/core";
25
+ import { css, skin } from "@grafctory/skin";
26
+ import { createElement } from "preact";
27
+ import "./strip.css";
28
+ const justify = {
29
+ start: "start",
30
+ center: "center",
31
+ end: "end",
32
+ spread: "space-between",
33
+ head: undefined, // set apart by the stylesheet
34
+ tail: undefined // set apart by the stylesheet
35
+ };
36
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
37
+ /**
38
+ * Creates a horizontal strip.
39
+ *
40
+ * Places what it holds one item beside the other, in the order given, with the same gap between each pair and none
41
+ * before the first or after the last. The gap is a step of the {@link @grafctory/skin!index.skin spacing ladder}, so it
42
+ * follows the text size of the strip and whatever an app retuned the ladder to.
43
+ *
44
+ * The strip stands as wide as whatever holds it and as tall as its tallest item, each item keeping its own width;
45
+ * a strip told to grow takes whatever room its container leaves along the main axis. Items that do not fit stay on
46
+ * one line and overflow it, unless the strip is told to wrap, in which case they flow onto as many rows as they
47
+ * need, set apart as `wrap` states.
48
+ *
49
+ * A strip given a look sets its items on a padded, rounded surface of its own, painting everything inside it as
50
+ * standing on that surface, so a screen sets a toolbar or a row of tiles apart without a wrapper of its own.
51
+ *
52
+ * The strip carries no semantics: grouping its items for assistive technology takes an element inside it or around it.
53
+ *
54
+ * @param options The widget configuration
55
+ *
56
+ * @returns The horizontal strip
57
+ */
58
+ export function Strip({ look, grow = false, wrap = false, place = "start", align = "start", space, children }) {
59
+ const leading = isString(wrap) ? wrap : wrap ? space : undefined;
60
+ return createElement("clay-strip", {
61
+ look,
62
+ place,
63
+ style: {
64
+ flexGrow: grow ? 1 : undefined,
65
+ flexWrap: wrap ? "wrap" : undefined,
66
+ justifyContent: justify[place],
67
+ alignItems: align,
68
+ columnGap: opt(space, step => css.var(skin[step])),
69
+ rowGap: opt(leading, step => css.var(skin[step]))
70
+ }
71
+ }, children);
72
+ }
73
+ //# sourceMappingURL=strip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip.js","sourceRoot":"","sources":["../../src/layouts/strip.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAgB,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAA0B,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,aAAa,CAAC;AAGrB,MAAM,OAAO,GAAG;IACf,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,eAAe;IACvB,IAAI,EAAE,SAAS,EAAE,8BAA8B;IAC/C,IAAI,EAAE,SAAS,CAAC,8BAA8B;CAC9C,CAAC;AAGF,wHAAwH;AAExH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,KAAK,CAAC,EAErB,IAAI,EAEJ,IAAI,GAAG,KAAK,EACZ,IAAI,GAAG,KAAK,EAEZ,KAAK,GAAG,OAAO,EACf,KAAK,GAAG,OAAO,EACf,KAAK,EAEL,QAAQ,EAgDR;IAEA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAEjE,OAAO,aAAa,CAAC,YAAY,EAAE;QAElC,IAAI;QACJ,KAAK;QAEL,KAAK,EAAE;YACN,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YAC9B,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YACnC,cAAc,EAAE,OAAO,CAAC,KAAK,CAAC;YAC9B,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAClD,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACjD;KAED,EAAE,QAAQ,CAAC,CAAC;AAEd,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Headless tabs.
3
+ *
4
+ * Offers what a tab strip does without drawing one: a fixed set of labelled panels, which of them are open to a
5
+ * reader, the one on show, and the activation a reader performs on it. A rendering layer adopts them and supplies
6
+ * the markup, the styling and the gestures, so the same behaviour serves any layer.
7
+ *
8
+ * @module tabs.core
9
+ */
10
+ import { type Optional } from "@grafctory/core";
11
+ import { type Some } from "@grafctory/core/arrays";
12
+ /**
13
+ * Headless tabs.
14
+ *
15
+ * Holds a fixed set of labelled panels and the one on show, offering the activation a tab strip performs: a direct
16
+ * choice and the step to either neighbour, wrapping at both ends as keyboard navigation expects. A panel may be
17
+ * disabled: its label keeps its place, but no activation brings it on show and stepping passes it over.
18
+ *
19
+ * An activation yields new tabs and leaves these as they stand, so tabs read earlier keep their panels and their
20
+ * choice. One that changes nothing yields these tabs themselves, which a rendering layer takes as nothing to redraw.
21
+ */
22
+ export interface Tabs {
23
+ /**
24
+ * Whether each panel can be shown, keyed by its label: the labels in display order, unique and none of them blank.
25
+ */
26
+ readonly labels: Readonly<Record<string, boolean>>;
27
+ /**
28
+ * The label of the panel on show, or `undefined` if no panel is enabled.
29
+ */
30
+ readonly active: Optional<string>;
31
+ /**
32
+ * Activates a panel.
33
+ *
34
+ * @param label The label of the panel to show
35
+ *
36
+ * @returns Tabs showing `label`, or these tabs if `label` is unknown, disabled or already on show
37
+ */
38
+ select(label: string): this;
39
+ /**
40
+ * Activates the following enabled panel, stepping over disabled ones and wrapping from the last to the first.
41
+ *
42
+ * @returns Tabs showing the following enabled panel, or these tabs if they hold no other enabled panel
43
+ */
44
+ next(): this;
45
+ /**
46
+ * Activates the preceding enabled panel, stepping over disabled ones and wrapping from the first to the last.
47
+ *
48
+ * @returns Tabs showing the preceding enabled panel, or these tabs if they hold no other enabled panel
49
+ */
50
+ back(): this;
51
+ }
52
+ /**
53
+ * Creates headless tabs.
54
+ *
55
+ * @param options The tabs configuration
56
+ *
57
+ * @returns Immutable {@link Tabs} for `labels`, showing `active` where its panel is enabled, else the first enabled one
58
+ *
59
+ * @throws {@link !TypeError TypeError} If `labels` includes a blank label, or if `active` isn't one of them
60
+ */
61
+ export declare function createTabs({ labels, active }?: {
62
+ /**
63
+ * The labels identifying the panels, in display order: a record stating for each label whether its panel can be
64
+ * shown, or a list of labels whose panels can all be shown, taken as given with duplicates removed, keeping the
65
+ * first occurrence; empty if omitted.
66
+ */
67
+ labels?: Some<string> | Readonly<Record<string, boolean>>;
68
+ /**
69
+ * The label of the panel to show; the first enabled panel if omitted or if it identifies a disabled panel.
70
+ */
71
+ active?: string;
72
+ }): Tabs;
73
+ //# sourceMappingURL=tabs.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.core.d.ts","sourceRoot":"","sources":["../../src/layouts/tabs.core.ts"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AAEH,OAAO,EAAkC,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,KAAK,IAAI,EAAU,MAAM,wBAAwB,CAAC;AAI3D;;;;;;;;;GASG;AACH,MAAM,WAAW,IAAI;IAEpB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAGlC;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B;;;;OAIG;IACH,IAAI,IAAI,IAAI,CAAC;IAEb;;;;OAIG;IACH,IAAI,IAAI,IAAI,CAAC;CAEb;AAKD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,EAE1B,MAAM,EACN,MAAM,EAEN,GAAE;IAEF;;;;OAIG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAEzD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAEV,GAAG,IAAI,CAyDZ"}
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Copyright © 2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Headless tabs.
18
+ *
19
+ * Offers what a tab strip does without drawing one: a fixed set of labelled panels, which of them are open to a
20
+ * reader, the one on show, and the activation a reader performs on it. A rendering layer adopts them and supplies
21
+ * the markup, the styling and the gestures, so the same behaviour serves any layer.
22
+ *
23
+ * @module tabs.core
24
+ */
25
+ import { assert, isArray, isString, opt } from "@grafctory/core";
26
+ import { unique } from "@grafctory/core/arrays";
27
+ import { createState } from "@grafctory/core/state";
28
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
29
+ /**
30
+ * Creates headless tabs.
31
+ *
32
+ * @param options The tabs configuration
33
+ *
34
+ * @returns Immutable {@link Tabs} for `labels`, showing `active` where its panel is enabled, else the first enabled one
35
+ *
36
+ * @throws {@link !TypeError TypeError} If `labels` includes a blank label, or if `active` isn't one of them
37
+ */
38
+ export function createTabs({ labels, active } = {}) {
39
+ const entries = labels === undefined ? []
40
+ : isString(labels) ? [[labels, true]]
41
+ : isArray(labels) ? unique(labels).map((label) => [label, true])
42
+ : Object.entries(labels).map(([label, shown]) => [label, shown === true]);
43
+ const panels = assert(Object.fromEntries(entries), panels => Object.keys(panels).every(label => label.trim().length > 0), "unexpected blank panel labels");
44
+ const enabled = Object.keys(panels).filter(label => panels[label]);
45
+ const chosen = opt(active, label => assert(label, label => label in panels, `unknown panel label <${label}>`), enabled[0]);
46
+ const panel = enabled.includes(chosen) ? chosen : enabled[0];
47
+ return createState({
48
+ labels: panels,
49
+ active: panel,
50
+ select(label) {
51
+ return enabled.includes(label) ? { active: label } : {};
52
+ },
53
+ next() {
54
+ return { active: shift(this.active, +1) };
55
+ },
56
+ back() {
57
+ return { active: shift(this.active, -1) };
58
+ }
59
+ });
60
+ // stepping runs on the enabled panels alone, so a disabled one is passed over rather than landed on and left
61
+ function shift(active, offset) {
62
+ return opt(active, label => enabled[(enabled.indexOf(label) + offset + enabled.length) % enabled.length]);
63
+ }
64
+ }
65
+ //# sourceMappingURL=tabs.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.core.js","sourceRoot":"","sources":["../../src/layouts/tabs.core.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,260 @@
1
+ /*
2
+ * Copyright © 2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /* The strip is a row of tabs closed by a rule, with the section on show underneath. */
18
+
19
+ /* The look of tabs stating none, which an area assigns to all the tabs it holds; there is no loud step. */
20
+
21
+ @property --clay-tabs-look {
22
+ syntax: "subtle | normal";
23
+ inherits: true;
24
+ initial-value: normal;
25
+ }
26
+
27
+ clay-tabs {
28
+
29
+ display: block;
30
+
31
+ padding-bottom: var(--skin--spacing-250);
32
+
33
+ & > nav {
34
+
35
+ display: flex;
36
+
37
+ column-gap: var(--skin--spacing-100);
38
+
39
+ /* The strip stands on one line: a label is never broken, and a tab never moves to a line of its own. */
40
+
41
+ white-space: nowrap;
42
+ overflow-y: visible;
43
+
44
+ border-bottom-style: var(--skin--border-style);
45
+
46
+ & > label {
47
+
48
+ padding-bottom: calc(2 * var(--skin--spacing-010));
49
+ margin-bottom: calc(-1 * var(--skin--border-width)); /* The mark sits on the rule, not above it. */
50
+ cursor: pointer;
51
+
52
+ font-size: var(--skin--font-size-small);
53
+ font-weight: var(--skin--font-weight-strong);
54
+ color: var(--skin--color-label);
55
+
56
+ background-color: transparent; /* The reset hands down an opaque page, which would mask the rule. */
57
+
58
+ border-bottom-style: var(--skin--border-style);
59
+ border-bottom-color: transparent;
60
+
61
+ /*
62
+ * The mark and the label are eased rather than switched, so the eye follows the strip to whichever tab
63
+ * took over. The pace is the one a pointer change owes, and a reader who asked for less motion gets
64
+ * none of it, the duration collapsing to zero on its own with no rule of this sheet needed for it.
65
+ */
66
+
67
+ transition-property: color, border-bottom-color;
68
+ transition-duration: var(--skin--duration-fast);
69
+ transition-timing-function: var(--skin--easing-standard);
70
+
71
+ &:hover {
72
+ color: var(--skin--color-hover);
73
+ }
74
+
75
+ /* A tab that cannot be chosen is greyed, the pointer and `aria-disabled` saying so alongside the colour. */
76
+
77
+ &[aria-disabled="true"] {
78
+ color: var(--skin--color-disabled);
79
+ cursor: default;
80
+ }
81
+
82
+ /*
83
+ * A tab carries no box of its own, so the mark is drawn around the label, held clear of the word by the
84
+ * offset so the two are not read as one. The colour the strip marks its choice with is left to the rule
85
+ * below, which a focused tab never restates: the ring says where the keyboard stands, while the rule
86
+ * says which panel is on show, and the two never stand in for each other.
87
+ */
88
+
89
+ &:focus-visible {
90
+ outline: var(--skin--outline-focus);
91
+ outline-offset: var(--skin--border-width);
92
+ }
93
+
94
+ /* Heavier than the rule, to read as a highlight. Weight is left alone, since it would reflow the strip. */
95
+
96
+ &[aria-selected="true"] {
97
+ color: var(--skin--color);
98
+ border-bottom-width: calc(3 * var(--skin--border-width));
99
+ border-bottom-color: var(--skin--color-strong);
100
+ margin-bottom: calc(-3 * var(--skin--border-width));
101
+ }
102
+
103
+ }
104
+
105
+ }
106
+
107
+ /*
108
+ * Where the labels would not fit on one line, the strip gives way to the menu. It keeps its place in the
109
+ * document all the same, closed to nothing and taken off show, so what it holds leaves the accessibility tree
110
+ * and the tab order while the measurement deciding when the labels fit again still stands: the box is as wide
111
+ * as it ever was, which is all the measurement asks of it.
112
+ *
113
+ * It is closed rather than taken out of the flow, where it would become a positioned box painting over the header.
114
+ */
115
+
116
+ &[collapsed] > nav {
117
+ height: 0;
118
+ overflow: hidden;
119
+ visibility: hidden;
120
+ border-bottom-style: none; /* Closed to nothing means nothing, and a rule would hold the box a pixel open. */
121
+ }
122
+
123
+ /*
124
+ * The bar the menu stands in carries the rule the strip carried, across the whole width, so the section below is
125
+ * set off exactly as before. The bar is a flex line rather than a line of text, so nothing of the menu is left
126
+ * hanging over the rule by the descender an inline box reserves.
127
+ *
128
+ * The bar holds the gap down to the rule, wide enough for the ring the menu is marked with to fall short of it.
129
+ * The mark reads as belonging to the control rather than to the rule, which is what a reader expects of a boxed
130
+ * control, and the rule goes on saying only what it said before: where the section below begins.
131
+ */
132
+
133
+ & > span {
134
+
135
+ display: flex;
136
+
137
+ padding-bottom: var(--skin--spacing-050);
138
+
139
+ border-bottom-style: var(--skin--border-style);
140
+
141
+ /*
142
+ * The menu takes the width of its labels, so the ring left on it after a choice wraps the control rather
143
+ * than the whole bar. It gives that width up where the labels outrun the room, and the platform clips the rest.
144
+ */
145
+
146
+ & > select {
147
+
148
+ /*
149
+ * The menu is marked around the box its own label makes, the radius rounding the corners the ring is
150
+ * drawn around and the offset holding it clear of the word. The room the ring asks for is taken outside
151
+ * the box rather than as padding within it, so the box stays the width of the label: the menu goes on
152
+ * starting where the first tab of the strip started, and the section below lines up with both.
153
+ */
154
+
155
+ padding: 0;
156
+ border-style: none;
157
+ border-radius: var(--skin--border-radius-025);
158
+
159
+ cursor: pointer;
160
+
161
+ font-size: var(--skin--font-size-small);
162
+ font-weight: var(--skin--font-weight-strong);
163
+ color: var(--skin--color);
164
+
165
+ background-color: transparent; /* The page shows through, so the bar reads as the strip it stands in for. */
166
+
167
+ /*
168
+ * The mark stands wherever the platform calls the focus worth showing, which for a menu takes in a
169
+ * pointer choice: the arrow keys work it from there, so the mark is owed. A tab, which the same gesture
170
+ * leaves unmarked, takes no keys of its own until the strip is entered.
171
+ *
172
+ * What is owed is the ring the design system marks a control with, which follows the contour the radius
173
+ * above gives it, rounded corners included, and stops short of the rule below.
174
+ */
175
+
176
+ &:focus-visible {
177
+ outline: var(--skin--outline-focus);
178
+ outline-offset: var(--skin--spacing-025);
179
+ }
180
+
181
+ /*
182
+ * The list is drawn by the platform, on a surface of its own that the inherited page colours would not
183
+ * stand against. Each entry is handed the page colours outright, so it stays readable there.
184
+ */
185
+
186
+ & > option {
187
+
188
+ color: var(--skin--color);
189
+ background-color: var(--skin--background-color);
190
+
191
+ &:disabled {
192
+ color: var(--skin--color-disabled);
193
+ }
194
+
195
+ }
196
+
197
+ }
198
+
199
+ }
200
+
201
+ /*
202
+ * How loud the tabs appear is told in the rule closing them off, and never in colour. The quiet step keeps none,
203
+ * the labels reading as part of what surrounds them where the ordinary step sets the panel on show apart from
204
+ * them. The strip and the bar standing in for it drop the rule alike, so the two go on looking the same, and the
205
+ * mark the chosen tab wears stays either way: it states the choice, and is no part of the rule.
206
+ */
207
+
208
+ &[look="subtle"] {
209
+
210
+ & > nav,
211
+ & > span {
212
+ border-bottom-style: none;
213
+ }
214
+
215
+ }
216
+
217
+ & > div {
218
+
219
+ padding-top: var(--skin--spacing-150);
220
+
221
+ /*
222
+ * A panel takes no stop of its own, so it reaches the keyboard only where it is the box that scrolls and the
223
+ * browser hands it one on that account. It is a box either way, so the ring is drawn on its contour, the
224
+ * padding above setting it clear of the first line of whatever the panel holds.
225
+ */
226
+
227
+ &:focus-visible {
228
+ outline: var(--skin--outline-focus);
229
+ outline-offset: 0;
230
+ }
231
+
232
+ }
233
+
234
+ /*
235
+ * Tabs stating no look of their own take the one the area around them sets, read off the `--clay-tabs-look`
236
+ * knob through a style query: a rule has no other way to branch on a value, and the knob inherits, so every
237
+ * widget sits inside a container answering for it without a rule declaring one. The attribute has to be absent
238
+ * for the container to have a say, which is why the widget renders it only where the consumer asked for a look,
239
+ * and why the rules here hold themselves to tabs carrying none, leaving a stated look to the rules above.
240
+ *
241
+ * Only the quiet step is restated, the ordinary one being what the rules above already draw; an area assigning the
242
+ * loud one lands there too, there being no step above it here. The declarations are the ones the attribute rules carry,
243
+ * restated rather than shared: a style query is a conditional group and takes rules of its own, so the two forms
244
+ * of the same step cannot be written as one selector, nor as one rule nested under the other.
245
+ */
246
+
247
+ &:not([look]) {
248
+
249
+ @container style(--clay-tabs-look: subtle) {
250
+
251
+ & > nav,
252
+ & > span {
253
+ border-bottom-style: none;
254
+ }
255
+
256
+ }
257
+
258
+ }
259
+
260
+ }
@@ -0,0 +1,57 @@
1
+ import { type Optional } from "@grafctory/core";
2
+ import { type ComponentChildren } from "preact";
3
+ import "./tabs.css";
4
+ /**
5
+ * Creates a tabbed layout panel.
6
+ *
7
+ * Presents the labels of the panels given, in order, and the content of the one currently chosen, starting from the
8
+ * first one on offer. A panel is chosen with the pointer or with the keyboard, the arrow keys stepping to either
9
+ * neighbour and wrapping at both ends, `Home` and `End` jumping to either end of the strip.
10
+ *
11
+ * A panel given no content is disabled: its label keeps its place, marked as such, but no gesture ever brings it on
12
+ * show, a pointer choice on its label being refused and keyboard steps and jumps between the labels passing it by.
13
+ *
14
+ * Where the labels would not fit on one line, the strip gives way to a menu offering the same choice under the same
15
+ * rules, worked with the keys the platform gives a menu of its own: the labels keep their order, a disabled one stays
16
+ * out of reach, and the panel on show carries on unchanged, named as before but presented as a plain region rather
17
+ * than as a tab panel. The strip comes back as soon as the labels fit again, so which of the two a reader meets
18
+ * follows the room the widget is given rather than anything the caller states.
19
+ *
20
+ * Every panel on offer stays in the document while another is on show, so what it holds keeps its state throughout,
21
+ * at the cost of being rendered whether or not it is visible. The panels are taken as they stand when the widget first
22
+ * renders: a label added or removed later leaves the strip unchanged.
23
+ *
24
+ * @param options The widget configuration
25
+ *
26
+ * @returns The tabbed panel
27
+ *
28
+ * @throws {@link !TypeError TypeError} If `panels` includes a blank label
29
+ *
30
+ * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/tabs/ ARIA Authoring Practices: Tabs Pattern}
31
+ */
32
+ export declare function Tabs({ name, look, panels }: {
33
+ /**
34
+ * The accessible name of the tabs as a strip or as a menu, telling several on a screen apart; unnamed if omitted.
35
+ */
36
+ name?: string;
37
+ /**
38
+ * How loud the tabs appear, told in the rule closing them off rather than in colour, so the step still reads
39
+ * where colour does not: `normal` carries the rule, setting the panel on show apart from the strip or from the
40
+ * menu standing in for it, and `subtle` keeps none, the labels then reading as part of what surrounds them. The
41
+ * mark the chosen tab wears stays either way, so the choice is as plain under one step as under the other. No
42
+ * loud step is offered, a rule being as far as a strip goes.
43
+ *
44
+ * Tabs stating nothing take the look the {@link style!Style styled area} around them assigns as `tabsLook`, which
45
+ * is `normal` where nothing assigns it. A look stated here answers to that alone, so a strip asking for the rule
46
+ * keeps it inside a quietened panel, while every other strip in the panel recedes as the area asks.
47
+ */
48
+ look?: "subtle" | "normal";
49
+ /**
50
+ * The content of each panel, keyed by its label in display order; a label with no content marks a disabled panel.
51
+ */
52
+ panels: Readonly<Record<string, Optional<ComponentChildren>>>;
53
+ }): import("preact").VNode<{
54
+ collapsed: boolean;
55
+ look: "subtle" | "normal" | undefined;
56
+ }>;
57
+ //# sourceMappingURL=tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/layouts/tabs.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,QAAQ,CAAC;AAG/D,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,IAAI,CAAC,EAEpB,IAAI,EAEJ,IAAI,EAEJ,MAAM,EAEN,EAAE;IAEF;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAE1B;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAA;CAE7D;;;GA8JA"}