@kdcloudjs/kdesign 1.8.11 → 1.8.13
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/dist/kdesign.css +1 -1
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +93 -15
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +1 -1
- package/dist/kdesign.min.js +3 -3
- package/dist/kdesign.min.js.map +1 -1
- package/es/_utils/KeyCode.js +1 -333
- package/es/_utils/arrayUtil.js +0 -8
- package/es/_utils/formatUtil.js +9 -59
- package/es/_utils/getStringLength.js +0 -1
- package/es/_utils/hooks.js +2 -34
- package/es/_utils/index.js +1 -7
- package/es/_utils/numberUtil.js +0 -54
- package/es/_utils/raf.js +2 -2
- package/es/_utils/reactNode.js +1 -1
- package/es/_utils/resizeObserver.js +2 -4
- package/es/_utils/type.js +0 -1
- package/es/_utils/usePopper.js +3 -3
- package/es/alert/alert.js +8 -16
- package/es/anchor/anchor-link.js +3 -3
- package/es/anchor/anchor.js +23 -26
- package/es/anchor/context.js +1 -1
- package/es/avatar/avatar.js +8 -11
- package/es/badge/badge.js +7 -13
- package/es/base-data/base-data.js +42 -104
- package/es/breadcrumb/breadcrumb.js +12 -12
- package/es/breadcrumb/breadcrumbItem.js +5 -5
- package/es/button/button.js +13 -24
- package/es/button/group.js +13 -13
- package/es/card/card.js +12 -14
- package/es/carousel/carousel.js +13 -13
- package/es/carousel/displayList.js +3 -3
- package/es/carousel/fadeList.js +3 -3
- package/es/carousel/slideList.js +4 -4
- package/es/carousel/slidebar.js +3 -3
- package/es/cascader/cascader.js +31 -36
- package/es/checkbox/checkbox.js +25 -30
- package/es/checkbox/group.js +8 -9
- package/es/city-picker/city-picker.js +28 -38
- package/es/city-picker/interface.js +1 -1
- package/es/city-picker/option.js +4 -4
- package/es/clipboard/clipboard.js +5 -23
- package/es/clipboard/util.js +0 -60
- package/es/collapse/collapse.js +5 -5
- package/es/collapse/panel.js +15 -15
- package/es/color-picker/color-picker-panel.js +12 -13
- package/es/color-picker/color-picker.js +6 -10
- package/es/color-picker/utils/validateColor.js +0 -3
- package/es/config-provider/ConfigContext.js +1 -4
- package/es/config-provider/SizeContext.js +3 -3
- package/es/config-provider/compDefaultProps.js +3 -10
- package/es/config-provider/configProvider.js +1 -6
- package/es/config-provider/defaultConfig.js +0 -1
- package/es/date-picker/calendar.js +6 -23
- package/es/date-picker/context.js +1 -1
- package/es/date-picker/date-panel.js +12 -13
- package/es/date-picker/date-picker.js +7 -12
- package/es/date-picker/hooks/use-hover-value.js +0 -1
- package/es/date-picker/hooks/use-picker-input.js +0 -4
- package/es/date-picker/hooks/use-range-disabled.js +2 -6
- package/es/date-picker/hooks/use-range-view-dates.js +1 -9
- package/es/date-picker/hooks/use-text-value-mapping.js +0 -1
- package/es/date-picker/locale/zh_CN.js +0 -1
- package/es/date-picker/panel/date-time/date-time.js +4 -6
- package/es/date-picker/panel/header/header.js +14 -14
- package/es/date-picker/panel/month/month.js +5 -6
- package/es/date-picker/panel/quarter/quarter.js +4 -4
- package/es/date-picker/panel/time/time-column.js +4 -6
- package/es/date-picker/panel/time/time.js +10 -35
- package/es/date-picker/panel/week/week.js +5 -8
- package/es/date-picker/panel/year/year.js +4 -6
- package/es/date-picker/popper.js +3 -6
- package/es/date-picker/range/input-range.js +12 -13
- package/es/date-picker/range-picker.js +13 -36
- package/es/date-picker/single/input-date.js +8 -14
- package/es/date-picker/utils/date-fns.js +0 -35
- package/es/date-picker/utils/get-extra-footer.js +1 -1
- package/es/date-picker/utils/get-ranges.js +8 -8
- package/es/date-picker/utils/index.js +0 -3
- package/es/divider/divider.js +2 -2
- package/es/drawer/drawer.js +14 -39
- package/es/dropdown/dropdown.js +10 -11
- package/es/dropdown/menu.js +8 -12
- package/es/empty/defaultEmptyImg.js +18 -18
- package/es/empty/empty.js +9 -10
- package/es/empty/illustrationEmptyImg.js +106 -106
- package/es/filter/condition.js +10 -10
- package/es/filter/filter.js +17 -19
- package/es/filter/scheme.js +34 -41
- package/es/form/Field.js +5 -5
- package/es/form/FieldContext.js +1 -1
- package/es/form/FieldLabel.js +2 -2
- package/es/form/FieldWrapper.js +6 -6
- package/es/form/Form.js +2 -5
- package/es/form/FormContext.js +2 -4
- package/es/form/hooks/useForm.js +1 -14
- package/es/form/index.js +1 -1
- package/es/grid/col.js +1 -7
- package/es/grid/row.js +3 -9
- package/es/icon/icon.js +2 -2
- package/es/image/image.js +5 -7
- package/es/image/preview-group.js +3 -4
- package/es/image/preview.js +22 -24
- package/es/image-cropper/cropper.js +3 -6
- package/es/image-cropper/image-cropper.js +5 -5
- package/es/image-cropper/operation-bar.js +9 -9
- package/es/index.js +4 -0
- package/es/input/ClearableLabeledInput.js +13 -13
- package/es/input/TextArea.js +7 -7
- package/es/input/calculateNodeHeight.js +6 -11
- package/es/input/index.js +0 -1
- package/es/input/input.js +5 -5
- package/es/input-number/inputNumber.js +3 -10
- package/es/layout/layout.js +5 -9
- package/es/layout/sider.js +11 -14
- package/es/link/link.js +8 -12
- package/es/locale/locale.js +4 -34
- package/es/menu/menu.js +3 -4
- package/es/menu/menuItem.js +8 -13
- package/es/menu/subMenu.js +19 -27
- package/es/menu/util.js +0 -4
- package/es/message/content.js +13 -13
- package/es/message/index.js +1 -3
- package/es/modal/confirm.js +1 -1
- package/es/modal/modal.js +32 -40
- package/es/notification/content.js +18 -18
- package/es/notification/index.js +1 -1
- package/es/notification-base/index.js +1 -1
- package/es/notification-base/notice.js +2 -2
- package/es/notification-base/notification.js +3 -3
- package/es/pagination/pagination.js +48 -70
- package/es/popconfirm/popconfirm.js +8 -10
- package/es/popper/index.d.ts +4 -1
- package/es/popper/index.js +84 -22
- package/es/progress/circle.js +6 -8
- package/es/progress/line.js +3 -3
- package/es/progress/progress.js +11 -11
- package/es/qr-code/qr-code.js +6 -6
- package/es/radio/context.js +1 -1
- package/es/radio/group.js +9 -13
- package/es/radio/radio-button.js +2 -2
- package/es/radio/radio.js +19 -24
- package/es/rate/rate.js +11 -61
- package/es/search/option.js +4 -5
- package/es/search/quick-search.js +36 -57
- package/es/search/search-panel.js +56 -60
- package/es/search/search.js +9 -10
- package/es/select/interface.js +1 -1
- package/es/select/option.js +4 -4
- package/es/select/select.js +47 -87
- package/es/signature/drawingBoard.js +16 -16
- package/es/signature/signature.js +20 -20
- package/es/signature/utils/signature_pad.js +4 -12
- package/es/slider/marks.js +3 -5
- package/es/slider/slider.js +11 -32
- package/es/slider/sliderTooltip.js +3 -3
- package/es/slider/steps.js +2 -2
- package/es/slider/track.js +1 -1
- package/es/space/space.js +3 -5
- package/es/spin/spin.js +16 -18
- package/es/split-panel/split-panel.js +7 -18
- package/es/split-panel/trigger.js +6 -6
- package/es/stepper/stepper.js +11 -12
- package/es/steps/Step.js +8 -8
- package/es/steps/Steps.js +5 -5
- package/es/switch/switch.js +4 -6
- package/es/table/api.js +5 -22
- package/es/table/table.js +4 -15
- package/es/tabs/active-line.js +2 -6
- package/es/tabs/arrow-button.js +3 -3
- package/es/tabs/context.js +1 -1
- package/es/tabs/index.js +0 -1
- package/es/tabs/tab-pane.js +6 -6
- package/es/tabs/tabs.js +31 -34
- package/es/tag/tag.js +7 -15
- package/es/timeline/Timeline.js +5 -5
- package/es/timeline/TimelineItem.js +5 -5
- package/es/tooltip/tooltip.js +2 -2
- package/es/transfer/list-body.js +4 -4
- package/es/transfer/list-item.js +5 -6
- package/es/transfer/list.js +18 -22
- package/es/transfer/operation.js +7 -7
- package/es/transfer/search.js +5 -5
- package/es/transfer/transfer.js +8 -13
- package/es/tree/tree.js +9 -9
- package/es/tree/treeNode.js +18 -20
- package/es/tree/utils/treeUtils.js +1 -27
- package/es/tree-select/interface.js +1 -1
- package/es/tree-select/tree-select.js +35 -48
- package/es/typography/base.js +5 -5
- package/es/typography/index.js +0 -1
- package/es/typography/paragraph.js +1 -1
- package/es/typography/text.js +1 -1
- package/es/typography/title.js +1 -1
- package/es/typography/typography.js +4 -8
- package/es/upload/dragger.js +2 -2
- package/es/upload/request.js +0 -5
- package/es/upload/scan-files.js +0 -1
- package/es/upload/upload.js +34 -34
- package/es/upload/verify-file.js +0 -1
- package/es/view-container/context.js +1 -1
- package/es/view-container/view-container.js +4 -8
- package/es/virtual-list/Filler.js +2 -2
- package/es/virtual-list/utils/algorithmUtil.js +0 -13
- package/es/virtual-list/utils/itemUtil.js +0 -30
- package/es/virtual-list/virtual-list.js +8 -11
- package/lib/_utils/KeyCode.js +1 -333
- package/lib/_utils/arrayUtil.js +0 -8
- package/lib/_utils/formatUtil.js +9 -59
- package/lib/_utils/getStringLength.js +0 -1
- package/lib/_utils/hooks.js +2 -34
- package/lib/_utils/index.js +0 -7
- package/lib/_utils/numberUtil.js +0 -54
- package/lib/_utils/raf.js +2 -2
- package/lib/_utils/reactNode.js +1 -1
- package/lib/_utils/resizeObserver.js +2 -4
- package/lib/_utils/type.js +0 -1
- package/lib/_utils/usePopper.js +3 -3
- package/lib/alert/alert.js +8 -16
- package/lib/anchor/anchor-link.js +3 -3
- package/lib/anchor/anchor.js +23 -26
- package/lib/anchor/context.js +1 -1
- package/lib/avatar/avatar.js +8 -11
- package/lib/badge/badge.js +7 -13
- package/lib/base-data/base-data.js +42 -104
- package/lib/breadcrumb/breadcrumb.js +12 -12
- package/lib/breadcrumb/breadcrumbItem.js +5 -5
- package/lib/button/button.js +13 -24
- package/lib/button/group.js +13 -13
- package/lib/card/card.js +12 -14
- package/lib/carousel/carousel.js +13 -13
- package/lib/carousel/displayList.js +3 -3
- package/lib/carousel/fadeList.js +3 -3
- package/lib/carousel/slideList.js +4 -4
- package/lib/carousel/slidebar.js +3 -3
- package/lib/cascader/cascader.js +31 -36
- package/lib/checkbox/checkbox.js +25 -30
- package/lib/checkbox/group.js +8 -8
- package/lib/city-picker/city-picker.js +28 -38
- package/lib/city-picker/interface.js +1 -1
- package/lib/city-picker/option.js +4 -4
- package/lib/clipboard/clipboard.js +5 -23
- package/lib/clipboard/util.js +0 -60
- package/lib/collapse/collapse.js +5 -5
- package/lib/collapse/panel.js +15 -15
- package/lib/color-picker/color-picker-panel.js +12 -14
- package/lib/color-picker/color-picker.js +6 -10
- package/lib/color-picker/utils/validateColor.js +0 -3
- package/lib/config-provider/ConfigContext.js +1 -5
- package/lib/config-provider/SizeContext.js +3 -3
- package/lib/config-provider/compDefaultProps.js +3 -10
- package/lib/config-provider/configProvider.js +1 -7
- package/lib/config-provider/defaultConfig.js +0 -1
- package/lib/date-picker/calendar.js +6 -23
- package/lib/date-picker/context.js +1 -1
- package/lib/date-picker/date-panel.js +12 -13
- package/lib/date-picker/date-picker.js +7 -12
- package/lib/date-picker/hooks/use-hover-value.js +0 -1
- package/lib/date-picker/hooks/use-picker-input.js +0 -4
- package/lib/date-picker/hooks/use-range-disabled.js +2 -6
- package/lib/date-picker/hooks/use-range-view-dates.js +1 -9
- package/lib/date-picker/hooks/use-text-value-mapping.js +0 -1
- package/lib/date-picker/locale/zh_CN.js +0 -1
- package/lib/date-picker/panel/date-time/date-time.js +4 -6
- package/lib/date-picker/panel/header/header.js +14 -14
- package/lib/date-picker/panel/month/month.js +5 -6
- package/lib/date-picker/panel/quarter/quarter.js +4 -4
- package/lib/date-picker/panel/time/time-column.js +4 -6
- package/lib/date-picker/panel/time/time.js +10 -35
- package/lib/date-picker/panel/week/week.js +5 -8
- package/lib/date-picker/panel/year/year.js +4 -6
- package/lib/date-picker/popper.js +3 -6
- package/lib/date-picker/range/input-range.js +12 -13
- package/lib/date-picker/range-picker.js +13 -36
- package/lib/date-picker/single/input-date.js +8 -14
- package/lib/date-picker/utils/date-fns.js +0 -34
- package/lib/date-picker/utils/get-extra-footer.js +1 -1
- package/lib/date-picker/utils/get-ranges.js +8 -8
- package/lib/date-picker/utils/index.js +0 -3
- package/lib/divider/divider.js +2 -2
- package/lib/drawer/drawer.js +14 -40
- package/lib/dropdown/dropdown.js +10 -11
- package/lib/dropdown/menu.js +8 -12
- package/lib/empty/defaultEmptyImg.js +18 -18
- package/lib/empty/empty.js +9 -10
- package/lib/empty/illustrationEmptyImg.js +106 -106
- package/lib/filter/condition.js +10 -10
- package/lib/filter/filter.js +17 -19
- package/lib/filter/scheme.js +34 -41
- package/lib/form/Field.js +5 -5
- package/lib/form/FieldContext.js +1 -1
- package/lib/form/FieldLabel.js +2 -2
- package/lib/form/FieldWrapper.js +6 -6
- package/lib/form/Form.js +2 -5
- package/lib/form/FormContext.js +2 -4
- package/lib/form/hooks/useForm.js +1 -14
- package/lib/form/index.js +1 -1
- package/lib/grid/col.js +1 -7
- package/lib/grid/row.js +3 -9
- package/lib/icon/icon.js +2 -2
- package/lib/image/image.js +5 -7
- package/lib/image/preview-group.js +3 -4
- package/lib/image/preview.js +22 -24
- package/lib/image-cropper/cropper.js +3 -6
- package/lib/image-cropper/image-cropper.js +5 -5
- package/lib/image-cropper/operation-bar.js +9 -9
- package/lib/index.js +2 -8
- package/lib/input/ClearableLabeledInput.js +13 -13
- package/lib/input/TextArea.js +7 -7
- package/lib/input/calculateNodeHeight.js +6 -11
- package/lib/input/index.js +0 -1
- package/lib/input/input.js +5 -5
- package/lib/input-number/inputNumber.js +3 -10
- package/lib/layout/layout.js +5 -9
- package/lib/layout/sider.js +11 -14
- package/lib/link/link.js +8 -12
- package/lib/locale/locale.js +4 -34
- package/lib/menu/menu.js +3 -4
- package/lib/menu/menuItem.js +8 -13
- package/lib/menu/subMenu.js +19 -27
- package/lib/menu/util.js +0 -4
- package/lib/message/content.js +13 -13
- package/lib/message/index.js +1 -3
- package/lib/modal/confirm.js +1 -1
- package/lib/modal/modal.js +32 -40
- package/lib/notification/content.js +18 -18
- package/lib/notification/index.js +1 -1
- package/lib/notification-base/index.js +1 -1
- package/lib/notification-base/notice.js +2 -2
- package/lib/notification-base/notification.js +3 -3
- package/lib/pagination/pagination.js +48 -70
- package/lib/popconfirm/popconfirm.js +8 -10
- package/lib/popper/index.d.ts +4 -1
- package/lib/popper/index.js +84 -22
- package/lib/progress/circle.js +6 -8
- package/lib/progress/line.js +3 -3
- package/lib/progress/progress.js +11 -11
- package/lib/qr-code/qr-code.js +6 -6
- package/lib/radio/context.js +1 -1
- package/lib/radio/group.js +9 -13
- package/lib/radio/radio-button.js +2 -2
- package/lib/radio/radio.js +19 -24
- package/lib/rate/rate.js +11 -61
- package/lib/search/option.js +4 -5
- package/lib/search/quick-search.js +36 -57
- package/lib/search/search-panel.js +56 -60
- package/lib/search/search.js +9 -10
- package/lib/select/interface.js +1 -1
- package/lib/select/option.js +4 -4
- package/lib/select/select.js +47 -87
- package/lib/signature/drawingBoard.js +16 -16
- package/lib/signature/signature.js +20 -20
- package/lib/signature/utils/signature_pad.js +4 -12
- package/lib/slider/marks.js +3 -5
- package/lib/slider/slider.js +11 -32
- package/lib/slider/sliderTooltip.js +3 -3
- package/lib/slider/steps.js +2 -2
- package/lib/slider/track.js +1 -1
- package/lib/space/space.js +3 -5
- package/lib/spin/spin.js +16 -18
- package/lib/split-panel/split-panel.js +7 -18
- package/lib/split-panel/trigger.js +6 -6
- package/lib/stepper/stepper.js +11 -12
- package/lib/steps/Step.js +8 -8
- package/lib/steps/Steps.js +5 -5
- package/lib/switch/switch.js +4 -6
- package/lib/table/api.js +5 -22
- package/lib/table/table.js +4 -15
- package/lib/tabs/active-line.js +2 -6
- package/lib/tabs/arrow-button.js +3 -3
- package/lib/tabs/context.js +1 -1
- package/lib/tabs/index.js +0 -1
- package/lib/tabs/tab-pane.js +6 -6
- package/lib/tabs/tabs.js +31 -34
- package/lib/tag/tag.js +7 -15
- package/lib/timeline/Timeline.js +5 -5
- package/lib/timeline/TimelineItem.js +5 -5
- package/lib/tooltip/tooltip.js +2 -2
- package/lib/transfer/list-body.js +4 -4
- package/lib/transfer/list-item.js +5 -6
- package/lib/transfer/list.js +18 -22
- package/lib/transfer/operation.js +7 -7
- package/lib/transfer/search.js +5 -5
- package/lib/transfer/transfer.js +8 -13
- package/lib/tree/tree.js +9 -9
- package/lib/tree/treeNode.js +18 -20
- package/lib/tree/utils/treeUtils.js +1 -27
- package/lib/tree-select/interface.js +1 -1
- package/lib/tree-select/tree-select.js +35 -48
- package/lib/typography/base.js +5 -5
- package/lib/typography/index.js +0 -1
- package/lib/typography/paragraph.js +1 -1
- package/lib/typography/text.js +1 -1
- package/lib/typography/title.js +1 -1
- package/lib/typography/typography.js +4 -8
- package/lib/upload/dragger.js +2 -2
- package/lib/upload/request.js +0 -5
- package/lib/upload/scan-files.js +0 -1
- package/lib/upload/upload.js +34 -34
- package/lib/upload/verify-file.js +0 -1
- package/lib/view-container/context.js +1 -1
- package/lib/view-container/view-container.js +4 -8
- package/lib/virtual-list/Filler.js +2 -2
- package/lib/virtual-list/utils/algorithmUtil.js +0 -13
- package/lib/virtual-list/utils/itemUtil.js +0 -30
- package/lib/virtual-list/virtual-list.js +8 -12
- package/package.json +1 -3
package/lib/_utils/formatUtil.js
CHANGED
|
@@ -20,28 +20,6 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
/**
|
|
24
|
-
* [数值类型格式化]
|
|
25
|
-
* @param {[type]} num [待格式化的数字]
|
|
26
|
-
* @param {String} mask [数值掩码
|
|
27
|
-
* 0:必须输入数字(0—9)
|
|
28
|
-
* 9:可选择输入数字(0—9)或空格
|
|
29
|
-
* #:可选择输入数字(0—9) 递归
|
|
30
|
-
* .: 小数点
|
|
31
|
-
* ,: 千位符
|
|
32
|
-
* %: 对最终值除以100处理
|
|
33
|
-
* %%: 对最终值不做处理
|
|
34
|
-
* //A: [a-zA-Z0-9]
|
|
35
|
-
* //S: [a-zA-Z]
|
|
36
|
-
* //&:必须输入任一字符或空格
|
|
37
|
-
* //C:可选择输入任一字符或空格
|
|
38
|
-
* $: 货币
|
|
39
|
-
* ]
|
|
40
|
-
* @param {Boolean} zeroShow [为零显示]
|
|
41
|
-
* @param {[type]} decimalLength [小数精度的位数]
|
|
42
|
-
* @param {Boolean} showDecimalTailZero [是否显示尾部零]
|
|
43
|
-
* @return [格式化后的数值]
|
|
44
|
-
*/
|
|
45
23
|
function formatNumber(num, formatParams) {
|
|
46
24
|
var _context;
|
|
47
25
|
var _formatParams$mask = formatParams.mask,
|
|
@@ -69,13 +47,9 @@ function formatNumber(num, formatParams) {
|
|
|
69
47
|
}
|
|
70
48
|
}
|
|
71
49
|
var floatNum = (0, _parseFloat.default)(numInfo.numStr);
|
|
72
|
-
// 非纯数字不处理,直接返回''
|
|
73
|
-
// if (Number.isNaN(floatNum)) return ''
|
|
74
50
|
if ((0, _isNan.default)(Number(num))) {
|
|
75
|
-
// throw new Error('toFixed() number argument must be a valid number')
|
|
76
51
|
return num + '';
|
|
77
52
|
}
|
|
78
|
-
// 为零不显示,且等于零,直接返回''
|
|
79
53
|
if (!zeroShow && Number(num) === 0) return '';
|
|
80
54
|
var maskInfo = analyzMask(mask);
|
|
81
55
|
if (maskInfo.errorMask) return numInfo.numStr;
|
|
@@ -95,11 +69,9 @@ function formatNumber(num, formatParams) {
|
|
|
95
69
|
var numStr = numInfo.numStr.replace('.', '');
|
|
96
70
|
numInfo.numStr = numStr.substring(0, point + 2) + '.' + numStr.substring(point + 2);
|
|
97
71
|
}
|
|
98
|
-
// 去掉数字前面的零
|
|
99
72
|
numInfo.numStr = numInfo.numStr.replace(/^0+/, '');
|
|
100
73
|
if (numInfo.numStr === '.') numInfo.numStr = '0';
|
|
101
74
|
if ((0, _includes.default)(_context2 = numInfo.numStr).call(_context2, '-')) {
|
|
102
|
-
// 负数的情况 去掉前面的0
|
|
103
75
|
numInfo.numStr = numInfo.numStr.replace('-', '');
|
|
104
76
|
numInfo.numStr = numInfo.numStr.replace(/^0+/, '');
|
|
105
77
|
numInfo.numStr = '-' + numInfo.numStr;
|
|
@@ -107,25 +79,21 @@ function formatNumber(num, formatParams) {
|
|
|
107
79
|
floatNum = floatNum * 100;
|
|
108
80
|
}
|
|
109
81
|
}
|
|
110
|
-
var isNegativeNumber = floatNum < 0;
|
|
82
|
+
var isNegativeNumber = floatNum < 0;
|
|
111
83
|
if (isNegativeNumber) {
|
|
112
84
|
var _context3;
|
|
113
85
|
floatNum = Math.abs(floatNum);
|
|
114
|
-
numInfo.numStr = (0, _slice.default)(_context3 = numInfo.numStr).call(_context3, 1);
|
|
86
|
+
numInfo.numStr = (0, _slice.default)(_context3 = numInfo.numStr).call(_context3, 1);
|
|
115
87
|
}
|
|
116
|
-
|
|
117
88
|
var numStrArr = numInfo.numStr.split('.');
|
|
118
89
|
numInfo.intStr = numStrArr[0];
|
|
119
90
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
120
91
|
if (!showDecimalTailZero) {
|
|
121
92
|
numInfo = cutTailZero(numInfo);
|
|
122
93
|
}
|
|
123
|
-
// 小数部分处理。暂时不考虑其他。只校验位数和尾数补零问题,整数
|
|
124
94
|
if (decimalLength !== undefined && decimalLength >= 0) {
|
|
125
|
-
// floatNum = Number.parseFloat(numInfo.numStr) // 当整数位数大于16位时,parseFloat会丢掉末尾的值,有问题!!!
|
|
126
95
|
numInfo.numStr = (0, _numberUtil.toFixed)(numInfo.numStr, decimalLength, isRound);
|
|
127
96
|
numStrArr = numInfo.numStr.split('.');
|
|
128
|
-
// 去除整数部分多余的 0
|
|
129
97
|
var intStr = numStrArr[0].replace(/^0+/, '');
|
|
130
98
|
numInfo.intStr = intStr === '' ? '0' : intStr;
|
|
131
99
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
@@ -133,7 +101,6 @@ function formatNumber(num, formatParams) {
|
|
|
133
101
|
numInfo = cutTailZero(numInfo);
|
|
134
102
|
}
|
|
135
103
|
}
|
|
136
|
-
// 整数部分格式化
|
|
137
104
|
var formatValue = intFormatMask(maskInfo.intMask, numInfo.intStr);
|
|
138
105
|
var currencySign = maskInfo.currencySign ? '$' : '';
|
|
139
106
|
if (param.symbol) {
|
|
@@ -141,12 +108,6 @@ function formatNumber(num, formatParams) {
|
|
|
141
108
|
}
|
|
142
109
|
return currencySign + (isNegativeNumber ? '-' : '') + (formatValue || numInfo.intStr || '0') + (numInfo.decimalStr.length > 0 ? '.' : '') + numInfo.decimalStr + (maskInfo.percent ? '%' : '');
|
|
143
110
|
}
|
|
144
|
-
/**
|
|
145
|
-
* 格式化数字字段编辑态的值
|
|
146
|
-
* 不支持掩码的格式化信息
|
|
147
|
-
* @param {*} num
|
|
148
|
-
* @param {*} param
|
|
149
|
-
*/
|
|
150
111
|
function formatEditNumber(num, _ref) {
|
|
151
112
|
var _ref$zeroShow = _ref.zeroShow,
|
|
152
113
|
zeroShow = _ref$zeroShow === void 0 ? false : _ref$zeroShow,
|
|
@@ -156,7 +117,6 @@ function formatEditNumber(num, _ref) {
|
|
|
156
117
|
_ref$roundMethod = _ref.roundMethod,
|
|
157
118
|
roundMethod = _ref$roundMethod === void 0 ? '0' : _ref$roundMethod,
|
|
158
119
|
symbol = _ref.symbol;
|
|
159
|
-
// 如果精度超过100,直接返回数值
|
|
160
120
|
if (decimalLength && (decimalLength < 0 || decimalLength > 100)) return num + '';
|
|
161
121
|
if (num === undefined || num === null) num = '';
|
|
162
122
|
var numInfo = {
|
|
@@ -177,27 +137,22 @@ function formatEditNumber(num, _ref) {
|
|
|
177
137
|
}
|
|
178
138
|
}
|
|
179
139
|
var floatNum = (0, _parseFloat.default)(numInfo.numStr);
|
|
180
|
-
// 非纯数字不处理,直接返回''
|
|
181
140
|
if ((0, _isNan.default)(floatNum)) return '';
|
|
182
|
-
// 为零不显示,且等于零,直接返回''
|
|
183
141
|
if (!zeroShow && floatNum === 0) return '';
|
|
184
|
-
var isNegativeNumber = floatNum < 0;
|
|
142
|
+
var isNegativeNumber = floatNum < 0;
|
|
185
143
|
if (isNegativeNumber) {
|
|
186
144
|
var _context4;
|
|
187
145
|
floatNum = Math.abs(floatNum);
|
|
188
|
-
numInfo.numStr = (0, _slice.default)(_context4 = numInfo.numStr).call(_context4, 1);
|
|
146
|
+
numInfo.numStr = (0, _slice.default)(_context4 = numInfo.numStr).call(_context4, 1);
|
|
189
147
|
}
|
|
190
|
-
|
|
191
148
|
var numStrArr = numInfo.numStr.split('.');
|
|
192
149
|
numInfo.intStr = numStrArr[0];
|
|
193
150
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
194
151
|
if (!showDecimalTailZero) {
|
|
195
152
|
numInfo = cutTailZero(numInfo);
|
|
196
153
|
}
|
|
197
|
-
// 小数部分处理。暂时不考虑其他。只校验位数和尾数补零问题,整数
|
|
198
154
|
if (decimalLength != null && decimalLength >= 0) {
|
|
199
|
-
|
|
200
|
-
var isRound = roundMethod.toString() === '1'; // 是否四舍五入
|
|
155
|
+
var isRound = roundMethod.toString() === '1';
|
|
201
156
|
numInfo.numStr = (0, _numberUtil.toFixed)(numInfo.numStr, decimalLength, isRound);
|
|
202
157
|
numStrArr = numInfo.numStr.split('.');
|
|
203
158
|
numInfo.intStr = numStrArr[0];
|
|
@@ -218,10 +173,10 @@ function analyzMask(mask) {
|
|
|
218
173
|
formatMask: ''
|
|
219
174
|
};
|
|
220
175
|
mask = mask.replace(/%%/g, '');
|
|
221
|
-
maskInfo.currencySign = mask.indexOf('$') >= 0;
|
|
222
|
-
maskInfo.percent = mask.indexOf('%') >= 0;
|
|
223
|
-
mask = mask.replace(/%/g, '').replace(/\$/g, '');
|
|
224
|
-
var masks = mask.split('.');
|
|
176
|
+
maskInfo.currencySign = mask.indexOf('$') >= 0;
|
|
177
|
+
maskInfo.percent = mask.indexOf('%') >= 0;
|
|
178
|
+
mask = mask.replace(/%/g, '').replace(/\$/g, '');
|
|
179
|
+
var masks = mask.split('.');
|
|
225
180
|
if (masks.length > 2) {
|
|
226
181
|
maskInfo.errorMask = true;
|
|
227
182
|
}
|
|
@@ -252,26 +207,22 @@ function intFormatMask(intMask, intValue) {
|
|
|
252
207
|
var lastHashIndex = intMask.lastIndexOf('#');
|
|
253
208
|
var formatValue = '';
|
|
254
209
|
if (intMask.split(',').length > 1) {
|
|
255
|
-
// 如果包含多个分隔符,则认为是末尾分隔符为分组数
|
|
256
210
|
lastHashIndex = intMask.length - 1 - intMask.lastIndexOf(',');
|
|
257
211
|
}
|
|
258
212
|
for (var i = intMask.length - 1; i >= 0;) {
|
|
259
213
|
var char = intMask.charAt(i);
|
|
260
214
|
switch (char) {
|
|
261
215
|
case '0':
|
|
262
|
-
// 数字必录
|
|
263
216
|
formatValue = (intValue.charAt(intValue.length - 1 - index) || '0') + formatValue;
|
|
264
217
|
index++;
|
|
265
218
|
i--;
|
|
266
219
|
break;
|
|
267
220
|
case '9':
|
|
268
|
-
// 数字可选
|
|
269
221
|
formatValue = intValue.charAt(intValue.length - 1 - index) + formatValue;
|
|
270
222
|
index++;
|
|
271
223
|
i--;
|
|
272
224
|
break;
|
|
273
225
|
case '#':
|
|
274
|
-
// 递归
|
|
275
226
|
formatValue = intValue.charAt(intValue.length - 1 - index) + formatValue;
|
|
276
227
|
index++;
|
|
277
228
|
i = i === firstHashIndex ? lastHashIndex : i - 1;
|
|
@@ -284,7 +235,6 @@ function intFormatMask(intMask, intValue) {
|
|
|
284
235
|
}
|
|
285
236
|
if (index >= intValue.length) break;
|
|
286
237
|
}
|
|
287
|
-
// 如果第一个字符不是数字,去掉
|
|
288
238
|
if (formatValue && !/^[0-9]*$/.test(formatValue.charAt(0))) {
|
|
289
239
|
formatValue = formatValue.substring(1);
|
|
290
240
|
}
|
package/lib/_utils/hooks.js
CHANGED
|
@@ -28,13 +28,6 @@ var _devwarning = _interopRequireDefault(require("./devwarning"));
|
|
|
28
28
|
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; } } }; }
|
|
29
29
|
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); }
|
|
30
30
|
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; }
|
|
31
|
-
/**
|
|
32
|
-
* @description 点击指定区域外执行回调
|
|
33
|
-
*
|
|
34
|
-
* @export
|
|
35
|
-
* @param {RefObject<HTMLElement>[]} refs
|
|
36
|
-
* @param {(e: Event) => void} handler
|
|
37
|
-
*/
|
|
38
31
|
function useOnClickOutside(refs, handler) {
|
|
39
32
|
(0, _react.useEffect)(function () {
|
|
40
33
|
var listener = function listener(event) {
|
|
@@ -62,24 +55,7 @@ function useOnClickOutside(refs, handler) {
|
|
|
62
55
|
};
|
|
63
56
|
}, [refs, handler]);
|
|
64
57
|
}
|
|
65
|
-
|
|
66
|
-
* @description 合并状态
|
|
67
|
-
*
|
|
68
|
-
* @export
|
|
69
|
-
* @template T
|
|
70
|
-
* @template R
|
|
71
|
-
* @param {(T | (() => T))} defaultStateValue
|
|
72
|
-
* @param {({
|
|
73
|
-
* defaultValue?: T | (() => T)
|
|
74
|
-
* value?: T
|
|
75
|
-
* onChange?: (value: T, prevValue: T) => void
|
|
76
|
-
* postState?: (value: T) => T
|
|
77
|
-
* })} [option]
|
|
78
|
-
* @returns {[R, (value: T) => void]}
|
|
79
|
-
*/
|
|
80
|
-
function useMergedState(defaultStateValue,
|
|
81
|
-
// 初始state
|
|
82
|
-
option) {
|
|
58
|
+
function useMergedState(defaultStateValue, option) {
|
|
83
59
|
var _ref = option || {},
|
|
84
60
|
defaultValue = _ref.defaultValue,
|
|
85
61
|
value = _ref.value,
|
|
@@ -119,12 +95,6 @@ option) {
|
|
|
119
95
|
}, [value]);
|
|
120
96
|
return [mergedValue, triggerChange];
|
|
121
97
|
}
|
|
122
|
-
/**
|
|
123
|
-
* @description 获取之前的值
|
|
124
|
-
*
|
|
125
|
-
* @export
|
|
126
|
-
* @param {P} value
|
|
127
|
-
*/
|
|
128
98
|
function usePrevious(value) {
|
|
129
99
|
var ref = (0, _react.useRef)(value);
|
|
130
100
|
(0, _react.useEffect)(function () {
|
|
@@ -200,8 +170,7 @@ function useResizeObserver(element, handler) {
|
|
|
200
170
|
return;
|
|
201
171
|
}
|
|
202
172
|
var contentRect = entries[0].contentRect;
|
|
203
|
-
var hide = contentRect.width === 0 && contentRect.height === 0;
|
|
204
|
-
// DOMRectReadOnly 对象不可读, 不可赋值
|
|
173
|
+
var hide = contentRect.width === 0 && contentRect.height === 0;
|
|
205
174
|
var rect = (0, _extends2.default)({
|
|
206
175
|
hide: hide
|
|
207
176
|
}, contentRect);
|
|
@@ -236,7 +205,6 @@ function useStateWithPromise(defaultVal) {
|
|
|
236
205
|
var _useState3 = (0, _react.useState)({
|
|
237
206
|
value: defaultVal,
|
|
238
207
|
resolve: function resolve(e) {
|
|
239
|
-
// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions
|
|
240
208
|
e;
|
|
241
209
|
}
|
|
242
210
|
}),
|
package/lib/_utils/index.js
CHANGED
|
@@ -7,13 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getCompProps = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
9
9
|
var _compDefaultProps = _interopRequireDefault(require("../config-provider/compDefaultProps"));
|
|
10
|
-
// kdesign提供组件默认属性
|
|
11
|
-
/**
|
|
12
|
-
* 结合compDefaultProps、用户自定义默认属性和组件当前属性获取组件实际应用属性
|
|
13
|
-
* @param {keyof typeof compDefaultProps} compName 组件名
|
|
14
|
-
* @param {any} userDefaultProps 用户自定义组件默认属性
|
|
15
|
-
* @param {any} compProps 组件接收到的属性
|
|
16
|
-
*/
|
|
17
10
|
var getCompProps = function getCompProps(compName, userDefaultProps, compProps) {
|
|
18
11
|
var defaultProps = _compDefaultProps.default[compName];
|
|
19
12
|
var userProps = userDefaultProps && userDefaultProps[compName] || {};
|
package/lib/_utils/numberUtil.js
CHANGED
|
@@ -14,48 +14,29 @@ var _isNan = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stab
|
|
|
14
14
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
15
15
|
var _fill = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/fill"));
|
|
16
16
|
var _big = _interopRequireDefault(require("big.js"));
|
|
17
|
-
/**
|
|
18
|
-
* 使用定点表示法来格式化一个数
|
|
19
|
-
* @param {String|Number} number [必选,数字或者表示数字的字符串,范围为[0,20],超过范围则报错]
|
|
20
|
-
* @param {Number} digits [必选,小数点后数字的个数]
|
|
21
|
-
* @param {Boolean} isRound [可选,格式化时是否四舍五入,默认为false,即进行四舍五入,为false时直接截取,不满足位数的往后补0]
|
|
22
|
-
* @return {String} [结果]
|
|
23
|
-
*/
|
|
24
17
|
function toFixed(number, digits) {
|
|
25
18
|
var isRound = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
26
|
-
// 非数字
|
|
27
|
-
// if (!/(^-\d+|^\d+)\.?\d*$/gi.test(number)) { // Number.isFinite(number)
|
|
28
|
-
// throw new Error('toFixed() number argument must be a valid number')
|
|
29
|
-
// }
|
|
30
19
|
if ((0, _isNan.default)(Number(number))) {
|
|
31
20
|
throw new Error('toFixed() number argument must be a valid number');
|
|
32
21
|
}
|
|
33
|
-
// 是否为正数
|
|
34
22
|
var isPositive = +number >= 0;
|
|
35
|
-
// 转化为字符串
|
|
36
23
|
number += '';
|
|
37
24
|
isRound = Boolean(isRound);
|
|
38
|
-
// 去掉正负号,统一按照正数来处理,最后再加上符号
|
|
39
25
|
number = number.replace(/^(?:-|\+)/gi, '');
|
|
40
|
-
// 小数点过大
|
|
41
26
|
if (digits > 20 || digits < 0) {
|
|
42
27
|
throw new RangeError('toFixed() digits argument must be between 0 and 20');
|
|
43
28
|
}
|
|
44
|
-
// 如果是简写如.11则整数位补0,变成0.11
|
|
45
29
|
if (/^\./gi.test(number)) {
|
|
46
30
|
number = '0' + number;
|
|
47
31
|
}
|
|
48
32
|
var numParts = number.split('.');
|
|
49
33
|
var result = '';
|
|
50
|
-
// 在str后面加n个0
|
|
51
34
|
var _paddingZero = function _paddingZero(str, n) {
|
|
52
35
|
for (var i = 0; i < n; i++) {
|
|
53
36
|
str += '0';
|
|
54
37
|
}
|
|
55
38
|
return str;
|
|
56
39
|
};
|
|
57
|
-
// 在str后面加0,直至str的长度达到n
|
|
58
|
-
// 如果超过了n,则直接截取前n个字符串
|
|
59
40
|
var _paddingZeroTo = function _paddingZeroTo(str, n) {
|
|
60
41
|
if (str.length >= n) {
|
|
61
42
|
return str.substr(0, n);
|
|
@@ -63,39 +44,24 @@ function toFixed(number, digits) {
|
|
|
63
44
|
return _paddingZero(str, n - str.length);
|
|
64
45
|
}
|
|
65
46
|
};
|
|
66
|
-
// 直接就是整数
|
|
67
47
|
if (numParts.length < 2) {
|
|
68
48
|
result = numParts[0] + '.' + _paddingZero('', digits);
|
|
69
49
|
} else {
|
|
70
|
-
// 为浮点数
|
|
71
|
-
// 如果为截取
|
|
72
50
|
if (isRound === false) {
|
|
73
51
|
result = numParts[0] + '.' + _paddingZeroTo(numParts[1], digits);
|
|
74
|
-
// 如果为四舍五入
|
|
75
52
|
} else {
|
|
76
|
-
// 放大10的N次方倍
|
|
77
53
|
var enlarge = numParts[0] + _paddingZeroTo(numParts[1], digits) + '.' + numParts[1].substr(digits);
|
|
78
|
-
// 取整
|
|
79
54
|
enlarge = Math.round(parseFloat(enlarge)) + '';
|
|
80
|
-
// 缩小10的N次方
|
|
81
55
|
while (enlarge.length <= digits) {
|
|
82
56
|
enlarge = '0' + enlarge;
|
|
83
57
|
}
|
|
84
58
|
result = enlarge.substr(0, enlarge.length - digits) + '.' + enlarge.substr(enlarge.length - digits);
|
|
85
59
|
}
|
|
86
60
|
}
|
|
87
|
-
// 如果最后一位为.,则去除
|
|
88
61
|
result = result.replace(/\.$/gi, '').replace(/^\./gi, '0.');
|
|
89
|
-
// 加上正负数符号位
|
|
90
62
|
result = isPositive ? result : '-' + result;
|
|
91
63
|
return result;
|
|
92
64
|
}
|
|
93
|
-
/**
|
|
94
|
-
* 将已有的数字进行前面补零的方法
|
|
95
|
-
* @param {String|Number} number [需要在前面补零的数字]
|
|
96
|
-
* @param {Number} lenght [补零后的数字长度]
|
|
97
|
-
* 如:supplementZero(1, 4) return '0001'
|
|
98
|
-
*/
|
|
99
65
|
function supplementZero(number) {
|
|
100
66
|
var _context;
|
|
101
67
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
@@ -103,29 +69,20 @@ function supplementZero(number) {
|
|
|
103
69
|
if (number.length > length) return number;
|
|
104
70
|
return (0, _slice.default)(_context = Array(length).join('0') + number).call(_context, -length);
|
|
105
71
|
}
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
108
|
-
* 序列化字符串为数字,只取字符串中的数字、小数点、正负号
|
|
109
|
-
* @param {String} strNumber 字符串
|
|
110
|
-
*/
|
|
111
72
|
function serialization(strNumber) {
|
|
112
73
|
var numberList = strNumber.match(/\d|^-|\./g);
|
|
113
74
|
if (!numberList) return '';
|
|
114
|
-
// 取出正负号
|
|
115
75
|
var sign = numberList[0] === '-' ? '-' : '';
|
|
116
76
|
if (sign === '-') {
|
|
117
|
-
// 有负号, 去掉数组的负号
|
|
118
77
|
numberList.shift();
|
|
119
78
|
}
|
|
120
79
|
var numberString = numberList.join('');
|
|
121
|
-
// .replace('.', 'a').replace(/\./g, '').replace('a', '.')
|
|
122
80
|
var res = numberString.replace(/^0{2,}/gi, '0');
|
|
123
81
|
if (/^(0[^.])/gi.test(res)) {
|
|
124
82
|
return sign + (0, _slice.default)(res).call(res, 1);
|
|
125
83
|
}
|
|
126
84
|
return sign + res;
|
|
127
85
|
}
|
|
128
|
-
// 根据整数精度和小数精度获取最大值
|
|
129
86
|
function getMaxNumberByPrecision(integerPrecision, decimalPrecision) {
|
|
130
87
|
var _context2, _context3;
|
|
131
88
|
var integerString = (0, _fill.default)(_context2 = Array(integerPrecision)).call(_context2, '9').reduce(function (res, value) {
|
|
@@ -135,19 +92,9 @@ function getMaxNumberByPrecision(integerPrecision, decimalPrecision) {
|
|
|
135
92
|
return res += value;
|
|
136
93
|
}, integerString + '.'));
|
|
137
94
|
}
|
|
138
|
-
/**
|
|
139
|
-
* 判断是否为正则表达式
|
|
140
|
-
* @param {string|number} number 待判断的值
|
|
141
|
-
*/
|
|
142
95
|
function isExp(number) {
|
|
143
96
|
return /\d+\.?\d*e[+-]*\d+/i.test(number.toString());
|
|
144
97
|
}
|
|
145
|
-
/**
|
|
146
|
-
* 将科学计数法显示的数字格式化为正常浮点数
|
|
147
|
-
* 1e-6 => 0.000006
|
|
148
|
-
* @param {Number} number 待格式化的科学计数法
|
|
149
|
-
* @returns num 格式化后的数值,如果不满足科学计数法的话,则原值返回
|
|
150
|
-
*/
|
|
151
98
|
function exponentToFloat(number) {
|
|
152
99
|
var tempNumber = Number(number);
|
|
153
100
|
if (isNaN(tempNumber) || !isFinite(tempNumber) || number === '') return tempNumber.toString();
|
|
@@ -155,7 +102,6 @@ function exponentToFloat(number) {
|
|
|
155
102
|
var bigNumValue = bigNum.valueOf();
|
|
156
103
|
var exponentReg = /^(?!-0(\.0+)?(e|$))-?(0|[1-9]\d*)(\.\d+)?(e-?(0|[1-9]\d*))?$/i;
|
|
157
104
|
if (exponentReg.test(bigNumValue)) {
|
|
158
|
-
// 获取精度, 默认 10
|
|
159
105
|
var lenArr = exponentReg.exec(bigNumValue);
|
|
160
106
|
var len = Number(lenArr && lenArr[6] ? lenArr[6] : 10);
|
|
161
107
|
var fixedNumber = bigNum.toFixed(len).valueOf();
|
package/lib/_utils/raf.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.raf = exports.caf = void 0;
|
|
7
7
|
var target = typeof window === 'undefined' ? global : window;
|
|
8
8
|
var vendors = ['webkit', 'ms', 'moz', 'o'];
|
|
9
|
-
var raf = target.requestAnimationFrame;
|
|
9
|
+
var raf = target.requestAnimationFrame;
|
|
10
10
|
exports.raf = raf;
|
|
11
|
-
var caf = target.cancelAnimationFrame;
|
|
11
|
+
var caf = target.cancelAnimationFrame;
|
|
12
12
|
exports.caf = caf;
|
|
13
13
|
if (!raf || !caf) {
|
|
14
14
|
vendors.some(function (prefix) {
|
package/lib/_utils/reactNode.js
CHANGED
|
@@ -17,7 +17,7 @@ var isValidElement = React.isValidElement;
|
|
|
17
17
|
exports.isValidElement = isValidElement;
|
|
18
18
|
function replaceElement(element, replacement, props) {
|
|
19
19
|
if (!isValidElement(element)) return replacement;
|
|
20
|
-
return
|
|
20
|
+
return React.cloneElement(element, typeof props === 'function' ? props(element.props || {}) : props);
|
|
21
21
|
}
|
|
22
22
|
function isFragment(child) {
|
|
23
23
|
return child && isValidElement(child) && child.type === React.Fragment;
|
|
@@ -17,7 +17,7 @@ var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-po
|
|
|
17
17
|
var _reactDom = require("react-dom");
|
|
18
18
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
19
19
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
var ResizeObserverComponent =
|
|
20
|
+
var ResizeObserverComponent = function (_React$Component) {
|
|
21
21
|
(0, _inherits2.default)(ResizeObserverComponent, _React$Component);
|
|
22
22
|
var _super = _createSuper(ResizeObserverComponent);
|
|
23
23
|
function ResizeObserverComponent() {
|
|
@@ -34,7 +34,6 @@ var ResizeObserverComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
34
34
|
var onResize = _this.props.onResize;
|
|
35
35
|
onResize && onResize(entry);
|
|
36
36
|
});
|
|
37
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
38
37
|
_this.resizeObserver.observe((0, _reactDom.findDOMNode)((0, _assertThisInitialized2.default)(_this)));
|
|
39
38
|
};
|
|
40
39
|
_this.destroyResizeObserver = function () {
|
|
@@ -46,7 +45,7 @@ var ResizeObserverComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
46
45
|
(0, _createClass2.default)(ResizeObserverComponent, [{
|
|
47
46
|
key: "componentDidMount",
|
|
48
47
|
value: function componentDidMount() {
|
|
49
|
-
if (!
|
|
48
|
+
if (!_react.default.isValidElement(this.props.children)) {
|
|
50
49
|
console.warn('The children of ResizeObserver is invalid.');
|
|
51
50
|
} else {
|
|
52
51
|
this.createResizeObserver();
|
|
@@ -55,7 +54,6 @@ var ResizeObserverComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
55
54
|
}, {
|
|
56
55
|
key: "componentDidUpdate",
|
|
57
56
|
value: function componentDidUpdate() {
|
|
58
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
59
57
|
if (!this.resizeObserver && (0, _reactDom.findDOMNode)(this)) {
|
|
60
58
|
this.createResizeObserver();
|
|
61
59
|
}
|
package/lib/_utils/type.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.tupleNum = exports.tuple = void 0;
|
|
7
|
-
// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead
|
|
8
7
|
var tuple = function tuple() {
|
|
9
8
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
9
|
args[_key] = arguments[_key];
|
package/lib/_utils/usePopper.js
CHANGED
|
@@ -634,11 +634,11 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
634
634
|
};
|
|
635
635
|
}
|
|
636
636
|
}, [getTriggerElement, hidePopper, locatorRef, mouseEnterDelay, mousePos, showPopper, trigger, visible]);
|
|
637
|
-
var Locator =
|
|
637
|
+
var Locator = (0, _react.cloneElement)(locatorElement, {
|
|
638
638
|
ref: locatorRef
|
|
639
639
|
});
|
|
640
|
-
var Popper =
|
|
641
|
-
return
|
|
640
|
+
var Popper = _react.default.createElement("div", (0, _extends2.default)({}, popperProps), popperElement);
|
|
641
|
+
return _react.default.createElement(_react.default.Fragment, null, Locator, exist && container && _reactDom.default.createPortal(Popper, container));
|
|
642
642
|
}
|
|
643
643
|
var _default = usePopper;
|
|
644
644
|
exports.default = _default;
|
package/lib/alert/alert.js
CHANGED
|
@@ -51,18 +51,10 @@ var setContainerStyle = function setContainerStyle(dom, posInfo) {
|
|
|
51
51
|
dom.style.setProperty(prop, styles[prop]);
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
|
-
/**
|
|
55
|
-
* @description 创建悬浮顶部的反馈浮层容器
|
|
56
|
-
* @param alertContainer 反馈浮层容器ref
|
|
57
|
-
* @param alertPrefixCls 反馈浮层前缀class
|
|
58
|
-
* @param bannerOffset 反馈浮层悬浮顶部的坐标量
|
|
59
|
-
*
|
|
60
|
-
*/
|
|
61
54
|
function createAlertContainer(alertContainer, alertPrefixCls, bannerOffset) {
|
|
62
55
|
var posKey = bannerOffset.join(',');
|
|
63
56
|
var container = document.createElement('div');
|
|
64
57
|
container.classList.add("".concat(alertPrefixCls, "-banner-container"));
|
|
65
|
-
// container.classList.add(`${alertPrefixCls}-banner-container-flex`)
|
|
66
58
|
setContainerStyle(container, bannerOffset);
|
|
67
59
|
alertContainer.current = container;
|
|
68
60
|
allBannerAlertPortalsContainer.appendChild(container);
|
|
@@ -74,7 +66,7 @@ var Alert = function Alert(props) {
|
|
|
74
66
|
getPrefixCls = _useContext.getPrefixCls,
|
|
75
67
|
prefixCls = _useContext.prefixCls,
|
|
76
68
|
userDefaultProps = _useContext.compDefaultProps;
|
|
77
|
-
var alertProps = (0, _utils.getCompProps)('Alert', userDefaultProps, props);
|
|
69
|
+
var alertProps = (0, _utils.getCompProps)('Alert', userDefaultProps, props);
|
|
78
70
|
var type = alertProps.type,
|
|
79
71
|
message = alertProps.message,
|
|
80
72
|
showIcon = alertProps.showIcon,
|
|
@@ -176,26 +168,26 @@ var Alert = function Alert(props) {
|
|
|
176
168
|
var _context2;
|
|
177
169
|
return (0, _concat.default)(_context2 = "alert-".concat(type, "-")).call(_context2, mode, "-color");
|
|
178
170
|
};
|
|
179
|
-
var iconNode =
|
|
171
|
+
var iconNode = _react.default.createElement("div", {
|
|
180
172
|
className: (0, _classnames.default)("".concat(alertPrefixCls, "-icon"), getAlertColorType('icon'))
|
|
181
|
-
}, icon ||
|
|
173
|
+
}, icon || _react.default.createElement(_index.Icon, {
|
|
182
174
|
type: alertIconType
|
|
183
175
|
}));
|
|
184
|
-
var AlertComp =
|
|
176
|
+
var AlertComp = _react.default.createElement("div", (0, _extends2.default)({
|
|
185
177
|
className: (0, _classnames.default)(alertClasses, getAlertColorType('bg'), getAlertColorType('border'))
|
|
186
178
|
}, events, {
|
|
187
179
|
ref: alertRef,
|
|
188
180
|
style: style
|
|
189
|
-
}, othersProps), showIcon && iconNode,
|
|
181
|
+
}, othersProps), showIcon && iconNode, _react.default.createElement("div", {
|
|
190
182
|
className: (0, _classnames.default)((_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, "".concat(alertPrefixCls, "-message"), true), (0, _defineProperty2.default)(_classNames2, "".concat(alertPrefixCls, "-without-icon-message"), !showIcon), _classNames2))
|
|
191
|
-
}, message), extra, closable && type !== 'success' &&
|
|
183
|
+
}, message), extra, closable && type !== 'success' && _react.default.createElement("div", {
|
|
192
184
|
className: "".concat(alertPrefixCls, "-close-icon"),
|
|
193
185
|
onClick: handleClose
|
|
194
|
-
}, closeNode ||
|
|
186
|
+
}, closeNode || _react.default.createElement(_index.Icon, {
|
|
195
187
|
type: "close"
|
|
196
188
|
})));
|
|
197
189
|
if (banner) {
|
|
198
|
-
return
|
|
190
|
+
return _reactDom.default.createPortal(AlertComp, alertContainer.current);
|
|
199
191
|
} else {
|
|
200
192
|
return AlertComp;
|
|
201
193
|
}
|
|
@@ -26,7 +26,7 @@ var AnchorLink = function AnchorLink(props) {
|
|
|
26
26
|
var _useContext = (0, _react.useContext)(_ConfigContext.default),
|
|
27
27
|
getPrefixCls = _useContext.getPrefixCls,
|
|
28
28
|
prefixCls = _useContext.prefixCls;
|
|
29
|
-
var anchorLinkPrefixCls = getPrefixCls(prefixCls, 'anchor', customPrefixcls);
|
|
29
|
+
var anchorLinkPrefixCls = getPrefixCls(prefixCls, 'anchor', customPrefixcls);
|
|
30
30
|
var _useContext2 = (0, _react.useContext)(_context.default),
|
|
31
31
|
activeLink = _useContext2.activeLink,
|
|
32
32
|
scrollTo = _useContext2.scrollTo,
|
|
@@ -57,9 +57,9 @@ var AnchorLink = function AnchorLink(props) {
|
|
|
57
57
|
var active = activeLink === href;
|
|
58
58
|
var anchorLinkClasses = (0, _classnames.default)("".concat(anchorLinkPrefixCls, "-link"), (0, _defineProperty2.default)({}, "".concat(anchorLinkPrefixCls, "-link-active"), active), className);
|
|
59
59
|
var titleClassName = (0, _classnames.default)("".concat(anchorLinkPrefixCls, "-link-title"), (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, "".concat(anchorLinkPrefixCls, "-link-title-active"), active), (0, _defineProperty2.default)(_classNames2, "".concat(anchorLinkPrefixCls, "-link-title-secondary"), !isFirstLevel && type === 'bookmarks'), _classNames2));
|
|
60
|
-
return
|
|
60
|
+
return _react.default.createElement("div", {
|
|
61
61
|
className: anchorLinkClasses
|
|
62
|
-
},
|
|
62
|
+
}, _react.default.createElement("span", {
|
|
63
63
|
title: typeof title === 'string' ? title : '',
|
|
64
64
|
className: titleClassName,
|
|
65
65
|
onClick: handleClick
|