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/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
  });
@@ -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(function({ frontTitle: e = "签到翻牌", frontSubtitle: t = "点击翻开今日奖励", backTitle: n = "恭喜获得", backSubtitle: r = "积分 +20", flipped: i, defaultFlipped: o = !1, onReveal: s, onFlipChange: l, disabled: f = !1 }, p) {
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
- }), Ae = {
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(function({ items: e, targetIndex: t, buttonText: i = "开始抽奖", onDrawEnd: o, disabled: l = !1 }, f) {
2885
- 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);
2886
2889
  r(() => {
2887
- x.current = o;
2888
- }, [o]), r(() => {
2889
- S.current = t;
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
- C(), y(!1), h(null), _(null);
2897
- }, [C]), T = n((e) => {
2898
- if (v || l) return;
2899
- C(), _(null), y(!0);
2900
- 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 = () => {
2901
- if (h(r % 9), r += 1, r > n) {
2902
- 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);
2903
2906
  return;
2904
2907
  }
2905
2908
  let e = 60 + Math.floor(r * 12);
2906
- b.current.push(window.setTimeout(i, e));
2909
+ x.current.push(window.setTimeout(i, e));
2907
2910
  };
2908
2911
  i();
2909
2912
  }, [
2910
- p,
2911
- C,
2912
- l,
2913
- v
2913
+ m,
2914
+ w,
2915
+ f,
2916
+ y
2914
2917
  ]);
2915
- return a(f, () => ({
2916
- draw: T,
2917
- reset: w
2918
- }), [T, w]), /* @__PURE__ */ d("div", {
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: p.map((e, t) => {
2925
- let n = m === t, r = g === t;
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
- onClick: () => T(),
2942
- disabled: v || l,
2943
- 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
2944
2949
  })]
2945
2950
  });
2946
- }), At = {
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
- /** Front face title (e.g. Day 3) */
9
+ /** 正面标题 */
8
10
  frontTitle?: string;
9
- /** Front face subtitle */
11
+ /** 正面副标题 */
10
12
  frontSubtitle?: string;
11
- /** Back face reward title */
13
+ /** 背面奖励标题 */
12
14
  backTitle?: string;
13
- /** Back face detail */
15
+ /** 背面奖励说明 */
14
16
  backSubtitle?: string;
15
- /** Controlled flip; omit for uncontrolled */
17
+ /** 受控翻面状态;不传则非受控 */
16
18
  flipped?: boolean;
17
- /** Initial flip when uncontrolled */
19
+ /** 非受控时的初始翻面状态,默认 false */
18
20
  defaultFlipped?: boolean;
19
- /** Called after flip toggles to true (reveal) */
21
+ /** 翻到背面时回调 */
20
22
  onReveal?: () => void;
21
- /** Called on any flip change */
23
+ /** 翻面状态变化回调 */
22
24
  onFlipChange?: (flipped: boolean) => void;
23
- /** Disable clicking the card */
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
- /** Optional emoji / short mark shown above the label */
5
+ /** 可选图标(emoji 等),显示在文案上方 */
5
6
  icon?: string;
6
7
  }
7
8
  export interface NineGridHandle {
8
- /** Start a draw. Optional override for server-drawn index. */
9
+ /** 开始抽奖;可传入目标索引覆盖 props.targetIndex */
9
10
  draw: (targetIndex?: number) => void;
11
+ /** 重置高亮与中奖态 */
10
12
  reset: () => void;
11
13
  }
12
14
  export interface NineGridProps {
13
- /** Exactly 9 prize cells (or will be padded/truncated to 9) */
15
+ /** 9 个奖品格子(不足补齐、超出截断) */
14
16
  items?: NineGridItem[];
15
- /** Next winning index 0–8 (server draw). Omit for random. */
17
+ /** 指定下一次抽中的索引 0–8(服务端开奖);不传则随机 */
16
18
  targetIndex?: number;
17
- /** Draw button label */
19
+ /** 抽奖按钮文案 */
18
20
  buttonText?: string;
19
- /** Called when the highlight settles on a cell */
21
+ /** 抽奖进行中的按钮文案 */
22
+ spinningText?: string;
23
+ /** 抽奖结束回调 */
20
24
  onDrawEnd?: (item: NineGridItem, index: number) => void;
21
- /** Disable interaction while drawing */
25
+ /** 禁用交互 */
22
26
  disabled?: boolean;
23
27
  }
24
28
  declare const NineGrid: React.ForwardRefExoticComponent<NineGridProps & React.RefAttributes<NineGridHandle>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cos-design",
3
- "version": "3.7.8",
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",