@digilogiclabs/saas-factory-ui 1.16.1 → 1.16.2
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 +119 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -67
- package/dist/index.mjs.map +1 -1
- package/dist/web/index.js +119 -63
- package/dist/web/index.js.map +1 -1
- package/dist/web/index.mjs +120 -67
- package/dist/web/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30500,10 +30500,11 @@ function DiceRoller({
|
|
|
30500
30500
|
const [rolling, setRolling] = (0, import_react66.useState)(false);
|
|
30501
30501
|
const [results, setResults] = (0, import_react66.useState)(null);
|
|
30502
30502
|
const [history, setHistory] = (0, import_react66.useState)([]);
|
|
30503
|
-
const
|
|
30504
|
-
|
|
30505
|
-
);
|
|
30506
|
-
const
|
|
30503
|
+
const dieWrapperRefs = (0, import_react66.useRef)([]);
|
|
30504
|
+
const cubeRefs = (0, import_react66.useRef)([]);
|
|
30505
|
+
const shadowRefs = (0, import_react66.useRef)([]);
|
|
30506
|
+
const currentPositionsRef = (0, import_react66.useRef)(null);
|
|
30507
|
+
const rollingRef = (0, import_react66.useRef)(false);
|
|
30507
30508
|
const timersRef = (0, import_react66.useRef)([]);
|
|
30508
30509
|
const rafHandleRef = (0, import_react66.useRef)(null);
|
|
30509
30510
|
const arenaRef = (0, import_react66.useRef)(null);
|
|
@@ -30574,15 +30575,54 @@ function DiceRoller({
|
|
|
30574
30575
|
})),
|
|
30575
30576
|
[]
|
|
30576
30577
|
);
|
|
30578
|
+
const writeDiePosition = (0, import_react66.useCallback)(
|
|
30579
|
+
(i, x, y) => {
|
|
30580
|
+
const el = dieWrapperRefs.current[i];
|
|
30581
|
+
if (!el) return;
|
|
30582
|
+
el.style.transform = `translate3d(${x - half}px, ${y - half}px, 0)`;
|
|
30583
|
+
},
|
|
30584
|
+
[half]
|
|
30585
|
+
);
|
|
30586
|
+
const writeCubeRotation = (0, import_react66.useCallback)(
|
|
30587
|
+
(i, rx, ry, rz, withTransition) => {
|
|
30588
|
+
const el = cubeRefs.current[i];
|
|
30589
|
+
if (!el) return;
|
|
30590
|
+
el.style.transition = withTransition ? "transform 0.95s cubic-bezier(0.12,0.8,0.22,1)" : "none";
|
|
30591
|
+
el.style.transform = `rotateX(${rx}deg) rotateY(${ry}deg) rotateZ(${rz}deg)`;
|
|
30592
|
+
},
|
|
30593
|
+
[]
|
|
30594
|
+
);
|
|
30577
30595
|
(0, import_react66.useEffect)(() => {
|
|
30596
|
+
const w = arenaRef.current?.offsetWidth ?? arena.w;
|
|
30597
|
+
const h = arenaRef.current?.offsetHeight ?? arenaHeight;
|
|
30598
|
+
if (w === 0 || h === 0) return;
|
|
30599
|
+
const initial = defaultPositions(w, h, clampedCount);
|
|
30600
|
+
currentPositionsRef.current = initial;
|
|
30601
|
+
for (let i = 0; i < clampedCount; i++) {
|
|
30602
|
+
const pos = initial[i];
|
|
30603
|
+
const el = dieWrapperRefs.current[i];
|
|
30604
|
+
if (el) {
|
|
30605
|
+
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)`;
|
|
30607
|
+
}
|
|
30608
|
+
const cube = cubeRefs.current[i];
|
|
30609
|
+
if (cube) {
|
|
30610
|
+
cube.style.transition = "none";
|
|
30611
|
+
cube.style.transform = "rotateX(0deg) rotateY(0deg) rotateZ(0deg)";
|
|
30612
|
+
}
|
|
30613
|
+
}
|
|
30578
30614
|
setResults(null);
|
|
30579
|
-
|
|
30580
|
-
|
|
30581
|
-
|
|
30582
|
-
|
|
30583
|
-
|
|
30615
|
+
}, [
|
|
30616
|
+
clampedCount,
|
|
30617
|
+
effectiveSize,
|
|
30618
|
+
arena.w,
|
|
30619
|
+
arenaHeight,
|
|
30620
|
+
defaultPositions,
|
|
30621
|
+
half
|
|
30622
|
+
]);
|
|
30584
30623
|
const roll = (0, import_react66.useCallback)(() => {
|
|
30585
|
-
if (
|
|
30624
|
+
if (rollingRef.current) return;
|
|
30625
|
+
rollingRef.current = true;
|
|
30586
30626
|
setRolling(true);
|
|
30587
30627
|
const vals = Array.from(
|
|
30588
30628
|
{ length: clampedCount },
|
|
@@ -30590,21 +30630,29 @@ function DiceRoller({
|
|
|
30590
30630
|
);
|
|
30591
30631
|
timersRef.current.forEach((t) => clearTimeout(t));
|
|
30592
30632
|
timersRef.current = [];
|
|
30633
|
+
if (rafHandleRef.current != null) {
|
|
30634
|
+
cancelAnimationFrame(rafHandleRef.current);
|
|
30635
|
+
rafHandleRef.current = null;
|
|
30636
|
+
}
|
|
30593
30637
|
const w = arenaRef.current?.offsetWidth ?? 400;
|
|
30594
30638
|
const h = arenaRef.current?.offsetHeight ?? 260;
|
|
30595
|
-
const starts =
|
|
30639
|
+
const starts = currentPositionsRef.current ?? defaultPositions(w, h, clampedCount);
|
|
30596
30640
|
if (reducedMotion) {
|
|
30597
|
-
|
|
30598
|
-
|
|
30599
|
-
|
|
30600
|
-
|
|
30601
|
-
|
|
30602
|
-
|
|
30641
|
+
const final = defaultPositions(w, h, clampedCount);
|
|
30642
|
+
currentPositionsRef.current = final;
|
|
30643
|
+
for (let i = 0; i < clampedCount; i++) {
|
|
30644
|
+
const p = final[i];
|
|
30645
|
+
const el = dieWrapperRefs.current[i];
|
|
30646
|
+
if (el) {
|
|
30647
|
+
el.style.transition = "transform 0.2s ease-out";
|
|
30648
|
+
el.style.transform = `translate3d(${p.x - half}px, ${p.y - half}px, 0)`;
|
|
30603
30649
|
}
|
|
30604
|
-
|
|
30605
|
-
|
|
30650
|
+
const tgt = SHOW_ROT[vals[i]];
|
|
30651
|
+
writeCubeRotation(i, tgt.x, tgt.y, 0, true);
|
|
30652
|
+
}
|
|
30606
30653
|
setResults(vals);
|
|
30607
30654
|
setRolling(false);
|
|
30655
|
+
rollingRef.current = false;
|
|
30608
30656
|
const total2 = vals.reduce((a, b) => a + b, 0);
|
|
30609
30657
|
onRoll?.(vals, total2);
|
|
30610
30658
|
if (showHistory) {
|
|
@@ -30613,24 +30661,24 @@ function DiceRoller({
|
|
|
30613
30661
|
return;
|
|
30614
30662
|
}
|
|
30615
30663
|
const frames = simulateDice(w, h, effectiveSize, starts, clampedCount);
|
|
30616
|
-
|
|
30617
|
-
|
|
30618
|
-
|
|
30619
|
-
|
|
30620
|
-
|
|
30621
|
-
|
|
30622
|
-
|
|
30623
|
-
|
|
30624
|
-
|
|
30625
|
-
|
|
30626
|
-
|
|
30627
|
-
|
|
30664
|
+
for (let i = 0; i < clampedCount; i++) {
|
|
30665
|
+
writeCubeRotation(
|
|
30666
|
+
i,
|
|
30667
|
+
(Math.random() - 0.5) * 720,
|
|
30668
|
+
(Math.random() - 0.5) * 720,
|
|
30669
|
+
(Math.random() - 0.5) * 720,
|
|
30670
|
+
false
|
|
30671
|
+
);
|
|
30672
|
+
const el = dieWrapperRefs.current[i];
|
|
30673
|
+
if (el) el.style.transition = "none";
|
|
30674
|
+
const shadow = shadowRefs.current[i];
|
|
30675
|
+
if (shadow) shadow.style.opacity = "0.2";
|
|
30676
|
+
}
|
|
30677
|
+
if (dieWrapperRefs.current[0]) {
|
|
30678
|
+
dieWrapperRefs.current[0].offsetHeight;
|
|
30679
|
+
}
|
|
30628
30680
|
const playbackMs = TUMBLE_MS;
|
|
30629
30681
|
const startTime = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
30630
|
-
if (rafHandleRef.current != null) {
|
|
30631
|
-
cancelAnimationFrame(rafHandleRef.current);
|
|
30632
|
-
rafHandleRef.current = null;
|
|
30633
|
-
}
|
|
30634
30682
|
const tick = (now) => {
|
|
30635
30683
|
const elapsed = now - startTime;
|
|
30636
30684
|
const progress = Math.max(0, Math.min(1, elapsed / playbackMs));
|
|
@@ -30638,34 +30686,43 @@ function DiceRoller({
|
|
|
30638
30686
|
frames.length - 1,
|
|
30639
30687
|
Math.floor(progress * frames.length)
|
|
30640
30688
|
);
|
|
30641
|
-
|
|
30689
|
+
const frame = frames[idx];
|
|
30690
|
+
if (frame) {
|
|
30691
|
+
for (let i = 0; i < clampedCount; i++) {
|
|
30692
|
+
const p = frame[i];
|
|
30693
|
+
if (p) writeDiePosition(i, p.x, p.y);
|
|
30694
|
+
}
|
|
30695
|
+
currentPositionsRef.current = frame.slice(0, clampedCount);
|
|
30696
|
+
}
|
|
30642
30697
|
if (progress < 1) {
|
|
30643
30698
|
rafHandleRef.current = requestAnimationFrame(tick);
|
|
30644
30699
|
} else {
|
|
30645
30700
|
rafHandleRef.current = null;
|
|
30701
|
+
for (let i = 0; i < clampedCount; i++) {
|
|
30702
|
+
const el = dieWrapperRefs.current[i];
|
|
30703
|
+
if (el)
|
|
30704
|
+
el.style.transition = "transform 0.35s cubic-bezier(0.25,0.46,0.45,0.94)";
|
|
30705
|
+
const shadow = shadowRefs.current[i];
|
|
30706
|
+
if (shadow) shadow.style.opacity = "0.85";
|
|
30707
|
+
}
|
|
30646
30708
|
}
|
|
30647
30709
|
};
|
|
30648
30710
|
rafHandleRef.current = requestAnimationFrame(tick);
|
|
30649
30711
|
requestAnimationFrame(() => {
|
|
30650
30712
|
requestAnimationFrame(() => {
|
|
30651
|
-
|
|
30652
|
-
const
|
|
30653
|
-
|
|
30654
|
-
|
|
30655
|
-
|
|
30656
|
-
|
|
30657
|
-
|
|
30658
|
-
z: (Math.random() > 0.5 ? 1 : -1) * 360,
|
|
30659
|
-
tr: true
|
|
30660
|
-
};
|
|
30661
|
-
}
|
|
30662
|
-
return n;
|
|
30663
|
-
});
|
|
30713
|
+
for (let i = 0; i < clampedCount; i++) {
|
|
30714
|
+
const tgt = SHOW_ROT[vals[i]];
|
|
30715
|
+
const lx = tgt.x + (Math.random() > 0.5 ? 720 : -720);
|
|
30716
|
+
const ly = tgt.y;
|
|
30717
|
+
const lz = (Math.random() > 0.5 ? 1 : -1) * 360;
|
|
30718
|
+
writeCubeRotation(i, lx, ly, lz, true);
|
|
30719
|
+
}
|
|
30664
30720
|
});
|
|
30665
30721
|
});
|
|
30666
30722
|
const settleTimer = setTimeout(() => {
|
|
30667
30723
|
setResults(vals);
|
|
30668
30724
|
setRolling(false);
|
|
30725
|
+
rollingRef.current = false;
|
|
30669
30726
|
const total2 = vals.reduce((a, b) => a + b, 0);
|
|
30670
30727
|
onRoll?.(vals, total2);
|
|
30671
30728
|
if (showHistory) {
|
|
@@ -30674,13 +30731,14 @@ function DiceRoller({
|
|
|
30674
30731
|
}, SETTLE_MS);
|
|
30675
30732
|
timersRef.current.push(settleTimer);
|
|
30676
30733
|
}, [
|
|
30677
|
-
rolling,
|
|
30678
30734
|
clampedCount,
|
|
30679
|
-
positions,
|
|
30680
30735
|
defaultPositions,
|
|
30681
30736
|
effectiveSize,
|
|
30737
|
+
half,
|
|
30682
30738
|
reducedMotion,
|
|
30683
30739
|
onRoll,
|
|
30740
|
+
writeCubeRotation,
|
|
30741
|
+
writeDiePosition,
|
|
30684
30742
|
showHistory,
|
|
30685
30743
|
historyMax
|
|
30686
30744
|
]);
|
|
@@ -30706,7 +30764,6 @@ function DiceRoller({
|
|
|
30706
30764
|
},
|
|
30707
30765
|
[]
|
|
30708
30766
|
);
|
|
30709
|
-
const activePositions = positions ?? defaultPositions(arena.w, arenaHeight, clampedCount);
|
|
30710
30767
|
const total = results ? results.reduce((a, b) => a + b, 0) : null;
|
|
30711
30768
|
return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
|
|
30712
30769
|
"div",
|
|
@@ -30734,27 +30791,22 @@ function DiceRoller({
|
|
|
30734
30791
|
cursor: trigger === "click" ? "pointer" : void 0
|
|
30735
30792
|
},
|
|
30736
30793
|
children: Array.from({ length: clampedCount }, (_, d) => {
|
|
30737
|
-
const rot = rotations[d] ?? { x: 0, y: 0, z: 0, tr: true };
|
|
30738
|
-
const pos = activePositions[d] ?? {
|
|
30739
|
-
x: arena.w / 2,
|
|
30740
|
-
y: arenaHeight / 2
|
|
30741
|
-
};
|
|
30742
|
-
const translate = `translate3d(${pos.x - half}px, ${pos.y - half}px, 0)`;
|
|
30743
30794
|
return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
|
|
30744
30795
|
"div",
|
|
30745
30796
|
{
|
|
30797
|
+
ref: (el) => {
|
|
30798
|
+
dieWrapperRefs.current[d] = el;
|
|
30799
|
+
},
|
|
30746
30800
|
style: {
|
|
30747
30801
|
position: "absolute",
|
|
30748
30802
|
left: 0,
|
|
30749
30803
|
top: 0,
|
|
30750
30804
|
width: effectiveSize,
|
|
30751
30805
|
height: effectiveSize,
|
|
30752
|
-
transform: translate,
|
|
30753
30806
|
// Parent must preserve 3D so the inner cube's rotateX/Y/Z
|
|
30754
30807
|
// still renders with depth — otherwise adding a transform
|
|
30755
30808
|
// to the wrapper would flatten its children into 2D.
|
|
30756
30809
|
transformStyle: "preserve-3d",
|
|
30757
|
-
transition: rolling ? "transform 0.04s linear" : "transform 0.35s cubic-bezier(0.25,0.46,0.45,0.94)",
|
|
30758
30810
|
willChange: "transform",
|
|
30759
30811
|
zIndex: 2,
|
|
30760
30812
|
perspective: 700
|
|
@@ -30763,6 +30815,9 @@ function DiceRoller({
|
|
|
30763
30815
|
/* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
|
|
30764
30816
|
"div",
|
|
30765
30817
|
{
|
|
30818
|
+
ref: (el) => {
|
|
30819
|
+
shadowRefs.current[d] = el;
|
|
30820
|
+
},
|
|
30766
30821
|
style: {
|
|
30767
30822
|
position: "absolute",
|
|
30768
30823
|
bottom: -6,
|
|
@@ -30772,7 +30827,7 @@ function DiceRoller({
|
|
|
30772
30827
|
background: `radial-gradient(ellipse,${colors.shadow} 0%,transparent 70%)`,
|
|
30773
30828
|
borderRadius: "50%",
|
|
30774
30829
|
pointerEvents: "none",
|
|
30775
|
-
opacity:
|
|
30830
|
+
opacity: 0.85,
|
|
30776
30831
|
transition: "opacity 0.3s"
|
|
30777
30832
|
}
|
|
30778
30833
|
}
|
|
@@ -30780,13 +30835,14 @@ function DiceRoller({
|
|
|
30780
30835
|
/* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
|
|
30781
30836
|
"div",
|
|
30782
30837
|
{
|
|
30838
|
+
ref: (el) => {
|
|
30839
|
+
cubeRefs.current[d] = el;
|
|
30840
|
+
},
|
|
30783
30841
|
style: {
|
|
30784
30842
|
width: "100%",
|
|
30785
30843
|
height: "100%",
|
|
30786
30844
|
position: "relative",
|
|
30787
30845
|
transformStyle: "preserve-3d",
|
|
30788
|
-
transition: rot.tr ? "transform 0.95s cubic-bezier(0.12,0.8,0.22,1)" : "none",
|
|
30789
|
-
transform: `rotateX(${rot.x}deg) rotateY(${rot.y}deg) rotateZ(${rot.z}deg)`,
|
|
30790
30846
|
willChange: "transform"
|
|
30791
30847
|
},
|
|
30792
30848
|
children: [1, 2, 3, 4, 5, 6].map((val, fi) => /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
|