@getflip/swirl-components 0.533.0 → 0.534.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/components.json +158 -1
- package/dist/cjs/index-D-n4TKMG.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{media-query.service-B8u-DqoO.js → media-query.service-C1jMjjiy.js} +1 -1
- package/dist/cjs/swirl-action-list_2.cjs.entry.js +2 -2
- package/dist/cjs/swirl-app-layout.cjs.entry.js +2 -2
- package/dist/cjs/swirl-autocomplete.cjs.entry.js +1 -1
- package/dist/cjs/swirl-banner.cjs.entry.js +2 -2
- package/dist/cjs/swirl-button.cjs.entry.js +2 -2
- package/dist/cjs/swirl-carousel.cjs.entry.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-console-layout.cjs.entry.js +1 -1
- package/dist/cjs/swirl-date-input.cjs.entry.js +2 -2
- package/dist/cjs/swirl-date-picker_2.cjs.entry.js +1 -1
- package/dist/cjs/swirl-file-chip.cjs.entry.js +1 -1
- package/dist/cjs/swirl-file-viewer-audio_7.cjs.entry.js +1 -1
- package/dist/cjs/swirl-file-viewer_7.cjs.entry.js +1 -1
- package/dist/cjs/swirl-form-control.cjs.entry.js +1 -1
- package/dist/cjs/swirl-icon-check-small_3.cjs.entry.js +2 -2
- package/dist/cjs/swirl-icon-error_3.cjs.entry.js +2 -2
- package/dist/cjs/swirl-image-grid-item.cjs.entry.js +1 -1
- package/dist/cjs/swirl-inline-status.cjs.entry.js +2 -2
- package/dist/cjs/swirl-lightbox.cjs.entry.js +1 -1
- package/dist/cjs/swirl-menu-item.cjs.entry.js +1 -1
- package/dist/cjs/swirl-menu.cjs.entry.js +1 -1
- package/dist/cjs/swirl-modal.cjs.entry.js +1 -1
- package/dist/cjs/swirl-option-list.cjs.entry.js +1 -1
- package/dist/cjs/swirl-pagination.cjs.entry.js +1 -1
- package/dist/cjs/swirl-pdf-reader.cjs.entry.js +1 -1
- package/dist/cjs/swirl-popover_2.cjs.entry.js +1 -1
- package/dist/cjs/swirl-resource-list-file-item.cjs.entry.js +2 -2
- package/dist/cjs/swirl-resource-list-item.cjs.entry.js +2 -2
- package/dist/cjs/swirl-search.cjs.entry.js +2 -2
- package/dist/cjs/swirl-select.cjs.entry.js +1 -1
- package/dist/cjs/swirl-shell-layout.cjs.entry.js +1 -1
- package/dist/cjs/swirl-tab-bar.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table-column.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table-row.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table.cjs.entry.js +2287 -2
- package/dist/cjs/swirl-tabs.cjs.entry.js +1 -1
- package/dist/cjs/swirl-text-input.cjs.entry.js +2 -2
- package/dist/cjs/swirl-time-input.cjs.entry.js +2 -2
- package/dist/cjs/swirl-toast.cjs.entry.js +2 -2
- package/dist/cjs/swirl-toolbar.cjs.entry.js +1 -1
- package/dist/cjs/swirl-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/{utils-UfZG-xPD.js → utils-C4tLdXqU.js} +33 -0
- package/dist/collection/components/swirl-table/swirl-table-virtualizer.js +224 -0
- package/dist/collection/components/swirl-table/swirl-table.js +253 -2
- package/dist/collection/components/swirl-table/swirl-table.stories.js +190 -0
- package/dist/collection/utils.js +32 -0
- package/dist/components/media-query.service.js +1 -1
- package/dist/components/swirl-file-viewer-pdf2.js +1 -1
- package/dist/components/swirl-popover2.js +1 -1
- package/dist/components/swirl-tab-bar2.js +1 -1
- package/dist/components/swirl-table.js +1 -1
- package/dist/components/swirl-tabs.js +1 -1
- package/dist/components/swirl-tooltip2.js +1 -1
- package/dist/components/utils.js +1 -1
- package/dist/esm/index-Dz56lJ37.js +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{media-query.service-CCYT6DU8.js → media-query.service-Bbqqduao.js} +1 -1
- package/dist/esm/swirl-action-list_2.entry.js +2 -2
- package/dist/esm/swirl-app-layout.entry.js +2 -2
- package/dist/esm/swirl-autocomplete.entry.js +1 -1
- package/dist/esm/swirl-banner.entry.js +2 -2
- package/dist/esm/swirl-button.entry.js +2 -2
- package/dist/esm/swirl-carousel.entry.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-console-layout.entry.js +1 -1
- package/dist/esm/swirl-date-input.entry.js +2 -2
- package/dist/esm/swirl-date-picker_2.entry.js +1 -1
- package/dist/esm/swirl-file-chip.entry.js +1 -1
- package/dist/esm/swirl-file-viewer-audio_7.entry.js +1 -1
- package/dist/esm/swirl-file-viewer_7.entry.js +1 -1
- package/dist/esm/swirl-form-control.entry.js +1 -1
- package/dist/esm/swirl-icon-check-small_3.entry.js +2 -2
- package/dist/esm/swirl-icon-error_3.entry.js +2 -2
- package/dist/esm/swirl-image-grid-item.entry.js +1 -1
- package/dist/esm/swirl-inline-status.entry.js +2 -2
- package/dist/esm/swirl-lightbox.entry.js +1 -1
- package/dist/esm/swirl-menu-item.entry.js +1 -1
- package/dist/esm/swirl-menu.entry.js +1 -1
- package/dist/esm/swirl-modal.entry.js +1 -1
- package/dist/esm/swirl-option-list.entry.js +1 -1
- package/dist/esm/swirl-pagination.entry.js +1 -1
- package/dist/esm/swirl-pdf-reader.entry.js +1 -1
- package/dist/esm/swirl-popover_2.entry.js +1 -1
- package/dist/esm/swirl-resource-list-file-item.entry.js +2 -2
- package/dist/esm/swirl-resource-list-item.entry.js +2 -2
- package/dist/esm/swirl-search.entry.js +2 -2
- package/dist/esm/swirl-select.entry.js +1 -1
- package/dist/esm/swirl-shell-layout.entry.js +1 -1
- package/dist/esm/swirl-tab-bar.entry.js +1 -1
- package/dist/esm/swirl-table-column.entry.js +1 -1
- package/dist/esm/swirl-table-row.entry.js +1 -1
- package/dist/esm/swirl-table.entry.js +2288 -3
- package/dist/esm/swirl-tabs.entry.js +1 -1
- package/dist/esm/swirl-text-input.entry.js +2 -2
- package/dist/esm/swirl-time-input.entry.js +2 -2
- package/dist/esm/swirl-toast.entry.js +2 -2
- package/dist/esm/swirl-toolbar.entry.js +1 -1
- package/dist/esm/swirl-tooltip.entry.js +1 -1
- package/dist/esm/{utils-CCck-DTo.js → utils-D23VxAsw.js} +33 -1
- package/dist/swirl-components/p-0cb6bbde.entry.js +1 -0
- package/dist/swirl-components/{p-ea6bdee5.entry.js → p-20354a36.entry.js} +1 -1
- package/dist/swirl-components/{p-8d078f8a.entry.js → p-247ada6e.entry.js} +1 -1
- package/dist/swirl-components/{p-270be9f2.entry.js → p-29fed244.entry.js} +1 -1
- package/dist/swirl-components/{p-c924fc96.entry.js → p-437ac2fa.entry.js} +1 -1
- package/dist/swirl-components/{p-97deaddc.entry.js → p-48c1b8e4.entry.js} +1 -1
- package/dist/swirl-components/{p-40be5fde.entry.js → p-48c559a4.entry.js} +1 -1
- package/dist/swirl-components/p-4a1d3582.entry.js +1 -0
- package/dist/swirl-components/{p-ad4fd14f.entry.js → p-5c6fc0bc.entry.js} +1 -1
- package/dist/swirl-components/{p-73a8e8a0.entry.js → p-6242f9bb.entry.js} +1 -1
- package/dist/swirl-components/{p-0c0acfd3.entry.js → p-641bb5b1.entry.js} +1 -1
- package/dist/swirl-components/{p-993dae75.entry.js → p-6528e39b.entry.js} +1 -1
- package/dist/swirl-components/{p-b45902de.entry.js → p-6785b8a5.entry.js} +1 -1
- package/dist/swirl-components/{p-dcf08d9a.entry.js → p-692dd291.entry.js} +1 -1
- package/dist/swirl-components/{p-418a8b7b.entry.js → p-6e0825ae.entry.js} +1 -1
- package/dist/swirl-components/{p-22931b7b.entry.js → p-71e1f20d.entry.js} +1 -1
- package/dist/swirl-components/{p-f015fc2d.entry.js → p-78af0765.entry.js} +1 -1
- package/dist/swirl-components/{p-2ddf4a93.entry.js → p-7a9bb681.entry.js} +1 -1
- package/dist/swirl-components/{p-b36ee49f.entry.js → p-84cfb27a.entry.js} +1 -1
- package/dist/swirl-components/{p-c6bceca5.entry.js → p-91b316f9.entry.js} +1 -1
- package/dist/swirl-components/{p-da6fa0fa.entry.js → p-958aa736.entry.js} +1 -1
- package/dist/swirl-components/{p-fbdb4aff.entry.js → p-95d6d7ad.entry.js} +1 -1
- package/dist/swirl-components/{p-577174d9.entry.js → p-984c4d86.entry.js} +1 -1
- package/dist/swirl-components/{p-CCck-DTo.js → p-D23VxAsw.js} +1 -1
- package/dist/swirl-components/{p-Bfn7CHM9.js → p-_iAIu_AF.js} +1 -1
- package/dist/swirl-components/{p-d0275263.entry.js → p-a11ba0b5.entry.js} +1 -1
- package/dist/swirl-components/{p-1bf78baf.entry.js → p-ae978c57.entry.js} +1 -1
- package/dist/swirl-components/{p-95a403cf.entry.js → p-b08aa57d.entry.js} +1 -1
- package/dist/swirl-components/{p-26362ab2.entry.js → p-bb4c80bf.entry.js} +1 -1
- package/dist/swirl-components/{p-e63650e3.entry.js → p-c182f4c1.entry.js} +1 -1
- package/dist/swirl-components/{p-d763ce05.entry.js → p-c4dad69d.entry.js} +1 -1
- package/dist/swirl-components/{p-47b02bc4.entry.js → p-cf855c44.entry.js} +1 -1
- package/dist/swirl-components/{p-fbcc5141.entry.js → p-d26aa1e7.entry.js} +1 -1
- package/dist/swirl-components/{p-3340670b.entry.js → p-d298c94c.entry.js} +1 -1
- package/dist/swirl-components/{p-9ad61433.entry.js → p-d8924470.entry.js} +1 -1
- package/dist/swirl-components/{p-268ddaee.entry.js → p-dab890a1.entry.js} +2 -2
- package/dist/swirl-components/{p-3e6fb027.entry.js → p-de5a7b4a.entry.js} +1 -1
- package/dist/swirl-components/p-ea36e3ec.entry.js +1 -0
- package/dist/swirl-components/{p-96c9486a.entry.js → p-eb297822.entry.js} +1 -1
- package/dist/swirl-components/{p-bee027a0.entry.js → p-ec10ca71.entry.js} +1 -1
- package/dist/swirl-components/{p-94e6a907.entry.js → p-f6c37730.entry.js} +1 -1
- package/dist/swirl-components/{p-b581b1e6.entry.js → p-fd188df6.entry.js} +1 -1
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-table/swirl-table-virtualizer.d.ts +60 -0
- package/dist/types/components/swirl-table/swirl-table.d.ts +43 -0
- package/dist/types/components/swirl-table/swirl-table.stories.d.ts +2 -0
- package/dist/types/components.d.ts +57 -2
- package/dist/types/utils.d.ts +12 -0
- package/package.json +2 -1
- package/vscode-data.json +16 -0
- package/dist/swirl-components/p-0c0b46e1.entry.js +0 -1
- package/dist/swirl-components/p-2943bc69.entry.js +0 -1
- package/dist/swirl-components/p-5fa1c77c.entry.js +0 -1
|
@@ -5,6 +5,10 @@ export type SwirlTableDropRowEvent = Pick<SortableEvent, "oldIndex" | "newIndex"
|
|
|
5
5
|
newNextSiblingItemId: string | undefined;
|
|
6
6
|
newPrevSiblingItemId: string | undefined;
|
|
7
7
|
};
|
|
8
|
+
export type SwirlTableVirtualizationRows = {
|
|
9
|
+
/** 0-based indexes of the rows to render, in ascending order. */
|
|
10
|
+
indexes: number[];
|
|
11
|
+
};
|
|
8
12
|
/**
|
|
9
13
|
* @slot columns - Column container, should contain SwirlTableColumns.
|
|
10
14
|
* @slot rows - Row container, should contain SwirlTableRows.
|
|
@@ -24,7 +28,27 @@ export declare class SwirlTable {
|
|
|
24
28
|
enableDragDrop?: boolean;
|
|
25
29
|
label: string;
|
|
26
30
|
loading?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Draws only the rows near the visible area. Render the rows from
|
|
33
|
+
* `virtualizationRowsChange`, each with its 0-based index in `data-index`.
|
|
34
|
+
* Requires `virtualizationRowCount`. Doesn't work with drag & drop or row
|
|
35
|
+
* groups.
|
|
36
|
+
*/
|
|
37
|
+
enableVirtualization?: boolean;
|
|
38
|
+
/** Total number of rows when virtualized. */
|
|
39
|
+
virtualizationRowCount?: number;
|
|
40
|
+
/** Height in px assumed for rows not drawn yet. */
|
|
41
|
+
virtualizationEstimatedRowHeight?: number;
|
|
42
|
+
/** Number of extra rows drawn above and below the visible ones. */
|
|
43
|
+
virtualizationOverscan?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Indexes of rows to keep drawn when out of view, e.g. a row with an open
|
|
46
|
+
* menu. The focused row is always kept.
|
|
47
|
+
*/
|
|
48
|
+
virtualizationKeepRowsRendered?: number[];
|
|
27
49
|
dropRow: EventEmitter<SwirlTableDropRowEvent>;
|
|
50
|
+
/** Emits the indexes of the rows to render. */
|
|
51
|
+
virtualizationRowsChange: EventEmitter<SwirlTableVirtualizationRows>;
|
|
28
52
|
empty: boolean;
|
|
29
53
|
liveRegionText: string;
|
|
30
54
|
scrollable: boolean;
|
|
@@ -40,8 +64,14 @@ export declare class SwirlTable {
|
|
|
40
64
|
private positionBeforeKeyboardMove?;
|
|
41
65
|
private rowMutationObserver;
|
|
42
66
|
private sortable;
|
|
67
|
+
private virtualizer;
|
|
68
|
+
private focusedRowIndex;
|
|
43
69
|
componentDidLoad(): Promise<void>;
|
|
44
70
|
disconnectedCallback(): void;
|
|
71
|
+
handleVirtualizationChange(): void;
|
|
72
|
+
private get virtualizerConfig();
|
|
73
|
+
private updateVirtualizer;
|
|
74
|
+
private destroyVirtualizer;
|
|
45
75
|
handleEnableDragDropChange(): void;
|
|
46
76
|
/**
|
|
47
77
|
* Set up an Intersection Observer to monitor when the table container becomes visible.
|
|
@@ -59,6 +89,11 @@ export declare class SwirlTable {
|
|
|
59
89
|
private stopRowMutationObserver;
|
|
60
90
|
private setupDragDrop;
|
|
61
91
|
private onVisibilityChange;
|
|
92
|
+
/**
|
|
93
|
+
* A table hidden on load falls back to the window. Look for the scroll
|
|
94
|
+
* container again once it is visible.
|
|
95
|
+
*/
|
|
96
|
+
private updateScrollParent;
|
|
62
97
|
componentDidRender(): Promise<void>;
|
|
63
98
|
onWindowResize(): Promise<void>;
|
|
64
99
|
/**
|
|
@@ -94,6 +129,14 @@ export declare class SwirlTable {
|
|
|
94
129
|
private onScroll;
|
|
95
130
|
private onFocus;
|
|
96
131
|
private onBlur;
|
|
132
|
+
/**
|
|
133
|
+
* Measures and positions rows after they were added, removed or re-indexed.
|
|
134
|
+
* The focused row's index is read again first, as it changes when e.g. a row
|
|
135
|
+
* is inserted above it.
|
|
136
|
+
*/
|
|
137
|
+
private syncVirtualizedRows;
|
|
138
|
+
/** Keeps the focused row drawn, so it doesn't lose focus. */
|
|
139
|
+
private trackFocusedRow;
|
|
97
140
|
private onKeyDown;
|
|
98
141
|
render(): any;
|
|
99
142
|
}
|
|
@@ -75,7 +75,7 @@ import { SwirlSymbolSize } from "./components/swirl-symbol/swirl-symbol.types";
|
|
|
75
75
|
import { SwirlTabBarJustify as SwirlTabBarJustify1, SwirlTabBarPadding as SwirlTabBarPadding1, SwirlTabBarTabBadge, SwirlTabBarVariant as SwirlTabBarVariant1 } from "./components/swirl-tab-bar/swirl-tab-bar";
|
|
76
76
|
import { SwirlTabPadding } from "./components/swirl-tab/swirl-tab";
|
|
77
77
|
import { SwirlTabBarJustify, SwirlTabBarPadding, SwirlTabBarTab, SwirlTabBarVariant } from "./components/swirl-tab-bar/swirl-tab-bar";
|
|
78
|
-
import { SwirlTableDropRowEvent } from "./components/swirl-table/swirl-table";
|
|
78
|
+
import { SwirlTableDropRowEvent, SwirlTableVirtualizationRows } from "./components/swirl-table/swirl-table";
|
|
79
79
|
import { SwirlTableColumnSort, SwirlTableColumnVariant } from "./components/swirl-table-column/swirl-table-column";
|
|
80
80
|
import { SwirlTagIconPosition, SwirlTagIntent, SwirlTagSize, SwirlTagVariant } from "./components/swirl-tag/swirl-tag";
|
|
81
81
|
import { SwirlTextAlign, SwirlTextColor, SwirlTextFontFamily, SwirlTextFontStyle, SwirlTextSize, SwirlTextTruncateDirection, SwirlTextWeight, SwirlTextWhiteSpace } from "./components/swirl-text/swirl-text";
|
|
@@ -160,7 +160,7 @@ export { SwirlSymbolSize } from "./components/swirl-symbol/swirl-symbol.types";
|
|
|
160
160
|
export { SwirlTabBarJustify as SwirlTabBarJustify1, SwirlTabBarPadding as SwirlTabBarPadding1, SwirlTabBarTabBadge, SwirlTabBarVariant as SwirlTabBarVariant1 } from "./components/swirl-tab-bar/swirl-tab-bar";
|
|
161
161
|
export { SwirlTabPadding } from "./components/swirl-tab/swirl-tab";
|
|
162
162
|
export { SwirlTabBarJustify, SwirlTabBarPadding, SwirlTabBarTab, SwirlTabBarVariant } from "./components/swirl-tab-bar/swirl-tab-bar";
|
|
163
|
-
export { SwirlTableDropRowEvent } from "./components/swirl-table/swirl-table";
|
|
163
|
+
export { SwirlTableDropRowEvent, SwirlTableVirtualizationRows } from "./components/swirl-table/swirl-table";
|
|
164
164
|
export { SwirlTableColumnSort, SwirlTableColumnVariant } from "./components/swirl-table-column/swirl-table-column";
|
|
165
165
|
export { SwirlTagIconPosition, SwirlTagIntent, SwirlTagSize, SwirlTagVariant } from "./components/swirl-tag/swirl-tag";
|
|
166
166
|
export { SwirlTextAlign, SwirlTextColor, SwirlTextFontFamily, SwirlTextFontStyle, SwirlTextSize, SwirlTextTruncateDirection, SwirlTextWeight, SwirlTextWhiteSpace } from "./components/swirl-text/swirl-text";
|
|
@@ -5455,12 +5455,35 @@ export namespace Components {
|
|
|
5455
5455
|
*/
|
|
5456
5456
|
"emptyStateLabel"?: string;
|
|
5457
5457
|
"enableDragDrop"?: boolean;
|
|
5458
|
+
/**
|
|
5459
|
+
* Draws only the rows near the visible area. Render the rows from `virtualizationRowsChange`, each with its 0-based index in `data-index`. Requires `virtualizationRowCount`. Doesn't work with drag & drop or row groups.
|
|
5460
|
+
*/
|
|
5461
|
+
"enableVirtualization"?: boolean;
|
|
5458
5462
|
"label": string;
|
|
5459
5463
|
"loading"?: boolean;
|
|
5460
5464
|
/**
|
|
5461
5465
|
* Force a re-render of the table
|
|
5462
5466
|
*/
|
|
5463
5467
|
"rerender": () => Promise<void>;
|
|
5468
|
+
/**
|
|
5469
|
+
* Height in px assumed for rows not drawn yet.
|
|
5470
|
+
* @default 56
|
|
5471
|
+
*/
|
|
5472
|
+
"virtualizationEstimatedRowHeight"?: number;
|
|
5473
|
+
/**
|
|
5474
|
+
* Indexes of rows to keep drawn when out of view, e.g. a row with an open menu. The focused row is always kept.
|
|
5475
|
+
* @default []
|
|
5476
|
+
*/
|
|
5477
|
+
"virtualizationKeepRowsRendered"?: number[];
|
|
5478
|
+
/**
|
|
5479
|
+
* Number of extra rows drawn above and below the visible ones.
|
|
5480
|
+
* @default 10
|
|
5481
|
+
*/
|
|
5482
|
+
"virtualizationOverscan"?: number;
|
|
5483
|
+
/**
|
|
5484
|
+
* Total number of rows when virtualized.
|
|
5485
|
+
*/
|
|
5486
|
+
"virtualizationRowCount"?: number;
|
|
5464
5487
|
}
|
|
5465
5488
|
interface SwirlTableCell {
|
|
5466
5489
|
}
|
|
@@ -9941,6 +9964,7 @@ declare global {
|
|
|
9941
9964
|
};
|
|
9942
9965
|
interface HTMLSwirlTableElementEventMap {
|
|
9943
9966
|
"dropRow": SwirlTableDropRowEvent;
|
|
9967
|
+
"virtualizationRowsChange": SwirlTableVirtualizationRows;
|
|
9944
9968
|
}
|
|
9945
9969
|
interface HTMLSwirlTableElement extends Components.SwirlTable, HTMLStencilElement {
|
|
9946
9970
|
addEventListener<K extends keyof HTMLSwirlTableElementEventMap>(type: K, listener: (this: HTMLSwirlTableElement, ev: SwirlTableCustomEvent<HTMLSwirlTableElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -15936,9 +15960,36 @@ declare namespace LocalJSX {
|
|
|
15936
15960
|
*/
|
|
15937
15961
|
"emptyStateLabel"?: string;
|
|
15938
15962
|
"enableDragDrop"?: boolean;
|
|
15963
|
+
/**
|
|
15964
|
+
* Draws only the rows near the visible area. Render the rows from `virtualizationRowsChange`, each with its 0-based index in `data-index`. Requires `virtualizationRowCount`. Doesn't work with drag & drop or row groups.
|
|
15965
|
+
*/
|
|
15966
|
+
"enableVirtualization"?: boolean;
|
|
15939
15967
|
"label": string;
|
|
15940
15968
|
"loading"?: boolean;
|
|
15941
15969
|
"onDropRow"?: (event: SwirlTableCustomEvent<SwirlTableDropRowEvent>) => void;
|
|
15970
|
+
/**
|
|
15971
|
+
* Emits the indexes of the rows to render.
|
|
15972
|
+
*/
|
|
15973
|
+
"onVirtualizationRowsChange"?: (event: SwirlTableCustomEvent<SwirlTableVirtualizationRows>) => void;
|
|
15974
|
+
/**
|
|
15975
|
+
* Height in px assumed for rows not drawn yet.
|
|
15976
|
+
* @default 56
|
|
15977
|
+
*/
|
|
15978
|
+
"virtualizationEstimatedRowHeight"?: number;
|
|
15979
|
+
/**
|
|
15980
|
+
* Indexes of rows to keep drawn when out of view, e.g. a row with an open menu. The focused row is always kept.
|
|
15981
|
+
* @default []
|
|
15982
|
+
*/
|
|
15983
|
+
"virtualizationKeepRowsRendered"?: number[];
|
|
15984
|
+
/**
|
|
15985
|
+
* Number of extra rows drawn above and below the visible ones.
|
|
15986
|
+
* @default 10
|
|
15987
|
+
*/
|
|
15988
|
+
"virtualizationOverscan"?: number;
|
|
15989
|
+
/**
|
|
15990
|
+
* Total number of rows when virtualized.
|
|
15991
|
+
*/
|
|
15992
|
+
"virtualizationRowCount"?: number;
|
|
15942
15993
|
}
|
|
15943
15994
|
interface SwirlTableCell {
|
|
15944
15995
|
}
|
|
@@ -19124,6 +19175,10 @@ declare namespace LocalJSX {
|
|
|
19124
19175
|
"enableDragDrop": boolean;
|
|
19125
19176
|
"label": string;
|
|
19126
19177
|
"loading": boolean;
|
|
19178
|
+
"enableVirtualization": boolean;
|
|
19179
|
+
"virtualizationRowCount": number;
|
|
19180
|
+
"virtualizationEstimatedRowHeight": number;
|
|
19181
|
+
"virtualizationOverscan": number;
|
|
19127
19182
|
}
|
|
19128
19183
|
interface SwirlTableColumnAttributes {
|
|
19129
19184
|
"variant": SwirlTableColumnVariant;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -53,3 +53,15 @@ export declare function isPdfMimeType(mimeType: string): boolean;
|
|
|
53
53
|
export declare function isCompressedArchiveMimeType(mimeType: string): boolean;
|
|
54
54
|
export declare function isDocumentMimeType(mimeType: string): boolean;
|
|
55
55
|
export declare function getPixelsFromRemToken(token: string): number;
|
|
56
|
+
/**
|
|
57
|
+
* Nearest vertically scrolling ancestor, also across shadow roots. Falls back
|
|
58
|
+
* to the window.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getScrollParent(el: HTMLElement): HTMLElement | Window;
|
|
61
|
+
/**
|
|
62
|
+
* Parent in the rendered (flat) tree: a slotted element's parent is its slot,
|
|
63
|
+
* not its light DOM parent, and a shadow root's top element's parent is the
|
|
64
|
+
* host. Unlike `closestPassShadow`, this finds ancestors inside the shadow
|
|
65
|
+
* root an element is slotted into.
|
|
66
|
+
*/
|
|
67
|
+
export declare function getFlatTreeParent(el: Element): Element | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getflip/swirl-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.534.0",
|
|
4
4
|
"description": "Swirl Design System Web Component Library",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@getflip/swirl-icons": "0.97.0",
|
|
48
48
|
"@getflip/swirl-tokens": "2.14.3",
|
|
49
49
|
"@stencil/core": "4.43.1",
|
|
50
|
+
"@tanstack/virtual-core": "3.19.10",
|
|
50
51
|
"a11y-dialog": "7.5.2",
|
|
51
52
|
"balance-text": "3.3.1",
|
|
52
53
|
"classnames": "2.3.1",
|
package/vscode-data.json
CHANGED
|
@@ -26113,6 +26113,10 @@
|
|
|
26113
26113
|
"name": "enable-drag-drop",
|
|
26114
26114
|
"description": ""
|
|
26115
26115
|
},
|
|
26116
|
+
{
|
|
26117
|
+
"name": "enable-virtualization",
|
|
26118
|
+
"description": "Draws only the rows near the visible area. Render the rows from\n`virtualizationRowsChange`, each with its 0-based index in `data-index`.\nRequires `virtualizationRowCount`. Doesn't work with drag & drop or row\ngroups."
|
|
26119
|
+
},
|
|
26116
26120
|
{
|
|
26117
26121
|
"name": "label",
|
|
26118
26122
|
"description": ""
|
|
@@ -26120,6 +26124,18 @@
|
|
|
26120
26124
|
{
|
|
26121
26125
|
"name": "loading",
|
|
26122
26126
|
"description": ""
|
|
26127
|
+
},
|
|
26128
|
+
{
|
|
26129
|
+
"name": "virtualization-estimated-row-height",
|
|
26130
|
+
"description": "Height in px assumed for rows not drawn yet."
|
|
26131
|
+
},
|
|
26132
|
+
{
|
|
26133
|
+
"name": "virtualization-overscan",
|
|
26134
|
+
"description": "Number of extra rows drawn above and below the visible ones."
|
|
26135
|
+
},
|
|
26136
|
+
{
|
|
26137
|
+
"name": "virtualization-row-count",
|
|
26138
|
+
"description": "Total number of rows when virtualized."
|
|
26123
26139
|
}
|
|
26124
26140
|
]
|
|
26125
26141
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,h as s,a as i,d as a}from"./p-Dz56lJ37.js";import{g as o,c as r}from"./p-orsBiyT_.js";import{S as l}from"./p-CMrz6687.js";import{d as n,i as h,q as c}from"./p-CCck-DTo.js";var d,b,w=o((b||(b=1,d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=void 0,a=void 0,o=void 0,r=[];return function(){var n=function(t){return"function"==typeof t?t():t}(e),h=(new Date).getTime(),c=!i||h-i>n;i=h;for(var d=arguments.length,b=Array(d),w=0;w<d;w++)b[w]=arguments[w];if(c&&s.leading)return s.accumulate?Promise.resolve(t.call(this,[b])).then((function(t){return t[0]})):Promise.resolve(t.call.apply(t,[this].concat(b)));if(a?clearTimeout(o):a=function(){var t={};return t.promise=new Promise((function(e,s){t.resolve=e,t.reject=s})),t}(),r.push(b),o=setTimeout(l.bind(this),n),s.accumulate){var u=r.length-1;return a.promise.then((function(t){return t[u]}))}return a.promise};function l(){var e=a;clearTimeout(o),Promise.resolve(s.accumulate?t.call(this,r):t.apply(this,r[r.length-1])).then(e.resolve,e.reject),r=[],a=null}}),d));const u={end:"Dropped. Final position in table: {position} of {rowCount}.",initial:"Press space to move the row.",moved:"Current position in table: {position} of {rowCount}.",start:"Row grabbed. Current position in table: {position} of {rowCount}. Press up and down arrow keys to change position, Space to drop."},p=class{constructor(s){t(this,s),this.dropRow=e(this,"dropRow",7),this.dragDropInstructions=u,this.emptyStateLabel="No results found.",this.liveRegionText="",this.triggerRerender=n((async()=>{await this.updateLayout(),this.updateEmptyState()}),0,!0),this.updateLayout=w((async()=>{this.resetCellStyles(),this.resetColumnStyles(),this.resetEmptyRowStyles(),this.resetRowGroupStyles(),this.layoutEmptyRow(),this.layoutRowGroups(),this.layOutCellsAndColumns(),this.updateScrolledState()}),16,{leading:!0}),this.onScroll=()=>{this.updateScrolledState()},this.onFocus=t=>{if(this.movingViaKeyboard){const t=this.el.querySelector(".table-row--moving");t&&this.focusDragHandleOfRow(t)}const e=!!t.target?.closest(this.dragDropHandle);""===this.liveRegionText&&e&&this.updateLiveRegionText("initial")},this.onBlur=t=>{const e=t.relatedTarget,s=!!e?.closest(this.dragDropHandle);this.el.contains(e)&&s||""!==this.liveRegionText&&this.updateLiveRegionText()},this.onKeyDown=t=>{if(!this.enableDragDrop)return;const e=t.target?.closest("swirl-table-row");t.target?.closest(this.dragDropHandle)&&("Space"===t.code?(t.preventDefault(),t.stopPropagation(),this.toggleKeyboardMove(e)):"ArrowUp"===t.code?(t.preventDefault(),t.stopPropagation(),this.moveRow(e,"up")):"ArrowDown"===t.code?(t.preventDefault(),t.stopPropagation(),this.moveRow(e,"down")):"Escape"===t.code&&(t.preventDefault(),t.stopPropagation(),this.cancelKeyboardMove()))}}async componentDidLoad(){this.setupIntersectionObserver(),this.setupMutationObservers(),queueMicrotask((()=>{this.setupDragDrop()}))}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.columnMutationObserver?.disconnect(),this.rowMutationObserver?.disconnect(),this.sortable?.destroy()}handleEnableDragDropChange(){queueMicrotask((()=>{this.setupDragDrop()}))}setupIntersectionObserver(){this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange.bind(this),{threshold:0}),this.intersectionObserver.observe(this.container)}setupMutationObservers(){this.columnMutationObserver=new MutationObserver((t=>{t.some((t=>t.addedNodes.length||t.removedNodes.length))&&this.updateLayout()})),this.columnMutationObserver.observe(this.headerEl,{childList:!0,subtree:!0}),this.rowMutationObserver=new MutationObserver((t=>{t.some((t=>t.addedNodes.length||t.removedNodes.length))&&(this.updateEmptyState(),this.setupDragDrop())})),this.startRowMutationObserver()}startRowMutationObserver(){this.rowMutationObserver?.observe(this.bodyEl,{childList:!0,subtree:!0})}stopRowMutationObserver(){this.rowMutationObserver?.disconnect()}setupDragDrop(){if(this.sortable&&(this.sortable.destroy(),this.sortable=void 0),this.enableDragDrop){if(this.el.querySelector("swirl-table-row-group"))return void console.warn('[Swirl] Drag & drop is not yet supported for swirl-tables using the "swirl-table-row-group" component.');if(!this.dragDropHandle)return void console.warn('[Swirl] swirl-table required the "dragDropHandle" prop to be set when drag & drop is enabled.');const t=this.el.querySelector('[slot="rows"]');this.dragDropContainer="SWIRL-TABLE-ROW"!==t?.tagName?t??this.bodyEl:this.bodyEl,this.sortable=new l(this.dragDropContainer,{animation:100,direction:"vertical",handle:this.dragDropHandle,fallbackOnBody:!0,group:`swirl-table-${Math.random().toString().substring(2)}`,onStart:()=>{this.stopRowMutationObserver()},onEnd:t=>{t.stopPropagation();const{to:e,newIndex:s,oldIndex:i,item:a}=t;this.dropRow.emit({newIndex:s,oldIndex:i,item:a,itemId:a.id??a.querySelector(":scope > swirl-table-row").id,newNextSiblingItemId:s<e.children.length-1?e.children[s+1].id:void 0,newPrevSiblingItemId:s>0?e.children[s-1].id:void 0}),this.startRowMutationObserver()}})}}async onVisibilityChange(t){t.some((t=>t.isIntersecting))&&setTimeout((async()=>{await this.updateLayout()}),100)}async componentDidRender(){await this.updateLayout(),this.updateEmptyState()}async onWindowResize(){await this.updateLayout()}async rerender(){this.triggerRerender()}resetEmptyRowStyles(){const t=this.el.querySelector(".table__empty-row");Boolean(t)&&(t.style.width="")}resetRowGroupStyles(){Array.from(this.el.querySelectorAll("swirl-table-row-group")).forEach((t=>{const e=t.shadowRoot.querySelector(".table-row-group__header-row");Boolean(e)&&(t.shadowRoot.querySelector(".table-row-group__header-row").style.width="")}))}resetColumnStyles(){this.getColumns().forEach((t=>{t.classList.remove("table-column--has-shadow","table-column--is-sticky","table-column--is-sticky-right"),t.style.right="",t.style.left="",t.style.position="",t.style.zIndex=""}))}resetCellStyles(){this.getCells().forEach((t=>{t.classList.remove("table-cell--has-shadow","table-cell--is-sticky","table-cell--is-sticky-right"),t.style.flex="",t.style.left="",t.style.right="",t.style.position="",t.style.zIndex=""}))}updateScrolledState(){const t=h();if(void 0===this.container)return;const e=this.container.scrollWidth>this.container.clientWidth,s=this.container.scrollLeft>0,i=Math.ceil(this.container.clientWidth+this.container.scrollLeft)>=Math.floor(this.container.scrollWidth);e!==this.scrollable&&(e&&!t?this.container.classList.add("table__container--scrollable"):this.container.classList.remove("table__container--scrollable")),s!==this.scrolled&&(s&&!t?this.container.classList.add("table__container--scrolled"):this.container.classList.remove("table__container--scrolled")),i!==this.scrolledToEnd&&(i&&!t?this.container.classList.add("table__container--scrolled-to-end"):this.container.classList.remove("table__container--scrolled-to-end"))}getColumns(){return Array.from(this.el.querySelectorAll("swirl-table-column"))}getCells(){return Array.from(this.el.querySelectorAll("swirl-table-cell"))}layoutEmptyRow(){const t=this.el.querySelector(".table__empty-row");if(!Boolean(t))return;const e=`${this.el.querySelector(".table__container").scrollWidth}px`;t.style.width=e}layoutRowGroups(){const t=Array.from(this.el.querySelectorAll("swirl-table-row-group")),e=`${this.el.querySelector(".table__container")?.scrollWidth}px`;t.forEach((t=>{const s=t.shadowRoot.querySelector(".table-row-group__header-row");Boolean(s)&&(t.shadowRoot.querySelector(".table-row-group__header-row").style.width=e)}))}layOutCellsAndColumns(){const t=this.getColumns(),e=this.getCells();t.forEach(((s,i)=>{const a=this.getCellsForColumn(e,t,i),o=this.calculateColumnProperties(s,t,i);a.forEach((t=>this.applyCellStyles(t,s,o))),this.applyColumnStyles(s,o)}))}getCellsForColumn(t,e,s){return t.filter(((t,i)=>(s-i)%e.length==0))}calculateColumnProperties(t,e,s){return{leftOffsetForStickyColumn:t.sticky?this.getLeftOffsetForStickyColumn(e,s):0,columnWidth:`${t.getBoundingClientRect().width}px`,isLastColumnSticky:t.sticky&&e.length===s+1,hasShadowRight:t.sticky&&!this.hasStickyColumnsToRight(e,s)}}applyCellStyles(t,e,s){const{leftOffsetForStickyColumn:i,columnWidth:a,isLastColumnSticky:o,hasShadowRight:r}=s;t.style.flex=Boolean(a)?`0 0 ${a}`:"",h()||(e.sticky&&!o&&(t.classList.add("table-cell--is-sticky"),t.style.left=i+"px",r&&t.classList.add("table-cell--has-shadow-right")),o&&t.classList.add("table-cell--is-sticky-right","table-cell--has-shadow-left"))}applyColumnStyles(t,e){if(h())return;const{leftOffsetForStickyColumn:s,isLastColumnSticky:i,hasShadowRight:a}=e;t.sticky&&!i&&(t.classList.add("table-column--is-sticky"),t.style.left=s+"px",a&&t.classList.add("table-column--has-shadow-right")),i&&t.classList.add("table-column--is-sticky-right","table-column--has-shadow-left")}getLeftOffsetForStickyColumn(t,e){return t.slice(0,e).reduce(((t,e)=>{if(e.sticky)return t+e.getBoundingClientRect().width}),0)}hasStickyColumnsToRight(t,e){return t.slice(e+1,t.length-1).some((t=>t.sticky))}updateEmptyState(){const t=this.el.querySelector('[slot="rows"]');this.empty=!Boolean(t)||0===t.children.length}updateLiveRegionText(t,e={}){let s=t?this.dragDropInstructions[t]:"";for(const[t,i]of Object.entries(e??{}))s=s.replaceAll(`{${t}}`,String(i));s!==this.liveRegionText&&(this.liveRegionText=s)}toggleKeyboardMove(t){this.movingViaKeyboard?this.endKeyboardMove(t):this.startKeyboardMove(t)}startKeyboardMove(t){this.movingViaKeyboard=!0,this.positionBeforeKeyboardMove=Array.from(this.dragDropContainer.children).indexOf(t),t.classList.add("table-row--moving"),this.updateLiveRegionText("start",{position:Array.from(this.dragDropContainer.children).indexOf(t)+1,rowCount:this.dragDropContainer.children.length})}endKeyboardMove(t){this.movingViaKeyboard=!1,t.classList.remove("table-row--moving"),this.updateLiveRegionText("end",{position:Array.from(this.dragDropContainer.children).indexOf(t)+1,rowCount:this.dragDropContainer.children.length}),this.dropRow.emit({item:t,newIndex:Array.from(this.dragDropContainer.children).indexOf(t),oldIndex:this.positionBeforeKeyboardMove,itemId:t.id,newNextSiblingItemId:Array.from(this.dragDropContainer.children).indexOf(t)<this.dragDropContainer.children.length-1?this.dragDropContainer.children[Array.from(this.dragDropContainer.children).indexOf(t)+1].id:void 0,newPrevSiblingItemId:Array.from(this.dragDropContainer.children).indexOf(t)>0?this.dragDropContainer.children[Array.from(this.dragDropContainer.children).indexOf(t)-1].id:void 0}),this.positionBeforeKeyboardMove=void 0}cancelKeyboardMove(){if(!this.movingViaKeyboard)return;const t=this.el.querySelector(".table-row--moving");t&&(t.classList.remove("table-row--moving"),this.movingViaKeyboard=!1,void 0!==this.positionBeforeKeyboardMove&&this.dragDropContainer.insertBefore(t,this.dragDropContainer.children[this.positionBeforeKeyboardMove]))}moveRow(t,e){if(!this.movingViaKeyboard)return;let s;if("up"===e){const e=Array.from(this.dragDropContainer.children).indexOf(t);s=Math.max(0,e-1),this.dragDropContainer.insertBefore(t,this.dragDropContainer.children[s])}else{const e=Array.from(this.dragDropContainer.children).indexOf(t);s=Math.min(this.dragDropContainer.children.length-1,e+1),this.dragDropContainer.insertBefore(t,this.dragDropContainer.children[s+1])}this.updateLiveRegionText("moved",{position:s+1,rowCount:this.dragDropContainer.children.length}),this.focusDragHandleOfRow(t)}focusDragHandleOfRow(t){const e=c(t,this.dragDropHandle)?.[0];"BUTTON"===e.tagName?e.focus():e.querySelector("button")?.focus()}render(){const t=Boolean(this.el.querySelector('[slot="empty"]')),e=r("table",{"table--show-empty-state":this.empty&&!this.loading,"table--keyboard-move":this.movingViaKeyboard});return s(i,{key:"16d0611e24b24ee9f79cc38e0095a67672d74c2e"},s("div",{key:"aec12bf6d94bef63f68acfaf028658254d01f181",class:e},this.enableDragDrop&&s("swirl-visually-hidden",{key:"0af23c204985e8578aee552beff188f5e599275f"},s("span",{key:"0f4bcc195d7bd265c028b70604ba74b1531e3c25","aria-live":"assertive"},this.liveRegionText)),s("div",{key:"77e6c52ecbf5e81d268b9c49364cbe166e8ba45e",class:"table__container",onFocusin:this.onFocus,onFocusout:this.onBlur,onKeyDown:this.onKeyDown,onScroll:this.onScroll,ref:t=>this.container=t,tabIndex:-1},s("div",{key:"21156e4f5d0a98c1c11cdab2c8d812833d1af031","aria-describedby":Boolean(this.caption)?"caption":void 0,"aria-label":this.label,role:"table",class:"table__table"},this.caption&&s("swirl-visually-hidden",{key:"deea452f4a44ffaf0f8472e0ba07446f555de0c2"},s("div",{key:"e0f7da4bf4009659451e3890827861a64045d740",id:"caption"},this.caption)),s("div",{key:"ce3b91d7709fb0b607cf3b4fa48f5d118d04ac4f",role:"rowgroup"},s("div",{key:"15c9d000b9d69eedc6ca1285a9dcfa20ca2bec02",class:"table__header",ref:t=>this.headerEl=t,role:"row"},s("slot",{key:"31f61474ba47292819e5fbaf655817ed28a03434",name:"columns"}))),s("div",{key:"2d5e8fab1af067c1eb59ad84db517113cc6935e3",class:"table__body",ref:t=>this.bodyEl=t},s("slot",{key:"47f0b034e0412de19194c87bf2dd1eea524af173",name:"rows"}),s("div",{key:"4b97574c5c5919c35fd5a9ce48a4b4dbb24d9518",class:"table__empty-row",role:"row"},s("div",{key:"e8d44d595d30450512ad57defb3c61fd77f2040a","aria-colspan":this.getColumns().length,class:"table__empty-row-cell",role:"cell"},s("slot",{key:"6551e8e625520b44e608a41e67d58e65a06c20d2",name:"empty"}),!t&&s("swirl-text",{key:"7689d667f7574ddd4dfa3ad54d05906e1822c035",align:"center",size:"sm"},this.emptyStateLabel))))))))}get el(){return a(this)}static get watchers(){return{enableDragDrop:[{handleEnableDragDropChange:0}]}}};p.style=".sc-swirl-table-h{--swirl-table-shadow-rgba:rgba(23, 23, 23, 0.2);position:relative;display:block}.sc-swirl-table-h *.sc-swirl-table{box-sizing:border-box}html.theme-dark.sc-swirl-table-h,html.theme-dark .sc-swirl-table-h{--swirl-table-shadow-rgba:rgba(0, 0, 0, 0.2)}.table--keyboard-move.sc-swirl-table:focus-within{--swirl-table-moving-row-border:var(--s-border-width-default) solid var(--s-border-highlight)}.table--show-empty-state.sc-swirl-table .table__empty-row.sc-swirl-table{display:flex}.table__container.sc-swirl-table{position:relative;overflow:auto;width:100%}.table__container--scrolled.sc-swirl-table{--swirl-table-sticky-right-shadow:4px 0 16px -4px var(--swirl-table-shadow-rgba), 2px 0 4px -2px var(--swirl-table-shadow-rgba)}.table__container--scrollable.sc-swirl-table:not(.table__container--scrolled-to-end){--swirl-table-sticky-left-shadow:0px 4px 16px 0px var(--swirl-table-shadow-rgba), 0px 1px 4px 0px var(--swirl-table-shadow-rgba)}.table__table.sc-swirl-table{width:-moz-max-content;width:max-content;min-width:max(20rem, 100%)}.table__header.sc-swirl-table-s>*,.table__header .sc-swirl-table-s>*{display:flex}.table__empty-row.sc-swirl-table{display:none}.table__empty-row-cell.sc-swirl-table{display:flex;overflow:auto;padding-top:var(--s-space-8);padding-right:var(--s-space-16);padding-bottom:var(--s-space-8);padding-left:var(--s-space-16);flex-basis:0;flex-grow:1;flex-shrink:1;align-items:center;background-color:var(--s-surface-default)}.table__empty-row-cell.sc-swirl-table>*.sc-swirl-table{flex-grow:1}";export{p as swirl_table}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as o,a as s,d as i}from"./p-Dz56lJ37.js";import{k as r}from"./p-CCck-DTo.js";const e=class{constructor(o){t(this,o),this.orientation="horizontal",this.spacing="8",this.onKeyDown=t=>{"ArrowDown"===t.code||"ArrowRight"===t.code?(t.preventDefault(),this.focusNextItem()):"ArrowUp"!==t.code&&"ArrowLeft"!==t.code||(t.preventDefault(),this.focusPreviousItem())}}componentDidLoad(){const t=this.getItems();this.deactivateTabIndexes(t);const o=t[0]?.querySelector("button");Boolean(o)&&(o.tabIndex=0)}getItems(){return Array.from(this.el.querySelectorAll("swirl-button, swirl-chip"))}focusNextItem(){const t=this.getItems(),o=this.getActiveItemIndex(t);this.focusItem(t[(o+1)%t.length])}focusPreviousItem(){const t=this.getItems(),o=this.getActiveItemIndex(t);this.focusItem(t[0===o?t.length-1:o-1])}getActiveItemIndex(t){const o=r();return t.findIndex((t=>t===o?.closest("swirl-button, swirl-chip")))}focusItem(t){const o=this.getItems();if(this.deactivateTabIndexes(o),!Boolean(t))return;const s=t.querySelector("button");Boolean(s)&&(s.tabIndex=0,s.focus())}deactivateTabIndexes(t){t.forEach((t=>{const o=t.querySelector("button");Boolean(o)&&(o.tabIndex=-1)}))}render(){return o(s,{key:"73b1af3aced583df7489fed5d8fd87269b71958f"},o("swirl-stack",{key:"53acf3a4c4dcdb67004ce0c685fbce11709a36ad",align:"center","aria-label":this.label,"aria-orientation":this.orientation,role:"toolbar",onKeyDown:this.onKeyDown,orientation:this.orientation,spacing:this.spacing,wrap:!0},o("slot",{key:"602437b7f5529bae90be0203362223527b56644c"})))}get el(){return i(this)}};e.style=":host{display:block}:host *{box-sizing:border-box}";export{e as swirl_toolbar}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as s,h as i,a as e,d as a}from"./p-Dz56lJ37.js";import{a as o,c as h,o as l}from"./p-CLsTbQHn.js";import{c}from"./p-orsBiyT_.js";import{d as r}from"./p-CCck-DTo.js";const n=class{constructor(i){t(this,i),this.valueChange=s(this,"valueChange",7),this.clearable=!0,this.clearButtonLabel="Clear input",this.generateSuggestions=async()=>[],this.menuLabel="Suggestions",this.active=!1,this.loading=!1,this.suggestions=[],this.onChange=t=>{t.stopPropagation(),this.updateTerm(t)},this.updateTerm=r((async t=>{this.updateSuggestions(t.detail),this.open(),this.multiSelect||Boolean(t.detail)&&""!==t.detail||(this.value=void 0,this.valueChange.emit(this.value))}),250,!1),this.onSelect=async t=>{if(t.stopPropagation(),this.multiSelect){const s=t.detail,i=this.suggestions.filter((t=>!s.includes(t.id))).map((t=>t.id));this.value=[...this.value.filter((t=>!i.includes(t.id))),...this.suggestions.filter((t=>s.includes(t.id)&&!this.value.some((s=>s.id===t.id))))],this.valueChange.emit(this.value),this.inputEl.value="";const e=this.inputEl.querySelector("input");Boolean(e)&&(e.value="",queueMicrotask((()=>{e.focus(),this.close()})),this.updateSuggestions(e.value))}else if(Boolean(t.detail[0])){const s=t.detail[0],i=this.suggestions.find((t=>t.id===s));if(!Boolean(i))return;this.value=i,this.valueChange.emit(this.value),queueMicrotask((()=>{this.inputEl.querySelector("input")?.focus(),this.close()}))}},this.onRemoveValue=t=>{Array.isArray(this.value)&&(this.value=this.value.filter((s=>s.id!==t)),this.valueChange.emit(this.value))},this.onFocusOut=t=>{const s=t.relatedTarget;Boolean(s)&&!this.el.contains(s)&&this.close()},this.onFocus=()=>{this.updateSuggestions(),this.open()},this.onKeyDown=t=>{"Escape"===t.code&&(t.preventDefault(),t.stopPropagation(),this.inputEl.querySelector("input").focus(),this.close())},this.onInputKeyDown=t=>{"ArrowDown"===t.code&&(t.preventDefault(),this.listboxEl.querySelector('[role="listbox"]')?.querySelector('[tabIndex="0"]')?.focus())}}componentWillLoad(){const t=document.querySelectorAll("swirl-datepicker").length;this.id=`autocomplete-${t}`,this.handleInitialValue()}onWindowClick(t){this.el.contains(t.target)||this.close()}watchMultiSelect(){this.handleInitialValue()}async close(){if(!this.active)return;this.disableAutoUpdate&&this.disableAutoUpdate();const t=this.inputEl.querySelector("input");Boolean(t)&&(t.value=this.multiSelect?"":this.value?.label||""),this.active=!1}async open(){this.active||(this.active=!0,requestAnimationFrame((async()=>{await this.reposition(),this.disableAutoUpdate&&this.disableAutoUpdate(),this.disableAutoUpdate=o(this.inputEl,this.listboxContainerEl,this.reposition.bind(this),{animationFrame:!0}),this.listboxContainerEl.scrollTop=0,this.updateSuggestions(this.inputEl.querySelector("input").value)})))}async reposition(){Boolean(this.listboxContainerEl)&&(this.position=await h(this.inputEl,this.listboxContainerEl,{middleware:[l({crossAxis:-16,mainAxis:16})],placement:"bottom-start",strategy:"fixed"}))}async updateSuggestions(t){this.loading=!0,this.suggestions=[],this.suggestions=await this.generateSuggestions(t),this.loading=!1}handleInitialValue(){this.multiSelect&&!Array.isArray(this.value)&&(this.value=[]),!this.multiSelect&&Array.isArray(this.value)&&(this.value=void 0)}render(){const t=`${this.id}-suggestions`,s=this.clearable&&!this.multiSelect,a=this.multiSelect?this.value.map((t=>t.id)):Boolean(this.value)?[this.value.id]:[],o=this.multiSelect?void 0:this.value?.label||"",h=c("autocomplete",{"autocomplete--inactive":!this.active});return i(e,{key:"bf076ad2e3840ef8bd57153c90107d3df1a806ad"},i("div",{key:"d5a5988e04aab0d702c0dee903d784dc69101933",class:h,onKeyDown:this.onKeyDown},this.multiSelect&&Array.isArray(this.value)&&this.value.length>0&&i("div",{key:"c0032b03256dc5c88fc38236599fbbd8cdae96df",class:"autocomplete__multi-select-tags"},i("swirl-stack",{key:"1d4b148a2273271571b6e05455cd113ef7c1656e",orientation:"horizontal",spacing:"8",wrap:!0},this.value.map((t=>i("swirl-tag",{key:t.id,label:t.label,onRemove:()=>this.onRemoveValue(t.id),removable:!this.disabled}))))),i("swirl-text-input",{key:"f40bd864adb81e66ae73ce79f54bd6f4b0d1312e",autoSelect:this.autoSelect,class:"autocomplete__input",clearable:s,clearButtonLabel:this.clearButtonLabel,disabled:this.disabled,disableDynamicWidth:!0,id:this.id,inline:this.inline,invalid:this.invalid,onInputFocus:this.onFocus,onKeyDown:this.onInputKeyDown,onValueChange:this.onChange,maxLength:this.maxLength,mode:this.mode,placeholder:this.placeholder,ref:t=>this.inputEl=t,required:this.required,spellCheck:this.spellCheck,swirlAriaAutocomplete:"list",swirlAriaControls:t,swirlAriaDescribedby:this.swirlAriaDescribedby,swirlAriaExpanded:String(this.active),swirlRole:"combobox",value:o}),i("div",{key:"1f1ee304b4fdfacc9f582f1b7c85bd7359841895",class:"autocomplete__listbox-container",onFocusout:this.onFocusOut,ref:t=>this.listboxContainerEl=t,style:{top:Boolean(this.position)?`${this.position?.y}px`:"",left:Boolean(this.position)?`${this.position?.x}px`:"",width:`${this.inputEl?.getBoundingClientRect().width+32}px`}},this.loading&&i("div",{key:"e163af35f06c0d4c8be7ffbccfad83138a6677bd",class:"autocomplete__spinner"},i("swirl-spinner",{key:"252d6a9ba7c4f035e06d79d400d5d63db342a4ec"})),this.suggestions.length>0&&i("swirl-option-list",{key:"4e2360c358a4c639812821f753dbcdf5d723bb60",allowDeselect:!0===this.multiSelect,label:this.menuLabel,multiSelect:this.multiSelect,onValueChange:this.onSelect,optionListId:t,ref:t=>this.listboxEl=t,value:a},this.suggestions.map((t=>i("swirl-option-list-item",{selected:Array.isArray(this.value)?this.value.some((s=>s.id===t.id)):this.value?.id===t.id,key:t.id,disabled:t.disabled,label:t.label,value:t.id})))))))}get el(){return a(this)}static get watchers(){return{multiSelect:[{watchMultiSelect:0}]}}};n.style=".sc-swirl-autocomplete-h{display:block}.sc-swirl-autocomplete-h *.sc-swirl-autocomplete{box-sizing:border-box}.autocomplete--inactive.sc-swirl-autocomplete .autocomplete__listbox-container.sc-swirl-autocomplete{display:none}.autocomplete__listbox-container.sc-swirl-autocomplete{position:fixed;z-index:var(--s-z-40);overflow-x:hidden;overflow-y:auto;max-height:18rem;padding-top:var(--s-space-8);padding-bottom:var(--s-space-8);border-radius:var(--s-border-radius-sm);background:var(--s-translucent-low-default);-webkit-backdrop-filter:blur(var(--s-blur-l));backdrop-filter:blur(var(--s-blur-l));animation:autocomplete-enter 0.1s;box-shadow:var(--s-shadow-level-1)}.autocomplete__listbox-container.sc-swirl-autocomplete:empty{display:none}.autocomplete__spinner.sc-swirl-autocomplete{display:flex;padding:var(--s-space-16);justify-content:center;align-items:center}.autocomplete__multi-select-tags.sc-swirl-autocomplete{margin-top:var(--swirl-autocomplete-tags-margin-top);margin-bottom:var(--s-space-4)}@keyframes autocomplete-enter{from{opacity:0}to{opacity:1}}";export{n as swirl_autocomplete}
|