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.
Files changed (101) hide show
  1. package/README.md +291 -4
  2. package/dist/advanced.css +89 -0
  3. package/dist/components/accordion.js +3 -2
  4. package/dist/components/advanced-forms.d.ts +40 -0
  5. package/dist/components/advanced-forms.js +66 -0
  6. package/dist/components/advanced-layout.d.ts +29 -0
  7. package/dist/components/advanced-layout.js +49 -0
  8. package/dist/components/ai-status.d.ts +29 -0
  9. package/dist/components/ai-status.js +19 -0
  10. package/dist/components/alert.d.ts +1 -1
  11. package/dist/components/alert.js +1 -0
  12. package/dist/components/animated-tooltip.d.ts +10 -0
  13. package/dist/components/animated-tooltip.js +17 -0
  14. package/dist/components/badge.d.ts +4 -2
  15. package/dist/components/badge.js +7 -4
  16. package/dist/components/breadcrumb.d.ts +1 -1
  17. package/dist/components/breadcrumb.js +2 -1
  18. package/dist/components/button-group.d.ts +5 -0
  19. package/dist/components/button-group.js +8 -0
  20. package/dist/components/button.d.ts +4 -4
  21. package/dist/components/button.js +8 -3
  22. package/dist/components/card.d.ts +6 -1
  23. package/dist/components/card.js +13 -2
  24. package/dist/components/code-block.d.ts +31 -0
  25. package/dist/components/code-block.js +49 -0
  26. package/dist/components/compare.d.ts +17 -0
  27. package/dist/components/compare.js +39 -0
  28. package/dist/components/data-table-columns.d.ts +24 -0
  29. package/dist/components/data-table-columns.js +60 -0
  30. package/dist/components/data-table.d.ts +9 -1
  31. package/dist/components/data-table.js +16 -6
  32. package/dist/components/dialog.d.ts +11 -2
  33. package/dist/components/dialog.js +13 -2
  34. package/dist/components/dropdown-menu.js +2 -2
  35. package/dist/components/feature-card.d.ts +9 -0
  36. package/dist/components/feature-card.js +6 -0
  37. package/dist/components/fields.d.ts +9 -2
  38. package/dist/components/fields.js +10 -5
  39. package/dist/components/globe-renderer.d.ts +7 -0
  40. package/dist/components/globe-renderer.js +32 -0
  41. package/dist/components/globe.d.ts +9 -0
  42. package/dist/components/globe.js +25 -0
  43. package/dist/components/icon.d.ts +26 -0
  44. package/dist/components/icon.js +26 -0
  45. package/dist/components/image-generation-loader.d.ts +15 -0
  46. package/dist/components/image-generation-loader.js +93 -0
  47. package/dist/components/interactive-card.d.ts +6 -0
  48. package/dist/components/interactive-card.js +18 -0
  49. package/dist/components/link-preview.d.ts +25 -0
  50. package/dist/components/link-preview.js +84 -0
  51. package/dist/components/loader.d.ts +18 -0
  52. package/dist/components/loader.js +17 -0
  53. package/dist/components/loading.js +1 -1
  54. package/dist/components/message.d.ts +8 -0
  55. package/dist/components/message.js +11 -0
  56. package/dist/components/motion.d.ts +32 -0
  57. package/dist/components/motion.js +63 -0
  58. package/dist/components/multi-step-loader.d.ts +16 -0
  59. package/dist/components/multi-step-loader.js +29 -0
  60. package/dist/components/navigation.d.ts +76 -0
  61. package/dist/components/navigation.js +99 -0
  62. package/dist/components/popover.js +1 -1
  63. package/dist/components/progress.js +1 -1
  64. package/dist/components/prompt-input.d.ts +17 -0
  65. package/dist/components/prompt-input.js +27 -0
  66. package/dist/components/select.js +4 -3
  67. package/dist/components/sheet.js +2 -1
  68. package/dist/components/stat-card.d.ts +10 -0
  69. package/dist/components/stat-card.js +6 -0
  70. package/dist/components/tabs.d.ts +3 -1
  71. package/dist/components/tabs.js +4 -4
  72. package/dist/components/text-effects.d.ts +48 -0
  73. package/dist/components/text-effects.js +105 -0
  74. package/dist/components/theme-controls.d.ts +2 -0
  75. package/dist/components/theme-controls.js +17 -0
  76. package/dist/components/theme-provider.d.ts +20 -0
  77. package/dist/components/theme-provider.js +50 -0
  78. package/dist/components/theme-script.d.ts +9 -0
  79. package/dist/components/theme-script.js +8 -0
  80. package/dist/components/timeline.d.ts +12 -0
  81. package/dist/components/timeline.js +11 -0
  82. package/dist/components/tooltip.js +1 -1
  83. package/dist/components/use-column-layout.d.ts +6 -0
  84. package/dist/components/use-column-layout.js +38 -0
  85. package/dist/components/use-column-pinning.d.ts +10 -0
  86. package/dist/components/use-column-pinning.js +50 -0
  87. package/dist/components/world-map.d.ts +17 -0
  88. package/dist/components/world-map.js +13 -0
  89. package/dist/data/land.d.ts +1 -0
  90. package/dist/data/land.js +2 -0
  91. package/dist/index.d.ts +33 -5
  92. package/dist/index.js +30 -3
  93. package/dist/lib/canvas-tokens.d.ts +5 -0
  94. package/dist/lib/canvas-tokens.js +34 -0
  95. package/dist/lib/column-layout.d.ts +36 -0
  96. package/dist/lib/column-layout.js +69 -0
  97. package/dist/lib/theme-settings.d.ts +22 -0
  98. package/dist/lib/theme-settings.js +36 -0
  99. package/dist/styles.css +56 -3
  100. package/dist/tokens.css +273 -153
  101. package/package.json +20 -3
@@ -1,25 +1,35 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useId, useMemo, useState } from "react";
4
- import { createPaginatedRowModel, rowPaginationFeature, tableFeatures, useTable } from "@tanstack/react-table";
4
+ import { createPaginatedRowModel, rowPaginationFeature, columnOrderingFeature, columnPinningFeature, columnVisibilityFeature, tableFeatures, useTable } from "@tanstack/react-table";
5
5
  import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "./table.js";
6
6
  import { Pagination } from "./pagination.js";
7
7
  import { Input, Label } from "./fields.js";
8
8
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
9
- const features = tableFeatures({ rowPaginationFeature, paginatedRowModel: createPaginatedRowModel() });
9
+ import { useColumnLayout } from "./use-column-layout.js";
10
+ import { useColumnPinning } from "./use-column-pinning.js";
11
+ import { ColumnDragScope, DataTableColumnManager, ManagedColumnHead } from "./data-table-columns.js";
12
+ const features = tableFeatures({ rowPaginationFeature, columnOrderingFeature, columnPinningFeature, columnVisibilityFeature, paginatedRowModel: createPaginatedRowModel() });
10
13
  /** Client pagination: pass the complete dataset. Filter before paginating. */
11
- export function DataTable({ data, columns, getRowId, caption, initialPageSize = 10, pageSizeOptions = [5, 10, 25, 50], searchText, searchLabel = "Search rows", loading = false, error }) {
14
+ export function DataTable({ data, columns, getRowId, caption, initialPageSize = 10, pageSizeOptions = [5, 10, 25, 50], searchText, searchLabel = "Search rows", loading = false, error, columnManagement = true, columnLayout, defaultColumnLayout, onColumnLayoutChange, columnLayoutStorageKey }) {
12
15
  const id = useId();
16
+ const { layout, change, reset } = useColumnLayout(columns, columnLayout, defaultColumnLayout, onColumnLayoutChange, columnLayoutStorageKey);
17
+ const pinning = useColumnPinning(layout);
13
18
  const [query, setQuery] = useState("");
14
19
  const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: Number.isInteger(initialPageSize) && initialPageSize > 0 ? initialPageSize : 10 });
15
20
  const filtered = useMemo(() => searchText ? data.filter(row => searchText(row).toLowerCase().includes(query.trim().toLowerCase())) : data, [data, query, searchText]);
16
21
  const pageCount = Math.max(1, Math.ceil(filtered.length / pagination.pageSize));
17
22
  const safePagination = { ...pagination, pageIndex: Math.min(pagination.pageIndex, pageCount - 1) };
18
- const definitions = useMemo(() => columns.map(column => ({ id: column.id, header: column.header, cell: ({ row }) => column.cell(row.original) })), [columns]);
19
- const table = useTable({ features, data: filtered, columns: definitions, getRowId, state: { pagination: safePagination }, onPaginationChange: setPagination, autoResetPageIndex: false });
23
+ const definitions = useMemo(() => columns.map(column => ({ id: column.id, header: column.header, enableHiding: column.enableHiding, enablePinning: column.enablePinning, cell: ({ row }) => column.cell(row.original) })), [columns]);
24
+ const table = useTable({ features, data: filtered, columns: definitions, getRowId, state: { pagination: safePagination, columnOrder: layout.order, columnVisibility: layout.visibility, columnPinning: layout.pinning }, onPaginationChange: setPagination, autoResetPageIndex: false });
20
25
  const options = [...new Set([...pageSizeOptions, pagination.pageSize])].filter(size => Number.isInteger(size) && size > 0).sort((a, b) => a - b);
21
26
  const unavailable = loading || !!error;
22
27
  const start = filtered.length ? safePagination.pageIndex * pagination.pageSize + 1 : 0;
23
28
  const end = Math.min((safePagination.pageIndex + 1) * pagination.pageSize, filtered.length);
24
- return _jsxs("div", { className: "grid min-w-0 gap-stack", "aria-busy": loading, children: [_jsxs("div", { className: "flex flex-col gap-stack tablet:flex-row tablet:items-end tablet:justify-between", children: [searchText && _jsxs("div", { className: "grid w-full gap-control tablet:max-w-preview-wide", children: [_jsx(Label, { htmlFor: `${id}-search`, children: searchLabel }), _jsx(Input, { id: `${id}-search`, value: query, disabled: unavailable, placeholder: "Filter results\u2026", onChange: event => { setQuery(event.target.value); setPagination(current => ({ ...current, pageIndex: 0 })); } })] }), _jsxs("div", { className: "grid gap-control", children: [_jsx(Label, { htmlFor: `${id}-size`, children: "Rows per page" }), _jsxs(Select, { value: String(pagination.pageSize), disabled: unavailable, onValueChange: value => setPagination({ pageIndex: 0, pageSize: Number(value) }), children: [_jsx(SelectTrigger, { id: `${id}-size`, className: "w-auto", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: options.map(size => _jsx(SelectItem, { value: String(size), children: size }, size)) })] })] })] }), _jsx("div", { className: "sky-border min-w-0 overflow-hidden rounded-surface border-border", children: _jsxs(Table, { children: [_jsx(TableCaption, { children: caption }), _jsx(TableHeader, { children: table.getHeaderGroups().map(group => _jsx(TableRow, { children: group.headers.map(header => _jsx(TableHead, { children: _jsx(table.FlexRender, { header: header }) }, header.id)) }, group.id)) }), _jsx(TableBody, { children: unavailable || !filtered.length ? _jsx(TableRow, { children: _jsx(TableCell, { colSpan: Math.max(1, columns.length), className: "p-panel text-center", children: _jsx("span", { role: error ? "alert" : "status", children: loading ? "Loading rows…" : error ?? "No matching rows." }) }) }) : table.getRowModel().rows.map(row => _jsx(TableRow, { children: row.getAllCells().map(cell => _jsx(TableCell, { children: _jsx(table.FlexRender, { cell: cell }) }, cell.id)) }, row.id)) })] }) }), !unavailable && _jsxs(_Fragment, { children: [_jsxs("p", { role: "status", className: "text-caption text-muted-foreground", children: ["Showing ", start, "\u2013", end, " of ", filtered.length, " rows"] }), _jsx(Pagination, { page: safePagination.pageIndex + 1, pageCount: pageCount, onPageChange: page => setPagination(current => ({ ...current, pageIndex: page - 1 })), label: `${caption} pagination` })] })] });
29
+ const content = _jsx("div", { className: "sky-border min-w-0 overflow-hidden rounded-surface border-border", children: _jsxs(Table, { ref: pinning.tableRef, className: "sky-managed-table", children: [_jsx(TableCaption, { children: caption }), _jsx(TableHeader, { children: table.getHeaderGroups().map(group => _jsx(TableRow, { children: group.headers.map(header => {
30
+ const column = columns.find(item => item.id === header.column.id);
31
+ const props = pinning.cellProps(column.id);
32
+ return columnManagement ? _jsx(ManagedColumnHead, { column: column, layout: layout, change: change, style: props.style, pinned: props["data-pinned"] }, header.id) : _jsx(TableHead, { className: "sky-table-cell", "data-column-id": column.id, ...props, children: _jsx(table.FlexRender, { header: header }) }, header.id);
33
+ }) }, group.id)) }), _jsx(TableBody, { children: unavailable || !filtered.length ? _jsx(TableRow, { children: _jsx(TableCell, { colSpan: Math.max(1, table.getVisibleLeafColumns().length), className: "p-panel text-center", children: _jsx("span", { role: error ? "alert" : "status", children: loading ? "Loading rows…" : error ?? "No matching rows." }) }) }) : table.getRowModel().rows.map(row => _jsx(TableRow, { children: row.getVisibleCells().map(cell => _jsx(TableCell, { className: "sky-table-cell", ...pinning.cellProps(cell.column.id), children: _jsx(table.FlexRender, { cell: cell }) }, cell.id)) }, row.id)) })] }) });
34
+ return _jsxs("div", { className: "grid min-w-0 gap-stack", "aria-busy": loading, children: [_jsxs("div", { className: "flex flex-col gap-stack tablet:flex-row tablet:flex-wrap tablet:items-end tablet:justify-between", children: [searchText && _jsxs("div", { className: "grid w-full gap-control tablet:max-w-preview-wide", children: [_jsx(Label, { htmlFor: `${id}-search`, children: searchLabel }), _jsx(Input, { id: `${id}-search`, value: query, disabled: unavailable, placeholder: "Filter results\u2026", onChange: event => { setQuery(event.target.value); setPagination(current => ({ ...current, pageIndex: 0 })); } })] }), _jsxs("div", { className: "grid shrink-0 gap-control", children: [_jsx(Label, { htmlFor: `${id}-size`, children: "Rows per page" }), _jsxs(Select, { value: String(pagination.pageSize), disabled: unavailable, onValueChange: value => setPagination({ pageIndex: 0, pageSize: Number(value) }), children: [_jsx(SelectTrigger, { id: `${id}-size`, className: "w-auto", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: options.map(size => _jsx(SelectItem, { value: String(size), children: size }, size)) })] })] }), columnManagement && _jsx(DataTableColumnManager, { columns: columns, layout: layout, change: change, reset: reset })] }), columnManagement ? _jsx(ColumnDragScope, { columns: columns, layout: layout, change: change, visibleOnly: true, children: content }) : content, pinning.suspended && _jsx("p", { className: "text-caption text-muted-foreground", children: "Pinned columns will stick when there is enough space. Scroll horizontally to view all columns." }), !unavailable && _jsxs(_Fragment, { children: [_jsxs("p", { role: "status", className: "text-caption text-muted-foreground", children: ["Showing ", start, "\u2013", end, " of ", filtered.length, " rows"] }), _jsx(Pagination, { page: safePagination.pageIndex + 1, pageCount: pageCount, onPageChange: page => setPagination(current => ({ ...current, pageIndex: page - 1 })), label: `${caption} pagination` })] })] });
25
35
  }
@@ -1,11 +1,20 @@
1
1
  import type { ComponentPropsWithRef } from "react";
2
+ import { type VariantProps } from "class-variance-authority";
2
3
  import * as Primitive from "@radix-ui/react-dialog";
3
4
  export declare const Dialog: import("react").FC<Primitive.DialogProps>;
4
5
  export declare const DialogTrigger: import("react").ForwardRefExoticComponent<Primitive.DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
5
6
  export declare const DialogClose: import("react").ForwardRefExoticComponent<Primitive.DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
6
- export declare function DialogContent({ children, className, closeLabel, ...props }: ComponentPropsWithRef<typeof Primitive.Content> & {
7
+ declare const dialogVariants: (props?: ({
8
+ variant?: "default" | "classic" | "modern" | null | undefined;
9
+ size?: "default" | "sm" | "lg" | null | undefined;
10
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
+ export type DialogContentProps = ComponentPropsWithRef<typeof Primitive.Content> & VariantProps<typeof dialogVariants> & {
7
12
  closeLabel?: string;
8
- }): import("react").JSX.Element;
13
+ showClose?: boolean;
14
+ };
15
+ export declare function DialogContent({ children, className, variant, size, closeLabel, showClose, ...props }: DialogContentProps): import("react").JSX.Element;
16
+ export declare function DialogHeader({ className, ...props }: ComponentPropsWithRef<"div">): import("react").JSX.Element;
9
17
  export declare function DialogTitle({ className, ...props }: ComponentPropsWithRef<typeof Primitive.Title>): import("react").JSX.Element;
10
18
  export declare function DialogDescription({ className, ...props }: ComponentPropsWithRef<typeof Primitive.Description>): import("react").JSX.Element;
11
19
  export declare function DialogFooter({ className, ...props }: ComponentPropsWithRef<"div">): import("react").JSX.Element;
20
+ export {};
@@ -1,13 +1,24 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cva } from "class-variance-authority";
3
4
  import * as Primitive from "@radix-ui/react-dialog";
4
5
  import { Button } from "./button.js";
6
+ import { Icon } from "./icon.js";
5
7
  import { cn } from "../lib/utils.js";
6
8
  export const Dialog = Primitive.Root;
7
9
  export const DialogTrigger = Primitive.Trigger;
8
10
  export const DialogClose = Primitive.Close;
9
- export function DialogContent({ children, className, closeLabel = "Close dialog", ...props }) {
10
- return _jsxs(Primitive.Portal, { children: [_jsx(Primitive.Overlay, { className: "sky-overlay fixed inset-0 bg-overlay" }), _jsxs(Primitive.Content, { className: cn("sky-modal sky-modal-fit sky-border fixed start-1/2 top-1/2 grid -translate-x-1/2 -translate-y-1/2 gap-stack overflow-y-auto rounded-modal border-border bg-popover p-panel text-popover-foreground shadow-floating tablet:max-w-dialog", className), ...props, children: [_jsx(Primitive.Close, { asChild: true, children: _jsx(Button, { variant: "ghost", className: "justify-self-end", "aria-label": closeLabel, children: closeLabel }) }), children] })] });
11
+ const dialogVariants = cva("sky-modal sky-modal-fit sky-border fixed left-1/2 top-1/2 grid -translate-x-1/2 -translate-y-1/2 gap-stack overflow-y-auto rounded-modal border-border bg-popover p-panel text-popover-foreground shadow-floating", {
12
+ variants: {
13
+ variant: { default: "", classic: "rounded-control border-input", modern: "rounded-modal shadow-raised" },
14
+ size: { default: "tablet:max-w-dialog", sm: "tablet:max-w-dialog-sm", lg: "tablet:max-w-dialog-lg" },
15
+ }, defaultVariants: { variant: "default", size: "default" },
16
+ });
17
+ export function DialogContent({ children, className, variant, size, closeLabel = "Close dialog", showClose = true, ...props }) {
18
+ return _jsxs(Primitive.Portal, { children: [_jsx(Primitive.Overlay, { className: "sky-overlay fixed inset-0 bg-overlay" }), _jsxs(Primitive.Content, { className: cn(dialogVariants({ variant, size }), className), ...props, children: [showClose && _jsx(Primitive.Close, { asChild: true, children: _jsxs(Button, { variant: "ghost", className: "justify-self-end", "aria-label": closeLabel, children: [_jsx(Icon, { name: "close" }), closeLabel] }) }), children] })] });
19
+ }
20
+ export function DialogHeader({ className, ...props }) {
21
+ return _jsx("div", { className: cn("grid gap-control min-w-0", className), ...props });
11
22
  }
12
23
  export function DialogTitle({ className, ...props }) {
13
24
  return _jsx(Primitive.Title, { className: cn("text-title font-semibold leading-title", className), ...props });
@@ -6,10 +6,10 @@ export const DropdownMenu = Primitive.Root;
6
6
  export const DropdownMenuTrigger = Primitive.Trigger;
7
7
  export const DropdownMenuGroup = Primitive.Group;
8
8
  export function DropdownMenuContent({ className, ...props }) {
9
- return _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { className: cn("sky-popover sky-border min-w-preview overflow-y-auto rounded-surface border-border bg-popover p-control text-popover-foreground shadow-floating", className), ...props }) });
9
+ return _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { className: cn("sky-enter sky-popover sky-border min-w-preview overflow-y-auto rounded-surface border-border bg-popover p-control text-popover-foreground shadow-floating", className), ...props }) });
10
10
  }
11
11
  export function DropdownMenuItem({ className, ...props }) {
12
- return _jsx(Primitive.Item, { className: cn("sky-disabled flex min-h-touch cursor-default items-center gap-control rounded-control px-inline py-control text-label outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none tablet:min-h-field", className), ...props });
12
+ return _jsx(Primitive.Item, { className: cn("sky-icon-slot sky-disabled flex min-h-touch cursor-default items-center gap-control rounded-control px-inline py-control text-label outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none tablet:min-h-field", className), ...props });
13
13
  }
14
14
  export function DropdownMenuLabel({ className, ...props }) {
15
15
  return _jsx(Primitive.Label, { className: cn("px-inline py-control text-caption font-semibold text-muted-foreground", className), ...props });
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from "react";
2
+ import { type CardProps } from "./card.js";
3
+ export type FeatureCardProps = Omit<CardProps, "title"> & {
4
+ title: ReactNode;
5
+ description?: ReactNode;
6
+ icon?: ReactNode;
7
+ action?: ReactNode;
8
+ };
9
+ export declare function FeatureCard({ title, description, icon, action, children, className, variant, ...props }: FeatureCardProps): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from "./card.js";
3
+ import { cn } from "../lib/utils.js";
4
+ export function FeatureCard({ title, description, icon, action, children, className, variant = "modern", ...props }) {
5
+ return _jsxs(Card, { variant: variant, className: cn("flex h-full flex-col", className), ...props, children: [_jsxs(CardHeader, { children: [icon && _jsx("div", { "aria-hidden": "true", className: "sky-icon-slot mb-control flex size-field items-center justify-center rounded-control bg-secondary text-primary", children: icon }), _jsx(CardTitle, { children: title }), description && _jsx(CardDescription, { children: description })] }), children && _jsx(CardContent, { className: "flex-1", children: children }), action && _jsx(CardFooter, { className: "mt-auto", children: action })] });
6
+ }
@@ -1,5 +1,12 @@
1
1
  import type { ComponentPropsWithRef } from "react";
2
- export declare function Input({ className, ...props }: ComponentPropsWithRef<"input">): import("react").JSX.Element;
3
- export declare function Textarea({ className, ...props }: ComponentPropsWithRef<"textarea">): import("react").JSX.Element;
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare const fieldVariants: (props?: ({
4
+ variant?: "default" | "classic" | "filled" | "gradient" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ export type InputProps = ComponentPropsWithRef<"input"> & VariantProps<typeof fieldVariants>;
7
+ export type TextareaProps = ComponentPropsWithRef<"textarea"> & VariantProps<typeof fieldVariants>;
8
+ export declare function Input({ className, variant, ...props }: InputProps): import("react").JSX.Element;
9
+ export declare function Textarea({ className, variant, ...props }: TextareaProps): import("react").JSX.Element;
4
10
  export declare function Label({ className, ...props }: ComponentPropsWithRef<"label">): import("react").JSX.Element;
5
11
  export declare function Checkbox({ className, ...props }: Omit<ComponentPropsWithRef<"input">, "type">): import("react").JSX.Element;
12
+ export {};
@@ -1,11 +1,16 @@
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
- const fieldClass = "w-full min-w-0 rounded-control sky-border border-input bg-background px-inline py-control text-body tablet:text-label sky-focus disabled:cursor-not-allowed sky-disabled aria-invalid:border-destructive";
4
- export function Input({ className, ...props }) {
5
- return _jsx("input", { className: cn(fieldClass, "h-field min-h-touch tablet:min-h-field", className), ...props });
4
+ const fieldClass = "sky-field w-full min-w-0 rounded-control sky-border border-input bg-background px-inline py-control text-body tablet:text-label sky-focus disabled:cursor-not-allowed sky-disabled aria-invalid:border-destructive";
5
+ const fieldVariants = cva(fieldClass, {
6
+ variants: { variant: { default: "", filled: "border-transparent bg-muted", classic: "bg-card shadow-raised", gradient: "sky-gradient-border" } },
7
+ defaultVariants: { variant: "default" },
8
+ });
9
+ export function Input({ className, variant, ...props }) {
10
+ return _jsx("input", { className: cn(fieldVariants({ variant }), "h-field min-h-touch tablet:min-h-field", className), ...props });
6
11
  }
7
- export function Textarea({ className, ...props }) {
8
- return _jsx("textarea", { className: cn(fieldClass, "min-h-textarea", className), ...props });
12
+ export function Textarea({ className, variant, ...props }) {
13
+ return _jsx("textarea", { className: cn(fieldVariants({ variant }), "min-h-textarea", className), ...props });
9
14
  }
10
15
  export function Label({ className, ...props }) {
11
16
  return _jsx("label", { className: cn("text-label font-medium", className), ...props });
@@ -0,0 +1,7 @@
1
+ import { type GeoConnection } from "./world-map.js";
2
+ export default function GlobeRenderer({ connections, variant, active, themeKey }: {
3
+ connections: readonly GeoConnection[];
4
+ variant: "arcs" | "points";
5
+ active: boolean;
6
+ themeKey: string;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useRef, useState } from "react";
4
+ import { Canvas, useFrame, useThree } from "@react-three/fiber";
5
+ import { OrbitControls } from "@react-three/drei";
6
+ import ThreeGlobe from "three-globe";
7
+ import { landRings } from "../data/land.js";
8
+ import { validPoint } from "./world-map.js";
9
+ import { resolveCanvasColor } from "../lib/canvas-tokens.js";
10
+ function Earth({ connections, variant, active, colors }) {
11
+ const globe = useMemo(() => new ThreeGlobe({ animateIn: false }), []);
12
+ const { invalidate } = useThree();
13
+ useEffect(() => {
14
+ const valid = connections.filter(item => validPoint(item.start) && validPoint(item.end));
15
+ globe.polygonsData(landRings.map(ring => ({ type: "Feature", geometry: { type: "Polygon", coordinates: [ring] } }))).polygonCapColor(() => colors[1]).polygonSideColor(() => colors[1]).polygonStrokeColor(() => colors[2]);
16
+ globe.globeMaterial().color.set(colors[0]);
17
+ globe.showAtmosphere(false).pointsData(valid.flatMap(item => [item.start, item.end])).pointLat("lat").pointLng("lng").pointColor(() => colors[2]).pointAltitude(.02).pointRadius(.7);
18
+ globe.arcsData(variant === "arcs" ? valid : []).arcStartLat(item => item.start.lat).arcStartLng(item => item.start.lng).arcEndLat(item => item.end.lat).arcEndLng(item => item.end.lng).arcColor(() => colors[2]).arcStroke(.4).arcDashLength(1).arcDashGap(0).arcsTransitionDuration(0).pointsTransitionDuration(0).polygonsTransitionDuration(0);
19
+ invalidate();
20
+ }, [globe, connections, variant, colors, invalidate]);
21
+ useFrame((_, delta) => { if (active)
22
+ globe.rotation.y += delta * .08; });
23
+ useEffect(() => () => { globe.pauseAnimation(); globe.traverse(object => { const mesh = object; mesh.geometry?.dispose(); if (mesh.material)
24
+ (Array.isArray(mesh.material) ? mesh.material : [mesh.material]).forEach((material) => material.dispose()); }); }, [globe]);
25
+ return _jsx("primitive", { object: globe });
26
+ }
27
+ export default function GlobeRenderer({ connections, variant, active, themeKey }) {
28
+ const ref = useRef(null), [colors, setColors] = useState();
29
+ useEffect(() => { if (ref.current)
30
+ setColors(["var(--card)", "var(--muted-foreground)", "var(--primary)"].map(color => resolveCanvasColor(ref.current, color))); }, [themeKey]);
31
+ return _jsx("div", { ref: ref, className: "h-chart w-full", role: "img", "aria-label": "Interactive globe", children: colors && _jsxs(Canvas, { dpr: [1, 1.5], frameloop: active ? "always" : "demand", camera: { position: [0, 0, 280], near: 1, far: 1000 }, children: [_jsx("ambientLight", { intensity: 2 }), _jsx("directionalLight", { position: [100, 100, 200], intensity: 2 }), _jsx(Earth, { connections: connections, variant: variant, active: active, colors: colors }), _jsx(OrbitControls, { enablePan: false, minDistance: 150, maxDistance: 450, enableDamping: false })] }) });
32
+ }
@@ -0,0 +1,9 @@
1
+ import { type GeoConnection } from "./world-map.js";
2
+ export type GlobeProps = {
3
+ connections?: readonly GeoConnection[];
4
+ variant?: "arcs" | "points";
5
+ autoRotate?: boolean;
6
+ label?: string;
7
+ className?: string;
8
+ };
9
+ export declare function Globe({ connections, variant, autoRotate, label, className }: GlobeProps): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Component, lazy, Suspense, useEffect, useState } from "react";
4
+ import { WorldMap } from "./world-map.js";
5
+ import { useAnimationActivity } from "./motion.js";
6
+ import { Button } from "./button.js";
7
+ const Renderer = lazy(() => import("./globe-renderer.js"));
8
+ class GlobeBoundary extends Component {
9
+ state = { failed: false };
10
+ static getDerivedStateFromError() { return { failed: true }; }
11
+ render() { return this.state.failed ? this.props.fallback : this.props.children; }
12
+ }
13
+ export function Globe({ connections = [], variant = "arcs", autoRotate = true, label = "Global connections", className }) {
14
+ const activity = useAnimationActivity(), [supported, setSupported] = useState(false), [paused, setPaused] = useState(false);
15
+ useEffect(() => { const canvas = document.createElement("canvas"); try {
16
+ const gl = canvas.getContext("webgl2");
17
+ setSupported(!!gl);
18
+ gl?.getExtension("WEBGL_lose_context")?.loseContext();
19
+ }
20
+ catch {
21
+ setSupported(false);
22
+ } }, []);
23
+ const fallback = _jsx(WorldMap, { connections: connections, label: label });
24
+ return _jsx("section", { ref: activity.ref, "aria-label": label, className: className, children: supported && activity.inView ? _jsxs(GlobeBoundary, { fallback: fallback, children: [_jsx(Suspense, { fallback: fallback, children: _jsx(Renderer, { connections: connections, variant: variant, active: activity.enabled && !paused && autoRotate, themeKey: activity.themeKey }) }), _jsx("p", { className: "text-caption text-muted-foreground", children: "Drag to rotate. Scroll to zoom." }), _jsx(Button, { variant: "ghost", size: "sm", onClick: () => setPaused(!paused), children: paused ? "Resume rotation" : "Pause rotation" }), _jsxs("details", { className: "text-caption", children: [_jsx("summary", { children: "Connection details" }), connections.map(item => _jsxs("p", { children: [item.start.label ?? `${item.start.lat}, ${item.start.lng}`, " to ", item.end.label ?? `${item.end.lat}, ${item.end.lng}`] }, item.id))] })] }) : fallback });
25
+ }
@@ -0,0 +1,26 @@
1
+ import type { ComponentPropsWithRef } from "react";
2
+ declare const paths: {
3
+ readonly menu: "M4 6h16M4 12h16M4 18h16";
4
+ readonly upload: "M12 16V3m-5 5 5-5 5 5M4 16v5h16v-5";
5
+ readonly play: "m8 4 12 8-12 8z";
6
+ readonly pause: "M8 4v16M16 4v16";
7
+ readonly reset: "M3 10a9 9 0 1 1 1 8M3 4v6h6";
8
+ readonly search: "M21 21l-5-5M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0";
9
+ readonly "arrow-right": "M5 12h14m-7-7 7 7-7 7";
10
+ readonly compare: "m8 8-4 4 4 4m8-8 4 4-4 4M12 3v18";
11
+ readonly "chevron-down": "m6 9 6 6 6-6";
12
+ readonly "chevron-up": "m6 15 6-6 6 6";
13
+ readonly "chevron-right": "m9 6 6 6-6 6";
14
+ readonly "arrow-up": "M12 19V5m-7 7 7-7 7 7";
15
+ readonly "arrow-down": "M12 5v14m-7-7 7 7 7-7";
16
+ readonly "arrow-left": "M19 12H5m7-7-7 7 7 7";
17
+ readonly check: "m5 12 4 4L19 6";
18
+ readonly close: "m6 6 12 12M6 18 18 6";
19
+ };
20
+ export type IconName = keyof typeof paths | "grip" | "more-horizontal";
21
+ export type IconProps = Omit<ComponentPropsWithRef<"svg">, "children" | "name"> & {
22
+ name: IconName;
23
+ };
24
+ /** Decorative by default. Label the enclosing control, or pass aria-label for a standalone image. */
25
+ export declare function Icon({ name, className, "aria-label": label, "aria-labelledby": labelledBy, ...props }: IconProps): import("react").JSX.Element;
26
+ export {};
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from "../lib/utils.js";
3
+ const paths = {
4
+ menu: "M4 6h16M4 12h16M4 18h16",
5
+ upload: "M12 16V3m-5 5 5-5 5 5M4 16v5h16v-5",
6
+ play: "m8 4 12 8-12 8z",
7
+ pause: "M8 4v16M16 4v16",
8
+ reset: "M3 10a9 9 0 1 1 1 8M3 4v6h6",
9
+ search: "M21 21l-5-5M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0",
10
+ "arrow-right": "M5 12h14m-7-7 7 7-7 7",
11
+ compare: "m8 8-4 4 4 4m8-8 4 4-4 4M12 3v18",
12
+ "chevron-down": "m6 9 6 6 6-6",
13
+ "chevron-up": "m6 15 6-6 6 6",
14
+ "chevron-right": "m9 6 6 6-6 6",
15
+ "arrow-up": "M12 19V5m-7 7 7-7 7 7",
16
+ "arrow-down": "M12 5v14m-7-7 7 7 7-7",
17
+ "arrow-left": "M19 12H5m7-7-7 7 7 7",
18
+ check: "m5 12 4 4L19 6",
19
+ close: "m6 6 12 12M6 18 18 6",
20
+ };
21
+ /** Decorative by default. Label the enclosing control, or pass aria-label for a standalone image. */
22
+ export function Icon({ name, className, "aria-label": label, "aria-labelledby": labelledBy, ...props }) {
23
+ return _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": label || labelledBy ? undefined : true, role: label || labelledBy ? "img" : undefined, "aria-label": label, "aria-labelledby": labelledBy, focusable: "false", className: cn("block size-icon shrink-0", className), ...props, children: name === "grip" ? [5, 12, 19].flatMap(y => [9, 15].map(x => _jsx("circle", { cx: x, cy: y, r: 1, fill: "currentColor", stroke: "none" }, `${x}-${y}`)))
24
+ : name === "more-horizontal" ? [5, 12, 19].map(x => _jsx("circle", { cx: x, cy: 12, r: 1, fill: "currentColor" }, x))
25
+ : _jsx("path", { d: paths[name] }) });
26
+ }
@@ -0,0 +1,15 @@
1
+ import { type MotionPreference } from "./motion.js";
2
+ export type ImageGenerationLoaderProps = {
3
+ loading?: boolean;
4
+ effect?: "shimmer" | "wave" | "scale-wave" | "none";
5
+ easing?: "linear" | "ease-in-out";
6
+ text?: string;
7
+ duration?: number;
8
+ cellSize?: number;
9
+ gap?: number;
10
+ bandHeight?: number;
11
+ colors?: readonly [string, string];
12
+ motion?: MotionPreference;
13
+ className?: string;
14
+ };
15
+ export declare function ImageGenerationLoader({ loading, effect, easing, text, duration, cellSize, gap, bandHeight, colors, motion, className }: ImageGenerationLoaderProps): import("react").JSX.Element | null;
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { useAnimationActivity } from "./motion.js";
5
+ import { canvas2D, resolveCanvasColor, tokenLength } from "../lib/canvas-tokens.js";
6
+ import { cn } from "../lib/utils.js";
7
+ export function ImageGenerationLoader({ loading = true, effect = "shimmer", easing = "ease-in-out", text = "Generating", duration = 4000, cellSize, gap, bandHeight, colors = ["var(--primary)", "var(--info)"], motion, className }) {
8
+ const activity = useAnimationActivity(motion);
9
+ const canvasRef = useRef(null);
10
+ const [available, setAvailable] = useState(true);
11
+ const [firstColor, secondColor] = colors;
12
+ useEffect(() => {
13
+ const node = activity.node, canvas = canvasRef.current;
14
+ if (!node || !canvas || !loading)
15
+ return;
16
+ const ctx = canvas2D(canvas);
17
+ if (!ctx) {
18
+ setAvailable(false);
19
+ return;
20
+ }
21
+ setAvailable(true);
22
+ const mask = document.createElement("canvas"), maskCtx = canvas2D(mask);
23
+ let width = 0, height = 0, frame = 0, start = 0, textPixels;
24
+ const a = resolveCanvasColor(node, firstColor), b = resolveCanvasColor(node, secondColor);
25
+ const cell = Math.max(1, cellSize && Number.isFinite(cellSize) ? cellSize : tokenLength(node, "--sky-loader-cell", 4));
26
+ const spacing = Math.max(0, gap !== undefined && Number.isFinite(gap) ? gap : tokenLength(node, "--sky-loader-gap", 2));
27
+ const band = Math.max(cell, bandHeight && Number.isFinite(bandHeight) ? bandHeight : tokenLength(node, "--sky-loader-band", 48));
28
+ const milliseconds = Number.isFinite(duration) && duration > 0 ? duration : 4000;
29
+ function draw(time) {
30
+ if (!ctx)
31
+ return;
32
+ if (!start)
33
+ start = time;
34
+ const raw = activity.enabled ? ((time - start) % milliseconds) / milliseconds : .5;
35
+ const progress = easing === "linear" ? raw : (1 - Math.cos(Math.PI * raw)) / 2;
36
+ const yBand = progress * (height + band) - band / 2;
37
+ ctx.clearRect(0, 0, width, height);
38
+ ctx.fillStyle = b;
39
+ ctx.globalAlpha = .12;
40
+ ctx.fillRect(0, 0, width, Math.max(0, yBand - band / 2));
41
+ ctx.globalAlpha = 1;
42
+ const stride = Math.max(cell + spacing, Math.sqrt(width * height / 6000));
43
+ for (let y = 0; y < height; y += stride)
44
+ for (let x = 0; x < width; x += stride) {
45
+ const distance = Math.abs(y - yBand) / band;
46
+ const alpha = Math.max(0, 1 - distance);
47
+ if (alpha <= 0)
48
+ continue;
49
+ const wave = Math.sin(x / stride * .45 + raw * Math.PI * 4);
50
+ const inText = textPixels && textPixels[(Math.floor(y) * Math.ceil(width) + Math.floor(x)) * 4 + 3] > 0;
51
+ ctx.fillStyle = inText ? b : a;
52
+ ctx.globalAlpha = inText ? 1 : alpha * (effect === "shimmer" ? .45 + .35 * Math.sin(x + y + raw * 12) : .55);
53
+ const size = cell * (effect === "scale-wave" ? 1 + alpha * (wave + 1) / 2 : 1);
54
+ const offset = effect === "wave" ? wave * stride * alpha : 0;
55
+ ctx.fillRect(x - (size - cell) / 2, y + offset, size, size);
56
+ }
57
+ ctx.globalAlpha = 1;
58
+ if (activity.enabled && effect !== "none")
59
+ frame = requestAnimationFrame(draw);
60
+ }
61
+ function resize() {
62
+ if (!node || !canvas || !ctx)
63
+ return;
64
+ cancelAnimationFrame(frame);
65
+ const rect = node.getBoundingClientRect();
66
+ width = Math.ceil(rect.width);
67
+ height = Math.ceil(rect.height);
68
+ if (!width || !height)
69
+ return;
70
+ const ratio = Math.min(window.devicePixelRatio || 1, 2, Math.sqrt(4000000 / (width * height)));
71
+ canvas.width = Math.ceil(width * ratio);
72
+ canvas.height = Math.ceil(height * ratio);
73
+ ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
74
+ mask.width = width;
75
+ mask.height = height;
76
+ if (maskCtx) {
77
+ maskCtx.font = `600 ${Math.min(width / Math.max(text.length * .65, 1), band * .65)}px ${getComputedStyle(node).fontFamily}`;
78
+ maskCtx.textAlign = "center";
79
+ maskCtx.textBaseline = "middle";
80
+ maskCtx.fillText(text.toUpperCase(), width / 2, height / 2);
81
+ textPixels = maskCtx.getImageData(0, 0, width, height).data;
82
+ }
83
+ draw(performance.now());
84
+ }
85
+ const observer = new ResizeObserver(resize);
86
+ observer.observe(node);
87
+ resize();
88
+ return () => { observer.disconnect(); cancelAnimationFrame(frame); };
89
+ }, [activity.node, activity.enabled, activity.themeKey, loading, effect, easing, text, duration, cellSize, gap, bandHeight, firstColor, secondColor]);
90
+ if (!loading)
91
+ return null;
92
+ return _jsxs("div", { ref: activity.ref, className: cn("pointer-events-none absolute inset-0 overflow-hidden", className), "aria-busy": "true", children: [_jsx("canvas", { ref: canvasRef, "aria-hidden": "true", className: "size-full" }), _jsx("span", { role: "status", className: cn("absolute inset-x-0 bottom-0 bg-card p-inline text-center text-label text-card-foreground", available && activity.enabled && effect !== "none" && "sr-only"), children: text })] });
93
+ }
@@ -0,0 +1,6 @@
1
+ import { type CardProps } from "./card.js";
2
+ export type InteractiveCardProps = CardProps & {
3
+ effect?: "lift" | "spotlight" | "none";
4
+ };
5
+ /** Decorative emphasis; put actual actions in semantic buttons or links inside the card. */
6
+ export declare function InteractiveCard({ effect, className, onPointerMove, ...props }: InteractiveCardProps): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Card } from "./card.js";
4
+ import { cn } from "../lib/utils.js";
5
+ /** Decorative emphasis; put actual actions in semantic buttons or links inside the card. */
6
+ export function InteractiveCard({ effect = "lift", className, onPointerMove, ...props }) {
7
+ return _jsx(Card, { "data-effect": effect, className: cn("sky-interactive-card relative", className), onPointerMove: event => {
8
+ onPointerMove?.(event);
9
+ const motion = document.documentElement.dataset.motion;
10
+ if (event.defaultPrevented || effect !== "spotlight" || event.pointerType === "touch" || motion === "none" || motion === "reduced" || window.matchMedia("(prefers-reduced-motion: reduce)").matches)
11
+ return;
12
+ const bounds = event.currentTarget.getBoundingClientRect();
13
+ if (!bounds.width || !bounds.height)
14
+ return;
15
+ event.currentTarget.style.setProperty("--sky-pointer-x", `${(event.clientX - bounds.left) / bounds.width * 100}%`);
16
+ event.currentTarget.style.setProperty("--sky-pointer-y", `${(event.clientY - bounds.top) / bounds.height * 100}%`);
17
+ }, ...props });
18
+ }
@@ -0,0 +1,25 @@
1
+ import { type ReactNode } from "react";
2
+ export type LinkPreviewData = {
3
+ title?: string;
4
+ description?: string;
5
+ image?: string;
6
+ };
7
+ export type PreviewResolver = (url: string, signal: AbortSignal) => Promise<LinkPreviewData>;
8
+ export type LinkPreviewProps = {
9
+ href: string;
10
+ children: ReactNode;
11
+ className?: string;
12
+ } & ({
13
+ provider?: "static";
14
+ preview: LinkPreviewData;
15
+ resolve?: never;
16
+ } | {
17
+ provider: "custom";
18
+ resolve: PreviewResolver;
19
+ preview?: never;
20
+ } | {
21
+ provider: "microlink";
22
+ preview?: never;
23
+ resolve?: never;
24
+ });
25
+ export declare function LinkPreview(props: LinkPreviewProps): import("react").JSX.Element;
@@ -0,0 +1,84 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
5
+ import { Button } from "./button.js";
6
+ import { Icon } from "./icon.js";
7
+ import { Skeleton } from "./loading.js";
8
+ const cache = new Map();
9
+ const resolverIds = new WeakMap();
10
+ let nextResolver = 0;
11
+ const pending = new Map();
12
+ async function microlink(url, signal) {
13
+ const response = await fetch(`https://api.microlink.io/?url=${encodeURIComponent(url)}&screenshot=true`, { signal });
14
+ if (!response.ok)
15
+ throw new Error("Preview unavailable");
16
+ const result = await response.json();
17
+ if (result.status !== "success")
18
+ throw new Error("Preview unavailable");
19
+ return { title: result.data?.title, description: result.data?.description, image: result.data?.screenshot?.url ?? result.data?.image?.url };
20
+ }
21
+ export function LinkPreview(props) {
22
+ const [open, setOpen] = useState(false), [data, setData] = useState(props.preview), [error, setError] = useState(false);
23
+ const hover = useRef(undefined);
24
+ const resolver = props.provider === "custom" ? props.resolve : microlink;
25
+ useEffect(() => () => clearTimeout(hover.current), []);
26
+ useEffect(() => {
27
+ setData(props.preview);
28
+ setError(false);
29
+ if (!open || !props.provider || props.provider === "static")
30
+ return;
31
+ let parsed;
32
+ try {
33
+ parsed = new URL(props.href);
34
+ if (!/^https?:$/.test(parsed.protocol))
35
+ throw new Error();
36
+ }
37
+ catch {
38
+ setError(true);
39
+ return;
40
+ }
41
+ if (!resolverIds.has(resolver))
42
+ resolverIds.set(resolver, ++nextResolver);
43
+ const key = `${resolverIds.get(resolver)}:${parsed.href}`;
44
+ const cached = cache.get(key);
45
+ if (cached && cached.expires > Date.now()) {
46
+ setData(cached.data);
47
+ return;
48
+ }
49
+ let entry = pending.get(key);
50
+ if (!entry) {
51
+ const controller = new AbortController();
52
+ const promise = Promise.resolve().then(() => resolver(parsed.href, controller.signal)).then(value => { if (!controller.signal.aborted) {
53
+ if (cache.size >= 100)
54
+ cache.delete(cache.keys().next().value);
55
+ cache.set(key, { data: value, expires: Date.now() + 300000 });
56
+ } return value; }).finally(() => { if (pending.get(key)?.controller === controller)
57
+ pending.delete(key); });
58
+ entry = { controller, promise, subscribers: 0 };
59
+ pending.set(key, entry);
60
+ }
61
+ entry.subscribers++;
62
+ let current = true;
63
+ const timeout = setTimeout(() => {
64
+ if (!current)
65
+ return;
66
+ current = false;
67
+ setError(true);
68
+ // Other subscribers own their own deadline and must not be cancelled here.
69
+ if (entry.subscribers === 1)
70
+ entry.controller.abort();
71
+ }, 15000);
72
+ entry.promise.then(value => { clearTimeout(timeout); if (current)
73
+ setData(value); }, () => { clearTimeout(timeout); if (current)
74
+ setError(true); });
75
+ return () => { current = false; clearTimeout(timeout); entry.subscribers--; if (!entry.subscribers) {
76
+ entry.controller.abort();
77
+ if (pending.get(key) === entry)
78
+ pending.delete(key);
79
+ } };
80
+ }, [open, props.href, props.preview, props.provider, resolver]);
81
+ const enter = () => { clearTimeout(hover.current); hover.current = setTimeout(() => setOpen(true), 200); };
82
+ const leave = () => { clearTimeout(hover.current); hover.current = setTimeout(() => setOpen(false), 250); };
83
+ return _jsx("span", { className: props.className, children: _jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsxs("span", { className: "inline-flex items-center gap-control", onMouseEnter: enter, onMouseLeave: leave, children: [_jsx("a", { href: props.href, className: "sky-link sky-focus text-primary underline", onFocus: enter, children: props.children }), _jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { size: "icon", variant: "ghost", "aria-label": `Preview ${props.href}`, children: _jsx(Icon, { name: "search" }) }) })] }), _jsxs(PopoverContent, { onOpenAutoFocus: event => event.preventDefault(), onMouseEnter: () => clearTimeout(hover.current), onMouseLeave: leave, "aria-label": "Link preview", children: [error ? _jsx("p", { role: "status", className: "text-label", children: "Preview unavailable. You can still open the link." }) : !data ? _jsx("div", { role: "status", "aria-label": "Loading preview", children: _jsx(Skeleton, { className: "h-preview" }) }) : _jsxs("div", { className: "grid gap-control", children: [data.image && _jsx("img", { src: data.image, alt: "Website preview", className: "max-h-preview w-full rounded-control object-cover", onError: event => { event.currentTarget.hidden = true; } }), _jsx("p", { className: "font-medium", children: data.title ?? props.href }), data.description && _jsx("p", { className: "text-label text-muted-foreground", children: data.description })] }), _jsx("a", { href: props.href, className: "sky-focus mt-stack inline-flex min-h-touch items-center text-label text-primary underline", children: "Open link" })] })] }) });
84
+ }
@@ -0,0 +1,18 @@
1
+ import type { ComponentPropsWithRef } from "react";
2
+ import { type MotionPreference } from "./motion.js";
3
+ export type LoaderProps = ComponentPropsWithRef<"div"> & {
4
+ variant?: "dots" | "sliding-dots" | "svg" | "glitch" | "shimmer";
5
+ size?: "sm" | "md" | "lg";
6
+ label?: string;
7
+ motion?: MotionPreference;
8
+ };
9
+ export declare function Loader({ variant, size, label, motion, className, ref: forwardedRef, ...props }: LoaderProps): import("react").JSX.Element;
10
+ export declare const LoaderOne: (props: Omit<LoaderProps, "variant">) => import("react").JSX.Element;
11
+ export declare const LoaderTwo: (props: Omit<LoaderProps, "variant">) => import("react").JSX.Element;
12
+ export declare const LoaderThree: (props: Omit<LoaderProps, "variant">) => import("react").JSX.Element;
13
+ export declare const LoaderFour: ({ text, ...props }: Omit<LoaderProps, "variant"> & {
14
+ text?: string;
15
+ }) => import("react").JSX.Element;
16
+ export declare const LoaderFive: ({ text, ...props }: Omit<LoaderProps, "variant"> & {
17
+ text?: string;
18
+ }) => import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useAnimationActivity } from "./motion.js";
4
+ import { cn } from "../lib/utils.js";
5
+ export function Loader({ variant = "dots", size = "md", label = "Loading", motion, className, ref: forwardedRef, ...props }) {
6
+ const activity = useAnimationActivity(motion);
7
+ return _jsxs("div", { ref: node => { activity.ref(node); if (typeof forwardedRef === "function")
8
+ return forwardedRef(node); if (forwardedRef)
9
+ forwardedRef.current = node; }, role: "status", "aria-label": label, "data-running": activity.enabled, "data-size": size, "data-variant": variant, className: cn("sky-loader inline-flex items-center justify-center gap-control text-primary", className), ...props, children: [_jsx("span", { className: "sr-only", children: label }), variant === "dots" || variant === "sliding-dots" ? _jsx("span", { "aria-hidden": "true", className: "inline-flex items-center gap-control", children: [0, 1, 2].map(index => _jsx("span", { className: "sky-loader-dot", style: { "--sky-index": index } }, index)) })
10
+ : variant === "svg" ? _jsx("svg", { "aria-hidden": "true", className: "sky-loader-symbol", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.5, children: _jsx("path", { className: "sky-loader-path", pathLength: 1, d: "m13 2-9 12h7l-1 8 10-13h-7z" }) })
11
+ : _jsx("span", { "aria-hidden": "true", className: cn("relative inline-block font-medium", variant === "glitch" ? "sky-loader-glitch" : "sky-loader-shimmer"), children: label })] });
12
+ }
13
+ export const LoaderOne = (props) => _jsx(Loader, { ...props, variant: "dots" });
14
+ export const LoaderTwo = (props) => _jsx(Loader, { ...props, variant: "sliding-dots" });
15
+ export const LoaderThree = (props) => _jsx(Loader, { ...props, variant: "svg" });
16
+ export const LoaderFour = ({ text, ...props }) => _jsx(Loader, { ...props, label: text ?? props.label, variant: "glitch" });
17
+ export const LoaderFive = ({ text, ...props }) => _jsx(Loader, { ...props, label: text ?? props.label, variant: "shimmer" });