@_tc/template-core 0.0.1-bate.36 → 0.0.1-bate.37
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 +53 -24
- 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 +17 -12
- package/cjs/packages/core/loader/model.js +3 -3
- package/cjs/packages/core/loader/router.js +14 -5
- 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 +53 -24
- 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 +17 -12
- package/esm/packages/core/loader/model.js +3 -3
- package/esm/packages/core/loader/router.js +14 -5
- package/fe/frontend/dash/Dashboard.d.ts +7 -0
- package/fe/frontend/dash/Dashboard.js +63 -0
- package/fe/frontend/dash/dash.entry.d.ts +2 -0
- package/fe/frontend/dash/dash.entry.js +62 -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 +13 -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 +207 -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 +7 -0
- package/fe/frontend/widgets/common/language.d.ts +2 -0
- package/fe/frontend/widgets/common/language.js +8 -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 +22 -0
- package/fe/frontend/widgets/common/menu.js +80 -0
- package/fe/frontend/widgets/common/request.d.ts +33 -0
- package/fe/frontend/widgets/common/request.js +127 -0
- package/fe/frontend/widgets/components/BasePage/HeaderView.d.ts +9 -0
- package/fe/frontend/widgets/components/BasePage/HeaderView.js +14 -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 +109 -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 +58 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.d.ts +11 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.js +176 -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 +67 -0
- package/fe/frontend/widgets/defaultPages/Schema/schemaType.d.ts +41 -0
- package/fe/frontend/widgets/defaultPages/Schema/schemaType.js +4 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.d.ts +23 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.js +66 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.d.ts +33 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.js +24 -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 +72 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.d.ts +4 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.js +31 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.d.ts +10 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +31 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.js +15 -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 +24 -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 +11 -0
- package/fe/frontend/widgets/hooks/useCurrentMenuData.js +20 -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 +16 -0
- package/fe/frontend/widgets/store/mode.js +36 -0
- package/fe/model/types/data/button.d.ts +23 -0
- package/fe/model/types/data/button.js +1 -0
- package/fe/model/types/data/component.d.ts +37 -0
- package/fe/model/types/data/component.js +1 -0
- package/fe/model/types/data/fetchInfo.d.ts +8 -0
- package/fe/model/types/data/fetchInfo.js +1 -0
- package/fe/model/types/data/schema.d.ts +47 -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 +44 -0
- package/fe/model/types/menuType.js +1 -0
- package/fe/model/types/model.d.ts +20 -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 +87 -0
- package/fe/packages/common/i18n/default.js +85 -0
- package/fe/packages/common/i18n/en-US.d.ts +87 -0
- package/fe/packages/common/i18n/en-US.js +85 -0
- package/fe/packages/common/i18n/index.d.ts +19 -0
- package/fe/packages/common/i18n/index.js +142 -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 +47 -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 +16 -30
- package/fe/packages/ui/react/components/Button/Button.js +53 -26
- package/fe/packages/ui/react/components/Button/SumbitButton.d.ts +2 -6
- package/fe/packages/ui/react/components/Button/SumbitButton.js +3 -14
- 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.d.ts → ConfirmDialog/ConfirmDialog.d.ts} +0 -8
- 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 -23
- package/fe/packages/ui/react/components/DataTable/{data-table.js → index.js} +57 -47
- package/fe/packages/ui/react/components/Date/Calendar.d.ts +0 -13
- package/fe/packages/ui/react/components/Date/Calendar.js +5 -13
- package/fe/packages/ui/react/components/Date/Date.d.ts +4 -13
- package/fe/packages/ui/react/components/Date/Date.js +70 -66
- package/fe/packages/ui/react/components/Date/LocaleContext.d.ts +0 -4
- package/fe/packages/ui/react/components/Date/LocaleContext.js +0 -4
- package/fe/packages/ui/react/components/Date/LocaleProvider.d.ts +0 -11
- package/fe/packages/ui/react/components/Date/LocaleProvider.js +0 -11
- package/fe/packages/ui/react/components/Date/TimePicker.js +3 -2
- package/fe/packages/ui/react/components/Date/dateLocaleStore.d.ts +0 -6
- 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 -19
- package/fe/packages/ui/react/components/Date/locales.js +7 -47
- package/fe/packages/ui/react/components/Drawer/Drawer.d.ts +23 -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 +24 -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.d.ts +0 -6
- package/fe/packages/ui/react/components/Form/Form.js +1 -1
- package/fe/packages/ui/react/components/Form/FormItem.d.ts +0 -21
- package/fe/packages/ui/react/components/Form/FormItem.js +2 -9
- package/fe/packages/ui/react/components/Form/SchemaForm/data.d.ts +45 -0
- package/fe/packages/ui/react/components/Form/{SchemeForm → SchemaForm}/data.js +8 -1
- package/fe/packages/ui/react/components/Form/SchemaForm/index.d.ts +60 -0
- package/fe/packages/ui/react/components/Form/SchemaForm/index.js +75 -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 -20
- package/fe/packages/ui/react/components/ImagePreview/PreviewImage.d.ts +0 -3
- package/fe/packages/ui/react/components/ImagePreview/PreviewImage.js +5 -2
- package/fe/packages/ui/react/components/Input/Input.d.ts +3 -21
- package/fe/packages/ui/react/components/Input/Input.js +5 -7
- package/fe/packages/ui/react/components/InputNumber/InputNumber.d.ts +26 -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.d.ts +0 -29
- package/fe/packages/ui/react/components/Label/Label.js +2 -4
- package/fe/packages/ui/react/components/Menu/Menu.d.ts +18 -0
- package/fe/packages/ui/react/components/Menu/Menu.js +98 -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 +3 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.js +124 -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 +58 -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.d.ts +0 -7
- package/fe/packages/ui/react/components/Message/Message.js +4 -4
- package/fe/packages/ui/react/components/Message/MessageManager.js +0 -8
- package/fe/packages/ui/react/components/Modal/Modal.d.ts +3 -7
- package/fe/packages/ui/react/components/Modal/Modal.js +6 -44
- package/fe/packages/ui/react/components/Modal/ModalManager.d.ts +0 -12
- package/fe/packages/ui/react/components/Modal/ModalManager.js +5 -7
- package/fe/packages/ui/react/components/Overlay/Overlay.d.ts +20 -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.d.ts → Pagination/Pagination.d.ts} +0 -7
- package/fe/packages/ui/react/components/{Pagination.js → Pagination/Pagination.js} +5 -12
- 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 +69 -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 -5
- package/fe/packages/ui/react/components/Search/Search.js +3 -3
- package/fe/packages/ui/react/components/Select/Select.d.ts +2 -2
- package/fe/packages/ui/react/components/Select/Select.js +52 -113
- 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.d.ts +0 -15
- package/fe/packages/ui/react/components/Skeleton/Skeleton.js +3 -3
- package/fe/packages/ui/react/components/Switch/Switch.js +3 -1
- package/fe/packages/ui/react/components/TableSearch/TableSearch.d.ts +5 -41
- package/fe/packages/ui/react/components/TableSearch/TableSearch.js +21 -22
- package/fe/packages/ui/react/components/TableSearch/lang.js +5 -14
- package/fe/packages/ui/react/components/Textarea/Textarea.d.ts +21 -0
- package/fe/packages/ui/react/components/Textarea/Textarea.js +36 -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/Tooltip.d.ts +9 -0
- package/fe/packages/ui/react/components/Tooltip/Tooltip.js +71 -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.d.ts → TreeSelect/TreeSelect.d.ts} +0 -6
- package/fe/packages/ui/react/components/{TreeSelect.js → TreeSelect/TreeSelect.js} +9 -17
- 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.d.ts +0 -27
- package/fe/packages/ui/react/components/Upload/Upload.js +2 -1
- package/fe/packages/ui/react/components/{breadcrumb.js → breadcrumb/breadcrumb.js} +15 -21
- 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 +43 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.js +123 -0
- package/fe/packages/ui/react/components/hooks/useInputController.d.ts +0 -3
- package/fe/packages/ui/react/components/hooks/useInputController.js +0 -7
- 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 +101 -0
- package/fe/packages/ui/react/components/testPage/index.js +251 -81
- package/fe/packages/ui/react/hooks/useExecuteOnce.d.ts +12 -0
- package/fe/packages/ui/react/hooks/useExecuteOnce.js +36 -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 +18 -0
- package/fe/packages/ui/react/hooks/useRefState.js +28 -0
- package/fe/packages/ui/react/hooks/useWatch.d.ts +15 -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 +13 -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 +9 -0
- package/fe/packages/ui/react/i18n/useI18n.js +14 -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 -2
- 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 -46
- package/fe/packages/ui/react/lib/export.js +0 -40
- package/fe/packages/ui/react/lib/utils.d.ts +0 -24
- package/fe/packages/ui/react/lib/utils.js +0 -25
- package/fe/packages/ui/react/stores/breadcrumb.js +0 -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/package.json +12 -1
- 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/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.d.ts +0 -152
- package/fe/packages/ui/react/components/Form/SchemeForm/index.js +0 -69
- package/fe/packages/ui/react/components/Textarea.d.ts +0 -59
- package/fe/packages/ui/react/components/Textarea.js +0 -35
- package/fe/packages/ui/react/components/Tooltip.d.ts +0 -25
- 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/{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,142 @@
|
|
|
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
|
+
export const mergeI18nDictionary = (base = {}, patch = {}) => {
|
|
8
|
+
const next = { ...base };
|
|
9
|
+
Object.entries(patch).forEach(([key, value]) => {
|
|
10
|
+
const current = next[key];
|
|
11
|
+
if (isPlainI18nDictionary(current) && isPlainI18nDictionary(value)) {
|
|
12
|
+
next[key] = mergeI18nDictionary(current, value);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
next[key] = value;
|
|
16
|
+
});
|
|
17
|
+
return next;
|
|
18
|
+
};
|
|
19
|
+
export const mergeI18nResources = (base = {}, patch = {}) => {
|
|
20
|
+
const next = { ...base };
|
|
21
|
+
Object.entries(patch).forEach(([language, messages]) => {
|
|
22
|
+
if (!messages)
|
|
23
|
+
return;
|
|
24
|
+
next[language] = mergeI18nDictionary(next[language], messages);
|
|
25
|
+
});
|
|
26
|
+
return next;
|
|
27
|
+
};
|
|
28
|
+
export const getI18nPathValue = (dictionary, key) => {
|
|
29
|
+
if (!dictionary)
|
|
30
|
+
return undefined;
|
|
31
|
+
return key.split('.').reduce((value, currentKey) => {
|
|
32
|
+
if (!isPlainI18nDictionary(value))
|
|
33
|
+
return undefined;
|
|
34
|
+
return value[currentKey];
|
|
35
|
+
}, dictionary);
|
|
36
|
+
};
|
|
37
|
+
export const interpolateI18nMessage = (value, data) => {
|
|
38
|
+
if (!data)
|
|
39
|
+
return value;
|
|
40
|
+
return value.replace(/\{([A-Za-z0-9_]+)\}/g, (match, key) => {
|
|
41
|
+
const nextValue = data[key];
|
|
42
|
+
return typeof nextValue === 'undefined' || nextValue === null ? match : String(nextValue);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export const translate = (state, key, fillingData, options) => {
|
|
46
|
+
const language = options?.language || state.language;
|
|
47
|
+
const fallbackLanguage = options?.fallbackLanguage || state.fallbackLanguage;
|
|
48
|
+
const value = getI18nPathValue(state.resources[language], key) ??
|
|
49
|
+
getI18nPathValue(state.resources[fallbackLanguage], key) ??
|
|
50
|
+
options?.fallback ??
|
|
51
|
+
key;
|
|
52
|
+
return (typeof value === 'string' ? interpolateI18nMessage(value, fillingData) : value);
|
|
53
|
+
};
|
|
54
|
+
const getBrowserWindow = () => {
|
|
55
|
+
return globalThis.window;
|
|
56
|
+
};
|
|
57
|
+
const getStoredLanguage = (storageKey) => {
|
|
58
|
+
const windowRef = getBrowserWindow();
|
|
59
|
+
if (!windowRef) {
|
|
60
|
+
return defaultLanguage;
|
|
61
|
+
}
|
|
62
|
+
return windowRef.localStorage.getItem(storageKey) || defaultLanguage;
|
|
63
|
+
};
|
|
64
|
+
const persistLanguage = (storageKey, language) => {
|
|
65
|
+
const windowRef = getBrowserWindow();
|
|
66
|
+
if (!windowRef)
|
|
67
|
+
return;
|
|
68
|
+
windowRef.localStorage.setItem(storageKey, language);
|
|
69
|
+
};
|
|
70
|
+
const createInitialState = () => ({
|
|
71
|
+
language: getStoredLanguage(languageLocalKey),
|
|
72
|
+
fallbackLanguage: defaultLanguage,
|
|
73
|
+
resources: translations,
|
|
74
|
+
storageKey: languageLocalKey,
|
|
75
|
+
persist: true,
|
|
76
|
+
});
|
|
77
|
+
const createI18nStore = () => {
|
|
78
|
+
let state;
|
|
79
|
+
const listeners = new Set();
|
|
80
|
+
const setState = (partial) => {
|
|
81
|
+
const previousState = state;
|
|
82
|
+
const nextPartial = typeof partial === 'function' ? partial(state) : partial;
|
|
83
|
+
state = { ...state, ...nextPartial };
|
|
84
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
85
|
+
};
|
|
86
|
+
const initialState = createInitialState();
|
|
87
|
+
state = {
|
|
88
|
+
...initialState,
|
|
89
|
+
t: (key, fillingData, options) => i18n(key, fillingData, options),
|
|
90
|
+
setLanguage: (language) => {
|
|
91
|
+
setState({ language });
|
|
92
|
+
const { persist, storageKey } = state;
|
|
93
|
+
if (persist) {
|
|
94
|
+
persistLanguage(storageKey, language);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
setFallbackLanguage: (fallbackLanguage) => {
|
|
98
|
+
setState({ fallbackLanguage });
|
|
99
|
+
},
|
|
100
|
+
setResources: (resources, options) => {
|
|
101
|
+
setState((currentState) => ({
|
|
102
|
+
resources: options?.merge ? mergeI18nResources(currentState.resources, resources) : resources,
|
|
103
|
+
}));
|
|
104
|
+
},
|
|
105
|
+
addResources: (language, messages, options) => {
|
|
106
|
+
setState((currentState) => {
|
|
107
|
+
const shouldMerge = options?.merge ?? true;
|
|
108
|
+
const currentMessages = currentState.resources[language];
|
|
109
|
+
return {
|
|
110
|
+
resources: {
|
|
111
|
+
...currentState.resources,
|
|
112
|
+
[language]: shouldMerge ? mergeI18nDictionary(currentMessages, messages) : messages,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
configureI18n: (config) => {
|
|
118
|
+
setState(config);
|
|
119
|
+
},
|
|
120
|
+
resetI18n: () => {
|
|
121
|
+
setState(createInitialState());
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const initialStoreState = state;
|
|
125
|
+
return {
|
|
126
|
+
getState: () => state,
|
|
127
|
+
getInitialState: () => initialStoreState,
|
|
128
|
+
setState,
|
|
129
|
+
subscribe: (listener) => {
|
|
130
|
+
listeners.add(listener);
|
|
131
|
+
return () => {
|
|
132
|
+
listeners.delete(listener);
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
export const i18nStore = createI18nStore();
|
|
138
|
+
export const i18n = (key, fillingData, options) => {
|
|
139
|
+
return translate(i18nStore.getState(), key, fillingData, options);
|
|
140
|
+
};
|
|
141
|
+
export const t = i18n;
|
|
142
|
+
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,47 @@
|
|
|
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
|
+
storageKey: string;
|
|
16
|
+
persist: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface I18nTranslateOptions {
|
|
19
|
+
language?: I18nLanguage;
|
|
20
|
+
fallbackLanguage?: I18nLanguage;
|
|
21
|
+
fallback?: I18nMessage;
|
|
22
|
+
}
|
|
23
|
+
export interface I18nSetResourcesOptions {
|
|
24
|
+
merge?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface I18nAddResourcesOptions {
|
|
27
|
+
merge?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export type I18nTranslator = <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => T | string;
|
|
30
|
+
export interface I18nActions {
|
|
31
|
+
setLanguage: (language: I18nLanguage) => void;
|
|
32
|
+
setFallbackLanguage: (language: I18nLanguage) => void;
|
|
33
|
+
setResources: (resources: I18nResources, options?: I18nSetResourcesOptions) => void;
|
|
34
|
+
addResources: (language: I18nLanguage, messages: I18nDictionary, options?: I18nAddResourcesOptions) => void;
|
|
35
|
+
configureI18n: (config: Partial<Pick<I18nState, 'storageKey' | 'persist'>>) => void;
|
|
36
|
+
resetI18n: () => void;
|
|
37
|
+
t: I18nTranslator;
|
|
38
|
+
}
|
|
39
|
+
export type I18nStore = I18nState & I18nActions;
|
|
40
|
+
export type I18nStoreListener = (state: I18nStore, previousState: I18nStore) => void;
|
|
41
|
+
export interface I18nStoreApi {
|
|
42
|
+
getState: () => I18nStore;
|
|
43
|
+
getInitialState: () => I18nStore;
|
|
44
|
+
setState: (partial: Partial<I18nStore> | ((state: I18nStore) => Partial<I18nStore>)) => void;
|
|
45
|
+
subscribe: (listener: I18nStoreListener) => () => void;
|
|
46
|
+
}
|
|
47
|
+
//# 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
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isPlainObject } from "../guards";
|
|
2
|
+
const isEmptyValue = (value) => {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return true;
|
|
5
|
+
if (Array.isArray(value))
|
|
6
|
+
return value.length === 0;
|
|
7
|
+
if (isPlainObject(value))
|
|
8
|
+
return Object.keys(value).length === 0;
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
11
|
+
const filterEmptyValue = (value) => {
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
const result = value
|
|
14
|
+
.map((item) => filterEmptyValue(item))
|
|
15
|
+
.filter((item) => !isEmptyValue(item));
|
|
16
|
+
return result.length > 0 ? result : undefined;
|
|
17
|
+
}
|
|
18
|
+
if (isPlainObject(value)) {
|
|
19
|
+
const result = {};
|
|
20
|
+
for (const [key, item] of Object.entries(value)) {
|
|
21
|
+
const nextValue = filterEmptyValue(item);
|
|
22
|
+
if (!isEmptyValue(nextValue)) {
|
|
23
|
+
result[key] = nextValue;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
export function filterEmpty(data) {
|
|
31
|
+
return filterEmptyValue(data);
|
|
32
|
+
}
|
|
33
|
+
export const filtereEmpty = filterEmpty;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "./filterEmpty";
|
|
2
|
+
export declare const pick: <T extends object, K extends keyof T>(target: T, keys: readonly K[]) => Pick<T, K>;
|
|
3
|
+
export declare const omit: <T extends object, K extends keyof T>(target: T, keys: readonly K[]) => Omit<T, K>;
|
|
4
|
+
export declare const mapValues: <T extends object, TResult>(target: T, mapper: <K extends keyof T>(value: T[K], key: K) => TResult) => { [K in keyof T]: TResult; };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export * from "./filterEmpty";
|
|
2
|
+
export const pick = (target, keys) => {
|
|
3
|
+
const result = {};
|
|
4
|
+
for (const key of keys) {
|
|
5
|
+
if (key in target) {
|
|
6
|
+
result[key] = target[key];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
export const omit = (target, keys) => {
|
|
12
|
+
const result = { ...target };
|
|
13
|
+
for (const key of keys) {
|
|
14
|
+
delete result[key];
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
export const mapValues = (target, mapper) => {
|
|
19
|
+
const result = {};
|
|
20
|
+
const keys = Object.keys(target);
|
|
21
|
+
for (const key of keys) {
|
|
22
|
+
result[key] = mapper(target[key], key);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const isBlank = (value) => {
|
|
2
|
+
return value === null || value === undefined || value.trim().length === 0;
|
|
3
|
+
};
|
|
4
|
+
export const capitalize = (value) => {
|
|
5
|
+
if (value.length === 0)
|
|
6
|
+
return value;
|
|
7
|
+
const first = value.charAt(0).toUpperCase();
|
|
8
|
+
return `${first}${value.slice(1)}`;
|
|
9
|
+
};
|
|
10
|
+
export const kebabCase = (value) => {
|
|
11
|
+
return value
|
|
12
|
+
.trim()
|
|
13
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
14
|
+
.replace(/[\s_]+/g, "-")
|
|
15
|
+
.replace(/-+/g, "-")
|
|
16
|
+
.toLowerCase();
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,39 +1,25 @@
|
|
|
1
|
-
import type { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
export type ButtonVariant = 'default' | 'primary' | 'text' | 'link';
|
|
1
|
+
import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type ButtonVariant = 'default' | 'primary' | 'dashed' | 'text' | 'link';
|
|
3
|
+
export type ButtonState = 'danger' | 'ghost';
|
|
3
4
|
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 按钮变体
|
|
7
|
-
* @default 'default'
|
|
8
|
-
*/
|
|
9
|
-
variant?: ButtonVariant;
|
|
10
|
-
/**
|
|
11
|
-
* 按钮尺寸
|
|
12
|
-
* @default 'md'
|
|
13
|
-
*/
|
|
5
|
+
type ButtonCommonProps = {
|
|
14
6
|
size?: ButtonSize;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*/
|
|
7
|
+
state?: ButtonState;
|
|
8
|
+
disabled?: boolean;
|
|
18
9
|
loading?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* 左侧图标
|
|
21
|
-
*/
|
|
22
10
|
leftIcon?: ReactNode;
|
|
23
|
-
/**
|
|
24
|
-
* 右侧图标
|
|
25
|
-
*/
|
|
26
11
|
rightIcon?: ReactNode;
|
|
27
|
-
/**
|
|
28
|
-
* 是否去除下划线(仅对 variant="link" 有效)
|
|
29
|
-
* @default false
|
|
30
|
-
*/
|
|
31
12
|
noUnderline?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* 作为子元素,用于更灵活的布局
|
|
34
|
-
*/
|
|
35
13
|
children?: ReactNode;
|
|
36
|
-
}
|
|
37
|
-
|
|
14
|
+
};
|
|
15
|
+
type ButtonElementVariant = Exclude<ButtonVariant, 'link'>;
|
|
16
|
+
export type ButtonProps = ButtonElementProps | ButtonLinkProps;
|
|
17
|
+
export type ButtonElementProps = ButtonCommonProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled'> & {
|
|
18
|
+
variant?: ButtonElementVariant;
|
|
19
|
+
};
|
|
20
|
+
export type ButtonLinkProps = ButtonCommonProps & AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
21
|
+
variant: 'link';
|
|
22
|
+
};
|
|
23
|
+
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
38
24
|
export { Button };
|
|
39
25
|
//# sourceMappingURL=Button.d.ts.map
|