@livo-tv/blocks 1.2.0 → 1.3.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.d.cts CHANGED
@@ -466,12 +466,14 @@ type CurtainPreviewProps = {
466
466
  * static first frame so a large grid does not play every loop at once.
467
467
  */
468
468
  playWhenVisible?: boolean;
469
+ /** Force a static first frame even when the tile is visible. */
470
+ frozen?: boolean;
469
471
  };
470
472
  /**
471
473
  * Thumbnail for a curtain asset: still image, or a muted looping video
472
474
  * that plays only while visible (unless reduced motion is on).
473
475
  */
474
- declare function CurtainPreview({ kind, url, alt, className, playWhenVisible, }: CurtainPreviewProps): React.JSX.Element;
476
+ declare function CurtainPreview({ kind, url, alt, className, playWhenVisible, frozen, }: CurtainPreviewProps): React.JSX.Element;
475
477
 
476
478
  type CurtainPickerOwnerType = "organization" | "platform" | string;
477
479
  type CurtainPickerItem = {
@@ -508,7 +510,7 @@ type CurtainPickerProps = {
508
510
  onChange?: (id: string | null) => void;
509
511
  allowNone?: boolean;
510
512
  disabled?: boolean;
511
- /** `compact` is for dialogs (tighter grid). */
513
+ /** `compact` is a selected preview plus a dense thumbnail grid. */
512
514
  variant?: "default" | "compact";
513
515
  /** Split the grid into organization / platform / other sections. */
514
516
  groupByOwner?: boolean;
package/dist/index.d.ts CHANGED
@@ -466,12 +466,14 @@ type CurtainPreviewProps = {
466
466
  * static first frame so a large grid does not play every loop at once.
467
467
  */
468
468
  playWhenVisible?: boolean;
469
+ /** Force a static first frame even when the tile is visible. */
470
+ frozen?: boolean;
469
471
  };
470
472
  /**
471
473
  * Thumbnail for a curtain asset: still image, or a muted looping video
472
474
  * that plays only while visible (unless reduced motion is on).
473
475
  */
474
- declare function CurtainPreview({ kind, url, alt, className, playWhenVisible, }: CurtainPreviewProps): React.JSX.Element;
476
+ declare function CurtainPreview({ kind, url, alt, className, playWhenVisible, frozen, }: CurtainPreviewProps): React.JSX.Element;
475
477
 
476
478
  type CurtainPickerOwnerType = "organization" | "platform" | string;
477
479
  type CurtainPickerItem = {
@@ -508,7 +510,7 @@ type CurtainPickerProps = {
508
510
  onChange?: (id: string | null) => void;
509
511
  allowNone?: boolean;
510
512
  disabled?: boolean;
511
- /** `compact` is for dialogs (tighter grid). */
513
+ /** `compact` is a selected preview plus a dense thumbnail grid. */
512
514
  variant?: "default" | "compact";
513
515
  /** Split the grid into organization / platform / other sections. */
514
516
  groupByOwner?: boolean;
package/dist/index.js CHANGED
@@ -2328,13 +2328,14 @@ function CurtainPreview({
2328
2328
  url,
2329
2329
  alt = "",
2330
2330
  className,
2331
- playWhenVisible = true
2331
+ playWhenVisible = true,
2332
+ frozen = false
2332
2333
  }) {
2333
2334
  const prefersReduced = useMediaQuery2("(prefers-reduced-motion: reduce)");
2334
2335
  const video = isVideoKind(kind);
2335
- const observe = playWhenVisible && video && !prefersReduced;
2336
+ const observe = !frozen && playWhenVisible && video && !prefersReduced;
2336
2337
  const [setNode, inView] = useElementInView(observe);
2337
- const shouldPlay = video && !prefersReduced && (!playWhenVisible || inView);
2338
+ const shouldPlay = !frozen && video && !prefersReduced && (!playWhenVisible || inView);
2338
2339
  if (!url) {
2339
2340
  return /* @__PURE__ */ jsx(
2340
2341
  "div",
@@ -2416,13 +2417,43 @@ function groupHeading(group, copy) {
2416
2417
  return headings[group];
2417
2418
  }
2418
2419
  function gridClass(variant) {
2419
- return variant === "compact" ? "grid gap-3 sm:grid-cols-2" : "grid gap-4 sm:grid-cols-2 lg:grid-cols-3";
2420
+ return variant === "compact" ? "grid grid-cols-3 gap-2 sm:grid-cols-4 lg:grid-cols-6" : "grid gap-4 sm:grid-cols-2 lg:grid-cols-3";
2421
+ }
2422
+ function selectionRing(selectable) {
2423
+ return selectable && "has-[:checked]:ring-ring has-[:checked]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2";
2424
+ }
2425
+ function resolvePreviewItem(selectedId, ready, allowNone) {
2426
+ if (selectedId) {
2427
+ return ready.find((curtain) => curtain.id === selectedId) ?? ready[0] ?? null;
2428
+ }
2429
+ if (allowNone) return null;
2430
+ return ready[0] ?? null;
2431
+ }
2432
+ function itemActions(item, onMakeDefault, onDelete, canMakeDefault, canDelete) {
2433
+ if (!item) return {};
2434
+ return {
2435
+ onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
2436
+ onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
2437
+ };
2420
2438
  }
2421
2439
  function CurtainPickerSkeleton({
2422
2440
  count = 6,
2423
2441
  variant = "default",
2424
2442
  className
2425
2443
  }) {
2444
+ if (variant === "compact") {
2445
+ return /* @__PURE__ */ jsxs("div", { className: cn("space-y-4", className), "aria-hidden": "true", children: [
2446
+ /* @__PURE__ */ jsxs("div", { className: "max-w-sm space-y-3", children: [
2447
+ /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
2448
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
2449
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-1/2 rounded bg-skeleton" })
2450
+ ] }),
2451
+ /* @__PURE__ */ jsx("ul", { className: gridClass("compact"), children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxs("li", { className: "space-y-1.5 rounded-lg border p-1.5", children: [
2452
+ /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
2453
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-3/4 rounded bg-skeleton" })
2454
+ ] }, index)) })
2455
+ ] });
2456
+ }
2426
2457
  return /* @__PURE__ */ jsx("ul", { className: cn(gridClass(variant), className), "aria-hidden": "true", children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxs("li", { className: "space-y-3 rounded-xl border p-4", children: [
2427
2458
  /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
2428
2459
  /* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
@@ -2449,9 +2480,20 @@ function CurtainPicker({
2449
2480
  const copy = { ...DEFAULT_CURTAIN_PICKER_LABELS, ...labels };
2450
2481
  const groupName = React7.useId();
2451
2482
  const selectable = typeof onChange === "function";
2483
+ const compact = variant === "compact";
2452
2484
  const selectedId = value === "" ? null : value ?? null;
2453
2485
  const ready = curtains.filter((curtain) => curtain.publicUrl);
2454
2486
  const showEmpty = ready.length === 0 && !allowNone;
2487
+ const previewItem = resolvePreviewItem(selectedId, ready, allowNone);
2488
+ const selectedItem = selectedId ? ready.find((curtain) => curtain.id === selectedId) ?? null : null;
2489
+ const actionTarget = selectedItem ?? (!selectable ? previewItem : null);
2490
+ const compactActions = compact ? itemActions(
2491
+ actionTarget,
2492
+ onMakeDefault,
2493
+ onDelete,
2494
+ canMakeDefault,
2495
+ canDelete
2496
+ ) : {};
2455
2497
  const grouped = React7.useMemo(() => {
2456
2498
  if (!groupByOwner) {
2457
2499
  return [{ group: null, items: ready }];
@@ -2479,46 +2521,174 @@ function CurtainPicker({
2479
2521
  checked: selectedId === null,
2480
2522
  disabled,
2481
2523
  copy,
2524
+ compact,
2482
2525
  onSelect: () => onChange(null)
2483
2526
  }
2484
2527
  ) : null;
2485
- if (grouped.length === 0 && noneTile) {
2486
- return /* @__PURE__ */ jsx("ul", { className: cn(gridClass(variant), className), children: /* @__PURE__ */ jsx("li", { children: noneTile }) });
2487
- }
2488
- return /* @__PURE__ */ jsx("div", { className: cn("space-y-6", className), children: grouped.map((section, index) => /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
2489
- section.group ? /* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-sm font-medium", children: groupHeading(section.group, copy) }) : null,
2490
- /* @__PURE__ */ jsxs("ul", { className: gridClass(variant), children: [
2491
- index === 0 && noneTile ? /* @__PURE__ */ jsx("li", { children: noneTile }) : null,
2492
- section.items.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
2493
- CurtainPickerCard,
2528
+ const sections = grouped.length === 0 && noneTile ? [{ group: null, items: [] }] : grouped;
2529
+ return /* @__PURE__ */ jsxs("div", { className: cn(compact ? "space-y-4" : "space-y-6", className), children: [
2530
+ compact ? /* @__PURE__ */ jsx(
2531
+ SelectedPreview,
2532
+ {
2533
+ item: previewItem,
2534
+ copy,
2535
+ disabled,
2536
+ actionsPending,
2537
+ onMakeDefault: compactActions.onMakeDefault,
2538
+ onDelete: compactActions.onDelete
2539
+ }
2540
+ ) : null,
2541
+ sections.map((section, index) => /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
2542
+ section.group ? /* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-sm font-medium", children: groupHeading(section.group, copy) }) : null,
2543
+ /* @__PURE__ */ jsxs("ul", { className: gridClass(variant), children: [
2544
+ index === 0 && noneTile ? /* @__PURE__ */ jsx("li", { children: noneTile }) : null,
2545
+ section.items.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
2546
+ CurtainPickerCard,
2547
+ {
2548
+ item,
2549
+ name: groupName,
2550
+ selectable,
2551
+ checked: selectedId === item.id,
2552
+ disabled,
2553
+ actionsPending,
2554
+ copy,
2555
+ compact,
2556
+ onSelect: onChange ? () => onChange(item.id) : void 0,
2557
+ onMakeDefault: compact ? void 0 : itemActions(
2558
+ item,
2559
+ onMakeDefault,
2560
+ onDelete,
2561
+ canMakeDefault,
2562
+ canDelete
2563
+ ).onMakeDefault,
2564
+ onDelete: compact ? void 0 : itemActions(
2565
+ item,
2566
+ onMakeDefault,
2567
+ onDelete,
2568
+ canMakeDefault,
2569
+ canDelete
2570
+ ).onDelete
2571
+ }
2572
+ ) }, item.id))
2573
+ ] })
2574
+ ] }, section.group ?? "all"))
2575
+ ] });
2576
+ }
2577
+ function SelectedPreview({
2578
+ item,
2579
+ copy,
2580
+ disabled,
2581
+ actionsPending,
2582
+ onMakeDefault,
2583
+ onDelete
2584
+ }) {
2585
+ const owner = item ? ownerLabel(item.ownerType, copy) : null;
2586
+ return /* @__PURE__ */ jsxs("div", { className: "max-w-sm space-y-3", children: [
2587
+ item ? /* @__PURE__ */ jsxs(Fragment, { children: [
2588
+ /* @__PURE__ */ jsx(
2589
+ CurtainPreview,
2494
2590
  {
2495
- item,
2496
- name: groupName,
2497
- selectable,
2498
- checked: selectedId === item.id,
2499
- disabled,
2500
- actionsPending,
2501
- copy,
2502
- onSelect: onChange ? () => onChange(item.id) : void 0,
2503
- onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
2504
- onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
2591
+ kind: item.kind,
2592
+ url: item.publicUrl,
2593
+ alt: "",
2594
+ className: "pointer-events-none"
2505
2595
  }
2506
- ) }, item.id))
2507
- ] })
2508
- ] }, section.group ?? "all")) });
2596
+ ),
2597
+ /* @__PURE__ */ jsx(
2598
+ ItemMeta,
2599
+ {
2600
+ title: item.title,
2601
+ detail: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 "),
2602
+ isDefault: item.isDefault,
2603
+ defaultBadge: copy.defaultBadge
2604
+ }
2605
+ )
2606
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2607
+ /* @__PURE__ */ jsx(
2608
+ "div",
2609
+ {
2610
+ className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950",
2611
+ "aria-hidden": "true"
2612
+ }
2613
+ ),
2614
+ /* @__PURE__ */ jsxs("div", { children: [
2615
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: copy.none }),
2616
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
2617
+ ] })
2618
+ ] }),
2619
+ /* @__PURE__ */ jsx(
2620
+ ManageActions,
2621
+ {
2622
+ disabled,
2623
+ actionsPending,
2624
+ copy,
2625
+ onMakeDefault,
2626
+ onDelete
2627
+ }
2628
+ )
2629
+ ] });
2630
+ }
2631
+ function ItemMeta({
2632
+ title,
2633
+ detail,
2634
+ isDefault,
2635
+ defaultBadge
2636
+ }) {
2637
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
2638
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
2639
+ /* @__PURE__ */ jsx("p", { className: "truncate font-medium", children: title }),
2640
+ detail ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: detail }) : null
2641
+ ] }),
2642
+ isDefault ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground shrink-0 text-xs", children: defaultBadge }) : null
2643
+ ] });
2644
+ }
2645
+ function ManageActions({
2646
+ disabled,
2647
+ actionsPending,
2648
+ copy,
2649
+ onMakeDefault,
2650
+ onDelete
2651
+ }) {
2652
+ if (!onMakeDefault && !onDelete) return null;
2653
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
2654
+ onMakeDefault ? /* @__PURE__ */ jsx(
2655
+ Button,
2656
+ {
2657
+ type: "button",
2658
+ size: "sm",
2659
+ variant: "secondary",
2660
+ disabled: disabled || actionsPending,
2661
+ onClick: onMakeDefault,
2662
+ children: copy.makeDefault
2663
+ }
2664
+ ) : null,
2665
+ onDelete ? /* @__PURE__ */ jsx(
2666
+ Button,
2667
+ {
2668
+ type: "button",
2669
+ size: "sm",
2670
+ variant: "destructive",
2671
+ disabled: disabled || actionsPending,
2672
+ onClick: onDelete,
2673
+ children: copy.delete
2674
+ }
2675
+ ) : null
2676
+ ] });
2509
2677
  }
2510
2678
  function NoneTile({
2511
2679
  name,
2512
2680
  checked,
2513
2681
  disabled,
2514
2682
  copy,
2683
+ compact,
2515
2684
  onSelect
2516
2685
  }) {
2517
2686
  return /* @__PURE__ */ jsxs(
2518
2687
  "label",
2519
2688
  {
2520
2689
  className: cn(
2521
- "block cursor-pointer space-y-3 rounded-xl border p-4 transition-shadow",
2690
+ "block cursor-pointer transition-shadow",
2691
+ compact ? "flex min-h-11 flex-col gap-1.5 rounded-lg border p-1.5" : "space-y-3 rounded-xl border p-4",
2522
2692
  "has-[:checked]:ring-ring has-[:checked]:ring-2",
2523
2693
  "has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
2524
2694
  disabled && "pointer-events-none opacity-50"
@@ -2537,7 +2707,7 @@ function NoneTile({
2537
2707
  }
2538
2708
  ),
2539
2709
  /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950" }),
2540
- /* @__PURE__ */ jsxs("div", { children: [
2710
+ compact ? /* @__PURE__ */ jsx("p", { className: "truncate text-xs font-medium", children: copy.none }) : /* @__PURE__ */ jsxs("div", { children: [
2541
2711
  /* @__PURE__ */ jsx("p", { className: "font-medium", children: copy.none }),
2542
2712
  /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
2543
2713
  ] })
@@ -2553,25 +2723,36 @@ function CurtainPickerCard({
2553
2723
  disabled,
2554
2724
  actionsPending,
2555
2725
  copy,
2726
+ compact,
2556
2727
  onSelect,
2557
2728
  onMakeDefault,
2558
2729
  onDelete
2559
2730
  }) {
2560
2731
  const owner = ownerLabel(item.ownerType, copy);
2561
- const media = /* @__PURE__ */ jsx(CurtainPreview, { kind: item.kind, url: item.publicUrl, alt: item.title });
2562
- const meta = /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
2563
- /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
2564
- /* @__PURE__ */ jsx("p", { className: "truncate font-medium", children: item.title }),
2565
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 ") })
2566
- ] }),
2567
- item.isDefault ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground shrink-0 text-xs", children: copy.defaultBadge }) : null
2568
- ] });
2732
+ const media = /* @__PURE__ */ jsx(
2733
+ CurtainPreview,
2734
+ {
2735
+ kind: item.kind,
2736
+ url: item.publicUrl,
2737
+ alt: item.title,
2738
+ frozen: compact
2739
+ }
2740
+ );
2741
+ const meta = compact ? /* @__PURE__ */ jsx("p", { className: "truncate text-xs font-medium", children: item.title }) : /* @__PURE__ */ jsx(
2742
+ ItemMeta,
2743
+ {
2744
+ title: item.title,
2745
+ detail: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 "),
2746
+ isDefault: item.isDefault,
2747
+ defaultBadge: copy.defaultBadge
2748
+ }
2749
+ );
2569
2750
  return /* @__PURE__ */ jsxs(
2570
2751
  "div",
2571
2752
  {
2572
2753
  className: cn(
2573
- "space-y-3 rounded-xl border p-4",
2574
- selectable && "has-[:checked]:ring-ring has-[:checked]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
2754
+ compact ? "rounded-lg border p-1.5" : "space-y-3 rounded-xl border p-4",
2755
+ selectionRing(selectable),
2575
2756
  disabled && "opacity-50"
2576
2757
  ),
2577
2758
  children: [
@@ -2579,7 +2760,7 @@ function CurtainPickerCard({
2579
2760
  "label",
2580
2761
  {
2581
2762
  className: cn(
2582
- "block space-y-3",
2763
+ compact ? "flex min-h-11 flex-col gap-1.5" : "block space-y-3",
2583
2764
  disabled ? "pointer-events-none" : "cursor-pointer"
2584
2765
  ),
2585
2766
  children: [
@@ -2599,34 +2780,20 @@ function CurtainPickerCard({
2599
2780
  meta
2600
2781
  ]
2601
2782
  }
2602
- ) : /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
2783
+ ) : /* @__PURE__ */ jsxs("div", { className: compact ? "space-y-1.5" : "space-y-3", children: [
2603
2784
  media,
2604
2785
  meta
2605
2786
  ] }),
2606
- onMakeDefault || onDelete ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
2607
- onMakeDefault ? /* @__PURE__ */ jsx(
2608
- Button,
2609
- {
2610
- type: "button",
2611
- size: "sm",
2612
- variant: "secondary",
2613
- disabled: disabled || actionsPending,
2614
- onClick: onMakeDefault,
2615
- children: copy.makeDefault
2616
- }
2617
- ) : null,
2618
- onDelete ? /* @__PURE__ */ jsx(
2619
- Button,
2620
- {
2621
- type: "button",
2622
- size: "sm",
2623
- variant: "destructive",
2624
- disabled: disabled || actionsPending,
2625
- onClick: onDelete,
2626
- children: copy.delete
2627
- }
2628
- ) : null
2629
- ] }) : null
2787
+ compact ? null : /* @__PURE__ */ jsx(
2788
+ ManageActions,
2789
+ {
2790
+ disabled,
2791
+ actionsPending,
2792
+ copy,
2793
+ onMakeDefault,
2794
+ onDelete
2795
+ }
2796
+ )
2630
2797
  ]
2631
2798
  }
2632
2799
  );