@splicetree/plugin-dnd 3.0.1 → 3.0.2

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 (3) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +15 -12
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @splicetree/plugin-dnd
2
2
 
3
+ ## 3.0.2
4
+
3
5
  ## 3.0.1
4
6
 
5
7
  ## 3.0.0
package/README.md CHANGED
@@ -23,7 +23,7 @@ const tree = createSpliceTree(data, {
23
23
  configuration: {
24
24
  dnd: {
25
25
  // 控制可拖拽
26
- disabledDrag: (n) => n.level === 2, // 例如:禁用所有 2 级节点的拖拽
26
+ disabledDrag: n => n.level === 2, // 例如:禁用所有 2 级节点的拖拽
27
27
  // 控制可放置
28
28
  levelMatrix: {
29
29
  // 例如:3 级可以放到 2 级「内」,但 2 级不能放到 1 级「内」
@@ -36,7 +36,9 @@ const tree = createSpliceTree(data, {
36
36
  ],
37
37
  // 完全自定义:覆盖所有规则(高优先级)
38
38
  canDrop: (src, tgt, pos) => {
39
- if (src.id === 'a' && tgt.id === 'b') return false
39
+ if (src.id === 'a' && tgt.id === 'b') {
40
+ return false
41
+ }
40
42
  return true
41
43
  },
42
44
  },
@@ -48,16 +50,16 @@ const tree = createSpliceTree(data, {
48
50
 
49
51
  ### Options
50
52
 
51
- | 选项 | 类型 | 默认值 | 说明 |
52
- | ------------------ | ------------------------------------------------------------ | ------ | -------------------------------------------------------------------- |
53
- | `autoUpdateParent` | `boolean` | `true` | 拖拽后自动更新源节点的父字段;为 `false` 时不写回且不移动 |
54
- | `autoExpandOnDrop` | `boolean` | `true` | 拖入后自动展开目标节点 |
55
- | `readonly` | `boolean` | `false`| 只读模式,禁用拖拽与放置 |
56
- | `reorderOnly` | `boolean` | `false`| 仅允许同层级排序(禁用 `INSIDE` 放入子级) |
57
- | `disabledDrag` | `boolean \| string[] \| (node: DndNode) => boolean` | `无` | 禁用拖拽:布尔、ID 列表或方法 |
58
- | `levelMatrix` | `Record<level, Record<level, { before?: boolean; inside?: boolean; after?: boolean }>>` | `无` | 基于层级的允许矩阵。未显式配置的组合默认允许 |
59
- | `denyDropPairs` | `{ fromId: string; toId: string; positions?: DropPosition[] }[]` | `无` | 显式禁止某些源-目标的放置;未指定 `positions` 时,禁止所有落点 |
60
- | `canDrop` | `(src: DndNode, tgt: DndNode, position: DropPosition) => boolean` | `无` | 自定义总规则(高优先级,返回 `true/false` 覆盖其它规则) |
53
+ | 选项 | 类型 | 默认值 | 说明 |
54
+ | ------------------ | --------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------- |
55
+ | `autoUpdateParent` | `boolean` | `true` | 拖拽后自动更新源节点的父字段;为 `false` 时不写回且不移动 |
56
+ | `autoExpandOnDrop` | `boolean` | `true` | 拖入后自动展开目标节点 |
57
+ | `readonly` | `boolean` | `false` | 只读模式,禁用拖拽与放置 |
58
+ | `reorderOnly` | `boolean` | `false` | 仅允许同层级排序(禁用 `INSIDE` 放入子级) |
59
+ | `disabledDrag` | `boolean \| string[] \| (node: DndNode) => boolean` | `无` | 禁用拖拽:布尔、ID 列表或方法 |
60
+ | `levelMatrix` | `Record<level, Record<level, { before?: boolean; inside?: boolean; after?: boolean }>>` | `无` | 基于层级的允许矩阵。未显式配置的组合默认允许 |
61
+ | `denyDropPairs` | `{ fromId: string; toId: string; positions?: DropPosition[] }[]` | `无` | 显式禁止某些源-目标的放置;未指定 `positions` 时,禁止所有落点 |
62
+ | `canDrop` | `(src: DndNode, tgt: DndNode, position: DropPosition) => boolean` | `无` | 自定义总规则(高优先级,返回 `true/false` 覆盖其它规则) |
61
63
 
62
64
  ### Events
63
65
 
@@ -87,6 +89,7 @@ const tree = createSpliceTree(data, {
87
89
  | `isDisabled()` | `无` | 当前节点是否禁用拖拽 |
88
90
 
89
91
  ## 规则优先级
92
+
90
93
  - `readonly` → 全面禁止
91
94
  - `canDrop` → 优先级最高,返回值直接决定是否允许
92
95
  - `denyDropPairs` → 其次,命中即禁止
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@splicetree/plugin-dnd",
3
3
  "type": "module",
4
- "version": "3.0.1",
4
+ "version": "3.0.2",
5
5
  "author": {
6
6
  "email": "michael.cocova@gmail.com",
7
7
  "name": "Michael Cocova"
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "devDependencies": {
26
- "@splicetree/core": "3.0.1"
26
+ "@splicetree/core": "3.0.2"
27
27
  },
28
28
  "scripts": {
29
29
  "dev": "tsdown --watch",