@fusion.dev/helix-headless 0.146.0 → 0.148.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 +9287 -1084
- package/dist/accordion/item/accordion-item.d.ts +43 -21
- package/dist/accordion/item/accordion-item.js +37 -11
- package/dist/accordion/root/accordion-root.d.ts +8 -2
- package/dist/accordion/root/accordion-root.js +6 -8
- package/dist/announcement/root/announcement-root.d.ts +66 -6
- package/dist/announcement/root/announcement-root.js +144 -13
- package/dist/area-chart/root/area-chart-root.d.ts +18 -1
- package/dist/area-chart/root/area-chart-root.js +14 -7
- package/dist/avatar/root/avatar-root.d.ts +31 -1
- package/dist/avatar/root/avatar-root.js +11 -1
- package/dist/badge/count.d.ts +14 -0
- package/dist/badge/count.js +20 -0
- package/dist/badge/root/badge-root.d.ts +57 -6
- package/dist/badge/root/badge-root.js +77 -8
- package/dist/bar-chart/root/bar-chart-root.js +11 -20
- package/dist/bar-chart/stack.d.ts +10 -0
- package/dist/bar-chart/stack.js +8 -0
- package/dist/blockquote/root/blockquote-root.d.ts +66 -8
- package/dist/blockquote/root/blockquote-root.js +85 -8
- package/dist/breadcrumbs/breadcrumb/breadcrumb.d.ts +14 -0
- package/dist/breadcrumbs/breadcrumb/breadcrumb.js +12 -2
- package/dist/breadcrumbs/root/breadcrumbs-root.js +2 -2
- package/dist/button/root/button-root.d.ts +24 -38
- package/dist/button/root/button-root.js +6 -37
- package/dist/button/submitter.d.ts +27 -0
- package/dist/button/submitter.js +25 -0
- package/dist/button-group/arrows.d.ts +14 -0
- package/dist/button-group/arrows.js +10 -0
- package/dist/button-group/root/button-group-root.d.ts +141 -3
- package/dist/button-group/root/button-group-root.js +142 -2
- package/dist/canvas/edge-pan.d.ts +61 -0
- package/dist/canvas/edge-pan.js +63 -0
- package/dist/canvas/node/canvas-node.d.ts +12 -2
- package/dist/canvas/node/canvas-node.js +6 -2
- package/dist/canvas/root/canvas-document.d.ts +10 -0
- package/dist/canvas/root/canvas-document.js +1 -0
- package/dist/canvas/root/canvas-root.d.ts +107 -5
- package/dist/canvas/root/canvas-root.js +140 -36
- package/dist/canvas/snap.d.ts +42 -0
- package/dist/canvas/snap.js +32 -0
- package/dist/card/root/card-root.d.ts +12 -1
- package/dist/card/root/card-root.js +11 -4
- package/dist/carousel/root/carousel-root.d.ts +4 -3
- package/dist/carousel/root/carousel-root.js +2 -6
- package/dist/chat/root/chat-root.d.ts +28 -4
- package/dist/chat/root/chat-root.js +12 -7
- package/dist/checkbox/root/checkbox-root.js +5 -7
- package/dist/checkbox-group/root/checkbox-group-root.d.ts +13 -0
- package/dist/checkbox-group/root/checkbox-group-root.js +16 -7
- package/dist/checkbox-group/select-all.d.ts +9 -4
- package/dist/checkbox-group/select-all.js +1 -1
- package/dist/code-block/root/code-block-root.d.ts +41 -18
- package/dist/code-block/root/code-block-root.js +21 -6
- package/dist/color-input/root/color-input-root.d.ts +11 -0
- package/dist/color-input/root/color-input-root.js +12 -5
- package/dist/color-picker/channels.js +1 -2
- package/dist/color-picker/root/color-picker-root.d.ts +32 -24
- package/dist/color-picker/root/color-picker-root.js +99 -55
- package/dist/color-picker/wheel.d.ts +28 -0
- package/dist/color-picker/wheel.js +15 -0
- package/dist/combobox/root/combobox-root.d.ts +83 -11
- package/dist/combobox/root/combobox-root.js +81 -18
- package/dist/command/root/command-root.d.ts +7 -4
- package/dist/command/root/command-root.js +2 -19
- package/dist/copy-button/root/copy-button-root.d.ts +16 -1
- package/dist/copy-button/root/copy-button-root.js +7 -2
- package/dist/data-table/keys.d.ts +0 -18
- package/dist/data-table/keys.js +1 -11
- package/dist/data-table/root/data-table-root.js +29 -50
- package/dist/date-input/root/date-input-root.d.ts +8 -1
- package/dist/date-input/root/date-input-root.js +8 -5
- package/dist/date-picker/root/date-picker-root.d.ts +14 -9
- package/dist/date-picker/root/date-picker-root.js +21 -16
- package/dist/description-list/item/description-list-item.d.ts +22 -4
- package/dist/description-list/item/description-list-item.js +14 -4
- package/dist/divider/root/divider-root.d.ts +45 -16
- package/dist/divider/root/divider-root.js +28 -4
- package/dist/donut-chart/root/donut-chart-root.js +13 -6
- package/dist/donut-chart/slice-label.d.ts +35 -0
- package/dist/donut-chart/slice-label.js +11 -0
- package/dist/drawer/root/drawer-root.d.ts +4 -2
- package/dist/drawer/root/drawer-root.js +15 -3
- package/dist/drilldown/item/drilldown-item.d.ts +21 -1
- package/dist/drilldown/item/drilldown-item.js +38 -4
- package/dist/drilldown/root/drilldown-root.js +3 -2
- package/dist/element-events.generated.js +5 -1
- package/dist/empty/root/empty-root.d.ts +46 -2
- package/dist/empty/root/empty-root.js +50 -5
- package/dist/file-input/root/file-input-root.d.ts +34 -6
- package/dist/file-input/root/file-input-root.js +55 -21
- package/dist/file-input/status.d.ts +24 -0
- package/dist/file-input/status.js +11 -0
- package/dist/filter-input/chip/filter-chip.d.ts +23 -0
- package/dist/filter-input/chip/filter-chip.js +10 -2
- package/dist/filter-input/root/filter-input-root.d.ts +8 -0
- package/dist/filter-input/root/filter-input-root.js +17 -27
- package/dist/format-date/fields.d.ts +20 -0
- package/dist/format-date/fields.js +14 -0
- package/dist/format-date/options.d.ts +5 -5
- package/dist/format-date/options.js +10 -39
- package/dist/format-date/root/format-date-root.d.ts +53 -4
- package/dist/format-date/root/format-date-root.js +38 -50
- package/dist/graph/root/graph-root.d.ts +23 -5
- package/dist/graph/root/graph-root.js +17 -20
- package/dist/heatmap/root/buckets.d.ts +21 -0
- package/dist/heatmap/root/buckets.js +34 -0
- package/dist/heatmap/root/heatmap-root.d.ts +76 -3
- package/dist/heatmap/root/heatmap-root.js +105 -20
- package/dist/icon/index.d.ts +1 -1
- package/dist/icon/index.js +1 -1
- package/dist/icon/registry.d.ts +26 -1
- package/dist/icon/registry.js +12 -1
- package/dist/icon/root/icon-root.d.ts +13 -0
- package/dist/icon/root/icon-root.js +23 -2
- package/dist/icon/root/index.d.ts +1 -1
- package/dist/icon/root/index.js +1 -1
- package/dist/image/root/image-root.d.ts +20 -0
- package/dist/image/root/image-root.js +6 -1
- package/dist/input/root/input-root.d.ts +23 -2
- package/dist/input/root/input-root.js +12 -8
- package/dist/kbd/root/kbd-root.d.ts +20 -3
- package/dist/kbd/root/kbd-root.js +23 -50
- package/dist/legend/hidden-series.d.ts +10 -2
- package/dist/legend/hidden-series.js +5 -2
- package/dist/legend/root/legend-root.d.ts +25 -7
- package/dist/legend/root/legend-root.js +25 -26
- package/dist/lightbox/root/lightbox-root.d.ts +50 -5
- package/dist/lightbox/root/lightbox-root.js +76 -8
- package/dist/lightbox/zoom.d.ts +2 -0
- package/dist/lightbox/zoom.js +5 -3
- package/dist/line-chart/root/line-chart-root.d.ts +16 -0
- package/dist/line-chart/root/line-chart-root.js +10 -2
- package/dist/list/root/list-root.d.ts +10 -2
- package/dist/list/root/list-root.js +31 -24
- package/dist/list/selection.d.ts +17 -0
- package/dist/list/selection.js +16 -0
- package/dist/listbox/root/listbox-root.d.ts +125 -26
- package/dist/listbox/root/listbox-root.js +156 -166
- package/dist/map/marker/map-marker.d.ts +2 -1
- package/dist/map/root/map-root.d.ts +40 -2
- package/dist/map/root/map-root.js +64 -23
- package/dist/megamenu/hand-over.d.ts +75 -0
- package/dist/megamenu/hand-over.js +67 -0
- package/dist/megamenu/root/megamenu-root.d.ts +38 -14
- package/dist/megamenu/root/megamenu-root.js +29 -50
- package/dist/menu/item/menu-item.js +4 -4
- package/dist/menu/root/menu-root.d.ts +5 -2
- package/dist/meter/root/meter-root.d.ts +42 -0
- package/dist/meter/root/meter-root.js +33 -7
- package/dist/navigation/root/navigation-root.js +5 -8
- package/dist/notifications/group/notification-group.d.ts +8 -1
- package/dist/notifications/group/notification-group.js +12 -6
- package/dist/notifications/notification/notification.d.ts +12 -1
- package/dist/notifications/notification/notification.js +3 -1
- package/dist/notifications/root/notifications-root.d.ts +48 -3
- package/dist/notifications/root/notifications-root.js +36 -6
- package/dist/number-input/grain.d.ts +28 -0
- package/dist/number-input/grain.js +14 -0
- package/dist/number-input/root/number-input-root.d.ts +17 -1
- package/dist/number-input/root/number-input-root.js +29 -18
- package/dist/object-inspector/root/object-inspector-root.d.ts +17 -6
- package/dist/object-inspector/root/object-inspector-root.js +31 -20
- package/dist/option/index.d.ts +1 -0
- package/dist/option/index.js +1 -0
- package/dist/option/separator/option-separator.d.ts +30 -0
- package/dist/option/separator/option-separator.js +21 -0
- package/dist/outline/root/outline-root.d.ts +12 -0
- package/dist/outline/root/outline-root.js +5 -19
- package/dist/pagination/size/pagination-size.d.ts +6 -0
- package/dist/pagination/size/pagination-size.js +5 -3
- package/dist/pin-input/code.d.ts +51 -1
- package/dist/pin-input/code.js +37 -0
- package/dist/pin-input/root/pin-input-root.d.ts +98 -121
- package/dist/pin-input/root/pin-input-root.js +151 -156
- package/dist/popover/hide-outside.js +2 -9
- package/dist/popover/root/popover-root.d.ts +7 -1
- package/dist/popover/root/popover-root.js +9 -1
- package/dist/progress/root/progress-root.d.ts +27 -0
- package/dist/progress/root/progress-root.js +25 -7
- package/dist/qr-code/export.d.ts +19 -0
- package/dist/qr-code/export.js +14 -0
- package/dist/qr-code/name.d.ts +11 -0
- package/dist/qr-code/name.js +7 -0
- package/dist/qr-code/root/qr-code-root.d.ts +31 -9
- package/dist/qr-code/root/qr-code-root.js +29 -17
- package/dist/radio/group/radio-group.d.ts +15 -0
- package/dist/radio/root/radio-root.js +2 -2
- package/dist/rating/root/rating-root.d.ts +22 -9
- package/dist/rating/root/rating-root.js +15 -39
- package/dist/scatter-chart/measures.d.ts +22 -0
- package/dist/scatter-chart/measures.js +11 -0
- package/dist/scatter-chart/root/scatter-chart-root.d.ts +26 -0
- package/dist/scatter-chart/root/scatter-chart-root.js +21 -7
- package/dist/scroll-area/scrollbar.d.ts +0 -8
- package/dist/scroll-area/scrollbar.js +1 -1
- package/dist/select/align.d.ts +47 -0
- package/dist/select/align.js +7 -0
- package/dist/select/root/select-root.d.ts +115 -11
- package/dist/select/root/select-root.js +104 -20
- package/dist/slider/root/slider-root.d.ts +18 -1
- package/dist/slider/root/slider-root.js +22 -0
- package/dist/sparkline/readings.d.ts +30 -12
- package/dist/sparkline/readings.js +32 -15
- package/dist/sparkline/root/sparkline-root.d.ts +46 -3
- package/dist/sparkline/root/sparkline-root.js +60 -21
- package/dist/speed-dial/group/speed-dial-group.d.ts +48 -0
- package/dist/speed-dial/group/speed-dial-group.js +43 -0
- package/dist/speed-dial/index.d.ts +1 -0
- package/dist/speed-dial/index.js +1 -0
- package/dist/speed-dial/item/speed-dial-item.d.ts +27 -2
- package/dist/speed-dial/item/speed-dial-item.js +43 -5
- package/dist/speed-dial/long-press.d.ts +50 -0
- package/dist/speed-dial/long-press.js +48 -0
- package/dist/speed-dial/root/speed-dial-root.d.ts +86 -1
- package/dist/speed-dial/root/speed-dial-root.js +123 -6
- package/dist/splitter/root/splitter-root.d.ts +9 -2
- package/dist/splitter/root/splitter-root.js +18 -3
- package/dist/steps/root/steps-root.d.ts +8 -1
- package/dist/steps/root/steps-root.js +6 -1
- package/dist/steps/step/step.d.ts +1 -0
- package/dist/steps/step/step.js +1 -1
- package/dist/table/cell/table-cell.d.ts +8 -1
- package/dist/table/cell/table-cell.js +6 -2
- package/dist/table/column/table-column.d.ts +6 -0
- package/dist/table/column/table-column.js +5 -1
- package/dist/table/grid-controller.d.ts +117 -0
- package/dist/table/grid-controller.js +293 -0
- package/dist/table/root/table-root.d.ts +47 -3
- package/dist/table/root/table-root.js +93 -29
- package/dist/table/row/table-row.d.ts +36 -0
- package/dist/table/row/table-row.js +52 -2
- package/dist/tabs/root/tabs-root.d.ts +5 -3
- package/dist/tag/group/tag-group.d.ts +16 -4
- package/dist/tag/group/tag-group.js +23 -20
- package/dist/textarea/root/textarea-root.d.ts +14 -2
- package/dist/textarea/root/textarea-root.js +6 -7
- package/dist/time-input/root/time-input-root.d.ts +5 -1
- package/dist/time-input/root/time-input-root.js +10 -7
- package/dist/time-picker/root/time-picker-root.d.ts +12 -14
- package/dist/time-picker/root/time-picker-root.js +18 -23
- package/dist/toast/item/toast-item.d.ts +9 -6
- package/dist/toast/item/toast-item.js +1 -1
- package/dist/toast/root/toast-root.d.ts +40 -4
- package/dist/toast/root/toast-root.js +68 -16
- package/dist/toast/words.d.ts +12 -0
- package/dist/toast/words.js +25 -0
- package/dist/toggle/group/toggle-group.d.ts +29 -5
- package/dist/toggle/group/toggle-group.js +26 -43
- package/dist/toggle/root/toggle-root.js +2 -4
- package/dist/toolbar/root/toolbar-root.d.ts +52 -5
- package/dist/toolbar/root/toolbar-root.js +88 -13
- package/dist/tooltip/root/tooltip-root.d.ts +7 -1
- package/dist/tooltip/root/tooltip-root.js +10 -2
- package/dist/tour/root/tour-root.d.ts +15 -0
- package/dist/tour/root/tour-root.js +20 -1
- package/dist/tour/stop/tour-stop.d.ts +3 -0
- package/dist/tour/stop/tour-stop.js +3 -3
- package/dist/tree/root/tree-root.js +2 -2
- package/dist/trend/figure.d.ts +16 -0
- package/dist/trend/figure.js +8 -0
- package/dist/trend/root/trend-root.d.ts +41 -2
- package/dist/trend/root/trend-root.js +29 -3
- package/dist/video/root/extra-controls.d.ts +12 -0
- package/dist/video/root/extra-controls.js +6 -2
- package/dist/video/root/video-root.d.ts +16 -1
- package/dist/video/root/video-root.js +15 -1
- package/dist/video-playlist/root/video-playlist-root.d.ts +11 -1
- package/dist/video-playlist/root/video-playlist-root.js +3 -0
- package/dist/virtual-list/fill.d.ts +11 -0
- package/dist/virtual-list/fill.js +9 -0
- package/dist/virtual-list/keys.d.ts +16 -7
- package/dist/virtual-list/keys.js +17 -6
- package/dist/virtual-list/plan.d.ts +17 -1
- package/dist/virtual-list/plan.js +13 -2
- package/dist/virtual-list/root/virtual-list-root.d.ts +25 -3
- package/dist/virtual-list/root/virtual-list-root.js +53 -41
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +4934 -954
- package/types/svelte.d.ts +2 -0
- package/types/vue.d.ts +946 -253
- package/dist/color-picker/swatches.d.ts +0 -12
- package/dist/color-picker/swatches.js +0 -26
- package/dist/rating/steps.d.ts +0 -7
- package/dist/rating/steps.js +0 -9
- package/dist/tooltip/focus-target.d.ts +0 -6
- package/dist/tooltip/focus-target.js +0 -9
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export const drawPlan = ({ count, drawn, first, kept, last, redraw = false, }) => {
|
|
1
|
+
export const drawPlan = ({ across = 1, count, drawn, first, kept, last, redraw = false, }) => {
|
|
2
2
|
const wanted = [];
|
|
3
3
|
for (let at = first; at < Math.min(last, count); at += 1) {
|
|
4
4
|
wanted.push(at);
|
|
5
5
|
}
|
|
6
6
|
if (kept !== undefined && !wanted.includes(kept)) {
|
|
7
|
-
|
|
7
|
+
const width = Math.max(1, across);
|
|
8
|
+
const start = kept - (kept % width);
|
|
9
|
+
for (let at = start; at < Math.min(start + width, count); at += 1) {
|
|
10
|
+
wanted.push(at);
|
|
11
|
+
}
|
|
8
12
|
wanted.sort((a, b) => a - b);
|
|
9
13
|
}
|
|
10
14
|
const keep = new Set(wanted);
|
|
@@ -14,3 +18,10 @@ export const drawPlan = ({ count, drawn, first, kept, last, redraw = false, }) =
|
|
|
14
18
|
export const stopAfter = (active, wanted, { count, first, last, onScreen, }) => wanted.includes(active)
|
|
15
19
|
? active
|
|
16
20
|
: Math.max(Math.min(onScreen, Math.min(last, count) - 1), first, 0);
|
|
21
|
+
export const itemsOf = (lines, across, count) => {
|
|
22
|
+
const width = Math.max(1, across);
|
|
23
|
+
return {
|
|
24
|
+
first: Math.min(lines.first * width, count),
|
|
25
|
+
last: Math.min(lines.last * width, count),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -46,13 +46,20 @@ export interface VirtualListRange {
|
|
|
46
46
|
*
|
|
47
47
|
* Rows are your markup in the light DOM, so your stylesheet styles them.
|
|
48
48
|
*
|
|
49
|
+
* **A grid.** `columns` lays the items out that many to a line, as a grid of
|
|
50
|
+
* equal columns, and windows the set a line at a time, as React Aria's grid
|
|
51
|
+
* layout does. Each item draws one element, a cell of the grid, and
|
|
52
|
+
* `estimate` is the height of a line. Space the items with padding inside
|
|
53
|
+
* each one, which the list measures with the line.
|
|
54
|
+
*
|
|
49
55
|
* **Keyboard.** The list is one tab stop.
|
|
50
56
|
*
|
|
51
57
|
* | Key | What it does |
|
|
52
58
|
* |---|---|
|
|
53
|
-
* | Down, Up | Moves to the next or the previous item. |
|
|
59
|
+
* | Down, Up | Moves to the next or the previous item, or in a grid to the item in the same column on the next or the previous line. |
|
|
60
|
+
* | Right, Left | In a grid, moves to the next or the previous item along the line, the other way round on a right-to-left page. |
|
|
54
61
|
* | Home, End | Moves to the first or the last item. |
|
|
55
|
-
* | Page Down, Page Up | Moves by the number of items on screen. |
|
|
62
|
+
* | Page Down, Page Up | Moves by the number of items, or of lines in a grid, on screen. |
|
|
56
63
|
* | A letter or a word | Moves to the next item whose text starts with what you typed. |
|
|
57
64
|
* | Tab | Moves into the focused row's own links and buttons, then out of the list. |
|
|
58
65
|
*
|
|
@@ -68,7 +75,7 @@ export interface VirtualListRange {
|
|
|
68
75
|
*
|
|
69
76
|
* **Selecting.** `selection-mode` makes the list a list box a reader chooses
|
|
70
77
|
* from: `single` selects one item and `multiple` any number. Space or a press
|
|
71
|
-
* selects an item, Shift with Space,
|
|
78
|
+
* selects an item, Shift with Space, an arrow, Home, End or a press takes in
|
|
72
79
|
* the items from the last one chosen, and Control or Command with A selects
|
|
73
80
|
* them all, in `multiple`. `value` holds the chosen items' keys, separated by
|
|
74
81
|
* commas, in the order of the set: `key-field` names each item's key, and a
|
|
@@ -116,6 +123,12 @@ export interface VirtualListRange {
|
|
|
116
123
|
* @csspart viewport - The scrolling box. On this tier, it needs only a block size.
|
|
117
124
|
*/
|
|
118
125
|
export declare class HelixHeadlessVirtualList extends HelixElement {
|
|
126
|
+
/**
|
|
127
|
+
* How many items a line holds. One, the default, is a list; more lays the
|
|
128
|
+
* items out as a grid of that many equal columns, windowed a line at a
|
|
129
|
+
* time, with Left and Right moving along a line.
|
|
130
|
+
*/
|
|
131
|
+
columns: number;
|
|
119
132
|
/**
|
|
120
133
|
* The height of one row, in pixels, used to find the row at a scroll offset.
|
|
121
134
|
*
|
|
@@ -247,6 +260,10 @@ export declare class HelixHeadlessVirtualList extends HelixElement {
|
|
|
247
260
|
* box to measure.
|
|
248
261
|
*/
|
|
249
262
|
get range(): VirtualListRange;
|
|
263
|
+
/** How many items a line holds: `columns`, at least one. */
|
|
264
|
+
private get across();
|
|
265
|
+
/** The items a span of lines holds. */
|
|
266
|
+
private itemsOn;
|
|
250
267
|
/**
|
|
251
268
|
* Scrolls the list to show the item at `index`.
|
|
252
269
|
*
|
|
@@ -267,6 +284,11 @@ export declare class HelixHeadlessVirtualList extends HelixElement {
|
|
|
267
284
|
* window moved.
|
|
268
285
|
*/
|
|
269
286
|
private drawn;
|
|
287
|
+
/**
|
|
288
|
+
* The drawn lines, for the controller to measure: each row in a list, and
|
|
289
|
+
* the first item of each line in a grid, whose cell is as tall as its line.
|
|
290
|
+
*/
|
|
291
|
+
private lines;
|
|
270
292
|
/**
|
|
271
293
|
* Reads the source named by `for`, before the render that draws it.
|
|
272
294
|
*
|
|
@@ -4,16 +4,17 @@ 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, commaList, customElement, elementById,
|
|
7
|
+
import { AriaForwardController, anchorAt, commaList, customElement, elementById, HelixElement, HelixLoadMoreEvent, HelixRangeChangeEvent, inRowOrder, isRtl, pressedOwnControl, rangeAdd, requestValue, searchableById, selectsAll, Typeahead, toggleValue, typesCharacter, VirtualizeController, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html, nothing, render } from 'lit';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
10
|
import { holdControls, releaseControls } from '../controls.js';
|
|
11
|
-
import { fillHoles,
|
|
11
|
+
import { fillHoles, keyOf, textsOf } from '../fill.js';
|
|
12
12
|
import { stepIndex } from '../keys.js';
|
|
13
|
-
import { drawPlan, stopAfter } from '../plan.js';
|
|
13
|
+
import { drawPlan, itemsOf, stopAfter } from '../plan.js';
|
|
14
14
|
let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixElement {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
|
+
this.columns = 1;
|
|
17
18
|
this.estimate = 32;
|
|
18
19
|
this.for = '';
|
|
19
20
|
this.keyField = '';
|
|
@@ -34,10 +35,10 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
34
35
|
});
|
|
35
36
|
this.virtualize = new VirtualizeController(this, {
|
|
36
37
|
container: () => this.partNamed('viewport'),
|
|
37
|
-
count: () => this.data.length,
|
|
38
|
+
count: () => Math.ceil(this.data.length / this.across),
|
|
38
39
|
estimate: () => this.estimate,
|
|
39
40
|
measured: () => this.measured,
|
|
40
|
-
rows: () => this.
|
|
41
|
+
rows: () => this.lines(),
|
|
41
42
|
});
|
|
42
43
|
this.handleKeydown = (event) => {
|
|
43
44
|
if (event.defaultPrevented) {
|
|
@@ -57,7 +58,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
57
58
|
}
|
|
58
59
|
const toggle = event.ctrlKey || event.metaKey;
|
|
59
60
|
if (this.selectionMode && !event.altKey) {
|
|
60
|
-
if (
|
|
61
|
+
if (selectsAll(event) && this.selectionMode === 'multiple') {
|
|
61
62
|
event.preventDefault();
|
|
62
63
|
this.choose(this.keys().join(','));
|
|
63
64
|
return;
|
|
@@ -73,7 +74,10 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
76
|
const { first, last } = this.virtualize.visible();
|
|
76
|
-
const next = stepIndex(event.key, at, this.data.length, last - first - 1
|
|
77
|
+
const next = stepIndex(event.key, at, this.data.length, last - first - 1, {
|
|
78
|
+
across: this.across,
|
|
79
|
+
forward: isRtl(this) ? 'ArrowLeft' : 'ArrowRight',
|
|
80
|
+
});
|
|
77
81
|
if (next === undefined) {
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
@@ -94,9 +98,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
94
98
|
if (at === undefined) {
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
97
|
-
|
|
98
|
-
if (inner.some((node) => node instanceof HTMLElement &&
|
|
99
|
-
node.matches('a[href], button, input, select, textarea, label'))) {
|
|
101
|
+
if (pressedOwnControl(event, row, 'a[href], button, input, select, textarea, label')) {
|
|
100
102
|
return;
|
|
101
103
|
}
|
|
102
104
|
this.press(at, event.shiftKey && this.selectionMode === 'multiple');
|
|
@@ -117,14 +119,21 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
117
119
|
};
|
|
118
120
|
}
|
|
119
121
|
get range() {
|
|
120
|
-
return this.virtualize.visible();
|
|
122
|
+
return this.itemsOn(this.virtualize.visible());
|
|
123
|
+
}
|
|
124
|
+
get across() {
|
|
125
|
+
return Math.max(1, Math.trunc(this.columns) || 1);
|
|
126
|
+
}
|
|
127
|
+
itemsOn(lines) {
|
|
128
|
+
return itemsOf(lines, this.across, this.data.length);
|
|
121
129
|
}
|
|
122
130
|
scrollToIndex(index, options = {}) {
|
|
123
131
|
const count = this.data.length;
|
|
124
132
|
if (count === 0 || !Number.isFinite(index)) {
|
|
125
133
|
return;
|
|
126
134
|
}
|
|
127
|
-
|
|
135
|
+
const at = Math.max(0, Math.min(Math.trunc(index), count - 1));
|
|
136
|
+
this.virtualize.reveal(Math.floor(at / this.across), 0, options);
|
|
128
137
|
this.virtualize.measure();
|
|
129
138
|
}
|
|
130
139
|
get data() {
|
|
@@ -136,6 +145,15 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
136
145
|
index: Number(element.dataset.index),
|
|
137
146
|
}));
|
|
138
147
|
}
|
|
148
|
+
lines() {
|
|
149
|
+
const across = this.across;
|
|
150
|
+
const drawn = this.drawn();
|
|
151
|
+
return across === 1
|
|
152
|
+
? drawn
|
|
153
|
+
: drawn
|
|
154
|
+
.filter(({ index }) => index % across === 0)
|
|
155
|
+
.map(({ element, index }) => ({ element, index: index / across }));
|
|
156
|
+
}
|
|
139
157
|
willUpdate(changed) {
|
|
140
158
|
super.willUpdate(changed);
|
|
141
159
|
if (this.readFor !== this.for && searchableById(this) && !this.hydrating) {
|
|
@@ -205,7 +223,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
205
223
|
}
|
|
206
224
|
}
|
|
207
225
|
report() {
|
|
208
|
-
const { first, last } = this.
|
|
226
|
+
const { first, last } = this.range;
|
|
209
227
|
if (first !== this.said.first || last !== this.said.last) {
|
|
210
228
|
this.said = { first, last };
|
|
211
229
|
this.dispatchEvent(new HelixRangeChangeEvent({ first, last }));
|
|
@@ -220,9 +238,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
220
238
|
?.content.querySelector('[data-field]')
|
|
221
239
|
?.getAttribute('data-field') ||
|
|
222
240
|
'';
|
|
223
|
-
return this.data
|
|
224
|
-
? textOf(item)
|
|
225
|
-
: textOf(valueAt(item, field)));
|
|
241
|
+
return textsOf(this.data, field);
|
|
226
242
|
}
|
|
227
243
|
indexOf(node) {
|
|
228
244
|
if (!(node instanceof HTMLElement) || node.parentElement !== this) {
|
|
@@ -235,11 +251,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
235
251
|
return this.querySelector(`:scope > [data-index="${index}"]`);
|
|
236
252
|
}
|
|
237
253
|
keyAt(at) {
|
|
238
|
-
|
|
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);
|
|
254
|
+
return keyOf(this.data[at], at, this.keyField);
|
|
243
255
|
}
|
|
244
256
|
keys() {
|
|
245
257
|
return this.data.map((_, at) => this.keyAt(at));
|
|
@@ -256,8 +268,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
256
268
|
const now = commaList(this.value);
|
|
257
269
|
if (extend && mode === 'multiple') {
|
|
258
270
|
const keys = this.keys();
|
|
259
|
-
const
|
|
260
|
-
const range = rangeAdd(now, keys, from, at);
|
|
271
|
+
const range = rangeAdd(now, keys, anchorAt(keys, this.anchor, at).anchor, at);
|
|
261
272
|
if (range) {
|
|
262
273
|
this.choose(this.inOrder(range));
|
|
263
274
|
}
|
|
@@ -271,29 +282,20 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
271
282
|
this.choose(this.inOrder(toggleValue(now, key)));
|
|
272
283
|
}
|
|
273
284
|
inOrder(keys) {
|
|
274
|
-
|
|
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(',');
|
|
285
|
+
return inRowOrder(keys, this.keys()).join(',');
|
|
278
286
|
}
|
|
279
287
|
choose(next) {
|
|
280
288
|
if (next === this.value) {
|
|
281
289
|
return;
|
|
282
290
|
}
|
|
283
|
-
|
|
284
|
-
|
|
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
|
+
requestValue(this, next, (value) => {
|
|
292
|
+
this.value = value;
|
|
291
293
|
});
|
|
292
294
|
}
|
|
293
295
|
async focusIndex(index) {
|
|
294
296
|
this.active = index;
|
|
295
297
|
this.focusing = index;
|
|
296
|
-
this.virtualize.reveal(index);
|
|
298
|
+
this.virtualize.reveal(Math.floor(index / this.across));
|
|
297
299
|
this.virtualize.measure();
|
|
298
300
|
this.requestUpdate();
|
|
299
301
|
try {
|
|
@@ -315,7 +317,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
315
317
|
}
|
|
316
318
|
keptIndex() {
|
|
317
319
|
const index = this.focusing ?? this.focusedIndex();
|
|
318
|
-
const { first, last } = this.virtualize.window;
|
|
320
|
+
const { first, last } = this.itemsOn(this.virtualize.window);
|
|
319
321
|
return index !== undefined && index < this.data.length && (index < first || index >= last)
|
|
320
322
|
? index
|
|
321
323
|
: undefined;
|
|
@@ -363,9 +365,10 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
363
365
|
return;
|
|
364
366
|
}
|
|
365
367
|
const count = this.data.length;
|
|
366
|
-
const { first, last } = this.virtualize.window;
|
|
368
|
+
const { first, last } = this.itemsOn(this.virtualize.window);
|
|
367
369
|
const children = [...this.children].filter((child) => child !== template && child instanceof HTMLElement && !child.hasAttribute('slot'));
|
|
368
370
|
const plan = drawPlan({
|
|
371
|
+
across: this.across,
|
|
369
372
|
count,
|
|
370
373
|
drawn: children.map((child) => Number(child.dataset.index)),
|
|
371
374
|
first,
|
|
@@ -406,7 +409,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
406
409
|
count,
|
|
407
410
|
first,
|
|
408
411
|
last,
|
|
409
|
-
onScreen: this.
|
|
412
|
+
onScreen: this.range.first,
|
|
410
413
|
});
|
|
411
414
|
const chosen = this.chosen;
|
|
412
415
|
for (const [at, group] of drawn) {
|
|
@@ -425,7 +428,9 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
425
428
|
this.released = this.active;
|
|
426
429
|
}
|
|
427
430
|
render() {
|
|
428
|
-
const
|
|
431
|
+
const kept = this.hasUpdated ? this.keptIndex() : undefined;
|
|
432
|
+
const { after, before } = this.virtualize.spacers(kept === undefined ? undefined : Math.floor(kept / this.across));
|
|
433
|
+
const across = this.across;
|
|
429
434
|
return html `<div
|
|
430
435
|
data-scroller
|
|
431
436
|
part="viewport"
|
|
@@ -439,7 +444,11 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
439
444
|
}}
|
|
440
445
|
>
|
|
441
446
|
<div part="before" style="block-size: ${before}px"></div>
|
|
442
|
-
<slot
|
|
447
|
+
<slot
|
|
448
|
+
style=${across === 1
|
|
449
|
+
? nothing
|
|
450
|
+
: `display: grid; grid-template-columns: repeat(${across}, minmax(0, 1fr))`}
|
|
451
|
+
></slot>
|
|
443
452
|
<div part="after" style="block-size: ${after}px"></div>
|
|
444
453
|
${this.loading
|
|
445
454
|
? html `<div part="loading" role=${this.selectionMode ? 'option' : 'listitem'}>
|
|
@@ -449,6 +458,9 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
|
|
|
449
458
|
</div>`;
|
|
450
459
|
}
|
|
451
460
|
};
|
|
461
|
+
__decorate([
|
|
462
|
+
property({ type: Number })
|
|
463
|
+
], HelixHeadlessVirtualList.prototype, "columns", void 0);
|
|
452
464
|
__decorate([
|
|
453
465
|
property({ type: Number })
|
|
454
466
|
], HelixHeadlessVirtualList.prototype, "estimate", void 0);
|