@unicom-cloud/ui 0.8.106 → 0.8.108

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 (197) hide show
  1. package/App.js +7 -0
  2. package/BackTop.js +2 -4
  3. package/Calendar.js +2 -2
  4. package/ColorPicker.js +15 -14
  5. package/Constant.js +4 -0
  6. package/Copy.js +4 -3
  7. package/Countdown.js +25 -0
  8. package/Grid.js +8 -10
  9. package/LiquidFill.js +4 -3
  10. package/List.js +7 -6
  11. package/Marquee.js +4 -3
  12. package/Modal.js +4 -2
  13. package/PageHeader.js +3 -2
  14. package/QrCode.js +4 -3
  15. package/RowCol.js +8 -0
  16. package/Segmented.js +14 -4
  17. package/Statistic.js +5 -4
  18. package/Tour.js +4 -3
  19. package/Transfer.js +4 -2
  20. package/anchor/Link.js +1 -1
  21. package/app/App.js +26 -0
  22. package/app/context.js +9 -0
  23. package/app/index.js +9 -0
  24. package/app/interface.js +1 -0
  25. package/app/useApp.js +8 -0
  26. package/avatar/Group.js +1 -1
  27. package/back-top/index.js +44 -56
  28. package/button/index.js +52 -51
  29. package/calendar/Lunar.js +71 -0
  30. package/calendar/index.js +11 -11
  31. package/cascader/base/node.js +22 -20
  32. package/cascader/base/store.js +10 -10
  33. package/cascader/util.js +29 -27
  34. package/color-picker/Mode.js +8 -7
  35. package/color-picker/hooks/useColorPicker.js +56 -55
  36. package/color-picker/index.js +49 -48
  37. package/color-picker/utils.js +58 -57
  38. package/components/common/empty/index.js +2 -2
  39. package/components/common/flex/index.js +64 -55
  40. package/components/common/flex/interface.js +6 -6
  41. package/components/common/hooks/useInterval.js +6 -6
  42. package/components/common/icons/file/index.js +13 -11
  43. package/components/common/space/index.js +53 -53
  44. package/components/common/utils/dayjs.js +114 -126
  45. package/components/common/utils/is.js +98 -104
  46. package/components/common/utils/setDir.js +12 -0
  47. package/components/common/utils/setTheme.js +13 -13
  48. package/components/common/utils/toArray.js +7 -5
  49. package/config-provider/ConfigProvider.js +32 -30
  50. package/constant/index.js +4 -0
  51. package/copy/index.js +2 -1
  52. package/countdown/index.js +113 -0
  53. package/countdown/interface.js +1 -0
  54. package/countdown/util.js +29 -0
  55. package/descriptions/index.js +45 -45
  56. package/divider/index.js +28 -20
  57. package/dropdown/Button.js +1 -1
  58. package/empty/index.js +1 -1
  59. package/flex/index.js +30 -29
  60. package/form/FormItem.js +126 -122
  61. package/grid/Grid.js +56 -90
  62. package/grid/Item.js +44 -65
  63. package/grid/context.js +2 -6
  64. package/grid/index.js +6 -8
  65. package/grid/util.js +6 -44
  66. package/hooks/useResponsiveState.js +54 -0
  67. package/index.js +614 -605
  68. package/input/Button.js +12 -12
  69. package/input/Group.js +11 -12
  70. package/input/Input.js +112 -102
  71. package/input/InputElement.js +25 -24
  72. package/input/Search.js +24 -24
  73. package/layout/Sider.js +1 -1
  74. package/liquid-fill/index.js +4 -3
  75. package/list/Item.js +21 -21
  76. package/list/index.js +53 -52
  77. package/marquee/index.js +20 -19
  78. package/marquee-/index.js +4 -3
  79. package/mentions/util.js +9 -8
  80. package/modal/Confirm.js +17 -17
  81. package/modal/Modal.js +247 -237
  82. package/modal/index.js +4 -2
  83. package/modal/use-modal/index.js +2 -2
  84. package/package.json +1 -1
  85. package/page-header/index.js +57 -56
  86. package/pagination/Pagination.js +89 -92
  87. package/qr-code/index.js +4 -3
  88. package/radio/Group.js +1 -1
  89. package/row-col/Col-.js +88 -0
  90. package/row-col/Col.js +159 -0
  91. package/row-col/Row.js +73 -0
  92. package/row-col/context.js +5 -0
  93. package/row-col/index.js +11 -0
  94. package/row-col/interface.js +1 -0
  95. package/segmented/index.js +257 -206
  96. package/select/Select.js +191 -191
  97. package/select/util.js +50 -50
  98. package/select-view/Core.js +31 -28
  99. package/space/index.js +15 -13
  100. package/splitter/SplitBar.js +44 -46
  101. package/statistic/index.js +56 -55
  102. package/statistic/interface.js +4 -1
  103. package/style.css +1 -1
  104. package/table/Table.js +198 -210
  105. package/table/hook/useColumns.js +27 -26
  106. package/table/hook/useStickyClassNames.js +9 -8
  107. package/table/hook/useThResizable.js +4 -3
  108. package/table/th-resizable/index.js +2 -2
  109. package/table/thead/index.js +18 -16
  110. package/time-picker/util.js +20 -30
  111. package/timeline/Item.js +1 -1
  112. package/tour/index.js +4 -3
  113. package/transfer/index.js +93 -91
  114. package/trigger/index.js +66 -66
  115. package/types/common/development/interface.d.ts +3 -3
  116. package/types/common/flex/index.d.ts +3 -9
  117. package/types/common/flex/interface.d.ts +15 -4
  118. package/types/common/space/index.d.ts +3 -5
  119. package/types/common/space/interface.d.ts +2 -0
  120. package/types/common/utils/dayjs.d.ts +3 -1
  121. package/types/common/utils/is.d.ts +3 -4
  122. package/types/common/utils/setDir.d.ts +2 -0
  123. package/types/pc/app/App.d.ts +6 -0
  124. package/types/pc/app/context.d.ts +4 -0
  125. package/types/pc/app/index.d.ts +5 -0
  126. package/types/pc/app/interface.d.ts +17 -0
  127. package/types/pc/app/useApp.d.ts +3 -0
  128. package/types/pc/back-top/interface.d.ts +4 -17
  129. package/types/pc/button/interface.d.ts +2 -2
  130. package/types/pc/calendar/Lunar.d.ts +17 -0
  131. package/types/pc/calendar/index.d.ts +1 -1
  132. package/types/pc/config-provider/interface.d.ts +17 -12
  133. package/types/pc/constant/index.d.ts +1 -0
  134. package/types/pc/countdown/interface.d.ts +65 -0
  135. package/types/pc/countdown/util.d.ts +7 -0
  136. package/types/pc/divider/interface.d.ts +1 -0
  137. package/types/pc/flex/index.d.ts +8 -6
  138. package/types/pc/flex/interface.d.ts +3 -10
  139. package/types/pc/form/FormItem.d.ts +1 -1
  140. package/types/pc/form/interface.d.ts +1 -1
  141. package/types/pc/grid/Grid.d.ts +2 -4
  142. package/types/pc/grid/Item.d.ts +1 -5
  143. package/types/pc/grid/context.d.ts +4 -15
  144. package/types/pc/grid/index.d.ts +4 -6
  145. package/types/pc/grid/interface.d.ts +14 -142
  146. package/types/pc/grid/util.d.ts +1 -10
  147. package/types/pc/hooks/useResponsiveState.d.ts +3 -0
  148. package/types/pc/index.d.ts +10 -4
  149. package/types/pc/input/Button.d.ts +2 -2
  150. package/types/pc/list/interface.d.ts +2 -1
  151. package/types/pc/message/index.d.ts +1 -9
  152. package/types/pc/message/interface.d.ts +8 -0
  153. package/types/pc/message/useMessage.d.ts +1 -2
  154. package/types/pc/modal/Modal.d.ts +1 -0
  155. package/types/pc/modal/config.d.ts +1 -2
  156. package/types/pc/modal/index.d.ts +2 -1
  157. package/types/pc/modal/interface.d.ts +17 -5
  158. package/types/pc/notification/index.d.ts +2 -9
  159. package/types/pc/notification/interface.d.ts +7 -0
  160. package/types/pc/notification/useNotification.d.ts +1 -2
  161. package/types/pc/pagination/PageOption.d.ts +0 -1
  162. package/types/pc/pagination/interface.d.ts +5 -6
  163. package/types/pc/{grid → row-col}/Col-.d.ts +1 -1
  164. package/types/pc/{grid → row-col}/Col.d.ts +1 -2
  165. package/types/pc/{grid → row-col}/Row.d.ts +1 -2
  166. package/types/pc/row-col/context.d.ts +6 -0
  167. package/types/pc/row-col/index.d.ts +7 -0
  168. package/types/pc/row-col/interface.d.ts +112 -0
  169. package/types/pc/segmented/index.d.ts +3 -7
  170. package/types/pc/segmented/interface.d.ts +38 -5
  171. package/types/pc/select-view/Core.d.ts +1 -8
  172. package/types/pc/select-view/index.d.ts +1 -8
  173. package/types/pc/select-view/interface.d.ts +9 -2
  174. package/types/pc/space/index.d.ts +5 -7
  175. package/types/pc/space/interface.d.ts +3 -10
  176. package/types/pc/statistic/index.d.ts +1 -1
  177. package/types/pc/statistic/interface.d.ts +1 -49
  178. package/types/pc/utils/is.d.ts +1 -1
  179. package/types/pc/utils/names.d.ts +422 -111
  180. package/types/pc/utils/responsiveObserve.d.ts +8 -8
  181. package/typography/Ellipsis.js +5 -4
  182. package/typography/Operations.js +4 -3
  183. package/utils/dayjs.js +13 -11
  184. package/utils/index.js +245 -244
  185. package/utils/is.js +65 -66
  186. package/utils/names.js +309 -150
  187. package/utils/responsiveObserve.js +43 -36
  188. package/version/index.js +1 -1
  189. package/grid/Col-.js +0 -86
  190. package/grid/Col.js +0 -169
  191. package/grid/Row.js +0 -96
  192. package/grid/hook/useResponsiveState.js +0 -38
  193. package/statistic/Countdown.js +0 -56
  194. package/statistic/util.js +0 -33
  195. package/types/pc/grid/hook/useResponsiveState.d.ts +0 -2
  196. package/types/pc/statistic/util.d.ts +0 -1
  197. /package/types/pc/{statistic/Countdown.d.ts → countdown/index.d.ts} +0 -0
package/button/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import { jsx as l, jsxs as v, Fragment as A } from "react/jsx-runtime";
2
- import M from "@unicom-cloud/icons/IconUiLoading";
3
- import R, { forwardRef as Q, useContext as W, useState as Y, useRef as H, useEffect as J } from "react";
1
+ import { jsx as l, jsxs as A, Fragment as M } from "react/jsx-runtime";
2
+ import Q from "@unicom-cloud/icons/IconUiLoading";
3
+ import R, { forwardRef as W, useContext as Y, useState as H, useRef as J, useEffect as K } from "react";
4
4
  import "../config-provider/ConfigProvider.js";
5
- import K from "../components/common/hooks/useMergeProps.js";
6
- import V from "@unicom-cloud/utils/class-name";
7
- import X from "./Group.js";
8
- import Z from "../config-provider/context.js";
9
- const tt = /^[\u4e00-\u9fa5]{2}$/;
10
- function et(f) {
5
+ import V from "../components/common/hooks/useMergeProps.js";
6
+ import X from "@unicom-cloud/utils/class-name";
7
+ import Z from "./Group.js";
8
+ import tt from "../config-provider/context.js";
9
+ const et = /^[\u4e00-\u9fa5]{2}$/;
10
+ function nt(u) {
11
11
  const o = [];
12
12
  let i = !1;
13
- return R.Children.forEach(f, (e) => {
13
+ return R.Children.forEach(u, (e) => {
14
14
  const r = typeof e == "string" || typeof e == "number";
15
15
  if (r && i) {
16
- const a = o.length - 1, u = o[a];
17
- o[a] = `${u}${e}`;
16
+ const a = o.length - 1, f = o[a];
17
+ o[a] = `${f}${e}`;
18
18
  } else
19
19
  o.push(e);
20
20
  i = r;
@@ -23,21 +23,22 @@ function et(f) {
23
23
  (e) => typeof e == "string" ? /* @__PURE__ */ l("span", { children: e }) : e
24
24
  );
25
25
  }
26
- const nt = {
26
+ const ot = {
27
27
  htmlType: "button",
28
28
  type: "default",
29
- shape: "square"
29
+ shape: "square",
30
+ size: "medium"
30
31
  };
31
- function ot(f, o) {
32
+ function st(u, o) {
32
33
  const {
33
34
  getPrefixCls: i,
34
35
  size: e,
35
36
  autoInsertSpaceInButton: r,
36
37
  componentConfig: a,
37
- rtl: u
38
- } = W(Z), _ = K(
39
- f,
40
- nt,
38
+ rtl: f
39
+ } = Y(tt), _ = V(
40
+ u,
41
+ ot,
41
42
  a?.Button
42
43
  ), {
43
44
  style: g,
@@ -46,10 +47,10 @@ function ot(f, o) {
46
47
  htmlType: S,
47
48
  type: x,
48
49
  status: y,
49
- size: k,
50
- shape: U,
50
+ size: N = "medium",
51
+ shape: k,
51
52
  href: d,
52
- anchorProps: z,
53
+ anchorProps: U,
53
54
  disabled: c,
54
55
  loading: m,
55
56
  loadingFixedWidth: O,
@@ -59,56 +60,56 @@ function ot(f, o) {
59
60
  iconRight: j,
60
61
  onClick: D,
61
62
  long: L,
62
- ...N
63
- } = _, T = m ? /* @__PURE__ */ l(M, {}) : E, [h, B] = Y(!1), q = H(), s = o || q;
64
- J(() => {
63
+ ...T
64
+ } = _, q = N === "default" ? "medium" : N, B = m ? /* @__PURE__ */ l(Q, {}) : E, [h, P] = H(!1), v = J(), s = o || v;
65
+ K(() => {
65
66
  if (r && s && s.current) {
66
67
  const n = s.current.textContent;
67
- tt.test(n) ? h || B(!0) : h && B(!1);
68
+ et.test(n) ? h || P(!0) : h && P(!1);
68
69
  }
69
70
  }, [s.current, r]);
70
- const t = i?.("btn"), C = x === "default" ? "secondary" : x, P = V(
71
+ const t = i?.("btn"), C = x === "default" ? "secondary" : x, w = X(
71
72
  t,
72
73
  C === "text-only" && `${t}-text`,
73
74
  `${t}-${C}`,
74
- C !== "text-only" && `${t}-size-${k || e}`,
75
- `${t}-shape-${U}`,
75
+ C !== "text-only" && `${t}-size-${q || e}`,
76
+ `${t}-shape-${k}`,
76
77
  {
77
78
  [`${t}-long`]: L,
78
79
  [`${t}-status-${y}`]: y,
79
80
  [`${t}-loading-fixed-width`]: O,
80
81
  [`${t}-loading`]: m,
81
82
  [`${t}-link`]: d,
82
- [`${t}-icon-only`]: F || !p && p !== 0 && T,
83
+ [`${t}-icon-only`]: F || !p && p !== 0 && B,
83
84
  [`${t}-disabled`]: c,
84
85
  [`${t}-two-chinese-chars`]: h,
85
- [`${t}-rtl`]: u
86
+ [`${t}-rtl`]: f
86
87
  },
87
88
  I
88
- ), w = (n) => {
89
+ ), b = (n) => {
89
90
  if (m || c) {
90
91
  typeof n?.preventDefault == "function" && n.preventDefault();
91
92
  return;
92
93
  }
93
94
  D?.(n);
94
- }, b = /* @__PURE__ */ v(A, { children: [
95
- T,
96
- et(p),
95
+ }, z = /* @__PURE__ */ A(M, { children: [
96
+ B,
97
+ nt(p),
97
98
  j,
98
99
  G
99
100
  ] });
100
101
  if (d) {
101
- const n = { ...z };
102
+ const n = { ...U };
102
103
  return c ? delete n.href : n.href = d, /* @__PURE__ */ l(
103
104
  "a",
104
105
  {
105
106
  ref: s,
106
- ...N,
107
+ ...T,
107
108
  ...n,
108
109
  style: g,
109
- className: P,
110
- onClick: w,
111
- children: b
110
+ className: w,
111
+ onClick: b,
112
+ children: z
112
113
  }
113
114
  );
114
115
  }
@@ -116,21 +117,21 @@ function ot(f, o) {
116
117
  "button",
117
118
  {
118
119
  ref: s,
119
- ...N,
120
+ ...T,
120
121
  style: g,
121
- className: P,
122
+ className: w,
122
123
  type: S,
123
124
  disabled: c,
124
- onClick: w,
125
- children: b
125
+ onClick: b,
126
+ children: z
126
127
  }
127
128
  );
128
129
  }
129
- const st = Q(ot), $ = st;
130
+ const rt = W(st), $ = rt;
130
131
  $.__PQB_BUTTON = !0;
131
- $.Group = X;
132
+ $.Group = Z;
132
133
  $.displayName = "Button";
133
- const dt = [
134
+ const mt = [
134
135
  "default",
135
136
  "primary",
136
137
  "secondary",
@@ -138,10 +139,10 @@ const dt = [
138
139
  "text",
139
140
  "text-only",
140
141
  "outline"
141
- ], mt = ["warning", "danger", "success", "processing", "default"];
142
+ ], ht = ["warning", "danger", "success", "processing", "default"];
142
143
  export {
143
- mt as BUTTON_STATUS,
144
- dt as BUTTON_TYPE,
145
- X as ButtonGroup,
144
+ ht as BUTTON_STATUS,
145
+ mt as BUTTON_TYPE,
146
+ Z as ButtonGroup,
146
147
  $ as default
147
148
  };
@@ -0,0 +1,71 @@
1
+ import { jsx as a, jsxs as s } from "react/jsx-runtime";
2
+ import { LunarUtil as m, SolarUtil as g, Solar as u, Lunar as C } from "@unicom-cloud/utils/lunar";
3
+ import { useEffect as I } from "react";
4
+ import E from "./index.js";
5
+ import d from "../flex/index.js";
6
+ import S from "../space/index.js";
7
+ import "../components/common/utils/is.js";
8
+ import { isPlainObject as c } from "@unicom-cloud/utils/is";
9
+ function j(f) {
10
+ const { festival: n } = f;
11
+ return I(() => (c(n?.lunar) && Object.entries(n.lunar).forEach(([e, t], r, i) => {
12
+ m.FESTIVAL[e] = t;
13
+ }), () => {
14
+ c(n?.lunar) && Object.entries(n.lunar).forEach(([e, t], r, i) => {
15
+ delete m.FESTIVAL[e];
16
+ });
17
+ }), [n.lunar]), I(() => (c(n?.solar) && Object.entries(n.solar).forEach(([e, t], r, i) => {
18
+ g.FESTIVAL[e] = t;
19
+ }), () => {
20
+ c(n?.solar) && Object.entries(n.solar).forEach(([e, t], r, i) => {
21
+ delete g.FESTIVAL[e];
22
+ });
23
+ }), [n.solar]), /* @__PURE__ */ a(
24
+ E,
25
+ {
26
+ headerRender: ({
27
+ value: e,
28
+ pageShowDate: t,
29
+ onChangeMode: r,
30
+ onChange: i,
31
+ onChangePageDate: h,
32
+ header: o
33
+ }) => {
34
+ const p = t?.toDate?.(), D = u.fromDate(p), l = C.fromDate(p);
35
+ return /* @__PURE__ */ s(d.Vertical, { children: [
36
+ /* @__PURE__ */ a("div", { children: o }),
37
+ /* @__PURE__ */ s(d, { style: { padding: "0px 24px" }, children: [
38
+ /* @__PURE__ */ a("span", { children: l.getYearInChinese() }),
39
+ /* @__PURE__ */ a("span", { children: l.getYearInGanZhi() }),
40
+ /* @__PURE__ */ a("span", { children: l.getYearShengXiao() }),
41
+ /* @__PURE__ */ s("span", { children: [
42
+ l.getMonthInChinese(),
43
+ "月"
44
+ ] }),
45
+ /* @__PURE__ */ a("span", { children: l.getSeason() }),
46
+ /* @__PURE__ */ a("span", { children: D.getXingZuo() })
47
+ ] })
48
+ ] });
49
+ },
50
+ dateInnerContent: (e) => {
51
+ const t = u.fromDate(e.toDate()), r = C.fromDate(e.toDate()), i = r.getJieQi(), h = [
52
+ ...t.getFestivals(),
53
+ ...r.getFestivals()
54
+ // ...solar.getOtherFestivals(),
55
+ // ...lunar.getOtherFestivals(),
56
+ ];
57
+ let o = r.getDayInChinese();
58
+ return r.getDay() == 1 && (o = `${r.getMonthInChinese()}月${o}`), /* @__PURE__ */ s(d.Vertical, { gap: 0, children: [
59
+ /* @__PURE__ */ a("span", { children: o }),
60
+ !!h.length && /* @__PURE__ */ a(S, { children: h }),
61
+ !!i && /* @__PURE__ */ a("span", { children: i })
62
+ ] });
63
+ },
64
+ ...f
65
+ }
66
+ );
67
+ }
68
+ j.displayName = "LunarComponent";
69
+ export {
70
+ j as default
71
+ };
package/calendar/index.js CHANGED
@@ -6,10 +6,10 @@ import de from "../components/common/hooks/useMergeProps.js";
6
6
  import me from "@unicom-cloud/utils/class-name";
7
7
  import { getDayjsValue as u, getNow as A, methods as g } from "../components/common/utils/dayjs.js";
8
8
  import { pickDataAttributes as ce } from "../components/common/utils/pick.js";
9
- import ie, { getAllDaysByTime as pe } from "./Month.js";
10
- import fe from "./Year.js";
11
- import he from "./header/index.js";
12
- import ue from "./header/Panel.js";
9
+ import ie from "./header/index.js";
10
+ import pe from "./header/Panel.js";
11
+ import fe, { getAllDaysByTime as he } from "./Month.js";
12
+ import ue from "./Year.js";
13
13
  import ge from "../config-provider/context.js";
14
14
  function ye(m, y) {
15
15
  return m === "month" || m === "year" && !y ? "YYYY-MM-DD" : "YYYY-MM";
@@ -57,7 +57,7 @@ function De(m) {
57
57
  u(w || _, i)
58
58
  ), [X, p] = M(
59
59
  u(F, i) || Y || A()
60
- ), t = u(R, i) || X, C = "value" in s ? u(w, i) : Y, N = le(() => pe(s, t), [t.toString(), a, W]);
60
+ ), t = u(R, i) || X, C = "value" in s ? u(w, i) : Y, N = le(() => he(s, t), [t.toString(), a, W]);
61
61
  function f(e) {
62
62
  U(e), z?.(e), v(e);
63
63
  }
@@ -100,8 +100,8 @@ function De(m) {
100
100
  modes: I,
101
101
  innerMode: a,
102
102
  panelOperations: J
103
- }, $ = d ? /* @__PURE__ */ r(ue, { ...V }) : /* @__PURE__ */ r(
104
- he,
103
+ }, $ = d ? /* @__PURE__ */ r(pe, { ...V }) : /* @__PURE__ */ r(
104
+ ie,
105
105
  {
106
106
  ...V,
107
107
  CALENDAR_LOCALE: l,
@@ -129,7 +129,7 @@ function De(m) {
129
129
  header: $
130
130
  }) : $,
131
131
  a === "month" && /* @__PURE__ */ r("div", { className: `${o}-body`, children: /* @__PURE__ */ r(
132
- ie,
132
+ fe,
133
133
  {
134
134
  ...s,
135
135
  prefixCls: o,
@@ -142,7 +142,7 @@ function De(m) {
142
142
  }
143
143
  ) }),
144
144
  a === "year" && /* @__PURE__ */ r("div", { className: `${o}-body`, children: /* @__PURE__ */ r(
145
- fe,
145
+ ue,
146
146
  {
147
147
  ...s,
148
148
  prefixCls: o,
@@ -168,7 +168,7 @@ function De(m) {
168
168
  }
169
169
  De.displayName = "Calendar";
170
170
  export {
171
- ie as CalendarMonth,
172
- fe as CalendarYear,
171
+ fe as CalendarMonth,
172
+ ue as CalendarYear,
173
173
  De as default
174
174
  };
@@ -1,5 +1,7 @@
1
1
  import n from "lodash/get";
2
2
  import { DefaultFieldNames as _ } from "../Cascader.js";
3
+ import "../../components/common/utils/is.js";
4
+ import { isArray as C } from "@unicom-cloud/utils/is";
3
5
  class u {
4
6
  value;
5
7
  label;
@@ -27,21 +29,21 @@ class u {
27
29
  config = {};
28
30
  // 保存暴露给外部的属性
29
31
  _data;
30
- constructor(e, t, a) {
31
- this.config = t || {}, this._initNode(e, a || null);
32
+ constructor(e, t, h) {
33
+ this.config = t || {}, this._initNode(e, h || null);
32
34
  }
33
35
  _initNode = (e, t = null) => {
34
- const { showEmptyChildren: a, lazyload: l } = this.config, h = { ..._, ...this.config.fieldNames }, s = n(e, h.children) || e[h.children];
35
- let r = Array.isArray(s) ? a ? !1 : s.length === 0 : !0;
36
- l && (h.isLeaf in e ? r = !!n(e, h.isLeaf) || !!e[h.isLeaf] : r = !1);
37
- const c = n(e, h.value) || e[h.value], f = n(e, h.label) || e[h.label], d = {
36
+ const { showEmptyChildren: h, lazyload: a } = this.config, l = { ..._, ...this.config.fieldNames }, s = n(e, l.children) || e[l.children];
37
+ let r = C(s) ? h ? !1 : s.length === 0 : !0;
38
+ a && (l.isLeaf in e ? r = !!n(e, l.isLeaf) || !!e[l.isLeaf] : r = !1);
39
+ const c = n(e, l.value) || e[l.value], f = n(e, l.label) || e[l.label], d = {
38
40
  ...e,
39
41
  value: c,
40
42
  label: f,
41
43
  isLeaf: r,
42
44
  loading: !1,
43
45
  loaded: !1,
44
- disabled: t && t.disabled || n(e, h.disabled) || e[h.disabled],
46
+ disabled: t && t.disabled || n(e, l.disabled) || e[l.disabled],
45
47
  parent: t,
46
48
  pathValue: t ? [...t.pathValue, c] : [c],
47
49
  pathLabel: t ? [...t.pathLabel, f] : [f],
@@ -62,9 +64,9 @@ class u {
62
64
  * 那么只有当前节点的所有children加起来等于children.length,才是全选,否则和大于0,就是半选。
63
65
  */
64
66
  _isHalfChecked = () => {
65
- const e = this.children.reduce((t, a) => {
66
- const l = a._halfChecked ? 0.5 : a._checked ? 1 : 0;
67
- return t + l;
67
+ const e = this.children.reduce((t, h) => {
68
+ const a = h._halfChecked ? 0.5 : h._checked ? 1 : 0;
69
+ return t + a;
68
70
  }, 0);
69
71
  return e !== this.children.length && e > 0;
70
72
  };
@@ -74,18 +76,18 @@ class u {
74
76
  * @param ignoreDisabled 是否忽略节点禁用设置选中状态,一般在初始化设置选中状态时传参为true
75
77
  */
76
78
  _setNodeChildrenChecked = (e, t) => {
77
- !t && this.disabled || this.children && this.children.length && (this.children.forEach((a) => {
78
- a.disabled ? t && a.setCheckedStateIgnoreDisabled(e) : a.setCheckedState(e);
79
+ !t && this.disabled || this.children && this.children.length && (this.children.forEach((h) => {
80
+ h.disabled ? t && h.setCheckedStateIgnoreDisabled(e) : h.setCheckedState(e);
79
81
  }), this.updateHalfState(e));
80
82
  };
81
83
  getSelfChildrenValue = () => {
82
- const e = [], t = (a, l) => {
83
- if (!l || !l.length) {
84
- e.push(a);
84
+ const e = [], t = (h, a) => {
85
+ if (!a || !a.length) {
86
+ e.push(h);
85
87
  return;
86
88
  }
87
- (l || []).forEach((h) => {
88
- t(h.pathValue, h.children);
89
+ (a || []).forEach((l) => {
90
+ t(l.pathValue, l.children);
89
91
  });
90
92
  };
91
93
  return t(this.pathValue, this.children), e;
@@ -102,9 +104,9 @@ class u {
102
104
  const t = e ? this._checked : !this._checked && !this._halfChecked;
103
105
  if (!(this.disabled || t) && (this.setCheckedProperty(e), !this.config.changeOnSelect)) {
104
106
  this._setNodeChildrenChecked(e);
105
- let a = this.parent;
106
- for (; a && !a.disabled; )
107
- a.updateHalfState(e), a = a.parent;
107
+ let h = this.parent;
108
+ for (; h && !h.disabled; )
109
+ h.updateHalfState(e), h = h.parent;
108
110
  }
109
111
  };
110
112
  // 忽略禁用设置选中状态
@@ -1,16 +1,16 @@
1
- import n from "lodash/isArray";
1
+ import o from "lodash/isArray";
2
2
  import f from "lodash/isEqualWith";
3
3
  import l from "lodash/isFunction";
4
4
  import c from "lodash/isString";
5
- import { transformValuesToSet as d, valueInSet as o } from "../util.js";
5
+ import { transformValuesToSet as d, valueInSet as h } from "../util.js";
6
6
  import u from "./node.js";
7
- class S {
7
+ class C {
8
8
  nodes = [];
9
9
  flatNodes = [];
10
10
  config = {};
11
11
  constructor(e, t, s) {
12
12
  this.config = { ...s };
13
- const r = Array.isArray(t) ? t : [];
13
+ const r = o(t) ? t : [];
14
14
  this.nodes = this._calcNodes(e, null), this._updateFlatNodes(), this.setNodeCheckedByValue(r);
15
15
  }
16
16
  // 初始化节点状态,附加状态信息字段: _checked,_halfChecked,parent,disabled
@@ -20,7 +20,7 @@ class S {
20
20
  const e = !this.config.changeOnSelect;
21
21
  this.flatNodes = [];
22
22
  const t = (s) => {
23
- s && ((!e || s.isLeaf) && this.flatNodes.push(s), n(s.children) && s.children.forEach((r) => {
23
+ s && ((!e || s.isLeaf) && this.flatNodes.push(s), o(s.children) && s.children.forEach((r) => {
24
24
  t(r);
25
25
  }));
26
26
  };
@@ -38,8 +38,8 @@ class S {
38
38
  this.flatNodes.forEach((s) => {
39
39
  let r = !1;
40
40
  this.config.showParent ? s.pathValue.some(
41
- (a, i, h) => o(t, h.slice(0, i + 1))
42
- ) && (r = !0) : o(t, s.pathValue) && (r = !0), s.setCheckedStateIgnoreDisabled(r);
41
+ (i, a, n) => h(t, n.slice(0, a + 1))
42
+ ) && (r = !0) : h(t, s.pathValue) && (r = !0), s.setCheckedStateIgnoreDisabled(r);
43
43
  });
44
44
  };
45
45
  /**
@@ -67,8 +67,8 @@ class S {
67
67
  searchNodeByLabel = (e) => {
68
68
  if (!e)
69
69
  return this.flatNodes;
70
- const { filterOption: t } = this.config, s = l(t) ? t : (r, a) => c(a.label) && a.label.indexOf(r) > -1;
71
- return this.flatNodes.filter((r) => r.getPathNodes().some((i) => s(e, i._data)));
70
+ const { filterOption: t } = this.config, s = l(t) ? t : (r, i) => c(i.label) && i.label.indexOf(r) > -1;
71
+ return this.flatNodes.filter((r) => r.getPathNodes().some((a) => s(e, a._data)));
72
72
  };
73
73
  /** 获取所有节点 */
74
74
  getOptions = () => this.nodes;
@@ -86,5 +86,5 @@ class S {
86
86
  };
87
87
  }
88
88
  export {
89
- S as default
89
+ C as default
90
90
  };
package/cascader/util.js CHANGED
@@ -1,49 +1,51 @@
1
- import k from "./base/store.js";
2
- const a = "__pqb_cascader__", y = "parent", O = "child", j = {
1
+ import "../components/common/utils/is.js";
2
+ import C from "./base/store.js";
3
+ import { isArray as V } from "@unicom-cloud/utils/is";
4
+ const a = "__pqb_cascader__", N = "parent", v = "child", E = {
3
5
  cascader: "cascader",
4
6
  select: "select"
5
7
  };
6
- function C(e) {
8
+ function w(e) {
7
9
  return {
8
10
  showEmptyChildren: e.showEmptyChildren,
9
11
  changeOnSelect: e.changeOnSelect,
10
12
  lazyload: !!e.loadMore,
11
13
  fieldNames: e.fieldNames,
12
14
  filterOption: e.filterOption,
13
- showParent: e.mode === "multiple" && !e.changeOnSelect && e.checkedStrategy === y
15
+ showParent: e.mode === "multiple" && !e.changeOnSelect && e.checkedStrategy === N
14
16
  };
15
17
  }
16
- function A(e, t) {
17
- const n = t ? Array.isArray(t[0]) ? t : [t] : [];
18
- return new k(e.options || [], n, C(e));
18
+ function P(e, t) {
19
+ const n = t ? V(t[0]) ? t : [t] : [];
20
+ return new C(e.options || [], n, w(e));
19
21
  }
20
- const V = (e) => (e || []).reduce((c, o) => (c.add([].concat(o).join(a)), c), /* @__PURE__ */ new Set()), i = (e, t) => {
22
+ const g = (e) => (e || []).reduce((c, o) => (c.add([].concat(o).join(a)), c), /* @__PURE__ */ new Set()), i = (e, t) => {
21
23
  const n = t || [];
22
24
  return e.has(n.join(a));
23
- }, v = (e, t) => {
25
+ }, b = (e, t) => {
24
26
  const n = t || [];
25
27
  return e.delete(n.join(a));
26
- }, E = (e, t, n) => {
28
+ }, A = (e, t, n) => {
27
29
  let c = [];
28
30
  if (e === void 0 ? c = [] : t ? c = e : c = [e], n && n.config.showParent) {
29
- const o = n.getCheckedNodes(), h = V(
31
+ const o = n.getCheckedNodes(), h = g(
30
32
  o.map((l) => l.pathValue)
31
33
  ), f = [], s = {};
32
34
  return c.map((l, S, r) => {
33
- l.some((u, m, g) => {
34
- const d = g.slice(0, m + 1), _ = i(h, d);
35
+ l.some((u, m, k) => {
36
+ const d = k.slice(0, m + 1), _ = i(h, d);
35
37
  return _ && !s[d.join(a)] && (f.push(d), s[d.join(a)] = 1), _;
36
38
  });
37
39
  }), f;
38
40
  }
39
41
  return c;
40
- }, N = (e) => {
41
- const t = (n) => Array.isArray(n) ? n.every((c) => c._checked || c.disabled ? !0 : t(c.children)) : !1;
42
+ }, y = (e) => {
43
+ const t = (n) => V(n) ? n.every((c) => c._checked || c.disabled ? !0 : t(c.children)) : !1;
42
44
  return e._halfChecked && t(e?.children);
43
- }, P = (e, t, n, c) => {
44
- const o = c && N(n) ? !1 : c, h = t.getCheckedNodes().reduce((r, u) => (r.add(u.pathValue.join(a)), r), /* @__PURE__ */ new Set());
45
+ }, H = (e, t, n, c) => {
46
+ const o = c && y(n) ? !1 : c, h = t.getCheckedNodes().reduce((r, u) => (r.add(u.pathValue.join(a)), r), /* @__PURE__ */ new Set());
45
47
  n.setCheckedState(o);
46
- const s = t.getCheckedNodes().map((r) => r.pathValue), l = V(s), S = /* @__PURE__ */ new Set();
48
+ const s = t.getCheckedNodes().map((r) => r.pathValue), l = g(s), S = /* @__PURE__ */ new Set();
47
49
  return e.filter((r, u, m) => {
48
50
  if (!i(h, r) || i(l, r))
49
51
  return S.add(r.join(a)), !0;
@@ -52,15 +54,15 @@ const V = (e) => (e || []).reduce((c, o) => (c.add([].concat(o).join(a)), c), /*
52
54
  );
53
55
  };
54
56
  export {
55
- j as PANEL_MODE,
56
- O as SHOW_CHILD,
57
- y as SHOW_PARENT,
57
+ E as PANEL_MODE,
58
+ v as SHOW_CHILD,
59
+ N as SHOW_PARENT,
58
60
  a as ValueSeparator,
59
- E as formatValue,
60
- C as getConfig,
61
- P as getMultipleCheckValue,
62
- A as getStore,
63
- v as removeValueFromSet,
64
- V as transformValuesToSet,
61
+ A as formatValue,
62
+ w as getConfig,
63
+ H as getMultipleCheckValue,
64
+ P as getStore,
65
+ b as removeValueFromSet,
66
+ g as transformValuesToSet,
65
67
  i as valueInSet
66
68
  };
@@ -1,10 +1,11 @@
1
+ import i from "lodash/isArray";
1
2
  import { ColorPickerMode as t } from "./interface.js";
2
- const i = (r) => Array.isArray(r) && r.length === 1 ? r[0] : r, g = (r) => i(r) === t.Single, A = (r) => i(r) === t.Gradient, o = (r) => Array.isArray(i(r)), s = (r) => o(r) ? t.Gradient : r, c = (r, n, e) => r && Array.isArray(r) ? t.Gradient : r && typeof r == "string" ? t.Single : n && Array.isArray(n) ? t.Gradient : n && typeof n == "string" ? t.Single : s(e);
3
+ const e = (r) => i(r) && r.length === 1 ? r[0] : r, f = (r) => e(r) === t.Single, d = (r) => e(r) === t.Gradient, s = (r) => i(e(r)), g = (r) => s(r) ? t.Gradient : r, p = (r, n, o) => r && i(r) ? t.Gradient : r && typeof r == "string" ? t.Single : n && i(n) ? t.Gradient : n && typeof n == "string" ? t.Single : g(o);
3
4
  export {
4
- s as getInitialActiveMode,
5
- i as getMode,
6
- c as getModeByValue,
7
- A as isGradientMode,
8
- o as isMultiMode,
9
- g as isSingleMode
5
+ g as getInitialActiveMode,
6
+ e as getMode,
7
+ p as getModeByValue,
8
+ d as isGradientMode,
9
+ s as isMultiMode,
10
+ f as isSingleMode
10
11
  };