@digilogiclabs/saas-factory-ui 2.2.0 → 2.3.0

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.
@@ -30366,14 +30366,35 @@ var PIP_POS = {
30366
30366
  [75, 75]
30367
30367
  ]
30368
30368
  };
30369
- var SHOW_ROT = {
30369
+ var D6_FACE_PLACEMENTS = {
30370
30370
  1: { x: 0, y: 0 },
30371
- 2: { x: 0, y: 180 },
30372
- 3: { x: 0, y: -90 },
30373
- 4: { x: 0, y: 90 },
30374
- 5: { x: -90, y: 0 },
30375
- 6: { x: 90, y: 0 }
30371
+ 2: { x: 0, y: 90 },
30372
+ 3: { x: 90, y: 0 },
30373
+ 4: { x: -90, y: 0 },
30374
+ 5: { x: 0, y: -90 },
30375
+ 6: { x: 0, y: 180 }
30376
30376
  };
30377
+ function d6LandingRotation(value) {
30378
+ const p = D6_FACE_PLACEMENTS[value];
30379
+ return {
30380
+ x: Math.abs(p.x) === 180 ? 180 : -p.x || 0,
30381
+ y: Math.abs(p.y) === 180 ? 180 : -p.y || 0
30382
+ };
30383
+ }
30384
+ var POLY_SHAPES = {
30385
+ 4: { points: "50,8 93,86 7,86", textY: 62, fontScale: 0.3 },
30386
+ 8: { points: "50,4 96,50 50,96 4,50", textY: 51, fontScale: 0.33 },
30387
+ 10: { points: "50,4 93,44 50,96 7,44", textY: 47, fontScale: 0.3 },
30388
+ 12: { points: "50,4 95,37 78,93 22,93 5,37", textY: 54, fontScale: 0.33 },
30389
+ 20: {
30390
+ points: "50,3 91,26 91,74 50,97 9,74 9,26",
30391
+ textY: 51,
30392
+ fontScale: 0.33
30393
+ }
30394
+ };
30395
+ function formatDieValue(v, sides) {
30396
+ return sides > 8 && (v === 6 || v === 9) ? `${v}.` : String(v);
30397
+ }
30377
30398
  var MAX_COUNT = 6;
30378
30399
  var TUMBLE_MS = 950;
30379
30400
  var SETTLE_MS = 1100;
@@ -30525,6 +30546,7 @@ function Face({ value, pipColor, pipShadow, pipDiameter }) {
30525
30546
  }
30526
30547
  function DiceRoller({
30527
30548
  count: count2 = 2,
30549
+ sides = 6,
30528
30550
  theme: theme5 = "red",
30529
30551
  darkMode,
30530
30552
  size = 80,
@@ -30553,6 +30575,7 @@ function DiceRoller({
30553
30575
  const dieWrapperRefs = useRef40([]);
30554
30576
  const cubeRefs = useRef40([]);
30555
30577
  const shadowRefs = useRef40([]);
30578
+ const numeralRefs = useRef40([]);
30556
30579
  const currentPositionsRef = useRef40(null);
30557
30580
  const rollingRef = useRef40(false);
30558
30581
  const dieSetters = useRef40([]);
@@ -30582,6 +30605,15 @@ function DiceRoller({
30582
30605
  }
30583
30606
  return shadowSetters.current[i];
30584
30607
  };
30608
+ const numeralSetters = useRef40([]);
30609
+ const getNumeralSetter = (i) => {
30610
+ if (!numeralSetters.current[i]) {
30611
+ numeralSetters.current[i] = (el) => {
30612
+ numeralRefs.current[i] = el;
30613
+ };
30614
+ }
30615
+ return numeralSetters.current[i];
30616
+ };
30585
30617
  const timersRef = useRef40([]);
30586
30618
  const rafHandleRef = useRef40(null);
30587
30619
  const arenaRef = useRef40(null);
@@ -30634,15 +30666,15 @@ function DiceRoller({
30634
30666
  const pipDiameter = Math.round(effectiveSize * 0.2);
30635
30667
  const faceRadius = Math.round(effectiveSize * 0.07);
30636
30668
  const arenaHeight = arenaHeightProp ?? Math.max(effectiveSize * 3, 200);
30637
- const faceTransforms = useMemo26(
30638
- () => [
30639
- `translateZ(${half}px)`,
30640
- `rotateY(180deg) translateZ(${half}px)`,
30641
- `rotateY(-90deg) translateZ(${half}px)`,
30642
- `rotateY(90deg) translateZ(${half}px)`,
30643
- `rotateX(90deg) translateZ(${half}px)`,
30644
- `rotateX(-90deg) translateZ(${half}px)`
30645
- ],
30669
+ const faceTransformFor = useCallback41(
30670
+ (value) => {
30671
+ const p = D6_FACE_PLACEMENTS[value];
30672
+ const parts = [];
30673
+ if (p.x !== 0) parts.push(`rotateX(${p.x}deg)`);
30674
+ if (p.y !== 0) parts.push(`rotateY(${p.y}deg)`);
30675
+ parts.push(`translateZ(${half}px)`);
30676
+ return parts.join(" ");
30677
+ },
30646
30678
  [half]
30647
30679
  );
30648
30680
  const defaultPositions = useCallback41(
@@ -30664,11 +30696,11 @@ function DiceRoller({
30664
30696
  [half]
30665
30697
  );
30666
30698
  const writeCubeRotation = useCallback41(
30667
- (i, rx, ry, rz, withTransition) => {
30699
+ (i, rx, ry, rz, withTransition, tiltZ = 0) => {
30668
30700
  const el = cubeRefs.current[i];
30669
30701
  if (!el) return;
30670
30702
  el.style.transition = withTransition ? "transform 0.95s cubic-bezier(0.12,0.8,0.22,1)" : "none";
30671
- el.style.transform = `rotateX(${rx}deg) rotateY(${ry}deg) rotateZ(${rz}deg)`;
30703
+ el.style.transform = `${tiltZ ? `rotateZ(${tiltZ}deg) ` : ""}rotateX(${rx}deg) rotateY(${ry}deg) rotateZ(${rz}deg)`;
30672
30704
  },
30673
30705
  []
30674
30706
  );
@@ -30698,19 +30730,23 @@ function DiceRoller({
30698
30730
  setResults(null);
30699
30731
  }, [
30700
30732
  clampedCount,
30733
+ sides,
30701
30734
  effectiveSize,
30702
30735
  arena.w,
30703
30736
  arenaHeight,
30704
30737
  defaultPositions,
30705
30738
  half
30706
30739
  ]);
30740
+ useEffect52(() => {
30741
+ setHistory([]);
30742
+ }, [sides]);
30707
30743
  const roll = useCallback41(() => {
30708
30744
  if (rollingRef.current) return;
30709
30745
  rollingRef.current = true;
30710
30746
  setRolling(true);
30711
30747
  const vals = Array.from(
30712
30748
  { length: clampedCount },
30713
- () => Math.floor(Math.random() * 6) + 1
30749
+ () => Math.floor(Math.random() * sides) + 1
30714
30750
  );
30715
30751
  timersRef.current.forEach((t) => clearTimeout(t));
30716
30752
  timersRef.current = [];
@@ -30725,13 +30761,17 @@ function DiceRoller({
30725
30761
  const starts = currentPositionsRef.current ?? defaultPositions(w, h, clampedCount);
30726
30762
  const frames = simulateDice(w, h, effectiveSize, starts, clampedCount);
30727
30763
  for (let i = 0; i < clampedCount; i++) {
30728
- writeCubeRotation(
30729
- i,
30730
- (Math.random() - 0.5) * 720,
30731
- (Math.random() - 0.5) * 720,
30732
- (Math.random() - 0.5) * 720,
30733
- false
30734
- );
30764
+ if (sides === 6) {
30765
+ writeCubeRotation(
30766
+ i,
30767
+ (Math.random() - 0.5) * 720,
30768
+ (Math.random() - 0.5) * 720,
30769
+ (Math.random() - 0.5) * 720,
30770
+ false
30771
+ );
30772
+ } else {
30773
+ writeCubeRotation(i, 0, 0, (Math.random() - 0.5) * 720, false);
30774
+ }
30735
30775
  const el = dieWrapperRefs.current[i];
30736
30776
  if (el) el.style.transition = "none";
30737
30777
  const shadow = shadowRefs.current[i];
@@ -30764,18 +30804,47 @@ function DiceRoller({
30764
30804
  }, capturedStep * stepMs);
30765
30805
  timersRef.current.push(timer);
30766
30806
  }
30807
+ if (sides !== 6) {
30808
+ const flickerTicks = 8;
30809
+ const flickerStep = Math.max(60, Math.floor(TUMBLE_MS / flickerTicks));
30810
+ for (let f = 1; f <= flickerTicks; f++) {
30811
+ const t = setTimeout(() => {
30812
+ for (let i = 0; i < clampedCount; i++) {
30813
+ const el = numeralRefs.current[i];
30814
+ if (el)
30815
+ el.textContent = formatDieValue(
30816
+ Math.floor(Math.random() * sides) + 1,
30817
+ sides
30818
+ );
30819
+ }
30820
+ }, f * flickerStep);
30821
+ timersRef.current.push(t);
30822
+ }
30823
+ }
30767
30824
  requestAnimationFrame(() => {
30768
30825
  requestAnimationFrame(() => {
30769
30826
  for (let i = 0; i < clampedCount; i++) {
30770
- const tgt = SHOW_ROT[vals[i]];
30771
- const lx = tgt.x + (Math.random() > 0.5 ? 720 : -720);
30772
- const ly = tgt.y;
30773
- const lz = (Math.random() > 0.5 ? 1 : -1) * 360;
30774
- writeCubeRotation(i, lx, ly, lz, true);
30827
+ const tilt = (Math.random() - 0.5) * 18;
30828
+ if (sides === 6) {
30829
+ const tgt = d6LandingRotation(vals[i]);
30830
+ const lx = tgt.x + (Math.random() > 0.5 ? 720 : -720);
30831
+ const ly = tgt.y;
30832
+ const lz = (Math.random() > 0.5 ? 1 : -1) * 360;
30833
+ writeCubeRotation(i, lx, ly, lz, true, tilt);
30834
+ } else {
30835
+ const lz = (Math.random() > 0.5 ? 1 : -1) * 720 + tilt;
30836
+ writeCubeRotation(i, 0, 0, lz, true);
30837
+ }
30775
30838
  }
30776
30839
  });
30777
30840
  });
30778
30841
  const settleTimer = setTimeout(() => {
30842
+ if (sides !== 6) {
30843
+ for (let i = 0; i < clampedCount; i++) {
30844
+ const el = numeralRefs.current[i];
30845
+ if (el) el.textContent = formatDieValue(vals[i], sides);
30846
+ }
30847
+ }
30779
30848
  setResults(vals);
30780
30849
  setRolling(false);
30781
30850
  rollingRef.current = false;
@@ -30788,6 +30857,7 @@ function DiceRoller({
30788
30857
  timersRef.current.push(settleTimer);
30789
30858
  }, [
30790
30859
  clampedCount,
30860
+ sides,
30791
30861
  defaultPositions,
30792
30862
  effectiveSize,
30793
30863
  half,
@@ -30833,7 +30903,7 @@ function DiceRoller({
30833
30903
  {
30834
30904
  ref: arenaRef,
30835
30905
  role: "img",
30836
- "aria-label": ariaLabel ?? `${clampedCount} dice`,
30906
+ "aria-label": ariaLabel ?? `${clampedCount} ${sides === 6 ? "dice" : `${sides}-sided dice`}`,
30837
30907
  "aria-live": "polite",
30838
30908
  style: {
30839
30909
  position: "relative",
@@ -30896,7 +30966,7 @@ function DiceRoller({
30896
30966
  transformStyle: "preserve-3d",
30897
30967
  willChange: "transform"
30898
30968
  },
30899
- children: [1, 2, 3, 4, 5, 6].map((val, fi) => /* @__PURE__ */ jsx113(
30969
+ children: sides === 6 ? [1, 2, 3, 4, 5, 6].map((val) => /* @__PURE__ */ jsx113(
30900
30970
  "div",
30901
30971
  {
30902
30972
  style: {
@@ -30906,7 +30976,7 @@ function DiceRoller({
30906
30976
  background: colors.face,
30907
30977
  border: `1px solid ${colors.faceBorder}`,
30908
30978
  borderRadius: faceRadius,
30909
- transform: faceTransforms[fi],
30979
+ transform: faceTransformFor(val),
30910
30980
  transition: "background 0.3s, border-color 0.3s"
30911
30981
  },
30912
30982
  children: /* @__PURE__ */ jsx113(
@@ -30920,7 +30990,64 @@ function DiceRoller({
30920
30990
  )
30921
30991
  },
30922
30992
  val
30923
- ))
30993
+ )) : (() => {
30994
+ const shape = POLY_SHAPES[sides];
30995
+ const shown = results?.[d] ?? sides;
30996
+ return /* @__PURE__ */ jsxs86(
30997
+ "svg",
30998
+ {
30999
+ viewBox: "0 0 100 100",
31000
+ width: "100%",
31001
+ height: "100%",
31002
+ style: { display: "block", overflow: "visible" },
31003
+ "aria-hidden": "true",
31004
+ children: [
31005
+ /* @__PURE__ */ jsx113(
31006
+ "polygon",
31007
+ {
31008
+ points: shape.points,
31009
+ fill: colors.face,
31010
+ stroke: colors.faceBorder,
31011
+ strokeWidth: 2.5,
31012
+ strokeLinejoin: "round",
31013
+ style: { transition: "fill 0.3s, stroke 0.3s" }
31014
+ }
31015
+ ),
31016
+ /* @__PURE__ */ jsx113(
31017
+ "polygon",
31018
+ {
31019
+ points: shape.points,
31020
+ fill: "none",
31021
+ stroke: colors.faceBorder,
31022
+ strokeWidth: 1.5,
31023
+ strokeLinejoin: "round",
31024
+ opacity: 0.55,
31025
+ transform: "translate(50 50) scale(0.76) translate(-50 -50)"
31026
+ }
31027
+ ),
31028
+ /* @__PURE__ */ jsx113(
31029
+ "text",
31030
+ {
31031
+ ref: getNumeralSetter(d),
31032
+ x: 50,
31033
+ y: shape.textY,
31034
+ textAnchor: "middle",
31035
+ dominantBaseline: "central",
31036
+ fontSize: 100 * shape.fontScale,
31037
+ fontWeight: 800,
31038
+ fill: colors.pip,
31039
+ style: {
31040
+ fontVariantNumeric: "tabular-nums",
31041
+ transition: "fill 0.3s",
31042
+ userSelect: "none"
31043
+ },
31044
+ children: formatDieValue(shown, sides)
31045
+ }
31046
+ )
31047
+ ]
31048
+ }
31049
+ );
31050
+ })()
30924
31051
  }
30925
31052
  )
30926
31053
  ] }, d);
@@ -43343,6 +43470,7 @@ export {
43343
43470
  CommentSystem,
43344
43471
  Container,
43345
43472
  ConversionKPI,
43473
+ D6_FACE_PLACEMENTS,
43346
43474
  DashboardGrid,
43347
43475
  DashboardLayout,
43348
43476
  DashboardWidget,
@@ -43583,6 +43711,7 @@ export {
43583
43711
  createFormStore,
43584
43712
  createOptimizedStore,
43585
43713
  cssAnimations,
43714
+ d6LandingRotation,
43586
43715
  dailyTrendingConfig,
43587
43716
  detectAuthProvider,
43588
43717
  detectDelimiter,