@unicom-cloud/ui 0.8.106 → 0.8.107

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 (84) hide show
  1. package/App.js +7 -0
  2. package/BackTop.js +2 -4
  3. package/Calendar.js +2 -2
  4. package/Modal.js +4 -2
  5. package/app/App.js +26 -0
  6. package/app/context.js +9 -0
  7. package/app/index.js +9 -0
  8. package/app/interface.js +1 -0
  9. package/app/useApp.js +8 -0
  10. package/back-top/index.js +44 -56
  11. package/calendar/Lunar.js +71 -0
  12. package/calendar/index.js +11 -11
  13. package/color-picker/index.js +34 -34
  14. package/components/common/flex/index.js +4 -4
  15. package/components/common/icons/file/index.js +13 -11
  16. package/components/common/utils/dayjs.js +99 -124
  17. package/components/common/utils/is.js +98 -104
  18. package/components/common/utils/setDir.js +12 -0
  19. package/components/common/utils/setTheme.js +13 -13
  20. package/config-provider/ConfigProvider.js +32 -30
  21. package/descriptions/index.js +32 -32
  22. package/divider/index.js +28 -20
  23. package/empty/index.js +1 -1
  24. package/grid/Grid.js +55 -88
  25. package/grid/Item.js +40 -61
  26. package/grid/context.js +1 -4
  27. package/grid/hook/useResponsiveState.js +22 -25
  28. package/grid/util.js +6 -44
  29. package/index.js +462 -457
  30. package/input/Button.js +12 -12
  31. package/input/Group.js +11 -12
  32. package/input/Input.js +112 -102
  33. package/input/Search.js +24 -24
  34. package/modal/Confirm.js +17 -17
  35. package/modal/Modal.js +247 -237
  36. package/modal/index.js +4 -2
  37. package/modal/use-modal/index.js +2 -2
  38. package/package.json +1 -1
  39. package/select-view/Core.js +31 -28
  40. package/splitter/SplitBar.js +44 -46
  41. package/style.css +1 -1
  42. package/table/Table.js +198 -210
  43. package/table/th-resizable/index.js +9 -10
  44. package/time-picker/util.js +20 -30
  45. package/types/common/development/interface.d.ts +3 -3
  46. package/types/common/utils/is.d.ts +3 -4
  47. package/types/common/utils/setDir.d.ts +2 -0
  48. package/types/pc/app/App.d.ts +6 -0
  49. package/types/pc/app/context.d.ts +4 -0
  50. package/types/pc/app/index.d.ts +5 -0
  51. package/types/pc/app/interface.d.ts +17 -0
  52. package/types/pc/app/useApp.d.ts +3 -0
  53. package/types/pc/back-top/interface.d.ts +4 -17
  54. package/types/pc/calendar/Lunar.d.ts +17 -0
  55. package/types/pc/calendar/index.d.ts +1 -1
  56. package/types/pc/config-provider/interface.d.ts +1 -1
  57. package/types/pc/divider/interface.d.ts +1 -0
  58. package/types/pc/grid/Grid.d.ts +1 -2
  59. package/types/pc/grid/Item.d.ts +2 -5
  60. package/types/pc/grid/context.d.ts +4 -10
  61. package/types/pc/grid/hook/useResponsiveState.d.ts +2 -2
  62. package/types/pc/grid/interface.d.ts +9 -19
  63. package/types/pc/grid/util.d.ts +1 -10
  64. package/types/pc/index.d.ts +3 -1
  65. package/types/pc/input/Button.d.ts +2 -2
  66. package/types/pc/message/index.d.ts +1 -9
  67. package/types/pc/message/interface.d.ts +8 -0
  68. package/types/pc/message/useMessage.d.ts +1 -2
  69. package/types/pc/modal/Modal.d.ts +1 -0
  70. package/types/pc/modal/config.d.ts +1 -2
  71. package/types/pc/modal/index.d.ts +2 -1
  72. package/types/pc/modal/interface.d.ts +17 -5
  73. package/types/pc/notification/index.d.ts +2 -9
  74. package/types/pc/notification/interface.d.ts +7 -0
  75. package/types/pc/notification/useNotification.d.ts +1 -2
  76. package/types/pc/select-view/Core.d.ts +1 -8
  77. package/types/pc/select-view/index.d.ts +1 -8
  78. package/types/pc/select-view/interface.d.ts +9 -2
  79. package/types/pc/utils/is.d.ts +1 -1
  80. package/types/pc/utils/names.d.ts +303 -0
  81. package/utils/index.js +58 -59
  82. package/utils/is.js +65 -66
  83. package/utils/names.js +298 -144
  84. package/version/index.js +1 -1
package/modal/index.js CHANGED
@@ -1,4 +1,6 @@
1
- import t from "./Modal.js";
1
+ import e from "./Modal.js";
2
+ import { default as r } from "./use-modal/index.js";
2
3
  export {
3
- t as default
4
+ e as default,
5
+ r as useModal
4
6
  };
@@ -24,9 +24,9 @@ function j() {
24
24
  },
25
25
  c
26
26
  );
27
- r.current?.addInstance(i);
27
+ r.current?.addInstance?.(i);
28
28
  function C() {
29
- r.current?.removeInstance(i);
29
+ r.current?.removeInstance?.(i);
30
30
  }
31
31
  function a() {
32
32
  e?.close();
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@unicom-cloud/ui","version":"0.8.106","dependencies":{"@unicom-cloud/icons":"latest"},"peerDependencies":{"react":"^18.3.1","react-dom":"^18.3.1","dayjs":"^1.11.10","lodash":"^4.17.21","uuid":"^11.1.0","qrcode.react":"^4.2.0"},"peerDependenciesMeta":{},"type":"module","types":"types/pc/index.d.ts","main":"./index.js","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
1
+ {"name":"@unicom-cloud/ui","version":"0.8.107","dependencies":{"@unicom-cloud/icons":"latest"},"peerDependencies":{"react":"^18.3.1","react-dom":"^18.3.1","dayjs":"^1.11.10","lodash":"^4.17.21","uuid":"^11.1.0","qrcode.react":"^4.2.0"},"peerDependenciesMeta":{},"type":"module","types":"types/pc/index.d.ts","main":"./index.js","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
@@ -36,7 +36,7 @@ const K = "__pqb_value_tag_placeholder", w = {
36
36
  allowCreate: Ce,
37
37
  status: xe,
38
38
  loading: Ie,
39
- disabled: g,
39
+ disabled: b,
40
40
  animation: we,
41
41
  prefixCls: n,
42
42
  suffixIcon: G,
@@ -45,7 +45,7 @@ const K = "__pqb_value_tag_placeholder", w = {
45
45
  clearIcon: D,
46
46
  placeholder: q,
47
47
  renderText: X,
48
- value: b,
48
+ value: v,
49
49
  inputValue: F,
50
50
  popupVisible: p,
51
51
  maxTagCount: c,
@@ -66,7 +66,7 @@ const K = "__pqb_value_tag_placeholder", w = {
66
66
  onRemoveCheckedItem: Re,
67
67
  onSort: A,
68
68
  ...Oe
69
- } = x, N = ae(null), f = ae(null), { size: Me, getPrefixCls: Q } = qe(fo), [Ae, Y] = ce(w.NONE), [B, Z] = ce(!1), Be = to(), T = "showSearch" in x ? x.showSearch : I, m = T || Ce, y = ge || Me, V = B || p, Ve = C(T) && T.retainInputValue, v = !I && b !== void 0 ? X(b).text : "", _ = (e) => {
69
+ } = x, N = ae(null), f = ae(null), { size: Me, getPrefixCls: Q } = qe(fo), [Ae, Y] = ce(w.NONE), [B, Z] = ce(!1), Be = to(), T = "showSearch" in x ? x.showSearch : I, m = T || Ce, y = ge || Me, V = B || p, Ve = C(T) && T.retainInputValue, h = !I && v !== void 0 ? X(v).text : "", _ = (e) => {
70
70
  e?.preventDefault?.();
71
71
  }, U = (e) => {
72
72
  const o = m ? N.current : f.current;
@@ -103,13 +103,13 @@ const K = "__pqb_value_tag_placeholder", w = {
103
103
  let e;
104
104
  switch (Ae) {
105
105
  case w.BEFORE:
106
- e = F || (Ve ? v : "");
106
+ e = F || (Ve ? h : "");
107
107
  break;
108
108
  case w.EDITING:
109
109
  e = F || "";
110
110
  break;
111
111
  default:
112
- e = v;
112
+ e = h;
113
113
  break;
114
114
  }
115
115
  const o = !!(V && m || R), s = {
@@ -117,7 +117,8 @@ const K = "__pqb_value_tag_placeholder", w = {
117
117
  // _inputValue after renderText(value) may be rich text, but the value of <input> cannot be object
118
118
  value: o && typeof e != "object" ? e : "",
119
119
  // Allow placeholder to display the selected value first when searching
120
- placeholder: m && v && typeof v != "object" ? v : q
120
+ placeholder: m && // 0 can also be used as a placeholder, because when options is number[], the selected value may be 0
121
+ (h || h === 0) && typeof h != "object" ? h : q
121
122
  };
122
123
  return m ? (s.onPaste = i.paste, s.onKeyDown = i.keyDown, s.onFocus = i.focus, s.onBlur = i.blur, s.onChange = i.change) : (s.tabIndex = -1, s.style.pointerEvents = "none"), /* @__PURE__ */ k("span", { className: `${n}-view-selector`, children: [
123
124
  /* @__PURE__ */ t(
@@ -125,7 +126,7 @@ const K = "__pqb_value_tag_placeholder", w = {
125
126
  {
126
127
  "aria-hidden": !o || void 0,
127
128
  ref: N,
128
- disabled: g,
129
+ disabled: b,
129
130
  className: E(`${n}-view-input`, {
130
131
  [`${n}-hidden`]: !o
131
132
  }),
@@ -149,9 +150,9 @@ const K = "__pqb_value_tag_placeholder", w = {
149
150
  }, L = Qe(() => {
150
151
  if (!I)
151
152
  return [];
152
- const e = le(b) ? [] : [].concat(b);
153
- return (de(oe) ? e.slice(0, oe) : e).map((P, h, te) => ne(P));
154
- }, [b, I, c, z]), Le = () => {
153
+ const e = le(v) ? [] : [].concat(v);
154
+ return (de(oe) ? e.slice(0, oe) : e).map((P, g, te) => ne(P));
155
+ }, [v, I, c, z]), Le = () => {
155
156
  const e = C(c) ? c.count : c, o = C(c) && c.showPopover, s = Q?.("input-tag"), P = (r) => C(c) && ro(c.render) ? c.render(r) : e === "responsive" ? /* @__PURE__ */ k(
156
157
  ie,
157
158
  {
@@ -163,9 +164,9 @@ const K = "__pqb_value_tag_placeholder", w = {
163
164
  ]
164
165
  },
165
166
  K
166
- ) : `+${r}...`, h = le(b) ? [] : [].concat(b), te = () => {
167
- for (let r = h.length - 1; r >= 0; r--) {
168
- const l = h[r];
167
+ ) : `+${r}...`, g = le(v) ? [] : [].concat(v), te = () => {
168
+ for (let r = g.length - 1; r >= 0; r--) {
169
+ const l = g[r];
169
170
  if (!z(l).disabled)
170
171
  return r;
171
172
  }
@@ -179,7 +180,7 @@ const K = "__pqb_value_tag_placeholder", w = {
179
180
  onRemove: (r, l, u) => {
180
181
  const $ = u.key;
181
182
  let a = -1;
182
- $ === po.key && (a = te()) !== -1 && (r = h[a], l = a), c && Be(), Re?.(r, l, u);
183
+ $ === po.key && (a = te()) !== -1 && (r = g[a], l = a), c && Be(), Re?.(r, l, u);
183
184
  }
184
185
  }, Ke = {
185
186
  suffix: null,
@@ -190,7 +191,7 @@ const K = "__pqb_value_tag_placeholder", w = {
190
191
  labelInValue: !1
191
192
  }, se = (() => {
192
193
  if (de(e)) {
193
- const r = h.length - e;
194
+ const r = g.length - e;
194
195
  if (r > 0) {
195
196
  const l = {
196
197
  label: P(r),
@@ -199,14 +200,16 @@ const K = "__pqb_value_tag_placeholder", w = {
199
200
  value: K
200
201
  };
201
202
  if (o) {
202
- const u = h.map((a, d) => ({ val: a, index: d })).slice(e).map((a) => {
203
+ const u = g.map((a, d) => ({ val: a, index: d })).slice(e).map((a) => {
203
204
  const d = ne(a.val);
204
205
  return M ? M(
205
206
  {
206
207
  ...d,
207
- onClose: (H) => {
208
- j.onRemove(d.value, a.index, H);
209
- }
208
+ onClose: (H) => j.onRemove(
209
+ d.value,
210
+ a.index,
211
+ H
212
+ )
210
213
  },
211
214
  a.index,
212
215
  L.concat(l)
@@ -248,7 +251,7 @@ const K = "__pqb_value_tag_placeholder", w = {
248
251
  ...Ke,
249
252
  className: V ? `${Q?.("input-tag")}-focus` : "",
250
253
  ref: N,
251
- disabled: g,
254
+ disabled: b,
252
255
  dragToSort: J,
253
256
  disableInput: !T,
254
257
  animation: we,
@@ -270,8 +273,8 @@ const K = "__pqb_value_tag_placeholder", w = {
270
273
  K
271
274
  );
272
275
  if (u > -1) {
273
- const $ = r.slice(0, u), a = r.slice(u + 1), d = h.slice(
274
- r.length - 1 - h.length
276
+ const $ = r.slice(0, u), a = r.slice(u + 1), d = g.slice(
277
+ r.length - 1 - g.length
275
278
  );
276
279
  A($.concat(d, a));
277
280
  } else
@@ -281,7 +284,7 @@ const K = "__pqb_value_tag_placeholder", w = {
281
284
  ...j
282
285
  }
283
286
  );
284
- }, re = xe || (x.error ? "error" : void 0), je = !g && !R && ve ? /* @__PURE__ */ t(
287
+ }, re = xe || (x.error ? "error" : void 0), je = !b && !R && ve ? /* @__PURE__ */ t(
285
288
  ao,
286
289
  {
287
290
  size: y,
@@ -300,7 +303,7 @@ const K = "__pqb_value_tag_placeholder", w = {
300
303
  [`${n}-size-${y}`]: y,
301
304
  [`${n}-focused`]: V,
302
305
  [`${n}-${re}`]: re,
303
- [`${n}-disabled`]: g,
306
+ [`${n}-disabled`]: b,
304
307
  [`${n}-no-border`]: !be,
305
308
  [`${n}-rtl`]: $e
306
309
  },
@@ -313,24 +316,24 @@ const K = "__pqb_value_tag_placeholder", w = {
313
316
  "aria-haspopup": "listbox",
314
317
  "aria-autocomplete": "list",
315
318
  "aria-expanded": p,
316
- "aria-disabled": g,
319
+ "aria-disabled": b,
317
320
  "aria-controls": Te,
318
321
  ...uo(Oe, ["onClick", "onMouseEnter", "onMouseLeave"]),
319
322
  ...ye,
320
323
  ref: f,
321
- tabIndex: g ? -1 : 0,
324
+ tabIndex: b ? -1 : 0,
322
325
  id: pe,
323
326
  style: fe,
324
327
  className: He,
325
328
  onKeyDown: ee,
326
329
  onFocus: (e) => {
327
- !g && !J && (m ? N.current && N.current.focus() : S("focus", e));
330
+ !b && !J && (m ? N.current && N.current.focus() : S("focus", e));
328
331
  },
329
332
  onBlur: (e) => S("blur", e),
330
333
  children: /* @__PURE__ */ k(
331
334
  "div",
332
335
  {
333
- title: typeof v == "string" ? v : void 0,
336
+ title: typeof h == "string" ? h : void 0,
334
337
  className: E(`${n}-view`, {
335
338
  [`${n}-view-with-prefix`]: O
336
339
  }),
@@ -3,68 +3,66 @@ import H from "@unicom-cloud/icons/IconUiDown";
3
3
  import J from "@unicom-cloud/icons/IconUiLeft";
4
4
  import K from "@unicom-cloud/icons/IconUiRight";
5
5
  import Q from "@unicom-cloud/icons/IconUiUp";
6
- import E from "react";
6
+ import { useContext as W, useState as X, useEffect as Z } from "react";
7
7
  import "../config-provider/ConfigProvider.js";
8
8
  import f from "@unicom-cloud/utils/class-name";
9
9
  import Y from "./hooks/useEvent.js";
10
- import W from "../config-provider/context.js";
11
- function O(d) {
10
+ import _ from "../config-provider/context.js";
11
+ function b(d) {
12
12
  return typeof d == "number" && !Number.isNaN(d) ? Math.round(d) : 0;
13
13
  }
14
- const ie = (d) => {
15
- const { getPrefixCls: y } = E.useContext(W), {
14
+ const fe = (d) => {
15
+ const { getPrefixCls: y } = W(_), {
16
16
  prefixCls: I,
17
17
  vertical: s,
18
18
  index: n,
19
19
  active: z,
20
- ariaNow: $,
21
- ariaMin: M,
22
- ariaMax: N,
20
+ ariaNow: E,
21
+ ariaMin: $,
22
+ ariaMax: M,
23
23
  startCollapsible: T,
24
24
  endCollapsible: j,
25
- onOffsetStart: S,
25
+ onOffsetStart: O,
26
26
  onOffsetUpdate: v,
27
27
  onOffsetEnd: h,
28
28
  onCollapse: P,
29
29
  lazy: a,
30
30
  containerSize: m
31
- } = d, e = y?.("bar", I), [r, w] = E.useState(
32
- null
33
- ), [g, U] = E.useState(0), k = s ? 0 : g, A = s ? g : 0, D = (t) => {
34
- t.currentTarget && (w([t.pageX, t.pageY]), S(n));
35
- }, R = (t) => {
36
- if (t.touches.length === 1) {
37
- const o = t.touches[0];
38
- w([o.pageX, o.pageY]), S(n);
31
+ } = d, e = y?.("bar", I), [r, w] = X(null), [g, S] = X(0), k = s ? 0 : g, A = s ? g : 0, D = (o) => {
32
+ o.currentTarget && (w([o.pageX, o.pageY]), O(n));
33
+ }, V = (o) => {
34
+ if (o.touches.length === 1) {
35
+ const t = o.touches[0];
36
+ w([t.pageX, t.pageY]), O(n);
39
37
  }
40
- }, V = (t) => {
41
- const o = m * $ / 100, c = o + t, x = Math.max(0, m * M / 100), i = Math.min(m, m * N / 100);
42
- return Math.max(x, Math.min(i, c)) - o;
43
- }, L = Y((t, o) => {
44
- const c = V(
45
- s ? o : t
38
+ }, B = (o) => {
39
+ const t = m * E / 100, c = t + o, x = Math.max(0, m * $ / 100), i = Math.min(m, m * M / 100);
40
+ return Math.max(x, Math.min(i, c)) - t;
41
+ }, N = Y((o, t) => {
42
+ const c = B(
43
+ s ? t : o
46
44
  );
47
- U(c);
48
- }), b = Y(() => {
49
- v(n, k, A, !0), U(0), h(!0);
45
+ S(c);
46
+ }), L = Y(() => {
47
+ v(n, k, A, !0), S(0), h(!0);
50
48
  });
51
- E.useEffect(() => {
49
+ Z(() => {
52
50
  if (r) {
53
- const t = (i) => {
54
- const { pageX: u, pageY: C } = i, p = u - r[0], X = C - r[1];
55
- a ? L(p, X) : v(n, p, X);
56
- }, o = () => {
57
- a ? b() : h(), w(null);
51
+ const o = (i) => {
52
+ const { pageX: p, pageY: C } = i, u = p - r[0], U = C - r[1];
53
+ a ? N(u, U) : v(n, u, U);
54
+ }, t = () => {
55
+ a ? L() : h(), w(null);
58
56
  }, c = (i) => {
59
57
  if (i.touches.length === 1) {
60
- const u = i.touches[0], C = u.pageX - r[0], p = u.pageY - r[1];
61
- a ? L(C, p) : v(n, C, p);
58
+ const p = i.touches[0], C = p.pageX - r[0], u = p.pageY - r[1];
59
+ a ? N(C, u) : v(n, C, u);
62
60
  }
63
61
  }, x = () => {
64
- a ? b() : h(), w(null);
62
+ a ? L() : h(), w(null);
65
63
  };
66
- return window.addEventListener("touchmove", c), window.addEventListener("touchend", x), window.addEventListener("mousemove", t), window.addEventListener("mouseup", o), () => {
67
- window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", o), window.removeEventListener("touchmove", c), window.removeEventListener("touchend", x);
64
+ return window.addEventListener("touchmove", c), window.addEventListener("touchend", x), window.addEventListener("mousemove", o), window.addEventListener("mouseup", t), () => {
65
+ window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", t), window.removeEventListener("touchmove", c), window.removeEventListener("touchend", x);
68
66
  };
69
67
  }
70
68
  }, [
@@ -73,15 +71,15 @@ const ie = (d) => {
73
71
  s,
74
72
  n,
75
73
  m,
74
+ E,
76
75
  $,
77
76
  M,
78
77
  N,
79
- L,
80
78
  v,
81
- b,
79
+ L,
82
80
  h
83
81
  ]);
84
- const B = {
82
+ const R = {
85
83
  [`--${e}-preview-offset`]: `${g}px`
86
84
  }, q = s ? Q : J, F = s ? H : K;
87
85
  return /* @__PURE__ */ G(
@@ -89,9 +87,9 @@ const ie = (d) => {
89
87
  {
90
88
  className: e,
91
89
  role: "separator",
92
- "aria-valuenow": O($),
93
- "aria-valuemin": O(M),
94
- "aria-valuemax": O(N),
90
+ "aria-valuenow": b(E),
91
+ "aria-valuemin": b($),
92
+ "aria-valuemax": b(M),
95
93
  children: [
96
94
  a && /* @__PURE__ */ l(
97
95
  "div",
@@ -99,7 +97,7 @@ const ie = (d) => {
99
97
  className: f(`${e}-preview`, {
100
98
  [`${e}-preview-active`]: !!g
101
99
  }),
102
- style: B
100
+ style: R
103
101
  }
104
102
  ),
105
103
  /* @__PURE__ */ l(
@@ -109,7 +107,7 @@ const ie = (d) => {
109
107
  [`${e}-dragger-active`]: z
110
108
  }),
111
109
  onMouseDown: D,
112
- onTouchStart: R
110
+ onTouchStart: V
113
111
  }
114
112
  ),
115
113
  T && /* @__PURE__ */ l(
@@ -155,5 +153,5 @@ const ie = (d) => {
155
153
  );
156
154
  };
157
155
  export {
158
- ie as default
156
+ fe as default
159
157
  };