@unicom-cloud/ui 0.8.97 → 0.8.98

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.
@@ -1,7 +1,8 @@
1
- import { jsxs as x, jsx as e } from "react/jsx-runtime";
2
- import { useRef as p, useState as I, useEffect as F } from "react";
1
+ import { jsx as a, jsxs as x } from "react/jsx-runtime";
2
+ import { useContext as nt, useRef as P, useState as O, useEffect as j } from "react";
3
+ import "../config-provider/ConfigProvider.js";
3
4
  import "@unicom-cloud/utils/case-name";
4
- import K from "@unicom-cloud/utils/class-name";
5
+ import at from "@unicom-cloud/utils/class-name";
5
6
  import "../dist/tinycolor/chunk/BOzCVdr0.js";
6
7
  import "@unicom-cloud/utils/constant/ui";
7
8
  import "../utils/contextHolder.js";
@@ -24,7 +25,7 @@ import "lodash/debounce";
24
25
  import "lodash/get";
25
26
  import "lodash/has";
26
27
  import "lodash/kebabCase";
27
- import "lodash/merge";
28
+ import st from "lodash/merge";
28
29
  import "lodash/mergeWith";
29
30
  import "lodash/set";
30
31
  import "lodash/setWith";
@@ -44,138 +45,174 @@ import "@unicom-cloud/utils/file/saveAs";
44
45
  import "@unicom-cloud/utils/screenfull";
45
46
  import "@unicom-cloud/utils/constant/ui.js";
46
47
  import "@unicom-cloud/utils/tree";
47
- import { isArray as L } from "@unicom-cloud/utils/is";
48
- import { v4 as N } from "uuid";
48
+ import "@unicom-cloud/utils/is";
49
+ import { v4 as b } from "uuid";
49
50
  import "../dist/validate/src/index.js";
50
51
  import "@unicom-cloud/utils/constant/keyboardCode";
51
- const Vr = ({
52
- style: O,
53
- className: W,
54
- value: q = 0.5,
55
- size: r = 200,
56
- waveColor: s = "rgb(var(--pqb-data-3))",
57
- backgroundColor: b = "var(--pqb-color-neutral-1)",
58
- textColor: B = "var(--pqb-color-neutral-8)",
59
- showPercent: D = !0,
60
- duration: g = 2e3,
61
- waveCount: i = 3,
62
- waveAmplitude: E = 10,
63
- borderColor: H = "var(--pqb-color-neutral-4)",
64
- borderWidth: a = 2
65
- }) => {
66
- const M = p(N()), $ = p(N()), R = p(null), l = p(), u = p(), h = p(0), [v, _] = I(0), [T, P] = I([]);
67
- let S;
68
- L(s) && (S = /* @__PURE__ */ x(
69
- "linearGradient",
70
- {
71
- id: $.current,
72
- x1: "0%",
73
- y1: "0%",
74
- x2: "0%",
75
- y2: "100%",
76
- children: [
77
- /* @__PURE__ */ e("stop", { offset: "0%", stopColor: s[0] }),
78
- /* @__PURE__ */ e("stop", { offset: "100%", stopColor: s[1] })
79
- ]
80
- }
81
- ));
82
- const A = (r - a) / 2, m = r / 2, V = (A - a) * 2 * (1 - v) + 1;
83
- F(() => {
84
- P(Array.from({ length: i }, (n, t) => t * Math.PI));
85
- }, [i]);
86
- const Y = (n, t, o) => {
87
- const c = [];
52
+ import mt from "../config-provider/context.js";
53
+ const se = (D) => {
54
+ const { getPrefixCls: I, componentConfig: V } = nt(mt), {
55
+ style: _,
56
+ className: E,
57
+ value: A = 0.5,
58
+ size: i = 200,
59
+ fontSize: h,
60
+ waveColor: F = "rgb(var(--pqb-blue-6))",
61
+ backgroundColor: N = "var(--pqb-color-neutral-1)",
62
+ textColor: H = "var(--pqb-color-neutral-8)",
63
+ showPercent: Y = !0,
64
+ duration: y = 2e3,
65
+ waveCount: c = 3,
66
+ waveAmplitude: J = 10,
67
+ borderColor: q = "var(--pqb-color-neutral-4)",
68
+ borderWidth: g = 2,
69
+ outerBorderColor: K = q,
70
+ outerBorderWidth: w = 0,
71
+ borderGap: Q = 2,
72
+ decimalPlaces: U = 0,
73
+ percentFontScale: X = 0.5,
74
+ waveSpeedVariation: Z = 0.5
75
+ } = st({}, V?.LiquidFill, D), n = I?.("liquid-fill"), d = P({
76
+ clipPath: b(),
77
+ // 裁剪路径ID
78
+ waveGradient: b(),
79
+ // 波浪渐变ID
80
+ bgGradient: b()
81
+ // 背景渐变ID
82
+ }).current, tt = P(null), o = P({
83
+ fill: 0,
84
+ // 填充动画ID
85
+ wave: 0,
86
+ // 波浪动画ID
87
+ startTime: 0
88
+ // 动画开始时间
89
+ }).current, [$, G] = O(0), [et, z] = O([]), M = i / 2 - w / 2, W = M - Q - g / 2, m = W - g / 2, e = i / 2, S = m * 2, rt = S * ($ / 100) + g / 2, k = (r, t) => {
90
+ if (typeof t == "string") return null;
91
+ const { from: s, to: l, direction: p = "vertical" } = t;
92
+ return /* @__PURE__ */ x("linearGradient", { id: r, x1: "0%", y1: "0%", x2: p === "horizontal" ? "100%" : "0%", y2: p === "horizontal" ? "0%" : "100%", children: [
93
+ /* @__PURE__ */ a("stop", { offset: "0%", stopColor: s }),
94
+ /* @__PURE__ */ a("stop", { offset: "100%", stopColor: l })
95
+ ] });
96
+ }, B = (r, t) => typeof r == "string" ? r : `url(#${t})`, ot = (r, t, s) => {
97
+ const l = [], v = e - m, L = e + m;
88
98
  for (let f = 0; f <= 30; f++) {
89
- const d = f / 30 * r, y = Math.min(
90
- V + n * Math.sin(d * t + o),
91
- r - a
99
+ const u = v + f / 30 * S, C = Math.min(
100
+ e + m - rt + // 这里原来是减去 waterHeight,现在直接使用 waterHeight
101
+ r * Math.sin((u - v) * t + s),
102
+ e + m
92
103
  );
93
- c.push([d, y]);
104
+ l.push([u, C]);
94
105
  }
95
- return c.push([r, r]), c.push([0, r]), c.map(([f, d], y) => `${y === 0 ? "M" : "L"}${f} ${d}`).join(" ");
96
- }, G = () => {
97
- P(
98
- (n) => n.map((t, o) => t + 0.02 * (o + 1))
99
- ), u.current = requestAnimationFrame(G);
100
- }, j = (n) => {
101
- h.current || (h.current = n);
102
- const t = n - h.current, o = Math.min(t / g, 1) * q;
103
- _(o), t < g ? l.current = requestAnimationFrame(j) : cancelAnimationFrame(l.current);
104
- };
105
- F(() => (h.current = 0, l.current = requestAnimationFrame(j), u.current = requestAnimationFrame(G), () => {
106
- cancelAnimationFrame(l.current), cancelAnimationFrame(u.current);
107
- }), [q, g, i]), F(() => () => {
108
- cancelAnimationFrame(l.current), cancelAnimationFrame(u.current);
109
- }, []);
110
- const J = () => Array.from({ length: i }).map((n, t) => {
111
- const o = E * (i - t) / i, c = 0.02 * (t + 1), k = T[t] || 0;
112
- return /* @__PURE__ */ e(
106
+ return l.push([L, e + m]), l.push([v, e + m]), l.map(([f, u], C) => `${C === 0 ? "M" : "L"}${f} ${u}`).join(" ");
107
+ }, it = () => Array.from({ length: c }).map((r, t) => {
108
+ const s = J * (c - t) / c, l = 0.02 * (t + 1), p = et[t] || 0;
109
+ return /* @__PURE__ */ a(
113
110
  "path",
114
111
  {
115
- d: Y(o, c, k),
116
- fill: L(s) ? `url(#${$.current})` : s,
117
- fillOpacity: 0.3 + 0.7 / i * t
112
+ className: `${n}-path`,
113
+ d: ot(s, l, p),
114
+ fill: B(F, d.waveGradient),
115
+ fillOpacity: 0.3 + 0.7 / c * t
118
116
  },
119
117
  t
120
118
  );
121
- });
122
- return /* @__PURE__ */ e(
119
+ }), R = () => {
120
+ z(
121
+ (r) => r.map(
122
+ (t, s) => t + 0.02 * (s + 1) * (1 + Z * Math.random())
123
+ )
124
+ ), $ < 100 && (o.wave = requestAnimationFrame(R));
125
+ }, T = (r) => {
126
+ o.startTime || (o.startTime = r);
127
+ const t = r - o.startTime, s = Math.min(t / y, 1) * A * 100;
128
+ G(s), t < y && (o.fill = requestAnimationFrame(T));
129
+ };
130
+ return j(() => {
131
+ z(Array.from({ length: c }, (r, t) => t * Math.PI));
132
+ }, [c]), j(() => (cancelAnimationFrame(o.fill), cancelAnimationFrame(o.wave), o.startTime = 0, G(0), o.fill = requestAnimationFrame(T), o.wave = requestAnimationFrame(R), () => {
133
+ cancelAnimationFrame(o.fill), cancelAnimationFrame(o.wave);
134
+ }), [A, y, c]), /* @__PURE__ */ a(
123
135
  "div",
124
136
  {
125
- className: K(W),
137
+ className: at(n, E),
126
138
  style: {
127
- width: r,
128
- height: r,
129
- display: "inline-block",
130
- lineHeight: 0,
131
- ...O
139
+ width: i,
140
+ height: i,
141
+ ..._
132
142
  },
133
143
  children: /* @__PURE__ */ x(
134
144
  "svg",
135
145
  {
136
- ref: R,
137
- width: r,
138
- height: r,
139
- viewBox: `0 0 ${r} ${r}`,
146
+ className: `${n}-svg`,
147
+ ref: tt,
148
+ width: i,
149
+ height: i,
150
+ viewBox: `0 0 ${i} ${i}`,
140
151
  preserveAspectRatio: "xMidYMid meet",
141
152
  children: [
142
- /* @__PURE__ */ e(
143
- "circle",
144
- {
145
- cx: m,
146
- cy: m,
147
- r: A,
148
- fill: b,
149
- stroke: H,
150
- strokeWidth: a
151
- }
152
- ),
153
153
  /* @__PURE__ */ x("defs", { children: [
154
- /* @__PURE__ */ e("clipPath", { id: M.current, children: /* @__PURE__ */ e(
154
+ k(d.waveGradient, F),
155
+ k(d.bgGradient, N),
156
+ /* @__PURE__ */ a("clipPath", { id: d.clipPath, className: `${n}-clipPath`, children: /* @__PURE__ */ a(
155
157
  "circle",
156
158
  {
157
- cx: m,
158
- cy: m,
159
- r: A - a / 2
159
+ className: `${n}-clipPath-circle`,
160
+ cx: e,
161
+ cy: e,
162
+ r: m
160
163
  }
161
- ) }),
162
- S
164
+ ) })
163
165
  ] }),
164
- /* @__PURE__ */ e("g", { clipPath: `url(#${M.current})`, children: J() }),
165
- D && /* @__PURE__ */ e(
166
+ w > 0 && /* @__PURE__ */ a(
167
+ "circle",
168
+ {
169
+ className: `${n}-outerBorder`,
170
+ cx: e,
171
+ cy: e,
172
+ r: M,
173
+ fill: "none",
174
+ stroke: K,
175
+ strokeWidth: w,
176
+ strokeOpacity: 0.5
177
+ }
178
+ ),
179
+ /* @__PURE__ */ a(
180
+ "circle",
181
+ {
182
+ className: `${n}-border`,
183
+ cx: e,
184
+ cy: e,
185
+ r: W,
186
+ fill: B(N, d.bgGradient),
187
+ stroke: q,
188
+ strokeWidth: g
189
+ }
190
+ ),
191
+ /* @__PURE__ */ a("g", { className: `${n}-g`, clipPath: `url(#${d.clipPath})`, children: it() }),
192
+ Y && /* @__PURE__ */ x(
166
193
  "text",
167
194
  {
168
- x: m,
169
- y: m,
170
- fill: B,
171
- fontSize: r * 0.15,
195
+ className: `${n}-text`,
196
+ x: e,
197
+ y: e,
198
+ fill: H,
199
+ fontSize: typeof h == "string" ? h : i * 0.15,
172
200
  textAnchor: "middle",
173
201
  dominantBaseline: "middle",
174
- style: {
175
- userSelect: "none",
176
- pointerEvents: "none"
177
- },
178
- children: `${Math.round(v * 100)}%`
202
+ children: [
203
+ $.toFixed(U),
204
+ /* @__PURE__ */ a(
205
+ "tspan",
206
+ {
207
+ style: {
208
+ fontSize: `calc(${typeof h == "string" ? h : `${i * 0.15}px`} * ${X})`
209
+ },
210
+ className: `${n}-text-tspan`,
211
+ alignmentBaseline: "mathematical",
212
+ children: "%"
213
+ }
214
+ )
215
+ ]
179
216
  }
180
217
  )
181
218
  ]
@@ -185,5 +222,5 @@ const Vr = ({
185
222
  );
186
223
  };
187
224
  export {
188
- Vr as default
225
+ se as default
189
226
  };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@unicom-cloud/ui","version":"0.8.97","dependencies":{"@unicom-cloud/icons":"latest"},"peerDependencies":{"dayjs":"^1.11.10","lodash":"^4.17.21","react":"^18.3.1","react-dom":"^18.3.1"},"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.98","dependencies":{"@unicom-cloud/icons":"latest"},"peerDependencies":{"dayjs":"^1.11.10","lodash":"^4.17.21","react":"^18.3.1","react-dom":"^18.3.1"},"peerDependenciesMeta":{},"type":"module","types":"types/pc/index.d.ts","main":"./index.js","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}