@_tc/template-core 0.2.12 → 0.3.1
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 +7 -9
- package/.skills/tc-component-usage-skills/reference/component-api.md +2 -2
- package/.skills/tc-component-usage-skills/reference/examples.md +9 -9
- package/.skills/tc-component-usage-skills/reference/patterns.md +5 -5
- package/.skills/tc-component-usage-skills/reference/template-core-frontend.md +1 -1
- package/.skills/tc-generator/SKILL.md +31 -14
- package/.skills/tc-generator/reference/example.md +4 -4
- package/.skills/tc-generator/reference/model-schema.md +9 -5
- package/.skills/tc-generator/reference/runtime-extensions.md +9 -7
- package/AGENT_README.md +66 -33
- package/CHANGE.md +48 -5
- package/README.md +161 -46
- package/cjs/app/controller/ssr.js +1 -0
- package/cjs/app/controller/view.js +1 -1
- package/cjs/app/html/shell.js +36 -0
- package/cjs/app/middleware.js +1 -1
- package/cjs/app/router/ssr.js +1 -0
- package/cjs/app/router/view.js +1 -1
- package/cjs/app/ssr/html.js +17 -0
- package/cjs/app/ssr/manifest.js +2 -0
- package/cjs/app/view/entry.tpl +2 -37
- package/cjs/bundler/buildBE.js +1 -1
- package/cjs/bundler/buildSSR.js +1 -0
- package/cjs/bundler/entryCollect.js +1 -0
- package/cjs/bundler/feSharedConfig.js +1 -0
- package/cjs/bundler/index.js +1 -1
- package/cjs/bundler/ssrClientManifest.js +1 -0
- package/cjs/bundler/ssrEntries.js +1 -0
- package/cjs/bundler/utils.js +3 -3
- package/cjs/packages/common/i18n/index.js +1 -1
- package/cjs/packages/common/index.js +1 -1
- package/cjs/packages/common/ssr/hydration.js +1 -0
- package/cjs/packages/common/ssr/index.js +1 -0
- package/cjs/packages/core/index.js +1 -1
- package/cjs/packages/core/loader/controller.js +1 -1
- package/cjs/packages/core/loader/extend.js +1 -1
- package/cjs/packages/core/loader/merge.js +1 -0
- package/cjs/packages/core/loader/middleware.js +1 -1
- package/cjs/packages/core/loader/model.js +1 -1
- package/cjs/packages/core/loader/router-schema.js +1 -1
- package/cjs/packages/core/loader/router.js +1 -1
- package/cjs/packages/core/loader/service.js +1 -1
- package/cjs/packages/core/paths.js +1 -1
- package/cjs/scripts/vite-build/build.js +3 -3
- package/cjs/scripts/vite-build/collect.js +1 -1
- package/cjs/scripts/vite-build/dts.js +1 -1
- package/cjs/scripts/vite-build/normalize.js +1 -1
- package/cjs/ssrSharedData/outputPaths.js +1 -0
- package/esm/app/controller/ssr.js +215 -0
- package/esm/app/controller/view.js +26 -25
- package/esm/app/html/shell.js +69 -0
- package/esm/app/middleware.js +18 -9
- package/esm/app/router/ssr.js +8 -0
- package/esm/app/router/view.js +5 -4
- package/esm/app/ssr/html.js +90 -0
- package/esm/app/ssr/manifest.js +47 -0
- package/esm/app/view/entry.tpl +2 -37
- package/esm/bundler/buildBE.js +1 -1
- package/esm/bundler/buildSSR.js +126 -0
- package/esm/bundler/entryCollect.js +45 -0
- package/esm/bundler/feSharedConfig.js +143 -0
- package/esm/bundler/index.js +4 -2
- package/esm/bundler/ssrClientManifest.js +14 -0
- package/esm/bundler/ssrEntries.js +13 -0
- package/esm/bundler/utils.js +248 -255
- package/esm/packages/common/i18n/index.js +5 -1
- package/esm/packages/common/index.js +4 -2
- package/esm/packages/common/ssr/hydration.js +55 -0
- package/esm/packages/common/ssr/index.js +20 -0
- package/esm/packages/core/index.js +42 -42
- package/esm/packages/core/loader/controller.js +11 -9
- package/esm/packages/core/loader/extend.js +20 -16
- package/esm/packages/core/loader/merge.js +7 -0
- package/esm/packages/core/loader/middleware.js +11 -12
- package/esm/packages/core/loader/model.js +2 -2
- package/esm/packages/core/loader/router-schema.js +22 -15
- package/esm/packages/core/loader/router.js +32 -26
- package/esm/packages/core/loader/service.js +11 -9
- package/esm/packages/core/paths.js +9 -1
- package/esm/scripts/vite-build/build.js +88 -83
- package/esm/scripts/vite-build/collect.js +31 -27
- package/esm/scripts/vite-build/dts.js +1 -1
- package/esm/scripts/vite-build/normalize.js +6 -3
- package/esm/ssrSharedData/outputPaths.js +33 -0
- package/fe/frontend/apps/dash/Dashboard.d.ts +5 -1
- package/fe/frontend/apps/dash/Dashboard.js +22 -13
- package/fe/frontend/apps/dash/types.d.ts +2 -0
- package/fe/frontend/src/api/baseInfo.d.ts +1 -1
- package/fe/frontend/src/common/CRUD/CRUD.js +1 -1
- package/fe/frontend/src/common/CRUD/index.js +1 -1
- package/fe/frontend/src/common/menu.d.ts +1 -1
- package/fe/frontend/src/common/menu.js +8 -7
- package/fe/frontend/src/common/request.js +1 -1
- package/fe/frontend/src/common/schemaForm.d.ts +1 -0
- package/fe/frontend/src/common/schemaForm.js +12 -0
- package/fe/frontend/src/components/AsyncSelect/AsyncSelect.d.ts +1 -1
- package/fe/frontend/src/components/Router/basename.d.ts +3 -0
- package/fe/frontend/src/components/Router/basename.js +11 -0
- package/fe/frontend/src/components/Router/index.d.ts +1 -1
- package/fe/frontend/src/components/Router/index.js +3 -1
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/builtIn.d.ts +1 -1
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/data.d.ts +1 -1
- package/fe/frontend/src/defaultPages/SchemaPage/schemaType.d.ts +2 -2
- package/fe/frontend/src/defaultPages/SchemaPage/utils/schemaConversion.d.ts +1 -1
- package/fe/frontend/src/defaultPages/SidebarSlotPage/SidebarSlotContainer.d.ts +2 -1
- package/fe/frontend/src/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +8 -4
- package/fe/frontend/src/defaultPages/SidebarSlotPageTmp.js +2 -1
- package/fe/frontend/src/exportStore.js +2 -2
- package/fe/frontend/src/hooks/useCurrentMenuData.d.ts +1 -1
- package/fe/frontend/src/hooks/useCurrentMenuData.js +2 -2
- package/fe/frontend/src/hooks/useRouterParams.js +4 -3
- package/fe/frontend/src/index.d.ts +1 -0
- package/fe/frontend/src/index.js +4 -3
- package/fe/frontend/src/main.js +2 -0
- package/fe/frontend/src/stores/mode.d.ts +15 -2
- package/fe/frontend/src/stores/mode.js +19 -5
- package/fe/frontend/src/typing/window.d.ts +2 -0
- package/fe/packages/common/LRUCache.js +2 -0
- package/fe/packages/common/array/index.js +37 -0
- package/fe/packages/common/cache/index.js +2 -0
- package/fe/packages/common/guards/index.js +19 -1
- package/fe/packages/common/http/index.js +1 -1
- package/fe/packages/common/i18n/index.js +8 -4
- package/fe/packages/common/i18n/locales.js +1 -1
- package/fe/packages/common/i18n/types.d.ts +1 -0
- package/fe/packages/common/i18n/types.js +0 -0
- package/fe/packages/common/index.d.ts +1 -0
- package/fe/packages/common/index.js +17 -0
- package/fe/packages/common/log/index.js +146 -0
- package/fe/packages/common/number/index.js +11 -0
- package/fe/packages/common/object/filterEmpty.js +2 -1
- package/fe/packages/common/object/filtereEmpty.js +2 -0
- package/fe/packages/common/object/index.js +20 -0
- package/fe/packages/common/ssr/hydration.d.ts +23 -0
- package/fe/packages/common/ssr/hydration.js +88 -0
- package/fe/packages/common/ssr/index.d.ts +8 -0
- package/fe/packages/common/ssr/index.js +52 -0
- package/fe/packages/common/string/index.js +32 -0
- package/fe/packages/common/types/index.js +0 -0
- package/fe/packages/react/hooks/index.d.ts +2 -0
- package/fe/packages/react/hooks/index.js +3 -1
- package/fe/packages/react/hooks/useHydrationData.d.ts +2 -0
- package/fe/packages/react/hooks/useHydrationData.js +23 -0
- package/fe/packages/react/hooks/useSSR.d.ts +6 -0
- package/fe/packages/react/hooks/useSSR.js +46 -0
- package/fe/packages/react/ui/components/DataTable/index.js +16 -15
- package/fe/packages/react/ui/components/Form/SchemaForm/data.d.ts +3 -2
- package/fe/packages/react/ui/components/Form/SchemaForm/data.js +5 -6
- package/fe/packages/react/ui/components/Form/SchemaForm/index.d.ts +1 -0
- package/fe/packages/react/ui/components/Form/SchemaForm/index.js +2 -2
- package/fe/packages/react/ui/components/Form/index.js +2 -1
- package/fe/packages/react/ui/components/Input/Input.js +5 -1
- package/fe/packages/react/ui/components/Popup/Popup.js +6 -1
- package/fe/packages/react/ui/components/index.js +2 -1
- package/fe/packages/react/ui/components/testPage/demos/core/DataTableDemo.js +241 -211
- package/fe/packages/react/ui/components/testPage/demos/core/DataTableDemo2.js +1 -1
- package/fe/packages/react/ui/i18n/I18nProvider.js +4 -0
- package/fe/packages/react/ui/index.js +2 -1
- package/fe/ssr/apps/dash/dash.entry.d.ts +13 -0
- package/fe/ssr/apps/dash/dash.entry.js +162 -0
- package/fe/ssr/apps/demo/demo.entry.d.ts +13 -0
- package/fe/ssr/apps/demo/demo.entry.js +38 -0
- package/fe/ssr/apps/server-data/server-data.entry.d.ts +26 -0
- package/fe/ssr/apps/server-data/server-data.entry.js +275 -0
- package/fe/ssr/apps/ui-components/ui-components.entry.d.ts +5 -0
- package/fe/ssr/apps/ui-components/ui-components.entry.js +17 -0
- package/fe/ssr/components/StreamingRender/StreamingCache.d.ts +2 -0
- package/fe/ssr/components/StreamingRender/StreamingCache.js +31 -0
- package/fe/ssr/components/StreamingRender/StreamingRender.d.ts +3 -0
- package/fe/ssr/components/StreamingRender/StreamingRender.js +48 -0
- package/fe/ssr/components/StreamingRender/StreamingScript.d.ts +8 -0
- package/fe/ssr/components/StreamingRender/StreamingScript.js +58 -0
- package/fe/ssr/components/StreamingRender/index.d.ts +4 -0
- package/fe/ssr/components/StreamingRender/index.js +5 -0
- package/fe/ssr/components/StreamingRender/type.d.ts +9 -0
- package/fe/ssr/components/StreamingRender/type.js +0 -0
- package/fe/ssr/components/index.d.ts +2 -0
- package/fe/ssr/components/index.js +2 -0
- package/fe/ssr/createSSREntry.d.ts +6 -0
- package/fe/ssr/createSSREntry.js +42 -0
- package/fe/ssr/hooks/index.d.ts +1 -0
- package/fe/ssr/hooks/index.js +2 -0
- package/fe/ssr/hooks/useSuspensePromise.d.ts +1 -0
- package/fe/ssr/hooks/useSuspensePromise.js +31 -0
- package/fe/ssr/index.d.ts +4 -0
- package/fe/ssr/index.js +6 -0
- package/fe/ssr/types.d.ts +13 -0
- package/fe/ssr/types.js +0 -0
- package/{model → models}/frontend/src/typing/window.d.ts +2 -0
- package/{model → models}/packages/common/i18n/types.d.ts +1 -0
- package/{model → models}/packages/common/index.d.ts +1 -0
- package/models/packages/common/ssr/hydration.d.ts +23 -0
- package/models/packages/common/ssr/index.d.ts +8 -0
- package/{model → models}/packages/react/ui/components/Form/SchemaForm/data.d.ts +3 -2
- package/{model → models}/packages/react/ui/components/Form/SchemaForm/index.d.ts +1 -0
- package/package.json +43 -6
- package/types/app/controller/ssr.d.ts +14 -0
- package/types/app/html/shell.d.ts +101 -0
- package/types/app/router/ssr.d.ts +6 -0
- package/types/app/ssr/html.d.ts +53 -0
- package/types/app/ssr/manifest.d.ts +17 -0
- package/types/app/typings.d.ts +2 -0
- package/types/bundler/buildSSR.d.ts +56 -0
- package/types/bundler/entryCollect.d.ts +36 -0
- package/types/bundler/feSharedConfig.d.ts +35 -0
- package/types/bundler/index.d.ts +4 -0
- package/types/bundler/ssrClientManifest.d.ts +4 -0
- package/types/bundler/ssrEntries.d.ts +23 -0
- package/types/bundler/state.d.ts +2 -2
- package/types/bundler/utils.d.ts +35 -2
- package/types/config/config.default.d.ts +10 -0
- package/types/packages/common/i18n/types.d.ts +2 -0
- package/types/packages/common/index.d.ts +1 -0
- package/types/packages/common/ssr/hydration.d.ts +72 -0
- package/types/packages/common/ssr/index.d.ts +34 -0
- package/types/packages/core/loader/merge.d.ts +3 -0
- package/types/packages/core/loader/model.d.ts +2 -2
- package/types/packages/core/paths.d.ts +5 -0
- package/types/packages/core/types.d.ts +10 -1
- package/types/scripts/vite-build/build.d.ts +1 -0
- package/types/scripts/vite-build/types.d.ts +3 -0
- package/types/ssrSharedData/outputPaths.d.ts +59 -0
- package/fe/packages/react/hooks/useWatch.test.js +0 -24
- package/fe/packages/react/ui/assets/table/no-result.js +0 -4
- package/fe/packages/react/ui/components/DataTable/dataTableWidth.test.js +0 -39
- package/fe/packages/react/ui/components/InputNumber/inputNumberUtils.test.js +0 -59
- /package/.skills/tc-generator/reference/project-template/{model → models}/product/mode.js +0 -0
- /package/.skills/tc-generator/reference/project-template/{model → models}/product/project/default.js +0 -0
- /package/fe/{model → models}/types/data/button.d.ts +0 -0
- /package/fe/{model → models}/types/data/component.d.ts +0 -0
- /package/fe/{model → models}/types/data/fetchInfo.d.ts +0 -0
- /package/fe/{model → models}/types/data/schema.d.ts +0 -0
- /package/fe/{model → models}/types/data/search.d.ts +0 -0
- /package/fe/{model → models}/types/index.d.ts +0 -0
- /package/fe/{model → models}/types/menuType.d.ts +0 -0
- /package/fe/{model → models}/types/model.d.ts +0 -0
- /package/{model → models}/frontend/extended/SchemaForm/data.d.ts +0 -0
- /package/{model → models}/frontend/src/common/auth/index.d.ts +0 -0
- /package/{model → models}/frontend/src/common/fetchErrorShow.d.ts +0 -0
- /package/{model → models}/frontend/src/common/language.d.ts +0 -0
- /package/{model → models}/frontend/src/common/logFn/index.d.ts +0 -0
- /package/{model → models}/frontend/src/common/request.d.ts +0 -0
- /package/{model → models}/frontend/src/components/AsyncSelect/AsyncSelect.d.ts +0 -0
- /package/{model → models}/frontend/src/components/AsyncSelect/index.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/components/CallCom/DetailPanel.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/components/CallCom/PopFrom.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/components/CallCom/builtIn.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/data/eventInfo.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/data/index.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/hooks/useComConfig.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/schemaType.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/utils/permissions.d.ts +0 -0
- /package/{model → models}/frontend/src/defaultPages/SchemaPage/utils/validator.d.ts +0 -0
- /package/{model → models}/frontend/src/hooks/useText.d.ts +0 -0
- /package/{model → models}/frontend/src/language/en-US.d.ts +0 -0
- /package/{model → models}/frontend/src/language/index.d.ts +0 -0
- /package/{model → models}/frontend/src/language/resources.d.ts +0 -0
- /package/{model → models}/frontend/src/language/zh-CN.d.ts +0 -0
- /package/{model → models}/frontend/src/stores/apiFreezer.d.ts +0 -0
- /package/{model → models}/frontend/src/stores/schemaEventBus.d.ts +0 -0
- /package/{model → models}/frontend/src/stores/schemaStore.d.ts +0 -0
- /package/{model → models}/frontend/src/typing/scalability.d.ts +0 -0
- /package/{model/model → models/models}/index.d.ts +0 -0
- /package/{model/model → models/models}/test.d.ts +0 -0
- /package/{model/model → models/models}/types/data/button.d.ts +0 -0
- /package/{model/model → models/models}/types/data/component.d.ts +0 -0
- /package/{model/model → models/models}/types/data/fetchInfo.d.ts +0 -0
- /package/{model/model → models/models}/types/data/schema.d.ts +0 -0
- /package/{model/model → models/models}/types/data/search.d.ts +0 -0
- /package/{model/model → models/models}/types/index.d.ts +0 -0
- /package/{model/model → models/models}/types/menuType.d.ts +0 -0
- /package/{model/model → models/models}/types/model.d.ts +0 -0
- /package/{model → models}/packages/common/array/index.d.ts +0 -0
- /package/{model → models}/packages/common/cache/LRUCache.d.ts +0 -0
- /package/{model → models}/packages/common/cache/index.d.ts +0 -0
- /package/{model → models}/packages/common/guards/index.d.ts +0 -0
- /package/{model → models}/packages/common/http/index.d.ts +0 -0
- /package/{model → models}/packages/common/i18n/default.d.ts +0 -0
- /package/{model → models}/packages/common/i18n/en-US.d.ts +0 -0
- /package/{model → models}/packages/common/i18n/index.d.ts +0 -0
- /package/{model → models}/packages/common/i18n/locales.d.ts +0 -0
- /package/{model → models}/packages/common/log/index.d.ts +0 -0
- /package/{model → models}/packages/common/number/index.d.ts +0 -0
- /package/{model → models}/packages/common/object/filterEmpty.d.ts +0 -0
- /package/{model → models}/packages/common/object/index.d.ts +0 -0
- /package/{model → models}/packages/common/rafTimer.d.ts +0 -0
- /package/{model → models}/packages/common/string/index.d.ts +0 -0
- /package/{model → models}/packages/common/types/index.d.ts +0 -0
- /package/{model → models}/packages/react/hooks/useBreadcrumb.d.ts +0 -0
- /package/{model → models}/packages/react/hooks/useExecuteOnce.d.ts +0 -0
- /package/{model → models}/packages/react/hooks/useLanguage.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Button/Button.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Button/SubmitButton.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Button/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Card/Card.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Card/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Checkbox/Checkbox.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Checkbox/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/ConfirmDialog/ConfirmDialog.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/ConfirmDialog/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/DataTable/ActionBtn.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/DataTable/dataTableWidth.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/DataTable/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/Calendar.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/Date.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/LocaleContext.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/LocaleProvider.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/TimePicker.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/data.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/dateLocaleStore.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/dropdownPositioning.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Date/locales.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Drawer/Drawer.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Drawer/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Dropdown/Dropdown.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Dropdown/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Form/Form.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Form/FormItem.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Form/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Form/useForm.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/ImagePreview/ImagePreview.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/ImagePreview/PreviewImage.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/ImagePreview/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Input/Input.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Input/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/InputNumber/InputNumber.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/InputNumber/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/InputNumber/inputNumberUtils.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Label/Label.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Label/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Layout/Layout.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Layout/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Loading/Loading.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Loading/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Menu/Menu.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Menu/MenuContext.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Menu/MenuItem.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Menu/SubMenu.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Menu/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Menu/menuTypes.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Menu/utils.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Message/Message.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Message/MessageManager.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Message/data.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Message/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Modal/Modal.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Modal/ModalManager.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Modal/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Notification/Notification.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Notification/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Overlay/Overlay.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Overlay/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Pagination/Pagination.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Pagination/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Popup/Popup.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Popup/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Radio/Radio.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Radio/RadioGroup.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Radio/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Search/Search.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Search/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Select/Select.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Select/dropdownPositioning.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Select/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Skeleton/Skeleton.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Skeleton/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Switch/Switch.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Switch/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/TableSearch/TableSearch.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/TableSearch/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/TableSearch/lang.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/TableSearch/tableSearchLocaleStore.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Tabs/Tabs.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Tabs/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Textarea/Textarea.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Textarea/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Tooltip/Tooltip.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Tooltip/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/TreeSelect/TreeSelect.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/TreeSelect/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Upload/ImageUpload.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Upload/Upload.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/Upload/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/breadcrumb/breadcrumb.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/breadcrumb/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/hooks/useDropdownPositioning.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/hooks/useInputController.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/table/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/table/table.d.ts +0 -0
- /package/{model → models}/packages/react/ui/components/types/baseType.d.ts +0 -0
- /package/{model → models}/packages/react/ui/i18n/I18nProvider.d.ts +0 -0
- /package/{model → models}/packages/react/ui/i18n/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/i18n/useI18n.d.ts +0 -0
- /package/{model → models}/packages/react/ui/index.d.ts +0 -0
- /package/{model → models}/packages/react/ui/lib/createStoreHook.d.ts +0 -0
- /package/{model → models}/packages/react/ui/lib/export.d.ts +0 -0
- /package/{model → models}/packages/react/ui/lib/utils.d.ts +0 -0
- /package/{model → models}/packages/react/ui/stores/breadcrumb.d.ts +0 -0
- /package/{model → models}/packages/react/ui/stores/language.d.ts +0 -0
- /package/{model → models}/packages/react/ui/types/index.d.ts +0 -0
- /package/{model → models}/typings/type.d.ts +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region packages/common/number/index.ts
|
|
2
|
+
var clamp = (value, min, max) => {
|
|
3
|
+
if (min > max) throw new RangeError("min must be less than or equal to max");
|
|
4
|
+
return Math.min(Math.max(value, min), max);
|
|
5
|
+
};
|
|
6
|
+
var toFiniteNumber = (value, fallback = 0) => {
|
|
7
|
+
const numberValue = typeof value === "number" ? value : Number(value);
|
|
8
|
+
return Number.isFinite(numberValue) ? numberValue : fallback;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { clamp, toFiniteNumber };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { filterEmpty, filtereEmpty } from "./filterEmpty.js";
|
|
2
|
+
//#region packages/common/object/index.ts
|
|
3
|
+
var pick = (target, keys) => {
|
|
4
|
+
const result = {};
|
|
5
|
+
for (const key of keys) if (key in target) result[key] = target[key];
|
|
6
|
+
return result;
|
|
7
|
+
};
|
|
8
|
+
var omit = (target, keys) => {
|
|
9
|
+
const result = { ...target };
|
|
10
|
+
for (const key of keys) delete result[key];
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
var mapValues = (target, mapper) => {
|
|
14
|
+
const result = {};
|
|
15
|
+
const keys = Object.keys(target);
|
|
16
|
+
for (const key of keys) result[key] = mapper(target[key], key);
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { filterEmpty, filtereEmpty, mapValues, omit, pick };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface SSRHydrationData<Props = Record<string, unknown>, State = Record<string, unknown>> {
|
|
2
|
+
props: Props;
|
|
3
|
+
state: State;
|
|
4
|
+
meta: SSRPageMeta;
|
|
5
|
+
}
|
|
6
|
+
export interface SSRPageMeta {
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
renderedAt: number;
|
|
10
|
+
pathname: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const SSR_DATA_KEY = "__SSR_DATA__";
|
|
13
|
+
declare global {
|
|
14
|
+
interface Window {
|
|
15
|
+
[SSR_DATA_KEY]?: SSRHydrationData | string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export declare function serializeHydrationDataScriptContent(data: SSRHydrationData): string;
|
|
19
|
+
export declare function serializeHydrationData(data: SSRHydrationData): string;
|
|
20
|
+
export declare function peekHydrationData<Props = Record<string, unknown>, State = Record<string, unknown>>(): SSRHydrationData<Props, State> | null;
|
|
21
|
+
export declare function clearHydrationData(): void;
|
|
22
|
+
export declare function readHydrationData<Props = Record<string, unknown>, State = Record<string, unknown>>(): SSRHydrationData<Props, State> | null;
|
|
23
|
+
export declare function createHydrationData<Props = Record<string, unknown>, State = Record<string, unknown>>(props: Props, meta: Omit<SSRPageMeta, 'renderedAt'>, state?: State): SSRHydrationData<Props, State>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//#region packages/common/ssr/hydration.ts
|
|
2
|
+
/**
|
|
3
|
+
* 全局注水数据的 key
|
|
4
|
+
*/
|
|
5
|
+
var SSR_DATA_KEY = "__SSR_DATA__";
|
|
6
|
+
function getBuffer() {
|
|
7
|
+
return globalThis.Buffer;
|
|
8
|
+
}
|
|
9
|
+
function encodeUtf8ToBase64(value) {
|
|
10
|
+
const Buffer = getBuffer();
|
|
11
|
+
if (Buffer) return Buffer.from(value, "utf-8").toString("base64");
|
|
12
|
+
const bytes = new TextEncoder().encode(value);
|
|
13
|
+
let binary = "";
|
|
14
|
+
bytes.forEach((byte) => {
|
|
15
|
+
binary += String.fromCharCode(byte);
|
|
16
|
+
});
|
|
17
|
+
return btoa(binary);
|
|
18
|
+
}
|
|
19
|
+
function decodeBase64ToUtf8(value) {
|
|
20
|
+
const Buffer = getBuffer();
|
|
21
|
+
if (Buffer) return Buffer.from(value, "base64").toString("utf-8");
|
|
22
|
+
const binary = atob(value);
|
|
23
|
+
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
24
|
+
return new TextDecoder().decode(bytes);
|
|
25
|
+
}
|
|
26
|
+
function parseHydrationData(value) {
|
|
27
|
+
if (typeof value !== "string") return value;
|
|
28
|
+
return JSON.parse(decodeBase64ToUtf8(value));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 服务端:将注水数据序列化为 inline script 内容。
|
|
32
|
+
* 数据内容以 base64 字符串注入,避免在 HTML 中明文暴露 JSON。
|
|
33
|
+
*/
|
|
34
|
+
function serializeHydrationDataScriptContent(data) {
|
|
35
|
+
const encoded = encodeUtf8ToBase64(JSON.stringify(data));
|
|
36
|
+
return `window.${SSR_DATA_KEY}=${JSON.stringify(encoded)}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 服务端:将注水数据序列化为 script 标签。
|
|
40
|
+
*/
|
|
41
|
+
function serializeHydrationData(data) {
|
|
42
|
+
return `<script>${serializeHydrationDataScriptContent(data)}<\/script>`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 客户端:从 window 查看注水数据
|
|
46
|
+
* 不会清除全局数据,适合入口工厂与组件 hook 在同一次 hydration 中共享。
|
|
47
|
+
*/
|
|
48
|
+
function peekHydrationData() {
|
|
49
|
+
if (typeof window === "undefined") return null;
|
|
50
|
+
const rawData = window[SSR_DATA_KEY];
|
|
51
|
+
if (!rawData) return null;
|
|
52
|
+
const data = parseHydrationData(rawData);
|
|
53
|
+
window[SSR_DATA_KEY] = data;
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 客户端:清除 window 上的注水数据
|
|
58
|
+
* 推荐在 hydration 首次提交后调用,避免初次渲染期间的读取竞争。
|
|
59
|
+
*/
|
|
60
|
+
function clearHydrationData() {
|
|
61
|
+
if (typeof window === "undefined") return;
|
|
62
|
+
delete window[SSR_DATA_KEY];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 客户端:从 window 读取注水数据
|
|
66
|
+
* 保持历史兼容:读取后立即清除。
|
|
67
|
+
*/
|
|
68
|
+
function readHydrationData() {
|
|
69
|
+
const data = peekHydrationData();
|
|
70
|
+
if (!data) return null;
|
|
71
|
+
clearHydrationData();
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 服务端:创建注水数据对象
|
|
76
|
+
*/
|
|
77
|
+
function createHydrationData(props, meta, state) {
|
|
78
|
+
return {
|
|
79
|
+
props,
|
|
80
|
+
state: state ?? {},
|
|
81
|
+
meta: {
|
|
82
|
+
...meta,
|
|
83
|
+
renderedAt: Date.now()
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { SSR_DATA_KEY, clearHydrationData, createHydrationData, peekHydrationData, readHydrationData, serializeHydrationData, serializeHydrationDataScriptContent };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const isBrowser: boolean;
|
|
2
|
+
export declare const isServer: boolean;
|
|
3
|
+
export declare function clientOnly<T>(fn: () => T, fallback: T): T;
|
|
4
|
+
export declare function safeWindow(): Window | undefined;
|
|
5
|
+
export declare function safeDocument(): Document | undefined;
|
|
6
|
+
export declare function safeLocalStorage(key: string, fallback?: string): string;
|
|
7
|
+
export declare function safeSetLocalStorage(key: string, value: string): void;
|
|
8
|
+
export * from "./hydration";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SSR_DATA_KEY, clearHydrationData, createHydrationData, peekHydrationData, readHydrationData, serializeHydrationData, serializeHydrationDataScriptContent } from "./hydration.js";
|
|
2
|
+
//#region packages/common/ssr/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* SSR 环境检测与守卫工具
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 是否在浏览器环境中运行
|
|
8
|
+
*/
|
|
9
|
+
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
10
|
+
/**
|
|
11
|
+
* 是否在服务端环境中运行
|
|
12
|
+
*/
|
|
13
|
+
var isServer = !isBrowser;
|
|
14
|
+
/**
|
|
15
|
+
* 仅在浏览器环境执行回调,服务端返回 fallback
|
|
16
|
+
*/
|
|
17
|
+
function clientOnly(fn, fallback) {
|
|
18
|
+
if (isServer) return fallback;
|
|
19
|
+
return fn();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 安全访问 window 对象
|
|
23
|
+
* 服务端返回 undefined
|
|
24
|
+
*/
|
|
25
|
+
function safeWindow() {
|
|
26
|
+
if (isServer) return void 0;
|
|
27
|
+
return window;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 安全访问 document 对象
|
|
31
|
+
* 服务端返回 undefined
|
|
32
|
+
*/
|
|
33
|
+
function safeDocument() {
|
|
34
|
+
if (isServer) return void 0;
|
|
35
|
+
return document;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 安全读取 localStorage
|
|
39
|
+
*/
|
|
40
|
+
function safeLocalStorage(key, fallback = "") {
|
|
41
|
+
if (isServer) return fallback;
|
|
42
|
+
return localStorage.getItem(key) ?? fallback;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 安全写入 localStorage
|
|
46
|
+
*/
|
|
47
|
+
function safeSetLocalStorage(key, value) {
|
|
48
|
+
if (isServer) return;
|
|
49
|
+
localStorage.setItem(key, value);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { SSR_DATA_KEY, clearHydrationData, clientOnly, createHydrationData, isBrowser, isServer, peekHydrationData, readHydrationData, safeDocument, safeLocalStorage, safeSetLocalStorage, safeWindow, serializeHydrationData, serializeHydrationDataScriptContent };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region packages/common/string/index.ts
|
|
2
|
+
var isBlank = (value) => {
|
|
3
|
+
return value === null || value === void 0 || value.trim().length === 0;
|
|
4
|
+
};
|
|
5
|
+
var capitalize = (value) => {
|
|
6
|
+
if (value.length === 0) return value;
|
|
7
|
+
return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
|
|
8
|
+
};
|
|
9
|
+
var kebabCase = (value) => {
|
|
10
|
+
return value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/-+/g, "-").toLowerCase();
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 拼接字符串片段,自动跳过空值和不满足条件的片段。
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* joinStr('btn', isActive && 'active', [disabled, 'disabled'], { separator: ' ' })
|
|
17
|
+
* // => 'btn active disabled'
|
|
18
|
+
*/
|
|
19
|
+
var joinStr = (...strings) => {
|
|
20
|
+
const lastItem = strings[strings.length - 1];
|
|
21
|
+
const options = lastItem !== null && typeof lastItem === "object" && !Array.isArray(lastItem) && "separator" in lastItem ? lastItem : void 0;
|
|
22
|
+
const separator = options?.separator ?? " ";
|
|
23
|
+
return (options ? strings.slice(0, -1) : strings).flatMap((item) => {
|
|
24
|
+
if (Array.isArray(item)) {
|
|
25
|
+
const [condition, value] = item;
|
|
26
|
+
return condition ? value : void 0;
|
|
27
|
+
}
|
|
28
|
+
return item;
|
|
29
|
+
}).filter((item) => item !== null && item !== void 0 && item !== false && item !== "").join(separator);
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { capitalize, isBlank, joinStr, kebabCase };
|
|
File without changes
|
|
@@ -5,5 +5,7 @@ export { default as useInit } from "./useInit";
|
|
|
5
5
|
export * from "./useLanguage";
|
|
6
6
|
export { default as usePagination } from "./usePagination";
|
|
7
7
|
export { default as useRefState } from "./useRefState";
|
|
8
|
+
export * from "./useSSR";
|
|
8
9
|
export { default as useWatch } from "./useWatch";
|
|
9
10
|
export * from "./useWatch";
|
|
11
|
+
export * from "./useHydrationData";
|
|
@@ -5,4 +5,6 @@ import useExecuteOnce, { executionPhaseType } from "./useExecuteOnce.js";
|
|
|
5
5
|
import useRefState from "./useRefState.js";
|
|
6
6
|
import useWatch, { defaultCompare, identityCompare, shallowCompare } from "./useWatch.js";
|
|
7
7
|
import usePagination from "./usePagination.js";
|
|
8
|
-
|
|
8
|
+
import { useClientValue, useHydrated, useWindowSize } from "./useSSR.js";
|
|
9
|
+
import { useHydrationData } from "./useHydrationData.js";
|
|
10
|
+
export { defaultCompare, executionPhaseType, identityCompare, shallowCompare, useBreadcrumb, useClientValue, useExecuteOnce, useHydrated, useHydrationData, useInit, useLanguage, usePagination, useRefState, useWatch, useWindowSize };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { peekHydrationData } from "../../common/ssr/hydration.js";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
//#region packages/react/hooks/useHydrationData.ts
|
|
4
|
+
/**
|
|
5
|
+
* 查看 SSR 注水数据的 hook
|
|
6
|
+
* 只在首次渲染时读取,后续返回缓存值
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* function App() {
|
|
11
|
+
* const hydration = useHydrationData<{ title: string }>()
|
|
12
|
+
* const title = hydration?.props.title ?? 'Default'
|
|
13
|
+
* return <h1>{title}</h1>
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function useHydrationData() {
|
|
18
|
+
const ref = useRef(void 0);
|
|
19
|
+
if (ref.current === void 0) ref.current = peekHydrationData();
|
|
20
|
+
return ref.current;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useHydrationData };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
//#region packages/react/hooks/useSSR.ts
|
|
3
|
+
/**
|
|
4
|
+
* 检测当前是否已完成 hydration
|
|
5
|
+
* - 服务端渲染时返回 false
|
|
6
|
+
* - 客户端 hydration 完成后返回 true
|
|
7
|
+
*/
|
|
8
|
+
function useHydrated() {
|
|
9
|
+
const [hydrated, setHydrated] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setHydrated(true);
|
|
12
|
+
}, []);
|
|
13
|
+
return hydrated;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 仅在客户端执行的 hook
|
|
17
|
+
* 服务端渲染时返回 fallback 值
|
|
18
|
+
*/
|
|
19
|
+
function useClientValue(fn, fallback) {
|
|
20
|
+
const [value, setValue] = useState(fallback);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setValue(fn());
|
|
23
|
+
}, []);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* SSR 安全的 window 尺寸 hook
|
|
28
|
+
*/
|
|
29
|
+
function useWindowSize() {
|
|
30
|
+
const [size, setSize] = useState({
|
|
31
|
+
width: 0,
|
|
32
|
+
height: 0
|
|
33
|
+
});
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const update = () => setSize({
|
|
36
|
+
width: window.innerWidth,
|
|
37
|
+
height: window.innerHeight
|
|
38
|
+
});
|
|
39
|
+
update();
|
|
40
|
+
window.addEventListener("resize", update);
|
|
41
|
+
return () => window.removeEventListener("resize", update);
|
|
42
|
+
}, []);
|
|
43
|
+
return size;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { useClientValue, useHydrated, useWindowSize };
|
|
@@ -2,7 +2,6 @@ import { useI18n } from "../../i18n/useI18n.js";
|
|
|
2
2
|
import "../../i18n/index.js";
|
|
3
3
|
import { Checkbox } from "../Checkbox/Checkbox.js";
|
|
4
4
|
import "../Checkbox/index.js";
|
|
5
|
-
import no_result_default from "../../assets/table/no-result.js";
|
|
6
5
|
import { Pagination } from "../Pagination/Pagination.js";
|
|
7
6
|
import "../Pagination/index.js";
|
|
8
7
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../table/table.js";
|
|
@@ -14,6 +13,7 @@ import { getDataTableColumnStyle, getDataTableColumnWidth, getDataTableFixedOffs
|
|
|
14
13
|
import { useMemo, useState } from "react";
|
|
15
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
15
|
//#region packages/react/ui/components/DataTable/index.tsx
|
|
16
|
+
var noResult = new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='120'%20height='120'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'%3e%3crect%20x='3'%20y='3'%20width='18'%20height='18'%20rx='2'%20ry='2'/%3e%3cline%20x1='3'%20y1='9'%20x2='21'%20y2='9'/%3e%3cline%20x1='9'%20y1='21'%20x2='9'%20y2='9'/%3e%3c/svg%3e", "" + import.meta.url).href;
|
|
17
17
|
var defaultRowKey = "id";
|
|
18
18
|
var rowSelectionColumnWidth = 48;
|
|
19
19
|
var actionColumnWidth = 96;
|
|
@@ -135,8 +135,10 @@ function DataTable({ columns, data: pData, loading, rowKey = defaultRowKey, rowS
|
|
|
135
135
|
]);
|
|
136
136
|
return /* @__PURE__ */ jsxs("div", {
|
|
137
137
|
className: "tc-ui-data-table bg-background rounded-[20px] overflow-hidden relative",
|
|
138
|
-
children: [
|
|
139
|
-
|
|
138
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
139
|
+
className: loading ? "hidden" : void 0,
|
|
140
|
+
"aria-hidden": loading,
|
|
141
|
+
children: [/* @__PURE__ */ jsxs(Table, {
|
|
140
142
|
containerClassName: "rounded-b-none overflow-x-auto",
|
|
141
143
|
children: [/* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [rowSelection && /* @__PURE__ */ jsxs(TableHead, {
|
|
142
144
|
fixed: "left",
|
|
@@ -156,7 +158,7 @@ function DataTable({ columns, data: pData, loading, rowKey = defaultRowKey, rowS
|
|
|
156
158
|
isAction: column.isAction ?? column.key === "action",
|
|
157
159
|
fixed,
|
|
158
160
|
fixedOffset,
|
|
159
|
-
hideSeparatorWhenFixedActive: fixed === "right",
|
|
161
|
+
hideSeparatorWhenFixedActive: fixed === "right" || fixed === "left" && fixedOffset === "0px",
|
|
160
162
|
style: getDataTableColumnStyle(column, defaultColumnWidth, actionColumnWidth),
|
|
161
163
|
children: column.title
|
|
162
164
|
}, column.key);
|
|
@@ -166,7 +168,7 @@ function DataTable({ columns, data: pData, loading, rowKey = defaultRowKey, rowS
|
|
|
166
168
|
children: /* @__PURE__ */ jsxs("div", {
|
|
167
169
|
className: "flex flex-col items-center w-full gap-2.5",
|
|
168
170
|
children: [/* @__PURE__ */ jsx("img", {
|
|
169
|
-
src:
|
|
171
|
+
src: noResult,
|
|
170
172
|
alt: t("components.dataTable.noData"),
|
|
171
173
|
className: " w-24 h-24"
|
|
172
174
|
}), t("components.dataTable.noData")]
|
|
@@ -196,19 +198,18 @@ function DataTable({ columns, data: pData, loading, rowKey = defaultRowKey, rowS
|
|
|
196
198
|
}, column.key);
|
|
197
199
|
})] }, recordKey);
|
|
198
200
|
}) })]
|
|
199
|
-
}),
|
|
200
|
-
loading && /* @__PURE__ */ jsx("div", {
|
|
201
|
-
className: "absolute inset-0 rounded-[20px] bg-background/70 text-sm text-gray-600 z-[100]",
|
|
202
|
-
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
203
|
-
mode: "tableloading",
|
|
204
|
-
rows: 8
|
|
205
|
-
})
|
|
206
|
-
}),
|
|
207
|
-
showPagination && /* @__PURE__ */ jsx("div", {
|
|
201
|
+
}), showPagination && /* @__PURE__ */ jsx("div", {
|
|
208
202
|
className: "px-6 pb-6 mt-6",
|
|
209
203
|
children: /* @__PURE__ */ jsx(Pagination, { ...pagination })
|
|
204
|
+
})]
|
|
205
|
+
}), loading && /* @__PURE__ */ jsx("div", {
|
|
206
|
+
className: "overflow-hidden rounded-[20px] bg-background/70 text-sm text-gray-600",
|
|
207
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
208
|
+
mode: "tableloading",
|
|
209
|
+
rows: 8,
|
|
210
|
+
className: "overflow-hidden"
|
|
210
211
|
})
|
|
211
|
-
]
|
|
212
|
+
})]
|
|
212
213
|
});
|
|
213
214
|
}
|
|
214
215
|
//#endregion
|
|
@@ -26,8 +26,9 @@ export type ExtendedFieldType = Extract<keyof SchemaFormNamespace.FieldTypes | k
|
|
|
26
26
|
export type SchemaFormAllFieldType = SchemaFormFieldType | ExtendedFieldType;
|
|
27
27
|
export type SchemaFormAllPropsMap = SchemaFormComponentPropsMap & SchemaFormNamespace.PropsMap;
|
|
28
28
|
export type SchemaFormComponent = React.ComponentType<any> | React.LazyExoticComponent<React.ComponentType<any>>;
|
|
29
|
-
export declare const componentsMap: Record<SchemaFormAllFieldType, SchemaFormComponent
|
|
30
|
-
export type SchemaFormComponentsMap = Partial<Record<
|
|
29
|
+
export declare const componentsMap: Partial<Record<SchemaFormAllFieldType, SchemaFormComponent>>;
|
|
30
|
+
export type SchemaFormComponentsMap = Partial<Record<string, SchemaFormComponent>>;
|
|
31
|
+
export declare const registerSchemaFormComponents: (map: SchemaFormComponentsMap) => void;
|
|
31
32
|
export type FieldProps = {
|
|
32
33
|
[K in SchemaFormAllFieldType]: {
|
|
33
34
|
type: K;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import consumerComponentsMap from "@tc/scalability/SchemaForm/data";
|
|
3
|
-
import frameComponentsMap from "@tc/scalability/SchemaForm/frameData";
|
|
4
2
|
var componentsMap = {
|
|
5
3
|
input: React.lazy(async () => ({ default: (await import("../../Input/index.js")).Input })),
|
|
6
4
|
inputNumber: React.lazy(async () => ({ default: (await import("../../InputNumber/index.js")).InputNumber })),
|
|
@@ -8,9 +6,10 @@ var componentsMap = {
|
|
|
8
6
|
textarea: React.lazy(async () => ({ default: (await import("../../Textarea/index.js")).Textarea })),
|
|
9
7
|
switch: React.lazy(async () => ({ default: (await import("../../Switch/index.js")).Switch })),
|
|
10
8
|
date: React.lazy(async () => ({ default: (await import("../../Date/index.js")).DatePicker })),
|
|
11
|
-
checkbox: React.lazy(async () => ({ default: (await import("../../Checkbox/index.js")).Checkbox }))
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
checkbox: React.lazy(async () => ({ default: (await import("../../Checkbox/index.js")).Checkbox }))
|
|
10
|
+
};
|
|
11
|
+
var registerSchemaFormComponents = (map) => {
|
|
12
|
+
Object.assign(componentsMap, map);
|
|
14
13
|
};
|
|
15
14
|
//#endregion
|
|
16
|
-
export { componentsMap };
|
|
15
|
+
export { componentsMap, registerSchemaFormComponents };
|
|
@@ -6,6 +6,7 @@ import { type FormProps } from "..";
|
|
|
6
6
|
import { type ButtonElementProps } from "../../Button";
|
|
7
7
|
import type { LabelLayout } from "../../Label";
|
|
8
8
|
import { type FieldProps, type SchemaFormAllFieldType } from "./data";
|
|
9
|
+
export { registerSchemaFormComponents } from "./data";
|
|
9
10
|
export type { FieldProps, SchemaFormAllFieldType, SchemaFormAllPropsMap, SchemaFormComponent, SchemaFormComponentsMap, SchemaFormComponentPropsMap, SchemaFormFieldType, SchemaFormNamespace, } from "./data";
|
|
10
11
|
export type FormFieldType = SchemaFormAllFieldType;
|
|
11
12
|
type BaseField<T> = {
|
|
@@ -8,7 +8,7 @@ import "../../Skeleton/index.js";
|
|
|
8
8
|
import { Form } from "../Form.js";
|
|
9
9
|
import { FormItem } from "../FormItem.js";
|
|
10
10
|
import { useForm } from "../useForm.js";
|
|
11
|
-
import { componentsMap } from "./data.js";
|
|
11
|
+
import { componentsMap, registerSchemaFormComponents } from "./data.js";
|
|
12
12
|
import "../index.js";
|
|
13
13
|
import { Suspense, useEffect, useMemo, useRef } from "react";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -116,4 +116,4 @@ var SchemaForm = ({ form, getForm, schemas, className, onFinish, onFinishFailed,
|
|
|
116
116
|
};
|
|
117
117
|
SchemaForm.displayName = "SchemaForm";
|
|
118
118
|
//#endregion
|
|
119
|
-
export { SchemaForm, SchemaForm as default };
|
|
119
|
+
export { SchemaForm, SchemaForm as default, registerSchemaFormComponents };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Form } from "./Form.js";
|
|
2
2
|
import { FormItem } from "./FormItem.js";
|
|
3
3
|
import { useForm } from "./useForm.js";
|
|
4
|
+
import { registerSchemaFormComponents } from "./SchemaForm/data.js";
|
|
4
5
|
import { SchemaForm } from "./SchemaForm/index.js";
|
|
5
|
-
export { Form, FormItem, SchemaForm, useForm };
|
|
6
|
+
export { Form, FormItem, SchemaForm, registerSchemaFormComponents, useForm };
|
|
@@ -21,7 +21,11 @@ var Input = forwardRef(({ className, inputClassName, type, value: controlledValu
|
|
|
21
21
|
Promise.resolve().then(() => {
|
|
22
22
|
if (!isMountedRef.current) return;
|
|
23
23
|
const input = controllerRef.current;
|
|
24
|
-
if (input?.getAttribute("type") === "password" && input.hasAttribute("value"))
|
|
24
|
+
if (input?.getAttribute("type") === "password" && input.hasAttribute("value")) {
|
|
25
|
+
const currentValue = input.value;
|
|
26
|
+
input.removeAttribute("value");
|
|
27
|
+
input.value = currentValue;
|
|
28
|
+
}
|
|
25
29
|
});
|
|
26
30
|
}, [controllerRef, isPasswordInput]);
|
|
27
31
|
useEffect(() => {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { cn } from "../../lib/utils.js";
|
|
2
2
|
import { getDefaultDropdownPosition, useDropdownPositioning } from "../hooks/useDropdownPositioning.js";
|
|
3
|
-
import { useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
//#region packages/react/ui/components/Popup/Popup.tsx
|
|
7
7
|
var DEFAULT_POPUP_CLASSNAME = cn("fixed z-[1000]", "rounded-xl border border-border/60 bg-popover text-popover-foreground", "shadow-[var(--shadow-floating)]", "animate-in fade-in-0 zoom-in-95");
|
|
8
8
|
var canUseDocument = () => typeof document !== "undefined";
|
|
9
9
|
function Popup({ open, anchorRef, children, className, style, placement = "bottom-end", offset = 8, keepMounted = false, closeOnClickOutside = true, closeOnEscape = true, matchAnchorWidth = false, position, positioning, strategy = getDefaultDropdownPosition, contentRef, container, positionMode = "fixed", hoverBridge = 0, hoverBridgePlacement = "auto", onOpenChange }) {
|
|
10
|
+
const [mounted, setMounted] = useState(false);
|
|
10
11
|
const internalContentRef = useRef(null);
|
|
11
12
|
const panelRef = contentRef ?? internalContentRef;
|
|
12
13
|
const internalPositioning = useDropdownPositioning({
|
|
@@ -60,7 +61,11 @@ function Popup({ open, anchorRef, children, className, style, placement = "botto
|
|
|
60
61
|
style
|
|
61
62
|
]);
|
|
62
63
|
const showBothHorizontalHoverBridges = hoverBridge > 0 && (placement.startsWith("right") || placement.startsWith("left")) && hoverBridgePlacement === "horizontal";
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
setMounted(true);
|
|
66
|
+
}, []);
|
|
63
67
|
if (!keepMounted && !open) return null;
|
|
68
|
+
if (!mounted) return null;
|
|
64
69
|
const portalContainer = container ?? (canUseDocument() ? document.body : void 0);
|
|
65
70
|
if (!portalContainer) return null;
|
|
66
71
|
return createPortal(/* @__PURE__ */ jsxs("div", {
|
|
@@ -40,6 +40,7 @@ import { Label } from "./Label/Label.js";
|
|
|
40
40
|
import "./Label/index.js";
|
|
41
41
|
import { FormItem } from "./Form/FormItem.js";
|
|
42
42
|
import { useForm } from "./Form/useForm.js";
|
|
43
|
+
import { registerSchemaFormComponents } from "./Form/SchemaForm/data.js";
|
|
43
44
|
import { SchemaForm } from "./Form/SchemaForm/index.js";
|
|
44
45
|
import "./Form/index.js";
|
|
45
46
|
import { ImagePreviewController } from "./ImagePreview/ImagePreview.js";
|
|
@@ -78,4 +79,4 @@ import "./TreeSelect/index.js";
|
|
|
78
79
|
import { FileUpload } from "./Upload/Upload.js";
|
|
79
80
|
import { ImageUpload } from "./Upload/ImageUpload.js";
|
|
80
81
|
import "./Upload/index.js";
|
|
81
|
-
export { ActionBtn, AsynchronousButton, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, CollapseToggle, ConfirmDialog, DataTable, Drawer, Dropdown, FileUpload, Form, FormItem, ImagePreviewController, ImageUpload, Input, InputNumber, Label, Layout, Loading, LoadingIndicator, Menu, MenuItem, Modal, Notification, Overlay, Pagination, Popup, PreviewImage, Radio, RadioGroup, SchemaForm, Search, Select, SimpleBreadcrumb, Skeleton, SubMenu, SubmitButton, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSearch, Tabs, Textarea, Tooltip, TreeSelect, canUseDocument, getDefaultDropdownPosition, message, modal, useDropdownPositioning, useForm, useMenuStore, useRadioGroupContext };
|
|
82
|
+
export { ActionBtn, AsynchronousButton, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, CollapseToggle, ConfirmDialog, DataTable, Drawer, Dropdown, FileUpload, Form, FormItem, ImagePreviewController, ImageUpload, Input, InputNumber, Label, Layout, Loading, LoadingIndicator, Menu, MenuItem, Modal, Notification, Overlay, Pagination, Popup, PreviewImage, Radio, RadioGroup, SchemaForm, Search, Select, SimpleBreadcrumb, Skeleton, SubMenu, SubmitButton, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSearch, Tabs, Textarea, Tooltip, TreeSelect, canUseDocument, getDefaultDropdownPosition, message, modal, registerSchemaFormComponents, useDropdownPositioning, useForm, useMenuStore, useRadioGroupContext };
|