@grafctory/clay-widgets 0.0.0-stage → 0.4.1
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.
- package/LICENSE +201 -0
- package/README.md +46 -2
- package/dist/content/empty.css +107 -0
- package/dist/content/empty.d.ts +40 -0
- package/dist/content/empty.d.ts.map +1 -0
- package/dist/content/empty.js +42 -0
- package/dist/content/empty.js.map +1 -0
- package/dist/content/heading.css +34 -0
- package/dist/content/heading.d.ts +45 -0
- package/dist/content/heading.d.ts.map +1 -0
- package/dist/content/heading.js +49 -0
- package/dist/content/heading.js.map +1 -0
- package/dist/content/image.css +176 -0
- package/dist/content/image.d.ts +71 -0
- package/dist/content/image.d.ts.map +1 -0
- package/dist/content/image.js +63 -0
- package/dist/content/image.js.map +1 -0
- package/dist/content/infobox.css +186 -0
- package/dist/content/infobox.d.ts +72 -0
- package/dist/content/infobox.d.ts.map +1 -0
- package/dist/content/infobox.js +63 -0
- package/dist/content/infobox.js.map +1 -0
- package/dist/content/pill.css +76 -0
- package/dist/content/pill.d.ts +57 -0
- package/dist/content/pill.d.ts.map +1 -0
- package/dist/content/pill.js +48 -0
- package/dist/content/pill.js.map +1 -0
- package/dist/content/text.css +44 -0
- package/dist/content/text.d.ts +30 -0
- package/dist/content/text.d.ts.map +1 -0
- package/dist/content/text.js +42 -0
- package/dist/content/text.js.map +1 -0
- package/dist/controls/button.css +469 -0
- package/dist/controls/button.d.ts +116 -0
- package/dist/controls/button.d.ts.map +1 -0
- package/dist/controls/button.js +61 -0
- package/dist/controls/button.js.map +1 -0
- package/dist/controls/checkbox.css +23 -0
- package/dist/controls/checkbox.d.ts +54 -0
- package/dist/controls/checkbox.d.ts.map +1 -0
- package/dist/controls/checkbox.js +49 -0
- package/dist/controls/checkbox.js.map +1 -0
- package/dist/controls/choice.css +288 -0
- package/dist/controls/choice.d.ts +63 -0
- package/dist/controls/choice.d.ts.map +1 -0
- package/dist/controls/choice.js +52 -0
- package/dist/controls/choice.js.map +1 -0
- package/dist/controls/fieldset.css +37 -0
- package/dist/controls/fieldset.d.ts +49 -0
- package/dist/controls/fieldset.d.ts.map +1 -0
- package/dist/controls/fieldset.js +51 -0
- package/dist/controls/fieldset.js.map +1 -0
- package/dist/controls/form.css +50 -0
- package/dist/controls/form.d.ts +64 -0
- package/dist/controls/form.d.ts.map +1 -0
- package/dist/controls/form.js +62 -0
- package/dist/controls/form.js.map +1 -0
- package/dist/controls/input.css +57 -0
- package/dist/controls/input.d.ts +120 -0
- package/dist/controls/input.d.ts.map +1 -0
- package/dist/controls/input.js +78 -0
- package/dist/controls/input.js.map +1 -0
- package/dist/controls/label.css +73 -0
- package/dist/controls/label.d.ts +76 -0
- package/dist/controls/label.d.ts.map +1 -0
- package/dist/controls/label.js +73 -0
- package/dist/controls/label.js.map +1 -0
- package/dist/controls/radio.css +23 -0
- package/dist/controls/radio.d.ts +60 -0
- package/dist/controls/radio.d.ts.map +1 -0
- package/dist/controls/radio.js +50 -0
- package/dist/controls/radio.js.map +1 -0
- package/dist/controls/select.css +37 -0
- package/dist/controls/select.d.ts +62 -0
- package/dist/controls/select.d.ts.map +1 -0
- package/dist/controls/select.js +59 -0
- package/dist/controls/select.js.map +1 -0
- package/dist/controls/switch.css +154 -0
- package/dist/controls/switch.d.ts +44 -0
- package/dist/controls/switch.d.ts.map +1 -0
- package/dist/controls/switch.js +48 -0
- package/dist/controls/switch.js.map +1 -0
- package/dist/controls/textarea.css +50 -0
- package/dist/controls/textarea.d.ts +97 -0
- package/dist/controls/textarea.d.ts.map +1 -0
- package/dist/controls/textarea.js +75 -0
- package/dist/controls/textarea.js.map +1 -0
- package/dist/glyphs/icon.core.d.ts +52 -0
- package/dist/glyphs/icon.core.d.ts.map +1 -0
- package/dist/glyphs/icon.core.js +67 -0
- package/dist/glyphs/icon.core.js.map +1 -0
- package/dist/glyphs/icon.css +32 -0
- package/dist/glyphs/icon.d.ts +152 -0
- package/dist/glyphs/icon.d.ts.map +1 -0
- package/dist/glyphs/icon.js +167 -0
- package/dist/glyphs/icon.js.map +1 -0
- package/dist/glyphs/icon.md +76 -0
- package/dist/glyphs/logo.css +73 -0
- package/dist/glyphs/logo.d.ts +27 -0
- package/dist/glyphs/logo.d.ts.map +1 -0
- package/dist/glyphs/logo.js +49 -0
- package/dist/glyphs/logo.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/card.css +166 -0
- package/dist/layouts/card.d.ts +69 -0
- package/dist/layouts/card.d.ts.map +1 -0
- package/dist/layouts/card.js +57 -0
- package/dist/layouts/card.js.map +1 -0
- package/dist/layouts/stack.css +58 -0
- package/dist/layouts/stack.d.ts +64 -0
- package/dist/layouts/stack.d.ts.map +1 -0
- package/dist/layouts/stack.js +69 -0
- package/dist/layouts/stack.js.map +1 -0
- package/dist/layouts/strip.css +58 -0
- package/dist/layouts/strip.d.ts +72 -0
- package/dist/layouts/strip.d.ts.map +1 -0
- package/dist/layouts/strip.js +73 -0
- package/dist/layouts/strip.js.map +1 -0
- package/dist/layouts/tabs.core.d.ts +73 -0
- package/dist/layouts/tabs.core.d.ts.map +1 -0
- package/dist/layouts/tabs.core.js +65 -0
- package/dist/layouts/tabs.core.js.map +1 -0
- package/dist/layouts/tabs.css +260 -0
- package/dist/layouts/tabs.d.ts +57 -0
- package/dist/layouts/tabs.d.ts.map +1 -0
- package/dist/layouts/tabs.js +128 -0
- package/dist/layouts/tabs.js.map +1 -0
- package/dist/layouts/tree.css +138 -0
- package/dist/layouts/tree.d.ts +46 -0
- package/dist/layouts/tree.d.ts.map +1 -0
- package/dist/layouts/tree.js +69 -0
- package/dist/layouts/tree.js.map +1 -0
- package/dist/navigation/link.css +229 -0
- package/dist/navigation/link.d.ts +89 -0
- package/dist/navigation/link.d.ts.map +1 -0
- package/dist/navigation/link.js +91 -0
- package/dist/navigation/link.js.map +1 -0
- package/dist/navigation/path.css +122 -0
- package/dist/navigation/path.d.ts +42 -0
- package/dist/navigation/path.d.ts.map +1 -0
- package/dist/navigation/path.js +49 -0
- package/dist/navigation/path.js.map +1 -0
- package/dist/navigation/toc.core.d.ts +111 -0
- package/dist/navigation/toc.core.d.ts.map +1 -0
- package/dist/navigation/toc.core.js +60 -0
- package/dist/navigation/toc.core.js.map +1 -0
- package/dist/navigation/toc.css +53 -0
- package/dist/navigation/toc.d.ts +112 -0
- package/dist/navigation/toc.d.ts.map +1 -0
- package/dist/navigation/toc.js +321 -0
- package/dist/navigation/toc.js.map +1 -0
- package/dist/scopes/guard.css +26 -0
- package/dist/scopes/guard.d.ts +37 -0
- package/dist/scopes/guard.d.ts.map +1 -0
- package/dist/scopes/guard.js +60 -0
- package/dist/scopes/guard.js.map +1 -0
- package/dist/scopes/style.css +26 -0
- package/dist/scopes/style.d.ts +68 -0
- package/dist/scopes/style.d.ts.map +1 -0
- package/dist/scopes/style.js +108 -0
- package/dist/scopes/style.js.map +1 -0
- package/dist/shells/tool.css +778 -0
- package/dist/shells/tool.d.ts +164 -0
- package/dist/shells/tool.d.ts.map +1 -0
- package/dist/shells/tool.js +251 -0
- package/dist/shells/tool.js.map +1 -0
- package/dist/signals/more.css +42 -0
- package/dist/signals/more.d.ts +28 -0
- package/dist/signals/more.d.ts.map +1 -0
- package/dist/signals/more.js +61 -0
- package/dist/signals/more.js.map +1 -0
- package/dist/signals/note.css +221 -0
- package/dist/signals/note.d.ts +83 -0
- package/dist/signals/note.d.ts.map +1 -0
- package/dist/signals/note.js +72 -0
- package/dist/signals/note.js.map +1 -0
- package/dist/signals/toasts.css +463 -0
- package/dist/signals/toasts.d.ts +68 -0
- package/dist/signals/toasts.d.ts.map +1 -0
- package/dist/signals/toasts.js +160 -0
- package/dist/signals/toasts.js.map +1 -0
- package/package.json +331 -4
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import "./checkbox.css";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a checkbox.
|
|
4
|
+
*
|
|
5
|
+
* Takes its answer on a native checkbox, so the tick by `Space` or by a press, the tab stop, and the checked state
|
|
6
|
+
* assistive technology announces come from the platform. A box standing for a group of boxes ticked in part shows the
|
|
7
|
+
* mixed state while `indeterminate`, which the next tick clears, leaving the box ticked or clear as the reader sets it.
|
|
8
|
+
*
|
|
9
|
+
* The answer is either held by the caller, which shows `checked` and is handed each tick through `onChange`, or left
|
|
10
|
+
* to the box where `checked` is omitted, the box then keeping whatever the reader ticks.
|
|
11
|
+
*
|
|
12
|
+
* A setting taking effect as soon as it is flipped, rather than when the form around it is submitted, is better served
|
|
13
|
+
* by a {@link switch!Switch Switch}, whose look tells the reader that the change applies at once.
|
|
14
|
+
*
|
|
15
|
+
* @param options The widget configuration
|
|
16
|
+
*
|
|
17
|
+
* @returns The checkbox
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/ ARIA Authoring Practices: Checkbox Pattern}
|
|
20
|
+
*/
|
|
21
|
+
export declare function Checkbox({ name, id, disabled, indeterminate, required, checked, onChange }: {
|
|
22
|
+
/**
|
|
23
|
+
* The accessible name, required where no {@link label!Label Label} names the box.
|
|
24
|
+
*/
|
|
25
|
+
name?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The id a split {@link label!Label Label} names the box by; no id if omitted.
|
|
28
|
+
*/
|
|
29
|
+
id?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the box takes no tick, greyed and out of the tab order; live if omitted.
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the box shows the mixed state, neither ticked nor clear, as a box standing for a group ticked in part
|
|
36
|
+
* does; ticked or clear as `checked` says if omitted, and cleared by the next tick the reader makes.
|
|
37
|
+
*/
|
|
38
|
+
indeterminate?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the box fails its constraints while clear, as one accepting terms does; optional if omitted.
|
|
41
|
+
*/
|
|
42
|
+
required?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the box is shown ticked, held by the caller; left to the box if omitted.
|
|
45
|
+
*/
|
|
46
|
+
checked?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Receives the state of the box on every tick.
|
|
49
|
+
*
|
|
50
|
+
* @param checked Whether the box is now ticked
|
|
51
|
+
*/
|
|
52
|
+
onChange?: (checked: boolean) => void;
|
|
53
|
+
}): import("preact").VNode<import("preact").ClassAttributes<HTMLElement> & import("preact").HTMLAttributes<EventTarget> & import("preact").SVGAttributes<SVGElement>>;
|
|
54
|
+
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/controls/checkbox.tsx"],"names":[],"mappings":"AA0BA,OAAO,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,EAExB,IAAI,EACJ,EAAE,EAEF,QAAQ,EACR,aAAa,EACb,QAAQ,EAER,OAAO,EAEP,QAAQ,EAER,EAAE;IAEF;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IAEX;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAErC,qKAmBA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
* Checkbox.
|
|
19
|
+
*
|
|
20
|
+
* Takes a yes or no answer submitted with the form around it, such as agreeing to terms or opting into a mailing,
|
|
21
|
+
* or one pick among several boxes ticked independently of one another, each answering for itself.
|
|
22
|
+
*
|
|
23
|
+
* @module checkbox
|
|
24
|
+
*/
|
|
25
|
+
import { createElement } from "preact";
|
|
26
|
+
import "./checkbox.css";
|
|
27
|
+
/**
|
|
28
|
+
* Creates a checkbox.
|
|
29
|
+
*
|
|
30
|
+
* Takes its answer on a native checkbox, so the tick by `Space` or by a press, the tab stop, and the checked state
|
|
31
|
+
* assistive technology announces come from the platform. A box standing for a group of boxes ticked in part shows the
|
|
32
|
+
* mixed state while `indeterminate`, which the next tick clears, leaving the box ticked or clear as the reader sets it.
|
|
33
|
+
*
|
|
34
|
+
* The answer is either held by the caller, which shows `checked` and is handed each tick through `onChange`, or left
|
|
35
|
+
* to the box where `checked` is omitted, the box then keeping whatever the reader ticks.
|
|
36
|
+
*
|
|
37
|
+
* A setting taking effect as soon as it is flipped, rather than when the form around it is submitted, is better served
|
|
38
|
+
* by a {@link switch!Switch Switch}, whose look tells the reader that the change applies at once.
|
|
39
|
+
*
|
|
40
|
+
* @param options The widget configuration
|
|
41
|
+
*
|
|
42
|
+
* @returns The checkbox
|
|
43
|
+
*
|
|
44
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/ ARIA Authoring Practices: Checkbox Pattern}
|
|
45
|
+
*/
|
|
46
|
+
export function Checkbox({ name, id, disabled, indeterminate, required, checked, onChange }) {
|
|
47
|
+
return createElement("clay-checkbox", {}, _jsx("input", { id: id, disabled: disabled, indeterminate: indeterminate, required: required, "aria-label": name, type: "checkbox", checked: checked, onChange: event => onChange?.(event.currentTarget.checked) }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../src/controls/checkbox.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,QAAQ,CAAC,EAExB,IAAI,EACJ,EAAE,EAEF,QAAQ,EACR,aAAa,EACb,QAAQ,EAER,OAAO,EAEP,QAAQ,EA0CR;IAEA,OAAO,aAAa,CAAC,eAAe,EAAE,EAAE,EAAE,gBAEzC,EAAE,EAAE,EAAE,EAEN,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,QAAQ,gBAEN,IAAI,EAChB,IAAI,EAAC,UAAU,EAEf,OAAO,EAAE,OAAO,EAEhB,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,GAEzD,CAAC,CAAC;AAEL,CAAC"}
|
|
@@ -0,0 +1,288 @@
|
|
|
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 choice is drawn as a track holding a thumb. The track is one box in the field border, sunk into the page, with
|
|
19
|
+
* the corners and the height of a select, so it sits in a row of buttons and selects as one of them. The chosen
|
|
20
|
+
* option is the thumb, raised out of the track as a card of its own and told apart from it by surface and edge
|
|
21
|
+
* rather than by hue, so the choice reads in greyscale as it does in colour. The radio buttons carrying the choice
|
|
22
|
+
* stay in the document, out of view, so the platform keeps their keys and focus.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/* The look of a choice stating none, which an area assigns to every choice it holds. */
|
|
26
|
+
|
|
27
|
+
@property --clay-choice-look {
|
|
28
|
+
syntax: "subtle | normal | strong";
|
|
29
|
+
inherits: true;
|
|
30
|
+
initial-value: normal;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
clay-choice {
|
|
34
|
+
|
|
35
|
+
display: inline-block;
|
|
36
|
+
vertical-align: middle;
|
|
37
|
+
|
|
38
|
+
/* The segments share the width of the widest one, so no option reads as weightier than another. */
|
|
39
|
+
|
|
40
|
+
& > fieldset {
|
|
41
|
+
|
|
42
|
+
display: grid;
|
|
43
|
+
grid-auto-flow: column;
|
|
44
|
+
grid-auto-columns: 1fr;
|
|
45
|
+
|
|
46
|
+
margin: 0;
|
|
47
|
+
padding: 0;
|
|
48
|
+
|
|
49
|
+
border-style: var(--skin--border-style);
|
|
50
|
+
border-color: var(--skin--border-color-field);
|
|
51
|
+
border-radius: var(--skin--border-radius-025);
|
|
52
|
+
background-color: var(--skin--background-color-sunken);
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* An option is a control rather than text, so a press or a drag across the row chooses rather than selects
|
|
56
|
+
* its label, as with a button.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
& > label {
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* An option is a segment of the track rather than a name beside its box, so it drops the row and the strong
|
|
63
|
+
* weight the design system sets a label wrapping a radio button in, and its segment fills the column.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
display: block;
|
|
67
|
+
position: relative;
|
|
68
|
+
font-weight: var(--skin--font-weight);
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
user-select: none;
|
|
71
|
+
|
|
72
|
+
/* The reset hands every box the colour of the one around it, so labels are left unpainted. */
|
|
73
|
+
|
|
74
|
+
background-color: transparent;
|
|
75
|
+
|
|
76
|
+
& > input {
|
|
77
|
+
position: absolute;
|
|
78
|
+
opacity: 0;
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* A segment takes the room and the corners of a select, so the track stands exactly as tall as a select
|
|
84
|
+
* beside it, and more inline room, so the thumb stands clear of its label.
|
|
85
|
+
*
|
|
86
|
+
* A glyph sits on the baseline of its line and rides high in the segment, so what a segment carries is
|
|
87
|
+
* centred instead. The segment is floored at the height of a line of text, so a choice of glyphs stands
|
|
88
|
+
* as tall as a choice of labels, and the two line up when set side by side in a row of controls.
|
|
89
|
+
*
|
|
90
|
+
* Every segment keeps an edge, transparent unless chosen, so moving the choice never shifts the row, and
|
|
91
|
+
* is pulled out over the border of the track by the width of one, so the edge of the thumb merges into
|
|
92
|
+
* the border of the track along its stretch rather than doubling it.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
& > span {
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
min-height: calc(1lh + 2 * (var(--skin--spacing-025) + var(--skin--border-width)));
|
|
100
|
+
margin: calc(-1 * var(--skin--border-width));
|
|
101
|
+
padding: var(--skin--spacing-025) var(--skin--spacing-075);
|
|
102
|
+
border: var(--skin--border-width) var(--skin--border-style) transparent;
|
|
103
|
+
border-radius: var(--skin--border-radius-025);
|
|
104
|
+
background-color: transparent;
|
|
105
|
+
color: var(--skin--color-label);
|
|
106
|
+
white-space: nowrap;
|
|
107
|
+
transition-property: color, border-color, background-color;
|
|
108
|
+
transition-duration: var(--skin--duration-fast);
|
|
109
|
+
transition-timing-function: var(--skin--easing-standard);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/*
|
|
113
|
+
* An option on offer answers the pointer and the press with the neutral cover a button carrying no
|
|
114
|
+
* meaning takes, deepening the track by the same step it deepens any surface.
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
&:hover > input:not(:checked) + span {
|
|
118
|
+
background-color: var(--skin--background-color-hover-neutral);
|
|
119
|
+
color: var(--skin--color);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:active > input:not(:checked) + span {
|
|
123
|
+
background-color: var(--skin--background-color-pressed-neutral);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* The chosen segment is the thumb, raised out of the track on the raised surface and edged in the field
|
|
128
|
+
* border it merges into. Its label takes the text colour where the others recede into the label colour,
|
|
129
|
+
* and the checked state tells assistive technology which option is chosen.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
& > input:checked + span {
|
|
133
|
+
border-color: var(--skin--border-color-field);
|
|
134
|
+
background-color: var(--skin--background-color-raised);
|
|
135
|
+
color: var(--skin--color);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* The ring marks the segment the keyboard stands on, which the radio button kept out of view cannot draw
|
|
140
|
+
* for itself, just inside the segment, as the design system draws it inside a boxed control.
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
& > input:focus-visible + span {
|
|
144
|
+
outline: var(--skin--outline-focus);
|
|
145
|
+
outline-offset: calc(-2 * var(--skin--border-width));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* The quiet step drops the track and the thumb and sets the options one line tall, so they read as part of the
|
|
154
|
+
* text around them and never stand taller than their line. Each option is as wide as what it carries rather than
|
|
155
|
+
* as the widest. The chosen one is inked in the selection accent and underlined by a bar spanning its label or
|
|
156
|
+
* glyph, so the mark survives where the accent alone would not tell it from its neighbours. The bar stands just
|
|
157
|
+
* clear of its word, heavy enough to read as a mark, and takes no room, so moving the choice never shifts the line.
|
|
158
|
+
*
|
|
159
|
+
* The strong step sets the options in the strong weight and inks the label on the thumb in the selection accent,
|
|
160
|
+
* so the choice stands out from the quieter fields and selects around it. A glyph carries no weight of its own,
|
|
161
|
+
* so its stroke is drawn at the strong width to keep it on the footing of a bold label.
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
&[look="subtle"] > fieldset {
|
|
165
|
+
|
|
166
|
+
display: flex;
|
|
167
|
+
column-gap: var(--skin--spacing-050);
|
|
168
|
+
padding: 0;
|
|
169
|
+
border-style: none;
|
|
170
|
+
background-color: transparent;
|
|
171
|
+
|
|
172
|
+
& > label {
|
|
173
|
+
|
|
174
|
+
& > span {
|
|
175
|
+
min-height: 1lh;
|
|
176
|
+
margin: 0;
|
|
177
|
+
padding: 0;
|
|
178
|
+
border-style: none;
|
|
179
|
+
border-radius: 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&:is(:hover, :active) > input:not(:checked) + span {
|
|
183
|
+
background-color: transparent;
|
|
184
|
+
color: var(--skin--color-hover);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
& > input:checked + span {
|
|
188
|
+
|
|
189
|
+
background-color: transparent;
|
|
190
|
+
color: var(--skin--color-selected);
|
|
191
|
+
|
|
192
|
+
&::after {
|
|
193
|
+
content: "";
|
|
194
|
+
position: absolute;
|
|
195
|
+
inset-inline: 0;
|
|
196
|
+
top: calc(100% + var(--skin--spacing-010));
|
|
197
|
+
height: calc(2 * var(--skin--border-width));
|
|
198
|
+
background-color: currentColor;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
&[look="strong"] > fieldset > label {
|
|
208
|
+
|
|
209
|
+
font-weight: var(--skin--font-weight-strong);
|
|
210
|
+
|
|
211
|
+
& .lucide {
|
|
212
|
+
stroke-width: var(--skin--stroke-width-strong);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
& > input:checked + span {
|
|
216
|
+
color: var(--skin--color-selected);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/*
|
|
222
|
+
* A choice stating no look of its own takes the one the area around it sets, read off the `--clay-choice-look`
|
|
223
|
+
* knob through a style query, restating the declarations of the attribute rules above: a style query is a
|
|
224
|
+
* conditional group taking rules of its own, so the two forms of the same step cannot be written as one selector.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
@container style(--clay-choice-look: subtle) {
|
|
228
|
+
&:not([look]) > fieldset {
|
|
229
|
+
|
|
230
|
+
display: flex;
|
|
231
|
+
column-gap: var(--skin--spacing-050);
|
|
232
|
+
padding: 0;
|
|
233
|
+
border-style: none;
|
|
234
|
+
background-color: transparent;
|
|
235
|
+
|
|
236
|
+
& > label {
|
|
237
|
+
|
|
238
|
+
& > span {
|
|
239
|
+
min-height: 1lh;
|
|
240
|
+
margin: 0;
|
|
241
|
+
padding: 0;
|
|
242
|
+
border-style: none;
|
|
243
|
+
border-radius: 0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
&:is(:hover, :active) > input:not(:checked) + span {
|
|
247
|
+
background-color: transparent;
|
|
248
|
+
color: var(--skin--color-hover);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
& > input:checked + span {
|
|
252
|
+
|
|
253
|
+
background-color: transparent;
|
|
254
|
+
color: var(--skin--color-selected);
|
|
255
|
+
|
|
256
|
+
&::after {
|
|
257
|
+
content: "";
|
|
258
|
+
position: absolute;
|
|
259
|
+
inset-inline: 0;
|
|
260
|
+
top: calc(100% + var(--skin--spacing-010));
|
|
261
|
+
height: calc(2 * var(--skin--border-width));
|
|
262
|
+
background-color: currentColor;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
@container style(--clay-choice-look: strong) {
|
|
273
|
+
&:not([look]) > fieldset > label {
|
|
274
|
+
|
|
275
|
+
font-weight: var(--skin--font-weight-strong);
|
|
276
|
+
|
|
277
|
+
& .lucide {
|
|
278
|
+
stroke-width: var(--skin--stroke-width-strong);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
& > input:checked + span {
|
|
282
|
+
color: var(--skin--color-selected);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segmented choice.
|
|
3
|
+
*
|
|
4
|
+
* Offers a choice among a few options as one row of segments, every option in view and the chosen one marked, so a
|
|
5
|
+
* setting such as the colour scheme is read and changed in a single glance and gesture.
|
|
6
|
+
*
|
|
7
|
+
* @module choice
|
|
8
|
+
*/
|
|
9
|
+
import { type ComponentChildren } from "preact";
|
|
10
|
+
import "./choice.css";
|
|
11
|
+
/**
|
|
12
|
+
* Creates a segmented choice.
|
|
13
|
+
*
|
|
14
|
+
* Lays the options out in the order given as a group of radio buttons, so the platform supplies the keys and the focus
|
|
15
|
+
* a choice owes: `Tab` reaches the group as one stop, landing on the chosen option, and the arrow keys move the choice
|
|
16
|
+
* to either neighbour, wrapping at both ends. The chosen option is marked as `look` sets out, and carries the checked
|
|
17
|
+
* state assistive technology reads, so the choice reaches a reader who cannot see the mark.
|
|
18
|
+
*
|
|
19
|
+
* The choice is held by the caller: the widget shows `value` as chosen and hands each new choice to `onChange`, so a
|
|
20
|
+
* caller keeping the choice somewhere of its own, such as the storage of the page, passes it back as `value`.
|
|
21
|
+
*
|
|
22
|
+
* @param options The widget configuration
|
|
23
|
+
*
|
|
24
|
+
* @returns The segmented choice
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/radio/ ARIA Authoring Practices: Radio Group Pattern}
|
|
27
|
+
*/
|
|
28
|
+
export declare function Choice<V extends string>({ name, look, // deliberately left undefaulted, so an unstated look falls through to the one the area assigns
|
|
29
|
+
options, value, onChange }: {
|
|
30
|
+
/**
|
|
31
|
+
* The accessible name of the group, such as `Colour scheme`, saying what is being chosen.
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* How loud the choice appears. `subtle` drops the box and keeps the options one line tall, so they fit inside a
|
|
36
|
+
* line of text and read as part of it; the chosen one is inked and underlined in the selection accent. `normal`
|
|
37
|
+
* sinks the options into a track boxed and sized as a {@link select!Select Select} is, each as wide as the widest,
|
|
38
|
+
* and raises the chosen one out of the track as a card. `strong` also sets the options in the strong weight and
|
|
39
|
+
* inks the chosen one in the accent, so the choice stands out from the fields and menus around it while matching
|
|
40
|
+
* their height, borders and corners, and a row mixing them still lines up as one.
|
|
41
|
+
*
|
|
42
|
+
* A choice stating nothing takes the look the {@link style!Style styled area} around it assigns as `choiceLook`,
|
|
43
|
+
* which is `normal` where nothing assigns it. Stating a look here answers to that alone, whatever the area says.
|
|
44
|
+
*/
|
|
45
|
+
look?: "subtle" | "normal" | "strong";
|
|
46
|
+
/**
|
|
47
|
+
* The label of each option, keyed by its value, in display order.
|
|
48
|
+
*/
|
|
49
|
+
options: Readonly<Record<V, ComponentChildren>>;
|
|
50
|
+
/**
|
|
51
|
+
* The value of the option shown as chosen; none if omitted or if it names no option.
|
|
52
|
+
*/
|
|
53
|
+
value?: V;
|
|
54
|
+
/**
|
|
55
|
+
* Receives the value of the option a reader chooses.
|
|
56
|
+
*
|
|
57
|
+
* @param value The value of the chosen option
|
|
58
|
+
*/
|
|
59
|
+
onChange?: (value: V) => void;
|
|
60
|
+
}): import("preact").VNode<{
|
|
61
|
+
look: "subtle" | "normal" | "strong" | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
//# sourceMappingURL=choice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../../src/controls/choice.tsx"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,QAAQ,CAAC;AAE/D,OAAO,cAAc,CAAC;AAKtB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,EAExC,IAAI,EAEJ,IAAI,EAAE,+FAA+F;AAErG,OAAO,EACP,KAAK,EAEL,QAAQ,EAER,EAAE;IAEF;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAErC;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAA;IAE/C;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,CAAA;IAET;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CAE7B;;GAyBA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
* Segmented choice.
|
|
19
|
+
*
|
|
20
|
+
* Offers a choice among a few options as one row of segments, every option in view and the chosen one marked, so a
|
|
21
|
+
* setting such as the colour scheme is read and changed in a single glance and gesture.
|
|
22
|
+
*
|
|
23
|
+
* @module choice
|
|
24
|
+
*/
|
|
25
|
+
import { createElement } from "preact";
|
|
26
|
+
import { useId } from "preact/hooks";
|
|
27
|
+
import "./choice.css";
|
|
28
|
+
// noinspection JSCommentMatchesSignature
|
|
29
|
+
/**
|
|
30
|
+
* Creates a segmented choice.
|
|
31
|
+
*
|
|
32
|
+
* Lays the options out in the order given as a group of radio buttons, so the platform supplies the keys and the focus
|
|
33
|
+
* a choice owes: `Tab` reaches the group as one stop, landing on the chosen option, and the arrow keys move the choice
|
|
34
|
+
* to either neighbour, wrapping at both ends. The chosen option is marked as `look` sets out, and carries the checked
|
|
35
|
+
* state assistive technology reads, so the choice reaches a reader who cannot see the mark.
|
|
36
|
+
*
|
|
37
|
+
* The choice is held by the caller: the widget shows `value` as chosen and hands each new choice to `onChange`, so a
|
|
38
|
+
* caller keeping the choice somewhere of its own, such as the storage of the page, passes it back as `value`.
|
|
39
|
+
*
|
|
40
|
+
* @param options The widget configuration
|
|
41
|
+
*
|
|
42
|
+
* @returns The segmented choice
|
|
43
|
+
*
|
|
44
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/radio/ ARIA Authoring Practices: Radio Group Pattern}
|
|
45
|
+
*/
|
|
46
|
+
export function Choice({ name, look, // deliberately left undefaulted, so an unstated look falls through to the one the area assigns
|
|
47
|
+
options, value, onChange }) {
|
|
48
|
+
const group = useId();
|
|
49
|
+
return createElement("clay-choice", { look }, _jsx("fieldset", { "aria-label": name, children: Object.keys(options).map(option => // ;(cast) options is assumed to carry no keys beyond V
|
|
50
|
+
_jsxs("label", { children: [_jsx("input", { type: "radio", name: group, value: option, checked: option === value, onChange: () => onChange?.(option) }), _jsx("span", { children: options[option] })] }, option)) }));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=choice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choice.js","sourceRoot":"","sources":["../../src/controls/choice.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAA0B,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,cAAc,CAAC;AAGtB,yCAAyC;AAEzC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAmB,EAExC,IAAI,EAEJ,IAAI,EAAE,+FAA+F;AAErG,OAAO,EACP,KAAK,EAEL,QAAQ,EAuCR;IAEA,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC;IAEtB,OAAO,aAAa,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,EAAE,iCAAsB,IAAI,YAEtE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,uDAAuD;SAElG,4BAEC,gBACC,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,KAAK,KAAK,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,GACjC,EAEF,yBAAO,OAAO,CAAC,MAAM,CAAC,GAAQ,KAVnB,MAAM,CAYV,CACR,GAEU,CAAC,CAAC;AAEf,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 group is framed and captioned as the design system frames every native field set. */
|
|
18
|
+
|
|
19
|
+
clay-fieldset {
|
|
20
|
+
|
|
21
|
+
display: contents;
|
|
22
|
+
|
|
23
|
+
& > fieldset {
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* A group of radio buttons the reader has to pick from is marked on its caption, as a label naming a
|
|
27
|
+
* required field is, the buttons themselves being left unmarked so the one pick owed is marked once.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
&:has(:required:enabled[type="radio"]) > legend::after {
|
|
31
|
+
content: " *" / "";
|
|
32
|
+
color: var(--skin--color-fail);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field group.
|
|
3
|
+
*
|
|
4
|
+
* Gathers related fields under a caption naming them as a whole, such as the parts of an address or the buttons of a
|
|
5
|
+
* radio group, and turns them all off at once where they do not apply to the case at hand.
|
|
6
|
+
*
|
|
7
|
+
* @module fieldset
|
|
8
|
+
*/
|
|
9
|
+
import { type ComponentChildren } from "preact";
|
|
10
|
+
import "./fieldset.css";
|
|
11
|
+
/**
|
|
12
|
+
* Creates a field group.
|
|
13
|
+
*
|
|
14
|
+
* Gathers its fields in a native field set, so assistive technology announces the caption on entering the group,
|
|
15
|
+
* before the label of the field reached, and a `disabled` group turns off every field it holds without each having to
|
|
16
|
+
* be told. The group frames its fields in a box with the caption set into its top edge, and leaves the fields
|
|
17
|
+
* inside it where the children place them, so the screen keeps the layout of the group in its own hands.
|
|
18
|
+
*
|
|
19
|
+
* A group is named by its visible `label` or, where none is shown, by `name`; a radio group always takes one, its
|
|
20
|
+
* buttons being otherwise named one by one with nothing saying what is being picked. A visible caption over required
|
|
21
|
+
* radio buttons taking input shows an asterisk, as a {@link label!Label Label} naming a required field does.
|
|
22
|
+
*
|
|
23
|
+
* @param options The widget configuration
|
|
24
|
+
*
|
|
25
|
+
* @returns The field group
|
|
26
|
+
*
|
|
27
|
+
* @see [HTML: The fieldset element][fieldset]
|
|
28
|
+
*
|
|
29
|
+
* [fieldset]: https://html.spec.whatwg.org/multipage/form-elements.html#the-fieldset-element
|
|
30
|
+
*/
|
|
31
|
+
export declare function Fieldset({ name, disabled, label, children }: {
|
|
32
|
+
/**
|
|
33
|
+
* The accessible name of a group showing no `label`.
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether every field in the group takes no input, greyed and out of the tab order; live if omitted.
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The caption naming the group, set into the top edge of the frame around the fields; no caption if omitted.
|
|
42
|
+
*/
|
|
43
|
+
label?: ComponentChildren;
|
|
44
|
+
/**
|
|
45
|
+
* The fields of the group.
|
|
46
|
+
*/
|
|
47
|
+
children?: ComponentChildren;
|
|
48
|
+
}): import("preact").VNode<import("preact").ClassAttributes<HTMLElement> & import("preact").HTMLAttributes<EventTarget> & import("preact").SVGAttributes<SVGElement>>;
|
|
49
|
+
//# sourceMappingURL=fieldset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldset.d.ts","sourceRoot":"","sources":["../../src/controls/fieldset.tsx"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,QAAQ,CAAC;AAE/D,OAAO,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,EAExB,IAAI,EAEJ,QAAQ,EAER,KAAK,EAEL,QAAQ,EAER,EAAE;IAEF;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAA;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAE5B,qKAgBA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
* Field group.
|
|
19
|
+
*
|
|
20
|
+
* Gathers related fields under a caption naming them as a whole, such as the parts of an address or the buttons of a
|
|
21
|
+
* radio group, and turns them all off at once where they do not apply to the case at hand.
|
|
22
|
+
*
|
|
23
|
+
* @module fieldset
|
|
24
|
+
*/
|
|
25
|
+
import { createElement } from "preact";
|
|
26
|
+
import { isContent } from "../index.js";
|
|
27
|
+
import "./fieldset.css";
|
|
28
|
+
/**
|
|
29
|
+
* Creates a field group.
|
|
30
|
+
*
|
|
31
|
+
* Gathers its fields in a native field set, so assistive technology announces the caption on entering the group,
|
|
32
|
+
* before the label of the field reached, and a `disabled` group turns off every field it holds without each having to
|
|
33
|
+
* be told. The group frames its fields in a box with the caption set into its top edge, and leaves the fields
|
|
34
|
+
* inside it where the children place them, so the screen keeps the layout of the group in its own hands.
|
|
35
|
+
*
|
|
36
|
+
* A group is named by its visible `label` or, where none is shown, by `name`; a radio group always takes one, its
|
|
37
|
+
* buttons being otherwise named one by one with nothing saying what is being picked. A visible caption over required
|
|
38
|
+
* radio buttons taking input shows an asterisk, as a {@link label!Label Label} naming a required field does.
|
|
39
|
+
*
|
|
40
|
+
* @param options The widget configuration
|
|
41
|
+
*
|
|
42
|
+
* @returns The field group
|
|
43
|
+
*
|
|
44
|
+
* @see [HTML: The fieldset element][fieldset]
|
|
45
|
+
*
|
|
46
|
+
* [fieldset]: https://html.spec.whatwg.org/multipage/form-elements.html#the-fieldset-element
|
|
47
|
+
*/
|
|
48
|
+
export function Fieldset({ name, disabled, label, children }) {
|
|
49
|
+
return createElement("clay-fieldset", {}, _jsxs("fieldset", { disabled: disabled, "aria-label": name, children: [isContent(label) && _jsx("legend", { children: label }), children] }));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=fieldset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldset.js","sourceRoot":"","sources":["../../src/controls/fieldset.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAA0B,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,QAAQ,CAAC,EAExB,IAAI,EAEJ,QAAQ,EAER,KAAK,EAEL,QAAQ,EAwBR;IAEA,OAAO,aAAa,CAAC,eAAe,EAAE,EAAE,EAAE,oBAEzC,QAAQ,EAAE,QAAQ,gBAEN,IAAI,aAIf,SAAS,CAAC,KAAK,CAAC,IAAI,2BAAS,KAAK,GAAU,EAE5C,QAAQ,IAEC,CAAC,CAAC;AAEd,CAAC"}
|