@digilogiclabs/saas-factory-ui 2.8.1 → 2.9.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.
package/dist/index.mjs CHANGED
@@ -30388,6 +30388,7 @@ function TiltCard({
30388
30388
  import {
30389
30389
  useCallback as useCallback44,
30390
30390
  useEffect as useEffect54,
30391
+ useId as useId3,
30391
30392
  useMemo as useMemo28,
30392
30393
  useRef as useRef39,
30393
30394
  useState as useState70
@@ -30478,17 +30479,192 @@ function d6LandingRotation(value) {
30478
30479
  y: Math.abs(p.y) === 180 ? 180 : -p.y || 0
30479
30480
  };
30480
30481
  }
30481
- var POLY_SHAPES = {
30482
- 4: { points: "50,8 93,86 7,86", textY: 62, fontScale: 0.3 },
30483
- 8: { points: "50,4 96,50 50,96 4,50", textY: 51, fontScale: 0.33 },
30484
- 10: { points: "50,4 93,44 50,96 7,44", textY: 47, fontScale: 0.3 },
30485
- 12: { points: "50,4 95,37 78,93 22,93 5,37", textY: 54, fontScale: 0.33 },
30486
- 20: {
30487
- points: "50,3 91,26 91,74 50,97 9,74 9,26",
30488
- textY: 51,
30489
- fontScale: 0.33
30482
+ var PHI = (1 + Math.sqrt(5)) / 2;
30483
+ var dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
30484
+ var cross3 = (a, b) => [
30485
+ a[1] * b[2] - a[2] * b[1],
30486
+ a[2] * b[0] - a[0] * b[2],
30487
+ a[0] * b[1] - a[1] * b[0]
30488
+ ];
30489
+ var sub3 = (a, b) => [
30490
+ a[0] - b[0],
30491
+ a[1] - b[1],
30492
+ a[2] - b[2]
30493
+ ];
30494
+ var scale3 = (a, s) => [a[0] * s, a[1] * s, a[2] * s];
30495
+ var len3 = (a) => Math.hypot(a[0], a[1], a[2]);
30496
+ var norm3 = (a) => scale3(a, 1 / len3(a));
30497
+ function rotateAround(p, axis, angle) {
30498
+ const cosA = Math.cos(angle);
30499
+ const sinA = Math.sin(angle);
30500
+ const t1 = scale3(p, cosA);
30501
+ const t2 = scale3(cross3(axis, p), sinA);
30502
+ const t3 = scale3(axis, dot3(axis, p) * (1 - cosA));
30503
+ return [t1[0] + t2[0] + t3[0], t1[1] + t2[1] + t3[1], t1[2] + t2[2] + t3[2]];
30504
+ }
30505
+ function rotationTo(from, to) {
30506
+ const c = dot3(from, to);
30507
+ if (c > 1 - 1e-9) return (p) => p;
30508
+ const axis = c < -1 + 1e-9 ? norm3(
30509
+ Math.abs(from[0]) < 0.9 ? cross3(from, [1, 0, 0]) : cross3(from, [0, 1, 0])
30510
+ ) : norm3(cross3(from, to));
30511
+ const angle = Math.acos(Math.max(-1, Math.min(1, c)));
30512
+ return (p) => rotateAround(p, axis, angle);
30513
+ }
30514
+ function solidVertices(sides) {
30515
+ switch (sides) {
30516
+ case 4:
30517
+ return [
30518
+ [1, 1, 1],
30519
+ [1, -1, -1],
30520
+ [-1, 1, -1],
30521
+ [-1, -1, 1]
30522
+ ];
30523
+ case 8:
30524
+ return [
30525
+ [1, 0, 0],
30526
+ [-1, 0, 0],
30527
+ [0, 1, 0],
30528
+ [0, -1, 0],
30529
+ [0, 0, 1],
30530
+ [0, 0, -1]
30531
+ ];
30532
+ case 10: {
30533
+ const h = 0.15;
30534
+ const cos36 = Math.cos(Math.PI / 5);
30535
+ const zApex = 2 * h / (1 - cos36) * cos36 + h;
30536
+ const verts = [
30537
+ [0, 0, zApex],
30538
+ [0, 0, -zApex]
30539
+ ];
30540
+ for (let k = 0; k < 10; k++) {
30541
+ const a = k * Math.PI / 5;
30542
+ verts.push([Math.cos(a), Math.sin(a), k % 2 === 0 ? h : -h]);
30543
+ }
30544
+ return verts;
30545
+ }
30546
+ case 12: {
30547
+ const v = [];
30548
+ for (const sx of [1, -1])
30549
+ for (const sy of [1, -1])
30550
+ for (const sz of [1, -1]) v.push([sx, sy, sz]);
30551
+ const b = 1 / PHI;
30552
+ for (const s1 of [1, -1])
30553
+ for (const s2 of [1, -1]) {
30554
+ v.push([0, s1 * b, s2 * PHI]);
30555
+ v.push([s1 * b, s2 * PHI, 0]);
30556
+ v.push([s2 * PHI, 0, s1 * b]);
30557
+ }
30558
+ return v;
30559
+ }
30560
+ case 20: {
30561
+ const v = [];
30562
+ for (const s1 of [1, -1])
30563
+ for (const s2 of [1, -1]) {
30564
+ v.push([0, s1, s2 * PHI]);
30565
+ v.push([s1, s2 * PHI, 0]);
30566
+ v.push([s2 * PHI, 0, s1]);
30567
+ }
30568
+ return v;
30569
+ }
30490
30570
  }
30491
- };
30571
+ }
30572
+ function computeFaces(verts) {
30573
+ const faces = [];
30574
+ const seen = /* @__PURE__ */ new Set();
30575
+ for (let i = 0; i < verts.length; i++)
30576
+ for (let j = i + 1; j < verts.length; j++)
30577
+ for (let k = j + 1; k < verts.length; k++) {
30578
+ let n = cross3(sub3(verts[j], verts[i]), sub3(verts[k], verts[i]));
30579
+ if (len3(n) < 1e-9) continue;
30580
+ n = norm3(n);
30581
+ let d = dot3(n, verts[i]);
30582
+ if (d < 0) {
30583
+ n = scale3(n, -1);
30584
+ d = -d;
30585
+ }
30586
+ if (verts.some((p) => dot3(n, p) > d + 1e-4)) continue;
30587
+ const ids = verts.flatMap(
30588
+ (p, idx) => Math.abs(dot3(n, p) - d) < 1e-4 ? [idx] : []
30589
+ );
30590
+ const key = ids.join(",");
30591
+ if (seen.has(key)) continue;
30592
+ seen.add(key);
30593
+ faces.push({ normal: n, ids });
30594
+ }
30595
+ return faces;
30596
+ }
30597
+ var polyhedronCache = /* @__PURE__ */ new Map();
30598
+ function buildPolyhedron(sides) {
30599
+ const cached = polyhedronCache.get(sides);
30600
+ if (cached) return cached;
30601
+ let verts = solidVertices(sides);
30602
+ const rough = computeFaces(verts);
30603
+ const front = rough.reduce(
30604
+ (best, f) => f.normal[2] > best.normal[2] + 1e-9 ? f : best
30605
+ );
30606
+ const rot = rotationTo(front.normal, [0, 0, 1]);
30607
+ verts = verts.map(rot);
30608
+ const rMax = Math.max(...verts.map(len3));
30609
+ verts = verts.map((p) => scale3(p, 1 / rMax));
30610
+ const raw = computeFaces(verts);
30611
+ const built = raw.map((f) => {
30612
+ const faceVerts = f.ids.map((i) => verts[i]);
30613
+ const centroid = scale3(
30614
+ faceVerts.reduce((a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]]),
30615
+ 1 / faceVerts.length
30616
+ );
30617
+ const w = f.normal;
30618
+ let vRaw = sub3([0, 1, 0], scale3(w, w[1]));
30619
+ if (len3(vRaw) < 1e-6) vRaw = sub3([0, 0, 1], scale3(w, w[2]));
30620
+ const v = norm3(vRaw);
30621
+ const u = cross3(v, w);
30622
+ const pts = faceVerts.map((p) => [
30623
+ dot3(sub3(p, centroid), u),
30624
+ dot3(sub3(p, centroid), v)
30625
+ ]).sort((a, b) => Math.atan2(a[1], a[0]) - Math.atan2(b[1], b[0]));
30626
+ return { normal: w, centroid, u, v, pts, value: 0 };
30627
+ });
30628
+ built.sort((a, b) => b.normal[2] - a.normal[2]);
30629
+ const oppOf = (i) => built.findIndex((g) => dot3(built[i].normal, g.normal) < -0.9999);
30630
+ const pool = [];
30631
+ for (let v2 = 1; v2 < sides; v2++) pool.push(v2);
30632
+ built[0].value = sides;
30633
+ const opp0 = oppOf(0);
30634
+ if (opp0 >= 0) {
30635
+ built[opp0].value = 1;
30636
+ pool.splice(pool.indexOf(1), 1);
30637
+ }
30638
+ for (let i = 1; i < built.length; i++) {
30639
+ if (built[i].value !== 0) continue;
30640
+ const v2 = pool.shift();
30641
+ built[i].value = v2;
30642
+ const j = oppOf(i);
30643
+ if (j >= 0 && built[j].value === 0) {
30644
+ built[j].value = sides + 1 - v2;
30645
+ pool.splice(pool.indexOf(sides + 1 - v2), 1);
30646
+ }
30647
+ }
30648
+ const faceRadius = Math.max(
30649
+ ...built.flatMap((f) => f.pts.map(([x, y]) => Math.hypot(x, y)))
30650
+ );
30651
+ const edgeDist = (pts) => Math.min(
30652
+ ...pts.map((p1, i2) => {
30653
+ const p2 = pts[(i2 + 1) % pts.length];
30654
+ const dx = p2[0] - p1[0];
30655
+ const dy = p2[1] - p1[1];
30656
+ const t = Math.max(
30657
+ 0,
30658
+ Math.min(1, -(p1[0] * dx + p1[1] * dy) / (dx * dx + dy * dy))
30659
+ );
30660
+ return Math.hypot(p1[0] + t * dx, p1[1] + t * dy);
30661
+ })
30662
+ );
30663
+ const faceInradius = Math.min(...built.map((f) => edgeDist(f.pts)));
30664
+ const result = { faces: built, faceRadius, faceInradius };
30665
+ polyhedronCache.set(sides, result);
30666
+ return result;
30667
+ }
30492
30668
  function formatDieValue(v, sides) {
30493
30669
  return sides > 8 && (v === 6 || v === 9) ? `${v}.` : String(v);
30494
30670
  }
@@ -30713,6 +30889,7 @@ function DiceRoller({
30713
30889
  }
30714
30890
  return numeralSetters.current[i];
30715
30891
  };
30892
+ const sheenGradientId = useId3();
30716
30893
  const timersRef = useRef39([]);
30717
30894
  const rafHandleRef = useRef39(null);
30718
30895
  const arenaRef = useRef39(null);
@@ -31098,57 +31275,97 @@ function DiceRoller({
31098
31275
  },
31099
31276
  val
31100
31277
  )) : (() => {
31101
- const shape = POLY_SHAPES[sides];
31278
+ const geo = buildPolyhedron(sides);
31279
+ const R = effectiveSize / 2;
31280
+ const S = Math.ceil(geo.faceRadius * R * 2) + 6;
31281
+ const fontSize = geo.faceInradius * R * 1.15;
31102
31282
  const shown = results?.[d] ?? sides;
31103
- const cardFaceStyle = {
31104
- position: "absolute",
31105
- inset: 0,
31106
- display: "block",
31107
- overflow: "visible",
31108
- backfaceVisibility: "hidden"
31109
- };
31110
- return /* @__PURE__ */ jsxs86(Fragment30, { children: [
31111
- /* @__PURE__ */ jsxs86(
31283
+ return /* @__PURE__ */ jsx114(Fragment30, { children: geo.faces.map((f, fi) => {
31284
+ const m = `matrix3d(${f.u[0]},${f.u[1]},${f.u[2]},0,${f.v[0]},${f.v[1]},${f.v[2]},0,${f.normal[0]},${f.normal[1]},${f.normal[2]},0,${f.centroid[0] * R},${f.centroid[1] * R},${f.centroid[2] * R},1)`;
31285
+ const gid = `${sheenGradientId}-${d}-${fi}`;
31286
+ const pts = f.pts.map(
31287
+ ([x, y]) => `${(x * R + S / 2).toFixed(2)},${(y * R + S / 2).toFixed(2)}`
31288
+ ).join(" ");
31289
+ return /* @__PURE__ */ jsxs86(
31112
31290
  "svg",
31113
31291
  {
31114
- viewBox: "0 0 100 100",
31115
- width: "100%",
31116
- height: "100%",
31117
- style: cardFaceStyle,
31292
+ width: S,
31293
+ height: S,
31294
+ viewBox: `0 0 ${S} ${S}`,
31295
+ style: {
31296
+ position: "absolute",
31297
+ left: "50%",
31298
+ top: "50%",
31299
+ marginLeft: -S / 2,
31300
+ marginTop: -S / 2,
31301
+ overflow: "visible",
31302
+ transform: m,
31303
+ // Convex solid: a face is either front-
31304
+ // facing or hidden behind nearer faces,
31305
+ // so hiding backfaces is both correct
31306
+ // and the mirrored-numeral guard.
31307
+ backfaceVisibility: "hidden"
31308
+ },
31118
31309
  "aria-hidden": "true",
31119
31310
  children: [
31120
- /* @__PURE__ */ jsx114(
31121
- "polygon",
31311
+ /* @__PURE__ */ jsx114("defs", { children: /* @__PURE__ */ jsxs86(
31312
+ "radialGradient",
31122
31313
  {
31123
- points: shape.points,
31124
- fill: colors.face,
31125
- stroke: colors.faceBorder,
31126
- strokeWidth: 2.5,
31127
- strokeLinejoin: "round",
31128
- style: { transition: "fill 0.3s, stroke 0.3s" }
31314
+ id: gid,
31315
+ cx: "32%",
31316
+ cy: "26%",
31317
+ r: "80%",
31318
+ children: [
31319
+ /* @__PURE__ */ jsx114(
31320
+ "stop",
31321
+ {
31322
+ offset: "0%",
31323
+ stopColor: "#fff",
31324
+ stopOpacity: "0.38"
31325
+ }
31326
+ ),
31327
+ /* @__PURE__ */ jsx114(
31328
+ "stop",
31329
+ {
31330
+ offset: "55%",
31331
+ stopColor: "#fff",
31332
+ stopOpacity: "0.08"
31333
+ }
31334
+ ),
31335
+ /* @__PURE__ */ jsx114(
31336
+ "stop",
31337
+ {
31338
+ offset: "100%",
31339
+ stopColor: "#fff",
31340
+ stopOpacity: "0"
31341
+ }
31342
+ )
31343
+ ]
31129
31344
  }
31130
- ),
31345
+ ) }),
31131
31346
  /* @__PURE__ */ jsx114(
31132
31347
  "polygon",
31133
31348
  {
31134
- points: shape.points,
31135
- fill: "none",
31349
+ points: pts,
31350
+ fill: colors.face,
31136
31351
  stroke: colors.faceBorder,
31137
31352
  strokeWidth: 1.5,
31138
31353
  strokeLinejoin: "round",
31139
- opacity: 0.55,
31140
- transform: "translate(50 50) scale(0.76) translate(-50 -50)"
31354
+ style: {
31355
+ transition: "fill 0.3s, stroke 0.3s"
31356
+ }
31141
31357
  }
31142
31358
  ),
31359
+ /* @__PURE__ */ jsx114("polygon", { points: pts, fill: `url(#${gid})` }),
31143
31360
  /* @__PURE__ */ jsx114(
31144
31361
  "text",
31145
31362
  {
31146
- ref: getNumeralSetter(d),
31147
- x: 50,
31148
- y: shape.textY,
31363
+ ref: fi === 0 ? getNumeralSetter(d) : void 0,
31364
+ x: S / 2,
31365
+ y: S / 2,
31149
31366
  textAnchor: "middle",
31150
31367
  dominantBaseline: "central",
31151
- fontSize: 100 * shape.fontScale,
31368
+ fontSize,
31152
31369
  fontWeight: 800,
31153
31370
  fill: colors.pip,
31154
31371
  style: {
@@ -31156,59 +31373,17 @@ function DiceRoller({
31156
31373
  transition: "fill 0.3s",
31157
31374
  userSelect: "none"
31158
31375
  },
31159
- children: formatDieValue(shown, sides)
31376
+ children: formatDieValue(
31377
+ fi === 0 ? shown : f.value,
31378
+ sides
31379
+ )
31160
31380
  }
31161
31381
  )
31162
31382
  ]
31163
- }
31164
- ),
31165
- /* @__PURE__ */ jsxs86(
31166
- "svg",
31167
- {
31168
- viewBox: "0 0 100 100",
31169
- width: "100%",
31170
- height: "100%",
31171
- style: {
31172
- ...cardFaceStyle,
31173
- transform: "rotateY(180deg)"
31174
- },
31175
- "aria-hidden": "true",
31176
- children: [
31177
- /* @__PURE__ */ jsx114(
31178
- "polygon",
31179
- {
31180
- points: shape.points,
31181
- fill: colors.face,
31182
- stroke: colors.faceBorder,
31183
- strokeWidth: 2.5,
31184
- strokeLinejoin: "round",
31185
- style: { transition: "fill 0.3s, stroke 0.3s" }
31186
- }
31187
- ),
31188
- /* @__PURE__ */ jsx114(
31189
- "polygon",
31190
- {
31191
- points: shape.points,
31192
- fill: "none",
31193
- stroke: colors.faceBorder,
31194
- strokeWidth: 1.5,
31195
- strokeLinejoin: "round",
31196
- opacity: 0.55,
31197
- transform: "translate(50 50) scale(0.76) translate(-50 -50)"
31198
- }
31199
- ),
31200
- /* @__PURE__ */ jsx114(
31201
- "polygon",
31202
- {
31203
- points: shape.points,
31204
- fill: "#000",
31205
- opacity: 0.14
31206
- }
31207
- )
31208
- ]
31209
- }
31210
- )
31211
- ] });
31383
+ },
31384
+ fi
31385
+ );
31386
+ }) });
31212
31387
  })()
31213
31388
  }
31214
31389
  )
@@ -45663,6 +45838,7 @@ export {
45663
45838
  audioAppTabs,
45664
45839
  audioPlayerVariants,
45665
45840
  breadcrumbsVariants,
45841
+ buildPolyhedron,
45666
45842
  cn,
45667
45843
  commonValidators,
45668
45844
  containerVariants2 as containerVariants,