@douyinfe/semi-ui 2.17.0-beta.0 → 2.17.0-beta.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.
package/empty/index.tsx CHANGED
@@ -79,17 +79,17 @@ export default class Empty extends BaseComponent<EmptyProps, EmptyState> {
79
79
  const { className, image, description, style, title, imageStyle, children, layout, darkModeImage } = this.props;
80
80
 
81
81
  const alt = typeof description === 'string' ? description : 'empty';
82
- const imgSrc = this.state.mode && darkModeImage ? darkModeImage : image;
82
+ const imgSrc = ((this.state.mode === 'dark') && darkModeImage) ? darkModeImage : image;
83
83
  let imageNode = null;
84
84
  if (typeof imgSrc === 'string') {
85
- imageNode = <img alt={alt} src={imgSrc} />;
85
+ imageNode = <img alt={alt} src={imgSrc}/>;
86
86
  } else if (imgSrc && 'id' in (imgSrc as any)) {
87
87
  imageNode = (
88
88
  <svg
89
89
  // className={iconCls}
90
90
  aria-hidden="true"
91
91
  >
92
- <use xlinkHref={`#${(imgSrc as any).id}`} />
92
+ <use xlinkHref={`#${(imgSrc as any).id}`}/>
93
93
  </svg>
94
94
  );
95
95
  } else {
@@ -801,6 +801,33 @@ class Cascader extends _baseComponent.default {
801
801
  return firstInProps || treeDataHasChange;
802
802
  };
803
803
 
804
+ const getRealKeys = (realValue, keyEntities) => {
805
+ // normallizedValue is used to save the value in two-dimensional array format
806
+ let normallizedValue = [];
807
+
808
+ if ((0, _isArray.default)(realValue)) {
809
+ normallizedValue = (0, _isArray.default)(realValue[0]) ? realValue : [realValue];
810
+ } else {
811
+ if (realValue !== undefined) {
812
+ normallizedValue = [[realValue]];
813
+ }
814
+ } // formatValuePath is used to save value of valuePath
815
+
816
+
817
+ const formatValuePath = [];
818
+ (0, _forEach.default)(normallizedValue).call(normallizedValue, valueItem => {
819
+ const formatItem = onChangeWithObject ? (0, _map.default)(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
820
+ formatValuePath.push(formatItem);
821
+ }); // formatKeys is used to save key of value
822
+
823
+ const formatKeys = [];
824
+ (0, _forEach.default)(formatValuePath).call(formatValuePath, v => {
825
+ const formatKeyItem = (0, _util.findKeysForValues)(v, keyEntities);
826
+ !(0, _isEmpty2.default)(formatKeyItem) && formatKeys.push(formatKeyItem);
827
+ });
828
+ return formatKeys;
829
+ };
830
+
804
831
  const needUpdateTreeData = needUpdate('treeData') || needUpdateData();
805
832
  const needUpdateValue = needUpdate('value') || (0, _isEmpty2.default)(prevProps) && defaultValue;
806
833
 
@@ -817,31 +844,15 @@ class Cascader extends _baseComponent.default {
817
844
  let realKeys = prevState.checkedKeys; // when data was updated
818
845
 
819
846
  if (needUpdateValue) {
820
- // normallizedValue is used to save the value in two-dimensional array format
821
- let normallizedValue = [];
822
- const realValue = needUpdate('value') ? value : defaultValue; // eslint-disable-next-line max-depth
823
-
824
- if ((0, _isArray.default)(realValue)) {
825
- normallizedValue = (0, _isArray.default)(realValue[0]) ? realValue : [realValue];
826
- } else {
827
- if (realValue !== undefined) {
828
- normallizedValue = [[realValue]];
829
- }
830
- } // formatValuePath is used to save value of valuePath
831
-
832
-
833
- const formatValuePath = [];
834
- (0, _forEach.default)(normallizedValue).call(normallizedValue, valueItem => {
835
- const formatItem = onChangeWithObject ? (0, _map.default)(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
836
- formatValuePath.push(formatItem);
837
- }); // formatKeys is used to save key of value
838
-
839
- const formatKeys = [];
840
- (0, _forEach.default)(formatValuePath).call(formatValuePath, v => {
841
- const formatKeyItem = (0, _util.findKeysForValues)(v, keyEntities);
842
- !(0, _isEmpty2.default)(formatKeyItem) && formatKeys.push(formatKeyItem);
843
- });
844
- realKeys = formatKeys;
847
+ const realValue = needUpdate('value') ? value : defaultValue;
848
+ realKeys = getRealKeys(realValue, keyEntities);
849
+ } else {
850
+ // needUpdateValue is false
851
+ // if treeData is updated & Cascader is controlled, realKeys should be recalculated
852
+ if (needUpdateTreeData && 'value' in props) {
853
+ const realValue = value;
854
+ realKeys = getRealKeys(realValue, keyEntities);
855
+ }
845
856
  }
846
857
 
847
858
  if ((0, _isSet2.default)(realKeys)) {
@@ -88,7 +88,7 @@ class Empty extends _baseComponent.default {
88
88
  darkModeImage
89
89
  } = this.props;
90
90
  const alt = typeof description === 'string' ? description : 'empty';
91
- const imgSrc = this.state.mode && darkModeImage ? darkModeImage : image;
91
+ const imgSrc = this.state.mode === 'dark' && darkModeImage ? darkModeImage : image;
92
92
  let imageNode = null;
93
93
 
94
94
  if (typeof imgSrc === 'string') {
@@ -742,6 +742,37 @@ class Cascader extends BaseComponent {
742
742
  return firstInProps || treeDataHasChange;
743
743
  };
744
744
 
745
+ const getRealKeys = (realValue, keyEntities) => {
746
+ // normallizedValue is used to save the value in two-dimensional array format
747
+ let normallizedValue = [];
748
+
749
+ if (_Array$isArray(realValue)) {
750
+ normallizedValue = _Array$isArray(realValue[0]) ? realValue : [realValue];
751
+ } else {
752
+ if (realValue !== undefined) {
753
+ normallizedValue = [[realValue]];
754
+ }
755
+ } // formatValuePath is used to save value of valuePath
756
+
757
+
758
+ const formatValuePath = [];
759
+
760
+ _forEachInstanceProperty(normallizedValue).call(normallizedValue, valueItem => {
761
+ const formatItem = onChangeWithObject ? _mapInstanceProperty(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
762
+ formatValuePath.push(formatItem);
763
+ }); // formatKeys is used to save key of value
764
+
765
+
766
+ const formatKeys = [];
767
+
768
+ _forEachInstanceProperty(formatValuePath).call(formatValuePath, v => {
769
+ const formatKeyItem = findKeysForValues(v, keyEntities);
770
+ !_isEmpty(formatKeyItem) && formatKeys.push(formatKeyItem);
771
+ });
772
+
773
+ return formatKeys;
774
+ };
775
+
745
776
  const needUpdateTreeData = needUpdate('treeData') || needUpdateData();
746
777
  const needUpdateValue = needUpdate('value') || _isEmpty(prevProps) && defaultValue;
747
778
 
@@ -758,35 +789,15 @@ class Cascader extends BaseComponent {
758
789
  let realKeys = prevState.checkedKeys; // when data was updated
759
790
 
760
791
  if (needUpdateValue) {
761
- // normallizedValue is used to save the value in two-dimensional array format
762
- let normallizedValue = [];
763
- const realValue = needUpdate('value') ? value : defaultValue; // eslint-disable-next-line max-depth
764
-
765
- if (_Array$isArray(realValue)) {
766
- normallizedValue = _Array$isArray(realValue[0]) ? realValue : [realValue];
767
- } else {
768
- if (realValue !== undefined) {
769
- normallizedValue = [[realValue]];
770
- }
771
- } // formatValuePath is used to save value of valuePath
772
-
773
-
774
- const formatValuePath = [];
775
-
776
- _forEachInstanceProperty(normallizedValue).call(normallizedValue, valueItem => {
777
- const formatItem = onChangeWithObject ? _mapInstanceProperty(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
778
- formatValuePath.push(formatItem);
779
- }); // formatKeys is used to save key of value
780
-
781
-
782
- const formatKeys = [];
783
-
784
- _forEachInstanceProperty(formatValuePath).call(formatValuePath, v => {
785
- const formatKeyItem = findKeysForValues(v, keyEntities);
786
- !_isEmpty(formatKeyItem) && formatKeys.push(formatKeyItem);
787
- });
788
-
789
- realKeys = formatKeys;
792
+ const realValue = needUpdate('value') ? value : defaultValue;
793
+ realKeys = getRealKeys(realValue, keyEntities);
794
+ } else {
795
+ // needUpdateValue is false
796
+ // if treeData is updated & Cascader is controlled, realKeys should be recalculated
797
+ if (needUpdateTreeData && 'value' in props) {
798
+ const realValue = value;
799
+ realKeys = getRealKeys(realValue, keyEntities);
800
+ }
790
801
  }
791
802
 
792
803
  if (_isSet(realKeys)) {
@@ -67,7 +67,7 @@ export default class Empty extends BaseComponent {
67
67
  darkModeImage
68
68
  } = this.props;
69
69
  const alt = typeof description === 'string' ? description : 'empty';
70
- const imgSrc = this.state.mode && darkModeImage ? darkModeImage : image;
70
+ const imgSrc = this.state.mode === 'dark' && darkModeImage ? darkModeImage : image;
71
71
  let imageNode = null;
72
72
 
73
73
  if (typeof imgSrc === 'string') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.17.0-beta.0",
3
+ "version": "2.17.0-beta.1",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -15,11 +15,11 @@
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
17
  "@douyinfe/semi-animation": "2.12.0",
18
- "@douyinfe/semi-animation-react": "2.17.0-beta.0",
19
- "@douyinfe/semi-foundation": "2.17.0-beta.0",
20
- "@douyinfe/semi-icons": "2.17.0-beta.0",
18
+ "@douyinfe/semi-animation-react": "2.17.0-beta.1",
19
+ "@douyinfe/semi-foundation": "2.17.0-beta.1",
20
+ "@douyinfe/semi-icons": "2.17.0-beta.1",
21
21
  "@douyinfe/semi-illustrations": "2.15.0",
22
- "@douyinfe/semi-theme-default": "2.17.0-beta.0",
22
+ "@douyinfe/semi-theme-default": "2.17.0-beta.1",
23
23
  "async-validator": "^3.5.0",
24
24
  "classnames": "^2.2.6",
25
25
  "copy-text-to-clipboard": "^2.1.1",
@@ -66,13 +66,13 @@
66
66
  ],
67
67
  "author": "",
68
68
  "license": "MIT",
69
- "gitHead": "471474bb6fe0a743bc3daba532279969cc9374a5",
69
+ "gitHead": "f2829772791684497142f4bf6839063b9ef4427f",
70
70
  "devDependencies": {
71
71
  "@babel/plugin-proposal-decorators": "^7.15.8",
72
72
  "@babel/plugin-transform-runtime": "^7.15.8",
73
73
  "@babel/preset-env": "^7.15.8",
74
74
  "@babel/preset-react": "^7.14.5",
75
- "@douyinfe/semi-scss-compile": "2.17.0-beta.0",
75
+ "@douyinfe/semi-scss-compile": "2.17.0-beta.1",
76
76
  "@storybook/addon-knobs": "^6.3.1",
77
77
  "@types/lodash": "^4.14.176",
78
78
  "@types/react": ">=16.0.0",