@_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,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,218 @@
|
|
|
1
|
+
import { useI18n } from "../../i18n/useI18n.js";
|
|
2
|
+
import "../../i18n/index.js";
|
|
3
|
+
import { cn } from "../../core/lib/utils.js";
|
|
4
|
+
import { Input } from "../Input/Input.js";
|
|
5
|
+
import "../Input/index.js";
|
|
6
|
+
import { Popup } from "../../overlays/Popup/Popup.js";
|
|
7
|
+
import "../../overlays/Popup/index.js";
|
|
8
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { X } from "lucide-react";
|
|
11
|
+
//#region packages/react/forms/MultiSelect/MultiSelect.tsx
|
|
12
|
+
var isGroup = (option) => "options" in option;
|
|
13
|
+
function MultiSelect({ options, value: controlledValue, defaultValue = [], onChange, placeholder, className, disabled, searchable = true, onSearch, maxTagCount, clearable = true, getPopupContainer, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }) {
|
|
14
|
+
const t = useI18n();
|
|
15
|
+
const rootRef = useRef(null);
|
|
16
|
+
const anchorRef = useRef(null);
|
|
17
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
18
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
19
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
20
|
+
const [responsiveTagCount, setResponsiveTagCount] = useState();
|
|
21
|
+
const tagMeasureRef = useRef(null);
|
|
22
|
+
const listboxId = `${useId()}-listbox`;
|
|
23
|
+
const selectedValues = controlledValue ?? internalValue;
|
|
24
|
+
const selectedValueSet = new Set(selectedValues);
|
|
25
|
+
const flattenedOptions = useMemo(() => options.flatMap((option) => isGroup(option) ? option.options : [option]), [options]);
|
|
26
|
+
const filteredGroups = useMemo(() => {
|
|
27
|
+
if (onSearch || !searchTerm.trim()) return options;
|
|
28
|
+
const term = searchTerm.trim().toLowerCase();
|
|
29
|
+
return options.map((option) => {
|
|
30
|
+
if (isGroup(option)) return {
|
|
31
|
+
...option,
|
|
32
|
+
options: option.options.filter((item) => String(item.searchText ?? item.label ?? "").toLowerCase().includes(term))
|
|
33
|
+
};
|
|
34
|
+
return String(option.searchText ?? option.label ?? "").toLowerCase().includes(term) ? option : null;
|
|
35
|
+
}).filter((option) => option !== null && (isGroup(option) ? option.options.length > 0 : true));
|
|
36
|
+
}, [
|
|
37
|
+
onSearch,
|
|
38
|
+
options,
|
|
39
|
+
searchTerm
|
|
40
|
+
]);
|
|
41
|
+
const selectedOptions = selectedValues.map((value) => flattenedOptions.find((option) => option.value === value)).filter((option) => option !== void 0);
|
|
42
|
+
const measureResponsiveTags = useCallback(() => {
|
|
43
|
+
if (maxTagCount !== "responsive") return;
|
|
44
|
+
const availableWidth = rootRef.current?.getBoundingClientRect().width ?? 0;
|
|
45
|
+
const tagWidths = Array.from(tagMeasureRef.current?.querySelectorAll("[data-multi-select-measure]") ?? []).map((element) => element.getBoundingClientRect().width);
|
|
46
|
+
const clearButtonWidth = clearable && selectedOptions.length > 0 && !disabled ? 28 : 0;
|
|
47
|
+
const gap = 4;
|
|
48
|
+
let usedWidth = clearButtonWidth;
|
|
49
|
+
let visibleCount = 0;
|
|
50
|
+
for (let index = 0; index < tagWidths.length; index += 1) {
|
|
51
|
+
const tagWidth = tagWidths[index] ?? 0;
|
|
52
|
+
const nextWidth = usedWidth + tagWidth + (visibleCount > 0 ? gap : 0);
|
|
53
|
+
if (nextWidth + (tagWidths.length - index - 1 > 0 ? 36 : 0) > availableWidth && visibleCount > 0) break;
|
|
54
|
+
usedWidth = nextWidth;
|
|
55
|
+
visibleCount += 1;
|
|
56
|
+
}
|
|
57
|
+
setResponsiveTagCount(visibleCount);
|
|
58
|
+
}, [
|
|
59
|
+
clearable,
|
|
60
|
+
disabled,
|
|
61
|
+
maxTagCount,
|
|
62
|
+
selectedOptions.length
|
|
63
|
+
]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (maxTagCount !== "responsive" || typeof ResizeObserver === "undefined") return;
|
|
66
|
+
const element = rootRef.current;
|
|
67
|
+
if (!element) return;
|
|
68
|
+
const update = () => measureResponsiveTags();
|
|
69
|
+
update();
|
|
70
|
+
const observer = new ResizeObserver(update);
|
|
71
|
+
observer.observe(element);
|
|
72
|
+
return () => observer.disconnect();
|
|
73
|
+
}, [maxTagCount, measureResponsiveTags]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
measureResponsiveTags();
|
|
76
|
+
}, [measureResponsiveTags, selectedOptions]);
|
|
77
|
+
const visibleTagCount = maxTagCount === "responsive" ? responsiveTagCount : maxTagCount;
|
|
78
|
+
const visibleOptions = visibleTagCount === void 0 ? selectedOptions : selectedOptions.slice(0, visibleTagCount);
|
|
79
|
+
const hiddenTagCount = selectedOptions.length - visibleOptions.length;
|
|
80
|
+
const popupContainer = isOpen && getPopupContainer === "parent" ? rootRef.current?.parentElement ?? void 0 : isOpen && typeof document !== "undefined" && typeof getPopupContainer === "function" ? getPopupContainer() : void 0;
|
|
81
|
+
const updateValue = (nextValue) => {
|
|
82
|
+
if (controlledValue === void 0) setInternalValue(nextValue);
|
|
83
|
+
onChange?.(nextValue);
|
|
84
|
+
};
|
|
85
|
+
const toggleOption = (option) => {
|
|
86
|
+
updateValue(selectedValueSet.has(option.value) ? selectedValues.filter((value) => value !== option.value) : [...selectedValues, option.value]);
|
|
87
|
+
};
|
|
88
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
89
|
+
ref: rootRef,
|
|
90
|
+
className: cn("tc-ui-multi-select relative w-full", className),
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ jsxs("div", {
|
|
93
|
+
ref: anchorRef,
|
|
94
|
+
id,
|
|
95
|
+
role: "combobox",
|
|
96
|
+
"aria-label": ariaLabel,
|
|
97
|
+
"aria-labelledby": ariaLabelledBy,
|
|
98
|
+
"aria-expanded": isOpen,
|
|
99
|
+
"aria-controls": listboxId,
|
|
100
|
+
"aria-haspopup": "listbox",
|
|
101
|
+
"aria-disabled": disabled || void 0,
|
|
102
|
+
tabIndex: disabled ? -1 : 0,
|
|
103
|
+
onClick: () => !disabled && setIsOpen(true),
|
|
104
|
+
onKeyDown: (event) => {
|
|
105
|
+
if (disabled) return;
|
|
106
|
+
if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown") {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
setIsOpen(true);
|
|
109
|
+
} else if (event.key === "Escape") {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
setIsOpen(false);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
className: cn("flex min-h-10 w-full flex-wrap items-center gap-1 rounded-lg border bg-background", "px-2 py-1 text-sm", disabled ? "cursor-not-allowed bg-muted" : "cursor-pointer", isOpen ? "border-theme ring-2 ring-theme/25" : "border-border"),
|
|
115
|
+
children: [
|
|
116
|
+
visibleOptions.length > 0 ? visibleOptions.map((option) => /* @__PURE__ */ jsxs("span", {
|
|
117
|
+
className: "inline-flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-xs",
|
|
118
|
+
children: [option.label, /* @__PURE__ */ jsx("button", {
|
|
119
|
+
type: "button",
|
|
120
|
+
disabled,
|
|
121
|
+
"aria-label": t("components.multiSelect.removeOption", { label: typeof option.label === "string" ? option.label : String(option.value) }),
|
|
122
|
+
className: cn("text-muted-foreground hover:text-foreground", "disabled:cursor-not-allowed disabled:opacity-60"),
|
|
123
|
+
onClick: (event) => {
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
if (!disabled) toggleOption(option);
|
|
126
|
+
},
|
|
127
|
+
children: /* @__PURE__ */ jsx(X, { size: 12 })
|
|
128
|
+
})]
|
|
129
|
+
}, option.value)) : /* @__PURE__ */ jsx("span", {
|
|
130
|
+
className: "min-h-5 flex-1 px-1 text-left text-muted-foreground",
|
|
131
|
+
children: placeholder ?? t("components.select.empty")
|
|
132
|
+
}),
|
|
133
|
+
hiddenTagCount > 0 && /* @__PURE__ */ jsxs("span", {
|
|
134
|
+
className: "px-1 text-xs text-muted-foreground",
|
|
135
|
+
children: ["+", hiddenTagCount]
|
|
136
|
+
}),
|
|
137
|
+
clearable && selectedOptions.length > 0 && !disabled && /* @__PURE__ */ jsx("button", {
|
|
138
|
+
type: "button",
|
|
139
|
+
"aria-label": t("components.multiSelect.clear"),
|
|
140
|
+
className: "ml-auto p-1 text-muted-foreground hover:text-foreground",
|
|
141
|
+
onClick: (event) => {
|
|
142
|
+
event.stopPropagation();
|
|
143
|
+
updateValue([]);
|
|
144
|
+
},
|
|
145
|
+
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ jsxs(Popup, {
|
|
150
|
+
open: isOpen,
|
|
151
|
+
anchorRef,
|
|
152
|
+
onOpenChange: setIsOpen,
|
|
153
|
+
container: popupContainer,
|
|
154
|
+
matchAnchorWidth: true,
|
|
155
|
+
className: "max-h-60 overflow-auto p-1",
|
|
156
|
+
children: [searchable && /* @__PURE__ */ jsx(Input, {
|
|
157
|
+
autoFocus: true,
|
|
158
|
+
value: searchTerm,
|
|
159
|
+
onChange: (nextValue) => {
|
|
160
|
+
setSearchTerm(nextValue);
|
|
161
|
+
onSearch?.(nextValue);
|
|
162
|
+
},
|
|
163
|
+
onClick: (event) => event.stopPropagation(),
|
|
164
|
+
placeholder: t("components.multiSelect.search"),
|
|
165
|
+
className: "mb-1",
|
|
166
|
+
inputClassName: "h-8",
|
|
167
|
+
"aria-label": t("components.multiSelect.searchOptions")
|
|
168
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
169
|
+
id: listboxId,
|
|
170
|
+
role: "listbox",
|
|
171
|
+
"aria-multiselectable": "true",
|
|
172
|
+
children: [filteredGroups.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
173
|
+
className: "px-3 py-2 text-center text-sm text-muted-foreground",
|
|
174
|
+
children: t("components.select.empty")
|
|
175
|
+
}), filteredGroups.map((entry, index) => {
|
|
176
|
+
if (!isGroup(entry)) return /* @__PURE__ */ jsx(OptionRow, {
|
|
177
|
+
option: entry,
|
|
178
|
+
selected: selectedValueSet.has(entry.value),
|
|
179
|
+
onToggle: toggleOption
|
|
180
|
+
}, entry.value);
|
|
181
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
182
|
+
className: "px-3 py-1 text-xs font-medium text-muted-foreground",
|
|
183
|
+
children: entry.label
|
|
184
|
+
}), entry.options.map((option) => /* @__PURE__ */ jsx(OptionRow, {
|
|
185
|
+
option,
|
|
186
|
+
selected: selectedValueSet.has(option.value),
|
|
187
|
+
onToggle: toggleOption
|
|
188
|
+
}, option.value))] }, `group-${index}`);
|
|
189
|
+
})]
|
|
190
|
+
})]
|
|
191
|
+
}),
|
|
192
|
+
maxTagCount === "responsive" && /* @__PURE__ */ jsx("div", {
|
|
193
|
+
ref: tagMeasureRef,
|
|
194
|
+
"aria-hidden": "true",
|
|
195
|
+
className: "pointer-events-none absolute -z-10 whitespace-nowrap opacity-0",
|
|
196
|
+
children: selectedOptions.map((option) => /* @__PURE__ */ jsxs("span", {
|
|
197
|
+
"data-multi-select-measure": true,
|
|
198
|
+
className: "mr-1 inline-flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-xs",
|
|
199
|
+
children: [option.label, /* @__PURE__ */ jsx(X, { size: 12 })]
|
|
200
|
+
}, option.value))
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function OptionRow({ option, selected, onToggle }) {
|
|
206
|
+
return /* @__PURE__ */ jsx("div", {
|
|
207
|
+
role: "option",
|
|
208
|
+
"aria-selected": selected,
|
|
209
|
+
"aria-disabled": option.disabled || void 0,
|
|
210
|
+
onClick: () => {
|
|
211
|
+
if (!option.disabled) onToggle(option);
|
|
212
|
+
},
|
|
213
|
+
className: cn("rounded-md px-3 py-2 text-sm", option.disabled ? "cursor-not-allowed text-muted-foreground/60" : "cursor-pointer hover:bg-foreground/8", selected && !option.disabled && "bg-theme/12"),
|
|
214
|
+
children: option.label
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
218
|
+
export { MultiSelect };
|
|
@@ -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;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useI18n } from "../../i18n/useI18n.js";
|
|
2
|
+
import "../../i18n/index.js";
|
|
1
3
|
import { cn } from "../../core/lib/utils.js";
|
|
2
4
|
import { Button } from "../../core/Button/Button.js";
|
|
3
5
|
import "../../core/Button/index.js";
|
|
@@ -11,7 +13,11 @@ function Pagination({ current, pageSize, total, onChange, onPageSizeChange, page
|
|
|
11
13
|
20,
|
|
12
14
|
50,
|
|
13
15
|
100
|
|
14
|
-
], className }) {
|
|
16
|
+
], className, showTotal, previousPageLabel, nextPageLabel, pageSizeLabel }) {
|
|
17
|
+
const t = useI18n();
|
|
18
|
+
const resolvedPreviousPageLabel = previousPageLabel ?? t("components.pagination.previousPage");
|
|
19
|
+
const resolvedNextPageLabel = nextPageLabel ?? t("components.pagination.nextPage");
|
|
20
|
+
const resolvedPageSizeLabel = pageSizeLabel ?? t("components.pagination.pageSize");
|
|
15
21
|
const totalPages = Math.ceil(total / pageSize);
|
|
16
22
|
const releaseFocus = (event) => {
|
|
17
23
|
event.currentTarget.blur();
|
|
@@ -58,9 +64,9 @@ function Pagination({ current, pageSize, total, onChange, onPageSizeChange, page
|
|
|
58
64
|
return /* @__PURE__ */ jsxs("div", {
|
|
59
65
|
className: cn("tc-ui-pagination flex items-center gap-4", className),
|
|
60
66
|
children: [
|
|
61
|
-
/* @__PURE__ */
|
|
67
|
+
/* @__PURE__ */ jsx("div", {
|
|
62
68
|
className: "text-sm text-muted-foreground",
|
|
63
|
-
children: [
|
|
69
|
+
children: showTotal ? showTotal(total, [Math.min((current - 1) * pageSize + 1, total), Math.min(current * pageSize, total)]) : `Total ${total}`
|
|
64
70
|
}),
|
|
65
71
|
/* @__PURE__ */ jsxs("div", {
|
|
66
72
|
className: "flex flex-1 items-center justify-center gap-1.5",
|
|
@@ -69,6 +75,7 @@ function Pagination({ current, pageSize, total, onChange, onPageSizeChange, page
|
|
|
69
75
|
onClick: handlePrevious,
|
|
70
76
|
disabled: current === 1,
|
|
71
77
|
size: "sm",
|
|
78
|
+
"aria-label": resolvedPreviousPageLabel,
|
|
72
79
|
className: cn("inline-flex items-center justify-center", "h-8 w-8 rounded-md px-0", "text-sm font-medium", "border border-border/70 bg-background", "transition-colors duration-150", "focus-visible:ring-2 focus-visible:ring-ring/35 focus-visible:ring-offset-0", current === 1 ? "cursor-not-allowed text-muted-foreground/45" : "cursor-pointer text-muted-foreground hover:bg-foreground/8 hover:text-foreground"),
|
|
73
80
|
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
|
|
74
81
|
}),
|
|
@@ -89,6 +96,7 @@ function Pagination({ current, pageSize, total, onChange, onPageSizeChange, page
|
|
|
89
96
|
onClick: handleNext,
|
|
90
97
|
size: "sm",
|
|
91
98
|
disabled: current === totalPages,
|
|
99
|
+
"aria-label": resolvedNextPageLabel,
|
|
92
100
|
className: cn("inline-flex items-center justify-center", "h-8 w-8 rounded-md px-0", "text-sm font-medium", "border border-border/70 bg-background", "transition-colors duration-150", "focus-visible:ring-2 focus-visible:ring-ring/35 focus-visible:ring-offset-0", current === totalPages ? "cursor-not-allowed text-muted-foreground/45" : "cursor-pointer text-muted-foreground hover:bg-foreground/8 hover:text-foreground"),
|
|
93
101
|
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
94
102
|
})
|
|
@@ -105,7 +113,8 @@ function Pagination({ current, pageSize, total, onChange, onPageSizeChange, page
|
|
|
105
113
|
})),
|
|
106
114
|
className: "w-20 [&>div]:bg-muted [&>div]:border-border [&>div]:shadow-sm [&>div]:py-2 [&>div]:px-3 [&>div]:h-8",
|
|
107
115
|
clearable: false,
|
|
108
|
-
searchable: false
|
|
116
|
+
searchable: false,
|
|
117
|
+
"aria-label": resolvedPageSizeLabel
|
|
109
118
|
})
|
|
110
119
|
})
|
|
111
120
|
]
|
|
@@ -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>>;
|
|
@@ -15,7 +15,7 @@ import { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState }
|
|
|
15
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
import { ChevronUp, X } from "lucide-react";
|
|
17
17
|
//#region packages/react/forms/Select/Select.tsx
|
|
18
|
-
var Select = forwardRef(({ options, value: controlledValue, defaultValue, placeholder, onChange, className, disabled, loading, clearable = true, searchable = true, getPopupContainer }, ref) => {
|
|
18
|
+
var Select = forwardRef(({ options, value: controlledValue, defaultValue, placeholder, onChange, className, disabled, loading, clearable = true, searchable = true, onSearch, notFoundContent, optionRender, onPopupScroll, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, getPopupContainer }, ref) => {
|
|
19
19
|
const t = useI18n();
|
|
20
20
|
const [isOpen, setIsOpen] = useState(false);
|
|
21
21
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
@@ -52,12 +52,14 @@ var Select = forwardRef(({ options, value: controlledValue, defaultValue, placeh
|
|
|
52
52
|
const selectedOption = options.find((opt) => opt.value === value);
|
|
53
53
|
const displayText = selectedOption ? selectedOption.label : placeholder || "";
|
|
54
54
|
const filteredOptions = useMemo(() => {
|
|
55
|
+
if (onSearch) return options;
|
|
55
56
|
if (!searchable || !searchTerm.trim()) return options;
|
|
56
57
|
const lower = searchTerm.trim().toLowerCase();
|
|
57
58
|
return options.filter((opt) => {
|
|
58
59
|
return (opt.searchText ?? (typeof opt.label === "string" || typeof opt.label === "number" ? String(opt.label) : "")).toLowerCase().includes(lower);
|
|
59
60
|
});
|
|
60
61
|
}, [
|
|
62
|
+
onSearch,
|
|
61
63
|
options,
|
|
62
64
|
searchTerm,
|
|
63
65
|
searchable
|
|
@@ -117,10 +119,15 @@ var Select = forwardRef(({ options, value: controlledValue, defaultValue, placeh
|
|
|
117
119
|
value
|
|
118
120
|
]);
|
|
119
121
|
const handleSelect = useCallback((optionValue) => {
|
|
122
|
+
if (options.find((option) => option.value === optionValue)?.disabled) return;
|
|
120
123
|
if (!isControlled) setInternalValue(optionValue);
|
|
121
124
|
onChange?.(optionValue);
|
|
122
125
|
setIsOpen(false);
|
|
123
|
-
}, [
|
|
126
|
+
}, [
|
|
127
|
+
isControlled,
|
|
128
|
+
onChange,
|
|
129
|
+
options
|
|
130
|
+
]);
|
|
124
131
|
const handleClear = useCallback((event) => {
|
|
125
132
|
event.stopPropagation();
|
|
126
133
|
if (disabled) return;
|
|
@@ -128,9 +135,11 @@ var Select = forwardRef(({ options, value: controlledValue, defaultValue, placeh
|
|
|
128
135
|
onChange?.(void 0);
|
|
129
136
|
}, [disabled, onChange]);
|
|
130
137
|
const handleSearchChange = useCallback((event) => {
|
|
131
|
-
|
|
138
|
+
const nextSearchTerm = event.target.value;
|
|
139
|
+
setSearchTerm(nextSearchTerm);
|
|
132
140
|
setActiveOptionIndex(0);
|
|
133
|
-
|
|
141
|
+
onSearch?.(nextSearchTerm);
|
|
142
|
+
}, [onSearch]);
|
|
134
143
|
const moveActiveOption = useCallback((direction) => {
|
|
135
144
|
if (filteredOptions.length === 0) return;
|
|
136
145
|
setActiveOptionIndex((current) => {
|
|
@@ -214,6 +223,9 @@ var Select = forwardRef(({ options, value: controlledValue, defaultValue, placeh
|
|
|
214
223
|
onMouseEnter: () => setIsHover(true),
|
|
215
224
|
onMouseLeave: () => setIsHover(false),
|
|
216
225
|
role: "combobox",
|
|
226
|
+
id,
|
|
227
|
+
"aria-label": ariaLabel,
|
|
228
|
+
"aria-labelledby": ariaLabelledBy,
|
|
217
229
|
"aria-expanded": isOpen,
|
|
218
230
|
"aria-haspopup": "listbox",
|
|
219
231
|
"aria-controls": listboxId,
|
|
@@ -250,6 +262,7 @@ var Select = forwardRef(({ options, value: controlledValue, defaultValue, placeh
|
|
|
250
262
|
container: popupContainer,
|
|
251
263
|
positionMode: isParentPopupContainer ? "absolute" : "fixed",
|
|
252
264
|
className: cn("w-full rounded-xl border border-border/60 bg-popover text-popover-foreground", "shadow-[var(--shadow-floating)]", "max-h-60 overflow-auto"),
|
|
265
|
+
onScroll: onPopupScroll,
|
|
253
266
|
children: /* @__PURE__ */ jsx("div", {
|
|
254
267
|
className: cn("w-full", !isOpen && "hidden"),
|
|
255
268
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -265,12 +278,12 @@ var Select = forwardRef(({ options, value: controlledValue, defaultValue, placeh
|
|
|
265
278
|
"aria-selected": isSelected,
|
|
266
279
|
onClick: () => handleSelect(option.value),
|
|
267
280
|
onMouseEnter: () => setActiveOptionIndex(index),
|
|
268
|
-
className: cn("px-4 py-2 text-sm cursor-pointer transition-colors rounded-md", "hover:bg-foreground/8", (isSelected || isActive) && "bg-theme/12 text-foreground"),
|
|
269
|
-
children: option.label
|
|
281
|
+
className: cn("px-4 py-2 text-sm cursor-pointer transition-colors rounded-md", option.disabled && "cursor-not-allowed opacity-50 pointer-events-none", "hover:bg-foreground/8", !option.disabled && (isSelected || isActive) && "bg-theme/12 text-foreground"),
|
|
282
|
+
children: optionRender ? optionRender(option, { index }) : option.label
|
|
270
283
|
}, option.value);
|
|
271
284
|
}) : /* @__PURE__ */ jsx("div", {
|
|
272
285
|
className: "px-4 py-2 text-sm text-muted-foreground text-center",
|
|
273
|
-
children: t("components.select.empty")
|
|
286
|
+
children: notFoundContent ?? t("components.select.empty")
|
|
274
287
|
})
|
|
275
288
|
})
|
|
276
289
|
})
|
|
@@ -14,6 +14,8 @@ import { Pagination } from "./Pagination/Pagination.js";
|
|
|
14
14
|
import "./Pagination/index.js";
|
|
15
15
|
import { ActionBtn } from "./DataTable/ActionBtn.js";
|
|
16
16
|
import { DataTable } from "./DataTable/index.js";
|
|
17
|
+
import { MultiSelect } from "./MultiSelect/MultiSelect.js";
|
|
18
|
+
import "./MultiSelect/index.js";
|
|
17
19
|
import { defaultLocale, enUSLocale, getDateFnsLocale, getDateLocale, registerDateFnsLocale, registerDateFnsLocales, zhCNLocale } from "./Date/locales.js";
|
|
18
20
|
import { useDateLocaleStore } from "./Date/dateLocaleStore.js";
|
|
19
21
|
import { useDateLocale } from "./Date/LocaleContext.js";
|
|
@@ -38,4 +40,4 @@ import Search from "./Search/Search.js";
|
|
|
38
40
|
import "./Search/index.js";
|
|
39
41
|
import TableSearch from "./TableSearch/TableSearch.js";
|
|
40
42
|
import "./TableSearch/index.js";
|
|
41
|
-
export { ActionBtn, DataTable, DateLocaleProvider, DatePicker, FileUpload, Form, FormItem, ImageUpload, Input, InputNumber, Pagination, Radio, RadioGroup, SchemaForm, Search, Select, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSearch, Textarea, TreeSelect, defaultLocale, enUSLocale, getDateFnsLocale, getDateLocale, registerDateFnsLocale, registerDateFnsLocales, registerSchemaFormComponents, useDateLocale, useDateLocaleStore, useForm, useRadioGroupContext, zhCNLocale };
|
|
43
|
+
export { ActionBtn, DataTable, DateLocaleProvider, DatePicker, FileUpload, Form, FormItem, ImageUpload, Input, InputNumber, MultiSelect, Pagination, Radio, RadioGroup, SchemaForm, Search, Select, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSearch, Textarea, TreeSelect, defaultLocale, enUSLocale, getDateFnsLocale, getDateLocale, registerDateFnsLocale, registerDateFnsLocales, registerSchemaFormComponents, useDateLocale, useDateLocaleStore, useForm, useRadioGroupContext, zhCNLocale };
|
|
@@ -13,6 +13,11 @@ declare const LOCALES: {
|
|
|
13
13
|
readonly breadcrumb: {
|
|
14
14
|
readonly close: "关闭";
|
|
15
15
|
};
|
|
16
|
+
readonly pagination: {
|
|
17
|
+
readonly previousPage: "上一页";
|
|
18
|
+
readonly nextPage: "下一页";
|
|
19
|
+
readonly pageSize: "每页条数";
|
|
20
|
+
};
|
|
16
21
|
readonly confirmDialog: {
|
|
17
22
|
readonly title: "提示";
|
|
18
23
|
readonly okText: "确认";
|
|
@@ -20,6 +25,8 @@ declare const LOCALES: {
|
|
|
20
25
|
};
|
|
21
26
|
readonly dataTable: {
|
|
22
27
|
readonly noData: "暂无数据";
|
|
28
|
+
readonly selectAll: "全选行";
|
|
29
|
+
readonly selectRow: "选择行";
|
|
23
30
|
};
|
|
24
31
|
readonly date: {
|
|
25
32
|
readonly placeholder: "请选择日期";
|
|
@@ -64,6 +71,12 @@ declare const LOCALES: {
|
|
|
64
71
|
readonly okText: "确认";
|
|
65
72
|
readonly cancelText: "取消";
|
|
66
73
|
};
|
|
74
|
+
readonly multiSelect: {
|
|
75
|
+
readonly removeOption: "移除{label}";
|
|
76
|
+
readonly clear: "清除选择";
|
|
77
|
+
readonly search: "搜索";
|
|
78
|
+
readonly searchOptions: "搜索选项";
|
|
79
|
+
};
|
|
67
80
|
readonly message: {
|
|
68
81
|
readonly close: "关闭";
|
|
69
82
|
};
|
|
@@ -98,6 +111,11 @@ declare const LOCALES: {
|
|
|
98
111
|
readonly breadcrumb: {
|
|
99
112
|
readonly close: "Close";
|
|
100
113
|
};
|
|
114
|
+
readonly pagination: {
|
|
115
|
+
readonly previousPage: "Previous page";
|
|
116
|
+
readonly nextPage: "Next page";
|
|
117
|
+
readonly pageSize: "Items per page";
|
|
118
|
+
};
|
|
101
119
|
readonly confirmDialog: {
|
|
102
120
|
readonly title: "Prompt";
|
|
103
121
|
readonly okText: "Confirm";
|
|
@@ -105,6 +123,8 @@ declare const LOCALES: {
|
|
|
105
123
|
};
|
|
106
124
|
readonly dataTable: {
|
|
107
125
|
readonly noData: "No Data";
|
|
126
|
+
readonly selectAll: "Select all rows";
|
|
127
|
+
readonly selectRow: "Select row";
|
|
108
128
|
};
|
|
109
129
|
readonly date: {
|
|
110
130
|
readonly placeholder: "Select date";
|
|
@@ -149,6 +169,12 @@ declare const LOCALES: {
|
|
|
149
169
|
readonly okText: "Confirm";
|
|
150
170
|
readonly cancelText: "Cancel";
|
|
151
171
|
};
|
|
172
|
+
readonly multiSelect: {
|
|
173
|
+
readonly removeOption: "Remove {label}";
|
|
174
|
+
readonly clear: "Clear selection";
|
|
175
|
+
readonly search: "Search";
|
|
176
|
+
readonly searchOptions: "Search options";
|
|
177
|
+
};
|
|
152
178
|
readonly message: {
|
|
153
179
|
readonly close: "Close";
|
|
154
180
|
};
|
|
@@ -44,6 +44,7 @@ import { Pagination } from "./forms/Pagination/Pagination.js";
|
|
|
44
44
|
import { Dropdown } from "./overlays/Dropdown/Dropdown.js";
|
|
45
45
|
import { ActionBtn } from "./forms/DataTable/ActionBtn.js";
|
|
46
46
|
import { DataTable } from "./forms/DataTable/index.js";
|
|
47
|
+
import { MultiSelect } from "./forms/MultiSelect/MultiSelect.js";
|
|
47
48
|
import { defaultLocale, enUSLocale, getDateFnsLocale, getDateLocale, registerDateFnsLocale, registerDateFnsLocales, zhCNLocale } from "./forms/Date/locales.js";
|
|
48
49
|
import { useDateLocaleStore } from "./forms/Date/dateLocaleStore.js";
|
|
49
50
|
import { useDateLocale } from "./forms/Date/LocaleContext.js";
|
|
@@ -77,4 +78,4 @@ import { PreviewImage } from "./ui/components/ImagePreview/PreviewImage.js";
|
|
|
77
78
|
import "./ui/components/ImagePreview/index.js";
|
|
78
79
|
import { Tabs } from "./ui/components/Tabs/Tabs.js";
|
|
79
80
|
import "./ui/components/Tabs/index.js";
|
|
80
|
-
export { ActionBtn, AsynchronousButton, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, CollapseToggle, ConfirmDialog, DataTable, DateLocaleProvider, DatePicker, Drawer, Dropdown, ExportType, FileUpload, Form, FormItem, I18nContext, I18nProvider, 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, breadcrumbStore, canUseDocument, cn, createStoreHook, defaultCompare, defaultLocale, enUSLocale, executionPhaseType, exportToExcel, formatDate, formatDateTime, formatTime, generateStartEndTime, getDataTableColumnStyle, getDataTableColumnWidth, getDataTableFixedOffset, getDateFnsLocale, getDateLocale, getDefaultDropdownPosition, getLanguage, getUiReactLocale, i18n, i18nStore, identityCompare, message, modal, normalizeTableWidth, registerDateFnsLocale, registerDateFnsLocales, registerSchemaFormComponents, shallowCompare, t, translate, useBreadcrumb, useBreadcrumbStore, useClientValue, useDateLocale, useDateLocaleStore, useDropdownPositioning, useForm, useHydrated, useHydrationData, useI18n, useI18nStore, useInputController, useLanguage, useI18nStore$1 as useLanguages, useMenuStore, useRadioGroupContext, useTableState, useWatch, useWindowSize, zhCNLocale };
|
|
81
|
+
export { ActionBtn, AsynchronousButton, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, CollapseToggle, ConfirmDialog, DataTable, DateLocaleProvider, DatePicker, Drawer, Dropdown, ExportType, FileUpload, Form, FormItem, I18nContext, I18nProvider, ImagePreviewController, ImageUpload, Input, InputNumber, Label, Layout, Loading, LoadingIndicator, Menu, MenuItem, Modal, MultiSelect, 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, breadcrumbStore, canUseDocument, cn, createStoreHook, defaultCompare, defaultLocale, enUSLocale, executionPhaseType, exportToExcel, formatDate, formatDateTime, formatTime, generateStartEndTime, getDataTableColumnStyle, getDataTableColumnWidth, getDataTableFixedOffset, getDateFnsLocale, getDateLocale, getDefaultDropdownPosition, getLanguage, getUiReactLocale, i18n, i18nStore, identityCompare, message, modal, normalizeTableWidth, registerDateFnsLocale, registerDateFnsLocales, registerSchemaFormComponents, shallowCompare, t, translate, useBreadcrumb, useBreadcrumbStore, useClientValue, useDateLocale, useDateLocaleStore, useDropdownPositioning, useForm, useHydrated, useHydrationData, useI18n, useI18nStore, useInputController, useLanguage, useI18nStore$1 as useLanguages, useMenuStore, useRadioGroupContext, useTableState, useWatch, useWindowSize, zhCNLocale };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { DialogAccessibilityProps } from "../Overlay/index";
|
|
2
3
|
export type DrawerPlacement = 'top' | 'right' | 'bottom' | 'left';
|
|
3
|
-
export type DrawerProps = {
|
|
4
|
+
export type DrawerProps = DialogAccessibilityProps & {
|
|
4
5
|
open?: boolean;
|
|
5
6
|
onClose?: () => void;
|
|
6
7
|
title?: ReactNode;
|
|
@@ -19,4 +20,4 @@ export type DrawerProps = {
|
|
|
19
20
|
renderNode?: HTMLElement | (() => HTMLElement);
|
|
20
21
|
keyboard?: boolean;
|
|
21
22
|
};
|
|
22
|
-
export declare function Drawer({ open, onClose, title, children, footer, className, contentClassName, mask, maskClosable, lockScroll, closable, placement, width, height, renderNode, keyboard, zIndex, }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function Drawer({ open, onClose, title, children, footer, className, contentClassName, mask, maskClosable, lockScroll, closable, placement, width, height, renderNode, keyboard, zIndex, role, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, initialFocus, }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { Button } from "../../core/Button/Button.js";
|
|
|
5
5
|
import "../../core/Button/index.js";
|
|
6
6
|
import { Overlay } from "../Overlay/Overlay.js";
|
|
7
7
|
import "../Overlay/index.js";
|
|
8
|
-
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { X } from "lucide-react";
|
|
11
11
|
//#region packages/react/overlays/Drawer/Drawer.tsx
|
|
@@ -42,8 +42,10 @@ var getDrawerSizeStyle = (placement, width, height) => {
|
|
|
42
42
|
const resolvedSize = typeof size === "number" ? `${size}px` : size;
|
|
43
43
|
return isHorizontal ? { width: resolvedSize } : { height: resolvedSize };
|
|
44
44
|
};
|
|
45
|
-
function Drawer({ open = false, onClose, title, children, footer, className, contentClassName, mask = true, maskClosable = true, lockScroll = true, closable = true, placement = "right", width = 420, height = 360, renderNode, keyboard = true, zIndex = 1e3 }) {
|
|
45
|
+
function Drawer({ open = false, onClose, title, children, footer, className, contentClassName, mask = true, maskClosable = true, lockScroll = true, closable = true, placement = "right", width = 420, height = 360, renderNode, keyboard = true, zIndex = 1e3, role = "dialog", "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, initialFocus }) {
|
|
46
46
|
const t = useI18n();
|
|
47
|
+
const titleId = useId();
|
|
48
|
+
const dialogRef = useRef(null);
|
|
47
49
|
const [mounted, setMounted] = useState(open);
|
|
48
50
|
const [visible, setVisible] = useState(false);
|
|
49
51
|
const animationFrameRef = useRef(void 0);
|
|
@@ -114,9 +116,20 @@ function Drawer({ open = false, onClose, title, children, footer, className, con
|
|
|
114
116
|
closable,
|
|
115
117
|
renderNode,
|
|
116
118
|
zIndex,
|
|
119
|
+
dialogRef,
|
|
120
|
+
initialFocus,
|
|
121
|
+
layerOpen: open,
|
|
117
122
|
className: "tc-ui-drawer",
|
|
118
123
|
style: { transition: `opacity ${DRAWER_ANIMATION_DURATION}ms ${DRAWER_ANIMATION_EASING}` },
|
|
119
124
|
children: /* @__PURE__ */ jsxs("div", {
|
|
125
|
+
ref: dialogRef,
|
|
126
|
+
role,
|
|
127
|
+
"aria-modal": open ? "true" : void 0,
|
|
128
|
+
"aria-label": ariaLabel,
|
|
129
|
+
"aria-describedby": ariaDescribedBy,
|
|
130
|
+
"aria-labelledby": title ? titleId : void 0,
|
|
131
|
+
"aria-hidden": !open || void 0,
|
|
132
|
+
tabIndex: -1,
|
|
120
133
|
className: cn("fixed border border-border/70 bg-popover text-popover-foreground", "shadow-[0_22px_70px_hsl(var(--background)/0.58),inset_0_1px_0_hsl(var(--foreground)/0.06)]", "flex flex-col", getDrawerPositionClassName(placement), getDrawerRadiusClassName(placement), placement === "top" || placement === "bottom" ? "max-h-[90vh]" : "max-w-[90vw]", className),
|
|
121
134
|
style: drawerStyle,
|
|
122
135
|
onClick: handleContentClick,
|
|
@@ -124,6 +137,7 @@ function Drawer({ open = false, onClose, title, children, footer, className, con
|
|
|
124
137
|
(title || closable) && /* @__PURE__ */ jsxs("div", {
|
|
125
138
|
className: "flex items-center justify-between border-b border-border/60 px-4 py-3",
|
|
126
139
|
children: [title && /* @__PURE__ */ jsx("div", {
|
|
140
|
+
id: titleId,
|
|
127
141
|
className: "text-sm font-semibold leading-5 text-foreground",
|
|
128
142
|
children: title
|
|
129
143
|
}), closable && /* @__PURE__ */ jsx(Button, {
|
|
@@ -5,20 +5,30 @@ export interface DropdownBaseItem {
|
|
|
5
5
|
label: ReactNode;
|
|
6
6
|
icon?: ReactNode;
|
|
7
7
|
danger?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
onClick?: () => void;
|
|
9
10
|
}
|
|
11
|
+
export interface DropdownDividerItem {
|
|
12
|
+
type: 'divider';
|
|
13
|
+
key?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
10
16
|
export interface DropdownRenderItem {
|
|
11
17
|
render: (item: DropdownRenderItem, context: {
|
|
12
18
|
onClick: () => void;
|
|
13
19
|
close: () => void;
|
|
14
20
|
}) => ReactNode;
|
|
15
21
|
}
|
|
16
|
-
export type DropdownItem = Omit<DropdownBaseItem, 'render'> | DropdownRenderItem;
|
|
22
|
+
export type DropdownItem = Omit<DropdownBaseItem, 'render'> | DropdownRenderItem | DropdownDividerItem;
|
|
17
23
|
export interface DropdownProps {
|
|
18
24
|
items: DropdownItem[];
|
|
19
25
|
children: ReactNode;
|
|
20
26
|
className?: string;
|
|
27
|
+
popupClassName?: string;
|
|
28
|
+
open?: boolean;
|
|
29
|
+
defaultOpen?: boolean;
|
|
30
|
+
onOpenChange?: (open: boolean) => void;
|
|
21
31
|
placement?: DropdownPlacement;
|
|
22
32
|
getPopupContainer?: () => HTMLElement;
|
|
23
33
|
}
|
|
24
|
-
export declare function Dropdown({ items, children, className, placement, getPopupContainer }: DropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare function Dropdown({ items, children, className, popupClassName, open: controlledOpen, defaultOpen, onOpenChange, placement, getPopupContainer, }: DropdownProps): import("react/jsx-runtime").JSX.Element;
|