@douyinfe/semi-foundation 2.36.0-alpha.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/calendar.scss +1 -1
- package/calendar/foundation.ts +2 -1
- package/datePicker/_utils/getYears.ts +8 -4
- package/datePicker/foundation.ts +1 -1
- package/datePicker/monthsGridFoundation.ts +2 -1
- package/datePicker/yearAndMonthFoundation.ts +3 -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/calendar.css +2 -2
- package/lib/cjs/calendar/calendar.scss +1 -1
- 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.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/getYears.js +9 -7
- 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 +25 -25
- 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 +5 -4
- package/lib/cjs/datePicker/monthsGridFoundation.js +43 -238
- package/lib/cjs/datePicker/yearAndMonthFoundation.d.ts +3 -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.d.ts +0 -2
- package/lib/cjs/navigation/itemFoundation.js +3 -21
- package/lib/cjs/navigation/navigation.css +7 -77
- package/lib/cjs/navigation/navigation.scss +7 -119
- package/lib/cjs/navigation/subNavFoundation.d.ts +0 -2
- 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/bacisSteps.scss +238 -287
- package/lib/cjs/steps/constants.js +0 -2
- package/lib/cjs/steps/fillSteps.scss +142 -153
- package/lib/cjs/steps/navSteps.scss +40 -61
- package/lib/cjs/steps/steps.css +17 -381
- 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 +72 -302
- package/lib/cjs/table/table.css +6 -0
- package/lib/cjs/table/table.scss +12 -0
- 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/tabs/tabs.css +14 -14
- package/lib/cjs/tabs/tabs.scss +16 -14
- 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 +2 -2
- package/lib/cjs/timePicker/foundation.js +6 -102
- 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/timeline/timeline.css +0 -36
- package/lib/cjs/timeline/timeline.scss +46 -96
- 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.d.ts +1 -0
- package/lib/cjs/typography/constants.js +1 -2
- package/lib/cjs/typography/formatNumeral.d.ts +3 -3
- package/lib/cjs/typography/formatNumeral.js +16 -32
- package/lib/cjs/typography/typography.css +120 -0
- package/lib/cjs/typography/typography.scss +131 -6
- package/lib/cjs/typography/variables.scss +48 -0
- 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/calendar.css +2 -2
- package/lib/es/calendar/calendar.scss +1 -1
- 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.d.ts +1 -1
- package/lib/es/datePicker/_utils/getYears.js +9 -6
- 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 +25 -25
- 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 +5 -4
- package/lib/es/datePicker/monthsGridFoundation.js +42 -222
- package/lib/es/datePicker/yearAndMonthFoundation.d.ts +3 -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.d.ts +0 -2
- package/lib/es/navigation/itemFoundation.js +3 -18
- package/lib/es/navigation/navigation.css +7 -77
- package/lib/es/navigation/navigation.scss +7 -119
- package/lib/es/navigation/subNavFoundation.d.ts +0 -2
- 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/steps/bacisSteps.scss +238 -287
- package/lib/es/steps/fillSteps.scss +142 -153
- package/lib/es/steps/navSteps.scss +40 -61
- package/lib/es/steps/steps.css +17 -381
- 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 +72 -309
- package/lib/es/table/table.css +6 -0
- package/lib/es/table/table.scss +12 -0
- 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/tabs/tabs.css +14 -14
- package/lib/es/tabs/tabs.scss +16 -14
- 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 +2 -2
- package/lib/es/timePicker/foundation.js +7 -95
- 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/timeline/timeline.css +0 -36
- package/lib/es/timeline/timeline.scss +46 -96
- 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/constants.d.ts +1 -0
- package/lib/es/typography/constants.js +1 -0
- package/lib/es/typography/formatNumeral.d.ts +3 -3
- package/lib/es/typography/formatNumeral.js +16 -29
- package/lib/es/typography/typography.css +120 -0
- package/lib/es/typography/typography.scss +131 -6
- package/lib/es/typography/variables.scss +48 -0
- 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/navigation/itemFoundation.ts +1 -3
- package/navigation/navigation.scss +7 -119
- package/navigation/subNavFoundation.ts +1 -3
- package/overflowList/foundation.ts +4 -4
- package/package.json +2 -2
- package/steps/bacisSteps.scss +238 -287
- package/steps/fillSteps.scss +142 -153
- package/steps/navSteps.scss +40 -61
- package/table/foundation.ts +8 -10
- package/table/table.scss +12 -0
- package/tabs/tabs.scss +16 -14
- package/timePicker/foundation.ts +4 -6
- package/timeline/timeline.scss +46 -96
- package/typography/constants.ts +1 -0
- package/typography/typography.scss +131 -6
- package/typography/variables.scss +48 -0
- package/upload/foundation.ts +8 -8
|
@@ -4,7 +4,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
4
4
|
resolve(value);
|
|
5
5
|
});
|
|
6
6
|
}
|
|
7
|
-
|
|
8
7
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
8
|
function fulfilled(value) {
|
|
10
9
|
try {
|
|
@@ -13,7 +12,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
13
12
|
reject(e);
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
function rejected(value) {
|
|
18
16
|
try {
|
|
19
17
|
step(generator["throw"](value));
|
|
@@ -21,15 +19,12 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
21
19
|
reject(e);
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
function step(result) {
|
|
26
23
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
26
|
});
|
|
31
27
|
};
|
|
32
|
-
|
|
33
28
|
import BaseFoundation from '../base/foundation';
|
|
34
29
|
import isPromise from '../utils/isPromise';
|
|
35
30
|
import { getUuidv4 } from '../utils/uuid';
|
|
@@ -45,16 +40,13 @@ const {
|
|
|
45
40
|
DRAG_AREA_LEGAL,
|
|
46
41
|
TRIGGER_AUTO
|
|
47
42
|
} = strings;
|
|
48
|
-
|
|
49
43
|
class UploadFoundation extends BaseFoundation {
|
|
50
44
|
constructor(adapter) {
|
|
51
45
|
super(Object.assign({}, adapter));
|
|
52
46
|
}
|
|
53
|
-
|
|
54
47
|
destroy() {
|
|
55
48
|
this.releaseMemory();
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
getError(_ref) {
|
|
59
51
|
let {
|
|
60
52
|
action,
|
|
@@ -70,25 +62,20 @@ class UploadFoundation extends BaseFoundation {
|
|
|
70
62
|
err.url = action;
|
|
71
63
|
return err;
|
|
72
64
|
}
|
|
73
|
-
|
|
74
65
|
getBody(xhr) {
|
|
75
66
|
if (!xhr) {
|
|
76
67
|
return;
|
|
77
68
|
}
|
|
78
|
-
|
|
79
69
|
const text = xhr.responseText || xhr.response;
|
|
80
|
-
|
|
81
70
|
if (!text) {
|
|
82
71
|
return text;
|
|
83
72
|
}
|
|
84
|
-
|
|
85
73
|
try {
|
|
86
74
|
return JSON.parse(text);
|
|
87
75
|
} catch (error) {
|
|
88
76
|
return text;
|
|
89
77
|
}
|
|
90
78
|
}
|
|
91
|
-
|
|
92
79
|
checkFileSize(file) {
|
|
93
80
|
const {
|
|
94
81
|
size
|
|
@@ -98,11 +85,9 @@ class UploadFoundation extends BaseFoundation {
|
|
|
98
85
|
minSize
|
|
99
86
|
} = this.getProps();
|
|
100
87
|
let isIllegal = false;
|
|
101
|
-
|
|
102
88
|
if (size > maxSize * byteKB || size < minSize * byteKB) {
|
|
103
89
|
isIllegal = true;
|
|
104
90
|
}
|
|
105
|
-
|
|
106
91
|
return isIllegal;
|
|
107
92
|
}
|
|
108
93
|
/**
|
|
@@ -134,8 +119,6 @@ class UploadFoundation extends BaseFoundation {
|
|
|
134
119
|
* 8. TODO: check
|
|
135
120
|
* 9. afterUpload
|
|
136
121
|
*/
|
|
137
|
-
|
|
138
|
-
|
|
139
122
|
handleChange(currentFileList) {
|
|
140
123
|
const invalidFiles = [];
|
|
141
124
|
const {
|
|
@@ -147,83 +130,62 @@ class UploadFoundation extends BaseFoundation {
|
|
|
147
130
|
fileList
|
|
148
131
|
} = this.getStates();
|
|
149
132
|
let files = Array.from(currentFileList); // When the selected file
|
|
150
|
-
|
|
151
133
|
if (typeof accept !== 'undefined') {
|
|
152
134
|
files = files.filter(item => {
|
|
153
135
|
const isValid = this.checkFileFormat(accept, item);
|
|
154
|
-
|
|
155
136
|
if (!isValid) {
|
|
156
137
|
invalidFiles.push(item);
|
|
157
138
|
}
|
|
158
|
-
|
|
159
139
|
return isValid;
|
|
160
140
|
});
|
|
161
|
-
|
|
162
141
|
if (invalidFiles.length !== 0) {
|
|
163
142
|
this._adapter.notifyAcceptInvalid(invalidFiles);
|
|
164
143
|
}
|
|
165
|
-
|
|
166
144
|
if (files.length === 0) {
|
|
167
145
|
return;
|
|
168
146
|
}
|
|
169
147
|
}
|
|
170
|
-
|
|
171
148
|
files = files.map(file => {
|
|
172
149
|
if (transformFile) {
|
|
173
150
|
file = transformFile(file);
|
|
174
151
|
}
|
|
175
|
-
|
|
176
152
|
if (!file.uid) {
|
|
177
153
|
file.uid = getUuidv4();
|
|
178
154
|
}
|
|
179
|
-
|
|
180
155
|
if (this.checkFileSize(file)) {
|
|
181
156
|
file._sizeInvalid = true;
|
|
182
157
|
file.status = FILE_STATUS_VALID_FAIL;
|
|
183
|
-
|
|
184
158
|
this._adapter.notifySizeError(file, fileList);
|
|
185
159
|
}
|
|
186
|
-
|
|
187
160
|
return file;
|
|
188
161
|
});
|
|
189
162
|
const total = fileList.length + files.length;
|
|
190
|
-
|
|
191
163
|
if (typeof limit !== 'undefined') {
|
|
192
164
|
// Determine whether the limit is exceeded
|
|
193
165
|
if (total > limit) {
|
|
194
166
|
this._adapter.notifyExceed(files);
|
|
195
|
-
|
|
196
167
|
if (limit === 1) {
|
|
197
168
|
// Replace the current file with the last file
|
|
198
169
|
files = files.slice(-1);
|
|
199
|
-
|
|
200
170
|
this._adapter.notifyFileSelect(files);
|
|
201
|
-
|
|
202
171
|
this._adapter.resetInput();
|
|
203
|
-
|
|
204
172
|
this.replaceFileList(files);
|
|
205
173
|
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
174
|
+
}
|
|
175
|
+
// If the limit is exceeded, the calculation can add a few more files and continue uploading the remaining files
|
|
209
176
|
const restNum = limit - fileList.length;
|
|
210
177
|
files = files.slice(0, restNum);
|
|
211
178
|
}
|
|
212
179
|
}
|
|
213
|
-
|
|
214
180
|
this._adapter.notifyFileSelect(files);
|
|
215
|
-
|
|
216
181
|
this._adapter.resetInput();
|
|
217
|
-
|
|
218
182
|
this.addFilesToList(files);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
183
|
+
}
|
|
184
|
+
// Triggered when replacing a single file
|
|
222
185
|
handleReplaceChange(currentFileList) {
|
|
223
186
|
if (currentFileList.length === 0) {
|
|
224
187
|
return;
|
|
225
188
|
}
|
|
226
|
-
|
|
227
189
|
const {
|
|
228
190
|
transformFile,
|
|
229
191
|
uploadTrigger,
|
|
@@ -234,60 +196,46 @@ class UploadFoundation extends BaseFoundation {
|
|
|
234
196
|
fileList
|
|
235
197
|
} = this.getStates();
|
|
236
198
|
let newFile = Array.from(currentFileList).pop();
|
|
237
|
-
|
|
238
199
|
if (typeof accept !== 'undefined') {
|
|
239
200
|
if (!this.checkFileFormat(accept, newFile)) {
|
|
240
201
|
this._adapter.notifyAcceptInvalid([newFile]);
|
|
241
|
-
|
|
242
202
|
return;
|
|
243
203
|
}
|
|
244
204
|
}
|
|
245
|
-
|
|
246
205
|
if (transformFile) {
|
|
247
206
|
newFile = transformFile(newFile);
|
|
248
207
|
}
|
|
249
|
-
|
|
250
208
|
if (!newFile.uid) {
|
|
251
209
|
newFile.uid = getUuidv4();
|
|
252
210
|
}
|
|
253
|
-
|
|
254
211
|
if (this.checkFileSize(newFile)) {
|
|
255
212
|
newFile._sizeInvalid = true;
|
|
256
213
|
newFile.status = FILE_STATUS_VALID_FAIL;
|
|
257
|
-
|
|
258
214
|
this._adapter.notifySizeError(newFile, fileList);
|
|
259
215
|
}
|
|
260
|
-
|
|
261
216
|
this._adapter.notifyFileSelect([newFile]);
|
|
262
|
-
|
|
263
217
|
const newFileItem = this.buildFileItem(newFile, uploadTrigger);
|
|
264
218
|
const newFileList = [...fileList];
|
|
265
219
|
newFileList.splice(replaceIdx, 1, newFileItem);
|
|
266
|
-
|
|
267
220
|
this._adapter.notifyChange({
|
|
268
221
|
currentFile: newFileItem,
|
|
269
222
|
fileList: newFileList
|
|
270
223
|
});
|
|
271
|
-
|
|
272
224
|
this._adapter.updateFileList(newFileList, () => {
|
|
273
225
|
this._adapter.resetReplaceInput();
|
|
274
|
-
|
|
275
226
|
this.upload(newFileItem);
|
|
276
227
|
});
|
|
277
228
|
}
|
|
278
|
-
|
|
279
229
|
buildFileItem(fileInstance, uploadTrigger) {
|
|
280
230
|
const {
|
|
281
231
|
_sizeInvalid,
|
|
282
232
|
status
|
|
283
233
|
} = fileInstance;
|
|
284
|
-
|
|
285
234
|
try {
|
|
286
235
|
// can't use ... to get rest property on File Object
|
|
287
236
|
delete fileInstance._sizeInvalid;
|
|
288
237
|
delete fileInstance.status;
|
|
289
238
|
} catch (error) {}
|
|
290
|
-
|
|
291
239
|
const _file = {
|
|
292
240
|
status: status ? status : uploadTrigger === TRIGGER_AUTO ? FILE_STATUS_UPLOADING : FILE_STATUS_WAIT_UPLOAD,
|
|
293
241
|
name: fileInstance.name,
|
|
@@ -297,37 +245,30 @@ class UploadFoundation extends BaseFoundation {
|
|
|
297
245
|
fileInstance,
|
|
298
246
|
url: this._createURL(fileInstance)
|
|
299
247
|
};
|
|
300
|
-
|
|
301
248
|
if (_sizeInvalid) {
|
|
302
249
|
_file._sizeInvalid = true;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
250
|
+
}
|
|
251
|
+
// If it is an image, preview; if it is a pdf, you can jump to
|
|
306
252
|
if (this.isImage(fileInstance)) {
|
|
307
253
|
_file.preview = true;
|
|
308
254
|
}
|
|
309
|
-
|
|
310
255
|
return _file;
|
|
311
256
|
}
|
|
312
|
-
|
|
313
257
|
replaceFileList(files) {
|
|
314
258
|
const {
|
|
315
259
|
uploadTrigger
|
|
316
260
|
} = this.getProps();
|
|
317
261
|
const currentFiles = files.map(item => this.buildFileItem(item, uploadTrigger));
|
|
318
|
-
|
|
319
262
|
this._adapter.notifyChange({
|
|
320
263
|
fileList: currentFiles,
|
|
321
264
|
currentFile: currentFiles[0]
|
|
322
265
|
});
|
|
323
|
-
|
|
324
266
|
this._adapter.updateFileList(currentFiles, () => {
|
|
325
267
|
if (uploadTrigger === TRIGGER_AUTO) {
|
|
326
268
|
this.startUpload(currentFiles);
|
|
327
269
|
}
|
|
328
270
|
});
|
|
329
271
|
}
|
|
330
|
-
|
|
331
272
|
addFilesToList(files) {
|
|
332
273
|
const fileList = this.getState('fileList').slice();
|
|
333
274
|
const {
|
|
@@ -336,28 +277,24 @@ class UploadFoundation extends BaseFoundation {
|
|
|
336
277
|
const currentFiles = files.map(item => this.buildFileItem(item, uploadTrigger));
|
|
337
278
|
currentFiles.forEach(file => {
|
|
338
279
|
const index = fileList.findIndex(item => item.uid === file.uid);
|
|
339
|
-
|
|
340
280
|
if (index !== -1) {
|
|
341
281
|
fileList[index] = file;
|
|
342
282
|
} else {
|
|
343
283
|
fileList.push(file);
|
|
344
|
-
|
|
345
284
|
this._adapter.notifyChange({
|
|
346
285
|
fileList,
|
|
347
286
|
currentFile: file
|
|
348
287
|
});
|
|
349
288
|
}
|
|
350
289
|
});
|
|
351
|
-
|
|
352
290
|
this._adapter.updateFileList(fileList, () => {
|
|
353
291
|
if (uploadTrigger === TRIGGER_AUTO) {
|
|
354
292
|
this.startUpload(currentFiles);
|
|
355
293
|
}
|
|
356
294
|
});
|
|
357
|
-
}
|
|
295
|
+
}
|
|
296
|
+
// 插入多个文件到指定位置
|
|
358
297
|
// Insert files to the specified location
|
|
359
|
-
|
|
360
|
-
|
|
361
298
|
insertFileToList(files, index) {
|
|
362
299
|
const {
|
|
363
300
|
limit,
|
|
@@ -368,51 +305,40 @@ class UploadFoundation extends BaseFoundation {
|
|
|
368
305
|
const {
|
|
369
306
|
fileList
|
|
370
307
|
} = this.getStates();
|
|
371
|
-
const unAcceptFileList = [];
|
|
308
|
+
const unAcceptFileList = [];
|
|
309
|
+
// 当次选中的文件
|
|
372
310
|
// current selected file
|
|
373
|
-
|
|
374
311
|
let currentFileList = Array.from(files);
|
|
375
|
-
|
|
376
312
|
if (typeof accept !== 'undefined') {
|
|
377
313
|
currentFileList = currentFileList.filter(item => {
|
|
378
314
|
const isValid = this.checkFileFormat(accept, item);
|
|
379
|
-
|
|
380
315
|
if (!isValid) {
|
|
381
316
|
unAcceptFileList.push(item);
|
|
382
317
|
}
|
|
383
|
-
|
|
384
318
|
return isValid;
|
|
385
319
|
});
|
|
386
|
-
|
|
387
320
|
if (unAcceptFileList.length !== 0) {
|
|
388
321
|
this._adapter.notifyAcceptInvalid(unAcceptFileList);
|
|
389
322
|
}
|
|
390
|
-
|
|
391
323
|
if (currentFileList.length === 0) {
|
|
392
324
|
return;
|
|
393
325
|
}
|
|
394
326
|
}
|
|
395
|
-
|
|
396
327
|
currentFileList = currentFileList.map(file => {
|
|
397
328
|
if (!file.uid) {
|
|
398
329
|
file.uid = getUuidv4();
|
|
399
330
|
}
|
|
400
|
-
|
|
401
331
|
if (this.checkFileSize(file)) {
|
|
402
332
|
file._sizeInvalid = true;
|
|
403
333
|
file.status = FILE_STATUS_VALID_FAIL;
|
|
404
|
-
|
|
405
334
|
this._adapter.notifySizeError(file, fileList);
|
|
406
335
|
}
|
|
407
|
-
|
|
408
336
|
if (transformFile) {
|
|
409
337
|
file = transformFile(file);
|
|
410
338
|
}
|
|
411
|
-
|
|
412
339
|
return file;
|
|
413
340
|
});
|
|
414
341
|
const total = fileList.length + currentFileList.length;
|
|
415
|
-
|
|
416
342
|
if (typeof limit !== 'undefined') {
|
|
417
343
|
// 判断是否超出限制
|
|
418
344
|
// Determine whether the limit is exceeded
|
|
@@ -421,40 +347,30 @@ class UploadFoundation extends BaseFoundation {
|
|
|
421
347
|
// 使用最后面的文件对当前文件进行替换
|
|
422
348
|
// Use the last file to replace the current file
|
|
423
349
|
currentFileList = currentFileList.slice(-1);
|
|
424
|
-
|
|
425
350
|
this._adapter.notifyFileSelect(currentFileList);
|
|
426
|
-
|
|
427
351
|
this._adapter.resetInput();
|
|
428
|
-
|
|
429
352
|
this.replaceFileList(currentFileList);
|
|
430
353
|
return;
|
|
431
|
-
}
|
|
354
|
+
}
|
|
355
|
+
// 如果超出了限制,则计算还能添加几个文件,将剩余的文件继续上传
|
|
432
356
|
// If the limit is exceeded, several files can be added to the calculation, and the remaining files will continue to be uploaded
|
|
433
|
-
|
|
434
|
-
|
|
435
357
|
const restNum = limit - fileList.length;
|
|
436
358
|
currentFileList = currentFileList.slice(0, restNum);
|
|
437
|
-
|
|
438
359
|
this._adapter.notifyExceed(currentFileList);
|
|
439
360
|
}
|
|
440
361
|
}
|
|
441
|
-
|
|
442
362
|
const fileItemList = currentFileList.map(file => this.buildFileItem(file, uploadTrigger));
|
|
443
363
|
const newFileList = fileList.slice();
|
|
444
|
-
|
|
445
364
|
if (typeof index !== 'undefined') {
|
|
446
365
|
newFileList.splice(index, 0, ...fileItemList);
|
|
447
366
|
} else {
|
|
448
367
|
newFileList.push(...fileItemList);
|
|
449
368
|
}
|
|
450
|
-
|
|
451
369
|
this._adapter.notifyFileSelect(currentFileList);
|
|
452
|
-
|
|
453
370
|
this._adapter.notifyChange({
|
|
454
371
|
fileList: newFileList,
|
|
455
372
|
currentFile: null
|
|
456
373
|
});
|
|
457
|
-
|
|
458
374
|
this._adapter.updateFileList(newFileList, () => {
|
|
459
375
|
if (uploadTrigger === TRIGGER_AUTO) {
|
|
460
376
|
this.startUpload(fileItemList);
|
|
@@ -462,14 +378,11 @@ class UploadFoundation extends BaseFoundation {
|
|
|
462
378
|
});
|
|
463
379
|
}
|
|
464
380
|
/* istanbul ignore next */
|
|
465
|
-
|
|
466
|
-
|
|
467
381
|
manualUpload() {
|
|
468
382
|
// find the list of files that have not been uploaded
|
|
469
383
|
const waitToUploadFileList = this.getState('fileList').filter(item => item.status === FILE_STATUS_WAIT_UPLOAD);
|
|
470
384
|
this.startUpload(waitToUploadFileList);
|
|
471
385
|
}
|
|
472
|
-
|
|
473
386
|
startUpload(fileList) {
|
|
474
387
|
fileList.forEach(file => {
|
|
475
388
|
if (!file._sizeInvalid) {
|
|
@@ -477,27 +390,22 @@ class UploadFoundation extends BaseFoundation {
|
|
|
477
390
|
}
|
|
478
391
|
});
|
|
479
392
|
}
|
|
480
|
-
|
|
481
393
|
upload(file) {
|
|
482
394
|
const {
|
|
483
395
|
beforeUpload
|
|
484
396
|
} = this.getProps();
|
|
485
|
-
|
|
486
397
|
if (typeof beforeUpload === 'undefined') {
|
|
487
398
|
this.post(file);
|
|
488
399
|
return;
|
|
489
400
|
}
|
|
490
|
-
|
|
491
401
|
if (typeof beforeUpload === 'function') {
|
|
492
402
|
const {
|
|
493
403
|
fileList
|
|
494
404
|
} = this.getStates();
|
|
495
|
-
|
|
496
405
|
const buResult = this._adapter.notifyBeforeUpload({
|
|
497
406
|
file,
|
|
498
407
|
fileList
|
|
499
408
|
});
|
|
500
|
-
|
|
501
409
|
switch (true) {
|
|
502
410
|
// sync validate - boolean
|
|
503
411
|
case buResult === true:
|
|
@@ -505,7 +413,6 @@ class UploadFoundation extends BaseFoundation {
|
|
|
505
413
|
this.post(file);
|
|
506
414
|
break;
|
|
507
415
|
}
|
|
508
|
-
|
|
509
416
|
case buResult === false:
|
|
510
417
|
{
|
|
511
418
|
const newResult = {
|
|
@@ -516,7 +423,6 @@ class UploadFoundation extends BaseFoundation {
|
|
|
516
423
|
break;
|
|
517
424
|
}
|
|
518
425
|
// async validate
|
|
519
|
-
|
|
520
426
|
case buResult && isPromise(buResult):
|
|
521
427
|
{
|
|
522
428
|
Promise.resolve(buResult).then(resolveData => {
|
|
@@ -524,11 +430,9 @@ class UploadFoundation extends BaseFoundation {
|
|
|
524
430
|
shouldUpload: true
|
|
525
431
|
};
|
|
526
432
|
const typeOfResolveData = Object.prototype.toString.call(resolveData).slice(8, -1);
|
|
527
|
-
|
|
528
433
|
if (typeOfResolveData === 'Object') {
|
|
529
434
|
newResult = Object.assign(Object.assign({}, newResult), resolveData);
|
|
530
435
|
}
|
|
531
|
-
|
|
532
436
|
this.handleBeforeUploadResultInObject(newResult, file);
|
|
533
437
|
}, rejectVal => {
|
|
534
438
|
let newResult = {
|
|
@@ -536,29 +440,24 @@ class UploadFoundation extends BaseFoundation {
|
|
|
536
440
|
status: strings.FILE_STATUS_VALID_FAIL
|
|
537
441
|
};
|
|
538
442
|
const typeOfRejectData = Object.prototype.toString.call(rejectVal).slice(8, -1);
|
|
539
|
-
|
|
540
443
|
if (typeOfRejectData === 'Object') {
|
|
541
444
|
newResult = Object.assign(Object.assign({}, newResult), rejectVal);
|
|
542
445
|
}
|
|
543
|
-
|
|
544
446
|
this.handleBeforeUploadResultInObject(newResult, file);
|
|
545
447
|
});
|
|
546
448
|
break;
|
|
547
449
|
}
|
|
548
450
|
// sync validate - object
|
|
549
|
-
|
|
550
451
|
case typeof buResult === 'object':
|
|
551
452
|
// inject to fileList
|
|
552
453
|
this.handleBeforeUploadResultInObject(buResult, file);
|
|
553
454
|
break;
|
|
554
|
-
|
|
555
455
|
default:
|
|
556
456
|
break;
|
|
557
457
|
}
|
|
558
458
|
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
|
|
459
|
+
}
|
|
460
|
+
// handle beforeUpload result when it's an object
|
|
562
461
|
handleBeforeUploadResultInObject(buResult, file) {
|
|
563
462
|
const {
|
|
564
463
|
shouldUpload,
|
|
@@ -568,75 +467,59 @@ class UploadFoundation extends BaseFoundation {
|
|
|
568
467
|
fileInstance
|
|
569
468
|
} = buResult;
|
|
570
469
|
let newFileList = this.getState('fileList').slice();
|
|
571
|
-
|
|
572
470
|
if (autoRemove) {
|
|
573
471
|
newFileList = newFileList.filter(item => item.uid !== file.uid);
|
|
574
472
|
} else {
|
|
575
473
|
const index = this._getFileIndex(file, newFileList);
|
|
576
|
-
|
|
577
474
|
if (index < 0) {
|
|
578
475
|
return;
|
|
579
476
|
}
|
|
580
|
-
|
|
581
477
|
status ? newFileList[index].status = status : null;
|
|
582
478
|
validateMessage ? newFileList[index].validateMessage = validateMessage : null;
|
|
583
|
-
|
|
584
479
|
if (fileInstance) {
|
|
585
480
|
fileInstance.uid = file.uid; // reuse recent file uid
|
|
586
|
-
|
|
587
481
|
newFileList[index].fileInstance = fileInstance;
|
|
588
482
|
newFileList[index].size = getFileSize(fileInstance.size);
|
|
589
483
|
newFileList[index].name = fileInstance.name;
|
|
590
484
|
}
|
|
591
|
-
|
|
592
485
|
newFileList[index].shouldUpload = shouldUpload;
|
|
593
486
|
}
|
|
594
|
-
|
|
595
487
|
this._adapter.updateFileList(newFileList);
|
|
596
|
-
|
|
597
488
|
this._adapter.notifyChange({
|
|
598
489
|
fileList: newFileList,
|
|
599
490
|
currentFile: file
|
|
600
491
|
});
|
|
601
|
-
|
|
602
492
|
if (shouldUpload) {
|
|
603
493
|
this.post(file);
|
|
604
494
|
}
|
|
605
495
|
}
|
|
606
|
-
|
|
607
496
|
post(file) {
|
|
608
497
|
const {
|
|
609
498
|
fileInstance
|
|
610
499
|
} = file;
|
|
611
500
|
const option = this.getProps();
|
|
612
|
-
|
|
613
501
|
if (typeof XMLHttpRequest === 'undefined') {
|
|
614
502
|
return;
|
|
615
503
|
}
|
|
616
|
-
|
|
617
504
|
const xhr = new XMLHttpRequest();
|
|
618
505
|
const formData = new FormData();
|
|
619
506
|
const {
|
|
620
507
|
action
|
|
621
|
-
} = option;
|
|
622
|
-
|
|
508
|
+
} = option;
|
|
509
|
+
// add data
|
|
623
510
|
let {
|
|
624
511
|
data
|
|
625
512
|
} = option;
|
|
626
|
-
|
|
627
513
|
if (data) {
|
|
628
514
|
if (typeof data === 'function') {
|
|
629
515
|
data = data(fileInstance);
|
|
630
516
|
}
|
|
631
|
-
|
|
632
517
|
Object.keys(data).forEach(key => {
|
|
633
518
|
formData.append(key, data[key]);
|
|
634
519
|
});
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
|
|
520
|
+
}
|
|
521
|
+
// add file
|
|
638
522
|
const fileName = option.name || option.fileName || fileInstance.name;
|
|
639
|
-
|
|
640
523
|
if (option.customRequest) {
|
|
641
524
|
return option.customRequest({
|
|
642
525
|
fileName,
|
|
@@ -662,50 +545,40 @@ class UploadFoundation extends BaseFoundation {
|
|
|
662
545
|
action: option.action
|
|
663
546
|
});
|
|
664
547
|
}
|
|
665
|
-
|
|
666
548
|
formData.append(fileName, fileInstance);
|
|
667
549
|
xhr.open('post', action, true);
|
|
668
|
-
|
|
669
550
|
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
670
551
|
xhr.withCredentials = true;
|
|
671
552
|
}
|
|
672
|
-
|
|
673
553
|
if (xhr.upload) {
|
|
674
554
|
xhr.upload.onprogress = e => this.handleProgress({
|
|
675
555
|
e,
|
|
676
556
|
fileInstance
|
|
677
557
|
});
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
|
|
558
|
+
}
|
|
559
|
+
// Callback function after upload is completed
|
|
681
560
|
xhr.onload = e => this.handleOnLoad({
|
|
682
561
|
e,
|
|
683
562
|
xhr,
|
|
684
563
|
fileInstance
|
|
685
564
|
});
|
|
686
|
-
|
|
687
565
|
xhr.onerror = e => this.handleError({
|
|
688
566
|
e,
|
|
689
567
|
xhr,
|
|
690
568
|
fileInstance
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
|
|
569
|
+
});
|
|
570
|
+
// add headers
|
|
694
571
|
let headers = option.headers || {};
|
|
695
|
-
|
|
696
572
|
if (typeof headers === 'function') {
|
|
697
573
|
headers = headers(fileInstance);
|
|
698
574
|
}
|
|
699
|
-
|
|
700
575
|
for (const item in headers) {
|
|
701
576
|
if (Object.prototype.hasOwnProperty.call(headers, item) && headers[item] !== null) {
|
|
702
577
|
xhr.setRequestHeader(item, headers[item]);
|
|
703
578
|
}
|
|
704
579
|
}
|
|
705
|
-
|
|
706
580
|
xhr.send(formData);
|
|
707
581
|
}
|
|
708
|
-
|
|
709
582
|
handleProgress(_ref2) {
|
|
710
583
|
let {
|
|
711
584
|
e,
|
|
@@ -716,30 +589,22 @@ class UploadFoundation extends BaseFoundation {
|
|
|
716
589
|
} = this.getStates();
|
|
717
590
|
const newFileList = fileList.slice();
|
|
718
591
|
let percent = 0;
|
|
719
|
-
|
|
720
592
|
if (e.total > 0) {
|
|
721
593
|
percent = Number((e.loaded / e.total * 100 * numbers.PROGRESS_COEFFICIENT).toFixed(0)) || 0;
|
|
722
594
|
}
|
|
723
|
-
|
|
724
595
|
const index = this._getFileIndex(fileInstance, newFileList);
|
|
725
|
-
|
|
726
596
|
if (index < 0) {
|
|
727
597
|
return;
|
|
728
598
|
}
|
|
729
|
-
|
|
730
599
|
newFileList[index].percent = percent;
|
|
731
600
|
newFileList[index].status = FILE_STATUS_UPLOADING;
|
|
732
|
-
|
|
733
601
|
this._adapter.notifyProgress(percent, fileInstance, newFileList);
|
|
734
|
-
|
|
735
602
|
this._adapter.updateFileList(newFileList);
|
|
736
|
-
|
|
737
603
|
this._adapter.notifyChange({
|
|
738
604
|
fileList: newFileList,
|
|
739
605
|
currentFile: newFileList[index]
|
|
740
606
|
});
|
|
741
607
|
}
|
|
742
|
-
|
|
743
608
|
handleOnLoad(_ref3) {
|
|
744
609
|
let {
|
|
745
610
|
e,
|
|
@@ -749,13 +614,10 @@ class UploadFoundation extends BaseFoundation {
|
|
|
749
614
|
const {
|
|
750
615
|
fileList
|
|
751
616
|
} = this.getStates();
|
|
752
|
-
|
|
753
617
|
const index = this._getFileIndex(fileInstance, fileList);
|
|
754
|
-
|
|
755
618
|
if (index < 0) {
|
|
756
619
|
return;
|
|
757
620
|
}
|
|
758
|
-
|
|
759
621
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
760
622
|
this.handleError({
|
|
761
623
|
e,
|
|
@@ -771,7 +633,6 @@ class UploadFoundation extends BaseFoundation {
|
|
|
771
633
|
});
|
|
772
634
|
}
|
|
773
635
|
}
|
|
774
|
-
|
|
775
636
|
handleSuccess(_ref4) {
|
|
776
637
|
let {
|
|
777
638
|
e,
|
|
@@ -784,32 +645,25 @@ class UploadFoundation extends BaseFoundation {
|
|
|
784
645
|
fileList
|
|
785
646
|
} = this.getStates();
|
|
786
647
|
let body = null;
|
|
787
|
-
|
|
788
648
|
const index = this._getFileIndex(fileInstance, fileList);
|
|
789
|
-
|
|
790
649
|
if (index < 0) {
|
|
791
650
|
return;
|
|
792
651
|
}
|
|
793
|
-
|
|
794
652
|
if (isCustomRequest) {
|
|
795
653
|
// use when pass customRequest
|
|
796
654
|
body = response;
|
|
797
655
|
} else {
|
|
798
656
|
body = this.getBody(xhr);
|
|
799
657
|
}
|
|
800
|
-
|
|
801
658
|
const newFileList = fileList.slice();
|
|
802
659
|
const {
|
|
803
660
|
afterUpload
|
|
804
661
|
} = this.getProps();
|
|
805
662
|
newFileList[index].status = FILE_STATUS_SUCCESS;
|
|
806
663
|
newFileList[index].percent = 100;
|
|
807
|
-
|
|
808
664
|
this._adapter.notifyProgress(100, fileInstance, newFileList);
|
|
809
|
-
|
|
810
665
|
newFileList[index].response = body;
|
|
811
666
|
e ? newFileList[index].event = e : null;
|
|
812
|
-
|
|
813
667
|
if (afterUpload && typeof afterUpload === 'function') {
|
|
814
668
|
const {
|
|
815
669
|
autoRemove,
|
|
@@ -826,30 +680,23 @@ class UploadFoundation extends BaseFoundation {
|
|
|
826
680
|
name ? newFileList[index].name = name : null;
|
|
827
681
|
autoRemove ? newFileList.splice(index, 1) : null;
|
|
828
682
|
}
|
|
829
|
-
|
|
830
683
|
this._adapter.notifySuccess(body, fileInstance, newFileList);
|
|
831
|
-
|
|
832
684
|
this._adapter.notifyChange({
|
|
833
685
|
fileList: newFileList,
|
|
834
686
|
currentFile: newFileList[index]
|
|
835
687
|
});
|
|
836
|
-
|
|
837
688
|
this._adapter.updateFileList(newFileList);
|
|
838
689
|
}
|
|
839
|
-
|
|
840
690
|
_getFileIndex(file, fileList) {
|
|
841
691
|
return fileList.findIndex(item => item.uid === file.uid);
|
|
842
692
|
}
|
|
843
|
-
|
|
844
693
|
handleRemove(file) {
|
|
845
694
|
const {
|
|
846
695
|
disabled
|
|
847
696
|
} = this.getProps();
|
|
848
|
-
|
|
849
697
|
if (disabled) {
|
|
850
698
|
return;
|
|
851
699
|
}
|
|
852
|
-
|
|
853
700
|
const {
|
|
854
701
|
fileList
|
|
855
702
|
} = this.getStates();
|
|
@@ -858,28 +705,20 @@ class UploadFoundation extends BaseFoundation {
|
|
|
858
705
|
if (res === false) {
|
|
859
706
|
return;
|
|
860
707
|
}
|
|
861
|
-
|
|
862
708
|
const newFileList = fileList.slice();
|
|
863
|
-
|
|
864
709
|
const index = this._getFileIndex(file, fileList);
|
|
865
|
-
|
|
866
710
|
if (index < 0) {
|
|
867
711
|
return;
|
|
868
712
|
}
|
|
869
|
-
|
|
870
713
|
newFileList.splice(index, 1);
|
|
871
|
-
|
|
872
714
|
this._adapter.notifyRemove(file.fileInstance, newFileList, file);
|
|
873
|
-
|
|
874
715
|
this._adapter.updateFileList(newFileList);
|
|
875
|
-
|
|
876
716
|
this._adapter.notifyChange({
|
|
877
717
|
fileList: newFileList,
|
|
878
718
|
currentFile: file
|
|
879
719
|
});
|
|
880
720
|
});
|
|
881
721
|
}
|
|
882
|
-
|
|
883
722
|
handleError(_ref5) {
|
|
884
723
|
let {
|
|
885
724
|
e,
|
|
@@ -889,13 +728,10 @@ class UploadFoundation extends BaseFoundation {
|
|
|
889
728
|
const {
|
|
890
729
|
fileList
|
|
891
730
|
} = this.getStates();
|
|
892
|
-
|
|
893
731
|
const index = this._getFileIndex(fileInstance, fileList);
|
|
894
|
-
|
|
895
732
|
if (index < 0) {
|
|
896
733
|
return;
|
|
897
734
|
}
|
|
898
|
-
|
|
899
735
|
const {
|
|
900
736
|
action
|
|
901
737
|
} = this.getProps();
|
|
@@ -908,17 +744,13 @@ class UploadFoundation extends BaseFoundation {
|
|
|
908
744
|
newFileList[index].status = FILE_STATUS_UPLOAD_FAIL;
|
|
909
745
|
newFileList[index].response = error;
|
|
910
746
|
newFileList[index].event = e;
|
|
911
|
-
|
|
912
747
|
this._adapter.notifyError(error, fileInstance, newFileList, xhr);
|
|
913
|
-
|
|
914
748
|
this._adapter.updateFileList(newFileList);
|
|
915
|
-
|
|
916
749
|
this._adapter.notifyChange({
|
|
917
750
|
currentFile: newFileList[index],
|
|
918
751
|
fileList: newFileList
|
|
919
752
|
});
|
|
920
753
|
}
|
|
921
|
-
|
|
922
754
|
handleClear() {
|
|
923
755
|
const {
|
|
924
756
|
disabled
|
|
@@ -926,27 +758,22 @@ class UploadFoundation extends BaseFoundation {
|
|
|
926
758
|
const {
|
|
927
759
|
fileList
|
|
928
760
|
} = this.getStates();
|
|
929
|
-
|
|
930
761
|
if (disabled) {
|
|
931
762
|
return;
|
|
932
763
|
}
|
|
933
|
-
|
|
934
764
|
Promise.resolve(this._adapter.notifyBeforeClear(fileList)).then(res => {
|
|
935
765
|
if (res === false) {
|
|
936
766
|
return;
|
|
937
767
|
}
|
|
938
|
-
|
|
939
768
|
this._adapter.updateFileList([]);
|
|
940
|
-
|
|
941
769
|
this._adapter.notifyClear();
|
|
942
|
-
|
|
943
770
|
this._adapter.notifyChange({
|
|
944
771
|
fileList: []
|
|
945
772
|
});
|
|
946
|
-
}).catch(error => {
|
|
773
|
+
}).catch(error => {
|
|
774
|
+
// if user pass reject promise, no need to do anything
|
|
947
775
|
});
|
|
948
776
|
}
|
|
949
|
-
|
|
950
777
|
_createURL(fileInstance) {
|
|
951
778
|
// https://stackoverflow.com/questions/31742072/filereader-vs-window-url-createobjecturl
|
|
952
779
|
const url = URL.createObjectURL(fileInstance);
|
|
@@ -955,14 +782,11 @@ class UploadFoundation extends BaseFoundation {
|
|
|
955
782
|
} = this.getStates();
|
|
956
783
|
const newUrls = localUrls.slice();
|
|
957
784
|
newUrls.push(url);
|
|
958
|
-
|
|
959
785
|
this._adapter.updateLocalUrls(newUrls);
|
|
960
|
-
|
|
961
786
|
return url;
|
|
962
|
-
}
|
|
787
|
+
}
|
|
788
|
+
// 释放预览文件所占用的内存
|
|
963
789
|
// Release memory used by preview files
|
|
964
|
-
|
|
965
|
-
|
|
966
790
|
releaseMemory() {
|
|
967
791
|
const {
|
|
968
792
|
localUrls
|
|
@@ -971,7 +795,6 @@ class UploadFoundation extends BaseFoundation {
|
|
|
971
795
|
this._releaseBlob(url);
|
|
972
796
|
});
|
|
973
797
|
}
|
|
974
|
-
|
|
975
798
|
_releaseBlob(url) {
|
|
976
799
|
try {
|
|
977
800
|
URL.revokeObjectURL(url);
|
|
@@ -979,17 +802,13 @@ class UploadFoundation extends BaseFoundation {
|
|
|
979
802
|
console.log(error);
|
|
980
803
|
}
|
|
981
804
|
}
|
|
982
|
-
|
|
983
805
|
isImage(file) {
|
|
984
806
|
return /(webp|svg|png|gif|jpg|jpeg|bmp|dpg)$/i.test(file.type);
|
|
985
807
|
}
|
|
986
808
|
/* istanbul ignore next */
|
|
987
|
-
|
|
988
|
-
|
|
989
809
|
isMultiple() {
|
|
990
810
|
return Boolean(this.getProp('multiple'));
|
|
991
811
|
}
|
|
992
|
-
|
|
993
812
|
handleDragEnter(e) {
|
|
994
813
|
e.preventDefault();
|
|
995
814
|
e.stopPropagation();
|
|
@@ -997,25 +816,20 @@ class UploadFoundation extends BaseFoundation {
|
|
|
997
816
|
const {
|
|
998
817
|
disabled
|
|
999
818
|
} = this.getProps();
|
|
1000
|
-
|
|
1001
819
|
if (!disabled) {
|
|
1002
820
|
this._adapter.updateDragAreaStatus(DRAG_AREA_LEGAL);
|
|
1003
821
|
}
|
|
1004
822
|
}
|
|
1005
|
-
|
|
1006
823
|
handleDirectoryDrop(e) {
|
|
1007
824
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1008
825
|
const fileList = this.getState('fileList').slice();
|
|
1009
826
|
const items = [].slice.call(e.dataTransfer.items);
|
|
1010
827
|
const files = yield mapFileTree(items);
|
|
1011
828
|
this.handleChange(files);
|
|
1012
|
-
|
|
1013
829
|
this._adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
|
|
1014
|
-
|
|
1015
830
|
this._adapter.notifyDrop(e, files, fileList);
|
|
1016
831
|
});
|
|
1017
832
|
}
|
|
1018
|
-
|
|
1019
833
|
handleDrop(e) {
|
|
1020
834
|
// Block file opening in browser
|
|
1021
835
|
e.preventDefault();
|
|
@@ -1025,44 +839,37 @@ class UploadFoundation extends BaseFoundation {
|
|
|
1025
839
|
directory
|
|
1026
840
|
} = this.getProps();
|
|
1027
841
|
const fileList = this.getState('fileList').slice();
|
|
1028
|
-
|
|
1029
842
|
if (!disabled) {
|
|
1030
843
|
if (directory) {
|
|
1031
844
|
this.handleDirectoryDrop(e);
|
|
1032
845
|
return;
|
|
1033
846
|
}
|
|
1034
|
-
|
|
1035
847
|
const files = Array.from(e.dataTransfer.files);
|
|
1036
848
|
this.handleChange(files);
|
|
1037
|
-
|
|
1038
849
|
this._adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
|
|
1039
|
-
|
|
1040
850
|
this._adapter.notifyDrop(e, files, fileList);
|
|
1041
851
|
}
|
|
1042
852
|
}
|
|
1043
|
-
|
|
1044
853
|
handleDragOver(e) {
|
|
1045
854
|
e.preventDefault();
|
|
1046
855
|
e.stopPropagation();
|
|
1047
856
|
}
|
|
1048
|
-
|
|
1049
857
|
handleDragLeave(e) {
|
|
1050
858
|
e.preventDefault();
|
|
1051
|
-
e.stopPropagation();
|
|
859
|
+
e.stopPropagation();
|
|
860
|
+
// 防止拖拽进入子元素时触发的dragLeave也被处理
|
|
1052
861
|
// Prevent dragLeave triggered when dragging into a child element is also handled
|
|
1053
862
|
// https://stackoverflow.com/questions/7110353/html5-dragleave-fired-when-hovering-a-child-element
|
|
1054
|
-
|
|
1055
863
|
if (this._dragEnterTarget === e.target) {
|
|
1056
864
|
this._adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
|
|
1057
865
|
}
|
|
1058
|
-
}
|
|
866
|
+
}
|
|
867
|
+
// 拖拽上传时,需要对文件的格式进行校验
|
|
1059
868
|
// When dragging and uploading, you need to verify the file format
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
869
|
checkFileFormat(accept, file) {
|
|
1063
870
|
const acceptTypes = accept.split(',').map(type => type.trim()).filter(type => type);
|
|
1064
|
-
const mimeType = file.type || '';
|
|
1065
|
-
|
|
871
|
+
const mimeType = file.type || '';
|
|
872
|
+
// Get the large class to which MIMEtype belongs, eg: image/jpeg = > image, application/= > application
|
|
1066
873
|
const baseMimeType = mimeType.replace(/\/.*$/, '');
|
|
1067
874
|
return acceptTypes.some(type => {
|
|
1068
875
|
// When accepted as a suffix filename such as [.jpeg]
|
|
@@ -1070,39 +877,30 @@ class UploadFoundation extends BaseFoundation {
|
|
|
1070
877
|
const fileName = file.name || '';
|
|
1071
878
|
const acceptExtension = type.split('.').pop().toLowerCase();
|
|
1072
879
|
return endsWith(fileName.toLowerCase(), acceptExtension);
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
|
|
880
|
+
}
|
|
881
|
+
// When accepted as a general class such as [image/*] or [video/*]
|
|
1076
882
|
if (/\/\*$/.test(type)) {
|
|
1077
883
|
const acceptBaseMimeType = type.replace(/\/.*$/, '');
|
|
1078
884
|
return baseMimeType === acceptBaseMimeType;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
|
|
885
|
+
}
|
|
886
|
+
// When accepted as a full MIME types string
|
|
1082
887
|
if (/^[^\/]+\/[^\/]+$/.test(type)) {
|
|
1083
888
|
return mimeType === type;
|
|
1084
889
|
}
|
|
1085
|
-
|
|
1086
890
|
return false;
|
|
1087
891
|
});
|
|
1088
892
|
}
|
|
1089
|
-
|
|
1090
893
|
retry(fileItem) {
|
|
1091
894
|
const {
|
|
1092
895
|
onRetry
|
|
1093
896
|
} = this.getProps();
|
|
1094
|
-
|
|
1095
897
|
if (onRetry && typeof onRetry === 'function') {
|
|
1096
898
|
onRetry(fileItem);
|
|
1097
899
|
}
|
|
1098
|
-
|
|
1099
900
|
this.post(fileItem);
|
|
1100
901
|
}
|
|
1101
|
-
|
|
1102
902
|
handlePreviewClick(fileItem) {
|
|
1103
903
|
this._adapter.notifyPreviewClick(fileItem);
|
|
1104
904
|
}
|
|
1105
|
-
|
|
1106
905
|
}
|
|
1107
|
-
|
|
1108
906
|
export default UploadFoundation;
|