@douyinfe/semi-foundation 2.9.1 → 2.10.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.
- package/carousel/carousel.scss +425 -0
- package/carousel/constants.ts +32 -0
- package/carousel/foundation.ts +164 -0
- package/carousel/rtl.scss +47 -0
- package/carousel/variables.scss +46 -0
- 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 +341 -0
- package/lib/cjs/carousel/carousel.scss +425 -0
- package/lib/cjs/carousel/constants.d.ts +27 -0
- package/lib/cjs/carousel/constants.js +41 -0
- package/lib/cjs/carousel/foundation.d.ts +29 -0
- package/lib/cjs/carousel/foundation.js +216 -0
- package/lib/cjs/carousel/rtl.scss +47 -0
- package/lib/cjs/carousel/variables.scss +46 -0
- 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/switch/constants.d.ts +1 -0
- package/lib/cjs/switch/constants.js +1 -0
- package/lib/cjs/switch/foundation.d.ts +3 -0
- package/lib/cjs/switch/foundation.js +18 -0
- package/lib/cjs/switch/switch.css +3 -0
- package/lib/cjs/switch/switch.scss +4 -0
- package/lib/cjs/switch/variables.scss +2 -0
- 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 +8 -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 +341 -0
- package/lib/es/carousel/carousel.scss +425 -0
- package/lib/es/carousel/constants.d.ts +27 -0
- package/lib/es/carousel/constants.js +28 -0
- package/lib/es/carousel/foundation.d.ts +29 -0
- package/lib/es/carousel/foundation.js +198 -0
- package/lib/es/carousel/rtl.scss +47 -0
- package/lib/es/carousel/variables.scss +46 -0
- 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/switch/constants.d.ts +1 -0
- package/lib/es/switch/constants.js +1 -0
- package/lib/es/switch/foundation.d.ts +3 -0
- package/lib/es/switch/foundation.js +18 -0
- package/lib/es/switch/switch.css +3 -0
- package/lib/es/switch/switch.scss +4 -0
- package/lib/es/switch/variables.scss +2 -0
- 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 +8 -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/switch/constants.ts +1 -0
- package/switch/foundation.ts +16 -0
- package/switch/switch.scss +4 -0
- package/switch/variables.scss +2 -0
- 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 +8 -8
- package/upload/utils.ts +1 -1
- package/utils/isNullOrUndefined.ts +1 -1
- package/utils/object.ts +10 -10
package/switch/foundation.ts
CHANGED
|
@@ -3,6 +3,7 @@ import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
|
3
3
|
export interface SwitchAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
4
4
|
setNativeControlChecked: (nativeControlChecked: boolean | undefined) => void;
|
|
5
5
|
setNativeControlDisabled: (nativeControlDisabled: boolean | undefined) => void;
|
|
6
|
+
setFocusVisible: (focusVisible: boolean) => void;
|
|
6
7
|
notifyChange: (checked: boolean, e: any) => void;
|
|
7
8
|
}
|
|
8
9
|
|
|
@@ -37,6 +38,21 @@ export default class SwitchFoundation<P = Record<string, any>, S = Record<string
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
handleFocusVisible = (event: any) => {
|
|
42
|
+
const { target } = event;
|
|
43
|
+
try {
|
|
44
|
+
if (target.matches(':focus-visible')) {
|
|
45
|
+
this._adapter.setFocusVisible(true);
|
|
46
|
+
}
|
|
47
|
+
} catch (error){
|
|
48
|
+
console.warn('The current browser does not support the focus-visible');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
handleBlur = () => {
|
|
53
|
+
this._adapter.setFocusVisible(false);
|
|
54
|
+
}
|
|
55
|
+
|
|
40
56
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
41
57
|
destroy(): void {}
|
|
42
58
|
}
|
package/switch/switch.scss
CHANGED
package/switch/variables.scss
CHANGED
|
@@ -37,6 +37,7 @@ $color-switch_unchecked-text-default: var(--semi-color-text-2); // 关闭态开
|
|
|
37
37
|
$color-switch_loading_spin-default: var(--semi-color-white); // 加载态开关loading图标颜色
|
|
38
38
|
$color-switch_spin_checked-bg-default: var(--semi-color-success-hover); // 已开启开关加载态loading背景颜色
|
|
39
39
|
$color-switch_spin_unchecked-bg-default: var(--semi-color-fill-1); // 已关闭开关加载态loading背景颜色
|
|
40
|
+
$color-switch_primary-outline-focus: var(--semi-color-primary-light-active); // 开关轮廓 - 聚焦
|
|
40
41
|
|
|
41
42
|
// Width/Height
|
|
42
43
|
$width-switch: 40px; // 开关宽度
|
|
@@ -57,6 +58,7 @@ $width-switch_checked_unchecked_text: 26px; // 开关按钮文字宽度
|
|
|
57
58
|
$width-switch_spin-small: 10px; // 小尺寸开关加载 spin 宽度
|
|
58
59
|
$width-switch_spin-default: 18px; // 默认尺寸开关加载 spin 宽度
|
|
59
60
|
$width-switch_spin-large: 28px; // 大尺寸开关加载 spin 宽度
|
|
61
|
+
$width-switch-outline: 2px; // 开关轮廓宽度
|
|
60
62
|
|
|
61
63
|
|
|
62
64
|
// Spacing
|
package/tabs/foundation.ts
CHANGED
|
@@ -30,8 +30,8 @@ class TabsFoundation<P = Record<string, any>, S = Record<string, any>> extends B
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
handleTabClick(activeKey: string, event: any): void {
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
33
|
+
const isControlledComponent = this._isInProps('activeKey');
|
|
34
|
+
if (isControlledComponent) {
|
|
35
35
|
this._notifyChange(activeKey);
|
|
36
36
|
} else {
|
|
37
37
|
this._notifyChange(activeKey);
|
|
@@ -89,7 +89,7 @@ class ComboboxFoundation extends BaseFoundation<DefaultAdapter> {
|
|
|
89
89
|
if (this._isInProps('format')) {
|
|
90
90
|
return this.getProp('format');
|
|
91
91
|
} else if (this.getProp('use12Hours')) {
|
|
92
|
-
return strings.
|
|
92
|
+
return strings.DEFAULT_FORMAT_A;
|
|
93
93
|
} else {
|
|
94
94
|
return strings.DEFAULT_FORMAT;
|
|
95
95
|
}
|
package/timePicker/constants.ts
CHANGED
|
@@ -21,7 +21,7 @@ const strings = {
|
|
|
21
21
|
DEFAULT_MULTIPLE_SEPARATOR,
|
|
22
22
|
SIZE: inputStrings.SIZE,
|
|
23
23
|
DEFAULT_FORMAT: 'HH:mm:ss',
|
|
24
|
-
|
|
24
|
+
DEFAULT_FORMAT_A: 'a h:mm:ss',
|
|
25
25
|
STATUS: VALIDATE_STATUS,
|
|
26
26
|
DEFAULT_POSITION: {
|
|
27
27
|
[TYPE_TIME_PICKER]: 'bottomLeft',
|
package/timePicker/foundation.ts
CHANGED
|
@@ -94,7 +94,7 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
|
|
|
94
94
|
if (this._isInProps('format')) {
|
|
95
95
|
return this.getProp('format');
|
|
96
96
|
} else if (this.getProp('use12Hours')) {
|
|
97
|
-
return strings.
|
|
97
|
+
return strings.DEFAULT_FORMAT_A;
|
|
98
98
|
} else {
|
|
99
99
|
return strings.DEFAULT_FORMAT;
|
|
100
100
|
}
|
package/transfer/foundation.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { omit } from 'lodash';
|
|
|
2
2
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
3
|
import { BasicValue as BasicTreeValue } from '../tree/foundation';
|
|
4
4
|
import { strings } from './constants';
|
|
5
|
-
import { _generateGroupedData, _generateTreeData } from './
|
|
5
|
+
import { _generateGroupedData, _generateTreeData } from './transferUtils';
|
|
6
6
|
|
|
7
7
|
export interface BasicDataItem {
|
|
8
8
|
[x: string]: any;
|
|
File without changes
|
package/tree/foundation.ts
CHANGED
|
@@ -544,7 +544,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
544
544
|
/*
|
|
545
545
|
* Compute the checked state of the node
|
|
546
546
|
*/
|
|
547
|
-
|
|
547
|
+
calcCheckedStatus(targetStatus: boolean, eventKey: string) {
|
|
548
548
|
// From checked to unchecked, you can change it directly
|
|
549
549
|
if (!targetStatus) {
|
|
550
550
|
return targetStatus;
|
|
@@ -566,7 +566,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
566
566
|
/*
|
|
567
567
|
* In strict disable mode, calculate the nodes of checked and halfCheckedKeys and return their corresponding keys
|
|
568
568
|
*/
|
|
569
|
-
|
|
569
|
+
calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean) {
|
|
570
570
|
const { keyEntities, disabledKeys } = this.getStates();
|
|
571
571
|
const { checkedKeys } = this.getCopyFromState(['checkedKeys']);
|
|
572
572
|
const descendantKeys = normalizeKeyList(findDescendantKeys([eventKey], keyEntities, false), keyEntities, true);
|
|
@@ -592,9 +592,9 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
592
592
|
const { checked, eventKey, data } = treeNode;
|
|
593
593
|
if (checkRelation === 'related') {
|
|
594
594
|
// Find the checked state of the current node
|
|
595
|
-
const targetStatus = disableStrictly ? this.
|
|
595
|
+
const targetStatus = disableStrictly ? this.calcCheckedStatus(!checked, eventKey) : !checked;
|
|
596
596
|
const { checkedKeys, halfCheckedKeys } = disableStrictly ?
|
|
597
|
-
this.
|
|
597
|
+
this.calcNonDisabledCheckedKeys(eventKey, targetStatus) :
|
|
598
598
|
this.calcCheckedKeys(eventKey, targetStatus);
|
|
599
599
|
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
600
600
|
this.notifyChange([...checkedKeys], e);
|
package/tree/treeUtil.ts
CHANGED
|
@@ -87,11 +87,11 @@ export function convertJsonToData(treeJson: TreeDataSimpleJson) {
|
|
|
87
87
|
value: children,
|
|
88
88
|
};
|
|
89
89
|
if (isObject(children)) {
|
|
90
|
-
const
|
|
90
|
+
const newChildren: any[] = [];
|
|
91
91
|
Object.entries(children).forEach(c => {
|
|
92
|
-
traverseNode(c[0], c[1], currPath,
|
|
92
|
+
traverseNode(c[0], c[1], currPath, newChildren);
|
|
93
93
|
});
|
|
94
|
-
newNode.children =
|
|
94
|
+
newNode.children = newChildren;
|
|
95
95
|
}
|
|
96
96
|
res.push(newNode);
|
|
97
97
|
};
|
|
@@ -327,8 +327,8 @@ export function calcCheckedKeys(values: any, keyEntities: KeyEntities) {
|
|
|
327
327
|
visited = [...visited, ...siblingKeys];
|
|
328
328
|
const allChecked = siblingKeys.every((siblingKey: string) => checkedKeys.has(siblingKey));
|
|
329
329
|
if (!allChecked) {
|
|
330
|
-
const
|
|
331
|
-
halfCheckedKeys = new Set([...halfCheckedKeys, ...
|
|
330
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
331
|
+
halfCheckedKeys = new Set([...halfCheckedKeys, ...ancestorKeys]);
|
|
332
332
|
} else {
|
|
333
333
|
checkedKeys.add(parent.key);
|
|
334
334
|
// IMPORTANT! parent level may not exist in original level map; if add to the end directly may destroy the hierarchical order
|
|
@@ -358,8 +358,8 @@ export function calcExpandedKeys(keyList: any[] = [], keyEntities: KeyEntities,
|
|
|
358
358
|
keyList = [keyList];
|
|
359
359
|
}
|
|
360
360
|
if (autoExpandParent) {
|
|
361
|
-
const
|
|
362
|
-
return new Set(
|
|
361
|
+
const ancestorKeys = findAncestorKeys(keyList, keyEntities, true);
|
|
362
|
+
return new Set(ancestorKeys);
|
|
363
363
|
}
|
|
364
364
|
return new Set(keyList);
|
|
365
365
|
}
|
|
@@ -482,8 +482,8 @@ export function calcCheckedKeysForChecked(key: string, keyEntities: KeyEntities,
|
|
|
482
482
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
483
483
|
const allChecked = siblingKeys.every(key => checkedKeys.has(key));
|
|
484
484
|
if (!allChecked) {
|
|
485
|
-
const
|
|
486
|
-
halfCheckedKeys = new Set([...halfCheckedKeys, ...
|
|
485
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
486
|
+
halfCheckedKeys = new Set([...halfCheckedKeys, ...ancestorKeys]);
|
|
487
487
|
} else {
|
|
488
488
|
const par = node.parent;
|
|
489
489
|
checkedKeys.add(par.key);
|
|
@@ -525,10 +525,10 @@ export function calcCheckedKeysForUnchecked(key: string, keyEntities: KeyEntitie
|
|
|
525
525
|
const siblingKeys = findSiblingKeys([key], keyEntities);
|
|
526
526
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
527
527
|
const anyChecked = siblingKeys.some(key => checkedKeys.has(key) || halfCheckedKeys.has(key));
|
|
528
|
-
const
|
|
528
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
529
529
|
// If there is checked or halfChecked in the sibling node, you need to change the parent node to halfChecked
|
|
530
530
|
if (anyChecked) {
|
|
531
|
-
|
|
531
|
+
ancestorKeys.forEach(itemKey => {
|
|
532
532
|
if (checkedKeys.has(itemKey)) {
|
|
533
533
|
checkedKeys.delete(itemKey);
|
|
534
534
|
halfCheckedKeys.add(itemKey);
|
package/treeSelect/constants.ts
CHANGED
package/treeSelect/foundation.ts
CHANGED
|
@@ -622,11 +622,11 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
622
622
|
const { checked, eventKey, data } = treeNode;
|
|
623
623
|
if (checkRelation === 'related') {
|
|
624
624
|
const targetStatus = disableStrictly ?
|
|
625
|
-
this.
|
|
625
|
+
this.calcCheckedStatus(!checked, eventKey) :
|
|
626
626
|
!checked;
|
|
627
627
|
|
|
628
628
|
const { checkedKeys, halfCheckedKeys } = disableStrictly ?
|
|
629
|
-
this.
|
|
629
|
+
this.calcNonDisabledCheckedKeys(eventKey, targetStatus) :
|
|
630
630
|
this.calcCheckedKeys(eventKey, targetStatus);
|
|
631
631
|
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
632
632
|
this._notifyChange([...checkedKeys], e);
|
|
@@ -656,7 +656,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
-
|
|
659
|
+
calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean) {
|
|
660
660
|
const { keyEntities, disabledKeys } = this.getStates();
|
|
661
661
|
const { checkedKeys } = this.getCopyFromState(['checkedKeys']);
|
|
662
662
|
const descendantKeys = normalizeKeyList(findDescendantKeys([eventKey], keyEntities, false), keyEntities, true);
|
|
@@ -671,7 +671,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
671
671
|
return calcCheckedKeys(newCheckedKeys, keyEntities);
|
|
672
672
|
}
|
|
673
673
|
|
|
674
|
-
|
|
674
|
+
calcCheckedStatus(targetStatus: boolean, eventKey: string) {
|
|
675
675
|
if (!targetStatus) {
|
|
676
676
|
return targetStatus;
|
|
677
677
|
}
|
package/upload/foundation.ts
CHANGED
|
@@ -124,11 +124,11 @@ class UploadFoundation<P = Record<string, any>, S = Record<string, any>> extends
|
|
|
124
124
|
checkFileSize(file: File): boolean {
|
|
125
125
|
const { size } = file;
|
|
126
126
|
const { maxSize, minSize } = this.getProps();
|
|
127
|
-
let
|
|
127
|
+
let isIllegal = false;
|
|
128
128
|
if (size > maxSize * byteKB || size < minSize * byteKB) {
|
|
129
|
-
|
|
129
|
+
isIllegal = true;
|
|
130
130
|
}
|
|
131
|
-
return
|
|
131
|
+
return isIllegal;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
@@ -425,7 +425,7 @@ class UploadFoundation<P = Record<string, any>, S = Record<string, any>> extends
|
|
|
425
425
|
const { fileList } = this.getStates();
|
|
426
426
|
const buResult = this._adapter.notifyBeforeUpload({ file, fileList });
|
|
427
427
|
switch (true) {
|
|
428
|
-
// sync
|
|
428
|
+
// sync validate - boolean
|
|
429
429
|
case buResult === true: {
|
|
430
430
|
this.post(file);
|
|
431
431
|
break;
|
|
@@ -438,11 +438,11 @@ class UploadFoundation<P = Record<string, any>, S = Record<string, any>> extends
|
|
|
438
438
|
// async validate
|
|
439
439
|
case buResult && isPromise(buResult): {
|
|
440
440
|
Promise.resolve(buResult as Promise<BeforeUploadObjectResult>).then(
|
|
441
|
-
|
|
441
|
+
resolveData => {
|
|
442
442
|
let newResult = { shouldUpload: true };
|
|
443
|
-
const
|
|
444
|
-
if (
|
|
445
|
-
newResult = { ...newResult, ...
|
|
443
|
+
const typeOfResolveData = Object.prototype.toString.call(resolveData).slice(8, -1);
|
|
444
|
+
if (typeOfResolveData === 'Object') {
|
|
445
|
+
newResult = { ...newResult, ...resolveData };
|
|
446
446
|
}
|
|
447
447
|
this.handleBeforeUploadResultInObject(newResult, file);
|
|
448
448
|
},
|
package/upload/utils.ts
CHANGED
|
@@ -86,7 +86,7 @@ export async function mapFileTree(items: Array<DataTransferItem>): Promise<Array
|
|
|
86
86
|
const result = await Promise.all(promises);
|
|
87
87
|
return result;
|
|
88
88
|
} catch (error) {
|
|
89
|
-
console.warn('
|
|
89
|
+
console.warn('Captured error while loop directory.');
|
|
90
90
|
console.error(error);
|
|
91
91
|
return [];
|
|
92
92
|
}
|
package/utils/object.ts
CHANGED
|
@@ -16,7 +16,7 @@ type Many<T> = T | ReadonlyArray<T>;
|
|
|
16
16
|
type PropertyName = string | number | symbol;
|
|
17
17
|
type PropertyPath = Many<PropertyName>;
|
|
18
18
|
|
|
19
|
-
type
|
|
19
|
+
type ObjectType = Record<string, any>;
|
|
20
20
|
|
|
21
21
|
const pathToArrayElem = (path: any) => {
|
|
22
22
|
const pathArray = lodashToPath(path);
|
|
@@ -25,7 +25,7 @@ const pathToArrayElem = (path: any) => {
|
|
|
25
25
|
return justNumber ? false : Number.isInteger(+pathArray[pathArray.length - 1]);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
function isEmptyObject(target:
|
|
28
|
+
function isEmptyObject(target: ObjectType) {
|
|
29
29
|
/**
|
|
30
30
|
* var a = {};
|
|
31
31
|
* var b = { c: undefined }
|
|
@@ -35,8 +35,8 @@ function isEmptyObject(target: ObjctType) {
|
|
|
35
35
|
* }
|
|
36
36
|
* the result of JSON.stringify(a/b/d) are same: '{}'
|
|
37
37
|
* We can use the above features to remove keys with empty values in Form
|
|
38
|
-
* But we cannot use JSON.stringify() directly, because if the input parameter of JSON.stringify includes fiberNode, it will cause an TypeError: '
|
|
39
|
-
* So we have to mock it's
|
|
38
|
+
* 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'
|
|
39
|
+
* So we have to mock it's behavior, also, the form value cannot have Symbol or function type, it can be ignored
|
|
40
40
|
*/
|
|
41
41
|
if (!isObject(target)) {
|
|
42
42
|
return false;
|
|
@@ -52,7 +52,7 @@ function isEmptyObject(target: ObjctType) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
function cleanup(obj:
|
|
55
|
+
function cleanup(obj: ObjectType, path: string[], pull = true) {
|
|
56
56
|
if (path.length === 0) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
@@ -79,15 +79,15 @@ function cleanup(obj: ObjctType, path: string[], pull = true) {
|
|
|
79
79
|
cleanup(obj, path.slice(0, path.length - 1), pull);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export function empty(object:
|
|
82
|
+
export function empty(object: ObjectType) {
|
|
83
83
|
return lodashValues(object).length === 0;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export function get(object:
|
|
86
|
+
export function get(object: ObjectType, path: PropertyPath) {
|
|
87
87
|
return lodashGet(object, path);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
export function remove(object:
|
|
90
|
+
export function remove(object: ObjectType, path: PropertyPath) {
|
|
91
91
|
lodashUnset(object, path);
|
|
92
92
|
// a.b => [a, b]
|
|
93
93
|
// arr[11].a => [arr, 11, a]
|
|
@@ -123,7 +123,7 @@ export function set(object: any, path: PropertyPath, value: any, allowEmpty?: bo
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export function has(object:
|
|
126
|
+
export function has(object: ObjectType, path: PropertyPath) {
|
|
127
127
|
return lodashHas(object, path);
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -133,7 +133,7 @@ export function has(object: ObjctType, path: PropertyPath) {
|
|
|
133
133
|
* @param {object|Function} srcObj
|
|
134
134
|
* @returns {object|Function}
|
|
135
135
|
*/
|
|
136
|
-
export function forwardStatics<T extends
|
|
136
|
+
export function forwardStatics<T extends ObjectType | ((...arg: any) => any)>(obj: T, srcObj: ObjectType | ((...arg: any) => any)): T {
|
|
137
137
|
if (
|
|
138
138
|
obj &&
|
|
139
139
|
(typeof obj === 'function' || typeof obj === 'object') &&
|