@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.cjs CHANGED
@@ -56,11 +56,11 @@ let _radix_ui_react_select = require("@radix-ui/react-select");
56
56
  _radix_ui_react_select = __toESM(_radix_ui_react_select, 1);
57
57
  let cmdk = require("cmdk");
58
58
  let sonner = require("sonner");
59
+ let _tanstack_react_virtual = require("@tanstack/react-virtual");
59
60
  let _radix_ui_react_context_menu = require("@radix-ui/react-context-menu");
60
61
  _radix_ui_react_context_menu = __toESM(_radix_ui_react_context_menu, 1);
61
62
  let react_resizable_panels = require("react-resizable-panels");
62
63
  react_resizable_panels = __toESM(react_resizable_panels, 1);
63
- let _tanstack_react_virtual = require("@tanstack/react-virtual");
64
64
  let _radix_ui_react_slider = require("@radix-ui/react-slider");
65
65
  _radix_ui_react_slider = __toESM(_radix_ui_react_slider, 1);
66
66
  // src/lib/utils.ts
@@ -98,12 +98,12 @@ function cn(...inputs) {
98
98
  * Note: 'primary' is a semantic alias for 'default' variant for better code readability
99
99
  * @experimental
100
100
  */
101
- const buttonVariants = (0, class_variance_authority.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", {
101
+ const buttonVariants = (0, class_variance_authority.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`, {
102
102
  variants: {
103
103
  variant: {
104
104
  default: "bg-primary text-primary-foreground border border-transparent hover:opacity-90",
105
105
  primary: "bg-primary text-primary-foreground border border-transparent hover:opacity-90",
106
- destructive: "bg-destructive-solid text-destructive-foreground border border-transparent hover:bg-destructive-600",
106
+ destructive: "bg-destructive-solid text-destructive-foreground border border-transparent hover:bg-destructive-hover",
107
107
  outline: "border border-border text-foreground hover-unified bg-background",
108
108
  secondary: "bg-background border border-border text-foreground hover:bg-primary/5",
109
109
  ghost: "text-foreground border border-transparent hover-unified",
@@ -287,6 +287,15 @@ const FormLabelWithTooltip = react.forwardRef(({ className, labelClassName, tool
287
287
  });
288
288
  });
289
289
  FormLabelWithTooltip.displayName = "FormLabelWithTooltip";
290
+ // src/components/badge.tsx
291
+ /** The arms `badgeVariants` is built from. Its type is read from them: {@link VariantsFn}. */
292
+ /** The status variants, and the solid each one's dot is drawn in. */
293
+ const STATUS_DOT = {
294
+ success: "bg-success-solid",
295
+ warning: "bg-warning-solid",
296
+ destructive: "bg-danger-solid",
297
+ info: "bg-info-solid"
298
+ };
290
299
  /**
291
300
  * Badge Component - Design System Specification
292
301
  *
@@ -305,34 +314,40 @@ FormLabelWithTooltip.displayName = "FormLabelWithTooltip";
305
314
  * - Padding: 2px 10px (vertical × horizontal)
306
315
  * - Border radius: Full (pill shape)
307
316
  * - Font: 12px (text-xs), medium weight (500)
308
- * - Colors: Light backgrounds with dark text for visibility in both light/dark modes
309
- *
310
- * Variants (6 total per design spec):
311
- * - default: Light gray background
312
- * - primary: Light blue background
313
- * - success: Light green background
314
- * - warning: Light amber background
315
- * - destructive: Light red background
316
- * - outline: Transparent background with border border-border
317
+ * - Status variants (success, warning, destructive, info): a neutral chip with
318
+ * a 6px dot in the status's solid colour before the label
319
+ *
320
+ * Variants:
321
+ * - default: muted background
322
+ * - primary: primary tint
323
+ * - success, warning, destructive, info: quiet chip with a status dot
324
+ * - outline: transparent background with a border
317
325
  * @experimental
318
326
  */
319
- const badgeVariants = (0, class_variance_authority.cva)("inline-flex items-center rounded-sm px-2.5 py-0.5 h-[22px] text-xs font-medium transition-colors", {
327
+ const badgeVariants = (0, class_variance_authority.cva)("inline-flex items-center gap-1.5 rounded-sm px-2.5 py-0.5 h-[22px] text-xs font-medium transition-colors", {
320
328
  variants: { variant: {
321
329
  default: "bg-muted text-foreground",
322
330
  primary: "bg-primary/10 text-primary dark:bg-primary/20",
323
- success: "bg-success-100 text-success-700 dark:bg-success-900 dark:text-success-100",
324
- warning: "bg-warning-100 text-warning-700 dark:bg-warning-900 dark:text-warning-100",
325
- destructive: "bg-destructive-100 text-destructive-700 dark:bg-destructive-900 dark:text-destructive-100",
331
+ success: "border border-border bg-card text-foreground",
332
+ warning: "border border-border bg-card text-foreground",
333
+ destructive: "border border-border bg-card text-foreground",
334
+ info: "border border-border bg-card text-foreground",
326
335
  outline: "border border-border bg-transparent text-foreground dark:text-muted-foreground dark:border-border"
327
336
  } },
328
337
  defaultVariants: { variant: "default" }
329
338
  });
330
339
  /** @public */
331
- function Badge({ className, variant = "default", ...props }) {
332
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
340
+ function Badge({ className, variant = "default", children, ...props }) {
341
+ const dot = variant && variant in STATUS_DOT ? STATUS_DOT[variant] : null;
342
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
333
343
  "data-slot": `badge.${variant}`,
334
344
  className: cn(badgeVariants({ variant }), className),
335
- ...props
345
+ ...props,
346
+ children: [dot ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
347
+ "aria-hidden": "true",
348
+ "data-slot": "badge-dot",
349
+ className: cn("size-1.5 shrink-0 rounded-full", dot)
350
+ }) : null, children]
336
351
  });
337
352
  }
338
353
  /**
@@ -563,11 +578,12 @@ Stat.displayName = "Stat";
563
578
  * - Padding: 16px (p-4)
564
579
  * - Border radius: `rounded-md`, one step tighter than Card's `rounded-lg`
565
580
  * for inline/flow content vs. larger container components
566
- * - Border: 1px solid matching variant color
581
+ * - Border: 1px; the card border for info and success, the status border for
582
+ * warning and destructive
567
583
  * - Shadow: sm (subtle elevation)
568
584
  * - Font: 14px (text-sm)
569
585
  * - Layout: Flex with gap-3 for icon/content spacing
570
- * - Colors: Light backgrounds with dark text for WCAG 2.2 AA compliance
586
+ * - Colors: the page's foreground text; the icon in the status's text colour
571
587
  *
572
588
  * Variants (4 total):
573
589
  * - info (default): Blue - informational messages, neutral announcements
@@ -624,10 +640,10 @@ Stat.displayName = "Stat";
624
640
  */
625
641
  const alertVariants = (0, class_variance_authority.cva)("relative flex items-start gap-3 rounded-md border border-border p-4 text-sm transition-colors duration-150", {
626
642
  variants: { variant: {
627
- info: "bg-primary/5 text-primary",
628
- 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",
629
- 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",
630
- 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"
643
+ info: "border-border bg-card text-foreground [&>svg]:text-info-text",
644
+ success: "border-border bg-card text-foreground [&>svg]:text-success-text",
645
+ warning: "border-warning-border bg-warning-surface text-foreground [&>svg]:text-warning-text",
646
+ destructive: "border-danger-border bg-danger-surface text-foreground [&>svg]:text-danger-text"
631
647
  } },
632
648
  defaultVariants: { variant: "info" }
633
649
  });
@@ -780,12 +796,13 @@ function Separator({ className, orientation = "horizontal", decorative = true, .
780
796
  * @see {@link https://adrianroselli.com/2020/11/more-accessible-skeletons.html More Accessible Skeletons}
781
797
  * @experimental
782
798
  */
783
- const Skeleton = react.forwardRef(({ className, ...props }, ref) => {
799
+ const Skeleton = react.forwardRef(({ className, still = false, ...props }, ref) => {
784
800
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
785
801
  ref,
786
802
  "data-slot": "skeleton",
803
+ "data-still": still ? "" : void 0,
787
804
  "aria-hidden": "true",
788
- className: cn("bg-primary/5 animate-pulse rounded-md motion-reduce:animate-none", className),
805
+ className: cn(still ? "bg-secondary rounded-md" : "bg-primary/5 animate-pulse rounded-md motion-reduce:animate-none", className),
789
806
  ...props
790
807
  });
791
808
  });
@@ -800,7 +817,7 @@ Skeleton.displayName = "Skeleton";
800
817
  const progressVariants = (0, class_variance_authority.cva)("h-full rounded-none transition-all", {
801
818
  variants: { variant: {
802
819
  default: "bg-primary-500",
803
- success: "bg-success-500",
820
+ success: "bg-success-solid",
804
821
  error: "bg-destructive"
805
822
  } },
806
823
  defaultVariants: { variant: "default" }
@@ -1411,7 +1428,7 @@ const TabsList = (0, react.forwardRef)(({ className, variant, scrollable = false
1411
1428
  });
1412
1429
  });
1413
1430
  TabsList.displayName = _radix_ui_react_tabs.List.displayName;
1414
- const tabsTriggerVariants = (0, class_variance_authority.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", {
1431
+ const tabsTriggerVariants = (0, class_variance_authority.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", {
1415
1432
  variants: { size: {
1416
1433
  default: "text-sm",
1417
1434
  sm: "text-xs"
@@ -2274,6 +2291,65 @@ const sheetVariants = (0, class_variance_authority.cva)("fixed z-50 gap-4 bg-bac
2274
2291
  } },
2275
2292
  defaultVariants: { side: "right" }
2276
2293
  });
2294
+ /** How far down, as a share of the sheet's height, a drag must go to close it. */
2295
+ const DISMISS_SHARE = .25;
2296
+ /** A release faster than this, in px per ms, closes it from a shorter drag. */
2297
+ const FLICK_SPEED = .6;
2298
+ /** The shortest drag a flick closes from, so a tap never closes the sheet. */
2299
+ const FLICK_MIN_DISTANCE = 24;
2300
+ /** Whether a drag released at `distance` after `elapsed` ms closes the sheet. */
2301
+ function dragCloses(distance, elapsed, height) {
2302
+ if (distance >= height * DISMISS_SHARE) return true;
2303
+ return distance >= FLICK_MIN_DISTANCE && distance / Math.max(elapsed, 1) >= FLICK_SPEED;
2304
+ }
2305
+ /**
2306
+ * The grab strip: the sheet follows the pointer down (never up), and on
2307
+ * release either closes or springs back. It moves the sheet with an inline
2308
+ * transform, so the closing slide continues from where the finger let go.
2309
+ */
2310
+ function SheetDragHandle({ onDismiss }) {
2311
+ const drag = react.useRef(null);
2312
+ const onPointerDown = (event) => {
2313
+ const sheet = event.currentTarget.closest("[data-slot='sheet-content']");
2314
+ if (!sheet) return;
2315
+ event.currentTarget.setPointerCapture?.(event.pointerId);
2316
+ drag.current = {
2317
+ y: event.clientY,
2318
+ time: performance.now(),
2319
+ height: sheet.getBoundingClientRect().height,
2320
+ sheet
2321
+ };
2322
+ sheet.style.transition = "none";
2323
+ };
2324
+ const onPointerMove = (event) => {
2325
+ const start = drag.current;
2326
+ if (!start) return;
2327
+ const distance = Math.max(0, event.clientY - start.y);
2328
+ start.sheet.style.transform = `translateY(${distance}px)`;
2329
+ };
2330
+ const release = (event, cancelled) => {
2331
+ const start = drag.current;
2332
+ if (!start) return;
2333
+ drag.current = null;
2334
+ start.sheet.style.transition = "";
2335
+ const distance = Math.max(0, event.clientY - start.y);
2336
+ if (!cancelled && dragCloses(distance, performance.now() - start.time, start.height)) {
2337
+ onDismiss();
2338
+ return;
2339
+ }
2340
+ start.sheet.style.transform = "";
2341
+ };
2342
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2343
+ "aria-hidden": "true",
2344
+ "data-slot": "sheet-drag-handle",
2345
+ className: "flex h-6 w-full shrink-0 cursor-grab touch-none items-center justify-center active:cursor-grabbing",
2346
+ onPointerDown,
2347
+ onPointerMove,
2348
+ onPointerUp: (event) => release(event, false),
2349
+ onPointerCancel: (event) => release(event, true),
2350
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "h-1 w-10 rounded-full bg-border" })
2351
+ });
2352
+ }
2277
2353
  /**
2278
2354
  * SheetContent
2279
2355
  *
@@ -2288,17 +2364,24 @@ const sheetVariants = (0, class_variance_authority.cva)("fixed z-50 gap-4 bg-bac
2288
2364
  * @param side - Which edge to slide in from: "left", "right", "top", "bottom"
2289
2365
  * @public
2290
2366
  */
2291
- const SheetContent = react.forwardRef(({ side = "right", className, children, ...props }, ref) => {
2367
+ const SheetContent = react.forwardRef(({ side = "right", className, children, dragHandle = false, ...props }, ref) => {
2292
2368
  const portalContainer = usePortalContainer();
2293
2369
  const modal = react.useContext(SheetModalContext);
2370
+ const close = react.useRef(null);
2371
+ const draggable = dragHandle && side === "bottom";
2294
2372
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SheetPortal, {
2295
2373
  container: portalContainer,
2296
- children: [modal ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetOverlay, {}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dialog.Content, {
2374
+ children: [modal ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetOverlay, {}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dialog.Content, {
2297
2375
  ref,
2298
2376
  "data-slot": "sheet-content",
2299
2377
  className: cn(sheetVariants({ side }), className),
2300
2378
  ...props,
2301
- children
2379
+ children: [draggable ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetDragHandle, { onDismiss: () => close.current?.click() }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dialog.Close, {
2380
+ ref: close,
2381
+ hidden: true,
2382
+ tabIndex: -1,
2383
+ "aria-hidden": "true"
2384
+ })] }) : null, children]
2302
2385
  })]
2303
2386
  });
2304
2387
  });
@@ -2422,7 +2505,7 @@ const CommandDialog = ({ children, commandProps, contentProps, ...props }) => {
2422
2505
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CommandDialogOverlay, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dialog.Content, {
2423
2506
  ...contentProps,
2424
2507
  "data-slot": "command-content",
2425
- 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%]"),
2508
+ 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"),
2426
2509
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Command, {
2427
2510
  ...commandProps,
2428
2511
  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),
@@ -2499,7 +2582,7 @@ CommandSeparator.displayName = "CommandSeparator";
2499
2582
  */
2500
2583
  const CommandItem = (0, react.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(cmdk.Command.Item, {
2501
2584
  ref,
2502
- 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),
2585
+ 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),
2503
2586
  ...props
2504
2587
  }));
2505
2588
  CommandItem.displayName = "CommandItem";
@@ -2747,7 +2830,15 @@ function Toaster({ theme = "system", ...props }) {
2747
2830
  "--normal-border": "var(--nx-border)",
2748
2831
  "--border-radius": "0px",
2749
2832
  "--success-bg": "var(--nx-toast-success-bg)",
2750
- "--success-text": "var(--nx-toast-success-text)"
2833
+ "--success-text": "var(--nx-toast-success-text)",
2834
+ "--warning-bg": "var(--nx-toast-warning-bg)",
2835
+ "--warning-text": "var(--nx-toast-warning-text)",
2836
+ "--error-bg": "var(--nx-danger-surface)",
2837
+ "--error-border": "var(--nx-danger-border)",
2838
+ "--error-text": "var(--nx-danger-text)",
2839
+ "--info-bg": "var(--nx-info-surface)",
2840
+ "--info-border": "var(--nx-info-border)",
2841
+ "--info-text": "var(--nx-info-text)"
2751
2842
  },
2752
2843
  ...props
2753
2844
  });
@@ -3647,6 +3738,963 @@ function ColorPicker({ color, onColorChange, swatches = [], onSwatchSelect, rece
3647
3738
  ]
3648
3739
  });
3649
3740
  }
3741
+ // src/components/icon-glyph.tsx
3742
+ /** The shape elements a body may contain. */
3743
+ const SHAPES = /* @__PURE__ */ new Set([
3744
+ "path",
3745
+ "circle",
3746
+ "ellipse",
3747
+ "line",
3748
+ "polygon",
3749
+ "polyline",
3750
+ "rect"
3751
+ ]);
3752
+ /** The attributes a shape may carry: geometry, and its fill. */
3753
+ const GEOMETRY = /* @__PURE__ */ new Set([
3754
+ "d",
3755
+ "cx",
3756
+ "cy",
3757
+ "r",
3758
+ "rx",
3759
+ "ry",
3760
+ "x",
3761
+ "y",
3762
+ "x1",
3763
+ "x2",
3764
+ "y1",
3765
+ "y2",
3766
+ "width",
3767
+ "height",
3768
+ "points",
3769
+ "fill"
3770
+ ]);
3771
+ /** The fills a shape may name: none, or the text colour. */
3772
+ const FILLS = /* @__PURE__ */ new Set(["none", "currentColor"]);
3773
+ /**
3774
+ * Read bodies, by body. A picker draws the same few hundred icons on every
3775
+ * scroll, and reading each once is what keeps a scroll from re-reading them.
3776
+ * Bounded so a host searching several large sets cannot grow it without end.
3777
+ */
3778
+ const readBodies = /* @__PURE__ */ new Map();
3779
+ const READ_BODIES_LIMIT = 4096;
3780
+ /** One element and the attributes after its name, anchored where the last one ended. */
3781
+ const ELEMENT = /\s*<([a-z]+)((?:\s+[a-zA-Z0-9-]+="[^"<>]*")*)\s*\/>/y;
3782
+ const ATTRIBUTE = /([a-zA-Z0-9-]+)="([^"<>]*)"/g;
3783
+ /** A shape's attributes, or `null` when any is not allowed geometry. */
3784
+ function readAttributes(text) {
3785
+ const attributes = {};
3786
+ for (const [, name = "", value = ""] of text.matchAll(ATTRIBUTE)) {
3787
+ if (!(GEOMETRY.has(name) && (name !== "fill" || FILLS.has(value)))) return null;
3788
+ attributes[name] = value;
3789
+ }
3790
+ return attributes;
3791
+ }
3792
+ /** The shape at `at` and where it ends, or `null` when none starts there. */
3793
+ function readShape(body, at) {
3794
+ ELEMENT.lastIndex = at;
3795
+ const match = ELEMENT.exec(body);
3796
+ const tag = match?.[1];
3797
+ if (match === null || tag === void 0 || !SHAPES.has(tag)) return null;
3798
+ const attributes = readAttributes(match[2] ?? "");
3799
+ return attributes === null ? null : {
3800
+ shape: {
3801
+ tag,
3802
+ attributes
3803
+ },
3804
+ end: ELEMENT.lastIndex
3805
+ };
3806
+ }
3807
+ /**
3808
+ * A body read as shapes, or `null` when any part of it is not one: every
3809
+ * element must be an allowed shape, every attribute allowed geometry, and
3810
+ * nothing may sit between the elements but whitespace.
3811
+ */
3812
+ function readBody(body) {
3813
+ const cached = readBodies.get(body);
3814
+ if (cached !== void 0) return cached;
3815
+ let shapes = [];
3816
+ let at = 0;
3817
+ while (shapes !== null && body.slice(at).trim() !== "") {
3818
+ const read = readShape(body, at);
3819
+ if (read === null) shapes = null;
3820
+ else {
3821
+ shapes.push(read.shape);
3822
+ at = read.end;
3823
+ }
3824
+ }
3825
+ if (readBodies.size >= READ_BODIES_LIMIT) readBodies.clear();
3826
+ readBodies.set(body, shapes);
3827
+ return shapes;
3828
+ }
3829
+ /**
3830
+ * An icon from an {@link IconSource}, drawn as an inline SVG in the text
3831
+ * colour.
3832
+ *
3833
+ * Decorative by default (`aria-hidden`): the control around it names the
3834
+ * icon. The body is read into React elements rather than inserted as markup,
3835
+ * and a body that is not a run of plain shapes draws an empty box.
3836
+ *
3837
+ * @experimental
3838
+ */
3839
+ function IconGlyph({ icon, className, ...props }) {
3840
+ const shapes = readBody(icon.body) ?? [];
3841
+ const stroked = icon.stroked !== false;
3842
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
3843
+ xmlns: "http://www.w3.org/2000/svg",
3844
+ viewBox: icon.viewBox,
3845
+ "aria-hidden": "true",
3846
+ focusable: "false",
3847
+ fill: stroked ? "none" : "currentColor",
3848
+ stroke: stroked ? "currentColor" : "none",
3849
+ strokeWidth: stroked ? 2 : void 0,
3850
+ strokeLinecap: stroked ? "round" : void 0,
3851
+ strokeLinejoin: stroked ? "round" : void 0,
3852
+ className: cn("size-4 shrink-0", className),
3853
+ ...props,
3854
+ children: shapes.map((shape, index) => react.createElement(shape.tag, {
3855
+ key: index,
3856
+ ...shape.attributes
3857
+ }))
3858
+ });
3859
+ }
3860
+ /**
3861
+ * An icon's name as a person reads it: `circle-arrow-up` is
3862
+ * `Circle arrow up`.
3863
+ */
3864
+ function iconDisplayName(name) {
3865
+ const words = name.replace(/-/g, " ").trim();
3866
+ return words.charAt(0).toUpperCase() + words.slice(1);
3867
+ }
3868
+ // src/components/icon-picker.tsx
3869
+ /** Icons per row of the results grid. */
3870
+ const COLUMNS = 8;
3871
+ /** One row of the grid: a 38px cell and the 2px gap below it. */
3872
+ const ROW_HEIGHT$1 = 40;
3873
+ /** Rows a Page Up or Page Down moves the highlight by. */
3874
+ const PAGE_ROWS = 5;
3875
+ /** How the picker's headings are set: small capitals in the muted ink. */
3876
+ const HEADING_TEXT = "px-3 pb-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground";
3877
+ /** A heading inside the grid, "Recent" or "All icons": its line and the space above. */
3878
+ const HEADING_HEIGHT = 28;
3879
+ /** How many recently used icons the picker offers: one row of the grid. */
3880
+ const RECENT_SHOWN = COLUMNS;
3881
+ const loads = /* @__PURE__ */ new WeakMap();
3882
+ const loaded = /* @__PURE__ */ new WeakMap();
3883
+ function loadOnce(load) {
3884
+ const existing = loads.get(load);
3885
+ if (existing !== void 0) return existing;
3886
+ const loading = load();
3887
+ loads.set(load, loading);
3888
+ loading.then((source) => loaded.set(load, source), () => {
3889
+ if (loads.get(load) === loading) loads.delete(load);
3890
+ });
3891
+ return loading;
3892
+ }
3893
+ /**
3894
+ * The icon source, loaded once `wanted` turns true, and a way to try again
3895
+ * after a failed load.
3896
+ */
3897
+ function useIconSource(load, wanted) {
3898
+ const [state, setState] = react.useState(() => {
3899
+ const source = loaded.get(load);
3900
+ return source === void 0 ? { status: "loading" } : {
3901
+ status: "ready",
3902
+ source
3903
+ };
3904
+ });
3905
+ const [attempt, setAttempt] = react.useState(0);
3906
+ react.useEffect(() => {
3907
+ if (!wanted) return;
3908
+ let current = true;
3909
+ setState((previous) => previous.status === "ready" ? previous : { status: "loading" });
3910
+ loadOnce(load).then((source) => {
3911
+ if (current) setState({
3912
+ status: "ready",
3913
+ source
3914
+ });
3915
+ }, () => {
3916
+ if (current) setState({ status: "failed" });
3917
+ });
3918
+ return () => {
3919
+ current = false;
3920
+ };
3921
+ }, [
3922
+ load,
3923
+ wanted,
3924
+ attempt
3925
+ ]);
3926
+ return [state, () => setAttempt((n) => n + 1)];
3927
+ }
3928
+ /**
3929
+ * What a stored id draws as, once the source can say, and a way to ask again
3930
+ * after the asking failed.
3931
+ */
3932
+ function useResolvedIcon(source, id) {
3933
+ const [resolved, setResolved] = react.useState(null);
3934
+ const [attempt, setAttempt] = react.useState(0);
3935
+ const ready = source.status === "ready" ? source.source : null;
3936
+ react.useEffect(() => {
3937
+ if (ready === null || !id) return;
3938
+ let current = true;
3939
+ ready.resolve(id).then((icon) => {
3940
+ if (!current) return;
3941
+ setResolved({
3942
+ id,
3943
+ attempt,
3944
+ answer: icon === null ? { status: "missing" } : {
3945
+ status: "found",
3946
+ icon
3947
+ }
3948
+ });
3949
+ }, () => {
3950
+ if (current) setResolved({
3951
+ id,
3952
+ attempt,
3953
+ answer: { status: "failed" }
3954
+ });
3955
+ });
3956
+ return () => {
3957
+ current = false;
3958
+ };
3959
+ }, [
3960
+ ready,
3961
+ id,
3962
+ attempt
3963
+ ]);
3964
+ const retry = () => setAttempt((n) => n + 1);
3965
+ if (!id) return [{ status: "none" }, retry];
3966
+ if (resolved?.id === id && (resolved.answer.status !== "failed" || resolved.attempt === attempt)) return [resolved.answer, retry];
3967
+ return [source.status === "failed" ? { status: "failed" } : { status: "loading" }, retry];
3968
+ }
3969
+ /** The set and name an id carries, read without the set: `lucide:star`. */
3970
+ function partsOf(id) {
3971
+ const colon = id.indexOf(":");
3972
+ return colon === -1 ? {
3973
+ set: "",
3974
+ name: id
3975
+ } : {
3976
+ set: id.slice(0, colon),
3977
+ name: id.slice(colon + 1)
3978
+ };
3979
+ }
3980
+ /** The rows of icons from `start` up to `end`, eight to a row. */
3981
+ function iconRows(start, end) {
3982
+ const rows = [];
3983
+ for (let at = start; at < end; at += COLUMNS) rows.push({
3984
+ kind: "icons",
3985
+ start: at,
3986
+ end: Math.min(end, at + COLUMNS)
3987
+ });
3988
+ return rows;
3989
+ }
3990
+ /**
3991
+ * The grid's rows: the recently used icons under "Recent" and the rest under
3992
+ * `label` ("All icons", or the search's matches) when there are any recent
3993
+ * ones to show, otherwise the icons alone, under the heading above the grid.
3994
+ */
3995
+ function gridRows(recentCount, count, label) {
3996
+ if (recentCount === 0) return iconRows(0, count);
3997
+ return [
3998
+ {
3999
+ kind: "heading",
4000
+ label: "Recent"
4001
+ },
4002
+ ...iconRows(0, recentCount),
4003
+ {
4004
+ kind: "heading",
4005
+ label
4006
+ },
4007
+ ...iconRows(recentCount, count)
4008
+ ];
4009
+ }
4010
+ /** What the icons below the Recent row are: the whole set, or a search's matches. */
4011
+ function resultsLabel(query) {
4012
+ return query === "" ? "All icons" : `Matches for “${query}”`;
4013
+ }
4014
+ /** The rows the arrow and page keys move the highlight up or down by. */
4015
+ const ROW_STEPS = {
4016
+ ArrowUp: -1,
4017
+ ArrowDown: 1,
4018
+ PageUp: -5,
4019
+ PageDown: PAGE_ROWS
4020
+ };
4021
+ /**
4022
+ * Where a key moves the highlight from `active` in the grid's rows, or
4023
+ * `undefined` for a key the grid does not answer. Left and right move by one
4024
+ * icon, across rows; up and down move by rows of icons, past a heading,
4025
+ * keeping the column, or the last icon of a shorter row. Up from the top row
4026
+ * stays put rather than jumping to the first icon.
4027
+ */
4028
+ function stepFrom(key, active, rows) {
4029
+ const icons = rows.filter((row) => row.kind === "icons");
4030
+ const last = icons.at(-1);
4031
+ if (last === void 0) return void 0;
4032
+ if (key === "ArrowLeft") return Math.max(0, active - 1);
4033
+ if (key === "ArrowRight") return Math.min(last.end - 1, active + 1);
4034
+ const step = ROW_STEPS[key];
4035
+ if (step === void 0) return void 0;
4036
+ const at = icons.findIndex((row) => active >= row.start && active < row.end);
4037
+ const from = icons[at];
4038
+ const to = icons[Math.min(icons.length - 1, Math.max(0, at + step))];
4039
+ if (from === void 0 || to === void 0) return void 0;
4040
+ return Math.min(to.end - 1, to.start + (active - from.start));
4041
+ }
4042
+ /** The row an option is drawn in, for scrolling it into view. */
4043
+ function rowOf(rows, index) {
4044
+ return Math.max(0, rows.findIndex((row) => row.kind === "icons" && index >= row.start && index < row.end));
4045
+ }
4046
+ /**
4047
+ * The recently used icons to offer, newest first: the ids the host remembers
4048
+ * that the set still draws, found among the whole set's icons, which the
4049
+ * picker has from the browse it opens on. Offered above a search's matches
4050
+ * too, so an icon used a moment ago is one press away whatever is typed.
4051
+ */
4052
+ function recentAmong(wholeSet, recentIds) {
4053
+ if (wholeSet === null || recentIds === void 0) return [];
4054
+ const byId = new Map(wholeSet.map((icon) => [icon.id, icon]));
4055
+ const recent = [];
4056
+ for (const id of new Set(recentIds)) {
4057
+ const icon = byId.get(id);
4058
+ if (icon !== void 0) recent.push(icon);
4059
+ if (recent.length === RECENT_SHOWN) break;
4060
+ }
4061
+ return recent;
4062
+ }
4063
+ /** What the picker's status line says, for the results in hand. */
4064
+ function announcementFor(results, failed, query) {
4065
+ if (results === null) return failed ? "The icons could not be loaded." : "Loading icons.";
4066
+ if (results.length === 0) return `No icons match “${query}”.`;
4067
+ const icons = `${results.length} ${results.length === 1 ? "icon" : "icons"}`;
4068
+ return query === "" ? `${icons}.` : `${icons} match “${query}”.`;
4069
+ }
4070
+ /**
4071
+ * The results for a query, and the highlighted one among them.
4072
+ *
4073
+ * The latest search wins: results arrive asynchronously, so a slow answer to
4074
+ * "tr" must not replace the answer to "truck" that came back first, and
4075
+ * until the query typed is answered the search is `pending`. Browsing (an
4076
+ * empty query) highlights the chosen icon, once `currentSettled` says which
4077
+ * icon `currentId` is; a search highlights its best match. The highlight is a
4078
+ * place among the options as drawn, which while browsing start with the
4079
+ * Recent row the host's `recentIds` give.
4080
+ */
4081
+ function useIconSearch(source, query, currentId, currentSettled, recentIds) {
4082
+ const [answer, setAnswer] = react.useState(null);
4083
+ const [wholeSet, setWholeSet] = react.useState(null);
4084
+ const [attempt, setAttempt] = react.useState(0);
4085
+ const [active, setActive] = react.useState(0);
4086
+ const [start, setStart] = react.useState(null);
4087
+ const placed = react.useRef(null);
4088
+ const place = react.useEffectEvent((found) => {
4089
+ if (found.status !== "found" || !currentSettled) return;
4090
+ placed.current = {
4091
+ answer: found,
4092
+ wholeSet
4093
+ };
4094
+ const browsing = found.query.trim() === "";
4095
+ const recent = recentAmong(browsing ? found.results : wholeSet, recentIds);
4096
+ const options = [...recent, ...found.results];
4097
+ const chosen = browsing && currentId ? options.findIndex((icon) => icon.id === currentId) : -1;
4098
+ const index = browsing ? Math.max(0, chosen) : found.results.length > 0 ? recent.length : 0;
4099
+ setActive(index);
4100
+ setStart({
4101
+ index,
4102
+ centred: chosen > 0
4103
+ });
4104
+ });
4105
+ const land = react.useEffectEvent((found) => {
4106
+ setAnswer(found);
4107
+ place(found);
4108
+ });
4109
+ const wantsRecent = recentIds !== void 0 && recentIds.length > 0;
4110
+ react.useEffect(() => {
4111
+ if (source === null || !wantsRecent) return;
4112
+ let current = true;
4113
+ source.search("").then((results) => {
4114
+ if (!current) return;
4115
+ setWholeSet(results);
4116
+ }, () => {});
4117
+ return () => {
4118
+ current = false;
4119
+ };
4120
+ }, [source, wantsRecent]);
4121
+ react.useEffect(() => {
4122
+ if (answer !== null && (placed.current?.answer !== answer || placed.current.wholeSet !== wholeSet)) place(answer);
4123
+ }, [
4124
+ answer,
4125
+ currentSettled,
4126
+ wholeSet
4127
+ ]);
4128
+ const latest = react.useRef(0);
4129
+ react.useEffect(() => {
4130
+ if (source === null) return;
4131
+ const search = ++latest.current;
4132
+ source.search(query).then((results) => {
4133
+ if (search === latest.current) land({
4134
+ status: "found",
4135
+ results,
4136
+ query,
4137
+ attempt
4138
+ });
4139
+ }, () => {
4140
+ if (search === latest.current) land({
4141
+ status: "failed",
4142
+ query,
4143
+ attempt
4144
+ });
4145
+ });
4146
+ }, [
4147
+ source,
4148
+ query,
4149
+ attempt
4150
+ ]);
4151
+ const pending = source !== null && (answer === null || answer.query !== query || answer.attempt !== attempt);
4152
+ return {
4153
+ results: answer?.status === "found" ? answer.results : null,
4154
+ answered: answer?.query.trim() ?? "",
4155
+ failed: answer?.status === "failed",
4156
+ pending,
4157
+ active,
4158
+ setActive,
4159
+ start,
4160
+ retry: () => setAttempt((n) => n + 1),
4161
+ wholeSet
4162
+ };
4163
+ }
4164
+ /**
4165
+ * How results awaiting a newer answer are drawn: kept, and dimmed.
4166
+ *
4167
+ * Kept rather than cleared because most answers land within a frame or two,
4168
+ * and a grid emptied on every keystroke would flash its loading line while
4169
+ * the person types. Dimmed only after a short delay for the same reason, so
4170
+ * a quick answer never visibly dims; a slow one fades the stale icons back
4171
+ * to say they are not what Enter chooses. Brightening again has no delay.
4172
+ */
4173
+ function pendingFade(pending) {
4174
+ return cn("transition-opacity", pending && "opacity-50 delay-150");
4175
+ }
4176
+ /** What stands in the grid while there is nothing to choose from. */
4177
+ function PickerMessage({ results, failed, query, onRetry }) {
4178
+ if (results !== null && results.length > 0) return null;
4179
+ if (results === null && failed) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4180
+ className: "flex flex-col items-center gap-2 py-8 text-center text-muted-foreground",
4181
+ children: [
4182
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.TriangleAlert, {
4183
+ className: "size-5",
4184
+ "aria-hidden": "true"
4185
+ }),
4186
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "The icons could not be loaded." }),
4187
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
4188
+ type: "button",
4189
+ variant: "outline",
4190
+ size: "sm",
4191
+ onClick: onRetry,
4192
+ children: "Try again"
4193
+ })
4194
+ ]
4195
+ });
4196
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4197
+ className: "py-8 text-center text-muted-foreground",
4198
+ children: results === null ? "Loading icons…" : `No icons match “${query}”.`
4199
+ });
4200
+ }
4201
+ /** One icon in the grid: an option of the listbox. */
4202
+ function IconOption({ icon, id, index, count, isActive, isCurrent, isRecent, onHighlight, onChoose }) {
4203
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4204
+ id,
4205
+ role: "option",
4206
+ "aria-selected": isActive,
4207
+ "aria-setsize": count,
4208
+ "aria-posinset": index + 1,
4209
+ "aria-label": `${iconDisplayName(icon.name)}${isRecent ? ", recent" : ""}${isCurrent ? ", current" : ""}`,
4210
+ "data-current": isCurrent || void 0,
4211
+ onMouseDown: (event) => event.preventDefault(),
4212
+ onMouseMove: () => {
4213
+ if (!isActive) onHighlight(index);
4214
+ },
4215
+ onClick: () => onChoose(icon),
4216
+ 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"),
4217
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconGlyph, {
4218
+ icon,
4219
+ className: "size-5"
4220
+ })
4221
+ });
4222
+ }
4223
+ /** The highlighted icon, large, with its name and the words it is found by. */
4224
+ function HighlightedIcon({ icon, className }) {
4225
+ const words = (icon?.tags ?? []).slice(0, 3).join(", ");
4226
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4227
+ className: cn("flex min-h-[57px] items-center gap-2.5 border-t border-border px-3 py-2", className),
4228
+ children: icon === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4229
+ className: "grid size-9 shrink-0 place-items-center rounded-md bg-muted",
4230
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconGlyph, {
4231
+ icon,
4232
+ className: "size-[22px]"
4233
+ })
4234
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
4235
+ className: "min-w-0",
4236
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4237
+ className: "block truncate font-semibold",
4238
+ children: iconDisplayName(icon.name)
4239
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4240
+ className: "block truncate text-xs text-muted-foreground",
4241
+ children: words === "" ? icon.name : `${icon.name} · ${words}`
4242
+ })]
4243
+ })] })
4244
+ });
4245
+ }
4246
+ /**
4247
+ * A search-first icon picker: a search box over a grid of the matching icons,
4248
+ * and the highlighted icon's name and tags beneath.
4249
+ *
4250
+ * The search box keeps focus throughout, as a combobox. The arrow keys move a
4251
+ * highlight through the grid (left and right by one icon, up and down by a
4252
+ * row), Page Up and Page Down by several rows, and Enter chooses the
4253
+ * highlighted icon; the first match is highlighted as soon as results arrive,
4254
+ * so typing and pressing Enter chooses the best match. The grid is a listbox
4255
+ * that renders only the rows in view, which is what keeps a set of nearly two
4256
+ * thousand icons quick to open. How many icons match is announced politely.
4257
+ *
4258
+ * @experimental
4259
+ */
4260
+ function IconPicker({ loadIcons, value, onChoose, recentIcons, className }) {
4261
+ const base = react.useId();
4262
+ const listId = `${base}-icons`;
4263
+ const optionId = (index) => `${base}-icon-${index}`;
4264
+ const [sourceState, retryLoad] = useIconSource(loadIcons, true);
4265
+ const source = sourceState.status === "ready" ? sourceState.source : null;
4266
+ const [query, setQuery] = react.useState("");
4267
+ const scrollRef = react.useRef(null);
4268
+ const inputRef = react.useRef(null);
4269
+ const [current] = useResolvedIcon(sourceState, value);
4270
+ const currentId = current.status === "found" ? current.icon.id : value;
4271
+ const { results, answered, failed: searchFailed, pending, active, setActive, start, retry: retrySearch, wholeSet } = useIconSearch(source, query, currentId, current.status !== "loading", recentIcons);
4272
+ const { options, recentCount } = react.useMemo(() => {
4273
+ const recent = recentAmong(wholeSet, recentIcons);
4274
+ return {
4275
+ options: [...recent, ...results ?? []],
4276
+ recentCount: recent.length
4277
+ };
4278
+ }, [
4279
+ results,
4280
+ wholeSet,
4281
+ recentIcons
4282
+ ]);
4283
+ const count = options.length;
4284
+ const rows = react.useMemo(() => gridRows(recentCount, count, resultsLabel(answered)), [
4285
+ recentCount,
4286
+ count,
4287
+ answered
4288
+ ]);
4289
+ const highlighted = pending ? void 0 : options[active];
4290
+ const trimmed = query.trim();
4291
+ const failed = sourceState.status === "failed" || searchFailed && !pending;
4292
+ const retry = () => {
4293
+ if (sourceState.status === "failed") retryLoad();
4294
+ else retrySearch();
4295
+ inputRef.current?.focus();
4296
+ };
4297
+ const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
4298
+ count: rows.length,
4299
+ getScrollElement: () => scrollRef.current,
4300
+ estimateSize: (index) => rows[index]?.kind === "heading" ? HEADING_HEIGHT : ROW_HEIGHT$1,
4301
+ overscan: 4
4302
+ });
4303
+ const scrollToStart = react.useEffectEvent((at) => {
4304
+ virtualizer.scrollToIndex(at.centred ? rowOf(rows, at.index) : 0, { align: at.centred ? "center" : "start" });
4305
+ });
4306
+ react.useEffect(() => {
4307
+ if (start !== null) scrollToStart(start);
4308
+ }, [start]);
4309
+ const chooseAnswered = (icon) => {
4310
+ if (!pending) onChoose(icon);
4311
+ };
4312
+ const message = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PickerMessage, {
4313
+ results,
4314
+ failed,
4315
+ query: answered,
4316
+ onRetry: retry
4317
+ });
4318
+ const onKeyDown = (event) => {
4319
+ if (pending) {
4320
+ if (event.key === "Enter") event.preventDefault();
4321
+ return;
4322
+ }
4323
+ const next = stepFrom(event.key, active, rows);
4324
+ if (next !== void 0) {
4325
+ event.preventDefault();
4326
+ setActive(next);
4327
+ virtualizer.scrollToIndex(rowOf(rows, next), { align: "auto" });
4328
+ return;
4329
+ }
4330
+ if (event.key === "Enter" && highlighted !== void 0) {
4331
+ event.preventDefault();
4332
+ onChoose(highlighted);
4333
+ }
4334
+ };
4335
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4336
+ className: cn("flex h-[min(452px,70vh,var(--radix-popover-content-available-height,452px))] flex-col text-sm text-foreground", className),
4337
+ children: [
4338
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4339
+ 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",
4340
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Search, {
4341
+ className: "size-[15px] shrink-0 text-muted-foreground",
4342
+ "aria-hidden": "true"
4343
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
4344
+ ref: inputRef,
4345
+ type: "text",
4346
+ role: "combobox",
4347
+ "aria-label": "Search icons",
4348
+ "aria-expanded": "true",
4349
+ "aria-controls": listId,
4350
+ "aria-autocomplete": "list",
4351
+ "aria-activedescendant": highlighted === void 0 ? void 0 : optionId(active),
4352
+ autoComplete: "off",
4353
+ spellCheck: false,
4354
+ placeholder: "Search icons",
4355
+ value: query,
4356
+ onChange: (event) => setQuery(event.target.value),
4357
+ onKeyDown,
4358
+ className: "min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
4359
+ })]
4360
+ }),
4361
+ recentCount > 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4362
+ className: HEADING_TEXT,
4363
+ children: resultsLabel(trimmed)
4364
+ }),
4365
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4366
+ ref: scrollRef,
4367
+ className: "min-h-0 flex-1 overflow-y-auto px-2.5",
4368
+ children: [
4369
+ recentCount > 0 ? null : message,
4370
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4371
+ id: listId,
4372
+ role: "listbox",
4373
+ "aria-label": "Icons",
4374
+ "aria-busy": pending || void 0,
4375
+ className: cn("relative w-full", pendingFade(pending)),
4376
+ style: { height: virtualizer.getTotalSize() },
4377
+ children: virtualizer.getVirtualItems().map((item) => {
4378
+ const row = rows[item.index];
4379
+ if (row === void 0) return null;
4380
+ if (row.kind === "heading") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4381
+ "aria-hidden": "true",
4382
+ className: cn(HEADING_TEXT, "absolute inset-x-0 top-0 flex items-end px-0.5"),
4383
+ style: {
4384
+ height: HEADING_HEIGHT,
4385
+ transform: `translateY(${item.start}px)`
4386
+ },
4387
+ children: row.label
4388
+ }, item.key);
4389
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4390
+ role: "presentation",
4391
+ className: "absolute inset-x-0 top-0 grid grid-cols-8 gap-0.5",
4392
+ style: { transform: `translateY(${item.start}px)` },
4393
+ children: options.slice(row.start, row.end).map((icon, column) => {
4394
+ const index = row.start + column;
4395
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconOption, {
4396
+ icon,
4397
+ id: optionId(index),
4398
+ index,
4399
+ count,
4400
+ isActive: index === active,
4401
+ isCurrent: icon.id === currentId,
4402
+ isRecent: index < recentCount,
4403
+ onHighlight: setActive,
4404
+ onChoose: chooseAnswered
4405
+ }, icon.id);
4406
+ })
4407
+ }, item.key);
4408
+ })
4409
+ }),
4410
+ recentCount > 0 ? message : null
4411
+ ]
4412
+ }),
4413
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HighlightedIcon, {
4414
+ icon: options[active],
4415
+ className: pendingFade(pending)
4416
+ }),
4417
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4418
+ role: "status",
4419
+ "aria-live": "polite",
4420
+ className: "sr-only",
4421
+ children: announcementFor(results, failed, answered)
4422
+ })
4423
+ ]
4424
+ });
4425
+ }
4426
+ /** The text the field shows and speaks for a value, however it resolved. */
4427
+ function valueTextFor(value, resolved, source, label) {
4428
+ if (!value) return {
4429
+ name: "Choose an icon",
4430
+ set: "",
4431
+ spoken: `${label}: none chosen`
4432
+ };
4433
+ const parts = partsOf(value);
4434
+ const setName = source !== null && parts.set === source.prefix ? source.label : iconDisplayName(parts.set);
4435
+ if (resolved.status === "missing") return {
4436
+ name: parts.name,
4437
+ set: setName === "" ? "Not found" : `${setName} · not found`,
4438
+ spoken: `${label}: ${parts.name}, not found`
4439
+ };
4440
+ if (resolved.status === "failed") {
4441
+ const name = iconDisplayName(parts.name);
4442
+ return {
4443
+ name,
4444
+ set: setName === "" ? "Could not load" : `${setName} · could not load`,
4445
+ spoken: `${label}: ${name}, could not be loaded`
4446
+ };
4447
+ }
4448
+ const name = iconDisplayName(resolved.status === "found" ? resolved.icon.name : parts.name);
4449
+ return {
4450
+ name,
4451
+ set: setName,
4452
+ spoken: `${label}: ${name}`
4453
+ };
4454
+ }
4455
+ /** The tile the chosen icon is drawn in, or what stands in for it. */
4456
+ function IconSwatch({ resolved }) {
4457
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4458
+ 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"),
4459
+ children: resolved.status === "found" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconGlyph, {
4460
+ icon: resolved.icon,
4461
+ className: "size-[18px]"
4462
+ }) : resolved.status === "missing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CircleHelp, {
4463
+ className: "size-[18px] text-muted-foreground",
4464
+ "aria-hidden": "true"
4465
+ }) : resolved.status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.TriangleAlert, {
4466
+ className: "size-[18px] text-muted-foreground",
4467
+ "aria-hidden": "true"
4468
+ }) : null
4469
+ });
4470
+ }
4471
+ /** What the field's button shows: the swatch, the name, the set, a chevron. */
4472
+ function IconFieldFace({ resolved, text, empty }) {
4473
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
4474
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconSwatch, { resolved }),
4475
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
4476
+ className: "min-w-0 flex-1 leading-tight",
4477
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4478
+ className: cn("block text-sm font-medium [overflow-wrap:anywhere]", empty && "font-normal text-muted-foreground"),
4479
+ children: text.name
4480
+ }), text.set === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4481
+ className: "text-[11px] text-muted-foreground",
4482
+ children: text.set
4483
+ })]
4484
+ }),
4485
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
4486
+ className: "size-3.5 shrink-0 text-muted-foreground",
4487
+ "aria-hidden": "true"
4488
+ })
4489
+ ] });
4490
+ }
4491
+ /** The warning under a field whose icon the set no longer draws. */
4492
+ function MissingIconWarning({ shown, id }) {
4493
+ if (!shown) return null;
4494
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
4495
+ id,
4496
+ 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",
4497
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.TriangleAlert, {
4498
+ className: "mt-px size-3.5 shrink-0",
4499
+ "aria-hidden": "true"
4500
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "This icon is no longer available. Choose another." })]
4501
+ });
4502
+ }
4503
+ /**
4504
+ * The button that opens the picker. Every prop it is not given by name goes
4505
+ * to the `<button>`, so a popover trigger can hand it its ref, state and
4506
+ * handlers.
4507
+ */
4508
+ function IconFieldButton({ resolved, text, empty, interactive, invalid, readOnly, ...button }) {
4509
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4510
+ type: "button",
4511
+ ...button,
4512
+ "aria-label": text.spoken,
4513
+ "aria-invalid": invalid || void 0,
4514
+ "aria-disabled": readOnly || void 0,
4515
+ 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"),
4516
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconFieldFace, {
4517
+ resolved,
4518
+ text,
4519
+ empty
4520
+ })
4521
+ });
4522
+ }
4523
+ /** The bordered row the field's two buttons sit in. */
4524
+ function IconFieldFrame({ invalid, disabled, children }) {
4525
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4526
+ className: cn("flex w-full items-center rounded-md border border-input bg-background", invalid && "border-destructive", disabled && "opacity-50"),
4527
+ children
4528
+ });
4529
+ }
4530
+ /** A button that clears the field, drawn while there is a value to clear. */
4531
+ function ClearIconButton({ shown, onClear }) {
4532
+ if (!shown) return null;
4533
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4534
+ type: "button",
4535
+ "aria-label": "Clear icon",
4536
+ onClick: onClear,
4537
+ 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",
4538
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
4539
+ className: "size-[15px]",
4540
+ "aria-hidden": "true"
4541
+ })
4542
+ });
4543
+ }
4544
+ /**
4545
+ * What a field's value draws as and is called, loading the set when there is
4546
+ * an icon to draw or a picker to fill. Opening the picker asks again for
4547
+ * whichever failed to arrive, the set or the value's icon.
4548
+ */
4549
+ function useIconFieldValue(loadIcons, value, label, open) {
4550
+ const [sourceState, retryLoad] = useIconSource(loadIcons, Boolean(value) || open);
4551
+ const [resolved, retryResolve] = useResolvedIcon(sourceState, value);
4552
+ const source = sourceState.status === "ready" ? sourceState.source : null;
4553
+ const retryFailed = react.useEffectEvent(() => {
4554
+ if (sourceState.status === "failed") retryLoad();
4555
+ else if (resolved.status === "failed") retryResolve();
4556
+ });
4557
+ react.useEffect(() => {
4558
+ if (open) retryFailed();
4559
+ }, [open]);
4560
+ return {
4561
+ resolved,
4562
+ text: valueTextFor(value, resolved, source, label)
4563
+ };
4564
+ }
4565
+ /**
4566
+ * A button the field keeps a handle on and hands to the caller's ref too: the
4567
+ * field takes focus back to it after a clear, and a form focuses it from
4568
+ * outside. One callback ref gives the node to both.
4569
+ */
4570
+ function useSharedButtonRef(ref) {
4571
+ const own = react.useRef(null);
4572
+ return [own, react.useCallback((node) => {
4573
+ own.current = node;
4574
+ if (typeof ref === "function") ref(node);
4575
+ else if (ref) ref.current = node;
4576
+ }, [ref])];
4577
+ }
4578
+ /** The warning's id while the warning is drawn, for the button it describes. */
4579
+ function warningIdIf(missing, id) {
4580
+ return missing ? id : void 0;
4581
+ }
4582
+ /** Joins the ids describing an element, or `undefined` when there are none. */
4583
+ function describedByIds(...ids) {
4584
+ const joined = ids.filter((id) => id !== void 0 && id !== "").join(" ");
4585
+ return joined === "" ? void 0 : joined;
4586
+ }
4587
+ /** The popover the field's picker opens in, beside the field. */
4588
+ function IconFieldPopover({ ref, loadIcons, value, recentIcons, onChoose }) {
4589
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverContent, {
4590
+ ref,
4591
+ align: "start",
4592
+ collisionPadding: 8,
4593
+ "aria-label": "Choose an icon",
4594
+ className: "w-[min(360px,calc(100vw-32px))] rounded-[10px] p-0 shadow-lg motion-reduce:animate-none",
4595
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconPicker, {
4596
+ loadIcons,
4597
+ value,
4598
+ recentIcons,
4599
+ onChoose: (icon) => onChoose(icon.id)
4600
+ })
4601
+ });
4602
+ }
4603
+ /**
4604
+ * Whether the field's picker is open, and a setter that opens it only for a
4605
+ * field that can be changed and reports the field left when it closes.
4606
+ */
4607
+ function useReportedOpen(interactive, onBlur) {
4608
+ const [open, setOpen] = react.useState(false);
4609
+ const setOpenAndReport = (next) => {
4610
+ if (next && !interactive) return;
4611
+ setOpen(next);
4612
+ if (!next) onBlur?.();
4613
+ };
4614
+ return [open, setOpenAndReport];
4615
+ }
4616
+ /**
4617
+ * A blur handler for the field's wrapper that reports the field left when
4618
+ * focus moves from its buttons to somewhere outside the field. The picker sits
4619
+ * in a portal, elsewhere in the document, so it is checked by its own node;
4620
+ * its focus events still bubble to the wrapper through React. Focus never
4621
+ * leaves the open picker without closing it, and the close reports, so
4622
+ * nothing is reported while it is open or for focus leaving it.
4623
+ */
4624
+ function focusLeftReporter(open, pickerRef, onBlur) {
4625
+ return (event) => {
4626
+ const picker = pickerRef.current;
4627
+ if (open || picker?.contains(event.target)) return;
4628
+ const next = event.relatedTarget;
4629
+ if (!(next instanceof Node && (event.currentTarget.contains(next) || picker?.contains(next) === true))) onBlur?.();
4630
+ };
4631
+ }
4632
+ /**
4633
+ * A field holding one icon: a button showing the chosen icon, its name and
4634
+ * its set, which opens an {@link IconPicker}, and a button that clears it.
4635
+ *
4636
+ * An id the source no longer draws is shown by its name with a warning, and
4637
+ * kept until someone chooses another: the field never rewrites a stored value
4638
+ * on its own. Escape closes the picker and returns focus to the button.
4639
+ *
4640
+ * @experimental
4641
+ */
4642
+ function IconField({ value, onChange, loadIcons, label = "Icon", id, disabled = false, readOnly = false, invalid = false, "aria-describedby": describedBy, onBlur, recentIcons, ref, className }) {
4643
+ const interactive = !disabled && !readOnly;
4644
+ const [open, setOpenAndReport] = useReportedOpen(interactive, onBlur);
4645
+ const [triggerRef, setTrigger] = useSharedButtonRef(ref);
4646
+ const warningId = react.useId();
4647
+ const { resolved, text } = useIconFieldValue(loadIcons, value, label, open);
4648
+ const missing = resolved.status === "missing";
4649
+ const pickerRef = react.useRef(null);
4650
+ const reportFocusLeft = focusLeftReporter(open, pickerRef, onBlur);
4651
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4652
+ className: cn("w-full", className),
4653
+ onBlur: reportFocusLeft,
4654
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(IconFieldFrame, {
4655
+ invalid,
4656
+ disabled,
4657
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Popover, {
4658
+ open,
4659
+ onOpenChange: setOpenAndReport,
4660
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverTrigger, {
4661
+ asChild: true,
4662
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconFieldButton, {
4663
+ ref: setTrigger,
4664
+ id,
4665
+ "aria-describedby": describedByIds(describedBy, warningIdIf(missing, warningId)),
4666
+ disabled,
4667
+ resolved,
4668
+ text,
4669
+ empty: !value,
4670
+ interactive,
4671
+ invalid,
4672
+ readOnly
4673
+ })
4674
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconFieldPopover, {
4675
+ ref: pickerRef,
4676
+ loadIcons,
4677
+ value,
4678
+ recentIcons,
4679
+ onChoose: (id) => {
4680
+ onChange(id);
4681
+ setOpenAndReport(false);
4682
+ }
4683
+ })]
4684
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClearIconButton, {
4685
+ shown: Boolean(value) && interactive,
4686
+ onClear: () => {
4687
+ onChange(null);
4688
+ onBlur?.();
4689
+ triggerRef.current?.focus();
4690
+ }
4691
+ })]
4692
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MissingIconWarning, {
4693
+ shown: missing,
4694
+ id: warningId
4695
+ })]
4696
+ });
4697
+ }
3650
4698
  // src/components/context-menu.tsx
3651
4699
  /**
3652
4700
  * ContextMenu Component
@@ -3979,7 +5027,17 @@ const ResizableHandle = ({ withGrip, className, children, ...props }) => /* @__P
3979
5027
  * @module
3980
5028
  */
3981
5029
  const ROW_HEIGHT = 28;
3982
- const INDENT_PER_LEVEL = 12;
5030
+ /**
5031
+ * How far each level of the tree is indented, in pixels.
5032
+ *
5033
+ * Exported because a consumer that lets rows be dragged to a depth has to step
5034
+ * by the same distance the rows are drawn at: an editor reading a pointer's x
5035
+ * as a depth draws its drop line where a row at that depth would start, and
5036
+ * two separate numbers would put the line a level away from the hand.
5037
+ *
5038
+ * @experimental
5039
+ */
5040
+ const TREE_INDENT_PX = 20;
3983
5041
  /** The text a row can be typed to, falling back to a string label. */
3984
5042
  function textOf(node) {
3985
5043
  if (typeof node.textValue === "string") return node.textValue;
@@ -4091,6 +5149,22 @@ const TreeView = react.forwardRef(({ nodes, expandedIds, defaultExpandedIds, onE
4091
5149
  estimateSize: () => ROW_HEIGHT,
4092
5150
  overscan: 8
4093
5151
  });
5152
+ const revealed = react.useRef(null);
5153
+ react.useEffect(() => {
5154
+ if (selected === null) {
5155
+ revealed.current = null;
5156
+ return;
5157
+ }
5158
+ if (revealed.current === selected) return;
5159
+ const index = rows.findIndex((row) => row.node.id === selected);
5160
+ if (index < 0) return;
5161
+ revealed.current = selected;
5162
+ virtualizer.scrollToIndex(index, { align: "auto" });
5163
+ }, [
5164
+ selected,
5165
+ rows,
5166
+ virtualizer
5167
+ ]);
4094
5168
  const commitExpanded = (next) => {
4095
5169
  const ids = [...next];
4096
5170
  if (expandedIds === void 0) setExpandedState(ids);
@@ -4252,7 +5326,7 @@ const TreeView = react.forwardRef(({ nodes, expandedIds, defaultExpandedIds, onE
4252
5326
  style: {
4253
5327
  height: item.size,
4254
5328
  transform: `translateY(${item.start}px)`,
4255
- paddingLeft: 4 + row.level * INDENT_PER_LEVEL
5329
+ paddingLeft: 4 + row.level * 20
4256
5330
  },
4257
5331
  children: [
4258
5332
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -5785,7 +6859,7 @@ const SHELL_MEASURE = {
5785
6859
  * "how far is content from the panel's edge".
5786
6860
  * @experimental
5787
6861
  */
5788
- const PageShell = (0, react.forwardRef)(({ width = "form", className, children, style, ...props }, ref) => {
6862
+ const PageShell = (0, react.forwardRef)(({ width = "form", align = "start", className, children, style, ...props }, ref) => {
5789
6863
  const shellRef = (0, react.useRef)(null);
5790
6864
  const attachRef = (0, react.useCallback)((node) => {
5791
6865
  shellRef.current = node;
@@ -5818,6 +6892,7 @@ const PageShell = (0, react.forwardRef)(({ width = "form", className, children,
5818
6892
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5819
6893
  ref: attachRef,
5820
6894
  "data-slot": "page-shell",
6895
+ "data-align": align,
5821
6896
  style: shellStyle,
5822
6897
  className: cn("nx-page-shell py-8", className),
5823
6898
  ...props,
@@ -5881,32 +6956,156 @@ Bleed.displayName = "Bleed";
5881
6956
  * prop.
5882
6957
  * @experimental
5883
6958
  */
5884
- const PageHeader = (0, react.forwardRef)(({ title, description, breadcrumbs, actions, className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
6959
+ const PageHeader = (0, react.forwardRef)(({ title, description, breadcrumbs, actions, tabs, media, meta, titleId, className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
5885
6960
  ref,
5886
6961
  "data-slot": "page-header",
5887
6962
  className: cn("mb-8", className),
5888
6963
  ...props,
5889
- children: [breadcrumbs ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5890
- className: "mb-6",
5891
- children: breadcrumbs
5892
- }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5893
- className: "flex flex-col justify-between gap-4 sm:flex-row sm:items-center",
5894
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5895
- className: "space-y-1",
5896
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
5897
- className: "text-xl font-semibold tracking-tight",
5898
- children: title
5899
- }), description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5900
- className: "mt-1 text-sm font-normal text-muted-foreground",
5901
- children: description
6964
+ children: [
6965
+ breadcrumbs ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6966
+ className: "mb-6 empty:hidden",
6967
+ children: breadcrumbs
6968
+ }) : null,
6969
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6970
+ className: "flex flex-col justify-between gap-4 sm:flex-row sm:items-center",
6971
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6972
+ className: "flex min-w-0 items-start gap-4",
6973
+ children: [media ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6974
+ className: "shrink-0",
6975
+ children: media
6976
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6977
+ className: "min-w-0 space-y-1",
6978
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6979
+ className: "flex flex-wrap items-center gap-3",
6980
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
6981
+ id: titleId,
6982
+ className: "text-xl font-semibold tracking-tight",
6983
+ children: title
6984
+ }), meta]
6985
+ }), description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6986
+ "data-slot": "page-header-description",
6987
+ className: "mt-1 text-sm font-normal text-muted-foreground",
6988
+ children: description
6989
+ }) : null]
6990
+ })]
6991
+ }), actions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6992
+ className: "flex items-center gap-3",
6993
+ children: actions
5902
6994
  }) : null]
5903
- }), actions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5904
- className: "flex items-center gap-3",
5905
- children: actions
5906
- }) : null]
5907
- })]
6995
+ }),
6996
+ tabs ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6997
+ className: "mt-6",
6998
+ children: tabs
6999
+ }) : null
7000
+ ]
5908
7001
  }));
5909
7002
  PageHeader.displayName = "PageHeader";
7003
+ /**
7004
+ * The tab row of a page whose sections each have their own address. A labelled
7005
+ * `nav` of links rather than an ARIA tablist: every tab changes the URL, and a
7006
+ * link inside `role="tab"` breaks the tabs pattern's keyboard and announcement
7007
+ * contract. The current section is marked with `aria-current="page"` by
7008
+ * `PageTab`.
7009
+ * @experimental
7010
+ */
7011
+ const PageTabs = (0, react.forwardRef)(({ label, className, children, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
7012
+ ref,
7013
+ "aria-label": label,
7014
+ "data-slot": "page-tabs",
7015
+ className: cn("flex gap-1 overflow-x-auto border-b border-border", className),
7016
+ ...props,
7017
+ children
7018
+ }));
7019
+ PageTabs.displayName = "PageTabs";
7020
+ /**
7021
+ * One section of a `PageTabs` row: a link, underlined when current.
7022
+ * @experimental
7023
+ */
7024
+ const PageTab = (0, react.forwardRef)(({ current = false, asChild = false, className, children, ...props }, ref) => {
7025
+ const Comp = asChild ? _radix_ui_react_slot.Slot : "a";
7026
+ const marker = current ? "page" : void 0;
7027
+ const content = asChild && (0, react.isValidElement)(children) ? (0, react.cloneElement)(children, { "aria-current": marker }) : children;
7028
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Comp, {
7029
+ ...props,
7030
+ ref,
7031
+ "data-slot": "page-tab",
7032
+ "aria-current": marker,
7033
+ 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),
7034
+ children: content
7035
+ });
7036
+ });
7037
+ PageTab.displayName = "PageTab";
7038
+ // src/components/page-frame.tsx
7039
+ /**
7040
+ * The shell each type draws with. A table rather than a branch per type, so
7041
+ * the four widths are read in one place and a fifth type is one row.
7042
+ */
7043
+ const SHELL_FOR = { form: {
7044
+ width: "form",
7045
+ align: "start"
7046
+ } };
7047
+ const PageFrameClaimContext = (0, react.createContext)(null);
7048
+ /**
7049
+ * Hears whether the content inside it draws a `PageFrame`, for a host that
7050
+ * gives unframed content a frame of its own and must not frame content twice.
7051
+ * Read from the frames themselves rather than from what the content is called,
7052
+ * so a page that draws a frame through any component is heard the same way.
7053
+ *
7054
+ * The frame claims in a layout effect, so a host that changes its own markup
7055
+ * in answer does so before the first paint.
7056
+ * @experimental
7057
+ */
7058
+ function PageFrameListener({ onFrame, children }) {
7059
+ const onFrameRef = (0, react.useRef)(onFrame);
7060
+ (0, react.useLayoutEffect)(() => {
7061
+ onFrameRef.current = onFrame;
7062
+ });
7063
+ const claims = (0, react.useRef)([]);
7064
+ const claim = (0, react.useCallback)((type) => {
7065
+ const entry = { type };
7066
+ claims.current = [...claims.current, entry];
7067
+ onFrameRef.current(type);
7068
+ return () => {
7069
+ claims.current = claims.current.filter((other) => other !== entry);
7070
+ onFrameRef.current(claims.current[claims.current.length - 1]?.type ?? null);
7071
+ };
7072
+ }, []);
7073
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageFrameClaimContext.Provider, {
7074
+ value: claim,
7075
+ children
7076
+ });
7077
+ }
7078
+ /**
7079
+ * A page's frame: the width and gutter its type gives it. A page says what it
7080
+ * is, and the frame decides how wide that is, so two pages of one type can
7081
+ * never drift apart.
7082
+ * @experimental
7083
+ */
7084
+ const PageFrame = (0, react.forwardRef)(({ type, className, children: content, ...props }, ref) => {
7085
+ const claim = (0, react.useContext)(PageFrameClaimContext);
7086
+ (0, react.useLayoutEffect)(() => claim?.(type), [claim, type]);
7087
+ const children = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageFrameClaimContext.Provider, {
7088
+ value: null,
7089
+ children: content
7090
+ });
7091
+ if (type !== "form") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
7092
+ ref,
7093
+ "data-slot": "page-frame",
7094
+ "data-page-type": type,
7095
+ className: cn("min-w-0", type === "list" && "nx-page-pad", className),
7096
+ ...props,
7097
+ children
7098
+ });
7099
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageShell, {
7100
+ ref,
7101
+ "data-page-type": type,
7102
+ ...SHELL_FOR[type],
7103
+ className,
7104
+ ...props,
7105
+ children
7106
+ });
7107
+ });
7108
+ PageFrame.displayName = "PageFrame";
5910
7109
  exports.Accordion = Accordion;
5911
7110
  exports.AccordionContent = AccordionContent;
5912
7111
  exports.AccordionItem = AccordionItem;
@@ -5996,10 +7195,17 @@ exports.FormActions = FormActions;
5996
7195
  exports.FormLabelWithTooltip = FormLabelWithTooltip;
5997
7196
  exports.FormSection = FormSection;
5998
7197
  exports.Grid = Grid;
7198
+ exports.IconField = IconField;
7199
+ exports.IconGlyph = IconGlyph;
7200
+ exports.IconPicker = IconPicker;
5999
7201
  exports.Input = Input;
6000
7202
  exports.Label = Label;
7203
+ exports.PageFrame = PageFrame;
7204
+ exports.PageFrameListener = PageFrameListener;
6001
7205
  exports.PageHeader = PageHeader;
6002
7206
  exports.PageShell = PageShell;
7207
+ exports.PageTab = PageTab;
7208
+ exports.PageTabs = PageTabs;
6003
7209
  exports.Popover = Popover;
6004
7210
  exports.PopoverAnchor = PopoverAnchor;
6005
7211
  exports.PopoverContent = PopoverContent;
@@ -6041,6 +7247,7 @@ exports.Spinner = Spinner;
6041
7247
  exports.Stack = Stack;
6042
7248
  exports.Stat = Stat;
6043
7249
  exports.Switch = Switch;
7250
+ exports.TREE_INDENT_PX = TREE_INDENT_PX;
6044
7251
  exports.Table = Table;
6045
7252
  exports.TableBody = TableBody;
6046
7253
  exports.TableCaption = TableCaption;