@ioca/react 1.3.2 → 1.3.4
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/components/affix/affix.js +2 -0
- package/lib/components/affix/affix.js.map +1 -0
- package/lib/components/affix/index.js +2 -0
- package/lib/components/affix/index.js.map +1 -0
- package/lib/components/affix/totop.js +2 -0
- package/lib/components/affix/totop.js.map +1 -0
- package/lib/components/badge/badge.js +2 -0
- package/lib/components/badge/badge.js.map +1 -0
- package/lib/components/badge/index.js +2 -0
- package/lib/components/badge/index.js.map +1 -0
- package/lib/components/button/button.js +2 -0
- package/lib/components/button/button.js.map +1 -0
- package/lib/components/button/group.js +2 -0
- package/lib/components/button/group.js.map +1 -0
- package/lib/components/button/index.js +2 -0
- package/lib/components/button/index.js.map +1 -0
- package/lib/components/button/toggle.js +2 -0
- package/lib/components/button/toggle.js.map +1 -0
- package/lib/components/card/card.js +2 -0
- package/lib/components/card/card.js.map +1 -0
- package/lib/components/card/index.js +2 -0
- package/lib/components/card/index.js.map +1 -0
- package/lib/components/checkbox/checkbox.js +2 -0
- package/lib/components/checkbox/checkbox.js.map +1 -0
- package/lib/components/checkbox/index.js +2 -0
- package/lib/components/checkbox/index.js.map +1 -0
- package/lib/components/checkbox/item.js +2 -0
- package/lib/components/checkbox/item.js.map +1 -0
- package/lib/components/collapse/collapse.js +2 -0
- package/lib/components/collapse/collapse.js.map +1 -0
- package/lib/components/collapse/index.js +2 -0
- package/lib/components/collapse/index.js.map +1 -0
- package/lib/components/collapse/item.js +2 -0
- package/lib/components/collapse/item.js.map +1 -0
- package/lib/components/datagrid/cell.js +2 -0
- package/lib/components/datagrid/cell.js.map +1 -0
- package/lib/components/datagrid/datagrid.js +2 -0
- package/lib/components/datagrid/datagrid.js.map +1 -0
- package/lib/components/datagrid/index.js +2 -0
- package/lib/components/datagrid/index.js.map +1 -0
- package/lib/components/datagrid/resize.js +2 -0
- package/lib/components/datagrid/resize.js.map +1 -0
- package/lib/components/datagrid/row.js +2 -0
- package/lib/components/datagrid/row.js.map +1 -0
- package/lib/components/datagrid/sorter.js +2 -0
- package/lib/components/datagrid/sorter.js.map +1 -0
- package/lib/components/description/description.js +2 -0
- package/lib/components/description/description.js.map +1 -0
- package/lib/components/description/index.js +2 -0
- package/lib/components/description/index.js.map +1 -0
- package/lib/components/drawer/drawer.js +2 -0
- package/lib/components/drawer/drawer.js.map +1 -0
- package/lib/components/drawer/index.js +2 -0
- package/lib/components/drawer/index.js.map +1 -0
- package/lib/components/dropdown/dropdown.js +2 -0
- package/lib/components/dropdown/dropdown.js.map +1 -0
- package/lib/components/dropdown/index.js +2 -0
- package/lib/components/dropdown/index.js.map +1 -0
- package/lib/components/dropdown/item.js +2 -0
- package/lib/components/dropdown/item.js.map +1 -0
- package/lib/components/editor/controls.js +2 -0
- package/lib/components/editor/controls.js.map +1 -0
- package/lib/components/editor/editor.js +2 -0
- package/lib/components/editor/editor.js.map +1 -0
- package/lib/components/editor/index.js +2 -0
- package/lib/components/editor/index.js.map +1 -0
- package/lib/components/flex/flex.js +2 -0
- package/lib/components/flex/flex.js.map +1 -0
- package/lib/components/flex/index.js +2 -0
- package/lib/components/flex/index.js.map +1 -0
- package/lib/components/form/context.js +2 -0
- package/lib/components/form/context.js.map +1 -0
- package/lib/components/form/field.js +2 -0
- package/lib/components/form/field.js.map +1 -0
- package/lib/components/form/form.js +2 -0
- package/lib/components/form/form.js.map +1 -0
- package/lib/components/form/index.js +2 -0
- package/lib/components/form/index.js.map +1 -0
- package/lib/components/form/useForm.js +2 -0
- package/lib/components/form/useForm.js.map +1 -0
- package/lib/components/icon/icon.js +2 -0
- package/lib/components/icon/icon.js.map +1 -0
- package/lib/components/icon/index.js +2 -0
- package/lib/components/icon/index.js.map +1 -0
- package/lib/components/image/image.js +2 -0
- package/lib/components/image/image.js.map +1 -0
- package/lib/components/image/index.js +2 -0
- package/lib/components/image/index.js.map +1 -0
- package/lib/components/image/list.js +2 -0
- package/lib/components/image/list.js.map +1 -0
- package/lib/components/input/container.js +2 -0
- package/lib/components/input/container.js.map +1 -0
- package/lib/components/input/index.js +2 -0
- package/lib/components/input/index.js.map +1 -0
- package/lib/components/input/input.js +2 -0
- package/lib/components/input/input.js.map +1 -0
- package/lib/components/input/number.js +2 -0
- package/lib/components/input/number.js.map +1 -0
- package/lib/components/input/range.js +2 -0
- package/lib/components/input/range.js.map +1 -0
- package/lib/components/input/textarea.js +2 -0
- package/lib/components/input/textarea.js.map +1 -0
- package/lib/components/list/index.js +2 -0
- package/lib/components/list/index.js.map +1 -0
- package/lib/components/list/item.js +2 -0
- package/lib/components/list/item.js.map +1 -0
- package/lib/components/list/list.js +2 -0
- package/lib/components/list/list.js.map +1 -0
- package/lib/components/loading/index.js +2 -0
- package/lib/components/loading/index.js.map +1 -0
- package/lib/components/loading/loading.js +2 -0
- package/lib/components/loading/loading.js.map +1 -0
- package/lib/components/message/index.js +2 -0
- package/lib/components/message/index.js.map +1 -0
- package/lib/components/message/message.js +2 -0
- package/lib/components/message/message.js.map +1 -0
- package/lib/components/modal/hookModal.js +2 -0
- package/lib/components/modal/hookModal.js.map +1 -0
- package/lib/components/modal/index.js +2 -0
- package/lib/components/modal/index.js.map +1 -0
- package/lib/components/modal/modal.js +2 -0
- package/lib/components/modal/modal.js.map +1 -0
- package/lib/components/modal/useModal.js +2 -0
- package/lib/components/modal/useModal.js.map +1 -0
- package/lib/components/pagination/index.js +2 -0
- package/lib/components/pagination/index.js.map +1 -0
- package/lib/components/pagination/page.js +2 -0
- package/lib/components/pagination/page.js.map +1 -0
- package/lib/components/pagination/pagination.js +2 -0
- package/lib/components/pagination/pagination.js.map +1 -0
- package/lib/components/picker/colors/footer.js +2 -0
- package/lib/components/picker/colors/footer.js.map +1 -0
- package/lib/components/picker/colors/handle.js +2 -0
- package/lib/components/picker/colors/handle.js.map +1 -0
- package/lib/components/picker/colors/index.js +2 -0
- package/lib/components/picker/colors/index.js.map +1 -0
- package/lib/components/picker/dates/dates.js +2 -0
- package/lib/components/picker/dates/dates.js.map +1 -0
- package/lib/components/picker/dates/index.js +2 -0
- package/lib/components/picker/dates/index.js.map +1 -0
- package/lib/components/picker/dates/panel.js +2 -0
- package/lib/components/picker/dates/panel.js.map +1 -0
- package/lib/components/picker/time/index.js +2 -0
- package/lib/components/picker/time/index.js.map +1 -0
- package/lib/components/picker/time/item.js +2 -0
- package/lib/components/picker/time/item.js.map +1 -0
- package/lib/components/picker/time/panel.js +2 -0
- package/lib/components/picker/time/panel.js.map +1 -0
- package/lib/components/popconfirm/index.js +2 -0
- package/lib/components/popconfirm/index.js.map +1 -0
- package/lib/components/popconfirm/popconfirm.js +2 -0
- package/lib/components/popconfirm/popconfirm.js.map +1 -0
- package/lib/components/popup/content.js +2 -0
- package/lib/components/popup/content.js.map +1 -0
- package/lib/components/popup/index.js +2 -0
- package/lib/components/popup/index.js.map +1 -0
- package/lib/components/popup/popup.js +2 -0
- package/lib/components/popup/popup.js.map +1 -0
- package/lib/components/progress/circle.js +2 -0
- package/lib/components/progress/circle.js.map +1 -0
- package/lib/components/progress/index.js +2 -0
- package/lib/components/progress/index.js.map +1 -0
- package/lib/components/progress/line.js +2 -0
- package/lib/components/progress/line.js.map +1 -0
- package/lib/components/progress/progress.js +2 -0
- package/lib/components/progress/progress.js.map +1 -0
- package/lib/components/radio/index.js +2 -0
- package/lib/components/radio/index.js.map +1 -0
- package/lib/components/radio/item.js +2 -0
- package/lib/components/radio/item.js.map +1 -0
- package/lib/components/radio/radio.js +2 -0
- package/lib/components/radio/radio.js.map +1 -0
- package/lib/components/resizable/index.js +2 -0
- package/lib/components/resizable/index.js.map +1 -0
- package/lib/components/resizable/resizable.js +2 -0
- package/lib/components/resizable/resizable.js.map +1 -0
- package/lib/components/select/index.js +2 -0
- package/lib/components/select/index.js.map +1 -0
- package/lib/components/select/options.js +2 -0
- package/lib/components/select/options.js.map +1 -0
- package/lib/components/select/select.js +2 -0
- package/lib/components/select/select.js.map +1 -0
- package/lib/components/step/divider.js +2 -0
- package/lib/components/step/divider.js.map +1 -0
- package/lib/components/step/index.js +2 -0
- package/lib/components/step/index.js.map +1 -0
- package/lib/components/step/item.js +2 -0
- package/lib/components/step/item.js.map +1 -0
- package/lib/components/step/step.js +2 -0
- package/lib/components/step/step.js.map +1 -0
- package/lib/components/swiper/index.js +2 -0
- package/lib/components/swiper/index.js.map +1 -0
- package/lib/components/swiper/item.js +2 -0
- package/lib/components/swiper/item.js.map +1 -0
- package/lib/components/swiper/swiper.js +2 -0
- package/lib/components/swiper/swiper.js.map +1 -0
- package/lib/components/tabs/index.js +2 -0
- package/lib/components/tabs/index.js.map +1 -0
- package/lib/components/tabs/item.js +2 -0
- package/lib/components/tabs/item.js.map +1 -0
- package/lib/components/tabs/tabs.js +2 -0
- package/lib/components/tabs/tabs.js.map +1 -0
- package/lib/components/tag/index.js +2 -0
- package/lib/components/tag/index.js.map +1 -0
- package/lib/components/tag/tag.js +2 -0
- package/lib/components/tag/tag.js.map +1 -0
- package/lib/components/text/highlight.js +2 -0
- package/lib/components/text/highlight.js.map +1 -0
- package/lib/components/text/index.js +2 -0
- package/lib/components/text/index.js.map +1 -0
- package/lib/components/text/number.js +2 -0
- package/lib/components/text/number.js.map +1 -0
- package/lib/components/text/text.js +2 -0
- package/lib/components/text/text.js.map +1 -0
- package/lib/components/text/time.js +2 -0
- package/lib/components/text/time.js.map +1 -0
- package/lib/components/tree/index.js +2 -0
- package/lib/components/tree/index.js.map +1 -0
- package/lib/components/tree/item.js +2 -0
- package/lib/components/tree/item.js.map +1 -0
- package/lib/components/tree/tree.js +2 -0
- package/lib/components/tree/tree.js.map +1 -0
- package/lib/components/upload/index.js +2 -0
- package/lib/components/upload/index.js.map +1 -0
- package/lib/components/upload/renderFile.js +2 -0
- package/lib/components/upload/renderFile.js.map +1 -0
- package/lib/components/upload/upload.js +2 -0
- package/lib/components/upload/upload.js.map +1 -0
- package/lib/components/utils/empty/index.js +2 -0
- package/lib/components/utils/empty/index.js.map +1 -0
- package/lib/components/utils/helpericon/helpericon.js +2 -0
- package/lib/components/utils/helpericon/helpericon.js.map +1 -0
- package/lib/components/utils/helpericon/index.js +2 -0
- package/lib/components/utils/helpericon/index.js.map +1 -0
- package/lib/components/video/index.js +2 -0
- package/lib/components/video/index.js.map +1 -0
- package/lib/components/video/video.js +2 -0
- package/lib/components/video/video.js.map +1 -0
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/js/hooks.js +2 -0
- package/lib/js/hooks.js.map +1 -0
- package/lib/js/usePreview/content.js +2 -0
- package/lib/js/usePreview/content.js.map +1 -0
- package/lib/js/usePreview/index.js +2 -0
- package/lib/js/usePreview/index.js.map +1 -0
- package/lib/js/usePreview/renderFile.js +2 -0
- package/lib/js/usePreview/renderFile.js.map +1 -0
- package/lib/js/usePreview/type.js +2 -0
- package/lib/js/usePreview/type.js.map +1 -0
- package/lib/js/useRipple/index.js +2 -0
- package/lib/js/useRipple/index.js.map +1 -0
- package/lib/js/utils.js +2 -0
- package/lib/js/utils.js.map +1 -0
- package/lib/types/components/affix/affix.d.ts +12 -0
- package/lib/types/components/affix/index.d.ts +7 -0
- package/lib/types/components/affix/totop.d.ts +8 -0
- package/lib/types/components/affix/type.d.ts +15 -0
- package/lib/types/components/badge/badge.d.ts +8 -0
- package/lib/types/components/badge/index.d.ts +7 -0
- package/lib/types/components/badge/type.d.ts +17 -0
- package/lib/types/components/button/button.d.ts +7 -0
- package/lib/types/components/button/group.d.ts +8 -0
- package/lib/types/components/button/index.d.ts +7 -0
- package/lib/types/components/button/toggle.d.ts +8 -0
- package/lib/types/components/button/type.d.ts +46 -0
- package/lib/types/components/card/card.d.ts +8 -0
- package/lib/types/components/card/index.d.ts +7 -0
- package/lib/types/components/card/type.d.ts +15 -0
- package/lib/types/components/checkbox/checkbox.d.ts +12 -0
- package/lib/types/components/checkbox/index.d.ts +7 -0
- package/lib/types/components/checkbox/item.d.ts +8 -0
- package/lib/types/components/checkbox/type.d.ts +26 -0
- package/lib/types/components/collapse/collapse.d.ts +12 -0
- package/lib/types/components/collapse/index.d.ts +7 -0
- package/lib/types/components/collapse/item.d.ts +8 -0
- package/lib/types/components/collapse/type.d.ts +25 -0
- package/lib/types/components/datagrid/datagrid.d.ts +8 -0
- package/lib/types/components/datagrid/index.d.ts +7 -0
- package/lib/types/components/datagrid/type.d.ts +42 -0
- package/lib/types/components/description/description.d.ts +8 -0
- package/lib/types/components/description/index.d.ts +7 -0
- package/lib/types/components/description/type.d.ts +27 -0
- package/lib/types/components/drawer/drawer.d.ts +7 -0
- package/lib/types/components/drawer/index.d.ts +7 -0
- package/lib/types/components/drawer/type.d.ts +18 -0
- package/lib/types/components/dropdown/dropdown.d.ts +11 -0
- package/lib/types/components/dropdown/index.d.ts +7 -0
- package/lib/types/components/dropdown/type.d.ts +15 -0
- package/lib/types/components/editor/editor.d.ts +8 -0
- package/lib/types/components/editor/index.d.ts +7 -0
- package/lib/types/components/editor/type.d.ts +21 -0
- package/lib/types/components/flex/flex.d.ts +7 -0
- package/lib/types/components/flex/index.d.ts +7 -0
- package/lib/types/components/flex/type.d.ts +15 -0
- package/lib/types/components/form/field.d.ts +8 -0
- package/lib/types/components/form/form.d.ts +14 -0
- package/lib/types/components/form/index.d.ts +7 -0
- package/lib/types/components/form/type.d.ts +32 -0
- package/lib/types/components/form/useForm.d.ts +19 -0
- package/lib/types/components/icon/icon.d.ts +8 -0
- package/lib/types/components/icon/index.d.ts +7 -0
- package/lib/types/components/icon/type.d.ts +14 -0
- package/lib/types/components/image/image.d.ts +7 -0
- package/lib/types/components/image/index.d.ts +7 -0
- package/lib/types/components/image/list.d.ts +8 -0
- package/lib/types/components/image/type.d.ts +30 -0
- package/lib/types/components/input/index.d.ts +7 -0
- package/lib/types/components/input/input.d.ts +7 -0
- package/lib/types/components/input/number.d.ts +8 -0
- package/lib/types/components/input/range.d.ts +8 -0
- package/lib/types/components/input/textarea.d.ts +8 -0
- package/lib/types/components/input/type.d.ts +48 -0
- package/lib/types/components/list/index.d.ts +7 -0
- package/lib/types/components/list/list.d.ts +11 -0
- package/lib/types/components/list/type.d.ts +17 -0
- package/lib/types/components/loading/index.d.ts +7 -0
- package/lib/types/components/loading/loading.d.ts +8 -0
- package/lib/types/components/loading/type.d.ts +12 -0
- package/lib/types/components/message/index.d.ts +7 -0
- package/lib/types/components/message/message.d.ts +26 -0
- package/lib/types/components/message/type.d.ts +23 -0
- package/lib/types/components/modal/index.d.ts +7 -0
- package/lib/types/components/modal/modal.d.ts +7 -0
- package/lib/types/components/modal/type.d.ts +33 -0
- package/lib/types/components/modal/useModal.d.ts +11 -0
- package/lib/types/components/pagination/index.d.ts +7 -0
- package/lib/types/components/pagination/pagination.d.ts +8 -0
- package/lib/types/components/pagination/type.d.ts +20 -0
- package/lib/types/components/picker/colors/index.d.ts +8 -0
- package/lib/types/components/picker/dates/index.d.ts +8 -0
- package/lib/types/components/picker/time/index.d.ts +8 -0
- package/lib/types/components/picker/type.d.ts +43 -0
- package/lib/types/components/popconfirm/index.d.ts +7 -0
- package/lib/types/components/popconfirm/popconfirm.d.ts +8 -0
- package/lib/types/components/popconfirm/type.d.ts +16 -0
- package/lib/types/components/popup/index.d.ts +7 -0
- package/lib/types/components/popup/popup.d.ts +8 -0
- package/lib/types/components/popup/type.d.ts +31 -0
- package/lib/types/components/progress/index.d.ts +7 -0
- package/lib/types/components/progress/progress.d.ts +8 -0
- package/lib/types/components/progress/type.d.ts +25 -0
- package/lib/types/components/radio/index.d.ts +7 -0
- package/lib/types/components/radio/item.d.ts +8 -0
- package/lib/types/components/radio/radio.d.ts +12 -0
- package/lib/types/components/radio/type.d.ts +22 -0
- package/lib/types/components/resizable/index.d.ts +7 -0
- package/lib/types/components/resizable/resizable.d.ts +8 -0
- package/lib/types/components/resizable/type.d.ts +21 -0
- package/lib/types/components/select/index.d.ts +7 -0
- package/lib/types/components/select/select.d.ts +8 -0
- package/lib/types/components/select/type.d.ts +24 -0
- package/lib/types/components/step/index.d.ts +7 -0
- package/lib/types/components/step/item.d.ts +8 -0
- package/lib/types/components/step/step.d.ts +12 -0
- package/lib/types/components/step/type.d.ts +21 -0
- package/lib/types/components/swiper/index.d.ts +7 -0
- package/lib/types/components/swiper/item.d.ts +8 -0
- package/lib/types/components/swiper/swiper.d.ts +7 -0
- package/lib/types/components/swiper/type.d.ts +54 -0
- package/lib/types/components/tabs/index.d.ts +7 -0
- package/lib/types/components/tabs/item.d.ts +8 -0
- package/lib/types/components/tabs/tabs.d.ts +7 -0
- package/lib/types/components/tabs/type.d.ts +46 -0
- package/lib/types/components/tag/index.d.ts +7 -0
- package/lib/types/components/tag/tag.d.ts +8 -0
- package/lib/types/components/tag/type.d.ts +16 -0
- package/lib/types/components/text/highlight.d.ts +8 -0
- package/lib/types/components/text/index.d.ts +7 -0
- package/lib/types/components/text/number.d.ts +8 -0
- package/lib/types/components/text/text.d.ts +7 -0
- package/lib/types/components/text/time.d.ts +8 -0
- package/lib/types/components/text/type.d.ts +45 -0
- package/lib/types/components/tree/index.d.ts +7 -0
- package/lib/types/components/tree/tree.d.ts +8 -0
- package/lib/types/components/tree/type.d.ts +50 -0
- package/lib/types/components/upload/index.d.ts +7 -0
- package/lib/types/components/upload/type.d.ts +38 -0
- package/lib/types/components/upload/upload.d.ts +8 -0
- package/lib/types/components/video/index.d.ts +7 -0
- package/lib/types/components/video/type.d.ts +29 -0
- package/lib/types/components/video/video.d.ts +8 -0
- package/lib/types/index.d.ts +41 -1021
- package/lib/types/js/usePreview/index.d.ts +7 -0
- package/lib/types/js/usePreview/type.d.ts +32 -0
- package/lib/types/type/index.d.ts +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.js","sources":["../../../packages/components/form/useForm.ts"],"sourcesContent":["import PubSub from \"pubsub-js\";\nimport { uid } from \"radash\";\nimport { useRef } from \"react\";\nimport { IForm, TRule } from \"./type\";\n\nexport class IFormInstance {\n\treadonly id?: string;\n\tdata: Record<string, any> = {};\n\tcacheData: Record<string, any> = {};\n\trules?: Pick<IForm, \"rules\"> = {};\n\n\tconstructor() {\n\t\tthis.id = uid(8);\n\t\tthis.data = {};\n\t}\n\n\tget(field?: string) {\n\t\treturn field ? this.data[field] : this.data;\n\t}\n\n\tset(field: any, value?: any) {\n\t\tconst id = this.id;\n\t\tif (!this.data) return;\n\n\t\tif (typeof field === \"string\") {\n\t\t\tthis.data[field] = value;\n\t\t\tthis.cacheData[field] = value;\n\t\t\tPubSub.publish(`${id}:set:${field}`, value);\n\t\t\treturn;\n\t\t}\n\n\t\tObject.keys(field).map((name) => {\n\t\t\tthis.data[name] = field[name];\n\t\t\tthis.cacheData[name] = field[name];\n\t\t\tPubSub.publish(`${id}:set:${name}`, field[name]);\n\t\t});\n\t}\n\n\tdelete(field) {\n\t\tdelete this.data[field];\n\t}\n\n\tclear() {\n\t\tif (!this.data) return;\n\t\tthis.cacheData = {};\n\n\t\tObject.keys(this.data).map((name) => {\n\t\t\tPubSub.publish(`${this.id}:set:${name}`, undefined);\n\t\t\tthis.data[name] = undefined;\n\t\t});\n\t}\n\n\tasync validate(field?: string) {\n\t\tconst { id, rules, data } = this;\n\t\tif (!rules) return data;\n\n\t\tif (field) {\n\t\t\tconst o = rules[field];\n\t\t\tconst rule: TRule = {\n\t\t\t\tvalidator: (v) =>\n\t\t\t\t\tArray.isArray(v)\n\t\t\t\t\t\t? v.length > 0\n\t\t\t\t\t\t: ![undefined, null, \"\"].includes(v),\n\t\t\t\tmessage: undefined,\n\t\t\t};\n\n\t\t\tif (typeof o === \"function\") {\n\t\t\t\trule.validator = o;\n\t\t\t} else if (o === true) {\n\t\t\t\trule.message = \"required\";\n\t\t\t} else {\n\t\t\t\tObject.assign(rule, o);\n\t\t\t}\n\n\t\t\tconst isValid = rule.validator?.(data[field], this);\n\n\t\t\tif (!isValid) {\n\t\t\t\tPubSub.publish(`${id}:invalid:${field}`, {\n\t\t\t\t\tmessage: rule.message,\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tPubSub.publish(`${id}:invalid:${name}`, {\n\t\t\t\tmessage: null,\n\t\t\t\tstatus: \"normal\",\n\t\t\t});\n\t\t\treturn true;\n\t\t}\n\n\t\tlet isAllValid = true;\n\n\t\tObject.keys(data).map((name) => {\n\t\t\tconst o = rules[name];\n\t\t\tif (o === undefined) return;\n\n\t\t\tconst rule: TRule = {\n\t\t\t\tvalidator: (v) => (Array.isArray(v) ? v.length > 0 : !!v),\n\t\t\t\tmessage: undefined,\n\t\t\t};\n\n\t\t\tif (typeof o === \"function\") {\n\t\t\t\trule.validator = o;\n\t\t\t} else if (o === true) {\n\t\t\t\trule.message = \"required\";\n\t\t\t} else {\n\t\t\t\tObject.assign(rule, o);\n\t\t\t}\n\n\t\t\tconst isValid = rule.validator?.(data[name], this);\n\n\t\t\tif (!isValid) {\n\t\t\t\tPubSub.publish(`${id}:invalid:${name}`, {\n\t\t\t\t\tmessage: rule.message,\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t});\n\t\t\t\tisAllValid = false;\n\t\t\t} else {\n\t\t\t\tPubSub.publish(`${id}:invalid:${name}`, {\n\t\t\t\t\tmessage: null,\n\t\t\t\t\tstatus: \"normal\",\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\treturn isAllValid ? Promise.resolve(data) : false;\n\t}\n}\n\nexport default function useForm(form?: IFormInstance) {\n\tconst formRef = useRef<IFormInstance>(null);\n\n\tif (!formRef.current) {\n\t\tformRef.current = form ?? new IFormInstance();\n\t}\n\n\treturn formRef.current;\n}\n"],"names":["IFormInstance","id","data","cacheData","rules","constructor","this","uid","get","field","set","value","PubSub","publish","Object","keys","map","name","clear","undefined","validate","o","rule","validator","v","Array","isArray","length","includes","message","assign","isValid","status","isAllValid","Promise","resolve","useForm","form","formRef","useRef","current"],"mappings":"2FAKaA,EACHC,GACTC,KAA4B,CAAE,EAC9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AAcgB,OAAQ,CACvCY,QAAS,KACTG,OAAQ,YAEF,IAXNpB,EAAOC,QAAQ,GAAGZ,aAAcQ,IAAS,CACxCoB,QAASP,EAAKO,QACdG,OAAQ,WAEF,GAUT,IAAIC,GAAa,EAmCjB,OAjCAnB,OAAOC,KAAKb,GAAMc,KAAKC,IACtB,MAAMI,EAAIjB,EAAMa,GAChB,QAAUE,IAANE,EAAiB,OAErB,MAAMC,EAAc,CACnBC,UAAYC,GAAOC,MAAMC,QAAQF,GAAKA,EAAEG,OAAS,IAAMH,EACvDK,aAASV,GAGO,mBAANE,EACVC,EAAKC,UAAYF,GACD,IAANA,EACVC,EAAKO,QAAU,WAEff,OAAOgB,OAAOR,EAAMD,GAGrB,MAAMU,EAAUT,EAAKC,YAAYrB,EAAKe,GAAOX,MAExCyB,EAOJnB,EAAOC,QAAQ,GAAGZ,aAAcgB,IAAQ,CACvCY,QAAS,KACTG,OAAQ,YARTpB,EAAOC,QAAQ,GAAGZ,aAAcgB,IAAQ,CACvCY,QAASP,EAAKO,QACdG,OAAQ,UAETC,GAAa,QASRA,GAAaC,QAAQC,QAAQjC,IAId,SAAAkC,EAAQC,GAC/B,MAAMC,EAAUC,EAAsB,MAMtC,OAJKD,EAAQE,UACZF,EAAQE,QAAUH,GAAQ,IAAIrC,GAGxBsC,EAAQE,OAChB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import t from"classnames";import{isValidElement as e,cloneElement as r}from"react";const s=s=>{const{ref:o,icon:a,size:i="1.425em",rotate:c,style:m,className:n,...f}=s;if(!e(a))return a;const l={ref:o,style:{transform:c?`rotate(${c}deg)`:void 0,...m,width:i,height:i},className:t("i-icon",n),...f};return r(a,l)};export{s as default};
|
|
2
|
+
//# sourceMappingURL=icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.js","sources":["../../../packages/components/icon/icon.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { cloneElement, isValidElement } from \"react\";\nimport \"./index.css\";\nimport { IIcon } from \"./type\";\n\nconst Icon = (props: IIcon) => {\n\tconst {\n\t\tref,\n\t\ticon,\n\t\tsize = \"1.425em\",\n\t\trotate,\n\t\tstyle,\n\t\tclassName,\n\t\t...restProps\n\t} = props;\n\n\tif (!isValidElement(icon)) return icon;\n\n\tconst iconProps = {\n\t\tref,\n\t\tstyle: {\n\t\t\ttransform: rotate ? `rotate(${rotate}deg)` : undefined,\n\t\t\t...style,\n\t\t\twidth: size,\n\t\t\theight: size,\n\t\t},\n\t\tclassName: classNames(\"i-icon\", className),\n\t\t...restProps,\n\t};\n\n\treturn cloneElement(icon, iconProps);\n};\n\nexport default Icon;\n"],"names":["Icon","props","ref","icon","size","rotate","style","className","restProps","isValidElement","iconProps","transform","undefined","width","height","classNames","cloneElement"],"mappings":"mFAKA,MAAMA,EAAQC,IACb,MAAMC,IACLA,EAAGC,KACHA,EAAIC,KACJA,EAAO,UAASC,OAChBA,EAAMC,MACNA,EAAKC,UACLA,KACGC,GACAP,EAEJ,IAAKQ,EAAeN,GAAO,OAAOA,EAElC,MAAMO,EAAY,CACjBR,MACAI,MAAO,CACNK,UAAWN,EAAS,UAAUA,aAAeO,KAC1CN,EACHO,MAAOT,EACPU,OAAQV,GAETG,UAAWQ,EAAW,SAAUR,MAC7BC,GAGJ,OAAOQ,EAAab,EAAMO,EAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as r,jsxs as o,Fragment as t}from"react/jsx-runtime";import{HideImageTwotone as s}from"@ricons/material";import{useReactive as e}from"ahooks";import i from"classnames";import{useRef as a,useEffect as c}from"react";import{useIntersectionObserver as n}from"../../js/hooks.js";import l from"../../js/usePreview/index.js";import m from"../icon/icon.js";import d from"../loading/loading.js";const u=u=>{const{src:f,round:g,size:p,initSize:v,lazyload:h,fallback:j=r(m,{icon:r(s,{}),size:"2em",className:"color-5"}),fit:b,style:k,className:y,cover:w,coverClass:z,usePreview:C,onLoad:N,onError:x,onClick:E,...A}=u,L=e({status:"loading"}),P=a(null),F=b?"100%":void 0,{observe:G,unobserve:I}=n(),M=l(),S=r=>{E?.(r),C&&f&&M({items:[{src:f,type:"IMAGE"}]})};c((()=>{if(f&&(P.current?.complete||(L.status="loading"),h&&P.current))return G(P.current,((r,o)=>{o&&(r.setAttribute("src",r.dataset.src||""),I(r))})),()=>{P.current&&I(P.current)}}),[f]),A[h?"data-src":"src"]=f;const $="loading"===L.status?v:void 0;return r("div",{style:{width:p??$,height:p??$,...k},className:i("i-image",y,{rounded:g,[`i-image-${L.status}`]:L.status}),children:"error"===L.status?j:o(t,{children:[f&&r("img",{ref:P,style:{objectFit:b,width:F,height:F},...A,onLoad:r=>{N?.(r),L.status=void 0},onError:r=>{x?.(r),L.status="error"},onClick:S}),f&&"loading"===L.status&&r(d,{absolute:!0}),w&&r("div",{className:i("i-image-cover",z),onClick:S,children:w})]})})};export{u as default};
|
|
2
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sources":["../../../packages/components/image/image.tsx"],"sourcesContent":["import { HideImageTwotone } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { useEffect, useRef } from \"react\";\nimport { useIntersectionObserver } from \"../../js/hooks\";\nimport usePreview from \"../../js/usePreview\";\nimport Icon from \"../icon\";\nimport Loading from \"../loading\";\nimport \"./index.css\";\nimport type { CompositionImage, IImage } from \"./type\";\n\nconst Image = (props: IImage) => {\n\tconst {\n\t\tsrc,\n\t\tround,\n\t\tsize,\n\t\tinitSize,\n\t\tlazyload,\n\t\tfallback = (\n\t\t\t<Icon icon={<HideImageTwotone />} size='2em' className='color-5' />\n\t\t),\n\t\tfit,\n\t\tstyle,\n\t\tclassName,\n\t\tcover,\n\t\tcoverClass,\n\t\tusePreview: previewable,\n\t\tonLoad,\n\t\tonError,\n\t\tonClick,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive<{ status?: string }>({\n\t\tstatus: \"loading\",\n\t});\n\tconst ref = useRef<HTMLImageElement>(null);\n\tconst wh = fit ? \"100%\" : undefined;\n\n\tconst { observe, unobserve } = useIntersectionObserver();\n\tconst preview = usePreview();\n\n\tconst handleError = (err) => {\n\t\tonError?.(err);\n\t\tstate.status = \"error\";\n\t};\n\n\tconst handleLoad = (e) => {\n\t\tonLoad?.(e);\n\t\tstate.status = undefined;\n\t};\n\n\tconst handleClick = (e) => {\n\t\tonClick?.(e);\n\n\t\tpreviewable &&\n\t\t\tsrc &&\n\t\t\tpreview({\n\t\t\t\titems: [\n\t\t\t\t\t{\n\t\t\t\t\t\tsrc,\n\t\t\t\t\t\ttype: \"IMAGE\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t};\n\n\tuseEffect(() => {\n\t\tif (!src) return;\n\n\t\tif (!ref.current?.complete) {\n\t\t\tstate.status = \"loading\";\n\t\t}\n\n\t\tif (!lazyload || !ref.current) return;\n\n\t\tobserve(ref.current, (tar: HTMLElement, visible: boolean) => {\n\t\t\tif (!visible) return;\n\n\t\t\ttar.setAttribute(\"src\", tar.dataset.src || \"\");\n\t\t\tunobserve(tar);\n\t\t});\n\n\t\treturn () => {\n\t\t\tref.current && unobserve(ref.current);\n\t\t};\n\t}, [src]);\n\n\trestProps[lazyload ? \"data-src\" : \"src\"] = src;\n\tconst iSize = state.status === \"loading\" ? initSize : undefined;\n\n\treturn (\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\twidth: size ?? iSize,\n\t\t\t\theight: size ?? iSize,\n\t\t\t\t...style,\n\t\t\t}}\n\t\t\tclassName={classNames(\"i-image\", className, {\n\t\t\t\trounded: round,\n\t\t\t\t[`i-image-${state.status}`]: state.status,\n\t\t\t})}\n\t\t>\n\t\t\t{state.status === \"error\" ? (\n\t\t\t\tfallback\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{src && (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\t\tstyle={{ objectFit: fit, width: wh, height: wh }}\n\t\t\t\t\t\t\t{...restProps}\n\t\t\t\t\t\t\tonLoad={handleLoad}\n\t\t\t\t\t\t\tonError={handleError}\n\t\t\t\t\t\t\tonClick={handleClick}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{src && state.status === \"loading\" && <Loading absolute />}\n\n\t\t\t\t\t{cover && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={classNames(\"i-image-cover\", coverClass)}\n\t\t\t\t\t\t\tonClick={handleClick}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{cover}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Image as CompositionImage;\n"],"names":["Image","props","src","round","size","initSize","lazyload","fallback","_jsx","Icon","icon","HideImageTwotone","className","fit","style","cover","coverClass","usePreview","previewable","onLoad","onError","onClick","restProps","state","useReactive","status","ref","useRef","wh","undefined","observe","unobserve","useIntersectionObserver","preview","handleClick","e","items","type","useEffect","current","complete","tar","visible","setAttribute","dataset","iSize","width","height","classNames","rounded","children","_jsxs","objectFit","err","Loading","absolute"],"mappings":"6YAWA,MAAMA,EAASC,IACd,MAAMC,IACLA,EAAGC,MACHA,EAAKC,KACLA,EAAIC,SACJA,EAAQC,SACRA,EAAQC,SACRA,EACCC,EAACC,EAAI,CAACC,KAAMF,EAACG,EAAmB,CAAA,GAAEP,KAAK,MAAMQ,UAAU,YACvDC,IACDA,EAAGC,MACHA,EAAKF,UACLA,EAASG,MACTA,EAAKC,WACLA,EACAC,WAAYC,EAAWC,OACvBA,EAAMC,QACNA,EAAOC,QACPA,KACGC,GACArB,EAEEsB,EAAQC,EAAiC,CAC9CC,OAAQ,YAEHC,EAAMC,EAAyB,MAC/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":3,"file":"index.js","sources":["../../../packages/components/image/index.tsx"],"sourcesContent":["import Image from \"./image\";\nimport List from \"./list\";\n\nImage.List = List;\n\nexport default Image;\n"],"names":["Image","List"],"mappings":"mDAGAA,EAAMC,KAAOA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import{useMemo as r}from"react";import e from"../../js/usePreview/index.js";import{getSuffixByUrl as s,getFileType as t}from"../../js/utils.js";import o from"../flex/flex.js";import m from"./image.js";function c(c){const{items:n=[],gap:a=8,columns:p,wrap:f,direction:l,usePreview:u,onClick:j,...g}=c,x=e(),d=r((()=>n.map((i=>{const r={src:""};return"string"==typeof i?r.src=i:Object.assign(r,i),r.suffix=s(r.src)||"",r.type=t(r.suffix,i.type),r}))),[n]);return d.length?i(o,{className:"i-image-list",gap:a,columns:p,wrap:f,direction:l,children:d.map(((r,e)=>i(m,{src:r.src,size:60,usePreview:!1,onClick:i=>((i,r)=>{j?.(i),u&&x({items:d,initial:r})})(i,e),...g},e)))}):""}export{c as default};
|
|
2
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../packages/components/image/list.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport usePreview from \"../../js/usePreview\";\nimport { TPreviewItem } from \"../../js/usePreview/type\";\nimport { getFileType, getSuffixByUrl } from \"../../js/utils\";\nimport Flex from \"../flex\";\nimport Image from \"./image\";\nimport { IImageList } from \"./type\";\n\nexport default function List(props: IImageList) {\n\tconst {\n\t\titems = [],\n\t\tgap = 8,\n\t\tcolumns,\n\t\twrap,\n\t\tdirection,\n\t\tusePreview: previewable,\n\t\tonClick,\n\t\t...restProps\n\t} = props;\n\tconst preview = usePreview();\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 handleClick = (e, i) => {\n\t\tonClick?.(e);\n\n\t\tpreviewable &&\n\t\t\tpreview({\n\t\t\t\titems: files,\n\t\t\t\tinitial: i,\n\t\t\t});\n\t};\n\n\tif (!files.length) return \"\";\n\n\treturn (\n\t\t<Flex\n\t\t\tclassName='i-image-list'\n\t\t\tgap={gap}\n\t\t\tcolumns={columns}\n\t\t\twrap={wrap}\n\t\t\tdirection={direction}\n\t\t>\n\t\t\t{files.map((img, i) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Image\n\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\tsrc={img.src}\n\t\t\t\t\t\tsize={60}\n\t\t\t\t\t\tusePreview={false}\n\t\t\t\t\t\tonClick={(e) => handleClick(e, i)}\n\t\t\t\t\t\t{...restProps}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t})}\n\t\t</Flex>\n\t);\n}\n"],"names":["List","props","items","gap","columns","wrap","direction","usePreview","previewable","onClick","restProps","preview","files","useMemo","map","item","o","src","Object","assign","suffix","getSuffixByUrl","type","getFileType","length","_jsx","Flex","className","children","img","i","Image","size","e","initial","handleClick"],"mappings":"iPAQwB,SAAAA,EAAKC,GAC5B,MAAMC,MACLA,EAAQ,GAAEC,IACVA,EAAM,EAACC,QACPA,EAAOC,KACPA,EAAIC,UACJA,EACAC,WAAYC,EAAWC,QACvBA,KACGC,GACAT,EACEU,EAAUJ,IAEVK,EAAQC,GAAQ,IACdX,EAAMY,KAAKC,IACjB,MAAMC,EAAkB,CACvBC,IAAK,IAWN,MAToB,iBAATF,EACVC,EAAEC,IAAMF,EAERG,OAAOC,OAAOH,EAAGD,GAGlBC,EAAEI,OAASC,EAAeL,EAAEC,MAAQ,GACpCD,EAAEM,KAAOC,EAAYP,EAAEI,OAAQL,EAAW,MAEnCC,CAAC,KAEP,CAACd,IAYJ,OAAKU,EAAMY,OAGVC,EAACC,EAAI,CACJC,UAAU,eACVxB,IAAKA,EACLC,QAASA,EACTC,KAAMA,EACNC,UAAWA,EAEVsB,SAAAhB,EAAME,KAAI,CAACe,EAAKC,IAEfL,EAACM,EAEA,CAAAd,IAAKY,EAAIZ,IACTe,KAAM,GACNzB,YAAY,EACZE,QAAUwB,GA3BK,EAACA,EAAGH,KACvBrB,IAAUwB,GAEVzB,GACCG,EAAQ,CACPT,MAAOU,EACPsB,QAASJ,GACR,EAoBiBK,CAAYF,EAAGH,MAC3BpB,GALCoB,OAbgB,EAwB3B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,jsx as a}from"react/jsx-runtime";import l from"classnames";function s(s){const{as:i="label",label:n,className:t,labelInline:r,style:c,children:m,status:p,tip:u,required:o}=s;return e(i,{className:l("i-input-label",t,{"i-input-inline":r}),style:c,children:[n&&e("span",{className:"i-input-label-text",children:[o&&a("span",{className:"error",children:"*"}),n]}),m,u&&a("span",{className:l("i-input-message",{[`i-input-${p}`]:"normal"!==p}),children:u})]})}export{s as default};
|
|
2
|
+
//# sourceMappingURL=container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.js","sources":["../../../packages/components/input/container.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { IInputContainer } from \"./type\";\n\nexport default function InputContainer(props: IInputContainer) {\n\tconst {\n\t\tas: As = \"label\",\n\t\tlabel,\n\t\tclassName,\n\t\tlabelInline,\n\t\tstyle,\n\t\tchildren,\n\t\tstatus,\n\t\ttip,\n\t\trequired,\n\t} = props;\n\n\treturn (\n\t\t<As\n\t\t\tclassName={classNames(\"i-input-label\", className, {\n\t\t\t\t\"i-input-inline\": labelInline,\n\t\t\t})}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t{label && (\n\t\t\t\t<span className='i-input-label-text'>\n\t\t\t\t\t{required && <span className='error'>*</span>}\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t)}\n\n\t\t\t{children}\n\n\t\t\t{tip && (\n\t\t\t\t<span\n\t\t\t\t\tclassName={classNames(\"i-input-message\", {\n\t\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t})}\n\t\t\t\t>\n\t\t\t\t\t{tip}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</As>\n\t);\n}\n"],"names":["InputContainer","props","as","As","label","className","labelInline","style","children","status","tip","required","_jsxs","classNames","_jsx"],"mappings":"4EAGwB,SAAAA,EAAeC,GACtC,MACCC,GAAIC,EAAK,QAAOC,MAChBA,EAAKC,UACLA,EAASC,YACTA,EAAWC,MACXA,EAAKC,SACLA,EAAQC,OACRA,EAAMC,IACNA,EAAGC,SACHA,GACGV,EAEJ,OACCW,EAACT,EACA,CAAAE,UAAWQ,EAAW,gBAAiBR,EAAW,CACjD,iBAAkBC,IAEnBC,MAAOA,EAAKC,SAAA,CAEXJ,GACAQ,EAAM,OAAA,CAAAP,UAAU,qBAAoBG,SAAA,CAClCG,GAAYG,UAAMT,UAAU,QAAOG,SAAA,MACnCJ,KAIFI,EAEAE,GACAI,UACCT,UAAWQ,EAAW,kBAAmB,CACxC,CAAC,WAAWJ,KAAsB,WAAXA,aAGvBC,MAKN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../packages/components/input/index.tsx"],"sourcesContent":["import Input from \"./input\";\nimport Number from \"./number\";\nimport Range from \"./range\";\nimport Textarea from \"./textarea\";\n\nInput.Textarea = Textarea;\nInput.Number = Number;\nInput.Range = Range;\n\nexport default Input;\n"],"names":["Input","Textarea","Number","Range"],"mappings":"4GAKAA,EAAMC,SAAWA,EACjBD,EAAME,OAASA,EACfF,EAAMG,MAAQA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e,jsxs as i}from"react/jsx-runtime";import{VisibilityRound as a,VisibilityOffRound as t}from"@ricons/material";import{useReactive as r}from"ahooks";import s from"classnames";import{useMemo as n,useEffect as l}from"react";import o from"../utils/helpericon/helpericon.js";import p from"./container.js";const m=m=>{const{ref:u,type:c="text",label:d,name:v,value:b=m.initValue??"",initValue:f="",prepend:h,append:y,labelInline:N,className:g,status:w="normal",message:j,tip:x,clear:C,hideVisible:V,border:k,required:q,onChange:E,onEnter:I,style:$,...D}=m,K=r({value:b,type:c,visible:!1}),O=n((()=>{if("password"===c)return K.visible?e(a,{}):e(t,{})}),[K.visible]);l((()=>{K.value=b}),[b]);const z={ref:u,type:K.type,name:v,value:K.value,className:s("i-input",`i-input-${c}`),onChange:e=>{const i=e.target.value;K.value=i,E?.(i,e)},onKeyDown:e=>{"Enter"===e.code&&I?.(e)},...D},A=C&&K.value,B="password"===c&&!!K.value;return e(p,{label:d,labelInline:N,className:g,style:$,tip:j??x,status:w,required:q,children:i("div",{className:s("i-input-item",{[`i-input-${w}`]:"normal"!==w,"i-input-borderless":!k}),children:[h&&e("div",{className:"i-input-prepend",children:h}),e("input",{...z}),e(o,{active:!!A||B,icon:O,onClick:()=>{if("password"===c&&!V)return void Object.assign(K,{visible:!K.visible,type:K.visible?"password":"text"});E?.("")}}),y&&e("div",{className:"i-input-append",children:y})]})})};export{m as default};
|
|
2
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../../packages/components/input/input.tsx"],"sourcesContent":["import { VisibilityOffRound, VisibilityRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect, useMemo } from \"react\";\nimport \"../../css/input.css\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport type { CompositionInput, IInput } from \"./type\";\n\nconst Input = ((props: IInput) => {\n\tconst {\n\t\tref,\n\t\ttype = \"text\",\n\t\tlabel,\n\t\tname,\n\t\tvalue = props.initValue ?? \"\",\n\t\tinitValue = \"\",\n\t\tprepend,\n\t\tappend,\n\t\tlabelInline,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tmessage,\n\t\ttip,\n\t\tclear,\n\t\thideVisible,\n\t\tborder,\n\t\trequired,\n\t\tonChange,\n\t\tonEnter,\n\t\tstyle,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t\ttype,\n\t\tvisible: false,\n\t});\n\n\tconst handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n\t\tconst v = e.target.value;\n\n\t\tstate.value = v;\n\t\tonChange?.(v, e);\n\t};\n\n\tconst handleKeydown = (e) => {\n\t\te.code === \"Enter\" && onEnter?.(e);\n\t};\n\n\tconst handleHelperClick = () => {\n\t\tif (type === \"password\" && !hideVisible) {\n\t\t\tObject.assign(state, {\n\t\t\t\tvisible: !state.visible,\n\t\t\t\ttype: !state.visible ? \"text\" : \"password\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst v = \"\";\n\t\tonChange?.(v);\n\t};\n\n\tconst HelperIcon = useMemo(() => {\n\t\tif (type === \"password\") {\n\t\t\treturn state.visible ? <VisibilityRound /> : <VisibilityOffRound />;\n\t\t}\n\n\t\treturn undefined;\n\t}, [state.visible]);\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\tconst inputProps = {\n\t\tref,\n\t\ttype: state.type,\n\t\tname,\n\t\tvalue: state.value,\n\t\tclassName: classNames(\"i-input\", `i-input-${type}`),\n\t\tonChange: handleChange,\n\t\tonKeyDown: handleKeydown,\n\t\t...restProps,\n\t};\n\n\tconst clearable = clear && state.value;\n\tconst showHelper = type === \"password\" && !!state.value;\n\n\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\ttip={message ?? tip}\n\t\t\tstatus={status}\n\t\t\trequired={required}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-input-item\", {\n\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t\"i-input-borderless\": !border,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{prepend && <div className='i-input-prepend'>{prepend}</div>}\n\n\t\t\t\t<input {...inputProps} />\n\n\t\t\t\t<Helpericon\n\t\t\t\t\tactive={!!clearable || showHelper}\n\t\t\t\t\ticon={HelperIcon}\n\t\t\t\t\tonClick={handleHelperClick}\n\t\t\t\t/>\n\n\t\t\t\t{append && <div className='i-input-append'>{append}</div>}\n\t\t\t</div>\n\t\t</InputContainer>\n\t);\n}) as CompositionInput;\n\nexport default Input;\n"],"names":["Input","props","ref","type","label","name","value","initValue","prepend","append","labelInline","className","status","message","tip","clear","hideVisible","border","required","onChange","onEnter","style","restProps","state","useReactive","visible","HelperIcon","useMemo","_jsx","VisibilityRound","VisibilityOffRound","useEffect","inputProps","classNames","e","v","target","onKeyDown","code","clearable","showHelper","InputContainer","_jsxs","children","Helpericon","active","icon","onClick","Object","assign"],"mappings":"0TASA,MAAMA,EAAUC,IACf,MAAMC,IACLA,EAAGC,KACHA,EAAO,OAAMC,MACbA,EAAKC,KACLA,EAAIC,MACJA,EAAQL,EAAMM,WAAa,GAAEA,UAC7BA,EAAY,GAAEC,QACdA,EAAOC,OACPA,EAAMC,YACNA,EAAWC,UACXA,EAASC,OACTA,EAAS,SAAQC,QACjBA,EAAOC,IACPA,EAAGC,MACHA,EAAKC,YACLA,EAAWC,OACXA,EAAMC,SACNA,EAAQC,SACRA,EAAQC,QACRA,EAAOC,MACPA,KACGC,GACArB,EAEEsB,EAAQC,EAAY,CACzBlB,QACAH,OACAsB,SAAS,IA2BJC,EAAaC,GAAQ,KAC1B,GAAa,aAATxB,EACH,OAAOoB,EAAME,QAAUG,EAACC,EAAe,CAAA,GAAMD,EAACE,KAG/B,GACd,CAACP,EAAME,UAEVM,GAAU,KACTR,EAAMjB,MAAQA,CAAK,GACjB,CAACA,IAEJ,MAAM0B,EAAa,CAClB9B,MACAC,KAAMoB,EAAMpB,KACZE,OACAC,MAAOiB,EAAMjB,MACbK,UAAWsB,EAAW,UAAW,WAAW9B,KAC5CgB,SA1CqBe,IACrB,MAAMC,EAAID,EAAEE,OAAO9B,MAEnBiB,EAAMjB,MAAQ6B,EACdhB,IAAWgB,EAAGD,EAAE,EAuChBG,UApCsBH,IACX,UAAXA,EAAEI,MAAoBlB,IAAUc,EAAE,KAoC/BZ,GAGEiB,EAAYxB,GAASQ,EAAMjB,MAC3BkC,EAAsB,aAATrC,KAAyBoB,EAAMjB,MAElD,OACCsB,EAACa,GACArC,MAAOA,EACPM,YAAaA,EACbC,UAAWA,EACXU,MAAOA,EACPP,IAAKD,GAAWC,EAChBF,OAAQA,EACRM,SAAUA,WAEVwB,EACC,MAAA,CAAA/B,UAAWsB,EAAW,eAAgB,CACrC,CAAC,WAAWrB,KAAsB,WAAXA,EACvB,sBAAuBK,IACtB0B,SAAA,CAEDnC,GAAWoB,EAAA,MAAA,CAAKjB,UAAU,2BAAmBH,IAE9CoB,EAAW,QAAA,IAAAI,IAEXJ,EAACgB,EACA,CAAAC,SAAUN,GAAaC,EACvBM,KAAMpB,EACNqB,QA9DsB,KACzB,GAAa,aAAT5C,IAAwBa,EAK3B,YAJAgC,OAAOC,OAAO1B,EAAO,CACpBE,SAAUF,EAAME,QAChBtB,KAAOoB,EAAME,QAAmB,WAAT,SAMzBN,IADU,GACG,IAuDVV,GAAUmB,EAAK,MAAA,CAAAjB,UAAU,iBAAgBgC,SAAElC,QAI/C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{MinusRound as i,PlusRound as a}from"@ricons/material";import{useReactive as t}from"ahooks";import l from"classnames";import{useEffect as r}from"react";import{formatNumber as o,clamp as s}from"../../js/utils.js";import p from"../utils/helpericon/helpericon.js";import m from"./container.js";const c=c=>{const{ref:u,label:d,name:v,value:f=c.initValue??"",initValue:h,labelInline:b,step:N=1,min:g=-1/0,max:j=1/0,thousand:C,precision:y,type:k,className:x,status:I="normal",append:V,border:A,prepend:B,message:E,tip:$,hideControl:q,style:w,onChange:z,onEnter:D,onInput:F,onBlur:G,...H}=c,J=t({value:f}),K=e=>e?"number"!=typeof e&&C?e.replaceAll(C,""):e:"",L=e=>{const n=K(J.value)??0,i=s(+n+e,g,j);J.value=(e=>o(e,{precision:y,thousand:C}))(i),z?.(i)};r((()=>{J.value=f}),[f]);const M={ref:u,name:v,value:J.value,className:"i-input i-input-number",onChange:e=>{const{value:n}=e.target,i=K(n.replace(/[^\d\.-]/g,""));J.value=i,z?.(+i,e)},...H};return e(m,{label:d,labelInline:b,className:x,style:w,tip:E??$,status:I,children:n("div",{className:l("i-input-item",{[`i-input-${I}`]:"normal"!==I,"i-input-borderless":!A}),children:[B&&e("div",{className:"i-input-prepend",children:B}),!q&&e(p,{active:!0,icon:e(i,{}),onClick:()=>L(-N)}),e("input",{...M}),!q&&e(p,{active:!0,icon:e(a,{}),onClick:()=>L(N)}),V&&e("div",{className:"i-input-append",children:V})]})})};export{c as default};
|
|
2
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","sources":["../../../packages/components/input/number.tsx"],"sourcesContent":["import { MinusRound, PlusRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect } from \"react\";\nimport \"../../css/input.css\";\nimport { clamp, formatNumber } from \"../../js/utils\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport type { IInputNumber } from \"./type\";\n\nconst Number = (props: IInputNumber) => {\n\tconst {\n\t\tref,\n\t\tlabel,\n\t\tname,\n\t\tvalue = props.initValue ?? \"\",\n\t\tinitValue,\n\t\tlabelInline,\n\t\tstep = 1,\n\t\tmin = -Infinity,\n\t\tmax = Infinity,\n\t\tthousand,\n\t\tprecision,\n\t\ttype,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tappend,\n\t\tborder,\n\t\tprepend,\n\t\tmessage,\n\t\ttip,\n\t\thideControl,\n\t\tstyle,\n\t\tonChange,\n\t\tonEnter,\n\t\tonInput,\n\t\tonBlur,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t});\n\n\tconst getRangeNumber = (v: number) => clamp(v, min, max);\n\n\tconst getFormatNumber = (v: number) =>\n\t\tformatNumber(v, { precision, thousand });\n\n\tconst formatInputValue = (v?: string | number) => {\n\t\tif (!v) return \"\";\n\t\tif (typeof v === \"number\" || !thousand) return v;\n\n\t\treturn v.replaceAll(thousand, \"\");\n\t};\n\n\tconst handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n\t\tconst { value } = e.target;\n\t\tconst v = formatInputValue(value.replace(/[^\\d\\.-]/g, \"\"));\n\n\t\tstate.value = v;\n\t\tonChange?.(+v, e);\n\t};\n\n\tconst handleOperate = (param: number) => {\n\t\tconst value = formatInputValue(state.value) ?? 0;\n\t\tconst result = getRangeNumber(+value + param);\n\n\t\tstate.value = getFormatNumber(result);\n\n\t\tonChange?.(result);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\tconst inputProps = {\n\t\tref,\n\t\tname,\n\t\tvalue: state.value,\n\t\tclassName: \"i-input i-input-number\",\n\t\tonChange: handleChange,\n\t\t...restProps,\n\t};\n\n\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\ttip={message ?? tip}\n\t\t\tstatus={status}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-input-item\", {\n\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t\"i-input-borderless\": !border,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{prepend && <div className='i-input-prepend'>{prepend}</div>}\n\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<MinusRound />}\n\t\t\t\t\t\tonClick={() => handleOperate(-step)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t<input {...inputProps} />\n\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<PlusRound />}\n\t\t\t\t\t\tonClick={() => handleOperate(step)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t{append && <div className='i-input-append'>{append}</div>}\n\t\t\t</div>\n\t\t</InputContainer>\n\t);\n};\n\nexport default Number;\n"],"names":["Number","props","ref","label","name","value","initValue","labelInline","step","min","Infinity","max","thousand","precision","type","className","status","append","border","prepend","message","tip","hideControl","style","onChange","onEnter","onInput","onBlur","restProps","state","useReactive","formatInputValue","v","replaceAll","handleOperate","param","result","clamp","formatNumber","getFormatNumber","useEffect","inputProps","e","target","replace","_jsx","InputContainer","children","_jsxs","classNames","Helpericon","active","icon","MinusRound","onClick","PlusRound"],"mappings":"2VAUA,MAAMA,EAAUC,IACf,MAAMC,IACLA,EAAGC,MACHA,EAAKC,KACLA,EAAIC,MACJA,EAAQJ,EAAMK,WAAa,GAAEA,UAC7BA,EAASC,YACTA,EAAWC,KACXA,EAAO,EAACC,IACRA,GAAOC,IAAQC,IACfA,EAAMD,IAAQE,SACdA,EAAQC,UACRA,EAASC,KACTA,EAAIC,UACJA,EAASC,OACTA,EAAS,SAAQC,OACjBA,EAAMC,OACNA,EAAMC,QACNA,EAAOC,QACPA,EAAOC,IACPA,EAAGC,YACHA,EAAWC,MACXA,EAAKC,SACLA,EAAQC,QACRA,EAAOC,QACPA,EAAOC,OACPA,KACGC,GACA3B,EAEE4B,EAAQC,EAAY,CACzBzB,UAQK0B,EAAoBC,GACpBA,EACY,iBAANA,GAAmBpB,EA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useReactive as t}from"ahooks";import r from"classnames";import{useEffect as o}from"react";import{formatNumber as s,clamp as p}from"../../js/utils.js";import c from"../utils/helpericon/helpericon.js";import u from"./container.js";const m=m=>{const{label:v,name:d,value:h=m.initValue??"",initValue:f,labelInline:g,min:y=-1/0,max:C=1/0,type:b,className:k,status:N="normal",message:j,tip:A,append:x,prepend:D,step:I=1,thousand:P,precision:V,hideControl:B,placeholder:$,border:q,onChange:w,onBlur:z,style:E,...F}=m,G=t({value:h}),H=e=>e?"number"!=typeof e&&P?e.replaceAll(P,""):e:"",J=(e,a)=>{const{value:i}=e.target,l=H(i.replace(/[^\d\.-]/g,"")),n=Array.isArray(G.value)?G.value:[];n[a]=+l,G.value=n,w?.(n,e)},K=(e,a,i)=>{e.preventDefault(),e.stopPropagation();const l=Array.isArray(G.value)?G.value:[],n=H(l[i])??0,t=p(+n+a,y,C);l[i]=(e=>s(e,{precision:V,thousand:P}))(t),G.value=l,w?.(l,e)};o((()=>{G.value=h}),[h]);const L={name:d,className:"i-input i-input-number",...F};return e(u,{label:v,labelInline:g,className:k,style:E,tip:j??A,status:N,children:a("div",{className:r("i-input-item",{[`i-input-${N}`]:"normal"!==N,"i-input-borderless":!q}),children:[D&&e("div",{className:"i-input-prepend",children:D}),!B&&e(c,{active:!0,icon:e(i,{}),onClick:e=>K(e,-I,0)}),e("input",{value:G.value?.[0]||"",placeholder:$?.[0],...L,onChange:e=>J(e,0)}),!B&&e(c,{active:!0,icon:e(l,{}),onClick:e=>K(e,I,0)}),e(c,{active:!0,icon:e(n,{}),style:{margin:0},onClick:e=>{e.preventDefault(),e.stopPropagation();const a=G.value?G.value:[],i=a[0];a[0]=a[1],a[1]=i,G.value=a,w?.(a)}}),!B&&e(c,{active:!0,icon:e(i,{}),onClick:e=>K(e,-I,1)}),e("input",{value:G.value?.[1]||"",placeholder:$?.[1],...L,onChange:e=>J(e,1)}),!B&&e(c,{active:!0,icon:e(l,{}),onClick:e=>K(e,I,1)}),x&&e("div",{className:"i-input-append",children:x})]})})};export{m as default};
|
|
2
|
+
//# sourceMappingURL=range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range.js","sources":["../../../packages/components/input/range.tsx"],"sourcesContent":["import { MinusRound, PlusRound, SyncAltRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, MouseEvent, useEffect } from \"react\";\nimport \"../../css/input.css\";\nimport { clamp, formatNumber } from \"../../js/utils\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport type { IInputRange } from \"./type\";\n\nconst Range = (props: IInputRange) => {\n\tconst {\n\t\tlabel,\n\t\tname,\n\t\tvalue = props.initValue ?? \"\",\n\t\tinitValue,\n\t\tlabelInline,\n\t\tmin = -Infinity,\n\t\tmax = Infinity,\n\t\ttype,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tmessage,\n\t\ttip,\n\t\tappend,\n\t\tprepend,\n\t\tstep = 1,\n\t\tthousand,\n\t\tprecision,\n\t\thideControl,\n\t\tplaceholder,\n\t\tborder,\n\t\tonChange,\n\t\tonBlur,\n\t\tstyle,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t});\n\n\tconst getRangeNumber = (v: number) => clamp(v, min, max);\n\n\tconst getFormatNumber = (v: number) =>\n\t\tformatNumber(v, { precision, thousand });\n\n\tconst formatInputValue = (v?: string | number) => {\n\t\tif (!v) return \"\";\n\t\tif (typeof v === \"number\" || !thousand) return v;\n\n\t\treturn v.replaceAll(thousand, \"\");\n\t};\n\n\tconst handleChange = (e: ChangeEvent<HTMLInputElement>, i: number) => {\n\t\tconst { value } = e.target;\n\t\tconst v = formatInputValue(value.replace(/[^\\d\\.-]/g, \"\"));\n\n\t\tconst range = Array.isArray(state.value) ? state.value : [];\n\t\trange[i] = +v;\n\n\t\tstate.value = range;\n\t\tonChange?.(range, e);\n\t};\n\n\tconst handleOperate = (\n\t\te: MouseEvent<Element>,\n\t\tparam: number,\n\t\ti: number\n\t) => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\n\t\tconst range = Array.isArray(state.value) ? state.value : [];\n\t\tconst value = formatInputValue(range[i]) ?? 0;\n\t\tconst result = getRangeNumber(+value + param);\n\n\t\trange[i] = getFormatNumber(result);\n\n\t\tstate.value = range;\n\t\tonChange?.(range, e);\n\t};\n\n\tconst handleSwitch = (e: MouseEvent) => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t\tconst range = state.value ? state.value : [];\n\t\tconst v = range[0];\n\t\trange[0] = range[1];\n\t\trange[1] = v;\n\n\t\tstate.value = range;\n\t\tonChange?.(range);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\tconst inputProps = {\n\t\tname,\n\t\tclassName: \"i-input i-input-number\",\n\t\t...restProps,\n\t};\n\n\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\ttip={message ?? tip}\n\t\t\tstatus={status}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-input-item\", {\n\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t\"i-input-borderless\": !border,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{prepend && <div className='i-input-prepend'>{prepend}</div>}\n\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<MinusRound />}\n\t\t\t\t\t\tonClick={(e) => handleOperate(e, -step, 0)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t<input\n\t\t\t\t\tvalue={state.value?.[0] || \"\"}\n\t\t\t\t\tplaceholder={placeholder?.[0]}\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\tonChange={(e) => handleChange(e, 0)}\n\t\t\t\t/>\n\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<PlusRound />}\n\t\t\t\t\t\tonClick={(e) => handleOperate(e, step, 0)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<Helpericon\n\t\t\t\t\tactive\n\t\t\t\t\ticon={<SyncAltRound />}\n\t\t\t\t\tstyle={{ margin: 0 }}\n\t\t\t\t\tonClick={handleSwitch}\n\t\t\t\t/>\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<MinusRound />}\n\t\t\t\t\t\tonClick={(e) => handleOperate(e, -step, 1)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t<input\n\t\t\t\t\tvalue={state.value?.[1] || \"\"}\n\t\t\t\t\tplaceholder={placeholder?.[1]}\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\tonChange={(e) => handleChange(e, 1)}\n\t\t\t\t/>\n\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<PlusRound />}\n\t\t\t\t\t\tonClick={(e) => handleOperate(e, step, 1)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t{append && <div className='i-input-append'>{append}</div>}\n\t\t\t</div>\n\t\t</InputContainer>\n\t);\n};\n\nexport default Range;\n"],"names":["Range","props","label","name","value","initValue","labelInline","min","Infinity","max","type","className","status","message","tip","append","prepend","step","thousand","precision","hideControl","placeholder","border","onChange","onBlur","style","restProps","state","useReactive","formatInputValue","v","replaceAll","handleChange","e","i","target","replace","range","Array","isArray","handleOperate","param","preventDefault","stopPropagation","result","clamp","formatNumber","getFormatNumber","useEffect","inputProps","_jsx","InputContainer","children","_jsxs","classNames","Helpericon","active","icon","MinusRound","onClick","PlusRound","SyncAltRound","margin"],"mappings":"6WAUA,MAAMA,EAASC,IACd,MAAMC,MACLA,EAAKC,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AM,KAIxCF,GAAUmC,EAAA,MAAA,CAAKvC,UAAU,iBAAgByC,SAAErC,QAE7B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useReactive as t}from"ahooks";import a from"classnames";import{useRef as l,useEffect as n}from"react";import r from"./container.js";const i=i=>{const{ref:o,label:s,name:m,value:u=i.initValue,initValue:c,labelInline:p,className:f,status:h="normal",message:d,tip:v,autoSize:g,border:b,style:x,onChange:y,onEnter:N,...C}=i,j=t({value:u}),E=l(null);n((()=>{j.value=u}),[u]);const I={ref:o,name:m,value:j.value,className:"i-input i-textarea",onChange:e=>{const t=e.target.value;j.value=t;const a=E.current?.firstChild;g&&a&&(a.style.height=`${a.scrollHeight}px`),y?.(t,e)},onKeyDown:e=>{"Enter"===e.code&&(e.stopPropagation(),N?.(e))},...C};return e(r,{label:s,labelInline:p,className:f,style:x,tip:d??v,status:h,children:e("div",{ref:E,className:a("i-input-item",{[`i-input-${h}`]:"normal"!==h,"i-input-borderless":!b}),children:e("textarea",{...I})})})};export{i as default};
|
|
2
|
+
//# sourceMappingURL=textarea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.js","sources":["../../../packages/components/input/textarea.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect, useRef } from \"react\";\nimport \"../../css/input.css\";\nimport InputContainer from \"./container\";\nimport type { ITextarea } from \"./type\";\n\nconst Textarea = (props: ITextarea) => {\n\tconst {\n\t\tref,\n\t\tlabel,\n\t\tname,\n\t\tvalue = props.initValue,\n\t\tinitValue,\n\t\tlabelInline,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tmessage,\n\t\ttip,\n\t\tautoSize,\n\t\tborder,\n\t\tstyle,\n\t\tonChange,\n\t\tonEnter,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t});\n\tconst refTextarea = useRef<HTMLDivElement>(null);\n\n\tconst handleChange = (\n\t\te: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>\n\t) => {\n\t\tconst v = e.target.value;\n\n\t\tstate.value = v;\n\n\t\tconst ta = refTextarea.current?.firstChild as HTMLElement;\n\t\tif (autoSize && ta) {\n\t\t\tta.style.height = `${ta.scrollHeight}px`;\n\t\t}\n\n\t\tonChange?.(v, e);\n\t};\n\n\tconst handleKeydown = (e) => {\n\t\tif (e.code !== \"Enter\") return;\n\n\t\te.stopPropagation();\n\t\tonEnter?.(e);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\tconst inputProps = {\n\t\tref,\n\t\tname,\n\t\tvalue: state.value,\n\t\tclassName: \"i-input i-textarea\",\n\t\tonChange: handleChange,\n\t\tonKeyDown: handleKeydown,\n\t\t...restProps,\n\t};\n\n\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\ttip={message ?? tip}\n\t\t\tstatus={status}\n\t\t>\n\t\t\t<div\n\t\t\t\tref={refTextarea}\n\t\t\t\tclassName={classNames(\"i-input-item\", {\n\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t\"i-input-borderless\": !border,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<textarea {...inputProps} />\n\t\t\t</div>\n\t\t</InputContainer>\n\t);\n};\n\nexport default Textarea;\n"],"names":["Textarea","props","ref","label","name","value","initValue","labelInline","className","status","message","tip","autoSize","border","style","onChange","onEnter","restProps","state","useReactive","refTextarea","useRef","useEffect","inputProps","e","v","target","ta","current","firstChild","height","scrollHeight","onKeyDown","code","stopPropagation","_jsx","InputContainer","children","classNames"],"mappings":"mLAOA,MAAMA,EAAYC,IACjB,MAAMC,IACLA,EAAGC,MACHA,EAAKC,KACLA,EAAIC,MACJA,EAAQJ,EAAMK,UAASA,UACvBA,EAASC,YACTA,EAAWC,UACXA,EAASC,OACTA,EAAS,SAAQC,QACjBA,EAAOC,IACPA,EAAGC,SACHA,EAAQC,OACRA,EAAMC,MACNA,EAAKC,SACLA,EAAQC,QACRA,KACGC,GACAhB,EAEEiB,EAAQC,EAAY,CACzBd,UAEKe,EAAcC,EAAuB,MAwB3CC,GAAU,KACTJ,EAAMb,MAAQA,CAAK,GACjB,CAACA,IAEJ,MAAMkB,EAAa,CAClBrB,MACAE,OACAC,MAAOa,EAAMb,MACbG,UAAW,qBACXO,SA9BAS,IAEA,MAAMC,EAAID,EAAEE,OAAOrB,MAEnBa,EAAMb,MAAQoB,EAEd,MAAME,EAAKP,EAAYQ,SAASC,WAC5BjB,GAAYe,IACfA,EAAGb,MAAMgB,OAAS,GAAGH,EAAGI,kBAGzBhB,IAAWU,EAAGD,EAAE,EAoBhBQ,UAjBsBR,IACP,UAAXA,EAAES,OAENT,EAAEU,kBACFlB,IAAUQ,GAAE,KAcTP,GAGJ,OACCkB,EAACC,GACAjC,MAAOA,EACPI,YAAaA,EACbC,UAAWA,EACXM,MAAOA,EACPH,IAAKD,GAAWC,EAChBF,OAAQA,EAER4B,SAAAF,EAAA,MAAA,CACCjC,IAAKkB,EACLZ,UAAW8B,EAAW,eAAgB,CACrC,CAAC,WAAW7B,KAAsB,WAAXA,EACvB,sBAAuBI,aAGxBsB,EAAc,WAAA,IAAAZ,OAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,jsx as i}from"react/jsx-runtime";import t from"classnames";const l=l=>{const{ref:s,active:a,type:r,align:m,disabled:n,label:c,style:o,className:d,children:p,...f}=l;return e("li",{ref:s,className:t("i-list-item",d,{"i-list-item-active":a,"i-list-option":"option"===r,disabled:n}),style:{alignItems:m,...o},...f,children:[void 0!==c&&i("span",{className:"i-list-item-label",children:c}),p]})};export{l as default};
|
|
2
|
+
//# sourceMappingURL=item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../packages/components/list/item.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { IListItem } from \"./type\";\n\nconst Item = (props: IListItem) => {\n\tconst {\n\t\tref,\n\t\tactive,\n\t\ttype,\n\t\talign,\n\t\tdisabled,\n\t\tlabel,\n\t\tstyle,\n\t\tclassName,\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\treturn (\n\t\t<li\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-list-item\", className, {\n\t\t\t\t\"i-list-item-active\": active,\n\t\t\t\t\"i-list-option\": type === \"option\",\n\t\t\t\tdisabled,\n\t\t\t})}\n\t\t\tstyle={{ alignItems: align, ...style }}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{label !== undefined && (\n\t\t\t\t<span className='i-list-item-label'>{label}</span>\n\t\t\t)}\n\t\t\t{children}\n\t\t</li>\n\t);\n};\n\nexport default Item;\n"],"names":["Item","props","ref","active","type","align","disabled","label","style","className","children","restProps","_jsxs","classNames","alignItems","undefined","_jsx"],"mappings":"4EAGA,MAAMA,EAAQC,IACb,MAAMC,IACLA,EAAGC,OACHA,EAAMC,KACNA,EAAIC,MACJA,EAAKC,SACLA,EAAQC,MACRA,EAAKC,MACLA,EAAKC,UACLA,EAASC,SACTA,KACGC,GACAV,EAEJ,OACCW,EAAA,KAAA,CACCV,IAAKA,EACLO,UAAWI,EAAW,cAAeJ,EAAW,CAC/C,qBAAsBN,EACtB,gBAA0B,WAATC,EACjBE,aAEDE,MAAO,CAAEM,WAAYT,KAAUG,MAC3BG,EAEHD,SAAA,MAAUK,IAAVR,GACAS,EAAM,OAAA,CAAAP,UAAU,oBAAmBC,SAAEH,IAErCG,IACG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import e from"classnames";import{Children as r,cloneElement as m}from"react";import o from"./item.js";const s=s=>{const{label:a,type:l,className:p,children:c,...i}=s;return t("ul",{className:e("i-list",p),...i,children:r.map(c,((t,e)=>{const r="function"==typeof a?a(e):a,{type:s,props:l}=t;return s===o?m(t,{label:r,...l,type:s}):t}))})};s.Item=o;export{s as default};
|
|
2
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../packages/components/list/list.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { Children, cloneElement } from \"react\";\nimport \"./index.css\";\nimport Item from \"./item\";\nimport { IList } from \"./type\";\n\nconst List = (props: IList) => {\n\tconst { label, type, className, children, ...restProps } = props;\n\n\treturn (\n\t\t<ul className={classNames(\"i-list\", className)} {...restProps}>\n\t\t\t{Children.map(children, (node: any, i) => {\n\t\t\t\tconst renderLabel =\n\t\t\t\t\ttypeof label === \"function\" ? label(i) : label;\n\n\t\t\t\tconst { type, props: nodeProps } = node;\n\n\t\t\t\tif (type === Item) {\n\t\t\t\t\treturn cloneElement(node, {\n\t\t\t\t\t\tlabel: renderLabel,\n\t\t\t\t\t\t...nodeProps,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn node;\n\t\t\t})}\n\t\t</ul>\n\t);\n};\n\nList.Item = Item;\n\nexport default List;\n"],"names":["List","props","label","type","className","children","restProps","_jsx","classNames","Children","map","node","i","renderLabel","nodeProps","Item","cloneElement"],"mappings":"8IAMA,MAAMA,EAAQC,IACb,MAAMC,MAAEA,EAAKC,KAAEA,EAAIC,UAAEA,EAASC,SAAEA,KAAaC,GAAcL,EAE3D,OACCM,EAAI,KAAA,CAAAH,UAAWI,EAAW,SAAUJ,MAAgBE,WAClDG,EAASC,IAAIL,GAAU,CAACM,EAAWC,KACnC,MAAMC,EACY,mBAAVX,EAAuBA,EAAMU,GAAKV,GAEpCC,KAAEA,EAAMF,MAAOa,GAAcH,EAEnC,OAAIR,IAASY,EACLC,EAAaL,EAAM,CACzBT,MAAOW,KACJC,EACHX,SAIKQ,CAAI,KAER,EAIPX,EAAKe,KAAOA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import t from"classnames";const o=o=>{const{icon:i,text:r,size:a,absolute:n,style:l,className:c,...m}=o;return e("div",{className:t("i-loading-container",{absolute:n},c),style:{...l,inset:n?0:"unset"},...m,children:[i??s("svg",{width:"24",height:"24",stroke:"#000",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"i-loading-icon",style:{fontSize:a},children:s("circle",{cx:"12",cy:"12",r:"9.5",fill:"none",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:40,strokeDashoffset:0})}),r]})};export{o as default};
|
|
2
|
+
//# sourceMappingURL=loading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading.js","sources":["../../../packages/components/loading/loading.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport \"./index.css\";\nimport { ILoading } from \"./type\";\n\nconst Loading = (props: ILoading) => {\n\tconst { icon, text, size, absolute, style, className, ...restProps } =\n\t\tprops;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t\"i-loading-container\",\n\t\t\t\t{\n\t\t\t\t\tabsolute,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={{\n\t\t\t\t...style,\n\t\t\t\tinset: absolute ? 0 : \"unset\",\n\t\t\t}}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{icon ?? (\n\t\t\t\t<svg\n\t\t\t\t\twidth='24'\n\t\t\t\t\theight='24'\n\t\t\t\t\tstroke='#000'\n\t\t\t\t\tviewBox='0 0 24 24'\n\t\t\t\t\txmlns='http://www.w3.org/2000/svg'\n\t\t\t\t\tclassName='i-loading-icon'\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tfontSize: size,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<circle\n\t\t\t\t\t\tcx='12'\n\t\t\t\t\t\tcy='12'\n\t\t\t\t\t\tr='9.5'\n\t\t\t\t\t\tfill='none'\n\t\t\t\t\t\tstrokeWidth='3'\n\t\t\t\t\t\tstrokeLinecap='round'\n\t\t\t\t\t\tstrokeDasharray={40}\n\t\t\t\t\t\tstrokeDashoffset={0}\n\t\t\t\t\t/>\n\t\t\t\t</svg>\n\t\t\t)}\n\n\t\t\t{text}\n\t\t</div>\n\t);\n};\n\nexport default Loading;\n"],"names":["Loading","props","icon","text","size","absolute","style","className","restProps","_jsxs","classNames","inset","children","_jsx","width","height","stroke","viewBox","xmlns","fontSize","cx","cy","r","fill","strokeWidth","strokeLinecap","strokeDasharray","strokeDashoffset"],"mappings":"4EAIA,MAAMA,EAAWC,IAChB,MAAMC,KAAEA,EAAIC,KAAEA,EAAIC,KAAEA,EAAIC,SAAEA,EAAQC,MAAEA,EAAKC,UAAEA,KAAcC,GACxDP,EAED,OACCQ,EACC,MAAA,CAAAF,UAAWG,EACV,sBACA,CACCL,YAEDE,GAEDD,MAAO,IACHA,EACHK,MAAON,EAAW,EAAI,YAEnBG,EAASI,SAAA,CAEZV,GACAW,EAAA,MAAA,CACCC,MAAM,KACNC,OAAO,KACPC,OAAO,OACPC,QAAQ,YACRC,MAAM,6BACNX,UAAU,iBACVD,MAAO,CACNa,SAAUf,GACVQ,SAEDC,YACCO,GAAG,KACHC,GAAG,KACHC,EAAE,MACFC,KAAK,OACLC,YAAY,IACZC,cAAc,QACdC,gBAAiB,GACjBC,iBAAkB,MAKpBxB,IACI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useReactive as s}from"ahooks";import i from"classnames";import{uid as c}from"radash";import{useRef as o,useEffect as r,isValidElement as a}from"react";import{createRoot as l}from"react-dom/client";const m={left:"flex-start",center:"center",right:"flex-end"},u=12,d={duration:3e3,closable:!0,active:!1},f=function(){const e=document.createElement("div");return e.dataset.id="messages",document.body.append(e),e}(),g={oneInstance:null,callout(e){},close(){}},p={left:[],center:[],right:[]},h={left:[],center:[],right:[]};l(f).render(e((function(){const i=o(null),c=s({items:{left:[],center:[],right:[]},tops:{left:[],center:[],right:[]}}),a={left:0,center:0,right:0};r((()=>{Object.assign(g,{callout:function(e){const{align:t="center",unshift:n,onShow:s}=e,o=p[t][n?"unshift":"push"](e);c.items[t]=[...p[t]],e.close=this.close.bind(e),setTimeout((()=>{const e=i.current?.offsetHeight||0;p[t][n?0:o-1].active=!0,c.items[t]=[...p[t]],h[t][n?"unshift":"push"](e),c.tops[t]=[...h[t]],s?.()}),12),0!==e.duration&&(e.timer=setTimeout((()=>{this.close.call(e)}),e.duration))},close:function(){const e=this,{align:t="center",onHide:n}=e,s=p[t].findIndex((t=>t.id===e.id));s<0||(p[t][s].active=!1,c.items[t]=[...p[t]],e.timer=setTimeout((()=>{const s=p[t].findIndex((t=>t.id===e.id));p[t].splice(s,1),h[t].splice(s,1),c.tops[t]=[...h[t]],c.items[t]=[...p[t]],e.timer&&clearTimeout(e.timer),n?.()}),240))}})}),[]);const l=(t,s)=>{if(!t)return e(n,{});const{id:o,active:r,content:l,align:d="center",className:f}=t;a[d]+=c.tops[d][s-1]||0;const p=u*s+a[d];return e(b,{ref:i,active:r,content:l,top:p,className:f,style:{alignSelf:m[d]},onClick:g.close.bind(t)},o)};return t("div",{className:"i-messages",children:[c.items.left.map(l),c.items.center.map(l),c.items.right.map(l)]})}),{}));const b=function({ref:t,active:n,content:s,top:c,className:o,style:r,onClick:a}){return e("div",{ref:t,className:i("i-message",o,{"i-message-active":n}),style:{...r,top:c},onClick:a,children:s})};function v(e){return(["string","number"].includes(typeof e)||a(e))&&(e={content:e}),e=Object.assign({id:c(7)},d,e),g.callout(e),{instance:e,close:g.close.bind(e)}}v.error=e=>v({content:e,className:"bg-error"}),v.success=e=>v({content:e,className:"bg-success"}),v.warning=e=>v({content:e,className:"bg-warning"}),v.one=e=>{const t=g.oneInstance;if(t)t.active&&0!==t.duration?(clearTimeout(t.timer),t.timer=setTimeout((()=>{t.close?.()}),t.duration)):g.callout(t);else{const{instance:t}=v(e);g.oneInstance=t}};export{v as default};
|
|
2
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sources":["../../../packages/components/message/message.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { uid } from \"radash\";\nimport { ReactNode, isValidElement, useEffect, useRef } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport \"./index.css\";\nimport type { IMessage, IMessageItem, THeights, TMessageQueue } from \"./type\";\n\nconst AlignMap = {\n\tleft: \"flex-start\",\n\tcenter: \"center\",\n\tright: \"flex-end\",\n};\n\nconst GlobalConfig = {\n\talign: \"center\",\n\toffset: \"12px\",\n\tgap: 12,\n};\n\nconst ItemDefaultConfig = {\n\tduration: 3000,\n\tclosable: true,\n\tactive: false,\n};\n\nconst container = createContainer();\nconst handler: {\n\toneInstance: null | IMessage;\n\tcallout: (item: IMessage) => void;\n\tclose: () => void;\n} = {\n\toneInstance: null,\n\tcallout(item: IMessage) {},\n\tclose() {},\n};\n\nconst queue: TMessageQueue = {\n\tleft: [],\n\tcenter: [],\n\tright: [],\n};\nconst heights: THeights = {\n\tleft: [],\n\tcenter: [],\n\tright: [],\n};\n\ncreateRoot(container).render(<Messages />);\n\nconst MessageItem = function ({\n\tref,\n\tactive,\n\tcontent,\n\ttop,\n\tclassName,\n\tstyle,\n\tonClick,\n}: IMessageItem) {\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-message\", className, {\n\t\t\t\t\"i-message-active\": active,\n\t\t\t})}\n\t\t\tstyle={{\n\t\t\t\t...style,\n\t\t\t\ttop,\n\t\t\t}}\n\t\t\tonClick={onClick}\n\t\t>\n\t\t\t{content}\n\t\t</div>\n\t);\n};\n\nfunction Messages() {\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst state = useReactive<{\n\t\ttops: THeights;\n\t\titems: TMessageQueue;\n\t}>({\n\t\titems: {\n\t\t\tleft: [],\n\t\t\tcenter: [],\n\t\t\tright: [],\n\t\t},\n\t\ttops: {\n\t\t\tleft: [],\n\t\t\tcenter: [],\n\t\t\tright: [],\n\t\t},\n\t});\n\tconst offsetTop = {\n\t\tleft: 0,\n\t\tcenter: 0,\n\t\tright: 0,\n\t};\n\n\tuseEffect(() => {\n\t\tObject.assign(handler, {\n\t\t\tcallout: function (item: IMessage) {\n\t\t\t\tconst { align = \"center\", unshift, onShow } = item;\n\t\t\t\tconst size = queue[align][unshift ? \"unshift\" : \"push\"](item);\n\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\titem.close = this.close.bind(item);\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tconst h = ref.current?.offsetHeight || 0;\n\n\t\t\t\t\tqueue[align][unshift ? 0 : size - 1].active = true;\n\t\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\t\theights[align][unshift ? \"unshift\" : \"push\"](h);\n\t\t\t\t\tstate.tops[align] = [...heights[align]];\n\t\t\t\t\tonShow?.();\n\t\t\t\t}, 12);\n\n\t\t\t\tif (item.duration !== 0) {\n\t\t\t\t\titem.timer = setTimeout(() => {\n\t\t\t\t\t\tthis.close.call(item);\n\t\t\t\t\t}, item.duration);\n\t\t\t\t}\n\t\t\t},\n\t\t\tclose: function () {\n\t\t\t\tconst item = this as IMessage;\n\t\t\t\tconst { align = \"center\", onHide } = item;\n\t\t\t\tconst index = queue[align].findIndex((i) => i.id === item.id);\n\t\t\t\tif (index < 0) return;\n\n\t\t\t\tqueue[align][index].active = false;\n\t\t\t\tstate.items[align] = [...queue[align]];\n\n\t\t\t\titem.timer = setTimeout(() => {\n\t\t\t\t\tconst index = queue[align].findIndex(\n\t\t\t\t\t\t(i) => i.id === item.id\n\t\t\t\t\t);\n\n\t\t\t\t\tqueue[align].splice(index, 1);\n\t\t\t\t\theights[align].splice(index, 1);\n\t\t\t\t\tstate.tops[align] = [...heights[align]];\n\t\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\t\titem.timer && clearTimeout(item.timer);\n\t\t\t\t\tonHide?.();\n\t\t\t\t}, 240);\n\t\t\t},\n\t\t});\n\t}, []);\n\n\tconst renderItems = (item, i) => {\n\t\tif (!item) return <></>;\n\n\t\tconst { id, active, content, align = \"center\", className } = item;\n\t\toffsetTop[align] += state.tops[align][i - 1] || 0;\n\t\tconst top = GlobalConfig.gap * i + offsetTop[align];\n\n\t\treturn (\n\t\t\t<MessageItem\n\t\t\t\tkey={id}\n\t\t\t\tref={ref}\n\t\t\t\tactive={active}\n\t\t\t\tcontent={content}\n\t\t\t\ttop={top}\n\t\t\t\tclassName={className}\n\t\t\t\tstyle={{ alignSelf: AlignMap[align] }}\n\t\t\t\tonClick={handler.close.bind(item)}\n\t\t\t/>\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className='i-messages'>\n\t\t\t{state.items.left.map(renderItems)}\n\t\t\t{state.items.center.map(renderItems)}\n\t\t\t{state.items.right.map(renderItems)}\n\t\t</div>\n\t);\n}\n\nexport function setMessageConfig(config: IMessage) {\n\tObject.assign(GlobalConfig, config);\n}\n\nfunction message(config: IMessage | ReactNode) {\n\tif (\n\t\t[\"string\", \"number\"].includes(typeof config) ||\n\t\tisValidElement(config)\n\t) {\n\t\tconfig = { content: config as ReactNode };\n\t}\n\n\tconfig = Object.assign(\n\t\t{ id: uid(7) },\n\t\tItemDefaultConfig,\n\t\tconfig as IMessage\n\t);\n\n\thandler.callout(config as IMessage);\n\n\treturn {\n\t\tinstance: config,\n\t\tclose: handler.close.bind(config),\n\t};\n}\n\nfunction createContainer() {\n\tconst container = document.createElement(\"div\");\n\tcontainer.dataset.id = \"messages\";\n\tdocument.body.append(container);\n\n\treturn container;\n}\n\nmessage.error = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-error\",\n\t});\n};\n\nmessage.success = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-success\",\n\t});\n};\n\nmessage.warning = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-warning\",\n\t});\n};\n\nmessage.one = (config: IMessage) => {\n\tconst o = handler.oneInstance;\n\n\tif (o) {\n\t\tif (o.active && o.duration !== 0) {\n\t\t\tclearTimeout(o.timer);\n\t\t\to.timer = setTimeout(() => {\n\t\t\t\to.close?.();\n\t\t\t}, o.duration);\n\t\t} else {\n\t\t\thandler.callout(o);\n\t\t}\n\t} else {\n\t\tconst { instance } = message(config);\n\t\thandler.oneInstance = instance;\n\t}\n};\n\nexport default message;\n"],"names":["AlignMap","left","center","right","GlobalConfig","ItemDefaultConfig","duration","closable","active","container","document","createElement","dataset","id","body","append","createContainer","handler","oneInstance","callout","item","close","queue","heights","createRoot","render","_jsx","ref","useRef","state","useReactive","items","tops","offsetTop","useEffect","Object","assign","align","unshift","onShow","size","this","bind","setTimeout","h","current","offsetHeight","timer","call","onHide","index","findIndex","i","splice","clearTimeout","renderItems","content","className","top","MessageItem","style","alignSelf","onClick","_jsxs","children","map","classNames","message","config","includes","isValidElement","uid","instance","error","success","warning","one","o"],"mappings":"4QAQA,MAAMA,EAAW,CAChBC,KAAM,aACNC,OAAQ,SACRC,MAAO,YAGFC,EAGA,GAGAC,EAAoB,CACzBC,SAAU,IACVC,UAAU,EACVC,QAAQ,GAGHC,EAkLN,WACC,MAAMA,EAAYC,SAASC,cAAc,OAIzC,OAHAF,EAAUG,QAAQC,GAAK,WACvBH,SAASI,KAAKC,OAAON,GAEdA,CACR,CAxLkBO,GACZC,EAIF,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YAAaT,EAAW,CAC7C,mBAAoBjD,IAErBoD,MAAO,IACHA,EACHF,OAEDI,QAASA,WAERN,GAGJ,EA4GA,SAASW,EAAQC,GAgBhB,OAdC,CAAC,SAAU,UAAUC,gBAAgBD,IACrCE,EAAeF,MAEfA,EAAS,CAAEZ,QAASY,IAGrBA,EAASjC,OAAOC,OACf,CAAEvB,GAAI0D,EAAI,IACVlE,EACA+D,GAGDnD,EAAQE,QAAQiD,GAET,CACNI,SAAUJ,EACV/C,MAAOJ,EAAQI,MAAMqB,KAAK0B,GAE5B,CAUAD,EAAQM,MAASjB,GACTW,EAAQ,CACdX,UACAC,UAAW,aAIbU,EAAQO,QAAWlB,GACXW,EAAQ,CACdX,UACAC,UAAW,eAIbU,EAAQQ,QAAWnB,GACXW,EAAQ,CACdX,UACAC,UAAW,eAIbU,EAAQS,IAAOR,IACd,MAAMS,EAAI5D,EAAQC,YAElB,GAAI2D,EACCA,EAAErE,QAAyB,IAAfqE,EAAEvE,UACjBgD,aAAauB,EAAE9B,OACf8B,EAAE9B,MAAQJ,YAAW,KACpBkC,EAAExD,SAAS,GACTwD,EAAEvE,WAELW,EAAQE,QAAQ0D,OAEX,CACN,MAAML,SAAEA,GAAaL,EAAQC,GAC7BnD,EAAQC,YAAcsD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useReactive as o}from"ahooks";import{useImperativeHandle as r}from"react";import s from"./modal.js";const t=t=>{const{ref:i}=t,m=o({}),a=Object.assign({},t,m);return r(i,(()=>({update:(e={})=>{Object.assign(m,e)},close:()=>{m.visible=!1,a.closable||Promise.resolve().then((()=>{m.visible=!0}))}}))),e(s,{...a})};export{t as default};
|
|
2
|
+
//# sourceMappingURL=hookModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hookModal.js","sources":["../../../packages/components/modal/hookModal.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport type { RefObject } from \"react\";\nimport { useImperativeHandle } from \"react\";\nimport Modal from \"./modal\";\nimport type { IModal, RefHookModal } from \"./type\";\n\nconst HookModal = (\n\tprops: IModal & { ref?: RefObject<RefHookModal | null> }\n) => {\n\tconst { ref } = props;\n\tconst state = useReactive<IModal>({});\n\n\tconst mergedProps = Object.assign({}, props, state);\n\n\tuseImperativeHandle(ref, () => ({\n\t\tupdate: (config: IModal = {}) => {\n\t\t\tObject.assign(state, config);\n\t\t},\n\n\t\tclose: () => {\n\t\t\tstate.visible = false;\n\n\t\t\tif (mergedProps.closable) return;\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tstate.visible = true;\n\t\t\t});\n\t\t},\n\t}));\n\n\treturn <Modal {...mergedProps} />;\n};\n\nexport default HookModal;\n"],"names":["HookModal","props","ref","state","useReactive","mergedProps","Object","assign","useImperativeHandle","update","config","close","visible","closable","Promise","resolve","then","_jsx","Modal"],"mappings":"mJAMA,MAAMA,EACLC,IAEA,MAAMC,IAAEA,GAAQD,EACVE,EAAQC,EAAoB,IAE5BC,EAAcC,OAAOC,OAAO,CAAA,EAAIN,EAAOE,GAiB7C,OAfAK,EAAoBN,GAAK,KAAO,CAC/BO,OAAQ,CAACC,EAAiB,MACzBJ,OAAOC,OAAOJ,EAAOO,EAAO,EAG7BC,MAAO,KACNR,EAAMS,SAAU,EAEZP,EAAYQ,UAChBC,QAAQC,UAAUC,MAAK,KACtBb,EAAMS,SAAU,CAAI,GACnB,MAIGK,EAACC,EAAU,IAAAb,GAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../packages/components/modal/index.tsx"],"sourcesContent":["import Modal from \"./modal\";\nimport useModal from \"./useModal\";\n\nModal.useModal = useModal;\n\nexport default Modal;\n"],"names":["Modal","useModal"],"mappings":"uDAGAA,EAAMC,SAAWA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as o,jsxs as e,Fragment as t}from"react/jsx-runtime";import i from"classnames";import{useState as n,useRef as r,useEffect as c,useMemo as l}from"react";import{createPortal as s}from"react-dom";import{useKeydown as a}from"../../js/hooks.js";import"../button/index.js";import d from"../utils/helpericon/helpericon.js";import m from"../button/button.js";function u(i){const{title:n,footer:r,hideCloseButton:c,footerLeft:s,okButtonProps:a,cancelButtonProps:u,children:h,onOk:f,onClose:p}=i,k=n||!c,b=async()=>{await(f?.())||p?.()},C=l((()=>{if(r||null===r)return r;const i=Object.assign({children:"确定",onClick:b},a),n=Object.assign({secondary:!0,children:"关闭",onClick:p},u);return e(t,{children:[s,o(m,{...i}),o(m,{...n})]})}),[r,a,u]);return e(t,{children:[k&&e("header",{className:"i-modal-header",children:[n&&o("b",{children:n}),o(d,{active:!c,className:"i-modal-close",onClick:p})]}),o("div",{className:"i-modal-content",children:h}),o("footer",{className:"i-modal-footer",children:C})]})}function h(t){const{visible:l,title:d,footer:m,okButtonProps:h,cancelButtonProps:f,closable:p=!0,hideBackdrop:k,backdropClosable:b=!0,hideCloseButton:C,disableEsc:B,width:j,height:v,customized:N,fixed:P,hideShadow:g,children:y,style:O,className:w,keepDOM:x,footerLeft:E,onClick:L,onVisibleChange:T,onClose:z,onOk:D,...M}=t,[S,V]=n(l),[q,A]=n(!1),[F,G]=n(!1),H=r(!0),I=()=>{if(H.current){if(H.current=!1,!p)return G(!0),void setTimeout((()=>{G(!1),H.current=!0}),400);A(!1),setTimeout((()=>{!x&&V(!1),H.current=!0,T?.(!1),z?.()}),240)}};return a((o=>{"Escape"===o.code&&l&&I()}),{disabled:B}),c((()=>{l?H.current&&((!x||!S)&&V(!0),H.current=!1,setTimeout((()=>{A(!0),T?.(!0),H.current=!0}),24)):I()}),[l]),S?s(o("div",{className:i("i-modal-container",{"i-modal-backdrop":!k,"i-modal-customized":N,"i-modal-active":q,fixed:P},w),style:O,onClick:function(){b&&I()},children:e("div",{className:i("i-modal",{bounced:F,shadow:!g}),style:{width:j,height:v},onClick:o=>{o.stopPropagation(),document.documentElement.click(),L?.(o)},...M,children:[N&&y,!N&&o(u,{title:d,hideCloseButton:C,footer:m,okButtonProps:h,cancelButtonProps:f,children:y,footerLeft:E,onOk:D,onClose:I})]})}),document.body):null}export{h as default};
|
|
2
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../packages/components/modal/modal.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useKeydown } from \"../../js/hooks\";\nimport Button from \"../button\";\nimport Helpericon from \"../utils/helpericon\";\nimport \"./index.css\";\nimport { CompositionModal, IModal, IModalContent } from \"./type\";\n\nfunction DefaultContent(props: IModalContent) {\n\tconst {\n\t\ttitle,\n\t\tfooter,\n\t\thideCloseButton,\n\t\tfooterLeft,\n\t\tokButtonProps,\n\t\tcancelButtonProps,\n\t\tchildren,\n\t\tonOk,\n\t\tonClose,\n\t} = props;\n\tconst showHeader = title || !hideCloseButton;\n\n\tconst handleOk = async () => {\n\t\tconst ret = await onOk?.();\n\n\t\tif (ret) return;\n\n\t\tonClose?.();\n\t};\n\n\tconst renderFooter = useMemo(() => {\n\t\tif (footer || footer === null) return footer;\n\n\t\tconst propsOk = Object.assign(\n\t\t\t{\n\t\t\t\tchildren: \"确定\",\n\t\t\t\tonClick: handleOk,\n\t\t\t},\n\t\t\tokButtonProps\n\t\t);\n\t\tconst propsCancel = Object.assign(\n\t\t\t{\n\t\t\t\tsecondary: true,\n\t\t\t\tchildren: \"关闭\",\n\t\t\t\tonClick: onClose,\n\t\t\t},\n\t\t\tcancelButtonProps\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{footerLeft}\n\t\t\t\t<Button {...propsOk} />\n\t\t\t\t<Button {...propsCancel} />\n\t\t\t</>\n\t\t);\n\t}, [footer, okButtonProps, cancelButtonProps]);\n\n\treturn (\n\t\t<>\n\t\t\t{showHeader && (\n\t\t\t\t<header className='i-modal-header'>\n\t\t\t\t\t{title && <b>{title}</b>}\n\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive={!hideCloseButton}\n\t\t\t\t\t\tclassName='i-modal-close'\n\t\t\t\t\t\tonClick={onClose}\n\t\t\t\t\t/>\n\t\t\t\t</header>\n\t\t\t)}\n\n\t\t\t<div className='i-modal-content'>{children}</div>\n\n\t\t\t<footer className='i-modal-footer'>{renderFooter}</footer>\n\t\t</>\n\t);\n}\n\nfunction Modal(props: IModal) {\n\tconst {\n\t\tvisible,\n\t\ttitle,\n\t\tfooter,\n\t\tokButtonProps,\n\t\tcancelButtonProps,\n\t\tclosable = true,\n\t\thideBackdrop,\n\t\tbackdropClosable = true,\n\t\thideCloseButton,\n\t\tdisableEsc,\n\t\twidth,\n\t\theight,\n\t\tcustomized,\n\t\tfixed,\n\t\thideShadow,\n\t\tchildren,\n\t\tstyle,\n\t\tclassName,\n\t\tkeepDOM,\n\t\tfooterLeft,\n\t\tonClick,\n\t\tonVisibleChange,\n\t\tonClose,\n\t\tonOk,\n\t\t...restProps\n\t} = props;\n\tconst [show, setShow] = useState(visible);\n\tconst [active, setActive] = useState(false);\n\tconst [bounced, setBounced] = useState(false);\n\tconst toggable = useRef(true);\n\n\tconst handleShow = () => {\n\t\tif (!toggable.current) return;\n\n\t\t(!keepDOM || !show) && setShow(true);\n\t\ttoggable.current = false;\n\t\tsetTimeout(() => {\n\t\t\tsetActive(true);\n\t\t\tonVisibleChange?.(true);\n\t\t\ttoggable.current = true;\n\t\t}, 24);\n\t};\n\n\tconst handleHide = () => {\n\t\tif (!toggable.current) return;\n\t\ttoggable.current = false;\n\n\t\tif (!closable) {\n\t\t\tsetBounced(true);\n\t\t\tsetTimeout(() => {\n\t\t\t\tsetBounced(false);\n\t\t\t\ttoggable.current = true;\n\t\t\t}, 400);\n\t\t\treturn;\n\t\t}\n\n\t\tsetActive(false);\n\t\tsetTimeout(() => {\n\t\t\t!keepDOM && setShow(false);\n\t\t\ttoggable.current = true;\n\t\t\tonVisibleChange?.(false);\n\t\t\tonClose?.();\n\t\t}, 240);\n\t};\n\n\tconst handleBackdropClick = function () {\n\t\tbackdropClosable && handleHide();\n\t};\n\n\tuseKeydown(\n\t\t(e) => {\n\t\t\tif (e.code !== \"Escape\" || !visible) return;\n\t\t\thandleHide();\n\t\t},\n\t\t{ disabled: disableEsc }\n\t);\n\n\tuseEffect(() => {\n\t\tvisible ? handleShow() : handleHide();\n\t}, [visible]);\n\n\tif (!show) return null;\n\n\treturn createPortal(\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t\"i-modal-container\",\n\t\t\t\t{\n\t\t\t\t\t\"i-modal-backdrop\": !hideBackdrop,\n\t\t\t\t\t\"i-modal-customized\": customized,\n\t\t\t\t\t\"i-modal-active\": active,\n\t\t\t\t\tfixed,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={style}\n\t\t\tonClick={handleBackdropClick}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-modal\", {\n\t\t\t\t\tbounced,\n\t\t\t\t\tshadow: !hideShadow,\n\t\t\t\t})}\n\t\t\t\tstyle={{\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t}}\n\t\t\t\tonClick={(e) => {\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\tdocument.documentElement.click();\n\t\t\t\t\tonClick?.(e);\n\t\t\t\t}}\n\t\t\t\t{...restProps}\n\t\t\t>\n\t\t\t\t{customized && children}\n\n\t\t\t\t{!customized && (\n\t\t\t\t\t<DefaultContent\n\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\thideCloseButton={hideCloseButton}\n\t\t\t\t\t\tfooter={footer}\n\t\t\t\t\t\tokButtonProps={okButtonProps}\n\t\t\t\t\t\tcancelButtonProps={cancelButtonProps}\n\t\t\t\t\t\tchildren={children}\n\t\t\t\t\t\tfooterLeft={footerLeft}\n\t\t\t\t\t\tonOk={onOk}\n\t\t\t\t\t\tonClose={handleHide}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>,\n\t\tdocument.body\n\t);\n}\n\nexport default Modal as CompositionModal;\n"],"names":["DefaultContent","props","title","footer","hideCloseButton","footerLeft","okButtonProps","cancelButtonProps","children","onOk","onClose","showHeader","handleOk","async","renderFooter","useMemo","propsOk","Object","assign","onClick","propsCancel","secondary","_jsxs","_Fragment","_jsx","Button","className","Helpericon","active","Modal","visible","closable","hideBackdrop","backdropClosable","disableEsc","width","height","customized","fixed","hideShadow","style","keepDOM","onVisibleChange","restProps","show","setShow","useState","setActive","bounced","setBounced","toggable","useRef","handleHide","current","setTimeout","useKeydown","e","code","disabled","useEffect","createPortal","classNames","shadow","stopPropagation","document","documentElement","click","body"],"mappings":"0WASA,SAASA,EAAeC,GACvB,MAAMC,MACLA,EAAKC,OACLA,EAAMC,gBACNA,EAAeC,WACfA,EAAUC,cACVA,EAAaC,kBACbA,EAAiBC,SACjBA,EAAQC,KACRA,EAAIC,QACJA,GACGT,EACEU,EAAaT,IAAUE,EAEvBQ,EAAWC,gBACEJ,QAIlBC,KAAW,EAGNI,EAAeC,GAAQ,KAC5B,GAAIZ,GAAqB,OAAXA,EAAiB,OAAOA,EAEtC,MAAMa,EAAUC,OAAOC,OACtB,CACCV,SAAU,KACVW,QAASP,GAEVN,GAEKc,EAAcH,OAAOC,OAC1B,CACCG,WAAW,EACXb,SAAU,KACVW,QAAST,GAEVH,GAGD,OACCe,EACEC,EAAA,CAAAf,SAAA,CAAAH,EACDmB,EAACC,EAAW,IAAAT,IACZQ,EAACC,EAAM,IAAKL,MACV,GAEF,CAACjB,EAAQG,EAAeC,IAE3B,OACCe,EACEC,EAAA,CAAAf,SAAA,CAAAG,GACAW,YAAQI,UAAU,iBAAgBlB,SAAA,CAChCN,GAASsB,gBAAItB,IAEdsB,EAACG,EAAU,CACVC,QAASxB,EACTsB,UAAU,gBACVP,QAAST,OAKZc,EAAA,MAAA,CAAKE,UAAU,kB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AOA,EACPrB,QA/B0B,WAC3Bc,GAAoBmB,GACpB,WA+BC9B,EACC,MAAA,CAAAI,UAAWmC,EAAW,UAAW,CAChCb,UACAc,QAASvB,IAEVC,MAAO,CACNL,QACAC,UAEDjB,QAAUqC,IACTA,EAAEO,kBACFC,SAASC,gBAAgBC,QACzB/C,IAAUqC,EAAE,KAETb,EAASnC,SAAA,CAEZ6B,GAAc7B,GAEb6B,GACDb,EAACxB,EACA,CAAAE,MAAOA,EACPE,gBAAiBA,EACjBD,OAAQA,EACRG,cAAeA,EACfC,kBAAmBA,EACnBC,SAAUA,EACVH,WAAYA,EACZI,KAAMA,EACNC,QAAS0C,SAKbY,SAASG,MAlDQ,IAoDnB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{useRef as o}from"react";import{renderNode as t}from"../../js/utils.js";import e from"./hookModal.js";function n(){const n=o(null);return{open:o=>{const s=t(r(e,{ref:n,visible:!0,...o,onClose:()=>{o.onClose?.(),s?.()}}))},update:r=>{if(!n.current)return;const{update:o}=n.current;o(r)},close:()=>{if(!n.current)return;const{close:r}=n.current;r()}}}export{n as default};
|
|
2
|
+
//# sourceMappingURL=useModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useModal.js","sources":["../../../packages/components/modal/useModal.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport { renderNode } from \"../../js/utils\";\nimport HookModal from \"./hookModal\";\nimport { IModal, RefHookModal } from \"./type\";\n\nexport default function useModal() {\n\tconst ref = useRef<RefHookModal>(null);\n\n\tconst handleOpen = (props: IModal) => {\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\t{...props}\n\t\t\t\tonClose={() => {\n\t\t\t\t\tprops.onClose?.();\n\t\t\t\t\tunMount?.();\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst handleUpdate = (props: IModal) => {\n\t\tif (!ref.current) return;\n\n\t\tconst { update } = ref.current;\n\t\tupdate(props);\n\t};\n\n\tconst handleClose = () => {\n\t\tif (!ref.current) return;\n\n\t\tconst { close } = ref.current;\n\t\tclose();\n\t};\n\n\treturn {\n\t\topen: handleOpen,\n\t\tupdate: handleUpdate,\n\t\tclose: handleClose,\n\t};\n}\n"],"names":["useModal","ref","useRef","open","props","unMount","renderNode","_jsx","HookModal","visible","onClose","update","current","close"],"mappings":"oJAKc,SAAUA,IACvB,MAAMC,EAAMC,EAAqB,MA8BjC,MAAO,CACNC,KA7BmBC,IACnB,MAAMC,EAAUC,EACfC,EAACC,GACAP,IAAKA,EACLQ,SACI,KAAAL,EACJM,QAAS,KACRN,EAAMM,YACNL,KAAW,IAGb,EAmBDM,OAhBqBP,IACrB,IAAKH,EAAIW,QAAS,OAElB,MAAMD,OAAEA,GAAWV,EAAIW,QACvBD,EAAOP,EAAM,EAabS,MAVmB,KACnB,IAAKZ,EAAIW,QAAS,OAElB,MAAMC,MAAEA,GAAUZ,EAAIW,QACtBC,GAAO,EAQT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as a,jsx as e}from"react/jsx-runtime";import i from"classnames";import{useState as o}from"react";import r from"../loading/loading.js";const t=t=>{const{page:n,active:c,children:s,onChange:m}=t,[p,g]=o(!1);return a("a",{className:i("i-page",{"i-page-active":c,"i-page-loading":p,"i-page-disabled":!1}),"data-page":n,onClick:async()=>{c||p||(g(!0),await(m?.(n)),g(!1))},children:[p&&e(r,{}),s]})};export{t as default};
|
|
2
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sources":["../../../packages/components/pagination/page.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useState } from \"react\";\nimport Loading from \"../loading\";\nimport { IPageItem } from \"./type\";\n\nconst Page = (props: IPageItem) => {\n\tconst { page, active, children, onChange } = props;\n\tconst [loading, setLoading] = useState(false);\n\n\tconst handleClick = async () => {\n\t\tif (active || loading) return;\n\n\t\tsetLoading(true);\n\t\tawait onChange?.(page);\n\t\tsetLoading(false);\n\t};\n\n\treturn (\n\t\t<a\n\t\t\tclassName={classNames(\"i-page\", {\n\t\t\t\t\"i-page-active\": active,\n\t\t\t\t\"i-page-loading\": loading,\n\t\t\t\t\"i-page-disabled\": false,\n\t\t\t})}\n\t\t\tdata-page={page}\n\t\t\tonClick={handleClick}\n\t\t>\n\t\t\t{loading && <Loading />}\n\t\t\t{children}\n\t\t</a>\n\t);\n};\n\nexport default Page;\n"],"names":["Page","props","page","active","children","onChange","loading","setLoading","useState","_jsxs","className","classNames","onClick","async","_jsx","Loading"],"mappings":"kJAKA,MAAMA,EAAQC,IACb,MAAMC,KAAEA,EAAIC,OAAEA,EAAMC,SAAEA,EAAQC,SAAEA,GAAaJ,GACtCK,EAASC,GAAcC,GAAS,GAUvC,OACCC,EACC,IAAA,CAAAC,UAAWC,EAAW,SAAU,CAC/B,gBAAiBR,EACjB,iBAAkBG,EAClB,mBAAmB,gBAETJ,EACXU,QAhBkBC,UACfV,GAAUG,IAEdC,GAAW,SACLF,IAAWH,IACjBK,GAAW,GAAM,EAafH,SAAA,CAAAE,GAAWQ,EAACC,EAAU,CAAA,GACtBX,IACE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e,Fragment as n,jsxs as a}from"react/jsx-runtime";import{KeyboardArrowLeftRound as r,KeyboardArrowRightRound as i,MoreHorizRound as o}from"@ricons/material";import t from"classnames";import{useState as c,useMemo as m,useEffect as s}from"react";import p from"../icon/icon.js";import l from"./page.js";const g=g=>{const{page:h=1,size:d=10,total:f=0,sibling:u=2,prev:C=e(p,{icon:e(r,{})}),next:j=e(p,{icon:e(i,{})}),simple:v,jumper:x,className:y,renderEllipsis:M=()=>e(p,{icon:e(o,{}),className:"color-7"}),renderPage:N=e=>e,onChange:w,...P}=g,[b,z]=c(h),[A,E]=c(!1),k=m((()=>Math.ceil(f/d)),[d,f]),[q,B,D]=m((()=>{const e=Math.max(1,b-u),n=Math.min(k,b+u);return[e,n,Array.from({length:n-e+1}).map(((n,a)=>e+a))]}),[b,k,u]);if(k<=b&&1===b)return e(n,{});const F=async e=>{if(w&&!A)return E(!0),new Promise((async n=>{void 0!==e&&(await w(e),z(e),E(!1),n())}))};return s((()=>z(h)),[h]),a("div",{className:t("i-pagination",y),...P,children:[C&&e(l,{page:b-1||1,onChange:F,children:C}),q>1&&e(l,{page:1,onChange:F,children:N(1)}),q>2&&M(),D.map((n=>e(l,{page:n,active:n===b,onChange:F,children:N(n)},n))),B<k-1&&M(),B<k&&e(l,{page:k,onChange:F,children:N(k)}),j&&e(l,{page:b+1,onChange:F,children:j})]})};export{g as default};
|
|
2
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sources":["../../../packages/components/pagination/pagination.tsx"],"sourcesContent":["import {\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tMoreHorizRound,\n} from \"@ricons/material\";\nimport classNames from \"classnames\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport Icon from \"../icon\";\nimport \"./index.css\";\nimport Page from \"./page\";\nimport { IPagination } from \"./type\";\n\nconst Pagination = (props: IPagination) => {\n\tconst {\n\t\tpage: defaultPage = 1,\n\t\tsize = 10,\n\t\ttotal = 0,\n\t\tsibling = 2,\n\t\tprev = <Icon icon={<KeyboardArrowLeftRound />} />,\n\t\tnext = <Icon icon={<KeyboardArrowRightRound />} />,\n\t\tsimple,\n\t\tjumper,\n\t\tclassName,\n\t\trenderEllipsis = () => (\n\t\t\t<Icon icon={<MoreHorizRound />} className='color-7' />\n\t\t),\n\t\trenderPage = (i) => i,\n\t\tonChange,\n\t\t...restProps\n\t} = props;\n\n\tconst [page, setPage] = useState(defaultPage);\n\tconst [loading, setLoading] = useState(false);\n\n\tconst totalPage = useMemo(() => Math.ceil(total / size), [size, total]);\n\n\tconst [start, end, loop] = useMemo(() => {\n\t\tconst start = Math.max(1, page - sibling);\n\t\tconst end = Math.min(totalPage, page + sibling);\n\n\t\treturn [\n\t\t\tstart,\n\t\t\tend,\n\t\t\tArray.from({ length: end - start + 1 }).map((n, i) => start + i),\n\t\t];\n\t}, [page, totalPage, sibling]);\n\n\tif (totalPage <= page && page === 1) return <></>;\n\n\tconst handlePageChange = async (p?: number) => {\n\t\tif (!onChange || loading) return;\n\t\tsetLoading(true);\n\n\t\treturn new Promise<void>(async (resolve) => {\n\t\t\tif (p === undefined) return;\n\t\t\tawait onChange(p);\n\t\t\tsetPage(p);\n\t\t\tsetLoading(false);\n\t\t\tresolve();\n\t\t});\n\t};\n\n\tuseEffect(() => setPage(defaultPage), [defaultPage]);\n\n\treturn (\n\t\t<div className={classNames(\"i-pagination\", className)} {...restProps}>\n\t\t\t{prev && (\n\t\t\t\t<Page page={page - 1 || 1} onChange={handlePageChange}>\n\t\t\t\t\t{prev}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{start > 1 && (\n\t\t\t\t<Page page={1} onChange={handlePageChange}>\n\t\t\t\t\t{renderPage(1)}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{start > 2 && renderEllipsis()}\n\n\t\t\t{loop.map((p) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Page\n\t\t\t\t\t\tkey={p}\n\t\t\t\t\t\tpage={p}\n\t\t\t\t\t\tactive={p === page}\n\t\t\t\t\t\tonChange={handlePageChange}\n\t\t\t\t\t>\n\t\t\t\t\t\t{renderPage(p)}\n\t\t\t\t\t</Page>\n\t\t\t\t);\n\t\t\t})}\n\n\t\t\t{end < totalPage - 1 && renderEllipsis()}\n\n\t\t\t{end < totalPage && (\n\t\t\t\t<Page page={totalPage} onChange={handlePageChange}>\n\t\t\t\t\t{renderPage(totalPage)}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{next && (\n\t\t\t\t<Page page={page + 1} onChange={handlePageChange}>\n\t\t\t\t\t{next}\n\t\t\t\t</Page>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Pagination;\n"],"names":["Pagination","props","page","defaultPage","size","total","sibling","prev","_jsx","Icon","icon","KeyboardArrowLeftRound","next","KeyboardArrowRightRound","simple","jumper","className","renderEllipsis","MoreHorizRound","renderPage","i","onChange","restProps","setPage","useState","loading","setLoading","totalPage","useMemo","Math","ceil","start","end","loop","max","min","Array","from","length","map","n","handlePageChange","async","p","Promise","resolve","undefined","useEffect","_jsxs","classNames","children","Page","active"],"mappings":"0TAYA,MAAMA,EAAcC,IACnB,MACCC,KAAMC,EAAc,EAACC,KACrBA,EAAO,GAAEC,MACTA,EAAQ,EAACC,QACTA,EAAU,EAACC,KACXA,EAAOC,EAACC,EAAK,CAAAC,KAAMF,EAACG,QAA6BC,KACjDA,EAAOJ,EAACC,EAAK,CAAAC,KAAMF,EAACK,QAA8BC,OAClDA,EAAMC,OACNA,EAAMC,UACNA,EAASC,eACTA,EAAiB,IAChBT,EAACC,EAAK,CAAAC,KAAMF,EAACU,MAAmBF,UAAU,YAC1CG,WACDA,EAAcC,GAAMA,EAACC,SACrBA,KACGC,GACArB,GAEGC,EAAMqB,GAAWC,EAASrB,IAC1BsB,EAASC,GAAcF,GAAS,GAEjCG,EAAYC,GAAQ,IAAMC,KAAKC,KAAKzB,EAAQD,IAAO,CAACA,EAAMC,KAEzD0B,EAAOC,EAAKC,GAAQL,GAAQ,KAClC,MAAMG,EAAQF,KAAKK,IAAI,EAAGhC,EAAOI,GAC3B0B,EAAMH,KAAKM,IAAIR,EAAWzB,EAAOI,GAEvC,MAAO,CACNyB,EACAC,EACAI,MAAMC,KAAK,CAAEC,OAAQN,EAAMD,EAAQ,IAAKQ,KAAI,CAACC,EAAGpB,IAAMW,EAAQX,IAC9D,GACC,CAAClB,EAAMyB,EAAWrB,IAErB,GAAIqB,GAAazB,GAAiB,IAATA,EAAY,OAAOM,QAE5C,MAAMiC,EAAmBC,MAAOC,IAC/B,GAAKtB,IAAYI,EAGjB,OAFAC,GAAW,GAEJ,IAAIkB,SAAcF,MAAOG,SACrBC,IAANH,UACEtB,EAASsB,GACfpB,EAAQoB,GACRjB,GAAW,GACXmB,IAAS,GACR,EAKH,OAFAE,GAAU,IAAMxB,EAAQpB,IAAc,CAACA,IAGtC6C,EAAA,MAAA,CAAKhC,UAAWiC,EAAW,eAAgBjC,MAAgBM,EACzD4B,SAAA,CAAA3C,GACAC,EAAC2C,EAAI,CAACjD,KAAMA,EAAO,GAAK,EAAGmB,SAAUoB,EAAgBS,SACnD3C,IAIFwB,EAAQ,GACRvB,EAAC2C,GAAKjD,KAAM,EAAGmB,SAAUoB,EACvBS,SAAA/B,EAAW,KAIbY,EAAQ,GAAKd,IAEbgB,EAAKM,KAAKI,GAETnC,EAAC2C,EAEA,CAAAjD,KAAMyC,EACNS,OAAQT,IAAMzC,EACdmB,SAAUoB,EAAgBS,SAEzB/B,EAAWwB,IALPA,KAUPX,EAAML,EAAY,GAAKV,IAEvBe,EAAML,GACNnB,EAAC2C,EAAI,CAACjD,KAAMyB,EAAWN,SAAUoB,EAAgBS,SAC/C/B,EAAWQ,KAIbf,GACAJ,EAAC2C,EAAI,CAACjD,KAAMA,EAAO,EAAGmB,SAAUoB,EAC9BS,SAAAtC,MAGE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as o,jsx as t}from"react/jsx-runtime";import{CheckRound as e}from"@ricons/material";import{useReactive as r}from"ahooks";import{useEffect as i}from"react";import"../../button/index.js";import n from"../../icon/icon.js";import"../../input/index.js";import a from"../../select/select.js";import p from"../../input/input.js";import l from"../../button/button.js";const m={HEX:"toHexString",RGB:"toRgbString",HSB:"toHsbString"};function s(m){const{value:s,type:c,onTypeChange:u,onChange:d,onOk:f}=m,h=r({value:s,type:c});return i((()=>{h.value=s,h.type=c}),[s,c]),o("div",{className:"i-colorpicker-footer",children:[t(a,{readOnly:!0,hideClear:!0,hideArrow:!0,style:{width:"5.6em"},options:["RGB","HEX","HSB"],value:h.type,onChange:o=>{h.type=o,u(o)}}),t(p,{placeholder:"color",value:h.value,onChange:o=>{h.value=o,d(o)}}),t(l,{square:!0,onClick:f,children:t(n,{icon:t(e,{})})})]})}export{m as ColorMethods,s as default};
|
|
2
|
+
//# sourceMappingURL=footer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer.js","sources":["../../../../packages/components/picker/colors/footer.tsx"],"sourcesContent":["import { CheckRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport { useEffect } from \"react\";\nimport Button from \"../../button\";\nimport Icon from \"../../icon\";\nimport Input from \"../../input\";\nimport Select from \"../../select\";\n\nexport const ColorMethods = {\n\tHEX: \"toHexString\",\n\tRGB: \"toRgbString\",\n\tHSB: \"toHsbString\",\n};\n\nexport default function Footer(props) {\n\tconst { value, type, onTypeChange, onChange, onOk } = props;\n\tconst state = useReactive({\n\t\tvalue,\n\t\ttype,\n\t});\n\n\tconst handleChange = (v) => {\n\t\tstate.value = v;\n\t\tonChange(v);\n\t};\n\n\tconst handleTypeChange = (t) => {\n\t\tstate.type = t;\n\t\tonTypeChange(t);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t\tstate.type = type;\n\t}, [value, type]);\n\n\treturn (\n\t\t<div className='i-colorpicker-footer'>\n\t\t\t<Select\n\t\t\t\treadOnly\n\t\t\t\thideClear\n\t\t\t\thideArrow\n\t\t\t\tstyle={{ width: \"5.6em\" }}\n\t\t\t\toptions={[\"RGB\", \"HEX\", \"HSB\"]}\n\t\t\t\tvalue={state.type}\n\t\t\t\tonChange={handleTypeChange}\n\t\t\t/>\n\t\t\t<Input\n\t\t\t\tplaceholder='color'\n\t\t\t\tvalue={state.value}\n\t\t\t\tonChange={handleChange}\n\t\t\t/>\n\t\t\t<Button square onClick={onOk}>\n\t\t\t\t<Icon icon={<CheckRound />} />\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n"],"names":["ColorMethods","HEX","RGB","HSB","Footer","props","value","type","onTypeChange","onChange","onOk","state","useReactive","useEffect","_jsxs","className","_jsx","Select","readOnly","hideClear","hideArrow","style","width","options","t","Input","placeholder","v","Button","square","onClick","children","Icon","icon","CheckRound"],"mappings":"oXAQa,MAAAA,EAAe,CAC3BC,IAAK,cACLC,IAAK,cACLC,IAAK,eAGkB,SAAAC,EAAOC,GAC9B,MAAMC,MAAEA,EAAKC,KAAEA,EAAIC,aAAEA,EAAYC,SAAEA,EAAQC,KAAEA,GAASL,EAChDM,EAAQC,EAAY,CACzBN,QACAC,SAkBD,OALAM,GAAU,KACTF,EAAML,MAAQA,EACdK,EAAMJ,KAAOA,CAAI,GACf,CAACD,EAAOC,IAGVO,EAAK,MAAA,CAAAC,UAAU,iCACdC,EAACC,EACA,CAAAC,YACAC,WAAS,EACTC,WACA,EAAAC,MAAO,CAAEC,MAAO,SAChBC,QAAS,CAAC,MAAO,MAAO,OACxBjB,MAAOK,EAAMJ,KACbE,SAnBuBe,IACzBb,EAAMJ,KAAOiB,EACbhB,EAAagB,EAAE,IAmBdR,EAACS,GACAC,YAAY,QACZpB,MAAOK,EAAML,MACbG,SA7BmBkB,IACrBhB,EAAML,MAAQqB,EACdlB,EAASkB,EAAE,IA6BVX,EAACY,EAAM,CAACC,QAAO,EAAAC,QAASpB,EAAIqB,SAC3Bf,EAACgB,EAAI,CAACC,KAAMjB,EAACkB,EAAU,CAAA,SAI3B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import a from"classnames";const c=c=>{const{ref:s,color:l,handle:o,placeholder:t,className:i,...n}=c;return e("div",{ref:s,className:a("i-colorpicker-handle",i),...n,children:["text"!==o&&r("i",{className:"i-colorpicker-square",style:{background:l}}),"square"!==o&&r("span",{className:"i-colorpicker-text",style:{color:l},children:l??t})]})};export{c as default};
|
|
2
|
+
//# sourceMappingURL=handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.js","sources":["../../../../packages/components/picker/colors/handle.tsx"],"sourcesContent":["import classNames from \"classnames\";\n\nconst Handle = (props) => {\n\tconst { ref, color, handle, placeholder, className, ...restProps } = props;\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-colorpicker-handle\", className)}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{handle !== \"text\" && (\n\t\t\t\t<i\n\t\t\t\t\tclassName='i-colorpicker-square'\n\t\t\t\t\tstyle={{ background: color }}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{handle !== \"square\" && (\n\t\t\t\t<span className='i-colorpicker-text' style={{ color }}>\n\t\t\t\t\t{color ?? placeholder}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Handle;\n"],"names":["Handle","props","ref","color","handle","placeholder","className","restProps","_jsxs","classNames","children","_jsx","style","background"],"mappings":"4EAEA,MAAMA,EAAUC,IACf,MAAMC,IAAEA,EAAGC,MAAEA,EAAKC,OAAEA,EAAMC,YAAEA,EAAWC,UAAEA,KAAcC,GAAcN,EAErE,OACCO,EAAA,MAAA,CACCN,IAAKA,EACLI,UAAWG,EAAW,uBAAwBH,MAC1CC,EAEHG,SAAA,CAAW,SAAXN,GACAO,EACC,IAAA,CAAAL,UAAU,uBACVM,MAAO,CAAEC,WAAYV,KAIX,WAAXC,GACAO,EAAM,OAAA,CAAAL,UAAU,qBAAqBM,MAAO,CAAET,SAC5CO,SAAAP,GAASE,MAGP"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e,jsxs as o,Fragment as l}from"react/jsx-runtime";import a from"@rc-component/color-picker";import{useReactive as n}from"ahooks";import{useEffect as i}from"react";import r from"../../popup/popup.js";import t,{ColorMethods as p}from"./footer.js";import s from"./handle.js";function c(c){const{value:u,type:h="HEX",disabledAlpha:m,children:v,usePanel:d,handle:b="both",placeholder:y="Colors",popupProps:f,onChange:g}=c,C=n({type:h,value:u,syncValue:u,visible:f?.visible}),V=e=>{const o=p[e];C.type=e,C.value=C.syncValue[o]?.()},j=e=>{C.value=e,C.syncValue=e},k=()=>{g?.(C.value),C.visible=!1};return i((()=>{C.syncValue=u,C.value=u}),[u]),d?e(a,{...c}):e(r,{trigger:"click",touchable:!0,position:"bottom",...f,visible:C.visible,content:e(a,{value:C.syncValue,disabledAlpha:m,panelRender:a=>o(l,{children:[a,e(t,{value:C.value,type:C.type,onTypeChange:V,onChange:j,onOk:k})]}),onChange:e=>{C.syncValue=e},onChangeComplete:e=>{const o=p[C.type];1!==e.a&&(e.a=parseFloat(e.a.toFixed(3))),C.value=e[o]?.()}}),onVisibleChange:e=>{C.visible=e,f?.onVisibleChange?.(e)},children:v??e(s,{color:u,handle:b,placeholder:y})})}export{c as default};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/components/picker/colors/index.tsx"],"sourcesContent":["import ColorsPanel from \"@rc-component/color-picker\";\nimport { useReactive } from \"ahooks\";\nimport { useEffect } from \"react\";\nimport Popup from \"../../popup\";\nimport { IColorPicker } from \"../type\";\nimport Footer, { ColorMethods } from \"./footer\";\nimport Handle from \"./handle\";\nimport \"./index.css\";\n\nexport default function ColorPicker(props: IColorPicker) {\n\tconst {\n\t\tvalue,\n\t\ttype = \"HEX\",\n\t\tdisabledAlpha,\n\t\tchildren,\n\t\tusePanel,\n\t\thandle = \"both\",\n\t\tplaceholder = \"Colors\",\n\t\tpopupProps,\n\t\tonChange,\n\t} = props;\n\n\tconst state = useReactive({\n\t\ttype,\n\t\tvalue,\n\t\tsyncValue: value,\n\t\tvisible: popupProps?.visible,\n\t});\n\n\tconst handleChange = (target) => {\n\t\tstate.syncValue = target;\n\t};\n\n\tconst handleComplete = (target) => {\n\t\tconst method = ColorMethods[state.type];\n\n\t\tif (target.a !== 1) {\n\t\t\ttarget.a = parseFloat(target.a.toFixed(3));\n\t\t}\n\n\t\tstate.value = target[method]?.();\n\t};\n\n\tconst handleVisibleChange = (v: boolean) => {\n\t\tstate.visible = v;\n\t\tpopupProps?.onVisibleChange?.(v);\n\t};\n\n\tconst handleTypeChange = (t) => {\n\t\tconst method = ColorMethods[t];\n\n\t\tstate.type = t;\n\t\tstate.value = state.syncValue[method]?.();\n\t};\n\n\tconst handleValueChange = (v) => {\n\t\tstate.value = v;\n\t\tstate.syncValue = v;\n\t};\n\n\tconst handleOk = () => {\n\t\tonChange?.(state.value);\n\t\tstate.visible = false;\n\t};\n\n\tuseEffect(() => {\n\t\tstate.syncValue = value;\n\t\tstate.value = value;\n\t}, [value]);\n\n\tif (usePanel) {\n\t\treturn <ColorsPanel {...props} />;\n\t}\n\n\treturn (\n\t\t<Popup\n\t\t\ttrigger='click'\n\t\t\ttouchable\n\t\t\tposition='bottom'\n\t\t\t{...popupProps}\n\t\t\tvisible={state.visible}\n\t\t\tcontent={\n\t\t\t\t<ColorsPanel\n\t\t\t\t\tvalue={state.syncValue}\n\t\t\t\t\tdisabledAlpha={disabledAlpha}\n\t\t\t\t\tpanelRender={(panel) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{panel}\n\t\t\t\t\t\t\t\t<Footer\n\t\t\t\t\t\t\t\t\tvalue={state.value}\n\t\t\t\t\t\t\t\t\ttype={state.type}\n\t\t\t\t\t\t\t\t\tonTypeChange={handleTypeChange}\n\t\t\t\t\t\t\t\t\tonChange={handleValueChange}\n\t\t\t\t\t\t\t\t\tonOk={handleOk}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t);\n\t\t\t\t\t}}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tonChangeComplete={handleComplete}\n\t\t\t\t/>\n\t\t\t}\n\t\t\tonVisibleChange={handleVisibleChange}\n\t\t>\n\t\t\t{children ?? (\n\t\t\t\t<Handle\n\t\t\t\t\tcolor={value}\n\t\t\t\t\thandle={handle}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</Popup>\n\t);\n}\n"],"names":["ColorPicker","props","value","type","disabledAlpha","children","usePanel","handle","placeholder","popupProps","onChange","state","useReactive","syncValue","visible","handleTypeChange","t","method","ColorMethods","handleValueChange","v","handleOk","useEffect","_jsx","ColorsPanel","Popup","trigger","touchable","position","content","panelRender","panel","_jsxs","_Fragment","Footer","onTypeChange","onOk","target","onChangeComplete","a","parseFloat","toFixed","onVisibleChange","Handle","color"],"mappings":"8RASwB,SAAAA,EAAYC,GACnC,MAAMC,MACLA,EAAKC,KACLA,EAAO,MAAKC,cACZA,EAAaC,SACbA,EAAQC,SACRA,EAAQC,OACRA,EAAS,OAAMC,YACfA,EAAc,SAAQC,WACtBA,EAAUC,SACVA,GACGT,EAEEU,EAAQC,EAAY,CACzBT,OACAD,QACAW,UAAWX,EACXY,QAASL,GAAYK,UAsBhBC,EAAoBC,IACzB,MAAMC,EAASC,EAAaF,GAE5BL,EAAMR,KAAOa,EACbL,EAAMT,MAAQS,EAAME,UAAUI,MAAW,EAGpCE,EAAqBC,IAC1BT,EAAMT,MAAQkB,EACdT,EAAME,UAAYO,CAAC,EAGdC,EAAW,KAChBX,IAAWC,EAAMT,OACjBS,EAAMG,SAAU,CAAK,EAQtB,OALAQ,GAAU,KACTX,EAAME,UAAYX,EAClBS,EAAMT,MAAQA,CAAK,GACjB,CAACA,IAEAI,EACIiB,EAACC,EAAgB,IAAAvB,IAIxBsB,EAACE,GACAC,QAAQ,QACRC,aACAC,SAAS,YACLnB,EACJK,QAASH,EAAMG,QACfe,QACCN,EAACC,GACAtB,MAAOS,EAAME,UACbT,cAAeA,EACf0B,YAAcC,GAEZC,EAAAC,EAAA,CAAA5B,SAAA,CACE0B,EACDR,EAACW,EAAM,CACNhC,MAAOS,EAAMT,MACbC,KAAMQ,EAAMR,KACZgC,aAAcpB,EACdL,SAAUS,EACViB,KAAMf,OAKVX,SAtEkB2B,IACrB1B,EAAME,UAAYwB,CAAM,EAsErBC,iBAnEoBD,IACvB,MAAMpB,EAASC,EAAaP,EAAMR,MAEjB,IAAbkC,EAAOE,IACVF,EAAOE,EAAIC,WAAWH,EAAOE,EAAEE,QAAQ,KAGxC9B,EAAMT,MAAQmC,EAAOpB,MAAW,IA+D/ByB,gBA5D2BtB,IAC5BT,EAAMG,QAAUM,EAChBX,GAAYiC,kBAAkBtB,EAAE,EA0DKf,SAEnCA,GACAkB,EAACoB,GACAC,MAAO1C,EACPK,OAAQA,EACRC,YAAaA,KAKlB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,Fragment as a,jsx as t}from"react/jsx-runtime";import r from"classnames";import d from"dayjs";import{useMemo as i}from"react";const m=m=>{const{value:s,month:n,weeks:c=["一","二","三","四","五","六","日"],renderDate:o=e=>e.date(),disabledDate:p,onDateClick:l}=m,h=d(),k=i((()=>{const e=[],a=n.add(-1,"month").endOf("month");let{$W:t,$D:r}=a;if(0!==t){const r=Array.from({length:t}).map(((e,r)=>a.add(r+1-t,"day")));e.push(...r)}const d=n.endOf("month");return r=d.$D,t=d.$W,e.push(...Array.from({length:r}).map(((e,a)=>d.add(a+1-r,"day")))),0!==t&&e.push(...Array.from({length:7-t}).map(((e,a)=>d.add(a+1,"day")))),e}),[n]);return e(a,{children:[t("div",{className:"i-datepicker-weeks",children:c.map(((e,a)=>t("span",{className:"i-datepicker-week",children:e},a)))}),t("div",{className:"i-datepicker-dates",children:k.map(((e,a)=>{const d=e.isSame(s,"day"),i=e.isSame(n,"month"),m=e.isSame(h,"day"),c=p?.(e);return t("div",{className:r("i-datepicker-item",{"i-datepicker-active":d,"i-datepicker-same-month":i,"i-datepicker-today":m,"i-datepicker-disabled":c}),onClick:()=>(e=>{p?.(e)||l?.(e)})(e),children:o(e)},a)}))})]})};export{m as default};
|
|
2
|
+
//# sourceMappingURL=dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dates.js","sources":["../../../../packages/components/picker/dates/dates.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport dayjs, { Dayjs } from \"dayjs\";\nimport { ReactNode, useMemo } from \"react\";\nimport { IBaseDates } from \"../type\";\n\nconst Dates = (\n\tprops: IBaseDates & {\n\t\tmonth: any;\n\t}\n) => {\n\tconst {\n\t\tvalue,\n\t\tmonth,\n\t\tweeks = [\"一\", \"二\", \"三\", \"四\", \"五\", \"六\", \"日\"],\n\t\trenderDate = (date: Dayjs) => date.date(),\n\t\tdisabledDate,\n\t\tonDateClick,\n\t} = props;\n\tconst today = dayjs();\n\n\tconst dates = useMemo(() => {\n\t\tconst dates: Dayjs[] = [];\n\n\t\tconst lastDateOfLastMonth = month.add(-1, \"month\").endOf(\"month\");\n\t\tlet { $W, $D } = lastDateOfLastMonth;\n\n\t\tif ($W !== 0) {\n\t\t\tconst lastMonthDates = Array.from({ length: $W }).map(\n\t\t\t\t(whatever, i) => lastDateOfLastMonth.add(i + 1 - $W, \"day\")\n\t\t\t);\n\t\t\tdates.push(...lastMonthDates);\n\t\t}\n\n\t\tconst lastDate = month.endOf(\"month\");\n\t\t$D = lastDate.$D;\n\t\t$W = lastDate.$W;\n\t\tdates.push(\n\t\t\t...Array.from({ length: $D }).map((whatever, i) =>\n\t\t\t\tlastDate.add(i + 1 - $D, \"day\")\n\t\t\t)\n\t\t);\n\n\t\tif ($W !== 0) {\n\t\t\tdates.push(\n\t\t\t\t...Array.from({ length: 7 - $W }).map((whatever, i) =>\n\t\t\t\t\tlastDate.add(i + 1, \"day\")\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn dates;\n\t}, [month]);\n\n\tconst handleDateClick = (date: Dayjs) => {\n\t\tif (disabledDate?.(date)) return;\n\n\t\tonDateClick?.(date);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<div className='i-datepicker-weeks'>\n\t\t\t\t{weeks.map((week: ReactNode, i: number) => (\n\t\t\t\t\t<span key={i} className='i-datepicker-week'>\n\t\t\t\t\t\t{week}\n\t\t\t\t\t</span>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t\t<div className='i-datepicker-dates'>\n\t\t\t\t{dates.map((date, i: number) => {\n\t\t\t\t\tconst active = date.isSame(value, \"day\");\n\t\t\t\t\tconst isSameMonth = date.isSame(month, \"month\");\n\t\t\t\t\tconst isToday = date.isSame(today, \"day\");\n\t\t\t\t\tconst disabled = disabledDate?.(date);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\t\tclassName={classNames(\"i-datepicker-item\", {\n\t\t\t\t\t\t\t\t\"i-datepicker-active\": active,\n\t\t\t\t\t\t\t\t\"i-datepicker-same-month\": isSameMonth,\n\t\t\t\t\t\t\t\t\"i-datepicker-today\": isToday,\n\t\t\t\t\t\t\t\t\"i-datepicker-disabled\": disabled,\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\tonClick={() => handleDateClick(date)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{renderDate(date)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</div>\n\t\t</>\n\t);\n};\n\nexport default Dates;\n"],"names":["Dates","props","value","month","weeks","renderDate","date","disabledDate","onDateClick","today","dayjs","dates","useMemo","lastDateOfLastMonth","add","endOf","$W","$D","lastMonthDates","Array","from","length","map","whatever","i","push","lastDate","_jsxs","_jsx","className","children","week","active","isSame","isSameMonth","isToday","disabled","classNames","onClick","handleDateClick"],"mappings":"+IAKA,MAAMA,EACLC,IAIA,MAAMC,MACLA,EAAKC,MACLA,EAAKC,MACLA,EAAQ,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAAIC,WAC3CA,EAAcC,GAAgBA,EAAKA,OAAMC,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EAAK,EA4BCiC,CAAgBjC,GAE9BwB,SAAAzB,EAAWC,IATPkB,EAUA,QAIP"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{CalendarMonthTwotone as r}from"@ricons/material";import{useReactive as o}from"ahooks";import a from"dayjs";import t from"dayjs/plugin/customParseFormat.js";import{useState as n,useMemo as i,useEffect as l}from"react";import s from"../../icon/icon.js";import"../../input/index.js";import m from"../../popup/popup.js";import p from"./panel.js";import u from"../../input/input.js";a.extend(t);const c=["YYYY-MM-DD","YYYY-M-D","YYYY/MM/DD","YYYY/M/D"],d="YYYY-MM-DD",Y=t=>{const{name:Y,value:f,weeks:D,format:v=d,placeholder:h=t.format??d,renderDate:M,renderMonth:j,renderYear:g,popupProps:k,disabledDate:b,onDateClick:C,onChange:w,onBlur:x,...V}=t,y=o({value:f}),[z,B]=n(!1),P=i((()=>{if(!y.value)return null;const e=a(y.value,v,!0);return e.isValid()?e:null}),[y.value]),E=e=>{y.value=e,w?.(e)},F=()=>{if(!y.value)return;const e=a(y.value,c,!0);e.isValid()?E(e.format(v)):E("")};return l((()=>{y.value=f}),[f]),e(m,{visible:z,trigger:"click",position:"bottom",arrow:!1,align:"start",onVisibleChange:e=>{k?.onVisibleChange?.(e),B(e)},watchResize:!0,content:e(p,{value:P,weeks:D,renderDate:M,renderMonth:j,renderYear:g,disabledDate:b,onDateClick:e=>{E(e.format(v))}}),...k,children:e(u,{value:y.value,append:e(s,{icon:e(r,{}),className:"i-datepicker-icon",size:"1em"}),placeholder:h,onChange:E,onBlur:e=>{x?.(e),F()},onEnter:F,...V})})};export{Y as default};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/components/picker/dates/index.tsx"],"sourcesContent":["import { CalendarMonthTwotone } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport dayjs, { Dayjs } from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport Icon from \"../../icon\";\nimport Input from \"../../input\";\nimport Popup from \"../../popup\";\nimport { IDatePicker } from \"../type\";\nimport \"./index.css\";\nimport Panel from \"./panel\";\n\ndayjs.extend(customParseFormat);\n\nconst FORMATTYPES = [\"YYYY-MM-DD\", \"YYYY-M-D\", \"YYYY/MM/DD\", \"YYYY/M/D\"];\nconst FORMAT = \"YYYY-MM-DD\";\n\nconst Datepicker = (props: IDatePicker) => {\n\tconst {\n\t\tname,\n\t\tvalue,\n\t\tweeks,\n\t\tformat = FORMAT,\n\t\tplaceholder = props.format ?? FORMAT,\n\t\trenderDate,\n\t\trenderMonth,\n\t\trenderYear,\n\t\tpopupProps,\n\t\tdisabledDate,\n\t\tonDateClick,\n\t\tonChange,\n\t\tonBlur,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t});\n\n\tconst [active, setActive] = useState<boolean>(false);\n\n\tconst dayJsValue = useMemo(() => {\n\t\tif (!state.value) return null;\n\n\t\tconst date = dayjs(state.value as string, format, true);\n\n\t\tif (date.isValid()) return date;\n\n\t\treturn null;\n\t}, [state.value]);\n\n\tconst handleDateClick = (date: Dayjs) => {\n\t\thandleChange(date.format(format));\n\t};\n\n\tconst handleChange = (v) => {\n\t\tstate.value = v;\n\t\tonChange?.(v);\n\t};\n\n\tconst handleSetDate = () => {\n\t\tif (!state.value) return;\n\n\t\tconst date = dayjs(state.value as string, FORMATTYPES, true);\n\n\t\tif (date.isValid()) {\n\t\t\thandleChange(date.format(format));\n\t\t\treturn;\n\t\t}\n\n\t\thandleChange(\"\");\n\t};\n\n\tconst handleBlur = (e) => {\n\t\tonBlur?.(e);\n\t\thandleSetDate();\n\t};\n\n\tconst handleVisibleChange = (v) => {\n\t\tpopupProps?.onVisibleChange?.(v);\n\t\tsetActive(v);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\treturn (\n\t\t<Popup\n\t\t\tvisible={active}\n\t\t\ttrigger='click'\n\t\t\tposition='bottom'\n\t\t\tarrow={false}\n\t\t\talign='start'\n\t\t\tonVisibleChange={handleVisibleChange}\n\t\t\twatchResize\n\t\t\tcontent={\n\t\t\t\t<Panel\n\t\t\t\t\tvalue={dayJsValue}\n\t\t\t\t\tweeks={weeks}\n\t\t\t\t\trenderDate={renderDate}\n\t\t\t\t\trenderMonth={renderMonth}\n\t\t\t\t\trenderYear={renderYear}\n\t\t\t\t\tdisabledDate={disabledDate}\n\t\t\t\t\tonDateClick={handleDateClick}\n\t\t\t\t/>\n\t\t\t}\n\t\t\t{...popupProps}\n\t\t>\n\t\t\t<Input\n\t\t\t\tvalue={state.value}\n\t\t\t\tappend={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={<CalendarMonthTwotone />}\n\t\t\t\t\t\tclassName='i-datepicker-icon'\n\t\t\t\t\t\tsize='1em'\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tplaceholder={placeholder}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tonBlur={handleBlur}\n\t\t\t\tonEnter={handleSetDate}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t</Popup>\n\t);\n};\n\nexport default Datepicker;\n"],"names":["dayjs","extend","customParseFormat","FORMATTYPES","FORMAT","Datepicker","props","name","value","weeks","format","placeholder","renderDate","renderMonth","renderYear","popupProps","disabledDate","onDateClick","onChange","onBlur","restProps","state","useReactive","active","setActive","useState","dayJsValue","useMemo","date","isValid","handleChange","v","handleSetDate","useEffect","_jsx","Popup","visible","trigger","position","arrow","align","onVisibleChange","watchResize","content","Panel","children","Input","append","Icon","icon","CalendarMonthTwotone","className","size","e","onEnter"],"mappings":"yaAYAA,EAAMC,OAAOC,GAEb,MAAMC,EAAc,CAAC,aAAc,WAAY,aAAc,YACvDC,EAAS,aAETC,EAAcC,IACnB,MAAMC,KACLA,EAAIC,MACJA,EAAKC,MACL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sB,QAAStB,KACLZ,KAEE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,jsx as a}from"react/jsx-runtime";import{KeyboardArrowLeftRound as t,KeyboardArrowRightRound as r}from"@ricons/material";import{useReactive as i}from"ahooks";import n from"classnames";import o from"dayjs";import{throttle as c}from"radash";import{useRef as l,useEffect as s}from"react";import d from"../../icon/icon.js";import m from"../../utils/helpericon/helpericon.js";import h from"./dates.js";const p=[1,2,3,4,5,6,7,8,9,10,11,12],k=t=>{const{value:r,unitMonth:i="月",unitYear:n="年",renderYear:o,renderMonth:c,onClick:l}=t;return e("a",{className:"i-datepicker-action","data-ripple":!0,onClick:l,children:[a("span",{children:o?.(r.year())}),n,a("span",{children:c?.(r.month()+1)}),i]})},y=y=>{const{value:u,unitYear:v,unitMonth:f,renderDate:Y,renderMonth:N=e=>e,renderYear:b=e=>e,disabledDate:C,onDateClick:D}=y,M=i({today:u,month:u||o(),selectedYear:o(),years:[],selectable:!1}),j=l(null),g=e=>{M.month=M.month[e?"add":"subtract"](1,"month")},x=c({interval:100},(e=>{const a=e.deltaY<0;M.years=M.years.map((e=>e+(a?-1:1)))}));return s((()=>{if(!M.selectable)return;M.selectedYear=M.month;const e=M.selectedYear.year(),a=Array.from({length:7}).map(((a,t)=>e-3+t));M.years=[...a]}),[M.selectable]),s((()=>{M.today=u,M.month=u||o()}),[u]),e("div",{className:"i-datepicker",children:[e("div",{className:"i-datepicker-units",children:[a(k,{value:M.month,unitYear:v,unitMonth:f,renderMonth:N,renderYear:b,onClick:()=>M.selectable=!0}),a("a",{className:"ml-auto i-datepicker-action","data-ripple":!0,onClick:()=>g(!1),children:a(d,{icon:a(t,{})})}),a("a",{className:"i-datepicker-action","data-ripple":!0,onClick:()=>g(!0),children:a(d,{icon:a(r,{})})})]}),e("div",{className:n("i-datepicker-ym",{"i-datepicker-active":M.selectable}),children:[a(m,{active:!0,className:"i-datepicker-close",onClick:e=>{e.stopPropagation(),M.selectable=!1}}),a("div",{ref:j,className:"i-datepicker-years",onWheel:x,children:M.years.map((e=>a("a",{className:n("i-datepicker-year",{"i-datepicker-active":e===M.selectedYear.year()}),onClick:()=>M.selectedYear=M.selectedYear.year(e),children:b(e)},e)))}),a("div",{className:"i-datepicker-months",children:p.map((e=>a("a",{className:n("i-datepicker-month",{"i-datepicker-active":e===M.month.month()+1}),onClick:()=>{return a=e,M.month=M.month.year(M.selectedYear.year()).month(a-1),void(M.selectable=!1);var a},children:N(e)},e)))})]}),a(h,{value:M.today,month:M.month,disabledDate:C,onDateClick:e=>{e.isSame(M.today,"day")||(e.isSame(M.month,"month")||(M.month=e),M.today=e,D?.(e))},renderDate:Y})]})};export{y as default};
|
|
2
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel.js","sources":["../../../../packages/components/picker/dates/panel.tsx"],"sourcesContent":["import {\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport dayjs, { Dayjs } from \"dayjs\";\nimport { throttle } from \"radash\";\nimport { ReactNode, useEffect, useRef } from \"react\";\nimport Icon from \"../../icon\";\nimport Helpericon from \"../../utils/helpericon\";\nimport { IBaseDates } from \"../type\";\nimport Dates from \"./dates\";\n\nconst MONTHS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];\n\nconst YearMonth = (\n\tprops: IBaseDates & {\n\t\tonClick?: () => void;\n\t}\n) => {\n\tconst {\n\t\tvalue,\n\t\tunitMonth = \"月\",\n\t\tunitYear = \"年\",\n\t\trenderYear,\n\t\trenderMonth,\n\t\tonClick,\n\t} = props;\n\n\treturn (\n\t\t<a className='i-datepicker-action' data-ripple onClick={onClick}>\n\t\t\t<span>{renderYear?.(value.year())}</span>\n\t\t\t{unitYear}\n\t\t\t<span>{renderMonth?.(value.month() + 1)}</span>\n\t\t\t{unitMonth}\n\t\t</a>\n\t);\n};\n\nconst Panel = (props: IBaseDates) => {\n\tconst {\n\t\tvalue,\n\t\tunitYear,\n\t\tunitMonth,\n\t\trenderDate,\n\t\trenderMonth = (m: ReactNode) => m,\n\t\trenderYear = (y: ReactNode) => y,\n\t\tdisabledDate,\n\t\tonDateClick,\n\t} = props;\n\n\tconst state = useReactive({\n\t\ttoday: value,\n\t\tmonth: value || dayjs(),\n\t\tselectedYear: dayjs(),\n\t\tyears: [] as number[],\n\t\tselectable: false,\n\t});\n\n\tconst $years = useRef<HTMLDivElement>(null);\n\n\tconst handleOperateMonth = (next: boolean) => {\n\t\tstate.month = state.month[next ? \"add\" : \"subtract\"](1, \"month\");\n\t};\n\n\tconst handleChangeDate = (date: Dayjs) => {\n\t\tif (date.isSame(state.today, \"day\")) return;\n\n\t\tif (!date.isSame(state.month, \"month\")) {\n\t\t\tstate.month = date;\n\t\t}\n\n\t\tstate.today = date;\n\t\tonDateClick?.(date);\n\t};\n\n\tconst handleChangeMonth = (month: number) => {\n\t\tstate.month = state.month\n\t\t\t.year(state.selectedYear.year())\n\t\t\t.month(month - 1);\n\t\tstate.selectable = false;\n\t};\n\n\tconst getMoreYears = throttle({ interval: 100 }, (e) => {\n\t\tconst isUp = e.deltaY < 0;\n\n\t\tstate.years = state.years.map((y) => (y += isUp ? -1 : 1));\n\t});\n\n\tuseEffect(() => {\n\t\tif (!state.selectable) return;\n\n\t\tstate.selectedYear = state.month;\n\t\tconst y = state.selectedYear.year();\n\t\tconst years = Array.from({ length: 7 }).map((_, i) => y - 3 + i);\n\n\t\tstate.years = [...years];\n\t}, [state.selectable]);\n\n\tuseEffect(() => {\n\t\tstate.today = value;\n\t\tstate.month = value || dayjs();\n\t}, [value]);\n\n\treturn (\n\t\t<div className='i-datepicker'>\n\t\t\t<div className='i-datepicker-units'>\n\t\t\t\t<YearMonth\n\t\t\t\t\tvalue={state.month}\n\t\t\t\t\tunitYear={unitYear}\n\t\t\t\t\tunitMonth={unitMonth}\n\t\t\t\t\trenderMonth={renderMonth}\n\t\t\t\t\trenderYear={renderYear}\n\t\t\t\t\tonClick={() => (state.selectable = true)}\n\t\t\t\t/>\n\t\t\t\t<a\n\t\t\t\t\tclassName='ml-auto i-datepicker-action'\n\t\t\t\t\tdata-ripple\n\t\t\t\t\tonClick={() => handleOperateMonth(false)}\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={<KeyboardArrowLeftRound />} />\n\t\t\t\t</a>\n\t\t\t\t<a\n\t\t\t\t\tclassName='i-datepicker-action'\n\t\t\t\t\tdata-ripple\n\t\t\t\t\tonClick={() => handleOperateMonth(true)}\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={<KeyboardArrowRightRound />} />\n\t\t\t\t</a>\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-datepicker-ym\", {\n\t\t\t\t\t\"i-datepicker-active\": state.selectable,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<Helpericon\n\t\t\t\t\tactive\n\t\t\t\t\tclassName='i-datepicker-close'\n\t\t\t\t\tonClick={(e) => {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\tstate.selectable = false;\n\t\t\t\t\t}}\n\t\t\t\t/>\n\n\t\t\t\t<div\n\t\t\t\t\tref={$years}\n\t\t\t\t\tclassName='i-datepicker-years'\n\t\t\t\t\tonWheel={getMoreYears}\n\t\t\t\t>\n\t\t\t\t\t{state.years.map((y) => (\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\tkey={y}\n\t\t\t\t\t\t\tclassName={classNames(\"i-datepicker-year\", {\n\t\t\t\t\t\t\t\t\"i-datepicker-active\":\n\t\t\t\t\t\t\t\t\ty === state.selectedYear.year(),\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\t(state.selectedYear =\n\t\t\t\t\t\t\t\t\tstate.selectedYear.year(y))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{renderYear(y)}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\n\t\t\t\t<div className='i-datepicker-months'>\n\t\t\t\t\t{MONTHS.map((m) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tkey={m}\n\t\t\t\t\t\t\t\tclassName={classNames(\"i-datepicker-month\", {\n\t\t\t\t\t\t\t\t\t\"i-datepicker-active\":\n\t\t\t\t\t\t\t\t\t\tm === state.month.month() + 1,\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\tonClick={() => handleChangeMonth(m)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderMonth(m)}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<Dates\n\t\t\t\tvalue={state.today}\n\t\t\t\tmonth={state.month}\n\t\t\t\tdisabledDate={disabledDate}\n\t\t\t\tonDateClick={handleChangeDate}\n\t\t\t\trenderDate={renderDate}\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport default Panel;\n"],"names":["MONTHS","YearMonth","props","value","unitMonth","unitYear","renderYear","renderMonth","onClick","_jsxs","className","children","_jsx","year","month","Panel","renderDate","m","y","disabledDate","onDateClick","state","useReactive","today","dayjs","selectedYear","years","selectable","$years","useRef","handleOperateMonth","next","getMoreYears","throttle","interval","e","isUp","deltaY","map","useEffect","Array","from","length","_","i","Icon","icon","KeyboardArrowLeftRound","KeyboardArrowRightRound","classNames","Helpericon","active","stopPropagation","ref","onWheel","handleChangeMonth","Dates","date","isSame"],"mappings":"6ZAcA,MAAMA,EAAS,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,GAAI,GAAI,IAE7CC,EACLC,IAIA,MAAMC,MACLA,EAAKC,UACLA,EAAY,IAAGC,SACfA,EAAW,IAAGC,WACdA,EAAUC,YACVA,EAAWC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O,SAExBkC,EAAKC,OAAOrC,EAAMP,MAAO,WAC7BO,EAAMP,MAAQ2C,GAGfpC,EAAME,MAAQkC,EACdrC,IAAcqC,GAAK,EAqHjBzC,WAAYA,MAER"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{AccessTimeRound as o}from"@ricons/material";import{useReactive as a}from"ahooks";import{useState as r,useEffect as i}from"react";import n from"../../icon/icon.js";import"../../input/index.js";import t from"../../popup/popup.js";import l from"./panel.js";import p from"../../input/input.js";const m="hh:mm:ss";function s(s){const{name:u,value:c,format:f=m,periods:h,placeholder:v=s.format??m,renderItem:d,onChange:g,onBlur:j,popupProps:V,...b}=s,C=a({value:c,safeValue:void 0}),[k,x]=r(!1),w=e=>{C.value=e};return i((()=>{C.value=c}),[c]),e(t,{visible:k,trigger:"click",position:"bottom",arrow:!1,align:"start",watchResize:!0,...V,onVisibleChange:e=>{V?.onVisibleChange?.(e),x(e)},content:e(l,{value:C.value,format:f,periods:h,renderItem:d,onChange:w,onFallback:e=>{C.safeValue=e}}),children:e(p,{value:C.value,placeholder:v,append:e(n,{icon:e(o,{}),className:"i-timepicker-icon",size:"1em"}),onChange:w,onBlur:e=>{j?.(e),C.value&&(C.value=C.safeValue,w(C.safeValue))},...b})})}export{s as default};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|