@getflip/swirl-ai 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.
@@ -14,8 +14,13 @@ The SwirlTable component is used to organize and display data sets.
14
14
  - `dragDropHandle` (string | undefined) –
15
15
  - `emptyStateLabel` (string | undefined) –
16
16
  - `enableDragDrop` (boolean | undefined) –
17
+ - `enableVirtualization` (boolean | undefined) –
17
18
  - `loading` (boolean | undefined) –
19
+ - `virtualizationEstimatedRowHeight` (number | undefined) –
20
+ - `virtualizationOverscan` (number | undefined) –
21
+ - `virtualizationRowCount` (number | undefined) –
18
22
  - `dragDropInstructions` ({ end: string; initial: string; moved: string; start: string; } | undefined) –
23
+ - `virtualizationKeepRowsRendered` (number[] | undefined) –
19
24
 
20
25
  ## Slots
21
26
 
@@ -26,6 +31,7 @@ The SwirlTable component is used to organize and display data sets.
26
31
  ## Events
27
32
 
28
33
  - `dropRow` – CustomEvent<Pick<SortableEvent, "oldIndex" | "newIndex" | "item"> & { itemId: string; newNextSiblingItemId: string; newPrevSiblingItemId: string; }>
34
+ - `virtualizationRowsChange` – CustomEvent<{ indexes: number[]; }>
29
35
 
30
36
  ## Methods
31
37
 
@@ -61757,6 +61757,14 @@
61757
61757
  },
61758
61758
  "fieldName": "enableDragDrop"
61759
61759
  },
61760
+ {
61761
+ "name": "enable-virtualization",
61762
+ "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.",
61763
+ "type": {
61764
+ "text": "boolean | undefined"
61765
+ },
61766
+ "fieldName": "enableVirtualization"
61767
+ },
61760
61768
  {
61761
61769
  "name": "label",
61762
61770
  "type": {
@@ -61770,6 +61778,32 @@
61770
61778
  "text": "boolean | undefined"
61771
61779
  },
61772
61780
  "fieldName": "loading"
61781
+ },
61782
+ {
61783
+ "name": "virtualization-estimated-row-height",
61784
+ "description": "Height in px assumed for rows not drawn yet.",
61785
+ "type": {
61786
+ "text": "number | undefined"
61787
+ },
61788
+ "default": "56",
61789
+ "fieldName": "virtualizationEstimatedRowHeight"
61790
+ },
61791
+ {
61792
+ "name": "virtualization-overscan",
61793
+ "description": "Number of extra rows drawn above and below the visible ones.",
61794
+ "type": {
61795
+ "text": "number | undefined"
61796
+ },
61797
+ "default": "10",
61798
+ "fieldName": "virtualizationOverscan"
61799
+ },
61800
+ {
61801
+ "name": "virtualization-row-count",
61802
+ "description": "Total number of rows when virtualized.",
61803
+ "type": {
61804
+ "text": "number | undefined"
61805
+ },
61806
+ "fieldName": "virtualizationRowCount"
61773
61807
  }
61774
61808
  ],
61775
61809
  "members": [
@@ -61819,6 +61853,16 @@
61819
61853
  "readonly": true,
61820
61854
  "attribute": "enable-drag-drop"
61821
61855
  },
61856
+ {
61857
+ "kind": "field",
61858
+ "name": "enableVirtualization",
61859
+ "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.",
61860
+ "type": {
61861
+ "text": "boolean | undefined"
61862
+ },
61863
+ "readonly": true,
61864
+ "attribute": "enable-virtualization"
61865
+ },
61822
61866
  {
61823
61867
  "kind": "field",
61824
61868
  "name": "label",
@@ -61837,6 +61881,48 @@
61837
61881
  "readonly": true,
61838
61882
  "attribute": "loading"
61839
61883
  },
61884
+ {
61885
+ "kind": "field",
61886
+ "name": "virtualizationEstimatedRowHeight",
61887
+ "description": "Height in px assumed for rows not drawn yet.",
61888
+ "type": {
61889
+ "text": "number | undefined"
61890
+ },
61891
+ "default": "56",
61892
+ "readonly": true,
61893
+ "attribute": "virtualization-estimated-row-height"
61894
+ },
61895
+ {
61896
+ "kind": "field",
61897
+ "name": "virtualizationKeepRowsRendered",
61898
+ "description": "Indexes of rows to keep drawn when out of view, e.g. a row with an open\nmenu. The focused row is always kept.",
61899
+ "type": {
61900
+ "text": "number[] | undefined"
61901
+ },
61902
+ "default": "[]",
61903
+ "readonly": true
61904
+ },
61905
+ {
61906
+ "kind": "field",
61907
+ "name": "virtualizationOverscan",
61908
+ "description": "Number of extra rows drawn above and below the visible ones.",
61909
+ "type": {
61910
+ "text": "number | undefined"
61911
+ },
61912
+ "default": "10",
61913
+ "readonly": true,
61914
+ "attribute": "virtualization-overscan"
61915
+ },
61916
+ {
61917
+ "kind": "field",
61918
+ "name": "virtualizationRowCount",
61919
+ "description": "Total number of rows when virtualized.",
61920
+ "type": {
61921
+ "text": "number | undefined"
61922
+ },
61923
+ "readonly": true,
61924
+ "attribute": "virtualization-row-count"
61925
+ },
61840
61926
  {
61841
61927
  "kind": "method",
61842
61928
  "name": "rerender",
@@ -61865,6 +61951,18 @@
61865
61951
  }
61866
61952
  ]
61867
61953
  }
61954
+ },
61955
+ {
61956
+ "name": "virtualizationRowsChange",
61957
+ "description": "Emits the indexes of the rows to render.",
61958
+ "type": {
61959
+ "text": "CustomEvent<{ indexes: number[]; }>",
61960
+ "references": [
61961
+ {
61962
+ "name": "SwirlTableVirtualizationRows"
61963
+ }
61964
+ ]
61965
+ }
61868
61966
  }
61869
61967
  ],
61870
61968
  "slots": [
@@ -0,0 +1,60 @@
1
+ export interface SwirlTableVirtualizerConfig {
2
+ estimatedRowHeight: number;
3
+ keptIndexes: number[];
4
+ overscan: number;
5
+ rowCount: number;
6
+ }
7
+ type ScrollElement = HTMLElement | Window;
8
+ /**
9
+ * Decides which rows of a swirl-table to draw and positions them. The consumer
10
+ * renders the rows, identified by `data-index`. Padding on the table body
11
+ * stands in for the rows not drawn. A row's margin-top fills the gap before a
12
+ * kept row far from the visible ones.
13
+ */
14
+ export declare class SwirlTableVirtualizer {
15
+ private bodyEl;
16
+ readonly scrollElement: ScrollElement;
17
+ private config;
18
+ private onIndexesChange;
19
+ private virtualizer;
20
+ private unmount;
21
+ private scrollMargin;
22
+ private measuredIndexes;
23
+ private observedRows;
24
+ /**
25
+ * Own observer, because the virtualizer's `measureElement` caches elements
26
+ * by index and stops observing reused ones.
27
+ */
28
+ private resizeObserver;
29
+ private indexes;
30
+ private isResizingRows;
31
+ private hasChangeWhileResizing;
32
+ constructor(bodyEl: HTMLElement, scrollElement: ScrollElement, config: SwirlTableVirtualizerConfig, onIndexesChange: (indexes: number[]) => void);
33
+ setConfig(config: SwirlTableVirtualizerConfig): void;
34
+ /**
35
+ * Call after rows were added, removed or re-indexed. Measures new rows and
36
+ * positions all rows.
37
+ */
38
+ sync(): void;
39
+ destroy(): void;
40
+ private applyOptions;
41
+ private update;
42
+ /**
43
+ * Measures where the rows start again, as content above the table can
44
+ * change height, e.g. a toolbar appears. Returns whether it changed.
45
+ */
46
+ private updateScrollMargin;
47
+ /**
48
+ * Reports each row's height for its current index. Every resize makes the
49
+ * virtualizer call onChange, so the rows are positioned once at the end
50
+ * instead of after each resize.
51
+ */
52
+ private resizeRows;
53
+ private handleChange;
54
+ private layout;
55
+ private getRenderedRows;
56
+ private options;
57
+ /** Offset of the first row from the top of the scrolled content. */
58
+ private measureScrollMargin;
59
+ }
60
+ export {};
@@ -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
  }
@@ -16,3 +16,5 @@ declare const _default: {
16
16
  };
17
17
  export default _default;
18
18
  export declare const SwirlTable: any;
19
+ export declare const Virtualized: any;
20
+ export declare const VirtualizedWindowScroll: any;
@@ -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;
@@ -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-ai",
3
- "version": "0.533.0",
3
+ "version": "0.534.0",
4
4
  "description": "Swirl Design System AI package with artifacts for AI agents",
5
5
  "author": "Flip GmbH",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "lint": "tsc --noEmit"
27
27
  },
28
28
  "devDependencies": {
29
- "@getflip/swirl-components": "0.533.0",
29
+ "@getflip/swirl-components": "0.534.0",
30
30
  "@getflip/swirl-tokens": "2.14.3",
31
31
  "@types/node": "25.3.0",
32
32
  "tsx": "^4.7.0",