@_tc/template-core 0.0.1-bate.36 → 0.0.1-bate.38
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/cjs/app/controller/base.js +3 -3
- package/cjs/app/controller/project.js +1 -1
- package/cjs/app/controller/view.js +16 -7
- package/cjs/app/middleware/api-params-verify.js +10 -1
- package/cjs/app/middleware/error-handle.js +9 -3
- package/cjs/app/middleware/project-handler.js +1 -1
- package/cjs/app/router/view.js +3 -1
- package/cjs/app/router-schema/project.js +1 -1
- package/cjs/app/service/project.js +5 -0
- package/cjs/bundler/defaultAlias.js +5 -0
- package/cjs/bundler/dev.js +4 -3
- package/cjs/bundler/index.js +2 -1
- package/cjs/bundler/prod.js +4 -3
- package/cjs/bundler/utils.js +52 -23
- package/cjs/packages/common/LRUCache.js +4 -0
- package/cjs/packages/common/array/index.js +43 -0
- package/cjs/packages/common/cache/LRUCache.js +45 -0
- package/cjs/packages/common/cache/index.js +4 -0
- package/cjs/packages/common/guards/index.js +34 -0
- package/cjs/packages/common/i18n/default.js +95 -0
- package/cjs/packages/common/i18n/en-US.js +95 -0
- package/cjs/packages/common/i18n/index.js +178 -0
- package/cjs/packages/common/i18n/locales.js +17 -0
- package/cjs/packages/common/i18n/types.js +1 -0
- package/cjs/packages/common/index.js +65 -0
- package/cjs/packages/common/log/index.js +160 -0
- package/cjs/packages/common/number/index.js +14 -0
- package/cjs/packages/common/object/filterEmpty.js +32 -0
- package/cjs/packages/common/object/filtereEmpty.js +5 -0
- package/cjs/packages/common/object/index.js +26 -0
- package/cjs/packages/common/string/index.js +17 -0
- package/cjs/packages/common/types/index.js +1 -0
- package/cjs/packages/core/index.js +18 -13
- package/cjs/packages/core/loader/config.js +4 -2
- package/cjs/packages/core/loader/controller.js +2 -3
- package/cjs/packages/core/loader/extend.js +1 -2
- package/cjs/packages/core/loader/middleware.js +2 -3
- package/cjs/packages/core/loader/model.js +10 -6
- package/cjs/packages/core/loader/router-schema.js +4 -2
- package/cjs/packages/core/loader/router.js +24 -11
- package/cjs/packages/core/loader/service.js +2 -2
- package/cjs/packages/utils/runFileFn.js +46 -1
- package/esm/app/controller/base.js +3 -3
- package/esm/app/controller/project.js +3 -3
- package/esm/app/controller/view.js +16 -7
- package/esm/app/middleware/api-params-verify.js +10 -1
- package/esm/app/middleware/error-handle.js +9 -3
- package/esm/app/middleware/project-handler.js +1 -1
- package/esm/app/router/view.js +3 -1
- package/esm/app/router-schema/project.js +1 -1
- package/esm/app/service/project.js +5 -0
- package/esm/bundler/defaultAlias.js +4 -0
- package/esm/bundler/dev.js +4 -3
- package/esm/bundler/index.js +2 -1
- package/esm/bundler/prod.js +4 -3
- package/esm/bundler/utils.js +52 -23
- package/esm/index.js +2 -2
- package/esm/packages/common/LRUCache.js +2 -0
- package/esm/packages/common/array/index.js +37 -0
- package/esm/packages/common/cache/LRUCache.js +43 -0
- package/esm/packages/common/cache/index.js +2 -0
- package/esm/packages/common/guards/index.js +26 -0
- package/esm/packages/common/i18n/default.js +93 -0
- package/esm/packages/common/i18n/en-US.js +93 -0
- package/esm/packages/common/i18n/index.js +162 -0
- package/esm/packages/common/i18n/locales.js +11 -0
- package/esm/packages/common/i18n/types.js +0 -0
- package/esm/packages/common/index.js +13 -0
- package/esm/packages/common/log/index.js +146 -0
- package/esm/packages/common/number/index.js +11 -0
- package/esm/packages/common/object/filterEmpty.js +29 -0
- package/esm/packages/common/object/filtereEmpty.js +2 -0
- package/esm/packages/common/object/index.js +20 -0
- package/esm/packages/common/string/index.js +13 -0
- package/esm/packages/common/types/index.js +0 -0
- package/esm/packages/core/index.js +18 -14
- package/esm/packages/core/loader/config.js +4 -3
- package/esm/packages/core/loader/controller.js +2 -4
- package/esm/packages/core/loader/extend.js +1 -3
- package/esm/packages/core/loader/middleware.js +2 -4
- package/esm/packages/core/loader/model.js +10 -7
- package/esm/packages/core/loader/router-schema.js +4 -3
- package/esm/packages/core/loader/router.js +24 -12
- package/esm/packages/core/loader/service.js +2 -3
- package/esm/packages/utils/runFileFn.js +47 -1
- package/fe/frontend/dash/Dashboard.d.ts +7 -0
- package/fe/frontend/dash/Dashboard.js +73 -0
- package/fe/frontend/dash/dash.entry.d.ts +2 -0
- package/fe/frontend/dash/dash.entry.js +80 -0
- package/fe/frontend/index.d.ts +3 -0
- package/fe/frontend/index.js +1 -0
- package/fe/frontend/main.css +2 -184
- package/fe/frontend/main.d.ts +10 -3
- package/fe/frontend/main.js +15 -4
- package/fe/frontend/testPage/testPage.entry.js +1 -2
- package/fe/frontend/typing/window.d.ts +7 -0
- package/fe/frontend/typing/window.js +1 -0
- package/fe/frontend/widgets/api/baseInfo.d.ts +31 -0
- package/fe/frontend/widgets/api/baseInfo.js +15 -0
- package/fe/frontend/widgets/common/CRUD/CRUD.d.ts +70 -0
- package/fe/frontend/widgets/common/CRUD/CRUD.js +208 -0
- package/fe/frontend/widgets/common/CRUD/index.d.ts +2 -0
- package/fe/frontend/widgets/common/CRUD/index.js +1 -0
- package/fe/frontend/widgets/common/auth/index.d.ts +7 -0
- package/fe/frontend/widgets/common/auth/index.js +20 -0
- package/fe/frontend/widgets/common/generateMenuData.d.ts +4 -0
- package/fe/frontend/widgets/common/generateMenuData.js +14 -0
- package/fe/frontend/widgets/common/importComponent.d.ts +5 -0
- package/fe/frontend/widgets/common/importComponent.js +8 -0
- package/fe/frontend/widgets/common/language.d.ts +2 -0
- package/fe/frontend/widgets/common/language.js +9 -0
- package/fe/frontend/widgets/common/logFn/index.d.ts +4 -0
- package/fe/frontend/widgets/common/logFn/index.js +8 -0
- package/fe/frontend/widgets/common/menu.d.ts +34 -0
- package/fe/frontend/widgets/common/menu.js +101 -0
- package/fe/frontend/widgets/common/request.d.ts +36 -0
- package/fe/frontend/widgets/common/request.js +133 -0
- package/fe/frontend/widgets/components/BasePage/HeaderView.d.ts +9 -0
- package/fe/frontend/widgets/components/BasePage/HeaderView.js +16 -0
- package/fe/frontend/widgets/components/Router/index.d.ts +9 -0
- package/fe/frontend/widgets/components/Router/index.js +11 -0
- package/fe/frontend/widgets/components/Router/type.d.ts +2 -0
- package/fe/frontend/widgets/components/Router/type.js +1 -0
- package/fe/frontend/widgets/defaultPages/Iframe/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Iframe/index.js +14 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/DetailPanel.d.ts +7 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/DetailPanel.js +94 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.d.ts +13 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.js +124 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/data.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/data.js +6 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.js +63 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.d.ts +11 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.js +188 -0
- package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.d.ts +8 -0
- package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.js +6 -0
- package/fe/frontend/widgets/defaultPages/Schema/data/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/data/index.js +1 -0
- package/fe/frontend/widgets/defaultPages/Schema/hooks/useComConfig.d.ts +10 -0
- package/fe/frontend/widgets/defaultPages/Schema/hooks/useComConfig.js +14 -0
- package/fe/frontend/widgets/defaultPages/Schema/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/index.js +74 -0
- package/fe/frontend/widgets/defaultPages/Schema/schemaType.d.ts +50 -0
- package/fe/frontend/widgets/defaultPages/Schema/schemaType.js +4 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.d.ts +42 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.js +70 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.d.ts +47 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.js +26 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/fetchErrorShow.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/fetchErrorShow.js +8 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/permissions.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/permissions.js +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.js +115 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.d.ts +7 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.js +36 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.d.ts +10 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +38 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.js +16 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPageTmp.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPageTmp.js +17 -0
- package/fe/frontend/widgets/defaultPages/SlotPage/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/SlotPage/index.js +26 -0
- package/fe/frontend/widgets/defaultPages/Todo.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Todo.js +5 -0
- package/fe/frontend/widgets/hooks/useCurrentMenuData.d.ts +19 -0
- package/fe/frontend/widgets/hooks/useCurrentMenuData.js +28 -0
- package/fe/frontend/widgets/hooks/useRouterParams.d.ts +5 -0
- package/fe/frontend/widgets/hooks/useRouterParams.js +11 -0
- package/fe/frontend/widgets/store/mode.d.ts +19 -0
- package/fe/frontend/widgets/store/mode.js +37 -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 +61 -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/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 +10 -0
- package/fe/packages/common/index.js +9 -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 +85 -4
- package/fe/packages/ui/react/components/DataTable/{data-table.d.ts → index.d.ts} +10 -4
- package/fe/packages/ui/react/components/DataTable/{data-table.js → index.js} +58 -44
- 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 +25 -0
- package/fe/packages/ui/react/components/Dropdown/Dropdown.js +28 -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 +45 -0
- package/fe/packages/ui/react/components/Form/{SchemeForm → SchemaForm}/data.js +9 -1
- 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/table.js +20 -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 +277 -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/types/data/button.d.ts +32 -0
- package/model/types/data/component.d.ts +61 -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 +2 -0
- package/model/types/menuType.d.ts +73 -0
- package/model/types/model.d.ts +33 -0
- package/model/types/test.d.ts +2 -0
- package/package.json +20 -6
- package/types/app/controller/base.d.ts +3 -3
- package/types/app/router/view.d.ts +2 -3
- package/types/app/service/project.d.ts +29 -4
- package/types/app/type.d.ts +1 -0
- package/types/app/typings.d.ts +12 -21
- package/types/bundler/defaultAlias.d.ts +3 -0
- package/types/bundler/utils.d.ts +1 -1
- package/types/config/config.default.d.ts +14 -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/i18n/default.d.ts +86 -0
- package/types/packages/common/i18n/en-US.d.ts +86 -0
- package/types/packages/common/i18n/index.d.ts +18 -0
- package/types/packages/common/i18n/locales.d.ts +7 -0
- package/types/packages/common/i18n/types.d.ts +46 -0
- package/types/packages/common/index.d.ts +9 -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/types/packages/core/index.d.ts +1 -1
- package/types/packages/core/loader/router.d.ts +1 -1
- package/types/packages/core/types.d.ts +12 -3
- package/types/packages/utils/runFileFn.d.ts +5 -3
- package/fe/packages/ui/react/components/ConfirmDialog.js +0 -9
- 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/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/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/fe/packages/ui/react/components/{table.d.ts → table/table.d.ts} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI component library default English language resources.
|
|
3
|
+
*
|
|
4
|
+
* Only built-in component copy belongs here. Applications can override or extend it with I18nProvider.resources.
|
|
5
|
+
*/
|
|
6
|
+
export const defaultEnglishResources = {
|
|
7
|
+
common: {
|
|
8
|
+
tip: 'Prompt',
|
|
9
|
+
confirm: 'Confirm',
|
|
10
|
+
cancel: 'Cancel',
|
|
11
|
+
close: 'Close',
|
|
12
|
+
submit: 'Submit',
|
|
13
|
+
reset: 'Reset',
|
|
14
|
+
},
|
|
15
|
+
components: {
|
|
16
|
+
breadcrumb: {
|
|
17
|
+
close: 'Close',
|
|
18
|
+
},
|
|
19
|
+
confirmDialog: {
|
|
20
|
+
title: 'Prompt',
|
|
21
|
+
okText: 'Confirm',
|
|
22
|
+
cancelText: 'Cancel',
|
|
23
|
+
},
|
|
24
|
+
dataTable: {
|
|
25
|
+
noData: 'No Data',
|
|
26
|
+
},
|
|
27
|
+
date: {
|
|
28
|
+
placeholder: 'Select date',
|
|
29
|
+
placeholderDateTime: 'Select date and time',
|
|
30
|
+
placeholderRange: 'Select date range',
|
|
31
|
+
placeholderDateTimeRange: 'Select date and time range',
|
|
32
|
+
weekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
33
|
+
selectTime: 'Select time',
|
|
34
|
+
startTime: 'Start time',
|
|
35
|
+
endTime: 'End time',
|
|
36
|
+
confirm: 'Confirm',
|
|
37
|
+
monthFormat: 'MMM yyyy',
|
|
38
|
+
quickRanges: 'Quick ranges',
|
|
39
|
+
quickRangeToday: 'Today',
|
|
40
|
+
quickRangeYesterday: 'Yesterday',
|
|
41
|
+
quickRangeLast7Days: 'Last 7 days',
|
|
42
|
+
quickRangeLast30Days: 'Last 30 days',
|
|
43
|
+
quickRangeThisMonth: 'This month',
|
|
44
|
+
quickRangeLastYear: 'Last year',
|
|
45
|
+
clear: 'Clear',
|
|
46
|
+
},
|
|
47
|
+
form: {
|
|
48
|
+
submit: 'Submit',
|
|
49
|
+
cancel: 'Cancel',
|
|
50
|
+
},
|
|
51
|
+
imagePreview: {
|
|
52
|
+
closePreview: 'Close preview',
|
|
53
|
+
previousImage: 'Previous image',
|
|
54
|
+
nextImage: 'Next image',
|
|
55
|
+
zoomOut: 'Zoom out',
|
|
56
|
+
zoomIn: 'Zoom in',
|
|
57
|
+
reset: 'Reset',
|
|
58
|
+
rotateLeft: 'Rotate left',
|
|
59
|
+
rotateRight: 'Rotate right',
|
|
60
|
+
flipHorizontal: 'Flip horizontal',
|
|
61
|
+
flipVertical: 'Flip vertical',
|
|
62
|
+
previewImage: 'Preview image {index}',
|
|
63
|
+
},
|
|
64
|
+
modal: {
|
|
65
|
+
close: 'Close',
|
|
66
|
+
confirmTitle: 'Prompt',
|
|
67
|
+
okText: 'Confirm',
|
|
68
|
+
cancelText: 'Cancel',
|
|
69
|
+
},
|
|
70
|
+
message: {
|
|
71
|
+
close: 'Close',
|
|
72
|
+
},
|
|
73
|
+
select: {
|
|
74
|
+
empty: 'No options',
|
|
75
|
+
},
|
|
76
|
+
tableSearch: {
|
|
77
|
+
reset: 'Reset',
|
|
78
|
+
search: 'Search',
|
|
79
|
+
export: 'Export Excel',
|
|
80
|
+
expand: 'Expand',
|
|
81
|
+
collapse: 'Collapse',
|
|
82
|
+
exportCurrentPage: 'Current Page',
|
|
83
|
+
exportCurrentQuery: 'Current Filters',
|
|
84
|
+
},
|
|
85
|
+
upload: {
|
|
86
|
+
deleteImage: 'Delete image',
|
|
87
|
+
upload: 'Upload',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { I18nDictionary, I18nInterpolationValues, I18nMessage, I18nResources, I18nStore, I18nStoreListener, I18nTranslateOptions, I18nTranslateState } from './types';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './locales';
|
|
4
|
+
export declare const isPlainI18nDictionary: (value: I18nMessage) => value is I18nDictionary;
|
|
5
|
+
/**
|
|
6
|
+
* 深合并单个语言包。
|
|
7
|
+
* 嵌套对象递归合并,字符串、数组、数字等叶子节点直接以 patch 覆盖 base。
|
|
8
|
+
*/
|
|
9
|
+
export declare const mergeI18nDictionary: (base?: I18nDictionary, patch?: I18nDictionary) => I18nDictionary;
|
|
10
|
+
/**
|
|
11
|
+
* 合并多语言资源。
|
|
12
|
+
* 结构示例:{ 'zh-CN': { common: { ok: '确定' } }, 'en-US': { common: { ok: 'OK' } } }
|
|
13
|
+
*/
|
|
14
|
+
export declare const mergeI18nResources: (base?: I18nResources, patch?: I18nResources) => I18nResources;
|
|
15
|
+
/**
|
|
16
|
+
* 根据点分 key 从语言包中取值。
|
|
17
|
+
* 例如 common.submit 会读取 resources[language].common.submit。
|
|
18
|
+
*/
|
|
19
|
+
export declare const getI18nPathValue: (dictionary: I18nDictionary | undefined, key: string) => I18nMessage | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* 替换文案中的插值占位符。
|
|
22
|
+
* 例如 "Hello, {name}" + { name: "Tom" } => "Hello, Tom"。
|
|
23
|
+
*/
|
|
24
|
+
export declare const interpolateI18nMessage: (value: string, data?: I18nInterpolationValues) => string;
|
|
25
|
+
/**
|
|
26
|
+
* 纯翻译函数:只依赖传入的 state。
|
|
27
|
+
* 优先级:指定语言 -> 兜底语言 -> options.fallback -> 原 key。
|
|
28
|
+
*/
|
|
29
|
+
export declare const translate: <T = string>(state: I18nTranslateState, key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => T | string;
|
|
30
|
+
export declare const i18nStore: {
|
|
31
|
+
getState: () => I18nStore;
|
|
32
|
+
getInitialState: () => I18nStore;
|
|
33
|
+
setState: (partial: Partial<I18nStore> | ((state: I18nStore) => Partial<I18nStore>)) => void;
|
|
34
|
+
subscribe: (listener: I18nStoreListener) => () => void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 对外使用的 i18n 函数。
|
|
38
|
+
* 每次调用都会读取最新 state,适合在非 React 代码中直接使用。
|
|
39
|
+
*/
|
|
40
|
+
export declare const i18n: <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => string | T;
|
|
41
|
+
export declare const t: <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => string | T;
|
|
42
|
+
export declare const getLanguage: <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => string | T;
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { defaultLanguage, languageLocalKey, translations } from './locales';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './locales';
|
|
4
|
+
export const isPlainI18nDictionary = (value) => {
|
|
5
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 深合并单个语言包。
|
|
9
|
+
* 嵌套对象递归合并,字符串、数组、数字等叶子节点直接以 patch 覆盖 base。
|
|
10
|
+
*/
|
|
11
|
+
export const mergeI18nDictionary = (base = {}, patch = {}) => {
|
|
12
|
+
const next = { ...base };
|
|
13
|
+
Object.entries(patch).forEach(([key, value]) => {
|
|
14
|
+
const current = next[key];
|
|
15
|
+
if (isPlainI18nDictionary(current) && isPlainI18nDictionary(value)) {
|
|
16
|
+
next[key] = mergeI18nDictionary(current, value);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
next[key] = value;
|
|
20
|
+
});
|
|
21
|
+
return next;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 合并多语言资源。
|
|
25
|
+
* 结构示例:{ 'zh-CN': { common: { ok: '确定' } }, 'en-US': { common: { ok: 'OK' } } }
|
|
26
|
+
*/
|
|
27
|
+
export const mergeI18nResources = (base = {}, patch = {}) => {
|
|
28
|
+
const next = { ...base };
|
|
29
|
+
Object.entries(patch).forEach(([language, messages]) => {
|
|
30
|
+
if (!messages)
|
|
31
|
+
return;
|
|
32
|
+
next[language] = mergeI18nDictionary(next[language], messages);
|
|
33
|
+
});
|
|
34
|
+
return next;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 根据点分 key 从语言包中取值。
|
|
38
|
+
* 例如 common.submit 会读取 resources[language].common.submit。
|
|
39
|
+
*/
|
|
40
|
+
export const getI18nPathValue = (dictionary, key) => {
|
|
41
|
+
if (!dictionary)
|
|
42
|
+
return undefined;
|
|
43
|
+
return key.split('.').reduce((value, currentKey) => {
|
|
44
|
+
if (!isPlainI18nDictionary(value))
|
|
45
|
+
return undefined;
|
|
46
|
+
return value[currentKey];
|
|
47
|
+
}, dictionary);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 替换文案中的插值占位符。
|
|
51
|
+
* 例如 "Hello, {name}" + { name: "Tom" } => "Hello, Tom"。
|
|
52
|
+
*/
|
|
53
|
+
export const interpolateI18nMessage = (value, data) => {
|
|
54
|
+
if (!data)
|
|
55
|
+
return value;
|
|
56
|
+
return value.replace(/\{([A-Za-z0-9_]+)\}/g, (match, key) => {
|
|
57
|
+
const nextValue = data[key];
|
|
58
|
+
return typeof nextValue === 'undefined' || nextValue === null ? match : String(nextValue);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* 纯翻译函数:只依赖传入的 state。
|
|
63
|
+
* 优先级:指定语言 -> 兜底语言 -> options.fallback -> 原 key。
|
|
64
|
+
*/
|
|
65
|
+
export const translate = (state, key, fillingData, options) => {
|
|
66
|
+
const language = options?.language || state.language;
|
|
67
|
+
const fallbackLanguage = options?.fallbackLanguage || state.fallbackLanguage;
|
|
68
|
+
const value = getI18nPathValue(state.resources[language], key) ??
|
|
69
|
+
getI18nPathValue(state.resources[fallbackLanguage], key) ??
|
|
70
|
+
options?.fallback ??
|
|
71
|
+
key;
|
|
72
|
+
return (typeof value === 'string' ? interpolateI18nMessage(value, fillingData) : value);
|
|
73
|
+
};
|
|
74
|
+
const getBrowserWindow = () => {
|
|
75
|
+
return globalThis.window;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* 初始化时优先读取本地缓存语言。
|
|
79
|
+
* SSR 环境没有 window,直接回退到默认语言。
|
|
80
|
+
*/
|
|
81
|
+
const getStoredLanguage = (storageKey) => {
|
|
82
|
+
const windowRef = getBrowserWindow();
|
|
83
|
+
if (!windowRef) {
|
|
84
|
+
return defaultLanguage;
|
|
85
|
+
}
|
|
86
|
+
return windowRef.localStorage.getItem(storageKey) || defaultLanguage;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* 持久化当前语言,用于刷新页面后保持用户选择。
|
|
90
|
+
*/
|
|
91
|
+
const persistLanguage = (storageKey, language) => {
|
|
92
|
+
const windowRef = getBrowserWindow();
|
|
93
|
+
if (!windowRef)
|
|
94
|
+
return;
|
|
95
|
+
windowRef.localStorage.setItem(storageKey, language);
|
|
96
|
+
};
|
|
97
|
+
const createInitialState = () => ({
|
|
98
|
+
language: getStoredLanguage(languageLocalKey),
|
|
99
|
+
fallbackLanguage: defaultLanguage,
|
|
100
|
+
resources: translations,
|
|
101
|
+
storageKey: languageLocalKey,
|
|
102
|
+
persist: true,
|
|
103
|
+
});
|
|
104
|
+
const createI18nStore = () => {
|
|
105
|
+
let state;
|
|
106
|
+
const listeners = new Set();
|
|
107
|
+
const setState = (partial) => {
|
|
108
|
+
const previousState = state;
|
|
109
|
+
const nextPartial = typeof partial === 'function' ? partial(state) : partial;
|
|
110
|
+
state = { ...state, ...nextPartial };
|
|
111
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
112
|
+
};
|
|
113
|
+
const initialState = createInitialState();
|
|
114
|
+
state = {
|
|
115
|
+
...initialState,
|
|
116
|
+
t: (key, fillingData, options) => i18n(key, fillingData, options),
|
|
117
|
+
setLanguage: (language) => {
|
|
118
|
+
setState({ language });
|
|
119
|
+
const { persist, storageKey } = state;
|
|
120
|
+
if (persist) {
|
|
121
|
+
persistLanguage(storageKey, language);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
setFallbackLanguage: (fallbackLanguage) => {
|
|
125
|
+
setState({ fallbackLanguage });
|
|
126
|
+
},
|
|
127
|
+
setResources: (resources, options) => {
|
|
128
|
+
setState((currentState) => ({
|
|
129
|
+
resources: options?.merge ? mergeI18nResources(currentState.resources, resources) : resources,
|
|
130
|
+
}));
|
|
131
|
+
},
|
|
132
|
+
addResources: (language, messages, options) => {
|
|
133
|
+
setState((currentState) => {
|
|
134
|
+
const shouldMerge = options?.merge ?? true;
|
|
135
|
+
const currentMessages = currentState.resources[language];
|
|
136
|
+
return {
|
|
137
|
+
resources: {
|
|
138
|
+
...currentState.resources,
|
|
139
|
+
[language]: shouldMerge ? mergeI18nDictionary(currentMessages, messages) : messages,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
configureI18n: (config) => {
|
|
145
|
+
setState(config);
|
|
146
|
+
},
|
|
147
|
+
resetI18n: () => {
|
|
148
|
+
setState(createInitialState());
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
const initialStoreState = state;
|
|
152
|
+
return {
|
|
153
|
+
getState: () => state,
|
|
154
|
+
getInitialState: () => initialStoreState,
|
|
155
|
+
setState,
|
|
156
|
+
subscribe: (listener) => {
|
|
157
|
+
listeners.add(listener);
|
|
158
|
+
return () => {
|
|
159
|
+
listeners.delete(listener);
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
export const i18nStore = createI18nStore();
|
|
165
|
+
/**
|
|
166
|
+
* 对外使用的 i18n 函数。
|
|
167
|
+
* 每次调用都会读取最新 state,适合在非 React 代码中直接使用。
|
|
168
|
+
*/
|
|
169
|
+
export const i18n = (key, fillingData, options) => {
|
|
170
|
+
return translate(i18nStore.getState(), key, fillingData, options);
|
|
171
|
+
};
|
|
172
|
+
export const t = i18n;
|
|
173
|
+
export const getLanguage = i18n;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { I18nResources } from './types';
|
|
2
|
+
export declare const defaultLanguage: "zh-CN";
|
|
3
|
+
export declare const languageLocalKey = "tc_language";
|
|
4
|
+
export declare const translations: I18nResources;
|
|
5
|
+
export type Language = keyof typeof translations | (string & {});
|
|
6
|
+
export * from './default';
|
|
7
|
+
export * from './en-US';
|
|
8
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defaultLanguageResources } from './default';
|
|
2
|
+
import { defaultEnglishResources } from './en-US';
|
|
3
|
+
export const defaultLanguage = 'zh-CN';
|
|
4
|
+
export const languageLocalKey = 'tc_language';
|
|
5
|
+
export const translations = {
|
|
6
|
+
'zh-CN': defaultLanguageResources,
|
|
7
|
+
'en-US': defaultEnglishResources,
|
|
8
|
+
};
|
|
9
|
+
export * from './default';
|
|
10
|
+
export * from './en-US';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export type I18nLanguage = string;
|
|
2
|
+
export type I18nPrimitive = string | number | boolean | null | undefined;
|
|
3
|
+
export type I18nMessage = I18nPrimitive | I18nMessage[] | readonly I18nMessage[] | I18nDictionary;
|
|
4
|
+
export interface I18nDictionary {
|
|
5
|
+
[key: string]: I18nMessage;
|
|
6
|
+
}
|
|
7
|
+
export type I18nResources<Language extends I18nLanguage = I18nLanguage> = Partial<Record<Language, I18nDictionary>>;
|
|
8
|
+
export type I18nInterpolationValues = Record<string, I18nPrimitive>;
|
|
9
|
+
export interface I18nTranslateState {
|
|
10
|
+
language: I18nLanguage;
|
|
11
|
+
fallbackLanguage: I18nLanguage;
|
|
12
|
+
resources: I18nResources;
|
|
13
|
+
}
|
|
14
|
+
export interface I18nState extends I18nTranslateState {
|
|
15
|
+
/** 持久化语言时使用的 localStorage key。 */
|
|
16
|
+
storageKey: string;
|
|
17
|
+
/** 是否把 setLanguage 的结果写入 localStorage。 */
|
|
18
|
+
persist: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface I18nTranslateOptions {
|
|
21
|
+
/**
|
|
22
|
+
* 指定本次翻译使用的语言,不传则使用全局 language。
|
|
23
|
+
*/
|
|
24
|
+
language?: I18nLanguage;
|
|
25
|
+
/**
|
|
26
|
+
* 当前语言未命中时使用的兜底语言,不传则使用全局 fallbackLanguage。
|
|
27
|
+
*/
|
|
28
|
+
fallbackLanguage?: I18nLanguage;
|
|
29
|
+
/**
|
|
30
|
+
* 当前语言和兜底语言都未命中时返回的兜底值。
|
|
31
|
+
*/
|
|
32
|
+
fallback?: I18nMessage;
|
|
33
|
+
}
|
|
34
|
+
export interface I18nSetResourcesOptions {
|
|
35
|
+
/**
|
|
36
|
+
* 是否和现有资源深合并。默认 false,直接替换 resources。
|
|
37
|
+
*/
|
|
38
|
+
merge?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface I18nAddResourcesOptions {
|
|
41
|
+
/**
|
|
42
|
+
* 是否和当前语言资源深合并。默认 true。
|
|
43
|
+
*/
|
|
44
|
+
merge?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export type I18nTranslator = <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => T | string;
|
|
47
|
+
export interface I18nActions {
|
|
48
|
+
/** 设置当前展示语言。 */
|
|
49
|
+
setLanguage: (language: I18nLanguage) => void;
|
|
50
|
+
/** 设置兜底语言。 */
|
|
51
|
+
setFallbackLanguage: (language: I18nLanguage) => void;
|
|
52
|
+
/** 批量设置多语言资源,可选择替换或合并。 */
|
|
53
|
+
setResources: (resources: I18nResources, options?: I18nSetResourcesOptions) => void;
|
|
54
|
+
/** 为指定语言追加资源,默认和已有资源深合并。 */
|
|
55
|
+
addResources: (language: I18nLanguage, messages: I18nDictionary, options?: I18nAddResourcesOptions) => void;
|
|
56
|
+
/** 配置存储行为,主要由 I18nProvider 同步外部 props 使用。 */
|
|
57
|
+
configureI18n: (config: Partial<Pick<I18nState, 'storageKey' | 'persist'>>) => void;
|
|
58
|
+
/** 重置为默认语言、默认资源和默认存储配置。 */
|
|
59
|
+
resetI18n: () => void;
|
|
60
|
+
/** 挂在 store 上的翻译函数,方便直接读取。 */
|
|
61
|
+
t: I18nTranslator;
|
|
62
|
+
}
|
|
63
|
+
export type I18nStore = I18nState & I18nActions;
|
|
64
|
+
export type I18nStoreListener = (state: I18nStore, previousState: I18nStore) => void;
|
|
65
|
+
export interface I18nStoreApi {
|
|
66
|
+
getState: () => I18nStore;
|
|
67
|
+
getInitialState: () => I18nStore;
|
|
68
|
+
setState: (partial: Partial<I18nStore> | ((state: I18nStore) => Partial<I18nStore>)) => void;
|
|
69
|
+
subscribe: (listener: I18nStoreListener) => () => void;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./array";
|
|
2
|
+
export * from "./cache";
|
|
3
|
+
export * from "./guards";
|
|
4
|
+
export * from "./i18n";
|
|
5
|
+
export * from "./log";
|
|
6
|
+
export * from "./number";
|
|
7
|
+
export * from "./object";
|
|
8
|
+
export * from "./string";
|
|
9
|
+
export * from "./types";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const ANSI_RESET = "\u001B[0m";
|
|
2
|
+
export declare const ansiColors: {
|
|
3
|
+
readonly black: "\u001B[30m";
|
|
4
|
+
readonly red: "\u001B[31m";
|
|
5
|
+
readonly green: "\u001B[32m";
|
|
6
|
+
readonly yellow: "\u001B[33m";
|
|
7
|
+
readonly blue: "\u001B[34m";
|
|
8
|
+
readonly magenta: "\u001B[35m";
|
|
9
|
+
readonly pink: "\u001B[95m";
|
|
10
|
+
readonly cyan: "\u001B[36m";
|
|
11
|
+
readonly white: "\u001B[37m";
|
|
12
|
+
readonly gray: "\u001B[90m";
|
|
13
|
+
};
|
|
14
|
+
export type LogColor = keyof typeof ansiColors;
|
|
15
|
+
export type ColorLogOptions = {
|
|
16
|
+
color?: LogColor;
|
|
17
|
+
prefix?: string;
|
|
18
|
+
suffix?: string;
|
|
19
|
+
};
|
|
20
|
+
export type ColorLogAffixes = Omit<ColorLogOptions, 'color'>;
|
|
21
|
+
export declare const colorize: (message: unknown, color?: LogColor) => string;
|
|
22
|
+
export declare const joinColorized: (...messages: readonly unknown[]) => string;
|
|
23
|
+
export declare const logJoinColorized: (...messages: readonly unknown[]) => void;
|
|
24
|
+
export declare function colorLog(color: LogColor, ...data: unknown[]): void;
|
|
25
|
+
export declare function colorLog(...data: unknown[]): void;
|
|
26
|
+
export declare const logColor: (color: LogColor, ...data: unknown[]) => void;
|
|
27
|
+
export declare const logColorized: (...messages: readonly unknown[]) => void;
|
|
28
|
+
export declare const logGreen: (...data: unknown[]) => void;
|
|
29
|
+
export declare const logYellow: (...data: unknown[]) => void;
|
|
30
|
+
export declare const logPink: (...data: unknown[]) => void;
|
|
31
|
+
export declare const logWhite: (...data: unknown[]) => void;
|
|
32
|
+
export declare const logRed: (...data: unknown[]) => void;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
export const ANSI_RESET = '\x1b[0m';
|
|
2
|
+
export const ansiColors = {
|
|
3
|
+
black: '\x1b[30m',
|
|
4
|
+
red: '\x1b[31m',
|
|
5
|
+
green: '\x1b[32m',
|
|
6
|
+
yellow: '\x1b[33m',
|
|
7
|
+
blue: '\x1b[34m',
|
|
8
|
+
magenta: '\x1b[35m',
|
|
9
|
+
pink: '\x1b[95m',
|
|
10
|
+
cyan: '\x1b[36m',
|
|
11
|
+
white: '\x1b[37m',
|
|
12
|
+
gray: '\x1b[90m',
|
|
13
|
+
};
|
|
14
|
+
const getConsole = () => {
|
|
15
|
+
const globalValue = globalThis;
|
|
16
|
+
return globalValue.console;
|
|
17
|
+
};
|
|
18
|
+
export const colorize = (message, color = 'green') => {
|
|
19
|
+
return `${ansiColors[color]}${String(message)}${ANSI_RESET}`;
|
|
20
|
+
};
|
|
21
|
+
export const joinColorized = (...messages) => {
|
|
22
|
+
return messages.map(String).join('');
|
|
23
|
+
};
|
|
24
|
+
export const logJoinColorized = (...messages) => {
|
|
25
|
+
getConsole()?.log(messages.map(String).join(''));
|
|
26
|
+
};
|
|
27
|
+
const inspectPrimitive = (value) => {
|
|
28
|
+
if (typeof value === 'string')
|
|
29
|
+
return `'${value}'`;
|
|
30
|
+
if (typeof value === 'bigint')
|
|
31
|
+
return `${value}n`;
|
|
32
|
+
if (typeof value === 'symbol')
|
|
33
|
+
return String(value);
|
|
34
|
+
if (typeof value === 'function')
|
|
35
|
+
return `[Function${value.name ? `: ${value.name}` : ''}]`;
|
|
36
|
+
if (value === undefined)
|
|
37
|
+
return 'undefined';
|
|
38
|
+
if (value === null)
|
|
39
|
+
return 'null';
|
|
40
|
+
return String(value);
|
|
41
|
+
};
|
|
42
|
+
const inspectValue = (value, context, depth = 0) => {
|
|
43
|
+
if (value === null || typeof value !== 'object')
|
|
44
|
+
return inspectPrimitive(value);
|
|
45
|
+
if (context.seen.has(value))
|
|
46
|
+
return '[Circular]';
|
|
47
|
+
if (value instanceof Date)
|
|
48
|
+
return value.toISOString();
|
|
49
|
+
if (value instanceof Error)
|
|
50
|
+
return value.stack ?? `${value.name}: ${value.message}`;
|
|
51
|
+
context.seen.add(value);
|
|
52
|
+
if (Array.isArray(value)) {
|
|
53
|
+
const items = value.map((item) => inspectValue(item, context, depth + 1));
|
|
54
|
+
context.seen.delete(value);
|
|
55
|
+
return `[${items.join(', ')}]`;
|
|
56
|
+
}
|
|
57
|
+
const entries = Object.entries(value);
|
|
58
|
+
if (entries.length === 0) {
|
|
59
|
+
context.seen.delete(value);
|
|
60
|
+
return '{}';
|
|
61
|
+
}
|
|
62
|
+
const indent = ' '.repeat(depth);
|
|
63
|
+
const nextIndent = ' '.repeat(depth + 1);
|
|
64
|
+
const body = entries
|
|
65
|
+
.map(([key, item]) => `${nextIndent}${key}: ${inspectValue(item, context, depth + 1)}`)
|
|
66
|
+
.join(',\n');
|
|
67
|
+
context.seen.delete(value);
|
|
68
|
+
return `{\n${body}\n${indent}}`;
|
|
69
|
+
};
|
|
70
|
+
const stringifyLogValue = (value) => {
|
|
71
|
+
return typeof value === 'string' ? value : inspectValue(value, { seen: new WeakSet() });
|
|
72
|
+
};
|
|
73
|
+
const formatSpecifier = (specifier, value) => {
|
|
74
|
+
if (specifier === '%%')
|
|
75
|
+
return '%';
|
|
76
|
+
if (specifier === '%s')
|
|
77
|
+
return String(value);
|
|
78
|
+
if (specifier === '%d' || specifier === '%i')
|
|
79
|
+
return Number.parseInt(String(value), 10).toString();
|
|
80
|
+
if (specifier === '%f')
|
|
81
|
+
return Number.parseFloat(String(value)).toString();
|
|
82
|
+
if (specifier === '%j') {
|
|
83
|
+
try {
|
|
84
|
+
return JSON.stringify(value);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return '[Circular]';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (specifier === '%o' || specifier === '%O')
|
|
91
|
+
return stringifyLogValue(value);
|
|
92
|
+
if (specifier === '%c')
|
|
93
|
+
return '';
|
|
94
|
+
return specifier;
|
|
95
|
+
};
|
|
96
|
+
const formatLogData = (data) => {
|
|
97
|
+
if (data.length === 0)
|
|
98
|
+
return '';
|
|
99
|
+
const [first, ...rest] = data;
|
|
100
|
+
if (typeof first !== 'string') {
|
|
101
|
+
return data.map(stringifyLogValue).join(' ');
|
|
102
|
+
}
|
|
103
|
+
let index = 0;
|
|
104
|
+
const formatted = first.replace(/%[sdifjoOc%]/g, (specifier) => {
|
|
105
|
+
if (specifier === '%%')
|
|
106
|
+
return '%';
|
|
107
|
+
if (index >= rest.length)
|
|
108
|
+
return specifier;
|
|
109
|
+
const value = rest[index];
|
|
110
|
+
index += 1;
|
|
111
|
+
return formatSpecifier(specifier, value);
|
|
112
|
+
});
|
|
113
|
+
const remaining = rest.slice(index).map(stringifyLogValue);
|
|
114
|
+
return [formatted, ...remaining].join(' ');
|
|
115
|
+
};
|
|
116
|
+
const isLogColor = (value) => {
|
|
117
|
+
return typeof value === 'string' && value in ansiColors;
|
|
118
|
+
};
|
|
119
|
+
const isColorLogOptions = (value) => {
|
|
120
|
+
if (value === null || typeof value !== 'object')
|
|
121
|
+
return false;
|
|
122
|
+
const keys = Object.keys(value);
|
|
123
|
+
if (!keys.some((key) => key === 'color' || key === 'prefix' || key === 'suffix')) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const options = value;
|
|
127
|
+
return options.color === undefined || isLogColor(options.color);
|
|
128
|
+
};
|
|
129
|
+
const withColor = (color, data, options = {}) => {
|
|
130
|
+
const prefix = options.prefix ?? '';
|
|
131
|
+
const suffix = options.suffix ?? '';
|
|
132
|
+
const message = formatLogData(data);
|
|
133
|
+
return [`${ansiColors[color]}${prefix}${message}${suffix}${ANSI_RESET}`];
|
|
134
|
+
};
|
|
135
|
+
const printColorMessage = (data, config) => {
|
|
136
|
+
const color = config.color ?? 'green';
|
|
137
|
+
getConsole()?.log(...withColor(color, data, config));
|
|
138
|
+
};
|
|
139
|
+
export function colorLog(...data) {
|
|
140
|
+
const [first, ...rest] = data;
|
|
141
|
+
const last = data.at(-1);
|
|
142
|
+
if (isLogColor(first) && data.length >= 2) {
|
|
143
|
+
printColorMessage(rest, { color: first });
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (isLogColor(last) && data.length === 2) {
|
|
147
|
+
printColorMessage([first], { color: last });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (isColorLogOptions(last) && data.length >= 2) {
|
|
151
|
+
printColorMessage(data.slice(0, -1), last);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
printColorMessage(data, { color: 'green' });
|
|
155
|
+
}
|
|
156
|
+
export const logColor = (color, ...data) => {
|
|
157
|
+
printColorMessage(data, { color });
|
|
158
|
+
};
|
|
159
|
+
export const logColorized = (...messages) => {
|
|
160
|
+
getConsole()?.log(...messages);
|
|
161
|
+
};
|
|
162
|
+
export const logGreen = (...data) => {
|
|
163
|
+
logColor('green', ...data);
|
|
164
|
+
};
|
|
165
|
+
export const logYellow = (...data) => {
|
|
166
|
+
logColor('yellow', ...data);
|
|
167
|
+
};
|
|
168
|
+
export const logPink = (...data) => {
|
|
169
|
+
logColor('pink', ...data);
|
|
170
|
+
};
|
|
171
|
+
export const logWhite = (...data) => {
|
|
172
|
+
logColor('white', ...data);
|
|
173
|
+
};
|
|
174
|
+
export const logRed = (...data) => {
|
|
175
|
+
logColor('red', ...data);
|
|
176
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const clamp = (value, min, max) => {
|
|
2
|
+
if (min > max) {
|
|
3
|
+
throw new RangeError("min must be less than or equal to max");
|
|
4
|
+
}
|
|
5
|
+
return Math.min(Math.max(value, min), max);
|
|
6
|
+
};
|
|
7
|
+
export const toFiniteNumber = (value, fallback = 0) => {
|
|
8
|
+
const numberValue = typeof value === "number" ? value : Number(value);
|
|
9
|
+
return Number.isFinite(numberValue) ? numberValue : fallback;
|
|
10
|
+
};
|