@douyinfe/semi-foundation 2.10.0-beta.0 → 2.10.2
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/carousel/carousel.scss +4 -4
- package/carousel/foundation.ts +0 -2
- package/cascader/foundation.ts +6 -6
- package/checkbox/checkboxGroupFoundation.ts +2 -2
- package/datePicker/_utils/getDefaultPickerDate.ts +3 -3
- package/datePicker/_utils/parser.ts +1 -1
- package/datePicker/foundation.ts +4 -4
- package/datePicker/monthsGridFoundation.ts +11 -11
- package/datePicker/yearAndMonthFoundation.ts +1 -1
- package/form/foundation.ts +9 -5
- package/form/interface.ts +1 -0
- package/input/textareaFoundation.ts +5 -5
- package/inputNumber/foundation.ts +25 -9
- package/lib/cjs/carousel/carousel.css +4 -4
- package/lib/cjs/carousel/carousel.scss +4 -4
- package/lib/cjs/carousel/foundation.d.ts +0 -1
- package/lib/cjs/carousel/foundation.js +0 -3
- package/lib/cjs/cascader/foundation.d.ts +2 -2
- package/lib/cjs/cascader/foundation.js +6 -6
- package/lib/cjs/checkbox/checkboxGroupFoundation.d.ts +1 -1
- package/lib/cjs/checkbox/checkboxGroupFoundation.js +2 -2
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.js +2 -2
- package/lib/cjs/datePicker/_utils/parser.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/parser.js +2 -2
- package/lib/cjs/datePicker/foundation.js +3 -3
- package/lib/cjs/datePicker/monthsGridFoundation.js +9 -9
- package/lib/cjs/datePicker/yearAndMonthFoundation.d.ts +1 -1
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +2 -2
- package/lib/cjs/form/foundation.d.ts +1 -0
- package/lib/cjs/form/foundation.js +9 -5
- package/lib/cjs/form/interface.d.ts +1 -0
- package/lib/cjs/input/textareaFoundation.d.ts +5 -5
- package/lib/cjs/inputNumber/foundation.d.ts +8 -0
- package/lib/cjs/inputNumber/foundation.js +20 -8
- package/lib/cjs/navigation/foundation.d.ts +3 -3
- package/lib/cjs/navigation/foundation.js +13 -13
- package/lib/cjs/tabs/foundation.js +2 -2
- package/lib/cjs/timePicker/ComboxFoundation.js +1 -1
- package/lib/cjs/timePicker/constants.d.ts +1 -1
- package/lib/cjs/timePicker/constants.js +1 -1
- package/lib/cjs/timePicker/foundation.js +1 -1
- package/lib/cjs/transfer/foundation.js +3 -3
- package/lib/cjs/transfer/{transferUtlls.d.ts → transferUtils.d.ts} +0 -0
- package/lib/cjs/transfer/{transferUtlls.js → transferUtils.js} +0 -0
- package/lib/cjs/tree/foundation.d.ts +2 -2
- package/lib/cjs/tree/foundation.js +4 -4
- package/lib/cjs/tree/treeUtil.js +11 -11
- package/lib/cjs/treeSelect/constants.d.ts +1 -1
- package/lib/cjs/treeSelect/constants.js +1 -1
- package/lib/cjs/treeSelect/foundation.d.ts +2 -2
- package/lib/cjs/treeSelect/foundation.js +4 -4
- package/lib/cjs/upload/foundation.js +9 -8
- package/lib/cjs/upload/utils.js +1 -1
- package/lib/cjs/utils/isNullOrUndefined.d.ts +1 -1
- package/lib/cjs/utils/isNullOrUndefined.js +1 -1
- package/lib/cjs/utils/object.d.ts +6 -6
- package/lib/cjs/utils/object.js +2 -2
- package/lib/es/carousel/carousel.css +4 -4
- package/lib/es/carousel/carousel.scss +4 -4
- package/lib/es/carousel/foundation.d.ts +0 -1
- package/lib/es/carousel/foundation.js +0 -2
- package/lib/es/cascader/foundation.d.ts +2 -2
- package/lib/es/cascader/foundation.js +6 -6
- package/lib/es/checkbox/checkboxGroupFoundation.d.ts +1 -1
- package/lib/es/checkbox/checkboxGroupFoundation.js +2 -2
- package/lib/es/datePicker/_utils/getDefaultPickerDate.js +3 -3
- package/lib/es/datePicker/_utils/parser.d.ts +1 -1
- package/lib/es/datePicker/_utils/parser.js +1 -1
- package/lib/es/datePicker/foundation.js +4 -4
- package/lib/es/datePicker/monthsGridFoundation.js +10 -10
- package/lib/es/datePicker/yearAndMonthFoundation.d.ts +1 -1
- package/lib/es/datePicker/yearAndMonthFoundation.js +1 -1
- package/lib/es/form/foundation.d.ts +1 -0
- package/lib/es/form/foundation.js +9 -5
- package/lib/es/form/interface.d.ts +1 -0
- package/lib/es/input/textareaFoundation.d.ts +5 -5
- package/lib/es/inputNumber/foundation.d.ts +8 -0
- package/lib/es/inputNumber/foundation.js +18 -8
- package/lib/es/navigation/foundation.d.ts +3 -3
- package/lib/es/navigation/foundation.js +13 -13
- package/lib/es/tabs/foundation.js +2 -2
- package/lib/es/timePicker/ComboxFoundation.js +1 -1
- package/lib/es/timePicker/constants.d.ts +1 -1
- package/lib/es/timePicker/constants.js +1 -1
- package/lib/es/timePicker/foundation.js +1 -1
- package/lib/es/transfer/foundation.js +1 -1
- package/lib/es/transfer/{transferUtlls.d.ts → transferUtils.d.ts} +0 -0
- package/lib/es/transfer/{transferUtlls.js → transferUtils.js} +0 -0
- package/lib/es/tree/foundation.d.ts +2 -2
- package/lib/es/tree/foundation.js +4 -4
- package/lib/es/tree/treeUtil.js +11 -11
- package/lib/es/treeSelect/constants.d.ts +1 -1
- package/lib/es/treeSelect/constants.js +1 -1
- package/lib/es/treeSelect/foundation.d.ts +2 -2
- package/lib/es/treeSelect/foundation.js +4 -4
- package/lib/es/upload/foundation.js +9 -8
- package/lib/es/upload/utils.js +1 -1
- package/lib/es/utils/isNullOrUndefined.d.ts +1 -1
- package/lib/es/utils/isNullOrUndefined.js +1 -1
- package/lib/es/utils/object.d.ts +6 -6
- package/lib/es/utils/object.js +2 -2
- package/navigation/foundation.ts +12 -12
- package/package.json +3 -3
- package/tabs/foundation.ts +2 -2
- package/timePicker/ComboxFoundation.ts +1 -1
- package/timePicker/constants.ts +1 -1
- package/timePicker/foundation.ts +1 -1
- package/transfer/foundation.ts +1 -1
- package/transfer/{transferUtlls.ts → transferUtils.ts} +0 -0
- package/tree/foundation.ts +4 -4
- package/tree/treeUtil.ts +11 -11
- package/treeSelect/constants.ts +1 -1
- package/treeSelect/foundation.ts +4 -4
- package/upload/foundation.ts +9 -8
- package/upload/utils.ts +1 -1
- package/utils/isNullOrUndefined.ts +1 -1
- package/utils/object.ts +10 -10
|
@@ -18,6 +18,13 @@ export interface InputNumberAdapter extends DefaultAdapter {
|
|
|
18
18
|
restoreCursor: (str?: string) => boolean;
|
|
19
19
|
fixCaret: (start: number, end: number) => void;
|
|
20
20
|
setClickUpOrDown: (clicked: boolean) => void;
|
|
21
|
+
updateStates: (states: BaseInputNumberState, callback?: () => void) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface BaseInputNumberState {
|
|
24
|
+
value?: number | string;
|
|
25
|
+
number?: number | null;
|
|
26
|
+
focusing?: boolean;
|
|
27
|
+
hovering?: boolean;
|
|
21
28
|
}
|
|
22
29
|
declare class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
|
|
23
30
|
_intervalHasRegistered: boolean;
|
|
@@ -108,5 +115,6 @@ declare class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
|
|
|
108
115
|
isValidString(str: string): boolean;
|
|
109
116
|
notifyChange(value: string, e: any): void;
|
|
110
117
|
notifyNumberChange(value: number, e: any): void;
|
|
118
|
+
updateStates(states: BaseInputNumberState, callback?: () => void): void;
|
|
111
119
|
}
|
|
112
120
|
export default InputNumberFoundation;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _isString from "lodash/isString";
|
|
1
2
|
import _get from "lodash/get";
|
|
2
3
|
import _toString from "lodash/toString";
|
|
3
4
|
import _toNumber from "lodash/toNumber";
|
|
@@ -6,6 +7,7 @@ import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
|
6
7
|
import _lastIndexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/last-index-of";
|
|
7
8
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
8
9
|
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
10
|
+
import _Number$isNaN from "@babel/runtime-corejs3/core-js-stable/number/is-nan";
|
|
9
11
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
10
12
|
|
|
11
13
|
/* eslint-disable max-len */
|
|
@@ -208,9 +210,9 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
208
210
|
|
|
209
211
|
this._adapter.recordCursorPosition();
|
|
210
212
|
|
|
211
|
-
const
|
|
213
|
+
const formattedVal = code === keyCode.UP ? this.add() : this.minus();
|
|
212
214
|
|
|
213
|
-
this._doInput(
|
|
215
|
+
this._doInput(formattedVal, event, () => {
|
|
214
216
|
this._adapter.restoreCursor();
|
|
215
217
|
});
|
|
216
218
|
|
|
@@ -384,18 +386,22 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
384
386
|
value
|
|
385
387
|
} = this.getProps();
|
|
386
388
|
const propsValue = this._isControlledComponent('value') ? value : defaultValue;
|
|
387
|
-
const
|
|
389
|
+
const tmpNumber = this.doParse(_toString(propsValue), false, true, true);
|
|
388
390
|
let number = null;
|
|
389
391
|
|
|
390
|
-
if (typeof
|
|
391
|
-
number =
|
|
392
|
+
if (typeof tmpNumber === 'number' && !isNaN(tmpNumber)) {
|
|
393
|
+
number = tmpNumber;
|
|
392
394
|
}
|
|
393
395
|
|
|
394
|
-
const
|
|
396
|
+
const formattedValue = typeof number === 'number' ? this.doFormat(number, true) : '';
|
|
395
397
|
|
|
396
398
|
this._adapter.setNumber(number);
|
|
397
399
|
|
|
398
|
-
this._adapter.setValue(
|
|
400
|
+
this._adapter.setValue(formattedValue);
|
|
401
|
+
|
|
402
|
+
if (_isString(formattedValue) && formattedValue !== String(propsValue)) {
|
|
403
|
+
this.notifyChange(formattedValue, null);
|
|
404
|
+
}
|
|
399
405
|
}
|
|
400
406
|
|
|
401
407
|
add(step, event) {
|
|
@@ -466,7 +472,7 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
466
472
|
_adjustPrec(num) {
|
|
467
473
|
const precision = this.getProp('precision');
|
|
468
474
|
|
|
469
|
-
if (typeof precision === 'number' && num !== '') {
|
|
475
|
+
if (typeof precision === 'number' && num !== '' && num !== null && !_Number$isNaN(Number(num))) {
|
|
470
476
|
num = Number(num).toFixed(precision);
|
|
471
477
|
}
|
|
472
478
|
|
|
@@ -684,6 +690,10 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
684
690
|
}
|
|
685
691
|
}
|
|
686
692
|
|
|
693
|
+
updateStates(states, callback) {
|
|
694
|
+
this._adapter.updateStates(states, callback);
|
|
695
|
+
}
|
|
696
|
+
|
|
687
697
|
}
|
|
688
698
|
|
|
689
699
|
export default InputNumberFoundation;
|
|
@@ -60,14 +60,14 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
60
60
|
getCalcState(): {
|
|
61
61
|
itemKeysMap: {};
|
|
62
62
|
willOpenKeys: any[];
|
|
63
|
-
|
|
63
|
+
formattedItems: any[];
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
66
|
* Calculate formatted items and itemsKeyMap
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
getFormattedItems(): {
|
|
69
69
|
itemKeysMap: {};
|
|
70
|
-
|
|
70
|
+
formattedItems: any[];
|
|
71
71
|
};
|
|
72
72
|
/**
|
|
73
73
|
* Calculate the keys that will need to be opened soon
|
|
@@ -92,7 +92,7 @@ export default class NavigationFoundation extends BaseFoundation {
|
|
|
92
92
|
const {
|
|
93
93
|
itemKeysMap,
|
|
94
94
|
willOpenKeys,
|
|
95
|
-
|
|
95
|
+
formattedItems
|
|
96
96
|
} = this.getCalcState();
|
|
97
97
|
const parentSelectKeys = this.selectLevelZeroParentKeys(itemKeysMap, willSelectedKeys);
|
|
98
98
|
willSelectedKeys = _concatInstanceProperty(willSelectedKeys).call(willSelectedKeys, parentSelectKeys);
|
|
@@ -102,7 +102,7 @@ export default class NavigationFoundation extends BaseFoundation {
|
|
|
102
102
|
selectedKeys: willSelectedKeys,
|
|
103
103
|
itemKeysMap,
|
|
104
104
|
openKeys: willOpenKeys,
|
|
105
|
-
items:
|
|
105
|
+
items: formattedItems
|
|
106
106
|
};
|
|
107
107
|
} else {
|
|
108
108
|
this._adapter.updateSelectedKeys(willSelectedKeys);
|
|
@@ -111,7 +111,7 @@ export default class NavigationFoundation extends BaseFoundation {
|
|
|
111
111
|
|
|
112
112
|
this._adapter.updateOpenKeys(willOpenKeys);
|
|
113
113
|
|
|
114
|
-
this._adapter.updateItems(
|
|
114
|
+
this._adapter.updateItems(formattedItems);
|
|
115
115
|
|
|
116
116
|
this._adapter.setItemsChanged(true);
|
|
117
117
|
}
|
|
@@ -126,13 +126,13 @@ export default class NavigationFoundation extends BaseFoundation {
|
|
|
126
126
|
getCalcState() {
|
|
127
127
|
const {
|
|
128
128
|
itemKeysMap,
|
|
129
|
-
|
|
130
|
-
} = this.
|
|
129
|
+
formattedItems
|
|
130
|
+
} = this.getFormattedItems();
|
|
131
131
|
const willOpenKeys = this.getWillOpenKeys(itemKeysMap);
|
|
132
132
|
return {
|
|
133
133
|
itemKeysMap,
|
|
134
134
|
willOpenKeys,
|
|
135
|
-
|
|
135
|
+
formattedItems
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
@@ -140,17 +140,17 @@ export default class NavigationFoundation extends BaseFoundation {
|
|
|
140
140
|
*/
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
getFormattedItems() {
|
|
144
144
|
const {
|
|
145
145
|
items,
|
|
146
146
|
children
|
|
147
147
|
} = this.getProps();
|
|
148
|
-
const
|
|
149
|
-
const willHandleItems = _Array$isArray(items) && items.length ?
|
|
148
|
+
const formattedItems = this.formatItems(items);
|
|
149
|
+
const willHandleItems = _Array$isArray(items) && items.length ? formattedItems : children;
|
|
150
150
|
const itemKeysMap = NavigationFoundation.buildItemKeysMap(willHandleItems);
|
|
151
151
|
return {
|
|
152
152
|
itemKeysMap,
|
|
153
|
-
|
|
153
|
+
formattedItems
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
@@ -241,13 +241,13 @@ export default class NavigationFoundation extends BaseFoundation {
|
|
|
241
241
|
|
|
242
242
|
formatItems() {
|
|
243
243
|
let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
244
|
-
const
|
|
244
|
+
const formattedItems = [];
|
|
245
245
|
|
|
246
246
|
for (const item of items) {
|
|
247
|
-
|
|
247
|
+
formattedItems.push(new NavItem(item));
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
return
|
|
250
|
+
return formattedItems;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
handleSelect(data) {
|
|
@@ -23,9 +23,9 @@ class TabsFoundation extends BaseFoundation {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
handleTabClick(activeKey, event) {
|
|
26
|
-
const
|
|
26
|
+
const isControlledComponent = this._isInProps('activeKey');
|
|
27
27
|
|
|
28
|
-
if (
|
|
28
|
+
if (isControlledComponent) {
|
|
29
29
|
this._notifyChange(activeKey);
|
|
30
30
|
} else {
|
|
31
31
|
this._notifyChange(activeKey);
|
|
@@ -91,7 +91,7 @@ class ComboboxFoundation extends BaseFoundation {
|
|
|
91
91
|
if (this._isInProps('format')) {
|
|
92
92
|
return this.getProp('format');
|
|
93
93
|
} else if (this.getProp('use12Hours')) {
|
|
94
|
-
return strings.
|
|
94
|
+
return strings.DEFAULT_FORMAT_A;
|
|
95
95
|
} else {
|
|
96
96
|
return strings.DEFAULT_FORMAT;
|
|
97
97
|
}
|
|
@@ -12,7 +12,7 @@ declare const strings: {
|
|
|
12
12
|
DEFAULT_MULTIPLE_SEPARATOR: ",";
|
|
13
13
|
SIZE: readonly ["small", "large", "default"];
|
|
14
14
|
DEFAULT_FORMAT: string;
|
|
15
|
-
|
|
15
|
+
DEFAULT_FORMAT_A: string;
|
|
16
16
|
STATUS: readonly ["default", "error", "warning", "success"];
|
|
17
17
|
DEFAULT_POSITION: {
|
|
18
18
|
time: string;
|
|
@@ -18,7 +18,7 @@ const strings = {
|
|
|
18
18
|
DEFAULT_MULTIPLE_SEPARATOR,
|
|
19
19
|
SIZE: inputStrings.SIZE,
|
|
20
20
|
DEFAULT_FORMAT: 'HH:mm:ss',
|
|
21
|
-
|
|
21
|
+
DEFAULT_FORMAT_A: 'a h:mm:ss',
|
|
22
22
|
STATUS: VALIDATE_STATUS,
|
|
23
23
|
DEFAULT_POSITION: {
|
|
24
24
|
[TYPE_TIME_PICKER]: 'bottomLeft',
|
|
@@ -66,7 +66,7 @@ class TimePickerFoundation extends BaseFoundation {
|
|
|
66
66
|
if (this._isInProps('format')) {
|
|
67
67
|
return this.getProp('format');
|
|
68
68
|
} else if (this.getProp('use12Hours')) {
|
|
69
|
-
return strings.
|
|
69
|
+
return strings.DEFAULT_FORMAT_A;
|
|
70
70
|
} else {
|
|
71
71
|
return strings.DEFAULT_FORMAT;
|
|
72
72
|
}
|
|
@@ -11,7 +11,7 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
|
11
11
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
|
|
12
12
|
import BaseFoundation from '../base/foundation';
|
|
13
13
|
import { strings } from './constants';
|
|
14
|
-
import { _generateGroupedData, _generateTreeData } from './
|
|
14
|
+
import { _generateGroupedData, _generateTreeData } from './transferUtils'; // eslint-disable-next-line max-len
|
|
15
15
|
|
|
16
16
|
export default class TransferFoundation extends BaseFoundation {
|
|
17
17
|
constructor(adapter) {
|
|
File without changes
|
|
File without changes
|
|
@@ -256,8 +256,8 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
256
256
|
checkedKeys: Set<string>;
|
|
257
257
|
halfCheckedKeys: Set<string>;
|
|
258
258
|
};
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
calcCheckedStatus(targetStatus: boolean, eventKey: string): boolean;
|
|
260
|
+
calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean): {
|
|
261
261
|
checkedKeys: Set<string>;
|
|
262
262
|
halfCheckedKeys: Set<any>;
|
|
263
263
|
};
|
|
@@ -317,7 +317,7 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
317
317
|
*/
|
|
318
318
|
|
|
319
319
|
|
|
320
|
-
|
|
320
|
+
calcCheckedStatus(targetStatus, eventKey) {
|
|
321
321
|
// From checked to unchecked, you can change it directly
|
|
322
322
|
if (!targetStatus) {
|
|
323
323
|
return targetStatus;
|
|
@@ -350,7 +350,7 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
350
350
|
*/
|
|
351
351
|
|
|
352
352
|
|
|
353
|
-
|
|
353
|
+
calcNonDisabledCheckedKeys(eventKey, targetStatus) {
|
|
354
354
|
const {
|
|
355
355
|
keyEntities,
|
|
356
356
|
disabledKeys
|
|
@@ -394,11 +394,11 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
394
394
|
|
|
395
395
|
if (checkRelation === 'related') {
|
|
396
396
|
// Find the checked state of the current node
|
|
397
|
-
const targetStatus = disableStrictly ? this.
|
|
397
|
+
const targetStatus = disableStrictly ? this.calcCheckedStatus(!checked, eventKey) : !checked;
|
|
398
398
|
const {
|
|
399
399
|
checkedKeys,
|
|
400
400
|
halfCheckedKeys
|
|
401
|
-
} = disableStrictly ? this.
|
|
401
|
+
} = disableStrictly ? this.calcNonDisabledCheckedKeys(eventKey, targetStatus) : this.calcCheckedKeys(eventKey, targetStatus);
|
|
402
402
|
|
|
403
403
|
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
404
404
|
|
package/lib/es/tree/treeUtil.js
CHANGED
|
@@ -98,13 +98,13 @@ export function convertJsonToData(treeJson) {
|
|
|
98
98
|
if (_isObject(children)) {
|
|
99
99
|
var _context2;
|
|
100
100
|
|
|
101
|
-
const
|
|
101
|
+
const newChildren = [];
|
|
102
102
|
|
|
103
103
|
_forEachInstanceProperty(_context2 = _Object$entries(children)).call(_context2, c => {
|
|
104
|
-
traverseNode(c[0], c[1], currPath,
|
|
104
|
+
traverseNode(c[0], c[1], currPath, newChildren);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
newNode.children =
|
|
107
|
+
newNode.children = newChildren;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
res.push(newNode);
|
|
@@ -380,8 +380,8 @@ export function calcCheckedKeys(values, keyEntities) {
|
|
|
380
380
|
const allChecked = _everyInstanceProperty(siblingKeys).call(siblingKeys, siblingKey => checkedKeys.has(siblingKey));
|
|
381
381
|
|
|
382
382
|
if (!allChecked) {
|
|
383
|
-
const
|
|
384
|
-
halfCheckedKeys = new _Set([...halfCheckedKeys, ...
|
|
383
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
384
|
+
halfCheckedKeys = new _Set([...halfCheckedKeys, ...ancestorKeys]);
|
|
385
385
|
} else {
|
|
386
386
|
checkedKeys.add(parent.key); // IMPORTANT! parent level may not exist in original level map; if add to the end directly may destroy the hierarchical order
|
|
387
387
|
|
|
@@ -421,8 +421,8 @@ export function calcExpandedKeys() {
|
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
if (autoExpandParent) {
|
|
424
|
-
const
|
|
425
|
-
return new _Set(
|
|
424
|
+
const ancestorKeys = findAncestorKeys(keyList, keyEntities, true);
|
|
425
|
+
return new _Set(ancestorKeys);
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
return new _Set(keyList);
|
|
@@ -567,8 +567,8 @@ export function calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfChe
|
|
|
567
567
|
const allChecked = _everyInstanceProperty(siblingKeys).call(siblingKeys, key => checkedKeys.has(key));
|
|
568
568
|
|
|
569
569
|
if (!allChecked) {
|
|
570
|
-
const
|
|
571
|
-
halfCheckedKeys = new _Set([...halfCheckedKeys, ...
|
|
570
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
571
|
+
halfCheckedKeys = new _Set([...halfCheckedKeys, ...ancestorKeys]);
|
|
572
572
|
} else {
|
|
573
573
|
const par = node.parent;
|
|
574
574
|
checkedKeys.add(par.key);
|
|
@@ -618,10 +618,10 @@ export function calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfC
|
|
|
618
618
|
|
|
619
619
|
const anyChecked = _someInstanceProperty(siblingKeys).call(siblingKeys, key => checkedKeys.has(key) || halfCheckedKeys.has(key));
|
|
620
620
|
|
|
621
|
-
const
|
|
621
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false); // If there is checked or halfChecked in the sibling node, you need to change the parent node to halfChecked
|
|
622
622
|
|
|
623
623
|
if (anyChecked) {
|
|
624
|
-
_forEachInstanceProperty(
|
|
624
|
+
_forEachInstanceProperty(ancestorKeys).call(ancestorKeys, itemKey => {
|
|
625
625
|
if (checkedKeys.has(itemKey)) {
|
|
626
626
|
checkedKeys.delete(itemKey);
|
|
627
627
|
halfCheckedKeys.add(itemKey);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VALIDATE_STATUS, BASE_CLASS_PREFIX } from '../base/constants';
|
|
2
2
|
const cssClasses = {
|
|
3
3
|
PREFIX: "".concat(BASE_CLASS_PREFIX, "-tree-select"),
|
|
4
|
-
|
|
4
|
+
PREFIX_TREE: "".concat(BASE_CLASS_PREFIX, "-tree"),
|
|
5
5
|
PREFIX_OPTION: "".concat(BASE_CLASS_PREFIX, "-tree-select-option")
|
|
6
6
|
};
|
|
7
7
|
const strings = {
|
|
@@ -148,11 +148,11 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
148
148
|
halfCheckedKeys: Set<string>;
|
|
149
149
|
};
|
|
150
150
|
handleMultipleSelect(e: any, treeNode: BasicTreeNodeProps): void;
|
|
151
|
-
|
|
151
|
+
calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean): {
|
|
152
152
|
checkedKeys: Set<string>;
|
|
153
153
|
halfCheckedKeys: Set<any>;
|
|
154
154
|
};
|
|
155
|
-
|
|
155
|
+
calcCheckedStatus(targetStatus: boolean, eventKey: string): boolean;
|
|
156
156
|
handleNodeExpandInSearch(e: any, treeNode: BasicTreeNodeProps): void;
|
|
157
157
|
handleNodeExpand(e: any, treeNode: BasicTreeNodeProps): void;
|
|
158
158
|
/**
|
|
@@ -610,11 +610,11 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
610
610
|
} = treeNode;
|
|
611
611
|
|
|
612
612
|
if (checkRelation === 'related') {
|
|
613
|
-
const targetStatus = disableStrictly ? this.
|
|
613
|
+
const targetStatus = disableStrictly ? this.calcCheckedStatus(!checked, eventKey) : !checked;
|
|
614
614
|
const {
|
|
615
615
|
checkedKeys,
|
|
616
616
|
halfCheckedKeys
|
|
617
|
-
} = disableStrictly ? this.
|
|
617
|
+
} = disableStrictly ? this.calcNonDisabledCheckedKeys(eventKey, targetStatus) : this.calcCheckedKeys(eventKey, targetStatus);
|
|
618
618
|
|
|
619
619
|
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
620
620
|
|
|
@@ -660,7 +660,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
662
|
|
|
663
|
-
|
|
663
|
+
calcNonDisabledCheckedKeys(eventKey, targetStatus) {
|
|
664
664
|
const {
|
|
665
665
|
keyEntities,
|
|
666
666
|
disabledKeys
|
|
@@ -682,7 +682,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
682
682
|
return calcCheckedKeys(newCheckedKeys, keyEntities);
|
|
683
683
|
}
|
|
684
684
|
|
|
685
|
-
|
|
685
|
+
calcCheckedStatus(targetStatus, eventKey) {
|
|
686
686
|
if (!targetStatus) {
|
|
687
687
|
return targetStatus;
|
|
688
688
|
}
|
|
@@ -116,13 +116,13 @@ class UploadFoundation extends BaseFoundation {
|
|
|
116
116
|
maxSize,
|
|
117
117
|
minSize
|
|
118
118
|
} = this.getProps();
|
|
119
|
-
let
|
|
119
|
+
let isIllegal = false;
|
|
120
120
|
|
|
121
121
|
if (size > maxSize * byteKB || size < minSize * byteKB) {
|
|
122
|
-
|
|
122
|
+
isIllegal = true;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
return
|
|
125
|
+
return isIllegal;
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* 1. 选择文件
|
|
@@ -530,7 +530,7 @@ class UploadFoundation extends BaseFoundation {
|
|
|
530
530
|
});
|
|
531
531
|
|
|
532
532
|
switch (true) {
|
|
533
|
-
// sync
|
|
533
|
+
// sync validate - boolean
|
|
534
534
|
case buResult === true:
|
|
535
535
|
{
|
|
536
536
|
this.post(file);
|
|
@@ -550,17 +550,17 @@ class UploadFoundation extends BaseFoundation {
|
|
|
550
550
|
|
|
551
551
|
case buResult && isPromise(buResult):
|
|
552
552
|
{
|
|
553
|
-
_Promise.resolve(buResult).then(
|
|
553
|
+
_Promise.resolve(buResult).then(resolveData => {
|
|
554
554
|
var _context5;
|
|
555
555
|
|
|
556
556
|
let newResult = {
|
|
557
557
|
shouldUpload: true
|
|
558
558
|
};
|
|
559
559
|
|
|
560
|
-
const
|
|
560
|
+
const typeOfResolveData = _sliceInstanceProperty(_context5 = Object.prototype.toString.call(resolveData)).call(_context5, 8, -1);
|
|
561
561
|
|
|
562
|
-
if (
|
|
563
|
-
newResult = _Object$assign(_Object$assign({}, newResult),
|
|
562
|
+
if (typeOfResolveData === 'Object') {
|
|
563
|
+
newResult = _Object$assign(_Object$assign({}, newResult), resolveData);
|
|
564
564
|
}
|
|
565
565
|
|
|
566
566
|
this.handleBeforeUploadResultInObject(newResult, file);
|
|
@@ -1086,6 +1086,7 @@ class UploadFoundation extends BaseFoundation {
|
|
|
1086
1086
|
if (!disabled) {
|
|
1087
1087
|
if (directory) {
|
|
1088
1088
|
this.handleDirectoryDrop(e);
|
|
1089
|
+
return;
|
|
1089
1090
|
}
|
|
1090
1091
|
|
|
1091
1092
|
const files = _Array$from(e.dataTransfer.files);
|
package/lib/es/upload/utils.js
CHANGED
|
@@ -134,7 +134,7 @@ export function mapFileTree(items) {
|
|
|
134
134
|
const result = yield _Promise.all(promises);
|
|
135
135
|
return result;
|
|
136
136
|
} catch (error) {
|
|
137
|
-
console.warn('
|
|
137
|
+
console.warn('Captured error while loop directory.');
|
|
138
138
|
console.error(error);
|
|
139
139
|
return [];
|
|
140
140
|
}
|
package/lib/es/utils/object.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
declare type Many<T> = T | ReadonlyArray<T>;
|
|
2
2
|
declare type PropertyName = string | number | symbol;
|
|
3
3
|
declare type PropertyPath = Many<PropertyName>;
|
|
4
|
-
declare type
|
|
5
|
-
export declare function empty(object:
|
|
6
|
-
export declare function get(object:
|
|
7
|
-
export declare function remove(object:
|
|
4
|
+
declare type ObjectType = Record<string, any>;
|
|
5
|
+
export declare function empty(object: ObjectType): boolean;
|
|
6
|
+
export declare function get(object: ObjectType, path: PropertyPath): any;
|
|
7
|
+
export declare function remove(object: ObjectType, path: PropertyPath): void;
|
|
8
8
|
export declare function set(object: any, path: PropertyPath, value: any, allowEmpty?: boolean): any;
|
|
9
|
-
export declare function has(object:
|
|
9
|
+
export declare function has(object: ObjectType, path: PropertyPath): boolean;
|
|
10
10
|
/**
|
|
11
11
|
* set static properties from `srcObj` to `obj`
|
|
12
12
|
* @param {object|Function} obj
|
|
13
13
|
* @param {object|Function} srcObj
|
|
14
14
|
* @returns {object|Function}
|
|
15
15
|
*/
|
|
16
|
-
export declare function forwardStatics<T extends
|
|
16
|
+
export declare function forwardStatics<T extends ObjectType | ((...arg: any) => any)>(obj: T, srcObj: ObjectType | ((...arg: any) => any)): T;
|
|
17
17
|
export {};
|
package/lib/es/utils/object.js
CHANGED
|
@@ -31,8 +31,8 @@ function isEmptyObject(target) {
|
|
|
31
31
|
* }
|
|
32
32
|
* the result of JSON.stringify(a/b/d) are same: '{}'
|
|
33
33
|
* We can use the above features to remove keys with empty values in Form
|
|
34
|
-
* But we cannot use JSON.stringify() directly, because if the input parameter of JSON.stringify includes fiberNode, it will cause an TypeError: '
|
|
35
|
-
* So we have to mock it's
|
|
34
|
+
* But we cannot use JSON.stringify() directly, because if the input parameter of JSON.stringify includes fiberNode, it will cause an TypeError: 'Converting circular structure to JSON'
|
|
35
|
+
* So we have to mock it's behavior, also, the form value cannot have Symbol or function type, it can be ignored
|
|
36
36
|
*/
|
|
37
37
|
if (!_isObject(target)) {
|
|
38
38
|
return false;
|
package/navigation/foundation.ts
CHANGED
|
@@ -118,7 +118,7 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
118
118
|
init(lifecycle: string) {
|
|
119
119
|
const { defaultSelectedKeys, selectedKeys } = this.getProps();
|
|
120
120
|
let willSelectedKeys = selectedKeys || defaultSelectedKeys || [];
|
|
121
|
-
const { itemKeysMap, willOpenKeys,
|
|
121
|
+
const { itemKeysMap, willOpenKeys, formattedItems } = this.getCalcState();
|
|
122
122
|
const parentSelectKeys = this.selectLevelZeroParentKeys(itemKeysMap, willSelectedKeys);
|
|
123
123
|
willSelectedKeys = willSelectedKeys.concat(parentSelectKeys);
|
|
124
124
|
|
|
@@ -127,13 +127,13 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
127
127
|
selectedKeys: willSelectedKeys,
|
|
128
128
|
itemKeysMap,
|
|
129
129
|
openKeys: willOpenKeys,
|
|
130
|
-
items:
|
|
130
|
+
items: formattedItems,
|
|
131
131
|
};
|
|
132
132
|
} else {
|
|
133
133
|
this._adapter.updateSelectedKeys(willSelectedKeys);
|
|
134
134
|
this._adapter.setItemKeysMap(itemKeysMap);
|
|
135
135
|
this._adapter.updateOpenKeys(willOpenKeys);
|
|
136
|
-
this._adapter.updateItems(
|
|
136
|
+
this._adapter.updateItems(formattedItems);
|
|
137
137
|
this._adapter.setItemsChanged(true);
|
|
138
138
|
}
|
|
139
139
|
return undefined;
|
|
@@ -143,22 +143,22 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
143
143
|
* Get the state to be calculated
|
|
144
144
|
*/
|
|
145
145
|
getCalcState() {
|
|
146
|
-
const { itemKeysMap,
|
|
146
|
+
const { itemKeysMap, formattedItems } = this.getFormattedItems();
|
|
147
147
|
const willOpenKeys = this.getWillOpenKeys(itemKeysMap);
|
|
148
|
-
return { itemKeysMap, willOpenKeys,
|
|
148
|
+
return { itemKeysMap, willOpenKeys, formattedItems };
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Calculate formatted items and itemsKeyMap
|
|
153
153
|
*/
|
|
154
|
-
|
|
154
|
+
getFormattedItems() {
|
|
155
155
|
const { items, children } = this.getProps();
|
|
156
|
-
const
|
|
157
|
-
const willHandleItems = Array.isArray(items) && items.length ?
|
|
156
|
+
const formattedItems = this.formatItems(items);
|
|
157
|
+
const willHandleItems = Array.isArray(items) && items.length ? formattedItems : children;
|
|
158
158
|
const itemKeysMap = NavigationFoundation.buildItemKeysMap(willHandleItems);
|
|
159
159
|
return {
|
|
160
160
|
itemKeysMap,
|
|
161
|
-
|
|
161
|
+
formattedItems
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -229,11 +229,11 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
formatItems(items: ItemProps[] = []) {
|
|
232
|
-
const
|
|
232
|
+
const formattedItems = [];
|
|
233
233
|
for (const item of items) {
|
|
234
|
-
|
|
234
|
+
formattedItems.push(new NavItem(item));
|
|
235
235
|
}
|
|
236
|
-
return
|
|
236
|
+
return formattedItems;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
handleSelect(data: OnSelectData) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
11
|
-
"@douyinfe/semi-animation": "2.10.
|
|
11
|
+
"@douyinfe/semi-animation": "2.10.2",
|
|
12
12
|
"async-validator": "^3.5.0",
|
|
13
13
|
"classnames": "^2.2.6",
|
|
14
14
|
"date-fns": "^2.9.0",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"*.scss",
|
|
25
25
|
"*.css"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "00b27ff43fe6ed5d775d5849bd0adc4c4c5ea231",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
30
30
|
"@babel/plugin-transform-runtime": "^7.15.8",
|