@douyinfe/semi-foundation 2.75.0 → 2.75.1-alpha.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/cascader/cascader.scss +8 -2
- package/cascader/foundation.ts +19 -2
- package/lib/cjs/cascader/cascader.css +6 -2
- package/lib/cjs/cascader/cascader.scss +8 -2
- package/lib/cjs/cascader/foundation.d.ts +5 -10
- package/lib/cjs/cascader/foundation.js +16 -0
- package/lib/cjs/navigation/foundation.js +8 -2
- package/lib/cjs/navigation/itemFoundation.d.ts +0 -1
- package/lib/es/cascader/cascader.css +6 -2
- package/lib/es/cascader/cascader.scss +8 -2
- package/lib/es/cascader/foundation.d.ts +5 -10
- package/lib/es/cascader/foundation.js +16 -0
- package/lib/es/navigation/foundation.js +8 -2
- package/lib/es/navigation/itemFoundation.d.ts +0 -1
- package/navigation/foundation.ts +10 -5
- package/navigation/itemFoundation.ts +1 -2
- package/package.json +4 -4
package/cascader/cascader.scss
CHANGED
|
@@ -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,
|
package/cascader/foundation.ts
CHANGED
|
@@ -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() {
|
|
@@ -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 {
|
|
@@ -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 (
|
|
55
|
-
const children = Array.isArray(
|
|
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
|
}
|
|
@@ -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 (
|
|
48
|
-
const children = Array.isArray(
|
|
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
|
}
|
package/navigation/foundation.ts
CHANGED
|
@@ -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 (
|
|
92
|
-
const children = Array.isArray(
|
|
93
|
-
?
|
|
94
|
-
: [
|
|
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,
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.75.
|
|
3
|
+
"version": "2.75.1-alpha.1",
|
|
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.
|
|
11
|
-
"@douyinfe/semi-json-viewer-core": "2.75.
|
|
10
|
+
"@douyinfe/semi-animation": "2.75.1-alpha.1",
|
|
11
|
+
"@douyinfe/semi-json-viewer-core": "2.75.1-alpha.1",
|
|
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": "
|
|
32
|
+
"gitHead": "008eacc5033ed0cec2856002dfdf0ecd46debb67",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
35
35
|
"@babel/preset-env": "^7.15.8",
|