@douyinfe/semi-foundation 2.36.0-beta.0 → 2.36.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/calendar/foundation.ts +2 -1
- package/lib/cjs/anchor/constants.js +0 -2
- package/lib/cjs/anchor/foundation.js +10 -73
- package/lib/cjs/anchor/linkFoundation.js +4 -16
- package/lib/cjs/autoComplete/constants.js +0 -3
- package/lib/cjs/autoComplete/foundation.d.ts +1 -1
- package/lib/cjs/autoComplete/foundation.js +25 -139
- package/lib/cjs/autoComplete/optionFoundation.js +4 -14
- package/lib/cjs/avatar/constants.js +0 -2
- package/lib/cjs/avatar/foundation.js +0 -17
- package/lib/cjs/backtop/constants.js +0 -2
- package/lib/cjs/backtop/foundation.d.ts +2 -2
- package/lib/cjs/backtop/foundation.js +0 -21
- package/lib/cjs/badge/constants.js +0 -2
- package/lib/cjs/banner/constants.js +0 -2
- package/lib/cjs/banner/foundation.js +0 -7
- package/lib/cjs/base/constants.js +2 -4
- package/lib/cjs/base/foundation.d.ts +1 -1
- package/lib/cjs/base/foundation.js +12 -46
- package/lib/cjs/base/index.js +0 -3
- package/lib/cjs/breadcrumb/constants.js +0 -2
- package/lib/cjs/breadcrumb/foundation.js +1 -12
- package/lib/cjs/breadcrumb/itemFoundation.js +0 -7
- package/lib/cjs/button/constants.js +0 -2
- package/lib/cjs/calendar/constants.js +0 -2
- package/lib/cjs/calendar/eventUtil.d.ts +1 -1
- package/lib/cjs/calendar/eventUtil.js +2 -74
- package/lib/cjs/calendar/foundation.d.ts +2 -2
- package/lib/cjs/calendar/foundation.js +28 -123
- package/lib/cjs/card/constants.js +0 -2
- package/lib/cjs/carousel/constants.js +0 -2
- package/lib/cjs/carousel/foundation.js +2 -52
- package/lib/cjs/cascader/constants.js +0 -3
- package/lib/cjs/cascader/foundation.d.ts +4 -4
- package/lib/cjs/cascader/foundation.js +28 -242
- package/lib/cjs/cascader/util.js +6 -24
- package/lib/cjs/checkbox/checkboxFoundation.js +2 -38
- package/lib/cjs/checkbox/checkboxGroupFoundation.js +2 -23
- package/lib/cjs/checkbox/constants.js +0 -2
- package/lib/cjs/collapse/constants.js +0 -2
- package/lib/cjs/collapse/foundation.d.ts +1 -1
- package/lib/cjs/collapse/foundation.js +2 -13
- package/lib/cjs/collapsible/constants.js +0 -2
- package/lib/cjs/collapsible/foundation.js +0 -9
- package/lib/cjs/datePicker/_utils/formatter.js +4 -10
- package/lib/cjs/datePicker/_utils/getDayOfWeek.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/getDayOfWeek.js +0 -4
- package/lib/cjs/datePicker/_utils/getDefaultFormatToken.js +0 -5
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.js +0 -15
- package/lib/cjs/datePicker/_utils/getFullDateOffset.js +0 -7
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +0 -5
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +0 -6
- package/lib/cjs/datePicker/_utils/getMonthTable.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/getMonthTable.js +3 -14
- package/lib/cjs/datePicker/_utils/getMonthsInYear.js +0 -2
- package/lib/cjs/datePicker/_utils/getYears.js +0 -4
- package/lib/cjs/datePicker/_utils/index.js +0 -13
- package/lib/cjs/datePicker/_utils/isAfter.js +0 -4
- package/lib/cjs/datePicker/_utils/isBefore.js +0 -4
- package/lib/cjs/datePicker/_utils/isBetween.js +0 -4
- package/lib/cjs/datePicker/_utils/isDate.js +0 -1
- package/lib/cjs/datePicker/_utils/isSameDay.js +0 -4
- package/lib/cjs/datePicker/_utils/isTimestamp.js +0 -4
- package/lib/cjs/datePicker/_utils/isUnixTimestamp.js +0 -4
- package/lib/cjs/datePicker/_utils/isValidDate.js +0 -1
- package/lib/cjs/datePicker/_utils/isValidTimeZone.js +0 -1
- package/lib/cjs/datePicker/_utils/isWithinInterval.js +0 -4
- package/lib/cjs/datePicker/_utils/parser.js +0 -10
- package/lib/cjs/datePicker/constants.js +0 -3
- package/lib/cjs/datePicker/foundation.d.ts +24 -24
- package/lib/cjs/datePicker/foundation.js +22 -333
- package/lib/cjs/datePicker/inputFoundation.d.ts +3 -3
- package/lib/cjs/datePicker/inputFoundation.js +5 -86
- package/lib/cjs/datePicker/monthFoundation.d.ts +1 -1
- package/lib/cjs/datePicker/monthFoundation.js +3 -28
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +3 -3
- package/lib/cjs/datePicker/monthsGridFoundation.js +43 -238
- package/lib/cjs/datePicker/yearAndMonthFoundation.d.ts +1 -1
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +12 -38
- package/lib/cjs/descriptions/constants.js +0 -2
- package/lib/cjs/divider/constants.js +0 -2
- package/lib/cjs/dropdown/constants.js +0 -3
- package/lib/cjs/dropdown/foundation.js +4 -23
- package/lib/cjs/dropdown/menuFoundation.js +8 -27
- package/lib/cjs/empty/constants.js +0 -2
- package/lib/cjs/form/constants.js +0 -2
- package/lib/cjs/form/foundation.js +75 -206
- package/lib/cjs/form/interface.d.ts +5 -5
- package/lib/cjs/form/utils.js +47 -77
- package/lib/cjs/grid/constants.js +0 -2
- package/lib/cjs/highlight/constants.js +0 -2
- package/lib/cjs/icons/constants.js +0 -2
- package/lib/cjs/image/constants.js +0 -2
- package/lib/cjs/image/imageFoundation.js +4 -18
- package/lib/cjs/image/previewFooterFoundation.js +0 -13
- package/lib/cjs/image/previewFoundation.js +0 -11
- package/lib/cjs/image/previewImageFoundation.js +6 -80
- package/lib/cjs/image/previewInnerFoundation.js +12 -77
- package/lib/cjs/image/utils.js +0 -14
- package/lib/cjs/input/constants.js +0 -2
- package/lib/cjs/input/foundation.js +17 -101
- package/lib/cjs/input/textareaFoundation.js +20 -85
- package/lib/cjs/input/util/calculateNodeHeight.js +6 -18
- package/lib/cjs/input/util/getSizingData.js +7 -11
- package/lib/cjs/inputNumber/constants.js +0 -2
- package/lib/cjs/inputNumber/foundation.js +29 -192
- package/lib/cjs/layout/constants.js +0 -2
- package/lib/cjs/list/constants.js +0 -2
- package/lib/cjs/modal/constants.js +0 -2
- package/lib/cjs/modal/modalContentFoundation.js +0 -20
- package/lib/cjs/modal/modalFoundation.d.ts +2 -2
- package/lib/cjs/modal/modalFoundation.js +2 -22
- package/lib/cjs/navigation/NavItem.js +0 -10
- package/lib/cjs/navigation/constants.js +0 -3
- package/lib/cjs/navigation/foundation.js +3 -67
- package/lib/cjs/navigation/itemFoundation.js +3 -21
- package/lib/cjs/navigation/subNavFoundation.js +4 -40
- package/lib/cjs/notification/constants.js +0 -3
- package/lib/cjs/notification/notificationFoundation.d.ts +3 -3
- package/lib/cjs/notification/notificationFoundation.js +0 -16
- package/lib/cjs/notification/notificationListFoundation.js +7 -17
- package/lib/cjs/overflowList/constants.js +0 -2
- package/lib/cjs/overflowList/foundation.js +11 -41
- package/lib/cjs/pagination/constants.js +0 -2
- package/lib/cjs/pagination/foundation.d.ts +3 -3
- package/lib/cjs/pagination/foundation.js +21 -90
- package/lib/cjs/popconfirm/constants.js +0 -2
- package/lib/cjs/popconfirm/popconfirmFoundation.js +1 -21
- package/lib/cjs/popover/constants.js +0 -3
- package/lib/cjs/progress/constants.js +0 -2
- package/lib/cjs/progress/generates.d.ts +2 -2
- package/lib/cjs/progress/generates.js +19 -60
- package/lib/cjs/radio/constants.js +0 -2
- package/lib/cjs/radio/radioFoundation.js +0 -14
- package/lib/cjs/radio/radioGroupFoundation.js +4 -23
- package/lib/cjs/radio/radioInnerFoundation.js +2 -19
- package/lib/cjs/rating/constants.js +0 -2
- package/lib/cjs/rating/foundation.js +11 -61
- package/lib/cjs/scrollList/constants.js +0 -2
- package/lib/cjs/scrollList/foundation.js +0 -4
- package/lib/cjs/scrollList/itemFoundation.js +8 -61
- package/lib/cjs/scrollList/scrollTo.js +2 -5
- package/lib/cjs/select/constants.js +0 -3
- package/lib/cjs/select/foundation.d.ts +2 -2
- package/lib/cjs/select/foundation.js +122 -425
- package/lib/cjs/select/optionFoundation.js +4 -14
- package/lib/cjs/sideSheet/constants.js +0 -2
- package/lib/cjs/sideSheet/sideSheetFoundation.js +0 -18
- package/lib/cjs/skeleton/constants.js +0 -2
- package/lib/cjs/slider/constants.js +0 -2
- package/lib/cjs/slider/foundation.d.ts +1 -1
- package/lib/cjs/slider/foundation.js +25 -204
- package/lib/cjs/space/constants.js +0 -2
- package/lib/cjs/spin/constants.js +0 -2
- package/lib/cjs/spin/foundation.js +3 -13
- package/lib/cjs/steps/constants.js +0 -2
- package/lib/cjs/switch/constants.js +0 -2
- package/lib/cjs/switch/foundation.js +2 -18
- package/lib/cjs/table/bodyFoundation.js +2 -34
- package/lib/cjs/table/cellFoundation.js +0 -5
- package/lib/cjs/table/constants.js +7 -8
- package/lib/cjs/table/foundation.d.ts +17 -14
- package/lib/cjs/table/foundation.js +71 -302
- package/lib/cjs/table/tableRowFoundation.js +0 -11
- package/lib/cjs/table/tableSelectionCellFoundation.js +0 -6
- package/lib/cjs/table/utils.d.ts +2 -2
- package/lib/cjs/table/utils.js +5 -118
- package/lib/cjs/tabs/constants.js +0 -2
- package/lib/cjs/tabs/foundation.js +2 -40
- package/lib/cjs/tag/constants.js +1 -2
- package/lib/cjs/tagInput/constants.js +0 -2
- package/lib/cjs/tagInput/foundation.d.ts +4 -4
- package/lib/cjs/tagInput/foundation.js +4 -94
- package/lib/cjs/tagInput/utils/getSplitedArray.js +0 -11
- package/lib/cjs/timePicker/ComboxFoundation.js +4 -39
- package/lib/cjs/timePicker/constants.js +0 -3
- package/lib/cjs/timePicker/foundation.d.ts +1 -1
- package/lib/cjs/timePicker/foundation.js +3 -97
- package/lib/cjs/timePicker/inputFoundation.js +6 -25
- package/lib/cjs/timePicker/utils/index.js +6 -45
- package/lib/cjs/timePicker/utils/localeDate.js +0 -10
- package/lib/cjs/timeline/constants.js +0 -2
- package/lib/cjs/toast/constants.js +0 -3
- package/lib/cjs/toast/toastFoundation.d.ts +3 -3
- package/lib/cjs/toast/toastFoundation.js +0 -14
- package/lib/cjs/toast/toastListFoundation.js +4 -22
- package/lib/cjs/tooltip/constants.js +0 -2
- package/lib/cjs/tooltip/foundation.d.ts +1 -1
- package/lib/cjs/tooltip/foundation.js +63 -291
- package/lib/cjs/transfer/constants.js +0 -2
- package/lib/cjs/transfer/foundation.d.ts +1 -1
- package/lib/cjs/transfer/foundation.js +4 -68
- package/lib/cjs/transfer/transferUtils.js +5 -27
- package/lib/cjs/tree/constants.js +0 -2
- package/lib/cjs/tree/foundation.d.ts +3 -3
- package/lib/cjs/tree/foundation.js +34 -150
- package/lib/cjs/tree/treeUtil.js +54 -173
- package/lib/cjs/treeSelect/constants.js +0 -2
- package/lib/cjs/treeSelect/foundation.d.ts +7 -7
- package/lib/cjs/treeSelect/foundation.js +18 -192
- package/lib/cjs/typography/constants.js +0 -2
- package/lib/cjs/typography/formatNumeral.d.ts +3 -3
- package/lib/cjs/typography/formatNumeral.js +16 -32
- package/lib/cjs/upload/constants.js +0 -2
- package/lib/cjs/upload/foundation.d.ts +5 -5
- package/lib/cjs/upload/foundation.js +36 -245
- package/lib/cjs/upload/utils.js +10 -29
- package/lib/cjs/utils/Event.js +2 -21
- package/lib/cjs/utils/FocusHandle.d.ts +1 -1
- package/lib/cjs/utils/FocusHandle.js +6 -35
- package/lib/cjs/utils/Logger.js +0 -21
- package/lib/cjs/utils/Store.js +0 -10
- package/lib/cjs/utils/a11y.js +18 -43
- package/lib/cjs/utils/array.d.ts +1 -1
- package/lib/cjs/utils/array.js +0 -7
- package/lib/cjs/utils/arrayMove.js +0 -1
- package/lib/cjs/utils/classnames.js +0 -12
- package/lib/cjs/utils/date-fns-extra.js +0 -35
- package/lib/cjs/utils/dom.d.ts +1 -1
- package/lib/cjs/utils/dom.js +0 -13
- package/lib/cjs/utils/function.js +0 -1
- package/lib/cjs/utils/getDataAttr.js +0 -2
- package/lib/cjs/utils/getHighlight.js +5 -26
- package/lib/cjs/utils/getMotionObjFromProps.js +0 -12
- package/lib/cjs/utils/index.js +0 -4
- package/lib/cjs/utils/isBothNaN.js +0 -2
- package/lib/cjs/utils/isElement.js +0 -1
- package/lib/cjs/utils/isEnterPress.js +0 -5
- package/lib/cjs/utils/isEscPress.js +0 -5
- package/lib/cjs/utils/isNullOrUndefined.js +0 -1
- package/lib/cjs/utils/isNumber.js +0 -1
- package/lib/cjs/utils/isObject.js +0 -1
- package/lib/cjs/utils/isPromise.js +0 -3
- package/lib/cjs/utils/isString.js +0 -1
- package/lib/cjs/utils/keyCode.js +0 -105
- package/lib/cjs/utils/log.js +0 -5
- package/lib/cjs/utils/number.js +0 -2
- package/lib/cjs/utils/object.d.ts +4 -4
- package/lib/cjs/utils/object.js +12 -34
- package/lib/cjs/utils/set.js +0 -8
- package/lib/cjs/utils/shallowEqualObjects.js +0 -7
- package/lib/cjs/utils/touchPolyfill.js +0 -7
- package/lib/cjs/utils/type.d.ts +3 -3
- package/lib/cjs/utils/uuid.js +2 -9
- package/lib/cjs/utils/warning.js +0 -1
- package/lib/es/anchor/foundation.js +10 -66
- package/lib/es/anchor/linkFoundation.js +4 -12
- package/lib/es/autoComplete/foundation.d.ts +1 -1
- package/lib/es/autoComplete/foundation.js +24 -132
- package/lib/es/autoComplete/optionFoundation.js +4 -10
- package/lib/es/avatar/foundation.js +0 -12
- package/lib/es/backtop/foundation.d.ts +2 -2
- package/lib/es/backtop/foundation.js +0 -16
- package/lib/es/banner/foundation.js +0 -3
- package/lib/es/base/constants.js +2 -2
- package/lib/es/base/foundation.d.ts +1 -1
- package/lib/es/base/foundation.js +11 -44
- package/lib/es/breadcrumb/foundation.js +0 -7
- package/lib/es/breadcrumb/itemFoundation.js +0 -3
- package/lib/es/calendar/eventUtil.d.ts +1 -1
- package/lib/es/calendar/eventUtil.js +2 -36
- package/lib/es/calendar/foundation.d.ts +2 -2
- package/lib/es/calendar/foundation.js +28 -117
- package/lib/es/carousel/foundation.js +2 -47
- package/lib/es/cascader/constants.js +0 -1
- package/lib/es/cascader/foundation.d.ts +4 -4
- package/lib/es/cascader/foundation.js +30 -226
- package/lib/es/cascader/util.js +6 -15
- package/lib/es/checkbox/checkboxFoundation.js +2 -34
- package/lib/es/checkbox/checkboxGroupFoundation.js +2 -20
- package/lib/es/collapse/foundation.d.ts +1 -1
- package/lib/es/collapse/foundation.js +2 -9
- package/lib/es/collapsible/foundation.js +0 -7
- package/lib/es/datePicker/_utils/formatter.js +4 -8
- package/lib/es/datePicker/_utils/getDayOfWeek.d.ts +1 -1
- package/lib/es/datePicker/_utils/getDayOfWeek.js +0 -3
- package/lib/es/datePicker/_utils/getDefaultFormatToken.js +0 -2
- package/lib/es/datePicker/_utils/getDefaultPickerDate.d.ts +1 -1
- package/lib/es/datePicker/_utils/getDefaultPickerDate.js +0 -10
- package/lib/es/datePicker/_utils/getFullDateOffset.js +0 -3
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +0 -4
- package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +0 -5
- package/lib/es/datePicker/_utils/getMonthTable.d.ts +1 -1
- package/lib/es/datePicker/_utils/getMonthTable.js +4 -14
- package/lib/es/datePicker/_utils/getMonthsInYear.js +0 -1
- package/lib/es/datePicker/_utils/getYears.js +0 -3
- package/lib/es/datePicker/_utils/isBetween.js +0 -1
- package/lib/es/datePicker/_utils/parser.js +0 -8
- package/lib/es/datePicker/foundation.d.ts +24 -24
- package/lib/es/datePicker/foundation.js +22 -318
- package/lib/es/datePicker/inputFoundation.d.ts +3 -3
- package/lib/es/datePicker/inputFoundation.js +5 -74
- package/lib/es/datePicker/monthFoundation.d.ts +1 -1
- package/lib/es/datePicker/monthFoundation.js +4 -22
- package/lib/es/datePicker/monthsGridFoundation.d.ts +3 -3
- package/lib/es/datePicker/monthsGridFoundation.js +42 -222
- package/lib/es/datePicker/yearAndMonthFoundation.d.ts +1 -1
- package/lib/es/datePicker/yearAndMonthFoundation.js +12 -36
- package/lib/es/dropdown/foundation.js +4 -18
- package/lib/es/dropdown/menuFoundation.js +8 -22
- package/lib/es/form/foundation.js +74 -195
- package/lib/es/form/interface.d.ts +5 -5
- package/lib/es/form/utils.js +47 -70
- package/lib/es/image/imageFoundation.js +4 -13
- package/lib/es/image/previewFooterFoundation.js +0 -9
- package/lib/es/image/previewFoundation.js +0 -7
- package/lib/es/image/previewImageFoundation.js +6 -72
- package/lib/es/image/previewInnerFoundation.js +12 -70
- package/lib/es/image/utils.js +0 -6
- package/lib/es/input/foundation.js +17 -93
- package/lib/es/input/textareaFoundation.js +20 -75
- package/lib/es/input/util/calculateNodeHeight.js +6 -18
- package/lib/es/input/util/getSizingData.js +7 -11
- package/lib/es/inputNumber/foundation.js +28 -183
- package/lib/es/modal/modalContentFoundation.js +0 -15
- package/lib/es/modal/modalFoundation.d.ts +2 -2
- package/lib/es/modal/modalFoundation.js +2 -17
- package/lib/es/navigation/NavItem.js +0 -6
- package/lib/es/navigation/constants.js +1 -1
- package/lib/es/navigation/foundation.js +2 -60
- package/lib/es/navigation/itemFoundation.js +3 -18
- package/lib/es/navigation/subNavFoundation.js +4 -36
- package/lib/es/notification/constants.js +1 -1
- package/lib/es/notification/notificationFoundation.d.ts +3 -3
- package/lib/es/notification/notificationFoundation.js +0 -11
- package/lib/es/notification/notificationListFoundation.js +6 -13
- package/lib/es/overflowList/foundation.js +11 -37
- package/lib/es/pagination/foundation.d.ts +3 -3
- package/lib/es/pagination/foundation.js +20 -87
- package/lib/es/popconfirm/popconfirmFoundation.js +1 -16
- package/lib/es/progress/generates.d.ts +2 -2
- package/lib/es/progress/generates.js +19 -59
- package/lib/es/radio/radioFoundation.js +0 -9
- package/lib/es/radio/radioGroupFoundation.js +4 -19
- package/lib/es/radio/radioInnerFoundation.js +2 -15
- package/lib/es/rating/foundation.js +10 -54
- package/lib/es/scrollList/itemFoundation.js +8 -60
- package/lib/es/scrollList/scrollTo.js +2 -4
- package/lib/es/select/foundation.d.ts +2 -2
- package/lib/es/select/foundation.js +122 -411
- package/lib/es/select/optionFoundation.js +4 -10
- package/lib/es/sideSheet/sideSheetFoundation.js +0 -12
- package/lib/es/slider/foundation.d.ts +1 -1
- package/lib/es/slider/foundation.js +24 -197
- package/lib/es/spin/foundation.js +3 -11
- package/lib/es/switch/foundation.js +2 -13
- package/lib/es/table/bodyFoundation.js +2 -25
- package/lib/es/table/cellFoundation.js +0 -1
- package/lib/es/table/constants.js +6 -6
- package/lib/es/table/foundation.d.ts +17 -14
- package/lib/es/table/foundation.js +71 -309
- package/lib/es/table/tableRowFoundation.js +2 -9
- package/lib/es/table/tableSelectionCellFoundation.js +0 -2
- package/lib/es/table/utils.d.ts +2 -2
- package/lib/es/table/utils.js +5 -81
- package/lib/es/tabs/foundation.js +2 -35
- package/lib/es/tagInput/foundation.d.ts +4 -4
- package/lib/es/tagInput/foundation.js +4 -84
- package/lib/es/tagInput/utils/getSplitedArray.js +0 -7
- package/lib/es/timePicker/ComboxFoundation.js +4 -30
- package/lib/es/timePicker/foundation.d.ts +1 -1
- package/lib/es/timePicker/foundation.js +4 -90
- package/lib/es/timePicker/inputFoundation.js +6 -22
- package/lib/es/timePicker/utils/index.js +6 -25
- package/lib/es/timePicker/utils/localeDate.js +0 -8
- package/lib/es/toast/constants.js +1 -1
- package/lib/es/toast/toastFoundation.d.ts +3 -3
- package/lib/es/toast/toastFoundation.js +0 -9
- package/lib/es/toast/toastListFoundation.js +4 -18
- package/lib/es/tooltip/foundation.d.ts +1 -1
- package/lib/es/tooltip/foundation.js +63 -288
- package/lib/es/transfer/foundation.d.ts +1 -1
- package/lib/es/transfer/foundation.js +6 -62
- package/lib/es/transfer/transferUtils.js +5 -21
- package/lib/es/tree/foundation.d.ts +3 -3
- package/lib/es/tree/foundation.js +34 -143
- package/lib/es/tree/treeUtil.js +54 -139
- package/lib/es/treeSelect/foundation.d.ts +7 -7
- package/lib/es/treeSelect/foundation.js +20 -179
- package/lib/es/typography/formatNumeral.d.ts +3 -3
- package/lib/es/typography/formatNumeral.js +16 -29
- package/lib/es/upload/foundation.d.ts +5 -5
- package/lib/es/upload/foundation.js +36 -238
- package/lib/es/upload/utils.js +10 -24
- package/lib/es/utils/Event.js +2 -17
- package/lib/es/utils/FocusHandle.d.ts +1 -1
- package/lib/es/utils/FocusHandle.js +6 -32
- package/lib/es/utils/Logger.js +0 -20
- package/lib/es/utils/Store.js +0 -9
- package/lib/es/utils/a11y.js +18 -31
- package/lib/es/utils/array.d.ts +1 -1
- package/lib/es/utils/array.js +0 -5
- package/lib/es/utils/classnames.js +0 -10
- package/lib/es/utils/date-fns-extra.js +0 -27
- package/lib/es/utils/dom.d.ts +1 -1
- package/lib/es/utils/dom.js +0 -9
- package/lib/es/utils/getDataAttr.js +0 -1
- package/lib/es/utils/getHighlight.js +5 -26
- package/lib/es/utils/getMotionObjFromProps.js +0 -8
- package/lib/es/utils/isBothNaN.js +0 -1
- package/lib/es/utils/isEnterPress.js +0 -2
- package/lib/es/utils/isEscPress.js +0 -2
- package/lib/es/utils/keyCode.js +0 -104
- package/lib/es/utils/log.js +0 -3
- package/lib/es/utils/object.d.ts +4 -4
- package/lib/es/utils/object.js +12 -28
- package/lib/es/utils/set.js +0 -5
- package/lib/es/utils/shallowEqualObjects.js +0 -6
- package/lib/es/utils/touchPolyfill.js +0 -5
- package/lib/es/utils/type.d.ts +3 -3
- package/lib/es/utils/uuid.js +2 -8
- package/package.json +2 -2
- package/table/foundation.ts +7 -10
- package/upload/foundation.ts +8 -8
|
@@ -2,34 +2,25 @@ import _isString from "lodash/isString";
|
|
|
2
2
|
import _get from "lodash/get";
|
|
3
3
|
import _toString from "lodash/toString";
|
|
4
4
|
import _toNumber from "lodash/toNumber";
|
|
5
|
-
|
|
6
5
|
/* eslint-disable max-len */
|
|
7
|
-
|
|
8
6
|
/* eslint-disable no-param-reassign */
|
|
9
|
-
|
|
10
7
|
/* eslint-disable eqeqeq */
|
|
11
8
|
import BaseFoundation from '../base/foundation';
|
|
12
9
|
import keyCode from '../utils/keyCode';
|
|
13
10
|
import { numbers } from './constants';
|
|
14
11
|
import { minus as numberMinus } from '../utils/number';
|
|
15
|
-
|
|
16
12
|
class InputNumberFoundation extends BaseFoundation {
|
|
17
13
|
init() {
|
|
18
14
|
this._setInitValue();
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
destroy() {
|
|
22
17
|
this._unregisterInterval();
|
|
23
|
-
|
|
24
18
|
this._unregisterTimer();
|
|
25
|
-
|
|
26
19
|
this._adapter.unregisterGlobalEvent('mouseup');
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
isControlled() {
|
|
30
22
|
return this._isControlledComponent('value');
|
|
31
23
|
}
|
|
32
|
-
|
|
33
24
|
_doInput() {
|
|
34
25
|
let v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
35
26
|
let event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
@@ -37,34 +28,28 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
37
28
|
let notifyVal = v;
|
|
38
29
|
let number = v;
|
|
39
30
|
let isValidNumber = true;
|
|
40
|
-
const isControlled = this.isControlled();
|
|
41
|
-
|
|
31
|
+
const isControlled = this.isControlled();
|
|
32
|
+
// console.log(v);
|
|
42
33
|
if (typeof v !== 'number') {
|
|
43
34
|
number = this.doParse(v, false);
|
|
44
35
|
isValidNumber = !isNaN(number);
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
if (isValidNumber) {
|
|
48
38
|
notifyVal = number;
|
|
49
|
-
|
|
50
39
|
if (!isControlled) {
|
|
51
40
|
this._adapter.setNumber(number);
|
|
52
41
|
}
|
|
53
42
|
}
|
|
54
|
-
|
|
55
43
|
if (!isControlled) {
|
|
56
44
|
this._adapter.setValue(v, updateCb);
|
|
57
45
|
}
|
|
58
|
-
|
|
59
46
|
if (this.getProp('keepFocus')) {
|
|
60
47
|
this._adapter.setFocusing(true, () => {
|
|
61
48
|
this._adapter.setClickUpOrDown(true);
|
|
62
49
|
});
|
|
63
50
|
}
|
|
64
|
-
|
|
65
51
|
this.notifyChange(notifyVal, event);
|
|
66
52
|
}
|
|
67
|
-
|
|
68
53
|
_registerInterval(cb) {
|
|
69
54
|
const pressInterval = this.getProp('pressInterval') || numbers.DEFAULT_PRESS_INTERVAL;
|
|
70
55
|
this._intervalHasRegistered = true;
|
|
@@ -74,7 +59,6 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
74
59
|
}
|
|
75
60
|
}, pressInterval);
|
|
76
61
|
}
|
|
77
|
-
|
|
78
62
|
_unregisterInterval() {
|
|
79
63
|
if (this._interval) {
|
|
80
64
|
this._intervalHasRegistered = false;
|
|
@@ -82,7 +66,6 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
82
66
|
this._interval = null;
|
|
83
67
|
}
|
|
84
68
|
}
|
|
85
|
-
|
|
86
69
|
_registerTimer(cb) {
|
|
87
70
|
const pressTimeout = this.getProp('pressTimeout') || numbers.DEFAULT_PRESS_TIMEOUT;
|
|
88
71
|
this._timerHasRegistered = true;
|
|
@@ -92,7 +75,6 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
92
75
|
}
|
|
93
76
|
}, pressTimeout);
|
|
94
77
|
}
|
|
95
|
-
|
|
96
78
|
_unregisterTimer() {
|
|
97
79
|
if (this._timer) {
|
|
98
80
|
this._timerHasRegistered = false;
|
|
@@ -100,20 +82,15 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
100
82
|
this._timer = null;
|
|
101
83
|
}
|
|
102
84
|
}
|
|
103
|
-
|
|
104
85
|
handleInputFocus(e) {
|
|
105
86
|
const value = this.getState('value');
|
|
106
|
-
|
|
107
|
-
|
|
87
|
+
if (value !== '') {
|
|
88
|
+
// let parsedStr = this.doParse(this.getState('value'));
|
|
108
89
|
// this._adapter.setValue(Number(parsedStr));
|
|
109
90
|
}
|
|
110
|
-
|
|
111
91
|
this._adapter.recordCursorPosition();
|
|
112
|
-
|
|
113
92
|
this._adapter.setFocusing(true, null);
|
|
114
|
-
|
|
115
93
|
this._adapter.setClickUpOrDown(false);
|
|
116
|
-
|
|
117
94
|
this._adapter.notifyFocus(e);
|
|
118
95
|
}
|
|
119
96
|
/**
|
|
@@ -121,23 +98,18 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
121
98
|
* @param {String} value
|
|
122
99
|
* @param {*} event
|
|
123
100
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
101
|
handleInputChange(value, event) {
|
|
127
102
|
// Check accuracy, adjust accuracy, adjust maximum and minimum values, call parser to parse the number
|
|
128
|
-
const parsedNum = this.doParse(value, true, true, true);
|
|
129
|
-
|
|
130
|
-
const toNum = this.doParse(value, false, false, false);
|
|
131
|
-
|
|
103
|
+
const parsedNum = this.doParse(value, true, true, true);
|
|
104
|
+
// Parser parsed number, type Number (normal number or NaN)
|
|
105
|
+
const toNum = this.doParse(value, false, false, false);
|
|
106
|
+
// String converted from parser parsed numbers or directly converted without parser
|
|
132
107
|
const valueAfterParser = this.afterParser(value);
|
|
133
|
-
|
|
134
108
|
this._adapter.recordCursorPosition();
|
|
135
|
-
|
|
136
109
|
let notifyVal;
|
|
137
|
-
let num = toNum;
|
|
138
|
-
|
|
110
|
+
let num = toNum;
|
|
111
|
+
// The formatted input value
|
|
139
112
|
let formattedNum = value;
|
|
140
|
-
|
|
141
113
|
if (value === '') {
|
|
142
114
|
if (!this.isControlled()) {
|
|
143
115
|
num = null;
|
|
@@ -150,13 +122,11 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
150
122
|
* This logic is used to solve the problem that parsedNum is not a valid number
|
|
151
123
|
*/
|
|
152
124
|
if (typeof toNum === 'number' && !isNaN(toNum)) {
|
|
153
|
-
formattedNum = this.doFormat(toNum, false);
|
|
154
|
-
|
|
125
|
+
formattedNum = this.doFormat(toNum, false);
|
|
126
|
+
// console.log(`parsedStr: `, parsedStr, `toNum: `, toNum);
|
|
155
127
|
const dotIndex = valueAfterParser.lastIndexOf('.');
|
|
156
128
|
const lengthAfterDot = valueAfterParser.length - 1 - dotIndex;
|
|
157
|
-
|
|
158
129
|
const precLength = this._getPrecLen(toNum);
|
|
159
|
-
|
|
160
130
|
if (!precLength) {
|
|
161
131
|
const dotBeginStr = dotIndex > -1 ? valueAfterParser.slice(dotIndex) : '';
|
|
162
132
|
formattedNum += dotBeginStr;
|
|
@@ -165,9 +135,8 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
165
135
|
for (let i = 0; i < lengthAfterDot - precLength; i++) {
|
|
166
136
|
formattedNum += '0';
|
|
167
137
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
138
|
+
}
|
|
139
|
+
// NOUSE:
|
|
171
140
|
num = toNum;
|
|
172
141
|
} else {
|
|
173
142
|
/**
|
|
@@ -179,163 +148,120 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
179
148
|
*/
|
|
180
149
|
formattedNum = this.doFormat(valueAfterParser, false);
|
|
181
150
|
}
|
|
182
|
-
|
|
183
151
|
notifyVal = valueAfterParser;
|
|
184
152
|
}
|
|
185
|
-
|
|
186
153
|
if (!this.isControlled() && (num === null || typeof num === 'number' && !isNaN(num))) {
|
|
187
154
|
this._adapter.setNumber(num);
|
|
188
155
|
}
|
|
189
|
-
|
|
190
156
|
this._adapter.setValue(this.isControlled() ? formattedNum : this.doFormat(valueAfterParser, false), () => {
|
|
191
157
|
this._adapter.restoreCursor();
|
|
192
158
|
});
|
|
193
|
-
|
|
194
159
|
this.notifyChange(notifyVal, event);
|
|
195
160
|
}
|
|
196
|
-
|
|
197
161
|
handleInputKeyDown(event) {
|
|
198
162
|
const code = event.keyCode;
|
|
199
|
-
|
|
200
163
|
if (code === keyCode.UP || code === keyCode.DOWN) {
|
|
201
164
|
this._adapter.setClickUpOrDown(true);
|
|
202
|
-
|
|
203
165
|
this._adapter.recordCursorPosition();
|
|
204
|
-
|
|
205
166
|
const formattedVal = code === keyCode.UP ? this.add(null, event) : this.minus(null, event);
|
|
206
|
-
|
|
207
167
|
this._doInput(formattedVal, event, () => {
|
|
208
168
|
this._adapter.restoreCursor();
|
|
209
169
|
});
|
|
210
|
-
|
|
211
170
|
event.preventDefault();
|
|
212
171
|
}
|
|
213
|
-
|
|
214
172
|
this._adapter.notifyKeyDown(event);
|
|
215
173
|
}
|
|
216
|
-
|
|
217
174
|
handleInputBlur(e) {
|
|
218
175
|
const currentValue = _toString(this.getState('value'));
|
|
219
|
-
|
|
220
176
|
let currentNumber = this.getState('number');
|
|
221
|
-
|
|
222
177
|
if (currentNumber != null || currentValue != null && currentValue !== '') {
|
|
223
178
|
const parsedNum = this.doParse(currentValue, false, true, true);
|
|
224
179
|
let numHasChanged = false;
|
|
225
180
|
let strHasChanged = false;
|
|
226
181
|
let willSetNum, willSetVal;
|
|
227
|
-
|
|
228
182
|
if (this.isValidNumber(parsedNum) && currentNumber !== parsedNum) {
|
|
229
183
|
willSetNum = parsedNum;
|
|
230
|
-
|
|
231
184
|
if (!this.isControlled()) {
|
|
232
185
|
currentNumber = willSetNum;
|
|
233
186
|
}
|
|
234
|
-
|
|
235
187
|
numHasChanged = true;
|
|
236
188
|
}
|
|
237
|
-
|
|
238
189
|
const currentFormattedNum = this.doFormat(currentNumber, true);
|
|
239
|
-
|
|
240
190
|
if (currentFormattedNum !== currentValue) {
|
|
241
191
|
willSetVal = currentFormattedNum;
|
|
242
192
|
strHasChanged = true;
|
|
243
193
|
}
|
|
244
|
-
|
|
245
194
|
if (strHasChanged || numHasChanged) {
|
|
246
195
|
const notifyVal = willSetVal != null ? willSetVal : willSetNum;
|
|
247
|
-
|
|
248
196
|
if (willSetVal != null) {
|
|
249
|
-
this._adapter.setValue(willSetVal);
|
|
250
|
-
|
|
197
|
+
this._adapter.setValue(willSetVal);
|
|
198
|
+
// this.notifyChange(willSetVal);
|
|
251
199
|
}
|
|
252
200
|
|
|
253
201
|
if (willSetNum != null) {
|
|
254
202
|
// eslint-disable-next-line max-depth
|
|
255
203
|
if (!this._isControlledComponent('value')) {
|
|
256
204
|
this._adapter.setNumber(willSetNum);
|
|
257
|
-
}
|
|
258
|
-
|
|
205
|
+
}
|
|
206
|
+
// this.notifyChange(willSetNum);
|
|
259
207
|
}
|
|
260
208
|
|
|
261
209
|
this.notifyChange(notifyVal, e);
|
|
262
210
|
}
|
|
263
211
|
}
|
|
264
|
-
|
|
265
212
|
this._adapter.setFocusing(false);
|
|
266
|
-
|
|
267
213
|
this._adapter.notifyBlur(e);
|
|
268
214
|
}
|
|
269
|
-
|
|
270
215
|
handleInputMouseEnter(event) {
|
|
271
216
|
this._adapter.setHovering(true);
|
|
272
217
|
}
|
|
273
|
-
|
|
274
218
|
handleInputMouseLeave(event) {
|
|
275
219
|
this._adapter.setHovering(false);
|
|
276
220
|
}
|
|
277
|
-
|
|
278
221
|
handleInputMouseMove(event) {
|
|
279
222
|
this._adapter.setHovering(true);
|
|
280
223
|
}
|
|
281
|
-
|
|
282
224
|
handleMouseUp(e) {
|
|
283
225
|
this._unregisterInterval();
|
|
284
|
-
|
|
285
226
|
this._unregisterTimer();
|
|
286
|
-
|
|
287
227
|
this._adapter.unregisterGlobalEvent('mouseup');
|
|
288
228
|
}
|
|
289
|
-
|
|
290
229
|
handleUpClick(event) {
|
|
291
230
|
const {
|
|
292
231
|
readonly
|
|
293
232
|
} = this.getProps();
|
|
294
|
-
|
|
295
233
|
if (!this._isMouseButtonLeft(event) || readonly) {
|
|
296
234
|
return;
|
|
297
235
|
}
|
|
298
|
-
|
|
299
236
|
this._adapter.setClickUpOrDown(true);
|
|
300
|
-
|
|
301
237
|
if (event) {
|
|
302
238
|
this._persistEvent(event);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
239
|
+
event.stopPropagation();
|
|
240
|
+
// Prevent native blurring events
|
|
306
241
|
this._preventDefault(event);
|
|
307
242
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
243
|
+
this.upClick(event);
|
|
244
|
+
// Cannot access event objects asynchronously https://reactjs.org/docs/events.html#event-pooling
|
|
311
245
|
this._registerTimer(() => {
|
|
312
246
|
this._registerInterval(() => {
|
|
313
247
|
this.upClick(event);
|
|
314
248
|
});
|
|
315
249
|
});
|
|
316
250
|
}
|
|
317
|
-
|
|
318
251
|
handleDownClick(event) {
|
|
319
252
|
const {
|
|
320
253
|
readonly
|
|
321
254
|
} = this.getProps();
|
|
322
|
-
|
|
323
255
|
if (!this._isMouseButtonLeft(event) || readonly) {
|
|
324
256
|
return;
|
|
325
257
|
}
|
|
326
|
-
|
|
327
258
|
this._adapter.setClickUpOrDown(true);
|
|
328
|
-
|
|
329
259
|
if (event) {
|
|
330
260
|
this._persistEvent(event);
|
|
331
|
-
|
|
332
261
|
event.stopPropagation();
|
|
333
|
-
|
|
334
262
|
this._preventDefault(event);
|
|
335
263
|
}
|
|
336
|
-
|
|
337
264
|
this.downClick(event);
|
|
338
|
-
|
|
339
265
|
this._registerTimer(() => {
|
|
340
266
|
this._registerInterval(() => {
|
|
341
267
|
this.downClick(event);
|
|
@@ -346,44 +272,31 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
346
272
|
* Whether it is a left mouse button click
|
|
347
273
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
348
274
|
*/
|
|
349
|
-
|
|
350
|
-
|
|
351
275
|
_isMouseButtonLeft(event) {
|
|
352
276
|
return _get(event, 'button') === numbers.MOUSE_BUTTON_LEFT;
|
|
353
277
|
}
|
|
354
|
-
|
|
355
278
|
_preventDefault(event) {
|
|
356
279
|
const keepFocus = this._adapter.getProp('keepFocus');
|
|
357
|
-
|
|
358
280
|
const innerButtons = this._adapter.getProp('innerButtons');
|
|
359
|
-
|
|
360
281
|
if (keepFocus || innerButtons) {
|
|
361
282
|
event.preventDefault();
|
|
362
283
|
}
|
|
363
284
|
}
|
|
364
|
-
|
|
365
285
|
handleMouseLeave(event) {
|
|
366
286
|
this._adapter.registerGlobalEvent('mouseup', () => {
|
|
367
287
|
this.handleMouseUp(event);
|
|
368
288
|
});
|
|
369
289
|
}
|
|
370
|
-
|
|
371
290
|
upClick(event) {
|
|
372
291
|
const value = this.add(null, event);
|
|
373
|
-
|
|
374
292
|
this._doInput(value, event);
|
|
375
|
-
|
|
376
293
|
this._adapter.notifyUpClick(value, event);
|
|
377
294
|
}
|
|
378
|
-
|
|
379
295
|
downClick(event) {
|
|
380
296
|
const value = this.minus(null, event);
|
|
381
|
-
|
|
382
297
|
this._doInput(value, event);
|
|
383
|
-
|
|
384
298
|
this._adapter.notifyDownClick(value, event);
|
|
385
299
|
}
|
|
386
|
-
|
|
387
300
|
_setInitValue() {
|
|
388
301
|
const {
|
|
389
302
|
defaultValue,
|
|
@@ -392,22 +305,16 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
392
305
|
const propsValue = this._isControlledComponent('value') ? value : defaultValue;
|
|
393
306
|
const tmpNumber = this.doParse(_toString(propsValue), false, true, true);
|
|
394
307
|
let number = null;
|
|
395
|
-
|
|
396
308
|
if (typeof tmpNumber === 'number' && !isNaN(tmpNumber)) {
|
|
397
309
|
number = tmpNumber;
|
|
398
310
|
}
|
|
399
|
-
|
|
400
311
|
const formattedValue = typeof number === 'number' ? this.doFormat(number, true) : '';
|
|
401
|
-
|
|
402
312
|
this._adapter.setNumber(number);
|
|
403
|
-
|
|
404
313
|
this._adapter.setValue(formattedValue);
|
|
405
|
-
|
|
406
314
|
if (_isString(formattedValue) && formattedValue !== String(propsValue !== null && propsValue !== void 0 ? propsValue : '')) {
|
|
407
315
|
this.notifyChange(formattedValue, null);
|
|
408
316
|
}
|
|
409
317
|
}
|
|
410
|
-
|
|
411
318
|
add(step, event) {
|
|
412
319
|
const pressShift = event && event.shiftKey;
|
|
413
320
|
const propStep = pressShift ? this.getProp('shiftStep') : this.getProp('step');
|
|
@@ -417,17 +324,11 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
417
324
|
let curNum = this.toNumber(curVal) || 0;
|
|
418
325
|
const min = this.getProp('min');
|
|
419
326
|
const max = this.getProp('max');
|
|
420
|
-
|
|
421
327
|
const minPrecLen = this._getPrecLen(min);
|
|
422
|
-
|
|
423
328
|
const maxPrecLen = this._getPrecLen(max);
|
|
424
|
-
|
|
425
329
|
const curPrecLen = this._getPrecLen(curNum);
|
|
426
|
-
|
|
427
330
|
const stepPrecLen = this._getPrecLen(step);
|
|
428
|
-
|
|
429
331
|
const scale = Math.pow(10, Math.max(minPrecLen, maxPrecLen, curPrecLen, stepPrecLen));
|
|
430
|
-
|
|
431
332
|
if (step < 0) {
|
|
432
333
|
// Js accuracy problem
|
|
433
334
|
if (Math.abs(numberMinus(min, curNum)) >= stepAbs) {
|
|
@@ -438,19 +339,15 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
438
339
|
curNum = (curNum * scale + step * scale) / scale;
|
|
439
340
|
}
|
|
440
341
|
}
|
|
441
|
-
|
|
442
342
|
if (typeof min === 'number' && min > curNum) {
|
|
443
343
|
curNum = min;
|
|
444
344
|
}
|
|
445
|
-
|
|
446
345
|
if (typeof max === 'number' && max < curNum) {
|
|
447
346
|
curNum = max;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
347
|
+
}
|
|
348
|
+
// console.log('scale: ', scale, 'curNum: ', curNum);
|
|
451
349
|
return this.doFormat(curNum, true);
|
|
452
350
|
}
|
|
453
|
-
|
|
454
351
|
minus(step, event) {
|
|
455
352
|
const pressShift = event && event.shiftKey;
|
|
456
353
|
const propStep = pressShift ? this.getProp('shiftStep') : this.getProp('step');
|
|
@@ -462,24 +359,18 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
462
359
|
* @param {number} num
|
|
463
360
|
* @returns {number}
|
|
464
361
|
*/
|
|
465
|
-
|
|
466
|
-
|
|
467
362
|
_getPrecLen(num) {
|
|
468
363
|
if (typeof num !== 'string') {
|
|
469
364
|
num = String(Math.abs(Number(num || '')));
|
|
470
365
|
}
|
|
471
|
-
|
|
472
366
|
const idx = num.indexOf('.') + 1;
|
|
473
367
|
return idx ? num.length - idx : 0;
|
|
474
368
|
}
|
|
475
|
-
|
|
476
369
|
_adjustPrec(num) {
|
|
477
370
|
const precision = this.getProp('precision');
|
|
478
|
-
|
|
479
371
|
if (typeof precision === 'number' && num !== '' && num !== null && !Number.isNaN(Number(num))) {
|
|
480
372
|
num = Number(num).toFixed(precision);
|
|
481
373
|
}
|
|
482
|
-
|
|
483
374
|
return _toString(num);
|
|
484
375
|
}
|
|
485
376
|
/**
|
|
@@ -488,8 +379,6 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
488
379
|
* @param {boolean} needAdjustPrec
|
|
489
380
|
* @returns {string}
|
|
490
381
|
*/
|
|
491
|
-
|
|
492
|
-
|
|
493
382
|
doFormat() {
|
|
494
383
|
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
495
384
|
let needAdjustPrec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
@@ -498,17 +387,14 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
498
387
|
// }
|
|
499
388
|
let str;
|
|
500
389
|
const formatter = this.getProp('formatter');
|
|
501
|
-
|
|
502
390
|
if (needAdjustPrec) {
|
|
503
391
|
str = this._adjustPrec(value);
|
|
504
392
|
} else {
|
|
505
393
|
str = _toString(value);
|
|
506
394
|
}
|
|
507
|
-
|
|
508
395
|
if (typeof formatter === 'function') {
|
|
509
396
|
str = formatter(str);
|
|
510
397
|
}
|
|
511
|
-
|
|
512
398
|
return str;
|
|
513
399
|
}
|
|
514
400
|
/**
|
|
@@ -516,20 +402,16 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
516
402
|
* @param {number} current
|
|
517
403
|
* @returns {number}
|
|
518
404
|
*/
|
|
519
|
-
|
|
520
|
-
|
|
521
405
|
fetchMinOrMax(current) {
|
|
522
406
|
const {
|
|
523
407
|
min,
|
|
524
408
|
max
|
|
525
409
|
} = this.getProps();
|
|
526
|
-
|
|
527
410
|
if (current < min) {
|
|
528
411
|
return min;
|
|
529
412
|
} else if (current > max) {
|
|
530
413
|
return max;
|
|
531
414
|
}
|
|
532
|
-
|
|
533
415
|
return current;
|
|
534
416
|
}
|
|
535
417
|
/**
|
|
@@ -540,49 +422,38 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
540
422
|
* @param {boolean} needAdjustMaxMin
|
|
541
423
|
* @returns {number}
|
|
542
424
|
*/
|
|
543
|
-
|
|
544
|
-
|
|
545
425
|
doParse(value) {
|
|
546
426
|
let needCheckPrec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
547
427
|
let needAdjustPrec = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
548
428
|
let needAdjustMaxMin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
549
|
-
|
|
550
429
|
if (typeof value === 'number') {
|
|
551
430
|
if (needAdjustMaxMin) {
|
|
552
431
|
value = this.fetchMinOrMax(value);
|
|
553
432
|
}
|
|
554
|
-
|
|
555
433
|
if (needAdjustPrec) {
|
|
556
434
|
value = this._adjustPrec(value);
|
|
557
435
|
}
|
|
558
|
-
|
|
559
436
|
return _toNumber(value);
|
|
560
437
|
}
|
|
561
|
-
|
|
562
438
|
const parser = this.getProp('parser');
|
|
563
|
-
|
|
564
439
|
if (typeof parser === 'function') {
|
|
565
440
|
value = parser(value);
|
|
566
441
|
}
|
|
567
|
-
|
|
568
442
|
if (needCheckPrec && typeof value === 'string') {
|
|
569
443
|
const zeroIsValid = value.indexOf('.') === -1 || value.indexOf('.') > -1 && (value === '0' || value.lastIndexOf('0') < value.length - 1);
|
|
570
444
|
const dotIsValid = value.lastIndexOf('.') < value.length - 1 && value.split('').filter(v => v === '.').length < 2;
|
|
571
|
-
|
|
572
|
-
|
|
445
|
+
if (!zeroIsValid || !dotIsValid
|
|
446
|
+
// (this.getProp('precision') > 0 && this._getPrecLen(value) > this.getProp('precision'))
|
|
573
447
|
) {
|
|
574
448
|
return NaN;
|
|
575
449
|
}
|
|
576
450
|
}
|
|
577
|
-
|
|
578
451
|
if (needAdjustPrec) {
|
|
579
452
|
value = this._adjustPrec(value);
|
|
580
453
|
}
|
|
581
|
-
|
|
582
454
|
if (typeof value === 'string' && value.length) {
|
|
583
455
|
return needAdjustMaxMin ? this.fetchMinOrMax(_toNumber(value)) : _toNumber(value);
|
|
584
456
|
}
|
|
585
|
-
|
|
586
457
|
return NaN;
|
|
587
458
|
}
|
|
588
459
|
/**
|
|
@@ -590,37 +461,27 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
590
461
|
* @param {string} value
|
|
591
462
|
* @returns {string}
|
|
592
463
|
*/
|
|
593
|
-
|
|
594
|
-
|
|
595
464
|
afterParser(value) {
|
|
596
465
|
const parser = this.getProp('parser');
|
|
597
|
-
|
|
598
466
|
if (typeof value === 'string' && typeof parser === 'function') {
|
|
599
467
|
return _toString(parser(value));
|
|
600
468
|
}
|
|
601
|
-
|
|
602
469
|
return _toString(value);
|
|
603
470
|
}
|
|
604
|
-
|
|
605
471
|
toNumber(value) {
|
|
606
472
|
let needAdjustPrec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
607
|
-
|
|
608
473
|
if (typeof value === 'number') {
|
|
609
474
|
return value;
|
|
610
475
|
}
|
|
611
|
-
|
|
612
476
|
if (typeof value === 'string') {
|
|
613
477
|
const parser = this.getProp('parser');
|
|
614
|
-
|
|
615
478
|
if (typeof parser === 'function') {
|
|
616
479
|
value = parser(value);
|
|
617
480
|
}
|
|
618
|
-
|
|
619
481
|
if (needAdjustPrec) {
|
|
620
482
|
value = this._adjustPrec(value);
|
|
621
483
|
}
|
|
622
484
|
}
|
|
623
|
-
|
|
624
485
|
return _toNumber(value);
|
|
625
486
|
}
|
|
626
487
|
/**
|
|
@@ -632,70 +493,54 @@ class InputNumberFoundation extends BaseFoundation {
|
|
|
632
493
|
* @param {*} needCheckPrec
|
|
633
494
|
* @returns
|
|
634
495
|
*/
|
|
635
|
-
|
|
636
|
-
|
|
637
496
|
isValidNumber(num) {
|
|
638
497
|
let needCheckPrec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
639
|
-
|
|
640
498
|
if (typeof num === 'number' && !isNaN(num)) {
|
|
641
499
|
const {
|
|
642
500
|
min,
|
|
643
501
|
max,
|
|
644
502
|
precision
|
|
645
503
|
} = this.getProps();
|
|
646
|
-
|
|
647
504
|
const numPrec = this._getPrecLen(num);
|
|
648
|
-
|
|
649
505
|
const precIsValid = needCheckPrec ? typeof precision === 'number' && numPrec <= precision || typeof precision !== 'number' : true;
|
|
650
|
-
|
|
651
506
|
if (num >= min && num <= max && precIsValid) {
|
|
652
507
|
return true;
|
|
653
508
|
}
|
|
654
509
|
}
|
|
655
|
-
|
|
656
510
|
return false;
|
|
657
511
|
}
|
|
658
|
-
|
|
659
512
|
isValidString(str) {
|
|
660
513
|
if (typeof str === 'string' && str.length) {
|
|
661
514
|
const parsedNum = this.doParse(str);
|
|
662
515
|
return this.isValidNumber(parsedNum);
|
|
663
516
|
}
|
|
664
|
-
|
|
665
517
|
return false;
|
|
666
518
|
}
|
|
667
|
-
|
|
668
519
|
notifyChange(value, e) {
|
|
669
520
|
if (value == null || value === '') {
|
|
670
521
|
this._adapter.notifyChange('', e);
|
|
671
522
|
} else {
|
|
672
523
|
const parsedNum = this.toNumber(value, true);
|
|
673
|
-
|
|
674
524
|
if (typeof parsedNum === 'number' && !isNaN(parsedNum)) {
|
|
675
525
|
// this._adapter.notifyChange(typeof value === 'number' ? parsedNum : this.afterParser(value), e);
|
|
676
526
|
this._adapter.notifyChange(parsedNum, e);
|
|
677
|
-
|
|
678
527
|
this.notifyNumberChange(parsedNum, e);
|
|
679
528
|
} else {
|
|
680
529
|
this._adapter.notifyChange(this.afterParser(value), e);
|
|
681
530
|
}
|
|
682
531
|
}
|
|
683
532
|
}
|
|
684
|
-
|
|
685
533
|
notifyNumberChange(value, e) {
|
|
686
534
|
const {
|
|
687
535
|
number
|
|
688
|
-
} = this.getStates();
|
|
689
|
-
|
|
536
|
+
} = this.getStates();
|
|
537
|
+
// Does not trigger numberChange if value is not a significant number
|
|
690
538
|
if (this.isValidNumber(value) && value !== number) {
|
|
691
539
|
this._adapter.notifyNumberChange(value, e);
|
|
692
540
|
}
|
|
693
541
|
}
|
|
694
|
-
|
|
695
542
|
updateStates(states, callback) {
|
|
696
543
|
this._adapter.updateStates(states, callback);
|
|
697
544
|
}
|
|
698
|
-
|
|
699
545
|
}
|
|
700
|
-
|
|
701
546
|
export default InputNumberFoundation;
|