vlist 3.0.0-next.2 → 3.0.0-next.4
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/README.github.md +88 -39
- package/README.md +44 -27
- package/dist/config.d.ts +129 -12
- package/dist/config.js +1 -1
- package/dist/core/create.d.ts +22 -4
- package/dist/core/dom.d.ts +22 -2
- package/dist/core/fold.d.ts +52 -0
- package/dist/core/hooks.d.ts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/pipeline.d.ts +1 -1
- package/dist/core/pool.d.ts +9 -2
- package/dist/core/runway.d.ts +29 -3
- package/dist/core/scroll.d.ts +1 -1
- package/dist/core/sizes.d.ts +1 -1
- package/dist/core/state.d.ts +13 -1
- package/dist/core/types.d.ts +151 -61
- package/dist/core/velocity.d.ts +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.js +1 -1
- package/dist/internals.d.ts +0 -1
- package/dist/internals.js +1 -1
- package/dist/plugins/a11y/index.d.ts +1 -0
- package/dist/plugins/a11y/plugin.d.ts +1 -1
- package/dist/plugins/autosize/index.d.ts +2 -1
- package/dist/plugins/autosize/plugin.d.ts +13 -2
- package/dist/plugins/carousel/engine.d.ts +1 -1
- package/dist/plugins/carousel/index.d.ts +1 -0
- package/dist/plugins/carousel/plugin.d.ts +42 -6
- package/dist/plugins/carousel/presets.d.ts +1 -1
- package/dist/plugins/data/index.d.ts +1 -0
- package/dist/plugins/data/plugin.d.ts +15 -2
- package/dist/plugins/grid/index.d.ts +2 -1
- package/dist/plugins/grid/plugin.d.ts +14 -2
- package/dist/plugins/groups/async-bridge.d.ts +6 -6
- package/dist/plugins/groups/index.d.ts +1 -0
- package/dist/plugins/groups/layout.d.ts +2 -2
- package/dist/plugins/groups/plugin.d.ts +12 -4
- package/dist/plugins/groups/sticky.d.ts +2 -1
- package/dist/plugins/groups/types.d.ts +8 -3
- package/dist/plugins/masonry/index.d.ts +2 -1
- package/dist/plugins/masonry/plugin.d.ts +10 -2
- package/dist/plugins/masonry/renderer.d.ts +5 -1
- package/dist/plugins/page/plugin.d.ts +1 -1
- package/dist/plugins/scrollbar/index.d.ts +2 -1
- package/dist/plugins/scrollbar/plugin.d.ts +7 -2
- package/dist/plugins/search/index.d.ts +1 -0
- package/dist/plugins/search/plugin.d.ts +29 -1
- package/dist/plugins/selection/index.d.ts +2 -1
- package/dist/plugins/selection/plugin.d.ts +23 -2
- package/dist/plugins/snapshots/index.d.ts +1 -0
- package/dist/plugins/snapshots/plugin.d.ts +9 -2
- package/dist/plugins/sortable/index.d.ts +1 -0
- package/dist/plugins/sortable/plugin.d.ts +14 -3
- package/dist/plugins/table/index.d.ts +1 -0
- package/dist/plugins/table/plugin.d.ts +19 -3
- package/dist/plugins/transition/plugin.d.ts +1 -1
- package/dist/plugins/tree/index.d.ts +1 -0
- package/dist/plugins/tree/layout.d.ts +3 -1
- package/dist/plugins/tree/plugin.d.ts +37 -3
- package/dist/plugins/tree/types.d.ts +1 -1
- package/dist/rendering/sizes.d.ts +19 -1
- package/dist/size.json +1 -1
- package/dist/synthetic.d.ts +2 -2
- package/dist/synthetic.js +1 -1
- package/dist/types.d.ts +14 -21
- package/dist/utils/apply-scroll-behavior.d.ts +15 -0
- package/dist/utils/scroll-padding.d.ts +36 -0
- package/dist/utils/stats.d.ts +9 -1
- package/dist/vlist-tree.css +1 -1
- package/dist/vlist.css +1 -1
- package/package.json +6 -2
- package/dist/plugins/grid/renderer.d.ts +0 -68
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Masonry Plugin
|
|
3
3
|
*/
|
|
4
4
|
export { masonry, type MasonryPluginConfig, type MasonryContext } from "./plugin";
|
|
5
5
|
export { createMasonryLayout } from "./layout";
|
|
6
6
|
export { createMasonryRenderer, type MasonryRenderer, type GetItemFn } from "./renderer";
|
|
7
7
|
export type { MasonryConfig, MasonryLayout, ItemPlacement } from "./types";
|
|
8
|
+
export type { MasonryMethods } from "./plugin";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Masonry Plugin
|
|
3
3
|
*
|
|
4
4
|
* Switches from list layout to masonry/Pinterest-style layout with
|
|
5
5
|
* shortest-lane placement. Each item is positioned in the shortest
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { VListItem } from "../../types";
|
|
15
15
|
import type { VListPlugin } from "../../core/types";
|
|
16
|
+
import type { MasonryLayout } from "./types";
|
|
16
17
|
export interface MasonryPluginConfig {
|
|
17
18
|
columns: number;
|
|
18
19
|
gap?: number;
|
|
@@ -28,5 +29,12 @@ export interface MasonryContext {
|
|
|
28
29
|
gap: number;
|
|
29
30
|
containerWidth: number;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
/** Methods the masonry plugin adds to the list instance. */
|
|
33
|
+
export interface MasonryMethods {
|
|
34
|
+
/** The current masonry layout. */
|
|
35
|
+
getMasonryLayout(): MasonryLayout;
|
|
36
|
+
/** Change columns or gap at runtime. */
|
|
37
|
+
updateMasonry(config: Partial<MasonryPluginConfig>): void;
|
|
38
|
+
}
|
|
39
|
+
export declare function masonry<T extends VListItem = VListItem>(config: MasonryPluginConfig): VListPlugin<T, MasonryMethods>;
|
|
32
40
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -52,6 +52,10 @@ export interface MasonryRenderer<T extends VListItem = VListItem> {
|
|
|
52
52
|
* @param isHorizontal - Whether layout is horizontal (scrolls right)
|
|
53
53
|
* @param totalItemsGetter - Optional getter for total item count (for aria-setsize)
|
|
54
54
|
* @param ariaIdPrefix - Optional unique prefix for element IDs (for aria-activedescendant)
|
|
55
|
+
* @param ariaPosInSetGetter - Optional mapper from layout index to aria-posinset
|
|
56
|
+
* @param interactive - Whether the list is a listbox. A getter is resolved on
|
|
57
|
+
* each render so masonry can wait for a11y()/selection() (priority 50/55)
|
|
58
|
+
* to call enableListbox() after this plugin's priority-10 setup.
|
|
55
59
|
*/
|
|
56
|
-
export declare const createMasonryRenderer: <T extends VListItem = VListItem>(itemsContainer: HTMLElement, template: ItemTemplate<T>, classPrefix: string, isHorizontal?: boolean, totalItemsGetter?: () => number, ariaIdPrefix?: string, ariaPosInSetGetter?: (layoutIndex: number) => number, interactive?: boolean, getBaseOffset?: () => number) => MasonryRenderer<T>;
|
|
60
|
+
export declare const createMasonryRenderer: <T extends VListItem = VListItem>(itemsContainer: HTMLElement, template: ItemTemplate<T>, classPrefix: string, isHorizontal?: boolean, totalItemsGetter?: () => number, ariaIdPrefix?: string, ariaPosInSetGetter?: (layoutIndex: number) => number, interactive?: boolean | (() => boolean), getBaseOffset?: () => number) => MasonryRenderer<T>;
|
|
57
61
|
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Scrollbar Plugin
|
|
3
3
|
*/
|
|
4
4
|
export { scrollbar, type ScrollbarPluginConfig } from "./plugin";
|
|
5
5
|
export { createScrollbar, type Scrollbar, type ScrollbarConfig, type ScrollCallback, } from "./scrollbar";
|
|
6
|
+
export type { ScrollbarMethods } from "./plugin";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Scrollbar Plugin
|
|
3
3
|
*
|
|
4
4
|
* Replaces the native scrollbar with a custom, cross-browser consistent scrollbar.
|
|
5
5
|
* Priority 15 — runs after layout plugins (10) but before selection (50).
|
|
@@ -16,5 +16,10 @@ import { type ScrollbarConfig } from "./scrollbar";
|
|
|
16
16
|
export interface ScrollbarPluginConfig extends ScrollbarConfig {
|
|
17
17
|
gutter?: boolean;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
/** Methods the scrollbar plugin adds to the list instance. */
|
|
20
|
+
export interface ScrollbarMethods {
|
|
21
|
+
/** Recompute the thumb from the current content size. */
|
|
22
|
+
refreshScrollbar(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function scrollbar<T extends VListItem = VListItem>(config?: ScrollbarPluginConfig): VListPlugin<T, ScrollbarMethods>;
|
|
20
25
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { search, DEFAULT_SEARCH_TEXT, type SearchPluginConfig, type SearchPluginInstance, type SearchText, } from "./plugin";
|
|
7
7
|
export { makeGetText, type FieldAccessor } from "./match";
|
|
8
|
+
export type { SearchMethods } from "./plugin";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -12,6 +12,17 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Phase 2 (server-side search via `data()`, column-aware, fuzzy, query syntax)
|
|
14
14
|
* is out of scope here.
|
|
15
|
+
*
|
|
16
|
+
* Restrictions:
|
|
17
|
+
* - Cannot be combined with `data()`. Filtering is client-side over the items
|
|
18
|
+
* the list holds, and with an adapter those are only the loaded window.
|
|
19
|
+
* Query the remote dataset through the adapter instead.
|
|
20
|
+
* - Cannot be combined with `tree()`. Filtering a tree means preserving the
|
|
21
|
+
* ancestors of each match, which belongs to the plugin that owns the layout;
|
|
22
|
+
* `tree()` provides no such hook.
|
|
23
|
+
* - Cannot *yet* be combined with `carousel()`. Filter mode replaces the item
|
|
24
|
+
* accessors and the total that the carousel window owns, and clearing the
|
|
25
|
+
* query does not give them back. Fixable — see `conflicts` below.
|
|
15
26
|
*/
|
|
16
27
|
import type { VListItem } from "../../types";
|
|
17
28
|
import type { VListPlugin } from "../../core/types";
|
|
@@ -78,7 +89,24 @@ export interface SearchPluginConfig<T extends VListItem = VListItem> {
|
|
|
78
89
|
/** Consumer-supplied UI text / localization. Falls back to {@link DEFAULT_SEARCH_TEXT}. */
|
|
79
90
|
text?: SearchText;
|
|
80
91
|
}
|
|
81
|
-
|
|
92
|
+
/** Methods the search plugin adds to the list instance. */
|
|
93
|
+
export interface SearchMethods {
|
|
94
|
+
/** Show the search bar. */
|
|
95
|
+
openSearch(): void;
|
|
96
|
+
/** Hide the search bar and clear the query. */
|
|
97
|
+
closeSearch(): void;
|
|
98
|
+
/** Set the query, opening the bar when needed. */
|
|
99
|
+
setQuery(query: string): void;
|
|
100
|
+
/** The current query. */
|
|
101
|
+
getQuery(): string;
|
|
102
|
+
/** Move to the next match. */
|
|
103
|
+
nextMatch(): void;
|
|
104
|
+
/** Move to the previous match. */
|
|
105
|
+
prevMatch(): void;
|
|
106
|
+
/** Indices of the matching items. */
|
|
107
|
+
getMatches(): number[];
|
|
108
|
+
}
|
|
109
|
+
export interface SearchPluginInstance<T extends VListItem = VListItem> extends VListPlugin<T, SearchMethods> {
|
|
82
110
|
}
|
|
83
111
|
export declare function search<T extends VListItem = VListItem>(config?: SearchPluginConfig<T>): SearchPluginInstance<T>;
|
|
84
112
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Selection Plugin
|
|
3
3
|
*/
|
|
4
4
|
export { selection, type SelectionPluginConfig } from "./plugin";
|
|
5
5
|
export { createSelectionState, selectOne, toggleOne, selectRange, selectRangeMut, selectAllItems, moveFocus, getSelectedArray, getSelectedItems, getSelectedItemsMut, type SelectionState, selectItems, deselectItems, toggleSelection, selectAll, clearSelection, isSelected, getSelectedIds, getSelectionCount, isSelectionEmpty, selectFocused, moveFocusUp, moveFocusDown, moveFocusToFirst, moveFocusToLast, moveFocusByPage, claimPlaceholderSelection, setFocusedIndex, } from "./state";
|
|
6
|
+
export type { SelectionMethods } from "./plugin";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Selection Plugin
|
|
3
3
|
*
|
|
4
4
|
* Manages selection state, click/keyboard handlers, ARIA attributes.
|
|
5
5
|
* Adapted from v1 withSelection feature + a11y.ts to the v2 plugin interface.
|
|
@@ -19,5 +19,26 @@ export interface SelectionPluginConfig {
|
|
|
19
19
|
*/
|
|
20
20
|
keyboard?: boolean;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
/** Methods the selection plugin adds to the list instance. */
|
|
23
|
+
export interface SelectionMethods<T extends VListItem = VListItem> {
|
|
24
|
+
/** Select one or more items by id. Does not move the viewport. */
|
|
25
|
+
select(...ids: Array<string | number>): void;
|
|
26
|
+
/** Deselect one or more items by id. */
|
|
27
|
+
deselect(...ids: Array<string | number>): void;
|
|
28
|
+
/** Toggle one item by id. */
|
|
29
|
+
toggleSelect(id: string | number): void;
|
|
30
|
+
/** Select every item (multiple mode only). */
|
|
31
|
+
selectAll(): void;
|
|
32
|
+
/** Clear the selection. */
|
|
33
|
+
clearSelection(): void;
|
|
34
|
+
/** Ids of the selected items. */
|
|
35
|
+
getSelected(): Array<string | number>;
|
|
36
|
+
/** The selected items. */
|
|
37
|
+
getSelectedItems(): T[];
|
|
38
|
+
/** Select the next item and scroll it into view. `select(id)` selects without moving the viewport. */
|
|
39
|
+
selectNext(): void;
|
|
40
|
+
/** Select the previous item and scroll it into view. `select(id)` selects without moving the viewport. */
|
|
41
|
+
selectPrevious(): void;
|
|
42
|
+
}
|
|
43
|
+
export declare function selection<T extends VListItem = VListItem>(config?: SelectionPluginConfig): VListPlugin<T, SelectionMethods<T>>;
|
|
23
44
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Snapshots Plugin
|
|
3
3
|
*
|
|
4
4
|
* Scroll save/restore for SPA navigation and tab switching.
|
|
5
5
|
* Captures the first visible item index + sub-pixel offset,
|
|
@@ -13,5 +13,12 @@ export interface SnapshotsPluginConfig {
|
|
|
13
13
|
restore?: ScrollSnapshot;
|
|
14
14
|
autoSave?: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/** Methods the snapshots plugin adds to the list instance. */
|
|
17
|
+
export interface SnapshotsMethods {
|
|
18
|
+
/** Capture the scroll position, anchor item and selection. */
|
|
19
|
+
getScrollSnapshot(): ScrollSnapshot;
|
|
20
|
+
/** Restore a snapshot; pass false to keep the current selection. */
|
|
21
|
+
restoreScroll(snapshot: ScrollSnapshot, restoreSelection?: boolean): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare function snapshots<T extends VListItem = VListItem>(config?: SnapshotsPluginConfig): VListPlugin<T, SnapshotsMethods>;
|
|
17
24
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Sortable Plugin
|
|
3
3
|
*
|
|
4
4
|
* Drag-and-drop reordering for virtual lists.
|
|
5
5
|
* Priority 30 — runs after layout plugins and scrollbar, before selection.
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
* The consumer reorders their data and calls `setItems()`.
|
|
18
18
|
*
|
|
19
19
|
* Restrictions:
|
|
20
|
-
* - Cannot be combined with grid, masonry, table
|
|
20
|
+
* - Cannot be combined with the grid, masonry, table or tree plugins
|
|
21
|
+
* - Cannot *yet* be combined with carousel: this plugin asks the size cache
|
|
22
|
+
* about a data index, and carousel makes it speak virtual ones. Fixable —
|
|
23
|
+
* see `conflicts` below.
|
|
21
24
|
*/
|
|
22
25
|
import type { VListItem } from "../../types";
|
|
23
26
|
import type { VListPlugin } from "../../core/types";
|
|
@@ -28,7 +31,15 @@ export interface SortablePluginConfig {
|
|
|
28
31
|
edgeScrollZone?: number;
|
|
29
32
|
edgeScrollSpeed?: number;
|
|
30
33
|
dragThreshold?: number;
|
|
34
|
+
/** Touch/pen hold delay without a handle, in milliseconds (default 350).
|
|
35
|
+
* Moving dragThreshold pixels before this expires yields to scrolling. */
|
|
36
|
+
touchDelay?: number;
|
|
31
37
|
ghostContainer?: HTMLElement;
|
|
32
38
|
}
|
|
33
|
-
|
|
39
|
+
/** Methods the sortable plugin adds to the list instance. */
|
|
40
|
+
export interface SortableMethods {
|
|
41
|
+
/** Whether a drag or keyboard sort is in progress. */
|
|
42
|
+
isSorting(): boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare function sortable<T extends VListItem = VListItem>(config?: SortablePluginConfig): VListPlugin<T, SortableMethods>;
|
|
34
45
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -7,4 +7,5 @@ export { createTableLayout } from "./layout";
|
|
|
7
7
|
export { createTableHeader } from "./header";
|
|
8
8
|
export { createTableRenderer, type TableRendererInstance } from "./renderer";
|
|
9
9
|
export type { TableConfig, TableColumn, TableFillMode, TableLayout, TableHeader, TableRenderer, ResolvedColumn, ColumnResizeEvent, ColumnSortEvent, ColumnClickEvent, } from "./types";
|
|
10
|
+
export type { TableMethods } from "./plugin";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Table Plugin
|
|
3
3
|
*
|
|
4
4
|
* Switches from list layout to a data table with columns, resizable headers,
|
|
5
5
|
* sticky header row, and cell-based rendering.
|
|
@@ -13,8 +13,24 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { VListItem } from "../../types";
|
|
15
15
|
import type { VListPlugin } from "../../core/types";
|
|
16
|
-
import type { TableConfig } from "./types";
|
|
16
|
+
import type { TableConfig, TableColumn } from "./types";
|
|
17
17
|
export interface TablePluginConfig<T extends VListItem = VListItem> extends TableConfig<T> {
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
/** Methods the table plugin adds to the list instance. */
|
|
20
|
+
export interface TableMethods<T extends VListItem = VListItem> {
|
|
21
|
+
/** Replace the column definitions. */
|
|
22
|
+
updateColumns(columns: TableColumn<T>[]): void;
|
|
23
|
+
/** Resize one column by key or index. */
|
|
24
|
+
resizeColumn(keyOrIndex: string | number, width: number): void;
|
|
25
|
+
/** Current width of every column, by key. */
|
|
26
|
+
getColumnWidths(): Record<string, number>;
|
|
27
|
+
/** Set the sort column and direction. */
|
|
28
|
+
setSort(key: string | null, direction?: "asc" | "desc"): void;
|
|
29
|
+
/** Current sort column and direction. */
|
|
30
|
+
getSort(): {
|
|
31
|
+
key: string | null;
|
|
32
|
+
direction: "asc" | "desc";
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare function table<T extends VListItem = VListItem>(config: TablePluginConfig<T>): VListPlugin<T, TableMethods<T>>;
|
|
20
36
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Tree Layout
|
|
3
3
|
*
|
|
4
4
|
* Manages the flat representation of a tree: DFS traversal, expand/collapse,
|
|
5
5
|
* surgical splice, and index lookups. All mutations target the flatNodes array
|
|
@@ -21,6 +21,8 @@ export interface TreeLayout<T extends VListItem> {
|
|
|
21
21
|
addChild(parentId: string | number | null, item: T, index?: number): void;
|
|
22
22
|
removeNode(id: string | number): number;
|
|
23
23
|
moveNode(id: string | number, newParentId: string | number | null, index?: number): void;
|
|
24
|
+
/** The source item, including one hidden inside a closed folder. */
|
|
25
|
+
findItem(id: string | number): T | undefined;
|
|
24
26
|
readonly totalVisible: number;
|
|
25
27
|
readonly rootItems: readonly T[];
|
|
26
28
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vlist
|
|
2
|
+
* vlist — Tree Plugin
|
|
3
3
|
*
|
|
4
4
|
* Renders hierarchical data as a virtualized, collapsible tree view with
|
|
5
5
|
* WAI-ARIA treeview keyboard navigation. Owns the tree→flat conversion
|
|
@@ -10,9 +10,43 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Replaces the render pipeline (like groups/grid/table) to maintain full
|
|
12
12
|
* control over tree-specific ARIA, CSS classes, indent, and expand/collapse.
|
|
13
|
+
*
|
|
14
|
+
* Restrictions:
|
|
15
|
+
* - Cannot be combined with `groups()`, `grid()`, `masonry()` or `table()`:
|
|
16
|
+
* each of those owns the layout, and so does this one.
|
|
17
|
+
* - Cannot be combined with `data()`, which claims the same data-access hooks
|
|
18
|
+
* and would replace them. Use `loadChildren` for async tree data.
|
|
13
19
|
*/
|
|
14
20
|
import type { VListItem } from "../../types";
|
|
15
21
|
import type { VListPlugin } from "../../core/types";
|
|
16
|
-
import type { TreePluginConfig } from "./types";
|
|
17
|
-
|
|
22
|
+
import type { TreePluginConfig, FlatNode } from "./types";
|
|
23
|
+
/** Methods the tree plugin adds to the list instance. */
|
|
24
|
+
export interface TreeMethods<T extends VListItem = VListItem> {
|
|
25
|
+
/** Expand one node. */
|
|
26
|
+
expand(id: string | number): void;
|
|
27
|
+
/** Collapse one node. */
|
|
28
|
+
collapse(id: string | number): void;
|
|
29
|
+
/** Toggle one node. */
|
|
30
|
+
toggle(id: string | number): void;
|
|
31
|
+
/** Expand every node. */
|
|
32
|
+
expandAll(): void;
|
|
33
|
+
/** Collapse every node. */
|
|
34
|
+
collapseAll(): void;
|
|
35
|
+
/** Expand every ancestor of a node so it becomes visible. */
|
|
36
|
+
expandTo(id: string | number): void;
|
|
37
|
+
/** Ids of the expanded nodes. */
|
|
38
|
+
getExpanded(): (string | number)[];
|
|
39
|
+
/** Whether a node is expanded. */
|
|
40
|
+
isExpanded(id: string | number): boolean;
|
|
41
|
+
/** Add a child under a parent, or at the root when parentId is null. */
|
|
42
|
+
addChild(parentId: string | number | null, item: T, index?: number): void;
|
|
43
|
+
/** Move a node under a new parent. */
|
|
44
|
+
moveNode(id: string | number, newParentId: string | number | null, index?: number): void;
|
|
45
|
+
/** Visible node count and the flattened nodes. */
|
|
46
|
+
getTreeLayout(): {
|
|
47
|
+
totalVisible: number;
|
|
48
|
+
flatNodes: FlatNode<T>[];
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare function tree<T extends VListItem = VListItem>(config?: TreePluginConfig<T>): VListPlugin<T, TreeMethods<T>>;
|
|
18
52
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -23,6 +23,18 @@ export interface SizeCache {
|
|
|
23
23
|
getTotal(): number;
|
|
24
24
|
/** Rebuild cache (call when items change) */
|
|
25
25
|
rebuild(totalItems: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Re-read the sizes of `startIndex..endIndex`, an ascending in-range pair —
|
|
28
|
+
* cost independent of the total item count.
|
|
29
|
+
*
|
|
30
|
+
* Use this instead of `rebuild` when a handful of item sizes changed but the
|
|
31
|
+
* item count did not: a measurement batch from `autosize()`, say. The
|
|
32
|
+
* variable cache re-reads the size function only for the blocks the range
|
|
33
|
+
* touches, where `rebuild` re-reads every item. Out-of-range bounds are
|
|
34
|
+
* ignored. On the fixed cache this is a no-op, since every item is the same
|
|
35
|
+
* size.
|
|
36
|
+
*/
|
|
37
|
+
invalidate(startIndex: number, endIndex?: number): void;
|
|
26
38
|
/** Whether sizes are variable (false = fixed fast path) */
|
|
27
39
|
isVariable(): boolean;
|
|
28
40
|
}
|
|
@@ -31,8 +43,14 @@ export interface SizeCache {
|
|
|
31
43
|
*
|
|
32
44
|
* When size is a number, returns a zero-overhead fixed implementation.
|
|
33
45
|
* When size is a function, builds a prefix-sum array for efficient lookups.
|
|
46
|
+
*
|
|
47
|
+
* `gap` is the spacing already baked into each slot by the caller's size spec.
|
|
48
|
+
* The cache subtracts one trailing gap from the total, because the space after
|
|
49
|
+
* the last item is not content. Pass 0 when the spec carries no gap. Core,
|
|
50
|
+
* autosize and grid each re-implemented this correction, and a plugin that
|
|
51
|
+
* replaced the size config silently dropped whichever copy was installed.
|
|
34
52
|
*/
|
|
35
|
-
export declare const createSizeCache: (size: number | ((index: number) => number), initialTotal: number) => SizeCache;
|
|
53
|
+
export declare const createSizeCache: (size: number | ((index: number) => number), initialTotal: number, gap?: number) => SizeCache;
|
|
36
54
|
/**
|
|
37
55
|
* Count how many items fit in a given container size starting from startIndex
|
|
38
56
|
* Used for compressed mode visible range calculations
|
package/dist/size.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"base":{"minified":"
|
|
1
|
+
{"base":{"minified":"27.0","gzipped":"10.0","minBytes":27603,"gzBytes":10201},"synthetic":{"minified":"33.9","gzipped":"12.6","minBytes":34667,"gzBytes":12893},"synthetic + carousel":{"minified":"47.8","gzipped":"17.4","minBytes":48925,"gzBytes":17837},"synthetic + sortable":{"minified":"45.7","gzipped":"16.1","minBytes":46780,"gzBytes":16517},"createStats":{"minified":"27.5","gzipped":"10.2","minBytes":28205,"gzBytes":10435},"synthetic + createStats":{"minified":"34.4","gzipped":"12.8","minBytes":35269,"gzBytes":13118},"native":{"minified":"27.0","gzipped":"10.0","minBytes":27603,"gzBytes":10198},"a11y":{"minified":"30.8","gzipped":"11.3","minBytes":31497,"gzBytes":11616},"selection":{"minified":"36.4","gzipped":"12.9","minBytes":37319,"gzBytes":13177},"data":{"minified":"40.6","gzipped":"14.8","minBytes":41559,"gzBytes":15110},"scrollbar":{"minified":"35.1","gzipped":"12.8","minBytes":35931,"gzBytes":13145},"sortable":{"minified":"38.7","gzipped":"13.4","minBytes":39668,"gzBytes":13768},"groups":{"minified":"43.0","gzipped":"15.4","minBytes":44057,"gzBytes":15722},"page":{"minified":"29.5","gzipped":"10.9","minBytes":30205,"gzBytes":11134},"snapshots":{"minified":"30.3","gzipped":"11.1","minBytes":30982,"gzBytes":11373},"transition":{"minified":"33.7","gzipped":"12.0","minBytes":34485,"gzBytes":12240},"autosize":{"minified":"30.2","gzipped":"11.1","minBytes":30884,"gzBytes":11367},"grid":{"minified":"34.4","gzipped":"12.5","minBytes":35196,"gzBytes":12846},"table":{"minified":"45.4","gzipped":"15.9","minBytes":46488,"gzBytes":16277},"masonry":{"minified":"39.0","gzipped":"14.4","minBytes":39986,"gzBytes":14734},"tree":{"minified":"43.1","gzipped":"15.3","minBytes":44181,"gzBytes":15712},"search":{"minified":"36.5","gzipped":"13.3","minBytes":37367,"gzBytes":13594},"carousel":{"minified":"41.7","gzipped":"15.2","minBytes":42706,"gzBytes":15517}}
|
package/dist/synthetic.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CreateVListConfig, VList, VListPlugin } from "./core/types";
|
|
1
|
+
import type { CreateVListConfig, PluginMethods, VList, VListPlugin } from "./core/types";
|
|
2
2
|
import type { VListItem } from "./types";
|
|
3
3
|
export type { CreateVListConfig as SyntheticVListConfig } from "./core/types";
|
|
4
|
-
export declare function createVList<T extends VListItem = VListItem>(config: CreateVListConfig<T>, plugins?:
|
|
4
|
+
export declare function createVList<T extends VListItem = VListItem, const P extends readonly VListPlugin<T, any>[] = VListPlugin<T>[]>(config: CreateVListConfig<T>, plugins?: P): VList<T> & PluginMethods<P>;
|
|
5
5
|
//# sourceMappingURL=synthetic.d.ts.map
|