@douyinfe/semi-ui 2.57.0-beta.0 → 2.57.1-alpha.0

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 (40) hide show
  1. package/README.md +1 -1
  2. package/dist/css/semi.css +21 -3
  3. package/dist/css/semi.min.css +1 -1
  4. package/dist/umd/semi-ui.js +99 -87
  5. package/dist/umd/semi-ui.js.map +1 -1
  6. package/dist/umd/semi-ui.min.js +1 -1
  7. package/dist/umd/semi-ui.min.js.map +1 -1
  8. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
  9. package/lib/cjs/form/baseForm.d.ts +2 -2
  10. package/lib/cjs/form/field.d.ts +2 -2
  11. package/lib/cjs/form/hoc/withField.js +11 -4
  12. package/lib/cjs/image/image.js +7 -3
  13. package/lib/cjs/image/interface.d.ts +2 -0
  14. package/lib/cjs/input/index.js +3 -3
  15. package/lib/cjs/input/textarea.js +4 -2
  16. package/lib/cjs/modal/confirm.d.ts +9 -9
  17. package/lib/cjs/slider/index.js +4 -2
  18. package/lib/cjs/table/Body/BaseRow.js +1 -1
  19. package/lib/cjs/table/interface.d.ts +1 -1
  20. package/lib/cjs/tagInput/index.js +8 -3
  21. package/lib/cjs/tooltip/index.js +10 -1
  22. package/lib/cjs/treeSelect/index.js +44 -39
  23. package/lib/cjs/typography/title.d.ts +1 -1
  24. package/lib/es/datePicker/monthsGrid.d.ts +1 -1
  25. package/lib/es/form/baseForm.d.ts +2 -2
  26. package/lib/es/form/field.d.ts +2 -2
  27. package/lib/es/form/hoc/withField.js +11 -4
  28. package/lib/es/image/image.js +7 -3
  29. package/lib/es/image/interface.d.ts +2 -0
  30. package/lib/es/input/index.js +3 -3
  31. package/lib/es/input/textarea.js +4 -2
  32. package/lib/es/modal/confirm.d.ts +9 -9
  33. package/lib/es/slider/index.js +4 -2
  34. package/lib/es/table/Body/BaseRow.js +1 -1
  35. package/lib/es/table/interface.d.ts +1 -1
  36. package/lib/es/tagInput/index.js +8 -3
  37. package/lib/es/tooltip/index.js +11 -2
  38. package/lib/es/treeSelect/index.js +44 -39
  39. package/lib/es/typography/title.d.ts +1 -1
  40. package/package.json +8 -8
@@ -86,7 +86,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
86
86
  renderMonth(month: Date, panelType: PanelType): JSX.Element;
87
87
  handleWeeksRowNumChange: (weeksRowNum: number, panelType: PanelType) => void;
88
88
  reselect: () => void;
89
- getYAMOpenType: () => "both" | "none" | "left" | "right";
89
+ getYAMOpenType: () => "none" | "left" | "right" | "both";
90
90
  renderTimePicker(panelType: PanelType, panelDetail: MonthInfo): JSX.Element;
91
91
  renderYearAndMonth(panelType: PanelType, panelDetail: MonthInfo): JSX.Element;
92
92
  renderSwitch(panelType: PanelType): JSX.Element;
@@ -86,7 +86,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
86
86
  onDropdownVisibleChange?: (visible: boolean) => void;
87
87
  zIndex?: number;
88
88
  position?: "left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
89
- onSearch?: (value: string, event: React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent>) => void;
89
+ onSearch?: (value: string, event: React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element>) => void;
90
90
  dropdownClassName?: string;
91
91
  dropdownStyle?: React.CSSProperties;
92
92
  dropdownMargin?: number | {
@@ -140,7 +140,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
140
140
  preventScroll?: boolean;
141
141
  showRestTagsPopover?: boolean;
142
142
  restTagsPopoverProps?: import("../popover").PopoverProps;
143
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
143
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "motion" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
144
144
  static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
145
145
  static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & React.RefAttributes<any>>;
146
146
  static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
@@ -32,7 +32,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
32
32
  onDropdownVisibleChange?: (visible: boolean) => void;
33
33
  zIndex?: number;
34
34
  position?: "left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
35
- onSearch?: (value: string, event: import("react").KeyboardEvent<Element> | import("react").MouseEvent<Element, MouseEvent>) => void;
35
+ onSearch?: (value: string, event: import("react").MouseEvent<Element, MouseEvent> | import("react").KeyboardEvent<Element>) => void;
36
36
  dropdownClassName?: string;
37
37
  dropdownStyle?: import("react").CSSProperties;
38
38
  dropdownMargin?: number | {
@@ -86,7 +86,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
86
86
  preventScroll?: boolean;
87
87
  showRestTagsPopover?: boolean;
88
88
  restTagsPopoverProps?: import("../popover").PopoverProps;
89
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
89
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "motion" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
90
90
  declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
91
91
  declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
92
92
  declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
@@ -117,6 +117,7 @@ function withField(Component, opts) {
117
117
  const [touched, setTouched] = (0, _react.useState)();
118
118
  const [cursor, setCursor, getCursor] = (0, _index.useStateWithGetter)(0);
119
119
  const [status, setStatus] = (0, _react.useState)(validateStatus); // use props.validateStatus to init
120
+ const isUnmounted = (0, _react.useRef)(false);
120
121
  const rulesRef = (0, _react.useRef)(rules);
121
122
  const validateRef = (0, _react.useRef)(validate);
122
123
  const validatePromise = (0, _react.useRef)(null);
@@ -127,6 +128,9 @@ function withField(Component, opts) {
127
128
  updater.updateStateTouched(field, isTouched, callOpts);
128
129
  };
129
130
  const updateError = (errors, callOpts) => {
131
+ if (isUnmounted.current) {
132
+ return;
133
+ }
130
134
  if (errors === getError()) {
131
135
  // When the inspection result is unchanged, no need to update, saving a forceUpdate overhead
132
136
  // When errors is an array, deepEqual is not used, and it is always treated as a need to update
@@ -171,7 +175,7 @@ function withField(Component, opts) {
171
175
  validator.validate(model, {
172
176
  first: mergeStopValidateWithError
173
177
  }, (errors, fields) => {}).then(res => {
174
- if (validatePromise.current !== rootPromise) {
178
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
175
179
  return;
176
180
  }
177
181
  // validation passed
@@ -179,7 +183,7 @@ function withField(Component, opts) {
179
183
  updateError(undefined, callOpts);
180
184
  resolve({});
181
185
  }).catch(err => {
182
- if (validatePromise.current !== rootPromise) {
186
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
183
187
  return;
184
188
  }
185
189
  let {
@@ -225,7 +229,7 @@ function withField(Component, opts) {
225
229
  } else if ((0, _isPromise.default)(maybePromisedErrors)) {
226
230
  maybePromisedErrors.then(result => {
227
231
  // If the async validate is outdated (a newer validate occurs), the result should be discarded
228
- if (validatePromise.current !== rootPromise) {
232
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
229
233
  return;
230
234
  }
231
235
  if ((0, _utils.isValid)(result)) {
@@ -353,11 +357,14 @@ function withField(Component, opts) {
353
357
  rulesRef.current = rules;
354
358
  validateRef.current = validate;
355
359
  }, [rules, validate]);
356
- // exec validate once when trigger inlcude 'mount'
357
360
  useIsomorphicEffect(() => {
361
+ // exec validate once when trigger include 'mount'
358
362
  if (validateOnMount) {
359
363
  fieldValidate(value);
360
364
  }
365
+ return () => {
366
+ isUnmounted.current = true;
367
+ };
361
368
  // eslint-disable-next-line react-hooks/exhaustive-deps
362
369
  }, []);
363
370
  // register when mounted,unregister when unmounted
@@ -169,9 +169,11 @@ class Image extends _baseComponent.default {
169
169
  fallback,
170
170
  placeholder,
171
171
  imageID,
172
- setDownloadName
172
+ setDownloadName,
173
+ imgCls,
174
+ imgStyle
173
175
  } = _b,
174
- restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
176
+ restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName", "imgCls", "imgStyle"]);
175
177
  const outerStyle = Object.assign({
176
178
  width,
177
179
  height
@@ -194,9 +196,11 @@ class Image extends _baseComponent.default {
194
196
  src: this.isInGroup() && this.isLazyLoad() ? undefined : src,
195
197
  "data-src": src,
196
198
  alt: alt,
199
+ style: imgStyle,
197
200
  className: (0, _classnames.default)(`${prefixCls}-img`, {
198
201
  [`${prefixCls}-img-preview`]: showPreviewCursor,
199
- [`${prefixCls}-img-error`]: loadStatus === "error"
202
+ [`${prefixCls}-img-error`]: loadStatus === "error",
203
+ [imgCls]: Boolean(imgCls)
200
204
  }),
201
205
  width: width,
202
206
  height: height,
@@ -23,6 +23,8 @@ export interface ImageProps extends BaseProps {
23
23
  children?: ReactNode;
24
24
  imageID?: number;
25
25
  setDownloadName?: (src: string) => string;
26
+ imgStyle?: React.CSSProperties;
27
+ imgCls?: string;
26
28
  }
27
29
  export interface PreviewProps extends BaseProps {
28
30
  visible?: boolean;
@@ -70,9 +70,10 @@ class Input extends _baseComponent.default {
70
70
  this.handlePreventMouseDown = e => {
71
71
  this.foundation.handlePreventMouseDown(e);
72
72
  };
73
+ const initValue = 'value' in props ? props.value : props.defaultValue;
73
74
  this.state = {
74
- value: '',
75
- cachedValue: null,
75
+ value: initValue,
76
+ cachedValue: props.value,
76
77
  disabled: false,
77
78
  props: {},
78
79
  isFocus: false,
@@ -145,7 +146,6 @@ class Input extends _baseComponent.default {
145
146
  componentDidMount() {
146
147
  // autofocus is changed from the original support of input to the support of manually calling the focus method,
147
148
  // so that preventScroll can still take effect under the setting of autofocus
148
- this.foundation.init();
149
149
  const {
150
150
  disabled,
151
151
  autoFocus,
@@ -46,12 +46,14 @@ class TextArea extends _baseComponent.default {
46
46
  forwardRef.current = node;
47
47
  }
48
48
  };
49
+ const initValue = 'value' in props ? props.value : props.defaultValue;
49
50
  this.state = {
50
- value: '',
51
+ value: initValue,
51
52
  isFocus: false,
52
53
  isHover: false,
53
54
  height: 0,
54
- minLength: props.minLength
55
+ minLength: props.minLength,
56
+ cachedValue: props.value
55
57
  };
56
58
  this.focusing = false;
57
59
  this.foundation = new _textareaFoundation.default(this.adapter);
@@ -146,19 +146,19 @@ export declare function withWarning(props: ModalReactProps): {
146
146
  type: "warning";
147
147
  };
148
148
  export declare function withError(props: ModalReactProps): {
149
- title?: React.ReactNode;
150
149
  children?: React.ReactNode;
151
- size?: import("@douyinfe/semi-foundation/lib/cjs/modal/modalFoundation").Size;
152
150
  style?: React.CSSProperties;
153
151
  className?: string;
154
- motion?: boolean;
155
152
  getPopupContainer?: () => HTMLElement;
156
153
  footer?: React.ReactNode;
157
154
  header?: React.ReactNode;
155
+ title?: React.ReactNode;
158
156
  direction?: any;
159
157
  mask?: boolean;
160
158
  visible?: boolean;
161
159
  zIndex?: number;
160
+ size?: import("@douyinfe/semi-foundation/lib/cjs/modal/modalFoundation").Size;
161
+ motion?: boolean;
162
162
  width?: string | number;
163
163
  height?: string | number;
164
164
  content?: React.ReactNode;
@@ -209,13 +209,10 @@ export declare function withError(props: ModalReactProps): {
209
209
  onMouseEnter?: React.MouseEventHandler<HTMLButtonElement>;
210
210
  onMouseLeave?: React.MouseEventHandler<HTMLButtonElement>;
211
211
  'aria-label'?: string;
212
- title?: string;
213
- name?: string;
214
212
  value?: string | number | readonly string[];
215
- onAnimationStart?: React.AnimationEventHandler<HTMLButtonElement>;
216
- onAnimationEnd?: React.AnimationEventHandler<HTMLButtonElement>;
217
213
  form?: string;
218
214
  slot?: string;
215
+ title?: string;
219
216
  prefix?: string;
220
217
  dangerouslySetInnerHTML?: {
221
218
  __html: string | TrustedHTML;
@@ -370,7 +367,9 @@ export declare function withError(props: ModalReactProps): {
370
367
  onScrollCapture?: React.UIEventHandler<HTMLButtonElement>;
371
368
  onWheel?: React.WheelEventHandler<HTMLButtonElement>;
372
369
  onWheelCapture?: React.WheelEventHandler<HTMLButtonElement>;
370
+ onAnimationStart?: React.AnimationEventHandler<HTMLButtonElement>;
373
371
  onAnimationStartCapture?: React.AnimationEventHandler<HTMLButtonElement>;
372
+ onAnimationEnd?: React.AnimationEventHandler<HTMLButtonElement>;
374
373
  onAnimationEndCapture?: React.AnimationEventHandler<HTMLButtonElement>;
375
374
  onAnimationIteration?: React.AnimationEventHandler<HTMLButtonElement>;
376
375
  onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement>;
@@ -384,6 +383,7 @@ export declare function withError(props: ModalReactProps): {
384
383
  suppressHydrationWarning?: boolean;
385
384
  accessKey?: string;
386
385
  autoFocus?: boolean;
386
+ name?: string;
387
387
  contextMenu?: string;
388
388
  dir?: string;
389
389
  draggable?: boolean | "true" | "false";
@@ -391,7 +391,7 @@ export declare function withError(props: ModalReactProps): {
391
391
  translate?: "no" | "yes";
392
392
  role?: React.AriaRole;
393
393
  contentEditable?: "inherit" | (boolean | "true" | "false");
394
- inputMode?: "search" | "none" | "text" | "email" | "tel" | "url" | "numeric" | "decimal";
394
+ inputMode?: "search" | "text" | "none" | "email" | "tel" | "url" | "numeric" | "decimal";
395
395
  nonce?: string;
396
396
  tabIndex?: number;
397
397
  content?: string;
@@ -425,7 +425,7 @@ export declare function withError(props: ModalReactProps): {
425
425
  is?: string;
426
426
  'aria-activedescendant'?: string;
427
427
  'aria-atomic'?: boolean | "true" | "false";
428
- 'aria-autocomplete'?: "both" | "none" | "list" | "inline";
428
+ 'aria-autocomplete'?: "none" | "list" | "both" | "inline";
429
429
  'aria-busy'?: boolean | "true" | "false";
430
430
  'aria-checked'?: boolean | "true" | "false" | "mixed";
431
431
  'aria-colcount'?: number;
@@ -392,11 +392,13 @@ class Slider extends _baseComponent.default {
392
392
  var _this = this;
393
393
  return Object.assign(Object.assign({}, super.adapter), {
394
394
  getSliderLengths: () => {
395
+ var _a;
395
396
  if (this.sliderEl && this.sliderEl.current) {
396
397
  const rect = this.sliderEl.current.getBoundingClientRect();
398
+ const offsetParentRect = (_a = this.sliderEl.current.offsetParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
397
399
  const offset = {
398
- x: this.sliderEl.current.offsetLeft,
399
- y: this.sliderEl.current.offsetTop
400
+ x: offsetParentRect ? rect.left - offsetParentRect.left : this.sliderEl.current.offsetLeft,
401
+ y: offsetParentRect ? rect.top - offsetParentRect.top : this.sliderEl.current.offsetTop
400
402
  };
401
403
  return {
402
404
  sliderX: offset.x,
@@ -281,7 +281,7 @@ class TableRow extends _baseComponent.default {
281
281
  rowProps = __rest(_a, ["className", "style"]);
282
282
  this.adapter.setCache('customRowProps', Object.assign({}, rowProps));
283
283
  const baseRowStyle = Object.assign(Object.assign({}, style), customStyle);
284
- const rowCls = typeof replaceClassName === 'string' && replaceClassName.length ? replaceClassName : (0, _classnames.default)(className, `${prefixCls}-row`, {
284
+ const rowCls = typeof replaceClassName === 'string' && replaceClassName.length ? (0, _classnames.default)(replaceClassName, customClassName) : (0, _classnames.default)(className, `${prefixCls}-row`, {
285
285
  [`${prefixCls}-row-selected`]: selected,
286
286
  [`${prefixCls}-row-expanded`]: expanded,
287
287
  [`${prefixCls}-row-hovered`]: hovered,
@@ -173,7 +173,7 @@ export interface OnRowReturnObject extends Omit<React.DetailedHTMLProps<React.HT
173
173
  style?: React.CSSProperties;
174
174
  onClick?: (e: React.MouseEvent) => void;
175
175
  }
176
- export interface OnGroupedRowReturnObject extends Omit<React.HTMLAttributes<HTMLTableRowElement>, 'className'> {
176
+ export interface OnGroupedRowReturnObject extends React.HTMLAttributes<HTMLTableRowElement> {
177
177
  [x: string]: any;
178
178
  style?: React.CSSProperties;
179
179
  onClick?: (e: React.MouseEvent) => void;
@@ -448,9 +448,12 @@ class TagInput extends _baseComponent.default {
448
448
  className,
449
449
  disabled,
450
450
  placeholder,
451
- validateStatus
451
+ validateStatus,
452
+ prefix,
453
+ insetLabel,
454
+ suffix
452
455
  } = _a,
453
- rest = __rest(_a, ["size", "style", "className", "disabled", "placeholder", "validateStatus"]);
456
+ rest = __rest(_a, ["size", "style", "className", "disabled", "placeholder", "validateStatus", "prefix", "insetLabel", "suffix"]);
454
457
  const {
455
458
  focusing,
456
459
  hovering,
@@ -465,7 +468,9 @@ class TagInput extends _baseComponent.default {
465
468
  [`${prefixCls}-error`]: validateStatus === 'error',
466
469
  [`${prefixCls}-warning`]: validateStatus === 'warning',
467
470
  [`${prefixCls}-small`]: size === 'small',
468
- [`${prefixCls}-large`]: size === 'large'
471
+ [`${prefixCls}-large`]: size === 'large',
472
+ [`${prefixCls}-with-prefix`]: !!prefix || !!insetLabel,
473
+ [`${prefixCls}-with-suffix`]: !!suffix
469
474
  });
470
475
  const inputCls = (0, _classnames.default)(`${prefixCls}-wrapper-input`, `${prefixCls}-wrapper-input-${size}`);
471
476
  const wrapperCls = (0, _classnames.default)(`${prefixCls}-wrapper`);
@@ -13,7 +13,7 @@ var _get2 = _interopRequireDefault(require("lodash/get"));
13
13
  var _noop2 = _interopRequireDefault(require("lodash/noop"));
14
14
  var _throttle2 = _interopRequireDefault(require("lodash/throttle"));
15
15
  var _react = _interopRequireWildcard(require("react"));
16
- var _reactDom = _interopRequireDefault(require("react-dom"));
16
+ var _reactDom = _interopRequireWildcard(require("react-dom"));
17
17
  var _classnames = _interopRequireDefault(require("classnames"));
18
18
  var _propTypes = _interopRequireDefault(require("prop-types"));
19
19
  var _constants = require("@douyinfe/semi-foundation/lib/cjs/base/constants");
@@ -545,6 +545,15 @@ class Tooltip extends _baseComponent.default {
545
545
  this.mounted = true;
546
546
  this.getPopupContainer = this.props.getPopupContainer || this.context.getPopupContainer || defaultGetContainer;
547
547
  this.foundation.init();
548
+ (0, _utils.runAfterTicks)(() => {
549
+ let triggerEle = this.triggerEl.current;
550
+ if (triggerEle) {
551
+ if (!(triggerEle instanceof HTMLElement)) {
552
+ triggerEle = (0, _reactDom.findDOMNode)(triggerEle);
553
+ }
554
+ }
555
+ this.foundation.updateStateIfCursorOnTrigger(triggerEle);
556
+ }, 1);
548
557
  }
549
558
  componentWillUnmount() {
550
559
  this.mounted = false;
@@ -367,15 +367,17 @@ class TreeSelect extends _baseComponent.default {
367
367
  leafOnly,
368
368
  searchPosition,
369
369
  triggerRender,
370
- borderless
370
+ borderless,
371
+ checkRelation
371
372
  } = _a,
372
- rest = __rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless"]);
373
+ rest = __rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless", "checkRelation"]);
373
374
  const {
374
375
  inputValue,
375
376
  selectedKeys,
376
377
  checkedKeys,
377
378
  keyEntities,
378
- isFocus
379
+ isFocus,
380
+ realCheckedKeys
379
381
  } = this.state;
380
382
  const filterable = Boolean(filterTreeNode);
381
383
  const useCustomTrigger = typeof triggerRender === 'function';
@@ -403,31 +405,45 @@ class TreeSelect extends _baseComponent.default {
403
405
  [`${prefixcls}-with-suffix`]: suffix,
404
406
  [`${prefixcls}-with-suffix`]: suffix
405
407
  }, className);
406
- const triggerRenderKeys = multiple ? (0, _treeUtil.normalizeKeyList)([...checkedKeys], keyEntities, leafOnly, true) : selectedKeys;
407
- const inner = useCustomTrigger ? /*#__PURE__*/_react.default.createElement(_trigger.default, {
408
- inputValue: inputValue,
409
- value: triggerRenderKeys.map(key => (0, _get2.default)(keyEntities, [key, 'data'])),
410
- disabled: disabled,
411
- placeholder: placeholder,
412
- onClear: this.handleClear,
413
- componentName: 'TreeSelect',
414
- triggerRender: triggerRender,
415
- componentProps: Object.assign({}, this.props),
416
- onSearch: this.search,
417
- onRemove: this.removeTag
418
- }) : [/*#__PURE__*/_react.default.createElement(_react.Fragment, {
419
- key: 'prefix'
420
- }, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
421
- key: 'selection'
422
- }, /*#__PURE__*/_react.default.createElement("div", {
423
- className: `${prefixcls}-selection`
424
- }, this.renderSelectContent())), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
425
- key: 'suffix'
426
- }, suffix ? this.renderSuffix() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
427
- key: 'clearBtn'
428
- }, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
429
- key: 'arrow'
430
- }, this.renderArrow())];
408
+ let inner;
409
+ if (useCustomTrigger) {
410
+ let triggerRenderKeys = [];
411
+ if (multiple) {
412
+ if (checkRelation === 'related') {
413
+ triggerRenderKeys = (0, _treeUtil.normalizeKeyList)([...checkedKeys], keyEntities, leafOnly, true);
414
+ } else if (checkRelation === 'unRelated') {
415
+ triggerRenderKeys = [...realCheckedKeys];
416
+ }
417
+ } else {
418
+ triggerRenderKeys = selectedKeys;
419
+ }
420
+ inner = /*#__PURE__*/_react.default.createElement(_trigger.default, {
421
+ inputValue: inputValue,
422
+ value: triggerRenderKeys.map(key => (0, _get2.default)(keyEntities, [key, 'data'])),
423
+ disabled: disabled,
424
+ placeholder: placeholder,
425
+ onClear: this.handleClear,
426
+ componentName: 'TreeSelect',
427
+ triggerRender: triggerRender,
428
+ componentProps: Object.assign({}, this.props),
429
+ onSearch: this.search,
430
+ onRemove: this.removeTag
431
+ });
432
+ } else {
433
+ inner = [/*#__PURE__*/_react.default.createElement(_react.Fragment, {
434
+ key: 'prefix'
435
+ }, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
436
+ key: 'selection'
437
+ }, /*#__PURE__*/_react.default.createElement("div", {
438
+ className: `${prefixcls}-selection`
439
+ }, this.renderSelectContent())), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
440
+ key: 'suffix'
441
+ }, suffix ? this.renderSuffix() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
442
+ key: 'clearBtn'
443
+ }, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
444
+ key: 'arrow'
445
+ }, this.renderArrow())];
446
+ }
431
447
  const tabIndex = disabled ? null : 0;
432
448
  /**
433
449
  * Reasons for disabling the a11y eslint rule:
@@ -891,7 +907,6 @@ class TreeSelect extends _baseComponent.default {
891
907
  };
892
908
  }
893
909
  static getDerivedStateFromProps(props, prevState) {
894
- var _a;
895
910
  const {
896
911
  prevProps,
897
912
  rePosKey
@@ -954,16 +969,6 @@ class TreeSelect extends _baseComponent.default {
954
969
  newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)((0, _treeUtil.normalizeValue)(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
955
970
  } else if (!prevProps && props.value) {
956
971
  newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)((0, _treeUtil.normalizeValue)(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
957
- } else if (!isExpandControlled && needUpdateTreeData && props.value) {
958
- // 当 treeData 已经设置具体的值,并且设置了 props.loadData ,则认为 treeData 的更新是因为 loadData 导致的
959
- // 如果是因为 loadData 导致 treeData改变, 此时在这里重新计算 key 会导致为未选中的展开项目被收起
960
- // 所以此时不需要重新计算 expandedKeys,因为在点击展开按钮时候已经把被展开的项添加到 expandedKeys 中
961
- // When treeData has a specific value and props.loadData is set, it is considered that the update of treeData is caused by loadData
962
- // If the treeData is changed because of loadData, recalculating the key here will cause the unselected expanded items to be collapsed
963
- // So there is no need to recalculate expandedKeys at this time, because the expanded item has been added to expandedKeys when the expand button is clicked
964
- if (!(prevState.treeData && ((_a = prevState.treeData) === null || _a === void 0 ? void 0 : _a.length) > 0 && props.loadData)) {
965
- newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)(props.value, keyEntities, props.multiple, valueEntities);
966
- }
967
972
  }
968
973
  if (!newState.expandedKeys) {
969
974
  delete newState.expandedKeys;
@@ -60,7 +60,7 @@ export default class Title extends PureComponent<TitleProps> {
60
60
  underline: PropTypes.Requireable<boolean>;
61
61
  strong: PropTypes.Requireable<boolean>;
62
62
  type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
63
- heading: PropTypes.Requireable<1 | 2 | 3 | 4 | 5 | 6>;
63
+ heading: PropTypes.Requireable<4 | 2 | 1 | 3 | 5 | 6>;
64
64
  style: PropTypes.Requireable<object>;
65
65
  className: PropTypes.Requireable<string>;
66
66
  component: PropTypes.Requireable<string>;
@@ -86,7 +86,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
86
86
  renderMonth(month: Date, panelType: PanelType): JSX.Element;
87
87
  handleWeeksRowNumChange: (weeksRowNum: number, panelType: PanelType) => void;
88
88
  reselect: () => void;
89
- getYAMOpenType: () => "both" | "none" | "left" | "right";
89
+ getYAMOpenType: () => "none" | "left" | "right" | "both";
90
90
  renderTimePicker(panelType: PanelType, panelDetail: MonthInfo): JSX.Element;
91
91
  renderYearAndMonth(panelType: PanelType, panelDetail: MonthInfo): JSX.Element;
92
92
  renderSwitch(panelType: PanelType): JSX.Element;
@@ -86,7 +86,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
86
86
  onDropdownVisibleChange?: (visible: boolean) => void;
87
87
  zIndex?: number;
88
88
  position?: "left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
89
- onSearch?: (value: string, event: React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent>) => void;
89
+ onSearch?: (value: string, event: React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element>) => void;
90
90
  dropdownClassName?: string;
91
91
  dropdownStyle?: React.CSSProperties;
92
92
  dropdownMargin?: number | {
@@ -140,7 +140,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
140
140
  preventScroll?: boolean;
141
141
  showRestTagsPopover?: boolean;
142
142
  restTagsPopoverProps?: import("../popover").PopoverProps;
143
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
143
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "motion" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
144
144
  static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
145
145
  static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & React.RefAttributes<any>>;
146
146
  static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
@@ -32,7 +32,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
32
32
  onDropdownVisibleChange?: (visible: boolean) => void;
33
33
  zIndex?: number;
34
34
  position?: "left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
35
- onSearch?: (value: string, event: import("react").KeyboardEvent<Element> | import("react").MouseEvent<Element, MouseEvent>) => void;
35
+ onSearch?: (value: string, event: import("react").MouseEvent<Element, MouseEvent> | import("react").KeyboardEvent<Element>) => void;
36
36
  dropdownClassName?: string;
37
37
  dropdownStyle?: import("react").CSSProperties;
38
38
  dropdownMargin?: number | {
@@ -86,7 +86,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
86
86
  preventScroll?: boolean;
87
87
  showRestTagsPopover?: boolean;
88
88
  restTagsPopoverProps?: import("../popover").PopoverProps;
89
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
89
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "motion" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
90
90
  declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
91
91
  declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
92
92
  declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
@@ -107,6 +107,7 @@ function withField(Component, opts) {
107
107
  const [touched, setTouched] = useState();
108
108
  const [cursor, setCursor, getCursor] = useStateWithGetter(0);
109
109
  const [status, setStatus] = useState(validateStatus); // use props.validateStatus to init
110
+ const isUnmounted = useRef(false);
110
111
  const rulesRef = useRef(rules);
111
112
  const validateRef = useRef(validate);
112
113
  const validatePromise = useRef(null);
@@ -117,6 +118,9 @@ function withField(Component, opts) {
117
118
  updater.updateStateTouched(field, isTouched, callOpts);
118
119
  };
119
120
  const updateError = (errors, callOpts) => {
121
+ if (isUnmounted.current) {
122
+ return;
123
+ }
120
124
  if (errors === getError()) {
121
125
  // When the inspection result is unchanged, no need to update, saving a forceUpdate overhead
122
126
  // When errors is an array, deepEqual is not used, and it is always treated as a need to update
@@ -161,7 +165,7 @@ function withField(Component, opts) {
161
165
  validator.validate(model, {
162
166
  first: mergeStopValidateWithError
163
167
  }, (errors, fields) => {}).then(res => {
164
- if (validatePromise.current !== rootPromise) {
168
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
165
169
  return;
166
170
  }
167
171
  // validation passed
@@ -169,7 +173,7 @@ function withField(Component, opts) {
169
173
  updateError(undefined, callOpts);
170
174
  resolve({});
171
175
  }).catch(err => {
172
- if (validatePromise.current !== rootPromise) {
176
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
173
177
  return;
174
178
  }
175
179
  let {
@@ -215,7 +219,7 @@ function withField(Component, opts) {
215
219
  } else if (isPromise(maybePromisedErrors)) {
216
220
  maybePromisedErrors.then(result => {
217
221
  // If the async validate is outdated (a newer validate occurs), the result should be discarded
218
- if (validatePromise.current !== rootPromise) {
222
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
219
223
  return;
220
224
  }
221
225
  if (isValid(result)) {
@@ -343,11 +347,14 @@ function withField(Component, opts) {
343
347
  rulesRef.current = rules;
344
348
  validateRef.current = validate;
345
349
  }, [rules, validate]);
346
- // exec validate once when trigger inlcude 'mount'
347
350
  useIsomorphicEffect(() => {
351
+ // exec validate once when trigger include 'mount'
348
352
  if (validateOnMount) {
349
353
  fieldValidate(value);
350
354
  }
355
+ return () => {
356
+ isUnmounted.current = true;
357
+ };
351
358
  // eslint-disable-next-line react-hooks/exhaustive-deps
352
359
  }, []);
353
360
  // register when mounted,unregister when unmounted
@@ -162,9 +162,11 @@ export default class Image extends BaseComponent {
162
162
  fallback,
163
163
  placeholder,
164
164
  imageID,
165
- setDownloadName
165
+ setDownloadName,
166
+ imgCls,
167
+ imgStyle
166
168
  } = _b,
167
- restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
169
+ restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName", "imgCls", "imgStyle"]);
168
170
  const outerStyle = Object.assign({
169
171
  width,
170
172
  height
@@ -187,9 +189,11 @@ export default class Image extends BaseComponent {
187
189
  src: this.isInGroup() && this.isLazyLoad() ? undefined : src,
188
190
  "data-src": src,
189
191
  alt: alt,
192
+ style: imgStyle,
190
193
  className: cls(`${prefixCls}-img`, {
191
194
  [`${prefixCls}-img-preview`]: showPreviewCursor,
192
- [`${prefixCls}-img-error`]: loadStatus === "error"
195
+ [`${prefixCls}-img-error`]: loadStatus === "error",
196
+ [imgCls]: Boolean(imgCls)
193
197
  }),
194
198
  width: width,
195
199
  height: height,