@_tc/template-core 0.0.1-bate.9 → 0.0.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/README.md +1108 -0
- package/cjs/_virtual/_rolldown/runtime.js +1 -0
- package/cjs/app/controller/base.js +1 -21
- package/cjs/app/controller/project.js +1 -50
- package/cjs/app/controller/view.js +1 -14
- package/cjs/app/data/signKey.js +1 -4
- package/cjs/app/extend/$fetch.js +1 -0
- package/cjs/app/extend/db.js +1 -12
- package/cjs/app/extend/generateErrorMessage.js +1 -14
- package/cjs/app/extend/logger.js +1 -72
- package/cjs/app/extend/parsingParamsOnUrl.js +1 -22
- package/cjs/app/extend/render-view.js +1 -21
- package/cjs/app/middleware/api-params-verify.js +1 -63
- package/cjs/app/middleware/api-sign-verify.js +1 -28
- package/cjs/app/middleware/error-handle.js +1 -33
- package/cjs/app/middleware/project-handler.js +1 -21
- package/cjs/app/middleware.js +1 -60
- package/cjs/app/router/project.js +1 -8
- package/cjs/app/router/view.js +1 -5
- package/cjs/app/router-schema/project.js +1 -33
- package/cjs/app/service/base.js +1 -0
- package/cjs/app/service/project.js +1 -42
- package/cjs/app/type.js +1 -2
- package/cjs/app/typings.js +1 -2
- package/cjs/bundler/defaultAlias.js +1 -0
- package/cjs/bundler/dev.js +1 -68
- package/cjs/bundler/index.js +1 -18
- package/cjs/bundler/prod.js +1 -19
- package/cjs/bundler/state.js +1 -0
- package/cjs/bundler/utils.js +1 -127
- package/cjs/index.js +1 -21
- package/cjs/packages/common/LRUCache.js +1 -0
- package/cjs/packages/common/array/index.js +1 -0
- package/cjs/packages/common/cache/LRUCache.js +1 -0
- package/cjs/packages/common/cache/index.js +1 -0
- package/cjs/packages/common/guards/index.js +1 -0
- package/cjs/packages/common/http/index.js +1 -0
- package/cjs/packages/common/i18n/default.js +1 -0
- package/cjs/packages/common/i18n/en-US.js +1 -0
- package/cjs/packages/common/i18n/index.js +1 -0
- package/cjs/packages/common/i18n/locales.js +1 -0
- package/cjs/packages/common/i18n/types.js +1 -0
- package/cjs/packages/common/index.js +1 -0
- package/cjs/packages/common/log/index.js +2 -0
- package/cjs/packages/common/number/index.js +1 -0
- package/cjs/packages/common/object/filterEmpty.js +1 -0
- package/cjs/packages/common/object/filtereEmpty.js +1 -0
- package/cjs/packages/common/object/index.js +1 -0
- package/cjs/packages/common/string/index.js +1 -0
- package/cjs/packages/common/types/index.js +1 -0
- package/cjs/packages/core/env.js +1 -25
- package/cjs/packages/core/index.js +1 -116
- package/cjs/packages/core/loader/config.js +1 -45
- package/cjs/packages/core/loader/controller.js +1 -40
- package/cjs/packages/core/loader/extend.js +1 -41
- package/cjs/packages/core/loader/middleware.js +1 -38
- package/cjs/packages/core/loader/model.js +1 -132
- package/cjs/packages/core/loader/router-schema.js +1 -35
- package/cjs/packages/core/loader/router.js +1 -62
- package/cjs/packages/core/loader/service.js +1 -30
- package/cjs/packages/core/paths.js +1 -10
- package/cjs/packages/core/types.js +1 -2
- package/cjs/packages/utils/getAllFilesInFolder.js +1 -45
- package/cjs/packages/utils/getAllFnReturnValue.js +1 -6
- package/cjs/packages/utils/index.js +1 -20
- package/cjs/packages/utils/loadFile.js +1 -65
- package/cjs/packages/utils/path.js +1 -64
- package/cjs/packages/utils/runFileFn.js +1 -5
- package/esm/_virtual/_rolldown/runtime.js +20 -0
- package/esm/app/controller/base.js +26 -21
- package/esm/app/controller/project.js +52 -42
- package/esm/app/controller/view.js +23 -12
- package/esm/app/data/signKey.js +8 -1
- package/esm/app/extend/$fetch.js +15 -0
- package/esm/app/extend/db.js +5 -8
- package/esm/app/extend/generateErrorMessage.js +6 -11
- package/esm/app/extend/logger.js +25 -36
- package/esm/app/extend/parsingParamsOnUrl.js +13 -19
- package/esm/app/extend/render-view.js +18 -15
- package/esm/app/middleware/api-params-verify.js +55 -57
- package/esm/app/middleware/api-sign-verify.js +17 -22
- package/esm/app/middleware/error-handle.js +23 -30
- package/esm/app/middleware/project-handler.js +14 -18
- package/esm/app/middleware.js +17 -54
- package/esm/app/router/project.js +6 -5
- package/esm/app/router/view.js +6 -2
- package/esm/app/router-schema/project.js +14 -30
- package/esm/app/service/base.js +14 -0
- package/esm/app/service/project.js +23 -34
- package/esm/app/type.js +0 -1
- package/esm/app/typings.js +0 -1
- package/esm/bundler/defaultAlias.js +4 -0
- package/esm/bundler/dev.js +11 -28
- package/esm/bundler/index.js +17 -13
- package/esm/bundler/prod.js +13 -15
- package/esm/bundler/state.js +10 -0
- package/esm/bundler/utils.js +191 -82
- package/esm/index.js +15 -12
- package/esm/packages/common/LRUCache.js +2 -0
- package/esm/packages/common/array/index.js +27 -0
- package/esm/packages/common/cache/LRUCache.js +39 -0
- package/esm/packages/common/cache/index.js +2 -0
- package/esm/packages/common/guards/index.js +8 -0
- package/esm/packages/common/http/index.js +256 -0
- package/esm/packages/common/i18n/default.js +88 -0
- package/esm/packages/common/i18n/en-US.js +88 -0
- package/esm/packages/common/i18n/index.js +91 -0
- package/esm/packages/common/i18n/locales.js +9 -0
- package/esm/packages/common/index.js +14 -0
- package/esm/packages/common/log/index.js +93 -0
- package/esm/packages/common/number/index.js +10 -0
- package/esm/packages/common/object/filterEmpty.js +23 -0
- package/esm/packages/common/object/filtereEmpty.js +2 -0
- package/esm/packages/common/object/index.js +17 -0
- package/esm/packages/common/string/index.js +4 -0
- package/esm/packages/common/types/index.js +0 -0
- package/esm/packages/core/env.js +24 -23
- package/esm/packages/core/index.js +51 -108
- package/esm/packages/core/loader/config.js +26 -42
- package/esm/packages/core/loader/controller.js +12 -37
- package/esm/packages/core/loader/extend.js +22 -38
- package/esm/packages/core/loader/middleware.js +15 -35
- package/esm/packages/core/loader/model.js +65 -124
- package/esm/packages/core/loader/router-schema.js +18 -32
- package/esm/packages/core/loader/router.js +35 -56
- package/esm/packages/core/loader/service.js +12 -27
- package/esm/packages/core/paths.js +7 -4
- package/esm/packages/core/types.js +0 -1
- package/esm/packages/utils/getAllFilesInFolder.js +8 -7
- package/esm/packages/utils/getAllFnReturnValue.js +0 -6
- package/esm/packages/utils/index.js +5 -4
- package/esm/packages/utils/loadFile.js +33 -62
- package/esm/packages/utils/path.js +14 -25
- package/esm/packages/utils/runFileFn.js +45 -1
- package/fe/frontend/apps/dash/Dashboard.d.ts +6 -0
- package/fe/frontend/apps/dash/Dashboard.js +75 -0
- package/fe/frontend/apps/dash/dash.entry.d.ts +2 -0
- package/fe/frontend/apps/dash/dash.entry.js +80 -0
- package/fe/frontend/apps/dash/types.d.ts +17 -0
- package/fe/frontend/apps/testPage/index.d.ts +3 -0
- package/fe/frontend/apps/testPage/index.js +6 -0
- package/fe/frontend/apps/testPage/testPage.entry.d.ts +2 -0
- package/fe/frontend/apps/testPage/testPage.entry.js +6 -0
- package/fe/frontend/extended/SchemaForm/data.d.ts +13 -0
- package/fe/frontend/extended/SchemaForm/data.js +8 -0
- package/fe/frontend/src/api/baseInfo.d.ts +31 -0
- package/fe/frontend/src/api/baseInfo.js +15 -0
- package/fe/frontend/src/common/CRUD/CRUD.d.ts +3 -0
- package/fe/frontend/src/common/CRUD/CRUD.js +2 -0
- package/fe/frontend/src/common/CRUD/index.d.ts +2 -0
- package/fe/frontend/src/common/CRUD/index.js +1 -0
- package/fe/frontend/src/common/auth/index.d.ts +7 -0
- package/fe/frontend/src/common/auth/index.js +20 -0
- package/fe/frontend/src/common/fetchErrorShow.d.ts +3 -0
- package/fe/frontend/src/common/fetchErrorShow.js +8 -0
- package/fe/frontend/src/common/generateMenuData.d.ts +4 -0
- package/fe/frontend/src/common/generateMenuData.js +12 -0
- package/fe/frontend/src/common/importComponent.d.ts +5 -0
- package/fe/frontend/src/common/importComponent.js +8 -0
- package/fe/frontend/src/common/language.d.ts +2 -0
- package/fe/frontend/src/common/language.js +9 -0
- package/fe/frontend/src/common/logFn/index.d.ts +5 -0
- package/fe/frontend/src/common/logFn/index.js +9 -0
- package/fe/frontend/src/common/menu.d.ts +34 -0
- package/fe/frontend/src/common/menu.js +101 -0
- package/fe/frontend/src/common/request.d.ts +37 -0
- package/fe/frontend/src/common/request.js +217 -0
- package/fe/frontend/src/components/AsyncSelect/AsyncSelect.d.ts +8 -0
- package/fe/frontend/src/components/AsyncSelect/AsyncSelect.js +32 -0
- package/fe/frontend/src/components/AsyncSelect/index.d.ts +4 -0
- package/fe/frontend/src/components/AsyncSelect/index.js +3 -0
- package/fe/frontend/src/components/BasePage/HeaderView.d.ts +9 -0
- package/fe/frontend/src/components/BasePage/HeaderView.js +14 -0
- package/fe/frontend/src/components/Router/index.d.ts +9 -0
- package/fe/frontend/src/components/Router/index.js +11 -0
- package/fe/frontend/src/components/Router/type.d.ts +2 -0
- package/fe/frontend/src/components/Router/type.js +1 -0
- package/fe/frontend/src/defaultPages/Iframe/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/Iframe/index.js +14 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/DetailPanel.d.ts +7 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/DetailPanel.js +94 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/PopFrom.d.ts +13 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/PopFrom.js +124 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/builtIn.d.ts +44 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/builtIn.js +7 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/data.d.ts +4 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/data.js +6 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaSearch/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaSearch/index.js +63 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/index.d.ts +11 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/index.js +188 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/eventInfo.d.ts +8 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/eventInfo.js +6 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/index.js +1 -0
- package/fe/frontend/src/defaultPages/SchemaPage/hooks/useComConfig.d.ts +10 -0
- package/fe/frontend/src/defaultPages/SchemaPage/hooks/useComConfig.js +14 -0
- package/fe/frontend/src/defaultPages/SchemaPage/index.css +167 -0
- package/fe/frontend/src/defaultPages/SchemaPage/index.d.ts +4 -0
- package/fe/frontend/src/defaultPages/SchemaPage/index.js +75 -0
- package/fe/frontend/src/defaultPages/SchemaPage/schemaType.d.ts +51 -0
- package/fe/frontend/src/defaultPages/SchemaPage/schemaType.js +4 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/permissions.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/permissions.js +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/schemaConversion.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/schemaConversion.js +115 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/validator.d.ts +7 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/validator.js +36 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/SidebarSlotContainer.d.ts +10 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +38 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/index.js +16 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPageTmp.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPageTmp.js +17 -0
- package/fe/frontend/src/defaultPages/SlotPage/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SlotPage/index.js +26 -0
- package/fe/frontend/src/exportStore.d.ts +17 -0
- package/fe/frontend/src/exportStore.js +16 -0
- package/fe/frontend/src/hooks/useCurrentMenuData.d.ts +19 -0
- package/fe/frontend/src/hooks/useCurrentMenuData.js +28 -0
- package/fe/frontend/src/hooks/useRouterParams.d.ts +5 -0
- package/fe/frontend/src/hooks/useRouterParams.js +11 -0
- package/fe/frontend/src/index.d.ts +16 -0
- package/fe/frontend/src/index.js +13 -0
- package/fe/frontend/src/main.css +96 -0
- package/fe/frontend/src/main.d.ts +27 -0
- package/fe/frontend/src/main.js +72 -0
- package/fe/frontend/src/stores/apiFreezer.d.ts +93 -0
- package/fe/frontend/src/stores/apiFreezer.js +49 -0
- package/fe/frontend/src/stores/mode.d.ts +19 -0
- package/fe/frontend/src/stores/mode.js +37 -0
- package/fe/frontend/src/stores/schemaEventBus.d.ts +42 -0
- package/fe/frontend/src/stores/schemaEventBus.js +70 -0
- package/fe/frontend/src/stores/schemaStore.d.ts +47 -0
- package/fe/frontend/src/stores/schemaStore.js +26 -0
- package/fe/frontend/src/typing/scalability.d.ts +47 -0
- package/fe/frontend/src/typing/scalability.js +1 -0
- package/fe/frontend/src/typing/window.d.ts +7 -0
- package/fe/frontend/src/typing/window.js +1 -0
- package/fe/model/types/data/button.d.ts +32 -0
- package/fe/model/types/data/button.js +16 -0
- package/fe/model/types/data/component.d.ts +40 -0
- package/fe/model/types/data/component.js +11 -0
- package/fe/model/types/data/fetchInfo.d.ts +20 -0
- package/fe/model/types/data/fetchInfo.js +1 -0
- package/fe/model/types/data/schema.d.ts +98 -0
- package/fe/model/types/data/schema.js +1 -0
- package/fe/model/types/data/search.d.ts +7 -0
- package/fe/model/types/data/search.js +1 -0
- package/fe/model/types/menuType.d.ts +73 -0
- package/fe/model/types/menuType.js +1 -0
- package/fe/model/types/model.d.ts +33 -0
- package/fe/model/types/model.js +1 -0
- package/fe/packages/common/array/index.d.ts +7 -0
- package/fe/packages/common/array/index.js +40 -0
- package/fe/packages/common/cache/LRUCache.d.ts +13 -0
- package/fe/packages/common/cache/LRUCache.js +47 -0
- package/fe/packages/common/cache/index.d.ts +2 -0
- package/fe/packages/common/cache/index.js +1 -0
- package/fe/packages/common/guards/index.d.ts +9 -0
- package/fe/packages/common/guards/index.js +24 -0
- package/fe/packages/common/http/index.d.ts +90 -0
- package/fe/packages/common/http/index.js +310 -0
- package/fe/packages/common/i18n/default.d.ts +92 -0
- package/fe/packages/common/i18n/default.js +90 -0
- package/fe/packages/common/i18n/en-US.d.ts +92 -0
- package/fe/packages/common/i18n/en-US.js +90 -0
- package/fe/packages/common/i18n/index.d.ts +43 -0
- package/fe/packages/common/i18n/index.js +173 -0
- package/fe/packages/common/i18n/locales.d.ts +8 -0
- package/fe/packages/common/i18n/locales.js +10 -0
- package/fe/packages/common/i18n/types.d.ts +71 -0
- package/fe/packages/common/i18n/types.js +1 -0
- package/fe/packages/common/index.d.ts +11 -0
- package/fe/packages/common/index.js +10 -0
- package/fe/packages/common/log/index.d.ts +33 -0
- package/fe/packages/common/log/index.js +176 -0
- package/fe/packages/common/number/index.d.ts +3 -0
- package/fe/packages/common/number/index.js +10 -0
- package/fe/packages/common/object/filterEmpty.d.ts +3 -0
- package/fe/packages/common/object/filterEmpty.js +33 -0
- package/fe/packages/common/object/index.d.ts +5 -0
- package/fe/packages/common/object/index.js +25 -0
- package/fe/packages/common/string/index.d.ts +4 -0
- package/fe/packages/common/string/index.js +17 -0
- package/fe/packages/common/types/index.d.ts +4 -0
- package/fe/packages/common/types/index.js +1 -0
- package/fe/packages/ui/react/components/Button/Button.d.ts +29 -10
- package/fe/packages/ui/react/components/Button/Button.js +53 -23
- package/fe/packages/ui/react/components/Button/SumbitButton.d.ts +2 -2
- package/fe/packages/ui/react/components/Button/SumbitButton.js +3 -10
- package/fe/packages/ui/react/components/Button/index.d.ts +1 -1
- package/fe/packages/ui/react/components/Checkbox/Checkbox.d.ts +1 -1
- package/fe/packages/ui/react/components/Checkbox/Checkbox.js +5 -3
- package/fe/packages/ui/react/components/ConfirmDialog/ConfirmDialog.js +11 -0
- package/fe/packages/ui/react/components/ConfirmDialog/index.d.ts +2 -0
- package/fe/packages/ui/react/components/ConfirmDialog/index.js +1 -0
- package/fe/packages/ui/react/components/DataTable/ActionBtn.d.ts +3 -1
- package/fe/packages/ui/react/components/DataTable/ActionBtn.js +87 -4
- package/fe/packages/ui/react/components/DataTable/{data-table.d.ts → index.d.ts} +12 -4
- package/fe/packages/ui/react/components/DataTable/index.js +187 -0
- package/fe/packages/ui/react/components/Date/Calendar.js +4 -3
- package/fe/packages/ui/react/components/Date/Date.d.ts +5 -3
- package/fe/packages/ui/react/components/Date/Date.js +71 -48
- package/fe/packages/ui/react/components/Date/TimePicker.js +3 -1
- package/fe/packages/ui/react/components/Date/dropdownPositioning.d.ts +3 -0
- package/fe/packages/ui/react/components/Date/dropdownPositioning.js +12 -0
- package/fe/packages/ui/react/components/Date/locales.d.ts +1 -0
- package/fe/packages/ui/react/components/Date/locales.js +7 -38
- package/fe/packages/ui/react/components/Drawer/Drawer.d.ts +29 -0
- package/fe/packages/ui/react/components/Drawer/Drawer.js +100 -0
- package/fe/packages/ui/react/components/Drawer/index.d.ts +3 -0
- package/fe/packages/ui/react/components/Drawer/index.js +1 -0
- package/fe/packages/ui/react/components/Dropdown/Dropdown.d.ts +26 -0
- package/fe/packages/ui/react/components/Dropdown/Dropdown.js +49 -0
- package/fe/packages/ui/react/components/Dropdown/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Dropdown/index.js +1 -0
- package/fe/packages/ui/react/components/Form/Form.js +1 -1
- package/fe/packages/ui/react/components/Form/FormItem.js +1 -1
- package/fe/packages/ui/react/components/Form/SchemaForm/data.d.ts +40 -0
- package/fe/packages/ui/react/components/Form/SchemaForm/data.js +18 -0
- package/fe/packages/ui/react/components/Form/{SchemeForm → SchemaForm}/index.d.ts +15 -14
- package/fe/packages/ui/react/components/Form/SchemaForm/index.js +79 -0
- package/fe/packages/ui/react/components/Form/index.d.ts +1 -1
- package/fe/packages/ui/react/components/Form/index.js +1 -1
- package/fe/packages/ui/react/components/ImagePreview/ImagePreview.js +15 -12
- package/fe/packages/ui/react/components/ImagePreview/PreviewImage.js +5 -2
- package/fe/packages/ui/react/components/Input/Input.d.ts +5 -1
- package/fe/packages/ui/react/components/Input/Input.js +5 -4
- package/fe/packages/ui/react/components/InputNumber/InputNumber.d.ts +28 -0
- package/fe/packages/ui/react/components/InputNumber/InputNumber.js +144 -0
- package/fe/packages/ui/react/components/InputNumber/index.d.ts +2 -0
- package/fe/packages/ui/react/components/InputNumber/index.js +1 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.d.ts +30 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.js +63 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.d.ts +2 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.js +27 -0
- package/fe/packages/ui/react/components/Label/Label.js +2 -2
- package/fe/packages/ui/react/components/Menu/Menu.d.ts +18 -0
- package/fe/packages/ui/react/components/Menu/Menu.js +102 -0
- package/fe/packages/ui/react/components/Menu/MenuContext.d.ts +39 -0
- package/fe/packages/ui/react/components/Menu/MenuContext.js +97 -0
- package/fe/packages/ui/react/components/Menu/MenuItem.d.ts +3 -0
- package/fe/packages/ui/react/components/Menu/MenuItem.js +33 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.d.ts +10 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.js +169 -0
- package/fe/packages/ui/react/components/Menu/index.d.ts +9 -0
- package/fe/packages/ui/react/components/Menu/index.js +5 -0
- package/fe/packages/ui/react/components/Menu/menuTypes.d.ts +59 -0
- package/fe/packages/ui/react/components/Menu/menuTypes.js +1 -0
- package/fe/packages/ui/react/components/Menu/utils.d.ts +2 -0
- package/fe/packages/ui/react/components/Menu/utils.js +7 -0
- package/fe/packages/ui/react/components/Message/Message.js +4 -1
- package/fe/packages/ui/react/components/Modal/Modal.d.ts +3 -1
- package/fe/packages/ui/react/components/Modal/Modal.js +6 -43
- package/fe/packages/ui/react/components/Modal/ModalManager.js +4 -3
- package/fe/packages/ui/react/components/Overlay/Overlay.d.ts +23 -0
- package/fe/packages/ui/react/components/Overlay/Overlay.js +53 -0
- package/fe/packages/ui/react/components/Overlay/index.d.ts +3 -0
- package/fe/packages/ui/react/components/Overlay/index.js +1 -0
- package/fe/packages/ui/react/components/{Pagination.js → Pagination/Pagination.js} +4 -4
- package/fe/packages/ui/react/components/Pagination/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Pagination/index.js +1 -0
- package/fe/packages/ui/react/components/Popup/Popup.d.ts +26 -0
- package/fe/packages/ui/react/components/Popup/Popup.js +81 -0
- package/fe/packages/ui/react/components/Popup/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Popup/index.js +1 -0
- package/fe/packages/ui/react/components/Search/Search.d.ts +2 -2
- package/fe/packages/ui/react/components/Search/Search.js +3 -3
- package/fe/packages/ui/react/components/Select/Select.d.ts +5 -0
- package/fe/packages/ui/react/components/Select/Select.js +52 -109
- package/fe/packages/ui/react/components/Select/dropdownPositioning.d.ts +3 -0
- package/fe/packages/ui/react/components/Select/dropdownPositioning.js +13 -0
- package/fe/packages/ui/react/components/Skeleton/Skeleton.js +2 -2
- package/fe/packages/ui/react/components/Switch/Switch.js +3 -1
- package/fe/packages/ui/react/components/TableSearch/TableSearch.d.ts +5 -4
- package/fe/packages/ui/react/components/TableSearch/TableSearch.js +23 -21
- package/fe/packages/ui/react/components/TableSearch/lang.js +5 -14
- package/fe/packages/ui/react/components/{Textarea.d.ts → Textarea/Textarea.d.ts} +11 -3
- package/fe/packages/ui/react/components/Textarea/Textarea.js +37 -0
- package/fe/packages/ui/react/components/Textarea/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Textarea/index.js +1 -0
- package/fe/packages/ui/react/components/{Tooltip.d.ts → Tooltip/Tooltip.d.ts} +2 -2
- package/fe/packages/ui/react/components/Tooltip/Tooltip.js +79 -0
- package/fe/packages/ui/react/components/Tooltip/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Tooltip/index.js +1 -0
- package/fe/packages/ui/react/components/{TreeSelect.js → TreeSelect/TreeSelect.js} +9 -11
- package/fe/packages/ui/react/components/TreeSelect/index.d.ts +2 -0
- package/fe/packages/ui/react/components/TreeSelect/index.js +1 -0
- package/fe/packages/ui/react/components/Upload/ImageUpload.js +18 -6
- package/fe/packages/ui/react/components/Upload/Upload.js +2 -1
- package/fe/packages/ui/react/components/{breadcrumb.js → breadcrumb/breadcrumb.js} +15 -12
- package/fe/packages/ui/react/components/breadcrumb/index.d.ts +2 -0
- package/fe/packages/ui/react/components/breadcrumb/index.js +1 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.d.ts +49 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.js +137 -0
- package/fe/packages/ui/react/components/index.d.ts +7 -1
- package/fe/packages/ui/react/components/index.js +7 -1
- package/fe/packages/ui/react/components/table/index.d.ts +2 -0
- package/fe/packages/ui/react/components/table/index.js +1 -0
- package/fe/packages/ui/react/components/{table.d.ts → table/table.d.ts} +12 -2
- package/fe/packages/ui/react/components/table/table.js +116 -0
- package/fe/packages/ui/react/components/testPage/MenuTestPage.d.ts +2 -0
- package/fe/packages/ui/react/components/testPage/MenuTestPage.js +104 -0
- package/fe/packages/ui/react/components/testPage/index.js +300 -81
- package/fe/packages/ui/react/hooks/useExecuteOnce.d.ts +30 -0
- package/fe/packages/ui/react/hooks/useExecuteOnce.js +57 -0
- package/fe/packages/ui/react/hooks/useInit.d.ts +1 -1
- package/fe/packages/ui/react/hooks/useInit.js +1 -1
- package/fe/packages/ui/react/hooks/useLanguage.d.ts +1 -6
- package/fe/packages/ui/react/hooks/useRefState.d.ts +30 -0
- package/fe/packages/ui/react/hooks/useRefState.js +29 -0
- package/fe/packages/ui/react/hooks/useWatch.d.ts +23 -0
- package/fe/packages/ui/react/hooks/useWatch.js +87 -0
- package/fe/packages/ui/react/hooks/useWatch.test.d.ts +2 -0
- package/fe/packages/ui/react/hooks/useWatch.test.js +22 -0
- package/fe/packages/ui/react/i18n/I18nProvider.d.ts +31 -0
- package/fe/packages/ui/react/i18n/I18nProvider.js +25 -0
- package/fe/packages/ui/react/i18n/index.d.ts +4 -0
- package/fe/packages/ui/react/i18n/index.js +3 -0
- package/fe/packages/ui/react/i18n/useI18n.d.ts +13 -0
- package/fe/packages/ui/react/i18n/useI18n.js +18 -0
- package/fe/packages/ui/react/index.css +238 -0
- package/fe/packages/ui/react/index.d.ts +2 -0
- package/fe/packages/ui/react/index.js +2 -0
- package/fe/packages/ui/react/lib/createStoreHook.d.ts +9 -0
- package/fe/packages/ui/react/lib/createStoreHook.js +6 -0
- package/fe/packages/ui/react/lib/export.d.ts +2 -2
- package/fe/packages/ui/react/stores/language.d.ts +3 -12
- package/fe/packages/ui/react/stores/language.js +2 -51
- package/fe/typings/type.d.ts +5 -0
- package/fe/typings/type.js +1 -0
- package/model/index.d.ts +2 -0
- package/model/test.d.ts +2 -0
- package/model/types/data/button.d.ts +32 -0
- package/model/types/data/component.d.ts +40 -0
- package/model/types/data/fetchInfo.d.ts +20 -0
- package/model/types/data/schema.d.ts +98 -0
- package/model/types/data/search.d.ts +7 -0
- package/model/types/index.d.ts +3 -0
- package/model/types/menuType.d.ts +73 -0
- package/model/types/model.d.ts +33 -0
- package/package.json +36 -17
- package/{cjs → types}/app/controller/base.d.ts +4 -5
- package/types/app/controller/project.d.ts +22 -0
- package/{cjs → types}/app/controller/view.d.ts +1 -2
- package/types/app/extend/$fetch.d.ts +8 -0
- package/{cjs → types}/app/extend/db.d.ts +1 -1
- package/{cjs → types}/app/extend/logger.d.ts +1 -1
- package/{cjs → types}/app/extend/render-view.d.ts +1 -2
- package/{cjs → types}/app/middleware/api-params-verify.d.ts +1 -2
- package/{cjs → types}/app/middleware/api-sign-verify.d.ts +1 -2
- package/{esm/app/middleware/api-sign-verify.d.ts → types/app/middleware/error-handle.d.ts} +1 -3
- package/{cjs → types}/app/middleware/project-handler.d.ts +2 -2
- package/{cjs → types}/app/middleware.d.ts +0 -2
- package/{cjs/app/router/view.d.ts → types/app/router/project.d.ts} +1 -1
- package/types/app/router/view.d.ts +3 -0
- package/{cjs → types}/app/router-schema/project.d.ts +1 -1
- package/types/app/service/base.d.ts +9 -0
- package/types/app/service/project.d.ts +57 -0
- package/types/app/type.d.ts +5 -0
- package/{cjs → types}/app/typings.d.ts +17 -23
- package/types/bundler/defaultAlias.d.ts +3 -0
- package/types/bundler/index.d.ts +2 -0
- package/types/bundler/state.d.ts +18 -0
- package/types/bundler/utils.d.ts +9 -0
- package/types/config/config.default.d.ts +14 -0
- package/types/index.d.ts +28 -0
- package/types/packages/common/LRUCache.d.ts +1 -0
- package/types/packages/common/array/index.d.ts +6 -0
- package/types/packages/common/cache/LRUCache.d.ts +12 -0
- package/types/packages/common/cache/index.d.ts +1 -0
- package/types/packages/common/guards/index.d.ts +8 -0
- package/types/packages/common/http/index.d.ts +89 -0
- package/types/packages/common/i18n/default.d.ts +91 -0
- package/types/packages/common/i18n/en-US.d.ts +91 -0
- package/types/packages/common/i18n/index.d.ts +42 -0
- package/types/packages/common/i18n/locales.d.ts +7 -0
- package/types/packages/common/i18n/types.d.ts +70 -0
- package/types/packages/common/index.d.ts +10 -0
- package/types/packages/common/log/index.d.ts +32 -0
- package/types/packages/common/number/index.d.ts +2 -0
- package/types/packages/common/object/filterEmpty.d.ts +2 -0
- package/types/packages/common/object/filtereEmpty.d.ts +1 -0
- package/types/packages/common/object/index.d.ts +4 -0
- package/types/packages/common/string/index.d.ts +3 -0
- package/types/packages/common/types/index.d.ts +3 -0
- package/{cjs → types}/packages/core/index.d.ts +1 -1
- package/{cjs → types}/packages/core/loader/config.d.ts +1 -1
- package/{cjs → types}/packages/core/loader/controller.d.ts +2 -2
- package/{cjs → types}/packages/core/loader/middleware.d.ts +1 -1
- package/{esm → types}/packages/core/loader/model.d.ts +2 -3
- package/{cjs → types}/packages/core/loader/router-schema.d.ts +2 -2
- package/{cjs → types}/packages/core/loader/router.d.ts +1 -1
- package/{cjs → types}/packages/core/loader/service.d.ts +2 -2
- package/{cjs → types}/packages/core/types.d.ts +42 -3
- package/types/packages/utils/getAllFnReturnValue.d.ts +0 -0
- package/types/packages/utils/runFileFn.d.ts +7 -0
- package/types/typings/type.d.ts +4 -0
- package/cjs/app/controller/project.d.ts +0 -11
- package/cjs/app/middleware/error-handle.d.ts +0 -5
- package/cjs/app/router/project.d.ts +0 -4
- package/cjs/app/service/bese.d.ts +0 -10
- package/cjs/app/service/bese.js +0 -17
- package/cjs/app/service/project.d.ts +0 -27
- package/cjs/app/type.d.ts +0 -2
- package/cjs/bundler/index.d.ts +0 -1
- package/cjs/bundler/utils.d.ts +0 -7
- package/cjs/index.d.ts +0 -28
- package/cjs/packages/core/loader/model.d.ts +0 -36
- package/cjs/packages/utils/runFileFn.d.ts +0 -5
- package/cjs/typings/type.d.ts +0 -4
- package/cjs/typings/type.js +0 -2
- package/esm/app/controller/base.d.ts +0 -14
- package/esm/app/controller/project.d.ts +0 -12
- package/esm/app/controller/view.d.ts +0 -9
- package/esm/app/data/signKey.d.ts +0 -2
- package/esm/app/extend/db.d.ts +0 -3
- package/esm/app/extend/generateErrorMessage.d.ts +0 -8
- package/esm/app/extend/logger.d.ts +0 -12
- package/esm/app/extend/parsingParamsOnUrl.d.ts +0 -3
- package/esm/app/extend/render-view.d.ts +0 -5
- package/esm/app/middleware/api-params-verify.d.ts +0 -6
- package/esm/app/middleware/error-handle.d.ts +0 -6
- package/esm/app/middleware/project-handler.d.ts +0 -5
- package/esm/app/middleware.d.ts +0 -6
- package/esm/app/router/project.d.ts +0 -5
- package/esm/app/router/view.d.ts +0 -5
- package/esm/app/router-schema/project.d.ts +0 -4
- package/esm/app/service/bese.d.ts +0 -11
- package/esm/app/service/bese.js +0 -12
- package/esm/app/service/project.d.ts +0 -28
- package/esm/app/type.d.ts +0 -3
- package/esm/app/typings.d.ts +0 -50
- package/esm/bundler/dev.d.ts +0 -2
- package/esm/bundler/index.d.ts +0 -2
- package/esm/bundler/prod.d.ts +0 -2
- package/esm/bundler/utils.d.ts +0 -8
- package/esm/index.d.ts +0 -29
- package/esm/packages/core/env.d.ts +0 -16
- package/esm/packages/core/index.d.ts +0 -7
- package/esm/packages/core/loader/config.d.ts +0 -10
- package/esm/packages/core/loader/controller.d.ts +0 -18
- package/esm/packages/core/loader/extend.d.ts +0 -9
- package/esm/packages/core/loader/middleware.d.ts +0 -12
- package/esm/packages/core/loader/router-schema.d.ts +0 -19
- package/esm/packages/core/loader/router.d.ts +0 -9
- package/esm/packages/core/loader/service.d.ts +0 -18
- package/esm/packages/core/paths.d.ts +0 -12
- package/esm/packages/core/types.d.ts +0 -75
- package/esm/packages/utils/getAllFilesInFolder.d.ts +0 -10
- package/esm/packages/utils/getAllFnReturnValue.d.ts +0 -1
- package/esm/packages/utils/index.d.ts +0 -5
- package/esm/packages/utils/loadFile.d.ts +0 -21
- package/esm/packages/utils/path.d.ts +0 -25
- package/esm/packages/utils/runFileFn.d.ts +0 -6
- package/esm/typings/type.d.ts +0 -5
- package/fe/frontend/main.d.ts +0 -3
- package/fe/frontend/main.js +0 -6
- package/fe/packages/ui/react/components/ConfirmDialog.js +0 -9
- package/fe/packages/ui/react/components/DataTable/data-table.js +0 -141
- package/fe/packages/ui/react/components/Dropdown.d.ts +0 -16
- package/fe/packages/ui/react/components/Dropdown.js +0 -54
- package/fe/packages/ui/react/components/Form/SchemeForm/data.d.ts +0 -51
- package/fe/packages/ui/react/components/Form/SchemeForm/data.js +0 -8
- package/fe/packages/ui/react/components/Form/SchemeForm/index.js +0 -69
- package/fe/packages/ui/react/components/Textarea.js +0 -35
- package/fe/packages/ui/react/components/Tooltip.js +0 -118
- package/fe/packages/ui/react/components/table.js +0 -20
- package/fe/packages/ui/react/locales/index.d.ts +0 -8
- package/fe/packages/ui/react/locales/index.js +0 -6
- /package/{cjs/packages/utils/getAllFnReturnValue.d.ts → esm/packages/common/i18n/types.js} +0 -0
- /package/{esm/typings/type.js → fe/frontend/apps/dash/types.js} +0 -0
- /package/fe/packages/ui/react/components/{ConfirmDialog.d.ts → ConfirmDialog/ConfirmDialog.d.ts} +0 -0
- /package/fe/packages/ui/react/components/{Pagination.d.ts → Pagination/Pagination.d.ts} +0 -0
- /package/fe/packages/ui/react/components/{TreeSelect.d.ts → TreeSelect/TreeSelect.d.ts} +0 -0
- /package/fe/packages/ui/react/components/{breadcrumb.d.ts → breadcrumb/breadcrumb.d.ts} +0 -0
- /package/{cjs → types}/app/data/signKey.d.ts +0 -0
- /package/{cjs → types}/app/extend/generateErrorMessage.d.ts +0 -0
- /package/{cjs → types}/app/extend/parsingParamsOnUrl.d.ts +0 -0
- /package/{cjs → types}/bundler/dev.d.ts +0 -0
- /package/{cjs → types}/bundler/prod.d.ts +0 -0
- /package/{cjs → types}/packages/core/env.d.ts +0 -0
- /package/{cjs → types}/packages/core/loader/extend.d.ts +0 -0
- /package/{cjs → types}/packages/core/paths.d.ts +0 -0
- /package/{cjs → types}/packages/utils/getAllFilesInFolder.d.ts +0 -0
- /package/{cjs → types}/packages/utils/index.d.ts +0 -0
- /package/{cjs → types}/packages/utils/loadFile.d.ts +0 -0
- /package/{cjs → types}/packages/utils/path.d.ts +0 -0
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ArrowLeft, ArrowRight, FlipHorizontal, FlipVertical, RefreshCw, RotateCcw, RotateCw, X, ZoomIn, ZoomOut, } from 'lucide-react';
|
|
3
|
+
import { useI18n } from '../../i18n';
|
|
3
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
5
|
import { createPortal } from 'react-dom';
|
|
6
|
+
import { Button } from '../Button';
|
|
5
7
|
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
6
8
|
function PreviewCore({ images, initialIndex, onClose }) {
|
|
9
|
+
const t = useI18n();
|
|
7
10
|
const [index, setIndex] = useState(initialIndex);
|
|
8
11
|
const [scale, _setScale] = useState(1);
|
|
9
12
|
const scaleRef = useRef(scale);
|
|
@@ -98,13 +101,13 @@ function PreviewCore({ images, initialIndex, onClose }) {
|
|
|
98
101
|
}, [rotation, scale, flipX, flipY, position]);
|
|
99
102
|
if (!hasImages)
|
|
100
103
|
return null;
|
|
101
|
-
const content = (_jsxs("div", { className: "fixed inset-0 z-[1100] bg-black/40 text-white", onClick: onClose, children: [_jsx("
|
|
104
|
+
const content = (_jsxs("div", { className: "tc-ui-image-preview fixed inset-0 z-[1100] bg-black/40 text-white", onClick: onClose, children: [_jsx(Button, { variant: "text", 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": t('components.imagePreview.closePreview'), children: _jsx(X, { size: 20 }) }), images.length > 1 && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
102
105
|
e.stopPropagation();
|
|
103
106
|
toPrev();
|
|
104
|
-
}, 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":
|
|
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": t('components.imagePreview.previousImage'), children: _jsx(ArrowLeft, { size: 20 }) }), _jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
105
108
|
e.stopPropagation();
|
|
106
109
|
toNext();
|
|
107
|
-
}, 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":
|
|
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": t('components.imagePreview.nextImage'), children: _jsx(ArrowRight, { size: 20 }) })] })), _jsx("div", { className: "absolute inset-0 flex items-center justify-center overflow-hidden", onClick: (e) => e.stopPropagation(), onWheel: (e) => {
|
|
108
111
|
e.preventDefault();
|
|
109
112
|
if (e.deltaY < 0) {
|
|
110
113
|
zoomIn();
|
|
@@ -112,13 +115,13 @@ function PreviewCore({ images, initialIndex, onClose }) {
|
|
|
112
115
|
else {
|
|
113
116
|
zoomOut();
|
|
114
117
|
}
|
|
115
|
-
}, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onMouseLeave: handleMouseUp, style: { cursor: isDragging ? 'grabbing' : scale > 1 ? 'grab' : 'default' }, children: _jsx("div", { className: "relative max-h-[85vh] max-w-[90vw]", children: _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" }) }) }), _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: [_jsx("
|
|
118
|
+
}, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onMouseLeave: handleMouseUp, style: { cursor: isDragging ? 'grabbing' : scale > 1 ? 'grab' : 'default' }, children: _jsx("div", { className: "relative max-h-[85vh] max-w-[90vw]", children: _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" }) }) }), _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: [_jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
116
119
|
e.stopPropagation();
|
|
117
120
|
zoomOut();
|
|
118
|
-
}, className: "flex items-center gap-1 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label":
|
|
121
|
+
}, className: "flex items-center gap-1 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": t('components.imagePreview.zoomOut'), children: _jsx(ZoomOut, { size: 16 }) }), _jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
119
122
|
e.stopPropagation();
|
|
120
123
|
zoomIn();
|
|
121
|
-
}, className: "flex items-center gap-1 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label":
|
|
124
|
+
}, className: "flex items-center gap-1 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": t('components.imagePreview.zoomIn'), children: _jsx(ZoomIn, { size: 16 }) }), _jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
122
125
|
e.stopPropagation();
|
|
123
126
|
if (!imgRef.current)
|
|
124
127
|
return;
|
|
@@ -140,22 +143,22 @@ function PreviewCore({ images, initialIndex, onClose }) {
|
|
|
140
143
|
setScale(lastScaleBeforeNatural.current);
|
|
141
144
|
lastScaleBeforeNatural.current = null;
|
|
142
145
|
}
|
|
143
|
-
}, 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" }), _jsx("
|
|
146
|
+
}, 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" }), _jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
144
147
|
e.stopPropagation();
|
|
145
148
|
reset();
|
|
146
|
-
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label":
|
|
149
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": t('components.imagePreview.reset'), children: _jsx(RefreshCw, { size: 16 }) }), _jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
147
150
|
e.stopPropagation();
|
|
148
151
|
rotateLeft();
|
|
149
|
-
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label":
|
|
152
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": t('components.imagePreview.rotateLeft'), children: _jsx(RotateCcw, { size: 16 }) }), _jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
150
153
|
e.stopPropagation();
|
|
151
154
|
rotateRight();
|
|
152
|
-
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label":
|
|
155
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": t('components.imagePreview.rotateRight'), children: _jsx(RotateCw, { size: 16 }) }), _jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
153
156
|
e.stopPropagation();
|
|
154
157
|
setFlipX((prev) => !prev);
|
|
155
|
-
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label":
|
|
158
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": t('components.imagePreview.flipHorizontal'), children: _jsx(FlipHorizontal, { size: 16 }) }), _jsx(Button, { variant: "text", type: "button", onClick: (e) => {
|
|
156
159
|
e.stopPropagation();
|
|
157
160
|
setFlipY((prev) => !prev);
|
|
158
|
-
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label":
|
|
161
|
+
}, className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-white/15 text-sm", "aria-label": t('components.imagePreview.flipVertical'), children: _jsx(FlipVertical, { size: 16 }) })] })] }));
|
|
159
162
|
return createPortal(content, document.body);
|
|
160
163
|
}
|
|
161
164
|
export function ImagePreviewController({ open, images, initialIndex = 0, onClose }) {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from '../../i18n';
|
|
2
3
|
import { useMemo, useState } from 'react';
|
|
4
|
+
import { Button } from '../Button';
|
|
3
5
|
import { ImagePreviewController } from './ImagePreview';
|
|
4
6
|
export function PreviewImage(props) {
|
|
7
|
+
const t = useI18n();
|
|
5
8
|
const { onClose, images, thumbSize = 80, direction = 'horizontal', ...ext } = props;
|
|
6
9
|
const [open, setOpen] = useState(false);
|
|
7
10
|
const [currentIndex, setCurrentIndex] = useState(ext.initialIndex ?? 0);
|
|
@@ -15,10 +18,10 @@ export function PreviewImage(props) {
|
|
|
15
18
|
}, [thumbSize]);
|
|
16
19
|
if (!images?.length)
|
|
17
20
|
return null;
|
|
18
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { className: `flex gap-2 ${direction === 'vertical' ? 'flex-col' : ''}`, children: images.map((src, idx) => (_jsx("
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: `flex gap-2 ${direction === 'vertical' ? 'flex-col' : ''}`, children: images.map((src, idx) => (_jsx(Button, { variant: "text", type: "button", className: `relative aspect-square overflow-hidden rounded border border-border ${sizeClass}`, style: sizeStyle, onClick: () => {
|
|
19
22
|
setCurrentIndex(idx);
|
|
20
23
|
setOpen(true);
|
|
21
|
-
}, "aria-label":
|
|
24
|
+
}, "aria-label": t('components.imagePreview.previewImage', { index: idx + 1 }), children: _jsx("img", { src: src, alt: "", className: "h-full w-full object-cover" }) }, src + idx))) }), _jsx(ImagePreviewController, { ...ext, images: images, initialIndex: currentIndex, open: open, onClose: () => {
|
|
22
25
|
setOpen(false);
|
|
23
26
|
onClose?.();
|
|
24
27
|
} })] }));
|
|
@@ -17,8 +17,10 @@ export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | '
|
|
|
17
17
|
};
|
|
18
18
|
/** 输入框内部右侧按钮 */
|
|
19
19
|
addonAfter?: ReactNode;
|
|
20
|
+
/** 原生 input 节点的自定义 className */
|
|
21
|
+
inputClassName?: string;
|
|
20
22
|
};
|
|
21
|
-
declare const Input: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "
|
|
23
|
+
declare const Input: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange"> & {
|
|
22
24
|
value?: string;
|
|
23
25
|
/**
|
|
24
26
|
*
|
|
@@ -36,6 +38,8 @@ declare const Input: import("react").ForwardRefExoticComponent<Omit<InputHTMLAtt
|
|
|
36
38
|
};
|
|
37
39
|
/** 输入框内部右侧按钮 */
|
|
38
40
|
addonAfter?: ReactNode;
|
|
41
|
+
/** 原生 input 节点的自定义 className */
|
|
42
|
+
inputClassName?: string;
|
|
39
43
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
40
44
|
export { Input };
|
|
41
45
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -3,21 +3,22 @@ import { cn } from '../../lib/utils';
|
|
|
3
3
|
import { X } from 'lucide-react';
|
|
4
4
|
import { forwardRef, useCallback, useMemo } from 'react';
|
|
5
5
|
import { useInputController } from '../hooks/useInputController';
|
|
6
|
-
const Input = forwardRef(({ className, type, value: controlledValue, onChange, defaultValue, allowClear, disabled, addonAfter, ...props }, ref) => {
|
|
6
|
+
const Input = forwardRef(({ className, inputClassName, type, value: controlledValue, onChange, defaultValue, allowClear, disabled, addonAfter, ...props }, ref) => {
|
|
7
7
|
const { setInternalValue, setIsFocused, setRefs, controllerRef, isControlledRef, isFocused, value, hasValue, } = useInputController({
|
|
8
8
|
defaultValue,
|
|
9
9
|
controlledValue,
|
|
10
10
|
ref,
|
|
11
11
|
});
|
|
12
|
+
const isFileInput = type === 'file';
|
|
12
13
|
// 在change恒定时 不重复生成 fn
|
|
13
14
|
// isControlledRef setInternalValue 都是不会变的值
|
|
14
15
|
const handleChange = useCallback((e) => {
|
|
15
16
|
const newValue = e.target.value;
|
|
16
|
-
if (!isControlledRef.current) {
|
|
17
|
+
if (!isFileInput && !isControlledRef.current) {
|
|
17
18
|
setInternalValue(newValue);
|
|
18
19
|
}
|
|
19
20
|
onChange?.(newValue, e);
|
|
20
|
-
}, [isControlledRef, onChange, setInternalValue]);
|
|
21
|
+
}, [isFileInput, isControlledRef, onChange, setInternalValue]);
|
|
21
22
|
const handleClear = useCallback((e) => {
|
|
22
23
|
e.preventDefault();
|
|
23
24
|
e.stopPropagation();
|
|
@@ -44,7 +45,7 @@ const Input = forwardRef(({ className, type, value: controlledValue, onChange, d
|
|
|
44
45
|
return undefined;
|
|
45
46
|
}, [allowClear]);
|
|
46
47
|
const showClearIcon = hasValue && clearIcon && !disabled;
|
|
47
|
-
return (_jsxs("div", { className:
|
|
48
|
+
return (_jsxs("div", { className: cn('tc-ui-input relative w-full', className), children: [_jsx("input", { type: type, ref: setRefs, ...(!isFileInput && { value }), onChange: handleChange, className: 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', inputClassName), onFocus: (e) => {
|
|
48
49
|
if (!disabled) {
|
|
49
50
|
setIsFocused(true);
|
|
50
51
|
props.onFocus?.(e);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ChangeEvent, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { type InputNumberConstraints } from './inputNumberUtils';
|
|
3
|
+
export type InputNumberProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'defaultValue' | 'onChange' | 'step' | 'type' | 'value'> & InputNumberConstraints & {
|
|
4
|
+
value?: number;
|
|
5
|
+
defaultValue?: number;
|
|
6
|
+
onChange?: (value: number | undefined, e: ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
allowClear?: boolean | {
|
|
8
|
+
clearIcon: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
addonAfter?: ReactNode;
|
|
11
|
+
allowStep?: boolean;
|
|
12
|
+
/** 原生 input 节点的自定义 className */
|
|
13
|
+
inputClassName?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const InputNumber: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "type" | "defaultValue" | "onChange" | "step"> & InputNumberConstraints & {
|
|
16
|
+
value?: number;
|
|
17
|
+
defaultValue?: number;
|
|
18
|
+
onChange?: (value: number | undefined, e: ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
+
allowClear?: boolean | {
|
|
20
|
+
clearIcon: ReactNode;
|
|
21
|
+
};
|
|
22
|
+
addonAfter?: ReactNode;
|
|
23
|
+
allowStep?: boolean;
|
|
24
|
+
/** 原生 input 节点的自定义 className */
|
|
25
|
+
inputClassName?: string;
|
|
26
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
27
|
+
export { InputNumber };
|
|
28
|
+
//# sourceMappingURL=InputNumber.d.ts.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
import { ChevronDown, ChevronUp, X } from 'lucide-react';
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import { formatNumber, isValidNumberInput, normalizeNumber, parseInputNumber, shouldSyncDisplayValue, stepValue, } from './inputNumberUtils';
|
|
6
|
+
const formatDisplayValue = (value, constraints) => typeof value === 'number' ? formatNumber(value, constraints) : '';
|
|
7
|
+
const getBlurValue = (rawValue) => {
|
|
8
|
+
if (rawValue === '' || rawValue === '-' || rawValue === '.' || rawValue === '-.') {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const normalizedRawValue = rawValue.endsWith('.') ? rawValue.slice(0, -1) : rawValue;
|
|
12
|
+
const parsedValue = Number(normalizedRawValue);
|
|
13
|
+
return Number.isFinite(parsedValue) ? parsedValue : undefined;
|
|
14
|
+
};
|
|
15
|
+
const InputNumber = forwardRef(({ className, inputClassName, value: controlledValue, onChange, defaultValue, allowClear, addonAfter, allowStep = false, disabled, min, max, precision, step, inputMode = 'decimal', ...props }, ref) => {
|
|
16
|
+
const constraints = useMemo(() => ({
|
|
17
|
+
min,
|
|
18
|
+
max,
|
|
19
|
+
precision,
|
|
20
|
+
step,
|
|
21
|
+
}), [max, min, precision, step]);
|
|
22
|
+
const isControlled = controlledValue !== undefined;
|
|
23
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
24
|
+
const currentValue = isControlled ? controlledValue : internalValue;
|
|
25
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
26
|
+
const [displayValue, setDisplayValue] = useState(() => formatDisplayValue(currentValue, constraints));
|
|
27
|
+
const inputRef = useRef(null);
|
|
28
|
+
const setRefs = useCallback((node) => {
|
|
29
|
+
inputRef.current = node;
|
|
30
|
+
if (typeof ref === 'function') {
|
|
31
|
+
ref(node);
|
|
32
|
+
}
|
|
33
|
+
else if (ref) {
|
|
34
|
+
ref.current = node;
|
|
35
|
+
}
|
|
36
|
+
}, [ref]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!shouldSyncDisplayValue({ isFocused, displayValue, currentValue })) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const nextDisplayValue = formatDisplayValue(currentValue, constraints);
|
|
42
|
+
if (nextDisplayValue !== displayValue) {
|
|
43
|
+
setDisplayValue(nextDisplayValue);
|
|
44
|
+
}
|
|
45
|
+
}, [constraints, currentValue, displayValue, isFocused]);
|
|
46
|
+
const emitChange = useCallback((nextValue, e, forceNotify = false) => {
|
|
47
|
+
if (!isControlled) {
|
|
48
|
+
setInternalValue(nextValue);
|
|
49
|
+
}
|
|
50
|
+
if (forceNotify || !Object.is(currentValue, nextValue)) {
|
|
51
|
+
onChange?.(nextValue, e);
|
|
52
|
+
}
|
|
53
|
+
}, [currentValue, isControlled, onChange]);
|
|
54
|
+
const createSyntheticChangeEvent = useCallback((value) => {
|
|
55
|
+
const target = inputRef.current;
|
|
56
|
+
if (target) {
|
|
57
|
+
target.value = value;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
target: { value },
|
|
61
|
+
currentTarget: { value },
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
64
|
+
const handleChange = useCallback((e) => {
|
|
65
|
+
const nextDisplayValue = e.target.value;
|
|
66
|
+
if (!isValidNumberInput(nextDisplayValue)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setDisplayValue(nextDisplayValue);
|
|
70
|
+
const parsedValue = parseInputNumber(nextDisplayValue);
|
|
71
|
+
if (parsedValue.kind === 'empty') {
|
|
72
|
+
emitChange(undefined, e);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (parsedValue.kind === 'number') {
|
|
76
|
+
emitChange(parsedValue.value, e);
|
|
77
|
+
}
|
|
78
|
+
}, [emitChange]);
|
|
79
|
+
const handleBlur = useCallback((e) => {
|
|
80
|
+
setIsFocused(false);
|
|
81
|
+
const nextValue = getBlurValue(displayValue);
|
|
82
|
+
if (nextValue === undefined) {
|
|
83
|
+
const syntheticEvent = createSyntheticChangeEvent('');
|
|
84
|
+
setDisplayValue('');
|
|
85
|
+
emitChange(undefined, syntheticEvent);
|
|
86
|
+
props.onBlur?.(e);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const normalizedValue = normalizeNumber(nextValue, constraints);
|
|
90
|
+
const nextDisplayValue = formatDisplayValue(normalizedValue, constraints);
|
|
91
|
+
const syntheticEvent = createSyntheticChangeEvent(nextDisplayValue);
|
|
92
|
+
setDisplayValue(nextDisplayValue);
|
|
93
|
+
emitChange(normalizedValue, syntheticEvent);
|
|
94
|
+
props.onBlur?.(e);
|
|
95
|
+
}, [constraints, createSyntheticChangeEvent, displayValue, emitChange, props]);
|
|
96
|
+
const handleFocus = useCallback((e) => {
|
|
97
|
+
if (disabled) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
setIsFocused(true);
|
|
101
|
+
props.onFocus?.(e);
|
|
102
|
+
}, [disabled, props]);
|
|
103
|
+
const clearIcon = useMemo(() => {
|
|
104
|
+
if (!allowClear) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
if (typeof allowClear === 'boolean') {
|
|
108
|
+
return (_jsx("span", { className: cn('h-5 w-5 rounded-full', 'bg-muted text-foreground', 'flex items-center justify-center', 'transition-colors hover:bg-muted/80'), children: _jsx(X, { size: 12 }) }));
|
|
109
|
+
}
|
|
110
|
+
return allowClear.clearIcon;
|
|
111
|
+
}, [allowClear]);
|
|
112
|
+
const hasValue = displayValue.length > 0;
|
|
113
|
+
const showClearIcon = hasValue && clearIcon && !disabled;
|
|
114
|
+
const hasRightAccessories = showClearIcon || addonAfter || allowStep;
|
|
115
|
+
const currentParsedValue = parseInputNumber(displayValue);
|
|
116
|
+
const stepBaseValue = currentParsedValue.kind === 'number' ? currentParsedValue.value : currentValue;
|
|
117
|
+
const normalizedCurrentStepValue = typeof stepBaseValue === 'number' ? normalizeNumber(stepBaseValue, constraints) : undefined;
|
|
118
|
+
const canStep = useCallback((direction) => {
|
|
119
|
+
if (disabled) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const nextValue = stepValue(stepBaseValue, direction, constraints);
|
|
123
|
+
return !Object.is(nextValue, normalizedCurrentStepValue);
|
|
124
|
+
}, [constraints, disabled, normalizedCurrentStepValue, stepBaseValue]);
|
|
125
|
+
const handleStep = useCallback((direction) => {
|
|
126
|
+
const nextValue = stepValue(stepBaseValue, direction, constraints);
|
|
127
|
+
const nextDisplayValue = formatDisplayValue(nextValue, constraints);
|
|
128
|
+
const syntheticEvent = createSyntheticChangeEvent(nextDisplayValue);
|
|
129
|
+
setDisplayValue(nextDisplayValue);
|
|
130
|
+
emitChange(nextValue, syntheticEvent, true);
|
|
131
|
+
inputRef.current?.focus();
|
|
132
|
+
}, [constraints, createSyntheticChangeEvent, emitChange, stepBaseValue]);
|
|
133
|
+
const handleClear = useCallback((e) => {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
e.stopPropagation();
|
|
136
|
+
const syntheticEvent = createSyntheticChangeEvent('');
|
|
137
|
+
setDisplayValue('');
|
|
138
|
+
emitChange(undefined, syntheticEvent, true);
|
|
139
|
+
inputRef.current?.focus();
|
|
140
|
+
}, [createSyntheticChangeEvent, emitChange]);
|
|
141
|
+
return (_jsxs("div", { className: cn('tc-ui-input-number relative w-full', className), children: [_jsx("input", { ref: setRefs, type: "text", value: displayValue, onChange: handleChange, inputMode: inputMode, className: 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 && !allowStep && !addonAfter && 'pr-10', hasRightAccessories && 'pr-24', allowStep && addonAfter && 'pr-28', disabled ? 'cursor-not-allowed bg-muted border-border text-muted-foreground' : 'bg-background', !disabled && !hasValue && !isFocused && 'border-border', !disabled && (hasValue || isFocused) && 'border-theme', inputClassName), onFocus: handleFocus, onBlur: handleBlur, disabled: disabled, ...props }), hasRightAccessories && (_jsxs("div", { className: "absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1", children: [showClearIcon && (_jsx("button", { type: "button", onMouseDown: (e) => e.preventDefault(), onClick: handleClear, children: clearIcon })), addonAfter && _jsx("div", { children: addonAfter }), allowStep && (_jsxs("div", { className: "flex flex-col overflow-hidden rounded-md border border-border", children: [_jsx("button", { type: "button", onMouseDown: (e) => e.preventDefault(), onClick: () => handleStep('up'), disabled: !canStep('up'), className: cn('flex h-4 w-4 items-center justify-center bg-background text-foreground transition-colors', 'border-b border-border', 'disabled:cursor-not-allowed disabled:text-muted-foreground', !disabled && canStep('up') && 'hover:bg-muted'), children: _jsx(ChevronUp, { size: 12 }) }), _jsx("button", { type: "button", onMouseDown: (e) => e.preventDefault(), onClick: () => handleStep('down'), disabled: !canStep('down'), className: cn('flex h-4 w-4 items-center justify-center bg-background text-foreground transition-colors', 'disabled:cursor-not-allowed disabled:text-muted-foreground', !disabled && canStep('down') && 'hover:bg-muted'), children: _jsx(ChevronDown, { size: 12 }) })] }))] }))] }));
|
|
142
|
+
});
|
|
143
|
+
InputNumber.displayName = 'InputNumber';
|
|
144
|
+
export { InputNumber };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InputNumber';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface InputNumberConstraints {
|
|
2
|
+
min?: number;
|
|
3
|
+
max?: number;
|
|
4
|
+
precision?: number;
|
|
5
|
+
step?: number;
|
|
6
|
+
}
|
|
7
|
+
export type ParsedInputNumber = {
|
|
8
|
+
kind: 'empty';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'incomplete';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'invalid';
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'number';
|
|
15
|
+
value: number;
|
|
16
|
+
};
|
|
17
|
+
export type StepDirection = 'up' | 'down';
|
|
18
|
+
export declare const isValidNumberInput: (value: string) => boolean;
|
|
19
|
+
export declare const clampValue: (value: number, constraints: InputNumberConstraints) => number;
|
|
20
|
+
export declare const applyPrecision: (value: number, precision?: number) => number;
|
|
21
|
+
export declare const normalizeNumber: (value: number, constraints: InputNumberConstraints) => number;
|
|
22
|
+
export declare const formatNumber: (value: number, constraints: InputNumberConstraints) => string;
|
|
23
|
+
export declare const parseInputNumber: (value: string) => ParsedInputNumber;
|
|
24
|
+
export declare const shouldSyncDisplayValue: ({ isFocused, displayValue, currentValue, }: {
|
|
25
|
+
isFocused: boolean;
|
|
26
|
+
displayValue: string;
|
|
27
|
+
currentValue: number | undefined;
|
|
28
|
+
}) => boolean;
|
|
29
|
+
export declare const stepValue: (currentValue: number | undefined, direction: StepDirection, constraints: InputNumberConstraints) => number;
|
|
30
|
+
//# sourceMappingURL=inputNumberUtils.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const isFiniteNumber = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
2
|
+
export const isValidNumberInput = (value) => /^-?\d*(\.\d*)?$/.test(value);
|
|
3
|
+
export const clampValue = (value, constraints) => {
|
|
4
|
+
let nextValue = value;
|
|
5
|
+
if (isFiniteNumber(constraints.min)) {
|
|
6
|
+
nextValue = Math.max(nextValue, constraints.min);
|
|
7
|
+
}
|
|
8
|
+
if (isFiniteNumber(constraints.max)) {
|
|
9
|
+
nextValue = Math.min(nextValue, constraints.max);
|
|
10
|
+
}
|
|
11
|
+
return nextValue;
|
|
12
|
+
};
|
|
13
|
+
export const applyPrecision = (value, precision) => {
|
|
14
|
+
if (typeof precision !== 'number' || precision < 0) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
return Number(value.toFixed(precision));
|
|
18
|
+
};
|
|
19
|
+
export const normalizeNumber = (value, constraints) => {
|
|
20
|
+
return clampValue(applyPrecision(value, constraints.precision), constraints);
|
|
21
|
+
};
|
|
22
|
+
export const formatNumber = (value, constraints) => {
|
|
23
|
+
const normalized = normalizeNumber(value, constraints);
|
|
24
|
+
if (typeof constraints.precision === 'number' && constraints.precision >= 0) {
|
|
25
|
+
return normalized.toFixed(constraints.precision);
|
|
26
|
+
}
|
|
27
|
+
return String(normalized);
|
|
28
|
+
};
|
|
29
|
+
export const parseInputNumber = (value) => {
|
|
30
|
+
if (value === '') {
|
|
31
|
+
return { kind: 'empty' };
|
|
32
|
+
}
|
|
33
|
+
if (value === '-' || value === '.' || value === '-.' || /^-?\d+\.$/.test(value)) {
|
|
34
|
+
return { kind: 'incomplete' };
|
|
35
|
+
}
|
|
36
|
+
if (!isValidNumberInput(value)) {
|
|
37
|
+
return { kind: 'invalid' };
|
|
38
|
+
}
|
|
39
|
+
const parsedValue = Number(value);
|
|
40
|
+
if (!Number.isFinite(parsedValue)) {
|
|
41
|
+
return { kind: 'invalid' };
|
|
42
|
+
}
|
|
43
|
+
return { kind: 'number', value: parsedValue };
|
|
44
|
+
};
|
|
45
|
+
export const shouldSyncDisplayValue = ({ isFocused, displayValue, currentValue, }) => {
|
|
46
|
+
if (!isFocused) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
const parsedDisplayValue = parseInputNumber(displayValue);
|
|
50
|
+
if (parsedDisplayValue.kind === 'incomplete' || parsedDisplayValue.kind === 'invalid') {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (parsedDisplayValue.kind === 'empty') {
|
|
54
|
+
return currentValue !== undefined;
|
|
55
|
+
}
|
|
56
|
+
return !Object.is(parsedDisplayValue.value, currentValue);
|
|
57
|
+
};
|
|
58
|
+
export const stepValue = (currentValue, direction, constraints) => {
|
|
59
|
+
const step = constraints.step && constraints.step > 0 ? constraints.step : 1;
|
|
60
|
+
const baseValue = isFiniteNumber(currentValue) ? currentValue : 0;
|
|
61
|
+
const delta = direction === 'up' ? step : -step;
|
|
62
|
+
return normalizeNumber(baseValue + delta, constraints);
|
|
63
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { clampValue, formatNumber, parseInputNumber, shouldSyncDisplayValue, stepValue } from './inputNumberUtils';
|
|
4
|
+
test('parseInputNumber keeps empty and transitional values unresolved', () => {
|
|
5
|
+
assert.deepEqual(parseInputNumber(''), { kind: 'empty' });
|
|
6
|
+
assert.deepEqual(parseInputNumber('-'), { kind: 'incomplete' });
|
|
7
|
+
assert.deepEqual(parseInputNumber('.'), { kind: 'incomplete' });
|
|
8
|
+
assert.deepEqual(parseInputNumber('1.'), { kind: 'incomplete' });
|
|
9
|
+
assert.deepEqual(parseInputNumber('-1.'), { kind: 'incomplete' });
|
|
10
|
+
assert.deepEqual(parseInputNumber('1.25'), { kind: 'number', value: 1.25 });
|
|
11
|
+
});
|
|
12
|
+
test('formatNumber applies precision and clamps boundaries', () => {
|
|
13
|
+
assert.equal(formatNumber(1.236, { precision: 2 }), '1.24');
|
|
14
|
+
assert.equal(formatNumber(12, { max: 10 }), '10');
|
|
15
|
+
assert.equal(clampValue(-3, { min: 0 }), 0);
|
|
16
|
+
});
|
|
17
|
+
test('stepValue respects min max precision and step', () => {
|
|
18
|
+
assert.equal(stepValue(undefined, 'up', { step: 0.25, precision: 2 }), 0.25);
|
|
19
|
+
assert.equal(stepValue(9.9, 'up', { step: 1, max: 10, precision: 1 }), 10);
|
|
20
|
+
assert.equal(stepValue(0.3, 'down', { step: 0.2, min: 0, precision: 1 }), 0.1);
|
|
21
|
+
});
|
|
22
|
+
test('shouldSyncDisplayValue preserves editable decimals while focused', () => {
|
|
23
|
+
assert.equal(shouldSyncDisplayValue({ isFocused: true, displayValue: '12.5', currentValue: 12.5 }), false);
|
|
24
|
+
assert.equal(shouldSyncDisplayValue({ isFocused: true, displayValue: '12.56', currentValue: 12.56 }), false);
|
|
25
|
+
assert.equal(shouldSyncDisplayValue({ isFocused: true, displayValue: '12.56', currentValue: 3.14 }), true);
|
|
26
|
+
assert.equal(shouldSyncDisplayValue({ isFocused: false, displayValue: '12.56', currentValue: 12.56 }), true);
|
|
27
|
+
});
|
|
@@ -27,9 +27,9 @@ const Label = forwardRef((props, ref) => {
|
|
|
27
27
|
};
|
|
28
28
|
}, [props]);
|
|
29
29
|
if (isVertical) {
|
|
30
|
-
return (_jsxs("div", { ref: ref, className: cn('flex flex-col gap-2', className), children: [_jsx("label", { htmlFor: htmlFor, className: labelStyles, children: label }), _jsx("div", { className: cn('w-full', contentClassName), children: children })] }));
|
|
30
|
+
return (_jsxs("div", { ref: ref, className: cn('tc-ui-label flex flex-col gap-2', className), children: [_jsx("label", { htmlFor: htmlFor, className: labelStyles, children: label }), _jsx("div", { className: cn('w-full', contentClassName), children: children })] }));
|
|
31
31
|
}
|
|
32
|
-
return (_jsxs("div", { ref: ref, className: cn('flex items-center gap-4', className), children: [_jsx("label", { htmlFor: htmlFor, className: cn(labelStyles, usedClassName), style: { width: labelWidth, flexShrink: 0 }, children: label }), _jsx("div", { className: cn('flex-1', contentClassName), children: children })] }));
|
|
32
|
+
return (_jsxs("div", { ref: ref, className: cn('tc-ui-label flex items-center gap-4', className), children: [_jsx("label", { htmlFor: htmlFor, className: cn(labelStyles, usedClassName), style: { width: labelWidth, flexShrink: 0 }, children: label }), _jsx("div", { className: cn('flex-1', contentClassName), children: children })] }));
|
|
33
33
|
});
|
|
34
34
|
Label.displayName = 'Label';
|
|
35
35
|
export { Label };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import { MenuItem } from "./MenuItem";
|
|
3
|
+
import { SubMenu } from "./SubMenu";
|
|
4
|
+
import type { MenuProps } from "./menuTypes";
|
|
5
|
+
export interface CollapseToggleHandle {
|
|
6
|
+
collapse: () => void;
|
|
7
|
+
expand: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface CollapseToggleProps {
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const CollapseToggle: import("react").ForwardRefExoticComponent<CollapseToggleProps & import("react").RefAttributes<CollapseToggleHandle>>;
|
|
13
|
+
export declare const Menu: FC<MenuProps> & {
|
|
14
|
+
Item: typeof MenuItem;
|
|
15
|
+
SubMenu: typeof SubMenu;
|
|
16
|
+
CollapseToggle: typeof CollapseToggle;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=Menu.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, } from "react";
|
|
4
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
5
|
+
import { CollapsedContext, useMenuStore, MenuStoreContext, createMenuContextValue, } from "./MenuContext";
|
|
6
|
+
import { MenuItem } from "./MenuItem";
|
|
7
|
+
import { SubMenu } from "./SubMenu";
|
|
8
|
+
function renderItems(items, parentKey) {
|
|
9
|
+
return items.map((item) => {
|
|
10
|
+
if (item.children && item.children.length > 0) {
|
|
11
|
+
return (_jsx(SubMenu, { eventKey: item.key, label: item.label, icon: item.icon, disabled: item.disabled, popup: item.popup, parentKey: parentKey, children: renderItems(item.children, item.key) }, item.key));
|
|
12
|
+
}
|
|
13
|
+
return (_jsx(MenuItem, { eventKey: item.key, icon: item.icon, disabled: item.disabled, danger: item.danger, onClick: item.onClick, className: item.className, style: item.style, width: item.width, minWidth: item.minWidth, maxWidth: item.maxWidth, children: item.label }, item.key));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export const CollapseToggle = forwardRef(({ className }, ref) => {
|
|
17
|
+
const collapsed = useMenuStore((s) => s.collapsed);
|
|
18
|
+
const setCollapsed = useMenuStore((s) => s.setCollapsed);
|
|
19
|
+
const onCollapse = useMenuStore((s) => s.onCollapse);
|
|
20
|
+
const propsCollapsed = useMenuStore((s) => s.propsCollapsed);
|
|
21
|
+
const shouldShowCollapseToggle = () => {
|
|
22
|
+
/**
|
|
23
|
+
* 传入 collapsed 且没有 onCollapse 时,表示折叠状态完全由外部控制。
|
|
24
|
+
* 内部控制器无法改变状态,因此不渲染。
|
|
25
|
+
*/
|
|
26
|
+
if (typeof propsCollapsed !== "undefined" &&
|
|
27
|
+
typeof onCollapse === "undefined") {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
useImperativeHandle(ref, () => ({
|
|
33
|
+
collapse: () => setCollapsed(true),
|
|
34
|
+
expand: () => setCollapsed(false),
|
|
35
|
+
}), [setCollapsed]);
|
|
36
|
+
if (!shouldShowCollapseToggle()) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return (_jsx("div", { role: "button", onClick: () => setCollapsed(!collapsed), className: cn("mx-1 mb-1 flex h-9 cursor-pointer items-center justify-center rounded-lg", "text-muted-foreground transition-all", "hover:bg-muted/60 hover:text-foreground", className), children: collapsed ? (_jsx(ChevronRight, { className: "h-4 w-4" })) : (_jsx(ChevronLeft, { className: "h-4 w-4" })) }));
|
|
40
|
+
});
|
|
41
|
+
CollapseToggle.displayName = "CollapseToggle";
|
|
42
|
+
function MenuInner({ children, items, className, mode, }) {
|
|
43
|
+
const collapsed = useMenuStore((s) => s.collapsed);
|
|
44
|
+
const collapsedWidth = useMenuStore((s) => s.collapsedWidth);
|
|
45
|
+
const content = items ? renderItems(items) : children;
|
|
46
|
+
return (_jsxs("nav", { role: "menu", className: cn("tc-ui-menu relative overflow-hidden rounded-xl bg-background shadow-sm", mode === "left" && "flex flex-col p-1", mode === "top" && "flex flex-row items-center p-[3px]", className), style: mode === "left" && collapsed ? { width: collapsedWidth } : undefined, children: [mode === "left" && _jsx(CollapseToggle, {}), _jsx(CollapsedContext.Provider, { value: mode === "left" && collapsed, children: _jsx("div", { className: cn(mode === "left" && "flex flex-col gap-1", mode === "top" && "flex flex-row items-center gap-1"), children: content }) })] }));
|
|
47
|
+
}
|
|
48
|
+
export const Menu = ({ mode = "left", expandTrigger = "click", expandMode = "accordion", selectedKey: controlledSelectedKey, defaultSelectedKey, onSelect, items, children, className, collapsed: controlledCollapsed, defaultCollapsed, onCollapse, collapsedWidth = 64, collapsedLabelTooltip = true, }) => {
|
|
49
|
+
const storeRef = useRef(null);
|
|
50
|
+
if (!storeRef.current) {
|
|
51
|
+
storeRef.current = createMenuContextValue({
|
|
52
|
+
mode,
|
|
53
|
+
expandTrigger,
|
|
54
|
+
expandMode,
|
|
55
|
+
selectedKey: controlledSelectedKey,
|
|
56
|
+
defaultSelectedKey,
|
|
57
|
+
collapsed: controlledCollapsed,
|
|
58
|
+
propsCollapsed: controlledCollapsed,
|
|
59
|
+
defaultCollapsed,
|
|
60
|
+
collapsedWidth,
|
|
61
|
+
collapsedLabelTooltip,
|
|
62
|
+
onSelect,
|
|
63
|
+
onCollapse,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const store = storeRef.current;
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
store.setState({
|
|
69
|
+
mode,
|
|
70
|
+
expandTrigger,
|
|
71
|
+
expandMode,
|
|
72
|
+
propsCollapsed: controlledCollapsed,
|
|
73
|
+
collapsedWidth,
|
|
74
|
+
collapsedLabelTooltip,
|
|
75
|
+
onSelect,
|
|
76
|
+
onCollapse,
|
|
77
|
+
});
|
|
78
|
+
}, [
|
|
79
|
+
mode,
|
|
80
|
+
expandTrigger,
|
|
81
|
+
expandMode,
|
|
82
|
+
controlledCollapsed,
|
|
83
|
+
collapsedWidth,
|
|
84
|
+
collapsedLabelTooltip,
|
|
85
|
+
onSelect,
|
|
86
|
+
onCollapse,
|
|
87
|
+
]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (controlledSelectedKey !== undefined) {
|
|
90
|
+
store.setState({ selectedKey: controlledSelectedKey });
|
|
91
|
+
}
|
|
92
|
+
}, [controlledSelectedKey]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (controlledCollapsed !== undefined) {
|
|
95
|
+
store.setState({ collapsed: controlledCollapsed });
|
|
96
|
+
}
|
|
97
|
+
}, [controlledCollapsed]);
|
|
98
|
+
return (_jsx(MenuStoreContext.Provider, { value: store, children: _jsx(MenuInner, { mode: mode, items: items, className: className, children: children }) }));
|
|
99
|
+
};
|
|
100
|
+
Menu.Item = MenuItem;
|
|
101
|
+
Menu.SubMenu = SubMenu;
|
|
102
|
+
Menu.CollapseToggle = CollapseToggle;
|