@adia-ai/web-components 0.8.41 → 0.8.43
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/CHANGELOG.md +35 -0
- package/MIGRATION.md +240 -3
- package/USAGE.md +4 -4
- package/color/index.js +1 -1
- package/components/action-list/action-item.a2ui.json +7 -7
- package/components/action-list/action-item.yaml +21 -9
- package/components/action-list/action-list.class.js +13 -7
- package/components/action-list/action-list.d.ts +2 -2
- package/components/button/button.yaml +1 -1
- package/components/calendar-picker/calendar-picker.a2ui.json +1 -1
- package/components/calendar-picker/calendar-picker.class.js +2 -3
- package/components/calendar-picker/calendar-picker.css +16 -18
- package/components/calendar-picker/calendar-picker.yaml +2 -2
- package/components/card/card.css +3 -3
- package/components/chart/chart.a2ui.json +8 -8
- package/components/chart/chart.class.js +21 -19
- package/components/chart/chart.d.ts +6 -6
- package/components/chart/chart.yaml +16 -9
- package/components/chart-legend/chart-legend.a2ui.json +7 -11
- package/components/chart-legend/chart-legend.class.js +17 -8
- package/components/chart-legend/chart-legend.css +5 -2
- package/components/chart-legend/chart-legend.d.ts +2 -2
- package/components/chart-legend/chart-legend.yaml +12 -8
- package/components/check/check.css +9 -0
- package/components/{color-picker/color-picker.a2ui.json → color-area/color-area.a2ui.json} +15 -12
- package/components/{color-picker/color-picker.class.js → color-area/color-area.class.js} +10 -8
- package/components/color-area/color-area.css +185 -0
- package/components/color-area/color-area.d.ts +66 -0
- package/components/color-area/color-area.examples.md +19 -0
- package/components/color-area/color-area.js +17 -0
- package/components/{color-picker/color-picker.yaml → color-area/color-area.yaml} +17 -9
- package/components/color-input/color-input.a2ui.json +5 -5
- package/components/color-input/color-input.class.js +9 -6
- package/components/color-input/color-input.css +1 -1
- package/components/color-input/color-input.js +2 -2
- package/components/color-input/color-input.yaml +14 -12
- package/components/description-list/description-list.a2ui.json +1 -1
- package/components/description-list/description-list.css +1 -1
- package/components/description-list/description-list.d.ts +1 -1
- package/components/description-list/description-list.yaml +1 -1
- package/components/drilldown/drilldown.a2ui.json +3 -0
- package/components/drilldown/drilldown.css +8 -1
- package/components/drilldown/drilldown.yaml +2 -0
- package/components/field/field.a2ui.json +1 -1
- package/components/field/field.class.js +5 -2
- package/components/field/field.yaml +1 -1
- package/components/index.js +1 -4
- package/components/input/input.a2ui.json +4 -4
- package/components/input/input.class.js +8 -0
- package/components/input/input.css +6 -0
- package/components/input/input.yaml +11 -8
- package/components/integration-card/integration-card.examples.md +2 -1
- package/components/menu/menu-item.a2ui.json +7 -7
- package/components/menu/menu-item.yaml +20 -7
- package/components/menu/menu.class.js +13 -7
- package/components/menu/menu.d.ts +2 -2
- package/components/pane/pane.a2ui.json +11 -11
- package/components/pane/pane.class.js +8 -4
- package/components/pane/pane.css +15 -10
- package/components/pane/pane.d.ts +10 -9
- package/components/pane/pane.yaml +9 -7
- package/components/progress/progress.a2ui.json +1 -1
- package/components/progress/progress.class.js +2 -2
- package/components/progress/progress.d.ts +1 -1
- package/components/progress/progress.yaml +2 -2
- package/components/radio/radio.css +7 -0
- package/components/search/search.css +10 -1
- package/components/segment/segment.a2ui.json +1 -2
- package/components/segment/segment.css +10 -0
- package/components/segment/segment.yaml +1 -2
- package/components/segmented/segmented.a2ui.json +1 -3
- package/components/segmented/segmented.class.js +2 -2
- package/components/segmented/segmented.yaml +2 -4
- package/components/select/select.css +6 -0
- package/components/step-progress/step-progress.yaml +1 -1
- package/components/swatch/swatch.yaml +1 -1
- package/components/switch/switch.css +8 -0
- package/components/table-toolbar/table-toolbar.a2ui.json +42 -1
- package/components/table-toolbar/table-toolbar.class.js +166 -14
- package/components/table-toolbar/table-toolbar.css +46 -0
- package/components/table-toolbar/table-toolbar.d.ts +13 -1
- package/components/table-toolbar/table-toolbar.yaml +104 -14
- package/components/textarea/textarea.css +4 -0
- package/components/time-picker/time-picker.yaml +3 -2
- package/components/tree/tree.yaml +1 -1
- package/components/upload/upload.class.js +16 -0
- package/components/upload/upload.d.ts +7 -0
- package/components/upload/upload.yaml +7 -3
- package/core/icons.js +3 -1
- package/custom-elements.json +147 -468
- package/dist/host.min.css +1 -1
- package/dist/host.sheet.js +1 -1
- package/dist/theme-provider.min.js +1 -1
- package/dist/web-components.min.css +1 -1
- package/dist/web-components.min.js +88 -85
- package/dist/web-components.sheet.js +1 -1
- package/index.d.ts +9 -13
- package/package.json +1 -1
- package/patterns/admin-shell/admin-shell.examples.html +2 -2
- package/patterns/chart-in-card/chart-in-card.examples.html +10 -10
- package/patterns/conversion-funnel/conversion-funnel.html +2 -2
- package/patterns/editor-shell/editor-shell.examples.html +3 -3
- package/patterns/form-system/form-system.examples.html +1 -1
- package/styles/colors/semantics/features.css +8 -1
- package/styles/components.css +1 -4
- package/traits/arrow-grid-nav/arrow-grid-nav.js +1 -1
- package/traits/resize-observer/resize-observer.js +1 -1
- package/components/color-picker/color-picker.css +0 -182
- package/components/color-picker/color-picker.d.ts +0 -99
- package/components/color-picker/color-picker.examples.md +0 -19
- package/components/color-picker/color-picker.js +0 -17
- package/components/datetime-picker/datetime-picker.a2ui.json +0 -256
- package/components/datetime-picker/datetime-picker.class.js +0 -58
- package/components/datetime-picker/datetime-picker.css +0 -11
- package/components/datetime-picker/datetime-picker.d.ts +0 -87
- package/components/datetime-picker/datetime-picker.examples.md +0 -25
- package/components/datetime-picker/datetime-picker.js +0 -17
- package/components/datetime-picker/datetime-picker.yaml +0 -254
- package/components/progress-row/progress-row.a2ui.json +0 -107
- package/components/progress-row/progress-row.class.js +0 -118
- package/components/progress-row/progress-row.css +0 -60
- package/components/progress-row/progress-row.d.ts +0 -24
- package/components/progress-row/progress-row.examples.md +0 -7
- package/components/progress-row/progress-row.js +0 -17
- package/components/progress-row/progress-row.yaml +0 -85
- package/components/toggle-group/toggle-group.a2ui.json +0 -148
- package/components/toggle-group/toggle-group.class.js +0 -195
- package/components/toggle-group/toggle-group.css +0 -127
- package/components/toggle-group/toggle-group.d.ts +0 -50
- package/components/toggle-group/toggle-group.examples.md +0 -33
- package/components/toggle-group/toggle-group.js +0 -18
- package/components/toggle-group/toggle-group.yaml +0 -135
- package/components/toggle-group/toggle-option.a2ui.json +0 -86
- package/components/toggle-group/toggle-option.yaml +0 -75
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://adiaui.dev/a2ui/v0_9/components/ToggleGroup.json",
|
|
4
|
-
"title": "ToggleGroup",
|
|
5
|
-
"description": "DEPRECATED (gh#1369) — use <segmented-ui multiple> + <segment-ui> instead. Multi-select button group (unlike <segmented-ui> which is single-select by default). Hosts <toggle-option-ui> children, each independently toggleable; emits change events with the active value set.",
|
|
6
|
-
"type": "object",
|
|
7
|
-
"allOf": [
|
|
8
|
-
{
|
|
9
|
-
"$ref": "common_types.json#/$defs/ComponentCommon"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"$ref": "common_types.json#/$defs/CatalogComponentCommon"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"properties": {
|
|
16
|
-
"component": {
|
|
17
|
-
"const": "ToggleGroup"
|
|
18
|
-
},
|
|
19
|
-
"single": {
|
|
20
|
-
"description": "When true, restrict to one active option (single-select) — clicking the already-selected option again CLEARS it (empty value), unlike a native radiogroup. Migration (gh#1369): [single]=true maps to plain <segmented-ui> (no [multiple]) — note segmented-ui's single-select never clears on re-click, it's standard radiogroup semantics; the default (false, multi-select) maps to <segmented-ui multiple>.",
|
|
21
|
-
"type": "boolean",
|
|
22
|
-
"default": false
|
|
23
|
-
},
|
|
24
|
-
"value": {
|
|
25
|
-
"description": "Comma-separated selected values",
|
|
26
|
-
"type": "string",
|
|
27
|
-
"default": ""
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"required": [
|
|
31
|
-
"component"
|
|
32
|
-
],
|
|
33
|
-
"unevaluatedProperties": false,
|
|
34
|
-
"x-adiaui": {
|
|
35
|
-
"allowedChildren": [
|
|
36
|
-
"ToggleOption"
|
|
37
|
-
],
|
|
38
|
-
"anti_patterns": [],
|
|
39
|
-
"category": "navigation",
|
|
40
|
-
"composes": [],
|
|
41
|
-
"events": {
|
|
42
|
-
"change": {
|
|
43
|
-
"description": "Fired when selection changes. detail: { value }",
|
|
44
|
-
"detail": {
|
|
45
|
-
"value": {
|
|
46
|
-
"description": "New toggle-group value.",
|
|
47
|
-
"type": "string"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"examples": [
|
|
53
|
-
{
|
|
54
|
-
"description": "Basic ToggleGroup usage",
|
|
55
|
-
"a2ui": "[\n {\n \"id\": \"root\",\n \"component\": \"Card\",\n \"children\": [\n \"sec\"\n ]\n },\n {\n \"id\": \"sec\",\n \"component\": \"Section\",\n \"children\": [\n \"comp\"\n ]\n },\n {\n \"id\": \"comp\",\n \"component\": \"ToggleGroup\",\n \"value\": \"\"\n }\n]",
|
|
56
|
-
"name": "basic-toggle-group"
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
"keywords": [
|
|
60
|
-
"togglegroup",
|
|
61
|
-
"toggle-group",
|
|
62
|
-
"toggle",
|
|
63
|
-
"group"
|
|
64
|
-
],
|
|
65
|
-
"name": "UIToggleGroup",
|
|
66
|
-
"parts": {},
|
|
67
|
-
"related": [
|
|
68
|
-
"ToggleOption",
|
|
69
|
-
"Segmented",
|
|
70
|
-
"Radio"
|
|
71
|
-
],
|
|
72
|
-
"slots": {
|
|
73
|
-
"default": {
|
|
74
|
-
"description": "Default slot — primary child content."
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
"states": [
|
|
78
|
-
{
|
|
79
|
-
"description": "Default, ready for interaction.",
|
|
80
|
-
"name": "idle"
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
"status": "deprecated",
|
|
84
|
-
"synonyms": {
|
|
85
|
-
"toggle-group": [
|
|
86
|
-
"segmented-control",
|
|
87
|
-
"option-group",
|
|
88
|
-
"toggle-set"
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
|
-
"tag": "toggle-group-ui",
|
|
92
|
-
"tokens": {
|
|
93
|
-
"--toggle-group-border": {
|
|
94
|
-
"description": "Border color of the group container"
|
|
95
|
-
},
|
|
96
|
-
"--toggle-group-height": {
|
|
97
|
-
"description": "Height of the group container"
|
|
98
|
-
},
|
|
99
|
-
"--toggle-group-radius": {
|
|
100
|
-
"description": "Border radius of the group container"
|
|
101
|
-
},
|
|
102
|
-
"--toggle-option-bg-hover": {
|
|
103
|
-
"description": "Background color on hover"
|
|
104
|
-
},
|
|
105
|
-
"--toggle-option-border": {
|
|
106
|
-
"description": "Border color between adjacent options"
|
|
107
|
-
},
|
|
108
|
-
"--toggle-option-duration": {
|
|
109
|
-
"description": "Transition duration"
|
|
110
|
-
},
|
|
111
|
-
"--toggle-option-easing": {
|
|
112
|
-
"description": "Transition easing function"
|
|
113
|
-
},
|
|
114
|
-
"--toggle-option-fg": {
|
|
115
|
-
"description": "Default text color"
|
|
116
|
-
},
|
|
117
|
-
"--toggle-option-fg-disabled": {
|
|
118
|
-
"description": "Text color when disabled"
|
|
119
|
-
},
|
|
120
|
-
"--toggle-option-fg-hover": {
|
|
121
|
-
"description": "Text color on hover"
|
|
122
|
-
},
|
|
123
|
-
"--toggle-option-focus-ring": {
|
|
124
|
-
"description": "Focus ring box-shadow"
|
|
125
|
-
},
|
|
126
|
-
"--toggle-option-font-size": {
|
|
127
|
-
"description": "Font size for option text and icons"
|
|
128
|
-
},
|
|
129
|
-
"--toggle-option-gap": {
|
|
130
|
-
"description": "Gap between icon and text within an option"
|
|
131
|
-
},
|
|
132
|
-
"--toggle-option-height": {
|
|
133
|
-
"description": "Min-height of each option"
|
|
134
|
-
},
|
|
135
|
-
"--toggle-option-px": {
|
|
136
|
-
"description": "Horizontal padding of each option"
|
|
137
|
-
},
|
|
138
|
-
"--toggle-option-selected-bg": {
|
|
139
|
-
"description": "Background color when selected"
|
|
140
|
-
},
|
|
141
|
-
"--toggle-option-selected-fg": {
|
|
142
|
-
"description": "Text color when selected"
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
"traits": [],
|
|
146
|
-
"version": 1
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Non-side-effect class export for `<toggle-option-ui>` (+ co-located primitives).
|
|
3
|
-
*
|
|
4
|
-
* Importing this file gives you the class(es) without auto-registering the tag.
|
|
5
|
-
* Useful for test isolation, subclassing with tag-name override, or selective
|
|
6
|
-
* composition.
|
|
7
|
-
*
|
|
8
|
-
* The auto-register path stays at `@adia-ai/web-components/components/toggle-group`
|
|
9
|
-
* (which imports this file + calls `defineIfFree()`).
|
|
10
|
-
*
|
|
11
|
-
* @see ../../USAGE.md#registration--auto-vs-explicit
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* DEPRECATED (gh#1369, #1363 C1, ADR-0057) — use <segmented-ui multiple> +
|
|
16
|
-
* <segment-ui> instead (same comma-separated value encoding). Kept working
|
|
17
|
-
* as-is for existing consumers; no behavior change.
|
|
18
|
-
*
|
|
19
|
-
* <toggle-group-ui value="bold,italic">
|
|
20
|
-
* <toggle-option-ui value="bold" icon="text-b"></toggle-option-ui>
|
|
21
|
-
* <toggle-option-ui value="italic" icon="text-italic"></toggle-option-ui>
|
|
22
|
-
* <toggle-option-ui value="underline" icon="text-underline"></toggle-option-ui>
|
|
23
|
-
* </toggle-group-ui>
|
|
24
|
-
*
|
|
25
|
-
* Multi-select button group (unlike segmented which is single-select by default).
|
|
26
|
-
*
|
|
27
|
-
* Properties:
|
|
28
|
-
* value — comma-separated selected values
|
|
29
|
-
* single — restrict to one active option at a time (default false: multi-select)
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
import { UIElement } from '../../core/element.js';
|
|
33
|
-
|
|
34
|
-
// ── Toggle Option ──
|
|
35
|
-
//
|
|
36
|
-
// Parent-managed. Selection state flows through `toggle-group-ui`'s `value`
|
|
37
|
-
// (and `single` mode flag) — the group's `value` stays the single source of
|
|
38
|
-
// truth. ADR-0056 (gh#1303): the child's current-state surface is the
|
|
39
|
-
// declared, reflected `selected` prop below, converging onto <segment-ui>'s
|
|
40
|
-
// mechanism (yaml → catalog → generative grammar) instead of a private
|
|
41
|
-
// stamp. Don't set `selected` directly on an option; drive the group's
|
|
42
|
-
// `value` instead.
|
|
43
|
-
|
|
44
|
-
export class UIToggleOption extends UIElement {
|
|
45
|
-
static properties = {
|
|
46
|
-
value: { type: String, default: '', reflect: true },
|
|
47
|
-
text: { type: String, default: '', reflect: true },
|
|
48
|
-
icon: { type: String, default: '', reflect: true },
|
|
49
|
-
disabled: { type: Boolean, default: false, reflect: true },
|
|
50
|
-
selected: { type: Boolean, default: false, reflect: true },
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
static template = () => null;
|
|
54
|
-
|
|
55
|
-
#stamped = false;
|
|
56
|
-
|
|
57
|
-
// gh#1369 (#1363 C1): DEPRECATED — use <segment-ui> inside
|
|
58
|
-
// <segmented-ui multiple> instead. One-time warn, same pattern as
|
|
59
|
-
// UIFormElement's #labelWarned (form.js) — informational only, behavior
|
|
60
|
-
// is unchanged.
|
|
61
|
-
static #deprecationWarned = false;
|
|
62
|
-
|
|
63
|
-
connected() {
|
|
64
|
-
if (!UIToggleOption.#deprecationWarned) {
|
|
65
|
-
UIToggleOption.#deprecationWarned = true;
|
|
66
|
-
// eslint-disable-next-line no-console
|
|
67
|
-
console.warn(
|
|
68
|
-
'[AdiaUI] <toggle-option-ui> is deprecated — use <segment-ui> ' +
|
|
69
|
-
'inside <segmented-ui multiple> instead (gh#1369, #1363 C1). ' +
|
|
70
|
-
'Kept working as-is; no behavior change.',
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
this.setAttribute('role', 'button');
|
|
74
|
-
this.setAttribute('tabindex', '0');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
render() {
|
|
78
|
-
if (!this.#stamped) {
|
|
79
|
-
this.#stamped = true;
|
|
80
|
-
this.#stamp();
|
|
81
|
-
}
|
|
82
|
-
if (this.disabled) this.setAttribute('aria-disabled', 'true');
|
|
83
|
-
else this.removeAttribute('aria-disabled');
|
|
84
|
-
this.setAttribute('aria-pressed', this.selected ? 'true' : 'false');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
#stamp() {
|
|
88
|
-
let inner = '';
|
|
89
|
-
if (this.icon) inner += `<icon-ui name="${this.icon}"></icon-ui>`;
|
|
90
|
-
if (this.text) inner += `<span data-text>${this.text}</span>`;
|
|
91
|
-
this.innerHTML = inner;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
disconnected() {
|
|
95
|
-
this.#stamped = false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export class UIToggleGroup extends UIElement {
|
|
100
|
-
static properties = {
|
|
101
|
-
value: { type: String, default: '', reflect: true },
|
|
102
|
-
single: { type: Boolean, default: false, reflect: true },
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
static template = () => null;
|
|
106
|
-
|
|
107
|
-
#bound = false;
|
|
108
|
-
|
|
109
|
-
// gh#1369 (#1363 C1): DEPRECATED — use <segmented-ui multiple> instead.
|
|
110
|
-
static #deprecationWarned = false;
|
|
111
|
-
|
|
112
|
-
get #valueSet() {
|
|
113
|
-
return new Set(this.value ? this.value.split(',').map(v => v.trim()).filter(Boolean) : []);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
connected() {
|
|
117
|
-
if (!UIToggleGroup.#deprecationWarned) {
|
|
118
|
-
UIToggleGroup.#deprecationWarned = true;
|
|
119
|
-
// #deprecationWarned is a one-shot PER CLASS (not per instance,
|
|
120
|
-
// matching UIFormElement's #labelWarned pattern) — the message can't
|
|
121
|
-
// branch on THIS instance's [single] alone without misleading a page
|
|
122
|
-
// that mixes single and non-single toggle-groups, so it states both
|
|
123
|
-
// mappings instead (gh#1369 review).
|
|
124
|
-
// eslint-disable-next-line no-console
|
|
125
|
-
console.warn(
|
|
126
|
-
'[AdiaUI] <toggle-group-ui> is deprecated (gh#1369, #1363 C1) — ' +
|
|
127
|
-
'migrate to <segmented-ui multiple> + <segment-ui> (multi-select, ' +
|
|
128
|
-
'the default) or plain <segmented-ui> with no [multiple] (when ' +
|
|
129
|
-
'[single] is set — note single-select never clears on re-click, ' +
|
|
130
|
-
'unlike [single]\'s clear-on-reclick). Same comma-separated value ' +
|
|
131
|
-
'encoding either way. Kept working as-is; no behavior change.',
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
if (!this.#bound) {
|
|
135
|
-
this.#bound = true;
|
|
136
|
-
this.addEventListener('click', this.#onClick);
|
|
137
|
-
this.addEventListener('keydown', this.#onKey);
|
|
138
|
-
}
|
|
139
|
-
this.setAttribute('role', 'group');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
render() {
|
|
143
|
-
const selected = this.#valueSet;
|
|
144
|
-
for (const opt of this.querySelectorAll('toggle-option-ui')) {
|
|
145
|
-
const optVal = opt.value || opt.getAttribute('value') || '';
|
|
146
|
-
const isSelected = selected.has(optVal);
|
|
147
|
-
// ADR-0056 (gh#1303): `selected` is the declared, reflected mechanism —
|
|
148
|
-
// converges onto <segment-ui>'s convention (opt's own render() stamps
|
|
149
|
-
// aria-pressed from it).
|
|
150
|
-
opt.selected = isSelected;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
#toggle(opt) {
|
|
155
|
-
if (opt.disabled) return;
|
|
156
|
-
const optVal = opt.value || opt.getAttribute('value') || '';
|
|
157
|
-
if (!optVal) return;
|
|
158
|
-
|
|
159
|
-
const selected = this.#valueSet;
|
|
160
|
-
|
|
161
|
-
if (this.single) {
|
|
162
|
-
if (selected.has(optVal)) {
|
|
163
|
-
selected.clear();
|
|
164
|
-
} else {
|
|
165
|
-
selected.clear();
|
|
166
|
-
selected.add(optVal);
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
if (selected.has(optVal)) selected.delete(optVal);
|
|
170
|
-
else selected.add(optVal);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
this.value = [...selected].join(',');
|
|
174
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { value: this.value } }));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
#onClick = (e) => {
|
|
178
|
-
const opt = e.target.closest('toggle-option-ui');
|
|
179
|
-
if (opt && this.contains(opt)) this.#toggle(opt);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
#onKey = (e) => {
|
|
183
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
184
|
-
e.preventDefault();
|
|
185
|
-
const opt = e.target.closest('toggle-option-ui');
|
|
186
|
-
if (opt && this.contains(opt)) this.#toggle(opt);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
disconnected() {
|
|
191
|
-
this.removeEventListener('click', this.#onClick);
|
|
192
|
-
this.removeEventListener('keydown', this.#onKey);
|
|
193
|
-
this.#bound = false;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/* DEPRECATED (gh#1369, #1363 C1, ADR-0057): <toggle-group-ui>/
|
|
2
|
-
<toggle-option-ui> are superseded by <segmented-ui multiple> +
|
|
3
|
-
<segment-ui> (segment.css owns the equivalent [multiple]-mode styling).
|
|
4
|
-
This file is kept as-is for existing consumers — no behavior change.
|
|
5
|
-
|
|
6
|
-
Safari 17.x bug: `:scope:not(...):hover` (Flavor A) and `:scope[selected]`
|
|
7
|
-
(Flavor B — attribute-removal restyle) both fail inside `@scope`.
|
|
8
|
-
Selectors moved out. The @scope is `(toggle-option-ui)` — NOT
|
|
9
|
-
`(toggle-group-ui)` — so the moved-out selectors target
|
|
10
|
-
`toggle-option-ui:hover` / `toggle-option-ui[selected]`. See
|
|
11
|
-
docs/BROWSER-COMPAT.md §3a; mirrors segment.css. */
|
|
12
|
-
toggle-option-ui:not([disabled]):hover {
|
|
13
|
-
--toggle-option-bg: var(--toggle-option-bg-hover);
|
|
14
|
-
--toggle-option-fg: var(--toggle-option-fg-hover);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/* ADR-0056 (gh#1303): converged onto <segment-ui>'s declared, reflected
|
|
18
|
-
[selected] prop, set by <toggle-group-ui> (toggle-group.class.js). */
|
|
19
|
-
toggle-option-ui[selected] {
|
|
20
|
-
--toggle-option-bg: var(--toggle-option-selected-bg);
|
|
21
|
-
--toggle-option-fg: var(--toggle-option-selected-fg);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@scope (toggle-group-ui) {
|
|
25
|
-
:where(:scope) {
|
|
26
|
-
/* ── Tokens ── */
|
|
27
|
-
--toggle-group-border-width: 1px;
|
|
28
|
-
--toggle-group-border-color: var(--a-ui-border);
|
|
29
|
-
--toggle-group-radius: var(--a-radius);
|
|
30
|
-
--toggle-group-height: var(--a-size);
|
|
31
|
-
text-align: start; /* §text-align-reset — blocks inheritance from centered ancestors */
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:scope {
|
|
35
|
-
box-sizing: border-box;
|
|
36
|
-
display: flex;
|
|
37
|
-
border: var(--toggle-group-border-width) solid var(--toggle-group-border-color);
|
|
38
|
-
border-radius: var(--toggle-group-radius);
|
|
39
|
-
overflow: hidden;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/* Display convention (ADR-0037): block-level by default; [inline] opts back to inline-level. */
|
|
43
|
-
:scope[inline] { display: inline-flex; }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@scope (toggle-option-ui) {
|
|
47
|
-
:where(:scope) {
|
|
48
|
-
/* ── Layout ── */
|
|
49
|
-
--toggle-option-gap: var(--a-space-1);
|
|
50
|
-
--toggle-option-height: var(--a-size);
|
|
51
|
-
--toggle-option-px: var(--a-ui-px);
|
|
52
|
-
--toggle-option-border-width: 1px;
|
|
53
|
-
--toggle-option-border-color: var(--a-ui-border);
|
|
54
|
-
|
|
55
|
-
/* ── Colors ── */
|
|
56
|
-
--toggle-option-bg: transparent;
|
|
57
|
-
--toggle-option-fg: var(--a-fg-muted);
|
|
58
|
-
--toggle-option-fg-hover: var(--md-sys-color-neutral-on-surface);
|
|
59
|
-
--toggle-option-bg-hover: var(--a-bg-muted);
|
|
60
|
-
--toggle-option-selected-bg: var(--md-sys-color-primary-container);
|
|
61
|
-
--toggle-option-selected-fg: var(--a-primary-bg);
|
|
62
|
-
--toggle-option-fg-disabled: var(--a-ui-text-disabled);
|
|
63
|
-
|
|
64
|
-
/* ── Typography ── */
|
|
65
|
-
--toggle-option-font-size: var(--a-ui-size);
|
|
66
|
-
|
|
67
|
-
/* ── Transition ── */
|
|
68
|
-
--toggle-option-duration: var(--a-duration-fast);
|
|
69
|
-
--toggle-option-easing: var(--a-easing);
|
|
70
|
-
|
|
71
|
-
/* ── State ── */
|
|
72
|
-
--toggle-option-focus-ring: var(--a-focus-ring);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
:scope {
|
|
76
|
-
box-sizing: border-box;
|
|
77
|
-
display: inline-flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
justify-content: center;
|
|
80
|
-
gap: var(--toggle-option-gap);
|
|
81
|
-
min-height: var(--toggle-option-height);
|
|
82
|
-
padding: 0 var(--toggle-option-px);
|
|
83
|
-
border: none;
|
|
84
|
-
background: var(--toggle-option-bg);
|
|
85
|
-
color: var(--toggle-option-fg);
|
|
86
|
-
font: inherit;
|
|
87
|
-
/* font-family floor — see segment.css rationale (inline default; this
|
|
88
|
-
scope's tokens don't use the -default suffix). */
|
|
89
|
-
font-family: var(--toggle-option-font-family, var(--a-font-family-ui));
|
|
90
|
-
font-size: var(--toggle-option-font-size);
|
|
91
|
-
cursor: pointer;
|
|
92
|
-
transition:
|
|
93
|
-
background var(--toggle-option-duration) var(--toggle-option-easing),
|
|
94
|
-
color var(--toggle-option-duration) var(--toggle-option-easing);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/* Adjacent options share borders */
|
|
98
|
-
:scope + :scope {
|
|
99
|
-
border-inline-start: var(--toggle-option-border-width) solid var(--toggle-option-border-color);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/* hover rule moved outside @scope — see Safari 17.x bug note at top. */
|
|
103
|
-
|
|
104
|
-
:scope:focus-visible {
|
|
105
|
-
outline: none;
|
|
106
|
-
box-shadow: var(--toggle-option-focus-ring);
|
|
107
|
-
border-color: transparent;
|
|
108
|
-
z-index: 1;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/* [selected] state rule moved outside @scope — see Safari 17.x bug note at top. */
|
|
112
|
-
|
|
113
|
-
:scope[disabled] {
|
|
114
|
-
--toggle-option-fg: var(--toggle-option-fg-disabled);
|
|
115
|
-
cursor: not-allowed;
|
|
116
|
-
pointer-events: none;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/* Icon sizing */
|
|
120
|
-
icon-ui {
|
|
121
|
-
--a-icon-size: var(--toggle-option-font-size);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
[data-text] {
|
|
125
|
-
white-space: nowrap;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `<toggle-group-ui>` — DEPRECATED (gh#1369) — use <segmented-ui multiple> + <segment-ui> instead. Multi-select button group (unlike <segmented-ui> which is single-select by default). Hosts <toggle-option-ui> children, each independently toggleable; emits change events with the active value set.
|
|
3
|
-
*
|
|
4
|
-
* @see https://ui-kit.exe.xyz/site/components/toggle-group
|
|
5
|
-
*
|
|
6
|
-
* Type declarations generated by scripts/build/dts-codegen.mjs from
|
|
7
|
-
* the component's `.a2ui.json` sidecar(s). Edit the source `.yaml`,
|
|
8
|
-
* run `npm run build:components`, then `npm run codegen:dts` to
|
|
9
|
-
* regenerate; or hand-author this file fully if rich event types are
|
|
10
|
-
* needed beyond what the yaml `events:` block can express.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { UIElement } from '../../core/element.js';
|
|
14
|
-
|
|
15
|
-
export interface ToggleGroupChangeEventDetail {
|
|
16
|
-
/** New toggle-group value. */
|
|
17
|
-
value: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type ToggleGroupChangeEvent = CustomEvent<ToggleGroupChangeEventDetail>;
|
|
21
|
-
|
|
22
|
-
export class UIToggleGroup extends UIElement {
|
|
23
|
-
/** When true, restrict to one active option (single-select) — clicking the already-selected option again CLEARS it (empty value), unlike a native radiogroup. Migration (gh#1369): [single]=true maps to plain <segmented-ui> (no [multiple]) — note segmented-ui's single-select never clears on re-click, it's standard radiogroup semantics; the default (false, multi-select) maps to <segmented-ui multiple>. */
|
|
24
|
-
single: boolean;
|
|
25
|
-
/** Comma-separated selected values */
|
|
26
|
-
value: string;
|
|
27
|
-
|
|
28
|
-
addEventListener(type: 'change', listener: (ev: ToggleGroupChangeEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
29
|
-
addEventListener<K extends keyof HTMLElementEventMap>(
|
|
30
|
-
type: K,
|
|
31
|
-
listener: (this: UIToggleGroup, ev: HTMLElementEventMap[K]) => unknown,
|
|
32
|
-
options?: boolean | AddEventListenerOptions,
|
|
33
|
-
): void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class UIToggleOption extends UIElement {
|
|
37
|
-
/** Disabled state — blocks pointer + keyboard activation. */
|
|
38
|
-
disabled: boolean;
|
|
39
|
-
/** Optional Phosphor icon name; renders as a leading icon. */
|
|
40
|
-
icon: string;
|
|
41
|
-
/** Whether this option is currently selected. Managed by the parent
|
|
42
|
-
<toggle-group-ui> container (ADR-0056) — don't set directly; the group's
|
|
43
|
-
`value` is the single source of truth. Converges onto <segment-ui>'s
|
|
44
|
-
declared reflected-prop mechanism. */
|
|
45
|
-
selected: boolean;
|
|
46
|
-
/** Visible label text. */
|
|
47
|
-
text: string;
|
|
48
|
-
/** Stable identifier matched against the parent group's `value`. */
|
|
49
|
-
value: string;
|
|
50
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# toggle-group — Examples
|
|
2
|
-
|
|
3
|
-
## icon group
|
|
4
|
-
|
|
5
|
-
```html
|
|
6
|
-
<toggle-group-ui value="bold">
|
|
7
|
-
<toggle-option-ui value="bold" icon="text-b"></toggle-option-ui>
|
|
8
|
-
<toggle-option-ui value="italic" icon="text-italic"></toggle-option-ui>
|
|
9
|
-
<toggle-option-ui value="underline" icon="text-underline"></toggle-option-ui>
|
|
10
|
-
</toggle-group-ui>
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## text group
|
|
14
|
-
|
|
15
|
-
```html
|
|
16
|
-
<toggle-group-ui value="week">
|
|
17
|
-
<toggle-option-ui value="day" text="Day"></toggle-option-ui>
|
|
18
|
-
<toggle-option-ui value="week" text="Week"></toggle-option-ui>
|
|
19
|
-
<toggle-option-ui value="month" text="Month"></toggle-option-ui>
|
|
20
|
-
<toggle-option-ui value="year" text="Year"></toggle-option-ui>
|
|
21
|
-
</toggle-group-ui>
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## single select
|
|
25
|
-
|
|
26
|
-
```html
|
|
27
|
-
<toggle-group-ui value="left" single>
|
|
28
|
-
<toggle-option-ui value="left" icon="text-align-left"></toggle-option-ui>
|
|
29
|
-
<toggle-option-ui value="center" icon="text-align-center"></toggle-option-ui>
|
|
30
|
-
<toggle-option-ui value="right" icon="text-align-right"></toggle-option-ui>
|
|
31
|
-
<toggle-option-ui value="justify" icon="text-align-justify"></toggle-option-ui>
|
|
32
|
-
</toggle-group-ui>
|
|
33
|
-
```
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `<toggle-option-ui>` — auto-registers the tag on import.
|
|
3
|
-
*
|
|
4
|
-
* For non-side-effect class import (test isolation, tag override), use
|
|
5
|
-
* the `class` subpath:
|
|
6
|
-
*
|
|
7
|
-
* import { UIToggleOption, UIToggleGroup } from '@adia-ai/web-components/components/toggle-group/class';
|
|
8
|
-
*
|
|
9
|
-
* @see ../../USAGE.md#registration--auto-vs-explicit
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { defineIfFree } from '../../core/register.js';
|
|
13
|
-
import { UIToggleOption, UIToggleGroup } from './toggle-group.class.js';
|
|
14
|
-
|
|
15
|
-
defineIfFree('toggle-option-ui', UIToggleOption);
|
|
16
|
-
defineIfFree('toggle-group-ui', UIToggleGroup);
|
|
17
|
-
|
|
18
|
-
export { UIToggleOption, UIToggleGroup };
|