@dxos/react-ui-list 0.8.1 → 0.8.2-main.10c050d

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 (45) hide show
  1. package/dist/lib/browser/index.mjs +684 -597
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +684 -598
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +684 -597
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/Accordion/Accordion.d.ts +2 -2
  11. package/dist/types/src/components/Accordion/AccordionItem.d.ts.map +1 -1
  12. package/dist/types/src/components/Accordion/AccordionRoot.d.ts.map +1 -1
  13. package/dist/types/src/components/List/List.d.ts +3 -3
  14. package/dist/types/src/components/List/List.d.ts.map +1 -1
  15. package/dist/types/src/components/List/ListItem.d.ts +1 -1
  16. package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
  17. package/dist/types/src/components/List/ListRoot.d.ts +1 -1
  18. package/dist/types/src/components/List/ListRoot.d.ts.map +1 -1
  19. package/dist/types/src/components/List/testing.d.ts +10 -10
  20. package/dist/types/src/components/List/testing.d.ts.map +1 -1
  21. package/dist/types/src/components/Tree/Tree.d.ts +4 -3
  22. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  23. package/dist/types/src/components/Tree/Tree.stories.d.ts +2 -1
  24. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  25. package/dist/types/src/components/Tree/TreeContext.d.ts +1 -1
  26. package/dist/types/src/components/Tree/TreeItem.d.ts +9 -9
  27. package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
  28. package/dist/types/src/components/Tree/TreeItemToggle.d.ts.map +1 -1
  29. package/dist/types/src/components/Tree/helpers.d.ts.map +1 -1
  30. package/dist/types/src/components/Tree/testing.d.ts +8 -8
  31. package/dist/types/src/components/Tree/testing.d.ts.map +1 -1
  32. package/dist/types/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +19 -18
  34. package/src/components/Accordion/Accordion.stories.tsx +2 -2
  35. package/src/components/List/List.stories.tsx +5 -5
  36. package/src/components/List/ListItem.tsx +5 -8
  37. package/src/components/List/ListRoot.tsx +3 -3
  38. package/src/components/List/testing.ts +10 -8
  39. package/src/components/Tree/Tree.stories.tsx +8 -8
  40. package/src/components/Tree/Tree.tsx +11 -6
  41. package/src/components/Tree/TreeContext.tsx +1 -1
  42. package/src/components/Tree/TreeItem.tsx +23 -21
  43. package/src/components/Tree/TreeItemToggle.tsx +1 -5
  44. package/src/components/Tree/testing.ts +8 -8
  45. package/src/util/path.ts +1 -1
@@ -1,7 +1,8 @@
1
1
  import '@dxos-theme';
2
2
  import { type Meta, type StoryObj } from '@storybook/react';
3
3
  import { Tree } from './Tree';
4
- declare const meta: Meta<typeof Tree>;
4
+ import { type TestItem } from './testing';
5
+ declare const meta: Meta<typeof Tree<TestItem>>;
5
6
  export default meta;
6
7
  export declare const Default: {};
7
8
  export declare const Draggable: StoryObj<typeof Tree>;
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/Tree.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAIrB,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQ5D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAU9B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,CAgF3B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,IAAK,CAAC;AAE1B,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,OAAO,IAAI,CAI3C,CAAC"}
1
+ {"version":3,"file":"Tree.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/Tree.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAIrB,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQ5D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAQnE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,CAgFrC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,IAAK,CAAC;AAE1B,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,OAAO,IAAI,CAI3C,CAAC"}
@@ -10,7 +10,7 @@ export type PropsFromTreeItem = {
10
10
  testId?: string;
11
11
  };
12
12
  export type TreeContextType<T = any> = {
13
- getItems: (parent?: T) => T[];
13
+ useItems: (parent?: T) => T[];
14
14
  getProps: (item: T, parent: string[]) => PropsFromTreeItem;
15
15
  isOpen: (path: string[], item: T) => boolean;
16
16
  isCurrent: (path: string[], item: T) => boolean;
@@ -1,13 +1,14 @@
1
- import React, { type FC } from 'react';
2
- import { S } from '@dxos/echo-schema';
3
- export declare const TreeDataSchema: S.Struct<{
4
- id: typeof S.String;
5
- path: S.Array$<typeof S.String>;
6
- item: typeof S.Any;
1
+ import { Schema } from 'effect';
2
+ import { type FC } from 'react';
3
+ import { type HasId } from '@dxos/echo-schema';
4
+ export declare const TreeDataSchema: Schema.Struct<{
5
+ id: typeof Schema.String;
6
+ path: Schema.Array$<typeof Schema.String>;
7
+ item: typeof Schema.Any;
7
8
  }>;
8
- export type TreeData = S.Schema.Type<typeof TreeDataSchema>;
9
+ export type TreeData = Schema.Schema.Type<typeof TreeDataSchema>;
9
10
  export declare const isTreeData: (data: unknown) => data is TreeData;
10
- export type TreeItemProps<T = any> = {
11
+ export type TreeItemProps<T extends HasId = any> = {
11
12
  item: T;
12
13
  path: string[];
13
14
  levelOffset?: number;
@@ -33,6 +34,5 @@ export type TreeItemProps<T = any> = {
33
34
  option: boolean;
34
35
  }) => void;
35
36
  };
36
- export declare const RawTreeItem: <T = any>({ item, path: _path, last, draggable: _draggable, renderColumns: Columns, canDrop, onOpenChange, onSelect, levelOffset, }: TreeItemProps<T>) => React.JSX.Element;
37
37
  export declare const TreeItem: FC<TreeItemProps>;
38
38
  //# sourceMappingURL=TreeItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/TreeItem.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,EAA2D,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAEpH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAqBtC,eAAO,MAAM,cAAc;;;;EAIzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,UAAU,SAAU,OAAO,KAAG,IAAI,IAAI,QAAsC,CAAC;AAE1F,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,GAAG,IAAI;IACnC,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,EAAE,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC;QACR,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,IAAI,EAAE,OAAO,CAAC;QACd,QAAQ,EAAE,OAAO,CAAC;QAClB,WAAW,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;KACtC,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,KAAK,OAAO,CAAC;IAC1D,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5E,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC7F,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,mIAU1B,aAAa,CAAC,CAAC,CAAC,sBAgNlB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAwB,EAAE,CAAC,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"TreeItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/TreeItem.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAc,EAA2D,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAEpH,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAqB/C,eAAO,MAAM,cAAc;;;;EAIzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,cAAc,CAAC,CAAC;AAEjE,eAAO,MAAM,UAAU,GAAI,MAAM,OAAO,KAAG,IAAI,IAAI,QAA2C,CAAC;AAE/F,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,IAAI;IACjD,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,EAAE,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC;QACR,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,IAAI,EAAE,OAAO,CAAC;QACd,QAAQ,EAAE,OAAO,CAAC;QAClB,WAAW,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;KACtC,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,KAAK,OAAO,CAAC;IAC1D,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5E,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC7F,CAAC;AA+NF,eAAO,MAAM,QAAQ,EAAwB,EAAE,CAAC,aAAa,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeItemToggle.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/TreeItemToggle.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAKhD,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,cAAc,0HAoB1B,CAAC"}
1
+ {"version":3,"file":"TreeItemToggle.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/TreeItemToggle.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAKhD,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,cAAc,0HAgB1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/helpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,eAAO,MAAM,kBAAkB,UAAW,MAAM;;CAE9C,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/helpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,EAAE,oBAAiC;;CAEjF,CAAC"}
@@ -1,17 +1,17 @@
1
1
  import { type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
2
- import { S } from '@dxos/echo-schema';
2
+ import { Schema } from 'effect';
3
+ import { type HasId } from '@dxos/echo-schema';
3
4
  import { type TreeData } from './TreeItem';
4
- export type TestItem = {
5
- id: string;
5
+ export type TestItem = HasId & {
6
6
  name: string;
7
7
  icon?: string;
8
8
  items: TestItem[];
9
9
  };
10
- export declare const TestItemSchema: S.Struct<{
11
- id: typeof S.String;
12
- name: typeof S.String;
13
- icon: S.optional<typeof S.String>;
14
- items: S.mutable<S.Array$<S.suspend<TestItem, TestItem, never>>>;
10
+ export declare const TestItemSchema: Schema.Struct<{
11
+ id: import("@dxos/keys").ObjectIdClass;
12
+ name: typeof Schema.String;
13
+ icon: Schema.optional<typeof Schema.String>;
14
+ items: Schema.mutable<Schema.Array$<Schema.suspend<TestItem, TestItem, never>>>;
15
15
  }>;
16
16
  export declare const createTree: (n?: number, d?: number) => TestItem;
17
17
  export declare const updateState: ({ state, instruction, source, target, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/testing.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,oDAAoD,CAAC;AAEtF,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAItC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;EAKzB,CAAC;AAEH,eAAO,MAAM,UAAU,8BAAmB,QAaxC,CAAC;AAmBH,eAAO,MAAM,WAAW,4CAKrB;IACD,KAAK,EAAE,QAAQ,CAAC;IAChB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;CAClB,SAgCA,CAAC"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/testing.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,oDAAoD,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,mBAAmB,CAAC;AAIzD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;EAKzB,CAAC;AAEH,eAAO,MAAM,UAAU,GAAI,UAAK,EAAE,UAAK,KAAG,QAaxC,CAAC;AAmBH,eAAO,MAAM,WAAW,GAAI,yCAKzB;IACD,KAAK,EAAE,QAAQ,CAAC;IAChB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;CAClB,SAgCA,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.7.3"}
1
+ {"version":"5.8.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-list",
3
- "version": "0.8.1",
3
+ "version": "0.8.2-main.10c050d",
4
4
  "description": "A list component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -25,39 +25,40 @@
25
25
  "dependencies": {
26
26
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
27
27
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
28
- "@preact/signals-core": "^1.6.0",
28
+ "@preact-signals/safe-react": "^0.9.0",
29
+ "@preact/signals-core": "^1.9.0",
29
30
  "@radix-ui/react-accordion": "1.2.3",
30
31
  "@radix-ui/react-context": "1.1.1",
31
- "@dxos/debug": "0.8.1",
32
- "@dxos/echo-schema": "0.8.1",
33
- "@dxos/invariant": "0.8.1",
34
- "@dxos/live-object": "0.8.1",
35
- "@dxos/log": "0.8.1",
36
- "@dxos/react-ui-attention": "0.8.1",
37
- "@dxos/react-ui-text-tooltip": "0.8.1",
38
- "@dxos/react-ui-types": "0.8.1",
39
- "@dxos/util": "0.8.1"
32
+ "@dxos/debug": "0.8.2-main.10c050d",
33
+ "@dxos/echo-schema": "0.8.2-main.10c050d",
34
+ "@dxos/invariant": "0.8.2-main.10c050d",
35
+ "@dxos/live-object": "0.8.2-main.10c050d",
36
+ "@dxos/react-ui-attention": "0.8.2-main.10c050d",
37
+ "@dxos/react-ui-text-tooltip": "0.8.2-main.10c050d",
38
+ "@dxos/react-ui-types": "0.8.2-main.10c050d",
39
+ "@dxos/log": "0.8.2-main.10c050d",
40
+ "@dxos/util": "0.8.2-main.10c050d"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@phosphor-icons/react": "^2.1.5",
43
44
  "@types/react": "~18.2.0",
44
45
  "@types/react-dom": "~18.2.0",
45
- "effect": "3.13.3",
46
+ "effect": "3.14.21",
46
47
  "react": "~18.2.0",
47
48
  "react-dom": "~18.2.0",
48
49
  "vite": "5.4.7",
49
- "@dxos/random": "0.8.1",
50
- "@dxos/react-ui-theme": "0.8.1",
51
- "@dxos/storybook-utils": "0.8.1",
52
- "@dxos/react-ui": "0.8.1"
50
+ "@dxos/random": "0.8.2-main.10c050d",
51
+ "@dxos/react-ui-theme": "0.8.2-main.10c050d",
52
+ "@dxos/react-ui": "0.8.2-main.10c050d",
53
+ "@dxos/storybook-utils": "0.8.2-main.10c050d"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "@phosphor-icons/react": "^2.1.5",
56
57
  "effect": "3.13.3",
57
58
  "react": "~18.2.0",
58
59
  "react-dom": "~18.2.0",
59
- "@dxos/react-ui": "0.8.1",
60
- "@dxos/react-ui-theme": "0.8.1"
60
+ "@dxos/react-ui-theme": "0.8.2-main.10c050d",
61
+ "@dxos/react-ui": "0.8.2-main.10c050d"
61
62
  },
62
63
  "publishConfig": {
63
64
  "access": "public"
@@ -26,9 +26,9 @@ const DefaultStory = () => {
26
26
  return (
27
27
  <Accordion.Root<TestItem> items={items} classNames='w-[40rem]'>
28
28
  {({ items }) => (
29
- <div className='flex flex-col w-full border-y border-divider divide-y divide-divider'>
29
+ <div className='flex flex-col w-full border-y border-separator divide-y divide-separator'>
30
30
  {items.map((item) => (
31
- <Accordion.Item key={item.id} item={item} classNames='border-x border-divider'>
31
+ <Accordion.Item key={item.id} item={item} classNames='border-x border-separator'>
32
32
  <Accordion.ItemHeader>{item.name}</Accordion.ItemHeader>
33
33
  <Accordion.ItemBody>
34
34
  <p>{item.text}</p>
@@ -5,10 +5,10 @@
5
5
  import '@dxos-theme';
6
6
 
7
7
  import { type Meta, type StoryObj } from '@storybook/react';
8
+ import { Schema } from 'effect';
8
9
  import React from 'react';
9
10
 
10
- import { S } from '@dxos/echo-schema';
11
- import { create } from '@dxos/live-object';
11
+ import { live } from '@dxos/live-object';
12
12
  import { ghostHover, mx } from '@dxos/react-ui-theme';
13
13
  import { withLayout, withTheme } from '@dxos/storybook-utils';
14
14
  import { arrayMove } from '@dxos/util';
@@ -96,13 +96,13 @@ const SimpleStory = ({ items = [], ...props }: ListRootProps<TestItemType>) => {
96
96
  );
97
97
  };
98
98
 
99
- const list = create(createList(100));
99
+ const list = live(createList(100));
100
100
 
101
101
  export const Default: StoryObj<ListRootProps<TestItemType>> = {
102
102
  render: DefaultStory,
103
103
  args: {
104
104
  items: list.items,
105
- isItem: S.is(TestItemSchema),
105
+ isItem: Schema.is(TestItemSchema),
106
106
  },
107
107
  };
108
108
 
@@ -110,6 +110,6 @@ export const Simple: StoryObj<ListRootProps<TestItemType>> = {
110
110
  render: SimpleStory,
111
111
  args: {
112
112
  items: list.items,
113
- isItem: S.is(TestItemSchema),
113
+ isItem: Schema.is(TestItemSchema),
114
114
  },
115
115
  };
@@ -30,7 +30,7 @@ import { mx } from '@dxos/react-ui-theme';
30
30
 
31
31
  import { useListContext } from './ListRoot';
32
32
 
33
- export type ListItemRecord = {};
33
+ export type ListItemRecord = any;
34
34
 
35
35
  export type ItemDragState =
36
36
  | {
@@ -96,7 +96,7 @@ export const ListItem = <T extends ListItemRecord>({ children, classNames, item,
96
96
  draggable({
97
97
  element,
98
98
  dragHandle: dragHandleRef.current!,
99
- getInitialData: () => item,
99
+ getInitialData: () => item as any,
100
100
  onGenerateDragPreview: dragPreview
101
101
  ? ({ nativeSetDragImage, source }) => {
102
102
  const rect = source.element.getBoundingClientRect();
@@ -104,10 +104,7 @@ export const ListItem = <T extends ListItemRecord>({ children, classNames, item,
104
104
  nativeSetDragImage,
105
105
  getOffset: ({ container }) => {
106
106
  const { height } = container.getBoundingClientRect();
107
- return {
108
- x: 20,
109
- y: height / 2,
110
- };
107
+ return { x: 20, y: height / 2 };
111
108
  },
112
109
  render: ({ container }) => {
113
110
  container.style.width = rect.width + 'px';
@@ -134,10 +131,10 @@ export const ListItem = <T extends ListItemRecord>({ children, classNames, item,
134
131
  dropTargetForElements({
135
132
  element,
136
133
  canDrop: ({ source }) => {
137
- return source.element !== element && isItem(source.data);
134
+ return (source.element !== element && isItem?.(source.data)) ?? false;
138
135
  },
139
136
  getData: ({ input }) => {
140
- return attachClosestEdge(item, { element, input, allowedEdges: ['top', 'bottom'] });
137
+ return attachClosestEdge(item as any, { element, input, allowedEdges: ['top', 'bottom'] });
141
138
  },
142
139
  getIsSticky: () => true,
143
140
  onDragEnter: ({ self }) => {
@@ -15,7 +15,7 @@ type ListContext<T extends ListItemRecord> = {
15
15
  state: ItemDragState & { item?: T };
16
16
  setState: (state: ItemDragState & { item?: T }) => void;
17
17
  dragPreview?: boolean;
18
- isItem: (item: any) => boolean;
18
+ isItem?: (item: any) => boolean;
19
19
  getId?: (item: T) => string; // TODO(burdon): Require if T doesn't conform to type.
20
20
  };
21
21
 
@@ -68,7 +68,7 @@ export const ListRoot = <T extends ListItemRecord>({
68
68
  }
69
69
 
70
70
  return monitorForElements({
71
- canMonitor: ({ source }) => isItem(source.data),
71
+ canMonitor: ({ source }) => isItem?.(source.data) ?? false,
72
72
  onDrop: ({ location, source }) => {
73
73
  const target = location.current.dropTargets[0];
74
74
  if (!target) {
@@ -78,7 +78,7 @@ export const ListRoot = <T extends ListItemRecord>({
78
78
  const sourceData = source.data;
79
79
  const targetData = target.data;
80
80
 
81
- if (!isItem(sourceData) || !isItem(targetData)) {
81
+ if (!isItem?.(sourceData) || !isItem?.(targetData)) {
82
82
  return;
83
83
  }
84
84
 
@@ -2,21 +2,23 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { S } from '@dxos/echo-schema';
5
+ import { Schema } from 'effect';
6
+
7
+ import { ObjectId } from '@dxos/echo-schema';
6
8
  import { faker } from '@dxos/random';
7
9
 
8
- export const TestItemSchema = S.Struct({
9
- id: S.String,
10
- name: S.String,
10
+ export const TestItemSchema = Schema.Struct({
11
+ id: ObjectId,
12
+ name: Schema.String,
11
13
  });
12
14
 
13
- export type TestItemType = S.Schema.Type<typeof TestItemSchema>;
15
+ export type TestItemType = Schema.Schema.Type<typeof TestItemSchema>;
14
16
 
15
- export const TestList = S.Struct({
16
- items: S.mutable(S.Array(TestItemSchema)),
17
+ export const TestList = Schema.Struct({
18
+ items: Schema.mutable(Schema.Array(TestItemSchema)),
17
19
  });
18
20
 
19
- export type TestList = S.Schema.Type<typeof TestList>;
21
+ export type TestList = Schema.Schema.Type<typeof TestList>;
20
22
 
21
23
  export const createList = (n = 10): TestList => ({
22
24
  items: faker.helpers.multiple(
@@ -9,7 +9,7 @@ import { extractInstruction, type Instruction } from '@atlaskit/pragmatic-drag-a
9
9
  import { type Meta, type StoryObj } from '@storybook/react';
10
10
  import React, { useEffect } from 'react';
11
11
 
12
- import { create, type ReactiveObject } from '@dxos/live-object';
12
+ import { live, type Live } from '@dxos/live-object';
13
13
  import { faker } from '@dxos/random';
14
14
  import { Icon } from '@dxos/react-ui';
15
15
  import { withLayout, withTheme } from '@dxos/storybook-utils';
@@ -21,13 +21,13 @@ import { Path } from '../../util';
21
21
 
22
22
  faker.seed(1234);
23
23
 
24
- const tree = create<TestItem>(createTree());
25
- const state = new Map<string, ReactiveObject<{ open: boolean; current: boolean }>>();
24
+ const tree = live<TestItem>(createTree());
25
+ const state = new Map<string, Live<{ open: boolean; current: boolean }>>();
26
26
 
27
- const meta: Meta<typeof Tree> = {
27
+ const meta: Meta<typeof Tree<TestItem>> = {
28
28
  title: 'ui/react-ui-list/Tree',
29
29
  component: Tree,
30
- decorators: [withTheme, withLayout({ tooltips: true })],
30
+ decorators: [withTheme, withLayout()],
31
31
  render: (args) => {
32
32
  useEffect(() => {
33
33
  return monitorForElements({
@@ -57,7 +57,7 @@ const meta: Meta<typeof Tree> = {
57
57
  },
58
58
  args: {
59
59
  id: tree.id,
60
- getItems: (testItem?: TestItem) => {
60
+ useItems: (testItem?: TestItem) => {
61
61
  return testItem?.items ?? tree.items;
62
62
  },
63
63
  getProps: (testItem: TestItem) => ({
@@ -70,7 +70,7 @@ const meta: Meta<typeof Tree> = {
70
70
  }),
71
71
  isOpen: (_path: string[]) => {
72
72
  const path = Path.create(..._path);
73
- const object = state.get(path) ?? create({ open: false, current: false });
73
+ const object = state.get(path) ?? live({ open: false, current: false });
74
74
  if (!state.has(path)) {
75
75
  state.set(path, object);
76
76
  }
@@ -79,7 +79,7 @@ const meta: Meta<typeof Tree> = {
79
79
  },
80
80
  isCurrent: (_path: string[]) => {
81
81
  const path = Path.create(..._path);
82
- const object = state.get(path) ?? create({ open: false, current: false });
82
+ const object = state.get(path) ?? live({ open: false, current: false });
83
83
  if (!state.has(path)) {
84
84
  state.set(path, object);
85
85
  }
@@ -4,20 +4,25 @@
4
4
 
5
5
  import React, { useMemo } from 'react';
6
6
 
7
+ import { type HasId } from '@dxos/echo-schema';
7
8
  import { Treegrid, type TreegridRootProps } from '@dxos/react-ui';
8
9
 
9
10
  import { type TreeContextType, TreeProvider } from './TreeContext';
10
11
  import { TreeItem, type TreeItemProps } from './TreeItem';
11
12
 
12
- export type TreeProps<T = any> = { root?: T; path?: string[]; id: string } & TreeContextType &
13
+ export type TreeProps<T extends HasId = any> = {
14
+ root?: T;
15
+ path?: string[];
16
+ id: string;
17
+ } & TreeContextType<T> &
13
18
  Partial<Pick<TreegridRootProps, 'gridTemplateColumns' | 'classNames'>> &
14
19
  Pick<TreeItemProps<T>, 'draggable' | 'renderColumns' | 'canDrop' | 'onOpenChange' | 'onSelect' | 'levelOffset'>;
15
20
 
16
- export const Tree = <T = any,>({
21
+ export const Tree = <T extends HasId = any>({
17
22
  root,
18
23
  path,
19
24
  id,
20
- getItems,
25
+ useItems,
21
26
  getProps,
22
27
  isOpen,
23
28
  isCurrent,
@@ -32,14 +37,14 @@ export const Tree = <T = any,>({
32
37
  }: TreeProps<T>) => {
33
38
  const context = useMemo(
34
39
  () => ({
35
- getItems,
40
+ useItems,
36
41
  getProps,
37
42
  isOpen,
38
43
  isCurrent,
39
44
  }),
40
- [getItems, getProps, isOpen, isCurrent],
45
+ [useItems, getProps, isOpen, isCurrent],
41
46
  );
42
- const items = getItems(root);
47
+ const items = useItems(root);
43
48
  const treePath = useMemo(() => (path ? [...path, id] : [id]), [id, path]);
44
49
 
45
50
  return (
@@ -19,7 +19,7 @@ export type PropsFromTreeItem = {
19
19
  };
20
20
 
21
21
  export type TreeContextType<T = any> = {
22
- getItems: (parent?: T) => T[];
22
+ useItems: (parent?: T) => T[];
23
23
  getProps: (item: T, parent: string[]) => PropsFromTreeItem;
24
24
  isOpen: (path: string[], item: T) => boolean;
25
25
  isCurrent: (path: string[], item: T) => boolean;
@@ -10,9 +10,10 @@ import {
10
10
  type Instruction,
11
11
  type ItemMode,
12
12
  } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
13
+ import { Schema } from 'effect';
13
14
  import React, { memo, useCallback, useEffect, useMemo, useRef, useState, type FC, type KeyboardEvent } from 'react';
14
15
 
15
- import { S } from '@dxos/echo-schema';
16
+ import { type HasId } from '@dxos/echo-schema';
16
17
  import { invariant } from '@dxos/invariant';
17
18
  import { Treegrid, TreeItem as NaturalTreeItem } from '@dxos/react-ui';
18
19
  import {
@@ -33,17 +34,17 @@ type TreeItemState = 'idle' | 'dragging' | 'preview' | 'parent-of-instruction';
33
34
  const hoverableDescriptionIcons =
34
35
  '[--icons-color:inherit] hover-hover:[--icons-color:var(--description-text)] hover-hover:hover:[--icons-color:inherit] focus-within:[--icons-color:inherit]';
35
36
 
36
- export const TreeDataSchema = S.Struct({
37
- id: S.String,
38
- path: S.Array(S.String),
39
- item: S.Any,
37
+ export const TreeDataSchema = Schema.Struct({
38
+ id: Schema.String,
39
+ path: Schema.Array(Schema.String),
40
+ item: Schema.Any,
40
41
  });
41
42
 
42
- export type TreeData = S.Schema.Type<typeof TreeDataSchema>;
43
+ export type TreeData = Schema.Schema.Type<typeof TreeDataSchema>;
43
44
 
44
- export const isTreeData = (data: unknown): data is TreeData => S.is(TreeDataSchema)(data);
45
+ export const isTreeData = (data: unknown): data is TreeData => Schema.is(TreeDataSchema)(data);
45
46
 
46
- export type TreeItemProps<T = any> = {
47
+ export type TreeItemProps<T extends HasId = any> = {
47
48
  item: T;
48
49
  path: string[];
49
50
  levelOffset?: number;
@@ -61,7 +62,7 @@ export type TreeItemProps<T = any> = {
61
62
  onSelect?: (params: { item: T; path: string[]; current: boolean; option: boolean }) => void;
62
63
  };
63
64
 
64
- export const RawTreeItem = <T = any,>({
65
+ const RawTreeItem = <T extends HasId = any>({
65
66
  item,
66
67
  path: _path,
67
68
  last,
@@ -72,17 +73,6 @@ export const RawTreeItem = <T = any,>({
72
73
  onSelect,
73
74
  levelOffset = 2,
74
75
  }: TreeItemProps<T>) => {
75
- const { getItems, getProps, isOpen, isCurrent } = useTree();
76
- const items = getItems(item);
77
- const { id, label, parentOf, icon, disabled, className, headingClassName, testId } = getProps(item, _path);
78
- const path = useMemo(() => [..._path, id], [_path, id]);
79
- const open = isOpen(path, item);
80
- const current = isCurrent(path, item);
81
- const level = path.length - levelOffset;
82
- const isBranch = !!parentOf;
83
- const mode: ItemMode = last ? 'last-in-group' : open ? 'expanded' : 'standard';
84
- const data = useMemo(() => ({ id, path, item }) satisfies TreeData, [id, path, item]);
85
-
86
76
  const rowRef = useRef<HTMLDivElement | null>(null);
87
77
  const buttonRef = useRef<HTMLButtonElement | null>(null);
88
78
  const openRef = useRef(false);
@@ -91,6 +81,16 @@ export const RawTreeItem = <T = any,>({
91
81
  const [instruction, setInstruction] = useState<Instruction | null>(null);
92
82
  const [menuOpen, setMenuOpen] = useState(false);
93
83
 
84
+ const { useItems, getProps, isOpen, isCurrent } = useTree();
85
+ const items = useItems(item);
86
+ const { id, label, parentOf, icon, disabled, className, headingClassName, testId } = getProps(item, _path);
87
+ const path = useMemo(() => [..._path, id], [_path, id]);
88
+ const open = isOpen(path, item);
89
+ const current = isCurrent(path, item);
90
+ const level = path.length - levelOffset;
91
+ const isBranch = !!parentOf;
92
+ const mode: ItemMode = last ? 'last-in-group' : open ? 'expanded' : 'standard';
93
+
94
94
  const cancelExpand = useCallback(() => {
95
95
  if (cancelExpandRef.current) {
96
96
  clearTimeout(cancelExpandRef.current);
@@ -105,6 +105,8 @@ export const RawTreeItem = <T = any,>({
105
105
 
106
106
  invariant(buttonRef.current);
107
107
 
108
+ const data = { id, path, item } satisfies TreeData;
109
+
108
110
  // https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about
109
111
  return combine(
110
112
  draggable({
@@ -222,7 +224,7 @@ export const RawTreeItem = <T = any,>({
222
224
  aria-labelledby={`${id}__label`}
223
225
  parentOf={parentOf?.join(Treegrid.PARENT_OF_SEPARATOR)}
224
226
  classNames={mx(
225
- 'grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-groupSurface',
227
+ 'grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-activeSurface',
226
228
  hoverableControls,
227
229
  hoverableFocusedKeyboardControls,
228
230
  hoverableFocusedWithinControls,
@@ -26,11 +26,7 @@ export const TreeItemToggle = memo(
26
26
  classNames={mx('is-6 pli-0 dx-focus-ring-inset', hidden ? 'hidden' : !isBranch && 'invisible')}
27
27
  onClick={onToggle}
28
28
  >
29
- <Icon
30
- icon='ph--caret-right--regular'
31
- size={3}
32
- classNames={mx('transition duration-200', open && 'rotate-90')}
33
- />
29
+ <Icon icon='ph--caret-right--bold' size={3} classNames={mx('transition duration-200', open && 'rotate-90')} />
34
30
  </Button>
35
31
  );
36
32
  }),
@@ -3,25 +3,25 @@
3
3
  //
4
4
 
5
5
  import { type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
6
+ import { Schema } from 'effect';
6
7
 
7
- import { S } from '@dxos/echo-schema';
8
+ import { type HasId, ObjectId } from '@dxos/echo-schema';
8
9
  import { log } from '@dxos/log';
9
10
  import { faker } from '@dxos/random';
10
11
 
11
12
  import { type TreeData } from './TreeItem';
12
13
 
13
- export type TestItem = {
14
- id: string;
14
+ export type TestItem = HasId & {
15
15
  name: string;
16
16
  icon?: string;
17
17
  items: TestItem[];
18
18
  };
19
19
 
20
- export const TestItemSchema = S.Struct({
21
- id: S.String,
22
- name: S.String,
23
- icon: S.optional(S.String),
24
- items: S.mutable(S.Array(S.suspend((): S.Schema<TestItem> => TestItemSchema))),
20
+ export const TestItemSchema = Schema.Struct({
21
+ id: ObjectId,
22
+ name: Schema.String,
23
+ icon: Schema.optional(Schema.String),
24
+ items: Schema.mutable(Schema.Array(Schema.suspend((): Schema.Schema<TestItem> => TestItemSchema))),
25
25
  });
26
26
 
27
27
  export const createTree = (n = 4, d = 4): TestItem => ({
package/src/util/path.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- const SEPARATOR = '~';
5
+ const SEPARATOR = '+';
6
6
 
7
7
  export const Path = {
8
8
  create: (...args: string[]) => args.join(SEPARATOR),