@kdcloudjs/kdesign 1.6.33 → 1.6.35
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/CHANGELOG.md +14 -0
- package/dist/kdesign-complete.less +8 -9
- package/dist/kdesign.css +9 -5
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +9332 -11853
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +4 -4
- package/dist/kdesign.min.js +18 -18
- package/dist/kdesign.min.js.map +1 -1
- package/es/_utils/KeyCode.js +6 -119
- package/es/_utils/arrayUtil.js +0 -5
- package/es/_utils/devwarning.js +0 -1
- package/es/_utils/formatUtil.js +36 -99
- package/es/_utils/getStringLength.js +0 -2
- package/es/_utils/hooks.js +32 -72
- package/es/_utils/index.js +0 -2
- package/es/_utils/numberUtil.js +32 -55
- package/es/_utils/omit.js +0 -2
- package/es/_utils/raf.js +0 -6
- package/es/_utils/resizeObserver.js +2 -17
- package/es/_utils/testBrowserType.js +0 -2
- package/es/_utils/type.js +0 -2
- package/es/_utils/usePopper.js +84 -167
- package/es/alert/alert.js +20 -50
- package/es/anchor/anchor-link.js +12 -23
- package/es/anchor/anchor.js +69 -168
- package/es/avatar/avatar.js +29 -44
- package/es/badge/badge.js +33 -53
- package/es/base-data/base-data.js +89 -197
- package/es/button/button.js +30 -55
- package/es/button/group.js +27 -39
- package/es/card/card.js +19 -23
- package/es/carousel/carousel.js +31 -65
- package/es/carousel/displayList.js +2 -5
- package/es/carousel/fadeList.js +4 -7
- package/es/carousel/slideList.js +1 -7
- package/es/carousel/slidebar.js +5 -12
- package/es/cascader/cascader.js +56 -116
- package/es/cascader/util.js +10 -58
- package/es/checkbox/checkbox.js +22 -47
- package/es/checkbox/group.js +19 -35
- package/es/checkbox/style/index.css +2 -0
- package/es/checkbox/style/index.less +1 -0
- package/es/city-picker/city-group.js +5 -13
- package/es/city-picker/city-list.js +4 -9
- package/es/city-picker/city-panel-item.js +3 -8
- package/es/city-picker/city-panel.js +25 -50
- package/es/city-picker/city-picker.js +22 -46
- package/es/city-picker/city-search-panel.js +6 -13
- package/es/city-picker/no-data.js +3 -6
- package/es/city-picker/utils/grouping.js +0 -4
- package/es/collapse/collapse.js +17 -40
- package/es/collapse/panel.js +21 -44
- package/es/config-provider/SizeContext.js +1 -1
- package/es/config-provider/compDefaultProps.js +0 -1
- package/es/config-provider/configProvider.js +2 -7
- package/es/config-provider/defaultConfig.js +0 -1
- package/es/date-picker/calendar.js +12 -21
- package/es/date-picker/date-panel.js +20 -60
- package/es/date-picker/date-picker.js +145 -186
- package/es/date-picker/hooks/use-hover-value.js +5 -13
- package/es/date-picker/hooks/use-picker-input.js +17 -31
- package/es/date-picker/hooks/use-range-cls.js +8 -14
- package/es/date-picker/hooks/use-range-disabled.js +7 -21
- package/es/date-picker/hooks/use-range-view-dates.js +18 -39
- package/es/date-picker/hooks/use-state-memo.js +0 -2
- package/es/date-picker/hooks/use-text-value-mapping.js +6 -11
- package/es/date-picker/hooks/use-value-texts.js +0 -1
- package/es/date-picker/panel/date-time/date-time.js +7 -10
- package/es/date-picker/panel/header/header.js +9 -11
- package/es/date-picker/panel/month/month.js +11 -30
- package/es/date-picker/panel/quarter/quarter.js +8 -25
- package/es/date-picker/panel/time/time-column.js +8 -18
- package/es/date-picker/panel/time/time.js +62 -88
- package/es/date-picker/panel/week/week.js +25 -57
- package/es/date-picker/panel/year/year.js +19 -42
- package/es/date-picker/popper.js +28 -35
- package/es/date-picker/range/input-range.js +95 -129
- package/es/date-picker/range-picker.d.ts +1 -0
- package/es/date-picker/range-picker.js +196 -284
- package/es/date-picker/single/input-date.js +87 -111
- package/es/date-picker/utils/date-fns.js +32 -63
- package/es/date-picker/utils/get-extra-footer.js +0 -1
- package/es/date-picker/utils/get-ranges.js +13 -19
- package/es/date-picker/utils/index.js +9 -80
- package/es/drawer/drawer.js +50 -71
- package/es/dropdown/dropdown.js +26 -42
- package/es/dropdown/menu.d.ts +3 -2
- package/es/dropdown/menu.js +32 -43
- package/es/empty/defaultEmptyImg.js +2 -5
- package/es/empty/empty.js +15 -26
- package/es/empty/illustrationEmptyImg.js +2 -5
- package/es/filter/condition.js +5 -17
- package/es/filter/filter.js +29 -54
- package/es/filter/scheme.js +35 -71
- package/es/form/Field.js +36 -98
- package/es/form/FieldContext.js +0 -2
- package/es/form/FieldLabel.js +11 -17
- package/es/form/FieldWrapper.js +6 -9
- package/es/form/Form.js +28 -46
- package/es/form/FormContext.js +0 -4
- package/es/form/hooks/useForceUpdate.js +2 -5
- package/es/form/hooks/useForm.js +10 -84
- package/es/grid/col.js +23 -39
- package/es/grid/row.js +22 -36
- package/es/icon/icon.js +11 -29
- package/es/image/image.js +31 -49
- package/es/image/preview-group.js +25 -41
- package/es/image/preview.js +24 -39
- package/es/image-cropper/cropper.js +13 -23
- package/es/image-cropper/image-cropper.js +39 -69
- package/es/image-cropper/operation-bar.js +14 -27
- package/es/index.js +0 -2
- package/es/input/ClearableLabeledInput.js +27 -50
- package/es/input/TextArea.js +45 -86
- package/es/input/calculateNodeHeight.js +4 -16
- package/es/input/index.js +2 -2
- package/es/input/input.js +32 -67
- package/es/input-number/inputNumber.js +50 -109
- package/es/layout/layout.js +28 -49
- package/es/layout/sider.js +39 -73
- package/es/link/link.js +19 -33
- package/es/locale/locale.js +6 -44
- package/es/locale/zh-CN.js +0 -2
- package/es/menu/menu.js +29 -63
- package/es/menu/menuItem.js +27 -52
- package/es/menu/subMenu.js +44 -99
- package/es/menu/util.js +4 -13
- package/es/message/content.js +7 -23
- package/es/message/index.js +14 -26
- package/es/modal/confirm.js +3 -12
- package/es/modal/index.js +0 -4
- package/es/modal/modal.js +41 -63
- package/es/notification/content.js +13 -35
- package/es/notification/index.js +20 -35
- package/es/notification-base/index.js +4 -24
- package/es/notification-base/notice.js +12 -24
- package/es/notification-base/notification.js +3 -18
- package/es/pagination/pagination.js +76 -113
- package/es/popconfirm/popconfirm.js +22 -33
- package/es/progress/circle.js +9 -18
- package/es/progress/line.js +5 -9
- package/es/progress/progress.js +21 -44
- package/es/progress/utils.js +6 -22
- package/es/radio/group.js +19 -35
- package/es/radio/radio-button.js +6 -19
- package/es/radio/radio.js +19 -46
- package/es/rate/rate.js +30 -67
- package/es/rate/style/index.css +3 -3
- package/es/rate/style/index.less +3 -9
- package/es/search/option.js +10 -17
- package/es/search/quick-search.js +68 -155
- package/es/search/search-panel.js +28 -49
- package/es/search/search.js +23 -43
- package/es/select/interface.js +0 -1
- package/es/select/option.js +13 -25
- package/es/select/select.js +114 -221
- package/es/select/style/index.css +3 -0
- package/es/select/style/index.less +4 -0
- package/es/slider/marks.js +9 -15
- package/es/slider/slider.js +60 -104
- package/es/slider/sliderTooltip.js +9 -17
- package/es/slider/steps.js +8 -19
- package/es/slider/track.js +5 -8
- package/es/slider/utils.js +4 -14
- package/es/space/space.js +16 -34
- package/es/spin/spin.js +16 -32
- package/es/split-panel/split-panel.js +57 -83
- package/es/split-panel/trigger.js +8 -17
- package/es/stepper/stepper.js +27 -57
- package/es/steps/Step.js +18 -34
- package/es/steps/Steps.js +19 -38
- package/es/style/icon/kdicon.css +0 -1
- package/es/switch/switch.js +25 -43
- package/es/table/api.d.ts +4 -0
- package/es/table/api.js +128 -0
- package/es/table/feature/autoRowSpan.js +0 -2
- package/es/table/feature/colGroupExtendable.js +0 -2
- package/es/table/feature/columnDrag.js +0 -2
- package/es/table/feature/columnResize.js +0 -2
- package/es/table/feature/contextMenu.js +0 -2
- package/es/table/feature/filter.js +0 -2
- package/es/table/feature/mergeCellHover.js +0 -2
- package/es/table/feature/rowDetail.js +0 -2
- package/es/table/feature/rowSelection.js +11 -21
- package/es/table/feature/sort.js +0 -2
- package/es/table/feature/treeMode.js +0 -2
- package/es/table/feature/useFooterDataSource.js +0 -2
- package/es/table/feature/useRangeSelection.js +0 -2
- package/es/table/interface.d.ts +3 -0
- package/es/table/table.js +38 -54
- package/es/tabs/active-line.js +6 -8
- package/es/tabs/arrow-button.js +5 -10
- package/es/tabs/index.js +2 -2
- package/es/tabs/tab-pane.js +7 -23
- package/es/tabs/tabs.js +42 -104
- package/es/tag/tag.js +34 -56
- package/es/timeline/Timeline.js +16 -33
- package/es/timeline/TimelineItem.js +15 -26
- package/es/tooltip/tooltip.js +7 -11
- package/es/transfer/list-body.js +12 -31
- package/es/transfer/list-item.js +10 -18
- package/es/transfer/list.js +35 -68
- package/es/transfer/operation.js +12 -14
- package/es/transfer/search.js +5 -11
- package/es/transfer/transfer.js +51 -100
- package/es/tree/tree.js +95 -156
- package/es/tree/treeHooks.js +18 -34
- package/es/tree/treeNode.js +57 -96
- package/es/tree/utils/treeUtils.js +22 -150
- package/es/typography/base.js +16 -33
- package/es/typography/index.js +2 -2
- package/es/typography/paragraph.js +0 -2
- package/es/typography/text.js +0 -2
- package/es/typography/title.js +3 -14
- package/es/typography/typography.js +14 -24
- package/es/upload/dragger.js +3 -12
- package/es/upload/request.js +6 -26
- package/es/upload/scan-files.js +2 -13
- package/es/upload/upload.js +63 -131
- package/es/upload/utils.js +0 -2
- package/es/upload/verify-file.js +0 -6
- package/es/view-container/view-container.js +7 -9
- package/es/virtual-list/Filler.js +3 -7
- package/es/virtual-list/utils/algorithmUtil.js +0 -13
- package/es/virtual-list/utils/itemUtil.js +18 -47
- package/es/virtual-list/virtual-list.js +64 -137
- package/lib/_utils/KeyCode.js +6 -120
- package/lib/_utils/arrayUtil.js +0 -9
- package/lib/_utils/devwarning.js +0 -5
- package/lib/_utils/formatUtil.js +36 -103
- package/lib/_utils/getStringLength.js +0 -3
- package/lib/_utils/hooks.js +32 -90
- package/lib/_utils/index.js +0 -6
- package/lib/_utils/numberUtil.js +32 -64
- package/lib/_utils/omit.js +0 -5
- package/lib/_utils/raf.js +0 -7
- package/lib/_utils/react-children.js +0 -5
- package/lib/_utils/reactNode.js +0 -9
- package/lib/_utils/resizeObserver.js +2 -25
- package/lib/_utils/testBrowserType.js +0 -3
- package/lib/_utils/type.js +0 -6
- package/lib/_utils/usePopper.js +84 -190
- package/lib/alert/alert.js +20 -74
- package/lib/alert/index.js +0 -3
- package/lib/alert/style/css.js +0 -1
- package/lib/alert/style/index.js +0 -1
- package/lib/anchor/anchor-link.js +12 -35
- package/lib/anchor/anchor.js +69 -204
- package/lib/anchor/context.js +0 -7
- package/lib/anchor/index.js +0 -4
- package/lib/anchor/style/css.js +0 -1
- package/lib/anchor/style/index.js +0 -1
- package/lib/avatar/avatar.js +29 -70
- package/lib/avatar/index.js +0 -9
- package/lib/avatar/style/css.js +0 -1
- package/lib/avatar/style/index.js +0 -1
- package/lib/badge/badge.js +33 -70
- package/lib/badge/index.js +0 -9
- package/lib/badge/style/css.js +0 -1
- package/lib/badge/style/index.js +0 -1
- package/lib/base-data/base-data.js +89 -218
- package/lib/base-data/index.js +0 -9
- package/lib/base-data/interface.js +0 -2
- package/lib/base-data/style/css.js +0 -1
- package/lib/base-data/style/index.js +0 -1
- package/lib/button/button.js +30 -72
- package/lib/button/group.js +27 -61
- package/lib/button/index.js +0 -4
- package/lib/button/style/css.js +0 -1
- package/lib/button/style/index.js +0 -1
- package/lib/card/card.js +19 -35
- package/lib/card/index.js +0 -9
- package/lib/card/style/css.js +0 -1
- package/lib/card/style/index.js +0 -1
- package/lib/carousel/carousel.js +31 -112
- package/lib/carousel/displayList.js +2 -14
- package/lib/carousel/fadeList.js +4 -16
- package/lib/carousel/index.js +0 -12
- package/lib/carousel/slideList.js +1 -14
- package/lib/carousel/slidebar.js +5 -22
- package/lib/carousel/style/css.js +0 -1
- package/lib/carousel/style/index.js +0 -1
- package/lib/cascader/cascader.js +56 -150
- package/lib/cascader/index.js +0 -9
- package/lib/cascader/style/css.js +0 -1
- package/lib/cascader/style/index.js +0 -1
- package/lib/cascader/util.js +10 -87
- package/lib/checkbox/checkbox.js +22 -69
- package/lib/checkbox/group.js +18 -59
- package/lib/checkbox/index.js +0 -9
- package/lib/checkbox/style/css.js +0 -1
- package/lib/checkbox/style/index.css +2 -0
- package/lib/checkbox/style/index.js +0 -1
- package/lib/checkbox/style/index.less +1 -0
- package/lib/city-picker/city-group.js +5 -24
- package/lib/city-picker/city-list.js +4 -21
- package/lib/city-picker/city-panel-item.js +3 -17
- package/lib/city-picker/city-panel.js +25 -64
- package/lib/city-picker/city-picker.js +22 -67
- package/lib/city-picker/city-search-panel.js +6 -25
- package/lib/city-picker/index.js +0 -9
- package/lib/city-picker/no-data.js +3 -15
- package/lib/city-picker/style/css.js +0 -1
- package/lib/city-picker/style/index.js +0 -1
- package/lib/city-picker/utils/grouping.js +0 -5
- package/lib/collapse/collapse.js +17 -62
- package/lib/collapse/index.js +0 -4
- package/lib/collapse/panel.js +21 -62
- package/lib/collapse/style/css.js +0 -1
- package/lib/collapse/style/index.js +0 -1
- package/lib/config-provider/ConfigContext.js +1 -4
- package/lib/config-provider/SizeContext.js +1 -6
- package/lib/config-provider/compDefaultProps.js +0 -8
- package/lib/config-provider/configProvider.js +3 -18
- package/lib/config-provider/defaultConfig.js +0 -5
- package/lib/config-provider/index.js +0 -6
- package/lib/date-picker/calendar.js +12 -35
- package/lib/date-picker/context.js +0 -7
- package/lib/date-picker/date-panel.js +20 -81
- package/lib/date-picker/date-picker.js +145 -214
- package/lib/date-picker/hooks/use-hover-value.js +5 -19
- package/lib/date-picker/hooks/use-picker-input.js +17 -37
- package/lib/date-picker/hooks/use-range-cls.js +8 -21
- package/lib/date-picker/hooks/use-range-disabled.js +7 -30
- package/lib/date-picker/hooks/use-range-view-dates.js +16 -49
- package/lib/date-picker/hooks/use-state-memo.js +0 -5
- package/lib/date-picker/hooks/use-text-value-mapping.js +6 -20
- package/lib/date-picker/hooks/use-value-texts.js +0 -5
- package/lib/date-picker/index.js +0 -4
- package/lib/date-picker/panel/date-time/date-time.js +7 -23
- package/lib/date-picker/panel/header/header.js +9 -21
- package/lib/date-picker/panel/month/month.js +11 -46
- package/lib/date-picker/panel/quarter/quarter.js +8 -40
- package/lib/date-picker/panel/time/time-column.js +8 -31
- package/lib/date-picker/panel/time/time.js +60 -106
- package/lib/date-picker/panel/week/week.js +25 -73
- package/lib/date-picker/panel/year/year.js +19 -56
- package/lib/date-picker/popper.js +28 -47
- package/lib/date-picker/range/input-range.js +95 -145
- package/lib/date-picker/range-picker.d.ts +1 -0
- package/lib/date-picker/range-picker.js +194 -324
- package/lib/date-picker/single/input-date.js +87 -127
- package/lib/date-picker/utils/date-fns.js +25 -136
- package/lib/date-picker/utils/get-extra-footer.js +0 -8
- package/lib/date-picker/utils/get-ranges.js +13 -24
- package/lib/date-picker/utils/index.js +9 -104
- package/lib/drawer/drawer.js +49 -95
- package/lib/drawer/index.js +0 -9
- package/lib/drawer/style/css.js +0 -1
- package/lib/drawer/style/index.js +0 -1
- package/lib/dropdown/dropdown.js +26 -56
- package/lib/dropdown/index.js +0 -9
- package/lib/dropdown/menu.d.ts +3 -2
- package/lib/dropdown/menu.js +29 -56
- package/lib/dropdown/style/css.js +0 -1
- package/lib/dropdown/style/index.js +0 -1
- package/lib/empty/defaultEmptyImg.js +2 -14
- package/lib/empty/empty.js +15 -42
- package/lib/empty/illustrationEmptyImg.js +2 -14
- package/lib/empty/index.js +0 -9
- package/lib/empty/style/css.js +0 -1
- package/lib/empty/style/index.js +0 -1
- package/lib/filter/condition.js +5 -28
- package/lib/filter/filter.js +29 -73
- package/lib/filter/index.js +0 -9
- package/lib/filter/scheme.js +35 -82
- package/lib/filter/style/css.js +0 -1
- package/lib/filter/style/index.js +0 -1
- package/lib/form/Field.js +36 -127
- package/lib/form/FieldContext.js +0 -6
- package/lib/form/FieldLabel.js +11 -29
- package/lib/form/FieldWrapper.js +6 -19
- package/lib/form/Form.js +28 -65
- package/lib/form/FormContext.js +0 -11
- package/lib/form/hooks/useForceUpdate.js +2 -9
- package/lib/form/hooks/useForm.js +10 -98
- package/lib/form/index.js +0 -12
- package/lib/form/style/css.js +0 -1
- package/lib/form/style/index.js +0 -1
- package/lib/grid/col.js +23 -51
- package/lib/grid/index.js +0 -3
- package/lib/grid/row.js +22 -49
- package/lib/grid/style/css.js +0 -1
- package/lib/grid/style/index.js +0 -1
- package/lib/icon/icon.js +11 -44
- package/lib/icon/index.js +0 -9
- package/lib/icon/interface.js +0 -6
- package/lib/icon/style/css.js +0 -1
- package/lib/icon/style/index.js +0 -1
- package/lib/image/image.js +31 -64
- package/lib/image/index.js +0 -9
- package/lib/image/preview-group.js +25 -54
- package/lib/image/preview.js +24 -57
- package/lib/image/style/css.js +0 -1
- package/lib/image/style/index.js +0 -1
- package/lib/image-cropper/cropper.js +11 -33
- package/lib/image-cropper/image-cropper.js +39 -89
- package/lib/image-cropper/index.js +0 -3
- package/lib/image-cropper/operation-bar.js +14 -44
- package/lib/image-cropper/style/css.js +0 -1
- package/lib/image-cropper/style/index.js +0 -1
- package/lib/index.js +2 -64
- package/lib/input/ClearableLabeledInput.js +27 -65
- package/lib/input/TextArea.js +45 -108
- package/lib/input/calculateNodeHeight.js +4 -23
- package/lib/input/index.js +0 -9
- package/lib/input/input.js +32 -87
- package/lib/input-number/index.js +0 -3
- package/lib/input-number/inputNumber.js +50 -129
- package/lib/input-number/style/css.js +0 -1
- package/lib/input-number/style/index.js +0 -1
- package/lib/layout/index.js +0 -9
- package/lib/layout/layout.js +28 -64
- package/lib/layout/sider.js +39 -89
- package/lib/layout/style/css.js +0 -1
- package/lib/layout/style/index.js +0 -1
- package/lib/link/index.js +0 -9
- package/lib/link/link.js +19 -50
- package/lib/link/style/css.js +0 -1
- package/lib/link/style/index.js +0 -1
- package/lib/locale/index.js +0 -7
- package/lib/locale/locale.js +6 -58
- package/lib/locale/zh-CN.js +0 -4
- package/lib/menu/index.js +0 -9
- package/lib/menu/menu.js +29 -83
- package/lib/menu/menuItem.js +27 -69
- package/lib/menu/style/css.js +0 -1
- package/lib/menu/style/index.js +0 -1
- package/lib/menu/subMenu.js +44 -122
- package/lib/menu/util.js +4 -28
- package/lib/message/content.js +7 -32
- package/lib/message/index.js +14 -33
- package/lib/message/style/css.js +0 -1
- package/lib/message/style/index.js +0 -1
- package/lib/modal/confirm.js +3 -21
- package/lib/modal/index.js +0 -14
- package/lib/modal/modal.js +41 -86
- package/lib/modal/style/css.js +0 -1
- package/lib/modal/style/index.js +0 -1
- package/lib/notification/content.js +15 -48
- package/lib/notification/index.js +20 -42
- package/lib/notification/style/css.js +0 -1
- package/lib/notification/style/index.js +0 -1
- package/lib/notification-base/index.js +4 -31
- package/lib/notification-base/notice.js +12 -38
- package/lib/notification-base/notification.js +3 -31
- package/lib/pagination/index.js +0 -3
- package/lib/pagination/pagination.js +76 -137
- package/lib/pagination/style/css.js +0 -1
- package/lib/pagination/style/index.js +0 -1
- package/lib/popconfirm/index.js +0 -9
- package/lib/popconfirm/popconfirm.js +22 -46
- package/lib/popconfirm/style/css.js +0 -1
- package/lib/popconfirm/style/index.js +0 -1
- package/lib/progress/circle.js +9 -25
- package/lib/progress/index.js +0 -3
- package/lib/progress/line.js +5 -11
- package/lib/progress/progress.js +21 -64
- package/lib/progress/style/css.js +0 -1
- package/lib/progress/style/index.js +0 -1
- package/lib/progress/utils.js +6 -30
- package/lib/radio/context.js +0 -7
- package/lib/radio/group.js +19 -53
- package/lib/radio/index.js +0 -5
- package/lib/radio/radio-button.js +6 -32
- package/lib/radio/radio.js +19 -66
- package/lib/radio/style/css.js +0 -1
- package/lib/radio/style/index.js +0 -1
- package/lib/rate/index.js +0 -3
- package/lib/rate/rate.js +30 -82
- package/lib/rate/style/css.js +0 -1
- package/lib/rate/style/index.css +3 -3
- package/lib/rate/style/index.js +0 -1
- package/lib/rate/style/index.less +3 -9
- package/lib/search/index.js +0 -7
- package/lib/search/interface.js +0 -2
- package/lib/search/option.js +10 -29
- package/lib/search/quick-search.js +68 -171
- package/lib/search/search-panel.js +28 -66
- package/lib/search/search.js +23 -63
- package/lib/search/style/css.js +0 -1
- package/lib/search/style/index.js +0 -1
- package/lib/select/index.js +0 -4
- package/lib/select/interface.js +0 -3
- package/lib/select/option.js +13 -40
- package/lib/select/select.js +114 -234
- package/lib/select/style/index.css +3 -0
- package/lib/select/style/index.less +4 -0
- package/lib/slider/index.js +0 -9
- package/lib/slider/marks.js +9 -22
- package/lib/slider/slider.js +58 -123
- package/lib/slider/sliderTooltip.js +9 -30
- package/lib/slider/steps.js +8 -24
- package/lib/slider/style/css.js +0 -1
- package/lib/slider/style/index.js +0 -1
- package/lib/slider/track.js +5 -11
- package/lib/slider/utils.js +4 -21
- package/lib/space/index.js +0 -9
- package/lib/space/space.js +16 -50
- package/lib/space/style/css.js +0 -1
- package/lib/space/style/index.js +0 -1
- package/lib/spin/index.js +0 -9
- package/lib/spin/spin.js +16 -50
- package/lib/spin/style/css.js +0 -1
- package/lib/spin/style/index.js +0 -1
- package/lib/split-panel/index.js +0 -9
- package/lib/split-panel/split-panel.js +57 -101
- package/lib/split-panel/style/css.js +0 -1
- package/lib/split-panel/style/index.js +0 -1
- package/lib/split-panel/trigger.js +8 -23
- package/lib/stepper/index.js +0 -9
- package/lib/stepper/stepper.js +27 -81
- package/lib/stepper/style/css.js +0 -1
- package/lib/stepper/style/index.js +0 -1
- package/lib/steps/Step.js +18 -40
- package/lib/steps/Steps.js +19 -55
- package/lib/steps/index.js +0 -5
- package/lib/steps/interface.js +0 -2
- package/lib/steps/style/css.js +0 -1
- package/lib/steps/style/index.js +0 -1
- package/lib/style/icon/kdicon.css +0 -1
- package/lib/switch/index.js +0 -3
- package/lib/switch/style/css.js +0 -1
- package/lib/switch/style/index.js +0 -1
- package/lib/switch/switch.js +23 -59
- package/lib/table/api.d.ts +4 -0
- package/lib/table/api.js +135 -0
- package/lib/table/feature/autoRowSpan.js +0 -3
- package/lib/table/feature/colGroupExtendable.js +0 -3
- package/lib/table/feature/columnDrag.js +0 -3
- package/lib/table/feature/columnResize.js +0 -3
- package/lib/table/feature/contextMenu.js +0 -3
- package/lib/table/feature/filter.js +0 -6
- package/lib/table/feature/mergeCellHover.js +0 -3
- package/lib/table/feature/rowDetail.js +0 -5
- package/lib/table/feature/rowSelection.js +11 -24
- package/lib/table/feature/sort.js +0 -6
- package/lib/table/feature/treeMode.js +0 -5
- package/lib/table/feature/useFooterDataSource.js +0 -3
- package/lib/table/feature/useRangeSelection.js +0 -5
- package/lib/table/index.js +0 -3
- package/lib/table/interface.d.ts +3 -0
- package/lib/table/style/css.js +0 -1
- package/lib/table/style/index.js +0 -1
- package/lib/table/table.js +38 -85
- package/lib/tabs/active-line.js +6 -17
- package/lib/tabs/arrow-button.js +5 -23
- package/lib/tabs/context.js +0 -7
- package/lib/tabs/index.js +2 -6
- package/lib/tabs/style/css.js +0 -1
- package/lib/tabs/style/index.js +0 -1
- package/lib/tabs/tab-pane.js +7 -38
- package/lib/tabs/tabs.js +42 -135
- package/lib/tag/index.js +0 -9
- package/lib/tag/style/css.js +0 -1
- package/lib/tag/style/index.js +0 -1
- package/lib/tag/tag.js +34 -74
- package/lib/timeline/Timeline.js +16 -45
- package/lib/timeline/TimelineItem.js +15 -39
- package/lib/timeline/index.js +0 -3
- package/lib/timeline/style/css.js +0 -1
- package/lib/timeline/style/index.js +0 -1
- package/lib/tooltip/index.js +0 -9
- package/lib/tooltip/style/css.js +0 -1
- package/lib/tooltip/style/index.js +0 -1
- package/lib/tooltip/tooltip.js +7 -24
- package/lib/transfer/index.js +0 -3
- package/lib/transfer/list-body.js +12 -48
- package/lib/transfer/list-item.js +10 -27
- package/lib/transfer/list.js +35 -89
- package/lib/transfer/operation.js +12 -18
- package/lib/transfer/search.js +5 -16
- package/lib/transfer/style/css.js +0 -1
- package/lib/transfer/style/index.js +0 -1
- package/lib/transfer/transfer.js +51 -122
- package/lib/tree/index.js +0 -11
- package/lib/tree/style/css.js +0 -1
- package/lib/tree/style/index.js +0 -1
- package/lib/tree/tree.js +95 -196
- package/lib/tree/treeHooks.js +18 -64
- package/lib/tree/treeNode.js +57 -126
- package/lib/tree/utils/treeUtils.js +22 -193
- package/lib/typography/base.js +16 -53
- package/lib/typography/index.js +2 -8
- package/lib/typography/paragraph.js +0 -11
- package/lib/typography/style/css.js +0 -1
- package/lib/typography/style/index.js +0 -1
- package/lib/typography/text.js +0 -6
- package/lib/typography/title.js +3 -21
- package/lib/typography/typography.js +12 -35
- package/lib/upload/dragger.js +3 -21
- package/lib/upload/index.js +0 -11
- package/lib/upload/request.js +6 -27
- package/lib/upload/scan-files.js +2 -15
- package/lib/upload/style/css.js +0 -1
- package/lib/upload/style/index.js +0 -1
- package/lib/upload/upload.js +63 -151
- package/lib/upload/utils.js +0 -6
- package/lib/upload/verify-file.js +0 -9
- package/lib/view-container/context.js +0 -7
- package/lib/view-container/index.js +0 -3
- package/lib/view-container/view-container.js +7 -21
- package/lib/virtual-list/Filler.js +3 -15
- package/lib/virtual-list/index.js +0 -9
- package/lib/virtual-list/utils/algorithmUtil.js +0 -15
- package/lib/virtual-list/utils/itemUtil.js +18 -60
- package/lib/virtual-list/virtual-list.js +63 -158
- package/package.json +3 -2
package/es/_utils/formatUtil.js
CHANGED
|
@@ -3,20 +3,14 @@ import _Number$parseFloat from "@babel/runtime-corejs3/core-js-stable/number/par
|
|
|
3
3
|
import _Number$isNaN from "@babel/runtime-corejs3/core-js-stable/number/is-nan";
|
|
4
4
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
5
5
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
6
|
-
|
|
7
6
|
var __rest = this && this.__rest || function (s, e) {
|
|
8
7
|
var t = {};
|
|
9
|
-
|
|
10
|
-
for (var p in s) {
|
|
11
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14
9
|
if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
|
|
15
10
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
16
11
|
}
|
|
17
12
|
return t;
|
|
18
13
|
};
|
|
19
|
-
|
|
20
14
|
import { toFixed, exponentToFloat, isExp } from './numberUtil';
|
|
21
15
|
/**
|
|
22
16
|
* [数值类型格式化]
|
|
@@ -40,20 +34,17 @@ import { toFixed, exponentToFloat, isExp } from './numberUtil';
|
|
|
40
34
|
* @param {Boolean} showDecimalTailZero [是否显示尾部零]
|
|
41
35
|
* @return [格式化后的数值]
|
|
42
36
|
*/
|
|
43
|
-
|
|
44
37
|
export function formatNumber(num, formatParams) {
|
|
45
38
|
var _context;
|
|
46
|
-
|
|
47
39
|
var _formatParams$mask = formatParams.mask,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
mask = _formatParams$mask === void 0 ? '' : _formatParams$mask,
|
|
41
|
+
_formatParams$zeroSho = formatParams.zeroShow,
|
|
42
|
+
zeroShow = _formatParams$zeroSho === void 0 ? false : _formatParams$zeroSho,
|
|
43
|
+
decimalLength = formatParams.decimalLength,
|
|
44
|
+
_formatParams$showDec = formatParams.showDecimalTailZero,
|
|
45
|
+
showDecimalTailZero = _formatParams$showDec === void 0 ? false : _formatParams$showDec,
|
|
46
|
+
isRound = formatParams.isRound,
|
|
47
|
+
param = __rest(formatParams, ["mask", "zeroShow", "decimalLength", "showDecimalTailZero", "isRound"]);
|
|
57
48
|
if (decimalLength !== undefined && (decimalLength < 0 || decimalLength > 100)) return num + '';
|
|
58
49
|
if (num === undefined || num === null) num = '';
|
|
59
50
|
var numInfo = {
|
|
@@ -61,40 +52,31 @@ export function formatNumber(num, formatParams) {
|
|
|
61
52
|
intStr: '',
|
|
62
53
|
decimalStr: ''
|
|
63
54
|
};
|
|
64
|
-
|
|
65
55
|
if (typeof num === 'number') {
|
|
66
56
|
numInfo.numStr = num + '';
|
|
67
57
|
} else {
|
|
68
58
|
numInfo.numStr = num.replace(/,/g, '');
|
|
69
|
-
|
|
70
59
|
if (isExp(numInfo.numStr)) {
|
|
71
60
|
numInfo.numStr = exponentToFloat(numInfo.numStr);
|
|
72
61
|
}
|
|
73
62
|
}
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
var floatNum = _Number$parseFloat(numInfo.numStr);
|
|
64
|
+
// 非纯数字不处理,直接返回''
|
|
76
65
|
// if (Number.isNaN(floatNum)) return ''
|
|
77
|
-
|
|
78
|
-
|
|
79
66
|
if (_Number$isNaN(Number(num))) {
|
|
80
67
|
// throw new Error('toFixed() number argument must be a valid number')
|
|
81
68
|
return num + '';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
}
|
|
70
|
+
// 为零不显示,且等于零,直接返回''
|
|
85
71
|
if (!zeroShow && Number(num) === 0) return '';
|
|
86
72
|
var maskInfo = analyzMask(mask);
|
|
87
73
|
if (maskInfo.errorMask) return numInfo.numStr;
|
|
88
|
-
|
|
89
74
|
var isIncludePercent = _includesInstanceProperty(_context = numInfo.numStr).call(_context, '%');
|
|
90
|
-
|
|
91
75
|
if (maskInfo.percent) {
|
|
92
76
|
if (!isIncludePercent) {
|
|
93
77
|
var _context2;
|
|
94
|
-
|
|
95
78
|
var point = numInfo.numStr.indexOf('.');
|
|
96
79
|
var length = numInfo.numStr.length;
|
|
97
|
-
|
|
98
80
|
if (point < 0) {
|
|
99
81
|
numInfo.numStr = numInfo.numStr + '00';
|
|
100
82
|
} else if (point === length - 1) {
|
|
@@ -104,28 +86,22 @@ export function formatNumber(num, formatParams) {
|
|
|
104
86
|
} else {
|
|
105
87
|
var numStr = numInfo.numStr.replace('.', '');
|
|
106
88
|
numInfo.numStr = numStr.substring(0, point + 2) + '.' + numStr.substring(point + 2);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
89
|
+
}
|
|
90
|
+
// 去掉数字前面的零
|
|
110
91
|
numInfo.numStr = numInfo.numStr.replace(/^0+/, '');
|
|
111
92
|
if (numInfo.numStr === '.') numInfo.numStr = '0';
|
|
112
|
-
|
|
113
93
|
if (_includesInstanceProperty(_context2 = numInfo.numStr).call(_context2, '-')) {
|
|
114
94
|
// 负数的情况 去掉前面的0
|
|
115
95
|
numInfo.numStr = numInfo.numStr.replace('-', '');
|
|
116
96
|
numInfo.numStr = numInfo.numStr.replace(/^0+/, '');
|
|
117
97
|
numInfo.numStr = '-' + numInfo.numStr;
|
|
118
98
|
}
|
|
119
|
-
|
|
120
99
|
floatNum = floatNum * 100;
|
|
121
100
|
}
|
|
122
101
|
}
|
|
123
|
-
|
|
124
102
|
var isNegativeNumber = floatNum < 0; // 是否是负数
|
|
125
|
-
|
|
126
103
|
if (isNegativeNumber) {
|
|
127
104
|
var _context3;
|
|
128
|
-
|
|
129
105
|
floatNum = Math.abs(floatNum);
|
|
130
106
|
numInfo.numStr = _sliceInstanceProperty(_context3 = numInfo.numStr).call(_context3, 1); // 去除第一个负号
|
|
131
107
|
}
|
|
@@ -133,34 +109,28 @@ export function formatNumber(num, formatParams) {
|
|
|
133
109
|
var numStrArr = numInfo.numStr.split('.');
|
|
134
110
|
numInfo.intStr = numStrArr[0];
|
|
135
111
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
136
|
-
|
|
137
112
|
if (!showDecimalTailZero) {
|
|
138
113
|
numInfo = cutTailZero(numInfo);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
114
|
+
}
|
|
115
|
+
// 小数部分处理。暂时不考虑其他。只校验位数和尾数补零问题,整数
|
|
142
116
|
if (decimalLength !== undefined && decimalLength >= 0) {
|
|
143
117
|
// floatNum = Number.parseFloat(numInfo.numStr) // 当整数位数大于16位时,parseFloat会丢掉末尾的值,有问题!!!
|
|
144
118
|
numInfo.numStr = toFixed(numInfo.numStr, decimalLength, isRound);
|
|
145
|
-
numStrArr = numInfo.numStr.split('.');
|
|
146
|
-
|
|
119
|
+
numStrArr = numInfo.numStr.split('.');
|
|
120
|
+
// 去除整数部分多余的 0
|
|
147
121
|
var intStr = numStrArr[0].replace(/^0+/, '');
|
|
148
122
|
numInfo.intStr = intStr === '' ? '0' : intStr;
|
|
149
123
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
150
|
-
|
|
151
124
|
if (!showDecimalTailZero) {
|
|
152
125
|
numInfo = cutTailZero(numInfo);
|
|
153
126
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
127
|
+
}
|
|
128
|
+
// 整数部分格式化
|
|
157
129
|
var formatValue = intFormatMask(maskInfo.intMask, numInfo.intStr);
|
|
158
130
|
var currencySign = maskInfo.currencySign ? '$' : '';
|
|
159
|
-
|
|
160
131
|
if (param.symbol) {
|
|
161
132
|
currencySign = param.symbol;
|
|
162
133
|
}
|
|
163
|
-
|
|
164
134
|
return currencySign + (isNegativeNumber ? '-' : '') + (formatValue || numInfo.intStr || '0') + (numInfo.decimalStr.length > 0 ? '.' : '') + numInfo.decimalStr + (maskInfo.percent ? '%' : '');
|
|
165
135
|
}
|
|
166
136
|
/**
|
|
@@ -169,16 +139,15 @@ export function formatNumber(num, formatParams) {
|
|
|
169
139
|
* @param {*} num
|
|
170
140
|
* @param {*} param
|
|
171
141
|
*/
|
|
172
|
-
|
|
173
142
|
export function formatEditNumber(num, _ref) {
|
|
174
143
|
var _ref$zeroShow = _ref.zeroShow,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
144
|
+
zeroShow = _ref$zeroShow === void 0 ? false : _ref$zeroShow,
|
|
145
|
+
decimalLength = _ref.decimalLength,
|
|
146
|
+
_ref$showDecimalTailZ = _ref.showDecimalTailZero,
|
|
147
|
+
showDecimalTailZero = _ref$showDecimalTailZ === void 0 ? false : _ref$showDecimalTailZ,
|
|
148
|
+
_ref$roundMethod = _ref.roundMethod,
|
|
149
|
+
roundMethod = _ref$roundMethod === void 0 ? '0' : _ref$roundMethod,
|
|
150
|
+
symbol = _ref.symbol;
|
|
182
151
|
// 如果精度超过100,直接返回数值
|
|
183
152
|
if (decimalLength && (decimalLength < 0 || decimalLength > 100)) return num + '';
|
|
184
153
|
if (num === undefined || num === null) num = '';
|
|
@@ -188,32 +157,25 @@ export function formatEditNumber(num, _ref) {
|
|
|
188
157
|
decimalStr: ''
|
|
189
158
|
};
|
|
190
159
|
if (zeroShow && num === '') return '';
|
|
191
|
-
|
|
192
160
|
if (typeof num === 'number') {
|
|
193
161
|
numInfo.numStr = num + '';
|
|
194
162
|
} else {
|
|
195
163
|
numInfo.numStr = num.replace(/,/g, '');
|
|
196
|
-
|
|
197
164
|
if (isExp(numInfo.numStr)) {
|
|
198
165
|
numInfo.numStr = exponentToFloat(numInfo.numStr);
|
|
199
166
|
}
|
|
200
|
-
|
|
201
167
|
if (symbol && numInfo.numStr.indexOf(symbol) === 0) {
|
|
202
168
|
numInfo.numStr = numInfo.numStr.replace(symbol, '');
|
|
203
169
|
}
|
|
204
170
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (_Number$isNaN(floatNum)) return ''; // 为零不显示,且等于零,直接返回''
|
|
210
|
-
|
|
171
|
+
var floatNum = _Number$parseFloat(numInfo.numStr);
|
|
172
|
+
// 非纯数字不处理,直接返回''
|
|
173
|
+
if (_Number$isNaN(floatNum)) return '';
|
|
174
|
+
// 为零不显示,且等于零,直接返回''
|
|
211
175
|
if (!zeroShow && floatNum === 0) return '';
|
|
212
176
|
var isNegativeNumber = floatNum < 0; // 是否是负数
|
|
213
|
-
|
|
214
177
|
if (isNegativeNumber) {
|
|
215
178
|
var _context4;
|
|
216
|
-
|
|
217
179
|
floatNum = Math.abs(floatNum);
|
|
218
180
|
numInfo.numStr = _sliceInstanceProperty(_context4 = numInfo.numStr).call(_context4, 1); // 去除第一个负号
|
|
219
181
|
}
|
|
@@ -221,29 +183,23 @@ export function formatEditNumber(num, _ref) {
|
|
|
221
183
|
var numStrArr = numInfo.numStr.split('.');
|
|
222
184
|
numInfo.intStr = numStrArr[0];
|
|
223
185
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
224
|
-
|
|
225
186
|
if (!showDecimalTailZero) {
|
|
226
187
|
numInfo = cutTailZero(numInfo);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
188
|
+
}
|
|
189
|
+
// 小数部分处理。暂时不考虑其他。只校验位数和尾数补零问题,整数
|
|
230
190
|
if (decimalLength != null && decimalLength >= 0) {
|
|
231
191
|
// floatNum = Number.parseFloat(numInfo.numStr) // 当整数位数大于16位时,parseFloat会丢掉末尾的值
|
|
232
192
|
var isRound = roundMethod.toString() === '1'; // 是否四舍五入
|
|
233
|
-
|
|
234
193
|
numInfo.numStr = toFixed(numInfo.numStr, decimalLength, isRound);
|
|
235
194
|
numStrArr = numInfo.numStr.split('.');
|
|
236
195
|
numInfo.intStr = numStrArr[0];
|
|
237
196
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
238
|
-
|
|
239
197
|
if (!showDecimalTailZero) {
|
|
240
198
|
numInfo = cutTailZero(numInfo);
|
|
241
199
|
}
|
|
242
200
|
}
|
|
243
|
-
|
|
244
201
|
return (isNegativeNumber ? '-' : '') + (numInfo.intStr || '0') + (numInfo.decimalStr.length > 0 ? '.' : '') + numInfo.decimalStr;
|
|
245
202
|
}
|
|
246
|
-
|
|
247
203
|
function analyzMask(mask) {
|
|
248
204
|
var maskInfo = {
|
|
249
205
|
errorMask: false,
|
|
@@ -255,27 +211,20 @@ function analyzMask(mask) {
|
|
|
255
211
|
};
|
|
256
212
|
mask = mask.replace(/%%/g, '');
|
|
257
213
|
maskInfo.currencySign = mask.indexOf('$') >= 0; // 是否显示货币标识
|
|
258
|
-
|
|
259
214
|
maskInfo.percent = mask.indexOf('%') >= 0; // 是否有百分号
|
|
260
|
-
|
|
261
215
|
mask = mask.replace(/%/g, '').replace(/\$/g, ''); // 清楚上面的特殊字符
|
|
262
|
-
|
|
263
216
|
var masks = mask.split('.'); // 以小数点为界切分掩码
|
|
264
|
-
|
|
265
217
|
if (masks.length > 2) {
|
|
266
218
|
maskInfo.errorMask = true;
|
|
267
219
|
}
|
|
268
|
-
|
|
269
220
|
maskInfo.intMask = masks[0];
|
|
270
221
|
maskInfo.decimalMask = masks[1];
|
|
271
222
|
maskInfo.formatMask = mask;
|
|
272
223
|
return maskInfo;
|
|
273
224
|
}
|
|
274
|
-
|
|
275
225
|
function cutTailZero(numInfo) {
|
|
276
226
|
var decimalStr = numInfo.decimalStr;
|
|
277
227
|
var len = decimalStr.length;
|
|
278
|
-
|
|
279
228
|
if (len > 0) {
|
|
280
229
|
for (var i = len - 1; i >= 0; i--) {
|
|
281
230
|
if (decimalStr[i] === '0') {
|
|
@@ -284,28 +233,22 @@ function cutTailZero(numInfo) {
|
|
|
284
233
|
break;
|
|
285
234
|
}
|
|
286
235
|
}
|
|
287
|
-
|
|
288
236
|
numInfo.decimalStr = decimalStr;
|
|
289
237
|
}
|
|
290
|
-
|
|
291
238
|
return numInfo;
|
|
292
239
|
}
|
|
293
|
-
|
|
294
240
|
function intFormatMask(intMask, intValue) {
|
|
295
241
|
var numGroupFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
296
242
|
var index = 0;
|
|
297
243
|
var firstHashIndex = intMask.indexOf('#');
|
|
298
244
|
var lastHashIndex = intMask.lastIndexOf('#');
|
|
299
245
|
var formatValue = '';
|
|
300
|
-
|
|
301
246
|
if (intMask.split(',').length > 1) {
|
|
302
247
|
// 如果包含多个分隔符,则认为是末尾分隔符为分组数
|
|
303
248
|
lastHashIndex = intMask.length - 1 - intMask.lastIndexOf(',');
|
|
304
249
|
}
|
|
305
|
-
|
|
306
250
|
for (var i = intMask.length - 1; i >= 0;) {
|
|
307
251
|
var char = intMask.charAt(i);
|
|
308
|
-
|
|
309
252
|
switch (char) {
|
|
310
253
|
case '0':
|
|
311
254
|
// 数字必录
|
|
@@ -313,35 +256,29 @@ function intFormatMask(intMask, intValue) {
|
|
|
313
256
|
index++;
|
|
314
257
|
i--;
|
|
315
258
|
break;
|
|
316
|
-
|
|
317
259
|
case '9':
|
|
318
260
|
// 数字可选
|
|
319
261
|
formatValue = intValue.charAt(intValue.length - 1 - index) + formatValue;
|
|
320
262
|
index++;
|
|
321
263
|
i--;
|
|
322
264
|
break;
|
|
323
|
-
|
|
324
265
|
case '#':
|
|
325
266
|
// 递归
|
|
326
267
|
formatValue = intValue.charAt(intValue.length - 1 - index) + formatValue;
|
|
327
268
|
index++;
|
|
328
269
|
i = i === firstHashIndex ? lastHashIndex : i - 1;
|
|
329
270
|
break;
|
|
330
|
-
|
|
331
271
|
default:
|
|
332
272
|
if (numGroupFormat) char = numGroupFormat;
|
|
333
273
|
formatValue = char + formatValue;
|
|
334
274
|
i--;
|
|
335
275
|
break;
|
|
336
276
|
}
|
|
337
|
-
|
|
338
277
|
if (index >= intValue.length) break;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
278
|
+
}
|
|
279
|
+
// 如果第一个字符不是数字,去掉
|
|
342
280
|
if (formatValue && !/^[0-9]*$/.test(formatValue.charAt(0))) {
|
|
343
281
|
formatValue = formatValue.substring(1);
|
|
344
282
|
}
|
|
345
|
-
|
|
346
283
|
return formatValue;
|
|
347
284
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// 计算字符串长度,中文字符占两个长度
|
|
2
2
|
export default function (str) {
|
|
3
3
|
var len = 0;
|
|
4
|
-
|
|
5
4
|
for (var i = 0; i < str.length; i++) {
|
|
6
5
|
if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
|
|
7
6
|
len += 2;
|
|
@@ -9,6 +8,5 @@ export default function (str) {
|
|
|
9
8
|
len++;
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return len;
|
|
14
12
|
}
|
package/es/_utils/hooks.js
CHANGED
|
@@ -7,13 +7,9 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
|
7
7
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
8
8
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
9
9
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
10
|
-
|
|
11
10
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
|
-
|
|
13
11
|
function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
-
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
|
-
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
13
|
import { useEffect, useState, useRef, useReducer } from 'react';
|
|
18
14
|
import ResizeObserver from 'resize-observer-polyfill';
|
|
19
15
|
import devWarning from './devwarning';
|
|
@@ -24,17 +20,14 @@ import devWarning from './devwarning';
|
|
|
24
20
|
* @param {RefObject<HTMLElement>[]} refs
|
|
25
21
|
* @param {(e: Event) => void} handler
|
|
26
22
|
*/
|
|
27
|
-
|
|
28
23
|
export function useOnClickOutside(refs, handler) {
|
|
29
24
|
useEffect(function () {
|
|
30
25
|
var listener = function listener(event) {
|
|
31
26
|
var _iterator = _createForOfIteratorHelper(refs),
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
_step;
|
|
34
28
|
try {
|
|
35
29
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
36
30
|
var ref = _step.value;
|
|
37
|
-
|
|
38
31
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
39
32
|
return;
|
|
40
33
|
}
|
|
@@ -44,10 +37,8 @@ export function useOnClickOutside(refs, handler) {
|
|
|
44
37
|
} finally {
|
|
45
38
|
_iterator.f();
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
handler(event);
|
|
49
41
|
};
|
|
50
|
-
|
|
51
42
|
document.addEventListener('mousedown', listener);
|
|
52
43
|
document.addEventListener('touchstart', listener);
|
|
53
44
|
return function () {
|
|
@@ -71,51 +62,42 @@ export function useOnClickOutside(refs, handler) {
|
|
|
71
62
|
* })} [option]
|
|
72
63
|
* @returns {[R, (value: T) => void]}
|
|
73
64
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
export function useMergedState(defaultStateValue,
|
|
66
|
+
// 初始state
|
|
76
67
|
option) {
|
|
77
68
|
var _ref = option || {},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
defaultValue = _ref.defaultValue,
|
|
70
|
+
value = _ref.value,
|
|
71
|
+
onChange = _ref.onChange,
|
|
72
|
+
postState = _ref.postState;
|
|
83
73
|
var _useState = useState(function () {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
innerValue = _useState2[0],
|
|
96
|
-
setInnerValue = _useState2[1];
|
|
97
|
-
|
|
74
|
+
if (value !== undefined) {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
if (defaultValue !== undefined) {
|
|
78
|
+
return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
|
|
79
|
+
}
|
|
80
|
+
return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
|
|
81
|
+
}),
|
|
82
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
+
innerValue = _useState2[0],
|
|
84
|
+
setInnerValue = _useState2[1];
|
|
98
85
|
var mergedValue = value !== undefined ? value : innerValue;
|
|
99
|
-
|
|
100
86
|
if (postState) {
|
|
101
87
|
mergedValue = postState(mergedValue);
|
|
102
88
|
}
|
|
103
|
-
|
|
104
89
|
function triggerChange(newValue) {
|
|
105
90
|
setInnerValue(newValue);
|
|
106
|
-
|
|
107
91
|
if (mergedValue !== newValue && onChange) {
|
|
108
92
|
onChange(newValue, mergedValue);
|
|
109
93
|
}
|
|
110
94
|
}
|
|
111
|
-
|
|
112
95
|
var firstRenderRef = useRef(true);
|
|
113
96
|
useEffect(function () {
|
|
114
97
|
if (firstRenderRef.current) {
|
|
115
98
|
firstRenderRef.current = false;
|
|
116
99
|
return;
|
|
117
100
|
}
|
|
118
|
-
|
|
119
101
|
if (value === undefined) {
|
|
120
102
|
setInnerValue(value);
|
|
121
103
|
}
|
|
@@ -128,7 +110,6 @@ option) {
|
|
|
128
110
|
* @export
|
|
129
111
|
* @param {P} value
|
|
130
112
|
*/
|
|
131
|
-
|
|
132
113
|
export function usePrevious(value) {
|
|
133
114
|
var ref = useRef(value);
|
|
134
115
|
useEffect(function () {
|
|
@@ -140,12 +121,10 @@ export function useHideDocumentScrollBar(visible, isBody, mask) {
|
|
|
140
121
|
useEffect(function () {
|
|
141
122
|
var isChange = false;
|
|
142
123
|
var previousDocumentOverflow = document.documentElement.style.overflow;
|
|
143
|
-
|
|
144
124
|
if (visible && isBody && mask) {
|
|
145
125
|
document.documentElement.style.overflow = 'hidden';
|
|
146
126
|
isChange = true;
|
|
147
127
|
}
|
|
148
|
-
|
|
149
128
|
return function () {
|
|
150
129
|
if (isChange) {
|
|
151
130
|
document.documentElement.style.overflow = previousDocumentOverflow;
|
|
@@ -156,42 +135,33 @@ export function useHideDocumentScrollBar(visible, isBody, mask) {
|
|
|
156
135
|
export function useOverflowHidden(container, hidden, allowDisable) {
|
|
157
136
|
var needResetContainerStyle = useRef(false);
|
|
158
137
|
var originContainerStyle = useRef({});
|
|
159
|
-
|
|
160
138
|
var getScrollBarWidth = function getScrollBarWidth(element) {
|
|
161
139
|
return element.tagName === 'BODY' ? window.innerWidth - (document.body.clientWidth || document.documentElement.clientWidth) : element.offsetWidth - element.clientWidth;
|
|
162
140
|
};
|
|
163
|
-
|
|
164
141
|
var setContainerStyle = function setContainerStyle() {
|
|
165
142
|
if (container && container.style.overflow !== 'hidden') {
|
|
166
143
|
var originStyle = container.style;
|
|
167
144
|
needResetContainerStyle.current = true;
|
|
168
145
|
var containerScrollBarWidth = getScrollBarWidth(container);
|
|
169
|
-
|
|
170
146
|
if (containerScrollBarWidth) {
|
|
171
147
|
var _context;
|
|
172
|
-
|
|
173
148
|
originContainerStyle.current.width = originStyle.width;
|
|
174
149
|
container.style.width = _concatInstanceProperty(_context = "calc(".concat(container.style.width || '100%', " - ")).call(_context, containerScrollBarWidth, "px)");
|
|
175
150
|
}
|
|
176
|
-
|
|
177
151
|
originContainerStyle.current.overflow = originStyle.overflow;
|
|
178
152
|
container.style.overflow = 'hidden';
|
|
179
153
|
}
|
|
180
154
|
};
|
|
181
|
-
|
|
182
155
|
var resetContainerStyle = function resetContainerStyle() {
|
|
183
156
|
if (needResetContainerStyle.current && container) {
|
|
184
157
|
var originStyle = originContainerStyle.current;
|
|
185
|
-
|
|
186
158
|
_Object$keys(originStyle).forEach(function (i) {
|
|
187
159
|
return container.style[i] = originStyle[i];
|
|
188
160
|
});
|
|
189
161
|
}
|
|
190
|
-
|
|
191
162
|
needResetContainerStyle.current = false;
|
|
192
163
|
originContainerStyle.current = {};
|
|
193
164
|
};
|
|
194
|
-
|
|
195
165
|
useEffect(function () {
|
|
196
166
|
if (!allowDisable) return;
|
|
197
167
|
hidden ? setContainerStyle() : resetContainerStyle();
|
|
@@ -206,31 +176,25 @@ export function useResizeObserver(element, handler) {
|
|
|
206
176
|
if (typeof element === 'function') {
|
|
207
177
|
element = element();
|
|
208
178
|
}
|
|
209
|
-
|
|
210
179
|
if (!element) {
|
|
211
180
|
devWarning(!element && element !== null, 'useResizeMeasure', 'useResizeMeasure指定的元素不存在');
|
|
212
181
|
return;
|
|
213
182
|
}
|
|
214
|
-
|
|
215
183
|
var measure = function measure(entries) {
|
|
216
184
|
if (!entries[0] || !entries[0].contentRect) {
|
|
217
185
|
return;
|
|
218
186
|
}
|
|
219
|
-
|
|
220
187
|
var contentRect = entries[0].contentRect;
|
|
221
188
|
var hide = contentRect.width === 0 && contentRect.height === 0; // 隐藏条件:高宽都为0
|
|
222
189
|
// DOMRectReadOnly 对象不可读, 不可赋值
|
|
223
|
-
|
|
224
190
|
var rect = _extends({
|
|
225
191
|
hide: hide
|
|
226
192
|
}, contentRect);
|
|
227
|
-
|
|
228
193
|
['width', 'height', 'x', 'y', 'bottom', 'top', 'left', 'right'].forEach(function (prop) {
|
|
229
194
|
rect[prop] = contentRect[prop];
|
|
230
195
|
});
|
|
231
196
|
handler && handler(rect);
|
|
232
197
|
};
|
|
233
|
-
|
|
234
198
|
var resizeObserver = new ResizeObserver(measure);
|
|
235
199
|
resizeObserver && resizeObserver.observe(element);
|
|
236
200
|
return function () {
|
|
@@ -247,25 +211,23 @@ export function useIsFirstRender() {
|
|
|
247
211
|
}
|
|
248
212
|
export function useForceUpdate() {
|
|
249
213
|
var _useReducer = useReducer(function (v) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
214
|
+
return v + 1;
|
|
215
|
+
}, 0),
|
|
216
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
217
|
+
dispatch = _useReducer2[1];
|
|
255
218
|
return dispatch;
|
|
256
219
|
}
|
|
257
220
|
export function useStateWithPromise(defaultVal) {
|
|
258
221
|
var _useState3 = useState({
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
222
|
+
value: defaultVal,
|
|
223
|
+
resolve: function resolve(e) {
|
|
224
|
+
// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions
|
|
225
|
+
e;
|
|
226
|
+
}
|
|
227
|
+
}),
|
|
228
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
229
|
+
state = _useState4[0],
|
|
230
|
+
setState = _useState4[1];
|
|
269
231
|
useEffect(function () {
|
|
270
232
|
state.resolve(state.value);
|
|
271
233
|
}, [state]);
|
|
@@ -273,11 +235,9 @@ export function useStateWithPromise(defaultVal) {
|
|
|
273
235
|
return new _Promise(function (resolve) {
|
|
274
236
|
setState(function (prevState) {
|
|
275
237
|
var nextVal = updater;
|
|
276
|
-
|
|
277
238
|
if (typeof updater === 'function') {
|
|
278
239
|
nextVal = updater(prevState.value);
|
|
279
240
|
}
|
|
280
|
-
|
|
281
241
|
return {
|
|
282
242
|
value: nextVal,
|
|
283
243
|
resolve: resolve
|
package/es/_utils/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import compDefaultProps from '../config-provider/compDefaultProps'; // kdesign提供组件默认属性
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* 结合compDefaultProps、用户自定义默认属性和组件当前属性获取组件实际应用属性
|
|
6
5
|
* @param {keyof typeof compDefaultProps} compName 组件名
|
|
7
6
|
* @param {any} userDefaultProps 用户自定义组件默认属性
|
|
8
7
|
* @param {any} compProps 组件接收到的属性
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
9
|
export var getCompProps = function getCompProps(compName, userDefaultProps, compProps) {
|
|
12
10
|
var defaultProps = compDefaultProps[compName];
|
|
13
11
|
var userProps = userDefaultProps && userDefaultProps[compName] || {};
|