@douyinfe/semi-foundation 2.36.0-alpha.0 → 2.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calendar/calendar.scss +1 -1
- package/calendar/foundation.ts +2 -1
- package/datePicker/_utils/getYears.ts +8 -4
- package/datePicker/foundation.ts +1 -1
- package/datePicker/monthsGridFoundation.ts +2 -1
- package/datePicker/yearAndMonthFoundation.ts +3 -1
- package/lib/cjs/anchor/constants.js +0 -2
- package/lib/cjs/anchor/foundation.js +10 -73
- package/lib/cjs/anchor/linkFoundation.js +4 -16
- package/lib/cjs/autoComplete/constants.js +0 -3
- package/lib/cjs/autoComplete/foundation.d.ts +1 -1
- package/lib/cjs/autoComplete/foundation.js +25 -139
- package/lib/cjs/autoComplete/optionFoundation.js +4 -14
- package/lib/cjs/avatar/constants.js +0 -2
- package/lib/cjs/avatar/foundation.js +0 -17
- package/lib/cjs/backtop/constants.js +0 -2
- package/lib/cjs/backtop/foundation.d.ts +2 -2
- package/lib/cjs/backtop/foundation.js +0 -21
- package/lib/cjs/badge/constants.js +0 -2
- package/lib/cjs/banner/constants.js +0 -2
- package/lib/cjs/banner/foundation.js +0 -7
- package/lib/cjs/base/constants.js +2 -4
- package/lib/cjs/base/foundation.d.ts +1 -1
- package/lib/cjs/base/foundation.js +12 -46
- package/lib/cjs/base/index.js +0 -3
- package/lib/cjs/breadcrumb/constants.js +0 -2
- package/lib/cjs/breadcrumb/foundation.js +1 -12
- package/lib/cjs/breadcrumb/itemFoundation.js +0 -7
- package/lib/cjs/button/constants.js +0 -2
- package/lib/cjs/calendar/calendar.css +2 -2
- package/lib/cjs/calendar/calendar.scss +1 -1
- package/lib/cjs/calendar/constants.js +0 -2
- package/lib/cjs/calendar/eventUtil.d.ts +1 -1
- package/lib/cjs/calendar/eventUtil.js +2 -74
- package/lib/cjs/calendar/foundation.d.ts +2 -2
- package/lib/cjs/calendar/foundation.js +28 -123
- package/lib/cjs/card/constants.js +0 -2
- package/lib/cjs/carousel/constants.js +0 -2
- package/lib/cjs/carousel/foundation.js +2 -52
- package/lib/cjs/cascader/constants.js +0 -3
- package/lib/cjs/cascader/foundation.d.ts +4 -4
- package/lib/cjs/cascader/foundation.js +28 -242
- package/lib/cjs/cascader/util.js +6 -24
- package/lib/cjs/checkbox/checkboxFoundation.js +2 -38
- package/lib/cjs/checkbox/checkboxGroupFoundation.js +2 -23
- package/lib/cjs/checkbox/constants.js +0 -2
- package/lib/cjs/collapse/constants.js +0 -2
- package/lib/cjs/collapse/foundation.d.ts +1 -1
- package/lib/cjs/collapse/foundation.js +2 -13
- package/lib/cjs/collapsible/constants.js +0 -2
- package/lib/cjs/collapsible/foundation.js +0 -9
- package/lib/cjs/datePicker/_utils/formatter.js +4 -10
- package/lib/cjs/datePicker/_utils/getDayOfWeek.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/getDayOfWeek.js +0 -4
- package/lib/cjs/datePicker/_utils/getDefaultFormatToken.js +0 -5
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.js +0 -15
- package/lib/cjs/datePicker/_utils/getFullDateOffset.js +0 -7
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +0 -5
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +0 -6
- package/lib/cjs/datePicker/_utils/getMonthTable.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/getMonthTable.js +3 -14
- package/lib/cjs/datePicker/_utils/getMonthsInYear.js +0 -2
- package/lib/cjs/datePicker/_utils/getYears.d.ts +1 -1
- package/lib/cjs/datePicker/_utils/getYears.js +9 -7
- package/lib/cjs/datePicker/_utils/index.js +0 -13
- package/lib/cjs/datePicker/_utils/isAfter.js +0 -4
- package/lib/cjs/datePicker/_utils/isBefore.js +0 -4
- package/lib/cjs/datePicker/_utils/isBetween.js +0 -4
- package/lib/cjs/datePicker/_utils/isDate.js +0 -1
- package/lib/cjs/datePicker/_utils/isSameDay.js +0 -4
- package/lib/cjs/datePicker/_utils/isTimestamp.js +0 -4
- package/lib/cjs/datePicker/_utils/isUnixTimestamp.js +0 -4
- package/lib/cjs/datePicker/_utils/isValidDate.js +0 -1
- package/lib/cjs/datePicker/_utils/isValidTimeZone.js +0 -1
- package/lib/cjs/datePicker/_utils/isWithinInterval.js +0 -4
- package/lib/cjs/datePicker/_utils/parser.js +0 -10
- package/lib/cjs/datePicker/constants.js +0 -3
- package/lib/cjs/datePicker/foundation.d.ts +25 -25
- package/lib/cjs/datePicker/foundation.js +22 -333
- package/lib/cjs/datePicker/inputFoundation.d.ts +3 -3
- package/lib/cjs/datePicker/inputFoundation.js +5 -86
- package/lib/cjs/datePicker/monthFoundation.d.ts +1 -1
- package/lib/cjs/datePicker/monthFoundation.js +3 -28
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +5 -4
- package/lib/cjs/datePicker/monthsGridFoundation.js +43 -238
- package/lib/cjs/datePicker/yearAndMonthFoundation.d.ts +3 -1
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +12 -38
- package/lib/cjs/descriptions/constants.js +0 -2
- package/lib/cjs/divider/constants.js +0 -2
- package/lib/cjs/dropdown/constants.js +0 -3
- package/lib/cjs/dropdown/foundation.js +4 -23
- package/lib/cjs/dropdown/menuFoundation.js +8 -27
- package/lib/cjs/empty/constants.js +0 -2
- package/lib/cjs/form/constants.js +0 -2
- package/lib/cjs/form/foundation.js +75 -206
- package/lib/cjs/form/interface.d.ts +5 -5
- package/lib/cjs/form/utils.js +47 -77
- package/lib/cjs/grid/constants.js +0 -2
- package/lib/cjs/highlight/constants.js +0 -2
- package/lib/cjs/icons/constants.js +0 -2
- package/lib/cjs/image/constants.js +0 -2
- package/lib/cjs/image/imageFoundation.js +4 -18
- package/lib/cjs/image/previewFooterFoundation.js +0 -13
- package/lib/cjs/image/previewFoundation.js +0 -11
- package/lib/cjs/image/previewImageFoundation.js +6 -80
- package/lib/cjs/image/previewInnerFoundation.js +12 -77
- package/lib/cjs/image/utils.js +0 -14
- package/lib/cjs/input/constants.js +0 -2
- package/lib/cjs/input/foundation.js +17 -101
- package/lib/cjs/input/textareaFoundation.js +20 -85
- package/lib/cjs/input/util/calculateNodeHeight.js +6 -18
- package/lib/cjs/input/util/getSizingData.js +7 -11
- package/lib/cjs/inputNumber/constants.js +0 -2
- package/lib/cjs/inputNumber/foundation.js +29 -192
- package/lib/cjs/layout/constants.js +0 -2
- package/lib/cjs/list/constants.js +0 -2
- package/lib/cjs/modal/constants.js +0 -2
- package/lib/cjs/modal/modalContentFoundation.js +0 -20
- package/lib/cjs/modal/modalFoundation.d.ts +2 -2
- package/lib/cjs/modal/modalFoundation.js +2 -22
- package/lib/cjs/navigation/NavItem.js +0 -10
- package/lib/cjs/navigation/constants.js +0 -3
- package/lib/cjs/navigation/foundation.js +3 -67
- package/lib/cjs/navigation/itemFoundation.d.ts +0 -2
- package/lib/cjs/navigation/itemFoundation.js +3 -21
- package/lib/cjs/navigation/navigation.css +7 -77
- package/lib/cjs/navigation/navigation.scss +7 -119
- package/lib/cjs/navigation/subNavFoundation.d.ts +0 -2
- package/lib/cjs/navigation/subNavFoundation.js +4 -40
- package/lib/cjs/notification/constants.js +0 -3
- package/lib/cjs/notification/notificationFoundation.d.ts +3 -3
- package/lib/cjs/notification/notificationFoundation.js +0 -16
- package/lib/cjs/notification/notificationListFoundation.js +7 -17
- package/lib/cjs/overflowList/constants.js +0 -2
- package/lib/cjs/overflowList/foundation.js +11 -41
- package/lib/cjs/pagination/constants.js +0 -2
- package/lib/cjs/pagination/foundation.d.ts +3 -3
- package/lib/cjs/pagination/foundation.js +21 -90
- package/lib/cjs/popconfirm/constants.js +0 -2
- package/lib/cjs/popconfirm/popconfirmFoundation.js +1 -21
- package/lib/cjs/popover/constants.js +0 -3
- package/lib/cjs/progress/constants.js +0 -2
- package/lib/cjs/progress/generates.d.ts +2 -2
- package/lib/cjs/progress/generates.js +19 -60
- package/lib/cjs/radio/constants.js +0 -2
- package/lib/cjs/radio/radioFoundation.js +0 -14
- package/lib/cjs/radio/radioGroupFoundation.js +4 -23
- package/lib/cjs/radio/radioInnerFoundation.js +2 -19
- package/lib/cjs/rating/constants.js +0 -2
- package/lib/cjs/rating/foundation.js +11 -61
- package/lib/cjs/scrollList/constants.js +0 -2
- package/lib/cjs/scrollList/foundation.js +0 -4
- package/lib/cjs/scrollList/itemFoundation.js +8 -61
- package/lib/cjs/scrollList/scrollTo.js +2 -5
- package/lib/cjs/select/constants.js +0 -3
- package/lib/cjs/select/foundation.d.ts +2 -2
- package/lib/cjs/select/foundation.js +122 -425
- package/lib/cjs/select/optionFoundation.js +4 -14
- package/lib/cjs/sideSheet/constants.js +0 -2
- package/lib/cjs/sideSheet/sideSheetFoundation.js +0 -18
- package/lib/cjs/skeleton/constants.js +0 -2
- package/lib/cjs/slider/constants.js +0 -2
- package/lib/cjs/slider/foundation.d.ts +1 -1
- package/lib/cjs/slider/foundation.js +25 -204
- package/lib/cjs/space/constants.js +0 -2
- package/lib/cjs/spin/constants.js +0 -2
- package/lib/cjs/spin/foundation.js +3 -13
- package/lib/cjs/steps/bacisSteps.scss +238 -287
- package/lib/cjs/steps/constants.js +0 -2
- package/lib/cjs/steps/fillSteps.scss +142 -153
- package/lib/cjs/steps/navSteps.scss +40 -61
- package/lib/cjs/steps/steps.css +17 -381
- package/lib/cjs/switch/constants.js +0 -2
- package/lib/cjs/switch/foundation.js +2 -18
- package/lib/cjs/table/bodyFoundation.js +2 -34
- package/lib/cjs/table/cellFoundation.js +0 -5
- package/lib/cjs/table/constants.js +7 -8
- package/lib/cjs/table/foundation.d.ts +17 -14
- package/lib/cjs/table/foundation.js +72 -302
- package/lib/cjs/table/table.css +6 -0
- package/lib/cjs/table/table.scss +12 -0
- package/lib/cjs/table/tableRowFoundation.js +0 -11
- package/lib/cjs/table/tableSelectionCellFoundation.js +0 -6
- package/lib/cjs/table/utils.d.ts +2 -2
- package/lib/cjs/table/utils.js +5 -118
- package/lib/cjs/tabs/constants.js +0 -2
- package/lib/cjs/tabs/foundation.js +2 -40
- package/lib/cjs/tabs/tabs.css +14 -14
- package/lib/cjs/tabs/tabs.scss +16 -14
- package/lib/cjs/tag/constants.js +1 -2
- package/lib/cjs/tagInput/constants.js +0 -2
- package/lib/cjs/tagInput/foundation.d.ts +4 -4
- package/lib/cjs/tagInput/foundation.js +4 -94
- package/lib/cjs/tagInput/utils/getSplitedArray.js +0 -11
- package/lib/cjs/timePicker/ComboxFoundation.js +4 -39
- package/lib/cjs/timePicker/constants.js +0 -3
- package/lib/cjs/timePicker/foundation.d.ts +2 -2
- package/lib/cjs/timePicker/foundation.js +6 -102
- package/lib/cjs/timePicker/inputFoundation.js +6 -25
- package/lib/cjs/timePicker/utils/index.js +6 -45
- package/lib/cjs/timePicker/utils/localeDate.js +0 -10
- package/lib/cjs/timeline/constants.js +0 -2
- package/lib/cjs/timeline/timeline.css +0 -36
- package/lib/cjs/timeline/timeline.scss +46 -96
- package/lib/cjs/toast/constants.js +0 -3
- package/lib/cjs/toast/toastFoundation.d.ts +3 -3
- package/lib/cjs/toast/toastFoundation.js +0 -14
- package/lib/cjs/toast/toastListFoundation.js +4 -22
- package/lib/cjs/tooltip/constants.js +0 -2
- package/lib/cjs/tooltip/foundation.d.ts +1 -1
- package/lib/cjs/tooltip/foundation.js +63 -291
- package/lib/cjs/transfer/constants.js +0 -2
- package/lib/cjs/transfer/foundation.d.ts +1 -1
- package/lib/cjs/transfer/foundation.js +4 -68
- package/lib/cjs/transfer/transferUtils.js +5 -27
- package/lib/cjs/tree/constants.js +0 -2
- package/lib/cjs/tree/foundation.d.ts +3 -3
- package/lib/cjs/tree/foundation.js +34 -150
- package/lib/cjs/tree/treeUtil.js +54 -173
- package/lib/cjs/treeSelect/constants.js +0 -2
- package/lib/cjs/treeSelect/foundation.d.ts +7 -7
- package/lib/cjs/treeSelect/foundation.js +18 -192
- package/lib/cjs/typography/constants.d.ts +1 -0
- package/lib/cjs/typography/constants.js +1 -2
- package/lib/cjs/typography/formatNumeral.d.ts +3 -3
- package/lib/cjs/typography/formatNumeral.js +16 -32
- package/lib/cjs/typography/typography.css +120 -0
- package/lib/cjs/typography/typography.scss +131 -6
- package/lib/cjs/typography/variables.scss +48 -0
- package/lib/cjs/upload/constants.js +0 -2
- package/lib/cjs/upload/foundation.d.ts +5 -5
- package/lib/cjs/upload/foundation.js +36 -245
- package/lib/cjs/upload/utils.js +10 -29
- package/lib/cjs/utils/Event.js +2 -21
- package/lib/cjs/utils/FocusHandle.d.ts +1 -1
- package/lib/cjs/utils/FocusHandle.js +6 -35
- package/lib/cjs/utils/Logger.js +0 -21
- package/lib/cjs/utils/Store.js +0 -10
- package/lib/cjs/utils/a11y.js +18 -43
- package/lib/cjs/utils/array.d.ts +1 -1
- package/lib/cjs/utils/array.js +0 -7
- package/lib/cjs/utils/arrayMove.js +0 -1
- package/lib/cjs/utils/classnames.js +0 -12
- package/lib/cjs/utils/date-fns-extra.js +0 -35
- package/lib/cjs/utils/dom.d.ts +1 -1
- package/lib/cjs/utils/dom.js +0 -13
- package/lib/cjs/utils/function.js +0 -1
- package/lib/cjs/utils/getDataAttr.js +0 -2
- package/lib/cjs/utils/getHighlight.js +5 -26
- package/lib/cjs/utils/getMotionObjFromProps.js +0 -12
- package/lib/cjs/utils/index.js +0 -4
- package/lib/cjs/utils/isBothNaN.js +0 -2
- package/lib/cjs/utils/isElement.js +0 -1
- package/lib/cjs/utils/isEnterPress.js +0 -5
- package/lib/cjs/utils/isEscPress.js +0 -5
- package/lib/cjs/utils/isNullOrUndefined.js +0 -1
- package/lib/cjs/utils/isNumber.js +0 -1
- package/lib/cjs/utils/isObject.js +0 -1
- package/lib/cjs/utils/isPromise.js +0 -3
- package/lib/cjs/utils/isString.js +0 -1
- package/lib/cjs/utils/keyCode.js +0 -105
- package/lib/cjs/utils/log.js +0 -5
- package/lib/cjs/utils/number.js +0 -2
- package/lib/cjs/utils/object.d.ts +4 -4
- package/lib/cjs/utils/object.js +12 -34
- package/lib/cjs/utils/set.js +0 -8
- package/lib/cjs/utils/shallowEqualObjects.js +0 -7
- package/lib/cjs/utils/touchPolyfill.js +0 -7
- package/lib/cjs/utils/type.d.ts +3 -3
- package/lib/cjs/utils/uuid.js +2 -9
- package/lib/cjs/utils/warning.js +0 -1
- package/lib/es/anchor/foundation.js +10 -66
- package/lib/es/anchor/linkFoundation.js +4 -12
- package/lib/es/autoComplete/foundation.d.ts +1 -1
- package/lib/es/autoComplete/foundation.js +24 -132
- package/lib/es/autoComplete/optionFoundation.js +4 -10
- package/lib/es/avatar/foundation.js +0 -12
- package/lib/es/backtop/foundation.d.ts +2 -2
- package/lib/es/backtop/foundation.js +0 -16
- package/lib/es/banner/foundation.js +0 -3
- package/lib/es/base/constants.js +2 -2
- package/lib/es/base/foundation.d.ts +1 -1
- package/lib/es/base/foundation.js +11 -44
- package/lib/es/breadcrumb/foundation.js +0 -7
- package/lib/es/breadcrumb/itemFoundation.js +0 -3
- package/lib/es/calendar/calendar.css +2 -2
- package/lib/es/calendar/calendar.scss +1 -1
- package/lib/es/calendar/eventUtil.d.ts +1 -1
- package/lib/es/calendar/eventUtil.js +2 -36
- package/lib/es/calendar/foundation.d.ts +2 -2
- package/lib/es/calendar/foundation.js +28 -117
- package/lib/es/carousel/foundation.js +2 -47
- package/lib/es/cascader/constants.js +0 -1
- package/lib/es/cascader/foundation.d.ts +4 -4
- package/lib/es/cascader/foundation.js +30 -226
- package/lib/es/cascader/util.js +6 -15
- package/lib/es/checkbox/checkboxFoundation.js +2 -34
- package/lib/es/checkbox/checkboxGroupFoundation.js +2 -20
- package/lib/es/collapse/foundation.d.ts +1 -1
- package/lib/es/collapse/foundation.js +2 -9
- package/lib/es/collapsible/foundation.js +0 -7
- package/lib/es/datePicker/_utils/formatter.js +4 -8
- package/lib/es/datePicker/_utils/getDayOfWeek.d.ts +1 -1
- package/lib/es/datePicker/_utils/getDayOfWeek.js +0 -3
- package/lib/es/datePicker/_utils/getDefaultFormatToken.js +0 -2
- package/lib/es/datePicker/_utils/getDefaultPickerDate.d.ts +1 -1
- package/lib/es/datePicker/_utils/getDefaultPickerDate.js +0 -10
- package/lib/es/datePicker/_utils/getFullDateOffset.js +0 -3
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +0 -4
- package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +0 -5
- package/lib/es/datePicker/_utils/getMonthTable.d.ts +1 -1
- package/lib/es/datePicker/_utils/getMonthTable.js +4 -14
- package/lib/es/datePicker/_utils/getMonthsInYear.js +0 -1
- package/lib/es/datePicker/_utils/getYears.d.ts +1 -1
- package/lib/es/datePicker/_utils/getYears.js +9 -6
- package/lib/es/datePicker/_utils/isBetween.js +0 -1
- package/lib/es/datePicker/_utils/parser.js +0 -8
- package/lib/es/datePicker/foundation.d.ts +25 -25
- package/lib/es/datePicker/foundation.js +22 -318
- package/lib/es/datePicker/inputFoundation.d.ts +3 -3
- package/lib/es/datePicker/inputFoundation.js +5 -74
- package/lib/es/datePicker/monthFoundation.d.ts +1 -1
- package/lib/es/datePicker/monthFoundation.js +4 -22
- package/lib/es/datePicker/monthsGridFoundation.d.ts +5 -4
- package/lib/es/datePicker/monthsGridFoundation.js +42 -222
- package/lib/es/datePicker/yearAndMonthFoundation.d.ts +3 -1
- package/lib/es/datePicker/yearAndMonthFoundation.js +12 -36
- package/lib/es/dropdown/foundation.js +4 -18
- package/lib/es/dropdown/menuFoundation.js +8 -22
- package/lib/es/form/foundation.js +74 -195
- package/lib/es/form/interface.d.ts +5 -5
- package/lib/es/form/utils.js +47 -70
- package/lib/es/image/imageFoundation.js +4 -13
- package/lib/es/image/previewFooterFoundation.js +0 -9
- package/lib/es/image/previewFoundation.js +0 -7
- package/lib/es/image/previewImageFoundation.js +6 -72
- package/lib/es/image/previewInnerFoundation.js +12 -70
- package/lib/es/image/utils.js +0 -6
- package/lib/es/input/foundation.js +17 -93
- package/lib/es/input/textareaFoundation.js +20 -75
- package/lib/es/input/util/calculateNodeHeight.js +6 -18
- package/lib/es/input/util/getSizingData.js +7 -11
- package/lib/es/inputNumber/foundation.js +28 -183
- package/lib/es/modal/modalContentFoundation.js +0 -15
- package/lib/es/modal/modalFoundation.d.ts +2 -2
- package/lib/es/modal/modalFoundation.js +2 -17
- package/lib/es/navigation/NavItem.js +0 -6
- package/lib/es/navigation/constants.js +1 -1
- package/lib/es/navigation/foundation.js +2 -60
- package/lib/es/navigation/itemFoundation.d.ts +0 -2
- package/lib/es/navigation/itemFoundation.js +3 -18
- package/lib/es/navigation/navigation.css +7 -77
- package/lib/es/navigation/navigation.scss +7 -119
- package/lib/es/navigation/subNavFoundation.d.ts +0 -2
- package/lib/es/navigation/subNavFoundation.js +4 -36
- package/lib/es/notification/constants.js +1 -1
- package/lib/es/notification/notificationFoundation.d.ts +3 -3
- package/lib/es/notification/notificationFoundation.js +0 -11
- package/lib/es/notification/notificationListFoundation.js +6 -13
- package/lib/es/overflowList/foundation.js +11 -37
- package/lib/es/pagination/foundation.d.ts +3 -3
- package/lib/es/pagination/foundation.js +20 -87
- package/lib/es/popconfirm/popconfirmFoundation.js +1 -16
- package/lib/es/progress/generates.d.ts +2 -2
- package/lib/es/progress/generates.js +19 -59
- package/lib/es/radio/radioFoundation.js +0 -9
- package/lib/es/radio/radioGroupFoundation.js +4 -19
- package/lib/es/radio/radioInnerFoundation.js +2 -15
- package/lib/es/rating/foundation.js +10 -54
- package/lib/es/scrollList/itemFoundation.js +8 -60
- package/lib/es/scrollList/scrollTo.js +2 -4
- package/lib/es/select/foundation.d.ts +2 -2
- package/lib/es/select/foundation.js +122 -411
- package/lib/es/select/optionFoundation.js +4 -10
- package/lib/es/sideSheet/sideSheetFoundation.js +0 -12
- package/lib/es/slider/foundation.d.ts +1 -1
- package/lib/es/slider/foundation.js +24 -197
- package/lib/es/spin/foundation.js +3 -11
- package/lib/es/steps/bacisSteps.scss +238 -287
- package/lib/es/steps/fillSteps.scss +142 -153
- package/lib/es/steps/navSteps.scss +40 -61
- package/lib/es/steps/steps.css +17 -381
- package/lib/es/switch/foundation.js +2 -13
- package/lib/es/table/bodyFoundation.js +2 -25
- package/lib/es/table/cellFoundation.js +0 -1
- package/lib/es/table/constants.js +6 -6
- package/lib/es/table/foundation.d.ts +17 -14
- package/lib/es/table/foundation.js +72 -309
- package/lib/es/table/table.css +6 -0
- package/lib/es/table/table.scss +12 -0
- package/lib/es/table/tableRowFoundation.js +2 -9
- package/lib/es/table/tableSelectionCellFoundation.js +0 -2
- package/lib/es/table/utils.d.ts +2 -2
- package/lib/es/table/utils.js +5 -81
- package/lib/es/tabs/foundation.js +2 -35
- package/lib/es/tabs/tabs.css +14 -14
- package/lib/es/tabs/tabs.scss +16 -14
- package/lib/es/tagInput/foundation.d.ts +4 -4
- package/lib/es/tagInput/foundation.js +4 -84
- package/lib/es/tagInput/utils/getSplitedArray.js +0 -7
- package/lib/es/timePicker/ComboxFoundation.js +4 -30
- package/lib/es/timePicker/foundation.d.ts +2 -2
- package/lib/es/timePicker/foundation.js +7 -95
- package/lib/es/timePicker/inputFoundation.js +6 -22
- package/lib/es/timePicker/utils/index.js +6 -25
- package/lib/es/timePicker/utils/localeDate.js +0 -8
- package/lib/es/timeline/timeline.css +0 -36
- package/lib/es/timeline/timeline.scss +46 -96
- package/lib/es/toast/constants.js +1 -1
- package/lib/es/toast/toastFoundation.d.ts +3 -3
- package/lib/es/toast/toastFoundation.js +0 -9
- package/lib/es/toast/toastListFoundation.js +4 -18
- package/lib/es/tooltip/foundation.d.ts +1 -1
- package/lib/es/tooltip/foundation.js +63 -288
- package/lib/es/transfer/foundation.d.ts +1 -1
- package/lib/es/transfer/foundation.js +6 -62
- package/lib/es/transfer/transferUtils.js +5 -21
- package/lib/es/tree/foundation.d.ts +3 -3
- package/lib/es/tree/foundation.js +34 -143
- package/lib/es/tree/treeUtil.js +54 -139
- package/lib/es/treeSelect/foundation.d.ts +7 -7
- package/lib/es/treeSelect/foundation.js +20 -179
- package/lib/es/typography/constants.d.ts +1 -0
- package/lib/es/typography/constants.js +1 -0
- package/lib/es/typography/formatNumeral.d.ts +3 -3
- package/lib/es/typography/formatNumeral.js +16 -29
- package/lib/es/typography/typography.css +120 -0
- package/lib/es/typography/typography.scss +131 -6
- package/lib/es/typography/variables.scss +48 -0
- package/lib/es/upload/foundation.d.ts +5 -5
- package/lib/es/upload/foundation.js +36 -238
- package/lib/es/upload/utils.js +10 -24
- package/lib/es/utils/Event.js +2 -17
- package/lib/es/utils/FocusHandle.d.ts +1 -1
- package/lib/es/utils/FocusHandle.js +6 -32
- package/lib/es/utils/Logger.js +0 -20
- package/lib/es/utils/Store.js +0 -9
- package/lib/es/utils/a11y.js +18 -31
- package/lib/es/utils/array.d.ts +1 -1
- package/lib/es/utils/array.js +0 -5
- package/lib/es/utils/classnames.js +0 -10
- package/lib/es/utils/date-fns-extra.js +0 -27
- package/lib/es/utils/dom.d.ts +1 -1
- package/lib/es/utils/dom.js +0 -9
- package/lib/es/utils/getDataAttr.js +0 -1
- package/lib/es/utils/getHighlight.js +5 -26
- package/lib/es/utils/getMotionObjFromProps.js +0 -8
- package/lib/es/utils/isBothNaN.js +0 -1
- package/lib/es/utils/isEnterPress.js +0 -2
- package/lib/es/utils/isEscPress.js +0 -2
- package/lib/es/utils/keyCode.js +0 -104
- package/lib/es/utils/log.js +0 -3
- package/lib/es/utils/object.d.ts +4 -4
- package/lib/es/utils/object.js +12 -28
- package/lib/es/utils/set.js +0 -5
- package/lib/es/utils/shallowEqualObjects.js +0 -6
- package/lib/es/utils/touchPolyfill.js +0 -5
- package/lib/es/utils/type.d.ts +3 -3
- package/lib/es/utils/uuid.js +2 -8
- package/navigation/itemFoundation.ts +1 -3
- package/navigation/navigation.scss +7 -119
- package/navigation/subNavFoundation.ts +1 -3
- package/overflowList/foundation.ts +4 -4
- package/package.json +2 -2
- package/steps/bacisSteps.scss +238 -287
- package/steps/fillSteps.scss +142 -153
- package/steps/navSteps.scss +40 -61
- package/table/foundation.ts +8 -10
- package/table/table.scss +12 -0
- package/tabs/tabs.scss +16 -14
- package/timePicker/foundation.ts +4 -6
- package/timeline/timeline.scss +46 -96
- package/typography/constants.ts +1 -0
- package/typography/typography.scss +131 -6
- package/typography/variables.scss +48 -0
- package/upload/foundation.ts +8 -8
|
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
9
|
-
|
|
10
8
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
11
|
-
|
|
12
9
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
13
|
-
|
|
14
10
|
var _a11y = require("../utils/a11y");
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
/* eslint-disable no-param-reassign */
|
|
13
|
+
/* eslint-disable prefer-destructuring, max-lines-per-function, one-var, max-len, @typescript-eslint/restrict-plus-operands */
|
|
14
|
+
/* argus-disable unPkgSensitiveInfo */
|
|
17
15
|
|
|
18
16
|
const REGS = {
|
|
19
17
|
TOP: /top/i,
|
|
@@ -29,32 +27,25 @@ const defaultRect = {
|
|
|
29
27
|
scrollLeft: 0,
|
|
30
28
|
scrollTop: 0
|
|
31
29
|
};
|
|
32
|
-
|
|
33
30
|
class Tooltip extends _foundation.default {
|
|
34
31
|
constructor(adapter) {
|
|
35
32
|
var _this;
|
|
36
|
-
|
|
37
33
|
super(Object.assign({}, adapter));
|
|
38
34
|
_this = this;
|
|
39
|
-
|
|
40
35
|
this.removePortal = () => {
|
|
41
36
|
this._adapter.removePortal();
|
|
42
37
|
};
|
|
43
|
-
|
|
44
38
|
this.setDisplayNone = (displayNone, cb) => {
|
|
45
39
|
this._adapter.setDisplayNone(displayNone, cb);
|
|
46
40
|
};
|
|
47
|
-
|
|
48
41
|
this.onResize = () => {
|
|
49
42
|
// this.log('resize');
|
|
50
43
|
// rePosition when window resize
|
|
51
44
|
this.calcPosition();
|
|
52
45
|
};
|
|
53
|
-
|
|
54
46
|
this.delayShow = () => {
|
|
55
47
|
const mouseEnterDelay = this.getProp('mouseEnterDelay');
|
|
56
48
|
this.clearDelayTimer();
|
|
57
|
-
|
|
58
49
|
if (mouseEnterDelay > 0) {
|
|
59
50
|
this._timer = setTimeout(() => {
|
|
60
51
|
this.show();
|
|
@@ -64,7 +55,6 @@ class Tooltip extends _foundation.default {
|
|
|
64
55
|
this.show();
|
|
65
56
|
}
|
|
66
57
|
};
|
|
67
|
-
|
|
68
58
|
this.show = () => {
|
|
69
59
|
const content = this.getProp('content');
|
|
70
60
|
const trigger = this.getProp('trigger');
|
|
@@ -73,36 +63,28 @@ class Tooltip extends _foundation.default {
|
|
|
73
63
|
visible,
|
|
74
64
|
displayNone
|
|
75
65
|
} = this.getStates();
|
|
76
|
-
|
|
77
66
|
if (displayNone) {
|
|
78
67
|
this.setDisplayNone(false);
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
if (visible) {
|
|
82
70
|
return;
|
|
83
71
|
}
|
|
84
|
-
|
|
85
72
|
this.clearDelayTimer();
|
|
86
73
|
/**
|
|
87
74
|
* If you emit an event in setState callback, you need to place the event listener function before setState to execute.
|
|
88
75
|
* This is to avoid event registration being executed later than setState callback when setState is executed in setTimeout.
|
|
89
76
|
* internal-issues:1402#note_38969412
|
|
90
77
|
*/
|
|
91
|
-
|
|
92
78
|
this._adapter.on('portalInserted', () => {
|
|
93
79
|
this.calcPosition();
|
|
94
80
|
});
|
|
95
|
-
|
|
96
81
|
this._adapter.on('positionUpdated', () => {
|
|
97
82
|
this._togglePortalVisible(true);
|
|
98
83
|
});
|
|
99
|
-
|
|
100
84
|
this._adapter.insertPortal(content, {
|
|
101
85
|
left: -9999,
|
|
102
86
|
top: -9999
|
|
103
87
|
}); // offscreen rendering
|
|
104
|
-
|
|
105
|
-
|
|
106
88
|
if (trigger === 'custom') {
|
|
107
89
|
// eslint-disable-next-line
|
|
108
90
|
this._adapter.registerClickOutsideHandler(() => {});
|
|
@@ -116,14 +98,10 @@ class Tooltip extends _foundation.default {
|
|
|
116
98
|
* Because the handler needs to be bound to the document. If you bind during the constructor phase
|
|
117
99
|
* When there are multiple container instances in a page, one click triggers the handler of multiple containers
|
|
118
100
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
101
|
if (trigger === 'click' || clickTriggerToHide) {
|
|
122
102
|
this._adapter.registerClickOutsideHandler(this.hide);
|
|
123
103
|
}
|
|
124
|
-
|
|
125
104
|
this._bindScrollEvent();
|
|
126
|
-
|
|
127
105
|
this._bindResizeEvent();
|
|
128
106
|
};
|
|
129
107
|
/**
|
|
@@ -139,22 +117,18 @@ class Tooltip extends _foundation.default {
|
|
|
139
117
|
* - decide whether to automatically adjust the position according to the current position and the boundingClient of wrapper
|
|
140
118
|
* - adjust the current style according to the current position, the boundingClient of trigger and motion.handle Style
|
|
141
119
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
120
|
this.calcPosition = function (triggerRect, wrapperRect, containerRect) {
|
|
145
121
|
let shouldUpdatePos = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
146
122
|
triggerRect = ((0, _isEmpty2.default)(triggerRect) ? _this._adapter.getTriggerBounding() : triggerRect) || Object.assign({}, defaultRect);
|
|
147
123
|
containerRect = ((0, _isEmpty2.default)(containerRect) ? _this._adapter.getPopupContainerRect() : containerRect) || Object.assign({}, defaultRect);
|
|
148
|
-
wrapperRect = ((0, _isEmpty2.default)(wrapperRect) ? _this._adapter.getWrapperBounding() : wrapperRect) || Object.assign({}, defaultRect);
|
|
149
|
-
|
|
124
|
+
wrapperRect = ((0, _isEmpty2.default)(wrapperRect) ? _this._adapter.getWrapperBounding() : wrapperRect) || Object.assign({}, defaultRect);
|
|
125
|
+
// console.log('containerRect: ', containerRect, 'triggerRect: ', triggerRect, 'wrapperRect: ', wrapperRect);
|
|
150
126
|
let style = _this.calcPosStyle({
|
|
151
127
|
triggerRect,
|
|
152
128
|
wrapperRect,
|
|
153
129
|
containerRect
|
|
154
130
|
});
|
|
155
|
-
|
|
156
131
|
let position = _this.getProp('position');
|
|
157
|
-
|
|
158
132
|
if (_this.getProp('autoAdjustOverflow')) {
|
|
159
133
|
// console.log('style: ', style, '\ntriggerRect: ', triggerRect, '\nwrapperRect: ', wrapperRect);
|
|
160
134
|
const {
|
|
@@ -162,7 +136,6 @@ class Tooltip extends _foundation.default {
|
|
|
162
136
|
isHeightOverFlow,
|
|
163
137
|
isWidthOverFlow
|
|
164
138
|
} = _this.adjustPosIfNeed(position, style, triggerRect, wrapperRect, containerRect);
|
|
165
|
-
|
|
166
139
|
if (position !== adjustedPos || isHeightOverFlow || isWidthOverFlow) {
|
|
167
140
|
position = adjustedPos;
|
|
168
141
|
style = _this.calcPosStyle({
|
|
@@ -175,21 +148,17 @@ class Tooltip extends _foundation.default {
|
|
|
175
148
|
});
|
|
176
149
|
}
|
|
177
150
|
}
|
|
178
|
-
|
|
179
151
|
if (shouldUpdatePos && _this._mounted) {
|
|
180
152
|
// this._adapter.updatePlacementAttr(style.position);
|
|
181
153
|
_this._adapter.setPosition(Object.assign(Object.assign({}, style), {
|
|
182
154
|
position
|
|
183
155
|
}));
|
|
184
156
|
}
|
|
185
|
-
|
|
186
157
|
return style;
|
|
187
158
|
};
|
|
188
|
-
|
|
189
159
|
this.delayHide = () => {
|
|
190
160
|
const mouseLeaveDelay = this.getProp('mouseLeaveDelay');
|
|
191
161
|
this.clearDelayTimer();
|
|
192
|
-
|
|
193
162
|
if (mouseLeaveDelay > 0) {
|
|
194
163
|
this._timer = setTimeout(() => {
|
|
195
164
|
// console.log('delayHide for ', mouseLeaveDelay, ' ms, ', ...args);
|
|
@@ -200,36 +169,26 @@ class Tooltip extends _foundation.default {
|
|
|
200
169
|
this.hide();
|
|
201
170
|
}
|
|
202
171
|
};
|
|
203
|
-
|
|
204
172
|
this.hide = () => {
|
|
205
173
|
this.clearDelayTimer();
|
|
206
|
-
|
|
207
174
|
this._togglePortalVisible(false);
|
|
208
|
-
|
|
209
175
|
this._adapter.off('portalInserted');
|
|
210
|
-
|
|
211
176
|
this._adapter.off('positionUpdated');
|
|
212
177
|
};
|
|
213
|
-
|
|
214
178
|
this.handleContainerKeydown = event => {
|
|
215
179
|
const {
|
|
216
180
|
guardFocus,
|
|
217
181
|
closeOnEsc
|
|
218
182
|
} = this.getProps();
|
|
219
|
-
|
|
220
183
|
switch (event && event.key) {
|
|
221
184
|
case "Escape":
|
|
222
185
|
closeOnEsc && this._handleEscKeyDown(event);
|
|
223
186
|
break;
|
|
224
|
-
|
|
225
187
|
case "Tab":
|
|
226
188
|
if (guardFocus) {
|
|
227
189
|
const container = this._adapter.getContainer();
|
|
228
|
-
|
|
229
190
|
const focusableElements = this._adapter.getFocusableElements(container);
|
|
230
|
-
|
|
231
191
|
const focusableNum = focusableElements.length;
|
|
232
|
-
|
|
233
192
|
if (focusableNum) {
|
|
234
193
|
// Shift + Tab will move focus backward
|
|
235
194
|
if (event.shiftKey) {
|
|
@@ -239,104 +198,77 @@ class Tooltip extends _foundation.default {
|
|
|
239
198
|
}
|
|
240
199
|
}
|
|
241
200
|
}
|
|
242
|
-
|
|
243
201
|
break;
|
|
244
|
-
|
|
245
202
|
default:
|
|
246
203
|
break;
|
|
247
204
|
}
|
|
248
205
|
};
|
|
249
|
-
|
|
250
206
|
this._timer = null;
|
|
251
207
|
}
|
|
252
|
-
|
|
253
208
|
init() {
|
|
254
209
|
const {
|
|
255
210
|
wrapperId
|
|
256
211
|
} = this.getProps();
|
|
257
212
|
this._mounted = true;
|
|
258
|
-
|
|
259
213
|
this._bindEvent();
|
|
260
|
-
|
|
261
214
|
this._shouldShow();
|
|
262
|
-
|
|
263
215
|
this._initContainerPosition();
|
|
264
|
-
|
|
265
216
|
if (!wrapperId) {
|
|
266
217
|
this._adapter.setId();
|
|
267
218
|
}
|
|
268
219
|
}
|
|
269
|
-
|
|
270
220
|
destroy() {
|
|
271
221
|
this._mounted = false;
|
|
272
222
|
this.unBindEvent();
|
|
273
223
|
}
|
|
274
|
-
|
|
275
224
|
_bindEvent() {
|
|
276
225
|
const trigger = this.getProp('trigger'); // get trigger type
|
|
277
|
-
|
|
278
226
|
const {
|
|
279
227
|
triggerEventSet,
|
|
280
228
|
portalEventSet
|
|
281
229
|
} = this._generateEvent(trigger);
|
|
282
|
-
|
|
283
230
|
this._bindTriggerEvent(triggerEventSet);
|
|
284
|
-
|
|
285
231
|
this._bindPortalEvent(portalEventSet);
|
|
286
|
-
|
|
287
232
|
this._bindResizeEvent();
|
|
288
233
|
}
|
|
289
|
-
|
|
290
234
|
unBindEvent() {
|
|
291
235
|
this._adapter.unregisterClickOutsideHandler();
|
|
292
|
-
|
|
293
236
|
this.unBindResizeEvent();
|
|
294
237
|
this.unBindScrollEvent();
|
|
295
238
|
}
|
|
296
|
-
|
|
297
239
|
_bindTriggerEvent(triggerEventSet) {
|
|
298
240
|
this._adapter.registerTriggerEvent(triggerEventSet);
|
|
299
241
|
}
|
|
300
|
-
|
|
301
242
|
_bindPortalEvent(portalEventSet) {
|
|
302
243
|
this._adapter.registerPortalEvent(portalEventSet);
|
|
303
244
|
}
|
|
304
|
-
|
|
305
245
|
_bindResizeEvent() {
|
|
306
246
|
this._adapter.registerResizeHandler(this.onResize);
|
|
307
247
|
}
|
|
308
|
-
|
|
309
248
|
unBindResizeEvent() {
|
|
310
249
|
this._adapter.unregisterResizeHandler(this.onResize);
|
|
311
250
|
}
|
|
312
|
-
|
|
313
251
|
_adjustPos() {
|
|
314
252
|
let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
315
253
|
let isVertical = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
316
254
|
let adjustType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'reverse';
|
|
317
255
|
let concatPos = arguments.length > 3 ? arguments[3] : undefined;
|
|
318
|
-
|
|
319
256
|
switch (adjustType) {
|
|
320
257
|
case 'reverse':
|
|
321
258
|
return this._reversePos(position, isVertical);
|
|
322
|
-
|
|
323
259
|
case 'expand':
|
|
324
260
|
// only happens when position is top/bottom/left/right
|
|
325
261
|
return this._expandPos(position, concatPos);
|
|
326
|
-
|
|
327
262
|
case 'reduce':
|
|
328
263
|
// only happens when position other than top/bottom/left/right
|
|
329
264
|
return this._reducePos(position);
|
|
330
|
-
|
|
331
265
|
default:
|
|
332
266
|
return this._reversePos(position, isVertical);
|
|
333
267
|
}
|
|
334
268
|
}
|
|
335
|
-
|
|
336
269
|
_reversePos() {
|
|
337
270
|
let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
338
271
|
let isVertical = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
339
|
-
|
|
340
272
|
if (isVertical) {
|
|
341
273
|
if (REGS.TOP.test(position)) {
|
|
342
274
|
return position.replace('top', 'bottom').replace('Top', 'Bottom');
|
|
@@ -348,33 +280,27 @@ class Tooltip extends _foundation.default {
|
|
|
348
280
|
} else if (REGS.RIGHT.test(position)) {
|
|
349
281
|
return position.replace('right', 'left').replace('Right', 'Left');
|
|
350
282
|
}
|
|
351
|
-
|
|
352
283
|
return position;
|
|
353
284
|
}
|
|
354
|
-
|
|
355
285
|
_expandPos() {
|
|
356
286
|
let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
357
287
|
let concatPos = arguments.length > 1 ? arguments[1] : undefined;
|
|
358
288
|
return position.concat(concatPos);
|
|
359
289
|
}
|
|
360
|
-
|
|
361
290
|
_reducePos() {
|
|
362
291
|
let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
363
292
|
// if cur position consists of two directions, remove the last position
|
|
364
293
|
const found = ['Top', 'Bottom', 'Left', 'Right'].find(pos => position.endsWith(pos));
|
|
365
294
|
return found ? position.replace(found, '') : position;
|
|
366
295
|
}
|
|
367
|
-
|
|
368
296
|
clearDelayTimer() {
|
|
369
297
|
if (this._timer) {
|
|
370
298
|
clearTimeout(this._timer);
|
|
371
299
|
this._timer = null;
|
|
372
300
|
}
|
|
373
301
|
}
|
|
374
|
-
|
|
375
302
|
_generateEvent(types) {
|
|
376
303
|
const eventNames = this._adapter.getEventName();
|
|
377
|
-
|
|
378
304
|
const triggerEventSet = {
|
|
379
305
|
// bind esc keydown on trigger for a11y
|
|
380
306
|
[eventNames.keydown]: event => {
|
|
@@ -382,122 +308,101 @@ class Tooltip extends _foundation.default {
|
|
|
382
308
|
}
|
|
383
309
|
};
|
|
384
310
|
let portalEventSet = {};
|
|
385
|
-
|
|
386
311
|
switch (types) {
|
|
387
312
|
case 'focus':
|
|
388
313
|
triggerEventSet[eventNames.focus] = () => {
|
|
389
314
|
this.delayShow();
|
|
390
315
|
};
|
|
391
|
-
|
|
392
316
|
triggerEventSet[eventNames.blur] = () => {
|
|
393
317
|
this.delayHide();
|
|
394
318
|
};
|
|
395
|
-
|
|
396
319
|
portalEventSet = triggerEventSet;
|
|
397
320
|
break;
|
|
398
|
-
|
|
399
321
|
case 'click':
|
|
400
322
|
triggerEventSet[eventNames.click] = () => {
|
|
401
323
|
// this.delayShow();
|
|
402
324
|
this.show();
|
|
403
325
|
};
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
326
|
+
portalEventSet = {};
|
|
327
|
+
// Click outside needs special treatment, can not be directly tied to the trigger Element, need to be bound to the document
|
|
407
328
|
break;
|
|
408
|
-
|
|
409
329
|
case 'hover':
|
|
410
330
|
triggerEventSet[eventNames.mouseEnter] = () => {
|
|
411
331
|
// console.log(e);
|
|
412
332
|
this.setCache('isClickToHide', false);
|
|
413
|
-
this.delayShow();
|
|
333
|
+
this.delayShow();
|
|
334
|
+
// this.show('trigger');
|
|
414
335
|
};
|
|
415
336
|
|
|
416
337
|
triggerEventSet[eventNames.mouseLeave] = () => {
|
|
417
338
|
// console.log(e);
|
|
418
|
-
this.delayHide();
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
339
|
+
this.delayHide();
|
|
340
|
+
// this.hide('trigger');
|
|
341
|
+
};
|
|
342
|
+
// bind focus to hover trigger for a11y
|
|
422
343
|
triggerEventSet[eventNames.focus] = () => {
|
|
423
344
|
const {
|
|
424
345
|
disableFocusListener
|
|
425
346
|
} = this.getProps();
|
|
426
347
|
!disableFocusListener && this.delayShow();
|
|
427
348
|
};
|
|
428
|
-
|
|
429
349
|
triggerEventSet[eventNames.blur] = () => {
|
|
430
350
|
const {
|
|
431
351
|
disableFocusListener
|
|
432
352
|
} = this.getProps();
|
|
433
353
|
!disableFocusListener && this.delayHide();
|
|
434
354
|
};
|
|
435
|
-
|
|
436
355
|
portalEventSet = Object.assign({}, triggerEventSet);
|
|
437
|
-
|
|
438
356
|
if (this.getProp('clickToHide')) {
|
|
439
357
|
portalEventSet[eventNames.click] = () => {
|
|
440
358
|
this.setCache('isClickToHide', true);
|
|
441
359
|
this.hide();
|
|
442
360
|
};
|
|
443
|
-
|
|
444
361
|
portalEventSet[eventNames.mouseEnter] = () => {
|
|
445
362
|
if (this.getCache('isClickToHide')) {
|
|
446
363
|
return;
|
|
447
364
|
}
|
|
448
|
-
|
|
449
365
|
this.delayShow();
|
|
450
366
|
};
|
|
451
367
|
}
|
|
452
|
-
|
|
453
368
|
break;
|
|
454
|
-
|
|
455
369
|
case 'custom':
|
|
456
370
|
// when trigger type is 'custom', no need to bind eventHandler
|
|
457
371
|
// show/hide completely depend on props.visible which change by user
|
|
458
372
|
break;
|
|
459
|
-
|
|
460
373
|
default:
|
|
461
374
|
break;
|
|
462
375
|
}
|
|
463
|
-
|
|
464
376
|
return {
|
|
465
377
|
triggerEventSet,
|
|
466
378
|
portalEventSet
|
|
467
379
|
};
|
|
468
380
|
}
|
|
469
|
-
|
|
470
381
|
_shouldShow() {
|
|
471
382
|
const visible = this.getProp('visible');
|
|
472
|
-
|
|
473
383
|
if (visible) {
|
|
474
384
|
this.show();
|
|
475
|
-
} else {
|
|
385
|
+
} else {
|
|
386
|
+
// this.hide();
|
|
476
387
|
}
|
|
477
388
|
}
|
|
478
|
-
|
|
479
389
|
_togglePortalVisible(isVisible) {
|
|
480
390
|
const nowVisible = this.getState('visible');
|
|
481
|
-
|
|
482
391
|
if (nowVisible !== isVisible) {
|
|
483
392
|
this._adapter.togglePortalVisible(isVisible, () => {
|
|
484
393
|
if (isVisible) {
|
|
485
394
|
this._adapter.setInitialFocus();
|
|
486
395
|
}
|
|
487
|
-
|
|
488
396
|
this._adapter.notifyVisibleChange(isVisible);
|
|
489
397
|
});
|
|
490
398
|
}
|
|
491
399
|
}
|
|
492
|
-
|
|
493
400
|
_roundPixel(pixel) {
|
|
494
401
|
if (typeof pixel === 'number') {
|
|
495
402
|
return Math.round(pixel);
|
|
496
403
|
}
|
|
497
|
-
|
|
498
404
|
return pixel;
|
|
499
405
|
}
|
|
500
|
-
|
|
501
406
|
calcTransformOrigin(position, triggerRect, translateX, translateY) {
|
|
502
407
|
// eslint-disable-next-line
|
|
503
408
|
if (position && triggerRect && translateX != null && translateY != null) {
|
|
@@ -505,26 +410,20 @@ class Tooltip extends _foundation.default {
|
|
|
505
410
|
if (['topLeft', 'bottomLeft'].includes(position)) {
|
|
506
411
|
return `${this._roundPixel(triggerRect.width / 2)}px ${-translateY * 100}%`;
|
|
507
412
|
}
|
|
508
|
-
|
|
509
413
|
if (['topRight', 'bottomRight'].includes(position)) {
|
|
510
414
|
return `calc(100% - ${this._roundPixel(triggerRect.width / 2)}px) ${-translateY * 100}%`;
|
|
511
415
|
}
|
|
512
|
-
|
|
513
416
|
if (['leftTop', 'rightTop'].includes(position)) {
|
|
514
417
|
return `${-translateX * 100}% ${this._roundPixel(triggerRect.height / 2)}px`;
|
|
515
418
|
}
|
|
516
|
-
|
|
517
419
|
if (['leftBottom', 'rightBottom'].includes(position)) {
|
|
518
420
|
return `${-translateX * 100}% calc(100% - ${this._roundPixel(triggerRect.height / 2)}px)`;
|
|
519
421
|
}
|
|
520
422
|
}
|
|
521
|
-
|
|
522
423
|
return `${-translateX * 100}% ${-translateY * 100}%`;
|
|
523
424
|
}
|
|
524
|
-
|
|
525
425
|
return null;
|
|
526
426
|
}
|
|
527
|
-
|
|
528
427
|
calcPosStyle(props) {
|
|
529
428
|
const {
|
|
530
429
|
spacing,
|
|
@@ -535,10 +434,10 @@ class Tooltip extends _foundation.default {
|
|
|
535
434
|
} = window;
|
|
536
435
|
const triggerRect = ((0, _isEmpty2.default)(props.triggerRect) ? props.triggerRect : this._adapter.getTriggerBounding()) || Object.assign({}, defaultRect);
|
|
537
436
|
const containerRect = ((0, _isEmpty2.default)(props.containerRect) ? props.containerRect : this._adapter.getPopupContainerRect()) || Object.assign({}, defaultRect);
|
|
538
|
-
const wrapperRect = ((0, _isEmpty2.default)(props.wrapperRect) ? props.wrapperRect : this._adapter.getWrapperBounding()) || Object.assign({}, defaultRect);
|
|
539
|
-
|
|
540
|
-
const position = props.position != null ? props.position : this.getProp('position');
|
|
541
|
-
|
|
437
|
+
const wrapperRect = ((0, _isEmpty2.default)(props.wrapperRect) ? props.wrapperRect : this._adapter.getWrapperBounding()) || Object.assign({}, defaultRect);
|
|
438
|
+
// eslint-disable-next-line
|
|
439
|
+
const position = props.position != null ? props.position : this.getProp('position');
|
|
440
|
+
// eslint-disable-next-line
|
|
542
441
|
const SPACING = spacing != null ? spacing : this.getProp('spacing');
|
|
543
442
|
const {
|
|
544
443
|
arrowPointAtCenter,
|
|
@@ -550,15 +449,13 @@ class Tooltip extends _foundation.default {
|
|
|
550
449
|
const verticalArrowHeight = (0, _get2.default)(arrowBounding, 'width', 24);
|
|
551
450
|
const arrowOffsetY = (0, _get2.default)(arrowBounding, 'offsetY', 0);
|
|
552
451
|
const positionOffsetX = 6;
|
|
553
|
-
const positionOffsetY = 6;
|
|
452
|
+
const positionOffsetY = 6;
|
|
453
|
+
// You must use left/top when rendering, using right/bottom does not render the element position correctly
|
|
554
454
|
// Use left/top + translate to achieve tooltip positioning perfectly without knowing the size of the tooltip expansion layer
|
|
555
|
-
|
|
556
455
|
let left;
|
|
557
456
|
let top;
|
|
558
457
|
let translateX = 0; // Container x-direction translation distance
|
|
559
|
-
|
|
560
458
|
let translateY = 0; // Container y-direction translation distance
|
|
561
|
-
|
|
562
459
|
const middleX = triggerRect.left + triggerRect.width / 2;
|
|
563
460
|
const middleY = triggerRect.top + triggerRect.height / 2;
|
|
564
461
|
const offsetXWithArrow = positionOffsetX + horizontalArrowWidth / 2;
|
|
@@ -572,7 +469,6 @@ class Tooltip extends _foundation.default {
|
|
|
572
469
|
const isTriggerNearLeft = middleX - containerRect.left < containerRect.right - middleX;
|
|
573
470
|
const isTriggerNearTop = middleY - containerRect.top < containerRect.bottom - middleY;
|
|
574
471
|
const isWrapperWidthOverflow = wrapperRect.width > innerWidth;
|
|
575
|
-
|
|
576
472
|
switch (position) {
|
|
577
473
|
case 'top':
|
|
578
474
|
// left = middleX;
|
|
@@ -582,7 +478,6 @@ class Tooltip extends _foundation.default {
|
|
|
582
478
|
translateX = -0.5;
|
|
583
479
|
translateY = -1;
|
|
584
480
|
break;
|
|
585
|
-
|
|
586
481
|
case 'topLeft':
|
|
587
482
|
// left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
|
|
588
483
|
// top = triggerRect.top - SPACING;
|
|
@@ -590,7 +485,6 @@ class Tooltip extends _foundation.default {
|
|
|
590
485
|
top = isHeightOverFlow ? containerRect.bottom + offsetHeight : triggerRect.top - SPACING;
|
|
591
486
|
translateY = -1;
|
|
592
487
|
break;
|
|
593
|
-
|
|
594
488
|
case 'topRight':
|
|
595
489
|
// left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
|
|
596
490
|
// top = triggerRect.top - SPACING;
|
|
@@ -599,7 +493,6 @@ class Tooltip extends _foundation.default {
|
|
|
599
493
|
translateY = -1;
|
|
600
494
|
translateX = -1;
|
|
601
495
|
break;
|
|
602
|
-
|
|
603
496
|
case 'left':
|
|
604
497
|
// left = triggerRect.left - SPACING;
|
|
605
498
|
// top = middleY;
|
|
@@ -609,7 +502,6 @@ class Tooltip extends _foundation.default {
|
|
|
609
502
|
translateX = -1;
|
|
610
503
|
translateY = -0.5;
|
|
611
504
|
break;
|
|
612
|
-
|
|
613
505
|
case 'leftTop':
|
|
614
506
|
// left = triggerRect.left - SPACING;
|
|
615
507
|
// top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
|
|
@@ -617,7 +509,6 @@ class Tooltip extends _foundation.default {
|
|
|
617
509
|
top = isHeightOverFlow ? containerRect.top : pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
|
|
618
510
|
translateX = -1;
|
|
619
511
|
break;
|
|
620
|
-
|
|
621
512
|
case 'leftBottom':
|
|
622
513
|
// left = triggerRect.left - SPACING;
|
|
623
514
|
// top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
|
|
@@ -626,7 +517,6 @@ class Tooltip extends _foundation.default {
|
|
|
626
517
|
translateX = -1;
|
|
627
518
|
translateY = -1;
|
|
628
519
|
break;
|
|
629
|
-
|
|
630
520
|
case 'bottom':
|
|
631
521
|
// left = middleX;
|
|
632
522
|
// top = triggerRect.top + triggerRect.height + SPACING;
|
|
@@ -634,14 +524,12 @@ class Tooltip extends _foundation.default {
|
|
|
634
524
|
top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING : triggerRect.top + triggerRect.height + SPACING;
|
|
635
525
|
translateX = -0.5;
|
|
636
526
|
break;
|
|
637
|
-
|
|
638
527
|
case 'bottomLeft':
|
|
639
528
|
// left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
|
|
640
529
|
// top = triggerRect.bottom + SPACING;
|
|
641
530
|
left = isWidthOverFlow ? isWrapperWidthOverflow ? containerRect.left : containerRect.right - wrapperRect.width : pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
|
|
642
531
|
top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING : triggerRect.top + triggerRect.height + SPACING;
|
|
643
532
|
break;
|
|
644
|
-
|
|
645
533
|
case 'bottomRight':
|
|
646
534
|
// left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
|
|
647
535
|
// top = triggerRect.bottom + SPACING;
|
|
@@ -649,7 +537,6 @@ class Tooltip extends _foundation.default {
|
|
|
649
537
|
top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING : triggerRect.top + triggerRect.height + SPACING;
|
|
650
538
|
translateX = -1;
|
|
651
539
|
break;
|
|
652
|
-
|
|
653
540
|
case 'right':
|
|
654
541
|
// left = triggerRect.right + SPACING;
|
|
655
542
|
// top = middleY;
|
|
@@ -657,14 +544,12 @@ class Tooltip extends _foundation.default {
|
|
|
657
544
|
top = isHeightOverFlow ? isTriggerNearTop ? containerRect.top + wrapperRect.height / 2 : containerRect.bottom - wrapperRect.height / 2 + offsetHeight : middleY;
|
|
658
545
|
translateY = -0.5;
|
|
659
546
|
break;
|
|
660
|
-
|
|
661
547
|
case 'rightTop':
|
|
662
548
|
// left = triggerRect.right + SPACING;
|
|
663
549
|
// top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
|
|
664
550
|
left = isWidthOverFlow ? containerRect.left - SPACING + offsetXWithArrow : triggerRect.right + SPACING;
|
|
665
551
|
top = isHeightOverFlow ? containerRect.top : pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
|
|
666
552
|
break;
|
|
667
|
-
|
|
668
553
|
case 'rightBottom':
|
|
669
554
|
// left = triggerRect.right + SPACING;
|
|
670
555
|
// top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
|
|
@@ -672,40 +557,32 @@ class Tooltip extends _foundation.default {
|
|
|
672
557
|
top = isHeightOverFlow ? containerRect.bottom + offsetHeight : pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
|
|
673
558
|
translateY = -1;
|
|
674
559
|
break;
|
|
675
|
-
|
|
676
560
|
case 'leftTopOver':
|
|
677
561
|
left = triggerRect.left - SPACING;
|
|
678
562
|
top = triggerRect.top - SPACING;
|
|
679
563
|
break;
|
|
680
|
-
|
|
681
564
|
case 'rightTopOver':
|
|
682
565
|
left = triggerRect.right + SPACING;
|
|
683
566
|
top = triggerRect.top - SPACING;
|
|
684
567
|
translateX = -1;
|
|
685
568
|
break;
|
|
686
|
-
|
|
687
569
|
case 'leftBottomOver':
|
|
688
570
|
left = triggerRect.left - SPACING;
|
|
689
571
|
top = triggerRect.bottom + SPACING;
|
|
690
572
|
translateY = -1;
|
|
691
573
|
break;
|
|
692
|
-
|
|
693
574
|
case 'rightBottomOver':
|
|
694
575
|
left = triggerRect.right + SPACING;
|
|
695
576
|
top = triggerRect.bottom + SPACING;
|
|
696
577
|
translateX = -1;
|
|
697
578
|
translateY = -1;
|
|
698
579
|
break;
|
|
699
|
-
|
|
700
580
|
default:
|
|
701
581
|
break;
|
|
702
582
|
}
|
|
703
|
-
|
|
704
583
|
const transformOrigin = this.calcTransformOrigin(position, triggerRect, translateX, translateY); // Transform origin
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
584
|
+
const _containerIsBody = this._adapter.containerIsBody();
|
|
585
|
+
// Calculate container positioning relative to window
|
|
709
586
|
left = left - containerRect.left;
|
|
710
587
|
top = top - containerRect.top;
|
|
711
588
|
/**
|
|
@@ -715,99 +592,82 @@ class Tooltip extends _foundation.default {
|
|
|
715
592
|
* When container is body, if position is not relative or absolute, then the top/left calculated by trigger will be positioned according to html
|
|
716
593
|
* At this time, if the body has a margin, the calculated position will have a problem relative to the body fix issue #1368
|
|
717
594
|
*/
|
|
718
|
-
|
|
719
595
|
if (_containerIsBody && !this._adapter.containerIsRelativeOrAbsolute()) {
|
|
720
|
-
const documentEleRect = this._adapter.getDocumentElementBounding();
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
596
|
+
const documentEleRect = this._adapter.getDocumentElementBounding();
|
|
597
|
+
// Represents the left of the body relative to html
|
|
598
|
+
left += containerRect.left - documentEleRect.left;
|
|
599
|
+
// Represents the top of the body relative to html
|
|
725
600
|
top += containerRect.top - documentEleRect.top;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
|
|
601
|
+
}
|
|
602
|
+
// ContainerRect.scrollLeft to solve the inner scrolling of the container
|
|
729
603
|
left = _containerIsBody ? left : left + containerRect.scrollLeft;
|
|
730
604
|
top = _containerIsBody ? top : top + containerRect.scrollTop;
|
|
731
605
|
const triggerHeight = triggerRect.height;
|
|
732
|
-
|
|
733
606
|
if (this.getProp('showArrow') && !arrowPointAtCenter && triggerHeight <= (verticalArrowHeight / 2 + arrowOffsetY) * 2) {
|
|
734
607
|
const offsetY = triggerHeight / 2 - (arrowOffsetY + verticalArrowHeight / 2);
|
|
735
|
-
|
|
736
608
|
if ((position.includes('Top') || position.includes('Bottom')) && !position.includes('Over')) {
|
|
737
609
|
top = position.includes('Top') ? top + offsetY : top - offsetY;
|
|
738
610
|
}
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
|
|
611
|
+
}
|
|
612
|
+
// The left/top value here must be rounded, otherwise it will cause the small triangle to shake
|
|
742
613
|
const style = {
|
|
743
614
|
left: this._roundPixel(left),
|
|
744
615
|
top: this._roundPixel(top)
|
|
745
616
|
};
|
|
746
|
-
let transform = '';
|
|
747
|
-
|
|
617
|
+
let transform = '';
|
|
618
|
+
// eslint-disable-next-line
|
|
748
619
|
if (translateX != null) {
|
|
749
620
|
transform += `translateX(${translateX * 100}%) `;
|
|
750
621
|
Object.defineProperty(style, 'translateX', {
|
|
751
622
|
enumerable: false,
|
|
752
623
|
value: translateX
|
|
753
624
|
});
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
|
|
625
|
+
}
|
|
626
|
+
// eslint-disable-next-line
|
|
757
627
|
if (translateY != null) {
|
|
758
628
|
transform += `translateY(${translateY * 100}%) `;
|
|
759
629
|
Object.defineProperty(style, 'translateY', {
|
|
760
630
|
enumerable: false,
|
|
761
631
|
value: translateY
|
|
762
632
|
});
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
|
|
633
|
+
}
|
|
634
|
+
// eslint-disable-next-line
|
|
766
635
|
if (transformOrigin != null) {
|
|
767
636
|
style.transformOrigin = transformOrigin;
|
|
768
637
|
}
|
|
769
|
-
|
|
770
638
|
if (transform) {
|
|
771
639
|
style.transform = transform;
|
|
772
640
|
}
|
|
773
|
-
|
|
774
641
|
return style;
|
|
775
642
|
}
|
|
776
|
-
|
|
777
643
|
isLR() {
|
|
778
644
|
let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
779
645
|
return position.includes('left') || position.includes('right');
|
|
780
646
|
}
|
|
781
|
-
|
|
782
647
|
isTB() {
|
|
783
648
|
let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
784
649
|
return position.includes('top') || position.includes('bottom');
|
|
785
650
|
}
|
|
786
|
-
|
|
787
651
|
isReverse(rowSpace, reverseSpace, size) {
|
|
788
652
|
// 原空间不足,反向空间足够
|
|
789
653
|
// Insufficient original space, enough reverse space
|
|
790
654
|
return rowSpace < size && reverseSpace > size;
|
|
791
655
|
}
|
|
792
|
-
|
|
793
656
|
isOverFlow(rowSpace, reverseSpace, size) {
|
|
794
657
|
// 原空间且反向空间都不足
|
|
795
658
|
// The original space and the reverse space are not enough
|
|
796
659
|
return rowSpace < size && reverseSpace < size;
|
|
797
660
|
}
|
|
798
|
-
|
|
799
661
|
isHalfOverFlow(posSpace, negSpace, size) {
|
|
800
662
|
// 正半空间或者负半空间不足,即表示有遮挡,需要偏移
|
|
801
663
|
// Insufficient positive half space or negative half space means that there is occlusion and needs to be offset
|
|
802
664
|
return posSpace < size || negSpace < size;
|
|
803
665
|
}
|
|
804
|
-
|
|
805
666
|
isHalfAllEnough(posSpace, negSpace, size) {
|
|
806
667
|
// 正半空间和负半空间都足够,即表示可以从 topLeft/topRight 变成 top
|
|
807
668
|
// Both positive and negative half-spaces are sufficient, which means you can change from topLeft/topRight to top
|
|
808
669
|
return posSpace >= size || negSpace >= size;
|
|
809
670
|
}
|
|
810
|
-
|
|
811
671
|
getReverse(viewOverFlow, containerOverFlow, shouldReverseView, shouldReverseContainer) {
|
|
812
672
|
/**
|
|
813
673
|
* 基于视口和容器一起判断,以下几种情况允许从原方向转到反方向,以判断是否应该由top->bottom为例子
|
|
@@ -823,9 +683,8 @@ class Tooltip extends _foundation.default {
|
|
|
823
683
|
* 3. Viewport upper space ❌ lower space✅ and container upper space ❌ lower space✅
|
|
824
684
|
*/
|
|
825
685
|
return viewOverFlow && shouldReverseContainer || shouldReverseView && containerOverFlow || shouldReverseView && shouldReverseContainer;
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
|
|
686
|
+
}
|
|
687
|
+
// place the dom correctly
|
|
829
688
|
adjustPosIfNeed(position, style, triggerRect, wrapperRect, containerRect) {
|
|
830
689
|
const {
|
|
831
690
|
innerWidth,
|
|
@@ -841,7 +700,6 @@ class Tooltip extends _foundation.default {
|
|
|
841
700
|
const marginBottom = typeof margin === 'number' ? margin : margin.marginBottom;
|
|
842
701
|
let isHeightOverFlow = false;
|
|
843
702
|
let isWidthOverFlow = false;
|
|
844
|
-
|
|
845
703
|
if (wrapperRect.width > 0 && wrapperRect.height > 0) {
|
|
846
704
|
// let clientLeft = left + translateX * wrapperRect.width - containerRect.scrollLeft;
|
|
847
705
|
// let clientTop = top + translateY * wrapperRect.height - containerRect.scrollTop;
|
|
@@ -862,10 +720,10 @@ class Tooltip extends _foundation.default {
|
|
|
862
720
|
const restClientRight = innerWidth - clientRight;
|
|
863
721
|
const restClientBottom = innerHeight - clientBottom;
|
|
864
722
|
const widthIsBigger = wrapperRect.width > triggerRect.width;
|
|
865
|
-
const heightIsBigger = wrapperRect.height > triggerRect.height;
|
|
723
|
+
const heightIsBigger = wrapperRect.height > triggerRect.height;
|
|
724
|
+
// The wrapperR ect.top|bottom equivalent cannot be directly used here for comparison, which is easy to cause jitter
|
|
866
725
|
// 基于视口的微调判断
|
|
867
726
|
// Fine-tuning judgment based on viewport
|
|
868
|
-
|
|
869
727
|
const shouldViewReverseTop = clientTop - marginTop < wrapperRect.height + spacing && restClientBottom - marginBottom > wrapperRect.height + spacing;
|
|
870
728
|
const shouldViewReverseLeft = clientLeft - marginLeft < wrapperRect.width + spacing && restClientRight - marginRight > wrapperRect.width + spacing;
|
|
871
729
|
const shouldViewReverseBottom = restClientBottom - marginBottom < wrapperRect.height + spacing && clientTop - marginTop > wrapperRect.height + spacing;
|
|
@@ -879,9 +737,9 @@ class Tooltip extends _foundation.default {
|
|
|
879
737
|
const shouldReverseTopOver = restClientTop < wrapperRect.height + spacing && clientBottom > wrapperRect.height + spacing;
|
|
880
738
|
const shouldReverseBottomOver = clientBottom < wrapperRect.height + spacing && restClientTop > wrapperRect.height + spacing;
|
|
881
739
|
const shouldReverseLeftOver = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
|
|
882
|
-
const shouldReverseRightOver = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
|
|
740
|
+
const shouldReverseRightOver = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
|
|
741
|
+
// 基于容器的微调判断
|
|
883
742
|
// Fine-tuning judgment based on container
|
|
884
|
-
|
|
885
743
|
const clientTopInContainer = clientTop - containerRect.top;
|
|
886
744
|
const clientLeftInContainer = clientLeft - containerRect.left;
|
|
887
745
|
const clientBottomInContainer = clientTopInContainer + triggerRect.height;
|
|
@@ -889,9 +747,9 @@ class Tooltip extends _foundation.default {
|
|
|
889
747
|
const restClientBottomInContainer = containerRect.bottom - clientBottom;
|
|
890
748
|
const restClientRightInContainer = containerRect.right - clientRight;
|
|
891
749
|
const restClientTopInContainer = restClientBottomInContainer + triggerRect.height;
|
|
892
|
-
const restClientLeftInContainer = restClientRightInContainer + triggerRect.width;
|
|
750
|
+
const restClientLeftInContainer = restClientRightInContainer + triggerRect.width;
|
|
751
|
+
// 当原空间不足,反向空间足够时,可以反向。
|
|
893
752
|
// When the original space is insufficient and the reverse space is sufficient, the reverse can be performed.
|
|
894
|
-
|
|
895
753
|
const shouldContainerReverseTop = this.isReverse(clientTopInContainer - marginTop, restClientBottomInContainer - marginBottom, wrapperRect.height + spacing);
|
|
896
754
|
const shouldContainerReverseLeft = this.isReverse(clientLeftInContainer - marginLeft, restClientRightInContainer - marginRight, wrapperRect.width + spacing);
|
|
897
755
|
const shouldContainerReverseBottom = this.isReverse(restClientBottomInContainer - marginBottom, clientTopInContainer - marginTop, wrapperRect.height + spacing);
|
|
@@ -903,9 +761,9 @@ class Tooltip extends _foundation.default {
|
|
|
903
761
|
const shouldContainerReverseLeftSide = this.isReverse(restClientLeftInContainer, clientRightInContainer, wrapperRect.width);
|
|
904
762
|
const shouldContainerReverseRightSide = this.isReverse(clientRightInContainer, restClientLeftInContainer, wrapperRect.width);
|
|
905
763
|
const halfHeight = triggerRect.height / 2;
|
|
906
|
-
const halfWidth = triggerRect.width / 2;
|
|
764
|
+
const halfWidth = triggerRect.width / 2;
|
|
765
|
+
// 视口, 原空间与反向空间是否都不足判断
|
|
907
766
|
// Viewport, whether the original space and the reverse space are insufficient to judge
|
|
908
|
-
|
|
909
767
|
const isViewYOverFlow = this.isOverFlow(clientTop - marginTop, restClientBottom - marginBottom, wrapperRect.height + spacing);
|
|
910
768
|
const isViewXOverFlow = this.isOverFlow(clientLeft - marginLeft, restClientRight - marginRight, wrapperRect.width + spacing);
|
|
911
769
|
const isViewYOverFlowSide = this.isOverFlow(clientBottom - marginTop, restClientTop - marginBottom, wrapperRect.height + spacing);
|
|
@@ -913,9 +771,9 @@ class Tooltip extends _foundation.default {
|
|
|
913
771
|
const isViewYOverFlowSideHalf = this.isHalfOverFlow(clientBottom - halfHeight, restClientTop - halfHeight, wrapperRect.height / 2);
|
|
914
772
|
const isViewXOverFlowSideHalf = this.isHalfOverFlow(clientRight - halfWidth, restClientLeft - halfWidth, wrapperRect.width / 2);
|
|
915
773
|
const isViewYEnoughSideHalf = this.isHalfAllEnough(clientBottom - halfHeight, restClientTop - halfHeight, wrapperRect.height / 2);
|
|
916
|
-
const isViewXEnoughSideHalf = this.isHalfAllEnough(clientRight - halfWidth, restClientLeft - halfWidth, wrapperRect.width / 2);
|
|
774
|
+
const isViewXEnoughSideHalf = this.isHalfAllEnough(clientRight - halfWidth, restClientLeft - halfWidth, wrapperRect.width / 2);
|
|
775
|
+
// 容器, 原空间与反向空间是否都不足判断
|
|
917
776
|
// container, whether the original space and the reverse space are insufficient to judge
|
|
918
|
-
|
|
919
777
|
const isContainerYOverFlow = this.isOverFlow(clientTopInContainer - marginTop, restClientBottomInContainer - marginBottom, wrapperRect.height + spacing);
|
|
920
778
|
const isContainerXOverFlow = this.isOverFlow(clientLeftInContainer - marginLeft, restClientRightInContainer - marginRight, wrapperRect.width + spacing);
|
|
921
779
|
const isContainerYOverFlowSide = this.isOverFlow(clientBottomInContainer - marginTop, restClientTopInContainer - marginBottom, wrapperRect.height + spacing);
|
|
@@ -923,254 +781,195 @@ class Tooltip extends _foundation.default {
|
|
|
923
781
|
const isContainerYOverFlowSideHalf = this.isHalfOverFlow(clientBottomInContainer - halfHeight, restClientTopInContainer - halfHeight, wrapperRect.height / 2);
|
|
924
782
|
const isContainerXOverFlowSideHalf = this.isHalfOverFlow(clientRightInContainer - halfWidth, restClientLeftInContainer - halfWidth, wrapperRect.width / 2);
|
|
925
783
|
const isContainerYEnoughSideHalf = this.isHalfAllEnough(clientBottomInContainer - halfHeight, restClientTopInContainer - halfHeight, wrapperRect.height / 2);
|
|
926
|
-
const isContainerXEnoughSideHalf = this.isHalfAllEnough(clientRightInContainer - halfWidth, restClientLeftInContainer - halfWidth, wrapperRect.width / 2);
|
|
784
|
+
const isContainerXEnoughSideHalf = this.isHalfAllEnough(clientRightInContainer - halfWidth, restClientLeftInContainer - halfWidth, wrapperRect.width / 2);
|
|
785
|
+
// 综合 viewport + container 判断微调,即视口 + 容器都放置不行时才能考虑位置调整
|
|
927
786
|
// Comprehensive viewport + container judgment fine-tuning, that is, the position adjustment can only be considered when the viewport + container cannot be placed.
|
|
928
|
-
|
|
929
787
|
const shouldReverseTop = this.getReverse(isViewYOverFlow, isContainerYOverFlow, shouldViewReverseTop, shouldContainerReverseTop);
|
|
930
788
|
const shouldReverseLeft = this.getReverse(isViewXOverFlow, isContainerXOverFlow, shouldViewReverseLeft, shouldContainerReverseLeft);
|
|
931
789
|
const shouldReverseBottom = this.getReverse(isViewYOverFlow, isContainerYOverFlow, shouldViewReverseBottom, shouldContainerReverseBottom);
|
|
932
|
-
const shouldReverseRight = this.getReverse(isViewXOverFlow, isContainerXOverFlow, shouldViewReverseRight, shouldContainerReverseRight);
|
|
790
|
+
const shouldReverseRight = this.getReverse(isViewXOverFlow, isContainerXOverFlow, shouldViewReverseRight, shouldContainerReverseRight);
|
|
791
|
+
// const shouldReverseTopOver = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseTopOver, shouldContainerReverseTopOver);
|
|
933
792
|
// const shouldReverseBottomOver = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseBottomOver, shouldContainerReverseBottomOver);
|
|
934
|
-
|
|
935
793
|
const shouldReverseTopSide = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseTopSide, shouldContainerReverseTopSide);
|
|
936
794
|
const shouldReverseBottomSide = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseBottomSide, shouldContainerReverseBottomSide);
|
|
937
795
|
const shouldReverseLeftSide = this.getReverse(isViewXOverFlowSide, isContainerXOverFlowSide, shouldViewReverseLeftSide, shouldContainerReverseLeftSide);
|
|
938
796
|
const shouldReverseRightSide = this.getReverse(isViewXOverFlowSide, isContainerXOverFlowSide, shouldViewReverseRightSide, shouldContainerReverseRightSide);
|
|
939
797
|
const isYOverFlowSideHalf = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf;
|
|
940
798
|
const isXOverFlowSideHalf = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf;
|
|
941
|
-
|
|
942
799
|
switch (position) {
|
|
943
800
|
case 'top':
|
|
944
801
|
if (shouldReverseTop) {
|
|
945
802
|
position = this._adjustPos(position, true);
|
|
946
803
|
}
|
|
947
|
-
|
|
948
804
|
if (isXOverFlowSideHalf && (shouldReverseLeftSide || shouldReverseRightSide)) {
|
|
949
805
|
position = this._adjustPos(position, true, 'expand', shouldReverseLeftSide ? 'Right' : 'Left');
|
|
950
806
|
}
|
|
951
|
-
|
|
952
807
|
break;
|
|
953
|
-
|
|
954
808
|
case 'topLeft':
|
|
955
809
|
if (shouldReverseTop) {
|
|
956
810
|
position = this._adjustPos(position, true);
|
|
957
811
|
}
|
|
958
|
-
|
|
959
812
|
if (shouldReverseLeftSide && widthIsBigger) {
|
|
960
813
|
position = this._adjustPos(position);
|
|
961
814
|
}
|
|
962
|
-
|
|
963
815
|
if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
|
|
964
816
|
position = this._adjustPos(position, true, 'reduce');
|
|
965
817
|
}
|
|
966
|
-
|
|
967
818
|
break;
|
|
968
|
-
|
|
969
819
|
case 'topRight':
|
|
970
820
|
if (shouldReverseTop) {
|
|
971
821
|
position = this._adjustPos(position, true);
|
|
972
822
|
}
|
|
973
|
-
|
|
974
823
|
if (shouldReverseRightSide && widthIsBigger) {
|
|
975
824
|
position = this._adjustPos(position);
|
|
976
825
|
}
|
|
977
|
-
|
|
978
826
|
if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
|
|
979
827
|
position = this._adjustPos(position, true, 'reduce');
|
|
980
828
|
}
|
|
981
|
-
|
|
982
829
|
break;
|
|
983
|
-
|
|
984
830
|
case 'left':
|
|
985
831
|
if (shouldReverseLeft) {
|
|
986
832
|
position = this._adjustPos(position);
|
|
987
833
|
}
|
|
988
|
-
|
|
989
834
|
if (isYOverFlowSideHalf && (shouldReverseTopSide || shouldReverseBottomSide)) {
|
|
990
835
|
position = this._adjustPos(position, false, 'expand', shouldReverseTopSide ? 'Bottom' : 'Top');
|
|
991
836
|
}
|
|
992
|
-
|
|
993
837
|
break;
|
|
994
|
-
|
|
995
838
|
case 'leftTop':
|
|
996
839
|
if (shouldReverseLeft) {
|
|
997
840
|
position = this._adjustPos(position);
|
|
998
841
|
}
|
|
999
|
-
|
|
1000
842
|
if (shouldReverseTopSide && heightIsBigger) {
|
|
1001
843
|
position = this._adjustPos(position, true);
|
|
1002
844
|
}
|
|
1003
|
-
|
|
1004
845
|
if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
|
|
1005
846
|
position = this._adjustPos(position, false, 'reduce');
|
|
1006
847
|
}
|
|
1007
|
-
|
|
1008
848
|
break;
|
|
1009
|
-
|
|
1010
849
|
case 'leftBottom':
|
|
1011
850
|
if (shouldReverseLeft) {
|
|
1012
851
|
position = this._adjustPos(position);
|
|
1013
852
|
}
|
|
1014
|
-
|
|
1015
853
|
if (shouldReverseBottomSide && heightIsBigger) {
|
|
1016
854
|
position = this._adjustPos(position, true);
|
|
1017
855
|
}
|
|
1018
|
-
|
|
1019
856
|
if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
|
|
1020
857
|
position = this._adjustPos(position, false, 'reduce');
|
|
1021
858
|
}
|
|
1022
|
-
|
|
1023
859
|
break;
|
|
1024
|
-
|
|
1025
860
|
case 'bottom':
|
|
1026
861
|
if (shouldReverseBottom) {
|
|
1027
862
|
position = this._adjustPos(position, true);
|
|
1028
863
|
}
|
|
1029
|
-
|
|
1030
864
|
if (isXOverFlowSideHalf && (shouldReverseLeftSide || shouldReverseRightSide)) {
|
|
1031
865
|
position = this._adjustPos(position, true, 'expand', shouldReverseLeftSide ? 'Right' : 'Left');
|
|
1032
866
|
}
|
|
1033
|
-
|
|
1034
867
|
break;
|
|
1035
|
-
|
|
1036
868
|
case 'bottomLeft':
|
|
1037
869
|
if (shouldReverseBottom) {
|
|
1038
870
|
position = this._adjustPos(position, true);
|
|
1039
871
|
}
|
|
1040
|
-
|
|
1041
872
|
if (shouldReverseLeftSide && widthIsBigger) {
|
|
1042
873
|
position = this._adjustPos(position);
|
|
1043
874
|
}
|
|
1044
|
-
|
|
1045
875
|
if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
|
|
1046
876
|
position = this._adjustPos(position, true, 'reduce');
|
|
1047
877
|
}
|
|
1048
|
-
|
|
1049
878
|
break;
|
|
1050
|
-
|
|
1051
879
|
case 'bottomRight':
|
|
1052
880
|
if (shouldReverseBottom) {
|
|
1053
881
|
position = this._adjustPos(position, true);
|
|
1054
882
|
}
|
|
1055
|
-
|
|
1056
883
|
if (shouldReverseRightSide && widthIsBigger) {
|
|
1057
884
|
position = this._adjustPos(position);
|
|
1058
885
|
}
|
|
1059
|
-
|
|
1060
886
|
if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
|
|
1061
887
|
position = this._adjustPos(position, true, 'reduce');
|
|
1062
888
|
}
|
|
1063
|
-
|
|
1064
889
|
break;
|
|
1065
|
-
|
|
1066
890
|
case 'right':
|
|
1067
891
|
if (shouldReverseRight) {
|
|
1068
892
|
position = this._adjustPos(position);
|
|
1069
893
|
}
|
|
1070
|
-
|
|
1071
894
|
if (isYOverFlowSideHalf && (shouldReverseTopSide || shouldReverseBottomSide)) {
|
|
1072
895
|
position = this._adjustPos(position, false, 'expand', shouldReverseTopSide ? 'Bottom' : 'Top');
|
|
1073
896
|
}
|
|
1074
|
-
|
|
1075
897
|
break;
|
|
1076
|
-
|
|
1077
898
|
case 'rightTop':
|
|
1078
899
|
if (shouldReverseRight) {
|
|
1079
900
|
position = this._adjustPos(position);
|
|
1080
901
|
}
|
|
1081
|
-
|
|
1082
902
|
if (shouldReverseTopSide && heightIsBigger) {
|
|
1083
903
|
position = this._adjustPos(position, true);
|
|
1084
904
|
}
|
|
1085
|
-
|
|
1086
905
|
if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
|
|
1087
906
|
position = this._adjustPos(position, false, 'reduce');
|
|
1088
907
|
}
|
|
1089
|
-
|
|
1090
908
|
break;
|
|
1091
|
-
|
|
1092
909
|
case 'rightBottom':
|
|
1093
910
|
if (shouldReverseRight) {
|
|
1094
911
|
position = this._adjustPos(position);
|
|
1095
912
|
}
|
|
1096
|
-
|
|
1097
913
|
if (shouldReverseBottomSide && heightIsBigger) {
|
|
1098
914
|
position = this._adjustPos(position, true);
|
|
1099
915
|
}
|
|
1100
|
-
|
|
1101
916
|
if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
|
|
1102
917
|
position = this._adjustPos(position, false, 'reduce');
|
|
1103
918
|
}
|
|
1104
|
-
|
|
1105
919
|
break;
|
|
1106
|
-
|
|
1107
920
|
case 'leftTopOver':
|
|
1108
921
|
if (shouldReverseTopOver) {
|
|
1109
922
|
position = this._adjustPos(position, true);
|
|
1110
923
|
}
|
|
1111
|
-
|
|
1112
924
|
if (shouldReverseLeftOver) {
|
|
1113
925
|
position = this._adjustPos(position);
|
|
1114
926
|
}
|
|
1115
|
-
|
|
1116
927
|
break;
|
|
1117
|
-
|
|
1118
928
|
case 'leftBottomOver':
|
|
1119
929
|
if (shouldReverseBottomOver) {
|
|
1120
930
|
position = this._adjustPos(position, true);
|
|
1121
931
|
}
|
|
1122
|
-
|
|
1123
932
|
if (shouldReverseLeftOver) {
|
|
1124
933
|
position = this._adjustPos(position);
|
|
1125
934
|
}
|
|
1126
|
-
|
|
1127
935
|
break;
|
|
1128
|
-
|
|
1129
936
|
case 'rightTopOver':
|
|
1130
937
|
if (shouldReverseTopOver) {
|
|
1131
938
|
position = this._adjustPos(position, true);
|
|
1132
939
|
}
|
|
1133
|
-
|
|
1134
940
|
if (shouldReverseRightOver) {
|
|
1135
941
|
position = this._adjustPos(position);
|
|
1136
942
|
}
|
|
1137
|
-
|
|
1138
943
|
break;
|
|
1139
|
-
|
|
1140
944
|
case 'rightBottomOver':
|
|
1141
945
|
if (shouldReverseBottomOver) {
|
|
1142
946
|
position = this._adjustPos(position, true);
|
|
1143
947
|
}
|
|
1144
|
-
|
|
1145
948
|
if (shouldReverseRightOver) {
|
|
1146
949
|
position = this._adjustPos(position);
|
|
1147
950
|
}
|
|
1148
|
-
|
|
1149
951
|
break;
|
|
1150
|
-
|
|
1151
952
|
default:
|
|
1152
953
|
break;
|
|
1153
|
-
}
|
|
954
|
+
}
|
|
955
|
+
// 判断溢出 Judgment overflow
|
|
1154
956
|
// 上下方向 top and bottom
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
957
|
if (this.isTB(position)) {
|
|
1158
|
-
isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow;
|
|
958
|
+
isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow;
|
|
959
|
+
// Related PR: https://github.com/DouyinFE/semi-design/pull/1297
|
|
1159
960
|
// If clientRight or restClientRight less than 0, means that the left and right parts of the trigger are blocked
|
|
1160
961
|
// Then the display of the wrapper will also be affected, make width overflow to offset the wrapper
|
|
1161
|
-
|
|
1162
962
|
if (position === 'top' || position === 'bottom') {
|
|
1163
963
|
isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf || clientRight < 0 || restClientRight < 0;
|
|
1164
964
|
} else {
|
|
1165
965
|
isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide || clientRight < 0 || restClientRight < 0;
|
|
1166
966
|
}
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
|
|
967
|
+
}
|
|
968
|
+
// 左右方向 left and right
|
|
1170
969
|
if (this.isLR(position)) {
|
|
1171
|
-
isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow;
|
|
970
|
+
isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow;
|
|
971
|
+
// If clientTop or restClientTop less than 0, means that the top and bottom parts of the trigger are blocked
|
|
1172
972
|
// Then the display of the wrapper will also be affected, make height overflow to offset the wrapper
|
|
1173
|
-
|
|
1174
973
|
if (position === 'left' || position === 'right') {
|
|
1175
974
|
isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf || clientTop < 0 || restClientTop < 0;
|
|
1176
975
|
} else {
|
|
@@ -1178,55 +977,44 @@ class Tooltip extends _foundation.default {
|
|
|
1178
977
|
}
|
|
1179
978
|
}
|
|
1180
979
|
}
|
|
1181
|
-
|
|
1182
980
|
return {
|
|
1183
981
|
position,
|
|
1184
982
|
isHeightOverFlow,
|
|
1185
983
|
isWidthOverFlow
|
|
1186
984
|
};
|
|
1187
985
|
}
|
|
1188
|
-
|
|
1189
986
|
_bindScrollEvent() {
|
|
1190
|
-
this._adapter.registerScrollHandler(() => this.calcPosition());
|
|
987
|
+
this._adapter.registerScrollHandler(() => this.calcPosition());
|
|
988
|
+
// Capture scroll events on the window to determine whether the current scrolling area (e.target) will affect the positioning of the pop-up layer relative to the viewport when scrolling
|
|
1191
989
|
// (By determining whether the e.target contains the triggerDom of the current tooltip) If so, the pop-up layer will also be affected and needs to be repositioned
|
|
1192
|
-
|
|
1193
990
|
}
|
|
1194
991
|
|
|
1195
992
|
unBindScrollEvent() {
|
|
1196
993
|
this._adapter.unregisterScrollHandler();
|
|
1197
994
|
}
|
|
1198
|
-
|
|
1199
995
|
_initContainerPosition() {
|
|
1200
996
|
this._adapter.updateContainerPosition();
|
|
1201
997
|
}
|
|
1202
|
-
|
|
1203
998
|
_handleTriggerKeydown(event) {
|
|
1204
999
|
const {
|
|
1205
1000
|
closeOnEsc,
|
|
1206
1001
|
disableArrowKeyDown
|
|
1207
1002
|
} = this.getProps();
|
|
1208
|
-
|
|
1209
1003
|
const container = this._adapter.getContainer();
|
|
1210
|
-
|
|
1211
1004
|
const focusableElements = this._adapter.getFocusableElements(container);
|
|
1212
|
-
|
|
1213
1005
|
const focusableNum = focusableElements.length;
|
|
1214
|
-
|
|
1215
1006
|
switch (event && event.key) {
|
|
1216
1007
|
case "Escape":
|
|
1217
1008
|
(0, _a11y.handlePrevent)(event);
|
|
1218
1009
|
closeOnEsc && this._handleEscKeyDown(event);
|
|
1219
1010
|
break;
|
|
1220
|
-
|
|
1221
1011
|
case "ArrowUp":
|
|
1222
1012
|
// when disableArrowKeyDown is true, disable tooltip's arrow keyboard event action
|
|
1223
1013
|
!disableArrowKeyDown && focusableNum && this._handleTriggerArrowUpKeydown(focusableElements, event);
|
|
1224
1014
|
break;
|
|
1225
|
-
|
|
1226
1015
|
case "ArrowDown":
|
|
1227
1016
|
!disableArrowKeyDown && focusableNum && this._handleTriggerArrowDownKeydown(focusableElements, event);
|
|
1228
1017
|
break;
|
|
1229
|
-
|
|
1230
1018
|
default:
|
|
1231
1019
|
break;
|
|
1232
1020
|
}
|
|
@@ -1240,18 +1028,14 @@ class Tooltip extends _foundation.default {
|
|
|
1240
1028
|
* 如果 trigger 是 focus 或者 hover,则它绑定了 onFocus,这里我们如果重新 focus 的话,popup 会再次打开
|
|
1241
1029
|
* 因此 returnFocusOnClose 只支持 click trigger
|
|
1242
1030
|
*/
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
1031
|
focusTrigger() {
|
|
1246
1032
|
const {
|
|
1247
1033
|
trigger,
|
|
1248
1034
|
returnFocusOnClose,
|
|
1249
1035
|
preventScroll
|
|
1250
1036
|
} = this.getProps();
|
|
1251
|
-
|
|
1252
1037
|
if (returnFocusOnClose && trigger !== 'custom') {
|
|
1253
1038
|
const triggerNode = this._adapter.getTriggerNode();
|
|
1254
|
-
|
|
1255
1039
|
if (triggerNode && 'focus' in triggerNode) {
|
|
1256
1040
|
triggerNode.focus({
|
|
1257
1041
|
preventScroll
|
|
@@ -1259,31 +1043,24 @@ class Tooltip extends _foundation.default {
|
|
|
1259
1043
|
}
|
|
1260
1044
|
}
|
|
1261
1045
|
}
|
|
1262
|
-
|
|
1263
1046
|
_handleEscKeyDown(event) {
|
|
1264
1047
|
const {
|
|
1265
1048
|
trigger
|
|
1266
1049
|
} = this.getProps();
|
|
1267
|
-
|
|
1268
1050
|
if (trigger !== 'custom') {
|
|
1269
1051
|
// Move the focus into the trigger first and then close the pop-up layer
|
|
1270
1052
|
// to avoid the problem of opening the pop-up layer again when the focus returns to the trigger in the case of hover and focus
|
|
1271
1053
|
this.focusTrigger();
|
|
1272
1054
|
this.hide();
|
|
1273
1055
|
}
|
|
1274
|
-
|
|
1275
1056
|
this._adapter.notifyEscKeydown(event);
|
|
1276
1057
|
}
|
|
1277
|
-
|
|
1278
1058
|
_handleContainerTabKeyDown(focusableElements, event) {
|
|
1279
1059
|
const {
|
|
1280
1060
|
preventScroll
|
|
1281
1061
|
} = this.getProps();
|
|
1282
|
-
|
|
1283
1062
|
const activeElement = this._adapter.getActiveElement();
|
|
1284
|
-
|
|
1285
1063
|
const isLastCurrentFocus = focusableElements[focusableElements.length - 1] === activeElement;
|
|
1286
|
-
|
|
1287
1064
|
if (isLastCurrentFocus) {
|
|
1288
1065
|
focusableElements[0].focus({
|
|
1289
1066
|
preventScroll
|
|
@@ -1296,11 +1073,8 @@ class Tooltip extends _foundation.default {
|
|
|
1296
1073
|
const {
|
|
1297
1074
|
preventScroll
|
|
1298
1075
|
} = this.getProps();
|
|
1299
|
-
|
|
1300
1076
|
const activeElement = this._adapter.getActiveElement();
|
|
1301
|
-
|
|
1302
1077
|
const isFirstCurrentFocus = focusableElements[0] === activeElement;
|
|
1303
|
-
|
|
1304
1078
|
if (isFirstCurrentFocus) {
|
|
1305
1079
|
focusableElements[focusableElements.length - 1].focus({
|
|
1306
1080
|
preventScroll
|
|
@@ -1328,7 +1102,5 @@ class Tooltip extends _foundation.default {
|
|
|
1328
1102
|
});
|
|
1329
1103
|
event.preventDefault(); // prevent browser default scroll behavior
|
|
1330
1104
|
}
|
|
1331
|
-
|
|
1332
1105
|
}
|
|
1333
|
-
|
|
1334
1106
|
exports.default = Tooltip;
|