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