@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.
@@ -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
- transition?: Partial<AwsBlockGroupTransition>;
13
+ beat?: number;
14
+ hold?: number;
19
15
  className?: string;
20
16
  style?: CSSProperties;
21
17
  }
@@ -1,4 +1,4 @@
1
- import { AwsBlockSize, AwsGlyphFamily, AwsGlyphStage, AwsPaletteColor } from '@digo-labs/common';
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?: AwsBlockSize;
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.resize,
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
- enter: {
2475
- duration: e.enter,
2476
- ease: t.circle
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(t) {
2495
- let { blocks: n, poses: r, behavior: i = "build", pose: o, onPose: s, fit: c = "all", transition: l, className: u, style: d } = t, f = Gr(), p = A(), { ref: m, width: h, height: g } = Ur(), [_, y] = U(0), x = H(s);
2496
- x.current = s;
2497
- let S = r.length - 1, C = Math.min(o ?? _, S), T = r[Math.max(C - 1, 0)], E = r[C], D = o === void 0 ? r[C >= S ? i === "iterate" ? 0 : C : C + 1] : void 0, O = !c || h > 0 && g > 0, k = p ? 0 : Jr, ee = p ? qr : l?.enter ?? Kr.enter, j = p ? qr : l?.move ?? Kr.move, M = p ? qr : l?.resize ?? Kr.resize;
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 (o !== void 0 || !O || i === "build" && _ >= S) return;
2500
- let t = r[_].hold ?? e.hold, n = setTimeout(() => y(_ >= S ? 0 : _ + 1), (k + t) * 1e3);
2501
- return () => clearTimeout(n);
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
- r,
2507
- _,
2508
- S,
2509
- k
2505
+ x,
2506
+ D,
2507
+ u,
2508
+ d,
2509
+ h
2510
2510
  ]), B(() => {
2511
- if (!O) return;
2512
- let e = setTimeout(() => x.current?.(C), k * 1e3);
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
- C,
2517
- k
2517
+ N
2518
2518
  ]);
2519
- let N = {
2520
- width: h,
2521
- height: g
2522
- }, P = a.getLayout(r, E, N, c);
2523
- function F(e, t) {
2524
- let n = {
2525
- x: P.offset.x + e.x * P.unit,
2526
- y: P.offset.y + e.y * P.unit
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: s.offset.x + o.x * s.unit - (i.x - e.x) * P.unit,
2534
- y: s.offset.y + o.y * s.unit - (i.y - e.y) * P.unit
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: m,
2569
+ ref: g,
2539
2570
  "data-slot": "aws-block-group",
2540
- className: v(f.root, u),
2541
- style: d,
2571
+ className: v(m.root, f),
2572
+ style: p,
2542
2573
  children: /* @__PURE__ */ W(Fr, {
2543
- unit: P.unit,
2544
- children: /* @__PURE__ */ W(b, { children: O && E.blocks.map((e) => /* @__PURE__ */ W(w.div, {
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: f.block,
2547
- initial: { ...F(e, T) },
2548
- animate: { ...F(e, E) },
2549
- exit: { ...F(e, D) },
2550
- transition: j,
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: n[e.id].color,
2553
- family: n[e.id].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: ee,
2558
- resize: M
2592
+ enter: R(e),
2593
+ resize: F
2559
2594
  },
2560
- style: { transformOrigin: a.getBlockOrigin(e, E) }
2595
+ style: { transformOrigin: z(e) }
2561
2596
  })
2562
2597
  }, e.id)) })
2563
2598
  })