@douyinfe/semi-foundation 2.19.0-beta.0 → 2.19.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/anchor/anchor.scss +1 -8
- package/anchor/rtl.scss +0 -1
- package/anchor/variables.scss +1 -0
- package/calendar/eventUtil.ts +8 -7
- package/calendar/foundation.ts +14 -14
- package/datePicker/monthsGridFoundation.ts +10 -3
- package/dropdown/foundation.ts +2 -1
- package/dropdown/menuFoundation.ts +2 -1
- package/getBabelConfig.js +0 -12
- package/lib/cjs/anchor/anchor.css +1 -10
- package/lib/cjs/anchor/anchor.scss +1 -8
- package/lib/cjs/anchor/constants.js +1 -4
- package/lib/cjs/anchor/foundation.js +5 -12
- package/lib/cjs/anchor/linkFoundation.js +4 -9
- package/lib/cjs/anchor/rtl.scss +0 -1
- package/lib/cjs/anchor/variables.scss +1 -0
- package/lib/cjs/autoComplete/constants.js +1 -4
- package/lib/cjs/autoComplete/foundation.js +14 -33
- package/lib/cjs/autoComplete/optionFoundation.js +4 -9
- package/lib/cjs/avatar/constants.js +1 -4
- package/lib/cjs/avatar/foundation.js +4 -9
- package/lib/cjs/backtop/constants.js +1 -4
- package/lib/cjs/backtop/foundation.js +4 -9
- package/lib/cjs/badge/constants.js +1 -4
- package/lib/cjs/banner/constants.js +1 -4
- package/lib/cjs/banner/foundation.js +4 -9
- package/lib/cjs/base/constants.js +2 -6
- package/lib/cjs/base/env.js +1 -4
- package/lib/cjs/base/foundation.js +5 -10
- package/lib/cjs/base/index.js +3 -6
- package/lib/cjs/breadcrumb/constants.js +1 -4
- package/lib/cjs/breadcrumb/foundation.js +6 -13
- package/lib/cjs/breadcrumb/itemFoundation.js +4 -9
- package/lib/cjs/button/constants.js +1 -4
- package/lib/cjs/calendar/constants.js +1 -4
- package/lib/cjs/calendar/eventUtil.d.ts +3 -3
- package/lib/cjs/calendar/eventUtil.js +28 -53
- package/lib/cjs/calendar/foundation.js +63 -85
- package/lib/cjs/card/constants.js +1 -4
- package/lib/cjs/carousel/constants.js +1 -4
- package/lib/cjs/carousel/foundation.js +5 -12
- package/lib/cjs/cascader/constants.js +1 -4
- package/lib/cjs/cascader/foundation.js +55 -100
- package/lib/cjs/cascader/util.js +9 -30
- package/lib/cjs/checkbox/checkboxFoundation.js +6 -13
- package/lib/cjs/checkbox/checkboxGroupFoundation.js +9 -18
- package/lib/cjs/checkbox/constants.js +1 -4
- package/lib/cjs/collapse/constants.js +1 -4
- package/lib/cjs/collapse/foundation.js +9 -20
- package/lib/cjs/collapsible/constants.js +1 -4
- package/lib/cjs/datePicker/_utils/formatter.js +3 -12
- package/lib/cjs/datePicker/_utils/getDayOfWeek.js +1 -4
- package/lib/cjs/datePicker/_utils/getDefaultFormatToken.js +1 -4
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.js +5 -10
- package/lib/cjs/datePicker/_utils/getFullDateOffset.js +3 -6
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +2 -11
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +1 -4
- package/lib/cjs/datePicker/_utils/getMonthTable.js +2 -11
- package/lib/cjs/datePicker/_utils/getMonthsInYear.js +3 -16
- package/lib/cjs/datePicker/_utils/getYears.js +2 -9
- package/lib/cjs/datePicker/_utils/index.js +16 -30
- package/lib/cjs/datePicker/_utils/isAfter.js +3 -6
- package/lib/cjs/datePicker/_utils/isBefore.js +3 -6
- package/lib/cjs/datePicker/_utils/isBetween.js +3 -6
- package/lib/cjs/datePicker/_utils/isDate.js +1 -4
- package/lib/cjs/datePicker/_utils/isSameDay.js +3 -6
- package/lib/cjs/datePicker/_utils/isTimestamp.js +3 -6
- package/lib/cjs/datePicker/_utils/isUnixTimestamp.js +3 -6
- package/lib/cjs/datePicker/_utils/isValidDate.js +1 -4
- package/lib/cjs/datePicker/_utils/isWithinInterval.js +3 -6
- package/lib/cjs/datePicker/_utils/parser.js +1 -4
- package/lib/cjs/datePicker/constants.js +3 -10
- package/lib/cjs/datePicker/foundation.js +42 -85
- package/lib/cjs/datePicker/inputFoundation.js +7 -20
- package/lib/cjs/datePicker/monthFoundation.js +5 -12
- package/lib/cjs/datePicker/monthsGridFoundation.js +47 -68
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +4 -9
- package/lib/cjs/descriptions/constants.js +1 -4
- package/lib/cjs/divider/constants.js +1 -4
- package/lib/cjs/dropdown/constants.js +1 -4
- package/lib/cjs/dropdown/foundation.js +7 -15
- package/lib/cjs/dropdown/menuFoundation.js +11 -31
- package/lib/cjs/empty/constants.js +1 -4
- package/lib/cjs/form/constants.js +1 -4
- package/lib/cjs/form/foundation.js +64 -104
- package/lib/cjs/form/interface.js +1 -3
- package/lib/cjs/form/utils.js +14 -29
- package/lib/cjs/grid/constants.js +1 -4
- package/lib/cjs/icons/constants.js +1 -4
- package/lib/cjs/input/constants.js +1 -4
- package/lib/cjs/input/foundation.js +7 -18
- package/lib/cjs/input/textareaFoundation.js +6 -13
- package/lib/cjs/input/util/calculateNodeHeight.js +3 -17
- package/lib/cjs/input/util/getSizingData.js +5 -10
- package/lib/cjs/inputNumber/constants.js +4 -11
- package/lib/cjs/inputNumber/foundation.js +11 -30
- package/lib/cjs/layout/constants.js +1 -4
- package/lib/cjs/list/constants.js +1 -4
- package/lib/cjs/modal/constants.js +1 -4
- package/lib/cjs/modal/modalContentFoundation.js +4 -9
- package/lib/cjs/modal/modalFoundation.js +4 -9
- package/lib/cjs/navigation/NavItem.js +6 -21
- package/lib/cjs/navigation/constants.js +1 -4
- package/lib/cjs/navigation/foundation.js +22 -37
- package/lib/cjs/navigation/itemFoundation.js +4 -9
- package/lib/cjs/navigation/subNavFoundation.js +10 -21
- package/lib/cjs/notification/constants.js +1 -4
- package/lib/cjs/notification/notificationFoundation.js +5 -12
- package/lib/cjs/notification/notificationListFoundation.js +4 -9
- package/lib/cjs/overflowList/constants.js +3 -10
- package/lib/cjs/overflowList/foundation.js +12 -29
- package/lib/cjs/pagination/constants.js +1 -4
- package/lib/cjs/pagination/foundation.js +18 -37
- package/lib/cjs/popconfirm/constants.js +1 -4
- package/lib/cjs/popconfirm/popconfirmFoundation.js +3 -6
- package/lib/cjs/popover/constants.js +2 -9
- package/lib/cjs/progress/constants.js +1 -4
- package/lib/cjs/radio/constants.js +1 -4
- package/lib/cjs/radio/radioFoundation.js +3 -6
- package/lib/cjs/radio/radioGroupFoundation.js +6 -11
- package/lib/cjs/radio/radioInnerFoundation.js +5 -10
- package/lib/cjs/rating/constants.js +1 -4
- package/lib/cjs/rating/foundation.js +7 -20
- package/lib/cjs/scrollList/constants.js +1 -4
- package/lib/cjs/scrollList/foundation.js +3 -6
- package/lib/cjs/scrollList/itemFoundation.js +8 -21
- package/lib/cjs/scrollList/scrollTo.js +1 -4
- package/lib/cjs/select/constants.js +1 -4
- package/lib/cjs/select/foundation.js +56 -98
- package/lib/cjs/select/optionFoundation.js +4 -9
- package/lib/cjs/sideSheet/constants.js +1 -4
- package/lib/cjs/sideSheet/sideSheetFoundation.js +6 -15
- package/lib/cjs/skeleton/constants.js +1 -4
- package/lib/cjs/slider/constants.js +1 -4
- package/lib/cjs/slider/foundation.js +13 -24
- package/lib/cjs/space/constants.js +1 -4
- package/lib/cjs/spin/constants.js +1 -4
- package/lib/cjs/spin/foundation.js +5 -12
- package/lib/cjs/steps/constants.js +1 -4
- package/lib/cjs/switch/constants.js +1 -4
- package/lib/cjs/switch/foundation.js +4 -9
- package/lib/cjs/table/bodyFoundation.js +9 -22
- package/lib/cjs/table/cellFoundation.js +3 -6
- package/lib/cjs/table/constants.js +1 -4
- package/lib/cjs/table/foundation.js +76 -117
- package/lib/cjs/table/tableRowFoundation.js +3 -6
- package/lib/cjs/table/tableSelectionCellFoundation.js +3 -6
- package/lib/cjs/table/utils.js +42 -71
- package/lib/cjs/tabs/constants.js +1 -4
- package/lib/cjs/tabs/foundation.js +8 -23
- package/lib/cjs/tag/constants.js +1 -4
- package/lib/cjs/tagInput/constants.js +1 -4
- package/lib/cjs/tagInput/foundation.js +12 -31
- package/lib/cjs/tagInput/utils/getSplitedArray.js +3 -6
- package/lib/cjs/timePicker/ComboxFoundation.js +10 -29
- package/lib/cjs/timePicker/constants.js +1 -4
- package/lib/cjs/timePicker/foundation.js +26 -45
- package/lib/cjs/timePicker/inputFoundation.js +4 -9
- package/lib/cjs/timePicker/utils/index.js +7 -14
- package/lib/cjs/timePicker/utils/localeDate.js +2 -9
- package/lib/cjs/timeline/constants.js +1 -4
- package/lib/cjs/toast/constants.js +1 -4
- package/lib/cjs/toast/toastFoundation.js +5 -12
- package/lib/cjs/toast/toastListFoundation.js +5 -12
- package/lib/cjs/tooltip/constants.js +1 -4
- package/lib/cjs/tooltip/foundation.js +29 -56
- package/lib/cjs/transfer/constants.js +1 -4
- package/lib/cjs/transfer/foundation.js +24 -47
- package/lib/cjs/transfer/transferUtils.js +16 -45
- package/lib/cjs/tree/constants.js +1 -4
- package/lib/cjs/tree/foundation.js +41 -76
- package/lib/cjs/tree/treeUtil.js +60 -107
- package/lib/cjs/treeSelect/constants.js +1 -4
- package/lib/cjs/treeSelect/foundation.js +49 -82
- package/lib/cjs/typography/constants.js +1 -4
- package/lib/cjs/upload/constants.js +1 -4
- package/lib/cjs/upload/foundation.js +56 -112
- package/lib/cjs/upload/utils.js +13 -32
- package/lib/cjs/utils/Event.js +9 -23
- package/lib/cjs/utils/FocusHandle.js +6 -15
- package/lib/cjs/utils/Logger.js +1 -4
- package/lib/cjs/utils/Store.js +5 -20
- package/lib/cjs/utils/a11y.js +8 -13
- package/lib/cjs/utils/array.js +6 -15
- package/lib/cjs/utils/arrayMove.js +3 -12
- package/lib/cjs/utils/classnames.js +6 -15
- package/lib/cjs/utils/date-fns-extra.js +7 -18
- package/lib/cjs/utils/dom.js +5 -12
- package/lib/cjs/utils/function.js +1 -4
- package/lib/cjs/utils/getDataAttr.js +2 -13
- package/lib/cjs/utils/getHighlight.js +7 -22
- package/lib/cjs/utils/getMotionObjFromProps.js +4 -9
- package/lib/cjs/utils/index.js +5 -15
- package/lib/cjs/utils/isBothNaN.js +1 -4
- package/lib/cjs/utils/isElement.js +1 -4
- package/lib/cjs/utils/isEnterPress.js +3 -6
- package/lib/cjs/utils/isEscPress.js +3 -6
- package/lib/cjs/utils/isNullOrUndefined.js +1 -4
- package/lib/cjs/utils/isNumber.js +1 -4
- package/lib/cjs/utils/isObject.js +1 -4
- package/lib/cjs/utils/isPromise.js +3 -6
- package/lib/cjs/utils/isString.js +1 -4
- package/lib/cjs/utils/keyCode.js +1 -4
- package/lib/cjs/utils/log.js +3 -6
- package/lib/cjs/utils/number.js +1 -4
- package/lib/cjs/utils/object.js +10 -27
- package/lib/cjs/utils/set.js +4 -9
- package/lib/cjs/utils/shallowEqualObjects.js +3 -10
- package/lib/cjs/utils/touchPolyfill.js +5 -12
- package/lib/cjs/utils/type.js +1 -3
- package/lib/cjs/utils/uuid.js +3 -14
- package/lib/cjs/utils/warning.js +1 -4
- package/lib/es/anchor/anchor.css +1 -10
- package/lib/es/anchor/anchor.scss +1 -8
- package/lib/es/anchor/foundation.js +2 -4
- package/lib/es/anchor/linkFoundation.js +1 -2
- package/lib/es/anchor/rtl.scss +0 -1
- package/lib/es/anchor/variables.scss +1 -0
- package/lib/es/autoComplete/foundation.js +11 -26
- package/lib/es/autoComplete/optionFoundation.js +1 -2
- package/lib/es/avatar/foundation.js +1 -2
- package/lib/es/backtop/foundation.js +1 -2
- package/lib/es/banner/foundation.js +1 -2
- package/lib/es/base/foundation.js +2 -3
- package/lib/es/breadcrumb/foundation.js +3 -6
- package/lib/es/breadcrumb/itemFoundation.js +1 -2
- package/lib/es/calendar/eventUtil.d.ts +3 -3
- package/lib/es/calendar/eventUtil.js +27 -56
- package/lib/es/calendar/foundation.js +60 -90
- package/lib/es/carousel/foundation.js +2 -4
- package/lib/es/cascader/foundation.js +49 -94
- package/lib/es/cascader/util.js +6 -21
- package/lib/es/checkbox/checkboxFoundation.js +3 -6
- package/lib/es/checkbox/checkboxGroupFoundation.js +6 -9
- package/lib/es/collapse/foundation.js +6 -10
- package/lib/es/datePicker/_utils/formatter.js +2 -5
- package/lib/es/datePicker/_utils/getDefaultPickerDate.js +2 -3
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +1 -4
- package/lib/es/datePicker/_utils/getMonthTable.js +1 -5
- package/lib/es/datePicker/_utils/getMonthsInYear.js +2 -9
- package/lib/es/datePicker/_utils/getYears.js +1 -3
- package/lib/es/datePicker/constants.js +2 -7
- package/lib/es/datePicker/foundation.js +39 -70
- package/lib/es/datePicker/inputFoundation.js +4 -11
- package/lib/es/datePicker/monthFoundation.js +2 -4
- package/lib/es/datePicker/monthsGridFoundation.js +40 -55
- package/lib/es/datePicker/yearAndMonthFoundation.js +1 -2
- package/lib/es/dropdown/foundation.js +4 -7
- package/lib/es/dropdown/menuFoundation.js +8 -21
- package/lib/es/form/foundation.js +59 -91
- package/lib/es/form/utils.js +11 -19
- package/lib/es/input/foundation.js +4 -9
- package/lib/es/input/textareaFoundation.js +3 -5
- package/lib/es/input/util/calculateNodeHeight.js +2 -10
- package/lib/es/input/util/getSizingData.js +2 -5
- package/lib/es/inputNumber/constants.js +3 -8
- package/lib/es/inputNumber/foundation.js +8 -18
- package/lib/es/modal/modalContentFoundation.js +1 -2
- package/lib/es/modal/modalFoundation.js +1 -2
- package/lib/es/navigation/NavItem.js +5 -11
- package/lib/es/navigation/foundation.js +19 -25
- package/lib/es/navigation/itemFoundation.js +1 -3
- package/lib/es/navigation/subNavFoundation.js +7 -13
- package/lib/es/notification/notificationFoundation.js +2 -4
- package/lib/es/notification/notificationListFoundation.js +1 -3
- package/lib/es/overflowList/constants.js +2 -3
- package/lib/es/overflowList/foundation.js +9 -23
- package/lib/es/pagination/foundation.js +15 -28
- package/lib/es/popover/constants.js +1 -2
- package/lib/es/radio/radioGroupFoundation.js +3 -4
- package/lib/es/radio/radioInnerFoundation.js +2 -3
- package/lib/es/rating/foundation.js +4 -13
- package/lib/es/scrollList/itemFoundation.js +5 -13
- package/lib/es/select/foundation.js +50 -88
- package/lib/es/select/optionFoundation.js +1 -2
- package/lib/es/sideSheet/sideSheetFoundation.js +3 -7
- package/lib/es/slider/foundation.js +10 -16
- package/lib/es/spin/foundation.js +2 -4
- package/lib/es/switch/foundation.js +1 -2
- package/lib/es/table/bodyFoundation.js +6 -11
- package/lib/es/table/foundation.js +67 -93
- package/lib/es/table/utils.js +33 -51
- package/lib/es/tabs/foundation.js +5 -18
- package/lib/es/tagInput/foundation.js +9 -21
- package/lib/es/timePicker/ComboxFoundation.js +7 -16
- package/lib/es/timePicker/foundation.js +23 -37
- package/lib/es/timePicker/inputFoundation.js +1 -2
- package/lib/es/timePicker/utils/index.js +4 -6
- package/lib/es/timePicker/utils/localeDate.js +1 -2
- package/lib/es/toast/toastFoundation.js +2 -4
- package/lib/es/toast/toastListFoundation.js +2 -4
- package/lib/es/tooltip/foundation.js +26 -46
- package/lib/es/transfer/foundation.js +21 -43
- package/lib/es/transfer/transferUtils.js +13 -33
- package/lib/es/tree/foundation.js +38 -70
- package/lib/es/tree/treeUtil.js +57 -109
- package/lib/es/treeSelect/foundation.js +45 -73
- package/lib/es/upload/foundation.js +52 -118
- package/lib/es/upload/utils.js +12 -25
- package/lib/es/utils/Event.js +5 -12
- package/lib/es/utils/FocusHandle.js +3 -7
- package/lib/es/utils/Store.js +4 -12
- package/lib/es/utils/a11y.js +5 -6
- package/lib/es/utils/array.js +3 -5
- package/lib/es/utils/arrayMove.js +2 -6
- package/lib/es/utils/classnames.js +3 -6
- package/lib/es/utils/date-fns-extra.js +6 -14
- package/lib/es/utils/dom.js +1 -2
- package/lib/es/utils/getDataAttr.js +1 -5
- package/lib/es/utils/getHighlight.js +4 -14
- package/lib/es/utils/getMotionObjFromProps.js +1 -2
- package/lib/es/utils/object.js +7 -15
- package/lib/es/utils/set.js +1 -2
- package/lib/es/utils/shallowEqualObjects.js +2 -5
- package/lib/es/utils/touchPolyfill.js +2 -6
- package/lib/es/utils/uuid.js +2 -7
- package/package.json +2 -4
- package/select/foundation.ts +2 -2
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import _toPath from "lodash/toPath";
|
|
2
2
|
import _isFunction from "lodash/isFunction";
|
|
3
3
|
import _isUndefined from "lodash/isUndefined";
|
|
4
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
5
|
-
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
6
|
-
import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
|
|
7
|
-
import _valuesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/values";
|
|
8
|
-
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
9
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
10
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
11
|
-
import _everyInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/every";
|
|
12
|
-
import _keysInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/keys";
|
|
13
|
-
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
14
4
|
|
|
15
5
|
/* eslint-disable prefer-const, max-len */
|
|
16
6
|
import BaseFoundation from '../base/foundation';
|
|
@@ -20,9 +10,7 @@ import { isValid } from './utils';
|
|
|
20
10
|
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
21
11
|
export default class FormFoundation extends BaseFoundation {
|
|
22
12
|
constructor(adapter) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
super(_Object$assign({}, adapter));
|
|
13
|
+
super(Object.assign({}, adapter));
|
|
26
14
|
/*
|
|
27
15
|
Also need to read initValue here, because the Form level can set the initial value,
|
|
28
16
|
and the Field level can also set the initial value.
|
|
@@ -47,31 +35,31 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
47
35
|
// key: fieldName
|
|
48
36
|
// value: { field, fieldApi, keepState, initValue}
|
|
49
37
|
|
|
50
|
-
this.fields = new
|
|
38
|
+
this.fields = new Map(); // Record all registered fields
|
|
51
39
|
|
|
52
40
|
this.registered = {}; // Record all registered ArrayField
|
|
53
41
|
|
|
54
|
-
this.registeredArrayField = new
|
|
55
|
-
this.register =
|
|
56
|
-
this.unRegister =
|
|
57
|
-
this.registerArrayField =
|
|
58
|
-
this.unRegisterArrayField =
|
|
59
|
-
this.getArrayField =
|
|
60
|
-
this.updateArrayField =
|
|
61
|
-
this.getField =
|
|
62
|
-
this.setValues =
|
|
63
|
-
this.updateStateValue =
|
|
64
|
-
this.updateStateError =
|
|
65
|
-
this.updateStateTouched =
|
|
66
|
-
this.getFormState =
|
|
67
|
-
this.getValue =
|
|
68
|
-
this.getError =
|
|
69
|
-
this.getTouched =
|
|
70
|
-
this.getInitValues =
|
|
71
|
-
this.getInitValue =
|
|
72
|
-
this.getFormProps =
|
|
73
|
-
this.getFieldExist =
|
|
74
|
-
this.scrollToField =
|
|
42
|
+
this.registeredArrayField = new Map();
|
|
43
|
+
this.register = this.register.bind(this);
|
|
44
|
+
this.unRegister = this.unRegister.bind(this);
|
|
45
|
+
this.registerArrayField = this.registerArrayField.bind(this);
|
|
46
|
+
this.unRegisterArrayField = this.unRegisterArrayField.bind(this);
|
|
47
|
+
this.getArrayField = this.getArrayField.bind(this);
|
|
48
|
+
this.updateArrayField = this.updateArrayField.bind(this);
|
|
49
|
+
this.getField = this.getField.bind(this);
|
|
50
|
+
this.setValues = this.setValues.bind(this);
|
|
51
|
+
this.updateStateValue = this.updateStateValue.bind(this);
|
|
52
|
+
this.updateStateError = this.updateStateError.bind(this);
|
|
53
|
+
this.updateStateTouched = this.updateStateTouched.bind(this);
|
|
54
|
+
this.getFormState = this.getFormState.bind(this);
|
|
55
|
+
this.getValue = this.getValue.bind(this);
|
|
56
|
+
this.getError = this.getError.bind(this);
|
|
57
|
+
this.getTouched = this.getTouched.bind(this);
|
|
58
|
+
this.getInitValues = this.getInitValues.bind(this);
|
|
59
|
+
this.getInitValue = this.getInitValue.bind(this);
|
|
60
|
+
this.getFormProps = this.getFormProps.bind(this);
|
|
61
|
+
this.getFieldExist = this.getFieldExist.bind(this);
|
|
62
|
+
this.scrollToField = this.scrollToField.bind(this);
|
|
75
63
|
}
|
|
76
64
|
|
|
77
65
|
init() {
|
|
@@ -117,7 +105,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
117
105
|
|
|
118
106
|
try {
|
|
119
107
|
if (!targetField.keepState) {
|
|
120
|
-
ObjectUtil.remove(
|
|
108
|
+
ObjectUtil.remove(this.data.values, field);
|
|
121
109
|
ObjectUtil.remove(this.data.errors, field);
|
|
122
110
|
ObjectUtil.remove(this.data.touched, field);
|
|
123
111
|
}
|
|
@@ -150,8 +138,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
150
138
|
}
|
|
151
139
|
|
|
152
140
|
updateArrayField(arrayField, updateValue) {
|
|
153
|
-
const mergeVal =
|
|
154
|
-
|
|
141
|
+
const mergeVal = Object.assign(Object.assign({}, this.registeredArrayField.get(arrayField)), updateValue);
|
|
155
142
|
this.registeredArrayField.set(arrayField, mergeVal);
|
|
156
143
|
}
|
|
157
144
|
|
|
@@ -175,7 +162,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
175
162
|
const {
|
|
176
163
|
validateFields
|
|
177
164
|
} = this.getProps();
|
|
178
|
-
return new
|
|
165
|
+
return new Promise((resolve, reject) => {
|
|
179
166
|
let maybePromisedErrors;
|
|
180
167
|
|
|
181
168
|
try {
|
|
@@ -236,12 +223,12 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
236
223
|
values
|
|
237
224
|
} = this.data; // When there is no custom validation function at Form level, perform validation of each Field
|
|
238
225
|
|
|
239
|
-
return new
|
|
226
|
+
return new Promise((resolve, reject) => {
|
|
240
227
|
let promiseSet = [];
|
|
241
228
|
|
|
242
229
|
const targetFields = this._getOperateFieldMap(fieldPaths);
|
|
243
230
|
|
|
244
|
-
|
|
231
|
+
targetFields.forEach((field, fieldPath) => {
|
|
245
232
|
// Call each fieldApi for verification
|
|
246
233
|
const fieldValue = this.getValue(fieldPath); // When centralized verification, no need to trigger forceUpdate and notify
|
|
247
234
|
|
|
@@ -253,8 +240,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
253
240
|
promiseSet.push(validateResult);
|
|
254
241
|
field.fieldApi.setTouched(true, opts);
|
|
255
242
|
});
|
|
256
|
-
|
|
257
|
-
_Promise.all(promiseSet).then(() => {
|
|
243
|
+
Promise.all(promiseSet).then(() => {
|
|
258
244
|
// After the centralized verification is completed, trigger notify and forceUpdate once.
|
|
259
245
|
this._adapter.notifyChange(this.data);
|
|
260
246
|
|
|
@@ -307,41 +293,35 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
307
293
|
|
|
308
294
|
|
|
309
295
|
_getNestedField(path) {
|
|
310
|
-
var _context21;
|
|
311
|
-
|
|
312
296
|
const allRegisterField = this.fields;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
let nestedFieldPath = new _Map();
|
|
317
|
-
|
|
318
|
-
_forEachInstanceProperty(allFieldPath).call(allFieldPath, item => {
|
|
297
|
+
const allFieldPath = [...allRegisterField].map(item => item[0]);
|
|
298
|
+
let nestedFieldPath = new Map();
|
|
299
|
+
allFieldPath.forEach(item => {
|
|
319
300
|
let itemPath = _toPath(item);
|
|
320
301
|
|
|
321
302
|
let targetPath = _toPath(path);
|
|
322
303
|
|
|
323
|
-
if (
|
|
304
|
+
if (targetPath.every((path, i) => targetPath[i] === itemPath[i])) {
|
|
324
305
|
const realField = allRegisterField.get(item);
|
|
325
306
|
nestedFieldPath.set(item, realField);
|
|
326
307
|
}
|
|
327
308
|
});
|
|
328
|
-
|
|
329
309
|
return nestedFieldPath;
|
|
330
310
|
} // get all operate fields, called by validate() / reset()
|
|
331
311
|
|
|
332
312
|
|
|
333
313
|
_getOperateFieldMap(fieldPaths) {
|
|
334
|
-
let targetFields = new
|
|
314
|
+
let targetFields = new Map();
|
|
335
315
|
|
|
336
316
|
if (!_isUndefined(fieldPaths)) {
|
|
337
317
|
// reset or validate specific fields
|
|
338
|
-
|
|
318
|
+
fieldPaths.forEach(path => {
|
|
339
319
|
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'])
|
|
340
320
|
|
|
341
321
|
if (_isUndefined(field)) {
|
|
342
322
|
const nestedFields = this._getNestedField(path);
|
|
343
323
|
|
|
344
|
-
targetFields = new
|
|
324
|
+
targetFields = new Map([...targetFields, ...nestedFields]);
|
|
345
325
|
} else {
|
|
346
326
|
targetFields.set(path, field);
|
|
347
327
|
}
|
|
@@ -358,7 +338,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
358
338
|
reset(fieldPaths) {
|
|
359
339
|
const targetFields = this._getOperateFieldMap(fieldPaths);
|
|
360
340
|
|
|
361
|
-
|
|
341
|
+
targetFields.forEach(field => {
|
|
362
342
|
field.fieldApi.reset();
|
|
363
343
|
});
|
|
364
344
|
|
|
@@ -374,16 +354,13 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
374
354
|
}
|
|
375
355
|
|
|
376
356
|
_resetArrayField() {
|
|
377
|
-
var _context22;
|
|
378
|
-
|
|
379
357
|
/*
|
|
380
358
|
When Reset, arrayField needs to be processed separately. Restore the key/value of arrayField in formState according to the initial value
|
|
381
359
|
Update the key inside the arrayField to make it actively renderer
|
|
382
360
|
Reset时,arrayField需要单独处理, 根据初始值还原 arrayField在formState中的key/value, 更新 arrayField内部的key,使其主动rerender
|
|
383
361
|
*/
|
|
384
|
-
const arrayFieldPaths = [...
|
|
385
|
-
|
|
386
|
-
_forEachInstanceProperty(arrayFieldPaths).call(arrayFieldPaths, path => {
|
|
362
|
+
const arrayFieldPaths = [...this.registeredArrayField.keys()];
|
|
363
|
+
arrayFieldPaths.forEach(path => {
|
|
387
364
|
const arrayFieldState = this.registeredArrayField.get(path);
|
|
388
365
|
const arrayFieldInitValue = arrayFieldState.initValue;
|
|
389
366
|
this.updateStateValue(path, arrayFieldInitValue, {
|
|
@@ -399,9 +376,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
399
376
|
|
|
400
377
|
|
|
401
378
|
injectErrorToField(errors) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
_forEachInstanceProperty(_context23 = this.fields).call(_context23, field => {
|
|
379
|
+
this.fields.forEach(field => {
|
|
405
380
|
const fieldError = ObjectUtil.get(errors, field.field);
|
|
406
381
|
const opts = {
|
|
407
382
|
notNotify: true,
|
|
@@ -418,20 +393,20 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
418
393
|
|
|
419
394
|
switch (true) {
|
|
420
395
|
case !isAllField && !needClone:
|
|
421
|
-
result = ObjectUtil.get(
|
|
396
|
+
result = ObjectUtil.get(this.data.values, field);
|
|
422
397
|
break;
|
|
423
398
|
|
|
424
399
|
case !isAllField && needClone:
|
|
425
|
-
fieldValue = ObjectUtil.get(
|
|
400
|
+
fieldValue = ObjectUtil.get(this.data.values, field);
|
|
426
401
|
result = this._adapter.cloneDeep(fieldValue);
|
|
427
402
|
break;
|
|
428
403
|
|
|
429
404
|
case isAllField && !needClone:
|
|
430
|
-
result =
|
|
405
|
+
result = Object.assign({}, this.data.values);
|
|
431
406
|
break;
|
|
432
407
|
|
|
433
408
|
case isAllField && needClone:
|
|
434
|
-
result = this._adapter.cloneDeep(
|
|
409
|
+
result = this._adapter.cloneDeep(this.data.values);
|
|
435
410
|
break;
|
|
436
411
|
|
|
437
412
|
default:
|
|
@@ -442,15 +417,13 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
442
417
|
}
|
|
443
418
|
|
|
444
419
|
setValues(values, _ref) {
|
|
445
|
-
var _context24;
|
|
446
|
-
|
|
447
420
|
let {
|
|
448
421
|
isOverride = false
|
|
449
422
|
} = _ref;
|
|
450
423
|
|
|
451
424
|
const _values = this._adapter.cloneDeep(values);
|
|
452
425
|
|
|
453
|
-
|
|
426
|
+
this.fields.forEach(field => {
|
|
454
427
|
const value = ObjectUtil.get(_values, field.field); // When calling setValues to override the values, only need to trigger onValueChange and onChange once, so setNotNotify of setValue to true
|
|
455
428
|
// 调用setValues进行值的覆盖时,只需要回调一次onValueChange、onChange即可,所以此处将setValue的notNotify置为true
|
|
456
429
|
|
|
@@ -461,13 +434,9 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
461
434
|
field.fieldApi.setValue(value, opts);
|
|
462
435
|
}); // if there exists any arrayField component in this form
|
|
463
436
|
|
|
464
|
-
|
|
465
437
|
if (this.registeredArrayField.size) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const arrayFieldPaths = [..._keysInstanceProperty(_context25 = this.registeredArrayField).call(_context25)];
|
|
469
|
-
|
|
470
|
-
_forEachInstanceProperty(arrayFieldPaths).call(arrayFieldPaths, path => {
|
|
438
|
+
const arrayFieldPaths = [...this.registeredArrayField.keys()];
|
|
439
|
+
arrayFieldPaths.forEach(path => {
|
|
471
440
|
this.updateArrayField(path, {
|
|
472
441
|
updateKey: new Date().valueOf()
|
|
473
442
|
});
|
|
@@ -484,7 +453,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
484
453
|
|
|
485
454
|
this._adapter.notifyChange(this.data);
|
|
486
455
|
|
|
487
|
-
this._adapter.notifyValueChange(
|
|
456
|
+
this._adapter.notifyValueChange(this.data.values, Object.assign({}, values));
|
|
488
457
|
|
|
489
458
|
this._adapter.forceUpdate();
|
|
490
459
|
} // update formState value
|
|
@@ -504,7 +473,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
504
473
|
const formAllowEmpty = this.getProp('allowEmpty'); // priority at Field level
|
|
505
474
|
|
|
506
475
|
const allowEmpty = fieldAllowEmpty ? fieldAllowEmpty : formAllowEmpty;
|
|
507
|
-
ObjectUtil.set(
|
|
476
|
+
ObjectUtil.set(this.data.values, field, value, allowEmpty);
|
|
508
477
|
/**
|
|
509
478
|
* When registering, setValue called when Field initValue is synchronized to FormState should not trigger notify
|
|
510
479
|
* but need to trigger forceUpdate, otherwise useFormState, useFieldState initial rendering will have problems
|
|
@@ -516,7 +485,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
516
485
|
if (!notNotify) {
|
|
517
486
|
this._adapter.notifyChange(this.data);
|
|
518
487
|
|
|
519
|
-
this._adapter.notifyValueChange(
|
|
488
|
+
this._adapter.notifyValueChange(this.data.values, {
|
|
520
489
|
[field]: value
|
|
521
490
|
});
|
|
522
491
|
}
|
|
@@ -594,9 +563,9 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
594
563
|
let nestedFields = this._getNestedField(field);
|
|
595
564
|
|
|
596
565
|
if (nestedFields.size) {
|
|
597
|
-
|
|
566
|
+
nestedFields.forEach(fieldStaff => {
|
|
598
567
|
let fieldPath = fieldStaff.field;
|
|
599
|
-
let newFieldVal = ObjectUtil.get(
|
|
568
|
+
let newFieldVal = ObjectUtil.get(this.data.values, fieldPath);
|
|
600
569
|
let nestedBatchUpdateOpts = {
|
|
601
570
|
notNotify: true,
|
|
602
571
|
notUpdate: true
|
|
@@ -626,7 +595,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
626
595
|
let nestedFields = this._getNestedField(field);
|
|
627
596
|
|
|
628
597
|
if (nestedFields.size) {
|
|
629
|
-
|
|
598
|
+
nestedFields.forEach(fieldStaff => {
|
|
630
599
|
let fieldPath = fieldStaff.field;
|
|
631
600
|
let newFieldError = ObjectUtil.get(this.data.errors, fieldPath);
|
|
632
601
|
let nestedBatchUpdateOpts = {
|
|
@@ -656,7 +625,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
656
625
|
let nestedFields = this._getNestedField(field);
|
|
657
626
|
|
|
658
627
|
if (nestedFields.size) {
|
|
659
|
-
|
|
628
|
+
nestedFields.forEach(fieldStaff => {
|
|
660
629
|
let fieldPath = fieldStaff.field;
|
|
661
630
|
let newFieldTouch = ObjectUtil.get(this.data.touched, fieldPath);
|
|
662
631
|
let nestedBatchUpdateOpts = {
|
|
@@ -708,7 +677,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
708
677
|
|
|
709
678
|
getFormApi() {
|
|
710
679
|
const fieldSetterApi = this.getFieldSetterApi();
|
|
711
|
-
return
|
|
680
|
+
return Object.assign(Object.assign({}, fieldSetterApi), {
|
|
712
681
|
reset: fields => this.reset(fields),
|
|
713
682
|
validate: fields => this.validate(fields),
|
|
714
683
|
getValue: field => this.getValue(field, {
|
|
@@ -746,7 +715,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
746
715
|
但如果是业务方用formApi调用getFormState时,行为无法预料,有可能会进行侵入式修改,所以用深克隆进行隔离
|
|
747
716
|
*/
|
|
748
717
|
if (!needClone) {
|
|
749
|
-
return
|
|
718
|
+
return Object.assign({}, this.data);
|
|
750
719
|
} else {
|
|
751
720
|
return this._adapter.cloneDeep(this.data);
|
|
752
721
|
}
|
|
@@ -759,9 +728,8 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
759
728
|
valid = Boolean(ObjectUtil.empty(this.data.errors));
|
|
760
729
|
} else {
|
|
761
730
|
// when trigger partial validate
|
|
762
|
-
const targetFieldStr = [...
|
|
763
|
-
|
|
764
|
-
_forEachInstanceProperty(targetFieldStr).call(targetFieldStr, fieldStr => {
|
|
731
|
+
const targetFieldStr = [...targetFields.keys()];
|
|
732
|
+
targetFieldStr.forEach(fieldStr => {
|
|
765
733
|
const fieldError = ObjectUtil.get(this.data.errors, fieldStr);
|
|
766
734
|
|
|
767
735
|
if (!isValid(fieldError)) {
|
|
@@ -810,7 +778,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
810
778
|
typeof autoScrollToError === 'object' ? scrollOpts = autoScrollToError : null;
|
|
811
779
|
|
|
812
780
|
if (timeout) {
|
|
813
|
-
|
|
781
|
+
setTimeout(() => this._getErrorFieldAndScroll(scrollOpts), 100);
|
|
814
782
|
} else {
|
|
815
783
|
this._getErrorFieldAndScroll(scrollOpts);
|
|
816
784
|
}
|
package/lib/es/form/utils.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import _cloneDeep from "lodash/cloneDeep";
|
|
2
|
-
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
3
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
4
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
5
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
6
|
-
import _everyInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/every";
|
|
7
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
8
2
|
|
|
9
3
|
var __rest = this && this.__rest || function (s, e) {
|
|
10
4
|
var t = {};
|
|
11
5
|
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) &&
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
13
7
|
|
|
14
|
-
if (s != null && typeof
|
|
15
|
-
if (
|
|
8
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
16
10
|
}
|
|
17
11
|
return t;
|
|
18
12
|
};
|
|
@@ -46,8 +40,8 @@ export function isRequired() {
|
|
|
46
40
|
|
|
47
41
|
if (typeof rules === 'object' && 'required' in rules) {
|
|
48
42
|
required = rules.required;
|
|
49
|
-
} else if (
|
|
50
|
-
|
|
43
|
+
} else if (Array.isArray(rules) && rules.length) {
|
|
44
|
+
rules.forEach(rule => {
|
|
51
45
|
rule.required ? required = true : null;
|
|
52
46
|
});
|
|
53
47
|
}
|
|
@@ -59,8 +53,8 @@ export function isValid(errors) {
|
|
|
59
53
|
|
|
60
54
|
if (typeof errors === 'string' && errors.length) {
|
|
61
55
|
valid = false;
|
|
62
|
-
} else if (
|
|
63
|
-
valid =
|
|
56
|
+
} else if (Array.isArray(errors) && errors.length) {
|
|
57
|
+
valid = errors.every(error => isValid(error));
|
|
64
58
|
} else if (typeof errors === 'boolean') {
|
|
65
59
|
valid = errors;
|
|
66
60
|
} else if (errors && typeof errors.$$typeof === 'symbol' && errors.$$typeof.toString() === 'Symbol(react.element)') {
|
|
@@ -74,7 +68,7 @@ export function isValid(errors) {
|
|
|
74
68
|
function transformTrigger(trigger) {
|
|
75
69
|
let result = [];
|
|
76
70
|
|
|
77
|
-
if (
|
|
71
|
+
if (Array.isArray(trigger)) {
|
|
78
72
|
result = trigger;
|
|
79
73
|
}
|
|
80
74
|
|
|
@@ -97,9 +91,7 @@ export function mergeOptions(opts, props) {
|
|
|
97
91
|
shouldInject: true,
|
|
98
92
|
shouldMemo: true
|
|
99
93
|
};
|
|
100
|
-
|
|
101
|
-
const options = _Object$assign(_Object$assign({}, defaultOpts), opts); // If the field attribute is declared, then the injection is carried out (mainly used to deal with the case where Checkbox and Radio are used separately from the Group); other cases are subject to options
|
|
102
|
-
|
|
94
|
+
const options = Object.assign(Object.assign({}, defaultOpts), opts); // If the field attribute is declared, then the injection is carried out (mainly used to deal with the case where Checkbox and Radio are used separately from the Group); other cases are subject to options
|
|
103
95
|
|
|
104
96
|
const shouldInject = 'field' in props ? true : options.shouldInject;
|
|
105
97
|
return {
|
|
@@ -120,7 +112,7 @@ export function mergeProps(props) {
|
|
|
120
112
|
stopValidateWithError: false
|
|
121
113
|
};
|
|
122
114
|
|
|
123
|
-
let _a =
|
|
115
|
+
let _a = Object.assign(Object.assign({}, defaultProps), props),
|
|
124
116
|
{
|
|
125
117
|
field,
|
|
126
118
|
label,
|
|
@@ -218,5 +210,5 @@ export function mergeProps(props) {
|
|
|
218
210
|
}
|
|
219
211
|
|
|
220
212
|
function bothEmptyArray(val, otherVal) {
|
|
221
|
-
return
|
|
213
|
+
return Array.isArray(val) && Array.isArray(otherVal) && !val.length && !otherVal.length;
|
|
222
214
|
}
|
|
@@ -3,16 +3,13 @@ import _isString from "lodash/isString";
|
|
|
3
3
|
import _isNumber from "lodash/isNumber";
|
|
4
4
|
import _set from "lodash/set";
|
|
5
5
|
import _noop from "lodash/noop";
|
|
6
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
7
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
8
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
9
6
|
import BaseFoundation from '../base/foundation';
|
|
10
7
|
import { strings } from './constants';
|
|
11
8
|
import { ENTER_KEY } from './../utils/keyCode';
|
|
12
9
|
|
|
13
10
|
class InputFoundation extends BaseFoundation {
|
|
14
11
|
constructor(adapter) {
|
|
15
|
-
super(
|
|
12
|
+
super(Object.assign(Object.assign({}, InputFoundation.inputDefaultAdapter), adapter));
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
static get inputDefaultAdapter() {
|
|
@@ -158,7 +155,7 @@ class InputFoundation extends BaseFoundation {
|
|
|
158
155
|
let truncatedValue = '';
|
|
159
156
|
|
|
160
157
|
for (let i = 1, len = value.length; i <= len; i++) {
|
|
161
|
-
const currentValue =
|
|
158
|
+
const currentValue = value.slice(0, i);
|
|
162
159
|
|
|
163
160
|
if (getValueLength(currentValue) > maxLength) {
|
|
164
161
|
return truncatedValue;
|
|
@@ -169,7 +166,7 @@ class InputFoundation extends BaseFoundation {
|
|
|
169
166
|
|
|
170
167
|
return truncatedValue;
|
|
171
168
|
} else {
|
|
172
|
-
return
|
|
169
|
+
return value.slice(0, maxLength);
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
172
|
|
|
@@ -359,10 +356,8 @@ class InputFoundation extends BaseFoundation {
|
|
|
359
356
|
|
|
360
357
|
|
|
361
358
|
handleModeEnterPress(e) {
|
|
362
|
-
var _context;
|
|
363
|
-
|
|
364
359
|
// trigger by Enter or Space key
|
|
365
|
-
if (
|
|
360
|
+
if (['Enter', ' '].includes(e === null || e === void 0 ? void 0 : e.key)) {
|
|
366
361
|
this.handlePreventMouseDown(e);
|
|
367
362
|
this.handleClickEye(e);
|
|
368
363
|
}
|
|
@@ -2,14 +2,12 @@ import _isString from "lodash/isString";
|
|
|
2
2
|
import _isNumber from "lodash/isNumber";
|
|
3
3
|
import _isFunction from "lodash/isFunction";
|
|
4
4
|
import _noop from "lodash/noop";
|
|
5
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
6
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
7
5
|
import BaseFoundation from '../base/foundation';
|
|
8
6
|
import calculateNodeHeight from './util/calculateNodeHeight';
|
|
9
7
|
import getSizingData from './util/getSizingData';
|
|
10
8
|
export default class TextAreaFoundation extends BaseFoundation {
|
|
11
9
|
constructor(adapter) {
|
|
12
|
-
super(
|
|
10
|
+
super(Object.assign(Object.assign({}, TextAreaFoundation.textAreaDefaultAdapter), adapter));
|
|
13
11
|
|
|
14
12
|
this.resizeTextarea = cb => {
|
|
15
13
|
const {
|
|
@@ -178,7 +176,7 @@ export default class TextAreaFoundation extends BaseFoundation {
|
|
|
178
176
|
let truncatedValue = '';
|
|
179
177
|
|
|
180
178
|
for (let i = 1, len = value.length; i <= len; i++) {
|
|
181
|
-
const currentValue =
|
|
179
|
+
const currentValue = value.slice(0, i);
|
|
182
180
|
|
|
183
181
|
if (getValueLength(currentValue) > maxLength) {
|
|
184
182
|
return truncatedValue;
|
|
@@ -189,7 +187,7 @@ export default class TextAreaFoundation extends BaseFoundation {
|
|
|
189
187
|
|
|
190
188
|
return truncatedValue;
|
|
191
189
|
} else {
|
|
192
|
-
return
|
|
190
|
+
return value.slice(0, maxLength);
|
|
193
191
|
}
|
|
194
192
|
}
|
|
195
193
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
2
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
3
1
|
// Reference to https://github.com/andreypopp/react-textarea-autosize/
|
|
4
2
|
let hiddenTextarea = null;
|
|
5
3
|
const HIDDEN_TEXTAREA_STYLE = {
|
|
@@ -15,9 +13,7 @@ const HIDDEN_TEXTAREA_STYLE = {
|
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
const forceHiddenStyles = node => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
_forEachInstanceProperty(_context = _Object$keys(HIDDEN_TEXTAREA_STYLE)).call(_context, key => {
|
|
16
|
+
Object.keys(HIDDEN_TEXTAREA_STYLE).forEach(key => {
|
|
21
17
|
node.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');
|
|
22
18
|
});
|
|
23
19
|
};
|
|
@@ -35,8 +31,6 @@ const getContentHeight = (node, sizingData) => {
|
|
|
35
31
|
};
|
|
36
32
|
|
|
37
33
|
export default function calculateNodeHeight(sizingData, value) {
|
|
38
|
-
var _context2;
|
|
39
|
-
|
|
40
34
|
let minRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
41
35
|
let maxRows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Infinity;
|
|
42
36
|
|
|
@@ -59,11 +53,9 @@ export default function calculateNodeHeight(sizingData, value) {
|
|
|
59
53
|
const {
|
|
60
54
|
boxSizing
|
|
61
55
|
} = sizingStyle;
|
|
62
|
-
|
|
63
|
-
_forEachInstanceProperty(_context2 = _Object$keys(sizingStyle)).call(_context2, key => {
|
|
56
|
+
Object.keys(sizingStyle).forEach(key => {
|
|
64
57
|
hiddenTextarea.style[key] = sizingStyle[key];
|
|
65
58
|
});
|
|
66
|
-
|
|
67
59
|
forceHiddenStyles(hiddenTextarea);
|
|
68
60
|
hiddenTextarea.value = value;
|
|
69
61
|
let height = getContentHeight(hiddenTextarea, sizingData); // measure height of a textarea with a single row
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _pick from "lodash/pick";
|
|
2
|
-
import _parseFloat from "@babel/runtime-corejs3/core-js-stable/parse-float";
|
|
3
2
|
const SIZING_STYLE = ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth', 'boxSizing', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'letterSpacing', 'lineHeight', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', // non-standard
|
|
4
3
|
'tabSize', 'textIndent', // non-standard
|
|
5
4
|
'textRendering', 'textTransform', 'width'];
|
|
@@ -21,10 +20,8 @@ const getSizingData = node => {
|
|
|
21
20
|
return null;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
const paddingSize =
|
|
25
|
-
|
|
26
|
-
const borderSize = _parseFloat(sizingStyle.borderBottomWidth) + _parseFloat(sizingStyle.borderTopWidth);
|
|
27
|
-
|
|
23
|
+
const paddingSize = parseFloat(sizingStyle.paddingBottom) + parseFloat(sizingStyle.paddingTop);
|
|
24
|
+
const borderSize = parseFloat(sizingStyle.borderBottomWidth) + parseFloat(sizingStyle.borderTopWidth);
|
|
28
25
|
return {
|
|
29
26
|
sizingStyle,
|
|
30
27
|
paddingSize,
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
2
1
|
import { cssClasses as inputCssClasses, numbers as inputNumbers, strings as inputStrings } from '../input/constants';
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const numbers = _Object$assign(_Object$assign({}, inputNumbers), {
|
|
2
|
+
const cssClasses = Object.assign({}, inputCssClasses);
|
|
3
|
+
const numbers = Object.assign(Object.assign({}, inputNumbers), {
|
|
7
4
|
DEFAULT_STEP: 1,
|
|
8
5
|
DEFAULT_SHIFT_STEP: 10,
|
|
9
6
|
DEFAULT_PRESS_TIMEOUT: 250,
|
|
10
7
|
DEFAULT_PRESS_INTERVAL: 0,
|
|
11
8
|
MOUSE_BUTTON_LEFT: 0
|
|
12
9
|
});
|
|
13
|
-
|
|
14
|
-
const strings = _Object$assign({}, inputStrings);
|
|
15
|
-
|
|
10
|
+
const strings = Object.assign({}, inputStrings);
|
|
16
11
|
export { cssClasses, numbers, strings };
|