@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.
@@ -44222,6 +44222,7 @@ var collapsible = __webpack_require__("v967");
44222
44222
 
44223
44223
 
44224
44224
 
44225
+
44225
44226
  class Collapsible extends BaseComponent {
44226
44227
  constructor(props) {
44227
44228
  super(props);
@@ -44245,7 +44246,8 @@ class Collapsible extends BaseComponent {
44245
44246
  domInRenderTree: false,
44246
44247
  domHeight: 0,
44247
44248
  visible: this.props.isOpen,
44248
- isTransitioning: false
44249
+ isTransitioning: false,
44250
+ cacheIsOpen: this.props.isOpen
44249
44251
  };
44250
44252
  this.foundation = new collapsible_foundation(this.adapter);
44251
44253
  }
@@ -44281,6 +44283,20 @@ class Collapsible extends BaseComponent {
44281
44283
  }
44282
44284
  });
44283
44285
  }
44286
+ static getDerivedStateFromProps(props, prevState) {
44287
+ const newState = {};
44288
+ const isOpenChanged = props.isOpen !== prevState.cacheIsOpen;
44289
+ if (isOpenChanged) {
44290
+ if (props.isOpen || !props.motion) {
44291
+ newState.visible = props.isOpen;
44292
+ }
44293
+ }
44294
+ if (props.motion && isOpenChanged) {
44295
+ newState.isTransitioning = true;
44296
+ }
44297
+ newState.cacheIsOpen = props.isOpen;
44298
+ return newState;
44299
+ }
44284
44300
  componentDidMount() {
44285
44301
  super.componentDidMount();
44286
44302
  this.resizeObserver = new ResizeObserver(this.handleResize);
@@ -44292,22 +44308,14 @@ class Collapsible extends BaseComponent {
44292
44308
  }
44293
44309
  }
44294
44310
  componentDidUpdate(prevProps, prevState, snapshot) {
44295
- const changedPropKeys = Object.keys(this.props).filter(key => !isEqual_default()(this.props[key], prevProps[key]));
44296
- const changedStateKeys = Object.keys(this.state).filter(key => !isEqual_default()(this.state[key], prevState[key]));
44311
+ const changedPropKeys = Object.keys(pick_default()(this.props, ['reCalcKey'])).filter(key => !isEqual_default()(this.props[key], prevProps[key]));
44312
+ const changedStateKeys = Object.keys(pick_default()(this.state, ['domInRenderTree'])).filter(key => !isEqual_default()(this.state[key], prevState[key]));
44297
44313
  if (changedPropKeys.includes("reCalcKey")) {
44298
44314
  this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
44299
44315
  }
44300
44316
  if (changedStateKeys.includes("domInRenderTree") && this.state.domInRenderTree) {
44301
44317
  this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
44302
44318
  }
44303
- if (changedPropKeys.includes("isOpen")) {
44304
- if (this.props.isOpen || !this.props.motion) {
44305
- this.foundation.updateVisible(this.props.isOpen);
44306
- }
44307
- }
44308
- if (this.props.motion && prevProps.isOpen !== this.props.isOpen) {
44309
- this.foundation.updateIsTransitioning(true);
44310
- }
44311
44319
  }
44312
44320
  componentWillUnmount() {
44313
44321
  super.componentWillUnmount();