@dxos/react-ui-list 0.8.3 → 0.8.4-main.28f8d3d

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 (38) hide show
  1. package/dist/lib/browser/index.mjs +82 -76
  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 +82 -76
  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.stories.d.ts +1 -1
  8. package/dist/types/src/components/Accordion/Accordion.stories.d.ts.map +1 -1
  9. package/dist/types/src/components/Accordion/AccordionItem.d.ts.map +1 -1
  10. package/dist/types/src/components/List/List.d.ts +6 -6
  11. package/dist/types/src/components/List/List.d.ts.map +1 -1
  12. package/dist/types/src/components/List/List.stories.d.ts +1 -1
  13. package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
  14. package/dist/types/src/components/List/ListItem.d.ts +5 -8
  15. package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
  16. package/dist/types/src/components/List/ListRoot.d.ts.map +1 -1
  17. package/dist/types/src/components/Tree/Tree.stories.d.ts +2 -2
  18. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/Tree/TreeItem.d.ts +8 -7
  20. package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
  21. package/dist/types/src/components/Tree/TreeItemHeading.d.ts.map +1 -1
  22. package/dist/types/src/components/Tree/TreeItemToggle.d.ts.map +1 -1
  23. package/dist/types/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +18 -19
  25. package/src/components/Accordion/Accordion.stories.tsx +1 -1
  26. package/src/components/Accordion/Accordion.tsx +1 -1
  27. package/src/components/Accordion/AccordionItem.tsx +2 -1
  28. package/src/components/List/List.stories.tsx +2 -2
  29. package/src/components/List/List.tsx +2 -5
  30. package/src/components/List/ListItem.tsx +53 -34
  31. package/src/components/List/ListRoot.tsx +1 -1
  32. package/src/components/Tree/Tree.stories.tsx +6 -5
  33. package/src/components/Tree/TreeItem.tsx +16 -16
  34. package/src/components/Tree/TreeItemHeading.tsx +3 -4
  35. package/src/components/Tree/TreeItemToggle.tsx +2 -3
  36. package/dist/lib/node/index.cjs +0 -886
  37. package/dist/lib/node/index.cjs.map +0 -7
  38. package/dist/lib/node/meta.json +0 -1
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
- // packages/ui/react-ui-list/src/components/Accordion/AccordionItem.tsx
3
+ // src/components/Accordion/AccordionItem.tsx
4
4
  import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
5
5
  import * as AccordionPrimitive2 from "@radix-ui/react-accordion";
6
6
  import { createContext as createContext2 } from "@radix-ui/react-context";
@@ -8,7 +8,7 @@ import React2 from "react";
8
8
  import { Icon } from "@dxos/react-ui";
9
9
  import { mx as mx2 } from "@dxos/react-ui-theme";
10
10
 
11
- // packages/ui/react-ui-list/src/components/Accordion/AccordionRoot.tsx
11
+ // src/components/Accordion/AccordionRoot.tsx
12
12
  import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
13
13
  import * as AccordionPrimitive from "@radix-ui/react-accordion";
14
14
  import { createContext } from "@radix-ui/react-context";
@@ -36,7 +36,7 @@ var AccordionRoot = ({ classNames, items, getId = defaultGetId, children, value,
36
36
  }
37
37
  };
38
38
 
39
- // packages/ui/react-ui-list/src/components/Accordion/AccordionItem.tsx
39
+ // src/components/Accordion/AccordionItem.tsx
40
40
  var ACCORDION_ITEM_NAME = "AccordionItem";
41
41
  var [AccordionItemProvider, useAccordionItemContext] = createContext2(ACCORDION_ITEM_NAME);
42
42
  var AccordionItem = ({ children, classNames, item }) => {
@@ -84,7 +84,7 @@ var AccordionItemBody = ({ children, classNames }) => {
84
84
  }
85
85
  };
86
86
 
87
- // packages/ui/react-ui-list/src/components/Accordion/Accordion.tsx
87
+ // src/components/Accordion/Accordion.tsx
88
88
  var Accordion = {
89
89
  Root: AccordionRoot,
90
90
  Item: AccordionItem,
@@ -92,20 +92,20 @@ var Accordion = {
92
92
  ItemBody: AccordionItemBody
93
93
  };
94
94
 
95
- // packages/ui/react-ui-list/src/components/List/ListItem.tsx
95
+ // src/components/List/ListItem.tsx
96
96
  import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
97
97
  import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
98
98
  import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
99
99
  import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
100
100
  import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
101
101
  import { createContext as createContext4 } from "@radix-ui/react-context";
102
- import React4, { forwardRef, useEffect as useEffect2, useRef, useState as useState2 } from "react";
102
+ import React4, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
103
103
  import { createPortal } from "react-dom";
104
104
  import { invariant } from "@dxos/invariant";
105
- import { Icon as Icon2, ListItem as NaturalListItem } from "@dxos/react-ui";
105
+ import { IconButton, ListItem as NaturalListItem, useTranslation } from "@dxos/react-ui";
106
106
  import { mx as mx3 } from "@dxos/react-ui-theme";
107
107
 
108
- // packages/ui/react-ui-list/src/components/List/ListRoot.tsx
108
+ // src/components/List/ListRoot.tsx
109
109
  import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
110
110
  import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
111
111
  import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
@@ -180,8 +180,8 @@ var ListRoot = ({ children, items, isItem, getId = defaultGetId2, onMove, ...pro
180
180
  }
181
181
  };
182
182
 
183
- // packages/ui/react-ui-list/src/components/List/ListItem.tsx
184
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-list/src/components/List/ListItem.tsx";
183
+ // src/components/List/ListItem.tsx
184
+ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-list/src/components/List/ListItem.tsx";
185
185
  var idle = {
186
186
  type: "idle"
187
187
  };
@@ -202,7 +202,7 @@ var ListItem = ({ children, classNames, item, ...props }) => {
202
202
  const element = ref.current;
203
203
  invariant(element, void 0, {
204
204
  F: __dxlog_file,
205
- L: 91,
205
+ L: 98,
206
206
  S: void 0,
207
207
  A: [
208
208
  "element",
@@ -285,6 +285,9 @@ var ListItem = ({ children, classNames, item, ...props }) => {
285
285
  closestEdge
286
286
  });
287
287
  },
288
+ onDragLeave: () => {
289
+ setState(idle);
290
+ },
288
291
  onDrag: ({ self }) => {
289
292
  const closestEdge = extractClosestEdge2(self.data);
290
293
  setState((current) => {
@@ -297,9 +300,6 @@ var ListItem = ({ children, classNames, item, ...props }) => {
297
300
  };
298
301
  });
299
302
  },
300
- onDragLeave: () => {
301
- setState(idle);
302
- },
303
303
  onDrop: () => {
304
304
  setState(idle);
305
305
  }
@@ -311,67 +311,54 @@ var ListItem = ({ children, classNames, item, ...props }) => {
311
311
  return /* @__PURE__ */ React4.createElement(ListItemProvider, {
312
312
  item,
313
313
  dragHandleRef
314
- }, /* @__PURE__ */ React4.createElement("div", {
315
- role: "none",
316
- className: "relative"
317
314
  }, /* @__PURE__ */ React4.createElement("div", {
318
315
  ref,
319
316
  role: "listitem",
320
- className: mx3("flex overflow-hidden", classNames, stateStyles[state.type]),
317
+ className: mx3("flex overflow-hidden relative", classNames, stateStyles[state.type]),
321
318
  ...props
322
- }, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React4.createElement(NaturalListItem.DropIndicator, {
319
+ }, children, state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React4.createElement(NaturalListItem.DropIndicator, {
323
320
  edge: state.closestEdge
324
321
  })));
325
322
  } finally {
326
323
  _effect.f();
327
324
  }
328
325
  };
329
- var IconButton = /* @__PURE__ */ forwardRef(({ classNames, icon, ...props }, forwardedRef) => {
330
- var _effect = _useSignals4();
331
- try {
332
- return /* @__PURE__ */ React4.createElement("button", {
333
- ref: forwardedRef,
334
- className: mx3("flex items-center justify-center", classNames),
335
- ...props
336
- }, /* @__PURE__ */ React4.createElement(Icon2, {
337
- icon,
338
- classNames: "cursor-pointer",
339
- size: 4
340
- }));
341
- } finally {
342
- _effect.f();
343
- }
344
- });
345
- var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", ...props }) => {
326
+ var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", label, ...props }) => {
346
327
  var _effect = _useSignals4();
347
328
  try {
348
329
  const { state } = useListContext("DELETE_BUTTON");
349
330
  const isDisabled = state.type !== "idle" || disabled;
331
+ const { t } = useTranslation("os");
350
332
  return /* @__PURE__ */ React4.createElement(IconButton, {
333
+ iconOnly: true,
334
+ variant: "ghost",
335
+ ...props,
351
336
  icon,
352
337
  disabled: isDisabled,
338
+ label: label ?? t("delete label"),
353
339
  classNames: [
354
340
  classNames,
355
341
  autoHide && disabled && "hidden"
356
- ],
357
- ...props
342
+ ]
358
343
  });
359
344
  } finally {
360
345
  _effect.f();
361
346
  }
362
347
  };
363
- var ListItemButton = ({ autoHide = true, classNames, disabled, ...props }) => {
348
+ var ListItemButton = ({ autoHide = true, iconOnly = true, variant = "ghost", classNames, disabled, ...props }) => {
364
349
  var _effect = _useSignals4();
365
350
  try {
366
351
  const { state } = useListContext("ITEM_BUTTON");
367
352
  const isDisabled = state.type !== "idle" || disabled;
368
353
  return /* @__PURE__ */ React4.createElement(IconButton, {
354
+ ...props,
369
355
  disabled: isDisabled,
356
+ iconOnly,
357
+ variant,
370
358
  classNames: [
371
359
  classNames,
372
360
  autoHide && disabled && "hidden"
373
- ],
374
- ...props
361
+ ]
375
362
  });
376
363
  } finally {
377
364
  _effect.f();
@@ -381,7 +368,11 @@ var ListItemDragHandle = ({ disabled }) => {
381
368
  var _effect = _useSignals4();
382
369
  try {
383
370
  const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
371
+ const { t } = useTranslation("os");
384
372
  return /* @__PURE__ */ React4.createElement(IconButton, {
373
+ iconOnly: true,
374
+ variant: "ghost",
375
+ label: t("drag handle label"),
385
376
  ref: dragHandleRef,
386
377
  icon: "ph--dots-six-vertical--regular",
387
378
  disabled
@@ -418,7 +409,7 @@ var ListItemTitle = ({ classNames, children, ...props }) => {
418
409
  }
419
410
  };
420
411
 
421
- // packages/ui/react-ui-list/src/components/List/List.tsx
412
+ // src/components/List/List.tsx
422
413
  var List = {
423
414
  Root: ListRoot,
424
415
  Item: ListItem,
@@ -427,23 +418,22 @@ var List = {
427
418
  ItemDragHandle: ListItemDragHandle,
428
419
  ItemDeleteButton: ListItemDeleteButton,
429
420
  ItemButton: ListItemButton,
430
- ItemTitle: ListItemTitle,
431
- IconButton
421
+ ItemTitle: ListItemTitle
432
422
  };
433
423
 
434
- // packages/ui/react-ui-list/src/components/Tree/Tree.tsx
424
+ // src/components/Tree/Tree.tsx
435
425
  import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
436
426
  import React8, { useMemo as useMemo2 } from "react";
437
427
  import { Treegrid as Treegrid2 } from "@dxos/react-ui";
438
428
 
439
- // packages/ui/react-ui-list/src/components/Tree/TreeContext.tsx
429
+ // src/components/Tree/TreeContext.tsx
440
430
  import { createContext as createContext5, useContext } from "react";
441
431
  import { raise } from "@dxos/debug";
442
432
  var TreeContext = /* @__PURE__ */ createContext5(null);
443
433
  var TreeProvider = TreeContext.Provider;
444
434
  var useTree = () => useContext(TreeContext) ?? raise(new Error("TreeContext not found"));
445
435
 
446
- // packages/ui/react-ui-list/src/components/Tree/TreeItem.tsx
436
+ // src/components/Tree/TreeItem.tsx
447
437
  import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
448
438
  import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
449
439
  import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
@@ -451,19 +441,24 @@ import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-
451
441
  import { Schema } from "effect";
452
442
  import React7, { memo as memo3, useCallback as useCallback3, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
453
443
  import { invariant as invariant2 } from "@dxos/invariant";
454
- import { Treegrid, TreeItem as NaturalTreeItem } from "@dxos/react-ui";
455
- import { ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, mx as mx6 } from "@dxos/react-ui-theme";
444
+ import { TreeItem as NaturalTreeItem, Treegrid } from "@dxos/react-ui";
445
+ import { ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls } from "@dxos/react-ui-theme";
456
446
 
457
- // packages/ui/react-ui-list/src/components/Tree/TreeItemHeading.tsx
447
+ // src/components/Tree/helpers.ts
448
+ var DEFAULT_INDENTATION = 8;
449
+ var paddingIndentation = (level, indentation = DEFAULT_INDENTATION) => ({
450
+ paddingInlineStart: `${(level - 1) * indentation}px`
451
+ });
452
+
453
+ // src/components/Tree/TreeItemHeading.tsx
458
454
  import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
459
- import React5, { forwardRef as forwardRef2, memo, useCallback as useCallback2 } from "react";
460
- import { Button, Icon as Icon3, toLocalizedString, useTranslation } from "@dxos/react-ui";
455
+ import React5, { forwardRef, memo, useCallback as useCallback2 } from "react";
456
+ import { Button, Icon as Icon2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
461
457
  import { TextTooltip } from "@dxos/react-ui-text-tooltip";
462
- import { mx as mx4 } from "@dxos/react-ui-theme";
463
- var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label, icon, className, disabled, current, onSelect }, forwardedRef) => {
458
+ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label, icon, className, disabled, current, onSelect }, forwardedRef) => {
464
459
  var _effect = _useSignals5();
465
460
  try {
466
- const { t } = useTranslation();
461
+ const { t } = useTranslation2();
467
462
  const handleSelect = useCallback2((event) => {
468
463
  onSelect?.(event.altKey);
469
464
  }, [
@@ -489,14 +484,18 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label,
489
484
  "data-testid": "treeItem.heading",
490
485
  variant: "ghost",
491
486
  density: "fine",
492
- classNames: mx4("grow gap-2 pis-0.5 hover:bg-transparent dark:hover:bg-transparent", "disabled:cursor-default disabled:opacity-100", className),
487
+ classNames: [
488
+ "grow gap-2 pis-0.5 hover:bg-transparent dark:hover:bg-transparent",
489
+ "disabled:cursor-default disabled:opacity-100",
490
+ className
491
+ ],
493
492
  disabled,
494
493
  onClick: handleSelect,
495
494
  onKeyDown: handleButtonKeydown,
496
495
  ...current && {
497
496
  "aria-current": "location"
498
497
  }
499
- }, icon && /* @__PURE__ */ React5.createElement(Icon3, {
498
+ }, icon && /* @__PURE__ */ React5.createElement(Icon2, {
500
499
  icon: icon ?? "ph--placeholder--regular",
501
500
  size: 5,
502
501
  classNames: "mlb-1"
@@ -509,12 +508,11 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label,
509
508
  }
510
509
  }));
511
510
 
512
- // packages/ui/react-ui-list/src/components/Tree/TreeItemToggle.tsx
511
+ // src/components/Tree/TreeItemToggle.tsx
513
512
  import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
514
- import React6, { forwardRef as forwardRef3, memo as memo2 } from "react";
515
- import { Button as Button2, Icon as Icon4 } from "@dxos/react-ui";
516
- import { mx as mx5 } from "@dxos/react-ui-theme";
517
- var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef3(({ open, isBranch, hidden, onToggle }, forwardedRef) => {
513
+ import React6, { forwardRef as forwardRef2, memo as memo2 } from "react";
514
+ import { Button as Button2, Icon as Icon3 } from "@dxos/react-ui";
515
+ var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef2(({ open, isBranch, hidden, onToggle }, forwardedRef) => {
518
516
  var _effect = _useSignals6();
519
517
  try {
520
518
  return /* @__PURE__ */ React6.createElement(Button2, {
@@ -523,26 +521,26 @@ var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef3(({ open,
523
521
  "aria-expanded": open,
524
522
  variant: "ghost",
525
523
  density: "fine",
526
- classNames: mx5("is-6 pli-0 dx-focus-ring-inset", hidden ? "hidden" : !isBranch && "invisible"),
524
+ classNames: [
525
+ "is-6 pli-0 dx-focus-ring-inset",
526
+ hidden ? "hidden" : !isBranch && "invisible"
527
+ ],
527
528
  onClick: onToggle
528
- }, /* @__PURE__ */ React6.createElement(Icon4, {
529
+ }, /* @__PURE__ */ React6.createElement(Icon3, {
529
530
  icon: "ph--caret-right--bold",
530
531
  size: 3,
531
- classNames: mx5("transition duration-200", open && "rotate-90")
532
+ classNames: [
533
+ "transition duration-200",
534
+ open && "rotate-90"
535
+ ]
532
536
  }));
533
537
  } finally {
534
538
  _effect.f();
535
539
  }
536
540
  }));
537
541
 
538
- // packages/ui/react-ui-list/src/components/Tree/helpers.ts
539
- var DEFAULT_INDENTATION = 8;
540
- var paddingIndentation = (level, indentation = DEFAULT_INDENTATION) => ({
541
- paddingInlineStart: `${(level - 1) * indentation}px`
542
- });
543
-
544
- // packages/ui/react-ui-list/src/components/Tree/TreeItem.tsx
545
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-list/src/components/Tree/TreeItem.tsx";
542
+ // src/components/Tree/TreeItem.tsx
543
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-list/src/components/Tree/TreeItem.tsx";
546
544
  var hoverableDescriptionIcons = "[--icons-color:inherit] hover-hover:[--icons-color:var(--description-text)] hover-hover:hover:[--icons-color:inherit] focus-within:[--icons-color:inherit]";
547
545
  var TreeDataSchema = Schema.Struct({
548
546
  id: Schema.String,
@@ -746,7 +744,15 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
746
744
  id,
747
745
  "aria-labelledby": `${id}__label`,
748
746
  parentOf: parentOf?.join(Treegrid.PARENT_OF_SEPARATOR),
749
- classNames: mx6("grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-activeSurface", hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, hoverableDescriptionIcons, ghostHover, className),
747
+ classNames: [
748
+ "grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-activeSurface",
749
+ hoverableControls,
750
+ hoverableFocusedKeyboardControls,
751
+ hoverableFocusedWithinControls,
752
+ hoverableDescriptionIcons,
753
+ ghostHover,
754
+ className
755
+ ],
750
756
  "data-itemid": id,
751
757
  "data-testid": testId,
752
758
  // NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
@@ -803,7 +809,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
803
809
  };
804
810
  var TreeItem = /* @__PURE__ */ memo3(RawTreeItem);
805
811
 
806
- // packages/ui/react-ui-list/src/components/Tree/Tree.tsx
812
+ // src/components/Tree/Tree.tsx
807
813
  var Tree = ({ root, path, id, useItems, getProps, isOpen, isCurrent, draggable: draggable3 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, levelOffset, renderColumns, canDrop, onOpenChange, onSelect }) => {
808
814
  var _effect = _useSignals8();
809
815
  try {
@@ -850,7 +856,7 @@ var Tree = ({ root, path, id, useItems, getProps, isOpen, isCurrent, draggable:
850
856
  }
851
857
  };
852
858
 
853
- // packages/ui/react-ui-list/src/util/path.ts
859
+ // src/util/path.ts
854
860
  var SEPARATOR = "+";
855
861
  var Path = {
856
862
  create: (...args) => args.join(SEPARATOR),