@dxos/react-ui-list 0.8.4-main.72ec0f3 → 0.8.4-main.7ace549

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-list",
3
- "version": "0.8.4-main.72ec0f3",
3
+ "version": "0.8.4-main.7ace549",
4
4
  "description": "A list component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -30,16 +30,16 @@
30
30
  "@preact/signals-core": "^1.12.1",
31
31
  "@radix-ui/react-accordion": "1.2.3",
32
32
  "@radix-ui/react-context": "1.1.1",
33
- "@dxos/debug": "0.8.4-main.72ec0f3",
34
- "@dxos/echo": "0.8.4-main.72ec0f3",
35
- "@dxos/invariant": "0.8.4-main.72ec0f3",
36
- "@dxos/log": "0.8.4-main.72ec0f3",
37
- "@dxos/react-ui": "0.8.4-main.72ec0f3",
38
- "@dxos/live-object": "0.8.4-main.72ec0f3",
39
- "@dxos/react-ui-theme": "0.8.4-main.72ec0f3",
40
- "@dxos/react-ui-types": "0.8.4-main.72ec0f3",
41
- "@dxos/react-ui-text-tooltip": "0.8.4-main.72ec0f3",
42
- "@dxos/util": "0.8.4-main.72ec0f3"
33
+ "@dxos/echo": "0.8.4-main.7ace549",
34
+ "@dxos/invariant": "0.8.4-main.7ace549",
35
+ "@dxos/live-object": "0.8.4-main.7ace549",
36
+ "@dxos/log": "0.8.4-main.7ace549",
37
+ "@dxos/react-ui": "0.8.4-main.7ace549",
38
+ "@dxos/react-ui-text-tooltip": "0.8.4-main.7ace549",
39
+ "@dxos/react-ui-theme": "0.8.4-main.7ace549",
40
+ "@dxos/react-ui-types": "0.8.4-main.7ace549",
41
+ "@dxos/util": "0.8.4-main.7ace549",
42
+ "@dxos/debug": "0.8.4-main.7ace549"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/react": "~19.2.2",
@@ -48,15 +48,15 @@
48
48
  "react": "~19.2.0",
49
49
  "react-dom": "~19.2.0",
50
50
  "vite": "7.1.9",
51
- "@dxos/random": "0.8.4-main.72ec0f3",
52
- "@dxos/storybook-utils": "0.8.4-main.72ec0f3"
51
+ "@dxos/random": "0.8.4-main.7ace549",
52
+ "@dxos/storybook-utils": "0.8.4-main.7ace549"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "effect": "^3.13.3",
56
56
  "react": "^19.0.0",
57
57
  "react-dom": "^19.0.0",
58
- "@dxos/react-ui": "0.8.4-main.72ec0f3",
59
- "@dxos/react-ui-theme": "0.8.4-main.72ec0f3"
58
+ "@dxos/react-ui": "0.8.4-main.7ace549",
59
+ "@dxos/react-ui-theme": "0.8.4-main.7ace549"
60
60
  },
61
61
  "publishConfig": {
62
62
  "access": "public"
@@ -4,11 +4,11 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { ObjectId } from '@dxos/echo/internal';
7
+ import { Obj } from '@dxos/echo';
8
8
  import { faker } from '@dxos/random';
9
9
 
10
10
  export const TestItemSchema = Schema.Struct({
11
- id: ObjectId,
11
+ id: Obj.ID,
12
12
  name: Schema.String,
13
13
  });
14
14
 
@@ -18,7 +18,14 @@ export type TreeProps<T extends HasId = any, O = any> = {
18
18
  Partial<Pick<TreegridRootProps, 'gridTemplateColumns' | 'classNames'>> &
19
19
  Pick<
20
20
  TreeItemProps<T>,
21
- 'draggable' | 'renderColumns' | 'canDrop' | 'canSelect' | 'onOpenChange' | 'onSelect' | 'levelOffset'
21
+ | 'draggable'
22
+ | 'renderColumns'
23
+ | 'blockInstruction'
24
+ | 'canDrop'
25
+ | 'canSelect'
26
+ | 'onOpenChange'
27
+ | 'onSelect'
28
+ | 'levelOffset'
22
29
  >;
23
30
 
24
31
  export const Tree = <T extends HasId = any, O = any>({
@@ -34,6 +41,7 @@ export const Tree = <T extends HasId = any, O = any>({
34
41
  classNames,
35
42
  levelOffset,
36
43
  renderColumns,
44
+ blockInstruction,
37
45
  canDrop,
38
46
  canSelect,
39
47
  onOpenChange,
@@ -63,6 +71,7 @@ export const Tree = <T extends HasId = any, O = any>({
63
71
  levelOffset={levelOffset}
64
72
  draggable={draggable}
65
73
  renderColumns={renderColumns}
74
+ blockInstruction={blockInstruction}
66
75
  canDrop={canDrop}
67
76
  canSelect={canSelect}
68
77
  onOpenChange={onOpenChange}
@@ -58,6 +58,7 @@ export type TreeItemProps<T extends HasId = any> = {
58
58
  last: boolean;
59
59
  draggable?: boolean;
60
60
  renderColumns?: ColumnRenderer<T>;
61
+ blockInstruction?: (params: { instruction: Instruction; source: TreeData; target: TreeData }) => boolean;
61
62
  canDrop?: (params: { source: TreeData; target: TreeData }) => boolean;
62
63
  canSelect?: (params: { item: T; path: string[] }) => boolean;
63
64
  onOpenChange?: (params: { item: T; path: string[]; open: boolean }) => void;
@@ -71,6 +72,7 @@ const RawTreeItem = <T extends HasId = any>({
71
72
  last,
72
73
  draggable: _draggable,
73
74
  renderColumns: Columns,
75
+ blockInstruction,
74
76
  canDrop,
75
77
  canSelect,
76
78
  onOpenChange,
@@ -149,7 +151,11 @@ const RawTreeItem = <T extends HasId = any>({
149
151
  },
150
152
  getIsSticky: () => true,
151
153
  onDrag: ({ self, source }) => {
152
- const instruction = extractInstruction(self.data);
154
+ const desired = extractInstruction(self.data);
155
+ const block =
156
+ desired && blockInstruction?.({ instruction: desired, source: source.data as TreeData, target: data });
157
+ const instruction: Instruction | null =
158
+ block && desired.type !== 'instruction-blocked' ? { type: 'instruction-blocked', desired } : desired;
153
159
 
154
160
  if (source.data.id !== id) {
155
161
  if (instruction?.type === 'make-child' && isBranch && !open && !cancelExpandRef.current) {
@@ -180,7 +186,7 @@ const RawTreeItem = <T extends HasId = any>({
180
186
  },
181
187
  }),
182
188
  );
183
- }, [_draggable, item, id, mode, path, open, canDrop]);
189
+ }, [_draggable, item, id, mode, path, open, blockInstruction, canDrop]);
184
190
 
185
191
  // Cancel expand on unmount.
186
192
  useEffect(() => () => cancelExpand(), [cancelExpand]);
@@ -279,6 +285,7 @@ const RawTreeItem = <T extends HasId = any>({
279
285
  last={index === items.length - 1}
280
286
  draggable={_draggable}
281
287
  renderColumns={Columns}
288
+ blockInstruction={blockInstruction}
282
289
  canDrop={canDrop}
283
290
  canSelect={canSelect}
284
291
  onOpenChange={onOpenChange}
@@ -5,7 +5,8 @@
5
5
  import { type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
6
6
  import * as Schema from 'effect/Schema';
7
7
 
8
- import { type HasId, ObjectId } from '@dxos/echo/internal';
8
+ import { Obj } from '@dxos/echo';
9
+ import { type HasId } from '@dxos/echo/internal';
9
10
  import { log } from '@dxos/log';
10
11
  import { faker } from '@dxos/random';
11
12
 
@@ -18,7 +19,7 @@ export type TestItem = HasId & {
18
19
  };
19
20
 
20
21
  export const TestItemSchema = Schema.Struct({
21
- id: ObjectId,
22
+ id: Obj.ID,
22
23
  name: Schema.String,
23
24
  icon: Schema.optional(Schema.String),
24
25
  items: Schema.mutable(Schema.Array(Schema.suspend((): Schema.Schema<TestItem> => TestItemSchema))),