@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
|
@@ -41,7 +41,7 @@ function getDefaultPickerDate(options) {
|
|
|
41
41
|
break;
|
|
42
42
|
|
|
43
43
|
case typeof nowDate === 'string':
|
|
44
|
-
nowDate = (0, _parser.
|
|
44
|
+
nowDate = (0, _parser.compatibleParse)(nowDate, format, undefined, dateFnsLocale);
|
|
45
45
|
break;
|
|
46
46
|
|
|
47
47
|
default:
|
|
@@ -58,7 +58,7 @@ function getDefaultPickerDate(options) {
|
|
|
58
58
|
break;
|
|
59
59
|
|
|
60
60
|
case typeof nextDate === 'string':
|
|
61
|
-
nextDate = (0, _parser.
|
|
61
|
+
nextDate = (0, _parser.compatibleParse)(nextDate, format, undefined, dateFnsLocale);
|
|
62
62
|
break;
|
|
63
63
|
|
|
64
64
|
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;
|
|
@@ -6,7 +6,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
exports.
|
|
9
|
+
exports.compatibleParse = compatibleParse;
|
|
10
10
|
|
|
11
11
|
var _dateFns = require("date-fns");
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ var _dateFns = require("date-fns");
|
|
|
18
18
|
/**
|
|
19
19
|
* Parsing value to Date object
|
|
20
20
|
*/
|
|
21
|
-
function
|
|
21
|
+
function compatibleParse(value, formatToken, baseDate, locale) {
|
|
22
22
|
let result = null;
|
|
23
23
|
|
|
24
24
|
if (value) {
|
|
@@ -225,7 +225,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
225
225
|
if ((0, _index.isValidDate)(value)) {
|
|
226
226
|
dateObj = value;
|
|
227
227
|
} else if ((0, _isString2.default)(value)) {
|
|
228
|
-
dateObj = (0, _parser.
|
|
228
|
+
dateObj = (0, _parser.compatibleParse)(value, this.getProp('format'), undefined, dateFnsLocale);
|
|
229
229
|
} else if ((0, _index.isTimestamp)(value)) {
|
|
230
230
|
dateObj = new Date(value);
|
|
231
231
|
} else {
|
|
@@ -603,7 +603,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
603
603
|
case 'date':
|
|
604
604
|
case 'dateTime':
|
|
605
605
|
case 'month':
|
|
606
|
-
parsedResult = input ? (0, _parser.
|
|
606
|
+
parsedResult = input ? (0, _parser.compatibleParse)(input, formatToken, nowDate, dateFnsLocale) : '';
|
|
607
607
|
formatedInput = parsedResult && (0, _dateFns.isValid)(parsedResult) && this.localeFormat(parsedResult, formatToken);
|
|
608
608
|
|
|
609
609
|
if (parsedResult && formatedInput === input) {
|
|
@@ -617,7 +617,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
617
617
|
const separator = rangeSeparator;
|
|
618
618
|
const values = input.split(separator);
|
|
619
619
|
parsedResult = values && (0, _reduce.default)(values).call(values, (arr, cur) => {
|
|
620
|
-
const parsedVal = cur && (0, _parser.
|
|
620
|
+
const parsedVal = cur && (0, _parser.compatibleParse)(cur, formatToken, nowDate, dateFnsLocale);
|
|
621
621
|
parsedVal && arr.push(parsedVal);
|
|
622
622
|
return arr;
|
|
623
623
|
}, []);
|
|
@@ -80,7 +80,7 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
initDefaultPickerValue() {
|
|
83
|
-
const defaultPickerValue = (0, _parser.
|
|
83
|
+
const defaultPickerValue = (0, _parser.compatibleParse)(this.getProp('defaultPickerValue'));
|
|
84
84
|
|
|
85
85
|
if (defaultPickerValue && (0, _index.isValidDate)(defaultPickerValue)) {
|
|
86
86
|
this._updatePanelDetail(_constants.strings.PANEL_TYPE_LEFT, {
|
|
@@ -690,7 +690,7 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
690
690
|
|
|
691
691
|
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
|
|
692
692
|
|
|
693
|
-
const newSelectedDates = (0, _map.default)(_context4 = [...newSelected]).call(_context4, _dateStr => (0, _parser.
|
|
693
|
+
const newSelectedDates = (0, _map.default)(_context4 = [...newSelected]).call(_context4, _dateStr => (0, _parser.compatibleParse)(_dateStr, dateFormat, undefined, dateFnsLocale));
|
|
694
694
|
this.handleShowDateAndTime(panelType, time);
|
|
695
695
|
|
|
696
696
|
if (!isControlledComponent) {
|
|
@@ -724,10 +724,10 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
724
724
|
|
|
725
725
|
const dateFnsLocale = this._adapter.getProp('dateFnsLocale');
|
|
726
726
|
|
|
727
|
-
const dateStr = (0, _dateFns.format)((0, _index.isValidDate)(date) ? date : (0, _parser.
|
|
728
|
-
const timeStr = (0, _dateFns.format)((0, _index.isValidDate)(time) ? time : (0, _parser.
|
|
727
|
+
const dateStr = (0, _dateFns.format)((0, _index.isValidDate)(date) ? date : (0, _parser.compatibleParse)(date, _constants.strings.FORMAT_FULL_DATE, undefined, dateFnsLocale), _constants.strings.FORMAT_FULL_DATE);
|
|
728
|
+
const timeStr = (0, _dateFns.format)((0, _index.isValidDate)(time) ? time : (0, _parser.compatibleParse)(time, _constants.strings.FORMAT_TIME_PICKER, undefined, dateFnsLocale), _constants.strings.FORMAT_TIME_PICKER);
|
|
729
729
|
const timeFormat = this.getValidTimeFormat();
|
|
730
|
-
return (0, _parser.
|
|
730
|
+
return (0, _parser.compatibleParse)((0, _concat.default)(_context5 = "".concat(dateStr, " ")).call(_context5, timeStr), timeFormat, undefined, dateFnsLocale);
|
|
731
731
|
}
|
|
732
732
|
|
|
733
733
|
handleRangeSelected(day) {
|
|
@@ -810,7 +810,7 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
810
810
|
const dateFormat = this.getValidDateFormat(); // only notify when choose completed
|
|
811
811
|
|
|
812
812
|
if (rangeStart || rangeEnd) {
|
|
813
|
-
const [startDate, endDate] = [(0, _parser.
|
|
813
|
+
const [startDate, endDate] = [(0, _parser.compatibleParse)(rangeStart, dateFormat, undefined, dateFnsLocale), (0, _parser.compatibleParse)(rangeEnd, dateFormat, undefined, dateFnsLocale)];
|
|
814
814
|
let date = [startDate, endDate]; // If the type is dateRangeTime, add the value of time
|
|
815
815
|
|
|
816
816
|
if (type === 'dateTimeRange') {
|
|
@@ -948,7 +948,7 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
948
948
|
// } else
|
|
949
949
|
|
|
950
950
|
if (type === 'dateTimeRange' && destRange) {
|
|
951
|
-
const rangeDate = (0, _parser.
|
|
951
|
+
const rangeDate = (0, _parser.compatibleParse)(destRange, dateFormat, undefined, dateFnsLocale);
|
|
952
952
|
year = rangeDate.getFullYear();
|
|
953
953
|
monthNo = rangeDate.getMonth();
|
|
954
954
|
date = rangeDate.getDate();
|
|
@@ -997,8 +997,8 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
997
997
|
const dateFormat = this.getValidDateFormat(); // TODO: Modify a time individually
|
|
998
998
|
|
|
999
999
|
if (rangeStart && rangeEnd) {
|
|
1000
|
-
let startDate = (0, _parser.
|
|
1001
|
-
let endDate = (0, _parser.
|
|
1000
|
+
let startDate = (0, _parser.compatibleParse)(rangeStart, dateFormat, undefined, dateFnsLocale);
|
|
1001
|
+
let endDate = (0, _parser.compatibleParse)(rangeEnd, dateFormat, undefined, dateFnsLocale); // console.log('_updateTimeInDateRange()', rangeStart, rangeEnd, startDate, endDate);
|
|
1002
1002
|
|
|
1003
1003
|
if (panelType === _constants.strings.PANEL_TYPE_RIGHT) {
|
|
1004
1004
|
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;
|
|
@@ -14,7 +14,7 @@ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
14
14
|
|
|
15
15
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
16
16
|
|
|
17
|
-
class
|
|
17
|
+
class YearAndMonthFoundation extends _foundation.default {
|
|
18
18
|
constructor(adapter) {
|
|
19
19
|
super((0, _assign.default)({}, adapter));
|
|
20
20
|
} // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -49,4 +49,4 @@ class YearAndMonthFoundataion extends _foundation.default {
|
|
|
49
49
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
exports.default =
|
|
52
|
+
exports.default = YearAndMonthFoundation;
|
|
@@ -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;
|
|
@@ -111,6 +111,10 @@ class FormFoundation extends _foundation.default {
|
|
|
111
111
|
this.scrollToField = (0, _bind.default)(_context20 = this.scrollToField).call(_context20, this);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
init() {
|
|
115
|
+
this._adapter.initFormId();
|
|
116
|
+
}
|
|
117
|
+
|
|
114
118
|
getField(field) {
|
|
115
119
|
const targetField = this.fields.get(field);
|
|
116
120
|
return targetField;
|
|
@@ -361,7 +365,7 @@ class FormFoundation extends _foundation.default {
|
|
|
361
365
|
let targetFields = new _map.default();
|
|
362
366
|
|
|
363
367
|
if (!(0, _isUndefined2.default)(fieldPaths)) {
|
|
364
|
-
// reset or validate
|
|
368
|
+
// reset or validate specific fields
|
|
365
369
|
(0, _forEach.default)(fieldPaths).call(fieldPaths, path => {
|
|
366
370
|
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'])
|
|
367
371
|
|
|
@@ -496,8 +500,8 @@ class FormFoundation extends _foundation.default {
|
|
|
496
500
|
updateKey: new Date().valueOf()
|
|
497
501
|
});
|
|
498
502
|
});
|
|
499
|
-
} // When
|
|
500
|
-
// 当
|
|
503
|
+
} // When isOverride is true, there may be a non-existent field in the values passed in, directly synchronized to formState.values
|
|
504
|
+
// 当isOverride为true,传入的values中可能存在不存在的field时,直接将其同步到formState.values中
|
|
501
505
|
|
|
502
506
|
|
|
503
507
|
if (isOverride) {
|
|
@@ -671,7 +675,7 @@ class FormFoundation extends _foundation.default {
|
|
|
671
675
|
};
|
|
672
676
|
|
|
673
677
|
const setTouched = (field, isTouched, opts) => {
|
|
674
|
-
const fieldApi = this.fields.get(field) ? this.fields.get(field).fieldApi : undefined; // touched is boolean variable, no need to
|
|
678
|
+
const fieldApi = this.fields.get(field) ? this.fields.get(field).fieldApi : undefined; // touched is boolean variable, no need to exec deepClone like setValue
|
|
675
679
|
|
|
676
680
|
if (fieldApi) {
|
|
677
681
|
fieldApi.setTouched(isTouched, opts);
|
|
@@ -758,7 +762,7 @@ class FormFoundation extends _foundation.default {
|
|
|
758
762
|
getFormState() {
|
|
759
763
|
let needClone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
760
764
|
|
|
761
|
-
// NOTES:这里如果直接返回this.data,
|
|
765
|
+
// NOTES:这里如果直接返回this.data,forceUpdate 触发 Form rerender 时,通过context传下去的formState会被认为是同一个对象【应该是浅对比的原因】
|
|
762
766
|
// 使用了useFormState相关的component都不会触发重新渲染。所以使用...复制一次
|
|
763
767
|
|
|
764
768
|
/*
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -20,8 +20,12 @@ var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stab
|
|
|
20
20
|
|
|
21
21
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
22
22
|
|
|
23
|
+
var _isNan = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/is-nan"));
|
|
24
|
+
|
|
23
25
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
24
26
|
|
|
27
|
+
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
28
|
+
|
|
25
29
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
26
30
|
|
|
27
31
|
var _toString2 = _interopRequireDefault(require("lodash/toString"));
|
|
@@ -232,9 +236,9 @@ class InputNumberFoundation extends _foundation.default {
|
|
|
232
236
|
|
|
233
237
|
this._adapter.recordCursorPosition();
|
|
234
238
|
|
|
235
|
-
const
|
|
239
|
+
const formattedVal = code === _keyCode.default.UP ? this.add() : this.minus();
|
|
236
240
|
|
|
237
|
-
this._doInput(
|
|
241
|
+
this._doInput(formattedVal, event, () => {
|
|
238
242
|
this._adapter.restoreCursor();
|
|
239
243
|
});
|
|
240
244
|
|
|
@@ -407,18 +411,22 @@ class InputNumberFoundation extends _foundation.default {
|
|
|
407
411
|
value
|
|
408
412
|
} = this.getProps();
|
|
409
413
|
const propsValue = this._isControlledComponent('value') ? value : defaultValue;
|
|
410
|
-
const
|
|
414
|
+
const tmpNumber = this.doParse((0, _toString2.default)(propsValue), false, true, true);
|
|
411
415
|
let number = null;
|
|
412
416
|
|
|
413
|
-
if (typeof
|
|
414
|
-
number =
|
|
417
|
+
if (typeof tmpNumber === 'number' && !isNaN(tmpNumber)) {
|
|
418
|
+
number = tmpNumber;
|
|
415
419
|
}
|
|
416
420
|
|
|
417
|
-
const
|
|
421
|
+
const formattedValue = typeof number === 'number' ? this.doFormat(number, true) : '';
|
|
418
422
|
|
|
419
423
|
this._adapter.setNumber(number);
|
|
420
424
|
|
|
421
|
-
this._adapter.setValue(
|
|
425
|
+
this._adapter.setValue(formattedValue);
|
|
426
|
+
|
|
427
|
+
if ((0, _isString2.default)(formattedValue) && formattedValue !== String(propsValue)) {
|
|
428
|
+
this.notifyChange(formattedValue, null);
|
|
429
|
+
}
|
|
422
430
|
}
|
|
423
431
|
|
|
424
432
|
add(step, event) {
|
|
@@ -489,7 +497,7 @@ class InputNumberFoundation extends _foundation.default {
|
|
|
489
497
|
_adjustPrec(num) {
|
|
490
498
|
const precision = this.getProp('precision');
|
|
491
499
|
|
|
492
|
-
if (typeof precision === 'number' && num !== '') {
|
|
500
|
+
if (typeof precision === 'number' && num !== '' && num !== null && !(0, _isNan.default)(Number(num))) {
|
|
493
501
|
num = Number(num).toFixed(precision);
|
|
494
502
|
}
|
|
495
503
|
|
|
@@ -707,6 +715,10 @@ class InputNumberFoundation extends _foundation.default {
|
|
|
707
715
|
}
|
|
708
716
|
}
|
|
709
717
|
|
|
718
|
+
updateStates(states, callback) {
|
|
719
|
+
this._adapter.updateStates(states, callback);
|
|
720
|
+
}
|
|
721
|
+
|
|
710
722
|
}
|
|
711
723
|
|
|
712
724
|
var _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
|
|
@@ -114,7 +114,7 @@ class NavigationFoundation extends _foundation.default {
|
|
|
114
114
|
const {
|
|
115
115
|
itemKeysMap,
|
|
116
116
|
willOpenKeys,
|
|
117
|
-
|
|
117
|
+
formattedItems
|
|
118
118
|
} = this.getCalcState();
|
|
119
119
|
const parentSelectKeys = this.selectLevelZeroParentKeys(itemKeysMap, willSelectedKeys);
|
|
120
120
|
willSelectedKeys = (0, _concat.default)(willSelectedKeys).call(willSelectedKeys, parentSelectKeys);
|
|
@@ -124,7 +124,7 @@ class NavigationFoundation extends _foundation.default {
|
|
|
124
124
|
selectedKeys: willSelectedKeys,
|
|
125
125
|
itemKeysMap,
|
|
126
126
|
openKeys: willOpenKeys,
|
|
127
|
-
items:
|
|
127
|
+
items: formattedItems
|
|
128
128
|
};
|
|
129
129
|
} else {
|
|
130
130
|
this._adapter.updateSelectedKeys(willSelectedKeys);
|
|
@@ -133,7 +133,7 @@ class NavigationFoundation extends _foundation.default {
|
|
|
133
133
|
|
|
134
134
|
this._adapter.updateOpenKeys(willOpenKeys);
|
|
135
135
|
|
|
136
|
-
this._adapter.updateItems(
|
|
136
|
+
this._adapter.updateItems(formattedItems);
|
|
137
137
|
|
|
138
138
|
this._adapter.setItemsChanged(true);
|
|
139
139
|
}
|
|
@@ -148,13 +148,13 @@ class NavigationFoundation extends _foundation.default {
|
|
|
148
148
|
getCalcState() {
|
|
149
149
|
const {
|
|
150
150
|
itemKeysMap,
|
|
151
|
-
|
|
152
|
-
} = this.
|
|
151
|
+
formattedItems
|
|
152
|
+
} = this.getFormattedItems();
|
|
153
153
|
const willOpenKeys = this.getWillOpenKeys(itemKeysMap);
|
|
154
154
|
return {
|
|
155
155
|
itemKeysMap,
|
|
156
156
|
willOpenKeys,
|
|
157
|
-
|
|
157
|
+
formattedItems
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
@@ -162,17 +162,17 @@ class NavigationFoundation extends _foundation.default {
|
|
|
162
162
|
*/
|
|
163
163
|
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
getFormattedItems() {
|
|
166
166
|
const {
|
|
167
167
|
items,
|
|
168
168
|
children
|
|
169
169
|
} = this.getProps();
|
|
170
|
-
const
|
|
171
|
-
const willHandleItems = (0, _isArray.default)(items) && items.length ?
|
|
170
|
+
const formattedItems = this.formatItems(items);
|
|
171
|
+
const willHandleItems = (0, _isArray.default)(items) && items.length ? formattedItems : children;
|
|
172
172
|
const itemKeysMap = NavigationFoundation.buildItemKeysMap(willHandleItems);
|
|
173
173
|
return {
|
|
174
174
|
itemKeysMap,
|
|
175
|
-
|
|
175
|
+
formattedItems
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
@@ -263,13 +263,13 @@ class NavigationFoundation extends _foundation.default {
|
|
|
263
263
|
|
|
264
264
|
formatItems() {
|
|
265
265
|
let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
266
|
-
const
|
|
266
|
+
const formattedItems = [];
|
|
267
267
|
|
|
268
268
|
for (const item of items) {
|
|
269
|
-
|
|
269
|
+
formattedItems.push(new _NavItem.default(item));
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
return
|
|
272
|
+
return formattedItems;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
handleSelect(data) {
|
|
@@ -37,9 +37,9 @@ class TabsFoundation extends _foundation.default {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
handleTabClick(activeKey, event) {
|
|
40
|
-
const
|
|
40
|
+
const isControlledComponent = this._isInProps('activeKey');
|
|
41
41
|
|
|
42
|
-
if (
|
|
42
|
+
if (isControlledComponent) {
|
|
43
43
|
this._notifyChange(activeKey);
|
|
44
44
|
} else {
|
|
45
45
|
this._notifyChange(activeKey);
|
|
@@ -118,7 +118,7 @@ class ComboboxFoundation extends _foundation.default {
|
|
|
118
118
|
if (this._isInProps('format')) {
|
|
119
119
|
return this.getProp('format');
|
|
120
120
|
} else if (this.getProp('use12Hours')) {
|
|
121
|
-
return _constants.strings.
|
|
121
|
+
return _constants.strings.DEFAULT_FORMAT_A;
|
|
122
122
|
} else {
|
|
123
123
|
return _constants.strings.DEFAULT_FORMAT;
|
|
124
124
|
}
|
|
@@ -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;
|
|
@@ -31,7 +31,7 @@ const strings = {
|
|
|
31
31
|
DEFAULT_MULTIPLE_SEPARATOR,
|
|
32
32
|
SIZE: _constants2.strings.SIZE,
|
|
33
33
|
DEFAULT_FORMAT: 'HH:mm:ss',
|
|
34
|
-
|
|
34
|
+
DEFAULT_FORMAT_A: 'a h:mm:ss',
|
|
35
35
|
STATUS: _constants.VALIDATE_STATUS,
|
|
36
36
|
DEFAULT_POSITION: {
|
|
37
37
|
[TYPE_TIME_PICKER]: 'bottomLeft',
|
|
@@ -92,7 +92,7 @@ class TimePickerFoundation extends _foundation.default {
|
|
|
92
92
|
if (this._isInProps('format')) {
|
|
93
93
|
return this.getProp('format');
|
|
94
94
|
} else if (this.getProp('use12Hours')) {
|
|
95
|
-
return _constants.strings.
|
|
95
|
+
return _constants.strings.DEFAULT_FORMAT_A;
|
|
96
96
|
} else {
|
|
97
97
|
return _constants.strings.DEFAULT_FORMAT;
|
|
98
98
|
}
|
|
@@ -36,7 +36,7 @@ var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
|
36
36
|
|
|
37
37
|
var _constants = require("./constants");
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _transferUtils = require("./transferUtils");
|
|
40
40
|
|
|
41
41
|
// eslint-disable-next-line max-len
|
|
42
42
|
class TransferFoundation extends _foundation.default {
|
|
@@ -45,11 +45,11 @@ class TransferFoundation extends _foundation.default {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
_generateGroupedData(dataSource) {
|
|
48
|
-
return (0,
|
|
48
|
+
return (0, _transferUtils._generateGroupedData)(dataSource);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
_generateTreeData(dataSource) {
|
|
52
|
-
return (0,
|
|
52
|
+
return (0, _transferUtils._generateTreeData)(dataSource);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
_generatePath(item) {
|
|
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
|
};
|
|
@@ -342,7 +342,7 @@ class TreeFoundation extends _foundation.default {
|
|
|
342
342
|
*/
|
|
343
343
|
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
calcCheckedStatus(targetStatus, eventKey) {
|
|
346
346
|
// From checked to unchecked, you can change it directly
|
|
347
347
|
if (!targetStatus) {
|
|
348
348
|
return targetStatus;
|
|
@@ -371,7 +371,7 @@ class TreeFoundation extends _foundation.default {
|
|
|
371
371
|
*/
|
|
372
372
|
|
|
373
373
|
|
|
374
|
-
|
|
374
|
+
calcNonDisabledCheckedKeys(eventKey, targetStatus) {
|
|
375
375
|
const {
|
|
376
376
|
keyEntities,
|
|
377
377
|
disabledKeys
|
|
@@ -412,11 +412,11 @@ class TreeFoundation extends _foundation.default {
|
|
|
412
412
|
|
|
413
413
|
if (checkRelation === 'related') {
|
|
414
414
|
// Find the checked state of the current node
|
|
415
|
-
const targetStatus = disableStrictly ? this.
|
|
415
|
+
const targetStatus = disableStrictly ? this.calcCheckedStatus(!checked, eventKey) : !checked;
|
|
416
416
|
const {
|
|
417
417
|
checkedKeys,
|
|
418
418
|
halfCheckedKeys
|
|
419
|
-
} = disableStrictly ? this.
|
|
419
|
+
} = disableStrictly ? this.calcNonDisabledCheckedKeys(eventKey, targetStatus) : this.calcCheckedKeys(eventKey, targetStatus);
|
|
420
420
|
|
|
421
421
|
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
422
422
|
|
package/lib/cjs/tree/treeUtil.js
CHANGED
|
@@ -159,11 +159,11 @@ function convertJsonToData(treeJson) {
|
|
|
159
159
|
if ((0, _isObject2.default)(children)) {
|
|
160
160
|
var _context2;
|
|
161
161
|
|
|
162
|
-
const
|
|
162
|
+
const newChildren = [];
|
|
163
163
|
(0, _forEach.default)(_context2 = (0, _entries.default)(children)).call(_context2, c => {
|
|
164
|
-
traverseNode(c[0], c[1], currPath,
|
|
164
|
+
traverseNode(c[0], c[1], currPath, newChildren);
|
|
165
165
|
});
|
|
166
|
-
newNode.children =
|
|
166
|
+
newNode.children = newChildren;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
res.push(newNode);
|
|
@@ -434,8 +434,8 @@ function calcCheckedKeys(values, keyEntities) {
|
|
|
434
434
|
const allChecked = (0, _every.default)(siblingKeys).call(siblingKeys, siblingKey => checkedKeys.has(siblingKey));
|
|
435
435
|
|
|
436
436
|
if (!allChecked) {
|
|
437
|
-
const
|
|
438
|
-
halfCheckedKeys = new _set.default([...halfCheckedKeys, ...
|
|
437
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
438
|
+
halfCheckedKeys = new _set.default([...halfCheckedKeys, ...ancestorKeys]);
|
|
439
439
|
} else {
|
|
440
440
|
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
|
|
441
441
|
|
|
@@ -474,8 +474,8 @@ function calcExpandedKeys() {
|
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
if (autoExpandParent) {
|
|
477
|
-
const
|
|
478
|
-
return new _set.default(
|
|
477
|
+
const ancestorKeys = findAncestorKeys(keyList, keyEntities, true);
|
|
478
|
+
return new _set.default(ancestorKeys);
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
return new _set.default(keyList);
|
|
@@ -627,8 +627,8 @@ function calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfCheckedKey
|
|
|
627
627
|
const allChecked = (0, _every.default)(siblingKeys).call(siblingKeys, key => checkedKeys.has(key));
|
|
628
628
|
|
|
629
629
|
if (!allChecked) {
|
|
630
|
-
const
|
|
631
|
-
halfCheckedKeys = new _set.default([...halfCheckedKeys, ...
|
|
630
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
631
|
+
halfCheckedKeys = new _set.default([...halfCheckedKeys, ...ancestorKeys]);
|
|
632
632
|
} else {
|
|
633
633
|
const par = node.parent;
|
|
634
634
|
checkedKeys.add(par.key);
|
|
@@ -677,10 +677,10 @@ function calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfCheckedK
|
|
|
677
677
|
const siblingKeys = findSiblingKeys([key], keyEntities); // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
678
678
|
|
|
679
679
|
const anyChecked = (0, _some.default)(siblingKeys).call(siblingKeys, key => checkedKeys.has(key) || halfCheckedKeys.has(key));
|
|
680
|
-
const
|
|
680
|
+
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
|
|
681
681
|
|
|
682
682
|
if (anyChecked) {
|
|
683
|
-
(0, _forEach.default)(
|
|
683
|
+
(0, _forEach.default)(ancestorKeys).call(ancestorKeys, itemKey => {
|
|
684
684
|
if (checkedKeys.has(itemKey)) {
|
|
685
685
|
checkedKeys.delete(itemKey);
|
|
686
686
|
halfCheckedKeys.add(itemKey);
|