@dxos/react-ui-list 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b

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 (93) hide show
  1. package/dist/lib/browser/index.mjs +956 -270
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +956 -270
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/Accordion/Accordion.d.ts +1 -1
  8. package/dist/types/src/components/Accordion/Accordion.d.ts.map +1 -1
  9. package/dist/types/src/components/Accordion/Accordion.stories.d.ts.map +1 -1
  10. package/dist/types/src/components/Accordion/AccordionItem.d.ts.map +1 -1
  11. package/dist/types/src/components/Accordion/AccordionRoot.d.ts +1 -1
  12. package/dist/types/src/components/Accordion/AccordionRoot.d.ts.map +1 -1
  13. package/dist/types/src/components/Combobox/Combobox.d.ts +105 -0
  14. package/dist/types/src/components/Combobox/Combobox.d.ts.map +1 -0
  15. package/dist/types/src/components/Combobox/Combobox.stories.d.ts +12 -0
  16. package/dist/types/src/components/Combobox/Combobox.stories.d.ts.map +1 -0
  17. package/dist/types/src/components/Combobox/index.d.ts +2 -0
  18. package/dist/types/src/components/Combobox/index.d.ts.map +1 -0
  19. package/dist/types/src/components/List/List.d.ts +18 -7
  20. package/dist/types/src/components/List/List.d.ts.map +1 -1
  21. package/dist/types/src/components/List/List.stories.d.ts +2 -2
  22. package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/List/ListItem.d.ts +10 -8
  24. package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
  25. package/dist/types/src/components/List/ListRoot.d.ts.map +1 -1
  26. package/dist/types/src/components/List/testing.d.ts.map +1 -1
  27. package/dist/types/src/components/Listbox/Listbox.d.ts +27 -0
  28. package/dist/types/src/components/Listbox/Listbox.d.ts.map +1 -0
  29. package/dist/types/src/components/Listbox/Listbox.stories.d.ts +12 -0
  30. package/dist/types/src/components/Listbox/Listbox.stories.d.ts.map +1 -0
  31. package/dist/types/src/components/Listbox/index.d.ts +2 -0
  32. package/dist/types/src/components/Listbox/index.d.ts.map +1 -0
  33. package/dist/types/src/components/Picker/Picker.d.ts +49 -0
  34. package/dist/types/src/components/Picker/Picker.d.ts.map +1 -0
  35. package/dist/types/src/components/Picker/Picker.stories.d.ts +28 -0
  36. package/dist/types/src/components/Picker/Picker.stories.d.ts.map +1 -0
  37. package/dist/types/src/components/Picker/context.d.ts +29 -0
  38. package/dist/types/src/components/Picker/context.d.ts.map +1 -0
  39. package/dist/types/src/components/Picker/index.d.ts +3 -0
  40. package/dist/types/src/components/Picker/index.d.ts.map +1 -0
  41. package/dist/types/src/components/RowList/RowList.d.ts +61 -0
  42. package/dist/types/src/components/RowList/RowList.d.ts.map +1 -0
  43. package/dist/types/src/components/RowList/RowList.stories.d.ts +35 -0
  44. package/dist/types/src/components/RowList/RowList.stories.d.ts.map +1 -0
  45. package/dist/types/src/components/RowList/index.d.ts +3 -0
  46. package/dist/types/src/components/RowList/index.d.ts.map +1 -0
  47. package/dist/types/src/components/Tree/Tree.d.ts +6 -5
  48. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  49. package/dist/types/src/components/Tree/Tree.stories.d.ts +1 -1
  50. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  51. package/dist/types/src/components/Tree/TreeContext.d.ts +21 -10
  52. package/dist/types/src/components/Tree/TreeContext.d.ts.map +1 -1
  53. package/dist/types/src/components/Tree/TreeItem.d.ts +8 -0
  54. package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
  55. package/dist/types/src/components/Tree/TreeItemHeading.d.ts.map +1 -1
  56. package/dist/types/src/components/Tree/helpers.d.ts.map +1 -1
  57. package/dist/types/src/components/Tree/index.d.ts +2 -0
  58. package/dist/types/src/components/Tree/index.d.ts.map +1 -1
  59. package/dist/types/src/components/Tree/testing.d.ts.map +1 -1
  60. package/dist/types/src/components/index.d.ts +4 -0
  61. package/dist/types/src/components/index.d.ts.map +1 -1
  62. package/dist/types/src/util/path.d.ts.map +1 -1
  63. package/dist/types/tsconfig.tsbuildinfo +1 -1
  64. package/package.json +21 -20
  65. package/src/components/Accordion/Accordion.stories.tsx +5 -5
  66. package/src/components/Accordion/AccordionItem.tsx +2 -5
  67. package/src/components/Combobox/Combobox.stories.tsx +60 -0
  68. package/src/components/Combobox/Combobox.tsx +387 -0
  69. package/src/components/Combobox/index.ts +5 -0
  70. package/src/components/List/List.stories.tsx +12 -12
  71. package/src/components/List/List.tsx +14 -10
  72. package/src/components/List/ListItem.tsx +55 -37
  73. package/src/components/List/ListRoot.tsx +1 -1
  74. package/src/components/List/testing.ts +4 -4
  75. package/src/components/Listbox/Listbox.stories.tsx +48 -0
  76. package/src/components/Listbox/Listbox.tsx +201 -0
  77. package/src/components/Listbox/index.ts +5 -0
  78. package/src/components/Picker/Picker.stories.tsx +131 -0
  79. package/src/components/Picker/Picker.tsx +368 -0
  80. package/src/components/Picker/context.ts +43 -0
  81. package/src/components/Picker/index.ts +6 -0
  82. package/src/components/RowList/RowList.stories.tsx +163 -0
  83. package/src/components/RowList/RowList.tsx +353 -0
  84. package/src/components/RowList/index.ts +6 -0
  85. package/src/components/Tree/Tree.stories.tsx +105 -30
  86. package/src/components/Tree/Tree.tsx +30 -40
  87. package/src/components/Tree/TreeContext.tsx +18 -9
  88. package/src/components/Tree/TreeItem.tsx +179 -108
  89. package/src/components/Tree/TreeItemHeading.tsx +5 -4
  90. package/src/components/Tree/TreeItemToggle.tsx +4 -4
  91. package/src/components/Tree/index.ts +2 -0
  92. package/src/components/Tree/testing.ts +5 -5
  93. package/src/components/index.ts +4 -0
@@ -46,7 +46,7 @@ var AccordionItemHeader = ({ classNames, children, ...props }) => {
46
46
  ...props,
47
47
  className: mx2(classNames)
48
48
  }, /* @__PURE__ */ React2.createElement(AccordionPrimitive2.Trigger, {
49
- className: "group flex items-center p-2 dx-focus-ring-inset is-full text-start"
49
+ className: "group flex items-center p-2 dx-focus-ring-inset w-full text-start"
50
50
  }, children, /* @__PURE__ */ React2.createElement(Icon, {
51
51
  icon: "ph--caret-right--regular",
52
52
  size: 4,
@@ -57,7 +57,6 @@ var AccordionItemBody = ({ children, classNames }) => {
57
57
  return /* @__PURE__ */ React2.createElement(AccordionPrimitive2.Content, {
58
58
  className: "overflow-hidden data-[state=closed]:animate-slide-up data-[state=open]:animate-slide-down"
59
59
  }, /* @__PURE__ */ React2.createElement("div", {
60
- role: "none",
61
60
  className: mx2("p-2", classNames)
62
61
  }, children));
63
62
  };
@@ -70,29 +69,466 @@ var Accordion = {
70
69
  ItemBody: AccordionItemBody
71
70
  };
72
71
 
72
+ // src/components/Combobox/Combobox.tsx
73
+ import { createContext as createContext4 } from "@radix-ui/react-context";
74
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
75
+ import React4, { forwardRef as forwardRef2, useCallback as useCallback2 } from "react";
76
+ import { Button, Icon as Icon2, Popover, ScrollArea, useId } from "@dxos/react-ui";
77
+ import { composable, composableProps, mx as mx4 } from "@dxos/ui-theme";
78
+
79
+ // src/components/Picker/Picker.tsx
80
+ import { Slot } from "@radix-ui/react-slot";
81
+ import React3, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
82
+ import { Input, useThemeContext } from "@dxos/react-ui";
83
+ import { mx as mx3 } from "@dxos/ui-theme";
84
+
85
+ // src/components/Picker/context.ts
86
+ import { createContext as createContext3 } from "@radix-ui/react-context";
87
+ var [PickerItemContextProvider, usePickerItemContext] = createContext3("PickerItem");
88
+ var [PickerInputContextProvider, usePickerInputContext] = createContext3("PickerInput");
89
+
90
+ // src/components/Picker/Picker.tsx
91
+ var PickerRoot = ({ children }) => {
92
+ const [selectedValue, setSelectedValue] = useState(void 0);
93
+ const itemsRef = useRef(/* @__PURE__ */ new Map());
94
+ const [itemVersion, setItemVersion] = useState(0);
95
+ useEffect(() => {
96
+ const current = selectedValue !== void 0 ? itemsRef.current.get(selectedValue) : void 0;
97
+ const isValid = current !== void 0 && !current.disabled;
98
+ if (!isValid && itemsRef.current.size > 0) {
99
+ const entries = Array.from(itemsRef.current.entries()).filter(([, data]) => !data.disabled);
100
+ if (entries.length > 0) {
101
+ entries.sort(([, a], [, b]) => {
102
+ const position = a.element.compareDocumentPosition(b.element);
103
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
104
+ return -1;
105
+ }
106
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
107
+ return 1;
108
+ }
109
+ return 0;
110
+ });
111
+ const firstValue = entries[0]?.[0];
112
+ if (firstValue !== void 0 && firstValue !== selectedValue) {
113
+ setSelectedValue(firstValue);
114
+ }
115
+ } else if (selectedValue !== void 0) {
116
+ setSelectedValue(void 0);
117
+ }
118
+ }
119
+ }, [
120
+ itemVersion,
121
+ selectedValue
122
+ ]);
123
+ const registerItem = useCallback((value, element, onSelect, disabled) => {
124
+ if (element) {
125
+ itemsRef.current.set(value, {
126
+ element,
127
+ onSelect,
128
+ disabled
129
+ });
130
+ setItemVersion((v) => v + 1);
131
+ }
132
+ }, []);
133
+ const unregisterItem = useCallback((value) => {
134
+ itemsRef.current.delete(value);
135
+ setItemVersion((v) => v + 1);
136
+ }, []);
137
+ const getItemValues = useCallback(() => {
138
+ return Array.from(itemsRef.current.entries()).filter(([, data]) => !data.disabled).sort(([, a], [, b]) => {
139
+ const position = a.element.compareDocumentPosition(b.element);
140
+ return position & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : position & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
141
+ }).map(([value]) => value);
142
+ }, []);
143
+ const triggerSelect = useCallback(() => {
144
+ if (selectedValue !== void 0) {
145
+ const item = itemsRef.current.get(selectedValue);
146
+ item?.onSelect?.();
147
+ }
148
+ }, [
149
+ selectedValue
150
+ ]);
151
+ const itemContextValue = useMemo(() => ({
152
+ selectedValue,
153
+ onSelectedValueChange: setSelectedValue,
154
+ registerItem,
155
+ unregisterItem
156
+ }), [
157
+ selectedValue,
158
+ registerItem,
159
+ unregisterItem
160
+ ]);
161
+ const inputContextValue = useMemo(() => ({
162
+ selectedValue,
163
+ onSelectedValueChange: setSelectedValue,
164
+ getItemValues,
165
+ triggerSelect
166
+ }), [
167
+ selectedValue,
168
+ getItemValues,
169
+ triggerSelect
170
+ ]);
171
+ return /* @__PURE__ */ React3.createElement(PickerInputContextProvider, inputContextValue, /* @__PURE__ */ React3.createElement(PickerItemContextProvider, itemContextValue, children));
172
+ };
173
+ PickerRoot.displayName = "Picker.Root";
174
+ var PickerInput = /* @__PURE__ */ forwardRef(({ value, onValueChange, onChange, onKeyDown, autoFocus, ...props }, forwardedRef) => {
175
+ const { hasIosKeyboard } = useThemeContext();
176
+ const { selectedValue, onSelectedValueChange, getItemValues, triggerSelect } = usePickerInputContext("Picker.Input");
177
+ const handleChange = useCallback((event) => {
178
+ onValueChange?.(event.target.value);
179
+ onChange?.(event);
180
+ }, [
181
+ onValueChange,
182
+ onChange
183
+ ]);
184
+ const handleKeyDown = useCallback((event) => {
185
+ onKeyDown?.(event);
186
+ if (event.defaultPrevented) {
187
+ return;
188
+ }
189
+ const values = getItemValues();
190
+ if (values.length === 0) {
191
+ if (event.key === "Escape") {
192
+ onValueChange?.("");
193
+ }
194
+ return;
195
+ }
196
+ const currentIndex = selectedValue !== void 0 ? values.indexOf(selectedValue) : -1;
197
+ switch (event.key) {
198
+ case "ArrowDown": {
199
+ event.preventDefault();
200
+ const nextIndex = currentIndex === -1 ? 0 : Math.min(currentIndex + 1, values.length - 1);
201
+ const nextValue = values[nextIndex];
202
+ if (nextValue !== void 0) {
203
+ onSelectedValueChange(nextValue);
204
+ }
205
+ break;
206
+ }
207
+ case "ArrowUp": {
208
+ event.preventDefault();
209
+ const prevIndex = currentIndex === -1 ? values.length - 1 : Math.max(currentIndex - 1, 0);
210
+ const prevValue = values[prevIndex];
211
+ if (prevValue !== void 0) {
212
+ onSelectedValueChange(prevValue);
213
+ }
214
+ break;
215
+ }
216
+ case "Enter": {
217
+ if (selectedValue !== void 0) {
218
+ event.preventDefault();
219
+ triggerSelect();
220
+ }
221
+ break;
222
+ }
223
+ case "Home": {
224
+ event.preventDefault();
225
+ const firstValue = values[0];
226
+ if (firstValue !== void 0) {
227
+ onSelectedValueChange(firstValue);
228
+ }
229
+ break;
230
+ }
231
+ case "End": {
232
+ event.preventDefault();
233
+ const lastValue = values[values.length - 1];
234
+ if (lastValue !== void 0) {
235
+ onSelectedValueChange(lastValue);
236
+ }
237
+ break;
238
+ }
239
+ case "Escape": {
240
+ event.preventDefault();
241
+ if (selectedValue !== void 0) {
242
+ onSelectedValueChange(void 0);
243
+ } else {
244
+ onValueChange?.("");
245
+ }
246
+ break;
247
+ }
248
+ }
249
+ }, [
250
+ selectedValue,
251
+ onSelectedValueChange,
252
+ getItemValues,
253
+ triggerSelect,
254
+ onValueChange,
255
+ onKeyDown
256
+ ]);
257
+ return /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.TextInput, {
258
+ ...props,
259
+ autoFocus: autoFocus && !hasIosKeyboard,
260
+ ...value !== void 0 && {
261
+ value
262
+ },
263
+ onChange: handleChange,
264
+ onKeyDown: handleKeyDown,
265
+ ref: forwardedRef
266
+ }));
267
+ });
268
+ PickerInput.displayName = "Picker.Input";
269
+ var PickerItem = /* @__PURE__ */ forwardRef(({ classNames, value, onSelect, disabled, asChild, children, ...props }, forwardedRef) => {
270
+ const { selectedValue, onSelectedValueChange, registerItem, unregisterItem } = usePickerItemContext("Picker.Item");
271
+ const internalRef = useRef(null);
272
+ const isSelected = selectedValue === value && !disabled;
273
+ useEffect(() => {
274
+ const element = internalRef.current;
275
+ if (element) {
276
+ registerItem(value, element, onSelect, disabled);
277
+ }
278
+ return () => unregisterItem(value);
279
+ }, [
280
+ value,
281
+ onSelect,
282
+ disabled,
283
+ registerItem,
284
+ unregisterItem
285
+ ]);
286
+ useEffect(() => {
287
+ if (isSelected && internalRef.current) {
288
+ internalRef.current.scrollIntoView({
289
+ block: "nearest",
290
+ behavior: "smooth"
291
+ });
292
+ }
293
+ }, [
294
+ isSelected
295
+ ]);
296
+ const handleClick = useCallback(() => {
297
+ if (disabled) {
298
+ return;
299
+ }
300
+ onSelectedValueChange(value);
301
+ onSelect?.();
302
+ }, [
303
+ disabled,
304
+ value,
305
+ onSelectedValueChange,
306
+ onSelect
307
+ ]);
308
+ const handleMouseDown = useCallback((event) => {
309
+ event.preventDefault();
310
+ }, []);
311
+ const Comp = asChild ? Slot : "div";
312
+ return /* @__PURE__ */ React3.createElement(Comp, {
313
+ ...props,
314
+ ref: (node) => {
315
+ internalRef.current = node;
316
+ if (typeof forwardedRef === "function") {
317
+ forwardedRef(node);
318
+ } else if (forwardedRef) {
319
+ forwardedRef.current = node;
320
+ }
321
+ },
322
+ role: "option",
323
+ "aria-selected": isSelected,
324
+ "aria-disabled": disabled,
325
+ "data-selected": isSelected,
326
+ "data-disabled": disabled,
327
+ "data-value": value,
328
+ // Browser focus stays on the input; highlight is via `aria-selected`.
329
+ tabIndex: -1,
330
+ className: mx3("dx-hover dx-selected px-[var(--gutter,0.75rem)] py-1 cursor-pointer select-none", disabled && "opacity-50 cursor-not-allowed", classNames),
331
+ onMouseDown: handleMouseDown,
332
+ onClick: handleClick
333
+ }, children);
334
+ });
335
+ PickerItem.displayName = "Picker.Item";
336
+ var Picker = {
337
+ Root: PickerRoot,
338
+ Input: PickerInput,
339
+ Item: PickerItem
340
+ };
341
+
342
+ // src/components/Combobox/Combobox.tsx
343
+ var COMBOBOX_NAME = "Combobox";
344
+ var COMBOBOX_CONTENT_NAME = "ComboboxContent";
345
+ var COMBOBOX_ITEM_NAME = "ComboboxItem";
346
+ var COMBOBOX_TRIGGER_NAME = "ComboboxTrigger";
347
+ var [ComboboxProvider, useComboboxContext] = createContext4(COMBOBOX_NAME, {});
348
+ var ComboboxRoot = ({ children, modal, modalId: modalIdProp, open: openProp, defaultOpen, onOpenChange: propsOnOpenChange, value: valueProp, defaultValue, onValueChange: propsOnValueChange, placeholder }) => {
349
+ const modalId = useId(COMBOBOX_NAME, modalIdProp);
350
+ const [open = false, onOpenChange] = useControllableState({
351
+ prop: openProp,
352
+ defaultProp: defaultOpen,
353
+ onChange: propsOnOpenChange
354
+ });
355
+ const [value = "", onValueChange] = useControllableState({
356
+ prop: valueProp,
357
+ defaultProp: defaultValue,
358
+ onChange: propsOnValueChange
359
+ });
360
+ return /* @__PURE__ */ React4.createElement(Popover.Root, {
361
+ open,
362
+ onOpenChange,
363
+ modal
364
+ }, /* @__PURE__ */ React4.createElement(ComboboxProvider, {
365
+ isCombobox: true,
366
+ modalId,
367
+ placeholder,
368
+ open,
369
+ onOpenChange,
370
+ value,
371
+ onValueChange
372
+ }, children));
373
+ };
374
+ var ComboboxContent = composable(({ children, ...props }, forwardedRef) => {
375
+ const { modalId } = useComboboxContext(COMBOBOX_CONTENT_NAME);
376
+ return /* @__PURE__ */ React4.createElement(Popover.Content, {
377
+ ...composableProps(props, {
378
+ id: modalId
379
+ }),
380
+ ref: forwardedRef
381
+ }, /* @__PURE__ */ React4.createElement(Popover.Viewport, {
382
+ classNames: "w-(--radix-popover-trigger-width)"
383
+ }, /* @__PURE__ */ React4.createElement(Picker.Root, null, children)));
384
+ });
385
+ ComboboxContent.displayName = COMBOBOX_CONTENT_NAME;
386
+ var ComboboxTrigger = /* @__PURE__ */ forwardRef2(({ children, onClick, ...props }, forwardedRef) => {
387
+ const { modalId, open, onOpenChange, placeholder, value } = useComboboxContext(COMBOBOX_TRIGGER_NAME);
388
+ const handleClick = useCallback2((event) => {
389
+ onClick?.(event);
390
+ onOpenChange?.(true);
391
+ }, [
392
+ onClick,
393
+ onOpenChange
394
+ ]);
395
+ return /* @__PURE__ */ React4.createElement(Popover.Trigger, {
396
+ asChild: true
397
+ }, /* @__PURE__ */ React4.createElement(Button, {
398
+ ...props,
399
+ role: "combobox",
400
+ "aria-expanded": open,
401
+ "aria-controls": modalId,
402
+ "aria-haspopup": "dialog",
403
+ onClick: handleClick,
404
+ ref: forwardedRef
405
+ }, children ?? /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("span", {
406
+ className: mx4("font-normal text-start flex-1 min-w-0 truncate me-2", !value && "text-subdued")
407
+ }, value || placeholder), /* @__PURE__ */ React4.createElement(Icon2, {
408
+ icon: "ph--caret-down--bold",
409
+ size: 3
410
+ }))));
411
+ });
412
+ ComboboxTrigger.displayName = COMBOBOX_TRIGGER_NAME;
413
+ var ComboboxVirtualTrigger = Popover.VirtualTrigger;
414
+ var ComboboxInput = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
415
+ return /* @__PURE__ */ React4.createElement(Picker.Input, {
416
+ ...props,
417
+ classNames: [
418
+ "m-form-chrome mb-0 w-[calc(100%-2*var(--spacing-form-chrome))]",
419
+ classNames
420
+ ],
421
+ ref: forwardedRef
422
+ });
423
+ });
424
+ ComboboxInput.displayName = "Combobox.Input";
425
+ var ComboboxList = /* @__PURE__ */ forwardRef2(({ classNames, children, ...props }, forwardedRef) => {
426
+ return /* @__PURE__ */ React4.createElement(ScrollArea.Root, {
427
+ ...composableProps(props, {
428
+ classNames: [
429
+ "py-form-chrome",
430
+ classNames
431
+ ]
432
+ }),
433
+ role: "listbox",
434
+ centered: true,
435
+ padding: true,
436
+ thin: true,
437
+ ref: forwardedRef
438
+ }, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, children));
439
+ });
440
+ ComboboxList.displayName = "Combobox.List";
441
+ var ComboboxItem = /* @__PURE__ */ forwardRef2(({ classNames, onSelect, value, label, icon, iconClassNames, checked, suffix, disabled, closeOnSelect = true, children }, forwardedRef) => {
442
+ const { onValueChange, onOpenChange } = useComboboxContext(COMBOBOX_ITEM_NAME);
443
+ const handleSelect = useCallback2(() => {
444
+ onSelect?.();
445
+ if (value !== void 0) {
446
+ onValueChange?.(value);
447
+ }
448
+ if (closeOnSelect) {
449
+ onOpenChange?.(false);
450
+ }
451
+ }, [
452
+ onSelect,
453
+ onValueChange,
454
+ onOpenChange,
455
+ value,
456
+ closeOnSelect
457
+ ]);
458
+ return /* @__PURE__ */ React4.createElement(Picker.Item, {
459
+ value,
460
+ disabled,
461
+ onSelect: handleSelect,
462
+ ref: forwardedRef,
463
+ classNames: [
464
+ // Full width inside the viewport (no horizontal margin).
465
+ // `px-3 py-1`, `cursor-pointer`, `select-none` and the
466
+ // `dx-hover` / `dx-selected` pairing come from `Picker.Item`'s
467
+ // defaults; we only add the row-shape (flex / icons + label)
468
+ // and the disabled overrides on top.
469
+ "flex w-full gap-2 items-center",
470
+ disabled && "hover:bg-transparent data-[selected=true]:bg-transparent",
471
+ classNames
472
+ ]
473
+ }, children ?? /* @__PURE__ */ React4.createElement(React4.Fragment, null, icon && /* @__PURE__ */ React4.createElement(Icon2, {
474
+ icon,
475
+ classNames: iconClassNames
476
+ }), /* @__PURE__ */ React4.createElement("span", {
477
+ className: "w-0 grow truncate"
478
+ }, label), suffix && /* @__PURE__ */ React4.createElement("span", {
479
+ className: "shrink-0 text-description"
480
+ }, suffix), checked && /* @__PURE__ */ React4.createElement(Icon2, {
481
+ icon: "ph--check--regular"
482
+ })));
483
+ });
484
+ ComboboxItem.displayName = COMBOBOX_ITEM_NAME;
485
+ var ComboboxArrow = Popover.Arrow;
486
+ var ComboboxEmpty = /* @__PURE__ */ forwardRef2(({ classNames, children }, forwardedRef) => {
487
+ return /* @__PURE__ */ React4.createElement("div", {
488
+ ref: forwardedRef,
489
+ role: "status",
490
+ className: mx4(classNames)
491
+ }, children);
492
+ });
493
+ ComboboxEmpty.displayName = "Combobox.Empty";
494
+ var ComboboxPortal = Popover.Portal;
495
+ var Combobox = {
496
+ Root: ComboboxRoot,
497
+ Portal: ComboboxPortal,
498
+ Content: ComboboxContent,
499
+ Trigger: ComboboxTrigger,
500
+ VirtualTrigger: ComboboxVirtualTrigger,
501
+ Input: ComboboxInput,
502
+ List: ComboboxList,
503
+ Item: ComboboxItem,
504
+ Arrow: ComboboxArrow,
505
+ Empty: ComboboxEmpty
506
+ };
507
+
73
508
  // src/components/List/ListItem.tsx
509
+ import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
74
510
  import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
75
511
  import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
76
512
  import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
77
- import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
78
- import { createContext as createContext4 } from "@radix-ui/react-context";
79
- import React4, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
513
+ import { createContext as createContext6 } from "@radix-ui/react-context";
514
+ import { Slot as Slot2 } from "@radix-ui/react-slot";
515
+ import React6, { useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
80
516
  import { createPortal } from "react-dom";
81
517
  import { invariant } from "@dxos/invariant";
82
518
  import { IconButton, ListItem as NaturalListItem, useTranslation } from "@dxos/react-ui";
83
- import { mx as mx3, osTranslations } from "@dxos/ui-theme";
519
+ import { mx as mx5, osTranslations } from "@dxos/ui-theme";
84
520
 
85
521
  // src/components/List/ListRoot.tsx
86
- import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
87
522
  import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
88
523
  import { getReorderDestinationIndex } from "@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index";
89
- import { createContext as createContext3 } from "@radix-ui/react-context";
90
- import React3, { useCallback, useEffect, useState } from "react";
524
+ import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
525
+ import { createContext as createContext5 } from "@radix-ui/react-context";
526
+ import React5, { useCallback as useCallback3, useEffect as useEffect2, useState as useState2 } from "react";
91
527
  var LIST_NAME = "List";
92
- var [ListProvider, useListContext] = createContext3(LIST_NAME);
528
+ var [ListProvider, useListContext] = createContext5(LIST_NAME);
93
529
  var defaultGetId2 = (item) => item?.id;
94
530
  var ListRoot = ({ children, items, isItem, getId = defaultGetId2, onMove, ...props }) => {
95
- const isEqual = useCallback((a, b) => {
531
+ const isEqual = useCallback3((a, b) => {
96
532
  const idA = getId?.(a);
97
533
  const idB = getId?.(b);
98
534
  if (idA !== void 0 && idB !== void 0) {
@@ -103,8 +539,8 @@ var ListRoot = ({ children, items, isItem, getId = defaultGetId2, onMove, ...pro
103
539
  }, [
104
540
  getId
105
541
  ]);
106
- const [state, setState] = useState(idle);
107
- useEffect(() => {
542
+ const [state, setState] = useState2(idle);
543
+ useEffect2(() => {
108
544
  if (!items) {
109
545
  return;
110
546
  }
@@ -140,7 +576,7 @@ var ListRoot = ({ children, items, isItem, getId = defaultGetId2, onMove, ...pro
140
576
  isEqual,
141
577
  onMove
142
578
  ]);
143
- return /* @__PURE__ */ React3.createElement(ListProvider, {
579
+ return /* @__PURE__ */ React5.createElement(ListProvider, {
144
580
  state,
145
581
  setState,
146
582
  isItem,
@@ -161,23 +597,16 @@ var stateStyles = {
161
597
  };
162
598
  var defaultContext = {};
163
599
  var LIST_ITEM_NAME = "ListItem";
164
- var [ListItemProvider, useListItemContext] = createContext4(LIST_ITEM_NAME, defaultContext);
165
- var ListItem = ({ children, classNames, item, ...props }) => {
600
+ var [ListItemProvider, useListItemContext] = createContext6(LIST_ITEM_NAME, defaultContext);
601
+ var ListItem = ({ children, classNames, item, asChild, selected, ...props }) => {
602
+ const Comp = asChild ? Slot2 : "div";
166
603
  const { isItem, readonly, dragPreview, setState: setRootState } = useListContext(LIST_ITEM_NAME);
167
- const ref = useRef(null);
168
- const dragHandleRef = useRef(null);
169
- const [state, setState] = useState2(idle);
170
- useEffect2(() => {
171
- const element = ref.current;
172
- invariant(element, void 0, {
173
- F: __dxlog_file,
174
- L: 98,
175
- S: void 0,
176
- A: [
177
- "element",
178
- ""
179
- ]
180
- });
604
+ const rootRef = useRef2(null);
605
+ const dragHandleRef = useRef2(null);
606
+ const [state, setState] = useState3(idle);
607
+ useEffect3(() => {
608
+ const element = rootRef.current;
609
+ invariant(element, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 37, S: void 0, A: ["element", ""] });
181
610
  return combine(
182
611
  //
183
612
  // https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#draggable
@@ -277,43 +706,44 @@ var ListItem = ({ children, classNames, item, ...props }) => {
277
706
  }, [
278
707
  item
279
708
  ]);
280
- return /* @__PURE__ */ React4.createElement(ListItemProvider, {
709
+ return /* @__PURE__ */ React6.createElement(ListItemProvider, {
281
710
  item,
282
711
  dragHandleRef
283
- }, /* @__PURE__ */ React4.createElement("div", {
284
- ref,
712
+ }, /* @__PURE__ */ React6.createElement(Comp, {
713
+ ...props,
285
714
  role: "listitem",
286
- className: mx3("flex relative", classNames, stateStyles[state.type]),
287
- ...props
288
- }, children, state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React4.createElement(NaturalListItem.DropIndicator, {
715
+ "aria-selected": selected,
716
+ className: mx5("relative p-1 dx-selected dx-hover", classNames, stateStyles[state.type]),
717
+ ref: rootRef
718
+ }, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React6.createElement(NaturalListItem.DropIndicator, {
289
719
  edge: state.closestEdge
290
- })));
720
+ }));
291
721
  };
292
- var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", label, ...props }) => {
293
- const { state } = useListContext("DELETE_BUTTON");
722
+ var ListItemIconButton = ({ autoHide = true, iconOnly = true, variant = "ghost", classNames, disabled, ...props }) => {
723
+ const { state } = useListContext("ITEM_BUTTON");
294
724
  const isDisabled = state.type !== "idle" || disabled;
295
- const { t } = useTranslation(osTranslations);
296
- return /* @__PURE__ */ React4.createElement(IconButton, {
297
- iconOnly: true,
298
- variant: "ghost",
725
+ return /* @__PURE__ */ React6.createElement(IconButton, {
299
726
  ...props,
300
- icon,
301
727
  disabled: isDisabled,
302
- label: label ?? t("delete label"),
728
+ iconOnly,
729
+ variant,
303
730
  classNames: [
304
731
  classNames,
305
732
  autoHide && disabled && "hidden"
306
733
  ]
307
734
  });
308
735
  };
309
- var ListItemButton = ({ autoHide = true, iconOnly = true, variant = "ghost", classNames, disabled, ...props }) => {
310
- const { state } = useListContext("ITEM_BUTTON");
736
+ var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", label, ...props }) => {
737
+ const { state } = useListContext("DELETE_BUTTON");
311
738
  const isDisabled = state.type !== "idle" || disabled;
312
- return /* @__PURE__ */ React4.createElement(IconButton, {
739
+ const { t } = useTranslation(osTranslations);
740
+ return /* @__PURE__ */ React6.createElement(IconButton, {
313
741
  ...props,
742
+ variant: "ghost",
314
743
  disabled: isDisabled,
315
- iconOnly,
316
- variant,
744
+ icon,
745
+ iconOnly: true,
746
+ label: label ?? t("delete.label"),
317
747
  classNames: [
318
748
  classNames,
319
749
  autoHide && disabled && "hidden"
@@ -323,13 +753,13 @@ var ListItemButton = ({ autoHide = true, iconOnly = true, variant = "ghost", cla
323
753
  var ListItemDragHandle = ({ disabled }) => {
324
754
  const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
325
755
  const { t } = useTranslation(osTranslations);
326
- return /* @__PURE__ */ React4.createElement(IconButton, {
327
- iconOnly: true,
756
+ return /* @__PURE__ */ React6.createElement(IconButton, {
328
757
  variant: "ghost",
329
- label: t("drag handle label"),
330
- ref: dragHandleRef,
758
+ disabled,
331
759
  icon: "ph--dots-six-vertical--regular",
332
- disabled
760
+ iconOnly: true,
761
+ label: t("drag-handle.label"),
762
+ ref: dragHandleRef
333
763
  });
334
764
  };
335
765
  var ListItemDragPreview = ({ children }) => {
@@ -338,11 +768,11 @@ var ListItemDragPreview = ({ children }) => {
338
768
  item: state.item
339
769
  }), state.container) : null;
340
770
  };
341
- var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */ React4.createElement("div", {
342
- className: mx3("flex is-full gap-2", classNames)
771
+ var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */ React6.createElement("div", {
772
+ className: mx5("flex w-full gap-2", classNames)
343
773
  }, children);
344
- var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */ React4.createElement("div", {
345
- className: mx3("flex grow items-center truncate", classNames),
774
+ var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */ React6.createElement("div", {
775
+ className: mx5("flex grow items-center truncate", classNames),
346
776
  ...props
347
777
  }, children);
348
778
 
@@ -353,31 +783,253 @@ var List = {
353
783
  ItemDragPreview: ListItemDragPreview,
354
784
  ItemWrapper: ListItemWrapper,
355
785
  ItemDragHandle: ListItemDragHandle,
786
+ ItemIconButton: ListItemIconButton,
356
787
  ItemDeleteButton: ListItemDeleteButton,
357
- ItemButton: ListItemButton,
358
788
  ItemTitle: ListItemTitle
359
789
  };
360
790
 
791
+ // src/components/Listbox/Listbox.tsx
792
+ import { createContextScope as createContextScope2 } from "@radix-ui/react-context";
793
+ import React8, { forwardRef as forwardRef3 } from "react";
794
+ import { Icon as Icon3 } from "@dxos/react-ui";
795
+ import { mx as mx6 } from "@dxos/ui-theme";
796
+
797
+ // src/components/RowList/RowList.tsx
798
+ import { useArrowNavigationGroup } from "@fluentui/react-tabster";
799
+ import { createContextScope } from "@radix-ui/react-context";
800
+ import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
801
+ import React7, { useCallback as useCallback4 } from "react";
802
+ import { List as List2, ListItem as ListItem2 } from "@dxos/react-list";
803
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
804
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
805
+ var ROW_LIST_NAME = "RowList";
806
+ var ROW_LIST_ROOT_NAME = "RowList.Root";
807
+ var ROW_LIST_VIEWPORT_NAME = "RowList.Viewport";
808
+ var ROW_LIST_CONTENT_NAME = "RowList.Content";
809
+ var ROW_NAME = "List.Row";
810
+ var [createRowListContext, createRowListScope] = createContextScope(ROW_LIST_NAME, []);
811
+ var [RowListProvider, useRowListContext] = createRowListContext(ROW_LIST_NAME);
812
+ var Root2 = ({ selectedId, defaultSelectedId, onSelectChange, children }) => {
813
+ const [resolved, setResolved] = useControllableState2({
814
+ prop: selectedId,
815
+ defaultProp: defaultSelectedId,
816
+ onChange: (next) => {
817
+ if (next !== void 0) {
818
+ onSelectChange?.(next);
819
+ }
820
+ }
821
+ });
822
+ const setSelected = useCallback4((id) => setResolved(id), [
823
+ setResolved
824
+ ]);
825
+ return /* @__PURE__ */ React7.createElement(RowListProvider, {
826
+ scope: void 0,
827
+ selectedId: resolved,
828
+ setSelected
829
+ }, children);
830
+ };
831
+ Root2.displayName = ROW_LIST_ROOT_NAME;
832
+ var Viewport = composable2((props, forwardedRef) => {
833
+ const { thin, padding, centered, children, ...rest } = props;
834
+ const composed = composableProps2(rest, {
835
+ classNames: "dx-container"
836
+ });
837
+ return /* @__PURE__ */ React7.createElement(ScrollArea2.Root, {
838
+ orientation: "vertical",
839
+ thin,
840
+ padding,
841
+ centered,
842
+ ...composed,
843
+ ref: forwardedRef
844
+ }, /* @__PURE__ */ React7.createElement(ScrollArea2.Viewport, null, children));
845
+ });
846
+ Viewport.displayName = ROW_LIST_VIEWPORT_NAME;
847
+ var firstEnabledOption = (ul) => {
848
+ if (!ul) {
849
+ return null;
850
+ }
851
+ return ul.querySelector('[role="option"]:not([aria-disabled="true"])');
852
+ };
853
+ var Content2 = composable2((props, forwardedRef) => {
854
+ useRowListContext(ROW_LIST_CONTENT_NAME, void 0);
855
+ const arrowGroup = useArrowNavigationGroup({
856
+ axis: "vertical",
857
+ memorizeCurrent: true
858
+ });
859
+ const { children, ...rest } = props;
860
+ const handleFocus = useCallback4((event) => {
861
+ if (event.target !== event.currentTarget) {
862
+ return;
863
+ }
864
+ const ul = event.currentTarget;
865
+ const selected = ul.querySelector('[role="option"][aria-selected="true"]:not([aria-disabled="true"])');
866
+ const target = selected ?? firstEnabledOption(ul);
867
+ target?.focus();
868
+ }, []);
869
+ const composed = composableProps2(rest, {
870
+ classNames: "flex flex-col"
871
+ });
872
+ return /* @__PURE__ */ React7.createElement(List2, {
873
+ variant: "unordered",
874
+ ...composed,
875
+ ...arrowGroup,
876
+ role: "listbox",
877
+ onFocus: handleFocus,
878
+ ref: forwardedRef
879
+ }, children);
880
+ });
881
+ Content2.displayName = ROW_LIST_CONTENT_NAME;
882
+ var ROW_BASE = "dx-hover dx-selected px-3 py-2 cursor-pointer outline-none border-b border-separator last:border-b-0";
883
+ var Row = composable2((props, forwardedRef) => {
884
+ const { id, disabled, onClick, onFocus, children, ...rest } = props;
885
+ const { selectedId, setSelected } = useRowListContext(ROW_NAME, void 0);
886
+ const isSelected = selectedId === id;
887
+ const handleClick = useCallback4((event) => {
888
+ if (disabled) {
889
+ return;
890
+ }
891
+ setSelected(id);
892
+ onClick?.(event);
893
+ }, [
894
+ disabled,
895
+ id,
896
+ setSelected,
897
+ onClick
898
+ ]);
899
+ const handleFocus = useCallback4((event) => {
900
+ if (!disabled && selectedId !== id) {
901
+ setSelected(id);
902
+ }
903
+ onFocus?.(event);
904
+ }, [
905
+ disabled,
906
+ selectedId,
907
+ id,
908
+ setSelected,
909
+ onFocus
910
+ ]);
911
+ const composed = composableProps2(rest, {
912
+ classNames: [
913
+ ROW_BASE,
914
+ disabled && "opacity-50 cursor-not-allowed"
915
+ ]
916
+ });
917
+ return /* @__PURE__ */ React7.createElement(ListItem2, {
918
+ ...composed,
919
+ role: "option",
920
+ tabIndex: 0,
921
+ "aria-selected": isSelected,
922
+ "aria-disabled": disabled || void 0,
923
+ onClick: handleClick,
924
+ onFocus: handleFocus,
925
+ ref: forwardedRef
926
+ }, children);
927
+ });
928
+ Row.displayName = ROW_NAME;
929
+ var useRowListSelection = (id) => {
930
+ const { selectedId } = useRowListContext("useRowListSelection", void 0);
931
+ return selectedId === id;
932
+ };
933
+ var RowList = {
934
+ Root: Root2,
935
+ Viewport,
936
+ Content: Content2
937
+ };
938
+
939
+ // src/components/Listbox/Listbox.tsx
940
+ var commandItem = "flex items-center overflow-hidden";
941
+ var LISTBOX_NAME = "Listbox";
942
+ var LISTBOX_OPTION_NAME = "ListboxOption";
943
+ var LISTBOX_OPTION_LABEL_NAME = "ListboxOptionLabel";
944
+ var LISTBOX_OPTION_INDICATOR_NAME = "ListboxOptionIndicator";
945
+ var [createListboxContext, createListboxScope] = createContextScope2(LISTBOX_NAME, [
946
+ createRowListScope
947
+ ]);
948
+ var [createListboxOptionContext, createListboxOptionScope] = createContextScope2(LISTBOX_OPTION_NAME, [
949
+ createListboxScope
950
+ ]);
951
+ var [ListboxOptionProvider, useListboxOptionContext] = createListboxOptionContext(LISTBOX_OPTION_NAME);
952
+ var ListboxRoot = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
953
+ const { __listboxScope: _scope, children, classNames, value, defaultValue, onValueChange, autoFocus: _autoFocus, ...rootProps } = props;
954
+ return /* @__PURE__ */ React8.createElement(RowList.Root, {
955
+ selectedId: value,
956
+ defaultSelectedId: defaultValue,
957
+ onSelectChange: onValueChange
958
+ }, /* @__PURE__ */ React8.createElement(RowList.Content, {
959
+ ...rootProps,
960
+ classNames: mx6("w-full", classNames),
961
+ ref: forwardedRef
962
+ }, children));
963
+ });
964
+ ListboxRoot.displayName = LISTBOX_NAME;
965
+ var ListboxOption = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
966
+ const { __listboxScope, children, classNames, value, ...rootProps } = props;
967
+ return /* @__PURE__ */ React8.createElement(Row, {
968
+ id: value,
969
+ ...rootProps,
970
+ classNames: mx6("dx-focus-ring rounded-xs", commandItem, classNames),
971
+ ref: forwardedRef
972
+ }, /* @__PURE__ */ React8.createElement(ListboxOptionProviderHost, {
973
+ value
974
+ }, children));
975
+ });
976
+ ListboxOption.displayName = LISTBOX_OPTION_NAME;
977
+ var ListboxOptionProviderHost = ({ value, children }) => {
978
+ const isSelected = useRowListSelection(value);
979
+ return /* @__PURE__ */ React8.createElement(ListboxOptionProvider, {
980
+ scope: void 0,
981
+ value,
982
+ isSelected
983
+ }, children);
984
+ };
985
+ var ListboxOptionLabel = /* @__PURE__ */ forwardRef3(({ children, classNames, ...rootProps }, forwardedRef) => {
986
+ return /* @__PURE__ */ React8.createElement("span", {
987
+ ...rootProps,
988
+ className: mx6("grow truncate", classNames),
989
+ ref: forwardedRef
990
+ }, children);
991
+ });
992
+ ListboxOptionLabel.displayName = LISTBOX_OPTION_LABEL_NAME;
993
+ var ListboxOptionIndicator = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
994
+ const { __listboxOptionScope, classNames, ...rootProps } = props;
995
+ const { isSelected } = useListboxOptionContext(LISTBOX_OPTION_INDICATOR_NAME, __listboxOptionScope);
996
+ return /* @__PURE__ */ React8.createElement(Icon3, {
997
+ icon: "ph--check--regular",
998
+ ...rootProps,
999
+ classNames: mx6(!isSelected && "invisible", classNames),
1000
+ ref: forwardedRef
1001
+ });
1002
+ });
1003
+ ListboxOptionIndicator.displayName = LISTBOX_OPTION_INDICATOR_NAME;
1004
+ var Listbox = {
1005
+ Root: ListboxRoot,
1006
+ Option: ListboxOption,
1007
+ OptionLabel: ListboxOptionLabel,
1008
+ OptionIndicator: ListboxOptionIndicator
1009
+ };
1010
+
361
1011
  // src/components/Tree/Tree.tsx
362
- import React8, { useMemo as useMemo2 } from "react";
1012
+ import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
1013
+ import React12, { useMemo as useMemo3 } from "react";
363
1014
  import { Treegrid as Treegrid2 } from "@dxos/react-ui";
364
1015
 
365
1016
  // src/components/Tree/TreeContext.tsx
366
- import { createContext as createContext5, useContext } from "react";
1017
+ import { createContext as createContext7, useContext } from "react";
367
1018
  import { raise } from "@dxos/debug";
368
- var TreeContext = /* @__PURE__ */ createContext5(null);
1019
+ var TreeContext = /* @__PURE__ */ createContext7(null);
369
1020
  var TreeProvider = TreeContext.Provider;
370
1021
  var useTree = () => useContext(TreeContext) ?? raise(new Error("TreeContext not found"));
371
1022
 
372
1023
  // src/components/Tree/TreeItem.tsx
1024
+ import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
373
1025
  import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
374
1026
  import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
375
- import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
1027
+ import { useAtomValue } from "@effect-atom/atom-react";
376
1028
  import * as Schema from "effect/Schema";
377
- import React7, { memo as memo3, useCallback as useCallback3, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
1029
+ import React11, { memo as memo3, useCallback as useCallback6, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
378
1030
  import { invariant as invariant2 } from "@dxos/invariant";
379
- import { TreeItem as NaturalTreeItem, Treegrid } from "@dxos/react-ui";
380
- import { ghostFocusWithin, ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls } from "@dxos/ui-theme";
1031
+ import { TreeItem as NaturalTreeItem, Treegrid, TREEGRID_PARENT_OF_SEPARATOR } from "@dxos/react-ui";
1032
+ import { ghostFocusWithin, ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, mx as mx7 } from "@dxos/ui-theme";
381
1033
 
382
1034
  // src/components/Tree/helpers.ts
383
1035
  var DEFAULT_INDENTATION = 8;
@@ -386,19 +1038,19 @@ var paddingIndentation = (level, indentation = DEFAULT_INDENTATION) => ({
386
1038
  });
387
1039
 
388
1040
  // src/components/Tree/TreeItemHeading.tsx
389
- import React5, { forwardRef, memo, useCallback as useCallback2 } from "react";
390
- import { Button, Icon as Icon2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
1041
+ import React9, { forwardRef as forwardRef4, memo, useCallback as useCallback5 } from "react";
1042
+ import { Button as Button2, Icon as Icon4, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
391
1043
  import { TextTooltip } from "@dxos/react-ui-text-tooltip";
392
1044
  import { getStyles } from "@dxos/ui-theme";
393
- var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label, className, icon, iconHue, disabled, current, onSelect }, forwardedRef) => {
1045
+ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef4(({ label, className, icon, iconHue, disabled, current, onSelect }, forwardedRef) => {
394
1046
  const { t } = useTranslation2();
395
1047
  const styles = iconHue ? getStyles(iconHue) : void 0;
396
- const handleSelect = useCallback2((event) => {
1048
+ const handleSelect = useCallback5((event) => {
397
1049
  onSelect?.(event.altKey);
398
1050
  }, [
399
1051
  onSelect
400
1052
  ]);
401
- const handleButtonKeydown = useCallback2((event) => {
1053
+ const handleButtonKeydown = useCallback5((event) => {
402
1054
  if (event.key === " " || event.key === "Enter") {
403
1055
  event.preventDefault();
404
1056
  event.stopPropagation();
@@ -407,19 +1059,18 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label,
407
1059
  }, [
408
1060
  onSelect
409
1061
  ]);
410
- return /* @__PURE__ */ React5.createElement(TextTooltip, {
1062
+ return /* @__PURE__ */ React9.createElement(TextTooltip, {
411
1063
  text: toLocalizedString(label, t),
412
1064
  side: "bottom",
413
1065
  truncateQuery: "span[data-tooltip]",
414
1066
  onlyWhenTruncating: true,
415
1067
  asChild: true,
416
1068
  ref: forwardedRef
417
- }, /* @__PURE__ */ React5.createElement(Button, {
1069
+ }, /* @__PURE__ */ React9.createElement(Button2, {
418
1070
  "data-testid": "treeItem.heading",
419
1071
  variant: "ghost",
420
- density: "fine",
421
1072
  classNames: [
422
- "grow gap-2 pis-0.5 hover:bg-transparent dark:hover:bg-transparent",
1073
+ "grow gap-2 ps-0.5 hover:bg-transparent dark:hover:bg-transparent",
423
1074
  "disabled:cursor-default disabled:opacity-100",
424
1075
  className
425
1076
  ],
@@ -429,33 +1080,33 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label,
429
1080
  ...current && {
430
1081
  "aria-current": "location"
431
1082
  }
432
- }, icon && /* @__PURE__ */ React5.createElement(Icon2, {
433
- icon: icon ?? "ph--placeholder--regular",
1083
+ }, icon && /* @__PURE__ */ React9.createElement(Icon4, {
434
1084
  size: 5,
1085
+ icon: icon ?? "ph--placeholder--regular",
435
1086
  classNames: [
436
- "mlb-1",
437
- styles?.icon
1087
+ "my-1",
1088
+ styles?.surfaceText
438
1089
  ]
439
- }), /* @__PURE__ */ React5.createElement("span", {
440
- className: "flex-1 is-0 truncate text-start text-sm font-normal",
1090
+ }), /* @__PURE__ */ React9.createElement("span", {
1091
+ className: "flex-1 w-0 truncate text-start font-normal",
441
1092
  "data-tooltip": true
442
1093
  }, toLocalizedString(label, t))));
443
1094
  }));
444
1095
 
445
1096
  // src/components/Tree/TreeItemToggle.tsx
446
- import React6, { forwardRef as forwardRef2, memo as memo2 } from "react";
1097
+ import React10, { forwardRef as forwardRef5, memo as memo2 } from "react";
447
1098
  import { IconButton as IconButton2 } from "@dxos/react-ui";
448
- var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef2(({ open, isBranch, hidden, classNames, ...props }, forwardedRef) => {
449
- return /* @__PURE__ */ React6.createElement(IconButton2, {
1099
+ var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef5(({ classNames, open, isBranch, hidden, ...props }, forwardedRef) => {
1100
+ return /* @__PURE__ */ React10.createElement(IconButton2, {
450
1101
  ref: forwardedRef,
451
1102
  "data-testid": "treeItem.toggle",
452
1103
  "aria-expanded": open,
453
1104
  variant: "ghost",
454
1105
  density: "fine",
455
1106
  classNames: [
456
- "bs-full is-6 pli-0",
457
- "[&_svg]:transition-[transform] [&_svg]:duration-200",
458
- open && "[&_svg]:rotate-90",
1107
+ "h-full w-6 px-0",
1108
+ "[&_svg]:transition-transform [&_svg]:duration-200",
1109
+ open ? "[&_svg]:rotate-90" : "[&_svg]:rotate-0",
459
1110
  hidden ? "hidden" : !isBranch && "invisible",
460
1111
  classNames
461
1112
  ],
@@ -478,26 +1129,26 @@ var TreeDataSchema = Schema.Struct({
478
1129
  item: Schema.Any
479
1130
  });
480
1131
  var isTreeData = (data) => Schema.is(TreeDataSchema)(data);
481
- var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _draggable, renderColumns: Columns, blockInstruction, canDrop, canSelect, onOpenChange, onSelect }) => {
482
- const rowRef = useRef2(null);
483
- const buttonRef = useRef2(null);
484
- const openRef = useRef2(false);
485
- const cancelExpandRef = useRef2(null);
486
- const [_state, setState] = useState3("idle");
487
- const [instruction, setInstruction] = useState3(null);
488
- const [menuOpen, setMenuOpen] = useState3(false);
489
- const { useItems, getProps, useIsOpen, useIsCurrent } = useTree();
490
- const items = useItems(item);
491
- const { id, parentOf, label, className, headingClassName, icon, iconHue, disabled, testId } = getProps(item, _path);
492
- const path = useMemo(() => [
493
- ..._path,
494
- id
1132
+ var RawTreeItem = ({ item, path: pathProp, levelOffset = 2, last, draggable: draggableProp, renderColumns: Columns, blockInstruction, canDrop, canSelect, onOpenChange, onSelect, onItemHover }) => {
1133
+ const rowRef = useRef3(null);
1134
+ const buttonRef = useRef3(null);
1135
+ const openRef = useRef3(false);
1136
+ const cancelExpandRef = useRef3(null);
1137
+ const [_state, setState] = useState4("idle");
1138
+ const [instruction, setInstruction] = useState4(null);
1139
+ const [menuOpen, setMenuOpen] = useState4(false);
1140
+ const { itemProps: itemPropsAtom, childIds: childIdsAtom, itemOpen: itemOpenAtom, itemCurrent: itemCurrentAtom } = useTree();
1141
+ const path = useMemo2(() => [
1142
+ ...pathProp,
1143
+ item.id
495
1144
  ], [
496
- _path,
497
- id
1145
+ pathProp,
1146
+ item.id
498
1147
  ]);
499
- const open = useIsOpen(path, item);
500
- const current = useIsCurrent(path, item);
1148
+ const { id, parentOf, draggable: itemDraggable, droppable: itemDroppable, label, className, headingClassName, icon, iconHue, disabled, testId } = useAtomValue(itemPropsAtom(path));
1149
+ const childIds = useAtomValue(childIdsAtom(item.id));
1150
+ const open = useAtomValue(itemOpenAtom(path));
1151
+ const current = useAtomValue(itemCurrentAtom(path));
501
1152
  const level = path.length - levelOffset;
502
1153
  const isBranch = !!parentOf;
503
1154
  const mode = last ? "last-in-group" : open ? "expanded" : "standard";
@@ -505,122 +1156,132 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
505
1156
  item,
506
1157
  path
507
1158
  }) ?? true;
508
- const cancelExpand = useCallback3(() => {
1159
+ const data = {
1160
+ id,
1161
+ path,
1162
+ item
1163
+ };
1164
+ const shouldSeedNativeDragData = typeof document !== "undefined" && document.body.hasAttribute("data-platform");
1165
+ const cancelExpand = useCallback6(() => {
509
1166
  if (cancelExpandRef.current) {
510
1167
  clearTimeout(cancelExpandRef.current);
511
1168
  cancelExpandRef.current = null;
512
1169
  }
513
1170
  }, []);
514
- useEffect3(() => {
515
- if (!_draggable) {
1171
+ const isItemDraggable = draggableProp && itemDraggable !== false;
1172
+ const isItemDroppable = itemDroppable !== false;
1173
+ const nativeDragText = id;
1174
+ useEffect4(() => {
1175
+ if (!draggableProp) {
516
1176
  return;
517
1177
  }
518
- invariant2(buttonRef.current, void 0, {
519
- F: __dxlog_file2,
520
- L: 111,
521
- S: void 0,
522
- A: [
523
- "buttonRef.current",
524
- ""
525
- ]
526
- });
527
- const data = {
528
- id,
529
- path,
530
- item
531
- };
532
- return combine2(
533
- draggable2({
534
- element: buttonRef.current,
535
- getInitialData: () => data,
536
- onDragStart: () => {
537
- setState("dragging");
538
- if (open) {
539
- openRef.current = true;
540
- onOpenChange?.({
541
- item,
542
- path,
543
- open: false
544
- });
545
- }
546
- },
547
- onDrop: () => {
548
- setState("idle");
549
- if (openRef.current) {
550
- onOpenChange?.({
551
- item,
552
- path,
553
- open: true
554
- });
555
- }
1178
+ invariant2(buttonRef.current, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 70, S: void 0, A: ["buttonRef.current", ""] });
1179
+ const makeDraggable = () => draggable2({
1180
+ element: buttonRef.current,
1181
+ getInitialData: () => data,
1182
+ getInitialDataForExternal: () => {
1183
+ if (!shouldSeedNativeDragData) {
1184
+ return {};
556
1185
  }
557
- }),
558
- // https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/hitbox/constellation/index/about.mdx
559
- dropTargetForElements2({
560
- element: buttonRef.current,
561
- getData: ({ input, element }) => {
562
- return attachInstruction(data, {
563
- input,
564
- element,
565
- indentPerLevel: DEFAULT_INDENTATION,
566
- currentLevel: level,
567
- mode,
568
- block: isBranch ? [] : [
569
- "make-child"
570
- ]
571
- });
572
- },
573
- canDrop: ({ source }) => {
574
- const _canDrop = canDrop ?? (() => true);
575
- return source.element !== buttonRef.current && _canDrop({
576
- source: source.data,
577
- target: data
1186
+ return {
1187
+ "text/plain": nativeDragText
1188
+ };
1189
+ },
1190
+ onDragStart: () => {
1191
+ setState("dragging");
1192
+ if (open) {
1193
+ openRef.current = true;
1194
+ onOpenChange?.({
1195
+ item,
1196
+ path,
1197
+ open: false
578
1198
  });
579
- },
580
- getIsSticky: () => true,
581
- onDrag: ({ self, source }) => {
582
- const desired = extractInstruction(self.data);
583
- const block = desired && blockInstruction?.({
584
- instruction: desired,
585
- source: source.data,
586
- target: data
1199
+ }
1200
+ },
1201
+ onDrop: () => {
1202
+ setState("idle");
1203
+ if (openRef.current) {
1204
+ onOpenChange?.({
1205
+ item,
1206
+ path,
1207
+ open: true
587
1208
  });
588
- const instruction2 = block && desired.type !== "instruction-blocked" ? {
589
- type: "instruction-blocked",
590
- desired
591
- } : desired;
592
- if (source.data.id !== id) {
593
- if (instruction2?.type === "make-child" && isBranch && !open && !cancelExpandRef.current) {
594
- cancelExpandRef.current = setTimeout(() => {
595
- onOpenChange?.({
596
- item,
597
- path,
598
- open: true
599
- });
600
- }, 500);
601
- }
602
- if (instruction2?.type !== "make-child") {
603
- cancelExpand();
604
- }
605
- setInstruction(instruction2);
606
- } else if (instruction2?.type === "reparent") {
607
- setInstruction(instruction2);
608
- } else {
609
- setInstruction(null);
1209
+ }
1210
+ }
1211
+ });
1212
+ if (!isItemDroppable) {
1213
+ return isItemDraggable ? makeDraggable() : void 0;
1214
+ }
1215
+ const dropTarget = dropTargetForElements2({
1216
+ element: buttonRef.current,
1217
+ getData: ({ input, element }) => {
1218
+ return attachInstruction(data, {
1219
+ input,
1220
+ element,
1221
+ indentPerLevel: DEFAULT_INDENTATION,
1222
+ currentLevel: level,
1223
+ mode,
1224
+ block: isBranch ? [] : [
1225
+ "make-child"
1226
+ ]
1227
+ });
1228
+ },
1229
+ canDrop: ({ source }) => {
1230
+ const _canDrop = canDrop ?? (() => true);
1231
+ return source.element !== buttonRef.current && _canDrop({
1232
+ source: source.data,
1233
+ target: data
1234
+ });
1235
+ },
1236
+ getIsSticky: () => true,
1237
+ onDrag: ({ self, source }) => {
1238
+ const desired = extractInstruction(self.data);
1239
+ const block = desired && blockInstruction?.({
1240
+ instruction: desired,
1241
+ source: source.data,
1242
+ target: data
1243
+ });
1244
+ const instruction2 = block && desired.type !== "instruction-blocked" ? {
1245
+ type: "instruction-blocked",
1246
+ desired
1247
+ } : desired;
1248
+ if (source.data.id !== id) {
1249
+ if (instruction2?.type === "make-child" && isBranch && !open && !cancelExpandRef.current) {
1250
+ cancelExpandRef.current = setTimeout(() => {
1251
+ onOpenChange?.({
1252
+ item,
1253
+ path,
1254
+ open: true
1255
+ });
1256
+ }, 500);
610
1257
  }
611
- },
612
- onDragLeave: () => {
613
- cancelExpand();
614
- setInstruction(null);
615
- },
616
- onDrop: () => {
617
- cancelExpand();
1258
+ if (instruction2?.type !== "make-child") {
1259
+ cancelExpand();
1260
+ }
1261
+ setInstruction(instruction2);
1262
+ } else if (instruction2?.type === "reparent") {
1263
+ setInstruction(instruction2);
1264
+ } else {
618
1265
  setInstruction(null);
619
1266
  }
620
- })
621
- );
1267
+ },
1268
+ onDragLeave: () => {
1269
+ cancelExpand();
1270
+ setInstruction(null);
1271
+ },
1272
+ onDrop: () => {
1273
+ cancelExpand();
1274
+ setInstruction(null);
1275
+ }
1276
+ });
1277
+ if (!isItemDraggable) {
1278
+ return dropTarget;
1279
+ }
1280
+ return combine2(makeDraggable(), dropTarget);
622
1281
  }, [
623
- _draggable,
1282
+ draggableProp,
1283
+ isItemDraggable,
1284
+ isItemDroppable,
624
1285
  item,
625
1286
  id,
626
1287
  mode,
@@ -629,10 +1290,10 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
629
1290
  blockInstruction,
630
1291
  canDrop
631
1292
  ]);
632
- useEffect3(() => () => cancelExpand(), [
1293
+ useEffect4(() => () => cancelExpand(), [
633
1294
  cancelExpand
634
1295
  ]);
635
- const handleOpenToggle = useCallback3(() => onOpenChange?.({
1296
+ const handleOpenToggle = useCallback6(() => onOpenChange?.({
636
1297
  item,
637
1298
  path,
638
1299
  open: !open
@@ -642,7 +1303,7 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
642
1303
  path,
643
1304
  open
644
1305
  ]);
645
- const handleSelect = useCallback3((option = false) => {
1306
+ const handleSelect = useCallback6((option = false) => {
646
1307
  if (isBranch && (option || current)) {
647
1308
  handleOpenToggle();
648
1309
  } else if (canSelectItem) {
@@ -667,7 +1328,7 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
667
1328
  handleOpenToggle,
668
1329
  onSelect
669
1330
  ]);
670
- const handleKeyDown = useCallback3((event) => {
1331
+ const handleKeyDown = useCallback6((event) => {
671
1332
  switch (event.key) {
672
1333
  case "ArrowRight":
673
1334
  case "ArrowLeft":
@@ -680,44 +1341,56 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
680
1341
  handleOpenToggle,
681
1342
  handleSelect
682
1343
  ]);
683
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Treegrid.Row, {
1344
+ const handleItemHover = useCallback6(() => {
1345
+ onItemHover?.({
1346
+ item
1347
+ });
1348
+ }, [
1349
+ onItemHover,
1350
+ item
1351
+ ]);
1352
+ const handleContextMenu = useCallback6((event) => {
1353
+ event.preventDefault();
1354
+ setMenuOpen(true);
1355
+ }, [
1356
+ setMenuOpen
1357
+ ]);
1358
+ const childProps = {
1359
+ draggable: draggableProp,
1360
+ renderColumns: Columns,
1361
+ blockInstruction,
1362
+ canDrop,
1363
+ canSelect,
1364
+ onItemHover,
1365
+ onOpenChange,
1366
+ onSelect
1367
+ };
1368
+ return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Treegrid.Row, {
684
1369
  ref: rowRef,
685
1370
  key: id,
686
1371
  id,
687
1372
  "aria-labelledby": `${id}__label`,
688
- parentOf: parentOf?.join(Treegrid.PARENT_OF_SEPARATOR),
689
- classNames: [
690
- "grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-activeSurface",
691
- hoverableControls,
692
- hoverableFocusedKeyboardControls,
693
- hoverableFocusedWithinControls,
694
- hoverableDescriptionIcons,
695
- ghostHover,
696
- ghostFocusWithin,
697
- className
698
- ],
1373
+ parentOf: parentOf?.join(TREEGRID_PARENT_OF_SEPARATOR),
699
1374
  "data-object-id": id,
700
1375
  "data-testid": testId,
701
1376
  // NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
702
1377
  // without alerting the user (except for in the correct link element). See also:
703
1378
  // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current#description
704
1379
  "aria-current": current ? "" : void 0,
1380
+ classNames: mx7("grid grid-cols-subgrid col-[tree-row] mt-0.5 is-current:bg-active-surface", hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, hoverableDescriptionIcons, ghostFocusWithin, ghostHover, className),
705
1381
  onKeyDown: handleKeyDown,
706
- onContextMenu: (event) => {
707
- event.preventDefault();
708
- setMenuOpen(true);
709
- }
710
- }, /* @__PURE__ */ React7.createElement("div", {
711
- role: "none",
1382
+ onMouseEnter: handleItemHover,
1383
+ onContextMenu: handleContextMenu
1384
+ }, /* @__PURE__ */ React11.createElement("div", {
712
1385
  className: "indent relative grid grid-cols-subgrid col-[tree-row]",
713
1386
  style: paddingIndentation(level)
714
- }, /* @__PURE__ */ React7.createElement(Treegrid.Cell, {
1387
+ }, /* @__PURE__ */ React11.createElement(Treegrid.Cell, {
715
1388
  classNames: "flex items-center"
716
- }, /* @__PURE__ */ React7.createElement(TreeItemToggle, {
1389
+ }, /* @__PURE__ */ React11.createElement(TreeItemToggle, {
717
1390
  isBranch,
718
1391
  open,
719
1392
  onClick: handleOpenToggle
720
- }), /* @__PURE__ */ React7.createElement(TreeItemHeading, {
1393
+ }), /* @__PURE__ */ React11.createElement(TreeItemHeading, {
721
1394
  disabled,
722
1395
  current,
723
1396
  label,
@@ -726,46 +1399,41 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
726
1399
  iconHue,
727
1400
  onSelect: handleSelect,
728
1401
  ref: buttonRef
729
- })), Columns && /* @__PURE__ */ React7.createElement(Columns, {
1402
+ })), Columns && /* @__PURE__ */ React11.createElement(Columns, {
730
1403
  item,
731
1404
  path,
732
1405
  open,
733
1406
  menuOpen,
734
1407
  setMenuOpen
735
- }), instruction && /* @__PURE__ */ React7.createElement(NaturalTreeItem.DropIndicator, {
1408
+ }), instruction && /* @__PURE__ */ React11.createElement(NaturalTreeItem.DropIndicator, {
736
1409
  instruction,
737
1410
  gap: 2
738
- }))), open && items.map((item2, index) => /* @__PURE__ */ React7.createElement(TreeItem, {
739
- key: item2.id,
740
- item: item2,
1411
+ }))), open && childIds.map((childId, index) => /* @__PURE__ */ React11.createElement(TreeItemById, {
1412
+ key: childId,
1413
+ id: childId,
741
1414
  path,
742
- last: index === items.length - 1,
743
- draggable: _draggable,
744
- renderColumns: Columns,
745
- blockInstruction,
746
- canDrop,
747
- canSelect,
748
- onOpenChange,
749
- onSelect
1415
+ last: index === childIds.length - 1,
1416
+ ...childProps
750
1417
  })));
751
1418
  };
752
1419
  var TreeItem = /* @__PURE__ */ memo3(RawTreeItem);
1420
+ var RawTreeItemById = ({ id, ...props }) => {
1421
+ const { item: itemAtom } = useTree();
1422
+ const item = useAtomValue(itemAtom(id));
1423
+ if (!item) {
1424
+ return null;
1425
+ }
1426
+ return /* @__PURE__ */ React11.createElement(TreeItem, {
1427
+ item,
1428
+ ...props
1429
+ });
1430
+ };
1431
+ var TreeItemById = /* @__PURE__ */ memo3(RawTreeItemById);
753
1432
 
754
1433
  // src/components/Tree/Tree.tsx
755
- var Tree = ({ root, path, id, useItems, getProps, useIsOpen, useIsCurrent, draggable: draggable3 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, levelOffset, renderColumns, blockInstruction, canDrop, canSelect, onOpenChange, onSelect }) => {
756
- const context = useMemo2(() => ({
757
- useItems,
758
- getProps,
759
- useIsOpen,
760
- useIsCurrent
761
- }), [
762
- useItems,
763
- getProps,
764
- useIsOpen,
765
- useIsCurrent
766
- ]);
767
- const items = useItems(root);
768
- const treePath = useMemo2(() => path ? [
1434
+ var Tree = ({ model, rootId, path, id, draggable: draggable3 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, levelOffset, renderColumns, blockInstruction, canDrop, canSelect, onOpenChange, onSelect, onItemHover }) => {
1435
+ const childIds = useAtomValue2(model.childIds(rootId));
1436
+ const treePath = useMemo3(() => path ? [
769
1437
  ...path,
770
1438
  id
771
1439
  ] : [
@@ -774,15 +1442,7 @@ var Tree = ({ root, path, id, useItems, getProps, useIsOpen, useIsCurrent, dragg
774
1442
  id,
775
1443
  path
776
1444
  ]);
777
- return /* @__PURE__ */ React8.createElement(Treegrid2.Root, {
778
- gridTemplateColumns,
779
- classNames
780
- }, /* @__PURE__ */ React8.createElement(TreeProvider, {
781
- value: context
782
- }, items.map((item, index) => /* @__PURE__ */ React8.createElement(TreeItem, {
783
- key: item.id,
784
- item,
785
- last: index === items.length - 1,
1445
+ const childProps = {
786
1446
  path: treePath,
787
1447
  levelOffset,
788
1448
  draggable: draggable3,
@@ -791,7 +1451,19 @@ var Tree = ({ root, path, id, useItems, getProps, useIsOpen, useIsCurrent, dragg
791
1451
  canDrop,
792
1452
  canSelect,
793
1453
  onOpenChange,
794
- onSelect
1454
+ onSelect,
1455
+ onItemHover
1456
+ };
1457
+ return /* @__PURE__ */ React12.createElement(Treegrid2.Root, {
1458
+ gridTemplateColumns,
1459
+ classNames
1460
+ }, /* @__PURE__ */ React12.createElement(TreeProvider, {
1461
+ value: model
1462
+ }, childIds.map((childId, index) => /* @__PURE__ */ React12.createElement(TreeItemById, {
1463
+ key: childId,
1464
+ id: childId,
1465
+ last: index === childIds.length - 1,
1466
+ ...childProps
795
1467
  }))));
796
1468
  };
797
1469
 
@@ -812,13 +1484,27 @@ var Path = {
812
1484
  };
813
1485
  export {
814
1486
  Accordion,
1487
+ Combobox,
1488
+ DEFAULT_INDENTATION,
815
1489
  List,
1490
+ Listbox,
816
1491
  Path,
1492
+ Picker,
1493
+ Row,
1494
+ RowList,
817
1495
  Tree,
818
1496
  TreeDataSchema,
819
1497
  TreeItem,
1498
+ TreeItemById,
1499
+ TreeItemToggle,
820
1500
  TreeProvider,
1501
+ createListboxScope,
1502
+ createRowListScope,
821
1503
  isTreeData,
1504
+ paddingIndentation,
1505
+ usePickerInputContext,
1506
+ usePickerItemContext,
1507
+ useRowListSelection,
822
1508
  useTree
823
1509
  };
824
1510
  //# sourceMappingURL=index.mjs.map