@hkyhy/marsun-components-core 0.1.11 → 0.1.15
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/README.md +31 -6
- package/dist/components/AgentHub/Chat/Action/CreateButton.js +8 -0
- package/dist/components/AgentHub/Chat/Action/CreateButton.js.map +1 -0
- package/dist/components/AgentHub/Chat/Action/ManageActionButtons.js +20 -0
- package/dist/components/AgentHub/Chat/Action/ManageActionButtons.js.map +1 -0
- package/dist/components/AgentHub/Chat/Action/SessionActionButtons.js +24 -0
- package/dist/components/AgentHub/Chat/Action/SessionActionButtons.js.map +1 -0
- package/dist/components/AgentHub/Chat/Action/handlers.d.ts +0 -5
- package/dist/components/AgentHub/Chat/Detail/ChatInput/index.js +65 -0
- package/dist/components/AgentHub/Chat/Detail/ChatInput/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatInput/style.module.scss.js +12 -0
- package/dist/components/AgentHub/Chat/Detail/ChatInput/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.d.ts +31 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.js +85 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/style.module.scss.js +14 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/index.d.ts +9 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/index.js +22 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/style.module.scss.js +8 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/index.js +21 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/style.module.scss.js +8 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/index.js +17 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/style.module.scss.js +7 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/index.js +68 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/style.module.scss.js +7 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/index.js +247 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/style.module.scss.js +31 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/index.js +43 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/style.module.scss.js +8 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/index.js +103 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/style.module.scss.js +14 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/index.js +58 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/style.module.scss.js +9 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/index.js +309 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/style.module.scss.js +24 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/index.js +122 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/style.module.scss.js +25 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/index.d.ts +12 -0
- package/dist/components/AgentHub/Chat/Form/Form.js +37 -0
- package/dist/components/AgentHub/Chat/Form/Form.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/index.js +86 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/style.module.scss.js +25 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/FilterBar.js +17 -0
- package/dist/components/AgentHub/Chat/List/FilterBar.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/index.js +156 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/style.module.scss.js +28 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Modal/FormModal.js +58 -0
- package/dist/components/AgentHub/Chat/Modal/FormModal.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useAutoScrollToBottom.js +35 -0
- package/dist/components/AgentHub/Chat/hooks/useAutoScrollToBottom.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useChat.js +51 -0
- package/dist/components/AgentHub/Chat/hooks/useChat.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useChatSessions.js +60 -0
- package/dist/components/AgentHub/Chat/hooks/useChatSessions.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useSSECompletion.js +69 -0
- package/dist/components/AgentHub/Chat/hooks/useSSECompletion.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useTypewriter.js +39 -0
- package/dist/components/AgentHub/Chat/hooks/useTypewriter.js.map +1 -0
- package/dist/components/AgentHub/Chat/index.d.ts +1 -0
- package/dist/components/AgentHub/Chat/utils/citationContent.js +169 -0
- package/dist/components/AgentHub/Chat/utils/citationContent.js.map +1 -0
- package/dist/components/AgentHub/Chat/utils/messageContent.js +85 -0
- package/dist/components/AgentHub/Chat/utils/messageContent.js.map +1 -0
- package/dist/components/AgentHub/Chat/utils/sanitizeMermaidChart.js +22 -0
- package/dist/components/AgentHub/Chat/utils/sanitizeMermaidChart.js.map +1 -0
- package/dist/components/AgentHub/Chat/utils/sessionMessages.js +151 -0
- package/dist/components/AgentHub/Chat/utils/sessionMessages.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/CreateButton.js +8 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/CreateButton.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/ManageActionButtons.js +20 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/ManageActionButtons.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/index.js +110 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/index.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/style.module.scss.js +7 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/index.js +18 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/index.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/style.module.scss.js +7 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Form/Form.js +31 -0
- package/dist/components/AgentHub/KnowledgeBase/Form/Form.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/List/FilterBar.js +17 -0
- package/dist/components/AgentHub/KnowledgeBase/List/FilterBar.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/index.js +118 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/index.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/style.module.scss.js +23 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Modal/FormModal.js +47 -0
- package/dist/components/AgentHub/KnowledgeBase/Modal/FormModal.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/constants/types.js +28 -0
- package/dist/components/AgentHub/KnowledgeBase/constants/types.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKBDocuments.js +21 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKBDocuments.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKnowledgeBase.js +32 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKnowledgeBase.js.map +1 -0
- package/dist/components/Filter/FilterDateRange/index.d.ts +2 -0
- package/dist/components/Filter/FilterDateRange/index.js +62 -51
- package/dist/components/Filter/FilterDateRange/index.js.map +1 -1
- package/dist/components/Filter/FilterSelect/index.d.ts +6 -2
- package/dist/components/Filter/FilterSelect/index.js +132 -107
- package/dist/components/Filter/FilterSelect/index.js.map +1 -1
- package/dist/components/Filter/FilterTrigger/index.d.ts +2 -2
- package/dist/components/Filter/FilterTrigger/index.js.map +1 -1
- package/dist/components/Filter/FilterTrigger/style.module.scss.js +4 -4
- package/dist/components/Filter/index.d.ts +1 -1
- package/dist/components/Icons/index.js +153 -145
- package/dist/components/Icons/index.js.map +1 -1
- package/dist/components/LlmFormattedText/LlmFormattedText/index.d.ts +8 -0
- package/dist/components/LlmFormattedText/LlmFormattedText/index.js +42 -0
- package/dist/components/LlmFormattedText/LlmFormattedText/index.js.map +1 -0
- package/dist/components/LlmFormattedText/LlmFormattedText/style.module.scss.js +17 -0
- package/dist/components/LlmFormattedText/LlmFormattedText/style.module.scss.js.map +1 -0
- package/dist/components/LlmFormattedText/index.d.ts +4 -0
- package/dist/components/LlmFormattedText/parseLlmText.d.ts +14 -0
- package/dist/components/LlmFormattedText/parseLlmText.js +77 -0
- package/dist/components/LlmFormattedText/parseLlmText.js.map +1 -0
- package/dist/components/Sparkline/Sparkline/index.d.ts +11 -0
- package/dist/components/Sparkline/Sparkline/index.js +46 -0
- package/dist/components/Sparkline/Sparkline/index.js.map +1 -0
- package/dist/components/Sparkline/Sparkline/style.module.scss.js +8 -0
- package/dist/components/Sparkline/Sparkline/style.module.scss.js.map +1 -0
- package/dist/components/Sparkline/index.d.ts +2 -0
- package/dist/components/TooltipInfo/TooltipInfo.js +29 -20
- package/dist/components/TooltipInfo/TooltipInfo.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +291 -175
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/theme/constants.d.ts +47 -1
- package/dist/theme/constants.js +50 -5
- package/dist/theme/constants.js.map +1 -1
- package/dist/theme/index.d.ts +2 -2
- package/dist/theme/index.js +8 -6
- package/dist/theme/theme.d.ts +10 -0
- package/dist/theme/theme.js +24 -34
- package/dist/theme/theme.js.map +1 -1
- package/dist/theme/tokens.css +139 -0
- package/package.json +6 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKBDocuments.js","sources":["../../../../../src/components/AgentHub/KnowledgeBase/hooks/useKBDocuments.ts"],"sourcesContent":["import type { KBDocument } from '@/components/AgentHub/types';\nimport { useMarsunFetch } from '@/provider';\nimport { useFetchData } from '@/hooks/useFetchData';\n\nexport type UseKBDocumentsOptions = {\n listUrl?: string;\n transformList?: (raw: unknown) => KBDocument[];\n};\n\nexport const useKBDocuments = (datasetId: string | undefined, options: UseKBDocumentsOptions = {}) => {\n const fetchCtx = useMarsunFetch();\n const url = options.listUrl?.replace('{datasetId}', datasetId ?? '');\n\n const { data, loading, reload } = useFetchData<KBDocument[]>({\n fetchUrl: url,\n transformData:\n options.transformList ??\n ((raw) => {\n const r = raw as { data?: KBDocument[] };\n return Array.isArray(r?.data) ? r.data : [];\n }),\n enabled: !!url && !!datasetId,\n baseUrl: fetchCtx.baseUrl,\n defaultHeaders: fetchCtx.headers,\n timeoutMs: fetchCtx.timeoutMs,\n });\n\n return { data: data ?? [], loading, fetchData: reload };\n};\n"],"names":["useKBDocuments","datasetId","options","fetchCtx","useMarsunFetch","url","_a","data","loading","reload","useFetchData","raw","r"],"mappings":";;AASO,MAAMA,IAAiB,CAACC,GAA+BC,IAAiC,OAAO;;AACpG,QAAMC,IAAWC,EAAA,GACXC,KAAMC,IAAAJ,EAAQ,YAAR,gBAAAI,EAAiB,QAAQ,eAAeL,KAAa,KAE3D,EAAE,MAAAM,GAAM,SAAAC,GAAS,QAAAC,EAAA,IAAWC,EAA2B;AAAA,IAC3D,UAAUL;AAAA,IACV,eACEH,EAAQ,kBACP,CAACS,MAAQ;AACR,YAAMC,IAAID;AACV,aAAO,MAAM,QAAQC,KAAA,gBAAAA,EAAG,IAAI,IAAIA,EAAE,OAAO,CAAA;AAAA,IAC3C;AAAA,IACF,SAAS,CAAC,CAACP,KAAO,CAAC,CAACJ;AAAA,IACpB,SAASE,EAAS;AAAA,IAClB,gBAAgBA,EAAS;AAAA,IACzB,WAAWA,EAAS;AAAA,EAAA,CACrB;AAED,SAAO,EAAE,MAAMI,KAAQ,CAAA,GAAI,SAAAC,GAAS,WAAWC,EAAA;AACjD;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useFetchData as f } from "../../../../hooks/useFetchData.js";
|
|
2
|
+
import { useCallback as m } from "react";
|
|
3
|
+
import { useMarsunFetch as h } from "../../../../provider/context.js";
|
|
4
|
+
const b = (e = {}) => {
|
|
5
|
+
const a = h(), { data: d, loading: c, reload: t } = f({
|
|
6
|
+
fetchUrl: e.listUrl,
|
|
7
|
+
transformData: e.transformList ?? ((l) => {
|
|
8
|
+
const r = l;
|
|
9
|
+
return Array.isArray(r == null ? void 0 : r.data) ? r.data : [];
|
|
10
|
+
}),
|
|
11
|
+
enabled: !!e.listUrl,
|
|
12
|
+
baseUrl: a.baseUrl,
|
|
13
|
+
defaultHeaders: a.headers,
|
|
14
|
+
timeoutMs: a.timeoutMs
|
|
15
|
+
}), u = m(
|
|
16
|
+
async (l) => {
|
|
17
|
+
var s;
|
|
18
|
+
if (!e.deleteUrl) return;
|
|
19
|
+
const r = e.deleteUrl.replace("{id}", l);
|
|
20
|
+
await fetch(`${a.baseUrl ?? ""}${r}`, {
|
|
21
|
+
method: "DELETE",
|
|
22
|
+
headers: a.headers
|
|
23
|
+
}), (s = e.onDeleteSuccess) == null || s.call(e), t();
|
|
24
|
+
},
|
|
25
|
+
[e, a, t]
|
|
26
|
+
);
|
|
27
|
+
return { data: d ?? [], loading: c, fetchData: t, deleteDataset: u };
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
b as useKnowledgeBase
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useKnowledgeBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKnowledgeBase.js","sources":["../../../../../src/components/AgentHub/KnowledgeBase/hooks/useKnowledgeBase.ts"],"sourcesContent":["import type { Dataset } from '@/components/AgentHub/types';\nimport { useMarsunFetch } from '@/provider';\nimport { useFetchData } from '@/hooks/useFetchData';\nimport { useCallback } from 'react';\n\nexport type UseKnowledgeBaseOptions = {\n listUrl?: string;\n transformList?: (raw: unknown) => Dataset[];\n deleteUrl?: string;\n onDeleteSuccess?: () => void;\n};\n\nexport const useKnowledgeBase = (options: UseKnowledgeBaseOptions = {}) => {\n const fetchCtx = useMarsunFetch();\n const { data, loading, reload } = useFetchData<Dataset[]>({\n fetchUrl: options.listUrl,\n transformData:\n options.transformList ??\n ((raw) => {\n const r = raw as { data?: Dataset[] };\n return Array.isArray(r?.data) ? r.data : [];\n }),\n enabled: !!options.listUrl,\n baseUrl: fetchCtx.baseUrl,\n defaultHeaders: fetchCtx.headers,\n timeoutMs: fetchCtx.timeoutMs,\n });\n\n const deleteDataset = useCallback(\n async (id: string) => {\n if (!options.deleteUrl) return;\n const url = options.deleteUrl.replace('{id}', id);\n await fetch(`${fetchCtx.baseUrl ?? ''}${url}`, {\n method: 'DELETE',\n headers: fetchCtx.headers,\n });\n options.onDeleteSuccess?.();\n reload();\n },\n [options, fetchCtx, reload],\n );\n\n return { data: data ?? [], loading, fetchData: reload, deleteDataset };\n};\n"],"names":["useKnowledgeBase","options","fetchCtx","useMarsunFetch","data","loading","reload","useFetchData","raw","deleteDataset","useCallback","id","url","_a"],"mappings":";;;AAYO,MAAMA,IAAmB,CAACC,IAAmC,OAAO;AACzE,QAAMC,IAAWC,EAAA,GACX,EAAE,MAAAC,GAAM,SAAAC,GAAS,QAAAC,EAAA,IAAWC,EAAwB;AAAA,IACxD,UAAUN,EAAQ;AAAA,IAClB,eACEA,EAAQ,kBACP,CAACO,MAAQ;AACR,YAAM,IAAIA;AACV,aAAO,MAAM,QAAQ,uBAAG,IAAI,IAAI,EAAE,OAAO,CAAA;AAAA,IAC3C;AAAA,IACF,SAAS,CAAC,CAACP,EAAQ;AAAA,IACnB,SAASC,EAAS;AAAA,IAClB,gBAAgBA,EAAS;AAAA,IACzB,WAAWA,EAAS;AAAA,EAAA,CACrB,GAEKO,IAAgBC;AAAA,IACpB,OAAOC,MAAe;;AACpB,UAAI,CAACV,EAAQ,UAAW;AACxB,YAAMW,IAAMX,EAAQ,UAAU,QAAQ,QAAQU,CAAE;AAChD,YAAM,MAAM,GAAGT,EAAS,WAAW,EAAE,GAAGU,CAAG,IAAI;AAAA,QAC7C,QAAQ;AAAA,QACR,SAASV,EAAS;AAAA,MAAA,CACnB,IACDW,IAAAZ,EAAQ,oBAAR,QAAAY,EAAA,KAAAZ,IACAK,EAAA;AAAA,IACF;AAAA,IACA,CAACL,GAASC,GAAUI,CAAM;AAAA,EAAA;AAG5B,SAAO,EAAE,MAAMF,KAAQ,CAAA,GAAI,SAAAC,GAAS,WAAWC,GAAQ,eAAAG,EAAA;AACzD;"}
|
|
@@ -10,6 +10,8 @@ interface QuickOption {
|
|
|
10
10
|
interface FilterDateRangeProps extends BaseFilterProps {
|
|
11
11
|
value?: [string, string] | null;
|
|
12
12
|
onChange?: (value: [string, string] | null) => void;
|
|
13
|
+
/** 默认区间:与默认相同时视为未筛选 */
|
|
14
|
+
defaultValue?: [string, string];
|
|
13
15
|
showQuickOptions?: boolean;
|
|
14
16
|
quickOptions?: QuickOption[];
|
|
15
17
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { DatePicker as
|
|
1
|
+
import { jsxs as L, jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import { DatePicker as Q } from "antd";
|
|
3
3
|
import s from "dayjs";
|
|
4
|
-
import { useState as
|
|
5
|
-
import
|
|
6
|
-
import { resolveHidden as
|
|
7
|
-
import { useFilterRegister as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
const { RangePicker:
|
|
4
|
+
import { useState as O, useEffect as R, useMemo as W } from "react";
|
|
5
|
+
import _ from "../FilterPopover/index.js";
|
|
6
|
+
import { resolveHidden as M } from "../types.js";
|
|
7
|
+
import { useFilterRegister as $ } from "../useFilterState.js";
|
|
8
|
+
import m from "./style.module.scss.js";
|
|
9
|
+
import Y from "classnames";
|
|
10
|
+
const { RangePicker: A } = Q, B = [
|
|
11
11
|
{
|
|
12
12
|
key: "lastWeek",
|
|
13
13
|
label: "上周",
|
|
@@ -21,69 +21,80 @@ const { RangePicker: V } = P, L = [
|
|
|
21
21
|
label: "本周",
|
|
22
22
|
getValue: () => [s().startOf("week"), s().endOf("week")]
|
|
23
23
|
}
|
|
24
|
-
]
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
];
|
|
25
|
+
function E(e, r) {
|
|
26
|
+
return !(e != null && e[0]) || !(e != null && e[1]) ? !(r != null && r[0]) || !(r != null && r[1]) : !(r != null && r[0]) || !(r != null && r[1]) ? !1 : e[0] === r[0] && e[1] === r[1];
|
|
27
|
+
}
|
|
28
|
+
const a = ({
|
|
29
|
+
filterKey: e,
|
|
30
|
+
label: r,
|
|
27
31
|
value: t,
|
|
28
|
-
onChange:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
onChange: n,
|
|
33
|
+
defaultValue: F,
|
|
34
|
+
showQuickOptions: P = !0,
|
|
35
|
+
quickOptions: V,
|
|
36
|
+
active: j,
|
|
32
37
|
hidden: k
|
|
33
38
|
}) => {
|
|
34
|
-
const [
|
|
39
|
+
const [I, p] = O(!1), [o, c] = O(
|
|
35
40
|
t ? [s(t[0]), s(t[1])] : null
|
|
36
|
-
), [
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
), [y, d] = O(null), f = $(), N = () => {
|
|
42
|
+
t != null && t[0] && (t != null && t[1]) ? c([s(t[0]), s(t[1])]) : c(null), d(null);
|
|
43
|
+
};
|
|
44
|
+
R(() => {
|
|
45
|
+
t != null && t[0] && (t != null && t[1]) ? c([s(t[0]), s(t[1])]) : c(null);
|
|
39
46
|
}, [t]);
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
if (
|
|
43
|
-
if (
|
|
44
|
-
|
|
47
|
+
const l = !!(t != null && t[0]) && !E(t, F), D = W(() => !l || !(t != null && t[0]) || !(t != null && t[1]) ? "" : `${t[0]} ~ ${t[1]}`, [l, t]);
|
|
48
|
+
if (R(() => {
|
|
49
|
+
if (f) {
|
|
50
|
+
if (M(k)) {
|
|
51
|
+
f.unregister(e);
|
|
45
52
|
return;
|
|
46
53
|
}
|
|
47
|
-
|
|
54
|
+
D ? f.register(e, { label: r, valueLabel: D, onRemove: () => n == null ? void 0 : n(null) }) : f.unregister(e);
|
|
48
55
|
}
|
|
49
|
-
}, [
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
}, [D, e, r, k]), M(k)) return null;
|
|
57
|
+
const S = () => {
|
|
58
|
+
o != null && o[0] && (o != null && o[1]) ? n == null || n([o[0].format("YYYY-MM-DD"), o[1].format("YYYY-MM-DD")]) : n == null || n(null), p(!1);
|
|
59
|
+
}, T = () => {
|
|
60
|
+
N(), p(!1);
|
|
61
|
+
}, x = (i) => {
|
|
62
|
+
i || N(), p(i);
|
|
63
|
+
}, q = V ?? (P ? B : []);
|
|
64
|
+
return /* @__PURE__ */ L(
|
|
65
|
+
_,
|
|
57
66
|
{
|
|
58
|
-
label:
|
|
59
|
-
active:
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
label: r,
|
|
68
|
+
active: j || l,
|
|
69
|
+
open: I,
|
|
70
|
+
onOpenChange: x,
|
|
71
|
+
onConfirm: S,
|
|
72
|
+
onReset: T,
|
|
62
73
|
children: [
|
|
63
|
-
|
|
74
|
+
q.length > 0 && /* @__PURE__ */ g("div", { className: Y("filter-date-range-quick-options", m["filter-date-range-quick-options"]), children: q.map((i) => /* @__PURE__ */ g(
|
|
64
75
|
"span",
|
|
65
76
|
{
|
|
66
|
-
className:
|
|
77
|
+
className: Y(
|
|
67
78
|
"filter-date-range-quick-option",
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
m["filter-date-range-quick-option"],
|
|
80
|
+
y === i.key && "filter-date-range-quick-option-active",
|
|
81
|
+
y === i.key && m["filter-date-range-quick-option-active"]
|
|
71
82
|
),
|
|
72
83
|
onClick: () => {
|
|
73
|
-
const
|
|
74
|
-
|
|
84
|
+
const w = i.getValue();
|
|
85
|
+
w && (c(w), d(i.key));
|
|
75
86
|
},
|
|
76
87
|
children: i.label
|
|
77
88
|
},
|
|
78
89
|
i.key
|
|
79
90
|
)) }),
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
91
|
+
/* @__PURE__ */ g(
|
|
92
|
+
A,
|
|
82
93
|
{
|
|
83
|
-
className:
|
|
84
|
-
value:
|
|
94
|
+
className: Y("filter-date-range-picker", m["filter-date-range-picker"]),
|
|
95
|
+
value: o,
|
|
85
96
|
onChange: (i) => {
|
|
86
|
-
c(i),
|
|
97
|
+
c(i), d(null);
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
)
|
|
@@ -92,6 +103,6 @@ const { RangePicker: V } = P, L = [
|
|
|
92
103
|
);
|
|
93
104
|
};
|
|
94
105
|
export {
|
|
95
|
-
|
|
106
|
+
a as default
|
|
96
107
|
};
|
|
97
108
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Filter/FilterDateRange/index.tsx"],"sourcesContent":["import { DatePicker } from 'antd';\nimport dayjs, { Dayjs } from 'dayjs';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport FilterPopover from '../FilterPopover';\nimport type { BaseFilterProps } from '../types';\nimport { resolveHidden } from '../types';\nimport { useFilterRegister } from '../useFilterState';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\nconst { RangePicker } = DatePicker;\n\n/** 快捷选项配置类型 */\ninterface QuickOption {\n key: string;\n label: string;\n getValue: () => [Dayjs, Dayjs] | null;\n}\n\n/** 内置快捷选项 */\nconst BUILT_IN_OPTIONS: QuickOption[] = [\n {\n key: 'lastWeek',\n label: '上周',\n getValue: () => [\n dayjs().subtract(1, 'week').startOf('week'),\n dayjs().subtract(1, 'week').endOf('week'),\n ],\n },\n {\n key: 'thisWeek',\n label: '本周',\n getValue: () => [dayjs().startOf('week'), dayjs().endOf('week')],\n },\n];\n\ninterface FilterDateRangeProps extends BaseFilterProps {\n value?: [string, string] | null;\n onChange?: (value: [string, string] | null) => void;\n showQuickOptions?: boolean;\n quickOptions?: QuickOption[];\n}\n\nconst FilterDateRange: React.FC<FilterDateRangeProps> = ({\n filterKey,\n label,\n value,\n onChange,\n showQuickOptions = true,\n quickOptions,\n active,\n hidden,\n}) => {\n const [dates, setDates] = useState<[Dayjs | null, Dayjs | null] | null>(\n value ? [dayjs(value[0]), dayjs(value[1])] : null,\n );\n const [activeQuickKey, setActiveQuickKey] = useState<string | null>(null);\n\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Filter/FilterDateRange/index.tsx"],"sourcesContent":["import { DatePicker } from 'antd';\nimport dayjs, { Dayjs } from 'dayjs';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport FilterPopover from '../FilterPopover';\nimport type { BaseFilterProps } from '../types';\nimport { resolveHidden } from '../types';\nimport { useFilterRegister } from '../useFilterState';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\nconst { RangePicker } = DatePicker;\n\n/** 快捷选项配置类型 */\ninterface QuickOption {\n key: string;\n label: string;\n getValue: () => [Dayjs, Dayjs] | null;\n}\n\n/** 内置快捷选项 */\nconst BUILT_IN_OPTIONS: QuickOption[] = [\n {\n key: 'lastWeek',\n label: '上周',\n getValue: () => [\n dayjs().subtract(1, 'week').startOf('week'),\n dayjs().subtract(1, 'week').endOf('week'),\n ],\n },\n {\n key: 'thisWeek',\n label: '本周',\n getValue: () => [dayjs().startOf('week'), dayjs().endOf('week')],\n },\n];\n\ninterface FilterDateRangeProps extends BaseFilterProps {\n value?: [string, string] | null;\n onChange?: (value: [string, string] | null) => void;\n /** 默认区间:与默认相同时视为未筛选 */\n defaultValue?: [string, string];\n showQuickOptions?: boolean;\n quickOptions?: QuickOption[];\n}\n\nfunction isSameRange(a?: [string, string] | null, b?: [string, string]): boolean {\n if (!a?.[0] || !a?.[1]) return !b?.[0] || !b?.[1];\n if (!b?.[0] || !b?.[1]) return false;\n return a[0] === b[0] && a[1] === b[1];\n}\n\nconst FilterDateRange: React.FC<FilterDateRangeProps> = ({\n filterKey,\n label,\n value,\n onChange,\n defaultValue,\n showQuickOptions = true,\n quickOptions,\n active,\n hidden,\n}) => {\n const [open, setOpen] = useState(false);\n const [dates, setDates] = useState<[Dayjs | null, Dayjs | null] | null>(\n value ? [dayjs(value[0]), dayjs(value[1])] : null,\n );\n const [activeQuickKey, setActiveQuickKey] = useState<string | null>(null);\n\n const registerFn = useFilterRegister();\n\n const revertToCommitted = () => {\n if (value?.[0] && value?.[1]) {\n setDates([dayjs(value[0]), dayjs(value[1])]);\n } else {\n setDates(null);\n }\n setActiveQuickKey(null);\n };\n\n useEffect(() => {\n if (value?.[0] && value?.[1]) {\n setDates([dayjs(value[0]), dayjs(value[1])]);\n } else {\n setDates(null);\n }\n }, [value]);\n\n const hasNonDefaultValue = !!value?.[0] && !isSameRange(value, defaultValue);\n\n const valueLabel = useMemo(() => {\n if (!hasNonDefaultValue || !value?.[0] || !value?.[1]) return '';\n return `${value[0]} ~ ${value[1]}`;\n }, [hasNonDefaultValue, value]);\n\n useEffect(() => {\n if (!registerFn) return;\n if (resolveHidden(hidden)) {\n registerFn.unregister(filterKey);\n return;\n }\n if (valueLabel) {\n registerFn.register(filterKey, { label, valueLabel, onRemove: () => onChange?.(null) });\n } else {\n registerFn.unregister(filterKey);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [valueLabel, filterKey, label, hidden]);\n\n if (resolveHidden(hidden)) return null;\n\n const handleConfirm = () => {\n if (dates?.[0] && dates?.[1]) {\n onChange?.([dates[0].format('YYYY-MM-DD'), dates[1].format('YYYY-MM-DD')]);\n } else {\n onChange?.(null);\n }\n setOpen(false);\n };\n\n const handleDiscardDraft = () => {\n revertToCommitted();\n setOpen(false);\n };\n\n const handleOpenChange = (nextOpen: boolean) => {\n if (!nextOpen) {\n revertToCommitted();\n }\n setOpen(nextOpen);\n };\n\n const opts = quickOptions ?? (showQuickOptions ? BUILT_IN_OPTIONS : []);\n\n return (\n <FilterPopover\n label={label}\n active={active || hasNonDefaultValue}\n open={open}\n onOpenChange={handleOpenChange}\n onConfirm={handleConfirm}\n onReset={handleDiscardDraft}\n >\n {opts.length > 0 && (\n <div className={classNames('filter-date-range-quick-options', styles['filter-date-range-quick-options'])}>\n {opts.map((opt) => (\n <span\n key={opt.key}\n className={classNames('filter-date-range-quick-option', styles['filter-date-range-quick-option'],\n activeQuickKey === opt.key && 'filter-date-range-quick-option-active',\n activeQuickKey === opt.key && styles['filter-date-range-quick-option-active'],\n )}\n onClick={() => {\n const v = opt.getValue();\n if (v) {\n setDates(v);\n setActiveQuickKey(opt.key);\n }\n }}\n >\n {opt.label}\n </span>\n ))}\n </div>\n )}\n <RangePicker\n className={classNames('filter-date-range-picker', styles['filter-date-range-picker'])}\n value={dates}\n onChange={(vals) => {\n setDates(vals as [Dayjs | null, Dayjs | null] | null);\n setActiveQuickKey(null);\n }}\n />\n </FilterPopover>\n );\n};\n\nexport default FilterDateRange;\nexport type { FilterDateRangeProps, QuickOption };\n"],"names":["RangePicker","DatePicker","BUILT_IN_OPTIONS","dayjs","isSameRange","a","b","FilterDateRange","filterKey","label","value","onChange","defaultValue","showQuickOptions","quickOptions","active","hidden","open","setOpen","useState","dates","setDates","activeQuickKey","setActiveQuickKey","registerFn","useFilterRegister","revertToCommitted","useEffect","hasNonDefaultValue","valueLabel","useMemo","resolveHidden","handleConfirm","handleDiscardDraft","handleOpenChange","nextOpen","opts","jsxs","FilterPopover","jsx","classNames","styles","opt","v","vals"],"mappings":";;;;;;;;;AAUA,MAAM,EAAE,aA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;AAAA,YACxB;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { BaseFilterProps, FilterOption } from '../types';
|
|
3
|
+
type FilterSelectValue = string | number | (string | number)[] | undefined;
|
|
4
|
+
export type { FilterSelectValue };
|
|
3
5
|
interface FilterSelectProps extends BaseFilterProps {
|
|
4
6
|
options: FilterOption[];
|
|
5
|
-
value?:
|
|
6
|
-
onChange?: (value:
|
|
7
|
+
value?: FilterSelectValue;
|
|
8
|
+
onChange?: (value: FilterSelectValue) => void;
|
|
7
9
|
/** 默认值:与默认值相同时视为未筛选(不展示已选标签与选中态) */
|
|
8
10
|
defaultValue?: string | number;
|
|
11
|
+
/** 多选默认值:与默认集合相同时视为未筛选 */
|
|
12
|
+
defaultValues?: (string | number)[];
|
|
9
13
|
placeholder?: string;
|
|
10
14
|
searchable?: boolean;
|
|
11
15
|
/** 是否多选 */
|
|
@@ -1,149 +1,174 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Check as
|
|
3
|
-
import { Input as
|
|
4
|
-
import { useState as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { resolveFilterVisible as
|
|
8
|
-
import { useFilterRegister as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
const { Search:
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
return
|
|
1
|
+
import { jsxs as x, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { Check as Q, X as U } from "../../Icons/index.js";
|
|
3
|
+
import { Input as W, Checkbox as Y, Space as Z } from "antd";
|
|
4
|
+
import { useState as P, useRef as _, useMemo as j, useEffect as T } from "react";
|
|
5
|
+
import K from "../../Form/PersonOptionRow/index.js";
|
|
6
|
+
import V from "../FilterPopover/index.js";
|
|
7
|
+
import { resolveFilterVisible as z } from "../types.js";
|
|
8
|
+
import { useFilterRegister as ee } from "../useFilterState.js";
|
|
9
|
+
import f from "./style.module.scss.js";
|
|
10
|
+
import d from "classnames";
|
|
11
|
+
const { Search: re } = W;
|
|
12
|
+
function te(r) {
|
|
13
|
+
const t = [r.label];
|
|
14
|
+
return r.departmentName && t.push(r.departmentName), t.join(" · ");
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
return [
|
|
16
|
+
function se(r, t) {
|
|
17
|
+
const i = t.toLowerCase();
|
|
18
|
+
return [r.label, r.departmentName, r.email, r.phone, r.employeeId].filter(Boolean).some((c) => String(c).toLowerCase().includes(i));
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
if (
|
|
22
|
-
if (!
|
|
23
|
-
|
|
20
|
+
function ne(r, t) {
|
|
21
|
+
if (!(r != null && r.length) && !(t != null && t.length)) return !0;
|
|
22
|
+
if (!r || !t || r.length !== t.length) return !1;
|
|
23
|
+
const i = [...r].map(String).sort(), c = [...t].map(String).sort();
|
|
24
|
+
return i.every((n, o) => n === c[o]);
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
function B(r, t, i, c) {
|
|
27
|
+
if (c) {
|
|
28
|
+
const n = Array.isArray(r) ? r : r != null && r !== "" ? [r] : [];
|
|
29
|
+
return i != null && i.length && ne(n, i) ? [] : n;
|
|
30
|
+
}
|
|
31
|
+
if (!(t !== void 0 && r === t))
|
|
32
|
+
return r;
|
|
33
|
+
}
|
|
34
|
+
function ie(r, t, i, c) {
|
|
35
|
+
if (i) {
|
|
36
|
+
const o = r || [];
|
|
37
|
+
return o.length > 0 ? o.map((g) => {
|
|
38
|
+
var S;
|
|
39
|
+
return ((S = t.find((s) => s.value === g)) == null ? void 0 : S.label) ?? String(g);
|
|
40
|
+
}).join("、") : "";
|
|
41
|
+
}
|
|
42
|
+
if (r == null) return "";
|
|
43
|
+
const n = t.find((o) => o.value === r);
|
|
44
|
+
return n ? c ? te(n) : n.label : String(r);
|
|
45
|
+
}
|
|
46
|
+
const xe = ({
|
|
47
|
+
filterKey: r,
|
|
48
|
+
label: t,
|
|
49
|
+
options: i = [],
|
|
50
|
+
value: c,
|
|
30
51
|
onChange: n,
|
|
31
|
-
defaultValue:
|
|
32
|
-
|
|
52
|
+
defaultValue: o,
|
|
53
|
+
defaultValues: g,
|
|
54
|
+
searchable: S = !1,
|
|
33
55
|
multiple: s = !1,
|
|
34
|
-
variant:
|
|
56
|
+
variant: E = "default",
|
|
35
57
|
active: I,
|
|
36
|
-
hidden:
|
|
37
|
-
display:
|
|
58
|
+
hidden: A,
|
|
59
|
+
display: C
|
|
38
60
|
}) => {
|
|
39
|
-
const u =
|
|
40
|
-
|
|
41
|
-
),
|
|
42
|
-
|
|
43
|
-
const
|
|
61
|
+
const u = E === "person", [M, N] = P(!1), [k, b] = P(""), h = B(c, o, g, s), [l, p] = P(
|
|
62
|
+
h ?? (s ? [] : void 0)
|
|
63
|
+
), L = ee(), w = _(n);
|
|
64
|
+
w.current = n;
|
|
65
|
+
const D = j(
|
|
44
66
|
() => () => {
|
|
45
67
|
var e;
|
|
46
|
-
(e =
|
|
68
|
+
(e = w.current) == null || e.call(w, void 0);
|
|
47
69
|
},
|
|
48
70
|
[]
|
|
71
|
+
), F = () => {
|
|
72
|
+
p(h ?? (s ? [] : void 0)), b("");
|
|
73
|
+
};
|
|
74
|
+
T(() => {
|
|
75
|
+
const e = B(c, o, g, s);
|
|
76
|
+
p(e ?? (s ? [] : void 0)), (e == null || Array.isArray(e) && e.length === 0) && b("");
|
|
77
|
+
}, [c, o, g, s]);
|
|
78
|
+
const y = j(
|
|
79
|
+
() => ie(h, i, s, u),
|
|
80
|
+
[i, h, s, u]
|
|
49
81
|
);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const g = P(() => {
|
|
55
|
-
if (s) {
|
|
56
|
-
const c = r || [];
|
|
57
|
-
return c.length > 0 ? c.map((l) => {
|
|
58
|
-
var k;
|
|
59
|
-
return ((k = o.find((G) => G.value === l)) == null ? void 0 : k.label) ?? String(l);
|
|
60
|
-
}).join("、") : "";
|
|
61
|
-
}
|
|
62
|
-
if (r == null) return "";
|
|
63
|
-
const e = o.find((c) => c.value === r);
|
|
64
|
-
return e ? u ? V(e) : e.label : String(r);
|
|
65
|
-
}, [o, r, s, u]);
|
|
66
|
-
if (j(() => {
|
|
67
|
-
if (!S) return;
|
|
68
|
-
if (!A({ display: L, hidden: w }, { filterKey: t, label: i, value: m })) {
|
|
69
|
-
S.unregister(t);
|
|
82
|
+
if (T(() => {
|
|
83
|
+
if (!L) return;
|
|
84
|
+
if (!z({ display: C, hidden: A }, { filterKey: r, label: t, value: c })) {
|
|
85
|
+
L.unregister(r);
|
|
70
86
|
return;
|
|
71
87
|
}
|
|
72
|
-
|
|
73
|
-
label:
|
|
74
|
-
valueLabel:
|
|
75
|
-
onRemove:
|
|
76
|
-
}) :
|
|
77
|
-
}, [
|
|
78
|
-
const
|
|
79
|
-
(e) => u ?
|
|
80
|
-
) :
|
|
81
|
-
n == null || n(
|
|
88
|
+
y ? L.register(r, {
|
|
89
|
+
label: t,
|
|
90
|
+
valueLabel: y,
|
|
91
|
+
onRemove: D
|
|
92
|
+
}) : L.unregister(r);
|
|
93
|
+
}, [y, r, t, A, C, D]), !z({ display: C, hidden: A }, { filterKey: r, label: t, value: c })) return null;
|
|
94
|
+
const R = k ? i.filter(
|
|
95
|
+
(e) => u ? se(e, k) : e.label.toLowerCase().includes(k.toLowerCase())
|
|
96
|
+
) : i, q = () => {
|
|
97
|
+
n == null || n(l), N(!1);
|
|
82
98
|
}, X = () => {
|
|
83
|
-
|
|
99
|
+
F(), N(!1);
|
|
84
100
|
}, $ = (e) => {
|
|
101
|
+
!e && s && F(), N(e);
|
|
102
|
+
}, G = (e) => {
|
|
85
103
|
if (!s) {
|
|
86
|
-
const
|
|
87
|
-
let
|
|
88
|
-
|
|
104
|
+
const a = o !== void 0 && e === o;
|
|
105
|
+
let v;
|
|
106
|
+
l === e || a ? v = void 0 : v = e, p(v), n == null || n(v), N(!1);
|
|
89
107
|
}
|
|
90
|
-
},
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
-
|
|
108
|
+
}, O = (e) => {
|
|
109
|
+
const a = l || [], v = a.includes(e) ? a.filter((J) => J !== e) : [...a, e];
|
|
110
|
+
p(v);
|
|
111
|
+
}, H = s ? Array.isArray(h) && h.length > 0 : h != null && h !== "";
|
|
112
|
+
return /* @__PURE__ */ x(
|
|
113
|
+
V,
|
|
96
114
|
{
|
|
97
|
-
label:
|
|
98
|
-
active: I ||
|
|
115
|
+
label: t,
|
|
116
|
+
active: I || H,
|
|
99
117
|
open: M,
|
|
100
|
-
onOpenChange:
|
|
101
|
-
onConfirm: s ?
|
|
118
|
+
onOpenChange: $,
|
|
119
|
+
onConfirm: s ? q : void 0,
|
|
102
120
|
onReset: s ? X : void 0,
|
|
103
121
|
children: [
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
S && /* @__PURE__ */ m(
|
|
123
|
+
re,
|
|
106
124
|
{
|
|
107
|
-
placeholder: `搜索${
|
|
125
|
+
placeholder: `搜索${t}`,
|
|
108
126
|
allowClear: !0,
|
|
109
127
|
size: "middle",
|
|
110
|
-
className:
|
|
111
|
-
value:
|
|
112
|
-
onChange: (e) =>
|
|
128
|
+
className: d("filter-select-search", f["filter-select-search"]),
|
|
129
|
+
value: k,
|
|
130
|
+
onChange: (e) => b(e.target.value)
|
|
113
131
|
}
|
|
114
132
|
),
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
|
|
133
|
+
/* @__PURE__ */ x("div", { className: d("filter-select-options", f["filter-select-options"]), children: [
|
|
134
|
+
R.map((e) => /* @__PURE__ */ x(
|
|
117
135
|
"div",
|
|
118
136
|
{
|
|
119
|
-
className:
|
|
137
|
+
className: d(
|
|
120
138
|
"filter-select-option",
|
|
121
|
-
|
|
122
|
-
!s &&
|
|
139
|
+
f["filter-select-option"],
|
|
140
|
+
!s && l === e.value && d("filter-select-option-selected", f["filter-select-option-selected"])
|
|
123
141
|
),
|
|
124
|
-
onClick: () =>
|
|
142
|
+
onClick: () => s ? O(e.value) : G(e.value),
|
|
125
143
|
children: [
|
|
126
|
-
s && /* @__PURE__ */
|
|
127
|
-
|
|
128
|
-
|
|
144
|
+
s && /* @__PURE__ */ m(
|
|
145
|
+
Y,
|
|
146
|
+
{
|
|
147
|
+
checked: l == null ? void 0 : l.includes(e.value),
|
|
148
|
+
onChange: () => O(e.value),
|
|
149
|
+
onClick: (a) => a.stopPropagation()
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
u ? /* @__PURE__ */ m(K, { option: e }) : /* @__PURE__ */ m("span", { children: e.label }),
|
|
153
|
+
!s && !u && l === e.value && /* @__PURE__ */ m(Q, { className: d("filter-select-option-check", f["filter-select-option-check"]) })
|
|
129
154
|
]
|
|
130
155
|
},
|
|
131
156
|
String(e.value)
|
|
132
157
|
)),
|
|
133
|
-
|
|
158
|
+
R.length === 0 && /* @__PURE__ */ m("div", { className: d("filter-select-empty", f["filter-select-empty"]), children: "暂无数据" })
|
|
134
159
|
] }),
|
|
135
|
-
s && (
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
const
|
|
139
|
-
return /* @__PURE__ */
|
|
160
|
+
s && (l == null ? void 0 : l.length) > 0 && /* @__PURE__ */ x("div", { className: d("filter-select-selected-bar", f["filter-select-selected-bar"]), children: [
|
|
161
|
+
/* @__PURE__ */ m("div", { className: d("filter-select-selected-label", f["filter-select-selected-label"]), children: "已选:" }),
|
|
162
|
+
/* @__PURE__ */ m(Z, { size: [4, 4], wrap: !0, children: l.map((e) => {
|
|
163
|
+
const a = i.find((v) => v.value === e);
|
|
164
|
+
return /* @__PURE__ */ x(
|
|
140
165
|
"span",
|
|
141
166
|
{
|
|
142
|
-
className:
|
|
143
|
-
onClick: () =>
|
|
167
|
+
className: d("filter-select-selected-tag", f["filter-select-selected-tag"]),
|
|
168
|
+
onClick: () => O(e),
|
|
144
169
|
children: [
|
|
145
|
-
(
|
|
146
|
-
/* @__PURE__ */
|
|
170
|
+
(a == null ? void 0 : a.label) ?? String(e),
|
|
171
|
+
/* @__PURE__ */ m(U, { className: d("filter-select-selected-remove", f["filter-select-selected-remove"]) })
|
|
147
172
|
]
|
|
148
173
|
},
|
|
149
174
|
String(e)
|
|
@@ -155,6 +180,6 @@ const me = ({
|
|
|
155
180
|
);
|
|
156
181
|
};
|
|
157
182
|
export {
|
|
158
|
-
|
|
183
|
+
xe as default
|
|
159
184
|
};
|
|
160
185
|
//# sourceMappingURL=index.js.map
|