@hkyhy/marsun-components-core 0.1.24 → 0.1.26

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 (31) hide show
  1. package/dist/components/Auth/UserProfileCard/UserProfileCard.d.ts +23 -0
  2. package/dist/components/Auth/UserProfileCard/UserProfileCard.js +57 -0
  3. package/dist/components/Auth/UserProfileCard/UserProfileCard.js.map +1 -0
  4. package/dist/components/Auth/UserProfileCard/index.d.ts +2 -0
  5. package/dist/components/Auth/UserProfileCard/style.module.scss.js +14 -0
  6. package/dist/components/Auth/UserProfileCard/style.module.scss.js.map +1 -0
  7. package/dist/components/Auth/index.d.ts +2 -0
  8. package/dist/components/Filter/FilterSelect/index.d.ts +4 -2
  9. package/dist/components/Filter/FilterSelect/index.js +253 -157
  10. package/dist/components/Filter/FilterSelect/index.js.map +1 -1
  11. package/dist/components/Filter/FilterSelect/style.module.scss.js +14 -12
  12. package/dist/components/Filter/FilterSelect/style.module.scss.js.map +1 -1
  13. package/dist/components/Table/Table.d.ts +8 -0
  14. package/dist/components/Table/Table.js +39 -0
  15. package/dist/components/Table/Table.js.map +1 -0
  16. package/dist/components/Table/index.d.ts +2 -0
  17. package/dist/components/Table/style.module.scss.js +7 -0
  18. package/dist/components/Table/style.module.scss.js.map +1 -0
  19. package/dist/components/index.d.ts +1 -0
  20. package/dist/index.d.ts +3 -1
  21. package/dist/index.js +410 -405
  22. package/dist/index.js.map +1 -1
  23. package/dist/marsun-components-core.css +1 -1
  24. package/dist/styles/global.css +1 -1
  25. package/dist/utils/authRedirect.d.ts +17 -4
  26. package/dist/utils/authRedirect.js +39 -20
  27. package/dist/utils/authRedirect.js.map +1 -1
  28. package/dist/utils/createMarsunRequest.d.ts +2 -0
  29. package/dist/utils/createMarsunRequest.js +20 -18
  30. package/dist/utils/createMarsunRequest.js.map +1 -1
  31. package/package.json +1 -1
@@ -0,0 +1,23 @@
1
+ import { MenuProps } from 'antd';
2
+ import { default as React } from 'react';
3
+ export type UserProfileCardProps = {
4
+ /** 主文案(姓名 / 展示名) */
5
+ name: string;
6
+ /** 副文案(邮箱 / 工号等) */
7
+ sub?: string;
8
+ /** 头像文字,默认 name 首字 */
9
+ avatarText?: string;
10
+ /** 侧栏折叠时仅显示头像 */
11
+ collapsed?: boolean;
12
+ /** 自定义下拉菜单;不传则在提供 onLogout 时生成「退出登录」 */
13
+ menuItems?: MenuProps['items'];
14
+ /** 点击默认「退出登录」时回调 */
15
+ onLogout?: () => void;
16
+ className?: string;
17
+ };
18
+ /**
19
+ * 侧栏底部用户卡片:整卡点击向上展开菜单(默认退出登录)。
20
+ * 纯 UI;是否挂载由业务根据登录态决定。
21
+ */
22
+ declare const UserProfileCard: React.FC<UserProfileCardProps>;
23
+ export default UserProfileCard;
@@ -0,0 +1,57 @@
1
+ import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
+ import { LogOut as u } from "../../Icons/index.js";
3
+ import { Avatar as h, Dropdown as N } from "antd";
4
+ import p from "classnames";
5
+ import { useMemo as v } from "react";
6
+ import r from "./style.module.scss.js";
7
+ const C = ({
8
+ name: l,
9
+ sub: t,
10
+ avatarText: f,
11
+ collapsed: i = !1,
12
+ menuItems: a,
13
+ onLogout: s,
14
+ className: m
15
+ }) => {
16
+ const d = (f || l).trim().charAt(0).toUpperCase() || "U", o = v(() => a || (s ? [
17
+ {
18
+ key: "logout",
19
+ danger: !0,
20
+ label: "退出登录",
21
+ icon: /* @__PURE__ */ e(u, { size: 14 }),
22
+ onClick: s
23
+ }
24
+ ] : []), [a, s]), c = /* @__PURE__ */ n(
25
+ "button",
26
+ {
27
+ type: "button",
28
+ className: p(
29
+ r["user-profile-card"],
30
+ i && r["user-profile-card--collapsed"],
31
+ m
32
+ ),
33
+ "aria-label": "用户菜单",
34
+ children: [
35
+ /* @__PURE__ */ e(h, { className: r["user-profile-avatar"], size: i ? 32 : 40, children: d }),
36
+ i ? null : /* @__PURE__ */ n("div", { className: r["user-profile-meta"], children: [
37
+ /* @__PURE__ */ e("div", { className: r["user-profile-name"], title: l, children: l }),
38
+ t ? /* @__PURE__ */ e("div", { className: r["user-profile-sub"], title: t, children: t }) : null
39
+ ] })
40
+ ]
41
+ }
42
+ );
43
+ return /* @__PURE__ */ e(
44
+ "div",
45
+ {
46
+ className: p(
47
+ r["user-profile-wrap"],
48
+ i && r["user-profile-wrap--collapsed"]
49
+ ),
50
+ children: o && o.length > 0 ? /* @__PURE__ */ e(N, { menu: { items: o }, trigger: ["click"], placement: "topLeft", children: c }) : c
51
+ }
52
+ );
53
+ };
54
+ export {
55
+ C as default
56
+ };
57
+ //# sourceMappingURL=UserProfileCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserProfileCard.js","sources":["../../../../src/components/Auth/UserProfileCard/UserProfileCard.tsx"],"sourcesContent":["import { LogOut } from '../../Icons';\nimport { Avatar, Dropdown } from 'antd';\nimport type { MenuProps } from 'antd';\nimport classNames from 'classnames';\nimport React, { useMemo } from 'react';\nimport styles from './style.module.scss';\n\nexport type UserProfileCardProps = {\n /** 主文案(姓名 / 展示名) */\n name: string;\n /** 副文案(邮箱 / 工号等) */\n sub?: string;\n /** 头像文字,默认 name 首字 */\n avatarText?: string;\n /** 侧栏折叠时仅显示头像 */\n collapsed?: boolean;\n /** 自定义下拉菜单;不传则在提供 onLogout 时生成「退出登录」 */\n menuItems?: MenuProps['items'];\n /** 点击默认「退出登录」时回调 */\n onLogout?: () => void;\n className?: string;\n};\n\n/**\n * 侧栏底部用户卡片:整卡点击向上展开菜单(默认退出登录)。\n * 纯 UI;是否挂载由业务根据登录态决定。\n */\nconst UserProfileCard: React.FC<UserProfileCardProps> = ({\n name,\n sub,\n avatarText,\n collapsed = false,\n menuItems,\n onLogout,\n className,\n}) => {\n const initial = (avatarText || name).trim().charAt(0).toUpperCase() || 'U';\n\n const items = useMemo<MenuProps['items']>(() => {\n if (menuItems) return menuItems;\n if (!onLogout) return [];\n return [\n {\n key: 'logout',\n danger: true,\n label: '退出登录',\n icon: <LogOut size={14} />,\n onClick: onLogout,\n },\n ];\n }, [menuItems, onLogout]);\n\n const card = (\n <button\n type=\"button\"\n className={classNames(\n styles['user-profile-card'],\n collapsed && styles['user-profile-card--collapsed'],\n className,\n )}\n aria-label=\"用户菜单\"\n >\n <Avatar className={styles['user-profile-avatar']} size={collapsed ? 32 : 40}>\n {initial}\n </Avatar>\n {!collapsed ? (\n <div className={styles['user-profile-meta']}>\n <div className={styles['user-profile-name']} title={name}>\n {name}\n </div>\n {sub ? (\n <div className={styles['user-profile-sub']} title={sub}>\n {sub}\n </div>\n ) : null}\n </div>\n ) : null}\n </button>\n );\n\n return (\n <div\n className={classNames(\n styles['user-profile-wrap'],\n collapsed && styles['user-profile-wrap--collapsed'],\n )}\n >\n {items && items.length > 0 ? (\n <Dropdown menu={{ items }} trigger={['click']} placement=\"topLeft\">\n {card}\n </Dropdown>\n ) : (\n card\n )}\n </div>\n );\n};\n\nexport default UserProfileCard;\n"],"names":["UserProfileCard","name","sub","avatarText","collapsed","menuItems","onLogout","className","initial","items","useMemo","jsx","LogOut","card","jsxs","classNames","styles","Avatar","Dropdown"],"mappings":";;;;;;AA2BA,MAAMA,IAAkD,CAAC;AAAA,EACvD,MAAAC;AAAA,EACA,KAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AACF,MAAM;AACJ,QAAMC,KAAWL,KAAcF,GAAM,OAAO,OAAO,CAAC,EAAE,YAAA,KAAiB,KAEjEQ,IAAQC,EAA4B,MACpCL,MACCC,IACE;AAAA,IACL;AAAA,MACE,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,MAAM,gBAAAK,EAACC,GAAA,EAAO,MAAM,GAAA,CAAI;AAAA,MACxB,SAASN;AAAA,IAAA;AAAA,EACX,IARoB,CAAA,IAUrB,CAACD,GAAWC,CAAQ,CAAC,GAElBO,IACJ,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAWC;AAAA,QACTC,EAAO,mBAAmB;AAAA,QAC1BZ,KAAaY,EAAO,8BAA8B;AAAA,QAClDT;AAAA,MAAA;AAAA,MAEF,cAAW;AAAA,MAEX,UAAA;AAAA,QAAA,gBAAAI,EAACM,GAAA,EAAO,WAAWD,EAAO,qBAAqB,GAAG,MAAMZ,IAAY,KAAK,IACtE,UAAAI,EAAA,CACH;AAAA,QACEJ,IAWE,OAVF,gBAAAU,EAAC,SAAI,WAAWE,EAAO,mBAAmB,GACxC,UAAA;AAAA,UAAA,gBAAAL,EAAC,SAAI,WAAWK,EAAO,mBAAmB,GAAG,OAAOf,GACjD,UAAAA,GACH;AAAA,UACCC,IACC,gBAAAS,EAAC,OAAA,EAAI,WAAWK,EAAO,kBAAkB,GAAG,OAAOd,GAChD,UAAAA,EAAA,CACH,IACE;AAAA,QAAA,EAAA,CACN;AAAA,MACE;AAAA,IAAA;AAAA,EAAA;AAIR,SACE,gBAAAS;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWI;AAAA,QACTC,EAAO,mBAAmB;AAAA,QAC1BZ,KAAaY,EAAO,8BAA8B;AAAA,MAAA;AAAA,MAGnD,eAASP,EAAM,SAAS,IACvB,gBAAAE,EAACO,KAAS,MAAM,EAAE,OAAAT,EAAA,GAAS,SAAS,CAAC,OAAO,GAAG,WAAU,WACtD,aACH,IAEAI;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -0,0 +1,2 @@
1
+ export { default as UserProfileCard } from './UserProfileCard';
2
+ export type { UserProfileCardProps } from './UserProfileCard';
@@ -0,0 +1,14 @@
1
+ const r = {
2
+ "user-profile-wrap": "_user-profile-wrap_1rbrn_1",
3
+ "user-profile-wrap--collapsed": "_user-profile-wrap--collapsed_1rbrn_6",
4
+ "user-profile-card": "_user-profile-card_1rbrn_12",
5
+ "user-profile-card--collapsed": "_user-profile-card--collapsed_1rbrn_30",
6
+ "user-profile-avatar": "_user-profile-avatar_1rbrn_36",
7
+ "user-profile-meta": "_user-profile-meta_1rbrn_43",
8
+ "user-profile-name": "_user-profile-name_1rbrn_48",
9
+ "user-profile-sub": "_user-profile-sub_1rbrn_58"
10
+ };
11
+ export {
12
+ r as default
13
+ };
14
+ //# sourceMappingURL=style.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -1,3 +1,5 @@
1
1
  export { default as PermissionGuard } from './PermissionGuard';
2
2
  export { default as ProtectedRoute } from './ProtectedRoute';
3
3
  export { hasPermission } from './hasPermission';
4
+ export { UserProfileCard } from './UserProfileCard';
5
+ export type { UserProfileCardProps } from './UserProfileCard';
@@ -6,10 +6,12 @@ interface FilterSelectProps extends BaseFilterProps {
6
6
  options: FilterOption[];
7
7
  value?: FilterSelectValue;
8
8
  onChange?: (value: FilterSelectValue) => void;
9
- /** 默认值:与默认值相同时视为未筛选(不展示已选标签与选中态) */
9
+ /** 默认值:与默认值相同时视为未筛选(除非 showDefaultAsSelected) */
10
10
  defaultValue?: string | number;
11
- /** 多选默认值:与默认集合相同时视为未筛选 */
11
+ /** 多选默认值:与默认集合相同时视为未筛选(除非 showDefaultAsSelected) */
12
12
  defaultValues?: (string | number)[];
13
+ /** 为 true 时,value 等于默认仍展示在「您已选择」并保持选中态 */
14
+ showDefaultAsSelected?: boolean;
13
15
  placeholder?: string;
14
16
  searchable?: boolean;
15
17
  /** 是否多选 */
@@ -1,207 +1,303 @@
1
- import { jsxs as N, jsx as v } from "react/jsx-runtime";
2
- import { Check as W, X as Y } from "../../Icons/index.js";
3
- import { Input as Z, Checkbox as _, Space as K } from "antd";
4
- import { useState as D, useRef as V, useMemo as z, useEffect as B } from "react";
5
- import ee from "../../Form/PersonOptionRow/index.js";
6
- import re from "../FilterPopover/index.js";
7
- import { resolveFilterVisible as E } from "../types.js";
8
- import { useFilterRegister as te } from "../useFilterState.js";
9
- import m from "./style.module.scss.js";
10
- import h from "classnames";
11
- const { Search: se } = Z;
12
- function ne(r) {
13
- const t = [r.label];
14
- return r.departmentName && t.push(r.departmentName), t.join(" · ");
1
+ import { jsxs as b, jsx as m } from "react/jsx-runtime";
2
+ import { Check as oe, X as le } from "../../Icons/index.js";
3
+ import { Input as ae, Checkbox as Q, Space as fe } from "antd";
4
+ import { useState as E, useRef as ge, useMemo as U, useEffect as W } from "react";
5
+ import de from "../../Form/PersonOptionRow/index.js";
6
+ import he from "../FilterPopover/index.js";
7
+ import { resolveFilterVisible as Y } from "../types.js";
8
+ import { useFilterRegister as me } from "../useFilterState.js";
9
+ import g from "./style.module.scss.js";
10
+ import v from "classnames";
11
+ const { Search: ve } = ae;
12
+ function Se(r) {
13
+ const s = [r.label];
14
+ return r.departmentName && s.push(r.departmentName), s.join(" · ");
15
15
  }
16
- function ce(r, t) {
17
- const o = t.toLowerCase();
18
- return [r.label, r.departmentName, r.email, r.phone, r.employeeId].filter(Boolean).some((l) => String(l).toLowerCase().includes(o));
16
+ function Ae(r, s) {
17
+ const i = s.toLowerCase();
18
+ return [r.label, r.departmentName, r.email, r.phone, r.employeeId].filter(Boolean).some((o) => String(o).toLowerCase().includes(i));
19
19
  }
20
- function ie(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 o = [...r].map(String).sort(), l = [...t].map(String).sort();
24
- return o.every((c, d) => c === l[d]);
20
+ function Z(r, s) {
21
+ if (!(r != null && r.length) && !(s != null && s.length)) return !0;
22
+ if (!r || !s || r.length !== s.length) return !1;
23
+ const i = [...r].map(String).sort(), o = [...s].map(String).sort();
24
+ return i.every((l, a) => l === o[a]);
25
25
  }
26
- function I(r, t, o, l) {
27
- if (l) {
28
- const c = Array.isArray(r) ? r : r != null && r !== "" ? [r] : [];
29
- return o != null && o.length && ie(c, o) ? [] : c;
26
+ function _(r) {
27
+ return Array.isArray(r) ? r : r != null && r !== "" ? [r] : [];
28
+ }
29
+ function q(r, s, i, o, l) {
30
+ if (o) {
31
+ const a = _(r);
32
+ return !l && (i != null && i.length) && Z(a, i) ? [] : a;
30
33
  }
31
- if (!(t !== void 0 && r === t))
34
+ if (!(!l && s !== void 0 && r === s))
32
35
  return r;
33
36
  }
34
- function oe(r, t, o, l) {
35
- if (o) {
37
+ function I(r, s, i, o) {
38
+ return o ? _(r) : q(r, s, i, !1, !0);
39
+ }
40
+ function xe(r, s, i, o, l) {
41
+ if (i) {
36
42
  const d = r || [];
37
- return d.length > 0 ? d.map((u) => {
38
- var S;
39
- return ((S = t.find((s) => String(s.value) === String(u))) == null ? void 0 : S.label) ?? String(u);
43
+ return d.length ? l != null && l.length && Z(d, l) ? "全部" : d.map((N) => {
44
+ var w;
45
+ return ((w = s.find((n) => String(n.value) === String(N))) == null ? void 0 : w.label) ?? String(N);
40
46
  }).join("、") : "";
41
47
  }
42
48
  if (r == null) return "";
43
- const c = t.find((d) => String(d.value) === String(r));
44
- return c ? l ? ne(c) : c.label : String(r);
49
+ const a = s.find((d) => String(d.value) === String(r));
50
+ return a ? o ? Se(a) : a.label : String(r);
45
51
  }
46
- const Ne = ({
52
+ const Re = ({
47
53
  filterKey: r,
48
- label: t,
49
- options: o = [],
50
- value: l,
51
- onChange: c,
52
- defaultValue: d,
53
- defaultValues: u,
54
- searchable: S = !1,
55
- multiple: s = !1,
56
- minSelection: g,
57
- variant: M = "default",
58
- active: q,
59
- hidden: C,
60
- display: O
54
+ label: s,
55
+ options: i = [],
56
+ value: o,
57
+ onChange: l,
58
+ defaultValue: a,
59
+ defaultValues: d,
60
+ showDefaultAsSelected: N = !1,
61
+ searchable: w = !1,
62
+ multiple: n = !1,
63
+ minSelection: h,
64
+ variant: K = "default",
65
+ active: V,
66
+ hidden: u,
67
+ display: T
61
68
  }) => {
62
- const x = M === "person", [X, b] = D(!1), [y, R] = D(""), n = I(l, d, u, s), [a, k] = D(
63
- n ?? (s ? [] : void 0)
64
- ), L = te(), w = V(c);
65
- w.current = c;
66
- const F = z(() => {
67
- const e = Array.isArray(n) ? n : n != null && n !== "" ? [n] : [], i = !s || g == null || e.length > g;
69
+ const p = K === "person", [ee, F] = E(!1), [O, j] = E(""), f = q(
70
+ o,
71
+ a,
72
+ d,
73
+ n,
74
+ N
75
+ ), [S, y] = E(
76
+ () => I(o, a, d, n) ?? (n ? [] : void 0)
77
+ ), P = me(), R = ge(l);
78
+ R.current = l;
79
+ const X = U(() => {
80
+ const e = Array.isArray(f) ? f : f != null && f !== "" ? [f] : [], t = !n || h == null || e.length > h;
68
81
  return () => {
69
- var f;
70
- i && ((f = w.current) == null || f.call(w, void 0));
82
+ var c;
83
+ t && ((c = R.current) == null || c.call(R, void 0));
71
84
  };
72
- }, [n, g, s]), j = () => {
73
- k(n ?? (s ? [] : void 0)), R("");
85
+ }, [f, h, n]), $ = () => {
86
+ y(
87
+ I(o, a, d, n) ?? (n ? [] : void 0)
88
+ ), j("");
74
89
  };
75
- B(() => {
76
- const e = I(l, d, u, s);
77
- k(e ?? (s ? [] : void 0)), (e == null || Array.isArray(e) && e.length === 0) && R("");
78
- }, [l, d, u, s]);
79
- const P = z(
80
- () => oe(n, o, s, x),
81
- [o, n, s, x]
90
+ W(() => {
91
+ const e = I(o, a, d, n);
92
+ y(e ?? (n ? [] : void 0));
93
+ const t = q(
94
+ o,
95
+ a,
96
+ d,
97
+ n,
98
+ N
99
+ );
100
+ (t == null || Array.isArray(t) && t.length === 0) && j("");
101
+ }, [o, a, d, n, N]);
102
+ const D = U(
103
+ () => xe(f, i, n, p, d),
104
+ [i, f, n, p, d]
82
105
  );
83
- if (B(() => {
84
- if (!L) return;
85
- if (!E({ display: O, hidden: C }, { filterKey: r, label: t, value: l })) {
86
- L.unregister(r);
106
+ if (W(() => {
107
+ if (!P) return;
108
+ if (!Y({ display: T, hidden: u }, { filterKey: r, label: s, value: o })) {
109
+ P.unregister(r);
87
110
  return;
88
111
  }
89
- if (P) {
90
- const i = Array.isArray(n) ? n : n != null && n !== "" ? [n] : [], f = !s || g == null || i.length > g;
91
- L.register(r, {
92
- label: t,
93
- valueLabel: P,
94
- onRemove: F,
95
- removable: f
112
+ if (D) {
113
+ const t = Array.isArray(f) ? f : f != null && f !== "" ? [f] : [], c = !n || h == null || t.length > h;
114
+ P.register(r, {
115
+ label: s,
116
+ valueLabel: D,
117
+ onRemove: X,
118
+ removable: c
96
119
  });
97
120
  } else
98
- L.unregister(r);
99
- }, [P, r, t, C, O, F]), !E({ display: O, hidden: C }, { filterKey: r, label: t, value: l })) return null;
100
- const T = y ? o.filter(
101
- (e) => x ? ce(e, y) : e.label.toLowerCase().includes(y.toLowerCase())
102
- ) : o, $ = () => {
103
- c == null || c(a), b(!1);
104
- }, G = () => {
105
- j(), b(!1);
106
- }, H = (e) => {
107
- !e && s && j(), b(e);
108
- }, J = (e) => {
109
- if (!s) {
110
- const i = d !== void 0 && e === d;
111
- let f;
112
- a === e || i ? f = void 0 : f = e, k(f), c == null || c(f), b(!1);
121
+ P.unregister(r);
122
+ }, [D, r, s, u, T, X]), !Y({ display: T, hidden: u }, { filterKey: r, label: s, value: o })) return null;
123
+ const A = O ? i.filter(
124
+ (e) => p ? Ae(e, O) : e.label.toLowerCase().includes(O.toLowerCase())
125
+ ) : i, re = () => {
126
+ l == null || l(S), F(!1);
127
+ }, te = () => {
128
+ $(), F(!1);
129
+ }, ne = (e) => {
130
+ !e && n && $(), F(e);
131
+ }, se = (e) => {
132
+ if (!n) {
133
+ const t = a !== void 0 && e === a;
134
+ let c;
135
+ S === e || t ? c = void 0 : c = e, y(c), l == null || l(c), F(!1);
113
136
  }
114
- }, p = (e) => {
115
- const i = a || [];
116
- if (i.includes(e) && g != null && i.length <= g)
137
+ }, M = (e) => {
138
+ const t = S || [], c = t.some((x) => String(x) === String(e));
139
+ if (c && h != null && t.length <= h)
140
+ return;
141
+ const L = c ? t.filter((x) => String(x) !== String(e)) : [...t, e];
142
+ y(L);
143
+ }, k = Array.isArray(S) ? S : [], G = A.filter(
144
+ (e) => k.some((t) => String(t) === String(e.value))
145
+ ).length, z = A.length > 0 && G === A.length, ce = G > 0 && !z, H = (e) => {
146
+ const t = k, c = A.map((C) => C.value);
147
+ if (e) {
148
+ const C = new Set(t.map(String)), J = [...t];
149
+ for (const B of c)
150
+ C.has(String(B)) || (J.push(B), C.add(String(B)));
151
+ y(J);
117
152
  return;
118
- const f = i.includes(e) ? i.filter((A) => A !== e) : [...i, e];
119
- k(f);
120
- }, Q = s ? Array.isArray(n) && n.length > 0 : n != null && n !== "";
121
- return /* @__PURE__ */ N(
122
- re,
153
+ }
154
+ const L = new Set(c.map(String));
155
+ let x = t.filter((C) => !L.has(String(C)));
156
+ h != null && x.length < h && (x = t.slice(0, h)), y(x);
157
+ }, ie = n ? Array.isArray(f) && f.length > 0 : f != null && f !== "";
158
+ return /* @__PURE__ */ b(
159
+ he,
123
160
  {
124
- label: t,
125
- active: q || Q,
126
- open: X,
127
- onOpenChange: H,
128
- onConfirm: s ? $ : void 0,
129
- onReset: s ? G : void 0,
161
+ label: s,
162
+ active: V || ie,
163
+ open: ee,
164
+ onOpenChange: ne,
165
+ onConfirm: n ? re : void 0,
166
+ onReset: n ? te : void 0,
130
167
  children: [
131
- S && /* @__PURE__ */ v(
132
- se,
168
+ w && /* @__PURE__ */ m(
169
+ ve,
133
170
  {
134
- placeholder: `搜索${t}`,
171
+ placeholder: `搜索${s}`,
135
172
  allowClear: !0,
136
173
  size: "middle",
137
- className: h("filter-select-search", m["filter-select-search"]),
138
- value: y,
139
- onChange: (e) => R(e.target.value)
174
+ className: v("filter-select-search", g["filter-select-search"]),
175
+ value: O,
176
+ onChange: (e) => j(e.target.value)
140
177
  }
141
178
  ),
142
- /* @__PURE__ */ N("div", { className: h("filter-select-options", m["filter-select-options"]), children: [
143
- T.map((e) => /* @__PURE__ */ N(
179
+ /* @__PURE__ */ b("div", { className: v("filter-select-options", g["filter-select-options"]), children: [
180
+ n && A.length > 0 && /* @__PURE__ */ b(
144
181
  "div",
145
182
  {
146
- className: h(
183
+ className: v(
147
184
  "filter-select-option",
148
- m["filter-select-option"],
149
- !s && a === e.value && h("filter-select-option-selected", m["filter-select-option-selected"])
185
+ g["filter-select-option"],
186
+ "filter-select-select-all",
187
+ g["filter-select-select-all"]
150
188
  ),
151
- onClick: () => s ? p(e.value) : J(e.value),
189
+ onClick: () => H(!z),
152
190
  children: [
153
- s && /* @__PURE__ */ v(
154
- _,
191
+ /* @__PURE__ */ m(
192
+ Q,
155
193
  {
156
- checked: a == null ? void 0 : a.includes(e.value),
157
- onChange: () => p(e.value),
158
- onClick: (i) => i.stopPropagation()
194
+ checked: z,
195
+ indeterminate: ce,
196
+ onChange: (e) => H(e.target.checked),
197
+ onClick: (e) => e.stopPropagation()
159
198
  }
160
199
  ),
161
- x ? /* @__PURE__ */ v(ee, { option: e }) : /* @__PURE__ */ v("span", { children: e.label }),
162
- !s && !x && a === e.value && /* @__PURE__ */ v(W, { className: h("filter-select-option-check", m["filter-select-option-check"]) })
200
+ /* @__PURE__ */ m("span", { children: "全选" })
201
+ ]
202
+ }
203
+ ),
204
+ A.map((e) => /* @__PURE__ */ b(
205
+ "div",
206
+ {
207
+ className: v(
208
+ "filter-select-option",
209
+ g["filter-select-option"],
210
+ !n && S === e.value && v(
211
+ "filter-select-option-selected",
212
+ g["filter-select-option-selected"]
213
+ )
214
+ ),
215
+ onClick: () => n ? M(e.value) : se(e.value),
216
+ children: [
217
+ n && /* @__PURE__ */ m(
218
+ Q,
219
+ {
220
+ checked: k.some((t) => String(t) === String(e.value)),
221
+ onChange: () => M(e.value),
222
+ onClick: (t) => t.stopPropagation()
223
+ }
224
+ ),
225
+ p ? /* @__PURE__ */ m(de, { option: e }) : /* @__PURE__ */ m("span", { children: e.label }),
226
+ !n && !p && S === e.value && /* @__PURE__ */ m(
227
+ oe,
228
+ {
229
+ className: v(
230
+ "filter-select-option-check",
231
+ g["filter-select-option-check"]
232
+ )
233
+ }
234
+ )
163
235
  ]
164
236
  },
165
237
  String(e.value)
166
238
  )),
167
- T.length === 0 && /* @__PURE__ */ v("div", { className: h("filter-select-empty", m["filter-select-empty"]), children: "暂无数据" })
239
+ A.length === 0 && /* @__PURE__ */ m("div", { className: v("filter-select-empty", g["filter-select-empty"]), children: "暂无数据" })
168
240
  ] }),
169
- s && (a == null ? void 0 : a.length) > 0 && /* @__PURE__ */ N("div", { className: h("filter-select-selected-bar", m["filter-select-selected-bar"]), children: [
170
- /* @__PURE__ */ v("div", { className: h("filter-select-selected-label", m["filter-select-selected-label"]), children: "已选:" }),
171
- /* @__PURE__ */ v(K, { size: [4, 4], wrap: !0, children: a.map((e) => {
172
- const i = o.find((U) => String(U.value) === String(e)), f = a || [], A = g == null || f.length > g;
173
- return /* @__PURE__ */ N(
174
- "span",
175
- {
176
- className: h(
177
- "filter-select-selected-tag",
178
- m["filter-select-selected-tag"],
179
- !A && m["filter-select-selected-tag-disabled"]
180
- ),
181
- onClick: () => A && p(e),
182
- children: [
183
- (i == null ? void 0 : i.label) ?? String(e),
184
- /* @__PURE__ */ v(
185
- Y,
186
- {
187
- className: h(
188
- "filter-select-selected-remove",
189
- m["filter-select-selected-remove"],
190
- !A && m["filter-select-selected-remove-disabled"]
191
- )
192
- }
193
- )
194
- ]
195
- },
196
- String(e)
197
- );
198
- }) })
199
- ] })
241
+ n && k.length > 0 && /* @__PURE__ */ b(
242
+ "div",
243
+ {
244
+ className: v("filter-select-selected-bar", g["filter-select-selected-bar"]),
245
+ children: [
246
+ /* @__PURE__ */ m(
247
+ "div",
248
+ {
249
+ className: v(
250
+ "filter-select-selected-label",
251
+ g["filter-select-selected-label"]
252
+ ),
253
+ children: "已选:"
254
+ }
255
+ ),
256
+ /* @__PURE__ */ m(
257
+ "div",
258
+ {
259
+ className: v(
260
+ "filter-select-selected-tags",
261
+ g["filter-select-selected-tags"]
262
+ ),
263
+ children: /* @__PURE__ */ m(fe, { size: [4, 4], wrap: !0, children: k.map((e) => {
264
+ const t = i.find((L) => String(L.value) === String(e)), c = h == null || k.length > h;
265
+ return /* @__PURE__ */ b(
266
+ "span",
267
+ {
268
+ className: v(
269
+ "filter-select-selected-tag",
270
+ g["filter-select-selected-tag"],
271
+ !c && g["filter-select-selected-tag-disabled"]
272
+ ),
273
+ onClick: () => c && M(e),
274
+ children: [
275
+ (t == null ? void 0 : t.label) ?? String(e),
276
+ /* @__PURE__ */ m(
277
+ le,
278
+ {
279
+ className: v(
280
+ "filter-select-selected-remove",
281
+ g["filter-select-selected-remove"],
282
+ !c && g["filter-select-selected-remove-disabled"]
283
+ )
284
+ }
285
+ )
286
+ ]
287
+ },
288
+ String(e)
289
+ );
290
+ }) })
291
+ }
292
+ )
293
+ ]
294
+ }
295
+ )
200
296
  ]
201
297
  }
202
298
  );
203
299
  };
204
300
  export {
205
- Ne as default
301
+ Re as default
206
302
  };
207
303
  //# sourceMappingURL=index.js.map