@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
|
@@ -4,32 +4,134 @@ 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 { AriaForwardController, customElement, elementById, HelixElement, searchableById, VirtualizeController, } from '@fusion.dev/helix-core';
|
|
8
|
-
import { html } from 'lit';
|
|
7
|
+
import { AriaForwardController, commaList, customElement, elementById, HelixBeforeChangeEvent, HelixElement, HelixLoadMoreEvent, HelixRangeChangeEvent, rangeAdd, requestChange, searchableById, Typeahead, toggleValue, typesCharacter, VirtualizeController, valueAt, } from '@fusion.dev/helix-core';
|
|
8
|
+
import { html, nothing, render } from 'lit';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
|
+
import { holdControls, releaseControls } from '../controls.js';
|
|
11
|
+
import { fillHoles, textOf } from '../fill.js';
|
|
12
|
+
import { stepIndex } from '../keys.js';
|
|
13
|
+
import { drawPlan, stopAfter } from '../plan.js';
|
|
10
14
|
let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixElement {
|
|
11
15
|
constructor() {
|
|
12
16
|
super(...arguments);
|
|
13
17
|
this.estimate = 32;
|
|
14
18
|
this.for = '';
|
|
19
|
+
this.keyField = '';
|
|
15
20
|
this.label = '';
|
|
21
|
+
this.loading = false;
|
|
22
|
+
this.loadingLabel = 'Loading more';
|
|
16
23
|
this.measured = false;
|
|
24
|
+
this.textField = '';
|
|
25
|
+
this.value = '';
|
|
17
26
|
this.rows = [];
|
|
18
27
|
this.source = null;
|
|
28
|
+
this.active = 0;
|
|
29
|
+
this.said = { first: 0, last: 0 };
|
|
30
|
+
this.typeahead = new Typeahead();
|
|
19
31
|
this.aria = new AriaForwardController(this, {
|
|
20
32
|
label: true,
|
|
21
33
|
target: () => this.partNamed('viewport'),
|
|
22
34
|
});
|
|
23
35
|
this.virtualize = new VirtualizeController(this, {
|
|
24
36
|
container: () => this.partNamed('viewport'),
|
|
25
|
-
count: () => this.
|
|
37
|
+
count: () => this.data.length,
|
|
26
38
|
estimate: () => this.estimate,
|
|
27
39
|
measured: () => this.measured,
|
|
28
40
|
rows: () => this.drawn(),
|
|
29
41
|
});
|
|
42
|
+
this.handleKeydown = (event) => {
|
|
43
|
+
if (event.defaultPrevented) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const at = this.indexOf(event.target);
|
|
47
|
+
if (at === undefined) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (typesCharacter(event) && (event.key !== ' ' || this.typeahead.typing())) {
|
|
51
|
+
const found = this.typeahead.match(event.key, this.texts(), at);
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
if (found >= 0 && found !== at) {
|
|
54
|
+
void this.focusIndex(found);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const toggle = event.ctrlKey || event.metaKey;
|
|
59
|
+
if (this.selectionMode && !event.altKey) {
|
|
60
|
+
if (toggle && event.key.toLowerCase() === 'a' && this.selectionMode === 'multiple') {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
this.choose(this.keys().join(','));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (event.key === ' ' && !toggle) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
this.press(at, event.shiftKey);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const extend = event.shiftKey && this.selectionMode === 'multiple';
|
|
72
|
+
if (event.altKey || toggle || (event.shiftKey && !extend)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const { first, last } = this.virtualize.visible();
|
|
76
|
+
const next = stepIndex(event.key, at, this.data.length, last - first - 1);
|
|
77
|
+
if (next === undefined) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
void this.focusIndex(next);
|
|
82
|
+
if (extend) {
|
|
83
|
+
this.anchor ??= this.keyAt(at);
|
|
84
|
+
this.press(next, true);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
this.handleClick = (event) => {
|
|
88
|
+
if (!this.selectionMode) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const path = event.composedPath();
|
|
92
|
+
const row = path.find((node) => node instanceof HTMLElement && node.parentElement === this);
|
|
93
|
+
const at = this.indexOf(row ?? null);
|
|
94
|
+
if (at === undefined) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const inner = path.slice(0, path.indexOf(row));
|
|
98
|
+
if (inner.some((node) => node instanceof HTMLElement &&
|
|
99
|
+
node.matches('a[href], button, input, select, textarea, label'))) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.press(at, event.shiftKey && this.selectionMode === 'multiple');
|
|
103
|
+
};
|
|
104
|
+
this.handleFocusOut = () => {
|
|
105
|
+
this.requestUpdate();
|
|
106
|
+
};
|
|
107
|
+
this.handleFocusIn = (event) => {
|
|
108
|
+
let node = event.target;
|
|
109
|
+
while (node && node.parentNode !== this) {
|
|
110
|
+
node = node.parentNode;
|
|
111
|
+
}
|
|
112
|
+
const index = this.indexOf(node);
|
|
113
|
+
if (index !== undefined) {
|
|
114
|
+
this.active = index;
|
|
115
|
+
}
|
|
116
|
+
this.requestUpdate();
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
get range() {
|
|
120
|
+
return this.virtualize.visible();
|
|
121
|
+
}
|
|
122
|
+
scrollToIndex(index, options = {}) {
|
|
123
|
+
const count = this.data.length;
|
|
124
|
+
if (count === 0 || !Number.isFinite(index)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.virtualize.reveal(Math.max(0, Math.min(Math.trunc(index), count - 1)), 0, options);
|
|
128
|
+
this.virtualize.measure();
|
|
129
|
+
}
|
|
130
|
+
get data() {
|
|
131
|
+
return this.items ?? this.rows;
|
|
30
132
|
}
|
|
31
133
|
drawn() {
|
|
32
|
-
return [...this.querySelectorAll('[data-index]')].map((element) => ({
|
|
134
|
+
return [...this.querySelectorAll(':scope > [data-index]')].map((element) => ({
|
|
33
135
|
element,
|
|
34
136
|
index: Number(element.dataset.index),
|
|
35
137
|
}));
|
|
@@ -43,6 +145,10 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
43
145
|
}
|
|
44
146
|
connectedCallback() {
|
|
45
147
|
super.connectedCallback();
|
|
148
|
+
this.addEventListener('keydown', this.handleKeydown);
|
|
149
|
+
this.addEventListener('click', this.handleClick);
|
|
150
|
+
this.addEventListener('focusin', this.handleFocusIn);
|
|
151
|
+
this.addEventListener('focusout', this.handleFocusOut);
|
|
46
152
|
if (typeof MutationObserver === 'undefined') {
|
|
47
153
|
return;
|
|
48
154
|
}
|
|
@@ -55,6 +161,10 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
55
161
|
}
|
|
56
162
|
disconnectedCallback() {
|
|
57
163
|
super.disconnectedCallback();
|
|
164
|
+
this.removeEventListener('keydown', this.handleKeydown);
|
|
165
|
+
this.removeEventListener('click', this.handleClick);
|
|
166
|
+
this.removeEventListener('focusin', this.handleFocusIn);
|
|
167
|
+
this.removeEventListener('focusout', this.handleFocusOut);
|
|
58
168
|
this.watcher?.disconnect();
|
|
59
169
|
this.watcher = undefined;
|
|
60
170
|
}
|
|
@@ -76,6 +186,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
76
186
|
super.updated?.(changed);
|
|
77
187
|
this.virtualize.measure();
|
|
78
188
|
this.place();
|
|
189
|
+
this.report();
|
|
79
190
|
}
|
|
80
191
|
read() {
|
|
81
192
|
const source = this.for === '' ? null : elementById(this, this.for);
|
|
@@ -93,6 +204,106 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
93
204
|
this.rows = [];
|
|
94
205
|
}
|
|
95
206
|
}
|
|
207
|
+
report() {
|
|
208
|
+
const { first, last } = this.virtualize.visible();
|
|
209
|
+
if (first !== this.said.first || last !== this.said.last) {
|
|
210
|
+
this.said = { first, last };
|
|
211
|
+
this.dispatchEvent(new HelixRangeChangeEvent({ first, last }));
|
|
212
|
+
}
|
|
213
|
+
if (!this.loading && this.virtualize.endInSight()) {
|
|
214
|
+
this.dispatchEvent(new HelixLoadMoreEvent());
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
texts() {
|
|
218
|
+
const field = this.textField ||
|
|
219
|
+
this.querySelector(':scope > template')
|
|
220
|
+
?.content.querySelector('[data-field]')
|
|
221
|
+
?.getAttribute('data-field') ||
|
|
222
|
+
'';
|
|
223
|
+
return this.data.map((item) => field === '' || item === null || typeof item !== 'object'
|
|
224
|
+
? textOf(item)
|
|
225
|
+
: textOf(valueAt(item, field)));
|
|
226
|
+
}
|
|
227
|
+
indexOf(node) {
|
|
228
|
+
if (!(node instanceof HTMLElement) || node.parentElement !== this) {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
const index = node.dataset.index;
|
|
232
|
+
return index === undefined ? undefined : Number(index);
|
|
233
|
+
}
|
|
234
|
+
rowFor(index) {
|
|
235
|
+
return this.querySelector(`:scope > [data-index="${index}"]`);
|
|
236
|
+
}
|
|
237
|
+
keyAt(at) {
|
|
238
|
+
const item = this.data[at];
|
|
239
|
+
if (this.keyField !== '' && item !== null && typeof item === 'object') {
|
|
240
|
+
return textOf(valueAt(item, this.keyField));
|
|
241
|
+
}
|
|
242
|
+
return typeof item === 'string' || typeof item === 'number' ? String(item) : String(at);
|
|
243
|
+
}
|
|
244
|
+
keys() {
|
|
245
|
+
return this.data.map((_, at) => this.keyAt(at));
|
|
246
|
+
}
|
|
247
|
+
get chosen() {
|
|
248
|
+
return new Set(commaList(this.value));
|
|
249
|
+
}
|
|
250
|
+
press(at, extend = false) {
|
|
251
|
+
const mode = this.selectionMode;
|
|
252
|
+
const key = this.keyAt(at);
|
|
253
|
+
if (!mode || at < 0 || at >= this.data.length) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const now = commaList(this.value);
|
|
257
|
+
if (extend && mode === 'multiple') {
|
|
258
|
+
const keys = this.keys();
|
|
259
|
+
const from = this.anchor === undefined ? -1 : keys.indexOf(this.anchor);
|
|
260
|
+
const range = rangeAdd(now, keys, from, at);
|
|
261
|
+
if (range) {
|
|
262
|
+
this.choose(this.inOrder(range));
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
this.anchor = key;
|
|
267
|
+
if (mode === 'single') {
|
|
268
|
+
this.choose(now.length === 1 && now[0] === key ? '' : key);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
this.choose(this.inOrder(toggleValue(now, key)));
|
|
272
|
+
}
|
|
273
|
+
inOrder(keys) {
|
|
274
|
+
const wanted = new Set(keys);
|
|
275
|
+
const ordered = this.keys().filter((key) => wanted.has(key));
|
|
276
|
+
const placed = new Set(ordered);
|
|
277
|
+
return [...ordered, ...keys.filter((key) => !placed.has(key))].join(',');
|
|
278
|
+
}
|
|
279
|
+
choose(next) {
|
|
280
|
+
if (next === this.value) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
requestChange({
|
|
284
|
+
apply: (value) => {
|
|
285
|
+
this.value = value;
|
|
286
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
287
|
+
},
|
|
288
|
+
event: (value) => new HelixBeforeChangeEvent({ value }),
|
|
289
|
+
host: this,
|
|
290
|
+
next,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
async focusIndex(index) {
|
|
294
|
+
this.active = index;
|
|
295
|
+
this.focusing = index;
|
|
296
|
+
this.virtualize.reveal(index);
|
|
297
|
+
this.virtualize.measure();
|
|
298
|
+
this.requestUpdate();
|
|
299
|
+
try {
|
|
300
|
+
await this.updateComplete;
|
|
301
|
+
}
|
|
302
|
+
finally {
|
|
303
|
+
this.focusing = undefined;
|
|
304
|
+
}
|
|
305
|
+
this.rowFor(index)?.focus();
|
|
306
|
+
}
|
|
96
307
|
focusedIndex() {
|
|
97
308
|
const root = this.getRootNode();
|
|
98
309
|
let node = root.activeElement;
|
|
@@ -103,89 +314,138 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
103
314
|
return index === undefined ? undefined : Number(index);
|
|
104
315
|
}
|
|
105
316
|
keptIndex() {
|
|
106
|
-
const index = this.focusedIndex();
|
|
317
|
+
const index = this.focusing ?? this.focusedIndex();
|
|
107
318
|
const { first, last } = this.virtualize.window;
|
|
108
|
-
return index !== undefined && index < this.
|
|
319
|
+
return index !== undefined && index < this.data.length && (index < first || index >= last)
|
|
109
320
|
? index
|
|
110
321
|
: undefined;
|
|
111
322
|
}
|
|
112
|
-
|
|
113
|
-
|
|
323
|
+
mark(element, at, chosen) {
|
|
324
|
+
element.setAttribute('role', this.selectionMode ? 'option' : 'listitem');
|
|
325
|
+
if (this.selectionMode) {
|
|
326
|
+
element.setAttribute('aria-selected', String(chosen.has(this.keyAt(at))));
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
element.removeAttribute('aria-selected');
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
stamp(element, at) {
|
|
333
|
+
element.setAttribute('aria-posinset', String(at + 1));
|
|
334
|
+
element.setAttribute('aria-setsize', String(this.data.length));
|
|
335
|
+
element.setAttribute('data-index', String(at));
|
|
336
|
+
}
|
|
337
|
+
fill(elements, at) {
|
|
338
|
+
const item = this.data[at];
|
|
114
339
|
for (const element of elements) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
...element.querySelectorAll('[data-field]'),
|
|
118
|
-
]) {
|
|
119
|
-
hole.textContent = row[hole.dataset.field ?? ''] ?? '';
|
|
340
|
+
if (this.renderItem) {
|
|
341
|
+
render(this.renderItem(item, at), element);
|
|
120
342
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
343
|
+
else {
|
|
344
|
+
fillHoles(element, item);
|
|
345
|
+
}
|
|
346
|
+
this.stamp(element, at);
|
|
125
347
|
}
|
|
126
348
|
}
|
|
349
|
+
draw(template, at) {
|
|
350
|
+
const fragment = document.createDocumentFragment();
|
|
351
|
+
if (this.renderItem) {
|
|
352
|
+
fragment.append(document.createElement('div'));
|
|
353
|
+
}
|
|
354
|
+
else if (template) {
|
|
355
|
+
fragment.append(template.content.cloneNode(true));
|
|
356
|
+
}
|
|
357
|
+
this.fill([...fragment.children], at);
|
|
358
|
+
return fragment;
|
|
359
|
+
}
|
|
127
360
|
place() {
|
|
128
|
-
const template = this.querySelector('template');
|
|
129
|
-
if (!template) {
|
|
361
|
+
const template = this.querySelector(':scope > template');
|
|
362
|
+
if (!template && !this.renderItem) {
|
|
130
363
|
return;
|
|
131
364
|
}
|
|
365
|
+
const count = this.data.length;
|
|
132
366
|
const { first, last } = this.virtualize.window;
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
const keep = new Set(wanted);
|
|
367
|
+
const children = [...this.children].filter((child) => child !== template && child instanceof HTMLElement && !child.hasAttribute('slot'));
|
|
368
|
+
const plan = drawPlan({
|
|
369
|
+
count,
|
|
370
|
+
drawn: children.map((child) => Number(child.dataset.index)),
|
|
371
|
+
first,
|
|
372
|
+
kept: this.keptIndex(),
|
|
373
|
+
last,
|
|
374
|
+
redraw: (this.filledBy === undefined) !== (this.renderItem === undefined),
|
|
375
|
+
});
|
|
143
376
|
const drawn = new Map();
|
|
144
|
-
for (const child of
|
|
145
|
-
if (child === template) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
377
|
+
for (const child of children) {
|
|
148
378
|
const index = Number(child.dataset.index);
|
|
149
|
-
if (
|
|
379
|
+
if (plan.remove.has(index)) {
|
|
150
380
|
child.remove();
|
|
151
381
|
continue;
|
|
152
382
|
}
|
|
153
383
|
drawn.set(index, [...(drawn.get(index) ?? []), child]);
|
|
154
384
|
}
|
|
155
|
-
const refill = this.filledFrom !== this.
|
|
156
|
-
this.filledFrom = this.
|
|
385
|
+
const refill = this.filledFrom !== this.data || this.filledBy !== this.renderItem;
|
|
386
|
+
this.filledFrom = this.data;
|
|
387
|
+
this.filledBy = this.renderItem;
|
|
388
|
+
const fresh = new Set();
|
|
157
389
|
let anchor = drawn.values().next().value?.[0] ?? null;
|
|
158
|
-
for (const at of wanted) {
|
|
159
|
-
const row = this.rows[at];
|
|
390
|
+
for (const at of plan.wanted) {
|
|
160
391
|
const group = drawn.get(at);
|
|
161
392
|
if (group) {
|
|
162
393
|
if (refill) {
|
|
163
|
-
this.fill(group,
|
|
394
|
+
this.fill(group, at);
|
|
395
|
+
fresh.add(at);
|
|
164
396
|
}
|
|
165
397
|
anchor = group.at(-1).nextElementSibling;
|
|
166
398
|
continue;
|
|
167
399
|
}
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
400
|
+
const fragment = this.draw(template, at);
|
|
401
|
+
drawn.set(at, [...fragment.children]);
|
|
402
|
+
fresh.add(at);
|
|
403
|
+
this.insertBefore(fragment, anchor);
|
|
404
|
+
}
|
|
405
|
+
this.active = stopAfter(this.active, plan.wanted, {
|
|
406
|
+
count,
|
|
407
|
+
first,
|
|
408
|
+
last,
|
|
409
|
+
onScreen: this.virtualize.visible().first,
|
|
410
|
+
});
|
|
411
|
+
const chosen = this.chosen;
|
|
412
|
+
for (const [at, group] of drawn) {
|
|
413
|
+
for (const element of group) {
|
|
414
|
+
this.mark(element, at, chosen);
|
|
415
|
+
}
|
|
416
|
+
const stop = at === this.active;
|
|
417
|
+
group[0]?.setAttribute('tabindex', stop ? '0' : '-1');
|
|
418
|
+
if (stop && (fresh.has(at) || this.released !== at)) {
|
|
419
|
+
releaseControls(group);
|
|
420
|
+
}
|
|
421
|
+
else if (!stop && (fresh.has(at) || this.released === at)) {
|
|
422
|
+
holdControls(group);
|
|
423
|
+
}
|
|
171
424
|
}
|
|
425
|
+
this.released = this.active;
|
|
172
426
|
}
|
|
173
427
|
render() {
|
|
174
|
-
const
|
|
175
|
-
const kept = this.hasUpdated ? this.keptIndex() : undefined;
|
|
176
|
-
const room = kept === undefined ? 0 : this.virtualize.sizeOf(kept);
|
|
177
|
-
const before = window.before - (kept !== undefined && kept < window.first ? room : 0);
|
|
178
|
-
const after = window.after - (kept !== undefined && kept >= window.last ? room : 0);
|
|
428
|
+
const { after, before } = this.virtualize.spacers(this.hasUpdated ? this.keptIndex() : undefined);
|
|
179
429
|
return html `<div
|
|
180
430
|
data-scroller
|
|
181
431
|
part="viewport"
|
|
182
|
-
role
|
|
432
|
+
role=${this.selectionMode ? 'listbox' : 'list'}
|
|
433
|
+
aria-multiselectable=${this.selectionMode === 'multiple' ? 'true' : nothing}
|
|
434
|
+
aria-busy=${this.loading ? 'true' : nothing}
|
|
183
435
|
aria-label=${this.label}
|
|
184
|
-
@scroll=${() =>
|
|
436
|
+
@scroll=${() => {
|
|
437
|
+
this.virtualize.measure();
|
|
438
|
+
this.report();
|
|
439
|
+
}}
|
|
185
440
|
>
|
|
186
441
|
<div part="before" style="block-size: ${before}px"></div>
|
|
187
442
|
<slot></slot>
|
|
188
443
|
<div part="after" style="block-size: ${after}px"></div>
|
|
444
|
+
${this.loading
|
|
445
|
+
? html `<div part="loading" role=${this.selectionMode ? 'option' : 'listitem'}>
|
|
446
|
+
<slot name="loading">${this.loadingLabel}</slot>
|
|
447
|
+
</div>`
|
|
448
|
+
: nothing}
|
|
189
449
|
</div>`;
|
|
190
450
|
}
|
|
191
451
|
};
|
|
@@ -195,12 +455,36 @@ __decorate([
|
|
|
195
455
|
__decorate([
|
|
196
456
|
property()
|
|
197
457
|
], HelixHeadlessVirtualList.prototype, "for", void 0);
|
|
458
|
+
__decorate([
|
|
459
|
+
property({ attribute: false })
|
|
460
|
+
], HelixHeadlessVirtualList.prototype, "items", void 0);
|
|
461
|
+
__decorate([
|
|
462
|
+
property({ attribute: 'key-field' })
|
|
463
|
+
], HelixHeadlessVirtualList.prototype, "keyField", void 0);
|
|
198
464
|
__decorate([
|
|
199
465
|
property()
|
|
200
466
|
], HelixHeadlessVirtualList.prototype, "label", void 0);
|
|
467
|
+
__decorate([
|
|
468
|
+
property({ type: Boolean })
|
|
469
|
+
], HelixHeadlessVirtualList.prototype, "loading", void 0);
|
|
470
|
+
__decorate([
|
|
471
|
+
property({ attribute: 'loading-label' })
|
|
472
|
+
], HelixHeadlessVirtualList.prototype, "loadingLabel", void 0);
|
|
201
473
|
__decorate([
|
|
202
474
|
property({ type: Boolean })
|
|
203
475
|
], HelixHeadlessVirtualList.prototype, "measured", void 0);
|
|
476
|
+
__decorate([
|
|
477
|
+
property({ attribute: false })
|
|
478
|
+
], HelixHeadlessVirtualList.prototype, "renderItem", void 0);
|
|
479
|
+
__decorate([
|
|
480
|
+
property({ attribute: 'selection-mode' })
|
|
481
|
+
], HelixHeadlessVirtualList.prototype, "selectionMode", void 0);
|
|
482
|
+
__decorate([
|
|
483
|
+
property({ attribute: 'text-field' })
|
|
484
|
+
], HelixHeadlessVirtualList.prototype, "textField", void 0);
|
|
485
|
+
__decorate([
|
|
486
|
+
property()
|
|
487
|
+
], HelixHeadlessVirtualList.prototype, "value", void 0);
|
|
204
488
|
__decorate([
|
|
205
489
|
state()
|
|
206
490
|
], HelixHeadlessVirtualList.prototype, "rows", void 0);
|