@apdesign/web-react 1.4.0 → 1.4.1

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.
@@ -2,12 +2,12 @@ import React from 'react';
2
2
  import Group from './group';
3
3
  import { ButtonProps } from './interface';
4
4
  declare const ButtonComponent: React.ForwardRefExoticComponent<Partial<{
5
- htmlType?: "button" | "reset" | "submit";
6
- } & import("./interface").BaseButtonProps & Omit<React.ButtonHTMLAttributes<any>, "className" | "onClick" | "type"> & {
5
+ htmlType?: "button" | "submit" | "reset";
6
+ } & import("./interface").BaseButtonProps & Omit<React.ButtonHTMLAttributes<any>, "className" | "type" | "onClick"> & {
7
7
  href: string;
8
8
  target?: string;
9
9
  anchorProps?: React.HTMLProps<HTMLAnchorElement>;
10
- } & Omit<React.AnchorHTMLAttributes<any>, "className" | "onClick" | "type">> & React.RefAttributes<unknown>> & {
10
+ } & Omit<React.AnchorHTMLAttributes<any>, "className" | "type" | "onClick">> & React.RefAttributes<unknown>> & {
11
11
  __BYTE_BUTTON: boolean;
12
12
  Group: typeof Group;
13
13
  };
@@ -166,7 +166,9 @@ var useStateValue = function (props, key2nodeProps, indeterminateKeys) {
166
166
  }, [props.onChange, props.labelInValue, props.multiple, props.treeCheckable, props.value]);
167
167
  var confirmSetValue = function () {
168
168
  var onChange = props.onChange, labelInValue = props.labelInValue;
169
- setValue(__spreadArray([], __read(proxyValueCopy.current), false));
169
+ if (!('value' in props)) {
170
+ setValue(__spreadArray([], __read(proxyValueCopy.current), false));
171
+ }
170
172
  var tmp = proxyValueCopy.current.map(function (x) {
171
173
  return labelInValue ? { label: x.label, value: x.value } : x.value;
172
174
  });
@@ -144,10 +144,42 @@ function TreeList(props, ref) {
144
144
  clipPath: 'polygon(12px 50%, 0% 0%, 100% 0%, 100% 100%, 0% 100%)',
145
145
  whiteSpace: 'nowrap',
146
146
  }, onClick: function () {
147
- handleCheck([nodeProps._key], {
147
+ // 为了兼容严格勾选模式,这边改成先清空勾选,再由树组件内部触发勾选,才能准确获取子节点父节点勾选数据
148
+ // onCheck 方法需要在 TreeContext 进行增加renderExtra的参数
149
+ // props.onChange([], {
150
+ // checked: false,
151
+ // trigger: nodeProps,
152
+ // });
153
+ // requestAnimationFrame(() => {
154
+ // onCheck(true, nodeProps._key, e);
155
+ // confirmCheck();
156
+ // });
157
+ // 上面有点UI卡顿体验不好 方案二 手动获取所有勾选的key,自己构造handleCheck参数
158
+ var treeCheckStrictly = props.treeCheckStrictly;
159
+ var checkedKeys;
160
+ var getAllCheckedKeys = function (node, keys) {
161
+ if (keys === void 0) { keys = []; }
162
+ if (Array.isArray(node.childrenData) && node.childrenData.length) {
163
+ node.childrenData.forEach(function (child) {
164
+ getAllCheckedKeys(child, keys);
165
+ });
166
+ }
167
+ else {
168
+ keys.push(node._key);
169
+ }
170
+ return keys;
171
+ };
172
+ if (treeCheckStrictly) {
173
+ checkedKeys = [nodeProps._key];
174
+ }
175
+ else {
176
+ // 找到所有允许勾选的子节点
177
+ checkedKeys = getAllCheckedKeys(nodeProps);
178
+ }
179
+ handleCheck(checkedKeys, {
148
180
  checkedNodes: [],
149
181
  checked: true,
150
- node: { props: nodeProps },
182
+ node: { props: nodeProps }, // 不完整
151
183
  });
152
184
  confirmCheck();
153
185
  } }, (_a = locale.Select) === null || _a === void 0 ? void 0 : _a.filterThisItemOnly), propsRenderExtra === null || propsRenderExtra === void 0 ? void 0 :
@@ -216,8 +216,10 @@ var TreeSelect = function (baseProps, ref) {
216
216
  tryUpdatePopupVisible(false);
217
217
  };
218
218
  var confirmCheck = function () {
219
+ var _a;
219
220
  confirmSetValue();
220
- tryUpdatePopupVisible(false);
221
+ setPopupVisible(false);
222
+ (_a = props.onVisibleChange) === null || _a === void 0 ? void 0 : _a.call(props, false);
221
223
  };
222
224
  var handleRemoveCheckedItem = function (item, index, e) {
223
225
  e.stopPropagation();
package/es/index.d.ts CHANGED
@@ -139,4 +139,4 @@ export type { WatermarkProps } from './Watermark/interface';
139
139
  export { default as Watermark } from './Watermark';
140
140
  export type { ImageProps, ImagePreviewProps, ImagePreviewActionProps, ImagePreviewGroupProps } from './Image/interface';
141
141
  export { default as Image } from './Image';
142
- export declare const version = "1.4.0";
142
+ export declare const version = "1.4.1";
package/es/index.js CHANGED
@@ -69,4 +69,4 @@ export { default as Upload } from './Upload';
69
69
  export { default as Mentions } from './Mentions';
70
70
  export { default as Watermark } from './Watermark';
71
71
  export { default as Image } from './Image';
72
- export var version = '1.4.0';
72
+ export var version = '1.4.1';
@@ -173,7 +173,9 @@ var useStateValue = function (props, key2nodeProps, indeterminateKeys) {
173
173
  }, [props.onChange, props.labelInValue, props.multiple, props.treeCheckable, props.value]);
174
174
  var confirmSetValue = function () {
175
175
  var onChange = props.onChange, labelInValue = props.labelInValue;
176
- setValue(__spreadArray([], __read(proxyValueCopy.current), false));
176
+ if (!('value' in props)) {
177
+ setValue(__spreadArray([], __read(proxyValueCopy.current), false));
178
+ }
177
179
  var tmp = proxyValueCopy.current.map(function (x) {
178
180
  return labelInValue ? { label: x.label, value: x.value } : x.value;
179
181
  });
@@ -168,10 +168,42 @@ function TreeList(props, ref) {
168
168
  clipPath: 'polygon(12px 50%, 0% 0%, 100% 0%, 100% 100%, 0% 100%)',
169
169
  whiteSpace: 'nowrap',
170
170
  }, onClick: function () {
171
- handleCheck([nodeProps._key], {
171
+ // 为了兼容严格勾选模式,这边改成先清空勾选,再由树组件内部触发勾选,才能准确获取子节点父节点勾选数据
172
+ // onCheck 方法需要在 TreeContext 进行增加renderExtra的参数
173
+ // props.onChange([], {
174
+ // checked: false,
175
+ // trigger: nodeProps,
176
+ // });
177
+ // requestAnimationFrame(() => {
178
+ // onCheck(true, nodeProps._key, e);
179
+ // confirmCheck();
180
+ // });
181
+ // 上面有点UI卡顿体验不好 方案二 手动获取所有勾选的key,自己构造handleCheck参数
182
+ var treeCheckStrictly = props.treeCheckStrictly;
183
+ var checkedKeys;
184
+ var getAllCheckedKeys = function (node, keys) {
185
+ if (keys === void 0) { keys = []; }
186
+ if (Array.isArray(node.childrenData) && node.childrenData.length) {
187
+ node.childrenData.forEach(function (child) {
188
+ getAllCheckedKeys(child, keys);
189
+ });
190
+ }
191
+ else {
192
+ keys.push(node._key);
193
+ }
194
+ return keys;
195
+ };
196
+ if (treeCheckStrictly) {
197
+ checkedKeys = [nodeProps._key];
198
+ }
199
+ else {
200
+ // 找到所有允许勾选的子节点
201
+ checkedKeys = getAllCheckedKeys(nodeProps);
202
+ }
203
+ handleCheck(checkedKeys, {
172
204
  checkedNodes: [],
173
205
  checked: true,
174
- node: { props: nodeProps },
206
+ node: { props: nodeProps }, // 不完整
175
207
  });
176
208
  confirmCheck();
177
209
  } }, (_a = locale.Select) === null || _a === void 0 ? void 0 : _a.filterThisItemOnly), propsRenderExtra === null || propsRenderExtra === void 0 ? void 0 :
@@ -240,8 +240,10 @@ var TreeSelect = function (baseProps, ref) {
240
240
  tryUpdatePopupVisible(false);
241
241
  };
242
242
  var confirmCheck = function () {
243
+ var _a;
243
244
  confirmSetValue();
244
- tryUpdatePopupVisible(false);
245
+ setPopupVisible(false);
246
+ (_a = props.onVisibleChange) === null || _a === void 0 ? void 0 : _a.call(props, false);
245
247
  };
246
248
  var handleRemoveCheckedItem = function (item, index, e) {
247
249
  e.stopPropagation();
package/lib/index.d.ts CHANGED
@@ -139,4 +139,4 @@ export type { WatermarkProps } from './Watermark/interface';
139
139
  export { default as Watermark } from './Watermark';
140
140
  export type { ImageProps, ImagePreviewProps, ImagePreviewActionProps, ImagePreviewGroupProps } from './Image/interface';
141
141
  export { default as Image } from './Image';
142
- export declare const version = "1.4.0";
142
+ export declare const version = "1.4.1";
package/lib/index.js CHANGED
@@ -147,4 +147,4 @@ var Watermark_1 = require("./Watermark");
147
147
  Object.defineProperty(exports, "Watermark", { enumerable: true, get: function () { return __importDefault(Watermark_1).default; } });
148
148
  var Image_1 = require("./Image");
149
149
  Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return __importDefault(Image_1).default; } });
150
- exports.version = '1.4.0';
150
+ exports.version = '1.4.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apdesign/web-react",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "AP Design React UI Library.",
5
5
  "module": "./es/index.js",
6
6
  "main": "./lib/index.js",