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