@unicom-cloud/ui 0.8.92 → 0.8.93

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 +1 @@
1
- {"name":"@unicom-cloud/ui","version":"0.8.92","dependencies":{"@unicom-cloud/icons":"latest"},"peerDependencies":{"dayjs":"^1.11.10","lodash":"^4.17.21","react":"^18.3.1","react-dom":"^18.3.1"},"peerDependenciesMeta":{},"type":"module","types":"types/pc/index.d.ts","main":"./index.js","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
1
+ {"name":"@unicom-cloud/ui","version":"0.8.93","dependencies":{"@unicom-cloud/icons":"latest"},"peerDependencies":{"dayjs":"^1.11.10","lodash":"^4.17.21","react":"^18.3.1","react-dom":"^18.3.1"},"peerDependenciesMeta":{},"type":"module","types":"types/pc/index.d.ts","main":"./index.js","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
package/tree/Node.js CHANGED
@@ -1,35 +1,35 @@
1
- import { jsxs as w, Fragment as q, jsx as s } from "react/jsx-runtime";
1
+ import { jsxs as w, Fragment as q, jsx as r } from "react/jsx-runtime";
2
2
  import z from "@unicom-cloud/icons/IconUiCaretDown";
3
3
  import G from "@unicom-cloud/icons/IconUiDragDotVertical";
4
4
  import J from "@unicom-cloud/icons/IconUiFile";
5
5
  import K from "@unicom-cloud/icons/IconUiLoading";
6
- import u from "lodash/isFunction";
6
+ import m from "lodash/isFunction";
7
7
  import Q, { forwardRef as W, useContext as _, useRef as X, useState as Z, useCallback as I } from "react";
8
8
  import ee from "../checkbox/Checkbox.js";
9
9
  import "../config-provider/ConfigProvider.js";
10
- import ae from "../icon-hover/index.js";
10
+ import ne from "../icon-hover/index.js";
11
11
  import b from "@unicom-cloud/utils/class-name";
12
- import { throttleByRaf as ne } from "../components/common/utils/throttleByRaf.js";
12
+ import { throttleByRaf as ae } from "../components/common/utils/throttleByRaf.js";
13
13
  import ie from "./Animation.js";
14
14
  import { TreeContext as oe } from "./Context.js";
15
15
  import te from "../config-provider/context.js";
16
16
  function re(i, U) {
17
- const a = _(oe), { getPrefixCls: $ } = _(te), x = X(), [t, f] = Z({
17
+ const n = _(oe), { getPrefixCls: $ } = _(te), x = X(), [t, f] = Z({
18
18
  isAllowDrop: !0,
19
19
  isDragOver: !1,
20
20
  dragPosition: 0,
21
21
  isDragging: !1
22
22
  }), {
23
- _key: m = "",
23
+ _key: h = "",
24
24
  title: Y,
25
- icon: O,
26
- checkable: p,
25
+ icon: p,
26
+ checkable: O,
27
27
  selected: F,
28
28
  disabled: N,
29
29
  disableCheckbox: H,
30
30
  isLeaf: P,
31
- draggable: d,
32
- expanded: g,
31
+ draggable: l,
32
+ expanded: d,
33
33
  showLine: v,
34
34
  loading: M,
35
35
  selectable: T = !0
@@ -38,67 +38,67 @@ function re(i, U) {
38
38
  {
39
39
  [`${o}-selected`]: F,
40
40
  [`${o}-is-leaf`]: P,
41
- [`${o}-expanded`]: g,
41
+ [`${o}-expanded`]: d,
42
42
  [`${o}-disabled-selectable`]: !T,
43
43
  [`${o}-disabled`]: N,
44
- [`${o}-draggable`]: d
44
+ [`${o}-draggable`]: l
45
45
  },
46
46
  i.className
47
47
  ), c = (() => {
48
- const e = u(a.icons) ? a.icons(i) : a.icons, n = u(i.icons) ? i.icons(i) : i.icons;
49
- return { ...e, ...n };
48
+ const e = m(n.icons) ? n.icons(i) : n.icons, a = m(i.icons) ? i.icons(i) : i.icons;
49
+ return { ...e, ...a };
50
50
  })(), y = I(
51
51
  (e) => {
52
- var n;
53
- e !== g && ((n = a.onExpand) == null || n.call(a, e, m));
52
+ var a;
53
+ e !== d && ((a = n.onExpand) == null || a.call(n, e, h));
54
54
  },
55
- [g, a.onExpand]
55
+ [d, n.onExpand]
56
56
  ), A = I(async () => {
57
- var r;
58
- const { isLeaf: e, expanded: n } = i;
59
- e || (!((r = i.childrenData) != null && r.length) && u(a.loadMore) && !n ? await a.loadMore(i) : y(!n));
60
- }, [i, y, a.loadMore]), B = () => {
57
+ var s;
58
+ const { isLeaf: e, expanded: a } = i;
59
+ e || (!((s = i.childrenData) != null && s.length) && m(n.loadMore) && !a ? await n.loadMore(i) : y(!a));
60
+ }, [i, y, n.loadMore]), B = () => {
61
61
  if (M)
62
- return "loadingIcon" in c ? c.loadingIcon : /* @__PURE__ */ s(K, {});
63
- let e = null, n = !1;
62
+ return "loadingIcon" in c ? c.loadingIcon : /* @__PURE__ */ r(K, {});
63
+ let e = null, a = !1;
64
64
  if (P)
65
- v && (e = "switcherIcon" in c ? c.switcherIcon : /* @__PURE__ */ s(J, {}), n = !0);
65
+ v && (e = "switcherIcon" in c ? c.switcherIcon : /* @__PURE__ */ r(J, {}), a = !0);
66
66
  else {
67
- const r = v ? /* @__PURE__ */ s("span", { className: `${o}-${g ? "minus" : "plus"}-icon` }) : /* @__PURE__ */ s(z, {});
68
- e = "switcherIcon" in c ? c.switcherIcon : r, n = !v;
67
+ const s = v ? /* @__PURE__ */ r("span", { className: `${o}-${d ? "minus" : "plus"}-icon` }) : /* @__PURE__ */ r(z, {});
68
+ e = "switcherIcon" in c ? c.switcherIcon : s, a = !v;
69
69
  }
70
70
  if (e)
71
- return e = /* @__PURE__ */ s(
71
+ return e = /* @__PURE__ */ r(
72
72
  "span",
73
73
  {
74
74
  className: `${o}-switcher-icon`,
75
- "aria-label": g ? "fold button" : "expand button",
75
+ "aria-label": d ? "fold button" : "expand button",
76
76
  role: "button",
77
77
  tabIndex: 0,
78
78
  onClick: A,
79
79
  children: e
80
80
  }
81
- ), n ? /* @__PURE__ */ s(ae, { prefix: o, children: e }) : e;
82
- }, D = I(
83
- ne((e) => {
84
- var C;
85
- const n = x.current;
86
- if (!n)
81
+ ), a ? /* @__PURE__ */ r(ne, { prefix: o, children: e }) : e;
82
+ }, u = I(
83
+ ae((e) => {
84
+ var R;
85
+ const a = x.current;
86
+ if (!a)
87
87
  return;
88
- const r = n.getBoundingClientRect(), h = window.pageYOffset + r.top, l = e.pageY, L = r.height / 4, R = l - h, k = R < L ? -1 : R < r.height - L ? 0 : 1, V = a.allowDrop(i, k);
88
+ const s = a.getBoundingClientRect(), g = window.pageYOffset + s.top, D = e.pageY, L = s.height / 4, C = D - g, k = C < L ? -1 : C < s.height - L ? 0 : 1, V = n.allowDrop(i, k);
89
89
  f({
90
90
  ...t,
91
91
  isAllowDrop: V,
92
92
  isDragOver: !0,
93
93
  dragPosition: k
94
- }), (C = a.onNodeDragOver) == null || C.call(a, e, i, k);
94
+ }), (R = n.onNodeDragOver) == null || R.call(n, e, i, k);
95
95
  }),
96
- [a.onNodeDragOver]
96
+ [n.onNodeDragOver]
97
97
  );
98
- function E(e, n) {
99
- var l;
100
- const { disableCheckbox: r, disabled: h } = i;
101
- r || h || (l = a.onCheck) == null || l.call(a, e, m, n);
98
+ function E(e, a) {
99
+ var D;
100
+ const { disableCheckbox: s, disabled: g } = i;
101
+ s || g || (D = n.onCheck) == null || D.call(n, e, h, a);
102
102
  }
103
103
  return /* @__PURE__ */ w(q, { children: [
104
104
  /* @__PURE__ */ w(
@@ -109,32 +109,32 @@ function re(i, U) {
109
109
  ref: U,
110
110
  role: "treeitem",
111
111
  "aria-disabled": N,
112
- "aria-expanded": g,
112
+ "aria-expanded": d,
113
113
  "aria-level": i._level,
114
114
  children: [
115
- /* @__PURE__ */ s("span", { className: `${o}-indent`, "aria-hidden": !0, children: [...Array(i._level)].map((e, n) => /* @__PURE__ */ s(
115
+ /* @__PURE__ */ r("span", { className: `${o}-indent`, "aria-hidden": !0, children: [...Array(i._level)].map((e, a) => /* @__PURE__ */ r(
116
116
  "span",
117
117
  {
118
118
  className: b(`${o}-indent-block`, {
119
- [`${o}-indent-block-lineless`]: i._lineless && i._lineless[n]
119
+ [`${o}-indent-block-lineless`]: i._lineless && i._lineless[a]
120
120
  })
121
121
  },
122
- n
122
+ a
123
123
  )) }),
124
- /* @__PURE__ */ s(
124
+ /* @__PURE__ */ r(
125
125
  "span",
126
126
  {
127
127
  className: b(`${o}-switcher`, {
128
- [`${o}-switcher-expanded`]: g
128
+ [`${o}-switcher-expanded`]: d
129
129
  }),
130
130
  children: B()
131
131
  }
132
132
  ),
133
- p ? /* @__PURE__ */ s(
133
+ O ? /* @__PURE__ */ r(
134
134
  ee,
135
135
  {
136
136
  disabled: H || N,
137
- value: m,
137
+ value: h,
138
138
  indeterminate: i.indeterminated,
139
139
  checked: i.checked,
140
140
  onChange: E
@@ -146,7 +146,7 @@ function re(i, U) {
146
146
  "aria-grabbed": t.isDragging,
147
147
  ref: x,
148
148
  className: b(`${o}-title`, {
149
- [`${o}-title-draggable`]: d,
149
+ [`${o}-title-draggable`]: l,
150
150
  [`${o}-title-gap-top`]: t.isDragOver && t.isAllowDrop && t.dragPosition < 0,
151
151
  [`${o}-title-gap-bottom`]: t.isDragOver && t.isAllowDrop && t.dragPosition > 0,
152
152
  [`${o}-title-highlight`]: !t.isDragging && t.isDragOver && t.isAllowDrop && t.dragPosition === 0,
@@ -154,56 +154,56 @@ function re(i, U) {
154
154
  [`${o}-title-block`]: i.blockNode
155
155
  }),
156
156
  onClick: (e) => {
157
- const { onSelect: n, onNodeSelect: r, actionOnClick: h } = a;
157
+ const { onSelect: a, actionOnClick: s } = n;
158
158
  if (!i.disabled) {
159
- const l = [].concat(h);
160
- T && l.indexOf("select") > -1 && (n == null || n(m, e)), l.indexOf("expand") > -1 && A(), p && l.indexOf("check") > -1 && E(!i.checked, e), r == null || r(m, i.dataRef, i);
159
+ const g = [].concat(s);
160
+ T && g.indexOf("select") > -1 && (a == null || a(h, e)), g.indexOf("expand") > -1 && A(), O && g.indexOf("check") > -1 && E(!i.checked, e);
161
161
  }
162
162
  },
163
- draggable: d,
163
+ draggable: l,
164
164
  onDrop: (e) => {
165
- var n;
166
- e.stopPropagation(), e.preventDefault(), (n = a.onNodeDrop) == null || n.call(a, e, i, t.dragPosition), D.cancel(), f({
165
+ var a;
166
+ e.stopPropagation(), e.preventDefault(), (a = n.onNodeDrop) == null || a.call(n, e, i, t.dragPosition), u.cancel(), f({
167
167
  ...t,
168
168
  isDragOver: !1,
169
169
  dragPosition: 0
170
170
  });
171
171
  },
172
172
  onDragStart: (e) => {
173
- var n;
174
- if (d) {
173
+ var a;
174
+ if (l) {
175
175
  e.stopPropagation(), f({ ...t, isDragging: !0 });
176
176
  try {
177
177
  e.dataTransfer.setData("text/plain", "");
178
- } catch (r) {
179
- console.error(r);
178
+ } catch (s) {
179
+ console.error(s);
180
180
  }
181
- (n = a.onNodeDragStart) == null || n.call(a, e, i);
181
+ (a = n.onNodeDragStart) == null || a.call(n, e, i);
182
182
  }
183
183
  },
184
184
  onDragEnd: (e) => {
185
- var n;
186
- d && (e.stopPropagation(), D.cancel(), f({ ...t, isDragOver: !1, isDragging: !1 }), (n = a.onNodeDragEnd) == null || n.call(a, e, i));
185
+ var a;
186
+ l && (e.stopPropagation(), u.cancel(), f({ ...t, isDragOver: !1, isDragging: !1 }), (a = n.onNodeDragEnd) == null || a.call(n, e, i));
187
187
  },
188
188
  onDragOver: (e) => {
189
- e.preventDefault(), e.stopPropagation(), e.persist(), D(e);
189
+ e.preventDefault(), e.stopPropagation(), e.persist(), u(e);
190
190
  },
191
191
  onDragLeave: (e) => {
192
- var n;
193
- d && (e.stopPropagation(), D.cancel(), f({ ...t, isDragOver: !1 }), (n = a.onNodeDragLeave) == null || n.call(a, e, i));
192
+ var a;
193
+ l && (e.stopPropagation(), u.cancel(), f({ ...t, isDragOver: !1 }), (a = n.onNodeDragLeave) == null || a.call(n, e, i));
194
194
  },
195
195
  children: [
196
- O && /* @__PURE__ */ s("span", { className: `${o}-icon ${o}-custom-icon`, children: O }),
197
- /* @__PURE__ */ s("span", { className: `${o}-title-text`, children: u(a.renderTitle) ? a.renderTitle(i) : Y }),
198
- d && /* @__PURE__ */ s("span", { className: `${o}-icon ${o}-drag-icon`, children: "dragIcon" in c ? c.dragIcon : /* @__PURE__ */ s(G, {}) })
196
+ p && /* @__PURE__ */ r("span", { className: `${o}-icon ${o}-custom-icon`, children: p }),
197
+ /* @__PURE__ */ r("span", { className: `${o}-title-text`, children: m(n.renderTitle) ? n.renderTitle(i) : Y }),
198
+ l && /* @__PURE__ */ r("span", { className: `${o}-icon ${o}-drag-icon`, children: "dragIcon" in c ? c.dragIcon : /* @__PURE__ */ r(G, {}) })
199
199
  ]
200
200
  }
201
201
  ),
202
- u(a.renderExtra) && a.renderExtra(i)
202
+ m(n.renderExtra) && n.renderExtra(i)
203
203
  ]
204
204
  }
205
205
  ),
206
- a.animation && /* @__PURE__ */ s(ie, { ...i })
206
+ n.animation && /* @__PURE__ */ r(ie, { ...i })
207
207
  ] });
208
208
  }
209
209
  const S = W(re);
package/tree/Tree.js CHANGED
@@ -50,9 +50,9 @@ const ae = {
50
50
  "animation"
51
51
  ];
52
52
  function Ge(r, fe) {
53
- const g = ve(qe), U = S(null), f = S({}), b = S(), T = S(), M = S(), [a, k] = Te(() => {
54
- var l;
55
- const e = H(), n = $(e, (l = g.getPrefixCls) == null ? void 0 : l.call(g, "tree")), { checkedKeys: c, halfCheckedKeys: t } = R(
53
+ const C = ve(qe), U = S(null), f = S({}), b = S(), T = S(), M = S(), [o, m] = Te(() => {
54
+ var s;
55
+ const e = H(), n = $(e, (s = C.getPrefixCls) == null ? void 0 : s.call(C, "tree")), { checkedKeys: c, halfCheckedKeys: t } = R(
56
56
  r.checkedKeys || r.defaultCheckedKeys || []
57
57
  );
58
58
  return {
@@ -68,11 +68,11 @@ function Ge(r, fe) {
68
68
  nodeList: n
69
69
  };
70
70
  });
71
- function C(e) {
72
- const { componentConfig: n } = g ?? {}, c = e || r, t = (n == null ? void 0 : n.Tree) || {}, l = {};
73
- return Ve.forEach((s) => {
74
- le(c[s]) ? le(t[s]) ? l[s] = Ue[s] : l[s] = t[s] : l[s] = c[s];
75
- }), l;
71
+ function N(e) {
72
+ const { componentConfig: n } = C ?? {}, c = e || r, t = (n == null ? void 0 : n.Tree) || {}, s = {};
73
+ return Ve.forEach((l) => {
74
+ le(c[l]) ? le(t[l]) ? s[l] = Ue[l] : s[l] = t[l] : s[l] = c[l];
75
+ }), s;
76
76
  }
77
77
  function he(e, n) {
78
78
  let c = e;
@@ -99,10 +99,10 @@ function Ge(r, fe) {
99
99
  return e.treeData !== n.treeData || e.children !== n.children || c.some((t) => L(e[t], n[t]));
100
100
  }
101
101
  function V(e) {
102
- const n = C(), { selectable: c } = n, t = {
102
+ const n = N(), { selectable: c } = n, t = {
103
103
  ...ae,
104
104
  ..."treeData" in r ? n.fieldNames : {}
105
- }, l = {
105
+ }, s = {
106
106
  children: E(e, t.children),
107
107
  selectable: q(e, t.selectable) ? E(e, t.selectable) : c,
108
108
  checkable: q(e, t.checkable) ? E(e, t.checkable) : r.checkable,
@@ -112,58 +112,58 @@ function Ge(r, fe) {
112
112
  isLeaf: E(e, t.isLeaf),
113
113
  key: E(e, t.key)
114
114
  };
115
- return q(e, t.key) || delete l.key, l;
115
+ return q(e, t.key) || delete s.key, s;
116
116
  }
117
117
  function $(e, n) {
118
- var y;
118
+ var i;
119
119
  f.current = {};
120
- const c = n || ((y = g.getPrefixCls) == null ? void 0 : y.call(g, "tree")), t = [];
121
- let l = 0;
122
- const { showLine: s, blockNode: d } = C(), i = (_, u) => {
123
- const w = _.length;
124
- return _.map((m, x) => {
120
+ const c = n || ((i = C.getPrefixCls) == null ? void 0 : i.call(C, "tree")), t = [];
121
+ let s = 0;
122
+ const { showLine: l, blockNode: d } = N(), a = (k, u) => {
123
+ const w = k.length;
124
+ return k.map((x, g) => {
125
125
  const {
126
- children: o,
126
+ children: y,
127
127
  selectable: h,
128
128
  checkable: D,
129
- key: N = `${(u == null ? void 0 : u._key) || ""}-${x}`,
129
+ key: _ = `${(u == null ? void 0 : u._key) || ""}-${g}`,
130
130
  ...z
131
- } = V(m), O = {
131
+ } = V(x), O = {
132
132
  // data 中含有 dataRef 时,优先级较高
133
- dataRef: m,
133
+ dataRef: x,
134
134
  draggable: r.draggable,
135
135
  selectable: h,
136
136
  checkable: D,
137
- showLine: s,
137
+ showLine: l,
138
138
  blockNode: d,
139
- ...m,
139
+ ...x,
140
140
  ...z,
141
- key: N,
142
- children: o,
143
- _key: N,
144
- _index: l++,
141
+ key: _,
142
+ children: y,
143
+ _key: _,
144
+ _index: s++,
145
145
  parentKey: u ? u._key : void 0,
146
146
  pathParentKeys: u && u.pathParentKeys || [],
147
147
  _level: u._level || 0,
148
148
  // 保存node在sowLine模式下是否显示缩进线。如果父节点是其所在层级的最后一个节点,那么所有的子节点(包括孙子节点等)在父节点所在层级的缩进格都不显示缩进线。
149
149
  _lineless: u && u._lineless ? [...u._lineless || [], u._isTail] : []
150
150
  };
151
- return w === x + 1 && (O.className = de(
151
+ return w === g + 1 && (O.className = de(
152
152
  `${c}-node-is-tail`,
153
153
  O.className
154
- )), t.push(O), f.current[N] = O, o && o.length && (f.current[N].children = i(o, {
155
- _key: N,
154
+ )), t.push(O), f.current[_] = O, y && y.length && (f.current[_].children = a(y, {
155
+ _key: _,
156
156
  _level: O._level + 1,
157
157
  _lineless: O._lineless,
158
- _isTail: w === x + 1,
159
- pathParentKeys: [...(u == null ? void 0 : u.pathParentKeys) || [], N]
158
+ _isTail: w === g + 1,
159
+ pathParentKeys: [...(u == null ? void 0 : u.pathParentKeys) || [], _]
160
160
  })), O;
161
161
  });
162
162
  };
163
- return i(e || [], {}), t;
163
+ return a(e || [], {}), t;
164
164
  }
165
165
  function G(e) {
166
- if (!C().autoExpandParent)
166
+ if (!N().autoExpandParent)
167
167
  return e || [];
168
168
  if (!e)
169
169
  return Object.keys(f.current).filter((c) => {
@@ -173,8 +173,8 @@ function Ge(r, fe) {
173
173
  const n = {};
174
174
  return e.forEach((c) => {
175
175
  const t = f.current[c];
176
- t && (n[c] = 1, t.pathParentKeys && t.pathParentKeys.forEach((l) => {
177
- n[l] = 1;
176
+ t && (n[c] = 1, t.pathParentKeys && t.pathParentKeys.forEach((s) => {
177
+ n[s] = 1;
178
178
  }));
179
179
  }), Object.keys(n);
180
180
  }
@@ -195,84 +195,84 @@ function Ge(r, fe) {
195
195
  };
196
196
  }
197
197
  function ke(e, n) {
198
- var l;
199
- const { onSelect: c } = r, t = {
198
+ var l, d;
199
+ const { onSelect: c } = r, t = (l = f.current[e]) == null ? void 0 : l.dataRef, s = {
200
200
  e: n,
201
- data: (l = f.current[e]) == null ? void 0 : l.dataRef,
201
+ data: t,
202
202
  // 潘启宝添加
203
203
  node: K([e])[0]
204
204
  };
205
205
  if (r.multiple) {
206
- const s = [...a.selectedKeys], d = s.indexOf(e);
207
- d > -1 ? (s.splice(d, 1), t.selected = !1) : (t.selected = !0, s.push(e)), t.selectedNodes = K(s), "selectedKeys" in r || k((i) => {
208
- const y = { ...i };
209
- return y.selectedKeys = s, y;
210
- }), c == null || c(s, t);
206
+ const a = [...o.selectedKeys], i = a.indexOf(e);
207
+ i > -1 ? (a.splice(i, 1), s.selected = !1) : (s.selected = !0, a.push(e)), s.selectedNodes = K(a), "selectedKeys" in r || m((k) => {
208
+ const u = { ...k };
209
+ return u.selectedKeys = a, u;
210
+ }), c == null || c(a, s);
211
211
  } else
212
- t.selected = !0, t.selectedNodes = K([e]), "selectedKeys" in r || k((s) => {
213
- const d = { ...s };
214
- return d.selectedKeys = [e], d;
215
- }), c == null || c([e], t);
212
+ s.selected = !0, s.selectedNodes = K([e]), "selectedKeys" in r || m((a) => {
213
+ const i = { ...a };
214
+ return i.selectedKeys = [e], i;
215
+ }), c == null || c([e], s);
216
+ (d = r.onNodeSelect) == null || d.call(r, e, t, s);
216
217
  }
217
218
  function J(e, n, c) {
218
219
  var u, w;
219
- const { checkedStrategy: t } = C(), { onCheck: l, checkStrictly: s } = r, d = { e: c, node: K([n])[0] };
220
- let i = [...a.checkedKeys || []], y = a.halfCheckedKeys;
221
- if (s) {
222
- e ? i = i.concat(n) : i = i.filter((x) => x !== n);
223
- const m = {};
224
- "checkedKeys" in r || (m.checkedKeys = i), "halfCheckedKeys" in r || (m.halfCheckedKeys = y), Me(m) || k((x) => ({ ...x, ...m }));
220
+ const { checkedStrategy: t } = N(), { onCheck: s, checkStrictly: l } = r, d = (u = f.current[n]) == null ? void 0 : u.dataRef, a = { e: c, node: K([n])[0] };
221
+ let i = [...o.checkedKeys || []], k = o.halfCheckedKeys;
222
+ if (l) {
223
+ e ? i = i.concat(n) : i = i.filter((g) => g !== n);
224
+ const x = {};
225
+ "checkedKeys" in r || (x.checkedKeys = i), "halfCheckedKeys" in r || (x.halfCheckedKeys = k), Me(x) || m((g) => ({ ...g, ...x }));
225
226
  } else {
226
- const { checkedKeys: m, indeterminateKeys: x } = Be(
227
+ const { checkedKeys: x, indeterminateKeys: g } = Be(
227
228
  n,
228
229
  e,
229
230
  i,
230
231
  f.current,
231
- y
232
+ k
232
233
  );
233
- i = m, y = x, "checkedKeys" in r ? k((o) => {
234
- const h = { ...o };
235
- return h.halfCheckedKeys = y, h;
236
- }) : k((o) => {
237
- const h = { ...o };
238
- return h.checkedKeys = i, h.halfCheckedKeys = y, h;
239
- }), t === oe ? i = i.filter((o) => {
240
- const h = f.current[o];
234
+ i = x, k = g, "checkedKeys" in r ? m((y) => {
235
+ const h = { ...y };
236
+ return h.halfCheckedKeys = k, h;
237
+ }) : m((y) => {
238
+ const h = { ...y };
239
+ return h.checkedKeys = i, h.halfCheckedKeys = k, h;
240
+ }), t === oe ? i = i.filter((y) => {
241
+ const h = f.current[y];
241
242
  if (!h || i.indexOf(h.parentKey) === -1)
242
243
  return !0;
243
- }) : t === ue && (i = i.filter((o) => {
244
- var D, N;
245
- const h = f.current[o];
246
- if (!h || !((D = h.children) != null && D.length) || (N = h.children) != null && N.every((z) => i.indexOf(z._key) === -1))
244
+ }) : t === ue && (i = i.filter((y) => {
245
+ var D, _;
246
+ const h = f.current[y];
247
+ if (!h || !((D = h.children) != null && D.length) || (_ = h.children) != null && _.every((z) => i.indexOf(z._key) === -1))
247
248
  return !0;
248
249
  }));
249
250
  }
250
- const _ = (u = f.current[n]) == null ? void 0 : u.dataRef;
251
- l == null || l(i, {
252
- data: _,
253
- // 潘启宝添加
251
+ s == null || s(i, {
254
252
  checkedNodes: K(i),
255
253
  checked: e,
256
- halfCheckedKeys: y,
257
- halfCheckedNodes: K(y),
258
- ...d
259
- }), (w = r.onNodeCheck) == null || w.call(r, n, _, d);
254
+ halfCheckedKeys: k,
255
+ halfCheckedNodes: K(k),
256
+ data: d,
257
+ // 潘启宝添加
258
+ ...a
259
+ }), (w = r.onNodeCheck) == null || w.call(r, n, d, a);
260
260
  }
261
261
  function me(e) {
262
262
  if ($e(r.loadMore)) {
263
- const { loadingKeys: n = [], loadedKeys: c } = a;
264
- k((t) => {
265
- const l = { ...t };
266
- return l.loadingKeys = Array.from(/* @__PURE__ */ new Set([...n, e._key])), l.loadedKeys = c.filter((s) => s !== e._key), l;
263
+ const { loadingKeys: n = [], loadedKeys: c } = o;
264
+ m((t) => {
265
+ const s = { ...t };
266
+ return s.loadingKeys = Array.from(/* @__PURE__ */ new Set([...n, e._key])), s.loadedKeys = c.filter((l) => l !== e._key), s;
267
267
  }), I == null || I(K([e._key])[0]).then((t) => {
268
- k((l) => {
269
- const s = { ...l };
270
- return s.loadingKeys = l.loadingKeys.filter((d) => d !== e._key), s.loadedKeys = Array.from(/* @__PURE__ */ new Set([...l.loadedKeys, e._key])), s;
268
+ m((s) => {
269
+ const l = { ...s };
270
+ return l.loadingKeys = s.loadingKeys.filter((d) => d !== e._key), l.loadedKeys = Array.from(/* @__PURE__ */ new Set([...s.loadedKeys, e._key])), l;
271
271
  }), W(!e.expanded, e._key);
272
272
  }).catch((t) => {
273
- k((l) => {
274
- const s = { ...l };
275
- return s.loadingKeys = l.loadingKeys.filter((d) => d !== e._key), s;
273
+ m((s) => {
274
+ const l = { ...s };
275
+ return l.loadingKeys = s.loadingKeys.filter((d) => d !== e._key), l;
276
276
  }), console.error("[tree]load data error: ", t);
277
277
  }).finally(() => {
278
278
  });
@@ -301,12 +301,12 @@ function Ge(r, fe) {
301
301
  function _e(e, n) {
302
302
  let c = f.current[e.parentKey];
303
303
  for (; c; ) {
304
- const { _key: t, parentKey: l } = c;
304
+ const { _key: t, parentKey: s } = c;
305
305
  if (t === n.props._key)
306
306
  return !0;
307
- if (l === t)
307
+ if (s === t)
308
308
  return;
309
- c = f.current[l];
309
+ c = f.current[s];
310
310
  }
311
311
  }
312
312
  function Q(e, n) {
@@ -317,22 +317,22 @@ function Ge(r, fe) {
317
317
  const c = e.key, t = n.key;
318
318
  if (c !== void 0 || t !== void 0)
319
319
  return c === t;
320
- const l = e.props._key, s = n.props._key;
321
- return l === void 0 && s === void 0 ? !1 : l === s;
320
+ const s = e.props._key, l = n.props._key;
321
+ return s === void 0 && l === void 0 ? !1 : s === l;
322
322
  }
323
323
  function X(e, n, c) {
324
324
  if (b.current) {
325
- const { allowDrop: t } = C(), { onDrop: l } = r, s = K([n._key])[0];
326
- if (l && !_e(n, b.current) && !Q(b.current, s)) {
325
+ const { allowDrop: t } = N(), { onDrop: s } = r, l = K([n._key])[0];
326
+ if (s && !_e(n, b.current) && !Q(b.current, l)) {
327
327
  if (t && !t({
328
- dropNode: s,
328
+ dropNode: l,
329
329
  dragNode: b.current,
330
330
  dropPosition: c
331
331
  }))
332
332
  return;
333
- l({
333
+ s({
334
334
  dragNode: b.current,
335
- dropNode: s,
335
+ dropNode: l,
336
336
  dropPosition: c,
337
337
  e
338
338
  });
@@ -340,7 +340,7 @@ function Ge(r, fe) {
340
340
  }
341
341
  }
342
342
  function Y(e, n) {
343
- const { allowDrop: c } = C();
343
+ const { allowDrop: c } = N();
344
344
  let t = !0;
345
345
  return typeof c == "function" && (t = c({
346
346
  dropNode: K([e._key])[0],
@@ -349,14 +349,14 @@ function Ge(r, fe) {
349
349
  })), t;
350
350
  }
351
351
  function W(e, n) {
352
- const { currentExpandKeys: c, expandedKeys: t = [] } = a, { animation: l } = C(), { onExpand: s } = r;
352
+ const { currentExpandKeys: c, expandedKeys: t = [] } = o, { animation: s } = N(), { onExpand: l } = r;
353
353
  if (c.indexOf(n) > -1)
354
354
  return;
355
355
  let d = [];
356
- e ? d = Array.from(/* @__PURE__ */ new Set([...t, n])) : d = t.filter((i) => i !== n), "expandedKeys" in r || k((i) => {
357
- const y = { ...i };
358
- return y.expandedKeys = d, y.currentExpandKeys = l ? [...c, n] : [], y;
359
- }), s == null || s(d, {
356
+ e ? d = Array.from(/* @__PURE__ */ new Set([...t, n])) : d = t.filter((a) => a !== n), "expandedKeys" in r || m((a) => {
357
+ const i = { ...a };
358
+ return i.expandedKeys = d, i.currentExpandKeys = s ? [...c, n] : [], i;
359
+ }), l == null || l(d, {
360
360
  expanded: e,
361
361
  node: K([n])[0],
362
362
  expandedNodes: K(d)
@@ -373,60 +373,60 @@ function Ge(r, fe) {
373
373
  }
374
374
  function j(e) {
375
375
  return {
376
- expandedKeysSet: (e == null ? void 0 : e.expandedKeysSet) || new Set((a == null ? void 0 : a.expandedKeys) || []),
377
- checkedKeysSet: (e == null ? void 0 : e.checkedKeysSet) || new Set((a == null ? void 0 : a.checkedKeys) || []),
378
- selectedKeysSet: (e == null ? void 0 : e.selectedKeysSet) || new Set((a == null ? void 0 : a.selectedKeys) || []),
379
- halfCheckedKeysSet: (e == null ? void 0 : e.halfCheckedKeysSet) || new Set((a == null ? void 0 : a.halfCheckedKeys) || [])
376
+ expandedKeysSet: (e == null ? void 0 : e.expandedKeysSet) || new Set((o == null ? void 0 : o.expandedKeys) || []),
377
+ checkedKeysSet: (e == null ? void 0 : e.checkedKeysSet) || new Set((o == null ? void 0 : o.checkedKeys) || []),
378
+ selectedKeysSet: (e == null ? void 0 : e.selectedKeysSet) || new Set((o == null ? void 0 : o.selectedKeys) || []),
379
+ halfCheckedKeysSet: (e == null ? void 0 : e.halfCheckedKeysSet) || new Set((o == null ? void 0 : o.halfCheckedKeys) || [])
380
380
  };
381
381
  }
382
382
  function A(e, n) {
383
- const { autoExpandParent: c } = C(), { loadMore: t } = r, {
384
- selectedKeys: l,
385
- expandedKeys: s,
383
+ const { autoExpandParent: c } = N(), { loadMore: t } = r, {
384
+ selectedKeys: s,
385
+ expandedKeys: l,
386
386
  checkedKeys: d,
387
- loadingKeys: i = [],
388
- loadedKeys: y = []
389
- } = a, {
390
- expandedKeysSet: _,
387
+ loadingKeys: a = [],
388
+ loadedKeys: i = []
389
+ } = o, {
390
+ expandedKeysSet: k,
391
391
  checkedKeysSet: u,
392
392
  selectedKeysSet: w,
393
- halfCheckedKeysSet: m
394
- } = j(n), x = (o) => {
395
- const h = o.children && o.children.length, D = {
393
+ halfCheckedKeysSet: x
394
+ } = j(n), g = (y) => {
395
+ const h = y.children && y.children.length, D = {
396
396
  isLeaf: !h,
397
397
  autoExpandParent: h ? c : !1,
398
- expanded: _ ? _.has(o._key) : s.indexOf(o._key) > -1
398
+ expanded: k ? k.has(y._key) : l.indexOf(y._key) > -1
399
399
  };
400
400
  if (t) {
401
- const N = y.indexOf(o._key) > -1;
402
- D.loaded = N, D.isLeaf = h ? !1 : o.isLeaf;
401
+ const _ = i.indexOf(y._key) > -1;
402
+ D.loaded = _, D.isLeaf = h ? !1 : y.isLeaf;
403
403
  }
404
404
  return {
405
- ...o,
405
+ ...y,
406
406
  ...D,
407
- selected: w.has(o._key),
408
- indeterminated: m.has(o._key),
409
- loading: i.indexOf(o._key) > -1,
410
- checked: u.has(o._key),
411
- selectedKeys: l,
407
+ selected: w.has(y._key),
408
+ indeterminated: x.has(y._key),
409
+ loading: a.indexOf(y._key) > -1,
410
+ checked: u.has(y._key),
411
+ selectedKeys: s,
412
412
  checkedKeys: d,
413
- loadingKeys: i,
414
- loadedKeys: y,
415
- expandedKeys: s,
416
- childrenData: o.children || [],
413
+ loadingKeys: a,
414
+ loadedKeys: i,
415
+ expandedKeys: l,
416
+ childrenData: y.children || [],
417
417
  children: null
418
418
  };
419
419
  };
420
- return He(e) ? e.map((o) => x(o)) : x(e);
420
+ return He(e) ? e.map((y) => g(y)) : g(e);
421
421
  }
422
422
  function Z(e) {
423
- k((n) => {
423
+ m((n) => {
424
424
  const c = { ...n }, { currentExpandKeys: t } = n;
425
- return t.indexOf(e) > -1 && (c.currentExpandKeys = t.filter((l, s, d) => l !== e)), c;
425
+ return t.indexOf(e) > -1 && (c.currentExpandKeys = t.filter((s, l, d) => s !== e)), c;
426
426
  });
427
427
  }
428
428
  function p() {
429
- return a;
429
+ return o;
430
430
  }
431
431
  Ae(fe, () => ({
432
432
  scrollIntoView: he,
@@ -441,49 +441,49 @@ function Ge(r, fe) {
441
441
  handleNodeDrop: X,
442
442
  isSameNode: Q
443
443
  })), B(() => {
444
- const e = U.current, n = C(e), c = C();
444
+ const e = U.current, n = N(e), c = N();
445
445
  if (e !== r || !L(n, c)) {
446
446
  const t = {};
447
447
  if (Ke(
448
448
  { prevMergedProps: n, ...e },
449
449
  { ...c, ...r }
450
450
  )) {
451
- const s = H(), d = $(s);
452
- t.treeData = s, t.nodeList = d;
451
+ const l = H(), d = $(l);
452
+ t.treeData = l, t.nodeList = d;
453
453
  }
454
454
  if (t.treeData || "checkedKeys" in r && !L(e == null ? void 0 : e.checkedKeys, r.checkedKeys)) {
455
- const s = "checkedKeys" in r ? r.checkedKeys : a.checkedKeys, { halfCheckedKeys: d, checkedKeys: i } = R(
456
- s || []
455
+ const l = "checkedKeys" in r ? r.checkedKeys : o.checkedKeys, { halfCheckedKeys: d, checkedKeys: a } = R(
456
+ l || []
457
457
  );
458
- L(i, a.checkedKeys) || (t.checkedKeys = i), L(d, a.halfCheckedKeys) || (t.halfCheckedKeys = d);
458
+ L(a, o.checkedKeys) || (t.checkedKeys = a), L(d, o.halfCheckedKeys) || (t.halfCheckedKeys = d);
459
459
  }
460
- r.checkStrictly && "halfCheckedKeys" in r && !L(e == null ? void 0 : e.halfCheckedKeys, r.halfCheckedKeys) && (t.halfCheckedKeys = r.halfCheckedKeys), "expandedKeys" in r && !L(r.expandedKeys, e == null ? void 0 : e.expandedKeys) && (t.expandedKeys = r.expandedKeys, t.currentExpandKeys = c.animation ? [...t.expandedKeys ?? [], ...a.expandedKeys ?? []].reduce((s, d) => {
461
- const i = s.indexOf(d);
462
- return i === -1 ? s.push(d) : s.splice(i, 1), s;
463
- }, []).filter((s, d, i) => {
464
- var y;
465
- if (f.current[s])
466
- return f.current[s].pathParentKeys.some((u) => i.indexOf(u) > -1) ? !1 : (y = f.current[s].children) == null ? void 0 : y.length;
460
+ r.checkStrictly && "halfCheckedKeys" in r && !L(e == null ? void 0 : e.halfCheckedKeys, r.halfCheckedKeys) && (t.halfCheckedKeys = r.halfCheckedKeys), "expandedKeys" in r && !L(r.expandedKeys, e == null ? void 0 : e.expandedKeys) && (t.expandedKeys = r.expandedKeys, t.currentExpandKeys = c.animation ? [...t.expandedKeys ?? [], ...o.expandedKeys ?? []].reduce((l, d) => {
461
+ const a = l.indexOf(d);
462
+ return a === -1 ? l.push(d) : l.splice(a, 1), l;
463
+ }, []).filter((l, d, a) => {
464
+ var i;
465
+ if (f.current[l])
466
+ return f.current[l].pathParentKeys.some((u) => a.indexOf(u) > -1) ? !1 : (i = f.current[l].children) == null ? void 0 : i.length;
467
467
  }) : []);
468
- const l = t.currentExpandKeys || a.currentExpandKeys;
469
- t.treeData && l && (t.currentExpandKeys = l.filter((s) => {
470
- const d = t.treeData.find((i) => i.key === s);
468
+ const s = t.currentExpandKeys || o.currentExpandKeys;
469
+ t.treeData && s && (t.currentExpandKeys = s.filter((l) => {
470
+ const d = t.treeData.find((a) => a.key === l);
471
471
  return d && d.children && d.children.length;
472
- })), Object.keys(t).length && k((s) => ({ ...s, ...t }));
472
+ })), Object.keys(t).length && m((l) => ({ ...l, ...t }));
473
473
  }
474
474
  return U.current = r, () => {
475
475
  };
476
- }), B(() => ("selectedKeys" in r && !L(r.selectedKeys, a.selectedKeys) && k((e) => {
476
+ }), B(() => ("selectedKeys" in r && !L(r.selectedKeys, o.selectedKeys) && m((e) => {
477
477
  const n = { ...e };
478
478
  return n.selectedKeys = r.selectedKeys || [], n;
479
479
  }), () => {
480
- }), [r.selectedKeys, a.selectedKeys]), B(() => {
481
- var l;
482
- const e = H(), n = $(e, (l = g.getPrefixCls) == null ? void 0 : l.call(g, "tree")), { checkedKeys: c, halfCheckedKeys: t } = R(
480
+ }), [r.selectedKeys, o.selectedKeys]), B(() => {
481
+ var s;
482
+ const e = H(), n = $(e, (s = C.getPrefixCls) == null ? void 0 : s.call(C, "tree")), { checkedKeys: c, halfCheckedKeys: t } = R(
483
483
  r.checkedKeys || r.defaultCheckedKeys || []
484
484
  );
485
- return k((s) => {
486
- let d = { ...s };
485
+ return m((l) => {
486
+ let d = { ...l };
487
487
  return d = {
488
488
  ...d,
489
489
  selectedKeys: r.selectedKeys || r.defaultSelectedKeys || [],
@@ -510,12 +510,12 @@ function Ge(r, fe) {
510
510
  icons: Le,
511
511
  actionOnClick: we,
512
512
  animation: ce
513
- } = C(), { loadMore: I, checkable: Oe } = r, re = te ? {
513
+ } = N(), { loadMore: I, checkable: Oe } = r, re = te ? {
514
514
  threshold: 100,
515
515
  ...te
516
516
  } : ne ? { height: ne, threshold: 100 } : {
517
517
  threshold: null
518
- }, { getPrefixCls: F, rtl: Pe } = g, P = F == null ? void 0 : F("tree");
518
+ }, { getPrefixCls: F, rtl: Pe } = C, P = F == null ? void 0 : F("tree");
519
519
  return /* @__PURE__ */ se(
520
520
  We.Provider,
521
521
  {
@@ -541,11 +541,7 @@ function Ge(r, fe) {
541
541
  loadMore: I && me,
542
542
  allowDrop: Y,
543
543
  actionOnClick: we,
544
- virtualListProps: re,
545
- onNodeSelect(e, n, c) {
546
- var t;
547
- (t = r.onNodeSelect) == null || t.call(r, e, n, c);
548
- }
544
+ virtualListProps: re
549
545
  },
550
546
  children: /* @__PURE__ */ se(
551
547
  je,
@@ -566,11 +562,11 @@ function Ge(r, fe) {
566
562
  style: Ee,
567
563
  filterNode: r.filterNode,
568
564
  virtualListProps: re,
569
- expandedKeys: a.expandedKeys,
570
- currentExpandKeys: a.currentExpandKeys,
565
+ expandedKeys: o.expandedKeys,
566
+ currentExpandKeys: o.currentExpandKeys,
571
567
  getNodeProps: A,
572
568
  getDataSet: j,
573
- nodeList: a.nodeList,
569
+ nodeList: o.nodeList,
574
570
  onMouseDown: r.onMouseDown,
575
571
  ariaProps: {
576
572
  role: "tree",
@@ -25,5 +25,4 @@ export declare const TreeContext: import("react").Context<{
25
25
  onNodeDragLeave?: (e: DragEvent<HTMLSpanElement>, nodeProps: NodeProps) => void;
26
26
  allowDrop?: (nodeProps: NodeProps, dragPosition: 0 | 1 | -1) => boolean;
27
27
  getFieldInfo?: (nodeProps: NodeProps) => TreeDataType;
28
- onNodeSelect?: (key: string, data: unknown, extra: unknown) => void;
29
28
  }>;
package/version/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const I = "2025-06-03 17:30:11", t = "1748943011139", E = "2.66.0";
1
+ const I = "2025-06-03 17:59:19", t = "1748944759600", E = "2.66.0";
2
2
  export {
3
3
  E as VERSION,
4
4
  I as VERSION_BUILD_DATE,