@_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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from '../../lib/utils';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { SchemaForm } from '../Form';
|
|
5
5
|
const Search = (props) => {
|
|
6
|
-
const { defaultValue: pDefaultValue,
|
|
6
|
+
const { defaultValue: pDefaultValue, schemas, children, getForm, btnsClassName } = props;
|
|
7
7
|
const defaultValue = useMemo(() => {
|
|
8
8
|
return pDefaultValue;
|
|
9
9
|
}, []);
|
|
10
|
-
return (_jsxs("div", { className: "flex items-end justify-between gap-4 flex-wrap", children: [_jsx(
|
|
10
|
+
return (_jsxs("div", { className: "tc-ui-search flex items-end justify-between gap-4 flex-wrap", children: [_jsx(SchemaForm, { preserve: true, layout: "horizontal", schemas: schemas, initialValues: defaultValue, getForm: getForm, footerButtons: false }), _jsx("div", { className: cn('flex items-center gap-2 self-end ml-auto flex-wrap', btnsClassName), children: children })] }));
|
|
11
11
|
};
|
|
12
12
|
export default Search;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export type SelectOption = {
|
|
3
|
+
/** 展示内容;传 ReactNode 时建议同时提供 searchText 用于搜索 */
|
|
3
4
|
label: React.ReactNode;
|
|
4
5
|
value: string | number;
|
|
6
|
+
/** 搜索文本;优先级高于 label */
|
|
7
|
+
searchText?: string;
|
|
5
8
|
};
|
|
6
9
|
export type SelectProps = {
|
|
7
10
|
options: SelectOption[];
|
|
@@ -15,6 +18,8 @@ export type SelectProps = {
|
|
|
15
18
|
clearable?: boolean;
|
|
16
19
|
/** 是否支持搜索 默认开启 */
|
|
17
20
|
searchable?: boolean;
|
|
21
|
+
/** 自定义弹出容器,传 parent 时挂载到当前 Select 的父元素,不传则默认挂载到 document.body */
|
|
22
|
+
getPopupContainer?: 'parent' | (() => HTMLElement);
|
|
18
23
|
};
|
|
19
24
|
declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
25
|
export { Select };
|
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from '../../i18n';
|
|
2
3
|
import { cn } from '../../lib/utils';
|
|
3
4
|
import { ChevronUp, X } from 'lucide-react';
|
|
4
5
|
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import {
|
|
6
|
-
|
|
6
|
+
import { Button } from '../Button';
|
|
7
|
+
import { Input } from '../Input';
|
|
8
|
+
import { Popup } from '../Popup';
|
|
9
|
+
import { useDropdownPositioning } from '../hooks/useDropdownPositioning';
|
|
10
|
+
import { getSelectDropdownPosition } from './dropdownPositioning';
|
|
11
|
+
const Select = forwardRef(({ options, value: controlledValue, defaultValue, placeholder, onChange, className, disabled, clearable = true, searchable = true, getPopupContainer, }, ref) => {
|
|
12
|
+
const t = useI18n();
|
|
7
13
|
const [isOpen, setIsOpen] = useState(false);
|
|
8
14
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
9
15
|
const [isHover, setIsHover] = useState(false);
|
|
10
16
|
const [searchTerm, setSearchTerm] = useState('');
|
|
11
|
-
const
|
|
17
|
+
const rootRef = useRef(null);
|
|
12
18
|
const selectRef = useRef(null);
|
|
13
19
|
const dropdownRef = useRef(null);
|
|
14
20
|
const inputRef = useRef(null);
|
|
21
|
+
const popupContainerRef = useRef(null);
|
|
22
|
+
const isParentPopupContainer = getPopupContainer === 'parent';
|
|
23
|
+
popupContainerRef.current = isParentPopupContainer ? (rootRef.current?.parentElement ?? null) : null;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!isParentPopupContainer)
|
|
26
|
+
return;
|
|
27
|
+
const container = rootRef.current?.parentElement;
|
|
28
|
+
popupContainerRef.current = container ?? null;
|
|
29
|
+
if (!container || window.getComputedStyle(container).position !== 'static')
|
|
30
|
+
return;
|
|
31
|
+
const previousPosition = container.style.position;
|
|
32
|
+
container.style.position = 'relative';
|
|
33
|
+
return () => {
|
|
34
|
+
container.style.position = previousPosition;
|
|
35
|
+
};
|
|
36
|
+
}, [isParentPopupContainer]);
|
|
15
37
|
// 合并 refs
|
|
16
38
|
const setRefs = useCallback((node) => {
|
|
17
39
|
selectRef.current = node;
|
|
@@ -31,112 +53,37 @@ const Select = forwardRef(({ options, value: controlledValue, defaultValue, plac
|
|
|
31
53
|
if (!searchable || !searchTerm.trim())
|
|
32
54
|
return options;
|
|
33
55
|
const lower = searchTerm.trim().toLowerCase();
|
|
34
|
-
return options.filter((opt) =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!isOpen)
|
|
39
|
-
return;
|
|
40
|
-
const handleClickOutside = (event) => {
|
|
41
|
-
// 点击不在 选择部分 以及 下拉部分 关闭下拉
|
|
42
|
-
if (selectRef.current &&
|
|
43
|
-
!selectRef.current.contains(event.target) &&
|
|
44
|
-
dropdownRef.current &&
|
|
45
|
-
!dropdownRef.current.contains(event.target)) {
|
|
46
|
-
setIsOpen(false);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
50
|
-
return () => {
|
|
51
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
52
|
-
};
|
|
53
|
-
}, [isOpen]);
|
|
54
|
-
// 键盘关闭
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
const handleKeyDown = (event) => {
|
|
57
|
-
if (event.key === 'Escape' && isOpen) {
|
|
58
|
-
setIsOpen(false);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
if (isOpen) {
|
|
62
|
-
document.addEventListener('keydown', handleKeyDown);
|
|
63
|
-
}
|
|
64
|
-
return () => {
|
|
65
|
-
document.removeEventListener('keydown', handleKeyDown);
|
|
66
|
-
};
|
|
67
|
-
}, [isOpen]);
|
|
68
|
-
// 计算下拉菜单位置和方向
|
|
69
|
-
const updatePosition = useCallback(() => {
|
|
70
|
-
if (!selectRef.current)
|
|
71
|
-
return;
|
|
72
|
-
const rect = selectRef.current.getBoundingClientRect();
|
|
73
|
-
const scrollX = window.scrollX;
|
|
74
|
-
const scrollY = window.scrollY;
|
|
75
|
-
const viewportHeight = window.innerHeight;
|
|
76
|
-
// 获取实际下拉菜单高度,如果还未渲染则使用估算值
|
|
77
|
-
let dropdownHeight = 240; // 默认最大高度 max-h-60
|
|
78
|
-
if (dropdownRef.current) {
|
|
79
|
-
dropdownHeight = dropdownRef.current.getBoundingClientRect().height;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
// 估算下拉菜单高度(最大高度为 240px,即 max-h-60)
|
|
83
|
-
dropdownHeight = Math.min(filteredOptions.length * 40 + 8, 240); // 每个选项约40px + padding
|
|
84
|
-
}
|
|
85
|
-
const spaceBelow = viewportHeight - rect.bottom;
|
|
86
|
-
const spaceAbove = rect.top;
|
|
87
|
-
// 决定向上还是向下展开
|
|
88
|
-
const shouldPlaceTop = spaceBelow < dropdownHeight && spaceAbove > spaceBelow;
|
|
89
|
-
// 计算位置
|
|
90
|
-
let top;
|
|
91
|
-
if (shouldPlaceTop) {
|
|
92
|
-
// 向上展开:下拉菜单底部对齐触发器顶部
|
|
93
|
-
top = rect.top + scrollY - dropdownHeight - 4; // 4px 间距
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// 向下展开:下拉菜单顶部对齐触发器底部
|
|
97
|
-
top = rect.bottom + scrollY + 4; // 4px 间距
|
|
98
|
-
}
|
|
99
|
-
// 确保不超出视口
|
|
100
|
-
if (top < scrollY) {
|
|
101
|
-
top = scrollY + 4;
|
|
102
|
-
}
|
|
103
|
-
if (top + dropdownHeight > scrollY + viewportHeight) {
|
|
104
|
-
top = scrollY + viewportHeight - dropdownHeight - 4;
|
|
105
|
-
}
|
|
106
|
-
setPosition({
|
|
107
|
-
top,
|
|
108
|
-
left: rect.left + scrollX,
|
|
109
|
-
width: rect.width,
|
|
56
|
+
return options.filter((opt) => {
|
|
57
|
+
const searchText = opt.searchText ??
|
|
58
|
+
(typeof opt.label === 'string' || typeof opt.label === 'number' ? String(opt.label) : '');
|
|
59
|
+
return searchText.toLowerCase().includes(lower);
|
|
110
60
|
});
|
|
111
|
-
}, [
|
|
61
|
+
}, [options, searchTerm, searchable]);
|
|
62
|
+
const positioning = useDropdownPositioning({
|
|
63
|
+
open: isOpen,
|
|
64
|
+
anchorRef: selectRef,
|
|
65
|
+
contentRef: dropdownRef,
|
|
66
|
+
placement: 'bottom-start',
|
|
67
|
+
offset: 4,
|
|
68
|
+
matchAnchorWidth: true,
|
|
69
|
+
strategy: getSelectDropdownPosition,
|
|
70
|
+
estimateSize: () => ({
|
|
71
|
+
height: Math.min(filteredOptions.length * 40 + 8, 240),
|
|
72
|
+
}),
|
|
73
|
+
watchDeps: [filteredOptions.length, searchTerm, searchable],
|
|
74
|
+
containerRef: isParentPopupContainer ? popupContainerRef : undefined,
|
|
75
|
+
positionMode: isParentPopupContainer ? 'absolute' : 'fixed',
|
|
76
|
+
});
|
|
112
77
|
// 展开时更新位置并获取焦点
|
|
113
78
|
useEffect(() => {
|
|
114
79
|
if (isOpen) {
|
|
115
|
-
// 使用双重 requestAnimationFrame 确保 DOM 已完全渲染
|
|
116
80
|
requestAnimationFrame(() => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
inputRef.current?.focus();
|
|
121
|
-
}
|
|
122
|
-
});
|
|
81
|
+
if (searchable) {
|
|
82
|
+
inputRef.current?.focus();
|
|
83
|
+
}
|
|
123
84
|
});
|
|
124
85
|
}
|
|
125
|
-
}, [isOpen, searchable
|
|
126
|
-
// 监听滚动和窗口大小变化,更新位置
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
if (!isOpen)
|
|
129
|
-
return;
|
|
130
|
-
const handleUpdate = () => {
|
|
131
|
-
updatePosition();
|
|
132
|
-
};
|
|
133
|
-
window.addEventListener('scroll', handleUpdate, true);
|
|
134
|
-
window.addEventListener('resize', handleUpdate);
|
|
135
|
-
return () => {
|
|
136
|
-
window.removeEventListener('scroll', handleUpdate, true);
|
|
137
|
-
window.removeEventListener('resize', handleUpdate);
|
|
138
|
-
};
|
|
139
|
-
}, [isOpen, updatePosition]);
|
|
86
|
+
}, [isOpen, searchable]);
|
|
140
87
|
const handleToggle = useCallback(() => {
|
|
141
88
|
if (disabled)
|
|
142
89
|
return;
|
|
@@ -166,15 +113,11 @@ const Select = forwardRef(({ options, value: controlledValue, defaultValue, plac
|
|
|
166
113
|
const handleSearchChange = useCallback((event) => {
|
|
167
114
|
setSearchTerm(event.target.value);
|
|
168
115
|
}, []);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
top: `${position.top}px`,
|
|
172
|
-
left: `${position.left}px`,
|
|
173
|
-
width: `${position.width}px`,
|
|
174
|
-
}, children: _jsx("div", { className: "p-1", children: filteredOptions.length > 0 ? (filteredOptions.map((option) => {
|
|
116
|
+
const popupContainer = getPopupContainer === 'parent' ? (rootRef.current?.parentElement ?? undefined) : getPopupContainer?.();
|
|
117
|
+
return (_jsxs("div", { ref: rootRef, className: cn('tc-ui-select relative w-full', className), children: [_jsxs("div", { ref: setRefs, onClick: handleToggle, onMouseEnter: () => setIsHover(true), onMouseLeave: () => setIsHover(false), className: cn('flex w-full items-center justify-between rounded-lg px-4 py-3 text-sm', 'border transition-colors duration-200', 'focus:outline-none', disabled ? 'cursor-not-allowed bg-muted border-border' : 'cursor-pointer bg-background', !disabled && isOpen && 'border-theme', !disabled && !isOpen && 'border-border'), children: [searchable && isOpen ? (_jsx(Input, { ref: inputRef, value: searchTerm, onChange: (_, e) => handleSearchChange(e), onClick: (e) => e.stopPropagation(), placeholder: typeof displayText === 'string' ? displayText : placeholder, className: "min-w-0 flex-1", inputClassName: cn('h-5 min-w-0 flex-1 rounded-none border-0 bg-transparent px-0 py-0 text-left leading-5 outline-none', 'placeholder:text-muted-foreground', disabled && 'text-muted-foreground cursor-not-allowed'), disabled: disabled })) : (_jsx("span", { className: cn('min-h-5 min-w-0 flex-1 text-left truncate leading-5', disabled ? 'text-muted-foreground' : !selectedOption && 'text-muted-foreground'), children: displayText })), clearable && !disabled && value !== undefined && isHover ? (_jsx(Button, { variant: "text", type: "button", onClick: handleClear, className: "ml-2 flex items-center justify-center text-muted-foreground hover:text-foreground cursor-pointer", "aria-label": "Clear selection", title: "Clear", children: _jsx(X, { size: 14 }) })) : (_jsx(ChevronUp, { size: 16, className: cn('ml-2 transition-transform duration-200', isOpen ? 'rotate-0' : 'rotate-180') }))] }), _jsx(Popup, { open: isOpen, anchorRef: selectRef, contentRef: dropdownRef, positioning: positioning, keepMounted: true, onOpenChange: setIsOpen, container: popupContainer, positionMode: isParentPopupContainer ? 'absolute' : 'fixed', className: cn('z-[1000] w-full rounded-lg bg-background shadow-lg', 'border border-border', 'max-h-60 overflow-auto'), children: _jsx("div", { className: cn('w-full', !isOpen && 'hidden'), children: _jsx("div", { className: "p-1", children: filteredOptions.length > 0 ? (filteredOptions.map((option) => {
|
|
175
118
|
const isSelected = option.value === value;
|
|
176
119
|
return (_jsx("div", { onClick: () => handleSelect(option.value), className: cn('px-4 py-2 text-sm cursor-pointer transition-colors rounded-md', 'hover:bg-muted', isSelected && 'bg-muted'), children: option.label }, option.value));
|
|
177
|
-
})) : (_jsx("div", { className: "px-4 py-2 text-sm text-muted-foreground text-center", children:
|
|
120
|
+
})) : (_jsx("div", { className: "px-4 py-2 text-sm text-muted-foreground text-center", children: t('components.select.empty') })) }) }) })] }));
|
|
178
121
|
});
|
|
179
122
|
Select.displayName = 'Select';
|
|
180
123
|
export { Select };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const getSelectDropdownPosition = ({ anchorRect, contentRect, containerRect, viewportHeight, offset, matchAnchorWidth, }) => {
|
|
2
|
+
const dropdownHeight = contentRect?.height ?? 240;
|
|
3
|
+
const spaceBelow = viewportHeight - anchorRect.bottom;
|
|
4
|
+
const spaceAbove = anchorRect.top;
|
|
5
|
+
const shouldPlaceTop = spaceBelow < dropdownHeight && spaceAbove > spaceBelow;
|
|
6
|
+
const containerTop = containerRect?.top ?? 0;
|
|
7
|
+
const containerLeft = containerRect?.left ?? 0;
|
|
8
|
+
return {
|
|
9
|
+
top: (shouldPlaceTop ? anchorRect.top - dropdownHeight - offset : anchorRect.bottom + offset) - containerTop,
|
|
10
|
+
left: anchorRect.left - containerLeft,
|
|
11
|
+
width: matchAnchorWidth ? anchorRect.width : undefined,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -8,7 +8,7 @@ const PageLoadingSkeleton = ({ rows = 5, showTitle = true, showActions = true })
|
|
|
8
8
|
};
|
|
9
9
|
const TableLoadingSkeleton = ({ rows = 5 }) => {
|
|
10
10
|
const columnCount = 6; // 默认列数,可以根据需要调整
|
|
11
|
-
return (_jsx("div", { className: "w-full", children: _jsx("div", { className: "bg-
|
|
11
|
+
return (_jsx("div", { className: "w-full", children: _jsx("div", { className: "bg-background rounded-[20px] overflow-hidden", children: _jsxs(Table, { containerClassName: "rounded-b-none", children: [_jsx(TableHeader, { children: _jsx(TableRow, { children: Array.from({ length: columnCount }).map((_, index) => (_jsx(TableHead, { children: _jsx(SkeletonText, { width: index === 0 ? 120 : index === columnCount - 1 ? 80 : 150 }) }, index))) }) }), _jsx(TableBody, { children: Array.from({ length: rows }).map((_, rowIndex) => (_jsx(TableRow, { children: Array.from({ length: columnCount }).map((_, colIndex) => (_jsx(TableCell, { children: colIndex === columnCount - 1 ? (_jsxs("div", { className: "flex gap-2", children: [_jsx(SkeletonItem, { className: "h-8 w-16" }), _jsx(SkeletonItem, { className: "h-8 w-16" })] })) : (_jsx(SkeletonText, { width: colIndex === 0 ? 120 : colIndex === 1 ? '80%' : 150 })) }, colIndex))) }, rowIndex))) })] }) }) }));
|
|
12
12
|
};
|
|
13
13
|
const ComponentsLoadingSkeleton = ({ rows = 3 }) => {
|
|
14
14
|
return (_jsx("div", { className: "w-full space-y-3", children: Array.from({ length: rows }).map((_, index) => (_jsx(SkeletonItem, { className: "h-4 w-full" }, index))) }));
|
|
@@ -26,6 +26,6 @@ export const Skeleton = ({ mode = 'componentsloading', className, rows, showTitl
|
|
|
26
26
|
return _jsx(ComponentsLoadingSkeleton, { rows: rows });
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
return (_jsx("div", { className: cn('w-full', className), ...props, children: renderSkeleton() }));
|
|
29
|
+
return (_jsx("div", { className: cn('tc-ui-skeleton w-full', className), ...props, children: renderSkeleton() }));
|
|
30
30
|
};
|
|
31
31
|
Skeleton.displayName = 'Skeleton';
|
|
@@ -14,7 +14,9 @@ const Switch = forwardRef(({ checked: controlledChecked, defaultChecked, onChang
|
|
|
14
14
|
}
|
|
15
15
|
onChange?.(newChecked);
|
|
16
16
|
};
|
|
17
|
-
return (_jsx("button", { ref: ref, type: "button", role: "switch", "aria-checked": checked, disabled: disabled, onClick: handleToggle, className: cn('relative inline-flex h-6 w-11 items-center rounded-full transition-colors duration-200', 'focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2', disabled && 'cursor-not-allowed opacity-50', !disabled && 'cursor-pointer', checked
|
|
17
|
+
return (_jsx("button", { ref: ref, type: "button", role: "switch", "aria-checked": checked, disabled: disabled, onClick: handleToggle, className: cn('tc-ui-switch relative inline-flex h-6 w-11 items-center rounded-full transition-colors duration-200', 'focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2', disabled && 'cursor-not-allowed opacity-50', !disabled && 'cursor-pointer', checked
|
|
18
|
+
? 'bg-[hsl(var(--ring))] dark:bg-[hsl(var(--ring))]'
|
|
19
|
+
: 'bg-muted dark:bg-muted', className), children: _jsx("span", { className: cn('inline-block h-4 w-4 transform rounded-full bg-background transition-transform duration-200', checked ? 'translate-x-6' : 'translate-x-1') }) }));
|
|
18
20
|
});
|
|
19
21
|
Switch.displayName = 'Switch';
|
|
20
22
|
export { Switch };
|
|
@@ -2,19 +2,20 @@ import { ExportType } from '../../lib/export';
|
|
|
2
2
|
import type { MOmit } from '../../types';
|
|
3
3
|
import { type ReactNode } from 'react';
|
|
4
4
|
import { type DropdownItem } from '../Dropdown';
|
|
5
|
-
import type {
|
|
5
|
+
import type { FormFieldSchema } from '../Form';
|
|
6
6
|
import type { SearchProps } from '../Search/Search';
|
|
7
|
-
type
|
|
7
|
+
export type TableSearchSchema<T> = MOmit<FormFieldSchema<T>, 'rules' | 'required'> & {
|
|
8
8
|
/**
|
|
9
9
|
* - 字段是否常驻
|
|
10
10
|
* - 如果都没有则去前四个
|
|
11
11
|
*/
|
|
12
12
|
isPermanent?: boolean;
|
|
13
13
|
};
|
|
14
|
-
type TableSearchProps<T> = MOmit<SearchProps<T>, 'children' | '
|
|
14
|
+
type TableSearchProps<T> = MOmit<SearchProps<T>, 'children' | 'schemas'> & {
|
|
15
15
|
onSearch?: (values: T) => void;
|
|
16
16
|
onReset?: () => void;
|
|
17
|
-
|
|
17
|
+
renderActionBtnArea?: () => ReactNode;
|
|
18
|
+
schemas: TableSearchSchema<T>[];
|
|
18
19
|
/**
|
|
19
20
|
* 导出Excel按钮的下拉菜单项
|
|
20
21
|
*/
|
|
@@ -9,7 +9,7 @@ import { Search } from '../Search';
|
|
|
9
9
|
import { useTableSearchLocaleStore } from './tableSearchLocaleStore';
|
|
10
10
|
const EXPAND_BOUNDARIES = 4;
|
|
11
11
|
const TableSearch = (props) => {
|
|
12
|
-
const { onSearch, onReset, exportMenuItems, btnConfig: PBtnText, expandBoundaries = EXPAND_BOUNDARIES,
|
|
12
|
+
const { onSearch, onReset, exportMenuItems, btnConfig: PBtnText, expandBoundaries = EXPAND_BOUNDARIES, schemas, onExport, additionalButtons, defaultExpand = true, renderActionBtnArea, ...searchProps } = props;
|
|
13
13
|
const formRef = useRef(undefined);
|
|
14
14
|
const [isExpanded, setIsExpanded] = useState(defaultExpand);
|
|
15
15
|
const handleSearch = () => {
|
|
@@ -68,35 +68,35 @@ const TableSearch = (props) => {
|
|
|
68
68
|
PBtnText?.expandIcon,
|
|
69
69
|
locale,
|
|
70
70
|
]);
|
|
71
|
-
const {
|
|
72
|
-
const
|
|
71
|
+
const { permanentSchemas, alternativeSchemas } = useMemo(() => {
|
|
72
|
+
const alternativeSchemas = [];
|
|
73
73
|
const tmp = [];
|
|
74
|
-
for (let index = 0; index <
|
|
75
|
-
const item =
|
|
74
|
+
for (let index = 0; index < schemas.length; index++) {
|
|
75
|
+
const item = schemas[index];
|
|
76
76
|
if (item.isPermanent) {
|
|
77
77
|
tmp.push(item);
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
|
|
80
|
+
alternativeSchemas.push(item);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
if (tmp.length < expandBoundaries) {
|
|
84
84
|
const candidates = expandBoundaries - tmp.length;
|
|
85
85
|
for (let index = 0; index < candidates; index++) {
|
|
86
|
-
tmp.push(
|
|
86
|
+
tmp.push(alternativeSchemas[index]);
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
alternativeSchemas.splice(0, candidates);
|
|
89
89
|
}
|
|
90
|
-
return {
|
|
91
|
-
}, [expandBoundaries,
|
|
92
|
-
const showExpandedBtn =
|
|
93
|
-
let
|
|
90
|
+
return { alternativeSchemas, permanentSchemas: tmp };
|
|
91
|
+
}, [expandBoundaries, schemas]);
|
|
92
|
+
const showExpandedBtn = schemas.length > expandBoundaries;
|
|
93
|
+
let SSchemas;
|
|
94
94
|
// 有展开
|
|
95
95
|
if (showExpandedBtn) {
|
|
96
|
-
|
|
97
|
-
?
|
|
96
|
+
SSchemas = isExpanded
|
|
97
|
+
? schemas
|
|
98
98
|
: [
|
|
99
|
-
...
|
|
99
|
+
...permanentSchemas,
|
|
100
100
|
{
|
|
101
101
|
type: 'group',
|
|
102
102
|
fieldProps: {
|
|
@@ -104,16 +104,18 @@ const TableSearch = (props) => {
|
|
|
104
104
|
display: 'none',
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
|
-
|
|
108
|
-
childrens:
|
|
107
|
+
key: 'gropu1',
|
|
108
|
+
childrens: alternativeSchemas,
|
|
109
109
|
},
|
|
110
110
|
];
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
|
|
113
|
+
SSchemas = schemas;
|
|
114
114
|
}
|
|
115
|
-
return (_jsxs(Search, { getForm: (form) => {
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
return (_jsx("div", { className: "tc-ui-table-search", children: _jsxs(Search, { getForm: (form) => {
|
|
116
|
+
formRef.current = form;
|
|
117
|
+
}, schemas: SSchemas, ...searchProps, children: [showExpandedBtn && (_jsx(Button, { variant: "default", size: "sm", onClick: handleExpand, rightIcon: _jsx("span", { className: cn('transition-transform duration-200', isExpanded && 'rotate-180'), children: btnConfig.expandIcon }), children: isExpanded ? btnConfig.collapseBtn : btnConfig.expandBtn }, "expandedBtn")), _jsx(Button, { variant: "primary", size: "sm", onClick: handleSearch, children: btnConfig.searchBtn }), _jsx(Button, { variant: "default", size: "sm", onClick: handleReset, children: btnConfig.resetBtn }), renderActionBtnArea ? (renderActionBtnArea()) : (
|
|
118
|
+
// 导出Excel按钮
|
|
119
|
+
_jsx(Dropdown, { items: defaultExportItems, placement: "bottom-end", children: _jsx(Button, { variant: "default", size: "sm", rightIcon: _jsx(ChevronDown, { className: "h-4 w-4" }), children: btnConfig.exportBtn }) })), additionalButtons] }) }));
|
|
118
120
|
};
|
|
119
121
|
export default TableSearch;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
+
import { defaultEnglishResources, defaultLanguageResources } from '../../../../common/i18n';
|
|
2
|
+
const tableSearchDefaultLocale = defaultLanguageResources.components.tableSearch;
|
|
3
|
+
const tableSearchDefaultEnglishLocale = defaultEnglishResources.components.tableSearch;
|
|
1
4
|
export const zhCNLocale = {
|
|
2
|
-
|
|
3
|
-
search: '查询',
|
|
4
|
-
export: '导出Excel',
|
|
5
|
-
expand: '展开',
|
|
6
|
-
collapse: '收起',
|
|
7
|
-
exportCurrentPage: '当前页',
|
|
8
|
-
exportCurrentQuery: '当前查询条件',
|
|
5
|
+
...tableSearchDefaultLocale,
|
|
9
6
|
};
|
|
10
7
|
export const enUSLocale = {
|
|
11
|
-
|
|
12
|
-
search: 'Search',
|
|
13
|
-
export: 'Export Excel',
|
|
14
|
-
expand: 'Expand',
|
|
15
|
-
collapse: 'Collapse',
|
|
16
|
-
exportCurrentPage: 'Current Page',
|
|
17
|
-
exportCurrentQuery: 'Current Filters',
|
|
8
|
+
...tableSearchDefaultEnglishLocale,
|
|
18
9
|
};
|
|
19
10
|
export const defaultLocale = zhCNLocale;
|
|
20
11
|
export const btnConfig = defaultLocale;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChangeEvent, TextareaHTMLAttributes } from
|
|
2
|
-
export type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
1
|
+
import type { ChangeEvent, TextareaHTMLAttributes } from "react";
|
|
2
|
+
export type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "onChange" | "defaultValue"> & {
|
|
3
3
|
value?: string;
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -26,8 +26,12 @@ export type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'v
|
|
|
26
26
|
* 占位符文本
|
|
27
27
|
*/
|
|
28
28
|
placeholder?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 原生 textarea 节点的自定义 className
|
|
31
|
+
*/
|
|
32
|
+
textareaClassName?: string;
|
|
29
33
|
};
|
|
30
|
-
declare const Textarea: import("react").ForwardRefExoticComponent<Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "
|
|
34
|
+
declare const Textarea: import("react").ForwardRefExoticComponent<Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "defaultValue" | "onChange"> & {
|
|
31
35
|
value?: string;
|
|
32
36
|
/**
|
|
33
37
|
*
|
|
@@ -54,6 +58,10 @@ declare const Textarea: import("react").ForwardRefExoticComponent<Omit<TextareaH
|
|
|
54
58
|
* 占位符文本
|
|
55
59
|
*/
|
|
56
60
|
placeholder?: string;
|
|
61
|
+
/**
|
|
62
|
+
* 原生 textarea 节点的自定义 className
|
|
63
|
+
*/
|
|
64
|
+
textareaClassName?: string;
|
|
57
65
|
} & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
58
66
|
export { Textarea };
|
|
59
67
|
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
import { forwardRef, useCallback } from "react";
|
|
4
|
+
import { useInputController } from "../hooks/useInputController";
|
|
5
|
+
const Textarea = forwardRef(({ className, textareaClassName, value: controlledValue, onChange, defaultValue, maxLength = 500, showCount = true, placeholder, disabled, ...props }, ref) => {
|
|
6
|
+
const { isFocused, setIsFocused, setInternalValue, setRefs, value, hasValue, isControlledRef, currentLength, } = useInputController({
|
|
7
|
+
controlledValue,
|
|
8
|
+
defaultValue,
|
|
9
|
+
ref,
|
|
10
|
+
});
|
|
11
|
+
const handleChange = useCallback((e) => {
|
|
12
|
+
const newValue = e.target.value;
|
|
13
|
+
// 如果设置了 maxLength,限制输入长度
|
|
14
|
+
if (maxLength && newValue.length > maxLength) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!isControlledRef.current) {
|
|
18
|
+
setInternalValue(newValue);
|
|
19
|
+
}
|
|
20
|
+
onChange?.(newValue, e);
|
|
21
|
+
}, [maxLength, isControlledRef, onChange, setInternalValue]);
|
|
22
|
+
return (_jsxs("div", { className: cn("tc-ui-textarea relative w-fit", className), children: [_jsx("textarea", { ref: setRefs, value: value, onChange: handleChange, maxLength: maxLength, placeholder: placeholder, className: cn("flex w-full rounded-lg px-4 py-3 text-sm", "border transition-colors duration-200", "placeholder:text-muted-foreground", "focus:outline-none", "resize-none", showCount && "pb-10", disabled
|
|
23
|
+
? "cursor-not-allowed bg-muted border-border text-muted-foreground"
|
|
24
|
+
: "bg-background", !disabled && !hasValue && !isFocused && "border-border", !disabled && (hasValue || isFocused) && "border-foreground", textareaClassName), onFocus: (e) => {
|
|
25
|
+
if (!disabled) {
|
|
26
|
+
setIsFocused(true);
|
|
27
|
+
props.onFocus?.(e);
|
|
28
|
+
}
|
|
29
|
+
}, onBlur: (e) => {
|
|
30
|
+
if (!disabled) {
|
|
31
|
+
setIsFocused(false);
|
|
32
|
+
props.onBlur?.(e);
|
|
33
|
+
}
|
|
34
|
+
}, disabled: disabled, ...props }), showCount && (_jsxs("div", { className: cn('text-end', "text-xs text-muted-foreground", "pointer-events-none"), children: [currentLength, "/", maxLength] }))] }));
|
|
35
|
+
});
|
|
36
|
+
Textarea.displayName = "Textarea";
|
|
37
|
+
export { Textarea };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Textarea';
|
|
@@ -11,7 +11,7 @@ export interface TooltipProps {
|
|
|
11
11
|
* 提示位置
|
|
12
12
|
* @default 'right'
|
|
13
13
|
*/
|
|
14
|
-
placement?:
|
|
14
|
+
placement?: "top" | "bottom" | "left" | "right";
|
|
15
15
|
/**
|
|
16
16
|
* 是否显示
|
|
17
17
|
*/
|
|
@@ -21,5 +21,5 @@ export interface TooltipProps {
|
|
|
21
21
|
*/
|
|
22
22
|
className?: string;
|
|
23
23
|
}
|
|
24
|
-
export declare function Tooltip({ content, children, placement, visible, className }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function Tooltip({ content, children, placement, visible, className, }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
25
25
|
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
export function Tooltip({ content, children, placement = "right", visible, className, }) {
|
|
6
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
7
|
+
const [position, setPosition] = useState({ top: 0, left: 0 });
|
|
8
|
+
const triggerRef = useRef(null);
|
|
9
|
+
const tooltipRef = useRef(null);
|
|
10
|
+
const showTooltip = () => {
|
|
11
|
+
if (visible !== undefined) {
|
|
12
|
+
setIsVisible(visible);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
setIsVisible(true);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const hideTooltip = () => {
|
|
19
|
+
if (visible === undefined) {
|
|
20
|
+
setIsVisible(false);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (visible !== undefined) {
|
|
25
|
+
setIsVisible(visible);
|
|
26
|
+
}
|
|
27
|
+
}, [visible]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
// 显示时
|
|
30
|
+
if (isVisible && triggerRef.current && tooltipRef.current) {
|
|
31
|
+
// 使用 requestAnimationFrame 确保 DOM 已更新
|
|
32
|
+
requestAnimationFrame(() => {
|
|
33
|
+
if (!triggerRef.current || !tooltipRef.current)
|
|
34
|
+
return;
|
|
35
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
36
|
+
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
37
|
+
// const scrollY = window.scrollY;
|
|
38
|
+
// const scrollX = window.scrollX;
|
|
39
|
+
// const viewportWidth = window.innerWidth;
|
|
40
|
+
// const viewportHeight = window.innerHeight;
|
|
41
|
+
const padding = 8;
|
|
42
|
+
let top = 0;
|
|
43
|
+
let left = 0;
|
|
44
|
+
switch (placement) {
|
|
45
|
+
case "top":
|
|
46
|
+
top = triggerRect.top - tooltipRect.height - padding;
|
|
47
|
+
left =
|
|
48
|
+
triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
|
|
49
|
+
break;
|
|
50
|
+
case "bottom":
|
|
51
|
+
top = triggerRect.bottom + padding;
|
|
52
|
+
left =
|
|
53
|
+
triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
|
|
54
|
+
break;
|
|
55
|
+
case "left":
|
|
56
|
+
top = triggerRect.top;
|
|
57
|
+
left = triggerRect.left - tooltipRect.width - padding;
|
|
58
|
+
break;
|
|
59
|
+
case "right":
|
|
60
|
+
// 直接使用元素所在元素
|
|
61
|
+
top = triggerRect.top;
|
|
62
|
+
left = triggerRect.right + padding;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
setPosition({ top, left });
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// 隐藏时 重置定位定制 去除重影
|
|
69
|
+
if (!isVisible) {
|
|
70
|
+
const top = -100, left = -100;
|
|
71
|
+
setPosition({ top, left });
|
|
72
|
+
}
|
|
73
|
+
}, [isVisible, placement]);
|
|
74
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { ref: triggerRef, onMouseEnter: showTooltip, onMouseLeave: hideTooltip, className: "tc-ui-tooltip inline-block", children: children }), isVisible &&
|
|
75
|
+
createPortal(_jsx("div", { ref: tooltipRef, className: cn("fixed z-[9999] px-3 py-2", "bg-gray-800 text-white text-xs rounded", "shadow-lg", "pointer-events-none", "max-w-xs", className), style: {
|
|
76
|
+
top: `${position.top}px`,
|
|
77
|
+
left: `${position.left}px`,
|
|
78
|
+
}, children: content }), document.body)] }));
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Tooltip';
|