skyloom-ui 0.1.0 → 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 +352 -11
- 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,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;
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
10
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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(
|
|
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;
|