@unicom-cloud/ui 0.8.107 → 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 (137) hide show
  1. package/ColorPicker.js +15 -14
  2. package/Constant.js +4 -0
  3. package/Copy.js +4 -3
  4. package/Countdown.js +25 -0
  5. package/Grid.js +8 -10
  6. package/LiquidFill.js +4 -3
  7. package/List.js +7 -6
  8. package/Marquee.js +4 -3
  9. package/PageHeader.js +3 -2
  10. package/QrCode.js +4 -3
  11. package/RowCol.js +8 -0
  12. package/Segmented.js +14 -4
  13. package/Statistic.js +5 -4
  14. package/Tour.js +4 -3
  15. package/Transfer.js +4 -2
  16. package/anchor/Link.js +1 -1
  17. package/avatar/Group.js +1 -1
  18. package/button/index.js +52 -51
  19. package/calendar/Lunar.js +21 -21
  20. package/cascader/base/node.js +22 -20
  21. package/cascader/base/store.js +10 -10
  22. package/cascader/util.js +29 -27
  23. package/color-picker/Mode.js +8 -7
  24. package/color-picker/hooks/useColorPicker.js +56 -55
  25. package/color-picker/index.js +54 -53
  26. package/color-picker/utils.js +58 -57
  27. package/components/common/empty/index.js +2 -2
  28. package/components/common/flex/index.js +64 -55
  29. package/components/common/flex/interface.js +6 -6
  30. package/components/common/hooks/useInterval.js +6 -6
  31. package/components/common/space/index.js +53 -53
  32. package/components/common/utils/dayjs.js +75 -62
  33. package/components/common/utils/toArray.js +7 -5
  34. package/constant/index.js +4 -0
  35. package/copy/index.js +2 -1
  36. package/countdown/index.js +113 -0
  37. package/countdown/interface.js +1 -0
  38. package/countdown/util.js +29 -0
  39. package/descriptions/index.js +26 -26
  40. package/dropdown/Button.js +1 -1
  41. package/flex/index.js +30 -29
  42. package/form/FormItem.js +126 -122
  43. package/grid/Grid.js +40 -41
  44. package/grid/Item.js +37 -37
  45. package/grid/context.js +2 -3
  46. package/grid/index.js +6 -8
  47. package/hooks/useResponsiveState.js +54 -0
  48. package/index.js +614 -610
  49. package/input/InputElement.js +25 -24
  50. package/layout/Sider.js +1 -1
  51. package/liquid-fill/index.js +4 -3
  52. package/list/Item.js +21 -21
  53. package/list/index.js +53 -52
  54. package/marquee/index.js +20 -19
  55. package/marquee-/index.js +4 -3
  56. package/mentions/util.js +9 -8
  57. package/package.json +1 -1
  58. package/page-header/index.js +57 -56
  59. package/pagination/Pagination.js +89 -92
  60. package/qr-code/index.js +4 -3
  61. package/radio/Group.js +1 -1
  62. package/row-col/Col-.js +88 -0
  63. package/row-col/Col.js +159 -0
  64. package/row-col/Row.js +73 -0
  65. package/row-col/context.js +5 -0
  66. package/row-col/index.js +11 -0
  67. package/row-col/interface.js +1 -0
  68. package/segmented/index.js +257 -206
  69. package/select/Select.js +191 -191
  70. package/select/util.js +50 -50
  71. package/space/index.js +15 -13
  72. package/statistic/index.js +56 -55
  73. package/statistic/interface.js +4 -1
  74. package/style.css +1 -1
  75. package/table/hook/useColumns.js +27 -26
  76. package/table/hook/useStickyClassNames.js +9 -8
  77. package/table/hook/useThResizable.js +4 -3
  78. package/table/th-resizable/index.js +11 -10
  79. package/table/thead/index.js +18 -16
  80. package/timeline/Item.js +1 -1
  81. package/tour/index.js +4 -3
  82. package/transfer/index.js +93 -91
  83. package/trigger/index.js +66 -66
  84. package/types/common/flex/index.d.ts +3 -9
  85. package/types/common/flex/interface.d.ts +15 -4
  86. package/types/common/space/index.d.ts +3 -5
  87. package/types/common/space/interface.d.ts +2 -0
  88. package/types/common/utils/dayjs.d.ts +3 -1
  89. package/types/pc/button/interface.d.ts +2 -2
  90. package/types/pc/config-provider/interface.d.ts +16 -11
  91. package/types/pc/constant/index.d.ts +1 -0
  92. package/types/pc/countdown/interface.d.ts +65 -0
  93. package/types/pc/countdown/util.d.ts +7 -0
  94. package/types/pc/flex/index.d.ts +8 -6
  95. package/types/pc/flex/interface.d.ts +3 -10
  96. package/types/pc/form/FormItem.d.ts +1 -1
  97. package/types/pc/form/interface.d.ts +1 -1
  98. package/types/pc/grid/Grid.d.ts +1 -2
  99. package/types/pc/grid/Item.d.ts +1 -2
  100. package/types/pc/grid/context.d.ts +0 -5
  101. package/types/pc/grid/index.d.ts +4 -6
  102. package/types/pc/grid/interface.d.ts +7 -125
  103. package/types/pc/hooks/useResponsiveState.d.ts +3 -0
  104. package/types/pc/index.d.ts +7 -3
  105. package/types/pc/list/interface.d.ts +2 -1
  106. package/types/pc/pagination/PageOption.d.ts +0 -1
  107. package/types/pc/pagination/interface.d.ts +5 -6
  108. package/types/pc/{grid → row-col}/Col-.d.ts +1 -1
  109. package/types/pc/{grid → row-col}/Col.d.ts +1 -2
  110. package/types/pc/{grid → row-col}/Row.d.ts +1 -2
  111. package/types/pc/row-col/context.d.ts +6 -0
  112. package/types/pc/row-col/index.d.ts +7 -0
  113. package/types/pc/row-col/interface.d.ts +112 -0
  114. package/types/pc/segmented/index.d.ts +3 -7
  115. package/types/pc/segmented/interface.d.ts +38 -5
  116. package/types/pc/space/index.d.ts +5 -7
  117. package/types/pc/space/interface.d.ts +3 -10
  118. package/types/pc/statistic/index.d.ts +1 -1
  119. package/types/pc/statistic/interface.d.ts +1 -49
  120. package/types/pc/utils/names.d.ts +121 -113
  121. package/types/pc/utils/responsiveObserve.d.ts +8 -8
  122. package/typography/Ellipsis.js +5 -4
  123. package/typography/Operations.js +4 -3
  124. package/utils/dayjs.js +13 -11
  125. package/utils/index.js +244 -242
  126. package/utils/names.js +15 -10
  127. package/utils/responsiveObserve.js +43 -36
  128. package/version/index.js +1 -1
  129. package/grid/Col-.js +0 -86
  130. package/grid/Col.js +0 -169
  131. package/grid/Row.js +0 -96
  132. package/grid/hook/useResponsiveState.js +0 -35
  133. package/statistic/Countdown.js +0 -56
  134. package/statistic/util.js +0 -33
  135. package/types/pc/grid/hook/useResponsiveState.d.ts +0 -2
  136. package/types/pc/statistic/util.d.ts +0 -1
  137. /package/types/pc/{statistic/Countdown.d.ts → countdown/index.d.ts} +0 -0
@@ -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
  };
@@ -1,86 +1,87 @@
1
1
  import P from "@unicom-cloud/utils/tinycolor";
2
- import { useState as C, useRef as k, useMemo as G, useCallback as F, useEffect as M } from "react";
3
- import Z from "../../components/common/hooks/useIsFirstRender.js";
4
- import q from "../../components/common/hooks/useMergeValue.js";
5
- import { ColorPickerMode as y } from "../interface.js";
6
- import { getModeByValue as $, isGradientMode as H, isSingleMode as w } from "../Mode.js";
7
- import { mapValueToGradientColor as ee, getColorFromHsv as E, formatRgba as oe, formatHex as te, isEqualsColors as re, equalsHsv as ne, getRandomId as T } from "../utils.js";
8
- const ge = (s) => {
2
+ import k from "lodash/isArray";
3
+ import { useState as C, useRef as F, useMemo as G, useCallback as q, useEffect as M } from "react";
4
+ import $ from "../../components/common/hooks/useIsFirstRender.js";
5
+ import E from "../../components/common/hooks/useMergeValue.js";
6
+ import { ColorPickerMode as H } from "../interface.js";
7
+ import { getModeByValue as w, isGradientMode as R, isSingleMode as ee } from "../Mode.js";
8
+ import { mapValueToGradientColor as oe, getColorFromHsv as T, formatRgba as te, formatHex as re, isEqualsColors as ne, equalsHsv as se, getRandomId as B } from "../utils.js";
9
+ const ve = (s) => {
9
10
  const {
10
- mode: B = y.Single,
11
- defaultValue: j,
12
- format: R,
13
- onChange: z,
11
+ mode: j = H.Single,
12
+ defaultValue: z,
13
+ format: _,
14
+ onChange: D,
14
15
  disabledAlpha: h
15
- } = s, D = Z(), [p, J] = q(!1, {
16
+ } = s, J = $(), [p, K] = E(!1, {
16
17
  defaultValue: s.defaultPopupVisible,
17
18
  value: s.popupVisible
18
- }), [i, K] = C(
19
- $(
19
+ }), [i, L] = C(
20
+ w(
20
21
  s.value,
21
- j,
22
- B
22
+ z,
23
+ j
23
24
  )
24
- ), [r, L] = q(
25
- i === y.Gradient ? void 0 : "",
25
+ ), [r, N] = E(
26
+ i === H.Gradient ? void 0 : "",
26
27
  s
27
- ), [_, N] = C(
28
- H(i) && Array.isArray(r) ? ee(r, h) : []
29
- ), [O, Q] = C(_[0]?.id), v = k(_), b = k(O), o = v.current, A = b.current, m = (e) => {
30
- N(e), v.current = typeof e == "function" ? e(v.current) : e;
31
- }, x = (e) => {
32
- Q(e), b.current = e;
28
+ ), [x, O] = C(
29
+ R(i) && k(r) ? oe(r, h) : []
30
+ ), [Q, U] = C(x[0]?.id), v = F(x), b = F(Q), o = v.current, V = b.current, m = (e) => {
31
+ O(e), v.current = typeof e == "function" ? e(v.current) : e;
32
+ }, S = (e) => {
33
+ U(e), b.current = e;
33
34
  }, c = G(() => {
34
35
  const e = o.findIndex(
35
- (t) => t.id === A
36
+ (t) => t.id === V
36
37
  );
37
38
  return e !== -1 ? e : 0;
38
- }, [o, A]), u = Array.isArray(r) ? new P(r[c].color).toHsv_() : new P(r).toHsv_(), [d, S] = C({
39
+ }, [o, V]), u = k(r) ? new P(r[c].color).toHsv_() : new P(r).toHsv_(), [d, y] = C({
39
40
  h: u.h,
40
41
  s: u.s,
41
42
  v: u.v
42
- }), [n, V] = C(u.a), f = G(() => E(d), [d]), I = F(
43
- (e, t, a, l) => R === "rgb" ? oe(e, t, a, l) : te(e, t, a, l),
44
- [R]
43
+ }), [n, I] = C(u.a), f = G(() => T(d), [d]), A = q(
44
+ (e, t, a, l) => _ === "rgb" ? te(e, t, a, l) : re(e, t, a, l),
45
+ [_]
45
46
  ), g = G(() => {
46
- if (w(i)) {
47
+ if (ee(i)) {
47
48
  const { r: e, g: t, b: a } = f.rgb;
48
- return I(e, t, a, n);
49
+ return A(e, t, a, n);
49
50
  }
50
51
  return o.map((e) => {
51
52
  const { r: t, g: a, b: l } = e.color.rgb;
52
53
  return {
53
- color: I(t, a, l, e.alpha),
54
+ color: A(t, a, l, e.alpha),
54
55
  percent: e.percent
55
56
  };
56
57
  });
57
- }, [i, o, f.rgb, I, n]);
58
+ }, [i, o, f.rgb, A, n]);
58
59
  M(() => {
59
- L(g), !D && !re(r, g) && z?.(g);
60
+ N(g), !J && !ne(r, g) && D?.(g);
60
61
  }, [g]);
61
- const U = F(
62
+ const W = q(
62
63
  (e) => {
63
64
  if (e && r !== g) {
64
- const { h: t, s: a, v: l, a: Y } = u;
65
- S({ h: t, s: a, v: l }), V(Y);
65
+ const { h: t, s: a, v: l, a: Z } = u;
66
+ y({ h: t, s: a, v: l }), I(Z);
66
67
  }
67
- e !== p && (s.onVisibleChange?.(e), "popupVisible" in s || J(e));
68
+ e !== p && (s.onVisibleChange?.(e), "popupVisible" in s || K(e));
68
69
  },
69
70
  [s.onVisibleChange, p, r]
70
- ), W = (e) => {
71
- S(e), h && n !== 100 && V(100);
72
- }, X = (e) => {
73
- V(e);
71
+ ), X = (e) => {
72
+ y(e), h && n !== 100 && I(100);
73
+ }, Y = (e) => {
74
+ I(e);
74
75
  };
75
76
  return M(() => {
76
- if (!H(i) || !o.length || ne(o[c].color.hsv, d)) return;
77
+ if (!R(i) || !o.length || se(o[c].color.hsv, d)) return;
77
78
  const e = [...o];
78
79
  e[c] = {
79
80
  ...e[c],
80
- color: E(d)
81
+ color: T(d)
81
82
  }, m(e);
82
83
  }, [d]), M(() => {
83
- if (!H(i) || !o.length || o[c].alpha === n) return;
84
+ if (!R(i) || !o.length || o[c].alpha === n) return;
84
85
  const e = [...o];
85
86
  e[c] = {
86
87
  ...e[c],
@@ -91,34 +92,34 @@ const ge = (s) => {
91
92
  activeMode: i,
92
93
  gradientColors: o,
93
94
  gradientColorsRef: v,
94
- activeColorId: A,
95
+ activeColorId: V,
95
96
  activeColorIdRef: b,
96
97
  popupVisible: p,
97
98
  color: f,
98
99
  alpha: n,
99
- onHsvChange: W,
100
- onAlphaChange: X,
101
- onVisibleChange: U,
100
+ onHsvChange: X,
101
+ onAlphaChange: Y,
102
+ onVisibleChange: W,
102
103
  onActiveModeChange: (e) => {
103
- e !== i && (e === y.Single ? x(o[0]?.id) : m([
104
+ e !== i && (e === H.Single ? S(o[0]?.id) : m([
104
105
  {
105
- id: T(),
106
+ id: B(),
106
107
  color: f,
107
108
  alpha: n,
108
109
  percent: 0
109
110
  },
110
111
  {
111
- id: T(),
112
+ id: B(),
112
113
  color: f,
113
114
  alpha: n,
114
115
  percent: 100
115
116
  }
116
- ]), K(e));
117
+ ]), L(e));
117
118
  },
118
- onActiveColorIdChange: x,
119
+ onActiveColorIdChange: S,
119
120
  onGradientColorsChange: m
120
121
  };
121
122
  };
122
123
  export {
123
- ge as useColorPicker
124
+ ve as useColorPicker
124
125
  };
@@ -1,32 +1,33 @@
1
1
  import { jsx as e, jsxs as p } from "react/jsx-runtime";
2
- import G from "lodash/isFunction";
3
- import S from "lodash/isNil";
4
- import D, { useContext as q } from "react";
2
+ import G from "lodash/isArray";
3
+ import S from "lodash/isFunction";
4
+ import D from "lodash/isNil";
5
+ import q, { useContext as J } from "react";
5
6
  import "../config-provider/ConfigProvider.js";
6
- import J from "../copy/index.js";
7
- import K from "../components/common/hooks/useMergeProps.js";
8
- import L from "../trigger/index.js";
9
- import Q from "@unicom-cloud/utils/class-name";
10
- import { colors as U } from "./colors.js";
11
- import { ControlBar as kr } from "./ControlBar.js";
12
- import { useColorPicker as W } from "./hooks/useColorPicker.js";
13
- import { InputAlpha as yr } from "./InputAlpha.js";
14
- import { InputHex as Nr } from "./InputHex.js";
15
- import { InputRgb as br } from "./InputRgb.js";
16
- import { Palette as zr } from "./Palette.js";
17
- import { Panel as X } from "./Panel.js";
18
- import { getGradientString as Y, renderBackground as Z } from "./utils.js";
19
- import _ from "../config-provider/context.js";
7
+ import K from "../copy/index.js";
8
+ import L from "../components/common/hooks/useMergeProps.js";
9
+ import Q from "../trigger/index.js";
10
+ import U from "@unicom-cloud/utils/class-name";
11
+ import { colors as W } from "./colors.js";
12
+ import { ControlBar as Io } from "./ControlBar.js";
13
+ import { useColorPicker as X } from "./hooks/useColorPicker.js";
14
+ import { InputAlpha as bo } from "./InputAlpha.js";
15
+ import { InputHex as $o } from "./InputHex.js";
16
+ import { InputRgb as wo } from "./InputRgb.js";
17
+ import { Palette as Ro } from "./Palette.js";
18
+ import { Panel as Y } from "./Panel.js";
19
+ import { getGradientString as Z, renderBackground as _ } from "./utils.js";
20
+ import oo from "../config-provider/context.js";
20
21
  const c = {
21
22
  size: "default",
22
- presetColors: U
23
+ presetColors: W
23
24
  };
24
- function rr(t, m) {
25
+ function ro(t, m) {
25
26
  const {
26
27
  getPrefixCls: d,
27
28
  componentConfig: g,
28
29
  size: u
29
- } = q(_), n = K(
30
+ } = J(oo), n = L(
30
31
  t,
31
32
  { ...c, size: u || c.size },
32
33
  g?.ColorPicker
@@ -43,10 +44,10 @@ function rr(t, m) {
43
44
  historyColors: y,
44
45
  presetColors: I,
45
46
  showHistory: N,
46
- showPreset: A,
47
- renderFooter: b
48
- } = n, o = d?.("color-picker"), {
49
- value: r,
47
+ showPreset: b,
48
+ renderFooter: A
49
+ } = n, r = d?.("color-picker"), {
50
+ value: o,
50
51
  activeMode: $,
51
52
  gradientColors: z,
52
53
  activeColorId: w,
@@ -60,14 +61,14 @@ function rr(t, m) {
60
61
  onActiveModeChange: V,
61
62
  onGradientColorsChange: j,
62
63
  onActiveColorIdChange: F
63
- } = W(n);
64
+ } = X(n);
64
65
  return /* @__PURE__ */ e(
65
- L,
66
+ Q,
66
67
  {
67
68
  popup: () => /* @__PURE__ */ e(
68
- X,
69
+ Y,
69
70
  {
70
- value: r,
71
+ value: o,
71
72
  mode: h,
72
73
  activeMode: $,
73
74
  gradientColors: z,
@@ -78,14 +79,14 @@ function rr(t, m) {
78
79
  historyColors: y,
79
80
  presetColors: I,
80
81
  showHistory: N,
81
- showPreset: A,
82
+ showPreset: b,
82
83
  onHsvChange: M,
83
84
  onAlphaChange: O,
84
85
  onActiveModeChange: V,
85
86
  onGradientColorsChange: j,
86
87
  onActiveColorIdChange: F,
87
88
  disabledAlpha: x,
88
- renderFooter: b
89
+ renderFooter: A
89
90
  }
90
91
  ),
91
92
  trigger: "click",
@@ -103,16 +104,16 @@ function rr(t, m) {
103
104
  ...P,
104
105
  onVisibleChange: T,
105
106
  children: (() => {
106
- const a = G(t.triggerElement) ? t.triggerElement({ value: r }) : t.triggerElement;
107
- if (!S(a))
107
+ const a = S(t.triggerElement) ? t.triggerElement({ value: o }) : t.triggerElement;
108
+ if (!D(a))
108
109
  return a;
109
- const s = typeof r == "string" ? r : Y(r);
110
+ const s = typeof o == "string" ? o : Z(o);
110
111
  return /* @__PURE__ */ p(
111
112
  "div",
112
113
  {
113
- className: Q(o, f, {
114
- [`${o}-size-${l}`]: l,
115
- [`${o}-disabled`]: i
114
+ className: U(r, f, {
115
+ [`${r}-size-${l}`]: l,
116
+ [`${r}-disabled`]: i
116
117
  }),
117
118
  style: C,
118
119
  ref: m,
@@ -120,20 +121,20 @@ function rr(t, m) {
120
121
  /* @__PURE__ */ e(
121
122
  "div",
122
123
  {
123
- className: `${o}-preview`,
124
- style: Array.isArray(r) ? {
125
- background: Z(r)
126
- } : { backgroundColor: r }
124
+ className: `${r}-preview`,
125
+ style: G(o) ? {
126
+ background: _(o)
127
+ } : { backgroundColor: o }
127
128
  }
128
129
  ),
129
- !!v && /* @__PURE__ */ p("div", { className: `${o}-value`, children: [
130
+ !!v && /* @__PURE__ */ p("div", { className: `${r}-value`, children: [
130
131
  s,
131
- !i && /* @__PURE__ */ e(J, { text: s, className: `${o}-copy` })
132
+ !i && /* @__PURE__ */ e(K, { text: s, className: `${r}-copy` })
132
133
  ] }),
133
134
  /* @__PURE__ */ e(
134
135
  "input",
135
136
  {
136
- className: `${o}-input`,
137
+ className: `${r}-input`,
137
138
  value: s,
138
139
  disabled: i,
139
140
  readOnly: !0
@@ -147,16 +148,16 @@ function rr(t, m) {
147
148
  }
148
149
  );
149
150
  }
150
- const or = D.forwardRef(
151
- rr
151
+ const eo = q.forwardRef(
152
+ ro
152
153
  );
153
- or.displayName = "ColorPicker";
154
+ eo.displayName = "ColorPicker";
154
155
  export {
155
- kr as ColorPickerControlBar,
156
- yr as ColorPickerInputAlpha,
157
- Nr as ColorPickerInputHex,
158
- br as ColorPickerInputRgb,
159
- zr as ColorPickerPalette,
160
- X as ColorPickerPanel,
161
- or as default
156
+ Io as ColorPickerControlBar,
157
+ bo as ColorPickerInputAlpha,
158
+ $o as ColorPickerInputHex,
159
+ wo as ColorPickerInputRgb,
160
+ Ro as ColorPickerPalette,
161
+ Y as ColorPickerPanel,
162
+ eo as default
162
163
  };