@fusion.dev/helix-headless 0.143.0 → 0.145.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 +16990 -1383
- package/dist/accordion/item/accordion-item.d.ts +48 -12
- package/dist/accordion/item/accordion-item.js +26 -5
- package/dist/accordion/root/accordion-root.d.ts +6 -0
- package/dist/accordion/root/accordion-root.js +7 -1
- package/dist/announcement/root/announcement-root.d.ts +21 -1
- package/dist/announcement/root/announcement-root.js +36 -1
- package/dist/app-header/root/app-header-root.d.ts +7 -0
- package/dist/app-header/root/app-header-root.js +5 -1
- package/dist/app-header/sectioning.d.ts +7 -0
- package/dist/app-header/sectioning.js +26 -0
- package/dist/area-chart/root/area-chart-root.d.ts +12 -4
- package/dist/area-chart/root/area-chart-root.js +24 -7
- package/dist/avatar/root/avatar-root.d.ts +14 -0
- package/dist/avatar/root/avatar-root.js +23 -9
- package/dist/badge/root/badge-root.d.ts +11 -7
- package/dist/badge/root/badge-root.js +1 -1
- package/dist/bar-chart/root/bar-chart-root.d.ts +12 -3
- package/dist/bar-chart/root/bar-chart-root.js +17 -10
- package/dist/breadcrumbs/root/breadcrumbs-root.d.ts +32 -1
- package/dist/breadcrumbs/root/breadcrumbs-root.js +25 -2
- package/dist/button/root/button-root.d.ts +47 -1
- package/dist/button/root/button-root.js +38 -4
- package/dist/callout/root/callout-root.d.ts +18 -1
- package/dist/callout/root/callout-root.js +15 -4
- package/dist/canvas/root/canvas-root.d.ts +38 -3
- package/dist/canvas/root/canvas-root.js +121 -40
- 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 +90 -0
- package/dist/carousel/root/carousel-root.js +134 -12
- package/dist/chat/composer/chat-composer.d.ts +38 -6
- package/dist/chat/composer/chat-composer.js +42 -9
- package/dist/chat/message/chat-message.d.ts +32 -1
- package/dist/chat/message/chat-message.js +25 -9
- package/dist/chat/naming.d.ts +22 -0
- package/dist/chat/naming.js +12 -0
- package/dist/chat/relative-clock.d.ts +39 -0
- package/dist/chat/relative-clock.js +31 -0
- package/dist/chat/root/chat-root.d.ts +36 -0
- package/dist/chat/root/chat-root.js +24 -1
- package/dist/checkbox/root/checkbox-root.js +2 -0
- package/dist/checkbox-group/root/checkbox-group-root.d.ts +53 -3
- package/dist/checkbox-group/root/checkbox-group-root.js +71 -22
- 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 +38 -1
- package/dist/code-block/root/code-block-root.js +28 -7
- package/dist/color-input/root/color-input-root.d.ts +34 -1
- package/dist/color-input/root/color-input-root.js +23 -4
- 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 +81 -5
- package/dist/color-picker/root/color-picker-root.js +103 -10
- package/dist/combobox/root/combobox-root.d.ts +38 -3
- package/dist/combobox/root/combobox-root.js +64 -2
- package/dist/command/root/command-root.d.ts +30 -4
- package/dist/command/root/command-root.js +33 -3
- 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 +47 -1
- package/dist/copy-button/root/copy-button-root.js +44 -8
- package/dist/data-table/root/data-table-root.d.ts +150 -2
- package/dist/data-table/root/data-table-root.js +303 -29
- package/dist/data-table/tree.d.ts +40 -0
- package/dist/data-table/tree.js +55 -0
- package/dist/date-input/root/date-input-root.d.ts +73 -4
- package/dist/date-input/root/date-input-root.js +93 -43
- package/dist/date-picker/root/date-picker-root.d.ts +145 -1
- package/dist/date-picker/root/date-picker-root.js +239 -48
- package/dist/description-list/item/description-list-item.d.ts +17 -2
- package/dist/description-list/item/description-list-item.js +15 -2
- package/dist/description-list/root/description-list-root.d.ts +27 -1
- package/dist/description-list/root/description-list-root.js +26 -1
- package/dist/dialog/description.d.ts +9 -0
- package/dist/dialog/description.js +14 -0
- package/dist/dialog/root/dialog-root.d.ts +64 -1
- package/dist/dialog/root/dialog-root.js +49 -23
- package/dist/donut-chart/root/donut-chart-root.d.ts +25 -4
- package/dist/donut-chart/root/donut-chart-root.js +21 -6
- package/dist/drawer/root/drawer-root.d.ts +63 -2
- package/dist/drawer/root/drawer-root.js +95 -19
- 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 +11 -6
- package/dist/drilldown/item/drilldown-item.js +8 -5
- package/dist/drilldown/root/drilldown-root.d.ts +11 -0
- package/dist/drilldown/root/drilldown-root.js +8 -3
- package/dist/element-events.generated.js +61 -13
- package/dist/empty/root/empty-root.d.ts +1 -1
- package/dist/file-input/root/file-input-root.d.ts +47 -0
- package/dist/file-input/root/file-input-root.js +60 -22
- 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 +3 -0
- package/dist/filter-input/menu/filter-menu.js +8 -4
- package/dist/filter-input/root/filter-input-root.d.ts +38 -4
- package/dist/filter-input/root/filter-input-root.js +67 -3
- 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 +51 -0
- package/dist/format-date/root/format-date-root.js +58 -38
- package/dist/heatmap/root/heatmap-root.d.ts +23 -6
- package/dist/heatmap/root/heatmap-root.js +24 -13
- 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 +30 -4
- package/dist/icon/root/icon-root.js +41 -6
- 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/image/root/image-root.d.ts +14 -0
- package/dist/image/root/image-root.js +23 -2
- package/dist/input/root/input-root.d.ts +11 -0
- package/dist/input/root/input-root.js +16 -1
- package/dist/kbd/root/kbd-root.d.ts +20 -13
- package/dist/kbd/root/kbd-root.js +35 -37
- 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 +56 -0
- package/dist/legend/root/legend-root.js +54 -5
- package/dist/lightbox/item/lightbox-item.d.ts +15 -0
- package/dist/lightbox/item/lightbox-item.js +10 -1
- package/dist/lightbox/root/lightbox-root.d.ts +61 -1
- package/dist/lightbox/root/lightbox-root.js +94 -4
- package/dist/line-chart/root/line-chart-root.d.ts +11 -3
- package/dist/line-chart/root/line-chart-root.js +19 -5
- package/dist/list/item/list-item.d.ts +68 -1
- package/dist/list/item/list-item.js +66 -4
- package/dist/list/numbering.d.ts +14 -0
- package/dist/list/numbering.js +8 -0
- package/dist/list/root/list-root.d.ts +106 -9
- package/dist/list/root/list-root.js +189 -4
- package/dist/list/selection.d.ts +19 -0
- package/dist/list/selection.js +21 -0
- package/dist/listbox/root/listbox-root.d.ts +74 -3
- package/dist/listbox/root/listbox-root.js +86 -9
- 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 +6 -2
- package/dist/map/root/map-root.js +5 -2
- package/dist/megamenu/root/megamenu-root.d.ts +21 -0
- package/dist/megamenu/root/megamenu-root.js +16 -2
- package/dist/menu/index.d.ts +1 -0
- package/dist/menu/index.js +1 -0
- package/dist/menu/item/menu-item.d.ts +38 -11
- package/dist/menu/item/menu-item.js +33 -1
- package/dist/menu/root/menu-root.d.ts +25 -1
- package/dist/menu/root/menu-root.js +63 -6
- package/dist/menu/section/menu-section.d.ts +55 -0
- package/dist/menu/section/menu-section.js +60 -0
- package/dist/meter/root/meter-root.d.ts +7 -0
- package/dist/meter/root/meter-root.js +6 -3
- package/dist/navigation/root/navigation-root.d.ts +16 -1
- package/dist/navigation/root/navigation-root.js +27 -1
- package/dist/notifications/feed-keys.d.ts +10 -0
- package/dist/notifications/feed-keys.js +14 -0
- package/dist/notifications/notification/notification.d.ts +17 -0
- package/dist/notifications/notification/notification.js +21 -2
- package/dist/notifications/root/notifications-root.d.ts +60 -0
- package/dist/notifications/root/notifications-root.js +76 -1
- package/dist/number-input/root/number-input-root.d.ts +47 -0
- package/dist/number-input/root/number-input-root.js +58 -22
- package/dist/object-inspector/root/object-inspector-root.d.ts +98 -16
- package/dist/object-inspector/root/object-inspector-root.js +180 -80
- package/dist/object-inspector/rows.d.ts +57 -0
- package/dist/object-inspector/rows.js +86 -0
- package/dist/option/root/option-root.d.ts +54 -5
- package/dist/option/root/option-root.js +34 -5
- package/dist/outline/levels.d.ts +31 -0
- package/dist/outline/levels.js +23 -0
- package/dist/outline/root/outline-root.d.ts +68 -3
- package/dist/outline/root/outline-root.js +73 -8
- package/dist/pagination/size/pagination-size.d.ts +11 -2
- package/dist/pagination/size/pagination-size.js +19 -4
- 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 +21 -0
- package/dist/pin-input/root/pin-input-root.js +29 -2
- package/dist/popover/root/popover-root.d.ts +62 -4
- package/dist/popover/root/popover-root.js +53 -5
- package/dist/progress/root/progress-root.d.ts +7 -0
- package/dist/progress/root/progress-root.js +9 -3
- 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 +26 -0
- package/dist/qr-code/root/qr-code-root.js +49 -2
- package/dist/radio/group/radio-group.d.ts +17 -0
- package/dist/radio/group/radio-group.js +14 -1
- package/dist/rating/root/rating-root.d.ts +25 -0
- package/dist/rating/root/rating-root.js +46 -4
- package/dist/scatter-chart/root/scatter-chart-root.d.ts +17 -3
- package/dist/scatter-chart/root/scatter-chart-root.js +25 -7
- package/dist/scroll-area/root/scroll-area-root.d.ts +113 -0
- package/dist/scroll-area/root/scroll-area-root.js +218 -3
- package/dist/scroll-area/scrollbar.d.ts +65 -0
- package/dist/scroll-area/scrollbar.js +24 -0
- package/dist/select/root/select-root.d.ts +24 -0
- package/dist/select/root/select-root.js +21 -7
- package/dist/skeleton/root/skeleton-root.d.ts +25 -0
- package/dist/skeleton/root/skeleton-root.js +17 -2
- package/dist/slider/root/slider-root.d.ts +39 -0
- package/dist/slider/root/slider-root.js +45 -9
- package/dist/splitter/root/splitter-root.d.ts +13 -0
- package/dist/splitter/root/splitter-root.js +20 -2
- package/dist/splitter/snap.d.ts +9 -0
- package/dist/splitter/snap.js +12 -0
- package/dist/stat/root/stat-root.d.ts +2 -0
- package/dist/stat/root/stat-root.js +1 -1
- package/dist/steps/reach.d.ts +15 -0
- package/dist/steps/reach.js +12 -0
- package/dist/steps/root/steps-root.d.ts +30 -0
- package/dist/steps/root/steps-root.js +53 -0
- package/dist/steps/step/step.d.ts +39 -2
- package/dist/steps/step/step.js +29 -7
- package/dist/switch/root/switch-root.d.ts +12 -2
- package/dist/switch/root/switch-root.js +6 -1
- package/dist/table/column/table-column.d.ts +11 -0
- package/dist/table/column/table-column.js +6 -1
- package/dist/table/root/table-root.d.ts +101 -0
- package/dist/table/root/table-root.js +166 -5
- package/dist/table/row/table-row.d.ts +47 -1
- package/dist/table/row/table-row.js +39 -2
- package/dist/tabs/panel/tab-panel.d.ts +9 -5
- package/dist/tabs/panel/tab-panel.js +3 -4
- package/dist/tabs/root/tabs-root.d.ts +25 -1
- package/dist/tabs/root/tabs-root.js +21 -3
- package/dist/tabs/tab/tab.d.ts +36 -4
- package/dist/tabs/tab/tab.js +46 -3
- 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 +60 -0
- package/dist/tag/root/tag-root.js +74 -18
- 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 +9 -0
- package/dist/textarea/root/textarea-root.js +9 -1
- package/dist/time-input/root/time-input-root.d.ts +44 -5
- package/dist/time-input/root/time-input-root.js +69 -39
- package/dist/time-picker/root/time-picker-root.d.ts +54 -8
- package/dist/time-picker/root/time-picker-root.js +121 -91
- package/dist/timeline/group/timeline-group.d.ts +46 -0
- package/dist/timeline/group/timeline-group.js +37 -0
- package/dist/timeline/index.d.ts +1 -0
- package/dist/timeline/index.js +1 -0
- package/dist/timeline/root/timeline-root.d.ts +10 -3
- package/dist/toast/hotkey.d.ts +22 -0
- package/dist/toast/hotkey.js +23 -0
- package/dist/toast/item/toast-item.d.ts +26 -18
- package/dist/toast/item/toast-item.js +55 -48
- package/dist/toast/root/toast-root.d.ts +42 -8
- package/dist/toast/root/toast-root.js +64 -4
- package/dist/toggle/group/toggle-group.d.ts +57 -15
- package/dist/toggle/group/toggle-group.js +69 -9
- package/dist/toggle/root/toggle-root.d.ts +12 -1
- package/dist/toggle/root/toggle-root.js +11 -3
- package/dist/toolbar/root/toolbar-root.d.ts +13 -0
- package/dist/toolbar/root/toolbar-root.js +15 -5
- 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 +42 -17
- package/dist/tooltip/root/tooltip-root.js +50 -9
- package/dist/tour/naming.d.ts +30 -0
- package/dist/tour/naming.js +10 -0
- package/dist/tour/root/tour-root.d.ts +35 -0
- package/dist/tour/root/tour-root.js +56 -5
- package/dist/tour/stop/tour-stop.d.ts +53 -8
- package/dist/tour/stop/tour-stop.js +45 -15
- package/dist/tour/wait.d.ts +11 -0
- package/dist/tour/wait.js +19 -0
- package/dist/tree/item/tree-item.d.ts +54 -1
- package/dist/tree/item/tree-item.js +89 -20
- package/dist/tree/root/tree-root.d.ts +37 -0
- package/dist/tree/root/tree-root.js +51 -6
- package/dist/tree/selection.d.ts +24 -0
- package/dist/tree/selection.js +26 -0
- package/dist/trend/root/trend-root.d.ts +13 -0
- package/dist/trend/root/trend-root.js +14 -9
- package/dist/video/media-events.d.ts +49 -0
- package/dist/video/media-events.js +39 -0
- package/dist/video/root/video-root.d.ts +99 -13
- package/dist/video/root/video-root.js +84 -47
- package/dist/video-playlist/menu/video-playlist-menu.d.ts +3 -0
- package/dist/video-playlist/menu/video-playlist-menu.js +2 -1
- package/dist/video-playlist/order.d.ts +41 -0
- package/dist/video-playlist/order.js +34 -0
- package/dist/video-playlist/root/video-playlist-root.d.ts +70 -2
- package/dist/video-playlist/root/video-playlist-root.js +60 -16
- package/dist/virtual-list/controls.d.ts +4 -0
- package/dist/virtual-list/controls.js +30 -0
- package/dist/virtual-list/fill.d.ts +30 -0
- package/dist/virtual-list/fill.js +39 -0
- package/dist/virtual-list/keys.d.ts +15 -0
- package/dist/virtual-list/keys.js +24 -0
- package/dist/virtual-list/root/virtual-list-root.d.ts +155 -23
- package/dist/virtual-list/root/virtual-list-root.js +175 -34
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +8871 -1286
- package/types/svelte.d.ts +3 -0
- package/types/vue.d.ts +1918 -269
|
@@ -12,6 +12,16 @@ import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
|
12
12
|
* renders both `minute` and `month` as `m`, so a compact "3m" could mean three
|
|
13
13
|
* minutes or three months. `elapsedTime` in `helix/core` does the measurement.
|
|
14
14
|
*
|
|
15
|
+
* **`relative` shows the same reading in words**, such as "3 hours ago" at
|
|
16
|
+
* `long`, "3 hr. ago" at `short` and "3h ago" at `narrow`, the styles
|
|
17
|
+
* `sl-relative-time` offers. `numeric="always"` says "1 day ago" where the
|
|
18
|
+
* default says "yesterday".
|
|
19
|
+
*
|
|
20
|
+
* **`date-style` and `time-style` take each locale's own pattern**, such as
|
|
21
|
+
* "Tuesday, August 4, 2026" at `full`, and stand in for the separate fields,
|
|
22
|
+
* which `Intl` refuses beside them. `hour-cycle` sets a twelve or twenty-four
|
|
23
|
+
* hour clock either way.
|
|
24
|
+
*
|
|
15
25
|
* **The text refreshes on one timer shared by the page.** Each element
|
|
16
26
|
* schedules an update for when its current reading expires, and an element
|
|
17
27
|
* showing a date schedules none, so a long feed left open costs almost nothing.
|
|
@@ -53,6 +63,11 @@ export declare class HelixHeadlessFormatDate extends HelixElement {
|
|
|
53
63
|
* browser may use either.
|
|
54
64
|
*/
|
|
55
65
|
date: string;
|
|
66
|
+
/**
|
|
67
|
+
* The locale's own pattern for the date: `full`, `long`, `medium`, or
|
|
68
|
+
* `short`. Set, it stands in for `weekday`, `day`, `month`, `year` and `era`.
|
|
69
|
+
*/
|
|
70
|
+
dateStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
56
71
|
/**
|
|
57
72
|
* How the day of the month is written, where a date is shown.
|
|
58
73
|
*/
|
|
@@ -66,10 +81,22 @@ export declare class HelixHeadlessFormatDate extends HelixElement {
|
|
|
66
81
|
* few characters and a date is not.
|
|
67
82
|
*/
|
|
68
83
|
elapsed: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* How the era is written, such as AD, where a date is shown.
|
|
86
|
+
*/
|
|
87
|
+
era?: 'long' | 'narrow' | 'short';
|
|
69
88
|
/**
|
|
70
89
|
* How the hour is written, where a time of day is shown.
|
|
71
90
|
*/
|
|
72
91
|
hour?: 'numeric' | '2-digit';
|
|
92
|
+
/**
|
|
93
|
+
* The clock a time of day is written on: `h12` or `h11` for twelve hours,
|
|
94
|
+
* `h23` or `h24` for twenty-four.
|
|
95
|
+
*
|
|
96
|
+
* Absent is the locale's own, which is right unless your product shows every
|
|
97
|
+
* reader the same clock whatever their language.
|
|
98
|
+
*/
|
|
99
|
+
hourCycle?: 'h11' | 'h12' | 'h23' | 'h24';
|
|
73
100
|
/**
|
|
74
101
|
* The locale to format the timestamp in.
|
|
75
102
|
*
|
|
@@ -84,10 +111,30 @@ export declare class HelixHeadlessFormatDate extends HelixElement {
|
|
|
84
111
|
* How the month is written, where a date is shown.
|
|
85
112
|
*/
|
|
86
113
|
month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
|
|
114
|
+
/**
|
|
115
|
+
* Whether a `relative` reading may use a word for a number: `auto` says
|
|
116
|
+
* "yesterday" and "now", and `always` says "1 day ago" and "in 0 seconds".
|
|
117
|
+
*/
|
|
118
|
+
numeric?: 'always' | 'auto';
|
|
119
|
+
/**
|
|
120
|
+
* Shows how long ago the timestamp was, or how long until it, in words, in
|
|
121
|
+
* place of the date: `long` ("3 hours ago"), `short` ("3 hr. ago") or
|
|
122
|
+
* `narrow` ("3h ago").
|
|
123
|
+
*
|
|
124
|
+
* The reading refreshes as it goes stale, as `elapsed` does, and the whole
|
|
125
|
+
* date is its title. `elapsed` wins where both are set.
|
|
126
|
+
*/
|
|
127
|
+
relative?: 'long' | 'narrow' | 'short';
|
|
87
128
|
/**
|
|
88
129
|
* How the second is written, where a time of day is shown.
|
|
89
130
|
*/
|
|
90
131
|
second?: 'numeric' | '2-digit';
|
|
132
|
+
/**
|
|
133
|
+
* The locale's own pattern for the time of day: `full`, `long`, `medium`, or
|
|
134
|
+
* `short`. Set, it stands in for `hour`, `minute`, `second` and
|
|
135
|
+
* `time-zone-name`.
|
|
136
|
+
*/
|
|
137
|
+
timeStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
91
138
|
/**
|
|
92
139
|
* The time zone to read the timestamp in.
|
|
93
140
|
*
|
|
@@ -126,6 +173,10 @@ export declare class HelixHeadlessFormatDate extends HelixElement {
|
|
|
126
173
|
private get moment();
|
|
127
174
|
/** Every `Intl.DateTimeFormat` option a consumer set, and none they did not. */
|
|
128
175
|
private get options();
|
|
176
|
+
/** Whether the reading is how long ago rather than the date. */
|
|
177
|
+
private get reading();
|
|
178
|
+
/** What the reading says now, and when it stops being true. */
|
|
179
|
+
private readingAt;
|
|
129
180
|
connectedCallback(): void;
|
|
130
181
|
disconnectedCallback(): void;
|
|
131
182
|
protected firstUpdated(changed: PropertyValues): void;
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
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';
|
|
10
11
|
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
11
12
|
let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement {
|
|
12
13
|
constructor() {
|
|
@@ -31,38 +32,33 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
31
32
|
return Number.isNaN(parsed.getTime()) ? undefined : parsed;
|
|
32
33
|
}
|
|
33
34
|
get options() {
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
if (this.year) {
|
|
63
|
-
asked.year = this.year;
|
|
64
|
-
}
|
|
65
|
-
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);
|
|
66
62
|
}
|
|
67
63
|
connectedCallback() {
|
|
68
64
|
super.connectedCallback();
|
|
@@ -88,7 +84,11 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
88
84
|
if (this.childrenKnown) {
|
|
89
85
|
this.read();
|
|
90
86
|
}
|
|
91
|
-
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')) {
|
|
92
92
|
this.tick();
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -111,12 +111,12 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
111
111
|
this.stopTicking?.();
|
|
112
112
|
this.stopTicking = undefined;
|
|
113
113
|
const moment = this.moment;
|
|
114
|
-
if (!moment || !this.
|
|
114
|
+
if (!moment || !this.reading) {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
const now = new Date();
|
|
118
118
|
this.clock = now.getTime();
|
|
119
|
-
const { next } =
|
|
119
|
+
const { next } = this.readingAt(moment, now);
|
|
120
120
|
if (!Number.isFinite(next) || !this.isConnected) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
@@ -128,7 +128,7 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
128
128
|
return nothing;
|
|
129
129
|
}
|
|
130
130
|
const datetime = this.dateOnly ? (this.date || this.written).trim() : moment.toISOString();
|
|
131
|
-
if (!this.
|
|
131
|
+
if (!this.reading) {
|
|
132
132
|
const text = new Intl.DateTimeFormat(this.locale || undefined, this.options).format(moment);
|
|
133
133
|
return html `<time part="time" datetime=${datetime}>${text}</time>`;
|
|
134
134
|
}
|
|
@@ -137,28 +137,39 @@ let HelixHeadlessFormatDate = class HelixHeadlessFormatDate extends HelixElement
|
|
|
137
137
|
const whole = new Intl.DateTimeFormat(this.locale || undefined, {
|
|
138
138
|
dateStyle: 'long',
|
|
139
139
|
...(this.dateOnly ? {} : { timeStyle: 'short' }),
|
|
140
|
+
...(this.hourCycle ? { hourCycle: this.hourCycle } : {}),
|
|
140
141
|
...(zone ? { timeZone: zone } : {}),
|
|
141
142
|
}).format(moment);
|
|
143
|
+
const spoken = relativeTime(this.locale, { numeric: this.numeric ?? 'auto' })(moment, now).text;
|
|
142
144
|
return html `<time
|
|
143
145
|
part="time"
|
|
144
146
|
datetime=${datetime}
|
|
145
|
-
aria-label=${
|
|
147
|
+
aria-label=${spoken}
|
|
146
148
|
title=${whole}
|
|
147
|
-
>${
|
|
149
|
+
>${this.readingAt(moment, now).text}</time>`;
|
|
148
150
|
}
|
|
149
151
|
};
|
|
150
152
|
__decorate([
|
|
151
153
|
property()
|
|
152
154
|
], HelixHeadlessFormatDate.prototype, "date", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
property({ attribute: 'date-style' })
|
|
157
|
+
], HelixHeadlessFormatDate.prototype, "dateStyle", void 0);
|
|
153
158
|
__decorate([
|
|
154
159
|
property()
|
|
155
160
|
], HelixHeadlessFormatDate.prototype, "day", void 0);
|
|
156
161
|
__decorate([
|
|
157
162
|
property({ reflect: true, type: Boolean })
|
|
158
163
|
], HelixHeadlessFormatDate.prototype, "elapsed", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
property()
|
|
166
|
+
], HelixHeadlessFormatDate.prototype, "era", void 0);
|
|
159
167
|
__decorate([
|
|
160
168
|
property()
|
|
161
169
|
], HelixHeadlessFormatDate.prototype, "hour", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
property({ attribute: 'hour-cycle' })
|
|
172
|
+
], HelixHeadlessFormatDate.prototype, "hourCycle", void 0);
|
|
162
173
|
__decorate([
|
|
163
174
|
property()
|
|
164
175
|
], HelixHeadlessFormatDate.prototype, "locale", void 0);
|
|
@@ -168,9 +179,18 @@ __decorate([
|
|
|
168
179
|
__decorate([
|
|
169
180
|
property()
|
|
170
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);
|
|
171
188
|
__decorate([
|
|
172
189
|
property()
|
|
173
190
|
], HelixHeadlessFormatDate.prototype, "second", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
property({ attribute: 'time-style' })
|
|
193
|
+
], HelixHeadlessFormatDate.prototype, "timeStyle", void 0);
|
|
174
194
|
__decorate([
|
|
175
195
|
property({ attribute: 'time-zone' })
|
|
176
196
|
], HelixHeadlessFormatDate.prototype, "timeZone", void 0);
|
|
@@ -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. It is
|
|
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.
|
|
@@ -183,11 +192,6 @@ export declare class HelixHeadlessHeatmap extends HelixHeadlessHeatmap_base {
|
|
|
183
192
|
* this component writes out as custom properties, run backwards.
|
|
184
193
|
*/
|
|
185
194
|
private metrics;
|
|
186
|
-
/**
|
|
187
|
-
* Which drawn cell the pointer is on, as an index into `drawn`, or -1 for
|
|
188
|
-
* none.
|
|
189
|
-
*/
|
|
190
|
-
private hovered;
|
|
191
195
|
/**
|
|
192
196
|
* Carries a host `aria-labelledby` and `aria-describedby` to the strip, the
|
|
193
197
|
* image a reader lands on. The host is a generic around it.
|
|
@@ -283,6 +287,19 @@ export declare class HelixHeadlessHeatmap extends HelixHeadlessHeatmap_base {
|
|
|
283
287
|
* keep the oldest is answering a question nobody asked.
|
|
284
288
|
*/
|
|
285
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;
|
|
286
303
|
connectedCallback(): void;
|
|
287
304
|
disconnectedCallback(): void;
|
|
288
305
|
/**
|
|
@@ -20,7 +20,6 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
20
20
|
this.tones = '';
|
|
21
21
|
this.width = undefined;
|
|
22
22
|
this.metrics = undefined;
|
|
23
|
-
this.hovered = -1;
|
|
24
23
|
this.aria = new AriaForwardController(this, {
|
|
25
24
|
target: () => this.partNamed('strip'),
|
|
26
25
|
});
|
|
@@ -30,12 +29,14 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
30
29
|
if (!this.pointer.accepts(event)) {
|
|
31
30
|
return;
|
|
32
31
|
}
|
|
33
|
-
const cell = event.target?.closest?.('[part
|
|
32
|
+
const cell = event.target?.closest?.('[part~="cell"]');
|
|
34
33
|
const index = Number(cell?.getAttribute('data-index') ?? -1);
|
|
35
|
-
this.
|
|
34
|
+
this.pointer.set(Number.isInteger(index) ? index : -1);
|
|
36
35
|
};
|
|
37
36
|
this.onPointerLeave = () => {
|
|
38
|
-
this.
|
|
37
|
+
if (!this.pointer.keyed) {
|
|
38
|
+
this.pointer.set(-1);
|
|
39
|
+
}
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
get visible() {
|
|
@@ -98,6 +99,13 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
98
99
|
const all = this.points;
|
|
99
100
|
return all.slice(Math.max(0, all.length - this.room));
|
|
100
101
|
}
|
|
102
|
+
get readings() {
|
|
103
|
+
return this.drawn.length;
|
|
104
|
+
}
|
|
105
|
+
willUpdate(changed) {
|
|
106
|
+
super.willUpdate(changed);
|
|
107
|
+
this.pointer.grid = this.rowCount;
|
|
108
|
+
}
|
|
101
109
|
connectedCallback() {
|
|
102
110
|
super.connectedCallback();
|
|
103
111
|
if (typeof ResizeObserver !== 'undefined') {
|
|
@@ -141,12 +149,14 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
141
149
|
const bounds = writtenNumbers(this.thresholds);
|
|
142
150
|
const palette = writtenList(this.tones);
|
|
143
151
|
const cells = this.drawn;
|
|
152
|
+
const readable = cells.length > 0;
|
|
144
153
|
return html `<div
|
|
145
154
|
aria-label=${this.getAttribute?.('aria-label') || this.named || 'Heatmap'}
|
|
146
155
|
part="strip"
|
|
147
156
|
id=${CHART_PLOT}
|
|
148
|
-
role
|
|
157
|
+
role=${readable ? 'application' : 'img'}
|
|
149
158
|
style="--heatmap-rows: ${this.rowCount}"
|
|
159
|
+
tabindex=${readable ? '0' : nothing}
|
|
150
160
|
@pointerover=${this.onPointerOver}
|
|
151
161
|
@pointerleave=${this.onPointerLeave}
|
|
152
162
|
>
|
|
@@ -154,10 +164,14 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
154
164
|
? nothing
|
|
155
165
|
: cells.map((reading, index) => {
|
|
156
166
|
const tone = toneOf(reading, bounds, palette);
|
|
167
|
+
const active = this.pointer.at === index;
|
|
157
168
|
return tone === undefined
|
|
158
|
-
? html `<span
|
|
169
|
+
? html `<span
|
|
170
|
+
part="cell${active ? ' cell-active' : ''}"
|
|
171
|
+
data-index=${index}
|
|
172
|
+
></span>`
|
|
159
173
|
: html `<span
|
|
160
|
-
part="cell"
|
|
174
|
+
part="cell${active ? ' cell-active' : ''}"
|
|
161
175
|
data-index=${index}
|
|
162
176
|
data-tone=${tone}
|
|
163
177
|
style="--heatmap-tone: var(--heatmap-tone-${tone})"
|
|
@@ -173,9 +187,9 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
173
187
|
</div>`;
|
|
174
188
|
}
|
|
175
189
|
renderTooltip() {
|
|
176
|
-
const at = this.
|
|
190
|
+
const at = this.pointer.at;
|
|
177
191
|
if (at < 0) {
|
|
178
|
-
return
|
|
192
|
+
return drawTooltip(this.sourceRows, -1, this.tag('tooltip'), undefined, undefined, this.pointer);
|
|
179
193
|
}
|
|
180
194
|
const offset = this.points.length - this.drawn.length;
|
|
181
195
|
const cell = this.cellPx;
|
|
@@ -186,7 +200,7 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartSource(H
|
|
|
186
200
|
placement: 'top',
|
|
187
201
|
x: `${column * (cell + gap) + cell / 2}px`,
|
|
188
202
|
y: `${row * (cell + gap)}px`,
|
|
189
|
-
});
|
|
203
|
+
}, undefined, this.pointer);
|
|
190
204
|
}
|
|
191
205
|
};
|
|
192
206
|
__decorate([
|
|
@@ -213,9 +227,6 @@ __decorate([
|
|
|
213
227
|
__decorate([
|
|
214
228
|
state()
|
|
215
229
|
], HelixHeadlessHeatmap.prototype, "metrics", void 0);
|
|
216
|
-
__decorate([
|
|
217
|
-
state()
|
|
218
|
-
], HelixHeadlessHeatmap.prototype, "hovered", void 0);
|
|
219
230
|
HelixHeadlessHeatmap = __decorate([
|
|
220
231
|
customElement('helix-headless-heatmap')
|
|
221
232
|
], HelixHeadlessHeatmap);
|
package/dist/icon/index.d.ts
CHANGED
package/dist/icon/index.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { HelixIcon } from '@fusion.dev/helix-icons';
|
|
2
|
+
/** What a library gives for a name: a glyph, a glyph later, or nothing. */
|
|
3
|
+
export type IconResolver = (name: string) => HelixIcon | Promise<HelixIcon | undefined> | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Makes glyphs resolvable by name: a record of names to glyphs, such as the
|
|
6
|
+
* whole set, or a list of glyphs, each under its own `name`.
|
|
7
|
+
*
|
|
8
|
+
* A name registered again takes the newer glyph.
|
|
9
|
+
*/
|
|
10
|
+
export declare const registerIcons: (glyphs: Record<string, HelixIcon> | readonly HelixIcon[]) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves names written `prefix:name` through a library of your own, such as
|
|
13
|
+
* another icon set or glyphs fetched from a server.
|
|
14
|
+
*
|
|
15
|
+
* The resolver may answer at once or with a promise; an element waiting on a
|
|
16
|
+
* promise draws the glyph when it arrives and fires `load`. Each written name
|
|
17
|
+
* is asked once, and a prefix registered again is asked afresh.
|
|
18
|
+
*/
|
|
19
|
+
export declare const registerIconLibrary: (prefix: string, resolve: IconResolver) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Calls `watcher` whenever a glyph or a library is registered, so an element
|
|
22
|
+
* drawn before its glyph was registered can look again. Returns the function
|
|
23
|
+
* that stops it.
|
|
24
|
+
*/
|
|
25
|
+
export declare const watchIcons: (watcher: () => void) => (() => void);
|
|
26
|
+
/** The registered glyph of this name, or `undefined`. */
|
|
27
|
+
export declare const registeredIcon: (name: string) => HelixIcon | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The glyph for a name: a registered one at once, or what the library its
|
|
30
|
+
* prefix names gives, which may be a promise. `undefined` where nothing
|
|
31
|
+
* answers.
|
|
32
|
+
*
|
|
33
|
+
* A registered name wins over a library, so a page can override one glyph of
|
|
34
|
+
* a library by registering it under the same written name. A library that
|
|
35
|
+
* fails answers nothing.
|
|
36
|
+
*/
|
|
37
|
+
export declare const resolveIcon: (name: string) => HelixIcon | Promise<HelixIcon | undefined> | undefined;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const KEY = Symbol.for('helix.icon-registry');
|
|
2
|
+
const changed = (held) => {
|
|
3
|
+
for (const watcher of held.watchers) {
|
|
4
|
+
watcher();
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
const registry = () => {
|
|
8
|
+
const held = globalThis;
|
|
9
|
+
let found = held[KEY];
|
|
10
|
+
if (!found) {
|
|
11
|
+
found = { answers: new Map(), glyphs: new Map(), libraries: new Map(), watchers: new Set() };
|
|
12
|
+
held[KEY] = found;
|
|
13
|
+
}
|
|
14
|
+
return found;
|
|
15
|
+
};
|
|
16
|
+
export const registerIcons = (glyphs) => {
|
|
17
|
+
const held = registry();
|
|
18
|
+
const into = held.glyphs;
|
|
19
|
+
const entries = Array.isArray(glyphs)
|
|
20
|
+
? glyphs.map((glyph) => [glyph.name, glyph])
|
|
21
|
+
: Object.entries(glyphs);
|
|
22
|
+
for (const [name, glyph] of entries) {
|
|
23
|
+
into.set(name, glyph);
|
|
24
|
+
}
|
|
25
|
+
changed(held);
|
|
26
|
+
};
|
|
27
|
+
export const registerIconLibrary = (prefix, resolve) => {
|
|
28
|
+
const held = registry();
|
|
29
|
+
held.libraries.set(prefix, resolve);
|
|
30
|
+
for (const name of held.answers.keys()) {
|
|
31
|
+
if (name.startsWith(`${prefix}:`)) {
|
|
32
|
+
held.answers.delete(name);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
changed(held);
|
|
36
|
+
};
|
|
37
|
+
export const watchIcons = (watcher) => {
|
|
38
|
+
const held = registry();
|
|
39
|
+
held.watchers.add(watcher);
|
|
40
|
+
return () => {
|
|
41
|
+
held.watchers.delete(watcher);
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export const registeredIcon = (name) => registry().glyphs.get(name);
|
|
45
|
+
export const resolveIcon = (name) => {
|
|
46
|
+
const registered = registeredIcon(name);
|
|
47
|
+
if (registered || name === '') {
|
|
48
|
+
return registered;
|
|
49
|
+
}
|
|
50
|
+
const split = name.indexOf(':');
|
|
51
|
+
if (split <= 0) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const held = registry();
|
|
55
|
+
if (held.answers.has(name)) {
|
|
56
|
+
return held.answers.get(name);
|
|
57
|
+
}
|
|
58
|
+
const library = held.libraries.get(name.slice(0, split));
|
|
59
|
+
if (!library) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const answer = asked(library, name.slice(split + 1));
|
|
63
|
+
if (answer instanceof Promise) {
|
|
64
|
+
const settled = answer.then((glyph) => glyph, () => undefined);
|
|
65
|
+
held.answers.set(name, settled);
|
|
66
|
+
void settled.then((glyph) => {
|
|
67
|
+
if (held.answers.get(name) === settled) {
|
|
68
|
+
held.answers.set(name, glyph);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return settled;
|
|
72
|
+
}
|
|
73
|
+
held.answers.set(name, answer);
|
|
74
|
+
return answer;
|
|
75
|
+
};
|
|
76
|
+
const asked = (library, name) => {
|
|
77
|
+
try {
|
|
78
|
+
return library(name);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HelixElement } from '@fusion.dev/helix-core';
|
|
2
|
-
import {
|
|
2
|
+
import type { HelixIcon } from '@fusion.dev/helix-icons';
|
|
3
3
|
import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
4
4
|
/**
|
|
5
5
|
* @summary A named icon from the Helix set.
|
|
@@ -18,6 +18,15 @@ import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
|
18
18
|
* a dark background. Shapes that set their own `fill` or `stroke` are
|
|
19
19
|
* unaffected.
|
|
20
20
|
*
|
|
21
|
+
* **A name is looked up in a registry.** The family's entry registers the
|
|
22
|
+
* whole set, so any name in it draws. The element's own entry,
|
|
23
|
+
* `@fusion.dev/helix-headless/icon/root`, registers none: a page that imports
|
|
24
|
+
* it and calls `registerIcons` with the glyphs it names ships those and no
|
|
25
|
+
* others. `registerIconLibrary` resolves names under a prefix of your own,
|
|
26
|
+
* such as `lucide:camera`, at once or later, and the element fires `load` when
|
|
27
|
+
* a glyph that came later is drawn. A glyph registered after the element
|
|
28
|
+
* rendered is drawn then.
|
|
29
|
+
*
|
|
21
30
|
* A name with no match renders nothing, and the element fires `error`, so a
|
|
22
31
|
* typo in a name can be heard.
|
|
23
32
|
*
|
|
@@ -32,7 +41,8 @@ import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
|
32
41
|
* @aliases Glyph, Symbol
|
|
33
42
|
* @documentation https://fusion.dev/helix/components/icon
|
|
34
43
|
*
|
|
35
|
-
* @event {Event} error - `name` matches no icon
|
|
44
|
+
* @event {Event} error - `name` matches no registered icon and no library answers it, so nothing is drawn.
|
|
45
|
+
* @event {Event} load - A glyph a library gave later for `name` is drawn.
|
|
36
46
|
*
|
|
37
47
|
* @csspart svg - The rendered SVG.
|
|
38
48
|
*/
|
|
@@ -73,8 +83,12 @@ export declare class HelixHeadlessIcon extends HelixElement {
|
|
|
73
83
|
* so it is what markup can carry, and resolving one means an index of the
|
|
74
84
|
* whole set that no bundler can shake: 15 kB for a consumer who renders one
|
|
75
85
|
* mark. An attribute is the only thing an HTML author can write, and that is
|
|
76
|
-
* worth the index; a consumer who would rather not pay it
|
|
77
|
-
*
|
|
86
|
+
* worth the index; a consumer who would rather not pay it imports the
|
|
87
|
+
* element from `icon/root` and registers the glyphs it names, or hands over
|
|
88
|
+
* the value instead.
|
|
89
|
+
*
|
|
90
|
+
* A name written `prefix:name` asks the library registered under that
|
|
91
|
+
* prefix.
|
|
78
92
|
*/
|
|
79
93
|
name: string;
|
|
80
94
|
/**
|
|
@@ -92,6 +106,18 @@ export declare class HelixHeadlessIcon extends HelixElement {
|
|
|
92
106
|
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
93
107
|
/** The name the last `error` was fired for, so it fires once per name. */
|
|
94
108
|
private missed;
|
|
109
|
+
/** The glyph this render draws, from `icon` or the registry. */
|
|
110
|
+
private drawn;
|
|
111
|
+
/** A library is still answering for `name`, so it is not missing yet. */
|
|
112
|
+
private waiting;
|
|
113
|
+
/** The name whose late glyph arrived and has not been announced with `load`. */
|
|
114
|
+
private arrived;
|
|
115
|
+
/** Stops listening to the registry. */
|
|
116
|
+
private unwatch;
|
|
117
|
+
connectedCallback(): void;
|
|
118
|
+
disconnectedCallback(): void;
|
|
119
|
+
/** What the registry gives for `name` now, starting the wait for a late glyph. */
|
|
120
|
+
private lookup;
|
|
95
121
|
protected willUpdate(changed: PropertyValues): void;
|
|
96
122
|
protected updated(changed: PropertyValues): void;
|
|
97
123
|
protected render(): TemplateResult | typeof nothing;
|