@nextlyhq/ui 0.0.2-alpha.74 → 0.0.2-alpha.76
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 +403 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +217 -20
- package/dist/index.d.ts +217 -20
- package/dist/index.mjs +400 -79
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.scoped.css +1 -1
- package/dist/tailwind-preset.cjs +20 -0
- package/dist/tailwind-preset.cjs.map +1 -1
- package/dist/tailwind-preset.d.cts +20 -0
- package/dist/tailwind-preset.d.ts +20 -0
- package/dist/tailwind-preset.mjs +20 -0
- package/dist/tailwind-preset.mjs.map +1 -1
- package/dist/theme.css +123 -3
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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";
|
|
@@ -68,7 +68,7 @@ const buttonVariants = cva(`inline-flex items-center justify-center whitespace-n
|
|
|
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-
|
|
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
|
-
* -
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* -
|
|
278
|
-
* -
|
|
279
|
-
* - warning:
|
|
280
|
-
* -
|
|
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: "
|
|
289
|
-
warning: "
|
|
290
|
-
destructive: "
|
|
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
|
-
|
|
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
|
/**
|
|
@@ -502,21 +517,39 @@ const Grid = forwardRef(({ cols = 2, gap = 4, responsive = false, className, chi
|
|
|
502
517
|
});
|
|
503
518
|
});
|
|
504
519
|
Grid.displayName = "Grid";
|
|
520
|
+
/** Each tone's dot, in the status's solid colour (the same as `Badge`'s). */
|
|
521
|
+
const STAT_TONE_DOT = {
|
|
522
|
+
success: "bg-success-solid",
|
|
523
|
+
warning: "bg-warning-solid",
|
|
524
|
+
destructive: "bg-danger-solid",
|
|
525
|
+
info: "bg-info-solid"
|
|
526
|
+
};
|
|
505
527
|
/** Labelled metric block for dashboard-style plugin widgets.
|
|
506
528
|
* @experimental
|
|
507
529
|
*/
|
|
508
|
-
const Stat = forwardRef(({ label, value, className, ...props }, ref) =>
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
513
|
-
className: "text-sm text-muted-foreground",
|
|
514
|
-
children: label
|
|
515
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
516
|
-
className: "text-2xl font-semibold text-foreground",
|
|
530
|
+
const Stat = forwardRef(({ label, value, tone, size = "default", className, ...props }, ref) => {
|
|
531
|
+
const compact = size === "compact";
|
|
532
|
+
const figure = /* @__PURE__ */ jsx("span", {
|
|
533
|
+
className: cn("font-semibold text-foreground", compact ? "text-xl" : "text-2xl"),
|
|
517
534
|
children: value
|
|
518
|
-
})
|
|
519
|
-
|
|
535
|
+
});
|
|
536
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
537
|
+
ref,
|
|
538
|
+
className: cn("flex flex-col", compact ? "gap-3" : "gap-1", className),
|
|
539
|
+
...props,
|
|
540
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
541
|
+
className: cn("text-sm text-muted-foreground", compact && "font-semibold"),
|
|
542
|
+
children: label
|
|
543
|
+
}), tone === void 0 ? figure : /* @__PURE__ */ jsxs("span", {
|
|
544
|
+
className: "flex items-center gap-2.5",
|
|
545
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
546
|
+
"aria-hidden": "true",
|
|
547
|
+
"data-stat-tone": tone,
|
|
548
|
+
className: cn("size-2.5 shrink-0 rounded-full", STAT_TONE_DOT[tone])
|
|
549
|
+
}), figure]
|
|
550
|
+
})]
|
|
551
|
+
});
|
|
552
|
+
});
|
|
520
553
|
Stat.displayName = "Stat";
|
|
521
554
|
/**
|
|
522
555
|
* Alert Component - Design System Specification
|
|
@@ -528,11 +561,12 @@ Stat.displayName = "Stat";
|
|
|
528
561
|
* - Padding: 16px (p-4)
|
|
529
562
|
* - Border radius: `rounded-md`, one step tighter than Card's `rounded-lg`
|
|
530
563
|
* for inline/flow content vs. larger container components
|
|
531
|
-
* - Border: 1px
|
|
564
|
+
* - Border: 1px; the card border for info and success, the status border for
|
|
565
|
+
* warning and destructive
|
|
532
566
|
* - Shadow: sm (subtle elevation)
|
|
533
567
|
* - Font: 14px (text-sm)
|
|
534
568
|
* - Layout: Flex with gap-3 for icon/content spacing
|
|
535
|
-
* - Colors:
|
|
569
|
+
* - Colors: the page's foreground text; the icon in the status's text colour
|
|
536
570
|
*
|
|
537
571
|
* Variants (4 total):
|
|
538
572
|
* - info (default): Blue - informational messages, neutral announcements
|
|
@@ -589,10 +623,10 @@ Stat.displayName = "Stat";
|
|
|
589
623
|
*/
|
|
590
624
|
const alertVariants = cva("relative flex items-start gap-3 rounded-md border border-border p-4 text-sm transition-colors duration-150", {
|
|
591
625
|
variants: { variant: {
|
|
592
|
-
info: "bg-
|
|
593
|
-
success: "border-
|
|
594
|
-
warning: "border-warning-
|
|
595
|
-
destructive: "border-
|
|
626
|
+
info: "border-border bg-card text-foreground [&>svg]:text-info-text",
|
|
627
|
+
success: "border-border bg-card text-foreground [&>svg]:text-success-text",
|
|
628
|
+
warning: "border-warning-border bg-warning-surface text-foreground [&>svg]:text-warning-text",
|
|
629
|
+
destructive: "border-danger-border bg-danger-surface text-foreground [&>svg]:text-danger-text"
|
|
596
630
|
} },
|
|
597
631
|
defaultVariants: { variant: "info" }
|
|
598
632
|
});
|
|
@@ -745,12 +779,13 @@ function Separator({ className, orientation = "horizontal", decorative = true, .
|
|
|
745
779
|
* @see {@link https://adrianroselli.com/2020/11/more-accessible-skeletons.html More Accessible Skeletons}
|
|
746
780
|
* @experimental
|
|
747
781
|
*/
|
|
748
|
-
const Skeleton = React.forwardRef(({ className, ...props }, ref) => {
|
|
782
|
+
const Skeleton = React.forwardRef(({ className, still = false, ...props }, ref) => {
|
|
749
783
|
return /* @__PURE__ */ jsx("div", {
|
|
750
784
|
ref,
|
|
751
785
|
"data-slot": "skeleton",
|
|
786
|
+
"data-still": still ? "" : void 0,
|
|
752
787
|
"aria-hidden": "true",
|
|
753
|
-
className: cn("bg-primary/5 animate-pulse rounded-md motion-reduce:animate-none", className),
|
|
788
|
+
className: cn(still ? "bg-secondary rounded-md" : "bg-primary/5 animate-pulse rounded-md motion-reduce:animate-none", className),
|
|
754
789
|
...props
|
|
755
790
|
});
|
|
756
791
|
});
|
|
@@ -765,7 +800,7 @@ Skeleton.displayName = "Skeleton";
|
|
|
765
800
|
const progressVariants = cva("h-full rounded-none transition-all", {
|
|
766
801
|
variants: { variant: {
|
|
767
802
|
default: "bg-primary-500",
|
|
768
|
-
success: "bg-success-
|
|
803
|
+
success: "bg-success-solid",
|
|
769
804
|
error: "bg-destructive"
|
|
770
805
|
} },
|
|
771
806
|
defaultVariants: { variant: "default" }
|
|
@@ -2239,6 +2274,65 @@ const sheetVariants = cva("fixed z-50 gap-4 bg-background p-6 shadow-lg will-cha
|
|
|
2239
2274
|
} },
|
|
2240
2275
|
defaultVariants: { side: "right" }
|
|
2241
2276
|
});
|
|
2277
|
+
/** How far down, as a share of the sheet's height, a drag must go to close it. */
|
|
2278
|
+
const DISMISS_SHARE = .25;
|
|
2279
|
+
/** A release faster than this, in px per ms, closes it from a shorter drag. */
|
|
2280
|
+
const FLICK_SPEED = .6;
|
|
2281
|
+
/** The shortest drag a flick closes from, so a tap never closes the sheet. */
|
|
2282
|
+
const FLICK_MIN_DISTANCE = 24;
|
|
2283
|
+
/** Whether a drag released at `distance` after `elapsed` ms closes the sheet. */
|
|
2284
|
+
function dragCloses(distance, elapsed, height) {
|
|
2285
|
+
if (distance >= height * DISMISS_SHARE) return true;
|
|
2286
|
+
return distance >= FLICK_MIN_DISTANCE && distance / Math.max(elapsed, 1) >= FLICK_SPEED;
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* The grab strip: the sheet follows the pointer down (never up), and on
|
|
2290
|
+
* release either closes or springs back. It moves the sheet with an inline
|
|
2291
|
+
* transform, so the closing slide continues from where the finger let go.
|
|
2292
|
+
*/
|
|
2293
|
+
function SheetDragHandle({ onDismiss }) {
|
|
2294
|
+
const drag = React.useRef(null);
|
|
2295
|
+
const onPointerDown = (event) => {
|
|
2296
|
+
const sheet = event.currentTarget.closest("[data-slot='sheet-content']");
|
|
2297
|
+
if (!sheet) return;
|
|
2298
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
2299
|
+
drag.current = {
|
|
2300
|
+
y: event.clientY,
|
|
2301
|
+
time: performance.now(),
|
|
2302
|
+
height: sheet.getBoundingClientRect().height,
|
|
2303
|
+
sheet
|
|
2304
|
+
};
|
|
2305
|
+
sheet.style.transition = "none";
|
|
2306
|
+
};
|
|
2307
|
+
const onPointerMove = (event) => {
|
|
2308
|
+
const start = drag.current;
|
|
2309
|
+
if (!start) return;
|
|
2310
|
+
const distance = Math.max(0, event.clientY - start.y);
|
|
2311
|
+
start.sheet.style.transform = `translateY(${distance}px)`;
|
|
2312
|
+
};
|
|
2313
|
+
const release = (event, cancelled) => {
|
|
2314
|
+
const start = drag.current;
|
|
2315
|
+
if (!start) return;
|
|
2316
|
+
drag.current = null;
|
|
2317
|
+
start.sheet.style.transition = "";
|
|
2318
|
+
const distance = Math.max(0, event.clientY - start.y);
|
|
2319
|
+
if (!cancelled && dragCloses(distance, performance.now() - start.time, start.height)) {
|
|
2320
|
+
onDismiss();
|
|
2321
|
+
return;
|
|
2322
|
+
}
|
|
2323
|
+
start.sheet.style.transform = "";
|
|
2324
|
+
};
|
|
2325
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2326
|
+
"aria-hidden": "true",
|
|
2327
|
+
"data-slot": "sheet-drag-handle",
|
|
2328
|
+
className: "flex h-6 w-full shrink-0 cursor-grab touch-none items-center justify-center active:cursor-grabbing",
|
|
2329
|
+
onPointerDown,
|
|
2330
|
+
onPointerMove,
|
|
2331
|
+
onPointerUp: (event) => release(event, false),
|
|
2332
|
+
onPointerCancel: (event) => release(event, true),
|
|
2333
|
+
children: /* @__PURE__ */ jsx("span", { className: "h-1 w-10 rounded-full bg-border" })
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2242
2336
|
/**
|
|
2243
2337
|
* SheetContent
|
|
2244
2338
|
*
|
|
@@ -2253,17 +2347,24 @@ const sheetVariants = cva("fixed z-50 gap-4 bg-background p-6 shadow-lg will-cha
|
|
|
2253
2347
|
* @param side - Which edge to slide in from: "left", "right", "top", "bottom"
|
|
2254
2348
|
* @public
|
|
2255
2349
|
*/
|
|
2256
|
-
const SheetContent = React.forwardRef(({ side = "right", className, children, ...props }, ref) => {
|
|
2350
|
+
const SheetContent = React.forwardRef(({ side = "right", className, children, dragHandle = false, ...props }, ref) => {
|
|
2257
2351
|
const portalContainer = usePortalContainer();
|
|
2258
2352
|
const modal = React.useContext(SheetModalContext);
|
|
2353
|
+
const close = React.useRef(null);
|
|
2354
|
+
const draggable = dragHandle && side === "bottom";
|
|
2259
2355
|
return /* @__PURE__ */ jsxs(SheetPortal, {
|
|
2260
2356
|
container: portalContainer,
|
|
2261
|
-
children: [modal ? /* @__PURE__ */ jsx(SheetOverlay, {}) : null, /* @__PURE__ */
|
|
2357
|
+
children: [modal ? /* @__PURE__ */ jsx(SheetOverlay, {}) : null, /* @__PURE__ */ jsxs(DialogPrimitive.Content, {
|
|
2262
2358
|
ref,
|
|
2263
2359
|
"data-slot": "sheet-content",
|
|
2264
2360
|
className: cn(sheetVariants({ side }), className),
|
|
2265
2361
|
...props,
|
|
2266
|
-
children
|
|
2362
|
+
children: [draggable ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SheetDragHandle, { onDismiss: () => close.current?.click() }), /* @__PURE__ */ jsx(DialogPrimitive.Close, {
|
|
2363
|
+
ref: close,
|
|
2364
|
+
hidden: true,
|
|
2365
|
+
tabIndex: -1,
|
|
2366
|
+
"aria-hidden": "true"
|
|
2367
|
+
})] }) : null, children]
|
|
2267
2368
|
})]
|
|
2268
2369
|
});
|
|
2269
2370
|
});
|
|
@@ -2714,7 +2815,13 @@ function Toaster({ theme = "system", ...props }) {
|
|
|
2714
2815
|
"--success-bg": "var(--nx-toast-success-bg)",
|
|
2715
2816
|
"--success-text": "var(--nx-toast-success-text)",
|
|
2716
2817
|
"--warning-bg": "var(--nx-toast-warning-bg)",
|
|
2717
|
-
"--warning-text": "var(--nx-toast-warning-text)"
|
|
2818
|
+
"--warning-text": "var(--nx-toast-warning-text)",
|
|
2819
|
+
"--error-bg": "var(--nx-danger-surface)",
|
|
2820
|
+
"--error-border": "var(--nx-danger-border)",
|
|
2821
|
+
"--error-text": "var(--nx-danger-text)",
|
|
2822
|
+
"--info-bg": "var(--nx-info-surface)",
|
|
2823
|
+
"--info-border": "var(--nx-info-border)",
|
|
2824
|
+
"--info-text": "var(--nx-info-text)"
|
|
2718
2825
|
},
|
|
2719
2826
|
...props
|
|
2720
2827
|
});
|
|
@@ -4369,7 +4476,7 @@ function MissingIconWarning({ shown, id }) {
|
|
|
4369
4476
|
if (!shown) return null;
|
|
4370
4477
|
return /* @__PURE__ */ jsxs("p", {
|
|
4371
4478
|
id,
|
|
4372
|
-
className: "mt-1.5 flex items-start gap-2 rounded-md border border-warning-
|
|
4479
|
+
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",
|
|
4373
4480
|
children: [/* @__PURE__ */ jsx(TriangleAlert, {
|
|
4374
4481
|
className: "mt-px size-3.5 shrink-0",
|
|
4375
4482
|
"aria-hidden": "true"
|
|
@@ -6458,6 +6565,34 @@ function useActiveShortcuts() {
|
|
|
6458
6565
|
const manager = useShortcutManager();
|
|
6459
6566
|
return React.useSyncExternalStore(manager.subscribe, manager.activeBindings, manager.activeBindings);
|
|
6460
6567
|
}
|
|
6568
|
+
// src/components/field-row.tsx
|
|
6569
|
+
/**
|
|
6570
|
+
* The two-column settings row: label and help on the left, the control on the
|
|
6571
|
+
* right, stacking into one column on a narrow screen.
|
|
6572
|
+
*
|
|
6573
|
+
* Geometry only. It owns the grid and nothing about naming, so the rows that
|
|
6574
|
+
* differ in how they label their control — `FieldShell`'s row layout, and the
|
|
6575
|
+
* admin's form-bound and grouped settings rows — all draw this one grid rather
|
|
6576
|
+
* than three copies of it that could drift apart.
|
|
6577
|
+
*
|
|
6578
|
+
* It applies no vertical padding: `FormSection` sets the rhythm between its
|
|
6579
|
+
* rows, and a row that padded itself as well would double it.
|
|
6580
|
+
* @experimental
|
|
6581
|
+
*/
|
|
6582
|
+
function FieldRow({ aside, children, className, ...props }) {
|
|
6583
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
6584
|
+
"data-slot": "field-row",
|
|
6585
|
+
className: cn("grid grid-cols-1 md:grid-cols-[2fr_3fr] gap-4 md:gap-8 items-start", className),
|
|
6586
|
+
...props,
|
|
6587
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
6588
|
+
className: "flex flex-col",
|
|
6589
|
+
children: aside
|
|
6590
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
6591
|
+
className: "w-full",
|
|
6592
|
+
children
|
|
6593
|
+
})]
|
|
6594
|
+
});
|
|
6595
|
+
}
|
|
6461
6596
|
// src/components/field-shell.tsx
|
|
6462
6597
|
/**
|
|
6463
6598
|
* The width cap applies to a wrapper around the control, not to the field row.
|
|
@@ -6523,7 +6658,7 @@ function computeControlWiring(ownProps, requestedId, renderedMessageIds, hasErro
|
|
|
6523
6658
|
};
|
|
6524
6659
|
}
|
|
6525
6660
|
/** @experimental */
|
|
6526
|
-
function FieldShell({ label, description, error, width = "
|
|
6661
|
+
function FieldShell({ label, description, error, width, layout = "stacked", htmlFor, className, children }) {
|
|
6527
6662
|
const generatedControlId = useId();
|
|
6528
6663
|
const messageBaseId = useId();
|
|
6529
6664
|
const descriptionId = `${messageBaseId}-description`;
|
|
@@ -6552,27 +6687,69 @@ function FieldShell({ label, description, error, width = "half", htmlFor, classN
|
|
|
6552
6687
|
};
|
|
6553
6688
|
control = isFragmentChild ? children : cloneElement(children, controlOverrides);
|
|
6554
6689
|
}
|
|
6690
|
+
const parts = {
|
|
6691
|
+
label,
|
|
6692
|
+
description,
|
|
6693
|
+
error,
|
|
6694
|
+
controlId: wiring.id,
|
|
6695
|
+
descriptionId,
|
|
6696
|
+
errorId,
|
|
6697
|
+
width: width ?? (layout === "row" ? "fill" : "half"),
|
|
6698
|
+
className,
|
|
6699
|
+
control
|
|
6700
|
+
};
|
|
6701
|
+
return layout === "row" ? /* @__PURE__ */ jsx(RowField, { ...parts }) : /* @__PURE__ */ jsx(StackedField, { ...parts });
|
|
6702
|
+
}
|
|
6703
|
+
/**
|
|
6704
|
+
* The settings row: the label and its help on the left, the control and any
|
|
6705
|
+
* error under it on the right. The grid itself is `FieldRow`'s, so this row and
|
|
6706
|
+
* the admin's own settings rows cannot disagree about it.
|
|
6707
|
+
*/
|
|
6708
|
+
function RowField(parts) {
|
|
6709
|
+
return /* @__PURE__ */ jsxs(FieldRow, {
|
|
6710
|
+
className: parts.className,
|
|
6711
|
+
aside: /* @__PURE__ */ jsxs(Fragment$1, { children: [parts.label ? /* @__PURE__ */ jsx("label", {
|
|
6712
|
+
htmlFor: parts.controlId,
|
|
6713
|
+
className: "cursor-pointer text-sm font-semibold text-foreground",
|
|
6714
|
+
children: parts.label
|
|
6715
|
+
}) : null, parts.description ? /* @__PURE__ */ jsx("p", {
|
|
6716
|
+
id: parts.descriptionId,
|
|
6717
|
+
className: "mt-0.5 text-xs leading-relaxed text-muted-foreground",
|
|
6718
|
+
children: parts.description
|
|
6719
|
+
}) : null] }),
|
|
6720
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
6721
|
+
className: controlWidth({ width: parts.width }),
|
|
6722
|
+
children: parts.control
|
|
6723
|
+
}), parts.error ? /* @__PURE__ */ jsx("p", {
|
|
6724
|
+
id: parts.errorId,
|
|
6725
|
+
className: "mt-1.5 text-sm font-medium text-destructive",
|
|
6726
|
+
children: parts.error
|
|
6727
|
+
}) : null]
|
|
6728
|
+
});
|
|
6729
|
+
}
|
|
6730
|
+
/** The stacked field: the label, then the control, its help and any error. */
|
|
6731
|
+
function StackedField(parts) {
|
|
6555
6732
|
return /* @__PURE__ */ jsxs("div", {
|
|
6556
|
-
className: cn("flex flex-col gap-1.5", className),
|
|
6733
|
+
className: cn("flex flex-col gap-1.5", parts.className),
|
|
6557
6734
|
children: [
|
|
6558
|
-
label ? /* @__PURE__ */ jsx("label", {
|
|
6559
|
-
htmlFor:
|
|
6735
|
+
parts.label ? /* @__PURE__ */ jsx("label", {
|
|
6736
|
+
htmlFor: parts.controlId,
|
|
6560
6737
|
className: "text-sm font-medium text-foreground",
|
|
6561
|
-
children: label
|
|
6738
|
+
children: parts.label
|
|
6562
6739
|
}) : null,
|
|
6563
6740
|
/* @__PURE__ */ jsx("div", {
|
|
6564
|
-
className: controlWidth({ width }),
|
|
6565
|
-
children: control
|
|
6741
|
+
className: controlWidth({ width: parts.width }),
|
|
6742
|
+
children: parts.control
|
|
6566
6743
|
}),
|
|
6567
|
-
description ? /* @__PURE__ */ jsx("p", {
|
|
6568
|
-
id: descriptionId,
|
|
6744
|
+
parts.description ? /* @__PURE__ */ jsx("p", {
|
|
6745
|
+
id: parts.descriptionId,
|
|
6569
6746
|
className: "text-sm text-muted-foreground",
|
|
6570
|
-
children: description
|
|
6747
|
+
children: parts.description
|
|
6571
6748
|
}) : null,
|
|
6572
|
-
error ? /* @__PURE__ */ jsx("p", {
|
|
6573
|
-
id: errorId,
|
|
6749
|
+
parts.error ? /* @__PURE__ */ jsx("p", {
|
|
6750
|
+
id: parts.errorId,
|
|
6574
6751
|
className: "text-sm font-medium text-destructive",
|
|
6575
|
-
children: error
|
|
6752
|
+
children: parts.error
|
|
6576
6753
|
}) : null
|
|
6577
6754
|
]
|
|
6578
6755
|
});
|
|
@@ -6622,13 +6799,13 @@ function FormSection({ label, description, className, children }) {
|
|
|
6622
6799
|
* first as soon as either changed.
|
|
6623
6800
|
* @experimental
|
|
6624
6801
|
*/
|
|
6625
|
-
function FormActions({ dirty, className, children }) {
|
|
6802
|
+
function FormActions({ dirty, message = "You have unsaved changes", className, children }) {
|
|
6626
6803
|
return /* @__PURE__ */ jsxs("div", {
|
|
6627
6804
|
className: cn("sticky bottom-0 mt-8 flex items-center justify-end gap-3", "border-t border-border bg-background/95 py-4 backdrop-blur", className),
|
|
6628
6805
|
children: [dirty ? /* @__PURE__ */ jsx("span", {
|
|
6629
6806
|
role: "status",
|
|
6630
6807
|
className: "mr-auto text-sm text-muted-foreground",
|
|
6631
|
-
children:
|
|
6808
|
+
children: message
|
|
6632
6809
|
}) : null, children]
|
|
6633
6810
|
});
|
|
6634
6811
|
}
|
|
@@ -6735,7 +6912,7 @@ const SHELL_MEASURE = {
|
|
|
6735
6912
|
* "how far is content from the panel's edge".
|
|
6736
6913
|
* @experimental
|
|
6737
6914
|
*/
|
|
6738
|
-
const PageShell = forwardRef(({ width = "form", className, children, style, ...props }, ref) => {
|
|
6915
|
+
const PageShell = forwardRef(({ width = "form", align = "start", className, children, style, ...props }, ref) => {
|
|
6739
6916
|
const shellRef = useRef(null);
|
|
6740
6917
|
const attachRef = useCallback((node) => {
|
|
6741
6918
|
shellRef.current = node;
|
|
@@ -6768,6 +6945,7 @@ const PageShell = forwardRef(({ width = "form", className, children, style, ...p
|
|
|
6768
6945
|
children: /* @__PURE__ */ jsx("div", {
|
|
6769
6946
|
ref: attachRef,
|
|
6770
6947
|
"data-slot": "page-shell",
|
|
6948
|
+
"data-align": align,
|
|
6771
6949
|
style: shellStyle,
|
|
6772
6950
|
className: cn("nx-page-shell py-8", className),
|
|
6773
6951
|
...props,
|
|
@@ -6831,32 +7009,175 @@ Bleed.displayName = "Bleed";
|
|
|
6831
7009
|
* prop.
|
|
6832
7010
|
* @experimental
|
|
6833
7011
|
*/
|
|
6834
|
-
const PageHeader = forwardRef(({ title, description, breadcrumbs, actions, className, ...props }, ref) => /* @__PURE__ */ jsxs("header", {
|
|
7012
|
+
const PageHeader = forwardRef(({ title, description, breadcrumbs, actions, tabs, media, meta, titleId, className, ...props }, ref) => /* @__PURE__ */ jsxs("header", {
|
|
6835
7013
|
ref,
|
|
6836
7014
|
"data-slot": "page-header",
|
|
6837
7015
|
className: cn("mb-8", className),
|
|
6838
7016
|
...props,
|
|
6839
|
-
children: [
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
className: "
|
|
6846
|
-
children: [/* @__PURE__ */
|
|
6847
|
-
className: "
|
|
6848
|
-
children:
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
7017
|
+
children: [
|
|
7018
|
+
breadcrumbs ? /* @__PURE__ */ jsx("div", {
|
|
7019
|
+
className: "mb-6 empty:hidden",
|
|
7020
|
+
children: breadcrumbs
|
|
7021
|
+
}) : null,
|
|
7022
|
+
/* @__PURE__ */ jsxs("div", {
|
|
7023
|
+
className: "flex flex-col justify-between gap-4 sm:flex-row sm:items-center",
|
|
7024
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
7025
|
+
className: "flex min-w-0 items-start gap-4",
|
|
7026
|
+
children: [media ? /* @__PURE__ */ jsx("div", {
|
|
7027
|
+
className: "shrink-0",
|
|
7028
|
+
children: media
|
|
7029
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
7030
|
+
className: "min-w-0 space-y-1",
|
|
7031
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
7032
|
+
className: "flex flex-wrap items-center gap-3",
|
|
7033
|
+
children: [/* @__PURE__ */ jsx("h1", {
|
|
7034
|
+
id: titleId,
|
|
7035
|
+
className: "text-xl font-semibold tracking-tight",
|
|
7036
|
+
children: title
|
|
7037
|
+
}), meta]
|
|
7038
|
+
}), description ? /* @__PURE__ */ jsx("div", {
|
|
7039
|
+
"data-slot": "page-header-description",
|
|
7040
|
+
className: "mt-1 text-sm font-normal text-muted-foreground",
|
|
7041
|
+
children: description
|
|
7042
|
+
}) : null]
|
|
7043
|
+
})]
|
|
7044
|
+
}), actions ? /* @__PURE__ */ jsx("div", {
|
|
7045
|
+
className: "flex items-center gap-3",
|
|
7046
|
+
children: actions
|
|
6852
7047
|
}) : null]
|
|
6853
|
-
}),
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
7048
|
+
}),
|
|
7049
|
+
tabs ? /* @__PURE__ */ jsx("div", {
|
|
7050
|
+
className: "mt-6",
|
|
7051
|
+
children: tabs
|
|
7052
|
+
}) : null
|
|
7053
|
+
]
|
|
6858
7054
|
}));
|
|
6859
7055
|
PageHeader.displayName = "PageHeader";
|
|
6860
|
-
|
|
7056
|
+
/**
|
|
7057
|
+
* The tab row of a page whose sections each have their own address. A labelled
|
|
7058
|
+
* `nav` of links rather than an ARIA tablist: every tab changes the URL, and a
|
|
7059
|
+
* link inside `role="tab"` breaks the tabs pattern's keyboard and announcement
|
|
7060
|
+
* contract. The current section is marked with `aria-current="page"` by
|
|
7061
|
+
* `PageTab`.
|
|
7062
|
+
* @experimental
|
|
7063
|
+
*/
|
|
7064
|
+
const PageTabs = forwardRef(({ label, className, children, ...props }, ref) => {
|
|
7065
|
+
const row = useRef(null);
|
|
7066
|
+
const shown = useRef(null);
|
|
7067
|
+
const setRow = useCallback((node) => {
|
|
7068
|
+
row.current = node;
|
|
7069
|
+
if (typeof ref === "function") return ref(node);
|
|
7070
|
+
if (ref) ref.current = node;
|
|
7071
|
+
}, [ref]);
|
|
7072
|
+
useEffect(() => {
|
|
7073
|
+
const nav = row.current;
|
|
7074
|
+
const current = nav?.querySelector("[aria-current=\"page\"]") ?? null;
|
|
7075
|
+
if (nav === null || current === null || current === shown.current) return;
|
|
7076
|
+
shown.current = current;
|
|
7077
|
+
const bounds = nav.getBoundingClientRect();
|
|
7078
|
+
const tab = current.getBoundingClientRect();
|
|
7079
|
+
if (tab.left < bounds.left) nav.scrollLeft -= bounds.left - tab.left;
|
|
7080
|
+
else if (tab.right > bounds.right) nav.scrollLeft += tab.right - bounds.right;
|
|
7081
|
+
});
|
|
7082
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
7083
|
+
ref: setRow,
|
|
7084
|
+
"aria-label": label,
|
|
7085
|
+
"data-slot": "page-tabs",
|
|
7086
|
+
className: cn("flex gap-1 overflow-x-auto border-b border-border", className),
|
|
7087
|
+
...props,
|
|
7088
|
+
children
|
|
7089
|
+
});
|
|
7090
|
+
});
|
|
7091
|
+
PageTabs.displayName = "PageTabs";
|
|
7092
|
+
/**
|
|
7093
|
+
* One section of a `PageTabs` row: a link, underlined when current.
|
|
7094
|
+
* @experimental
|
|
7095
|
+
*/
|
|
7096
|
+
const PageTab = forwardRef(({ current = false, asChild = false, className, children, ...props }, ref) => {
|
|
7097
|
+
const Comp = asChild ? Slot : "a";
|
|
7098
|
+
const marker = current ? "page" : void 0;
|
|
7099
|
+
const content = asChild && isValidElement(children) ? cloneElement(children, { "aria-current": marker }) : children;
|
|
7100
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
7101
|
+
...props,
|
|
7102
|
+
ref,
|
|
7103
|
+
"data-slot": "page-tab",
|
|
7104
|
+
"aria-current": marker,
|
|
7105
|
+
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),
|
|
7106
|
+
children: content
|
|
7107
|
+
});
|
|
7108
|
+
});
|
|
7109
|
+
PageTab.displayName = "PageTab";
|
|
7110
|
+
// src/components/page-frame.tsx
|
|
7111
|
+
/**
|
|
7112
|
+
* The shell each type draws with. A table rather than a branch per type, so
|
|
7113
|
+
* the four widths are read in one place and a fifth type is one row.
|
|
7114
|
+
*/
|
|
7115
|
+
const SHELL_FOR = { form: {
|
|
7116
|
+
width: "form",
|
|
7117
|
+
align: "start"
|
|
7118
|
+
} };
|
|
7119
|
+
const PageFrameClaimContext = createContext(null);
|
|
7120
|
+
/**
|
|
7121
|
+
* Hears whether the content inside it draws a `PageFrame`, for a host that
|
|
7122
|
+
* gives unframed content a frame of its own and must not frame content twice.
|
|
7123
|
+
* Read from the frames themselves rather than from what the content is called,
|
|
7124
|
+
* so a page that draws a frame through any component is heard the same way.
|
|
7125
|
+
*
|
|
7126
|
+
* The frame claims in a layout effect, so a host that changes its own markup
|
|
7127
|
+
* in answer does so before the first paint.
|
|
7128
|
+
* @experimental
|
|
7129
|
+
*/
|
|
7130
|
+
function PageFrameListener({ onFrame, children }) {
|
|
7131
|
+
const onFrameRef = useRef(onFrame);
|
|
7132
|
+
useLayoutEffect(() => {
|
|
7133
|
+
onFrameRef.current = onFrame;
|
|
7134
|
+
});
|
|
7135
|
+
const claims = useRef([]);
|
|
7136
|
+
const claim = useCallback((type) => {
|
|
7137
|
+
const entry = { type };
|
|
7138
|
+
claims.current = [...claims.current, entry];
|
|
7139
|
+
onFrameRef.current(type);
|
|
7140
|
+
return () => {
|
|
7141
|
+
claims.current = claims.current.filter((other) => other !== entry);
|
|
7142
|
+
onFrameRef.current(claims.current[claims.current.length - 1]?.type ?? null);
|
|
7143
|
+
};
|
|
7144
|
+
}, []);
|
|
7145
|
+
return /* @__PURE__ */ jsx(PageFrameClaimContext.Provider, {
|
|
7146
|
+
value: claim,
|
|
7147
|
+
children
|
|
7148
|
+
});
|
|
7149
|
+
}
|
|
7150
|
+
/**
|
|
7151
|
+
* A page's frame: the width and gutter its type gives it. A page says what it
|
|
7152
|
+
* is, and the frame decides how wide that is, so two pages of one type can
|
|
7153
|
+
* never drift apart.
|
|
7154
|
+
* @experimental
|
|
7155
|
+
*/
|
|
7156
|
+
const PageFrame = forwardRef(({ type, className, children: content, ...props }, ref) => {
|
|
7157
|
+
const claim = useContext(PageFrameClaimContext);
|
|
7158
|
+
useLayoutEffect(() => claim?.(type), [claim, type]);
|
|
7159
|
+
const children = /* @__PURE__ */ jsx(PageFrameClaimContext.Provider, {
|
|
7160
|
+
value: null,
|
|
7161
|
+
children: content
|
|
7162
|
+
});
|
|
7163
|
+
if (type !== "form") return /* @__PURE__ */ jsx("div", {
|
|
7164
|
+
ref,
|
|
7165
|
+
"data-slot": "page-frame",
|
|
7166
|
+
"data-page-type": type,
|
|
7167
|
+
className: cn("min-w-0", type === "list" && "nx-page-pad", className),
|
|
7168
|
+
...props,
|
|
7169
|
+
children
|
|
7170
|
+
});
|
|
7171
|
+
return /* @__PURE__ */ jsx(PageShell, {
|
|
7172
|
+
ref,
|
|
7173
|
+
"data-page-type": type,
|
|
7174
|
+
...SHELL_FOR[type],
|
|
7175
|
+
className,
|
|
7176
|
+
...props,
|
|
7177
|
+
children
|
|
7178
|
+
});
|
|
7179
|
+
});
|
|
7180
|
+
PageFrame.displayName = "PageFrame";
|
|
7181
|
+
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, FieldRow, 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 };
|
|
6861
7182
|
|
|
6862
7183
|
//# sourceMappingURL=index.mjs.map
|