@dxos/react-ui-list 0.8.1-main.ba2dec9 → 0.8.1-staging.31c3ee1
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 +148 -71
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +177 -107
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +148 -71
- 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 +7 -0
- package/dist/types/src/components/Accordion/Accordion.d.ts.map +1 -0
- package/dist/types/src/components/Accordion/Accordion.stories.d.ts +8 -0
- package/dist/types/src/components/Accordion/Accordion.stories.d.ts.map +1 -0
- package/dist/types/src/components/Accordion/AccordionItem.d.ts +20 -0
- package/dist/types/src/components/Accordion/AccordionItem.d.ts.map +1 -0
- package/dist/types/src/components/Accordion/AccordionRoot.d.ts +20 -0
- package/dist/types/src/components/Accordion/AccordionRoot.d.ts.map +1 -0
- package/dist/types/src/components/Accordion/index.d.ts +2 -0
- package/dist/types/src/components/Accordion/index.d.ts.map +1 -0
- package/dist/types/src/components/List/List.d.ts +2 -2
- 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 +2 -2
- package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
- package/dist/types/src/components/List/ListRoot.d.ts +9 -10
- package/dist/types/src/components/List/ListRoot.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/components/Accordion/Accordion.stories.tsx +56 -0
- package/src/components/Accordion/Accordion.tsx +17 -0
- package/src/components/Accordion/AccordionItem.tsx +65 -0
- package/src/components/Accordion/AccordionRoot.tsx +58 -0
- package/src/components/Accordion/index.ts +5 -0
- package/src/components/List/List.stories.tsx +7 -7
- package/src/components/List/List.tsx +1 -1
- package/src/components/List/ListItem.tsx +4 -4
- package/src/components/List/ListRoot.tsx +10 -13
- package/src/components/Tree/TreeItem.tsx +8 -4
- package/src/components/Tree/TreeItemHeading.tsx +1 -1
- package/src/components/Tree/TreeItemToggle.tsx +1 -1
- package/src/components/index.ts +1 -0
|
@@ -1,25 +1,95 @@
|
|
|
1
|
+
// packages/ui/react-ui-list/src/components/Accordion/AccordionItem.tsx
|
|
2
|
+
import * as AccordionPrimitive2 from "@radix-ui/react-accordion";
|
|
3
|
+
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
4
|
+
import React2 from "react";
|
|
5
|
+
import { Icon } from "@dxos/react-ui";
|
|
6
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
7
|
+
|
|
8
|
+
// packages/ui/react-ui-list/src/components/Accordion/AccordionRoot.tsx
|
|
9
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
10
|
+
import { createContext } from "@radix-ui/react-context";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
13
|
+
var ACCORDION_NAME = "Accordion";
|
|
14
|
+
var [AccordionProvider, useAccordionContext] = createContext(ACCORDION_NAME);
|
|
15
|
+
var defaultGetId = (item) => item?.id;
|
|
16
|
+
var AccordionRoot = ({ classNames, items, getId = defaultGetId, children, value, defaultValue, onValueChange }) => {
|
|
17
|
+
return /* @__PURE__ */ React.createElement(AccordionProvider, {
|
|
18
|
+
getId
|
|
19
|
+
}, /* @__PURE__ */ React.createElement(AccordionPrimitive.Root, {
|
|
20
|
+
type: "multiple",
|
|
21
|
+
value,
|
|
22
|
+
defaultValue,
|
|
23
|
+
onValueChange,
|
|
24
|
+
className: mx(classNames)
|
|
25
|
+
}, children?.({
|
|
26
|
+
items: items ?? []
|
|
27
|
+
})));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// packages/ui/react-ui-list/src/components/Accordion/AccordionItem.tsx
|
|
31
|
+
var ACCORDION_ITEM_NAME = "AccordionItem";
|
|
32
|
+
var [AccordionItemProvider, useAccordionItemContext] = createContext2(ACCORDION_ITEM_NAME);
|
|
33
|
+
var AccordionItem = ({ children, classNames, item }) => {
|
|
34
|
+
const { getId } = useAccordionContext(ACCORDION_ITEM_NAME);
|
|
35
|
+
return /* @__PURE__ */ React2.createElement(AccordionItemProvider, {
|
|
36
|
+
item
|
|
37
|
+
}, /* @__PURE__ */ React2.createElement(AccordionPrimitive2.Item, {
|
|
38
|
+
value: getId(item),
|
|
39
|
+
className: mx2("overflow-hidden", classNames)
|
|
40
|
+
}, children));
|
|
41
|
+
};
|
|
42
|
+
var AccordionItemHeader = ({ classNames, children, ...props }) => {
|
|
43
|
+
return /* @__PURE__ */ React2.createElement(AccordionPrimitive2.Header, {
|
|
44
|
+
...props,
|
|
45
|
+
className: mx2(classNames)
|
|
46
|
+
}, /* @__PURE__ */ React2.createElement(AccordionPrimitive2.Trigger, {
|
|
47
|
+
className: "group flex items-center p-2 dx-focus-ring-inset is-full text-start"
|
|
48
|
+
}, children, /* @__PURE__ */ React2.createElement(Icon, {
|
|
49
|
+
icon: "ph--caret-right--regular",
|
|
50
|
+
size: 4,
|
|
51
|
+
classNames: "transition-transform duration-200 group-data-[state=open]:rotate-90"
|
|
52
|
+
})));
|
|
53
|
+
};
|
|
54
|
+
var AccordionItemBody = ({ children, classNames }) => {
|
|
55
|
+
return /* @__PURE__ */ React2.createElement(AccordionPrimitive2.Content, {
|
|
56
|
+
className: "overflow-hidden data-[state=closed]:animate-slideUp data-[state=open]:animate-slideDown"
|
|
57
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
58
|
+
role: "none",
|
|
59
|
+
className: mx2("p-2", classNames)
|
|
60
|
+
}, children));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// packages/ui/react-ui-list/src/components/Accordion/Accordion.tsx
|
|
64
|
+
var Accordion = {
|
|
65
|
+
Root: AccordionRoot,
|
|
66
|
+
Item: AccordionItem,
|
|
67
|
+
ItemHeader: AccordionItemHeader,
|
|
68
|
+
ItemBody: AccordionItemBody
|
|
69
|
+
};
|
|
70
|
+
|
|
1
71
|
// packages/ui/react-ui-list/src/components/List/ListItem.tsx
|
|
2
72
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
3
73
|
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
4
74
|
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
5
75
|
import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
6
|
-
import { createContext as
|
|
7
|
-
import
|
|
76
|
+
import { createContext as createContext4 } from "@radix-ui/react-context";
|
|
77
|
+
import React4, { forwardRef, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
8
78
|
import { createPortal } from "react-dom";
|
|
9
79
|
import { invariant } from "@dxos/invariant";
|
|
10
|
-
import { Icon, ListItem as NaturalListItem } from "@dxos/react-ui";
|
|
11
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
80
|
+
import { Icon as Icon2, ListItem as NaturalListItem } from "@dxos/react-ui";
|
|
81
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
12
82
|
|
|
13
83
|
// packages/ui/react-ui-list/src/components/List/ListRoot.tsx
|
|
14
84
|
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
15
85
|
import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
16
86
|
import { getReorderDestinationIndex } from "@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index";
|
|
17
|
-
import { createContext } from "@radix-ui/react-context";
|
|
18
|
-
import
|
|
87
|
+
import { createContext as createContext3 } from "@radix-ui/react-context";
|
|
88
|
+
import React3, { useCallback, useEffect, useState } from "react";
|
|
19
89
|
var LIST_NAME = "List";
|
|
20
|
-
var [ListProvider, useListContext] =
|
|
21
|
-
var
|
|
22
|
-
var ListRoot = ({
|
|
90
|
+
var [ListProvider, useListContext] = createContext3(LIST_NAME);
|
|
91
|
+
var defaultGetId2 = (item) => item?.id;
|
|
92
|
+
var ListRoot = ({ children, items, isItem, getId = defaultGetId2, onMove, ...props }) => {
|
|
23
93
|
const isEqual = useCallback((a, b) => {
|
|
24
94
|
const idA = getId?.(a);
|
|
25
95
|
const idB = getId?.(b);
|
|
@@ -68,10 +138,10 @@ var ListRoot = ({ classNames, children, items, isItem, getId = defaultGetId, onM
|
|
|
68
138
|
isEqual,
|
|
69
139
|
onMove
|
|
70
140
|
]);
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
isItem,
|
|
141
|
+
return /* @__PURE__ */ React3.createElement(ListProvider, {
|
|
73
142
|
state,
|
|
74
143
|
setState,
|
|
144
|
+
isItem,
|
|
75
145
|
...props
|
|
76
146
|
}, children?.({
|
|
77
147
|
state,
|
|
@@ -89,7 +159,7 @@ var stateStyles = {
|
|
|
89
159
|
};
|
|
90
160
|
var defaultContext = {};
|
|
91
161
|
var LIST_ITEM_NAME = "ListItem";
|
|
92
|
-
var [ListItemProvider, useListItemContext] =
|
|
162
|
+
var [ListItemProvider, useListItemContext] = createContext4(LIST_ITEM_NAME, defaultContext);
|
|
93
163
|
var ListItem = ({ children, classNames, item, ...props }) => {
|
|
94
164
|
const { isItem, dragPreview, setState: setRootState } = useListContext(LIST_ITEM_NAME);
|
|
95
165
|
const ref = useRef(null);
|
|
@@ -204,27 +274,27 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
204
274
|
}, [
|
|
205
275
|
item
|
|
206
276
|
]);
|
|
207
|
-
return /* @__PURE__ */
|
|
277
|
+
return /* @__PURE__ */ React4.createElement(ListItemProvider, {
|
|
208
278
|
item,
|
|
209
279
|
dragHandleRef
|
|
210
|
-
}, /* @__PURE__ */
|
|
280
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
211
281
|
role: "none",
|
|
212
282
|
className: "relative"
|
|
213
|
-
}, /* @__PURE__ */
|
|
283
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
214
284
|
ref,
|
|
215
285
|
role: "listitem",
|
|
216
|
-
className:
|
|
286
|
+
className: mx3("flex overflow-hidden", classNames, stateStyles[state.type]),
|
|
217
287
|
...props
|
|
218
|
-
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */
|
|
288
|
+
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React4.createElement(NaturalListItem.DropIndicator, {
|
|
219
289
|
edge: state.closestEdge
|
|
220
290
|
})));
|
|
221
291
|
};
|
|
222
292
|
var IconButton = /* @__PURE__ */ forwardRef(({ classNames, icon, ...props }, forwardedRef) => {
|
|
223
|
-
return /* @__PURE__ */
|
|
293
|
+
return /* @__PURE__ */ React4.createElement("button", {
|
|
224
294
|
ref: forwardedRef,
|
|
225
|
-
className:
|
|
295
|
+
className: mx3("flex items-center justify-center", classNames),
|
|
226
296
|
...props
|
|
227
|
-
}, /* @__PURE__ */
|
|
297
|
+
}, /* @__PURE__ */ React4.createElement(Icon2, {
|
|
228
298
|
icon,
|
|
229
299
|
classNames: "cursor-pointer",
|
|
230
300
|
size: 4
|
|
@@ -233,7 +303,7 @@ var IconButton = /* @__PURE__ */ forwardRef(({ classNames, icon, ...props }, for
|
|
|
233
303
|
var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", ...props }) => {
|
|
234
304
|
const { state } = useListContext("DELETE_BUTTON");
|
|
235
305
|
const isDisabled = state.type !== "idle" || disabled;
|
|
236
|
-
return /* @__PURE__ */
|
|
306
|
+
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
237
307
|
icon,
|
|
238
308
|
disabled: isDisabled,
|
|
239
309
|
classNames: [
|
|
@@ -246,7 +316,7 @@ var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph-
|
|
|
246
316
|
var ListItemButton = ({ autoHide = true, classNames, disabled, ...props }) => {
|
|
247
317
|
const { state } = useListContext("ITEM_BUTTON");
|
|
248
318
|
const isDisabled = state.type !== "idle" || disabled;
|
|
249
|
-
return /* @__PURE__ */
|
|
319
|
+
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
250
320
|
disabled: isDisabled,
|
|
251
321
|
classNames: [
|
|
252
322
|
classNames,
|
|
@@ -257,7 +327,7 @@ var ListItemButton = ({ autoHide = true, classNames, disabled, ...props }) => {
|
|
|
257
327
|
};
|
|
258
328
|
var ListItemDragHandle = () => {
|
|
259
329
|
const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
|
|
260
|
-
return /* @__PURE__ */
|
|
330
|
+
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
261
331
|
ref: dragHandleRef,
|
|
262
332
|
icon: "ph--dots-six-vertical--regular"
|
|
263
333
|
});
|
|
@@ -268,11 +338,11 @@ var ListItemDragPreview = ({ children }) => {
|
|
|
268
338
|
item: state.item
|
|
269
339
|
}), state.container) : null;
|
|
270
340
|
};
|
|
271
|
-
var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */
|
|
272
|
-
className:
|
|
341
|
+
var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */ React4.createElement("div", {
|
|
342
|
+
className: mx3("flex is-full gap-2", classNames)
|
|
273
343
|
}, children);
|
|
274
|
-
var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */
|
|
275
|
-
className:
|
|
344
|
+
var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */ React4.createElement("div", {
|
|
345
|
+
className: mx3("flex grow items-center truncate", classNames),
|
|
276
346
|
...props
|
|
277
347
|
}, children);
|
|
278
348
|
|
|
@@ -290,13 +360,13 @@ var List = {
|
|
|
290
360
|
};
|
|
291
361
|
|
|
292
362
|
// packages/ui/react-ui-list/src/components/Tree/Tree.tsx
|
|
293
|
-
import
|
|
363
|
+
import React8, { useMemo as useMemo2 } from "react";
|
|
294
364
|
import { Treegrid as Treegrid2 } from "@dxos/react-ui";
|
|
295
365
|
|
|
296
366
|
// packages/ui/react-ui-list/src/components/Tree/TreeContext.tsx
|
|
297
|
-
import { createContext as
|
|
367
|
+
import { createContext as createContext5, useContext } from "react";
|
|
298
368
|
import { raise } from "@dxos/debug";
|
|
299
|
-
var TreeContext = /* @__PURE__ */
|
|
369
|
+
var TreeContext = /* @__PURE__ */ createContext5(null);
|
|
300
370
|
var useTree = () => useContext(TreeContext) ?? raise(new Error("TreeContext not found"));
|
|
301
371
|
var TreeProvider = TreeContext.Provider;
|
|
302
372
|
|
|
@@ -304,17 +374,17 @@ var TreeProvider = TreeContext.Provider;
|
|
|
304
374
|
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
305
375
|
import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
306
376
|
import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
307
|
-
import
|
|
377
|
+
import React7, { memo as memo3, useCallback as useCallback3, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
|
|
308
378
|
import { S } from "@dxos/echo-schema";
|
|
309
379
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
310
380
|
import { Treegrid, TreeItem as NaturalTreeItem } from "@dxos/react-ui";
|
|
311
|
-
import { ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, mx as
|
|
381
|
+
import { ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, mx as mx6 } from "@dxos/react-ui-theme";
|
|
312
382
|
|
|
313
383
|
// packages/ui/react-ui-list/src/components/Tree/TreeItemHeading.tsx
|
|
314
|
-
import
|
|
315
|
-
import { Button, Icon as
|
|
384
|
+
import React5, { forwardRef as forwardRef2, memo, useCallback as useCallback2 } from "react";
|
|
385
|
+
import { Button, Icon as Icon3, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
316
386
|
import { TextTooltip } from "@dxos/react-ui-text-tooltip";
|
|
317
|
-
import { mx as
|
|
387
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
318
388
|
var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label, icon, className, disabled, current, onSelect }, forwardedRef) => {
|
|
319
389
|
const { t } = useTranslation();
|
|
320
390
|
const handleSelect = useCallback2((event) => {
|
|
@@ -331,51 +401,51 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label,
|
|
|
331
401
|
}, [
|
|
332
402
|
onSelect
|
|
333
403
|
]);
|
|
334
|
-
return /* @__PURE__ */
|
|
404
|
+
return /* @__PURE__ */ React5.createElement(TextTooltip, {
|
|
335
405
|
text: toLocalizedString(label, t),
|
|
336
406
|
side: "bottom",
|
|
337
407
|
truncateQuery: "span[data-tooltip]",
|
|
338
408
|
onlyWhenTruncating: true,
|
|
339
409
|
asChild: true,
|
|
340
410
|
ref: forwardedRef
|
|
341
|
-
}, /* @__PURE__ */
|
|
411
|
+
}, /* @__PURE__ */ React5.createElement(Button, {
|
|
342
412
|
"data-testid": "treeItem.heading",
|
|
343
413
|
variant: "ghost",
|
|
344
414
|
density: "fine",
|
|
345
|
-
classNames:
|
|
415
|
+
classNames: mx4("grow gap-2 pis-0.5 hover:bg-transparent dark:hover:bg-transparent", "disabled:cursor-default disabled:opacity-100", className),
|
|
346
416
|
disabled,
|
|
347
417
|
onClick: handleSelect,
|
|
348
418
|
onKeyDown: handleButtonKeydown,
|
|
349
419
|
...current && {
|
|
350
420
|
"aria-current": "location"
|
|
351
421
|
}
|
|
352
|
-
}, icon && /* @__PURE__ */
|
|
422
|
+
}, icon && /* @__PURE__ */ React5.createElement(Icon3, {
|
|
353
423
|
icon: icon ?? "ph--placeholder--regular",
|
|
354
|
-
size:
|
|
355
|
-
classNames: "
|
|
356
|
-
}), /* @__PURE__ */
|
|
424
|
+
size: 5,
|
|
425
|
+
classNames: "mlb-1"
|
|
426
|
+
}), /* @__PURE__ */ React5.createElement("span", {
|
|
357
427
|
className: "flex-1 is-0 truncate text-start text-sm font-normal",
|
|
358
428
|
"data-tooltip": true
|
|
359
429
|
}, toLocalizedString(label, t))));
|
|
360
430
|
}));
|
|
361
431
|
|
|
362
432
|
// packages/ui/react-ui-list/src/components/Tree/TreeItemToggle.tsx
|
|
363
|
-
import
|
|
364
|
-
import { Button as Button2, Icon as
|
|
365
|
-
import { mx as
|
|
433
|
+
import React6, { forwardRef as forwardRef3, memo as memo2 } from "react";
|
|
434
|
+
import { Button as Button2, Icon as Icon4 } from "@dxos/react-ui";
|
|
435
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
366
436
|
var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef3(({ open, isBranch, hidden, onToggle }, forwardedRef) => {
|
|
367
|
-
return /* @__PURE__ */
|
|
437
|
+
return /* @__PURE__ */ React6.createElement(Button2, {
|
|
368
438
|
ref: forwardedRef,
|
|
369
439
|
"data-testid": "treeItem.toggle",
|
|
370
440
|
"aria-expanded": open,
|
|
371
441
|
variant: "ghost",
|
|
372
442
|
density: "fine",
|
|
373
|
-
classNames:
|
|
443
|
+
classNames: mx5("is-6 pli-0 dx-focus-ring-inset", hidden ? "hidden" : !isBranch && "invisible"),
|
|
374
444
|
onClick: onToggle
|
|
375
|
-
}, /* @__PURE__ */
|
|
445
|
+
}, /* @__PURE__ */ React6.createElement(Icon4, {
|
|
376
446
|
icon: "ph--caret-right--regular",
|
|
377
447
|
size: 3,
|
|
378
|
-
classNames:
|
|
448
|
+
classNames: mx5("transition duration-200", open && "rotate-90")
|
|
379
449
|
}));
|
|
380
450
|
}));
|
|
381
451
|
|
|
@@ -546,18 +616,24 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
546
616
|
open
|
|
547
617
|
]);
|
|
548
618
|
const handleSelect = useCallback3((option = false) => {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
619
|
+
if (isBranch) {
|
|
620
|
+
handleOpenChange();
|
|
621
|
+
} else {
|
|
622
|
+
rowRef.current?.focus();
|
|
623
|
+
onSelect?.({
|
|
624
|
+
item,
|
|
625
|
+
path,
|
|
626
|
+
current: !current,
|
|
627
|
+
option
|
|
628
|
+
});
|
|
629
|
+
}
|
|
556
630
|
}, [
|
|
557
|
-
onSelect,
|
|
558
631
|
item,
|
|
559
632
|
path,
|
|
560
|
-
current
|
|
633
|
+
current,
|
|
634
|
+
isBranch,
|
|
635
|
+
handleOpenChange,
|
|
636
|
+
onSelect
|
|
561
637
|
]);
|
|
562
638
|
const handleKeyDown = useCallback3((event) => {
|
|
563
639
|
switch (event.key) {
|
|
@@ -577,13 +653,13 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
577
653
|
handleOpenChange,
|
|
578
654
|
handleSelect
|
|
579
655
|
]);
|
|
580
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Treegrid.Row, {
|
|
581
657
|
ref: rowRef,
|
|
582
658
|
key: id,
|
|
583
659
|
id,
|
|
584
660
|
"aria-labelledby": `${id}__label`,
|
|
585
661
|
parentOf: parentOf?.join(Treegrid.PARENT_OF_SEPARATOR),
|
|
586
|
-
classNames:
|
|
662
|
+
classNames: mx6("grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-groupSurface", hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, hoverableDescriptionIcons, ghostHover, className),
|
|
587
663
|
"data-itemid": id,
|
|
588
664
|
"data-testid": testId,
|
|
589
665
|
// NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
|
|
@@ -595,18 +671,18 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
595
671
|
event.preventDefault();
|
|
596
672
|
setMenuOpen(true);
|
|
597
673
|
}
|
|
598
|
-
}, /* @__PURE__ */
|
|
674
|
+
}, /* @__PURE__ */ React7.createElement(Treegrid.Cell, {
|
|
599
675
|
indent: true,
|
|
600
676
|
classNames: "relative grid grid-cols-subgrid col-[tree-row]",
|
|
601
677
|
style: paddingIndentation(level)
|
|
602
|
-
}, /* @__PURE__ */
|
|
678
|
+
}, /* @__PURE__ */ React7.createElement("div", {
|
|
603
679
|
role: "none",
|
|
604
680
|
className: "flex items-center"
|
|
605
|
-
}, /* @__PURE__ */
|
|
606
|
-
open,
|
|
681
|
+
}, /* @__PURE__ */ React7.createElement(TreeItemToggle, {
|
|
607
682
|
isBranch,
|
|
683
|
+
open,
|
|
608
684
|
onToggle: handleOpenChange
|
|
609
|
-
}), /* @__PURE__ */
|
|
685
|
+
}), /* @__PURE__ */ React7.createElement(TreeItemHeading, {
|
|
610
686
|
ref: buttonRef,
|
|
611
687
|
label,
|
|
612
688
|
icon,
|
|
@@ -614,16 +690,16 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
614
690
|
disabled,
|
|
615
691
|
current,
|
|
616
692
|
onSelect: handleSelect
|
|
617
|
-
})), Columns && /* @__PURE__ */
|
|
693
|
+
})), Columns && /* @__PURE__ */ React7.createElement(Columns, {
|
|
618
694
|
item,
|
|
619
695
|
path,
|
|
620
696
|
open,
|
|
621
697
|
menuOpen,
|
|
622
698
|
setMenuOpen
|
|
623
|
-
}), instruction && /* @__PURE__ */
|
|
699
|
+
}), instruction && /* @__PURE__ */ React7.createElement(NaturalTreeItem.DropIndicator, {
|
|
624
700
|
instruction,
|
|
625
701
|
gap: 2
|
|
626
|
-
}))), open && items.map((item2, index) => /* @__PURE__ */
|
|
702
|
+
}))), open && items.map((item2, index) => /* @__PURE__ */ React7.createElement(TreeItem, {
|
|
627
703
|
key: item2.id,
|
|
628
704
|
item: item2,
|
|
629
705
|
path,
|
|
@@ -660,12 +736,12 @@ var Tree = ({ root, path, id, getItems, getProps, isOpen, isCurrent, draggable:
|
|
|
660
736
|
id,
|
|
661
737
|
path
|
|
662
738
|
]);
|
|
663
|
-
return /* @__PURE__ */
|
|
739
|
+
return /* @__PURE__ */ React8.createElement(Treegrid2.Root, {
|
|
664
740
|
gridTemplateColumns,
|
|
665
741
|
classNames
|
|
666
|
-
}, /* @__PURE__ */
|
|
742
|
+
}, /* @__PURE__ */ React8.createElement(TreeProvider, {
|
|
667
743
|
value: context
|
|
668
|
-
}, items.map((item, index) => /* @__PURE__ */
|
|
744
|
+
}, items.map((item, index) => /* @__PURE__ */ React8.createElement(TreeItem, {
|
|
669
745
|
key: item.id,
|
|
670
746
|
item,
|
|
671
747
|
last: index === items.length - 1,
|
|
@@ -695,6 +771,7 @@ var Path = {
|
|
|
695
771
|
onPath: (path, id) => Path.parts(path).includes(id)
|
|
696
772
|
};
|
|
697
773
|
export {
|
|
774
|
+
Accordion,
|
|
698
775
|
List,
|
|
699
776
|
Path,
|
|
700
777
|
RawTreeItem,
|