@ark-ui/solid 5.17.0 → 5.18.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/dist/chunk/7HON4OS6.js +217 -0
- package/dist/chunk/{P7WR6WX5.js → HJFJPRY5.js} +1 -1
- package/dist/chunk/{FQGMWBGA.js → HSBJVWHB.js} +1 -1
- package/dist/chunk/{KAYDBHSW.jsx → IDNDLSEV.jsx} +4 -4
- package/dist/chunk/{JEPST7BN.jsx → LBI4ZRKN.jsx} +5 -3
- package/dist/chunk/{AKYIM67Z.jsx → UYFUB47A.jsx} +5 -3
- package/dist/chunk/{NCRPFSNO.jsx → VR5BNKL7.jsx} +4 -4
- package/dist/chunk/XFW6RT6G.js +321 -0
- package/dist/chunk/YRHUWQ7U.jsx +237 -0
- package/dist/chunk/ZHSHZ7SJ.jsx +240 -0
- package/dist/components/accordion/index.jsx +3 -3
- package/dist/components/angle-slider/index.jsx +2 -2
- package/dist/components/avatar/index.jsx +2 -2
- package/dist/components/carousel/index.jsx +2 -2
- package/dist/components/checkbox/index.d.ts +1 -1
- package/dist/components/checkbox/index.jsx +2 -2
- package/dist/components/clipboard/index.jsx +1 -1
- package/dist/components/collapsible/index.jsx +2 -2
- package/dist/components/collection/index.d.ts +105 -3
- package/dist/components/collection/index.js +1 -1
- package/dist/components/collection/index.jsx +5 -3
- package/dist/components/color-picker/index.d.ts +1 -1
- package/dist/components/color-picker/index.jsx +2 -2
- package/dist/components/combobox/index.js +1 -1
- package/dist/components/combobox/index.jsx +3 -3
- package/dist/components/date-picker/index.d.ts +1 -1
- package/dist/components/date-picker/index.jsx +2 -2
- package/dist/components/dialog/index.jsx +2 -2
- package/dist/components/download-trigger/index.jsx +1 -1
- package/dist/components/editable/index.jsx +2 -2
- package/dist/components/field/index.d.ts +1 -1
- package/dist/components/field/index.jsx +1 -1
- package/dist/components/fieldset/index.d.ts +1 -1
- package/dist/components/fieldset/index.jsx +1 -1
- package/dist/components/file-upload/index.js +1 -1
- package/dist/components/file-upload/index.jsx +2 -2
- package/dist/components/floating-panel/index.jsx +2 -2
- package/dist/components/format/index.jsx +1 -1
- package/dist/components/frame/index.jsx +1 -1
- package/dist/components/hover-card/index.jsx +2 -2
- package/dist/components/index.d.ts +4 -1
- package/dist/components/index.js +28 -27
- package/dist/components/index.jsx +462 -450
- package/dist/components/json-tree-view/index.d.ts +69 -0
- package/dist/components/json-tree-view/index.js +1 -0
- package/dist/components/json-tree-view/index.jsx +26 -0
- package/dist/components/listbox/index.js +1 -1
- package/dist/components/listbox/index.jsx +3 -3
- package/dist/components/menu/index.jsx +2 -2
- package/dist/components/number-input/index.jsx +2 -2
- package/dist/components/pagination/index.jsx +2 -2
- package/dist/components/password-input/index.jsx +2 -2
- package/dist/components/pin-input/index.jsx +2 -2
- package/dist/components/popover/index.jsx +2 -2
- package/dist/components/progress/index.jsx +2 -2
- package/dist/components/qr-code/index.jsx +2 -2
- package/dist/components/radio-group/index.jsx +2 -2
- package/dist/components/rating-group/index.jsx +2 -2
- package/dist/components/segment-group/index.jsx +2 -2
- package/dist/components/select/index.js +1 -1
- package/dist/components/select/index.jsx +3 -3
- package/dist/components/signature-pad/index.js +1 -1
- package/dist/components/signature-pad/index.jsx +2 -2
- package/dist/components/slider/index.jsx +2 -2
- package/dist/components/splitter/index.jsx +2 -2
- package/dist/components/steps/index.jsx +2 -2
- package/dist/components/switch/index.jsx +2 -2
- package/dist/components/tabs/index.jsx +2 -2
- package/dist/components/tags-input/index.jsx +2 -2
- package/dist/components/time-picker/index.jsx +2 -2
- package/dist/components/timer/index.jsx +1 -1
- package/dist/components/toast/index.jsx +2 -2
- package/dist/components/toggle-group/index.jsx +2 -2
- package/dist/components/tooltip/index.jsx +2 -2
- package/dist/components/tour/index.jsx +2 -2
- package/dist/components/tree-view/index.d.ts +9 -39
- package/dist/components/tree-view/index.js +1 -1
- package/dist/components/tree-view/index.jsx +4 -4
- package/dist/index.d.ts +5 -2
- package/dist/index.js +28 -27
- package/dist/index.jsx +465 -453
- package/dist/providers/index.jsx +4 -4
- package/dist/tree-view-tree-CbBeWSwi.d.ts +41 -0
- package/package.json +63 -62
- package/dist/chunk/AQUEJK4Z.jsx +0 -122
- package/dist/chunk/XL4VFEPW.js +0 -104
- package/dist/chunk/{XUH2TAUG.jsx → 4L4266PL.jsx} +3 -3
- package/dist/chunk/{2WR5J3OZ.jsx → 6XAZQVOY.jsx} +3 -3
- package/dist/chunk/{HP3ZGMDZ.jsx → 7FASJWDK.jsx} +3 -3
- package/dist/chunk/{ZTNABPZL.jsx → 7OXBQSIZ.jsx} +3 -3
- package/dist/chunk/{YAOPG62Z.jsx → 7RYPC5LL.jsx} +3 -3
- package/dist/chunk/{4FUKCXPR.jsx → 7UNWOGPT.jsx} +3 -3
- package/dist/chunk/{35XSFKD5.jsx → CINP4S7J.jsx} +3 -3
- package/dist/chunk/{ZSMY7WCA.jsx → D2MI7N5P.jsx} +3 -3
- package/dist/chunk/{PPQSRJ6X.jsx → DLZTFD37.jsx} +3 -3
- package/dist/chunk/{4UNGYCFT.jsx → FG427CLW.jsx} +3 -3
- package/dist/chunk/{2UVDYZIY.jsx → FOIEK72O.jsx} +3 -3
- package/dist/chunk/{HDKSS6KE.jsx → GLN6WFQR.jsx} +3 -3
- package/dist/chunk/{WOUVNHGI.jsx → H4MJ4254.jsx} +3 -3
- package/dist/chunk/{BJ3QT4LE.jsx → H7TJLB3R.jsx} +0 -0
- package/dist/chunk/{CBGZAFEX.jsx → I7VQFKYT.jsx} +3 -3
- package/dist/chunk/{3DOPQCHJ.jsx → JK6QXH6B.jsx} +3 -3
- package/dist/chunk/{UW5WJ2LL.jsx → JKM73NGJ.jsx} +3 -3
- package/dist/chunk/{3WT7Q753.jsx → L22RABDV.jsx} +3 -3
- package/dist/chunk/{U5CBLW6U.jsx → L5XYJCAK.jsx} +3 -3
- package/dist/chunk/{NPHS6PVV.jsx → MJTOTU2A.jsx} +3 -3
- package/dist/chunk/{QBN5FEQF.js → NWXJCBMN.js} +0 -0
- package/dist/chunk/{OKNWZYMH.jsx → OM7DNJ6L.jsx} +3 -3
- package/dist/chunk/{JUBTXT4B.jsx → OM7V7VVC.jsx} +3 -3
- package/dist/chunk/{5U4KEVIU.jsx → PRA2XFQE.jsx} +3 -3
- package/dist/chunk/{MM6NNI6M.jsx → QXYWHKF7.jsx} +3 -3
- package/dist/chunk/{QC5C6JJA.jsx → V6S3C3U7.jsx} +3 -3
- package/dist/chunk/{LKPEYZZO.jsx → V75EMOIC.jsx} +3 -3
- package/dist/chunk/{S4OS4UYL.jsx → VXQNQSLM.jsx} +3 -3
- package/dist/chunk/{ZNBZTQ46.jsx → WBLWV2L4.jsx} +3 -3
- package/dist/chunk/{POJRD725.jsx → X5GWQYGE.jsx} +3 -3
- package/dist/chunk/{WG67YHCV.jsx → XENPQFEN.jsx} +3 -3
- package/dist/chunk/{AHH5Z3VJ.jsx → XOIHVYJ7.jsx} +3 -3
- package/dist/chunk/{N3H47LNB.jsx → XSGHIZ6Q.jsx} +3 -3
- package/dist/chunk/{L64MXP66.jsx → Y2LC36B4.jsx} +3 -3
- package/dist/chunk/{XKBIT7L5.jsx → YJX4W6VT.jsx} +3 -3
- package/dist/chunk/{RC4UV6HP.jsx → YM35RFYG.jsx} +3 -3
- package/dist/chunk/{WHXDBQDP.jsx → Z2BXVXSV.jsx} +3 -3
- package/dist/chunk/{3B7I46SI.jsx → ZHLQWQXX.jsx} +3 -3
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tree_view_exports,
|
|
3
|
+
useTreeView,
|
|
4
|
+
useTreeViewContext
|
|
5
|
+
} from "./VR5BNKL7.jsx";
|
|
6
|
+
import {
|
|
7
|
+
createTreeCollection
|
|
8
|
+
} from "./ZHSHZ7SJ.jsx";
|
|
9
|
+
import {
|
|
10
|
+
createSplitProps
|
|
11
|
+
} from "./6WEDGJKQ.jsx";
|
|
12
|
+
import {
|
|
13
|
+
createContext
|
|
14
|
+
} from "./TVCIHLER.jsx";
|
|
15
|
+
import {
|
|
16
|
+
__export
|
|
17
|
+
} from "./7IUG3E2V.jsx";
|
|
18
|
+
|
|
19
|
+
// src/components/json-tree-view/json-tree-view-root.tsx
|
|
20
|
+
import { getRootNode, nodeToString, nodeToValue } from "@zag-js/json-tree-utils";
|
|
21
|
+
import { createMemo, splitProps } from "solid-js";
|
|
22
|
+
|
|
23
|
+
// src/components/json-tree-view/get-branch-value.ts
|
|
24
|
+
function getBranchValues(tree, depth) {
|
|
25
|
+
let values = [];
|
|
26
|
+
tree.visit({
|
|
27
|
+
onEnter: (node, indexPath) => {
|
|
28
|
+
if (indexPath.length === 0) return;
|
|
29
|
+
if (tree.isBranchNode(node) && indexPath.length <= depth) {
|
|
30
|
+
values.push(tree.getNodeValue(node));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return values;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/components/json-tree-view/json-tree-view-props-context.ts
|
|
38
|
+
var [JsonTreeViewPropsProvider, useJsonTreeViewPropsContext] = createContext({
|
|
39
|
+
hookName: "useJsonTreeViewPropsContext",
|
|
40
|
+
providerName: "<JsonTreeViewPropsProvider />"
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/components/json-tree-view/json-tree-view-root.tsx
|
|
44
|
+
var splitJsonTreeViewProps = createSplitProps();
|
|
45
|
+
var JsonTreeViewRoot = (props) => {
|
|
46
|
+
const [jsonTreeProps, localProps] = splitJsonTreeViewProps(props, [
|
|
47
|
+
"maxPreviewItems",
|
|
48
|
+
"collapseStringsAfterLength",
|
|
49
|
+
"quotesOnKeys",
|
|
50
|
+
"groupArraysAfterLength",
|
|
51
|
+
"showNonenumerable"
|
|
52
|
+
]);
|
|
53
|
+
const [jsonProps, restProps] = splitProps(localProps, ["data", "defaultExpandedDepth"]);
|
|
54
|
+
const collection = createMemo(() => {
|
|
55
|
+
return createTreeCollection({
|
|
56
|
+
nodeToValue,
|
|
57
|
+
nodeToString,
|
|
58
|
+
rootNode: getRootNode(jsonProps.data)
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
const defaultExpandedValue = createMemo(() => {
|
|
62
|
+
return jsonProps.defaultExpandedDepth != null ? getBranchValues(collection(), jsonProps.defaultExpandedDepth) : void 0;
|
|
63
|
+
});
|
|
64
|
+
return <JsonTreeViewPropsProvider value={jsonTreeProps}>
|
|
65
|
+
<tree_view_exports.Root
|
|
66
|
+
data-scope="json-tree-view"
|
|
67
|
+
collection={collection()}
|
|
68
|
+
defaultExpandedValue={defaultExpandedValue()}
|
|
69
|
+
{...restProps}
|
|
70
|
+
>
|
|
71
|
+
{props.children}
|
|
72
|
+
</tree_view_exports.Root>
|
|
73
|
+
</JsonTreeViewPropsProvider>;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/components/json-tree-view/json-tree-view-root-provider.tsx
|
|
77
|
+
var JsonTreeViewRootProvider = (props) => {
|
|
78
|
+
return <tree_view_exports.RootProvider data-scope="json-tree-view" {...props} />;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/components/json-tree-view/json-tree-view-tree.tsx
|
|
82
|
+
import { Index as Index2 } from "solid-js";
|
|
83
|
+
|
|
84
|
+
// src/components/json-tree-view/json-tree-view-node.tsx
|
|
85
|
+
import {
|
|
86
|
+
getAccessibleDescription,
|
|
87
|
+
jsonNodeToElement,
|
|
88
|
+
keyPathToKey as keyPathToKey2
|
|
89
|
+
} from "@zag-js/json-tree-utils";
|
|
90
|
+
import { createMemo as createMemo3 } from "solid-js";
|
|
91
|
+
import { Index, Show } from "solid-js/web";
|
|
92
|
+
|
|
93
|
+
// src/components/json-tree-view/json-tree-view-key-node.tsx
|
|
94
|
+
import { keyPathToKey } from "@zag-js/json-tree-utils";
|
|
95
|
+
import { createMemo as createMemo2 } from "solid-js";
|
|
96
|
+
var JsonTreeViewKeyNode = (props) => {
|
|
97
|
+
const key = createMemo2(() => keyPathToKey(props.node.keyPath));
|
|
98
|
+
return <>
|
|
99
|
+
<span data-kind="key" data-non-enumerable={props.node.isNonEnumerable ? "" : void 0}>
|
|
100
|
+
{props.showQuotes ? `"${key()}"` : key()}
|
|
101
|
+
</span>
|
|
102
|
+
<span data-kind="colon">: </span>
|
|
103
|
+
</>;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/components/json-tree-view/json-tree-view-value-node.tsx
|
|
107
|
+
import { For } from "solid-js";
|
|
108
|
+
import { Dynamic } from "solid-js/web";
|
|
109
|
+
var JsonTreeViewValueNode = (props) => {
|
|
110
|
+
if (props.node.type === "text") {
|
|
111
|
+
return <>{props.renderValue?.(props.node) ?? props.node.value}</>;
|
|
112
|
+
}
|
|
113
|
+
return <Dynamic
|
|
114
|
+
component={props.node.tagName}
|
|
115
|
+
data-root={props.node.properties.root ? "" : void 0}
|
|
116
|
+
data-type={props.node.properties.nodeType}
|
|
117
|
+
data-kind={props.node.properties.kind}
|
|
118
|
+
>
|
|
119
|
+
<For each={props.node.children}>
|
|
120
|
+
{(child) => <JsonTreeViewValueNode node={child} renderValue={props.renderValue} />}
|
|
121
|
+
</For>
|
|
122
|
+
</Dynamic>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// src/components/json-tree-view/json-tree-view-node.tsx
|
|
126
|
+
var scopeProps = {
|
|
127
|
+
"data-scope": "json-tree-view"
|
|
128
|
+
};
|
|
129
|
+
function JsonTreeViewNode(props) {
|
|
130
|
+
const tree = useTreeViewContext();
|
|
131
|
+
const nodeState = createMemo3(() => tree().getNodeState({ node: props.node, indexPath: props.indexPath }));
|
|
132
|
+
const options = useJsonTreeViewPropsContext();
|
|
133
|
+
const key = createMemo3(() => keyPathToKey2(props.node.keyPath, { excludeRoot: true }));
|
|
134
|
+
const valueNode = createMemo3(() => jsonNodeToElement(props.node, options));
|
|
135
|
+
const nodeProps = createMemo3(() => {
|
|
136
|
+
const desc = getAccessibleDescription(props.node);
|
|
137
|
+
const line = props.indexPath.reduce((acc, curr) => acc + curr, 1);
|
|
138
|
+
const lineLength = props.indexPath.length - 1;
|
|
139
|
+
return {
|
|
140
|
+
...scopeProps,
|
|
141
|
+
"aria-label": desc,
|
|
142
|
+
"data-line": line,
|
|
143
|
+
style: { ["--line-length"]: lineLength }
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
return <tree_view_exports.NodeProvider node={props.node} indexPath={props.indexPath}>
|
|
147
|
+
<Show
|
|
148
|
+
when={nodeState().isBranch}
|
|
149
|
+
fallback={<tree_view_exports.Item {...nodeProps()}>
|
|
150
|
+
<tree_view_exports.ItemText {...scopeProps}>
|
|
151
|
+
<Show when={key()}>
|
|
152
|
+
<JsonTreeViewKeyNode node={props.node} showQuotes={options.quotesOnKeys} />
|
|
153
|
+
</Show>
|
|
154
|
+
<JsonTreeViewValueNode node={valueNode()} renderValue={props.renderValue} />
|
|
155
|
+
</tree_view_exports.ItemText>
|
|
156
|
+
</tree_view_exports.Item>}
|
|
157
|
+
>
|
|
158
|
+
<tree_view_exports.Branch {...scopeProps}>
|
|
159
|
+
<tree_view_exports.BranchControl {...nodeProps()}>
|
|
160
|
+
<Show when={props.arrow}>
|
|
161
|
+
<tree_view_exports.BranchIndicator {...scopeProps}>{props.arrow}</tree_view_exports.BranchIndicator>
|
|
162
|
+
</Show>
|
|
163
|
+
<tree_view_exports.BranchText {...scopeProps}>
|
|
164
|
+
<Show when={key()}>
|
|
165
|
+
<JsonTreeViewKeyNode node={props.node} showQuotes={options.quotesOnKeys} />
|
|
166
|
+
</Show>
|
|
167
|
+
<JsonTreeViewValueNode node={valueNode()} renderValue={props.renderValue} />
|
|
168
|
+
</tree_view_exports.BranchText>
|
|
169
|
+
</tree_view_exports.BranchControl>
|
|
170
|
+
<tree_view_exports.BranchContent {...scopeProps}>
|
|
171
|
+
<Show when={typeof props.indentGuide === "boolean"} fallback={props.indentGuide}>
|
|
172
|
+
<tree_view_exports.BranchIndentGuide />
|
|
173
|
+
</Show>
|
|
174
|
+
<Index each={props.node.children}>
|
|
175
|
+
{(child, index) => <JsonTreeViewNode {...props} node={child()} indexPath={[...props.indexPath, index]} />}
|
|
176
|
+
</Index>
|
|
177
|
+
</tree_view_exports.BranchContent>
|
|
178
|
+
</tree_view_exports.Branch>
|
|
179
|
+
</Show>
|
|
180
|
+
</tree_view_exports.NodeProvider>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/components/json-tree-view/json-tree-view-tree.tsx
|
|
184
|
+
var splitTreeNodeProps = createSplitProps();
|
|
185
|
+
var JsonTreeViewTree = (props) => {
|
|
186
|
+
const [nodeProps, treeProps] = splitTreeNodeProps(props, ["arrow", "indentGuide", "renderValue"]);
|
|
187
|
+
const tree = useTreeViewContext();
|
|
188
|
+
const children = () => tree().collection.getNodeChildren(tree().collection.rootNode);
|
|
189
|
+
return <tree_view_exports.Tree data-scope="json-tree-view" {...treeProps}>
|
|
190
|
+
<Index2 each={children()}>
|
|
191
|
+
{(child, index) => <JsonTreeViewNode node={child()} indexPath={[index]} {...nodeProps} />}
|
|
192
|
+
</Index2>
|
|
193
|
+
</tree_view_exports.Tree>;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// src/components/json-tree-view/use-json-tree-view.ts
|
|
197
|
+
import { getRootNode as getRootNode2, nodeToString as nodeToString2, nodeToValue as nodeToValue2 } from "@zag-js/json-tree-utils";
|
|
198
|
+
import { createMemo as createMemo4, splitProps as splitProps2 } from "solid-js";
|
|
199
|
+
import { untrack } from "solid-js/web";
|
|
200
|
+
var useJsonTreeView = (props) => {
|
|
201
|
+
const [jsonProps, restProps] = splitProps2(props, ["data", "defaultExpandedDepth"]);
|
|
202
|
+
const collection = createMemo4(() => {
|
|
203
|
+
return createTreeCollection({
|
|
204
|
+
nodeToValue: nodeToValue2,
|
|
205
|
+
nodeToString: nodeToString2,
|
|
206
|
+
rootNode: getRootNode2(jsonProps.data)
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
const defaultExpandedValue = createMemo4(() => {
|
|
210
|
+
return jsonProps.defaultExpandedDepth != null ? getBranchValues(collection(), jsonProps.defaultExpandedDepth) : void 0;
|
|
211
|
+
});
|
|
212
|
+
const machineProps = createMemo4(() => {
|
|
213
|
+
return {
|
|
214
|
+
defaultExpandedValue: untrack(defaultExpandedValue),
|
|
215
|
+
...restProps,
|
|
216
|
+
collection: collection(),
|
|
217
|
+
typeahead: false
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
return useTreeView(machineProps);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// src/components/json-tree-view/json-tree-view.tsx
|
|
224
|
+
var json_tree_view_exports = {};
|
|
225
|
+
__export(json_tree_view_exports, {
|
|
226
|
+
Root: () => JsonTreeViewRoot,
|
|
227
|
+
RootProvider: () => JsonTreeViewRootProvider,
|
|
228
|
+
Tree: () => JsonTreeViewTree
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export {
|
|
232
|
+
JsonTreeViewRoot,
|
|
233
|
+
JsonTreeViewRootProvider,
|
|
234
|
+
JsonTreeViewTree,
|
|
235
|
+
useJsonTreeView,
|
|
236
|
+
json_tree_view_exports
|
|
237
|
+
};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// src/components/collection/grid-collection.ts
|
|
2
|
+
import {
|
|
3
|
+
GridCollection
|
|
4
|
+
} from "@zag-js/collection";
|
|
5
|
+
var createGridCollection = (options) => new GridCollection(options);
|
|
6
|
+
|
|
7
|
+
// src/components/collection/list-collection.ts
|
|
8
|
+
import { ListCollection } from "@zag-js/collection";
|
|
9
|
+
var createListCollection = (options) => new ListCollection(options);
|
|
10
|
+
|
|
11
|
+
// src/components/collection/tree-collection.ts
|
|
12
|
+
import {
|
|
13
|
+
TreeCollection,
|
|
14
|
+
filePathToTree
|
|
15
|
+
} from "@zag-js/collection";
|
|
16
|
+
var createTreeCollection = (options) => new TreeCollection(options);
|
|
17
|
+
var createFileTreeCollection = (paths) => filePathToTree(paths);
|
|
18
|
+
|
|
19
|
+
// src/components/collection/use-list-collection.ts
|
|
20
|
+
import { createMemo, createSignal, splitProps } from "solid-js";
|
|
21
|
+
function useListCollection(props) {
|
|
22
|
+
const splittedProps = createMemo(() => {
|
|
23
|
+
const rawProps = typeof props === "function" ? props() : props;
|
|
24
|
+
return splitProps(rawProps, ["initialItems", "filter", "limit"]);
|
|
25
|
+
});
|
|
26
|
+
const init = () => {
|
|
27
|
+
const [localProps] = splittedProps();
|
|
28
|
+
return localProps.initialItems;
|
|
29
|
+
};
|
|
30
|
+
const [items, setItemsImpl] = createSignal(init());
|
|
31
|
+
const [filterText, setFilterText] = createSignal("");
|
|
32
|
+
const setItems = (newItems) => {
|
|
33
|
+
setItemsImpl(newItems);
|
|
34
|
+
setFilterText("");
|
|
35
|
+
};
|
|
36
|
+
const create = (itemsToCreate) => {
|
|
37
|
+
const [, collectionOptions] = splittedProps();
|
|
38
|
+
return createListCollection({ ...collectionOptions, items: itemsToCreate });
|
|
39
|
+
};
|
|
40
|
+
const collection = createMemo(() => {
|
|
41
|
+
const [localProps, collectionOptions] = splittedProps();
|
|
42
|
+
const filter = localProps.filter;
|
|
43
|
+
let activeItems = items();
|
|
44
|
+
if (filterText() && filter) {
|
|
45
|
+
activeItems = create(items()).filter((itemString, _index, item) => filter(itemString, filterText(), item)).items;
|
|
46
|
+
}
|
|
47
|
+
const limitedItems = localProps.limit == null ? activeItems : activeItems.slice(0, localProps.limit);
|
|
48
|
+
return createListCollection({ ...collectionOptions, items: limitedItems });
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
collection,
|
|
52
|
+
filter: (inputValue = "") => {
|
|
53
|
+
setFilterText(inputValue);
|
|
54
|
+
},
|
|
55
|
+
set: (newItems) => {
|
|
56
|
+
setItems(newItems);
|
|
57
|
+
},
|
|
58
|
+
reset: () => {
|
|
59
|
+
const [localProps] = splittedProps();
|
|
60
|
+
setItems(localProps.initialItems);
|
|
61
|
+
},
|
|
62
|
+
clear: () => {
|
|
63
|
+
setItems([]);
|
|
64
|
+
},
|
|
65
|
+
insert: (index, ...itemsToInsert) => {
|
|
66
|
+
const newItems = create(items()).insert(index, ...itemsToInsert).items;
|
|
67
|
+
setItems(newItems);
|
|
68
|
+
},
|
|
69
|
+
insertBefore: (value, ...itemsToInsert) => {
|
|
70
|
+
const newItems = create(items()).insertBefore(value, ...itemsToInsert).items;
|
|
71
|
+
setItems(newItems);
|
|
72
|
+
},
|
|
73
|
+
insertAfter: (value, ...itemsToInsert) => {
|
|
74
|
+
const newItems = create(items()).insertAfter(value, ...itemsToInsert).items;
|
|
75
|
+
setItems(newItems);
|
|
76
|
+
},
|
|
77
|
+
remove: (...itemOrValues) => {
|
|
78
|
+
const newItems = create(items()).remove(...itemOrValues).items;
|
|
79
|
+
setItems(newItems);
|
|
80
|
+
},
|
|
81
|
+
move: (value, to) => {
|
|
82
|
+
const newItems = create(items()).move(value, to).items;
|
|
83
|
+
setItems(newItems);
|
|
84
|
+
},
|
|
85
|
+
moveBefore: (value, ...values) => {
|
|
86
|
+
const newItems = create(items()).moveBefore(value, ...values).items;
|
|
87
|
+
setItems(newItems);
|
|
88
|
+
},
|
|
89
|
+
moveAfter: (value, ...values) => {
|
|
90
|
+
const newItems = create(items()).moveAfter(value, ...values).items;
|
|
91
|
+
setItems(newItems);
|
|
92
|
+
},
|
|
93
|
+
reorder: (from, to) => {
|
|
94
|
+
const newItems = create(items()).reorder(from, to).items;
|
|
95
|
+
setItems(newItems);
|
|
96
|
+
},
|
|
97
|
+
append: (...itemsToAppend) => {
|
|
98
|
+
const newItems = create(items()).append(...itemsToAppend).items;
|
|
99
|
+
setItems(newItems);
|
|
100
|
+
},
|
|
101
|
+
upsert: (value, item, mode = "append") => {
|
|
102
|
+
const newItems = create(items()).upsert(value, item, mode).items;
|
|
103
|
+
setItems(newItems);
|
|
104
|
+
},
|
|
105
|
+
prepend: (...itemsToPrepend) => {
|
|
106
|
+
const newItems = create(items()).prepend(...itemsToPrepend).items;
|
|
107
|
+
setItems(newItems);
|
|
108
|
+
},
|
|
109
|
+
update: (value, item) => {
|
|
110
|
+
const newItems = create(items()).update(value, item).items;
|
|
111
|
+
setItems(newItems);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/components/collection/use-list-selection.ts
|
|
117
|
+
import { Selection } from "@zag-js/collection";
|
|
118
|
+
import { createEffect, createMemo as createMemo2, createSignal as createSignal2, on, splitProps as splitProps2 } from "solid-js";
|
|
119
|
+
function useListSelection(props) {
|
|
120
|
+
const splittedProps = createMemo2(() => {
|
|
121
|
+
const rawProps = typeof props === "function" ? props() : props;
|
|
122
|
+
return splitProps2(rawProps, [
|
|
123
|
+
"collection",
|
|
124
|
+
"selectionMode",
|
|
125
|
+
"deselectable",
|
|
126
|
+
"initialSelectedValues",
|
|
127
|
+
"resetOnCollectionChange"
|
|
128
|
+
]);
|
|
129
|
+
});
|
|
130
|
+
const createSelection = (values = []) => {
|
|
131
|
+
const [localProps] = splittedProps();
|
|
132
|
+
const selection2 = new Selection(values);
|
|
133
|
+
selection2.selectionMode = localProps.selectionMode ?? "single";
|
|
134
|
+
selection2.deselectable = localProps.deselectable ?? true;
|
|
135
|
+
return selection2;
|
|
136
|
+
};
|
|
137
|
+
const init = () => {
|
|
138
|
+
const [localProps] = splittedProps();
|
|
139
|
+
return createSelection(localProps.initialSelectedValues ?? []);
|
|
140
|
+
};
|
|
141
|
+
const [selection, setSelection] = createSignal2(init());
|
|
142
|
+
const watchDeps = () => {
|
|
143
|
+
const [{ collection, resetOnCollectionChange }] = splittedProps();
|
|
144
|
+
return [collection.getValues(), resetOnCollectionChange];
|
|
145
|
+
};
|
|
146
|
+
createEffect(
|
|
147
|
+
on(
|
|
148
|
+
watchDeps,
|
|
149
|
+
([, resetOnCollectionChange]) => {
|
|
150
|
+
if (resetOnCollectionChange) {
|
|
151
|
+
setSelection(createSelection());
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{ defer: true }
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
const selectedValues = createMemo2(() => Array.from(selection()));
|
|
158
|
+
const isEmpty = createMemo2(() => selection().isEmpty());
|
|
159
|
+
const firstSelectedValue = createMemo2(() => {
|
|
160
|
+
const [localProps] = splittedProps();
|
|
161
|
+
return selection().firstSelectedValue(localProps.collection);
|
|
162
|
+
});
|
|
163
|
+
const lastSelectedValue = createMemo2(() => {
|
|
164
|
+
const [localProps] = splittedProps();
|
|
165
|
+
return selection().lastSelectedValue(localProps.collection);
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
selectedValues,
|
|
169
|
+
isEmpty,
|
|
170
|
+
firstSelectedValue,
|
|
171
|
+
lastSelectedValue,
|
|
172
|
+
isSelected: (value) => {
|
|
173
|
+
return selection().isSelected(value);
|
|
174
|
+
},
|
|
175
|
+
isAllSelected: () => {
|
|
176
|
+
const [localProps] = splittedProps();
|
|
177
|
+
const allValues = localProps.collection.getValues();
|
|
178
|
+
return allValues.length > 0 && allValues.every((value) => selection().isSelected(value));
|
|
179
|
+
},
|
|
180
|
+
isSomeSelected: () => {
|
|
181
|
+
const [localProps] = splittedProps();
|
|
182
|
+
const allValues = localProps.collection.getValues();
|
|
183
|
+
return allValues.some((value) => selection().isSelected(value));
|
|
184
|
+
},
|
|
185
|
+
canSelect: (value) => {
|
|
186
|
+
const [localProps] = splittedProps();
|
|
187
|
+
return selection().canSelect(localProps.collection, value);
|
|
188
|
+
},
|
|
189
|
+
select: (value, forceToggle) => {
|
|
190
|
+
const [localProps] = splittedProps();
|
|
191
|
+
setSelection(selection().select(localProps.collection, value, forceToggle));
|
|
192
|
+
},
|
|
193
|
+
deselect: (value) => {
|
|
194
|
+
setSelection(selection().deselect(value));
|
|
195
|
+
},
|
|
196
|
+
toggle: (value) => {
|
|
197
|
+
const [localProps] = splittedProps();
|
|
198
|
+
setSelection(selection().toggleSelection(localProps.collection, value));
|
|
199
|
+
},
|
|
200
|
+
replace: (value) => {
|
|
201
|
+
const [localProps] = splittedProps();
|
|
202
|
+
setSelection(selection().replaceSelection(localProps.collection, value));
|
|
203
|
+
},
|
|
204
|
+
extend: (anchorValue, targetValue) => {
|
|
205
|
+
const [localProps] = splittedProps();
|
|
206
|
+
setSelection(selection().extendSelection(localProps.collection, anchorValue, targetValue));
|
|
207
|
+
},
|
|
208
|
+
setSelectedValues: (values) => {
|
|
209
|
+
setSelection(selection().setSelection(values));
|
|
210
|
+
},
|
|
211
|
+
clear: () => {
|
|
212
|
+
setSelection(selection().clearSelection());
|
|
213
|
+
},
|
|
214
|
+
resetSelection: () => {
|
|
215
|
+
setSelection(createSelection());
|
|
216
|
+
},
|
|
217
|
+
setSelection: (newSelection) => {
|
|
218
|
+
setSelection(selection().setSelection(newSelection));
|
|
219
|
+
},
|
|
220
|
+
setSelectionMode: (mode) => {
|
|
221
|
+
const newSelection = selection().copy();
|
|
222
|
+
newSelection.selectionMode = mode;
|
|
223
|
+
setSelection(newSelection);
|
|
224
|
+
},
|
|
225
|
+
setDeselectable: (deselectable) => {
|
|
226
|
+
const newSelection = selection().copy();
|
|
227
|
+
newSelection.deselectable = deselectable;
|
|
228
|
+
setSelection(newSelection);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
createGridCollection,
|
|
235
|
+
createListCollection,
|
|
236
|
+
createTreeCollection,
|
|
237
|
+
createFileTreeCollection,
|
|
238
|
+
useListCollection,
|
|
239
|
+
useListSelection
|
|
240
|
+
};
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
useAccordion,
|
|
13
13
|
useAccordionContext,
|
|
14
14
|
useAccordionItemContext
|
|
15
|
-
} from "../../chunk/
|
|
16
|
-
import "../../chunk/
|
|
15
|
+
} from "../../chunk/IDNDLSEV.jsx";
|
|
16
|
+
import "../../chunk/Z2BXVXSV.jsx";
|
|
17
17
|
import "../../chunk/NEBB7COJ.jsx";
|
|
18
18
|
import "../../chunk/6WEDGJKQ.jsx";
|
|
19
19
|
import "../../chunk/UFYZ7HLU.jsx";
|
|
20
20
|
import "../../chunk/ODQYYKL5.jsx";
|
|
21
|
-
import "../../chunk/E2L62MKC.jsx";
|
|
22
21
|
import "../../chunk/YUC6JE7K.jsx";
|
|
22
|
+
import "../../chunk/E2L62MKC.jsx";
|
|
23
23
|
import "../../chunk/TVCIHLER.jsx";
|
|
24
24
|
import "../../chunk/KGOB2IMX.jsx";
|
|
25
25
|
import "../../chunk/7IUG3E2V.jsx";
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
angle_slider_exports,
|
|
14
14
|
useAngleSlider,
|
|
15
15
|
useAngleSliderContext
|
|
16
|
-
} from "../../chunk/
|
|
16
|
+
} from "../../chunk/X5GWQYGE.jsx";
|
|
17
17
|
import "../../chunk/6WEDGJKQ.jsx";
|
|
18
18
|
import "../../chunk/UFYZ7HLU.jsx";
|
|
19
19
|
import "../../chunk/ODQYYKL5.jsx";
|
|
20
|
-
import "../../chunk/E2L62MKC.jsx";
|
|
21
20
|
import "../../chunk/YUC6JE7K.jsx";
|
|
21
|
+
import "../../chunk/E2L62MKC.jsx";
|
|
22
22
|
import "../../chunk/TVCIHLER.jsx";
|
|
23
23
|
import "../../chunk/KGOB2IMX.jsx";
|
|
24
24
|
import "../../chunk/7IUG3E2V.jsx";
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
avatar_exports,
|
|
9
9
|
useAvatar,
|
|
10
10
|
useAvatarContext
|
|
11
|
-
} from "../../chunk/
|
|
11
|
+
} from "../../chunk/7RYPC5LL.jsx";
|
|
12
12
|
import "../../chunk/6WEDGJKQ.jsx";
|
|
13
13
|
import "../../chunk/UFYZ7HLU.jsx";
|
|
14
14
|
import "../../chunk/ODQYYKL5.jsx";
|
|
15
|
-
import "../../chunk/E2L62MKC.jsx";
|
|
16
15
|
import "../../chunk/YUC6JE7K.jsx";
|
|
16
|
+
import "../../chunk/E2L62MKC.jsx";
|
|
17
17
|
import "../../chunk/TVCIHLER.jsx";
|
|
18
18
|
import "../../chunk/KGOB2IMX.jsx";
|
|
19
19
|
import "../../chunk/7IUG3E2V.jsx";
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
carousel_exports,
|
|
15
15
|
useCarousel,
|
|
16
16
|
useCarouselContext
|
|
17
|
-
} from "../../chunk/
|
|
17
|
+
} from "../../chunk/7FASJWDK.jsx";
|
|
18
18
|
import "../../chunk/6WEDGJKQ.jsx";
|
|
19
19
|
import "../../chunk/UFYZ7HLU.jsx";
|
|
20
20
|
import "../../chunk/ODQYYKL5.jsx";
|
|
21
|
-
import "../../chunk/E2L62MKC.jsx";
|
|
22
21
|
import "../../chunk/YUC6JE7K.jsx";
|
|
22
|
+
import "../../chunk/E2L62MKC.jsx";
|
|
23
23
|
import "../../chunk/TVCIHLER.jsx";
|
|
24
24
|
import "../../chunk/KGOB2IMX.jsx";
|
|
25
25
|
import "../../chunk/7IUG3E2V.jsx";
|
|
@@ -139,7 +139,7 @@ interface CheckboxRootProviderProps extends HTMLProps<'label'>, RootProviderProp
|
|
|
139
139
|
}
|
|
140
140
|
declare const CheckboxRootProvider: (props: CheckboxRootProviderProps) => solid_js.JSX.Element;
|
|
141
141
|
|
|
142
|
-
declare const checkboxAnatomy: _zag_js_anatomy.AnatomyInstance<"label" | "
|
|
142
|
+
declare const checkboxAnatomy: _zag_js_anatomy.AnatomyInstance<"label" | "group" | "root" | "control" | "indicator">;
|
|
143
143
|
|
|
144
144
|
declare const checkbox_CheckedChangeDetails: typeof CheckedChangeDetails;
|
|
145
145
|
declare const checkbox_CheckedState: typeof CheckedState;
|
|
@@ -14,15 +14,15 @@ import {
|
|
|
14
14
|
useCheckboxContext,
|
|
15
15
|
useCheckboxGroup,
|
|
16
16
|
useCheckboxGroupContext
|
|
17
|
-
} from "../../chunk/
|
|
17
|
+
} from "../../chunk/L22RABDV.jsx";
|
|
18
18
|
import "../../chunk/HQOIDGRU.jsx";
|
|
19
19
|
import "../../chunk/JY6PMVAK.jsx";
|
|
20
20
|
import "../../chunk/DOBZPYAN.jsx";
|
|
21
21
|
import "../../chunk/6WEDGJKQ.jsx";
|
|
22
22
|
import "../../chunk/UFYZ7HLU.jsx";
|
|
23
23
|
import "../../chunk/ODQYYKL5.jsx";
|
|
24
|
-
import "../../chunk/E2L62MKC.jsx";
|
|
25
24
|
import "../../chunk/YUC6JE7K.jsx";
|
|
25
|
+
import "../../chunk/E2L62MKC.jsx";
|
|
26
26
|
import "../../chunk/TVCIHLER.jsx";
|
|
27
27
|
import "../../chunk/KGOB2IMX.jsx";
|
|
28
28
|
import "../../chunk/7IUG3E2V.jsx";
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
import "../../chunk/6WEDGJKQ.jsx";
|
|
17
17
|
import "../../chunk/UFYZ7HLU.jsx";
|
|
18
18
|
import "../../chunk/ODQYYKL5.jsx";
|
|
19
|
-
import "../../chunk/E2L62MKC.jsx";
|
|
20
19
|
import "../../chunk/YUC6JE7K.jsx";
|
|
20
|
+
import "../../chunk/E2L62MKC.jsx";
|
|
21
21
|
import "../../chunk/TVCIHLER.jsx";
|
|
22
22
|
import "../../chunk/KGOB2IMX.jsx";
|
|
23
23
|
import "../../chunk/7IUG3E2V.jsx";
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
collapsible_exports,
|
|
10
10
|
useCollapsible,
|
|
11
11
|
useCollapsibleContext
|
|
12
|
-
} from "../../chunk/
|
|
12
|
+
} from "../../chunk/Z2BXVXSV.jsx";
|
|
13
13
|
import "../../chunk/NEBB7COJ.jsx";
|
|
14
14
|
import "../../chunk/6WEDGJKQ.jsx";
|
|
15
15
|
import "../../chunk/UFYZ7HLU.jsx";
|
|
16
16
|
import "../../chunk/ODQYYKL5.jsx";
|
|
17
|
-
import "../../chunk/E2L62MKC.jsx";
|
|
18
17
|
import "../../chunk/YUC6JE7K.jsx";
|
|
18
|
+
import "../../chunk/E2L62MKC.jsx";
|
|
19
19
|
import "../../chunk/TVCIHLER.jsx";
|
|
20
20
|
import "../../chunk/KGOB2IMX.jsx";
|
|
21
21
|
import "../../chunk/7IUG3E2V.jsx";
|