@_tc/template-core 0.0.1-bate.35 → 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 +5 -1
- 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 +14 -2
- 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
|
@@ -1,13 +1,94 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
2
3
|
import { MoreHorizontal } from 'lucide-react';
|
|
4
|
+
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Button } from '../Button';
|
|
3
6
|
import { Dropdown } from '../Dropdown';
|
|
4
|
-
|
|
7
|
+
const isInlineAction = (action) => !('render' in action);
|
|
8
|
+
const renderActionLabel = (action) => (_jsxs(_Fragment, { children: [action.icon && _jsx("span", { className: "flex-shrink-0", children: action.icon }), _jsx("span", { className: "truncate", children: action.label })] }));
|
|
9
|
+
const canShowInlineActions = (actions) => actions.every(isInlineAction);
|
|
10
|
+
const InlineActions = ({ actions }) => (_jsx("div", { className: "tc-ui-action-btn-list inline-flex max-w-full items-center justify-center gap-1 whitespace-nowrap", children: actions.map((action) => isInlineAction(action) ? (_jsx(Button, { type: "button", onClick: action.onClick, className: cn('tc-ui-action-btn inline-flex h-8 max-w-full items-center justify-center gap-1 rounded px-2 text-sm transition-colors', action.danger ? 'text-red-600 hover:bg-red-50' : 'text-table-action-text hover:bg-background/60'), children: renderActionLabel(action) }, action.key)) : null) }));
|
|
11
|
+
const DropdownActions = ({ actions }) => (_jsx(Dropdown, { items: actions, children: _jsx(Button, { type: "button", state: "ghost", variant: "text", "aria-label": "More actions", className: "inline-flex h-8 w-8 items-center justify-center rounded transition-colors hover:bg-background/60", children: _jsx(MoreHorizontal, { className: "h-5 w-5 text-gray-600" }) }) }));
|
|
12
|
+
const AutoActionBtn = ({ actions }) => {
|
|
13
|
+
const containerRef = useRef(null);
|
|
14
|
+
const measureRef = useRef(null);
|
|
15
|
+
const [canShowInline, setCanShowInline] = useState(false);
|
|
16
|
+
const updateOverflow = useCallback(() => {
|
|
17
|
+
const container = containerRef.current;
|
|
18
|
+
const measure = measureRef.current;
|
|
19
|
+
if (!container || !measure) {
|
|
20
|
+
setCanShowInline(false);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const containerWidth = container.clientWidth;
|
|
24
|
+
const actionsWidth = measure.scrollWidth;
|
|
25
|
+
setCanShowInline(containerWidth > 0 && actionsWidth <= containerWidth);
|
|
26
|
+
}, []);
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
if (!canShowInlineActions(actions))
|
|
29
|
+
return;
|
|
30
|
+
if (actions.length <= 1)
|
|
31
|
+
return;
|
|
32
|
+
updateOverflow();
|
|
33
|
+
let rafId = 0;
|
|
34
|
+
const scheduleUpdate = () => {
|
|
35
|
+
cancelAnimationFrame(rafId);
|
|
36
|
+
rafId = requestAnimationFrame(updateOverflow);
|
|
37
|
+
};
|
|
38
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
39
|
+
window.addEventListener('resize', scheduleUpdate);
|
|
40
|
+
return () => {
|
|
41
|
+
cancelAnimationFrame(rafId);
|
|
42
|
+
window.removeEventListener('resize', scheduleUpdate);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const observer = new ResizeObserver(scheduleUpdate);
|
|
46
|
+
if (containerRef.current) {
|
|
47
|
+
observer.observe(containerRef.current);
|
|
48
|
+
}
|
|
49
|
+
if (measureRef.current) {
|
|
50
|
+
observer.observe(measureRef.current);
|
|
51
|
+
}
|
|
52
|
+
window.addEventListener('resize', scheduleUpdate);
|
|
53
|
+
return () => {
|
|
54
|
+
cancelAnimationFrame(rafId);
|
|
55
|
+
observer.disconnect();
|
|
56
|
+
window.removeEventListener('resize', scheduleUpdate);
|
|
57
|
+
};
|
|
58
|
+
}, [actions, updateOverflow]);
|
|
5
59
|
if (actions.length === 0) {
|
|
6
60
|
return '-';
|
|
7
61
|
}
|
|
62
|
+
if (actions.length === 1) {
|
|
63
|
+
if (!canShowInlineActions(actions)) {
|
|
64
|
+
return _jsx(DropdownActions, { actions: actions });
|
|
65
|
+
}
|
|
66
|
+
return _jsx(InlineActions, { actions: actions });
|
|
67
|
+
}
|
|
68
|
+
if (!canShowInlineActions(actions)) {
|
|
69
|
+
return _jsx(DropdownActions, { actions: actions });
|
|
70
|
+
}
|
|
71
|
+
return (_jsxs("div", { ref: containerRef, className: "relative w-full min-w-0", children: [_jsx("div", { ref: measureRef, "aria-hidden": "true", className: "pointer-events-none invisible absolute left-0 top-0 w-max max-w-none", children: _jsx(InlineActions, { actions: actions }) }), canShowInline ? _jsx(InlineActions, { actions: actions }) : _jsx(DropdownActions, { actions: actions })] }));
|
|
72
|
+
};
|
|
73
|
+
export const ActionBtn = ({ actions, overflow }) => {
|
|
74
|
+
if (overflow === 'dropdown') {
|
|
75
|
+
return actions.length === 0 ? '-' : _jsx(DropdownActions, { actions: actions });
|
|
76
|
+
}
|
|
77
|
+
if (overflow === 'auto') {
|
|
78
|
+
return _jsx(AutoActionBtn, { actions: actions });
|
|
79
|
+
}
|
|
80
|
+
if (actions.length === 0) {
|
|
81
|
+
return '-';
|
|
82
|
+
}
|
|
83
|
+
if (overflow === 'inline') {
|
|
84
|
+
return canShowInlineActions(actions) ? _jsx(InlineActions, { actions: actions }) : _jsx(DropdownActions, { actions: actions });
|
|
85
|
+
}
|
|
8
86
|
if (actions.length === 1) {
|
|
9
87
|
const action = actions[0];
|
|
10
|
-
|
|
88
|
+
if (!isInlineAction(action)) {
|
|
89
|
+
return _jsx(DropdownActions, { actions: actions });
|
|
90
|
+
}
|
|
91
|
+
return (_jsx(Button, { type: "button", onClick: action.onClick, className: "tc-ui-action-btn inline-flex items-center justify-center w-8 h-8 rounded transition-colors", children: action.label }));
|
|
11
92
|
}
|
|
12
|
-
return
|
|
93
|
+
return _jsx(DropdownActions, { actions: actions });
|
|
13
94
|
};
|
|
@@ -1,44 +1,31 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import type { DropdownItem } from '../Dropdown';
|
|
2
3
|
import { type PaginationProps } from '../Pagination';
|
|
3
4
|
import type { ColumnDef } from '../types/baseType';
|
|
4
|
-
|
|
5
|
+
import { type ActionOverflow } from './ActionBtn';
|
|
6
|
+
type DataTableActionColumnOptions<T> = {
|
|
7
|
+
actions?: DropdownItem[] | ((value: unknown, record: T, index: number) => DropdownItem[]);
|
|
8
|
+
actionOverflow?: ActionOverflow;
|
|
9
|
+
};
|
|
10
|
+
type TableColumnDef<T = Record<string, unknown>> = ColumnDef<T> & DataTableActionColumnOptions<T>;
|
|
5
11
|
type RowSelection<T> = {
|
|
6
|
-
/**
|
|
7
|
-
* 受控用法:完全由外部维护选中 keys
|
|
8
|
-
*/
|
|
9
12
|
selectedRowKeys?: Array<string | number>;
|
|
10
|
-
/**
|
|
11
|
-
* 非受控用法:仅作为初始值,后续由内部维护
|
|
12
|
-
*/
|
|
13
13
|
defaultSelectedRowKeys?: Array<string | number>;
|
|
14
|
-
/**
|
|
15
|
-
* 选中项变化回调(受控/非受控都会触发)
|
|
16
|
-
*/
|
|
17
14
|
onChange?: (selectedRowKeys: Array<string | number>, selectedRows: T[], isAll: boolean) => void;
|
|
18
|
-
/**
|
|
19
|
-
* 全选 受控
|
|
20
|
-
*/
|
|
21
15
|
isAll?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* theader checkbox
|
|
24
|
-
*/
|
|
25
16
|
beforeCheckboxNode?: ReactNode;
|
|
26
17
|
};
|
|
27
18
|
interface DataTableProps<T = Record<string, unknown>> {
|
|
28
|
-
columns:
|
|
19
|
+
columns: TableColumnDef<T>[];
|
|
29
20
|
data: T[];
|
|
30
21
|
rowKey?: keyof T | ((record: T, index: number) => string | number);
|
|
31
22
|
rowSelection?: RowSelection<T>;
|
|
32
23
|
pagination?: PaginationProps;
|
|
33
24
|
loading?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* 统一配置 column width 默认100px
|
|
36
|
-
* 会被columns[number].width覆盖
|
|
37
|
-
*/
|
|
38
25
|
defaultColumnWidth?: number;
|
|
39
26
|
}
|
|
40
27
|
export declare function DataTable<T = Record<string, unknown>>({ columns, data: pData, loading, rowKey, rowSelection, defaultColumnWidth, pagination: pPagination, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
41
28
|
export { ActionBtn } from './ActionBtn';
|
|
42
29
|
export type { ActionBtnProps } from './ActionBtn';
|
|
43
|
-
export type { DataTableProps, RowSelection };
|
|
44
|
-
//# sourceMappingURL=
|
|
30
|
+
export type { DataTableProps, RowSelection, TableColumnDef };
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,34 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import noResult from '@tc/ui-react/assets/table/no-result.svg';
|
|
3
|
+
import { useI18n } from '../../i18n';
|
|
3
4
|
import { useMemo, useState } from 'react';
|
|
5
|
+
import { Checkbox } from '../Checkbox';
|
|
4
6
|
import { Pagination } from '../Pagination';
|
|
5
7
|
import { Skeleton } from '../Skeleton';
|
|
6
8
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '../table';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
import { ActionBtn } from './ActionBtn';
|
|
10
|
+
const defaultRowKey = 'id';
|
|
11
|
+
const getRowKey = (record, index, rowKey = defaultRowKey) => {
|
|
12
|
+
if (typeof rowKey === 'function') {
|
|
13
|
+
return rowKey(record, index);
|
|
14
|
+
}
|
|
15
|
+
const key = record[rowKey];
|
|
16
|
+
return typeof key === 'string' || typeof key === 'number' ? key : index;
|
|
17
|
+
};
|
|
18
|
+
const renderCellContent = (column, value, record, rowIndex, hasAction) => {
|
|
19
|
+
if (hasAction && column.actions) {
|
|
20
|
+
const actions = typeof column.actions === 'function' ? column.actions(value, record, rowIndex) : column.actions;
|
|
21
|
+
return (_jsx("div", { className: "flex w-full min-w-0 justify-center", children: _jsx(ActionBtn, { actions: actions, overflow: column.actionOverflow ?? 'auto' }) }));
|
|
22
|
+
}
|
|
23
|
+
return column.render ? column.render(value, record, rowIndex) : value;
|
|
24
|
+
};
|
|
25
|
+
export function DataTable({ columns, data: pData, loading, rowKey = defaultRowKey, rowSelection, defaultColumnWidth = 100, pagination: pPagination, }) {
|
|
26
|
+
const t = useI18n();
|
|
15
27
|
const getCellValue = (record, column) => record[(column.dataIndex || column.key)];
|
|
16
28
|
const isControlled = rowSelection && Array.isArray(rowSelection.selectedRowKeys);
|
|
17
29
|
const [innerSelectedRowKeys, setInnerSelectedRowKeys] = useState(rowSelection?.defaultSelectedRowKeys ?? []);
|
|
18
30
|
const selectedRowKeys = (isControlled ? rowSelection?.selectedRowKeys : innerSelectedRowKeys) ?? [];
|
|
19
31
|
const selectedKeySet = new Set(selectedRowKeys);
|
|
20
32
|
const [currentPage, setCurrentPage] = useState(1);
|
|
21
|
-
const { showPagination, pagination, data } = useMemo(() => {
|
|
33
|
+
const { showPagination, pagination, data, pageStartIndex } = useMemo(() => {
|
|
22
34
|
let pagination;
|
|
23
35
|
let data = pData;
|
|
24
36
|
let showPagination;
|
|
25
|
-
|
|
37
|
+
let pageStartIndex = 0;
|
|
26
38
|
if (pPagination) {
|
|
27
39
|
pagination = pPagination;
|
|
28
40
|
showPagination = pagination.total > 0;
|
|
29
41
|
}
|
|
30
42
|
else {
|
|
31
|
-
// 使用内部
|
|
32
43
|
pagination = {
|
|
33
44
|
onChange(v) {
|
|
34
45
|
setCurrentPage(v);
|
|
@@ -38,16 +49,17 @@ export function DataTable({ columns, data: pData, loading, rowKey = 'id', rowSel
|
|
|
38
49
|
total: pData.length,
|
|
39
50
|
};
|
|
40
51
|
showPagination = pData.length > pagination.pageSize;
|
|
41
|
-
|
|
52
|
+
pageStartIndex = (pagination.current - 1) * pagination.pageSize;
|
|
53
|
+
data = pData.slice(pageStartIndex, pagination.current * pagination.pageSize);
|
|
42
54
|
}
|
|
43
55
|
return {
|
|
44
56
|
showPagination,
|
|
45
57
|
pagination,
|
|
46
58
|
data,
|
|
59
|
+
pageStartIndex,
|
|
47
60
|
};
|
|
48
61
|
}, [currentPage, pData, pPagination]);
|
|
49
|
-
|
|
50
|
-
const pageRowKeys = pData.map((record, index) => getRowKey(record, index));
|
|
62
|
+
const pageRowKeys = data.map((record, index) => getRowKey(record, pageStartIndex + index, rowKey));
|
|
51
63
|
const handleRowSelectChange = (key) => {
|
|
52
64
|
if (!rowSelection)
|
|
53
65
|
return;
|
|
@@ -55,7 +67,7 @@ export function DataTable({ columns, data: pData, loading, rowKey = 'id', rowSel
|
|
|
55
67
|
? selectedRowKeys.filter((k) => k !== key)
|
|
56
68
|
: [...selectedRowKeys, key];
|
|
57
69
|
const nextSelectedKeySet = new Set(nextSelectedKeys);
|
|
58
|
-
const selectedRows = pData.filter((record, index) => nextSelectedKeySet.has(getRowKey(record, index)));
|
|
70
|
+
const selectedRows = pData.filter((record, index) => nextSelectedKeySet.has(getRowKey(record, index, rowKey)));
|
|
59
71
|
if (!isControlled) {
|
|
60
72
|
setInnerSelectedRowKeys(nextSelectedKeys);
|
|
61
73
|
}
|
|
@@ -70,10 +82,8 @@ export function DataTable({ columns, data: pData, loading, rowKey = 'id', rowSel
|
|
|
70
82
|
const pageKeySet = new Set(pageRowKeys);
|
|
71
83
|
nextSelectedKeys = Array.from(new Set([
|
|
72
84
|
...selectedRowKeys,
|
|
73
|
-
//
|
|
74
85
|
...pageRowKeys.filter((key) => !selectedKeySet.has(key)),
|
|
75
86
|
]))
|
|
76
|
-
//
|
|
77
87
|
.filter((key) => pageKeySet.has(key) || selectedKeySet.has(key));
|
|
78
88
|
}
|
|
79
89
|
else {
|
|
@@ -81,27 +91,23 @@ export function DataTable({ columns, data: pData, loading, rowKey = 'id', rowSel
|
|
|
81
91
|
nextSelectedKeys = selectedRowKeys.filter((key) => !pageKeySet.has(key));
|
|
82
92
|
}
|
|
83
93
|
const nextSelectedKeySet = new Set(nextSelectedKeys);
|
|
84
|
-
const selectedRows = pData.filter((record, index) => nextSelectedKeySet.has(getRowKey(record, index)));
|
|
94
|
+
const selectedRows = pData.filter((record, index) => nextSelectedKeySet.has(getRowKey(record, index, rowKey)));
|
|
85
95
|
if (!isControlled) {
|
|
86
96
|
setInnerSelectedRowKeys(nextSelectedKeys);
|
|
87
97
|
}
|
|
88
98
|
rowSelection.onChange?.(nextSelectedKeys, selectedRows, checked);
|
|
89
99
|
};
|
|
90
100
|
const allChecked = rowSelection
|
|
91
|
-
? rowSelection.isAll ?? (pageRowKeys.length > 0 && pageRowKeys.every((key) => selectedKeySet.has(key)))
|
|
101
|
+
? (rowSelection.isAll ?? (pageRowKeys.length > 0 && pageRowKeys.every((key) => selectedKeySet.has(key))))
|
|
92
102
|
: false;
|
|
93
103
|
const partiallyChecked = rowSelection ? pageRowKeys.some((key) => selectedKeySet.has(key)) && !allChecked : false;
|
|
94
|
-
return (_jsxs("div", { className: "bg-
|
|
104
|
+
return (_jsxs("div", { className: "tc-ui-data-table bg-background rounded-[20px] overflow-hidden relative", children: [_jsxs(Table, { containerClassName: "rounded-b-none overflow-x-auto", children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [rowSelection && (_jsxs(TableHead, { className: "bg-table-header", style: {
|
|
95
105
|
width: '48px',
|
|
96
106
|
minWidth: '48px',
|
|
97
107
|
position: 'sticky',
|
|
98
108
|
left: 0,
|
|
99
109
|
zIndex: 10,
|
|
100
|
-
}, children: [rowSelection.beforeCheckboxNode, _jsx(
|
|
101
|
-
if (el) {
|
|
102
|
-
el.indeterminate = partiallyChecked;
|
|
103
|
-
}
|
|
104
|
-
}, onChange: handleSelectAllChange })] })), columns.map((column) => {
|
|
110
|
+
}, children: [rowSelection.beforeCheckboxNode, _jsx(Checkbox, { checked: allChecked, "aria-label": "Select all rows", indeterminate: partiallyChecked, onChange: (_, event) => handleSelectAllChange(event) })] })), columns.map((column) => {
|
|
105
111
|
const hasAction = column.isAction ?? column.key === 'action';
|
|
106
112
|
return (_jsx(TableHead, { isAction: hasAction, style: {
|
|
107
113
|
...(hasAction
|
|
@@ -115,27 +121,31 @@ export function DataTable({ columns, data: pData, loading, rowKey = 'id', rowSel
|
|
|
115
121
|
? { width: column.width, minWidth: column.width }
|
|
116
122
|
: { minWidth: defaultColumnWidth }),
|
|
117
123
|
}, children: column.title }, column.key));
|
|
118
|
-
})] }) }), _jsx(TableBody, { children: data.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (rowSelection ? 1 : 0), className: "text-muted-foreground", children: _jsxs("div", { className: "flex flex-col items-center w-full gap-2.5", children: [_jsx("img", { src: noResult, alt:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
124
|
+
})] }) }), _jsx(TableBody, { children: data.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (rowSelection ? 1 : 0), className: "text-muted-foreground", children: _jsxs("div", { className: "flex flex-col items-center w-full gap-2.5", children: [_jsx("img", { src: noResult, alt: t('components.dataTable.noData'), className: " w-24 h-24" }), t('components.dataTable.noData')] }) }) })) : (data.map((record, rowIndex) => {
|
|
125
|
+
const absoluteRowIndex = pageStartIndex + rowIndex;
|
|
126
|
+
const recordKey = getRowKey(record, absoluteRowIndex, rowKey);
|
|
127
|
+
return (_jsxs(TableRow, { children: [rowSelection && (_jsx(TableCell, { className: "bg-background", style: {
|
|
128
|
+
width: '48px',
|
|
129
|
+
minWidth: '48px',
|
|
130
|
+
position: 'sticky',
|
|
131
|
+
left: 0,
|
|
132
|
+
zIndex: 1,
|
|
133
|
+
}, children: _jsx(Checkbox, { checked: selectedKeySet.has(recordKey), "aria-label": "Select row", onChange: () => handleRowSelectChange(recordKey) }) })), columns.map((column) => {
|
|
134
|
+
const value = getCellValue(record, column);
|
|
135
|
+
const hasAction = column.isAction ?? column.key === 'action';
|
|
136
|
+
return (_jsx(TableCell, { isAction: hasAction, style: {
|
|
137
|
+
...(hasAction
|
|
138
|
+
? {
|
|
139
|
+
position: 'sticky',
|
|
140
|
+
right: 0,
|
|
141
|
+
zIndex: 1,
|
|
142
|
+
}
|
|
143
|
+
: undefined),
|
|
144
|
+
...(column.width
|
|
145
|
+
? { width: column.width, minWidth: column.width }
|
|
146
|
+
: { minWidth: defaultColumnWidth }),
|
|
147
|
+
}, children: renderCellContent(column, value, record, rowIndex, hasAction) }, column.key));
|
|
148
|
+
})] }, recordKey));
|
|
149
|
+
})) })] }), loading && (_jsx("div", { className: "absolute inset-0 rounded-[20px] bg-background/70 text-sm text-gray-600 z-[100]", children: _jsx(Skeleton, { mode: "tableloading", rows: 8 }) })), showPagination && (_jsx("div", { className: "px-6 pb-6 mt-6", children: _jsx(Pagination, { ...pagination }) }))] }));
|
|
140
150
|
}
|
|
141
151
|
export { ActionBtn } from './ActionBtn';
|
|
@@ -5,13 +5,7 @@ export type DateRange = {
|
|
|
5
5
|
to?: Date | undefined;
|
|
6
6
|
};
|
|
7
7
|
export type QuickRangePreset = {
|
|
8
|
-
/**
|
|
9
|
-
* 展示文案
|
|
10
|
-
*/
|
|
11
8
|
label: string;
|
|
12
|
-
/**
|
|
13
|
-
* 返回一个范围对象
|
|
14
|
-
*/
|
|
15
9
|
getRange: () => DateRange;
|
|
16
10
|
};
|
|
17
11
|
export interface CalendarProps {
|
|
@@ -21,14 +15,7 @@ export interface CalendarProps {
|
|
|
21
15
|
disabledDate?: (date: Date) => boolean;
|
|
22
16
|
showTime?: boolean;
|
|
23
17
|
className?: string;
|
|
24
|
-
/**
|
|
25
|
-
* 自定义文案配置,会覆盖默认文案
|
|
26
|
-
*/
|
|
27
18
|
locale?: Partial<DateLocaleConfig>;
|
|
28
|
-
/**
|
|
29
|
-
* 范围模式下的快捷选择配置
|
|
30
|
-
* 不传则使用默认预设
|
|
31
|
-
*/
|
|
32
19
|
quickRanges?: QuickRangePreset[];
|
|
33
20
|
}
|
|
34
21
|
export declare function Calendar({ mode, value, onChange, disabledDate, showTime, className, locale: customLocale, quickRanges, }: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,15 +4,14 @@ import { addMonths, addYears, eachDayOfInterval, endOfDay, endOfMonth, endOfWeek
|
|
|
4
4
|
import { zhCN } from 'date-fns/locale';
|
|
5
5
|
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
|
|
6
6
|
import { useMemo, useState } from 'react';
|
|
7
|
+
import { Button } from '../Button';
|
|
7
8
|
import { ModeType } from './data';
|
|
8
9
|
import { useDateLocale } from './LocaleContext';
|
|
9
10
|
import { TimePicker } from './TimePicker';
|
|
10
11
|
export function Calendar({ mode = ModeType.Single, value, onChange, disabledDate, showTime, className, locale: customLocale, quickRanges, }) {
|
|
11
12
|
const contextLocale = useDateLocale();
|
|
12
13
|
const locale = useMemo(() => ({ ...contextLocale, ...customLocale }), [contextLocale, customLocale]);
|
|
13
|
-
// Pending value for showTime mode (confirmed on button click)
|
|
14
14
|
const [pendingValue, setPendingValue] = useState(value ?? null);
|
|
15
|
-
// 当前显示的月份
|
|
16
15
|
const [currentMonth, setCurrentMonth] = useState(() => {
|
|
17
16
|
if (value instanceof Date)
|
|
18
17
|
return value;
|
|
@@ -20,9 +19,7 @@ export function Calendar({ mode = ModeType.Single, value, onChange, disabledDate
|
|
|
20
19
|
return value.from;
|
|
21
20
|
return new Date();
|
|
22
21
|
});
|
|
23
|
-
// 悬停日期(用于范围选择预览)
|
|
24
22
|
const [hoverDate, setHoverDate] = useState(null);
|
|
25
|
-
// 生成日历网格数据
|
|
26
23
|
const days = useMemo(() => {
|
|
27
24
|
const monthStart = startOfMonth(currentMonth);
|
|
28
25
|
const monthEnd = endOfMonth(monthStart);
|
|
@@ -110,7 +107,6 @@ export function Calendar({ mode = ModeType.Single, value, onChange, disabledDate
|
|
|
110
107
|
const handleDateClick = (date) => {
|
|
111
108
|
if (disabledDate?.(date))
|
|
112
109
|
return;
|
|
113
|
-
// Preserve time when showTime is enabled
|
|
114
110
|
let dateWithTime = date;
|
|
115
111
|
if (showTime && pendingValue instanceof Date) {
|
|
116
112
|
dateWithTime = new Date(date);
|
|
@@ -120,7 +116,6 @@ export function Calendar({ mode = ModeType.Single, value, onChange, disabledDate
|
|
|
120
116
|
dateWithTime.setMilliseconds(0);
|
|
121
117
|
}
|
|
122
118
|
if (showTime) {
|
|
123
|
-
// In showTime mode, store in pending value
|
|
124
119
|
if (mode === ModeType.Single) {
|
|
125
120
|
setPendingValue(dateWithTime);
|
|
126
121
|
}
|
|
@@ -140,7 +135,6 @@ export function Calendar({ mode = ModeType.Single, value, onChange, disabledDate
|
|
|
140
135
|
}
|
|
141
136
|
}
|
|
142
137
|
else {
|
|
143
|
-
// Without showTime, directly call onChange
|
|
144
138
|
if (mode === ModeType.Single) {
|
|
145
139
|
onChange?.(dateWithTime);
|
|
146
140
|
}
|
|
@@ -190,16 +184,14 @@ export function Calendar({ mode = ModeType.Single, value, onChange, disabledDate
|
|
|
190
184
|
const handleTimeChangeInternal = (date) => {
|
|
191
185
|
setPendingValue(date);
|
|
192
186
|
};
|
|
193
|
-
return (_jsxs("div", { className: cn('p-3', showTime || isRangeMode ? 'flex flex-col' : 'w-[280px]', className), children: [_jsxs("div", { className: cn('flex', (showTime || isRangeMode) && 'gap-4'), children: [isRangeMode && (_jsxs("div", { className: "w-[140px] pr-3 border-r border-border", children: [_jsx("div", { className: "text-xs font-medium text-muted-foreground mb-2", children: locale.quickRanges }), _jsx("div", { className: "space-y-1", children: quickRangePresets.map((preset) => (_jsx("
|
|
187
|
+
return (_jsxs("div", { className: cn('tc-ui-calendar p-3', showTime || isRangeMode ? 'flex flex-col' : 'w-[280px]', className), children: [_jsxs("div", { className: cn('flex', (showTime || isRangeMode) && 'gap-4'), children: [isRangeMode && (_jsxs("div", { className: "w-[140px] pr-3 border-r border-border", children: [_jsx("div", { className: "text-xs font-medium text-muted-foreground mb-2", children: locale.quickRanges }), _jsx("div", { className: "space-y-1", children: quickRangePresets.map((preset) => (_jsx(Button, { variant: "text", type: "button", onClick: () => handleQuickRangeClick(preset.getRange), className: cn('w-full justify-start text-left text-xs px-2 py-1 rounded', 'text-foreground hover:bg-muted transition-colors'), children: preset.label }, preset.label))) })] })), _jsxs("div", { className: "w-[280px]", children: [_jsxs("div", { className: "flex items-center justify-between mb-4", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "text", onClick: prevYear, className: "p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground transition-colors", type: "button", children: _jsx(ChevronsLeft, { size: 16 }) }), _jsx(Button, { variant: "text", onClick: prevMonth, className: "p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground transition-colors", type: "button", children: _jsx(ChevronLeft, { size: 16 }) })] }), _jsx("div", { className: "font-medium text-sm", children: format(currentMonth, locale.monthFormat, { locale: zhCN }) }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "text", onClick: nextMonth, className: "p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground transition-colors", type: "button", children: _jsx(ChevronRight, { size: 16 }) }), _jsx(Button, { variant: "text", onClick: nextYear, className: "p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground transition-colors", type: "button", children: _jsx(ChevronsRight, { size: 16 }) })] })] }), _jsx("div", { className: "grid grid-cols-7 mb-2", children: weekDays.map((day) => (_jsx("div", { className: "text-center text-xs text-muted-foreground font-medium py-1", children: day }, day))) }), _jsx("div", { className: "grid grid-cols-7 gap-y-1", onMouseLeave: () => setHoverDate(null), children: days.map((date, i) => {
|
|
194
188
|
const selected = isSelected(date);
|
|
195
189
|
const inRange = isInRange(date);
|
|
196
190
|
const isToday = isSameDay(date, new Date());
|
|
197
191
|
const isCurrentMonth = isSameMonth(date, currentMonth);
|
|
198
192
|
const isDisabled = disabledDate?.(date);
|
|
199
|
-
return (_jsx("div", { className: "flex justify-center p-0", children: _jsx("
|
|
200
|
-
}) })] }), showTime && (_jsx("div", { className: "flex flex-col border-l border-border pl-4", children: mode === ModeType.Single ? (_jsxs("div", { className: "flex flex-col justify-center h-full", children: [_jsx("div", { className: "text-xs font-medium text-muted-foreground mb-3 text-center", children: locale.selectTime }), _jsx(TimePicker, { value: pendingValue instanceof Date ? pendingValue : undefined, onChange: handleTimeChangeInternal, className: "border-0" })] })) : (
|
|
201
|
-
// Range mode: show two time pickers
|
|
202
|
-
_jsxs("div", { className: "space-y-4 flex flex-col justify-center h-full", children: [_jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium text-muted-foreground mb-2 text-center", children: locale.startTime }), _jsx(TimePicker, { value: pendingValue && 'from' in pendingValue && pendingValue.from ? pendingValue.from : undefined, onChange: (newDate) => {
|
|
193
|
+
return (_jsx("div", { className: "flex justify-center p-0", children: _jsx(Button, { variant: "text", type: "button", onClick: () => handleDateClick(date), onMouseEnter: () => setHoverDate(date), disabled: isDisabled, className: cn('w-8 h-8 flex items-center justify-center rounded text-sm transition-colors relative z-10', !isCurrentMonth && 'text-muted-foreground/40', isCurrentMonth && !selected && !inRange && !isDisabled && 'text-foreground hover:bg-muted', selected && 'bg-theme text-theme-foreground hover:bg-theme/90', inRange && !selected && 'bg-theme/10 text-theme', !selected && !inRange && isToday && 'border border-theme text-theme', isDisabled && 'text-muted-foreground cursor-not-allowed hover:bg-transparent opacity-50'), children: format(date, 'd') }) }, i));
|
|
194
|
+
}) })] }), showTime && (_jsx("div", { className: "flex flex-col border-l border-border pl-4", children: mode === ModeType.Single ? (_jsxs("div", { className: "flex flex-col justify-center h-full", children: [_jsx("div", { className: "text-xs font-medium text-muted-foreground mb-3 text-center", children: locale.selectTime }), _jsx(TimePicker, { value: pendingValue instanceof Date ? pendingValue : undefined, onChange: handleTimeChangeInternal, className: "border-0" })] })) : (_jsxs("div", { className: "space-y-4 flex flex-col justify-center h-full", children: [_jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium text-muted-foreground mb-2 text-center", children: locale.startTime }), _jsx(TimePicker, { value: pendingValue && 'from' in pendingValue && pendingValue.from ? pendingValue.from : undefined, onChange: (newDate) => {
|
|
203
195
|
const range = pendingValue;
|
|
204
196
|
setPendingValue({
|
|
205
197
|
from: newDate,
|
|
@@ -211,5 +203,5 @@ export function Calendar({ mode = ModeType.Single, value, onChange, disabledDate
|
|
|
211
203
|
from: range?.from,
|
|
212
204
|
to: newDate,
|
|
213
205
|
});
|
|
214
|
-
}, className: "border-0" })] }))] })) }))] }), showTime && (_jsx("div", { className: "pt-3 mt-3 border-t border-border", children: _jsx("
|
|
206
|
+
}, className: "border-0" })] }))] })) }))] }), showTime && (_jsx("div", { className: "pt-3 mt-3 border-t border-border", children: _jsx(Button, { variant: "primary", type: "button", onClick: handleConfirm, className: cn('w-full py-2 px-4 rounded', 'bg-theme text-theme-foreground', 'hover:bg-theme/90 transition-colors', 'text-sm font-medium'), children: locale.confirm }) }))] }));
|
|
215
207
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type DateRange, type QuickRangePreset } from
|
|
2
|
-
import { ModeType } from
|
|
3
|
-
import { type DateLocaleConfig } from
|
|
1
|
+
import { type DateRange, type QuickRangePreset } from "./Calendar";
|
|
2
|
+
import { ModeType } from "./data";
|
|
3
|
+
import { type DateLocaleConfig } from "./locales";
|
|
4
4
|
export type DateChangeStrValue = [string, string] | string;
|
|
5
5
|
type DateBaseValue = Date | DateRange;
|
|
6
6
|
type Dates = DateBaseValue | [Date, Date];
|
|
@@ -9,9 +9,6 @@ export type DatePickerProps = {
|
|
|
9
9
|
mode?: ModeType;
|
|
10
10
|
value?: DateValue;
|
|
11
11
|
defaultValue?: DateValue;
|
|
12
|
-
/**
|
|
13
|
-
* @default 'yyyy-MM-dd'
|
|
14
|
-
*/
|
|
15
12
|
format?: string;
|
|
16
13
|
placeholder?: string;
|
|
17
14
|
disabled?: boolean;
|
|
@@ -20,15 +17,9 @@ export type DatePickerProps = {
|
|
|
20
17
|
onChange?: (value?: DateChangeStrValue, date?: Dates) => void;
|
|
21
18
|
disabledDate?: (current: Date) => boolean;
|
|
22
19
|
className?: string;
|
|
23
|
-
/**
|
|
24
|
-
* 自定义文案配置,会覆盖默认文案
|
|
25
|
-
*/
|
|
26
20
|
locale?: Partial<DateLocaleConfig>;
|
|
27
|
-
/**
|
|
28
|
-
* 范围模式下的快捷选择配置
|
|
29
|
-
* 不传则使用默认预设
|
|
30
|
-
*/
|
|
31
21
|
quickRanges?: QuickRangePreset[];
|
|
22
|
+
getPopupContainer?: () => HTMLElement;
|
|
32
23
|
};
|
|
33
24
|
declare const DatePicker: import("react").ForwardRefExoticComponent<DatePickerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
25
|
export { DatePicker };
|