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