@frontile/theme 0.18.5 → 0.18.7

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
@@ -2448,6 +2448,312 @@ const segmentedControl = tv({
2448
2448
  }
2449
2449
  });
2450
2450
 
2451
+ /**
2452
+ * Every state class keys off a `data-*` attribute the Step writes onto its
2453
+ * `<li>` (`data-part="item"`, the `group/item` anchor): `data-state`
2454
+ * (`complete | active | upcoming`), `data-invalid`, `data-loading`,
2455
+ * `data-disabled`. `data-invalid` and friends are written as the strings
2456
+ * "true"/"false", so they are tested with `=true`.
2457
+ *
2458
+ * Class strings are spelled out per color rather than built in a loop:
2459
+ * Tailwind generates nothing from an interpolated class name.
2460
+ */
2461
+ const stepper = tv({
2462
+ slots: {
2463
+ // The named container the responsive label rules (added alongside the
2464
+ // layout work) measure against.
2465
+ base: '@container/stepper flex w-full',
2466
+ list: 'm-0 flex w-full list-none p-0',
2467
+ item: 'group/item relative flex',
2468
+ step: [...focusVisibleRing, 'inline-flex items-center gap-2',
2469
+ // Hit area: at least 44px whatever the circle size, so the visual
2470
+ // size and the touch target are independent.
2471
+ 'min-h-11 min-w-11 justify-center rounded-md', 'cursor-pointer text-start', 'transition-colors duration-200 motion-reduce:transition-none', 'group-data-[disabled=true]/item:cursor-not-allowed', 'group-data-[disabled=true]/item:opacity-disabled'],
2472
+ indicator: ['inline-flex shrink-0 items-center justify-center rounded-full', 'border-2 font-medium tabular-nums', 'transition-colors duration-200 motion-reduce:transition-none',
2473
+ // Upcoming is the resting state; the other states override it.
2474
+ 'border-neutral-mild text-neutral-firm',
2475
+ // Hovering an enabled upcoming step firms its ring, the one hint that
2476
+ // it can be picked. Active and complete steps already carry color, so
2477
+ // the selector is scoped to upcoming, not overridden by them.
2478
+ '[li[data-state=upcoming][data-disabled=false]>button:hover_&]:border-neutral',
2479
+ // Invalid is always danger, whatever `color` is, and outranks the
2480
+ // active and complete treatments. Those are `group-data-[state=...]`
2481
+ // classes of equal specificity emitted later, so only `!` guarantees
2482
+ // the win -- without it a step that is both complete and invalid shows
2483
+ // the accent color.
2484
+ 'group-data-[invalid=true]/item:border-danger!', 'group-data-[invalid=true]/item:bg-danger-subtle!', 'group-data-[invalid=true]/item:text-danger!'],
2485
+ // The check mark inside a complete indicator. It animates only while the
2486
+ // Step has `data-just-completed` -- set for the moment after a step
2487
+ // *becomes* complete -- so steps that load already complete stay still.
2488
+ check: ['shrink-0', 'group-data-[just-completed=true]/item:animate-stepper-check-pop', 'group-data-[just-completed=true]/item:[&_path]:animate-stepper-check-draw',
2489
+ // `1 2`: a dash as long as the path (normalized to 1) and a gap longer
2490
+ // than it, so the undrawn state shows nothing, not even a round cap.
2491
+ 'group-data-[just-completed=true]/item:[&_path]:[stroke-dasharray:1_2]', 'motion-reduce:animate-none motion-reduce:[&_path]:animate-none'],
2492
+ // The track is neutral; an `::after` fill in the step's color grows along
2493
+ // it when the step completes, and shrinks back if the user returns. The
2494
+ // fill's axis and origin come from `orientation`, below.
2495
+ connector: ['relative shrink-0 overflow-hidden bg-neutral-mild', 'after:absolute after:inset-0 after:content-[""]', 'after:transition-transform after:duration-300 after:ease-out', 'motion-reduce:after:transition-none',
2496
+ // The last step has nothing to connect to.
2497
+ 'group-last/item:hidden'],
2498
+ // Collapsed (menu) mode only. The trigger shows the current step and opens
2499
+ // the list, which becomes a floating panel; see `collapsed` below.
2500
+ trigger: [...focusVisibleRing, 'flex min-h-11 w-full cursor-pointer items-center justify-between gap-3',
2501
+ // Same border as a form field: it reads as a control, like a Select.
2502
+ 'rounded-xl border border-neutral-soft bg-surface-input px-3 py-2 text-start', 'hover:bg-surface-overlay-soft', 'transition-colors duration-200 motion-reduce:transition-none', '[&_svg]:transition-transform motion-reduce:[&_svg]:transition-none', '[&[aria-expanded=true]_svg]:rotate-180'],
2503
+ // A zero-size sentinel the root reads to learn which side of the
2504
+ // threshold it is on. The threshold stays in CSS, where the label rules
2505
+ // already read it, so the two can never disagree.
2506
+ probe: 'hidden',
2507
+ // The trigger's two lines of text, and its chevron.
2508
+ triggerLabel: 'flex min-w-0 flex-col gap-1',
2509
+ chevron: 'size-4 shrink-0 text-neutral-firm',
2510
+ // "Step N of M" and the active step's title, in the trigger and in the
2511
+ // standalone summary line. The count is the quiet eyebrow; the title is
2512
+ // what the reader is looking for, so it carries the weight.
2513
+ summaryText: 'block text-neutral-firm',
2514
+ summaryTitle: 'block font-medium text-neutral-strong',
2515
+ // The invalid step's exclamation mark, the loading spinner, and the text
2516
+ // only screen readers get for an invalid step.
2517
+ mark: 'shrink-0',
2518
+ spinner: 'fill-current text-neutral-mild',
2519
+ invalidText: 'sr-only',
2520
+ // Titles use the tight-leading label scale, so the gap is what separates
2521
+ // a title from its description.
2522
+ label: 'flex min-w-0 flex-col gap-1',
2523
+ title: ['font-medium text-neutral-strong', 'group-data-[state=upcoming]/item:text-neutral-firm', 'group-data-[invalid=true]/item:text-danger'],
2524
+ // Body, not caption: the caption scale's 1px tracking suits small
2525
+ // standalone text, but beside a title it reads as a different typeface.
2526
+ description: 'text-neutral-firm',
2527
+ summary: 'flex flex-col gap-1',
2528
+ panel: [...focusVisibleRing, 'outline-none']
2529
+ },
2530
+ variants: {
2531
+ color: {
2532
+ neutral: {
2533
+ indicator: ['group-data-[state=complete]/item:border-neutral-strong group-data-[state=complete]/item:bg-neutral-strong group-data-[state=complete]/item:text-background', 'group-data-[state=active]/item:border-neutral-strong group-data-[state=active]/item:text-neutral-strong group-data-[state=active]/item:bg-neutral-subtle'],
2534
+ connector: 'group-data-[state=complete]/item:after:bg-neutral-strong'
2535
+ },
2536
+ primary: {
2537
+ indicator: ['group-data-[state=complete]/item:border-primary group-data-[state=complete]/item:bg-primary group-data-[state=complete]/item:text-on-primary', 'group-data-[state=active]/item:border-primary group-data-[state=active]/item:text-primary group-data-[state=active]/item:bg-primary-subtle'],
2538
+ connector: 'group-data-[state=complete]/item:after:bg-primary'
2539
+ },
2540
+ secondary: {
2541
+ indicator: ['group-data-[state=complete]/item:border-secondary group-data-[state=complete]/item:bg-secondary group-data-[state=complete]/item:text-on-secondary', 'group-data-[state=active]/item:border-secondary group-data-[state=active]/item:text-secondary group-data-[state=active]/item:bg-secondary-subtle'],
2542
+ connector: 'group-data-[state=complete]/item:after:bg-secondary'
2543
+ },
2544
+ tertiary: {
2545
+ indicator: ['group-data-[state=complete]/item:border-tertiary group-data-[state=complete]/item:bg-tertiary group-data-[state=complete]/item:text-on-tertiary', 'group-data-[state=active]/item:border-tertiary group-data-[state=active]/item:text-tertiary group-data-[state=active]/item:bg-tertiary-subtle'],
2546
+ connector: 'group-data-[state=complete]/item:after:bg-tertiary'
2547
+ },
2548
+ success: {
2549
+ indicator: ['group-data-[state=complete]/item:border-success group-data-[state=complete]/item:bg-success group-data-[state=complete]/item:text-on-success', 'group-data-[state=active]/item:border-success group-data-[state=active]/item:text-success group-data-[state=active]/item:bg-success-subtle'],
2550
+ connector: 'group-data-[state=complete]/item:after:bg-success'
2551
+ },
2552
+ warning: {
2553
+ indicator: ['group-data-[state=complete]/item:border-warning group-data-[state=complete]/item:bg-warning group-data-[state=complete]/item:text-on-warning', 'group-data-[state=active]/item:border-warning group-data-[state=active]/item:text-warning group-data-[state=active]/item:bg-warning-subtle'],
2554
+ connector: 'group-data-[state=complete]/item:after:bg-warning'
2555
+ },
2556
+ danger: {
2557
+ indicator: ['group-data-[state=complete]/item:border-danger group-data-[state=complete]/item:bg-danger group-data-[state=complete]/item:text-on-danger', 'group-data-[state=active]/item:border-danger group-data-[state=active]/item:text-danger group-data-[state=active]/item:bg-danger-subtle'],
2558
+ connector: 'group-data-[state=complete]/item:after:bg-danger'
2559
+ }
2560
+ },
2561
+ // `step` is the padding that brings indicator plus padding to 44px, so the
2562
+ // hit area is 44px whatever the circle size and the circle sits 22px in
2563
+ // from the button's edge in every layout. `item` carries how far a
2564
+ // bottom-label connector sits from the item's center: the circle's radius
2565
+ // plus a 4px gap.
2566
+ //
2567
+ // Type steps down one level per size: the number sits at about half the
2568
+ // circle's height, the title one step above the number, and the
2569
+ // description one step below the title.
2570
+ size: {
2571
+ sm: {
2572
+ step: 'p-2.5',
2573
+ item: '[--stepper-offset:1rem]',
2574
+ // `[&_svg]` outranks an icon's own size class, so the circle, not the
2575
+ // icon, decides the glyph size (about half the circle, 4-6px padding).
2576
+ indicator: 'size-6 text-label-2xs [&_svg]:size-3',
2577
+ title: 'text-label-xs',
2578
+ description: 'text-body-2xs',
2579
+ summaryText: 'text-body-2xs',
2580
+ summaryTitle: 'text-label-xs',
2581
+ panel: 'py-2'
2582
+ },
2583
+ md: {
2584
+ step: 'p-2',
2585
+ item: '[--stepper-offset:1.125rem]',
2586
+ indicator: 'size-7 text-label-xs [&_svg]:size-3.5',
2587
+ title: 'text-label-sm',
2588
+ description: 'text-body-xs',
2589
+ summaryText: 'text-body-xs',
2590
+ summaryTitle: 'text-label-sm',
2591
+ panel: 'py-3'
2592
+ },
2593
+ lg: {
2594
+ step: 'p-1',
2595
+ item: '[--stepper-offset:1.375rem]',
2596
+ indicator: 'size-9 text-label-sm [&_svg]:size-4.5',
2597
+ title: 'text-label-md',
2598
+ description: 'text-body-sm',
2599
+ summaryText: 'text-body-sm',
2600
+ summaryTitle: 'text-label-md',
2601
+ panel: 'py-4'
2602
+ }
2603
+ },
2604
+ orientation: {
2605
+ horizontal: {
2606
+ base: 'flex-col gap-4',
2607
+ list: 'flex-row items-start',
2608
+ item: 'flex-1 items-center last:flex-none',
2609
+ connector: ['mx-1 h-0.5 min-w-4 flex-1',
2610
+ // Grows from the start edge, which is the right in RTL.
2611
+ 'after:origin-left after:scale-x-0 rtl:after:origin-right', 'group-data-[state=complete]/item:after:scale-x-100']
2612
+ },
2613
+ vertical: {
2614
+ base: 'flex-col gap-4',
2615
+ list: 'flex-col',
2616
+ // `pb-4` is the space between steps; the connector spans it.
2617
+ item: 'relative flex-col items-start pb-4 last:pb-0',
2618
+ // Circle at the top, beside the title's first line, so a step with a
2619
+ // description does not push its circle (and its connector) down.
2620
+ step: 'items-start',
2621
+ // Drawn absolutely from this circle to the next one, so it bridges the
2622
+ // step's 44px hit-area padding and any description height alike. The
2623
+ // circle's center is 22px down; `--stepper-offset` is its radius plus
2624
+ // the 4px clearance a horizontal connector also keeps.
2625
+ connector: ['absolute start-[21px] w-0.5', 'top-[calc(22px+var(--stepper-offset))] bottom-[calc(var(--stepper-offset)-22px)]', 'after:origin-top after:scale-y-0', 'group-data-[state=complete]/item:after:scale-y-100']
2626
+ }
2627
+ },
2628
+ // Where the label sits relative to the circle. `end` is beside it;
2629
+ // `bottom` centers it underneath. Vertical orientation ignores this.
2630
+ labelPosition: {
2631
+ end: {},
2632
+ bottom: {}
2633
+ },
2634
+ // What a horizontal Stepper does when it is too narrow for its titles.
2635
+ // `menu` swaps the row for a trigger and a floating list; `summary` hides
2636
+ // the titles and shows a "Step N of M" line; `none` leaves it alone. The
2637
+ // label rules depend on orientation and labelPosition, so they are
2638
+ // compound variants below.
2639
+ collapse: {
2640
+ menu: {},
2641
+ summary: {},
2642
+ none: {}
2643
+ },
2644
+ // True while a `menu` Stepper is actually collapsed. The component sets it
2645
+ // (it measures the root), and passes `orientation: 'vertical'` alongside,
2646
+ // so the list reuses the vertical layout inside the panel.
2647
+ collapsed: {
2648
+ true: {
2649
+ list: ['inset-auto m-0 w-auto min-w-64 max-w-[calc(100vw-1rem)] overflow-auto p-2 text-inherit', 'max-h-[min(24rem,70vh)] rounded-xl border border-neutral-muted bg-surface-input shadow-elevation-3',
2650
+ // `display` on the list would beat the UA rule that hides a closed
2651
+ // popover, so the closed state is restated here.
2652
+ '[&:not(:popover-open)]:hidden'],
2653
+ // Rows sit closer in the menu than in a vertical Stepper: it is a
2654
+ // list to pick from, not a page-level layout.
2655
+ item: 'items-stretch pb-1',
2656
+ step: 'w-full justify-start hover:bg-surface-overlay-soft'
2657
+ }
2658
+ }
2659
+ },
2660
+ compoundVariants: [
2661
+ // -- label below the circle (horizontal only; vertical ignores it) --
2662
+ // Items are equal-width columns, and the connector is drawn from this
2663
+ // item's circle to the next one's, so it needs `relative` on the item and
2664
+ // an offset that clears the circle (radius plus a 4px gap, per size).
2665
+ // Logical properties (`start`/`end`, `ms`) so the layout mirrors in RTL.
2666
+ {
2667
+ orientation: 'horizontal',
2668
+ labelPosition: 'bottom',
2669
+ class: {
2670
+ item: 'relative flex-1 flex-col items-center last:flex-1',
2671
+ step: 'flex-col',
2672
+ label: 'items-center text-center',
2673
+ connector: ['absolute top-[21px] mx-0 min-w-0 flex-none', 'start-[calc(50%+var(--stepper-offset))] end-[calc(-50%+var(--stepper-offset))]']
2674
+ }
2675
+ },
2676
+ // -- vertical: the title's first line is centered on the circle --
2677
+ // Half of (circle height - one title line) of top padding, so a title
2678
+ // lines up with the circle's middle whether or not a description follows.
2679
+ {
2680
+ orientation: 'vertical',
2681
+ size: 'sm',
2682
+ class: {
2683
+ title: 'pt-[calc((1.5rem-1lh)/2)]'
2684
+ }
2685
+ }, {
2686
+ orientation: 'vertical',
2687
+ size: 'md',
2688
+ class: {
2689
+ title: 'pt-[calc((1.75rem-1lh)/2)]'
2690
+ }
2691
+ }, {
2692
+ orientation: 'vertical',
2693
+ size: 'lg',
2694
+ class: {
2695
+ title: 'pt-[calc((2.25rem-1lh)/2)]'
2696
+ }
2697
+ },
2698
+ // -- responsive label collapse (horizontal only) --
2699
+ // Narrow: the label is visually hidden (`sr-only` keeps it in the
2700
+ // accessibility tree) and the summary shows. Wider than the threshold the
2701
+ // label returns and the summary goes.
2702
+ //
2703
+ // The thresholds are Frontile-namespaced container tokens, not `@md` /
2704
+ // `@2xl`: those read `--container-*`, which apps commonly redefine (and
2705
+ // which `max-w-*` shares), so they would move the breakpoints -- possibly
2706
+ // inverting the two modes. `var()` is not allowed in a container query
2707
+ // condition, so a theme token is the only way to make them tunable.
2708
+ {
2709
+ orientation: 'horizontal',
2710
+ collapse: 'summary',
2711
+ labelPosition: 'bottom',
2712
+ class: {
2713
+ label: 'sr-only @fr-stepper-bottom/stepper:not-sr-only',
2714
+ // The bottom-label row is symmetric (equal columns, centered
2715
+ // circles), so the line beneath it is centered too.
2716
+ summary: 'items-center text-center @fr-stepper-bottom/stepper:hidden',
2717
+ // With the title hidden the step is just its circle, so the focus
2718
+ // ring follows the circle instead of boxing it.
2719
+ step: '@max-fr-stepper-bottom/stepper:rounded-full'
2720
+ }
2721
+ }, {
2722
+ orientation: 'horizontal',
2723
+ collapse: 'summary',
2724
+ labelPosition: 'end',
2725
+ class: {
2726
+ label: 'sr-only @fr-stepper-end/stepper:not-sr-only',
2727
+ summary: '@fr-stepper-end/stepper:hidden',
2728
+ step: '@max-fr-stepper-end/stepper:rounded-full'
2729
+ }
2730
+ },
2731
+ // The probe is `display: block` from the same threshold at which titles
2732
+ // would appear, i.e. when the full row fits.
2733
+ {
2734
+ orientation: 'horizontal',
2735
+ collapse: 'menu',
2736
+ labelPosition: 'bottom',
2737
+ class: {
2738
+ probe: '@fr-stepper-bottom/stepper:block'
2739
+ }
2740
+ }, {
2741
+ orientation: 'horizontal',
2742
+ collapse: 'menu',
2743
+ labelPosition: 'end',
2744
+ class: {
2745
+ probe: '@fr-stepper-end/stepper:block'
2746
+ }
2747
+ }],
2748
+ defaultVariants: {
2749
+ color: 'primary',
2750
+ size: 'md',
2751
+ orientation: 'horizontal',
2752
+ labelPosition: 'end',
2753
+ collapse: 'menu'
2754
+ }
2755
+ });
2756
+
2451
2757
  const tabs = tv({
2452
2758
  slots: {
2453
2759
  base: 'flex',
@@ -2629,6 +2935,772 @@ const tabs = tv({
2629
2935
  }
2630
2936
  });
2631
2937
 
2938
+ // The shell is one CSS grid. The parts (sidebar, navbar, main, aside) are
2939
+ // siblings in whatever order the consumer writes them, so each places itself
2940
+ // in the grid rather than relying on a wrapper:
2941
+ //
2942
+ // col 1 col 2 col 3
2943
+ // row 1 sidebar | navbar | navbar
2944
+ // row 2 sidebar | main | aside
2945
+ //
2946
+ // row 3 bottom nav (all columns; only with `bottomNavRow: 'shown'`)
2947
+ //
2948
+ // Empty columns and rows are `auto` and collapse to nothing, so a layout with
2949
+ // no sidebar or aside needs no special casing. The inset card is a single
2950
+ // decorative element (`mainCard`) drawn behind the parts in the same grid
2951
+ // area; the parts round their own corners to match it.
2952
+ // The sidebar's drawn width per variant and collapse state, written once.
2953
+ // `sidebar` is the sidebar's own width class; `token` sets the root's
2954
+ // published `--app-sidebar-width` to the same length. The sidebar does NOT
2955
+ // read the token: the token is `0px` until a `Sidebar` registers with the
2956
+ // layout (after the first render), and the sidebar's width must not depend
2957
+ // on that. Class names are literal strings so Tailwind can see them.
2958
+ // The inset widths include the `pe-3`/`ps-3` gutter (border box).
2959
+ // `rail` is the narrow preset for a stacked-label rail (icon over a short
2960
+ // label). It is meant for `collapsible="none"`, so it has no collapsed row:
2961
+ // collapsed widths are the default size's.
2962
+ const sidebarWidths = {
2963
+ attached: {
2964
+ expanded: {
2965
+ sidebar: 'w-64',
2966
+ token: '[--app-sidebar-width:16rem]'
2967
+ },
2968
+ collapsed: {
2969
+ sidebar: 'w-16',
2970
+ token: '[--app-sidebar-width:4rem]'
2971
+ },
2972
+ rail: {
2973
+ sidebar: 'w-20',
2974
+ token: '[--app-sidebar-width:5rem]'
2975
+ }
2976
+ },
2977
+ inset: {
2978
+ expanded: {
2979
+ sidebar: 'w-60 [--sidebar-rail:3rem]',
2980
+ token: '[--app-sidebar-width:15rem]'
2981
+ },
2982
+ collapsed: {
2983
+ sidebar: 'w-[3.75rem] [--sidebar-rail:3rem]',
2984
+ token: '[--app-sidebar-width:3.75rem]'
2985
+ },
2986
+ // 80px plus the 12px `pe-3`/`ps-3` gutter.
2987
+ rail: {
2988
+ sidebar: 'w-[5.75rem]',
2989
+ token: '[--app-sidebar-width:5.75rem]'
2990
+ }
2991
+ }
2992
+ };
2993
+ const sidebarWidthVariants = ['attached', 'inset'].flatMap(variant => [
2994
+ // Collapsed widths are the same for every size.
2995
+ {
2996
+ variant,
2997
+ collapsed: true,
2998
+ class: {
2999
+ sidebar: sidebarWidths[variant].collapsed.sidebar
3000
+ }
3001
+ }, {
3002
+ variant,
3003
+ collapsed: false,
3004
+ sidebarSize: 'default',
3005
+ class: {
3006
+ sidebar: sidebarWidths[variant].expanded.sidebar
3007
+ }
3008
+ }, {
3009
+ variant,
3010
+ collapsed: false,
3011
+ sidebarSize: 'rail',
3012
+ class: {
3013
+ sidebar: sidebarWidths[variant].rail.sidebar
3014
+ }
3015
+ }, {
3016
+ variant,
3017
+ sidebarColumn: 'shown',
3018
+ sidebarSize: 'default',
3019
+ class: {
3020
+ base: sidebarWidths[variant].expanded.token
3021
+ }
3022
+ }, {
3023
+ variant,
3024
+ sidebarColumn: 'shown',
3025
+ sidebarSize: 'rail',
3026
+ class: {
3027
+ base: sidebarWidths[variant].rail.token
3028
+ }
3029
+ }, {
3030
+ variant,
3031
+ sidebarColumn: 'collapsed',
3032
+ class: {
3033
+ base: sidebarWidths[variant].collapsed.token
3034
+ }
3035
+ }]);
3036
+
3037
+ // Below the breakpoint the inset frame goes edge to edge: no gutter, no card
3038
+ // chrome, and the bottom bar needs no negative margins to escape the gutter.
3039
+ // Literal strings per breakpoint: Tailwind generates nothing from an
3040
+ // interpolated class. `max-sm` etc. are the exact complement of `sm:` etc.
3041
+ const edgeToEdge = {
3042
+ sm: {
3043
+ base: 'max-sm:p-0',
3044
+ card: 'max-sm:rounded-none max-sm:shadow-none max-sm:ring-0',
3045
+ radius: 'max-sm:rounded-none',
3046
+ bar: 'max-sm:mx-0 max-sm:mb-0'
3047
+ },
3048
+ md: {
3049
+ base: 'max-md:p-0',
3050
+ card: 'max-md:rounded-none max-md:shadow-none max-md:ring-0',
3051
+ radius: 'max-md:rounded-none',
3052
+ bar: 'max-md:mx-0 max-md:mb-0'
3053
+ },
3054
+ lg: {
3055
+ base: 'max-lg:p-0',
3056
+ card: 'max-lg:rounded-none max-lg:shadow-none max-lg:ring-0',
3057
+ radius: 'max-lg:rounded-none',
3058
+ bar: 'max-lg:mx-0 max-lg:mb-0'
3059
+ }
3060
+ };
3061
+ const edgeToEdgeVariants = ['sm', 'md', 'lg'].flatMap(breakpoint => {
3062
+ const e = edgeToEdge[breakpoint];
3063
+ return [{
3064
+ variant: 'inset',
3065
+ breakpoint,
3066
+ class: {
3067
+ base: e.base,
3068
+ mainCard: e.card,
3069
+ bottomNav: e.bar
3070
+ }
3071
+ }, {
3072
+ variant: 'inset',
3073
+ breakpoint,
3074
+ navbarPlacement: 'frame',
3075
+ class: {
3076
+ main: e.radius
3077
+ }
3078
+ }, {
3079
+ variant: 'inset',
3080
+ breakpoint,
3081
+ navbarPlacement: 'content',
3082
+ class: {
3083
+ navbar: e.radius,
3084
+ main: e.radius
3085
+ }
3086
+ }];
3087
+ });
3088
+
3089
+ // The layout's icon buttons (sidebar, menu and aside toggles). Same radius and
3090
+ // hover fill as a navigation row, so a toggle in the sidebar header reads as
3091
+ // one of its rows. `neutral-muted` stays visible on the frame's ground as
3092
+ // well as on the content surface.
3093
+ const iconButton = [...focusVisibleRing, 'inline-flex size-9 shrink-0 items-center justify-center rounded-lg', 'text-neutral-firm hover:bg-neutral-muted hover:text-neutral-strong'];
3094
+ const appLayout = tv({
3095
+ slots: {
3096
+ // Publishes the shell's sizes as custom properties, for the parts below
3097
+ // and for consumers (sticky offsets, custom parts):
3098
+ //
3099
+ // - `--app-navbar-height`: the height of the navbar and of the sidebar
3100
+ // header, so the two stay on one row.
3101
+ // - `--app-sidebar-width`: the sidebar's drawn width, border box (it
3102
+ // includes the inset variant's `pe-3`/`ps-3` gutter), set by the
3103
+ // `sidebarColumn` variant below. Published for consumers only (the
3104
+ // sidebar sizes itself): it settles after the first render, `0px` until
3105
+ // a Sidebar registers, so use a fallback where a flash matters. `0px`
3106
+ // when there is no sidebar column:
3107
+ // no Sidebar in the layout, below the breakpoint, or collapsed with
3108
+ // `collapsible="offcanvas"`.
3109
+ // - `--app-bottomnav-height`: the `BottomNav` bar's full height, the row
3110
+ // plus the safe-area inset (the literals in `bottom-nav.ts`), set
3111
+ // by the `bottomNavRow` variant below. `0px` when no bar is shown, so
3112
+ // consumers can offset by it unconditionally.
3113
+ //
3114
+ // The navbar and sidebar header read `--app-navbar-height` (always set)
3115
+ // with a literal fallback for parts rendered outside an `AppLayout`.
3116
+ base: ['relative grid w-full text-on-surface-app', 'grid-cols-[auto_minmax(0,1fr)_auto]', '[--app-navbar-height:3rem]'],
3117
+ // `group/sidebar` plus `data-collapsed` on the element lets any descendant
3118
+ // react to the icon rail with `group-data-[collapsed=true]/sidebar:`.
3119
+ // Labels written as `<span data-sidebar-label>`, anywhere in the sidebar
3120
+ // (header, body or footer), are visually hidden in the icon rail but stay
3121
+ // in the accessibility tree (`sr-only`, never `display: none`).
3122
+ sidebar: ['group/sidebar col-start-1 row-[1/-1] shrink-0 flex-col', 'data-[collapsed=true]:[&_[data-sidebar-label]]:sr-only',
3123
+ // Expanding, a label fades in once the width has mostly opened. It is
3124
+ // already visually hidden when collapsing, so the fade-out is unseen.
3125
+ 'data-[collapsed=true]:[&_[data-sidebar-label]]:opacity-0', '[&_[data-sidebar-label]]:transition-opacity [&_[data-sidebar-label]]:delay-100 [&_[data-sidebar-label]]:duration-150',
3126
+ // `visibility` is listed so an offcanvas sidebar stays visible while it
3127
+ // closes and becomes hidden only once its width reaches 0.
3128
+ 'transition-[width,padding,visibility] duration-200', 'motion-reduce:transition-none motion-reduce:[&_[data-sidebar-label]]:transition-none'],
3129
+ // The sidebar's `nav` inside the mobile drawer: always expanded, as tall
3130
+ // as the drawer.
3131
+ mobileSidebar: 'group/sidebar flex min-h-0 flex-1 flex-col',
3132
+ // The drawer's close button, merged over the Drawer's own position. The
3133
+ // drawer is portalled out of the layout, so the layout's custom
3134
+ // properties do not reach it: the values are the defaults written out.
3135
+ // The 36px button is centered in the 3rem header row (top 6px), and its
3136
+ // icon ends 22px from the edge, where a row's trailing content does.
3137
+ drawerCloseButton: 'top-1.5 right-3.5 rtl:right-auto rtl:left-3.5',
3138
+ // In the icon rail the header stacks its children: the brand on its
3139
+ // content line (where the items' icons sit, so it does not move when the
3140
+ // rail opens) and the `Toggle` under it. The end is the gutter, so the
3141
+ // toggle's fill lines up with a row's.
3142
+ //
3143
+ // The layout flips in one frame while the width eases over 200ms, so the
3144
+ // header carries its own motion. Its content box is always the navbar
3145
+ // height (`box-content`), so the row centers the same way in both states;
3146
+ // the stacked toggle hangs below it in `padding-bottom`, which eases on the
3147
+ // width's curve, so the body glides rather than jumps. The toggle fades in
3148
+ // at its new spot on collapse, and `overflow-x-clip` keeps a toggle that is
3149
+ // still arriving inside the narrow rail on expand (0.375rem of clip margin
3150
+ // leaves its focus ring visible). A header that is only a `Toggle` keeps
3151
+ // its one row.
3152
+ //
3153
+ // The two ends mirror each other: the brand's start and the end toggle's
3154
+ // icon are both half a rail minus half an icon from the sidebar's edge,
3155
+ // the same inset a row gives its icon and its trailing chevron or badge.
3156
+ // The end padding is that inset less the toggle's 0.5rem icon padding.
3157
+ sidebarHeader: ['box-content flex h-(--app-navbar-height,3rem) shrink-0 items-center gap-2 pb-0 ps-[calc((var(--sidebar-rail,4rem)_-_1.25rem)/2)] pe-[calc(var(--sidebar-rail,4rem)/2_-_1.125rem)]', 'overflow-x-clip [overflow-clip-margin:0.375rem]', 'transition-[padding-bottom] duration-200 motion-reduce:transition-none', 'group-data-[collapsed=true]/sidebar:flex-col', 'group-data-[collapsed=true]/sidebar:items-start', 'group-data-[collapsed=true]/sidebar:*:shrink-0',
3158
+ // An `ml-auto` meant for the expanded row (a toggle pushed to the end)
3159
+ // would shove a stacked child aside.
3160
+ 'group-data-[collapsed=true]/sidebar:*:mx-0',
3161
+ // Brand and toggle: the brand's top is where a 1.25rem icon centered in
3162
+ // the navbar height sits, so only the toggle travels.
3163
+ 'group-data-[collapsed=true]/sidebar:has-[>*:not([data-part=sidebar-toggle])]:pb-10', 'group-data-[collapsed=true]/sidebar:has-[>*:not([data-part=sidebar-toggle])]:*:first:mt-[calc((var(--app-navbar-height,3rem)-1.25rem)/2)]', 'group-data-[collapsed=true]/sidebar:not-has-[>*:not([data-part=sidebar-toggle])]:justify-center',
3164
+ // The toggle's icon sits 0.5rem inside its fill; pull the fill back so
3165
+ // the icon lands on the content line, centered in the rail.
3166
+ 'group-data-[collapsed=true]/sidebar:*:data-[part=sidebar-toggle]:-ms-2', 'group-data-[collapsed=true]/sidebar:*:data-[part=sidebar-toggle]:animate-[frontile-fade-in_160ms_60ms_ease-out_backwards]', 'group-data-[collapsed=true]/sidebar:*:data-[part=sidebar-toggle]:motion-reduce:animate-none'],
3167
+ // Where a row's fill starts, from the sidebar's edge: `--sidebar-gutter`
3168
+ // (0.5rem by default, 0 in the inset variant, whose frame is the gutter).
3169
+ // The items' rail-centering, the header and the footer use it too.
3170
+ // `--sidebar-clip` is the room the scrolling body leaves for the focus
3171
+ // ring, which it would clip at its edge. It is padding with an equal
3172
+ // negative margin, so it does not move the rows: they start at the gutter.
3173
+ // The body is a column with the rows' 4px gap, so items placed straight in
3174
+ // it are spaced like those in a `Group` (a column that must not shrink).
3175
+ // With no header above it or footer below it, the body insets its first
3176
+ // and last rows by the gutter, as it does their sides. Inset's gutter is
3177
+ // 0: the frame's padding already holds them off the edge.
3178
+ sidebarBody: ['-mx-(--sidebar-clip,0px) flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto *:shrink-0 px-[calc(var(--sidebar-gutter,0.5rem)+var(--sidebar-clip,0px))]', 'first:pt-(--sidebar-gutter,0.5rem) last:pb-(--sidebar-gutter,0.5rem)'],
3179
+ // A bare `Toggle` is offset so its icon sits on the content line.
3180
+ sidebarFooter: ['shrink-0 px-(--sidebar-gutter,0.5rem) py-2', '*:data-[part=sidebar-toggle]:ms-[calc((var(--sidebar-rail,4rem)_-_1.25rem)/2_-_var(--sidebar-gutter,0.5rem)_-_0.5rem)]'],
3181
+ // `Sidebar.Group`: a labelled set of items. The label is visually hidden
3182
+ // in the rail like any other sidebar label.
3183
+ sidebarGroup: 'flex flex-col gap-1 py-2',
3184
+ sidebarGroupLabel: ['truncate ps-[calc((var(--sidebar-rail,4rem)_-_1.25rem)/2_-_var(--sidebar-gutter,0.5rem))] pe-2 pb-1 font-label text-label-2xs text-neutral-firm', 'group-data-[collapsed=true]/sidebar:sr-only'],
3185
+ sidebarToggle: iconButton,
3186
+ // Opens the mobile drawer. Hidden from `breakpoint` up (see below).
3187
+ menuToggle: iconButton,
3188
+ // The navbar's side padding is the page header's, so its text lines up
3189
+ // with the page's. A toggle at either end is pulled back by its 0.5rem
3190
+ // icon padding, so its icon lines up instead of its fill.
3191
+ navbar: ['col-[2/-1] row-start-1 flex h-(--app-navbar-height,3rem) min-w-0 items-center gap-2 px-4', '[&>[data-part$=-toggle]:first-child]:-ms-2 [&>[data-part$=-toggle]:last-child]:-me-2'],
3192
+ main: 'col-start-2 row-start-2 min-h-0 min-w-0 outline-none',
3193
+ mainCard: 'pointer-events-none col-[2/-1]',
3194
+ // `BottomNav` inside the layout: the third row, across every column.
3195
+ // Merged over the bar's own (standalone, `fixed`) classes; the scroll
3196
+ // mode decides how it is positioned (see `scrollMode`).
3197
+ bottomNav: 'col-[1/-1] row-start-3',
3198
+ pageHeader: 'flex shrink-0 flex-wrap items-start gap-x-4 gap-y-2 px-4 py-4',
3199
+ pageHeaderContent: 'flex min-w-0 flex-1 flex-col gap-1',
3200
+ pageHeaderTitle: 'font-header text-header-lg text-neutral-strong',
3201
+ pageHeaderDescription: 'font-body text-body-sm text-neutral-firm',
3202
+ pageHeaderActions: 'flex shrink-0 items-center gap-2',
3203
+ // Literal `lg:block` here, not tied to `breakpoint`: the aside is a
3204
+ // wide-viewport affordance regardless of where the sidebar collapses.
3205
+ // Below `lg` the same block renders in a Drawer instead (`mobileAside`).
3206
+ aside: 'col-start-3 row-start-2 hidden w-72 shrink-0 overflow-y-auto p-4 font-body text-body-sm lg:block',
3207
+ // The aside's `aside` element inside the drawer: as tall as the drawer.
3208
+ mobileAside: 'min-h-0 flex-1 overflow-y-auto p-4 font-body text-body-sm',
3209
+ asideToggle: iconButton,
3210
+ skipLink: [...focusVisibleRing, 'sr-only focus:not-sr-only', 'focus:absolute focus:start-2 focus:top-2 focus:z-50', 'focus:rounded-md focus:bg-surface-app focus:px-3 focus:py-2', 'focus:text-on-surface-app focus:shadow-md']
3211
+ },
3212
+ variants: {
3213
+ variant: {
3214
+ // The tinted frame shows through a gutter around the card. The content
3215
+ // is the lit surface in both schemes: on a `canvas` frame in light, and
3216
+ // in dark, where `app` is black, `canvas` content on an `app` frame.
3217
+ inset: {
3218
+ base: 'bg-surface-canvas p-3 dark:bg-surface-app',
3219
+ // Transparent, borderless: the sidebar floats on the tinted frame.
3220
+ // The frame's own padding is the gutter, so rows start at the sidebar's
3221
+ // edge. 0.375rem of clip room clears the 5px focus ring, which the
3222
+ // scrolling body would otherwise clip at its edge.
3223
+ sidebar: 'bg-transparent [--sidebar-clip:0.375rem] [--sidebar-gutter:0px]',
3224
+ mainCard: 'rounded-xl bg-surface-app shadow-sm ring-1 ring-neutral-muted dark:bg-surface-canvas',
3225
+ aside: 'border-s border-neutral-muted',
3226
+ // The bottom bar runs edge to edge: it pulls out over the frame's
3227
+ // side and bottom gutter (`p-3`).
3228
+ bottomNav: '-mx-3 -mb-3'
3229
+ },
3230
+ // The sidebar's ground and border are the layout's (see the compound
3231
+ // variants), so a standalone sidebar draws neither.
3232
+ attached: {
3233
+ base: 'bg-surface-app dark:bg-surface-canvas',
3234
+ // Edge-to-edge content: no card chrome. The element is not rendered.
3235
+ mainCard: 'hidden',
3236
+ navbar: 'border-b border-neutral-muted bg-surface-app dark:bg-surface-canvas',
3237
+ aside: 'border-s border-neutral-muted'
3238
+ }
3239
+ },
3240
+ // `frame`: the navbar is a row on the tinted frame, above the card.
3241
+ // `content`: the card grows to cover the navbar row too.
3242
+ navbarPlacement: {
3243
+ frame: {
3244
+ mainCard: 'row-[2/3]'
3245
+ },
3246
+ content: {
3247
+ mainCard: 'row-[1/3]'
3248
+ }
3249
+ },
3250
+ // Where the sidebar stops being an off-canvas drawer and becomes inline.
3251
+ // Literal strings per breakpoint: Tailwind generates nothing from an
3252
+ // interpolated class.
3253
+ breakpoint: {
3254
+ sm: {
3255
+ sidebar: 'hidden sm:flex',
3256
+ menuToggle: 'sm:hidden'
3257
+ },
3258
+ md: {
3259
+ sidebar: 'hidden md:flex',
3260
+ menuToggle: 'md:hidden'
3261
+ },
3262
+ lg: {
3263
+ sidebar: 'hidden lg:flex',
3264
+ menuToggle: 'lg:hidden'
3265
+ }
3266
+ },
3267
+ collapsed: {
3268
+ true: {},
3269
+ false: {}
3270
+ },
3271
+ // What the layout's root reports for `--app-sidebar-width`: `shown` and
3272
+ // `collapsed` take the width from `variant` (compound variants below);
3273
+ // `none` is no sidebar column. Set by `AppLayout` only.
3274
+ sidebarColumn: {
3275
+ shown: {},
3276
+ collapsed: {},
3277
+ none: {
3278
+ base: '[--app-sidebar-width:0px]'
3279
+ }
3280
+ },
3281
+ // Whether the layout shows a `BottomNav` row: `@mobileNav="bottom"`,
3282
+ // below the breakpoint, with a `BottomNav` registered. `shown` adds the
3283
+ // third `auto` row (compound variants below) and publishes the bar's
3284
+ // height; the row height and safe-area expression must match `bottom-nav.ts`,
3285
+ // written out because Tailwind generates nothing from an interpolated class.
3286
+ // Set by `AppLayout` only.
3287
+ bottomNavRow: {
3288
+ shown: {
3289
+ base: '[--app-bottomnav-height:calc(3.75rem+var(--bottomnav-safe-area,env(safe-area-inset-bottom,0px)))]'
3290
+ },
3291
+ none: {
3292
+ base: '[--app-bottomnav-height:0px]'
3293
+ }
3294
+ },
3295
+ // The sidebar's width preset: `default`, or `rail` for a narrow
3296
+ // icon-over-label rail. Set by `Sidebar`, and by `AppLayout` for the root's
3297
+ // token. Defaults to `default` so existing callers are unchanged.
3298
+ sidebarSize: {
3299
+ default: {},
3300
+ rail: {}
3301
+ },
3302
+ // `icon` shrinks to a rail, `offcanvas` hides entirely, `none` ignores
3303
+ // `collapsed` (the Sidebar passes `collapsed: false` for it).
3304
+ collapsible: {
3305
+ icon: {},
3306
+ // The sidebar closes to no width, so its contents fade rather than
3307
+ // being seen squeezed: out quickly on collapse, back in once the width
3308
+ // has mostly opened (the delay, cleared while collapsing).
3309
+ offcanvas: {
3310
+ sidebar: ['overflow-x-clip', '*:transition-opacity *:delay-100 *:duration-150 motion-reduce:*:transition-none']
3311
+ },
3312
+ none: {}
3313
+ },
3314
+ // `end` moves the sidebar to the last column and the aside to the first,
3315
+ // so the two stay on opposite sides of the page. The grid is reordered,
3316
+ // not the DOM: aside and main take columns 1 and 2, with the navbar and
3317
+ // card spanning both. Logical utilities flip all of this in a
3318
+ // right-to-left document.
3319
+ sidebarSide: {
3320
+ start: {},
3321
+ end: {
3322
+ sidebar: 'col-start-3',
3323
+ navbar: 'col-[1/-2]',
3324
+ main: 'col-start-2',
3325
+ mainCard: 'col-[1/-2]',
3326
+ aside: 'col-start-1'
3327
+ }
3328
+ },
3329
+ // The sidebar rendered in the mobile drawer. The drawer's close button
3330
+ // sits at the end of the first row: the header leaves room for it, and a
3331
+ // body with no header above it leaves that row empty.
3332
+ inDrawer: {
3333
+ true: {
3334
+ sidebarHeader: 'pe-[3.625rem]',
3335
+ sidebarBody: 'first:pt-(--app-navbar-height,3rem)'
3336
+ },
3337
+ false: {}
3338
+ },
3339
+ // Outside an `AppLayout` there is no grid and no drawer breakpoint, so the
3340
+ // sidebar is always shown and as tall as its container.
3341
+ standalone: {
3342
+ true: {
3343
+ sidebar: 'flex h-full'
3344
+ },
3345
+ false: {}
3346
+ },
3347
+ // `content`: the shell fills the viewport and `main` scrolls itself.
3348
+ // `page`: the document scrolls and the sidebar sticks.
3349
+ scrollMode: {
3350
+ content: {
3351
+ base: 'h-dvh grid-rows-[auto_minmax(0,1fr)] overflow-hidden',
3352
+ main: 'overflow-y-auto',
3353
+ // A plain grid row under `main`, which scrolls on its own.
3354
+ bottomNav: 'static'
3355
+ },
3356
+ page: {
3357
+ // `isolate` keeps the z-indexes below (the sticky bar, the sidebar
3358
+ // lifted for a flyout) inside the shell. Overlays portal to the end
3359
+ // of the body with no z-index of their own, so they paint above the
3360
+ // whole shell by DOM order. Without it, any positive z-index in here
3361
+ // would paint over every Modal, Drawer and Popover.
3362
+ base: 'isolate min-h-dvh grid-rows-[auto_1fr]',
3363
+ // No z-index: nothing in `main` needs to pass under it, and overlays
3364
+ // (Modal, Drawer, Popover, Tooltip, a rail `NavFolder`'s menu) are
3365
+ // portalled out of the shell.
3366
+ sidebar: 'sticky top-0 h-dvh self-start',
3367
+ // The document scrolls, so the bar sticks to the bottom of the
3368
+ // viewport over the content. `z-10` lifts it over in-page layers
3369
+ // (z-10 is the highest used in content; a tie goes to the later
3370
+ // element, so the bar should come after `Main` in the DOM). The
3371
+ // root's `isolate` keeps it under overlays.
3372
+ bottomNav: 'sticky bottom-0 z-10'
3373
+ }
3374
+ }
3375
+ },
3376
+ compoundVariants: [
3377
+ // The sidebar's own width and the root's `--app-sidebar-width` both come
3378
+ // from `sidebarWidths`, so they cannot drift.
3379
+ ...sidebarWidthVariants,
3380
+ // The rail is 5rem wide, so its body gives up some side padding to the
3381
+ // stacked labels. 0.3125rem still clears the 5px focus ring.
3382
+ {
3383
+ sidebarSize: 'rail',
3384
+ class: {
3385
+ sidebar: '[--sidebar-gutter:0.3125rem]'
3386
+ }
3387
+ },
3388
+ // The rail's items are centered columns (icon over label), and the header
3389
+ // assumes a 4rem `--sidebar-rail` that this 5rem column does not set. Give
3390
+ // it the body's gutter on both sides and center its content, so a brand
3391
+ // sits over the same box as the items. A group label is centered likewise.
3392
+ {
3393
+ sidebarSize: 'rail',
3394
+ class: {
3395
+ sidebarHeader: 'ps-(--sidebar-gutter,0.5rem) pe-(--sidebar-gutter,0.5rem) justify-center',
3396
+ sidebarGroupLabel: 'ps-0 pe-0 text-center'
3397
+ }
3398
+ },
3399
+ // The inset sidebar floats on the frame, so it supplies its own spacing
3400
+ // to the card (the grid has no gap).
3401
+ {
3402
+ variant: 'inset',
3403
+ sidebarSide: 'start',
3404
+ class: {
3405
+ sidebar: 'pe-3'
3406
+ }
3407
+ }, {
3408
+ variant: 'inset',
3409
+ sidebarSide: 'end',
3410
+ class: {
3411
+ sidebar: 'ps-3'
3412
+ }
3413
+ },
3414
+ // Attached: the sidebar sits on the frame's ground, the same
3415
+ // ground the inset variant's sidebar floats on, with a border on
3416
+ // the side facing the content. Only in a layout: standalone, the sidebar
3417
+ // is transparent and borderless, and its container decides both.
3418
+ {
3419
+ variant: 'attached',
3420
+ standalone: false,
3421
+ class: {
3422
+ sidebar: 'border-e border-neutral-muted bg-surface-canvas dark:bg-surface-app'
3423
+ }
3424
+ }, {
3425
+ variant: 'attached',
3426
+ standalone: false,
3427
+ sidebarSide: 'end',
3428
+ class: {
3429
+ sidebar: 'border-e-0 border-s'
3430
+ }
3431
+ },
3432
+ // The aside sits at the start with `sidebarSide="end"`; its border
3433
+ // faces the content, on its end side.
3434
+ {
3435
+ variant: 'inset',
3436
+ sidebarSide: 'end',
3437
+ class: {
3438
+ aside: 'border-s-0 border-e'
3439
+ }
3440
+ }, {
3441
+ variant: 'attached',
3442
+ sidebarSide: 'end',
3443
+ class: {
3444
+ aside: 'border-s-0 border-e'
3445
+ }
3446
+ },
3447
+ // The bottom nav's row, after the navbar and main rows.
3448
+ {
3449
+ scrollMode: 'content',
3450
+ bottomNavRow: 'shown',
3451
+ class: {
3452
+ base: 'grid-rows-[auto_minmax(0,1fr)_auto]'
3453
+ }
3454
+ }, {
3455
+ scrollMode: 'page',
3456
+ bottomNavRow: 'shown',
3457
+ class: {
3458
+ base: 'grid-rows-[auto_1fr_auto]'
3459
+ }
3460
+ },
3461
+ // Page mode with the inset frame: the sticky sidebar sits inside the
3462
+ // root's `p-3` gutter, so it sticks below the top gutter and is shorter
3463
+ // by both gutters. With `top-0 h-dvh` the grid grew by the gutters and
3464
+ // the page always scrolled by 1.5rem.
3465
+ {
3466
+ variant: 'inset',
3467
+ scrollMode: 'page',
3468
+ class: {
3469
+ sidebar: 'top-3 h-[calc(100dvh-1.5rem)]'
3470
+ }
3471
+ },
3472
+ // A navbar on the frame is itself the top gutter: its row starts at the
3473
+ // frame's edge, so its content is centered between that edge and the
3474
+ // card instead of sitting a gutter low. Without a navbar, or with the
3475
+ // navbar inside the card (`content`), the card keeps the top gutter.
3476
+ {
3477
+ variant: 'inset',
3478
+ navbarPlacement: 'frame',
3479
+ class: {
3480
+ base: 'has-[>[data-part=navbar]]:pt-0'
3481
+ }
3482
+ },
3483
+ // The same in page mode: the sticky sidebar starts at the top and is
3484
+ // shorter by the bottom gutter only.
3485
+ {
3486
+ variant: 'inset',
3487
+ navbarPlacement: 'frame',
3488
+ scrollMode: 'page',
3489
+ class: {
3490
+ base: 'has-[>[data-part=navbar]]:[&>[data-part=sidebar]]:top-0 has-[>[data-part=navbar]]:[&>[data-part=sidebar]]:h-[calc(100dvh-0.75rem)]'
3491
+ }
3492
+ },
3493
+ // Offcanvas: collapsed is no width, no gutter, no border, and once the
3494
+ // width transition ends, `invisible`, so its links leave the tab order
3495
+ // and the accessibility tree. Comes after the width variants so `w-0`
3496
+ // wins.
3497
+ {
3498
+ collapsible: 'offcanvas',
3499
+ collapsed: true,
3500
+ class: {
3501
+ sidebar: 'invisible w-0 border-0 ps-0 pe-0 *:opacity-0 *:delay-0'
3502
+ }
3503
+ },
3504
+ // Main and navbar round their own corners to the card's, so content
3505
+ // scrolled inside `main` is clipped to the card's shape.
3506
+ {
3507
+ variant: 'inset',
3508
+ navbarPlacement: 'frame',
3509
+ class: {
3510
+ main: 'rounded-xl'
3511
+ }
3512
+ }, {
3513
+ variant: 'inset',
3514
+ navbarPlacement: 'content',
3515
+ class: {
3516
+ navbar: 'rounded-t-xl border-b border-neutral-muted',
3517
+ main: 'rounded-b-xl'
3518
+ }
3519
+ }, ...edgeToEdgeVariants],
3520
+ defaultVariants: {
3521
+ variant: 'inset',
3522
+ navbarPlacement: 'frame',
3523
+ breakpoint: 'md',
3524
+ collapsed: false,
3525
+ collapsible: 'icon',
3526
+ sidebarColumn: 'shown',
3527
+ bottomNavRow: 'none',
3528
+ sidebarSide: 'start',
3529
+ sidebarSize: 'default',
3530
+ standalone: false,
3531
+ inDrawer: false,
3532
+ scrollMode: 'content'
3533
+ }
3534
+ });
3535
+
3536
+ // The icon's position never depends on the collapsed state, so the rail
3537
+ // closes over it instead of the icon sliding as the width animates.
3538
+ // Start padding puts it at the center of the rail's content box:
3539
+ // (rail - body padding on both sides - icon 1.25rem) / 2. The body's
3540
+ // side padding is `--sidebar-gutter` (0.5rem unless the variant sets it).
3541
+ // `--sidebar-rail` is the content width, so the inset variant excludes its
3542
+ // 0.75rem gap. Only the inline layout follows the rail.
3543
+ //
3544
+ // The end padding is the same inset, so a trailing chevron or badge sits as
3545
+ // far inside the row as the icon does. A `Toggle` at the header's end lines
3546
+ // its icon up with them (see `sidebarHeader` in `app-layout.ts`).
3547
+ const railInset = 'ps-[calc((var(--sidebar-rail,4rem)_-_2*var(--sidebar-gutter,0.5rem)_-_1.25rem)/2)] pe-[calc((var(--sidebar-rail,4rem)_-_2*var(--sidebar-gutter,0.5rem)_-_1.25rem)/2)]';
3548
+
3549
+ // A badge on an inline row with an icon: at the row's trailing end, like a
3550
+ // folder's chevron, and on the icon's top-end corner once the sidebar
3551
+ // collapses to the rail and the label is gone. The row is the containing
3552
+ // block, so the corner is measured from the row's start, where the icon
3553
+ // sits at the rail inset: 4px past the icon's 1.25rem end and above its
3554
+ // top. Written out in full: Tailwind only sees literal class names.
3555
+ const railBadge = ['ms-auto', 'group-data-[collapsed=true]/sidebar:absolute', 'group-data-[collapsed=true]/sidebar:start-[calc((var(--sidebar-rail,4rem)_-_2*var(--sidebar-gutter,0.5rem)_-_1.25rem)/2_+_1.5rem)]', 'group-data-[collapsed=true]/sidebar:top-[calc(50%_-_0.875rem)]', 'group-data-[collapsed=true]/sidebar:-translate-x-full rtl:group-data-[collapsed=true]/sidebar:translate-x-full'];
3556
+ const navRow = [...focusVisibleRing,
3557
+ // 36px with a mouse; 44px where the pointer is coarse (touch).
3558
+ 'flex min-h-9 w-full items-center gap-2 rounded-lg px-2 py-1.5 font-body text-body-sm pointer-coarse:min-h-11', 'text-neutral-firm', 'not-data-[disabled=true]:hover:bg-neutral-muted', 'not-data-[disabled=true]:hover:text-neutral-strong', 'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-disabled'];
3559
+
3560
+ // An item is filled while it is the current page. A folder is never the
3561
+ // current page, so its trigger takes `navRow` alone.
3562
+ const navItemRow = [...navRow, 'data-[active=true]:bg-neutral-soft data-[active=true]:font-medium',
3563
+ // Hovering the current page keeps its fill rather than lightening it.
3564
+ 'not-data-[disabled=true]:data-[active=true]:hover:bg-neutral-soft', 'data-[active=true]:text-neutral-strong'];
3565
+
3566
+ /**
3567
+ * Shared navigation row styles: `NavLink`, `NavItem` and `NavFolder`.
3568
+ * Slot names equal the kebab-cased `data-part` each component renders.
3569
+ */
3570
+ const navItem = tv({
3571
+ slots: {
3572
+ navItem: navItemRow,
3573
+ // The slot sizes the icon, so an SVG that brings its own size (Lucide's
3574
+ // 24px attributes, a utility class) still matches the other rows.
3575
+ navItemIcon: 'relative inline-flex shrink-0 items-center justify-center [&>svg]:size-5',
3576
+ navItemLabel: 'truncate',
3577
+ // The short text shown under the icon in the stacked layout.
3578
+ navItemShortLabel: 'max-w-full truncate text-body-4xs leading-tight',
3579
+ navItemBadge: 'inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-danger px-1 font-label text-label-micro leading-none text-on-danger',
3580
+ // Screen-reader text appended to the label for a badge.
3581
+ navItemBadgeLabel: 'sr-only',
3582
+ navFolder: 'flex flex-col',
3583
+ // A button, which browsers do not give a pointer cursor on their own.
3584
+ navFolderTrigger: [...navRow, 'not-data-[disabled=true]:cursor-pointer'],
3585
+ navFolderChevron: ['ms-auto size-4 shrink-0 transition-transform data-[open=true]:rotate-90 motion-reduce:transition-none',
3586
+ // Mirrored right to left, so it points toward the inline end. CSS
3587
+ // applies `scale` before `rotate`, so the open state turns the other
3588
+ // way there to still point down.
3589
+ 'rtl:-scale-x-100 rtl:data-[open=true]:-rotate-90', 'group-data-[collapsed=true]/sidebar:hidden'],
3590
+ // The first child's top margin spaces it from the trigger. It lives
3591
+ // inside the panel because the collapsed panel clips it; a gap or
3592
+ // padding on the folder would show 4px while closed.
3593
+ navFolderPanel: 'ms-4 flex flex-col gap-1 border-s border-neutral-muted ps-2 *:first:mt-1'
3594
+ },
3595
+ variants: {
3596
+ layout: {
3597
+ inline: {
3598
+ // The containing block for a badge on the icon's corner in the rail.
3599
+ navItem: ['relative', railInset],
3600
+ navFolderTrigger: railInset,
3601
+ navItemIcon: 'size-5',
3602
+ // Hidden in the icon rail.
3603
+ navItemLabel: 'group-data-[collapsed=true]/sidebar:sr-only'
3604
+ },
3605
+ // Small icon over text. Ignores the sidebar's collapsed state.
3606
+ stacked: {
3607
+ navItem: ['group/nav-item mx-auto min-h-14 w-full max-w-[72px] flex-col justify-center gap-0.5 px-0.5 py-1 text-body-4xs',
3608
+ // The active fill sits behind the icon, not the whole item.
3609
+ 'data-[active=true]:bg-transparent not-data-[disabled=true]:hover:bg-transparent', 'not-data-[disabled=true]:data-[active=true]:hover:bg-transparent'],
3610
+ navItemIcon: ['h-8 w-11 rounded-lg', 'group-data-[active=true]/nav-item:bg-neutral-soft', 'group-not-data-[disabled=true]/nav-item:group-hover/nav-item:bg-neutral-muted', 'group-not-data-[disabled=true]/nav-item:group-data-[active=true]/nav-item:group-hover/nav-item:bg-neutral-soft']
3611
+ },
3612
+ // Icon only; the label is screen-reader text and a tooltip.
3613
+ icon: {
3614
+ navItem: 'size-11 min-h-11 justify-center rounded-lg px-0 py-0',
3615
+ navItemIcon: 'size-5',
3616
+ navItemLabel: 'sr-only'
3617
+ },
3618
+ // A row of a rail folder's `Dropdown` menu: the menu item draws the
3619
+ // row, the item only its icon, label and badge.
3620
+ menu: {
3621
+ navItemIcon: 'size-5'
3622
+ }
3623
+ },
3624
+ // The current page, in a rail folder's menu.
3625
+ current: {
3626
+ true: {
3627
+ navItemLabel: 'font-medium text-neutral-strong'
3628
+ }
3629
+ },
3630
+ // The visible text is the short label, so the full label is for
3631
+ // screen readers only.
3632
+ shortLabel: {
3633
+ true: {
3634
+ navItemLabel: 'sr-only'
3635
+ }
3636
+ },
3637
+ badgePlacement: {
3638
+ // At the icon's top-end corner.
3639
+ icon: {
3640
+ navItemBadge: 'absolute -top-1 -end-1'
3641
+ },
3642
+ end: {
3643
+ navItemBadge: 'ms-auto'
3644
+ },
3645
+ // At the end of an inline row with an icon; on the icon in the rail.
3646
+ rail: {
3647
+ navItemBadge: railBadge
3648
+ }
3649
+ },
3650
+ // A plain dot with no text (the More tab's "something inside has a
3651
+ // badge" marker).
3652
+ badgeDot: {
3653
+ true: {
3654
+ navItemBadge: 'size-2 min-w-2 p-0'
3655
+ }
3656
+ }
3657
+ },
3658
+ compoundVariants: [
3659
+ // The dot is smaller than the pill, so it sits closer to the corner.
3660
+ {
3661
+ badgeDot: true,
3662
+ badgePlacement: 'icon',
3663
+ class: {
3664
+ navItemBadge: '-top-0.5 -end-0.5'
3665
+ }
3666
+ }, {
3667
+ badgeDot: true,
3668
+ badgePlacement: 'rail',
3669
+ class: {
3670
+ navItemBadge: ['group-data-[collapsed=true]/sidebar:start-[calc((var(--sidebar-rail,4rem)_-_2*var(--sidebar-gutter,0.5rem)_-_1.25rem)/2_+_1.375rem)]', 'group-data-[collapsed=true]/sidebar:top-[calc(50%_-_0.75rem)]']
3671
+ }
3672
+ }],
3673
+ defaultVariants: {
3674
+ layout: 'inline'
3675
+ }
3676
+ });
3677
+
3678
+ /**
3679
+ * The mobile bottom tab bar. Slot names equal the kebab-cased `data-part`
3680
+ * each component renders.
3681
+ *
3682
+ * Standalone, the bar is fixed to the bottom of the viewport. There is no
3683
+ * z-index here on purpose; `AppLayout` positions it and layers it.
3684
+ */
3685
+ const bottomNav = tv({
3686
+ slots: {
3687
+ // Class names are literal strings so Tailwind can see them.
3688
+ bottomNav: ['fixed inset-x-0 bottom-0 box-border flex items-center justify-around', 'border-t border-neutral-muted bg-surface-app', 'min-h-[calc(3.75rem+var(--bottomnav-safe-area,env(safe-area-inset-bottom,0px)))]', 'pb-[var(--bottomnav-safe-area,env(safe-area-inset-bottom,0px))]'],
3689
+ // `BottomNav.More`: the copy of its block that is always rendered, out
3690
+ // of sight, so its items can report active and badge state while the
3691
+ // sheet is closed. `hidden` backs up the `hidden` attribute.
3692
+ bottomNavMoreRegistry: 'hidden',
3693
+ // The More sheet, merged into the bottom `Drawer`'s base: as tall as its
3694
+ // items, up to 80% of the viewport.
3695
+ bottomNavMoreSheet: 'h-auto max-h-[80dvh]',
3696
+ // The sheet's scrolling body, merged into the `Drawer`'s. The bottom
3697
+ // padding is the safe-area inset alone, like the bar's.
3698
+ bottomNavMoreBody: ['px-2 pt-6', 'pb-[var(--bottomnav-safe-area,env(safe-area-inset-bottom,0px))]'],
3699
+ // The `nav` inside the sheet that holds its items.
3700
+ bottomNavMoreNav: 'flex flex-col gap-0.5 pb-2'
3701
+ }
3702
+ });
3703
+
2632
3704
  const accordion = tv({
2633
3705
  slots: {
2634
3706
  base: 'flex flex-col',
@@ -3827,6 +4899,13 @@ const select = tv({
3827
4899
  isFilterable: {
3828
4900
  true: {},
3829
4901
  false: {}
4902
+ },
4903
+ // Whether any key is selected. In chips mode an empty field shows the
4904
+ // placeholder in the bare trigger, which has to be offset to where a
4905
+ // single select's placeholder sits (see the compound variants below).
4906
+ hasSelection: {
4907
+ true: {},
4908
+ false: {}
3830
4909
  }
3831
4910
  },
3832
4911
  compoundVariants: [
@@ -3860,6 +4939,34 @@ const select = tv({
3860
4939
  chipsField: 'p-2 gap-0 min-h-13.5'
3861
4940
  }
3862
4941
  },
4942
+ // That padding is tight so chips fit, which leaves an empty field's
4943
+ // placeholder closer to the border than a single select's (`p-2`/`p-3`/
4944
+ // `p-4` on `input`). The trigger makes up the difference while nothing is
4945
+ // selected. Listed before the start-content rules so their `ps-0` wins:
4946
+ // with start content `chipsField` already reserves the same `ps-8` a
4947
+ // single select's input does.
4948
+ {
4949
+ hasChips: true,
4950
+ hasSelection: false,
4951
+ size: 'sm',
4952
+ class: {
4953
+ input: 'ps-1'
4954
+ }
4955
+ }, {
4956
+ hasChips: true,
4957
+ hasSelection: false,
4958
+ size: 'md',
4959
+ class: {
4960
+ input: 'ps-1.5'
4961
+ }
4962
+ }, {
4963
+ hasChips: true,
4964
+ hasSelection: false,
4965
+ size: 'lg',
4966
+ class: {
4967
+ input: 'ps-2'
4968
+ }
4969
+ },
3863
4970
  // Chips have to clear the absolutely-positioned start/end content the same
3864
4971
  // way a bare `input` does, otherwise they run underneath the chevron and the
3865
4972
  // clear button.
@@ -3893,12 +5000,20 @@ const select = tv({
3893
5000
  },
3894
5001
  // Only the filterable trigger needs typing room -- and, since the field
3895
5002
  // itself no longer sets a gap, its own separation from the last chip.
3896
- // See `min-w-0` and `gap-0` above.
5003
+ // See `min-w-0` and `gap-0` above. With no chips there is no last chip to
5004
+ // clear, and the placeholder offset above positions the text instead.
3897
5005
  {
3898
5006
  hasChips: true,
3899
5007
  isFilterable: true,
3900
5008
  class: {
3901
- input: 'min-w-16 ms-1'
5009
+ input: 'min-w-16'
5010
+ }
5011
+ }, {
5012
+ hasChips: true,
5013
+ isFilterable: true,
5014
+ hasSelection: true,
5015
+ class: {
5016
+ input: 'ms-1'
3902
5017
  }
3903
5018
  }],
3904
5019
  defaultVariants: {
@@ -3940,9 +5055,60 @@ const datePicker = tv({
3940
5055
  // renders it, not `SegmentGroup` -- it separates groups rather than
3941
5056
  // living inside one.
3942
5057
  separator: 'text-neutral px-1',
3943
- calendarButton: 'pointer-events-auto'
5058
+ calendarButton: 'pointer-events-auto',
5059
+ // The popover's body: the calendar, and beside it the time columns of an
5060
+ // `hour` or `minute` granularity. Stacked on narrow screens, where a
5061
+ // calendar and two columns side by side no longer fit.
5062
+ panels: 'flex flex-col sm:flex-row',
5063
+ // The columns must not make the popover taller than the calendar: they
5064
+ // scroll within its height instead. That height is only known once the
5065
+ // calendar is laid out, so the columns are taken out of flow
5066
+ // (`timeColumns` is absolute) and this box, which stretches to the row,
5067
+ // reserves their width: `--time-columns` (set by the component) of them,
5068
+ // 3.5rem each, with the gaps and padding between.
5069
+ time: ['relative shrink-0', 'border-t border-neutral-soft sm:border-t-0 sm:border-s', 'sm:w-[calc(var(--time-columns)*3.75rem+0.75rem)]'],
5070
+ timeColumns: 'flex justify-center gap-1 p-2 h-56 sm:absolute sm:inset-0 sm:h-auto',
5071
+ timeColumn: 'flex flex-col w-14 min-h-0',
5072
+ // The column's accessible name as well as its heading, so it takes
5073
+ // `neutral-firm` (AA) rather than the weekday row's lighter `neutral`.
5074
+ timeColumnLabel: 'h-8 shrink-0 text-caption-sm text-neutral-firm text-center leading-8 truncate',
5075
+ // Positioned so the options measure their `offsetTop` against the list:
5076
+ // the component scrolls the selected option into view itself (see
5077
+ // `revealWithin`). The padding keeps the focus ring inside the clip.
5078
+ timeList: ['relative flex flex-col gap-0.5 flex-1 min-h-0 p-1', 'overflow-y-auto overscroll-contain', '[scrollbar-width:thin]'],
5079
+ timeOption: [...focusVisibleRing, 'shrink-0 h-9 rounded-md', 'text-body-sm text-neutral-strong tabular-nums', 'cursor-pointer select-none', 'transition-colors duration-200 motion-reduce:transition-none',
5080
+ // Excluded from the selected option, which gets its own hover per
5081
+ // color -- see the calendar's `day` slot for why.
5082
+ 'not-data-[selected=true]:hover:bg-surface-overlay-soft',
5083
+ // A read-only column moves focus but picks nothing.
5084
+ 'in-aria-readonly:cursor-default in-aria-readonly:hover:bg-transparent']
3944
5085
  },
3945
5086
  variants: {
5087
+ // The selected time option takes the calendar's selected-day fill, so
5088
+ // the day and the time picked read as one choice.
5089
+ color: {
5090
+ neutral: {
5091
+ timeOption: 'data-[selected=true]:bg-neutral-strong data-[selected=true]:text-on-neutral-strong data-[selected=true]:hover:bg-neutral-bolder'
5092
+ },
5093
+ primary: {
5094
+ timeOption: 'data-[selected=true]:bg-primary data-[selected=true]:text-on-primary data-[selected=true]:hover:bg-primary-firm'
5095
+ },
5096
+ secondary: {
5097
+ timeOption: 'data-[selected=true]:bg-secondary data-[selected=true]:text-on-secondary data-[selected=true]:hover:bg-secondary-firm'
5098
+ },
5099
+ tertiary: {
5100
+ timeOption: 'data-[selected=true]:bg-tertiary data-[selected=true]:text-on-tertiary data-[selected=true]:hover:bg-tertiary-firm'
5101
+ },
5102
+ success: {
5103
+ timeOption: 'data-[selected=true]:bg-success data-[selected=true]:text-on-success data-[selected=true]:hover:bg-success-firm'
5104
+ },
5105
+ warning: {
5106
+ timeOption: 'data-[selected=true]:bg-warning data-[selected=true]:text-on-warning data-[selected=true]:hover:bg-warning-firm'
5107
+ },
5108
+ danger: {
5109
+ timeOption: 'data-[selected=true]:bg-danger data-[selected=true]:text-on-danger data-[selected=true]:hover:bg-danger-firm'
5110
+ }
5111
+ },
3946
5112
  // The trigger is a `<button>` whose text *is* the value, so with neither a
3947
5113
  // value nor a `@placeholder` it has no content at all and collapses to its
3948
5114
  // padding -- noticeably shorter than every other field on the form.
@@ -4016,7 +5182,8 @@ const datePicker = tv({
4016
5182
  }
4017
5183
  }],
4018
5184
  defaultVariants: {
4019
- size: 'md'
5185
+ size: 'md',
5186
+ color: 'primary'
4020
5187
  }
4021
5188
  });
4022
5189
 
@@ -4299,9 +5466,11 @@ var components = /*#__PURE__*/Object.freeze({
4299
5466
  __proto__: null,
4300
5467
  accordion: accordion,
4301
5468
  alert: alert,
5469
+ appLayout: appLayout,
4302
5470
  autocomplete: autocomplete,
4303
5471
  avatar: avatar,
4304
5472
  backdrop: backdrop,
5473
+ bottomNav: bottomNav,
4305
5474
  breadcrumbs: breadcrumbs,
4306
5475
  button: button,
4307
5476
  buttonGroup: buttonGroup,
@@ -4337,6 +5506,7 @@ var components = /*#__PURE__*/Object.freeze({
4337
5506
  listboxItem: listboxItem,
4338
5507
  modal: modal,
4339
5508
  nativeSelect: nativeSelect,
5509
+ navItem: navItem,
4340
5510
  notificationCard: notificationCard,
4341
5511
  notificationsContainer: notificationsContainer,
4342
5512
  overlay: overlay,
@@ -4351,6 +5521,7 @@ var components = /*#__PURE__*/Object.freeze({
4351
5521
  select: select,
4352
5522
  skeleton: skeleton,
4353
5523
  spinner: spinner,
5524
+ stepper: stepper,
4354
5525
  switchInput: switchInput,
4355
5526
  table: table,
4356
5527
  tabs: tabs,