@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,9 +4,11 @@ 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, elapsedTime, HelixElement, subscribe } from '@fusion.dev/helix-core';
|
|
7
|
+
import { customElement, elapsedTime, HelixElement, relativeTime, subscribe, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html, nothing } from 'lit';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
|
+
import { formatOptions } from '../options.js';
|
|
11
|
+
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
10
12
|
let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement {
|
|
11
13
|
constructor() {
|
|
12
14
|
super(...arguments);
|
|
@@ -18,6 +20,9 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
18
20
|
this.stopTicking = undefined;
|
|
19
21
|
this.watching = undefined;
|
|
20
22
|
}
|
|
23
|
+
get dateOnly() {
|
|
24
|
+
return DATE_ONLY.test((this.date || this.written).trim());
|
|
25
|
+
}
|
|
21
26
|
get moment() {
|
|
22
27
|
const source = this.date || this.written;
|
|
23
28
|
if (source === '') {
|
|
@@ -27,35 +32,33 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
27
32
|
return Number.isNaN(parsed.getTime()) ? undefined : parsed;
|
|
28
33
|
}
|
|
29
34
|
get options() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
return asked;
|
|
35
|
+
return formatOptions({
|
|
36
|
+
dateOnly: this.dateOnly,
|
|
37
|
+
dateStyle: this.dateStyle,
|
|
38
|
+
day: this.day,
|
|
39
|
+
era: this.era,
|
|
40
|
+
hour: this.hour,
|
|
41
|
+
hourCycle: this.hourCycle,
|
|
42
|
+
minute: this.minute,
|
|
43
|
+
month: this.month,
|
|
44
|
+
second: this.second,
|
|
45
|
+
timeStyle: this.timeStyle,
|
|
46
|
+
timeZone: this.timeZone,
|
|
47
|
+
timeZoneName: this.timeZoneName,
|
|
48
|
+
weekday: this.weekday,
|
|
49
|
+
year: this.year,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
get reading() {
|
|
53
|
+
return this.elapsed || this.relative !== undefined;
|
|
54
|
+
}
|
|
55
|
+
readingAt(moment, now) {
|
|
56
|
+
return this.elapsed
|
|
57
|
+
? elapsedTime(this.locale)(moment, now)
|
|
58
|
+
: relativeTime(this.locale, {
|
|
59
|
+
numeric: this.numeric ?? 'auto',
|
|
60
|
+
style: this.relative ?? 'long',
|
|
61
|
+
})(moment, now);
|
|
59
62
|
}
|
|
60
63
|
connectedCallback() {
|
|
61
64
|
super.connectedCallback();
|
|
@@ -81,7 +84,11 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
81
84
|
if (this.childrenKnown) {
|
|
82
85
|
this.read();
|
|
83
86
|
}
|
|
84
|
-
if (changed.has('date') ||
|
|
87
|
+
if (changed.has('date') ||
|
|
88
|
+
changed.has('elapsed') ||
|
|
89
|
+
changed.has('locale') ||
|
|
90
|
+
changed.has('numeric') ||
|
|
91
|
+
changed.has('relative')) {
|
|
85
92
|
this.tick();
|
|
86
93
|
}
|
|
87
94
|
}
|
|
@@ -104,12 +111,12 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
104
111
|
this.stopTicking?.();
|
|
105
112
|
this.stopTicking = undefined;
|
|
106
113
|
const moment = this.moment;
|
|
107
|
-
if (!moment || !this.
|
|
114
|
+
if (!moment || !this.reading) {
|
|
108
115
|
return;
|
|
109
116
|
}
|
|
110
117
|
const now = new Date();
|
|
111
118
|
this.clock = now.getTime();
|
|
112
|
-
const { next } =
|
|
119
|
+
const { next } = this.readingAt(moment, now);
|
|
113
120
|
if (!Number.isFinite(next) || !this.isConnected) {
|
|
114
121
|
return;
|
|
115
122
|
}
|
|
@@ -120,24 +127,49 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
120
127
|
if (!moment) {
|
|
121
128
|
return nothing;
|
|
122
129
|
}
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
const datetime = this.dateOnly ? (this.date || this.written).trim() : moment.toISOString();
|
|
131
|
+
if (!this.reading) {
|
|
132
|
+
const text = new Intl.DateTimeFormat(this.locale || undefined, this.options).format(moment);
|
|
133
|
+
return html `<time part="time" datetime=${datetime}>${text}</time>`;
|
|
134
|
+
}
|
|
135
|
+
const now = new Date(this.clock ?? Date.now());
|
|
136
|
+
const zone = this.timeZone || (this.dateOnly ? 'UTC' : undefined);
|
|
137
|
+
const whole = new Intl.DateTimeFormat(this.locale || undefined, {
|
|
138
|
+
dateStyle: 'long',
|
|
139
|
+
...(this.dateOnly ? {} : { timeStyle: 'short' }),
|
|
140
|
+
...(this.hourCycle ? { hourCycle: this.hourCycle } : {}),
|
|
141
|
+
...(zone ? { timeZone: zone } : {}),
|
|
142
|
+
}).format(moment);
|
|
143
|
+
const spoken = relativeTime(this.locale, { numeric: this.numeric ?? 'auto' })(moment, now).text;
|
|
144
|
+
return html `<time
|
|
145
|
+
part="time"
|
|
146
|
+
datetime=${datetime}
|
|
147
|
+
aria-label=${spoken}
|
|
148
|
+
title=${whole}
|
|
149
|
+
>${this.readingAt(moment, now).text}</time>`;
|
|
127
150
|
}
|
|
128
151
|
};
|
|
129
152
|
__decorate([
|
|
130
153
|
property()
|
|
131
154
|
], HelixHeadlessFormatDate.prototype, "date", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
property({ attribute: 'date-style' })
|
|
157
|
+
], HelixHeadlessFormatDate.prototype, "dateStyle", void 0);
|
|
132
158
|
__decorate([
|
|
133
159
|
property()
|
|
134
160
|
], HelixHeadlessFormatDate.prototype, "day", void 0);
|
|
135
161
|
__decorate([
|
|
136
162
|
property({ reflect: true, type: Boolean })
|
|
137
163
|
], HelixHeadlessFormatDate.prototype, "elapsed", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
property()
|
|
166
|
+
], HelixHeadlessFormatDate.prototype, "era", void 0);
|
|
138
167
|
__decorate([
|
|
139
168
|
property()
|
|
140
169
|
], HelixHeadlessFormatDate.prototype, "hour", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
property({ attribute: 'hour-cycle' })
|
|
172
|
+
], HelixHeadlessFormatDate.prototype, "hourCycle", void 0);
|
|
141
173
|
__decorate([
|
|
142
174
|
property()
|
|
143
175
|
], HelixHeadlessFormatDate.prototype, "locale", void 0);
|
|
@@ -147,9 +179,18 @@ __decorate([
|
|
|
147
179
|
__decorate([
|
|
148
180
|
property()
|
|
149
181
|
], HelixHeadlessFormatDate.prototype, "month", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
property()
|
|
184
|
+
], HelixHeadlessFormatDate.prototype, "numeric", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
property()
|
|
187
|
+
], HelixHeadlessFormatDate.prototype, "relative", void 0);
|
|
150
188
|
__decorate([
|
|
151
189
|
property()
|
|
152
190
|
], HelixHeadlessFormatDate.prototype, "second", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
property({ attribute: 'time-style' })
|
|
193
|
+
], HelixHeadlessFormatDate.prototype, "timeStyle", void 0);
|
|
153
194
|
__decorate([
|
|
154
195
|
property({ attribute: 'time-zone' })
|
|
155
196
|
], HelixHeadlessFormatDate.prototype, "timeZone", void 0);
|
|
@@ -232,16 +232,37 @@ export declare class HelixHeadlessGraph extends HelixHeadlessGraph_base {
|
|
|
232
232
|
/**
|
|
233
233
|
* Moves the keyboard to a row, and the list to show it.
|
|
234
234
|
*
|
|
235
|
-
* **
|
|
236
|
-
*
|
|
237
|
-
*
|
|
235
|
+
* **The row the keys are on is always drawn**, beside the window where it is
|
|
236
|
+
* outside it, so `aria-activedescendant` names a row that exists. The list
|
|
237
|
+
* then scrolls to it, see `revealCursor`.
|
|
238
238
|
*/
|
|
239
239
|
private moveTo;
|
|
240
|
+
/**
|
|
241
|
+
* Brings the cursor's row into the list's box.
|
|
242
|
+
*
|
|
243
|
+
* **By the row's own box once it is in the window, and by the window
|
|
244
|
+
* otherwise.** The offset of a row that has not been drawn is a guess at its
|
|
245
|
+
* height, and a guess at 32 pixels was where End and Page Down sent the list
|
|
246
|
+
* when rows were taller: the list landed far from the row, which then was
|
|
247
|
+
* not drawn. So the window is moved toward the row, the rows it draws are
|
|
248
|
+
* measured, and the next try starts from there, a few times at most.
|
|
249
|
+
*/
|
|
250
|
+
private revealCursor;
|
|
251
|
+
/** The cursor's row, where it is outside the window and drawn beside it. */
|
|
252
|
+
private get keptRow();
|
|
240
253
|
/**
|
|
241
254
|
* The keys in the list. **Kept from the frame**, whose arrows pan the
|
|
242
255
|
* drawing: a reader moving through the list was moving the graph under it.
|
|
243
256
|
*/
|
|
244
257
|
private readonly handleListKeydown;
|
|
258
|
+
/** What has been typed toward a note's name, and when the last letter came. */
|
|
259
|
+
private typed;
|
|
260
|
+
/**
|
|
261
|
+
* Moves to the next note whose name starts with what was typed, as a
|
|
262
|
+
* listbox does. Letters within half a second of each other run together,
|
|
263
|
+
* and a repeated letter steps through the names that start with it.
|
|
264
|
+
*/
|
|
265
|
+
private typeahead;
|
|
245
266
|
/**
|
|
246
267
|
* The search field's keys, which belong to the field and never pan the
|
|
247
268
|
* graph. Escape empties a search that has words in it, and passes through
|
|
@@ -4,10 +4,11 @@ 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, fillTemplate, formatNumbers, HelixElement, HelixGraphFilterEvent, HelixGraphLayoutEvent, HelixGraphPanEvent, HelixGraphPartChangeEvent, HelixGraphReadyEvent, HelixGraphSignalEvent, HelixGraphZoomEvent, MixinControllerActive, MixinViewport, VirtualizeController, } from '@fusion.dev/helix-core';
|
|
7
|
+
import { customElement, fillTemplate, formatNumbers, HelixElement, HelixGraphFilterEvent, HelixGraphLayoutEvent, HelixGraphPanEvent, HelixGraphPartChangeEvent, HelixGraphReadyEvent, HelixGraphSignalEvent, HelixGraphZoomEvent, MixinControllerActive, MixinViewport, scrollItemIntoView, VirtualizeController, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { list, magnifyingGlass } from '@fusion.dev/helix-icons';
|
|
9
9
|
import { html, nothing } from 'lit';
|
|
10
10
|
import { property, state } from 'lit/decorators.js';
|
|
11
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
11
12
|
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
|
12
13
|
import { adjacencyOf, entriesOf, groupsOf, nameOf, sortedOf, within, withoutGroups, } from './graph-model.js';
|
|
13
14
|
const PAGE = 10;
|
|
@@ -65,8 +66,15 @@ let HelixHeadlessGraph = class HelixHeadlessGraph extends MixinViewport(MixinCon
|
|
|
65
66
|
event.preventDefault();
|
|
66
67
|
event.stopPropagation();
|
|
67
68
|
this.choose(this.cursor);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (event.key.length === 1 && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
event.stopPropagation();
|
|
74
|
+
this.typeahead(event.key);
|
|
68
75
|
}
|
|
69
76
|
};
|
|
77
|
+
this.typed = { at: 0, text: '' };
|
|
70
78
|
this.handleSearchKeydown = (event) => {
|
|
71
79
|
if (event.key === 'ArrowDown') {
|
|
72
80
|
event.preventDefault();
|
|
@@ -236,18 +244,50 @@ let HelixHeadlessGraph = class HelixHeadlessGraph extends MixinViewport(MixinCon
|
|
|
236
244
|
moveTo(index) {
|
|
237
245
|
const last = this.entries.length - 1;
|
|
238
246
|
this.cursor = Math.min(Math.max(index, 0), Math.max(last, 0));
|
|
247
|
+
void this.updateComplete.then(() => this.revealCursor());
|
|
248
|
+
}
|
|
249
|
+
revealCursor(attempts = 8) {
|
|
239
250
|
const list = this.partNamed('list');
|
|
240
251
|
if (!list) {
|
|
241
252
|
return;
|
|
242
253
|
}
|
|
243
|
-
const
|
|
244
|
-
if (
|
|
245
|
-
row.
|
|
254
|
+
const { first, last } = this.virtualize.window;
|
|
255
|
+
if (this.cursor >= first && this.cursor < last) {
|
|
256
|
+
const row = this.renderRoot.querySelector?.(`[data-index="${this.cursor}"]`);
|
|
257
|
+
if (row) {
|
|
258
|
+
scrollItemIntoView(row, { scroller: list });
|
|
259
|
+
}
|
|
260
|
+
return;
|
|
246
261
|
}
|
|
247
|
-
|
|
248
|
-
|
|
262
|
+
if (attempts === 0) {
|
|
263
|
+
return;
|
|
249
264
|
}
|
|
265
|
+
this.virtualize.reveal(this.cursor);
|
|
250
266
|
this.virtualize.measure();
|
|
267
|
+
void this.updateComplete.then(() => this.revealCursor(attempts - 1));
|
|
268
|
+
}
|
|
269
|
+
get keptRow() {
|
|
270
|
+
const { first, last } = this.virtualize.window;
|
|
271
|
+
const cursor = this.cursor;
|
|
272
|
+
return this.entries.length > 0 && (cursor < first || cursor >= last) ? cursor : undefined;
|
|
273
|
+
}
|
|
274
|
+
typeahead(letter) {
|
|
275
|
+
const now = Date.now();
|
|
276
|
+
const text = now - this.typed.at < 500 ? this.typed.text + letter : letter;
|
|
277
|
+
this.typed = { at: now, text };
|
|
278
|
+
const wanted = text.toLocaleLowerCase();
|
|
279
|
+
const repeated = [...wanted].every((one) => one === wanted[0]);
|
|
280
|
+
const prefix = repeated ? (wanted[0] ?? '') : wanted;
|
|
281
|
+
const entries = this.entries;
|
|
282
|
+
const start = repeated ? this.cursor + 1 : this.cursor;
|
|
283
|
+
for (let step = 0; step < entries.length; step += 1) {
|
|
284
|
+
const at = (start + step) % entries.length;
|
|
285
|
+
const entry = entries[at];
|
|
286
|
+
if (entry && nameOf(entry.node).toLocaleLowerCase().startsWith(prefix)) {
|
|
287
|
+
this.moveTo(at);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
251
291
|
}
|
|
252
292
|
togglePanel(open = !this.panelOpen) {
|
|
253
293
|
const inside = this.panelOpen && this.partNamed('panel')?.contains(this.shadowRoot?.activeElement ?? null);
|
|
@@ -290,8 +330,18 @@ let HelixHeadlessGraph = class HelixHeadlessGraph extends MixinViewport(MixinCon
|
|
|
290
330
|
renderRows() {
|
|
291
331
|
const { first, last } = this.virtualize.window;
|
|
292
332
|
const total = this.entries.length;
|
|
293
|
-
|
|
294
|
-
|
|
333
|
+
const indices = Array.from({ length: Math.max(0, Math.min(last, total) - first) }, (_, at) => first + at);
|
|
334
|
+
const kept = this.keptRow;
|
|
335
|
+
if (kept !== undefined && kept < total) {
|
|
336
|
+
if (kept < first) {
|
|
337
|
+
indices.unshift(kept);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
indices.push(kept);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return html `${repeat(indices, (index) => index, (index) => {
|
|
344
|
+
const entry = this.entries[index];
|
|
295
345
|
const relation = this.relationText(entry);
|
|
296
346
|
const chosen = entry.relation === 'selected';
|
|
297
347
|
return html `<div
|
|
@@ -311,10 +361,14 @@ let HelixHeadlessGraph = class HelixHeadlessGraph extends MixinViewport(MixinCon
|
|
|
311
361
|
<span part="note-name">${nameOf(entry.node)}</span>
|
|
312
362
|
${relation ? html `<span part="note-relation" aria-hidden="true">${relation}</span>` : nothing}
|
|
313
363
|
</div>`;
|
|
314
|
-
})
|
|
364
|
+
})}`;
|
|
315
365
|
}
|
|
316
366
|
render() {
|
|
317
|
-
const
|
|
367
|
+
const window = this.virtualize.window;
|
|
368
|
+
const kept = this.keptRow;
|
|
369
|
+
const room = kept === undefined ? 0 : this.virtualize.sizeOf(kept);
|
|
370
|
+
const before = Math.max(0, window.before - (kept !== undefined && kept < window.first ? room : 0));
|
|
371
|
+
const after = Math.max(0, window.after - (kept !== undefined && kept >= window.last ? room : 0));
|
|
318
372
|
const cursor = this.entries.length > 0 ? `note-${this.cursor}` : nothing;
|
|
319
373
|
return html `<div
|
|
320
374
|
part="region"
|
|
@@ -368,9 +422,9 @@ let HelixHeadlessGraph = class HelixHeadlessGraph extends MixinViewport(MixinCon
|
|
|
368
422
|
@keydown=${this.handleListKeydown}
|
|
369
423
|
@scroll=${() => this.virtualize.measure()}
|
|
370
424
|
>
|
|
371
|
-
<div part="before" style="block-size: ${before}px"></div>
|
|
425
|
+
<div part="before" role="presentation" style="block-size: ${before}px"></div>
|
|
372
426
|
${this.renderRows()}
|
|
373
|
-
<div part="after" style="block-size: ${after}px"></div>
|
|
427
|
+
<div part="after" role="presentation" style="block-size: ${after}px"></div>
|
|
374
428
|
</div>
|
|
375
429
|
</div>
|
|
376
430
|
</div>
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
/** A reading, reduced to what the bucketing needs. */
|
|
11
11
|
export interface Reading {
|
|
12
12
|
tone?: string | undefined;
|
|
13
|
-
|
|
13
|
+
/** The number, or undefined for a row whose cell was blank. */
|
|
14
|
+
value: number | undefined;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* The tone for one reading, from its own `data-tone` or from the thresholds.
|
|
@@ -6,8 +6,12 @@ export const toneOf = (reading, thresholds, tones) => {
|
|
|
6
6
|
return undefined;
|
|
7
7
|
}
|
|
8
8
|
let chosen;
|
|
9
|
+
const value = reading.value;
|
|
10
|
+
if (value === undefined) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
9
13
|
for (const [index, bound] of thresholds.entries()) {
|
|
10
|
-
if (
|
|
14
|
+
if (value >= bound) {
|
|
11
15
|
chosen = tones[index] ?? chosen;
|
|
12
16
|
}
|
|
13
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HelixElement } from '@fusion.dev/helix-core';
|
|
1
|
+
import { AriaForwardController, HelixElement } from '@fusion.dev/helix-core';
|
|
2
2
|
import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
3
3
|
import '../../tooltip/index.js';
|
|
4
4
|
declare const HelixHeadlessHeatmap_base: typeof HelixElement & (new (...args: any[]) => import("@fusion.dev/helix-core").MixinChartSourceInterface);
|
|
@@ -26,6 +26,12 @@ declare const HelixHeadlessHeatmap_base: typeof HelixElement & (new (...args: an
|
|
|
26
26
|
* your own stylesheet defines that property. The headless tier does not use
|
|
27
27
|
* `var(--helix-color-*)`.
|
|
28
28
|
*
|
|
29
|
+
* **The strip is read by key.** It takes focus once it has cells. The up and
|
|
30
|
+
* down arrows move a cell, the left and right arrows move a column, which is a
|
|
31
|
+
* week with `rows="7"`, and Home and End go to the first and the last. The
|
|
32
|
+
* tooltip follows, the `live` part says the cell's row in words, and Escape
|
|
33
|
+
* puts the tooltip away.
|
|
34
|
+
*
|
|
29
35
|
* @since 0.1.0
|
|
30
36
|
* @status stable
|
|
31
37
|
* @category charts
|
|
@@ -39,12 +45,14 @@ declare const HelixHeadlessHeatmap_base: typeof HelixElement & (new (...args: an
|
|
|
39
45
|
* @event {HelixResizeEvent} helix-resize - Fired when the number of cells drawn changes, with the new number.
|
|
40
46
|
*
|
|
41
47
|
* @csspart cell - One reading.
|
|
48
|
+
* @csspart cell-active - The cell the pointer or the keys rest on. Set alongside `cell`.
|
|
42
49
|
* @csspart empty - Shown when the table has no readings. It stays hidden until the table can be read: on the server and during hydration, there is no document to resolve `for` in.
|
|
43
50
|
* @csspart end - The trailing slot's box.
|
|
44
51
|
* @csspart footer - The three-slot row under the strip.
|
|
52
|
+
* @csspart live - The readout: a polite live region that says the cell the keys moved to. Hide it visually.
|
|
45
53
|
* @csspart mark - The invisible point the tooltip is anchored to.
|
|
46
54
|
* @csspart start - The leading slot's box.
|
|
47
|
-
* @csspart strip - The grid of cells.
|
|
55
|
+
* @csspart strip - The grid of cells, which takes focus to be read by key. It is named by the host's `aria-labelledby` or `aria-label`, then by `label`, then by the caption of the table.
|
|
48
56
|
* @csspart summary - The middle slot's box.
|
|
49
57
|
* @csspart tooltip - The bubble, forwarded from `Tooltip`.
|
|
50
58
|
* @csspart tooltip-anchor - The `Tooltip` element itself.
|
|
@@ -55,6 +63,7 @@ declare const HelixHeadlessHeatmap_base: typeof HelixElement & (new (...args: an
|
|
|
55
63
|
* @csspart tooltip-arrow-top - The point while the bubble is above the reading, on its bottom edge. Set alongside `tooltip-arrow`.
|
|
56
64
|
* @csspart tooltip-bottom - The bubble while it is below the reading. Set alongside `tooltip`.
|
|
57
65
|
* @csspart tooltip-cell - One column's name and value inside the tooltip.
|
|
66
|
+
* @csspart tooltip-cell-current - The cell the series keys rest on, in the charts whose readings hold several series. A strip draws one, so it is never set here.
|
|
58
67
|
* @csspart tooltip-label - The reading's own name inside the tooltip.
|
|
59
68
|
* @csspart tooltip-left - The bubble while it is left of the reading. Set alongside `tooltip`.
|
|
60
69
|
* @csspart tooltip-name - A column's name inside the tooltip.
|
|
@@ -184,18 +193,36 @@ export declare class HelixHeadlessHeatmap extends HelixHeadlessHeatmap_base {
|
|
|
184
193
|
*/
|
|
185
194
|
private metrics;
|
|
186
195
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
196
|
+
* Carries a host `aria-labelledby` and `aria-describedby` to the strip, the
|
|
197
|
+
* image a reader lands on. The host is a generic around it.
|
|
198
|
+
*/
|
|
199
|
+
protected readonly aria: AriaForwardController;
|
|
200
|
+
/**
|
|
201
|
+
* Hears an `aria-label` written on the element, which no property mirrors.
|
|
202
|
+
*
|
|
203
|
+
* Lit observes the attributes of its own properties only, and `ariaLabel`
|
|
204
|
+
* belongs to the platform.
|
|
205
|
+
*/
|
|
206
|
+
static get observedAttributes(): string[];
|
|
207
|
+
/**
|
|
208
|
+
* Called by the browser when an observed attribute changes. A new
|
|
209
|
+
* `aria-label` asks for an update, because it names the strip.
|
|
189
210
|
*/
|
|
190
|
-
|
|
211
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
191
212
|
private observer;
|
|
192
213
|
private announced;
|
|
193
214
|
/**
|
|
194
|
-
* Every
|
|
215
|
+
* Every row in the table, oldest first, as the table is written, with its
|
|
216
|
+
* reading where the row has one.
|
|
195
217
|
*
|
|
196
218
|
* **Not `readings`, which the mixin already has and which means a count.**
|
|
197
219
|
* Two members of the same name meaning a number and an array is the kind of
|
|
198
220
|
* collision that type-checks in one direction and reads wrong in both.
|
|
221
|
+
*
|
|
222
|
+
* **One cell per row, and a blank row is a cell with no reading.** Taken from
|
|
223
|
+
* the series alone, a blank dropped its day and every day after it moved one
|
|
224
|
+
* cell along, while the tooltip still counted rows and named the day beside
|
|
225
|
+
* the one under the pointer.
|
|
199
226
|
*/
|
|
200
227
|
private get points();
|
|
201
228
|
/**
|
|
@@ -260,9 +287,21 @@ export declare class HelixHeadlessHeatmap extends HelixHeadlessHeatmap_base {
|
|
|
260
287
|
* keep the oldest is answering a question nobody asked.
|
|
261
288
|
*/
|
|
262
289
|
private get drawn();
|
|
290
|
+
/**
|
|
291
|
+
* The number of cells drawn, which the keys walk.
|
|
292
|
+
*
|
|
293
|
+
* The mixin counts the table's rows, and a strip too narrow for all of them
|
|
294
|
+
* draws the newest, so a key stepping by rows would walk off the drawing.
|
|
295
|
+
*/
|
|
296
|
+
get readings(): number;
|
|
297
|
+
/**
|
|
298
|
+
* Tells the keys how many days stand in a column, so the up and down arrows
|
|
299
|
+
* move a day and the across pair a week. Here rather than in `updated`, for
|
|
300
|
+
* the reason `BarChart` gives: SSR calls this one.
|
|
301
|
+
*/
|
|
302
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
263
303
|
connectedCallback(): void;
|
|
264
304
|
disconnectedCallback(): void;
|
|
265
|
-
protected willUpdate(changed: PropertyValues): void;
|
|
266
305
|
/**
|
|
267
306
|
* Says on the footer whether any of its three slots holds anything.
|
|
268
307
|
*
|
|
@@ -303,8 +342,7 @@ export declare class HelixHeadlessHeatmap extends HelixHeadlessHeatmap_base {
|
|
|
303
342
|
*
|
|
304
343
|
* `pointerover` on the strip rather than a listener per cell: the event
|
|
305
344
|
* bubbles, so one handler covers however many cells there are, and unlike
|
|
306
|
-
* `mouseover` it is delivered for a pen
|
|
307
|
-
* press.
|
|
345
|
+
* `mouseover` it is delivered for a pen.
|
|
308
346
|
*/
|
|
309
347
|
private readonly onPointerOver;
|
|
310
348
|
private readonly onPointerLeave;
|
|
@@ -4,7 +4,7 @@ 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 { CHART_PLOT, customElement, drawTooltip, HelixElement, HelixResizeEvent,
|
|
7
|
+
import { AriaForwardController, byRow, CHART_PLOT, customElement, drawTooltip, HelixElement, HelixResizeEvent, MixinChartSource, markRegion, searchableById, writtenList, writtenNumbers, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html, nothing } from 'lit';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
10
|
import '../../tooltip/index.js';
|
|
@@ -20,23 +20,43 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
20
20
|
this.tones = '';
|
|
21
21
|
this.width = undefined;
|
|
22
22
|
this.metrics = undefined;
|
|
23
|
-
this.
|
|
23
|
+
this.aria = new AriaForwardController(this, {
|
|
24
|
+
target: () => this.partNamed('strip'),
|
|
25
|
+
});
|
|
24
26
|
this.observer = undefined;
|
|
25
27
|
this.announced = undefined;
|
|
26
28
|
this.onPointerOver = (event) => {
|
|
27
|
-
|
|
29
|
+
if (!this.pointer.accepts(event)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const cell = event.target?.closest?.('[part~="cell"]');
|
|
28
33
|
const index = Number(cell?.getAttribute('data-index') ?? -1);
|
|
29
|
-
this.
|
|
34
|
+
this.pointer.set(Number.isInteger(index) ? index : -1);
|
|
30
35
|
};
|
|
31
36
|
this.onPointerLeave = () => {
|
|
32
|
-
this.
|
|
37
|
+
if (!this.pointer.keyed) {
|
|
38
|
+
this.pointer.set(-1);
|
|
39
|
+
}
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
42
|
get visible() {
|
|
36
43
|
return Math.min(this.points.length, this.room);
|
|
37
44
|
}
|
|
45
|
+
static get observedAttributes() {
|
|
46
|
+
return [...super.observedAttributes, 'aria-label'];
|
|
47
|
+
}
|
|
48
|
+
attributeChangedCallback(name, old, value) {
|
|
49
|
+
super.attributeChangedCallback(name, old, value);
|
|
50
|
+
if (name === 'aria-label') {
|
|
51
|
+
this.requestUpdate();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
38
54
|
get points() {
|
|
39
|
-
|
|
55
|
+
const series = this.series[0];
|
|
56
|
+
if (!series) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
return byRow(series, this.sourceRows.length).map((point) => point ?? { value: undefined });
|
|
40
60
|
}
|
|
41
61
|
get sourceKnown() {
|
|
42
62
|
if (this.for === '') {
|
|
@@ -79,6 +99,13 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
79
99
|
const all = this.points;
|
|
80
100
|
return all.slice(Math.max(0, all.length - this.room));
|
|
81
101
|
}
|
|
102
|
+
get readings() {
|
|
103
|
+
return this.drawn.length;
|
|
104
|
+
}
|
|
105
|
+
willUpdate(changed) {
|
|
106
|
+
super.willUpdate(changed);
|
|
107
|
+
this.pointer.grid = this.rowCount;
|
|
108
|
+
}
|
|
82
109
|
connectedCallback() {
|
|
83
110
|
super.connectedCallback();
|
|
84
111
|
if (typeof ResizeObserver !== 'undefined') {
|
|
@@ -96,10 +123,6 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
96
123
|
this.observer?.disconnect();
|
|
97
124
|
this.observer = undefined;
|
|
98
125
|
}
|
|
99
|
-
willUpdate(changed) {
|
|
100
|
-
super.willUpdate(changed);
|
|
101
|
-
hostAria(this.internals, { label: this.label || 'Heatmap', role: 'img' });
|
|
102
|
-
}
|
|
103
126
|
markEmpty() {
|
|
104
127
|
markRegion(this.renderRoot, 'footer', ['start', 'summary', 'end']);
|
|
105
128
|
}
|
|
@@ -126,10 +149,14 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
126
149
|
const bounds = writtenNumbers(this.thresholds);
|
|
127
150
|
const palette = writtenList(this.tones);
|
|
128
151
|
const cells = this.drawn;
|
|
152
|
+
const readable = cells.length > 0;
|
|
129
153
|
return html `<div
|
|
154
|
+
aria-label=${this.getAttribute?.('aria-label') || this.named || 'Heatmap'}
|
|
130
155
|
part="strip"
|
|
131
156
|
id=${CHART_PLOT}
|
|
157
|
+
role=${readable ? 'application' : 'img'}
|
|
132
158
|
style="--heatmap-rows: ${this.rowCount}"
|
|
159
|
+
tabindex=${readable ? '0' : nothing}
|
|
133
160
|
@pointerover=${this.onPointerOver}
|
|
134
161
|
@pointerleave=${this.onPointerLeave}
|
|
135
162
|
>
|
|
@@ -137,10 +164,14 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
137
164
|
? nothing
|
|
138
165
|
: cells.map((reading, index) => {
|
|
139
166
|
const tone = toneOf(reading, bounds, palette);
|
|
167
|
+
const active = this.pointer.at === index;
|
|
140
168
|
return tone === undefined
|
|
141
|
-
? html `<span
|
|
169
|
+
? html `<span
|
|
170
|
+
part="cell${active ? ' cell-active' : ''}"
|
|
171
|
+
data-index=${index}
|
|
172
|
+
></span>`
|
|
142
173
|
: html `<span
|
|
143
|
-
part="cell"
|
|
174
|
+
part="cell${active ? ' cell-active' : ''}"
|
|
144
175
|
data-index=${index}
|
|
145
176
|
data-tone=${tone}
|
|
146
177
|
style="--heatmap-tone: var(--heatmap-tone-${tone})"
|
|
@@ -156,9 +187,9 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
156
187
|
</div>`;
|
|
157
188
|
}
|
|
158
189
|
renderTooltip() {
|
|
159
|
-
const at = this.
|
|
190
|
+
const at = this.pointer.at;
|
|
160
191
|
if (at < 0) {
|
|
161
|
-
return
|
|
192
|
+
return drawTooltip(this.sourceRows, -1, this.tag('tooltip'), undefined, undefined, this.pointer);
|
|
162
193
|
}
|
|
163
194
|
const offset = this.points.length - this.drawn.length;
|
|
164
195
|
const cell = this.cellPx;
|
|
@@ -169,7 +200,7 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
169
200
|
placement: 'top',
|
|
170
201
|
x: `${column * (cell + gap) + cell / 2}px`,
|
|
171
202
|
y: `${row * (cell + gap)}px`,
|
|
172
|
-
});
|
|
203
|
+
}, undefined, this.pointer);
|
|
173
204
|
}
|
|
174
205
|
};
|
|
175
206
|
__decorate([
|
|
@@ -196,9 +227,6 @@ __decorate([
|
|
|
196
227
|
__decorate([
|
|
197
228
|
state()
|
|
198
229
|
], HelixHeadlessHeatmap.prototype, "metrics", void 0);
|
|
199
|
-
__decorate([
|
|
200
|
-
state()
|
|
201
|
-
], HelixHeadlessHeatmap.prototype, "hovered", void 0);
|
|
202
230
|
HelixHeadlessHeatmap = __decorate([
|
|
203
231
|
customElement('helix-headless-heatmap')
|
|
204
232
|
], HelixHeadlessHeatmap);
|
package/dist/icon/index.d.ts
CHANGED
package/dist/icon/index.js
CHANGED