@unicom-cloud/ui 0.8.98 → 0.8.99
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.
- package/Badge.js +53 -7
- package/LiquidFill.js +59 -2
- package/Marquee.js +61 -0
- package/QrCode.js +13 -9
- package/Segmented.js +11 -0
- package/Space.js +14 -6
- package/Splitter.js +7 -0
- package/Tour.js +13 -9
- package/badge/index.js +177 -84
- package/collapse/Collapse.js +54 -48
- package/components/common/space/index.js +90 -106
- package/index.js +356 -353
- package/liquid-fill/index.js +255 -2
- package/marquee/index.js +282 -0
- package/menu/Item.js +17 -16
- package/package.json +1 -1
- package/qr-code/index.js +53 -36
- package/rate/index.js +8 -8
- package/segmented/index.js +217 -0
- package/space/index.js +28 -29
- package/splitter/index.js +117 -0
- package/splitter/interface.js +1 -0
- package/style.css +1 -1
- package/tour/index.js +110 -88
- package/types/common/hooks/useMergeProps.d.ts +1 -1
- package/types/common/space/index.d.ts +6 -5
- package/types/common/space/interface.d.ts +29 -16
- package/types/pc/badge/index.d.ts +4 -4
- package/types/pc/badge/interface.d.ts +26 -0
- package/types/pc/collapse/interface.d.ts +4 -0
- package/types/pc/config-provider/interface.d.ts +7 -1
- package/types/pc/date-picker/RangePicker.d.ts +1 -1
- package/types/pc/index.d.ts +10 -4
- package/types/pc/liquid-fill/index.d.ts +114 -1
- package/types/pc/marquee/index.d.ts +61 -0
- package/types/pc/menu/context.d.ts +1 -1
- package/types/pc/qr-code/index.d.ts +1 -1
- package/types/pc/rate/index.d.ts +2 -2
- package/types/pc/segmented/index.d.ts +8 -0
- package/types/pc/segmented/interface.d.ts +88 -0
- package/types/pc/space/index.d.ts +3 -1
- package/types/pc/space/interface.d.ts +6 -10
- package/types/pc/splitter/index.d.ts +4 -0
- package/types/pc/splitter/interface.d.ts +70 -0
- package/types/pc/tour/index.d.ts +6 -1
- package/types/pc/utils/names.d.ts +18 -0
- package/typography/Ellipsis.js +1 -1
- package/utils/names.js +12 -0
- package/version/index.js +1 -1
- package/_virtual/_commonjsHelpers.js +0 -6
- package/_virtual/index.js +0 -7
- package/_virtual/index2.js +0 -4
- package/liquid-fill/LiquidFill.js +0 -226
- package/liquid-fill/LiquidFill2.js +0 -3
- package/space-/index.js +0 -93
- package/types/common/utils/color.d.ts +0 -1
- package/types/common/utils/computeScrollIntoView.d.ts +0 -1
- package/types/common/utils/index.d.ts +0 -45
- package/types/common/utils/math.d.ts +0 -1
- package/types/common/utils/reactTransitionGroup.d.ts +0 -1
- package/types/common/utils/tree.d.ts +0 -1
- package/types/common/utils/tween.d.ts +0 -1
- package/types/common/utils/uuid.d.ts +0 -1
- package/types/common/utils/validate.d.ts +0 -1
- package/types/pc/liquid-fill/LiquidFill.d.ts +0 -115
- package/types/pc/liquid-fill/LiquidFill2.d.ts +0 -1
- package/types/pc/space-/index.d.ts +0 -6
- package/types/pc/space-/interface.d.ts +0 -38
- /package/{space- → components/common/space}/toArray.js +0 -0
- /package/{space- → segmented}/interface.js +0 -0
- /package/types/{pc/space- → common/space}/toArray.d.ts +0 -0
package/liquid-fill/index.js
CHANGED
|
@@ -1,4 +1,257 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as n, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as at, useRef as $, useState as V, useEffect as D } from "react";
|
|
3
|
+
import "../config-provider/ConfigProvider.js";
|
|
4
|
+
import "lodash/isEqualWith";
|
|
5
|
+
import "../components/common/utils/is.js";
|
|
6
|
+
import "@unicom-cloud/utils/constant/keyboardCode";
|
|
7
|
+
import "lodash/isNumber";
|
|
8
|
+
import "lodash/merge";
|
|
9
|
+
import "../components/common/utils/dom.js";
|
|
10
|
+
import "../components/common/hooks/useIntersectionObserver.js";
|
|
11
|
+
import st from "../components/common/hooks/useMergeProps.js";
|
|
12
|
+
import "../components/common/utils/reactDOM.js";
|
|
13
|
+
import "@unicom-cloud/utils/constant";
|
|
14
|
+
import mt from "../components/common/hooks/useUpdateEffect.js";
|
|
15
|
+
import "lodash/debounce";
|
|
16
|
+
import "@unicom-cloud/utils/case-name";
|
|
17
|
+
import lt from "@unicom-cloud/utils/class-name";
|
|
18
|
+
import "../dist/tinycolor/chunk/BOzCVdr0.js";
|
|
19
|
+
import "@unicom-cloud/utils/constant/ui";
|
|
20
|
+
import "../utils/contextHolder.js";
|
|
21
|
+
import "@unicom-cloud/utils/dayjs";
|
|
22
|
+
import "@unicom-cloud/utils/clipboard-copy";
|
|
23
|
+
import "../components/common/utils/dayjs.js";
|
|
24
|
+
import "@unicom-cloud/utils/file/fileToURL";
|
|
25
|
+
import "lodash/escapeRegExp";
|
|
26
|
+
import "lodash/isArray";
|
|
27
|
+
import "lodash/isString";
|
|
28
|
+
import "lodash/isFunction";
|
|
29
|
+
import "lodash/throttle";
|
|
30
|
+
import "lodash/camelCase";
|
|
31
|
+
import "lodash/capitalize";
|
|
32
|
+
import "lodash/cloneDeep";
|
|
33
|
+
import "lodash/get";
|
|
34
|
+
import "lodash/has";
|
|
35
|
+
import "lodash/kebabCase";
|
|
36
|
+
import "lodash/mergeWith";
|
|
37
|
+
import "lodash/set";
|
|
38
|
+
import "lodash/setWith";
|
|
39
|
+
import "lodash/snakeCase";
|
|
40
|
+
import "lodash/startCase";
|
|
41
|
+
import "lodash/uniq";
|
|
42
|
+
import "lodash/upperFirst";
|
|
43
|
+
import "@unicom-cloud/utils/math";
|
|
44
|
+
import "lodash/isPlainObject";
|
|
45
|
+
import "../dist/react-transition-group/src/CSSTransition.js";
|
|
46
|
+
import "../dist/react-transition-group/src/ReplaceTransition.js";
|
|
47
|
+
import "../dist/react-transition-group/src/SwitchTransition.js";
|
|
48
|
+
import "../dist/react-transition-group/chunk/CPfP7aNL.js";
|
|
49
|
+
import "../dist/react-transition-group/src/TransitionGroup.js";
|
|
50
|
+
import "@unicom-cloud/utils/file/saveAs";
|
|
51
|
+
import "@unicom-cloud/utils/screenfull";
|
|
52
|
+
import "@unicom-cloud/utils/constant/ui.js";
|
|
53
|
+
import "@unicom-cloud/utils/tree";
|
|
54
|
+
import { isNumber as ct } from "@unicom-cloud/utils/is";
|
|
55
|
+
import { v4 as A } from "uuid";
|
|
56
|
+
import "../dist/validate/src/index.js";
|
|
57
|
+
import pt from "../config-provider/context.js";
|
|
58
|
+
const dt = {
|
|
59
|
+
value: 0.5,
|
|
60
|
+
size: 200,
|
|
61
|
+
waveColor: "rgb(var(--pqb-blue-6))",
|
|
62
|
+
backgroundColor: "var(--pqb-color-neutral-1)",
|
|
63
|
+
textColor: "var(--pqb-color-neutral-8)",
|
|
64
|
+
showPercent: !0,
|
|
65
|
+
duration: 2e3,
|
|
66
|
+
waveCount: 3,
|
|
67
|
+
waveAmplitude: 10,
|
|
68
|
+
borderColor: "var(--pqb-color-neutral-4)",
|
|
69
|
+
borderWidth: 2,
|
|
70
|
+
outerBorderWidth: 0,
|
|
71
|
+
borderGap: 2,
|
|
72
|
+
decimalPlaces: 0,
|
|
73
|
+
percentFontScale: 0.5,
|
|
74
|
+
waveSpeedVariation: 0.5
|
|
75
|
+
}, ve = (E) => {
|
|
76
|
+
const { getPrefixCls: I, componentConfig: _ } = at(pt), i = I?.("liquid-fill"), H = st(
|
|
77
|
+
E,
|
|
78
|
+
dt,
|
|
79
|
+
_?.LiquidFill
|
|
80
|
+
), {
|
|
81
|
+
style: U,
|
|
82
|
+
className: Y,
|
|
83
|
+
value: F,
|
|
84
|
+
size: a,
|
|
85
|
+
fontSize: h = `${a * 0.15}px`,
|
|
86
|
+
waveColor: N,
|
|
87
|
+
backgroundColor: q,
|
|
88
|
+
textColor: J,
|
|
89
|
+
showPercent: K,
|
|
90
|
+
duration: y,
|
|
91
|
+
waveCount: c,
|
|
92
|
+
waveAmplitude: Q,
|
|
93
|
+
borderColor: G,
|
|
94
|
+
borderWidth: v,
|
|
95
|
+
outerBorderColor: W,
|
|
96
|
+
outerBorderWidth: g,
|
|
97
|
+
borderGap: X,
|
|
98
|
+
decimalPlaces: Z,
|
|
99
|
+
percentFontScale: tt,
|
|
100
|
+
waveSpeedVariation: B
|
|
101
|
+
} = H, d = $({
|
|
102
|
+
clipPath: A(),
|
|
103
|
+
// 裁剪路径ID
|
|
104
|
+
waveGradient: A(),
|
|
105
|
+
// 波浪渐变ID
|
|
106
|
+
bgGradient: A()
|
|
107
|
+
// 背景渐变ID
|
|
108
|
+
}).current, et = $(null), e = $({
|
|
109
|
+
fill: 0,
|
|
110
|
+
// 填充动画ID
|
|
111
|
+
wave: 0,
|
|
112
|
+
// 波浪动画ID
|
|
113
|
+
startTime: 0
|
|
114
|
+
// 动画开始时间
|
|
115
|
+
}).current, [C, M] = V(0), [rt, z] = V([]), S = a / 2 - g / 2, k = S - g / 2 - X - v / 2, m = k - v / 2, r = a / 2, R = m * 2, ot = R * (C / 100) + v / 2, T = (o, t) => {
|
|
116
|
+
if (typeof t == "string") return null;
|
|
117
|
+
const { from: s, to: l, direction: p = "vertical" } = t;
|
|
118
|
+
return /* @__PURE__ */ x("linearGradient", { id: o, x1: "0%", y1: "0%", x2: p === "horizontal" ? "100%" : "0%", y2: p === "horizontal" ? "0%" : "100%", children: [
|
|
119
|
+
/* @__PURE__ */ n("stop", { offset: "0%", stopColor: s }),
|
|
120
|
+
/* @__PURE__ */ n("stop", { offset: "100%", stopColor: l })
|
|
121
|
+
] });
|
|
122
|
+
}, L = (o, t) => typeof o == "string" ? o : `url(#${t})`, it = (o, t, s) => {
|
|
123
|
+
const l = [], w = r - m, j = r + m;
|
|
124
|
+
for (let u = 0; u <= 30; u++) {
|
|
125
|
+
const f = w + u / 30 * R, P = Math.min(
|
|
126
|
+
r + m - ot + // 这里原来是减去 waterHeight,现在直接使用 waterHeight
|
|
127
|
+
o * Math.sin((f - w) * t + s),
|
|
128
|
+
r + m
|
|
129
|
+
);
|
|
130
|
+
l.push([f, P]);
|
|
131
|
+
}
|
|
132
|
+
return l.push([j, r + m]), l.push([w, r + m]), l.map(([u, f], P) => `${P === 0 ? "M" : "L"}${u} ${f}`).join(" ");
|
|
133
|
+
}, nt = () => Array.from({ length: c }).map((o, t) => {
|
|
134
|
+
const s = Q * (c - t) / c, l = 0.02 * (t + 1), p = rt[t] || 0;
|
|
135
|
+
return /* @__PURE__ */ n(
|
|
136
|
+
"path",
|
|
137
|
+
{
|
|
138
|
+
className: `${i}-path`,
|
|
139
|
+
d: it(s, l, p),
|
|
140
|
+
fill: L(N, d.waveGradient),
|
|
141
|
+
fillOpacity: 0.3 + 0.7 / c * t
|
|
142
|
+
},
|
|
143
|
+
t
|
|
144
|
+
);
|
|
145
|
+
}), b = () => {
|
|
146
|
+
z(
|
|
147
|
+
(o) => o.map(
|
|
148
|
+
(t, s) => t + 0.02 * (s + 1) * (1 + B * Math.random())
|
|
149
|
+
)
|
|
150
|
+
), C < 100 && (e.wave = requestAnimationFrame(b));
|
|
151
|
+
}, O = (o) => {
|
|
152
|
+
e.startTime || (e.startTime = o);
|
|
153
|
+
const t = o - e.startTime, s = Math.min(t / y, 1) * F * 100;
|
|
154
|
+
M(s), t < y && (e.fill = requestAnimationFrame(O));
|
|
155
|
+
};
|
|
156
|
+
return D(() => {
|
|
157
|
+
z(Array.from({ length: c }, (o, t) => t * Math.PI));
|
|
158
|
+
}, [c]), D(() => (cancelAnimationFrame(e.fill), cancelAnimationFrame(e.wave), e.startTime = 0, M(0), e.fill = requestAnimationFrame(O), e.wave = requestAnimationFrame(b), () => {
|
|
159
|
+
cancelAnimationFrame(e.fill), cancelAnimationFrame(e.wave);
|
|
160
|
+
}), [F, y, c]), mt(() => (cancelAnimationFrame(e.wave), e.wave = requestAnimationFrame(b), () => {
|
|
161
|
+
cancelAnimationFrame(e.wave);
|
|
162
|
+
}), [B]), /* @__PURE__ */ n(
|
|
163
|
+
"div",
|
|
164
|
+
{
|
|
165
|
+
className: lt(i, Y),
|
|
166
|
+
style: {
|
|
167
|
+
width: a,
|
|
168
|
+
height: a,
|
|
169
|
+
...U
|
|
170
|
+
},
|
|
171
|
+
children: /* @__PURE__ */ x(
|
|
172
|
+
"svg",
|
|
173
|
+
{
|
|
174
|
+
className: `${i}-svg`,
|
|
175
|
+
ref: et,
|
|
176
|
+
width: a,
|
|
177
|
+
height: a,
|
|
178
|
+
viewBox: `0 0 ${a} ${a}`,
|
|
179
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ x("defs", { children: [
|
|
182
|
+
T(d.waveGradient, N),
|
|
183
|
+
T(d.bgGradient, q),
|
|
184
|
+
/* @__PURE__ */ n("clipPath", { id: d.clipPath, className: `${i}-clipPath`, children: /* @__PURE__ */ n(
|
|
185
|
+
"circle",
|
|
186
|
+
{
|
|
187
|
+
className: `${i}-clipPath-circle`,
|
|
188
|
+
cx: r,
|
|
189
|
+
cy: r,
|
|
190
|
+
r: m
|
|
191
|
+
}
|
|
192
|
+
) })
|
|
193
|
+
] }),
|
|
194
|
+
g > 0 && /* @__PURE__ */ n(
|
|
195
|
+
"circle",
|
|
196
|
+
{
|
|
197
|
+
className: `${i}-outerBorder`,
|
|
198
|
+
cx: r,
|
|
199
|
+
cy: r,
|
|
200
|
+
r: S,
|
|
201
|
+
fill: "none",
|
|
202
|
+
stroke: W || G,
|
|
203
|
+
strokeWidth: g,
|
|
204
|
+
strokeOpacity: W ? 1 : 0.5
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
/* @__PURE__ */ n(
|
|
208
|
+
"circle",
|
|
209
|
+
{
|
|
210
|
+
className: `${i}-border`,
|
|
211
|
+
cx: r,
|
|
212
|
+
cy: r,
|
|
213
|
+
r: k,
|
|
214
|
+
fill: L(q, d.bgGradient),
|
|
215
|
+
stroke: G,
|
|
216
|
+
strokeWidth: v
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
/* @__PURE__ */ n("g", { className: `${i}-g`, clipPath: `url(#${d.clipPath})`, children: nt() }),
|
|
220
|
+
K && /* @__PURE__ */ x(
|
|
221
|
+
"text",
|
|
222
|
+
{
|
|
223
|
+
style: {},
|
|
224
|
+
className: `${i}-text`,
|
|
225
|
+
x: r,
|
|
226
|
+
y: r,
|
|
227
|
+
fill: J,
|
|
228
|
+
fontSize: h,
|
|
229
|
+
textAnchor: "middle",
|
|
230
|
+
dominantBaseline: "middle",
|
|
231
|
+
alignmentBaseline: "middle",
|
|
232
|
+
children: [
|
|
233
|
+
C.toFixed(Z),
|
|
234
|
+
/* @__PURE__ */ n(
|
|
235
|
+
"tspan",
|
|
236
|
+
{
|
|
237
|
+
style: {
|
|
238
|
+
fontSize: `calc(${ct(h) ? h + "px" : h} * ${tt})`
|
|
239
|
+
},
|
|
240
|
+
className: `${i}-text-tspan`,
|
|
241
|
+
alignmentBaseline: "middle",
|
|
242
|
+
dominantBaseline: "middle",
|
|
243
|
+
children: "%"
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
};
|
|
2
255
|
export {
|
|
3
|
-
|
|
256
|
+
ve as default
|
|
4
257
|
};
|
package/marquee/index.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { jsxs as S, jsx as l, Fragment as A } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as U, useRef as k, useState as u, useEffect as N } from "react";
|
|
3
|
+
import "../config-provider/ConfigProvider.js";
|
|
4
|
+
import "lodash/isEqualWith";
|
|
5
|
+
import "../components/common/utils/is.js";
|
|
6
|
+
import "@unicom-cloud/utils/constant/keyboardCode";
|
|
7
|
+
import "lodash/isNumber";
|
|
8
|
+
import "lodash/merge";
|
|
9
|
+
import "../components/common/utils/dom.js";
|
|
10
|
+
import "../components/common/hooks/useIntersectionObserver.js";
|
|
11
|
+
import V from "../components/common/hooks/useMergeProps.js";
|
|
12
|
+
import "../components/common/utils/reactDOM.js";
|
|
13
|
+
import "@unicom-cloud/utils/constant";
|
|
14
|
+
import "lodash/debounce";
|
|
15
|
+
import "@unicom-cloud/utils/case-name";
|
|
16
|
+
import Z from "@unicom-cloud/utils/class-name";
|
|
17
|
+
import "../dist/tinycolor/chunk/BOzCVdr0.js";
|
|
18
|
+
import "@unicom-cloud/utils/constant/ui";
|
|
19
|
+
import "../utils/contextHolder.js";
|
|
20
|
+
import "@unicom-cloud/utils/dayjs";
|
|
21
|
+
import "@unicom-cloud/utils/clipboard-copy";
|
|
22
|
+
import "../components/common/utils/dayjs.js";
|
|
23
|
+
import "@unicom-cloud/utils/file/fileToURL";
|
|
24
|
+
import "lodash/escapeRegExp";
|
|
25
|
+
import "lodash/isArray";
|
|
26
|
+
import "lodash/isString";
|
|
27
|
+
import "lodash/isFunction";
|
|
28
|
+
import "lodash/throttle";
|
|
29
|
+
import "lodash/camelCase";
|
|
30
|
+
import "lodash/capitalize";
|
|
31
|
+
import "lodash/cloneDeep";
|
|
32
|
+
import "lodash/get";
|
|
33
|
+
import "lodash/has";
|
|
34
|
+
import "lodash/kebabCase";
|
|
35
|
+
import "lodash/mergeWith";
|
|
36
|
+
import "lodash/set";
|
|
37
|
+
import "lodash/setWith";
|
|
38
|
+
import "lodash/snakeCase";
|
|
39
|
+
import "lodash/startCase";
|
|
40
|
+
import "lodash/uniq";
|
|
41
|
+
import "lodash/upperFirst";
|
|
42
|
+
import "@unicom-cloud/utils/math";
|
|
43
|
+
import "lodash/isPlainObject";
|
|
44
|
+
import "../dist/react-transition-group/src/CSSTransition.js";
|
|
45
|
+
import "../dist/react-transition-group/src/ReplaceTransition.js";
|
|
46
|
+
import "../dist/react-transition-group/src/SwitchTransition.js";
|
|
47
|
+
import "../dist/react-transition-group/chunk/CPfP7aNL.js";
|
|
48
|
+
import "../dist/react-transition-group/src/TransitionGroup.js";
|
|
49
|
+
import { resizeObserver as _ } from "../components/common/utils/resizeObserver.js";
|
|
50
|
+
import "@unicom-cloud/utils/file/saveAs";
|
|
51
|
+
import "@unicom-cloud/utils/screenfull";
|
|
52
|
+
import "@unicom-cloud/utils/constant/ui.js";
|
|
53
|
+
import "@unicom-cloud/utils/tree";
|
|
54
|
+
import "@unicom-cloud/utils/is";
|
|
55
|
+
import "uuid";
|
|
56
|
+
import "../dist/validate/src/index.js";
|
|
57
|
+
import tt from "../config-provider/context.js";
|
|
58
|
+
const et = {
|
|
59
|
+
speed: 50,
|
|
60
|
+
// 默认50像素/秒(数值越大越快)
|
|
61
|
+
direction: "left",
|
|
62
|
+
pauseOnHover: !1,
|
|
63
|
+
gradient: !0,
|
|
64
|
+
loop: 0,
|
|
65
|
+
// 0表示无限循环
|
|
66
|
+
gradientSize: 50
|
|
67
|
+
}, se = (q) => {
|
|
68
|
+
const { getPrefixCls: O, componentConfig: P } = U(tt), s = O?.("marquee"), R = V(
|
|
69
|
+
q,
|
|
70
|
+
et,
|
|
71
|
+
P?.Marquee
|
|
72
|
+
);
|
|
73
|
+
let {
|
|
74
|
+
children: $,
|
|
75
|
+
style: L,
|
|
76
|
+
className: D,
|
|
77
|
+
speed: E,
|
|
78
|
+
// 默认50像素/秒(数值越大越快)
|
|
79
|
+
direction: c,
|
|
80
|
+
pauseOnHover: H,
|
|
81
|
+
gradient: W,
|
|
82
|
+
loop: a,
|
|
83
|
+
// 0表示无限循环
|
|
84
|
+
gradientSize: d,
|
|
85
|
+
onComplete: b
|
|
86
|
+
} = R;
|
|
87
|
+
const h = k(null), T = k(null), w = k(null), n = k(), [F, j] = u({ width: 0, height: 0 }), [rt, B] = u({ width: 0, height: 0 }), [y, I] = u(!1), [M, m] = u(!0), [x, p] = u(0), [X, g] = u(0), o = c === "left" || c === "right";
|
|
88
|
+
d = o ? 50 : 20;
|
|
89
|
+
const z = () => {
|
|
90
|
+
if (w.current && h.current) {
|
|
91
|
+
const r = w.current.scrollWidth, t = w.current.scrollHeight, i = h.current.offsetWidth, e = h.current.offsetHeight;
|
|
92
|
+
j({ width: r, height: t }), B({ width: i, height: e });
|
|
93
|
+
const f = o ? r > i : t > e;
|
|
94
|
+
if (I(f), f) {
|
|
95
|
+
const v = c === "right" ? -r : c === "down" ? -t : 0;
|
|
96
|
+
p(v);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
N(() => {
|
|
101
|
+
const r = _(
|
|
102
|
+
[h.current],
|
|
103
|
+
z
|
|
104
|
+
);
|
|
105
|
+
return () => r();
|
|
106
|
+
}, []), N(() => {
|
|
107
|
+
z(), g(0);
|
|
108
|
+
}, [$]), N(() => {
|
|
109
|
+
if (!M || !y)
|
|
110
|
+
return;
|
|
111
|
+
let r = null, t = x;
|
|
112
|
+
const i = o ? F.width : F.height;
|
|
113
|
+
let e = X;
|
|
114
|
+
const f = (v) => {
|
|
115
|
+
if (!r) {
|
|
116
|
+
r = v, n.current = requestAnimationFrame(f);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const Q = (v - r) / 1e3;
|
|
120
|
+
r = v;
|
|
121
|
+
const C = E * Q;
|
|
122
|
+
switch (c) {
|
|
123
|
+
case "left":
|
|
124
|
+
if (t -= C, t <= -i && (t += i, e += 1, g(e), a > 0 && e >= a)) {
|
|
125
|
+
cancelAnimationFrame(n.current), m(!1), p(0), b?.();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
case "right":
|
|
130
|
+
if (t += C, t >= 0 && (t -= i, e += 1, g(e), a > 0 && e >= a)) {
|
|
131
|
+
cancelAnimationFrame(n.current), m(!1), p(-i), b?.();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
case "up":
|
|
136
|
+
if (t -= C, t <= -i && (t += i, e += 1, g(e), a > 0 && e >= a)) {
|
|
137
|
+
cancelAnimationFrame(n.current), m(!1), p(0), b?.();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
case "down":
|
|
142
|
+
if (t += C, t >= 0 && (t -= i, e += 1, g(e), a > 0 && e >= a)) {
|
|
143
|
+
cancelAnimationFrame(n.current), m(!1), p(-i), b?.();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
p(t), n.current = requestAnimationFrame(f);
|
|
149
|
+
};
|
|
150
|
+
return n.current = requestAnimationFrame(f), () => {
|
|
151
|
+
n.current && cancelAnimationFrame(n.current);
|
|
152
|
+
};
|
|
153
|
+
}, [M, E, c, F, y, a]), N(() => (z(), () => {
|
|
154
|
+
n.current && cancelAnimationFrame(n.current);
|
|
155
|
+
}), []);
|
|
156
|
+
const Y = () => {
|
|
157
|
+
H && m(!1);
|
|
158
|
+
}, G = () => {
|
|
159
|
+
H && m(!0);
|
|
160
|
+
}, J = () => o ? `translateX(${x}px)` : `translateY(${x}px)`, K = () => {
|
|
161
|
+
const r = {
|
|
162
|
+
display: o ? "inline-block" : "block",
|
|
163
|
+
whiteSpace: o ? "nowrap" : "normal",
|
|
164
|
+
// 消除元素间默认间距
|
|
165
|
+
marginRight: o ? 0 : void 0,
|
|
166
|
+
marginBottom: o ? void 0 : 0
|
|
167
|
+
}, t = /* @__PURE__ */ l(
|
|
168
|
+
"div",
|
|
169
|
+
{
|
|
170
|
+
ref: w,
|
|
171
|
+
style: r,
|
|
172
|
+
className: `${s}-children`,
|
|
173
|
+
children: $
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
return y ? /* @__PURE__ */ S(A, { children: [
|
|
177
|
+
t,
|
|
178
|
+
/* @__PURE__ */ l("div", { style: r, className: `${s}-children`, children: $ })
|
|
179
|
+
] }) : t;
|
|
180
|
+
};
|
|
181
|
+
return /* @__PURE__ */ S(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
ref: h,
|
|
185
|
+
className: Z(
|
|
186
|
+
s,
|
|
187
|
+
`${s}-${c}`,
|
|
188
|
+
D
|
|
189
|
+
),
|
|
190
|
+
style: {
|
|
191
|
+
overflow: "hidden",
|
|
192
|
+
position: "relative",
|
|
193
|
+
...L
|
|
194
|
+
},
|
|
195
|
+
onMouseEnter: Y,
|
|
196
|
+
onMouseLeave: G,
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ l(
|
|
199
|
+
"div",
|
|
200
|
+
{
|
|
201
|
+
ref: T,
|
|
202
|
+
style: {
|
|
203
|
+
display: o ? "inline-block" : "block",
|
|
204
|
+
whiteSpace: "nowrap",
|
|
205
|
+
willChange: "transform",
|
|
206
|
+
// 启用GPU加速
|
|
207
|
+
transform: J()
|
|
208
|
+
},
|
|
209
|
+
className: `${s}-content`,
|
|
210
|
+
children: K()
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
W && y && (o ? /* @__PURE__ */ S(A, { children: [
|
|
214
|
+
/* @__PURE__ */ l(
|
|
215
|
+
"div",
|
|
216
|
+
{
|
|
217
|
+
style: {
|
|
218
|
+
position: "absolute",
|
|
219
|
+
top: 0,
|
|
220
|
+
left: 0,
|
|
221
|
+
width: d,
|
|
222
|
+
height: "100%",
|
|
223
|
+
background: "linear-gradient(to right, #fff, transparent)",
|
|
224
|
+
pointerEvents: "none"
|
|
225
|
+
},
|
|
226
|
+
className: `${s}-linear-gradient-to-right`
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
/* @__PURE__ */ l(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
style: {
|
|
233
|
+
position: "absolute",
|
|
234
|
+
top: 0,
|
|
235
|
+
right: 0,
|
|
236
|
+
width: d,
|
|
237
|
+
height: "100%",
|
|
238
|
+
background: "linear-gradient(to left, #fff, transparent)",
|
|
239
|
+
pointerEvents: "none"
|
|
240
|
+
},
|
|
241
|
+
className: `${s}-linear-gradient-to-left`
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
] }) : /* @__PURE__ */ S(A, { children: [
|
|
245
|
+
/* @__PURE__ */ l(
|
|
246
|
+
"div",
|
|
247
|
+
{
|
|
248
|
+
style: {
|
|
249
|
+
position: "absolute",
|
|
250
|
+
top: 0,
|
|
251
|
+
left: 0,
|
|
252
|
+
width: "100%",
|
|
253
|
+
height: d,
|
|
254
|
+
background: "linear-gradient(to bottom, #fff, transparent)",
|
|
255
|
+
pointerEvents: "none"
|
|
256
|
+
},
|
|
257
|
+
className: `${s}-linear-gradient-to-bottom`
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ l(
|
|
261
|
+
"div",
|
|
262
|
+
{
|
|
263
|
+
style: {
|
|
264
|
+
position: "absolute",
|
|
265
|
+
bottom: 0,
|
|
266
|
+
left: 0,
|
|
267
|
+
width: "100%",
|
|
268
|
+
height: d,
|
|
269
|
+
background: "linear-gradient(to top, #fff, transparent)",
|
|
270
|
+
pointerEvents: "none"
|
|
271
|
+
},
|
|
272
|
+
className: `${s}-linear-gradient-to-top`
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
] }))
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
export {
|
|
281
|
+
se as default
|
|
282
|
+
};
|
package/menu/Item.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as N, jsx as
|
|
1
|
+
import { jsxs as N, jsx as r, Fragment as D } from "react/jsx-runtime";
|
|
2
2
|
import F from "../dist/scroll-into-view-if-needed/src/index.js";
|
|
3
3
|
import { forwardRef as O, useContext as j, useRef as B, useEffect as K } from "react";
|
|
4
4
|
import U from "../components/common/hooks/useIsFirstRender.js";
|
|
@@ -12,8 +12,8 @@ import { PROPS_NEED_TO_BE_PASSED_IN_SUBMENU as q } from "./util.js";
|
|
|
12
12
|
function G(b, c) {
|
|
13
13
|
const {
|
|
14
14
|
_key: a,
|
|
15
|
-
children:
|
|
16
|
-
level:
|
|
15
|
+
children: i,
|
|
16
|
+
level: s,
|
|
17
17
|
disabled: l,
|
|
18
18
|
className: x,
|
|
19
19
|
style: E,
|
|
@@ -32,14 +32,15 @@ function G(b, c) {
|
|
|
32
32
|
scrollConfig: S,
|
|
33
33
|
tooltipProps: y,
|
|
34
34
|
onClickMenuItem: w
|
|
35
|
-
} = j(W),
|
|
35
|
+
} = j(W), o = B(null), R = U(), I = p === "vertical" && s > 1, v = m && !M && s === 1, n = f && ~f.indexOf(a);
|
|
36
36
|
K(() => {
|
|
37
37
|
const e = n && u;
|
|
38
|
-
|
|
38
|
+
o.current && e && setTimeout(
|
|
39
39
|
() => {
|
|
40
|
-
|
|
40
|
+
o.current && F(o.current, {
|
|
41
41
|
behavior: "smooth",
|
|
42
42
|
block: "start",
|
|
43
|
+
inline: "start",
|
|
43
44
|
scrollMode: "if-needed",
|
|
44
45
|
boundary: document.body,
|
|
45
46
|
...S
|
|
@@ -47,7 +48,7 @@ function G(b, c) {
|
|
|
47
48
|
},
|
|
48
49
|
R ? 500 : 0
|
|
49
50
|
);
|
|
50
|
-
}, [n, u]);
|
|
51
|
+
}, [n, u, o.current]);
|
|
51
52
|
const k = (e) => {
|
|
52
53
|
l || (w?.(a, e), _?.(e));
|
|
53
54
|
}, g = /* @__PURE__ */ N(
|
|
@@ -56,7 +57,7 @@ function G(b, c) {
|
|
|
56
57
|
tabIndex: l ? -1 : 0,
|
|
57
58
|
role: "menuitem",
|
|
58
59
|
ref: (e) => {
|
|
59
|
-
c = e,
|
|
60
|
+
c = e, o.current = c;
|
|
60
61
|
},
|
|
61
62
|
style: E,
|
|
62
63
|
className: A(
|
|
@@ -79,35 +80,35 @@ function G(b, c) {
|
|
|
79
80
|
),
|
|
80
81
|
children: [
|
|
81
82
|
I && !m ? /* @__PURE__ */ N(D, { children: [
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
+
/* @__PURE__ */ r(
|
|
83
84
|
V,
|
|
84
85
|
{
|
|
85
86
|
prefixCls: t,
|
|
86
87
|
levelIndent: P,
|
|
87
|
-
level:
|
|
88
|
+
level: s
|
|
88
89
|
}
|
|
89
90
|
),
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ r(
|
|
91
92
|
"span",
|
|
92
93
|
{
|
|
93
94
|
className: `${t}-item-inner`,
|
|
94
95
|
style: {
|
|
95
96
|
display: "block"
|
|
96
97
|
},
|
|
97
|
-
children:
|
|
98
|
+
children: i
|
|
98
99
|
}
|
|
99
100
|
)
|
|
100
|
-
] }) :
|
|
101
|
-
n && p === "horizontal" ? /* @__PURE__ */
|
|
101
|
+
] }) : i,
|
|
102
|
+
n && p === "horizontal" ? /* @__PURE__ */ r("div", { className: `${t}-selected-label` }) : null
|
|
102
103
|
]
|
|
103
104
|
}
|
|
104
105
|
);
|
|
105
|
-
return v ? /* @__PURE__ */
|
|
106
|
+
return v ? /* @__PURE__ */ r(
|
|
106
107
|
z,
|
|
107
108
|
{
|
|
108
109
|
trigger: "hover",
|
|
109
110
|
position: "right",
|
|
110
|
-
content: typeof d == "function" ? d() : /* @__PURE__ */
|
|
111
|
+
content: typeof d == "function" ? d() : /* @__PURE__ */ r("span", { children: i }),
|
|
111
112
|
triggerProps: {
|
|
112
113
|
className: `${t}-item-tooltip`,
|
|
113
114
|
...y?.triggerProps || {}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@unicom-cloud/ui","version":"0.8.
|
|
1
|
+
{"name":"@unicom-cloud/ui","version":"0.8.99","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"}}
|