@douyinfe/semi-ui 2.38.3-alpha.2-spin → 2.38.3-alpha.2-patch-3006

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.
@@ -21,6 +21,7 @@ interface CollapsibleState extends CollapsibleFoundationState {
21
21
  domHeight: number;
22
22
  visible: boolean;
23
23
  isTransitioning: boolean;
24
+ cacheIsOpen: boolean;
24
25
  }
25
26
  declare class Collapsible extends BaseComponent<CollapsibleProps, CollapsibleState> {
26
27
  static defaultProps: {
@@ -36,6 +37,7 @@ declare class Collapsible extends BaseComponent<CollapsibleProps, CollapsibleSta
36
37
  private resizeObserver;
37
38
  constructor(props: CollapsibleProps);
38
39
  get adapter(): CollapsibleAdapter<CollapsibleProps, CollapsibleState>;
40
+ static getDerivedStateFromProps(props: CollapsibleProps, prevState: CollapsibleState): Partial<CollapsibleState>;
39
41
  static getEntryInfo: (entry: ResizeObserverEntry) => {
40
42
  isShown: boolean;
41
43
  height: number;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _pick2 = _interopRequireDefault(require("lodash/pick"));
7
8
  var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
8
9
  var _react = _interopRequireDefault(require("react"));
9
10
  var _foundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/collapsible/foundation"));
@@ -36,7 +37,8 @@ class Collapsible extends _baseComponent.default {
36
37
  domInRenderTree: false,
37
38
  domHeight: 0,
38
39
  visible: this.props.isOpen,
39
- isTransitioning: false
40
+ isTransitioning: false,
41
+ cacheIsOpen: this.props.isOpen
40
42
  };
41
43
  this.foundation = new _foundation.default(this.adapter);
42
44
  }
@@ -72,6 +74,20 @@ class Collapsible extends _baseComponent.default {
72
74
  }
73
75
  });
74
76
  }
77
+ static getDerivedStateFromProps(props, prevState) {
78
+ const newState = {};
79
+ const isOpenChanged = props.isOpen !== prevState.cacheIsOpen;
80
+ if (isOpenChanged) {
81
+ if (props.isOpen || !props.motion) {
82
+ newState.visible = props.isOpen;
83
+ }
84
+ }
85
+ if (props.motion && isOpenChanged) {
86
+ newState.isTransitioning = true;
87
+ }
88
+ newState.cacheIsOpen = props.isOpen;
89
+ return newState;
90
+ }
75
91
  componentDidMount() {
76
92
  super.componentDidMount();
77
93
  this.resizeObserver = new ResizeObserver(this.handleResize);
@@ -83,22 +99,14 @@ class Collapsible extends _baseComponent.default {
83
99
  }
84
100
  }
85
101
  componentDidUpdate(prevProps, prevState, snapshot) {
86
- const changedPropKeys = Object.keys(this.props).filter(key => !(0, _isEqual2.default)(this.props[key], prevProps[key]));
87
- const changedStateKeys = Object.keys(this.state).filter(key => !(0, _isEqual2.default)(this.state[key], prevState[key]));
102
+ const changedPropKeys = Object.keys((0, _pick2.default)(this.props, ['reCalcKey'])).filter(key => !(0, _isEqual2.default)(this.props[key], prevProps[key]));
103
+ const changedStateKeys = Object.keys((0, _pick2.default)(this.state, ['domInRenderTree'])).filter(key => !(0, _isEqual2.default)(this.state[key], prevState[key]));
88
104
  if (changedPropKeys.includes("reCalcKey")) {
89
105
  this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
90
106
  }
91
107
  if (changedStateKeys.includes("domInRenderTree") && this.state.domInRenderTree) {
92
108
  this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
93
109
  }
94
- if (changedPropKeys.includes("isOpen")) {
95
- if (this.props.isOpen || !this.props.motion) {
96
- this.foundation.updateVisible(this.props.isOpen);
97
- }
98
- }
99
- if (this.props.motion && prevProps.isOpen !== this.props.isOpen) {
100
- this.foundation.updateIsTransitioning(true);
101
- }
102
110
  }
103
111
  componentWillUnmount() {
104
112
  super.componentWillUnmount();
@@ -138,7 +138,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
138
138
  preventScroll?: boolean;
139
139
  showRestTagsPopover?: boolean;
140
140
  restTagsPopoverProps?: import("../popover").PopoverProps;
141
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
141
+ } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "motion" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
142
142
  static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
143
143
  static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & React.RefAttributes<any>>;
144
144
  static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
@@ -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, "stopPropagation" | "getPopupContainer" | "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>>;
@@ -145,11 +145,11 @@ export declare function withError(props: ModalReactProps): {
145
145
  size?: import("@douyinfe/semi-foundation/lib/cjs/modal/modalFoundation").Size;
146
146
  style?: React.CSSProperties;
147
147
  className?: string;
148
- motion?: boolean;
149
148
  getPopupContainer?: () => HTMLElement;
150
149
  footer?: React.ReactNode;
151
150
  header?: React.ReactNode;
152
151
  direction?: any;
152
+ motion?: boolean;
153
153
  width?: string | number;
154
154
  height?: string | number;
155
155
  mask?: boolean;
@@ -204,10 +204,10 @@ export declare function withError(props: ModalReactProps): {
204
204
  title?: string;
205
205
  name?: string;
206
206
  value?: string | number | readonly string[];
207
- onAnimationStart?: React.AnimationEventHandler<HTMLButtonElement>;
208
- onAnimationEnd?: React.AnimationEventHandler<HTMLButtonElement>;
209
207
  form?: string;
210
208
  slot?: string;
209
+ onAnimationStart?: React.AnimationEventHandler<HTMLButtonElement>;
210
+ onAnimationEnd?: React.AnimationEventHandler<HTMLButtonElement>;
211
211
  hidden?: boolean;
212
212
  color?: string;
213
213
  content?: string;
@@ -21,6 +21,7 @@ interface CollapsibleState extends CollapsibleFoundationState {
21
21
  domHeight: number;
22
22
  visible: boolean;
23
23
  isTransitioning: boolean;
24
+ cacheIsOpen: boolean;
24
25
  }
25
26
  declare class Collapsible extends BaseComponent<CollapsibleProps, CollapsibleState> {
26
27
  static defaultProps: {
@@ -36,6 +37,7 @@ declare class Collapsible extends BaseComponent<CollapsibleProps, CollapsibleSta
36
37
  private resizeObserver;
37
38
  constructor(props: CollapsibleProps);
38
39
  get adapter(): CollapsibleAdapter<CollapsibleProps, CollapsibleState>;
40
+ static getDerivedStateFromProps(props: CollapsibleProps, prevState: CollapsibleState): Partial<CollapsibleState>;
39
41
  static getEntryInfo: (entry: ResizeObserverEntry) => {
40
42
  isShown: boolean;
41
43
  height: number;
@@ -1,3 +1,4 @@
1
+ import _pick from "lodash/pick";
1
2
  import _isEqual from "lodash/isEqual";
2
3
  import React from 'react';
3
4
  import CollapsibleFoundation from '@douyinfe/semi-foundation/lib/es/collapsible/foundation';
@@ -29,7 +30,8 @@ class Collapsible extends BaseComponent {
29
30
  domInRenderTree: false,
30
31
  domHeight: 0,
31
32
  visible: this.props.isOpen,
32
- isTransitioning: false
33
+ isTransitioning: false,
34
+ cacheIsOpen: this.props.isOpen
33
35
  };
34
36
  this.foundation = new CollapsibleFoundation(this.adapter);
35
37
  }
@@ -65,6 +67,20 @@ class Collapsible extends BaseComponent {
65
67
  }
66
68
  });
67
69
  }
70
+ static getDerivedStateFromProps(props, prevState) {
71
+ const newState = {};
72
+ const isOpenChanged = props.isOpen !== prevState.cacheIsOpen;
73
+ if (isOpenChanged) {
74
+ if (props.isOpen || !props.motion) {
75
+ newState.visible = props.isOpen;
76
+ }
77
+ }
78
+ if (props.motion && isOpenChanged) {
79
+ newState.isTransitioning = true;
80
+ }
81
+ newState.cacheIsOpen = props.isOpen;
82
+ return newState;
83
+ }
68
84
  componentDidMount() {
69
85
  super.componentDidMount();
70
86
  this.resizeObserver = new ResizeObserver(this.handleResize);
@@ -76,22 +92,14 @@ class Collapsible extends BaseComponent {
76
92
  }
77
93
  }
78
94
  componentDidUpdate(prevProps, prevState, snapshot) {
79
- const changedPropKeys = Object.keys(this.props).filter(key => !_isEqual(this.props[key], prevProps[key]));
80
- const changedStateKeys = Object.keys(this.state).filter(key => !_isEqual(this.state[key], prevState[key]));
95
+ const changedPropKeys = Object.keys(_pick(this.props, ['reCalcKey'])).filter(key => !_isEqual(this.props[key], prevProps[key]));
96
+ const changedStateKeys = Object.keys(_pick(this.state, ['domInRenderTree'])).filter(key => !_isEqual(this.state[key], prevState[key]));
81
97
  if (changedPropKeys.includes("reCalcKey")) {
82
98
  this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
83
99
  }
84
100
  if (changedStateKeys.includes("domInRenderTree") && this.state.domInRenderTree) {
85
101
  this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
86
102
  }
87
- if (changedPropKeys.includes("isOpen")) {
88
- if (this.props.isOpen || !this.props.motion) {
89
- this.foundation.updateVisible(this.props.isOpen);
90
- }
91
- }
92
- if (this.props.motion && prevProps.isOpen !== this.props.isOpen) {
93
- this.foundation.updateIsTransitioning(true);
94
- }
95
103
  }
96
104
  componentWillUnmount() {
97
105
  super.componentWillUnmount();
@@ -138,7 +138,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
138
138
  preventScroll?: boolean;
139
139
  showRestTagsPopover?: boolean;
140
140
  restTagsPopoverProps?: import("../popover").PopoverProps;
141
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
141
+ } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "motion" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
142
142
  static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
143
143
  static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & React.RefAttributes<any>>;
144
144
  static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
@@ -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, "stopPropagation" | "getPopupContainer" | "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>>;
@@ -145,11 +145,11 @@ export declare function withError(props: ModalReactProps): {
145
145
  size?: import("@douyinfe/semi-foundation/lib/es/modal/modalFoundation").Size;
146
146
  style?: React.CSSProperties;
147
147
  className?: string;
148
- motion?: boolean;
149
148
  getPopupContainer?: () => HTMLElement;
150
149
  footer?: React.ReactNode;
151
150
  header?: React.ReactNode;
152
151
  direction?: any;
152
+ motion?: boolean;
153
153
  width?: string | number;
154
154
  height?: string | number;
155
155
  mask?: boolean;
@@ -204,10 +204,10 @@ export declare function withError(props: ModalReactProps): {
204
204
  title?: string;
205
205
  name?: string;
206
206
  value?: string | number | readonly string[];
207
- onAnimationStart?: React.AnimationEventHandler<HTMLButtonElement>;
208
- onAnimationEnd?: React.AnimationEventHandler<HTMLButtonElement>;
209
207
  form?: string;
210
208
  slot?: string;
209
+ onAnimationStart?: React.AnimationEventHandler<HTMLButtonElement>;
210
+ onAnimationEnd?: React.AnimationEventHandler<HTMLButtonElement>;
211
211
  hidden?: boolean;
212
212
  color?: string;
213
213
  content?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.38.3-alpha.2-spin",
3
+ "version": "2.38.3-alpha.2-patch-3006",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -17,12 +17,12 @@
17
17
  "lib/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@douyinfe/semi-animation": "2.38.3-alpha.2-spin",
21
- "@douyinfe/semi-animation-react": "2.38.3-alpha.2-spin",
22
- "@douyinfe/semi-foundation": "2.38.3-alpha.2-spin",
23
- "@douyinfe/semi-icons": "2.38.3-alpha.2-spin",
24
- "@douyinfe/semi-illustrations": "2.38.3-alpha.2-spin",
25
- "@douyinfe/semi-theme-default": "2.38.3-alpha.2-spin",
20
+ "@douyinfe/semi-animation": "2.38.3-alpha.2-patch-3006",
21
+ "@douyinfe/semi-animation-react": "2.38.3-alpha.2-patch-3006",
22
+ "@douyinfe/semi-foundation": "2.38.3-alpha.2-patch-3006",
23
+ "@douyinfe/semi-icons": "2.38.3-alpha.2-patch-3006",
24
+ "@douyinfe/semi-illustrations": "2.38.3-alpha.2-patch-3006",
25
+ "@douyinfe/semi-theme-default": "2.38.3-alpha.2-patch-3006",
26
26
  "async-validator": "^3.5.0",
27
27
  "classnames": "^2.2.6",
28
28
  "copy-text-to-clipboard": "^2.1.1",
@@ -69,7 +69,7 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "9ebe9a7f7d63097175ad03eef7a55cdd65a4c3c2",
72
+ "gitHead": "3e02e0b8a1c3e479662e4c0e96fdcbd1b88b7c84",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",