skyloom-ui 0.1.1 → 0.1.2
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/README.md +291 -4
- package/dist/advanced.css +89 -0
- package/dist/components/accordion.js +3 -2
- package/dist/components/advanced-forms.d.ts +40 -0
- package/dist/components/advanced-forms.js +66 -0
- package/dist/components/advanced-layout.d.ts +29 -0
- package/dist/components/advanced-layout.js +49 -0
- package/dist/components/ai-status.d.ts +29 -0
- package/dist/components/ai-status.js +19 -0
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/alert.js +1 -0
- package/dist/components/animated-tooltip.d.ts +10 -0
- package/dist/components/animated-tooltip.js +17 -0
- package/dist/components/badge.d.ts +4 -2
- package/dist/components/badge.js +7 -4
- package/dist/components/breadcrumb.d.ts +1 -1
- package/dist/components/breadcrumb.js +2 -1
- package/dist/components/button-group.d.ts +5 -0
- package/dist/components/button-group.js +8 -0
- package/dist/components/button.d.ts +4 -4
- package/dist/components/button.js +8 -3
- package/dist/components/card.d.ts +6 -1
- package/dist/components/card.js +13 -2
- package/dist/components/code-block.d.ts +31 -0
- package/dist/components/code-block.js +49 -0
- package/dist/components/compare.d.ts +17 -0
- package/dist/components/compare.js +39 -0
- package/dist/components/data-table-columns.d.ts +24 -0
- package/dist/components/data-table-columns.js +60 -0
- package/dist/components/data-table.d.ts +9 -1
- package/dist/components/data-table.js +16 -6
- package/dist/components/dialog.d.ts +11 -2
- package/dist/components/dialog.js +13 -2
- package/dist/components/dropdown-menu.js +2 -2
- package/dist/components/feature-card.d.ts +9 -0
- package/dist/components/feature-card.js +6 -0
- package/dist/components/fields.d.ts +9 -2
- package/dist/components/fields.js +10 -5
- package/dist/components/globe-renderer.d.ts +7 -0
- package/dist/components/globe-renderer.js +32 -0
- package/dist/components/globe.d.ts +9 -0
- package/dist/components/globe.js +25 -0
- package/dist/components/icon.d.ts +26 -0
- package/dist/components/icon.js +26 -0
- package/dist/components/image-generation-loader.d.ts +15 -0
- package/dist/components/image-generation-loader.js +93 -0
- package/dist/components/interactive-card.d.ts +6 -0
- package/dist/components/interactive-card.js +18 -0
- package/dist/components/link-preview.d.ts +25 -0
- package/dist/components/link-preview.js +84 -0
- package/dist/components/loader.d.ts +18 -0
- package/dist/components/loader.js +17 -0
- package/dist/components/loading.js +1 -1
- package/dist/components/message.d.ts +8 -0
- package/dist/components/message.js +11 -0
- package/dist/components/motion.d.ts +32 -0
- package/dist/components/motion.js +63 -0
- package/dist/components/multi-step-loader.d.ts +16 -0
- package/dist/components/multi-step-loader.js +29 -0
- package/dist/components/navigation.d.ts +76 -0
- package/dist/components/navigation.js +99 -0
- package/dist/components/popover.js +1 -1
- package/dist/components/progress.js +1 -1
- package/dist/components/prompt-input.d.ts +17 -0
- package/dist/components/prompt-input.js +27 -0
- package/dist/components/select.js +4 -3
- package/dist/components/sheet.js +2 -1
- package/dist/components/stat-card.d.ts +10 -0
- package/dist/components/stat-card.js +6 -0
- package/dist/components/tabs.d.ts +3 -1
- package/dist/components/tabs.js +4 -4
- package/dist/components/text-effects.d.ts +48 -0
- package/dist/components/text-effects.js +105 -0
- package/dist/components/theme-controls.d.ts +2 -0
- package/dist/components/theme-controls.js +17 -0
- package/dist/components/theme-provider.d.ts +20 -0
- package/dist/components/theme-provider.js +50 -0
- package/dist/components/theme-script.d.ts +9 -0
- package/dist/components/theme-script.js +8 -0
- package/dist/components/timeline.d.ts +12 -0
- package/dist/components/timeline.js +11 -0
- package/dist/components/tooltip.js +1 -1
- package/dist/components/use-column-layout.d.ts +6 -0
- package/dist/components/use-column-layout.js +38 -0
- package/dist/components/use-column-pinning.d.ts +10 -0
- package/dist/components/use-column-pinning.js +50 -0
- package/dist/components/world-map.d.ts +17 -0
- package/dist/components/world-map.js +13 -0
- package/dist/data/land.d.ts +1 -0
- package/dist/data/land.js +2 -0
- package/dist/index.d.ts +33 -5
- package/dist/index.js +30 -3
- package/dist/lib/canvas-tokens.d.ts +5 -0
- package/dist/lib/canvas-tokens.js +34 -0
- package/dist/lib/column-layout.d.ts +36 -0
- package/dist/lib/column-layout.js +69 -0
- package/dist/lib/theme-settings.d.ts +22 -0
- package/dist/lib/theme-settings.js +36 -0
- package/dist/styles.css +56 -3
- package/dist/tokens.css +273 -153
- package/package.json +20 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { motion as animated, useMotionValue, animate } from "motion/react";
|
|
5
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "./card.js";
|
|
6
|
+
import { Dialog, DialogContent, DialogTitle, DialogDescription } from "./dialog.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
import { Icon } from "./icon.js";
|
|
9
|
+
import { useAnimationActivity, useMotionPolicy } from "./motion.js";
|
|
10
|
+
import { tokenLength } from "../lib/canvas-tokens.js";
|
|
11
|
+
import { cn } from "../lib/utils.js";
|
|
12
|
+
export function BentoGrid({ className, ...props }) { return _jsx("div", { className: cn("grid min-w-0 grid-cols-1 gap-stack tablet:grid-cols-2 laptop:grid-cols-3", className), ...props }); }
|
|
13
|
+
export function BentoGridItem({ title, description, header, icon, span = "default", children, className, ...props }) {
|
|
14
|
+
return _jsxs(Card, { ...props, className: cn("min-w-0 overflow-hidden", span === "wide" && "tablet:col-span-2", span === "tall" && "tablet:row-span-2", className), children: [header && _jsx("div", { className: "min-h-preview overflow-hidden bg-secondary", children: header }), _jsxs(CardHeader, { children: [icon && _jsx("span", { className: "sky-icon-slot text-primary", children: icon }), _jsx(CardTitle, { children: title }), description && _jsx(CardDescription, { children: description })] }), children && _jsx(CardContent, { children: children })] });
|
|
15
|
+
}
|
|
16
|
+
export function ContainerCover({ children, className, ...props }) { const activity = useAnimationActivity(); return _jsxs("span", { ...props, ref: activity.ref, "data-running": activity.enabled, className: cn("sky-cover relative inline-block overflow-hidden rounded-control bg-secondary px-inline py-control", className), children: [_jsx("span", { className: "relative z-10", children: children }), _jsx("span", { "aria-hidden": "true", className: "sky-cover-beams pointer-events-none absolute inset-0" })] }); }
|
|
17
|
+
function Thumbnail({ item }) { const [failed, setFailed] = useState(false); return item.image && !failed ? _jsx("img", { src: item.image, alt: "", className: "h-preview w-full object-cover", loading: "lazy", onError: () => setFailed(true) }) : _jsx("div", { className: "flex h-preview items-center justify-center bg-secondary p-inline text-primary", children: _jsx("span", { className: "text-title font-semibold", children: item.title }) }); }
|
|
18
|
+
function GalleryDialog({ item, onClose, variant }) { return _jsx(Dialog, { open: !!item, onOpenChange: open => { if (!open)
|
|
19
|
+
onClose(); }, children: _jsxs(DialogContent, { variant: variant, children: [_jsx(DialogTitle, { children: item?.title }), _jsx(DialogDescription, { children: item?.description ?? "Gallery details" }), item && _jsx(Thumbnail, { item: item }), item?.content] }) }); }
|
|
20
|
+
export function LayoutGrid({ items, variant = "default", className }) {
|
|
21
|
+
const [selected, setSelected] = useState(), trigger = useRef(null);
|
|
22
|
+
const { enabled } = useMotionPolicy();
|
|
23
|
+
return _jsxs(_Fragment, { children: [_jsx("div", { className: cn("grid grid-cols-1 gap-stack tablet:grid-cols-2", className), children: items.map(item => _jsxs(animated.button, { layout: enabled, type: "button", "data-variant": variant, className: "sky-focus sky-advanced-surface overflow-hidden text-start", onClick: event => { trigger.current = event.currentTarget; setSelected(item.id); }, children: [_jsx(Thumbnail, { item: item }), _jsx("span", { className: "block p-inline font-medium", children: item.title })] }, item.id)) }), _jsx(GalleryDialog, { item: items.find(item => item.id === selected), variant: variant, onClose: () => { setSelected(undefined); requestAnimationFrame(() => trigger.current?.focus()); } })] });
|
|
24
|
+
}
|
|
25
|
+
export function InfiniteCardGrid({ items, variant = "modern", className }) {
|
|
26
|
+
const [list, setList] = useState(false), [selected, setSelected] = useState(), [geometry, setGeometry] = useState({ width: 0, height: 0, tile: 1 });
|
|
27
|
+
const [position, setPosition] = useState({ x: 0, y: 0 });
|
|
28
|
+
const activity = useAnimationActivity(), x = useMotionValue(0), y = useMotionValue(0), moved = useRef(false), down = useRef({ x: 0, y: 0 }), focus = useRef(null);
|
|
29
|
+
useEffect(() => { const stopX = x.on("change", next => setPosition(current => ({ ...current, x: next }))); const stopY = y.on("change", next => setPosition(current => ({ ...current, y: next }))); return () => { stopX(); stopY(); }; }, [x, y]);
|
|
30
|
+
useEffect(() => { if (!activity.node)
|
|
31
|
+
return; const node = activity.node; const resize = () => { const rect = node.getBoundingClientRect(); setGeometry({ width: rect.width, height: rect.height, tile: tokenLength(node, "--sky-gallery-tile", 192) }); }; const observer = new ResizeObserver(resize); observer.observe(node); resize(); return () => observer.disconnect(); }, [activity.node, activity.themeKey]);
|
|
32
|
+
useEffect(() => { if (!activity.enabled) {
|
|
33
|
+
x.stop();
|
|
34
|
+
y.stop();
|
|
35
|
+
} return () => { x.stop(); y.stop(); }; }, [activity.enabled, x, y]);
|
|
36
|
+
const columns = Math.ceil(geometry.width / geometry.tile) + 2, rows = Math.ceil(geometry.height / geometry.tile) + 2;
|
|
37
|
+
const baseX = Math.floor(-position.x / geometry.tile) - 1, baseY = Math.floor(-position.y / geometry.tile) - 1;
|
|
38
|
+
const pan = (dx, dy) => { x.stop(); y.stop(); x.set(x.get() + dx); y.set(y.get() + dy); };
|
|
39
|
+
return _jsxs("section", { "aria-label": "Card gallery", className: cn("grid gap-control", className), children: [_jsxs("div", { className: "flex flex-wrap gap-control", children: [_jsx(Button, { variant: "outline", onClick: () => setList(!list), children: list ? "Explore grid" : "Accessible list" }), _jsx(Button, { variant: "ghost", onClick: () => { x.stop(); y.stop(); x.set(0); y.set(0); }, children: "Reset position" }), !list && _jsxs(_Fragment, { children: [_jsx(Button, { "aria-label": "Pan left", size: "icon", variant: "outline", onClick: () => pan(geometry.tile, 0), children: _jsx(Icon, { name: "arrow-left" }) }), _jsx(Button, { "aria-label": "Pan right", size: "icon", variant: "outline", onClick: () => pan(-geometry.tile, 0), children: _jsx(Icon, { name: "arrow-right" }) }), _jsx(Button, { "aria-label": "Pan up", size: "icon", variant: "outline", onClick: () => pan(0, geometry.tile), children: _jsx(Icon, { name: "arrow-up" }) }), _jsx(Button, { "aria-label": "Pan down", size: "icon", variant: "outline", onClick: () => pan(0, -geometry.tile), children: _jsx(Icon, { name: "arrow-down" }) })] })] }), !items.length ? _jsx("p", { children: "No cards available." }) : list ? _jsx(LayoutGrid, { items: items, variant: variant }) : _jsx("div", { ref: activity.ref, tabIndex: 0, role: "group", "aria-label": "Draggable gallery. Use arrow keys to pan, or switch to accessible list.", className: "sky-infinite-grid sky-focus relative overflow-hidden rounded-surface bg-muted", onKeyDown: event => { if (event.target !== event.currentTarget)
|
|
40
|
+
return; const offsets = { ArrowLeft: [geometry.tile, 0], ArrowRight: [-geometry.tile, 0], ArrowUp: [0, geometry.tile], ArrowDown: [0, -geometry.tile] }; if (offsets[event.key]) {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
pan(...offsets[event.key]);
|
|
43
|
+
} }, children: _jsx(animated.div, { drag: true, dragMomentum: false, style: { x, y }, className: "absolute inset-0 touch-none", onPointerDownCapture: event => { moved.current = false; down.current = { x: event.clientX, y: event.clientY }; }, onPointerMoveCapture: event => { if (Math.hypot(event.clientX - down.current.x, event.clientY - down.current.y) > 6)
|
|
44
|
+
moved.current = true; }, onDragEnd: (_, info) => { if (activity.enabled) {
|
|
45
|
+
animate(x, x.get() + info.velocity.x * .15, { type: "spring", damping: 35, stiffness: 150 });
|
|
46
|
+
animate(y, y.get() + info.velocity.y * .15, { type: "spring", damping: 35, stiffness: 150 });
|
|
47
|
+
} }, children: Array.from({ length: Math.min(rows * columns, 120) }, (_, index) => { const col = baseX + index % columns, row = baseY + Math.floor(index / columns), item = items[((row * 7 + col) % items.length + items.length) % items.length]; return _jsxs("button", { type: "button", tabIndex: -1, "aria-label": `Open ${item.title}`, "data-variant": variant, className: "sky-gallery-tile sky-advanced-surface absolute overflow-hidden text-start", style: { left: col * geometry.tile, top: row * geometry.tile, width: geometry.tile, height: geometry.tile }, onClick: event => { if (moved.current)
|
|
48
|
+
return; focus.current = event.currentTarget.closest("[role=group]"); setSelected(item.id); }, children: [_jsx(Thumbnail, { item: item }), _jsx("span", { className: "block truncate p-control text-label", children: item.title })] }, `${col}:${row}`); }) }) }), _jsx(GalleryDialog, { item: items.find(item => item.id === selected), variant: variant, onClose: () => { setSelected(undefined); requestAnimationFrame(() => focus.current?.focus()); } })] });
|
|
49
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
export type TaskStatus = "pending" | "running" | "complete" | "error";
|
|
3
|
+
export declare function Suggestions({ items, onSelect, disabled, className, ...props }: Omit<ComponentPropsWithRef<"div">, "onSelect" | "children"> & {
|
|
4
|
+
items: readonly string[];
|
|
5
|
+
onSelect: (value: string) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export declare function ToolStatus({ title, status, children, open, defaultOpen, onOpenChange, className }: {
|
|
9
|
+
title: string;
|
|
10
|
+
status: TaskStatus;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
open?: boolean;
|
|
13
|
+
defaultOpen?: boolean;
|
|
14
|
+
onOpenChange?: (open: boolean) => void;
|
|
15
|
+
className?: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
export declare function ShimmerText({ active, className, ...props }: ComponentPropsWithRef<"span"> & {
|
|
18
|
+
active?: boolean;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
20
|
+
export type TaskPlanStep = {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
description?: ReactNode;
|
|
24
|
+
status: TaskStatus;
|
|
25
|
+
};
|
|
26
|
+
export declare function TaskPlan({ title, steps, ...props }: Omit<ComponentPropsWithRef<"section">, "title" | "children"> & {
|
|
27
|
+
title: string;
|
|
28
|
+
steps: readonly TaskPlanStep[];
|
|
29
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "./accordion.js";
|
|
4
|
+
import { Badge } from "./badge.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
const statusLabels = { pending: "Pending", running: "Running", complete: "Complete", error: "Error" };
|
|
8
|
+
export function Suggestions({ items, onSelect, disabled, className, ...props }) {
|
|
9
|
+
return _jsx("div", { role: "group", "aria-label": "Suggested prompts", className: cn("flex min-w-0 flex-wrap gap-control", className), ...props, children: items.map((item, index) => _jsx(Button, { variant: "outline", shape: "pill", disabled: disabled, className: "h-auto whitespace-normal py-control text-start", onClick: () => onSelect(item), children: item }, `${index}-${item}`)) });
|
|
10
|
+
}
|
|
11
|
+
export function ToolStatus({ title, status, children, open, defaultOpen = false, onOpenChange, className }) {
|
|
12
|
+
return _jsx(Accordion, { type: "single", collapsible: true, value: open === undefined ? undefined : open ? "details" : "", defaultValue: defaultOpen ? "details" : "", onValueChange: value => onOpenChange?.(value === "details"), className: className, children: _jsxs(AccordionItem, { value: "details", children: [_jsxs(AccordionTrigger, { "aria-label": `${title} ${statusLabels[status]}`, children: [_jsx("span", { className: "min-w-0 flex-1 wrap-anywhere", children: title }), _jsx(Badge, { className: "shrink-0 whitespace-nowrap", variant: status === "error" ? "destructive" : status === "complete" ? "success" : "secondary", children: statusLabels[status] })] }), _jsx(AccordionContent, { children: children })] }) });
|
|
13
|
+
}
|
|
14
|
+
export function ShimmerText({ active = true, className, ...props }) {
|
|
15
|
+
return _jsx("span", { className: cn(active && "sky-shimmer-text", className), ...props });
|
|
16
|
+
}
|
|
17
|
+
export function TaskPlan({ title, steps, ...props }) {
|
|
18
|
+
return _jsxs("section", { "aria-label": title, ...props, children: [_jsx("h3", { className: "mb-stack text-body font-semibold", children: title }), _jsx("ol", { className: "grid gap-control", children: steps.map(step => _jsx("li", { children: _jsx(ToolStatus, { title: step.title, status: step.status, children: step.description ?? "No additional details." }) }, step.id)) })] });
|
|
19
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef } from "react";
|
|
2
2
|
export declare function Alert({ className, variant, role, ...props }: ComponentPropsWithRef<"div"> & {
|
|
3
|
-
variant?: "default" | "destructive" | "success";
|
|
3
|
+
variant?: "default" | "destructive" | "success" | "warning" | "info";
|
|
4
4
|
}): import("react").JSX.Element;
|
|
5
5
|
export declare function AlertTitle({ className, ...props }: ComponentPropsWithRef<"h3">): import("react").JSX.Element;
|
|
6
6
|
export declare function AlertDescription({ className, ...props }: ComponentPropsWithRef<"div">): import("react").JSX.Element;
|
package/dist/components/alert.js
CHANGED
|
@@ -3,6 +3,7 @@ import { cn } from "../lib/utils.js";
|
|
|
3
3
|
export function Alert({ className, variant = "default", role = "status", ...props }) {
|
|
4
4
|
return _jsx("div", { role: role, className: cn("sky-border grid gap-control rounded-surface bg-card p-panel", {
|
|
5
5
|
default: "border-border text-card-foreground", destructive: "border-destructive text-destructive", success: "border-success text-success",
|
|
6
|
+
warning: "border-warning text-warning", info: "border-info text-info",
|
|
6
7
|
}[variant], className), ...props });
|
|
7
8
|
}
|
|
8
9
|
export function AlertTitle({ className, ...props }) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type TooltipPerson = {
|
|
2
|
+
id: string | number;
|
|
3
|
+
name: string;
|
|
4
|
+
designation: string;
|
|
5
|
+
image?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function AnimatedTooltip({ items, effect }: {
|
|
8
|
+
items: readonly TooltipPerson[];
|
|
9
|
+
effect?: "spring" | "follow" | "none";
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { motion as animated } from "motion/react";
|
|
5
|
+
import { Avatar, AvatarImage, AvatarFallback } from "./avatar.js";
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
7
|
+
import { Tooltip, TooltipProvider, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
import { useMotionPolicy } from "./motion.js";
|
|
10
|
+
function Person({ item, effect }) {
|
|
11
|
+
const [x, setX] = useState(0);
|
|
12
|
+
const { enabled, settings } = useMotionPolicy();
|
|
13
|
+
const details = _jsxs(_Fragment, { children: [_jsx("p", { className: "font-semibold", children: item.name }), _jsx("p", { className: "text-caption", children: item.designation })] });
|
|
14
|
+
return _jsxs(Popover, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { size: "icon", variant: "ghost", shape: "pill", "aria-label": `Details for ${item.name}`, onPointerMove: event => { const rect = event.currentTarget.getBoundingClientRect(); if (event.pointerType === "mouse")
|
|
15
|
+
setX((event.clientX - rect.left) / rect.width - .5); }, onPointerLeave: () => setX(0), children: _jsxs(Avatar, { children: [_jsx(AvatarImage, { src: item.image, alt: "" }), _jsx(AvatarFallback, { children: item.name.slice(0, 2) })] }) }) }) }), _jsx(TooltipContent, { children: _jsx(animated.div, { initial: enabled && effect !== "none" ? { opacity: 0, scale: .85, y: "20%" } : false, animate: { opacity: 1, scale: 1, y: "0%", rotate: enabled && effect === "follow" ? x * 12 : 0, x: enabled && effect === "follow" ? `${x * 20}%` : "0%" }, transition: { type: "spring", stiffness: settings.stiffness, damping: settings.damping, duration: enabled ? undefined : 0 }, children: details }) })] }), _jsx(PopoverContent, { "aria-label": item.name, children: details })] });
|
|
16
|
+
}
|
|
17
|
+
export function AnimatedTooltip({ items, effect = "spring" }) { return _jsx(TooltipProvider, { children: _jsx("div", { className: "flex flex-wrap items-center -space-x-control rtl:space-x-reverse", "aria-label": "People", children: items.map(item => _jsx(Person, { item: item, effect: effect }, item.id)) }) }); }
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef } from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const variants: (props?: ({
|
|
4
|
-
variant?: "default" | "secondary" | "outline" | "destructive" | "success" | null | undefined;
|
|
4
|
+
variant?: "default" | "secondary" | "outline" | "destructive" | "soft" | "success" | "info" | "warning" | null | undefined;
|
|
5
|
+
shape?: "default" | "pill" | null | undefined;
|
|
5
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
-
export
|
|
7
|
+
export type BadgeProps = ComponentPropsWithRef<"span"> & VariantProps<typeof variants>;
|
|
8
|
+
export declare function Badge({ className, variant, shape, ...props }: BadgeProps): import("react").JSX.Element;
|
|
7
9
|
export {};
|
package/dist/components/badge.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cva } from "class-variance-authority";
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
|
-
const variants = cva("inline-flex items-center gap-control rounded-control px-inline py-control text-caption font-medium", {
|
|
4
|
+
const variants = cva("sky-icon-slot inline-flex items-center gap-control rounded-control px-inline py-control text-caption font-medium", {
|
|
5
5
|
variants: { variant: {
|
|
6
6
|
default: "bg-primary text-primary-foreground",
|
|
7
7
|
secondary: "bg-secondary text-secondary-foreground",
|
|
8
8
|
destructive: "bg-destructive text-destructive-foreground",
|
|
9
9
|
success: "bg-success text-success-foreground",
|
|
10
|
+
warning: "bg-warning text-warning-foreground",
|
|
11
|
+
info: "bg-info text-info-foreground",
|
|
12
|
+
soft: "bg-secondary text-primary",
|
|
10
13
|
outline: "sky-border border-border text-foreground",
|
|
11
|
-
} }, defaultVariants: { variant: "default" },
|
|
14
|
+
}, shape: { default: "", pill: "rounded-capsule" } }, defaultVariants: { variant: "default" },
|
|
12
15
|
});
|
|
13
|
-
export function Badge({ className, variant, ...props }) {
|
|
14
|
-
return _jsx("span", { className: cn(variants({ variant }), className), ...props });
|
|
16
|
+
export function Badge({ className, variant, shape, ...props }) {
|
|
17
|
+
return _jsx("span", { className: cn(variants({ variant, shape }), className), ...props });
|
|
15
18
|
}
|
|
@@ -4,4 +4,4 @@ export declare function BreadcrumbList({ className, ...props }: ComponentPropsWi
|
|
|
4
4
|
export declare function BreadcrumbItem({ className, ...props }: ComponentPropsWithRef<"li">): import("react").JSX.Element;
|
|
5
5
|
export declare function BreadcrumbLink({ className, ...props }: ComponentPropsWithRef<"a">): import("react").JSX.Element;
|
|
6
6
|
export declare function BreadcrumbPage({ className, ...props }: ComponentPropsWithRef<"span">): import("react").JSX.Element;
|
|
7
|
-
export declare function BreadcrumbSeparator({ children, ...props }: ComponentPropsWithRef<"li">): import("react").JSX.Element;
|
|
7
|
+
export declare function BreadcrumbSeparator({ children, className, ...props }: ComponentPropsWithRef<"li">): import("react").JSX.Element;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { Icon } from "./icon.js";
|
|
3
4
|
export function Breadcrumb(props) { return _jsx("nav", { "aria-label": "Breadcrumb", ...props }); }
|
|
4
5
|
export function BreadcrumbList({ className, ...props }) { return _jsx("ol", { className: cn("flex flex-wrap items-center gap-control text-label text-muted-foreground", className), ...props }); }
|
|
5
6
|
export function BreadcrumbItem({ className, ...props }) { return _jsx("li", { className: cn("inline-flex items-center gap-control", className), ...props }); }
|
|
6
7
|
export function BreadcrumbLink({ className, ...props }) { return _jsx("a", { className: cn("sky-focus inline-flex min-h-touch items-center hover:text-foreground", className), ...props }); }
|
|
7
8
|
export function BreadcrumbPage({ className, ...props }) { return _jsx("span", { "aria-current": "page", className: cn("text-foreground", className), ...props }); }
|
|
8
|
-
export function BreadcrumbSeparator({ children = "
|
|
9
|
+
export function BreadcrumbSeparator({ children = _jsx(Icon, { name: "chevron-right", className: "rtl:rotate-180" }), className, ...props }) { return _jsx("li", { "aria-hidden": "true", role: "presentation", className: cn("sky-icon-slot inline-flex shrink-0 items-center justify-center", className), ...props, children: children }); }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
export declare function ButtonGroup({ className, orientation, ...props }: ComponentPropsWithRef<"div"> & {
|
|
3
|
+
orientation?: "horizontal" | "vertical";
|
|
4
|
+
}): import("react").JSX.Element;
|
|
5
|
+
export declare function Kbd({ className, ...props }: ComponentPropsWithRef<"kbd">): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
export function ButtonGroup({ className, orientation = "horizontal", ...props }) {
|
|
4
|
+
return _jsx("div", { role: "group", className: cn("flex min-w-0 gap-control", orientation === "vertical" ? "flex-col items-stretch" : "flex-wrap items-center", className), ...props });
|
|
5
|
+
}
|
|
6
|
+
export function Kbd({ className, ...props }) {
|
|
7
|
+
return _jsx("kbd", { className: cn("sky-border inline-flex items-center justify-center rounded-control border-border bg-muted px-control py-control font-mono text-caption text-muted-foreground", className), ...props });
|
|
8
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
|
-
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "default" | "secondary" | "outline" | "ghost" | "destructive" | "link" | null | undefined;
|
|
3
|
+
export declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "hover-border-gradient" | "default" | "secondary" | "outline" | "ghost" | "destructive" | "link" | "soft" | "success" | "classic" | null | undefined;
|
|
5
5
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
|
+
shape?: "default" | "pill" | "square" | null | undefined;
|
|
6
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
8
|
export type ButtonProps = React.ComponentPropsWithRef<"button"> & VariantProps<typeof buttonVariants> & {
|
|
8
9
|
asChild?: boolean;
|
|
9
10
|
};
|
|
10
|
-
export declare function Button({ className, variant, size, asChild, type, ...props }: ButtonProps): React.JSX.Element;
|
|
11
|
-
export {};
|
|
11
|
+
export declare function Button({ className, variant, size, shape, asChild, type, ...props }: ButtonProps): React.JSX.Element;
|
|
@@ -3,18 +3,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Slot } from "@radix-ui/react-slot";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
|
-
const buttonVariants = cva("inline-flex items-center justify-center gap-control rounded-control text-label font-medium sky-transition sky-focus disabled:pointer-events-none sky-disabled", { variants: {
|
|
6
|
+
export const buttonVariants = cva("sky-action sky-icon-slot inline-flex items-center justify-center gap-control rounded-control text-label font-medium sky-transition sky-focus disabled:pointer-events-none sky-disabled", { variants: {
|
|
7
7
|
variant: {
|
|
8
|
+
"hover-border-gradient": "sky-gradient-border bg-card text-card-foreground",
|
|
8
9
|
default: "bg-primary text-primary-foreground sky-hover",
|
|
9
10
|
secondary: "bg-secondary text-secondary-foreground sky-hover",
|
|
10
11
|
outline: "sky-border border-input bg-background hover:bg-secondary",
|
|
11
12
|
ghost: "hover:bg-secondary",
|
|
12
13
|
destructive: "bg-destructive text-destructive-foreground sky-hover",
|
|
13
14
|
link: "sky-link text-primary hover:underline",
|
|
15
|
+
soft: "bg-secondary text-primary hover:bg-accent",
|
|
16
|
+
success: "bg-success text-success-foreground sky-hover",
|
|
17
|
+
classic: "sky-border border-input bg-card text-card-foreground shadow-raised hover:bg-secondary",
|
|
14
18
|
},
|
|
15
19
|
size: { default: "h-field min-h-touch tablet:min-h-field px-panel", sm: "h-field-sm min-h-touch tablet:min-h-field-sm px-inline", lg: "h-field-lg px-panel", icon: "size-field min-h-touch min-w-touch" },
|
|
20
|
+
shape: { default: "", pill: "rounded-capsule", square: "rounded-none" },
|
|
16
21
|
}, defaultVariants: { variant: "default", size: "default" } });
|
|
17
|
-
export function Button({ className, variant, size, asChild = false, type, ...props }) {
|
|
22
|
+
export function Button({ className, variant, size, shape, asChild = false, type, ...props }) {
|
|
18
23
|
const Component = asChild ? Slot : "button";
|
|
19
|
-
return _jsx(Component, { type: asChild ? type : (type ?? "button"), className: cn(buttonVariants({ variant, size }), className), ...props });
|
|
24
|
+
return _jsx(Component, { type: asChild ? type : (type ?? "button"), className: cn(buttonVariants({ variant, size, shape }), className), ...props });
|
|
20
25
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef } from "react";
|
|
2
|
-
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
export declare const cardVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "outline" | "soft" | "classic" | "modern" | "elevated" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export type CardProps = ComponentPropsWithRef<"div"> & VariantProps<typeof cardVariants>;
|
|
7
|
+
export declare function Card({ className, variant, ...props }: CardProps): import("react").JSX.Element;
|
|
3
8
|
export declare function CardHeader({ className, ...props }: ComponentPropsWithRef<"div">): import("react").JSX.Element;
|
|
4
9
|
export declare function CardTitle({ className, ...props }: ComponentPropsWithRef<"h2">): import("react").JSX.Element;
|
|
5
10
|
export declare function CardDescription({ className, ...props }: ComponentPropsWithRef<"p">): import("react").JSX.Element;
|
package/dist/components/card.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
2
3
|
import { cn } from "../lib/utils.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
4
|
+
export const cardVariants = cva("sky-border min-w-0 rounded-surface border-border bg-card text-card-foreground", {
|
|
5
|
+
variants: { variant: {
|
|
6
|
+
default: "shadow-raised",
|
|
7
|
+
outline: "shadow-none",
|
|
8
|
+
soft: "border-transparent bg-muted text-foreground shadow-none",
|
|
9
|
+
classic: "rounded-control border-input shadow-raised",
|
|
10
|
+
modern: "rounded-modal shadow-none",
|
|
11
|
+
elevated: "shadow-floating",
|
|
12
|
+
} }, defaultVariants: { variant: "default" },
|
|
13
|
+
});
|
|
14
|
+
export function Card({ className, variant, ...props }) {
|
|
15
|
+
return _jsx("div", { className: cn(cardVariants({ variant }), className), ...props });
|
|
5
16
|
}
|
|
6
17
|
export function CardHeader({ className, ...props }) {
|
|
7
18
|
return _jsx("div", { className: cn("grid gap-control p-panel", className), ...props });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "prismjs/components/prism-markup.js";
|
|
2
|
+
import "prismjs/components/prism-javascript.js";
|
|
3
|
+
import "prismjs/components/prism-typescript.js";
|
|
4
|
+
import "prismjs/components/prism-jsx.js";
|
|
5
|
+
import "prismjs/components/prism-tsx.js";
|
|
6
|
+
import "prismjs/components/prism-json.js";
|
|
7
|
+
import "prismjs/components/prism-css.js";
|
|
8
|
+
export type CodeSnippet = {
|
|
9
|
+
id: string;
|
|
10
|
+
code: string;
|
|
11
|
+
language?: string;
|
|
12
|
+
filename?: string;
|
|
13
|
+
highlightLines?: readonly number[];
|
|
14
|
+
};
|
|
15
|
+
export type CodeBlockProps = {
|
|
16
|
+
lineNumbers?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
} & ({
|
|
19
|
+
code: string;
|
|
20
|
+
language?: string;
|
|
21
|
+
filename?: string;
|
|
22
|
+
highlightLines?: readonly number[];
|
|
23
|
+
tabs?: never;
|
|
24
|
+
} | {
|
|
25
|
+
tabs: readonly CodeSnippet[];
|
|
26
|
+
code?: never;
|
|
27
|
+
language?: never;
|
|
28
|
+
filename?: never;
|
|
29
|
+
highlightLines?: never;
|
|
30
|
+
});
|
|
31
|
+
export declare function CodeBlock(props: CodeBlockProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import Prism from "prismjs";
|
|
5
|
+
import "prismjs/components/prism-markup.js";
|
|
6
|
+
import "prismjs/components/prism-javascript.js";
|
|
7
|
+
import "prismjs/components/prism-typescript.js";
|
|
8
|
+
import "prismjs/components/prism-jsx.js";
|
|
9
|
+
import "prismjs/components/prism-tsx.js";
|
|
10
|
+
import "prismjs/components/prism-json.js";
|
|
11
|
+
import "prismjs/components/prism-css.js";
|
|
12
|
+
import { Button } from "./button.js";
|
|
13
|
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from "./tabs.js";
|
|
14
|
+
import { cn } from "../lib/utils.js";
|
|
15
|
+
function highlightedLines(code, language) {
|
|
16
|
+
const lines = [[]];
|
|
17
|
+
const grammar = Prism.languages[language];
|
|
18
|
+
function visit(items, classes = []) {
|
|
19
|
+
for (const item of items) {
|
|
20
|
+
if (typeof item !== "string") {
|
|
21
|
+
visit(Array.isArray(item.content) ? item.content : [item.content], [...classes, "token", item.type]);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
item.split("\n").forEach((part, index) => {
|
|
25
|
+
if (index)
|
|
26
|
+
lines.push([]);
|
|
27
|
+
const line = lines[lines.length - 1];
|
|
28
|
+
line.push(classes.length ? _jsx("span", { className: classes.join(" "), children: part }, line.length) : part);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
visit(grammar ? Prism.tokenize(code, grammar) : [code]);
|
|
33
|
+
return lines;
|
|
34
|
+
}
|
|
35
|
+
export function CodeBlock(props) {
|
|
36
|
+
const [selected, setSelected] = useState(props.tabs?.[0]?.id ?? ""), [copied, setCopied] = useState(false);
|
|
37
|
+
const snippet = props.tabs ? props.tabs.find(tab => tab.id === selected) ?? props.tabs[0] : props;
|
|
38
|
+
const code = snippet?.code ?? "", language = snippet?.language ?? "text";
|
|
39
|
+
const rendered = useMemo(() => highlightedLines(code, language), [code, language]);
|
|
40
|
+
const content = _jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-between gap-control p-inline", children: [_jsx("span", { className: "truncate text-caption", children: snippet?.filename ?? language }), _jsx(Button, { size: "sm", variant: "ghost", onClick: async () => { try {
|
|
41
|
+
await navigator.clipboard.writeText(code);
|
|
42
|
+
setCopied(true);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
setCopied(false);
|
|
46
|
+
} }, children: copied ? "Copied" : "Copy code" })] }), _jsx("pre", { tabIndex: 0, className: "sky-focus max-w-full overflow-x-auto p-inline text-caption leading-body", children: _jsx("code", { children: rendered.map((line, index) => _jsxs("span", { className: cn("block min-h-control", snippet?.highlightLines?.includes(index + 1) && "bg-secondary"), children: [_jsx("span", { "aria-hidden": "true", className: cn("me-inline inline-block select-none text-muted-foreground", props.lineNumbers === false && "hidden"), children: index + 1 }), line, "\n"] }, index)) }) })] });
|
|
47
|
+
const active = props.tabs?.find(tab => tab.id === selected)?.id ?? props.tabs?.[0]?.id ?? "";
|
|
48
|
+
return _jsxs("section", { className: cn("sky-code sky-advanced-surface min-w-0 overflow-hidden", props.className), "aria-label": snippet?.filename ?? "Code example", children: [props.tabs ? _jsxs(Tabs, { value: active, onValueChange: value => { setSelected(value); setCopied(false); }, children: [_jsx(TabsList, { "aria-label": "Code files", children: props.tabs.map(tab => _jsx(TabsTrigger, { value: tab.id, children: tab.filename ?? tab.id }, tab.id)) }), props.tabs.map(tab => _jsx(TabsContent, { value: tab.id, children: tab.id === active && content }, tab.id))] }) : content, _jsx("span", { role: "status", className: "sr-only", children: copied ? "Code copied" : "" })] });
|
|
49
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type CompareProps = {
|
|
3
|
+
before: ReactNode;
|
|
4
|
+
after: ReactNode;
|
|
5
|
+
beforeLabel?: string;
|
|
6
|
+
afterLabel?: string;
|
|
7
|
+
value?: number;
|
|
8
|
+
defaultValue?: number;
|
|
9
|
+
onValueChange?: (value: number) => void;
|
|
10
|
+
orientation?: "horizontal" | "vertical";
|
|
11
|
+
interaction?: "drag" | "hover";
|
|
12
|
+
variant?: "default" | "classic" | "modern";
|
|
13
|
+
autoplay?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function Compare({ before, after, beforeLabel, afterLabel, value: controlled, defaultValue, onValueChange, orientation, interaction, variant, autoplay, className }: CompareProps): import("react").JSX.Element;
|
|
17
|
+
export declare const CompareSlider: typeof Compare;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Icon } from "./icon.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { useAnimationActivity } from "./motion.js";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
export function Compare({ before, after, beforeLabel = "Before", afterLabel = "After", value: controlled, defaultValue = 50, onValueChange, orientation = "horizontal", interaction = "drag", variant = "default", autoplay = false, className }) {
|
|
9
|
+
const [internal, setInternal] = useState(defaultValue), [dragging, setDragging] = useState(false), [paused, setPaused] = useState(false);
|
|
10
|
+
const activity = useAnimationActivity(), pointer = useRef(null);
|
|
11
|
+
const value = Math.max(0, Math.min(100, Number.isFinite(controlled ?? internal) ? controlled ?? internal : 50));
|
|
12
|
+
const latest = useRef(onValueChange);
|
|
13
|
+
latest.current = onValueChange;
|
|
14
|
+
function change(next) { const clamped = Math.max(0, Math.min(100, next)); if (controlled === undefined)
|
|
15
|
+
setInternal(clamped); latest.current?.(clamped); }
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!autoplay || paused || dragging || !activity.enabled || controlled !== undefined)
|
|
18
|
+
return;
|
|
19
|
+
let frame = 0;
|
|
20
|
+
const start = performance.now();
|
|
21
|
+
const tick = (time) => { const next = 50 + Math.sin((time - start) / 1500) * 45; setInternal(next); latest.current?.(next); frame = requestAnimationFrame(tick); };
|
|
22
|
+
frame = requestAnimationFrame(tick);
|
|
23
|
+
return () => cancelAnimationFrame(frame);
|
|
24
|
+
}, [autoplay, paused, dragging, activity.enabled, controlled]);
|
|
25
|
+
function move(event) {
|
|
26
|
+
if (pointer.current !== event.pointerId && !(interaction === "hover" && event.pointerType === "mouse"))
|
|
27
|
+
return;
|
|
28
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
29
|
+
const size = orientation === "horizontal" ? rect.width : rect.height;
|
|
30
|
+
if (size)
|
|
31
|
+
change(((orientation === "horizontal" ? event.clientX - rect.left : event.clientY - rect.top) / size) * 100);
|
|
32
|
+
}
|
|
33
|
+
return _jsxs("div", { className: cn("grid gap-control", className), children: [_jsxs("div", { ref: activity.ref, "data-variant": variant, "data-dragging": dragging && activity.enabled, "data-orientation": orientation, className: "sky-compare sky-advanced-surface relative isolate h-chart overflow-hidden", onPointerDown: event => { pointer.current = event.pointerId; event.currentTarget.setPointerCapture(event.pointerId); setDragging(true); setPaused(true); move(event); }, onPointerMove: move, onPointerUp: event => { if (pointer.current === event.pointerId) {
|
|
34
|
+
setDragging(false);
|
|
35
|
+
pointer.current = null;
|
|
36
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
37
|
+
} }, onPointerCancel: () => { setDragging(false); pointer.current = null; }, children: [_jsx("div", { className: "absolute inset-0", "aria-label": afterLabel, inert: true, children: after }), _jsx("div", { className: "absolute inset-0", "aria-label": beforeLabel, inert: true, style: { clipPath: orientation === "horizontal" ? `inset(0 ${100 - value}% 0 0)` : `inset(0 0 ${100 - value}% 0)` }, children: before }), _jsx("span", { className: "pointer-events-none absolute start-control top-control rounded-control bg-card p-control text-caption text-card-foreground", children: beforeLabel }), _jsx("span", { className: "pointer-events-none absolute end-control bottom-control rounded-control bg-card p-control text-caption text-card-foreground", children: afterLabel }), _jsxs("div", { className: "sky-compare-divider pointer-events-none absolute", style: (orientation === "horizontal" ? { left: `${value}%`, top: 0, height: "100%" } : { top: `${value}%`, left: 0, width: "100%" }), children: [_jsx("span", { className: "sky-compare-handle absolute flex size-touch items-center justify-center rounded-capsule bg-card text-card-foreground shadow-floating", children: _jsx(Icon, { name: "compare", className: orientation === "vertical" ? "rotate-90" : undefined }) }), variant === "modern" && dragging && activity.enabled && [0, 1, 2, 3, 4, 5].map(index => _jsx("i", { "aria-hidden": "true", className: "sky-compare-particle", style: { "--sky-index": index } }, index))] })] }), _jsxs("label", { className: "flex min-w-0 items-center gap-control text-caption", children: [_jsxs("span", { children: ["Compare ", beforeLabel, " and ", afterLabel] }), _jsx("input", { "aria-label": `Compare ${beforeLabel} and ${afterLabel}`, type: "range", min: 0, max: 100, value: value, className: "sky-focus min-h-touch min-w-0 flex-1 accent-primary", onFocus: () => setPaused(true), onChange: event => change(Number(event.target.value)) })] }), autoplay && _jsx(Button, { variant: "outline", onClick: () => setPaused(!paused), children: paused ? "Play comparison" : "Pause comparison" })] });
|
|
38
|
+
}
|
|
39
|
+
export const CompareSlider = Compare;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { type ColumnLayoutAction, type ColumnLayoutDefinition, type DataTableColumnLayout } from "../lib/column-layout.js";
|
|
3
|
+
type LayoutProps = {
|
|
4
|
+
columns: readonly ColumnLayoutDefinition[];
|
|
5
|
+
layout: DataTableColumnLayout;
|
|
6
|
+
change: (action: ColumnLayoutAction) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function ColumnDragScope({ children, columns, layout, change, visibleOnly, dragging }: LayoutProps & {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
visibleOnly?: boolean;
|
|
11
|
+
dragging?: {
|
|
12
|
+
current: boolean;
|
|
13
|
+
};
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
export declare function ManagedColumnHead({ column, layout, change, style, pinned }: Omit<LayoutProps, "columns"> & {
|
|
16
|
+
column: ColumnLayoutDefinition;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
pinned?: string;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
20
|
+
export declare function DataTableColumnManager({ columns, layout, change, reset, disabled }: LayoutProps & {
|
|
21
|
+
reset: () => void;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { DragDropProvider, DragOverlay } from "@dnd-kit/react";
|
|
5
|
+
import { isSortable, useSortable } from "@dnd-kit/react/sortable";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { Icon } from "./icon.js";
|
|
8
|
+
import { Switch } from "./switch.js";
|
|
9
|
+
import { Sheet, SheetTrigger, SheetContent, SheetTitle, SheetDescription, SheetFooter, SheetClose } from "./sheet.js";
|
|
10
|
+
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "./dropdown-menu.js";
|
|
11
|
+
import { columnRegion, columnsInRegion } from "../lib/column-layout.js";
|
|
12
|
+
import { cn } from "../lib/utils.js";
|
|
13
|
+
export function ColumnDragScope({ children, columns, layout, change, visibleOnly = false, dragging }) {
|
|
14
|
+
const [announcement, setAnnouncement] = useState("");
|
|
15
|
+
return _jsxs(DragDropProvider, { onDragStart: event => {
|
|
16
|
+
if (dragging)
|
|
17
|
+
dragging.current = true;
|
|
18
|
+
setAnnouncement(`Moving ${event.operation.source?.data.label}. Use arrow keys to reorder, Enter to drop, Escape to cancel.`);
|
|
19
|
+
}, onDragEnd: event => {
|
|
20
|
+
if (dragging)
|
|
21
|
+
setTimeout(() => { dragging.current = false; }, 0);
|
|
22
|
+
const source = event.operation.source;
|
|
23
|
+
if (!source || event.canceled || !isSortable(source)) {
|
|
24
|
+
setAnnouncement("Column move cancelled.");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const id = String(source.id);
|
|
28
|
+
const region = columnRegion(layout, id);
|
|
29
|
+
const ids = columnsInRegion(layout, region, visibleOnly);
|
|
30
|
+
const target = ids[source.index];
|
|
31
|
+
if (source.group === source.initialGroup && target) {
|
|
32
|
+
change({ type: "move", id, target, visibleOnly });
|
|
33
|
+
setAnnouncement(`${columns.find(column => column.id === id)?.header} moved to position ${source.index + 1}.`);
|
|
34
|
+
}
|
|
35
|
+
}, children: [children, _jsx(DragOverlay, { dropAnimation: null, children: source => _jsx("div", { className: "sky-border rounded-control border-primary bg-popover p-inline text-popover-foreground shadow-floating", children: String(source.data.label ?? "Column") }) }), _jsx("span", { className: "sr-only", role: "status", children: announcement })] });
|
|
36
|
+
}
|
|
37
|
+
function useColumnSortable(column, layout, visibleOnly) {
|
|
38
|
+
const region = columnRegion(layout, column.id);
|
|
39
|
+
return useSortable({ id: column.id, index: columnsInRegion(layout, region, visibleOnly).indexOf(column.id), group: region, type: region, accept: region, data: { label: column.header }, transition: null });
|
|
40
|
+
}
|
|
41
|
+
function canHide(column, layout) {
|
|
42
|
+
return column.enableHiding !== false && (layout.visibility[column.id] === false || layout.order.filter(id => layout.visibility[id]).length > 1);
|
|
43
|
+
}
|
|
44
|
+
export function ManagedColumnHead({ column, layout, change, style, pinned }) {
|
|
45
|
+
const { ref, handleRef, isDropTarget } = useColumnSortable(column, layout, true);
|
|
46
|
+
const region = columnRegion(layout, column.id);
|
|
47
|
+
return _jsx("th", { ref: ref, scope: "col", "data-column-id": column.id, "data-pinned": pinned, style: style, className: cn("sky-table-cell px-inline py-control text-start text-label font-medium text-muted-foreground", isDropTarget && "sky-column-target"), children: _jsxs("div", { className: "flex items-center gap-control", children: [_jsx(Button, { ref: handleRef, variant: "ghost", size: "icon", className: "sky-drag-handle shrink-0", "aria-label": `Move ${column.header} column`, children: _jsx(Icon, { name: "grip" }) }), _jsx("span", { className: "min-w-0 wrap-break-word", children: column.header }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "ms-auto shrink-0", "aria-label": `${column.header} column options`, children: _jsx(Icon, { name: "more-horizontal" }) }) }), _jsxs(DropdownMenuContent, { children: [_jsx(DropdownMenuItem, { disabled: column.enablePinning === false || region === "start", onSelect: () => change({ type: "pin", id: column.id, region: "start" }), children: "Pin to start" }), _jsx(DropdownMenuItem, { disabled: column.enablePinning === false || region === "end", onSelect: () => change({ type: "pin", id: column.id, region: "end" }), children: "Pin to end" }), _jsx(DropdownMenuItem, { disabled: region === "center", onSelect: () => change({ type: "pin", id: column.id, region: "center" }), children: "Unpin" }), _jsx(DropdownMenuItem, { disabled: !canHide(column, layout), onSelect: () => change({ type: "visibility", id: column.id, visible: false }), children: "Hide column" })] })] })] }) });
|
|
48
|
+
}
|
|
49
|
+
function ColumnManagerRow({ column, layout, change }) {
|
|
50
|
+
const { ref, handleRef, isDropTarget } = useColumnSortable(column, layout, false);
|
|
51
|
+
const region = columnRegion(layout, column.id);
|
|
52
|
+
const group = columnsInRegion(layout, region);
|
|
53
|
+
const index = group.indexOf(column.id);
|
|
54
|
+
return _jsxs("li", { ref: ref, className: cn("sky-border grid gap-control rounded-control border-border bg-card p-control text-card-foreground", isDropTarget && "sky-column-target"), children: [_jsxs("div", { className: "flex items-center gap-control", children: [_jsx(Button, { ref: handleRef, variant: "ghost", size: "icon", className: "sky-drag-handle shrink-0", "aria-label": `Reorder ${column.header}`, children: _jsx(Icon, { name: "grip" }) }), _jsx("span", { className: "min-w-0 flex-1 wrap-break-word font-medium", children: column.header }), _jsx(Switch, { "aria-label": `Show ${column.header}`, checked: layout.visibility[column.id], disabled: !canHide(column, layout), onCheckedChange: visible => change({ type: "visibility", id: column.id, visible }) })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-control", children: [_jsxs("label", { className: "flex min-w-0 flex-1 items-center gap-control text-label", children: ["Pin", _jsxs("span", { className: "relative min-w-0 flex-1", children: [_jsxs("select", { "aria-label": `Pin ${column.header}`, value: region, disabled: column.enablePinning === false, className: "sky-focus sky-border sky-disabled min-h-touch w-full min-w-0 appearance-none rounded-control border-input bg-background ps-control pe-field text-body text-foreground tablet:min-h-field tablet:text-label", onChange: event => change({ type: "pin", id: column.id, region: event.target.value }), children: [_jsx("option", { value: "center", children: "Unpinned" }), _jsx("option", { value: "start", children: "Start" }), _jsx("option", { value: "end", children: "End" })] }), _jsx(Icon, { name: "chevron-down", className: "pointer-events-none absolute end-control top-1/2 -translate-y-1/2 text-muted-foreground" })] })] }), _jsx(Button, { size: "icon", variant: "ghost", "aria-label": `Move ${column.header} up`, disabled: index === 0, onClick: () => change({ type: "move", id: column.id, target: group[index - 1] }), children: _jsx(Icon, { name: "arrow-up" }) }), _jsx(Button, { size: "icon", variant: "ghost", "aria-label": `Move ${column.header} down`, disabled: index === group.length - 1, onClick: () => change({ type: "move", id: column.id, target: group[index + 1] }), children: _jsx(Icon, { name: "arrow-down" }) })] })] });
|
|
55
|
+
}
|
|
56
|
+
export function DataTableColumnManager({ columns, layout, change, reset, disabled }) {
|
|
57
|
+
const dragging = useRef(false);
|
|
58
|
+
return _jsxs(Sheet, { children: [_jsx(SheetTrigger, { asChild: true, children: _jsx(Button, { variant: "outline", disabled: disabled, children: "Manage columns" }) }), _jsxs(SheetContent, { side: "left", className: "flex flex-col overflow-hidden", onEscapeKeyDown: event => { if (dragging.current)
|
|
59
|
+
event.preventDefault(); }, children: [_jsxs("div", { className: "grid shrink-0 gap-control", children: [_jsx(SheetTitle, { children: "Manage columns" }), _jsx(SheetDescription, { children: "Drag to reorder, toggle visibility, or choose a pin position." }), _jsxs("p", { className: "text-caption text-muted-foreground", children: [layout.order.filter(id => layout.visibility[id]).length, " of ", columns.length, " visible \u00B7 Changes apply immediately"] })] }), _jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto pe-control", children: [_jsx(ColumnDragScope, { columns: columns, layout: layout, change: change, dragging: dragging, children: _jsx("div", { className: "grid gap-panel", children: ["start", "center", "end"].map(region => _jsxs("section", { "aria-label": region === "center" ? "Unpinned columns" : `Pinned ${region} columns`, children: [_jsx("h3", { className: "mb-control text-caption font-semibold text-muted-foreground", children: region === "center" ? "Unpinned" : `Pinned ${region}` }), _jsx("ul", { className: "grid gap-control", children: columnsInRegion(layout, region).map(id => _jsx(ColumnManagerRow, { column: columns.find(column => column.id === id), layout: layout, change: change }, id)) }), !columnsInRegion(layout, region).length && _jsx("p", { className: "text-caption text-muted-foreground", children: "No columns in this group." })] }, region)) }) }), _jsx("p", { className: "mt-stack text-caption text-muted-foreground", children: "Start follows reading direction. Use the arrow buttons as an alternative to dragging." })] }), _jsxs(SheetFooter, { className: "shrink-0", children: [_jsx(Button, { variant: "outline", onClick: reset, children: "Reset columns" }), _jsx(SheetClose, { asChild: true, children: _jsx(Button, { children: "Done" }) })] })] })] });
|
|
60
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type RowData } from "@tanstack/react-table";
|
|
3
|
+
import type { DataTableColumnLayout } from "../lib/column-layout.js";
|
|
3
4
|
export type DataTableColumn<T> = {
|
|
4
5
|
id: string;
|
|
5
6
|
header: string;
|
|
6
7
|
cell: (row: T) => ReactNode;
|
|
8
|
+
enableHiding?: boolean;
|
|
9
|
+
enablePinning?: boolean;
|
|
7
10
|
};
|
|
8
11
|
export type DataTableProps<T extends RowData> = {
|
|
9
12
|
data: T[];
|
|
@@ -16,6 +19,11 @@ export type DataTableProps<T extends RowData> = {
|
|
|
16
19
|
searchLabel?: string;
|
|
17
20
|
loading?: boolean;
|
|
18
21
|
error?: string;
|
|
22
|
+
columnManagement?: boolean;
|
|
23
|
+
columnLayout?: DataTableColumnLayout;
|
|
24
|
+
defaultColumnLayout?: DataTableColumnLayout;
|
|
25
|
+
onColumnLayoutChange?: (layout: DataTableColumnLayout) => void;
|
|
26
|
+
columnLayoutStorageKey?: string;
|
|
19
27
|
};
|
|
20
28
|
/** Client pagination: pass the complete dataset. Filter before paginating. */
|
|
21
|
-
export declare function DataTable<T extends RowData>({ data, columns, getRowId, caption, initialPageSize, pageSizeOptions, searchText, searchLabel, loading, error }: DataTableProps<T>): import("react").JSX.Element;
|
|
29
|
+
export declare function DataTable<T extends RowData>({ data, columns, getRowId, caption, initialPageSize, pageSizeOptions, searchText, searchLabel, loading, error, columnManagement, columnLayout, defaultColumnLayout, onColumnLayoutChange, columnLayoutStorageKey }: DataTableProps<T>): import("react").JSX.Element;
|