cos-design 3.7.9 → 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/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: r = k }) => {
279
- let { hostRef: i, hostStyle: a } = D({
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
- }), o = r.length >= 2 ? r : k;
286
- return /* @__PURE__ */ u("div", {
287
- ref: i,
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: a,
290
- children: o.map((e, t) => /* @__PURE__ */ u("div", {
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
  });
@@ -2883,48 +2884,48 @@ var Ae = {
2883
2884
  let t = [...e?.length ? e : Dt];
2884
2885
  for (; t.length < 9;) t.push({ label: `奖品 ${t.length + 1}` });
2885
2886
  return t.slice(0, 9);
2886
- }, kt = t(({ items: e = Dt, targetIndex: t, buttonText: i = "开始抽奖", onDrawEnd: o, disabled: l = !1 }, f) => {
2887
- let p = Ot(e), [m, h] = c(null), [g, _] = c(null), [v, y] = c(!1), b = s([]), x = s(o), S = s(t);
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);
2888
2889
  r(() => {
2889
- x.current = o;
2890
- }, [o]), r(() => {
2891
- S.current = t;
2890
+ S.current = l;
2891
+ }, [l]), r(() => {
2892
+ C.current = t;
2892
2893
  }, [t]);
2893
- let C = n(() => {
2894
- b.current.forEach((e) => window.clearTimeout(e)), b.current = [];
2895
- }, []);
2896
- r(() => C, [C]);
2897
2894
  let w = n(() => {
2898
- C(), y(!1), h(null), _(null);
2899
- }, [C]), T = n((e) => {
2900
- if (v || l) return;
2901
- C(), _(null), y(!0);
2902
- let t = ((typeof e == "number" ? e : typeof S.current == "number" ? S.current : Math.floor(Math.random() * 9)) % 9 + 9) % 9, n = 18 + t, r = 0, i = () => {
2903
- if (h(r % 9), r += 1, r > n) {
2904
- h(t), _(t), y(!1), x.current?.(p[t], t);
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);
2905
2906
  return;
2906
2907
  }
2907
2908
  let e = 60 + Math.floor(r * 12);
2908
- b.current.push(window.setTimeout(i, e));
2909
+ x.current.push(window.setTimeout(i, e));
2909
2910
  };
2910
2911
  i();
2911
2912
  }, [
2912
- p,
2913
- C,
2914
- l,
2915
- v
2913
+ m,
2914
+ w,
2915
+ f,
2916
+ y
2916
2917
  ]);
2917
- return a(f, () => ({
2918
- draw: T,
2919
- reset: w
2920
- }), [T, w]), /* @__PURE__ */ d("div", {
2918
+ return a(p, () => ({
2919
+ draw: E,
2920
+ reset: T
2921
+ }), [E, T]), /* @__PURE__ */ d("div", {
2921
2922
  className: Et.nineGrid,
2922
2923
  children: [/* @__PURE__ */ u("div", {
2923
2924
  className: Et.board,
2924
2925
  role: "grid",
2925
2926
  "aria-label": "九宫格抽奖",
2926
- children: p.map((e, t) => {
2927
- let n = m === t, r = g === t;
2927
+ children: m.map((e, t) => {
2928
+ let n = h === t, r = _ === t;
2928
2929
  return /* @__PURE__ */ d("div", {
2929
2930
  role: "gridcell",
2930
2931
  className: `${Et.cell} ${n ? Et.active : ""} ${r ? Et.winner : ""}`,
@@ -2940,9 +2941,11 @@ var Ae = {
2940
2941
  }), /* @__PURE__ */ u("button", {
2941
2942
  type: "button",
2942
2943
  className: Et.button,
2943
- onClick: () => T(),
2944
- disabled: v || l,
2945
- children: v ? "抽奖中…" : i
2944
+ "data-testid": "nine-grid-draw",
2945
+ onClick: () => E(),
2946
+ disabled: y || f,
2947
+ "aria-busy": y,
2948
+ children: y ? o : i
2946
2949
  })]
2947
2950
  });
2948
2951
  });
@@ -9138,8 +9141,10 @@ var fs = {
9138
9141
  /* @__PURE__ */ u("button", {
9139
9142
  type: "button",
9140
9143
  className: fs.spinBtn,
9144
+ "data-testid": "slot-machine-spin",
9141
9145
  onClick: () => F(),
9142
9146
  disabled: v,
9147
+ "aria-busy": v,
9143
9148
  children: v ? p : _
9144
9149
  }),
9145
9150
  S.length > 0 && !v && /* @__PURE__ */ u("p", {
@@ -9675,8 +9680,10 @@ var bs = {
9675
9680
  /* @__PURE__ */ u("button", {
9676
9681
  type: "button",
9677
9682
  className: Ps.spinBtn,
9683
+ "data-testid": "turntable-spin",
9678
9684
  onClick: () => N(),
9679
9685
  disabled: S,
9686
+ "aria-busy": S,
9680
9687
  children: S ? p : f
9681
9688
  })
9682
9689
  ]
@@ -18,6 +18,8 @@ export interface NineGridProps {
18
18
  targetIndex?: number;
19
19
  /** 抽奖按钮文案 */
20
20
  buttonText?: string;
21
+ /** 抽奖进行中的按钮文案 */
22
+ spinningText?: string;
21
23
  /** 抽奖结束回调 */
22
24
  onDrawEnd?: (item: NineGridItem, index: number) => void;
23
25
  /** 禁用交互 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cos-design",
3
- "version": "3.7.9",
3
+ "version": "3.7.10",
4
4
  "description": "React visual-effect components for marketing pages, campaigns, canvas backgrounds, and creative showcases",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",