@fusion.dev/helix-headless 0.144.0 → 0.146.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 +15195 -4240
- package/dist/accordion/item/accordion-item.d.ts +62 -12
- package/dist/accordion/item/accordion-item.js +41 -10
- package/dist/accordion/root/accordion-root.d.ts +14 -5
- package/dist/accordion/root/accordion-root.js +7 -1
- package/dist/announcement/root/announcement-root.d.ts +24 -3
- package/dist/announcement/root/announcement-root.js +39 -2
- package/dist/app-header/root/app-header-root.d.ts +12 -0
- package/dist/app-header/root/app-header-root.js +13 -1
- package/dist/app-header/sectioning.d.ts +9 -0
- package/dist/app-header/sectioning.js +27 -0
- package/dist/avatar/group/avatar-group.d.ts +20 -14
- package/dist/avatar/group/avatar-group.js +17 -19
- package/dist/badge/root/badge-root.d.ts +3 -1
- package/dist/badge/root/badge-root.js +2 -2
- package/dist/bar-chart/root/bar-chart-root.d.ts +18 -1
- package/dist/bar-chart/root/bar-chart-root.js +52 -15
- package/dist/bar-chart/stack.d.ts +15 -0
- package/dist/bar-chart/stack.js +19 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.d.ts +57 -1
- package/dist/breadcrumbs/root/breadcrumbs-root.js +73 -3
- package/dist/button/root/button-root.d.ts +26 -0
- package/dist/button/root/button-root.js +38 -18
- package/dist/button-group/root/button-group-root.d.ts +2 -1
- package/dist/button-group/root/button-group-root.js +5 -1
- package/dist/canvas/node/canvas-node.d.ts +4 -3
- package/dist/canvas/node/canvas-node.js +3 -2
- package/dist/canvas/root/canvas-root.d.ts +38 -3
- package/dist/canvas/root/canvas-root.js +123 -42
- package/dist/card/root/card-root.d.ts +24 -3
- package/dist/card/root/card-root.js +20 -8
- package/dist/carousel/root/carousel-root.d.ts +133 -4
- package/dist/carousel/root/carousel-root.js +174 -24
- package/dist/carousel/stops.d.ts +20 -0
- package/dist/carousel/stops.js +30 -0
- 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 +27 -10
- package/dist/chat/naming.d.ts +26 -0
- package/dist/chat/naming.js +14 -0
- package/dist/chat/root/chat-root.d.ts +58 -0
- package/dist/chat/root/chat-root.js +43 -3
- package/dist/checkbox/root/checkbox-root.d.ts +20 -0
- package/dist/checkbox/root/checkbox-root.js +14 -1
- package/dist/checkbox-group/root/checkbox-group-root.d.ts +8 -2
- package/dist/checkbox-group/root/checkbox-group-root.js +12 -10
- package/dist/checkbox-group/select-all.d.ts +27 -0
- package/dist/checkbox-group/select-all.js +12 -0
- package/dist/code-block/highlight.d.ts +15 -0
- package/dist/code-block/highlight.js +4 -0
- package/dist/code-block/root/code-block-root.d.ts +57 -2
- package/dist/code-block/root/code-block-root.js +63 -8
- package/dist/color-input/root/color-input-root.d.ts +3 -0
- package/dist/color-input/root/color-input-root.js +6 -3
- package/dist/color-picker/root/color-picker-root.d.ts +33 -4
- package/dist/color-picker/root/color-picker-root.js +80 -21
- package/dist/color-picker/swatches.d.ts +12 -0
- package/dist/color-picker/swatches.js +26 -0
- package/dist/combobox/root/combobox-root.d.ts +43 -0
- package/dist/combobox/root/combobox-root.js +79 -15
- package/dist/command/root/command-root.d.ts +16 -1
- package/dist/command/root/command-root.js +22 -4
- package/dist/copy-button/root/copy-button-root.d.ts +26 -1
- package/dist/copy-button/root/copy-button-root.js +12 -5
- package/dist/data-table/index.d.ts +1 -1
- package/dist/data-table/index.js +1 -1
- package/dist/data-table/keys.d.ts +24 -0
- package/dist/data-table/keys.js +24 -0
- package/dist/data-table/root/data-table-root.d.ts +170 -13
- package/dist/data-table/root/data-table-root.js +294 -52
- package/dist/data-table/tree.d.ts +55 -0
- package/dist/data-table/tree.js +54 -0
- package/dist/date-input/root/date-input-root.d.ts +3 -1
- package/dist/date-input/root/date-input-root.js +18 -7
- package/dist/date-picker/root/date-picker-root.js +12 -6
- 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.js +15 -1
- package/dist/dialog/root/dialog-root.d.ts +8 -2
- package/dist/dialog/root/dialog-root.js +16 -1
- package/dist/divider/root/divider-root.d.ts +3 -0
- package/dist/divider/root/divider-root.js +2 -1
- package/dist/donut-chart/root/donut-chart-root.d.ts +31 -0
- package/dist/donut-chart/root/donut-chart-root.js +48 -1
- package/dist/drawer/reveal.d.ts +8 -0
- package/dist/drawer/reveal.js +1 -0
- package/dist/drawer/root/drawer-root.d.ts +59 -0
- package/dist/drawer/root/drawer-root.js +63 -4
- 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 +29 -0
- package/dist/drilldown/root/drilldown-root.js +28 -5
- package/dist/element-events.generated.js +83 -12
- package/dist/empty/root/empty-root.d.ts +3 -1
- package/dist/empty/root/empty-root.js +3 -2
- package/dist/file-input/root/file-input-root.d.ts +69 -6
- package/dist/file-input/root/file-input-root.js +82 -19
- package/dist/file-input/screen.d.ts +2 -1
- package/dist/filter-input/menu/filter-menu.d.ts +5 -0
- package/dist/filter-input/menu/filter-menu.js +16 -4
- package/dist/filter-input/root/filter-input-root.d.ts +30 -6
- package/dist/filter-input/root/filter-input-root.js +1 -1
- package/dist/filter-input/suggest.d.ts +28 -3
- package/dist/filter-input/suggest.js +18 -8
- package/dist/format-date/root/format-date-root.d.ts +9 -16
- package/dist/format-date/root/format-date-root.js +10 -27
- package/dist/heatmap/root/heatmap-root.d.ts +24 -13
- package/dist/heatmap/root/heatmap-root.js +34 -12
- package/dist/icon/root/icon-root.d.ts +12 -1
- package/dist/icon/root/icon-root.js +21 -10
- package/dist/icon/settle.d.ts +7 -0
- package/dist/icon/settle.js +10 -0
- package/dist/icon-button/root/icon-button-root.d.ts +2 -0
- package/dist/image/root/image-root.d.ts +5 -1
- package/dist/image/root/image-root.js +10 -2
- package/dist/input/root/input-root.d.ts +13 -3
- package/dist/input/root/input-root.js +12 -3
- package/dist/kbd/root/kbd-root.d.ts +35 -1
- package/dist/kbd/root/kbd-root.js +23 -4
- package/dist/legend/root/legend-root.d.ts +55 -8
- package/dist/legend/root/legend-root.js +55 -13
- package/dist/lightbox/root/lightbox-root.d.ts +49 -6
- package/dist/lightbox/root/lightbox-root.js +86 -19
- package/dist/lightbox/zoom-controller.d.ts +59 -0
- package/dist/lightbox/zoom-controller.js +128 -0
- package/dist/lightbox/zoom.d.ts +22 -0
- package/dist/lightbox/zoom.js +16 -0
- package/dist/line-chart/root/line-chart-root.d.ts +22 -1
- package/dist/line-chart/root/line-chart-root.js +21 -1
- package/dist/list/item/list-item.d.ts +70 -1
- package/dist/list/item/list-item.js +77 -6
- package/dist/list/numbering.d.ts +14 -0
- package/dist/list/numbering.js +8 -0
- package/dist/list/root/list-root.d.ts +155 -9
- package/dist/list/root/list-root.js +246 -4
- package/dist/list/selection.d.ts +49 -0
- package/dist/list/selection.js +30 -0
- package/dist/listbox/root/listbox-root.d.ts +37 -1
- package/dist/listbox/root/listbox-root.js +49 -4
- package/dist/loader/busy.d.ts +10 -0
- package/dist/loader/busy.js +11 -0
- package/dist/loader/root/loader-root.d.ts +9 -2
- package/dist/loader/root/loader-root.js +23 -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 +62 -0
- package/dist/megamenu/root/megamenu-root.js +90 -5
- package/dist/menu/index.d.ts +1 -0
- package/dist/menu/index.js +1 -0
- package/dist/menu/item/menu-item.d.ts +87 -11
- package/dist/menu/item/menu-item.js +78 -22
- package/dist/menu/root/menu-root.d.ts +39 -1
- package/dist/menu/root/menu-root.js +65 -8
- 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 +20 -1
- package/dist/meter/root/meter-root.js +11 -15
- package/dist/navigation/root/navigation-root.d.ts +18 -2
- package/dist/navigation/root/navigation-root.js +29 -3
- package/dist/notifications/root/notifications-root.d.ts +25 -0
- package/dist/notifications/root/notifications-root.js +33 -5
- package/dist/number-input/root/number-input-root.d.ts +17 -8
- package/dist/number-input/root/number-input-root.js +2 -7
- package/dist/object-inspector/root/object-inspector-root.d.ts +161 -32
- package/dist/object-inspector/root/object-inspector-root.js +264 -123
- package/dist/object-inspector/rows.d.ts +75 -0
- package/dist/object-inspector/rows.js +119 -0
- package/dist/option/root/option-root.d.ts +5 -3
- package/dist/outline/levels.d.ts +31 -0
- package/dist/outline/levels.js +23 -0
- package/dist/outline/root/outline-root.d.ts +86 -3
- package/dist/outline/root/outline-root.js +95 -12
- package/dist/pagination/size/pagination-size.d.ts +12 -2
- package/dist/pagination/size/pagination-size.js +20 -5
- package/dist/pin-input/code.d.ts +10 -0
- package/dist/pin-input/code.js +13 -0
- package/dist/pin-input/root/pin-input-root.d.ts +25 -1
- package/dist/pin-input/root/pin-input-root.js +10 -11
- package/dist/popover/hide-outside.d.ts +14 -0
- package/dist/popover/hide-outside.js +41 -0
- package/dist/popover/root/popover-root.d.ts +57 -7
- package/dist/popover/root/popover-root.js +58 -3
- package/dist/progress/root/progress-root.d.ts +20 -0
- package/dist/progress/root/progress-root.js +15 -15
- package/dist/qr-code/export.d.ts +26 -1
- package/dist/qr-code/export.js +14 -0
- package/dist/qr-code/root/qr-code-root.d.ts +19 -5
- package/dist/qr-code/root/qr-code-root.js +58 -9
- package/dist/quote/marks.d.ts +8 -0
- package/dist/quote/marks.js +5 -0
- package/dist/quote/root/quote-root.d.ts +14 -2
- package/dist/quote/root/quote-root.js +23 -1
- package/dist/radio/group/radio-group.d.ts +4 -10
- package/dist/radio/group/radio-group.js +5 -10
- package/dist/radio/root/radio-root.d.ts +6 -2
- package/dist/radio/root/radio-root.js +6 -1
- package/dist/rating/root/rating-root.d.ts +10 -5
- package/dist/rating/root/rating-root.js +32 -8
- package/dist/rating/steps.d.ts +7 -0
- package/dist/rating/steps.js +9 -0
- package/dist/scatter-chart/fit.d.ts +15 -0
- package/dist/scatter-chart/fit.js +35 -0
- package/dist/scatter-chart/root/scatter-chart-root.d.ts +21 -1
- package/dist/scatter-chart/root/scatter-chart-root.js +30 -17
- package/dist/scroll-area/root/scroll-area-root.d.ts +84 -0
- package/dist/scroll-area/root/scroll-area-root.js +106 -7
- package/dist/scroll-area/scrollbar-controller.d.ts +111 -0
- package/dist/scroll-area/scrollbar-controller.js +172 -0
- package/dist/scroll-area/scrollbar.d.ts +92 -0
- package/dist/scroll-area/scrollbar.js +33 -0
- package/dist/select/root/select-root.d.ts +15 -0
- package/dist/select/root/select-root.js +18 -6
- package/dist/skeleton/root/skeleton-root.d.ts +3 -0
- package/dist/skeleton/root/skeleton-root.js +4 -2
- package/dist/skip-link/root/skip-link-root.js +2 -2
- package/dist/slider/root/slider-root.d.ts +41 -4
- package/dist/slider/root/slider-root.js +23 -3
- package/dist/sparkline/readings.d.ts +18 -0
- package/dist/sparkline/readings.js +19 -0
- package/dist/sparkline/root/sparkline-root.d.ts +78 -7
- package/dist/sparkline/root/sparkline-root.js +118 -23
- package/dist/speed-dial/root/speed-dial-root.js +2 -2
- package/dist/splitter/root/splitter-root.d.ts +20 -12
- package/dist/splitter/root/splitter-root.js +226 -203
- package/dist/splitter/snap.d.ts +9 -0
- package/dist/splitter/snap.js +12 -0
- package/dist/stat/root/stat-root.d.ts +14 -5
- package/dist/stat/root/stat-root.js +21 -5
- package/dist/steps/reach.d.ts +20 -0
- package/dist/steps/reach.js +15 -0
- package/dist/steps/root/steps-root.d.ts +76 -0
- package/dist/steps/root/steps-root.js +93 -1
- package/dist/steps/step/step.d.ts +45 -2
- package/dist/steps/step/step.js +33 -6
- package/dist/switch/root/switch-root.d.ts +10 -0
- package/dist/table/column/table-column.d.ts +11 -10
- package/dist/table/column/table-column.js +8 -19
- package/dist/table/root/table-root.d.ts +126 -4
- package/dist/table/root/table-root.js +156 -6
- 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 +22 -5
- package/dist/tabs/panel/tab-panel.js +34 -6
- package/dist/tabs/root/tabs-root.d.ts +37 -1
- package/dist/tabs/root/tabs-root.js +22 -4
- package/dist/tabs/tab/tab.d.ts +41 -4
- package/dist/tabs/tab/tab.js +49 -3
- package/dist/tag/group/tag-group.d.ts +31 -4
- package/dist/tag/group/tag-group.js +46 -7
- package/dist/tag/root/tag-root.js +9 -2
- package/dist/textarea/root/textarea-root.d.ts +28 -1
- package/dist/textarea/root/textarea-root.js +40 -1
- package/dist/time-input/root/time-input-root.d.ts +5 -1
- package/dist/time-input/root/time-input-root.js +16 -8
- package/dist/time-picker/root/time-picker-root.d.ts +18 -4
- package/dist/time-picker/root/time-picker-root.js +7 -10
- package/dist/time-picker/wheel-name.d.ts +9 -0
- package/dist/time-picker/wheel-name.js +15 -0
- 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/item/toast-item.d.ts +24 -18
- package/dist/toast/item/toast-item.js +36 -40
- package/dist/toast/root/toast-root.d.ts +6 -0
- package/dist/toast/root/toast-root.js +16 -1
- package/dist/toggle/group/toggle-group.d.ts +24 -3
- package/dist/toggle/group/toggle-group.js +34 -5
- package/dist/toolbar/root/toolbar-root.d.ts +13 -0
- package/dist/toolbar/root/toolbar-root.js +15 -5
- package/dist/tooltip/root/tooltip-root.d.ts +13 -2
- package/dist/tooltip/root/tooltip-root.js +9 -1
- package/dist/tour/back.d.ts +10 -0
- package/dist/tour/back.js +8 -0
- package/dist/tour/root/tour-root.d.ts +30 -2
- package/dist/tour/root/tour-root.js +34 -8
- package/dist/tree/item/tree-item.d.ts +61 -4
- package/dist/tree/item/tree-item.js +92 -20
- package/dist/tree/root/tree-root.d.ts +58 -0
- package/dist/tree/root/tree-root.js +80 -16
- package/dist/tree/selection.d.ts +24 -0
- package/dist/tree/selection.js +13 -0
- package/dist/trend/root/trend-root.d.ts +43 -18
- package/dist/trend/root/trend-root.js +31 -6
- package/dist/video/media-events.d.ts +44 -0
- package/dist/video/media-events.js +35 -0
- package/dist/video/root/video-root.d.ts +117 -18
- package/dist/video/root/video-root.js +93 -47
- package/dist/video-playlist/menu/video-playlist-menu.d.ts +5 -0
- package/dist/video-playlist/menu/video-playlist-menu.js +3 -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 +77 -3
- 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 +22 -0
- package/dist/virtual-list/fill.js +23 -0
- package/dist/virtual-list/keys.d.ts +15 -0
- package/dist/virtual-list/keys.js +24 -0
- package/dist/virtual-list/plan.d.ts +49 -0
- package/dist/virtual-list/plan.js +16 -0
- package/dist/virtual-list/root/virtual-list-root.d.ts +259 -26
- package/dist/virtual-list/root/virtual-list-root.js +333 -49
- package/lint.json +1 -1
- package/package.json +8 -8
- package/types/jsx.d.ts +8113 -1394
- package/types/svelte.d.ts +2 -0
- package/types/vue.d.ts +1678 -353
- package/dist/data-table/root/order.d.ts +0 -141
- package/dist/data-table/root/order.js +0 -76
- package/dist/listbox/range.d.ts +0 -17
- package/dist/listbox/range.js +0 -5
- package/dist/tag/selection.d.ts +0 -10
- package/dist/tag/selection.js +0 -12
|
@@ -5,192 +5,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
var HelixHeadlessSplitter_1;
|
|
8
|
-
import { AriaForwardController, capturePointer, closestInstance, customElement, HelixBeforeCollapseEvent, HelixBeforeResizeEvent, HelixCollapseEvent, HelixElement, HelixResizedEvent, inlineStep, isRtl, requestChange, } from '@fusion.dev/helix-core';
|
|
8
|
+
import { AriaForwardController, capturePointer, closestInstance, commaList, customElement, HelixBeforeCollapseEvent, HelixBeforeResizeEvent, HelixCollapseEvent, HelixElement, HelixResizedEvent, inlineStep, isRtl, requestChange, } from '@fusion.dev/helix-core';
|
|
9
9
|
import { html, nothing } from 'lit';
|
|
10
10
|
import { property, state } from 'lit/decorators.js';
|
|
11
|
+
import { snapTo } from '../snap.js';
|
|
11
12
|
const STACK_BELOW = 512;
|
|
13
|
+
const channel = new WeakMap();
|
|
12
14
|
let HelixHeadlessSplitter = HelixHeadlessSplitter_1 = class HelixHeadlessSplitter extends HelixElement {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
this.collapsedLabel = 'Collapsed';
|
|
16
|
-
this.collapsedSize = 0;
|
|
17
|
-
this.cornerLabel = 'Resize both';
|
|
18
|
-
this.defaultPosition = 50;
|
|
19
|
-
this.label = 'Resize panes';
|
|
20
|
-
this.aria = new AriaForwardController(this, {
|
|
21
|
-
label: true,
|
|
22
|
-
target: () => this.partNamed('separator'),
|
|
23
|
-
});
|
|
24
|
-
this.max = 100;
|
|
25
|
-
this.min = 0;
|
|
26
|
-
this.step = 2;
|
|
27
|
-
this.positionState = undefined;
|
|
28
|
-
this.collapsedState = undefined;
|
|
29
|
-
this.opened = undefined;
|
|
30
|
-
this.began = undefined;
|
|
31
|
-
this.reached = undefined;
|
|
32
|
-
this.dragging = false;
|
|
33
|
-
this.crossings = [];
|
|
34
|
-
this.outer = null;
|
|
35
|
-
this.crossedAt = undefined;
|
|
36
|
-
this.cornerOrigin = null;
|
|
37
|
-
this.origin = null;
|
|
38
|
-
this.stacked = false;
|
|
39
|
-
this.handlePointerDown = (event) => {
|
|
40
|
-
const separator = event.currentTarget;
|
|
41
|
-
const box = this.getBoundingClientRect();
|
|
42
|
-
this.origin = this.vertical
|
|
43
|
-
? { length: box.height, start: box.top }
|
|
44
|
-
: { length: box.width, start: box.left };
|
|
45
|
-
capturePointer(separator, event.pointerId);
|
|
46
|
-
this.opened = this.collapsed ? undefined : this.position;
|
|
47
|
-
this.began = this.position;
|
|
48
|
-
this.reached = undefined;
|
|
49
|
-
this.dragging = true;
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
};
|
|
52
|
-
this.handlePointerMove = (event) => {
|
|
53
|
-
const origin = this.origin;
|
|
54
|
-
if (!origin || origin.length === 0) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const along = this.vertical ? event.clientY : event.clientX;
|
|
58
|
-
const raw = ((along - origin.start) / origin.length) * 100;
|
|
59
|
-
const rtl = !this.vertical && isRtl(this);
|
|
60
|
-
this.move(rtl ? 100 - raw : raw);
|
|
61
|
-
};
|
|
62
|
-
this.handlePointerUp = (event) => {
|
|
63
|
-
if (!this.origin) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const separator = event.currentTarget;
|
|
67
|
-
if (separator.hasPointerCapture(event.pointerId)) {
|
|
68
|
-
separator.releasePointerCapture(event.pointerId);
|
|
69
|
-
}
|
|
70
|
-
this.origin = null;
|
|
71
|
-
this.dragging = false;
|
|
72
|
-
this.settle(this.reached ?? this.position);
|
|
73
|
-
};
|
|
74
|
-
this.handleKeydown = (event) => {
|
|
75
|
-
if (event.key === 'Enter') {
|
|
76
|
-
this.toggleCollapse();
|
|
77
|
-
event.preventDefault();
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const toward = this.travel(event.key);
|
|
81
|
-
let next;
|
|
82
|
-
if (toward !== 0) {
|
|
83
|
-
next = this.position + toward * this.step;
|
|
84
|
-
}
|
|
85
|
-
else if (event.key === 'Home') {
|
|
86
|
-
next = this.minPercent;
|
|
87
|
-
}
|
|
88
|
-
else if (event.key === 'End') {
|
|
89
|
-
next = this.maxPercent;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
this.settle(next);
|
|
95
|
-
event.preventDefault();
|
|
96
|
-
};
|
|
97
|
-
this.handleDoubleClick = () => {
|
|
98
|
-
this.reset();
|
|
99
|
-
};
|
|
100
|
-
this.handleCornerDoubleClick = (event) => {
|
|
101
|
-
const crossing = this.crossings[Number(event.currentTarget.dataset.cross)];
|
|
102
|
-
if (!crossing) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
this.reset();
|
|
106
|
-
crossing.by.reset();
|
|
107
|
-
this.leaveSeparator(event);
|
|
108
|
-
};
|
|
109
|
-
this.handleCornerDown = (event) => {
|
|
110
|
-
const handle = event.currentTarget;
|
|
111
|
-
const crossing = this.crossings[Number(handle.dataset.cross)];
|
|
112
|
-
if (!crossing) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const mine = this.getBoundingClientRect();
|
|
116
|
-
const theirs = crossing.by.getBoundingClientRect();
|
|
117
|
-
this.cornerOrigin = {
|
|
118
|
-
by: crossing.by,
|
|
119
|
-
inner: crossing.by.vertical
|
|
120
|
-
? { length: theirs.height, start: theirs.top }
|
|
121
|
-
: { length: theirs.width, start: theirs.left },
|
|
122
|
-
outer: this.vertical
|
|
123
|
-
? { length: mine.height, start: mine.top }
|
|
124
|
-
: { length: mine.width, start: mine.left },
|
|
125
|
-
};
|
|
126
|
-
capturePointer(handle, event.pointerId);
|
|
127
|
-
this.opened = this.collapsed ? undefined : this.position;
|
|
128
|
-
crossing.by.opened = crossing.by.collapsed ? undefined : crossing.by.position;
|
|
129
|
-
this.began = this.position;
|
|
130
|
-
crossing.by.began = crossing.by.position;
|
|
131
|
-
this.reached = undefined;
|
|
132
|
-
crossing.by.reached = undefined;
|
|
133
|
-
this.dragging = true;
|
|
134
|
-
crossing.by.dragging = true;
|
|
135
|
-
this.leaveSeparator(event);
|
|
136
|
-
};
|
|
137
|
-
this.handleCornerMove = (event) => {
|
|
138
|
-
const origin = this.cornerOrigin;
|
|
139
|
-
if (!origin) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const rtl = isRtl(this);
|
|
143
|
-
const along = (box, at, inline) => {
|
|
144
|
-
if (box.length === 0) {
|
|
145
|
-
return undefined;
|
|
146
|
-
}
|
|
147
|
-
const raw = ((at - box.start) / box.length) * 100;
|
|
148
|
-
return inline && rtl ? 100 - raw : raw;
|
|
149
|
-
};
|
|
150
|
-
const mine = along(origin.outer, this.vertical ? event.clientY : event.clientX, !this.vertical);
|
|
151
|
-
const theirs = along(origin.inner, origin.by.vertical ? event.clientY : event.clientX, !origin.by.vertical);
|
|
152
|
-
if (mine !== undefined) {
|
|
153
|
-
this.moveTo(mine);
|
|
154
|
-
}
|
|
155
|
-
if (theirs !== undefined) {
|
|
156
|
-
origin.by.moveTo(theirs);
|
|
157
|
-
}
|
|
158
|
-
this.leaveSeparator(event);
|
|
159
|
-
};
|
|
160
|
-
this.handleCornerUp = (event) => {
|
|
161
|
-
const origin = this.cornerOrigin;
|
|
162
|
-
if (!origin) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const handle = event.currentTarget;
|
|
166
|
-
if (handle.hasPointerCapture(event.pointerId)) {
|
|
167
|
-
handle.releasePointerCapture(event.pointerId);
|
|
168
|
-
}
|
|
169
|
-
this.cornerOrigin = null;
|
|
170
|
-
this.moveTo(this.reached ?? this.position, true);
|
|
171
|
-
origin.by.moveTo(origin.by.reached ?? origin.by.position, true);
|
|
172
|
-
this.leaveSeparator(event);
|
|
173
|
-
};
|
|
174
|
-
this.handleCornerKeydown = (event) => {
|
|
175
|
-
const crossing = this.crossings[Number(event.currentTarget.dataset.cross)];
|
|
176
|
-
if (!crossing) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const inner = crossing.by;
|
|
180
|
-
const mine = this.travel(event.key);
|
|
181
|
-
const theirs = inner.travel(event.key);
|
|
182
|
-
if (mine !== 0) {
|
|
183
|
-
this.moveTo(this.position + mine * this.step, true);
|
|
184
|
-
}
|
|
185
|
-
else if (theirs !== 0) {
|
|
186
|
-
inner.moveTo(inner.position + theirs * inner.step, true);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
this.leaveSeparator(event);
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
15
|
get collapsed() {
|
|
195
16
|
const held = this.collapsedState;
|
|
196
17
|
if (held === undefined) {
|
|
@@ -345,6 +166,15 @@ let HelixHeadlessSplitter = HelixHeadlessSplitter_1 = class HelixHeadlessSplitte
|
|
|
345
166
|
});
|
|
346
167
|
}
|
|
347
168
|
}
|
|
169
|
+
snapped(position, length) {
|
|
170
|
+
if (this.snap === '' || length <= 0) {
|
|
171
|
+
return position;
|
|
172
|
+
}
|
|
173
|
+
const points = commaList(this.snap)
|
|
174
|
+
.map((point) => this.toPercent(point, Number.NaN))
|
|
175
|
+
.filter((point) => Number.isFinite(point));
|
|
176
|
+
return snapTo(position, points, (this.snapThreshold / length) * 100);
|
|
177
|
+
}
|
|
348
178
|
travel(key) {
|
|
349
179
|
if (!this.vertical) {
|
|
350
180
|
return inlineStep(this, key);
|
|
@@ -376,26 +206,211 @@ let HelixHeadlessSplitter = HelixHeadlessSplitter_1 = class HelixHeadlessSplitte
|
|
|
376
206
|
const home = this.clamp(this.defaultPosition);
|
|
377
207
|
this.settle(home);
|
|
378
208
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
209
|
+
constructor() {
|
|
210
|
+
super();
|
|
211
|
+
this.collapsedLabel = 'Collapsed';
|
|
212
|
+
this.collapsedSize = 0;
|
|
213
|
+
this.cornerLabel = 'Resize both';
|
|
214
|
+
this.defaultPosition = 50;
|
|
215
|
+
this.label = 'Resize panes';
|
|
216
|
+
this.aria = new AriaForwardController(this, {
|
|
217
|
+
label: true,
|
|
218
|
+
target: () => this.partNamed('separator'),
|
|
219
|
+
});
|
|
220
|
+
this.max = 100;
|
|
221
|
+
this.min = 0;
|
|
222
|
+
this.snap = '';
|
|
223
|
+
this.snapThreshold = 12;
|
|
224
|
+
this.step = 2;
|
|
225
|
+
this.positionState = undefined;
|
|
226
|
+
this.collapsedState = undefined;
|
|
227
|
+
this.opened = undefined;
|
|
228
|
+
this.began = undefined;
|
|
229
|
+
this.reached = undefined;
|
|
230
|
+
this.dragging = false;
|
|
231
|
+
this.crossings = [];
|
|
232
|
+
this.outer = null;
|
|
233
|
+
this.crossedAt = undefined;
|
|
234
|
+
this.cornerOrigin = null;
|
|
235
|
+
this.origin = null;
|
|
236
|
+
this.stacked = false;
|
|
237
|
+
this.handlePointerDown = (event) => {
|
|
238
|
+
const separator = event.currentTarget;
|
|
239
|
+
const box = this.getBoundingClientRect();
|
|
240
|
+
this.origin = this.vertical
|
|
241
|
+
? { length: box.height, start: box.top }
|
|
242
|
+
: { length: box.width, start: box.left };
|
|
243
|
+
capturePointer(separator, event.pointerId);
|
|
244
|
+
this.opened = this.collapsed ? undefined : this.position;
|
|
245
|
+
this.began = this.position;
|
|
246
|
+
this.reached = undefined;
|
|
247
|
+
this.dragging = true;
|
|
248
|
+
event.preventDefault();
|
|
249
|
+
};
|
|
250
|
+
this.handlePointerMove = (event) => {
|
|
251
|
+
const origin = this.origin;
|
|
252
|
+
if (!origin || origin.length === 0) {
|
|
383
253
|
return;
|
|
384
254
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
this.
|
|
389
|
-
}
|
|
390
|
-
this.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
255
|
+
const along = this.vertical ? event.clientY : event.clientX;
|
|
256
|
+
const raw = ((along - origin.start) / origin.length) * 100;
|
|
257
|
+
const rtl = !this.vertical && isRtl(this);
|
|
258
|
+
this.move(this.snapped(rtl ? 100 - raw : raw, origin.length));
|
|
259
|
+
};
|
|
260
|
+
this.handlePointerUp = (event) => {
|
|
261
|
+
if (!this.origin) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const separator = event.currentTarget;
|
|
265
|
+
if (separator.hasPointerCapture(event.pointerId)) {
|
|
266
|
+
separator.releasePointerCapture(event.pointerId);
|
|
267
|
+
}
|
|
268
|
+
this.origin = null;
|
|
269
|
+
this.dragging = false;
|
|
270
|
+
this.settle(this.reached ?? this.position);
|
|
271
|
+
};
|
|
272
|
+
this.handleKeydown = (event) => {
|
|
273
|
+
if (event.key === 'Enter') {
|
|
274
|
+
this.toggleCollapse();
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const toward = this.travel(event.key);
|
|
279
|
+
let next;
|
|
280
|
+
if (toward !== 0) {
|
|
281
|
+
next = this.position + toward * this.step;
|
|
282
|
+
}
|
|
283
|
+
else if (event.key === 'Home') {
|
|
284
|
+
next = this.minPercent;
|
|
285
|
+
}
|
|
286
|
+
else if (event.key === 'End') {
|
|
287
|
+
next = this.maxPercent;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
this.settle(next);
|
|
293
|
+
event.preventDefault();
|
|
294
|
+
};
|
|
295
|
+
this.handleDoubleClick = () => {
|
|
296
|
+
this.reset();
|
|
297
|
+
};
|
|
298
|
+
this.handleCornerDoubleClick = (event) => {
|
|
299
|
+
const crossing = this.crossings[Number(event.currentTarget.dataset.cross)];
|
|
300
|
+
if (!crossing) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.reset();
|
|
304
|
+
crossing.by.reset();
|
|
305
|
+
this.leaveSeparator(event);
|
|
306
|
+
};
|
|
307
|
+
this.handleCornerDown = (event) => {
|
|
308
|
+
const handle = event.currentTarget;
|
|
309
|
+
const crossing = this.crossings[Number(handle.dataset.cross)];
|
|
310
|
+
if (!crossing) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const mine = this.getBoundingClientRect();
|
|
314
|
+
const theirs = crossing.by.getBoundingClientRect();
|
|
315
|
+
this.cornerOrigin = {
|
|
316
|
+
by: crossing.by,
|
|
317
|
+
inner: crossing.by.vertical
|
|
318
|
+
? { length: theirs.height, start: theirs.top }
|
|
319
|
+
: { length: theirs.width, start: theirs.left },
|
|
320
|
+
outer: this.vertical
|
|
321
|
+
? { length: mine.height, start: mine.top }
|
|
322
|
+
: { length: mine.width, start: mine.left },
|
|
323
|
+
};
|
|
324
|
+
capturePointer(handle, event.pointerId);
|
|
325
|
+
this.opened = this.collapsed ? undefined : this.position;
|
|
326
|
+
crossing.by.opened = crossing.by.collapsed ? undefined : crossing.by.position;
|
|
327
|
+
this.began = this.position;
|
|
328
|
+
crossing.by.began = crossing.by.position;
|
|
329
|
+
this.reached = undefined;
|
|
330
|
+
crossing.by.reached = undefined;
|
|
331
|
+
this.dragging = true;
|
|
332
|
+
crossing.by.dragging = true;
|
|
333
|
+
this.leaveSeparator(event);
|
|
334
|
+
};
|
|
335
|
+
this.handleCornerMove = (event) => {
|
|
336
|
+
const origin = this.cornerOrigin;
|
|
337
|
+
if (!origin) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const rtl = isRtl(this);
|
|
341
|
+
const along = (box, at, inline) => {
|
|
342
|
+
if (box.length === 0) {
|
|
343
|
+
return undefined;
|
|
344
|
+
}
|
|
345
|
+
const raw = ((at - box.start) / box.length) * 100;
|
|
346
|
+
return inline && rtl ? 100 - raw : raw;
|
|
347
|
+
};
|
|
348
|
+
const mine = along(origin.outer, this.vertical ? event.clientY : event.clientX, !this.vertical);
|
|
349
|
+
const theirs = along(origin.inner, origin.by.vertical ? event.clientY : event.clientX, !origin.by.vertical);
|
|
350
|
+
if (mine !== undefined) {
|
|
351
|
+
this.moveTo(mine);
|
|
352
|
+
}
|
|
353
|
+
if (theirs !== undefined) {
|
|
354
|
+
origin.by.moveTo(theirs);
|
|
355
|
+
}
|
|
356
|
+
this.leaveSeparator(event);
|
|
357
|
+
};
|
|
358
|
+
this.handleCornerUp = (event) => {
|
|
359
|
+
const origin = this.cornerOrigin;
|
|
360
|
+
if (!origin) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const handle = event.currentTarget;
|
|
364
|
+
if (handle.hasPointerCapture(event.pointerId)) {
|
|
365
|
+
handle.releasePointerCapture(event.pointerId);
|
|
366
|
+
}
|
|
367
|
+
this.cornerOrigin = null;
|
|
368
|
+
this.moveTo(this.reached ?? this.position, true);
|
|
369
|
+
origin.by.moveTo(origin.by.reached ?? origin.by.position, true);
|
|
370
|
+
this.leaveSeparator(event);
|
|
371
|
+
};
|
|
372
|
+
this.handleCornerKeydown = (event) => {
|
|
373
|
+
const crossing = this.crossings[Number(event.currentTarget.dataset.cross)];
|
|
374
|
+
if (!crossing) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const inner = crossing.by;
|
|
378
|
+
const mine = this.travel(event.key);
|
|
379
|
+
const theirs = inner.travel(event.key);
|
|
380
|
+
if (mine !== 0) {
|
|
381
|
+
this.moveTo(this.position + mine * this.step, true);
|
|
382
|
+
}
|
|
383
|
+
else if (theirs !== 0) {
|
|
384
|
+
inner.moveTo(inner.position + theirs * inner.step, true);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
this.leaveSeparator(event);
|
|
390
|
+
};
|
|
391
|
+
channel.set(this, {
|
|
392
|
+
cross: (by, at) => {
|
|
393
|
+
const found = this.crossings.find((crossing) => crossing.by === by);
|
|
394
|
+
if (found) {
|
|
395
|
+
if (found.at === at) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
found.at = at;
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
this.crossings.push({ at, by });
|
|
402
|
+
}
|
|
403
|
+
this.requestUpdate();
|
|
404
|
+
},
|
|
405
|
+
uncross: (by) => {
|
|
406
|
+
const at = this.crossings.findIndex((crossing) => crossing.by === by);
|
|
407
|
+
if (at === -1) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
this.crossings.splice(at, 1);
|
|
411
|
+
this.requestUpdate();
|
|
412
|
+
},
|
|
413
|
+
});
|
|
399
414
|
}
|
|
400
415
|
findOuter() {
|
|
401
416
|
const outer = closestInstance(this.parentElement, HelixHeadlessSplitter_1);
|
|
@@ -404,7 +419,7 @@ let HelixHeadlessSplitter = HelixHeadlessSplitter_1 = class HelixHeadlessSplitte
|
|
|
404
419
|
}
|
|
405
420
|
this.outer = outer;
|
|
406
421
|
this.crossedAt = this.position;
|
|
407
|
-
outer
|
|
422
|
+
channel.get(outer)?.cross(this, this.position);
|
|
408
423
|
}
|
|
409
424
|
leaveSeparator(event) {
|
|
410
425
|
event.stopPropagation();
|
|
@@ -421,7 +436,9 @@ let HelixHeadlessSplitter = HelixHeadlessSplitter_1 = class HelixHeadlessSplitte
|
|
|
421
436
|
super.disconnectedCallback();
|
|
422
437
|
this.sizes?.disconnect();
|
|
423
438
|
this.sizes = undefined;
|
|
424
|
-
this.outer
|
|
439
|
+
if (this.outer) {
|
|
440
|
+
channel.get(this.outer)?.uncross(this);
|
|
441
|
+
}
|
|
425
442
|
this.outer = null;
|
|
426
443
|
this.crossedAt = undefined;
|
|
427
444
|
}
|
|
@@ -449,7 +466,7 @@ let HelixHeadlessSplitter = HelixHeadlessSplitter_1 = class HelixHeadlessSplitte
|
|
|
449
466
|
}
|
|
450
467
|
if (this.outer && this.showing !== this.crossedAt) {
|
|
451
468
|
this.crossedAt = this.showing;
|
|
452
|
-
this.outer
|
|
469
|
+
channel.get(this.outer)?.cross(this, this.showing);
|
|
453
470
|
}
|
|
454
471
|
}
|
|
455
472
|
willUpdate(changed) {
|
|
@@ -541,6 +558,12 @@ __decorate([
|
|
|
541
558
|
__decorate([
|
|
542
559
|
property({ type: Number })
|
|
543
560
|
], HelixHeadlessSplitter.prototype, "position", null);
|
|
561
|
+
__decorate([
|
|
562
|
+
property()
|
|
563
|
+
], HelixHeadlessSplitter.prototype, "snap", void 0);
|
|
564
|
+
__decorate([
|
|
565
|
+
property({ attribute: 'snap-threshold', type: Number })
|
|
566
|
+
], HelixHeadlessSplitter.prototype, "snapThreshold", void 0);
|
|
544
567
|
__decorate([
|
|
545
568
|
property({ type: Number })
|
|
546
569
|
], HelixHeadlessSplitter.prototype, "step", void 0);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a dragged divider lands: on the nearest snap point within `threshold`,
|
|
3
|
+
* or where the pointer is.
|
|
4
|
+
*
|
|
5
|
+
* Every number is a percentage of the splitter's box, so the caller turns a
|
|
6
|
+
* point written as a length, and the threshold, into one first. Ties go to the
|
|
7
|
+
* point written first.
|
|
8
|
+
*/
|
|
9
|
+
export declare const snapTo: (position: number, points: readonly number[], threshold: number) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const snapTo = (position, points, threshold) => {
|
|
2
|
+
let best;
|
|
3
|
+
let distance = Number.POSITIVE_INFINITY;
|
|
4
|
+
for (const point of points) {
|
|
5
|
+
const away = Math.abs(point - position);
|
|
6
|
+
if (away <= threshold && away < distance) {
|
|
7
|
+
best = point;
|
|
8
|
+
distance = away;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return best ?? position;
|
|
12
|
+
};
|
|
@@ -12,6 +12,13 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
12
12
|
* add an attribute after upgrade, which markup rendered on the server by React
|
|
13
13
|
* does not have.
|
|
14
14
|
*
|
|
15
|
+
* **A stat with a label is a group named by it**, so a reader moving through a
|
|
16
|
+
* dashboard hears "Revenue, group" and then the figure, its unit and its
|
|
17
|
+
* trend as one reading, rather than a run of loose words. The role and the name
|
|
18
|
+
* are set through `ElementInternals` once the label is known, which writes no
|
|
19
|
+
* attribute; a stat with no label has no role. Put a `Trend` in the `trend`
|
|
20
|
+
* slot to have it read inside the group, after the figure it qualifies.
|
|
21
|
+
*
|
|
15
22
|
* @since 0.1.0
|
|
16
23
|
* @status stable
|
|
17
24
|
* @category data
|
|
@@ -19,7 +26,8 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
19
26
|
* @documentation https://fusion.dev/helix/components/stat
|
|
20
27
|
*
|
|
21
28
|
* @slot - The value.
|
|
22
|
-
* @slot label - What the value measures.
|
|
29
|
+
* @slot label - What the value measures, which also names the stat for a screen reader.
|
|
30
|
+
* @slot trend - How the value moved, usually a `Trend`, read after the value inside the stat's group.
|
|
23
31
|
* @slot unit - The unit, shown beside the value.
|
|
24
32
|
*
|
|
25
33
|
* @csspart value - The slot the value is written in. A slot draws no box, so it takes the inherited properties, such as color and font, and passes them to the value.
|
|
@@ -40,10 +48,9 @@ export declare class HelixHeadlessStat extends HelixElement {
|
|
|
40
48
|
* the value's baseline whichever way the pair goes, and only this element
|
|
41
49
|
* knows which of its children the unit belongs to.
|
|
42
50
|
*
|
|
43
|
-
*
|
|
44
|
-
* moved
|
|
45
|
-
*
|
|
46
|
-
* layouts, and the pair stays the column.
|
|
51
|
+
* The name and the values are `Flex`'s, which lays out the same way. Which
|
|
52
|
+
* way a number moved is `Trend`'s `movement`. On a Stat, `up`, `down` and
|
|
53
|
+
* `neutral` are not layouts, and the pair stays the column.
|
|
47
54
|
*
|
|
48
55
|
* **Optional rather than defaulted to `column`, which is not a style
|
|
49
56
|
* preference.** A reflecting property with a default writes its attribute onto
|
|
@@ -54,6 +61,8 @@ export declare class HelixHeadlessStat extends HelixElement {
|
|
|
54
61
|
* carries nothing nobody wrote.
|
|
55
62
|
*/
|
|
56
63
|
direction?: 'column-reverse' | 'row' | 'row-reverse';
|
|
64
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
65
|
+
protected firstUpdated(changed: PropertyValues): void;
|
|
57
66
|
protected updated(changed: PropertyValues): void;
|
|
58
67
|
protected render(): TemplateResult;
|
|
59
68
|
}
|
|
@@ -4,10 +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 { customElement, HelixElement, reportRuntime } from '@fusion.dev/helix-core';
|
|
7
|
+
import { customElement, HelixElement, hostAria, reportRuntime, slottedWords, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
10
|
let HelixHeadlessStat = class HelixHeadlessStat extends HelixElement {
|
|
11
|
+
willUpdate(changed) {
|
|
12
|
+
super.willUpdate(changed);
|
|
13
|
+
const labels = this.knownChildren.filter((child) => child.slot === 'label');
|
|
14
|
+
hostAria(this.internals, {
|
|
15
|
+
label: labels.length > 0 && !('ariaLabelledByElements' in this.internals)
|
|
16
|
+
? slottedWords(this, ['label'])
|
|
17
|
+
: '',
|
|
18
|
+
labelledBy: labels,
|
|
19
|
+
role: labels.length > 0 ? 'group' : '',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
firstUpdated(changed) {
|
|
23
|
+
super.firstUpdated(changed);
|
|
24
|
+
this.finishHydration();
|
|
25
|
+
}
|
|
11
26
|
updated(changed) {
|
|
12
27
|
super.updated(changed);
|
|
13
28
|
const given = this.direction;
|
|
@@ -15,16 +30,17 @@ let HelixHeadlessStat = class HelixHeadlessStat extends HelixElement {
|
|
|
15
30
|
reportRuntime({
|
|
16
31
|
kind: 'misread-direction',
|
|
17
32
|
message: `<${this.localName} direction="${given}"> lays out as the column: \`${given}\` is a ` +
|
|
18
|
-
"
|
|
19
|
-
|
|
33
|
+
"`movement` of Trend's, which says which way a number moved. Put it on the " +
|
|
34
|
+
"`helix-trend` in the stat's `trend` slot.",
|
|
20
35
|
tag: this.localName,
|
|
21
36
|
});
|
|
22
37
|
}
|
|
23
38
|
}
|
|
24
39
|
render() {
|
|
25
|
-
return html `<slot name="label"></slot>
|
|
40
|
+
return html `<slot name="label" @slotchange=${() => this.requestUpdate()}></slot>
|
|
26
41
|
<slot part="value"></slot>
|
|
27
|
-
<slot name="unit"></slot
|
|
42
|
+
<slot name="unit"></slot>
|
|
43
|
+
<slot name="trend"></slot>`;
|
|
28
44
|
}
|
|
29
45
|
};
|
|
30
46
|
__decorate([
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** What linear mode reads of a step. */
|
|
2
|
+
export interface ReachableStep {
|
|
3
|
+
/** Whether the stage is finished. */
|
|
4
|
+
complete: boolean;
|
|
5
|
+
/** Whether a reader may pass the stage without finishing it. */
|
|
6
|
+
optional: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Whether a reader on step `from` may go to step `to`, in a linear sequence.
|
|
10
|
+
*
|
|
11
|
+
* Back is always allowed, as Ark UI's linear steps allow it. Forward is allowed
|
|
12
|
+
* only where every stage from the one the reader is on up to the target is
|
|
13
|
+
* complete or optional, so no stage is passed unfinished.
|
|
14
|
+
*/
|
|
15
|
+
export declare const canReach: (steps: readonly ReachableStep[], from: number, to: number) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* How far through a sequence is, from 0 to 100: the share of its stages that
|
|
18
|
+
* are complete, rounded to a whole number. An empty sequence is at 0.
|
|
19
|
+
*/
|
|
20
|
+
export declare const progressOf: (steps: readonly Pick<ReachableStep, 'complete'>[]) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const canReach = (steps, from, to) => {
|
|
2
|
+
if (to <= from) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
for (let at = Math.max(from, 0); at < to; at += 1) {
|
|
6
|
+
const step = steps[at];
|
|
7
|
+
if (step && !step.complete && !step.optional) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
export const progressOf = (steps) => steps.length === 0
|
|
14
|
+
? 0
|
|
15
|
+
: Math.round((steps.filter((step) => step.complete).length / steps.length) * 100);
|