@douyinfe/semi-foundation 2.2.0-beta.1 → 2.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/breadcrumb/foundation.ts +10 -1
- package/checkbox/checkboxFoundation.ts +9 -0
- package/datePicker/datePicker.scss +11 -0
- package/datePicker/foundation.ts +33 -15
- package/datePicker/inputFoundation.ts +2 -0
- package/datePicker/monthsGridFoundation.ts +10 -3
- package/datePicker/rtl.scss +15 -1
- package/datePicker/variables.scss +2 -0
- 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/datePicker.css +26 -2
- package/lib/cjs/datePicker/datePicker.scss +11 -0
- package/lib/cjs/datePicker/foundation.d.ts +6 -3
- package/lib/cjs/datePicker/foundation.js +42 -18
- package/lib/cjs/datePicker/inputFoundation.js +3 -0
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGridFoundation.js +16 -3
- package/lib/cjs/datePicker/rtl.scss +15 -1
- package/lib/cjs/datePicker/variables.scss +2 -0
- 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/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/table.css +0 -2
- package/lib/cjs/table/table.scss +0 -2
- 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 +15 -1
- package/lib/cjs/utils/uuid.js +31 -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/datePicker.css +26 -2
- package/lib/es/datePicker/datePicker.scss +11 -0
- package/lib/es/datePicker/foundation.d.ts +6 -3
- package/lib/es/datePicker/foundation.js +42 -18
- package/lib/es/datePicker/inputFoundation.js +3 -0
- package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/es/datePicker/monthsGridFoundation.js +15 -3
- package/lib/es/datePicker/rtl.scss +15 -1
- package/lib/es/datePicker/variables.scss +2 -0
- 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/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/table.css +0 -2
- package/lib/es/table/table.scss +0 -2
- 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 +15 -1
- package/lib/es/utils/uuid.js +31 -1
- package/modal/modalContentFoundation.ts +18 -0
- package/navigation/itemFoundation.ts +11 -0
- package/navigation/subNavFoundation.ts +12 -0
- 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/table.scss +0 -2
- 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 +23 -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;
|
|
@@ -140,6 +140,17 @@ $module: #{$prefix}-datepicker;
|
|
|
140
140
|
padding-bottom: $spacing-datepicker_footer-paddingBottom;
|
|
141
141
|
text-align: right;
|
|
142
142
|
background-color: $color-datepicker_footer-bg-default;
|
|
143
|
+
|
|
144
|
+
.#{$prefix}-button {
|
|
145
|
+
// cancel button
|
|
146
|
+
&:first-of-type {
|
|
147
|
+
margin-right: $spacing-datepicker_footer_cancel_button-marginRight;
|
|
148
|
+
}
|
|
149
|
+
// confirm button
|
|
150
|
+
&:nth-of-type(2) {
|
|
151
|
+
margin-right: $spacing-datepicker_footer_confirm_button-marginRight;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
// 年月选择
|
package/datePicker/foundation.ts
CHANGED
|
@@ -323,10 +323,8 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
323
323
|
* 2. set cachedSelectedValue using given dates(in needConfirm mode)
|
|
324
324
|
* - directly closePanel without click confirm will set cachedSelectedValue to state value
|
|
325
325
|
* - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
|
|
326
|
-
* @param {String} inputValue
|
|
327
|
-
* @param {Date[]} dates
|
|
328
326
|
*/
|
|
329
|
-
rangeTypeSideEffectsWhenClosePanel(inputValue: string,
|
|
327
|
+
rangeTypeSideEffectsWhenClosePanel(inputValue: string, willUpdateDates: Date[]) {
|
|
330
328
|
if (this._isRangeType()) {
|
|
331
329
|
this._adapter.setRangeInputFocus(false);
|
|
332
330
|
/**
|
|
@@ -334,11 +332,29 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
334
332
|
* when inputValue is null, picker value will back to last selected value
|
|
335
333
|
*/
|
|
336
334
|
this.handleInputBlur(inputValue);
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
335
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* clear input value when selected date is not confirmed
|
|
341
|
+
*/
|
|
342
|
+
needConfirmSideEffectsWhenClosePanel(willUpdateDates: Date[] | null | undefined) {
|
|
343
|
+
if (this._adapter.needConfirm() && !this._isRangeType()) {
|
|
344
|
+
/**
|
|
345
|
+
* if `null` input element will show `cachedSelectedValue` formatted value(format in DateInput render)
|
|
346
|
+
* if `` input element will show `` directly
|
|
347
|
+
*/
|
|
348
|
+
this._adapter.updateInputValue(null);
|
|
349
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
resetCachedSelectedValue(willUpdateDates?: Date[]) {
|
|
354
|
+
const { value, cachedSelectedValue } = this._adapter.getStates();
|
|
355
|
+
const newCachedSelectedValue = Array.isArray(willUpdateDates) ? willUpdateDates : value;
|
|
356
|
+
if (!isEqual(newCachedSelectedValue, cachedSelectedValue)) {
|
|
357
|
+
this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
|
|
342
358
|
}
|
|
343
359
|
}
|
|
344
360
|
|
|
@@ -354,13 +370,16 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
354
370
|
* @param {String} inputValue
|
|
355
371
|
* @param {Date[]} dates
|
|
356
372
|
*/
|
|
357
|
-
closePanel(e?: any, inputValue: string = null, dates
|
|
373
|
+
closePanel(e?: any, inputValue: string = null, dates?: Date[]) {
|
|
374
|
+
const { value, cachedSelectedValue } = this._adapter.getStates();
|
|
375
|
+
const willUpdateDates = isNullOrUndefined(dates) ? this._adapter.needConfirm() ? value : cachedSelectedValue : dates;
|
|
358
376
|
if (!this._isControlledComponent('open')) {
|
|
359
377
|
this._adapter.togglePanel(false);
|
|
360
378
|
this._adapter.unregisterClickOutSide();
|
|
361
379
|
}
|
|
362
380
|
// range type picker, closing panel requires the following side effects
|
|
363
|
-
this.rangeTypeSideEffectsWhenClosePanel(inputValue,
|
|
381
|
+
this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates as Date[]);
|
|
382
|
+
this.needConfirmSideEffectsWhenClosePanel(willUpdateDates as Date[]);
|
|
364
383
|
this._adapter.notifyOpenChange(false);
|
|
365
384
|
this._adapter.notifyBlur(e);
|
|
366
385
|
}
|
|
@@ -416,7 +435,8 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
416
435
|
if (parsedResult && parsedResult.length) {
|
|
417
436
|
this._updateValueAndInput(parsedResult, input === '');
|
|
418
437
|
} else if (input === '') {
|
|
419
|
-
|
|
438
|
+
// if clear input, set input to `''`
|
|
439
|
+
this._updateValueAndInput('' as any, true, '');
|
|
420
440
|
} else {
|
|
421
441
|
this._updateValueAndInput(stateValue);
|
|
422
442
|
}
|
|
@@ -725,7 +745,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
725
745
|
let inputValue;
|
|
726
746
|
if (!this._someDateDisabled(changedDates)) {
|
|
727
747
|
inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
|
|
728
|
-
const isRangeTypeAndInputIncomplete = this._isRangeType() && (
|
|
748
|
+
const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
|
|
729
749
|
/**
|
|
730
750
|
* If the input is incomplete when under control, the notifyChange is not triggered because
|
|
731
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
|
|
@@ -1004,11 +1024,9 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
1004
1024
|
};
|
|
1005
1025
|
|
|
1006
1026
|
_isRangeValueComplete = (value: Date[] | Date) => {
|
|
1007
|
-
let result =
|
|
1027
|
+
let result = false;
|
|
1008
1028
|
if (Array.isArray(value)) {
|
|
1009
1029
|
result = !value.some(date => isNullOrUndefined(date));
|
|
1010
|
-
} else {
|
|
1011
|
-
result = false;
|
|
1012
1030
|
}
|
|
1013
1031
|
return result;
|
|
1014
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/datePicker/rtl.scss
CHANGED
|
@@ -9,6 +9,18 @@ $module: #{$prefix}-datepicker;
|
|
|
9
9
|
padding-right: 0;
|
|
10
10
|
padding-left: $spacing-datepicker_footer-paddingRight;
|
|
11
11
|
text-align: left;
|
|
12
|
+
|
|
13
|
+
.#{$prefix}-button {
|
|
14
|
+
&:first-of-type {
|
|
15
|
+
margin-left: 0;
|
|
16
|
+
margin-right: 0;
|
|
17
|
+
}
|
|
18
|
+
// confirm button
|
|
19
|
+
&:nth-of-type(2) {
|
|
20
|
+
margin-right: $spacing-datepicker_footer_cancel_button-marginRight;
|
|
21
|
+
margin-left: 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
12
24
|
}
|
|
13
25
|
|
|
14
26
|
&-day {
|
|
@@ -66,7 +78,9 @@ $module: #{$prefix}-datepicker;
|
|
|
66
78
|
&-yam {
|
|
67
79
|
// rtl 对箭头进行翻转
|
|
68
80
|
.#{$prefix}-icon-chevron_left,
|
|
69
|
-
.#{$prefix}-icon-chevron_right
|
|
81
|
+
.#{$prefix}-icon-chevron_right,
|
|
82
|
+
.#{$prefix}-icon-double_chevron_left,
|
|
83
|
+
.#{$prefix}-icon-double_chevron_right {
|
|
70
84
|
transform: scaleX(-1);
|
|
71
85
|
}
|
|
72
86
|
}
|
|
@@ -33,6 +33,8 @@ $spacing-datepicker_scrolllist_body-padding: 0; // 时间选择滚动菜单内
|
|
|
33
33
|
$spacing-datepicker_footer-paddingTop: 10px; // 确认选择 footer 顶部内边距
|
|
34
34
|
$spacing-datepicker_footer-paddingBottom: 10px; // 确认选择 footer 底部内边距
|
|
35
35
|
$spacing-datepicker_footer-paddingRight: 8px; // 确认选择 footer 右侧内边距
|
|
36
|
+
$spacing-datepicker_footer_cancel_button-marginRight: 12px; // 确认选择 footer 取消按钮右外边距
|
|
37
|
+
$spacing-datepicker_footer_confirm_button-marginRight: 8px; // 确认选择 footer 确认按钮右外边距
|
|
36
38
|
$spacing-datepicker_navigation-paddingY: $spacing-base-tight; // 年月切换 header 垂直内边距
|
|
37
39
|
$spacing-datepicker_navigation-paddingX: $spacing-base; // 年月切换 header 水平内边距
|
|
38
40
|
$spacing-datepicker_month-padding: $spacing-base;
|
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
|
|
@@ -98,6 +98,12 @@
|
|
|
98
98
|
text-align: right;
|
|
99
99
|
background-color: var(--semi-color-fill-0);
|
|
100
100
|
}
|
|
101
|
+
.semi-datepicker-footer .semi-button:first-of-type {
|
|
102
|
+
margin-right: 12px;
|
|
103
|
+
}
|
|
104
|
+
.semi-datepicker-footer .semi-button:nth-of-type(2) {
|
|
105
|
+
margin-right: 8px;
|
|
106
|
+
}
|
|
101
107
|
.semi-datepicker-yam {
|
|
102
108
|
position: absolute;
|
|
103
109
|
top: 0;
|
|
@@ -705,6 +711,16 @@
|
|
|
705
711
|
padding-left: 8px;
|
|
706
712
|
text-align: left;
|
|
707
713
|
}
|
|
714
|
+
.semi-rtl .semi-datepicker-footer .semi-button:first-of-type,
|
|
715
|
+
.semi-portal-rtl .semi-datepicker-footer .semi-button:first-of-type {
|
|
716
|
+
margin-left: 0;
|
|
717
|
+
margin-right: 0;
|
|
718
|
+
}
|
|
719
|
+
.semi-rtl .semi-datepicker-footer .semi-button:nth-of-type(2),
|
|
720
|
+
.semi-portal-rtl .semi-datepicker-footer .semi-button:nth-of-type(2) {
|
|
721
|
+
margin-right: 12px;
|
|
722
|
+
margin-left: 0;
|
|
723
|
+
}
|
|
708
724
|
.semi-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main,
|
|
709
725
|
.semi-portal-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main {
|
|
710
726
|
border-radius: 0 var(--semi-border-radius-small) var(--semi-border-radius-small) 0;
|
|
@@ -740,12 +756,20 @@
|
|
|
740
756
|
margin-right: 8px;
|
|
741
757
|
}
|
|
742
758
|
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
|
|
743
|
-
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
759
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
760
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-double_chevron_left,
|
|
761
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-double_chevron_right, .semi-rtl .semi-datepicker-yam .semi-icon-chevron_left,
|
|
744
762
|
.semi-rtl .semi-datepicker-yam .semi-icon-chevron_right,
|
|
763
|
+
.semi-rtl .semi-datepicker-yam .semi-icon-double_chevron_left,
|
|
764
|
+
.semi-rtl .semi-datepicker-yam .semi-icon-double_chevron_right,
|
|
745
765
|
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
|
|
746
766
|
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
767
|
+
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-double_chevron_left,
|
|
768
|
+
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-double_chevron_right,
|
|
747
769
|
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_left,
|
|
748
|
-
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_right
|
|
770
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_right,
|
|
771
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-double_chevron_left,
|
|
772
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-double_chevron_right {
|
|
749
773
|
transform: scaleX(-1);
|
|
750
774
|
}
|
|
751
775
|
.semi-rtl .semi-datepicker-range-input-prefix,
|
|
@@ -140,6 +140,17 @@ $module: #{$prefix}-datepicker;
|
|
|
140
140
|
padding-bottom: $spacing-datepicker_footer-paddingBottom;
|
|
141
141
|
text-align: right;
|
|
142
142
|
background-color: $color-datepicker_footer-bg-default;
|
|
143
|
+
|
|
144
|
+
.#{$prefix}-button {
|
|
145
|
+
// cancel button
|
|
146
|
+
&:first-of-type {
|
|
147
|
+
margin-right: $spacing-datepicker_footer_cancel_button-marginRight;
|
|
148
|
+
}
|
|
149
|
+
// confirm button
|
|
150
|
+
&:nth-of-type(2) {
|
|
151
|
+
margin-right: $spacing-datepicker_footer_confirm_button-marginRight;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
// 年月选择
|
|
@@ -201,10 +201,13 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
201
201
|
* 2. set cachedSelectedValue using given dates(in needConfirm mode)
|
|
202
202
|
* - directly closePanel without click confirm will set cachedSelectedValue to state value
|
|
203
203
|
* - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
|
|
204
|
-
* @param {String} inputValue
|
|
205
|
-
* @param {Date[]} dates
|
|
206
204
|
*/
|
|
207
|
-
rangeTypeSideEffectsWhenClosePanel(inputValue: string,
|
|
205
|
+
rangeTypeSideEffectsWhenClosePanel(inputValue: string, willUpdateDates: Date[]): void;
|
|
206
|
+
/**
|
|
207
|
+
* clear input value when selected date is not confirmed
|
|
208
|
+
*/
|
|
209
|
+
needConfirmSideEffectsWhenClosePanel(willUpdateDates: Date[] | null | undefined): void;
|
|
210
|
+
resetCachedSelectedValue(willUpdateDates?: Date[]): void;
|
|
208
211
|
/**
|
|
209
212
|
* timing to call closePanel
|
|
210
213
|
* 1. click confirm button
|