@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,50 @@
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
+ /*
18
+ * A form draws nothing of its own: it stands in the flow as the block its fields are laid out in.
19
+ */
20
+
21
+ clay-form {
22
+
23
+ display: block;
24
+
25
+ /*
26
+ * A growing form takes the room a column leaves, shared with whatever else the column holds. A container laying
27
+ * its content out as a page does shares no room, so a form standing alone in one fills its height instead, which
28
+ * the container makes definite where it is meant to be filled, as the main body of a tool does. The element and
29
+ * the native form inside it both lay the fields out as a column, so a growing field or stack takes the room next.
30
+ */
31
+
32
+ &[grow] {
33
+
34
+ display: flex;
35
+ flex-direction: column;
36
+ flex: auto;
37
+
38
+ &:only-child {
39
+ min-block-size: 100%;
40
+ }
41
+
42
+ & > form {
43
+ display: flex;
44
+ flex-direction: column;
45
+ flex: auto;
46
+ }
47
+
48
+ }
49
+
50
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Editing form.
3
+ *
4
+ * Gathers the fields a resource is read and edited through, telling the screen whether what was entered is valid as
5
+ * the reader types, and handing over the submission the `Enter` key asks for without letting the page navigate away.
6
+ *
7
+ * @module form
8
+ */
9
+ import { type ComponentChildren } from "preact";
10
+ import "./form.css";
11
+ /**
12
+ * Creates a form.
13
+ *
14
+ * Wraps its fields in a native form, so the constraints each field states (`required`, `pattern`, `min`, `max` and the
15
+ * like) are checked by the platform, and pressing `Enter` in a field submits the form even where it shows no submit
16
+ * button. The browser never navigates on submission: whatever the submission means is left to `onSubmit`.
17
+ *
18
+ * A submit button placed inside the form does not reach `onSubmit`: the action it stands for belongs to its own
19
+ * `onClick`, leaving `onSubmit` with the submissions asked for from the keyboard alone.
20
+ *
21
+ * The form stands as tall as its fields unless told to grow. A growing form takes the room its container leaves and
22
+ * lays its fields out as a column, so a {@link stack!Stack Stack}, a {@link textarea!Textarea Textarea} or a
23
+ * {@link label!Label Label} told to grow inside it takes that room in turn: a single long text then fills the body of
24
+ * a screen, and runs on past it, lengthening the form rather than scrolling inside it.
25
+ *
26
+ * @param options The widget configuration
27
+ *
28
+ * @returns The form
29
+ *
30
+ * @see [MDN: Client-side form validation][validation]
31
+ *
32
+ * [validation]: https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation
33
+ */
34
+ export declare function Form({ grow, onSubmit, onValidate, children }: {
35
+ /**
36
+ * Whether the form takes the room its container leaves; sized to its fields if omitted. In a column, such as a
37
+ * {@link stack!Stack Stack} or the side column of a {@link tool!Tool Tool}, the form shares that room with the
38
+ * other items of the column. In a container laying its content out as a page, such as the main column of a `Tool`,
39
+ * the form fills the room only when it stands alone, with no heading or note beside it in the same container.
40
+ */
41
+ grow?: boolean;
42
+ /**
43
+ * What a submission asked for by pressing `Enter` in a field is handed to; submissions are ignored if omitted.
44
+ * Not called where a field fails its constraints, the platform reporting the failure to the reader instead.
45
+ */
46
+ onSubmit?: () => void;
47
+ /**
48
+ * What the validity of the form is handed to whenever the reader changes a field, as true where every field
49
+ * meets its constraints and false otherwise; validity goes untracked if omitted.
50
+ *
51
+ * A value set by a script signals nothing on its own, so a composite field setting values that way dispatches a
52
+ * bubbling `input` event from its own element to have the form checked against the new value.
53
+ *
54
+ * @param valid Whether every field in the form meets its constraints
55
+ */
56
+ onValidate?: (valid: boolean) => void;
57
+ /**
58
+ * The fields of the form.
59
+ */
60
+ children?: ComponentChildren;
61
+ }): import("preact").VNode<{
62
+ grow: boolean;
63
+ }>;
64
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/controls/form.tsx"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,QAAQ,CAAC;AAC/D,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,IAAI,CAAC,EAEpB,IAAY,EAEZ,QAAQ,EACR,UAAU,EAEV,QAAQ,EAER,EAAE;IAEF;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAGd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IAErB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAGrC;;OAEG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAE5B;;GA6BA"}
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ /*
3
+ * Copyright © 2026 Metreeca srl
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Editing form.
19
+ *
20
+ * Gathers the fields a resource is read and edited through, telling the screen whether what was entered is valid as
21
+ * the reader types, and handing over the submission the `Enter` key asks for without letting the page navigate away.
22
+ *
23
+ * @module form
24
+ */
25
+ import { createElement } from "preact";
26
+ import "./form.css";
27
+ /**
28
+ * Creates a form.
29
+ *
30
+ * Wraps its fields in a native form, so the constraints each field states (`required`, `pattern`, `min`, `max` and the
31
+ * like) are checked by the platform, and pressing `Enter` in a field submits the form even where it shows no submit
32
+ * button. The browser never navigates on submission: whatever the submission means is left to `onSubmit`.
33
+ *
34
+ * A submit button placed inside the form does not reach `onSubmit`: the action it stands for belongs to its own
35
+ * `onClick`, leaving `onSubmit` with the submissions asked for from the keyboard alone.
36
+ *
37
+ * The form stands as tall as its fields unless told to grow. A growing form takes the room its container leaves and
38
+ * lays its fields out as a column, so a {@link stack!Stack Stack}, a {@link textarea!Textarea Textarea} or a
39
+ * {@link label!Label Label} told to grow inside it takes that room in turn: a single long text then fills the body of
40
+ * a screen, and runs on past it, lengthening the form rather than scrolling inside it.
41
+ *
42
+ * @param options The widget configuration
43
+ *
44
+ * @returns The form
45
+ *
46
+ * @see [MDN: Client-side form validation][validation]
47
+ *
48
+ * [validation]: https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation
49
+ */
50
+ export function Form({ grow = false, onSubmit, onValidate, children }) {
51
+ /*
52
+ * The hidden submit input gives the form a default button, which pressing `Enter` in a field submits through even
53
+ * where the form holds several fields and shows the reader no submit button of its own.
54
+ */
55
+ return createElement("clay-form", { grow }, _jsxs("form", { onInput: event => onValidate?.(event.currentTarget.checkValidity()), onSubmit: event => {
56
+ event.preventDefault();
57
+ if (!(event.submitter instanceof HTMLButtonElement)) {
58
+ onSubmit?.();
59
+ }
60
+ }, children: [_jsx("input", { type: "submit", hidden: true }), children] }));
61
+ }
62
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/controls/form.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAA0B,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,IAAI,CAAC,EAEpB,IAAI,GAAG,KAAK,EAEZ,QAAQ,EACR,UAAU,EAEV,QAAQ,EAoCR;IAEA;;;OAGG;IAEH,OAAO,aAAa,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,gBAE3C,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,EAEnE,QAAQ,EAAE,KAAK,CAAC,EAAE;YAEjB,KAAK,CAAC,cAAc,EAAE,CAAC;YAEvB,IAAK,CAAC,CAAC,KAAK,CAAC,SAAS,YAAY,iBAAiB,CAAC,EAAG,CAAC;gBACvD,QAAQ,EAAE,EAAE,CAAC;YACd,CAAC;QAEF,CAAC,aAID,gBAAO,IAAI,EAAC,QAAQ,EAAC,MAAM,SAAE,EAE5B,QAAQ,IAEH,CAAC,CAAC;AAEV,CAAC"}
@@ -0,0 +1,57 @@
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
+ /* A field is drawn as the design system draws every native field, standing wherever the layout places it. */
18
+
19
+ clay-input {
20
+
21
+ display: contents;
22
+
23
+ /* A field sized in characters never stands wider than the column holding it, shrinking on a narrow viewport. */
24
+
25
+ & > input {
26
+ max-inline-size: 100%;
27
+ }
28
+
29
+ /*
30
+ * A growing field, or one wrapped by a growing label, spans the column holding it, whatever width its characters
31
+ * ask for. In a row, a strip or a horizontal label beside its text, it takes the room the row leaves instead.
32
+ */
33
+
34
+ &[grow] > input, clay-label[grow] > label > & > input {
35
+ align-self: stretch;
36
+ }
37
+
38
+ clay-strip > &[grow] > input,
39
+ clay-label[orientation="horizontal"] > label > &[grow] > input,
40
+ clay-label[grow][orientation="horizontal"] > label > & > input {
41
+ flex: auto;
42
+ align-self: auto;
43
+ }
44
+
45
+ /*
46
+ * An empty date or time field shows the pattern of its value where a text field shows its placeholder, so the
47
+ * pattern takes the placeholder colour, telling a field still to be filled from one holding a value. The field
48
+ * holding the keyboard takes the text colour back, since the parts the reader types land in the pattern itself.
49
+ *
50
+ * The types listed are kept in sync with the date and time types the `type` prop of the widget accepts.
51
+ */
52
+
53
+ &[empty] > input:is([type=date], [type=time], [type=datetime-local], [type=month], [type=week]):not(:focus) {
54
+ color: var(--skin--color-placeholder);
55
+ }
56
+
57
+ }
@@ -0,0 +1,129 @@
1
+ import "./input.css";
2
+ /**
3
+ * Creates a single-line field.
4
+ *
5
+ * Takes its value on a native input, so the editing keys, the on-screen keyboard suited to `type`, the date and time
6
+ * pickers, and the checking of every constraint come from the platform. A field failing a constraint is marked once
7
+ * the reader has had a say on it, and stops the {@link form!Form Form} around it from being submitted.
8
+ *
9
+ * The value is either held by the caller, which shows `value` and is handed each edit through `onChange`, or left to
10
+ * the field where `value` is omitted, the field then keeping whatever the reader types.
11
+ *
12
+ * @param options The widget configuration
13
+ *
14
+ * @returns The field
15
+ *
16
+ * @see [HTML: The input element][input]
17
+ *
18
+ * [input]: https://html.spec.whatwg.org/multipage/input.html#the-input-element
19
+ */
20
+ export declare function Input({ name, id, description, disabled, grow, readonly, required, type, autocomplete, min, max, step, minLength, maxLength, pattern, error, size, placeholder, value, onChange }: {
21
+ /**
22
+ * The accessible name, required where no {@link label!Label Label} names the field.
23
+ */
24
+ name?: string;
25
+ /**
26
+ * The id a split {@link label!Label Label} names the field by; no id if omitted.
27
+ */
28
+ id?: string;
29
+ /**
30
+ * The id of the element describing the field, such as a hint on the value expected, which assistive technology
31
+ * reads out along with the accessible name whenever the field takes focus; none if omitted. The id has to resolve
32
+ * to a rendered element, or the field is described by nothing at all and the hint reaches sighted readers only.
33
+ */
34
+ description?: string;
35
+ /**
36
+ * Whether the field takes no input, greyed and out of the tab order; editable if omitted.
37
+ */
38
+ disabled?: boolean;
39
+ /**
40
+ * Whether the field spans the column holding it, or the room left on its line in a {@link strip!Strip Strip};
41
+ * sized to `size` characters if omitted. A growing field of any type takes that whole room, so a long value such as
42
+ * an address stays in view. A field wrapped in a {@link label!Label Label} is bounded by the room the label takes
43
+ * instead, so spanning the column, or the room beside the label text, takes a label told to grow.
44
+ */
45
+ grow?: boolean;
46
+ /**
47
+ * Whether the field shows its value without taking edits, while staying in the tab order; editable if omitted.
48
+ */
49
+ readonly?: boolean;
50
+ /**
51
+ * Whether the field fails its constraints while empty; optional if omitted.
52
+ */
53
+ required?: boolean;
54
+ /**
55
+ * The kind of value the field takes, deciding the constraints checked on it and the keyboard or picker offered to
56
+ * type it with; `text` if omitted. Whatever the kind, the value is handed over as the text the field holds, as
57
+ * the platform writes it in every locale: a `date` as `YYYY-MM-DD`, a `time` as `hh:mm`, a `datetime-local` as
58
+ * `YYYY-MM-DDThh:mm`, a `month` as `YYYY-MM` and a `week` as `YYYY-Www`, with the week number in two digits.
59
+ */
60
+ type?: "text" | "email" | "url" | "tel" | "password" | "number" | "date" | "time" | "datetime-local" | "month" | "week";
61
+ /**
62
+ * The purpose of the value, as one of the [autofill names][autofill] the platform defines, such as `email` or
63
+ * `shipping street-address`; none if omitted. The browser offers the data it keeps for that purpose, and assistive
64
+ * technology states what the field asks for. WCAG SC 1.3.5 requires one on any field asking readers about
65
+ * themselves, so that a reader is spared typing what the browser already knows.
66
+ *
67
+ * [autofill]: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field
68
+ */
69
+ autocomplete?: string;
70
+ /**
71
+ * The least value a `number` field or a date or time field accepts, written as its values are; none if omitted.
72
+ */
73
+ min?: string;
74
+ /**
75
+ * The greatest value a `number` field or a date or time field accepts, written as its values are; none if omitted.
76
+ */
77
+ max?: string;
78
+ /**
79
+ * The granularity of the values a `number` field or a date or time field accepts, such as `0.01` for a price or
80
+ * `60` seconds for a time stated to the minute; the platform default for the type if omitted.
81
+ */
82
+ step?: string;
83
+ /**
84
+ * The least number of characters a non-empty value holds; no floor if omitted.
85
+ */
86
+ minLength?: number;
87
+ /**
88
+ * The greatest number of characters the field takes, typing past it being refused; no ceiling if omitted.
89
+ */
90
+ maxLength?: number;
91
+ /**
92
+ * The regular expression the whole value has to match, read as the platform reads it; any value if omitted.
93
+ */
94
+ pattern?: string;
95
+ /**
96
+ * The message reported while the field fails its constraints, stating the rule a valid value follows, such as
97
+ * `Enter an address at a partner university` for an address restricted by `pattern`; the platform message if
98
+ * omitted. It takes the place of the platform message wherever the platform shows one, and never changes whether
99
+ * the field or the {@link form!Form Form} around it is valid, which the constraints alone decide.
100
+ */
101
+ error?: string;
102
+ /**
103
+ * The width the field stands at, in characters, never wider than the column holding it; a `number` field or a
104
+ * date or time field ignores it, as does a growing field. The platform width, about 20 characters, if omitted.
105
+ */
106
+ size?: number;
107
+ /**
108
+ * The hint shown in the field while it is empty, such as an example of the value expected. It disappears as soon
109
+ * as the reader types, so it never stands in for a {@link label!Label Label}; no hint if omitted.
110
+ *
111
+ * A date or time field shows no hint: the platform fills it with the pattern of the value instead, such as
112
+ * `dd/mm/yyyy`, in the order and with the separators of the locale of the reader.
113
+ */
114
+ placeholder?: string;
115
+ /**
116
+ * The value shown in the field, held by the caller; left to the field if omitted.
117
+ */
118
+ value?: string;
119
+ /**
120
+ * Receives the value of the field on every edit, as the reader types it.
121
+ *
122
+ * @param value The value the field now holds
123
+ */
124
+ onChange?: (value: string) => void;
125
+ }): import("preact").VNode<{
126
+ empty: boolean;
127
+ grow: boolean;
128
+ }>;
129
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/controls/input.tsx"],"names":[],"mappings":"AA4BA,OAAO,aAAa,CAAC;AAGrB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,EAErB,IAAI,EACJ,EAAE,EACF,WAAW,EAEX,QAAQ,EACR,IAAY,EACZ,QAAQ,EACR,QAAQ,EAER,IAAa,EACb,YAAY,EAEZ,GAAG,EACH,GAAG,EACH,IAAI,EACJ,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EAEL,IAAI,EAEJ,WAAW,EACX,KAAK,EAEL,QAAQ,EAER,EAAE;IAEF;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IAEX;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;;OAKG;IAEH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,GAC5D,MAAM,GAAG,MAAM,GAAG,gBAAgB,GAAG,OAAO,GAAG,MAAM,CAAA;IAExD;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAElC;;;GA4DA"}
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx } from "preact/jsx-runtime";
2
+ /*
3
+ * Copyright © 2026 Metreeca srl
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Single-line field.
19
+ *
20
+ * Takes a value typed on one line, such as a title, an address, a number or a date, checked against the constraints
21
+ * the field states as the reader types it, so a mistake is caught before the form is submitted.
22
+ *
23
+ * @module input
24
+ */
25
+ import { createElement } from "preact";
26
+ import { useLayoutEffect, useRef, useState } from "preact/hooks";
27
+ import { report } from "../index.core.js";
28
+ import "./input.css";
29
+ /**
30
+ * Creates a single-line field.
31
+ *
32
+ * Takes its value on a native input, so the editing keys, the on-screen keyboard suited to `type`, the date and time
33
+ * pickers, and the checking of every constraint come from the platform. A field failing a constraint is marked once
34
+ * the reader has had a say on it, and stops the {@link form!Form Form} around it from being submitted.
35
+ *
36
+ * The value is either held by the caller, which shows `value` and is handed each edit through `onChange`, or left to
37
+ * the field where `value` is omitted, the field then keeping whatever the reader types.
38
+ *
39
+ * @param options The widget configuration
40
+ *
41
+ * @returns The field
42
+ *
43
+ * @see [HTML: The input element][input]
44
+ *
45
+ * [input]: https://html.spec.whatwg.org/multipage/input.html#the-input-element
46
+ */
47
+ export function Input({ name, id, description, disabled, grow = false, readonly, required, type = "text", autocomplete, min, max, step, minLength, maxLength, pattern, error, size, placeholder, value, onChange }) {
48
+ /*
49
+ * The element tells a stylesheet whether the field holds a value, which a date or time field offers no selector
50
+ * for, having no placeholder. A value held by the caller settles it; otherwise the last edit of the reader does.
51
+ */
52
+ const [typed, setTyped] = useState("");
53
+ const empty = (value ?? typed) === "";
54
+ /*
55
+ * The platform takes a custom message only through setCustomValidity, with no attribute standing for it, so the
56
+ * message is set on the element after every render, catching a value or an error changed by the caller, and on
57
+ * every edit, before the form around the field reads its validity and hands it over to its own validation handler.
58
+ */
59
+ const field = useRef(null);
60
+ useLayoutEffect(() => {
61
+ if (field.current) {
62
+ report(field.current, error);
63
+ }
64
+ });
65
+ return createElement("clay-input", { empty, grow }, _jsx("input", { ref: field, id: id, disabled: disabled, readOnly: readonly, required: required, "aria-label": name, "aria-describedby": description, type: type, autocomplete: autocomplete, min: min, max: max, step: step, minLength: minLength, maxLength: maxLength, pattern: pattern, size: size, placeholder: placeholder, value: value, onInput: event => {
66
+ report(event.currentTarget, error);
67
+ setTyped(event.currentTarget.value);
68
+ onChange?.(event.currentTarget.value);
69
+ } }));
70
+ }
71
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/controls/input.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,aAAa,CAAC;AAGrB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,KAAK,CAAC,EAErB,IAAI,EACJ,EAAE,EACF,WAAW,EAEX,QAAQ,EACR,IAAI,GAAG,KAAK,EACZ,QAAQ,EACR,QAAQ,EAER,IAAI,GAAG,MAAM,EACb,YAAY,EAEZ,GAAG,EACH,GAAG,EACH,IAAI,EACJ,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EAEL,IAAI,EAEJ,WAAW,EACX,KAAK,EAEL,QAAQ,EAkIR;IAEA;;;OAGG;IAEH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEvC,MAAM,KAAK,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IAEtC;;;;OAIG;IAEH,MAAM,KAAK,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAE7C,eAAe,CAAC,GAAG,EAAE;QACpB,IAAK,KAAK,CAAC,OAAO,EAAG,CAAC;YACrB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,gBAEnD,GAAG,EAAE,KAAK,EAEV,EAAE,EAAE,EAAE,EAEN,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,gBAEN,IAAI,sBACE,WAAW,EAC7B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAE1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAEhB,IAAI,EAAE,IAAI,EAEV,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EAEZ,OAAO,EAAE,KAAK,CAAC,EAAE;YAChB,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;YACnC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACpC,QAAQ,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC,GAEA,CAAC,CAAC;AAEL,CAAC"}
@@ -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
+ /* A label is the native one, standing wherever the layout around it places it with no box of its own. */
18
+
19
+ clay-label {
20
+
21
+ display: contents;
22
+
23
+ /*
24
+ * The colour, the weight, the size and the gap of a label are the design system's, which lays a label out by the
25
+ * control it wraps: a field below its text, a box beside it. The orientation the widget states takes the place of
26
+ * that guess, so a label stands as told whatever it wraps, and names a control standing apart at the size told.
27
+ */
28
+
29
+ &[orientation="vertical"] > label {
30
+ flex-direction: column;
31
+ align-items: start;
32
+ font-size: var(--skin--font-size-small);
33
+ }
34
+
35
+ &[orientation="horizontal"] > label {
36
+ flex-direction: row;
37
+ align-items: center;
38
+ font-size: inherit;
39
+ }
40
+
41
+ /*
42
+ * A growing label spans the column holding it, a vertical one also taking the height the column leaves; in a
43
+ * strip, it takes the room left on its line instead. The field it wraps is stretched to fill that room in turn.
44
+ */
45
+
46
+ &[grow] > label {
47
+ display: flex;
48
+ align-self: stretch;
49
+ }
50
+
51
+ &[grow][orientation="vertical"] > label {
52
+ flex: 1 0 auto;
53
+ }
54
+
55
+ clay-strip > &[grow] > label {
56
+ flex: auto;
57
+ align-self: auto;
58
+ }
59
+
60
+ /*
61
+ * A label naming a control the reader has to fill in is marked by an asterisk after its text from the moment the
62
+ * form is shown, so the reader knows what to fill in before trying to submit. The mark is silent to assistive
63
+ * technology, which already announces the requirement the control states. A radio button is left unmarked, the
64
+ * caption of the group it belongs to being marked instead, so a single pick is never marked once per button. The
65
+ * mark takes the colour of a failure, the one a field still empty will be marked in when the reader submits it.
66
+ */
67
+
68
+ &:is([required], :has(> label :required:enabled:not([type="radio"]))) > label > span:first-of-type::after {
69
+ content: " *" / "";
70
+ color: var(--skin--color-fail);
71
+ }
72
+
73
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Field label.
3
+ *
4
+ * Names a form control, so assistive technology announces the control by the text the reader sees beside it, and a
5
+ * press on that text reaches the control as a press on the control itself would.
6
+ *
7
+ * @module label
8
+ */
9
+ import { type ComponentChildren, type VNode } from "preact";
10
+ import "./label.css";
11
+ /**
12
+ * Creates a label.
13
+ *
14
+ * Names its control in either of two ways, the placement of the text and the control being left to the caller:
15
+ *
16
+ * - **wrapped**: the control is given among the children, with the text before or after it, and is named without
17
+ * any id, as in `<Label>Title <Input/></Label>` or `<Label><Checkbox/> Remember me</Label>`
18
+ * - **split**: the label stands apart from its control, such as in another column of a grid, and names it by the id
19
+ * given as `control`, which the control carries as its own `id` wherever on the screen it stands
20
+ *
21
+ * A label naming a control the reader has to fill in shows an asterisk after its text from the start, so the reader
22
+ * knows what to fill in before submitting. A wrapped control marks its label through its own `required` state while
23
+ * it takes input; a split label is marked through `required`. Assistive technology skips the asterisk and announces
24
+ * the requirement from the control itself. A radio button is never marked: the caption of the
25
+ * {@link fieldset!Fieldset Fieldset} grouping it is marked instead, so a single pick is marked once. The screen
26
+ * states what the asterisk stands for, for instance in a note opening the form, before the reader reaches any field.
27
+ *
28
+ * A label stands at the size of its text and control unless told to `grow`, whatever the field it wraps: a growing
29
+ * field never stretches the label around it, while a growing label stretches the {@link input!Input Input},
30
+ * {@link textarea!Textarea Textarea} or {@link select!Select Select} it wraps to fill the room it takes.
31
+ *
32
+ * @param options The widget configuration
33
+ *
34
+ * @returns The label
35
+ *
36
+ * @see [HTML: The label element][label]
37
+ *
38
+ * [label]: https://html.spec.whatwg.org/multipage/forms.html#the-label-element
39
+ */
40
+ export declare function Label({ orientation, grow, control, required, children }: {
41
+ /**
42
+ * How a wrapped control and its text are arranged: `vertical`, the default, stacks them one over the other, each
43
+ * aligned to the start, as a field stands under the text naming it; `horizontal` sets them side by side on one
44
+ * line, centred on each other, as a checkbox, a radio button or a switch stands beside the text naming it.
45
+ */
46
+ orientation?: "vertical" | "horizontal";
47
+ /**
48
+ * Whether the label spans the column holding it, a vertical label also taking the height the column leaves, or
49
+ * takes the room left on its line in a {@link strip!Strip Strip}; sized to its text and control if omitted. The
50
+ * field wrapped by a growing label fills that room, below the text or beside it, whether told to `grow` or not.
51
+ */
52
+ grow?: boolean;
53
+ /**
54
+ * The id of the control the label names where the label stands apart from it; the control wrapped among the
55
+ * children if omitted. The id has to resolve to a rendered control, or the label names nothing at all.
56
+ */
57
+ control?: string;
58
+ /**
59
+ * Whether the control named by `control` must be filled in, marking the label with an asterisk; unmarked if
60
+ * omitted. The setting marks the label only: the control still states the requirement through its own `required`,
61
+ * which the platform checks on submission and assistive technology announces on reaching the control.
62
+ */
63
+ required?: boolean;
64
+ /**
65
+ * The text naming the control, and the control itself where the label wraps it.
66
+ *
67
+ * Plain text may be given as it stands, but text mixing in markup, such as a link to the terms being accepted,
68
+ * goes inside a single `span`: each run of text and each element is otherwise laid out as a part of its own.
69
+ */
70
+ children?: ComponentChildren;
71
+ }): VNode<{
72
+ orientation: "vertical" | "horizontal";
73
+ grow: boolean;
74
+ required: boolean | undefined;
75
+ }>;
76
+ //# sourceMappingURL=label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../src/controls/label.tsx"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,iBAAiB,EAA+B,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AACzF,OAAO,aAAa,CAAC;AAGrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,KAAK,CAAC,EAErB,WAAwB,EACxB,IAAY,EAEZ,OAAO,EACP,QAAQ,EAER,QAAQ,EAER,EAAE;IAEF;;;;OAIG;IACH,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAA;IAEvC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAE5B;;;;GAIA"}