@_tc/template-core 0.0.1-bate.1 → 0.0.1-bate.2
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/app/pages/main.d.ts +3 -0
- package/app/pages/main.d.ts.map +1 -0
- package/app/pages/main.js +10 -0
- package/app/pages/main.js.map +1 -0
- package/app/vite/config/base.js +54 -0
- package/app/vite/config/base.js.map +1 -0
- package/app/vite/config/data.js +5 -0
- package/app/vite/config/data.js.map +1 -0
- package/app/vite/config/dev.js +13 -0
- package/app/vite/config/dev.js.map +1 -0
- package/app/vite/config/prod.js +32 -0
- package/app/vite/config/prod.js.map +1 -0
- package/app/vite/dev.js +23 -0
- package/app/vite/dev.js.map +1 -0
- package/app/vite/index.js +3 -0
- package/app/vite/index.js.map +1 -0
- package/app/vite/package.json +11 -0
- package/app/vite/prod.js +76 -0
- package/app/vite/prod.js.map +1 -0
- package/package.json +5 -3
- package/packages/core/index.js +1 -1
- package/packages/core/loader/config.js +1 -1
- package/packages/core/loader/controller.js +1 -1
- package/packages/core/loader/extend.js +1 -1
- package/packages/core/loader/middleware.js +1 -1
- package/packages/core/loader/model.js +1 -1
- package/packages/core/loader/router-schema.js +1 -1
- package/packages/core/loader/router.js +1 -1
- package/packages/core/loader/service.js +1 -1
- package/packages/ui/react/components/Button/Button.d.ts +15 -0
- package/packages/ui/react/components/Button/Button.d.ts.map +1 -0
- package/packages/ui/react/components/Button/Button.js +36 -0
- package/packages/ui/react/components/Button/Button.js.map +1 -0
- package/packages/ui/react/components/Button/SumbitButton.d.ts +9 -0
- package/packages/ui/react/components/Button/SumbitButton.d.ts.map +1 -0
- package/packages/ui/react/components/Button/SumbitButton.js +32 -0
- package/packages/ui/react/components/Button/SumbitButton.js.map +1 -0
- package/packages/ui/react/components/Button/index.d.ts +4 -0
- package/packages/ui/react/components/Button/index.d.ts.map +1 -0
- package/packages/ui/react/components/Button/index.js +21 -0
- package/packages/ui/react/components/Button/index.js.map +1 -0
- package/packages/ui/react/components/Checkbox/Checkbox.d.ts +17 -0
- package/packages/ui/react/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/packages/ui/react/components/Checkbox/Checkbox.js +41 -0
- package/packages/ui/react/components/Checkbox/Checkbox.js.map +1 -0
- package/packages/ui/react/components/Checkbox/index.d.ts +2 -0
- package/packages/ui/react/components/Checkbox/index.d.ts.map +1 -0
- package/packages/ui/react/components/Checkbox/index.js +18 -0
- package/packages/ui/react/components/Checkbox/index.js.map +1 -0
- package/packages/ui/react/components/ConfirmDialog.d.ts +12 -0
- package/packages/ui/react/components/ConfirmDialog.d.ts.map +1 -0
- package/packages/ui/react/components/ConfirmDialog.js +13 -0
- package/packages/ui/react/components/ConfirmDialog.js.map +1 -0
- package/packages/ui/react/components/DataTable/ActionBtn.d.ts +6 -0
- package/packages/ui/react/components/DataTable/ActionBtn.d.ts.map +1 -0
- package/packages/ui/react/components/DataTable/ActionBtn.js +18 -0
- package/packages/ui/react/components/DataTable/ActionBtn.js.map +1 -0
- package/packages/ui/react/components/DataTable/data-table.d.ts +25 -0
- package/packages/ui/react/components/DataTable/data-table.d.ts.map +1 -0
- package/packages/ui/react/components/DataTable/data-table.js +145 -0
- package/packages/ui/react/components/DataTable/data-table.js.map +1 -0
- package/packages/ui/react/components/Date/Calendar.d.ts +22 -0
- package/packages/ui/react/components/Date/Calendar.d.ts.map +1 -0
- package/packages/ui/react/components/Date/Calendar.js +210 -0
- package/packages/ui/react/components/Date/Calendar.js.map +1 -0
- package/packages/ui/react/components/Date/Date.d.ts +26 -0
- package/packages/ui/react/components/Date/Date.d.ts.map +1 -0
- package/packages/ui/react/components/Date/Date.js +161 -0
- package/packages/ui/react/components/Date/Date.js.map +1 -0
- package/packages/ui/react/components/Date/DateTestPage.d.ts +2 -0
- package/packages/ui/react/components/Date/DateTestPage.d.ts.map +1 -0
- package/packages/ui/react/components/Date/DateTestPage.js +33 -0
- package/packages/ui/react/components/Date/DateTestPage.js.map +1 -0
- package/packages/ui/react/components/Date/LocaleContext.d.ts +2 -0
- package/packages/ui/react/components/Date/LocaleContext.d.ts.map +1 -0
- package/packages/ui/react/components/Date/LocaleContext.js +9 -0
- package/packages/ui/react/components/Date/LocaleContext.js.map +1 -0
- package/packages/ui/react/components/Date/LocaleProvider.d.ts +8 -0
- package/packages/ui/react/components/Date/LocaleProvider.d.ts.map +1 -0
- package/packages/ui/react/components/Date/LocaleProvider.js +17 -0
- package/packages/ui/react/components/Date/LocaleProvider.js.map +1 -0
- package/packages/ui/react/components/Date/TimePicker.d.ts +7 -0
- package/packages/ui/react/components/Date/TimePicker.d.ts.map +1 -0
- package/packages/ui/react/components/Date/TimePicker.js +79 -0
- package/packages/ui/react/components/Date/TimePicker.js.map +1 -0
- package/packages/ui/react/components/Date/data.d.ts +6 -0
- package/packages/ui/react/components/Date/data.d.ts.map +1 -0
- package/packages/ui/react/components/Date/data.js +8 -0
- package/packages/ui/react/components/Date/data.js.map +1 -0
- package/packages/ui/react/components/Date/dateLocaleStore.d.ts +10 -0
- package/packages/ui/react/components/Date/dateLocaleStore.d.ts.map +1 -0
- package/packages/ui/react/components/Date/dateLocaleStore.js +18 -0
- package/packages/ui/react/components/Date/dateLocaleStore.js.map +1 -0
- package/packages/ui/react/components/Date/index.d.ts +6 -0
- package/packages/ui/react/components/Date/index.d.ts.map +1 -0
- package/packages/ui/react/components/Date/index.js +24 -0
- package/packages/ui/react/components/Date/index.js.map +1 -0
- package/packages/ui/react/components/Date/locales.d.ts +23 -0
- package/packages/ui/react/components/Date/locales.d.ts.map +1 -0
- package/packages/ui/react/components/Date/locales.js +43 -0
- package/packages/ui/react/components/Date/locales.js.map +1 -0
- package/packages/ui/react/components/Dropdown.d.ts +16 -0
- package/packages/ui/react/components/Dropdown.d.ts.map +1 -0
- package/packages/ui/react/components/Dropdown.js +56 -0
- package/packages/ui/react/components/Dropdown.js.map +1 -0
- package/packages/ui/react/components/Form/Form.d.ts +12 -0
- package/packages/ui/react/components/Form/Form.d.ts.map +1 -0
- package/packages/ui/react/components/Form/Form.js +15 -0
- package/packages/ui/react/components/Form/Form.js.map +1 -0
- package/packages/ui/react/components/Form/FormItem.d.ts +20 -0
- package/packages/ui/react/components/Form/FormItem.d.ts.map +1 -0
- package/packages/ui/react/components/Form/FormItem.js +76 -0
- package/packages/ui/react/components/Form/FormItem.js.map +1 -0
- package/packages/ui/react/components/Form/SchemeForm/data.d.ts +51 -0
- package/packages/ui/react/components/Form/SchemeForm/data.d.ts.map +1 -0
- package/packages/ui/react/components/Form/SchemeForm/data.js +48 -0
- package/packages/ui/react/components/Form/SchemeForm/data.js.map +1 -0
- package/packages/ui/react/components/Form/SchemeForm/index.d.ts +59 -0
- package/packages/ui/react/components/Form/SchemeForm/index.d.ts.map +1 -0
- package/packages/ui/react/components/Form/SchemeForm/index.js +70 -0
- package/packages/ui/react/components/Form/SchemeForm/index.js.map +1 -0
- package/packages/ui/react/components/Form/index.d.ts +5 -0
- package/packages/ui/react/components/Form/index.d.ts.map +1 -0
- package/packages/ui/react/components/Form/index.js +21 -0
- package/packages/ui/react/components/Form/index.js.map +1 -0
- package/packages/ui/react/components/Form/useForm.d.ts +3 -0
- package/packages/ui/react/components/Form/useForm.d.ts.map +1 -0
- package/packages/ui/react/components/Form/useForm.js +6 -0
- package/packages/ui/react/components/Form/useForm.js.map +1 -0
- package/packages/ui/react/components/ImagePreview/ImagePreview.d.ts +8 -0
- package/packages/ui/react/components/ImagePreview/ImagePreview.d.ts.map +1 -0
- package/packages/ui/react/components/ImagePreview/ImagePreview.js +162 -0
- package/packages/ui/react/components/ImagePreview/ImagePreview.js.map +1 -0
- package/packages/ui/react/components/ImagePreview/PreviewImage.d.ts +8 -0
- package/packages/ui/react/components/ImagePreview/PreviewImage.d.ts.map +1 -0
- package/packages/ui/react/components/ImagePreview/PreviewImage.js +29 -0
- package/packages/ui/react/components/ImagePreview/PreviewImage.js.map +1 -0
- package/packages/ui/react/components/ImagePreview/index.d.ts +3 -0
- package/packages/ui/react/components/ImagePreview/index.d.ts.map +1 -0
- package/packages/ui/react/components/ImagePreview/index.js +19 -0
- package/packages/ui/react/components/ImagePreview/index.js.map +1 -0
- package/packages/ui/react/components/Input/Input.d.ts +21 -0
- package/packages/ui/react/components/Input/Input.d.ts.map +1 -0
- package/packages/ui/react/components/Input/Input.js +61 -0
- package/packages/ui/react/components/Input/Input.js.map +1 -0
- package/packages/ui/react/components/Input/index.d.ts +2 -0
- package/packages/ui/react/components/Input/index.d.ts.map +1 -0
- package/packages/ui/react/components/Input/index.js +18 -0
- package/packages/ui/react/components/Input/index.js.map +1 -0
- package/packages/ui/react/components/Label/Label.d.ts +22 -0
- package/packages/ui/react/components/Label/Label.d.ts.map +1 -0
- package/packages/ui/react/components/Label/Label.js +37 -0
- package/packages/ui/react/components/Label/Label.js.map +1 -0
- package/packages/ui/react/components/Label/index.d.ts +3 -0
- package/packages/ui/react/components/Label/index.d.ts.map +1 -0
- package/packages/ui/react/components/Label/index.js +21 -0
- package/packages/ui/react/components/Label/index.js.map +1 -0
- package/packages/ui/react/components/Message/Message.d.ts +13 -0
- package/packages/ui/react/components/Message/Message.d.ts.map +1 -0
- package/packages/ui/react/components/Message/Message.js +56 -0
- package/packages/ui/react/components/Message/Message.js.map +1 -0
- package/packages/ui/react/components/Message/MessageManager.d.ts +37 -0
- package/packages/ui/react/components/Message/MessageManager.d.ts.map +1 -0
- package/packages/ui/react/components/Message/MessageManager.js +86 -0
- package/packages/ui/react/components/Message/MessageManager.js.map +1 -0
- package/packages/ui/react/components/Message/data.d.ts +2 -0
- package/packages/ui/react/components/Message/data.d.ts.map +1 -0
- package/packages/ui/react/components/Message/data.js +5 -0
- package/packages/ui/react/components/Message/data.js.map +1 -0
- package/packages/ui/react/components/Message/index.d.ts +3 -0
- package/packages/ui/react/components/Message/index.d.ts.map +1 -0
- package/packages/ui/react/components/Message/index.js +6 -0
- package/packages/ui/react/components/Message/index.js.map +1 -0
- package/packages/ui/react/components/Modal/Modal.d.ts +19 -0
- package/packages/ui/react/components/Modal/Modal.d.ts.map +1 -0
- package/packages/ui/react/components/Modal/Modal.js +51 -0
- package/packages/ui/react/components/Modal/Modal.js.map +1 -0
- package/packages/ui/react/components/Modal/ModalManager.d.ts +47 -0
- package/packages/ui/react/components/Modal/ModalManager.d.ts.map +1 -0
- package/packages/ui/react/components/Modal/ModalManager.js +91 -0
- package/packages/ui/react/components/Modal/ModalManager.js.map +1 -0
- package/packages/ui/react/components/Modal/index.d.ts +4 -0
- package/packages/ui/react/components/Modal/index.d.ts.map +1 -0
- package/packages/ui/react/components/Modal/index.js +8 -0
- package/packages/ui/react/components/Modal/index.js.map +1 -0
- package/packages/ui/react/components/Pagination.d.ts +11 -0
- package/packages/ui/react/components/Pagination.d.ts.map +1 -0
- package/packages/ui/react/components/Pagination.js +85 -0
- package/packages/ui/react/components/Pagination.js.map +1 -0
- package/packages/ui/react/components/Search/Search.d.ts +14 -0
- package/packages/ui/react/components/Search/Search.d.ts.map +1 -0
- package/packages/ui/react/components/Search/Search.js +15 -0
- package/packages/ui/react/components/Search/Search.js.map +1 -0
- package/packages/ui/react/components/Search/index.d.ts +2 -0
- package/packages/ui/react/components/Search/index.d.ts.map +1 -0
- package/packages/ui/react/components/Search/index.js +9 -0
- package/packages/ui/react/components/Search/index.js.map +1 -0
- package/packages/ui/react/components/Select/Select.d.ts +19 -0
- package/packages/ui/react/components/Select/Select.d.ts.map +1 -0
- package/packages/ui/react/components/Select/Select.js +167 -0
- package/packages/ui/react/components/Select/Select.js.map +1 -0
- package/packages/ui/react/components/Select/index.d.ts +2 -0
- package/packages/ui/react/components/Select/index.d.ts.map +1 -0
- package/packages/ui/react/components/Select/index.js +18 -0
- package/packages/ui/react/components/Select/index.js.map +1 -0
- package/packages/ui/react/components/Skeleton/Skeleton.d.ts +13 -0
- package/packages/ui/react/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/packages/ui/react/components/Skeleton/Skeleton.js +36 -0
- package/packages/ui/react/components/Skeleton/Skeleton.js.map +1 -0
- package/packages/ui/react/components/Skeleton/index.d.ts +3 -0
- package/packages/ui/react/components/Skeleton/index.d.ts.map +1 -0
- package/packages/ui/react/components/Skeleton/index.js +6 -0
- package/packages/ui/react/components/Skeleton/index.js.map +1 -0
- package/packages/ui/react/components/Switch/Switch.d.ts +11 -0
- package/packages/ui/react/components/Switch/Switch.d.ts.map +1 -0
- package/packages/ui/react/components/Switch/Switch.js +57 -0
- package/packages/ui/react/components/Switch/Switch.js.map +1 -0
- package/packages/ui/react/components/Switch/index.d.ts +2 -0
- package/packages/ui/react/components/Switch/index.d.ts.map +1 -0
- package/packages/ui/react/components/Switch/index.js +18 -0
- package/packages/ui/react/components/Switch/index.js.map +1 -0
- package/packages/ui/react/components/TableSearch/TableSearch.d.ts +30 -0
- package/packages/ui/react/components/TableSearch/TableSearch.d.ts.map +1 -0
- package/packages/ui/react/components/TableSearch/TableSearch.js +121 -0
- package/packages/ui/react/components/TableSearch/TableSearch.js.map +1 -0
- package/packages/ui/react/components/TableSearch/index.d.ts +2 -0
- package/packages/ui/react/components/TableSearch/index.d.ts.map +1 -0
- package/packages/ui/react/components/TableSearch/index.js +9 -0
- package/packages/ui/react/components/TableSearch/index.js.map +1 -0
- package/packages/ui/react/components/TableSearch/lang.d.ts +15 -0
- package/packages/ui/react/components/TableSearch/lang.d.ts.map +1 -0
- package/packages/ui/react/components/TableSearch/lang.js +28 -0
- package/packages/ui/react/components/TableSearch/lang.js.map +1 -0
- package/packages/ui/react/components/TableSearch/tableSearchLocaleStore.d.ts +9 -0
- package/packages/ui/react/components/TableSearch/tableSearchLocaleStore.d.ts.map +1 -0
- package/packages/ui/react/components/TableSearch/tableSearchLocaleStore.js +15 -0
- package/packages/ui/react/components/TableSearch/tableSearchLocaleStore.js.map +1 -0
- package/packages/ui/react/components/Textarea.d.ts +19 -0
- package/packages/ui/react/components/Textarea.d.ts.map +1 -0
- package/packages/ui/react/components/Textarea.js +38 -0
- package/packages/ui/react/components/Textarea.js.map +1 -0
- package/packages/ui/react/components/Tooltip.d.ts +9 -0
- package/packages/ui/react/components/Tooltip.d.ts.map +1 -0
- package/packages/ui/react/components/Tooltip.js +109 -0
- package/packages/ui/react/components/Tooltip.js.map +1 -0
- package/packages/ui/react/components/TreeSelect.d.ts +19 -0
- package/packages/ui/react/components/TreeSelect.d.ts.map +1 -0
- package/packages/ui/react/components/TreeSelect.js +160 -0
- package/packages/ui/react/components/TreeSelect.js.map +1 -0
- package/packages/ui/react/components/Upload/ImageUpload.d.ts +9 -0
- package/packages/ui/react/components/Upload/ImageUpload.d.ts.map +1 -0
- package/packages/ui/react/components/Upload/ImageUpload.js +67 -0
- package/packages/ui/react/components/Upload/ImageUpload.js.map +1 -0
- package/packages/ui/react/components/Upload/Upload.d.ts +14 -0
- package/packages/ui/react/components/Upload/Upload.d.ts.map +1 -0
- package/packages/ui/react/components/Upload/Upload.js +9 -0
- package/packages/ui/react/components/Upload/Upload.js.map +1 -0
- package/packages/ui/react/components/Upload/index.d.ts +3 -0
- package/packages/ui/react/components/Upload/index.d.ts.map +1 -0
- package/packages/ui/react/components/Upload/index.js +19 -0
- package/packages/ui/react/components/Upload/index.js.map +1 -0
- package/packages/ui/react/components/breadcrumb.d.ts +35 -0
- package/packages/ui/react/components/breadcrumb.d.ts.map +1 -0
- package/packages/ui/react/components/breadcrumb.js +80 -0
- package/packages/ui/react/components/breadcrumb.js.map +1 -0
- package/packages/ui/react/components/hooks/useInputController.d.ts +21 -0
- package/packages/ui/react/components/hooks/useInputController.d.ts.map +1 -0
- package/packages/ui/react/components/hooks/useInputController.js +43 -0
- package/packages/ui/react/components/hooks/useInputController.js.map +1 -0
- package/packages/ui/react/components/index.d.ts +24 -0
- package/packages/ui/react/components/index.d.ts.map +1 -0
- package/packages/ui/react/components/index.js +40 -0
- package/packages/ui/react/components/index.js.map +1 -0
- package/packages/ui/react/components/table.d.ts +17 -0
- package/packages/ui/react/components/table.d.ts.map +1 -0
- package/packages/ui/react/components/table.js +64 -0
- package/packages/ui/react/components/table.js.map +1 -0
- package/packages/ui/react/components/testPage/index.d.ts +3 -0
- package/packages/ui/react/components/testPage/index.d.ts.map +1 -0
- package/packages/ui/react/components/testPage/index.js +124 -0
- package/packages/ui/react/components/testPage/index.js.map +1 -0
- package/packages/ui/react/hooks/useBreadcrumb.d.ts +10 -0
- package/packages/ui/react/hooks/useBreadcrumb.d.ts.map +1 -0
- package/packages/ui/react/hooks/useBreadcrumb.js +6 -0
- package/packages/ui/react/hooks/useBreadcrumb.js.map +1 -0
- package/packages/ui/react/hooks/useInit.d.ts +3 -0
- package/packages/ui/react/hooks/useInit.d.ts.map +1 -0
- package/packages/ui/react/hooks/useInit.js +12 -0
- package/packages/ui/react/hooks/useInit.js.map +1 -0
- package/packages/ui/react/hooks/useLanguage.d.ts +7 -0
- package/packages/ui/react/hooks/useLanguage.d.ts.map +1 -0
- package/packages/ui/react/hooks/useLanguage.js +8 -0
- package/packages/ui/react/hooks/useLanguage.js.map +1 -0
- package/packages/ui/react/hooks/usePagination.d.ts +16 -0
- package/packages/ui/react/hooks/usePagination.d.ts.map +1 -0
- package/packages/ui/react/hooks/usePagination.js +34 -0
- package/packages/ui/react/hooks/usePagination.js.map +1 -0
- package/packages/ui/react/index.d.ts +3 -0
- package/packages/ui/react/index.d.ts.map +1 -0
- package/packages/ui/react/index.js +19 -0
- package/packages/ui/react/index.js.map +1 -0
- package/packages/ui/react/lib/export.d.ts +22 -0
- package/packages/ui/react/lib/export.d.ts.map +1 -0
- package/packages/ui/react/lib/export.js +136 -0
- package/packages/ui/react/lib/export.js.map +1 -0
- package/packages/ui/react/lib/utils.d.ts +10 -0
- package/packages/ui/react/lib/utils.d.ts.map +1 -0
- package/packages/ui/react/lib/utils.js +53 -0
- package/packages/ui/react/lib/utils.js.map +1 -0
- package/packages/ui/react/locales/index.d.ts +8 -0
- package/packages/ui/react/locales/index.d.ts.map +1 -0
- package/packages/ui/react/locales/index.js +10 -0
- package/packages/ui/react/locales/index.js.map +1 -0
- package/packages/ui/react/stores/breadcrumb.d.ts +15 -0
- package/packages/ui/react/stores/breadcrumb.d.ts.map +1 -0
- package/packages/ui/react/stores/breadcrumb.js +68 -0
- package/packages/ui/react/stores/breadcrumb.js.map +1 -0
- package/packages/ui/react/stores/language.d.ts +13 -0
- package/packages/ui/react/stores/language.d.ts.map +1 -0
- package/packages/ui/react/stores/language.js +55 -0
- package/packages/ui/react/stores/language.js.map +1 -0
- package/packages/ui/react/types/index.d.ts +2 -0
- package/packages/ui/react/types/index.d.ts.map +1 -0
- package/packages/ui/react/types/index.js +3 -0
- package/packages/ui/react/types/index.js.map +1 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImagePreviewController = ImagePreviewController;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const lucide_react_1 = require("lucide-react");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_dom_1 = require("react-dom");
|
|
8
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
9
|
+
function PreviewCore({ images, initialIndex, onClose }) {
|
|
10
|
+
const [index, setIndex] = (0, react_1.useState)(initialIndex);
|
|
11
|
+
const [scale, _setScale] = (0, react_1.useState)(1);
|
|
12
|
+
const scaleRef = (0, react_1.useRef)(scale);
|
|
13
|
+
const [rotation, setRotation] = (0, react_1.useState)(0);
|
|
14
|
+
const [flipX, setFlipX] = (0, react_1.useState)(false);
|
|
15
|
+
const [flipY, setFlipY] = (0, react_1.useState)(false);
|
|
16
|
+
const imgRef = (0, react_1.useRef)(null);
|
|
17
|
+
const lastScaleBeforeNatural = (0, react_1.useRef)(null);
|
|
18
|
+
const [position, setPosition] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
19
|
+
const [isDragging, setIsDragging] = (0, react_1.useState)(false);
|
|
20
|
+
const dragStart = (0, react_1.useRef)({ x: 0, y: 0 });
|
|
21
|
+
const positionRef = (0, react_1.useRef)({ x: 0, y: 0 });
|
|
22
|
+
const setScale = (0, react_1.useCallback)((newValue) => {
|
|
23
|
+
let newState = newValue;
|
|
24
|
+
if (typeof newValue === 'function') {
|
|
25
|
+
newState = newValue(scaleRef.current || 1);
|
|
26
|
+
}
|
|
27
|
+
scaleRef.current = newState;
|
|
28
|
+
_setScale(newState);
|
|
29
|
+
}, []);
|
|
30
|
+
const hasImages = images.length > 0;
|
|
31
|
+
const currentIndex = (0, react_1.useMemo)(() => clamp(index, 0, Math.max(images.length - 1, 0)), [index, images.length]);
|
|
32
|
+
const currentImage = hasImages ? images[currentIndex] : '';
|
|
33
|
+
const reset = () => {
|
|
34
|
+
setScale(1);
|
|
35
|
+
setRotation(0);
|
|
36
|
+
setFlipX(false);
|
|
37
|
+
setFlipY(false);
|
|
38
|
+
setPosition({ x: 0, y: 0 });
|
|
39
|
+
positionRef.current = { x: 0, y: 0 };
|
|
40
|
+
lastScaleBeforeNatural.current = null;
|
|
41
|
+
};
|
|
42
|
+
const handleMouseDown = (0, react_1.useCallback)((e) => {
|
|
43
|
+
setIsDragging(true);
|
|
44
|
+
dragStart.current = { x: e.clientX - positionRef.current.x, y: e.clientY - positionRef.current.y };
|
|
45
|
+
}, []);
|
|
46
|
+
const handleMouseMove = (0, react_1.useCallback)((e) => {
|
|
47
|
+
if (!isDragging)
|
|
48
|
+
return;
|
|
49
|
+
const newX = e.clientX - dragStart.current.x;
|
|
50
|
+
const newY = e.clientY - dragStart.current.y;
|
|
51
|
+
positionRef.current = { x: newX, y: newY };
|
|
52
|
+
setPosition({ x: newX, y: newY });
|
|
53
|
+
}, [isDragging]);
|
|
54
|
+
const handleMouseUp = (0, react_1.useCallback)(() => {
|
|
55
|
+
setIsDragging(false);
|
|
56
|
+
}, []);
|
|
57
|
+
const toPrev = () => {
|
|
58
|
+
if (!hasImages)
|
|
59
|
+
return;
|
|
60
|
+
setIndex((prev) => (prev - 1 + images.length) % images.length);
|
|
61
|
+
reset();
|
|
62
|
+
};
|
|
63
|
+
const toNext = () => {
|
|
64
|
+
if (!hasImages)
|
|
65
|
+
return;
|
|
66
|
+
setIndex((prev) => (prev + 1) % images.length);
|
|
67
|
+
reset();
|
|
68
|
+
};
|
|
69
|
+
const zoomIn = () => setScale((prev) => clamp(prev + 0.2, 0.2, 5));
|
|
70
|
+
const zoomOut = () => setScale((prev) => clamp(prev - 0.2, 0.2, 5));
|
|
71
|
+
const rotateLeft = () => setRotation((prev) => prev - 90);
|
|
72
|
+
const rotateRight = () => setRotation((prev) => prev + 90);
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
const handleKey = (e) => {
|
|
75
|
+
if (e.key === 'Escape') {
|
|
76
|
+
onClose();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (e.key === 'ArrowLeft') {
|
|
80
|
+
if (!hasImages)
|
|
81
|
+
return;
|
|
82
|
+
setIndex((prev) => (prev - 1 + images.length) % images.length);
|
|
83
|
+
reset();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (e.key === 'ArrowRight') {
|
|
87
|
+
if (!hasImages)
|
|
88
|
+
return;
|
|
89
|
+
setIndex((prev) => (prev + 1) % images.length);
|
|
90
|
+
reset();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
document.addEventListener('keydown', handleKey);
|
|
94
|
+
return () => document.removeEventListener('keydown', handleKey);
|
|
95
|
+
}, [onClose, hasImages, images.length]);
|
|
96
|
+
(0, react_1.useEffect)(() => {
|
|
97
|
+
if (!imgRef.current)
|
|
98
|
+
return;
|
|
99
|
+
const transform = `translate(calc(-50% + ${position.x}px), calc(-50% + ${position.y}px)) rotate(${rotation}deg) scale(${flipX ? -scale : scale}, ${flipY ? -scale : scale})`;
|
|
100
|
+
imgRef.current.style.transform = transform;
|
|
101
|
+
}, [rotation, scale, flipX, flipY, position]);
|
|
102
|
+
if (!hasImages)
|
|
103
|
+
return null;
|
|
104
|
+
const content = ((0, jsx_runtime_1.jsxs)("div", { className: "fixed inset-0 z-[1100] bg-black/40 text-white", onClick: onClose, children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: onClose, className: "absolute right-6 top-6 p-2 rounded-full bg-black/70 hover:bg-black/80 transition-colors z-10", "aria-label": "\u5173\u95ED\u9884\u89C8", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { size: 20 }) }), images.length > 1 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
toPrev();
|
|
107
|
+
}, className: "absolute left-4 top-1/2 -translate-y-1/2 p-3 rounded-full bg-black/70 hover:bg-black/80 transition-colors z-10", "aria-label": "\u4E0A\u4E00\u5F20", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowLeft, { size: 20 }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
toNext();
|
|
110
|
+
}, className: "absolute right-4 top-1/2 -translate-y-1/2 p-3 rounded-full bg-black/70 hover:bg-black/80 transition-colors z-10", "aria-label": "\u4E0B\u4E00\u5F20", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowRight, { size: 20 }) })] })), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 flex items-center justify-center overflow-hidden", onClick: (e) => e.stopPropagation(), onWheel: (e) => {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
if (e.deltaY < 0) {
|
|
113
|
+
zoomIn();
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
zoomOut();
|
|
117
|
+
}
|
|
118
|
+
}, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onMouseLeave: handleMouseUp, style: { cursor: isDragging ? 'grabbing' : scale > 1 ? 'grab' : 'default' }, children: (0, jsx_runtime_1.jsx)("div", { className: "relative max-h-[85vh] max-w-[90vw]", children: (0, jsx_runtime_1.jsx)("img", { ref: imgRef, src: currentImage, alt: "", draggable: false, className: " select-none max-h-[85vh] max-w-[90vw] absolute left-1/2 top-1/2 origin-center" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "absolute bottom-6 left-1/2 -translate-x-1/2 flex items-center gap-2 bg-black/70 backdrop-blur px-3 py-2 rounded-lg", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
zoomOut();
|
|
121
|
+
}, className: "flex items-center gap-1 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": "\u7F29\u5C0F", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ZoomOut, { size: 16 }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
zoomIn();
|
|
124
|
+
}, className: "flex items-center gap-1 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": "\u653E\u5927", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ZoomIn, { size: 16 }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
if (!imgRef.current)
|
|
127
|
+
return;
|
|
128
|
+
const { naturalWidth, naturalHeight, clientWidth, clientHeight } = imgRef.current;
|
|
129
|
+
if (lastScaleBeforeNatural.current === null) {
|
|
130
|
+
const scaleToNatural = Math.max(naturalWidth / Math.max(clientWidth, 1), naturalHeight / Math.max(clientHeight, 1), 1);
|
|
131
|
+
lastScaleBeforeNatural.current = scaleRef.current;
|
|
132
|
+
setScale(scaleToNatural);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
setScale(lastScaleBeforeNatural.current);
|
|
136
|
+
lastScaleBeforeNatural.current = null;
|
|
137
|
+
}
|
|
138
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": "1:1", children: "1:1" }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
139
|
+
e.stopPropagation();
|
|
140
|
+
reset();
|
|
141
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": "\u91CD\u7F6E", children: (0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCw, { size: 16 }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
rotateLeft();
|
|
144
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": "\u5DE6\u65CB\u8F6C", children: (0, jsx_runtime_1.jsx)(lucide_react_1.RotateCcw, { size: 16 }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
145
|
+
e.stopPropagation();
|
|
146
|
+
rotateRight();
|
|
147
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": "\u53F3\u65CB\u8F6C", children: (0, jsx_runtime_1.jsx)(lucide_react_1.RotateCw, { size: 16 }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
148
|
+
e.stopPropagation();
|
|
149
|
+
setFlipX((prev) => !prev);
|
|
150
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": "\u5DE6\u53F3\u955C\u50CF", children: (0, jsx_runtime_1.jsx)(lucide_react_1.FlipHorizontal, { size: 16 }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => {
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
setFlipY((prev) => !prev);
|
|
153
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": "\u4E0A\u4E0B\u955C\u50CF", children: (0, jsx_runtime_1.jsx)(lucide_react_1.FlipVertical, { size: 16 }) })] })] }));
|
|
154
|
+
return (0, react_dom_1.createPortal)(content, document.body);
|
|
155
|
+
}
|
|
156
|
+
function ImagePreviewController({ open, images, initialIndex = 0, onClose }) {
|
|
157
|
+
if (!open || images.length === 0)
|
|
158
|
+
return null;
|
|
159
|
+
const key = `${images.join('|')}-${initialIndex}`;
|
|
160
|
+
return (0, jsx_runtime_1.jsx)(PreviewCore, { images: images, initialIndex: initialIndex, onClose: onClose }, key);
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=ImagePreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImagePreview.js","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/ImagePreview/ImagePreview.tsx"],"names":[],"mappings":";;AAkUA,wDAIC;;AAtUD,+CAWqB;AACrB,iCAAyE;AACzE,yCAAwC;AAExC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAQ9F,SAAS,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAoB;IACtE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,YAAY,CAAC,CAAA;IAChD,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAA;IACtC,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAA;IAC9B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAA;IAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IACzC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,C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YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,IAAjE,GAAG,CAAkE,CAAA;AAChG,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MOmit } from '../../types';
|
|
2
|
+
import { type ImagePreviewControllerProps } from './ImagePreview';
|
|
3
|
+
export type PreviewImageProps = MOmit<ImagePreviewControllerProps, 'open' | 'onClose'> & Pick<Partial<ImagePreviewControllerProps>, 'onClose'> & {
|
|
4
|
+
thumbSize?: number | string;
|
|
5
|
+
direction?: 'horizontal' | 'vertical';
|
|
6
|
+
};
|
|
7
|
+
export declare function PreviewImage(props: PreviewImageProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=PreviewImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewImage.d.ts","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/ImagePreview/PreviewImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C,OAAO,EAA0B,KAAK,2BAA2B,EAAE,MAAM,gBAAgB,CAAA;AACzF,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,2BAA2B,EAAE,MAAM,GAAG,SAAS,CAAC,GACpF,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,EAAE,SAAS,CAAC,GAAG;IAItD,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC3B,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;CACtC,CAAA;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,kDAgDpD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreviewImage = PreviewImage;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ImagePreview_1 = require("./ImagePreview");
|
|
7
|
+
function PreviewImage(props) {
|
|
8
|
+
const { onClose, images, thumbSize = 80, direction = 'horizontal', ...ext } = props;
|
|
9
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
10
|
+
const [currentIndex, setCurrentIndex] = (0, react_1.useState)(ext.initialIndex ?? 0);
|
|
11
|
+
const sizeClass = (0, react_1.useMemo)(() => {
|
|
12
|
+
const value = typeof thumbSize === 'number' ? `${thumbSize}px` : thumbSize;
|
|
13
|
+
return `w-[${value}] h-[${value}]`;
|
|
14
|
+
}, [thumbSize]);
|
|
15
|
+
const sizeStyle = (0, react_1.useMemo)(() => {
|
|
16
|
+
const value = typeof thumbSize === 'number' ? `${thumbSize}px` : thumbSize;
|
|
17
|
+
return { width: value, height: value };
|
|
18
|
+
}, [thumbSize]);
|
|
19
|
+
if (!images?.length)
|
|
20
|
+
return null;
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `flex gap-2 ${direction === 'vertical' ? 'flex-col' : ''}`, children: images.map((src, idx) => ((0, jsx_runtime_1.jsx)("button", { type: "button", className: `relative aspect-square overflow-hidden rounded border border-border ${sizeClass}`, style: sizeStyle, onClick: () => {
|
|
22
|
+
setCurrentIndex(idx);
|
|
23
|
+
setOpen(true);
|
|
24
|
+
}, "aria-label": `预览第${idx + 1}张`, children: (0, jsx_runtime_1.jsx)("img", { src: src, alt: "", className: "h-full w-full object-cover" }) }, src + idx))) }), (0, jsx_runtime_1.jsx)(ImagePreview_1.ImagePreviewController, { ...ext, images: images, initialIndex: currentIndex, open: open, onClose: () => {
|
|
25
|
+
setOpen(false);
|
|
26
|
+
onClose?.();
|
|
27
|
+
} })] }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=PreviewImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewImage.js","sourceRoot":"","sources":["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,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CACxB,mCAEE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,uEAAuE,SAAS,EAAE,EAC7F,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,GAAG,EAAE;wBACZ,eAAe,CAAC,GAAG,CAAC,CAAA;wBACpB,OAAO,CAAC,IAAI,CAAC,CAAA;oBACf,CAAC,gBACW,MAAM,GAAG,GAAG,CAAC,GAAG,YAE5B,gCAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAC,EAAE,EAAC,SAAS,EAAC,4BAA4B,GAAG,IAV1D,GAAG,GAAG,GAAG,CAWP,CACV,CAAC,GACE,EAEN,uBAAC,qCAAsB,OACjB,GAAG,EACP,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,CAAC,KAAK,CAAC,CAAA;oBACd,OAAO,EAAE,EAAE,CAAA;gBACb,CAAC,GACD,IACD,CACJ,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/ImagePreview/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ImagePreview"), exports);
|
|
18
|
+
__exportStar(require("./PreviewImage"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/ImagePreview/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,iDAA8B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ChangeEvent, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'defaultValue'> & {
|
|
3
|
+
value?: string;
|
|
4
|
+
onChange?: (v: string, e: ChangeEvent<HTMLInputElement>) => void;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
allowClear?: boolean | {
|
|
7
|
+
clearIcon: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
addonAfter?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
declare const Input: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "defaultValue" | "onChange" | "value"> & {
|
|
12
|
+
value?: string;
|
|
13
|
+
onChange?: (v: string, e: ChangeEvent<HTMLInputElement>) => void;
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
allowClear?: boolean | {
|
|
16
|
+
clearIcon: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
addonAfter?: ReactNode;
|
|
19
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
20
|
+
export { Input };
|
|
21
|
+
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Input/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAc,SAAS,EAAE,MAAM,OAAO,CAAA;AAIpF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC,GAAG;IAC5G,KAAK,CAAC,EAAE,MAAM,CAAA;IAMd,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAKhE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,GAAG;QAAE,SAAS,EAAE,SAAS,CAAA;KAAE,CAAA;IAE/C,UAAU,CAAC,EAAE,SAAS,CAAA;CACvB,CAAA;AAED,QAAA,MAAM,KAAK;YAjBD,MAAM;eAMH,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI;mBAKjD,MAAM;iBACR,OAAO,GAAG;QAAE,SAAS,EAAE,SAAS,CAAA;KAAE;iBAElC,SAAS;oDAkIvB,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Input = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const utils_1 = require("../../lib/utils");
|
|
6
|
+
const lucide_react_1 = require("lucide-react");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const useInputController_1 = require("../hooks/useInputController");
|
|
9
|
+
const Input = (0, react_1.forwardRef)(({ className, type, value: controlledValue, onChange, defaultValue, allowClear, disabled, addonAfter, ...props }, ref) => {
|
|
10
|
+
const { setInternalValue, setIsFocused, setRefs, controllerRef, isControlledRef, isFocused, value, hasValue, } = (0, useInputController_1.useInputController)({
|
|
11
|
+
defaultValue,
|
|
12
|
+
controlledValue,
|
|
13
|
+
ref,
|
|
14
|
+
});
|
|
15
|
+
const handleChange = (0, react_1.useCallback)((e) => {
|
|
16
|
+
const newValue = e.target.value;
|
|
17
|
+
if (!isControlledRef.current) {
|
|
18
|
+
setInternalValue(newValue);
|
|
19
|
+
}
|
|
20
|
+
onChange?.(newValue, e);
|
|
21
|
+
}, [isControlledRef, onChange, setInternalValue]);
|
|
22
|
+
const handleClear = (0, react_1.useCallback)((e) => {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
if (!isControlledRef.current) {
|
|
26
|
+
setInternalValue('');
|
|
27
|
+
}
|
|
28
|
+
const syntheticEvent = {
|
|
29
|
+
target: { value: '' },
|
|
30
|
+
currentTarget: { value: '' },
|
|
31
|
+
};
|
|
32
|
+
onChange?.('', syntheticEvent);
|
|
33
|
+
controllerRef.current?.focus();
|
|
34
|
+
}, [controllerRef, isControlledRef, onChange, setInternalValue]);
|
|
35
|
+
const clearIcon = (0, react_1.useMemo)(() => {
|
|
36
|
+
if (allowClear) {
|
|
37
|
+
if (typeof allowClear === 'boolean') {
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)('w-5 h-5 rounded-full', 'bg-muted hover:bg-muted/80', 'text-foreground', 'transition-colors', 'flex items-center justify-center', 'focus:outline-none'), children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { size: 12 }) }));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return allowClear.clearIcon;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}, [allowClear]);
|
|
46
|
+
const showClearIcon = hasValue && clearIcon && !disabled;
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative w-full", children: [(0, jsx_runtime_1.jsx)("input", { type: type, ref: setRefs, value: value, onChange: handleChange, className: (0, utils_1.cn)('flex w-full rounded-lg px-4 py-3 text-sm', 'border transition-colors duration-200', 'placeholder:text-muted-foreground', 'focus:outline-none', showClearIcon && 'pr-10', addonAfter && 'pr-12', disabled ? 'cursor-not-allowed bg-muted border-border text-muted-foreground' : 'bg-background', !disabled && !hasValue && !isFocused && 'border-border', !disabled && (hasValue || isFocused) && 'border-theme', className), onFocus: (e) => {
|
|
48
|
+
if (!disabled) {
|
|
49
|
+
setIsFocused(true);
|
|
50
|
+
props.onFocus?.(e);
|
|
51
|
+
}
|
|
52
|
+
}, onBlur: (e) => {
|
|
53
|
+
if (!disabled) {
|
|
54
|
+
setIsFocused(false);
|
|
55
|
+
props.onBlur?.(e);
|
|
56
|
+
}
|
|
57
|
+
}, disabled: disabled, ...props }), showClearIcon && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClear, className: (0, utils_1.cn)('absolute right-3 top-1/2 -translate-y-1/2'), children: clearIcon })), addonAfter && (0, jsx_runtime_1.jsx)("div", { className: "absolute right-2 top-1/2 -translate-y-1/2", children: addonAfter })] }));
|
|
58
|
+
});
|
|
59
|
+
exports.Input = Input;
|
|
60
|
+
Input.displayName = 'Input';
|
|
61
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Input/Input.tsx"],"names":[],"mappings":";;;;AAAA,kDAA2C;AAC3C,+CAAgC;AAEhC,iCAAwD;AACxD,oEAAgE;AAoBhE,MAAM,KAAK,GAAG,IAAA,kBAAU,EACtB,CACE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,U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AAE,EAAE;oBACZ,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,YAAY,CAAC,KAAK,CAAC,CAAA;wBACnB,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;oBACnB,CAAC;gBACH,CAAC,EACD,QAAQ,EAAE,QAAQ,KACd,KAAK,GACT,EACD,aAAa,IAAI,CAChB,mCAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAA,UAAE,EAAC,2CAA2C,CAAC,YACnG,SAAS,GACH,CACV,EACA,UAAU,IAAI,gCAAK,SAAS,EAAC,2CAA2C,YAAE,UAAU,GAAO,IACxF,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAGQ,sBAAK;AAFd,KAAK,CAAC,WAAW,GAAG,OAAO,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Input/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Input"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Input/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
type VerticalLayout = {
|
|
3
|
+
layout?: 'vertical';
|
|
4
|
+
};
|
|
5
|
+
type HorizontalLayout = {
|
|
6
|
+
layout?: 'horizontal';
|
|
7
|
+
labelWidth?: string | number;
|
|
8
|
+
labelAlign?: 'left' | 'right' | 'center';
|
|
9
|
+
};
|
|
10
|
+
export type LabelLayout = HorizontalLayout | VerticalLayout;
|
|
11
|
+
export type LabelProps = {
|
|
12
|
+
label: ReactNode;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
htmlFor?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
labelClassName?: string;
|
|
18
|
+
contentClassName?: string;
|
|
19
|
+
} & LabelLayout;
|
|
20
|
+
declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export { Label };
|
|
22
|
+
//# sourceMappingURL=Label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label.d.ts","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Label/Label.tsx"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAS3D,KAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,CAAA;AACD,KAAK,gBAAgB,GAAG;IACtB,MAAM,CAAC,EAAE,YAAY,CAAA;IAKrB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAK5B,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,cAAc,CAAA;AAE3D,MAAM,MAAM,UAAU,GAAG;IAIvB,KAAK,EAAE,SAAS,CAAA;IAIhB,QAAQ,EAAE,SAAS,CAAA;IAKnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAIlB,OAAO,CAAC,EAAE,MAAM,CAAA;IAIhB,SAAS,CAAC,EAAE,MAAM,CAAA;IAIlB,cAAc,CAAC,EAAE,MAAM,CAAA;IAIvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,GAAG,WAAW,CAAA;AAEf,QAAA,MAAM,KAAK,uGAwDT,CAAA;AAIF,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Label = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const utils_1 = require("../../lib/utils");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const labelAlignStyles = {
|
|
8
|
+
left: 'text-left',
|
|
9
|
+
right: 'text-right',
|
|
10
|
+
center: 'text-center',
|
|
11
|
+
};
|
|
12
|
+
const Label = (0, react_1.forwardRef)((props, ref) => {
|
|
13
|
+
const { label, children, layout = 'vertical', required = false, htmlFor, className, labelClassName, contentClassName, } = props;
|
|
14
|
+
const isVertical = layout === 'vertical';
|
|
15
|
+
const labelStyles = (0, utils_1.cn)('text-sm font-medium text-foreground', required && "before:content-['*'] before:pt-1 before:mr-0.5 before:text-destructive", labelClassName);
|
|
16
|
+
const { usedClassName, labelWidth } = (0, react_1.useMemo)(() => {
|
|
17
|
+
let usedLabelWidth;
|
|
18
|
+
let usedClassName;
|
|
19
|
+
if (props.layout === 'horizontal') {
|
|
20
|
+
const labelWidth = props.labelWidth;
|
|
21
|
+
usedLabelWidth =
|
|
22
|
+
typeof labelWidth === 'number' ? `${labelWidth}px` : labelWidth === 'auto' ? 'auto' : labelWidth ?? 'auto';
|
|
23
|
+
usedClassName = labelAlignStyles[props.labelAlign ?? 'left'];
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
usedClassName,
|
|
27
|
+
labelWidth: usedLabelWidth,
|
|
28
|
+
};
|
|
29
|
+
}, [props]);
|
|
30
|
+
if (isVertical) {
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, utils_1.cn)('flex flex-col gap-2', className), children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: htmlFor, className: labelStyles, children: label }), (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)('w-full', contentClassName), children: children })] }));
|
|
32
|
+
}
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, utils_1.cn)('flex items-center gap-4', className), children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: htmlFor, className: (0, utils_1.cn)(labelStyles, usedClassName), style: { width: labelWidth, flexShrink: 0 }, children: label }), (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)('flex-1', contentClassName), children: children })] }));
|
|
34
|
+
});
|
|
35
|
+
exports.Label = Label;
|
|
36
|
+
Label.displayName = 'Label';
|
|
37
|
+
//# sourceMappingURL=Label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Label/Label.tsx"],"names":[],"mappings":";;;;AAAA,kDAA2C;AAC3C,iCAA2D;AAG3D,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,aAAa;CACtB,CAAA;AAqDD,MAAM,KAAK,GAAG,IAAA,kBAAU,EAA6B,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;I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;IAED,OAAO,CACL,iCAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAA,UAAE,EAAC,yBAAyB,EAAE,SAAS,CAAC,aAChE,kCAAO,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAA,UAAE,EAAC,WAAW,EAAE,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,YAC5G,KAAK,GACA,EACR,gCAAK,SAAS,EAAE,IAAA,UAAE,EAAC,QAAQ,EAAE,gBAAgB,CAAC,YAAG,QAAQ,GAAO,IAC5D,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAIO,sBAAK;AAFd,KAAK,CAAC,WAAW,GAAG,OAAO,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Label/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.default = void 0;
|
|
18
|
+
__exportStar(require("./Label"), exports);
|
|
19
|
+
var Label_1 = require("./Label");
|
|
20
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return Label_1.Label; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Label/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,iCAA0C;AAAjC,gGAAA,KAAK,OAAW"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type MessageType = 'success' | 'error' | 'warning' | 'info';
|
|
3
|
+
export type MessageProps = {
|
|
4
|
+
type?: MessageType;
|
|
5
|
+
content?: ReactNode;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
duration?: number;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
closable?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function Message({ type, content, children, duration, onClose, closable, className, }: MessageProps): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
//# sourceMappingURL=Message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Message/Message.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;AAElE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAA;IAKpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IAIpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAqBD,wBAAgB,OAAO,CAAC,EACtB,IAAa,EACb,OAAO,EACP,QAAQ,EACR,QAA2B,EAC3B,OAAO,EACP,QAAe,EACf,SAAS,GACV,EAAE,YAAY,kDAyEd"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Message = Message;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const utils_1 = require("../../lib/utils");
|
|
6
|
+
const lucide_react_1 = require("lucide-react");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const data_1 = require("./data");
|
|
9
|
+
const typeConfig = {
|
|
10
|
+
success: {
|
|
11
|
+
icon: lucide_react_1.CheckCircle2,
|
|
12
|
+
color: 'text-green-600',
|
|
13
|
+
},
|
|
14
|
+
error: {
|
|
15
|
+
icon: lucide_react_1.XCircle,
|
|
16
|
+
color: 'text-red-600',
|
|
17
|
+
},
|
|
18
|
+
warning: {
|
|
19
|
+
icon: lucide_react_1.AlertCircle,
|
|
20
|
+
color: 'text-yellow-600',
|
|
21
|
+
},
|
|
22
|
+
info: {
|
|
23
|
+
icon: lucide_react_1.Info,
|
|
24
|
+
color: 'text-blue-600',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
function Message({ type = 'info', content, children, duration = data_1.DEFAULT_DURATION, onClose, closable = true, className, }) {
|
|
28
|
+
const displayContent = children ?? content;
|
|
29
|
+
const [visible, setVisible] = (0, react_1.useState)(true);
|
|
30
|
+
const timerRef = (0, react_1.useRef)(null);
|
|
31
|
+
const messageRef = (0, react_1.useRef)(null);
|
|
32
|
+
const Icon = typeConfig[type].icon;
|
|
33
|
+
const iconColor = typeConfig[type].color;
|
|
34
|
+
const handleClose = () => {
|
|
35
|
+
setVisible(false);
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
onClose?.();
|
|
38
|
+
}, 200);
|
|
39
|
+
};
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
if (duration > 0) {
|
|
42
|
+
timerRef.current = setTimeout(() => {
|
|
43
|
+
handleClose();
|
|
44
|
+
}, duration);
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
if (timerRef.current) {
|
|
48
|
+
clearTimeout(timerRef.current);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}, [duration]);
|
|
52
|
+
if (!visible)
|
|
53
|
+
return null;
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: messageRef, className: (0, utils_1.cn)('flex items-start gap-3 px-4 py-3 rounded-lg shadow-lg', 'bg-background border border-border', 'min-w-[320px] max-w-[480px]', 'transition-all duration-200', 'pointer-events-auto', visible ? 'opacity-100 translate-y-0' : 'opacity-0 -translate-y-2', className), children: [(0, jsx_runtime_1.jsx)(Icon, { size: 20, className: (0, utils_1.cn)('flex-shrink-0 mt-0.5', iconColor) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 text-sm text-foreground", children: displayContent }), closable && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClose, "aria-label": "\u5173\u95ED", className: (0, utils_1.cn)('flex-shrink-0 p-0.5 rounded-md', 'text-muted-foreground hover:text-foreground', 'hover:bg-muted', 'transition-colors', 'focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2'), children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { size: 16 }) }))] }));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=Message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../../../../packages/ui/react/components/Message/Message.tsx"],"names":[],"mappings":";;AA4CA,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