@dxos/react-ui-list 0.8.4-main.84f28bd → 0.8.4-main.ae835ea

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 (50) hide show
  1. package/dist/lib/browser/index.mjs +109 -89
  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 +109 -89
  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 +7 -4
  8. package/dist/types/src/components/Accordion/Accordion.stories.d.ts.map +1 -1
  9. package/dist/types/src/components/Accordion/AccordionItem.d.ts +1 -1
  10. package/dist/types/src/components/Accordion/AccordionItem.d.ts.map +1 -1
  11. package/dist/types/src/components/List/List.d.ts +6 -6
  12. package/dist/types/src/components/List/List.d.ts.map +1 -1
  13. package/dist/types/src/components/List/List.stories.d.ts +14 -5
  14. package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/List/ListItem.d.ts +4 -7
  16. package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
  17. package/dist/types/src/components/List/ListRoot.d.ts.map +1 -1
  18. package/dist/types/src/components/List/testing.d.ts +1 -1
  19. package/dist/types/src/components/List/testing.d.ts.map +1 -1
  20. package/dist/types/src/components/Tree/Tree.d.ts +3 -3
  21. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  22. package/dist/types/src/components/Tree/Tree.stories.d.ts +36 -6
  23. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/Tree/TreeContext.d.ts +3 -2
  25. package/dist/types/src/components/Tree/TreeContext.d.ts.map +1 -1
  26. package/dist/types/src/components/Tree/TreeItem.d.ts +14 -9
  27. package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
  28. package/dist/types/src/components/Tree/TreeItemHeading.d.ts +4 -3
  29. package/dist/types/src/components/Tree/TreeItemHeading.d.ts.map +1 -1
  30. package/dist/types/src/components/Tree/TreeItemToggle.d.ts +3 -3
  31. package/dist/types/src/components/Tree/TreeItemToggle.d.ts.map +1 -1
  32. package/dist/types/src/components/Tree/testing.d.ts +2 -2
  33. package/dist/types/src/components/Tree/testing.d.ts.map +1 -1
  34. package/dist/types/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +25 -24
  36. package/src/components/Accordion/Accordion.stories.tsx +5 -7
  37. package/src/components/Accordion/Accordion.tsx +1 -1
  38. package/src/components/Accordion/AccordionItem.tsx +5 -2
  39. package/src/components/List/List.stories.tsx +16 -14
  40. package/src/components/List/List.tsx +2 -5
  41. package/src/components/List/ListItem.tsx +39 -27
  42. package/src/components/List/ListRoot.tsx +1 -1
  43. package/src/components/List/testing.ts +2 -2
  44. package/src/components/Tree/Tree.stories.tsx +51 -48
  45. package/src/components/Tree/Tree.tsx +7 -2
  46. package/src/components/Tree/TreeContext.tsx +3 -2
  47. package/src/components/Tree/TreeItem.tsx +51 -45
  48. package/src/components/Tree/TreeItemHeading.tsx +11 -9
  49. package/src/components/Tree/TreeItemToggle.tsx +29 -19
  50. package/src/components/Tree/testing.ts +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-list",
3
- "version": "0.8.4-main.84f28bd",
3
+ "version": "0.8.4-main.ae835ea",
4
4
  "description": "A list component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -9,6 +9,7 @@
9
9
  "type": "module",
10
10
  "exports": {
11
11
  ".": {
12
+ "source": "./src/index.ts",
12
13
  "types": "./dist/types/src/index.d.ts",
13
14
  "browser": "./dist/lib/browser/index.mjs",
14
15
  "node": "./dist/lib/node-esm/index.mjs"
@@ -26,36 +27,36 @@
26
27
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
27
28
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
28
29
  "@preact-signals/safe-react": "^0.9.0",
29
- "@preact/signals-core": "^1.9.0",
30
+ "@preact/signals-core": "^1.12.1",
30
31
  "@radix-ui/react-accordion": "1.2.3",
31
32
  "@radix-ui/react-context": "1.1.1",
32
- "@dxos/debug": "0.8.4-main.84f28bd",
33
- "@dxos/invariant": "0.8.4-main.84f28bd",
34
- "@dxos/echo-schema": "0.8.4-main.84f28bd",
35
- "@dxos/log": "0.8.4-main.84f28bd",
36
- "@dxos/live-object": "0.8.4-main.84f28bd",
37
- "@dxos/react-ui": "0.8.4-main.84f28bd",
38
- "@dxos/react-ui-text-tooltip": "0.8.4-main.84f28bd",
39
- "@dxos/react-ui-theme": "0.8.4-main.84f28bd",
40
- "@dxos/react-ui-types": "0.8.4-main.84f28bd",
41
- "@dxos/util": "0.8.4-main.84f28bd"
33
+ "@dxos/debug": "0.8.4-main.ae835ea",
34
+ "@dxos/echo": "0.8.4-main.ae835ea",
35
+ "@dxos/invariant": "0.8.4-main.ae835ea",
36
+ "@dxos/live-object": "0.8.4-main.ae835ea",
37
+ "@dxos/log": "0.8.4-main.ae835ea",
38
+ "@dxos/react-ui": "0.8.4-main.ae835ea",
39
+ "@dxos/react-ui-text-tooltip": "0.8.4-main.ae835ea",
40
+ "@dxos/react-ui-types": "0.8.4-main.ae835ea",
41
+ "@dxos/util": "0.8.4-main.ae835ea",
42
+ "@dxos/react-ui-theme": "0.8.4-main.ae835ea"
42
43
  },
43
44
  "devDependencies": {
44
- "@types/react": "~18.2.0",
45
- "@types/react-dom": "~18.2.0",
46
- "effect": "3.16.13",
47
- "react": "~18.2.0",
48
- "react-dom": "~18.2.0",
49
- "vite": "5.4.7",
50
- "@dxos/random": "0.8.4-main.84f28bd",
51
- "@dxos/storybook-utils": "0.8.4-main.84f28bd"
45
+ "@types/react": "~19.2.2",
46
+ "@types/react-dom": "~19.2.2",
47
+ "effect": "3.18.3",
48
+ "react": "~19.2.0",
49
+ "react-dom": "~19.2.0",
50
+ "vite": "7.1.9",
51
+ "@dxos/random": "0.8.4-main.ae835ea",
52
+ "@dxos/storybook-utils": "0.8.4-main.ae835ea"
52
53
  },
53
54
  "peerDependencies": {
54
55
  "effect": "^3.13.3",
55
- "react": "~18.2.0",
56
- "react-dom": "~18.2.0",
57
- "@dxos/react-ui-theme": "0.8.4-main.84f28bd",
58
- "@dxos/react-ui": "0.8.4-main.84f28bd"
56
+ "react": "^19.0.0",
57
+ "react-dom": "^19.0.0",
58
+ "@dxos/react-ui": "0.8.4-main.ae835ea",
59
+ "@dxos/react-ui-theme": "0.8.4-main.ae835ea"
59
60
  },
60
61
  "publishConfig": {
61
62
  "access": "public"
@@ -2,13 +2,11 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type StoryObj, type Meta } from '@storybook/react-vite';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React from 'react';
9
7
 
10
8
  import { faker } from '@dxos/random';
11
- import { withLayout, withTheme } from '@dxos/storybook-utils';
9
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
12
10
 
13
11
  import { Accordion } from './Accordion';
14
12
 
@@ -41,11 +39,11 @@ const DefaultStory = () => {
41
39
  );
42
40
  };
43
41
 
44
- const meta: Meta<typeof Accordion> = {
42
+ const meta = {
45
43
  title: 'ui/react-ui-list/Accordion',
46
44
  render: DefaultStory,
47
- decorators: [withTheme, withLayout({ fullscreen: true, classNames: 'flex justify-center' })],
48
- };
45
+ decorators: [withTheme, withLayout({ container: 'column' })],
46
+ } satisfies Meta<typeof Accordion>;
49
47
 
50
48
  export default meta;
51
49
 
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { AccordionItem, AccordionItemHeader, AccordionItemBody } from './AccordionItem';
5
+ import { AccordionItem, AccordionItemBody, AccordionItemHeader } from './AccordionItem';
6
6
  import { AccordionRoot } from './AccordionRoot';
7
7
 
8
8
  // TODO(burdon): Next iteration should be based on Radix UI Accordion:
@@ -9,16 +9,19 @@ import React, { type PropsWithChildren } from 'react';
9
9
  import { Icon, type ThemedClassName } from '@dxos/react-ui';
10
10
  import { mx } from '@dxos/react-ui-theme';
11
11
 
12
- import { useAccordionContext } from './AccordionRoot';
13
12
  import { type ListItemRecord } from '../List';
14
13
 
14
+ import { useAccordionContext } from './AccordionRoot';
15
+
15
16
  const ACCORDION_ITEM_NAME = 'AccordionItem';
16
17
 
17
18
  type AccordionItemContext<T extends ListItemRecord> = {
18
19
  item: T;
19
20
  };
20
21
 
21
- export const [AccordionItemProvider, useAccordionItemContext] =
22
+ // TODO(wittjosiah): This seems to be conflicting with something in the bundle.
23
+ // Perhaps @radix-ui/react-accordion?
24
+ export const [AccordionItemProvider, useDxAccordionItemContext] =
22
25
  createContext<AccordionItemContext<any>>(ACCORDION_ITEM_NAME);
23
26
 
24
27
  export type AccordionItemProps<T extends ListItemRecord> = ThemedClassName<PropsWithChildren<{ item: T }>>;
@@ -2,30 +2,21 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
- import { Schema } from 'effect';
6
+ import * as Schema from 'effect/Schema';
9
7
  import React from 'react';
10
8
 
11
9
  import { live } from '@dxos/live-object';
10
+ import { withTheme } from '@dxos/react-ui/testing';
12
11
  import { ghostHover, mx } from '@dxos/react-ui-theme';
13
- import { withLayout, withTheme } from '@dxos/storybook-utils';
14
12
  import { arrayMove } from '@dxos/util';
15
13
 
16
14
  import { List, type ListRootProps } from './List';
17
- import { createList, TestItemSchema, type TestItemType } from './testing';
15
+ import { TestItemSchema, type TestItemType, createList } from './testing';
18
16
 
19
17
  // TODO(burdon): var-icon-size.
20
18
  const grid = 'grid grid-cols-[32px_1fr_32px] min-bs-[2rem] rounded';
21
19
 
22
- const meta: Meta = {
23
- title: 'ui/react-ui-list/List',
24
- decorators: [withTheme, withLayout({ fullscreen: true })],
25
- };
26
-
27
- export default meta;
28
-
29
20
  const DefaultStory = ({ items = [], ...props }: ListRootProps<TestItemType>) => {
30
21
  const handleSelect = (item: TestItemType) => {
31
22
  console.log('select', item);
@@ -98,7 +89,18 @@ const SimpleStory = ({ items = [], ...props }: ListRootProps<TestItemType>) => {
98
89
 
99
90
  const list = live(createList(100));
100
91
 
101
- export const Default: StoryObj<ListRootProps<TestItemType>> = {
92
+ const meta = {
93
+ title: 'ui/react-ui-list/List',
94
+ component: List.Root,
95
+ decorators: [withTheme],
96
+ parameters: {
97
+ layout: 'fullscreen',
98
+ },
99
+ } satisfies Meta<typeof List.Root>;
100
+
101
+ export default meta;
102
+
103
+ export const Default: StoryObj<typeof DefaultStory> = {
102
104
  render: DefaultStory,
103
105
  args: {
104
106
  items: list.items,
@@ -106,7 +108,7 @@ export const Default: StoryObj<ListRootProps<TestItemType>> = {
106
108
  },
107
109
  };
108
110
 
109
- export const Simple: StoryObj<ListRootProps<TestItemType>> = {
111
+ export const Simple: StoryObj<typeof SimpleStory> = {
110
112
  render: SimpleStory,
111
113
  args: {
112
114
  items: list.items,
@@ -3,11 +3,9 @@
3
3
  //
4
4
 
5
5
  import {
6
- IconButton,
7
- type IconButtonProps,
8
6
  ListItem,
9
- ListItemDeleteButton,
10
7
  ListItemButton,
8
+ ListItemDeleteButton,
11
9
  ListItemDragHandle,
12
10
  ListItemDragPreview,
13
11
  type ListItemProps,
@@ -38,9 +36,8 @@ export const List = {
38
36
  ItemDeleteButton: ListItemDeleteButton,
39
37
  ItemButton: ListItemButton,
40
38
  ItemTitle: ListItemTitle,
41
- IconButton,
42
39
  };
43
40
 
44
41
  type ListItem = ListItemRecord;
45
42
 
46
- export type { ListRootProps, ListItemProps, IconButtonProps, ListItem, ListItemRecord };
43
+ export type { ListRootProps, ListItemProps, ListItem, ListItemRecord };
@@ -17,7 +17,6 @@ import React, {
17
17
  type MutableRefObject,
18
18
  type PropsWithChildren,
19
19
  type ReactNode,
20
- forwardRef,
21
20
  useEffect,
22
21
  useRef,
23
22
  useState,
@@ -25,7 +24,13 @@ import React, {
25
24
  import { createPortal } from 'react-dom';
26
25
 
27
26
  import { invariant } from '@dxos/invariant';
28
- import { Icon, type ThemedClassName, ListItem as NaturalListItem } from '@dxos/react-ui';
27
+ import {
28
+ IconButton,
29
+ type IconButtonProps,
30
+ ListItem as NaturalListItem,
31
+ type ThemedClassName,
32
+ useTranslation,
33
+ } from '@dxos/react-ui';
29
34
  import { mx } from '@dxos/react-ui-theme';
30
35
 
31
36
  import { useListContext } from './ListRoot';
@@ -165,15 +170,8 @@ export const ListItem = <T extends ListItemRecord>({ children, classNames, item,
165
170
 
166
171
  return (
167
172
  <ListItemProvider item={item} dragHandleRef={dragHandleRef}>
168
- <div role='none' className='relative'>
169
- <div
170
- ref={ref}
171
- role='listitem'
172
- className={mx('flex overflow-hidden', classNames, stateStyles[state.type])}
173
- {...props}
174
- >
175
- {children}
176
- </div>
173
+ <div ref={ref} role='listitem' className={mx('flex relative', classNames, stateStyles[state.type])} {...props}>
174
+ {children}
177
175
  {state.type === 'is-dragging-over' && state.closestEdge && (
178
176
  <NaturalListItem.DropIndicator edge={state.closestEdge} />
179
177
  )}
@@ -186,51 +184,65 @@ export const ListItem = <T extends ListItemRecord>({ children, classNames, item,
186
184
  // List item components
187
185
  //
188
186
 
189
- export type IconButtonProps = ThemedClassName<ComponentProps<'button'>> & { icon: string };
190
-
191
- export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
192
- ({ classNames, icon, ...props }, forwardedRef) => {
193
- return (
194
- <button ref={forwardedRef} className={mx('flex items-center justify-center', classNames)} {...props}>
195
- <Icon icon={icon} classNames='cursor-pointer' size={4} />
196
- </button>
197
- );
198
- },
199
- );
200
-
201
187
  export const ListItemDeleteButton = ({
202
188
  autoHide = true,
203
189
  classNames,
204
190
  disabled,
205
191
  icon = 'ph--x--regular',
192
+ label,
206
193
  ...props
207
- }: Partial<Pick<IconButtonProps, 'icon'>> & Omit<IconButtonProps, 'icon'> & { autoHide?: boolean }) => {
194
+ }: Partial<Pick<IconButtonProps, 'icon'>> &
195
+ Omit<IconButtonProps, 'icon' | 'label'> & { autoHide?: boolean; label?: string }) => {
208
196
  const { state } = useListContext('DELETE_BUTTON');
209
197
  const isDisabled = state.type !== 'idle' || disabled;
198
+ const { t } = useTranslation('os');
210
199
  return (
211
200
  <IconButton
201
+ iconOnly
202
+ variant='ghost'
203
+ {...props}
212
204
  icon={icon}
213
205
  disabled={isDisabled}
206
+ label={label ?? t('delete label')}
214
207
  classNames={[classNames, autoHide && disabled && 'hidden']}
215
- {...props}
216
208
  />
217
209
  );
218
210
  };
219
211
 
220
212
  export const ListItemButton = ({
221
213
  autoHide = true,
214
+ iconOnly = true,
215
+ variant = 'ghost',
222
216
  classNames,
223
217
  disabled,
224
218
  ...props
225
219
  }: IconButtonProps & { autoHide?: boolean }) => {
226
220
  const { state } = useListContext('ITEM_BUTTON');
227
221
  const isDisabled = state.type !== 'idle' || disabled;
228
- return <IconButton disabled={isDisabled} classNames={[classNames, autoHide && disabled && 'hidden']} {...props} />;
222
+ return (
223
+ <IconButton
224
+ {...props}
225
+ disabled={isDisabled}
226
+ iconOnly={iconOnly}
227
+ variant={variant}
228
+ classNames={[classNames, autoHide && disabled && 'hidden']}
229
+ />
230
+ );
229
231
  };
230
232
 
231
233
  export const ListItemDragHandle = ({ disabled }: Pick<IconButtonProps, 'disabled'>) => {
232
234
  const { dragHandleRef } = useListItemContext('DRAG_HANDLE');
233
- return <IconButton ref={dragHandleRef as any} icon='ph--dots-six-vertical--regular' disabled={disabled} />;
235
+ const { t } = useTranslation('os');
236
+ return (
237
+ <IconButton
238
+ iconOnly
239
+ variant='ghost'
240
+ label={t('drag handle label')}
241
+ ref={dragHandleRef as any}
242
+ icon='ph--dots-six-vertical--regular'
243
+ disabled={disabled}
244
+ />
245
+ );
234
246
  };
235
247
 
236
248
  export const ListItemDragPreview = <T extends ListItemRecord>({
@@ -8,7 +8,7 @@ import { getReorderDestinationIndex } from '@atlaskit/pragmatic-drag-and-drop-hi
8
8
  import { createContext } from '@radix-ui/react-context';
9
9
  import React, { type ReactNode, useCallback, useEffect, useState } from 'react';
10
10
 
11
- import { idle, type ItemDragState, type ListItemRecord } from './ListItem';
11
+ import { type ItemDragState, type ListItemRecord, idle } from './ListItem';
12
12
 
13
13
  type ListContext<T extends ListItemRecord> = {
14
14
  // TODO(burdon): Rename drag state.
@@ -2,9 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
 
7
- import { ObjectId } from '@dxos/echo-schema';
7
+ import { ObjectId } from '@dxos/echo/internal';
8
8
  import { faker } from '@dxos/random';
9
9
 
10
10
  export const TestItemSchema = Schema.Struct({
@@ -2,70 +2,71 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
8
- import { extractInstruction, type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
6
+ import { type Instruction, extractInstruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
9
7
  import { type Meta, type StoryObj } from '@storybook/react-vite';
10
8
  import React, { useEffect } from 'react';
11
9
 
12
- import { live, type Live } from '@dxos/live-object';
10
+ import { type Live, live } from '@dxos/live-object';
13
11
  import { faker } from '@dxos/random';
14
12
  import { Icon } from '@dxos/react-ui';
15
- import { withLayout, withTheme } from '@dxos/storybook-utils';
13
+ import { withTheme } from '@dxos/react-ui/testing';
16
14
 
17
- import { Tree } from './Tree';
18
- import { type TreeData } from './TreeItem';
19
- import { createTree, updateState, type TestItem } from './testing';
20
15
  import { Path } from '../../util';
21
16
 
17
+ import { type TestItem, createTree, updateState } from './testing';
18
+ import { Tree, type TreeProps } from './Tree';
19
+ import { type TreeData } from './TreeItem';
20
+
22
21
  faker.seed(1234);
23
22
 
23
+ const DefaultStory = (props: TreeProps) => {
24
+ useEffect(() => {
25
+ return monitorForElements({
26
+ canMonitor: ({ source }) => typeof source.data.id === 'string' && Array.isArray(source.data.path),
27
+ onDrop: ({ location, source }) => {
28
+ // Didn't drop on anything.
29
+ if (!location.current.dropTargets.length) {
30
+ return;
31
+ }
32
+
33
+ const target = location.current.dropTargets[0];
34
+ const instruction: Instruction | null = extractInstruction(target.data);
35
+ if (instruction !== null) {
36
+ updateState({
37
+ state: tree,
38
+ instruction,
39
+ source: source.data as TreeData,
40
+ target: target.data as TreeData,
41
+ });
42
+ }
43
+ },
44
+ });
45
+ }, []);
46
+
47
+ return <Tree {...props} />;
48
+ };
49
+
24
50
  const tree = live<TestItem>(createTree());
25
51
  const state = new Map<string, Live<{ open: boolean; current: boolean }>>();
26
52
 
27
- const meta: Meta<typeof Tree<TestItem>> = {
53
+ const meta = {
28
54
  title: 'ui/react-ui-list/Tree',
55
+
56
+ decorators: [withTheme],
29
57
  component: Tree,
30
- decorators: [withTheme, withLayout()],
31
- render: (args) => {
32
- useEffect(() => {
33
- return monitorForElements({
34
- canMonitor: ({ source }) => typeof source.data.id === 'string' && Array.isArray(source.data.path),
35
- onDrop: ({ location, source }) => {
36
- // Didn't drop on anything.
37
- if (!location.current.dropTargets.length) {
38
- return;
39
- }
40
-
41
- const target = location.current.dropTargets[0];
42
-
43
- const instruction: Instruction | null = extractInstruction(target.data);
44
- if (instruction !== null) {
45
- updateState({
46
- state: tree,
47
- instruction,
48
- source: source.data as TreeData,
49
- target: target.data as TreeData,
50
- });
51
- }
52
- },
53
- });
54
- }, []);
55
-
56
- return <Tree {...args} />;
57
- },
58
+ render: DefaultStory,
58
59
  args: {
59
60
  id: tree.id,
60
- useItems: (testItem?: TestItem) => {
61
- return testItem?.items ?? tree.items;
61
+ useItems: (parent?: TestItem) => {
62
+ return parent?.items ?? tree.items;
62
63
  },
63
- getProps: (testItem: TestItem) => ({
64
- id: testItem.id,
65
- label: testItem.name,
66
- icon: testItem.icon,
67
- ...((testItem.items?.length ?? 0) > 0 && {
68
- parentOf: testItem.items!.map(({ id }) => id),
64
+ getProps: (parent: TestItem) => ({
65
+ id: parent.id,
66
+ label: parent.name,
67
+ icon: parent.icon,
68
+ ...((parent.items?.length ?? 0) > 0 && {
69
+ parentOf: parent.items!.map(({ id }) => id),
69
70
  }),
70
71
  }),
71
72
  isOpen: (_path: string[]) => {
@@ -104,13 +105,15 @@ const meta: Meta<typeof Tree<TestItem>> = {
104
105
  object!.current = current;
105
106
  },
106
107
  },
107
- };
108
+ } satisfies Meta<typeof Tree<TestItem>>;
108
109
 
109
110
  export default meta;
110
111
 
111
- export const Default = {};
112
+ type Story = StoryObj<typeof meta>;
113
+
114
+ export const Default: Story = {};
112
115
 
113
- export const Draggable: StoryObj<typeof Tree> = {
116
+ export const Draggable: Story = {
114
117
  args: {
115
118
  draggable: true,
116
119
  },
@@ -4,7 +4,7 @@
4
4
 
5
5
  import React, { useMemo } from 'react';
6
6
 
7
- import { type HasId } from '@dxos/echo-schema';
7
+ import { type HasId } from '@dxos/echo/internal';
8
8
  import { Treegrid, type TreegridRootProps } from '@dxos/react-ui';
9
9
 
10
10
  import { type TreeContextType, TreeProvider } from './TreeContext';
@@ -16,7 +16,10 @@ export type TreeProps<T extends HasId = any, O = any> = {
16
16
  id: string;
17
17
  } & TreeContextType<T, O> &
18
18
  Partial<Pick<TreegridRootProps, 'gridTemplateColumns' | 'classNames'>> &
19
- Pick<TreeItemProps<T>, 'draggable' | 'renderColumns' | 'canDrop' | 'onOpenChange' | 'onSelect' | 'levelOffset'>;
19
+ Pick<
20
+ TreeItemProps<T>,
21
+ 'draggable' | 'renderColumns' | 'canDrop' | 'canSelect' | 'onOpenChange' | 'onSelect' | 'levelOffset'
22
+ >;
20
23
 
21
24
  export const Tree = <T extends HasId = any, O = any>({
22
25
  root,
@@ -32,6 +35,7 @@ export const Tree = <T extends HasId = any, O = any>({
32
35
  levelOffset,
33
36
  renderColumns,
34
37
  canDrop,
38
+ canSelect,
35
39
  onOpenChange,
36
40
  onSelect,
37
41
  }: TreeProps<T, O>) => {
@@ -60,6 +64,7 @@ export const Tree = <T extends HasId = any, O = any>({
60
64
  draggable={draggable}
61
65
  renderColumns={renderColumns}
62
66
  canDrop={canDrop}
67
+ canSelect={canSelect}
63
68
  onOpenChange={onOpenChange}
64
69
  onSelect={onSelect}
65
70
  />
@@ -11,10 +11,11 @@ export type TreeItemDataProps = {
11
11
  id: string;
12
12
  label: Label;
13
13
  parentOf?: string[];
14
- icon?: string;
15
- disabled?: boolean;
16
14
  className?: string;
17
15
  headingClassName?: string;
16
+ icon?: string;
17
+ iconHue?: string;
18
+ disabled?: boolean;
18
19
  testId?: string;
19
20
  };
20
21