vlist 3.0.0-next.1 → 3.0.0-next.3
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 +111 -65
- package/README.md +70 -54
- package/dist/config.d.ts +105 -14
- package/dist/config.js +1 -1
- package/dist/core/create.d.ts +22 -5
- package/dist/core/dom.d.ts +1 -1
- 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 +1 -1
- package/dist/core/runway.d.ts +6 -2
- 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 +134 -62
- 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/native.d.ts +6 -10
- package/dist/native.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 +30 -2
- 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/index.d.ts +1 -0
- package/dist/plugins/groups/plugin.d.ts +11 -3
- package/dist/plugins/groups/types.d.ts +6 -1
- 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 +26 -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 +11 -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 +1 -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 +7 -1
- package/dist/size.json +1 -1
- package/dist/synthetic.d.ts +3 -3
- package/dist/synthetic.js +1 -1
- package/dist/types.d.ts +17 -21
- package/dist/utils/scroll-padding.d.ts +36 -0
- package/dist/utils/stats.d.ts +9 -1
- package/dist/vlist.css +1 -1
- package/package.json +6 -2
- package/dist/plugins/grid/renderer.d.ts +0 -68
package/dist/config.d.ts
CHANGED
|
@@ -15,14 +15,22 @@
|
|
|
15
15
|
* lean and tree-shakeable; only consumers that opt into the batteries-included
|
|
16
16
|
* config (the adapters) pull in this module and, with it, every plugin it wires.
|
|
17
17
|
*/
|
|
18
|
-
import type { VListItem, GroupsConfig, VListAdapter } from "./types";
|
|
18
|
+
import type { VListItem, GroupsConfig, VListAdapter, ScrollConfig } from "./types";
|
|
19
19
|
import { createVList } from "./core/create";
|
|
20
|
-
import type {
|
|
21
|
-
import type {
|
|
20
|
+
import type { CreateVListConfig, VList, VListPlugin, PluginMethods } from "./core/types";
|
|
21
|
+
import type { AutosizeMethods } from "./plugins/autosize/plugin";
|
|
22
|
+
import type { DataMethods } from "./plugins/data/plugin";
|
|
23
|
+
import type { GridMethods } from "./plugins/grid/plugin";
|
|
24
|
+
import type { MasonryMethods } from "./plugins/masonry/plugin";
|
|
25
|
+
import type { GroupsMethods } from "./plugins/groups/plugin";
|
|
26
|
+
import type { SelectionMethods } from "./plugins/selection/plugin";
|
|
27
|
+
import type { ScrollbarMethods } from "./plugins/scrollbar/plugin";
|
|
28
|
+
import type { SnapshotsMethods } from "./plugins/snapshots/plugin";
|
|
22
29
|
import type { DataPluginConfig } from "./plugins/data";
|
|
23
30
|
import type { GridPluginConfig } from "./plugins/grid";
|
|
24
31
|
import type { MasonryPluginConfig } from "./plugins/masonry";
|
|
25
32
|
import type { SelectionPluginConfig } from "./plugins/selection";
|
|
33
|
+
import type { A11yPluginConfig } from "./plugins/a11y";
|
|
26
34
|
import type { ScrollbarPluginConfig } from "./plugins/scrollbar";
|
|
27
35
|
/** List creation function injected by an adapter consumer. */
|
|
28
36
|
export type VListFactory<T extends VListItem = VListItem> = typeof createVList<T>;
|
|
@@ -33,8 +41,8 @@ export type VListFactory<T extends VListItem = VListItem> = typeof createVList<T
|
|
|
33
41
|
* translated into plugins by {@link resolvePlugins}.
|
|
34
42
|
*/
|
|
35
43
|
export interface VListConfig<T extends VListItem = VListItem> extends Omit<CreateVListConfig<T>, "container" | "scroll"> {
|
|
36
|
-
/**
|
|
37
|
-
scroll?:
|
|
44
|
+
/** Scroll options; select synthetic input with a factory from vlist/synthetic. */
|
|
45
|
+
scroll?: ScrollConfig;
|
|
38
46
|
/** List factory; defaults to core createVList. Fixed for this instance. */
|
|
39
47
|
factory?: VListFactory<T>;
|
|
40
48
|
/** Layout mode. Wires the grid or masonry plugin from `grid`/`masonry`. */
|
|
@@ -45,10 +53,31 @@ export interface VListConfig<T extends VListItem = VListItem> extends Omit<Creat
|
|
|
45
53
|
masonry?: MasonryPluginConfig;
|
|
46
54
|
/** Sticky group headers. */
|
|
47
55
|
groups?: GroupsConfig;
|
|
48
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Row selection (single / multi). Omit it for a display-only list: nothing
|
|
58
|
+
* is wired then, so the list keeps `role="list"` and stays out of the tab
|
|
59
|
+
* order, exactly like a core list created without the plugin.
|
|
60
|
+
*/
|
|
49
61
|
selection?: SelectionPluginConfig;
|
|
50
|
-
/**
|
|
51
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Keyboard navigation, focus management and the WAI-ARIA listbox roles.
|
|
64
|
+
* Off by default, as in core: pass `true` for the defaults or an object to
|
|
65
|
+
* tune it. A selection mode other than `"none"` already provides both, so a
|
|
66
|
+
* list with one does not need this as well.
|
|
67
|
+
*/
|
|
68
|
+
a11y?: A11yPluginConfig | boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Custom overlay scrollbar. Off by default, as in core, which leaves the
|
|
71
|
+
* browser's native scrollbar in place: pass `true` for the defaults or an
|
|
72
|
+
* object to tune them. `"none"` is accepted for symmetry with
|
|
73
|
+
* `scroll.scrollbar` and wires nothing.
|
|
74
|
+
*/
|
|
75
|
+
scrollbar?: ScrollbarPluginConfig | "none" | boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Scroll position save/restore (`saveScroll` / `restoreScroll`).
|
|
78
|
+
* Off by default, as in core.
|
|
79
|
+
*/
|
|
80
|
+
snapshots?: boolean;
|
|
52
81
|
/** Async data source — enables the data plugin. */
|
|
53
82
|
adapter?: VListAdapter<T>;
|
|
54
83
|
/** Async loading tuning (used together with `adapter`). */
|
|
@@ -63,18 +92,80 @@ export interface VListConfig<T extends VListItem = VListItem> extends Omit<Creat
|
|
|
63
92
|
}
|
|
64
93
|
/**
|
|
65
94
|
* Translate a {@link VListConfig} into the ordered plugin array that the core
|
|
66
|
-
* `createVList` expects.
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
95
|
+
* `createVList` expects. Every plugin comes from a field the caller set, so a
|
|
96
|
+
* config with no feature fields resolves to no plugins and an adapter list
|
|
97
|
+
* behaves like a core list given the same options. Any user `plugins` are
|
|
98
|
+
* appended last as an escape hatch.
|
|
70
99
|
*/
|
|
71
100
|
export declare function resolvePlugins<T extends VListItem = VListItem>(config: VListConfig<T>): VListPlugin<T>[];
|
|
101
|
+
/** A field value that wires no plugin. `"none"` is the scrollbar's spelling of off. */
|
|
102
|
+
type Off = false | undefined | null | "none";
|
|
103
|
+
/**
|
|
104
|
+
* The methods a field adds when it is on. Distributive on purpose: a widened
|
|
105
|
+
* `boolean` is `true | false`, so the result is `M | {}` and a call on it is a
|
|
106
|
+
* type error — the honest answer when the compiler cannot know whether the
|
|
107
|
+
* plugin is seated. Narrow the config, or spell the field as a literal.
|
|
108
|
+
*/
|
|
109
|
+
type OnOff<V, M> = V extends Off ? {} : M;
|
|
110
|
+
/**
|
|
111
|
+
* The methods field `K` adds, or nothing when the config has no such field.
|
|
112
|
+
* Indexing `C[K]` directly would fall back to the constraint's type for an
|
|
113
|
+
* absent key and hand a plain config every plugin's methods.
|
|
114
|
+
*/
|
|
115
|
+
type Field<C, K extends PropertyKey, M> = C extends Record<K, infer V> ? OnOff<V, M> : {};
|
|
116
|
+
/** Whether the item spec carries an estimate, which wires autosize(). */
|
|
117
|
+
type Estimated<C> = C extends {
|
|
118
|
+
item: {
|
|
119
|
+
estimatedHeight: number;
|
|
120
|
+
} | {
|
|
121
|
+
estimatedWidth: number;
|
|
122
|
+
};
|
|
123
|
+
} ? C extends {
|
|
124
|
+
item: {
|
|
125
|
+
height: number;
|
|
126
|
+
} | {
|
|
127
|
+
width: number;
|
|
128
|
+
};
|
|
129
|
+
} ? {} : AutosizeMethods : {};
|
|
130
|
+
/**
|
|
131
|
+
* The plugin methods a {@link VListConfig} wires, derived from its fields the
|
|
132
|
+
* same way {@link resolvePlugins} derives the plugins — the two are the type
|
|
133
|
+
* and runtime halves of one mapping, and `test/types/config.ts` asserts they
|
|
134
|
+
* agree. This is what lets an adapter list carry `select()` or `reload()` the
|
|
135
|
+
* way a core list built with `createVList(config, [selection()])` does.
|
|
136
|
+
*/
|
|
137
|
+
export type ConfigMethods<T extends VListItem, C extends VListConfig<T>> = Field<C, "adapter", DataMethods> & (C extends {
|
|
138
|
+
layout: "grid";
|
|
139
|
+
} ? GridMethods : {}) & (C extends {
|
|
140
|
+
layout: "masonry";
|
|
141
|
+
} ? MasonryMethods : {}) & Field<C, "groups", GroupsMethods> & Field<C, "selection", SelectionMethods<T>> & Field<C, "scrollbar", ScrollbarMethods> & Field<C, "snapshots", SnapshotsMethods> & Estimated<C> & (C extends {
|
|
142
|
+
plugins: infer P extends readonly unknown[];
|
|
143
|
+
} ? PluginMethods<P> : {});
|
|
144
|
+
/**
|
|
145
|
+
* The item type a config is written for: the element type of its `items`, else
|
|
146
|
+
* the parameter of its template. `VListConfig<infer T>` would do neither
|
|
147
|
+
* reliably — a config with no `items` inferred `any`.
|
|
148
|
+
*/
|
|
149
|
+
export type ConfigItem<C> = C extends {
|
|
150
|
+
items: readonly (infer T extends VListItem)[];
|
|
151
|
+
} ? T : C extends {
|
|
152
|
+
item: {
|
|
153
|
+
template: (item: infer T extends VListItem, ...rest: never[]) => unknown;
|
|
154
|
+
};
|
|
155
|
+
} ? T : VListItem;
|
|
72
156
|
/**
|
|
73
157
|
* Create a vlist instance from a high-level {@link VListConfig}, resolving its
|
|
74
158
|
* feature fields into plugins via {@link resolvePlugins}. This is the single
|
|
75
159
|
* entry point every framework adapter delegates to.
|
|
160
|
+
*
|
|
161
|
+
* One type parameter, the config itself: the item type comes from its `items`
|
|
162
|
+
* or `template`, and the list's methods from its feature fields
|
|
163
|
+
* ({@link ConfigMethods}). Do not pass a type argument — `createVListFromConfig<Row>`
|
|
164
|
+
* would name a config type, not an item type, and fail to compile; the same
|
|
165
|
+
* trap `createVList<Row>` falls into is closed here by having no second slot.
|
|
76
166
|
*/
|
|
77
|
-
export declare function createVListFromConfig<
|
|
167
|
+
export declare function createVListFromConfig<const C extends VListConfig<any> & {
|
|
78
168
|
container: HTMLElement | string;
|
|
79
|
-
}): VList<
|
|
169
|
+
}>(config: C): VList<ConfigItem<C>> & ConfigMethods<ConfigItem<C>, C>;
|
|
170
|
+
export {};
|
|
80
171
|
//# sourceMappingURL=config.d.ts.map
|