@_tc/template-core 0.0.1-bate.46 → 0.0.1-bate.48
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/.skills/tc-component-usage-skills/SKILL.md +132 -0
- package/.skills/tc-component-usage-skills/reference/component-api.md +801 -0
- package/.skills/tc-component-usage-skills/reference/examples.md +435 -0
- package/.skills/tc-component-usage-skills/reference/patterns.md +392 -0
- package/.skills/tc-component-usage-skills/reference/template-core-frontend.md +104 -0
- package/.skills/tc-generator/SKILL.md +70 -0
- package/.skills/tc-generator/reference/example.md +357 -0
- package/.skills/tc-generator/reference/model-schema.md +328 -0
- package/.skills/tc-generator/reference/project-template/app/controller/product.js +73 -0
- package/.skills/tc-generator/reference/project-template/app/router/product.js +9 -0
- package/.skills/tc-generator/reference/project-template/config/config.default.js +7 -0
- package/.skills/tc-generator/reference/project-template/index.js +17 -0
- package/.skills/tc-generator/reference/project-template/model/product/mode.js +179 -0
- package/.skills/tc-generator/reference/project-template/model/product/project/default.js +5 -0
- package/.skills/tc-generator/reference/project-template/package.json +25 -0
- package/.skills/tc-generator/reference/runtime-extensions.md +190 -0
- package/README.md +1723 -0
- package/cjs/_virtual/_rolldown/runtime.js +1 -37
- package/cjs/app/controller/base.js +1 -29
- package/cjs/app/controller/project.js +1 -60
- package/cjs/app/controller/view.js +1 -24
- package/cjs/app/extend/$fetch.js +1 -0
- package/cjs/app/extend/db.js +20 -8
- package/cjs/app/extend/generateErrorMessage.js +1 -16
- package/cjs/app/extend/logger.js +1 -35
- package/cjs/app/extend/parsingParamsOnUrl.js +1 -22
- package/cjs/app/extend/render-view.js +1 -24
- package/cjs/app/middleware/api-params-verify.js +1 -72
- package/cjs/app/middleware/api-sign-verify.js +1 -23
- package/cjs/app/middleware/error-handle.js +1 -38
- package/cjs/app/middleware/project-handler.js +1 -21
- package/cjs/app/middleware.js +1 -32
- package/cjs/app/router/project.js +1 -10
- package/cjs/app/router/view.js +1 -9
- package/cjs/app/router-schema/project.js +1 -16
- package/cjs/app/service/base.js +1 -17
- package/cjs/app/service/project.js +1 -38
- package/cjs/app/type.js +0 -1
- package/cjs/app/typings.js +0 -1
- package/cjs/app/view/entry.tpl +27 -28
- package/cjs/bundler/buildBE.js +1 -0
- package/cjs/bundler/defaultAlias.js +1 -5
- package/cjs/bundler/dev.js +1 -20
- package/cjs/bundler/index.js +1 -19
- package/cjs/bundler/prod.js +1 -21
- package/cjs/bundler/state.js +1 -0
- package/cjs/bundler/utils.js +1 -262
- package/cjs/config/config.default.js +1 -0
- package/cjs/index.js +1 -23
- package/cjs/packages/common/LRUCache.js +1 -4
- package/cjs/packages/common/array/index.js +1 -43
- package/cjs/packages/common/cache/LRUCache.js +1 -45
- package/cjs/packages/common/cache/index.js +1 -4
- package/cjs/packages/common/guards/index.js +1 -34
- package/cjs/packages/common/http/index.js +1 -0
- package/cjs/packages/common/i18n/default.js +1 -95
- package/cjs/packages/common/i18n/en-US.js +1 -95
- package/cjs/packages/common/i18n/index.js +1 -178
- package/cjs/packages/common/i18n/locales.js +1 -17
- package/cjs/packages/common/i18n/types.js +0 -1
- package/cjs/packages/common/index.js +1 -65
- package/cjs/packages/common/log/index.js +2 -160
- package/cjs/packages/common/number/index.js +1 -14
- package/cjs/packages/common/object/filterEmpty.js +1 -32
- package/cjs/packages/common/object/filtereEmpty.js +1 -5
- package/cjs/packages/common/object/index.js +1 -26
- package/cjs/packages/common/string/index.js +1 -17
- package/cjs/packages/common/types/index.js +0 -1
- package/cjs/packages/core/env.js +1 -27
- package/cjs/packages/core/index.js +1 -110
- package/cjs/packages/core/loader/config.js +1 -43
- package/cjs/packages/core/loader/controller.js +1 -33
- package/cjs/packages/core/loader/extend.js +1 -31
- package/cjs/packages/core/loader/middleware.js +1 -30
- package/cjs/packages/core/loader/model.js +1 -111
- package/cjs/packages/core/loader/router-schema.js +1 -36
- package/cjs/packages/core/loader/router.js +1 -62
- package/cjs/packages/core/loader/service.js +1 -30
- package/cjs/packages/core/paths.js +1 -12
- package/cjs/packages/core/types.js +0 -1
- package/cjs/packages/utils/getAllFilesInFolder.js +1 -14
- package/cjs/packages/utils/getAllFnReturnValue.js +0 -1
- package/cjs/packages/utils/index.js +1 -11
- package/cjs/packages/utils/loadFile.js +1 -55
- package/cjs/packages/utils/path.js +1 -31
- package/cjs/packages/utils/runFileFn.js +1 -51
- package/cjs/scripts/vite-build/build.js +3 -0
- package/cjs/scripts/vite-build/collect.js +1 -0
- package/cjs/scripts/vite-build/constants.js +1 -0
- package/cjs/scripts/vite-build/dts.js +1 -0
- package/cjs/scripts/vite-build/index.js +1 -0
- package/cjs/scripts/vite-build/normalize.js +1 -0
- package/cjs/scripts/vite-build/plugins.js +1 -0
- package/cjs/scripts/vite-build/resolve.js +1 -0
- package/cjs/scripts/vite-build/types.js +0 -0
- package/cjs/scripts/vite-build/utils.js +1 -0
- package/esm/_virtual/_rolldown/runtime.js +4 -29
- package/esm/app/controller/base.js +14 -16
- package/esm/app/controller/project.js +39 -46
- package/esm/app/controller/view.js +23 -19
- package/esm/app/extend/$fetch.js +15 -0
- package/esm/app/extend/db.js +138 -4
- package/esm/app/extend/generateErrorMessage.js +4 -12
- package/esm/app/extend/logger.js +9 -17
- package/esm/app/extend/parsingParamsOnUrl.js +11 -18
- package/esm/app/extend/render-view.js +18 -16
- package/esm/app/middleware/api-params-verify.js +36 -50
- package/esm/app/middleware/api-sign-verify.js +10 -16
- package/esm/app/middleware/error-handle.js +17 -30
- package/esm/app/middleware/project-handler.js +11 -16
- package/esm/app/middleware.js +12 -19
- package/esm/app/router/project.js +4 -6
- package/esm/app/router/view.js +4 -5
- package/esm/app/router-schema/project.js +2 -2
- package/esm/app/service/base.js +6 -7
- package/esm/app/service/project.js +18 -32
- package/esm/app/view/entry.tpl +27 -28
- package/esm/bundler/buildBE.js +54 -0
- package/esm/bundler/defaultAlias.js +2 -2
- package/esm/bundler/dev.js +8 -14
- package/esm/bundler/index.js +11 -9
- package/esm/bundler/prod.js +9 -14
- package/esm/bundler/state.js +10 -0
- package/esm/bundler/utils.js +115 -164
- package/esm/config/config.default.js +9 -0
- package/esm/index.js +12 -15
- package/esm/packages/common/LRUCache.js +2 -2
- package/esm/packages/common/array/index.js +21 -31
- package/esm/packages/common/cache/LRUCache.js +21 -25
- package/esm/packages/common/cache/index.js +2 -2
- package/esm/packages/common/guards/index.js +5 -23
- package/esm/packages/common/http/index.js +256 -0
- package/esm/packages/common/i18n/default.js +2 -7
- package/esm/packages/common/i18n/en-US.js +2 -7
- package/esm/packages/common/i18n/index.js +73 -144
- package/esm/packages/common/i18n/locales.js +6 -8
- package/esm/packages/common/index.js +14 -13
- package/esm/packages/common/log/index.js +69 -122
- package/esm/packages/common/number/index.js +7 -8
- package/esm/packages/common/object/filterEmpty.js +16 -22
- package/esm/packages/common/object/filtereEmpty.js +2 -2
- package/esm/packages/common/object/index.js +14 -17
- package/esm/packages/common/string/index.js +2 -11
- package/esm/packages/core/env.js +22 -24
- package/esm/packages/core/index.js +36 -92
- package/esm/packages/core/loader/config.js +21 -35
- package/esm/packages/core/loader/controller.js +8 -27
- package/esm/packages/core/loader/extend.js +19 -21
- package/esm/packages/core/loader/middleware.js +9 -22
- package/esm/packages/core/loader/model.js +50 -91
- package/esm/packages/core/loader/router-schema.js +13 -29
- package/esm/packages/core/loader/router.js +27 -51
- package/esm/packages/core/loader/service.js +8 -24
- package/esm/packages/core/paths.js +5 -5
- package/esm/packages/utils/getAllFilesInFolder.js +6 -8
- package/esm/packages/utils/index.js +5 -5
- package/esm/packages/utils/loadFile.js +28 -43
- package/esm/packages/utils/path.js +10 -22
- package/esm/packages/utils/runFileFn.js +32 -37
- package/esm/scripts/vite-build/build.js +141 -0
- package/esm/scripts/vite-build/collect.js +79 -0
- package/esm/scripts/vite-build/constants.js +34 -0
- package/esm/scripts/vite-build/dts.js +132 -0
- package/esm/scripts/vite-build/index.js +3 -0
- package/esm/scripts/vite-build/normalize.js +78 -0
- package/esm/scripts/vite-build/plugins.js +106 -0
- package/esm/scripts/vite-build/resolve.js +46 -0
- package/esm/scripts/vite-build/types.js +0 -0
- package/esm/scripts/vite-build/utils.js +24 -0
- package/fe/bundler/defaultAlias.js +4 -0
- package/fe/frontend/apps/dash/Dashboard.d.ts +6 -0
- package/fe/frontend/apps/dash/Dashboard.js +164 -0
- package/fe/frontend/apps/dash/dash.entry.js +54 -0
- package/fe/frontend/apps/dash/types.d.ts +25 -0
- package/fe/frontend/apps/dash/types.js +0 -0
- package/fe/frontend/apps/ui-components/index.js +16 -0
- package/fe/frontend/apps/ui-components/ui-components.entry.d.ts +2 -0
- package/fe/frontend/apps/ui-components/ui-components.entry.js +8 -0
- package/fe/frontend/extended/SchemaForm/data.d.ts +1 -1
- package/fe/frontend/extended/SchemaForm/data.js +7 -7
- package/fe/frontend/{widgets → src}/api/baseInfo.d.ts +2 -2
- package/fe/frontend/src/api/baseInfo.js +14 -0
- package/fe/frontend/src/common/CRUD/CRUD.d.ts +3 -0
- package/fe/frontend/src/common/CRUD/CRUD.js +2 -0
- package/fe/frontend/src/common/CRUD/index.d.ts +2 -0
- package/fe/frontend/src/common/CRUD/index.js +2 -0
- package/fe/frontend/src/common/auth/index.js +21 -0
- package/fe/frontend/{widgets/defaultPages/Schema/utils → src/common}/fetchErrorShow.d.ts +1 -1
- package/fe/frontend/src/common/fetchErrorShow.js +11 -0
- package/fe/frontend/src/common/generateMenuData.d.ts +4 -0
- package/fe/frontend/src/common/generateMenuData.js +16 -0
- package/fe/frontend/{widgets → src}/common/importComponent.d.ts +1 -1
- package/fe/frontend/src/common/importComponent.js +23 -0
- package/fe/frontend/src/common/language.d.ts +3 -0
- package/fe/frontend/src/common/language.js +12 -0
- package/fe/frontend/{widgets → src}/common/logFn/index.d.ts +1 -0
- package/fe/frontend/src/common/logFn/index.js +14 -0
- package/fe/frontend/{widgets → src}/common/menu.d.ts +1 -1
- package/fe/frontend/src/common/menu.js +97 -0
- package/fe/frontend/src/common/request.d.ts +37 -0
- package/fe/frontend/src/common/request.js +183 -0
- package/fe/frontend/{components → src/components}/AsyncSelect/AsyncSelect.d.ts +3 -3
- package/fe/frontend/src/components/AsyncSelect/AsyncSelect.js +35 -0
- package/fe/frontend/src/components/AsyncSelect/index.d.ts +4 -0
- package/fe/frontend/src/components/AsyncSelect/index.js +5 -0
- package/fe/frontend/{widgets → src}/components/BasePage/HeaderView.d.ts +1 -0
- package/fe/frontend/src/components/BasePage/HeaderView.js +55 -0
- package/fe/frontend/src/components/LanguageSwitch/LanguageSwitch.d.ts +14 -0
- package/fe/frontend/src/components/LanguageSwitch/LanguageSwitch.js +44 -0
- package/fe/frontend/src/components/LanguageSwitch/index.d.ts +4 -0
- package/fe/frontend/src/components/LanguageSwitch/index.js +5 -0
- package/fe/frontend/{widgets → src}/components/Router/index.d.ts +2 -2
- package/fe/frontend/src/components/Router/index.js +21 -0
- package/fe/frontend/src/components/Router/type.js +0 -0
- package/fe/frontend/src/components/ThemeSwitch/ThemeSwitch.d.ts +15 -0
- package/fe/frontend/src/components/ThemeSwitch/ThemeSwitch.js +83 -0
- package/fe/frontend/src/components/ThemeSwitch/index.d.ts +4 -0
- package/fe/frontend/src/components/ThemeSwitch/index.js +5 -0
- package/fe/frontend/src/components/index.d.ts +11 -0
- package/fe/frontend/src/components/index.js +7 -0
- package/fe/frontend/src/defaultPages/Iframe/index.js +15 -0
- package/fe/frontend/src/defaultPages/NotFoundPage/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/NotFoundPage/index.js +28 -0
- package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/components/CallCom/DetailPanel.d.ts +1 -1
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/DetailPanel.js +102 -0
- package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/components/CallCom/PopFrom.d.ts +1 -1
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/PopFrom.js +119 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/builtIn.d.ts +44 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/builtIn.js +10 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/data.d.ts +4 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/data.js +9 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaSearch/index.js +62 -0
- package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/components/SchemaTable/index.d.ts +2 -2
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/index.js +200 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/eventInfo.js +9 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/index.js +4 -0
- package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/hooks/useComConfig.d.ts +1 -1
- package/fe/frontend/src/defaultPages/SchemaPage/hooks/useComConfig.js +17 -0
- package/fe/frontend/src/defaultPages/SchemaPage/index.css +112 -0
- package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/index.d.ts +1 -0
- package/fe/frontend/src/defaultPages/SchemaPage/index.js +90 -0
- package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/schemaType.d.ts +7 -6
- package/fe/frontend/src/defaultPages/SchemaPage/schemaType.js +7 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/permissions.js +6 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/schemaConversion.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/schemaConversion.js +66 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/validator.d.ts +11 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/validator.js +122 -0
- package/fe/frontend/{widgets → src}/defaultPages/SidebarSlotPage/SidebarSlotContainer.d.ts +2 -2
- package/fe/frontend/src/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +55 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/index.js +21 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPageTmp.js +21 -0
- package/fe/frontend/src/defaultPages/SlotPage/index.js +22 -0
- package/fe/frontend/src/exportStore.d.ts +17 -0
- package/fe/frontend/src/exportStore.js +5 -0
- package/fe/frontend/src/hooks/useCurrentMenuData.js +30 -0
- package/fe/frontend/src/hooks/useRouterParams.js +16 -0
- package/fe/frontend/src/index.d.ts +21 -0
- package/fe/frontend/src/index.js +19 -0
- package/fe/frontend/src/language/en-US.d.ts +89 -0
- package/fe/frontend/src/language/en-US.js +89 -0
- package/fe/frontend/src/language/index.d.ts +73 -0
- package/fe/frontend/src/language/index.js +79 -0
- package/fe/frontend/src/language/zh-CN.d.ts +89 -0
- package/fe/frontend/src/language/zh-CN.js +89 -0
- package/fe/frontend/src/main.css +96 -0
- package/fe/frontend/src/main.d.ts +27 -0
- package/fe/frontend/src/main.js +60 -0
- package/fe/frontend/src/stores/apiFreezer.d.ts +93 -0
- package/fe/frontend/src/stores/apiFreezer.js +53 -0
- package/fe/frontend/{widgets/store → src/stores}/mode.d.ts +3 -3
- package/fe/frontend/src/stores/mode.js +36 -0
- package/fe/frontend/{widgets/defaultPages/Schema → src}/stores/schemaEventBus.d.ts +1 -1
- package/fe/frontend/src/stores/schemaEventBus.js +53 -0
- package/fe/frontend/{widgets/defaultPages/Schema → src}/stores/schemaStore.d.ts +5 -5
- package/fe/frontend/src/stores/schemaStore.js +28 -0
- package/fe/frontend/{typing → src/typing}/scalability.d.ts +3 -3
- package/fe/frontend/src/typing/scalability.js +0 -0
- package/fe/frontend/src/typing/window.d.ts +9 -0
- package/fe/frontend/src/typing/window.js +0 -0
- package/fe/model/types/data/button.d.ts +4 -4
- package/fe/model/types/data/component.d.ts +32 -47
- package/fe/model/types/data/schema.d.ts +6 -6
- package/fe/model/types/data/search.d.ts +1 -1
- package/fe/model/types/model.d.ts +19 -12
- package/fe/packages/common/cache/LRUCache.js +43 -47
- package/fe/packages/common/guards/index.js +8 -24
- package/fe/packages/common/http/index.d.ts +90 -0
- package/fe/packages/common/http/index.js +300 -0
- package/fe/packages/common/i18n/default.js +91 -88
- package/fe/packages/common/i18n/en-US.js +91 -88
- package/fe/packages/common/i18n/index.d.ts +3 -3
- package/fe/packages/common/i18n/index.js +142 -153
- package/fe/packages/common/i18n/locales.d.ts +3 -3
- package/fe/packages/common/i18n/locales.js +10 -9
- package/fe/packages/common/index.d.ts +1 -0
- package/fe/packages/common/object/filterEmpty.js +25 -30
- package/fe/packages/react/hooks/useBreadcrumb.d.ts +10 -0
- package/fe/packages/react/hooks/useBreadcrumb.js +5 -0
- package/fe/packages/react/hooks/useExecuteOnce.js +47 -0
- package/fe/packages/react/hooks/useInit.js +11 -0
- package/fe/packages/react/hooks/useLanguage.d.ts +2 -0
- package/fe/packages/react/hooks/useLanguage.js +8 -0
- package/fe/packages/react/hooks/usePagination.js +30 -0
- package/fe/packages/{ui/react → react}/hooks/useRefState.d.ts +1 -1
- package/fe/packages/react/hooks/useRefState.js +35 -0
- package/fe/packages/react/hooks/useWatch.js +60 -0
- package/fe/packages/react/hooks/useWatch.test.js +24 -0
- package/fe/packages/react/ui/assets/table/no-result.js +4 -0
- package/fe/packages/{ui/react → react/ui}/components/Button/Button.d.ts +1 -1
- package/fe/packages/react/ui/components/Button/Button.js +88 -0
- package/fe/packages/react/ui/components/Button/SubmitButton.d.ts +13 -0
- package/fe/packages/react/ui/components/Button/SubmitButton.js +30 -0
- package/fe/packages/react/ui/components/Button/index.d.ts +4 -0
- package/fe/packages/react/ui/components/Button/index.js +3 -0
- package/fe/packages/react/ui/components/Card/Card.d.ts +15 -0
- package/fe/packages/react/ui/components/Card/Card.js +31 -0
- package/fe/packages/react/ui/components/Card/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Card/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/Checkbox/Checkbox.d.ts +1 -1
- package/fe/packages/react/ui/components/Checkbox/Checkbox.js +52 -0
- package/fe/packages/react/ui/components/Checkbox/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Checkbox/index.js +2 -0
- package/fe/packages/react/ui/components/ConfirmDialog/ConfirmDialog.js +41 -0
- package/fe/packages/react/ui/components/ConfirmDialog/index.d.ts +2 -0
- package/fe/packages/react/ui/components/ConfirmDialog/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/DataTable/ActionBtn.d.ts +1 -1
- package/fe/packages/react/ui/components/DataTable/ActionBtn.js +116 -0
- package/fe/packages/{ui/react → react/ui}/components/DataTable/index.d.ts +9 -7
- package/fe/packages/react/ui/components/DataTable/index.js +235 -0
- package/fe/packages/{ui/react → react/ui}/components/Date/Calendar.d.ts +2 -2
- package/fe/packages/react/ui/components/Date/Calendar.js +351 -0
- package/fe/packages/react/ui/components/Date/Date.js +210 -0
- package/fe/packages/react/ui/components/Date/DateTestPage.js +340 -0
- package/fe/packages/react/ui/components/Date/LocaleContext.js +11 -0
- package/fe/packages/{ui/react → react/ui}/components/Date/LocaleProvider.d.ts +2 -2
- package/fe/packages/react/ui/components/Date/LocaleProvider.js +31 -0
- package/fe/packages/react/ui/components/Date/TimePicker.js +136 -0
- package/fe/packages/react/ui/components/Date/data.js +7 -0
- package/fe/packages/{ui/react → react/ui}/components/Date/dateLocaleStore.d.ts +1 -1
- package/fe/packages/react/ui/components/Date/dateLocaleStore.js +14 -0
- package/fe/packages/react/ui/components/Date/dropdownPositioning.d.ts +3 -0
- package/fe/packages/react/ui/components/Date/dropdownPositioning.js +12 -0
- package/fe/packages/react/ui/components/Date/index.d.ts +6 -0
- package/fe/packages/react/ui/components/Date/index.js +6 -0
- package/fe/packages/react/ui/components/Date/locales.js +25 -0
- package/fe/packages/{ui/react → react/ui}/components/Drawer/Drawer.d.ts +1 -1
- package/fe/packages/react/ui/components/Drawer/Drawer.js +151 -0
- package/fe/packages/react/ui/components/Drawer/index.d.ts +3 -0
- package/fe/packages/react/ui/components/Drawer/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/Dropdown/Dropdown.d.ts +3 -2
- package/fe/packages/react/ui/components/Dropdown/Dropdown.js +105 -0
- package/fe/packages/react/ui/components/Dropdown/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Dropdown/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/Form/Form.d.ts +2 -2
- package/fe/packages/react/ui/components/Form/Form.js +15 -0
- package/fe/packages/{ui/react → react/ui}/components/Form/FormItem.d.ts +3 -3
- package/fe/packages/react/ui/components/Form/FormItem.js +60 -0
- package/fe/packages/{ui/react → react/ui}/components/Form/SchemaForm/data.d.ts +8 -8
- package/fe/packages/react/ui/components/Form/SchemaForm/data.js +16 -0
- package/fe/packages/react/ui/components/Form/SchemaForm/defaultComponentsMap.d.ts +4 -0
- package/fe/packages/react/ui/components/Form/SchemaForm/defaultComponentsMap.js +4 -0
- package/fe/packages/{ui/react → react/ui}/components/Form/SchemaForm/index.d.ts +9 -9
- package/fe/packages/react/ui/components/Form/SchemaForm/index.js +119 -0
- package/fe/packages/react/ui/components/Form/index.d.ts +5 -0
- package/fe/packages/react/ui/components/Form/index.js +5 -0
- package/fe/packages/react/ui/components/Form/useForm.d.ts +3 -0
- package/fe/packages/react/ui/components/Form/useForm.js +2 -0
- package/fe/packages/react/ui/components/ImagePreview/ImagePreview.js +307 -0
- package/fe/packages/{ui/react → react/ui}/components/ImagePreview/PreviewImage.d.ts +2 -2
- package/fe/packages/react/ui/components/ImagePreview/PreviewImage.js +56 -0
- package/fe/packages/react/ui/components/ImagePreview/index.d.ts +3 -0
- package/fe/packages/react/ui/components/ImagePreview/index.js +3 -0
- package/fe/packages/{ui/react → react/ui}/components/Input/Input.d.ts +1 -1
- package/fe/packages/react/ui/components/Input/Input.js +88 -0
- package/fe/packages/react/ui/components/Input/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Input/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/InputNumber/InputNumber.d.ts +2 -2
- package/fe/packages/react/ui/components/InputNumber/InputNumber.js +207 -0
- package/fe/packages/react/ui/components/InputNumber/index.d.ts +2 -0
- package/fe/packages/react/ui/components/InputNumber/index.js +2 -0
- package/fe/packages/react/ui/components/InputNumber/inputNumberUtils.js +45 -0
- package/fe/packages/react/ui/components/InputNumber/inputNumberUtils.test.js +59 -0
- package/fe/packages/{ui/react → react/ui}/components/Label/Label.d.ts +1 -1
- package/fe/packages/react/ui/components/Label/Label.js +58 -0
- package/fe/packages/react/ui/components/Label/index.d.ts +3 -0
- package/fe/packages/react/ui/components/Label/index.js +2 -0
- package/fe/packages/react/ui/components/Layout/Layout.d.ts +11 -0
- package/fe/packages/react/ui/components/Layout/Layout.js +33 -0
- package/fe/packages/react/ui/components/Layout/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Layout/index.js +2 -0
- package/fe/packages/react/ui/components/Loading/Loading.d.ts +25 -0
- package/fe/packages/react/ui/components/Loading/Loading.js +48 -0
- package/fe/packages/react/ui/components/Loading/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Loading/index.js +2 -0
- package/fe/packages/react/ui/components/Menu/Menu.js +147 -0
- package/fe/packages/react/ui/components/Menu/MenuContext.js +88 -0
- package/fe/packages/react/ui/components/Menu/MenuItem.js +78 -0
- package/fe/packages/react/ui/components/Menu/SubMenu.js +207 -0
- package/fe/packages/react/ui/components/Menu/index.d.ts +9 -0
- package/fe/packages/react/ui/components/Menu/index.js +5 -0
- package/fe/packages/{ui/react → react/ui}/components/Menu/menuTypes.d.ts +1 -1
- package/fe/packages/react/ui/components/Menu/menuTypes.js +0 -0
- package/fe/packages/react/ui/components/Menu/utils.js +8 -0
- package/fe/packages/{ui/react → react/ui}/components/Message/Message.d.ts +1 -1
- package/fe/packages/react/ui/components/Message/Message.js +76 -0
- package/fe/packages/{ui/react → react/ui}/components/Message/MessageManager.d.ts +2 -2
- package/fe/packages/react/ui/components/Message/MessageManager.js +104 -0
- package/fe/packages/react/ui/components/Message/data.js +4 -0
- package/fe/packages/react/ui/components/Message/index.d.ts +3 -0
- package/fe/packages/react/ui/components/Message/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/Modal/Modal.d.ts +1 -1
- package/fe/packages/react/ui/components/Modal/Modal.js +59 -0
- package/fe/packages/{ui/react → react/ui}/components/Modal/ModalManager.d.ts +5 -5
- package/fe/packages/react/ui/components/Modal/ModalManager.js +106 -0
- package/fe/packages/react/ui/components/Modal/index.d.ts +4 -0
- package/fe/packages/react/ui/components/Modal/index.js +3 -0
- package/fe/packages/react/ui/components/Notification/Notification.d.ts +14 -0
- package/fe/packages/react/ui/components/Notification/Notification.js +56 -0
- package/fe/packages/react/ui/components/Notification/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Notification/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/Overlay/Overlay.d.ts +1 -1
- package/fe/packages/react/ui/components/Overlay/Overlay.js +61 -0
- package/fe/packages/react/ui/components/Overlay/index.d.ts +3 -0
- package/fe/packages/react/ui/components/Overlay/index.js +2 -0
- package/fe/packages/react/ui/components/Pagination/Pagination.js +115 -0
- package/fe/packages/react/ui/components/Pagination/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Pagination/index.js +2 -0
- package/fe/packages/react/ui/components/Popup/Popup.js +86 -0
- package/fe/packages/react/ui/components/Popup/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Popup/index.js +2 -0
- package/fe/packages/react/ui/components/Radio/Radio.d.ts +9 -0
- package/fe/packages/react/ui/components/Radio/Radio.js +36 -0
- package/fe/packages/react/ui/components/Radio/RadioGroup.d.ts +19 -0
- package/fe/packages/react/ui/components/Radio/RadioGroup.js +33 -0
- package/fe/packages/react/ui/components/Radio/index.d.ts +3 -0
- package/fe/packages/react/ui/components/Radio/index.js +3 -0
- package/fe/packages/{ui/react → react/ui}/components/Search/Search.d.ts +4 -4
- package/fe/packages/react/ui/components/Search/Search.js +24 -0
- package/fe/packages/react/ui/components/Search/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Search/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/Select/Select.d.ts +1 -1
- package/fe/packages/react/ui/components/Select/Select.js +276 -0
- package/fe/packages/react/ui/components/Select/dropdownPositioning.d.ts +3 -0
- package/fe/packages/react/ui/components/Select/dropdownPositioning.js +16 -0
- package/fe/packages/react/ui/components/Select/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Select/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/Skeleton/Skeleton.d.ts +1 -1
- package/fe/packages/react/ui/components/Skeleton/Skeleton.js +101 -0
- package/fe/packages/react/ui/components/Skeleton/index.d.ts +3 -0
- package/fe/packages/react/ui/components/Skeleton/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/Switch/Switch.d.ts +1 -1
- package/fe/packages/react/ui/components/Switch/Switch.js +28 -0
- package/fe/packages/react/ui/components/Switch/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Switch/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/TableSearch/TableSearch.d.ts +6 -6
- package/fe/packages/react/ui/components/TableSearch/TableSearch.js +146 -0
- package/fe/packages/react/ui/components/TableSearch/index.d.ts +3 -0
- package/fe/packages/react/ui/components/TableSearch/index.js +2 -0
- package/fe/packages/react/ui/components/TableSearch/lang.js +14 -0
- package/fe/packages/{ui/react → react/ui}/components/TableSearch/tableSearchLocaleStore.d.ts +1 -1
- package/fe/packages/react/ui/components/TableSearch/tableSearchLocaleStore.js +10 -0
- package/fe/packages/react/ui/components/Tabs/Tabs.d.ts +16 -0
- package/fe/packages/react/ui/components/Tabs/Tabs.js +33 -0
- package/fe/packages/react/ui/components/Tabs/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Tabs/index.js +2 -0
- package/fe/packages/react/ui/components/Textarea/Textarea.js +58 -0
- package/fe/packages/react/ui/components/Textarea/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Textarea/index.js +2 -0
- package/fe/packages/react/ui/components/Tooltip/Tooltip.js +77 -0
- package/fe/packages/react/ui/components/Tooltip/index.d.ts +2 -0
- package/fe/packages/react/ui/components/Tooltip/index.js +2 -0
- package/fe/packages/react/ui/components/TreeSelect/TreeSelect.js +190 -0
- package/fe/packages/react/ui/components/TreeSelect/index.d.ts +2 -0
- package/fe/packages/react/ui/components/TreeSelect/index.js +2 -0
- package/fe/packages/react/ui/components/Upload/ImageUpload.js +101 -0
- package/fe/packages/{ui/react → react/ui}/components/Upload/Upload.d.ts +1 -1
- package/fe/packages/react/ui/components/Upload/Upload.js +29 -0
- package/fe/packages/react/ui/components/Upload/index.d.ts +3 -0
- package/fe/packages/react/ui/components/Upload/index.js +3 -0
- package/fe/packages/react/ui/components/breadcrumb/breadcrumb.js +155 -0
- package/fe/packages/react/ui/components/breadcrumb/index.d.ts +2 -0
- package/fe/packages/react/ui/components/breadcrumb/index.js +2 -0
- package/fe/packages/react/ui/components/hooks/useDropdownPositioning.js +121 -0
- package/fe/packages/react/ui/components/hooks/useInputController.js +39 -0
- package/fe/packages/react/ui/components/index.d.ts +36 -0
- package/fe/packages/react/ui/components/index.js +81 -0
- package/fe/packages/react/ui/components/table/index.d.ts +2 -0
- package/fe/packages/react/ui/components/table/index.js +2 -0
- package/fe/packages/{ui/react → react/ui}/components/table/table.d.ts +16 -3
- package/fe/packages/react/ui/components/table/table.js +166 -0
- package/fe/packages/react/ui/components/testPage/MenuTestPage.js +397 -0
- package/fe/packages/react/ui/components/testPage/index.js +1612 -0
- package/fe/packages/{ui/react → react/ui}/i18n/I18nProvider.d.ts +2 -2
- package/fe/packages/react/ui/i18n/I18nProvider.js +38 -0
- package/fe/packages/react/ui/i18n/index.d.ts +4 -0
- package/fe/packages/react/ui/i18n/index.js +7 -0
- package/fe/packages/react/ui/i18n/useI18n.d.ts +13 -0
- package/fe/packages/react/ui/i18n/useI18n.js +25 -0
- package/fe/packages/{ui/react → react/ui}/index.css +70 -9
- package/fe/packages/react/ui/index.d.ts +5 -0
- package/fe/packages/react/ui/index.js +58 -0
- package/fe/packages/{ui/react → react/ui}/lib/createStoreHook.d.ts +1 -1
- package/fe/packages/react/ui/lib/createStoreHook.js +9 -0
- package/fe/packages/{ui/react → react/ui}/lib/export.d.ts +1 -1
- package/fe/packages/react/ui/lib/export.js +112 -0
- package/fe/packages/react/ui/lib/utils.js +64 -0
- package/fe/packages/{ui/react → react/ui}/stores/breadcrumb.d.ts +1 -1
- package/fe/packages/react/ui/stores/breadcrumb.js +52 -0
- package/fe/packages/react/ui/stores/language.d.ts +4 -0
- package/fe/packages/react/ui/stores/language.js +4 -0
- package/fe/packages/react/ui/types/index.js +0 -0
- package/fe/typings/type.d.ts +1 -0
- package/model/index.d.ts +1 -1
- package/model/types/data/button.d.ts +4 -4
- package/model/types/data/component.d.ts +32 -47
- package/model/types/data/schema.d.ts +6 -6
- package/model/types/data/search.d.ts +1 -1
- package/model/types/index.d.ts +2 -1
- package/model/types/model.d.ts +19 -12
- package/package.json +37 -39
- package/types/app/controller/project.d.ts +14 -2
- package/types/app/controller/view.d.ts +1 -1
- package/types/app/extend/$fetch.d.ts +8 -0
- package/types/app/extend/db.d.ts +54 -1
- package/types/app/extend/render-view.d.ts +3 -0
- package/types/app/middleware/api-params-verify.d.ts +1 -1
- package/types/app/middleware/project-handler.d.ts +2 -2
- package/types/app/router/project.d.ts +1 -1
- package/types/app/service/base.d.ts +3 -4
- package/types/app/service/project.d.ts +7 -2
- package/types/app/type.d.ts +5 -3
- package/types/app/typings.d.ts +4 -2
- package/types/bundler/buildBE.d.ts +13 -0
- package/types/bundler/index.d.ts +4 -1
- package/types/bundler/state.d.ts +18 -0
- package/types/bundler/utils.d.ts +5 -0
- package/types/config/config.default.d.ts +33 -2
- package/types/index.d.ts +6 -5
- package/{fe/frontend/widgets/common/CRUD/CRUD.d.ts → types/packages/common/http/index.d.ts} +29 -10
- package/types/packages/common/i18n/default.d.ts +5 -0
- package/types/packages/common/i18n/en-US.d.ts +5 -0
- package/types/packages/common/i18n/index.d.ts +24 -0
- package/types/packages/common/i18n/types.d.ts +24 -0
- package/types/packages/common/index.d.ts +1 -0
- package/types/packages/core/index.d.ts +3 -3
- package/types/packages/core/loader/config.d.ts +6 -0
- package/types/packages/core/loader/controller.d.ts +14 -0
- package/types/packages/core/loader/extend.d.ts +6 -1
- package/types/packages/core/loader/middleware.d.ts +8 -0
- package/types/packages/core/loader/model.d.ts +22 -0
- package/types/packages/core/loader/router-schema.d.ts +15 -0
- package/types/packages/core/loader/router.d.ts +5 -0
- package/types/packages/core/loader/service.d.ts +14 -0
- package/types/packages/core/paths.d.ts +10 -7
- package/types/packages/core/types.d.ts +66 -3
- package/types/packages/utils/getAllFilesInFolder.d.ts +5 -0
- package/types/packages/utils/loadFile.d.ts +6 -0
- package/types/packages/utils/path.d.ts +18 -0
- package/types/scripts/vite-build/build.d.ts +24 -0
- package/types/scripts/vite-build/collect.d.ts +57 -0
- package/types/scripts/vite-build/constants.d.ts +6 -0
- package/types/scripts/vite-build/dts.d.ts +53 -0
- package/types/scripts/vite-build/index.d.ts +2 -0
- package/types/scripts/vite-build/normalize.d.ts +66 -0
- package/types/scripts/vite-build/plugins.d.ts +67 -0
- package/types/scripts/vite-build/resolve.d.ts +61 -0
- package/types/scripts/vite-build/types.d.ts +174 -0
- package/types/scripts/vite-build/utils.d.ts +35 -0
- package/types/typings/type.d.ts +1 -0
- package/cjs/app/README.md +0 -286
- package/cjs/app/data/signKey.js +0 -23
- package/esm/app/README.md +0 -286
- package/esm/app/data/signKey.js +0 -10
- package/fe/frontend/components/AsyncSelect/AsyncSelect.js +0 -32
- package/fe/frontend/components/AsyncSelect/index.d.ts +0 -4
- package/fe/frontend/components/AsyncSelect/index.js +0 -3
- package/fe/frontend/dash/Dashboard.d.ts +0 -7
- package/fe/frontend/dash/Dashboard.js +0 -73
- package/fe/frontend/dash/dash.entry.js +0 -93
- package/fe/frontend/dash/types.d.ts +0 -17
- package/fe/frontend/dash/types.js +0 -1
- package/fe/frontend/index.d.ts +0 -5
- package/fe/frontend/index.js +0 -2
- package/fe/frontend/main.css +0 -5
- package/fe/frontend/main.d.ts +0 -11
- package/fe/frontend/main.js +0 -19
- package/fe/frontend/testPage/index.js +0 -6
- package/fe/frontend/testPage/testPage.entry.d.ts +0 -2
- package/fe/frontend/testPage/testPage.entry.js +0 -3
- package/fe/frontend/typing/scalability.js +0 -1
- package/fe/frontend/typing/window.d.ts +0 -7
- package/fe/frontend/typing/window.js +0 -1
- package/fe/frontend/widgets/api/baseInfo.js +0 -15
- package/fe/frontend/widgets/common/CRUD/CRUD.js +0 -208
- package/fe/frontend/widgets/common/CRUD/index.d.ts +0 -2
- package/fe/frontend/widgets/common/CRUD/index.js +0 -1
- package/fe/frontend/widgets/common/auth/index.js +0 -20
- package/fe/frontend/widgets/common/generateMenuData.d.ts +0 -4
- package/fe/frontend/widgets/common/generateMenuData.js +0 -14
- package/fe/frontend/widgets/common/importComponent.js +0 -8
- package/fe/frontend/widgets/common/language.d.ts +0 -2
- package/fe/frontend/widgets/common/language.js +0 -9
- package/fe/frontend/widgets/common/logFn/index.js +0 -8
- package/fe/frontend/widgets/common/menu.js +0 -101
- package/fe/frontend/widgets/common/request.d.ts +0 -36
- package/fe/frontend/widgets/common/request.js +0 -133
- package/fe/frontend/widgets/components/BasePage/HeaderView.js +0 -16
- package/fe/frontend/widgets/components/Router/index.js +0 -11
- package/fe/frontend/widgets/components/Router/type.js +0 -1
- package/fe/frontend/widgets/defaultPages/Iframe/index.js +0 -14
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/DetailPanel.js +0 -94
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.js +0 -124
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/data.d.ts +0 -3
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/data.js +0 -6
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.js +0 -63
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.js +0 -188
- package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.js +0 -6
- package/fe/frontend/widgets/defaultPages/Schema/data/index.js +0 -1
- package/fe/frontend/widgets/defaultPages/Schema/hooks/useComConfig.js +0 -14
- package/fe/frontend/widgets/defaultPages/Schema/index.js +0 -74
- package/fe/frontend/widgets/defaultPages/Schema/schemaType.js +0 -4
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.js +0 -70
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.js +0 -26
- package/fe/frontend/widgets/defaultPages/Schema/utils/fetchErrorShow.js +0 -8
- package/fe/frontend/widgets/defaultPages/Schema/utils/permissions.js +0 -3
- package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.d.ts +0 -3
- package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.js +0 -115
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.d.ts +0 -7
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.js +0 -36
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +0 -38
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.js +0 -16
- package/fe/frontend/widgets/defaultPages/SidebarSlotPageTmp.js +0 -17
- package/fe/frontend/widgets/defaultPages/SlotPage/index.js +0 -26
- package/fe/frontend/widgets/defaultPages/Todo.d.ts +0 -3
- package/fe/frontend/widgets/defaultPages/Todo.js +0 -5
- package/fe/frontend/widgets/hooks/useCurrentMenuData.js +0 -28
- package/fe/frontend/widgets/hooks/useRouterParams.js +0 -11
- package/fe/frontend/widgets/store/mode.js +0 -37
- package/fe/model/types/data/button.js +0 -16
- package/fe/model/types/data/component.js +0 -11
- package/fe/model/types/data/fetchInfo.js +0 -1
- package/fe/model/types/data/schema.js +0 -1
- package/fe/model/types/data/search.js +0 -1
- package/fe/model/types/menuType.js +0 -1
- package/fe/model/types/model.js +0 -1
- package/fe/packages/common/array/index.js +0 -40
- package/fe/packages/common/cache/index.js +0 -1
- package/fe/packages/common/i18n/types.js +0 -1
- package/fe/packages/common/index.js +0 -9
- package/fe/packages/common/log/index.js +0 -176
- package/fe/packages/common/number/index.js +0 -10
- package/fe/packages/common/object/index.js +0 -25
- package/fe/packages/common/string/index.js +0 -17
- package/fe/packages/common/types/index.js +0 -1
- package/fe/packages/ui/react/components/Button/Button.js +0 -72
- package/fe/packages/ui/react/components/Button/SumbitButton.d.ts +0 -13
- package/fe/packages/ui/react/components/Button/SumbitButton.js +0 -25
- package/fe/packages/ui/react/components/Button/index.d.ts +0 -4
- package/fe/packages/ui/react/components/Button/index.js +0 -2
- package/fe/packages/ui/react/components/Checkbox/Checkbox.js +0 -39
- package/fe/packages/ui/react/components/Checkbox/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Checkbox/index.js +0 -1
- package/fe/packages/ui/react/components/ConfirmDialog/ConfirmDialog.js +0 -11
- package/fe/packages/ui/react/components/ConfirmDialog/index.d.ts +0 -2
- package/fe/packages/ui/react/components/ConfirmDialog/index.js +0 -1
- package/fe/packages/ui/react/components/DataTable/ActionBtn.js +0 -94
- package/fe/packages/ui/react/components/DataTable/index.js +0 -155
- package/fe/packages/ui/react/components/Date/Calendar.js +0 -216
- package/fe/packages/ui/react/components/Date/Date.js +0 -201
- package/fe/packages/ui/react/components/Date/DateTestPage.js +0 -29
- package/fe/packages/ui/react/components/Date/LocaleContext.js +0 -8
- package/fe/packages/ui/react/components/Date/LocaleProvider.js +0 -24
- package/fe/packages/ui/react/components/Date/TimePicker.js +0 -78
- package/fe/packages/ui/react/components/Date/data.js +0 -4
- package/fe/packages/ui/react/components/Date/dateLocaleStore.js +0 -14
- package/fe/packages/ui/react/components/Date/dropdownPositioning.d.ts +0 -3
- package/fe/packages/ui/react/components/Date/dropdownPositioning.js +0 -12
- package/fe/packages/ui/react/components/Date/index.d.ts +0 -6
- package/fe/packages/ui/react/components/Date/index.js +0 -5
- package/fe/packages/ui/react/components/Date/locales.js +0 -21
- package/fe/packages/ui/react/components/Drawer/Drawer.js +0 -100
- package/fe/packages/ui/react/components/Drawer/index.d.ts +0 -3
- package/fe/packages/ui/react/components/Drawer/index.js +0 -1
- package/fe/packages/ui/react/components/Dropdown/Dropdown.js +0 -28
- package/fe/packages/ui/react/components/Dropdown/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Dropdown/index.js +0 -1
- package/fe/packages/ui/react/components/Form/Form.js +0 -8
- package/fe/packages/ui/react/components/Form/FormItem.js +0 -43
- package/fe/packages/ui/react/components/Form/SchemaForm/data.js +0 -18
- package/fe/packages/ui/react/components/Form/SchemaForm/index.js +0 -79
- package/fe/packages/ui/react/components/Form/index.d.ts +0 -5
- package/fe/packages/ui/react/components/Form/index.js +0 -4
- package/fe/packages/ui/react/components/Form/useForm.d.ts +0 -3
- package/fe/packages/ui/react/components/Form/useForm.js +0 -1
- package/fe/packages/ui/react/components/ImagePreview/ImagePreview.js +0 -169
- package/fe/packages/ui/react/components/ImagePreview/PreviewImage.js +0 -28
- package/fe/packages/ui/react/components/ImagePreview/index.d.ts +0 -3
- package/fe/packages/ui/react/components/ImagePreview/index.js +0 -2
- package/fe/packages/ui/react/components/Input/Input.js +0 -61
- package/fe/packages/ui/react/components/Input/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Input/index.js +0 -1
- package/fe/packages/ui/react/components/InputNumber/InputNumber.js +0 -144
- package/fe/packages/ui/react/components/InputNumber/index.d.ts +0 -2
- package/fe/packages/ui/react/components/InputNumber/index.js +0 -1
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.js +0 -63
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.js +0 -27
- package/fe/packages/ui/react/components/Label/Label.js +0 -35
- package/fe/packages/ui/react/components/Label/index.d.ts +0 -3
- package/fe/packages/ui/react/components/Label/index.js +0 -2
- package/fe/packages/ui/react/components/Menu/Menu.js +0 -102
- package/fe/packages/ui/react/components/Menu/MenuContext.js +0 -97
- package/fe/packages/ui/react/components/Menu/MenuItem.js +0 -33
- package/fe/packages/ui/react/components/Menu/SubMenu.js +0 -169
- package/fe/packages/ui/react/components/Menu/index.d.ts +0 -9
- package/fe/packages/ui/react/components/Menu/index.js +0 -5
- package/fe/packages/ui/react/components/Menu/menuTypes.js +0 -1
- package/fe/packages/ui/react/components/Menu/utils.js +0 -7
- package/fe/packages/ui/react/components/Message/Message.js +0 -58
- package/fe/packages/ui/react/components/Message/MessageManager.js +0 -90
- package/fe/packages/ui/react/components/Message/data.js +0 -1
- package/fe/packages/ui/react/components/Message/index.d.ts +0 -3
- package/fe/packages/ui/react/components/Message/index.js +0 -1
- package/fe/packages/ui/react/components/Modal/Modal.js +0 -14
- package/fe/packages/ui/react/components/Modal/ModalManager.js +0 -90
- package/fe/packages/ui/react/components/Modal/index.d.ts +0 -4
- package/fe/packages/ui/react/components/Modal/index.js +0 -2
- package/fe/packages/ui/react/components/Overlay/Overlay.js +0 -53
- package/fe/packages/ui/react/components/Overlay/index.d.ts +0 -3
- package/fe/packages/ui/react/components/Overlay/index.js +0 -1
- package/fe/packages/ui/react/components/Pagination/Pagination.js +0 -88
- package/fe/packages/ui/react/components/Pagination/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Pagination/index.js +0 -1
- package/fe/packages/ui/react/components/Popup/Popup.js +0 -81
- package/fe/packages/ui/react/components/Popup/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Popup/index.js +0 -1
- package/fe/packages/ui/react/components/Search/Search.js +0 -12
- package/fe/packages/ui/react/components/Search/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Search/index.js +0 -1
- package/fe/packages/ui/react/components/Select/Select.js +0 -123
- package/fe/packages/ui/react/components/Select/dropdownPositioning.d.ts +0 -3
- package/fe/packages/ui/react/components/Select/dropdownPositioning.js +0 -13
- package/fe/packages/ui/react/components/Select/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Select/index.js +0 -1
- package/fe/packages/ui/react/components/Skeleton/Skeleton.js +0 -31
- package/fe/packages/ui/react/components/Skeleton/index.d.ts +0 -3
- package/fe/packages/ui/react/components/Skeleton/index.js +0 -1
- package/fe/packages/ui/react/components/Switch/Switch.js +0 -22
- package/fe/packages/ui/react/components/Switch/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Switch/index.js +0 -1
- package/fe/packages/ui/react/components/TableSearch/TableSearch.js +0 -121
- package/fe/packages/ui/react/components/TableSearch/index.d.ts +0 -2
- package/fe/packages/ui/react/components/TableSearch/index.js +0 -1
- package/fe/packages/ui/react/components/TableSearch/lang.js +0 -14
- package/fe/packages/ui/react/components/TableSearch/tableSearchLocaleStore.js +0 -11
- package/fe/packages/ui/react/components/Textarea/Textarea.js +0 -37
- package/fe/packages/ui/react/components/Textarea/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Textarea/index.js +0 -1
- package/fe/packages/ui/react/components/Tooltip/Tooltip.js +0 -79
- package/fe/packages/ui/react/components/Tooltip/index.d.ts +0 -2
- package/fe/packages/ui/react/components/Tooltip/index.js +0 -1
- package/fe/packages/ui/react/components/TreeSelect/TreeSelect.js +0 -160
- package/fe/packages/ui/react/components/TreeSelect/index.d.ts +0 -2
- package/fe/packages/ui/react/components/TreeSelect/index.js +0 -1
- package/fe/packages/ui/react/components/Upload/ImageUpload.js +0 -75
- package/fe/packages/ui/react/components/Upload/Upload.js +0 -6
- package/fe/packages/ui/react/components/Upload/index.d.ts +0 -3
- package/fe/packages/ui/react/components/Upload/index.js +0 -2
- package/fe/packages/ui/react/components/breadcrumb/breadcrumb.js +0 -81
- package/fe/packages/ui/react/components/breadcrumb/index.d.ts +0 -2
- package/fe/packages/ui/react/components/breadcrumb/index.js +0 -1
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.js +0 -137
- package/fe/packages/ui/react/components/hooks/useInputController.js +0 -45
- package/fe/packages/ui/react/components/index.d.ts +0 -30
- package/fe/packages/ui/react/components/index.js +0 -29
- package/fe/packages/ui/react/components/table/index.d.ts +0 -2
- package/fe/packages/ui/react/components/table/index.js +0 -1
- package/fe/packages/ui/react/components/table/table.js +0 -20
- package/fe/packages/ui/react/components/testPage/MenuTestPage.js +0 -104
- package/fe/packages/ui/react/components/testPage/index.js +0 -314
- package/fe/packages/ui/react/hooks/useBreadcrumb.d.ts +0 -10
- package/fe/packages/ui/react/hooks/useBreadcrumb.js +0 -2
- package/fe/packages/ui/react/hooks/useExecuteOnce.js +0 -57
- package/fe/packages/ui/react/hooks/useInit.js +0 -9
- package/fe/packages/ui/react/hooks/useLanguage.d.ts +0 -2
- package/fe/packages/ui/react/hooks/useLanguage.js +0 -4
- package/fe/packages/ui/react/hooks/usePagination.js +0 -27
- package/fe/packages/ui/react/hooks/useRefState.js +0 -29
- package/fe/packages/ui/react/hooks/useWatch.js +0 -87
- package/fe/packages/ui/react/hooks/useWatch.test.js +0 -22
- package/fe/packages/ui/react/i18n/I18nProvider.js +0 -25
- package/fe/packages/ui/react/i18n/index.d.ts +0 -4
- package/fe/packages/ui/react/i18n/index.js +0 -3
- package/fe/packages/ui/react/i18n/useI18n.d.ts +0 -13
- package/fe/packages/ui/react/i18n/useI18n.js +0 -18
- package/fe/packages/ui/react/index.d.ts +0 -5
- package/fe/packages/ui/react/index.js +0 -6
- package/fe/packages/ui/react/lib/createStoreHook.js +0 -6
- package/fe/packages/ui/react/lib/export.js +0 -138
- package/fe/packages/ui/react/lib/utils.js +0 -70
- package/fe/packages/ui/react/stores/breadcrumb.js +0 -66
- package/fe/packages/ui/react/stores/language.d.ts +0 -4
- package/fe/packages/ui/react/stores/language.js +0 -2
- package/fe/packages/ui/react/types/index.js +0 -1
- package/fe/typings/type.js +0 -1
- package/types/app/data/signKey.d.ts +0 -1
- /package/fe/frontend/{dash → apps/dash}/dash.entry.d.ts +0 -0
- /package/fe/frontend/{testPage → apps/ui-components}/index.d.ts +0 -0
- /package/fe/frontend/{widgets → src}/common/auth/index.d.ts +0 -0
- /package/fe/frontend/{widgets → src}/components/Router/type.d.ts +0 -0
- /package/fe/frontend/{widgets → src}/defaultPages/Iframe/index.d.ts +0 -0
- /package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/components/SchemaSearch/index.d.ts +0 -0
- /package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/data/eventInfo.d.ts +0 -0
- /package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/data/index.d.ts +0 -0
- /package/fe/frontend/{widgets/defaultPages/Schema → src/defaultPages/SchemaPage}/utils/permissions.d.ts +0 -0
- /package/fe/frontend/{widgets → src}/defaultPages/SidebarSlotPage/index.d.ts +0 -0
- /package/fe/frontend/{widgets → src}/defaultPages/SidebarSlotPageTmp.d.ts +0 -0
- /package/fe/frontend/{widgets → src}/defaultPages/SlotPage/index.d.ts +0 -0
- /package/fe/frontend/{widgets → src}/hooks/useCurrentMenuData.d.ts +0 -0
- /package/fe/frontend/{widgets → src}/hooks/useRouterParams.d.ts +0 -0
- /package/fe/packages/{ui/react → react}/hooks/useExecuteOnce.d.ts +0 -0
- /package/fe/packages/{ui/react → react}/hooks/useInit.d.ts +0 -0
- /package/fe/packages/{ui/react → react}/hooks/usePagination.d.ts +0 -0
- /package/fe/packages/{ui/react → react}/hooks/useWatch.d.ts +0 -0
- /package/fe/packages/{ui/react → react}/hooks/useWatch.test.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/assets/table/no-result.svg +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/ConfirmDialog/ConfirmDialog.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Date/Date.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Date/DateTestPage.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Date/LocaleContext.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Date/TimePicker.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Date/data.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Date/locales.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/ImagePreview/ImagePreview.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/InputNumber/inputNumberUtils.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/InputNumber/inputNumberUtils.test.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Menu/Menu.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Menu/MenuContext.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Menu/MenuItem.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Menu/SubMenu.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Menu/utils.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Message/data.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Pagination/Pagination.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Popup/Popup.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/TableSearch/lang.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Textarea/Textarea.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Tooltip/Tooltip.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/TreeSelect/TreeSelect.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/Upload/ImageUpload.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/breadcrumb/breadcrumb.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/hooks/useDropdownPositioning.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/hooks/useInputController.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/testPage/MenuTestPage.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/components/testPage/index.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/lib/utils.d.ts +0 -0
- /package/fe/packages/{ui/react → react/ui}/types/index.d.ts +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { cn } from "../../lib/utils.js";
|
|
2
|
+
import { Button } from "../Button/Button.js";
|
|
3
|
+
import "../Button/index.js";
|
|
4
|
+
import { Checkbox } from "../Checkbox/Checkbox.js";
|
|
5
|
+
import "../Checkbox/index.js";
|
|
6
|
+
import { useCallback, useMemo, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { ChevronDown, ChevronRight } from "lucide-react";
|
|
9
|
+
//#region packages/react/ui/components/TreeSelect/TreeSelect.tsx
|
|
10
|
+
function TreeSelect({ data, value = [], onChange, labelField = "name", checkable = true, className }) {
|
|
11
|
+
const [expandedKeys, setExpandedKeys] = useState(/* @__PURE__ */ new Set());
|
|
12
|
+
const { nodeMap, parentMap } = useMemo(() => {
|
|
13
|
+
const nodeM = /* @__PURE__ */ new Map();
|
|
14
|
+
const parentM = /* @__PURE__ */ new Map();
|
|
15
|
+
const traverse = (nodes, parentId) => {
|
|
16
|
+
nodes.forEach((node) => {
|
|
17
|
+
nodeM.set(node.id, node);
|
|
18
|
+
parentM.set(node.id, parentId);
|
|
19
|
+
if (node.children && node.children.length > 0) traverse(node.children, node.id);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
traverse(data, null);
|
|
23
|
+
return {
|
|
24
|
+
nodeMap: nodeM,
|
|
25
|
+
parentMap: parentM
|
|
26
|
+
};
|
|
27
|
+
}, [data]);
|
|
28
|
+
const getDescendantIds = useCallback((node) => {
|
|
29
|
+
const ids = [];
|
|
30
|
+
const traverse = (n) => {
|
|
31
|
+
if (n.children && n.children.length > 0) n.children.forEach((child) => {
|
|
32
|
+
ids.push(child.id);
|
|
33
|
+
traverse(child);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
traverse(node);
|
|
37
|
+
return ids;
|
|
38
|
+
}, []);
|
|
39
|
+
const updateParentSelection = useCallback((checkedSet) => {
|
|
40
|
+
const traverseUp = (nodeId) => {
|
|
41
|
+
const parentId = parentMap.get(nodeId);
|
|
42
|
+
if (parentId === void 0 || parentId === null) return;
|
|
43
|
+
const parentNode = nodeMap.get(parentId);
|
|
44
|
+
if (!parentNode || !parentNode.children) return;
|
|
45
|
+
const childIds = parentNode.children.map((child) => child.id);
|
|
46
|
+
if (childIds.filter((id) => checkedSet.has(id)).length === childIds.length) checkedSet.add(parentId);
|
|
47
|
+
else checkedSet.delete(parentId);
|
|
48
|
+
traverseUp(parentId);
|
|
49
|
+
};
|
|
50
|
+
checkedSet.forEach((id) => traverseUp(id));
|
|
51
|
+
}, [nodeMap, parentMap]);
|
|
52
|
+
const toggleExpand = useCallback((nodeId) => {
|
|
53
|
+
setExpandedKeys((prev) => {
|
|
54
|
+
const newSet = new Set(prev);
|
|
55
|
+
if (newSet.has(nodeId)) newSet.delete(nodeId);
|
|
56
|
+
else newSet.add(nodeId);
|
|
57
|
+
return newSet;
|
|
58
|
+
});
|
|
59
|
+
}, []);
|
|
60
|
+
const getIndeterminateKeys = useCallback((checkedSet) => {
|
|
61
|
+
const indeterminateKeys = [];
|
|
62
|
+
const getDescendantCount = (node) => {
|
|
63
|
+
if (!node.children || node.children.length === 0) return {
|
|
64
|
+
total: 1,
|
|
65
|
+
checked: checkedSet.has(node.id) ? 1 : 0
|
|
66
|
+
};
|
|
67
|
+
return node.children.reduce((acc, child) => {
|
|
68
|
+
const childResult = getDescendantCount(child);
|
|
69
|
+
return {
|
|
70
|
+
total: acc.total + childResult.total,
|
|
71
|
+
checked: acc.checked + childResult.checked
|
|
72
|
+
};
|
|
73
|
+
}, {
|
|
74
|
+
total: 0,
|
|
75
|
+
checked: 0
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const traverse = (nodes) => {
|
|
79
|
+
nodes.forEach((node) => {
|
|
80
|
+
if (node.children && node.children.length > 0) {
|
|
81
|
+
const { total, checked } = getDescendantCount(node);
|
|
82
|
+
if (checked > 0 && checked < total) indeterminateKeys.push(node.id);
|
|
83
|
+
traverse(node.children);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
traverse(data);
|
|
88
|
+
return indeterminateKeys;
|
|
89
|
+
}, [data]);
|
|
90
|
+
const toggleCheck = useCallback((node) => {
|
|
91
|
+
if (!checkable || !onChange) return;
|
|
92
|
+
const isChecked = value.includes(node.id);
|
|
93
|
+
const nextChecked = new Set(value);
|
|
94
|
+
const descendantIds = getDescendantIds(node);
|
|
95
|
+
if (isChecked) {
|
|
96
|
+
nextChecked.delete(node.id);
|
|
97
|
+
descendantIds.forEach((id) => nextChecked.delete(id));
|
|
98
|
+
} else {
|
|
99
|
+
nextChecked.add(node.id);
|
|
100
|
+
descendantIds.forEach((id) => nextChecked.add(id));
|
|
101
|
+
}
|
|
102
|
+
updateParentSelection(nextChecked);
|
|
103
|
+
const indeterminateKeys = getIndeterminateKeys(nextChecked);
|
|
104
|
+
onChange({
|
|
105
|
+
checked: Array.from(nextChecked),
|
|
106
|
+
indeterminate: indeterminateKeys
|
|
107
|
+
});
|
|
108
|
+
}, [
|
|
109
|
+
value,
|
|
110
|
+
onChange,
|
|
111
|
+
checkable,
|
|
112
|
+
getDescendantIds,
|
|
113
|
+
updateParentSelection,
|
|
114
|
+
getIndeterminateKeys
|
|
115
|
+
]);
|
|
116
|
+
const isNodeChecked = useCallback((nodeId) => {
|
|
117
|
+
return value.includes(nodeId);
|
|
118
|
+
}, [value]);
|
|
119
|
+
const isNodeIndeterminate = useCallback((node) => {
|
|
120
|
+
if (!node.children || node.children.length === 0) return false;
|
|
121
|
+
const getDescendantCount = (n) => {
|
|
122
|
+
if (!n.children || n.children.length === 0) return {
|
|
123
|
+
total: 1,
|
|
124
|
+
checked: value.includes(n.id) ? 1 : 0
|
|
125
|
+
};
|
|
126
|
+
return n.children.reduce((acc, child) => {
|
|
127
|
+
const childResult = getDescendantCount(child);
|
|
128
|
+
return {
|
|
129
|
+
total: acc.total + childResult.total,
|
|
130
|
+
checked: acc.checked + childResult.checked
|
|
131
|
+
};
|
|
132
|
+
}, {
|
|
133
|
+
total: 0,
|
|
134
|
+
checked: 0
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const { total, checked } = getDescendantCount(node);
|
|
138
|
+
return checked > 0 && checked < total;
|
|
139
|
+
}, [value]);
|
|
140
|
+
function renderTreeNode(node, level = 0) {
|
|
141
|
+
const hasChildren = node.children && node.children.length > 0;
|
|
142
|
+
const isExpanded = expandedKeys.has(node.id);
|
|
143
|
+
const isChecked = isNodeChecked(node.id);
|
|
144
|
+
const isIndeterminate = isNodeIndeterminate(node);
|
|
145
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
146
|
+
className: cn("flex items-center gap-2 py-2 px-2 hover:bg-muted/50 rounded-md cursor-pointer transition-colors", "group"),
|
|
147
|
+
style: { paddingLeft: `${level * 20 + 8}px` },
|
|
148
|
+
children: [
|
|
149
|
+
hasChildren ? /* @__PURE__ */ jsx(Button, {
|
|
150
|
+
variant: "text",
|
|
151
|
+
type: "button",
|
|
152
|
+
onClick: (e) => {
|
|
153
|
+
e.stopPropagation();
|
|
154
|
+
toggleExpand(node.id);
|
|
155
|
+
},
|
|
156
|
+
className: "flex-shrink-0 p-0.5 hover:bg-muted rounded",
|
|
157
|
+
children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
158
|
+
}) : /* @__PURE__ */ jsx("span", { className: "w-5" }),
|
|
159
|
+
checkable && /* @__PURE__ */ jsx(Checkbox, {
|
|
160
|
+
className: "flex-shrink-0",
|
|
161
|
+
checked: isChecked,
|
|
162
|
+
indeterminate: isIndeterminate,
|
|
163
|
+
"aria-label": `Select ${node.name}`,
|
|
164
|
+
onChange: (_, e) => {
|
|
165
|
+
e.stopPropagation();
|
|
166
|
+
toggleCheck(node);
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
/* @__PURE__ */ jsx("span", {
|
|
170
|
+
className: "flex-1 text-sm select-none",
|
|
171
|
+
onClick: () => {
|
|
172
|
+
if (hasChildren) toggleExpand(node.id);
|
|
173
|
+
else toggleCheck(node);
|
|
174
|
+
},
|
|
175
|
+
children: labelField === "desctext" ? node.desctext || node.name : node.name
|
|
176
|
+
})
|
|
177
|
+
]
|
|
178
|
+
}), hasChildren && isExpanded && /* @__PURE__ */ jsx("div", { children: node.children.map((child) => renderTreeNode(child, level + 1)) })] }, node.id);
|
|
179
|
+
}
|
|
180
|
+
if (!data || data.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
181
|
+
className: cn("tc-ui-tree-select p-8 text-center text-sm text-muted-foreground", className),
|
|
182
|
+
children: "No data"
|
|
183
|
+
});
|
|
184
|
+
return /* @__PURE__ */ jsx("div", {
|
|
185
|
+
className: cn("tc-ui-tree-select border border-border rounded-lg p-2 max-h-[400px] overflow-y-auto", className),
|
|
186
|
+
children: data.map((node) => renderTreeNode(node))
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { TreeSelect };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useI18n } from "../../i18n/useI18n.js";
|
|
2
|
+
import "../../i18n/index.js";
|
|
3
|
+
import { Button } from "../Button/Button.js";
|
|
4
|
+
import "../Button/index.js";
|
|
5
|
+
import { FileUpload } from "./Upload.js";
|
|
6
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Camera, X } from "lucide-react";
|
|
9
|
+
//#region packages/react/ui/components/Upload/ImageUpload.tsx
|
|
10
|
+
function ImageUpload({ accept = ".jpg,.png", maxCount = 1, value, onChange, beforeChange }) {
|
|
11
|
+
const t = useI18n();
|
|
12
|
+
const inputRef = useRef(null);
|
|
13
|
+
const [internalUrls, setInternalUrls] = useState([]);
|
|
14
|
+
const internalUrlsRef = useRef([]);
|
|
15
|
+
const urls = value ?? internalUrls;
|
|
16
|
+
const setUrls = onChange ?? setInternalUrls;
|
|
17
|
+
const mAccept = useMemo(() => {
|
|
18
|
+
return accept.split(",").map((item) => item.trim().replace(/\./g, "")).filter(Boolean).map((a) => `image/${a}`).join(", ");
|
|
19
|
+
}, [accept]);
|
|
20
|
+
const handleFileChange = (e) => {
|
|
21
|
+
const files = e.target.files;
|
|
22
|
+
if (!files || files.length === 0) return;
|
|
23
|
+
const newUrls = [];
|
|
24
|
+
const fileArray = Array.from(files);
|
|
25
|
+
const remainingCount = maxCount - urls.length;
|
|
26
|
+
fileArray.forEach((file) => {
|
|
27
|
+
if (newUrls.length < remainingCount) {
|
|
28
|
+
if (beforeChange) {
|
|
29
|
+
if (beforeChange(file) === false) return;
|
|
30
|
+
}
|
|
31
|
+
const url = URL.createObjectURL(file);
|
|
32
|
+
newUrls.push(url);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (maxCount > 1) setUrls([...urls, ...newUrls]);
|
|
36
|
+
else {
|
|
37
|
+
urls.forEach((url) => URL.revokeObjectURL(url));
|
|
38
|
+
setUrls(newUrls.slice(0, 1));
|
|
39
|
+
}
|
|
40
|
+
if (inputRef.current) inputRef.current.value = "";
|
|
41
|
+
};
|
|
42
|
+
const handleRemove = (index) => {
|
|
43
|
+
const urlToRemove = urls[index];
|
|
44
|
+
URL.revokeObjectURL(urlToRemove);
|
|
45
|
+
setUrls(urls.filter((_, i) => i !== index));
|
|
46
|
+
};
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (onChange) {
|
|
49
|
+
internalUrlsRef.current = [];
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
internalUrlsRef.current.filter((url) => !internalUrls.includes(url)).forEach((url) => URL.revokeObjectURL(url));
|
|
53
|
+
internalUrlsRef.current = internalUrls;
|
|
54
|
+
}, [onChange, internalUrls]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
return () => {
|
|
57
|
+
internalUrlsRef.current.forEach((url) => URL.revokeObjectURL(url));
|
|
58
|
+
internalUrlsRef.current = [];
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
62
|
+
className: "tc-ui-image-upload flex flex-wrap gap-3",
|
|
63
|
+
children: [urls.map((url, index) => /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
className: "relative h-24 w-24 overflow-hidden rounded-lg border border-border/60 bg-card group cursor-pointer shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)] transition-colors duration-200 hover:border-border/80 active:border-theme/60",
|
|
65
|
+
children: [/* @__PURE__ */ jsx("img", {
|
|
66
|
+
src: url,
|
|
67
|
+
alt: "",
|
|
68
|
+
className: "w-full h-full object-cover"
|
|
69
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
70
|
+
className: "absolute inset-0 flex items-center justify-center bg-background/0 transition-colors duration-200 group-hover:bg-background/55",
|
|
71
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
72
|
+
variant: "text",
|
|
73
|
+
type: "button",
|
|
74
|
+
onClick: (e) => {
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
handleRemove(index);
|
|
77
|
+
},
|
|
78
|
+
className: "rounded-full bg-destructive p-1.5 text-destructive-foreground opacity-0 shadow-[var(--shadow-accent)] transition-[background-color,opacity] duration-200 hover:bg-destructive/90 active:bg-destructive/80 focus-visible:ring-destructive group-hover:opacity-100",
|
|
79
|
+
"aria-label": t("components.upload.deleteImage"),
|
|
80
|
+
title: t("components.upload.deleteImage"),
|
|
81
|
+
children: /* @__PURE__ */ jsx(X, { size: 16 })
|
|
82
|
+
})
|
|
83
|
+
})]
|
|
84
|
+
}, index)), urls.length < maxCount && /* @__PURE__ */ jsx(FileUpload, {
|
|
85
|
+
inputRef,
|
|
86
|
+
accept: mAccept,
|
|
87
|
+
multiple: maxCount > 1,
|
|
88
|
+
onChange: handleFileChange,
|
|
89
|
+
labelClassName: "h-24 w-24 cursor-pointer rounded-lg border-0 p-0 focus-within:ring-2 focus-within:ring-theme/25",
|
|
90
|
+
selectLabel: /* @__PURE__ */ jsxs("div", {
|
|
91
|
+
className: "flex h-full w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-border/60 bg-card text-muted-foreground transition-colors duration-200 hover:border-border/80 hover:bg-muted/50 hover:text-foreground active:bg-muted/70",
|
|
92
|
+
children: [/* @__PURE__ */ jsx(Camera, { size: 24 }), /* @__PURE__ */ jsx("span", {
|
|
93
|
+
className: "text-xs",
|
|
94
|
+
children: t("components.upload.upload")
|
|
95
|
+
})]
|
|
96
|
+
})
|
|
97
|
+
})]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { ImageUpload };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Button } from "../Button/Button.js";
|
|
2
|
+
import "../Button/index.js";
|
|
3
|
+
import { Input } from "../Input/Input.js";
|
|
4
|
+
import "../Input/index.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/react/ui/components/Upload/Upload.tsx
|
|
7
|
+
function FileUpload({ inputRef, accept = "*", multiple, onChange, selectLabel, labelClassName, showClear, onClear, clearLabel }) {
|
|
8
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
9
|
+
className: "tc-ui-file-upload flex items-center gap-3",
|
|
10
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
11
|
+
className: labelClassName ?? "flex h-10 items-center gap-2 rounded-lg border border-border/60 bg-card px-4 py-2 text-sm text-card-foreground cursor-pointer transition-colors duration-200 hover:border-border/80 hover:bg-muted/50 active:bg-muted/70 focus-within:border-theme focus-within:ring-2 focus-within:ring-theme/25",
|
|
12
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
13
|
+
ref: inputRef,
|
|
14
|
+
type: "file",
|
|
15
|
+
accept,
|
|
16
|
+
multiple,
|
|
17
|
+
className: "hidden",
|
|
18
|
+
onChange: (_, e) => onChange?.(e)
|
|
19
|
+
}), selectLabel]
|
|
20
|
+
}), showClear && onClear && /* @__PURE__ */ jsx(Button, {
|
|
21
|
+
size: "sm",
|
|
22
|
+
variant: "link",
|
|
23
|
+
onClick: onClear,
|
|
24
|
+
children: clearLabel
|
|
25
|
+
})]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FileUpload };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { useI18n } from "../../i18n/useI18n.js";
|
|
2
|
+
import "../../i18n/index.js";
|
|
3
|
+
import { useBreadcrumb } from "../../../hooks/useBreadcrumb.js";
|
|
4
|
+
import { useLanguage } from "../../../hooks/useLanguage.js";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { Button } from "../Button/Button.js";
|
|
7
|
+
import "../Button/index.js";
|
|
8
|
+
import { forwardRef } from "react";
|
|
9
|
+
import { useNavigate } from "react-router-dom";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
|
12
|
+
//#region packages/react/ui/components/breadcrumb/breadcrumb.tsx
|
|
13
|
+
var Breadcrumb = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("nav", {
|
|
14
|
+
ref,
|
|
15
|
+
"aria-label": "breadcrumb",
|
|
16
|
+
className: cn("tc-ui-breadcrumb", className),
|
|
17
|
+
...props
|
|
18
|
+
}));
|
|
19
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
20
|
+
var BreadcrumbList = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("ol", {
|
|
21
|
+
ref,
|
|
22
|
+
className: cn("tc-ui-breadcrumb-list flex items-center gap-3 flex-wrap", className),
|
|
23
|
+
...props
|
|
24
|
+
}));
|
|
25
|
+
BreadcrumbList.displayName = "BreadcrumbList";
|
|
26
|
+
var BreadcrumbItem = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("li", {
|
|
27
|
+
ref,
|
|
28
|
+
className: cn("tc-ui-breadcrumb-item inline-flex items-center", className),
|
|
29
|
+
...props
|
|
30
|
+
}));
|
|
31
|
+
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
32
|
+
var BreadcrumbLink = forwardRef(({ className, ...props }, ref) => {
|
|
33
|
+
return /* @__PURE__ */ jsx("a", {
|
|
34
|
+
ref,
|
|
35
|
+
className: cn("tc-ui-breadcrumb-link transition-colors hover:text-foreground", className),
|
|
36
|
+
...props
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
40
|
+
var BreadcrumbPage = forwardRef(({ className, active, onClose, closable = true, children, ...props }, ref) => {
|
|
41
|
+
const t = useI18n();
|
|
42
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
43
|
+
ref,
|
|
44
|
+
role: "link",
|
|
45
|
+
"aria-disabled": "true",
|
|
46
|
+
"aria-current": "page",
|
|
47
|
+
className: cn("tc-ui-breadcrumb-page inline-flex items-center gap-2 px-4 py-2 rounded-lg border transition-all duration-200 text-sm", active ? "bg-breadcrumb-active-bg text-breadcrumb-active-text border-breadcrumb-active-bg shadow-sm" : "bg-background text-breadcrumb-text border-breadcrumb-border hover:border-gray-400", className),
|
|
48
|
+
...props,
|
|
49
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
50
|
+
className: "font-normal",
|
|
51
|
+
children
|
|
52
|
+
}), onClose && closable && /* @__PURE__ */ jsx(Button, {
|
|
53
|
+
variant: "text",
|
|
54
|
+
type: "button",
|
|
55
|
+
onClick: (e) => {
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
onClose();
|
|
58
|
+
},
|
|
59
|
+
className: "inline-flex items-center justify-center hover:opacity-70 transition-opacity",
|
|
60
|
+
"aria-label": t("components.breadcrumb.close"),
|
|
61
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
62
|
+
width: "16",
|
|
63
|
+
height: "16",
|
|
64
|
+
viewBox: "0 0 16 16",
|
|
65
|
+
fill: "none",
|
|
66
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
67
|
+
children: [/* @__PURE__ */ jsxs("g", {
|
|
68
|
+
clipPath: "url(#clip0_228_519)",
|
|
69
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
70
|
+
cx: "8",
|
|
71
|
+
cy: "8",
|
|
72
|
+
r: "6.66667",
|
|
73
|
+
stroke: "currentColor",
|
|
74
|
+
strokeWidth: "1"
|
|
75
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
76
|
+
d: "M9.66669 6.33302L6.33337 9.66634M6.33336 6.33301L9.66668 9.66633",
|
|
77
|
+
stroke: "currentColor",
|
|
78
|
+
strokeWidth: "1",
|
|
79
|
+
strokeLinecap: "round"
|
|
80
|
+
})]
|
|
81
|
+
}), /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", {
|
|
82
|
+
id: "clip0_228_519",
|
|
83
|
+
children: /* @__PURE__ */ jsx("rect", {
|
|
84
|
+
width: "16",
|
|
85
|
+
height: "16",
|
|
86
|
+
fill: "white"
|
|
87
|
+
})
|
|
88
|
+
}) })]
|
|
89
|
+
})
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
94
|
+
var BreadcrumbSeparator = ({ children, className, ...props }) => /* @__PURE__ */ jsx("li", {
|
|
95
|
+
role: "presentation",
|
|
96
|
+
"aria-hidden": "true",
|
|
97
|
+
className: cn("tc-ui-breadcrumb-separator [&>svg]:size-3.5", className),
|
|
98
|
+
...props,
|
|
99
|
+
children: children ?? /* @__PURE__ */ jsx(ChevronRight, {})
|
|
100
|
+
});
|
|
101
|
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
102
|
+
var BreadcrumbEllipsis = ({ className, ...props }) => /* @__PURE__ */ jsxs("span", {
|
|
103
|
+
role: "presentation",
|
|
104
|
+
"aria-hidden": "true",
|
|
105
|
+
"aria-label": "More",
|
|
106
|
+
className: cn("tc-ui-breadcrumb-ellipsis flex h-9 w-9 items-center justify-center", className),
|
|
107
|
+
...props,
|
|
108
|
+
children: [/* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" }), /* @__PURE__ */ jsx("span", {
|
|
109
|
+
className: "sr-only",
|
|
110
|
+
children: "More"
|
|
111
|
+
})]
|
|
112
|
+
});
|
|
113
|
+
BreadcrumbEllipsis.displayName = "BreadcrumbEllipsis";
|
|
114
|
+
function SimpleBreadcrumb({ className }) {
|
|
115
|
+
const { language } = useLanguage();
|
|
116
|
+
const navigate = useNavigate();
|
|
117
|
+
const { items, setActiveItem, removeItem } = useBreadcrumb();
|
|
118
|
+
const handleBreadcrumbClick = (id) => {
|
|
119
|
+
const item = items.find((item) => item.id === id);
|
|
120
|
+
if (item?.path) {
|
|
121
|
+
navigate(item.path);
|
|
122
|
+
setActiveItem(id);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const handleBreadcrumbClose = (id) => {
|
|
126
|
+
const isActive = items.find((item) => item.id === id)?.active;
|
|
127
|
+
const remainingItems = items.filter((item) => item.id !== id);
|
|
128
|
+
removeItem(id);
|
|
129
|
+
if (isActive) if (remainingItems.length > 0) {
|
|
130
|
+
const targetItem = remainingItems.at(-1);
|
|
131
|
+
const targetPath = targetItem.path;
|
|
132
|
+
if (targetPath) setTimeout(() => {
|
|
133
|
+
navigate(targetPath);
|
|
134
|
+
setActiveItem(targetItem.id);
|
|
135
|
+
}, 0);
|
|
136
|
+
} else setTimeout(() => {}, 0);
|
|
137
|
+
};
|
|
138
|
+
const getItemLabel = (item) => {
|
|
139
|
+
return language === "zh-CN" ? item.label : item.desctext || item.label;
|
|
140
|
+
};
|
|
141
|
+
return /* @__PURE__ */ jsx(Breadcrumb, {
|
|
142
|
+
className,
|
|
143
|
+
children: /* @__PURE__ */ jsx(BreadcrumbList, { children: items.map((item) => /* @__PURE__ */ jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsx(BreadcrumbPage, {
|
|
144
|
+
active: item.active,
|
|
145
|
+
closable: item.closable !== false,
|
|
146
|
+
onClose: () => handleBreadcrumbClose(item.id),
|
|
147
|
+
onClick: () => handleBreadcrumbClick(item.id),
|
|
148
|
+
className: "cursor-pointer",
|
|
149
|
+
"data-active": item.active ? "true" : void 0,
|
|
150
|
+
children: getItemLabel(item)
|
|
151
|
+
}) }, item.id)) })
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, SimpleBreadcrumb };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, SimpleBreadcrumb } from "./breadcrumb.js";
|
|
2
|
+
export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, SimpleBreadcrumb };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
//#region packages/react/ui/components/hooks/useDropdownPositioning.ts
|
|
3
|
+
var HIDDEN_POSITION = {
|
|
4
|
+
top: -100,
|
|
5
|
+
left: -100
|
|
6
|
+
};
|
|
7
|
+
var EMPTY_DEPS = [];
|
|
8
|
+
/**
|
|
9
|
+
* 计算弹窗该放在哪。
|
|
10
|
+
*
|
|
11
|
+
* right/left:跟触发元素顶部对齐,往右或往左弹。
|
|
12
|
+
* bottom/top:放在触发元素下方或上方,再按 start/end 对齐。
|
|
13
|
+
*/
|
|
14
|
+
var getDefaultDropdownPosition = ({ anchorRect, contentRect, containerRect, viewportWidth, placement, offset, matchAnchorWidth }) => {
|
|
15
|
+
const isRight = placement.startsWith("right");
|
|
16
|
+
const isLeft = placement.startsWith("left");
|
|
17
|
+
const isTop = placement.startsWith("top");
|
|
18
|
+
const containerTop = containerRect?.top ?? 0;
|
|
19
|
+
const containerLeft = containerRect?.left ?? 0;
|
|
20
|
+
const containerRight = containerRect?.right ?? viewportWidth;
|
|
21
|
+
const nextPosition = {
|
|
22
|
+
top: (isRight || isLeft ? anchorRect.top : isTop ? anchorRect.top - (contentRect?.height ?? 0) - offset : anchorRect.bottom + offset) - containerTop,
|
|
23
|
+
width: matchAnchorWidth ? anchorRect.width : void 0
|
|
24
|
+
};
|
|
25
|
+
if (isRight) nextPosition.left = anchorRect.right + offset - containerLeft;
|
|
26
|
+
else if (isLeft) nextPosition.left = anchorRect.left - (contentRect?.width ?? 0) - offset - containerLeft;
|
|
27
|
+
else if (placement.endsWith("start")) nextPosition.left = anchorRect.left - containerLeft;
|
|
28
|
+
else nextPosition.right = containerRight - anchorRect.right;
|
|
29
|
+
return nextPosition;
|
|
30
|
+
};
|
|
31
|
+
function useDropdownPositioning({ open, anchorRef, contentRef, placement = "bottom-end", offset = 8, matchAnchorWidth = false, strategy = getDefaultDropdownPosition, estimateSize, watchDeps = EMPTY_DEPS, containerRef, positionMode = "fixed" }) {
|
|
32
|
+
const [position, setPosition] = useState(HIDDEN_POSITION);
|
|
33
|
+
const [ready, setReady] = useState(false);
|
|
34
|
+
const getContentRect = useCallback(() => {
|
|
35
|
+
const measuredRect = contentRef.current?.getBoundingClientRect();
|
|
36
|
+
if (measuredRect && measuredRect.height > 0) return measuredRect;
|
|
37
|
+
const estimatedSize = estimateSize?.();
|
|
38
|
+
if (!estimatedSize) return measuredRect;
|
|
39
|
+
return new DOMRect(0, 0, estimatedSize.width ?? 0, estimatedSize.height ?? 0);
|
|
40
|
+
}, [contentRef, estimateSize]);
|
|
41
|
+
const updatePosition = useCallback(() => {
|
|
42
|
+
if (!anchorRef.current) return;
|
|
43
|
+
const anchorRect = anchorRef.current.getBoundingClientRect();
|
|
44
|
+
const contentRect = getContentRect();
|
|
45
|
+
const containerRect = positionMode === "absolute" ? containerRef?.current?.getBoundingClientRect() : void 0;
|
|
46
|
+
const newData = strategy({
|
|
47
|
+
anchorRect,
|
|
48
|
+
contentRect: contentRect ?? void 0,
|
|
49
|
+
containerRect,
|
|
50
|
+
viewportWidth: window.innerWidth,
|
|
51
|
+
viewportHeight: window.innerHeight,
|
|
52
|
+
placement,
|
|
53
|
+
offset,
|
|
54
|
+
matchAnchorWidth
|
|
55
|
+
});
|
|
56
|
+
setPosition(returnData.current.position = newData);
|
|
57
|
+
setReady(returnData.current.ready = Boolean(contentRef.current && contentRef.current.getBoundingClientRect().height > 0));
|
|
58
|
+
}, [
|
|
59
|
+
anchorRef,
|
|
60
|
+
contentRef,
|
|
61
|
+
containerRef,
|
|
62
|
+
getContentRect,
|
|
63
|
+
matchAnchorWidth,
|
|
64
|
+
offset,
|
|
65
|
+
placement,
|
|
66
|
+
positionMode,
|
|
67
|
+
strategy
|
|
68
|
+
]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (!open) {
|
|
71
|
+
setPosition(returnData.current.position = HIDDEN_POSITION);
|
|
72
|
+
setReady(returnData.current.ready = false);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const rafId = requestAnimationFrame(() => requestAnimationFrame(updatePosition));
|
|
76
|
+
return () => cancelAnimationFrame(rafId);
|
|
77
|
+
}, [open, updatePosition]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!open) return;
|
|
80
|
+
const handleUpdate = () => updatePosition();
|
|
81
|
+
window.addEventListener("scroll", handleUpdate, true);
|
|
82
|
+
window.addEventListener("resize", handleUpdate);
|
|
83
|
+
return () => {
|
|
84
|
+
window.removeEventListener("scroll", handleUpdate, true);
|
|
85
|
+
window.removeEventListener("resize", handleUpdate);
|
|
86
|
+
};
|
|
87
|
+
}, [open, updatePosition]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!open) return;
|
|
90
|
+
updatePosition();
|
|
91
|
+
}, [
|
|
92
|
+
useMemo(() => watchDeps, [watchDeps]),
|
|
93
|
+
open,
|
|
94
|
+
updatePosition
|
|
95
|
+
]);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!open || !contentRef.current) return;
|
|
98
|
+
let rafId = 0;
|
|
99
|
+
const observer = new ResizeObserver(() => {
|
|
100
|
+
rafId = requestAnimationFrame(() => requestAnimationFrame(updatePosition));
|
|
101
|
+
});
|
|
102
|
+
observer.observe(contentRef.current);
|
|
103
|
+
return () => {
|
|
104
|
+
observer.disconnect();
|
|
105
|
+
cancelAnimationFrame(rafId);
|
|
106
|
+
};
|
|
107
|
+
}, [
|
|
108
|
+
contentRef,
|
|
109
|
+
open,
|
|
110
|
+
updatePosition
|
|
111
|
+
]);
|
|
112
|
+
const returnData = useRef({
|
|
113
|
+
position,
|
|
114
|
+
ready,
|
|
115
|
+
updatePosition
|
|
116
|
+
});
|
|
117
|
+
returnData.current.updatePosition = updatePosition;
|
|
118
|
+
return returnData.current;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { getDefaultDropdownPosition, useDropdownPositioning };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
2
|
+
//#region packages/react/ui/components/hooks/useInputController.ts
|
|
3
|
+
/**
|
|
4
|
+
* 处理ref & 判断是否受控 & 使用的value & value.length
|
|
5
|
+
*/
|
|
6
|
+
var useInputController = (params) => {
|
|
7
|
+
const { defaultValue, ref, controlledValue } = params;
|
|
8
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
9
|
+
const [internalValue, setInternalValue] = useState(defaultValue || "");
|
|
10
|
+
const controllerRef = useRef(null);
|
|
11
|
+
const setRefs = useCallback((node) => {
|
|
12
|
+
controllerRef.current = node;
|
|
13
|
+
if (typeof ref === "function") ref(node);
|
|
14
|
+
else if (ref) ref.current = node;
|
|
15
|
+
}, [ref]);
|
|
16
|
+
const isControlledRef = useRef(false);
|
|
17
|
+
const isControlled = useMemo(() => {
|
|
18
|
+
const r = controlledValue !== void 0;
|
|
19
|
+
isControlledRef.current = r;
|
|
20
|
+
return r;
|
|
21
|
+
}, [controlledValue]);
|
|
22
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
23
|
+
const hasValue = Boolean(value && String(value).length > 0);
|
|
24
|
+
return {
|
|
25
|
+
setRefs,
|
|
26
|
+
setIsFocused,
|
|
27
|
+
setInternalValue,
|
|
28
|
+
controllerRef,
|
|
29
|
+
isControlledRef,
|
|
30
|
+
isControlled,
|
|
31
|
+
isFocused,
|
|
32
|
+
currentLength: value ? String(value).length : 0,
|
|
33
|
+
hasValue,
|
|
34
|
+
internalValue,
|
|
35
|
+
value
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { useInputController };
|