@apdesign/web-react 1.4.0 → 1.4.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.
@@ -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
  };
package/es/Modal/modal.js CHANGED
@@ -212,12 +212,10 @@ function Modal(baseProps, ref) {
212
212
  (closeIcon !== undefined ? (React.createElement("span", { onClick: onCancel, className: prefixCls + "-close-icon" }, closeIcon)) : (React.createElement(IconHover, { tabIndex: -1, onClick: onCancel, className: prefixCls + "-close-icon", role: "button", "aria-label": "Close" },
213
213
  React.createElement(IconClose, null))))));
214
214
  var ariaProps = title ? { 'aria-labelledby': "arco-dialog-" + dialogIndex.current } : {};
215
- // 将绑定到弹窗的尺寸相关样式移到上层div
216
- var _h = style || {}, width = _h.width, height = _h.height, restStyle = __rest(_h, ["width", "height"]);
217
215
  var modalDom = (React.createElement("div", __assign({ role: "dialog", "aria-modal": "true" }, ariaProps, { className: cs(prefixCls, (_a = {},
218
216
  _a[prefixCls + "-simple"] = simple,
219
217
  _a[prefixCls + "-rtl"] = rtl,
220
- _a), className), style: __assign(__assign({ display: draggable ? 'block' : null }, restStyle), { width: draggable ? '100%' : width, height: draggable ? '100%' : height }), ref: modalRef }), innerFocusLock ? (React.createElement(FocusLock, { crossFrame: false, disabled: !visible, autoFocus: innerAutoFocus, lockProps: {
218
+ _a), className), style: style, ref: modalRef }), innerFocusLock ? (React.createElement(FocusLock, { crossFrame: false, disabled: !visible, autoFocus: innerAutoFocus, lockProps: {
221
219
  tabIndex: -1,
222
220
  onKeyDown: onEscExit,
223
221
  } }, element)) : (React.createElement(React.Fragment, null, element))));
@@ -230,8 +228,7 @@ function Modal(baseProps, ref) {
230
228
  },
231
229
  });
232
230
  // 包装在Draggable中的modal
233
- var wrappedModalDom = draggable && title ? (React.createElement(Draggable, __assign({ bounds: "parent", handle: "." + prefixCls + "-header" }, draggableProps),
234
- React.createElement("div", { style: { top: 0, verticalAlign: 'middle', display: 'inline-block', width: width, height: height } }, modalWithMouseEventsDom))) : (modalWithMouseEventsDom);
231
+ var wrappedModalDom = draggable && title ? (React.createElement(Draggable, __assign({ bounds: "parent", handle: "." + prefixCls + "-header" }, draggableProps), modalWithMouseEventsDom)) : (modalWithMouseEventsDom);
235
232
  var setTransformOrigin = function (e) {
236
233
  if (haveOriginTransformOrigin.current)
237
234
  return;
@@ -52,7 +52,7 @@ import Trigger from '../Trigger';
52
52
  import OptGroup from './opt-group';
53
53
  import Option from './option';
54
54
  import ResizeObserver from '../_util/resizeObserver';
55
- import { isArray, isFunction, isNullOrUndefined, isObject } from '../_util/is';
55
+ import { isArray, isFunction, isObject } from '../_util/is';
56
56
  import getHotkeyHandler from '../_util/getHotkeyHandler';
57
57
  import warning from '../_util/warning';
58
58
  import SelectView from '../_class/select-view';
@@ -217,18 +217,14 @@ function Select(baseProps, ref) {
217
217
  }, [isMultipleMode, value]);
218
218
  useEffect(function () {
219
219
  if (isMultipleQuickSelectMode) {
220
- // 判断 props.value 之前有值现在被手动设置为 undefined 或者 []
221
- var hadValueBefore = !isNullOrUndefined(prevValueRef.current) &&
222
- !(Array.isArray(prevValueRef.current) && prevValueRef.current.length === 0);
223
- var isEmptyNow = isNullOrUndefined(props.value) || (Array.isArray(props.value) && props.value.length === 0);
224
- if (hadValueBefore && isEmptyNow) {
220
+ if (props.value !== prevValueRef.current) {
225
221
  setValue(getValidValue(props.value, isMultipleMode, labelInValue));
226
222
  setProxyValue(getValidValue(props.value, isMultipleMode, labelInValue));
227
223
  }
228
224
  // 更新 ref 以保存当前值用于下次比较
229
225
  prevValueRef.current = props.value;
230
226
  }
231
- }, [props.value, isMultipleQuickSelectMode]);
227
+ }, [props.value, isMultipleQuickSelectMode, labelInValue]);
232
228
  // 选项下拉框显示/隐藏时的一些自动行为
233
229
  useEffect(function () {
234
230
  if (popupVisible) {
@@ -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();
@@ -233,9 +235,7 @@ var TreeSelect = function (baseProps, ref) {
233
235
  selected: false,
234
236
  });
235
237
  if (isMultipleQuickSelectMode) {
236
- setTimeout(function () {
237
- confirmCheck();
238
- }, 0);
238
+ confirmCheck();
239
239
  }
240
240
  return;
241
241
  }
@@ -247,9 +247,7 @@ var TreeSelect = function (baseProps, ref) {
247
247
  selected: false,
248
248
  });
249
249
  if (isMultipleQuickSelectMode) {
250
- setTimeout(function () {
251
- confirmCheck();
252
- }, 0);
250
+ confirmCheck();
253
251
  }
254
252
  };
255
253
  useEffect(function () {
@@ -369,6 +367,9 @@ var TreeSelect = function (baseProps, ref) {
369
367
  e.stopPropagation();
370
368
  triggerChange([], {});
371
369
  (_a = props.onClear) === null || _a === void 0 ? void 0 : _a.call(props, !!popupVisible);
370
+ if (isMultipleQuickSelectMode) {
371
+ confirmCheck();
372
+ }
372
373
  }, onKeyDown: function (e) {
373
374
  var _a;
374
375
  e.stopPropagation();
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { TypographyParagraphProps, TypographyTitleProps } from './interface';
3
3
  declare const _default: React.ForwardRefExoticComponent<TypographyParagraphProps & TypographyTitleProps & import("./interface").CommonProps & {
4
- componentType: "Paragraph" | "Title" | "Text";
4
+ componentType: "Title" | "Paragraph" | "Text";
5
5
  } & React.RefAttributes<unknown>>;
6
6
  export default _default;
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.2";
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.2';
@@ -236,12 +236,10 @@ function Modal(baseProps, ref) {
236
236
  (closeIcon !== undefined ? (react_1.default.createElement("span", { onClick: onCancel, className: prefixCls + "-close-icon" }, closeIcon)) : (react_1.default.createElement(icon_hover_1.default, { tabIndex: -1, onClick: onCancel, className: prefixCls + "-close-icon", role: "button", "aria-label": "Close" },
237
237
  react_1.default.createElement(IconClose_1.default, null))))));
238
238
  var ariaProps = title ? { 'aria-labelledby': "arco-dialog-" + dialogIndex.current } : {};
239
- // 将绑定到弹窗的尺寸相关样式移到上层div
240
- var _h = style || {}, width = _h.width, height = _h.height, restStyle = __rest(_h, ["width", "height"]);
241
239
  var modalDom = (react_1.default.createElement("div", __assign({ role: "dialog", "aria-modal": "true" }, ariaProps, { className: (0, classNames_1.default)(prefixCls, (_a = {},
242
240
  _a[prefixCls + "-simple"] = simple,
243
241
  _a[prefixCls + "-rtl"] = rtl,
244
- _a), className), style: __assign(__assign({ display: draggable ? 'block' : null }, restStyle), { width: draggable ? '100%' : width, height: draggable ? '100%' : height }), ref: modalRef }), innerFocusLock ? (react_1.default.createElement(react_focus_lock_1.default, { crossFrame: false, disabled: !visible, autoFocus: innerAutoFocus, lockProps: {
242
+ _a), className), style: style, ref: modalRef }), innerFocusLock ? (react_1.default.createElement(react_focus_lock_1.default, { crossFrame: false, disabled: !visible, autoFocus: innerAutoFocus, lockProps: {
245
243
  tabIndex: -1,
246
244
  onKeyDown: onEscExit,
247
245
  } }, element)) : (react_1.default.createElement(react_1.default.Fragment, null, element))));
@@ -254,8 +252,7 @@ function Modal(baseProps, ref) {
254
252
  },
255
253
  });
256
254
  // 包装在Draggable中的modal
257
- var wrappedModalDom = draggable && title ? (react_1.default.createElement(react_draggable_1.default, __assign({ bounds: "parent", handle: "." + prefixCls + "-header" }, draggableProps),
258
- react_1.default.createElement("div", { style: { top: 0, verticalAlign: 'middle', display: 'inline-block', width: width, height: height } }, modalWithMouseEventsDom))) : (modalWithMouseEventsDom);
255
+ var wrappedModalDom = draggable && title ? (react_1.default.createElement(react_draggable_1.default, __assign({ bounds: "parent", handle: "." + prefixCls + "-header" }, draggableProps), modalWithMouseEventsDom)) : (modalWithMouseEventsDom);
259
256
  var setTransformOrigin = function (e) {
260
257
  if (haveOriginTransformOrigin.current)
261
258
  return;
@@ -241,18 +241,14 @@ function Select(baseProps, ref) {
241
241
  }, [isMultipleMode, value]);
242
242
  (0, react_1.useEffect)(function () {
243
243
  if (isMultipleQuickSelectMode) {
244
- // 判断 props.value 之前有值现在被手动设置为 undefined 或者 []
245
- var hadValueBefore = !(0, is_1.isNullOrUndefined)(prevValueRef.current) &&
246
- !(Array.isArray(prevValueRef.current) && prevValueRef.current.length === 0);
247
- var isEmptyNow = (0, is_1.isNullOrUndefined)(props.value) || (Array.isArray(props.value) && props.value.length === 0);
248
- if (hadValueBefore && isEmptyNow) {
244
+ if (props.value !== prevValueRef.current) {
249
245
  setValue((0, utils_1.getValidValue)(props.value, isMultipleMode, labelInValue));
250
246
  setProxyValue((0, utils_1.getValidValue)(props.value, isMultipleMode, labelInValue));
251
247
  }
252
248
  // 更新 ref 以保存当前值用于下次比较
253
249
  prevValueRef.current = props.value;
254
250
  }
255
- }, [props.value, isMultipleQuickSelectMode]);
251
+ }, [props.value, isMultipleQuickSelectMode, labelInValue]);
256
252
  // 选项下拉框显示/隐藏时的一些自动行为
257
253
  (0, react_1.useEffect)(function () {
258
254
  if (popupVisible) {
@@ -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();
@@ -257,9 +259,7 @@ var TreeSelect = function (baseProps, ref) {
257
259
  selected: false,
258
260
  });
259
261
  if (isMultipleQuickSelectMode) {
260
- setTimeout(function () {
261
- confirmCheck();
262
- }, 0);
262
+ confirmCheck();
263
263
  }
264
264
  return;
265
265
  }
@@ -271,9 +271,7 @@ var TreeSelect = function (baseProps, ref) {
271
271
  selected: false,
272
272
  });
273
273
  if (isMultipleQuickSelectMode) {
274
- setTimeout(function () {
275
- confirmCheck();
276
- }, 0);
274
+ confirmCheck();
277
275
  }
278
276
  };
279
277
  (0, react_1.useEffect)(function () {
@@ -393,6 +391,9 @@ var TreeSelect = function (baseProps, ref) {
393
391
  e.stopPropagation();
394
392
  triggerChange([], {});
395
393
  (_a = props.onClear) === null || _a === void 0 ? void 0 : _a.call(props, !!popupVisible);
394
+ if (isMultipleQuickSelectMode) {
395
+ confirmCheck();
396
+ }
396
397
  }, onKeyDown: function (e) {
397
398
  var _a;
398
399
  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.2";
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.2';
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.2",
4
4
  "description": "AP Design React UI Library.",
5
5
  "module": "./es/index.js",
6
6
  "main": "./lib/index.js",