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