@zhin.js/console-ui 0.0.0-stage → 1.0.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/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +88 -2
- package/dist/cn.d.ts +4 -0
- package/dist/cn.js +6 -0
- package/dist/components/InfoHint.d.ts +12 -0
- package/dist/components/InfoHint.js +12 -0
- package/dist/components/PageHeader.d.ts +11 -0
- package/dist/components/PageHeader.js +8 -0
- package/dist/components/PageShell.d.ts +11 -0
- package/dist/components/PageShell.js +8 -0
- package/dist/components/RefreshControl.d.ts +23 -0
- package/dist/components/RefreshControl.js +65 -0
- package/dist/components/StatCard.d.ts +27 -0
- package/dist/components/StatCard.js +27 -0
- package/dist/components/confirm-dialog-model.d.ts +9 -0
- package/dist/components/confirm-dialog-model.js +20 -0
- package/dist/components/confirm-dialog.d.ts +32 -0
- package/dist/components/confirm-dialog.js +71 -0
- package/dist/components/empty-state.d.ts +15 -0
- package/dist/components/empty-state.js +15 -0
- package/dist/components/error-alert.d.ts +15 -0
- package/dist/components/error-alert.js +22 -0
- package/dist/components/page-chrome.d.ts +41 -0
- package/dist/components/page-chrome.js +65 -0
- package/dist/components/refresh-control-model.d.ts +9 -0
- package/dist/components/refresh-control-model.js +26 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/accordion.js +14 -0
- package/dist/components/ui/alert.d.ts +8 -0
- package/dist/components/ui/alert.js +24 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/badge.js +29 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.js +37 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +16 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +9 -0
- package/dist/components/ui/dialog.d.ts +24 -0
- package/dist/components/ui/dialog.js +26 -0
- package/dist/components/ui/dropdown-menu.d.ts +19 -0
- package/dist/components/ui/dropdown-menu.js +25 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +8 -0
- package/dist/components/ui/list-item-button.d.ts +10 -0
- package/dist/components/ui/list-item-button.js +6 -0
- package/dist/components/ui/popover.d.ts +6 -0
- package/dist/components/ui/popover.js +9 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +10 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +13 -0
- package/dist/components/ui/searchable-select-model.d.ts +29 -0
- package/dist/components/ui/searchable-select-model.js +38 -0
- package/dist/components/ui/searchable-select.d.ts +23 -0
- package/dist/components/ui/searchable-select.js +84 -0
- package/dist/components/ui/select.d.ts +23 -0
- package/dist/components/ui/select.js +37 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +11 -0
- package/dist/components/ui/sheet.d.ts +27 -0
- package/dist/components/ui/sheet.js +26 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/switch.js +8 -0
- package/dist/components/ui/table.d.ts +16 -0
- package/dist/components/ui/table.js +16 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +13 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +8 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +11 -0
- package/dist/exports.json +138 -0
- package/dist/i18n/index.d.ts +27 -0
- package/dist/i18n/index.js +33 -0
- package/dist/i18n/messages.d.ts +36 -0
- package/dist/i18n/messages.js +72 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +44 -0
- package/dist/shared-module.d.ts +28 -0
- package/dist/shared-module.js +24 -0
- package/dist/styles.css +2316 -0
- package/dist/tokens.css +341 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +2 -0
- package/package.json +73 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useMemo, useSyncExternalStore } from 'react';
|
|
3
|
+
import { cn } from '../cn.js';
|
|
4
|
+
import { RefreshControl } from './RefreshControl.js';
|
|
5
|
+
/** One store per mounted page slot; the shell creates it and passes it to {@link PageChromeProvider}. */
|
|
6
|
+
export function createPageChromeStore() {
|
|
7
|
+
let current;
|
|
8
|
+
const listeners = new Set();
|
|
9
|
+
const emit = () => { for (const listener of [...listeners])
|
|
10
|
+
listener(); };
|
|
11
|
+
return {
|
|
12
|
+
get: () => current?.chrome,
|
|
13
|
+
set(chrome) {
|
|
14
|
+
const token = {};
|
|
15
|
+
current = { token, chrome };
|
|
16
|
+
emit();
|
|
17
|
+
return () => {
|
|
18
|
+
if (current?.token !== token)
|
|
19
|
+
return;
|
|
20
|
+
current = undefined;
|
|
21
|
+
emit();
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
subscribe(listener) {
|
|
25
|
+
listeners.add(listener);
|
|
26
|
+
return () => { listeners.delete(listener); };
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const PageChromeContext = createContext(null);
|
|
31
|
+
/** Wraps a page slot so pages inside can call {@link usePageChrome}. */
|
|
32
|
+
export function PageChromeProvider({ store, children }) {
|
|
33
|
+
const value = useMemo(() => store ?? createPageChromeStore(), [store]);
|
|
34
|
+
return _jsx(PageChromeContext.Provider, { value: value, children: children });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Hands header actions and the refresh control to the shell. Returns `true` when a shell is
|
|
38
|
+
* listening; `false` means the page renders outside a shell (e.g. an older Console) and may draw
|
|
39
|
+
* the controls itself.
|
|
40
|
+
*/
|
|
41
|
+
export function usePageChrome(chrome) {
|
|
42
|
+
const store = useContext(PageChromeContext);
|
|
43
|
+
const { actions, refresh } = chrome;
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!store)
|
|
46
|
+
return;
|
|
47
|
+
return store.set({ actions, refresh });
|
|
48
|
+
}, [store, actions, refresh]);
|
|
49
|
+
return store !== null;
|
|
50
|
+
}
|
|
51
|
+
/** The chrome the current page registered; for the shell. */
|
|
52
|
+
export function usePageChromeState(store) {
|
|
53
|
+
const contextStore = useContext(PageChromeContext);
|
|
54
|
+
const target = store ?? contextStore;
|
|
55
|
+
return useSyncExternalStore(target?.subscribe ?? noopSubscribe, target?.get ?? noopGet, target?.get ?? noopGet);
|
|
56
|
+
}
|
|
57
|
+
const noopSubscribe = () => () => { };
|
|
58
|
+
const noopGet = () => undefined;
|
|
59
|
+
/** Renders the registered refresh control and actions; the shell puts it into `PageHeader.actions`. */
|
|
60
|
+
export function PageChromeActions({ store, className }) {
|
|
61
|
+
const chrome = usePageChromeState(store);
|
|
62
|
+
if (!chrome || (chrome.actions == null && !chrome.refresh))
|
|
63
|
+
return null;
|
|
64
|
+
return (_jsxs("div", { className: cn('console-page-chrome-actions flex flex-wrap items-center gap-2', className), children: [chrome.refresh ? _jsx(RefreshControl, { ...chrome.refresh }) : null, chrome.actions] }));
|
|
65
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Auto-refresh choices offered by RefreshControl, in milliseconds (0 = manual). */
|
|
2
|
+
export declare const DEFAULT_REFRESH_INTERVALS: readonly number[];
|
|
3
|
+
/** The offered intervals plus `current` when it is not one of them (kept, so a custom value is not lost). */
|
|
4
|
+
export declare function refreshIntervalOptions(current: number, intervals?: readonly number[]): number[];
|
|
5
|
+
export declare function isValidInterval(value: unknown): value is number;
|
|
6
|
+
/** 「hh:mm:ss」 in 24-hour time; `null` when there is no valid time yet. */
|
|
7
|
+
export declare function formatRefreshTime(value: Date | number | string | null | undefined): string | null;
|
|
8
|
+
/** Whole seconds shown in the 「5s 自动」 label. */
|
|
9
|
+
export declare function intervalSeconds(intervalMs: number): number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Auto-refresh choices offered by RefreshControl, in milliseconds (0 = manual). */
|
|
2
|
+
export const DEFAULT_REFRESH_INTERVALS = Object.freeze([0, 5_000, 15_000, 30_000]);
|
|
3
|
+
/** The offered intervals plus `current` when it is not one of them (kept, so a custom value is not lost). */
|
|
4
|
+
export function refreshIntervalOptions(current, intervals = DEFAULT_REFRESH_INTERVALS) {
|
|
5
|
+
const values = [...new Set(intervals.filter(isValidInterval))];
|
|
6
|
+
if (isValidInterval(current) && !values.includes(current))
|
|
7
|
+
values.push(current);
|
|
8
|
+
return values.sort((left, right) => left - right);
|
|
9
|
+
}
|
|
10
|
+
export function isValidInterval(value) {
|
|
11
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
12
|
+
}
|
|
13
|
+
/** 「hh:mm:ss」 in 24-hour time; `null` when there is no valid time yet. */
|
|
14
|
+
export function formatRefreshTime(value) {
|
|
15
|
+
if (value === null || value === undefined || value === '')
|
|
16
|
+
return null;
|
|
17
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
18
|
+
if (Number.isNaN(date.getTime()))
|
|
19
|
+
return null;
|
|
20
|
+
const pad = (part) => String(part).padStart(2, '0');
|
|
21
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
22
|
+
}
|
|
23
|
+
/** Whole seconds shown in the 「5s 自动」 label. */
|
|
24
|
+
export function intervalSeconds(intervalMs) {
|
|
25
|
+
return Math.max(1, Math.round(intervalMs / 1000));
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as Radix from "radix-ui";
|
|
3
|
+
declare const Accordion: React.ForwardRefExoticComponent<(Radix.Accordion.AccordionSingleProps | Radix.Accordion.AccordionMultipleProps) & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const AccordionItem: React.ForwardRefExoticComponent<Omit<Radix.Accordion.AccordionItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
declare const AccordionTrigger: React.ForwardRefExoticComponent<Omit<Radix.Accordion.AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
declare const AccordionContent: React.ForwardRefExoticComponent<Omit<Radix.Accordion.AccordionContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
const AccordionPrimitive = Radix.Accordion;
|
|
5
|
+
import { cn } from '../../cn.js';
|
|
6
|
+
import { ChevronDown } from "lucide-react";
|
|
7
|
+
const Accordion = AccordionPrimitive.Root;
|
|
8
|
+
const AccordionItem = forwardRef(({ className, value, ...props }, ref) => (_jsx(AccordionPrimitive.Item, { ref: ref, value: value, className: cn("border-b", className), ...props })));
|
|
9
|
+
AccordionItem.displayName = "AccordionItem";
|
|
10
|
+
const AccordionTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsx(AccordionPrimitive.Header, { className: "flex", children: _jsxs(AccordionPrimitive.Trigger, { ref: ref, className: cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180", className), ...props, children: [children, _jsx(ChevronDown, { className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" })] }) })));
|
|
11
|
+
AccordionTrigger.displayName = "AccordionTrigger";
|
|
12
|
+
const AccordionContent = forwardRef(({ className, children, ...props }, ref) => (_jsx(AccordionPrimitive.Content, { ref: ref, className: "overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down", ...props, children: _jsx("div", { className: cn("pb-4 pt-0", className), children: children }) })));
|
|
13
|
+
AccordionContent.displayName = "AccordionContent";
|
|
14
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const Alert: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
|
|
4
|
+
variant?: "default" | "destructive" | "success" | "warning" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
declare const AlertTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
7
|
+
declare const AlertDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
8
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from '../../cn.js';
|
|
5
|
+
const alertVariants = cva("relative w-full rounded-[var(--console-radius-lg)] border-[length:var(--console-border-width)] px-4 py-3 text-[length:var(--console-text-body)] leading-relaxed [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-3.5 [&>svg]:text-foreground [&>svg~*]:pl-7", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "border-transparent bg-secondary text-foreground",
|
|
9
|
+
destructive: "border-destructive/30 bg-destructive/5 text-destructive dark:border-destructive/40 [&>svg]:text-destructive",
|
|
10
|
+
success: "console-badge-success [&>svg]:text-[hsl(var(--success))]",
|
|
11
|
+
warning: "console-badge-warning [&>svg]:text-[hsl(var(--warning))]",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
variant: "default",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const Alert = forwardRef(({ className, variant, ...props }, ref) => (_jsx("div", { ref: ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props })));
|
|
19
|
+
Alert.displayName = "Alert";
|
|
20
|
+
const AlertTitle = forwardRef(({ className, ...props }, ref) => (_jsx("h5", { ref: ref, className: cn("mb-1 font-medium leading-normal", className), ...props })));
|
|
21
|
+
AlertTitle.displayName = "AlertTitle";
|
|
22
|
+
const AlertDescription = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("text-[length:var(--console-text-body)] [&_p]:leading-relaxed", className), ...props })));
|
|
23
|
+
AlertDescription.displayName = "AlertDescription";
|
|
24
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const badgeVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "destructive" | "success" | "warning" | "secondary" | "outline" | "info" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export type BadgeProps = React.ComponentPropsWithoutRef<"span"> & VariantProps<typeof badgeVariants>;
|
|
8
|
+
declare function Badge({ className, variant, size, ...props }: BadgeProps): React.JSX.Element;
|
|
9
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { cn } from '../../cn.js';
|
|
4
|
+
const badgeVariants = cva("inline-flex items-center whitespace-nowrap rounded-full border-[length:var(--console-border-width)] text-[length:var(--console-text-label)] font-medium leading-5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", {
|
|
5
|
+
variants: {
|
|
6
|
+
variant: {
|
|
7
|
+
default: "border-[hsl(var(--primary-action-border))] bg-[hsl(var(--primary-action))] text-[hsl(var(--primary-action-foreground))]",
|
|
8
|
+
secondary: "border-transparent bg-[hsl(var(--foreground)/0.06)] text-secondary-foreground",
|
|
9
|
+
destructive: "border-transparent bg-destructive text-destructive-foreground",
|
|
10
|
+
outline: "border-[color:var(--console-border-strong)] text-foreground",
|
|
11
|
+
success: "console-badge-success",
|
|
12
|
+
warning: "console-badge-warning",
|
|
13
|
+
info: "console-badge-info",
|
|
14
|
+
},
|
|
15
|
+
// Badge text never goes below the label role (12px); "sm" only tightens spacing.
|
|
16
|
+
size: {
|
|
17
|
+
default: "px-2.5 py-0.5",
|
|
18
|
+
sm: "px-1.5 py-0",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: "default",
|
|
23
|
+
size: "default",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
function Badge({ className, variant, size, ...props }) {
|
|
27
|
+
return _jsx("span", { className: cn(badgeVariants({ variant, size }), className), ...props });
|
|
28
|
+
}
|
|
29
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "destructive-outline" | "ghost" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from '../../cn.js';
|
|
6
|
+
const buttonVariants = cva("console-control inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--console-radius-md)] border border-transparent text-[length:var(--console-text-body)] font-medium transition-[background-color,border-color,color,box-shadow] duration-150 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: "border-[hsl(var(--primary-action-border))] bg-[hsl(var(--primary-action))] text-[hsl(var(--primary-action-foreground))] hover:border-[hsl(var(--primary))] hover:bg-[hsl(var(--primary-action)/0.72)]",
|
|
10
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
11
|
+
outline: "border-[color:var(--console-border-strong)] bg-card text-foreground hover:bg-[var(--console-surface-hover)]",
|
|
12
|
+
// Page-level entry to a dangerous action (ADR 0063 决策 5): the outline button with destructive text.
|
|
13
|
+
// The solid `destructive` variant is only for the confirm button inside the confirmation dialog.
|
|
14
|
+
"destructive-outline": "border-[color:var(--console-border-strong)] bg-card text-destructive hover:bg-[var(--console-surface-hover)]",
|
|
15
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-accent",
|
|
16
|
+
ghost: "text-foreground hover:bg-[var(--console-surface-hover)]",
|
|
17
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
default: "h-[var(--console-control-height)] px-3.5 py-1.5",
|
|
21
|
+
sm: "h-[var(--console-control-height-sm)] rounded-[var(--console-radius-md)] px-3 text-[length:var(--console-text-body-sm)]",
|
|
22
|
+
lg: "h-[var(--console-control-height-lg)] rounded-[var(--console-radius-md)] px-5",
|
|
23
|
+
icon: "h-[var(--console-control-height)] w-[var(--console-control-height)] shrink-0",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
variant: "default",
|
|
28
|
+
size: "default",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const Slot = Radix.Slot.Root;
|
|
32
|
+
const Button = forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
33
|
+
const Comp = asChild ? Slot : "button";
|
|
34
|
+
return (_jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref: ref, ...props }));
|
|
35
|
+
});
|
|
36
|
+
Button.displayName = "Button";
|
|
37
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
interactive?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
declare const CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
declare const CardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
declare const CardDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
declare const CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
declare const CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from '../../cn.js';
|
|
4
|
+
const Card = forwardRef(({ className, interactive, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("console-card text-card-foreground", interactive && "console-card--interactive", className), ...props })));
|
|
5
|
+
Card.displayName = "Card";
|
|
6
|
+
const CardHeader = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("flex flex-col space-y-1.5 p-[var(--console-space-card)] pb-3", className), ...props })));
|
|
7
|
+
CardHeader.displayName = "CardHeader";
|
|
8
|
+
const CardTitle = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("console-section-title", className), ...props })));
|
|
9
|
+
CardTitle.displayName = "CardTitle";
|
|
10
|
+
const CardDescription = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("console-text-body text-muted-foreground", className), ...props })));
|
|
11
|
+
CardDescription.displayName = "CardDescription";
|
|
12
|
+
const CardContent = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("p-[var(--console-space-card)] pt-0", className), ...props })));
|
|
13
|
+
CardContent.displayName = "CardContent";
|
|
14
|
+
const CardFooter = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("flex items-center p-[var(--console-space-card)] pt-0", className), ...props })));
|
|
15
|
+
CardFooter.displayName = "CardFooter";
|
|
16
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as Radix from "radix-ui";
|
|
3
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Omit<Radix.Checkbox.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export { Checkbox };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
const CheckboxPrimitive = Radix.Checkbox;
|
|
5
|
+
import { cn } from '../../cn.js';
|
|
6
|
+
import { Check, Minus } from "lucide-react";
|
|
7
|
+
const Checkbox = forwardRef(({ className, ...props }, ref) => (_jsx(CheckboxPrimitive.Root, { ref: ref, className: cn("console-control peer inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-[3px] border border-input bg-card text-primary-foreground transition-colors disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary", className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { className: "group/indicator flex items-center justify-center text-current", children: [_jsx(Check, { className: "hidden h-3.5 w-3.5 group-data-[state=checked]/indicator:block" }), _jsx(Minus, { className: "hidden h-3.5 w-3.5 group-data-[state=indeterminate]/indicator:block" })] }) })));
|
|
8
|
+
Checkbox.displayName = "Checkbox";
|
|
9
|
+
export { Checkbox };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as Radix from "radix-ui";
|
|
3
|
+
declare const DialogPrimitive: typeof Radix.Dialog;
|
|
4
|
+
declare const Dialog: React.FC<Radix.Dialog.DialogProps>;
|
|
5
|
+
declare const DialogTrigger: React.ForwardRefExoticComponent<Radix.Dialog.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
declare const DialogPortal: React.FC<Radix.Dialog.DialogPortalProps>;
|
|
7
|
+
declare const DialogClose: React.ForwardRefExoticComponent<Radix.Dialog.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
declare const DialogOverlay: React.ForwardRefExoticComponent<Omit<Radix.Dialog.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export interface DialogContentProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
|
|
10
|
+
variant?: "modal" | "drawer";
|
|
11
|
+
side?: "right" | "left" | "bottom";
|
|
12
|
+
}
|
|
13
|
+
declare const DialogContent: React.ForwardRefExoticComponent<DialogContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
declare const DialogHeader: {
|
|
15
|
+
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
18
|
+
declare const DialogFooter: {
|
|
19
|
+
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
22
|
+
declare const DialogTitle: React.ForwardRefExoticComponent<Omit<Radix.Dialog.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
23
|
+
declare const DialogDescription: React.ForwardRefExoticComponent<Omit<Radix.Dialog.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
24
|
+
export { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ConsoleUiText } from '../../i18n/index.js';
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import * as Radix from "radix-ui";
|
|
5
|
+
const DialogPrimitive = Radix.Dialog;
|
|
6
|
+
import { cn } from '../../cn.js';
|
|
7
|
+
import { X } from "lucide-react";
|
|
8
|
+
const Dialog = DialogPrimitive.Root;
|
|
9
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
10
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
11
|
+
const DialogClose = DialogPrimitive.Close;
|
|
12
|
+
const DialogOverlay = forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Overlay, { ref: ref, className: cn("console-dialog-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className), ...props })));
|
|
13
|
+
DialogOverlay.displayName = "DialogOverlay";
|
|
14
|
+
const DialogContent = forwardRef(({ className, children, variant = "modal", side = "right", ...props }, ref) => (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { ref: ref, "data-side": variant === "drawer" ? side : undefined, className: cn(variant === "drawer"
|
|
15
|
+
? "console-sheet-content outline-none"
|
|
16
|
+
: "fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-2rem)] max-w-lg max-h-[calc(100dvh-2.5rem)] overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border-0 bg-popover text-popover-foreground p-[calc(var(--console-space-card)+0.25rem)] shadow-[var(--console-shadow-lg)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-[var(--console-radius-2xl)] outline-none", className), ...props, children: [children, _jsxs(DialogPrimitive.Close, { className: "console-dialog-close disabled:pointer-events-none", children: [_jsx(X, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: _jsx(ConsoleUiText, { id: "dialog.close" }) })] })] })] })));
|
|
17
|
+
DialogContent.displayName = "DialogContent";
|
|
18
|
+
const DialogHeader = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col space-y-1.5 pr-8 text-left", className), ...props }));
|
|
19
|
+
DialogHeader.displayName = "DialogHeader";
|
|
20
|
+
const DialogFooter = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:justify-end", className), ...props }));
|
|
21
|
+
DialogFooter.displayName = "DialogFooter";
|
|
22
|
+
const DialogTitle = forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Title, { ref: ref, className: cn("console-section-title", className), ...props })));
|
|
23
|
+
DialogTitle.displayName = "DialogTitle";
|
|
24
|
+
const DialogDescription = forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Description, { ref: ref, className: cn("text-[length:var(--console-text-body)] text-muted-foreground", className), ...props })));
|
|
25
|
+
DialogDescription.displayName = "DialogDescription";
|
|
26
|
+
export { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as Radix from "radix-ui";
|
|
3
|
+
declare const DropdownMenu: React.FC<Radix.DropdownMenu.DropdownMenuProps>;
|
|
4
|
+
declare const DropdownMenuTrigger: React.ForwardRefExoticComponent<Radix.DropdownMenu.DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
declare const DropdownMenuGroup: React.ForwardRefExoticComponent<Radix.DropdownMenu.DropdownMenuGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
declare const DropdownMenuPortal: React.FC<Radix.DropdownMenu.DropdownMenuPortalProps>;
|
|
7
|
+
declare const DropdownMenuSub: React.FC<Radix.DropdownMenu.DropdownMenuSubProps>;
|
|
8
|
+
declare const DropdownMenuRadioGroup: React.ForwardRefExoticComponent<Radix.DropdownMenu.DropdownMenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
declare const DropdownMenuContent: React.ForwardRefExoticComponent<Omit<Radix.DropdownMenu.DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
declare const DropdownMenuItem: React.ForwardRefExoticComponent<Omit<Radix.DropdownMenu.DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
11
|
+
inset?: boolean;
|
|
12
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
declare const DropdownMenuCheckboxItem: React.ForwardRefExoticComponent<Omit<Radix.DropdownMenu.DropdownMenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
declare const DropdownMenuRadioItem: React.ForwardRefExoticComponent<Omit<Radix.DropdownMenu.DropdownMenuRadioItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
declare const DropdownMenuLabel: React.ForwardRefExoticComponent<Omit<Radix.DropdownMenu.DropdownMenuLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
16
|
+
inset?: boolean;
|
|
17
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
declare const DropdownMenuSeparator: React.ForwardRefExoticComponent<Omit<Radix.DropdownMenu.DropdownMenuSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
19
|
+
export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuRadioGroup, DropdownMenuRadioItem, };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
const DropdownMenuPrimitive = Radix.DropdownMenu;
|
|
5
|
+
import { cn } from '../../cn.js';
|
|
6
|
+
import { Check, Circle } from "lucide-react";
|
|
7
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
8
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
9
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
10
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
11
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
12
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
13
|
+
const DropdownMenuContent = forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn("z-50 min-w-[9.5rem] overflow-hidden rounded-[var(--console-radius-lg)] border-0 bg-popover p-1.5 text-popover-foreground shadow-[var(--console-shadow-lg)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className), ...props }) })));
|
|
14
|
+
DropdownMenuContent.displayName = "DropdownMenuContent";
|
|
15
|
+
const DropdownMenuItem = forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Item, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center gap-2 rounded-[var(--console-radius-sm)] px-2 py-1.5 text-[length:var(--console-text-body)] outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", inset && "pl-8", className), ...props })));
|
|
16
|
+
DropdownMenuItem.displayName = "DropdownMenuItem";
|
|
17
|
+
const DropdownMenuCheckboxItem = forwardRef(({ className, children, checked, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.CheckboxItem, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center rounded-[var(--console-radius-sm)] py-1.5 pl-8 pr-2 text-[length:var(--console-text-body)] outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), checked: checked, ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), children] })));
|
|
18
|
+
DropdownMenuCheckboxItem.displayName = "DropdownMenuCheckboxItem";
|
|
19
|
+
const DropdownMenuRadioItem = forwardRef(({ className, children, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.RadioItem, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center gap-2 rounded-[var(--console-radius-sm)] py-1.5 pl-8 pr-2 text-[length:var(--console-text-body)] outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", className), ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }), children] })));
|
|
20
|
+
DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem";
|
|
21
|
+
const DropdownMenuLabel = forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Label, { ref: ref, className: cn("px-2 py-1.5 text-[length:var(--console-text-body)] font-semibold", inset && "pl-8", className), ...props })));
|
|
22
|
+
DropdownMenuLabel.displayName = "DropdownMenuLabel";
|
|
23
|
+
const DropdownMenuSeparator = forwardRef(({ className, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Separator, { ref: ref, className: cn("-mx-1 my-1 h-px bg-muted", className), ...props })));
|
|
24
|
+
DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
|
|
25
|
+
export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuRadioGroup, DropdownMenuRadioItem, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from '../../cn.js';
|
|
4
|
+
const Input = forwardRef(({ className, type, ...props }, ref) => {
|
|
5
|
+
return (_jsx("input", { type: type, className: cn("console-control flex h-[var(--console-control-height)] w-full rounded-[var(--console-radius-md)] border-[length:var(--console-border-width)] border-input bg-card hover:border-[hsl(var(--foreground)/0.45)] focus-visible:border-[hsl(var(--primary))] shadow-[var(--console-shadow-xs)] px-3 py-1 text-[length:var(--console-text-body)] transition-colors file:border-0 file:bg-transparent file:text-[length:var(--console-text-body)] file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-60", className), ref: ref, ...props }));
|
|
6
|
+
});
|
|
7
|
+
Input.displayName = "Input";
|
|
8
|
+
export { Input };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Internal building block for list rows, side-nav items and selectable cards that are
|
|
4
|
+
* buttons but not "actions" (use `Button` for those). It supplies the shared behaviours
|
|
5
|
+
* every such row needs - `type="button"`, a visible focus ring and a 44px tap target
|
|
6
|
+
* below 768px - while the caller's own class owns the visual layout.
|
|
7
|
+
*/
|
|
8
|
+
export type ListItemButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
9
|
+
declare const ListItemButton: React.ForwardRefExoticComponent<ListItemButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
export { ListItemButton };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from '../../cn.js';
|
|
4
|
+
const ListItemButton = forwardRef(({ className, type = "button", ...props }, ref) => (_jsx("button", { ref: ref, type: type, className: cn("cursor-pointer text-left max-md:min-h-11 disabled:cursor-not-allowed disabled:opacity-50", "focus-visible:outline focus-visible:outline-[length:var(--console-focus-width)] focus-visible:outline-offset-2 focus-visible:outline-ring", className), ...props })));
|
|
5
|
+
ListItemButton.displayName = "ListItemButton";
|
|
6
|
+
export { ListItemButton };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { Popover as Primitive } from 'radix-ui';
|
|
3
|
+
export declare const Popover: React.FC<Primitive.PopoverProps>;
|
|
4
|
+
export declare const PopoverTrigger: React.ForwardRefExoticComponent<Primitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export declare const PopoverAnchor: React.ForwardRefExoticComponent<Primitive.PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export declare const PopoverContent: React.ForwardRefExoticComponent<Omit<Primitive.PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { Popover as Primitive } from 'radix-ui';
|
|
4
|
+
import { cn } from '../../cn.js';
|
|
5
|
+
export const Popover = Primitive.Root;
|
|
6
|
+
export const PopoverTrigger = Primitive.Trigger;
|
|
7
|
+
export const PopoverAnchor = Primitive.Anchor;
|
|
8
|
+
export const PopoverContent = forwardRef(({ className, align = 'start', sideOffset = 8, ...props }, ref) => _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { ref: ref, align: align, sideOffset: sideOffset, collisionPadding: 12, className: cn('z-50 rounded-[var(--console-radius-lg)] border-[length:var(--console-border-width)] border-[color:var(--console-border-default)] bg-popover p-4 text-popover-foreground shadow-[var(--console-shadow-lg)] outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-1.5 data-[side=top]:slide-in-from-bottom-1.5', className), ...props }) }));
|
|
9
|
+
PopoverContent.displayName = 'PopoverContent';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as Radix from "radix-ui";
|
|
3
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<Omit<Radix.RadioGroup.RadioGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const RadioGroupItem: React.ForwardRefExoticComponent<Omit<Radix.RadioGroup.RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
import { cn } from '../../cn.js';
|
|
5
|
+
const RadioGroupPrimitive = Radix.RadioGroup;
|
|
6
|
+
const RadioGroup = forwardRef(({ className, ...props }, ref) => (_jsx(RadioGroupPrimitive.Root, { className: cn("grid gap-2", className), ...props, ref: ref })));
|
|
7
|
+
RadioGroup.displayName = "RadioGroup";
|
|
8
|
+
const RadioGroupItem = forwardRef(({ className, ...props }, ref) => (_jsx(RadioGroupPrimitive.Item, { ref: ref, className: cn("console-control aspect-square h-4 w-4 shrink-0 rounded-full border border-input bg-card text-primary transition-colors disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary", className), ...props, children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx("span", { className: "h-2 w-2 rounded-full bg-current" }) }) })));
|
|
9
|
+
RadioGroupItem.displayName = "RadioGroupItem";
|
|
10
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as Radix from "radix-ui";
|
|
3
|
+
declare const ScrollArea: React.ForwardRefExoticComponent<Omit<Radix.ScrollArea.ScrollAreaProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const ScrollBar: React.ForwardRefExoticComponent<Omit<Radix.ScrollArea.ScrollAreaScrollbarProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export { ScrollArea, ScrollBar };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
const ScrollAreaPrimitive = Radix.ScrollArea;
|
|
5
|
+
import { cn } from '../../cn.js';
|
|
6
|
+
const ScrollArea = forwardRef(({ className, children, ...props }, ref) => (_jsxs(ScrollAreaPrimitive.Root, { ref: ref, className: cn("relative overflow-hidden", className), ...props, children: [_jsx(ScrollAreaPrimitive.Viewport, { className: "h-full w-full rounded-[inherit]", children: children }), _jsx(ScrollBar, {}), _jsx(ScrollAreaPrimitive.Corner, {})] })));
|
|
7
|
+
ScrollArea.displayName = "ScrollArea";
|
|
8
|
+
const ScrollBar = forwardRef(({ className, orientation: orientationProp, ...props }, ref) => {
|
|
9
|
+
const orientation = (orientationProp ?? "vertical");
|
|
10
|
+
return (_jsx(ScrollAreaPrimitive.Scrollbar, { ref: ref, orientation: orientation, className: cn("flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]", className), ...props, children: _jsx(ScrollAreaPrimitive.Thumb, { className: "relative flex-1 rounded-full bg-border" }) }));
|
|
11
|
+
});
|
|
12
|
+
ScrollBar.displayName = "ScrollBar";
|
|
13
|
+
export { ScrollArea, ScrollBar };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Pure part of SearchableSelectField: which options a query keeps and how they are grouped.
|
|
4
|
+
* Groups appear in the order their first option appears; ungrouped options (such as 「未设置」)
|
|
5
|
+
* come first and are never filtered out, so clearing a choice stays one click away.
|
|
6
|
+
*/
|
|
7
|
+
export interface SearchableSelectOption {
|
|
8
|
+
value: string;
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
/** Heading the option is listed under; omitted for top-level choices such as 「未设置」. */
|
|
11
|
+
group?: string;
|
|
12
|
+
/** Secondary line under the label (e.g. `model · account`). */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** Extra text the search box matches (the label is used when it is a string). */
|
|
15
|
+
keywords?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface SearchableSelectGroup<T extends SearchableSelectOption = SearchableSelectOption> {
|
|
19
|
+
group: string | null;
|
|
20
|
+
options: T[];
|
|
21
|
+
}
|
|
22
|
+
/** Text a query is matched against: explicit keywords, else a string label, plus value, description and group. */
|
|
23
|
+
export declare function optionSearchText(option: SearchableSelectOption): string;
|
|
24
|
+
/** Every whitespace-separated term must appear somewhere in the option's search text. */
|
|
25
|
+
export declare function optionMatches(option: SearchableSelectOption, query: string): boolean;
|
|
26
|
+
/** `[{ group: string | null, options }]` for the options matching `query`; empty groups are dropped. */
|
|
27
|
+
export declare function groupSelectOptions<T extends SearchableSelectOption>(options: readonly T[], query?: string): SearchableSelectGroup<T>[];
|
|
28
|
+
/** Values in display order, for arrow-key movement (disabled options are skipped). */
|
|
29
|
+
export declare function navigableValues(grouped: readonly SearchableSelectGroup[]): string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const normalize = (value) => String(value ?? '').normalize('NFKC').toLocaleLowerCase();
|
|
2
|
+
/** Text a query is matched against: explicit keywords, else a string label, plus value, description and group. */
|
|
3
|
+
export function optionSearchText(option) {
|
|
4
|
+
const label = typeof option.label === 'string' ? option.label : '';
|
|
5
|
+
return normalize([option.keywords ?? '', label, option.value, option.description ?? '', option.group ?? ''].join(' '));
|
|
6
|
+
}
|
|
7
|
+
/** Every whitespace-separated term must appear somewhere in the option's search text. */
|
|
8
|
+
export function optionMatches(option, query) {
|
|
9
|
+
const terms = normalize(query).split(/\s+/u).filter(Boolean);
|
|
10
|
+
if (!terms.length)
|
|
11
|
+
return true;
|
|
12
|
+
const text = optionSearchText(option);
|
|
13
|
+
return terms.every(term => text.includes(term));
|
|
14
|
+
}
|
|
15
|
+
/** `[{ group: string | null, options }]` for the options matching `query`; empty groups are dropped. */
|
|
16
|
+
export function groupSelectOptions(options, query = '') {
|
|
17
|
+
const groups = new Map();
|
|
18
|
+
const loose = [];
|
|
19
|
+
for (const option of options) {
|
|
20
|
+
if (!option.group) {
|
|
21
|
+
if (!query || option.value === '' || optionMatches(option, query))
|
|
22
|
+
loose.push(option);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (!groups.has(option.group))
|
|
26
|
+
groups.set(option.group, []);
|
|
27
|
+
if (optionMatches(option, query))
|
|
28
|
+
groups.get(option.group).push(option);
|
|
29
|
+
}
|
|
30
|
+
return [
|
|
31
|
+
...(loose.length ? [{ group: null, options: loose }] : []),
|
|
32
|
+
...[...groups].filter(([, items]) => items.length).map(([group, items]) => ({ group, options: items })),
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
/** Values in display order, for arrow-key movement (disabled options are skipped). */
|
|
36
|
+
export function navigableValues(grouped) {
|
|
37
|
+
return grouped.flatMap(entry => entry.options.filter(option => !option.disabled).map(option => option.value));
|
|
38
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type SearchableSelectOption } from './searchable-select-model.js';
|
|
3
|
+
export type { SearchableSelectOption };
|
|
4
|
+
export interface SearchableSelectFieldProps {
|
|
5
|
+
options: readonly SearchableSelectOption[];
|
|
6
|
+
value: string;
|
|
7
|
+
onValueChange: (value: string) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
'aria-label'?: string;
|
|
12
|
+
'aria-labelledby'?: string;
|
|
13
|
+
/** Placeholder of the search box. */
|
|
14
|
+
searchPlaceholder?: string;
|
|
15
|
+
/** Shown when nothing matches the search. */
|
|
16
|
+
emptyText?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A select for long lists: a popover with a search box and grouped options (combobox / listbox
|
|
20
|
+
* pattern). Same controlled contract as SelectField (`options` / `value` / `onValueChange`), plus
|
|
21
|
+
* `group`, `description` and `keywords` per option. ↑ / ↓ move, Enter picks, Esc closes.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SearchableSelectField: React.ForwardRefExoticComponent<SearchableSelectFieldProps & React.RefAttributes<HTMLButtonElement>>;
|