@fusion.dev/helix-headless 0.142.1 → 0.144.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.
- package/custom-elements.json +25381 -1202
- package/dist/accordion/item/accordion-item.d.ts +38 -2
- package/dist/accordion/item/accordion-item.js +38 -6
- package/dist/accordion/root/accordion-root.d.ts +23 -1
- package/dist/accordion/root/accordion-root.js +39 -3
- package/dist/announcement/root/announcement-root.d.ts +11 -7
- package/dist/announcement/root/announcement-root.js +1 -1
- package/dist/app-header/root/app-header-root.d.ts +21 -0
- package/dist/app-header/root/app-header-root.js +31 -5
- package/dist/area-chart/root/area-chart-root.d.ts +12 -4
- package/dist/area-chart/root/area-chart-root.js +39 -11
- package/dist/avatar/group/avatar-group.d.ts +24 -3
- package/dist/avatar/group/avatar-group.js +34 -2
- package/dist/avatar/root/avatar-root.d.ts +17 -1
- package/dist/avatar/root/avatar-root.js +31 -10
- package/dist/badge/root/badge-root.d.ts +12 -0
- package/dist/badge/root/badge-root.js +1 -1
- package/dist/bar-chart/root/bar-chart-root.d.ts +30 -5
- package/dist/bar-chart/root/bar-chart-root.js +58 -21
- package/dist/blockquote/root/blockquote-root.d.ts +12 -7
- package/dist/blockquote/root/blockquote-root.js +6 -4
- package/dist/breadcrumbs/root/breadcrumbs-root.d.ts +9 -3
- package/dist/breadcrumbs/root/breadcrumbs-root.js +9 -1
- package/dist/button/root/button-root.d.ts +84 -1
- package/dist/button/root/button-root.js +81 -3
- package/dist/callout/root/callout-root.d.ts +32 -6
- package/dist/callout/root/callout-root.js +26 -7
- package/dist/canvas/root/canvas-root.d.ts +1 -0
- package/dist/canvas/root/canvas-root.js +10 -1
- package/dist/card/root/card-root.d.ts +30 -1
- package/dist/card/root/card-root.js +38 -5
- package/dist/carousel/root/carousel-root.d.ts +47 -5
- package/dist/carousel/root/carousel-root.js +53 -21
- package/dist/chat/composer/chat-composer.d.ts +13 -11
- package/dist/chat/composer/chat-composer.js +6 -12
- package/dist/chat/message/chat-message.js +8 -1
- package/dist/chat/root/chat-root.d.ts +1 -0
- package/dist/chat/root/chat-root.js +2 -1
- package/dist/checkbox/root/checkbox-root.d.ts +7 -0
- package/dist/checkbox/root/checkbox-root.js +9 -3
- package/dist/checkbox-group/root/checkbox-group-root.d.ts +116 -33
- package/dist/checkbox-group/root/checkbox-group-root.js +141 -44
- package/dist/code/root/code-root.d.ts +1 -1
- package/dist/code-block/lines.d.ts +13 -0
- package/dist/code-block/lines.js +2 -0
- package/dist/code-block/root/code-block-root.d.ts +49 -0
- package/dist/code-block/root/code-block-root.js +44 -3
- package/dist/color-input/root/color-input-root.d.ts +60 -2
- package/dist/color-input/root/color-input-root.js +55 -7
- package/dist/color-picker/channels.d.ts +26 -0
- package/dist/color-picker/channels.js +84 -0
- package/dist/color-picker/root/color-picker-root.d.ts +118 -12
- package/dist/color-picker/root/color-picker-root.js +183 -13
- package/dist/combobox/root/combobox-root.d.ts +126 -3
- package/dist/combobox/root/combobox-root.js +224 -21
- package/dist/command/root/command-root.d.ts +47 -10
- package/dist/command/root/command-root.js +45 -4
- package/dist/copy-button/from.d.ts +22 -0
- package/dist/copy-button/from.js +28 -0
- package/dist/copy-button/root/copy-button-root.d.ts +48 -7
- package/dist/copy-button/root/copy-button-root.js +54 -8
- package/dist/data-table/root/data-table-root.d.ts +164 -10
- package/dist/data-table/root/data-table-root.js +488 -57
- package/dist/date-input/root/date-input-root.d.ts +123 -9
- package/dist/date-input/root/date-input-root.js +147 -45
- package/dist/date-picker/root/date-picker-root.d.ts +229 -18
- package/dist/date-picker/root/date-picker-root.js +342 -46
- package/dist/dialog/description.d.ts +9 -0
- package/dist/dialog/description.js +14 -0
- package/dist/dialog/root/dialog-root.d.ts +101 -10
- package/dist/dialog/root/dialog-root.js +83 -4
- package/dist/donut-chart/root/donut-chart-root.d.ts +61 -16
- package/dist/donut-chart/root/donut-chart-root.js +48 -13
- package/dist/drawer/root/drawer-root.d.ts +93 -7
- package/dist/drawer/root/drawer-root.js +126 -5
- package/dist/drawer/swipe-start.d.ts +9 -0
- package/dist/drawer/swipe-start.js +12 -0
- package/dist/drilldown/item/drilldown-item.d.ts +16 -13
- package/dist/drilldown/item/drilldown-item.js +6 -2
- package/dist/drilldown/root/drilldown-root.d.ts +21 -5
- package/dist/drilldown/root/drilldown-root.js +26 -10
- package/dist/element-events.generated.js +42 -13
- package/dist/empty/root/empty-root.d.ts +1 -1
- package/dist/file-input/root/file-input-root.d.ts +65 -1
- package/dist/file-input/root/file-input-root.js +76 -12
- package/dist/file-input/screen.d.ts +35 -0
- package/dist/file-input/screen.js +49 -0
- package/dist/filter-input/menu/filter-menu.d.ts +9 -0
- package/dist/filter-input/menu/filter-menu.js +8 -0
- package/dist/filter-input/root/filter-input-root.d.ts +43 -6
- package/dist/filter-input/root/filter-input-root.js +89 -10
- package/dist/filter-input/suggest.d.ts +17 -0
- package/dist/filter-input/suggest.js +23 -0
- package/dist/format-date/options.d.ts +33 -0
- package/dist/format-date/options.js +42 -0
- package/dist/format-date/root/format-date-root.d.ts +62 -3
- package/dist/format-date/root/format-date-root.js +78 -37
- package/dist/graph/root/graph-root.d.ts +24 -3
- package/dist/graph/root/graph-root.js +66 -12
- package/dist/heatmap/root/buckets.d.ts +2 -1
- package/dist/heatmap/root/buckets.js +5 -1
- package/dist/heatmap/root/heatmap-root.d.ts +47 -9
- package/dist/heatmap/root/heatmap-root.js +46 -18
- package/dist/icon/index.d.ts +2 -0
- package/dist/icon/index.js +2 -0
- package/dist/icon/registry.d.ts +37 -0
- package/dist/icon/registry.js +83 -0
- package/dist/icon/root/icon-root.d.ts +53 -6
- package/dist/icon/root/icon-root.js +72 -4
- package/dist/icon/root/index.d.ts +2 -0
- package/dist/icon/root/index.js +2 -0
- package/dist/icon/set.d.ts +1 -0
- package/dist/icon/set.js +3 -0
- package/dist/icon-button/root/icon-button-root.d.ts +1 -1
- package/dist/image/root/image-root.d.ts +23 -2
- package/dist/image/root/image-root.js +23 -4
- package/dist/input/root/input-root.d.ts +62 -9
- package/dist/input/root/input-root.js +61 -5
- package/dist/kbd/root/kbd-root.d.ts +26 -11
- package/dist/kbd/root/kbd-root.js +35 -38
- package/dist/kbd/shortcut.d.ts +18 -0
- package/dist/kbd/shortcut.js +35 -0
- package/dist/legend/hidden-series.d.ts +8 -0
- package/dist/legend/hidden-series.js +13 -0
- package/dist/legend/root/legend-root.d.ts +63 -0
- package/dist/legend/root/legend-root.js +61 -7
- package/dist/lightbox/item/lightbox-item.d.ts +17 -1
- package/dist/lightbox/item/lightbox-item.js +10 -1
- package/dist/lightbox/root/lightbox-root.d.ts +77 -6
- package/dist/lightbox/root/lightbox-root.js +116 -5
- package/dist/line-chart/root/line-chart-root.d.ts +29 -4
- package/dist/line-chart/root/line-chart-root.js +58 -17
- package/dist/list/item/list-item.d.ts +11 -5
- package/dist/list/item/list-item.js +5 -6
- package/dist/listbox/range.d.ts +17 -0
- package/dist/listbox/range.js +5 -0
- package/dist/listbox/root/listbox-root.d.ts +184 -4
- package/dist/listbox/root/listbox-root.js +229 -23
- package/dist/loader/busy.d.ts +17 -0
- package/dist/loader/busy.js +24 -0
- package/dist/loader/root/loader-root.d.ts +37 -0
- package/dist/loader/root/loader-root.js +52 -3
- package/dist/map/root/map-root.d.ts +19 -4
- package/dist/map/root/map-root.js +36 -7
- package/dist/megamenu/root/megamenu-root.d.ts +10 -1
- package/dist/megamenu/root/megamenu-root.js +10 -1
- package/dist/menu/item/menu-item.d.ts +41 -12
- package/dist/menu/item/menu-item.js +46 -3
- package/dist/menu/root/menu-root.d.ts +32 -2
- package/dist/menu/root/menu-root.js +48 -8
- package/dist/meter/root/meter-root.d.ts +13 -0
- package/dist/meter/root/meter-root.js +24 -5
- package/dist/navigation/root/navigation-root.d.ts +10 -2
- package/dist/navigation/root/navigation-root.js +13 -2
- package/dist/notifications/feed-keys.d.ts +10 -0
- package/dist/notifications/feed-keys.js +14 -0
- package/dist/notifications/group/notification-group.d.ts +1 -0
- package/dist/notifications/notification/notification.d.ts +29 -0
- package/dist/notifications/notification/notification.js +51 -3
- package/dist/notifications/root/notifications-root.d.ts +49 -0
- package/dist/notifications/root/notifications-root.js +76 -2
- package/dist/number-input/root/number-input-root.d.ts +109 -7
- package/dist/number-input/root/number-input-root.js +109 -21
- package/dist/object-inspector/root/object-inspector-root.d.ts +49 -5
- package/dist/object-inspector/root/object-inspector-root.js +92 -12
- package/dist/option/root/option-root.d.ts +58 -6
- package/dist/option/root/option-root.js +35 -5
- package/dist/outline/root/outline-root.d.ts +13 -2
- package/dist/outline/root/outline-root.js +4 -2
- package/dist/pagination/root/pagination-root.d.ts +19 -1
- package/dist/pagination/root/pagination-root.js +49 -9
- package/dist/pagination/size/pagination-size.d.ts +13 -3
- package/dist/pagination/size/pagination-size.js +7 -0
- package/dist/pin-input/format.d.ts +7 -0
- package/dist/pin-input/format.js +16 -0
- package/dist/pin-input/root/pin-input-root.d.ts +37 -0
- package/dist/pin-input/root/pin-input-root.js +48 -7
- package/dist/popover/root/popover-root.d.ts +78 -3
- package/dist/popover/root/popover-root.js +74 -5
- package/dist/progress/root/progress-root.d.ts +23 -1
- package/dist/progress/root/progress-root.js +40 -10
- package/dist/qr-code/export.d.ts +31 -0
- package/dist/qr-code/export.js +10 -0
- package/dist/qr-code/root/qr-code-root.d.ts +45 -0
- package/dist/qr-code/root/qr-code-root.js +78 -3
- package/dist/radio/group/radio-group.d.ts +64 -0
- package/dist/radio/group/radio-group.js +66 -12
- package/dist/radio/root/radio-root.d.ts +8 -5
- package/dist/radio/root/radio-root.js +1 -2
- package/dist/rating/root/rating-root.d.ts +49 -1
- package/dist/rating/root/rating-root.js +69 -10
- package/dist/scatter-chart/root/scatter-chart-root.d.ts +17 -3
- package/dist/scatter-chart/root/scatter-chart-root.js +40 -14
- package/dist/select/root/select-root.d.ts +93 -3
- package/dist/select/root/select-root.js +111 -13
- package/dist/skeleton/root/skeleton-root.d.ts +39 -3
- package/dist/skeleton/root/skeleton-root.js +33 -4
- package/dist/skip-link/root/skip-link-root.d.ts +10 -0
- package/dist/skip-link/root/skip-link-root.js +15 -1
- package/dist/slider/root/slider-root.d.ts +59 -2
- package/dist/slider/root/slider-root.js +82 -8
- package/dist/sparkline/root/sparkline-root.d.ts +9 -10
- package/dist/speed-dial/item/speed-dial-item.d.ts +11 -5
- package/dist/speed-dial/item/speed-dial-item.js +7 -2
- package/dist/speed-dial/root/speed-dial-root.d.ts +15 -4
- package/dist/speed-dial/root/speed-dial-root.js +19 -5
- package/dist/splitter/root/splitter-root.d.ts +28 -6
- package/dist/splitter/root/splitter-root.js +35 -1
- package/dist/stat/root/stat-root.d.ts +9 -1
- package/dist/stat/root/stat-root.js +15 -2
- package/dist/steps/root/steps-root.js +1 -1
- package/dist/steps/step/step.d.ts +1 -0
- package/dist/steps/step/step.js +1 -1
- package/dist/switch/root/switch-root.d.ts +14 -2
- package/dist/switch/root/switch-root.js +7 -1
- package/dist/table/cell/table-cell.d.ts +24 -4
- package/dist/table/cell/table-cell.js +21 -1
- package/dist/table/column/table-column.d.ts +32 -6
- package/dist/table/column/table-column.js +36 -6
- package/dist/table/root/table-root.d.ts +94 -3
- package/dist/table/root/table-root.js +128 -5
- package/dist/table/row/table-row.d.ts +7 -0
- package/dist/table/row/table-row.js +9 -1
- package/dist/tabs/root/tabs-root.d.ts +6 -1
- package/dist/tabs/root/tabs-root.js +6 -2
- package/dist/tag/group/tag-group.d.ts +107 -0
- package/dist/tag/group/tag-group.js +157 -0
- package/dist/tag/index.d.ts +1 -0
- package/dist/tag/index.js +1 -0
- package/dist/tag/root/tag-root.d.ts +83 -1
- package/dist/tag/root/tag-root.js +87 -17
- package/dist/tag/selection.d.ts +10 -0
- package/dist/tag/selection.js +12 -0
- package/dist/textarea/grow.d.ts +22 -0
- package/dist/textarea/grow.js +20 -0
- package/dist/textarea/root/textarea-root.d.ts +13 -0
- package/dist/textarea/root/textarea-root.js +10 -2
- package/dist/time-input/root/time-input-root.d.ts +71 -6
- package/dist/time-input/root/time-input-root.js +110 -44
- package/dist/time-picker/root/time-picker-root.d.ts +155 -26
- package/dist/time-picker/root/time-picker-root.js +192 -63
- package/dist/toast/hotkey.d.ts +22 -0
- package/dist/toast/hotkey.js +23 -0
- package/dist/toast/item/toast-item.d.ts +16 -1
- package/dist/toast/item/toast-item.js +41 -13
- package/dist/toast/root/toast-root.d.ts +105 -8
- package/dist/toast/root/toast-root.js +209 -4
- package/dist/toggle/group/toggle-group.d.ts +95 -16
- package/dist/toggle/group/toggle-group.js +99 -13
- package/dist/toggle/root/toggle-root.d.ts +26 -11
- package/dist/toggle/root/toggle-root.js +14 -6
- package/dist/toolbar/root/toolbar-root.d.ts +55 -15
- package/dist/toolbar/root/toolbar-root.js +99 -16
- package/dist/tooltip/focus-target.d.ts +6 -0
- package/dist/tooltip/focus-target.js +9 -0
- package/dist/tooltip/root/tooltip-root.d.ts +73 -15
- package/dist/tooltip/root/tooltip-root.js +96 -7
- package/dist/tour/naming.d.ts +30 -0
- package/dist/tour/naming.js +10 -0
- package/dist/tour/root/tour-root.d.ts +67 -3
- package/dist/tour/root/tour-root.js +105 -17
- package/dist/tour/stop/tour-stop.d.ts +65 -3
- package/dist/tour/stop/tour-stop.js +61 -11
- package/dist/tour/wait.d.ts +11 -0
- package/dist/tour/wait.js +19 -0
- package/dist/tree/item/tree-item.d.ts +21 -5
- package/dist/tree/item/tree-item.js +14 -4
- package/dist/tree/root/tree-root.d.ts +29 -5
- package/dist/tree/root/tree-root.js +64 -8
- package/dist/trend/root/trend-root.d.ts +36 -1
- package/dist/trend/root/trend-root.js +41 -15
- package/dist/video/root/keys.d.ts +5 -0
- package/dist/video/root/keys.js +13 -1
- package/dist/video/root/video-root.d.ts +19 -0
- package/dist/video/root/video-root.js +48 -4
- package/dist/video-playlist/menu/video-playlist-menu.d.ts +20 -2
- package/dist/video-playlist/menu/video-playlist-menu.js +27 -5
- package/dist/video-playlist/root/video-playlist-root.js +6 -3
- package/dist/virtual-list/root/virtual-list-root.d.ts +52 -4
- package/dist/virtual-list/root/virtual-list-root.js +103 -21
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +9140 -1149
- package/types/svelte.d.ts +1 -0
- package/types/vue.d.ts +2089 -267
|
@@ -15,12 +15,18 @@ let HelixHeadlessInput = class HelixHeadlessInput extends MixinControllerValue(M
|
|
|
15
15
|
target: () => this.partNamed('control'),
|
|
16
16
|
});
|
|
17
17
|
this.announcesInput = true;
|
|
18
|
+
this.autocapitalize = '';
|
|
18
19
|
this.autocomplete = '';
|
|
19
20
|
this.clearable = false;
|
|
20
21
|
this.clearLabel = 'Clear';
|
|
22
|
+
this.enterKeyHint = '';
|
|
23
|
+
this.inputMode = '';
|
|
24
|
+
this.max = '';
|
|
25
|
+
this.min = '';
|
|
21
26
|
this.pattern = '';
|
|
22
27
|
this.placeholder = '';
|
|
23
28
|
this.readOnly = false;
|
|
29
|
+
this.reveal = false;
|
|
24
30
|
this.revealed = false;
|
|
25
31
|
this.handleInput = (event) => {
|
|
26
32
|
event.stopPropagation();
|
|
@@ -30,19 +36,27 @@ let HelixHeadlessInput = class HelixHeadlessInput extends MixinControllerValue(M
|
|
|
30
36
|
restoreValue(control, this.value);
|
|
31
37
|
};
|
|
32
38
|
this.handleClear = () => {
|
|
33
|
-
this.requestValue('')
|
|
39
|
+
if (this.value !== '' && this.requestValue('')) {
|
|
40
|
+
this.announceChange();
|
|
41
|
+
this.dispatchEvent(new Event('helix-clear', { bubbles: true, composed: true }));
|
|
42
|
+
}
|
|
34
43
|
const control = this.control;
|
|
35
44
|
if (control) {
|
|
36
45
|
restoreValue(control, this.value);
|
|
37
46
|
control.focus();
|
|
38
47
|
}
|
|
39
48
|
};
|
|
49
|
+
this.handleKeypress = (event) => {
|
|
50
|
+
if (event.key === 'Enter' && !event.defaultPrevented) {
|
|
51
|
+
this.submitImplicitly();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
40
54
|
this.handleChange = (event) => {
|
|
41
55
|
event.stopPropagation();
|
|
42
56
|
this.announceChange();
|
|
43
57
|
};
|
|
44
|
-
this.reveal = false;
|
|
45
58
|
this.revealLabel = 'Show password';
|
|
59
|
+
this.step = '';
|
|
46
60
|
this.type = 'text';
|
|
47
61
|
}
|
|
48
62
|
get effectiveType() {
|
|
@@ -88,6 +102,9 @@ let HelixHeadlessInput = class HelixHeadlessInput extends MixinControllerValue(M
|
|
|
88
102
|
get control() {
|
|
89
103
|
return this.partNamed('control');
|
|
90
104
|
}
|
|
105
|
+
get blocksImplicitSubmission() {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
91
108
|
sync() {
|
|
92
109
|
this.internals.setFormValue(this.value);
|
|
93
110
|
const control = this.control;
|
|
@@ -103,6 +120,20 @@ let HelixHeadlessInput = class HelixHeadlessInput extends MixinControllerValue(M
|
|
|
103
120
|
select() {
|
|
104
121
|
this.control?.select();
|
|
105
122
|
}
|
|
123
|
+
stepUp(count = 1) {
|
|
124
|
+
this.control?.stepUp(count);
|
|
125
|
+
this.takeStep();
|
|
126
|
+
}
|
|
127
|
+
stepDown(count = 1) {
|
|
128
|
+
this.control?.stepDown(count);
|
|
129
|
+
this.takeStep();
|
|
130
|
+
}
|
|
131
|
+
takeStep() {
|
|
132
|
+
const control = this.control;
|
|
133
|
+
if (control) {
|
|
134
|
+
this.value = control.value;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
106
137
|
willUpdate(changed) {
|
|
107
138
|
super.willUpdate(changed);
|
|
108
139
|
if (!this.hasUpdated) {
|
|
@@ -134,6 +165,12 @@ let HelixHeadlessInput = class HelixHeadlessInput extends MixinControllerValue(M
|
|
|
134
165
|
pattern=${this.pattern || nothing}
|
|
135
166
|
minlength=${this.minLength ?? nothing}
|
|
136
167
|
maxlength=${this.maxLength ?? nothing}
|
|
168
|
+
min=${this.min || nothing}
|
|
169
|
+
max=${this.max || nothing}
|
|
170
|
+
step=${this.step || nothing}
|
|
171
|
+
inputmode=${this.inputMode || nothing}
|
|
172
|
+
enterkeyhint=${this.enterKeyHint || nothing}
|
|
173
|
+
autocapitalize=${this.autocapitalize || nothing}
|
|
137
174
|
aria-describedby=${this.describedBy ?? nothing}
|
|
138
175
|
aria-invalid=${this.invalidity ?? nothing}
|
|
139
176
|
?disabled=${this.isDisabled}
|
|
@@ -141,6 +178,7 @@ let HelixHeadlessInput = class HelixHeadlessInput extends MixinControllerValue(M
|
|
|
141
178
|
?required=${this.required}
|
|
142
179
|
@input=${this.handleInput}
|
|
143
180
|
@change=${this.handleChange}
|
|
181
|
+
@keypress=${this.handleKeypress}
|
|
144
182
|
/>
|
|
145
183
|
<slot name="end"></slot>
|
|
146
184
|
<!-- In the tab order, unlike the browser's own search clear, which is not
|
|
@@ -176,6 +214,9 @@ let HelixHeadlessInput = class HelixHeadlessInput extends MixinControllerValue(M
|
|
|
176
214
|
${this.renderHint()}${this.renderFeedback()}`;
|
|
177
215
|
}
|
|
178
216
|
};
|
|
217
|
+
__decorate([
|
|
218
|
+
property()
|
|
219
|
+
], HelixHeadlessInput.prototype, "autocapitalize", void 0);
|
|
179
220
|
__decorate([
|
|
180
221
|
property()
|
|
181
222
|
], HelixHeadlessInput.prototype, "autocomplete", void 0);
|
|
@@ -185,9 +226,21 @@ __decorate([
|
|
|
185
226
|
__decorate([
|
|
186
227
|
property({ attribute: 'clear-label' })
|
|
187
228
|
], HelixHeadlessInput.prototype, "clearLabel", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
property({ attribute: 'enterkeyhint' })
|
|
231
|
+
], HelixHeadlessInput.prototype, "enterKeyHint", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
property({ attribute: 'inputmode' })
|
|
234
|
+
], HelixHeadlessInput.prototype, "inputMode", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
property()
|
|
237
|
+
], HelixHeadlessInput.prototype, "max", void 0);
|
|
188
238
|
__decorate([
|
|
189
239
|
property({ attribute: 'maxlength', type: Number })
|
|
190
240
|
], HelixHeadlessInput.prototype, "maxLength", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
property()
|
|
243
|
+
], HelixHeadlessInput.prototype, "min", void 0);
|
|
191
244
|
__decorate([
|
|
192
245
|
property({ attribute: 'minlength', type: Number })
|
|
193
246
|
], HelixHeadlessInput.prototype, "minLength", void 0);
|
|
@@ -200,15 +253,18 @@ __decorate([
|
|
|
200
253
|
__decorate([
|
|
201
254
|
property({ attribute: 'readonly', reflect: true, type: Boolean })
|
|
202
255
|
], HelixHeadlessInput.prototype, "readOnly", void 0);
|
|
203
|
-
__decorate([
|
|
204
|
-
state()
|
|
205
|
-
], HelixHeadlessInput.prototype, "revealed", void 0);
|
|
206
256
|
__decorate([
|
|
207
257
|
property({ type: Boolean })
|
|
208
258
|
], HelixHeadlessInput.prototype, "reveal", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
state()
|
|
261
|
+
], HelixHeadlessInput.prototype, "revealed", void 0);
|
|
209
262
|
__decorate([
|
|
210
263
|
property({ attribute: 'reveal-label' })
|
|
211
264
|
], HelixHeadlessInput.prototype, "revealLabel", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
property()
|
|
267
|
+
], HelixHeadlessInput.prototype, "step", void 0);
|
|
212
268
|
__decorate([
|
|
213
269
|
property()
|
|
214
270
|
], HelixHeadlessInput.prototype, "type", void 0);
|
|
@@ -17,6 +17,12 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
17
17
|
* The element binds the shortcut only when `within` is set. By default it draws
|
|
18
18
|
* the key and listens for nothing.
|
|
19
19
|
*
|
|
20
|
+
* **`for` names the control the shortcut works**, and the key writes its chord
|
|
21
|
+
* onto that control's `aria-keyshortcuts`, in the platform's words (`Meta+K`
|
|
22
|
+
* on an Apple keyboard, `Control+K` elsewhere), so a screen reader announces
|
|
23
|
+
* the shortcut with the control. A chord the page wrote there itself is left
|
|
24
|
+
* alone, and the key takes back only what it added.
|
|
25
|
+
*
|
|
20
26
|
* @since 0.1.0
|
|
21
27
|
* @status stable
|
|
22
28
|
* @category typography
|
|
@@ -31,11 +37,25 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
31
37
|
*/
|
|
32
38
|
export declare class HelixHeadlessKbd extends HelixElement {
|
|
33
39
|
/**
|
|
34
|
-
* The
|
|
40
|
+
* The id of the control the shortcut works, which is given the chord as its
|
|
41
|
+
* `aria-keyshortcuts`.
|
|
42
|
+
*
|
|
43
|
+
* Names an element in the same tree, the way `Tooltip.for` does. Separate
|
|
44
|
+
* from `within`, which says where the key listens: a key can describe a
|
|
45
|
+
* shortcut the page binds itself.
|
|
46
|
+
*/
|
|
47
|
+
for: string;
|
|
48
|
+
/**
|
|
49
|
+
* The key or chord to show, such as `mod+k`, `?`, or `/`.
|
|
35
50
|
*
|
|
36
51
|
* `mod` is the platform's own command modifier, which is the reason to write
|
|
37
52
|
* a chord here rather than a glyph: it is the one token whose right answer
|
|
38
53
|
* differs per reader.
|
|
54
|
+
*
|
|
55
|
+
* A symbol such as `?` or `!` is written as itself, without `shift`. It is
|
|
56
|
+
* matched whether or not Shift was held to type it, since that depends on
|
|
57
|
+
* the keyboard layout. Bound to the document, a chord that types a character
|
|
58
|
+
* is not taken from a field a reader is typing in.
|
|
39
59
|
*/
|
|
40
60
|
keys: string;
|
|
41
61
|
/**
|
|
@@ -52,8 +72,13 @@ export declare class HelixHeadlessKbd extends HelixElement {
|
|
|
52
72
|
within?: 'control' | 'document';
|
|
53
73
|
/** The element the listener is on, kept so it can be taken off the same one. */
|
|
54
74
|
private listening;
|
|
75
|
+
/** The control and the chord written onto it, so the same pair is taken back. */
|
|
76
|
+
private described;
|
|
55
77
|
connectedCallback(): void;
|
|
56
78
|
disconnectedCallback(): void;
|
|
79
|
+
/** Writes the chord onto the control `for` names, taking back one written before. */
|
|
80
|
+
private describe;
|
|
81
|
+
private undescribe;
|
|
57
82
|
protected updated(changed: Map<string, unknown>): void;
|
|
58
83
|
/**
|
|
59
84
|
* The chord as this reader's keyboard labels it.
|
|
@@ -66,16 +91,6 @@ export declare class HelixHeadlessKbd extends HelixElement {
|
|
|
66
91
|
private listen;
|
|
67
92
|
private deafen;
|
|
68
93
|
private readonly handleKeydown;
|
|
69
|
-
/**
|
|
70
|
-
* Whether this chord is one bare character, and so indistinguishable from
|
|
71
|
-
* typing.
|
|
72
|
-
*
|
|
73
|
-
* A single part means no modifier, and one code point means a character
|
|
74
|
-
* rather than a name: `/` and `?` are printable, `escape` and `enter` are not.
|
|
75
|
-
*/
|
|
76
|
-
private get printable();
|
|
77
|
-
/** Whether a press is this chord, modifiers and all. */
|
|
78
|
-
private matches_;
|
|
79
94
|
protected firstUpdated(changed: PropertyValues): void;
|
|
80
95
|
protected render(): TemplateResult;
|
|
81
96
|
}
|
|
@@ -4,9 +4,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { customElement, HelixElement, HelixShortcutEvent } from '@fusion.dev/helix-core';
|
|
7
|
+
import { ariaChord, chordParts, customElement, elementById, HelixElement, HelixShortcutEvent, matchesChord, onApple, printableChord, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
|
+
import { claimShortcut, releaseShortcut } from '../shortcut.js';
|
|
10
11
|
const typing = (node) => {
|
|
11
12
|
if (node instanceof HTMLTextAreaElement) {
|
|
12
13
|
return true;
|
|
@@ -66,20 +67,22 @@ const ELSEWHERE = {
|
|
|
66
67
|
tab: 'Tab',
|
|
67
68
|
up: '↑',
|
|
68
69
|
};
|
|
69
|
-
const onApple = () => typeof navigator !== 'undefined' && /mac|iphone|ipad|ipod/i.test(navigator.userAgent);
|
|
70
70
|
let HelixHeadlessKbd = class HelixHeadlessKbd extends HelixElement {
|
|
71
71
|
constructor() {
|
|
72
72
|
super(...arguments);
|
|
73
|
+
this.for = '';
|
|
73
74
|
this.keys = '';
|
|
74
75
|
this.handleKeydown = (event) => {
|
|
75
76
|
const press = event;
|
|
76
77
|
if (press.isComposing) {
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
|
-
if (this.within === 'document' &&
|
|
80
|
+
if (this.within === 'document' &&
|
|
81
|
+
printableChord(this.keys) &&
|
|
82
|
+
typing(press.composedPath()[0])) {
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
|
-
if (!this.
|
|
85
|
+
if (!matchesChord(press, this.keys, onApple())) {
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
88
|
const shortcut = new HelixShortcutEvent({ keys: this.keys });
|
|
@@ -92,10 +95,30 @@ let HelixHeadlessKbd = class HelixHeadlessKbd extends HelixElement {
|
|
|
92
95
|
connectedCallback() {
|
|
93
96
|
super.connectedCallback();
|
|
94
97
|
this.listen();
|
|
98
|
+
requestAnimationFrame(() => this.describe());
|
|
95
99
|
}
|
|
96
100
|
disconnectedCallback() {
|
|
97
101
|
super.disconnectedCallback();
|
|
98
102
|
this.deafen();
|
|
103
|
+
this.undescribe();
|
|
104
|
+
}
|
|
105
|
+
describe() {
|
|
106
|
+
const control = this.isConnected && this.for !== '' ? elementById(this, this.for) : null;
|
|
107
|
+
const chord = ariaChord(this.keys, onApple());
|
|
108
|
+
if (control === this.described?.control && chord === this.described?.chord) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.undescribe();
|
|
112
|
+
if (control && chord !== '') {
|
|
113
|
+
claimShortcut(control, chord);
|
|
114
|
+
this.described = { chord, control };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
undescribe() {
|
|
118
|
+
if (this.described) {
|
|
119
|
+
releaseShortcut(this.described.control, this.described.chord);
|
|
120
|
+
this.described = undefined;
|
|
121
|
+
}
|
|
99
122
|
}
|
|
100
123
|
updated(changed) {
|
|
101
124
|
super.updated(changed);
|
|
@@ -103,15 +126,15 @@ let HelixHeadlessKbd = class HelixHeadlessKbd extends HelixElement {
|
|
|
103
126
|
this.deafen();
|
|
104
127
|
this.listen();
|
|
105
128
|
}
|
|
129
|
+
if ((changed.has('for') && changed.get('for') !== undefined) ||
|
|
130
|
+
(changed.has('keys') && changed.get('keys') !== undefined)) {
|
|
131
|
+
this.describe();
|
|
132
|
+
}
|
|
106
133
|
}
|
|
107
134
|
get label() {
|
|
108
135
|
const apple = !this.hydrating && onApple();
|
|
109
136
|
const names = apple ? APPLE : ELSEWHERE;
|
|
110
|
-
const parts = this.keys
|
|
111
|
-
.split('+')
|
|
112
|
-
.map((part) => part.trim())
|
|
113
|
-
.filter((part) => part !== '')
|
|
114
|
-
.map((part) => names[part.toLowerCase()] ?? (part.length === 1 ? part.toUpperCase() : part));
|
|
137
|
+
const parts = chordParts(this.keys).map((part) => names[part.toLowerCase()] ?? (part.length === 1 ? part.toUpperCase() : part));
|
|
115
138
|
return parts.join(apple ? '' : '+');
|
|
116
139
|
}
|
|
117
140
|
listen() {
|
|
@@ -129,35 +152,6 @@ let HelixHeadlessKbd = class HelixHeadlessKbd extends HelixElement {
|
|
|
129
152
|
this.listening?.removeEventListener('keydown', this.handleKeydown);
|
|
130
153
|
this.listening = undefined;
|
|
131
154
|
}
|
|
132
|
-
get printable() {
|
|
133
|
-
const parts = this.keys
|
|
134
|
-
.split('+')
|
|
135
|
-
.map((part) => part.trim())
|
|
136
|
-
.filter((part) => part !== '');
|
|
137
|
-
return parts.length === 1 && [...(parts[0] ?? '')].length === 1;
|
|
138
|
-
}
|
|
139
|
-
matches_(press) {
|
|
140
|
-
const parts = this.keys
|
|
141
|
-
.split('+')
|
|
142
|
-
.map((part) => part.trim().toLowerCase())
|
|
143
|
-
.filter((part) => part !== '');
|
|
144
|
-
if (parts.length === 0) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
const wanted = parts[parts.length - 1] ?? '';
|
|
148
|
-
const modifiers = new Set(parts.slice(0, -1));
|
|
149
|
-
const mod = onApple() ? press.metaKey : press.ctrlKey;
|
|
150
|
-
return (press.key.toLowerCase() === wanted &&
|
|
151
|
-
(modifiers.has('mod') ? mod : true) &&
|
|
152
|
-
(modifiers.has('shift') ? press.shiftKey : !press.shiftKey) &&
|
|
153
|
-
(modifiers.has('alt') || modifiers.has('opt') ? press.altKey : !press.altKey) &&
|
|
154
|
-
(modifiers.has('ctrl') ? press.ctrlKey : modifiers.has('mod') ? true : !press.ctrlKey) &&
|
|
155
|
-
(modifiers.has('cmd') || modifiers.has('meta')
|
|
156
|
-
? press.metaKey
|
|
157
|
-
: modifiers.has('mod')
|
|
158
|
-
? true
|
|
159
|
-
: !press.metaKey));
|
|
160
|
-
}
|
|
161
155
|
firstUpdated(changed) {
|
|
162
156
|
super.firstUpdated(changed);
|
|
163
157
|
this.finishHydration();
|
|
@@ -166,6 +160,9 @@ let HelixHeadlessKbd = class HelixHeadlessKbd extends HelixElement {
|
|
|
166
160
|
return html `<kbd part="kbd">${this.keys === '' ? html `<slot></slot>` : this.label}</kbd>`;
|
|
167
161
|
}
|
|
168
162
|
};
|
|
163
|
+
__decorate([
|
|
164
|
+
property()
|
|
165
|
+
], HelixHeadlessKbd.prototype, "for", void 0);
|
|
169
166
|
__decorate([
|
|
170
167
|
property()
|
|
171
168
|
], HelixHeadlessKbd.prototype, "keys", void 0);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bookkeeping that writes a chord onto the control a shortcut belongs to,
|
|
3
|
+
* in the words core's `ariaChord` spells it in.
|
|
4
|
+
*
|
|
5
|
+
* Beside the family's `index.ts`, because the attribute is a fact about
|
|
6
|
+
* another element, and not the key's template.
|
|
7
|
+
*/
|
|
8
|
+
/** The space-separated list with `chord` added once. */
|
|
9
|
+
export declare const withShortcut: (list: string | null, chord: string) => string;
|
|
10
|
+
/** The list with `chord` taken out, or `null` when nothing is left. */
|
|
11
|
+
export declare const withoutShortcut: (list: string | null, chord: string) => string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Adds a chord to the control's `aria-keyshortcuts`, leaving any the page
|
|
14
|
+
* wrote itself.
|
|
15
|
+
*/
|
|
16
|
+
export declare const claimShortcut: (control: Element, chord: string) => void;
|
|
17
|
+
/** Takes back a chord this file wrote, and the attribute with the last one. */
|
|
18
|
+
export declare const releaseShortcut: (control: Element, chord: string) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const withShortcut = (list, chord) => {
|
|
2
|
+
const chords = (list ?? '').split(/\s+/).filter(Boolean);
|
|
3
|
+
return chords.includes(chord) ? chords.join(' ') : [...chords, chord].join(' ');
|
|
4
|
+
};
|
|
5
|
+
export const withoutShortcut = (list, chord) => {
|
|
6
|
+
const chords = (list ?? '').split(/\s+/).filter((one) => one !== '' && one !== chord);
|
|
7
|
+
return chords.length > 0 ? chords.join(' ') : null;
|
|
8
|
+
};
|
|
9
|
+
const WRITTEN = new WeakMap();
|
|
10
|
+
export const claimShortcut = (control, chord) => {
|
|
11
|
+
if (chord === '') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const before = control.getAttribute('aria-keyshortcuts');
|
|
15
|
+
if ((before ?? '').split(/\s+/).includes(chord) && !WRITTEN.get(control)?.has(chord)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const written = WRITTEN.get(control) ?? new Set();
|
|
19
|
+
written.add(chord);
|
|
20
|
+
WRITTEN.set(control, written);
|
|
21
|
+
control.setAttribute('aria-keyshortcuts', withShortcut(before, chord));
|
|
22
|
+
};
|
|
23
|
+
export const releaseShortcut = (control, chord) => {
|
|
24
|
+
const written = WRITTEN.get(control);
|
|
25
|
+
if (!written?.delete(chord)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const after = withoutShortcut(control.getAttribute('aria-keyshortcuts'), chord);
|
|
29
|
+
if (after === null) {
|
|
30
|
+
control.removeAttribute('aria-keyshortcuts');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
control.setAttribute('aria-keyshortcuts', after);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Whether a name is in the list, matched without regard to case, as a heading is. */
|
|
2
|
+
export declare const isHidden: (list: string, name: string) => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* The list a press on this name leaves: without it where it was hidden, and
|
|
5
|
+
* with it at the end where it was shown. Written back with a comma and a
|
|
6
|
+
* space, as a person writes a list.
|
|
7
|
+
*/
|
|
8
|
+
export declare const toggledNames: (list: string, name: string) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { commaList, seriesKey } from '@fusion.dev/helix-core';
|
|
2
|
+
export const isHidden = (list, name) => {
|
|
3
|
+
const key = seriesKey(name);
|
|
4
|
+
return commaList(list).some((one) => seriesKey(one) === key);
|
|
5
|
+
};
|
|
6
|
+
export const toggledNames = (list, name) => {
|
|
7
|
+
const key = seriesKey(name);
|
|
8
|
+
const now = commaList(list);
|
|
9
|
+
const next = isHidden(list, name)
|
|
10
|
+
? now.filter((one) => seriesKey(one) !== key)
|
|
11
|
+
: [...now, name.trim()];
|
|
12
|
+
return next.join(', ');
|
|
13
|
+
};
|
|
@@ -18,17 +18,28 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
18
18
|
*
|
|
19
19
|
* The table is resolved on the client. There is no server pass.
|
|
20
20
|
*
|
|
21
|
+
* **`toggles` makes each entry a button that hides its series.** Every chart
|
|
22
|
+
* reading the same table draws without a hidden series and fits its scale to
|
|
23
|
+
* the rest, and the series keeps its color. The button says whether its
|
|
24
|
+
* series is shown with `aria-pressed`. `hidden-series` holds the hidden names,
|
|
25
|
+
* so a page can start with some hidden or read which are.
|
|
26
|
+
*
|
|
21
27
|
* @since 0.1.0
|
|
22
28
|
* @status stable
|
|
23
29
|
* @category charts
|
|
24
30
|
* @aliases Key, Series Key
|
|
25
31
|
* @documentation https://fusion.dev/helix/components/legend
|
|
26
32
|
*
|
|
33
|
+
* @event {Event} change - Fired once a toggle has hidden or shown a series.
|
|
34
|
+
* @event {HelixBeforeChangeEvent} helix-before-change - Fired before a toggle hides or shows a series, with the `hidden-series` it would leave. Cancelable.
|
|
35
|
+
*
|
|
27
36
|
* @csspart entry - One name and its swatch. Draw the swatch with
|
|
28
37
|
* `::part(entry)::before` in your stylesheet. The entry holds its series color
|
|
29
38
|
* as `--chart-series`, and this tier ships no CSS.
|
|
39
|
+
* @csspart entry-hidden - An entry whose series is hidden. Set alongside `entry`.
|
|
30
40
|
* @csspart list - The list of entries.
|
|
31
41
|
* @csspart name - One series name.
|
|
42
|
+
* @csspart toggle - The button around a name under `toggles`, which hides or shows its series.
|
|
32
43
|
*/
|
|
33
44
|
export declare class HelixHeadlessLegend extends HelixElement {
|
|
34
45
|
/**
|
|
@@ -62,8 +73,53 @@ export declare class HelixHeadlessLegend extends HelixElement {
|
|
|
62
73
|
* `Tooltip.for` does, so it does not reflect and nothing styles on it.
|
|
63
74
|
*/
|
|
64
75
|
for: string;
|
|
76
|
+
/**
|
|
77
|
+
* The series hidden on the table, by name, separated by commas: what
|
|
78
|
+
* `toggles` hides and shows.
|
|
79
|
+
*
|
|
80
|
+
* Set it to start with series hidden. Every chart reading the same table
|
|
81
|
+
* draws without them. Commas only, because a column's heading may hold a
|
|
82
|
+
* space. For a ring the names are the rows.
|
|
83
|
+
*/
|
|
84
|
+
hiddenSeries: string;
|
|
85
|
+
/**
|
|
86
|
+
* The name of the list, which a screen reader announces before its entries.
|
|
87
|
+
*
|
|
88
|
+
* Absent names the list after the table's caption, so a page with several
|
|
89
|
+
* charts has a legend list for each that says which chart it keys.
|
|
90
|
+
*/
|
|
91
|
+
label: string;
|
|
92
|
+
/**
|
|
93
|
+
* Makes each entry a button that hides or shows its series in every chart
|
|
94
|
+
* reading the same table.
|
|
95
|
+
*
|
|
96
|
+
* Absent, the legend only displays, which is what it did before this
|
|
97
|
+
* existed. Reflected, because the styled tier draws a button differently
|
|
98
|
+
* from a plain entry.
|
|
99
|
+
*/
|
|
100
|
+
toggles: boolean;
|
|
65
101
|
protected readonly source: SourceController;
|
|
102
|
+
/** Whether this legend has written the table's hidden series, so leaving undoes it. */
|
|
103
|
+
private wrote;
|
|
66
104
|
protected willUpdate(changed: PropertyValues<this>): void;
|
|
105
|
+
/**
|
|
106
|
+
* Hands `hidden-series` to the table, where every chart reading it finds
|
|
107
|
+
* it.
|
|
108
|
+
*
|
|
109
|
+
* After the update rather than before, because a server has no table and a
|
|
110
|
+
* hydrating render must draw what the server drew: the charts follow a frame
|
|
111
|
+
* after the legend, which is when they draw at all.
|
|
112
|
+
*/
|
|
113
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
114
|
+
disconnectedCallback(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Hides the series of this name, or shows it again, asking first.
|
|
117
|
+
*
|
|
118
|
+
* `helix-before-change` carries the `hidden-series` the press would leave,
|
|
119
|
+
* and a listener that refuses it keeps the chart as it is. `change` follows
|
|
120
|
+
* once the series is hidden or shown.
|
|
121
|
+
*/
|
|
122
|
+
protected toggle(name: string): void;
|
|
67
123
|
/**
|
|
68
124
|
* The names, in the order the chart will draw them.
|
|
69
125
|
*
|
|
@@ -75,6 +131,13 @@ export declare class HelixHeadlessLegend extends HelixElement {
|
|
|
75
131
|
*/
|
|
76
132
|
protected names(): string[];
|
|
77
133
|
protected render(): TemplateResult;
|
|
134
|
+
/**
|
|
135
|
+
* The button around a name under `toggles`, behind a seam a tier can move.
|
|
136
|
+
*
|
|
137
|
+
* Pressed while its series is shown, which is the state a reader changes by
|
|
138
|
+
* pressing it: a toggle button says whether its thing is on.
|
|
139
|
+
*/
|
|
140
|
+
protected renderToggle(name: string, off: boolean): TemplateResult;
|
|
78
141
|
}
|
|
79
142
|
declare global {
|
|
80
143
|
interface HTMLElementTagNameMap {
|
|
@@ -4,20 +4,51 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { customElement, HelixElement, SourceController, seriesIndex, } from '@fusion.dev/helix-core';
|
|
8
|
-
import { html } from 'lit';
|
|
7
|
+
import { commaList, customElement, HelixBeforeChangeEvent, HelixElement, requestChange, SourceController, seriesIndex, } from '@fusion.dev/helix-core';
|
|
8
|
+
import { html, nothing } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
|
+
import { isHidden, toggledNames } from '../hidden-series.js';
|
|
10
11
|
let HelixHeadlessLegend = class HelixHeadlessLegend extends HelixElement {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
13
14
|
this.for = '';
|
|
15
|
+
this.hiddenSeries = '';
|
|
16
|
+
this.label = '';
|
|
17
|
+
this.toggles = false;
|
|
14
18
|
this.source = new SourceController(this);
|
|
19
|
+
this.wrote = false;
|
|
15
20
|
}
|
|
16
21
|
willUpdate(changed) {
|
|
17
22
|
if (changed.has('for')) {
|
|
18
23
|
this.source.watch();
|
|
19
24
|
}
|
|
20
25
|
}
|
|
26
|
+
updated(changed) {
|
|
27
|
+
super.updated(changed);
|
|
28
|
+
const names = commaList(this.hiddenSeries);
|
|
29
|
+
if (names.length > 0 || this.wrote) {
|
|
30
|
+
this.source.hide(names);
|
|
31
|
+
this.wrote = names.length > 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
disconnectedCallback() {
|
|
35
|
+
if (this.wrote) {
|
|
36
|
+
this.source.hide([]);
|
|
37
|
+
this.wrote = false;
|
|
38
|
+
}
|
|
39
|
+
super.disconnectedCallback();
|
|
40
|
+
}
|
|
41
|
+
toggle(name) {
|
|
42
|
+
requestChange({
|
|
43
|
+
apply: (value) => {
|
|
44
|
+
this.hiddenSeries = value;
|
|
45
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
46
|
+
},
|
|
47
|
+
event: (value) => new HelixBeforeChangeEvent({ value }),
|
|
48
|
+
host: this,
|
|
49
|
+
next: toggledNames(this.hiddenSeries, name),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
21
52
|
names() {
|
|
22
53
|
const series = this.source.series;
|
|
23
54
|
if (this.entries === 'categories') {
|
|
@@ -26,17 +57,31 @@ let HelixHeadlessLegend = class HelixHeadlessLegend extends HelixElement {
|
|
|
26
57
|
return (this.entries === 'measures' ? series.slice(1) : series).map((one) => one.name);
|
|
27
58
|
}
|
|
28
59
|
render() {
|
|
29
|
-
|
|
30
|
-
|
|
60
|
+
const named = this.label || this.source.element?.querySelector('caption')?.textContent?.trim();
|
|
61
|
+
return html `<ul aria-label=${named || nothing} part="list" role="list">
|
|
62
|
+
${this.names().map((name, index) => {
|
|
63
|
+
const off = isHidden(this.hiddenSeries, name);
|
|
64
|
+
return html `<li
|
|
31
65
|
data-series=${seriesIndex(index)}
|
|
32
|
-
part="entry"
|
|
66
|
+
part="entry${off ? ' entry-hidden' : ''}"
|
|
33
67
|
style="--chart-series: var(--chart-series-${seriesIndex(index)})"
|
|
34
68
|
role="listitem"
|
|
35
69
|
>
|
|
36
|
-
|
|
37
|
-
</li
|
|
70
|
+
${this.toggles ? this.renderToggle(name, off) : html `<span part="name">${name}</span>`}
|
|
71
|
+
</li>`;
|
|
72
|
+
})}
|
|
38
73
|
</ul>`;
|
|
39
74
|
}
|
|
75
|
+
renderToggle(name, off) {
|
|
76
|
+
return html `<button
|
|
77
|
+
aria-pressed=${off ? 'false' : 'true'}
|
|
78
|
+
part="toggle"
|
|
79
|
+
type="button"
|
|
80
|
+
@click=${() => this.toggle(name)}
|
|
81
|
+
>
|
|
82
|
+
<span part="name">${name}</span>
|
|
83
|
+
</button>`;
|
|
84
|
+
}
|
|
40
85
|
};
|
|
41
86
|
__decorate([
|
|
42
87
|
property({ reflect: true })
|
|
@@ -44,6 +89,15 @@ __decorate([
|
|
|
44
89
|
__decorate([
|
|
45
90
|
property()
|
|
46
91
|
], HelixHeadlessLegend.prototype, "for", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
property({ attribute: 'hidden-series' })
|
|
94
|
+
], HelixHeadlessLegend.prototype, "hiddenSeries", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
property()
|
|
97
|
+
], HelixHeadlessLegend.prototype, "label", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
property({ reflect: true, type: Boolean })
|
|
100
|
+
], HelixHeadlessLegend.prototype, "toggles", void 0);
|
|
47
101
|
HelixHeadlessLegend = __decorate([
|
|
48
102
|
customElement('helix-headless-legend')
|
|
49
103
|
], HelixHeadlessLegend);
|
|
@@ -8,6 +8,11 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
8
8
|
* or a chart. The lightbox shows one item at a time, and the root decides
|
|
9
9
|
* which.
|
|
10
10
|
*
|
|
11
|
+
* Each item is a `group` with the role description `slide`, named by its
|
|
12
|
+
* `label` or, without one, by its place in the set, such as "2 of 5", as the
|
|
13
|
+
* APG carousel pattern names a slide. The lightbox supplies both words, so they
|
|
14
|
+
* are translated on the lightbox.
|
|
15
|
+
*
|
|
11
16
|
* An item that is not current is hidden and stays in the DOM, as a `TabPanel`
|
|
12
17
|
* does. Crawlers can read it, it is in the server-rendered markup, and an
|
|
13
18
|
* `<img>` that has decoded does not decode again when you go back to it.
|
|
@@ -33,9 +38,20 @@ export declare class HelixHeadlessLightboxItem extends HelixElement {
|
|
|
33
38
|
*/
|
|
34
39
|
current: boolean;
|
|
35
40
|
/**
|
|
36
|
-
* The item's name
|
|
41
|
+
* The item's name. It names the item's group, and fills `{label}` in the
|
|
42
|
+
* lightbox's `status-label`.
|
|
37
43
|
*/
|
|
38
44
|
label: string;
|
|
45
|
+
/**
|
|
46
|
+
* @internal Set by the lightbox: the item's name where it has no `label`,
|
|
47
|
+
* which is its place in the set.
|
|
48
|
+
*/
|
|
49
|
+
position: string;
|
|
50
|
+
/**
|
|
51
|
+
* @internal Set by the lightbox: the word a screen reader says in place of
|
|
52
|
+
* the item's role. Empty leaves the role as it is.
|
|
53
|
+
*/
|
|
54
|
+
roleLabel: string;
|
|
39
55
|
/**
|
|
40
56
|
* The item's identifier. The root compares its `active` value against it.
|
|
41
57
|
*/
|