@dxos/react-ui-list 0.8.3 → 0.8.4-main.3f58842
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/lib/browser/index.mjs +47 -31
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +47 -31
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Accordion/Accordion.stories.d.ts +1 -1
- package/dist/types/src/components/Accordion/Accordion.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/List.d.ts.map +1 -1
- package/dist/types/src/components/List/List.stories.d.ts +1 -1
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/ListItem.d.ts +1 -1
- package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItemToggle.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -19
- package/src/components/Accordion/Accordion.stories.tsx +1 -1
- package/src/components/List/List.stories.tsx +1 -1
- package/src/components/List/ListItem.tsx +9 -7
- package/src/components/Tree/Tree.stories.tsx +1 -1
- package/src/components/Tree/TreeItem.tsx +2 -3
- package/src/components/Tree/TreeItemHeading.tsx +2 -3
- package/src/components/Tree/TreeItemToggle.tsx +2 -3
- package/dist/lib/node/index.cjs +0 -886
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
package/dist/lib/node/index.cjs
DELETED
|
@@ -1,886 +0,0 @@
|
|
|
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
|
-
var node_exports = {};
|
|
30
|
-
__export(node_exports, {
|
|
31
|
-
Accordion: () => Accordion,
|
|
32
|
-
List: () => List,
|
|
33
|
-
Path: () => Path,
|
|
34
|
-
Tree: () => Tree,
|
|
35
|
-
TreeDataSchema: () => TreeDataSchema,
|
|
36
|
-
TreeItem: () => TreeItem,
|
|
37
|
-
TreeProvider: () => TreeProvider,
|
|
38
|
-
isTreeData: () => isTreeData,
|
|
39
|
-
useTree: () => useTree
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(node_exports);
|
|
42
|
-
var import_tracking = require("@preact-signals/safe-react/tracking");
|
|
43
|
-
var AccordionPrimitive2 = __toESM(require("@radix-ui/react-accordion"));
|
|
44
|
-
var import_react_context = require("@radix-ui/react-context");
|
|
45
|
-
var import_react = __toESM(require("react"));
|
|
46
|
-
var import_react_ui = require("@dxos/react-ui");
|
|
47
|
-
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
48
|
-
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
|
49
|
-
var AccordionPrimitive = __toESM(require("@radix-ui/react-accordion"));
|
|
50
|
-
var import_react_context2 = require("@radix-ui/react-context");
|
|
51
|
-
var import_react2 = __toESM(require("react"));
|
|
52
|
-
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
53
|
-
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
|
54
|
-
var import_combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
55
|
-
var import_adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
56
|
-
var import_set_custom_native_drag_preview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
|
|
57
|
-
var import_closest_edge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
58
|
-
var import_react_context3 = require("@radix-ui/react-context");
|
|
59
|
-
var import_react3 = __toESM(require("react"));
|
|
60
|
-
var import_react_dom = require("react-dom");
|
|
61
|
-
var import_invariant = require("@dxos/invariant");
|
|
62
|
-
var import_react_ui2 = require("@dxos/react-ui");
|
|
63
|
-
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
64
|
-
var import_tracking4 = require("@preact-signals/safe-react/tracking");
|
|
65
|
-
var import_adapter2 = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
66
|
-
var import_closest_edge2 = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
67
|
-
var import_get_reorder_destination_index = require("@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index");
|
|
68
|
-
var import_react_context4 = require("@radix-ui/react-context");
|
|
69
|
-
var import_react4 = __toESM(require("react"));
|
|
70
|
-
var import_tracking5 = require("@preact-signals/safe-react/tracking");
|
|
71
|
-
var import_react5 = __toESM(require("react"));
|
|
72
|
-
var import_react_ui3 = require("@dxos/react-ui");
|
|
73
|
-
var import_react6 = require("react");
|
|
74
|
-
var import_debug = require("@dxos/debug");
|
|
75
|
-
var import_tracking6 = require("@preact-signals/safe-react/tracking");
|
|
76
|
-
var import_combine2 = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
77
|
-
var import_adapter3 = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
78
|
-
var import_tree_item = require("@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item");
|
|
79
|
-
var import_effect = require("effect");
|
|
80
|
-
var import_react7 = __toESM(require("react"));
|
|
81
|
-
var import_invariant2 = require("@dxos/invariant");
|
|
82
|
-
var import_react_ui4 = require("@dxos/react-ui");
|
|
83
|
-
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
84
|
-
var import_tracking7 = require("@preact-signals/safe-react/tracking");
|
|
85
|
-
var import_react8 = __toESM(require("react"));
|
|
86
|
-
var import_react_ui5 = require("@dxos/react-ui");
|
|
87
|
-
var import_react_ui_text_tooltip = require("@dxos/react-ui-text-tooltip");
|
|
88
|
-
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
89
|
-
var import_tracking8 = require("@preact-signals/safe-react/tracking");
|
|
90
|
-
var import_react9 = __toESM(require("react"));
|
|
91
|
-
var import_react_ui6 = require("@dxos/react-ui");
|
|
92
|
-
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
|
93
|
-
var ACCORDION_NAME = "Accordion";
|
|
94
|
-
var [AccordionProvider, useAccordionContext] = (0, import_react_context2.createContext)(ACCORDION_NAME);
|
|
95
|
-
var defaultGetId = (item) => item?.id;
|
|
96
|
-
var AccordionRoot = ({ classNames, items, getId = defaultGetId, children, value, defaultValue, onValueChange }) => {
|
|
97
|
-
var _effect = (0, import_tracking2.useSignals)();
|
|
98
|
-
try {
|
|
99
|
-
return /* @__PURE__ */ import_react2.default.createElement(AccordionProvider, {
|
|
100
|
-
getId
|
|
101
|
-
}, /* @__PURE__ */ import_react2.default.createElement(AccordionPrimitive.Root, {
|
|
102
|
-
type: "multiple",
|
|
103
|
-
value,
|
|
104
|
-
defaultValue,
|
|
105
|
-
onValueChange,
|
|
106
|
-
className: (0, import_react_ui_theme2.mx)(classNames)
|
|
107
|
-
}, children?.({
|
|
108
|
-
items: items ?? []
|
|
109
|
-
})));
|
|
110
|
-
} finally {
|
|
111
|
-
_effect.f();
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
var ACCORDION_ITEM_NAME = "AccordionItem";
|
|
115
|
-
var [AccordionItemProvider, useAccordionItemContext] = (0, import_react_context.createContext)(ACCORDION_ITEM_NAME);
|
|
116
|
-
var AccordionItem = ({ children, classNames, item }) => {
|
|
117
|
-
var _effect = (0, import_tracking.useSignals)();
|
|
118
|
-
try {
|
|
119
|
-
const { getId } = useAccordionContext(ACCORDION_ITEM_NAME);
|
|
120
|
-
return /* @__PURE__ */ import_react.default.createElement(AccordionItemProvider, {
|
|
121
|
-
item
|
|
122
|
-
}, /* @__PURE__ */ import_react.default.createElement(AccordionPrimitive2.Item, {
|
|
123
|
-
value: getId(item),
|
|
124
|
-
className: (0, import_react_ui_theme.mx)("overflow-hidden", classNames)
|
|
125
|
-
}, children));
|
|
126
|
-
} finally {
|
|
127
|
-
_effect.f();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
var AccordionItemHeader = ({ classNames, children, ...props }) => {
|
|
131
|
-
var _effect = (0, import_tracking.useSignals)();
|
|
132
|
-
try {
|
|
133
|
-
return /* @__PURE__ */ import_react.default.createElement(AccordionPrimitive2.Header, {
|
|
134
|
-
...props,
|
|
135
|
-
className: (0, import_react_ui_theme.mx)(classNames)
|
|
136
|
-
}, /* @__PURE__ */ import_react.default.createElement(AccordionPrimitive2.Trigger, {
|
|
137
|
-
className: "group flex items-center p-2 dx-focus-ring-inset is-full text-start"
|
|
138
|
-
}, children, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Icon, {
|
|
139
|
-
icon: "ph--caret-right--regular",
|
|
140
|
-
size: 4,
|
|
141
|
-
classNames: "transition-transform duration-200 group-data-[state=open]:rotate-90"
|
|
142
|
-
})));
|
|
143
|
-
} finally {
|
|
144
|
-
_effect.f();
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var AccordionItemBody = ({ children, classNames }) => {
|
|
148
|
-
var _effect = (0, import_tracking.useSignals)();
|
|
149
|
-
try {
|
|
150
|
-
return /* @__PURE__ */ import_react.default.createElement(AccordionPrimitive2.Content, {
|
|
151
|
-
className: "overflow-hidden data-[state=closed]:animate-slideUp data-[state=open]:animate-slideDown"
|
|
152
|
-
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
153
|
-
role: "none",
|
|
154
|
-
className: (0, import_react_ui_theme.mx)("p-2", classNames)
|
|
155
|
-
}, children));
|
|
156
|
-
} finally {
|
|
157
|
-
_effect.f();
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
var Accordion = {
|
|
161
|
-
Root: AccordionRoot,
|
|
162
|
-
Item: AccordionItem,
|
|
163
|
-
ItemHeader: AccordionItemHeader,
|
|
164
|
-
ItemBody: AccordionItemBody
|
|
165
|
-
};
|
|
166
|
-
var LIST_NAME = "List";
|
|
167
|
-
var [ListProvider, useListContext] = (0, import_react_context4.createContext)(LIST_NAME);
|
|
168
|
-
var defaultGetId2 = (item) => item?.id;
|
|
169
|
-
var ListRoot = ({ children, items, isItem, getId = defaultGetId2, onMove, ...props }) => {
|
|
170
|
-
var _effect = (0, import_tracking4.useSignals)();
|
|
171
|
-
try {
|
|
172
|
-
const isEqual = (0, import_react4.useCallback)((a, b) => {
|
|
173
|
-
const idA = getId?.(a);
|
|
174
|
-
const idB = getId?.(b);
|
|
175
|
-
if (idA !== void 0 && idB !== void 0) {
|
|
176
|
-
return idA === idB;
|
|
177
|
-
} else {
|
|
178
|
-
return a === b;
|
|
179
|
-
}
|
|
180
|
-
}, [
|
|
181
|
-
getId
|
|
182
|
-
]);
|
|
183
|
-
const [state, setState] = (0, import_react4.useState)(idle);
|
|
184
|
-
(0, import_react4.useEffect)(() => {
|
|
185
|
-
if (!items) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
return (0, import_adapter2.monitorForElements)({
|
|
189
|
-
canMonitor: ({ source }) => isItem?.(source.data) ?? false,
|
|
190
|
-
onDrop: ({ location, source }) => {
|
|
191
|
-
const target = location.current.dropTargets[0];
|
|
192
|
-
if (!target) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const sourceData = source.data;
|
|
196
|
-
const targetData = target.data;
|
|
197
|
-
if (!isItem?.(sourceData) || !isItem?.(targetData)) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
const sourceIdx = items.findIndex((item) => isEqual(item, sourceData));
|
|
201
|
-
const targetIdx = items.findIndex((item) => isEqual(item, targetData));
|
|
202
|
-
if (targetIdx < 0 || sourceIdx < 0) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
const closestEdgeOfTarget = (0, import_closest_edge2.extractClosestEdge)(targetData);
|
|
206
|
-
const destinationIndex = (0, import_get_reorder_destination_index.getReorderDestinationIndex)({
|
|
207
|
-
closestEdgeOfTarget,
|
|
208
|
-
startIndex: sourceIdx,
|
|
209
|
-
indexOfTarget: targetIdx,
|
|
210
|
-
axis: "vertical"
|
|
211
|
-
});
|
|
212
|
-
onMove?.(sourceIdx, destinationIndex);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}, [
|
|
216
|
-
items,
|
|
217
|
-
isEqual,
|
|
218
|
-
onMove
|
|
219
|
-
]);
|
|
220
|
-
return /* @__PURE__ */ import_react4.default.createElement(ListProvider, {
|
|
221
|
-
state,
|
|
222
|
-
setState,
|
|
223
|
-
isItem,
|
|
224
|
-
...props
|
|
225
|
-
}, children?.({
|
|
226
|
-
state,
|
|
227
|
-
items: items ?? []
|
|
228
|
-
}));
|
|
229
|
-
} finally {
|
|
230
|
-
_effect.f();
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-list/src/components/List/ListItem.tsx";
|
|
234
|
-
var idle = {
|
|
235
|
-
type: "idle"
|
|
236
|
-
};
|
|
237
|
-
var stateStyles = {
|
|
238
|
-
"is-dragging": "opacity-50"
|
|
239
|
-
};
|
|
240
|
-
var defaultContext = {};
|
|
241
|
-
var LIST_ITEM_NAME = "ListItem";
|
|
242
|
-
var [ListItemProvider, useListItemContext] = (0, import_react_context3.createContext)(LIST_ITEM_NAME, defaultContext);
|
|
243
|
-
var ListItem = ({ children, classNames, item, ...props }) => {
|
|
244
|
-
var _effect = (0, import_tracking3.useSignals)();
|
|
245
|
-
try {
|
|
246
|
-
const { isItem, readonly, dragPreview, setState: setRootState } = useListContext(LIST_ITEM_NAME);
|
|
247
|
-
const ref = (0, import_react3.useRef)(null);
|
|
248
|
-
const dragHandleRef = (0, import_react3.useRef)(null);
|
|
249
|
-
const [state, setState] = (0, import_react3.useState)(idle);
|
|
250
|
-
(0, import_react3.useEffect)(() => {
|
|
251
|
-
const element = ref.current;
|
|
252
|
-
(0, import_invariant.invariant)(element, void 0, {
|
|
253
|
-
F: __dxlog_file,
|
|
254
|
-
L: 91,
|
|
255
|
-
S: void 0,
|
|
256
|
-
A: [
|
|
257
|
-
"element",
|
|
258
|
-
""
|
|
259
|
-
]
|
|
260
|
-
});
|
|
261
|
-
return (0, import_combine.combine)(
|
|
262
|
-
//
|
|
263
|
-
// https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#draggable
|
|
264
|
-
//
|
|
265
|
-
(0, import_adapter.draggable)({
|
|
266
|
-
element,
|
|
267
|
-
dragHandle: dragHandleRef.current,
|
|
268
|
-
canDrag: () => !readonly,
|
|
269
|
-
getInitialData: () => item,
|
|
270
|
-
onGenerateDragPreview: dragPreview ? ({ nativeSetDragImage, source }) => {
|
|
271
|
-
const rect = source.element.getBoundingClientRect();
|
|
272
|
-
(0, import_set_custom_native_drag_preview.setCustomNativeDragPreview)({
|
|
273
|
-
nativeSetDragImage,
|
|
274
|
-
getOffset: ({ container }) => {
|
|
275
|
-
const { height } = container.getBoundingClientRect();
|
|
276
|
-
return {
|
|
277
|
-
x: 20,
|
|
278
|
-
y: height / 2
|
|
279
|
-
};
|
|
280
|
-
},
|
|
281
|
-
render: ({ container }) => {
|
|
282
|
-
container.style.width = rect.width + "px";
|
|
283
|
-
setState({
|
|
284
|
-
type: "preview",
|
|
285
|
-
container
|
|
286
|
-
});
|
|
287
|
-
setRootState({
|
|
288
|
-
type: "preview",
|
|
289
|
-
container,
|
|
290
|
-
item
|
|
291
|
-
});
|
|
292
|
-
return () => {
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
} : void 0,
|
|
297
|
-
onDragStart: () => {
|
|
298
|
-
setState({
|
|
299
|
-
type: "is-dragging"
|
|
300
|
-
});
|
|
301
|
-
setRootState({
|
|
302
|
-
type: "is-dragging",
|
|
303
|
-
item
|
|
304
|
-
});
|
|
305
|
-
},
|
|
306
|
-
onDrop: () => {
|
|
307
|
-
setState(idle);
|
|
308
|
-
setRootState(idle);
|
|
309
|
-
}
|
|
310
|
-
}),
|
|
311
|
-
//
|
|
312
|
-
// https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#drop-target-for-elements
|
|
313
|
-
//
|
|
314
|
-
(0, import_adapter.dropTargetForElements)({
|
|
315
|
-
element,
|
|
316
|
-
canDrop: ({ source }) => {
|
|
317
|
-
return (source.element !== element && isItem?.(source.data)) ?? false;
|
|
318
|
-
},
|
|
319
|
-
getData: ({ input }) => {
|
|
320
|
-
return (0, import_closest_edge.attachClosestEdge)(item, {
|
|
321
|
-
element,
|
|
322
|
-
input,
|
|
323
|
-
allowedEdges: [
|
|
324
|
-
"top",
|
|
325
|
-
"bottom"
|
|
326
|
-
]
|
|
327
|
-
});
|
|
328
|
-
},
|
|
329
|
-
getIsSticky: () => true,
|
|
330
|
-
onDragEnter: ({ self }) => {
|
|
331
|
-
const closestEdge = (0, import_closest_edge.extractClosestEdge)(self.data);
|
|
332
|
-
setState({
|
|
333
|
-
type: "is-dragging-over",
|
|
334
|
-
closestEdge
|
|
335
|
-
});
|
|
336
|
-
},
|
|
337
|
-
onDrag: ({ self }) => {
|
|
338
|
-
const closestEdge = (0, import_closest_edge.extractClosestEdge)(self.data);
|
|
339
|
-
setState((current) => {
|
|
340
|
-
if (current.type === "is-dragging-over" && current.closestEdge === closestEdge) {
|
|
341
|
-
return current;
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
type: "is-dragging-over",
|
|
345
|
-
closestEdge
|
|
346
|
-
};
|
|
347
|
-
});
|
|
348
|
-
},
|
|
349
|
-
onDragLeave: () => {
|
|
350
|
-
setState(idle);
|
|
351
|
-
},
|
|
352
|
-
onDrop: () => {
|
|
353
|
-
setState(idle);
|
|
354
|
-
}
|
|
355
|
-
})
|
|
356
|
-
);
|
|
357
|
-
}, [
|
|
358
|
-
item
|
|
359
|
-
]);
|
|
360
|
-
return /* @__PURE__ */ import_react3.default.createElement(ListItemProvider, {
|
|
361
|
-
item,
|
|
362
|
-
dragHandleRef
|
|
363
|
-
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
364
|
-
role: "none",
|
|
365
|
-
className: "relative"
|
|
366
|
-
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
367
|
-
ref,
|
|
368
|
-
role: "listitem",
|
|
369
|
-
className: (0, import_react_ui_theme3.mx)("flex overflow-hidden", classNames, stateStyles[state.type]),
|
|
370
|
-
...props
|
|
371
|
-
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ListItem.DropIndicator, {
|
|
372
|
-
edge: state.closestEdge
|
|
373
|
-
})));
|
|
374
|
-
} finally {
|
|
375
|
-
_effect.f();
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
var IconButton = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, icon, ...props }, forwardedRef) => {
|
|
379
|
-
var _effect = (0, import_tracking3.useSignals)();
|
|
380
|
-
try {
|
|
381
|
-
return /* @__PURE__ */ import_react3.default.createElement("button", {
|
|
382
|
-
ref: forwardedRef,
|
|
383
|
-
className: (0, import_react_ui_theme3.mx)("flex items-center justify-center", classNames),
|
|
384
|
-
...props
|
|
385
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Icon, {
|
|
386
|
-
icon,
|
|
387
|
-
classNames: "cursor-pointer",
|
|
388
|
-
size: 4
|
|
389
|
-
}));
|
|
390
|
-
} finally {
|
|
391
|
-
_effect.f();
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", ...props }) => {
|
|
395
|
-
var _effect = (0, import_tracking3.useSignals)();
|
|
396
|
-
try {
|
|
397
|
-
const { state } = useListContext("DELETE_BUTTON");
|
|
398
|
-
const isDisabled = state.type !== "idle" || disabled;
|
|
399
|
-
return /* @__PURE__ */ import_react3.default.createElement(IconButton, {
|
|
400
|
-
icon,
|
|
401
|
-
disabled: isDisabled,
|
|
402
|
-
classNames: [
|
|
403
|
-
classNames,
|
|
404
|
-
autoHide && disabled && "hidden"
|
|
405
|
-
],
|
|
406
|
-
...props
|
|
407
|
-
});
|
|
408
|
-
} finally {
|
|
409
|
-
_effect.f();
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
var ListItemButton = ({ autoHide = true, classNames, disabled, ...props }) => {
|
|
413
|
-
var _effect = (0, import_tracking3.useSignals)();
|
|
414
|
-
try {
|
|
415
|
-
const { state } = useListContext("ITEM_BUTTON");
|
|
416
|
-
const isDisabled = state.type !== "idle" || disabled;
|
|
417
|
-
return /* @__PURE__ */ import_react3.default.createElement(IconButton, {
|
|
418
|
-
disabled: isDisabled,
|
|
419
|
-
classNames: [
|
|
420
|
-
classNames,
|
|
421
|
-
autoHide && disabled && "hidden"
|
|
422
|
-
],
|
|
423
|
-
...props
|
|
424
|
-
});
|
|
425
|
-
} finally {
|
|
426
|
-
_effect.f();
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
var ListItemDragHandle = ({ disabled }) => {
|
|
430
|
-
var _effect = (0, import_tracking3.useSignals)();
|
|
431
|
-
try {
|
|
432
|
-
const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
|
|
433
|
-
return /* @__PURE__ */ import_react3.default.createElement(IconButton, {
|
|
434
|
-
ref: dragHandleRef,
|
|
435
|
-
icon: "ph--dots-six-vertical--regular",
|
|
436
|
-
disabled
|
|
437
|
-
});
|
|
438
|
-
} finally {
|
|
439
|
-
_effect.f();
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
var ListItemDragPreview = ({ children }) => {
|
|
443
|
-
const { state } = useListContext("DRAG_PREVIEW");
|
|
444
|
-
return state?.type === "preview" ? /* @__PURE__ */ (0, import_react_dom.createPortal)(children({
|
|
445
|
-
item: state.item
|
|
446
|
-
}), state.container) : null;
|
|
447
|
-
};
|
|
448
|
-
var ListItemWrapper = ({ classNames, children }) => {
|
|
449
|
-
var _effect = (0, import_tracking3.useSignals)();
|
|
450
|
-
try {
|
|
451
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
452
|
-
className: (0, import_react_ui_theme3.mx)("flex is-full gap-2", classNames)
|
|
453
|
-
}, children);
|
|
454
|
-
} finally {
|
|
455
|
-
_effect.f();
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
var ListItemTitle = ({ classNames, children, ...props }) => {
|
|
459
|
-
var _effect = (0, import_tracking3.useSignals)();
|
|
460
|
-
try {
|
|
461
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
462
|
-
className: (0, import_react_ui_theme3.mx)("flex grow items-center truncate", classNames),
|
|
463
|
-
...props
|
|
464
|
-
}, children);
|
|
465
|
-
} finally {
|
|
466
|
-
_effect.f();
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
var List = {
|
|
470
|
-
Root: ListRoot,
|
|
471
|
-
Item: ListItem,
|
|
472
|
-
ItemDragPreview: ListItemDragPreview,
|
|
473
|
-
ItemWrapper: ListItemWrapper,
|
|
474
|
-
ItemDragHandle: ListItemDragHandle,
|
|
475
|
-
ItemDeleteButton: ListItemDeleteButton,
|
|
476
|
-
ItemButton: ListItemButton,
|
|
477
|
-
ItemTitle: ListItemTitle,
|
|
478
|
-
IconButton
|
|
479
|
-
};
|
|
480
|
-
var TreeContext = /* @__PURE__ */ (0, import_react6.createContext)(null);
|
|
481
|
-
var TreeProvider = TreeContext.Provider;
|
|
482
|
-
var useTree = () => (0, import_react6.useContext)(TreeContext) ?? (0, import_debug.raise)(new Error("TreeContext not found"));
|
|
483
|
-
var TreeItemHeading = /* @__PURE__ */ (0, import_react8.memo)(/* @__PURE__ */ (0, import_react8.forwardRef)(({ label, icon, className, disabled, current, onSelect }, forwardedRef) => {
|
|
484
|
-
var _effect = (0, import_tracking7.useSignals)();
|
|
485
|
-
try {
|
|
486
|
-
const { t } = (0, import_react_ui5.useTranslation)();
|
|
487
|
-
const handleSelect = (0, import_react8.useCallback)((event) => {
|
|
488
|
-
onSelect?.(event.altKey);
|
|
489
|
-
}, [
|
|
490
|
-
onSelect
|
|
491
|
-
]);
|
|
492
|
-
const handleButtonKeydown = (0, import_react8.useCallback)((event) => {
|
|
493
|
-
if (event.key === " " || event.key === "Enter") {
|
|
494
|
-
event.preventDefault();
|
|
495
|
-
event.stopPropagation();
|
|
496
|
-
onSelect?.(event.altKey);
|
|
497
|
-
}
|
|
498
|
-
}, [
|
|
499
|
-
onSelect
|
|
500
|
-
]);
|
|
501
|
-
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui_text_tooltip.TextTooltip, {
|
|
502
|
-
text: (0, import_react_ui5.toLocalizedString)(label, t),
|
|
503
|
-
side: "bottom",
|
|
504
|
-
truncateQuery: "span[data-tooltip]",
|
|
505
|
-
onlyWhenTruncating: true,
|
|
506
|
-
asChild: true,
|
|
507
|
-
ref: forwardedRef
|
|
508
|
-
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui5.Button, {
|
|
509
|
-
"data-testid": "treeItem.heading",
|
|
510
|
-
variant: "ghost",
|
|
511
|
-
density: "fine",
|
|
512
|
-
classNames: (0, import_react_ui_theme5.mx)("grow gap-2 pis-0.5 hover:bg-transparent dark:hover:bg-transparent", "disabled:cursor-default disabled:opacity-100", className),
|
|
513
|
-
disabled,
|
|
514
|
-
onClick: handleSelect,
|
|
515
|
-
onKeyDown: handleButtonKeydown,
|
|
516
|
-
...current && {
|
|
517
|
-
"aria-current": "location"
|
|
518
|
-
}
|
|
519
|
-
}, icon && /* @__PURE__ */ import_react8.default.createElement(import_react_ui5.Icon, {
|
|
520
|
-
icon: icon ?? "ph--placeholder--regular",
|
|
521
|
-
size: 5,
|
|
522
|
-
classNames: "mlb-1"
|
|
523
|
-
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
524
|
-
className: "flex-1 is-0 truncate text-start text-sm font-normal",
|
|
525
|
-
"data-tooltip": true
|
|
526
|
-
}, (0, import_react_ui5.toLocalizedString)(label, t))));
|
|
527
|
-
} finally {
|
|
528
|
-
_effect.f();
|
|
529
|
-
}
|
|
530
|
-
}));
|
|
531
|
-
var TreeItemToggle = /* @__PURE__ */ (0, import_react9.memo)(/* @__PURE__ */ (0, import_react9.forwardRef)(({ open, isBranch, hidden, onToggle }, forwardedRef) => {
|
|
532
|
-
var _effect = (0, import_tracking8.useSignals)();
|
|
533
|
-
try {
|
|
534
|
-
return /* @__PURE__ */ import_react9.default.createElement(import_react_ui6.Button, {
|
|
535
|
-
ref: forwardedRef,
|
|
536
|
-
"data-testid": "treeItem.toggle",
|
|
537
|
-
"aria-expanded": open,
|
|
538
|
-
variant: "ghost",
|
|
539
|
-
density: "fine",
|
|
540
|
-
classNames: (0, import_react_ui_theme6.mx)("is-6 pli-0 dx-focus-ring-inset", hidden ? "hidden" : !isBranch && "invisible"),
|
|
541
|
-
onClick: onToggle
|
|
542
|
-
}, /* @__PURE__ */ import_react9.default.createElement(import_react_ui6.Icon, {
|
|
543
|
-
icon: "ph--caret-right--bold",
|
|
544
|
-
size: 3,
|
|
545
|
-
classNames: (0, import_react_ui_theme6.mx)("transition duration-200", open && "rotate-90")
|
|
546
|
-
}));
|
|
547
|
-
} finally {
|
|
548
|
-
_effect.f();
|
|
549
|
-
}
|
|
550
|
-
}));
|
|
551
|
-
var DEFAULT_INDENTATION = 8;
|
|
552
|
-
var paddingIndentation = (level, indentation = DEFAULT_INDENTATION) => ({
|
|
553
|
-
paddingInlineStart: `${(level - 1) * indentation}px`
|
|
554
|
-
});
|
|
555
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-list/src/components/Tree/TreeItem.tsx";
|
|
556
|
-
var hoverableDescriptionIcons = "[--icons-color:inherit] hover-hover:[--icons-color:var(--description-text)] hover-hover:hover:[--icons-color:inherit] focus-within:[--icons-color:inherit]";
|
|
557
|
-
var TreeDataSchema = import_effect.Schema.Struct({
|
|
558
|
-
id: import_effect.Schema.String,
|
|
559
|
-
path: import_effect.Schema.Array(import_effect.Schema.String),
|
|
560
|
-
item: import_effect.Schema.Any
|
|
561
|
-
});
|
|
562
|
-
var isTreeData = (data) => import_effect.Schema.is(TreeDataSchema)(data);
|
|
563
|
-
var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColumns: Columns, canDrop, onOpenChange, onSelect, levelOffset = 2 }) => {
|
|
564
|
-
var _effect = (0, import_tracking6.useSignals)();
|
|
565
|
-
try {
|
|
566
|
-
const rowRef = (0, import_react7.useRef)(null);
|
|
567
|
-
const buttonRef = (0, import_react7.useRef)(null);
|
|
568
|
-
const openRef = (0, import_react7.useRef)(false);
|
|
569
|
-
const cancelExpandRef = (0, import_react7.useRef)(null);
|
|
570
|
-
const [_state, setState] = (0, import_react7.useState)("idle");
|
|
571
|
-
const [instruction, setInstruction] = (0, import_react7.useState)(null);
|
|
572
|
-
const [menuOpen, setMenuOpen] = (0, import_react7.useState)(false);
|
|
573
|
-
const { useItems, getProps, isOpen, isCurrent } = useTree();
|
|
574
|
-
const items = useItems(item);
|
|
575
|
-
const { id, label, parentOf, icon, disabled, className, headingClassName, testId } = getProps(item, _path);
|
|
576
|
-
const path = (0, import_react7.useMemo)(() => [
|
|
577
|
-
..._path,
|
|
578
|
-
id
|
|
579
|
-
], [
|
|
580
|
-
_path,
|
|
581
|
-
id
|
|
582
|
-
]);
|
|
583
|
-
const open = isOpen(path, item);
|
|
584
|
-
const current = isCurrent(path, item);
|
|
585
|
-
const level = path.length - levelOffset;
|
|
586
|
-
const isBranch = !!parentOf;
|
|
587
|
-
const mode = last ? "last-in-group" : open ? "expanded" : "standard";
|
|
588
|
-
const cancelExpand = (0, import_react7.useCallback)(() => {
|
|
589
|
-
if (cancelExpandRef.current) {
|
|
590
|
-
clearTimeout(cancelExpandRef.current);
|
|
591
|
-
cancelExpandRef.current = null;
|
|
592
|
-
}
|
|
593
|
-
}, []);
|
|
594
|
-
(0, import_react7.useEffect)(() => {
|
|
595
|
-
if (!_draggable) {
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
(0, import_invariant2.invariant)(buttonRef.current, void 0, {
|
|
599
|
-
F: __dxlog_file2,
|
|
600
|
-
L: 106,
|
|
601
|
-
S: void 0,
|
|
602
|
-
A: [
|
|
603
|
-
"buttonRef.current",
|
|
604
|
-
""
|
|
605
|
-
]
|
|
606
|
-
});
|
|
607
|
-
const data = {
|
|
608
|
-
id,
|
|
609
|
-
path,
|
|
610
|
-
item
|
|
611
|
-
};
|
|
612
|
-
return (0, import_combine2.combine)(
|
|
613
|
-
(0, import_adapter3.draggable)({
|
|
614
|
-
element: buttonRef.current,
|
|
615
|
-
getInitialData: () => data,
|
|
616
|
-
onDragStart: () => {
|
|
617
|
-
setState("dragging");
|
|
618
|
-
if (open) {
|
|
619
|
-
openRef.current = true;
|
|
620
|
-
onOpenChange?.({
|
|
621
|
-
item,
|
|
622
|
-
path,
|
|
623
|
-
open: false
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
},
|
|
627
|
-
onDrop: () => {
|
|
628
|
-
setState("idle");
|
|
629
|
-
if (openRef.current) {
|
|
630
|
-
onOpenChange?.({
|
|
631
|
-
item,
|
|
632
|
-
path,
|
|
633
|
-
open: true
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}),
|
|
638
|
-
// https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/hitbox/constellation/index/about.mdx
|
|
639
|
-
(0, import_adapter3.dropTargetForElements)({
|
|
640
|
-
element: buttonRef.current,
|
|
641
|
-
getData: ({ input, element }) => {
|
|
642
|
-
return (0, import_tree_item.attachInstruction)(data, {
|
|
643
|
-
input,
|
|
644
|
-
element,
|
|
645
|
-
indentPerLevel: DEFAULT_INDENTATION,
|
|
646
|
-
currentLevel: level,
|
|
647
|
-
mode,
|
|
648
|
-
block: isBranch ? [] : [
|
|
649
|
-
"make-child"
|
|
650
|
-
]
|
|
651
|
-
});
|
|
652
|
-
},
|
|
653
|
-
canDrop: ({ source }) => {
|
|
654
|
-
const _canDrop = canDrop ?? (() => true);
|
|
655
|
-
return source.element !== buttonRef.current && _canDrop({
|
|
656
|
-
source: source.data,
|
|
657
|
-
target: data
|
|
658
|
-
});
|
|
659
|
-
},
|
|
660
|
-
getIsSticky: () => true,
|
|
661
|
-
onDrag: ({ self, source }) => {
|
|
662
|
-
const instruction2 = (0, import_tree_item.extractInstruction)(self.data);
|
|
663
|
-
if (source.data.id !== id) {
|
|
664
|
-
if (instruction2?.type === "make-child" && isBranch && !open && !cancelExpandRef.current) {
|
|
665
|
-
cancelExpandRef.current = setTimeout(() => {
|
|
666
|
-
onOpenChange?.({
|
|
667
|
-
item,
|
|
668
|
-
path,
|
|
669
|
-
open: true
|
|
670
|
-
});
|
|
671
|
-
}, 500);
|
|
672
|
-
}
|
|
673
|
-
if (instruction2?.type !== "make-child") {
|
|
674
|
-
cancelExpand();
|
|
675
|
-
}
|
|
676
|
-
setInstruction(instruction2);
|
|
677
|
-
} else if (instruction2?.type === "reparent") {
|
|
678
|
-
setInstruction(instruction2);
|
|
679
|
-
} else {
|
|
680
|
-
setInstruction(null);
|
|
681
|
-
}
|
|
682
|
-
},
|
|
683
|
-
onDragLeave: () => {
|
|
684
|
-
cancelExpand();
|
|
685
|
-
setInstruction(null);
|
|
686
|
-
},
|
|
687
|
-
onDrop: () => {
|
|
688
|
-
cancelExpand();
|
|
689
|
-
setInstruction(null);
|
|
690
|
-
}
|
|
691
|
-
})
|
|
692
|
-
);
|
|
693
|
-
}, [
|
|
694
|
-
_draggable,
|
|
695
|
-
item,
|
|
696
|
-
id,
|
|
697
|
-
mode,
|
|
698
|
-
path,
|
|
699
|
-
open,
|
|
700
|
-
canDrop
|
|
701
|
-
]);
|
|
702
|
-
(0, import_react7.useEffect)(() => () => cancelExpand(), [
|
|
703
|
-
cancelExpand
|
|
704
|
-
]);
|
|
705
|
-
const handleOpenChange = (0, import_react7.useCallback)(() => onOpenChange?.({
|
|
706
|
-
item,
|
|
707
|
-
path,
|
|
708
|
-
open: !open
|
|
709
|
-
}), [
|
|
710
|
-
onOpenChange,
|
|
711
|
-
item,
|
|
712
|
-
path,
|
|
713
|
-
open
|
|
714
|
-
]);
|
|
715
|
-
const handleSelect = (0, import_react7.useCallback)((option = false) => {
|
|
716
|
-
if (isBranch) {
|
|
717
|
-
handleOpenChange();
|
|
718
|
-
} else {
|
|
719
|
-
rowRef.current?.focus();
|
|
720
|
-
onSelect?.({
|
|
721
|
-
item,
|
|
722
|
-
path,
|
|
723
|
-
current: !current,
|
|
724
|
-
option
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
}, [
|
|
728
|
-
item,
|
|
729
|
-
path,
|
|
730
|
-
current,
|
|
731
|
-
isBranch,
|
|
732
|
-
handleOpenChange,
|
|
733
|
-
onSelect
|
|
734
|
-
]);
|
|
735
|
-
const handleKeyDown = (0, import_react7.useCallback)((event) => {
|
|
736
|
-
switch (event.key) {
|
|
737
|
-
case "ArrowRight":
|
|
738
|
-
isBranch && !open && handleOpenChange();
|
|
739
|
-
break;
|
|
740
|
-
case "ArrowLeft":
|
|
741
|
-
isBranch && open && handleOpenChange();
|
|
742
|
-
break;
|
|
743
|
-
case " ":
|
|
744
|
-
handleSelect(event.altKey);
|
|
745
|
-
break;
|
|
746
|
-
}
|
|
747
|
-
}, [
|
|
748
|
-
isBranch,
|
|
749
|
-
open,
|
|
750
|
-
handleOpenChange,
|
|
751
|
-
handleSelect
|
|
752
|
-
]);
|
|
753
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(import_react_ui4.Treegrid.Row, {
|
|
754
|
-
ref: rowRef,
|
|
755
|
-
key: id,
|
|
756
|
-
id,
|
|
757
|
-
"aria-labelledby": `${id}__label`,
|
|
758
|
-
parentOf: parentOf?.join(import_react_ui4.Treegrid.PARENT_OF_SEPARATOR),
|
|
759
|
-
classNames: (0, import_react_ui_theme4.mx)("grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-activeSurface", import_react_ui_theme4.hoverableControls, import_react_ui_theme4.hoverableFocusedKeyboardControls, import_react_ui_theme4.hoverableFocusedWithinControls, hoverableDescriptionIcons, import_react_ui_theme4.ghostHover, className),
|
|
760
|
-
"data-itemid": id,
|
|
761
|
-
"data-testid": testId,
|
|
762
|
-
// NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
|
|
763
|
-
// without alerting the user (except for in the correct link element). See also:
|
|
764
|
-
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current#description
|
|
765
|
-
"aria-current": current ? "" : void 0,
|
|
766
|
-
onKeyDown: handleKeyDown,
|
|
767
|
-
onContextMenu: (event) => {
|
|
768
|
-
event.preventDefault();
|
|
769
|
-
setMenuOpen(true);
|
|
770
|
-
}
|
|
771
|
-
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui4.Treegrid.Cell, {
|
|
772
|
-
indent: true,
|
|
773
|
-
classNames: "relative grid grid-cols-subgrid col-[tree-row]",
|
|
774
|
-
style: paddingIndentation(level)
|
|
775
|
-
}, /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
776
|
-
role: "none",
|
|
777
|
-
className: "flex items-center"
|
|
778
|
-
}, /* @__PURE__ */ import_react7.default.createElement(TreeItemToggle, {
|
|
779
|
-
isBranch,
|
|
780
|
-
open,
|
|
781
|
-
onToggle: handleOpenChange
|
|
782
|
-
}), /* @__PURE__ */ import_react7.default.createElement(TreeItemHeading, {
|
|
783
|
-
ref: buttonRef,
|
|
784
|
-
label,
|
|
785
|
-
icon,
|
|
786
|
-
className: headingClassName,
|
|
787
|
-
disabled,
|
|
788
|
-
current,
|
|
789
|
-
onSelect: handleSelect
|
|
790
|
-
})), Columns && /* @__PURE__ */ import_react7.default.createElement(Columns, {
|
|
791
|
-
item,
|
|
792
|
-
path,
|
|
793
|
-
open,
|
|
794
|
-
menuOpen,
|
|
795
|
-
setMenuOpen
|
|
796
|
-
}), instruction && /* @__PURE__ */ import_react7.default.createElement(import_react_ui4.TreeItem.DropIndicator, {
|
|
797
|
-
instruction,
|
|
798
|
-
gap: 2
|
|
799
|
-
}))), open && items.map((item2, index) => /* @__PURE__ */ import_react7.default.createElement(TreeItem, {
|
|
800
|
-
key: item2.id,
|
|
801
|
-
item: item2,
|
|
802
|
-
path,
|
|
803
|
-
last: index === items.length - 1,
|
|
804
|
-
draggable: _draggable,
|
|
805
|
-
renderColumns: Columns,
|
|
806
|
-
canDrop,
|
|
807
|
-
onOpenChange,
|
|
808
|
-
onSelect
|
|
809
|
-
})));
|
|
810
|
-
} finally {
|
|
811
|
-
_effect.f();
|
|
812
|
-
}
|
|
813
|
-
};
|
|
814
|
-
var TreeItem = /* @__PURE__ */ (0, import_react7.memo)(RawTreeItem);
|
|
815
|
-
var Tree = ({ root, path, id, useItems, getProps, isOpen, isCurrent, draggable: draggable3 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, levelOffset, renderColumns, canDrop, onOpenChange, onSelect }) => {
|
|
816
|
-
var _effect = (0, import_tracking5.useSignals)();
|
|
817
|
-
try {
|
|
818
|
-
const context = (0, import_react5.useMemo)(() => ({
|
|
819
|
-
useItems,
|
|
820
|
-
getProps,
|
|
821
|
-
isOpen,
|
|
822
|
-
isCurrent
|
|
823
|
-
}), [
|
|
824
|
-
useItems,
|
|
825
|
-
getProps,
|
|
826
|
-
isOpen,
|
|
827
|
-
isCurrent
|
|
828
|
-
]);
|
|
829
|
-
const items = useItems(root);
|
|
830
|
-
const treePath = (0, import_react5.useMemo)(() => path ? [
|
|
831
|
-
...path,
|
|
832
|
-
id
|
|
833
|
-
] : [
|
|
834
|
-
id
|
|
835
|
-
], [
|
|
836
|
-
id,
|
|
837
|
-
path
|
|
838
|
-
]);
|
|
839
|
-
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Treegrid.Root, {
|
|
840
|
-
gridTemplateColumns,
|
|
841
|
-
classNames
|
|
842
|
-
}, /* @__PURE__ */ import_react5.default.createElement(TreeProvider, {
|
|
843
|
-
value: context
|
|
844
|
-
}, items.map((item, index) => /* @__PURE__ */ import_react5.default.createElement(TreeItem, {
|
|
845
|
-
key: item.id,
|
|
846
|
-
item,
|
|
847
|
-
last: index === items.length - 1,
|
|
848
|
-
path: treePath,
|
|
849
|
-
levelOffset,
|
|
850
|
-
draggable: draggable3,
|
|
851
|
-
renderColumns,
|
|
852
|
-
canDrop,
|
|
853
|
-
onOpenChange,
|
|
854
|
-
onSelect
|
|
855
|
-
}))));
|
|
856
|
-
} finally {
|
|
857
|
-
_effect.f();
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
var SEPARATOR = "+";
|
|
861
|
-
var Path = {
|
|
862
|
-
create: (...args) => args.join(SEPARATOR),
|
|
863
|
-
parts: (path) => path.split(SEPARATOR),
|
|
864
|
-
length: (path) => path.split(SEPARATOR).length,
|
|
865
|
-
first: (path) => path.split(SEPARATOR)[0] ?? path,
|
|
866
|
-
last: (path) => path.split(SEPARATOR).at(-1) ?? path,
|
|
867
|
-
parent: (path) => path.split(SEPARATOR).slice(0, -1).join(SEPARATOR),
|
|
868
|
-
hasRoot: (path, id) => Path.first(path) === id,
|
|
869
|
-
hasChild: (path, compare) => Path.parent(compare) === path,
|
|
870
|
-
hasDescendent: (path, compare) => compare !== path && compare.startsWith(path),
|
|
871
|
-
siblings: (path, compare) => Path.parent(path) === Path.parent(compare),
|
|
872
|
-
onPath: (path, id) => Path.parts(path).includes(id)
|
|
873
|
-
};
|
|
874
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
875
|
-
0 && (module.exports = {
|
|
876
|
-
Accordion,
|
|
877
|
-
List,
|
|
878
|
-
Path,
|
|
879
|
-
Tree,
|
|
880
|
-
TreeDataSchema,
|
|
881
|
-
TreeItem,
|
|
882
|
-
TreeProvider,
|
|
883
|
-
isTreeData,
|
|
884
|
-
useTree
|
|
885
|
-
});
|
|
886
|
-
//# sourceMappingURL=index.cjs.map
|