@digo-labs/ui 0.1.19 → 0.1.20
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/aws/aws-block-group.d.ts +2 -6
- package/dist/aws/aws-block.d.ts +2 -2
- package/dist/index.js +94 -59
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { AwsBlockGroupBehavior, AwsBlockGroupFit, AwsBlockIdentity, AwsBlockPose } from '@digo-labs/common';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
-
import { Transition } from 'motion/react';
|
|
4
|
-
import { AwsBlockTransition } from './aws-block';
|
|
5
3
|
import { ComponentStylesProps } from '../utils/styles';
|
|
6
|
-
export interface AwsBlockGroupTransition extends AwsBlockTransition {
|
|
7
|
-
move: Transition;
|
|
8
|
-
}
|
|
9
4
|
type Properties = RootProperties & ComponentStylesProps<'awsBlockGroup'>;
|
|
10
5
|
export declare function AwsBlockGroup(properties: Properties): import("react").JSX.Element;
|
|
11
6
|
interface RootProperties {
|
|
@@ -15,7 +10,8 @@ interface RootProperties {
|
|
|
15
10
|
pose?: number;
|
|
16
11
|
onPose?: (pose: number) => void;
|
|
17
12
|
fit?: AwsBlockGroupFit;
|
|
18
|
-
|
|
13
|
+
beat?: number;
|
|
14
|
+
hold?: number;
|
|
19
15
|
className?: string;
|
|
20
16
|
style?: CSSProperties;
|
|
21
17
|
}
|
package/dist/aws/aws-block.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AwsGlyphFamily, AwsGlyphStage, AwsPaletteColor } from '@digo-labs/common';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
3
|
import { Transition } from 'motion/react';
|
|
4
4
|
import { ComponentStylesProps } from '../utils/styles';
|
|
@@ -10,7 +10,7 @@ type Properties = RootProperties & ComponentStylesProps<'awsBlock'>;
|
|
|
10
10
|
export declare function AwsBlock(properties: Properties): import("react").JSX.Element;
|
|
11
11
|
interface RootProperties {
|
|
12
12
|
color?: AwsPaletteColor;
|
|
13
|
-
size?:
|
|
13
|
+
size?: number;
|
|
14
14
|
family?: AwsGlyphFamily;
|
|
15
15
|
stage?: AwsGlyphStage;
|
|
16
16
|
onStage?: (stage: AwsGlyphStage) => void;
|
package/dist/index.js
CHANGED
|
@@ -2395,7 +2395,7 @@ var { ComponentStylesProvider: Lr, useComponentStyles: Rr } = q("awsBlock"), zr
|
|
|
2395
2395
|
ease: t.circle
|
|
2396
2396
|
},
|
|
2397
2397
|
resize: {
|
|
2398
|
-
duration: e.
|
|
2398
|
+
duration: e.beat,
|
|
2399
2399
|
ease: t.expo
|
|
2400
2400
|
}
|
|
2401
2401
|
}, Br = { duration: 0 };
|
|
@@ -2471,19 +2471,9 @@ function Ur() {
|
|
|
2471
2471
|
//#endregion
|
|
2472
2472
|
//#region src/aws/aws-block-group.tsx
|
|
2473
2473
|
var { ComponentStylesProvider: Wr, useComponentStyles: Gr } = q("awsBlockGroup"), Kr = {
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
},
|
|
2478
|
-
move: {
|
|
2479
|
-
duration: e.move,
|
|
2480
|
-
ease: t.expo
|
|
2481
|
-
},
|
|
2482
|
-
resize: {
|
|
2483
|
-
duration: e.resize,
|
|
2484
|
-
ease: t.expo
|
|
2485
|
-
}
|
|
2486
|
-
}, qr = { duration: 0 }, Jr = Math.max(e.enter, e.move, e.resize);
|
|
2474
|
+
duration: e.enter,
|
|
2475
|
+
ease: t.circle
|
|
2476
|
+
}, qr = { duration: 0 }, Jr = 4;
|
|
2487
2477
|
function Yr(e) {
|
|
2488
2478
|
let { classNames: t, ...n } = e;
|
|
2489
2479
|
return /* @__PURE__ */ W(Wr, {
|
|
@@ -2491,73 +2481,118 @@ function Yr(e) {
|
|
|
2491
2481
|
children: /* @__PURE__ */ W(Xr, { ...n })
|
|
2492
2482
|
});
|
|
2493
2483
|
}
|
|
2494
|
-
function Xr(
|
|
2495
|
-
let { blocks:
|
|
2496
|
-
|
|
2497
|
-
let
|
|
2484
|
+
function Xr(n) {
|
|
2485
|
+
let { blocks: r, poses: i, behavior: o = "build", pose: s, onPose: c, fit: l = "all", beat: u = e.beat, hold: d = e.hold, className: f, style: p } = n, m = Gr(), h = A(), { ref: g, width: _, height: y } = Ur(), [x, S] = U(0), C = H(c), T = H(0), E = H(0);
|
|
2486
|
+
C.current = c;
|
|
2487
|
+
let D = i.length - 1, O = Math.min(s ?? x, D);
|
|
2488
|
+
O !== E.current && (T.current = E.current, E.current = O);
|
|
2489
|
+
let k = i[O], ee = i[T.current], j = s === void 0 ? i[O >= D ? o === "iterate" ? 0 : O : O + 1] : void 0, M = !l || _ > 0 && y > 0, N = h ? 0 : k.beat ?? u, P = h ? 0 : j?.beat ?? u, F = {
|
|
2490
|
+
duration: N,
|
|
2491
|
+
ease: t.expo
|
|
2492
|
+
}, I = {
|
|
2493
|
+
duration: P,
|
|
2494
|
+
ease: t.expo
|
|
2495
|
+
}, te = h ? qr : Kr;
|
|
2498
2496
|
B(() => {
|
|
2499
|
-
if (
|
|
2500
|
-
let t =
|
|
2501
|
-
return () => clearTimeout(
|
|
2497
|
+
if (s !== void 0 || !M || o === "build" && x >= D) return;
|
|
2498
|
+
let e = x >= D ? 0 : x + 1, t = i[x].hold ?? d, n = h ? 0 : i[e].beat ?? u, r = setTimeout(() => S(e), (t + n) * 1e3);
|
|
2499
|
+
return () => clearTimeout(r);
|
|
2502
2500
|
}, [
|
|
2501
|
+
s,
|
|
2502
|
+
M,
|
|
2503
2503
|
o,
|
|
2504
|
-
O,
|
|
2505
2504
|
i,
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2505
|
+
x,
|
|
2506
|
+
D,
|
|
2507
|
+
u,
|
|
2508
|
+
d,
|
|
2509
|
+
h
|
|
2510
2510
|
]), B(() => {
|
|
2511
|
-
if (!
|
|
2512
|
-
let e = setTimeout(() =>
|
|
2511
|
+
if (!M) return;
|
|
2512
|
+
let e = setTimeout(() => C.current?.(O), N * 1e3);
|
|
2513
2513
|
return () => clearTimeout(e);
|
|
2514
2514
|
}, [
|
|
2515
|
+
M,
|
|
2515
2516
|
O,
|
|
2516
|
-
|
|
2517
|
-
k
|
|
2517
|
+
N
|
|
2518
2518
|
]);
|
|
2519
|
-
let
|
|
2520
|
-
width:
|
|
2521
|
-
height:
|
|
2522
|
-
},
|
|
2523
|
-
function
|
|
2524
|
-
|
|
2525
|
-
x:
|
|
2526
|
-
y:
|
|
2519
|
+
let ne = {
|
|
2520
|
+
width: _,
|
|
2521
|
+
height: y
|
|
2522
|
+
}, re = a.getLayout(i, k, ne, l);
|
|
2523
|
+
function L(e, t) {
|
|
2524
|
+
return {
|
|
2525
|
+
x: t.offset.x + e.x * t.unit,
|
|
2526
|
+
y: t.offset.y + e.y * t.unit
|
|
2527
|
+
};
|
|
2528
|
+
}
|
|
2529
|
+
function ie(e, t, n, r, o) {
|
|
2530
|
+
let s = a.getEntry(i, e.id), c = a.getContact(e, k, t.blocks.map((e) => e.id));
|
|
2531
|
+
if (s === "center" || !c || o > Jr) return null;
|
|
2532
|
+
let l = t.blocks.find((e) => e.id === c.id);
|
|
2533
|
+
if (l) {
|
|
2534
|
+
if (s === "split") return L(l, n);
|
|
2535
|
+
let i = a.projectContact(c, k, t);
|
|
2536
|
+
return i ? {
|
|
2537
|
+
x: n.offset.x + i.x * n.unit - (c.x - e.x) * r,
|
|
2538
|
+
y: n.offset.y + i.y * n.unit - (c.y - e.y) * r
|
|
2539
|
+
} : null;
|
|
2540
|
+
}
|
|
2541
|
+
let u = k.blocks.find((e) => e.id === c.id);
|
|
2542
|
+
if (!u) return null;
|
|
2543
|
+
let d = ie(u, t, n, r, o + 1) ?? L(u, re), f = +(a.getEntry(i, u.id) === "split"), p = a.getContact(u, k, t.blocks.map((e) => e.id)) ?? {
|
|
2544
|
+
id: u.id,
|
|
2545
|
+
x: u.x + u.size / 2,
|
|
2546
|
+
y: u.y + u.size / 2
|
|
2547
|
+
}, m = {
|
|
2548
|
+
x: d.x + (p.x - u.x) * r + (c.x - p.x) * r * f,
|
|
2549
|
+
y: d.y + (p.y - u.y) * r + (c.y - p.y) * r * f
|
|
2527
2550
|
};
|
|
2528
|
-
if (!t || t === E) return n;
|
|
2529
|
-
let i = a.getContact(e, E), o = i ? a.projectContact(i, E, t) : null;
|
|
2530
|
-
if (!i || !o) return n;
|
|
2531
|
-
let s = a.getLayout(r, t, N, c);
|
|
2532
2551
|
return {
|
|
2533
|
-
x:
|
|
2534
|
-
y:
|
|
2552
|
+
x: m.x - (c.x - e.x) * r,
|
|
2553
|
+
y: m.y - (c.y - e.y) * r
|
|
2535
2554
|
};
|
|
2536
2555
|
}
|
|
2556
|
+
function ae(e, t, n) {
|
|
2557
|
+
return !t || t === k ? L(e, re) : ie(e, t, a.getLayout(i, t, ne, l), n, 0) ?? L(e, re);
|
|
2558
|
+
}
|
|
2559
|
+
function R(e) {
|
|
2560
|
+
return a.getEntry(i, e.id) === "split" ? qr : j && !j.blocks.some((t) => t.id === e.id) ? I : k.blocks.length === 1 ? te : F;
|
|
2561
|
+
}
|
|
2562
|
+
function z(e) {
|
|
2563
|
+
if (a.getEntry(i, e.id) !== "contact") return "50% 50%";
|
|
2564
|
+
let t = ee.blocks.map((e) => e.id).concat(j?.blocks.map((e) => e.id) ?? []), n = a.getContact(e, k, t);
|
|
2565
|
+
return n ? `${(n.x - e.x) / e.size * 100}% ${(n.y - e.y) / e.size * 100}%` : "50% 50%";
|
|
2566
|
+
}
|
|
2567
|
+
let oe = j ? a.getLayout(i, j, ne, l) : re;
|
|
2537
2568
|
return /* @__PURE__ */ W("div", {
|
|
2538
|
-
ref:
|
|
2569
|
+
ref: g,
|
|
2539
2570
|
"data-slot": "aws-block-group",
|
|
2540
|
-
className: v(
|
|
2541
|
-
style:
|
|
2571
|
+
className: v(m.root, f),
|
|
2572
|
+
style: p,
|
|
2542
2573
|
children: /* @__PURE__ */ W(Fr, {
|
|
2543
|
-
unit:
|
|
2544
|
-
children: /* @__PURE__ */ W(b, { children:
|
|
2574
|
+
unit: re.unit,
|
|
2575
|
+
children: /* @__PURE__ */ W(b, { children: M && k.blocks.map((e) => /* @__PURE__ */ W(w.div, {
|
|
2545
2576
|
"data-slot": "aws-block-group-block",
|
|
2546
|
-
className:
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2577
|
+
className: m.block,
|
|
2578
|
+
style: { zIndex: a.getEntry(i, e.id) === "split" ? 0 : 1 },
|
|
2579
|
+
initial: { ...ae(e, ee, re.unit) },
|
|
2580
|
+
animate: { ...ae(e, k, re.unit) },
|
|
2581
|
+
exit: {
|
|
2582
|
+
...ae(e, j, oe.unit),
|
|
2583
|
+
transition: I
|
|
2584
|
+
},
|
|
2585
|
+
transition: F,
|
|
2551
2586
|
children: /* @__PURE__ */ W(Vr, {
|
|
2552
|
-
color:
|
|
2553
|
-
family:
|
|
2587
|
+
color: r[e.id].color,
|
|
2588
|
+
family: r[e.id].family,
|
|
2554
2589
|
size: e.size,
|
|
2555
2590
|
stage: e.stage,
|
|
2556
2591
|
transition: {
|
|
2557
|
-
enter:
|
|
2558
|
-
resize:
|
|
2592
|
+
enter: R(e),
|
|
2593
|
+
resize: F
|
|
2559
2594
|
},
|
|
2560
|
-
style: { transformOrigin:
|
|
2595
|
+
style: { transformOrigin: z(e) }
|
|
2561
2596
|
})
|
|
2562
2597
|
}, e.id)) })
|
|
2563
2598
|
})
|