@floor/vlist 0.5.8 → 0.6.1
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.md +787 -611
- package/dist/async/index.js +1 -0
- package/dist/builder/context.d.ts +3 -3
- package/dist/builder/context.d.ts.map +1 -1
- package/dist/builder/core.d.ts +1 -1
- package/dist/builder/core.d.ts.map +1 -1
- package/dist/builder/types.d.ts +3 -3
- package/dist/builder/types.d.ts.map +1 -1
- package/dist/core/full.d.ts +22 -0
- package/dist/core/full.d.ts.map +1 -0
- package/dist/core/lite.d.ts +129 -0
- package/dist/core/lite.d.ts.map +1 -0
- package/dist/core/minimal.d.ts +104 -0
- package/dist/core/minimal.d.ts.map +1 -0
- package/dist/features/async/index.d.ts +9 -0
- package/dist/features/async/index.d.ts.map +1 -0
- package/dist/features/async/manager.d.ts +103 -0
- package/dist/features/async/manager.d.ts.map +1 -0
- package/dist/features/async/placeholder.d.ts +62 -0
- package/dist/features/async/placeholder.d.ts.map +1 -0
- package/dist/features/async/plugin.d.ts +60 -0
- package/dist/features/async/plugin.d.ts.map +1 -0
- package/dist/features/async/sparse.d.ts +91 -0
- package/dist/features/async/sparse.d.ts.map +1 -0
- package/dist/features/grid/index.d.ts +9 -0
- package/dist/features/grid/index.d.ts.map +1 -0
- package/dist/features/grid/layout.d.ts +29 -0
- package/dist/features/grid/layout.d.ts.map +1 -0
- package/dist/features/grid/plugin.d.ts +48 -0
- package/dist/features/grid/plugin.d.ts.map +1 -0
- package/dist/features/grid/renderer.d.ts +55 -0
- package/dist/features/grid/renderer.d.ts.map +1 -0
- package/dist/features/grid/types.d.ts +71 -0
- package/dist/features/grid/types.d.ts.map +1 -0
- package/dist/features/page/index.d.ts +8 -0
- package/dist/features/page/index.d.ts.map +1 -0
- package/dist/features/page/plugin.d.ts +53 -0
- package/dist/features/page/plugin.d.ts.map +1 -0
- package/dist/features/scale/index.d.ts +10 -0
- package/dist/features/scale/index.d.ts.map +1 -0
- package/dist/features/scale/plugin.d.ts +42 -0
- package/dist/features/scale/plugin.d.ts.map +1 -0
- package/dist/features/scrollbar/controller.d.ts +121 -0
- package/dist/features/scrollbar/controller.d.ts.map +1 -0
- package/dist/features/scrollbar/index.d.ts +8 -0
- package/dist/features/scrollbar/index.d.ts.map +1 -0
- package/dist/features/scrollbar/plugin.d.ts +60 -0
- package/dist/features/scrollbar/plugin.d.ts.map +1 -0
- package/dist/features/scrollbar/scrollbar.d.ts +73 -0
- package/dist/features/scrollbar/scrollbar.d.ts.map +1 -0
- package/dist/features/sections/index.d.ts +10 -0
- package/dist/features/sections/index.d.ts.map +1 -0
- package/dist/features/sections/layout.d.ts +46 -0
- package/dist/features/sections/layout.d.ts.map +1 -0
- package/dist/features/sections/plugin.d.ts +64 -0
- package/dist/features/sections/plugin.d.ts.map +1 -0
- package/dist/features/sections/sticky.d.ts +33 -0
- package/dist/features/sections/sticky.d.ts.map +1 -0
- package/dist/features/sections/types.d.ts +86 -0
- package/dist/features/sections/types.d.ts.map +1 -0
- package/dist/features/selection/index.d.ts +7 -0
- package/dist/features/selection/index.d.ts.map +1 -0
- package/dist/features/selection/plugin.d.ts +44 -0
- package/dist/features/selection/plugin.d.ts.map +1 -0
- package/dist/features/selection/state.d.ts +102 -0
- package/dist/features/selection/state.d.ts.map +1 -0
- package/dist/features/snapshots/index.d.ts +8 -0
- package/dist/features/snapshots/index.d.ts.map +1 -0
- package/dist/features/snapshots/plugin.d.ts +44 -0
- package/dist/features/snapshots/plugin.d.ts.map +1 -0
- package/dist/grid/index.js +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/page/index.js +1 -0
- package/dist/react/index.js +1 -1
- package/dist/rendering/heights.d.ts +63 -0
- package/dist/rendering/heights.d.ts.map +1 -0
- package/dist/rendering/index.d.ts +9 -0
- package/dist/rendering/index.d.ts.map +1 -0
- package/dist/rendering/renderer.d.ts +103 -0
- package/dist/rendering/renderer.d.ts.map +1 -0
- package/dist/rendering/scale.d.ts +116 -0
- package/dist/rendering/scale.d.ts.map +1 -0
- package/dist/rendering/viewport.d.ts +139 -0
- package/dist/rendering/viewport.d.ts.map +1 -0
- package/dist/scale/index.js +1 -0
- package/dist/scrollbar/index.js +1 -0
- package/dist/sections/index.js +1 -0
- package/dist/selection/index.js +1 -1
- package/dist/svelte/index.js +1 -1
- package/dist/vue/index.js +1 -1
- package/package.json +1 -51
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/scrollbar/controller.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAM9D,uBAAuB;AACvB,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,CAAC;AAE5C,wBAAwB;AACxB,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,eAAe,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,sCAAsC;AACtC,MAAM,WAAW,sBAAsB;IACrC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,kDAAkD;IAClD,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAE3C,2CAA2C;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BA+eF,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAC5D,IAAI,CAAC,KACJ,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAyB3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,WAAW,MAAM,EACjB,cAAc,MAAM,EACpB,cAAc,MAAM,EACpB,kBAAa,KACZ,OAEF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,WAAW,MAAM,EAAE,kBAAa,KAAG,OAE1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,EACjB,cAAc,MAAM,EACpB,cAAc,MAAM,KACnB,MAIF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,EAClB,UAAU,MAAM,EAChB,cAAc,MAAM,EACpB,YAAY,MAAM,KACjB,OAEF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Scroll Domain
|
|
3
|
+
* Scroll controller and custom scrollbar
|
|
4
|
+
*/
|
|
5
|
+
export { withScrollbar, type ScrollbarPluginConfig } from "./plugin";
|
|
6
|
+
export { createScrollController, rafThrottle, isAtBottom, isAtTop, getScrollPercentage, isRangeVisible, type ScrollController, type ScrollControllerConfig, type ScrollEventData, type ScrollDirection, } from "./controller";
|
|
7
|
+
export { createScrollbar, type Scrollbar, type ScrollbarConfig, type ScrollCallback, } from "./scrollbar";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/scrollbar/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGrE,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,eAAe,EACf,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist/scroll - Builder Plugin
|
|
3
|
+
* Wraps the custom scrollbar into a VListPlugin for the composable builder.
|
|
4
|
+
*
|
|
5
|
+
* Priority: 30 (runs after renderer/data setup but before selection)
|
|
6
|
+
*
|
|
7
|
+
* What it wires:
|
|
8
|
+
* - DOM elements — track, thumb, and optional hover zone appended to viewport
|
|
9
|
+
* - CSS class — .vlist-viewport--custom-scrollbar hides native scrollbar
|
|
10
|
+
* - Drag handlers — mousedown on thumb, mousemove/mouseup on document
|
|
11
|
+
* - Track click — click on track to jump to position
|
|
12
|
+
* - Hover handlers — mouseenter/leave on track, hover zone, and viewport
|
|
13
|
+
* - Scroll sync — updates thumb position on every scroll frame
|
|
14
|
+
* - Resize sync — updates thumb size when container or content height changes
|
|
15
|
+
*
|
|
16
|
+
* No public methods are added — the scrollbar is entirely automatic.
|
|
17
|
+
*/
|
|
18
|
+
import type { VListItem } from "../../types";
|
|
19
|
+
import type { VListPlugin } from "../../builder/types";
|
|
20
|
+
/** Scrollbar plugin configuration */
|
|
21
|
+
export interface ScrollbarPluginConfig {
|
|
22
|
+
/** Auto-hide scrollbar after idle (default: true) */
|
|
23
|
+
autoHide?: boolean;
|
|
24
|
+
/** Auto-hide delay in milliseconds (default: 1000) */
|
|
25
|
+
autoHideDelay?: number;
|
|
26
|
+
/** Minimum thumb size in pixels (default: 30) */
|
|
27
|
+
minThumbSize?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Show scrollbar when hovering near the scrollbar edge (default: true).
|
|
30
|
+
* When true, an invisible hover zone is placed along the scrollbar edge.
|
|
31
|
+
*/
|
|
32
|
+
showOnHover?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Width of the invisible hover zone in pixels (default: 16).
|
|
35
|
+
* Only used when `showOnHover` is true.
|
|
36
|
+
*/
|
|
37
|
+
hoverZoneWidth?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Show scrollbar when the mouse enters the list viewport (default: true).
|
|
40
|
+
* When false, the scrollbar only appears on scroll or hover near edge.
|
|
41
|
+
*/
|
|
42
|
+
showOnViewportEnter?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a scrollbar plugin for the builder.
|
|
46
|
+
*
|
|
47
|
+
* Replaces the native browser scrollbar with a custom, cross-browser
|
|
48
|
+
* consistent scrollbar.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { vlist } from 'vlist/builder'
|
|
52
|
+
* import { withScrollbar } from 'vlist/scroll'
|
|
53
|
+
*
|
|
54
|
+
* const list = vlist({ ... })
|
|
55
|
+
* .use(withScrollbar({ autoHide: true, autoHideDelay: 1000 }))
|
|
56
|
+
* .build()
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const withScrollbar: <T extends VListItem = VListItem>(config?: ScrollbarPluginConfig) => VListPlugin<T>;
|
|
60
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/features/scrollbar/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAC;AAQvE,qCAAqC;AACrC,MAAM,WAAW,qBAAqB;IACpC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAMD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAC3D,SAAS,qBAAqB,KAC7B,WAAW,CAAC,CAAC,CAgFf,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Custom Scrollbar
|
|
3
|
+
* Provides visual scroll indication for compressed mode where native scrollbar is hidden
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Visual track and thumb
|
|
7
|
+
* - Thumb size proportional to visible content
|
|
8
|
+
* - Click on track to jump to position
|
|
9
|
+
* - Drag thumb to scroll
|
|
10
|
+
* - Auto-hide after idle (optional)
|
|
11
|
+
* - Show on hover with configurable hover zone (optional)
|
|
12
|
+
* - CSS variables for customization
|
|
13
|
+
* - Horizontal mode support (direction-aware axis)
|
|
14
|
+
*/
|
|
15
|
+
/** Scrollbar configuration */
|
|
16
|
+
export interface ScrollbarConfig {
|
|
17
|
+
/** Enable scrollbar (default: true when compressed) */
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
/** Auto-hide scrollbar after idle (default: true) */
|
|
20
|
+
autoHide?: boolean;
|
|
21
|
+
/** Auto-hide delay in milliseconds (default: 1000) */
|
|
22
|
+
autoHideDelay?: number;
|
|
23
|
+
/** Minimum thumb size in pixels (default: 30) */
|
|
24
|
+
minThumbSize?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Show scrollbar when hovering near the scrollbar edge (default: true).
|
|
27
|
+
* When true, an invisible hover zone is placed along the scrollbar edge.
|
|
28
|
+
* Moving the mouse into this zone reveals the scrollbar; it stays visible
|
|
29
|
+
* as long as the cursor remains over the zone or the track.
|
|
30
|
+
*/
|
|
31
|
+
showOnHover?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Width of the invisible hover zone in pixels (default: 16).
|
|
34
|
+
* Only used when `showOnHover` is true.
|
|
35
|
+
* A wider zone makes the scrollbar easier to discover;
|
|
36
|
+
* a narrower zone avoids interference with content near the edge.
|
|
37
|
+
*/
|
|
38
|
+
hoverZoneWidth?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Show scrollbar when the mouse enters the list viewport (default: true).
|
|
41
|
+
* When false, the scrollbar only appears on scroll or when hovering
|
|
42
|
+
* near the scrollbar edge (if `showOnHover` is true).
|
|
43
|
+
*/
|
|
44
|
+
showOnViewportEnter?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Scrollbar instance */
|
|
47
|
+
export interface Scrollbar {
|
|
48
|
+
/** Show the scrollbar */
|
|
49
|
+
show: () => void;
|
|
50
|
+
/** Hide the scrollbar */
|
|
51
|
+
hide: () => void;
|
|
52
|
+
/** Update scrollbar dimensions based on content/container size */
|
|
53
|
+
updateBounds: (totalHeight: number, containerHeight: number) => void;
|
|
54
|
+
/** Update thumb position based on scroll position */
|
|
55
|
+
updatePosition: (scrollTop: number) => void;
|
|
56
|
+
/** Check if scrollbar is visible */
|
|
57
|
+
isVisible: () => boolean;
|
|
58
|
+
/** Destroy and cleanup */
|
|
59
|
+
destroy: () => void;
|
|
60
|
+
}
|
|
61
|
+
/** Callback for scroll position changes */
|
|
62
|
+
export type ScrollCallback = (position: number) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Create a scrollbar instance
|
|
65
|
+
*
|
|
66
|
+
* @param viewport - The viewport element to attach scrollbar to
|
|
67
|
+
* @param onScroll - Callback when scrollbar interaction causes scroll
|
|
68
|
+
* @param config - Scrollbar configuration
|
|
69
|
+
* @param classPrefix - CSS class prefix (default: 'vlist')
|
|
70
|
+
* @param horizontal - Whether the scrollbar is horizontal (default: false)
|
|
71
|
+
*/
|
|
72
|
+
export declare const createScrollbar: (viewport: HTMLElement, onScroll: ScrollCallback, config?: ScrollbarConfig, classPrefix?: string, horizontal?: boolean) => Scrollbar;
|
|
73
|
+
//# sourceMappingURL=scrollbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollbar.d.ts","sourceRoot":"","sources":["../../../src/features/scrollbar/scrollbar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,8BAA8B;AAC9B,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,yBAAyB;AACzB,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB,yBAAyB;IACzB,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB,kEAAkE;IAClE,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;IAErE,qDAAqD;IACrD,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C,oCAAoC;IACpC,SAAS,EAAE,MAAM,OAAO,CAAC;IAEzB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,2CAA2C;AAC3C,MAAM,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;AAiBxD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,WAAW,EACrB,UAAU,cAAc,EACxB,SAAQ,eAAoB,EAC5B,oBAAqB,EACrB,oBAAkB,KACjB,SA4XF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Groups Domain
|
|
3
|
+
* Sticky headers and grouped lists
|
|
4
|
+
*/
|
|
5
|
+
export { withSections, type GroupsPluginConfig } from "./plugin";
|
|
6
|
+
export type { GroupsConfig, GroupBoundary, LayoutEntry, GroupHeaderItem, GroupLayout, StickyHeader, } from "./types";
|
|
7
|
+
export { isGroupHeader, isGroupHeader as isSectionHeader } from "./types";
|
|
8
|
+
export { createGroupLayout, buildLayoutItems, createGroupedHeightFn, } from "./layout";
|
|
9
|
+
export { createStickyHeader } from "./sticky";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/sections/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGjE,YAAY,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,eAAe,EACf,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,aAAa,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Group Layout
|
|
3
|
+
* Computes group boundaries and maps between data indices and layout indices.
|
|
4
|
+
*
|
|
5
|
+
* The layout transforms a flat items array into a "layout" that includes
|
|
6
|
+
* group header pseudo-items interspersed at group boundaries:
|
|
7
|
+
*
|
|
8
|
+
* Data: [item0, item1, item2, item3, item4, item5]
|
|
9
|
+
* Groups: [ A, A, A, B, B, C ]
|
|
10
|
+
* Layout: [headerA, item0, item1, item2, headerB, item3, item4, headerC, item5]
|
|
11
|
+
* Index: [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
|
|
12
|
+
*
|
|
13
|
+
* All lookups are O(log g) where g = number of groups, using binary search
|
|
14
|
+
* on the sorted group boundaries array.
|
|
15
|
+
*/
|
|
16
|
+
import type { GroupsConfig, GroupBoundary, GroupLayout, GroupHeaderItem } from "./types";
|
|
17
|
+
import type { VListItem } from "../../types";
|
|
18
|
+
/**
|
|
19
|
+
* Build the transformed layout items array with header pseudo-items inserted
|
|
20
|
+
* at group boundaries.
|
|
21
|
+
*
|
|
22
|
+
* @param items - Original data items
|
|
23
|
+
* @param groups - Computed group boundaries
|
|
24
|
+
* @returns Array of items and header pseudo-items in layout order
|
|
25
|
+
*/
|
|
26
|
+
export declare const buildLayoutItems: <T extends VListItem>(items: T[], groups: readonly GroupBoundary[]) => Array<T | GroupHeaderItem>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a height function for the layout that returns the correct height
|
|
29
|
+
* for both group headers and data items.
|
|
30
|
+
*
|
|
31
|
+
* @param layout - The group layout instance
|
|
32
|
+
* @param itemHeight - Original item height config (number or function)
|
|
33
|
+
* @returns A height function (layoutIndex) => number suitable for HeightCache
|
|
34
|
+
*/
|
|
35
|
+
export declare const createGroupedHeightFn: (layout: GroupLayout, itemHeight: number | ((index: number) => number)) => ((layoutIndex: number) => number);
|
|
36
|
+
/**
|
|
37
|
+
* Create a GroupLayout instance.
|
|
38
|
+
*
|
|
39
|
+
* The layout computes group boundaries from items and provides efficient
|
|
40
|
+
* O(log g) mappings between data indices and layout indices.
|
|
41
|
+
*
|
|
42
|
+
* @param itemCount - Number of data items
|
|
43
|
+
* @param config - Groups configuration
|
|
44
|
+
*/
|
|
45
|
+
export declare const createGroupLayout: (itemCount: number, config: GroupsConfig) => GroupLayout;
|
|
46
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/features/sections/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EAEX,eAAe,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA+G7C;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,SAAS,EAClD,OAAO,CAAC,EAAE,EACV,QAAQ,SAAS,aAAa,EAAE,KAC/B,KAAK,CAAC,CAAC,GAAG,eAAe,CA0B3B,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,WAAW,EACnB,YAAY,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,KAC/C,CAAC,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAelC,CAAC;AAMF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,WAAW,MAAM,EACjB,QAAQ,YAAY,KACnB,WAkIF,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist/groups - Builder Plugin
|
|
3
|
+
* Adds grouped lists with sticky section headers.
|
|
4
|
+
*
|
|
5
|
+
* Priority: 10 (runs first — transforms item list and height function before rendering)
|
|
6
|
+
*
|
|
7
|
+
* What it wires:
|
|
8
|
+
* - Transforms item list — inserts header items at group boundaries
|
|
9
|
+
* - Replaces height function — headers use headerHeight, data items use configured item.height
|
|
10
|
+
* - Unified template — dispatches to headerTemplate for headers, user template for items
|
|
11
|
+
* - Sticky header DOM — creates a positioned header element that updates as you scroll
|
|
12
|
+
* - Index mapping — translates between data indices and layout indices
|
|
13
|
+
* - CSS class — adds .vlist--grouped to the root element
|
|
14
|
+
*
|
|
15
|
+
* Restrictions:
|
|
16
|
+
* - Items must be pre-sorted by group
|
|
17
|
+
* - Cannot be combined with direction: 'horizontal'
|
|
18
|
+
*
|
|
19
|
+
* Can be combined with:
|
|
20
|
+
* - withGrid for grouped 2D layouts
|
|
21
|
+
* - reverse: true (sticky header shows current section as you scroll up through history)
|
|
22
|
+
*/
|
|
23
|
+
import type { VListItem } from "../../types";
|
|
24
|
+
import type { VListPlugin } from "../../builder/types";
|
|
25
|
+
/** Groups plugin configuration */
|
|
26
|
+
export interface GroupsPluginConfig {
|
|
27
|
+
/** Returns group key for item at index (required) */
|
|
28
|
+
getGroupForIndex: (index: number) => string;
|
|
29
|
+
/** Height of group headers in pixels (required) */
|
|
30
|
+
headerHeight: number;
|
|
31
|
+
/** Render function for headers (required) */
|
|
32
|
+
headerTemplate: (key: string, groupIndex: number) => HTMLElement | string;
|
|
33
|
+
/** Enable sticky headers — iOS Contacts style (default: true) */
|
|
34
|
+
sticky?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a groups plugin for the builder.
|
|
38
|
+
*
|
|
39
|
+
* Adds grouped lists with sticky section headers.
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { vlist } from 'vlist/builder'
|
|
43
|
+
* import { withGroups } from 'vlist/groups'
|
|
44
|
+
*
|
|
45
|
+
* const contacts = vlist({
|
|
46
|
+
* container: '#contacts',
|
|
47
|
+
* item: { height: 56, template: renderContact },
|
|
48
|
+
* items: sortedContacts,
|
|
49
|
+
* })
|
|
50
|
+
* .use(withGroups({
|
|
51
|
+
* getGroupForIndex: (i) => sortedContacts[i].lastName[0],
|
|
52
|
+
* headerHeight: 32,
|
|
53
|
+
* headerTemplate: (letter) => {
|
|
54
|
+
* const el = document.createElement('div')
|
|
55
|
+
* el.className = 'letter-header'
|
|
56
|
+
* el.textContent = letter
|
|
57
|
+
* return el
|
|
58
|
+
* },
|
|
59
|
+
* }))
|
|
60
|
+
* .build()
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const withSections: <T extends VListItem = VListItem>(config: GroupsPluginConfig) => VListPlugin<T>;
|
|
64
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/features/sections/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAC;AAuBvE,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAE5C,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC;IAE1E,iEAAiE;IACjE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAC1D,QAAQ,kBAAkB,KACzB,WAAW,CAAC,CAAC,CAmRf,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Sticky Header
|
|
3
|
+
* Manages a floating header element that "sticks" to the top of the viewport
|
|
4
|
+
* and transitions smoothly when the next group's header approaches.
|
|
5
|
+
*
|
|
6
|
+
* The sticky header is a separate DOM element positioned absolutely at the
|
|
7
|
+
* top of the root container. It overlays the scrolling content and shows
|
|
8
|
+
* the current group's header. When the next group's inline header scrolls
|
|
9
|
+
* into view, the sticky header is pushed upward to create the classic
|
|
10
|
+
* iOS Contacts-style transition effect.
|
|
11
|
+
*
|
|
12
|
+
* Layout:
|
|
13
|
+
* .vlist (root, position: relative)
|
|
14
|
+
* ├── .vlist-sticky-header (position: absolute, top: 0, z-index: 5)
|
|
15
|
+
* │ └── (content rendered by headerTemplate)
|
|
16
|
+
* └── .vlist-viewport
|
|
17
|
+
* └── .vlist-content
|
|
18
|
+
* └── .vlist-items
|
|
19
|
+
*/
|
|
20
|
+
import type { GroupLayout, GroupsConfig, StickyHeader } from "./types";
|
|
21
|
+
import type { HeightCache } from "../../rendering/heights";
|
|
22
|
+
/**
|
|
23
|
+
* Create a sticky header manager.
|
|
24
|
+
*
|
|
25
|
+
* @param root - The vlist root element (.vlist) — sticky header is appended here
|
|
26
|
+
* @param layout - Group layout for index/group resolution
|
|
27
|
+
* @param heightCache - The LAYOUT height cache (includes headers)
|
|
28
|
+
* @param config - Groups configuration (headerTemplate, headerHeight)
|
|
29
|
+
* @param classPrefix - CSS class prefix (default: 'vlist')
|
|
30
|
+
* @returns StickyHeader instance
|
|
31
|
+
*/
|
|
32
|
+
export declare const createStickyHeader: (root: HTMLElement, layout: GroupLayout, heightCache: HeightCache, config: GroupsConfig, classPrefix: string) => StickyHeader;
|
|
33
|
+
//# sourceMappingURL=sticky.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["../../../src/features/sections/sticky.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM3D;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,WAAW,EACjB,QAAQ,WAAW,EACnB,aAAa,WAAW,EACxB,QAAQ,YAAY,EACpB,aAAa,MAAM,KAClB,YAgMF,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Group Types
|
|
3
|
+
* Types for sticky headers and grouped lists
|
|
4
|
+
*/
|
|
5
|
+
import type { VListItem, GroupsConfig } from "../../types";
|
|
6
|
+
export type { GroupsConfig };
|
|
7
|
+
/** A single group boundary */
|
|
8
|
+
export interface GroupBoundary {
|
|
9
|
+
/** Group key (return value of getGroupForIndex) */
|
|
10
|
+
key: string;
|
|
11
|
+
/** Sequential group index (0-based) */
|
|
12
|
+
groupIndex: number;
|
|
13
|
+
/** Layout index of this group's header */
|
|
14
|
+
headerLayoutIndex: number;
|
|
15
|
+
/** Data index of the first item in this group */
|
|
16
|
+
firstDataIndex: number;
|
|
17
|
+
/** Number of data items in this group */
|
|
18
|
+
count: number;
|
|
19
|
+
}
|
|
20
|
+
/** Entry type in the layout — either a group header or a data item */
|
|
21
|
+
export type LayoutEntry = {
|
|
22
|
+
type: "header";
|
|
23
|
+
group: GroupBoundary;
|
|
24
|
+
} | {
|
|
25
|
+
type: "item";
|
|
26
|
+
dataIndex: number;
|
|
27
|
+
group: GroupBoundary;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Internal marker for group header pseudo-items inserted into the layout.
|
|
31
|
+
* These are interleaved with real data items in the transformed items array.
|
|
32
|
+
*/
|
|
33
|
+
export interface GroupHeaderItem extends VListItem {
|
|
34
|
+
/** Always `__group_header_{groupIndex}` */
|
|
35
|
+
id: string;
|
|
36
|
+
/** Discriminator flag */
|
|
37
|
+
__groupHeader: true;
|
|
38
|
+
/** The group key */
|
|
39
|
+
groupKey: string;
|
|
40
|
+
/** Sequential group index (0-based) */
|
|
41
|
+
groupIndex: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Type guard: check if an item is a group header pseudo-item
|
|
45
|
+
*/
|
|
46
|
+
export declare const isGroupHeader: (item: unknown) => item is GroupHeaderItem;
|
|
47
|
+
/** Group layout — maps between data indices and layout indices */
|
|
48
|
+
export interface GroupLayout {
|
|
49
|
+
/** Total layout entries (data items + group headers) */
|
|
50
|
+
readonly totalEntries: number;
|
|
51
|
+
/** Number of groups */
|
|
52
|
+
readonly groupCount: number;
|
|
53
|
+
/** All group boundaries, in order */
|
|
54
|
+
readonly groups: readonly GroupBoundary[];
|
|
55
|
+
/** Get the layout entry at a layout index — O(log g) */
|
|
56
|
+
getEntry: (layoutIndex: number) => LayoutEntry;
|
|
57
|
+
/** Map layout index → data index, or -1 if it's a header — O(log g) */
|
|
58
|
+
layoutToDataIndex: (layoutIndex: number) => number;
|
|
59
|
+
/** Map data index → layout index — O(log g) */
|
|
60
|
+
dataToLayoutIndex: (dataIndex: number) => number;
|
|
61
|
+
/** Get the group boundary that contains a given layout index — O(log g) */
|
|
62
|
+
getGroupAtLayoutIndex: (layoutIndex: number) => GroupBoundary;
|
|
63
|
+
/** Get the group boundary that contains a given data index — O(log g) */
|
|
64
|
+
getGroupAtDataIndex: (dataIndex: number) => GroupBoundary;
|
|
65
|
+
/** Get header height for a group */
|
|
66
|
+
getHeaderHeight: (groupIndex: number) => number;
|
|
67
|
+
/**
|
|
68
|
+
* Rebuild the layout from scratch.
|
|
69
|
+
* Call when items change (setItems, append, prepend, remove, etc.)
|
|
70
|
+
*/
|
|
71
|
+
rebuild: (itemCount: number) => void;
|
|
72
|
+
}
|
|
73
|
+
/** Sticky header manager */
|
|
74
|
+
export interface StickyHeader {
|
|
75
|
+
/** Update sticky header position and content based on scroll position */
|
|
76
|
+
update: (scrollTop: number) => void;
|
|
77
|
+
/** Force refresh the sticky header content (e.g. after items change) */
|
|
78
|
+
refresh: () => void;
|
|
79
|
+
/** Show the sticky header */
|
|
80
|
+
show: () => void;
|
|
81
|
+
/** Hide the sticky header */
|
|
82
|
+
hide: () => void;
|
|
83
|
+
/** Destroy and remove the sticky header DOM element */
|
|
84
|
+
destroy: () => void;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/features/sections/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3D,YAAY,EAAE,YAAY,EAAE,CAAC;AAM7B,8BAA8B;AAC9B,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IAEZ,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IAEnB,0CAA0C;IAC1C,iBAAiB,EAAE,MAAM,CAAC;IAE1B,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAC;IAEvB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,sEAAsE;AACtE,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAAC;AAM9D;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IAEX,yBAAyB;IACzB,aAAa,EAAE,IAAI,CAAC;IAEpB,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IAEjB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,OAAO,KAAG,IAAI,IAAI,eAMrD,CAAC;AAMF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electionPluginConfig } from "./plugin";
|
|
6
|
+
export { createSelectionState, selectItems, deselectItems, toggleSelection, selectAll, clearSelection, setFocusedIndex, moveFocusUp, moveFocusDown, moveFocusToFirst, moveFocusToLast, moveFocusByPage, selectFocused, selectRange, getSelectedIds, getSelectedItems, getSelectionCount, isSelected, isSelectionEmpty, type SelectionState, } from "./state";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/selection/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGrE,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,eAAe,EACf,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,KAAK,cAAc,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist/selection - Builder Plugin
|
|
3
|
+
* Wraps the selection domain into a VListPlugin for the composable builder.
|
|
4
|
+
*
|
|
5
|
+
* Priority: 50 (runs after renderer and data are ready)
|
|
6
|
+
*
|
|
7
|
+
* What it wires:
|
|
8
|
+
* - Click handler on items container — toggles selection on item click
|
|
9
|
+
* - Keyboard handler on root — ArrowUp/Down for focus, Space/Enter for toggle
|
|
10
|
+
* - ARIA attributes — aria-selected on items, aria-activedescendant on root
|
|
11
|
+
* - Live region — announces selection changes to screen readers
|
|
12
|
+
* - Render integration — passes selection state to render pipeline
|
|
13
|
+
*
|
|
14
|
+
* Added methods: select, deselect, toggleSelect, selectAll, clearSelection,
|
|
15
|
+
* getSelected, getSelectedItems
|
|
16
|
+
*
|
|
17
|
+
* Added events: item:click, selection:change
|
|
18
|
+
*/
|
|
19
|
+
import type { VListItem, SelectionMode } from "../../types";
|
|
20
|
+
import type { VListPlugin } from "../../builder/types";
|
|
21
|
+
/** Selection plugin configuration */
|
|
22
|
+
export interface SelectionPluginConfig {
|
|
23
|
+
/** Selection mode (default: 'single') */
|
|
24
|
+
mode?: SelectionMode;
|
|
25
|
+
/** Initially selected item IDs */
|
|
26
|
+
initial?: Array<string | number>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a selection plugin for the builder.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { vlist } from 'vlist/builder'
|
|
33
|
+
* import { withSelection } from 'vlist/selection'
|
|
34
|
+
*
|
|
35
|
+
* const list = vlist({ ... })
|
|
36
|
+
* .use(withSelection({ mode: 'multiple', initial: ['id-1'] }))
|
|
37
|
+
* .build()
|
|
38
|
+
*
|
|
39
|
+
* list.select('id-2')
|
|
40
|
+
* list.getSelected() // ['id-1', 'id-2']
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const withSelection: <T extends VListItem = VListItem>(config?: SelectionPluginConfig) => VListPlugin<T>;
|
|
44
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/features/selection/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAC;AAwBvE,qCAAqC;AACrC,MAAM,WAAW,qBAAqB;IACpC,yCAAyC;IACzC,IAAI,CAAC,EAAE,aAAa,CAAC;IAErB,kCAAkC;IAClC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CAClC;AAMD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAC3D,SAAS,qBAAqB,KAC7B,WAAW,CAAC,CAAC,CAwWf,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vlist - Selection State Management
|
|
3
|
+
* Pure functions for managing selection state
|
|
4
|
+
*/
|
|
5
|
+
import type { VListItem, SelectionMode, SelectionState } from "../../types";
|
|
6
|
+
export type { SelectionState } from "../../types";
|
|
7
|
+
/**
|
|
8
|
+
* Create initial selection state
|
|
9
|
+
* Pure function - no side effects
|
|
10
|
+
*/
|
|
11
|
+
export declare const createSelectionState: (initial?: Array<string | number>) => SelectionState;
|
|
12
|
+
/**
|
|
13
|
+
* Select items by ID
|
|
14
|
+
* Pure function - returns new state
|
|
15
|
+
*/
|
|
16
|
+
export declare const selectItems: (state: SelectionState, ids: Array<string | number>, mode: SelectionMode) => SelectionState;
|
|
17
|
+
/**
|
|
18
|
+
* Deselect items by ID
|
|
19
|
+
* Pure function - returns new state
|
|
20
|
+
*/
|
|
21
|
+
export declare const deselectItems: (state: SelectionState, ids: Array<string | number>) => SelectionState;
|
|
22
|
+
/**
|
|
23
|
+
* Toggle item selection
|
|
24
|
+
* Pure function - returns new state
|
|
25
|
+
*/
|
|
26
|
+
export declare const toggleSelection: (state: SelectionState, id: string | number, mode: SelectionMode) => SelectionState;
|
|
27
|
+
/**
|
|
28
|
+
* Select all items
|
|
29
|
+
* Pure function - returns new state
|
|
30
|
+
*/
|
|
31
|
+
export declare const selectAll: <T extends VListItem>(state: SelectionState, items: T[], mode: SelectionMode) => SelectionState;
|
|
32
|
+
/**
|
|
33
|
+
* Clear all selection
|
|
34
|
+
* Pure function - returns new state
|
|
35
|
+
*/
|
|
36
|
+
export declare const clearSelection: (state: SelectionState) => SelectionState;
|
|
37
|
+
/**
|
|
38
|
+
* Set focused index
|
|
39
|
+
* Mutates state in-place to avoid allocation on hot path
|
|
40
|
+
*/
|
|
41
|
+
export declare const setFocusedIndex: (state: SelectionState, index: number) => SelectionState;
|
|
42
|
+
/**
|
|
43
|
+
* Move focus up
|
|
44
|
+
* Mutates state in-place to avoid allocation on hot path
|
|
45
|
+
*/
|
|
46
|
+
export declare const moveFocusUp: (state: SelectionState, totalItems: number, wrap?: boolean) => SelectionState;
|
|
47
|
+
/**
|
|
48
|
+
* Move focus down
|
|
49
|
+
* Mutates state in-place to avoid allocation on hot path
|
|
50
|
+
*/
|
|
51
|
+
export declare const moveFocusDown: (state: SelectionState, totalItems: number, wrap?: boolean) => SelectionState;
|
|
52
|
+
/**
|
|
53
|
+
* Move focus to first item
|
|
54
|
+
* Mutates state in-place to avoid allocation on hot path
|
|
55
|
+
*/
|
|
56
|
+
export declare const moveFocusToFirst: (state: SelectionState, totalItems: number) => SelectionState;
|
|
57
|
+
/**
|
|
58
|
+
* Move focus to last item
|
|
59
|
+
* Mutates state in-place to avoid allocation on hot path
|
|
60
|
+
*/
|
|
61
|
+
export declare const moveFocusToLast: (state: SelectionState, totalItems: number) => SelectionState;
|
|
62
|
+
/**
|
|
63
|
+
* Move focus by page (for Page Up/Down)
|
|
64
|
+
* Mutates state in-place to avoid allocation on hot path
|
|
65
|
+
*/
|
|
66
|
+
export declare const moveFocusByPage: (state: SelectionState, totalItems: number, pageSize: number, direction: "up" | "down") => SelectionState;
|
|
67
|
+
/**
|
|
68
|
+
* Check if an item is selected
|
|
69
|
+
* Pure function - no side effects
|
|
70
|
+
*/
|
|
71
|
+
export declare const isSelected: (state: SelectionState, id: string | number) => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Get selected IDs as array
|
|
74
|
+
* Pure function - no side effects
|
|
75
|
+
*/
|
|
76
|
+
export declare const getSelectedIds: (state: SelectionState) => Array<string | number>;
|
|
77
|
+
/**
|
|
78
|
+
* Get selected items using ID lookup (O(k) where k = selected count)
|
|
79
|
+
* Pure function - no side effects
|
|
80
|
+
*/
|
|
81
|
+
export declare const getSelectedItems: <T extends VListItem>(state: SelectionState, getItemById: (id: string | number) => T | undefined) => T[];
|
|
82
|
+
/**
|
|
83
|
+
* Get selection count
|
|
84
|
+
* Pure function - no side effects
|
|
85
|
+
*/
|
|
86
|
+
export declare const getSelectionCount: (state: SelectionState) => number;
|
|
87
|
+
/**
|
|
88
|
+
* Check if selection is empty
|
|
89
|
+
* Pure function - no side effects
|
|
90
|
+
*/
|
|
91
|
+
export declare const isSelectionEmpty: (state: SelectionState) => boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Handle keyboard selection (Space/Enter on focused item)
|
|
94
|
+
* Pure function - returns new state
|
|
95
|
+
*/
|
|
96
|
+
export declare const selectFocused: <T extends VListItem>(state: SelectionState, items: T[], mode: SelectionMode) => SelectionState;
|
|
97
|
+
/**
|
|
98
|
+
* Handle shift+click range selection
|
|
99
|
+
* Pure function - returns new state
|
|
100
|
+
*/
|
|
101
|
+
export declare const selectRange: <T extends VListItem>(state: SelectionState, items: T[], fromIndex: number, toIndex: number, mode: SelectionMode) => SelectionState;
|
|
102
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/features/selection/state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG5E,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,KAC/B,cAGD,CAAC;AAMH;;;GAGG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,cAAc,EACrB,KAAK,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC3B,MAAM,aAAa,KAClB,cAsBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,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