@nextlyhq/ui 0.0.2-alpha.74 → 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 +269 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -17
- package/dist/index.d.ts +151 -17
- package/dist/index.mjs +267 -53
- 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.cjs
CHANGED
|
@@ -103,7 +103,7 @@ const buttonVariants = (0, class_variance_authority.cva)(`inline-flex items-cent
|
|
|
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-
|
|
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
|
-
* -
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
* -
|
|
313
|
-
* -
|
|
314
|
-
* - warning:
|
|
315
|
-
* -
|
|
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: "
|
|
324
|
-
warning: "
|
|
325
|
-
destructive: "
|
|
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
|
-
|
|
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
|
|
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:
|
|
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-
|
|
628
|
-
success: "border-
|
|
629
|
-
warning: "border-warning-
|
|
630
|
-
destructive: "border-
|
|
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-
|
|
820
|
+
success: "bg-success-solid",
|
|
804
821
|
error: "bg-destructive"
|
|
805
822
|
} },
|
|
806
823
|
defaultVariants: { variant: "default" }
|
|
@@ -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.
|
|
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
|
});
|
|
@@ -2749,7 +2832,13 @@ function Toaster({ theme = "system", ...props }) {
|
|
|
2749
2832
|
"--success-bg": "var(--nx-toast-success-bg)",
|
|
2750
2833
|
"--success-text": "var(--nx-toast-success-text)",
|
|
2751
2834
|
"--warning-bg": "var(--nx-toast-warning-bg)",
|
|
2752
|
-
"--warning-text": "var(--nx-toast-warning-text)"
|
|
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)"
|
|
2753
2842
|
},
|
|
2754
2843
|
...props
|
|
2755
2844
|
});
|
|
@@ -4404,7 +4493,7 @@ function MissingIconWarning({ shown, id }) {
|
|
|
4404
4493
|
if (!shown) return null;
|
|
4405
4494
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
4406
4495
|
id,
|
|
4407
|
-
className: "mt-1.5 flex items-start gap-2 rounded-md border border-warning-
|
|
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",
|
|
4408
4497
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.TriangleAlert, {
|
|
4409
4498
|
className: "mt-px size-3.5 shrink-0",
|
|
4410
4499
|
"aria-hidden": "true"
|
|
@@ -6770,7 +6859,7 @@ const SHELL_MEASURE = {
|
|
|
6770
6859
|
* "how far is content from the panel's edge".
|
|
6771
6860
|
* @experimental
|
|
6772
6861
|
*/
|
|
6773
|
-
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) => {
|
|
6774
6863
|
const shellRef = (0, react.useRef)(null);
|
|
6775
6864
|
const attachRef = (0, react.useCallback)((node) => {
|
|
6776
6865
|
shellRef.current = node;
|
|
@@ -6803,6 +6892,7 @@ const PageShell = (0, react.forwardRef)(({ width = "form", className, children,
|
|
|
6803
6892
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6804
6893
|
ref: attachRef,
|
|
6805
6894
|
"data-slot": "page-shell",
|
|
6895
|
+
"data-align": align,
|
|
6806
6896
|
style: shellStyle,
|
|
6807
6897
|
className: cn("nx-page-shell py-8", className),
|
|
6808
6898
|
...props,
|
|
@@ -6866,32 +6956,156 @@ Bleed.displayName = "Bleed";
|
|
|
6866
6956
|
* prop.
|
|
6867
6957
|
* @experimental
|
|
6868
6958
|
*/
|
|
6869
|
-
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", {
|
|
6870
6960
|
ref,
|
|
6871
6961
|
"data-slot": "page-header",
|
|
6872
6962
|
className: cn("mb-8", className),
|
|
6873
6963
|
...props,
|
|
6874
|
-
children: [
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
className: "
|
|
6881
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
6882
|
-
className: "
|
|
6883
|
-
children:
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
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
|
|
6887
6994
|
}) : null]
|
|
6888
|
-
}),
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6995
|
+
}),
|
|
6996
|
+
tabs ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6997
|
+
className: "mt-6",
|
|
6998
|
+
children: tabs
|
|
6999
|
+
}) : null
|
|
7000
|
+
]
|
|
6893
7001
|
}));
|
|
6894
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";
|
|
6895
7109
|
exports.Accordion = Accordion;
|
|
6896
7110
|
exports.AccordionContent = AccordionContent;
|
|
6897
7111
|
exports.AccordionItem = AccordionItem;
|
|
@@ -6986,8 +7200,12 @@ exports.IconGlyph = IconGlyph;
|
|
|
6986
7200
|
exports.IconPicker = IconPicker;
|
|
6987
7201
|
exports.Input = Input;
|
|
6988
7202
|
exports.Label = Label;
|
|
7203
|
+
exports.PageFrame = PageFrame;
|
|
7204
|
+
exports.PageFrameListener = PageFrameListener;
|
|
6989
7205
|
exports.PageHeader = PageHeader;
|
|
6990
7206
|
exports.PageShell = PageShell;
|
|
7207
|
+
exports.PageTab = PageTab;
|
|
7208
|
+
exports.PageTabs = PageTabs;
|
|
6991
7209
|
exports.Popover = Popover;
|
|
6992
7210
|
exports.PopoverAnchor = PopoverAnchor;
|
|
6993
7211
|
exports.PopoverContent = PopoverContent;
|