@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
package/lib/cjs/tree/treeUtil.js
CHANGED
|
@@ -31,33 +31,25 @@ exports.normalizeValue = normalizeValue;
|
|
|
31
31
|
exports.normalizedArr = normalizedArr;
|
|
32
32
|
exports.traverseDataNodes = traverseDataNodes;
|
|
33
33
|
exports.updateKeys = updateKeys;
|
|
34
|
-
|
|
35
34
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
36
|
-
|
|
37
35
|
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
38
|
-
|
|
39
36
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
40
|
-
|
|
41
37
|
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
42
|
-
|
|
43
38
|
var _isNull2 = _interopRequireDefault(require("lodash/isNull"));
|
|
44
|
-
|
|
45
39
|
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
46
|
-
|
|
47
40
|
var _max2 = _interopRequireDefault(require("lodash/max"));
|
|
48
|
-
|
|
49
41
|
var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
|
|
50
|
-
|
|
51
42
|
var _difference2 = _interopRequireDefault(require("lodash/difference"));
|
|
52
|
-
|
|
53
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
44
|
+
/**
|
|
45
|
+
* Part of the utils function implementation process reference
|
|
46
|
+
* https://github.com/react-component/tree/blob/master/src/util.tsx
|
|
47
|
+
*/
|
|
54
48
|
|
|
55
49
|
const DRAG_OFFSET = 0.45;
|
|
56
|
-
|
|
57
50
|
function getPosition(level, index) {
|
|
58
51
|
return `${level}-${index}`;
|
|
59
52
|
}
|
|
60
|
-
|
|
61
53
|
function isValid(val) {
|
|
62
54
|
return !(0, _isNull2.default)(val) && !(0, _isUndefined2.default)(val);
|
|
63
55
|
}
|
|
@@ -69,19 +61,16 @@ function isValid(val) {
|
|
|
69
61
|
* need expanded keys, provides `true` means all expanded
|
|
70
62
|
*/
|
|
71
63
|
// eslint-disable-next-line max-len
|
|
72
|
-
|
|
73
|
-
|
|
74
64
|
function flattenTreeData(treeNodeList, expandedKeys) {
|
|
75
65
|
let filteredShownKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
76
66
|
const flattenList = [];
|
|
77
67
|
const filterSearch = Boolean(filteredShownKeys);
|
|
78
|
-
|
|
79
68
|
function flatten(list) {
|
|
80
69
|
let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
81
70
|
return list.map((treeNode, index) => {
|
|
82
71
|
const pos = getPosition(parent ? parent.pos : '0', index);
|
|
83
|
-
const mergedKey = treeNode.key;
|
|
84
|
-
|
|
72
|
+
const mergedKey = treeNode.key;
|
|
73
|
+
// Add FlattenDataNode into list
|
|
85
74
|
const flattenNode = Object.assign(Object.assign({}, (0, _pick2.default)(treeNode, ['key', 'label', 'value', 'icon', 'disabled', 'isLeaf'])), {
|
|
86
75
|
parent,
|
|
87
76
|
pos,
|
|
@@ -90,30 +79,24 @@ function flattenTreeData(treeNodeList, expandedKeys) {
|
|
|
90
79
|
_innerDataTag: true
|
|
91
80
|
});
|
|
92
81
|
const isBooleanFilteredShownKeys = typeof filteredShownKeys === 'boolean';
|
|
93
|
-
|
|
94
82
|
if (!filterSearch || !isBooleanFilteredShownKeys && filteredShownKeys.has(mergedKey)) {
|
|
95
83
|
flattenList.push(flattenNode);
|
|
96
|
-
}
|
|
84
|
+
}
|
|
85
|
+
// Loop treeNode children
|
|
97
86
|
// eslint-disable-next-line max-len
|
|
98
|
-
|
|
99
|
-
|
|
100
87
|
if (expandedKeys.has(mergedKey) && (!filterSearch || !isBooleanFilteredShownKeys && filteredShownKeys.has(mergedKey))) {
|
|
101
88
|
flattenNode.children = flatten(treeNode.children || [], flattenNode);
|
|
102
89
|
} else {
|
|
103
90
|
flattenNode.children = [];
|
|
104
91
|
}
|
|
105
|
-
|
|
106
92
|
return flattenNode;
|
|
107
93
|
});
|
|
108
94
|
}
|
|
109
|
-
|
|
110
95
|
flatten(treeNodeList);
|
|
111
96
|
return flattenList;
|
|
112
97
|
}
|
|
113
|
-
|
|
114
98
|
function convertJsonToData(treeJson) {
|
|
115
99
|
const treeData = [];
|
|
116
|
-
|
|
117
100
|
const traverseNode = (key, children, path, res) => {
|
|
118
101
|
const currPath = [...path, key];
|
|
119
102
|
const itemKey = currPath.join('-');
|
|
@@ -122,7 +105,6 @@ function convertJsonToData(treeJson) {
|
|
|
122
105
|
label: key,
|
|
123
106
|
value: children
|
|
124
107
|
};
|
|
125
|
-
|
|
126
108
|
if ((0, _isObject2.default)(children)) {
|
|
127
109
|
const newChildren = [];
|
|
128
110
|
Object.entries(children).forEach(c => {
|
|
@@ -130,23 +112,19 @@ function convertJsonToData(treeJson) {
|
|
|
130
112
|
});
|
|
131
113
|
newNode.children = newChildren;
|
|
132
114
|
}
|
|
133
|
-
|
|
134
115
|
res.push(newNode);
|
|
135
116
|
};
|
|
136
|
-
|
|
137
117
|
Object.entries(treeJson).forEach(item => traverseNode(item[0], item[1], [], treeData));
|
|
138
118
|
return treeData;
|
|
139
119
|
}
|
|
140
120
|
/**
|
|
141
121
|
* Traverse all the data by `treeData`.
|
|
142
122
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
123
|
function traverseDataNodes(treeNodes, callback) {
|
|
146
124
|
const processNode = (node, ind, parent) => {
|
|
147
125
|
const children = node ? node.children : treeNodes;
|
|
148
|
-
const pos = node ? getPosition(parent.pos, ind) : '0';
|
|
149
|
-
|
|
126
|
+
const pos = node ? getPosition(parent.pos, ind) : '0';
|
|
127
|
+
// Process node if is not root
|
|
150
128
|
if (node) {
|
|
151
129
|
const data = {
|
|
152
130
|
data: Object.assign({}, node),
|
|
@@ -157,9 +135,8 @@ function traverseDataNodes(treeNodes, callback) {
|
|
|
157
135
|
level: Number(parent.level) + 1
|
|
158
136
|
};
|
|
159
137
|
callback(data);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
138
|
+
}
|
|
139
|
+
// Process children node
|
|
163
140
|
if (children) {
|
|
164
141
|
children.forEach((subNode, subIndex) => {
|
|
165
142
|
processNode(subNode, subIndex, {
|
|
@@ -170,12 +147,9 @@ function traverseDataNodes(treeNodes, callback) {
|
|
|
170
147
|
});
|
|
171
148
|
}
|
|
172
149
|
};
|
|
173
|
-
|
|
174
150
|
processNode(null);
|
|
175
151
|
}
|
|
176
152
|
/* Convert data to entities map */
|
|
177
|
-
|
|
178
|
-
|
|
179
153
|
function convertDataToEntities(dataNodes) {
|
|
180
154
|
const posEntities = {};
|
|
181
155
|
const keyEntities = {};
|
|
@@ -193,16 +167,13 @@ function convertDataToEntities(dataNodes) {
|
|
|
193
167
|
} = data;
|
|
194
168
|
const entity = Object.assign({}, data);
|
|
195
169
|
const value = (0, _get2.default)(entity, 'data.value', null);
|
|
196
|
-
|
|
197
170
|
if (value !== null) {
|
|
198
171
|
valueEntities[value] = key;
|
|
199
172
|
}
|
|
200
|
-
|
|
201
173
|
posEntities[pos] = entity;
|
|
202
|
-
keyEntities[key] = entity;
|
|
203
|
-
|
|
174
|
+
keyEntities[key] = entity;
|
|
175
|
+
// Fill children
|
|
204
176
|
entity.parent = posEntities[parentPos];
|
|
205
|
-
|
|
206
177
|
if (entity.parent) {
|
|
207
178
|
entity.parent.children = entity.parent.children || [];
|
|
208
179
|
entity.parent.children.push(entity);
|
|
@@ -211,25 +182,19 @@ function convertDataToEntities(dataNodes) {
|
|
|
211
182
|
return wrapper;
|
|
212
183
|
}
|
|
213
184
|
/* Get key by value */
|
|
214
|
-
|
|
215
|
-
|
|
216
185
|
function findKeysForValues(valueList, valueEntities) {
|
|
217
186
|
let isMultiple = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
218
|
-
|
|
219
187
|
if (!isValid(valueList)) {
|
|
220
188
|
return [];
|
|
221
189
|
}
|
|
222
|
-
|
|
223
190
|
if (!isMultiple && Array.isArray(valueList)) {
|
|
224
191
|
valueList = valueList.length ? [valueList[0]] : [];
|
|
225
192
|
} else if (!Array.isArray(valueList)) {
|
|
226
193
|
valueList = [valueList];
|
|
227
194
|
}
|
|
228
|
-
|
|
229
195
|
if ((0, _isEmpty2.default)(valueEntities)) {
|
|
230
196
|
return valueList;
|
|
231
197
|
}
|
|
232
|
-
|
|
233
198
|
const res = [];
|
|
234
199
|
valueList.forEach(val => {
|
|
235
200
|
if (val in valueEntities) {
|
|
@@ -241,21 +206,17 @@ function findKeysForValues(valueList, valueEntities) {
|
|
|
241
206
|
});
|
|
242
207
|
return res;
|
|
243
208
|
}
|
|
244
|
-
|
|
245
209
|
function findDescendantKeys(selectedKeys, options) {
|
|
246
210
|
let self = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
247
211
|
const res = [];
|
|
248
|
-
|
|
249
212
|
const findChild = item => {
|
|
250
213
|
if (!item) {
|
|
251
214
|
return;
|
|
252
215
|
}
|
|
253
|
-
|
|
254
216
|
const {
|
|
255
217
|
children
|
|
256
218
|
} = item;
|
|
257
219
|
const hasChildren = isValid(children);
|
|
258
|
-
|
|
259
220
|
if (hasChildren) {
|
|
260
221
|
children.forEach(child => {
|
|
261
222
|
res.push(child.key);
|
|
@@ -263,17 +224,14 @@ function findDescendantKeys(selectedKeys, options) {
|
|
|
263
224
|
});
|
|
264
225
|
}
|
|
265
226
|
};
|
|
266
|
-
|
|
267
227
|
selectedKeys.forEach(item => {
|
|
268
228
|
if (self) {
|
|
269
229
|
res.push(item);
|
|
270
230
|
}
|
|
271
|
-
|
|
272
231
|
findChild(options[item]);
|
|
273
232
|
});
|
|
274
233
|
return res;
|
|
275
234
|
}
|
|
276
|
-
|
|
277
235
|
function findChildKeys(keys, options) {
|
|
278
236
|
let omitKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
279
237
|
const res = [];
|
|
@@ -288,21 +246,16 @@ function findChildKeys(keys, options) {
|
|
|
288
246
|
return res;
|
|
289
247
|
}
|
|
290
248
|
/* istanbul ignore next */
|
|
291
|
-
|
|
292
|
-
|
|
293
249
|
function findLeafKeys(keys, options) {
|
|
294
250
|
const res = [];
|
|
295
|
-
|
|
296
251
|
const findChild = item => {
|
|
297
252
|
if (!item) {
|
|
298
253
|
return;
|
|
299
254
|
}
|
|
300
|
-
|
|
301
255
|
const {
|
|
302
256
|
children
|
|
303
257
|
} = item;
|
|
304
258
|
const isLeaf = !isValid(children);
|
|
305
|
-
|
|
306
259
|
if (isLeaf) {
|
|
307
260
|
res.push(item.key);
|
|
308
261
|
} else {
|
|
@@ -311,13 +264,11 @@ function findLeafKeys(keys, options) {
|
|
|
311
264
|
});
|
|
312
265
|
}
|
|
313
266
|
};
|
|
314
|
-
|
|
315
267
|
keys.forEach(item => {
|
|
316
268
|
findChild(options[item]);
|
|
317
269
|
});
|
|
318
270
|
return res;
|
|
319
271
|
}
|
|
320
|
-
|
|
321
272
|
function findSiblingKeys(selectedKeys, options) {
|
|
322
273
|
let self = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
323
274
|
const par = [];
|
|
@@ -329,39 +280,33 @@ function findSiblingKeys(selectedKeys, options) {
|
|
|
329
280
|
const res = findChildKeys((0, _uniq2.default)(par), options, self ? [] : selectedKeys);
|
|
330
281
|
return res;
|
|
331
282
|
}
|
|
332
|
-
|
|
333
283
|
function findAncestorKeys(selectedKeys, options) {
|
|
334
284
|
let self = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
335
|
-
const res = [];
|
|
336
|
-
|
|
285
|
+
const res = [];
|
|
286
|
+
// Recursively find the parent element
|
|
337
287
|
const findPar = item => {
|
|
338
288
|
if (item.parent) {
|
|
339
289
|
res.push(item.parent.key);
|
|
340
290
|
findPar(item.parent);
|
|
341
291
|
}
|
|
342
292
|
};
|
|
343
|
-
|
|
344
293
|
selectedKeys.forEach(item => {
|
|
345
294
|
options[item] && findPar(options[item]);
|
|
346
|
-
|
|
347
295
|
if (self) {
|
|
348
296
|
res.push(item);
|
|
349
297
|
}
|
|
350
298
|
});
|
|
351
299
|
return res;
|
|
352
300
|
}
|
|
353
|
-
|
|
354
301
|
function getSortedKeyList(keyList, keyEntities) {
|
|
355
302
|
const levelMap = {};
|
|
356
303
|
keyList.forEach(key => {
|
|
357
304
|
if (!keyEntities[key]) {
|
|
358
305
|
return;
|
|
359
306
|
}
|
|
360
|
-
|
|
361
307
|
const {
|
|
362
308
|
level
|
|
363
309
|
} = keyEntities[key];
|
|
364
|
-
|
|
365
310
|
if (levelMap[level]) {
|
|
366
311
|
levelMap[level].push(key);
|
|
367
312
|
} else {
|
|
@@ -370,7 +315,6 @@ function getSortedKeyList(keyList, keyEntities) {
|
|
|
370
315
|
});
|
|
371
316
|
return levelMap;
|
|
372
317
|
}
|
|
373
|
-
|
|
374
318
|
function calcCheckedKeys(values, keyEntities) {
|
|
375
319
|
const keyList = Array.isArray(values) ? values : [values];
|
|
376
320
|
const descendantKeys = findDescendantKeys(keyList, keyEntities, true);
|
|
@@ -379,103 +323,85 @@ function calcCheckedKeys(values, keyEntities) {
|
|
|
379
323
|
* their descendants must be checked. That is to say, if the descendant nodes have
|
|
380
324
|
* disabled+unchecked nodes, their ancestor nodes will definitely not be checked
|
|
381
325
|
*/
|
|
382
|
-
|
|
383
326
|
const checkedKeys = new Set([...descendantKeys]);
|
|
384
327
|
let halfCheckedKeys = new Set([]);
|
|
385
328
|
let visited = [];
|
|
386
329
|
const levelMap = getSortedKeyList(keyList, keyEntities);
|
|
387
|
-
|
|
388
330
|
const calcCurrLevel = node => {
|
|
389
331
|
const {
|
|
390
332
|
key,
|
|
391
333
|
parent,
|
|
392
334
|
level
|
|
393
|
-
} = node;
|
|
394
|
-
|
|
335
|
+
} = node;
|
|
336
|
+
// If the node does not have a parent node, or the node has been processed just now, no processing is done
|
|
395
337
|
if (!parent || visited.includes(key)) {
|
|
396
338
|
return;
|
|
397
339
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
340
|
+
const siblingKeys = findSiblingKeys([key], keyEntities);
|
|
341
|
+
// visited for caching to avoid double counting
|
|
401
342
|
visited = [...visited, ...siblingKeys];
|
|
402
343
|
const allChecked = siblingKeys.every(siblingKey => checkedKeys.has(siblingKey));
|
|
403
|
-
|
|
404
344
|
if (!allChecked) {
|
|
405
345
|
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
406
346
|
halfCheckedKeys = new Set([...halfCheckedKeys, ...ancestorKeys]);
|
|
407
347
|
} else {
|
|
408
|
-
checkedKeys.add(parent.key);
|
|
409
|
-
|
|
348
|
+
checkedKeys.add(parent.key);
|
|
349
|
+
// IMPORTANT! parent level may not exist in original level map; if add to the end directly may destroy the hierarchical order
|
|
410
350
|
if (level - 1 in levelMap && level) {
|
|
411
351
|
levelMap[level - 1].push(parent.key);
|
|
412
352
|
} else {
|
|
413
353
|
levelMap[level - 1] = [parent.key];
|
|
414
354
|
}
|
|
415
355
|
}
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
|
|
356
|
+
};
|
|
357
|
+
// Loop keyList from deepest Level to topLevel, bottom up
|
|
419
358
|
while (!(0, _isEmpty2.default)(levelMap)) {
|
|
420
359
|
const maxLevel = (0, _max2.default)(Object.keys(levelMap).map(key => Number(key)));
|
|
421
360
|
levelMap[maxLevel].forEach(key => calcCurrLevel(keyEntities[key]));
|
|
422
361
|
delete levelMap[maxLevel];
|
|
423
362
|
}
|
|
424
|
-
|
|
425
363
|
return {
|
|
426
364
|
checkedKeys,
|
|
427
365
|
halfCheckedKeys
|
|
428
366
|
};
|
|
429
367
|
}
|
|
430
368
|
/* Calculate the expanded node by key */
|
|
431
|
-
|
|
432
|
-
|
|
433
369
|
function calcExpandedKeys() {
|
|
434
370
|
let keyList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
435
371
|
let keyEntities = arguments.length > 1 ? arguments[1] : undefined;
|
|
436
372
|
let autoExpandParent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
437
|
-
|
|
438
373
|
if (!Array.isArray(keyList)) {
|
|
439
374
|
keyList = [keyList];
|
|
440
375
|
}
|
|
441
|
-
|
|
442
376
|
if (autoExpandParent) {
|
|
443
377
|
const ancestorKeys = findAncestorKeys(keyList, keyEntities, true);
|
|
444
378
|
return new Set(ancestorKeys);
|
|
445
379
|
}
|
|
446
|
-
|
|
447
380
|
return new Set(keyList);
|
|
448
381
|
}
|
|
449
382
|
/* Calculate the expanded node by value */
|
|
450
383
|
// eslint-disable-next-line max-len
|
|
451
|
-
|
|
452
|
-
|
|
453
384
|
function calcExpandedKeysForValues(value, keyEntities, isMultiple, valueEntities) {
|
|
454
385
|
const keys = findKeysForValues(value, valueEntities, isMultiple);
|
|
455
386
|
return new Set(findAncestorKeys(keys, keyEntities, false));
|
|
456
387
|
}
|
|
457
|
-
|
|
458
388
|
function calcMotionKeys(oldKeySet, newKeySet, keyEntities) {
|
|
459
389
|
let motionType = 'show';
|
|
460
390
|
const oldKeys = [...oldKeySet];
|
|
461
391
|
const newKeys = [...newKeySet];
|
|
462
|
-
|
|
463
392
|
if (Math.abs(oldKeys.length - newKeys.length) !== 1) {
|
|
464
393
|
return {
|
|
465
394
|
motionType,
|
|
466
395
|
motionKeys: []
|
|
467
396
|
};
|
|
468
397
|
}
|
|
469
|
-
|
|
470
398
|
let diffKeys = [];
|
|
471
|
-
|
|
472
399
|
if (oldKeys.length > newKeys.length) {
|
|
473
400
|
motionType = 'hide';
|
|
474
401
|
diffKeys = (0, _difference2.default)(oldKeys, newKeys);
|
|
475
402
|
} else {
|
|
476
403
|
diffKeys = (0, _difference2.default)(newKeys, oldKeys);
|
|
477
404
|
}
|
|
478
|
-
|
|
479
405
|
return {
|
|
480
406
|
motionType: diffKeys.length === 1 ? motionType : 'show',
|
|
481
407
|
motionKeys: diffKeys.length === 1 ? findDescendantKeys(diffKeys, keyEntities, false) : []
|
|
@@ -486,121 +412,98 @@ function calcMotionKeys(oldKeySet, newKeySet, keyEntities) {
|
|
|
486
412
|
* When filterTreeNode is a function,returns the result of filterTreeNode which called with (sugInput, target, option).
|
|
487
413
|
* The filteredPath parameter will only be passed in when the Cascader calls the filter function
|
|
488
414
|
*/
|
|
489
|
-
|
|
490
|
-
|
|
491
415
|
function filter(sugInput, option, filterTreeNode, filterProps, filteredPath) {
|
|
492
416
|
if (!filterTreeNode) {
|
|
493
417
|
return true;
|
|
494
418
|
}
|
|
495
|
-
|
|
496
419
|
let filterFn = filterTreeNode;
|
|
497
420
|
let target = filteredPath !== null && filteredPath !== void 0 ? filteredPath : option;
|
|
498
|
-
|
|
499
421
|
if (typeof filterTreeNode === 'boolean') {
|
|
500
422
|
filterFn = (targetVal, val) => {
|
|
501
423
|
const input = targetVal.toLowerCase();
|
|
502
424
|
return val.toString().toLowerCase().includes(input);
|
|
503
425
|
};
|
|
504
426
|
}
|
|
505
|
-
|
|
506
427
|
if (filterProps) {
|
|
507
428
|
target = option[filterProps];
|
|
508
429
|
}
|
|
509
|
-
|
|
510
430
|
return filterFn(sugInput, target, option);
|
|
511
431
|
}
|
|
512
|
-
|
|
513
432
|
function normalizedArr(val) {
|
|
514
433
|
if (!Array.isArray(val)) {
|
|
515
434
|
return [val];
|
|
516
435
|
} else {
|
|
517
436
|
return val;
|
|
518
437
|
}
|
|
519
|
-
}
|
|
438
|
+
}
|
|
439
|
+
// flag is used to determine whether to return when the key does not belong to the keys in keyEntities
|
|
520
440
|
// export function normalizeKeyList(keyList: any, keyEntities: KeyEntities, leafOnly = false) {
|
|
521
|
-
|
|
522
|
-
|
|
523
441
|
function normalizeKeyList(keyList, keyEntities) {
|
|
524
442
|
let leafOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
525
443
|
let flag = arguments.length > 3 ? arguments[3] : undefined;
|
|
526
444
|
const res = [];
|
|
527
445
|
const keyListSet = new Set(keyList);
|
|
528
|
-
|
|
529
446
|
if (!leafOnly) {
|
|
530
447
|
keyList.forEach(key => {
|
|
531
448
|
if (!keyEntities[key]) {
|
|
532
449
|
if (flag) {
|
|
533
450
|
res.push(key);
|
|
534
451
|
}
|
|
535
|
-
|
|
536
452
|
return;
|
|
537
453
|
}
|
|
538
|
-
|
|
539
454
|
const {
|
|
540
455
|
parent
|
|
541
456
|
} = keyEntities[key];
|
|
542
|
-
|
|
543
457
|
if (parent && keyListSet.has(parent.key)) {
|
|
544
458
|
return;
|
|
545
459
|
}
|
|
546
|
-
|
|
547
460
|
res.push(key);
|
|
548
461
|
});
|
|
549
462
|
} else {
|
|
550
463
|
keyList.forEach(key => {
|
|
551
464
|
if (keyEntities[key] && !isValid(keyEntities[key].children)) {
|
|
552
465
|
res.push(key);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
|
|
466
|
+
}
|
|
467
|
+
// when key is not in keyEntities, if flag is true, key should be push in res
|
|
556
468
|
if (!keyEntities[key] && flag) {
|
|
557
469
|
res.push(key);
|
|
558
470
|
}
|
|
559
471
|
});
|
|
560
472
|
}
|
|
561
|
-
|
|
562
473
|
return res;
|
|
563
474
|
}
|
|
564
|
-
|
|
565
475
|
function getMotionKeys(eventKey, expandedKeys, keyEntities) {
|
|
566
476
|
const res = [];
|
|
567
|
-
|
|
568
477
|
const getChild = itemKey => {
|
|
569
478
|
keyEntities[itemKey].children && keyEntities[itemKey].children.forEach(item => {
|
|
570
479
|
const {
|
|
571
480
|
key
|
|
572
481
|
} = item;
|
|
573
482
|
res.push(key);
|
|
574
|
-
|
|
575
483
|
if (expandedKeys.has(key)) {
|
|
576
484
|
getChild(key);
|
|
577
485
|
}
|
|
578
486
|
});
|
|
579
487
|
};
|
|
580
|
-
|
|
581
488
|
getChild(eventKey);
|
|
582
489
|
return res;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
490
|
+
}
|
|
491
|
+
// eslint-disable-next-line max-len
|
|
586
492
|
function calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfCheckedKeys) {
|
|
587
493
|
const descendantKeys = findDescendantKeys([key], keyEntities, true);
|
|
588
494
|
const nodeItem = keyEntities[key];
|
|
589
495
|
checkedKeys = new Set([...checkedKeys, key]);
|
|
590
|
-
|
|
591
496
|
const calcCurrLevel = node => {
|
|
592
497
|
if (!node.parent) {
|
|
593
498
|
return;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
|
|
499
|
+
}
|
|
500
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
597
501
|
const {
|
|
598
502
|
key
|
|
599
503
|
} = node;
|
|
600
|
-
const siblingKeys = findSiblingKeys([key], keyEntities);
|
|
601
|
-
|
|
504
|
+
const siblingKeys = findSiblingKeys([key], keyEntities);
|
|
505
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
602
506
|
const allChecked = siblingKeys.every(key => checkedKeys.has(key));
|
|
603
|
-
|
|
604
507
|
if (!allChecked) {
|
|
605
508
|
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
606
509
|
halfCheckedKeys = new Set([...halfCheckedKeys, ...ancestorKeys]);
|
|
@@ -610,15 +513,13 @@ function calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfCheckedKey
|
|
|
610
513
|
calcCurrLevel(par);
|
|
611
514
|
}
|
|
612
515
|
};
|
|
613
|
-
|
|
614
516
|
calcCurrLevel(nodeItem);
|
|
615
517
|
return {
|
|
616
518
|
checkedKeys: new Set([...checkedKeys, ...descendantKeys]),
|
|
617
519
|
halfCheckedKeys
|
|
618
520
|
};
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
|
|
521
|
+
}
|
|
522
|
+
// eslint-disable-next-line max-len
|
|
622
523
|
function calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfCheckedKeys) {
|
|
623
524
|
const descendantKeys = findDescendantKeys([key], keyEntities, true);
|
|
624
525
|
const nodeItem = keyEntities[key];
|
|
@@ -626,61 +527,54 @@ function calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfCheckedK
|
|
|
626
527
|
if (checkedKeys.has(descendantKey)) {
|
|
627
528
|
checkedKeys.delete(descendantKey);
|
|
628
529
|
}
|
|
629
|
-
|
|
630
530
|
if (halfCheckedKeys.has(descendantKey)) {
|
|
631
531
|
halfCheckedKeys.delete(descendantKey);
|
|
632
532
|
}
|
|
633
533
|
});
|
|
634
|
-
|
|
635
534
|
const calcCurrLevel = node => {
|
|
636
|
-
const par = node.parent;
|
|
637
|
-
|
|
535
|
+
const par = node.parent;
|
|
536
|
+
// no parent
|
|
638
537
|
if (!par) {
|
|
639
538
|
return;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
|
|
539
|
+
}
|
|
540
|
+
// Has a parent node, and the parent node is not checked or halfChecked
|
|
643
541
|
if (!checkedKeys.has(par.key) && !halfCheckedKeys.has(par.key)) {
|
|
644
542
|
return;
|
|
645
|
-
}
|
|
543
|
+
}
|
|
544
|
+
// Has a parent node, and the parent node is checked or halfChecked
|
|
646
545
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
647
|
-
|
|
648
|
-
|
|
649
546
|
const {
|
|
650
547
|
key
|
|
651
548
|
} = node;
|
|
652
|
-
const siblingKeys = findSiblingKeys([key], keyEntities);
|
|
653
|
-
|
|
549
|
+
const siblingKeys = findSiblingKeys([key], keyEntities);
|
|
550
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
654
551
|
const anyChecked = siblingKeys.some(key => checkedKeys.has(key) || halfCheckedKeys.has(key));
|
|
655
|
-
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
656
|
-
|
|
552
|
+
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
553
|
+
// If there is checked or halfChecked in the sibling node, you need to change the parent node to halfChecked
|
|
657
554
|
if (anyChecked) {
|
|
658
555
|
ancestorKeys.forEach(itemKey => {
|
|
659
556
|
if (checkedKeys.has(itemKey)) {
|
|
660
557
|
checkedKeys.delete(itemKey);
|
|
661
558
|
halfCheckedKeys.add(itemKey);
|
|
662
559
|
}
|
|
663
|
-
});
|
|
560
|
+
});
|
|
561
|
+
// If there is no checked or halfChecked in the sibling node, you need to change the parent node to unchecked
|
|
664
562
|
} else {
|
|
665
563
|
if (checkedKeys.has(par.key)) {
|
|
666
564
|
checkedKeys.delete(par.key);
|
|
667
565
|
}
|
|
668
|
-
|
|
669
566
|
if (halfCheckedKeys.has(par.key)) {
|
|
670
567
|
halfCheckedKeys.delete(par.key);
|
|
671
568
|
}
|
|
672
|
-
|
|
673
569
|
calcCurrLevel(par);
|
|
674
570
|
}
|
|
675
571
|
};
|
|
676
|
-
|
|
677
572
|
nodeItem && calcCurrLevel(nodeItem);
|
|
678
573
|
return {
|
|
679
574
|
checkedKeys,
|
|
680
575
|
halfCheckedKeys
|
|
681
576
|
};
|
|
682
577
|
}
|
|
683
|
-
|
|
684
578
|
function filterTreeData(info) {
|
|
685
579
|
const {
|
|
686
580
|
showFilteredOnly,
|
|
@@ -694,12 +588,10 @@ function filterTreeData(info) {
|
|
|
694
588
|
let filteredOptsKeys = [];
|
|
695
589
|
filteredOptsKeys = Object.values(keyEntities).filter(item => filter(inputValue, item.data, filterTreeNode, filterProps)).map(item => item.key);
|
|
696
590
|
let expandedOptsKeys = findAncestorKeys(filteredOptsKeys, keyEntities, false);
|
|
697
|
-
|
|
698
591
|
if (prevExpandedKeys.length) {
|
|
699
592
|
const prevExpandedValidKeys = prevExpandedKeys.filter(key => Boolean(keyEntities[key]));
|
|
700
593
|
expandedOptsKeys = expandedOptsKeys.concat(prevExpandedValidKeys);
|
|
701
594
|
}
|
|
702
|
-
|
|
703
595
|
const shownChildKeys = findDescendantKeys(filteredOptsKeys, keyEntities, true);
|
|
704
596
|
const filteredShownKeys = new Set([...shownChildKeys, ...expandedOptsKeys]);
|
|
705
597
|
const flattenNodes = flattenTreeData(treeData, new Set(expandedOptsKeys), showFilteredOnly && filteredShownKeys);
|
|
@@ -709,19 +601,15 @@ function filterTreeData(info) {
|
|
|
709
601
|
filteredExpandedKeys: new Set(expandedOptsKeys),
|
|
710
602
|
filteredShownKeys
|
|
711
603
|
};
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
|
|
604
|
+
}
|
|
605
|
+
// return data.value if data.value exist else fall back to key
|
|
715
606
|
function getValueOrKey(data) {
|
|
716
607
|
if (Array.isArray(data)) {
|
|
717
608
|
return data.map(item => (0, _get2.default)(item, 'value', item.key));
|
|
718
609
|
}
|
|
719
|
-
|
|
720
610
|
return (0, _get2.default)(data, 'value', data.key);
|
|
721
611
|
}
|
|
722
612
|
/* Convert value to string */
|
|
723
|
-
|
|
724
|
-
|
|
725
613
|
function normalizeValue(value, withObject) {
|
|
726
614
|
if (withObject && isValid(value)) {
|
|
727
615
|
return getValueOrKey(value);
|
|
@@ -729,12 +617,10 @@ function normalizeValue(value, withObject) {
|
|
|
729
617
|
return value;
|
|
730
618
|
}
|
|
731
619
|
}
|
|
732
|
-
|
|
733
620
|
function updateKeys(keySet, keyEntities) {
|
|
734
621
|
const keyArr = [...keySet];
|
|
735
622
|
return keyArr.filter(key => key in keyEntities);
|
|
736
623
|
}
|
|
737
|
-
|
|
738
624
|
function calcDisabledKeys(keyEntities) {
|
|
739
625
|
const disabledKeys = Object.keys(keyEntities).filter(key => keyEntities[key].data.disabled);
|
|
740
626
|
const {
|
|
@@ -742,7 +628,6 @@ function calcDisabledKeys(keyEntities) {
|
|
|
742
628
|
} = calcCheckedKeys(disabledKeys, keyEntities);
|
|
743
629
|
return checkedKeys;
|
|
744
630
|
}
|
|
745
|
-
|
|
746
631
|
function calcDropRelativePosition(event, treeNode) {
|
|
747
632
|
const {
|
|
748
633
|
clientY
|
|
@@ -751,25 +636,21 @@ function calcDropRelativePosition(event, treeNode) {
|
|
|
751
636
|
top,
|
|
752
637
|
bottom,
|
|
753
638
|
height
|
|
754
|
-
} = treeNode.nodeInstance.getBoundingClientRect();
|
|
755
|
-
|
|
639
|
+
} = treeNode.nodeInstance.getBoundingClientRect();
|
|
640
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
756
641
|
if (clientY <= top + height * DRAG_OFFSET) {
|
|
757
642
|
return -1;
|
|
758
643
|
}
|
|
759
|
-
|
|
760
644
|
if (clientY >= bottom - height * DRAG_OFFSET) {
|
|
761
645
|
return 1;
|
|
762
646
|
}
|
|
763
|
-
|
|
764
647
|
return 0;
|
|
765
648
|
}
|
|
766
|
-
|
|
767
649
|
function getDragNodesKeys(key, keyEntities) {
|
|
768
650
|
return findDescendantKeys([key], keyEntities, true);
|
|
769
651
|
}
|
|
770
|
-
|
|
771
652
|
function calcDropActualPosition(pos, relativeDropPos) {
|
|
772
|
-
const posArr = pos.split('-');
|
|
773
|
-
|
|
653
|
+
const posArr = pos.split('-');
|
|
654
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
774
655
|
return relativeDropPos + Number(posArr[posArr.length - 1]);
|
|
775
656
|
}
|