@_tc/template-core 0.4.0 → 0.4.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/reference/component-api.md +27 -0
- package/.skills/tc-generator/SKILL.md +1 -1
- package/.skills/tc-generator/reference/project-template/ssr/apps/hello/hello.entry.tsx +6 -1
- package/.skills/tc-generator/reference/runtime-extensions.md +10 -0
- package/AGENT_README.md +8 -2
- package/CHANGE.md +27 -0
- package/README.md +157 -8
- package/cjs/app/ai/agent/agent-scanner.service.js +1 -1
- package/cjs/app/ai/agent/agent.module.js +1 -1
- package/cjs/app/ai/ai-config.module.js +1 -1
- package/cjs/app/ai/ai-config.service.js +1 -1
- package/cjs/app/ai/ai.controller.js +1 -1
- package/cjs/app/ai/ai.module.js +1 -1
- package/cjs/app/ai/guardrail/guardrail.module.js +1 -1
- package/cjs/app/ai/guardrail/guardrail.service.js +1 -1
- package/cjs/app/ai/index.js +1 -0
- package/cjs/app/ai/mcp/internal/read-sse-response.js +2 -0
- package/cjs/app/ai/mcp/internal/stdio-process.js +1 -0
- package/cjs/app/ai/mcp/mcp-registry.service.js +2 -2
- package/cjs/app/ai/mcp/mcp.client.js +2 -3
- package/cjs/app/ai/mcp/mcp.loader.js +1 -1
- package/cjs/app/ai/mcp/mcp.module.js +1 -1
- package/cjs/app/ai/memory/checkpoint.service.js +1 -1
- package/cjs/app/ai/memory/memory.module.js +1 -1
- package/cjs/app/ai/memory/thread.service.js +1 -1
- package/cjs/app/ai/models/chat-sse.js +4 -0
- package/cjs/app/ai/models/chat.js +1 -0
- package/cjs/app/ai/models/http.js +1 -0
- package/cjs/app/ai/models/image.js +1 -0
- package/cjs/app/ai/models/video.js +1 -0
- package/cjs/app/ai/nest-service-provider.js +1 -0
- package/cjs/app/ai/rag/rag.module.js +1 -1
- package/cjs/app/ai/rag/retriever.service.js +1 -1
- package/cjs/app/ai/retention/conversation-retention.service.js +1 -1
- package/cjs/app/ai/runtime/ai-runtime-startup.validator.js +1 -1
- package/cjs/app/ai/runtime/ai-runtime.js +1 -0
- package/cjs/app/ai/runtime/internal/context-compaction.service.js +3 -3
- package/cjs/app/ai/runtime/internal/declaration-snapshot.js +1 -0
- package/cjs/app/ai/runtime/internal/owned-runtime-resources.js +1 -0
- package/cjs/app/ai/runtime/langchain/langchain-planner.service.js +1 -1
- package/cjs/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +1 -1
- package/cjs/app/ai/runtime/runtime.module.js +1 -1
- package/cjs/app/ai/skill/skill-scanner.service.js +1 -1
- package/cjs/app/ai/skill/skill.module.js +1 -1
- package/cjs/app/ai/snapshot-data.js +1 -0
- package/cjs/app/ai/store/internal/create-vector-store.js +1 -0
- package/cjs/app/ai/store/store.module.js +1 -1
- package/cjs/app/ai/tool/builtin/index.js +1 -1
- package/cjs/app/ai/tool/builtin/invoke-agent.tool.js +1 -1
- package/cjs/app/ai/tool/builtin/retrieve.tool.js +1 -1
- package/cjs/app/ai/tool/executor.service.js +1 -1
- package/cjs/app/ai/tool/tool-registry.service.js +1 -1
- package/cjs/app/ai/tool/tool.module.js +1 -1
- package/cjs/app/ai/trace/trace.service.js +1 -1
- package/cjs/app/csr/controller.js +1 -1
- package/cjs/app/csr/types.js +0 -0
- package/cjs/app/html/browser-options.js +1 -1
- package/cjs/app/html/shell.js +31 -16
- package/cjs/app/http/api-signing.js +1 -0
- package/cjs/app/http/body-parser.middleware.js +1 -1
- package/cjs/app/http/csp-nonce.js +1 -0
- package/cjs/app/http/error-response.js +1 -1
- package/cjs/app/http/exception-filter.js +1 -1
- package/cjs/app/http/request-body-parser-policy.js +1 -0
- package/cjs/app/http/security.guard.js +1 -1
- package/cjs/app/project/controller.js +1 -1
- package/cjs/app/project/service.js +1 -1
- package/cjs/app/providers/foundation.js +1 -1
- package/cjs/app/ssr/artifacts.js +1 -1
- package/cjs/app/ssr/controller.js +1 -1
- package/cjs/app/ssr/html.js +17 -17
- package/cjs/app/ssr/stream.js +1 -1
- package/cjs/app/static-assets.middleware.js +1 -1
- package/cjs/app/template-core.module.js +1 -1
- package/cjs/app/view/entry.tpl +2 -2
- package/cjs/bundler/buildSSR.js +1 -1
- package/cjs/bundler/entryCollect.js +1 -1
- package/cjs/bundler/feSharedConfig.js +1 -1
- package/cjs/bundler/utils.js +3 -3
- package/cjs/config/config.default.js +1 -1
- package/cjs/packages/common/index.js +1 -1
- package/cjs/packages/core/bootstrap.js +1 -1
- package/cjs/packages/core/startup.js +1 -1
- package/esm/app/ai/agent/agent-scanner.service.js +33 -36
- package/esm/app/ai/agent/agent.module.js +9 -7
- package/esm/app/ai/ai-config.module.js +14 -7
- package/esm/app/ai/ai-config.service.js +24 -20
- package/esm/app/ai/ai.controller.js +41 -41
- package/esm/app/ai/ai.module.js +15 -15
- package/esm/app/ai/guardrail/guardrail.module.js +11 -9
- package/esm/app/ai/guardrail/guardrail.service.js +5 -10
- package/esm/app/ai/index.js +2 -0
- package/esm/app/ai/mcp/internal/read-sse-response.js +35 -0
- package/esm/app/ai/mcp/internal/stdio-process.js +59 -0
- package/esm/app/ai/mcp/mcp-registry.service.js +10 -15
- package/esm/app/ai/mcp/mcp.client.js +77 -78
- package/esm/app/ai/mcp/mcp.loader.js +64 -42
- package/esm/app/ai/mcp/mcp.module.js +62 -22
- package/esm/app/ai/memory/checkpoint.service.js +18 -28
- package/esm/app/ai/memory/memory.module.js +15 -12
- package/esm/app/ai/memory/thread.service.js +21 -26
- package/esm/app/ai/models/chat-sse.js +44 -0
- package/esm/app/ai/models/chat.js +60 -0
- package/esm/app/ai/models/http.js +52 -0
- package/esm/app/ai/models/image.js +37 -0
- package/esm/app/ai/models/video.js +32 -0
- package/esm/app/ai/nest-service-provider.js +10 -0
- package/esm/app/ai/rag/rag.module.js +24 -15
- package/esm/app/ai/rag/retriever.service.js +37 -54
- package/esm/app/ai/retention/conversation-retention.service.js +16 -34
- package/esm/app/ai/runtime/ai-runtime-startup.validator.js +2 -19
- package/esm/app/ai/runtime/ai-runtime.js +104 -0
- package/esm/app/ai/runtime/internal/context-compaction.service.js +139 -145
- package/esm/app/ai/runtime/internal/declaration-snapshot.js +32 -0
- package/esm/app/ai/runtime/internal/owned-runtime-resources.js +21 -0
- package/esm/app/ai/runtime/langchain/langchain-planner.service.js +43 -49
- package/esm/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +273 -225
- package/esm/app/ai/runtime/runtime.module.js +56 -35
- package/esm/app/ai/skill/skill-scanner.service.js +11 -16
- package/esm/app/ai/skill/skill.module.js +11 -9
- package/esm/app/ai/snapshot-data.js +24 -0
- package/esm/app/ai/store/internal/create-vector-store.js +10 -0
- package/esm/app/ai/store/store.module.js +9 -13
- package/esm/app/ai/tool/builtin/index.js +16 -4
- package/esm/app/ai/tool/builtin/invoke-agent.tool.js +30 -34
- package/esm/app/ai/tool/builtin/retrieve.tool.js +9 -13
- package/esm/app/ai/tool/executor.service.js +22 -29
- package/esm/app/ai/tool/tool-registry.service.js +6 -16
- package/esm/app/ai/tool/tool.module.js +26 -12
- package/esm/app/ai/trace/trace.service.js +15 -28
- package/esm/app/csr/controller.js +114 -63
- package/esm/app/csr/types.js +0 -0
- package/esm/app/html/browser-options.js +2 -2
- package/esm/app/html/shell.js +173 -32
- package/esm/app/http/api-signing.js +13 -0
- package/esm/app/http/body-parser.middleware.js +47 -27
- package/esm/app/http/csp-nonce.js +13 -0
- package/esm/app/http/error-response.js +8 -5
- package/esm/app/http/exception-filter.js +4 -4
- package/esm/app/http/request-body-parser-policy.js +46 -0
- package/esm/app/http/security.guard.js +23 -21
- package/esm/app/project/controller.js +15 -15
- package/esm/app/project/service.js +3 -3
- package/esm/app/providers/foundation.js +5 -5
- package/esm/app/ssr/artifacts.js +25 -21
- package/esm/app/ssr/controller.js +148 -75
- package/esm/app/ssr/html.js +49 -44
- package/esm/app/ssr/stream.js +25 -24
- package/esm/app/static-assets.middleware.js +4 -4
- package/esm/app/template-core.module.js +57 -52
- package/esm/app/view/entry.tpl +2 -2
- package/esm/bundler/buildSSR.js +1 -1
- package/esm/bundler/entryCollect.js +9 -9
- package/esm/bundler/feSharedConfig.js +42 -42
- package/esm/bundler/utils.js +78 -90
- package/esm/config/config.default.js +4 -3
- package/esm/packages/common/index.js +6 -6
- package/esm/packages/core/bootstrap.js +5 -5
- package/esm/packages/core/startup.js +69 -46
- package/fe/frontend/src/common/request.js +5 -2
- package/fe/frontend/src/hooks/useRouterParams.d.ts +4 -2
- package/fe/packages/common/ssr/hydration.d.ts +9 -0
- package/fe/packages/react/core/Label/Label.d.ts +1 -0
- package/fe/packages/react/core/Label/Label.js +3 -1
- package/fe/packages/react/core/internal/i18n/default.d.ts +13 -0
- package/fe/packages/react/core/internal/i18n/default.js +16 -1
- package/fe/packages/react/core/internal/i18n/en-US.d.ts +13 -0
- package/fe/packages/react/core/internal/i18n/en-US.js +16 -1
- package/fe/packages/react/forms/DataTable/index.d.ts +2 -0
- package/fe/packages/react/forms/DataTable/index.js +43 -29
- package/fe/packages/react/forms/Form/FormItem.js +39 -12
- package/fe/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
- package/fe/packages/react/forms/MultiSelect/MultiSelect.js +218 -0
- package/fe/packages/react/forms/MultiSelect/index.d.ts +1 -0
- package/fe/packages/react/forms/MultiSelect/index.js +2 -0
- package/fe/packages/react/forms/Pagination/Pagination.d.ts +6 -1
- package/fe/packages/react/forms/Pagination/Pagination.js +13 -4
- package/fe/packages/react/forms/Select/Select.d.ts +11 -0
- package/fe/packages/react/forms/Select/Select.js +20 -7
- package/fe/packages/react/forms/index.d.ts +1 -0
- package/fe/packages/react/forms/index.js +3 -1
- package/fe/packages/react/i18n/getUiReactLocale.d.ts +26 -0
- package/fe/packages/react/index.js +2 -1
- package/fe/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
- package/fe/packages/react/overlays/Drawer/Drawer.js +16 -2
- package/fe/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
- package/fe/packages/react/overlays/Dropdown/Dropdown.js +27 -14
- package/fe/packages/react/overlays/Modal/Modal.d.ts +11 -3
- package/fe/packages/react/overlays/Modal/Modal.js +26 -2
- package/fe/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
- package/fe/packages/react/overlays/Modal/ModalManager.js +15 -5
- package/fe/packages/react/overlays/Modal/index.d.ts +1 -0
- package/fe/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
- package/fe/packages/react/overlays/Overlay/Overlay.js +31 -14
- package/fe/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
- package/fe/packages/react/overlays/Overlay/focusTypes.js +0 -0
- package/fe/packages/react/overlays/Overlay/index.d.ts +1 -0
- package/fe/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
- package/fe/packages/react/overlays/Overlay/overlayStack.js +290 -0
- package/fe/packages/react/overlays/Popup/Popup.d.ts +5 -4
- package/fe/packages/react/overlays/Popup/Popup.js +28 -11
- package/fe/packages/react/ui/components/index.js +2 -1
- package/fe/packages/react/ui/index.js +2 -1
- package/fe/ssr/components/StreamingRender/StreamingCache.d.ts +1 -0
- package/fe/ssr/components/StreamingRender/StreamingCache.js +5 -1
- package/fe/ssr/components/StreamingRender/StreamingRender.js +1 -1
- package/fe/ssr/components/StreamingRender/StreamingScript.d.ts +1 -0
- package/fe/ssr/components/StreamingRender/StreamingScript.js +9 -1
- package/fe/ssr/createSSREntry.d.ts +9 -3
- package/fe/ssr/createSSREntry.js +43 -19
- package/fe/ssr/index.d.ts +4 -1
- package/fe/ssr/index.js +2 -1
- package/fe/ssr/router.d.ts +76 -0
- package/fe/ssr/router.js +349 -0
- package/fe/ssr/types.d.ts +1 -1
- package/models/packages/common/ssr/hydration.d.ts +9 -0
- package/models/packages/react/core/Label/Label.d.ts +1 -0
- package/models/packages/react/core/internal/i18n/default.d.ts +13 -0
- package/models/packages/react/core/internal/i18n/en-US.d.ts +13 -0
- package/models/packages/react/forms/DataTable/index.d.ts +2 -0
- package/models/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
- package/models/packages/react/forms/MultiSelect/index.d.ts +1 -0
- package/models/packages/react/forms/Pagination/Pagination.d.ts +6 -1
- package/models/packages/react/forms/Select/Select.d.ts +11 -0
- package/models/packages/react/forms/index.d.ts +1 -0
- package/models/packages/react/i18n/getUiReactLocale.d.ts +26 -0
- package/models/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
- package/models/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
- package/models/packages/react/overlays/Modal/Modal.d.ts +11 -3
- package/models/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
- package/models/packages/react/overlays/Modal/index.d.ts +1 -0
- package/models/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
- package/models/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
- package/models/packages/react/overlays/Overlay/index.d.ts +1 -0
- package/models/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
- package/models/packages/react/overlays/Popup/Popup.d.ts +5 -4
- package/package.json +26 -1
- package/types/app/ai/agent/agent-scanner.service.d.ts +4 -4
- package/types/app/ai/ai-config.service.d.ts +7 -3
- package/types/app/ai/guardrail/guardrail.service.d.ts +2 -2
- package/types/app/ai/index.d.ts +9 -0
- package/types/app/ai/mcp/internal/load-mcp-config.d.ts +2 -2
- package/types/app/ai/mcp/internal/read-sse-response.d.ts +2 -0
- package/types/app/ai/mcp/internal/stdio-process.d.ts +5 -0
- package/types/app/ai/mcp/mcp-registry.service.d.ts +5 -3
- package/types/app/ai/mcp/mcp.client.d.ts +7 -4
- package/types/app/ai/mcp/mcp.loader.d.ts +11 -11
- package/types/app/ai/mcp/mcp.module.d.ts +5 -5
- package/types/app/ai/memory/thread.service.d.ts +3 -3
- package/types/app/ai/models/chat-sse.d.ts +5 -0
- package/types/app/ai/models/chat.d.ts +22 -0
- package/types/app/ai/models/http.d.ts +20 -0
- package/types/app/ai/models/image.d.ts +69 -0
- package/types/app/ai/models/video.d.ts +99 -0
- package/types/app/ai/nest-service-provider.d.ts +6 -0
- package/types/app/ai/retention/conversation-retention.service.d.ts +3 -4
- package/types/app/ai/runtime/ai-runtime-startup.validator.d.ts +2 -3
- package/types/app/ai/runtime/ai-runtime.d.ts +46 -0
- package/types/app/ai/runtime/internal/agent-run-context.d.ts +4 -0
- package/types/app/ai/runtime/internal/context-compaction.service.d.ts +2 -2
- package/types/app/ai/runtime/internal/declaration-snapshot.d.ts +8 -0
- package/types/app/ai/runtime/internal/owned-runtime-resources.d.ts +5 -0
- package/types/app/ai/runtime/langchain/langchain-planner.service.d.ts +1 -1
- package/types/app/ai/runtime/langgraph/langgraph-orchestrator.service.d.ts +33 -16
- package/types/app/ai/skill/skill-scanner.service.d.ts +3 -4
- package/types/app/ai/snapshot-data.d.ts +1 -0
- package/types/app/ai/store/internal/create-vector-store.d.ts +4 -0
- package/types/app/ai/tool/builtin/index.d.ts +1 -1
- package/types/app/ai/tool/builtin/invoke-agent.tool.d.ts +10 -3
- package/types/app/ai/tool/builtin/retrieve.tool.d.ts +4 -3
- package/types/app/ai/tool/executor.service.d.ts +3 -3
- package/types/app/ai/tool/tool-registry.service.d.ts +2 -7
- package/types/app/ai/tool/tool.interface.d.ts +1 -1
- package/types/app/ai/tool/tool.module.d.ts +8 -1
- package/types/app/ai/trace/trace.service.d.ts +4 -5
- package/types/app/csr/types.d.ts +10 -0
- package/types/app/html/browser-options.d.ts +1 -1
- package/types/app/html/shell.d.ts +37 -10
- package/types/app/http/api-signing.d.ts +16 -0
- package/types/app/http/body-parser.middleware.d.ts +6 -2
- package/types/app/http/csp-nonce.d.ts +3 -0
- package/types/app/http/error-response.d.ts +1 -0
- package/types/app/http/request-body-parser-policy.d.ts +8 -0
- package/types/app/http/security.guard.d.ts +1 -0
- package/types/app/ssr/artifacts.d.ts +6 -3
- package/types/app/ssr/html.d.ts +7 -0
- package/types/app/ssr/stream.d.ts +1 -1
- package/types/app/ssr/types.d.ts +56 -0
- package/types/bundler/buildSSR.d.ts +2 -1
- package/types/bundler/index.d.ts +1 -1
- package/types/bundler/state.d.ts +13 -0
- package/types/bundler/utils.d.ts +3 -14
- package/types/config/config.default.d.ts +9 -3
- package/types/index.d.ts +4 -1
- package/types/packages/common/ssr/hydration.d.ts +13 -0
- package/types/packages/core/index.d.ts +1 -1
- package/types/packages/core/startup.d.ts +41 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { SSRHydrationHead } from "../packages/common/index";
|
|
2
|
+
import type { SSRLayout, SSRPageDataPage, SSRPageDataStatus, SSRResolvedProps } from "./types";
|
|
3
|
+
import React, { type ComponentType } from "react";
|
|
4
|
+
export interface SSRNavigateOptions {
|
|
5
|
+
replace?: boolean;
|
|
6
|
+
scroll?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SSRRouterOptions {
|
|
9
|
+
ssrPageBasePath?: string;
|
|
10
|
+
layout?: SSRLayout;
|
|
11
|
+
fetcher?: typeof fetch;
|
|
12
|
+
onNavigationError?: (error: unknown) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface SSRLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
15
|
+
replace?: boolean;
|
|
16
|
+
scroll?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface SSRRoot {
|
|
19
|
+
render(children: React.ReactNode): void;
|
|
20
|
+
}
|
|
21
|
+
export interface SSRRouteState {
|
|
22
|
+
component: PageComponent;
|
|
23
|
+
layout?: SSRLayout;
|
|
24
|
+
data: PageResponse;
|
|
25
|
+
url: URL;
|
|
26
|
+
}
|
|
27
|
+
type PageComponent = ComponentType<SSRResolvedProps>;
|
|
28
|
+
type PageResponse = SSRPageDataPage | SSRPageDataStatus;
|
|
29
|
+
interface PendingNavigation {
|
|
30
|
+
page: string;
|
|
31
|
+
url: URL;
|
|
32
|
+
data: PageResponse;
|
|
33
|
+
router: SSRClientRouter;
|
|
34
|
+
replace?: boolean;
|
|
35
|
+
scroll?: boolean;
|
|
36
|
+
fromHistory?: boolean;
|
|
37
|
+
resolve: () => void;
|
|
38
|
+
reject: (error: unknown) => void;
|
|
39
|
+
}
|
|
40
|
+
declare global {
|
|
41
|
+
interface Window {
|
|
42
|
+
__TC_SSR_NAVIGATION__?: PendingNavigation;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export declare function createPageElement(component: PageComponent, layout: SSRLayout | undefined, data: PageResponse, url: URL): React.ReactElement;
|
|
46
|
+
export declare class SSRClientRouter {
|
|
47
|
+
private readonly root;
|
|
48
|
+
private readonly renderRoute?;
|
|
49
|
+
private currentComponent;
|
|
50
|
+
private currentLayout;
|
|
51
|
+
private currentBuildKey;
|
|
52
|
+
private currentPage;
|
|
53
|
+
private readonly components;
|
|
54
|
+
private pending;
|
|
55
|
+
private readonly basePath;
|
|
56
|
+
private readonly fetcher;
|
|
57
|
+
private readonly onPopState;
|
|
58
|
+
constructor(root: SSRRoot, component: PageComponent, data: SSRPageDataPage | SSRPageDataStatus, initialLayout: SSRLayout | undefined, options?: SSRRouterOptions, renderRoute?: ((state: SSRRouteState) => void) | undefined);
|
|
59
|
+
private readonly onNavigationError;
|
|
60
|
+
activate(): void;
|
|
61
|
+
canHandle(url: URL): boolean;
|
|
62
|
+
consumeNavigation(request: PendingNavigation, component: PageComponent, layout?: SSRLayout): boolean;
|
|
63
|
+
navigate(input: string | URL, options?: SSRNavigateOptions & {
|
|
64
|
+
fromHistory?: boolean;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
private readonly finishNavigation;
|
|
67
|
+
private readonly fullNavigation;
|
|
68
|
+
}
|
|
69
|
+
export declare function createSSRRouter(root: SSRRoot, component: PageComponent, data: SSRPageDataPage | SSRPageDataStatus, layout?: SSRLayout, options?: SSRRouterOptions, renderRoute?: (state: SSRRouteState) => void): SSRClientRouter;
|
|
70
|
+
export declare function setActiveSSRRouter(router: SSRClientRouter): void;
|
|
71
|
+
export declare function getActiveSSRRouter(): SSRClientRouter | undefined;
|
|
72
|
+
export declare function navigate(url: string | URL, options?: SSRNavigateOptions): Promise<void>;
|
|
73
|
+
export declare function Link({ replace, scroll, onClick, target, ...props }: SSRLinkProps): React.ReactElement;
|
|
74
|
+
export declare function consumePendingSSRNavigation(component: PageComponent, layout?: SSRLayout): boolean;
|
|
75
|
+
export declare function markSSRInitialHead(head: SSRHydrationHead | undefined): void;
|
|
76
|
+
export type { PageResponse as SSRNavigationPageResponse };
|
package/fe/ssr/router.js
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { resetStreamingRenderCache } from "./components/StreamingRender/StreamingCache.js";
|
|
2
|
+
import { resetClientStreamData } from "./components/StreamingRender/StreamingScript.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
//#region ssr/router.tsx
|
|
5
|
+
var NAVIGATION_HEADER = "x-tc-ssr-data";
|
|
6
|
+
var NAVIGATION_STATE_KEY = "__TC_SSR_NAVIGATION__";
|
|
7
|
+
var MANAGED_HEAD_ATTRIBUTE = "data-tc-ssr-head";
|
|
8
|
+
var getWindow = () => typeof window === "undefined" ? void 0 : window;
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return !!value && typeof value === "object";
|
|
11
|
+
}
|
|
12
|
+
function isPageResponse(value) {
|
|
13
|
+
if (!isRecord(value) || value.type !== "page" && value.type !== "status") return false;
|
|
14
|
+
return typeof value.page === "string" && isRecord(value.props) && typeof value.title === "string" && typeof value.description === "string" && typeof value.status === "number" && (typeof value.buildKey === "string" || value.buildKey === null) && (typeof value.entry === "string" || value.entry === null);
|
|
15
|
+
}
|
|
16
|
+
function isRedirectResponse(value) {
|
|
17
|
+
return isRecord(value) && value.type === "redirect" && typeof value.page === "string" && typeof value.location === "string" && Number.isInteger(value.status) && (typeof value.buildKey === "string" || value.buildKey === null);
|
|
18
|
+
}
|
|
19
|
+
function parseNavigationResponse(value) {
|
|
20
|
+
if (isPageResponse(value) || isRedirectResponse(value)) return value;
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function normalizePath(value) {
|
|
24
|
+
const normalized = value.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
25
|
+
if (normalized === "/") return normalized;
|
|
26
|
+
return `/${normalized.replace(/^\/+|\/+$/g, "")}`;
|
|
27
|
+
}
|
|
28
|
+
function inferSSRPageBasePath() {
|
|
29
|
+
const current = getWindow()?._basePath;
|
|
30
|
+
if (!current) return "/fessr";
|
|
31
|
+
const segments = normalizePath(new URL(current, window.location.origin).pathname).split("/").filter(Boolean);
|
|
32
|
+
return segments.length > 1 ? `/${segments.slice(0, -1).join("/")}` : "/";
|
|
33
|
+
}
|
|
34
|
+
function getPageFromUrl(url, basePath) {
|
|
35
|
+
const normalizedBase = normalizePath(basePath);
|
|
36
|
+
const pathname = normalizePath(url.pathname);
|
|
37
|
+
if (normalizedBase === "/") return pathname.split("/").filter(Boolean)[0] || null;
|
|
38
|
+
if (pathname !== normalizedBase && !pathname.startsWith(`${normalizedBase}/`)) return null;
|
|
39
|
+
return pathname.slice(normalizedBase.length).split("/").filter(Boolean)[0] ?? null;
|
|
40
|
+
}
|
|
41
|
+
/** Keep JSON-LD text identical to the server shell's script-safe serialization. */
|
|
42
|
+
function serializeForHtmlScript(value) {
|
|
43
|
+
return (JSON.stringify(value) ?? "null").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
44
|
+
}
|
|
45
|
+
function resolveEntryUrl(entry) {
|
|
46
|
+
if (entry.startsWith("/")) return new URL(entry, window.location.origin).href;
|
|
47
|
+
if (entry.startsWith("http://") || entry.startsWith("https://")) return entry;
|
|
48
|
+
return new URL(`/dist/${entry.replace(/^\/+/, "")}`, window.location.origin).href;
|
|
49
|
+
}
|
|
50
|
+
function identity(attributes) {
|
|
51
|
+
const key = [
|
|
52
|
+
"name",
|
|
53
|
+
"property",
|
|
54
|
+
"http-equiv",
|
|
55
|
+
"charset",
|
|
56
|
+
"rel",
|
|
57
|
+
"href"
|
|
58
|
+
].find((candidate) => typeof attributes[candidate] === "string" && String(attributes[candidate]).trim());
|
|
59
|
+
if (!key) return void 0;
|
|
60
|
+
return `${key}:${String(attributes[key]).trim().toLowerCase()}`;
|
|
61
|
+
}
|
|
62
|
+
function markInitialHead(head) {
|
|
63
|
+
if (typeof document === "undefined") return;
|
|
64
|
+
document.head.querySelector("meta[name=\"description\"]")?.setAttribute(MANAGED_HEAD_ATTRIBUTE, "true");
|
|
65
|
+
for (const attributes of head?.meta ?? []) {
|
|
66
|
+
const target = identity(attributes);
|
|
67
|
+
if (!target) continue;
|
|
68
|
+
for (const element of document.head.querySelectorAll("meta")) if (identity(Object.fromEntries([...element.attributes].map((item) => [item.name, item.value]))) === target) element.setAttribute(MANAGED_HEAD_ATTRIBUTE, "true");
|
|
69
|
+
}
|
|
70
|
+
for (const attributes of head?.link ?? []) {
|
|
71
|
+
const target = identity(attributes);
|
|
72
|
+
if (!target) continue;
|
|
73
|
+
for (const element of document.head.querySelectorAll("link")) if (identity(Object.fromEntries([...element.attributes].map((item) => [item.name, item.value]))) === target) element.setAttribute(MANAGED_HEAD_ATTRIBUTE, "true");
|
|
74
|
+
}
|
|
75
|
+
if (head?.jsonLd?.length) {
|
|
76
|
+
const scripts = [...document.head.querySelectorAll(`script[type="application/ld+json"]`)];
|
|
77
|
+
for (const value of head.jsonLd) {
|
|
78
|
+
const serialized = serializeForHtmlScript(value);
|
|
79
|
+
scripts.find((script) => script.textContent === serialized)?.setAttribute(MANAGED_HEAD_ATTRIBUTE, "true");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function setHeadAttributes(element, attributes) {
|
|
84
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
85
|
+
if (!/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(name) || /^on/i.test(name)) continue;
|
|
86
|
+
if (value === null || value === void 0 || value === false) continue;
|
|
87
|
+
element.setAttribute(name, String(value));
|
|
88
|
+
}
|
|
89
|
+
element.setAttribute(MANAGED_HEAD_ATTRIBUTE, "true");
|
|
90
|
+
}
|
|
91
|
+
function updateDocumentHead(data) {
|
|
92
|
+
if (typeof document === "undefined") return;
|
|
93
|
+
const nonce = document.head.querySelector("script[nonce]")?.nonce;
|
|
94
|
+
document.title = data.title;
|
|
95
|
+
document.head.querySelectorAll(`[${MANAGED_HEAD_ATTRIBUTE}]`).forEach((element) => element.remove());
|
|
96
|
+
if (data.description) {
|
|
97
|
+
const description = document.createElement("meta");
|
|
98
|
+
setHeadAttributes(description, {
|
|
99
|
+
name: "description",
|
|
100
|
+
content: data.description
|
|
101
|
+
});
|
|
102
|
+
document.head.append(description);
|
|
103
|
+
}
|
|
104
|
+
for (const attributes of data.head?.meta ?? []) {
|
|
105
|
+
const meta = document.createElement("meta");
|
|
106
|
+
setHeadAttributes(meta, attributes);
|
|
107
|
+
document.head.append(meta);
|
|
108
|
+
}
|
|
109
|
+
for (const attributes of data.head?.link ?? []) {
|
|
110
|
+
const link = document.createElement("link");
|
|
111
|
+
setHeadAttributes(link, attributes);
|
|
112
|
+
document.head.append(link);
|
|
113
|
+
}
|
|
114
|
+
for (const value of data.head?.jsonLd ?? []) {
|
|
115
|
+
const script = document.createElement("script");
|
|
116
|
+
script.type = "application/ld+json";
|
|
117
|
+
if (nonce) script.nonce = nonce;
|
|
118
|
+
script.textContent = serializeForHtmlScript(value);
|
|
119
|
+
script.setAttribute(MANAGED_HEAD_ATTRIBUTE, "true");
|
|
120
|
+
document.head.append(script);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function queryFromUrl(url) {
|
|
124
|
+
const query = {};
|
|
125
|
+
for (const key of new Set(url.searchParams.keys())) {
|
|
126
|
+
const values = url.searchParams.getAll(key);
|
|
127
|
+
query[key] = values.length === 1 ? values[0] : values;
|
|
128
|
+
}
|
|
129
|
+
return query;
|
|
130
|
+
}
|
|
131
|
+
function createPageElement(component, layout, data, url) {
|
|
132
|
+
const page = React.createElement(component, data.props);
|
|
133
|
+
if (!layout) return page;
|
|
134
|
+
return React.createElement(layout, {
|
|
135
|
+
children: page,
|
|
136
|
+
page: data.page,
|
|
137
|
+
path: url.pathname,
|
|
138
|
+
query: queryFromUrl(url)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
var SSRClientRouter = class {
|
|
142
|
+
currentComponent;
|
|
143
|
+
currentLayout;
|
|
144
|
+
currentBuildKey;
|
|
145
|
+
currentPage;
|
|
146
|
+
components = /* @__PURE__ */ new Map();
|
|
147
|
+
pending;
|
|
148
|
+
basePath;
|
|
149
|
+
fetcher;
|
|
150
|
+
onPopState = () => {
|
|
151
|
+
this.navigate(window.location.href, {
|
|
152
|
+
replace: true,
|
|
153
|
+
scroll: true,
|
|
154
|
+
fromHistory: true
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
constructor(root, component, data, initialLayout, options = {}, renderRoute) {
|
|
158
|
+
this.root = root;
|
|
159
|
+
this.renderRoute = renderRoute;
|
|
160
|
+
this.currentComponent = component;
|
|
161
|
+
this.components.set(data.page, component);
|
|
162
|
+
this.currentLayout = initialLayout ?? options.layout;
|
|
163
|
+
this.currentBuildKey = data.buildKey;
|
|
164
|
+
this.currentPage = data.page;
|
|
165
|
+
this.basePath = normalizePath(options.ssrPageBasePath ?? inferSSRPageBasePath());
|
|
166
|
+
this.fetcher = options.fetcher ?? globalThis.fetch.bind(globalThis);
|
|
167
|
+
this.onNavigationError = options.onNavigationError;
|
|
168
|
+
}
|
|
169
|
+
onNavigationError;
|
|
170
|
+
activate() {
|
|
171
|
+
window.addEventListener("popstate", this.onPopState);
|
|
172
|
+
markInitialHead(void 0);
|
|
173
|
+
}
|
|
174
|
+
canHandle(url) {
|
|
175
|
+
return url.origin === window.location.origin && !!getPageFromUrl(url, this.basePath);
|
|
176
|
+
}
|
|
177
|
+
consumeNavigation(request, component, layout) {
|
|
178
|
+
if (request.router !== this || this.pending !== request) return false;
|
|
179
|
+
this.pending = void 0;
|
|
180
|
+
window[NAVIGATION_STATE_KEY] = void 0;
|
|
181
|
+
this.currentComponent = component;
|
|
182
|
+
this.components.set(request.data.page, component);
|
|
183
|
+
if (!this.currentLayout && layout) this.currentLayout = layout;
|
|
184
|
+
this.currentPage = request.data.page;
|
|
185
|
+
this.currentBuildKey = request.data.buildKey;
|
|
186
|
+
const state = {
|
|
187
|
+
component,
|
|
188
|
+
layout: this.currentLayout,
|
|
189
|
+
data: request.data,
|
|
190
|
+
url: request.url
|
|
191
|
+
};
|
|
192
|
+
resetClientStreamData();
|
|
193
|
+
resetStreamingRenderCache();
|
|
194
|
+
if (this.renderRoute) this.renderRoute(state);
|
|
195
|
+
else this.root.render(createPageElement(component, this.currentLayout, request.data, request.url));
|
|
196
|
+
this.finishNavigation(request.url, request.data, request.replace, request.scroll, request.fromHistory);
|
|
197
|
+
request.resolve();
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
async navigate(input, options = {}) {
|
|
201
|
+
const target = new URL(input.toString(), window.location.href);
|
|
202
|
+
if (!this.canHandle(target)) {
|
|
203
|
+
this.fullNavigation(target.href, options.replace);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
let data;
|
|
207
|
+
try {
|
|
208
|
+
const response = await this.fetcher(target.href, {
|
|
209
|
+
credentials: "same-origin",
|
|
210
|
+
headers: {
|
|
211
|
+
accept: "application/json",
|
|
212
|
+
[NAVIGATION_HEADER]: "1"
|
|
213
|
+
},
|
|
214
|
+
redirect: "manual"
|
|
215
|
+
});
|
|
216
|
+
if (response.status >= 300 && response.status < 400) {
|
|
217
|
+
const location = response.headers.get("location");
|
|
218
|
+
this.fullNavigation(location ? new URL(location, target).href : target.href, options.replace);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
data = parseNavigationResponse(await response.json()) ?? (() => {
|
|
222
|
+
throw new Error("SSR data response has an invalid shape");
|
|
223
|
+
})();
|
|
224
|
+
} catch (error) {
|
|
225
|
+
this.onNavigationError?.(error);
|
|
226
|
+
this.fullNavigation(target.href, options.replace);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (isRedirectResponse(data)) {
|
|
230
|
+
this.fullNavigation(new URL(data.location, target).href, options.replace);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (this.currentBuildKey !== data.buildKey && (this.currentBuildKey !== null || data.buildKey !== null)) {
|
|
234
|
+
this.fullNavigation(target.href, options.replace);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!data.entry) {
|
|
238
|
+
this.fullNavigation(target.href, options.replace);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const entryUrl = resolveEntryUrl(data.entry);
|
|
242
|
+
if (!options.fromHistory) window.history.replaceState({
|
|
243
|
+
...window.history.state ?? {},
|
|
244
|
+
ssrScroll: [window.scrollX, window.scrollY]
|
|
245
|
+
}, "", window.location.href);
|
|
246
|
+
await new Promise((resolve, reject) => {
|
|
247
|
+
const request = {
|
|
248
|
+
page: data.page,
|
|
249
|
+
url: target,
|
|
250
|
+
data,
|
|
251
|
+
router: this,
|
|
252
|
+
replace: options.replace,
|
|
253
|
+
scroll: options.scroll,
|
|
254
|
+
fromHistory: options.fromHistory,
|
|
255
|
+
resolve,
|
|
256
|
+
reject
|
|
257
|
+
};
|
|
258
|
+
this.pending = request;
|
|
259
|
+
window[NAVIGATION_STATE_KEY] = request;
|
|
260
|
+
import(
|
|
261
|
+
/* @vite-ignore */
|
|
262
|
+
entryUrl
|
|
263
|
+
).then((module) => {
|
|
264
|
+
if (this.pending !== request) return;
|
|
265
|
+
const component = typeof module.default === "function" ? module.default : this.components.get(data.page);
|
|
266
|
+
if (!component || !this.consumeNavigation(request, component)) reject(/* @__PURE__ */ new Error(`SSR entry did not register page "${data.page}"`));
|
|
267
|
+
}).catch((error) => {
|
|
268
|
+
if (this.pending === request) {
|
|
269
|
+
this.pending = void 0;
|
|
270
|
+
window[NAVIGATION_STATE_KEY] = void 0;
|
|
271
|
+
reject(error);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}).catch((error) => {
|
|
275
|
+
this.onNavigationError?.(error);
|
|
276
|
+
this.fullNavigation(target.href, options.replace);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
finishNavigation = (url, data, replace = false, scroll = true, fromHistory = false) => {
|
|
280
|
+
const restore = fromHistory && Array.isArray(window.history.state?.ssrScroll) ? window.history.state.ssrScroll : void 0;
|
|
281
|
+
const nextState = {
|
|
282
|
+
...window.history.state ?? {},
|
|
283
|
+
ssrPage: data.page,
|
|
284
|
+
ssrScroll: [0, 0]
|
|
285
|
+
};
|
|
286
|
+
if (replace) window.history.replaceState(nextState, "", url.href);
|
|
287
|
+
else window.history.pushState(nextState, "", url.href);
|
|
288
|
+
updateDocumentHead(data);
|
|
289
|
+
if (!scroll) return;
|
|
290
|
+
const applyScroll = () => {
|
|
291
|
+
if (url.hash) document.getElementById(url.hash.slice(1))?.scrollIntoView();
|
|
292
|
+
else if (restore && typeof window.scrollTo === "function") window.scrollTo(restore[0], restore[1]);
|
|
293
|
+
else if (typeof window.scrollTo === "function") window.scrollTo(0, 0);
|
|
294
|
+
};
|
|
295
|
+
if (typeof window.requestAnimationFrame === "function") window.requestAnimationFrame(applyScroll);
|
|
296
|
+
else queueMicrotask(applyScroll);
|
|
297
|
+
};
|
|
298
|
+
fullNavigation = (url, replace = false) => {
|
|
299
|
+
if (replace) window.location.replace(url);
|
|
300
|
+
else window.location.assign(url);
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
function createSSRRouter(root, component, data, layout, options, renderRoute) {
|
|
304
|
+
const router = new SSRClientRouter(root, component, data, layout, options, renderRoute);
|
|
305
|
+
router.activate();
|
|
306
|
+
return router;
|
|
307
|
+
}
|
|
308
|
+
var activeRouter;
|
|
309
|
+
function setActiveSSRRouter(router) {
|
|
310
|
+
activeRouter = router;
|
|
311
|
+
}
|
|
312
|
+
function getActiveSSRRouter() {
|
|
313
|
+
return activeRouter;
|
|
314
|
+
}
|
|
315
|
+
async function navigate(url, options) {
|
|
316
|
+
if (activeRouter) {
|
|
317
|
+
await activeRouter.navigate(url, options);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (typeof window !== "undefined") window.location.assign(new URL(url.toString(), window.location.href).href);
|
|
321
|
+
}
|
|
322
|
+
function Link({ replace, scroll, onClick, target, ...props }) {
|
|
323
|
+
const handleClick = (event) => {
|
|
324
|
+
onClick?.(event);
|
|
325
|
+
if (event.defaultPrevented || event.button !== 0 || target || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || !props.href) return;
|
|
326
|
+
const url = new URL(props.href, window.location.href);
|
|
327
|
+
const router = getActiveSSRRouter();
|
|
328
|
+
if (!(router ? router.canHandle(url) : url.origin === window.location.origin && !!getPageFromUrl(url, inferSSRPageBasePath()))) return;
|
|
329
|
+
event.preventDefault();
|
|
330
|
+
navigate(url, {
|
|
331
|
+
replace,
|
|
332
|
+
scroll
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
return React.createElement("a", {
|
|
336
|
+
...props,
|
|
337
|
+
target,
|
|
338
|
+
onClick: handleClick
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
function consumePendingSSRNavigation(component, layout) {
|
|
342
|
+
const pending = getWindow()?.[NAVIGATION_STATE_KEY];
|
|
343
|
+
return !!pending && !!activeRouter?.consumeNavigation(pending, component, layout);
|
|
344
|
+
}
|
|
345
|
+
function markSSRInitialHead(head) {
|
|
346
|
+
markInitialHead(head);
|
|
347
|
+
}
|
|
348
|
+
//#endregion
|
|
349
|
+
export { Link, SSRClientRouter, consumePendingSSRNavigation, createPageElement, createSSRRouter, getActiveSSRRouter, markSSRInitialHead, navigate, setActiveSSRRouter };
|
package/fe/ssr/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { SSRPageDataPage, SSRPageDataRedirect, SSRPageDataResponse, SSRPageDataStatus, SSRPageHead, SSRPageHeadAttributes, SSRPageHeadResolver, SSRPageHeadValue, SSRLayout, SSRLayoutProps, SSRPageMetaContext, SSRPageMetaResolver, SSRPageMetaValue, SSRPageResult, SSRPropsContext, SSRRedirectResult, SSRResolvedProps, SSRStatusResult, } from "@_tc/template-core";
|
|
@@ -8,6 +8,15 @@ export interface SSRPageMeta {
|
|
|
8
8
|
description?: string;
|
|
9
9
|
renderedAt: number;
|
|
10
10
|
pathname: string;
|
|
11
|
+
page?: string;
|
|
12
|
+
buildKey?: string | null;
|
|
13
|
+
entry?: string | null;
|
|
14
|
+
head?: SSRHydrationHead;
|
|
15
|
+
}
|
|
16
|
+
export interface SSRHydrationHead {
|
|
17
|
+
meta?: Record<string, string | number | boolean | null | undefined>[];
|
|
18
|
+
link?: Record<string, string | number | boolean | null | undefined>[];
|
|
19
|
+
jsonLd?: unknown[];
|
|
11
20
|
}
|
|
12
21
|
export declare const SSR_DATA_KEY = "__SSR_DATA__";
|
|
13
22
|
declare global {
|
|
@@ -11,6 +11,11 @@ export declare const defaultLanguageResources: {
|
|
|
11
11
|
readonly breadcrumb: {
|
|
12
12
|
readonly close: "关闭";
|
|
13
13
|
};
|
|
14
|
+
readonly pagination: {
|
|
15
|
+
readonly previousPage: "上一页";
|
|
16
|
+
readonly nextPage: "下一页";
|
|
17
|
+
readonly pageSize: "每页条数";
|
|
18
|
+
};
|
|
14
19
|
readonly confirmDialog: {
|
|
15
20
|
readonly title: "提示";
|
|
16
21
|
readonly okText: "确认";
|
|
@@ -18,6 +23,8 @@ export declare const defaultLanguageResources: {
|
|
|
18
23
|
};
|
|
19
24
|
readonly dataTable: {
|
|
20
25
|
readonly noData: "暂无数据";
|
|
26
|
+
readonly selectAll: "全选行";
|
|
27
|
+
readonly selectRow: "选择行";
|
|
21
28
|
};
|
|
22
29
|
readonly date: {
|
|
23
30
|
readonly placeholder: "请选择日期";
|
|
@@ -62,6 +69,12 @@ export declare const defaultLanguageResources: {
|
|
|
62
69
|
readonly okText: "确认";
|
|
63
70
|
readonly cancelText: "取消";
|
|
64
71
|
};
|
|
72
|
+
readonly multiSelect: {
|
|
73
|
+
readonly removeOption: "移除{label}";
|
|
74
|
+
readonly clear: "清除选择";
|
|
75
|
+
readonly search: "搜索";
|
|
76
|
+
readonly searchOptions: "搜索选项";
|
|
77
|
+
};
|
|
65
78
|
readonly message: {
|
|
66
79
|
readonly close: "关闭";
|
|
67
80
|
};
|
|
@@ -11,6 +11,11 @@ export declare const defaultEnglishResources: {
|
|
|
11
11
|
readonly breadcrumb: {
|
|
12
12
|
readonly close: "Close";
|
|
13
13
|
};
|
|
14
|
+
readonly pagination: {
|
|
15
|
+
readonly previousPage: "Previous page";
|
|
16
|
+
readonly nextPage: "Next page";
|
|
17
|
+
readonly pageSize: "Items per page";
|
|
18
|
+
};
|
|
14
19
|
readonly confirmDialog: {
|
|
15
20
|
readonly title: "Prompt";
|
|
16
21
|
readonly okText: "Confirm";
|
|
@@ -18,6 +23,8 @@ export declare const defaultEnglishResources: {
|
|
|
18
23
|
};
|
|
19
24
|
readonly dataTable: {
|
|
20
25
|
readonly noData: "No Data";
|
|
26
|
+
readonly selectAll: "Select all rows";
|
|
27
|
+
readonly selectRow: "Select row";
|
|
21
28
|
};
|
|
22
29
|
readonly date: {
|
|
23
30
|
readonly placeholder: "Select date";
|
|
@@ -62,6 +69,12 @@ export declare const defaultEnglishResources: {
|
|
|
62
69
|
readonly okText: "Confirm";
|
|
63
70
|
readonly cancelText: "Cancel";
|
|
64
71
|
};
|
|
72
|
+
readonly multiSelect: {
|
|
73
|
+
readonly removeOption: "Remove {label}";
|
|
74
|
+
readonly clear: "Clear selection";
|
|
75
|
+
readonly search: "Search";
|
|
76
|
+
readonly searchOptions: "Search options";
|
|
77
|
+
};
|
|
65
78
|
readonly message: {
|
|
66
79
|
readonly close: "Close";
|
|
67
80
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import { type CheckboxProps } from "../../../../../fe/packages/react/core/Checkbox/index";
|
|
2
3
|
import type { DropdownItem } from "../../../../../fe/packages/react/overlays/Dropdown/index";
|
|
3
4
|
import { type PaginationProps } from "../Pagination";
|
|
4
5
|
import { type TableFixed } from "../../../../../fe/packages/react/forms/table/index";
|
|
@@ -16,6 +17,7 @@ type RowSelection<T> = {
|
|
|
16
17
|
onChange?: (selectedRowKeys: Array<string | number>, selectedRows: T[], isAll: boolean) => void;
|
|
17
18
|
isAll?: boolean;
|
|
18
19
|
beforeCheckboxNode?: ReactNode;
|
|
20
|
+
getCheckboxProps?: (record: T) => Pick<CheckboxProps, 'disabled' | 'aria-label' | 'aria-labelledby'>;
|
|
19
21
|
};
|
|
20
22
|
interface DataTableProps<T = Record<string, unknown>> {
|
|
21
23
|
columns: TableColumnDef<T>[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { SelectOption } from "../Select";
|
|
3
|
+
export type MultiSelectOption = SelectOption;
|
|
4
|
+
export interface MultiSelectOptionGroup {
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
options: MultiSelectOption[];
|
|
7
|
+
}
|
|
8
|
+
export type MultiSelectOptions = Array<MultiSelectOption | MultiSelectOptionGroup>;
|
|
9
|
+
export interface MultiSelectProps {
|
|
10
|
+
options: MultiSelectOptions;
|
|
11
|
+
value?: Array<string | number>;
|
|
12
|
+
defaultValue?: Array<string | number>;
|
|
13
|
+
onChange?: (value: Array<string | number>) => void;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
searchable?: boolean;
|
|
18
|
+
onSearch?: (value: string) => void;
|
|
19
|
+
maxTagCount?: number | 'responsive';
|
|
20
|
+
clearable?: boolean;
|
|
21
|
+
getPopupContainer?: 'parent' | (() => HTMLElement);
|
|
22
|
+
id?: string;
|
|
23
|
+
'aria-label'?: string;
|
|
24
|
+
'aria-labelledby'?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function MultiSelect({ options, value: controlledValue, defaultValue, onChange, placeholder, className, disabled, searchable, onSearch, maxTagCount, clearable, getPopupContainer, id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./MultiSelect";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
export interface PaginationProps {
|
|
2
3
|
current: number;
|
|
3
4
|
pageSize: number;
|
|
@@ -6,5 +7,9 @@ export interface PaginationProps {
|
|
|
6
7
|
onPageSizeChange?: (pageSize: number) => void;
|
|
7
8
|
pageSizeOptions?: number[];
|
|
8
9
|
className?: string;
|
|
10
|
+
showTotal?: (total: number, range: [number, number]) => ReactNode;
|
|
11
|
+
previousPageLabel?: string;
|
|
12
|
+
nextPageLabel?: string;
|
|
13
|
+
pageSizeLabel?: string;
|
|
9
14
|
}
|
|
10
|
-
export declare function Pagination({ current, pageSize, total, onChange, onPageSizeChange, pageSizeOptions, className, }: PaginationProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export declare function Pagination({ current, pageSize, total, onChange, onPageSizeChange, pageSizeOptions, className, showTotal, previousPageLabel, nextPageLabel, pageSizeLabel, }: PaginationProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -2,8 +2,12 @@ import React from "react";
|
|
|
2
2
|
export type SelectOption = {
|
|
3
3
|
label: React.ReactNode;
|
|
4
4
|
value: string | number;
|
|
5
|
+
disabled?: boolean;
|
|
5
6
|
searchText?: string;
|
|
6
7
|
};
|
|
8
|
+
export type SelectOptionRenderInfo = {
|
|
9
|
+
index: number;
|
|
10
|
+
};
|
|
7
11
|
export type SelectProps = {
|
|
8
12
|
options: SelectOption[];
|
|
9
13
|
value?: string | number;
|
|
@@ -15,6 +19,13 @@ export type SelectProps = {
|
|
|
15
19
|
disabled?: boolean;
|
|
16
20
|
clearable?: boolean;
|
|
17
21
|
searchable?: boolean;
|
|
22
|
+
onSearch?: (value: string) => void;
|
|
23
|
+
notFoundContent?: React.ReactNode;
|
|
24
|
+
optionRender?: (option: SelectOption, info: SelectOptionRenderInfo) => React.ReactNode;
|
|
25
|
+
onPopupScroll?: React.UIEventHandler<HTMLDivElement>;
|
|
26
|
+
id?: string;
|
|
27
|
+
'aria-label'?: string;
|
|
28
|
+
'aria-labelledby'?: string;
|
|
18
29
|
getPopupContainer?: 'parent' | (() => HTMLElement);
|
|
19
30
|
};
|
|
20
31
|
declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLDivElement>>;
|