@hkyhy/marsun-components-core 0.1.18 → 0.1.21

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.
Files changed (200) hide show
  1. package/dist/components/AgentHub/Chat/Detail/ChatAgentFab/index.d.ts +24 -0
  2. package/dist/components/AgentHub/Chat/Detail/ChatAgentFab/index.js +95 -0
  3. package/dist/components/AgentHub/Chat/Detail/ChatAgentFab/index.js.map +1 -0
  4. package/dist/components/AgentHub/Chat/Detail/ChatAgentFab/style.module.scss.js +15 -0
  5. package/dist/components/AgentHub/Chat/Detail/ChatAgentFab/style.module.scss.js.map +1 -0
  6. package/dist/components/AgentHub/Chat/Detail/ChatAgentFabLayout/index.d.ts +16 -0
  7. package/dist/components/AgentHub/Chat/Detail/ChatAgentFabLayout/index.js +37 -0
  8. package/dist/components/AgentHub/Chat/Detail/ChatAgentFabLayout/index.js.map +1 -0
  9. package/dist/components/AgentHub/Chat/Detail/ChatAgentFabLayout/style.module.scss.js +9 -0
  10. package/dist/components/AgentHub/Chat/Detail/ChatAgentFabLayout/style.module.scss.js.map +1 -0
  11. package/dist/components/AgentHub/Chat/Detail/ChatFollowUpSuggestions/index.d.ts +14 -0
  12. package/dist/components/AgentHub/Chat/Detail/ChatFollowUpSuggestions/index.js +79 -0
  13. package/dist/components/AgentHub/Chat/Detail/ChatFollowUpSuggestions/index.js.map +1 -0
  14. package/dist/components/AgentHub/Chat/Detail/ChatFollowUpSuggestions/style.module.scss.js +18 -0
  15. package/dist/components/AgentHub/Chat/Detail/ChatFollowUpSuggestions/style.module.scss.js.map +1 -0
  16. package/dist/components/AgentHub/Chat/Detail/ChatInput/index.d.ts +2 -0
  17. package/dist/components/AgentHub/Chat/Detail/ChatInput/index.js +60 -49
  18. package/dist/components/AgentHub/Chat/Detail/ChatInput/index.js.map +1 -1
  19. package/dist/components/AgentHub/Chat/Detail/ChatInput/style.module.scss.js +7 -6
  20. package/dist/components/AgentHub/Chat/Detail/ChatInput/style.module.scss.js.map +1 -1
  21. package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.d.ts +17 -4
  22. package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.js +104 -68
  23. package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.js.map +1 -1
  24. package/dist/components/AgentHub/Chat/Detail/ChatPanel/style.module.scss.js +13 -8
  25. package/dist/components/AgentHub/Chat/Detail/ChatPanel/style.module.scss.js.map +1 -1
  26. package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/index.js +5 -4
  27. package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/index.js.map +1 -1
  28. package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/style.module.scss.js +2 -2
  29. package/dist/components/AgentHub/Chat/Detail/ChatWidgetBlock/ChatWidgetSparkline.d.ts +7 -0
  30. package/dist/components/AgentHub/Chat/Detail/ChatWidgetBlock/ChatWidgetSparkline.js +55 -0
  31. package/dist/components/AgentHub/Chat/Detail/ChatWidgetBlock/ChatWidgetSparkline.js.map +1 -0
  32. package/dist/components/AgentHub/Chat/Detail/ChatWidgetBlock/index.d.ts +10 -0
  33. package/dist/components/AgentHub/Chat/Detail/ChatWidgetBlock/index.js +120 -0
  34. package/dist/components/AgentHub/Chat/Detail/ChatWidgetBlock/index.js.map +1 -0
  35. package/dist/components/AgentHub/Chat/Detail/ChatWidgetBlock/style.module.scss.js +32 -0
  36. package/dist/components/AgentHub/Chat/Detail/ChatWidgetBlock/style.module.scss.js.map +1 -0
  37. package/dist/components/AgentHub/Chat/Detail/CitationContent/style.module.scss.js +2 -2
  38. package/dist/components/AgentHub/Chat/Detail/MessageItem/index.js +130 -114
  39. package/dist/components/AgentHub/Chat/Detail/MessageItem/index.js.map +1 -1
  40. package/dist/components/AgentHub/Chat/Detail/MessageItem/style.module.scss.js +20 -18
  41. package/dist/components/AgentHub/Chat/Detail/MessageItem/style.module.scss.js.map +1 -1
  42. package/dist/components/AgentHub/Chat/Detail/index.d.ts +8 -0
  43. package/dist/components/AgentHub/Chat/hooks/index.d.ts +2 -0
  44. package/dist/components/AgentHub/Chat/hooks/useCitationPanel.d.ts +11 -0
  45. package/dist/components/AgentHub/Chat/hooks/useCitationPanel.js +22 -0
  46. package/dist/components/AgentHub/Chat/hooks/useCitationPanel.js.map +1 -0
  47. package/dist/components/AgentHub/types.d.ts +21 -0
  48. package/dist/components/Auth/ProtectedRoute.js +20 -14
  49. package/dist/components/Auth/ProtectedRoute.js.map +1 -1
  50. package/dist/components/File/index.d.ts +2 -0
  51. package/dist/components/File/utils/download.d.ts +20 -0
  52. package/dist/components/File/utils/download.js +30 -0
  53. package/dist/components/File/utils/download.js.map +1 -0
  54. package/dist/components/Filter/FilterDateRange/index.d.ts +6 -1
  55. package/dist/components/Filter/FilterDateRange/index.js +84 -62
  56. package/dist/components/Filter/FilterDateRange/index.js.map +1 -1
  57. package/dist/components/Filter/types.d.ts +1 -0
  58. package/dist/components/Filter/types.js.map +1 -1
  59. package/dist/components/Icons/index.d.ts +3 -1
  60. package/dist/components/Icons/index.js +157 -151
  61. package/dist/components/Icons/index.js.map +1 -1
  62. package/dist/index.d.ts +14 -0
  63. package/dist/index.js +377 -298
  64. package/dist/index.js.map +1 -1
  65. package/dist/marsun-components-core.css +1 -1
  66. package/dist/node_modules/axios/index.js +41 -0
  67. package/dist/node_modules/axios/index.js.map +1 -0
  68. package/dist/node_modules/axios/lib/adapters/adapters.js +66 -0
  69. package/dist/node_modules/axios/lib/adapters/adapters.js.map +1 -0
  70. package/dist/node_modules/axios/lib/adapters/fetch.js +324 -0
  71. package/dist/node_modules/axios/lib/adapters/fetch.js.map +1 -0
  72. package/dist/node_modules/axios/lib/adapters/xhr.js +86 -0
  73. package/dist/node_modules/axios/lib/adapters/xhr.js.map +1 -0
  74. package/dist/node_modules/axios/lib/axios.js +47 -0
  75. package/dist/node_modules/axios/lib/axios.js.map +1 -0
  76. package/dist/node_modules/axios/lib/cancel/CancelToken.js +78 -0
  77. package/dist/node_modules/axios/lib/cancel/CancelToken.js.map +1 -0
  78. package/dist/node_modules/axios/lib/cancel/CanceledError.js +19 -0
  79. package/dist/node_modules/axios/lib/cancel/CanceledError.js.map +1 -0
  80. package/dist/node_modules/axios/lib/cancel/isCancel.js +7 -0
  81. package/dist/node_modules/axios/lib/cancel/isCancel.js.map +1 -0
  82. package/dist/node_modules/axios/lib/core/Axios.js +168 -0
  83. package/dist/node_modules/axios/lib/core/Axios.js.map +1 -0
  84. package/dist/node_modules/axios/lib/core/AxiosError.js +110 -0
  85. package/dist/node_modules/axios/lib/core/AxiosError.js.map +1 -0
  86. package/dist/node_modules/axios/lib/core/AxiosHeaders.js +193 -0
  87. package/dist/node_modules/axios/lib/core/AxiosHeaders.js.map +1 -0
  88. package/dist/node_modules/axios/lib/core/InterceptorManager.js +60 -0
  89. package/dist/node_modules/axios/lib/core/InterceptorManager.js.map +1 -0
  90. package/dist/node_modules/axios/lib/core/buildFullPath.js +30 -0
  91. package/dist/node_modules/axios/lib/core/buildFullPath.js.map +1 -0
  92. package/dist/node_modules/axios/lib/core/dispatchRequest.js +43 -0
  93. package/dist/node_modules/axios/lib/core/dispatchRequest.js.map +1 -0
  94. package/dist/node_modules/axios/lib/core/mergeConfig.js +94 -0
  95. package/dist/node_modules/axios/lib/core/mergeConfig.js.map +1 -0
  96. package/dist/node_modules/axios/lib/core/settle.js +15 -0
  97. package/dist/node_modules/axios/lib/core/settle.js.map +1 -0
  98. package/dist/node_modules/axios/lib/core/transformData.js +14 -0
  99. package/dist/node_modules/axios/lib/core/transformData.js.map +1 -0
  100. package/dist/node_modules/axios/lib/defaults/index.js +96 -0
  101. package/dist/node_modules/axios/lib/defaults/index.js.map +1 -0
  102. package/dist/node_modules/axios/lib/defaults/transitional.js +12 -0
  103. package/dist/node_modules/axios/lib/defaults/transitional.js.map +1 -0
  104. package/dist/node_modules/axios/lib/env/data.js +5 -0
  105. package/dist/node_modules/axios/lib/env/data.js.map +1 -0
  106. package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +31 -0
  107. package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js.map +1 -0
  108. package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +78 -0
  109. package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js.map +1 -0
  110. package/dist/node_modules/axios/lib/helpers/bind.js +9 -0
  111. package/dist/node_modules/axios/lib/helpers/bind.js.map +1 -0
  112. package/dist/node_modules/axios/lib/helpers/buildURL.js +24 -0
  113. package/dist/node_modules/axios/lib/helpers/buildURL.js.map +1 -0
  114. package/dist/node_modules/axios/lib/helpers/combineURLs.js +7 -0
  115. package/dist/node_modules/axios/lib/helpers/combineURLs.js.map +1 -0
  116. package/dist/node_modules/axios/lib/helpers/composeSignals.js +33 -0
  117. package/dist/node_modules/axios/lib/helpers/composeSignals.js.map +1 -0
  118. package/dist/node_modules/axios/lib/helpers/cookies.js +44 -0
  119. package/dist/node_modules/axios/lib/helpers/cookies.js.map +1 -0
  120. package/dist/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +43 -0
  121. package/dist/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js.map +1 -0
  122. package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +47 -0
  123. package/dist/node_modules/axios/lib/helpers/formDataToJSON.js.map +1 -0
  124. package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +7 -0
  125. package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js.map +1 -0
  126. package/dist/node_modules/axios/lib/helpers/isAxiosError.js +8 -0
  127. package/dist/node_modules/axios/lib/helpers/isAxiosError.js.map +1 -0
  128. package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +9 -0
  129. package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js.map +1 -0
  130. package/dist/node_modules/axios/lib/helpers/null.js +5 -0
  131. package/dist/node_modules/axios/lib/helpers/null.js.map +1 -0
  132. package/dist/node_modules/axios/lib/helpers/parseHeaders.js +31 -0
  133. package/dist/node_modules/axios/lib/helpers/parseHeaders.js.map +1 -0
  134. package/dist/node_modules/axios/lib/helpers/parseProtocol.js +8 -0
  135. package/dist/node_modules/axios/lib/helpers/parseProtocol.js.map +1 -0
  136. package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +41 -0
  137. package/dist/node_modules/axios/lib/helpers/progressEventReducer.js.map +1 -0
  138. package/dist/node_modules/axios/lib/helpers/resolveConfig.js +54 -0
  139. package/dist/node_modules/axios/lib/helpers/resolveConfig.js.map +1 -0
  140. package/dist/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +34 -0
  141. package/dist/node_modules/axios/lib/helpers/sanitizeHeaderValue.js.map +1 -0
  142. package/dist/node_modules/axios/lib/helpers/speedometer.js +20 -0
  143. package/dist/node_modules/axios/lib/helpers/speedometer.js.map +1 -0
  144. package/dist/node_modules/axios/lib/helpers/spread.js +9 -0
  145. package/dist/node_modules/axios/lib/helpers/spread.js.map +1 -0
  146. package/dist/node_modules/axios/lib/helpers/throttle.js +16 -0
  147. package/dist/node_modules/axios/lib/helpers/throttle.js.map +1 -0
  148. package/dist/node_modules/axios/lib/helpers/toFormData.js +115 -0
  149. package/dist/node_modules/axios/lib/helpers/toFormData.js.map +1 -0
  150. package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +15 -0
  151. package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js.map +1 -0
  152. package/dist/node_modules/axios/lib/helpers/trackStream.js +67 -0
  153. package/dist/node_modules/axios/lib/helpers/trackStream.js.map +1 -0
  154. package/dist/node_modules/axios/lib/helpers/validator.js +58 -0
  155. package/dist/node_modules/axios/lib/helpers/validator.js.map +1 -0
  156. package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js +5 -0
  157. package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js.map +1 -0
  158. package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js +5 -0
  159. package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js.map +1 -0
  160. package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +6 -0
  161. package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js.map +1 -0
  162. package/dist/node_modules/axios/lib/platform/browser/index.js +16 -0
  163. package/dist/node_modules/axios/lib/platform/browser/index.js.map +1 -0
  164. package/dist/node_modules/axios/lib/platform/common/utils.js +10 -0
  165. package/dist/node_modules/axios/lib/platform/common/utils.js.map +1 -0
  166. package/dist/node_modules/axios/lib/platform/index.js +10 -0
  167. package/dist/node_modules/axios/lib/platform/index.js.map +1 -0
  168. package/dist/node_modules/axios/lib/utils.js +303 -0
  169. package/dist/node_modules/axios/lib/utils.js.map +1 -0
  170. package/dist/styles/global.css +1 -1
  171. package/dist/types/auth.d.ts +18 -0
  172. package/dist/utils/authRedirect.d.ts +6 -0
  173. package/dist/utils/authRedirect.js +33 -0
  174. package/dist/utils/authRedirect.js.map +1 -0
  175. package/dist/utils/createMarsunRequest.d.ts +26 -0
  176. package/dist/utils/createMarsunRequest.js +53 -0
  177. package/dist/utils/createMarsunRequest.js.map +1 -0
  178. package/dist/utils/date.d.ts +16 -0
  179. package/dist/utils/date.js +36 -0
  180. package/dist/utils/date.js.map +1 -0
  181. package/dist/utils/department/departmentPath.d.ts +18 -0
  182. package/dist/utils/department/departmentPath.js +63 -0
  183. package/dist/utils/department/departmentPath.js.map +1 -0
  184. package/dist/utils/department/departmentScope.d.ts +20 -0
  185. package/dist/utils/department/departmentScope.js +63 -0
  186. package/dist/utils/department/departmentScope.js.map +1 -0
  187. package/dist/utils/department/types.d.ts +12 -0
  188. package/dist/utils/permissionStorage.d.ts +13 -0
  189. package/dist/utils/permissionStorage.js +43 -0
  190. package/dist/utils/permissionStorage.js.map +1 -0
  191. package/dist/utils/personOption.d.ts +49 -0
  192. package/dist/utils/personOption.js +90 -0
  193. package/dist/utils/personOption.js.map +1 -0
  194. package/dist/utils/sessionActivity.d.ts +5 -0
  195. package/dist/utils/sessionActivity.js +18 -0
  196. package/dist/utils/sessionActivity.js.map +1 -0
  197. package/dist/utils/user/employeeId.d.ts +8 -0
  198. package/dist/utils/user/employeeId.js +14 -0
  199. package/dist/utils/user/employeeId.js.map +1 -0
  200. package/package.json +26 -1
@@ -0,0 +1,22 @@
1
+ import { useState as e, useCallback as i } from "react";
2
+ function f() {
3
+ const [o, t] = e(!1), [s, n] = e([]), [l, a] = e(), c = i(() => {
4
+ t(!1), n([]), a(void 0);
5
+ }, []), C = i((d, h) => {
6
+ n(d), a(h), t(!0);
7
+ }, []), r = i(() => {
8
+ t(!1);
9
+ }, []);
10
+ return {
11
+ citationOpen: o,
12
+ panelCitations: s,
13
+ highlightedCitationIndex: l,
14
+ handleCitationClick: C,
15
+ closeCitationPanel: r,
16
+ resetCitationState: c
17
+ };
18
+ }
19
+ export {
20
+ f as useCitationPanel
21
+ };
22
+ //# sourceMappingURL=useCitationPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCitationPanel.js","sources":["../../../../../src/components/AgentHub/Chat/hooks/useCitationPanel.ts"],"sourcesContent":["import type { Citation } from '@/components/AgentHub/types';\nimport { useCallback, useState } from 'react';\n\nexport interface UseCitationPanelResult {\n citationOpen: boolean;\n panelCitations: Citation[];\n highlightedCitationIndex: number | undefined;\n handleCitationClick: (items: Citation[], index?: number) => void;\n closeCitationPanel: () => void;\n resetCitationState: () => void;\n}\n\n/** FAB / 会话布局:点击消息角标打开 CitationPanel 的受控状态 */\nexport function useCitationPanel(): UseCitationPanelResult {\n const [citationOpen, setCitationOpen] = useState(false);\n const [panelCitations, setPanelCitations] = useState<Citation[]>([]);\n const [highlightedCitationIndex, setHighlightedCitationIndex] = useState<number | undefined>();\n\n const resetCitationState = useCallback(() => {\n setCitationOpen(false);\n setPanelCitations([]);\n setHighlightedCitationIndex(undefined);\n }, []);\n\n const handleCitationClick = useCallback((items: Citation[], index?: number) => {\n setPanelCitations(items);\n setHighlightedCitationIndex(index);\n setCitationOpen(true);\n }, []);\n\n const closeCitationPanel = useCallback(() => {\n setCitationOpen(false);\n }, []);\n\n return {\n citationOpen,\n panelCitations,\n highlightedCitationIndex,\n handleCitationClick,\n closeCitationPanel,\n resetCitationState,\n };\n}\n"],"names":["useCitationPanel","citationOpen","setCitationOpen","useState","panelCitations","setPanelCitations","highlightedCitationIndex","setHighlightedCitationIndex","resetCitationState","useCallback","handleCitationClick","items","index","closeCitationPanel"],"mappings":";AAaO,SAASA,IAA2C;AACzD,QAAM,CAACC,GAAcC,CAAe,IAAIC,EAAS,EAAK,GAChD,CAACC,GAAgBC,CAAiB,IAAIF,EAAqB,CAAA,CAAE,GAC7D,CAACG,GAA0BC,CAA2B,IAAIJ,EAAA,GAE1DK,IAAqBC,EAAY,MAAM;AAC3C,IAAAP,EAAgB,EAAK,GACrBG,EAAkB,CAAA,CAAE,GACpBE,EAA4B,MAAS;AAAA,EACvC,GAAG,CAAA,CAAE,GAECG,IAAsBD,EAAY,CAACE,GAAmBC,MAAmB;AAC7E,IAAAP,EAAkBM,CAAK,GACvBJ,EAA4BK,CAAK,GACjCV,EAAgB,EAAI;AAAA,EACtB,GAAG,CAAA,CAAE,GAECW,IAAqBJ,EAAY,MAAM;AAC3C,IAAAP,EAAgB,EAAK;AAAA,EACvB,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL,cAAAD;AAAA,IACA,gBAAAG;AAAA,IACA,0BAAAE;AAAA,IACA,qBAAAI;AAAA,IACA,oBAAAG;AAAA,IACA,oBAAAL;AAAA,EAAA;AAEJ;"}
@@ -21,8 +21,29 @@ export interface ChatMessage {
21
21
  thinking?: string;
22
22
  streaming?: boolean;
23
23
  thumbup?: boolean | null;
24
+ widgets?: ChatWidget[];
24
25
  [key: string]: unknown;
25
26
  }
27
+ export interface ChatWidgetSeries {
28
+ name?: string;
29
+ x?: string[];
30
+ y?: number[];
31
+ color?: string;
32
+ }
33
+ export interface ChatWidget {
34
+ type: string;
35
+ title?: string;
36
+ series?: ChatWidgetSeries[];
37
+ categories?: string[];
38
+ columns?: {
39
+ key: string;
40
+ label: string;
41
+ width?: number;
42
+ }[];
43
+ rows?: Record<string, unknown>[];
44
+ items?: Record<string, unknown>[];
45
+ meta?: Record<string, unknown>;
46
+ }
26
47
  export interface ChatSession {
27
48
  id: string;
28
49
  title?: string;
@@ -1,21 +1,27 @@
1
1
  import { jsx as t, Fragment as f } from "react/jsx-runtime";
2
- import { useLocation as $, Navigate as c } from "react-router-dom";
3
- import { useMarsunAuth as g } from "../../provider/context.js";
4
- const x = ({
5
- roles: e,
6
- permission: u,
7
- loginPath: i = "/login",
2
+ import { buildLoginPath as d, buildLocationRedirectUrl as g } from "../../utils/authRedirect.js";
3
+ import { useLocation as h, Navigate as i } from "react-router-dom";
4
+ import { useMarsunAuth as l } from "../../provider/context.js";
5
+ const j = ({
6
+ roles: r,
7
+ permission: n,
8
+ loginPath: c = "/login",
8
9
  fallbackPath: a = "/",
9
- children: p
10
+ children: m
10
11
  }) => {
11
- const { isAuthenticated: m, hasAnyRole: r, hasPermission: o } = g(), n = $();
12
- if (!m) {
13
- const d = encodeURIComponent(`${n.pathname}${n.search}${n.hash}`);
14
- return /* @__PURE__ */ t(c, { to: `${i}?redirect=${d}`, replace: !0 });
15
- }
16
- return e && e.length > 0 && !(r != null && r(e)) ? /* @__PURE__ */ t(c, { to: a, replace: !0 }) : u && !(o != null && o(u)) ? /* @__PURE__ */ t(c, { to: a, replace: !0 }) : /* @__PURE__ */ t(f, { children: p });
12
+ const { isAuthenticated: p, hasAnyRole: e, hasPermission: o } = l(), u = h();
13
+ return p ? r && r.length > 0 && !(e != null && e(r)) ? /* @__PURE__ */ t(i, { to: a, replace: !0 }) : n && !(o != null && o(n)) ? /* @__PURE__ */ t(i, { to: a, replace: !0 }) : /* @__PURE__ */ t(f, { children: m }) : /* @__PURE__ */ t(
14
+ i,
15
+ {
16
+ to: d(
17
+ g(u.pathname, u.search, u.hash),
18
+ c
19
+ ),
20
+ replace: !0
21
+ }
22
+ );
17
23
  };
18
24
  export {
19
- x as default
25
+ j as default
20
26
  };
21
27
  //# sourceMappingURL=ProtectedRoute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProtectedRoute.js","sources":["../../../src/components/Auth/ProtectedRoute.tsx"],"sourcesContent":["import { useMarsunAuth } from '@/provider';\nimport React from 'react';\nimport { Navigate, useLocation } from 'react-router-dom';\n\nexport interface ProtectedRouteProps {\n roles?: string[];\n permission?: string;\n loginPath?: string;\n fallbackPath?: string;\n children: React.ReactNode;\n}\n\nconst ProtectedRoute: React.FC<ProtectedRouteProps> = ({\n roles,\n permission,\n loginPath = '/login',\n fallbackPath = '/',\n children,\n}) => {\n const { isAuthenticated, hasAnyRole, hasPermission } = useMarsunAuth();\n const location = useLocation();\n\n if (!isAuthenticated) {\n const redirect = encodeURIComponent(`${location.pathname}${location.search}${location.hash}`);\n return <Navigate to={`${loginPath}?redirect=${redirect}`} replace />;\n }\n\n if (roles && roles.length > 0 && !hasAnyRole?.(roles)) {\n return <Navigate to={fallbackPath} replace />;\n }\n\n if (permission && !hasPermission?.(permission)) {\n return <Navigate to={fallbackPath} replace />;\n }\n\n return <>{children}</>;\n};\n\nexport default ProtectedRoute;\n"],"names":["ProtectedRoute","roles","permission","loginPath","fallbackPath","children","isAuthenticated","hasAnyRole","hasPermission","useMarsunAuth","location","useLocation","redirect","jsx","Navigate"],"mappings":";;;AAYA,MAAMA,IAAgD,CAAC;AAAA,EACrD,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,cAAAC,IAAe;AAAA,EACf,UAAAC;AACF,MAAM;AACJ,QAAM,EAAE,iBAAAC,GAAiB,YAAAC,GAAY,eAAAC,EAAA,IAAkBC,EAAA,GACjDC,IAAWC,EAAA;AAEjB,MAAI,CAACL,GAAiB;AACpB,UAAMM,IAAW,mBAAmB,GAAGF,EAAS,QAAQ,GAAGA,EAAS,MAAM,GAAGA,EAAS,IAAI,EAAE;AAC5F,WAAO,gBAAAG,EAACC,KAAS,IAAI,GAAGX,CAAS,aAAaS,CAAQ,IAAI,SAAO,GAAA,CAAC;AAAA,EACpE;AAEA,SAAIX,KAASA,EAAM,SAAS,KAAK,EAACM,KAAA,QAAAA,EAAaN,MACtC,gBAAAY,EAACC,GAAA,EAAS,IAAIV,GAAc,SAAO,IAAC,IAGzCF,KAAc,EAACM,KAAA,QAAAA,EAAgBN,MAC1B,gBAAAW,EAACC,GAAA,EAAS,IAAIV,GAAc,SAAO,IAAC,2BAGnC,UAAAC,GAAS;AACrB;"}
1
+ {"version":3,"file":"ProtectedRoute.js","sources":["../../../src/components/Auth/ProtectedRoute.tsx"],"sourcesContent":["import { useMarsunAuth } from '@/provider';\nimport { buildLocationRedirectUrl, buildLoginPath } from '@/utils/authRedirect';\nimport React from 'react';\nimport { Navigate, useLocation } from 'react-router-dom';\n\nexport interface ProtectedRouteProps {\n roles?: string[];\n permission?: string;\n loginPath?: string;\n fallbackPath?: string;\n children: React.ReactNode;\n}\n\nconst ProtectedRoute: React.FC<ProtectedRouteProps> = ({\n roles,\n permission,\n loginPath = '/login',\n fallbackPath = '/',\n children,\n}) => {\n const { isAuthenticated, hasAnyRole, hasPermission } = useMarsunAuth();\n const location = useLocation();\n\n if (!isAuthenticated) {\n return (\n <Navigate\n to={buildLoginPath(\n buildLocationRedirectUrl(location.pathname, location.search, location.hash),\n loginPath,\n )}\n replace\n />\n );\n }\n\n if (roles && roles.length > 0 && !hasAnyRole?.(roles)) {\n return <Navigate to={fallbackPath} replace />;\n }\n\n if (permission && !hasPermission?.(permission)) {\n return <Navigate to={fallbackPath} replace />;\n }\n\n return <>{children}</>;\n};\n\nexport default ProtectedRoute;\n"],"names":["ProtectedRoute","roles","permission","loginPath","fallbackPath","children","isAuthenticated","hasAnyRole","hasPermission","useMarsunAuth","location","useLocation","jsx","Navigate","buildLoginPath","buildLocationRedirectUrl"],"mappings":";;;;AAaA,MAAMA,IAAgD,CAAC;AAAA,EACrD,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,cAAAC,IAAe;AAAA,EACf,UAAAC;AACF,MAAM;AACJ,QAAM,EAAE,iBAAAC,GAAiB,YAAAC,GAAY,eAAAC,EAAA,IAAkBC,EAAA,GACjDC,IAAWC,EAAA;AAEjB,SAAKL,IAYDL,KAASA,EAAM,SAAS,KAAK,EAACM,KAAA,QAAAA,EAAaN,MACtC,gBAAAW,EAACC,GAAA,EAAS,IAAIT,GAAc,SAAO,IAAC,IAGzCF,KAAc,EAACM,KAAA,QAAAA,EAAgBN,MAC1B,gBAAAU,EAACC,GAAA,EAAS,IAAIT,GAAc,SAAO,IAAC,2BAGnC,UAAAC,GAAS,IAlBf,gBAAAO;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,IAAIC;AAAA,QACFC,EAAyBL,EAAS,UAAUA,EAAS,QAAQA,EAAS,IAAI;AAAA,QAC1EP;AAAA,MAAA;AAAA,MAEF,SAAO;AAAA,IAAA;AAAA,EAAA;AAcf;"}
@@ -10,3 +10,5 @@ export { default as FilePreviewModal } from './FilePreviewModal';
10
10
  export type { FilePreviewModalProps } from './FilePreviewModal';
11
11
  export { default as FilePreviewLink } from './FilePreviewLink';
12
12
  export type { FilePreviewLinkProps } from './FilePreviewLink';
13
+ export { downloadFileItem, getFileDownloadAuthHeaders, getFileDownloadUrl } from './utils/download';
14
+ export type { FileDownloadAuthOptions, FileDownloadOptions } from './utils/download';
@@ -0,0 +1,20 @@
1
+ export interface FileDownloadOptions {
2
+ preview?: boolean;
3
+ token?: string | null;
4
+ /** API 前缀,默认 /api */
5
+ apiPrefix?: string;
6
+ }
7
+ export interface FileDownloadAuthOptions {
8
+ getToken?: () => string | null;
9
+ apiPrefix?: string;
10
+ }
11
+ /** 带鉴权参数的文件下载 URL(用于新窗口打开、iframe 等场景) */
12
+ export declare function getFileDownloadUrl(fileId: string, options?: FileDownloadOptions & {
13
+ getToken?: () => string | null;
14
+ }): string;
15
+ export declare function getFileDownloadAuthHeaders(getToken?: () => string | null): HeadersInit | undefined;
16
+ /** 通过 fetch 鉴权后触发浏览器下载 */
17
+ export declare function downloadFileItem(file: {
18
+ id: string;
19
+ name: string;
20
+ }, options?: FileDownloadAuthOptions): Promise<boolean>;
@@ -0,0 +1,30 @@
1
+ function t(r, e) {
2
+ var a;
3
+ const f = (e == null ? void 0 : e.apiPrefix) ?? "/api", c = (e == null ? void 0 : e.token) === void 0 ? ((a = e == null ? void 0 : e.getToken) == null ? void 0 : a.call(e)) ?? null : e.token, d = new URLSearchParams();
4
+ c && d.set("token", c), e != null && e.preview && d.set("preview", "1");
5
+ const l = d.toString();
6
+ return `${f}/files/${r}/download${l ? `?${l}` : ""}`;
7
+ }
8
+ function u(r) {
9
+ const e = r == null ? void 0 : r();
10
+ return e ? { Authorization: `Bearer ${e}` } : void 0;
11
+ }
12
+ async function w(r, e) {
13
+ const f = (e == null ? void 0 : e.apiPrefix) ?? "/api";
14
+ try {
15
+ const c = await fetch(`${f}/files/${r.id}/download`, {
16
+ headers: u(e == null ? void 0 : e.getToken)
17
+ });
18
+ if (!c.ok) return !1;
19
+ const d = await c.blob(), l = URL.createObjectURL(d), a = document.createElement("a");
20
+ return a.href = l, a.download = r.name, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(l), !0;
21
+ } catch {
22
+ return !1;
23
+ }
24
+ }
25
+ export {
26
+ w as downloadFileItem,
27
+ u as getFileDownloadAuthHeaders,
28
+ t as getFileDownloadUrl
29
+ };
30
+ //# sourceMappingURL=download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.js","sources":["../../../../src/components/File/utils/download.ts"],"sourcesContent":["export interface FileDownloadOptions {\n preview?: boolean;\n token?: string | null;\n /** API 前缀,默认 /api */\n apiPrefix?: string;\n}\n\nexport interface FileDownloadAuthOptions {\n getToken?: () => string | null;\n apiPrefix?: string;\n}\n\n/** 带鉴权参数的文件下载 URL(用于新窗口打开、iframe 等场景) */\nexport function getFileDownloadUrl(\n fileId: string,\n options?: FileDownloadOptions & { getToken?: () => string | null },\n): string {\n const apiPrefix = options?.apiPrefix ?? '/api';\n const token = options?.token === undefined ? (options?.getToken?.() ?? null) : options.token;\n const params = new URLSearchParams();\n if (token) params.set('token', token);\n if (options?.preview) params.set('preview', '1');\n const qs = params.toString();\n return `${apiPrefix}/files/${fileId}/download${qs ? `?${qs}` : ''}`;\n}\n\nexport function getFileDownloadAuthHeaders(\n getToken?: () => string | null,\n): HeadersInit | undefined {\n const token = getToken?.();\n return token ? { Authorization: `Bearer ${token}` } : undefined;\n}\n\n/** 通过 fetch 鉴权后触发浏览器下载 */\nexport async function downloadFileItem(\n file: { id: string; name: string },\n options?: FileDownloadAuthOptions,\n): Promise<boolean> {\n const apiPrefix = options?.apiPrefix ?? '/api';\n try {\n const res = await fetch(`${apiPrefix}/files/${file.id}/download`, {\n headers: getFileDownloadAuthHeaders(options?.getToken),\n });\n if (!res.ok) return false;\n\n const blob = await res.blob();\n const blobUrl = URL.createObjectURL(blob);\n const anchor = document.createElement('a');\n anchor.href = blobUrl;\n anchor.download = file.name;\n document.body.appendChild(anchor);\n anchor.click();\n document.body.removeChild(anchor);\n URL.revokeObjectURL(blobUrl);\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["getFileDownloadUrl","fileId","options","_a","apiPrefix","token","params","qs","getFileDownloadAuthHeaders","getToken","downloadFileItem","file","res","blob","blobUrl","anchor"],"mappings":"AAaO,SAASA,EACdC,GACAC,GACQ;AAHH,MAAAC;AAIL,QAAMC,KAAYF,KAAA,gBAAAA,EAAS,cAAa,QAClCG,KAAQH,KAAA,gBAAAA,EAAS,WAAU,WAAaC,IAAAD,KAAA,gBAAAA,EAAS,aAAT,gBAAAC,EAAA,KAAAD,OAAyB,OAAQA,EAAQ,OACjFI,IAAS,IAAI,gBAAA;AACnB,EAAID,KAAOC,EAAO,IAAI,SAASD,CAAK,GAChCH,KAAA,QAAAA,EAAS,WAASI,EAAO,IAAI,WAAW,GAAG;AAC/C,QAAMC,IAAKD,EAAO,SAAA;AAClB,SAAO,GAAGF,CAAS,UAAUH,CAAM,YAAYM,IAAK,IAAIA,CAAE,KAAK,EAAE;AACnE;AAEO,SAASC,EACdC,GACyB;AACzB,QAAMJ,IAAQI,KAAA,gBAAAA;AACd,SAAOJ,IAAQ,EAAE,eAAe,UAAUA,CAAK,OAAO;AACxD;AAGA,eAAsBK,EACpBC,GACAT,GACkB;AAClB,QAAME,KAAYF,KAAA,gBAAAA,EAAS,cAAa;AACxC,MAAI;AACF,UAAMU,IAAM,MAAM,MAAM,GAAGR,CAAS,UAAUO,EAAK,EAAE,aAAa;AAAA,MAChE,SAASH,EAA2BN,KAAA,gBAAAA,EAAS,QAAQ;AAAA,IAAA,CACtD;AACD,QAAI,CAACU,EAAI,GAAI,QAAO;AAEpB,UAAMC,IAAO,MAAMD,EAAI,KAAA,GACjBE,IAAU,IAAI,gBAAgBD,CAAI,GAClCE,IAAS,SAAS,cAAc,GAAG;AACzC,WAAAA,EAAO,OAAOD,GACdC,EAAO,WAAWJ,EAAK,MACvB,SAAS,KAAK,YAAYI,CAAM,GAChCA,EAAO,MAAA,GACP,SAAS,KAAK,YAAYA,CAAM,GAChC,IAAI,gBAAgBD,CAAO,GACpB;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;"}
@@ -10,11 +10,16 @@ interface QuickOption {
10
10
  interface FilterDateRangeProps extends BaseFilterProps {
11
11
  value?: [string, string] | null;
12
12
  onChange?: (value: [string, string] | null) => void;
13
- /** 默认区间:与默认相同时视为未筛选 */
13
+ /** 默认区间:与默认相同时视为未筛选(除非 showDefaultAsSelected) */
14
14
  defaultValue?: [string, string];
15
+ /** 为 true 时,value 等于 defaultValue 仍展示在已选 Tag 中 */
16
+ showDefaultAsSelected?: boolean;
15
17
  showQuickOptions?: boolean;
16
18
  quickOptions?: QuickOption[];
17
19
  }
20
+ declare function isSameRange(a?: [string, string] | null, b?: [string, string]): boolean;
21
+ declare function findMatchingQuickKey(range: [string, string] | null | undefined, opts: QuickOption[]): string | null;
18
22
  declare const FilterDateRange: React.FC<FilterDateRangeProps>;
19
23
  export default FilterDateRange;
20
24
  export type { FilterDateRangeProps, QuickOption };
25
+ export { findMatchingQuickKey, isSameRange };
@@ -1,13 +1,13 @@
1
- import { jsxs as L, jsx as g } from "react/jsx-runtime";
2
- import { DatePicker as Q } from "antd";
1
+ import { jsxs as T, jsx as N } from "react/jsx-runtime";
2
+ import { DatePicker as A } from "antd";
3
3
  import s from "dayjs";
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 = [
4
+ import { useState as q, useEffect as F, useMemo as L } from "react";
5
+ import W from "../FilterPopover/index.js";
6
+ import { resolveHidden as P } from "../types.js";
7
+ import { useFilterRegister as _ } from "../useFilterState.js";
8
+ import l from "./style.module.scss.js";
9
+ import w from "classnames";
10
+ const { RangePicker: $ } = A, g = [
11
11
  {
12
12
  key: "lastWeek",
13
13
  label: "上周",
@@ -22,79 +22,99 @@ const { RangePicker: A } = Q, B = [
22
22
  getValue: () => [s().startOf("week"), s().endOf("week")]
23
23
  }
24
24
  ];
25
- function E(e, r) {
25
+ function h(e, r) {
26
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
27
  }
28
- const a = ({
28
+ function u(e, r) {
29
+ if (!(e != null && e[0]) || !(e != null && e[1])) return null;
30
+ const t = s(e[0]), n = s(e[1]);
31
+ for (const k of r) {
32
+ const f = k.getValue();
33
+ if (f && f[0].isSame(t, "day") && f[1].isSame(n, "day"))
34
+ return k.key;
35
+ }
36
+ return null;
37
+ }
38
+ const b = ({
29
39
  filterKey: e,
30
40
  label: r,
31
41
  value: t,
32
42
  onChange: n,
33
- defaultValue: F,
34
- showQuickOptions: P = !0,
35
- quickOptions: V,
36
- active: j,
37
- hidden: k
43
+ defaultValue: k,
44
+ showDefaultAsSelected: f = !1,
45
+ showQuickOptions: Q = !0,
46
+ quickOptions: j,
47
+ active: x,
48
+ hidden: y
38
49
  }) => {
39
- const [I, p] = O(!1), [o, c] = O(
50
+ const [I, D] = q(!1), [o, c] = q(
40
51
  t ? [s(t[0]), s(t[1])] : null
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);
52
+ ), [M, m] = q(null), d = _(), p = j ?? (Q ? g : []), R = (i) => {
53
+ m(u(i, p));
54
+ }, S = () => {
55
+ t != null && t[0] && (t != null && t[1]) ? (c([s(t[0]), s(t[1])]), R(t)) : (c(null), m(null));
43
56
  };
44
- R(() => {
45
- t != null && t[0] && (t != null && t[1]) ? c([s(t[0]), s(t[1])]) : c(null);
46
- }, [t]);
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);
57
+ F(() => {
58
+ t != null && t[0] && (t != null && t[1]) ? (c([s(t[0]), s(t[1])]), R(t)) : (c(null), m(null));
59
+ }, [t, p]);
60
+ const O = f ? !!(t != null && t[0]) : !!(t != null && t[0]) && !h(t, k), Y = L(() => !O || !(t != null && t[0]) || !(t != null && t[1]) ? "" : `${t[0]} ~ ${t[1]}`, [O, t]);
61
+ return F(() => {
62
+ if (d) {
63
+ if (P(y)) {
64
+ d.unregister(e);
52
65
  return;
53
66
  }
54
- D ? f.register(e, { label: r, valueLabel: D, onRemove: () => n == null ? void 0 : n(null) }) : f.unregister(e);
67
+ Y ? d.register(e, { label: r, valueLabel: Y, onRemove: () => n == null ? void 0 : n(null) }) : d.unregister(e);
55
68
  }
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
- _,
69
+ }, [Y, e, r, y]), P(y) ? null : /* @__PURE__ */ T(
70
+ W,
66
71
  {
67
72
  label: r,
68
- active: j || l,
73
+ active: x || O,
69
74
  open: I,
70
- onOpenChange: x,
71
- onConfirm: S,
72
- onReset: T,
75
+ onOpenChange: (i) => {
76
+ S(), D(i);
77
+ },
78
+ onConfirm: () => {
79
+ 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), D(!1);
80
+ },
81
+ onReset: () => {
82
+ S(), D(!1);
83
+ },
73
84
  children: [
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(
75
- "span",
85
+ p.length > 0 && /* @__PURE__ */ N(
86
+ "div",
76
87
  {
77
- className: Y(
78
- "filter-date-range-quick-option",
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"]
88
+ className: w(
89
+ "filter-date-range-quick-options",
90
+ l["filter-date-range-quick-options"]
82
91
  ),
83
- onClick: () => {
84
- const w = i.getValue();
85
- w && (c(w), d(i.key));
86
- },
87
- children: i.label
88
- },
89
- i.key
90
- )) }),
91
- /* @__PURE__ */ g(
92
- A,
92
+ children: p.map((i) => /* @__PURE__ */ N(
93
+ "span",
94
+ {
95
+ className: w(
96
+ "filter-date-range-quick-option",
97
+ l["filter-date-range-quick-option"],
98
+ M === i.key && "filter-date-range-quick-option-active",
99
+ M === i.key && l["filter-date-range-quick-option-active"]
100
+ ),
101
+ onClick: () => {
102
+ const V = i.getValue();
103
+ V && (c(V), m(i.key));
104
+ },
105
+ children: i.label
106
+ },
107
+ i.key
108
+ ))
109
+ }
110
+ ),
111
+ /* @__PURE__ */ N(
112
+ $,
93
113
  {
94
- className: Y("filter-date-range-picker", m["filter-date-range-picker"]),
114
+ className: w("filter-date-range-picker", l["filter-date-range-picker"]),
95
115
  value: o,
96
116
  onChange: (i) => {
97
- c(i), d(null);
117
+ c(i), m(null);
98
118
  }
99
119
  }
100
120
  )
@@ -103,6 +123,8 @@ const a = ({
103
123
  );
104
124
  };
105
125
  export {
106
- a as default
126
+ b as default,
127
+ u as findMatchingQuickKey,
128
+ h as isSameRange
107
129
  };
108
130
  //# 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 /** 默认区间:与默认相同时视为未筛选 */\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,aAAAA,MAAgBC,GAUlBC,IAAkC;AAAA,EACtC;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IAC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
+ {"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 /** 默认区间:与默认相同时视为未筛选(除非 showDefaultAsSelected) */\n defaultValue?: [string, string];\n /** 为 true 时,value 等于 defaultValue 仍展示在已选 Tag 中 */\n showDefaultAsSelected?: boolean;\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\nfunction findMatchingQuickKey(\n range: [string, string] | null | undefined,\n opts: QuickOption[],\n): string | null {\n if (!range?.[0] || !range?.[1]) return null;\n const start = dayjs(range[0]);\n const end = dayjs(range[1]);\n for (const opt of opts) {\n const v = opt.getValue();\n if (v && v[0].isSame(start, 'day') && v[1].isSame(end, 'day')) {\n return opt.key;\n }\n }\n return null;\n}\n\nconst FilterDateRange: React.FC<FilterDateRangeProps> = ({\n filterKey,\n label,\n value,\n onChange,\n defaultValue,\n showDefaultAsSelected = false,\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 const opts = quickOptions ?? (showQuickOptions ? BUILT_IN_OPTIONS : []);\n\n const syncActiveQuickKey = (range: [string, string] | null | undefined) => {\n setActiveQuickKey(findMatchingQuickKey(range, opts));\n };\n\n const revertToCommitted = () => {\n if (value?.[0] && value?.[1]) {\n setDates([dayjs(value[0]), dayjs(value[1])]);\n syncActiveQuickKey(value);\n } else {\n setDates(null);\n setActiveQuickKey(null);\n }\n };\n\n useEffect(() => {\n if (value?.[0] && value?.[1]) {\n setDates([dayjs(value[0]), dayjs(value[1])]);\n syncActiveQuickKey(value);\n } else {\n setDates(null);\n setActiveQuickKey(null);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value, opts]);\n\n const hasNonDefaultValue = showDefaultAsSelected\n ? !!value?.[0]\n : !!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 revertToCommitted();\n setOpen(nextOpen);\n };\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\n className={classNames(\n 'filter-date-range-quick-options',\n styles['filter-date-range-quick-options'],\n )}\n >\n {opts.map((opt) => (\n <span\n key={opt.key}\n className={classNames(\n 'filter-date-range-quick-option',\n 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 };\nexport { findMatchingQuickKey, isSameRange };\n"],"names":["RangePicker","DatePicker","BUILT_IN_OPTIONS","dayjs","isSameRange","a","b","findMatchingQuickKey","range","opts","start","end","opt","v","FilterDateRange","filterKey","label","value","onChange","defaultValue","showDefaultAsSelected","showQuickOptions","quickOptions","active","hidden","open","setOpen","useState","dates","setDates","activeQuickKey","setActiveQuickKey","registerFn","useFilterRegister","syncActiveQuickKey","revertToCommitted","useEffect","hasNonDefaultValue","valueLabel","useMemo","resolveHidden","jsxs","FilterPopover","nextOpen","jsx","classNames","styles","vals"],"mappings":";;;;;;;;;AAUA,MAAM,EAAE,aA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C,UAAArC,EAAK,IAAI,CAACG,MACT,gBAAAgC;AAAA,cAAC;AAAA,cAAA;AAAA,gBAEC,WAAWC;AAAA,kBACT;AAAA,kBACAC,EAAO,gCAAgC;AAAA,kBACvChB,MAAmBlB,EAAI,OAAO;AAAA,kBAC9BkB,MAAmBlB,EAAI,OAAOkC,EAAO,uCAAuC;AAAA,gBAAA;AAAA,gBAE9E,SAAS,MAAM;AACb,wBAAMjC,IAAID,EAAI,SAAA;AACd,kBAAIC,MACFgB,EAAShB,CAAC,GACVkB,EAAkBnB,EAAI,GAAG;AAAA,gBAE7B;AAAA,gBAEC,UAAAA,EAAI;AAAA,cAAA;AAAA,cAfAA,EAAI;AAAA,YAAA,CAiBZ;AAAA,UAAA;AAAA,QAAA;AAAA,QAGL,gBAAAgC;AAAA,UAAC5C;AAAA,UAAA;AAAA,YACC,WAAW6C,EAAW,4BAA4BC,EAAO,0BAA0B,CAAC;AAAA,YACpF,OAAOlB;AAAA,YACP,UAAU,CAACmB,MAAS;AAClB,cAAAlB,EAASkB,CAA2C,GACpDhB,EAAkB,IAAI;AAAA,YACxB;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -6,6 +6,7 @@ export interface FilterOption {
6
6
  }
7
7
  /** 人员展示选项(仅 UI 字段,数据由消费方提供) */
8
8
  export interface PersonOption extends FilterOption {
9
+ departmentId?: string;
9
10
  departmentName?: string;
10
11
  email?: string;
11
12
  phone?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/components/Filter/types.ts"],"sourcesContent":["import type { MaybeFn, Visibility } from '@/utils/resolveMaybeFn';\nimport { resolveMaybeFn } from '@/utils/resolveMaybeFn';\n\n/** 筛选选项基础类型 */\nexport interface FilterOption {\n label: string;\n value: string | number;\n}\n\n/** 人员展示选项(仅 UI 字段,数据由消费方提供) */\nexport interface PersonOption extends FilterOption {\n departmentName?: string;\n email?: string;\n phone?: string;\n employeeId?: string;\n}\n\n/** 已选项 */\nexport interface SelectedItem {\n key: string;\n label: string;\n valueLabel: string;\n onRemove: () => void;\n /** 为 false 时不允许移除(如多选至少保留一项) */\n removable?: boolean;\n}\n\n/** 所有筛选组件共用的 Props */\nexport interface BaseFilterProps {\n filterKey: string;\n label: string;\n active?: boolean;\n /** 隐藏;支持 boolean 或 (ctx) => boolean */\n hidden?: Visibility;\n /** 展示;与 hidden 二选一,display 优先 */\n display?: Visibility;\n}\n\nexport type FilterVisibilityContext = Record<string, unknown>;\n\n/** 解析 hidden(兼容旧 API,支持 MaybeFn) */\nexport function resolveHidden(\n hidden: MaybeFn<boolean, FilterVisibilityContext> | undefined,\n ctx: FilterVisibilityContext = {},\n): boolean {\n if (hidden === undefined) return false;\n return resolveMaybeFn(hidden, ctx, false);\n}\n\n/** 根据 display / hidden 计算筛选项是否可见 */\nexport function resolveFilterVisible(\n props: Pick<BaseFilterProps, 'display' | 'hidden'>,\n ctx: FilterVisibilityContext = {},\n): boolean {\n if (props.display !== undefined) {\n return resolveMaybeFn(props.display, ctx, true);\n }\n return !resolveHidden(props.hidden, ctx);\n}\n"],"names":["resolveHidden","hidden","ctx","resolveMaybeFn","resolveFilterVisible","props"],"mappings":";AAyCO,SAASA,EACdC,GACAC,IAA+B,IACtB;AACT,SAAID,MAAW,SAAkB,KAC1BE,EAAeF,GAAQC,GAAK,EAAK;AAC1C;AAGO,SAASE,EACdC,GACAH,IAA+B,IACtB;AACT,SAAIG,EAAM,YAAY,SACbF,EAAeE,EAAM,SAASH,GAAK,EAAI,IAEzC,CAACF,EAAcK,EAAM,QAAQH,CAAG;AACzC;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/components/Filter/types.ts"],"sourcesContent":["import type { MaybeFn, Visibility } from '@/utils/resolveMaybeFn';\nimport { resolveMaybeFn } from '@/utils/resolveMaybeFn';\n\n/** 筛选选项基础类型 */\nexport interface FilterOption {\n label: string;\n value: string | number;\n}\n\n/** 人员展示选项(仅 UI 字段,数据由消费方提供) */\nexport interface PersonOption extends FilterOption {\n departmentId?: string;\n departmentName?: string;\n email?: string;\n phone?: string;\n employeeId?: string;\n}\n\n/** 已选项 */\nexport interface SelectedItem {\n key: string;\n label: string;\n valueLabel: string;\n onRemove: () => void;\n /** 为 false 时不允许移除(如多选至少保留一项) */\n removable?: boolean;\n}\n\n/** 所有筛选组件共用的 Props */\nexport interface BaseFilterProps {\n filterKey: string;\n label: string;\n active?: boolean;\n /** 隐藏;支持 boolean 或 (ctx) => boolean */\n hidden?: Visibility;\n /** 展示;与 hidden 二选一,display 优先 */\n display?: Visibility;\n}\n\nexport type FilterVisibilityContext = Record<string, unknown>;\n\n/** 解析 hidden(兼容旧 API,支持 MaybeFn) */\nexport function resolveHidden(\n hidden: MaybeFn<boolean, FilterVisibilityContext> | undefined,\n ctx: FilterVisibilityContext = {},\n): boolean {\n if (hidden === undefined) return false;\n return resolveMaybeFn(hidden, ctx, false);\n}\n\n/** 根据 display / hidden 计算筛选项是否可见 */\nexport function resolveFilterVisible(\n props: Pick<BaseFilterProps, 'display' | 'hidden'>,\n ctx: FilterVisibilityContext = {},\n): boolean {\n if (props.display !== undefined) {\n return resolveMaybeFn(props.display, ctx, true);\n }\n return !resolveHidden(props.hidden, ctx);\n}\n"],"names":["resolveHidden","hidden","ctx","resolveMaybeFn","resolveFilterVisible","props"],"mappings":";AA0CO,SAASA,EACdC,GACAC,IAA+B,IACtB;AACT,SAAID,MAAW,SAAkB,KAC1BE,EAAeF,GAAQC,GAAK,EAAK;AAC1C;AAGO,SAASE,EACdC,GACAH,IAA+B,IACtB;AACT,SAAIG,EAAM,YAAY,SACbF,EAAeE,EAAM,SAASH,GAAK,EAAI,IAEzC,CAACF,EAAcK,EAAM,QAAQH,CAAG;AACzC;"}
@@ -51,8 +51,10 @@ export declare const LayoutGrid: React.ForwardRefExoticComponent<Omit<IconProps,
51
51
  export declare const Loader2: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
52
52
  export declare const Lock: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
53
53
  export declare const LogOut: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
54
+ export declare const Maximize2: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
54
55
  export declare const MessageCircle: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
55
56
  export declare const MessageSquare: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
57
+ export declare const Minimize2: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
56
58
  export declare const PanelLeftClose: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
57
59
  export declare const PanelLeftOpen: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
58
60
  export declare const Pause: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
@@ -80,6 +82,6 @@ export declare const UserRoundCog: React.ForwardRefExoticComponent<Omit<IconProp
80
82
  export declare const Users: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
81
83
  export declare const X: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
82
84
  export { createIcon };
83
- export declare const ICON_NAMES: readonly ["ArrowLeft", "ArrowLeftRight", "BarChart3", "BookOpen", "Bot", "Check", "ChevronDown", "ChevronLeft", "ChevronRight", "ChevronUp", "CircleAlert", "CircleCheck", "CircleHelp", "CirclePlay", "CircleX", "ClipboardCheck", "Clock", "CloudDownload", "CloudUpload", "Code", "Copy", "Crown", "Database", "Download", "Eye", "File", "FileArchive", "FileImage", "FileSpreadsheet", "FileText", "Flag", "Flame", "Folder", "FolderOpen", "Hash", "House", "Import", "Inbox", "Info", "LayoutDashboard", "LayoutGrid", "Loader2", "Lock", "LogOut", "MessageCircle", "MessageSquare", "PanelLeftClose", "PanelLeftOpen", "Pause", "Pencil", "Plus", "Presentation", "RefreshCw", "RotateCw", "Send", "Settings", "Shield", "ShieldCheck", "SlidersHorizontal", "Square", "Star", "ThumbsDown", "ThumbsUp", "Trash2", "Trophy", "Undo2", "Upload", "User", "UserPlus", "UserRoundCog", "Users", "X"];
85
+ export declare const ICON_NAMES: readonly ["ArrowLeft", "ArrowLeftRight", "BarChart3", "BookOpen", "Bot", "Check", "ChevronDown", "ChevronLeft", "ChevronRight", "ChevronUp", "CircleAlert", "CircleCheck", "CircleHelp", "CirclePlay", "CircleX", "ClipboardCheck", "Clock", "CloudDownload", "CloudUpload", "Code", "Copy", "Crown", "Database", "Download", "Eye", "File", "FileArchive", "FileImage", "FileSpreadsheet", "FileText", "Flag", "Flame", "Folder", "FolderOpen", "Hash", "House", "Import", "Inbox", "Info", "LayoutDashboard", "LayoutGrid", "Loader2", "Lock", "LogOut", "Maximize2", "MessageCircle", "MessageSquare", "Minimize2", "PanelLeftClose", "PanelLeftOpen", "Pause", "Pencil", "Plus", "Presentation", "RefreshCw", "RotateCw", "Send", "Settings", "Shield", "ShieldCheck", "SlidersHorizontal", "Square", "Star", "ThumbsDown", "ThumbsUp", "Trash2", "Trophy", "Undo2", "Upload", "User", "UserPlus", "UserRoundCog", "Users", "X"];
84
86
  export type IconName = (typeof ICON_NAMES)[number];
85
87
  export declare const ICON_REGISTRY: Record<IconName, React.FC<IconProps>>;