@fusion.dev/helix-headless 0.2.0 → 0.3.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 +234 -234
- package/dist/accordion/item/accordion-item.js +0 -108
- package/dist/accordion/root/accordion-root.js +0 -33
- package/dist/announcement/root/announcement-root.js +1 -76
- package/dist/app-header/root/app-header-root.js +0 -84
- package/dist/avatar/group/avatar-group.js +0 -77
- package/dist/avatar/root/avatar-root.js +0 -72
- package/dist/badge/root/badge-root.js +0 -67
- package/dist/bar-chart/root/bar-chart-root.js +3 -263
- package/dist/blockquote/root/blockquote-root.js +0 -46
- package/dist/breadcrumbs/breadcrumb/breadcrumb.js +0 -72
- package/dist/breadcrumbs/root/breadcrumbs-root.js +0 -52
- package/dist/button/root/button-root.js +0 -215
- package/dist/button-group/root/button-group-root.js +0 -30
- package/dist/callout/root/callout-root.js +0 -52
- package/dist/card/root/card-root.js +0 -41
- package/dist/carousel/root/carousel-root.d.ts +2 -2
- package/dist/carousel/root/carousel-root.js +2 -362
- package/dist/chat/composer/chat-composer.js +0 -131
- package/dist/chat/message/chat-message.js +0 -137
- package/dist/chat/root/chat-root.js +0 -193
- package/dist/checkbox/root/checkbox-root.js +0 -113
- package/dist/checkbox-group/root/checkbox-group-root.js +1 -157
- package/dist/code/root/code-root.js +0 -26
- package/dist/code-block/root/code-block-root.js +0 -100
- package/dist/color-input/root/color-input-root.js +0 -217
- package/dist/color-picker/color.js +0 -69
- package/dist/color-picker/root/color-picker-root.js +0 -272
- package/dist/combobox/root/combobox-root.js +0 -428
- package/dist/command/root/command-root.js +0 -177
- package/dist/copy-button/root/copy-button-root.js +0 -134
- package/dist/data-table/root/data-table-root.js +0 -336
- package/dist/data-table/root/order.js +0 -100
- package/dist/date-input/root/date-input-root.js +1 -398
- package/dist/date-picker/root/date-picker-root.js +0 -358
- package/dist/dialog/root/dialog-root.js +0 -189
- package/dist/divider/root/divider-root.js +0 -71
- package/dist/donut-chart/root/donut-chart-root.js +0 -214
- package/dist/drawer/root/drawer-root.js +0 -116
- package/dist/drilldown/item/drilldown-item.js +0 -82
- package/dist/drilldown/root/drilldown-root.js +0 -91
- package/dist/element-events.generated.js +0 -5
- package/dist/empty/root/empty-root.js +0 -35
- package/dist/file-input/root/file-input-root.js +0 -232
- package/dist/format-date/root/format-date-root.js +0 -95
- package/dist/heatmap/root/buckets.js +0 -57
- package/dist/heatmap/root/heatmap-root.js +0 -313
- package/dist/icon/root/icon-root.js +0 -48
- package/dist/icon-button/root/icon-button-root.js +0 -30
- package/dist/image/root/image-root.js +0 -174
- package/dist/index.js +0 -9
- package/dist/input/root/input-root.js +0 -228
- package/dist/kbd/root/kbd-root.js +0 -117
- package/dist/legend/root/legend-root.js +0 -73
- package/dist/line-chart/root/line-chart-root.js +0 -172
- package/dist/list/item/list-item.js +0 -92
- package/dist/list/root/list-root.js +0 -26
- package/dist/listbox/root/listbox-root.js +2 -429
- package/dist/loader/root/loader-root.js +0 -40
- package/dist/megamenu/root/megamenu-root.js +0 -284
- package/dist/menu/item/menu-item.js +1 -221
- package/dist/menu/root/menu-root.js +1 -171
- package/dist/meter/root/meter-root.js +1 -152
- package/dist/navigation/root/navigation-root.js +0 -56
- package/dist/notifications/notification/notification.js +0 -159
- package/dist/notifications/root/notifications-root.js +0 -148
- package/dist/number-input/root/number-input-root.js +1 -263
- package/dist/option/group/option-group.js +0 -26
- package/dist/option/root/option-root.js +0 -157
- package/dist/outline/root/outline-root.js +0 -292
- package/dist/pagination/root/pagination-root.js +0 -361
- package/dist/pagination/size/pagination-size.js +0 -104
- package/dist/pagination/summary/pagination-summary.js +0 -90
- package/dist/pin-input/root/pin-input-root.js +0 -276
- package/dist/popover/root/popover-root.js +0 -103
- package/dist/progress/root/progress-root.js +1 -133
- package/dist/qr-code/root/qr-code-root.js +0 -96
- package/dist/quote/root/quote-root.js +0 -25
- package/dist/radio/group/radio-group.js +0 -81
- package/dist/radio/root/radio-root.js +0 -85
- package/dist/rating/root/rating-root.js +0 -220
- package/dist/scroll-area/root/scroll-area-root.js +0 -100
- package/dist/select/root/select-root.js +2 -218
- package/dist/skeleton/root/skeleton-root.js +0 -20
- package/dist/slider/root/slider-root.js +1 -267
- package/dist/sparkline/root/sparkline-root.js +3 -164
- package/dist/speed-dial/item/speed-dial-item.js +0 -52
- package/dist/speed-dial/root/speed-dial-root.js +1 -116
- package/dist/splitter/root/splitter-root.js +0 -489
- package/dist/stat/group/stat-group.js +0 -18
- package/dist/stat/root/stat-root.js +0 -23
- package/dist/steps/root/steps-root.js +0 -62
- package/dist/steps/step/step.js +0 -131
- package/dist/switch/root/switch-root.js +0 -80
- package/dist/table/cell/table-cell.js +0 -23
- package/dist/table/column/table-column.js +0 -158
- package/dist/table/root/table-root.js +0 -82
- package/dist/table/row/table-row.js +0 -21
- package/dist/tabs/panel/tab-panel.js +0 -49
- package/dist/tabs/root/tabs-root.js +0 -98
- package/dist/tabs/tab/tab.js +0 -59
- package/dist/tag/root/tag-root.js +0 -31
- package/dist/textarea/root/textarea-root.js +0 -162
- package/dist/time-input/root/time-input-root.js +0 -283
- package/dist/time-picker/root/time-picker-root.js +0 -326
- package/dist/timeline/item/timeline-item.js +0 -66
- package/dist/timeline/root/timeline-root.js +0 -41
- package/dist/toast/item/toast-item.js +0 -165
- package/dist/toast/root/toast-root.js +0 -51
- package/dist/toggle/group/toggle-group.js +0 -150
- package/dist/toggle/root/toggle-root.js +0 -78
- package/dist/toolbar/root/toolbar-root.js +0 -116
- package/dist/tooltip/root/tooltip-root.js +0 -427
- package/dist/tour/root/tour-root.js +0 -130
- package/dist/tour/stop/tour-stop.js +1 -127
- package/dist/tree/item/tree-item.js +0 -198
- package/dist/tree/root/tree-root.js +0 -97
- package/dist/trend/root/trend-root.js +0 -53
- package/dist/video/root/video-root.d.ts +8 -12
- package/dist/video/root/video-root.js +5 -756
- package/dist/video-playlist/item/video-playlist-item.js +1 -90
- package/dist/video-playlist/menu/video-playlist-menu.js +1 -132
- package/dist/video-playlist/root/video-playlist-root.js +0 -113
- package/dist/virtual-list/root/virtual-list-root.js +0 -105
- package/jsx.d.ts +1408 -2576
- package/package.json +6 -6
- package/vue.d.ts +1 -1
|
@@ -7,39 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { customElement, HelixElement } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
|
-
/** Keys the toolbar handles, per the APG toolbar pattern. */
|
|
11
10
|
const KEYS = new Set(['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End']);
|
|
12
|
-
/**
|
|
13
|
-
* A control that owns its tab stop rather than taking one on its host.
|
|
14
|
-
*
|
|
15
|
-
* Checked as a property rather than with `instanceof`, for the same reason the
|
|
16
|
-
* control list is: a toolbar holds anything, so the contract has to be
|
|
17
|
-
* something a foreign element can satisfy.
|
|
18
|
-
*/
|
|
19
11
|
const ownsTabStop = (node) => 'focusable' in node;
|
|
20
|
-
/**
|
|
21
|
-
* Input types with no text to move a caret through and no value an arrow moves.
|
|
22
|
-
*
|
|
23
|
-
* Everything else claims the arrows for itself: a caret in a text field, a
|
|
24
|
-
* spinner on `number`, a value on `range`, a group on `radio`.
|
|
25
|
-
*/
|
|
26
12
|
const CARETLESS = new Set(['button', 'checkbox', 'color', 'file', 'image', 'reset', 'submit']);
|
|
27
|
-
/**
|
|
28
|
-
* Whether the press was already the business of whatever it landed on.
|
|
29
|
-
*
|
|
30
|
-
* A toolbar holds anything, and some of what it holds uses the arrow keys for
|
|
31
|
-
* itself. Moving the toolbar regardless makes an input in a toolbar
|
|
32
|
-
* uneditable: ArrowRight moves focus to the next control, and `preventDefault`
|
|
33
|
-
* means the caret never moves at all.
|
|
34
|
-
*
|
|
35
|
-
* `composedPath()[0]` rather than `event.target`, which is retargeted to the
|
|
36
|
-
* control's host at the shadow boundary and cannot tell a text field inside a
|
|
37
|
-
* component from the component itself.
|
|
38
|
-
*
|
|
39
|
-
* `defaultPrevented` first, because a control that has already answered the
|
|
40
|
-
* press has said so in the way the platform provides, and a foreign control
|
|
41
|
-
* this package has never heard of has no other way to say it.
|
|
42
|
-
*/
|
|
43
13
|
const claimed = (event) => {
|
|
44
14
|
if (event.defaultPrevented) {
|
|
45
15
|
return true;
|
|
@@ -53,36 +23,9 @@ const claimed = (event) => {
|
|
|
53
23
|
}
|
|
54
24
|
return inner.localName === 'input' && !CARETLESS.has(inner.type);
|
|
55
25
|
};
|
|
56
|
-
/**
|
|
57
|
-
* @summary A group of controls that share one tab stop.
|
|
58
|
-
*
|
|
59
|
-
* @description
|
|
60
|
-
* Separate from a button group, and the difference is what it holds: a group is
|
|
61
|
-
* homogeneous, a toolbar is not. A toolbar mixes buttons, toggles, and menus,
|
|
62
|
-
* which is why it is its own component rather than a variant of something.
|
|
63
|
-
*
|
|
64
|
-
* The whole toolbar is one tab stop and the arrows move between controls, so a
|
|
65
|
-
* page with three toolbars costs three presses of Tab to get past rather than
|
|
66
|
-
* thirty. Controls are found by asking the browser what is focusable rather
|
|
67
|
-
* than by matching tag names, so a toolbar works with anything put in it,
|
|
68
|
-
* including a consumer's own elements.
|
|
69
|
-
*
|
|
70
|
-
* @since 0.1.0
|
|
71
|
-
* @status stable
|
|
72
|
-
* @category layout
|
|
73
|
-
* @aliases Actions, Action bar
|
|
74
|
-
* @documentation https://helix.fusion.dev/components/toolbar
|
|
75
|
-
*
|
|
76
|
-
* @slot - The toolbar's controls.
|
|
77
|
-
*
|
|
78
|
-
* @csspart toolbar - The toolbar container.
|
|
79
|
-
*/
|
|
80
26
|
let HelixHeadlessToolbar = class HelixHeadlessToolbar extends HelixElement {
|
|
81
27
|
constructor() {
|
|
82
28
|
super(...arguments);
|
|
83
|
-
/**
|
|
84
|
-
* Accessible name for the toolbar.
|
|
85
|
-
*/
|
|
86
29
|
this.label = 'Toolbar';
|
|
87
30
|
this.handleFocusIn = (event) => {
|
|
88
31
|
const control = this.controls.find((entry) => entry.contains(event.target));
|
|
@@ -90,18 +33,6 @@ let HelixHeadlessToolbar = class HelixHeadlessToolbar extends HelixElement {
|
|
|
90
33
|
this.setTabStop(control);
|
|
91
34
|
}
|
|
92
35
|
};
|
|
93
|
-
/**
|
|
94
|
-
* Gives the tab stop back to a control that still exists.
|
|
95
|
-
*
|
|
96
|
-
* `controls` excludes anything disabled or hidden, so disabling the control
|
|
97
|
-
* holding the stop drops it out of the list while every other control is
|
|
98
|
-
* already at `-1`, leaving a toolbar the keyboard cannot reach at all. A Save
|
|
99
|
-
* button disabling itself once the form is clean is enough to do it.
|
|
100
|
-
*
|
|
101
|
-
* `foreign` stays false, the same as the first claim: a control this package
|
|
102
|
-
* has never heard of that was never given `tabindex="-1"` is still in the
|
|
103
|
-
* document's own tab order, so it is never the one that gets stranded.
|
|
104
|
-
*/
|
|
105
36
|
this.restoreTabStop = () => {
|
|
106
37
|
const controls = this.controls;
|
|
107
38
|
const held = controls.some((control) => ownsTabStop(control) ? control.focusable : control.tabIndex === 0);
|
|
@@ -134,7 +65,6 @@ let HelixHeadlessToolbar = class HelixHeadlessToolbar extends HelixElement {
|
|
|
134
65
|
next = controls.length - 1;
|
|
135
66
|
}
|
|
136
67
|
else {
|
|
137
|
-
// An arrow along the other axis is not ours; leave it to the page.
|
|
138
68
|
return;
|
|
139
69
|
}
|
|
140
70
|
event.preventDefault();
|
|
@@ -143,19 +73,6 @@ let HelixHeadlessToolbar = class HelixHeadlessToolbar extends HelixElement {
|
|
|
143
73
|
target?.focus();
|
|
144
74
|
};
|
|
145
75
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Children that can take the tab stop, in document order.
|
|
148
|
-
*
|
|
149
|
-
* Every child that is not `disabled` and not `aria-hidden`, which is
|
|
150
|
-
* deliberately a test on the element rather than a list of tag names: a
|
|
151
|
-
* toolbar holds anything, including elements this package has never heard of.
|
|
152
|
-
* Client only, there being no tree to walk on the server.
|
|
153
|
-
*
|
|
154
|
-
* **It does not ask a child whether it is focusable.** Reading a `focusable`
|
|
155
|
-
* property is what `setTabStop` does when moving the stop, not what this does
|
|
156
|
-
* when choosing the set, so an element that is neither disabled nor hidden and
|
|
157
|
-
* still cannot take focus is counted here and skipped there.
|
|
158
|
-
*/
|
|
159
76
|
get controls() {
|
|
160
77
|
return [...this.children].filter((child) => {
|
|
161
78
|
if (!(child instanceof HTMLElement)) {
|
|
@@ -164,17 +81,6 @@ let HelixHeadlessToolbar = class HelixHeadlessToolbar extends HelixElement {
|
|
|
164
81
|
return !child.hasAttribute('disabled') && child.getAttribute('aria-hidden') !== 'true';
|
|
165
82
|
});
|
|
166
83
|
}
|
|
167
|
-
/**
|
|
168
|
-
* Moves the single tab stop to one control.
|
|
169
|
-
*
|
|
170
|
-
* Prefers the control's own `focusable` property to writing `tabindex` on it.
|
|
171
|
-
* The attribute is a change to markup the consumer rendered, which a React
|
|
172
|
-
* consumer's hydration reports and does not patch up; a control that offers
|
|
173
|
-
* the property moves the stop inside its own shadow root instead.
|
|
174
|
-
*
|
|
175
|
-
* `tabindex` stays as the fallback, because a toolbar has to hold controls
|
|
176
|
-
* this package has never heard of.
|
|
177
|
-
*/
|
|
178
84
|
setTabStop(active, foreign = true) {
|
|
179
85
|
for (const control of this.controls) {
|
|
180
86
|
const stop = control === active;
|
|
@@ -186,29 +92,11 @@ let HelixHeadlessToolbar = class HelixHeadlessToolbar extends HelixElement {
|
|
|
186
92
|
}
|
|
187
93
|
}
|
|
188
94
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Sets the first tab stop once every custom control has upgraded.
|
|
191
|
-
*
|
|
192
|
-
* A custom element has no properties at all before it upgrades, so a pass
|
|
193
|
-
* that ran first would find no `focusable`, take the `tabindex` fallback, and
|
|
194
|
-
* write the very attribute this exists to avoid.
|
|
195
|
-
*/
|
|
196
95
|
async claimTabStop() {
|
|
197
96
|
const pending = [...new Set(this.controls.map((control) => control.localName))].filter((name) => name.includes('-'));
|
|
198
97
|
await Promise.all(pending.map((name) => customElements.whenDefined(name)));
|
|
199
|
-
// Foreign controls are left alone until focus arrives. Writing `tabindex`
|
|
200
|
-
// on one before any interaction changes markup the consumer rendered while
|
|
201
|
-
// React is still hydrating it, which it reports and does not patch up.
|
|
202
|
-
// Until then they keep the tab order the document already gave them, and
|
|
203
|
-
// the first `focusin` takes over from there.
|
|
204
98
|
this.setTabStop(this.controls[0], false);
|
|
205
99
|
}
|
|
206
|
-
/**
|
|
207
|
-
* The orientation in force.
|
|
208
|
-
*
|
|
209
|
-
* Unset is horizontal, and stays unset: the default is the absent attribute,
|
|
210
|
-
* so a reflected default cannot appear on the host after hydration.
|
|
211
|
-
*/
|
|
212
100
|
get axis() {
|
|
213
101
|
return this.orientation ?? 'horizontal';
|
|
214
102
|
}
|
|
@@ -216,10 +104,6 @@ let HelixHeadlessToolbar = class HelixHeadlessToolbar extends HelixElement {
|
|
|
216
104
|
super.connectedCallback();
|
|
217
105
|
this.addEventListener('keydown', this.handleKeydown);
|
|
218
106
|
this.addEventListener('focusin', this.handleFocusIn);
|
|
219
|
-
/* `disabled` and `aria-hidden` are what `controls` filters on, so a change
|
|
220
|
-
to either is a change to the set the stop has to live in. Nothing else is
|
|
221
|
-
watched, which also keeps `setTabStop` writing `tabindex` from feeding
|
|
222
|
-
back into this. */
|
|
223
107
|
this.watcher = new MutationObserver(this.restoreTabStop);
|
|
224
108
|
this.watcher.observe(this, {
|
|
225
109
|
attributeFilter: ['disabled', 'aria-hidden'],
|