@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
|
@@ -4,25 +4,25 @@ 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 {
|
|
7
|
+
import { clockLocale, commaList, customElement, dayPeriod, elementById, fillTemplate, HelixFormElement, inlineStep, isTwelveHour, MixinControllerValue, nearestTime, offeredTimes, reportValues, secondsAsValue, timeBarred, timeFault, valueAsSeconds, wheelParts, wholeHour, writeClock, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { nothing } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
10
|
import { html } from 'lit/static-html.js';
|
|
11
11
|
import '../../listbox/index.js';
|
|
12
12
|
import '../../option/index.js';
|
|
13
|
-
const isTwelveHour = (locale) => new Intl.DateTimeFormat(locale || undefined, { timeStyle: 'short' }).resolvedOptions().hour12 ===
|
|
14
|
-
true;
|
|
15
13
|
let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControllerValue(HelixFormElement) {
|
|
16
14
|
constructor() {
|
|
17
15
|
super(...arguments);
|
|
18
16
|
this.disableTimes = '';
|
|
17
|
+
this.hourLabel = 'Hour';
|
|
19
18
|
this.invalid = false;
|
|
20
19
|
this.label = 'Time';
|
|
21
20
|
this.locale = '';
|
|
21
|
+
this.manual = false;
|
|
22
22
|
this.max = '23:59';
|
|
23
|
+
this.meridiemLabel = 'Before or after noon';
|
|
23
24
|
this.min = '00:00';
|
|
24
|
-
this.
|
|
25
|
-
this.required = false;
|
|
25
|
+
this.minuteLabel = 'Minute';
|
|
26
26
|
this.handleListInput = (event) => {
|
|
27
27
|
event.stopPropagation();
|
|
28
28
|
};
|
|
@@ -55,60 +55,78 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
55
55
|
if (this.isDisabled) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
const { hour, meridiem, minute } = this.parts;
|
|
59
|
-
let
|
|
58
|
+
const { hour, meridiem, minute, second } = this.parts;
|
|
59
|
+
let [h, m, sec] = [hour, minute, second];
|
|
60
60
|
if (part === 'minute') {
|
|
61
|
-
|
|
61
|
+
m = Number(to);
|
|
62
|
+
}
|
|
63
|
+
else if (part === 'second') {
|
|
64
|
+
sec = Number(to);
|
|
62
65
|
}
|
|
63
66
|
else if (part === 'hour') {
|
|
64
|
-
|
|
65
|
-
const whole = isTwelveHour(this.locale) ? (shown % 12) + (meridiem === 'PM' ? 12 : 0) : shown;
|
|
66
|
-
next = whole * 60 + minute;
|
|
67
|
+
h = wholeHour(Number(to), isTwelveHour(this.clock) ? meridiem : undefined);
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
|
-
|
|
70
|
-
next = (half + (to === 'PM' ? 12 : 0)) * 60 + minute;
|
|
70
|
+
h = (hour % 12) + (to === 'PM' ? 12 : 0);
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
if (this.
|
|
72
|
+
const nearest = this.nearest(h * 3600 + m * 60 + sec);
|
|
73
|
+
if (this.barredAt(nearest)) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
this.requestValue(
|
|
76
|
+
this.requestValue(this.valueFor(nearest));
|
|
77
77
|
};
|
|
78
|
+
this.readOnly = false;
|
|
79
|
+
this.required = false;
|
|
80
|
+
this.secondLabel = 'Second';
|
|
81
|
+
this.seconds = false;
|
|
78
82
|
this.step = 15;
|
|
79
83
|
this.listRevealed = false;
|
|
84
|
+
this.naming = undefined;
|
|
85
|
+
this.handleColumnsKeydown = (event) => {
|
|
86
|
+
const step = inlineStep(this, event.key);
|
|
87
|
+
if (step === 0 || event.altKey || event.ctrlKey || event.metaKey) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const columns = [...(this.renderRoot?.querySelectorAll('[part="column"]') ?? [])];
|
|
91
|
+
const at = columns.findIndex((column) => event.composedPath().includes(column));
|
|
92
|
+
const next = columns[at + step];
|
|
93
|
+
if (at < 0 || !next) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
next.focus();
|
|
98
|
+
};
|
|
80
99
|
}
|
|
81
100
|
get times() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return found;
|
|
101
|
+
return offeredTimes(this.min, this.max, this.step, this.seconds);
|
|
102
|
+
}
|
|
103
|
+
get clock() {
|
|
104
|
+
return clockLocale(this.locale, this.hourCycle);
|
|
105
|
+
}
|
|
106
|
+
valueFor(at) {
|
|
107
|
+
return secondsAsValue(at, this.seconds);
|
|
90
108
|
}
|
|
91
109
|
barred(at) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
const seconds = valueAsSeconds(at);
|
|
111
|
+
return seconds !== null && this.barredAt(seconds);
|
|
112
|
+
}
|
|
113
|
+
barredAt(at) {
|
|
114
|
+
return timeBarred(at, this.disableTimes);
|
|
115
|
+
}
|
|
116
|
+
nearest(at) {
|
|
117
|
+
return nearestTime(this.times, at);
|
|
97
118
|
}
|
|
98
119
|
wholeHourBarred(shown, half) {
|
|
99
|
-
const whole =
|
|
100
|
-
const within = this.times.filter((at) => Math.floor(at /
|
|
101
|
-
return within.length > 0 && within.every((at) => this.
|
|
120
|
+
const whole = wholeHour(shown, half);
|
|
121
|
+
const within = this.times.filter((at) => Math.floor(at / 3600) === whole);
|
|
122
|
+
return within.length > 0 && within.every((at) => this.barredAt(at));
|
|
102
123
|
}
|
|
103
124
|
halfBarred(half) {
|
|
104
|
-
const within = this.times.filter((at) => (half === 'PM') === at >=
|
|
105
|
-
return within.length > 0 && within.every((at) => this.
|
|
125
|
+
const within = this.times.filter((at) => (half === 'PM') === at >= 43_200);
|
|
126
|
+
return within.length > 0 && within.every((at) => this.barredAt(at));
|
|
106
127
|
}
|
|
107
128
|
get held() {
|
|
108
|
-
return this.value
|
|
109
|
-
.split(',')
|
|
110
|
-
.map((one) => one.trim())
|
|
111
|
-
.filter(Boolean);
|
|
129
|
+
return commaList(this.value);
|
|
112
130
|
}
|
|
113
131
|
between(at) {
|
|
114
132
|
if (this.mode !== 'range') {
|
|
@@ -118,17 +136,25 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
118
136
|
return from !== undefined && to !== undefined && at > from && at < to;
|
|
119
137
|
}
|
|
120
138
|
get parts() {
|
|
121
|
-
const at =
|
|
122
|
-
|
|
123
|
-
return { hour, meridiem: hour < 12 ? 'AM' : 'PM', minute: at % 60 };
|
|
139
|
+
const at = valueAsSeconds(this.value) ?? valueAsSeconds(this.min) ?? 0;
|
|
140
|
+
return wheelParts(at, isTwelveHour(this.clock));
|
|
124
141
|
}
|
|
125
142
|
get hours() {
|
|
126
|
-
const found = new Set(this.times.map((at) => Math.floor(at /
|
|
143
|
+
const found = new Set(this.times.map((at) => Math.floor(at / 3600)));
|
|
127
144
|
return [...found];
|
|
128
145
|
}
|
|
129
146
|
get minutes() {
|
|
130
147
|
const hour = this.parts.hour;
|
|
131
|
-
|
|
148
|
+
const found = new Set(this.times
|
|
149
|
+
.filter((at) => Math.floor(at / 3600) === hour)
|
|
150
|
+
.map((at) => Math.floor(at / 60) % 60));
|
|
151
|
+
return [...found];
|
|
152
|
+
}
|
|
153
|
+
get secondsShown() {
|
|
154
|
+
const { hour, minute } = this.parts;
|
|
155
|
+
return this.times
|
|
156
|
+
.filter((at) => Math.floor(at / 60) === hour * 60 + minute)
|
|
157
|
+
.map((at) => at % 60);
|
|
132
158
|
}
|
|
133
159
|
reveal() {
|
|
134
160
|
if (this.mode !== undefined) {
|
|
@@ -148,6 +174,35 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
148
174
|
}
|
|
149
175
|
return super.requestValue(next);
|
|
150
176
|
}
|
|
177
|
+
fault(at) {
|
|
178
|
+
switch (timeFault(at, {
|
|
179
|
+
disableTimes: this.disableTimes,
|
|
180
|
+
max: this.max,
|
|
181
|
+
min: this.min,
|
|
182
|
+
offered: this.times,
|
|
183
|
+
})) {
|
|
184
|
+
case 'rangeUnderflow':
|
|
185
|
+
return [
|
|
186
|
+
'rangeUnderflow',
|
|
187
|
+
fillTemplate(this.rangeUnderflowMessage || 'Choose a time at or after {min}.', {
|
|
188
|
+
min: writeClock(this.min, this.clock, this.seconds),
|
|
189
|
+
}),
|
|
190
|
+
];
|
|
191
|
+
case 'rangeOverflow':
|
|
192
|
+
return [
|
|
193
|
+
'rangeOverflow',
|
|
194
|
+
fillTemplate(this.rangeOverflowMessage || 'Choose a time at or before {max}.', {
|
|
195
|
+
max: writeClock(this.max, this.clock, this.seconds),
|
|
196
|
+
}),
|
|
197
|
+
];
|
|
198
|
+
case 'unavailable':
|
|
199
|
+
return ['badInput', this.unavailableMessage || 'Choose a time that is available.'];
|
|
200
|
+
case 'stepMismatch':
|
|
201
|
+
return ['stepMismatch', this.stepMismatchMessage || 'Choose one of the times on offer.'];
|
|
202
|
+
default:
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
151
206
|
reportRequired() {
|
|
152
207
|
const anchor = this.partNamed('list') ?? undefined;
|
|
153
208
|
if (this.required && this.value === '') {
|
|
@@ -155,17 +210,25 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
155
210
|
return;
|
|
156
211
|
}
|
|
157
212
|
const held = this.held;
|
|
158
|
-
if (held.length > 0 && held.some((one) =>
|
|
213
|
+
if (held.length > 0 && held.some((one) => valueAsSeconds(one) === null)) {
|
|
214
|
+
const shape = this.seconds ? 'HH:mm:ss' : 'HH:mm';
|
|
159
215
|
this.internals.setValidity({ badInput: true }, this.badInputMessage ||
|
|
160
216
|
(this.mode === undefined
|
|
161
|
-
?
|
|
162
|
-
:
|
|
217
|
+
? `Enter a time as ${shape}.`
|
|
218
|
+
: `Enter times as ${shape}, separated by commas.`), anchor);
|
|
163
219
|
return;
|
|
164
220
|
}
|
|
221
|
+
for (const one of held) {
|
|
222
|
+
const fault = this.fault(one);
|
|
223
|
+
if (fault) {
|
|
224
|
+
this.internals.setValidity({ [fault[0]]: true }, fault[1], anchor);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
165
228
|
this.internals.setValidity({});
|
|
166
229
|
}
|
|
167
230
|
report() {
|
|
168
|
-
if (this.
|
|
231
|
+
if (this.isDisabled) {
|
|
169
232
|
this.internals.setFormValue(null);
|
|
170
233
|
return;
|
|
171
234
|
}
|
|
@@ -178,6 +241,25 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
178
241
|
await Promise.all(settling.map((one) => one.updateComplete));
|
|
179
242
|
this.reveal();
|
|
180
243
|
}
|
|
244
|
+
get listName() {
|
|
245
|
+
const named = (this.getAttribute('aria-labelledby') ?? '')
|
|
246
|
+
.split(/\s+/)
|
|
247
|
+
.filter(Boolean)
|
|
248
|
+
.map((id) => elementById(this, id)?.textContent?.trim() ?? '')
|
|
249
|
+
.filter(Boolean)
|
|
250
|
+
.join(' ');
|
|
251
|
+
return named || this.getAttribute('aria-label') || this.label;
|
|
252
|
+
}
|
|
253
|
+
connectedCallback() {
|
|
254
|
+
super.connectedCallback();
|
|
255
|
+
this.naming = new MutationObserver(() => this.requestUpdate());
|
|
256
|
+
this.naming.observe(this, { attributeFilter: ['aria-label', 'aria-labelledby'] });
|
|
257
|
+
}
|
|
258
|
+
disconnectedCallback() {
|
|
259
|
+
super.disconnectedCallback();
|
|
260
|
+
this.naming?.disconnect();
|
|
261
|
+
this.naming = undefined;
|
|
262
|
+
}
|
|
181
263
|
willUpdate(changed) {
|
|
182
264
|
super.willUpdate(changed);
|
|
183
265
|
this.internals.ariaInvalid = this.invalid ? 'true' : null;
|
|
@@ -196,7 +278,8 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
196
278
|
}
|
|
197
279
|
}
|
|
198
280
|
focus(options) {
|
|
199
|
-
|
|
281
|
+
;
|
|
282
|
+
(this.partNamed('list') ?? this.partNamed('column'))?.focus(options);
|
|
200
283
|
}
|
|
201
284
|
renderColumn(part, label, values, written, value, barred = () => false) {
|
|
202
285
|
return html `<${this.tag('listbox')}
|
|
@@ -228,17 +311,25 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
228
311
|
</${this.tag('listbox')}>`;
|
|
229
312
|
}
|
|
230
313
|
renderSpinner() {
|
|
231
|
-
const twelve = isTwelveHour(this.
|
|
232
|
-
const { hour, meridiem, minute } = this.parts;
|
|
233
|
-
const shownHour = twelve ? String(hour % 12 === 0 ? 12 : hour % 12) : String(hour);
|
|
314
|
+
const twelve = isTwelveHour(this.clock);
|
|
315
|
+
const { hour, meridiem, minute, second, shown } = this.parts;
|
|
234
316
|
const hours = twelve
|
|
235
317
|
? [...new Set(this.hours.map((one) => (one % 12 === 0 ? 12 : one % 12)))].sort((a, b) => a - b)
|
|
236
318
|
: this.hours;
|
|
237
|
-
return html `<div
|
|
238
|
-
|
|
239
|
-
|
|
319
|
+
return html `<div
|
|
320
|
+
part="columns"
|
|
321
|
+
role="group"
|
|
322
|
+
aria-label=${this.listName}
|
|
323
|
+
data-unset=${this.value === '' ? '' : nothing}
|
|
324
|
+
@keydown=${this.handleColumnsKeydown}
|
|
325
|
+
>
|
|
326
|
+
${this.renderColumn('hour', this.hourLabel, hours.map(String), (one) => (twelve ? one : one.padStart(2, '0')), String(shown), (one) => this.wholeHourBarred(Number(one), twelve ? meridiem : undefined))}
|
|
327
|
+
${this.renderColumn('minute', this.minuteLabel, this.minutes.map(String), (one) => one.padStart(2, '0'), String(minute), (one) => this.barredAt(hour * 3600 + Number(one) * 60))}
|
|
328
|
+
${this.seconds
|
|
329
|
+
? this.renderColumn('second', this.secondLabel, this.secondsShown.map(String), (one) => one.padStart(2, '0'), String(second), (one) => this.barredAt(hour * 3600 + minute * 60 + Number(one)))
|
|
330
|
+
: nothing}
|
|
240
331
|
${twelve
|
|
241
|
-
? this.renderColumn('meridiem',
|
|
332
|
+
? this.renderColumn('meridiem', this.meridiemLabel, ['AM', 'PM'], (one) => dayPeriod(one, this.clock), meridiem, (one) => this.halfBarred(one))
|
|
242
333
|
: nothing}
|
|
243
334
|
</div>`;
|
|
244
335
|
}
|
|
@@ -249,16 +340,17 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
249
340
|
exportparts="empty: list-empty, feedback: list-feedback, filter-icon: list-filter-icon,
|
|
250
341
|
filter-mark: list-filter-mark, hint: list-hint, items: list-items, label: list-label,
|
|
251
342
|
live: list-live, loading: list-loading, search: list-search, search-field: list-search-field"
|
|
252
|
-
aria-label=${this.
|
|
343
|
+
aria-label=${this.listName}
|
|
253
344
|
data-unset=${this.value === '' ? '' : nothing}
|
|
254
345
|
?disabled=${this.isDisabled}
|
|
346
|
+
?manual=${this.manual}
|
|
255
347
|
?multiple=${this.mode !== undefined}
|
|
256
348
|
.value=${this.value}
|
|
257
349
|
@helix-before-change=${this.handleChange}
|
|
258
350
|
@input=${this.handleListInput}
|
|
259
351
|
>
|
|
260
|
-
${this.times.map((
|
|
261
|
-
const at =
|
|
352
|
+
${this.times.map((seconds) => {
|
|
353
|
+
const at = this.valueFor(seconds);
|
|
262
354
|
const between = this.between(at);
|
|
263
355
|
return html `<${this.tag('option')}
|
|
264
356
|
part="option${between ? ' option-between' : ''}"
|
|
@@ -269,7 +361,7 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
269
361
|
?disabled=${this.barred(at)}
|
|
270
362
|
?selected=${this.held.includes(at)}
|
|
271
363
|
data-between=${between ? '' : nothing}
|
|
272
|
-
>${
|
|
364
|
+
>${writeClock(at, this.clock, this.seconds)}</${this.tag('option')}
|
|
273
365
|
>`;
|
|
274
366
|
})}
|
|
275
367
|
</${this.tag('listbox')}>`;
|
|
@@ -281,16 +373,20 @@ let HelixHeadlessTimePicker = class HelixHeadlessTimePicker extends MixinControl
|
|
|
281
373
|
return html `${this.renderList()}`;
|
|
282
374
|
}
|
|
283
375
|
get valueAsDate() {
|
|
284
|
-
|
|
376
|
+
const at = valueAsSeconds(this.value);
|
|
377
|
+
return at === null ? null : new Date(at * 1000);
|
|
285
378
|
}
|
|
286
379
|
set valueAsDate(date) {
|
|
287
|
-
this.
|
|
380
|
+
this.valueAsNumber = date ? date.getTime() : Number.NaN;
|
|
288
381
|
}
|
|
289
382
|
get valueAsNumber() {
|
|
290
|
-
|
|
383
|
+
const at = valueAsSeconds(this.value);
|
|
384
|
+
return at === null ? Number.NaN : at * 1000;
|
|
291
385
|
}
|
|
292
386
|
set valueAsNumber(ms) {
|
|
293
|
-
this.value = Number.isNaN(ms)
|
|
387
|
+
this.value = Number.isNaN(ms)
|
|
388
|
+
? ''
|
|
389
|
+
: this.valueFor(Math.floor((((ms % 86_400_000) + 86_400_000) % 86_400_000) / 1000));
|
|
294
390
|
}
|
|
295
391
|
};
|
|
296
392
|
__decorate([
|
|
@@ -299,6 +395,12 @@ __decorate([
|
|
|
299
395
|
__decorate([
|
|
300
396
|
property({ attribute: 'disable-times' })
|
|
301
397
|
], HelixHeadlessTimePicker.prototype, "disableTimes", void 0);
|
|
398
|
+
__decorate([
|
|
399
|
+
property({ attribute: 'hour-cycle' })
|
|
400
|
+
], HelixHeadlessTimePicker.prototype, "hourCycle", void 0);
|
|
401
|
+
__decorate([
|
|
402
|
+
property({ attribute: 'hour-label' })
|
|
403
|
+
], HelixHeadlessTimePicker.prototype, "hourLabel", void 0);
|
|
302
404
|
__decorate([
|
|
303
405
|
property({ reflect: true, type: Boolean })
|
|
304
406
|
], HelixHeadlessTimePicker.prototype, "invalid", void 0);
|
|
@@ -308,24 +410,51 @@ __decorate([
|
|
|
308
410
|
__decorate([
|
|
309
411
|
property()
|
|
310
412
|
], HelixHeadlessTimePicker.prototype, "locale", void 0);
|
|
413
|
+
__decorate([
|
|
414
|
+
property({ type: Boolean })
|
|
415
|
+
], HelixHeadlessTimePicker.prototype, "manual", void 0);
|
|
311
416
|
__decorate([
|
|
312
417
|
property()
|
|
313
418
|
], HelixHeadlessTimePicker.prototype, "max", void 0);
|
|
419
|
+
__decorate([
|
|
420
|
+
property({ attribute: 'meridiem-label' })
|
|
421
|
+
], HelixHeadlessTimePicker.prototype, "meridiemLabel", void 0);
|
|
314
422
|
__decorate([
|
|
315
423
|
property()
|
|
316
424
|
], HelixHeadlessTimePicker.prototype, "min", void 0);
|
|
425
|
+
__decorate([
|
|
426
|
+
property({ attribute: 'minute-label' })
|
|
427
|
+
], HelixHeadlessTimePicker.prototype, "minuteLabel", void 0);
|
|
317
428
|
__decorate([
|
|
318
429
|
property({ reflect: true })
|
|
319
430
|
], HelixHeadlessTimePicker.prototype, "mode", void 0);
|
|
431
|
+
__decorate([
|
|
432
|
+
property({ attribute: 'range-overflow-message' })
|
|
433
|
+
], HelixHeadlessTimePicker.prototype, "rangeOverflowMessage", void 0);
|
|
434
|
+
__decorate([
|
|
435
|
+
property({ attribute: 'range-underflow-message' })
|
|
436
|
+
], HelixHeadlessTimePicker.prototype, "rangeUnderflowMessage", void 0);
|
|
320
437
|
__decorate([
|
|
321
438
|
property({ attribute: 'readonly', reflect: true, type: Boolean })
|
|
322
439
|
], HelixHeadlessTimePicker.prototype, "readOnly", void 0);
|
|
323
440
|
__decorate([
|
|
324
441
|
property({ reflect: true, type: Boolean })
|
|
325
442
|
], HelixHeadlessTimePicker.prototype, "required", void 0);
|
|
443
|
+
__decorate([
|
|
444
|
+
property({ attribute: 'second-label' })
|
|
445
|
+
], HelixHeadlessTimePicker.prototype, "secondLabel", void 0);
|
|
446
|
+
__decorate([
|
|
447
|
+
property({ type: Boolean })
|
|
448
|
+
], HelixHeadlessTimePicker.prototype, "seconds", void 0);
|
|
326
449
|
__decorate([
|
|
327
450
|
property({ type: Number })
|
|
328
451
|
], HelixHeadlessTimePicker.prototype, "step", void 0);
|
|
452
|
+
__decorate([
|
|
453
|
+
property({ attribute: 'step-mismatch-message' })
|
|
454
|
+
], HelixHeadlessTimePicker.prototype, "stepMismatchMessage", void 0);
|
|
455
|
+
__decorate([
|
|
456
|
+
property({ attribute: 'unavailable-message' })
|
|
457
|
+
], HelixHeadlessTimePicker.prototype, "unavailableMessage", void 0);
|
|
329
458
|
__decorate([
|
|
330
459
|
property({ attribute: 'value-missing-message' })
|
|
331
460
|
], HelixHeadlessTimePicker.prototype, "valueMissingMessage", void 0);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ChordPress } from '@fusion.dev/helix-core';
|
|
2
|
+
/** A key and the modifiers held with it. */
|
|
3
|
+
export interface Chord {
|
|
4
|
+
alt: boolean;
|
|
5
|
+
ctrl: boolean;
|
|
6
|
+
key: string;
|
|
7
|
+
meta: boolean;
|
|
8
|
+
shift: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** What a key press carries that a chord is compared against. */
|
|
11
|
+
export type Pressed = ChordPress;
|
|
12
|
+
/**
|
|
13
|
+
* Reads a chord written as keys joined by `+`, such as `F8` or `Alt+T`, case
|
|
14
|
+
* aside. The last part is the key. Empty, or a chord with no key, is none.
|
|
15
|
+
*
|
|
16
|
+
* Split as core's `chordParts` splits every chord, and read more strictly than
|
|
17
|
+
* Kbd reads one: four modifiers by their own names, no `mod`, and Shift held
|
|
18
|
+
* exactly as written, so the key that moves to the stack is the one written.
|
|
19
|
+
*/
|
|
20
|
+
export declare const parseHotkey: (text: string) => Chord | null;
|
|
21
|
+
/** Whether a press is the chord: the same key, case aside, and exactly its modifiers. */
|
|
22
|
+
export declare const matchesHotkey: (pressed: Pressed, chord: Chord | null) => boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { chordParts } from '@fusion.dev/helix-core';
|
|
2
|
+
const MODIFIERS = new Set(['alt', 'ctrl', 'meta', 'shift']);
|
|
3
|
+
export const parseHotkey = (text) => {
|
|
4
|
+
const parts = chordParts(text);
|
|
5
|
+
const key = parts.pop();
|
|
6
|
+
if (!key || MODIFIERS.has(key.toLowerCase())) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const held = new Set(parts.map((one) => one.toLowerCase()));
|
|
10
|
+
return {
|
|
11
|
+
alt: held.has('alt'),
|
|
12
|
+
ctrl: held.has('ctrl'),
|
|
13
|
+
key,
|
|
14
|
+
meta: held.has('meta'),
|
|
15
|
+
shift: held.has('shift'),
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export const matchesHotkey = (pressed, chord) => chord !== null &&
|
|
19
|
+
pressed.key.toLowerCase() === chord.key.toLowerCase() &&
|
|
20
|
+
pressed.altKey === chord.alt &&
|
|
21
|
+
pressed.ctrlKey === chord.ctrl &&
|
|
22
|
+
pressed.metaKey === chord.meta &&
|
|
23
|
+
pressed.shiftKey === chord.shift;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HelixElement, type ToneMark } from '@fusion.dev/helix-core';
|
|
1
|
+
import { HelixElement, SwipeController, type ToneMark } from '@fusion.dev/helix-core';
|
|
2
2
|
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
3
3
|
declare const HelixHeadlessToastItem_base: (new (...args: any[]) => import("@fusion.dev/helix-core").DismissibleElement) & typeof HelixElement;
|
|
4
4
|
/**
|
|
@@ -12,6 +12,16 @@ declare const HelixHeadlessToastItem_base: (new (...args: any[]) => import("@fus
|
|
|
12
12
|
* with each new message, and the last of three messages would stay for nine
|
|
13
13
|
* seconds.
|
|
14
14
|
*
|
|
15
|
+
* **Each message is an `alertdialog` named by its words**, which is how a reader
|
|
16
|
+
* who moves into the stack hears which message they are on. A `danger` message
|
|
17
|
+
* is its own assertive live region, so it is announced at once; every other one
|
|
18
|
+
* is announced politely by the region.
|
|
19
|
+
*
|
|
20
|
+
* A touch or a pen swipes a message toward the end of the line, and past
|
|
21
|
+
* halfway, or quickly, dismisses it through the same `helix-dismiss` as its
|
|
22
|
+
* control. While it moves, the distance is on the `item` part as
|
|
23
|
+
* `--toast-swipe-x`.
|
|
24
|
+
*
|
|
15
25
|
* **Messages are inverted by default.** The item flips `color-scheme`, so a new
|
|
16
26
|
* message stands out from the page without using a color that carries meaning.
|
|
17
27
|
*
|
|
@@ -39,6 +49,7 @@ declare const HelixHeadlessToastItem_base: (new (...args: any[]) => import("@fus
|
|
|
39
49
|
* @csspart timer - The bar showing how long is left, where a duration was given.
|
|
40
50
|
*
|
|
41
51
|
* @cssproperty --toast-duration - How long this message stays, in milliseconds, for a progress hint.
|
|
52
|
+
* @cssproperty --toast-swipe-x - How far a swipe has moved the message across, in pixels, toward the right.
|
|
42
53
|
*/
|
|
43
54
|
export declare class HelixHeadlessToastItem extends HelixHeadlessToastItem_base {
|
|
44
55
|
/**
|
|
@@ -64,6 +75,9 @@ export declare class HelixHeadlessToastItem extends HelixHeadlessToastItem_base
|
|
|
64
75
|
*/
|
|
65
76
|
get open(): boolean;
|
|
66
77
|
set open(next: boolean);
|
|
78
|
+
protected readonly swipes: SwipeController;
|
|
79
|
+
/** Writes how far a swipe has moved the message toward the end of the line. */
|
|
80
|
+
private slide;
|
|
67
81
|
/** When the current run of the timer began, or nothing while it is paused. */
|
|
68
82
|
private startedAt;
|
|
69
83
|
/** What is left of the duration, so resuming continues rather than restarts. */
|
|
@@ -106,6 +120,7 @@ export declare class HelixHeadlessToastItem extends HelixHeadlessToastItem_base
|
|
|
106
120
|
connectedCallback(): void;
|
|
107
121
|
disconnectedCallback(): void;
|
|
108
122
|
protected willUpdate(changed: PropertyValues): void;
|
|
123
|
+
protected updated(changed: PropertyValues): void;
|
|
109
124
|
protected firstUpdated(changed: PropertyValues): void;
|
|
110
125
|
/**
|
|
111
126
|
* The mark for the message's tone, behind a seam.
|
|
@@ -4,14 +4,33 @@ 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, MixinDismissible, requestChange, toneMark, } from '@fusion.dev/helix-core';
|
|
8
|
-
import { x } from '@fusion.dev/helix-icons';
|
|
7
|
+
import { customElement, drawDismiss, drawDismissGlyph, HelixElement, hostAria, isRtl, MixinDismissible, requestChange, SwipeController, settleSwipe, swipeEdge, toneMark, towardEdge, } from '@fusion.dev/helix-core';
|
|
9
8
|
import { html, nothing } from 'lit';
|
|
10
9
|
import { property } from 'lit/decorators.js';
|
|
11
10
|
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
|
12
11
|
let HelixHeadlessToastItem = class HelixHeadlessToastItem extends MixinDismissible(HelixElement) {
|
|
13
12
|
constructor() {
|
|
14
13
|
super(...arguments);
|
|
14
|
+
this.swipes = new SwipeController(this, {
|
|
15
|
+
axis: () => (this.open ? 'x' : undefined),
|
|
16
|
+
end: (dx, _dy, vx) => {
|
|
17
|
+
const edge = swipeEdge('end', isRtl(this));
|
|
18
|
+
const width = this.partNamed('item')?.getBoundingClientRect().width ?? 0;
|
|
19
|
+
const shown = settleSwipe({
|
|
20
|
+
points: [1],
|
|
21
|
+
size: width,
|
|
22
|
+
travel: Math.max(0, towardEdge(edge, dx, 0)),
|
|
23
|
+
velocity: towardEdge(edge, vx, 0),
|
|
24
|
+
});
|
|
25
|
+
if (shown === 0 && this.dismiss()) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.slide(0);
|
|
29
|
+
},
|
|
30
|
+
move: (dx) => this.slide(Math.max(0, towardEdge(swipeEdge('end', isRtl(this)), dx, 0))),
|
|
31
|
+
start: (_target, event) => event.pointerType !== 'mouse',
|
|
32
|
+
surface: () => this.partNamed('item'),
|
|
33
|
+
});
|
|
15
34
|
this.openState = undefined;
|
|
16
35
|
this.holds = 0;
|
|
17
36
|
this.handlePause = () => {
|
|
@@ -33,6 +52,10 @@ let HelixHeadlessToastItem = class HelixHeadlessToastItem extends MixinDismissib
|
|
|
33
52
|
this.openState = next;
|
|
34
53
|
this.requestUpdate('open', previous);
|
|
35
54
|
}
|
|
55
|
+
slide(travel) {
|
|
56
|
+
const physical = isRtl(this) ? -travel : travel;
|
|
57
|
+
this.partNamed('item')?.style.setProperty('--toast-swipe-x', travel === 0 ? '' : `${Math.round(physical)}px`);
|
|
58
|
+
}
|
|
36
59
|
dismiss() {
|
|
37
60
|
if (!this.open) {
|
|
38
61
|
return true;
|
|
@@ -86,6 +109,16 @@ let HelixHeadlessToastItem = class HelixHeadlessToastItem extends MixinDismissib
|
|
|
86
109
|
super.willUpdate(changed);
|
|
87
110
|
this.toggleAttribute('data-closed', !this.open);
|
|
88
111
|
this.toggleAttribute('hidden', !this.open);
|
|
112
|
+
hostAria(this.internals, { role: 'alertdialog' });
|
|
113
|
+
this.internals.ariaModal = 'false';
|
|
114
|
+
this.internals.ariaLive = this.tone === 'danger' ? 'assertive' : null;
|
|
115
|
+
}
|
|
116
|
+
updated(changed) {
|
|
117
|
+
super.updated(changed);
|
|
118
|
+
const words = this.partNamed('content');
|
|
119
|
+
if (words) {
|
|
120
|
+
hostAria(this.internals, { labelledBy: [words] });
|
|
121
|
+
}
|
|
89
122
|
}
|
|
90
123
|
firstUpdated(changed) {
|
|
91
124
|
super.firstUpdated(changed);
|
|
@@ -108,9 +141,7 @@ let HelixHeadlessToastItem = class HelixHeadlessToastItem extends MixinDismissib
|
|
|
108
141
|
}
|
|
109
142
|
renderDismissIcon() {
|
|
110
143
|
return html `<slot name="dismiss-icon">
|
|
111
|
-
|
|
112
|
-
${unsafeSVG(x.content)}
|
|
113
|
-
</svg>
|
|
144
|
+
${drawDismissGlyph()}
|
|
114
145
|
</slot>`;
|
|
115
146
|
}
|
|
116
147
|
render() {
|
|
@@ -130,14 +161,11 @@ let HelixHeadlessToastItem = class HelixHeadlessToastItem extends MixinDismissib
|
|
|
130
161
|
<div part="content"><slot></slot></div>
|
|
131
162
|
<div part="actions"><slot name="actions"></slot></div>
|
|
132
163
|
${this.dismissible
|
|
133
|
-
?
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
>
|
|
139
|
-
${this.renderDismissIcon()}
|
|
140
|
-
</button>`
|
|
164
|
+
? drawDismiss({
|
|
165
|
+
label: this.dismissLabel,
|
|
166
|
+
mark: this.renderDismissIcon(),
|
|
167
|
+
onDismiss: () => this.dismiss(),
|
|
168
|
+
})
|
|
141
169
|
: nothing}
|
|
142
170
|
${this.duration
|
|
143
171
|
? html `<div
|