@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/es/checkbox/checkbox.js
CHANGED
|
@@ -91,7 +91,6 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
|
|
|
91
91
|
(_a = labelRef === null || labelRef === void 0 ? void 0 : labelRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', handleRepeatClick);
|
|
92
92
|
return function () {
|
|
93
93
|
var _a;
|
|
94
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
94
|
(_a = labelRef === null || labelRef === void 0 ? void 0 : labelRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', handleRepeatClick);
|
|
96
95
|
};
|
|
97
96
|
}, []);
|
|
@@ -108,37 +107,33 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
|
|
|
108
107
|
if ((value !== null && value !== void 0 ? value : '') !== '') {
|
|
109
108
|
inputProps.value = value;
|
|
110
109
|
}
|
|
111
|
-
return (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
type: "right-bold",
|
|
136
|
-
className: _concatInstanceProperty(_context20 = "".concat(checkboxPrefixCls, "-")).call(_context20, mergedCheckboxType, "-inner-icon")
|
|
137
|
-
}))) : null)
|
|
138
|
-
);
|
|
110
|
+
return React.createElement("label", _extends({
|
|
111
|
+
className: getRootClassName,
|
|
112
|
+
style: style,
|
|
113
|
+
ref: labelRef
|
|
114
|
+
}, rest), React.createElement("span", {
|
|
115
|
+
className: checkedWrapperClassName
|
|
116
|
+
}, selected ? React.createElement("span", {
|
|
117
|
+
className: innerIconClassName
|
|
118
|
+
}, React.createElement(Icon, {
|
|
119
|
+
type: "right-bold",
|
|
120
|
+
className: _concatInstanceProperty(_context19 = "".concat(checkboxPrefixCls, "-")).call(_context19, mergedCheckboxType, "-inner-icon")
|
|
121
|
+
})) : null, React.createElement("input", _extends({
|
|
122
|
+
type: "checkbox",
|
|
123
|
+
ref: ref
|
|
124
|
+
}, inputProps))), children ? React.createElement("span", {
|
|
125
|
+
className: "".concat(checkboxPrefixCls, "-children")
|
|
126
|
+
}, children) : null, !isDefaultType() ? React.createElement("span", {
|
|
127
|
+
className: triangleClassName
|
|
128
|
+
}, React.createElement("span", {
|
|
129
|
+
className: innerIconClassName
|
|
130
|
+
}, React.createElement(Icon, {
|
|
131
|
+
type: "right-bold",
|
|
132
|
+
className: _concatInstanceProperty(_context20 = "".concat(checkboxPrefixCls, "-")).call(_context20, mergedCheckboxType, "-inner-icon")
|
|
133
|
+
}))) : null);
|
|
139
134
|
};
|
|
140
135
|
return getDefaultCheckbox();
|
|
141
136
|
};
|
|
142
|
-
var Checkbox =
|
|
137
|
+
var Checkbox = React.forwardRef(InternalCheckbox);
|
|
143
138
|
Checkbox.displayName = 'Checkbox';
|
|
144
139
|
export default Checkbox;
|
package/es/checkbox/group.js
CHANGED
|
@@ -13,7 +13,6 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
13
13
|
return t;
|
|
14
14
|
};
|
|
15
15
|
import React, { useContext } from 'react';
|
|
16
|
-
// import { Icon } from '../index'
|
|
17
16
|
import classnames from 'classnames';
|
|
18
17
|
import ConfigContext from '../config-provider/ConfigContext';
|
|
19
18
|
import { getCompProps } from '../_utils';
|
|
@@ -23,13 +22,13 @@ import Checkbox from './checkbox';
|
|
|
23
22
|
import devWarning from '../_utils/devwarning';
|
|
24
23
|
export var CheckboxTypes = tuple('default', 'square');
|
|
25
24
|
export var CheckboxSizes = tuple('large', 'middle', 'small');
|
|
26
|
-
export var GroupContext =
|
|
27
|
-
var CheckboxGroup =
|
|
25
|
+
export var GroupContext = React.createContext(null);
|
|
26
|
+
var CheckboxGroup = React.forwardRef(function (props, ref) {
|
|
28
27
|
var _useContext = useContext(ConfigContext),
|
|
29
28
|
getPrefixCls = _useContext.getPrefixCls,
|
|
30
29
|
prefixCls = _useContext.prefixCls,
|
|
31
30
|
userDefaultProps = _useContext.compDefaultProps;
|
|
32
|
-
var CheckboxProps = getCompProps('CheckboxGroup', userDefaultProps, props);
|
|
31
|
+
var CheckboxProps = getCompProps('CheckboxGroup', userDefaultProps, props);
|
|
33
32
|
var checkboxType = CheckboxProps.checkboxType,
|
|
34
33
|
className = CheckboxProps.className,
|
|
35
34
|
style = CheckboxProps.style,
|
|
@@ -54,7 +53,7 @@ var CheckboxGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
54
53
|
setGroupValue(innerValue.current);
|
|
55
54
|
}, [value, defaultValue]);
|
|
56
55
|
var isControlled = typeof value !== 'undefined';
|
|
57
|
-
var checkboxGroupPrefixCls = getPrefixCls(prefixCls, 'checkbox-group', customPrefixcls);
|
|
56
|
+
var checkboxGroupPrefixCls = getPrefixCls(prefixCls, 'checkbox-group', customPrefixcls);
|
|
58
57
|
devWarning(isArrayValueRepeat(groupValue), 'checkboxGroup', "variable value's value should be unique ");
|
|
59
58
|
var getReduceItem = function getReduceItem(targetValue) {
|
|
60
59
|
var _context;
|
|
@@ -91,7 +90,7 @@ var CheckboxGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
91
90
|
};
|
|
92
91
|
var renderByOptions = function renderByOptions() {
|
|
93
92
|
return _mapInstanceProperty(options).call(options, function (option, index) {
|
|
94
|
-
return
|
|
93
|
+
return React.createElement(Checkbox, {
|
|
95
94
|
size: size,
|
|
96
95
|
disabled: option.disabled,
|
|
97
96
|
key: index,
|
|
@@ -104,13 +103,13 @@ var CheckboxGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
104
103
|
}, option.label || option);
|
|
105
104
|
});
|
|
106
105
|
};
|
|
107
|
-
return
|
|
106
|
+
return React.createElement("ul", _extends({
|
|
108
107
|
className: classnames(checkboxGroupPrefixCls, className),
|
|
109
108
|
style: style,
|
|
110
109
|
ref: ref
|
|
111
|
-
}, rest),
|
|
110
|
+
}, rest), React.createElement(GroupContext.Provider, {
|
|
112
111
|
value: context
|
|
113
112
|
}, options && options.length > 0 ? renderByOptions() : children));
|
|
114
113
|
});
|
|
115
114
|
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
116
|
-
export default
|
|
115
|
+
export default React.memo(CheckboxGroup);
|
|
@@ -88,7 +88,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
88
88
|
}];
|
|
89
89
|
var innerRef = useRef();
|
|
90
90
|
var selectRef = ref || innerRef;
|
|
91
|
-
var searchRef = useRef(null);
|
|
91
|
+
var searchRef = useRef(null);
|
|
92
92
|
var selectionRef = useRef(null);
|
|
93
93
|
var clearRef = useRef(null);
|
|
94
94
|
var optionsListRef = useRef(null);
|
|
@@ -122,7 +122,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
122
122
|
var selectPrefixCls = getPrefixCls(prefixCls, 'city-picker', customPrefixcls);
|
|
123
123
|
var cityPickerCls = classNames(selectPrefixCls, className, _defineProperty({}, "".concat(selectPrefixCls, "-visible"), optionShow));
|
|
124
124
|
var selectionCls = classNames(_defineProperty({}, "".concat(selectPrefixCls, "-selector"), true));
|
|
125
|
-
// 公共样式
|
|
126
125
|
var commCls = classNames((_classNames3 = {}, _defineProperty(_classNames3, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), _defineProperty(_classNames3, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), _defineProperty(_classNames3, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), _defineProperty(_classNames3, _concatInstanceProperty(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), _defineProperty(_classNames3, "".concat(selectPrefixCls, "-wrapper"), true), _defineProperty(_classNames3, "".concat(selectPrefixCls, "-show-search"), focusd), _classNames3));
|
|
127
126
|
useEffect(function () {
|
|
128
127
|
var _context2;
|
|
@@ -162,21 +161,18 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
162
161
|
}
|
|
163
162
|
});
|
|
164
163
|
}, []);
|
|
165
|
-
// 输入框变化搜索内容
|
|
166
164
|
var handleSearchChange = useCallback(function (event) {
|
|
167
165
|
var val = event.currentTarget.value;
|
|
168
166
|
setOptionShow(true);
|
|
169
167
|
setSearchValue(val);
|
|
170
168
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch(val);
|
|
171
169
|
}, [onSearch]);
|
|
172
|
-
// 清除搜索内容
|
|
173
170
|
var handleClear = useCallback(function () {
|
|
174
171
|
if (searchRef.current) {
|
|
175
172
|
searchRef.current.value = '';
|
|
176
173
|
setSearchValue('');
|
|
177
174
|
}
|
|
178
175
|
}, [searchRef]);
|
|
179
|
-
// 清空选择器内容
|
|
180
176
|
var handleReset = function handleReset(e) {
|
|
181
177
|
e.stopPropagation();
|
|
182
178
|
onClear && onClear('');
|
|
@@ -185,33 +181,31 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
185
181
|
setSearchValue('');
|
|
186
182
|
onChange && onChange(undefined, '');
|
|
187
183
|
};
|
|
188
|
-
// 渲染后缀图标
|
|
189
184
|
var renderSuffix = function renderSuffix() {
|
|
190
185
|
var _classNames4;
|
|
191
186
|
if (disabled) return null;
|
|
192
187
|
var suffixIcon = selectProps.suffixIcon;
|
|
193
188
|
var arrowIconCls = classNames((_classNames4 = {}, _defineProperty(_classNames4, "".concat(selectPrefixCls, "-icon-arrow"), true), _defineProperty(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-up"), optionShow), _defineProperty(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-down"), !optionShow), _defineProperty(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-focus"), optionShow), _classNames4));
|
|
194
189
|
var iconShow = allowClear && !disabled && (initValue !== null && initValue !== void 0 ? initValue : '') !== '';
|
|
195
|
-
return
|
|
190
|
+
return React.createElement(React.Fragment, null, iconShow && React.createElement("span", {
|
|
196
191
|
onClick: handleReset,
|
|
197
192
|
onMouseDown: function onMouseDown(e) {
|
|
198
193
|
return e.preventDefault();
|
|
199
194
|
},
|
|
200
195
|
className: "".concat(selectPrefixCls, "-icon-clear"),
|
|
201
196
|
ref: clearRef
|
|
202
|
-
}, clearIcon ||
|
|
197
|
+
}, clearIcon || React.createElement(Icon, {
|
|
203
198
|
type: "close"
|
|
204
|
-
})), showArrow &&
|
|
199
|
+
})), showArrow && React.createElement("span", {
|
|
205
200
|
className: arrowIconCls
|
|
206
|
-
}, suffixIcon ||
|
|
201
|
+
}, suffixIcon || React.createElement(Icon, {
|
|
207
202
|
type: "arrow-down"
|
|
208
203
|
})));
|
|
209
204
|
};
|
|
210
|
-
// 下拉列表为空时显示的内容
|
|
211
205
|
var renderNotContent = function renderNotContent(msg) {
|
|
212
206
|
var notFoundContent = selectProps.notFoundContent;
|
|
213
207
|
var emptyContent = notFoundContent || msg;
|
|
214
|
-
return
|
|
208
|
+
return React.createElement("div", {
|
|
215
209
|
className: "".concat(selectPrefixCls, "-dropdown-empty")
|
|
216
210
|
}, emptyContent);
|
|
217
211
|
};
|
|
@@ -221,11 +215,11 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
221
215
|
return "(".concat(escapeRegExp(item), ")");
|
|
222
216
|
}).join('|') : "(".concat(escapeRegExp(inputValue), ")"), 'i');
|
|
223
217
|
var strArr = text === null || text === void 0 ? void 0 : text.split(regex);
|
|
224
|
-
return
|
|
225
|
-
return (regex === null || regex === void 0 ? void 0 : regex.test(item)) ?
|
|
218
|
+
return React.createElement(React.Fragment, null, strArr === null || strArr === void 0 ? void 0 : _mapInstanceProperty(strArr).call(strArr, function (item, index) {
|
|
219
|
+
return (regex === null || regex === void 0 ? void 0 : regex.test(item)) ? React.createElement("span", {
|
|
226
220
|
key: index,
|
|
227
221
|
className: "".concat(selectPrefixCls, "-highlight")
|
|
228
|
-
}, item) :
|
|
222
|
+
}, item) : React.createElement("span", {
|
|
229
223
|
key: index
|
|
230
224
|
}, item);
|
|
231
225
|
}));
|
|
@@ -249,14 +243,14 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
249
243
|
if (!data.length) {
|
|
250
244
|
return renderNotContent(notContent);
|
|
251
245
|
}
|
|
252
|
-
return
|
|
246
|
+
return React.createElement("div", {
|
|
253
247
|
className: "".concat(selectPrefixCls, "-list"),
|
|
254
248
|
ref: optionsListRef,
|
|
255
249
|
onMouseDown: function onMouseDown(e) {
|
|
256
250
|
return e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
257
251
|
}
|
|
258
252
|
}, _mapInstanceProperty(data).call(data, function (item, index) {
|
|
259
|
-
return
|
|
253
|
+
return React.createElement(Option, {
|
|
260
254
|
key: item.id,
|
|
261
255
|
value: initValue,
|
|
262
256
|
city: item,
|
|
@@ -275,9 +269,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
275
269
|
}));
|
|
276
270
|
};
|
|
277
271
|
var renderLoading = function renderLoading() {
|
|
278
|
-
return
|
|
272
|
+
return React.createElement("div", {
|
|
279
273
|
className: "".concat(selectPrefixCls, "-dropdown-loading")
|
|
280
|
-
},
|
|
274
|
+
}, React.createElement(Spin, {
|
|
281
275
|
type: "container"
|
|
282
276
|
}));
|
|
283
277
|
};
|
|
@@ -285,18 +279,17 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
285
279
|
setTabsValue(type);
|
|
286
280
|
onTabPaneChange === null || onTabPaneChange === void 0 ? void 0 : onTabPaneChange(type);
|
|
287
281
|
};
|
|
288
|
-
// 渲染下拉列表框
|
|
289
282
|
var renderContent = function renderContent() {
|
|
290
|
-
return loading ? renderLoading() :
|
|
283
|
+
return loading ? renderLoading() : React.createElement(React.Fragment, null, searchValue ? React.createElement(React.Fragment, null, isDomestic(type) && React.createElement(Tabs, {
|
|
291
284
|
noContainer: true,
|
|
292
285
|
onChange: toggleTabPane,
|
|
293
286
|
activeKey: tabsValue
|
|
294
287
|
}, _mapInstanceProperty(tabsData).call(tabsData, function (item) {
|
|
295
|
-
return
|
|
288
|
+
return React.createElement(Tabs.TabPane, {
|
|
296
289
|
key: item.id,
|
|
297
290
|
tab: item.name
|
|
298
291
|
}, item);
|
|
299
|
-
})), tabsValue === 'domestic' ? renderNodeList(domesticList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText) : renderNodeList(foreignList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText)) :
|
|
292
|
+
})), 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.createElement(React.Fragment, null, !!commonList.length && React.createElement("div", {
|
|
300
293
|
className: "".concat(selectPrefixCls, "-dropdown-common")
|
|
301
294
|
}, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.common), renderNodeList(commonList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.commonEmptyText, true)));
|
|
302
295
|
};
|
|
@@ -330,14 +323,14 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
330
323
|
visibility: 'hidden'
|
|
331
324
|
} : undefined;
|
|
332
325
|
var itemCls = classNames((_classNames5 = {}, _defineProperty(_classNames5, "".concat(selectPrefixCls, "-content-item"), true), _defineProperty(_classNames5, "".concat(selectPrefixCls, "-content-item-seleted"), afterChangeFocus), _classNames5));
|
|
333
|
-
return
|
|
326
|
+
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
334
327
|
className: singleCls,
|
|
335
328
|
ref: selectionRef
|
|
336
|
-
},
|
|
329
|
+
}, React.createElement("div", {
|
|
337
330
|
className: "".concat(selectPrefixCls, "-content")
|
|
338
|
-
},
|
|
331
|
+
}, React.createElement("span", {
|
|
339
332
|
className: "".concat(selectPrefixCls, "-content-search")
|
|
340
|
-
},
|
|
333
|
+
}, React.createElement("input", {
|
|
341
334
|
ref: searchRef,
|
|
342
335
|
value: searchValue,
|
|
343
336
|
className: "".concat(selectPrefixCls, "-content-search-input"),
|
|
@@ -345,15 +338,15 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
345
338
|
onFocus: handleFocus,
|
|
346
339
|
onBlur: handleBlur,
|
|
347
340
|
readOnly: !!disabled
|
|
348
|
-
}), !searchValue &&
|
|
341
|
+
}), !searchValue && React.createElement("span", {
|
|
349
342
|
className: itemCls,
|
|
350
343
|
title: seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name
|
|
351
|
-
}, seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name)), !searchValue &&
|
|
344
|
+
}, seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name)), !searchValue && React.createElement("span", {
|
|
352
345
|
className: "".concat(selectPrefixCls, "-content-info")
|
|
353
|
-
}, _renderCityInfo(seletedCity))),
|
|
346
|
+
}, _renderCityInfo(seletedCity))), React.createElement("span", {
|
|
354
347
|
className: "".concat(selectPrefixCls, "-placeholder"),
|
|
355
348
|
style: hiddenStyle
|
|
356
|
-
}, !disabled ? placeholder : null),
|
|
349
|
+
}, !disabled ? placeholder : null), React.createElement("span", {
|
|
357
350
|
className: "".concat(selectPrefixCls, "-suffix")
|
|
358
351
|
}, renderSuffix())));
|
|
359
352
|
};
|
|
@@ -375,7 +368,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
375
368
|
(_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', fn);
|
|
376
369
|
};
|
|
377
370
|
}, [initValue]);
|
|
378
|
-
// keyboard
|
|
379
371
|
var curkeyboardList = useMemo(function () {
|
|
380
372
|
if (!searchValue) {
|
|
381
373
|
return commonList;
|
|
@@ -408,12 +400,10 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
408
400
|
var onInternalKeyDown = function onInternalKeyDown(e) {
|
|
409
401
|
var _a, _b, _c;
|
|
410
402
|
var which = e.which;
|
|
411
|
-
// open
|
|
412
403
|
if (which === KeyCode.ENTER || which === KeyCode.UP || which === KeyCode.DOWN) {
|
|
413
404
|
e.preventDefault();
|
|
414
405
|
setOptionShow(true);
|
|
415
406
|
}
|
|
416
|
-
// up、down、enter、esc
|
|
417
407
|
if (optionShow) {
|
|
418
408
|
var offset = 0;
|
|
419
409
|
switch (which) {
|
|
@@ -452,13 +442,13 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
452
442
|
}
|
|
453
443
|
};
|
|
454
444
|
var renderCityPicker = function renderCityPicker() {
|
|
455
|
-
return
|
|
445
|
+
return React.createElement("div", {
|
|
456
446
|
className: cityPickerCls,
|
|
457
447
|
ref: selectRef,
|
|
458
448
|
style: style
|
|
459
|
-
}, showDescription &&
|
|
449
|
+
}, showDescription && React.createElement("span", {
|
|
460
450
|
className: "".concat(selectPrefixCls, "-description")
|
|
461
|
-
}, description),
|
|
451
|
+
}, description), React.createElement("span", {
|
|
462
452
|
className: selectionCls,
|
|
463
453
|
tabIndex: disabled ? -1 : 0,
|
|
464
454
|
onFocus: function onFocus() {
|
|
@@ -507,6 +497,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
507
497
|
});
|
|
508
498
|
return usePopper(renderCityPicker(), renderContent(), popperProps);
|
|
509
499
|
};
|
|
510
|
-
var Select =
|
|
500
|
+
var Select = React.forwardRef(InternalSelect);
|
|
511
501
|
Select.displayName = 'CityPicker';
|
|
512
502
|
export default Select;
|
package/es/city-picker/option.js
CHANGED
|
@@ -36,19 +36,19 @@ var InternalOption = function InternalOption(props, ref) {
|
|
|
36
36
|
var handleOnMouseLeave = function handleOnMouseLeave() {
|
|
37
37
|
onChangeActiveIndex && onChangeActiveIndex(-1);
|
|
38
38
|
};
|
|
39
|
-
return
|
|
39
|
+
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
40
40
|
ref: optionRef,
|
|
41
41
|
className: optionCls,
|
|
42
42
|
title: name,
|
|
43
43
|
onClick: handleClick,
|
|
44
44
|
onMouseEnter: handleOnMouseEnter,
|
|
45
45
|
onMouseLeave: handleOnMouseLeave
|
|
46
|
-
}, typeof itemRender === 'function' ? itemRender(city) :
|
|
46
|
+
}, typeof itemRender === 'function' ? itemRender(city) : React.createElement(React.Fragment, null, React.createElement("span", {
|
|
47
47
|
className: "".concat(selectOptionPrefixCls, "-content")
|
|
48
|
-
}, children),
|
|
48
|
+
}, children), React.createElement("span", {
|
|
49
49
|
className: "".concat(selectOptionPrefixCls, "-info")
|
|
50
50
|
}, renderCityInfo === null || renderCityInfo === void 0 ? void 0 : renderCityInfo(city, true)))));
|
|
51
51
|
};
|
|
52
|
-
var Option =
|
|
52
|
+
var Option = React.forwardRef(InternalOption);
|
|
53
53
|
Option.displayName = 'CityPickerOption';
|
|
54
54
|
export default Option;
|
|
@@ -26,7 +26,6 @@ var InternalClipboard = function InternalClipboard(props, ref) {
|
|
|
26
26
|
getPrefixCls = _useContext.getPrefixCls,
|
|
27
27
|
prefixCls = _useContext.prefixCls,
|
|
28
28
|
userDefaultProps = _useContext.compDefaultProps;
|
|
29
|
-
// 剪贴板参数,合并了系统默认参数、用户定义组件统一参数及组件传参
|
|
30
29
|
var clipboardProps = getCompProps('Clipboard', userDefaultProps, props);
|
|
31
30
|
var className = clipboardProps.className,
|
|
32
31
|
customPrefixcls = clipboardProps.prefixCls,
|
|
@@ -42,65 +41,48 @@ var InternalClipboard = function InternalClipboard(props, ref) {
|
|
|
42
41
|
others = __rest(clipboardProps, ["className", "prefixCls", "action", "content", "children", "disabled", "icon", "size", "target", "onError", "onSuccess"]);
|
|
43
42
|
devWarning(ClipboardActions.indexOf(action) === -1, 'clipboard', "cannot found clipboard action '".concat(action, "'"));
|
|
44
43
|
devWarning(ClipboardSizes.indexOf(size) === -1, 'clipboard', "cannot found clipboard size '".concat(size, "'"));
|
|
45
|
-
// 剪贴板样式前缀
|
|
46
44
|
var clipboardPrefixCls = getPrefixCls(prefixCls, 'clipboard', customPrefixcls);
|
|
47
45
|
var clipboardClass = classNames(clipboardPrefixCls, className, (_classNames = {}, _defineProperty(_classNames, _concatInstanceProperty(_context = "".concat(clipboardPrefixCls, "-size-")).call(_context, size), size), _defineProperty(_classNames, "".concat(clipboardPrefixCls, "-icon-only"), !children && children !== 0 && icon !== null), _classNames));
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
// 如果没有传 icon,则使用默认图标
|
|
51
|
-
// 如果 icon 传 null,则不使用图标
|
|
52
|
-
var iconNode = icon || (icon === undefined ? /*#__PURE__*/React.createElement(Icon, {
|
|
46
|
+
var clipboardRef = ref || React.createRef();
|
|
47
|
+
var iconNode = icon || (icon === undefined ? React.createElement(Icon, {
|
|
53
48
|
type: "copy-code"
|
|
54
49
|
}) : null);
|
|
55
|
-
|
|
56
|
-
var childrenNode = typeof children === 'string' ? /*#__PURE__*/React.createElement("span", null, children) : children;
|
|
57
|
-
/**
|
|
58
|
-
* 剪贴板 click 事件处理
|
|
59
|
-
*/
|
|
50
|
+
var childrenNode = typeof children === 'string' ? React.createElement("span", null, children) : children;
|
|
60
51
|
var handleClick = useCallback(function () {
|
|
61
52
|
if (disabled) {
|
|
62
|
-
// 禁用状态不触发点击事件
|
|
63
53
|
return;
|
|
64
54
|
}
|
|
65
55
|
var selectedText;
|
|
66
56
|
try {
|
|
67
57
|
if (content) {
|
|
68
|
-
// 如果传了 content,则直接复制 content
|
|
69
58
|
selectedText = onClipboardCopy(content);
|
|
70
59
|
} else {
|
|
71
60
|
var targetElement = typeof target === 'string' ? document.querySelector(target) : target();
|
|
72
61
|
if (!targetElement) {
|
|
73
|
-
// 没有获取到元素,抛出异常
|
|
74
62
|
throw new Error("target element '".concat(target, "' does not exist"));
|
|
75
63
|
} else {
|
|
76
64
|
if (action === 'copy' && targetElement.hasAttribute('disabled')) {
|
|
77
|
-
// 复制被置为 disabled 的元素,抛出异常
|
|
78
65
|
throw new Error("invalid \"target\" attribute of element '".concat(targetElement, "'. Please use \"readonly\" instead of \"disabled\" attribute"));
|
|
79
66
|
}
|
|
80
67
|
if (action === 'cut' && (targetElement.hasAttribute('readonly') || targetElement.hasAttribute('disabled'))) {
|
|
81
|
-
// 剪切被置为 readonly 或 disabled 的元素,抛出异常
|
|
82
68
|
throw new Error("invalid \"target\" attribute of element '".concat(targetElement, "'. You can't cut text from elements with \"readonly\" or \"disabled\" attributes"));
|
|
83
69
|
}
|
|
84
70
|
}
|
|
85
|
-
// 对 targetElement 的值进行复制或剪切
|
|
86
71
|
selectedText = action === 'copy' ? onClipboardCopy(targetElement) : onClipboardCut(targetElement);
|
|
87
72
|
}
|
|
88
73
|
} catch (error) {
|
|
89
|
-
// 触发失败的回调
|
|
90
74
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
91
|
-
// 退出处理器
|
|
92
75
|
return;
|
|
93
76
|
}
|
|
94
|
-
// 触发成功的回调
|
|
95
77
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(selectedText);
|
|
96
78
|
}, [action, content, disabled, onError, onSuccess, target]);
|
|
97
|
-
return
|
|
79
|
+
return React.createElement("div", _extends({
|
|
98
80
|
className: clipboardClass,
|
|
99
81
|
disabled: disabled,
|
|
100
82
|
onClick: handleClick,
|
|
101
83
|
ref: clipboardRef
|
|
102
84
|
}, others), iconNode, childrenNode);
|
|
103
85
|
};
|
|
104
|
-
var Clipboard =
|
|
86
|
+
var Clipboard = React.forwardRef(InternalClipboard);
|
|
105
87
|
Clipboard.displayName = 'Clipboard';
|
|
106
88
|
export default Clipboard;
|
package/es/clipboard/util.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 获取元素的内容
|
|
3
|
-
* @param {HTMLElement} element
|
|
4
|
-
* @return {string}
|
|
5
|
-
*/
|
|
6
1
|
var getContent = function getContent(element) {
|
|
7
2
|
var content;
|
|
8
3
|
if (element.nodeName === 'SELECT') {
|
|
@@ -12,28 +7,16 @@ var getContent = function getContent(element) {
|
|
|
12
7
|
} else if (element.nodeName === 'TEXTAREA') {
|
|
13
8
|
content = element.value;
|
|
14
9
|
} else {
|
|
15
|
-
// 其他类型通过 select 与 range 来获取文本
|
|
16
|
-
// 获取 select
|
|
17
10
|
var selection = window.getSelection();
|
|
18
|
-
// 创建 range
|
|
19
11
|
var range = document.createRange();
|
|
20
|
-
// 设置 range 的元素
|
|
21
12
|
range.selectNodeContents(element);
|
|
22
|
-
// 重置 select
|
|
23
13
|
selection.removeAllRanges();
|
|
24
|
-
// 设置 select 的 range
|
|
25
14
|
selection.addRange(range);
|
|
26
|
-
// 获取选中的文本
|
|
27
15
|
content = selection.toString();
|
|
28
|
-
// 获取到文本后清空选中范围
|
|
29
16
|
selection.removeAllRanges();
|
|
30
17
|
}
|
|
31
18
|
return content;
|
|
32
19
|
};
|
|
33
|
-
/**
|
|
34
|
-
* 清空元素的内容
|
|
35
|
-
* @param {HTMLElement} element
|
|
36
|
-
*/
|
|
37
20
|
var clearElement = function clearElement(element) {
|
|
38
21
|
if (element.nodeName === 'SELECT') {
|
|
39
22
|
;
|
|
@@ -48,46 +31,26 @@ var clearElement = function clearElement(element) {
|
|
|
48
31
|
element.innerHTML = '';
|
|
49
32
|
}
|
|
50
33
|
};
|
|
51
|
-
/**
|
|
52
|
-
* 由将被复制的文本为 value 创建一个 HTMLTextAreaElement 容器
|
|
53
|
-
* @param {String} value
|
|
54
|
-
* @return {HTMLTextAreaElement}
|
|
55
|
-
*/
|
|
56
34
|
var createContainer = function createContainer(value) {
|
|
57
35
|
var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
|
|
58
36
|
var container = document.createElement('textarea');
|
|
59
|
-
// 防止在 ios 上缩放
|
|
60
37
|
container.style.fontSize = '12pt';
|
|
61
|
-
// 重置样式
|
|
62
38
|
container.style.border = '0';
|
|
63
39
|
container.style.padding = '0';
|
|
64
40
|
container.style.margin = '0';
|
|
65
|
-
// 把元素定位在视窗外
|
|
66
41
|
container.style.position = 'absolute';
|
|
67
42
|
container.style[isRTL ? 'right' : 'left'] = '-9999px';
|
|
68
43
|
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
69
44
|
container.style.top = "".concat(yPosition, "px");
|
|
70
|
-
// 设置为只读
|
|
71
45
|
container.setAttribute('readonly', '');
|
|
72
|
-
// 将文本赋值给元素
|
|
73
46
|
container.value = value;
|
|
74
47
|
document.body.appendChild(container);
|
|
75
48
|
return container;
|
|
76
49
|
};
|
|
77
|
-
/**
|
|
78
|
-
* 删除元素
|
|
79
|
-
* @param {HTMLElement} container
|
|
80
|
-
*/
|
|
81
50
|
var removeContainer = function removeContainer(container) {
|
|
82
51
|
document.body.removeChild(container);
|
|
83
52
|
};
|
|
84
|
-
/**
|
|
85
|
-
* 添加选中状态
|
|
86
|
-
* @param {HTMLElement} element
|
|
87
|
-
*/
|
|
88
53
|
var addSelection = function addSelection(element) {
|
|
89
|
-
// 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
|
|
90
|
-
// 使用 select 对 <textarea> 及 <input> 单独处理
|
|
91
54
|
if (element.nodeName === 'INPUT') {
|
|
92
55
|
;
|
|
93
56
|
element.select();
|
|
@@ -102,14 +65,8 @@ var addSelection = function addSelection(element) {
|
|
|
102
65
|
selection.addRange(range);
|
|
103
66
|
}
|
|
104
67
|
};
|
|
105
|
-
/**
|
|
106
|
-
* 移除选中状态
|
|
107
|
-
* @param {HTMLElement} element
|
|
108
|
-
*/
|
|
109
68
|
var removeSelection = function removeSelection(element) {
|
|
110
69
|
var _a;
|
|
111
|
-
// 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
|
|
112
|
-
// 使用 setSelectRange 对 <textarea> 及 <input> 单独处理
|
|
113
70
|
if (element.nodeName === 'INPUT') {
|
|
114
71
|
;
|
|
115
72
|
element.setSelectionRange(0, 0);
|
|
@@ -120,18 +77,11 @@ var removeSelection = function removeSelection(element) {
|
|
|
120
77
|
(_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
121
78
|
}
|
|
122
79
|
};
|
|
123
|
-
/**
|
|
124
|
-
* 剪贴板复制操作
|
|
125
|
-
* @param {string | HTMLElement} target
|
|
126
|
-
* @return {string}
|
|
127
|
-
*/
|
|
128
80
|
var onClipboardCopy = function onClipboardCopy(target) {
|
|
129
81
|
var copiedValue;
|
|
130
82
|
if (typeof target === 'string') {
|
|
131
|
-
// 如果传的是字符串,直接复制值
|
|
132
83
|
copiedValue = target;
|
|
133
84
|
if (navigator.clipboard) {
|
|
134
|
-
// navigator.clipboard api 存在时,优先使用其进行复制操作
|
|
135
85
|
if (copiedValue !== '') {
|
|
136
86
|
navigator.clipboard.writeText(copiedValue).then(null, function () {
|
|
137
87
|
throw new Error("failed to copy to clipboard of value '".concat(copiedValue, "'"));
|
|
@@ -145,7 +95,6 @@ var onClipboardCopy = function onClipboardCopy(target) {
|
|
|
145
95
|
removeContainer(container);
|
|
146
96
|
}
|
|
147
97
|
} else {
|
|
148
|
-
// 通过元素来复制
|
|
149
98
|
copiedValue = getContent(target);
|
|
150
99
|
if (navigator.clipboard) {
|
|
151
100
|
if (copiedValue !== '') {
|
|
@@ -161,25 +110,17 @@ var onClipboardCopy = function onClipboardCopy(target) {
|
|
|
161
110
|
}
|
|
162
111
|
return copiedValue;
|
|
163
112
|
};
|
|
164
|
-
/**
|
|
165
|
-
* 剪贴板剪切操作
|
|
166
|
-
* @param {HTMLElement} target
|
|
167
|
-
* @return {string}
|
|
168
|
-
*/
|
|
169
113
|
var onClipboardCut = function onClipboardCut(target) {
|
|
170
114
|
var cutValue = getContent(target);
|
|
171
115
|
if (target.nodeName === 'SELECT' || target.nodeName === 'INPUT' || target.nodeName === 'TEXTAREA') {
|
|
172
|
-
// 对于输入框,使用 document.execCommand('cut') 来剪切,防止受控的输入框无法清空内容
|
|
173
116
|
if (document.execCommand) {
|
|
174
117
|
addSelection(target);
|
|
175
118
|
document.execCommand('cut');
|
|
176
119
|
removeSelection(target);
|
|
177
120
|
} else {
|
|
178
|
-
// document.execCommand 命令不兼容,则抛出异常,因为受控的输入框无法清空元素内容
|
|
179
121
|
throw new Error("failed to cut to clipboard through unavailable api \"document.execCommand\"");
|
|
180
122
|
}
|
|
181
123
|
} else {
|
|
182
|
-
// 对于其他标签的元素,使用 navigator 写入剪贴板,并手动清空内容,防止其他标签无法清空内容
|
|
183
124
|
if (navigator.clipboard) {
|
|
184
125
|
if (cutValue !== '') {
|
|
185
126
|
navigator.clipboard.writeText(cutValue).then(null, function () {
|
|
@@ -188,7 +129,6 @@ var onClipboardCut = function onClipboardCut(target) {
|
|
|
188
129
|
}
|
|
189
130
|
clearElement(target);
|
|
190
131
|
} else {
|
|
191
|
-
// navigator.clipboard 命令不兼容,则抛出异常,因为非输入框无法适用 document.execCommand('cut')
|
|
192
132
|
throw new Error("failed to cut to clipboard through unavailable api \"navigator.clipboard\"");
|
|
193
133
|
}
|
|
194
134
|
}
|