@nextlyhq/ui 0.0.2-alpha.73 → 0.0.2-alpha.75

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.mjs CHANGED
@@ -2,12 +2,12 @@
2
2
  import { Slot } from "@radix-ui/react-slot";
3
3
  import { cva } from "class-variance-authority";
4
4
  import * as React from "react";
5
- import { Fragment, cloneElement, createContext, forwardRef, useCallback, useContext, useEffect, useId, useRef } from "react";
5
+ import { Fragment, cloneElement, createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef } from "react";
6
6
  import { clsx } from "clsx";
7
7
  import { twMerge } from "tailwind-merge";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { Root } from "@radix-ui/react-label";
10
- import { AlertCircle, AlertTriangle, Check, CheckCircle2, ChevronDown, ChevronRight, ChevronUp, Circle, FileQuestion, GripVertical, Info, Loader2, Minus, Pipette, Search, X, XCircle } from "lucide-react";
10
+ import { AlertCircle, AlertTriangle, Check, CheckCircle2, ChevronDown, ChevronRight, ChevronUp, Circle, CircleHelp, FileQuestion, GripVertical, Info, Loader2, Minus, Pipette, Search, TriangleAlert, X, XCircle } from "lucide-react";
11
11
  import { Content, Portal, Provider, Root as Root$1, Trigger } from "@radix-ui/react-tooltip";
12
12
  import * as SeparatorPrimitive from "@radix-ui/react-separator";
13
13
  import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
@@ -24,9 +24,9 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
24
24
  import * as SelectPrimitive from "@radix-ui/react-select";
25
25
  import { Command as Command$1, defaultFilter, useCommandState } from "cmdk";
26
26
  import { Toaster as Toaster$1, toast } from "sonner";
27
+ import { useVirtualizer } from "@tanstack/react-virtual";
27
28
  import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
28
29
  import * as ResizablePrimitive from "react-resizable-panels";
29
- import { useVirtualizer } from "@tanstack/react-virtual";
30
30
  import * as SliderPrimitive from "@radix-ui/react-slider";
31
31
  // src/lib/utils.ts
32
32
  /**
@@ -63,12 +63,12 @@ function cn(...inputs) {
63
63
  * Note: 'primary' is a semantic alias for 'default' variant for better code readability
64
64
  * @experimental
65
65
  */
66
- const buttonVariants = cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-all duration-150 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed active:scale-[0.98] [&_svg]:text-current", {
66
+ const buttonVariants = cva(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-all duration-150 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring [.overflow-hidden>&]:focus-visible:outline-offset-[-2px] [.overflow-hidden>&]:focus-visible:shadow-[inset_0_0_0_4px_var(--nx-background)] disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed active:scale-[0.98] [&_svg]:text-current`, {
67
67
  variants: {
68
68
  variant: {
69
69
  default: "bg-primary text-primary-foreground border border-transparent hover:opacity-90",
70
70
  primary: "bg-primary text-primary-foreground border border-transparent hover:opacity-90",
71
- destructive: "bg-destructive-solid text-destructive-foreground border border-transparent hover:bg-destructive-600",
71
+ destructive: "bg-destructive-solid text-destructive-foreground border border-transparent hover:bg-destructive-hover",
72
72
  outline: "border border-border text-foreground hover-unified bg-background",
73
73
  secondary: "bg-background border border-border text-foreground hover:bg-primary/5",
74
74
  ghost: "text-foreground border border-transparent hover-unified",
@@ -252,6 +252,15 @@ const FormLabelWithTooltip = React.forwardRef(({ className, labelClassName, tool
252
252
  });
253
253
  });
254
254
  FormLabelWithTooltip.displayName = "FormLabelWithTooltip";
255
+ // src/components/badge.tsx
256
+ /** The arms `badgeVariants` is built from. Its type is read from them: {@link VariantsFn}. */
257
+ /** The status variants, and the solid each one's dot is drawn in. */
258
+ const STATUS_DOT = {
259
+ success: "bg-success-solid",
260
+ warning: "bg-warning-solid",
261
+ destructive: "bg-danger-solid",
262
+ info: "bg-info-solid"
263
+ };
255
264
  /**
256
265
  * Badge Component - Design System Specification
257
266
  *
@@ -270,34 +279,40 @@ FormLabelWithTooltip.displayName = "FormLabelWithTooltip";
270
279
  * - Padding: 2px 10px (vertical × horizontal)
271
280
  * - Border radius: Full (pill shape)
272
281
  * - Font: 12px (text-xs), medium weight (500)
273
- * - Colors: Light backgrounds with dark text for visibility in both light/dark modes
274
- *
275
- * Variants (6 total per design spec):
276
- * - default: Light gray background
277
- * - primary: Light blue background
278
- * - success: Light green background
279
- * - warning: Light amber background
280
- * - destructive: Light red background
281
- * - outline: Transparent background with border border-border
282
+ * - Status variants (success, warning, destructive, info): a neutral chip with
283
+ * a 6px dot in the status's solid colour before the label
284
+ *
285
+ * Variants:
286
+ * - default: muted background
287
+ * - primary: primary tint
288
+ * - success, warning, destructive, info: quiet chip with a status dot
289
+ * - outline: transparent background with a border
282
290
  * @experimental
283
291
  */
284
- const badgeVariants = cva("inline-flex items-center rounded-sm px-2.5 py-0.5 h-[22px] text-xs font-medium transition-colors", {
292
+ const badgeVariants = cva("inline-flex items-center gap-1.5 rounded-sm px-2.5 py-0.5 h-[22px] text-xs font-medium transition-colors", {
285
293
  variants: { variant: {
286
294
  default: "bg-muted text-foreground",
287
295
  primary: "bg-primary/10 text-primary dark:bg-primary/20",
288
- success: "bg-success-100 text-success-700 dark:bg-success-900 dark:text-success-100",
289
- warning: "bg-warning-100 text-warning-700 dark:bg-warning-900 dark:text-warning-100",
290
- destructive: "bg-destructive-100 text-destructive-700 dark:bg-destructive-900 dark:text-destructive-100",
296
+ success: "border border-border bg-card text-foreground",
297
+ warning: "border border-border bg-card text-foreground",
298
+ destructive: "border border-border bg-card text-foreground",
299
+ info: "border border-border bg-card text-foreground",
291
300
  outline: "border border-border bg-transparent text-foreground dark:text-muted-foreground dark:border-border"
292
301
  } },
293
302
  defaultVariants: { variant: "default" }
294
303
  });
295
304
  /** @public */
296
- function Badge({ className, variant = "default", ...props }) {
297
- return /* @__PURE__ */ jsx("div", {
305
+ function Badge({ className, variant = "default", children, ...props }) {
306
+ const dot = variant && variant in STATUS_DOT ? STATUS_DOT[variant] : null;
307
+ return /* @__PURE__ */ jsxs("div", {
298
308
  "data-slot": `badge.${variant}`,
299
309
  className: cn(badgeVariants({ variant }), className),
300
- ...props
310
+ ...props,
311
+ children: [dot ? /* @__PURE__ */ jsx("span", {
312
+ "aria-hidden": "true",
313
+ "data-slot": "badge-dot",
314
+ className: cn("size-1.5 shrink-0 rounded-full", dot)
315
+ }) : null, children]
301
316
  });
302
317
  }
303
318
  /**
@@ -528,11 +543,12 @@ Stat.displayName = "Stat";
528
543
  * - Padding: 16px (p-4)
529
544
  * - Border radius: `rounded-md`, one step tighter than Card's `rounded-lg`
530
545
  * for inline/flow content vs. larger container components
531
- * - Border: 1px solid matching variant color
546
+ * - Border: 1px; the card border for info and success, the status border for
547
+ * warning and destructive
532
548
  * - Shadow: sm (subtle elevation)
533
549
  * - Font: 14px (text-sm)
534
550
  * - Layout: Flex with gap-3 for icon/content spacing
535
- * - Colors: Light backgrounds with dark text for WCAG 2.2 AA compliance
551
+ * - Colors: the page's foreground text; the icon in the status's text colour
536
552
  *
537
553
  * Variants (4 total):
538
554
  * - info (default): Blue - informational messages, neutral announcements
@@ -589,10 +605,10 @@ Stat.displayName = "Stat";
589
605
  */
590
606
  const alertVariants = cva("relative flex items-start gap-3 rounded-md border border-border p-4 text-sm transition-colors duration-150", {
591
607
  variants: { variant: {
592
- info: "bg-primary/5 text-primary",
593
- success: "border-success-200 bg-success-50 text-success-900 border-l-4 border-l-success dark:border-success-900 dark:border-l-success dark:bg-success-950 dark:text-success-100",
594
- warning: "border-warning-200 bg-warning-50 text-warning-900 border-l-4 border-l-warning dark:border-warning-900 dark:border-l-warning dark:bg-warning-950 dark:text-warning-100",
595
- destructive: "border-destructive-200 bg-destructive-50 text-destructive-900 border-l-4 border-l-destructive dark:border-destructive-900 dark:border-l-destructive dark:bg-destructive-950 dark:text-destructive-100"
608
+ info: "border-border bg-card text-foreground [&>svg]:text-info-text",
609
+ success: "border-border bg-card text-foreground [&>svg]:text-success-text",
610
+ warning: "border-warning-border bg-warning-surface text-foreground [&>svg]:text-warning-text",
611
+ destructive: "border-danger-border bg-danger-surface text-foreground [&>svg]:text-danger-text"
596
612
  } },
597
613
  defaultVariants: { variant: "info" }
598
614
  });
@@ -745,12 +761,13 @@ function Separator({ className, orientation = "horizontal", decorative = true, .
745
761
  * @see {@link https://adrianroselli.com/2020/11/more-accessible-skeletons.html More Accessible Skeletons}
746
762
  * @experimental
747
763
  */
748
- const Skeleton = React.forwardRef(({ className, ...props }, ref) => {
764
+ const Skeleton = React.forwardRef(({ className, still = false, ...props }, ref) => {
749
765
  return /* @__PURE__ */ jsx("div", {
750
766
  ref,
751
767
  "data-slot": "skeleton",
768
+ "data-still": still ? "" : void 0,
752
769
  "aria-hidden": "true",
753
- className: cn("bg-primary/5 animate-pulse rounded-md motion-reduce:animate-none", className),
770
+ className: cn(still ? "bg-secondary rounded-md" : "bg-primary/5 animate-pulse rounded-md motion-reduce:animate-none", className),
754
771
  ...props
755
772
  });
756
773
  });
@@ -765,7 +782,7 @@ Skeleton.displayName = "Skeleton";
765
782
  const progressVariants = cva("h-full rounded-none transition-all", {
766
783
  variants: { variant: {
767
784
  default: "bg-primary-500",
768
- success: "bg-success-500",
785
+ success: "bg-success-solid",
769
786
  error: "bg-destructive"
770
787
  } },
771
788
  defaultVariants: { variant: "default" }
@@ -1376,7 +1393,7 @@ const TabsList = forwardRef(({ className, variant, scrollable = false, ...props
1376
1393
  });
1377
1394
  });
1378
1395
  TabsList.displayName = List.displayName;
1379
- const tabsTriggerVariants = cva("inline-flex items-center justify-center whitespace-nowrap rounded-none bg-transparent px-4 py-2 font-medium cursor-pointer transition-all duration-200 border-b-2 relative -mb-0.5 data-[state=active]:border-b-primary data-[state=active]:text-primary data-[state=inactive]:border-transparent data-[state=inactive]:text-muted-foreground hover:text-primary hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed data-[orientation=vertical]:border-b-0 data-[orientation=vertical]:mb-0 data-[orientation=vertical]:border-r-2 data-[orientation=vertical]:-mr-0.5 data-[orientation=vertical]:data-[state=active]:border-r-primary", {
1396
+ const tabsTriggerVariants = cva("inline-flex items-center justify-center whitespace-nowrap rounded-none bg-transparent px-4 py-2 font-medium cursor-pointer transition-all duration-200 border-b-2 relative -mb-0.5 data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=inactive]:border-transparent data-[state=inactive]:text-muted-foreground hover:text-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed data-[orientation=vertical]:border-b-0 data-[orientation=vertical]:mb-0 data-[orientation=vertical]:border-r-2 data-[orientation=vertical]:-mr-0.5 data-[orientation=vertical]:data-[state=active]:border-r-primary", {
1380
1397
  variants: { size: {
1381
1398
  default: "text-sm",
1382
1399
  sm: "text-xs"
@@ -2239,6 +2256,65 @@ const sheetVariants = cva("fixed z-50 gap-4 bg-background p-6 shadow-lg will-cha
2239
2256
  } },
2240
2257
  defaultVariants: { side: "right" }
2241
2258
  });
2259
+ /** How far down, as a share of the sheet's height, a drag must go to close it. */
2260
+ const DISMISS_SHARE = .25;
2261
+ /** A release faster than this, in px per ms, closes it from a shorter drag. */
2262
+ const FLICK_SPEED = .6;
2263
+ /** The shortest drag a flick closes from, so a tap never closes the sheet. */
2264
+ const FLICK_MIN_DISTANCE = 24;
2265
+ /** Whether a drag released at `distance` after `elapsed` ms closes the sheet. */
2266
+ function dragCloses(distance, elapsed, height) {
2267
+ if (distance >= height * DISMISS_SHARE) return true;
2268
+ return distance >= FLICK_MIN_DISTANCE && distance / Math.max(elapsed, 1) >= FLICK_SPEED;
2269
+ }
2270
+ /**
2271
+ * The grab strip: the sheet follows the pointer down (never up), and on
2272
+ * release either closes or springs back. It moves the sheet with an inline
2273
+ * transform, so the closing slide continues from where the finger let go.
2274
+ */
2275
+ function SheetDragHandle({ onDismiss }) {
2276
+ const drag = React.useRef(null);
2277
+ const onPointerDown = (event) => {
2278
+ const sheet = event.currentTarget.closest("[data-slot='sheet-content']");
2279
+ if (!sheet) return;
2280
+ event.currentTarget.setPointerCapture?.(event.pointerId);
2281
+ drag.current = {
2282
+ y: event.clientY,
2283
+ time: performance.now(),
2284
+ height: sheet.getBoundingClientRect().height,
2285
+ sheet
2286
+ };
2287
+ sheet.style.transition = "none";
2288
+ };
2289
+ const onPointerMove = (event) => {
2290
+ const start = drag.current;
2291
+ if (!start) return;
2292
+ const distance = Math.max(0, event.clientY - start.y);
2293
+ start.sheet.style.transform = `translateY(${distance}px)`;
2294
+ };
2295
+ const release = (event, cancelled) => {
2296
+ const start = drag.current;
2297
+ if (!start) return;
2298
+ drag.current = null;
2299
+ start.sheet.style.transition = "";
2300
+ const distance = Math.max(0, event.clientY - start.y);
2301
+ if (!cancelled && dragCloses(distance, performance.now() - start.time, start.height)) {
2302
+ onDismiss();
2303
+ return;
2304
+ }
2305
+ start.sheet.style.transform = "";
2306
+ };
2307
+ return /* @__PURE__ */ jsx("div", {
2308
+ "aria-hidden": "true",
2309
+ "data-slot": "sheet-drag-handle",
2310
+ className: "flex h-6 w-full shrink-0 cursor-grab touch-none items-center justify-center active:cursor-grabbing",
2311
+ onPointerDown,
2312
+ onPointerMove,
2313
+ onPointerUp: (event) => release(event, false),
2314
+ onPointerCancel: (event) => release(event, true),
2315
+ children: /* @__PURE__ */ jsx("span", { className: "h-1 w-10 rounded-full bg-border" })
2316
+ });
2317
+ }
2242
2318
  /**
2243
2319
  * SheetContent
2244
2320
  *
@@ -2253,17 +2329,24 @@ const sheetVariants = cva("fixed z-50 gap-4 bg-background p-6 shadow-lg will-cha
2253
2329
  * @param side - Which edge to slide in from: "left", "right", "top", "bottom"
2254
2330
  * @public
2255
2331
  */
2256
- const SheetContent = React.forwardRef(({ side = "right", className, children, ...props }, ref) => {
2332
+ const SheetContent = React.forwardRef(({ side = "right", className, children, dragHandle = false, ...props }, ref) => {
2257
2333
  const portalContainer = usePortalContainer();
2258
2334
  const modal = React.useContext(SheetModalContext);
2335
+ const close = React.useRef(null);
2336
+ const draggable = dragHandle && side === "bottom";
2259
2337
  return /* @__PURE__ */ jsxs(SheetPortal, {
2260
2338
  container: portalContainer,
2261
- children: [modal ? /* @__PURE__ */ jsx(SheetOverlay, {}) : null, /* @__PURE__ */ jsx(DialogPrimitive.Content, {
2339
+ children: [modal ? /* @__PURE__ */ jsx(SheetOverlay, {}) : null, /* @__PURE__ */ jsxs(DialogPrimitive.Content, {
2262
2340
  ref,
2263
2341
  "data-slot": "sheet-content",
2264
2342
  className: cn(sheetVariants({ side }), className),
2265
2343
  ...props,
2266
- children
2344
+ children: [draggable ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SheetDragHandle, { onDismiss: () => close.current?.click() }), /* @__PURE__ */ jsx(DialogPrimitive.Close, {
2345
+ ref: close,
2346
+ hidden: true,
2347
+ tabIndex: -1,
2348
+ "aria-hidden": "true"
2349
+ })] }) : null, children]
2267
2350
  })]
2268
2351
  });
2269
2352
  });
@@ -2387,7 +2470,7 @@ const CommandDialog = ({ children, commandProps, contentProps, ...props }) => {
2387
2470
  children: [/* @__PURE__ */ jsx(CommandDialogOverlay, {}), /* @__PURE__ */ jsx(DialogPrimitive.Content, {
2388
2471
  ...contentProps,
2389
2472
  "data-slot": "command-content",
2390
- className: cn("fixed left-[50%] top-[50%] z-[100] translate-x-[-50%] translate-y-[-50%]", "w-full max-w-lg", "max-h-[85vh]", "sm:max-w-lg", "max-w-full", "m-4 sm:m-0", "overflow-hidden rounded-lg border border-border bg-background shadow-xl", "duration-200", "data-[state=open]:animate-in data-[state=closed]:animate-out", "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", "data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%]"),
2473
+ className: cn("fixed left-[50%] top-[13vh] z-[100] translate-x-[-50%]", "w-full max-w-lg", "max-h-[80vh]", "sm:max-w-lg", "max-w-full", "m-4 sm:m-0", "overflow-hidden rounded-lg border border-border bg-background shadow-xl", "duration-200", "data-[state=open]:animate-in data-[state=closed]:animate-out", "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", "data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2"),
2391
2474
  children: /* @__PURE__ */ jsx(Command, {
2392
2475
  ...commandProps,
2393
2476
  className: cn("[&_[cmdk-group-heading]]:px-3 [&_[cmdk-group-heading]]:py-2 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wide [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:mb-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-3 [&_[cmdk-item]]:py-2 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4", commandProps?.className),
@@ -2464,7 +2547,7 @@ CommandSeparator.displayName = "CommandSeparator";
2464
2547
  */
2465
2548
  const CommandItem = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Command$1.Item, {
2466
2549
  ref,
2467
- className: cn("relative flex cursor-pointer select-none items-center gap-3", "min-h-[44px] sm:min-h-[36px]", "px-3 py-2.5", "rounded-sm text-base sm:text-sm outline-none", "transition-all duration-200 ease-(--ease-premium)", "hover-unified", "aria-selected:bg-primary/5 aria-selected:text-primary", "data-[selected=true]:bg-primary/5 data-[selected=true]:text-primary", "data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50", className),
2550
+ className: cn("relative flex cursor-pointer select-none items-center gap-3", "min-h-[44px] sm:min-h-[36px]", "px-3 py-2.5", "rounded-sm text-base sm:text-sm outline-none", "transition-all duration-200 ease-(--ease-premium)", "hover-unified", "aria-selected:bg-primary/5 aria-selected:text-foreground", "data-[selected=true]:bg-primary/5 data-[selected=true]:text-foreground", "data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50", className),
2468
2551
  ...props
2469
2552
  }));
2470
2553
  CommandItem.displayName = "CommandItem";
@@ -2712,7 +2795,15 @@ function Toaster({ theme = "system", ...props }) {
2712
2795
  "--normal-border": "var(--nx-border)",
2713
2796
  "--border-radius": "0px",
2714
2797
  "--success-bg": "var(--nx-toast-success-bg)",
2715
- "--success-text": "var(--nx-toast-success-text)"
2798
+ "--success-text": "var(--nx-toast-success-text)",
2799
+ "--warning-bg": "var(--nx-toast-warning-bg)",
2800
+ "--warning-text": "var(--nx-toast-warning-text)",
2801
+ "--error-bg": "var(--nx-danger-surface)",
2802
+ "--error-border": "var(--nx-danger-border)",
2803
+ "--error-text": "var(--nx-danger-text)",
2804
+ "--info-bg": "var(--nx-info-surface)",
2805
+ "--info-border": "var(--nx-info-border)",
2806
+ "--info-text": "var(--nx-info-text)"
2716
2807
  },
2717
2808
  ...props
2718
2809
  });
@@ -3612,6 +3703,963 @@ function ColorPicker({ color, onColorChange, swatches = [], onSwatchSelect, rece
3612
3703
  ]
3613
3704
  });
3614
3705
  }
3706
+ // src/components/icon-glyph.tsx
3707
+ /** The shape elements a body may contain. */
3708
+ const SHAPES = /* @__PURE__ */ new Set([
3709
+ "path",
3710
+ "circle",
3711
+ "ellipse",
3712
+ "line",
3713
+ "polygon",
3714
+ "polyline",
3715
+ "rect"
3716
+ ]);
3717
+ /** The attributes a shape may carry: geometry, and its fill. */
3718
+ const GEOMETRY = /* @__PURE__ */ new Set([
3719
+ "d",
3720
+ "cx",
3721
+ "cy",
3722
+ "r",
3723
+ "rx",
3724
+ "ry",
3725
+ "x",
3726
+ "y",
3727
+ "x1",
3728
+ "x2",
3729
+ "y1",
3730
+ "y2",
3731
+ "width",
3732
+ "height",
3733
+ "points",
3734
+ "fill"
3735
+ ]);
3736
+ /** The fills a shape may name: none, or the text colour. */
3737
+ const FILLS = /* @__PURE__ */ new Set(["none", "currentColor"]);
3738
+ /**
3739
+ * Read bodies, by body. A picker draws the same few hundred icons on every
3740
+ * scroll, and reading each once is what keeps a scroll from re-reading them.
3741
+ * Bounded so a host searching several large sets cannot grow it without end.
3742
+ */
3743
+ const readBodies = /* @__PURE__ */ new Map();
3744
+ const READ_BODIES_LIMIT = 4096;
3745
+ /** One element and the attributes after its name, anchored where the last one ended. */
3746
+ const ELEMENT = /\s*<([a-z]+)((?:\s+[a-zA-Z0-9-]+="[^"<>]*")*)\s*\/>/y;
3747
+ const ATTRIBUTE = /([a-zA-Z0-9-]+)="([^"<>]*)"/g;
3748
+ /** A shape's attributes, or `null` when any is not allowed geometry. */
3749
+ function readAttributes(text) {
3750
+ const attributes = {};
3751
+ for (const [, name = "", value = ""] of text.matchAll(ATTRIBUTE)) {
3752
+ if (!(GEOMETRY.has(name) && (name !== "fill" || FILLS.has(value)))) return null;
3753
+ attributes[name] = value;
3754
+ }
3755
+ return attributes;
3756
+ }
3757
+ /** The shape at `at` and where it ends, or `null` when none starts there. */
3758
+ function readShape(body, at) {
3759
+ ELEMENT.lastIndex = at;
3760
+ const match = ELEMENT.exec(body);
3761
+ const tag = match?.[1];
3762
+ if (match === null || tag === void 0 || !SHAPES.has(tag)) return null;
3763
+ const attributes = readAttributes(match[2] ?? "");
3764
+ return attributes === null ? null : {
3765
+ shape: {
3766
+ tag,
3767
+ attributes
3768
+ },
3769
+ end: ELEMENT.lastIndex
3770
+ };
3771
+ }
3772
+ /**
3773
+ * A body read as shapes, or `null` when any part of it is not one: every
3774
+ * element must be an allowed shape, every attribute allowed geometry, and
3775
+ * nothing may sit between the elements but whitespace.
3776
+ */
3777
+ function readBody(body) {
3778
+ const cached = readBodies.get(body);
3779
+ if (cached !== void 0) return cached;
3780
+ let shapes = [];
3781
+ let at = 0;
3782
+ while (shapes !== null && body.slice(at).trim() !== "") {
3783
+ const read = readShape(body, at);
3784
+ if (read === null) shapes = null;
3785
+ else {
3786
+ shapes.push(read.shape);
3787
+ at = read.end;
3788
+ }
3789
+ }
3790
+ if (readBodies.size >= READ_BODIES_LIMIT) readBodies.clear();
3791
+ readBodies.set(body, shapes);
3792
+ return shapes;
3793
+ }
3794
+ /**
3795
+ * An icon from an {@link IconSource}, drawn as an inline SVG in the text
3796
+ * colour.
3797
+ *
3798
+ * Decorative by default (`aria-hidden`): the control around it names the
3799
+ * icon. The body is read into React elements rather than inserted as markup,
3800
+ * and a body that is not a run of plain shapes draws an empty box.
3801
+ *
3802
+ * @experimental
3803
+ */
3804
+ function IconGlyph({ icon, className, ...props }) {
3805
+ const shapes = readBody(icon.body) ?? [];
3806
+ const stroked = icon.stroked !== false;
3807
+ return /* @__PURE__ */ jsx("svg", {
3808
+ xmlns: "http://www.w3.org/2000/svg",
3809
+ viewBox: icon.viewBox,
3810
+ "aria-hidden": "true",
3811
+ focusable: "false",
3812
+ fill: stroked ? "none" : "currentColor",
3813
+ stroke: stroked ? "currentColor" : "none",
3814
+ strokeWidth: stroked ? 2 : void 0,
3815
+ strokeLinecap: stroked ? "round" : void 0,
3816
+ strokeLinejoin: stroked ? "round" : void 0,
3817
+ className: cn("size-4 shrink-0", className),
3818
+ ...props,
3819
+ children: shapes.map((shape, index) => React.createElement(shape.tag, {
3820
+ key: index,
3821
+ ...shape.attributes
3822
+ }))
3823
+ });
3824
+ }
3825
+ /**
3826
+ * An icon's name as a person reads it: `circle-arrow-up` is
3827
+ * `Circle arrow up`.
3828
+ */
3829
+ function iconDisplayName(name) {
3830
+ const words = name.replace(/-/g, " ").trim();
3831
+ return words.charAt(0).toUpperCase() + words.slice(1);
3832
+ }
3833
+ // src/components/icon-picker.tsx
3834
+ /** Icons per row of the results grid. */
3835
+ const COLUMNS = 8;
3836
+ /** One row of the grid: a 38px cell and the 2px gap below it. */
3837
+ const ROW_HEIGHT$1 = 40;
3838
+ /** Rows a Page Up or Page Down moves the highlight by. */
3839
+ const PAGE_ROWS = 5;
3840
+ /** How the picker's headings are set: small capitals in the muted ink. */
3841
+ const HEADING_TEXT = "px-3 pb-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground";
3842
+ /** A heading inside the grid, "Recent" or "All icons": its line and the space above. */
3843
+ const HEADING_HEIGHT = 28;
3844
+ /** How many recently used icons the picker offers: one row of the grid. */
3845
+ const RECENT_SHOWN = COLUMNS;
3846
+ const loads = /* @__PURE__ */ new WeakMap();
3847
+ const loaded = /* @__PURE__ */ new WeakMap();
3848
+ function loadOnce(load) {
3849
+ const existing = loads.get(load);
3850
+ if (existing !== void 0) return existing;
3851
+ const loading = load();
3852
+ loads.set(load, loading);
3853
+ loading.then((source) => loaded.set(load, source), () => {
3854
+ if (loads.get(load) === loading) loads.delete(load);
3855
+ });
3856
+ return loading;
3857
+ }
3858
+ /**
3859
+ * The icon source, loaded once `wanted` turns true, and a way to try again
3860
+ * after a failed load.
3861
+ */
3862
+ function useIconSource(load, wanted) {
3863
+ const [state, setState] = React.useState(() => {
3864
+ const source = loaded.get(load);
3865
+ return source === void 0 ? { status: "loading" } : {
3866
+ status: "ready",
3867
+ source
3868
+ };
3869
+ });
3870
+ const [attempt, setAttempt] = React.useState(0);
3871
+ React.useEffect(() => {
3872
+ if (!wanted) return;
3873
+ let current = true;
3874
+ setState((previous) => previous.status === "ready" ? previous : { status: "loading" });
3875
+ loadOnce(load).then((source) => {
3876
+ if (current) setState({
3877
+ status: "ready",
3878
+ source
3879
+ });
3880
+ }, () => {
3881
+ if (current) setState({ status: "failed" });
3882
+ });
3883
+ return () => {
3884
+ current = false;
3885
+ };
3886
+ }, [
3887
+ load,
3888
+ wanted,
3889
+ attempt
3890
+ ]);
3891
+ return [state, () => setAttempt((n) => n + 1)];
3892
+ }
3893
+ /**
3894
+ * What a stored id draws as, once the source can say, and a way to ask again
3895
+ * after the asking failed.
3896
+ */
3897
+ function useResolvedIcon(source, id) {
3898
+ const [resolved, setResolved] = React.useState(null);
3899
+ const [attempt, setAttempt] = React.useState(0);
3900
+ const ready = source.status === "ready" ? source.source : null;
3901
+ React.useEffect(() => {
3902
+ if (ready === null || !id) return;
3903
+ let current = true;
3904
+ ready.resolve(id).then((icon) => {
3905
+ if (!current) return;
3906
+ setResolved({
3907
+ id,
3908
+ attempt,
3909
+ answer: icon === null ? { status: "missing" } : {
3910
+ status: "found",
3911
+ icon
3912
+ }
3913
+ });
3914
+ }, () => {
3915
+ if (current) setResolved({
3916
+ id,
3917
+ attempt,
3918
+ answer: { status: "failed" }
3919
+ });
3920
+ });
3921
+ return () => {
3922
+ current = false;
3923
+ };
3924
+ }, [
3925
+ ready,
3926
+ id,
3927
+ attempt
3928
+ ]);
3929
+ const retry = () => setAttempt((n) => n + 1);
3930
+ if (!id) return [{ status: "none" }, retry];
3931
+ if (resolved?.id === id && (resolved.answer.status !== "failed" || resolved.attempt === attempt)) return [resolved.answer, retry];
3932
+ return [source.status === "failed" ? { status: "failed" } : { status: "loading" }, retry];
3933
+ }
3934
+ /** The set and name an id carries, read without the set: `lucide:star`. */
3935
+ function partsOf(id) {
3936
+ const colon = id.indexOf(":");
3937
+ return colon === -1 ? {
3938
+ set: "",
3939
+ name: id
3940
+ } : {
3941
+ set: id.slice(0, colon),
3942
+ name: id.slice(colon + 1)
3943
+ };
3944
+ }
3945
+ /** The rows of icons from `start` up to `end`, eight to a row. */
3946
+ function iconRows(start, end) {
3947
+ const rows = [];
3948
+ for (let at = start; at < end; at += COLUMNS) rows.push({
3949
+ kind: "icons",
3950
+ start: at,
3951
+ end: Math.min(end, at + COLUMNS)
3952
+ });
3953
+ return rows;
3954
+ }
3955
+ /**
3956
+ * The grid's rows: the recently used icons under "Recent" and the rest under
3957
+ * `label` ("All icons", or the search's matches) when there are any recent
3958
+ * ones to show, otherwise the icons alone, under the heading above the grid.
3959
+ */
3960
+ function gridRows(recentCount, count, label) {
3961
+ if (recentCount === 0) return iconRows(0, count);
3962
+ return [
3963
+ {
3964
+ kind: "heading",
3965
+ label: "Recent"
3966
+ },
3967
+ ...iconRows(0, recentCount),
3968
+ {
3969
+ kind: "heading",
3970
+ label
3971
+ },
3972
+ ...iconRows(recentCount, count)
3973
+ ];
3974
+ }
3975
+ /** What the icons below the Recent row are: the whole set, or a search's matches. */
3976
+ function resultsLabel(query) {
3977
+ return query === "" ? "All icons" : `Matches for “${query}”`;
3978
+ }
3979
+ /** The rows the arrow and page keys move the highlight up or down by. */
3980
+ const ROW_STEPS = {
3981
+ ArrowUp: -1,
3982
+ ArrowDown: 1,
3983
+ PageUp: -5,
3984
+ PageDown: PAGE_ROWS
3985
+ };
3986
+ /**
3987
+ * Where a key moves the highlight from `active` in the grid's rows, or
3988
+ * `undefined` for a key the grid does not answer. Left and right move by one
3989
+ * icon, across rows; up and down move by rows of icons, past a heading,
3990
+ * keeping the column, or the last icon of a shorter row. Up from the top row
3991
+ * stays put rather than jumping to the first icon.
3992
+ */
3993
+ function stepFrom(key, active, rows) {
3994
+ const icons = rows.filter((row) => row.kind === "icons");
3995
+ const last = icons.at(-1);
3996
+ if (last === void 0) return void 0;
3997
+ if (key === "ArrowLeft") return Math.max(0, active - 1);
3998
+ if (key === "ArrowRight") return Math.min(last.end - 1, active + 1);
3999
+ const step = ROW_STEPS[key];
4000
+ if (step === void 0) return void 0;
4001
+ const at = icons.findIndex((row) => active >= row.start && active < row.end);
4002
+ const from = icons[at];
4003
+ const to = icons[Math.min(icons.length - 1, Math.max(0, at + step))];
4004
+ if (from === void 0 || to === void 0) return void 0;
4005
+ return Math.min(to.end - 1, to.start + (active - from.start));
4006
+ }
4007
+ /** The row an option is drawn in, for scrolling it into view. */
4008
+ function rowOf(rows, index) {
4009
+ return Math.max(0, rows.findIndex((row) => row.kind === "icons" && index >= row.start && index < row.end));
4010
+ }
4011
+ /**
4012
+ * The recently used icons to offer, newest first: the ids the host remembers
4013
+ * that the set still draws, found among the whole set's icons, which the
4014
+ * picker has from the browse it opens on. Offered above a search's matches
4015
+ * too, so an icon used a moment ago is one press away whatever is typed.
4016
+ */
4017
+ function recentAmong(wholeSet, recentIds) {
4018
+ if (wholeSet === null || recentIds === void 0) return [];
4019
+ const byId = new Map(wholeSet.map((icon) => [icon.id, icon]));
4020
+ const recent = [];
4021
+ for (const id of new Set(recentIds)) {
4022
+ const icon = byId.get(id);
4023
+ if (icon !== void 0) recent.push(icon);
4024
+ if (recent.length === RECENT_SHOWN) break;
4025
+ }
4026
+ return recent;
4027
+ }
4028
+ /** What the picker's status line says, for the results in hand. */
4029
+ function announcementFor(results, failed, query) {
4030
+ if (results === null) return failed ? "The icons could not be loaded." : "Loading icons.";
4031
+ if (results.length === 0) return `No icons match “${query}”.`;
4032
+ const icons = `${results.length} ${results.length === 1 ? "icon" : "icons"}`;
4033
+ return query === "" ? `${icons}.` : `${icons} match “${query}”.`;
4034
+ }
4035
+ /**
4036
+ * The results for a query, and the highlighted one among them.
4037
+ *
4038
+ * The latest search wins: results arrive asynchronously, so a slow answer to
4039
+ * "tr" must not replace the answer to "truck" that came back first, and
4040
+ * until the query typed is answered the search is `pending`. Browsing (an
4041
+ * empty query) highlights the chosen icon, once `currentSettled` says which
4042
+ * icon `currentId` is; a search highlights its best match. The highlight is a
4043
+ * place among the options as drawn, which while browsing start with the
4044
+ * Recent row the host's `recentIds` give.
4045
+ */
4046
+ function useIconSearch(source, query, currentId, currentSettled, recentIds) {
4047
+ const [answer, setAnswer] = React.useState(null);
4048
+ const [wholeSet, setWholeSet] = React.useState(null);
4049
+ const [attempt, setAttempt] = React.useState(0);
4050
+ const [active, setActive] = React.useState(0);
4051
+ const [start, setStart] = React.useState(null);
4052
+ const placed = React.useRef(null);
4053
+ const place = React.useEffectEvent((found) => {
4054
+ if (found.status !== "found" || !currentSettled) return;
4055
+ placed.current = {
4056
+ answer: found,
4057
+ wholeSet
4058
+ };
4059
+ const browsing = found.query.trim() === "";
4060
+ const recent = recentAmong(browsing ? found.results : wholeSet, recentIds);
4061
+ const options = [...recent, ...found.results];
4062
+ const chosen = browsing && currentId ? options.findIndex((icon) => icon.id === currentId) : -1;
4063
+ const index = browsing ? Math.max(0, chosen) : found.results.length > 0 ? recent.length : 0;
4064
+ setActive(index);
4065
+ setStart({
4066
+ index,
4067
+ centred: chosen > 0
4068
+ });
4069
+ });
4070
+ const land = React.useEffectEvent((found) => {
4071
+ setAnswer(found);
4072
+ place(found);
4073
+ });
4074
+ const wantsRecent = recentIds !== void 0 && recentIds.length > 0;
4075
+ React.useEffect(() => {
4076
+ if (source === null || !wantsRecent) return;
4077
+ let current = true;
4078
+ source.search("").then((results) => {
4079
+ if (!current) return;
4080
+ setWholeSet(results);
4081
+ }, () => {});
4082
+ return () => {
4083
+ current = false;
4084
+ };
4085
+ }, [source, wantsRecent]);
4086
+ React.useEffect(() => {
4087
+ if (answer !== null && (placed.current?.answer !== answer || placed.current.wholeSet !== wholeSet)) place(answer);
4088
+ }, [
4089
+ answer,
4090
+ currentSettled,
4091
+ wholeSet
4092
+ ]);
4093
+ const latest = React.useRef(0);
4094
+ React.useEffect(() => {
4095
+ if (source === null) return;
4096
+ const search = ++latest.current;
4097
+ source.search(query).then((results) => {
4098
+ if (search === latest.current) land({
4099
+ status: "found",
4100
+ results,
4101
+ query,
4102
+ attempt
4103
+ });
4104
+ }, () => {
4105
+ if (search === latest.current) land({
4106
+ status: "failed",
4107
+ query,
4108
+ attempt
4109
+ });
4110
+ });
4111
+ }, [
4112
+ source,
4113
+ query,
4114
+ attempt
4115
+ ]);
4116
+ const pending = source !== null && (answer === null || answer.query !== query || answer.attempt !== attempt);
4117
+ return {
4118
+ results: answer?.status === "found" ? answer.results : null,
4119
+ answered: answer?.query.trim() ?? "",
4120
+ failed: answer?.status === "failed",
4121
+ pending,
4122
+ active,
4123
+ setActive,
4124
+ start,
4125
+ retry: () => setAttempt((n) => n + 1),
4126
+ wholeSet
4127
+ };
4128
+ }
4129
+ /**
4130
+ * How results awaiting a newer answer are drawn: kept, and dimmed.
4131
+ *
4132
+ * Kept rather than cleared because most answers land within a frame or two,
4133
+ * and a grid emptied on every keystroke would flash its loading line while
4134
+ * the person types. Dimmed only after a short delay for the same reason, so
4135
+ * a quick answer never visibly dims; a slow one fades the stale icons back
4136
+ * to say they are not what Enter chooses. Brightening again has no delay.
4137
+ */
4138
+ function pendingFade(pending) {
4139
+ return cn("transition-opacity", pending && "opacity-50 delay-150");
4140
+ }
4141
+ /** What stands in the grid while there is nothing to choose from. */
4142
+ function PickerMessage({ results, failed, query, onRetry }) {
4143
+ if (results !== null && results.length > 0) return null;
4144
+ if (results === null && failed) return /* @__PURE__ */ jsxs("div", {
4145
+ className: "flex flex-col items-center gap-2 py-8 text-center text-muted-foreground",
4146
+ children: [
4147
+ /* @__PURE__ */ jsx(TriangleAlert, {
4148
+ className: "size-5",
4149
+ "aria-hidden": "true"
4150
+ }),
4151
+ /* @__PURE__ */ jsx("p", { children: "The icons could not be loaded." }),
4152
+ /* @__PURE__ */ jsx(Button, {
4153
+ type: "button",
4154
+ variant: "outline",
4155
+ size: "sm",
4156
+ onClick: onRetry,
4157
+ children: "Try again"
4158
+ })
4159
+ ]
4160
+ });
4161
+ return /* @__PURE__ */ jsx("p", {
4162
+ className: "py-8 text-center text-muted-foreground",
4163
+ children: results === null ? "Loading icons…" : `No icons match “${query}”.`
4164
+ });
4165
+ }
4166
+ /** One icon in the grid: an option of the listbox. */
4167
+ function IconOption({ icon, id, index, count, isActive, isCurrent, isRecent, onHighlight, onChoose }) {
4168
+ return /* @__PURE__ */ jsx("div", {
4169
+ id,
4170
+ role: "option",
4171
+ "aria-selected": isActive,
4172
+ "aria-setsize": count,
4173
+ "aria-posinset": index + 1,
4174
+ "aria-label": `${iconDisplayName(icon.name)}${isRecent ? ", recent" : ""}${isCurrent ? ", current" : ""}`,
4175
+ "data-current": isCurrent || void 0,
4176
+ onMouseDown: (event) => event.preventDefault(),
4177
+ onMouseMove: () => {
4178
+ if (!isActive) onHighlight(index);
4179
+ },
4180
+ onClick: () => onChoose(icon),
4181
+ className: cn("flex h-[38px] cursor-pointer items-center justify-center rounded-md", isCurrent && !isActive && "bg-muted ring-[1.5px] ring-inset ring-primary", isActive ? "bg-primary text-primary-foreground" : "hover:bg-muted"),
4182
+ children: /* @__PURE__ */ jsx(IconGlyph, {
4183
+ icon,
4184
+ className: "size-5"
4185
+ })
4186
+ });
4187
+ }
4188
+ /** The highlighted icon, large, with its name and the words it is found by. */
4189
+ function HighlightedIcon({ icon, className }) {
4190
+ const words = (icon?.tags ?? []).slice(0, 3).join(", ");
4191
+ return /* @__PURE__ */ jsx("div", {
4192
+ className: cn("flex min-h-[57px] items-center gap-2.5 border-t border-border px-3 py-2", className),
4193
+ children: icon === void 0 ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
4194
+ className: "grid size-9 shrink-0 place-items-center rounded-md bg-muted",
4195
+ children: /* @__PURE__ */ jsx(IconGlyph, {
4196
+ icon,
4197
+ className: "size-[22px]"
4198
+ })
4199
+ }), /* @__PURE__ */ jsxs("span", {
4200
+ className: "min-w-0",
4201
+ children: [/* @__PURE__ */ jsx("span", {
4202
+ className: "block truncate font-semibold",
4203
+ children: iconDisplayName(icon.name)
4204
+ }), /* @__PURE__ */ jsx("span", {
4205
+ className: "block truncate text-xs text-muted-foreground",
4206
+ children: words === "" ? icon.name : `${icon.name} · ${words}`
4207
+ })]
4208
+ })] })
4209
+ });
4210
+ }
4211
+ /**
4212
+ * A search-first icon picker: a search box over a grid of the matching icons,
4213
+ * and the highlighted icon's name and tags beneath.
4214
+ *
4215
+ * The search box keeps focus throughout, as a combobox. The arrow keys move a
4216
+ * highlight through the grid (left and right by one icon, up and down by a
4217
+ * row), Page Up and Page Down by several rows, and Enter chooses the
4218
+ * highlighted icon; the first match is highlighted as soon as results arrive,
4219
+ * so typing and pressing Enter chooses the best match. The grid is a listbox
4220
+ * that renders only the rows in view, which is what keeps a set of nearly two
4221
+ * thousand icons quick to open. How many icons match is announced politely.
4222
+ *
4223
+ * @experimental
4224
+ */
4225
+ function IconPicker({ loadIcons, value, onChoose, recentIcons, className }) {
4226
+ const base = React.useId();
4227
+ const listId = `${base}-icons`;
4228
+ const optionId = (index) => `${base}-icon-${index}`;
4229
+ const [sourceState, retryLoad] = useIconSource(loadIcons, true);
4230
+ const source = sourceState.status === "ready" ? sourceState.source : null;
4231
+ const [query, setQuery] = React.useState("");
4232
+ const scrollRef = React.useRef(null);
4233
+ const inputRef = React.useRef(null);
4234
+ const [current] = useResolvedIcon(sourceState, value);
4235
+ const currentId = current.status === "found" ? current.icon.id : value;
4236
+ const { results, answered, failed: searchFailed, pending, active, setActive, start, retry: retrySearch, wholeSet } = useIconSearch(source, query, currentId, current.status !== "loading", recentIcons);
4237
+ const { options, recentCount } = React.useMemo(() => {
4238
+ const recent = recentAmong(wholeSet, recentIcons);
4239
+ return {
4240
+ options: [...recent, ...results ?? []],
4241
+ recentCount: recent.length
4242
+ };
4243
+ }, [
4244
+ results,
4245
+ wholeSet,
4246
+ recentIcons
4247
+ ]);
4248
+ const count = options.length;
4249
+ const rows = React.useMemo(() => gridRows(recentCount, count, resultsLabel(answered)), [
4250
+ recentCount,
4251
+ count,
4252
+ answered
4253
+ ]);
4254
+ const highlighted = pending ? void 0 : options[active];
4255
+ const trimmed = query.trim();
4256
+ const failed = sourceState.status === "failed" || searchFailed && !pending;
4257
+ const retry = () => {
4258
+ if (sourceState.status === "failed") retryLoad();
4259
+ else retrySearch();
4260
+ inputRef.current?.focus();
4261
+ };
4262
+ const virtualizer = useVirtualizer({
4263
+ count: rows.length,
4264
+ getScrollElement: () => scrollRef.current,
4265
+ estimateSize: (index) => rows[index]?.kind === "heading" ? HEADING_HEIGHT : ROW_HEIGHT$1,
4266
+ overscan: 4
4267
+ });
4268
+ const scrollToStart = React.useEffectEvent((at) => {
4269
+ virtualizer.scrollToIndex(at.centred ? rowOf(rows, at.index) : 0, { align: at.centred ? "center" : "start" });
4270
+ });
4271
+ React.useEffect(() => {
4272
+ if (start !== null) scrollToStart(start);
4273
+ }, [start]);
4274
+ const chooseAnswered = (icon) => {
4275
+ if (!pending) onChoose(icon);
4276
+ };
4277
+ const message = /* @__PURE__ */ jsx(PickerMessage, {
4278
+ results,
4279
+ failed,
4280
+ query: answered,
4281
+ onRetry: retry
4282
+ });
4283
+ const onKeyDown = (event) => {
4284
+ if (pending) {
4285
+ if (event.key === "Enter") event.preventDefault();
4286
+ return;
4287
+ }
4288
+ const next = stepFrom(event.key, active, rows);
4289
+ if (next !== void 0) {
4290
+ event.preventDefault();
4291
+ setActive(next);
4292
+ virtualizer.scrollToIndex(rowOf(rows, next), { align: "auto" });
4293
+ return;
4294
+ }
4295
+ if (event.key === "Enter" && highlighted !== void 0) {
4296
+ event.preventDefault();
4297
+ onChoose(highlighted);
4298
+ }
4299
+ };
4300
+ return /* @__PURE__ */ jsxs("div", {
4301
+ className: cn("flex h-[min(452px,70vh,var(--radix-popover-content-available-height,452px))] flex-col text-sm text-foreground", className),
4302
+ children: [
4303
+ /* @__PURE__ */ jsxs("div", {
4304
+ className: "m-2.5 flex items-center gap-1.5 rounded-md border-[1.5px] border-input px-2 py-1.5 focus-within:border-primary",
4305
+ children: [/* @__PURE__ */ jsx(Search, {
4306
+ className: "size-[15px] shrink-0 text-muted-foreground",
4307
+ "aria-hidden": "true"
4308
+ }), /* @__PURE__ */ jsx("input", {
4309
+ ref: inputRef,
4310
+ type: "text",
4311
+ role: "combobox",
4312
+ "aria-label": "Search icons",
4313
+ "aria-expanded": "true",
4314
+ "aria-controls": listId,
4315
+ "aria-autocomplete": "list",
4316
+ "aria-activedescendant": highlighted === void 0 ? void 0 : optionId(active),
4317
+ autoComplete: "off",
4318
+ spellCheck: false,
4319
+ placeholder: "Search icons",
4320
+ value: query,
4321
+ onChange: (event) => setQuery(event.target.value),
4322
+ onKeyDown,
4323
+ className: "min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
4324
+ })]
4325
+ }),
4326
+ recentCount > 0 ? null : /* @__PURE__ */ jsx("p", {
4327
+ className: HEADING_TEXT,
4328
+ children: resultsLabel(trimmed)
4329
+ }),
4330
+ /* @__PURE__ */ jsxs("div", {
4331
+ ref: scrollRef,
4332
+ className: "min-h-0 flex-1 overflow-y-auto px-2.5",
4333
+ children: [
4334
+ recentCount > 0 ? null : message,
4335
+ /* @__PURE__ */ jsx("div", {
4336
+ id: listId,
4337
+ role: "listbox",
4338
+ "aria-label": "Icons",
4339
+ "aria-busy": pending || void 0,
4340
+ className: cn("relative w-full", pendingFade(pending)),
4341
+ style: { height: virtualizer.getTotalSize() },
4342
+ children: virtualizer.getVirtualItems().map((item) => {
4343
+ const row = rows[item.index];
4344
+ if (row === void 0) return null;
4345
+ if (row.kind === "heading") return /* @__PURE__ */ jsx("p", {
4346
+ "aria-hidden": "true",
4347
+ className: cn(HEADING_TEXT, "absolute inset-x-0 top-0 flex items-end px-0.5"),
4348
+ style: {
4349
+ height: HEADING_HEIGHT,
4350
+ transform: `translateY(${item.start}px)`
4351
+ },
4352
+ children: row.label
4353
+ }, item.key);
4354
+ return /* @__PURE__ */ jsx("div", {
4355
+ role: "presentation",
4356
+ className: "absolute inset-x-0 top-0 grid grid-cols-8 gap-0.5",
4357
+ style: { transform: `translateY(${item.start}px)` },
4358
+ children: options.slice(row.start, row.end).map((icon, column) => {
4359
+ const index = row.start + column;
4360
+ return /* @__PURE__ */ jsx(IconOption, {
4361
+ icon,
4362
+ id: optionId(index),
4363
+ index,
4364
+ count,
4365
+ isActive: index === active,
4366
+ isCurrent: icon.id === currentId,
4367
+ isRecent: index < recentCount,
4368
+ onHighlight: setActive,
4369
+ onChoose: chooseAnswered
4370
+ }, icon.id);
4371
+ })
4372
+ }, item.key);
4373
+ })
4374
+ }),
4375
+ recentCount > 0 ? message : null
4376
+ ]
4377
+ }),
4378
+ /* @__PURE__ */ jsx(HighlightedIcon, {
4379
+ icon: options[active],
4380
+ className: pendingFade(pending)
4381
+ }),
4382
+ /* @__PURE__ */ jsx("p", {
4383
+ role: "status",
4384
+ "aria-live": "polite",
4385
+ className: "sr-only",
4386
+ children: announcementFor(results, failed, answered)
4387
+ })
4388
+ ]
4389
+ });
4390
+ }
4391
+ /** The text the field shows and speaks for a value, however it resolved. */
4392
+ function valueTextFor(value, resolved, source, label) {
4393
+ if (!value) return {
4394
+ name: "Choose an icon",
4395
+ set: "",
4396
+ spoken: `${label}: none chosen`
4397
+ };
4398
+ const parts = partsOf(value);
4399
+ const setName = source !== null && parts.set === source.prefix ? source.label : iconDisplayName(parts.set);
4400
+ if (resolved.status === "missing") return {
4401
+ name: parts.name,
4402
+ set: setName === "" ? "Not found" : `${setName} · not found`,
4403
+ spoken: `${label}: ${parts.name}, not found`
4404
+ };
4405
+ if (resolved.status === "failed") {
4406
+ const name = iconDisplayName(parts.name);
4407
+ return {
4408
+ name,
4409
+ set: setName === "" ? "Could not load" : `${setName} · could not load`,
4410
+ spoken: `${label}: ${name}, could not be loaded`
4411
+ };
4412
+ }
4413
+ const name = iconDisplayName(resolved.status === "found" ? resolved.icon.name : parts.name);
4414
+ return {
4415
+ name,
4416
+ set: setName,
4417
+ spoken: `${label}: ${name}`
4418
+ };
4419
+ }
4420
+ /** The tile the chosen icon is drawn in, or what stands in for it. */
4421
+ function IconSwatch({ resolved }) {
4422
+ return /* @__PURE__ */ jsx("span", {
4423
+ className: cn("grid size-7 shrink-0 place-items-center rounded-[5px]", resolved.status === "found" ? "bg-muted" : "border border-dashed border-muted-foreground", resolved.status === "loading" && "animate-pulse bg-muted motion-reduce:animate-none"),
4424
+ children: resolved.status === "found" ? /* @__PURE__ */ jsx(IconGlyph, {
4425
+ icon: resolved.icon,
4426
+ className: "size-[18px]"
4427
+ }) : resolved.status === "missing" ? /* @__PURE__ */ jsx(CircleHelp, {
4428
+ className: "size-[18px] text-muted-foreground",
4429
+ "aria-hidden": "true"
4430
+ }) : resolved.status === "failed" ? /* @__PURE__ */ jsx(TriangleAlert, {
4431
+ className: "size-[18px] text-muted-foreground",
4432
+ "aria-hidden": "true"
4433
+ }) : null
4434
+ });
4435
+ }
4436
+ /** What the field's button shows: the swatch, the name, the set, a chevron. */
4437
+ function IconFieldFace({ resolved, text, empty }) {
4438
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
4439
+ /* @__PURE__ */ jsx(IconSwatch, { resolved }),
4440
+ /* @__PURE__ */ jsxs("span", {
4441
+ className: "min-w-0 flex-1 leading-tight",
4442
+ children: [/* @__PURE__ */ jsx("span", {
4443
+ className: cn("block text-sm font-medium [overflow-wrap:anywhere]", empty && "font-normal text-muted-foreground"),
4444
+ children: text.name
4445
+ }), text.set === "" ? null : /* @__PURE__ */ jsx("span", {
4446
+ className: "text-[11px] text-muted-foreground",
4447
+ children: text.set
4448
+ })]
4449
+ }),
4450
+ /* @__PURE__ */ jsx(ChevronDown, {
4451
+ className: "size-3.5 shrink-0 text-muted-foreground",
4452
+ "aria-hidden": "true"
4453
+ })
4454
+ ] });
4455
+ }
4456
+ /** The warning under a field whose icon the set no longer draws. */
4457
+ function MissingIconWarning({ shown, id }) {
4458
+ if (!shown) return null;
4459
+ return /* @__PURE__ */ jsxs("p", {
4460
+ id,
4461
+ className: "mt-1.5 flex items-start gap-2 rounded-md border border-warning-border bg-warning-surface px-2.5 py-1.5 text-xs text-warning-text",
4462
+ children: [/* @__PURE__ */ jsx(TriangleAlert, {
4463
+ className: "mt-px size-3.5 shrink-0",
4464
+ "aria-hidden": "true"
4465
+ }), /* @__PURE__ */ jsx("span", { children: "This icon is no longer available. Choose another." })]
4466
+ });
4467
+ }
4468
+ /**
4469
+ * The button that opens the picker. Every prop it is not given by name goes
4470
+ * to the `<button>`, so a popover trigger can hand it its ref, state and
4471
+ * handlers.
4472
+ */
4473
+ function IconFieldButton({ resolved, text, empty, interactive, invalid, readOnly, ...button }) {
4474
+ return /* @__PURE__ */ jsx("button", {
4475
+ type: "button",
4476
+ ...button,
4477
+ "aria-label": text.spoken,
4478
+ "aria-invalid": invalid || void 0,
4479
+ "aria-disabled": readOnly || void 0,
4480
+ className: cn("flex min-w-0 flex-1 items-center gap-2 rounded-md px-1.5 py-[5px] text-left", "outline-none focus-visible:ring-2 focus-visible:ring-ring", interactive ? "cursor-pointer hover:bg-muted" : "cursor-default"),
4481
+ children: /* @__PURE__ */ jsx(IconFieldFace, {
4482
+ resolved,
4483
+ text,
4484
+ empty
4485
+ })
4486
+ });
4487
+ }
4488
+ /** The bordered row the field's two buttons sit in. */
4489
+ function IconFieldFrame({ invalid, disabled, children }) {
4490
+ return /* @__PURE__ */ jsx("div", {
4491
+ className: cn("flex w-full items-center rounded-md border border-input bg-background", invalid && "border-destructive", disabled && "opacity-50"),
4492
+ children
4493
+ });
4494
+ }
4495
+ /** A button that clears the field, drawn while there is a value to clear. */
4496
+ function ClearIconButton({ shown, onClear }) {
4497
+ if (!shown) return null;
4498
+ return /* @__PURE__ */ jsx("button", {
4499
+ type: "button",
4500
+ "aria-label": "Clear icon",
4501
+ onClick: onClear,
4502
+ className: "mr-1 grid place-items-center rounded p-[3px] text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
4503
+ children: /* @__PURE__ */ jsx(X, {
4504
+ className: "size-[15px]",
4505
+ "aria-hidden": "true"
4506
+ })
4507
+ });
4508
+ }
4509
+ /**
4510
+ * What a field's value draws as and is called, loading the set when there is
4511
+ * an icon to draw or a picker to fill. Opening the picker asks again for
4512
+ * whichever failed to arrive, the set or the value's icon.
4513
+ */
4514
+ function useIconFieldValue(loadIcons, value, label, open) {
4515
+ const [sourceState, retryLoad] = useIconSource(loadIcons, Boolean(value) || open);
4516
+ const [resolved, retryResolve] = useResolvedIcon(sourceState, value);
4517
+ const source = sourceState.status === "ready" ? sourceState.source : null;
4518
+ const retryFailed = React.useEffectEvent(() => {
4519
+ if (sourceState.status === "failed") retryLoad();
4520
+ else if (resolved.status === "failed") retryResolve();
4521
+ });
4522
+ React.useEffect(() => {
4523
+ if (open) retryFailed();
4524
+ }, [open]);
4525
+ return {
4526
+ resolved,
4527
+ text: valueTextFor(value, resolved, source, label)
4528
+ };
4529
+ }
4530
+ /**
4531
+ * A button the field keeps a handle on and hands to the caller's ref too: the
4532
+ * field takes focus back to it after a clear, and a form focuses it from
4533
+ * outside. One callback ref gives the node to both.
4534
+ */
4535
+ function useSharedButtonRef(ref) {
4536
+ const own = React.useRef(null);
4537
+ return [own, React.useCallback((node) => {
4538
+ own.current = node;
4539
+ if (typeof ref === "function") ref(node);
4540
+ else if (ref) ref.current = node;
4541
+ }, [ref])];
4542
+ }
4543
+ /** The warning's id while the warning is drawn, for the button it describes. */
4544
+ function warningIdIf(missing, id) {
4545
+ return missing ? id : void 0;
4546
+ }
4547
+ /** Joins the ids describing an element, or `undefined` when there are none. */
4548
+ function describedByIds(...ids) {
4549
+ const joined = ids.filter((id) => id !== void 0 && id !== "").join(" ");
4550
+ return joined === "" ? void 0 : joined;
4551
+ }
4552
+ /** The popover the field's picker opens in, beside the field. */
4553
+ function IconFieldPopover({ ref, loadIcons, value, recentIcons, onChoose }) {
4554
+ return /* @__PURE__ */ jsx(PopoverContent, {
4555
+ ref,
4556
+ align: "start",
4557
+ collisionPadding: 8,
4558
+ "aria-label": "Choose an icon",
4559
+ className: "w-[min(360px,calc(100vw-32px))] rounded-[10px] p-0 shadow-lg motion-reduce:animate-none",
4560
+ children: /* @__PURE__ */ jsx(IconPicker, {
4561
+ loadIcons,
4562
+ value,
4563
+ recentIcons,
4564
+ onChoose: (icon) => onChoose(icon.id)
4565
+ })
4566
+ });
4567
+ }
4568
+ /**
4569
+ * Whether the field's picker is open, and a setter that opens it only for a
4570
+ * field that can be changed and reports the field left when it closes.
4571
+ */
4572
+ function useReportedOpen(interactive, onBlur) {
4573
+ const [open, setOpen] = React.useState(false);
4574
+ const setOpenAndReport = (next) => {
4575
+ if (next && !interactive) return;
4576
+ setOpen(next);
4577
+ if (!next) onBlur?.();
4578
+ };
4579
+ return [open, setOpenAndReport];
4580
+ }
4581
+ /**
4582
+ * A blur handler for the field's wrapper that reports the field left when
4583
+ * focus moves from its buttons to somewhere outside the field. The picker sits
4584
+ * in a portal, elsewhere in the document, so it is checked by its own node;
4585
+ * its focus events still bubble to the wrapper through React. Focus never
4586
+ * leaves the open picker without closing it, and the close reports, so
4587
+ * nothing is reported while it is open or for focus leaving it.
4588
+ */
4589
+ function focusLeftReporter(open, pickerRef, onBlur) {
4590
+ return (event) => {
4591
+ const picker = pickerRef.current;
4592
+ if (open || picker?.contains(event.target)) return;
4593
+ const next = event.relatedTarget;
4594
+ if (!(next instanceof Node && (event.currentTarget.contains(next) || picker?.contains(next) === true))) onBlur?.();
4595
+ };
4596
+ }
4597
+ /**
4598
+ * A field holding one icon: a button showing the chosen icon, its name and
4599
+ * its set, which opens an {@link IconPicker}, and a button that clears it.
4600
+ *
4601
+ * An id the source no longer draws is shown by its name with a warning, and
4602
+ * kept until someone chooses another: the field never rewrites a stored value
4603
+ * on its own. Escape closes the picker and returns focus to the button.
4604
+ *
4605
+ * @experimental
4606
+ */
4607
+ function IconField({ value, onChange, loadIcons, label = "Icon", id, disabled = false, readOnly = false, invalid = false, "aria-describedby": describedBy, onBlur, recentIcons, ref, className }) {
4608
+ const interactive = !disabled && !readOnly;
4609
+ const [open, setOpenAndReport] = useReportedOpen(interactive, onBlur);
4610
+ const [triggerRef, setTrigger] = useSharedButtonRef(ref);
4611
+ const warningId = React.useId();
4612
+ const { resolved, text } = useIconFieldValue(loadIcons, value, label, open);
4613
+ const missing = resolved.status === "missing";
4614
+ const pickerRef = React.useRef(null);
4615
+ const reportFocusLeft = focusLeftReporter(open, pickerRef, onBlur);
4616
+ return /* @__PURE__ */ jsxs("div", {
4617
+ className: cn("w-full", className),
4618
+ onBlur: reportFocusLeft,
4619
+ children: [/* @__PURE__ */ jsxs(IconFieldFrame, {
4620
+ invalid,
4621
+ disabled,
4622
+ children: [/* @__PURE__ */ jsxs(Popover, {
4623
+ open,
4624
+ onOpenChange: setOpenAndReport,
4625
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
4626
+ asChild: true,
4627
+ children: /* @__PURE__ */ jsx(IconFieldButton, {
4628
+ ref: setTrigger,
4629
+ id,
4630
+ "aria-describedby": describedByIds(describedBy, warningIdIf(missing, warningId)),
4631
+ disabled,
4632
+ resolved,
4633
+ text,
4634
+ empty: !value,
4635
+ interactive,
4636
+ invalid,
4637
+ readOnly
4638
+ })
4639
+ }), /* @__PURE__ */ jsx(IconFieldPopover, {
4640
+ ref: pickerRef,
4641
+ loadIcons,
4642
+ value,
4643
+ recentIcons,
4644
+ onChoose: (id) => {
4645
+ onChange(id);
4646
+ setOpenAndReport(false);
4647
+ }
4648
+ })]
4649
+ }), /* @__PURE__ */ jsx(ClearIconButton, {
4650
+ shown: Boolean(value) && interactive,
4651
+ onClear: () => {
4652
+ onChange(null);
4653
+ onBlur?.();
4654
+ triggerRef.current?.focus();
4655
+ }
4656
+ })]
4657
+ }), /* @__PURE__ */ jsx(MissingIconWarning, {
4658
+ shown: missing,
4659
+ id: warningId
4660
+ })]
4661
+ });
4662
+ }
3615
4663
  // src/components/context-menu.tsx
3616
4664
  /**
3617
4665
  * ContextMenu Component
@@ -3944,7 +4992,17 @@ const ResizableHandle = ({ withGrip, className, children, ...props }) => /* @__P
3944
4992
  * @module
3945
4993
  */
3946
4994
  const ROW_HEIGHT = 28;
3947
- const INDENT_PER_LEVEL = 12;
4995
+ /**
4996
+ * How far each level of the tree is indented, in pixels.
4997
+ *
4998
+ * Exported because a consumer that lets rows be dragged to a depth has to step
4999
+ * by the same distance the rows are drawn at: an editor reading a pointer's x
5000
+ * as a depth draws its drop line where a row at that depth would start, and
5001
+ * two separate numbers would put the line a level away from the hand.
5002
+ *
5003
+ * @experimental
5004
+ */
5005
+ const TREE_INDENT_PX = 20;
3948
5006
  /** The text a row can be typed to, falling back to a string label. */
3949
5007
  function textOf(node) {
3950
5008
  if (typeof node.textValue === "string") return node.textValue;
@@ -4056,6 +5114,22 @@ const TreeView = React.forwardRef(({ nodes, expandedIds, defaultExpandedIds, onE
4056
5114
  estimateSize: () => ROW_HEIGHT,
4057
5115
  overscan: 8
4058
5116
  });
5117
+ const revealed = React.useRef(null);
5118
+ React.useEffect(() => {
5119
+ if (selected === null) {
5120
+ revealed.current = null;
5121
+ return;
5122
+ }
5123
+ if (revealed.current === selected) return;
5124
+ const index = rows.findIndex((row) => row.node.id === selected);
5125
+ if (index < 0) return;
5126
+ revealed.current = selected;
5127
+ virtualizer.scrollToIndex(index, { align: "auto" });
5128
+ }, [
5129
+ selected,
5130
+ rows,
5131
+ virtualizer
5132
+ ]);
4059
5133
  const commitExpanded = (next) => {
4060
5134
  const ids = [...next];
4061
5135
  if (expandedIds === void 0) setExpandedState(ids);
@@ -4217,7 +5291,7 @@ const TreeView = React.forwardRef(({ nodes, expandedIds, defaultExpandedIds, onE
4217
5291
  style: {
4218
5292
  height: item.size,
4219
5293
  transform: `translateY(${item.start}px)`,
4220
- paddingLeft: 4 + row.level * INDENT_PER_LEVEL
5294
+ paddingLeft: 4 + row.level * 20
4221
5295
  },
4222
5296
  children: [
4223
5297
  /* @__PURE__ */ jsx("span", {
@@ -5750,7 +6824,7 @@ const SHELL_MEASURE = {
5750
6824
  * "how far is content from the panel's edge".
5751
6825
  * @experimental
5752
6826
  */
5753
- const PageShell = forwardRef(({ width = "form", className, children, style, ...props }, ref) => {
6827
+ const PageShell = forwardRef(({ width = "form", align = "start", className, children, style, ...props }, ref) => {
5754
6828
  const shellRef = useRef(null);
5755
6829
  const attachRef = useCallback((node) => {
5756
6830
  shellRef.current = node;
@@ -5783,6 +6857,7 @@ const PageShell = forwardRef(({ width = "form", className, children, style, ...p
5783
6857
  children: /* @__PURE__ */ jsx("div", {
5784
6858
  ref: attachRef,
5785
6859
  "data-slot": "page-shell",
6860
+ "data-align": align,
5786
6861
  style: shellStyle,
5787
6862
  className: cn("nx-page-shell py-8", className),
5788
6863
  ...props,
@@ -5846,32 +6921,156 @@ Bleed.displayName = "Bleed";
5846
6921
  * prop.
5847
6922
  * @experimental
5848
6923
  */
5849
- const PageHeader = forwardRef(({ title, description, breadcrumbs, actions, className, ...props }, ref) => /* @__PURE__ */ jsxs("header", {
6924
+ const PageHeader = forwardRef(({ title, description, breadcrumbs, actions, tabs, media, meta, titleId, className, ...props }, ref) => /* @__PURE__ */ jsxs("header", {
5850
6925
  ref,
5851
6926
  "data-slot": "page-header",
5852
6927
  className: cn("mb-8", className),
5853
6928
  ...props,
5854
- children: [breadcrumbs ? /* @__PURE__ */ jsx("div", {
5855
- className: "mb-6",
5856
- children: breadcrumbs
5857
- }) : null, /* @__PURE__ */ jsxs("div", {
5858
- className: "flex flex-col justify-between gap-4 sm:flex-row sm:items-center",
5859
- children: [/* @__PURE__ */ jsxs("div", {
5860
- className: "space-y-1",
5861
- children: [/* @__PURE__ */ jsx("h1", {
5862
- className: "text-xl font-semibold tracking-tight",
5863
- children: title
5864
- }), description ? /* @__PURE__ */ jsx("p", {
5865
- className: "mt-1 text-sm font-normal text-muted-foreground",
5866
- children: description
6929
+ children: [
6930
+ breadcrumbs ? /* @__PURE__ */ jsx("div", {
6931
+ className: "mb-6 empty:hidden",
6932
+ children: breadcrumbs
6933
+ }) : null,
6934
+ /* @__PURE__ */ jsxs("div", {
6935
+ className: "flex flex-col justify-between gap-4 sm:flex-row sm:items-center",
6936
+ children: [/* @__PURE__ */ jsxs("div", {
6937
+ className: "flex min-w-0 items-start gap-4",
6938
+ children: [media ? /* @__PURE__ */ jsx("div", {
6939
+ className: "shrink-0",
6940
+ children: media
6941
+ }) : null, /* @__PURE__ */ jsxs("div", {
6942
+ className: "min-w-0 space-y-1",
6943
+ children: [/* @__PURE__ */ jsxs("div", {
6944
+ className: "flex flex-wrap items-center gap-3",
6945
+ children: [/* @__PURE__ */ jsx("h1", {
6946
+ id: titleId,
6947
+ className: "text-xl font-semibold tracking-tight",
6948
+ children: title
6949
+ }), meta]
6950
+ }), description ? /* @__PURE__ */ jsx("div", {
6951
+ "data-slot": "page-header-description",
6952
+ className: "mt-1 text-sm font-normal text-muted-foreground",
6953
+ children: description
6954
+ }) : null]
6955
+ })]
6956
+ }), actions ? /* @__PURE__ */ jsx("div", {
6957
+ className: "flex items-center gap-3",
6958
+ children: actions
5867
6959
  }) : null]
5868
- }), actions ? /* @__PURE__ */ jsx("div", {
5869
- className: "flex items-center gap-3",
5870
- children: actions
5871
- }) : null]
5872
- })]
6960
+ }),
6961
+ tabs ? /* @__PURE__ */ jsx("div", {
6962
+ className: "mt-6",
6963
+ children: tabs
6964
+ }) : null
6965
+ ]
5873
6966
  }));
5874
6967
  PageHeader.displayName = "PageHeader";
5875
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Bleed, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorPicker, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FieldShell, FormActions, FormLabelWithTooltip, FormSection, Grid, Input, Label, PageHeader, PageShell, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalProvider, Progress, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, SHELL_MEASURE, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, ShortcutProvider, ShortcutScope, Skeleton, Slider, Spinner, Stack, Stat, Switch, Table, TableBody, TableCaption, TableCell, TableEmpty, TableError, TableFooter, TableHead, TableHeader, TableLoading, TableRow, TableSearch, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TreeView, alertVariants, avatarVariants, badgeVariants, buttonVariants, cardVariants, chordMatches, commandDefaultFilter, createShortcutManager, detectApplePlatform, dialogContentVariants, inputVariants, parseKeys, progressVariants, selectTriggerVariants, sheetVariants, spinnerVariants, toast, useActiveShortcuts, useCommandHighlight, useIsomorphicLayoutEffect, usePortalContainer, useShortcutManager, useShortcuts };
6968
+ /**
6969
+ * The tab row of a page whose sections each have their own address. A labelled
6970
+ * `nav` of links rather than an ARIA tablist: every tab changes the URL, and a
6971
+ * link inside `role="tab"` breaks the tabs pattern's keyboard and announcement
6972
+ * contract. The current section is marked with `aria-current="page"` by
6973
+ * `PageTab`.
6974
+ * @experimental
6975
+ */
6976
+ const PageTabs = forwardRef(({ label, className, children, ...props }, ref) => /* @__PURE__ */ jsx("nav", {
6977
+ ref,
6978
+ "aria-label": label,
6979
+ "data-slot": "page-tabs",
6980
+ className: cn("flex gap-1 overflow-x-auto border-b border-border", className),
6981
+ ...props,
6982
+ children
6983
+ }));
6984
+ PageTabs.displayName = "PageTabs";
6985
+ /**
6986
+ * One section of a `PageTabs` row: a link, underlined when current.
6987
+ * @experimental
6988
+ */
6989
+ const PageTab = forwardRef(({ current = false, asChild = false, className, children, ...props }, ref) => {
6990
+ const Comp = asChild ? Slot : "a";
6991
+ const marker = current ? "page" : void 0;
6992
+ const content = asChild && isValidElement(children) ? cloneElement(children, { "aria-current": marker }) : children;
6993
+ return /* @__PURE__ */ jsx(Comp, {
6994
+ ...props,
6995
+ ref,
6996
+ "data-slot": "page-tab",
6997
+ "aria-current": marker,
6998
+ className: cn("-mb-px inline-flex h-9 shrink-0 items-center border-b-2 px-3 text-sm font-medium whitespace-nowrap transition-colors", current ? "border-foreground text-foreground" : "border-transparent text-muted-foreground hover:text-foreground", className),
6999
+ children: content
7000
+ });
7001
+ });
7002
+ PageTab.displayName = "PageTab";
7003
+ // src/components/page-frame.tsx
7004
+ /**
7005
+ * The shell each type draws with. A table rather than a branch per type, so
7006
+ * the four widths are read in one place and a fifth type is one row.
7007
+ */
7008
+ const SHELL_FOR = { form: {
7009
+ width: "form",
7010
+ align: "start"
7011
+ } };
7012
+ const PageFrameClaimContext = createContext(null);
7013
+ /**
7014
+ * Hears whether the content inside it draws a `PageFrame`, for a host that
7015
+ * gives unframed content a frame of its own and must not frame content twice.
7016
+ * Read from the frames themselves rather than from what the content is called,
7017
+ * so a page that draws a frame through any component is heard the same way.
7018
+ *
7019
+ * The frame claims in a layout effect, so a host that changes its own markup
7020
+ * in answer does so before the first paint.
7021
+ * @experimental
7022
+ */
7023
+ function PageFrameListener({ onFrame, children }) {
7024
+ const onFrameRef = useRef(onFrame);
7025
+ useLayoutEffect(() => {
7026
+ onFrameRef.current = onFrame;
7027
+ });
7028
+ const claims = useRef([]);
7029
+ const claim = useCallback((type) => {
7030
+ const entry = { type };
7031
+ claims.current = [...claims.current, entry];
7032
+ onFrameRef.current(type);
7033
+ return () => {
7034
+ claims.current = claims.current.filter((other) => other !== entry);
7035
+ onFrameRef.current(claims.current[claims.current.length - 1]?.type ?? null);
7036
+ };
7037
+ }, []);
7038
+ return /* @__PURE__ */ jsx(PageFrameClaimContext.Provider, {
7039
+ value: claim,
7040
+ children
7041
+ });
7042
+ }
7043
+ /**
7044
+ * A page's frame: the width and gutter its type gives it. A page says what it
7045
+ * is, and the frame decides how wide that is, so two pages of one type can
7046
+ * never drift apart.
7047
+ * @experimental
7048
+ */
7049
+ const PageFrame = forwardRef(({ type, className, children: content, ...props }, ref) => {
7050
+ const claim = useContext(PageFrameClaimContext);
7051
+ useLayoutEffect(() => claim?.(type), [claim, type]);
7052
+ const children = /* @__PURE__ */ jsx(PageFrameClaimContext.Provider, {
7053
+ value: null,
7054
+ children: content
7055
+ });
7056
+ if (type !== "form") return /* @__PURE__ */ jsx("div", {
7057
+ ref,
7058
+ "data-slot": "page-frame",
7059
+ "data-page-type": type,
7060
+ className: cn("min-w-0", type === "list" && "nx-page-pad", className),
7061
+ ...props,
7062
+ children
7063
+ });
7064
+ return /* @__PURE__ */ jsx(PageShell, {
7065
+ ref,
7066
+ "data-page-type": type,
7067
+ ...SHELL_FOR[type],
7068
+ className,
7069
+ ...props,
7070
+ children
7071
+ });
7072
+ });
7073
+ PageFrame.displayName = "PageFrame";
7074
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Bleed, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorPicker, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FieldShell, FormActions, FormLabelWithTooltip, FormSection, Grid, IconField, IconGlyph, IconPicker, Input, Label, PageFrame, PageFrameListener, PageHeader, PageShell, PageTab, PageTabs, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalProvider, Progress, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, SHELL_MEASURE, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, ShortcutProvider, ShortcutScope, Skeleton, Slider, Spinner, Stack, Stat, Switch, TREE_INDENT_PX, Table, TableBody, TableCaption, TableCell, TableEmpty, TableError, TableFooter, TableHead, TableHeader, TableLoading, TableRow, TableSearch, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TreeView, alertVariants, avatarVariants, badgeVariants, buttonVariants, cardVariants, chordMatches, commandDefaultFilter, createShortcutManager, detectApplePlatform, dialogContentVariants, inputVariants, parseKeys, progressVariants, selectTriggerVariants, sheetVariants, spinnerVariants, toast, useActiveShortcuts, useCommandHighlight, useIsomorphicLayoutEffect, usePortalContainer, useShortcutManager, useShortcuts };
5876
7075
 
5877
7076
  //# sourceMappingURL=index.mjs.map