@ioca/react 1.5.19 → 1.5.21
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/css/index.css +1 -2
- package/lib/es/components/affix/affix.js +1 -1
- package/lib/es/components/affix/index.js +0 -1
- package/lib/es/components/affix/totop.js +0 -1
- package/lib/es/components/badge/badge.js +1 -1
- package/lib/es/components/badge/index.js +0 -1
- package/lib/es/components/button/button.js +1 -1
- package/lib/es/components/button/confirm.js +0 -1
- package/lib/es/components/button/group.js +0 -1
- package/lib/es/components/button/index.js +0 -1
- package/lib/es/components/button/toggle.js +0 -1
- package/lib/es/components/card/card.js +1 -1
- package/lib/es/components/card/index.js +0 -1
- package/lib/es/components/checkbox/checkbox.js +2 -1
- package/lib/es/components/checkbox/index.js +0 -1
- package/lib/es/components/checkbox/item.js +0 -1
- package/lib/es/components/collapse/collapse.js +1 -1
- package/lib/es/components/collapse/index.js +0 -1
- package/lib/es/components/collapse/item.js +0 -1
- package/lib/es/components/datagrid/cell.js +0 -1
- package/lib/es/components/datagrid/datagrid.js +1 -1
- package/lib/es/components/datagrid/helper.js +0 -1
- package/lib/es/components/datagrid/index.js +0 -1
- package/lib/es/components/datagrid/resize.js +0 -1
- package/lib/es/components/datagrid/row.js +0 -1
- package/lib/es/components/datagrid/sorter.js +0 -1
- package/lib/es/components/datagrid/virtual.js +130 -104
- package/lib/es/components/description/description.js +1 -1
- package/lib/es/components/description/index.js +0 -1
- package/lib/es/components/drawer/drawer.js +1 -1
- package/lib/es/components/drawer/index.js +0 -1
- package/lib/es/components/dropdown/dropdown.js +1 -1
- package/lib/es/components/dropdown/index.js +0 -1
- package/lib/es/components/dropdown/item.js +0 -1
- package/lib/es/components/editor/controls.js +0 -1
- package/lib/es/components/editor/editor.js +1 -1
- package/lib/es/components/editor/index.js +0 -1
- package/lib/es/components/editor/memtion.js +0 -1
- package/lib/es/components/flex/flex.js +1 -1
- package/lib/es/components/flex/index.js +0 -1
- package/lib/es/components/form/context.js +0 -1
- package/lib/es/components/form/field.js +0 -1
- package/lib/es/components/form/form.js +1 -1
- package/lib/es/components/form/index.js +0 -1
- package/lib/es/components/form/useConfig.js +0 -1
- package/lib/es/components/form/useForm.js +1 -2
- package/lib/es/components/form/utils.js +0 -1
- package/lib/es/components/icon/icon.js +1 -1
- package/lib/es/components/icon/index.js +0 -1
- package/lib/es/components/image/image.js +1 -1
- package/lib/es/components/image/index.js +0 -1
- package/lib/es/components/image/list.js +0 -1
- package/lib/es/components/input/container.js +0 -1
- package/lib/es/components/input/index.js +0 -1
- package/lib/es/components/input/input.js +1 -1
- package/lib/es/components/input/number.js +1 -1
- package/lib/es/components/input/range.js +1 -1
- package/lib/es/components/input/textarea.js +1 -1
- package/lib/es/components/list/index.js +0 -1
- package/lib/es/components/list/item.js +0 -1
- package/lib/es/components/list/list.js +1 -1
- package/lib/es/components/loading/index.js +0 -1
- package/lib/es/components/loading/loading.js +1 -1
- package/lib/es/components/message/index.js +0 -1
- package/lib/es/components/message/message.js +1 -1
- package/lib/es/components/modal/content.js +1 -1
- package/lib/es/components/modal/context.js +0 -1
- package/lib/es/components/modal/hookModal.js +0 -1
- package/lib/es/components/modal/index.js +0 -1
- package/lib/es/components/modal/modal.js +1 -1
- package/lib/es/components/modal/modalManager.js +0 -1
- package/lib/es/components/modal/useModal.js +0 -1
- package/lib/es/components/pagination/index.js +0 -1
- package/lib/es/components/pagination/page.js +0 -1
- package/lib/es/components/pagination/pagination.js +1 -1
- package/lib/es/components/picker/colors/footer.js +0 -1
- package/lib/es/components/picker/colors/handle.js +0 -1
- package/lib/es/components/picker/colors/index.js +1 -1
- package/lib/es/components/picker/daterange/daterange.js +2 -1
- package/lib/es/components/picker/daterange/index.js +0 -1
- package/lib/es/components/picker/daterange/panel.js +0 -1
- package/lib/es/components/picker/dates/dates.js +0 -1
- package/lib/es/components/picker/dates/index.js +1 -1
- package/lib/es/components/picker/dates/panel.js +0 -1
- package/lib/es/components/picker/time/index.js +0 -1
- package/lib/es/components/picker/time/item.js +0 -1
- package/lib/es/components/picker/time/panel.js +1 -1
- package/lib/es/components/popconfirm/index.js +0 -1
- package/lib/es/components/popconfirm/popconfirm.js +1 -1
- package/lib/es/components/popup/content.js +0 -1
- package/lib/es/components/popup/index.js +0 -1
- package/lib/es/components/popup/popup.js +1 -1
- package/lib/es/components/progress/circle.js +0 -1
- package/lib/es/components/progress/index.js +0 -1
- package/lib/es/components/progress/line.js +0 -1
- package/lib/es/components/progress/progress.js +2 -1
- package/lib/es/components/radio/index.js +0 -1
- package/lib/es/components/radio/item.js +0 -1
- package/lib/es/components/radio/radio.js +2 -1
- package/lib/es/components/resizable/index.js +0 -1
- package/lib/es/components/resizable/resizable.js +1 -1
- package/lib/es/components/river/index.js +0 -1
- package/lib/es/components/river/river.js +1 -1
- package/lib/es/components/scroll/index.js +0 -1
- package/lib/es/components/scroll/scroll.js +1 -1
- package/lib/es/components/select/index.js +0 -1
- package/lib/es/components/select/options.js +0 -1
- package/lib/es/components/select/select.js +2 -1
- package/lib/es/components/step/divider.js +1 -1
- package/lib/es/components/step/index.js +0 -1
- package/lib/es/components/step/item.js +0 -1
- package/lib/es/components/step/step.js +1 -1
- package/lib/es/components/swiper/index.js +0 -1
- package/lib/es/components/swiper/item.js +0 -1
- package/lib/es/components/swiper/swiper.js +1 -1
- package/lib/es/components/tabs/contents.js +0 -1
- package/lib/es/components/tabs/helper.js +0 -1
- package/lib/es/components/tabs/index.js +0 -1
- package/lib/es/components/tabs/item.js +0 -1
- package/lib/es/components/tabs/navs.js +0 -1
- package/lib/es/components/tabs/tabs.js +9 -18
- package/lib/es/components/tag/index.js +0 -1
- package/lib/es/components/tag/tag.js +1 -1
- package/lib/es/components/text/highlight.js +0 -1
- package/lib/es/components/text/index.js +0 -1
- package/lib/es/components/text/number.js +0 -1
- package/lib/es/components/text/text.js +1 -1
- package/lib/es/components/text/time.js +0 -1
- package/lib/es/components/tree/index.js +0 -1
- package/lib/es/components/tree/item.js +44 -58
- package/lib/es/components/tree/tree.js +123 -20
- package/lib/es/components/tree/virtual.js +43 -0
- package/lib/es/components/upload/dropbox.js +0 -1
- package/lib/es/components/upload/index.js +0 -1
- package/lib/es/components/upload/renderFile.js +0 -1
- package/lib/es/components/upload/upload.js +1 -1
- package/lib/es/components/utils/empty/index.js +1 -1
- package/lib/es/components/utils/helpericon/helpericon.js +1 -1
- package/lib/es/components/utils/helpericon/index.js +0 -1
- package/lib/es/components/video/index.js +0 -1
- package/lib/es/components/video/video.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/es/js/hooks.js +0 -1
- package/lib/es/js/usePreview/content.js +3 -4
- package/lib/es/js/usePreview/index.js +1 -1
- package/lib/es/js/usePreview/renderFile.js +0 -1
- package/lib/es/js/usePreview/type.js +0 -1
- package/lib/es/js/useRipple/index.js +2 -1
- package/lib/es/js/useTheme/index.js +0 -1
- package/lib/es/js/utils.js +0 -1
- package/lib/index.js +338 -197
- package/lib/types/components/tabs/type.d.ts +1 -1
- package/lib/types/components/tree/type.d.ts +8 -5
- package/lib/types/js/usePreview/type.d.ts +1 -1
- package/package.json +8 -11
- package/lib/cjs/components/affix/affix.js +0 -80
- package/lib/cjs/components/affix/affix.js.map +0 -1
- package/lib/cjs/components/affix/index.js +0 -10
- package/lib/cjs/components/affix/index.js.map +0 -1
- package/lib/cjs/components/affix/totop.js +0 -21
- package/lib/cjs/components/affix/totop.js.map +0 -1
- package/lib/cjs/components/badge/badge.js +0 -21
- package/lib/cjs/components/badge/badge.js.map +0 -1
- package/lib/cjs/components/badge/index.js +0 -10
- package/lib/cjs/components/badge/index.js.map +0 -1
- package/lib/cjs/components/button/button.js +0 -72
- package/lib/cjs/components/button/button.js.map +0 -1
- package/lib/cjs/components/button/confirm.js +0 -58
- package/lib/cjs/components/button/confirm.js.map +0 -1
- package/lib/cjs/components/button/group.js +0 -29
- package/lib/cjs/components/button/group.js.map +0 -1
- package/lib/cjs/components/button/index.js +0 -10
- package/lib/cjs/components/button/index.js.map +0 -1
- package/lib/cjs/components/button/toggle.js +0 -47
- package/lib/cjs/components/button/toggle.js.map +0 -1
- package/lib/cjs/components/card/card.js +0 -21
- package/lib/cjs/components/card/card.js.map +0 -1
- package/lib/cjs/components/card/index.js +0 -10
- package/lib/cjs/components/card/index.js.map +0 -1
- package/lib/cjs/components/checkbox/checkbox.js +0 -47
- package/lib/cjs/components/checkbox/checkbox.js.map +0 -1
- package/lib/cjs/components/checkbox/index.js +0 -10
- package/lib/cjs/components/checkbox/index.js.map +0 -1
- package/lib/cjs/components/checkbox/item.js +0 -43
- package/lib/cjs/components/checkbox/item.js.map +0 -1
- package/lib/cjs/components/collapse/collapse.js +0 -80
- package/lib/cjs/components/collapse/collapse.js.map +0 -1
- package/lib/cjs/components/collapse/index.js +0 -10
- package/lib/cjs/components/collapse/index.js.map +0 -1
- package/lib/cjs/components/collapse/item.js +0 -12
- package/lib/cjs/components/collapse/item.js.map +0 -1
- package/lib/cjs/components/datagrid/cell.js +0 -34
- package/lib/cjs/components/datagrid/cell.js.map +0 -1
- package/lib/cjs/components/datagrid/datagrid.js +0 -219
- package/lib/cjs/components/datagrid/datagrid.js.map +0 -1
- package/lib/cjs/components/datagrid/helper.js +0 -83
- package/lib/cjs/components/datagrid/helper.js.map +0 -1
- package/lib/cjs/components/datagrid/index.js +0 -10
- package/lib/cjs/components/datagrid/index.js.map +0 -1
- package/lib/cjs/components/datagrid/resize.js +0 -72
- package/lib/cjs/components/datagrid/resize.js.map +0 -1
- package/lib/cjs/components/datagrid/row.js +0 -55
- package/lib/cjs/components/datagrid/row.js.map +0 -1
- package/lib/cjs/components/datagrid/sorter.js +0 -21
- package/lib/cjs/components/datagrid/sorter.js.map +0 -1
- package/lib/cjs/components/datagrid/virtual.js +0 -283
- package/lib/cjs/components/datagrid/virtual.js.map +0 -1
- package/lib/cjs/components/description/description.js +0 -36
- package/lib/cjs/components/description/description.js.map +0 -1
- package/lib/cjs/components/description/index.js +0 -10
- package/lib/cjs/components/description/index.js.map +0 -1
- package/lib/cjs/components/drawer/drawer.js +0 -77
- package/lib/cjs/components/drawer/drawer.js.map +0 -1
- package/lib/cjs/components/drawer/index.js +0 -10
- package/lib/cjs/components/drawer/index.js.map +0 -1
- package/lib/cjs/components/dropdown/dropdown.js +0 -36
- package/lib/cjs/components/dropdown/dropdown.js.map +0 -1
- package/lib/cjs/components/dropdown/index.js +0 -10
- package/lib/cjs/components/dropdown/index.js.map +0 -1
- package/lib/cjs/components/dropdown/item.js +0 -38
- package/lib/cjs/components/dropdown/item.js.map +0 -1
- package/lib/cjs/components/editor/controls.js +0 -64
- package/lib/cjs/components/editor/controls.js.map +0 -1
- package/lib/cjs/components/editor/editor.js +0 -287
- package/lib/cjs/components/editor/editor.js.map +0 -1
- package/lib/cjs/components/editor/index.js +0 -10
- package/lib/cjs/components/editor/index.js.map +0 -1
- package/lib/cjs/components/editor/memtion.js +0 -302
- package/lib/cjs/components/editor/memtion.js.map +0 -1
- package/lib/cjs/components/flex/flex.js +0 -36
- package/lib/cjs/components/flex/flex.js.map +0 -1
- package/lib/cjs/components/flex/index.js +0 -10
- package/lib/cjs/components/flex/index.js.map +0 -1
- package/lib/cjs/components/form/context.js +0 -10
- package/lib/cjs/components/form/context.js.map +0 -1
- package/lib/cjs/components/form/field.js +0 -81
- package/lib/cjs/components/form/field.js.map +0 -1
- package/lib/cjs/components/form/form.js +0 -76
- package/lib/cjs/components/form/form.js.map +0 -1
- package/lib/cjs/components/form/index.js +0 -10
- package/lib/cjs/components/form/index.js.map +0 -1
- package/lib/cjs/components/form/useConfig.js +0 -38
- package/lib/cjs/components/form/useConfig.js.map +0 -1
- package/lib/cjs/components/form/useForm.js +0 -127
- package/lib/cjs/components/form/useForm.js.map +0 -1
- package/lib/cjs/components/form/utils.js +0 -33
- package/lib/cjs/components/form/utils.js.map +0 -1
- package/lib/cjs/components/icon/icon.js +0 -31
- package/lib/cjs/components/icon/icon.js.map +0 -1
- package/lib/cjs/components/icon/index.js +0 -10
- package/lib/cjs/components/icon/index.js.map +0 -1
- package/lib/cjs/components/image/image.js +0 -103
- package/lib/cjs/components/image/image.js.map +0 -1
- package/lib/cjs/components/image/index.js +0 -10
- package/lib/cjs/components/image/index.js.map +0 -1
- package/lib/cjs/components/image/list.js +0 -47
- package/lib/cjs/components/image/list.js.map +0 -1
- package/lib/cjs/components/input/container.js +0 -22
- package/lib/cjs/components/input/container.js.map +0 -1
- package/lib/cjs/components/input/index.js +0 -10
- package/lib/cjs/components/input/index.js.map +0 -1
- package/lib/cjs/components/input/input.js +0 -85
- package/lib/cjs/components/input/input.js.map +0 -1
- package/lib/cjs/components/input/number.js +0 -118
- package/lib/cjs/components/input/number.js.map +0 -1
- package/lib/cjs/components/input/range.js +0 -82
- package/lib/cjs/components/input/range.js.map +0 -1
- package/lib/cjs/components/input/textarea.js +0 -64
- package/lib/cjs/components/input/textarea.js.map +0 -1
- package/lib/cjs/components/list/index.js +0 -10
- package/lib/cjs/components/list/index.js.map +0 -1
- package/lib/cjs/components/list/item.js +0 -23
- package/lib/cjs/components/list/item.js.map +0 -1
- package/lib/cjs/components/list/list.js +0 -33
- package/lib/cjs/components/list/list.js.map +0 -1
- package/lib/cjs/components/loading/index.js +0 -10
- package/lib/cjs/components/loading/index.js.map +0 -1
- package/lib/cjs/components/loading/loading.js +0 -26
- package/lib/cjs/components/loading/loading.js.map +0 -1
- package/lib/cjs/components/message/index.js +0 -11
- package/lib/cjs/components/message/index.js.map +0 -1
- package/lib/cjs/components/message/message.js +0 -239
- package/lib/cjs/components/message/message.js.map +0 -1
- package/lib/cjs/components/modal/content.js +0 -45
- package/lib/cjs/components/modal/content.js.map +0 -1
- package/lib/cjs/components/modal/context.js +0 -10
- package/lib/cjs/components/modal/context.js.map +0 -1
- package/lib/cjs/components/modal/hookModal.js +0 -31
- package/lib/cjs/components/modal/hookModal.js.map +0 -1
- package/lib/cjs/components/modal/index.js +0 -10
- package/lib/cjs/components/modal/index.js.map +0 -1
- package/lib/cjs/components/modal/modal.js +0 -140
- package/lib/cjs/components/modal/modal.js.map +0 -1
- package/lib/cjs/components/modal/modalManager.js +0 -83
- package/lib/cjs/components/modal/modalManager.js.map +0 -1
- package/lib/cjs/components/modal/useModal.js +0 -38
- package/lib/cjs/components/modal/useModal.js.map +0 -1
- package/lib/cjs/components/pagination/index.js +0 -10
- package/lib/cjs/components/pagination/index.js.map +0 -1
- package/lib/cjs/components/pagination/page.js +0 -32
- package/lib/cjs/components/pagination/page.js.map +0 -1
- package/lib/cjs/components/pagination/pagination.js +0 -52
- package/lib/cjs/components/pagination/pagination.js.map +0 -1
- package/lib/cjs/components/picker/colors/footer.js +0 -39
- package/lib/cjs/components/picker/colors/footer.js.map +0 -1
- package/lib/cjs/components/picker/colors/handle.js +0 -18
- package/lib/cjs/components/picker/colors/handle.js.map +0 -1
- package/lib/cjs/components/picker/colors/index.js +0 -72
- package/lib/cjs/components/picker/colors/index.js.map +0 -1
- package/lib/cjs/components/picker/daterange/daterange.js +0 -60
- package/lib/cjs/components/picker/daterange/daterange.js.map +0 -1
- package/lib/cjs/components/picker/daterange/index.js +0 -11
- package/lib/cjs/components/picker/daterange/index.js.map +0 -1
- package/lib/cjs/components/picker/daterange/panel.js +0 -55
- package/lib/cjs/components/picker/daterange/panel.js.map +0 -1
- package/lib/cjs/components/picker/dates/dates.js +0 -63
- package/lib/cjs/components/picker/dates/dates.js.map +0 -1
- package/lib/cjs/components/picker/dates/index.js +0 -73
- package/lib/cjs/components/picker/dates/index.js.map +0 -1
- package/lib/cjs/components/picker/dates/panel.js +0 -93
- package/lib/cjs/components/picker/dates/panel.js.map +0 -1
- package/lib/cjs/components/picker/time/index.js +0 -55
- package/lib/cjs/components/picker/time/index.js.map +0 -1
- package/lib/cjs/components/picker/time/item.js +0 -23
- package/lib/cjs/components/picker/time/item.js.map +0 -1
- package/lib/cjs/components/picker/time/panel.js +0 -104
- package/lib/cjs/components/picker/time/panel.js.map +0 -1
- package/lib/cjs/components/popconfirm/index.js +0 -10
- package/lib/cjs/components/popconfirm/index.js.map +0 -1
- package/lib/cjs/components/popconfirm/popconfirm.js +0 -55
- package/lib/cjs/components/popconfirm/popconfirm.js.map +0 -1
- package/lib/cjs/components/popup/content.js +0 -51
- package/lib/cjs/components/popup/content.js.map +0 -1
- package/lib/cjs/components/popup/index.js +0 -10
- package/lib/cjs/components/popup/index.js.map +0 -1
- package/lib/cjs/components/popup/popup.js +0 -495
- package/lib/cjs/components/popup/popup.js.map +0 -1
- package/lib/cjs/components/progress/circle.js +0 -16
- package/lib/cjs/components/progress/circle.js.map +0 -1
- package/lib/cjs/components/progress/index.js +0 -10
- package/lib/cjs/components/progress/index.js.map +0 -1
- package/lib/cjs/components/progress/line.js +0 -22
- package/lib/cjs/components/progress/line.js.map +0 -1
- package/lib/cjs/components/progress/progress.js +0 -90
- package/lib/cjs/components/progress/progress.js.map +0 -1
- package/lib/cjs/components/radio/index.js +0 -10
- package/lib/cjs/components/radio/index.js.map +0 -1
- package/lib/cjs/components/radio/item.js +0 -25
- package/lib/cjs/components/radio/item.js.map +0 -1
- package/lib/cjs/components/radio/radio.js +0 -40
- package/lib/cjs/components/radio/radio.js.map +0 -1
- package/lib/cjs/components/resizable/index.js +0 -10
- package/lib/cjs/components/resizable/index.js.map +0 -1
- package/lib/cjs/components/resizable/resizable.js +0 -68
- package/lib/cjs/components/resizable/resizable.js.map +0 -1
- package/lib/cjs/components/river/index.js +0 -10
- package/lib/cjs/components/river/index.js.map +0 -1
- package/lib/cjs/components/river/river.js +0 -114
- package/lib/cjs/components/river/river.js.map +0 -1
- package/lib/cjs/components/scroll/index.js +0 -10
- package/lib/cjs/components/scroll/index.js.map +0 -1
- package/lib/cjs/components/scroll/scroll.js +0 -78
- package/lib/cjs/components/scroll/scroll.js.map +0 -1
- package/lib/cjs/components/select/index.js +0 -10
- package/lib/cjs/components/select/index.js.map +0 -1
- package/lib/cjs/components/select/options.js +0 -55
- package/lib/cjs/components/select/options.js.map +0 -1
- package/lib/cjs/components/select/select.js +0 -103
- package/lib/cjs/components/select/select.js.map +0 -1
- package/lib/cjs/components/step/divider.js +0 -12
- package/lib/cjs/components/step/divider.js.map +0 -1
- package/lib/cjs/components/step/index.js +0 -10
- package/lib/cjs/components/step/index.js.map +0 -1
- package/lib/cjs/components/step/item.js +0 -30
- package/lib/cjs/components/step/item.js.map +0 -1
- package/lib/cjs/components/step/step.js +0 -44
- package/lib/cjs/components/step/step.js.map +0 -1
- package/lib/cjs/components/swiper/index.js +0 -10
- package/lib/cjs/components/swiper/index.js.map +0 -1
- package/lib/cjs/components/swiper/item.js +0 -33
- package/lib/cjs/components/swiper/item.js.map +0 -1
- package/lib/cjs/components/swiper/swiper.js +0 -241
- package/lib/cjs/components/swiper/swiper.js.map +0 -1
- package/lib/cjs/components/tabs/contents.js +0 -28
- package/lib/cjs/components/tabs/contents.js.map +0 -1
- package/lib/cjs/components/tabs/helper.js +0 -68
- package/lib/cjs/components/tabs/helper.js.map +0 -1
- package/lib/cjs/components/tabs/index.js +0 -10
- package/lib/cjs/components/tabs/index.js.map +0 -1
- package/lib/cjs/components/tabs/item.js +0 -12
- package/lib/cjs/components/tabs/item.js.map +0 -1
- package/lib/cjs/components/tabs/navs.js +0 -38
- package/lib/cjs/components/tabs/navs.js.map +0 -1
- package/lib/cjs/components/tabs/tabs.js +0 -264
- package/lib/cjs/components/tabs/tabs.js.map +0 -1
- package/lib/cjs/components/tag/index.js +0 -10
- package/lib/cjs/components/tag/index.js.map +0 -1
- package/lib/cjs/components/tag/tag.js +0 -26
- package/lib/cjs/components/tag/tag.js.map +0 -1
- package/lib/cjs/components/text/highlight.js +0 -32
- package/lib/cjs/components/text/highlight.js.map +0 -1
- package/lib/cjs/components/text/index.js +0 -10
- package/lib/cjs/components/text/index.js.map +0 -1
- package/lib/cjs/components/text/number.js +0 -31
- package/lib/cjs/components/text/number.js.map +0 -1
- package/lib/cjs/components/text/text.js +0 -42
- package/lib/cjs/components/text/text.js.map +0 -1
- package/lib/cjs/components/text/time.js +0 -24
- package/lib/cjs/components/text/time.js.map +0 -1
- package/lib/cjs/components/tree/index.js +0 -10
- package/lib/cjs/components/tree/index.js.map +0 -1
- package/lib/cjs/components/tree/item.js +0 -80
- package/lib/cjs/components/tree/item.js.map +0 -1
- package/lib/cjs/components/tree/tree.js +0 -134
- package/lib/cjs/components/tree/tree.js.map +0 -1
- package/lib/cjs/components/upload/dropbox.js +0 -54
- package/lib/cjs/components/upload/dropbox.js.map +0 -1
- package/lib/cjs/components/upload/index.js +0 -10
- package/lib/cjs/components/upload/index.js.map +0 -1
- package/lib/cjs/components/upload/renderFile.js +0 -66
- package/lib/cjs/components/upload/renderFile.js.map +0 -1
- package/lib/cjs/components/upload/upload.js +0 -163
- package/lib/cjs/components/upload/upload.js.map +0 -1
- package/lib/cjs/components/utils/empty/index.js +0 -19
- package/lib/cjs/components/utils/empty/index.js.map +0 -1
- package/lib/cjs/components/utils/helpericon/helpericon.js +0 -32
- package/lib/cjs/components/utils/helpericon/helpericon.js.map +0 -1
- package/lib/cjs/components/utils/helpericon/index.js +0 -10
- package/lib/cjs/components/utils/helpericon/index.js.map +0 -1
- package/lib/cjs/components/video/index.js +0 -10
- package/lib/cjs/components/video/index.js.map +0 -1
- package/lib/cjs/components/video/video.js +0 -181
- package/lib/cjs/components/video/video.js.map +0 -1
- package/lib/cjs/index.js +0 -92
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/js/hooks.js +0 -272
- package/lib/cjs/js/hooks.js.map +0 -1
- package/lib/cjs/js/usePreview/content.js +0 -164
- package/lib/cjs/js/usePreview/content.js.map +0 -1
- package/lib/cjs/js/usePreview/index.js +0 -27
- package/lib/cjs/js/usePreview/index.js.map +0 -1
- package/lib/cjs/js/usePreview/renderFile.js +0 -24
- package/lib/cjs/js/usePreview/renderFile.js.map +0 -1
- package/lib/cjs/js/usePreview/type.js +0 -13
- package/lib/cjs/js/usePreview/type.js.map +0 -1
- package/lib/cjs/js/useRipple/index.js +0 -51
- package/lib/cjs/js/useRipple/index.js.map +0 -1
- package/lib/cjs/js/useTheme/index.js +0 -155
- package/lib/cjs/js/useTheme/index.js.map +0 -1
- package/lib/cjs/js/utils.js +0 -302
- package/lib/cjs/js/utils.js.map +0 -1
- package/lib/css/colors.css +0 -792
- package/lib/css/index.css.map +0 -1
- package/lib/css/input.css +0 -214
- package/lib/css/reset.css +0 -140
- package/lib/css/tokens.css +0 -13
- package/lib/css/utilities.css +0 -1973
- package/lib/es/components/affix/affix.js.map +0 -1
- package/lib/es/components/affix/index.js.map +0 -1
- package/lib/es/components/affix/totop.js.map +0 -1
- package/lib/es/components/badge/badge.js.map +0 -1
- package/lib/es/components/badge/index.js.map +0 -1
- package/lib/es/components/button/button.js.map +0 -1
- package/lib/es/components/button/confirm.js.map +0 -1
- package/lib/es/components/button/group.js.map +0 -1
- package/lib/es/components/button/index.js.map +0 -1
- package/lib/es/components/button/toggle.js.map +0 -1
- package/lib/es/components/card/card.js.map +0 -1
- package/lib/es/components/card/index.js.map +0 -1
- package/lib/es/components/checkbox/checkbox.js.map +0 -1
- package/lib/es/components/checkbox/index.js.map +0 -1
- package/lib/es/components/checkbox/item.js.map +0 -1
- package/lib/es/components/collapse/collapse.js.map +0 -1
- package/lib/es/components/collapse/index.js.map +0 -1
- package/lib/es/components/collapse/item.js.map +0 -1
- package/lib/es/components/datagrid/cell.js.map +0 -1
- package/lib/es/components/datagrid/datagrid.js.map +0 -1
- package/lib/es/components/datagrid/helper.js.map +0 -1
- package/lib/es/components/datagrid/index.js.map +0 -1
- package/lib/es/components/datagrid/resize.js.map +0 -1
- package/lib/es/components/datagrid/row.js.map +0 -1
- package/lib/es/components/datagrid/sorter.js.map +0 -1
- package/lib/es/components/datagrid/virtual.js.map +0 -1
- package/lib/es/components/description/description.js.map +0 -1
- package/lib/es/components/description/index.js.map +0 -1
- package/lib/es/components/drawer/drawer.js.map +0 -1
- package/lib/es/components/drawer/index.js.map +0 -1
- package/lib/es/components/dropdown/dropdown.js.map +0 -1
- package/lib/es/components/dropdown/index.js.map +0 -1
- package/lib/es/components/dropdown/item.js.map +0 -1
- package/lib/es/components/editor/controls.js.map +0 -1
- package/lib/es/components/editor/editor.js.map +0 -1
- package/lib/es/components/editor/index.js.map +0 -1
- package/lib/es/components/editor/memtion.js.map +0 -1
- package/lib/es/components/flex/flex.js.map +0 -1
- package/lib/es/components/flex/index.js.map +0 -1
- package/lib/es/components/form/context.js.map +0 -1
- package/lib/es/components/form/field.js.map +0 -1
- package/lib/es/components/form/form.js.map +0 -1
- package/lib/es/components/form/index.js.map +0 -1
- package/lib/es/components/form/useConfig.js.map +0 -1
- package/lib/es/components/form/useForm.js.map +0 -1
- package/lib/es/components/form/utils.js.map +0 -1
- package/lib/es/components/icon/icon.js.map +0 -1
- package/lib/es/components/icon/index.js.map +0 -1
- package/lib/es/components/image/image.js.map +0 -1
- package/lib/es/components/image/index.js.map +0 -1
- package/lib/es/components/image/list.js.map +0 -1
- package/lib/es/components/input/container.js.map +0 -1
- package/lib/es/components/input/index.js.map +0 -1
- package/lib/es/components/input/input.js.map +0 -1
- package/lib/es/components/input/number.js.map +0 -1
- package/lib/es/components/input/range.js.map +0 -1
- package/lib/es/components/input/textarea.js.map +0 -1
- package/lib/es/components/list/index.js.map +0 -1
- package/lib/es/components/list/item.js.map +0 -1
- package/lib/es/components/list/list.js.map +0 -1
- package/lib/es/components/loading/index.js.map +0 -1
- package/lib/es/components/loading/loading.js.map +0 -1
- package/lib/es/components/message/index.js.map +0 -1
- package/lib/es/components/message/message.js.map +0 -1
- package/lib/es/components/modal/content.js.map +0 -1
- package/lib/es/components/modal/context.js.map +0 -1
- package/lib/es/components/modal/hookModal.js.map +0 -1
- package/lib/es/components/modal/index.js.map +0 -1
- package/lib/es/components/modal/modal.js.map +0 -1
- package/lib/es/components/modal/modalManager.js.map +0 -1
- package/lib/es/components/modal/useModal.js.map +0 -1
- package/lib/es/components/pagination/index.js.map +0 -1
- package/lib/es/components/pagination/page.js.map +0 -1
- package/lib/es/components/pagination/pagination.js.map +0 -1
- package/lib/es/components/picker/colors/footer.js.map +0 -1
- package/lib/es/components/picker/colors/handle.js.map +0 -1
- package/lib/es/components/picker/colors/index.js.map +0 -1
- package/lib/es/components/picker/daterange/daterange.js.map +0 -1
- package/lib/es/components/picker/daterange/index.js.map +0 -1
- package/lib/es/components/picker/daterange/panel.js.map +0 -1
- package/lib/es/components/picker/dates/dates.js.map +0 -1
- package/lib/es/components/picker/dates/index.js.map +0 -1
- package/lib/es/components/picker/dates/panel.js.map +0 -1
- package/lib/es/components/picker/time/index.js.map +0 -1
- package/lib/es/components/picker/time/item.js.map +0 -1
- package/lib/es/components/picker/time/panel.js.map +0 -1
- package/lib/es/components/popconfirm/index.js.map +0 -1
- package/lib/es/components/popconfirm/popconfirm.js.map +0 -1
- package/lib/es/components/popup/content.js.map +0 -1
- package/lib/es/components/popup/index.js.map +0 -1
- package/lib/es/components/popup/popup.js.map +0 -1
- package/lib/es/components/progress/circle.js.map +0 -1
- package/lib/es/components/progress/index.js.map +0 -1
- package/lib/es/components/progress/line.js.map +0 -1
- package/lib/es/components/progress/progress.js.map +0 -1
- package/lib/es/components/radio/index.js.map +0 -1
- package/lib/es/components/radio/item.js.map +0 -1
- package/lib/es/components/radio/radio.js.map +0 -1
- package/lib/es/components/resizable/index.js.map +0 -1
- package/lib/es/components/resizable/resizable.js.map +0 -1
- package/lib/es/components/river/index.js.map +0 -1
- package/lib/es/components/river/river.js.map +0 -1
- package/lib/es/components/scroll/index.js.map +0 -1
- package/lib/es/components/scroll/scroll.js.map +0 -1
- package/lib/es/components/select/index.js.map +0 -1
- package/lib/es/components/select/options.js.map +0 -1
- package/lib/es/components/select/select.js.map +0 -1
- package/lib/es/components/step/divider.js.map +0 -1
- package/lib/es/components/step/index.js.map +0 -1
- package/lib/es/components/step/item.js.map +0 -1
- package/lib/es/components/step/step.js.map +0 -1
- package/lib/es/components/swiper/index.js.map +0 -1
- package/lib/es/components/swiper/item.js.map +0 -1
- package/lib/es/components/swiper/swiper.js.map +0 -1
- package/lib/es/components/tabs/contents.js.map +0 -1
- package/lib/es/components/tabs/helper.js.map +0 -1
- package/lib/es/components/tabs/index.js.map +0 -1
- package/lib/es/components/tabs/item.js.map +0 -1
- package/lib/es/components/tabs/navs.js.map +0 -1
- package/lib/es/components/tabs/tabs.js.map +0 -1
- package/lib/es/components/tag/index.js.map +0 -1
- package/lib/es/components/tag/tag.js.map +0 -1
- package/lib/es/components/text/highlight.js.map +0 -1
- package/lib/es/components/text/index.js.map +0 -1
- package/lib/es/components/text/number.js.map +0 -1
- package/lib/es/components/text/text.js.map +0 -1
- package/lib/es/components/text/time.js.map +0 -1
- package/lib/es/components/tree/index.js.map +0 -1
- package/lib/es/components/tree/item.js.map +0 -1
- package/lib/es/components/tree/tree.js.map +0 -1
- package/lib/es/components/upload/dropbox.js.map +0 -1
- package/lib/es/components/upload/index.js.map +0 -1
- package/lib/es/components/upload/renderFile.js.map +0 -1
- package/lib/es/components/upload/upload.js.map +0 -1
- package/lib/es/components/utils/empty/index.js.map +0 -1
- package/lib/es/components/utils/helpericon/helpericon.js.map +0 -1
- package/lib/es/components/utils/helpericon/index.js.map +0 -1
- package/lib/es/components/video/index.js.map +0 -1
- package/lib/es/components/video/video.js.map +0 -1
- package/lib/es/index.js.map +0 -1
- package/lib/es/js/hooks.js.map +0 -1
- package/lib/es/js/usePreview/content.js.map +0 -1
- package/lib/es/js/usePreview/index.js.map +0 -1
- package/lib/es/js/usePreview/renderFile.js.map +0 -1
- package/lib/es/js/usePreview/type.js.map +0 -1
- package/lib/es/js/useRipple/index.js.map +0 -1
- package/lib/es/js/useTheme/index.js.map +0 -1
- package/lib/es/js/utils.js.map +0 -1
package/lib/cjs/js/hooks.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
|
|
5
|
-
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
6
|
-
const os = window.navigator.platform;
|
|
7
|
-
if (os.toLowerCase().includes("mac")) {
|
|
8
|
-
document.documentElement.classList.add("os-mac");
|
|
9
|
-
}
|
|
10
|
-
else if (os.toLowerCase().includes("win")) {
|
|
11
|
-
document.documentElement.classList.add("os-windows");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const MouseMoveEvents = new Set();
|
|
15
|
-
const MouseUpEvents = new Set();
|
|
16
|
-
const KeydownEvents = new Set();
|
|
17
|
-
let initialized = false;
|
|
18
|
-
const initEvents = () => {
|
|
19
|
-
if (typeof document === "undefined" || initialized)
|
|
20
|
-
return;
|
|
21
|
-
initialized = true;
|
|
22
|
-
const touchable = "ontouchend" in document;
|
|
23
|
-
const EVENTS = {
|
|
24
|
-
MOVE: touchable ? "touchmove" : "mousemove",
|
|
25
|
-
UP: touchable ? "touchend" : "mouseup",
|
|
26
|
-
KEYDOWN: "keydown",
|
|
27
|
-
};
|
|
28
|
-
document.addEventListener(EVENTS.MOVE, (e) => {
|
|
29
|
-
for (const listener of MouseMoveEvents.values()) {
|
|
30
|
-
listener(e);
|
|
31
|
-
}
|
|
32
|
-
}, { passive: false });
|
|
33
|
-
document.addEventListener(EVENTS.UP, (e) => {
|
|
34
|
-
for (const listener of MouseUpEvents.values()) {
|
|
35
|
-
listener(e);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
document.addEventListener(EVENTS.KEYDOWN, (e) => {
|
|
39
|
-
for (const listener of KeydownEvents.values()) {
|
|
40
|
-
listener(e);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
function initEventsOnce() {
|
|
45
|
-
react.useEffect(initEvents, []);
|
|
46
|
-
}
|
|
47
|
-
function useMouseMove(listener, options) {
|
|
48
|
-
initEventsOnce();
|
|
49
|
-
react.useEffect(() => {
|
|
50
|
-
MouseMoveEvents.add(listener);
|
|
51
|
-
return () => {
|
|
52
|
-
MouseMoveEvents.delete(listener);
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
}
|
|
56
|
-
function useMouseUp(listener, options) {
|
|
57
|
-
initEventsOnce();
|
|
58
|
-
react.useEffect(() => {
|
|
59
|
-
MouseUpEvents.add(listener);
|
|
60
|
-
return () => {
|
|
61
|
-
MouseUpEvents.delete(listener);
|
|
62
|
-
};
|
|
63
|
-
}, []);
|
|
64
|
-
}
|
|
65
|
-
function useKeydown(listener, options) {
|
|
66
|
-
initEventsOnce();
|
|
67
|
-
const listenerRef = react.useRef(listener);
|
|
68
|
-
listenerRef.current = listener;
|
|
69
|
-
react.useEffect(() => {
|
|
70
|
-
if (options?.disabled)
|
|
71
|
-
return;
|
|
72
|
-
const handler = (e) => listenerRef.current(e);
|
|
73
|
-
KeydownEvents.add(handler);
|
|
74
|
-
return () => {
|
|
75
|
-
KeydownEvents.delete(handler);
|
|
76
|
-
};
|
|
77
|
-
}, []);
|
|
78
|
-
}
|
|
79
|
-
function useReactive(initialState) {
|
|
80
|
-
const [, setFlag] = react.useState(0);
|
|
81
|
-
const scheduledRef = react.useRef(false);
|
|
82
|
-
const proxyCacheRef = react.useRef(new WeakMap());
|
|
83
|
-
const rootRef = react.useRef(null);
|
|
84
|
-
const proxyRef = react.useRef(null);
|
|
85
|
-
const notify = () => {
|
|
86
|
-
if (scheduledRef.current)
|
|
87
|
-
return;
|
|
88
|
-
scheduledRef.current = true;
|
|
89
|
-
const flush = () => {
|
|
90
|
-
scheduledRef.current = false;
|
|
91
|
-
setFlag((n) => n + 1);
|
|
92
|
-
};
|
|
93
|
-
if (typeof queueMicrotask !== "undefined") {
|
|
94
|
-
queueMicrotask(flush);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
Promise.resolve().then(flush);
|
|
98
|
-
};
|
|
99
|
-
const createProxy = (target) => {
|
|
100
|
-
if (!target || typeof target !== "object")
|
|
101
|
-
return target;
|
|
102
|
-
if (!Array.isArray(target)) {
|
|
103
|
-
const proto = Object.getPrototypeOf(target);
|
|
104
|
-
const isPlainObject = proto === Object.prototype || proto === null;
|
|
105
|
-
if (!isPlainObject)
|
|
106
|
-
return target;
|
|
107
|
-
}
|
|
108
|
-
const cached = proxyCacheRef.current.get(target);
|
|
109
|
-
if (cached)
|
|
110
|
-
return cached;
|
|
111
|
-
const proxy = new Proxy(target, {
|
|
112
|
-
get(t, p, r) {
|
|
113
|
-
return createProxy(Reflect.get(t, p, r));
|
|
114
|
-
},
|
|
115
|
-
set(t, p, v, r) {
|
|
116
|
-
const prev = Reflect.get(t, p, r);
|
|
117
|
-
const ok = Reflect.set(t, p, v, r);
|
|
118
|
-
if (prev !== v)
|
|
119
|
-
notify();
|
|
120
|
-
return ok;
|
|
121
|
-
},
|
|
122
|
-
deleteProperty(t, p) {
|
|
123
|
-
const had = Object.prototype.hasOwnProperty.call(t, p);
|
|
124
|
-
const ok = Reflect.deleteProperty(t, p);
|
|
125
|
-
if (had)
|
|
126
|
-
notify();
|
|
127
|
-
return ok;
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
proxyCacheRef.current.set(target, proxy);
|
|
131
|
-
return proxy;
|
|
132
|
-
};
|
|
133
|
-
if (!proxyRef.current) {
|
|
134
|
-
rootRef.current = initialState;
|
|
135
|
-
proxyRef.current = createProxy(rootRef.current);
|
|
136
|
-
}
|
|
137
|
-
return proxyRef.current;
|
|
138
|
-
}
|
|
139
|
-
function useSize(target) {
|
|
140
|
-
const [size, setSize] = react.useState();
|
|
141
|
-
react.useEffect(() => {
|
|
142
|
-
if (typeof window === "undefined")
|
|
143
|
-
return;
|
|
144
|
-
const resolveTarget = () => {
|
|
145
|
-
if (!target)
|
|
146
|
-
return null;
|
|
147
|
-
if (typeof target === "function")
|
|
148
|
-
return target();
|
|
149
|
-
if (typeof target === "object" && "current" in target) {
|
|
150
|
-
return target.current;
|
|
151
|
-
}
|
|
152
|
-
return target;
|
|
153
|
-
};
|
|
154
|
-
const el = resolveTarget();
|
|
155
|
-
if (!el)
|
|
156
|
-
return;
|
|
157
|
-
const update = () => {
|
|
158
|
-
const rect = el.getBoundingClientRect();
|
|
159
|
-
setSize({ width: rect.width, height: rect.height });
|
|
160
|
-
};
|
|
161
|
-
update();
|
|
162
|
-
let ro;
|
|
163
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
164
|
-
ro = new ResizeObserver(update);
|
|
165
|
-
ro.observe(el);
|
|
166
|
-
}
|
|
167
|
-
window.addEventListener("resize", update);
|
|
168
|
-
return () => {
|
|
169
|
-
window.removeEventListener("resize", update);
|
|
170
|
-
ro?.disconnect();
|
|
171
|
-
};
|
|
172
|
-
}, [target]);
|
|
173
|
-
return size;
|
|
174
|
-
}
|
|
175
|
-
const defaultObserver = {
|
|
176
|
-
observe: undefined,
|
|
177
|
-
unobserve: undefined,
|
|
178
|
-
disconnect: undefined,
|
|
179
|
-
};
|
|
180
|
-
function useIntersectionObserver(configs) {
|
|
181
|
-
const wmRef = react.useRef(new WeakMap());
|
|
182
|
-
const ioRef = react.useRef(undefined);
|
|
183
|
-
if (typeof window !== "undefined" && !ioRef.current) {
|
|
184
|
-
ioRef.current = new IntersectionObserver((entries) => {
|
|
185
|
-
entries.map((entry) => {
|
|
186
|
-
const callback = wmRef.current.get(entry.target);
|
|
187
|
-
callback?.(entry.target, entry.isIntersecting);
|
|
188
|
-
});
|
|
189
|
-
}, configs);
|
|
190
|
-
}
|
|
191
|
-
const observe = react.useCallback((target, callback) => {
|
|
192
|
-
if (!target || !ioRef.current || wmRef.current.get(target))
|
|
193
|
-
return;
|
|
194
|
-
wmRef.current.set(target, callback);
|
|
195
|
-
ioRef.current.observe(target);
|
|
196
|
-
}, []);
|
|
197
|
-
const unobserve = react.useCallback((target) => {
|
|
198
|
-
if (!target || !ioRef.current)
|
|
199
|
-
return;
|
|
200
|
-
ioRef.current.unobserve(target);
|
|
201
|
-
wmRef.current.delete(target);
|
|
202
|
-
}, []);
|
|
203
|
-
const disconnect = react.useCallback(() => {
|
|
204
|
-
ioRef.current?.disconnect();
|
|
205
|
-
}, []);
|
|
206
|
-
react.useEffect(() => {
|
|
207
|
-
return () => {
|
|
208
|
-
ioRef.current?.disconnect();
|
|
209
|
-
};
|
|
210
|
-
}, []);
|
|
211
|
-
if (typeof window === "undefined") {
|
|
212
|
-
return {
|
|
213
|
-
...defaultObserver,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
return {
|
|
217
|
-
observe,
|
|
218
|
-
unobserve,
|
|
219
|
-
disconnect,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
function useResizeObserver() {
|
|
223
|
-
const wmRef = react.useRef(new WeakMap());
|
|
224
|
-
const ioRef = react.useRef(undefined);
|
|
225
|
-
if (typeof window !== "undefined" && !ioRef.current) {
|
|
226
|
-
ioRef.current = new ResizeObserver((entries) => {
|
|
227
|
-
entries.map((entry) => {
|
|
228
|
-
const callback = wmRef.current.get(entry.target);
|
|
229
|
-
callback?.(entry.target);
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
const observe = react.useCallback((target, callback) => {
|
|
234
|
-
if (!target || !ioRef.current || wmRef.current.get(target))
|
|
235
|
-
return;
|
|
236
|
-
ioRef.current.observe(target);
|
|
237
|
-
wmRef.current.set(target, callback);
|
|
238
|
-
}, []);
|
|
239
|
-
const unobserve = react.useCallback((target) => {
|
|
240
|
-
if (!target || !ioRef.current)
|
|
241
|
-
return;
|
|
242
|
-
ioRef.current.unobserve(target);
|
|
243
|
-
wmRef.current.delete(target);
|
|
244
|
-
}, []);
|
|
245
|
-
const disconnect = react.useCallback(() => {
|
|
246
|
-
ioRef.current?.disconnect();
|
|
247
|
-
}, []);
|
|
248
|
-
react.useEffect(() => {
|
|
249
|
-
return () => {
|
|
250
|
-
ioRef.current?.disconnect();
|
|
251
|
-
};
|
|
252
|
-
}, []);
|
|
253
|
-
if (typeof window === "undefined") {
|
|
254
|
-
return {
|
|
255
|
-
...defaultObserver,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
return {
|
|
259
|
-
observe,
|
|
260
|
-
unobserve,
|
|
261
|
-
disconnect,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
exports.useIntersectionObserver = useIntersectionObserver;
|
|
266
|
-
exports.useKeydown = useKeydown;
|
|
267
|
-
exports.useMouseMove = useMouseMove;
|
|
268
|
-
exports.useMouseUp = useMouseUp;
|
|
269
|
-
exports.useReactive = useReactive;
|
|
270
|
-
exports.useResizeObserver = useResizeObserver;
|
|
271
|
-
exports.useSize = useSize;
|
|
272
|
-
//# sourceMappingURL=hooks.js.map
|
package/lib/cjs/js/hooks.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../../../packages/js/hooks.ts"],"sourcesContent":["import {\n\tDependencyList,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\n\ntype TMouseEvent = (e: MouseEvent) => void;\ntype TKeyboardEvent = (e: KeyboardEvent) => void;\ntype TEventOption = {\n\tdisabled?: boolean;\n};\n\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n\tconst os = window.navigator.platform;\n\n\tif (os.toLowerCase().includes(\"mac\")) {\n\t\tdocument.documentElement.classList.add(\"os-mac\");\n\t} else if (os.toLowerCase().includes(\"win\")) {\n\t\tdocument.documentElement.classList.add(\"os-windows\");\n\t}\n}\n\nconst MouseMoveEvents = new Set<TMouseEvent>();\nconst MouseUpEvents = new Set<TMouseEvent>();\nconst KeydownEvents = new Set<TKeyboardEvent>();\n\nlet initialized = false;\n\nconst initEvents = () => {\n\tif (typeof document === \"undefined\" || initialized) return;\n\tinitialized = true;\n\n\tconst touchable = \"ontouchend\" in document;\n\tconst EVENTS: Record<string, any> = {\n\t\tMOVE: touchable ? \"touchmove\" : \"mousemove\",\n\t\tUP: touchable ? \"touchend\" : \"mouseup\",\n\t\tKEYDOWN: \"keydown\",\n\t};\n\n\tdocument.addEventListener(\n\t\tEVENTS.MOVE,\n\t\t(e) => {\n\t\t\tfor (const listener of MouseMoveEvents.values()) {\n\t\t\t\tlistener(e);\n\t\t\t}\n\t\t},\n\t\t{ passive: false },\n\t);\n\n\tdocument.addEventListener(EVENTS.UP, (e) => {\n\t\tfor (const listener of MouseUpEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n\n\tdocument.addEventListener(EVENTS.KEYDOWN, (e) => {\n\t\tfor (const listener of KeydownEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n};\n\nfunction initEventsOnce() {\n\tuseEffect(initEvents, []);\n}\n\nexport function useMouseMove(listener: TMouseEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseMoveEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseMoveEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useMouseUp(listener: TMouseEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseUpEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseUpEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useKeydown(listener: TKeyboardEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tconst listenerRef = useRef(listener);\n\tlistenerRef.current = listener;\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tconst handler = (e: KeyboardEvent) => listenerRef.current(e);\n\t\tKeydownEvents.add(handler);\n\t\treturn () => {\n\t\t\tKeydownEvents.delete(handler);\n\t\t};\n\t}, []);\n}\n\nexport function useCreation<T>(factory: () => T, deps: DependencyList) {\n\treturn useMemo(factory, deps);\n}\n\nexport function useReactive<T extends object>(initialState: T): T {\n\tconst [, setFlag] = useState(0);\n\tconst scheduledRef = useRef(false);\n\tconst proxyCacheRef = useRef(new WeakMap<object, any>());\n\tconst rootRef = useRef<T | null>(null);\n\tconst proxyRef = useRef<T | null>(null);\n\n\tconst notify = () => {\n\t\tif (scheduledRef.current) return;\n\t\tscheduledRef.current = true;\n\n\t\tconst flush = () => {\n\t\t\tscheduledRef.current = false;\n\t\t\tsetFlag((n) => n + 1);\n\t\t};\n\n\t\tif (typeof queueMicrotask !== \"undefined\") {\n\t\t\tqueueMicrotask(flush);\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.resolve().then(flush);\n\t};\n\n\tconst createProxy = (target: any): any => {\n\t\tif (!target || typeof target !== \"object\") return target;\n\n\t\tif (!Array.isArray(target)) {\n\t\t\tconst proto = Object.getPrototypeOf(target);\n\t\t\tconst isPlainObject = proto === Object.prototype || proto === null;\n\t\t\tif (!isPlainObject) return target;\n\t\t}\n\n\t\tconst cached = proxyCacheRef.current.get(target);\n\t\tif (cached) return cached;\n\n\t\tconst proxy = new Proxy(target, {\n\t\t\tget(t, p, r) {\n\t\t\t\treturn createProxy(Reflect.get(t, p, r));\n\t\t\t},\n\t\t\tset(t, p, v, r) {\n\t\t\t\tconst prev = Reflect.get(t, p, r);\n\t\t\t\tconst ok = Reflect.set(t, p, v, r);\n\t\t\t\tif (prev !== v) notify();\n\t\t\t\treturn ok;\n\t\t\t},\n\t\t\tdeleteProperty(t, p) {\n\t\t\t\tconst had = Object.prototype.hasOwnProperty.call(t, p);\n\t\t\t\tconst ok = Reflect.deleteProperty(t, p);\n\t\t\t\tif (had) notify();\n\t\t\t\treturn ok;\n\t\t\t},\n\t\t});\n\n\t\tproxyCacheRef.current.set(target, proxy);\n\t\treturn proxy;\n\t};\n\n\tif (!proxyRef.current) {\n\t\trootRef.current = initialState;\n\t\tproxyRef.current = createProxy(rootRef.current);\n\t}\n\n\treturn proxyRef.current as T;\n}\n\ntype TSetState<T> = (\n\tvalue: T | undefined | ((prev: T | undefined) => T),\n) => void;\n\ntype TLocalStorageOptions<T> = {\n\tdefaultValue?: T | (() => T);\n\tlistenStorageChange?: boolean;\n};\n\nexport function useLocalStorageState<T>(\n\tkey: string,\n\toptions?: TLocalStorageOptions<T>,\n): [T | undefined, TSetState<T>] {\n\tconst { defaultValue, listenStorageChange } = options ?? {};\n\n\tconst getDefault = () => {\n\t\treturn typeof defaultValue === \"function\"\n\t\t\t? (defaultValue as () => T)()\n\t\t\t: defaultValue;\n\t};\n\n\tconst read = (): T | undefined => {\n\t\tif (typeof window === \"undefined\") return getDefault();\n\n\t\tconst raw = window.localStorage.getItem(key);\n\t\tif (raw === null) return getDefault();\n\n\t\ttry {\n\t\t\treturn JSON.parse(raw) as T;\n\t\t} catch (e) {\n\t\t\treturn raw as unknown as T;\n\t\t}\n\t};\n\n\tconst [state, setState] = useState<T | undefined>(() => read());\n\n\tconst set: TSetState<T> = (value) => {\n\t\tsetState((prev) => {\n\t\t\tconst next =\n\t\t\t\ttypeof value === \"function\"\n\t\t\t\t\t? (value as (prev: T | undefined) => T)(prev)\n\t\t\t\t\t: value;\n\n\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\twindow.localStorage.removeItem(key);\n\t\t\t\t} else {\n\t\t\t\t\twindow.localStorage.setItem(key, JSON.stringify(next));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn next;\n\t\t});\n\t};\n\n\tuseEffect(() => {\n\t\tif (!listenStorageChange) return;\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst onStorage = (e: StorageEvent) => {\n\t\t\tif (e.key !== key) return;\n\n\t\t\tif (e.newValue === null) {\n\t\t\t\tsetState(getDefault());\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tsetState(JSON.parse(e.newValue) as T);\n\t\t\t} catch (err) {\n\t\t\t\tsetState(e.newValue as unknown as T);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"storage\", onStorage);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"storage\", onStorage);\n\t\t};\n\t}, [key, listenStorageChange]);\n\n\treturn [state, set];\n}\n\ntype TResponsiveConfig = Record<string, number>;\n\nlet responsiveConfig: TResponsiveConfig = {};\n\nexport function configResponsive(config: TResponsiveConfig) {\n\tresponsiveConfig = config;\n}\n\nexport function useResponsive() {\n\tconst compute = () => {\n\t\tif (typeof window === \"undefined\") return {};\n\t\tconst w = window.innerWidth;\n\t\tconst result: Record<string, boolean> = {};\n\n\t\tfor (const key in responsiveConfig) {\n\t\t\tresult[key] = w >= responsiveConfig[key];\n\t\t}\n\n\t\treturn result;\n\t};\n\n\tconst [state, setState] = useState<Record<string, boolean>>(() =>\n\t\tcompute(),\n\t);\n\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst onResize = () => {\n\t\t\tconst next = compute();\n\t\t\tsetState((prev) => {\n\t\t\t\tconst prevKeys = Object.keys(prev);\n\t\t\t\tconst nextKeys = Object.keys(next);\n\t\t\t\tif (prevKeys.length !== nextKeys.length) return next;\n\n\t\t\t\tfor (const k of nextKeys) {\n\t\t\t\t\tif (prev[k] !== next[k]) return next;\n\t\t\t\t}\n\n\t\t\t\treturn prev;\n\t\t\t});\n\t\t};\n\n\t\tonResize();\n\t\twindow.addEventListener(\"resize\", onResize);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"resize\", onResize);\n\t\t};\n\t}, []);\n\n\treturn state;\n}\n\ntype TSize = { width: number; height: number };\n\nexport function useSize(target: any): TSize | undefined {\n\tconst [size, setSize] = useState<TSize>();\n\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst resolveTarget = () => {\n\t\t\tif (!target) return null;\n\t\t\tif (typeof target === \"function\") return target();\n\t\t\tif (typeof target === \"object\" && \"current\" in target) {\n\t\t\t\treturn target.current;\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tconst el = resolveTarget() as HTMLElement | null;\n\t\tif (!el) return;\n\n\t\tconst update = () => {\n\t\t\tconst rect = el.getBoundingClientRect();\n\t\t\tsetSize({ width: rect.width, height: rect.height });\n\t\t};\n\n\t\tupdate();\n\n\t\tlet ro: ResizeObserver | undefined;\n\t\tif (typeof ResizeObserver !== \"undefined\") {\n\t\t\tro = new ResizeObserver(update);\n\t\t\tro.observe(el);\n\t\t}\n\n\t\twindow.addEventListener(\"resize\", update);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"resize\", update);\n\t\t\tro?.disconnect();\n\t\t};\n\t}, [target]);\n\n\treturn size;\n}\n\nconst defaultObserver = {\n\tobserve: undefined,\n\tunobserve: undefined,\n\tdisconnect: undefined,\n};\n\nexport function useIntersectionObserver(configs?: IntersectionObserverInit) {\n\tconst wmRef = useRef(new WeakMap());\n\tconst ioRef = useRef<IntersectionObserver | undefined>(undefined);\n\n\tif (typeof window !== \"undefined\" && !ioRef.current) {\n\t\tioRef.current = new IntersectionObserver((entries) => {\n\t\t\tentries.map((entry) => {\n\t\t\t\tconst callback = wmRef.current.get(entry.target);\n\t\t\t\tcallback?.(entry.target, entry.isIntersecting);\n\t\t\t});\n\t\t}, configs);\n\t}\n\n\tconst observe = useCallback((target: HTMLElement, callback: Function) => {\n\t\tif (!target || !ioRef.current || wmRef.current.get(target)) return;\n\t\twmRef.current.set(target, callback);\n\t\tioRef.current.observe(target);\n\t}, []);\n\n\tconst unobserve = useCallback((target: HTMLElement) => {\n\t\tif (!target || !ioRef.current) return;\n\t\tioRef.current.unobserve(target);\n\t\twmRef.current.delete(target);\n\t}, []);\n\n\tconst disconnect = useCallback(() => {\n\t\tioRef.current?.disconnect();\n\t}, []);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tioRef.current?.disconnect();\n\t\t};\n\t}, []);\n\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n\nexport function useResizeObserver() {\n\tconst wmRef = useRef(new WeakMap());\n\tconst ioRef = useRef<ResizeObserver | undefined>(undefined);\n\n\tif (typeof window !== \"undefined\" && !ioRef.current) {\n\t\tioRef.current = new ResizeObserver((entries) => {\n\t\t\tentries.map((entry) => {\n\t\t\t\tconst callback = wmRef.current.get(entry.target);\n\t\t\t\tcallback?.(entry.target);\n\t\t\t});\n\t\t});\n\t}\n\n\tconst observe = useCallback((target: HTMLElement, callback: Function) => {\n\t\tif (!target || !ioRef.current || wmRef.current.get(target)) return;\n\t\tioRef.current.observe(target);\n\t\twmRef.current.set(target, callback);\n\t}, []);\n\n\tconst unobserve = useCallback((target: HTMLElement) => {\n\t\tif (!target || !ioRef.current) return;\n\t\tioRef.current.unobserve(target);\n\t\twmRef.current.delete(target);\n\t}, []);\n\n\tconst disconnect = useCallback(() => {\n\t\tioRef.current?.disconnect();\n\t}, []);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tioRef.current?.disconnect();\n\t\t};\n\t}, []);\n\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n"],"names":["useEffect","useRef","useState","useCallback"],"mappings":";;;;AAeA,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACrE,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ;IAEpC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACrC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;IACjD;SAAO,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5C,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC;IACrD;AACD;AAEA,MAAM,eAAe,GAAG,IAAI,GAAG,EAAe;AAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAe;AAC5C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB;AAE/C,IAAI,WAAW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K,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;AAC/B,QAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,UAAU,GAAGA,iBAAW,CAAC,MAAK;AACnC,QAAA,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE;IAC5B,CAAC,EAAE,EAAE,CAAC;IAENH,eAAS,CAAC,MAAK;AACd,QAAA,OAAO,MAAK;AACX,YAAA,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE;AAC5B,QAAA,CAAC;IACF,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAClC,OAAO;AACN,YAAA,GAAG,eAAe;SAClB;IACF;IAEA,OAAO;QACN,OAAO;QACP,SAAS;QACT,UAAU;KACV;AACF;;;;;;;;;;"}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var button = require('../../components/button/button.js');
|
|
7
|
-
var icon = require('../../components/icon/icon.js');
|
|
8
|
-
var material = require('@ricons/material');
|
|
9
|
-
var classNames = require('classnames');
|
|
10
|
-
var radash = require('radash');
|
|
11
|
-
var react = require('react');
|
|
12
|
-
var hooks = require('../hooks.js');
|
|
13
|
-
var utils = require('../utils.js');
|
|
14
|
-
var renderFile = require('./renderFile.js');
|
|
15
|
-
var type = require('./type.js');
|
|
16
|
-
|
|
17
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
18
|
-
|
|
19
|
-
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
20
|
-
|
|
21
|
-
function Content(props) {
|
|
22
|
-
const { items = [], initial = 0, renderFile: renderFile$1 = renderFile.default, onRotate, onChange, onClose, onZoom, } = props;
|
|
23
|
-
const state = hooks.useReactive({
|
|
24
|
-
current: initial,
|
|
25
|
-
rotate: 0,
|
|
26
|
-
scale: 1,
|
|
27
|
-
translate: [0, 0],
|
|
28
|
-
start: [0, 0],
|
|
29
|
-
dragging: false,
|
|
30
|
-
controlHidden: true,
|
|
31
|
-
});
|
|
32
|
-
const box = react.useRef(null);
|
|
33
|
-
const translate = react.useRef([0, 0]);
|
|
34
|
-
const hiddenTO = react.useRef(null);
|
|
35
|
-
const files = react.useMemo(() => {
|
|
36
|
-
return items.map((item) => {
|
|
37
|
-
const o = {
|
|
38
|
-
src: "",
|
|
39
|
-
};
|
|
40
|
-
if (typeof item === "string") {
|
|
41
|
-
o.src = item;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
Object.assign(o, item);
|
|
45
|
-
}
|
|
46
|
-
o.suffix = utils.getSuffixByUrl(o.src) || "";
|
|
47
|
-
o.type = utils.getFileType(o.suffix, item["type"]);
|
|
48
|
-
return o;
|
|
49
|
-
});
|
|
50
|
-
}, [items]);
|
|
51
|
-
const { file, content } = react.useMemo(() => {
|
|
52
|
-
const file = files[state.current];
|
|
53
|
-
const content = renderFile$1(file);
|
|
54
|
-
return {
|
|
55
|
-
file,
|
|
56
|
-
content,
|
|
57
|
-
};
|
|
58
|
-
}, [state.current, items]);
|
|
59
|
-
const isImage = file.type === type.TFileType.IMAGE;
|
|
60
|
-
const handleSwitch = (next) => {
|
|
61
|
-
const l = files.length;
|
|
62
|
-
const { current: before } = state;
|
|
63
|
-
if (next >= l) {
|
|
64
|
-
state.current = 0;
|
|
65
|
-
}
|
|
66
|
-
else if (next < 0) {
|
|
67
|
-
state.current = l - 1;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
state.current = next;
|
|
71
|
-
}
|
|
72
|
-
onChange?.(state.current, before);
|
|
73
|
-
state.rotate = files[state.current].rotate || 0;
|
|
74
|
-
if (state.scale !== 1) {
|
|
75
|
-
state.scale = 1;
|
|
76
|
-
onZoom?.(1);
|
|
77
|
-
}
|
|
78
|
-
onRotate?.(state.rotate);
|
|
79
|
-
state.translate = translate.current = [0, 0];
|
|
80
|
-
};
|
|
81
|
-
const handleRotate = (deg) => {
|
|
82
|
-
state.rotate += deg;
|
|
83
|
-
onRotate?.(state.rotate);
|
|
84
|
-
};
|
|
85
|
-
const handleMouseWheel = radash.throttle({ interval: 60 }, (e) => {
|
|
86
|
-
e.stopPropagation();
|
|
87
|
-
e.preventDefault();
|
|
88
|
-
if (!isImage)
|
|
89
|
-
return;
|
|
90
|
-
let after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);
|
|
91
|
-
if (after > 2)
|
|
92
|
-
after = 2;
|
|
93
|
-
if (after < 0.25)
|
|
94
|
-
after = 0.25;
|
|
95
|
-
onZoom?.(after);
|
|
96
|
-
state.scale = after;
|
|
97
|
-
});
|
|
98
|
-
const handleMouseDown = (e) => {
|
|
99
|
-
if (!isImage)
|
|
100
|
-
return;
|
|
101
|
-
e.preventDefault();
|
|
102
|
-
state.dragging = true;
|
|
103
|
-
state.start = [e.pageX, e.pageY];
|
|
104
|
-
};
|
|
105
|
-
const clearHiddenTO = () => {
|
|
106
|
-
if (!hiddenTO.current || state.controlHidden)
|
|
107
|
-
return;
|
|
108
|
-
clearTimeout(hiddenTO.current);
|
|
109
|
-
hiddenTO.current = null;
|
|
110
|
-
};
|
|
111
|
-
const setHiddenFalse = () => {
|
|
112
|
-
if (!state.controlHidden)
|
|
113
|
-
return;
|
|
114
|
-
state.controlHidden = false;
|
|
115
|
-
clearHiddenTO();
|
|
116
|
-
hiddenTO.current = setTimeout(() => {
|
|
117
|
-
state.controlHidden = true;
|
|
118
|
-
}, 1000);
|
|
119
|
-
};
|
|
120
|
-
const throttleMouseMove = radash.throttle({ interval: 300 }, setHiddenFalse);
|
|
121
|
-
const handleMouseMove = (e) => {
|
|
122
|
-
throttleMouseMove();
|
|
123
|
-
if (!state.dragging)
|
|
124
|
-
return;
|
|
125
|
-
e.preventDefault();
|
|
126
|
-
const [x, y] = translate.current;
|
|
127
|
-
const [ox, oy] = state.start;
|
|
128
|
-
const offsetX = e.pageX - ox;
|
|
129
|
-
const offsetY = e.pageY - oy;
|
|
130
|
-
state.translate = [x + offsetX, y + offsetY];
|
|
131
|
-
};
|
|
132
|
-
const handleMouseUp = () => {
|
|
133
|
-
if (!state.dragging)
|
|
134
|
-
return;
|
|
135
|
-
state.dragging = false;
|
|
136
|
-
translate.current = state.translate;
|
|
137
|
-
};
|
|
138
|
-
hooks.useMouseMove(handleMouseMove);
|
|
139
|
-
hooks.useMouseUp(handleMouseUp);
|
|
140
|
-
react.useEffect(() => {
|
|
141
|
-
if (!box.current)
|
|
142
|
-
return;
|
|
143
|
-
box.current.addEventListener("wheel", handleMouseWheel, {
|
|
144
|
-
passive: false,
|
|
145
|
-
});
|
|
146
|
-
return () => {
|
|
147
|
-
if (!box.current)
|
|
148
|
-
return;
|
|
149
|
-
box.current.removeEventListener("wheel", handleMouseWheel);
|
|
150
|
-
};
|
|
151
|
-
}, []);
|
|
152
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { ref: box, className: classNames__default("i-preview-content", {
|
|
153
|
-
"no-transition": state.dragging,
|
|
154
|
-
}), style: {
|
|
155
|
-
transform: `translate(${state.translate
|
|
156
|
-
.map((n) => `${n}px`)
|
|
157
|
-
.join(",")}) rotate(${state.rotate}deg) scale(${state.scale})`,
|
|
158
|
-
}, onMouseDown: handleMouseDown, onClick: (e) => e.stopPropagation(), children: content }), jsxRuntime.jsxs("div", { className: classNames__default("i-preview-controls", {
|
|
159
|
-
"i-preview-controls-hidden": state.controlHidden,
|
|
160
|
-
}), children: [jsxRuntime.jsx(button.default, { square: true, flat: true, onClick: onClose, children: jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.CloseRound, {}) }) }), files.length > 1 && (jsxRuntime.jsxs("span", { className: 'px-8', children: [state.current + 1, " / ", files.length] })), state.scale !== 1 && (jsxRuntime.jsxs(button.default, { flat: true, onClick: () => (state.scale = 1), children: [jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.AspectRatioRound, {}) }), jsxRuntime.jsxs("span", { className: 'mt-2', children: [(state.scale * 100).toFixed(0), "%"] })] })), jsxRuntime.jsx(button.default, { square: true, flat: true, href: file.src, target: '_blank', children: jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.OpenInNewRound, {}) }) }), jsxRuntime.jsx(button.default, { square: true, flat: true, href: file.src, download: true, target: '_blank', children: jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.FileDownloadOutlined, {}) }) }), jsxRuntime.jsx(button.default, { square: true, flat: true, onClick: () => handleRotate(90), children: jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.RotateRightRound, {}) }) }), jsxRuntime.jsx(button.default, { square: true, flat: true, onClick: () => handleRotate(-90), children: jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.RotateLeftRound, {}) }) }), files.length > 1 && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(button.default, { square: true, flat: true, onClick: () => handleSwitch(state.current - 1), children: jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.KeyboardArrowLeftRound, {}) }) }), jsxRuntime.jsx(button.default, { square: true, flat: true, onClick: () => handleSwitch(state.current + 1), children: jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.KeyboardArrowRightRound, {}) }) })] }))] })] }));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
exports.default = Content;
|
|
164
|
-
//# sourceMappingURL=content.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sources":["../../../../packages/js/usePreview/content.tsx"],"sourcesContent":["import Button from \"@p/components/button\";\nimport Icon from \"@p/components/icon\";\nimport {\n\tAspectRatioRound,\n\tCloseRound,\n\tFileDownloadOutlined,\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tOpenInNewRound,\n\tRotateLeftRound,\n\tRotateRightRound,\n} from \"@ricons/material\";\nimport classNames from \"classnames\";\nimport { throttle } from \"radash\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { useMouseMove, useMouseUp, useReactive } from \"../hooks\";\nimport { getFileType, getSuffixByUrl } from \"../utils\";\nimport DefaultRenderFile from \"./renderFile\";\nimport { IPreview, TFileType, TPreviewItem } from \"./type\";\n\nexport default function Content(props: IPreview) {\n\tconst {\n\t\titems = [],\n\t\tinitial = 0,\n\t\trenderFile = DefaultRenderFile,\n\t\tonRotate,\n\t\tonChange,\n\t\tonClose,\n\t\tonZoom,\n\t} = props;\n\tconst state = useReactive({\n\t\tcurrent: initial,\n\t\trotate: 0,\n\t\tscale: 1,\n\t\ttranslate: [0, 0],\n\t\tstart: [0, 0],\n\t\tdragging: false,\n\t\tcontrolHidden: true,\n\t});\n\tconst box = useRef<HTMLDivElement>(null);\n\tconst translate = useRef<number[]>([0, 0]);\n\tconst hiddenTO = useRef<any>(null);\n\n\tconst files = useMemo(() => {\n\t\treturn items.map((item) => {\n\t\t\tconst o: TPreviewItem = {\n\t\t\t\tsrc: \"\",\n\t\t\t};\n\t\t\tif (typeof item === \"string\") {\n\t\t\t\to.src = item;\n\t\t\t} else {\n\t\t\t\tObject.assign(o, item);\n\t\t\t}\n\n\t\t\to.suffix = getSuffixByUrl(o.src) || \"\";\n\t\t\to.type = getFileType(o.suffix, item[\"type\"]);\n\n\t\t\treturn o;\n\t\t});\n\t}, [items]);\n\n\tconst { file, content } = useMemo(() => {\n\t\tconst file = files[state.current];\n\t\tconst content = renderFile(file);\n\n\t\treturn {\n\t\t\tfile,\n\t\t\tcontent,\n\t\t};\n\t}, [state.current, items]);\n\n\tconst isImage = file.type === TFileType.IMAGE;\n\n\tconst handleSwitch = (next: number) => {\n\t\tconst l = files.length;\n\t\tconst { current: before } = state;\n\t\tif (next >= l) {\n\t\t\tstate.current = 0;\n\t\t} else if (next < 0) {\n\t\t\tstate.current = l - 1;\n\t\t} else {\n\t\t\tstate.current = next;\n\t\t}\n\t\tonChange?.(state.current, before);\n\n\t\tstate.rotate = files[state.current].rotate || 0;\n\n\t\tif (state.scale !== 1) {\n\t\t\tstate.scale = 1;\n\t\t\tonZoom?.(1);\n\t\t}\n\t\tonRotate?.(state.rotate);\n\t\tstate.translate = translate.current = [0, 0];\n\t};\n\n\tconst handleRotate = (deg: number) => {\n\t\tstate.rotate += deg;\n\n\t\tonRotate?.(state.rotate);\n\t};\n\n\tconst handleMouseWheel = throttle({ interval: 60 }, (e) => {\n\t\te.stopPropagation();\n\t\te.preventDefault();\n\t\tif (!isImage) return;\n\t\tlet after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);\n\t\tif (after > 2) after = 2;\n\t\tif (after < 0.25) after = 0.25;\n\n\t\tonZoom?.(after);\n\t\tstate.scale = after;\n\t});\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!isImage) return;\n\t\te.preventDefault();\n\t\tstate.dragging = true;\n\t\tstate.start = [e.pageX, e.pageY];\n\t};\n\n\tconst clearHiddenTO = () => {\n\t\tif (!hiddenTO.current || state.controlHidden) return;\n\t\tclearTimeout(hiddenTO.current);\n\t\thiddenTO.current = null;\n\t};\n\n\tconst setHiddenFalse = () => {\n\t\tif (!state.controlHidden) return;\n\t\tstate.controlHidden = false;\n\n\t\tclearHiddenTO();\n\t\thiddenTO.current = setTimeout(() => {\n\t\t\tstate.controlHidden = true;\n\t\t}, 1000);\n\t};\n\n\tconst throttleMouseMove = throttle({ interval: 300 }, setHiddenFalse);\n\n\tconst handleMouseMove = (e) => {\n\t\tthrottleMouseMove();\n\t\tif (!state.dragging) return;\n\t\te.preventDefault();\n\n\t\tconst [x, y] = translate.current;\n\t\tconst [ox, oy] = state.start;\n\t\tconst offsetX = e.pageX - ox;\n\t\tconst offsetY = e.pageY - oy;\n\n\t\tstate.translate = [x + offsetX, y + offsetY];\n\t};\n\n\tconst handleMouseUp = () => {\n\t\tif (!state.dragging) return;\n\t\tstate.dragging = false;\n\t\ttranslate.current = state.translate;\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\tuseEffect(() => {\n\t\tif (!box.current) return;\n\n\t\tbox.current.addEventListener(\"wheel\", handleMouseWheel, {\n\t\t\tpassive: false,\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (!box.current) return;\n\n\t\t\tbox.current.removeEventListener(\"wheel\", handleMouseWheel);\n\t\t};\n\t}, []);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={box}\n\t\t\t\tclassName={classNames(\"i-preview-content\", {\n\t\t\t\t\t\"no-transition\": state.dragging,\n\t\t\t\t})}\n\t\t\t\tstyle={{\n\t\t\t\t\ttransform: `translate(${state.translate\n\t\t\t\t\t\t.map((n) => `${n}px`)\n\t\t\t\t\t\t.join(\",\")}) rotate(${state.rotate}deg) scale(${\n\t\t\t\t\t\tstate.scale\n\t\t\t\t\t})`,\n\t\t\t\t}}\n\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-preview-controls\", {\n\t\t\t\t\t\"i-preview-controls-hidden\": state.controlHidden,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<Button square flat onClick={onClose}>\n\t\t\t\t\t<Icon icon={<CloseRound />} />\n\t\t\t\t</Button>\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<span className='px-8'>\n\t\t\t\t\t\t{state.current + 1} / {files.length}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{state.scale !== 1 && (\n\t\t\t\t\t<Button flat onClick={() => (state.scale = 1)}>\n\t\t\t\t\t\t<Icon icon={<AspectRatioRound />} />\n\t\t\t\t\t\t<span className='mt-2'>\n\t\t\t\t\t\t\t{(state.scale * 100).toFixed(0)}%\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Button>\n\t\t\t\t)}\n\t\t\t\t<Button square flat href={file.src} target='_blank'>\n\t\t\t\t\t<Icon icon={<OpenInNewRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat href={file.src} download target='_blank'>\n\t\t\t\t\t<Icon icon={<FileDownloadOutlined />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(90)}>\n\t\t\t\t\t<Icon icon={<RotateRightRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(-90)}>\n\t\t\t\t\t<Icon icon={<RotateLeftRound />} />\n\t\t\t\t</Button>\n\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current - 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowLeftRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current + 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowRightRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"names":["renderFile","DefaultRenderFile","useReactive","useRef","useMemo","getSuffixByUrl","getFileType","TFileType","throttle","useMouseMove","useMouseUp","useEffect","_jsxs","_Fragment","_jsx","classNames","Button","Icon","CloseRound","AspectRatioRound","OpenInNewRound","FileDownloadOutlined","RotateRightRound","RotateLeftRound","KeyboardArrowLeftRound","KeyboardArrowRightRound"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBc,SAAU,OAAO,CAAC,KAAe,EAAA;IAC9C,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(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var react = require('react');
|
|
7
|
-
var hookModal = require('../../components/modal/hookModal.js');
|
|
8
|
-
var utils = require('../utils.js');
|
|
9
|
-
var content = require('./content.js');
|
|
10
|
-
|
|
11
|
-
function usePreview() {
|
|
12
|
-
const ref = react.useRef(null);
|
|
13
|
-
const preview = (config) => {
|
|
14
|
-
const { items, modalProps, onClose, ...restProps } = config;
|
|
15
|
-
const handleClose = () => {
|
|
16
|
-
onClose?.();
|
|
17
|
-
unMount?.();
|
|
18
|
-
};
|
|
19
|
-
const unMount = utils.renderNode(jsxRuntime.jsx(hookModal.default, { ref: ref, visible: true, className: 'i-preview', customized: true, hideShadow: true, ...modalProps, children: jsxRuntime.jsx(content.default, { ...restProps, items: items, onClose: () => {
|
|
20
|
-
ref.current?.update({ visible: false });
|
|
21
|
-
} }), fixed: true, onClose: handleClose }));
|
|
22
|
-
};
|
|
23
|
-
return preview;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
exports.default = usePreview;
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/js/usePreview/index.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport HookModal from \"../../components/modal/hookModal\";\nimport type { RefHookModal } from \"../../components/modal/type\";\nimport { renderNode } from \"../utils\";\nimport Content from \"./content\";\nimport \"./index.css\";\nimport type { IPreview } from \"./type\";\n\nexport default function usePreview() {\n\tconst ref = useRef<RefHookModal>(null);\n\n\tconst preview = (config: IPreview) => {\n\t\tconst { items, modalProps, onClose, ...restProps } = config;\n\n\t\tconst handleClose = () => {\n\t\t\tonClose?.();\n\t\t\tunMount?.();\n\t\t};\n\n\t\tconst unMount = renderNode(\n\t\t\t<HookModal\n\t\t\t\tref={ref}\n\t\t\t\tvisible\n\t\t\t\tclassName='i-preview'\n\t\t\t\tcustomized\n\t\t\t\thideShadow\n\t\t\t\t{...modalProps}\n\t\t\t\tchildren={\n\t\t\t\t\t<Content\n\t\t\t\t\t\t{...restProps}\n\t\t\t\t\t\titems={items}\n\t\t\t\t\t\tonClose={() => {\n\t\t\t\t\t\t\tref.current?.update({ visible: false });\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tfixed\n\t\t\t\tonClose={handleClose}\n\t\t\t/>\n\t\t);\n\t};\n\n\treturn preview;\n}\n"],"names":["useRef","renderNode","_jsx","HookModal","Content"],"mappings":";;;;;;;;;;AAQc,SAAU,UAAU,GAAA;AACjC,IAAA,MAAM,GAAG,GAAGA,YAAM,CAAe,IAAI,CAAC;AAEtC,IAAA,MAAM,OAAO,GAAG,CAAC,MAAgB,KAAI;AACpC,QAAA,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,MAAM;QAE3D,MAAM,WAAW,GAAG,MAAK;YACxB,OAAO,IAAI;YACX,OAAO,IAAI;AACZ,QAAA,CAAC;AAED,QAAA,MAAM,OAAO,GAAGC,gBAAU,CACzBC,cAAA,CAACC,iBAAS,EAAA,EACT,GAAG,EAAE,GAAG,EACR,OAAO,EAAA,IAAA,EACP,SAAS,EAAC,WAAW,EACrB,UAAU,EAAA,IAAA,EACV,UAAU,WACN,UAAU,EACd,QAAQ,EACPD,eAACE,eAAO,EAAA,EAAA,GACH,SAAS,EACb,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,MAAK;oBACb,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;gBACxC,CAAC,EAAA,CACA,EAEH,KAAK,EAAA,IAAA,EACL,OAAO,EAAE,WAAW,EAAA,CACnB,CACF;AACF,IAAA,CAAC;AAED,IAAA,OAAO,OAAO;AACf;;;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var icon = require('../../components/icon/icon.js');
|
|
7
|
-
var video = require('../../components/video/video.js');
|
|
8
|
-
var material = require('@ricons/material');
|
|
9
|
-
var type = require('./type.js');
|
|
10
|
-
|
|
11
|
-
function renderFile(props) {
|
|
12
|
-
const { name, suffix, type: type$1 } = props;
|
|
13
|
-
switch (type$1) {
|
|
14
|
-
case type.TFileType.IMAGE:
|
|
15
|
-
return jsxRuntime.jsx("img", { src: props.src });
|
|
16
|
-
case type.TFileType.VIDEO:
|
|
17
|
-
return jsxRuntime.jsx(video.default, { ...props });
|
|
18
|
-
default:
|
|
19
|
-
return (jsxRuntime.jsxs("div", { className: "i-preview-unknown", children: [jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.FeedOutlined, {}), size: "3em" }), jsxRuntime.jsx("h5", { className: "mt-4", children: name || suffix })] }));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.default = renderFile;
|
|
24
|
-
//# sourceMappingURL=renderFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderFile.js","sources":["../../../../packages/js/usePreview/renderFile.tsx"],"sourcesContent":["import Icon from \"@p/components/icon\";\nimport Video from \"@p/components/video\";\nimport { FeedOutlined } from \"@ricons/material\";\nimport { TFileType, TPreviewItem } from \"./type\";\n\nexport default function renderFile(props: TPreviewItem) {\n const { name, suffix, type } = props;\n\n switch (type) {\n case TFileType.IMAGE:\n return <img src={props.src} />;\n case TFileType.VIDEO:\n return <Video {...props} />;\n default:\n return (\n <div className=\"i-preview-unknown\">\n <Icon icon={<FeedOutlined />} size=\"3em\" />\n <h5 className=\"mt-4\">{name || suffix}</h5>\n </div>\n );\n }\n}\n"],"names":["type","TFileType","_jsx","Video","_jsxs","Icon","FeedOutlined"],"mappings":";;;;;;;;;;AAKc,SAAU,UAAU,CAAC,KAAmB,EAAA;IAClD,MAAM,EAAE,IAAI,EAAE,MAAM,QAAEA,MAAI,EAAE,GAAG,KAAK;IAEpC,QAAQA,MAAI;QACR,KAAKC,cAAS,CAAC,KAAK;AAChB,YAAA,OAAOC,wBAAK,GAAG,EAAE,KAAK,CAAC,GAAG,GAAI;QAClC,KAAKD,cAAS,CAAC,KAAK;AAChB,YAAA,OAAOC,cAAA,CAACC,aAAK,EAAA,EAAA,GAAK,KAAK,GAAI;AAC/B,QAAA;AACI,YAAA,QACIC,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,mBAAmB,EAAA,QAAA,EAAA,CAC9BF,cAAA,CAACG,YAAI,EAAA,EAAC,IAAI,EAAEH,cAAA,CAACI,qBAAY,EAAA,EAAA,CAAG,EAAE,IAAI,EAAC,KAAK,EAAA,CAAG,EAC3CJ,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,MAAM,EAAA,QAAA,EAAE,IAAI,IAAI,MAAM,EAAA,CAAM,CAAA,EAAA,CACxC;;AAGtB;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
exports.TFileType = void 0;
|
|
4
|
-
(function (TFileType) {
|
|
5
|
-
TFileType["IMAGE"] = "IMAGE";
|
|
6
|
-
TFileType["VIDEO"] = "VIDEO";
|
|
7
|
-
TFileType["AUDIO"] = "AUDIO";
|
|
8
|
-
TFileType["PDF"] = "PDF";
|
|
9
|
-
TFileType["EXCEL"] = "EXCEL";
|
|
10
|
-
TFileType["TXT"] = "TXT";
|
|
11
|
-
TFileType["UNKNOWN"] = "UNKNOWN";
|
|
12
|
-
})(exports.TFileType || (exports.TFileType = {}));
|
|
13
|
-
//# sourceMappingURL=type.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sources":["../../../../packages/js/usePreview/type.ts"],"sourcesContent":["import { CSSProperties, ReactNode } from \"react\";\nimport type { IModal } from \"../../components/modal/type\";\n\nexport type TPreviewItem = {\n\tsrc: string;\n\tname?: ReactNode;\n\tthumb?: string;\n\trotate?: number;\n\tzoom?: number;\n\tstyle?: CSSProperties;\n\ttype?: string;\n\tsuffix?: string;\n};\n\nexport enum TFileType {\n\tIMAGE = \"IMAGE\",\n\tVIDEO = \"VIDEO\",\n\tAUDIO = \"AUDIO\",\n\tPDF = \"PDF\",\n\tEXCEL = \"EXCEL\",\n\tTXT = \"TXT\",\n\tUNKNOWN = \"UNKNOWN\",\n}\n\nexport interface IPreview {\n\titems: (TPreviewItem | string)[];\n\tinitial?: number;\n\tcontrols?: boolean;\n\tloop?: boolean;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tmodalProps?: IModal;\n\trenderImage?: (file: TPreviewItem) => ReactNode;\n\trenderFile?: (file: TPreviewItem) => ReactNode;\n\tonClose?: () => void;\n\tonChange?: (after: number, before?: number) => void;\n\tonZoom?: (scale: number) => void;\n\tonRotate?: (deg: number) => void;\n}\n"],"names":["TFileType"],"mappings":";;AAcYA;AAAZ,CAAA,UAAY,SAAS,EAAA;AACpB,IAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACpB,CAAC,EARWA,iBAAS,KAATA,iBAAS,GAAA,EAAA,CAAA,CAAA;;"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const TIMEOUT = 500;
|
|
6
|
-
const useRipple = () => {
|
|
7
|
-
if (!document)
|
|
8
|
-
return;
|
|
9
|
-
if (document.documentElement.dataset["iocaRipple"])
|
|
10
|
-
return;
|
|
11
|
-
document.documentElement.dataset["iocaRipple"] = "enable";
|
|
12
|
-
document.addEventListener("mousedown", listener);
|
|
13
|
-
};
|
|
14
|
-
function listener(e) {
|
|
15
|
-
const target = e.target;
|
|
16
|
-
const parent = target.closest("[data-ripple]");
|
|
17
|
-
if (!target || !parent)
|
|
18
|
-
return;
|
|
19
|
-
triggerRipple(parent, e);
|
|
20
|
-
}
|
|
21
|
-
function triggerRipple(target, e) {
|
|
22
|
-
if (!document)
|
|
23
|
-
return;
|
|
24
|
-
const [$box, $ripple] = createRipple();
|
|
25
|
-
const rect = target.getBoundingClientRect();
|
|
26
|
-
const size = Math.max(rect.width, rect.height) * 2;
|
|
27
|
-
$ripple.style.cssText = `
|
|
28
|
-
left: ${e.pageX - rect.left}px;
|
|
29
|
-
top: ${e.pageY - rect.top}px;
|
|
30
|
-
width: ${size}px;
|
|
31
|
-
height: ${size}px;
|
|
32
|
-
transition: all ${TIMEOUT / 1000}s;
|
|
33
|
-
`;
|
|
34
|
-
target.insertAdjacentElement("afterbegin", $box);
|
|
35
|
-
target.offsetHeight;
|
|
36
|
-
$ripple.classList.add("i-ripple-active");
|
|
37
|
-
setTimeout(() => {
|
|
38
|
-
$box.remove();
|
|
39
|
-
}, TIMEOUT);
|
|
40
|
-
}
|
|
41
|
-
function createRipple() {
|
|
42
|
-
const $box = document.createElement("SPAN");
|
|
43
|
-
const $ripple = document.createElement("SPAN");
|
|
44
|
-
$box.className = "i-ripple-container";
|
|
45
|
-
$ripple.className = "i-ripple";
|
|
46
|
-
$box.append($ripple);
|
|
47
|
-
return [$box, $ripple];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
exports.default = useRipple;
|
|
51
|
-
//# sourceMappingURL=index.js.map
|