@skygraph/react 0.0.0-placeholder.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +70 -12
- package/dist/Table-BmesoMje.d.ts +1017 -0
- package/dist/Table-CpKMOH2x.d.cts +1017 -0
- package/dist/chunk-2OCEO636.js +91 -0
- package/dist/chunk-2OCEO636.js.map +1 -0
- package/dist/chunk-BNMJSYI2.js +54 -0
- package/dist/chunk-BNMJSYI2.js.map +1 -0
- package/dist/chunk-FSV73JI4.js +58 -0
- package/dist/chunk-FSV73JI4.js.map +1 -0
- package/dist/chunk-GJDDPZH7.js +226 -0
- package/dist/chunk-GJDDPZH7.js.map +1 -0
- package/dist/chunk-MLEBVELO.js +1412 -0
- package/dist/chunk-MLEBVELO.js.map +1 -0
- package/dist/chunk-NXB3VAVF.js +3794 -0
- package/dist/chunk-NXB3VAVF.js.map +1 -0
- package/dist/chunk-SEQI65CF.js +61 -0
- package/dist/chunk-SEQI65CF.js.map +1 -0
- package/dist/chunk-UO6VJC3C.js +1667 -0
- package/dist/chunk-UO6VJC3C.js.map +1 -0
- package/dist/chunk-Z5UGF7EO.js +847 -0
- package/dist/chunk-Z5UGF7EO.js.map +1 -0
- package/dist/chunk-ZJF6SJLP.js +200 -0
- package/dist/chunk-ZJF6SJLP.js.map +1 -0
- package/dist/common-CdpocIEz.d.cts +27 -0
- package/dist/common-CdpocIEz.d.ts +27 -0
- package/dist/datagrid-B6hg5yJh.d.cts +200 -0
- package/dist/datagrid-B6hg5yJh.d.ts +200 -0
- package/dist/datagrid.cjs +1053 -0
- package/dist/datagrid.cjs.map +1 -0
- package/dist/datagrid.d.cts +2 -0
- package/dist/datagrid.d.ts +2 -0
- package/dist/datagrid.js +10 -0
- package/dist/datagrid.js.map +1 -0
- package/dist/devtools.cjs +253 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.cts +29 -0
- package/dist/devtools.d.ts +29 -0
- package/dist/devtools.js +9 -0
- package/dist/devtools.js.map +1 -0
- package/dist/form.cjs +1723 -0
- package/dist/form.cjs.map +1 -0
- package/dist/form.d.cts +530 -0
- package/dist/form.d.ts +530 -0
- package/dist/form.js +49 -0
- package/dist/form.js.map +1 -0
- package/dist/index.cjs +22467 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3685 -0
- package/dist/index.d.ts +3685 -0
- package/dist/index.js +14131 -0
- package/dist/index.js.map +1 -0
- package/dist/table.cjs +4134 -0
- package/dist/table.cjs.map +1 -0
- package/dist/table.d.cts +31 -0
- package/dist/table.d.ts +31 -0
- package/dist/table.js +26 -0
- package/dist/table.js.map +1 -0
- package/dist/tree.cjs +1822 -0
- package/dist/tree.cjs.map +1 -0
- package/dist/tree.d.cts +348 -0
- package/dist/tree.d.ts +348 -0
- package/dist/tree.js +13 -0
- package/dist/tree.js.map +1 -0
- package/dist/virtual.cjs +145 -0
- package/dist/virtual.cjs.map +1 -0
- package/dist/virtual.d.cts +50 -0
- package/dist/virtual.d.ts +50 -0
- package/dist/virtual.js +11 -0
- package/dist/virtual.js.map +1 -0
- package/package.json +108 -18
- package/index.js +0 -3
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { TreeNodeData, TreeKey, TreeFieldNames, TreeEngineOptions, Core, TreeEngine, TreeState } from '@skygraph/core';
|
|
4
|
+
|
|
5
|
+
/** Payload for `onCheck` describing the toggle and affected nodes. */
|
|
6
|
+
interface CheckInfo {
|
|
7
|
+
/** Whether the toggled node ended checked. */
|
|
8
|
+
checked: boolean;
|
|
9
|
+
/** Node whose checkbox was toggled. */
|
|
10
|
+
node: TreeNodeData;
|
|
11
|
+
/** All fully checked nodes after the update. */
|
|
12
|
+
checkedNodes: TreeNodeData[];
|
|
13
|
+
/** Keys in indeterminate half-checked state. */
|
|
14
|
+
halfCheckedKeys: TreeKey[];
|
|
15
|
+
}
|
|
16
|
+
/** Payload for `onSelect` after a selection change. */
|
|
17
|
+
interface SelectInfo {
|
|
18
|
+
/** Whether the node ended selected. */
|
|
19
|
+
selected: boolean;
|
|
20
|
+
/** Node that was clicked for selection. */
|
|
21
|
+
node: TreeNodeData;
|
|
22
|
+
/** All selected nodes after the update. */
|
|
23
|
+
selectedNodes: TreeNodeData[];
|
|
24
|
+
}
|
|
25
|
+
/** Payload for `onExpand` after an expand/collapse. */
|
|
26
|
+
interface ExpandInfo {
|
|
27
|
+
/** Whether the node ended expanded. */
|
|
28
|
+
expanded: boolean;
|
|
29
|
+
/** Node whose expander was toggled. */
|
|
30
|
+
node: TreeNodeData;
|
|
31
|
+
}
|
|
32
|
+
/** Drag lifecycle event payload with DOM event and node. */
|
|
33
|
+
interface DragInfo {
|
|
34
|
+
/** Browser drag event. */
|
|
35
|
+
event: React__default.DragEvent;
|
|
36
|
+
/** Associated tree node. */
|
|
37
|
+
node: TreeNodeData;
|
|
38
|
+
}
|
|
39
|
+
/** Drop completion payload including dragged node and position. */
|
|
40
|
+
interface DropInfo {
|
|
41
|
+
/** Browser drop event. */
|
|
42
|
+
event: React__default.DragEvent;
|
|
43
|
+
/** Drop target node. */
|
|
44
|
+
node: TreeNodeData;
|
|
45
|
+
/** Node that was dragged. */
|
|
46
|
+
dragNode: TreeNodeData;
|
|
47
|
+
/** Insert position relative to the target. */
|
|
48
|
+
dropPosition: -1 | 0 | 1;
|
|
49
|
+
}
|
|
50
|
+
/** Payload when an inline edit is committed (if editing is used). */
|
|
51
|
+
interface EditInfo {
|
|
52
|
+
/** Edited node key. */
|
|
53
|
+
key: TreeKey;
|
|
54
|
+
/** Edited node. */
|
|
55
|
+
node: TreeNodeData;
|
|
56
|
+
/** New title text. */
|
|
57
|
+
value: string;
|
|
58
|
+
/** Previous title text. */
|
|
59
|
+
oldValue: string;
|
|
60
|
+
}
|
|
61
|
+
/** Visual status hint for a node row. */
|
|
62
|
+
type TreeNodeStatus = 'default' | 'success' | 'warning' | 'error' | 'info';
|
|
63
|
+
/** Declarative action button on a tree node row. */
|
|
64
|
+
interface TreeNodeAction {
|
|
65
|
+
/** Action identifier. */
|
|
66
|
+
key: string;
|
|
67
|
+
/** Button icon. */
|
|
68
|
+
icon?: React__default.ReactNode;
|
|
69
|
+
/** Tooltip or aria label text. */
|
|
70
|
+
title?: string;
|
|
71
|
+
/** Click handler receiving node and key. */
|
|
72
|
+
onClick: (node: TreeNodeData, key: TreeKey) => void;
|
|
73
|
+
/** Hides the action for nodes where this returns false. */
|
|
74
|
+
visible?: (node: TreeNodeData) => boolean;
|
|
75
|
+
/** Disables the action per node. */
|
|
76
|
+
disabled?: (node: TreeNodeData) => boolean;
|
|
77
|
+
/** Destructive styling. */
|
|
78
|
+
danger?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/** Localizable strings for built-in tree UI. */
|
|
81
|
+
interface TreeLocale {
|
|
82
|
+
/** Empty tree placeholder. */
|
|
83
|
+
emptyText?: React__default.ReactNode;
|
|
84
|
+
/** Async loading label. */
|
|
85
|
+
loadingText?: string;
|
|
86
|
+
/** Search field placeholder. */
|
|
87
|
+
searchPlaceholder?: string;
|
|
88
|
+
/** Toolbar control to expand all nodes. */
|
|
89
|
+
expandAllText?: string;
|
|
90
|
+
/** Toolbar control to collapse all nodes. */
|
|
91
|
+
collapseAllText?: string;
|
|
92
|
+
/** Toolbar control to check all checkboxes. */
|
|
93
|
+
checkAllText?: string;
|
|
94
|
+
/** Toolbar control to clear all checks. */
|
|
95
|
+
uncheckAllText?: string;
|
|
96
|
+
/** Accessible label for the clear-search (×) button. */
|
|
97
|
+
clearSearch?: string;
|
|
98
|
+
}
|
|
99
|
+
/** Props for the `Tree` component. */
|
|
100
|
+
interface TreeProps {
|
|
101
|
+
/** Hierarchical data with keys and optional children. */
|
|
102
|
+
treeData: TreeNodeData[];
|
|
103
|
+
/** Renames `title`, `key`, `children`, and other field accessors. */
|
|
104
|
+
fieldNames?: TreeFieldNames;
|
|
105
|
+
/** Shows checkboxes on nodes. @default false */
|
|
106
|
+
checkable?: boolean;
|
|
107
|
+
/** When true, parent and child checks are independent. @default false */
|
|
108
|
+
checkStrictly?: boolean;
|
|
109
|
+
/** Controlled checked keys. */
|
|
110
|
+
checkedKeys?: TreeKey[];
|
|
111
|
+
/** Initial checked keys in uncontrolled mode. */
|
|
112
|
+
defaultCheckedKeys?: TreeKey[];
|
|
113
|
+
/** Fires after check state changes. */
|
|
114
|
+
onCheck?: (checkedKeys: TreeKey[], info: CheckInfo) => void;
|
|
115
|
+
/** Allows clicking titles to select nodes. @default true */
|
|
116
|
+
selectable?: boolean;
|
|
117
|
+
/** Allows multiple selected nodes. @default false */
|
|
118
|
+
multiple?: boolean;
|
|
119
|
+
/** Controlled selected keys. */
|
|
120
|
+
selectedKeys?: TreeKey[];
|
|
121
|
+
/** Initial selected keys in uncontrolled mode. */
|
|
122
|
+
defaultSelectedKeys?: TreeKey[];
|
|
123
|
+
/** Fires after selection changes. */
|
|
124
|
+
onSelect?: (selectedKeys: TreeKey[], info: SelectInfo) => void;
|
|
125
|
+
/** Controlled expanded keys. */
|
|
126
|
+
expandedKeys?: TreeKey[];
|
|
127
|
+
/** Initial expanded keys in uncontrolled mode. */
|
|
128
|
+
defaultExpandedKeys?: TreeKey[];
|
|
129
|
+
/** Expands every parent on first render when uncontrolled. @default false */
|
|
130
|
+
defaultExpandAll?: boolean;
|
|
131
|
+
/** Expands ancestors of the focused or matched node when filtering. @default false */
|
|
132
|
+
autoExpandParent?: boolean;
|
|
133
|
+
/** Fires after expand/collapse. */
|
|
134
|
+
onExpand?: (expandedKeys: TreeKey[], info: ExpandInfo) => void;
|
|
135
|
+
/** Enables drag handles per node or per node predicate. @default false */
|
|
136
|
+
draggable?: boolean | ((node: TreeNodeData) => boolean);
|
|
137
|
+
/** Validates whether a drop is allowed. */
|
|
138
|
+
allowDrop?: (info: {
|
|
139
|
+
dragNode: TreeNodeData;
|
|
140
|
+
dropNode: TreeNodeData;
|
|
141
|
+
dropPosition: -1 | 0 | 1;
|
|
142
|
+
}) => boolean;
|
|
143
|
+
/** Drag start callback. */
|
|
144
|
+
onDragStart?: (info: DragInfo) => void;
|
|
145
|
+
/** Drag enter callback. */
|
|
146
|
+
onDragEnter?: (info: DragInfo) => void;
|
|
147
|
+
/** Drag over callback. */
|
|
148
|
+
onDragOver?: (info: DragInfo) => void;
|
|
149
|
+
/** Drag leave callback. */
|
|
150
|
+
onDragLeave?: (info: DragInfo) => void;
|
|
151
|
+
/** Drag end callback. */
|
|
152
|
+
onDragEnd?: (info: DragInfo) => void;
|
|
153
|
+
/** Drop callback after a successful internal move. */
|
|
154
|
+
onDrop?: (info: DropInfo) => void;
|
|
155
|
+
/** Loads children asynchronously; return promise resolves when data is ready. */
|
|
156
|
+
loadData?: (node: TreeNodeData) => Promise<void>;
|
|
157
|
+
/** Keys whose children have finished loading. */
|
|
158
|
+
loadedKeys?: TreeKey[];
|
|
159
|
+
/** Renders guide lines between levels or configures leaf icons. @default false */
|
|
160
|
+
showLine?: boolean | {
|
|
161
|
+
showLeafIcon?: boolean | React__default.ReactNode;
|
|
162
|
+
};
|
|
163
|
+
/** Shows a leading icon column. @default false */
|
|
164
|
+
showIcon?: boolean;
|
|
165
|
+
/** Default node icon render or element. */
|
|
166
|
+
icon?: React__default.ReactNode | ((props: {
|
|
167
|
+
expanded: boolean;
|
|
168
|
+
selected: boolean;
|
|
169
|
+
}) => React__default.ReactNode);
|
|
170
|
+
/** Custom expand/collapse control. */
|
|
171
|
+
switcherIcon?: React__default.ReactNode | ((props: {
|
|
172
|
+
expanded: boolean;
|
|
173
|
+
loading: boolean;
|
|
174
|
+
isLeaf: boolean;
|
|
175
|
+
}) => React__default.ReactNode);
|
|
176
|
+
/** Makes the whole row clickable for selection. @default false */
|
|
177
|
+
blockNode?: boolean;
|
|
178
|
+
/** Fixed viewport height enabling internal virtual scroll. */
|
|
179
|
+
height?: number;
|
|
180
|
+
/** Uses windowed rendering when `height` is set and the list is large. @default true */
|
|
181
|
+
virtual?: boolean;
|
|
182
|
+
/** Disables all interactions. @default false */
|
|
183
|
+
disabled?: boolean;
|
|
184
|
+
/** Horizontal indent per depth level in pixels. @default 24 */
|
|
185
|
+
indentSize?: number;
|
|
186
|
+
/** Directory-style selection expands folders on click. @default false */
|
|
187
|
+
directory?: boolean;
|
|
188
|
+
/** Context menu handler on node rows. */
|
|
189
|
+
onRightClick?: (info: {
|
|
190
|
+
event: React__default.MouseEvent;
|
|
191
|
+
node: TreeNodeData;
|
|
192
|
+
}) => void;
|
|
193
|
+
/** Shows the toolbar search field. @default false */
|
|
194
|
+
showSearch?: boolean;
|
|
195
|
+
/** Controlled filter text. */
|
|
196
|
+
searchValue?: string;
|
|
197
|
+
/** Initial filter text when uncontrolled. @default '' */
|
|
198
|
+
defaultSearchValue?: string;
|
|
199
|
+
/** Emits filter text changes. */
|
|
200
|
+
onSearch?: (value: string) => void;
|
|
201
|
+
/** Predicate to include nodes while searching. */
|
|
202
|
+
filterTreeNode?: (node: TreeNodeData, searchValue: string) => boolean;
|
|
203
|
+
/** Highlights matched text in titles. @default true */
|
|
204
|
+
highlightSearch?: boolean;
|
|
205
|
+
/** Enables built-in keyboard navigation helpers. @default true */
|
|
206
|
+
keyboard?: boolean;
|
|
207
|
+
/** Enables inline editing of titles per node or predicate. @default false */
|
|
208
|
+
editable?: boolean | ((node: TreeNodeData) => boolean);
|
|
209
|
+
/** Commit handler for inline edits. */
|
|
210
|
+
onEdit?: (info: EditInfo) => void;
|
|
211
|
+
/** Cancel handler for inline edits. */
|
|
212
|
+
onEditCancel?: (key: TreeKey) => void;
|
|
213
|
+
/** Custom title area render. */
|
|
214
|
+
titleRender?: (node: TreeNodeData, info: {
|
|
215
|
+
expanded: boolean;
|
|
216
|
+
selected: boolean;
|
|
217
|
+
checked: boolean;
|
|
218
|
+
halfChecked: boolean;
|
|
219
|
+
}) => React__default.ReactNode;
|
|
220
|
+
/** Inline action buttons on node rows. */
|
|
221
|
+
actions?: TreeNodeAction[];
|
|
222
|
+
/** Shows toolbar with expand/collapse/check-all controls. @default false */
|
|
223
|
+
showToolbar?: boolean;
|
|
224
|
+
/** Extra toolbar nodes after built-ins. */
|
|
225
|
+
toolbarExtra?: React__default.ReactNode;
|
|
226
|
+
/** Enables expand/collapse animations. @default true */
|
|
227
|
+
animated?: boolean;
|
|
228
|
+
/** Focuses a node on mount when supported. @default false */
|
|
229
|
+
autoFocus?: boolean;
|
|
230
|
+
/** Controlled focused node key. */
|
|
231
|
+
focusedKey?: TreeKey;
|
|
232
|
+
/** Fires when focus moves to a node. */
|
|
233
|
+
onFocus?: (key: TreeKey) => void;
|
|
234
|
+
/** Scrolls the given key into view when it changes. */
|
|
235
|
+
scrollToKey?: TreeKey;
|
|
236
|
+
/** Maps a node to a status color variant. */
|
|
237
|
+
nodeStatus?: (node: TreeNodeData) => TreeNodeStatus;
|
|
238
|
+
/** Overrides default locale strings. */
|
|
239
|
+
locale?: TreeLocale;
|
|
240
|
+
/** Root wrapper class name. */
|
|
241
|
+
className?: string;
|
|
242
|
+
/** Root wrapper style. */
|
|
243
|
+
style?: React__default.CSSProperties;
|
|
244
|
+
/** Renders semantic tree without Skygraph styles. */
|
|
245
|
+
unstyled?: boolean;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Hierarchical list with expand/collapse, checkboxes, selection, search, keyboard focus, and optional drag-and-drop.
|
|
250
|
+
* State is managed by `useTree`; rows are rendered through `TreeNodeRow`.
|
|
251
|
+
*/
|
|
252
|
+
declare function Tree(props: TreeProps): react_jsx_runtime.JSX.Element;
|
|
253
|
+
|
|
254
|
+
interface UseTreeOptions extends TreeEngineOptions {
|
|
255
|
+
data?: TreeNodeData[];
|
|
256
|
+
}
|
|
257
|
+
interface UseTreeReturn {
|
|
258
|
+
core: Core;
|
|
259
|
+
tree: TreeEngine;
|
|
260
|
+
treeState: TreeState;
|
|
261
|
+
flatNodes: ReturnType<TreeEngine['getFlatNodes']>;
|
|
262
|
+
expand: (key: TreeKey) => void;
|
|
263
|
+
collapse: (key: TreeKey) => void;
|
|
264
|
+
toggleExpand: (key: TreeKey) => void;
|
|
265
|
+
setExpandedKeys: (keys: TreeKey[]) => void;
|
|
266
|
+
expandAll: () => void;
|
|
267
|
+
collapseAll: () => void;
|
|
268
|
+
expandToLevel: (level: number) => void;
|
|
269
|
+
check: (key: TreeKey) => void;
|
|
270
|
+
uncheck: (key: TreeKey) => void;
|
|
271
|
+
toggleCheck: (key: TreeKey) => void;
|
|
272
|
+
setCheckedKeys: (keys: TreeKey[]) => void;
|
|
273
|
+
checkAll: () => void;
|
|
274
|
+
uncheckAll: () => void;
|
|
275
|
+
select: (key: TreeKey, multiple?: boolean) => void;
|
|
276
|
+
deselect: (key: TreeKey) => void;
|
|
277
|
+
setSelectedKeys: (keys: TreeKey[]) => void;
|
|
278
|
+
markLoading: (key: TreeKey) => void;
|
|
279
|
+
markLoaded: (key: TreeKey) => void;
|
|
280
|
+
addChildren: (parentKey: TreeKey, children: TreeNodeData[]) => void;
|
|
281
|
+
moveNode: (dragKey: TreeKey, dropKey: TreeKey, position: -1 | 0 | 1) => TreeNodeData[] | null;
|
|
282
|
+
filterNodes: (predicate: ((node: TreeNodeData) => boolean) | null) => void;
|
|
283
|
+
getNodePath: (key: TreeKey) => TreeKey[];
|
|
284
|
+
refresh: () => void;
|
|
285
|
+
}
|
|
286
|
+
declare function useTree(options?: UseTreeOptions): UseTreeReturn;
|
|
287
|
+
|
|
288
|
+
/** Props for the tree-based dropdown selector. */
|
|
289
|
+
interface TreeSelectProps {
|
|
290
|
+
/** Tree nodes to show in the dropdown. */
|
|
291
|
+
treeData: TreeNodeData[];
|
|
292
|
+
/** Controlled selected key(s). */
|
|
293
|
+
value?: TreeKey | TreeKey[];
|
|
294
|
+
/** Initial selected key(s) when uncontrolled. */
|
|
295
|
+
defaultValue?: TreeKey | TreeKey[];
|
|
296
|
+
/** Fires when selection changes; value is single key or array when multiple/checkable. */
|
|
297
|
+
onChange?: (value: TreeKey | TreeKey[], label: React__default.ReactNode[], extra: {
|
|
298
|
+
triggerNode: TreeNodeData;
|
|
299
|
+
}) => void;
|
|
300
|
+
/** Maps custom field names on tree nodes. */
|
|
301
|
+
fieldNames?: TreeFieldNames;
|
|
302
|
+
/** Allows selecting more than one leaf without checkboxes. @default false */
|
|
303
|
+
multiple?: boolean;
|
|
304
|
+
/** Uses checkboxes and check propagation like `Tree`. @default false */
|
|
305
|
+
treeCheckable?: boolean;
|
|
306
|
+
/** Independent parent/child checks when checkable. @default false */
|
|
307
|
+
treeCheckStrictly?: boolean;
|
|
308
|
+
/** Expands all nodes initially in the dropdown tree. @default false */
|
|
309
|
+
treeDefaultExpandAll?: boolean;
|
|
310
|
+
/** Initial expanded keys in the dropdown tree. */
|
|
311
|
+
treeDefaultExpandedKeys?: TreeKey[];
|
|
312
|
+
/** Shows search input in the dropdown. @default false */
|
|
313
|
+
showSearch?: boolean;
|
|
314
|
+
/** Filters nodes while searching (defaults to title substring). */
|
|
315
|
+
filterTreeNode?: (inputValue: string, treeNode: TreeNodeData) => boolean;
|
|
316
|
+
/** Trigger placeholder when nothing selected. @default 'Please select' */
|
|
317
|
+
placeholder?: string;
|
|
318
|
+
/** Shows clear control on the trigger. @default false */
|
|
319
|
+
allowClear?: boolean;
|
|
320
|
+
/** Disables opening and editing the value. @default false */
|
|
321
|
+
disabled?: boolean;
|
|
322
|
+
/** Selector size token. @default 'middle' */
|
|
323
|
+
size?: 'small' | 'middle' | 'large';
|
|
324
|
+
/** Collapses multiple tags to a “+N” rest indicator. */
|
|
325
|
+
maxTagCount?: number;
|
|
326
|
+
/** Inline style for the dropdown panel. */
|
|
327
|
+
dropdownStyle?: React__default.CSSProperties;
|
|
328
|
+
/** Enables guide lines on the inner `Tree`. @default false */
|
|
329
|
+
treeLine?: boolean;
|
|
330
|
+
/** Which checked keys are surfaced to the trigger when checkable. @default 'SHOW_ALL' */
|
|
331
|
+
showCheckedStrategy?: 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD';
|
|
332
|
+
/** Fires when the search text changes. */
|
|
333
|
+
onSearch?: (value: string) => void;
|
|
334
|
+
/** Root wrapper class name. */
|
|
335
|
+
className?: string;
|
|
336
|
+
/** Root wrapper style. */
|
|
337
|
+
style?: React__default.CSSProperties;
|
|
338
|
+
/** Renders minimal markup without Skygraph selector styles. */
|
|
339
|
+
unstyled?: boolean;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Dropdown that embeds `Tree` for single or multiple selection, optional checkboxes, and search.
|
|
344
|
+
* Manages open state, filtering, and tag display for multi-value modes.
|
|
345
|
+
*/
|
|
346
|
+
declare function TreeSelect(props: TreeSelectProps): react_jsx_runtime.JSX.Element;
|
|
347
|
+
|
|
348
|
+
export { type CheckInfo, type DragInfo, type DropInfo, type EditInfo, type ExpandInfo, type SelectInfo, Tree, type TreeLocale, type TreeNodeAction, type TreeNodeStatus, type TreeProps, TreeSelect, type TreeSelectProps, type UseTreeOptions, type UseTreeReturn, useTree };
|
package/dist/tree.js
ADDED
package/dist/tree.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/virtual.cjs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/virtual.ts
|
|
31
|
+
var virtual_exports = {};
|
|
32
|
+
__export(virtual_exports, {
|
|
33
|
+
VirtualList: () => VirtualList,
|
|
34
|
+
useVirtualScroll: () => useVirtualScroll
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(virtual_exports);
|
|
37
|
+
|
|
38
|
+
// src/hooks/useVirtualScroll.ts
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var import_core = require("@skygraph/core");
|
|
41
|
+
function useVirtualScroll(options) {
|
|
42
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
43
|
+
const engineRef = (0, import_react.useRef)(null);
|
|
44
|
+
if (!engineRef.current) {
|
|
45
|
+
engineRef.current = (0, import_core.createVirtual)({
|
|
46
|
+
itemCount: options.itemCount,
|
|
47
|
+
itemHeight: options.itemHeight,
|
|
48
|
+
overscan: options.overscan
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const engine = engineRef.current;
|
|
52
|
+
(0, import_react.useEffect)(() => {
|
|
53
|
+
engine.setItemCount(options.itemCount);
|
|
54
|
+
}, [engine, options.itemCount]);
|
|
55
|
+
(0, import_react.useEffect)(() => {
|
|
56
|
+
engine.setItemHeight(options.itemHeight);
|
|
57
|
+
}, [engine, options.itemHeight]);
|
|
58
|
+
const [range, setRange] = (0, import_react.useState)(
|
|
59
|
+
() => engine.getRange(0, 0)
|
|
60
|
+
);
|
|
61
|
+
const recalc = (0, import_react.useCallback)(() => {
|
|
62
|
+
const el = containerRef.current;
|
|
63
|
+
if (!el) return;
|
|
64
|
+
setRange(engine.getRange(el.scrollTop, el.clientHeight));
|
|
65
|
+
}, [engine]);
|
|
66
|
+
(0, import_react.useEffect)(() => {
|
|
67
|
+
const el = containerRef.current;
|
|
68
|
+
if (!el) return;
|
|
69
|
+
recalc();
|
|
70
|
+
el.addEventListener("scroll", recalc, { passive: true });
|
|
71
|
+
const ro = new ResizeObserver(recalc);
|
|
72
|
+
ro.observe(el);
|
|
73
|
+
return () => {
|
|
74
|
+
el.removeEventListener("scroll", recalc);
|
|
75
|
+
ro.disconnect();
|
|
76
|
+
};
|
|
77
|
+
}, [recalc]);
|
|
78
|
+
(0, import_react.useEffect)(() => {
|
|
79
|
+
recalc();
|
|
80
|
+
}, [options.itemCount, recalc]);
|
|
81
|
+
const scrollToIndex = (0, import_react.useCallback)(
|
|
82
|
+
(index, align = "start") => {
|
|
83
|
+
const el = containerRef.current;
|
|
84
|
+
if (!el) return;
|
|
85
|
+
el.scrollTop = engine.scrollToIndex(index, el.clientHeight, align);
|
|
86
|
+
},
|
|
87
|
+
[engine]
|
|
88
|
+
);
|
|
89
|
+
return (0, import_react.useMemo)(
|
|
90
|
+
() => ({ range, containerRef, scrollToIndex, engine }),
|
|
91
|
+
[range, scrollToIndex, engine]
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/components/complex/VirtualList/VirtualList.tsx
|
|
96
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
97
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
98
|
+
function VirtualListInner(props, ref) {
|
|
99
|
+
const {
|
|
100
|
+
data,
|
|
101
|
+
itemHeight,
|
|
102
|
+
overscan,
|
|
103
|
+
renderItem,
|
|
104
|
+
className,
|
|
105
|
+
style,
|
|
106
|
+
itemKey
|
|
107
|
+
} = props;
|
|
108
|
+
const { range, containerRef, scrollToIndex } = useVirtualScroll({
|
|
109
|
+
itemCount: data.length,
|
|
110
|
+
itemHeight,
|
|
111
|
+
overscan
|
|
112
|
+
});
|
|
113
|
+
(0, import_react2.useImperativeHandle)(ref, () => ({ scrollToIndex }), [scrollToIndex]);
|
|
114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
ref: containerRef,
|
|
118
|
+
className,
|
|
119
|
+
style: {
|
|
120
|
+
overflow: "auto",
|
|
121
|
+
position: "relative",
|
|
122
|
+
...style
|
|
123
|
+
},
|
|
124
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { height: range.totalHeight, position: "relative" }, children: range.visibleItems.map((vi) => {
|
|
125
|
+
const item = data[vi.index];
|
|
126
|
+
const key = itemKey ? itemKey(item, vi.index) : vi.index;
|
|
127
|
+
const itemStyle = {
|
|
128
|
+
position: "absolute",
|
|
129
|
+
top: vi.offsetTop,
|
|
130
|
+
left: 0,
|
|
131
|
+
right: 0,
|
|
132
|
+
height: vi.height
|
|
133
|
+
};
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.default.Fragment, { children: renderItem(item, vi.index, itemStyle) }, key);
|
|
135
|
+
}) })
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
var VirtualList = (0, import_react2.forwardRef)(VirtualListInner);
|
|
140
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
+
0 && (module.exports = {
|
|
142
|
+
VirtualList,
|
|
143
|
+
useVirtualScroll
|
|
144
|
+
});
|
|
145
|
+
//# sourceMappingURL=virtual.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/virtual.ts","../src/hooks/useVirtualScroll.ts","../src/components/complex/VirtualList/VirtualList.tsx"],"sourcesContent":["export { useVirtualScroll } from './hooks/useVirtualScroll'\nexport type { UseVirtualScrollOptions, UseVirtualScrollReturn } from './hooks/useVirtualScroll'\nexport { VirtualList } from './components/complex/VirtualList/VirtualList'\nexport type { VirtualListProps, VirtualListRef } from './components/complex/VirtualList/VirtualList'\n","import { useState, useCallback, useRef, useEffect, useMemo } from 'react'\nimport { createVirtual } from '@skygraph/core'\nimport type { VirtualEngine, VirtualRange } from '@skygraph/core'\n\nexport interface UseVirtualScrollOptions {\n itemCount: number\n itemHeight: number | ((index: number) => number)\n overscan?: number\n}\n\nexport interface UseVirtualScrollReturn {\n range: VirtualRange\n containerRef: React.RefObject<HTMLElement | null>\n scrollToIndex: (index: number, align?: 'start' | 'center' | 'end') => void\n engine: VirtualEngine\n}\n\nexport function useVirtualScroll(options: UseVirtualScrollOptions): UseVirtualScrollReturn {\n const containerRef = useRef<HTMLElement | null>(null)\n const engineRef = useRef<VirtualEngine | null>(null)\n\n if (!engineRef.current) {\n engineRef.current = createVirtual({\n itemCount: options.itemCount,\n itemHeight: options.itemHeight,\n overscan: options.overscan,\n })\n }\n\n const engine = engineRef.current\n\n useEffect(() => {\n engine.setItemCount(options.itemCount)\n }, [engine, options.itemCount])\n\n useEffect(() => {\n engine.setItemHeight(options.itemHeight)\n }, [engine, options.itemHeight])\n\n const [range, setRange] = useState<VirtualRange>(() =>\n engine.getRange(0, 0),\n )\n\n const recalc = useCallback(() => {\n const el = containerRef.current\n if (!el) return\n setRange(engine.getRange(el.scrollTop, el.clientHeight))\n }, [engine])\n\n useEffect(() => {\n const el = containerRef.current\n if (!el) return\n\n recalc()\n\n el.addEventListener('scroll', recalc, { passive: true })\n const ro = new ResizeObserver(recalc)\n ro.observe(el)\n\n return () => {\n el.removeEventListener('scroll', recalc)\n ro.disconnect()\n }\n }, [recalc])\n\n useEffect(() => {\n recalc()\n }, [options.itemCount, recalc])\n\n const scrollToIndex = useCallback(\n (index: number, align: 'start' | 'center' | 'end' = 'start') => {\n const el = containerRef.current\n if (!el) return\n el.scrollTop = engine.scrollToIndex(index, el.clientHeight, align)\n },\n [engine],\n )\n\n return useMemo(\n () => ({ range, containerRef, scrollToIndex, engine }),\n [range, scrollToIndex, engine],\n )\n}\n","import React, { forwardRef, useImperativeHandle } from 'react'\nimport { useVirtualScroll } from '../../../hooks/useVirtualScroll'\nimport type { VirtualItem } from '@skygraph/core'\n\n/** Props for the virtualized fixed-height item list. */\nexport interface VirtualListProps<T = unknown> {\n /** Full dataset; only visible indices are rendered. */\n data: T[]\n /** Fixed row height or per-index height resolver in pixels. */\n itemHeight: number | ((index: number) => number)\n /** Extra rows rendered above and below the viewport. */\n overscan?: number\n /** Renders one item with absolute positioning styles applied by the list. */\n renderItem: (item: T, index: number, style: React.CSSProperties) => React.ReactNode\n /** Scrolling container class name. */\n className?: string\n /** Scrolling container inline style. */\n style?: React.CSSProperties\n /** Stable React key for each item; defaults to row index. */\n itemKey?: (item: T, index: number) => React.Key\n}\n\n/** Imperative API for `VirtualList`. */\nexport interface VirtualListRef {\n /**\n * Scrolls so the item at `index` is visible.\n * @param align - Where to place the item in the viewport.\n */\n scrollToIndex: (index: number, align?: 'start' | 'center' | 'end') => void\n}\n\nfunction VirtualListInner<T>(\n props: VirtualListProps<T>,\n ref: React.ForwardedRef<VirtualListRef>,\n) {\n const {\n data,\n itemHeight,\n overscan,\n renderItem,\n className,\n style,\n itemKey,\n } = props\n\n const { range, containerRef, scrollToIndex } = useVirtualScroll({\n itemCount: data.length,\n itemHeight,\n overscan,\n })\n\n useImperativeHandle(ref, () => ({ scrollToIndex }), [scrollToIndex])\n\n return (\n <div\n ref={containerRef as React.RefObject<HTMLDivElement>}\n className={className}\n style={{\n overflow: 'auto',\n position: 'relative',\n ...style,\n }}\n >\n <div style={{ height: range.totalHeight, position: 'relative' }}>\n {range.visibleItems.map((vi: VirtualItem) => {\n const item = data[vi.index]\n const key = itemKey ? itemKey(item, vi.index) : vi.index\n const itemStyle: React.CSSProperties = {\n position: 'absolute',\n top: vi.offsetTop,\n left: 0,\n right: 0,\n height: vi.height,\n }\n return (\n <React.Fragment key={key}>\n {renderItem(item, vi.index, itemStyle)}\n </React.Fragment>\n )\n })}\n </div>\n </div>\n )\n}\n\n/**\n * Virtualized scroll container: mounts row content only for items near the viewport.\n * Forwards a ref with `scrollToIndex` for programmatic scrolling.\n */\nexport const VirtualList = forwardRef(VirtualListInner) as <T>(\n props: VirtualListProps<T> & { ref?: React.Ref<VirtualListRef> },\n) => React.ReactElement\n"],"mappings":"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","names":["import_react","React"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { VirtualRange, VirtualEngine } from '@skygraph/core';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
interface UseVirtualScrollOptions {
|
|
5
|
+
itemCount: number;
|
|
6
|
+
itemHeight: number | ((index: number) => number);
|
|
7
|
+
overscan?: number;
|
|
8
|
+
}
|
|
9
|
+
interface UseVirtualScrollReturn {
|
|
10
|
+
range: VirtualRange;
|
|
11
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
12
|
+
scrollToIndex: (index: number, align?: 'start' | 'center' | 'end') => void;
|
|
13
|
+
engine: VirtualEngine;
|
|
14
|
+
}
|
|
15
|
+
declare function useVirtualScroll(options: UseVirtualScrollOptions): UseVirtualScrollReturn;
|
|
16
|
+
|
|
17
|
+
/** Props for the virtualized fixed-height item list. */
|
|
18
|
+
interface VirtualListProps<T = unknown> {
|
|
19
|
+
/** Full dataset; only visible indices are rendered. */
|
|
20
|
+
data: T[];
|
|
21
|
+
/** Fixed row height or per-index height resolver in pixels. */
|
|
22
|
+
itemHeight: number | ((index: number) => number);
|
|
23
|
+
/** Extra rows rendered above and below the viewport. */
|
|
24
|
+
overscan?: number;
|
|
25
|
+
/** Renders one item with absolute positioning styles applied by the list. */
|
|
26
|
+
renderItem: (item: T, index: number, style: React__default.CSSProperties) => React__default.ReactNode;
|
|
27
|
+
/** Scrolling container class name. */
|
|
28
|
+
className?: string;
|
|
29
|
+
/** Scrolling container inline style. */
|
|
30
|
+
style?: React__default.CSSProperties;
|
|
31
|
+
/** Stable React key for each item; defaults to row index. */
|
|
32
|
+
itemKey?: (item: T, index: number) => React__default.Key;
|
|
33
|
+
}
|
|
34
|
+
/** Imperative API for `VirtualList`. */
|
|
35
|
+
interface VirtualListRef {
|
|
36
|
+
/**
|
|
37
|
+
* Scrolls so the item at `index` is visible.
|
|
38
|
+
* @param align - Where to place the item in the viewport.
|
|
39
|
+
*/
|
|
40
|
+
scrollToIndex: (index: number, align?: 'start' | 'center' | 'end') => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Virtualized scroll container: mounts row content only for items near the viewport.
|
|
44
|
+
* Forwards a ref with `scrollToIndex` for programmatic scrolling.
|
|
45
|
+
*/
|
|
46
|
+
declare const VirtualList: <T>(props: VirtualListProps<T> & {
|
|
47
|
+
ref?: React__default.Ref<VirtualListRef>;
|
|
48
|
+
}) => React__default.ReactElement;
|
|
49
|
+
|
|
50
|
+
export { type UseVirtualScrollOptions, type UseVirtualScrollReturn, VirtualList, type VirtualListProps, type VirtualListRef, useVirtualScroll };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { VirtualRange, VirtualEngine } from '@skygraph/core';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
interface UseVirtualScrollOptions {
|
|
5
|
+
itemCount: number;
|
|
6
|
+
itemHeight: number | ((index: number) => number);
|
|
7
|
+
overscan?: number;
|
|
8
|
+
}
|
|
9
|
+
interface UseVirtualScrollReturn {
|
|
10
|
+
range: VirtualRange;
|
|
11
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
12
|
+
scrollToIndex: (index: number, align?: 'start' | 'center' | 'end') => void;
|
|
13
|
+
engine: VirtualEngine;
|
|
14
|
+
}
|
|
15
|
+
declare function useVirtualScroll(options: UseVirtualScrollOptions): UseVirtualScrollReturn;
|
|
16
|
+
|
|
17
|
+
/** Props for the virtualized fixed-height item list. */
|
|
18
|
+
interface VirtualListProps<T = unknown> {
|
|
19
|
+
/** Full dataset; only visible indices are rendered. */
|
|
20
|
+
data: T[];
|
|
21
|
+
/** Fixed row height or per-index height resolver in pixels. */
|
|
22
|
+
itemHeight: number | ((index: number) => number);
|
|
23
|
+
/** Extra rows rendered above and below the viewport. */
|
|
24
|
+
overscan?: number;
|
|
25
|
+
/** Renders one item with absolute positioning styles applied by the list. */
|
|
26
|
+
renderItem: (item: T, index: number, style: React__default.CSSProperties) => React__default.ReactNode;
|
|
27
|
+
/** Scrolling container class name. */
|
|
28
|
+
className?: string;
|
|
29
|
+
/** Scrolling container inline style. */
|
|
30
|
+
style?: React__default.CSSProperties;
|
|
31
|
+
/** Stable React key for each item; defaults to row index. */
|
|
32
|
+
itemKey?: (item: T, index: number) => React__default.Key;
|
|
33
|
+
}
|
|
34
|
+
/** Imperative API for `VirtualList`. */
|
|
35
|
+
interface VirtualListRef {
|
|
36
|
+
/**
|
|
37
|
+
* Scrolls so the item at `index` is visible.
|
|
38
|
+
* @param align - Where to place the item in the viewport.
|
|
39
|
+
*/
|
|
40
|
+
scrollToIndex: (index: number, align?: 'start' | 'center' | 'end') => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Virtualized scroll container: mounts row content only for items near the viewport.
|
|
44
|
+
* Forwards a ref with `scrollToIndex` for programmatic scrolling.
|
|
45
|
+
*/
|
|
46
|
+
declare const VirtualList: <T>(props: VirtualListProps<T> & {
|
|
47
|
+
ref?: React__default.Ref<VirtualListRef>;
|
|
48
|
+
}) => React__default.ReactElement;
|
|
49
|
+
|
|
50
|
+
export { type UseVirtualScrollOptions, type UseVirtualScrollReturn, VirtualList, type VirtualListProps, type VirtualListRef, useVirtualScroll };
|
package/dist/virtual.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|