@sheinx/base 3.9.7-beta.4 → 3.9.7-beta.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,QAAA,MAAM,IAAI,wHA8ST,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,QAAA,MAAM,IAAI,wHAmTT,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/cjs/tree/tree.js CHANGED
@@ -148,16 +148,23 @@ var Tree = function Tree(props) {
148
148
  return props.height || styleHeight;
149
149
  };
150
150
  var handleUpdateActive = function handleUpdateActive(active, item) {
151
- setActive(active);
152
- if (active !== props.active) {
153
- propSetActive === null || propSetActive === void 0 || propSetActive(active, item);
151
+ var fromUser = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
152
+ if (isActiveControlled && fromUser) {
153
+ // 受控模式下,用户点击时只调用外部回调,不更新内部状态
154
+ if (active !== props.active) {
155
+ propSetActive === null || propSetActive === void 0 || propSetActive(active, item);
156
+ }
157
+ return;
154
158
  }
159
+
160
+ // 其他情况(非受控模式,或受控模式下由 props.active 变化触发),更新内部状态和节点
161
+ setActive(active);
155
162
  datum.updateMap.forEach(function (update, id) {
156
163
  update('active', id === active);
157
164
  });
158
165
  };
159
166
  var handleNodeClick = function handleNodeClick(node, id) {
160
- handleUpdateActive(id, node);
167
+ handleUpdateActive(id, node, true);
161
168
  if (onClick) {
162
169
  onClick(node, id, datum.getPath(id));
163
170
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,QAAA,MAAM,IAAI,wHA8ST,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,QAAA,MAAM,IAAI,wHAmTT,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/esm/tree/tree.js CHANGED
@@ -141,16 +141,23 @@ var Tree = function Tree(props) {
141
141
  return props.height || styleHeight;
142
142
  };
143
143
  var handleUpdateActive = function handleUpdateActive(active, item) {
144
- setActive(active);
145
- if (active !== props.active) {
146
- propSetActive === null || propSetActive === void 0 || propSetActive(active, item);
144
+ var fromUser = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
145
+ if (isActiveControlled && fromUser) {
146
+ // 受控模式下,用户点击时只调用外部回调,不更新内部状态
147
+ if (active !== props.active) {
148
+ propSetActive === null || propSetActive === void 0 || propSetActive(active, item);
149
+ }
150
+ return;
147
151
  }
152
+
153
+ // 其他情况(非受控模式,或受控模式下由 props.active 变化触发),更新内部状态和节点
154
+ setActive(active);
148
155
  datum.updateMap.forEach(function (update, id) {
149
156
  update('active', id === active);
150
157
  });
151
158
  };
152
159
  var handleNodeClick = function handleNodeClick(node, id) {
153
- handleUpdateActive(id, node);
160
+ handleUpdateActive(id, node, true);
154
161
  if (onClick) {
155
162
  onClick(node, id, datum.getPath(id));
156
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.9.7-beta.4",
3
+ "version": "3.9.7-beta.6",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "module": "./esm/index.js",
11
11
  "typings": "./cjs/index.d.ts",
12
12
  "dependencies": {
13
- "@sheinx/hooks": "3.9.7-beta.4",
13
+ "@sheinx/hooks": "3.9.7-beta.6",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.3.3"