@ioca/react 1.4.78 → 1.4.79
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/lib/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/lib/cjs/components/affix/affix.cjs +66 -0
- package/lib/cjs/components/affix/affix.cjs.map +1 -0
- package/lib/cjs/components/affix/index.cjs +6 -0
- package/lib/cjs/components/affix/index.cjs.map +1 -0
- package/lib/cjs/components/affix/totop.cjs +25 -0
- package/lib/cjs/components/affix/totop.cjs.map +1 -0
- package/lib/cjs/components/badge/badge.cjs +24 -0
- package/lib/cjs/components/badge/badge.cjs.map +1 -0
- package/lib/cjs/components/badge/index.cjs +6 -0
- package/lib/cjs/components/badge/index.cjs.map +1 -0
- package/lib/cjs/components/button/button.cjs +64 -0
- package/lib/cjs/components/button/button.cjs.map +1 -0
- package/lib/cjs/components/button/confirm.cjs +60 -0
- package/lib/cjs/components/button/confirm.cjs.map +1 -0
- package/lib/cjs/components/button/group.cjs +26 -0
- package/lib/cjs/components/button/group.cjs.map +1 -0
- package/lib/cjs/components/button/index.cjs +6 -0
- package/lib/cjs/components/button/index.cjs.map +1 -0
- package/lib/cjs/components/button/toggle.cjs +46 -0
- package/lib/cjs/components/button/toggle.cjs.map +1 -0
- package/lib/cjs/components/card/card.cjs +33 -0
- package/lib/cjs/components/card/card.cjs.map +1 -0
- package/lib/cjs/components/card/index.cjs +6 -0
- package/lib/cjs/components/card/index.cjs.map +1 -0
- package/lib/cjs/components/checkbox/checkbox.cjs +66 -0
- package/lib/cjs/components/checkbox/checkbox.cjs.map +1 -0
- package/lib/cjs/components/checkbox/index.cjs +6 -0
- package/lib/cjs/components/checkbox/index.cjs.map +1 -0
- package/lib/cjs/components/checkbox/item.cjs +59 -0
- package/lib/cjs/components/checkbox/item.cjs.map +1 -0
- package/lib/cjs/components/collapse/collapse.cjs +84 -0
- package/lib/cjs/components/collapse/collapse.cjs.map +1 -0
- package/lib/cjs/components/collapse/index.cjs +6 -0
- package/lib/cjs/components/collapse/index.cjs.map +1 -0
- package/lib/cjs/components/collapse/item.cjs +10 -0
- package/lib/cjs/components/collapse/item.cjs.map +1 -0
- package/lib/cjs/components/datagrid/cell.cjs +39 -0
- package/lib/cjs/components/datagrid/cell.cjs.map +1 -0
- package/lib/cjs/components/datagrid/datagrid.cjs +140 -0
- package/lib/cjs/components/datagrid/datagrid.cjs.map +1 -0
- package/lib/cjs/components/datagrid/index.cjs +6 -0
- package/lib/cjs/components/datagrid/index.cjs.map +1 -0
- package/lib/cjs/components/datagrid/resize.cjs +42 -0
- package/lib/cjs/components/datagrid/resize.cjs.map +1 -0
- package/lib/cjs/components/datagrid/row.cjs +68 -0
- package/lib/cjs/components/datagrid/row.cjs.map +1 -0
- package/lib/cjs/components/datagrid/sorter.cjs +28 -0
- package/lib/cjs/components/datagrid/sorter.cjs.map +1 -0
- package/lib/cjs/components/description/description.cjs +43 -0
- package/lib/cjs/components/description/description.cjs.map +1 -0
- package/lib/cjs/components/description/index.cjs +6 -0
- package/lib/cjs/components/description/index.cjs.map +1 -0
- package/lib/cjs/components/drawer/drawer.cjs +84 -0
- package/lib/cjs/components/drawer/drawer.cjs.map +1 -0
- package/lib/cjs/components/drawer/index.cjs +6 -0
- package/lib/cjs/components/drawer/index.cjs.map +1 -0
- package/lib/cjs/components/dropdown/dropdown.cjs +38 -0
- package/lib/cjs/components/dropdown/dropdown.cjs.map +1 -0
- package/lib/cjs/components/dropdown/index.cjs +6 -0
- package/lib/cjs/components/dropdown/index.cjs.map +1 -0
- package/lib/cjs/components/dropdown/item.cjs +36 -0
- package/lib/cjs/components/dropdown/item.cjs.map +1 -0
- package/lib/cjs/components/editor/controls.cjs +89 -0
- package/lib/cjs/components/editor/controls.cjs.map +1 -0
- package/lib/cjs/components/editor/editor.cjs +91 -0
- package/lib/cjs/components/editor/editor.cjs.map +1 -0
- package/lib/cjs/components/editor/index.cjs +6 -0
- package/lib/cjs/components/editor/index.cjs.map +1 -0
- package/lib/cjs/components/flex/flex.cjs +31 -0
- package/lib/cjs/components/flex/flex.cjs.map +1 -0
- package/lib/cjs/components/flex/index.cjs +6 -0
- package/lib/cjs/components/flex/index.cjs.map +1 -0
- package/lib/cjs/components/form/context.cjs +7 -0
- package/lib/cjs/components/form/context.cjs.map +1 -0
- package/lib/cjs/components/form/field.cjs +71 -0
- package/lib/cjs/components/form/field.cjs.map +1 -0
- package/lib/cjs/components/form/form.cjs +64 -0
- package/lib/cjs/components/form/form.cjs.map +1 -0
- package/lib/cjs/components/form/index.cjs +6 -0
- package/lib/cjs/components/form/index.cjs.map +1 -0
- package/lib/cjs/components/form/useConfig.cjs +45 -0
- package/lib/cjs/components/form/useConfig.cjs.map +1 -0
- package/lib/cjs/components/form/useForm.cjs +123 -0
- package/lib/cjs/components/form/useForm.cjs.map +1 -0
- package/lib/cjs/components/icon/icon.cjs +24 -0
- package/lib/cjs/components/icon/icon.cjs.map +1 -0
- package/lib/cjs/components/icon/index.cjs +6 -0
- package/lib/cjs/components/icon/index.cjs.map +1 -0
- package/lib/cjs/components/image/image.cjs +86 -0
- package/lib/cjs/components/image/image.cjs.map +1 -0
- package/lib/cjs/components/image/index.cjs +6 -0
- package/lib/cjs/components/image/index.cjs.map +1 -0
- package/lib/cjs/components/image/list.cjs +49 -0
- package/lib/cjs/components/image/list.cjs.map +1 -0
- package/lib/cjs/components/input/container.cjs +30 -0
- package/lib/cjs/components/input/container.cjs.map +1 -0
- package/lib/cjs/components/input/index.cjs +6 -0
- package/lib/cjs/components/input/index.cjs.map +1 -0
- package/lib/cjs/components/input/input.cjs +113 -0
- package/lib/cjs/components/input/input.cjs.map +1 -0
- package/lib/cjs/components/input/number.cjs +138 -0
- package/lib/cjs/components/input/number.cjs.map +1 -0
- package/lib/cjs/components/input/range.cjs +134 -0
- package/lib/cjs/components/input/range.cjs.map +1 -0
- package/lib/cjs/components/input/textarea.cjs +61 -0
- package/lib/cjs/components/input/textarea.cjs.map +1 -0
- package/lib/cjs/components/list/index.cjs +6 -0
- package/lib/cjs/components/list/index.cjs.map +1 -0
- package/lib/cjs/components/list/item.cjs +30 -0
- package/lib/cjs/components/list/item.cjs.map +1 -0
- package/lib/cjs/components/list/list.cjs +30 -0
- package/lib/cjs/components/list/list.cjs.map +1 -0
- package/lib/cjs/components/loading/index.cjs +6 -0
- package/lib/cjs/components/loading/index.cjs.map +1 -0
- package/lib/cjs/components/loading/loading.cjs +39 -0
- package/lib/cjs/components/loading/loading.cjs.map +1 -0
- package/lib/cjs/components/message/index.cjs +6 -0
- package/lib/cjs/components/message/index.cjs.map +1 -0
- package/lib/cjs/components/message/message.cjs +197 -0
- package/lib/cjs/components/message/message.cjs.map +1 -0
- package/lib/cjs/components/modal/content.cjs +57 -0
- package/lib/cjs/components/modal/content.cjs.map +1 -0
- package/lib/cjs/components/modal/context.cjs +7 -0
- package/lib/cjs/components/modal/context.cjs.map +1 -0
- package/lib/cjs/components/modal/hookModal.cjs +28 -0
- package/lib/cjs/components/modal/hookModal.cjs.map +1 -0
- package/lib/cjs/components/modal/index.cjs +6 -0
- package/lib/cjs/components/modal/index.cjs.map +1 -0
- package/lib/cjs/components/modal/modal.cjs +117 -0
- package/lib/cjs/components/modal/modal.cjs.map +1 -0
- package/lib/cjs/components/modal/useModal.cjs +39 -0
- package/lib/cjs/components/modal/useModal.cjs.map +1 -0
- package/lib/cjs/components/pagination/index.cjs +6 -0
- package/lib/cjs/components/pagination/index.cjs.map +1 -0
- package/lib/cjs/components/pagination/page.cjs +31 -0
- package/lib/cjs/components/pagination/page.cjs.map +1 -0
- package/lib/cjs/components/pagination/pagination.cjs +86 -0
- package/lib/cjs/components/pagination/pagination.cjs.map +1 -0
- package/lib/cjs/components/picker/colors/footer.cjs +64 -0
- package/lib/cjs/components/picker/colors/footer.cjs.map +1 -0
- package/lib/cjs/components/picker/colors/handle.cjs +25 -0
- package/lib/cjs/components/picker/colors/handle.cjs.map +1 -0
- package/lib/cjs/components/picker/colors/index.cjs +81 -0
- package/lib/cjs/components/picker/colors/index.cjs.map +1 -0
- package/lib/cjs/components/picker/dates/dates.cjs +68 -0
- package/lib/cjs/components/picker/dates/dates.cjs.map +1 -0
- package/lib/cjs/components/picker/dates/index.cjs +97 -0
- package/lib/cjs/components/picker/dates/index.cjs.map +1 -0
- package/lib/cjs/components/picker/dates/panel.cjs +151 -0
- package/lib/cjs/components/picker/dates/panel.cjs.map +1 -0
- package/lib/cjs/components/picker/time/index.cjs +73 -0
- package/lib/cjs/components/picker/time/index.cjs.map +1 -0
- package/lib/cjs/components/picker/time/item.cjs +20 -0
- package/lib/cjs/components/picker/time/item.cjs.map +1 -0
- package/lib/cjs/components/picker/time/panel.cjs +144 -0
- package/lib/cjs/components/picker/time/panel.cjs.map +1 -0
- package/lib/cjs/components/popconfirm/index.cjs +6 -0
- package/lib/cjs/components/popconfirm/index.cjs.map +1 -0
- package/lib/cjs/components/popconfirm/popconfirm.cjs +86 -0
- package/lib/cjs/components/popconfirm/popconfirm.cjs.map +1 -0
- package/lib/cjs/components/popup/content.cjs +56 -0
- package/lib/cjs/components/popup/content.cjs.map +1 -0
- package/lib/cjs/components/popup/index.cjs +6 -0
- package/lib/cjs/components/popup/index.cjs.map +1 -0
- package/lib/cjs/components/popup/popup.cjs +425 -0
- package/lib/cjs/components/popup/popup.cjs.map +1 -0
- package/lib/cjs/components/progress/circle.cjs +45 -0
- package/lib/cjs/components/progress/circle.cjs.map +1 -0
- package/lib/cjs/components/progress/index.cjs +6 -0
- package/lib/cjs/components/progress/index.cjs.map +1 -0
- package/lib/cjs/components/progress/line.cjs +27 -0
- package/lib/cjs/components/progress/line.cjs.map +1 -0
- package/lib/cjs/components/progress/progress.cjs +100 -0
- package/lib/cjs/components/progress/progress.cjs.map +1 -0
- package/lib/cjs/components/radio/index.cjs +6 -0
- package/lib/cjs/components/radio/index.cjs.map +1 -0
- package/lib/cjs/components/radio/item.cjs +34 -0
- package/lib/cjs/components/radio/item.cjs.map +1 -0
- package/lib/cjs/components/radio/radio.cjs +62 -0
- package/lib/cjs/components/radio/radio.cjs.map +1 -0
- package/lib/cjs/components/resizable/index.cjs +6 -0
- package/lib/cjs/components/resizable/index.cjs.map +1 -0
- package/lib/cjs/components/resizable/resizable.cjs +81 -0
- package/lib/cjs/components/resizable/resizable.cjs.map +1 -0
- package/lib/cjs/components/river/index.cjs +6 -0
- package/lib/cjs/components/river/index.cjs.map +1 -0
- package/lib/cjs/components/river/river.cjs +116 -0
- package/lib/cjs/components/river/river.cjs.map +1 -0
- package/lib/cjs/components/select/index.cjs +6 -0
- package/lib/cjs/components/select/index.cjs.map +1 -0
- package/lib/cjs/components/select/options.cjs +76 -0
- package/lib/cjs/components/select/options.cjs.map +1 -0
- package/lib/cjs/components/select/select.cjs +155 -0
- package/lib/cjs/components/select/select.cjs.map +1 -0
- package/lib/cjs/components/step/divider.cjs +10 -0
- package/lib/cjs/components/step/divider.cjs.map +1 -0
- package/lib/cjs/components/step/index.cjs +6 -0
- package/lib/cjs/components/step/index.cjs.map +1 -0
- package/lib/cjs/components/step/item.cjs +60 -0
- package/lib/cjs/components/step/item.cjs.map +1 -0
- package/lib/cjs/components/step/step.cjs +42 -0
- package/lib/cjs/components/step/step.cjs.map +1 -0
- package/lib/cjs/components/swiper/index.cjs +6 -0
- package/lib/cjs/components/swiper/index.cjs.map +1 -0
- package/lib/cjs/components/swiper/item.cjs +39 -0
- package/lib/cjs/components/swiper/item.cjs.map +1 -0
- package/lib/cjs/components/swiper/swiper.cjs +262 -0
- package/lib/cjs/components/swiper/swiper.cjs.map +1 -0
- package/lib/cjs/components/tabs/index.cjs +6 -0
- package/lib/cjs/components/tabs/index.cjs.map +1 -0
- package/lib/cjs/components/tabs/item.cjs +10 -0
- package/lib/cjs/components/tabs/item.cjs.map +1 -0
- package/lib/cjs/components/tabs/tabs.cjs +272 -0
- package/lib/cjs/components/tabs/tabs.cjs.map +1 -0
- package/lib/cjs/components/tag/index.cjs +6 -0
- package/lib/cjs/components/tag/index.cjs.map +1 -0
- package/lib/cjs/components/tag/tag.cjs +32 -0
- package/lib/cjs/components/tag/tag.cjs.map +1 -0
- package/lib/cjs/components/text/highlight.cjs +35 -0
- package/lib/cjs/components/text/highlight.cjs.map +1 -0
- package/lib/cjs/components/text/index.cjs +6 -0
- package/lib/cjs/components/text/index.cjs.map +1 -0
- package/lib/cjs/components/text/number.cjs +32 -0
- package/lib/cjs/components/text/number.cjs.map +1 -0
- package/lib/cjs/components/text/text.cjs +39 -0
- package/lib/cjs/components/text/text.cjs.map +1 -0
- package/lib/cjs/components/text/time.cjs +24 -0
- package/lib/cjs/components/text/time.cjs.map +1 -0
- package/lib/cjs/components/tree/index.cjs +6 -0
- package/lib/cjs/components/tree/index.cjs.map +1 -0
- package/lib/cjs/components/tree/item.cjs +136 -0
- package/lib/cjs/components/tree/item.cjs.map +1 -0
- package/lib/cjs/components/tree/tree.cjs +127 -0
- package/lib/cjs/components/tree/tree.cjs.map +1 -0
- package/lib/cjs/components/upload/index.cjs +6 -0
- package/lib/cjs/components/upload/index.cjs.map +1 -0
- package/lib/cjs/components/upload/renderFile.cjs +99 -0
- package/lib/cjs/components/upload/renderFile.cjs.map +1 -0
- package/lib/cjs/components/upload/upload.cjs +165 -0
- package/lib/cjs/components/upload/upload.cjs.map +1 -0
- package/lib/cjs/components/utils/empty/index.cjs +17 -0
- package/lib/cjs/components/utils/empty/index.cjs.map +1 -0
- package/lib/cjs/components/utils/helpericon/helpericon.cjs +24 -0
- package/lib/cjs/components/utils/helpericon/helpericon.cjs.map +1 -0
- package/lib/cjs/components/utils/helpericon/index.cjs +6 -0
- package/lib/cjs/components/utils/helpericon/index.cjs.map +1 -0
- package/lib/cjs/components/video/index.cjs +6 -0
- package/lib/cjs/components/video/index.cjs.map +1 -0
- package/lib/cjs/components/video/video.cjs +237 -0
- package/lib/cjs/components/video/video.cjs.map +1 -0
- package/lib/cjs/index.cjs +83 -0
- package/lib/cjs/js/hooks.cjs +259 -0
- package/lib/cjs/js/hooks.cjs.map +1 -0
- package/lib/cjs/js/usePreview/content.cjs +197 -0
- package/lib/cjs/js/usePreview/content.cjs.map +1 -0
- package/lib/cjs/js/usePreview/index.cjs +39 -0
- package/lib/cjs/js/usePreview/index.cjs.map +1 -0
- package/lib/cjs/js/usePreview/renderFile.cjs +28 -0
- package/lib/cjs/js/usePreview/renderFile.cjs.map +1 -0
- package/lib/cjs/js/usePreview/type.cjs +15 -0
- package/lib/cjs/js/usePreview/type.cjs.map +1 -0
- package/lib/cjs/js/useRipple/index.cjs +45 -0
- package/lib/cjs/js/useRipple/index.cjs.map +1 -0
- package/lib/cjs/js/useTheme/index.cjs +30 -0
- package/lib/cjs/js/useTheme/index.cjs.map +1 -0
- package/lib/cjs/js/utils.cjs +284 -0
- package/lib/cjs/js/utils.cjs.map +1 -0
- package/lib/es/components/affix/affix.js +1 -1
- package/lib/es/components/affix/affix.js.map +1 -1
- package/lib/es/components/affix/totop.js +1 -1
- package/lib/es/components/affix/totop.js.map +1 -1
- package/lib/es/components/badge/badge.js.map +1 -1
- package/lib/es/components/button/button.js.map +1 -1
- package/lib/es/components/card/card.js.map +1 -1
- package/lib/es/components/checkbox/checkbox.js.map +1 -1
- package/lib/es/components/collapse/collapse.js +1 -2
- package/lib/es/components/collapse/collapse.js.map +1 -1
- package/lib/es/components/datagrid/datagrid.js.map +1 -1
- package/lib/es/components/description/description.js.map +1 -1
- package/lib/es/components/drawer/drawer.js.map +1 -1
- package/lib/es/components/dropdown/dropdown.js.map +1 -1
- package/lib/es/components/editor/controls.js +1 -7
- package/lib/es/components/editor/controls.js.map +1 -1
- package/lib/es/components/editor/editor.js.map +1 -1
- package/lib/es/components/flex/flex.js.map +1 -1
- package/lib/es/components/form/field.js +1 -1
- package/lib/es/components/form/form.js +1 -1
- package/lib/es/components/form/form.js.map +1 -1
- package/lib/es/components/form/useForm.js +2 -2
- package/lib/es/components/icon/icon.js.map +1 -1
- package/lib/es/components/image/image.js.map +1 -1
- package/lib/es/components/input/input.js +1 -2
- package/lib/es/components/input/input.js.map +1 -1
- package/lib/es/components/input/number.js +1 -3
- package/lib/es/components/input/number.js.map +1 -1
- package/lib/es/components/input/range.js +1 -3
- package/lib/es/components/input/range.js.map +1 -1
- package/lib/es/components/input/textarea.js.map +1 -1
- package/lib/es/components/list/list.js.map +1 -1
- package/lib/es/components/loading/loading.js.map +1 -1
- package/lib/es/components/message/message.js +2 -2
- package/lib/es/components/message/message.js.map +1 -1
- package/lib/es/components/modal/content.js.map +1 -1
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/pagination/pagination.js +1 -3
- package/lib/es/components/pagination/pagination.js.map +1 -1
- package/lib/es/components/picker/colors/footer.js +1 -1
- package/lib/es/components/picker/colors/footer.js.map +1 -1
- package/lib/es/components/picker/colors/index.js.map +1 -1
- package/lib/es/components/picker/dates/index.js +2 -2
- package/lib/es/components/picker/dates/index.js.map +1 -1
- package/lib/es/components/picker/dates/panel.js +2 -3
- package/lib/es/components/picker/dates/panel.js.map +1 -1
- package/lib/es/components/picker/time/index.js +1 -1
- package/lib/es/components/picker/time/index.js.map +1 -1
- package/lib/es/components/picker/time/panel.js.map +1 -1
- package/lib/es/components/popconfirm/popconfirm.js +1 -1
- package/lib/es/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/es/components/popup/popup.js +1 -1
- package/lib/es/components/popup/popup.js.map +1 -1
- package/lib/es/components/progress/progress.js.map +1 -1
- package/lib/es/components/radio/radio.js.map +1 -1
- package/lib/es/components/resizable/resizable.js.map +1 -1
- package/lib/es/components/river/river.js.map +1 -1
- package/lib/es/components/select/options.js +1 -2
- package/lib/es/components/select/options.js.map +1 -1
- package/lib/es/components/select/select.js +2 -2
- package/lib/es/components/select/select.js.map +1 -1
- package/lib/es/components/step/divider.js.map +1 -1
- package/lib/es/components/step/item.js +1 -1
- package/lib/es/components/step/item.js.map +1 -1
- package/lib/es/components/step/step.js.map +1 -1
- package/lib/es/components/swiper/swiper.js +1 -2
- package/lib/es/components/swiper/swiper.js.map +1 -1
- package/lib/es/components/tabs/tabs.js +1 -1
- package/lib/es/components/tabs/tabs.js.map +1 -1
- package/lib/es/components/tag/tag.js.map +1 -1
- package/lib/es/components/text/highlight.js +1 -1
- package/lib/es/components/text/text.js.map +1 -1
- package/lib/es/components/tree/item.js +1 -1
- package/lib/es/components/tree/item.js.map +1 -1
- package/lib/es/components/tree/tree.js.map +1 -1
- package/lib/es/components/upload/renderFile.js +2 -2
- package/lib/es/components/upload/renderFile.js.map +1 -1
- package/lib/es/components/upload/upload.js +2 -3
- package/lib/es/components/upload/upload.js.map +1 -1
- package/lib/es/components/utils/empty/index.js +1 -1
- package/lib/es/components/utils/empty/index.js.map +1 -1
- package/lib/es/components/utils/helpericon/helpericon.js +2 -2
- package/lib/es/components/utils/helpericon/helpericon.js.map +1 -1
- package/lib/es/components/video/video.js +2 -8
- package/lib/es/components/video/video.js.map +1 -1
- package/lib/es/js/usePreview/content.js +2 -9
- package/lib/es/js/usePreview/content.js.map +1 -1
- package/lib/es/js/usePreview/index.js.map +1 -1
- package/lib/es/js/usePreview/renderFile.js +1 -1
- package/lib/es/js/usePreview/renderFile.js.map +1 -1
- package/lib/es/js/useRipple/index.js.map +1 -1
- package/lib/es/js/utils.js +1 -1
- package/lib/types/components/affix/affix.js +1 -2
- package/lib/types/components/affix/totop.js +1 -1
- package/lib/types/components/badge/badge.js +0 -1
- package/lib/types/components/button/button.js +0 -1
- package/lib/types/components/card/card.js +0 -1
- package/lib/types/components/checkbox/checkbox.js +0 -2
- package/lib/types/components/collapse/collapse.js +1 -3
- package/lib/types/components/datagrid/datagrid.js +0 -1
- package/lib/types/components/description/description.js +0 -1
- package/lib/types/components/drawer/drawer.js +0 -1
- package/lib/types/components/dropdown/dropdown.js +0 -1
- package/lib/types/components/editor/controls.js +1 -7
- package/lib/types/components/editor/editor.js +0 -1
- package/lib/types/components/flex/flex.js +0 -1
- package/lib/types/components/form/field.js +1 -1
- package/lib/types/components/form/form.js +1 -2
- package/lib/types/components/form/useForm.js +2 -2
- package/lib/types/components/icon/icon.js +0 -1
- package/lib/types/components/image/image.js +0 -1
- package/lib/types/components/input/input.js +1 -3
- package/lib/types/components/input/number.js +1 -4
- package/lib/types/components/input/range.js +1 -4
- package/lib/types/components/input/textarea.js +0 -1
- package/lib/types/components/list/list.js +0 -1
- package/lib/types/components/loading/loading.js +0 -1
- package/lib/types/components/message/message.js +2 -3
- package/lib/types/components/modal/content.js +0 -1
- package/lib/types/components/modal/modal.js +0 -1
- package/lib/types/components/pagination/pagination.js +1 -4
- package/lib/types/components/picker/colors/footer.js +1 -1
- package/lib/types/components/picker/colors/index.js +0 -1
- package/lib/types/components/picker/dates/index.js +2 -3
- package/lib/types/components/picker/dates/panel.js +2 -3
- package/lib/types/components/picker/time/index.js +1 -1
- package/lib/types/components/picker/time/panel.js +0 -1
- package/lib/types/components/popconfirm/popconfirm.js +1 -2
- package/lib/types/components/popup/popup.js +1 -2
- package/lib/types/components/progress/progress.js +0 -2
- package/lib/types/components/radio/radio.js +0 -2
- package/lib/types/components/resizable/resizable.js +0 -1
- package/lib/types/components/river/river.js +0 -1
- package/lib/types/components/select/options.js +1 -2
- package/lib/types/components/select/select.js +2 -4
- package/lib/types/components/step/divider.js +0 -1
- package/lib/types/components/step/item.js +1 -1
- package/lib/types/components/step/step.js +0 -1
- package/lib/types/components/swiper/swiper.js +1 -3
- package/lib/types/components/tabs/tabs.js +1 -2
- package/lib/types/components/tag/tag.js +0 -1
- package/lib/types/components/text/highlight.js +1 -1
- package/lib/types/components/text/text.js +0 -1
- package/lib/types/components/tree/item.js +1 -1
- package/lib/types/components/tree/tree.js +0 -1
- package/lib/types/components/upload/renderFile.js +2 -2
- package/lib/types/components/upload/upload.js +2 -4
- package/lib/types/components/utils/empty/index.js +1 -2
- package/lib/types/components/utils/helpericon/helpericon.js +2 -3
- package/lib/types/components/video/video.js +2 -9
- package/lib/types/index.js +0 -1
- package/lib/types/js/usePreview/content.js +2 -9
- package/lib/types/js/usePreview/index.js +0 -1
- package/lib/types/js/usePreview/renderFile.js +1 -1
- package/lib/types/js/useRipple/index.js +0 -1
- package/lib/types/js/utils.js +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_hooks = require("../../js/hooks.cjs");
|
|
3
|
+
const require_utils = require("../../js/utils.cjs");
|
|
4
|
+
const require_content = require("./content.cjs");
|
|
5
|
+
let _Users_iann_codes_ioca_react_node_modules__pnpm_radash_12_1_1_node_modules_radash_dist_esm_index_mjs = require("/Users/iann/codes/ioca-react/node_modules/.pnpm/radash@12.1.1/node_modules/radash/dist/esm/index.mjs");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region packages/components/popup/popup.tsx
|
|
9
|
+
function Popup(props) {
|
|
10
|
+
const { visible = false, content, trigger = "hover", gap = 12, offset = 8, position = "top", showDelay = 16, hideDelay = 12, touchable, arrow = true, align = "center", fitSize, disabled, style, className, children, onVisibleChange } = props;
|
|
11
|
+
const triggerRef = (0, react.useRef)(null);
|
|
12
|
+
const contentRef = (0, react.useRef)(null);
|
|
13
|
+
const timerRef = (0, react.useRef)(null);
|
|
14
|
+
const afterHideTimerRef = (0, react.useRef)(null);
|
|
15
|
+
const rafRef = (0, react.useRef)(null);
|
|
16
|
+
const [show, setShow] = (0, react.useState)(false);
|
|
17
|
+
const showRef = (0, react.useRef)(false);
|
|
18
|
+
showRef.current = show;
|
|
19
|
+
const latestRef = (0, react.useRef)({
|
|
20
|
+
disabled,
|
|
21
|
+
trigger,
|
|
22
|
+
touchable,
|
|
23
|
+
showDelay,
|
|
24
|
+
hideDelay,
|
|
25
|
+
position,
|
|
26
|
+
gap,
|
|
27
|
+
offset,
|
|
28
|
+
align,
|
|
29
|
+
fitSize,
|
|
30
|
+
onVisibleChange
|
|
31
|
+
});
|
|
32
|
+
latestRef.current = {
|
|
33
|
+
disabled,
|
|
34
|
+
trigger,
|
|
35
|
+
touchable,
|
|
36
|
+
showDelay,
|
|
37
|
+
hideDelay,
|
|
38
|
+
position,
|
|
39
|
+
gap,
|
|
40
|
+
offset,
|
|
41
|
+
align,
|
|
42
|
+
fitSize,
|
|
43
|
+
onVisibleChange
|
|
44
|
+
};
|
|
45
|
+
const phaseRef = (0, react.useRef)("");
|
|
46
|
+
const lastPosRef = (0, react.useRef)(null);
|
|
47
|
+
const lastArrowRef = (0, react.useRef)(null);
|
|
48
|
+
const arrowElRef = (0, react.useRef)(null);
|
|
49
|
+
const pointRef = (0, react.useRef)(null);
|
|
50
|
+
const clearTimer = () => {
|
|
51
|
+
if (!timerRef.current) return;
|
|
52
|
+
clearTimeout(timerRef.current);
|
|
53
|
+
timerRef.current = null;
|
|
54
|
+
phaseRef.current = "";
|
|
55
|
+
};
|
|
56
|
+
const clearAllTimers = () => {
|
|
57
|
+
clearTimer();
|
|
58
|
+
if (afterHideTimerRef.current) {
|
|
59
|
+
clearTimeout(afterHideTimerRef.current);
|
|
60
|
+
afterHideTimerRef.current = null;
|
|
61
|
+
}
|
|
62
|
+
if (rafRef.current !== null) {
|
|
63
|
+
cancelAnimationFrame(rafRef.current);
|
|
64
|
+
rafRef.current = null;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const setContentVisible = (visible) => {
|
|
68
|
+
const el = contentRef.current;
|
|
69
|
+
if (!el) return;
|
|
70
|
+
el.style.opacity = visible ? "1" : "0";
|
|
71
|
+
el.style.transform = visible ? "none" : "translate(0, 2px)";
|
|
72
|
+
};
|
|
73
|
+
const ensureBaseStyle = () => {
|
|
74
|
+
const el = contentRef.current;
|
|
75
|
+
if (!el) return;
|
|
76
|
+
const pos = "fixed";
|
|
77
|
+
if (el.style.position !== pos) el.style.position = pos;
|
|
78
|
+
};
|
|
79
|
+
const applyFitSize = () => {
|
|
80
|
+
const o = latestRef.current;
|
|
81
|
+
const triggerEl = triggerRef.current;
|
|
82
|
+
const contentEl = contentRef.current;
|
|
83
|
+
if (!triggerEl || !contentEl) return;
|
|
84
|
+
const vertical = ["top", "bottom"].includes(o.position);
|
|
85
|
+
const key = vertical ? "width" : "height";
|
|
86
|
+
if (!o.fitSize) {
|
|
87
|
+
contentEl.style[key] = "";
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const size = triggerEl[vertical ? "offsetWidth" : "offsetHeight"];
|
|
91
|
+
contentEl.style[key] = typeof size === "number" ? `${size}px` : "";
|
|
92
|
+
};
|
|
93
|
+
const applyArrow = (arrowX, arrowY, arrowPos) => {
|
|
94
|
+
const contentEl = contentRef.current;
|
|
95
|
+
if (!contentEl) return;
|
|
96
|
+
const arrowEl = arrowElRef.current ?? contentEl.querySelector(".i-popup-arrow");
|
|
97
|
+
arrowElRef.current = arrowEl;
|
|
98
|
+
if (!arrowEl) return;
|
|
99
|
+
let left = arrowX ?? 0;
|
|
100
|
+
let top = arrowY ?? 0;
|
|
101
|
+
let transform = "";
|
|
102
|
+
switch (arrowPos) {
|
|
103
|
+
case "left":
|
|
104
|
+
left += 2;
|
|
105
|
+
transform = `translate(-100%, -50%) rotate(180deg)`;
|
|
106
|
+
break;
|
|
107
|
+
case "right":
|
|
108
|
+
left -= 2;
|
|
109
|
+
transform = `translate(0, -50%)`;
|
|
110
|
+
break;
|
|
111
|
+
case "top":
|
|
112
|
+
top -= 2;
|
|
113
|
+
transform = `translate(-50%, -50%) rotate(-90deg)`;
|
|
114
|
+
break;
|
|
115
|
+
case "bottom":
|
|
116
|
+
top += 2;
|
|
117
|
+
transform = `translate(-50%, -50%) rotate(90deg)`;
|
|
118
|
+
break;
|
|
119
|
+
default: break;
|
|
120
|
+
}
|
|
121
|
+
const prev = lastArrowRef.current;
|
|
122
|
+
if (prev && prev.left === left && prev.top === top && prev.transform === transform) return;
|
|
123
|
+
lastArrowRef.current = {
|
|
124
|
+
left,
|
|
125
|
+
top,
|
|
126
|
+
transform
|
|
127
|
+
};
|
|
128
|
+
arrowEl.style.left = `${left}px`;
|
|
129
|
+
arrowEl.style.top = `${top}px`;
|
|
130
|
+
arrowEl.style.transform = transform;
|
|
131
|
+
};
|
|
132
|
+
const applyLeftTop = (left, top) => {
|
|
133
|
+
const contentEl = contentRef.current;
|
|
134
|
+
if (!contentEl) return;
|
|
135
|
+
const prev = lastPosRef.current;
|
|
136
|
+
if (prev && prev.left === left && prev.top === top) return;
|
|
137
|
+
lastPosRef.current = {
|
|
138
|
+
left,
|
|
139
|
+
top
|
|
140
|
+
};
|
|
141
|
+
contentEl.style.left = `${left}px`;
|
|
142
|
+
contentEl.style.top = `${top}px`;
|
|
143
|
+
};
|
|
144
|
+
const computeRelativePosition = () => {
|
|
145
|
+
const triggerEl = triggerRef.current;
|
|
146
|
+
const contentEl = contentRef.current;
|
|
147
|
+
if (!triggerEl || !contentEl) return;
|
|
148
|
+
const o = latestRef.current;
|
|
149
|
+
applyFitSize();
|
|
150
|
+
const [left, top, { arrowX, arrowY, arrowPos }] = require_utils.getPosition(triggerEl, contentEl, {
|
|
151
|
+
position: o.position,
|
|
152
|
+
gap: o.gap,
|
|
153
|
+
offset: o.offset,
|
|
154
|
+
align: o.align,
|
|
155
|
+
refWindow: true
|
|
156
|
+
});
|
|
157
|
+
applyLeftTop(left, top);
|
|
158
|
+
applyArrow(arrowX, arrowY, arrowPos);
|
|
159
|
+
};
|
|
160
|
+
const computePointPosition = () => {
|
|
161
|
+
const contentEl = contentRef.current;
|
|
162
|
+
if (!contentEl) return;
|
|
163
|
+
const point = pointRef.current;
|
|
164
|
+
if (!point) return;
|
|
165
|
+
const [left, top] = require_utils.getPointPosition(point, contentEl);
|
|
166
|
+
applyLeftTop(left, top);
|
|
167
|
+
};
|
|
168
|
+
const scheduleComputePosition = () => {
|
|
169
|
+
if (!showRef.current) return;
|
|
170
|
+
if (rafRef.current !== null) return;
|
|
171
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
172
|
+
rafRef.current = null;
|
|
173
|
+
if (!showRef.current) return;
|
|
174
|
+
ensureBaseStyle();
|
|
175
|
+
if (latestRef.current.trigger === "contextmenu") {
|
|
176
|
+
computePointPosition();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
computeRelativePosition();
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
const handleShow = () => {
|
|
183
|
+
const opts = latestRef.current;
|
|
184
|
+
if (opts.disabled) return;
|
|
185
|
+
clearAllTimers();
|
|
186
|
+
if (showRef.current && (opts.trigger !== "hover" || opts.trigger === "hover" && !opts.touchable)) {
|
|
187
|
+
ensureBaseStyle();
|
|
188
|
+
computeRelativePosition();
|
|
189
|
+
setContentVisible(true);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
phaseRef.current = "showing";
|
|
193
|
+
if (!showRef.current) {
|
|
194
|
+
lastPosRef.current = null;
|
|
195
|
+
lastArrowRef.current = null;
|
|
196
|
+
arrowElRef.current = null;
|
|
197
|
+
setShow(true);
|
|
198
|
+
}
|
|
199
|
+
timerRef.current = setTimeout(() => {
|
|
200
|
+
if (phaseRef.current !== "showing") return;
|
|
201
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
202
|
+
rafRef.current = null;
|
|
203
|
+
if (phaseRef.current !== "showing") return;
|
|
204
|
+
if (!contentRef.current) return;
|
|
205
|
+
ensureBaseStyle();
|
|
206
|
+
if (opts.trigger === "contextmenu") computePointPosition();
|
|
207
|
+
else computeRelativePosition();
|
|
208
|
+
setContentVisible(true);
|
|
209
|
+
opts.onVisibleChange?.(true);
|
|
210
|
+
clearTimer();
|
|
211
|
+
phaseRef.current = "";
|
|
212
|
+
});
|
|
213
|
+
}, opts.showDelay);
|
|
214
|
+
};
|
|
215
|
+
const handleHide = () => {
|
|
216
|
+
if (!showRef.current) return;
|
|
217
|
+
clearAllTimers();
|
|
218
|
+
phaseRef.current = "hiding";
|
|
219
|
+
timerRef.current = setTimeout(() => {
|
|
220
|
+
if (phaseRef.current !== "hiding") {
|
|
221
|
+
clearTimer();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
setContentVisible(false);
|
|
225
|
+
afterHideTimerRef.current = setTimeout(() => {
|
|
226
|
+
afterHideTimerRef.current = null;
|
|
227
|
+
setShow(false);
|
|
228
|
+
clearAllTimers();
|
|
229
|
+
latestRef.current.onVisibleChange?.(false);
|
|
230
|
+
phaseRef.current = "";
|
|
231
|
+
}, 160);
|
|
232
|
+
}, latestRef.current.hideDelay);
|
|
233
|
+
};
|
|
234
|
+
const handleToggle = (action) => {
|
|
235
|
+
if (action !== void 0) {
|
|
236
|
+
action ? handleShow() : handleHide();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
showRef.current ? handleHide() : handleShow();
|
|
240
|
+
};
|
|
241
|
+
const hideRef = (0, react.useRef)(handleHide);
|
|
242
|
+
const toggleRef = (0, react.useRef)(handleToggle);
|
|
243
|
+
hideRef.current = handleHide;
|
|
244
|
+
toggleRef.current = handleToggle;
|
|
245
|
+
const doHide = (0, react.useMemo)(() => () => hideRef.current(), []);
|
|
246
|
+
const doToggle = (0, react.useMemo)(() => (action) => toggleRef.current(action), []);
|
|
247
|
+
const eventMaps = (0, react.useMemo)(() => {
|
|
248
|
+
return {
|
|
249
|
+
click: { onClick: () => doToggle(true) },
|
|
250
|
+
hover: {
|
|
251
|
+
onMouseEnter: () => doToggle(true),
|
|
252
|
+
onMouseLeave: () => doToggle(false)
|
|
253
|
+
},
|
|
254
|
+
focus: {
|
|
255
|
+
onFocus: () => doToggle(true),
|
|
256
|
+
onBlur: () => doToggle(false)
|
|
257
|
+
},
|
|
258
|
+
contextmenu: { onContextMenu: (e) => {
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
e.stopPropagation();
|
|
261
|
+
pointRef.current = {
|
|
262
|
+
pageX: e.pageX,
|
|
263
|
+
pageY: e.pageY
|
|
264
|
+
};
|
|
265
|
+
if (showRef.current) {
|
|
266
|
+
ensureBaseStyle();
|
|
267
|
+
computePointPosition();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
clearAllTimers();
|
|
271
|
+
phaseRef.current = "showing";
|
|
272
|
+
lastPosRef.current = null;
|
|
273
|
+
lastArrowRef.current = null;
|
|
274
|
+
arrowElRef.current = null;
|
|
275
|
+
setShow(true);
|
|
276
|
+
timerRef.current = setTimeout(() => {
|
|
277
|
+
if (phaseRef.current !== "showing") return;
|
|
278
|
+
if (!contentRef.current) return;
|
|
279
|
+
ensureBaseStyle();
|
|
280
|
+
computePointPosition();
|
|
281
|
+
setContentVisible(true);
|
|
282
|
+
clearTimer();
|
|
283
|
+
latestRef.current.onVisibleChange?.(true);
|
|
284
|
+
phaseRef.current = "";
|
|
285
|
+
}, latestRef.current.showDelay);
|
|
286
|
+
} },
|
|
287
|
+
none: {}
|
|
288
|
+
};
|
|
289
|
+
}, [doToggle]);
|
|
290
|
+
const contentTouch = (0, react.useMemo)(() => {
|
|
291
|
+
if (!touchable) return {};
|
|
292
|
+
const events = {};
|
|
293
|
+
if (trigger === "hover") {
|
|
294
|
+
events["onMouseEnter"] = () => {
|
|
295
|
+
clearTimer();
|
|
296
|
+
};
|
|
297
|
+
events["onMouseLeave"] = () => handleToggle(false);
|
|
298
|
+
}
|
|
299
|
+
return events;
|
|
300
|
+
}, [touchable, trigger]);
|
|
301
|
+
const { observe, unobserve, disconnect } = require_hooks.useResizeObserver();
|
|
302
|
+
(0, react.useEffect)(() => {
|
|
303
|
+
if (!observe) return;
|
|
304
|
+
const triggerEl = triggerRef.current;
|
|
305
|
+
const contentEl = contentRef.current;
|
|
306
|
+
if (triggerEl) observe(triggerEl, scheduleComputePosition);
|
|
307
|
+
if (contentEl) observe(contentEl, scheduleComputePosition);
|
|
308
|
+
return () => {
|
|
309
|
+
if (contentEl) unobserve(contentEl);
|
|
310
|
+
if (triggerEl) unobserve(triggerEl);
|
|
311
|
+
disconnect();
|
|
312
|
+
};
|
|
313
|
+
}, [
|
|
314
|
+
trigger,
|
|
315
|
+
observe,
|
|
316
|
+
unobserve,
|
|
317
|
+
disconnect,
|
|
318
|
+
show
|
|
319
|
+
]);
|
|
320
|
+
(0, react.useLayoutEffect)(() => {
|
|
321
|
+
if (!show) return;
|
|
322
|
+
ensureBaseStyle();
|
|
323
|
+
if (latestRef.current.trigger === "contextmenu") computePointPosition();
|
|
324
|
+
else computeRelativePosition();
|
|
325
|
+
}, [show]);
|
|
326
|
+
(0, react.useLayoutEffect)(() => {
|
|
327
|
+
doToggle(visible);
|
|
328
|
+
}, [visible]);
|
|
329
|
+
(0, react.useEffect)(() => {
|
|
330
|
+
return () => {
|
|
331
|
+
clearAllTimers();
|
|
332
|
+
};
|
|
333
|
+
}, []);
|
|
334
|
+
const mouseUpHandlerRef = (0, react.useRef)(() => {});
|
|
335
|
+
mouseUpHandlerRef.current = (e) => {
|
|
336
|
+
if (!showRef.current) return;
|
|
337
|
+
const triggerEl = triggerRef.current;
|
|
338
|
+
const contentEl = contentRef.current;
|
|
339
|
+
if (!triggerEl || !contentEl) return;
|
|
340
|
+
const tar = e.target;
|
|
341
|
+
if (triggerEl.contains(tar) || contentEl.contains(tar)) return;
|
|
342
|
+
doHide();
|
|
343
|
+
};
|
|
344
|
+
require_hooks.useMouseUp((0, react.useMemo)(() => (e) => mouseUpHandlerRef.current(e), []));
|
|
345
|
+
(0, react.useEffect)(() => {
|
|
346
|
+
if (!show) return;
|
|
347
|
+
if (typeof window === "undefined") return;
|
|
348
|
+
const onScrollOrResize = (0, _Users_iann_codes_ioca_react_node_modules__pnpm_radash_12_1_1_node_modules_radash_dist_esm_index_mjs.debounce)({ delay: 160 }, () => {
|
|
349
|
+
scheduleComputePosition();
|
|
350
|
+
});
|
|
351
|
+
window.addEventListener("scroll", onScrollOrResize, {
|
|
352
|
+
passive: true,
|
|
353
|
+
capture: true
|
|
354
|
+
});
|
|
355
|
+
return () => {
|
|
356
|
+
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
357
|
+
};
|
|
358
|
+
}, [show]);
|
|
359
|
+
const mergeRefs = (...refs) => {
|
|
360
|
+
return (node) => {
|
|
361
|
+
for (const ref of refs) {
|
|
362
|
+
if (!ref) continue;
|
|
363
|
+
if (typeof ref === "function") ref(node);
|
|
364
|
+
else ref.current = node;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(() => {
|
|
369
|
+
const events = eventMaps[trigger];
|
|
370
|
+
const items = react.Children.toArray(children);
|
|
371
|
+
const canAttachRef = (el) => {
|
|
372
|
+
if (!(0, react.isValidElement)(el)) return false;
|
|
373
|
+
const t = el.type;
|
|
374
|
+
if (typeof t === "string") return true;
|
|
375
|
+
if (t?.prototype?.isReactComponent) return true;
|
|
376
|
+
if (t?.$$typeof === Symbol.for("react.forward_ref")) return true;
|
|
377
|
+
return false;
|
|
378
|
+
};
|
|
379
|
+
if (items.length !== 1) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
380
|
+
ref: triggerRef,
|
|
381
|
+
...events,
|
|
382
|
+
className: "i-popup-trigger",
|
|
383
|
+
style: { display: "inline-block" },
|
|
384
|
+
children
|
|
385
|
+
});
|
|
386
|
+
const only = items[0];
|
|
387
|
+
if (!(0, react.isValidElement)(only) || !canAttachRef(only)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
388
|
+
ref: triggerRef,
|
|
389
|
+
...events,
|
|
390
|
+
className: "i-popup-trigger",
|
|
391
|
+
style: { display: "inline-block" },
|
|
392
|
+
children: only
|
|
393
|
+
});
|
|
394
|
+
const { className: childClassName, ...restProps } = only.props;
|
|
395
|
+
const nextProps = { ...restProps };
|
|
396
|
+
for (const evt of Object.keys(events)) {
|
|
397
|
+
const theirs = restProps[evt];
|
|
398
|
+
const ours = events[evt];
|
|
399
|
+
nextProps[evt] = typeof theirs === "function" ? (e) => {
|
|
400
|
+
ours(e);
|
|
401
|
+
theirs(e);
|
|
402
|
+
} : ours;
|
|
403
|
+
}
|
|
404
|
+
return (0, react.cloneElement)(only, {
|
|
405
|
+
ref: mergeRefs(only.ref, triggerRef),
|
|
406
|
+
className: childClassName,
|
|
407
|
+
...nextProps
|
|
408
|
+
});
|
|
409
|
+
})(), show && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_content.default, {
|
|
410
|
+
ref: contentRef,
|
|
411
|
+
arrow: arrow && trigger !== "contextmenu",
|
|
412
|
+
style: {
|
|
413
|
+
...style,
|
|
414
|
+
position: "fixed"
|
|
415
|
+
},
|
|
416
|
+
className,
|
|
417
|
+
...contentTouch,
|
|
418
|
+
trigger: triggerRef.current,
|
|
419
|
+
children: content
|
|
420
|
+
})] });
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
423
|
+
exports.default = Popup;
|
|
424
|
+
|
|
425
|
+
//# sourceMappingURL=popup.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popup.cjs","names":[],"sources":["../../../../packages/components/popup/popup.tsx"],"sourcesContent":["import { debounce } from \"radash\";\nimport {\n\tChildren,\n\tMouseEvent,\n\tRef,\n\tcloneElement,\n\tisValidElement,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport { useMouseUp, useResizeObserver } from \"../../js/hooks\";\nimport { getPointPosition, getPosition } from \"../../js/utils\";\nimport Content from \"./content\";\nimport \"./index.css\";\nimport { IPopup } from \"./type\";\n\nexport default function Popup(props: IPopup) {\n\tconst {\n\t\tvisible = false,\n\t\tcontent,\n\t\ttrigger = \"hover\",\n\t\tgap = 12,\n\t\toffset = 8,\n\t\tposition = \"top\",\n\t\tshowDelay = 16,\n\t\thideDelay = 12,\n\t\ttouchable,\n\t\tarrow = true,\n\t\talign = \"center\",\n\t\tfitSize,\n\t\tdisabled,\n\t\tstyle,\n\t\tclassName,\n\t\tchildren,\n\t\tonVisibleChange,\n\t} = props;\n\n\tconst triggerRef = useRef<HTMLElement>(null);\n\tconst contentRef = useRef<HTMLDivElement>(null);\n\tconst timerRef = useRef<any>(null);\n\tconst afterHideTimerRef = useRef<any>(null);\n\tconst rafRef = useRef<number | null>(null);\n\n\tconst [show, setShow] = useState(false);\n\tconst showRef = useRef(false);\n\tshowRef.current = show;\n\n\tconst latestRef = useRef({\n\t\tdisabled,\n\t\ttrigger,\n\t\ttouchable,\n\t\tshowDelay,\n\t\thideDelay,\n\t\tposition,\n\t\tgap,\n\t\toffset,\n\t\talign,\n\t\tfitSize,\n\t\tonVisibleChange,\n\t});\n\tlatestRef.current = {\n\t\tdisabled,\n\t\ttrigger,\n\t\ttouchable,\n\t\tshowDelay,\n\t\thideDelay,\n\t\tposition,\n\t\tgap,\n\t\toffset,\n\t\talign,\n\t\tfitSize,\n\t\tonVisibleChange,\n\t};\n\n\tconst phaseRef = useRef<\"\" | \"showing\" | \"hiding\">(\"\");\n\tconst lastPosRef = useRef<{ left: number; top: number } | null>(null);\n\tconst lastArrowRef = useRef<{\n\t\tleft: number;\n\t\ttop: number;\n\t\ttransform: string;\n\t} | null>(null);\n\tconst arrowElRef = useRef<HTMLElement | null>(null);\n\tconst pointRef = useRef<{ pageX: number; pageY: number } | null>(null);\n\n\tconst clearTimer = () => {\n\t\tif (!timerRef.current) return;\n\t\tclearTimeout(timerRef.current);\n\t\ttimerRef.current = null;\n\t\tphaseRef.current = \"\";\n\t};\n\n\tconst clearAllTimers = () => {\n\t\tclearTimer();\n\t\tif (afterHideTimerRef.current) {\n\t\t\tclearTimeout(afterHideTimerRef.current);\n\t\t\tafterHideTimerRef.current = null;\n\t\t}\n\t\tif (rafRef.current !== null) {\n\t\t\tcancelAnimationFrame(rafRef.current);\n\t\t\trafRef.current = null;\n\t\t}\n\t};\n\n\tconst setContentVisible = (visible: boolean) => {\n\t\tconst el = contentRef.current;\n\t\tif (!el) return;\n\t\tel.style.opacity = visible ? \"1\" : \"0\";\n\t\tel.style.transform = visible ? \"none\" : \"translate(0, 2px)\";\n\t};\n\n\tconst ensureBaseStyle = () => {\n\t\tconst el = contentRef.current;\n\t\tif (!el) return;\n\t\tconst pos = \"fixed\";\n\t\tif (el.style.position !== pos) el.style.position = pos;\n\t};\n\n\tconst applyFitSize = () => {\n\t\tconst o = latestRef.current;\n\t\tconst triggerEl = triggerRef.current;\n\t\tconst contentEl = contentRef.current;\n\t\tif (!triggerEl || !contentEl) return;\n\n\t\tconst vertical = [\"top\", \"bottom\"].includes(o.position);\n\t\tconst key = vertical ? \"width\" : \"height\";\n\t\tif (!o.fitSize) {\n\t\t\t(contentEl.style as any)[key] = \"\";\n\t\t\treturn;\n\t\t}\n\n\t\tconst size = triggerEl[vertical ? \"offsetWidth\" : \"offsetHeight\"];\n\t\t(contentEl.style as any)[key] =\n\t\t\ttypeof size === \"number\" ? `${size}px` : \"\";\n\t};\n\n\tconst applyArrow = (arrowX: number, arrowY: number, arrowPos: string) => {\n\t\tconst contentEl = contentRef.current;\n\t\tif (!contentEl) return;\n\n\t\tconst arrowEl =\n\t\t\tarrowElRef.current ??\n\t\t\t(contentEl.querySelector(\".i-popup-arrow\") as HTMLElement | null);\n\t\tarrowElRef.current = arrowEl;\n\t\tif (!arrowEl) return;\n\n\t\tlet left = arrowX ?? 0;\n\t\tlet top = arrowY ?? 0;\n\t\tlet transform = \"\";\n\n\t\tswitch (arrowPos) {\n\t\t\tcase \"left\":\n\t\t\t\tleft += 2;\n\t\t\t\ttransform = `translate(-100%, -50%) rotate(180deg)`;\n\t\t\t\tbreak;\n\t\t\tcase \"right\":\n\t\t\t\tleft -= 2;\n\t\t\t\ttransform = `translate(0, -50%)`;\n\t\t\t\tbreak;\n\t\t\tcase \"top\":\n\t\t\t\ttop -= 2;\n\t\t\t\ttransform = `translate(-50%, -50%) rotate(-90deg)`;\n\t\t\t\tbreak;\n\t\t\tcase \"bottom\":\n\t\t\t\ttop += 2;\n\t\t\t\ttransform = `translate(-50%, -50%) rotate(90deg)`;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tconst prev = lastArrowRef.current;\n\t\tif (\n\t\t\tprev &&\n\t\t\tprev.left === left &&\n\t\t\tprev.top === top &&\n\t\t\tprev.transform === transform\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tlastArrowRef.current = { left, top, transform };\n\t\tarrowEl.style.left = `${left}px`;\n\t\tarrowEl.style.top = `${top}px`;\n\t\tarrowEl.style.transform = transform;\n\t};\n\n\tconst applyLeftTop = (left: number, top: number) => {\n\t\tconst contentEl = contentRef.current;\n\t\tif (!contentEl) return;\n\n\t\tconst prev = lastPosRef.current;\n\t\tif (prev && prev.left === left && prev.top === top) return;\n\n\t\tlastPosRef.current = { left, top };\n\t\tcontentEl.style.left = `${left}px`;\n\t\tcontentEl.style.top = `${top}px`;\n\t};\n\n\tconst computeRelativePosition = () => {\n\t\tconst triggerEl = triggerRef.current;\n\t\tconst contentEl = contentRef.current;\n\t\tif (!triggerEl || !contentEl) return;\n\n\t\tconst o = latestRef.current;\n\t\tapplyFitSize();\n\n\t\tconst [left, top, { arrowX, arrowY, arrowPos }] = getPosition(\n\t\t\ttriggerEl,\n\t\t\tcontentEl,\n\t\t\t{\n\t\t\t\tposition: o.position,\n\t\t\t\tgap: o.gap,\n\t\t\t\toffset: o.offset,\n\t\t\t\talign: o.align,\n\t\t\t\trefWindow: true,\n\t\t\t},\n\t\t);\n\n\t\tapplyLeftTop(left, top);\n\t\tapplyArrow(arrowX, arrowY, arrowPos);\n\t};\n\n\tconst computePointPosition = () => {\n\t\tconst contentEl = contentRef.current as HTMLElement | null;\n\t\tif (!contentEl) return;\n\t\tconst point = pointRef.current;\n\t\tif (!point) return;\n\n\t\tconst [left, top] = getPointPosition(point as any, contentEl);\n\t\tapplyLeftTop(left, top);\n\t};\n\n\tconst scheduleComputePosition = () => {\n\t\tif (!showRef.current) return;\n\t\tif (rafRef.current !== null) return;\n\t\trafRef.current = requestAnimationFrame(() => {\n\t\t\trafRef.current = null;\n\t\t\tif (!showRef.current) return;\n\t\t\tensureBaseStyle();\n\n\t\t\tif (latestRef.current.trigger === \"contextmenu\") {\n\t\t\t\tcomputePointPosition();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcomputeRelativePosition();\n\t\t});\n\t};\n\n\tconst handleShow = () => {\n\t\tconst opts = latestRef.current;\n\t\tif (opts.disabled) return;\n\t\tclearAllTimers();\n\t\tif (\n\t\t\tshowRef.current &&\n\t\t\t(opts.trigger !== \"hover\" ||\n\t\t\t\t(opts.trigger === \"hover\" && !opts.touchable))\n\t\t) {\n\t\t\tensureBaseStyle();\n\t\t\tcomputeRelativePosition();\n\t\t\tsetContentVisible(true);\n\t\t\treturn;\n\t\t}\n\n\t\tphaseRef.current = \"showing\";\n\t\tif (!showRef.current) {\n\t\t\tlastPosRef.current = null;\n\t\t\tlastArrowRef.current = null;\n\t\t\tarrowElRef.current = null;\n\t\t\tsetShow(true);\n\t\t}\n\n\t\ttimerRef.current = setTimeout(() => {\n\t\t\tif (phaseRef.current !== \"showing\") return;\n\n\t\t\trafRef.current = requestAnimationFrame(() => {\n\t\t\t\trafRef.current = null;\n\t\t\t\tif (phaseRef.current !== \"showing\") return;\n\t\t\t\tif (!contentRef.current) return;\n\n\t\t\t\tensureBaseStyle();\n\t\t\t\tif (opts.trigger === \"contextmenu\") {\n\t\t\t\t\tcomputePointPosition();\n\t\t\t\t} else {\n\t\t\t\t\tcomputeRelativePosition();\n\t\t\t\t}\n\t\t\t\tsetContentVisible(true);\n\t\t\t\topts.onVisibleChange?.(true);\n\t\t\t\tclearTimer();\n\t\t\t\tphaseRef.current = \"\";\n\t\t\t});\n\t\t}, opts.showDelay);\n\t};\n\n\tconst handleHide = () => {\n\t\tif (!showRef.current) return;\n\n\t\tclearAllTimers();\n\t\tphaseRef.current = \"hiding\";\n\t\ttimerRef.current = setTimeout(() => {\n\t\t\tif (phaseRef.current !== \"hiding\") {\n\t\t\t\tclearTimer();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetContentVisible(false);\n\n\t\t\tafterHideTimerRef.current = setTimeout(() => {\n\t\t\t\tafterHideTimerRef.current = null;\n\t\t\t\tsetShow(false);\n\t\t\t\tclearAllTimers();\n\t\t\t\tlatestRef.current.onVisibleChange?.(false);\n\t\t\t\tphaseRef.current = \"\";\n\t\t\t}, 160);\n\t\t}, latestRef.current.hideDelay);\n\t};\n\n\tconst handleToggle = (action?: boolean) => {\n\t\tif (action !== undefined) {\n\t\t\taction ? handleShow() : handleHide();\n\t\t\treturn;\n\t\t}\n\t\tshowRef.current ? handleHide() : handleShow();\n\t};\n\n\tconst hideRef = useRef(handleHide);\n\tconst toggleRef = useRef(handleToggle);\n\thideRef.current = handleHide;\n\ttoggleRef.current = handleToggle;\n\n\tconst doHide = useMemo(() => () => hideRef.current(), []);\n\tconst doToggle = useMemo(\n\t\t() => (action?: boolean) => toggleRef.current(action),\n\t\t[],\n\t);\n\n\tconst eventMaps = useMemo(() => {\n\t\treturn {\n\t\t\tclick: {\n\t\t\t\tonClick: () => doToggle(true),\n\t\t\t},\n\t\t\thover: {\n\t\t\t\tonMouseEnter: () => doToggle(true),\n\t\t\t\tonMouseLeave: () => doToggle(false),\n\t\t\t},\n\t\t\tfocus: {\n\t\t\t\tonFocus: () => doToggle(true),\n\t\t\t\tonBlur: () => doToggle(false),\n\t\t\t},\n\t\t\tcontextmenu: {\n\t\t\t\tonContextMenu: (e: MouseEvent) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\n\t\t\t\t\tpointRef.current = {\n\t\t\t\t\t\tpageX: (e as any).pageX,\n\t\t\t\t\t\tpageY: (e as any).pageY,\n\t\t\t\t\t};\n\n\t\t\t\t\tif (showRef.current) {\n\t\t\t\t\t\tensureBaseStyle();\n\t\t\t\t\t\tcomputePointPosition();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tclearAllTimers();\n\t\t\t\t\tphaseRef.current = \"showing\";\n\t\t\t\t\tlastPosRef.current = null;\n\t\t\t\t\tlastArrowRef.current = null;\n\t\t\t\t\tarrowElRef.current = null;\n\t\t\t\t\tsetShow(true);\n\n\t\t\t\t\ttimerRef.current = setTimeout(() => {\n\t\t\t\t\t\tif (phaseRef.current !== \"showing\") return;\n\t\t\t\t\t\tif (!contentRef.current) return;\n\n\t\t\t\t\t\tensureBaseStyle();\n\t\t\t\t\t\tcomputePointPosition();\n\t\t\t\t\t\tsetContentVisible(true);\n\t\t\t\t\t\tclearTimer();\n\t\t\t\t\t\tlatestRef.current.onVisibleChange?.(true);\n\t\t\t\t\t\tphaseRef.current = \"\";\n\t\t\t\t\t}, latestRef.current.showDelay);\n\t\t\t\t},\n\t\t\t},\n\t\t\tnone: {},\n\t\t};\n\t}, [doToggle]);\n\n\tconst contentTouch = useMemo(() => {\n\t\tif (!touchable) return {};\n\t\tconst events: { [key: string]: () => void } = {};\n\n\t\tif (trigger === \"hover\") {\n\t\t\tevents[\"onMouseEnter\"] = () => {\n\t\t\t\tclearTimer();\n\t\t\t};\n\t\t\tevents[\"onMouseLeave\"] = () => handleToggle(false);\n\t\t}\n\n\t\treturn events;\n\t}, [touchable, trigger]);\n\n\tconst { observe, unobserve, disconnect } = useResizeObserver();\n\tuseEffect(() => {\n\t\tif (!observe) return;\n\t\tconst triggerEl = triggerRef.current;\n\t\tconst contentEl = contentRef.current;\n\t\tif (triggerEl) observe(triggerEl, scheduleComputePosition);\n\t\tif (contentEl) observe(contentEl, scheduleComputePosition);\n\t\treturn () => {\n\t\t\tif (contentEl) unobserve(contentEl);\n\t\t\tif (triggerEl) unobserve(triggerEl);\n\t\t\tdisconnect();\n\t\t};\n\t}, [trigger, observe, unobserve, disconnect, show]);\n\n\tuseLayoutEffect(() => {\n\t\tif (!show) return;\n\t\tensureBaseStyle();\n\t\tif (latestRef.current.trigger === \"contextmenu\") {\n\t\t\tcomputePointPosition();\n\t\t} else {\n\t\t\tcomputeRelativePosition();\n\t\t}\n\t}, [show]);\n\n\tuseLayoutEffect(() => {\n\t\tdoToggle(visible);\n\t}, [visible]);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tclearAllTimers();\n\t\t};\n\t}, []);\n\n\tconst mouseUpHandlerRef = useRef<(e: any) => void>(() => {});\n\tmouseUpHandlerRef.current = (e) => {\n\t\tif (!showRef.current) return;\n\t\tconst triggerEl = triggerRef.current;\n\t\tconst contentEl = contentRef.current;\n\t\tif (!triggerEl || !contentEl) return;\n\t\tconst tar = e.target as HTMLElement;\n\t\tif (triggerEl.contains(tar) || contentEl.contains(tar)) return;\n\t\tdoHide();\n\t};\n\tconst onGlobalMouseUp = useMemo(\n\t\t() => (e: any) => mouseUpHandlerRef.current(e),\n\t\t[],\n\t);\n\tuseMouseUp(onGlobalMouseUp);\n\n\tuseEffect(() => {\n\t\tif (!show) return;\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst onScrollOrResize = debounce({ delay: 160 }, () => {\n\t\t\tscheduleComputePosition();\n\t\t});\n\n\t\twindow.addEventListener(\"scroll\", onScrollOrResize, {\n\t\t\tpassive: true,\n\t\t\tcapture: true,\n\t\t});\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"scroll\", onScrollOrResize, true);\n\t\t};\n\t}, [show]);\n\n\tconst mergeRefs = (...refs: Array<Ref<HTMLElement> | undefined>) => {\n\t\treturn (node: HTMLElement | null) => {\n\t\t\tfor (const ref of refs) {\n\t\t\t\tif (!ref) continue;\n\t\t\t\tif (typeof ref === \"function\") {\n\t\t\t\t\tref(node);\n\t\t\t\t} else {\n\t\t\t\t\t(ref as any).current = node;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{(() => {\n\t\t\t\tconst events = eventMaps[trigger] as any;\n\t\t\t\tconst items = Children.toArray(children);\n\t\t\t\tconst canAttachRef = (el: any) => {\n\t\t\t\t\tif (!isValidElement(el)) return false;\n\t\t\t\t\tconst t: any = el.type;\n\t\t\t\t\tif (typeof t === \"string\") return true;\n\t\t\t\t\tif (t?.prototype?.isReactComponent) return true;\n\t\t\t\t\tif (t?.$$typeof === Symbol.for(\"react.forward_ref\"))\n\t\t\t\t\t\treturn true;\n\t\t\t\t\treturn false;\n\t\t\t\t};\n\n\t\t\t\tif (items.length !== 1) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={triggerRef as any}\n\t\t\t\t\t\t\t{...events}\n\t\t\t\t\t\t\tclassName='i-popup-trigger'\n\t\t\t\t\t\t\tstyle={{ display: \"inline-block\" }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst only = items[0] as any;\n\t\t\t\tif (!isValidElement(only) || !canAttachRef(only)) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={triggerRef as any}\n\t\t\t\t\t\t\t{...events}\n\t\t\t\t\t\t\tclassName='i-popup-trigger'\n\t\t\t\t\t\t\tstyle={{ display: \"inline-block\" }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{only}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst { className: childClassName, ...restProps } =\n\t\t\t\t\tonly.props as any;\n\t\t\t\tconst nextProps: Record<string, any> = { ...restProps };\n\t\t\t\tfor (const evt of Object.keys(events)) {\n\t\t\t\t\tconst theirs = restProps[evt];\n\t\t\t\t\tconst ours = events[evt];\n\t\t\t\t\tnextProps[evt] =\n\t\t\t\t\t\ttypeof theirs === \"function\"\n\t\t\t\t\t\t\t? (e: any) => {\n\t\t\t\t\t\t\t\t\tours(e);\n\t\t\t\t\t\t\t\t\ttheirs(e);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: ours;\n\t\t\t\t}\n\t\t\t\treturn cloneElement(only as any, {\n\t\t\t\t\tref: mergeRefs((only as any).ref, triggerRef as any),\n\t\t\t\t\tclassName: childClassName,\n\t\t\t\t\t...nextProps,\n\t\t\t\t});\n\t\t\t})()}\n\n\t\t\t{show && (\n\t\t\t\t<Content\n\t\t\t\t\tref={contentRef}\n\t\t\t\t\tarrow={arrow && trigger !== \"contextmenu\"}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tposition: \"fixed\",\n\t\t\t\t\t}}\n\t\t\t\t\tclassName={className}\n\t\t\t\t\t{...contentTouch}\n\t\t\t\t\ttrigger={triggerRef.current as HTMLElement}\n\t\t\t\t>\n\t\t\t\t\t{content}\n\t\t\t\t</Content>\n\t\t\t)}\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;;CAmBA,MAAO,EACN,UAAM,OACL,SACA,UAAO,SACP,MAAA,IACA,SAAQ,GACR,WAAU,OACV,YAAY,IACZ,YAAY,IACZ,WACA,QAAA,MACA,QAAQ,UACR,SACA,UACA,OACA,WACA,UACA,oBACA;;CAGD,MAAM,cAAA,GAAA,MAAA,QAAiC,KAAK;CAC5C,MAAM,YAAA,GAAA,MAAA,QAAoB,KAAA;CAC1B,MAAM,qBAAA,GAAA,MAAA,QAA4B,KAAA;CAClC,MAAM,UAAA,GAAA,MAAA,QAA+B,KAAK;;CAG1C,MAAM,WAAA,GAAA,MAAA,QAAiB,MAAC;AACxB,SAAM,UAAU;;EAGhB;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,CAAA;AACD,WAAE,UAAA;EACF;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;CAGD,MAAM,cAAA,GAAA,MAAA,QAAgD,KAAA;CACtD,MAAM,gBAAA,GAAA,MAAA,QAII,KAAE;CACZ,MAAI,cAAA,GAAA,MAAA,QAAW,KAAA;CACf,MAAM,YAAA,GAAA,MAAA,QAA6C,KAAA;;AAGnD,MAAK,CAAC,SAAA,QAAkB;AACvB,eAAa,SAAS,QAAO;AAC7B,WAAA,UAAa;AACb,WAAS,UAAU;;;AA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ACA,OAAK,SAAU,YAAA;EACf,OAAO;GACP,GAAA;GACC,UAAQ;GACR;EACA;EACD,GAAA;EACA,SAAI,WAAY;YAEjB;EACS,CAAA,CAET,EAAA,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_index = require("../text/index.cjs");
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
//#region packages/components/progress/circle.tsx
|
|
5
|
+
function Circle(props) {
|
|
6
|
+
const { value, circleSize = 40, lineWidth = 8 } = props;
|
|
7
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8
|
+
className: "i-progress-circle",
|
|
9
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
10
|
+
width: circleSize,
|
|
11
|
+
height: circleSize,
|
|
12
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
13
|
+
cx: circleSize / 2,
|
|
14
|
+
cy: circleSize / 2,
|
|
15
|
+
r: circleSize / 2 - lineWidth / 2,
|
|
16
|
+
fill: "none",
|
|
17
|
+
stroke: "var(--background-opacity-2)",
|
|
18
|
+
strokeWidth: lineWidth
|
|
19
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
20
|
+
cx: circleSize / 2,
|
|
21
|
+
cy: circleSize / 2,
|
|
22
|
+
r: circleSize / 2 - lineWidth / 2,
|
|
23
|
+
fill: "none",
|
|
24
|
+
stroke: "var(--color-main)",
|
|
25
|
+
strokeWidth: lineWidth,
|
|
26
|
+
strokeDasharray: 100,
|
|
27
|
+
pathLength: 100,
|
|
28
|
+
className: "i-progress-circle-path",
|
|
29
|
+
strokeLinecap: "round",
|
|
30
|
+
style: { strokeDashoffset: `calc(100 - ${value})` }
|
|
31
|
+
})]
|
|
32
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
33
|
+
className: "i-progress-circle-value",
|
|
34
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: value }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
|
|
35
|
+
size: ".81em",
|
|
36
|
+
className: "color-7",
|
|
37
|
+
children: "%"
|
|
38
|
+
})]
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.default = Circle;
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=circle.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle.cjs","names":["Text"],"sources":["../../../../packages/components/progress/circle.tsx"],"sourcesContent":["import Text from \"../text\";\nimport { IProgress } from \"./type\";\n\nexport default function Circle(\n\tprops: Pick<IProgress, \"value\" | \"circleSize\" | \"lineWidth\">\n) {\n\tconst { value, circleSize = 40, lineWidth = 8 } = props;\n\n\treturn (\n\t\t<div className='i-progress-circle'>\n\t\t\t<svg width={circleSize} height={circleSize}>\n\t\t\t\t<circle\n\t\t\t\t\tcx={circleSize / 2}\n\t\t\t\t\tcy={circleSize / 2}\n\t\t\t\t\tr={circleSize / 2 - lineWidth / 2}\n\t\t\t\t\tfill='none'\n\t\t\t\t\tstroke='var(--background-opacity-2)'\n\t\t\t\t\tstrokeWidth={lineWidth}\n\t\t\t\t/>\n\t\t\t\t<circle\n\t\t\t\t\tcx={circleSize / 2}\n\t\t\t\t\tcy={circleSize / 2}\n\t\t\t\t\tr={circleSize / 2 - lineWidth / 2}\n\t\t\t\t\tfill='none'\n\t\t\t\t\tstroke='var(--color-main)'\n\t\t\t\t\tstrokeWidth={lineWidth}\n\t\t\t\t\tstrokeDasharray={100}\n\t\t\t\t\tpathLength={100}\n\t\t\t\t\tclassName='i-progress-circle-path'\n\t\t\t\t\tstrokeLinecap='round'\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tstrokeDashoffset: `calc(100 - ${value})`,\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</svg>\n\n\t\t\t<span className='i-progress-circle-value'>\n\t\t\t\t<span>{value}</span>\n\t\t\t\t<Text size='.81em' className='color-7'>\n\t\t\t\t\t%\n\t\t\t\t</Text>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;AAGA,SAAwB,OACvB,OACC;CACD,MAAM,EAAE,OAAO,aAAa,IAAI,YAAY,MAAM;AAElD,QACC,iBAAA,GAAA,kBAAA,MAAC,OAAD;EAAK,WAAU;YAAf,CACC,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,OAAO;GAAY,QAAQ;aAAhC,CACC,iBAAA,GAAA,kBAAA,KAAC,UAAD;IACC,IAAI,aAAa;IACjB,IAAI,aAAa;IACjB,GAAG,aAAa,IAAI,YAAY;IAChC,MAAK;IACL,QAAO;IACP,aAAa;IACZ,CAAA,EACF,iBAAA,GAAA,kBAAA,KAAC,UAAD;IACC,IAAI,aAAa;IACjB,IAAI,aAAa;IACjB,GAAG,aAAa,IAAI,YAAY;IAChC,MAAK;IACL,QAAO;IACP,aAAa;IACb,iBAAiB;IACjB,YAAY;IACZ,WAAU;IACV,eAAc;IACd,OAAO,EACN,kBAAkB,cAAc,MAAM,IACtC;IACA,CAAA,CACG;MAEN,iBAAA,GAAA,kBAAA,MAAC,QAAD;GAAM,WAAU;aAAhB,CACC,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAA,UAAO,OAAa,CAAA,EACpB,iBAAA,GAAA,kBAAA,KAACA,cAAAA,SAAD;IAAM,MAAK;IAAQ,WAAU;cAAU;IAEhC,CAAA,CACD;KACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Progress"],"sources":["../../../../packages/components/progress/index.tsx"],"sourcesContent":["import Progress from \"./progress\";\n\nexport default Progress;\n"],"mappings":";AAEA,IAAA,6CAAeA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let classnames = require("classnames");
|
|
3
|
+
classnames = require_runtime.__toESM(classnames);
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region packages/components/progress/line.tsx
|
|
6
|
+
const Line = (props) => {
|
|
7
|
+
const { ref, value, lineWidth, vertical, barClass, dragging, renderCursor, onMouseDown, onTouchStart } = props;
|
|
8
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9
|
+
ref,
|
|
10
|
+
className: (0, classnames.default)("i-progress", { "i-progress-vertical": vertical }),
|
|
11
|
+
style: { [vertical ? "width" : "height"]: lineWidth },
|
|
12
|
+
onMouseDown,
|
|
13
|
+
onTouchStart,
|
|
14
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15
|
+
className: (0, classnames.default)("i-progress-bar", barClass, { "no-transition": dragging }),
|
|
16
|
+
style: { [vertical ? "height" : "width"]: `${value}%` },
|
|
17
|
+
children: renderCursor && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
18
|
+
className: "i-progress-cursor",
|
|
19
|
+
children: renderCursor(value ?? 0)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.default = Line;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=line.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.cjs","names":[],"sources":["../../../../packages/components/progress/line.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { MouseEvent, RefObject } from \"react\";\nimport { IProgress } from \"./type\";\n\nconst Line = (\n\tprops: Pick<\n\t\tIProgress,\n\t\t\"value\" | \"vertical\" | \"lineWidth\" | \"barClass\" | \"renderCursor\"\n\t> & {\n\t\tref: RefObject<HTMLDivElement | null>;\n\t\tdragging: boolean;\n\t\tonMouseDown: (e: MouseEvent) => void;\n\t\tonTouchStart: (e) => void;\n\t}\n) => {\n\tconst {\n\t\tref,\n\t\tvalue,\n\t\tlineWidth,\n\t\tvertical,\n\t\tbarClass,\n\t\tdragging,\n\t\trenderCursor,\n\t\tonMouseDown,\n\t\tonTouchStart,\n\t} = props;\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-progress\", {\n\t\t\t\t\"i-progress-vertical\": vertical,\n\t\t\t})}\n\t\t\tstyle={{ [vertical ? \"width\" : \"height\"]: lineWidth }}\n\t\t\tonMouseDown={onMouseDown}\n\t\t\tonTouchStart={onTouchStart}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-progress-bar\", barClass, {\n\t\t\t\t\t\"no-transition\": dragging,\n\t\t\t\t})}\n\t\t\t\tstyle={{ [vertical ? \"height\" : \"width\"]: `${value}%` }}\n\t\t\t>\n\t\t\t\t{renderCursor && (\n\t\t\t\t\t<a className='i-progress-cursor'>\n\t\t\t\t\t\t{renderCursor(value ?? 0)}\n\t\t\t\t\t</a>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default Line;\n"],"mappings":";;;;;AAIA,MAAM,QACL,UASI;CACJ,MAAM,EACL,KACA,OACA,WACA,UACA,UACA,UACA,cACA,aACA,iBACG;AAEJ,QACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACM;EACL,YAAA,GAAA,WAAA,SAAsB,cAAc,EACnC,uBAAuB,UACvB,CAAC;EACF,OAAO,GAAG,WAAW,UAAU,WAAW,WAAW;EACxC;EACC;YAEd,iBAAA,GAAA,kBAAA,KAAC,OAAD;GACC,YAAA,GAAA,WAAA,SAAsB,kBAAkB,UAAU,EACjD,iBAAiB,UACjB,CAAC;GACF,OAAO,GAAG,WAAW,WAAW,UAAU,GAAG,MAAM,IAAI;aAEtD,gBACA,iBAAA,GAAA,kBAAA,KAAC,KAAD;IAAG,WAAU;cACX,aAAa,SAAS,EAAE;IACtB,CAAA;GAEA,CAAA;EACD,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_hooks = require("../../js/hooks.cjs");
|
|
3
|
+
const require_circle = require("./circle.cjs");
|
|
4
|
+
const require_line = require("./line.cjs");
|
|
5
|
+
let classnames = require("classnames");
|
|
6
|
+
classnames = require_runtime.__toESM(classnames);
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
//#region packages/components/progress/progress.tsx
|
|
10
|
+
const Progress = (props) => {
|
|
11
|
+
const { value = 0, lineWidth = 8, circleSize = 40, precision = 0, style, draggable = true, type = "line", barClass, vertical, label, labelInline, className, renderCursor, onChange, onDraggingChange } = props;
|
|
12
|
+
const ref = (0, react.useRef)(null);
|
|
13
|
+
const state = require_hooks.useReactive({
|
|
14
|
+
value,
|
|
15
|
+
dragging: false,
|
|
16
|
+
size: 0,
|
|
17
|
+
start: 0
|
|
18
|
+
});
|
|
19
|
+
const pageXY = vertical ? "pageY" : "pageX";
|
|
20
|
+
const rectTL = vertical ? "top" : "left";
|
|
21
|
+
const rectWH = vertical ? "height" : "width";
|
|
22
|
+
const getFixedValue = () => {
|
|
23
|
+
let value = +state.value.toFixed(precision);
|
|
24
|
+
value = Math.min(100, value);
|
|
25
|
+
value = Math.max(0, value);
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
const handleMouseDown = (e) => {
|
|
29
|
+
if (!ref.current || !draggable) return;
|
|
30
|
+
if (e.touches) e = e.touches[0];
|
|
31
|
+
const rect = ref.current.getBoundingClientRect();
|
|
32
|
+
const value = (e[pageXY] - rect[rectTL]) * 100 / rect[rectWH];
|
|
33
|
+
Object.assign(state, {
|
|
34
|
+
value: vertical ? 100 - value : value,
|
|
35
|
+
size: rect[rectWH],
|
|
36
|
+
start: rect[rectTL],
|
|
37
|
+
dragging: true
|
|
38
|
+
});
|
|
39
|
+
onDraggingChange?.(true);
|
|
40
|
+
};
|
|
41
|
+
const handleMouseMove = (e) => {
|
|
42
|
+
if (!state.dragging || !draggable) return;
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
if (e.touches) e = e.touches[0];
|
|
45
|
+
const { start, size } = state;
|
|
46
|
+
const offset = e[pageXY] - start;
|
|
47
|
+
if (offset < 0 || offset > size) return;
|
|
48
|
+
const value = (e[pageXY] - start) * 100 / size;
|
|
49
|
+
state.value = vertical ? 100 - value : value;
|
|
50
|
+
};
|
|
51
|
+
const handleMouseUp = () => {
|
|
52
|
+
if (!state.dragging || !draggable) return;
|
|
53
|
+
onChange?.(getFixedValue());
|
|
54
|
+
state.dragging = false;
|
|
55
|
+
onDraggingChange?.(false);
|
|
56
|
+
};
|
|
57
|
+
require_hooks.useMouseMove(handleMouseMove);
|
|
58
|
+
require_hooks.useMouseUp(handleMouseUp);
|
|
59
|
+
(0, react.useEffect)(() => {
|
|
60
|
+
if (value > 100) {
|
|
61
|
+
state.value = 100;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (value < 0) {
|
|
65
|
+
state.value = 0;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
state.value = value;
|
|
69
|
+
}, [value]);
|
|
70
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
71
|
+
className: (0, classnames.default)("i-input-label", className, { "i-input-inline": labelInline }),
|
|
72
|
+
style,
|
|
73
|
+
children: [
|
|
74
|
+
label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
75
|
+
className: "i-input-label-text",
|
|
76
|
+
children: label
|
|
77
|
+
}),
|
|
78
|
+
type === "line" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_line.default, {
|
|
79
|
+
ref,
|
|
80
|
+
vertical,
|
|
81
|
+
lineWidth,
|
|
82
|
+
barClass,
|
|
83
|
+
dragging: state.dragging,
|
|
84
|
+
value: state.value,
|
|
85
|
+
renderCursor,
|
|
86
|
+
onMouseDown: handleMouseDown,
|
|
87
|
+
onTouchStart: handleMouseDown
|
|
88
|
+
}),
|
|
89
|
+
type === "circle" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_circle.default, {
|
|
90
|
+
value: state.value,
|
|
91
|
+
circleSize,
|
|
92
|
+
lineWidth
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
exports.default = Progress;
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=progress.cjs.map
|