cos-design 3.7.8 → 3.7.10
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/CHANGELOG.md +40 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +52 -41
- package/dist/src/components/flipCard/index.d.ts +11 -9
- package/dist/src/components/nineGrid/index.d.ts +11 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -275,24 +275,25 @@ import './index.css';var p = {
|
|
|
275
275
|
"#60efff",
|
|
276
276
|
"#7b2ff7",
|
|
277
277
|
"#f107a3"
|
|
278
|
-
], A = ({ width: e, height: t, fill: n = !1, colors:
|
|
279
|
-
let { hostRef:
|
|
278
|
+
], A = ({ width: e, height: t, fill: n = !1, colors: i = k }) => {
|
|
279
|
+
let { hostRef: a, hostStyle: o } = D({
|
|
280
280
|
fill: n,
|
|
281
281
|
width: e,
|
|
282
282
|
height: t,
|
|
283
283
|
defaultWidth: 800,
|
|
284
284
|
defaultHeight: 500
|
|
285
|
-
}),
|
|
286
|
-
return /* @__PURE__ */ u("div", {
|
|
287
|
-
ref:
|
|
285
|
+
}), s = i.length >= 2 ? i : k, [l, d] = c(() => typeof document < "u" && document.hidden);
|
|
286
|
+
return r(() => b(d), []), /* @__PURE__ */ u("div", {
|
|
287
|
+
ref: a,
|
|
288
288
|
className: O.aurora,
|
|
289
|
-
style:
|
|
290
|
-
children:
|
|
289
|
+
style: o,
|
|
290
|
+
children: s.map((e, t) => /* @__PURE__ */ u("div", {
|
|
291
291
|
className: O.band,
|
|
292
292
|
style: {
|
|
293
293
|
"--aurora-color": e,
|
|
294
294
|
"--aurora-delay": `${t * -3}s`,
|
|
295
|
-
"--aurora-duration": `${12 + t * 2}s
|
|
295
|
+
"--aurora-duration": `${12 + t * 2}s`,
|
|
296
|
+
animationPlayState: l ? "paused" : "running"
|
|
296
297
|
}
|
|
297
298
|
}, e + t))
|
|
298
299
|
});
|
|
@@ -1448,7 +1449,7 @@ var Oe = {
|
|
|
1448
1449
|
kicker: "cos-kicker-H-OGk",
|
|
1449
1450
|
title: "cos-title-XTDn7",
|
|
1450
1451
|
subtitle: "cos-subtitle-2YmXW"
|
|
1451
|
-
}, ke = t(
|
|
1452
|
+
}, ke = t(({ frontTitle: e = "签到翻牌", frontSubtitle: t = "点击翻开今日奖励", backTitle: n = "恭喜获得", backSubtitle: r = "积分 +20", flipped: i, defaultFlipped: o = !1, onReveal: s, onFlipChange: l, disabled: f = !1 }, p) => {
|
|
1452
1453
|
let [m, h] = c(o), g = typeof i == "boolean", _ = g ? !!i : m, v = (e, t) => {
|
|
1453
1454
|
g || h(e), l?.(e), e && t && s?.();
|
|
1454
1455
|
};
|
|
@@ -1508,7 +1509,9 @@ var Oe = {
|
|
|
1508
1509
|
})]
|
|
1509
1510
|
})
|
|
1510
1511
|
});
|
|
1511
|
-
})
|
|
1512
|
+
});
|
|
1513
|
+
ke.displayName = "FlipCard";
|
|
1514
|
+
var Ae = {
|
|
1512
1515
|
flipCounter: "cos-flipCounter-3LuI0",
|
|
1513
1516
|
digit: "cos-digit-yJRPy",
|
|
1514
1517
|
digitCard: "cos-digitCard-zZUzt",
|
|
@@ -2881,48 +2884,48 @@ var Oe = {
|
|
|
2881
2884
|
let t = [...e?.length ? e : Dt];
|
|
2882
2885
|
for (; t.length < 9;) t.push({ label: `奖品 ${t.length + 1}` });
|
|
2883
2886
|
return t.slice(0, 9);
|
|
2884
|
-
}, kt = t(
|
|
2885
|
-
let
|
|
2887
|
+
}, kt = t(({ items: e = Dt, targetIndex: t, buttonText: i = "开始抽奖", spinningText: o = "抽奖中…", onDrawEnd: l, disabled: f = !1 }, p) => {
|
|
2888
|
+
let m = Ot(e), [h, g] = c(null), [_, v] = c(null), [y, b] = c(!1), x = s([]), S = s(l), C = s(t);
|
|
2886
2889
|
r(() => {
|
|
2887
|
-
|
|
2888
|
-
}, [
|
|
2889
|
-
|
|
2890
|
+
S.current = l;
|
|
2891
|
+
}, [l]), r(() => {
|
|
2892
|
+
C.current = t;
|
|
2890
2893
|
}, [t]);
|
|
2891
|
-
let C = n(() => {
|
|
2892
|
-
b.current.forEach((e) => window.clearTimeout(e)), b.current = [];
|
|
2893
|
-
}, []);
|
|
2894
|
-
r(() => C, [C]);
|
|
2895
2894
|
let w = n(() => {
|
|
2896
|
-
|
|
2897
|
-
}, [
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2895
|
+
x.current.forEach((e) => window.clearTimeout(e)), x.current = [];
|
|
2896
|
+
}, []);
|
|
2897
|
+
r(() => w, [w]);
|
|
2898
|
+
let T = n(() => {
|
|
2899
|
+
w(), b(!1), g(null), v(null);
|
|
2900
|
+
}, [w]), E = n((e) => {
|
|
2901
|
+
if (y || f) return;
|
|
2902
|
+
w(), v(null), b(!0);
|
|
2903
|
+
let t = ((typeof e == "number" ? e : typeof C.current == "number" ? C.current : Math.floor(Math.random() * 9)) % 9 + 9) % 9, n = 18 + t, r = 0, i = () => {
|
|
2904
|
+
if (g(r % 9), r += 1, r > n) {
|
|
2905
|
+
g(t), v(t), b(!1), S.current?.(m[t], t);
|
|
2903
2906
|
return;
|
|
2904
2907
|
}
|
|
2905
2908
|
let e = 60 + Math.floor(r * 12);
|
|
2906
|
-
|
|
2909
|
+
x.current.push(window.setTimeout(i, e));
|
|
2907
2910
|
};
|
|
2908
2911
|
i();
|
|
2909
2912
|
}, [
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2913
|
+
m,
|
|
2914
|
+
w,
|
|
2915
|
+
f,
|
|
2916
|
+
y
|
|
2914
2917
|
]);
|
|
2915
|
-
return a(
|
|
2916
|
-
draw:
|
|
2917
|
-
reset:
|
|
2918
|
-
}), [
|
|
2918
|
+
return a(p, () => ({
|
|
2919
|
+
draw: E,
|
|
2920
|
+
reset: T
|
|
2921
|
+
}), [E, T]), /* @__PURE__ */ d("div", {
|
|
2919
2922
|
className: Et.nineGrid,
|
|
2920
2923
|
children: [/* @__PURE__ */ u("div", {
|
|
2921
2924
|
className: Et.board,
|
|
2922
2925
|
role: "grid",
|
|
2923
2926
|
"aria-label": "九宫格抽奖",
|
|
2924
|
-
children:
|
|
2925
|
-
let n =
|
|
2927
|
+
children: m.map((e, t) => {
|
|
2928
|
+
let n = h === t, r = _ === t;
|
|
2926
2929
|
return /* @__PURE__ */ d("div", {
|
|
2927
2930
|
role: "gridcell",
|
|
2928
2931
|
className: `${Et.cell} ${n ? Et.active : ""} ${r ? Et.winner : ""}`,
|
|
@@ -2938,12 +2941,16 @@ var Oe = {
|
|
|
2938
2941
|
}), /* @__PURE__ */ u("button", {
|
|
2939
2942
|
type: "button",
|
|
2940
2943
|
className: Et.button,
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
+
"data-testid": "nine-grid-draw",
|
|
2945
|
+
onClick: () => E(),
|
|
2946
|
+
disabled: y || f,
|
|
2947
|
+
"aria-busy": y,
|
|
2948
|
+
children: y ? o : i
|
|
2944
2949
|
})]
|
|
2945
2950
|
});
|
|
2946
|
-
})
|
|
2951
|
+
});
|
|
2952
|
+
kt.displayName = "NineGrid";
|
|
2953
|
+
var At = {
|
|
2947
2954
|
orbitalChart: "cos-orbitalChart-XLORB",
|
|
2948
2955
|
canvas: "cos-canvas-hGVud",
|
|
2949
2956
|
legend: "cos-legend-Np9Mm",
|
|
@@ -9134,8 +9141,10 @@ var fs = {
|
|
|
9134
9141
|
/* @__PURE__ */ u("button", {
|
|
9135
9142
|
type: "button",
|
|
9136
9143
|
className: fs.spinBtn,
|
|
9144
|
+
"data-testid": "slot-machine-spin",
|
|
9137
9145
|
onClick: () => F(),
|
|
9138
9146
|
disabled: v,
|
|
9147
|
+
"aria-busy": v,
|
|
9139
9148
|
children: v ? p : _
|
|
9140
9149
|
}),
|
|
9141
9150
|
S.length > 0 && !v && /* @__PURE__ */ u("p", {
|
|
@@ -9671,8 +9680,10 @@ var bs = {
|
|
|
9671
9680
|
/* @__PURE__ */ u("button", {
|
|
9672
9681
|
type: "button",
|
|
9673
9682
|
className: Ps.spinBtn,
|
|
9683
|
+
"data-testid": "turntable-spin",
|
|
9674
9684
|
onClick: () => N(),
|
|
9675
9685
|
disabled: S,
|
|
9686
|
+
"aria-busy": S,
|
|
9676
9687
|
children: S ? p : f
|
|
9677
9688
|
})
|
|
9678
9689
|
]
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export interface FlipCardHandle {
|
|
3
|
+
/** 翻到背面(揭示奖励) */
|
|
3
4
|
flip: () => void;
|
|
5
|
+
/** 翻回正面 */
|
|
4
6
|
reset: () => void;
|
|
5
7
|
}
|
|
6
8
|
export interface FlipCardProps {
|
|
7
|
-
/**
|
|
9
|
+
/** 正面标题 */
|
|
8
10
|
frontTitle?: string;
|
|
9
|
-
/**
|
|
11
|
+
/** 正面副标题 */
|
|
10
12
|
frontSubtitle?: string;
|
|
11
|
-
/**
|
|
13
|
+
/** 背面奖励标题 */
|
|
12
14
|
backTitle?: string;
|
|
13
|
-
/**
|
|
15
|
+
/** 背面奖励说明 */
|
|
14
16
|
backSubtitle?: string;
|
|
15
|
-
/**
|
|
17
|
+
/** 受控翻面状态;不传则非受控 */
|
|
16
18
|
flipped?: boolean;
|
|
17
|
-
/**
|
|
19
|
+
/** 非受控时的初始翻面状态,默认 false */
|
|
18
20
|
defaultFlipped?: boolean;
|
|
19
|
-
/**
|
|
21
|
+
/** 翻到背面时回调 */
|
|
20
22
|
onReveal?: () => void;
|
|
21
|
-
/**
|
|
23
|
+
/** 翻面状态变化回调 */
|
|
22
24
|
onFlipChange?: (flipped: boolean) => void;
|
|
23
|
-
/**
|
|
25
|
+
/** 禁用点击 */
|
|
24
26
|
disabled?: boolean;
|
|
25
27
|
}
|
|
26
28
|
declare const FlipCard: React.ForwardRefExoticComponent<FlipCardProps & React.RefAttributes<FlipCardHandle>>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export interface NineGridItem {
|
|
3
|
+
/** 奖品文案 */
|
|
3
4
|
label: string;
|
|
4
|
-
/**
|
|
5
|
+
/** 可选图标(emoji 等),显示在文案上方 */
|
|
5
6
|
icon?: string;
|
|
6
7
|
}
|
|
7
8
|
export interface NineGridHandle {
|
|
8
|
-
/**
|
|
9
|
+
/** 开始抽奖;可传入目标索引覆盖 props.targetIndex */
|
|
9
10
|
draw: (targetIndex?: number) => void;
|
|
11
|
+
/** 重置高亮与中奖态 */
|
|
10
12
|
reset: () => void;
|
|
11
13
|
}
|
|
12
14
|
export interface NineGridProps {
|
|
13
|
-
/**
|
|
15
|
+
/** 9 个奖品格子(不足补齐、超出截断) */
|
|
14
16
|
items?: NineGridItem[];
|
|
15
|
-
/**
|
|
17
|
+
/** 指定下一次抽中的索引 0–8(服务端开奖);不传则随机 */
|
|
16
18
|
targetIndex?: number;
|
|
17
|
-
/**
|
|
19
|
+
/** 抽奖按钮文案 */
|
|
18
20
|
buttonText?: string;
|
|
19
|
-
/**
|
|
21
|
+
/** 抽奖进行中的按钮文案 */
|
|
22
|
+
spinningText?: string;
|
|
23
|
+
/** 抽奖结束回调 */
|
|
20
24
|
onDrawEnd?: (item: NineGridItem, index: number) => void;
|
|
21
|
-
/**
|
|
25
|
+
/** 禁用交互 */
|
|
22
26
|
disabled?: boolean;
|
|
23
27
|
}
|
|
24
28
|
declare const NineGrid: React.ForwardRefExoticComponent<NineGridProps & React.RefAttributes<NineGridHandle>>;
|
package/package.json
CHANGED