@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
|
@@ -12,7 +12,7 @@ var _constants = require("../base/constants");
|
|
|
12
12
|
|
|
13
13
|
const cssClasses = {
|
|
14
14
|
PREFIX: "".concat(_constants.BASE_CLASS_PREFIX, "-tree-select"),
|
|
15
|
-
|
|
15
|
+
PREFIX_TREE: "".concat(_constants.BASE_CLASS_PREFIX, "-tree"),
|
|
16
16
|
PREFIX_OPTION: "".concat(_constants.BASE_CLASS_PREFIX, "-tree-select-option")
|
|
17
17
|
};
|
|
18
18
|
exports.cssClasses = cssClasses;
|
|
@@ -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
|
/**
|
|
@@ -641,11 +641,11 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
641
641
|
} = treeNode;
|
|
642
642
|
|
|
643
643
|
if (checkRelation === 'related') {
|
|
644
|
-
const targetStatus = disableStrictly ? this.
|
|
644
|
+
const targetStatus = disableStrictly ? this.calcCheckedStatus(!checked, eventKey) : !checked;
|
|
645
645
|
const {
|
|
646
646
|
checkedKeys,
|
|
647
647
|
halfCheckedKeys
|
|
648
|
-
} = disableStrictly ? this.
|
|
648
|
+
} = disableStrictly ? this.calcNonDisabledCheckedKeys(eventKey, targetStatus) : this.calcCheckedKeys(eventKey, targetStatus);
|
|
649
649
|
|
|
650
650
|
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
651
651
|
|
|
@@ -691,7 +691,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
|
|
694
|
-
|
|
694
|
+
calcNonDisabledCheckedKeys(eventKey, targetStatus) {
|
|
695
695
|
const {
|
|
696
696
|
keyEntities,
|
|
697
697
|
disabledKeys
|
|
@@ -711,7 +711,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
711
711
|
return (0, _treeUtil.calcCheckedKeys)(newCheckedKeys, keyEntities);
|
|
712
712
|
}
|
|
713
713
|
|
|
714
|
-
|
|
714
|
+
calcCheckedStatus(targetStatus, eventKey) {
|
|
715
715
|
if (!targetStatus) {
|
|
716
716
|
return targetStatus;
|
|
717
717
|
}
|
|
@@ -146,13 +146,13 @@ class UploadFoundation extends _foundation.default {
|
|
|
146
146
|
maxSize,
|
|
147
147
|
minSize
|
|
148
148
|
} = this.getProps();
|
|
149
|
-
let
|
|
149
|
+
let isIllegal = false;
|
|
150
150
|
|
|
151
151
|
if (size > maxSize * _utils.byteKB || size < minSize * _utils.byteKB) {
|
|
152
|
-
|
|
152
|
+
isIllegal = true;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
return
|
|
155
|
+
return isIllegal;
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* 1. 选择文件
|
|
@@ -550,7 +550,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
550
550
|
});
|
|
551
551
|
|
|
552
552
|
switch (true) {
|
|
553
|
-
// sync
|
|
553
|
+
// sync validate - boolean
|
|
554
554
|
case buResult === true:
|
|
555
555
|
{
|
|
556
556
|
this.post(file);
|
|
@@ -570,16 +570,16 @@ class UploadFoundation extends _foundation.default {
|
|
|
570
570
|
|
|
571
571
|
case buResult && (0, _isPromise.default)(buResult):
|
|
572
572
|
{
|
|
573
|
-
_promise.default.resolve(buResult).then(
|
|
573
|
+
_promise.default.resolve(buResult).then(resolveData => {
|
|
574
574
|
var _context5;
|
|
575
575
|
|
|
576
576
|
let newResult = {
|
|
577
577
|
shouldUpload: true
|
|
578
578
|
};
|
|
579
|
-
const
|
|
579
|
+
const typeOfResolveData = (0, _slice.default)(_context5 = Object.prototype.toString.call(resolveData)).call(_context5, 8, -1);
|
|
580
580
|
|
|
581
|
-
if (
|
|
582
|
-
newResult = (0, _assign.default)((0, _assign.default)({}, newResult),
|
|
581
|
+
if (typeOfResolveData === 'Object') {
|
|
582
|
+
newResult = (0, _assign.default)((0, _assign.default)({}, newResult), resolveData);
|
|
583
583
|
}
|
|
584
584
|
|
|
585
585
|
this.handleBeforeUploadResultInObject(newResult, file);
|
|
@@ -1092,6 +1092,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
1092
1092
|
if (!disabled) {
|
|
1093
1093
|
if (directory) {
|
|
1094
1094
|
this.handleDirectoryDrop(e);
|
|
1095
|
+
return;
|
|
1095
1096
|
}
|
|
1096
1097
|
|
|
1097
1098
|
const files = (0, _from.default)(e.dataTransfer.files);
|
package/lib/cjs/upload/utils.js
CHANGED
|
@@ -157,7 +157,7 @@ function mapFileTree(items) {
|
|
|
157
157
|
const result = yield _promise.default.all(promises);
|
|
158
158
|
return result;
|
|
159
159
|
} catch (error) {
|
|
160
|
-
console.warn('
|
|
160
|
+
console.warn('Captured error while loop directory.');
|
|
161
161
|
console.error(error);
|
|
162
162
|
return [];
|
|
163
163
|
}
|
|
@@ -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/cjs/utils/object.js
CHANGED
|
@@ -60,8 +60,8 @@ function isEmptyObject(target) {
|
|
|
60
60
|
* }
|
|
61
61
|
* the result of JSON.stringify(a/b/d) are same: '{}'
|
|
62
62
|
* We can use the above features to remove keys with empty values in Form
|
|
63
|
-
* But we cannot use JSON.stringify() directly, because if the input parameter of JSON.stringify includes fiberNode, it will cause an TypeError: '
|
|
64
|
-
* So we have to mock it's
|
|
63
|
+
* 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'
|
|
64
|
+
* So we have to mock it's behavior, also, the form value cannot have Symbol or function type, it can be ignored
|
|
65
65
|
*/
|
|
66
66
|
if (!(0, _isObject2.default)(target)) {
|
|
67
67
|
return false;
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
|
|
274
274
|
@keyframes semi-carousel-content-item-keyframe-slide-in {
|
|
275
275
|
from {
|
|
276
|
-
transform: translateX(
|
|
276
|
+
transform: translateX(100%);
|
|
277
277
|
}
|
|
278
278
|
to {
|
|
279
279
|
transform: translateX(0);
|
|
@@ -284,12 +284,12 @@
|
|
|
284
284
|
transform: translateX(0);
|
|
285
285
|
}
|
|
286
286
|
to {
|
|
287
|
-
transform: translateX(100%);
|
|
287
|
+
transform: translateX(-100%);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
@keyframes semi-carousel-content-item-keyframe-slide-in-reverse {
|
|
291
291
|
from {
|
|
292
|
-
transform: translateX(100%);
|
|
292
|
+
transform: translateX(-100%);
|
|
293
293
|
}
|
|
294
294
|
to {
|
|
295
295
|
transform: translateX(0);
|
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
transform: translateX(0);
|
|
301
301
|
}
|
|
302
302
|
to {
|
|
303
|
-
transform: translateX(
|
|
303
|
+
transform: translateX(100%);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
.semi-rtl .semi-carousel,
|
|
@@ -381,7 +381,7 @@ $module: #{$prefix}-carousel;
|
|
|
381
381
|
@keyframes #{$module}-content-item-keyframe-slide-in {
|
|
382
382
|
|
|
383
383
|
from {
|
|
384
|
-
transform: translateX(
|
|
384
|
+
transform: translateX(100%);
|
|
385
385
|
}
|
|
386
386
|
|
|
387
387
|
to {
|
|
@@ -396,14 +396,14 @@ $module: #{$prefix}-carousel;
|
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
to {
|
|
399
|
-
transform: translateX(100%);
|
|
399
|
+
transform: translateX(-100%);
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
@keyframes #{$module}-content-item-keyframe-slide-in-reverse {
|
|
404
404
|
|
|
405
405
|
from {
|
|
406
|
-
transform: translateX(100%);
|
|
406
|
+
transform: translateX(-100%);
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
to {
|
|
@@ -418,7 +418,7 @@ $module: #{$prefix}-carousel;
|
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
to {
|
|
421
|
-
transform: translateX(
|
|
421
|
+
transform: translateX(100%);
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
|
|
@@ -7,7 +7,6 @@ export interface CarouselAdapter<P = Record<string, any>, S = Record<string, any
|
|
|
7
7
|
setIsInit: (isInit: boolean) => void;
|
|
8
8
|
}
|
|
9
9
|
declare class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CarouselAdapter<P, S>, P, S> {
|
|
10
|
-
throttleChange: any;
|
|
11
10
|
constructor(adapter: CarouselAdapter<P, S>);
|
|
12
11
|
_interval: any;
|
|
13
12
|
play(interval: number): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _throttle from "lodash/throttle";
|
|
2
1
|
import _get from "lodash/get";
|
|
3
2
|
import _isObject from "lodash/isObject";
|
|
4
3
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
@@ -10,7 +9,6 @@ class CarouselFoundation extends BaseFoundation {
|
|
|
10
9
|
constructor(adapter) {
|
|
11
10
|
super(_Object$assign({}, adapter));
|
|
12
11
|
this._interval = null;
|
|
13
|
-
this.throttleChange = _throttle(this.onIndicatorChange, this.getSwitchingTime());
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
play(interval) {
|
|
@@ -204,7 +204,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
204
204
|
notifyIfLoadData(item: BasicEntity | BasicData): void;
|
|
205
205
|
handleSingleSelect(e: any, item: BasicEntity | BasicData): void;
|
|
206
206
|
_handleMultipleSelect(item: BasicEntity | BasicData): void;
|
|
207
|
-
|
|
207
|
+
calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean): {
|
|
208
208
|
/**
|
|
209
209
|
* The typical scenario is: suppose we select the 0-0 node, at this time
|
|
210
210
|
* selectedKeys=Set('0-0'), the input box will display a 0-0 label. When
|
|
@@ -219,7 +219,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
219
219
|
checkedKeys: Set<string>;
|
|
220
220
|
halfCheckedKeys: Set<any>;
|
|
221
221
|
};
|
|
222
|
-
|
|
222
|
+
calcCheckedStatus(targetStatus: boolean, eventKey: string): boolean;
|
|
223
223
|
_notifySelect(keys: Set<string>): void;
|
|
224
224
|
/**
|
|
225
225
|
* calculate all key of nodes that are checked or half checked
|
|
@@ -300,7 +300,7 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
300
300
|
activeKeys,
|
|
301
301
|
loadingKeys,
|
|
302
302
|
loading,
|
|
303
|
-
keyEntities:
|
|
303
|
+
keyEntities: keyEntityState,
|
|
304
304
|
selectedKeys: selectedKeysState
|
|
305
305
|
} = this.getStates();
|
|
306
306
|
|
|
@@ -371,7 +371,7 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
371
371
|
} else if (loading) {
|
|
372
372
|
// Use assign to avoid overwriting the'not-exist- * 'property of keyEntities after asynchronous loading
|
|
373
373
|
// Overwriting'not-exist- * 'will cause selectionContent to be emptied unexpectedly when clicking on a dropDown item
|
|
374
|
-
updateStates.keyEntities = _assign(
|
|
374
|
+
updateStates.keyEntities = _assign(keyEntityState, keyEntities);
|
|
375
375
|
|
|
376
376
|
this._adapter.updateStates(updateStates);
|
|
377
377
|
|
|
@@ -725,12 +725,12 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
725
725
|
|
|
726
726
|
const prevCheckedStatus = checkedKeys.has(key); // next checked status
|
|
727
727
|
|
|
728
|
-
const curCheckedStatus = disableStrictly ? this.
|
|
728
|
+
const curCheckedStatus = disableStrictly ? this.calcCheckedStatus(!prevCheckedStatus, key) : !prevCheckedStatus; // calculate all key of nodes that are checked or half checked
|
|
729
729
|
|
|
730
730
|
const {
|
|
731
731
|
checkedKeys: curCheckedKeys,
|
|
732
732
|
halfCheckedKeys: curHalfCheckedKeys
|
|
733
|
-
} = disableStrictly ? this.
|
|
733
|
+
} = disableStrictly ? this.calcNonDisabledCheckedKeys(key, curCheckedStatus) : this.calcCheckedKeys(key, curCheckedStatus);
|
|
734
734
|
const mergeType = calcMergeType(autoMergeValue, leafOnly);
|
|
735
735
|
const isLeafOnlyMerge = mergeType === strings.LEAF_ONLY_MERGE_TYPE;
|
|
736
736
|
const isNoneMerge = mergeType === strings.NONE_MERGE_TYPE;
|
|
@@ -788,7 +788,7 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
788
788
|
});
|
|
789
789
|
}
|
|
790
790
|
|
|
791
|
-
|
|
791
|
+
calcNonDisabledCheckedKeys(eventKey, targetStatus) {
|
|
792
792
|
const {
|
|
793
793
|
keyEntities,
|
|
794
794
|
disabledKeys
|
|
@@ -810,7 +810,7 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
810
810
|
return calcCheckedKeys(newCheckedKeys, keyEntities);
|
|
811
811
|
}
|
|
812
812
|
|
|
813
|
-
|
|
813
|
+
calcCheckedStatus(targetStatus, eventKey) {
|
|
814
814
|
if (!targetStatus) {
|
|
815
815
|
return targetStatus;
|
|
816
816
|
}
|
|
@@ -5,7 +5,7 @@ export interface CheckboxGroupAdapter extends DefaultAdapter {
|
|
|
5
5
|
notifyChange: (value: any[]) => void;
|
|
6
6
|
}
|
|
7
7
|
declare class CheckboxGroupFoundation extends BaseFoundation<CheckboxGroupAdapter> {
|
|
8
|
-
static get
|
|
8
|
+
static get checkboxGroupDefaultAdapter(): {};
|
|
9
9
|
constructor(adapter: CheckboxGroupAdapter);
|
|
10
10
|
init(): void;
|
|
11
11
|
notifyChange(value: any[]): void;
|
|
@@ -5,12 +5,12 @@ import BaseFoundation from '../base/foundation';
|
|
|
5
5
|
import warning from '../utils/warning';
|
|
6
6
|
|
|
7
7
|
class CheckboxGroupFoundation extends BaseFoundation {
|
|
8
|
-
static get
|
|
8
|
+
static get checkboxGroupDefaultAdapter() {
|
|
9
9
|
return {};
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
constructor(adapter) {
|
|
13
|
-
super(_Object$assign(_Object$assign({}, CheckboxGroupFoundation.
|
|
13
|
+
super(_Object$assign(_Object$assign({}, CheckboxGroupFoundation.checkboxGroupDefaultAdapter), adapter));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
init() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
2
2
|
import { addMonths } from 'date-fns';
|
|
3
3
|
import isValidDate from './isValidDate';
|
|
4
|
-
import {
|
|
4
|
+
import { compatibleParse } from './parser';
|
|
5
5
|
import isTimestamp from './isTimestamp';
|
|
6
6
|
/**
|
|
7
7
|
* get left panel picker date and right panel picker date
|
|
@@ -25,7 +25,7 @@ export default function getDefaultPickerDate(options) {
|
|
|
25
25
|
break;
|
|
26
26
|
|
|
27
27
|
case typeof nowDate === 'string':
|
|
28
|
-
nowDate =
|
|
28
|
+
nowDate = compatibleParse(nowDate, format, undefined, dateFnsLocale);
|
|
29
29
|
break;
|
|
30
30
|
|
|
31
31
|
default:
|
|
@@ -42,7 +42,7 @@ export default function getDefaultPickerDate(options) {
|
|
|
42
42
|
break;
|
|
43
43
|
|
|
44
44
|
case typeof nextDate === 'string':
|
|
45
|
-
nextDate =
|
|
45
|
+
nextDate = compatibleParse(nextDate, format, undefined, dateFnsLocale);
|
|
46
46
|
break;
|
|
47
47
|
|
|
48
48
|
default:
|
|
@@ -6,4 +6,4 @@ import { Locale } from 'date-fns';
|
|
|
6
6
|
/**
|
|
7
7
|
* Parsing value to Date object
|
|
8
8
|
*/
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function compatibleParse(value: string, formatToken?: string, baseDate?: Date, locale?: Locale): Date | null;
|
|
@@ -7,7 +7,7 @@ import { isValid, parseISO, parse } from 'date-fns';
|
|
|
7
7
|
* Parsing value to Date object
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export function
|
|
10
|
+
export function compatibleParse(value, formatToken, baseDate, locale) {
|
|
11
11
|
let result = null;
|
|
12
12
|
|
|
13
13
|
if (value) {
|
|
@@ -25,7 +25,7 @@ import BaseFoundation from '../base/foundation';
|
|
|
25
25
|
import { isValidDate, isTimestamp } from './_utils/index';
|
|
26
26
|
import isNullOrUndefined from '../utils/isNullOrUndefined';
|
|
27
27
|
import { utcToZonedTime, zonedTimeToUtc } from '../utils/date-fns-extra';
|
|
28
|
-
import {
|
|
28
|
+
import { compatibleParse } from './_utils/parser';
|
|
29
29
|
import { getDefaultFormatTokenByType } from './_utils/getDefaultFormatToken';
|
|
30
30
|
import { strings } from './constants';
|
|
31
31
|
import { strings as inputStrings } from '../input/constants';
|
|
@@ -185,7 +185,7 @@ export default class DatePickerFoundation extends BaseFoundation {
|
|
|
185
185
|
if (isValidDate(value)) {
|
|
186
186
|
dateObj = value;
|
|
187
187
|
} else if (_isString(value)) {
|
|
188
|
-
dateObj =
|
|
188
|
+
dateObj = compatibleParse(value, this.getProp('format'), undefined, dateFnsLocale);
|
|
189
189
|
} else if (isTimestamp(value)) {
|
|
190
190
|
dateObj = new Date(value);
|
|
191
191
|
} else {
|
|
@@ -563,7 +563,7 @@ export default class DatePickerFoundation extends BaseFoundation {
|
|
|
563
563
|
case 'date':
|
|
564
564
|
case 'dateTime':
|
|
565
565
|
case 'month':
|
|
566
|
-
parsedResult = input ?
|
|
566
|
+
parsedResult = input ? compatibleParse(input, formatToken, nowDate, dateFnsLocale) : '';
|
|
567
567
|
formatedInput = parsedResult && isValid(parsedResult) && this.localeFormat(parsedResult, formatToken);
|
|
568
568
|
|
|
569
569
|
if (parsedResult && formatedInput === input) {
|
|
@@ -577,7 +577,7 @@ export default class DatePickerFoundation extends BaseFoundation {
|
|
|
577
577
|
const separator = rangeSeparator;
|
|
578
578
|
const values = input.split(separator);
|
|
579
579
|
parsedResult = values && _reduceInstanceProperty(values).call(values, (arr, cur) => {
|
|
580
|
-
const parsedVal = cur &&
|
|
580
|
+
const parsedVal = cur && compatibleParse(cur, formatToken, nowDate, dateFnsLocale);
|
|
581
581
|
parsedVal && arr.push(parsedVal);
|
|
582
582
|
return arr;
|
|
583
583
|
}, []);
|
|
@@ -18,7 +18,7 @@ import { strings } from './constants';
|
|
|
18
18
|
import { format, set, addMonths, subMonths, subYears, addYears, differenceInCalendarMonths, differenceInCalendarYears, isSameDay, parseISO } from 'date-fns';
|
|
19
19
|
import { isBefore, isValidDate, getDefaultFormatToken, getFullDateOffset } from './_utils/index';
|
|
20
20
|
import { formatFullDate } from './_utils/getMonthTable';
|
|
21
|
-
import {
|
|
21
|
+
import { compatibleParse } from './_utils/parser';
|
|
22
22
|
import { zonedTimeToUtc } from '../utils/date-fns-extra';
|
|
23
23
|
import { getDefaultFormatTokenByType } from './_utils/getDefaultFormatToken';
|
|
24
24
|
import isNullOrUndefined from '../utils/isNullOrUndefined';
|
|
@@ -46,7 +46,7 @@ export default class MonthsGridFoundation extends BaseFoundation {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
initDefaultPickerValue() {
|
|
49
|
-
const defaultPickerValue =
|
|
49
|
+
const defaultPickerValue = compatibleParse(this.getProp('defaultPickerValue'));
|
|
50
50
|
|
|
51
51
|
if (defaultPickerValue && isValidDate(defaultPickerValue)) {
|
|
52
52
|
this._updatePanelDetail(strings.PANEL_TYPE_LEFT, {
|
|
@@ -661,7 +661,7 @@ export default class MonthsGridFoundation extends BaseFoundation {
|
|
|
661
661
|
|
|
662
662
|
const dateFormat = this.getValidDateFormat(); // When passed to the upper layer, it is converted into a Date object to ensure that the input parameter format of initFormDefaultValue is consistent
|
|
663
663
|
|
|
664
|
-
const newSelectedDates = _mapInstanceProperty(_context4 = [...newSelected]).call(_context4, _dateStr =>
|
|
664
|
+
const newSelectedDates = _mapInstanceProperty(_context4 = [...newSelected]).call(_context4, _dateStr => compatibleParse(_dateStr, dateFormat, undefined, dateFnsLocale));
|
|
665
665
|
|
|
666
666
|
this.handleShowDateAndTime(panelType, time);
|
|
667
667
|
|
|
@@ -696,10 +696,10 @@ export default class MonthsGridFoundation extends BaseFoundation {
|
|
|
696
696
|
|
|
697
697
|
const dateFnsLocale = this._adapter.getProp('dateFnsLocale');
|
|
698
698
|
|
|
699
|
-
const dateStr = format(isValidDate(date) ? date :
|
|
700
|
-
const timeStr = format(isValidDate(time) ? time :
|
|
699
|
+
const dateStr = format(isValidDate(date) ? date : compatibleParse(date, strings.FORMAT_FULL_DATE, undefined, dateFnsLocale), strings.FORMAT_FULL_DATE);
|
|
700
|
+
const timeStr = format(isValidDate(time) ? time : compatibleParse(time, strings.FORMAT_TIME_PICKER, undefined, dateFnsLocale), strings.FORMAT_TIME_PICKER);
|
|
701
701
|
const timeFormat = this.getValidTimeFormat();
|
|
702
|
-
return
|
|
702
|
+
return compatibleParse(_concatInstanceProperty(_context5 = "".concat(dateStr, " ")).call(_context5, timeStr), timeFormat, undefined, dateFnsLocale);
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
handleRangeSelected(day) {
|
|
@@ -782,7 +782,7 @@ export default class MonthsGridFoundation extends BaseFoundation {
|
|
|
782
782
|
const dateFormat = this.getValidDateFormat(); // only notify when choose completed
|
|
783
783
|
|
|
784
784
|
if (rangeStart || rangeEnd) {
|
|
785
|
-
const [startDate, endDate] = [
|
|
785
|
+
const [startDate, endDate] = [compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale), compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale)];
|
|
786
786
|
let date = [startDate, endDate]; // If the type is dateRangeTime, add the value of time
|
|
787
787
|
|
|
788
788
|
if (type === 'dateTimeRange') {
|
|
@@ -919,7 +919,7 @@ export default class MonthsGridFoundation extends BaseFoundation {
|
|
|
919
919
|
// } else
|
|
920
920
|
|
|
921
921
|
if (type === 'dateTimeRange' && destRange) {
|
|
922
|
-
const rangeDate =
|
|
922
|
+
const rangeDate = compatibleParse(destRange, dateFormat, undefined, dateFnsLocale);
|
|
923
923
|
year = rangeDate.getFullYear();
|
|
924
924
|
monthNo = rangeDate.getMonth();
|
|
925
925
|
date = rangeDate.getDate();
|
|
@@ -968,8 +968,8 @@ export default class MonthsGridFoundation extends BaseFoundation {
|
|
|
968
968
|
const dateFormat = this.getValidDateFormat(); // TODO: Modify a time individually
|
|
969
969
|
|
|
970
970
|
if (rangeStart && rangeEnd) {
|
|
971
|
-
let startDate =
|
|
972
|
-
let endDate =
|
|
971
|
+
let startDate = compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale);
|
|
972
|
+
let endDate = compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale); // console.log('_updateTimeInDateRange()', rangeStart, rangeEnd, startDate, endDate);
|
|
973
973
|
|
|
974
974
|
if (panelType === strings.PANEL_TYPE_RIGHT) {
|
|
975
975
|
endDate = this._mergeDateAndTime(timeDate, timeDate);
|
|
@@ -46,7 +46,7 @@ export interface YearScrollItem {
|
|
|
46
46
|
value: number;
|
|
47
47
|
disabled: boolean;
|
|
48
48
|
}
|
|
49
|
-
export default class
|
|
49
|
+
export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthAdapter> {
|
|
50
50
|
constructor(adapter: YearAndMonthAdapter);
|
|
51
51
|
init(): void;
|
|
52
52
|
destroy(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
2
2
|
import BaseFoundation from '../base/foundation';
|
|
3
|
-
export default class
|
|
3
|
+
export default class YearAndMonthFoundation extends BaseFoundation {
|
|
4
4
|
constructor(adapter) {
|
|
5
5
|
super(_Object$assign({}, adapter));
|
|
6
6
|
} // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -8,6 +8,7 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
8
8
|
registered: Record<string, boolean>;
|
|
9
9
|
registeredArrayField: Map<string, ArrayFieldStaff>;
|
|
10
10
|
constructor(adapter: BaseFormAdapter);
|
|
11
|
+
init(): void;
|
|
11
12
|
getField(field: string): FieldStaff | undefined;
|
|
12
13
|
register(field: string, fieldState: FieldState, fieldStuff: FieldStaff): void;
|
|
13
14
|
unRegister(field: string): void;
|
|
@@ -74,6 +74,10 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
74
74
|
this.scrollToField = _bindInstanceProperty(_context20 = this.scrollToField).call(_context20, this);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
init() {
|
|
78
|
+
this._adapter.initFormId();
|
|
79
|
+
}
|
|
80
|
+
|
|
77
81
|
getField(field) {
|
|
78
82
|
const targetField = this.fields.get(field);
|
|
79
83
|
return targetField;
|
|
@@ -330,7 +334,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
330
334
|
let targetFields = new _Map();
|
|
331
335
|
|
|
332
336
|
if (!_isUndefined(fieldPaths)) {
|
|
333
|
-
// reset or validate
|
|
337
|
+
// reset or validate specific fields
|
|
334
338
|
_forEachInstanceProperty(fieldPaths).call(fieldPaths, path => {
|
|
335
339
|
const field = this.fields.get(path); // may be undefined, if exists two fields like 'a[0]'、'a[1]', but user directly call reset(['a']) / validate(['a'])
|
|
336
340
|
|
|
@@ -468,8 +472,8 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
468
472
|
updateKey: new Date().valueOf()
|
|
469
473
|
});
|
|
470
474
|
});
|
|
471
|
-
} // When
|
|
472
|
-
// 当
|
|
475
|
+
} // When isOverride is true, there may be a non-existent field in the values passed in, directly synchronized to formState.values
|
|
476
|
+
// 当isOverride为true,传入的values中可能存在不存在的field时,直接将其同步到formState.values中
|
|
473
477
|
|
|
474
478
|
|
|
475
479
|
if (isOverride) {
|
|
@@ -643,7 +647,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
643
647
|
};
|
|
644
648
|
|
|
645
649
|
const setTouched = (field, isTouched, opts) => {
|
|
646
|
-
const fieldApi = this.fields.get(field) ? this.fields.get(field).fieldApi : undefined; // touched is boolean variable, no need to
|
|
650
|
+
const fieldApi = this.fields.get(field) ? this.fields.get(field).fieldApi : undefined; // touched is boolean variable, no need to exec deepClone like setValue
|
|
647
651
|
|
|
648
652
|
if (fieldApi) {
|
|
649
653
|
fieldApi.setTouched(isTouched, opts);
|
|
@@ -730,7 +734,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
730
734
|
getFormState() {
|
|
731
735
|
let needClone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
732
736
|
|
|
733
|
-
// NOTES:这里如果直接返回this.data,
|
|
737
|
+
// NOTES:这里如果直接返回this.data,forceUpdate 触发 Form rerender 时,通过context传下去的formState会被认为是同一个对象【应该是浅对比的原因】
|
|
734
738
|
// 使用了useFormState相关的component都不会触发重新渲染。所以使用...复制一次
|
|
735
739
|
|
|
736
740
|
/*
|
|
@@ -15,6 +15,7 @@ export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any
|
|
|
15
15
|
getFormProps: (keys: undefined | string | Array<string>) => any;
|
|
16
16
|
getAllErrorDOM: () => NodeList;
|
|
17
17
|
getFieldDOM: (field: string) => Node;
|
|
18
|
+
initFormId: () => void;
|
|
18
19
|
}
|
|
19
20
|
export interface FormState<T extends Record<string, any> = any> {
|
|
20
21
|
values?: T extends Record<string, any> ? T : Record<string, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter, noopFunction } from '../base/foundation';
|
|
2
|
-
export interface
|
|
2
|
+
export interface TextAreaDefaultAdapter {
|
|
3
3
|
notifyChange: noopFunction;
|
|
4
4
|
setValue: noopFunction;
|
|
5
5
|
toggleFocusing: noopFunction;
|
|
@@ -7,16 +7,16 @@ export interface TextAreaDefaultAdpter {
|
|
|
7
7
|
notifyBlur: noopFunction;
|
|
8
8
|
notifyKeyDown: noopFunction;
|
|
9
9
|
notifyEnterPress: noopFunction;
|
|
10
|
-
toggleHovering(
|
|
10
|
+
toggleHovering(hovering: boolean): void;
|
|
11
11
|
notifyClear(e: any): void;
|
|
12
12
|
}
|
|
13
|
-
export interface
|
|
13
|
+
export interface TextAreaAdapter extends Partial<DefaultAdapter>, Partial<TextAreaDefaultAdapter> {
|
|
14
14
|
setMinLength(length: number): void;
|
|
15
15
|
notifyPressEnter(e: any): void;
|
|
16
16
|
getRef(): any;
|
|
17
17
|
notifyHeightUpdate(e: any): void;
|
|
18
18
|
}
|
|
19
|
-
export default class TextAreaFoundation extends BaseFoundation<
|
|
19
|
+
export default class TextAreaFoundation extends BaseFoundation<TextAreaAdapter> {
|
|
20
20
|
static get textAreaDefaultAdapter(): {
|
|
21
21
|
notifyChange: (...args: any[]) => void;
|
|
22
22
|
setValue: (...args: any[]) => void;
|
|
@@ -27,7 +27,7 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdpter> {
|
|
|
27
27
|
notifyKeyDown: (...args: any[]) => void;
|
|
28
28
|
notifyEnterPress: (...args: any[]) => void;
|
|
29
29
|
};
|
|
30
|
-
constructor(adapter:
|
|
30
|
+
constructor(adapter: TextAreaAdapter);
|
|
31
31
|
init(): void;
|
|
32
32
|
destroy(): void;
|
|
33
33
|
setInitValue(): void;
|