@digilogiclabs/saas-factory-ui 1.16.2 → 1.16.3

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
@@ -30304,44 +30304,53 @@ function simulateDice(arenaW, arenaH, diceSize, starts, numDice) {
30304
30304
  const collisionDist = diceSize * 1.05;
30305
30305
  const bodies = [];
30306
30306
  for (let i = 0; i < numDice; i++) {
30307
- const s = starts[i] ?? { x: arenaW / 2, y: arenaH / 2 };
30307
+ const s = starts[i] ?? { x: arenaW / 2, y: minY };
30308
30308
  bodies.push({
30309
- x: clamp(s.x + (Math.random() - 0.5) * arenaW * 0.25, minX, maxX),
30310
- y: clamp(s.y + (Math.random() - 0.5) * arenaH * 0.25, minY, maxY),
30311
- // Minimum baseline velocity so small arenas still bounce visibly
30312
- // instead of drifting a few pixels. The `|| 1` guard makes sure
30313
- // we never get a near-zero initial velocity from `random - 0.5`.
30314
- vx: (Math.sign(Math.random() - 0.5) || 1) * (0.5 + Math.random() * 0.5) * arenaW * 1.4,
30315
- vy: (Math.sign(Math.random() - 0.5) || 1) * (0.5 + Math.random() * 0.5) * arenaH * 1.6
30309
+ x: clamp(s.x + (Math.random() - 0.5) * arenaW * 0.2, minX, maxX),
30310
+ y: clamp(minY + Math.random() * 8, minY, maxY),
30311
+ vx: (Math.sign(Math.random() - 0.5) || 1) * (0.35 + Math.random() * 0.55) * arenaW * 1.2,
30312
+ // Always downward initially this is the "drop" feel.
30313
+ vy: (0.25 + Math.random() * 0.4) * arenaH * 2.2
30316
30314
  });
30317
30315
  }
30318
- const steps = 32;
30319
- const dt = 2 / steps;
30320
- const friction = 0.9;
30316
+ const steps = 40;
30317
+ const dt = 2.4 / steps;
30318
+ const friction = 0.93;
30321
30319
  const wallRestitution = -0.72;
30322
30320
  const diceRestitution = 0.8;
30321
+ const gravity = arenaH * 0.9;
30323
30322
  const frames = [];
30323
+ const bounceScaleX = new Array(numDice).fill(1);
30324
+ const bounceScaleY = new Array(numDice).fill(1);
30324
30325
  for (let s = 0; s < steps; s++) {
30325
30326
  for (const b of bodies) {
30327
+ b.vy += gravity * dt;
30326
30328
  b.x += b.vx * dt;
30327
30329
  b.y += b.vy * dt;
30328
30330
  }
30329
- for (const b of bodies) {
30331
+ for (let i = 0; i < numDice; i++) {
30332
+ const b = bodies[i];
30330
30333
  if (b.x <= minX) {
30331
30334
  b.x = minX;
30332
30335
  b.vx *= wallRestitution;
30333
- }
30334
- if (b.x >= maxX) {
30336
+ bounceScaleX[i] = 0.78;
30337
+ bounceScaleY[i] = 1.14;
30338
+ } else if (b.x >= maxX) {
30335
30339
  b.x = maxX;
30336
30340
  b.vx *= wallRestitution;
30341
+ bounceScaleX[i] = 0.78;
30342
+ bounceScaleY[i] = 1.14;
30337
30343
  }
30338
30344
  if (b.y <= minY) {
30339
30345
  b.y = minY;
30340
30346
  b.vy *= wallRestitution;
30341
- }
30342
- if (b.y >= maxY) {
30347
+ bounceScaleY[i] = 0.78;
30348
+ bounceScaleX[i] = 1.14;
30349
+ } else if (b.y >= maxY) {
30343
30350
  b.y = maxY;
30344
30351
  b.vy *= wallRestitution;
30352
+ bounceScaleY[i] = 0.78;
30353
+ bounceScaleX[i] = 1.14;
30345
30354
  }
30346
30355
  }
30347
30356
  for (let i = 0; i < numDice; i++) {
@@ -30367,6 +30376,10 @@ function simulateDice(arenaW, arenaH, diceSize, starts, numDice) {
30367
30376
  a.vy += impulse * ny;
30368
30377
  b.vx -= impulse * nx;
30369
30378
  b.vy -= impulse * ny;
30379
+ bounceScaleX[i] = 0.88;
30380
+ bounceScaleY[i] = 1.08;
30381
+ bounceScaleX[j] = 0.88;
30382
+ bounceScaleY[j] = 1.08;
30370
30383
  }
30371
30384
  }
30372
30385
  }
@@ -30379,7 +30392,18 @@ function simulateDice(arenaW, arenaH, diceSize, starts, numDice) {
30379
30392
  b.x = clamp(b.x, minX, maxX);
30380
30393
  b.y = clamp(b.y, minY, maxY);
30381
30394
  }
30382
- frames.push(bodies.map((b) => ({ x: b.x, y: b.y })));
30395
+ for (let i = 0; i < numDice; i++) {
30396
+ bounceScaleX[i] += (1 - bounceScaleX[i]) * 0.35;
30397
+ bounceScaleY[i] += (1 - bounceScaleY[i]) * 0.35;
30398
+ }
30399
+ frames.push(
30400
+ bodies.map((b, i) => ({
30401
+ x: b.x,
30402
+ y: b.y,
30403
+ sx: bounceScaleX[i],
30404
+ sy: bounceScaleY[i]
30405
+ }))
30406
+ );
30383
30407
  }
30384
30408
  return frames;
30385
30409
  }
@@ -30505,6 +30529,33 @@ function DiceRoller({
30505
30529
  const shadowRefs = (0, import_react66.useRef)([]);
30506
30530
  const currentPositionsRef = (0, import_react66.useRef)(null);
30507
30531
  const rollingRef = (0, import_react66.useRef)(false);
30532
+ const dieSetters = (0, import_react66.useRef)([]);
30533
+ const cubeSetters = (0, import_react66.useRef)([]);
30534
+ const shadowSetters = (0, import_react66.useRef)([]);
30535
+ const getDieSetter = (i) => {
30536
+ if (!dieSetters.current[i]) {
30537
+ dieSetters.current[i] = (el) => {
30538
+ dieWrapperRefs.current[i] = el;
30539
+ };
30540
+ }
30541
+ return dieSetters.current[i];
30542
+ };
30543
+ const getCubeSetter = (i) => {
30544
+ if (!cubeSetters.current[i]) {
30545
+ cubeSetters.current[i] = (el) => {
30546
+ cubeRefs.current[i] = el;
30547
+ };
30548
+ }
30549
+ return cubeSetters.current[i];
30550
+ };
30551
+ const getShadowSetter = (i) => {
30552
+ if (!shadowSetters.current[i]) {
30553
+ shadowSetters.current[i] = (el) => {
30554
+ shadowRefs.current[i] = el;
30555
+ };
30556
+ }
30557
+ return shadowSetters.current[i];
30558
+ };
30508
30559
  const timersRef = (0, import_react66.useRef)([]);
30509
30560
  const rafHandleRef = (0, import_react66.useRef)(null);
30510
30561
  const arenaRef = (0, import_react66.useRef)(null);
@@ -30576,10 +30627,10 @@ function DiceRoller({
30576
30627
  []
30577
30628
  );
30578
30629
  const writeDiePosition = (0, import_react66.useCallback)(
30579
- (i, x, y) => {
30630
+ (i, x, y, sx = 1, sy = 1) => {
30580
30631
  const el = dieWrapperRefs.current[i];
30581
30632
  if (!el) return;
30582
- el.style.transform = `translate3d(${x - half}px, ${y - half}px, 0)`;
30633
+ el.style.transform = `translate3d(${x - half}px, ${y - half}px, 0) scale3d(${sx}, ${sy}, 1)`;
30583
30634
  },
30584
30635
  [half]
30585
30636
  );
@@ -30603,7 +30654,7 @@ function DiceRoller({
30603
30654
  const el = dieWrapperRefs.current[i];
30604
30655
  if (el) {
30605
30656
  el.style.transition = "transform 0.35s cubic-bezier(0.25,0.46,0.45,0.94)";
30606
- el.style.transform = `translate3d(${pos.x - half}px, ${pos.y - half}px, 0)`;
30657
+ el.style.transform = `translate3d(${pos.x - half}px, ${pos.y - half}px, 0) scale3d(1, 1, 1)`;
30607
30658
  }
30608
30659
  const cube = cubeRefs.current[i];
30609
30660
  if (cube) {
@@ -30645,7 +30696,7 @@ function DiceRoller({
30645
30696
  const el = dieWrapperRefs.current[i];
30646
30697
  if (el) {
30647
30698
  el.style.transition = "transform 0.2s ease-out";
30648
- el.style.transform = `translate3d(${p.x - half}px, ${p.y - half}px, 0)`;
30699
+ el.style.transform = `translate3d(${p.x - half}px, ${p.y - half}px, 0) scale3d(1, 1, 1)`;
30649
30700
  }
30650
30701
  const tgt = SHOW_ROT[vals[i]];
30651
30702
  writeCubeRotation(i, tgt.x, tgt.y, 0, true);
@@ -30690,9 +30741,12 @@ function DiceRoller({
30690
30741
  if (frame) {
30691
30742
  for (let i = 0; i < clampedCount; i++) {
30692
30743
  const p = frame[i];
30693
- if (p) writeDiePosition(i, p.x, p.y);
30744
+ if (p) writeDiePosition(i, p.x, p.y, p.sx, p.sy);
30694
30745
  }
30695
- currentPositionsRef.current = frame.slice(0, clampedCount);
30746
+ currentPositionsRef.current = frame.slice(0, clampedCount).map((f) => ({
30747
+ x: f.x,
30748
+ y: f.y
30749
+ }));
30696
30750
  }
30697
30751
  if (progress < 1) {
30698
30752
  rafHandleRef.current = requestAnimationFrame(tick);
@@ -30794,9 +30848,7 @@ function DiceRoller({
30794
30848
  return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
30795
30849
  "div",
30796
30850
  {
30797
- ref: (el) => {
30798
- dieWrapperRefs.current[d] = el;
30799
- },
30851
+ ref: getDieSetter(d),
30800
30852
  style: {
30801
30853
  position: "absolute",
30802
30854
  left: 0,
@@ -30815,9 +30867,7 @@ function DiceRoller({
30815
30867
  /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
30816
30868
  "div",
30817
30869
  {
30818
- ref: (el) => {
30819
- shadowRefs.current[d] = el;
30820
- },
30870
+ ref: getShadowSetter(d),
30821
30871
  style: {
30822
30872
  position: "absolute",
30823
30873
  bottom: -6,
@@ -30835,9 +30885,7 @@ function DiceRoller({
30835
30885
  /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
30836
30886
  "div",
30837
30887
  {
30838
- ref: (el) => {
30839
- cubeRefs.current[d] = el;
30840
- },
30888
+ ref: getCubeSetter(d),
30841
30889
  style: {
30842
30890
  width: "100%",
30843
30891
  height: "100%",