@kdcloudjs/kdesign 1.8.12 → 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 +5 -3
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +1 -1
- package/dist/kdesign.min.js +2 -2
- 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 +34 -103
- 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 +2 -0
- package/es/popper/index.js +9 -15
- 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 +34 -103
- 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 +2 -0
- package/lib/popper/index.js +9 -15
- 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/checkbox/group.js
CHANGED
|
@@ -36,14 +36,14 @@ var CheckboxTypes = (0, _type.tuple)('default', 'square');
|
|
|
36
36
|
exports.CheckboxTypes = CheckboxTypes;
|
|
37
37
|
var CheckboxSizes = (0, _type.tuple)('large', 'middle', 'small');
|
|
38
38
|
exports.CheckboxSizes = CheckboxSizes;
|
|
39
|
-
var GroupContext =
|
|
39
|
+
var GroupContext = _react.default.createContext(null);
|
|
40
40
|
exports.GroupContext = GroupContext;
|
|
41
|
-
var CheckboxGroup =
|
|
41
|
+
var CheckboxGroup = _react.default.forwardRef(function (props, ref) {
|
|
42
42
|
var _useContext = (0, _react.useContext)(_ConfigContext.default),
|
|
43
43
|
getPrefixCls = _useContext.getPrefixCls,
|
|
44
44
|
prefixCls = _useContext.prefixCls,
|
|
45
45
|
userDefaultProps = _useContext.compDefaultProps;
|
|
46
|
-
var CheckboxProps = (0, _utils.getCompProps)('CheckboxGroup', userDefaultProps, props);
|
|
46
|
+
var CheckboxProps = (0, _utils.getCompProps)('CheckboxGroup', userDefaultProps, props);
|
|
47
47
|
var checkboxType = CheckboxProps.checkboxType,
|
|
48
48
|
className = CheckboxProps.className,
|
|
49
49
|
style = CheckboxProps.style,
|
|
@@ -68,7 +68,7 @@ var CheckboxGroup = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
|
|
|
68
68
|
setGroupValue(innerValue.current);
|
|
69
69
|
}, [value, defaultValue]);
|
|
70
70
|
var isControlled = typeof value !== 'undefined';
|
|
71
|
-
var checkboxGroupPrefixCls = getPrefixCls(prefixCls, 'checkbox-group', customPrefixcls);
|
|
71
|
+
var checkboxGroupPrefixCls = getPrefixCls(prefixCls, 'checkbox-group', customPrefixcls);
|
|
72
72
|
(0, _devwarning.default)((0, _arrayUtil.isArrayValueRepeat)(groupValue), 'checkboxGroup', "variable value's value should be unique ");
|
|
73
73
|
var getReduceItem = function getReduceItem(targetValue) {
|
|
74
74
|
var _context;
|
|
@@ -105,7 +105,7 @@ var CheckboxGroup = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
|
|
|
105
105
|
};
|
|
106
106
|
var renderByOptions = function renderByOptions() {
|
|
107
107
|
return (0, _map.default)(options).call(options, function (option, index) {
|
|
108
|
-
return
|
|
108
|
+
return _react.default.createElement(_checkbox.default, {
|
|
109
109
|
size: size,
|
|
110
110
|
disabled: option.disabled,
|
|
111
111
|
key: index,
|
|
@@ -118,14 +118,14 @@ var CheckboxGroup = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
|
|
|
118
118
|
}, option.label || option);
|
|
119
119
|
});
|
|
120
120
|
};
|
|
121
|
-
return
|
|
121
|
+
return _react.default.createElement("ul", (0, _extends2.default)({
|
|
122
122
|
className: (0, _classnames.default)(checkboxGroupPrefixCls, className),
|
|
123
123
|
style: style,
|
|
124
124
|
ref: ref
|
|
125
|
-
}, rest),
|
|
125
|
+
}, rest), _react.default.createElement(GroupContext.Provider, {
|
|
126
126
|
value: context
|
|
127
127
|
}, options && options.length > 0 ? renderByOptions() : children));
|
|
128
128
|
});
|
|
129
129
|
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
130
|
-
var _default =
|
|
130
|
+
var _default = _react.default.memo(CheckboxGroup);
|
|
131
131
|
exports.default = _default;
|
|
@@ -100,7 +100,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
100
100
|
}];
|
|
101
101
|
var innerRef = (0, _react.useRef)();
|
|
102
102
|
var selectRef = ref || innerRef;
|
|
103
|
-
var searchRef = (0, _react.useRef)(null);
|
|
103
|
+
var searchRef = (0, _react.useRef)(null);
|
|
104
104
|
var selectionRef = (0, _react.useRef)(null);
|
|
105
105
|
var clearRef = (0, _react.useRef)(null);
|
|
106
106
|
var optionsListRef = (0, _react.useRef)(null);
|
|
@@ -134,7 +134,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
134
134
|
var selectPrefixCls = getPrefixCls(prefixCls, 'city-picker', customPrefixcls);
|
|
135
135
|
var cityPickerCls = (0, _classnames.default)(selectPrefixCls, className, (0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-visible"), optionShow));
|
|
136
136
|
var selectionCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-selector"), true));
|
|
137
|
-
// 公共样式
|
|
138
137
|
var commCls = (0, _classnames.default)((_classNames3 = {}, (0, _defineProperty2.default)(_classNames3, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), (0, _defineProperty2.default)(_classNames3, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames3, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames3, (0, _concat.default)(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames3, "".concat(selectPrefixCls, "-wrapper"), true), (0, _defineProperty2.default)(_classNames3, "".concat(selectPrefixCls, "-show-search"), focusd), _classNames3));
|
|
139
138
|
(0, _react.useEffect)(function () {
|
|
140
139
|
var _context2;
|
|
@@ -174,21 +173,18 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
174
173
|
}
|
|
175
174
|
});
|
|
176
175
|
}, []);
|
|
177
|
-
// 输入框变化搜索内容
|
|
178
176
|
var handleSearchChange = (0, _react.useCallback)(function (event) {
|
|
179
177
|
var val = event.currentTarget.value;
|
|
180
178
|
setOptionShow(true);
|
|
181
179
|
setSearchValue(val);
|
|
182
180
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch(val);
|
|
183
181
|
}, [onSearch]);
|
|
184
|
-
// 清除搜索内容
|
|
185
182
|
var handleClear = (0, _react.useCallback)(function () {
|
|
186
183
|
if (searchRef.current) {
|
|
187
184
|
searchRef.current.value = '';
|
|
188
185
|
setSearchValue('');
|
|
189
186
|
}
|
|
190
187
|
}, [searchRef]);
|
|
191
|
-
// 清空选择器内容
|
|
192
188
|
var handleReset = function handleReset(e) {
|
|
193
189
|
e.stopPropagation();
|
|
194
190
|
onClear && onClear('');
|
|
@@ -197,33 +193,31 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
197
193
|
setSearchValue('');
|
|
198
194
|
onChange && onChange(undefined, '');
|
|
199
195
|
};
|
|
200
|
-
// 渲染后缀图标
|
|
201
196
|
var renderSuffix = function renderSuffix() {
|
|
202
197
|
var _classNames4;
|
|
203
198
|
if (disabled) return null;
|
|
204
199
|
var suffixIcon = selectProps.suffixIcon;
|
|
205
200
|
var arrowIconCls = (0, _classnames.default)((_classNames4 = {}, (0, _defineProperty2.default)(_classNames4, "".concat(selectPrefixCls, "-icon-arrow"), true), (0, _defineProperty2.default)(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-up"), optionShow), (0, _defineProperty2.default)(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-down"), !optionShow), (0, _defineProperty2.default)(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-focus"), optionShow), _classNames4));
|
|
206
201
|
var iconShow = allowClear && !disabled && (initValue !== null && initValue !== void 0 ? initValue : '') !== '';
|
|
207
|
-
return
|
|
202
|
+
return _react.default.createElement(_react.default.Fragment, null, iconShow && _react.default.createElement("span", {
|
|
208
203
|
onClick: handleReset,
|
|
209
204
|
onMouseDown: function onMouseDown(e) {
|
|
210
205
|
return e.preventDefault();
|
|
211
206
|
},
|
|
212
207
|
className: "".concat(selectPrefixCls, "-icon-clear"),
|
|
213
208
|
ref: clearRef
|
|
214
|
-
}, clearIcon ||
|
|
209
|
+
}, clearIcon || _react.default.createElement(_index.Icon, {
|
|
215
210
|
type: "close"
|
|
216
|
-
})), showArrow &&
|
|
211
|
+
})), showArrow && _react.default.createElement("span", {
|
|
217
212
|
className: arrowIconCls
|
|
218
|
-
}, suffixIcon ||
|
|
213
|
+
}, suffixIcon || _react.default.createElement(_index.Icon, {
|
|
219
214
|
type: "arrow-down"
|
|
220
215
|
})));
|
|
221
216
|
};
|
|
222
|
-
// 下拉列表为空时显示的内容
|
|
223
217
|
var renderNotContent = function renderNotContent(msg) {
|
|
224
218
|
var notFoundContent = selectProps.notFoundContent;
|
|
225
219
|
var emptyContent = notFoundContent || msg;
|
|
226
|
-
return
|
|
220
|
+
return _react.default.createElement("div", {
|
|
227
221
|
className: "".concat(selectPrefixCls, "-dropdown-empty")
|
|
228
222
|
}, emptyContent);
|
|
229
223
|
};
|
|
@@ -233,11 +227,11 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
233
227
|
return "(".concat((0, _escapeRegExp.default)(item), ")");
|
|
234
228
|
}).join('|') : "(".concat((0, _escapeRegExp.default)(inputValue), ")"), 'i');
|
|
235
229
|
var strArr = text === null || text === void 0 ? void 0 : text.split(regex);
|
|
236
|
-
return
|
|
237
|
-
return (regex === null || regex === void 0 ? void 0 : regex.test(item)) ?
|
|
230
|
+
return _react.default.createElement(_react.default.Fragment, null, strArr === null || strArr === void 0 ? void 0 : (0, _map.default)(strArr).call(strArr, function (item, index) {
|
|
231
|
+
return (regex === null || regex === void 0 ? void 0 : regex.test(item)) ? _react.default.createElement("span", {
|
|
238
232
|
key: index,
|
|
239
233
|
className: "".concat(selectPrefixCls, "-highlight")
|
|
240
|
-
}, item) :
|
|
234
|
+
}, item) : _react.default.createElement("span", {
|
|
241
235
|
key: index
|
|
242
236
|
}, item);
|
|
243
237
|
}));
|
|
@@ -261,14 +255,14 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
261
255
|
if (!data.length) {
|
|
262
256
|
return renderNotContent(notContent);
|
|
263
257
|
}
|
|
264
|
-
return
|
|
258
|
+
return _react.default.createElement("div", {
|
|
265
259
|
className: "".concat(selectPrefixCls, "-list"),
|
|
266
260
|
ref: optionsListRef,
|
|
267
261
|
onMouseDown: function onMouseDown(e) {
|
|
268
262
|
return e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
269
263
|
}
|
|
270
264
|
}, (0, _map.default)(data).call(data, function (item, index) {
|
|
271
|
-
return
|
|
265
|
+
return _react.default.createElement(_option.default, {
|
|
272
266
|
key: item.id,
|
|
273
267
|
value: initValue,
|
|
274
268
|
city: item,
|
|
@@ -287,9 +281,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
287
281
|
}));
|
|
288
282
|
};
|
|
289
283
|
var renderLoading = function renderLoading() {
|
|
290
|
-
return
|
|
284
|
+
return _react.default.createElement("div", {
|
|
291
285
|
className: "".concat(selectPrefixCls, "-dropdown-loading")
|
|
292
|
-
},
|
|
286
|
+
}, _react.default.createElement(_index.Spin, {
|
|
293
287
|
type: "container"
|
|
294
288
|
}));
|
|
295
289
|
};
|
|
@@ -297,18 +291,17 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
297
291
|
setTabsValue(type);
|
|
298
292
|
onTabPaneChange === null || onTabPaneChange === void 0 ? void 0 : onTabPaneChange(type);
|
|
299
293
|
};
|
|
300
|
-
// 渲染下拉列表框
|
|
301
294
|
var renderContent = function renderContent() {
|
|
302
|
-
return loading ? renderLoading() :
|
|
295
|
+
return loading ? renderLoading() : _react.default.createElement(_react.default.Fragment, null, searchValue ? _react.default.createElement(_react.default.Fragment, null, isDomestic(type) && _react.default.createElement(_index.Tabs, {
|
|
303
296
|
noContainer: true,
|
|
304
297
|
onChange: toggleTabPane,
|
|
305
298
|
activeKey: tabsValue
|
|
306
299
|
}, (0, _map.default)(tabsData).call(tabsData, function (item) {
|
|
307
|
-
return
|
|
300
|
+
return _react.default.createElement(_index.Tabs.TabPane, {
|
|
308
301
|
key: item.id,
|
|
309
302
|
tab: item.name
|
|
310
303
|
}, item);
|
|
311
|
-
})), tabsValue === 'domestic' ? renderNodeList(domesticList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText) : renderNodeList(foreignList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText)) :
|
|
304
|
+
})), tabsValue === 'domestic' ? renderNodeList(domesticList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText) : renderNodeList(foreignList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText)) : _react.default.createElement(_react.default.Fragment, null, !!commonList.length && _react.default.createElement("div", {
|
|
312
305
|
className: "".concat(selectPrefixCls, "-dropdown-common")
|
|
313
306
|
}, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.common), renderNodeList(commonList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.commonEmptyText, true)));
|
|
314
307
|
};
|
|
@@ -342,14 +335,14 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
342
335
|
visibility: 'hidden'
|
|
343
336
|
} : undefined;
|
|
344
337
|
var itemCls = (0, _classnames.default)((_classNames5 = {}, (0, _defineProperty2.default)(_classNames5, "".concat(selectPrefixCls, "-content-item"), true), (0, _defineProperty2.default)(_classNames5, "".concat(selectPrefixCls, "-content-item-seleted"), afterChangeFocus), _classNames5));
|
|
345
|
-
return
|
|
338
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("div", {
|
|
346
339
|
className: singleCls,
|
|
347
340
|
ref: selectionRef
|
|
348
|
-
},
|
|
341
|
+
}, _react.default.createElement("div", {
|
|
349
342
|
className: "".concat(selectPrefixCls, "-content")
|
|
350
|
-
},
|
|
343
|
+
}, _react.default.createElement("span", {
|
|
351
344
|
className: "".concat(selectPrefixCls, "-content-search")
|
|
352
|
-
},
|
|
345
|
+
}, _react.default.createElement("input", {
|
|
353
346
|
ref: searchRef,
|
|
354
347
|
value: searchValue,
|
|
355
348
|
className: "".concat(selectPrefixCls, "-content-search-input"),
|
|
@@ -357,15 +350,15 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
357
350
|
onFocus: handleFocus,
|
|
358
351
|
onBlur: handleBlur,
|
|
359
352
|
readOnly: !!disabled
|
|
360
|
-
}), !searchValue &&
|
|
353
|
+
}), !searchValue && _react.default.createElement("span", {
|
|
361
354
|
className: itemCls,
|
|
362
355
|
title: seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name
|
|
363
|
-
}, seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name)), !searchValue &&
|
|
356
|
+
}, seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name)), !searchValue && _react.default.createElement("span", {
|
|
364
357
|
className: "".concat(selectPrefixCls, "-content-info")
|
|
365
|
-
}, _renderCityInfo(seletedCity))),
|
|
358
|
+
}, _renderCityInfo(seletedCity))), _react.default.createElement("span", {
|
|
366
359
|
className: "".concat(selectPrefixCls, "-placeholder"),
|
|
367
360
|
style: hiddenStyle
|
|
368
|
-
}, !disabled ? placeholder : null),
|
|
361
|
+
}, !disabled ? placeholder : null), _react.default.createElement("span", {
|
|
369
362
|
className: "".concat(selectPrefixCls, "-suffix")
|
|
370
363
|
}, renderSuffix())));
|
|
371
364
|
};
|
|
@@ -387,7 +380,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
387
380
|
(_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', fn);
|
|
388
381
|
};
|
|
389
382
|
}, [initValue]);
|
|
390
|
-
// keyboard
|
|
391
383
|
var curkeyboardList = (0, _react.useMemo)(function () {
|
|
392
384
|
if (!searchValue) {
|
|
393
385
|
return commonList;
|
|
@@ -420,12 +412,10 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
420
412
|
var onInternalKeyDown = function onInternalKeyDown(e) {
|
|
421
413
|
var _a, _b, _c;
|
|
422
414
|
var which = e.which;
|
|
423
|
-
// open
|
|
424
415
|
if (which === _KeyCode.default.ENTER || which === _KeyCode.default.UP || which === _KeyCode.default.DOWN) {
|
|
425
416
|
e.preventDefault();
|
|
426
417
|
setOptionShow(true);
|
|
427
418
|
}
|
|
428
|
-
// up、down、enter、esc
|
|
429
419
|
if (optionShow) {
|
|
430
420
|
var offset = 0;
|
|
431
421
|
switch (which) {
|
|
@@ -464,13 +454,13 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
464
454
|
}
|
|
465
455
|
};
|
|
466
456
|
var renderCityPicker = function renderCityPicker() {
|
|
467
|
-
return
|
|
457
|
+
return _react.default.createElement("div", {
|
|
468
458
|
className: cityPickerCls,
|
|
469
459
|
ref: selectRef,
|
|
470
460
|
style: style
|
|
471
|
-
}, showDescription &&
|
|
461
|
+
}, showDescription && _react.default.createElement("span", {
|
|
472
462
|
className: "".concat(selectPrefixCls, "-description")
|
|
473
|
-
}, description),
|
|
463
|
+
}, description), _react.default.createElement("span", {
|
|
474
464
|
className: selectionCls,
|
|
475
465
|
tabIndex: disabled ? -1 : 0,
|
|
476
466
|
onFocus: function onFocus() {
|
|
@@ -519,7 +509,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
519
509
|
});
|
|
520
510
|
return (0, _usePopper.default)(renderCityPicker(), renderContent(), popperProps);
|
|
521
511
|
};
|
|
522
|
-
var Select =
|
|
512
|
+
var Select = _react.default.forwardRef(InternalSelect);
|
|
523
513
|
Select.displayName = 'CityPicker';
|
|
524
514
|
var _default = Select;
|
|
525
515
|
exports.default = _default;
|
|
@@ -7,5 +7,5 @@ exports.Sizes = exports.BorderTypes = void 0;
|
|
|
7
7
|
var _type = require("../_utils/type");
|
|
8
8
|
var BorderTypes = (0, _type.tuple)('none', 'underline', 'bordered');
|
|
9
9
|
exports.BorderTypes = BorderTypes;
|
|
10
|
-
var Sizes = (0, _type.tuple)('large', 'middle', 'small');
|
|
10
|
+
var Sizes = (0, _type.tuple)('large', 'middle', 'small');
|
|
11
11
|
exports.Sizes = Sizes;
|
|
@@ -48,20 +48,20 @@ var InternalOption = function InternalOption(props, ref) {
|
|
|
48
48
|
var handleOnMouseLeave = function handleOnMouseLeave() {
|
|
49
49
|
onChangeActiveIndex && onChangeActiveIndex(-1);
|
|
50
50
|
};
|
|
51
|
-
return
|
|
51
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("div", {
|
|
52
52
|
ref: optionRef,
|
|
53
53
|
className: optionCls,
|
|
54
54
|
title: name,
|
|
55
55
|
onClick: handleClick,
|
|
56
56
|
onMouseEnter: handleOnMouseEnter,
|
|
57
57
|
onMouseLeave: handleOnMouseLeave
|
|
58
|
-
}, typeof itemRender === 'function' ? itemRender(city) :
|
|
58
|
+
}, typeof itemRender === 'function' ? itemRender(city) : _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("span", {
|
|
59
59
|
className: "".concat(selectOptionPrefixCls, "-content")
|
|
60
|
-
}, children),
|
|
60
|
+
}, children), _react.default.createElement("span", {
|
|
61
61
|
className: "".concat(selectOptionPrefixCls, "-info")
|
|
62
62
|
}, renderCityInfo === null || renderCityInfo === void 0 ? void 0 : renderCityInfo(city, true)))));
|
|
63
63
|
};
|
|
64
|
-
var Option =
|
|
64
|
+
var Option = _react.default.forwardRef(InternalOption);
|
|
65
65
|
Option.displayName = 'CityPickerOption';
|
|
66
66
|
var _default = Option;
|
|
67
67
|
exports.default = _default;
|
|
@@ -40,7 +40,6 @@ var InternalClipboard = function InternalClipboard(props, ref) {
|
|
|
40
40
|
getPrefixCls = _useContext.getPrefixCls,
|
|
41
41
|
prefixCls = _useContext.prefixCls,
|
|
42
42
|
userDefaultProps = _useContext.compDefaultProps;
|
|
43
|
-
// 剪贴板参数,合并了系统默认参数、用户定义组件统一参数及组件传参
|
|
44
43
|
var clipboardProps = (0, _utils.getCompProps)('Clipboard', userDefaultProps, props);
|
|
45
44
|
var className = clipboardProps.className,
|
|
46
45
|
customPrefixcls = clipboardProps.prefixCls,
|
|
@@ -56,66 +55,49 @@ var InternalClipboard = function InternalClipboard(props, ref) {
|
|
|
56
55
|
others = __rest(clipboardProps, ["className", "prefixCls", "action", "content", "children", "disabled", "icon", "size", "target", "onError", "onSuccess"]);
|
|
57
56
|
(0, _devwarning.default)(ClipboardActions.indexOf(action) === -1, 'clipboard', "cannot found clipboard action '".concat(action, "'"));
|
|
58
57
|
(0, _devwarning.default)(ClipboardSizes.indexOf(size) === -1, 'clipboard', "cannot found clipboard size '".concat(size, "'"));
|
|
59
|
-
// 剪贴板样式前缀
|
|
60
58
|
var clipboardPrefixCls = getPrefixCls(prefixCls, 'clipboard', customPrefixcls);
|
|
61
59
|
var clipboardClass = (0, _classnames.default)(clipboardPrefixCls, className, (_classNames = {}, (0, _defineProperty2.default)(_classNames, (0, _concat.default)(_context = "".concat(clipboardPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames, "".concat(clipboardPrefixCls, "-icon-only"), !children && children !== 0 && icon !== null), _classNames));
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
// 如果没有传 icon,则使用默认图标
|
|
65
|
-
// 如果 icon 传 null,则不使用图标
|
|
66
|
-
var iconNode = icon || (icon === undefined ? /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
60
|
+
var clipboardRef = ref || _react.default.createRef();
|
|
61
|
+
var iconNode = icon || (icon === undefined ? _react.default.createElement(_icon.default, {
|
|
67
62
|
type: "copy-code"
|
|
68
63
|
}) : null);
|
|
69
|
-
|
|
70
|
-
var childrenNode = typeof children === 'string' ? /*#__PURE__*/_react.default.createElement("span", null, children) : children;
|
|
71
|
-
/**
|
|
72
|
-
* 剪贴板 click 事件处理
|
|
73
|
-
*/
|
|
64
|
+
var childrenNode = typeof children === 'string' ? _react.default.createElement("span", null, children) : children;
|
|
74
65
|
var handleClick = (0, _react.useCallback)(function () {
|
|
75
66
|
if (disabled) {
|
|
76
|
-
// 禁用状态不触发点击事件
|
|
77
67
|
return;
|
|
78
68
|
}
|
|
79
69
|
var selectedText;
|
|
80
70
|
try {
|
|
81
71
|
if (content) {
|
|
82
|
-
// 如果传了 content,则直接复制 content
|
|
83
72
|
selectedText = (0, _util.onClipboardCopy)(content);
|
|
84
73
|
} else {
|
|
85
74
|
var targetElement = typeof target === 'string' ? document.querySelector(target) : target();
|
|
86
75
|
if (!targetElement) {
|
|
87
|
-
// 没有获取到元素,抛出异常
|
|
88
76
|
throw new Error("target element '".concat(target, "' does not exist"));
|
|
89
77
|
} else {
|
|
90
78
|
if (action === 'copy' && targetElement.hasAttribute('disabled')) {
|
|
91
|
-
// 复制被置为 disabled 的元素,抛出异常
|
|
92
79
|
throw new Error("invalid \"target\" attribute of element '".concat(targetElement, "'. Please use \"readonly\" instead of \"disabled\" attribute"));
|
|
93
80
|
}
|
|
94
81
|
if (action === 'cut' && (targetElement.hasAttribute('readonly') || targetElement.hasAttribute('disabled'))) {
|
|
95
|
-
// 剪切被置为 readonly 或 disabled 的元素,抛出异常
|
|
96
82
|
throw new Error("invalid \"target\" attribute of element '".concat(targetElement, "'. You can't cut text from elements with \"readonly\" or \"disabled\" attributes"));
|
|
97
83
|
}
|
|
98
84
|
}
|
|
99
|
-
// 对 targetElement 的值进行复制或剪切
|
|
100
85
|
selectedText = action === 'copy' ? (0, _util.onClipboardCopy)(targetElement) : (0, _util.onClipboardCut)(targetElement);
|
|
101
86
|
}
|
|
102
87
|
} catch (error) {
|
|
103
|
-
// 触发失败的回调
|
|
104
88
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
105
|
-
// 退出处理器
|
|
106
89
|
return;
|
|
107
90
|
}
|
|
108
|
-
// 触发成功的回调
|
|
109
91
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(selectedText);
|
|
110
92
|
}, [action, content, disabled, onError, onSuccess, target]);
|
|
111
|
-
return
|
|
93
|
+
return _react.default.createElement("div", (0, _extends2.default)({
|
|
112
94
|
className: clipboardClass,
|
|
113
95
|
disabled: disabled,
|
|
114
96
|
onClick: handleClick,
|
|
115
97
|
ref: clipboardRef
|
|
116
98
|
}, others), iconNode, childrenNode);
|
|
117
99
|
};
|
|
118
|
-
var Clipboard =
|
|
100
|
+
var Clipboard = _react.default.forwardRef(InternalClipboard);
|
|
119
101
|
Clipboard.displayName = 'Clipboard';
|
|
120
102
|
var _default = Clipboard;
|
|
121
103
|
exports.default = _default;
|
package/lib/clipboard/util.js
CHANGED
|
@@ -4,11 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.onClipboardCut = exports.onClipboardCopy = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* 获取元素的内容
|
|
9
|
-
* @param {HTMLElement} element
|
|
10
|
-
* @return {string}
|
|
11
|
-
*/
|
|
12
7
|
var getContent = function getContent(element) {
|
|
13
8
|
var content;
|
|
14
9
|
if (element.nodeName === 'SELECT') {
|
|
@@ -18,28 +13,16 @@ var getContent = function getContent(element) {
|
|
|
18
13
|
} else if (element.nodeName === 'TEXTAREA') {
|
|
19
14
|
content = element.value;
|
|
20
15
|
} else {
|
|
21
|
-
// 其他类型通过 select 与 range 来获取文本
|
|
22
|
-
// 获取 select
|
|
23
16
|
var selection = window.getSelection();
|
|
24
|
-
// 创建 range
|
|
25
17
|
var range = document.createRange();
|
|
26
|
-
// 设置 range 的元素
|
|
27
18
|
range.selectNodeContents(element);
|
|
28
|
-
// 重置 select
|
|
29
19
|
selection.removeAllRanges();
|
|
30
|
-
// 设置 select 的 range
|
|
31
20
|
selection.addRange(range);
|
|
32
|
-
// 获取选中的文本
|
|
33
21
|
content = selection.toString();
|
|
34
|
-
// 获取到文本后清空选中范围
|
|
35
22
|
selection.removeAllRanges();
|
|
36
23
|
}
|
|
37
24
|
return content;
|
|
38
25
|
};
|
|
39
|
-
/**
|
|
40
|
-
* 清空元素的内容
|
|
41
|
-
* @param {HTMLElement} element
|
|
42
|
-
*/
|
|
43
26
|
var clearElement = function clearElement(element) {
|
|
44
27
|
if (element.nodeName === 'SELECT') {
|
|
45
28
|
;
|
|
@@ -54,46 +37,26 @@ var clearElement = function clearElement(element) {
|
|
|
54
37
|
element.innerHTML = '';
|
|
55
38
|
}
|
|
56
39
|
};
|
|
57
|
-
/**
|
|
58
|
-
* 由将被复制的文本为 value 创建一个 HTMLTextAreaElement 容器
|
|
59
|
-
* @param {String} value
|
|
60
|
-
* @return {HTMLTextAreaElement}
|
|
61
|
-
*/
|
|
62
40
|
var createContainer = function createContainer(value) {
|
|
63
41
|
var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
|
|
64
42
|
var container = document.createElement('textarea');
|
|
65
|
-
// 防止在 ios 上缩放
|
|
66
43
|
container.style.fontSize = '12pt';
|
|
67
|
-
// 重置样式
|
|
68
44
|
container.style.border = '0';
|
|
69
45
|
container.style.padding = '0';
|
|
70
46
|
container.style.margin = '0';
|
|
71
|
-
// 把元素定位在视窗外
|
|
72
47
|
container.style.position = 'absolute';
|
|
73
48
|
container.style[isRTL ? 'right' : 'left'] = '-9999px';
|
|
74
49
|
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
75
50
|
container.style.top = "".concat(yPosition, "px");
|
|
76
|
-
// 设置为只读
|
|
77
51
|
container.setAttribute('readonly', '');
|
|
78
|
-
// 将文本赋值给元素
|
|
79
52
|
container.value = value;
|
|
80
53
|
document.body.appendChild(container);
|
|
81
54
|
return container;
|
|
82
55
|
};
|
|
83
|
-
/**
|
|
84
|
-
* 删除元素
|
|
85
|
-
* @param {HTMLElement} container
|
|
86
|
-
*/
|
|
87
56
|
var removeContainer = function removeContainer(container) {
|
|
88
57
|
document.body.removeChild(container);
|
|
89
58
|
};
|
|
90
|
-
/**
|
|
91
|
-
* 添加选中状态
|
|
92
|
-
* @param {HTMLElement} element
|
|
93
|
-
*/
|
|
94
59
|
var addSelection = function addSelection(element) {
|
|
95
|
-
// 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
|
|
96
|
-
// 使用 select 对 <textarea> 及 <input> 单独处理
|
|
97
60
|
if (element.nodeName === 'INPUT') {
|
|
98
61
|
;
|
|
99
62
|
element.select();
|
|
@@ -108,14 +71,8 @@ var addSelection = function addSelection(element) {
|
|
|
108
71
|
selection.addRange(range);
|
|
109
72
|
}
|
|
110
73
|
};
|
|
111
|
-
/**
|
|
112
|
-
* 移除选中状态
|
|
113
|
-
* @param {HTMLElement} element
|
|
114
|
-
*/
|
|
115
74
|
var removeSelection = function removeSelection(element) {
|
|
116
75
|
var _a;
|
|
117
|
-
// 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
|
|
118
|
-
// 使用 setSelectRange 对 <textarea> 及 <input> 单独处理
|
|
119
76
|
if (element.nodeName === 'INPUT') {
|
|
120
77
|
;
|
|
121
78
|
element.setSelectionRange(0, 0);
|
|
@@ -126,18 +83,11 @@ var removeSelection = function removeSelection(element) {
|
|
|
126
83
|
(_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
127
84
|
}
|
|
128
85
|
};
|
|
129
|
-
/**
|
|
130
|
-
* 剪贴板复制操作
|
|
131
|
-
* @param {string | HTMLElement} target
|
|
132
|
-
* @return {string}
|
|
133
|
-
*/
|
|
134
86
|
var onClipboardCopy = function onClipboardCopy(target) {
|
|
135
87
|
var copiedValue;
|
|
136
88
|
if (typeof target === 'string') {
|
|
137
|
-
// 如果传的是字符串,直接复制值
|
|
138
89
|
copiedValue = target;
|
|
139
90
|
if (navigator.clipboard) {
|
|
140
|
-
// navigator.clipboard api 存在时,优先使用其进行复制操作
|
|
141
91
|
if (copiedValue !== '') {
|
|
142
92
|
navigator.clipboard.writeText(copiedValue).then(null, function () {
|
|
143
93
|
throw new Error("failed to copy to clipboard of value '".concat(copiedValue, "'"));
|
|
@@ -151,7 +101,6 @@ var onClipboardCopy = function onClipboardCopy(target) {
|
|
|
151
101
|
removeContainer(container);
|
|
152
102
|
}
|
|
153
103
|
} else {
|
|
154
|
-
// 通过元素来复制
|
|
155
104
|
copiedValue = getContent(target);
|
|
156
105
|
if (navigator.clipboard) {
|
|
157
106
|
if (copiedValue !== '') {
|
|
@@ -167,26 +116,18 @@ var onClipboardCopy = function onClipboardCopy(target) {
|
|
|
167
116
|
}
|
|
168
117
|
return copiedValue;
|
|
169
118
|
};
|
|
170
|
-
/**
|
|
171
|
-
* 剪贴板剪切操作
|
|
172
|
-
* @param {HTMLElement} target
|
|
173
|
-
* @return {string}
|
|
174
|
-
*/
|
|
175
119
|
exports.onClipboardCopy = onClipboardCopy;
|
|
176
120
|
var onClipboardCut = function onClipboardCut(target) {
|
|
177
121
|
var cutValue = getContent(target);
|
|
178
122
|
if (target.nodeName === 'SELECT' || target.nodeName === 'INPUT' || target.nodeName === 'TEXTAREA') {
|
|
179
|
-
// 对于输入框,使用 document.execCommand('cut') 来剪切,防止受控的输入框无法清空内容
|
|
180
123
|
if (document.execCommand) {
|
|
181
124
|
addSelection(target);
|
|
182
125
|
document.execCommand('cut');
|
|
183
126
|
removeSelection(target);
|
|
184
127
|
} else {
|
|
185
|
-
// document.execCommand 命令不兼容,则抛出异常,因为受控的输入框无法清空元素内容
|
|
186
128
|
throw new Error("failed to cut to clipboard through unavailable api \"document.execCommand\"");
|
|
187
129
|
}
|
|
188
130
|
} else {
|
|
189
|
-
// 对于其他标签的元素,使用 navigator 写入剪贴板,并手动清空内容,防止其他标签无法清空内容
|
|
190
131
|
if (navigator.clipboard) {
|
|
191
132
|
if (cutValue !== '') {
|
|
192
133
|
navigator.clipboard.writeText(cutValue).then(null, function () {
|
|
@@ -195,7 +136,6 @@ var onClipboardCut = function onClipboardCut(target) {
|
|
|
195
136
|
}
|
|
196
137
|
clearElement(target);
|
|
197
138
|
} else {
|
|
198
|
-
// navigator.clipboard 命令不兼容,则抛出异常,因为非输入框无法适用 document.execCommand('cut')
|
|
199
139
|
throw new Error("failed to cut to clipboard through unavailable api \"navigator.clipboard\"");
|
|
200
140
|
}
|
|
201
141
|
}
|
package/lib/collapse/collapse.js
CHANGED
|
@@ -26,7 +26,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "functi
|
|
|
26
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
27
|
var IconPositionTypes = (0, _type.tuple)('left', 'right');
|
|
28
28
|
exports.IconPositionTypes = IconPositionTypes;
|
|
29
|
-
var InternalCollapse =
|
|
29
|
+
var InternalCollapse = _react.default.forwardRef(function (props, ref) {
|
|
30
30
|
var _React$useContext = _react.default.useContext(_ConfigContext.default),
|
|
31
31
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
32
32
|
prefixCls = _React$useContext.prefixCls,
|
|
@@ -43,7 +43,7 @@ var InternalCollapse = /*#__PURE__*/_react.default.forwardRef(function (props, r
|
|
|
43
43
|
className = _getCompProps.className,
|
|
44
44
|
children = _getCompProps.children,
|
|
45
45
|
customPrefixcls = _getCompProps.prefixCls;
|
|
46
|
-
var CollapsePrefixCls = getPrefixCls(prefixCls, 'collapse', customPrefixcls);
|
|
46
|
+
var CollapsePrefixCls = getPrefixCls(prefixCls, 'collapse', customPrefixcls);
|
|
47
47
|
var _useState = (0, _react.useState)([]),
|
|
48
48
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
49
49
|
innerKey = _useState2[0],
|
|
@@ -101,7 +101,7 @@ var InternalCollapse = /*#__PURE__*/_react.default.forwardRef(function (props, r
|
|
|
101
101
|
(0, _devwarning.default)(true, 'Collapse', 'children must be Collapse.Panel');
|
|
102
102
|
return item;
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return _react.default.cloneElement(item, (0, _extends2.default)({
|
|
105
105
|
expandIcon: expandIcon,
|
|
106
106
|
expandIconPosition: expandIconPosition,
|
|
107
107
|
onChange: onPanelChange,
|
|
@@ -111,8 +111,8 @@ var InternalCollapse = /*#__PURE__*/_react.default.forwardRef(function (props, r
|
|
|
111
111
|
});
|
|
112
112
|
};
|
|
113
113
|
var rootClassName = (0, _classnames.default)(className, (0, _defineProperty2.default)({}, "".concat(CollapsePrefixCls), true));
|
|
114
|
-
var collapseRef = ref ||
|
|
115
|
-
return
|
|
114
|
+
var collapseRef = ref || _react.default.createRef();
|
|
115
|
+
return _react.default.createElement("div", {
|
|
116
116
|
className: rootClassName,
|
|
117
117
|
style: style,
|
|
118
118
|
ref: collapseRef
|