@douyinfe/semi-foundation 2.75.0 → 2.75.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.
@@ -315,16 +315,20 @@ $module: #{$prefix}-cascader;
315
315
  border-bottom: $width-cascader_search-border solid $color-cascader_search-border-default;
316
316
  }
317
317
 
318
- .#{$module}-option-empty {
318
+ .#{$module}-option-lists .#{$module}-option-empty {
319
319
  @include font-size-regular;
320
320
  border-radius: $radius-cascader_option_empty;
321
- min-width: $width-cascader_option;
321
+ // min-width: $width-cascader_option;
322
322
  color: $color-cascader_option_empty-text-default;
323
323
  margin: 0;
324
324
  padding: $spacing-cascader_option_empty-paddingY $spacing-cascader_option_empty-paddingX;
325
325
  user-select: none;
326
326
  text-align: center;
327
327
  cursor: not-allowed;
328
+
329
+ &:hover {
330
+ background-color: transparent;
331
+ }
328
332
  }
329
333
  }
330
334
 
@@ -381,6 +385,8 @@ $module: #{$prefix}-cascader;
381
385
 
382
386
  &-empty {
383
387
  height: auto;
388
+ justify-content: center;
389
+ cursor: not-allowed;
384
390
  }
385
391
 
386
392
  ul,
@@ -1,4 +1,4 @@
1
- import { isEqual, get, difference, isUndefined, assign, isEmpty, isNumber, includes, isFunction, isObject } from 'lodash';
1
+ import { isEqual, get, difference, isUndefined, assign, isEmpty, isNumber, includes, isFunction, isObject, isString } from 'lodash';
2
2
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
3
3
  import {
4
4
  findAncestorKeys,
@@ -186,6 +186,7 @@ export interface BasicCascaderProps {
186
186
  }
187
187
 
188
188
  export interface BasicCascaderInnerData {
189
+ emptyContentMinWidth: number;
189
190
  isOpen: boolean;
190
191
  rePosKey: number;
191
192
  keyEntities: BasicEntities;
@@ -239,7 +240,9 @@ export interface CascaderAdapter extends DefaultAdapter<BasicCascaderProps, Basi
239
240
  updateLoadingKeyRefValue: (keys: Set<string>) => void;
240
241
  getLoadingKeyRefValue: () => Set<string>;
241
242
  updateLoadedKeyRefValue: (keys: Set<string>) => void;
242
- getLoadedKeyRefValue: () => Set<string>
243
+ getLoadedKeyRefValue: () => Set<string>;
244
+ setEmptyContentMinWidth: (minWidth: number) => void;
245
+ getTriggerWidth: () => number;
243
246
  }
244
247
 
245
248
  export default class CascaderFoundation extends BaseFoundation<CascaderAdapter, BasicCascaderProps, BasicCascaderInnerData> {
@@ -259,6 +262,19 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
259
262
  }
260
263
  }
261
264
 
265
+ _setEmptyContentMinWidth() {
266
+ const { style } = this.getProps();
267
+ let width;
268
+ if (style && isNumber(style.width)) {
269
+ width = style.width;
270
+ } else if (style && isString(style.width) && !style.width.includes('%')) {
271
+ width = style.width;
272
+ } else {
273
+ width = this._adapter.getTriggerWidth();
274
+ }
275
+ this._adapter.setEmptyContentMinWidth(width);
276
+ }
277
+
262
278
  handleKeyDown = (e: any) => {
263
279
  if (e.key === ESC_KEY) {
264
280
  const isOpen = this.getState('isOpen');
@@ -531,6 +547,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
531
547
  }
532
548
  this._adapter.notifyDropdownVisibleChange(true);
533
549
  this._adapter.registerClickOutsideHandler(e => this.close(e));
550
+ this._setEmptyContentMinWidth();
534
551
  }
535
552
 
536
553
  reCalcActiveKeys() {
package/getBabelConfig.js CHANGED
@@ -19,6 +19,7 @@ module.exports = ({ isESM }) => {
19
19
  ],
20
20
  plugins: [
21
21
  'lodash',
22
+ ...(isESM ? [] : ['./scripts/babel-plugin-lottie.js'])
22
23
  ]
23
24
  };
24
25
  };
@@ -256,12 +256,11 @@
256
256
  padding: 8px 12px;
257
257
  border-bottom: 1px solid var(--semi-color-fill-0);
258
258
  }
259
- .semi-cascader-popover .semi-cascader-option-empty {
259
+ .semi-cascader-popover .semi-cascader-option-lists .semi-cascader-option-empty {
260
260
  font-size: 14px;
261
261
  line-height: 20px;
262
262
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
263
263
  border-radius: var(--semi-border-radius-medium);
264
- min-width: 150px;
265
264
  color: var(--semi-color-disabled-text);
266
265
  margin: 0;
267
266
  padding: 8px 12px;
@@ -269,6 +268,9 @@
269
268
  text-align: center;
270
269
  cursor: not-allowed;
271
270
  }
271
+ .semi-cascader-popover .semi-cascader-option-lists .semi-cascader-option-empty:hover {
272
+ background-color: transparent;
273
+ }
272
274
 
273
275
  .semi-cascader-single.semi-cascader-filterable {
274
276
  display: inline-flex;
@@ -314,6 +316,8 @@
314
316
  }
315
317
  .semi-cascader-option-lists-empty {
316
318
  height: auto;
319
+ justify-content: center;
320
+ cursor: not-allowed;
317
321
  }
318
322
  .semi-cascader-option-lists ul,
319
323
  .semi-cascader-option-lists li {
@@ -315,16 +315,20 @@ $module: #{$prefix}-cascader;
315
315
  border-bottom: $width-cascader_search-border solid $color-cascader_search-border-default;
316
316
  }
317
317
 
318
- .#{$module}-option-empty {
318
+ .#{$module}-option-lists .#{$module}-option-empty {
319
319
  @include font-size-regular;
320
320
  border-radius: $radius-cascader_option_empty;
321
- min-width: $width-cascader_option;
321
+ // min-width: $width-cascader_option;
322
322
  color: $color-cascader_option_empty-text-default;
323
323
  margin: 0;
324
324
  padding: $spacing-cascader_option_empty-paddingY $spacing-cascader_option_empty-paddingX;
325
325
  user-select: none;
326
326
  text-align: center;
327
327
  cursor: not-allowed;
328
+
329
+ &:hover {
330
+ background-color: transparent;
331
+ }
328
332
  }
329
333
  }
330
334
 
@@ -381,6 +385,8 @@ $module: #{$prefix}-cascader;
381
385
 
382
386
  &-empty {
383
387
  height: auto;
388
+ justify-content: center;
389
+ cursor: not-allowed;
384
390
  }
385
391
 
386
392
  ul,
@@ -129,6 +129,7 @@ export interface BasicCascaderProps {
129
129
  onFocus?: (e: any) => void;
130
130
  }
131
131
  export interface BasicCascaderInnerData {
132
+ emptyContentMinWidth: number;
132
133
  isOpen: boolean;
133
134
  rePosKey: number;
134
135
  keyEntities: BasicEntities;
@@ -182,10 +183,13 @@ export interface CascaderAdapter extends DefaultAdapter<BasicCascaderProps, Basi
182
183
  getLoadingKeyRefValue: () => Set<string>;
183
184
  updateLoadedKeyRefValue: (keys: Set<string>) => void;
184
185
  getLoadedKeyRefValue: () => Set<string>;
186
+ setEmptyContentMinWidth: (minWidth: number) => void;
187
+ getTriggerWidth: () => number;
185
188
  }
186
189
  export default class CascaderFoundation extends BaseFoundation<CascaderAdapter, BasicCascaderProps, BasicCascaderInnerData> {
187
190
  constructor(adapter: CascaderAdapter);
188
191
  init(): void;
192
+ _setEmptyContentMinWidth(): void;
189
193
  handleKeyDown: (e: any) => void;
190
194
  destroy(): void;
191
195
  _isDisabled(): any;
@@ -244,16 +248,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
244
248
  */
245
249
  calcCheckedKeys(key: string, curCheckedStatus: boolean): {
246
250
  checkedKeys: Set<string>;
247
- halfCheckedKeys: Set<string>; /**
248
- * If selectedKeys does not meet the update conditions,
249
- * and state.selectedKeys is the same as selectedKeys
250
- * at this time, state.selectedKeys should be cleared.
251
- * A typical scenario is:
252
- * The originally selected node is the leaf node, but
253
- * after props.treeData is dynamically updated, the node
254
- * is a non-leaf node. At this point, selectedKeys should
255
- * be cleared.
256
- */
251
+ halfCheckedKeys: Set<string>;
257
252
  };
258
253
  handleInputChange(sugInput: string): void;
259
254
  handleClear(): void;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _isString2 = _interopRequireDefault(require("lodash/isString"));
7
8
  var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
8
9
  var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
9
10
  var _includes2 = _interopRequireDefault(require("lodash/includes"));
@@ -68,6 +69,20 @@ class CascaderFoundation extends _foundation.default {
68
69
  this.open();
69
70
  }
70
71
  }
72
+ _setEmptyContentMinWidth() {
73
+ const {
74
+ style
75
+ } = this.getProps();
76
+ let width;
77
+ if (style && (0, _isNumber2.default)(style.width)) {
78
+ width = style.width;
79
+ } else if (style && (0, _isString2.default)(style.width) && !style.width.includes('%')) {
80
+ width = style.width;
81
+ } else {
82
+ width = this._adapter.getTriggerWidth();
83
+ }
84
+ this._adapter.setEmptyContentMinWidth(width);
85
+ }
71
86
  destroy() {
72
87
  this._adapter.unregisterClickOutsideHandler();
73
88
  }
@@ -335,6 +350,7 @@ class CascaderFoundation extends _foundation.default {
335
350
  }
336
351
  this._adapter.notifyDropdownVisibleChange(true);
337
352
  this._adapter.registerClickOutsideHandler(e => this.close(e));
353
+ this._setEmptyContentMinWidth();
338
354
  }
339
355
  reCalcActiveKeys() {
340
356
  const {
@@ -5,8 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _foundation = _interopRequireDefault(require("../base/foundation"));
8
- var _lottieWeb = _interopRequireDefault(require("lottie-web"));
9
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _lottieWeb = undefined;
10
+ if (typeof document !== "undefined") {
11
+ _lottieWeb = require("lottie-web");
12
+ if (_lottieWeb && _lottieWeb.__esModule) _lottieWeb = _lottieWeb.default;
13
+ }
10
14
  class LottieFoundation extends _foundation.default {
11
15
  constructor(adapter) {
12
16
  super(Object.assign(Object.assign({}, LottieFoundation.defaultAdapter), adapter));
@@ -14,14 +18,14 @@ class LottieFoundation extends _foundation.default {
14
18
  this.handleParamsUpdate = () => {
15
19
  var _a;
16
20
  this.animation.destroy();
17
- this.animation = _lottieWeb.default.loadAnimation(this._adapter.getLoadParams());
21
+ this.animation = lottie.loadAnimation(this._adapter.getLoadParams());
18
22
  (_a = this.getProp("getAnimationInstance")) === null || _a === void 0 ? void 0 : _a(this.animation);
19
23
  };
20
24
  }
21
25
  init(lifecycle) {
22
26
  var _a, _b;
23
27
  super.init(lifecycle);
24
- this.animation = _lottieWeb.default.loadAnimation(this._adapter.getLoadParams());
28
+ this.animation = lottie.loadAnimation(this._adapter.getLoadParams());
25
29
  (_a = this.getProp("getAnimationInstance")) === null || _a === void 0 ? void 0 : _a(this.animation);
26
30
  (_b = this.getProp("getLottie")) === null || _b === void 0 ? void 0 : _b(LottieFoundation.getLottie());
27
31
  }
@@ -31,6 +35,6 @@ class LottieFoundation extends _foundation.default {
31
35
  }
32
36
  }
33
37
  LottieFoundation.getLottie = () => {
34
- return _lottieWeb.default;
38
+ return lottie;
35
39
  };
36
40
  var _default = exports.default = LottieFoundation;
@@ -38,6 +38,7 @@ class NavigationFoundation extends _foundation.default {
38
38
  let keysMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
39
39
  let parentKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
40
40
  let keyPropName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'itemKey';
41
+ var _a;
41
42
  if (Array.isArray(items) && items.length) {
42
43
  for (const item of items) {
43
44
  if (Array.isArray(item)) {
@@ -49,10 +50,15 @@ class NavigationFoundation extends _foundation.default {
49
50
  }
50
51
  if (itemKey) {
51
52
  keysMap[itemKey] = [...parentKeys];
53
+ // Children is not a recommended usage and may cause some bug-like performance, but some users have already used it, so here we only delete the ts definition instead of deleting the actual code
54
+ // children 并不是我们推荐的用法,可能会导致一些像 bug的表现,但是有些用户已经用了,所以此处仅作删除 ts 定义而非删除实际代码的操作
55
+ // refer https://github.com/DouyinFE/semi-design/issues/2710
56
+ // @ts-ignore
57
+ const itemChildren = (_a = item.props) === null || _a === void 0 ? void 0 : _a.children;
52
58
  if (Array.isArray(item.items) && item.items.length) {
53
59
  NavigationFoundation.buildItemKeysMap(item.items, keysMap, [...parentKeys, itemKey], keyPropName);
54
- } else if (item.props && item.props.children) {
55
- const children = Array.isArray(item.props.children) ? item.props.children : [item.props.children];
60
+ } else if (itemChildren) {
61
+ const children = Array.isArray(itemChildren) ? itemChildren : [itemChildren];
56
62
  NavigationFoundation.buildItemKeysMap(children, keysMap, [...parentKeys, itemKey], keyPropName);
57
63
  }
58
64
  }
@@ -10,7 +10,6 @@ export interface ItemProps {
10
10
  link?: string;
11
11
  linkOptions?: Record<string, any>;
12
12
  disabled?: boolean;
13
- children?: any;
14
13
  }
15
14
  export type ItemKey = string | number;
16
15
  export interface SelectedItemProps<Props = ItemProps> {
@@ -256,12 +256,11 @@
256
256
  padding: 8px 12px;
257
257
  border-bottom: 1px solid var(--semi-color-fill-0);
258
258
  }
259
- .semi-cascader-popover .semi-cascader-option-empty {
259
+ .semi-cascader-popover .semi-cascader-option-lists .semi-cascader-option-empty {
260
260
  font-size: 14px;
261
261
  line-height: 20px;
262
262
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
263
263
  border-radius: var(--semi-border-radius-medium);
264
- min-width: 150px;
265
264
  color: var(--semi-color-disabled-text);
266
265
  margin: 0;
267
266
  padding: 8px 12px;
@@ -269,6 +268,9 @@
269
268
  text-align: center;
270
269
  cursor: not-allowed;
271
270
  }
271
+ .semi-cascader-popover .semi-cascader-option-lists .semi-cascader-option-empty:hover {
272
+ background-color: transparent;
273
+ }
272
274
 
273
275
  .semi-cascader-single.semi-cascader-filterable {
274
276
  display: inline-flex;
@@ -314,6 +316,8 @@
314
316
  }
315
317
  .semi-cascader-option-lists-empty {
316
318
  height: auto;
319
+ justify-content: center;
320
+ cursor: not-allowed;
317
321
  }
318
322
  .semi-cascader-option-lists ul,
319
323
  .semi-cascader-option-lists li {
@@ -315,16 +315,20 @@ $module: #{$prefix}-cascader;
315
315
  border-bottom: $width-cascader_search-border solid $color-cascader_search-border-default;
316
316
  }
317
317
 
318
- .#{$module}-option-empty {
318
+ .#{$module}-option-lists .#{$module}-option-empty {
319
319
  @include font-size-regular;
320
320
  border-radius: $radius-cascader_option_empty;
321
- min-width: $width-cascader_option;
321
+ // min-width: $width-cascader_option;
322
322
  color: $color-cascader_option_empty-text-default;
323
323
  margin: 0;
324
324
  padding: $spacing-cascader_option_empty-paddingY $spacing-cascader_option_empty-paddingX;
325
325
  user-select: none;
326
326
  text-align: center;
327
327
  cursor: not-allowed;
328
+
329
+ &:hover {
330
+ background-color: transparent;
331
+ }
328
332
  }
329
333
  }
330
334
 
@@ -381,6 +385,8 @@ $module: #{$prefix}-cascader;
381
385
 
382
386
  &-empty {
383
387
  height: auto;
388
+ justify-content: center;
389
+ cursor: not-allowed;
384
390
  }
385
391
 
386
392
  ul,
@@ -129,6 +129,7 @@ export interface BasicCascaderProps {
129
129
  onFocus?: (e: any) => void;
130
130
  }
131
131
  export interface BasicCascaderInnerData {
132
+ emptyContentMinWidth: number;
132
133
  isOpen: boolean;
133
134
  rePosKey: number;
134
135
  keyEntities: BasicEntities;
@@ -182,10 +183,13 @@ export interface CascaderAdapter extends DefaultAdapter<BasicCascaderProps, Basi
182
183
  getLoadingKeyRefValue: () => Set<string>;
183
184
  updateLoadedKeyRefValue: (keys: Set<string>) => void;
184
185
  getLoadedKeyRefValue: () => Set<string>;
186
+ setEmptyContentMinWidth: (minWidth: number) => void;
187
+ getTriggerWidth: () => number;
185
188
  }
186
189
  export default class CascaderFoundation extends BaseFoundation<CascaderAdapter, BasicCascaderProps, BasicCascaderInnerData> {
187
190
  constructor(adapter: CascaderAdapter);
188
191
  init(): void;
192
+ _setEmptyContentMinWidth(): void;
189
193
  handleKeyDown: (e: any) => void;
190
194
  destroy(): void;
191
195
  _isDisabled(): any;
@@ -244,16 +248,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
244
248
  */
245
249
  calcCheckedKeys(key: string, curCheckedStatus: boolean): {
246
250
  checkedKeys: Set<string>;
247
- halfCheckedKeys: Set<string>; /**
248
- * If selectedKeys does not meet the update conditions,
249
- * and state.selectedKeys is the same as selectedKeys
250
- * at this time, state.selectedKeys should be cleared.
251
- * A typical scenario is:
252
- * The originally selected node is the leaf node, but
253
- * after props.treeData is dynamically updated, the node
254
- * is a non-leaf node. At this point, selectedKeys should
255
- * be cleared.
256
- */
251
+ halfCheckedKeys: Set<string>;
257
252
  };
258
253
  handleInputChange(sugInput: string): void;
259
254
  handleClear(): void;
@@ -1,3 +1,4 @@
1
+ import _isString from "lodash/isString";
1
2
  import _isObject from "lodash/isObject";
2
3
  import _isFunction from "lodash/isFunction";
3
4
  import _includes from "lodash/includes";
@@ -61,6 +62,20 @@ export default class CascaderFoundation extends BaseFoundation {
61
62
  this.open();
62
63
  }
63
64
  }
65
+ _setEmptyContentMinWidth() {
66
+ const {
67
+ style
68
+ } = this.getProps();
69
+ let width;
70
+ if (style && _isNumber(style.width)) {
71
+ width = style.width;
72
+ } else if (style && _isString(style.width) && !style.width.includes('%')) {
73
+ width = style.width;
74
+ } else {
75
+ width = this._adapter.getTriggerWidth();
76
+ }
77
+ this._adapter.setEmptyContentMinWidth(width);
78
+ }
64
79
  destroy() {
65
80
  this._adapter.unregisterClickOutsideHandler();
66
81
  }
@@ -328,6 +343,7 @@ export default class CascaderFoundation extends BaseFoundation {
328
343
  }
329
344
  this._adapter.notifyDropdownVisibleChange(true);
330
345
  this._adapter.registerClickOutsideHandler(e => this.close(e));
346
+ this._setEmptyContentMinWidth();
331
347
  }
332
348
  reCalcActiveKeys() {
333
349
  const {
@@ -31,6 +31,7 @@ export default class NavigationFoundation extends BaseFoundation {
31
31
  let keysMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
32
32
  let parentKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
33
33
  let keyPropName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'itemKey';
34
+ var _a;
34
35
  if (Array.isArray(items) && items.length) {
35
36
  for (const item of items) {
36
37
  if (Array.isArray(item)) {
@@ -42,10 +43,15 @@ export default class NavigationFoundation extends BaseFoundation {
42
43
  }
43
44
  if (itemKey) {
44
45
  keysMap[itemKey] = [...parentKeys];
46
+ // Children is not a recommended usage and may cause some bug-like performance, but some users have already used it, so here we only delete the ts definition instead of deleting the actual code
47
+ // children 并不是我们推荐的用法,可能会导致一些像 bug的表现,但是有些用户已经用了,所以此处仅作删除 ts 定义而非删除实际代码的操作
48
+ // refer https://github.com/DouyinFE/semi-design/issues/2710
49
+ // @ts-ignore
50
+ const itemChildren = (_a = item.props) === null || _a === void 0 ? void 0 : _a.children;
45
51
  if (Array.isArray(item.items) && item.items.length) {
46
52
  NavigationFoundation.buildItemKeysMap(item.items, keysMap, [...parentKeys, itemKey], keyPropName);
47
- } else if (item.props && item.props.children) {
48
- const children = Array.isArray(item.props.children) ? item.props.children : [item.props.children];
53
+ } else if (itemChildren) {
54
+ const children = Array.isArray(itemChildren) ? itemChildren : [itemChildren];
49
55
  NavigationFoundation.buildItemKeysMap(children, keysMap, [...parentKeys, itemKey], keyPropName);
50
56
  }
51
57
  }
@@ -10,7 +10,6 @@ export interface ItemProps {
10
10
  link?: string;
11
11
  linkOptions?: Record<string, any>;
12
12
  disabled?: boolean;
13
- children?: any;
14
13
  }
15
14
  export type ItemKey = string | number;
16
15
  export interface SelectedItemProps<Props = ItemProps> {
@@ -80,6 +80,11 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
80
80
  }
81
81
  if (itemKey) {
82
82
  keysMap[itemKey] = [...parentKeys];
83
+ // Children is not a recommended usage and may cause some bug-like performance, but some users have already used it, so here we only delete the ts definition instead of deleting the actual code
84
+ // children 并不是我们推荐的用法,可能会导致一些像 bug的表现,但是有些用户已经用了,所以此处仅作删除 ts 定义而非删除实际代码的操作
85
+ // refer https://github.com/DouyinFE/semi-design/issues/2710
86
+ // @ts-ignore
87
+ const itemChildren = item.props?.children;
83
88
 
84
89
  if (Array.isArray(item.items) && item.items.length) {
85
90
  NavigationFoundation.buildItemKeysMap(
@@ -87,11 +92,11 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
87
92
  keysMap,
88
93
  [...parentKeys, itemKey],
89
94
  keyPropName
90
- );
91
- } else if (item.props && item.props.children) {
92
- const children = Array.isArray(item.props.children)
93
- ? item.props.children
94
- : [item.props.children];
95
+ );
96
+ } else if (itemChildren) {
97
+ const children = Array.isArray(itemChildren)
98
+ ? itemChildren
99
+ : [itemChildren];
95
100
  NavigationFoundation.buildItemKeysMap(
96
101
  children,
97
102
  keysMap,
@@ -13,8 +13,7 @@ export interface ItemProps {
13
13
  isSubNav?: boolean;
14
14
  link?: string;
15
15
  linkOptions?: Record<string, any>;
16
- disabled?: boolean;
17
- children?: any
16
+ disabled?: boolean
18
17
  }
19
18
 
20
19
  export type ItemKey = string | number;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.75.0",
3
+ "version": "2.75.1-alpha.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.75.0",
11
- "@douyinfe/semi-json-viewer-core": "2.75.0",
10
+ "@douyinfe/semi-animation": "2.74.0",
11
+ "@douyinfe/semi-json-viewer-core": "2.74.0",
12
12
  "@mdx-js/mdx": "^3.0.1",
13
13
  "async-validator": "^3.5.0",
14
14
  "classnames": "^2.2.6",
@@ -29,7 +29,7 @@
29
29
  "*.scss",
30
30
  "*.css"
31
31
  ],
32
- "gitHead": "cd269c0f1d3a0af5a564109f22e3dc51dfd7691a",
32
+ "gitHead": "728ec65f284c2173b012475c0af90ac24dfa9c87",
33
33
  "devDependencies": {
34
34
  "@babel/plugin-transform-runtime": "^7.15.8",
35
35
  "@babel/preset-env": "^7.15.8",
@@ -0,0 +1,58 @@
1
+ module.exports = function (babel) {
2
+ const { types: t } = babel;
3
+ return {
4
+ visitor: {
5
+ ImportDeclaration(path) {
6
+ // 只处理 lottie-web 的导入
7
+ if (path.node.source.value === 'lottie-web') {
8
+ // 创建变量声明
9
+ const varDeclaration = t.variableDeclaration('var', [
10
+ t.variableDeclarator(
11
+ t.identifier('_lottieWeb'),
12
+ t.identifier('undefined')
13
+ )
14
+ ]);
15
+
16
+ // 创建条件语句
17
+ const ifStatement = t.ifStatement(
18
+ t.binaryExpression(
19
+ '!==',
20
+ t.unaryExpression('typeof', t.identifier('document')),
21
+ t.stringLiteral('undefined')
22
+ ),
23
+ t.blockStatement([
24
+ // _lottieWeb = require("lottie-web")
25
+ t.expressionStatement(
26
+ t.assignmentExpression(
27
+ '=',
28
+ t.identifier('_lottieWeb'),
29
+ t.callExpression(t.identifier('require'), [
30
+ t.stringLiteral('lottie-web')
31
+ ])
32
+ )
33
+ ),
34
+ // if (_lottieWeb && _lottieWeb.__esModule) _lottieWeb = _lottieWeb.default
35
+ t.ifStatement(
36
+ t.logicalExpression(
37
+ '&&',
38
+ t.identifier('_lottieWeb'),
39
+ t.memberExpression(t.identifier('_lottieWeb'), t.identifier('__esModule'))
40
+ ),
41
+ t.expressionStatement(
42
+ t.assignmentExpression(
43
+ '=',
44
+ t.identifier('_lottieWeb'),
45
+ t.memberExpression(t.identifier('_lottieWeb'), t.identifier('default'))
46
+ )
47
+ )
48
+ )
49
+ ])
50
+ );
51
+
52
+ path.insertBefore(varDeclaration);
53
+ path.replaceWith(ifStatement);
54
+ }
55
+ }
56
+ }
57
+ };
58
+ };