@_tc/template-core 0.0.1-bate.36 → 0.0.1-bate.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/app/controller/base.js +3 -3
- package/cjs/app/controller/project.js +1 -1
- package/cjs/app/controller/view.js +16 -7
- package/cjs/app/middleware/api-params-verify.js +10 -1
- package/cjs/app/middleware/error-handle.js +9 -3
- package/cjs/app/middleware/project-handler.js +1 -1
- package/cjs/app/router/view.js +3 -1
- package/cjs/app/router-schema/project.js +1 -1
- package/cjs/app/service/project.js +5 -0
- package/cjs/bundler/defaultAlias.js +5 -0
- package/cjs/bundler/dev.js +4 -3
- package/cjs/bundler/index.js +2 -1
- package/cjs/bundler/prod.js +4 -3
- package/cjs/bundler/utils.js +53 -24
- package/cjs/packages/common/LRUCache.js +4 -0
- package/cjs/packages/common/array/index.js +43 -0
- package/cjs/packages/common/cache/LRUCache.js +45 -0
- package/cjs/packages/common/cache/index.js +4 -0
- package/cjs/packages/common/guards/index.js +34 -0
- package/cjs/packages/common/i18n/default.js +95 -0
- package/cjs/packages/common/i18n/en-US.js +95 -0
- package/cjs/packages/common/i18n/index.js +178 -0
- package/cjs/packages/common/i18n/locales.js +17 -0
- package/cjs/packages/common/i18n/types.js +1 -0
- package/cjs/packages/common/index.js +65 -0
- package/cjs/packages/common/log/index.js +160 -0
- package/cjs/packages/common/number/index.js +14 -0
- package/cjs/packages/common/object/filterEmpty.js +32 -0
- package/cjs/packages/common/object/filtereEmpty.js +5 -0
- package/cjs/packages/common/object/index.js +26 -0
- package/cjs/packages/common/string/index.js +17 -0
- package/cjs/packages/common/types/index.js +1 -0
- package/cjs/packages/core/index.js +17 -12
- package/cjs/packages/core/loader/model.js +3 -3
- package/cjs/packages/core/loader/router.js +14 -5
- package/esm/app/controller/base.js +3 -3
- package/esm/app/controller/project.js +3 -3
- package/esm/app/controller/view.js +16 -7
- package/esm/app/middleware/api-params-verify.js +10 -1
- package/esm/app/middleware/error-handle.js +9 -3
- package/esm/app/middleware/project-handler.js +1 -1
- package/esm/app/router/view.js +3 -1
- package/esm/app/router-schema/project.js +1 -1
- package/esm/app/service/project.js +5 -0
- package/esm/bundler/defaultAlias.js +4 -0
- package/esm/bundler/dev.js +4 -3
- package/esm/bundler/index.js +2 -1
- package/esm/bundler/prod.js +4 -3
- package/esm/bundler/utils.js +53 -24
- package/esm/index.js +2 -2
- package/esm/packages/common/LRUCache.js +2 -0
- package/esm/packages/common/array/index.js +37 -0
- package/esm/packages/common/cache/LRUCache.js +43 -0
- package/esm/packages/common/cache/index.js +2 -0
- package/esm/packages/common/guards/index.js +26 -0
- package/esm/packages/common/i18n/default.js +93 -0
- package/esm/packages/common/i18n/en-US.js +93 -0
- package/esm/packages/common/i18n/index.js +162 -0
- package/esm/packages/common/i18n/locales.js +11 -0
- package/esm/packages/common/i18n/types.js +0 -0
- package/esm/packages/common/index.js +13 -0
- package/esm/packages/common/log/index.js +146 -0
- package/esm/packages/common/number/index.js +11 -0
- package/esm/packages/common/object/filterEmpty.js +29 -0
- package/esm/packages/common/object/filtereEmpty.js +2 -0
- package/esm/packages/common/object/index.js +20 -0
- package/esm/packages/common/string/index.js +13 -0
- package/esm/packages/common/types/index.js +0 -0
- package/esm/packages/core/index.js +17 -12
- package/esm/packages/core/loader/model.js +3 -3
- package/esm/packages/core/loader/router.js +14 -5
- package/fe/frontend/dash/Dashboard.d.ts +7 -0
- package/fe/frontend/dash/Dashboard.js +63 -0
- package/fe/frontend/dash/dash.entry.d.ts +2 -0
- package/fe/frontend/dash/dash.entry.js +62 -0
- package/fe/frontend/index.d.ts +3 -0
- package/fe/frontend/index.js +1 -0
- package/fe/frontend/main.css +2 -184
- package/fe/frontend/main.d.ts +10 -3
- package/fe/frontend/main.js +13 -4
- package/fe/frontend/testPage/testPage.entry.js +1 -2
- package/fe/frontend/typing/window.d.ts +7 -0
- package/fe/frontend/typing/window.js +1 -0
- package/fe/frontend/widgets/api/baseInfo.d.ts +31 -0
- package/fe/frontend/widgets/api/baseInfo.js +15 -0
- package/fe/frontend/widgets/common/CRUD/CRUD.d.ts +70 -0
- package/fe/frontend/widgets/common/CRUD/CRUD.js +207 -0
- package/fe/frontend/widgets/common/CRUD/index.d.ts +2 -0
- package/fe/frontend/widgets/common/CRUD/index.js +1 -0
- package/fe/frontend/widgets/common/auth/index.d.ts +7 -0
- package/fe/frontend/widgets/common/auth/index.js +20 -0
- package/fe/frontend/widgets/common/generateMenuData.d.ts +4 -0
- package/fe/frontend/widgets/common/generateMenuData.js +14 -0
- package/fe/frontend/widgets/common/importComponent.d.ts +5 -0
- package/fe/frontend/widgets/common/importComponent.js +7 -0
- package/fe/frontend/widgets/common/language.d.ts +2 -0
- package/fe/frontend/widgets/common/language.js +8 -0
- package/fe/frontend/widgets/common/logFn/index.d.ts +4 -0
- package/fe/frontend/widgets/common/logFn/index.js +8 -0
- package/fe/frontend/widgets/common/menu.d.ts +22 -0
- package/fe/frontend/widgets/common/menu.js +80 -0
- package/fe/frontend/widgets/common/request.d.ts +33 -0
- package/fe/frontend/widgets/common/request.js +127 -0
- package/fe/frontend/widgets/components/BasePage/HeaderView.d.ts +9 -0
- package/fe/frontend/widgets/components/BasePage/HeaderView.js +14 -0
- package/fe/frontend/widgets/components/Router/index.d.ts +9 -0
- package/fe/frontend/widgets/components/Router/index.js +11 -0
- package/fe/frontend/widgets/components/Router/type.d.ts +2 -0
- package/fe/frontend/widgets/components/Router/type.js +1 -0
- package/fe/frontend/widgets/defaultPages/Iframe/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Iframe/index.js +14 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/DetailPanel.d.ts +7 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/DetailPanel.js +94 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.d.ts +13 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.js +109 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/data.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/data.js +6 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.js +58 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.d.ts +11 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.js +176 -0
- package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.d.ts +8 -0
- package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.js +6 -0
- package/fe/frontend/widgets/defaultPages/Schema/data/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/data/index.js +1 -0
- package/fe/frontend/widgets/defaultPages/Schema/hooks/useComConfig.d.ts +10 -0
- package/fe/frontend/widgets/defaultPages/Schema/hooks/useComConfig.js +14 -0
- package/fe/frontend/widgets/defaultPages/Schema/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/index.js +67 -0
- package/fe/frontend/widgets/defaultPages/Schema/schemaType.d.ts +41 -0
- package/fe/frontend/widgets/defaultPages/Schema/schemaType.js +4 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.d.ts +23 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.js +66 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.d.ts +33 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.js +24 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/fetchErrorShow.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/fetchErrorShow.js +8 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/permissions.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/permissions.js +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.js +72 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.d.ts +4 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.js +31 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.d.ts +10 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +31 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.js +15 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPageTmp.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPageTmp.js +17 -0
- package/fe/frontend/widgets/defaultPages/SlotPage/index.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/SlotPage/index.js +24 -0
- package/fe/frontend/widgets/defaultPages/Todo.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Todo.js +5 -0
- package/fe/frontend/widgets/hooks/useCurrentMenuData.d.ts +11 -0
- package/fe/frontend/widgets/hooks/useCurrentMenuData.js +20 -0
- package/fe/frontend/widgets/hooks/useRouterParams.d.ts +5 -0
- package/fe/frontend/widgets/hooks/useRouterParams.js +11 -0
- package/fe/frontend/widgets/store/mode.d.ts +16 -0
- package/fe/frontend/widgets/store/mode.js +36 -0
- package/fe/model/types/data/button.d.ts +23 -0
- package/fe/model/types/data/button.js +1 -0
- package/fe/model/types/data/component.d.ts +37 -0
- package/fe/model/types/data/component.js +1 -0
- package/fe/model/types/data/fetchInfo.d.ts +8 -0
- package/fe/model/types/data/fetchInfo.js +1 -0
- package/fe/model/types/data/schema.d.ts +47 -0
- package/fe/model/types/data/schema.js +1 -0
- package/fe/model/types/data/search.d.ts +7 -0
- package/fe/model/types/data/search.js +1 -0
- package/fe/model/types/menuType.d.ts +44 -0
- package/fe/model/types/menuType.js +1 -0
- package/fe/model/types/model.d.ts +20 -0
- package/fe/model/types/model.js +1 -0
- package/fe/packages/common/array/index.d.ts +7 -0
- package/fe/packages/common/array/index.js +40 -0
- package/fe/packages/common/cache/LRUCache.d.ts +13 -0
- package/fe/packages/common/cache/LRUCache.js +47 -0
- package/fe/packages/common/cache/index.d.ts +2 -0
- package/fe/packages/common/cache/index.js +1 -0
- package/fe/packages/common/guards/index.d.ts +9 -0
- package/fe/packages/common/guards/index.js +24 -0
- package/fe/packages/common/i18n/default.d.ts +87 -0
- package/fe/packages/common/i18n/default.js +85 -0
- package/fe/packages/common/i18n/en-US.d.ts +87 -0
- package/fe/packages/common/i18n/en-US.js +85 -0
- package/fe/packages/common/i18n/index.d.ts +19 -0
- package/fe/packages/common/i18n/index.js +142 -0
- package/fe/packages/common/i18n/locales.d.ts +8 -0
- package/fe/packages/common/i18n/locales.js +10 -0
- package/fe/packages/common/i18n/types.d.ts +47 -0
- package/fe/packages/common/i18n/types.js +1 -0
- package/fe/packages/common/index.d.ts +10 -0
- package/fe/packages/common/index.js +9 -0
- package/fe/packages/common/log/index.d.ts +33 -0
- package/fe/packages/common/log/index.js +176 -0
- package/fe/packages/common/number/index.d.ts +3 -0
- package/fe/packages/common/number/index.js +10 -0
- package/fe/packages/common/object/filterEmpty.d.ts +3 -0
- package/fe/packages/common/object/filterEmpty.js +33 -0
- package/fe/packages/common/object/index.d.ts +5 -0
- package/fe/packages/common/object/index.js +25 -0
- package/fe/packages/common/string/index.d.ts +4 -0
- package/fe/packages/common/string/index.js +17 -0
- package/fe/packages/common/types/index.d.ts +4 -0
- package/fe/packages/common/types/index.js +1 -0
- package/fe/packages/ui/react/components/Button/Button.d.ts +16 -30
- package/fe/packages/ui/react/components/Button/Button.js +53 -26
- package/fe/packages/ui/react/components/Button/SumbitButton.d.ts +2 -6
- package/fe/packages/ui/react/components/Button/SumbitButton.js +3 -14
- package/fe/packages/ui/react/components/Button/index.d.ts +1 -1
- package/fe/packages/ui/react/components/Checkbox/Checkbox.d.ts +1 -1
- package/fe/packages/ui/react/components/Checkbox/Checkbox.js +5 -3
- package/fe/packages/ui/react/components/{ConfirmDialog.d.ts → ConfirmDialog/ConfirmDialog.d.ts} +0 -8
- package/fe/packages/ui/react/components/ConfirmDialog/ConfirmDialog.js +11 -0
- package/fe/packages/ui/react/components/ConfirmDialog/index.d.ts +2 -0
- package/fe/packages/ui/react/components/ConfirmDialog/index.js +1 -0
- package/fe/packages/ui/react/components/DataTable/ActionBtn.d.ts +3 -1
- package/fe/packages/ui/react/components/DataTable/ActionBtn.js +85 -4
- package/fe/packages/ui/react/components/DataTable/{data-table.d.ts → index.d.ts} +10 -23
- package/fe/packages/ui/react/components/DataTable/{data-table.js → index.js} +57 -47
- package/fe/packages/ui/react/components/Date/Calendar.d.ts +0 -13
- package/fe/packages/ui/react/components/Date/Calendar.js +5 -13
- package/fe/packages/ui/react/components/Date/Date.d.ts +4 -13
- package/fe/packages/ui/react/components/Date/Date.js +70 -66
- package/fe/packages/ui/react/components/Date/LocaleContext.d.ts +0 -4
- package/fe/packages/ui/react/components/Date/LocaleContext.js +0 -4
- package/fe/packages/ui/react/components/Date/LocaleProvider.d.ts +0 -11
- package/fe/packages/ui/react/components/Date/LocaleProvider.js +0 -11
- package/fe/packages/ui/react/components/Date/TimePicker.js +3 -2
- package/fe/packages/ui/react/components/Date/dateLocaleStore.d.ts +0 -6
- package/fe/packages/ui/react/components/Date/dropdownPositioning.d.ts +3 -0
- package/fe/packages/ui/react/components/Date/dropdownPositioning.js +12 -0
- package/fe/packages/ui/react/components/Date/locales.d.ts +1 -19
- package/fe/packages/ui/react/components/Date/locales.js +7 -47
- package/fe/packages/ui/react/components/Drawer/Drawer.d.ts +23 -0
- package/fe/packages/ui/react/components/Drawer/Drawer.js +100 -0
- package/fe/packages/ui/react/components/Drawer/index.d.ts +3 -0
- package/fe/packages/ui/react/components/Drawer/index.js +1 -0
- package/fe/packages/ui/react/components/Dropdown/Dropdown.d.ts +24 -0
- package/fe/packages/ui/react/components/Dropdown/Dropdown.js +28 -0
- package/fe/packages/ui/react/components/Dropdown/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Dropdown/index.js +1 -0
- package/fe/packages/ui/react/components/Form/Form.d.ts +0 -6
- package/fe/packages/ui/react/components/Form/Form.js +1 -1
- package/fe/packages/ui/react/components/Form/FormItem.d.ts +0 -21
- package/fe/packages/ui/react/components/Form/FormItem.js +2 -9
- package/fe/packages/ui/react/components/Form/SchemaForm/data.d.ts +45 -0
- package/fe/packages/ui/react/components/Form/{SchemeForm → SchemaForm}/data.js +8 -1
- package/fe/packages/ui/react/components/Form/SchemaForm/index.d.ts +60 -0
- package/fe/packages/ui/react/components/Form/SchemaForm/index.js +75 -0
- package/fe/packages/ui/react/components/Form/index.d.ts +1 -1
- package/fe/packages/ui/react/components/Form/index.js +1 -1
- package/fe/packages/ui/react/components/ImagePreview/ImagePreview.js +15 -20
- package/fe/packages/ui/react/components/ImagePreview/PreviewImage.d.ts +0 -3
- package/fe/packages/ui/react/components/ImagePreview/PreviewImage.js +5 -2
- package/fe/packages/ui/react/components/Input/Input.d.ts +3 -21
- package/fe/packages/ui/react/components/Input/Input.js +5 -7
- package/fe/packages/ui/react/components/InputNumber/InputNumber.d.ts +26 -0
- package/fe/packages/ui/react/components/InputNumber/InputNumber.js +144 -0
- package/fe/packages/ui/react/components/InputNumber/index.d.ts +2 -0
- package/fe/packages/ui/react/components/InputNumber/index.js +1 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.d.ts +30 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.js +63 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.d.ts +2 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.js +27 -0
- package/fe/packages/ui/react/components/Label/Label.d.ts +0 -29
- package/fe/packages/ui/react/components/Label/Label.js +2 -4
- package/fe/packages/ui/react/components/Menu/Menu.d.ts +18 -0
- package/fe/packages/ui/react/components/Menu/Menu.js +98 -0
- package/fe/packages/ui/react/components/Menu/MenuContext.d.ts +39 -0
- package/fe/packages/ui/react/components/Menu/MenuContext.js +97 -0
- package/fe/packages/ui/react/components/Menu/MenuItem.d.ts +3 -0
- package/fe/packages/ui/react/components/Menu/MenuItem.js +33 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.d.ts +3 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.js +124 -0
- package/fe/packages/ui/react/components/Menu/index.d.ts +9 -0
- package/fe/packages/ui/react/components/Menu/index.js +5 -0
- package/fe/packages/ui/react/components/Menu/menuTypes.d.ts +58 -0
- package/fe/packages/ui/react/components/Menu/menuTypes.js +1 -0
- package/fe/packages/ui/react/components/Menu/utils.d.ts +2 -0
- package/fe/packages/ui/react/components/Menu/utils.js +7 -0
- package/fe/packages/ui/react/components/Message/Message.d.ts +0 -7
- package/fe/packages/ui/react/components/Message/Message.js +4 -4
- package/fe/packages/ui/react/components/Message/MessageManager.js +0 -8
- package/fe/packages/ui/react/components/Modal/Modal.d.ts +3 -7
- package/fe/packages/ui/react/components/Modal/Modal.js +6 -44
- package/fe/packages/ui/react/components/Modal/ModalManager.d.ts +0 -12
- package/fe/packages/ui/react/components/Modal/ModalManager.js +5 -7
- package/fe/packages/ui/react/components/Overlay/Overlay.d.ts +20 -0
- package/fe/packages/ui/react/components/Overlay/Overlay.js +53 -0
- package/fe/packages/ui/react/components/Overlay/index.d.ts +3 -0
- package/fe/packages/ui/react/components/Overlay/index.js +1 -0
- package/fe/packages/ui/react/components/{Pagination.d.ts → Pagination/Pagination.d.ts} +0 -7
- package/fe/packages/ui/react/components/{Pagination.js → Pagination/Pagination.js} +5 -12
- package/fe/packages/ui/react/components/Pagination/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Pagination/index.js +1 -0
- package/fe/packages/ui/react/components/Popup/Popup.d.ts +26 -0
- package/fe/packages/ui/react/components/Popup/Popup.js +69 -0
- package/fe/packages/ui/react/components/Popup/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Popup/index.js +1 -0
- package/fe/packages/ui/react/components/Search/Search.d.ts +2 -5
- package/fe/packages/ui/react/components/Search/Search.js +3 -3
- package/fe/packages/ui/react/components/Select/Select.d.ts +2 -2
- package/fe/packages/ui/react/components/Select/Select.js +52 -113
- package/fe/packages/ui/react/components/Select/dropdownPositioning.d.ts +3 -0
- package/fe/packages/ui/react/components/Select/dropdownPositioning.js +13 -0
- package/fe/packages/ui/react/components/Skeleton/Skeleton.d.ts +0 -15
- package/fe/packages/ui/react/components/Skeleton/Skeleton.js +3 -3
- package/fe/packages/ui/react/components/Switch/Switch.js +3 -1
- package/fe/packages/ui/react/components/TableSearch/TableSearch.d.ts +5 -41
- package/fe/packages/ui/react/components/TableSearch/TableSearch.js +21 -22
- package/fe/packages/ui/react/components/TableSearch/lang.js +5 -14
- package/fe/packages/ui/react/components/Textarea/Textarea.d.ts +21 -0
- package/fe/packages/ui/react/components/Textarea/Textarea.js +36 -0
- package/fe/packages/ui/react/components/Textarea/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Textarea/index.js +1 -0
- package/fe/packages/ui/react/components/Tooltip/Tooltip.d.ts +9 -0
- package/fe/packages/ui/react/components/Tooltip/Tooltip.js +71 -0
- package/fe/packages/ui/react/components/Tooltip/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Tooltip/index.js +1 -0
- package/fe/packages/ui/react/components/{TreeSelect.d.ts → TreeSelect/TreeSelect.d.ts} +0 -6
- package/fe/packages/ui/react/components/{TreeSelect.js → TreeSelect/TreeSelect.js} +9 -17
- package/fe/packages/ui/react/components/TreeSelect/index.d.ts +2 -0
- package/fe/packages/ui/react/components/TreeSelect/index.js +1 -0
- package/fe/packages/ui/react/components/Upload/ImageUpload.js +18 -6
- package/fe/packages/ui/react/components/Upload/Upload.d.ts +0 -27
- package/fe/packages/ui/react/components/Upload/Upload.js +2 -1
- package/fe/packages/ui/react/components/{breadcrumb.js → breadcrumb/breadcrumb.js} +15 -21
- package/fe/packages/ui/react/components/breadcrumb/index.d.ts +2 -0
- package/fe/packages/ui/react/components/breadcrumb/index.js +1 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.d.ts +43 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.js +123 -0
- package/fe/packages/ui/react/components/hooks/useInputController.d.ts +0 -3
- package/fe/packages/ui/react/components/hooks/useInputController.js +0 -7
- package/fe/packages/ui/react/components/index.d.ts +7 -1
- package/fe/packages/ui/react/components/index.js +7 -1
- package/fe/packages/ui/react/components/table/index.d.ts +2 -0
- package/fe/packages/ui/react/components/table/index.js +1 -0
- package/fe/packages/ui/react/components/table/table.js +20 -0
- package/fe/packages/ui/react/components/testPage/MenuTestPage.d.ts +2 -0
- package/fe/packages/ui/react/components/testPage/MenuTestPage.js +101 -0
- package/fe/packages/ui/react/components/testPage/index.js +251 -81
- package/fe/packages/ui/react/hooks/useExecuteOnce.d.ts +12 -0
- package/fe/packages/ui/react/hooks/useExecuteOnce.js +36 -0
- package/fe/packages/ui/react/hooks/useInit.d.ts +1 -1
- package/fe/packages/ui/react/hooks/useInit.js +1 -1
- package/fe/packages/ui/react/hooks/useLanguage.d.ts +1 -6
- package/fe/packages/ui/react/hooks/useRefState.d.ts +18 -0
- package/fe/packages/ui/react/hooks/useRefState.js +28 -0
- package/fe/packages/ui/react/hooks/useWatch.d.ts +15 -0
- package/fe/packages/ui/react/hooks/useWatch.js +87 -0
- package/fe/packages/ui/react/hooks/useWatch.test.d.ts +2 -0
- package/fe/packages/ui/react/hooks/useWatch.test.js +22 -0
- package/fe/packages/ui/react/i18n/I18nProvider.d.ts +13 -0
- package/fe/packages/ui/react/i18n/I18nProvider.js +25 -0
- package/fe/packages/ui/react/i18n/index.d.ts +4 -0
- package/fe/packages/ui/react/i18n/index.js +3 -0
- package/fe/packages/ui/react/i18n/useI18n.d.ts +9 -0
- package/fe/packages/ui/react/i18n/useI18n.js +14 -0
- package/fe/packages/ui/react/index.css +238 -0
- package/fe/packages/ui/react/index.d.ts +2 -0
- package/fe/packages/ui/react/index.js +2 -2
- package/fe/packages/ui/react/lib/createStoreHook.d.ts +9 -0
- package/fe/packages/ui/react/lib/createStoreHook.js +6 -0
- package/fe/packages/ui/react/lib/export.d.ts +2 -46
- package/fe/packages/ui/react/lib/export.js +0 -40
- package/fe/packages/ui/react/lib/utils.d.ts +0 -24
- package/fe/packages/ui/react/lib/utils.js +0 -25
- package/fe/packages/ui/react/stores/breadcrumb.js +0 -2
- package/fe/packages/ui/react/stores/language.d.ts +3 -12
- package/fe/packages/ui/react/stores/language.js +2 -51
- package/fe/typings/type.d.ts +5 -0
- package/fe/typings/type.js +1 -0
- package/package.json +12 -1
- package/types/app/controller/base.d.ts +3 -3
- package/types/app/router/view.d.ts +2 -3
- package/types/app/service/project.d.ts +29 -4
- package/types/app/type.d.ts +1 -0
- package/types/app/typings.d.ts +12 -21
- package/types/bundler/defaultAlias.d.ts +3 -0
- package/types/bundler/utils.d.ts +1 -1
- package/types/config/config.default.d.ts +14 -0
- package/types/packages/common/LRUCache.d.ts +1 -0
- package/types/packages/common/array/index.d.ts +6 -0
- package/types/packages/common/cache/LRUCache.d.ts +12 -0
- package/types/packages/common/cache/index.d.ts +1 -0
- package/types/packages/common/guards/index.d.ts +8 -0
- package/types/packages/common/i18n/default.d.ts +86 -0
- package/types/packages/common/i18n/en-US.d.ts +86 -0
- package/types/packages/common/i18n/index.d.ts +18 -0
- package/types/packages/common/i18n/locales.d.ts +7 -0
- package/types/packages/common/i18n/types.d.ts +46 -0
- package/types/packages/common/index.d.ts +9 -0
- package/types/packages/common/log/index.d.ts +32 -0
- package/types/packages/common/number/index.d.ts +2 -0
- package/types/packages/common/object/filterEmpty.d.ts +2 -0
- package/types/packages/common/object/filtereEmpty.d.ts +1 -0
- package/types/packages/common/object/index.d.ts +4 -0
- package/types/packages/common/string/index.d.ts +3 -0
- package/types/packages/common/types/index.d.ts +3 -0
- package/types/packages/core/index.d.ts +1 -1
- package/types/packages/core/loader/router.d.ts +1 -1
- package/types/packages/core/types.d.ts +12 -3
- package/fe/packages/ui/react/components/ConfirmDialog.js +0 -9
- package/fe/packages/ui/react/components/Dropdown.d.ts +0 -16
- package/fe/packages/ui/react/components/Dropdown.js +0 -54
- package/fe/packages/ui/react/components/Form/SchemeForm/data.d.ts +0 -51
- package/fe/packages/ui/react/components/Form/SchemeForm/index.d.ts +0 -152
- package/fe/packages/ui/react/components/Form/SchemeForm/index.js +0 -69
- package/fe/packages/ui/react/components/Textarea.d.ts +0 -59
- package/fe/packages/ui/react/components/Textarea.js +0 -35
- package/fe/packages/ui/react/components/Tooltip.d.ts +0 -25
- package/fe/packages/ui/react/components/Tooltip.js +0 -118
- package/fe/packages/ui/react/components/table.js +0 -20
- package/fe/packages/ui/react/locales/index.d.ts +0 -8
- package/fe/packages/ui/react/locales/index.js +0 -6
- /package/fe/packages/ui/react/components/{breadcrumb.d.ts → breadcrumb/breadcrumb.d.ts} +0 -0
- /package/fe/packages/ui/react/components/{table.d.ts → table/table.d.ts} +0 -0
|
@@ -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 };
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from
|
|
3
|
-
import { format as formatDate, isValid, parse } from
|
|
4
|
-
import { Calendar as CalendarIcon, X } from
|
|
5
|
-
import { forwardRef, useEffect, useMemo, useRef, useState } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
import { format as formatDate, isValid, parse } from "date-fns";
|
|
4
|
+
import { Calendar as CalendarIcon, X } from "lucide-react";
|
|
5
|
+
import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { Button } from "../Button";
|
|
7
|
+
import { Input } from "../Input";
|
|
8
|
+
import { Popup } from "../Popup";
|
|
9
|
+
import { useDropdownPositioning } from "../hooks/useDropdownPositioning";
|
|
10
|
+
import { Calendar } from "./Calendar";
|
|
11
|
+
import { ModeType } from "./data";
|
|
12
|
+
import { getDatePickerDropdownPosition } from "./dropdownPositioning";
|
|
13
|
+
import { useDateLocale } from "./LocaleContext";
|
|
9
14
|
const formatValue = (val, format) => {
|
|
10
15
|
if (!val)
|
|
11
|
-
return
|
|
16
|
+
return "";
|
|
12
17
|
if (val instanceof Date)
|
|
13
18
|
return formatDate(val, format);
|
|
14
|
-
if (
|
|
19
|
+
if ("from" in val) {
|
|
15
20
|
if (val.from && val.to) {
|
|
16
21
|
return `${formatDate(val.from, format)} - ${formatDate(val.to, format)}`;
|
|
17
22
|
}
|
|
@@ -19,27 +24,25 @@ const formatValue = (val, format) => {
|
|
|
19
24
|
return formatDate(val.from, format);
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
|
-
return
|
|
27
|
+
return "";
|
|
23
28
|
};
|
|
24
29
|
const formatDateValue = (val, format) => {
|
|
25
30
|
if (!val)
|
|
26
|
-
return
|
|
27
|
-
/**
|
|
28
|
-
* 将 DateBaseValue 转为 yyyy-MM-dd | [yyyy-MM-dd, yyyy-MM-dd]
|
|
29
|
-
*/
|
|
31
|
+
return "";
|
|
30
32
|
if (val instanceof Date)
|
|
31
33
|
return formatDate(val, format);
|
|
32
|
-
if (
|
|
34
|
+
if ("from" in val) {
|
|
33
35
|
if (val.from && val.to) {
|
|
34
36
|
return [formatDate(val.from, format), formatDate(val.to, format)];
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
|
-
return
|
|
39
|
+
return "";
|
|
38
40
|
};
|
|
39
|
-
const DatePicker = forwardRef((
|
|
41
|
+
const DatePicker = forwardRef((props, ref) => {
|
|
42
|
+
const { mode = ModeType.Single, className, format: customFormat, placeholder, allowClear = true, disabled = false, showTime = false, value: pValue, defaultValue: pDefaultValue, onChange, disabledDate, locale: customLocale, quickRanges, getPopupContainer, } = props;
|
|
43
|
+
const isControlled = Object.prototype.hasOwnProperty.call(props, "value");
|
|
40
44
|
const contextLocale = useDateLocale();
|
|
41
45
|
const locale = { ...contextLocale, ...customLocale };
|
|
42
|
-
// 如果没有传入 placeholder,根据模式自动选择
|
|
43
46
|
const finalPlaceholder = placeholder ||
|
|
44
47
|
(showTime
|
|
45
48
|
? mode === ModeType.Range
|
|
@@ -48,23 +51,16 @@ const DatePicker = forwardRef(({ mode = ModeType.Single, className, format: cust
|
|
|
48
51
|
: mode === ModeType.Range
|
|
49
52
|
? locale.placeholderRange
|
|
50
53
|
: locale.placeholder);
|
|
51
|
-
|
|
52
|
-
const format = customFormat || (showTime ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd');
|
|
54
|
+
const format = customFormat || (showTime ? "yyyy-MM-dd HH:mm" : "yyyy-MM-dd");
|
|
53
55
|
const { value, defaultValue } = useMemo(() => {
|
|
54
|
-
/**
|
|
55
|
-
* 将 DateChangeStrValue 转为 Dates
|
|
56
|
-
*/
|
|
57
56
|
const convertValue = (val) => {
|
|
58
57
|
if (!val)
|
|
59
58
|
return undefined;
|
|
60
|
-
// Already a Date object
|
|
61
59
|
if (val instanceof Date)
|
|
62
60
|
return val;
|
|
63
|
-
|
|
64
|
-
if (typeof val === 'object' && 'from' in val)
|
|
61
|
+
if (typeof val === "object" && "from" in val)
|
|
65
62
|
return val;
|
|
66
|
-
|
|
67
|
-
if (typeof val === 'string') {
|
|
63
|
+
if (typeof val === "string") {
|
|
68
64
|
try {
|
|
69
65
|
const parsed = parse(val, format, new Date());
|
|
70
66
|
return isValid(parsed) ? parsed : undefined;
|
|
@@ -73,10 +69,8 @@ const DatePicker = forwardRef(({ mode = ModeType.Single, className, format: cust
|
|
|
73
69
|
return undefined;
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
|
-
// date range
|
|
77
72
|
if (Array.isArray(val)) {
|
|
78
|
-
|
|
79
|
-
if (typeof val[0] === 'string' && typeof val[1] === 'string') {
|
|
73
|
+
if (typeof val[0] === "string" && typeof val[1] === "string") {
|
|
80
74
|
try {
|
|
81
75
|
const from = parse(val[0], format, new Date());
|
|
82
76
|
const to = parse(val[1], format, new Date());
|
|
@@ -97,60 +91,63 @@ const DatePicker = forwardRef(({ mode = ModeType.Single, className, format: cust
|
|
|
97
91
|
defaultValue: convertValue(pDefaultValue),
|
|
98
92
|
};
|
|
99
93
|
}, [pDefaultValue, pValue, format]);
|
|
100
|
-
const
|
|
94
|
+
const initialValue = isControlled ? value : (value || defaultValue);
|
|
95
|
+
const [selectedDate, setSelectedDate] = useState(initialValue);
|
|
101
96
|
const [isOpen, setIsOpen] = useState(false);
|
|
102
|
-
const [inputValue, setInputValue] = useState(formatValue(
|
|
97
|
+
const [inputValue, setInputValue] = useState(formatValue(initialValue, format));
|
|
103
98
|
const [isHover, setIsHover] = useState(false);
|
|
104
99
|
const containerRef = useRef(null);
|
|
100
|
+
const dropdownContentRef = useRef(null);
|
|
105
101
|
const inputRef = useRef(null);
|
|
106
|
-
|
|
102
|
+
const rangeDraftRef = useRef(false);
|
|
103
|
+
const positioning = useDropdownPositioning({
|
|
104
|
+
open: isOpen,
|
|
105
|
+
anchorRef: containerRef,
|
|
106
|
+
contentRef: dropdownContentRef,
|
|
107
|
+
placement: "bottom-start",
|
|
108
|
+
offset: 8,
|
|
109
|
+
matchAnchorWidth: false,
|
|
110
|
+
strategy: getDatePickerDropdownPosition,
|
|
111
|
+
});
|
|
107
112
|
useEffect(() => {
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
if (!isControlled)
|
|
114
|
+
return;
|
|
115
|
+
if (mode === ModeType.Range && rangeDraftRef.current && value === undefined) {
|
|
116
|
+
return;
|
|
112
117
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
118
|
-
setIsOpen(false);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
if (isOpen) {
|
|
122
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
123
|
-
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
return () => { };
|
|
118
|
+
setSelectedDate(value);
|
|
119
|
+
setInputValue(formatValue(value, format));
|
|
120
|
+
if (mode !== ModeType.Range || !value || !('from' in value) || value.to) {
|
|
121
|
+
rangeDraftRef.current = false;
|
|
127
122
|
}
|
|
128
|
-
}, [
|
|
123
|
+
}, [isControlled, mode, value, format]);
|
|
129
124
|
const handleSelect = (date) => {
|
|
130
125
|
const newDate = date;
|
|
131
126
|
if (mode === ModeType.Range) {
|
|
132
|
-
|
|
133
|
-
if (date && 'from' in date && 'to' in date && date.from && date.to) {
|
|
127
|
+
if (date && "from" in date && "to" in date && date.from && date.to) {
|
|
134
128
|
setIsOpen(false);
|
|
135
129
|
}
|
|
136
130
|
}
|
|
137
131
|
else {
|
|
138
|
-
// Single mode: always close popup when onChange is triggered
|
|
139
|
-
// (In showTime mode, this only happens when user clicks confirm button)
|
|
140
132
|
setIsOpen(false);
|
|
141
133
|
}
|
|
142
|
-
|
|
143
|
-
setInputValue(formatValue(newDate, format));
|
|
144
|
-
// 只在非受控模式下更新内部状态
|
|
145
|
-
if (value === undefined) {
|
|
134
|
+
if (mode === ModeType.Range || !isControlled) {
|
|
146
135
|
setSelectedDate(newDate);
|
|
136
|
+
setInputValue(formatValue(newDate, format));
|
|
147
137
|
}
|
|
138
|
+
rangeDraftRef.current =
|
|
139
|
+
mode === ModeType.Range && !(newDate &&
|
|
140
|
+
typeof newDate === 'object' &&
|
|
141
|
+
'from' in newDate &&
|
|
142
|
+
newDate.from &&
|
|
143
|
+
newDate.to);
|
|
148
144
|
onChange?.(formatDateValue(newDate, format), newDate);
|
|
149
145
|
};
|
|
150
146
|
const handleClear = (e) => {
|
|
151
147
|
e.stopPropagation();
|
|
148
|
+
rangeDraftRef.current = false;
|
|
152
149
|
setSelectedDate(undefined);
|
|
153
|
-
setInputValue(
|
|
150
|
+
setInputValue("");
|
|
154
151
|
onChange?.(undefined, undefined);
|
|
155
152
|
inputRef.current?.focus();
|
|
156
153
|
};
|
|
@@ -161,18 +158,25 @@ const DatePicker = forwardRef(({ mode = ModeType.Single, className, format: cust
|
|
|
161
158
|
try {
|
|
162
159
|
const parsedDate = parse(newValue, format, new Date());
|
|
163
160
|
if (isValid(parsedDate)) {
|
|
164
|
-
if (
|
|
161
|
+
if (!isControlled)
|
|
165
162
|
setSelectedDate(parsedDate);
|
|
166
163
|
onChange?.(formatDateValue(parsedDate, format), parsedDate);
|
|
167
164
|
}
|
|
168
165
|
}
|
|
169
166
|
catch {
|
|
170
|
-
// ignore invalid date
|
|
171
167
|
}
|
|
172
168
|
}
|
|
173
169
|
};
|
|
174
170
|
const showClearIcon = allowClear && selectedDate && !disabled && isHover;
|
|
175
|
-
return (_jsx("div", { ref: ref, className: cn(
|
|
171
|
+
return (_jsx("div", { ref: ref, className: cn("tc-ui-date-picker relative w-full", mode === ModeType.Range ? "min-w-[255px]" : "", className), children: _jsxs("div", { ref: containerRef, className: "relative", children: [_jsxs("div", { className: cn("flex items-center w-full rounded-lg px-4 py-3 text-sm", "border transition-colors duration-200", "bg-background cursor-pointer", disabled &&
|
|
172
|
+
"cursor-not-allowed bg-muted border-border text-muted-foreground", !disabled && !selectedDate && !isOpen && "border-border", !disabled && (selectedDate || isOpen) && "border-theme"), onClick: () => !disabled && setIsOpen(!isOpen), onMouseEnter: () => setIsHover(true), onMouseLeave: () => setIsHover(false), children: [_jsx(Input, { ref: inputRef, type: "text", value: inputValue, onChange: (_, e) => handleInputChange(e), placeholder: finalPlaceholder, disabled: disabled, readOnly: mode === ModeType.Range, className: "flex-1", inputClassName: cn("flex-1 rounded-none border-0 bg-transparent px-0 py-0 outline-none", "text-sm text-foreground placeholder:text-muted-foreground", disabled && "cursor-not-allowed", mode === ModeType.Range &&
|
|
173
|
+
!disabled &&
|
|
174
|
+
"cursor-pointer caret-transparent") }), showClearIcon ? (_jsx(Button, { variant: "text", type: "button", onClick: handleClear, title: locale.clear, "aria-label": locale.clear, className: cn("ml-2 flex items-center justify-center", "w-5 h-5 rounded-full", "bg-muted hover:bg-muted/80", "text-foreground transition-colors", "cursor-pointer"), children: _jsx(X, { size: 12 }) })) : (_jsx(CalendarIcon, { size: 16, className: "ml-2 text-muted-foreground" }))] }), _jsx(Popup, { open: isOpen && !disabled, anchorRef: containerRef, contentRef: dropdownContentRef, positioning: positioning, keepMounted: true, onOpenChange: (nextOpen) => {
|
|
175
|
+
setIsOpen(nextOpen);
|
|
176
|
+
if (!nextOpen) {
|
|
177
|
+
rangeDraftRef.current = false;
|
|
178
|
+
}
|
|
179
|
+
}, className: cn("overflow-hidden"), container: getPopupContainer?.(), children: _jsx("div", { ref: dropdownContentRef, children: _jsx(Calendar, { mode: mode, value: selectedDate || null, onChange: handleSelect, disabledDate: disabledDate, showTime: showTime, locale: locale, quickRanges: quickRanges }) }) })] }) }));
|
|
176
180
|
});
|
|
177
|
-
DatePicker.displayName =
|
|
181
|
+
DatePicker.displayName = "DatePicker";
|
|
178
182
|
export { DatePicker };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { useDateLocaleStore } from './dateLocaleStore';
|
|
2
|
-
/**
|
|
3
|
-
* Hook for accessing the current Date component locale.
|
|
4
|
-
* Backed by Zustand, so no React Context is required.
|
|
5
|
-
*/
|
|
6
2
|
export const useDateLocale = () => {
|
|
7
3
|
return useDateLocaleStore((state) => state.locale);
|
|
8
4
|
};
|
|
@@ -4,16 +4,5 @@ export interface DateLocaleProviderProps {
|
|
|
4
4
|
locale?: DateLocaleConfig;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Date 组件文案配置 Provider
|
|
9
|
-
* 用于全局设置 Date 组件的文案
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* <DateLocaleProvider locale={customLocale}>
|
|
14
|
-
* <App />
|
|
15
|
-
* </DateLocaleProvider>
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
7
|
export declare function DateLocaleProvider({ locale, children }: DateLocaleProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
19
8
|
//# sourceMappingURL=LocaleProvider.d.ts.map
|
|
@@ -2,17 +2,6 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import { useDateLocaleStore } from './dateLocaleStore';
|
|
4
4
|
import { defaultLocale } from './locales';
|
|
5
|
-
/**
|
|
6
|
-
* Date 组件文案配置 Provider
|
|
7
|
-
* 用于全局设置 Date 组件的文案
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* <DateLocaleProvider locale={customLocale}>
|
|
12
|
-
* <App />
|
|
13
|
-
* </DateLocaleProvider>
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
5
|
export function DateLocaleProvider({ locale = defaultLocale, children }) {
|
|
17
6
|
const replaceLocale = useDateLocaleStore((state) => state.replaceLocale);
|
|
18
7
|
const resetLocale = useDateLocaleStore((state) => state.resetLocale);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from '../../lib/utils';
|
|
3
3
|
import { ChevronDown, ChevronUp } from 'lucide-react';
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { Input } from '../Input';
|
|
4
6
|
export function TimePicker({ value, onChange, className }) {
|
|
5
|
-
// Derive time from value prop directly
|
|
6
7
|
const hours = value?.getHours() ?? 0;
|
|
7
8
|
const minutes = value?.getMinutes() ?? 0;
|
|
8
9
|
const handleTimeChange = (newHours, newMinutes) => {
|
|
@@ -72,5 +73,5 @@ export function TimePicker({ value, onChange, className }) {
|
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
75
|
const formatNumber = (num) => String(num).padStart(2, '0');
|
|
75
|
-
return (_jsxs("div", { className: cn('flex items-center justify-center gap-3 py-3', className), children: [_jsxs("div", { className: "flex flex-col items-center gap-1", children: [_jsx("
|
|
76
|
+
return (_jsxs("div", { className: cn('tc-ui-time-picker flex items-center justify-center gap-3 py-3', className), children: [_jsxs("div", { className: "flex flex-col items-center gap-1", children: [_jsx(Button, { variant: "text", type: "button", onClick: incrementHours, className: "p-1 hover:bg-muted rounded transition-colors text-muted-foreground hover:text-foreground", children: _jsx(ChevronUp, { size: 14 }) }), _jsx(Input, { type: "text", value: formatNumber(hours), onChange: (_, e) => handleHoursInput(e), onKeyDown: handleHoursKeyDown, className: "w-12", inputClassName: cn('w-12 h-9 px-0 py-0 text-center text-sm font-medium', 'border border-border rounded', 'bg-background text-foreground', 'focus:outline-none focus:border-theme', 'transition-colors'), maxLength: 2 }), _jsx(Button, { variant: "text", type: "button", onClick: decrementHours, className: "p-1 hover:bg-muted rounded transition-colors text-muted-foreground hover:text-foreground", children: _jsx(ChevronDown, { size: 14 }) })] }), _jsx("div", { className: "text-lg font-medium text-foreground mb-1", children: ":" }), _jsxs("div", { className: "flex flex-col items-center gap-1", children: [_jsx(Button, { variant: "text", type: "button", onClick: incrementMinutes, className: "p-1 hover:bg-muted rounded transition-colors text-muted-foreground hover:text-foreground", children: _jsx(ChevronUp, { size: 14 }) }), _jsx(Input, { type: "text", value: formatNumber(minutes), onChange: (_, e) => handleMinutesInput(e), onKeyDown: handleMinutesKeyDown, className: "w-12", inputClassName: cn('w-12 h-9 px-0 py-0 text-center text-sm font-medium', 'border border-border rounded', 'bg-background text-foreground', 'focus:outline-none focus:border-theme', 'transition-colors'), maxLength: 2 }), _jsx(Button, { variant: "text", type: "button", onClick: decrementMinutes, className: "p-1 hover:bg-muted rounded transition-colors text-muted-foreground hover:text-foreground", children: _jsx(ChevronDown, { size: 14 }) })] })] }));
|
|
76
77
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { type DateLocaleConfig } from './locales';
|
|
2
2
|
type DateLocaleState = {
|
|
3
3
|
locale: DateLocaleConfig;
|
|
4
|
-
/**
|
|
5
|
-
* Merge partial updates into the current locale.
|
|
6
|
-
*/
|
|
7
4
|
setLocale: (patch: Partial<DateLocaleConfig>) => void;
|
|
8
|
-
/**
|
|
9
|
-
* Replace the locale entirely.
|
|
10
|
-
*/
|
|
11
5
|
replaceLocale: (nextLocale: DateLocaleConfig) => void;
|
|
12
6
|
resetLocale: () => void;
|
|
13
7
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const getDatePickerDropdownPosition = ({ anchorRect, contentRect, viewportHeight, offset, }) => {
|
|
2
|
+
const contentHeight = contentRect?.height ?? 360;
|
|
3
|
+
const spaceBelow = viewportHeight - anchorRect.bottom;
|
|
4
|
+
const spaceAbove = anchorRect.top;
|
|
5
|
+
const shouldFlipUp = spaceBelow < contentHeight && spaceAbove > spaceBelow;
|
|
6
|
+
return {
|
|
7
|
+
top: shouldFlipUp
|
|
8
|
+
? anchorRect.top - contentHeight - offset
|
|
9
|
+
: anchorRect.bottom + offset,
|
|
10
|
+
left: anchorRect.left,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Date 组件文案配置
|
|
3
|
-
* 支持外部修改文案内容
|
|
4
|
-
*/
|
|
5
1
|
export interface DateLocaleConfig {
|
|
6
2
|
placeholder: string;
|
|
7
3
|
placeholderDateTime: string;
|
|
@@ -12,13 +8,8 @@ export interface DateLocaleConfig {
|
|
|
12
8
|
startTime: string;
|
|
13
9
|
endTime: string;
|
|
14
10
|
confirm: string;
|
|
15
|
-
|
|
16
|
-
* 范围模式 - 快捷选择面板标题
|
|
17
|
-
*/
|
|
11
|
+
monthFormat: string;
|
|
18
12
|
quickRanges: string;
|
|
19
|
-
/**
|
|
20
|
-
* 范围模式 - 各快捷范围文案
|
|
21
|
-
*/
|
|
22
13
|
quickRangeToday: string;
|
|
23
14
|
quickRangeYesterday: string;
|
|
24
15
|
quickRangeLast7Days: string;
|
|
@@ -27,16 +18,7 @@ export interface DateLocaleConfig {
|
|
|
27
18
|
quickRangeLastYear: string;
|
|
28
19
|
clear: string;
|
|
29
20
|
}
|
|
30
|
-
/**
|
|
31
|
-
* 默认中文文案
|
|
32
|
-
*/
|
|
33
21
|
export declare const zhCNLocale: DateLocaleConfig;
|
|
34
|
-
/**
|
|
35
|
-
* 默认英文文案
|
|
36
|
-
*/
|
|
37
22
|
export declare const enUSLocale: DateLocaleConfig;
|
|
38
|
-
/**
|
|
39
|
-
* 默认使用中文文案
|
|
40
|
-
*/
|
|
41
23
|
export declare const defaultLocale: DateLocaleConfig;
|
|
42
24
|
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -1,52 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* 默认中文文案
|
|
7
|
-
*/
|
|
1
|
+
import { defaultEnglishResources, defaultLanguageResources } from '../../../../common/i18n';
|
|
2
|
+
const dateDefaultLocale = defaultLanguageResources.components.date;
|
|
3
|
+
const dateDefaultEnglishLocale = defaultEnglishResources.components.date;
|
|
8
4
|
export const zhCNLocale = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
placeholderRange: '选择日期范围',
|
|
12
|
-
placeholderDateTimeRange: '选择日期时间范围',
|
|
13
|
-
weekDays: ['日', '一', '二', '三', '四', '五', '六'],
|
|
14
|
-
selectTime: '选择时间',
|
|
15
|
-
startTime: '开始时间',
|
|
16
|
-
endTime: '结束时间',
|
|
17
|
-
confirm: '确认',
|
|
18
|
-
quickRanges: '快速选择',
|
|
19
|
-
quickRangeToday: '今天',
|
|
20
|
-
quickRangeYesterday: '昨天',
|
|
21
|
-
quickRangeLast7Days: '近7天',
|
|
22
|
-
quickRangeLast30Days: '近30天',
|
|
23
|
-
quickRangeThisMonth: '本月',
|
|
24
|
-
quickRangeLastYear: '最近一年',
|
|
25
|
-
clear: '清除',
|
|
5
|
+
...dateDefaultLocale,
|
|
6
|
+
weekDays: [...dateDefaultLocale.weekDays],
|
|
26
7
|
};
|
|
27
|
-
/**
|
|
28
|
-
* 默认英文文案
|
|
29
|
-
*/
|
|
30
8
|
export const enUSLocale = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
placeholderRange: 'Select date range',
|
|
34
|
-
placeholderDateTimeRange: 'Select date and time range',
|
|
35
|
-
weekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
36
|
-
selectTime: 'Select time',
|
|
37
|
-
startTime: 'Start time',
|
|
38
|
-
endTime: 'End time',
|
|
39
|
-
confirm: 'Confirm',
|
|
40
|
-
quickRanges: 'Quick ranges',
|
|
41
|
-
quickRangeToday: 'Today',
|
|
42
|
-
quickRangeYesterday: 'Yesterday',
|
|
43
|
-
quickRangeLast7Days: 'Last 7 days',
|
|
44
|
-
quickRangeLast30Days: 'Last 30 days',
|
|
45
|
-
quickRangeThisMonth: 'This month',
|
|
46
|
-
quickRangeLastYear: 'Last year',
|
|
47
|
-
clear: 'Clear',
|
|
9
|
+
...dateDefaultEnglishLocale,
|
|
10
|
+
weekDays: [...dateDefaultEnglishLocale.weekDays],
|
|
48
11
|
};
|
|
49
|
-
/**
|
|
50
|
-
* 默认使用中文文案
|
|
51
|
-
*/
|
|
52
12
|
export const defaultLocale = zhCNLocale;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type DrawerPlacement = 'top' | 'right' | 'bottom' | 'left';
|
|
3
|
+
export type DrawerProps = {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
title?: ReactNode;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
footer?: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
contentClassName?: string;
|
|
11
|
+
mask?: boolean;
|
|
12
|
+
maskClosable?: boolean;
|
|
13
|
+
lockScroll?: boolean;
|
|
14
|
+
closable?: boolean;
|
|
15
|
+
placement?: DrawerPlacement;
|
|
16
|
+
width?: number | string;
|
|
17
|
+
height?: number | string;
|
|
18
|
+
zIndex?: number;
|
|
19
|
+
renderNode?: HTMLElement | (() => HTMLElement);
|
|
20
|
+
keyboard?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare function Drawer({ open, onClose, title, children, footer, className, contentClassName, mask, maskClosable, lockScroll, closable, placement, width, height, renderNode, keyboard, zIndex, }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=Drawer.d.ts.map
|