@douyinfe/semi-foundation 2.2.1 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/breadcrumb/foundation.ts +10 -1
- package/checkbox/checkboxFoundation.ts +9 -0
- package/datePicker/foundation.ts +2 -4
- package/datePicker/monthsGridFoundation.ts +10 -3
- package/form/foundation.ts +20 -8
- package/form/utils.ts +2 -0
- package/input/foundation.ts +21 -2
- package/input/textareaFoundation.ts +11 -1
- package/inputNumber/foundation.ts +3 -2
- package/lib/cjs/breadcrumb/foundation.d.ts +4 -0
- package/lib/cjs/breadcrumb/foundation.js +12 -0
- package/lib/cjs/checkbox/checkboxFoundation.d.ts +3 -0
- package/lib/cjs/checkbox/checkboxFoundation.js +8 -0
- package/lib/cjs/datePicker/foundation.js +2 -4
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGridFoundation.js +16 -3
- package/lib/cjs/form/foundation.d.ts +13 -0
- package/lib/cjs/form/foundation.js +32 -8
- package/lib/cjs/form/utils.d.ts +1 -0
- package/lib/cjs/form/utils.js +5 -3
- package/lib/cjs/input/foundation.d.ts +8 -0
- package/lib/cjs/input/foundation.js +24 -2
- package/lib/cjs/input/textareaFoundation.d.ts +5 -1
- package/lib/cjs/input/textareaFoundation.js +12 -0
- package/lib/cjs/inputNumber/foundation.d.ts +2 -2
- package/lib/cjs/inputNumber/foundation.js +3 -1
- package/lib/cjs/modal/modalContentFoundation.d.ts +7 -0
- package/lib/cjs/modal/modalContentFoundation.js +14 -0
- package/lib/cjs/navigation/itemFoundation.d.ts +5 -0
- package/lib/cjs/navigation/itemFoundation.js +12 -0
- package/lib/cjs/navigation/subNavFoundation.d.ts +6 -0
- package/lib/cjs/navigation/subNavFoundation.js +14 -0
- package/lib/cjs/notification/notificationListFoundation.js +1 -1
- package/lib/cjs/radio/radio.css +7 -1
- package/lib/cjs/radio/radio.scss +8 -1
- package/lib/cjs/select/foundation.d.ts +2 -0
- package/lib/cjs/select/foundation.js +40 -6
- package/lib/cjs/sideSheet/sideSheetFoundation.d.ts +1 -0
- package/lib/cjs/slider/foundation.d.ts +6 -1
- package/lib/cjs/slider/foundation.js +6 -12
- package/lib/cjs/slider/slider.css +1 -0
- package/lib/cjs/slider/slider.scss +1 -0
- package/lib/cjs/table/utils.d.ts +7 -0
- package/lib/cjs/table/utils.js +26 -0
- package/lib/cjs/tagInput/foundation.d.ts +4 -0
- package/lib/cjs/tagInput/foundation.js +12 -0
- package/lib/cjs/tooltip/foundation.js +7 -6
- package/lib/cjs/transfer/transfer.css +0 -2
- package/lib/cjs/transfer/transfer.scss +0 -2
- package/lib/cjs/tree/foundation.d.ts +1 -0
- package/lib/cjs/tree/foundation.js +1 -1
- package/lib/cjs/treeSelect/foundation.d.ts +9 -1
- package/lib/cjs/treeSelect/foundation.js +22 -0
- package/lib/cjs/utils/isEnterPress.d.ts +4 -0
- package/lib/cjs/utils/isEnterPress.js +22 -0
- package/lib/cjs/utils/keyCode.d.ts +2 -0
- package/lib/cjs/utils/keyCode.js +5 -1
- package/lib/cjs/utils/uuid.d.ts +16 -1
- package/lib/cjs/utils/uuid.js +32 -0
- package/lib/es/breadcrumb/foundation.d.ts +4 -0
- package/lib/es/breadcrumb/foundation.js +11 -0
- package/lib/es/checkbox/checkboxFoundation.d.ts +3 -0
- package/lib/es/checkbox/checkboxFoundation.js +7 -0
- package/lib/es/datePicker/foundation.js +2 -4
- package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/es/datePicker/monthsGridFoundation.js +15 -3
- package/lib/es/form/foundation.d.ts +13 -0
- package/lib/es/form/foundation.js +31 -8
- package/lib/es/form/utils.d.ts +1 -0
- package/lib/es/form/utils.js +5 -3
- package/lib/es/input/foundation.d.ts +8 -0
- package/lib/es/input/foundation.js +23 -2
- package/lib/es/input/textareaFoundation.d.ts +5 -1
- package/lib/es/input/textareaFoundation.js +11 -0
- package/lib/es/inputNumber/foundation.d.ts +2 -2
- package/lib/es/inputNumber/foundation.js +3 -1
- package/lib/es/modal/modalContentFoundation.d.ts +7 -0
- package/lib/es/modal/modalContentFoundation.js +14 -0
- package/lib/es/navigation/itemFoundation.d.ts +5 -0
- package/lib/es/navigation/itemFoundation.js +11 -0
- package/lib/es/navigation/subNavFoundation.d.ts +6 -0
- package/lib/es/navigation/subNavFoundation.js +13 -0
- package/lib/es/notification/notificationListFoundation.js +1 -1
- package/lib/es/radio/radio.css +7 -1
- package/lib/es/radio/radio.scss +8 -1
- package/lib/es/select/foundation.d.ts +2 -0
- package/lib/es/select/foundation.js +31 -6
- package/lib/es/sideSheet/sideSheetFoundation.d.ts +1 -0
- package/lib/es/slider/foundation.d.ts +6 -1
- package/lib/es/slider/foundation.js +6 -12
- package/lib/es/slider/slider.css +1 -0
- package/lib/es/slider/slider.scss +1 -0
- package/lib/es/table/utils.d.ts +7 -0
- package/lib/es/table/utils.js +24 -0
- package/lib/es/tagInput/foundation.d.ts +4 -0
- package/lib/es/tagInput/foundation.js +11 -0
- package/lib/es/tooltip/foundation.js +7 -6
- package/lib/es/transfer/transfer.css +0 -2
- package/lib/es/transfer/transfer.scss +0 -2
- package/lib/es/tree/foundation.d.ts +1 -0
- package/lib/es/tree/foundation.js +1 -1
- package/lib/es/treeSelect/foundation.d.ts +9 -1
- package/lib/es/treeSelect/foundation.js +22 -1
- package/lib/es/utils/isEnterPress.d.ts +4 -0
- package/lib/es/utils/isEnterPress.js +8 -0
- package/lib/es/utils/keyCode.d.ts +2 -0
- package/lib/es/utils/keyCode.js +2 -0
- package/lib/es/utils/uuid.d.ts +16 -1
- package/lib/es/utils/uuid.js +32 -1
- package/modal/modalContentFoundation.ts +18 -0
- package/navigation/itemFoundation.ts +11 -0
- package/navigation/subNavFoundation.ts +12 -0
- package/notification/notificationListFoundation.ts +4 -8
- package/package.json +3 -3
- package/radio/radio.scss +8 -1
- package/select/foundation.ts +26 -7
- package/sideSheet/sideSheetFoundation.ts +3 -5
- package/slider/foundation.ts +10 -13
- package/slider/slider.scss +1 -0
- package/table/utils.ts +16 -0
- package/tagInput/foundation.ts +10 -0
- package/tooltip/foundation.ts +5 -5
- package/transfer/transfer.scss +0 -2
- package/tree/foundation.ts +2 -1
- package/treeSelect/foundation.ts +20 -0
- package/utils/isEnterPress.ts +8 -0
- package/utils/keyCode.ts +3 -0
- package/utils/uuid.ts +29 -1
package/breadcrumb/foundation.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable prefer-const */
|
|
2
2
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
|
-
|
|
3
|
+
import isEnterPress from '../utils/isEnterPress';
|
|
4
4
|
import { BreadcrumbItemInfo, Route } from './itemFoundation';
|
|
5
5
|
export interface BreadcrumbAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
6
6
|
notifyClick: (itemInfo: BreadcrumbItemInfo, event: any) => void;
|
|
@@ -21,6 +21,15 @@ export default class BreadcrumbFoundation<P = Record<string, any>, S = Record<st
|
|
|
21
21
|
this._adapter.expandCollapsed(clickEvent);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* A11y: simulate clear button click
|
|
26
|
+
*/
|
|
27
|
+
handleExpandEnterPress(keyboardEvent: any) {
|
|
28
|
+
if (isEnterPress(keyboardEvent)) {
|
|
29
|
+
this.handleExpand(keyboardEvent);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
genRoutes(routes: Array<Route>) {
|
|
25
34
|
return routes.map(route => {
|
|
26
35
|
if (typeof route !== 'object') {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter, noopFunction } from '../base/foundation';
|
|
2
|
+
import isEnterPress from '../utils/isEnterPress';
|
|
2
3
|
|
|
3
4
|
export interface BasicTargetObject {
|
|
4
5
|
[x: string]: any;
|
|
@@ -98,6 +99,12 @@ class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> exten
|
|
|
98
99
|
this._adapter.notifyGroupChange(event);
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
handleEnterPress(e: any) {
|
|
103
|
+
if (isEnterPress(e)) {
|
|
104
|
+
this.handleChange(e);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
101
108
|
setChecked(checked: boolean) {
|
|
102
109
|
this._adapter.setNativeControlChecked(checked);
|
|
103
110
|
}
|
|
@@ -121,6 +128,8 @@ export interface BaseCheckboxProps {
|
|
|
121
128
|
onMouseEnter?: (e: any) => void;
|
|
122
129
|
onMouseLeave?: (e: any) => void;
|
|
123
130
|
extra?: any;
|
|
131
|
+
addonId?: string;
|
|
132
|
+
extraId?: string;
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
export default CheckboxFoundation;
|
package/datePicker/foundation.ts
CHANGED
|
@@ -745,7 +745,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
745
745
|
let inputValue;
|
|
746
746
|
if (!this._someDateDisabled(changedDates)) {
|
|
747
747
|
inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
|
|
748
|
-
const isRangeTypeAndInputIncomplete = this._isRangeType() && (
|
|
748
|
+
const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
|
|
749
749
|
/**
|
|
750
750
|
* If the input is incomplete when under control, the notifyChange is not triggered because
|
|
751
751
|
* You need to update the value of the input box, otherwise there will be a problem that a date is selected but the input box does not show the date #1357
|
|
@@ -1024,11 +1024,9 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
1024
1024
|
};
|
|
1025
1025
|
|
|
1026
1026
|
_isRangeValueComplete = (value: Date[] | Date) => {
|
|
1027
|
-
let result =
|
|
1027
|
+
let result = false;
|
|
1028
1028
|
if (Array.isArray(value)) {
|
|
1029
1029
|
result = !value.some(date => isNullOrUndefined(date));
|
|
1030
|
-
} else {
|
|
1031
|
-
result = false;
|
|
1032
1030
|
}
|
|
1033
1031
|
return result;
|
|
1034
1032
|
};
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { isBefore, isValidDate, getDefaultFormatToken, getFullDateOffset } from './_utils/index';
|
|
17
17
|
import { formatFullDate, WeekStartNumber } from './_utils/getMonthTable';
|
|
18
18
|
import { compatiableParse } from './_utils/parser';
|
|
19
|
-
import { includes, isSet, isEqual } from 'lodash';
|
|
19
|
+
import { includes, isSet, isEqual, isFunction } from 'lodash';
|
|
20
20
|
import { zonedTimeToUtc } from '../utils/date-fns-extra';
|
|
21
21
|
import { getDefaultFormatTokenByType } from './_utils/getDefaultFormatToken';
|
|
22
22
|
import isNullOrUndefined from '../utils/isNullOrUndefined';
|
|
@@ -85,6 +85,7 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
|
|
|
85
85
|
setRangeInputFocus?: (rangeInputFocus: 'rangeStart' | 'rangeEnd') => void;
|
|
86
86
|
isAnotherPanelHasOpened?: (currentRangeInput: 'rangeStart' | 'rangeEnd') => boolean;
|
|
87
87
|
focusRecordsRef?: any;
|
|
88
|
+
triggerRender?: (props: Record<string, any>) => any;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
export interface MonthInfo {
|
|
@@ -636,7 +637,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
636
637
|
|
|
637
638
|
handleRangeSelected(day: MonthDayInfo) {
|
|
638
639
|
let { rangeStart, rangeEnd } = this.getStates();
|
|
639
|
-
const { startDateOffset, endDateOffset, type, dateFnsLocale, rangeInputFocus } = this.getProps();
|
|
640
|
+
const { startDateOffset, endDateOffset, type, dateFnsLocale, rangeInputFocus, triggerRender } = this._adapter.getProps();
|
|
640
641
|
const { fullDate } = day;
|
|
641
642
|
let rangeStartReset = false;
|
|
642
643
|
let rangeEndReset = false;
|
|
@@ -712,7 +713,13 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
712
713
|
date = [start, end];
|
|
713
714
|
}
|
|
714
715
|
}
|
|
715
|
-
|
|
716
|
+
/**
|
|
717
|
+
* no need to check focus then
|
|
718
|
+
* - dateRange and isDateRangeAndHasOffset
|
|
719
|
+
* - dateRange and triggerRender
|
|
720
|
+
*/
|
|
721
|
+
const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || isFunction(triggerRender)));
|
|
722
|
+
this._adapter.notifySelectedChange(date, { needCheckFocusRecord });
|
|
716
723
|
}
|
|
717
724
|
}
|
|
718
725
|
|
package/form/foundation.ts
CHANGED
|
@@ -258,10 +258,19 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Case A:
|
|
263
|
+
* All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
|
|
264
|
+
* input => output:
|
|
265
|
+
* a => a[0]、a[1]
|
|
266
|
+
* b => b.type、b.name[0]、b.name[2]
|
|
267
|
+
*
|
|
268
|
+
* Case B:
|
|
269
|
+
* All fields: activity.a[0]、activity.a[1]、activity.c、activity.d、other
|
|
270
|
+
* input => output:
|
|
271
|
+
* activity.a => activity.a[0]、activity.a[1]
|
|
272
|
+
*
|
|
273
|
+
*/
|
|
265
274
|
_getNestedField(path: string): Map<string, FieldStaff> {
|
|
266
275
|
const allRegisterField = this.fields;
|
|
267
276
|
const allFieldPath = [...allRegisterField].map(item => item[0]);
|
|
@@ -269,7 +278,7 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
269
278
|
allFieldPath.forEach(item => {
|
|
270
279
|
let itemPath = toPath(item);
|
|
271
280
|
let targetPath = toPath(path);
|
|
272
|
-
if (
|
|
281
|
+
if (targetPath.every((path, i) => (targetPath[i] === itemPath[i]))) {
|
|
273
282
|
const realField = allRegisterField.get(item);
|
|
274
283
|
nestedFieldPath.set(item, realField);
|
|
275
284
|
}
|
|
@@ -503,7 +512,8 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
503
512
|
nestedFields.forEach(fieldStaff => {
|
|
504
513
|
let fieldPath = fieldStaff.field;
|
|
505
514
|
let newFieldVal = ObjectUtil.get(this.data.values, fieldPath);
|
|
506
|
-
|
|
515
|
+
let nestedBatchUpdateOpts = { notNotify: true, notUpdate: true };
|
|
516
|
+
fieldStaff.fieldApi.setValue(newFieldVal, nestedBatchUpdateOpts);
|
|
507
517
|
});
|
|
508
518
|
}
|
|
509
519
|
// If the reset happens to be, then update the updateKey corresponding to ArrayField to render it again
|
|
@@ -524,7 +534,8 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
524
534
|
nestedFields.forEach(fieldStaff => {
|
|
525
535
|
let fieldPath = fieldStaff.field;
|
|
526
536
|
let newFieldError = ObjectUtil.get(this.data.errors, fieldPath);
|
|
527
|
-
|
|
537
|
+
let nestedBatchUpdateOpts = { notNotify: true, notUpdate: true };
|
|
538
|
+
fieldStaff.fieldApi.setError(newFieldError, nestedBatchUpdateOpts);
|
|
528
539
|
});
|
|
529
540
|
}
|
|
530
541
|
if (this.getArrayField(field)) {
|
|
@@ -544,7 +555,8 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
544
555
|
nestedFields.forEach(fieldStaff => {
|
|
545
556
|
let fieldPath = fieldStaff.field;
|
|
546
557
|
let newFieldTouch = ObjectUtil.get(this.data.touched, fieldPath);
|
|
547
|
-
|
|
558
|
+
let nestedBatchUpdateOpts = { notNotify: true, notUpdate: true };
|
|
559
|
+
fieldStaff.fieldApi.setTouched(newFieldTouch, nestedBatchUpdateOpts);
|
|
548
560
|
});
|
|
549
561
|
}
|
|
550
562
|
if (this.getArrayField(field)) {
|
package/form/utils.ts
CHANGED
|
@@ -133,6 +133,7 @@ export function mergeProps(props: any) {
|
|
|
133
133
|
extraText,
|
|
134
134
|
extraTextPosition,
|
|
135
135
|
pure,
|
|
136
|
+
id,
|
|
136
137
|
...rest
|
|
137
138
|
}: any = { ...defaultProps, ...props };
|
|
138
139
|
// Form中的任何类型组件,初始值都统一通过initValue字段来传入,同时将可能会导致组件行为错误的props抽取出来,防止透传到组件中
|
|
@@ -183,6 +184,7 @@ export function mergeProps(props: any) {
|
|
|
183
184
|
extraTextPosition,
|
|
184
185
|
pure,
|
|
185
186
|
rest,
|
|
187
|
+
id
|
|
186
188
|
};
|
|
187
189
|
}
|
|
188
190
|
|
package/input/foundation.ts
CHANGED
|
@@ -2,7 +2,8 @@ import BaseFoundation, { DefaultAdapter, noopFunction } from '../base/foundation
|
|
|
2
2
|
import { strings } from './constants';
|
|
3
3
|
import { noop, set, isNumber, isString, isFunction } from 'lodash';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import isEnterPress from '../utils/isEnterPress';
|
|
6
|
+
import { ENTER_KEY } from './../utils/keyCode';
|
|
6
7
|
|
|
7
8
|
export interface InputDefaultAdapter {
|
|
8
9
|
notifyChange: noopFunction;
|
|
@@ -261,7 +262,7 @@ class InputFoundation extends BaseFoundation<InputAdapter> {
|
|
|
261
262
|
|
|
262
263
|
handleKeyPress(e: any) {
|
|
263
264
|
this._adapter.notifyKeyPress(e);
|
|
264
|
-
if (e.key ===
|
|
265
|
+
if (e.key === ENTER_KEY) {
|
|
265
266
|
this._adapter.notifyEnterPress(e);
|
|
266
267
|
}
|
|
267
268
|
}
|
|
@@ -294,5 +295,23 @@ class InputFoundation extends BaseFoundation<InputAdapter> {
|
|
|
294
295
|
e.preventDefault();
|
|
295
296
|
}
|
|
296
297
|
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* A11y: simulate clear button click
|
|
301
|
+
*/
|
|
302
|
+
handleClearEnterPress(e: any) {
|
|
303
|
+
if (isEnterPress(e)) {
|
|
304
|
+
this.handleClear(e);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* A11y: simulate password button click
|
|
310
|
+
*/
|
|
311
|
+
handleModeEnterPress(e: any) {
|
|
312
|
+
if (isEnterPress(e)) {
|
|
313
|
+
this.handleClickEye(e);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
297
316
|
}
|
|
298
317
|
export default InputFoundation;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from 'lodash';
|
|
8
8
|
import calculateNodeHeight from './util/calculateNodeHeight';
|
|
9
9
|
import getSizingData from './util/getSizingData';
|
|
10
|
+
import isEnterPress from '../utils/isEnterPress';
|
|
10
11
|
|
|
11
12
|
export interface TextAreaDefaultAdpter {
|
|
12
13
|
notifyChange: noopFunction;
|
|
@@ -171,7 +172,7 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdpter> {
|
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
resizeTextarea = (cb
|
|
175
|
+
resizeTextarea = (cb?: any) => {
|
|
175
176
|
const { height } = this.getStates();
|
|
176
177
|
const { rows } = this.getProps();
|
|
177
178
|
const node = this._adapter.getRef().current;
|
|
@@ -232,4 +233,13 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdpter> {
|
|
|
232
233
|
this._adapter.notifyClear(e);
|
|
233
234
|
this.stopPropagation(e);
|
|
234
235
|
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A11y: simulate clear button click
|
|
239
|
+
*/
|
|
240
|
+
handleClearEnterPress(e: any) {
|
|
241
|
+
if (isEnterPress(e)) {
|
|
242
|
+
this.handleClear(e);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
235
245
|
}
|
|
@@ -126,6 +126,7 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
|
|
|
126
126
|
}
|
|
127
127
|
this._adapter.recordCursorPosition();
|
|
128
128
|
this._adapter.setFocusing(true, null);
|
|
129
|
+
this._adapter.setClickUpOrDown(false);
|
|
129
130
|
this._adapter.notifyFocus(e);
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -425,11 +426,11 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
|
|
|
425
426
|
|
|
426
427
|
/**
|
|
427
428
|
* format number to string
|
|
428
|
-
* @param {number} value
|
|
429
|
+
* @param {string|number} value
|
|
429
430
|
* @param {boolean} needAdjustPrec
|
|
430
431
|
* @returns {string}
|
|
431
432
|
*/
|
|
432
|
-
doFormat(value = 0, needAdjustPrec = true): string {
|
|
433
|
+
doFormat(value: string | number = 0, needAdjustPrec = true): string {
|
|
433
434
|
// if (typeof value === 'string') {
|
|
434
435
|
// return value;
|
|
435
436
|
// }
|
|
@@ -8,6 +8,10 @@ export default class BreadcrumbFoundation<P = Record<string, any>, S = Record<st
|
|
|
8
8
|
constructor(adapter: BreadcrumbAdapter<P, S>);
|
|
9
9
|
handleClick(info: BreadcrumbItemInfo, event: any): void;
|
|
10
10
|
handleExpand(clickEvent: any): void;
|
|
11
|
+
/**
|
|
12
|
+
* A11y: simulate clear button click
|
|
13
|
+
*/
|
|
14
|
+
handleExpandEnterPress(keyboardEvent: any): void;
|
|
11
15
|
genRoutes(routes: Array<Route>): ({
|
|
12
16
|
name: never;
|
|
13
17
|
_origin: {
|
|
@@ -16,6 +16,8 @@ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable
|
|
|
16
16
|
|
|
17
17
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
18
18
|
|
|
19
|
+
var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
|
|
20
|
+
|
|
19
21
|
/* eslint-disable prefer-const */
|
|
20
22
|
class BreadcrumbFoundation extends _foundation.default {
|
|
21
23
|
constructor(adapter) {
|
|
@@ -29,6 +31,16 @@ class BreadcrumbFoundation extends _foundation.default {
|
|
|
29
31
|
handleExpand(clickEvent) {
|
|
30
32
|
this._adapter.expandCollapsed(clickEvent);
|
|
31
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* A11y: simulate clear button click
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
handleExpandEnterPress(keyboardEvent) {
|
|
40
|
+
if ((0, _isEnterPress.default)(keyboardEvent)) {
|
|
41
|
+
this.handleExpand(keyboardEvent);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
32
44
|
|
|
33
45
|
genRoutes(routes) {
|
|
34
46
|
return (0, _map.default)(routes).call(routes, route => {
|
|
@@ -34,6 +34,7 @@ declare class CheckboxFoundation<P = Record<string, any>, S = Record<string, any
|
|
|
34
34
|
notifyChange(checked: boolean, e: any): void;
|
|
35
35
|
handleChange(e: any): void;
|
|
36
36
|
handleChangeInGroup(e: any): void;
|
|
37
|
+
handleEnterPress(e: any): void;
|
|
37
38
|
setChecked(checked: boolean): void;
|
|
38
39
|
destroy(): void;
|
|
39
40
|
}
|
|
@@ -52,5 +53,7 @@ export interface BaseCheckboxProps {
|
|
|
52
53
|
onMouseEnter?: (e: any) => void;
|
|
53
54
|
onMouseLeave?: (e: any) => void;
|
|
54
55
|
extra?: any;
|
|
56
|
+
addonId?: string;
|
|
57
|
+
extraId?: string;
|
|
55
58
|
}
|
|
56
59
|
export default CheckboxFoundation;
|
|
@@ -16,6 +16,8 @@ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-s
|
|
|
16
16
|
|
|
17
17
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
18
18
|
|
|
19
|
+
var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
|
|
20
|
+
|
|
19
21
|
class CheckboxFoundation extends _foundation.default {
|
|
20
22
|
constructor(adapter) {
|
|
21
23
|
super((0, _assign.default)({}, adapter));
|
|
@@ -99,6 +101,12 @@ class CheckboxFoundation extends _foundation.default {
|
|
|
99
101
|
this._adapter.notifyGroupChange(event);
|
|
100
102
|
}
|
|
101
103
|
|
|
104
|
+
handleEnterPress(e) {
|
|
105
|
+
if ((0, _isEnterPress.default)(e)) {
|
|
106
|
+
this.handleChange(e);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
102
110
|
setChecked(checked) {
|
|
103
111
|
this._adapter.setNativeControlChecked(checked);
|
|
104
112
|
} // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -96,12 +96,10 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
this._isRangeValueComplete = value => {
|
|
99
|
-
let result =
|
|
99
|
+
let result = false;
|
|
100
100
|
|
|
101
101
|
if ((0, _isArray.default)(value)) {
|
|
102
102
|
result = !(0, _some.default)(value).call(value, date => (0, _isNullOrUndefined.default)(date));
|
|
103
|
-
} else {
|
|
104
|
-
result = false;
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
return result;
|
|
@@ -755,7 +753,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
755
753
|
|
|
756
754
|
if (!this._someDateDisabled(changedDates)) {
|
|
757
755
|
inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
|
|
758
|
-
const isRangeTypeAndInputIncomplete = this._isRangeType() &&
|
|
756
|
+
const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
|
|
759
757
|
/**
|
|
760
758
|
* If the input is incomplete when under control, the notifyChange is not triggered because
|
|
761
759
|
* You need to update the value of the input box, otherwise there will be a problem that a date is selected but the input box does not show the date #1357
|
|
@@ -53,6 +53,7 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
|
|
|
53
53
|
setRangeInputFocus?: (rangeInputFocus: 'rangeStart' | 'rangeEnd') => void;
|
|
54
54
|
isAnotherPanelHasOpened?: (currentRangeInput: 'rangeStart' | 'rangeEnd') => boolean;
|
|
55
55
|
focusRecordsRef?: any;
|
|
56
|
+
triggerRender?: (props: Record<string, any>) => any;
|
|
56
57
|
}
|
|
57
58
|
export interface MonthInfo {
|
|
58
59
|
pickerDate: Date;
|
|
@@ -28,6 +28,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
28
28
|
|
|
29
29
|
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
30
30
|
|
|
31
|
+
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
32
|
+
|
|
31
33
|
var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
|
|
32
34
|
|
|
33
35
|
var _isSet2 = _interopRequireDefault(require("lodash/isSet"));
|
|
@@ -731,13 +733,16 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
731
733
|
rangeStart,
|
|
732
734
|
rangeEnd
|
|
733
735
|
} = this.getStates();
|
|
736
|
+
|
|
734
737
|
const {
|
|
735
738
|
startDateOffset,
|
|
736
739
|
endDateOffset,
|
|
737
740
|
type,
|
|
738
741
|
dateFnsLocale,
|
|
739
|
-
rangeInputFocus
|
|
740
|
-
|
|
742
|
+
rangeInputFocus,
|
|
743
|
+
triggerRender
|
|
744
|
+
} = this._adapter.getProps();
|
|
745
|
+
|
|
741
746
|
const {
|
|
742
747
|
fullDate
|
|
743
748
|
} = day;
|
|
@@ -818,9 +823,17 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
818
823
|
date = [start, end];
|
|
819
824
|
}
|
|
820
825
|
}
|
|
826
|
+
/**
|
|
827
|
+
* no need to check focus then
|
|
828
|
+
* - dateRange and isDateRangeAndHasOffset
|
|
829
|
+
* - dateRange and triggerRender
|
|
830
|
+
*/
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || (0, _isFunction2.default)(triggerRender)));
|
|
821
834
|
|
|
822
835
|
this._adapter.notifySelectedChange(date, {
|
|
823
|
-
needCheckFocusRecord
|
|
836
|
+
needCheckFocusRecord
|
|
824
837
|
});
|
|
825
838
|
}
|
|
826
839
|
}
|
|
@@ -19,6 +19,19 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
19
19
|
_formValidate(): Promise<unknown>;
|
|
20
20
|
_fieldsValidate(fieldPaths: Array<string>): Promise<unknown>;
|
|
21
21
|
submit(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Case A:
|
|
24
|
+
* All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
|
|
25
|
+
* input => output:
|
|
26
|
+
* a => a[0]、a[1]
|
|
27
|
+
* b => b.type、b.name[0]、b.name[2]
|
|
28
|
+
*
|
|
29
|
+
* Case B:
|
|
30
|
+
* All fields: activity.a[0]、activity.a[1]、activity.c、activity.d、other
|
|
31
|
+
* input => output:
|
|
32
|
+
* activity.a => activity.a[0]、activity.a[1]
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
22
35
|
_getNestedField(path: string): Map<string, FieldStaff>;
|
|
23
36
|
_getOperateFieldMap(fieldPaths?: Array<string>): Map<string, FieldStaff>;
|
|
24
37
|
reset(fieldPaths?: Array<string>): void;
|
|
@@ -28,6 +28,8 @@ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
|
|
|
28
28
|
|
|
29
29
|
var _map2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
30
30
|
|
|
31
|
+
var _every = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/every"));
|
|
32
|
+
|
|
31
33
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/keys"));
|
|
32
34
|
|
|
33
35
|
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
|
@@ -320,10 +322,20 @@ class FormFoundation extends _foundation.default {
|
|
|
320
322
|
|
|
321
323
|
this._adapter.notifySubmitFail(_errors, _values);
|
|
322
324
|
});
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Case A:
|
|
328
|
+
* All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
|
|
329
|
+
* input => output:
|
|
330
|
+
* a => a[0]、a[1]
|
|
331
|
+
* b => b.type、b.name[0]、b.name[2]
|
|
332
|
+
*
|
|
333
|
+
* Case B:
|
|
334
|
+
* All fields: activity.a[0]、activity.a[1]、activity.c、activity.d、other
|
|
335
|
+
* input => output:
|
|
336
|
+
* activity.a => activity.a[0]、activity.a[1]
|
|
337
|
+
*
|
|
338
|
+
*/
|
|
327
339
|
|
|
328
340
|
|
|
329
341
|
_getNestedField(path) {
|
|
@@ -336,7 +348,7 @@ class FormFoundation extends _foundation.default {
|
|
|
336
348
|
let itemPath = (0, _toPath2.default)(item);
|
|
337
349
|
let targetPath = (0, _toPath2.default)(path);
|
|
338
350
|
|
|
339
|
-
if (
|
|
351
|
+
if ((0, _every.default)(targetPath).call(targetPath, (path, i) => targetPath[i] === itemPath[i])) {
|
|
340
352
|
const realField = allRegisterField.get(item);
|
|
341
353
|
nestedFieldPath.set(item, realField);
|
|
342
354
|
}
|
|
@@ -610,7 +622,11 @@ class FormFoundation extends _foundation.default {
|
|
|
610
622
|
(0, _forEach.default)(nestedFields).call(nestedFields, fieldStaff => {
|
|
611
623
|
let fieldPath = fieldStaff.field;
|
|
612
624
|
let newFieldVal = ObjectUtil.get((0, _values2.default)(this.data), fieldPath);
|
|
613
|
-
|
|
625
|
+
let nestedBatchUpdateOpts = {
|
|
626
|
+
notNotify: true,
|
|
627
|
+
notUpdate: true
|
|
628
|
+
};
|
|
629
|
+
fieldStaff.fieldApi.setValue(newFieldVal, nestedBatchUpdateOpts);
|
|
614
630
|
});
|
|
615
631
|
} // If the reset happens to be, then update the updateKey corresponding to ArrayField to render it again
|
|
616
632
|
|
|
@@ -639,7 +655,11 @@ class FormFoundation extends _foundation.default {
|
|
|
639
655
|
(0, _forEach.default)(nestedFields).call(nestedFields, fieldStaff => {
|
|
640
656
|
let fieldPath = fieldStaff.field;
|
|
641
657
|
let newFieldError = ObjectUtil.get(this.data.errors, fieldPath);
|
|
642
|
-
|
|
658
|
+
let nestedBatchUpdateOpts = {
|
|
659
|
+
notNotify: true,
|
|
660
|
+
notUpdate: true
|
|
661
|
+
};
|
|
662
|
+
fieldStaff.fieldApi.setError(newFieldError, nestedBatchUpdateOpts);
|
|
643
663
|
});
|
|
644
664
|
}
|
|
645
665
|
|
|
@@ -665,7 +685,11 @@ class FormFoundation extends _foundation.default {
|
|
|
665
685
|
(0, _forEach.default)(nestedFields).call(nestedFields, fieldStaff => {
|
|
666
686
|
let fieldPath = fieldStaff.field;
|
|
667
687
|
let newFieldTouch = ObjectUtil.get(this.data.touched, fieldPath);
|
|
668
|
-
|
|
688
|
+
let nestedBatchUpdateOpts = {
|
|
689
|
+
notNotify: true,
|
|
690
|
+
notUpdate: true
|
|
691
|
+
};
|
|
692
|
+
fieldStaff.fieldApi.setTouched(newFieldTouch, nestedBatchUpdateOpts);
|
|
669
693
|
});
|
|
670
694
|
}
|
|
671
695
|
|
package/lib/cjs/form/utils.d.ts
CHANGED
package/lib/cjs/form/utils.js
CHANGED
|
@@ -183,9 +183,10 @@ function mergeProps(props) {
|
|
|
183
183
|
helpText,
|
|
184
184
|
extraText,
|
|
185
185
|
extraTextPosition,
|
|
186
|
-
pure
|
|
186
|
+
pure,
|
|
187
|
+
id
|
|
187
188
|
} = _a,
|
|
188
|
-
rest = __rest(_a, ["field", "label", "labelPosition", "labelWidth", "labelAlign", "labelCol", "wrapperCol", "initValue", "validate", "validateStatus", "trigger", "allowEmptyString", "allowEmpty", "emptyValue", "rules", "onChange", "keepState", "transform", "name", "fieldClassName", "fieldStyle", "noLabel", "noErrorMessage", "isInInputGroup", "stopValidateWithError", "convert", "showValidateIcon", "helpText", "extraText", "extraTextPosition", "pure"]); // Form中的任何类型组件,初始值都统一通过initValue字段来传入,同时将可能会导致组件行为错误的props抽取出来,防止透传到组件中
|
|
189
|
+
rest = __rest(_a, ["field", "label", "labelPosition", "labelWidth", "labelAlign", "labelCol", "wrapperCol", "initValue", "validate", "validateStatus", "trigger", "allowEmptyString", "allowEmpty", "emptyValue", "rules", "onChange", "keepState", "transform", "name", "fieldClassName", "fieldStyle", "noLabel", "noErrorMessage", "isInInputGroup", "stopValidateWithError", "convert", "showValidateIcon", "helpText", "extraText", "extraTextPosition", "pure", "id"]); // Form中的任何类型组件,初始值都统一通过initValue字段来传入,同时将可能会导致组件行为错误的props抽取出来,防止透传到组件中
|
|
189
190
|
// For any type of field component in Form, the initial value is uniformly passed in through the initValue field.
|
|
190
191
|
// At the same time, the props that may cause component behavior errors are extracted to prevent transparent transmission to the component.
|
|
191
192
|
|
|
@@ -233,7 +234,8 @@ function mergeProps(props) {
|
|
|
233
234
|
extraText,
|
|
234
235
|
extraTextPosition,
|
|
235
236
|
pure,
|
|
236
|
-
rest
|
|
237
|
+
rest,
|
|
238
|
+
id
|
|
237
239
|
};
|
|
238
240
|
}
|
|
239
241
|
|
|
@@ -75,5 +75,13 @@ declare class InputFoundation extends BaseFoundation<InputAdapter> {
|
|
|
75
75
|
* @param {Event} e
|
|
76
76
|
*/
|
|
77
77
|
handlePreventMouseDown(e: any): void;
|
|
78
|
+
/**
|
|
79
|
+
* A11y: simulate clear button click
|
|
80
|
+
*/
|
|
81
|
+
handleClearEnterPress(e: any): void;
|
|
82
|
+
/**
|
|
83
|
+
* A11y: simulate password button click
|
|
84
|
+
*/
|
|
85
|
+
handleModeEnterPress(e: any): void;
|
|
78
86
|
}
|
|
79
87
|
export default InputFoundation;
|
|
@@ -28,7 +28,9 @@ var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
|
28
28
|
|
|
29
29
|
var _constants = require("./constants");
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
|
|
32
|
+
|
|
33
|
+
var _keyCode = require("./../utils/keyCode");
|
|
32
34
|
|
|
33
35
|
class InputFoundation extends _foundation.default {
|
|
34
36
|
constructor(adapter) {
|
|
@@ -323,7 +325,7 @@ class InputFoundation extends _foundation.default {
|
|
|
323
325
|
handleKeyPress(e) {
|
|
324
326
|
this._adapter.notifyKeyPress(e);
|
|
325
327
|
|
|
326
|
-
if (e.key ===
|
|
328
|
+
if (e.key === _keyCode.ENTER_KEY) {
|
|
327
329
|
this._adapter.notifyEnterPress(e);
|
|
328
330
|
}
|
|
329
331
|
}
|
|
@@ -372,6 +374,26 @@ class InputFoundation extends _foundation.default {
|
|
|
372
374
|
e.preventDefault();
|
|
373
375
|
}
|
|
374
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* A11y: simulate clear button click
|
|
379
|
+
*/
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
handleClearEnterPress(e) {
|
|
383
|
+
if ((0, _isEnterPress.default)(e)) {
|
|
384
|
+
this.handleClear(e);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* A11y: simulate password button click
|
|
389
|
+
*/
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
handleModeEnterPress(e) {
|
|
393
|
+
if ((0, _isEnterPress.default)(e)) {
|
|
394
|
+
this.handleClickEye(e);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
375
397
|
|
|
376
398
|
}
|
|
377
399
|
|
|
@@ -55,9 +55,13 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdpter> {
|
|
|
55
55
|
handleFocus(e: any): void;
|
|
56
56
|
handleBlur(e: any): void;
|
|
57
57
|
handleKeyDown(e: any): void;
|
|
58
|
-
resizeTextarea: (cb
|
|
58
|
+
resizeTextarea: (cb?: any) => void;
|
|
59
59
|
handleMouseEnter(e: any): void;
|
|
60
60
|
handleMouseLeave(e: any): void;
|
|
61
61
|
isAllowClear(): boolean;
|
|
62
62
|
handleClear(e: any): void;
|
|
63
|
+
/**
|
|
64
|
+
* A11y: simulate clear button click
|
|
65
|
+
*/
|
|
66
|
+
handleClearEnterPress(e: any): void;
|
|
63
67
|
}
|