@digilogiclabs/saas-factory-ui 2.8.2 → 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,99 +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 depth = effectiveSize * 0.18;
31104
- const edgeLayers = 16;
31105
- const cardFaceStyle = {
31106
- position: "absolute",
31107
- inset: 0,
31108
- display: "block",
31109
- overflow: "visible",
31110
- backfaceVisibility: "hidden"
31111
- };
31112
- return /* @__PURE__ */ jsxs86(Fragment30, { children: [
31113
- Array.from({ length: edgeLayers }, (_2, li) => {
31114
- const z = -depth / 2 + depth * (li + 0.5) / edgeLayers;
31115
- return /* @__PURE__ */ jsxs86(
31116
- "svg",
31117
- {
31118
- viewBox: "0 0 100 100",
31119
- width: "100%",
31120
- height: "100%",
31121
- style: {
31122
- position: "absolute",
31123
- inset: 0,
31124
- display: "block",
31125
- overflow: "visible",
31126
- transform: `translateZ(${z}px)`
31127
- },
31128
- "aria-hidden": "true",
31129
- children: [
31130
- /* @__PURE__ */ jsx114(
31131
- "polygon",
31132
- {
31133
- points: shape.points,
31134
- fill: colors.face
31135
- }
31136
- ),
31137
- /* @__PURE__ */ jsx114(
31138
- "polygon",
31139
- {
31140
- points: shape.points,
31141
- fill: "#000",
31142
- opacity: 0.22
31143
- }
31144
- )
31145
- ]
31146
- },
31147
- li
31148
- );
31149
- }),
31150
- /* @__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(
31151
31290
  "svg",
31152
31291
  {
31153
- viewBox: "0 0 100 100",
31154
- width: "100%",
31155
- height: "100%",
31292
+ width: S,
31293
+ height: S,
31294
+ viewBox: `0 0 ${S} ${S}`,
31156
31295
  style: {
31157
- ...cardFaceStyle,
31158
- transform: `translateZ(${depth / 2}px)`
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"
31159
31308
  },
31160
31309
  "aria-hidden": "true",
31161
31310
  children: [
31162
- /* @__PURE__ */ jsx114(
31163
- "polygon",
31311
+ /* @__PURE__ */ jsx114("defs", { children: /* @__PURE__ */ jsxs86(
31312
+ "radialGradient",
31164
31313
  {
31165
- points: shape.points,
31166
- fill: colors.face,
31167
- stroke: colors.faceBorder,
31168
- strokeWidth: 2.5,
31169
- strokeLinejoin: "round",
31170
- 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
+ ]
31171
31344
  }
31172
- ),
31345
+ ) }),
31173
31346
  /* @__PURE__ */ jsx114(
31174
31347
  "polygon",
31175
31348
  {
31176
- points: shape.points,
31177
- fill: "none",
31349
+ points: pts,
31350
+ fill: colors.face,
31178
31351
  stroke: colors.faceBorder,
31179
31352
  strokeWidth: 1.5,
31180
31353
  strokeLinejoin: "round",
31181
- opacity: 0.55,
31182
- transform: "translate(50 50) scale(0.76) translate(-50 -50)"
31354
+ style: {
31355
+ transition: "fill 0.3s, stroke 0.3s"
31356
+ }
31183
31357
  }
31184
31358
  ),
31359
+ /* @__PURE__ */ jsx114("polygon", { points: pts, fill: `url(#${gid})` }),
31185
31360
  /* @__PURE__ */ jsx114(
31186
31361
  "text",
31187
31362
  {
31188
- ref: getNumeralSetter(d),
31189
- x: 50,
31190
- y: shape.textY,
31363
+ ref: fi === 0 ? getNumeralSetter(d) : void 0,
31364
+ x: S / 2,
31365
+ y: S / 2,
31191
31366
  textAnchor: "middle",
31192
31367
  dominantBaseline: "central",
31193
- fontSize: 100 * shape.fontScale,
31368
+ fontSize,
31194
31369
  fontWeight: 800,
31195
31370
  fill: colors.pip,
31196
31371
  style: {
@@ -31198,59 +31373,17 @@ function DiceRoller({
31198
31373
  transition: "fill 0.3s",
31199
31374
  userSelect: "none"
31200
31375
  },
31201
- children: formatDieValue(shown, sides)
31376
+ children: formatDieValue(
31377
+ fi === 0 ? shown : f.value,
31378
+ sides
31379
+ )
31202
31380
  }
31203
31381
  )
31204
31382
  ]
31205
- }
31206
- ),
31207
- /* @__PURE__ */ jsxs86(
31208
- "svg",
31209
- {
31210
- viewBox: "0 0 100 100",
31211
- width: "100%",
31212
- height: "100%",
31213
- style: {
31214
- ...cardFaceStyle,
31215
- transform: `rotateY(180deg) translateZ(${depth / 2}px)`
31216
- },
31217
- "aria-hidden": "true",
31218
- children: [
31219
- /* @__PURE__ */ jsx114(
31220
- "polygon",
31221
- {
31222
- points: shape.points,
31223
- fill: colors.face,
31224
- stroke: colors.faceBorder,
31225
- strokeWidth: 2.5,
31226
- strokeLinejoin: "round",
31227
- style: { transition: "fill 0.3s, stroke 0.3s" }
31228
- }
31229
- ),
31230
- /* @__PURE__ */ jsx114(
31231
- "polygon",
31232
- {
31233
- points: shape.points,
31234
- fill: "none",
31235
- stroke: colors.faceBorder,
31236
- strokeWidth: 1.5,
31237
- strokeLinejoin: "round",
31238
- opacity: 0.55,
31239
- transform: "translate(50 50) scale(0.76) translate(-50 -50)"
31240
- }
31241
- ),
31242
- /* @__PURE__ */ jsx114(
31243
- "polygon",
31244
- {
31245
- points: shape.points,
31246
- fill: "#000",
31247
- opacity: 0.14
31248
- }
31249
- )
31250
- ]
31251
- }
31252
- )
31253
- ] });
31383
+ },
31384
+ fi
31385
+ );
31386
+ }) });
31254
31387
  })()
31255
31388
  }
31256
31389
  )
@@ -45705,6 +45838,7 @@ export {
45705
45838
  audioAppTabs,
45706
45839
  audioPlayerVariants,
45707
45840
  breadcrumbsVariants,
45841
+ buildPolyhedron,
45708
45842
  cn,
45709
45843
  commonValidators,
45710
45844
  containerVariants2 as containerVariants,