@dxos/react-ui-list 0.8.2-staging.7ac8446 → 0.8.2

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