@skylab-kulubu/skylcn-ui 0.1.0
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/LICENSE +21 -0
- package/README.md +100 -0
- package/dist/assets/skylab-mark.d.ts +5 -0
- package/dist/assets/skylab-mark.d.ts.map +1 -0
- package/dist/assets/skylab-mark.js +29 -0
- package/dist/assets/skylab-mark.js.map +1 -0
- package/dist/charts/chart-frame.d.ts +42 -0
- package/dist/charts/chart-frame.d.ts.map +1 -0
- package/dist/charts/chart-frame.js +33 -0
- package/dist/charts/chart-frame.js.map +1 -0
- package/dist/charts/charts.d.ts +84 -0
- package/dist/charts/charts.d.ts.map +1 -0
- package/dist/charts/charts.js +194 -0
- package/dist/charts/charts.js.map +1 -0
- package/dist/charts/index.d.ts +3 -0
- package/dist/charts/index.d.ts.map +1 -0
- package/dist/charts/index.js +3 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/components/accordion.d.ts +7 -0
- package/dist/components/accordion.d.ts.map +1 -0
- package/dist/components/accordion.js +17 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/app-shell.d.ts +96 -0
- package/dist/components/app-shell.d.ts.map +1 -0
- package/dist/components/app-shell.js +191 -0
- package/dist/components/app-shell.js.map +1 -0
- package/dist/components/avatar.d.ts +28 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/avatar.js +26 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +41 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +42 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/bar-list.d.ts +33 -0
- package/dist/components/bar-list.d.ts.map +1 -0
- package/dist/components/bar-list.js +31 -0
- package/dist/components/bar-list.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +16 -0
- package/dist/components/breadcrumbs.d.ts.map +1 -0
- package/dist/components/breadcrumbs.js +21 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/button.d.ts +30 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +51 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +44 -0
- package/dist/components/calendar.d.ts.map +1 -0
- package/dist/components/calendar.js +93 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +38 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +38 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/carousel.d.ts +42 -0
- package/dist/components/carousel.d.ts.map +1 -0
- package/dist/components/carousel.js +92 -0
- package/dist/components/carousel.js.map +1 -0
- package/dist/components/checkbox.d.ts +3 -0
- package/dist/components/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox.js +9 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/command.d.ts +31 -0
- package/dist/components/command.d.ts.map +1 -0
- package/dist/components/command.js +91 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/copy-button.d.ts +10 -0
- package/dist/components/copy-button.d.ts.map +1 -0
- package/dist/components/copy-button.js +23 -0
- package/dist/components/copy-button.js.map +1 -0
- package/dist/components/data-list.d.ts +70 -0
- package/dist/components/data-list.d.ts.map +1 -0
- package/dist/components/data-list.js +119 -0
- package/dist/components/data-list.js.map +1 -0
- package/dist/components/dialog.d.ts +41 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +49 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/display-extra.d.ts +91 -0
- package/dist/components/display-extra.d.ts.map +1 -0
- package/dist/components/display-extra.js +91 -0
- package/dist/components/display-extra.js.map +1 -0
- package/dist/components/drawer.d.ts +22 -0
- package/dist/components/drawer.d.ts.map +1 -0
- package/dist/components/drawer.js +50 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/feedback.d.ts +63 -0
- package/dist/components/feedback.d.ts.map +1 -0
- package/dist/components/feedback.js +59 -0
- package/dist/components/feedback.js.map +1 -0
- package/dist/components/field.d.ts +21 -0
- package/dist/components/field.d.ts.map +1 -0
- package/dist/components/field.js +38 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/form-extra.d.ts +58 -0
- package/dist/components/form-extra.d.ts.map +1 -0
- package/dist/components/form-extra.js +51 -0
- package/dist/components/form-extra.js.map +1 -0
- package/dist/components/icon-swap.d.ts +15 -0
- package/dist/components/icon-swap.d.ts.map +1 -0
- package/dist/components/icon-swap.js +13 -0
- package/dist/components/icon-swap.js.map +1 -0
- package/dist/components/list.d.ts +43 -0
- package/dist/components/list.d.ts.map +1 -0
- package/dist/components/list.js +30 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/menu.d.ts +41 -0
- package/dist/components/menu.d.ts.map +1 -0
- package/dist/components/menu.js +67 -0
- package/dist/components/menu.js.map +1 -0
- package/dist/components/month-calendar.d.ts +38 -0
- package/dist/components/month-calendar.d.ts.map +1 -0
- package/dist/components/month-calendar.js +64 -0
- package/dist/components/month-calendar.js.map +1 -0
- package/dist/components/motion.d.ts +43 -0
- package/dist/components/motion.d.ts.map +1 -0
- package/dist/components/motion.js +56 -0
- package/dist/components/motion.js.map +1 -0
- package/dist/components/navigation-menu.d.ts +28 -0
- package/dist/components/navigation-menu.d.ts.map +1 -0
- package/dist/components/navigation-menu.js +26 -0
- package/dist/components/navigation-menu.js.map +1 -0
- package/dist/components/page-header.d.ts +45 -0
- package/dist/components/page-header.d.ts.map +1 -0
- package/dist/components/page-header.js +37 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/pagination.d.ts +19 -0
- package/dist/components/pagination.d.ts.map +1 -0
- package/dist/components/pagination.js +70 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.d.ts +10 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +15 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/preview-card.d.ts +11 -0
- package/dist/components/preview-card.d.ts.map +1 -0
- package/dist/components/preview-card.js +18 -0
- package/dist/components/preview-card.js.map +1 -0
- package/dist/components/proportion-bar.d.ts +16 -0
- package/dist/components/proportion-bar.d.ts.map +1 -0
- package/dist/components/proportion-bar.js +20 -0
- package/dist/components/proportion-bar.js.map +1 -0
- package/dist/components/radio-group.d.ts +11 -0
- package/dist/components/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group.js +13 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/reveal.d.ts +19 -0
- package/dist/components/reveal.d.ts.map +1 -0
- package/dist/components/reveal.js +25 -0
- package/dist/components/reveal.js.map +1 -0
- package/dist/components/segmented-control.d.ts +16 -0
- package/dist/components/segmented-control.d.ts.map +1 -0
- package/dist/components/segmented-control.js +21 -0
- package/dist/components/segmented-control.js.map +1 -0
- package/dist/components/select.d.ts +25 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +33 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/side-nav.d.ts +33 -0
- package/dist/components/side-nav.d.ts.map +1 -0
- package/dist/components/side-nav.js +52 -0
- package/dist/components/side-nav.js.map +1 -0
- package/dist/components/skeleton.d.ts +4 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton.js +7 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/skylab-loader.d.ts +10 -0
- package/dist/components/skylab-loader.d.ts.map +1 -0
- package/dist/components/skylab-loader.js +12 -0
- package/dist/components/skylab-loader.js.map +1 -0
- package/dist/components/sparkline.d.ts +12 -0
- package/dist/components/sparkline.d.ts.map +1 -0
- package/dist/components/sparkline.js +26 -0
- package/dist/components/sparkline.js.map +1 -0
- package/dist/components/state-card.d.ts +27 -0
- package/dist/components/state-card.d.ts.map +1 -0
- package/dist/components/state-card.js +17 -0
- package/dist/components/state-card.js.map +1 -0
- package/dist/components/switch.d.ts +15 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +12 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/tabs.d.ts +8 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +17 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/toast.d.ts +17 -0
- package/dist/components/toast.d.ts.map +1 -0
- package/dist/components/toast.js +30 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/tooltip.d.ts +15 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +13 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/tree.d.ts +26 -0
- package/dist/components/tree.d.ts.map +1 -0
- package/dist/components/tree.js +92 -0
- package/dist/components/tree.js.map +1 -0
- package/dist/components/trend-badge.d.ts +13 -0
- package/dist/components/trend-badge.d.ts.map +1 -0
- package/dist/components/trend-badge.js +22 -0
- package/dist/components/trend-badge.js.map +1 -0
- package/dist/data-table/data-table.d.ts +59 -0
- package/dist/data-table/data-table.d.ts.map +1 -0
- package/dist/data-table/data-table.js +207 -0
- package/dist/data-table/data-table.js.map +1 -0
- package/dist/data-table/index.d.ts +2 -0
- package/dist/data-table/index.d.ts.map +1 -0
- package/dist/data-table/index.js +2 -0
- package/dist/data-table/index.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +2 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/motion-preference.d.ts +11 -0
- package/dist/lib/motion-preference.d.ts.map +1 -0
- package/dist/lib/motion-preference.js +42 -0
- package/dist/lib/motion-preference.js.map +1 -0
- package/dist/lib/motion-tokens.d.ts +55 -0
- package/dist/lib/motion-tokens.d.ts.map +1 -0
- package/dist/lib/motion-tokens.js +26 -0
- package/dist/lib/motion-tokens.js.map +1 -0
- package/dist/lib/motion.d.ts +3 -0
- package/dist/lib/motion.d.ts.map +1 -0
- package/dist/lib/motion.js +19 -0
- package/dist/lib/motion.js.map +1 -0
- package/dist/lib/provider.d.ts +160 -0
- package/dist/lib/provider.d.ts.map +1 -0
- package/dist/lib/provider.js +156 -0
- package/dist/lib/provider.js.map +1 -0
- package/dist/lib/theme-script.d.ts +15 -0
- package/dist/lib/theme-script.d.ts.map +1 -0
- package/dist/lib/theme-script.js +15 -0
- package/dist/lib/theme-script.js.map +1 -0
- package/dist/lib/theme.d.ts +13 -0
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/lib/theme.js +78 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/lib/use-pending-indicator.d.ts +7 -0
- package/dist/lib/use-pending-indicator.d.ts.map +1 -0
- package/dist/lib/use-pending-indicator.js +27 -0
- package/dist/lib/use-pending-indicator.js.map +1 -0
- package/dist/lib/use-reduced-motion.d.ts +7 -0
- package/dist/lib/use-reduced-motion.d.ts.map +1 -0
- package/dist/lib/use-reduced-motion.js +28 -0
- package/dist/lib/use-reduced-motion.js.map +1 -0
- package/dist/styles/theme.css +368 -0
- package/dist/styles/tokens.css +248 -0
- package/package.json +90 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIxE,wBAAgB,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,+BA6B7E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';
|
|
4
|
+
import { Check, Minus } from 'lucide-react';
|
|
5
|
+
import { cn } from '../lib/cn.js';
|
|
6
|
+
export function Checkbox({ className, ...props }) {
|
|
7
|
+
return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('relative grid size-4 shrink-0 cursor-pointer place-content-center rounded-sm border border-border-strong bg-input-background outline-hidden after:absolute after:-inset-3', 'transition-[background-color,border-color] duration-(--motion-duration-fast) ease-enter', 'focus-visible:ring-2 focus-visible:ring-ring', 'data-indeterminate:border-skylab-800 data-indeterminate:bg-skylab-800 data-checked:border-skylab-800 data-checked:bg-skylab-800', 'data-disabled:cursor-not-allowed data-disabled:opacity-50', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { keepMounted: true, className: "text-white transition-transform duration-(--motion-duration-fast) ease-enter data-unchecked:scale-0", render: (indicatorProps, state) => (_jsx("span", { ...indicatorProps, children: state.indeterminate ? (_jsx(Minus, { className: "size-3", strokeWidth: 3 })) : (_jsx(Check, { className: "size-3", strokeWidth: 3 })) })) }) }));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,MAAM,UAAU,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAgC;IAC5E,OAAO,CACL,KAAC,iBAAiB,CAAC,IAAI,iBACX,UAAU,EACpB,SAAS,EAAE,EAAE,CACX,2KAA2K,EAC3K,yFAAyF,EACzF,8CAA8C,EAC9C,iIAAiI,EACjI,2DAA2D,EAC3D,SAAS,CACV,KACG,KAAK,YAET,KAAC,iBAAiB,CAAC,SAAS,IAC1B,WAAW,QACX,SAAS,EAAC,qGAAqG,EAC/G,MAAM,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,EAAE,CAAC,CACjC,kBAAU,cAAc,YACrB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CACrB,KAAC,KAAK,IAAC,SAAS,EAAC,QAAQ,EAAC,WAAW,EAAE,CAAC,GAAI,CAC7C,CAAC,CAAC,CAAC,CACF,KAAC,KAAK,IAAC,SAAS,EAAC,QAAQ,EAAC,WAAW,EAAE,CAAC,GAAI,CAC7C,GACI,CACR,GACD,GACqB,CAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type LucideIcon } from 'lucide-react';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
export type CommandItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
group?: string;
|
|
7
|
+
icon?: LucideIcon;
|
|
8
|
+
/** Extra words that should find it, such as synonyms. */
|
|
9
|
+
keywords?: string;
|
|
10
|
+
shortcut?: ReactNode;
|
|
11
|
+
/** A page to open; `onSelect` runs instead when given. */
|
|
12
|
+
href?: string;
|
|
13
|
+
onSelect?: () => void;
|
|
14
|
+
};
|
|
15
|
+
export type CommandPaletteProps = {
|
|
16
|
+
items: readonly CommandItem[];
|
|
17
|
+
open: boolean;
|
|
18
|
+
onOpenChange: (open: boolean) => void;
|
|
19
|
+
/** Opens an href; defaults to a full page load. Pass the router's push in apps. */
|
|
20
|
+
navigate?: (href: string) => void;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Opens the palette with Ctrl/⌘+K from anywhere, except while typing in an editor. */
|
|
24
|
+
export declare function useCommandShortcut(onOpen: () => void): void;
|
|
25
|
+
/**
|
|
26
|
+
* A search box over every page and action of an app, opened with Ctrl/⌘+K.
|
|
27
|
+
* Typing narrows the list (accents and dotless i ignored), arrows move,
|
|
28
|
+
* Enter opens, Esc closes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function CommandPalette({ items, open, onOpenChange, navigate, placeholder, }: CommandPaletteProps): import("react").JSX.Element;
|
|
31
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/components/command.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAA+C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKpF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,mFAAmF;IACnF,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAKF,uFAAuF;AACvF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,IAAI,QAWpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,WAAW,GACZ,EAAE,mBAAmB,+BA6JrB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
4
|
+
import { CornerDownLeft, Search } from 'lucide-react';
|
|
5
|
+
import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import { useSkylcn } from '../lib/provider.js';
|
|
8
|
+
import { Kbd } from './feedback.js';
|
|
9
|
+
const fold = (text) => text.toLocaleLowerCase('tr-TR').normalize('NFD').replace(/[̀-ͯ]/g, '').replace(/ı/g, 'i');
|
|
10
|
+
/** Opens the palette with Ctrl/⌘+K from anywhere, except while typing in an editor. */
|
|
11
|
+
export function useCommandShortcut(onOpen) {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const onKey = (event) => {
|
|
14
|
+
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'k') {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
onOpen();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
window.addEventListener('keydown', onKey);
|
|
20
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
21
|
+
}, [onOpen]);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A search box over every page and action of an app, opened with Ctrl/⌘+K.
|
|
25
|
+
* Typing narrows the list (accents and dotless i ignored), arrows move,
|
|
26
|
+
* Enter opens, Esc closes.
|
|
27
|
+
*/
|
|
28
|
+
export function CommandPalette({ items, open, onOpenChange, navigate, placeholder, }) {
|
|
29
|
+
const { messages } = useSkylcn();
|
|
30
|
+
const [query, setQuery] = useState('');
|
|
31
|
+
const [active, setActive] = useState(0);
|
|
32
|
+
const listId = useId();
|
|
33
|
+
const listRef = useRef(null);
|
|
34
|
+
const results = useMemo(() => {
|
|
35
|
+
const q = fold(query.trim());
|
|
36
|
+
return q
|
|
37
|
+
? items.filter((item) => fold(`${item.label} ${item.group ?? ''} ${item.keywords ?? ''}`).includes(q))
|
|
38
|
+
: items;
|
|
39
|
+
}, [items, query]);
|
|
40
|
+
const groups = useMemo(() => {
|
|
41
|
+
const map = new Map();
|
|
42
|
+
for (const item of results) {
|
|
43
|
+
const key = item.group ?? '';
|
|
44
|
+
map.set(key, [...(map.get(key) ?? []), item]);
|
|
45
|
+
}
|
|
46
|
+
return [...map.entries()];
|
|
47
|
+
}, [results]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
listRef.current
|
|
50
|
+
?.querySelector(`[data-index="${active}"]`)
|
|
51
|
+
?.scrollIntoView({ block: 'nearest' });
|
|
52
|
+
}, [active]);
|
|
53
|
+
const run = (item) => {
|
|
54
|
+
onOpenChange(false);
|
|
55
|
+
if (item.onSelect)
|
|
56
|
+
item.onSelect();
|
|
57
|
+
else if (item.href)
|
|
58
|
+
(navigate ?? ((href) => window.location.assign(href)))(item.href);
|
|
59
|
+
};
|
|
60
|
+
let index = -1;
|
|
61
|
+
return (_jsx(DialogPrimitive.Root, { open: open, onOpenChange: (next) => {
|
|
62
|
+
onOpenChange(next);
|
|
63
|
+
if (!next) {
|
|
64
|
+
setQuery('');
|
|
65
|
+
setActive(0);
|
|
66
|
+
}
|
|
67
|
+
}, children: _jsxs(DialogPrimitive.Portal, { children: [_jsx(DialogPrimitive.Backdrop, { className: "fixed inset-0 z-50 bg-black/50 transition-opacity duration-(--motion-duration-base) data-ending-style:opacity-0 data-starting-style:opacity-0" }), _jsxs(DialogPrimitive.Popup, { "aria-label": messages.commandPalette, className: cn('fixed top-[12vh] left-1/2 z-50 flex max-h-[70vh] w-[calc(100vw-2rem)] max-w-xl -translate-x-1/2 flex-col overflow-hidden rounded-xl border border-border bg-popover text-foreground shadow-overlay outline-hidden', 'transition-[opacity,scale] duration-(--motion-duration-base) ease-enter data-ending-style:scale-(--motion-scale-from) data-ending-style:opacity-0 data-starting-style:scale-(--motion-scale-from) data-starting-style:opacity-0'), children: [_jsxs("div", { className: "flex items-center gap-2 border-b border-border px-3", children: [_jsx(Search, { className: "size-4 shrink-0 text-subtle-foreground", "aria-hidden": true }), _jsx("input", { autoFocus: true, role: "combobox", "aria-expanded": true, "aria-controls": listId, "aria-activedescendant": results.length ? `${listId}-${active}` : undefined, "aria-label": placeholder ?? messages.commandPalette, value: query, placeholder: placeholder ?? messages.searchEverything, onChange: (event) => {
|
|
68
|
+
setQuery(event.target.value);
|
|
69
|
+
setActive(0);
|
|
70
|
+
}, onKeyDown: (event) => {
|
|
71
|
+
if (event.key === 'ArrowDown') {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
setActive((i) => Math.min(i + 1, results.length - 1));
|
|
74
|
+
}
|
|
75
|
+
else if (event.key === 'ArrowUp') {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
setActive((i) => Math.max(i - 1, 0));
|
|
78
|
+
}
|
|
79
|
+
else if (event.key === 'Enter' && results[active]) {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
run(results[active]);
|
|
82
|
+
}
|
|
83
|
+
}, className: "h-12 min-w-0 flex-1 bg-transparent text-sm outline-hidden placeholder:text-subtle-foreground pointer-coarse:text-base" }), _jsx(Kbd, { children: "Esc" })] }), _jsx("div", { ref: listRef, id: listId, role: "listbox", className: "scrollbar min-h-0 flex-1 overflow-y-auto p-1.5", children: results.length === 0 ? (_jsx("p", { className: "px-3 py-8 text-center text-xs text-muted-foreground", children: messages.noResults })) : (groups.map(([group, groupItems]) => (_jsxs("div", { role: "group", "aria-label": group || undefined, className: "pb-1", children: [group ? (_jsx("p", { className: "px-2 pt-2 pb-1 text-3xs font-medium tracking-label text-subtle-foreground uppercase", children: group })) : null, groupItems.map((item) => {
|
|
84
|
+
index += 1;
|
|
85
|
+
const i = index;
|
|
86
|
+
const Icon = item.icon;
|
|
87
|
+
const on = i === active;
|
|
88
|
+
return (_jsxs("div", { id: `${listId}-${i}`, role: "option", "aria-selected": on, "data-index": i, onPointerMove: () => setActive(i), onClick: () => run(item), className: cn('flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-2 text-sm pointer-coarse:py-2.5', on ? 'bg-accent text-foreground-strong' : 'text-secondary-foreground'), children: [Icon ? (_jsx(Icon, { className: "size-4 shrink-0 text-subtle-foreground", "aria-hidden": true })) : null, _jsx("span", { className: "min-w-0 flex-1 truncate", children: item.label }), item.shortcut ? (_jsx("span", { className: "shrink-0 text-3xs text-subtle-foreground", children: item.shortcut })) : null, on ? (_jsx(CornerDownLeft, { className: "size-3.5 shrink-0 text-subtle-foreground", "aria-hidden": true })) : null] }, item.id));
|
|
89
|
+
})] }, group || 'none')))) })] })] }) }));
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/components/command.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAmB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAwBpC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAC5B,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAE5F,uFAAuF;AACvF,MAAM,UAAU,kBAAkB,CAAC,MAAkB;IACnD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,CAAC,KAAoB,EAAE,EAAE;YACrC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,GAAG,CA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BACL,CAAC,EACb,aAAa,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EACxB,SAAS,EAAE,EAAE,CACX,6FAA6F,EAC7F,EAAE,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,2BAA2B,CACtE,aAEA,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,IAAI,IAAC,SAAS,EAAC,wCAAwC,wBAAe,CACxE,CAAC,CAAC,CAAC,IAAI,EACR,eAAM,SAAS,EAAC,yBAAyB,YAAE,IAAI,CAAC,KAAK,GAAQ,EAC5D,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CACf,eAAM,SAAS,EAAC,0CAA0C,YACvD,IAAI,CAAC,QAAQ,GACT,CACR,CAAC,CAAC,CAAC,IAAI,EACP,EAAE,CAAC,CAAC,CAAC,CACJ,KAAC,cAAc,IACb,SAAS,EAAC,0CAA0C,wBAEpD,CACH,CAAC,CAAC,CAAC,IAAI,KA1BH,IAAI,CAAC,EAAE,CA2BR,CACP,CAAC;oCACJ,CAAC,CAAC,KA9CG,KAAK,IAAI,MAAM,CA+ChB,CACP,CAAC,CACH,GACG,IACgB,IACD,GACJ,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ButtonProps } from './button.js';
|
|
2
|
+
export type CopyButtonProps = Omit<ButtonProps, 'children' | 'onClick'> & {
|
|
3
|
+
/** The text put on the clipboard. */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Names the button; "Kopyala" by default. */
|
|
6
|
+
label?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Copies a value, then turns its icon into a tick for a moment and says so to screen readers. */
|
|
9
|
+
export declare function CopyButton({ value, label, variant, size, ...props }: CopyButtonProps): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=copy-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-button.d.ts","sourceRoot":"","sources":["../../src/components/copy-button.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG;IACxE,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,OAAiB,EACjB,IAAgB,EAChB,GAAG,KAAK,EACT,EAAE,eAAe,+BA8BjB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check, Copy } from 'lucide-react';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { useSkylcn } from '../lib/provider.js';
|
|
6
|
+
import { Button } from './button.js';
|
|
7
|
+
import { IconSwap } from './icon-swap.js';
|
|
8
|
+
/** Copies a value, then turns its icon into a tick for a moment and says so to screen readers. */
|
|
9
|
+
export function CopyButton({ value, label, variant = 'ghost', size = 'icon-sm', ...props }) {
|
|
10
|
+
const { messages } = useSkylcn();
|
|
11
|
+
const [copied, setCopied] = useState(false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!copied)
|
|
14
|
+
return;
|
|
15
|
+
const timer = setTimeout(() => setCopied(false), 1600);
|
|
16
|
+
return () => clearTimeout(timer);
|
|
17
|
+
}, [copied]);
|
|
18
|
+
const name = copied ? messages.copied : (label ?? messages.copy);
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: variant, size: size, "aria-label": name, title: name, onClick: () => {
|
|
20
|
+
void navigator.clipboard?.writeText(value).then(() => setCopied(true));
|
|
21
|
+
}, ...props, children: _jsx(IconSwap, { swapped: copied, icon: Copy, swappedIcon: Check, className: "size-3.5" }) }), _jsx("span", { "aria-live": "polite", className: "sr-only", children: copied ? messages.copied : '' })] }));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=copy-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-button.js","sourceRoot":"","sources":["../../src/components/copy-button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAS1C,kGAAkG;AAClG,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,OAAO,GAAG,OAAO,EACjB,IAAI,GAAG,SAAS,EAChB,GAAG,KAAK,EACQ;IAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC;IACjC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjE,OAAO,CACL,8BACE,KAAC,MAAM,IACL,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,gBACE,IAAI,EAChB,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,GAAG,EAAE;oBACZ,KAAK,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;gBACzE,CAAC,KACG,KAAK,YAET,KAAC,QAAQ,IAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAC,UAAU,GAAG,GAC3E,EACT,4BAAgB,QAAQ,EAAC,SAAS,EAAC,SAAS,YACzC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GACzB,IACN,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { type StateCardProps } from './state-card.js';
|
|
3
|
+
type Breakpoint = 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
declare const JUSTIFY: {
|
|
5
|
+
readonly start: "justify-start";
|
|
6
|
+
readonly center: "justify-center";
|
|
7
|
+
readonly end: "justify-end";
|
|
8
|
+
};
|
|
9
|
+
export type DataListColumn = {
|
|
10
|
+
id: string;
|
|
11
|
+
/** A CSS grid track, such as `1.5rem`, `minmax(0,1fr)` or `7rem`. */
|
|
12
|
+
width: string;
|
|
13
|
+
/** The column appears from this breakpoint up. */
|
|
14
|
+
from?: Breakpoint;
|
|
15
|
+
align?: keyof typeof JUSTIFY;
|
|
16
|
+
};
|
|
17
|
+
export type DataListSort = {
|
|
18
|
+
field: string;
|
|
19
|
+
direction: 'asc' | 'desc';
|
|
20
|
+
};
|
|
21
|
+
export type DataListProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
22
|
+
columns: readonly DataListColumn[];
|
|
23
|
+
/** The current sort, read by sortable column headers. */
|
|
24
|
+
sort?: DataListSort;
|
|
25
|
+
/** Called with a column id when its header is pressed. */
|
|
26
|
+
onSortChange?: (field: string) => void;
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
};
|
|
29
|
+
/** A table-like list whose columns collapse by breakpoint, with sortable headers and linkable rows. */
|
|
30
|
+
export declare function DataList({ columns, sort, onSortChange, className, style, children, ...props }: DataListProps): import("react").JSX.Element;
|
|
31
|
+
export declare function DataListHeader({ className, children, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
32
|
+
export type DataListColumnHeaderProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
33
|
+
column: string;
|
|
34
|
+
/** Pressing the header asks the list to sort by this column. */
|
|
35
|
+
sortable?: boolean;
|
|
36
|
+
/** Names a column whose header shows no text, such as a status dot or row actions. */
|
|
37
|
+
label?: string;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
};
|
|
40
|
+
export declare function DataListColumnHeader({ column, sortable, label, className, children, ...props }: DataListColumnHeaderProps): import("react").JSX.Element;
|
|
41
|
+
/** Rows fade in one after another when they first arrive; later sorts, searches and pages swap in place. */
|
|
42
|
+
export declare function DataListBody({ className, children, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
43
|
+
type MotionOwned = 'onSelect' | 'onAnimationStart' | 'onDrag' | 'onDragStart' | 'onDragEnd';
|
|
44
|
+
export type DataListRowProps = Omit<ComponentProps<'div'>, MotionOwned> & {
|
|
45
|
+
/** Makes the whole row a link. Interactive cells stay pressable on their own. */
|
|
46
|
+
href?: string;
|
|
47
|
+
/** Makes the whole row a button. */
|
|
48
|
+
onSelect?: () => void;
|
|
49
|
+
/** The accessible name of the row link or button. */
|
|
50
|
+
label?: string;
|
|
51
|
+
selected?: boolean;
|
|
52
|
+
/** Position in the list; staggers the first rows as the list first appears. */
|
|
53
|
+
index?: number;
|
|
54
|
+
};
|
|
55
|
+
export declare function DataListRow({ href, onSelect, label, selected, index, className, style, children, ...props }: DataListRowProps): import("react").JSX.Element;
|
|
56
|
+
export type DataListCellProps = ComponentProps<'div'> & {
|
|
57
|
+
column: string;
|
|
58
|
+
/** Lifts the cell above the row link so its own buttons and links can be pressed. */
|
|
59
|
+
interactive?: boolean;
|
|
60
|
+
};
|
|
61
|
+
export declare function DataListCell({ column, interactive, className, children, ...props }: DataListCellProps): import("react").JSX.Element;
|
|
62
|
+
/** Placeholder rows in the list's own column layout, shown while rows load. */
|
|
63
|
+
export declare function DataListSkeleton({ rows, className }: {
|
|
64
|
+
rows?: number;
|
|
65
|
+
className?: string;
|
|
66
|
+
}): import("react").JSX.Element;
|
|
67
|
+
/** The empty or error state of a list, in place of its rows. */
|
|
68
|
+
export declare function DataListEmpty(props: StateCardProps): import("react").JSX.Element;
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=data-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-list.d.ts","sourceRoot":"","sources":["../../src/components/data-list.tsx"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,cAAc,EAEnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjE,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAW5C,QAAA,MAAM,OAAO;;;;CAAoF,CAAC;AAGlG,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,OAAO,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,MA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,GAAG,aAAa,GAAG,WAAW,CAAC;AAE5F,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,GAAG;IACxE,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,QAAgB,EAChB,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAqClB;AAkBD,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,WAAmB,EACnB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,iBAAiB,+BAmBnB;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,EAAE,IAAQ,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,+BAmC9F;AAED,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,+BAUlD"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ArrowUp } from 'lucide-react';
|
|
4
|
+
import { Children, createContext, useContext, useEffect, useState, } from 'react';
|
|
5
|
+
import { m } from 'motion/react';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import { transitions } from '../lib/motion-tokens.js';
|
|
8
|
+
import { useSkylcn } from '../lib/provider.js';
|
|
9
|
+
import { Skeleton } from './skeleton.js';
|
|
10
|
+
import { StateCard } from './state-card.js';
|
|
11
|
+
const BREAKPOINTS = ['base', 'sm', 'md', 'lg', 'xl'];
|
|
12
|
+
const RANK = { base: 0, sm: 1, md: 2, lg: 3, xl: 4 };
|
|
13
|
+
// Static so Tailwind sees them; a column shown from a breakpoint hides below it.
|
|
14
|
+
const SHOW_FROM = {
|
|
15
|
+
sm: 'hidden sm:flex',
|
|
16
|
+
md: 'hidden md:flex',
|
|
17
|
+
lg: 'hidden lg:flex',
|
|
18
|
+
xl: 'hidden xl:flex',
|
|
19
|
+
};
|
|
20
|
+
const JUSTIFY = { start: 'justify-start', center: 'justify-center', end: 'justify-end' };
|
|
21
|
+
const STAGGER_CAP = 8;
|
|
22
|
+
const DataListContext = createContext(null);
|
|
23
|
+
/** The row's link or button, handed to its first always-visible cell to render. */
|
|
24
|
+
const RowTargetContext = createContext(null);
|
|
25
|
+
/** Whether rows mounting now are the list's first rows, which fade in one after another. */
|
|
26
|
+
const EntranceContext = createContext(false);
|
|
27
|
+
function useDataList() {
|
|
28
|
+
const context = useContext(DataListContext);
|
|
29
|
+
if (!context)
|
|
30
|
+
throw new Error('DataList parts must be used inside <DataList>.');
|
|
31
|
+
return context;
|
|
32
|
+
}
|
|
33
|
+
function tracksAt(columns, bp) {
|
|
34
|
+
return columns
|
|
35
|
+
.filter((column) => !column.from || RANK[column.from] <= RANK[bp])
|
|
36
|
+
.map((column) => column.width)
|
|
37
|
+
.join(' ');
|
|
38
|
+
}
|
|
39
|
+
const ROW_GRID = 'grid items-center gap-3 grid-cols-(--dl-base) sm:grid-cols-(--dl-sm) md:grid-cols-(--dl-md) lg:grid-cols-(--dl-lg) xl:grid-cols-(--dl-xl)';
|
|
40
|
+
/** A table-like list whose columns collapse by breakpoint, with sortable headers and linkable rows. */
|
|
41
|
+
export function DataList({ columns, sort, onSortChange, className, style, children, ...props }) {
|
|
42
|
+
const vars = Object.fromEntries(BREAKPOINTS.map((bp) => [`--dl-${bp}`, tracksAt(columns, bp)]));
|
|
43
|
+
return (_jsx(DataListContext.Provider, { value: { columns, sort, onSortChange }, children: _jsx("div", { "data-slot": "data-list", role: "table", className: cn('min-w-0', className), style: { ...vars, ...style }, ...props, children: children }) }));
|
|
44
|
+
}
|
|
45
|
+
function columnClass(column) {
|
|
46
|
+
return cn('min-w-0 items-center', column?.from ? SHOW_FROM[column.from] : 'flex', JUSTIFY[column?.align ?? 'start']);
|
|
47
|
+
}
|
|
48
|
+
export function DataListHeader({ className, children, ...props }) {
|
|
49
|
+
return (_jsx("div", { "data-slot": "data-list-header", role: "row", className: cn(ROW_GRID, 'sticky top-[var(--skylcn-sticky-top,0px)] z-20 border-b border-border bg-background px-3 pb-2', className), ...props, children: children }));
|
|
50
|
+
}
|
|
51
|
+
const COLUMN_LABEL = 'text-3xs font-medium tracking-label text-subtle-foreground uppercase';
|
|
52
|
+
export function DataListColumnHeader({ column, sortable = false, label, className, children, ...props }) {
|
|
53
|
+
const { columns, sort, onSortChange } = useDataList();
|
|
54
|
+
const { messages } = useSkylcn();
|
|
55
|
+
const def = columns.find((c) => c.id === column);
|
|
56
|
+
const active = sort?.field === column;
|
|
57
|
+
const descending = active && sort.direction === 'desc';
|
|
58
|
+
const name = label ?? (typeof children === 'string' ? children : undefined);
|
|
59
|
+
const hiddenName = label && !children ? _jsx("span", { className: "sr-only", children: label }) : null;
|
|
60
|
+
if (!sortable || !onSortChange) {
|
|
61
|
+
return (_jsxs("div", { role: "columnheader", className: cn(columnClass(def), COLUMN_LABEL, className), ...props, children: [children, hiddenName] }));
|
|
62
|
+
}
|
|
63
|
+
return (_jsx("div", { role: "columnheader", "aria-sort": active ? (sort.direction === 'asc' ? 'ascending' : 'descending') : 'none', className: cn(columnClass(def), className), ...props, children: _jsxs("button", { type: "button", onClick: () => onSortChange(column), title: name ? messages.sortBy(name) : undefined, className: cn(COLUMN_LABEL, 'group/sort inline-flex min-w-0 items-center gap-1 rounded outline-hidden', 'transition-colors duration-(--motion-duration-fast) hover:text-secondary-foreground focus-visible:ring-2 focus-visible:ring-ring', active && 'text-secondary-foreground'), children: [children ? _jsx("span", { className: "truncate", children: children }) : null, hiddenName, _jsxs("span", { "aria-hidden": true, className: "grid size-2.75 shrink-0 place-items-center", children: [_jsx("span", { className: cn('col-start-1 row-start-1 size-1 rounded-full bg-faint-foreground transition-[opacity,scale,background-color] duration-(--motion-duration-base) ease-enter group-hover/sort:bg-muted-foreground', active ? 'scale-50 opacity-0' : 'scale-100 opacity-100') }), _jsx(ArrowUp, { strokeWidth: 2, className: cn('col-start-1 row-start-1 size-2.75 text-skylab-300 transition-[opacity,scale,rotate] duration-(--motion-duration-base) ease-enter motion-reduce:scale-100', active ? 'scale-100 opacity-100' : 'scale-50 opacity-0', descending ? 'rotate-180' : 'rotate-0') })] })] }) }));
|
|
64
|
+
}
|
|
65
|
+
/** Rows fade in one after another when they first arrive; later sorts, searches and pages swap in place. */
|
|
66
|
+
export function DataListBody({ className, children, ...props }) {
|
|
67
|
+
const hasRows = Children.count(children) > 0;
|
|
68
|
+
const [settled, setSettled] = useState(false);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (!hasRows || settled)
|
|
71
|
+
return;
|
|
72
|
+
const timer = setTimeout(() => setSettled(true), 800);
|
|
73
|
+
return () => clearTimeout(timer);
|
|
74
|
+
}, [hasRows, settled]);
|
|
75
|
+
return (_jsx(EntranceContext.Provider, { value: !settled, children: _jsx("div", { "data-slot": "data-list-body", role: "rowgroup", className: cn('divide-y divide-border-subtle', className), ...props, children: children }) }));
|
|
76
|
+
}
|
|
77
|
+
export function DataListRow({ href, onSelect, label, selected = false, index, className, style, children, ...props }) {
|
|
78
|
+
const firstFill = useContext(EntranceContext);
|
|
79
|
+
const entering = firstFill && index !== undefined;
|
|
80
|
+
return (_jsx(RowTargetContext.Provider, { value: href || onSelect ? { href, onSelect, label } : null, children: _jsx(m.div, { "data-slot": "data-list-row", role: "row", "aria-selected": selected || undefined,
|
|
81
|
+
// Rows glide to their new places when the sort changes; rows that turn
|
|
82
|
+
// up later (a search, a filter) fade in, the first fill staggers in CSS
|
|
83
|
+
layout: "position", transition: { layout: transitions.layout }, initial: firstFill ? false : { opacity: 0 }, animate: { opacity: 1 }, className: cn(ROW_GRID, 'group/row relative px-3 py-2.5 transition-colors duration-(--motion-duration-fast)', (href || onSelect) && 'hover:bg-card', selected && 'bg-skylab-500/5', entering && 'enter-rise', className), style: entering
|
|
84
|
+
? {
|
|
85
|
+
animationDelay: `calc(var(--motion-stagger) * ${Math.min(index, STAGGER_CAP)})`,
|
|
86
|
+
...style,
|
|
87
|
+
}
|
|
88
|
+
: style, ...props, children: children }) }));
|
|
89
|
+
}
|
|
90
|
+
const OVERLAY = 'absolute inset-0 rounded-[inherit] outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset';
|
|
91
|
+
/** Stretches over the whole row from inside a cell, so the table keeps only cells in its rows. */
|
|
92
|
+
function RowTargetOverlay({ href, onSelect, label }) {
|
|
93
|
+
const { Link } = useSkylcn();
|
|
94
|
+
if (href) {
|
|
95
|
+
return (_jsx(Link, { href: href, className: OVERLAY, children: _jsx("span", { className: "sr-only", children: label }) }));
|
|
96
|
+
}
|
|
97
|
+
return _jsx("button", { type: "button", onClick: onSelect, "aria-label": label, className: OVERLAY });
|
|
98
|
+
}
|
|
99
|
+
export function DataListCell({ column, interactive = false, className, children, ...props }) {
|
|
100
|
+
const { columns } = useDataList();
|
|
101
|
+
const target = useContext(RowTargetContext);
|
|
102
|
+
// The row's link lives in the first column that never hides, so it is always reachable.
|
|
103
|
+
const holdsTarget = target && columns.find((c) => !c.from)?.id === column;
|
|
104
|
+
return (_jsxs("div", { role: "cell", className: cn(columnClass(columns.find((c) => c.id === column)), interactive && 'relative z-10', className), ...props, children: [holdsTarget ? _jsx(RowTargetOverlay, { ...target }) : null, children] }));
|
|
105
|
+
}
|
|
106
|
+
/** Placeholder rows in the list's own column layout, shown while rows load. */
|
|
107
|
+
export function DataListSkeleton({ rows = 4, className }) {
|
|
108
|
+
const { columns } = useDataList();
|
|
109
|
+
const { messages } = useSkylcn();
|
|
110
|
+
return (_jsxs("div", { role: "rowgroup", "aria-busy": "true", className: cn('divide-y divide-border-subtle', className), children: [_jsx("div", { role: "row", className: "sr-only", children: _jsx("div", { role: "cell", children: _jsx("span", { role: "status", children: messages.loading }) }) }), Array.from({ length: rows }, (_, row) => (_jsx("div", { "aria-hidden": true, className: cn(ROW_GRID, 'px-3 py-2.5'), children: columns.map((column, i) => {
|
|
111
|
+
const narrow = /^\d*\.?\d+rem$/.test(column.width) && Number.parseFloat(column.width) <= 2;
|
|
112
|
+
return (_jsx("div", { className: columnClass(column), children: narrow ? (_jsx(Skeleton, { className: "size-1.5 rounded-full" })) : (_jsx(Skeleton, { className: cn('h-3.5', i === 1 ? 'w-40 max-w-full' : 'w-16 max-w-full') })) }, column.id));
|
|
113
|
+
}) }, row)))] }));
|
|
114
|
+
}
|
|
115
|
+
/** The empty or error state of a list, in place of its rows. */
|
|
116
|
+
export function DataListEmpty(props) {
|
|
117
|
+
return (_jsx("div", { role: "rowgroup", children: _jsx("div", { role: "row", children: _jsx("div", { role: "cell", children: _jsx(StateCard, { className: "py-12", ...props }) }) }) }));
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=data-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-list.js","sourceRoot":"","sources":["../../src/components/data-list.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,UAAU,EACV,SAAS,EACT,QAAQ,GAIT,MAAM,OAAO,CAAC;A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CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CACxC,mCAA2B,SAAS,EAAE,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,YAC9D,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACzB,MAAM,MAAM,GACV,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAC9E,OAAO,CACL,cAAqB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,YAChD,MAAM,CAAC,CAAC,CAAC,CACR,KAAC,QAAQ,IAAC,SAAS,EAAC,uBAAuB,GAAG,CAC/C,CAAC,CAAC,CAAC,CACF,KAAC,QAAQ,IACP,SAAS,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,GACvE,CACH,IAPO,MAAM,CAAC,EAAE,CAQb,CACP,CAAC;gBACJ,CAAC,CAAC,IAfM,GAAG,CAgBP,CACP,CAAC,IACE,CACP,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,aAAa,CAAC,KAAqB;IACjD,OAAO,CACL,cAAK,IAAI,EAAC,UAAU,YAClB,cAAK,IAAI,EAAC,KAAK,YACb,cAAK,IAAI,EAAC,MAAM,YACd,KAAC,SAAS,IAAC,SAAS,EAAC,OAAO,KAAK,KAAK,GAAI,GACtC,GACF,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
2
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
3
|
+
export declare const Dialog: <Payload>(props: DialogPrimitive.Root.Props<Payload>) => React.JSX.Element;
|
|
4
|
+
export declare const DialogTrigger: DialogPrimitive.Trigger;
|
|
5
|
+
export declare const DialogClose: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogCloseProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
export type DialogContentProps = DialogPrimitive.Popup.Props & {
|
|
7
|
+
/** Hides the close button in the corner, for dialogs that must be answered. */
|
|
8
|
+
hideClose?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A modal window for a short task: a form, a confirmation, details. Centred
|
|
12
|
+
* on wide screens and a bottom sheet on phones; focus stays inside and Esc closes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function DialogContent({ className, children, hideClose, ...props }: DialogContentProps): import("react").JSX.Element;
|
|
15
|
+
export declare function DialogHeader({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
16
|
+
export declare function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props): import("react").JSX.Element;
|
|
17
|
+
export declare function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props): import("react").JSX.Element;
|
|
18
|
+
export declare function DialogBody({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
19
|
+
export declare function DialogFooter({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
20
|
+
export type ConfirmDialogProps = {
|
|
21
|
+
open?: boolean;
|
|
22
|
+
onOpenChange?: (open: boolean) => void;
|
|
23
|
+
/** The button that opens it, when it is not opened from state. */
|
|
24
|
+
trigger?: ReactNode;
|
|
25
|
+
title: ReactNode;
|
|
26
|
+
description?: ReactNode;
|
|
27
|
+
/** A verb that names what happens, such as "Formu sil"; never "Tamam". */
|
|
28
|
+
actionLabel: string;
|
|
29
|
+
onAction: () => void;
|
|
30
|
+
/** Colours the action for removals and other things that cannot be undone. */
|
|
31
|
+
destructive?: boolean;
|
|
32
|
+
pending?: boolean;
|
|
33
|
+
cancelLabel?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Asks before an action that cannot be undone. Focus starts on Cancel, the
|
|
37
|
+
* action says exactly what it does, and nothing is pre-chosen for the reader.
|
|
38
|
+
* For actions that can be undone, prefer an undo toast to a question.
|
|
39
|
+
*/
|
|
40
|
+
export declare function ConfirmDialog({ open, onOpenChange, trigger, title, description, actionLabel, onAction, destructive, pending, cancelLabel, }: ConfirmDialogProps): import("react").JSX.Element;
|
|
41
|
+
//# sourceMappingURL=dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/components/dialog.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAU,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBpE,eAAO,MAAM,MAAM,4EAAuB,CAAC;AAC3C,eAAO,MAAM,aAAa,yBAA0B,CAAC;AACrD,eAAO,MAAM,WAAW,2JAAwB,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,GAAG;IAC7D,+EAA+E;IAC/E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,QAAQ,EACR,SAAiB,EACjB,GAAG,KAAK,EACT,EAAE,kBAAkB,+BAkBpB;AAED,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,+BAE1E;AAED,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,KAAK,+BAO/E;AAED,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,CAAC,WAAW,CAAC,KAAK,+BAO3F;AAED,wBAAgB,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,+BAOxE;AAED,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,+BAU1E;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,kEAAkE;IAClE,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EACR,WAAmB,EACnB,OAAe,EACf,WAAW,GACZ,EAAE,kBAAkB,+BAmCpB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AlertDialog as AlertPrimitive } from '@base-ui/react/alert-dialog';
|
|
4
|
+
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
5
|
+
import { X } from 'lucide-react';
|
|
6
|
+
import { useRef } from 'react';
|
|
7
|
+
import { cn } from '../lib/cn.js';
|
|
8
|
+
import { useSkylcn } from '../lib/provider.js';
|
|
9
|
+
import { Button } from './button.js';
|
|
10
|
+
const backdrop = 'fixed inset-0 z-50 bg-black/50 transition-opacity duration-(--motion-duration-base) ease-enter data-ending-style:opacity-0 data-starting-style:opacity-0';
|
|
11
|
+
// Centred from sm up; a sheet rising from the bottom edge on phones.
|
|
12
|
+
const popup = cn('fixed z-50 flex max-h-[calc(100dvh-2rem)] flex-col overflow-hidden border border-border bg-popover text-foreground shadow-overlay outline-hidden', 'transition-[opacity,translate,scale] duration-(--motion-duration-base) ease-enter data-ending-style:ease-exit data-ending-style:duration-(--motion-duration-fast)', 'inset-x-0 bottom-0 rounded-t-2xl pb-[env(safe-area-inset-bottom)] data-ending-style:translate-y-full data-starting-style:translate-y-full motion-reduce:data-ending-style:translate-y-0 motion-reduce:data-starting-style:translate-y-0 data-ending-style:opacity-0 data-starting-style:opacity-0', 'sm:inset-auto sm:top-1/2 sm:left-1/2 sm:w-[calc(100vw-2rem)] sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-xl sm:pb-0', 'sm:data-ending-style:-translate-y-1/2 sm:data-starting-style:-translate-y-1/2 sm:data-ending-style:scale-(--motion-scale-from) sm:data-starting-style:scale-(--motion-scale-from)');
|
|
13
|
+
export const Dialog = DialogPrimitive.Root;
|
|
14
|
+
export const DialogTrigger = DialogPrimitive.Trigger;
|
|
15
|
+
export const DialogClose = DialogPrimitive.Close;
|
|
16
|
+
/**
|
|
17
|
+
* A modal window for a short task: a form, a confirmation, details. Centred
|
|
18
|
+
* on wide screens and a bottom sheet on phones; focus stays inside and Esc closes.
|
|
19
|
+
*/
|
|
20
|
+
export function DialogContent({ className, children, hideClose = false, ...props }) {
|
|
21
|
+
const { messages } = useSkylcn();
|
|
22
|
+
return (_jsxs(DialogPrimitive.Portal, { children: [_jsx(DialogPrimitive.Backdrop, { className: backdrop }), _jsxs(DialogPrimitive.Popup, { "data-slot": "dialog-content", className: cn(popup, className), ...props, children: [children, hideClose ? null : (_jsx(DialogPrimitive.Close, { "aria-label": messages.close, className: "absolute top-3 right-3 grid size-8 place-items-center rounded-md text-subtle-foreground outline-hidden transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { className: "size-4" }) }))] })] }));
|
|
23
|
+
}
|
|
24
|
+
export function DialogHeader({ className, ...props }) {
|
|
25
|
+
return _jsx("div", { className: cn('flex flex-col gap-1 px-5 pt-5 pr-12', className), ...props });
|
|
26
|
+
}
|
|
27
|
+
export function DialogTitle({ className, ...props }) {
|
|
28
|
+
return (_jsx(DialogPrimitive.Title, { className: cn('text-base font-semibold text-foreground', className), ...props }));
|
|
29
|
+
}
|
|
30
|
+
export function DialogDescription({ className, ...props }) {
|
|
31
|
+
return (_jsx(DialogPrimitive.Description, { className: cn('text-xs leading-relaxed text-muted-foreground', className), ...props }));
|
|
32
|
+
}
|
|
33
|
+
export function DialogBody({ className, ...props }) {
|
|
34
|
+
return (_jsx("div", { className: cn('scrollbar min-h-0 flex-1 overflow-y-auto px-5 py-4', className), ...props }));
|
|
35
|
+
}
|
|
36
|
+
export function DialogFooter({ className, ...props }) {
|
|
37
|
+
return (_jsx("div", { className: cn('flex flex-col-reverse gap-2 border-t border-border-subtle px-5 py-3 sm:flex-row sm:justify-end', className), ...props }));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Asks before an action that cannot be undone. Focus starts on Cancel, the
|
|
41
|
+
* action says exactly what it does, and nothing is pre-chosen for the reader.
|
|
42
|
+
* For actions that can be undone, prefer an undo toast to a question.
|
|
43
|
+
*/
|
|
44
|
+
export function ConfirmDialog({ open, onOpenChange, trigger, title, description, actionLabel, onAction, destructive = false, pending = false, cancelLabel, }) {
|
|
45
|
+
const { messages } = useSkylcn();
|
|
46
|
+
const cancel = useRef(null);
|
|
47
|
+
return (_jsxs(AlertPrimitive.Root, { open: open, onOpenChange: onOpenChange, children: [trigger ? _jsx(AlertPrimitive.Trigger, { render: trigger }) : null, _jsxs(AlertPrimitive.Portal, { children: [_jsx(AlertPrimitive.Backdrop, { className: backdrop }), _jsxs(AlertPrimitive.Popup, { "data-slot": "confirm-dialog", initialFocus: cancel, className: popup, children: [_jsxs("div", { className: "flex flex-col gap-1 px-5 pt-5", children: [_jsx(AlertPrimitive.Title, { className: "text-base font-semibold text-foreground", children: title }), description ? (_jsx(AlertPrimitive.Description, { className: "text-xs leading-relaxed text-muted-foreground", children: description })) : null] }), _jsxs("div", { className: "mt-4 flex flex-col-reverse gap-2 border-t border-border-subtle px-5 py-3 sm:flex-row sm:justify-end", children: [_jsx(AlertPrimitive.Close, { render: _jsx(Button, { ref: cancel }), children: cancelLabel ?? messages.cancel }), _jsx(Button, { variant: destructive ? 'destructive' : 'primary', pending: pending, onClick: onAction, children: actionLabel })] })] })] })] }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/components/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,MAAM,EAAuC,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,QAAQ,GACZ,0JAA0J,CAAC;AAE7J,qEAAqE;AACrE,MAAM,KAAK,GAAG,EAAE,CACd,kJAAkJ,EAClJ,mKAAmK,EACnK,mSAAmS,EACnS,wIAAwI,EACxI,mLAAmL,CACpL,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC;AAC3C,MAAM,CAAC,MAAM,aAAa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