@zhin.js/console-ui 1.0.0 → 1.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/CHANGELOG.md +45 -0
- package/README.md +118 -11
- package/audit/index.mjs +21 -0
- package/audit/layout-audit.mjs +492 -0
- package/audit/mount-page.jsx +90 -0
- package/audit/plugin-pages.mjs +186 -0
- package/dist/components/BrandMark.d.ts +16 -0
- package/dist/components/BrandMark.js +21 -0
- package/dist/components/InfoHint.js +2 -1
- package/dist/components/PageHeader.d.ts +9 -2
- package/dist/components/PageHeader.js +6 -3
- package/dist/components/PageShell.d.ts +18 -3
- package/dist/components/PageShell.js +5 -3
- package/dist/components/RefreshControl.d.ts +6 -1
- package/dist/components/RefreshControl.js +9 -6
- package/dist/components/StatCard.d.ts +19 -5
- package/dist/components/StatCard.js +36 -10
- package/dist/components/StatusBadge.d.ts +14 -0
- package/dist/components/StatusBadge.js +19 -0
- package/dist/components/actions.d.ts +53 -0
- package/dist/components/actions.js +50 -0
- package/dist/components/code.d.ts +11 -0
- package/dist/components/code.js +10 -0
- package/dist/components/confirm-dialog.js +3 -2
- package/dist/components/content-blocks.d.ts +141 -0
- package/dist/components/content-blocks.js +77 -0
- package/dist/components/empty-illustrations.d.ts +15 -0
- package/dist/components/empty-illustrations.js +36 -0
- package/dist/components/empty-state.d.ts +23 -3
- package/dist/components/empty-state.js +36 -8
- package/dist/components/error-alert.js +2 -1
- package/dist/components/icon.d.ts +11 -0
- package/dist/components/icon.js +8 -0
- package/dist/components/layout.d.ts +38 -0
- package/dist/components/layout.js +28 -0
- package/dist/components/page-chrome.d.ts +12 -0
- package/dist/components/page-chrome.js +6 -5
- package/dist/components/ui/accordion.js +3 -2
- package/dist/components/ui/alert.js +5 -5
- package/dist/components/ui/badge.js +10 -9
- package/dist/components/ui/button.d.ts +10 -1
- package/dist/components/ui/button.js +26 -11
- package/dist/components/ui/card.d.ts +6 -0
- package/dist/components/ui/card.js +5 -4
- package/dist/components/ui/checkbox.js +2 -1
- package/dist/components/ui/control-variant.d.ts +10 -0
- package/dist/components/ui/control-variant.js +6 -0
- package/dist/components/ui/date-field-model.d.ts +39 -0
- package/dist/components/ui/date-field-model.js +105 -0
- package/dist/components/ui/date-field.d.ts +33 -0
- package/dist/components/ui/date-field.js +161 -0
- package/dist/components/ui/dialog.js +7 -6
- package/dist/components/ui/dropdown-menu.js +6 -5
- package/dist/components/ui/input.d.ts +6 -1
- package/dist/components/ui/input.js +3 -2
- package/dist/components/ui/list-item-button.js +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/scroll-area.js +1 -1
- package/dist/components/ui/searchable-select.d.ts +3 -0
- package/dist/components/ui/searchable-select.js +4 -3
- package/dist/components/ui/select.d.ts +7 -1
- package/dist/components/ui/select.js +7 -5
- package/dist/components/ui/sheet.js +4 -3
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/table.d.ts +11 -0
- package/dist/components/ui/table.js +37 -6
- package/dist/components/ui/tabs.js +3 -3
- package/dist/components/ui/textarea.d.ts +6 -1
- package/dist/components/ui/textarea.js +3 -2
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/use-container-width.d.ts +13 -0
- package/dist/components/use-container-width.js +30 -0
- package/dist/custom-media.css +13 -0
- package/dist/exports.json +41 -1
- package/dist/i18n/messages.d.ts +20 -1
- package/dist/i18n/messages.js +40 -2
- package/dist/index.d.ts +12 -0
- package/dist/index.js +11 -0
- package/dist/scale.json +643 -0
- package/dist/styles.css +1919 -836
- package/dist/theme.css +469 -0
- package/dist/tokens.css +434 -123
- package/dist/version.js +1 -1
- package/lint/eslint-plugin.mjs +128 -0
- package/lint/stylelint-config.mjs +43 -0
- package/lint/stylelint-plugin.mjs +195 -0
- package/lint/tailwind-classes.mjs +121 -0
- package/package.json +33 -3
- package/tokens/color.mjs +104 -0
- package/tokens/colors.css +220 -0
- package/tokens/generate.mjs +288 -0
- package/tokens/scale.mjs +137 -0
- package/tokens/tokens.mjs +362 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { MoreHorizontal } from 'lucide-react';
|
|
4
|
+
import { CONSOLE_ICON_STROKE_WIDTH } from './icon.js';
|
|
5
|
+
import { cn } from '../cn.js';
|
|
6
|
+
import { useConsoleUiI18n } from '../i18n/index.js';
|
|
7
|
+
import { Button } from './ui/button.js';
|
|
8
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from './ui/dropdown-menu.js';
|
|
9
|
+
import { CONSOLE_BREAKPOINTS_REM, useContainerAtLeast } from './use-container-width.js';
|
|
10
|
+
function buttonVariant(action) {
|
|
11
|
+
if (action.tone === 'destructive')
|
|
12
|
+
return 'destructive-outline';
|
|
13
|
+
if (action.tone === 'primary')
|
|
14
|
+
return 'primary';
|
|
15
|
+
return 'outline';
|
|
16
|
+
}
|
|
17
|
+
function ActionButton({ action, size }) {
|
|
18
|
+
const Icon = action.icon;
|
|
19
|
+
return (_jsxs(Button, { type: "button", variant: buttonVariant(action), size: size, disabled: action.disabled, onClick: action.onSelect, children: [Icon ? _jsx(Icon, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, "aria-hidden": "true" }) : null, action.label] }));
|
|
20
|
+
}
|
|
21
|
+
/** The 「更多」 menu: actions that do not get a button of their own. Destructive items come last. */
|
|
22
|
+
export function MoreMenu({ actions, label, size, align = 'end', className }) {
|
|
23
|
+
const i18n = useConsoleUiI18n();
|
|
24
|
+
if (!actions.length)
|
|
25
|
+
return null;
|
|
26
|
+
const regular = actions.filter(action => action.tone !== 'destructive');
|
|
27
|
+
const destructive = actions.filter(action => action.tone === 'destructive');
|
|
28
|
+
const item = (action) => {
|
|
29
|
+
const Icon = action.icon;
|
|
30
|
+
return (_jsxs(DropdownMenuItem, { disabled: action.disabled, onSelect: action.onSelect, className: cn(action.tone === 'destructive' && 'text-destructive focus:text-destructive'), children: [Icon ? _jsx(Icon, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, "aria-hidden": "true" }) : null, action.label] }, action.key ?? action.label));
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", size: size, className: cn('console-more-trigger', className), children: [_jsx(MoreHorizontal, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, "aria-hidden": "true" }), label ?? i18n.t('actions.more')] }) }), _jsxs(DropdownMenuContent, { align: align, children: [regular.map(item), regular.length && destructive.length ? _jsx(DropdownMenuSeparator, {}) : null, destructive.map(item)] })] }));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Header actions (ADR 0063 D18 第 7 条): what does not fit goes into the 「更多」 menu, so no
|
|
36
|
+
* control is ever pushed out of the viewport. Measures its own width, i.e. the header's.
|
|
37
|
+
*/
|
|
38
|
+
export function PageActions({ children, actions = [], moreActions = [], className }) {
|
|
39
|
+
const ref = useRef(null);
|
|
40
|
+
const wide = useContainerAtLeast(ref, CONSOLE_BREAKPOINTS_REM.sm) ?? true;
|
|
41
|
+
const inline = wide ? actions : actions.filter(action => action.tone === 'primary').slice(0, 1);
|
|
42
|
+
const collapsed = [...actions.filter(action => !inline.includes(action)), ...moreActions];
|
|
43
|
+
if (children == null && !actions.length && !moreActions.length)
|
|
44
|
+
return null;
|
|
45
|
+
return (_jsxs("div", { ref: ref, className: cn('console-page-actions', className), "data-slot": "page-actions", children: [children, inline.map(action => _jsx(ActionButton, { action: action }, action.key ?? action.label)), _jsx(MoreMenu, { actions: collapsed })] }));
|
|
46
|
+
}
|
|
47
|
+
/** Actions of one table row or list item: one labelled button, the rest in 「更多」. */
|
|
48
|
+
export function RowActions({ primary, more = [], className }) {
|
|
49
|
+
return (_jsxs("div", { className: cn('inline-flex items-center justify-end gap-2', className), "data-slot": "row-actions", children: [primary ? _jsx(ActionButton, { action: primary, size: "sm" }) : null, _jsx(MoreMenu, { actions: more, size: "sm" })] }));
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
export interface InlineCodeProps extends HTMLAttributes<HTMLElement> {
|
|
3
|
+
/** `subtle` (default): a very light fill; `plain`: no fill, only the monospace face. */
|
|
4
|
+
readonly tone?: 'subtle' | 'plain';
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Short identifiers inside text — package names, RPC names, IDs, cron expressions (ADR 0063 D31):
|
|
8
|
+
* `--console-font-mono`, no border, a very light fill or none. Also available as the
|
|
9
|
+
* `console-code` class for elements that are not React components.
|
|
10
|
+
*/
|
|
11
|
+
export declare function InlineCode({ tone, className, ...props }: InlineCodeProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../cn.js';
|
|
3
|
+
/**
|
|
4
|
+
* Short identifiers inside text — package names, RPC names, IDs, cron expressions (ADR 0063 D31):
|
|
5
|
+
* `--console-font-mono`, no border, a very light fill or none. Also available as the
|
|
6
|
+
* `console-code` class for elements that are not React components.
|
|
7
|
+
*/
|
|
8
|
+
export function InlineCode({ tone = 'subtle', className, ...props }) {
|
|
9
|
+
return _jsx("code", { "data-slot": "code", "data-tone": tone === 'plain' ? 'plain' : undefined, className: cn('console-code', className), ...props });
|
|
10
|
+
}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useConsoleUiI18n } from '../i18n/index.js';
|
|
3
3
|
import { useState, useCallback, useEffect, useId } from 'react';
|
|
4
4
|
import { AlertTriangle, Info } from 'lucide-react';
|
|
5
|
+
import { CONSOLE_ICON_STROKE_WIDTH } from './icon.js';
|
|
5
6
|
import { cn } from '../cn.js';
|
|
6
7
|
import { Dialog, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, DialogClose, } from './ui/dialog.js';
|
|
7
8
|
import { Button } from './ui/button.js';
|
|
@@ -38,12 +39,12 @@ export function ConfirmDialog({ open, onOpenChange, title, description, children
|
|
|
38
39
|
}
|
|
39
40
|
}, [canSubmit, onConfirm, onOpenChange, i18n]);
|
|
40
41
|
const Icon = variant === 'destructive' ? AlertTriangle : Info;
|
|
41
|
-
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsx(DialogHeader, { children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx("span", { className: cn('console-confirm-icon', variant === 'destructive' && 'is-destructive'), "aria-hidden": "true", children: _jsx(Icon, { className: "
|
|
42
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsx(DialogHeader, { children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx("span", { className: cn('console-confirm-icon', variant === 'destructive' && 'is-destructive'), "aria-hidden": "true", children: _jsx(Icon, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-5" }) }), _jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [_jsx(DialogTitle, { children: title }), description && _jsx(DialogDescription, { children: description })] })] }) }), children, confirmText != null && confirmText !== '' && (_jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: inputId, className: "block text-body text-muted-foreground", children: i18n.t("confirm.typeToConfirm", [confirmText]) }), _jsx(Input, { id: inputId, value: typed, autoComplete: "off", spellCheck: false, disabled: loading, onChange: event => setTyped(event.target.value), onKeyDown: event => {
|
|
42
43
|
if (event.key === 'Enter') {
|
|
43
44
|
event.preventDefault();
|
|
44
45
|
void handleConfirm();
|
|
45
46
|
}
|
|
46
|
-
} })] })), error && (_jsx("p", { role: "alert", className: "text-
|
|
47
|
+
} })] })), error && (_jsx("p", { role: "alert", className: "text-body text-destructive break-words", children: i18n.t("confirm.notCompleted", [error]) })), _jsxs(DialogFooter, { className: "border-t border-border/70 pt-3", children: [_jsx(DialogClose, { asChild: true, children: _jsx(Button, { variant: "outline", size: "sm", children: cancelLabel ?? i18n.t("confirm.cancel") }) }), _jsx(Button, { variant: variant === 'destructive' ? 'destructive-solid' : 'primary', size: "sm", onClick: handleConfirm, disabled: !canSubmit, children: loading ? i18n.t("confirm.processing") : (confirmLabel ?? i18n.t("confirm.confirm")) })] })] }) }));
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Hook for imperative confirm dialogs.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Content blocks for plugin pages and the declarative renderers of `@zhin.js/client` (ADR 0063 P2).
|
|
4
|
+
* They complement the P1b layout components and do not repeat them: sections are `Section`, grids
|
|
5
|
+
* `Grid` / `StatGrid`, statistic cards `StatCard`, tables `Table` (which turns rows into cards in a
|
|
6
|
+
* narrow container by itself). The page shell owns the header (title, description, actions,
|
|
7
|
+
* refresh). Layout follows the container the block is placed in (`.console-cq`), never the
|
|
8
|
+
* viewport (D18): key / value lists fold to one column in a narrow container.
|
|
9
|
+
*/
|
|
10
|
+
export type ContentTone = 'neutral' | 'primary' | 'success' | 'warning' | 'danger';
|
|
11
|
+
export interface ContentStackProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
/** `tight` inside a control group, `stack` (default) within a block, `section` between blocks. */
|
|
13
|
+
readonly gap?: 'tight' | 'stack' | 'section';
|
|
14
|
+
readonly direction?: 'column' | 'row';
|
|
15
|
+
/** Rows wrap by default. */
|
|
16
|
+
readonly wrap?: boolean;
|
|
17
|
+
readonly align?: 'start' | 'center' | 'end' | 'baseline' | 'stretch';
|
|
18
|
+
readonly justify?: 'start' | 'center' | 'end' | 'between';
|
|
19
|
+
}
|
|
20
|
+
/** Vertical (default) or horizontal group with a token gap. */
|
|
21
|
+
export declare function ContentStack({ gap, direction, wrap, align, justify, className, ...rest }: ContentStackProps): import("react").JSX.Element;
|
|
22
|
+
export interface FormFieldProps {
|
|
23
|
+
readonly label: ReactNode;
|
|
24
|
+
readonly hint?: ReactNode;
|
|
25
|
+
readonly error?: ReactNode;
|
|
26
|
+
readonly required?: boolean;
|
|
27
|
+
/** `id` of the control, so the label is clickable. */
|
|
28
|
+
readonly htmlFor?: string;
|
|
29
|
+
/** Spans the whole row of a `Grid`. */
|
|
30
|
+
readonly full?: boolean;
|
|
31
|
+
readonly className?: string;
|
|
32
|
+
readonly children?: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/** Label, control, hint and error of one form field. */
|
|
35
|
+
export declare function FormField({ label, hint, error, required, htmlFor, full, className, children }: FormFieldProps): import("react").JSX.Element;
|
|
36
|
+
export interface KeyValueItem {
|
|
37
|
+
readonly key?: string;
|
|
38
|
+
readonly label: ReactNode;
|
|
39
|
+
readonly value: ReactNode;
|
|
40
|
+
readonly hint?: ReactNode;
|
|
41
|
+
/** Greys the value out (e.g. a configured but disabled schedule). */
|
|
42
|
+
readonly muted?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface KeyValueListProps {
|
|
45
|
+
readonly items: readonly KeyValueItem[];
|
|
46
|
+
/** Columns in a wide container; always one in a narrow one. */
|
|
47
|
+
readonly columns?: 1 | 2 | 3;
|
|
48
|
+
readonly className?: string;
|
|
49
|
+
}
|
|
50
|
+
/** Description list (`dl`) of label / value pairs. */
|
|
51
|
+
export declare function KeyValueList({ items, columns, className }: KeyValueListProps): import("react").JSX.Element;
|
|
52
|
+
export interface ProgressMeterProps {
|
|
53
|
+
readonly value: number;
|
|
54
|
+
readonly max?: number;
|
|
55
|
+
readonly tone?: ContentTone;
|
|
56
|
+
/** Shows the percentage next to the bar. */
|
|
57
|
+
readonly showValue?: boolean;
|
|
58
|
+
/** Accessible name. */
|
|
59
|
+
readonly label?: string;
|
|
60
|
+
}
|
|
61
|
+
/** Horizontal progress bar (`role="progressbar"`). */
|
|
62
|
+
export declare function ProgressMeter({ value, max, tone, showValue, label }: ProgressMeterProps): import("react").JSX.Element;
|
|
63
|
+
export interface SparklineProps {
|
|
64
|
+
readonly values: readonly number[];
|
|
65
|
+
readonly tone?: ContentTone;
|
|
66
|
+
readonly label?: string;
|
|
67
|
+
}
|
|
68
|
+
/** Tiny trend line; needs at least two finite values. */
|
|
69
|
+
export declare function Sparkline({ values, tone, label }: SparklineProps): import("react").JSX.Element | null;
|
|
70
|
+
export interface TimelineItem {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
readonly title: ReactNode;
|
|
73
|
+
readonly description?: ReactNode;
|
|
74
|
+
readonly time?: ReactNode;
|
|
75
|
+
readonly tone?: ContentTone;
|
|
76
|
+
readonly badge?: ReactNode;
|
|
77
|
+
}
|
|
78
|
+
/** Vertical event list. */
|
|
79
|
+
export declare function Timeline({ items }: {
|
|
80
|
+
readonly items: readonly TimelineItem[];
|
|
81
|
+
}): import("react").JSX.Element;
|
|
82
|
+
export interface DisclosureProps {
|
|
83
|
+
readonly summary: ReactNode;
|
|
84
|
+
readonly description?: ReactNode;
|
|
85
|
+
/** Next to the summary (e.g. a count). */
|
|
86
|
+
readonly badge?: ReactNode;
|
|
87
|
+
readonly defaultOpen?: boolean;
|
|
88
|
+
readonly className?: string;
|
|
89
|
+
readonly children?: ReactNode;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Collapsed by default (`details` / `summary`): for secondary content such as raw IDs and JSON, which
|
|
93
|
+
* plugin pages do not show by default (D18 第 6 条), and for collapsible sections.
|
|
94
|
+
*/
|
|
95
|
+
export declare function Disclosure({ summary, description, badge, defaultOpen, className, children }: DisclosureProps): import("react").JSX.Element;
|
|
96
|
+
/** Inline monospace value (IDs, cron expressions, paths); the same look as `InlineCode` (ADR 0063 D31). */
|
|
97
|
+
export declare function CodeText({ children, className }: {
|
|
98
|
+
readonly children?: ReactNode;
|
|
99
|
+
readonly className?: string;
|
|
100
|
+
}): import("react").JSX.Element;
|
|
101
|
+
/** Pretty-printed JSON in a scrollable block. */
|
|
102
|
+
export declare function JsonBlock({ value, className }: {
|
|
103
|
+
readonly value: unknown;
|
|
104
|
+
readonly className?: string;
|
|
105
|
+
}): import("react").JSX.Element;
|
|
106
|
+
/** Image result (QR codes, previews) at a bounded size on a light backing. */
|
|
107
|
+
export declare function MediaPreview({ src, alt, className }: {
|
|
108
|
+
readonly src: string;
|
|
109
|
+
readonly alt: string;
|
|
110
|
+
readonly className?: string;
|
|
111
|
+
}): import("react").JSX.Element;
|
|
112
|
+
export interface RecordCardField {
|
|
113
|
+
readonly key: string;
|
|
114
|
+
readonly label: ReactNode;
|
|
115
|
+
readonly value: ReactNode;
|
|
116
|
+
}
|
|
117
|
+
export interface RecordCardProps {
|
|
118
|
+
/** First line of the card. */
|
|
119
|
+
readonly title?: ReactNode;
|
|
120
|
+
/** Before the title (checkbox, toggle). */
|
|
121
|
+
readonly leading?: ReactNode;
|
|
122
|
+
/** Label / value pairs, shown as a one-column {@link KeyValueList}. */
|
|
123
|
+
readonly fields?: readonly RecordCardField[];
|
|
124
|
+
readonly actions?: ReactNode;
|
|
125
|
+
readonly selected?: boolean;
|
|
126
|
+
readonly children?: ReactNode;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* One record (an account, a connection) as a card: the P1b `Card` with a header, a one-column
|
|
130
|
+
* {@link KeyValueList} and a footer for actions. For table rows use `Table`, which turns its rows
|
|
131
|
+
* into cards by itself in a narrow container.
|
|
132
|
+
*/
|
|
133
|
+
export declare function RecordCard({ title, leading, fields, actions, selected, children }: RecordCardProps): import("react").JSX.Element;
|
|
134
|
+
export interface LoadingBlockProps {
|
|
135
|
+
/** Accessible name of the busy region (e.g. 「加载中…」). */
|
|
136
|
+
readonly label: string;
|
|
137
|
+
/** Placeholder lines; default 2. */
|
|
138
|
+
readonly lines?: number;
|
|
139
|
+
}
|
|
140
|
+
/** Placeholder while a block loads: a `role="status"` region with skeleton text lines. */
|
|
141
|
+
export declare function LoadingBlock({ label, lines }: LoadingBlockProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../cn.js';
|
|
3
|
+
import { Card, CardContent, CardFooter, CardHeader } from './ui/card.js';
|
|
4
|
+
import { Skeleton } from './ui/skeleton.js';
|
|
5
|
+
/** Vertical (default) or horizontal group with a token gap. */
|
|
6
|
+
export function ContentStack({ gap = 'stack', direction = 'column', wrap, align, justify, className, ...rest }) {
|
|
7
|
+
return (_jsx("div", { className: cn('console-content-stack', `is-gap-${gap}`, direction === 'row' && 'is-row', direction === 'row' && wrap !== false && 'is-wrap', align && `is-align-${align}`, justify && `is-justify-${justify}`, className), ...rest }));
|
|
8
|
+
}
|
|
9
|
+
/** Label, control, hint and error of one form field. */
|
|
10
|
+
export function FormField({ label, hint, error, required, htmlFor, full, className, children }) {
|
|
11
|
+
return (_jsxs("div", { className: cn('console-form-field', full && 'is-full', className), children: [_jsxs("label", { className: "console-form-field-label", htmlFor: htmlFor, children: [label, required ? _jsx("span", { className: "console-form-field-required", "aria-hidden": "true", children: "*" }) : null] }), children, hint != null ? _jsx("span", { className: "console-form-field-hint", children: hint }) : null, error != null ? _jsx("span", { className: "console-form-field-error", role: "alert", children: error }) : null] }));
|
|
12
|
+
}
|
|
13
|
+
/** Description list (`dl`) of label / value pairs. */
|
|
14
|
+
export function KeyValueList({ items, columns = 2, className }) {
|
|
15
|
+
return (_jsx("div", { className: "console-cq", children: _jsx("dl", { className: cn('console-kv', `is-cols-${columns}`, className), children: items.map((item, index) => (_jsxs("div", { className: "console-kv-item", children: [_jsxs("dt", { className: "console-kv-label", children: [item.label, item.hint != null ? _jsx("span", { className: "console-kv-hint", children: item.hint }) : null] }), _jsx("dd", { className: cn('console-kv-value', item.muted && 'is-muted'), "data-muted": item.muted ? 'true' : undefined, children: item.value })] }, item.key ?? index))) }) }));
|
|
16
|
+
}
|
|
17
|
+
/** Horizontal progress bar (`role="progressbar"`). */
|
|
18
|
+
export function ProgressMeter({ value, max = 100, tone = 'primary', showValue, label }) {
|
|
19
|
+
const safeMax = max > 0 ? max : 100;
|
|
20
|
+
const clamped = Math.max(0, Math.min(safeMax, Number.isFinite(value) ? value : 0));
|
|
21
|
+
const percent = Math.round((clamped / safeMax) * 100);
|
|
22
|
+
return (_jsxs("span", { className: "console-progress", "data-tone": tone, children: [_jsx("span", { className: "console-progress-track", role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": safeMax, "aria-valuenow": clamped, children: _jsx("span", { className: "console-progress-bar", style: { width: `${percent}%` } }) }), showValue ? _jsxs("span", { className: "console-progress-value", children: [percent, "%"] }) : null] }));
|
|
23
|
+
}
|
|
24
|
+
/** Tiny trend line; needs at least two finite values. */
|
|
25
|
+
export function Sparkline({ values, tone = 'primary', label }) {
|
|
26
|
+
const points = values.filter(Number.isFinite);
|
|
27
|
+
if (points.length < 2)
|
|
28
|
+
return null;
|
|
29
|
+
const min = Math.min(...points);
|
|
30
|
+
const max = Math.max(...points);
|
|
31
|
+
const span = max - min || 1;
|
|
32
|
+
const step = 100 / (points.length - 1);
|
|
33
|
+
const d = points.map((point, index) => `${index === 0 ? 'M' : 'L'}${(index * step).toFixed(2)},${(30 - ((point - min) / span) * 28 - 1).toFixed(2)}`).join(' ');
|
|
34
|
+
return (_jsx("svg", { className: "console-sparkline", "data-tone": tone, viewBox: "0 0 100 30", preserveAspectRatio: "none", role: label ? 'img' : undefined, "aria-label": label, "aria-hidden": label ? undefined : true, children: _jsx("path", { d: d, fill: "none", vectorEffect: "non-scaling-stroke" }) }));
|
|
35
|
+
}
|
|
36
|
+
/** Vertical event list. */
|
|
37
|
+
export function Timeline({ items }) {
|
|
38
|
+
return (_jsx("ol", { className: "console-timeline", children: items.map(item => (_jsxs("li", { className: "console-timeline-item", "data-tone": item.tone ?? 'neutral', children: [_jsx("span", { className: "console-timeline-dot", "aria-hidden": "true" }), _jsxs("div", { className: "console-timeline-body", children: [_jsxs("div", { className: "console-timeline-head", children: [_jsx("span", { className: "console-timeline-title", children: item.title }), item.badge, item.time != null ? _jsx("span", { className: "console-timeline-time", children: item.time }) : null] }), item.description != null ? _jsx("p", { className: "console-timeline-description", children: item.description }) : null] })] }, item.id))) }));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Collapsed by default (`details` / `summary`): for secondary content such as raw IDs and JSON, which
|
|
42
|
+
* plugin pages do not show by default (D18 第 6 条), and for collapsible sections.
|
|
43
|
+
*/
|
|
44
|
+
export function Disclosure({ summary, description, badge, defaultOpen, className, children }) {
|
|
45
|
+
return (_jsxs("details", { className: cn('console-disclosure', className), open: defaultOpen || undefined, children: [_jsxs("summary", { className: "console-disclosure-summary", children: [_jsx("span", { className: "console-disclosure-title", children: summary }), badge, description != null ? _jsx("span", { className: "console-disclosure-description", children: description }) : null] }), _jsx("div", { className: "console-disclosure-body", children: children })] }));
|
|
46
|
+
}
|
|
47
|
+
/** Inline monospace value (IDs, cron expressions, paths); the same look as `InlineCode` (ADR 0063 D31). */
|
|
48
|
+
export function CodeText({ children, className }) {
|
|
49
|
+
return _jsx("code", { "data-slot": "code", className: cn('console-code console-code-text', className), children: children });
|
|
50
|
+
}
|
|
51
|
+
/** Pretty-printed JSON in a scrollable block. */
|
|
52
|
+
export function JsonBlock({ value, className }) {
|
|
53
|
+
let text;
|
|
54
|
+
try {
|
|
55
|
+
text = typeof value === 'string' ? value : JSON.stringify(value, null, 2) ?? String(value);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
text = String(value);
|
|
59
|
+
}
|
|
60
|
+
return _jsx("pre", { className: cn('console-json-block', className), children: text });
|
|
61
|
+
}
|
|
62
|
+
/** Image result (QR codes, previews) at a bounded size on a light backing. */
|
|
63
|
+
export function MediaPreview({ src, alt, className }) {
|
|
64
|
+
return _jsx("img", { src: src, alt: alt, className: cn('console-media-preview', className) });
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* One record (an account, a connection) as a card: the P1b `Card` with a header, a one-column
|
|
68
|
+
* {@link KeyValueList} and a footer for actions. For table rows use `Table`, which turns its rows
|
|
69
|
+
* into cards by itself in a narrow container.
|
|
70
|
+
*/
|
|
71
|
+
export function RecordCard({ title, leading, fields = [], actions, selected, children }) {
|
|
72
|
+
return (_jsxs(Card, { "data-selected": selected ? 'true' : undefined, "data-slot": "record-card", children: [title != null || leading != null ? (_jsx(CardHeader, { children: _jsxs("div", { className: "console-record-card-head", children: [leading, title != null ? _jsx("div", { className: "console-record-card-title", children: title }) : null] }) })) : null, fields.length > 0 || children != null ? (_jsx(CardContent, { children: _jsxs(ContentStack, { children: [fields.length > 0 ? _jsx(KeyValueList, { columns: 1, items: fields }) : null, children] }) })) : null, actions != null ? _jsx(CardFooter, { children: _jsx("div", { className: "console-page-actions", children: actions }) }) : null] }));
|
|
73
|
+
}
|
|
74
|
+
/** Placeholder while a block loads: a `role="status"` region with skeleton text lines. */
|
|
75
|
+
export function LoadingBlock({ label, lines = 2 }) {
|
|
76
|
+
return (_jsx("div", { role: "status", "aria-live": "polite", "aria-label": label, "data-loading": "", className: "console-loading-block", children: Array.from({ length: Math.max(1, lines) }, (_, index) => _jsx(Skeleton, { className: "console-skeleton-line" }, index)) }));
|
|
77
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Line-art illustrations of `EmptyState` (ADR 0063 D28, zhinjs/console#125): drawn on a 64 × 64
|
|
3
|
+
* grid, one 1.5px stroke (kept at 1.5px at every size), no fill, a single color — `brand-text`
|
|
4
|
+
* from the `.console-empty-art` class, i.e. `currentColor`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EMPTY_ILLUSTRATIONS: readonly ["messages", "tasks", "logs", "table", "record", "not-found", "generic"];
|
|
7
|
+
export type EmptyIllustrationName = (typeof EMPTY_ILLUSTRATIONS)[number];
|
|
8
|
+
export interface EmptyIllustrationProps {
|
|
9
|
+
readonly name: EmptyIllustrationName;
|
|
10
|
+
/** Pixel size; 64 by default (48 in a compact `EmptyState`). The stroke stays 1.5px. */
|
|
11
|
+
readonly size?: number;
|
|
12
|
+
readonly className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** One empty-state illustration (decorative: `aria-hidden`). */
|
|
15
|
+
export declare function EmptyIllustration({ name, size, className }: EmptyIllustrationProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../cn.js';
|
|
3
|
+
/**
|
|
4
|
+
* Line-art illustrations of `EmptyState` (ADR 0063 D28, zhinjs/console#125): drawn on a 64 × 64
|
|
5
|
+
* grid, one 1.5px stroke (kept at 1.5px at every size), no fill, a single color — `brand-text`
|
|
6
|
+
* from the `.console-empty-art` class, i.e. `currentColor`.
|
|
7
|
+
*/
|
|
8
|
+
export const EMPTY_ILLUSTRATIONS = Object.freeze([
|
|
9
|
+
'messages',
|
|
10
|
+
'tasks',
|
|
11
|
+
'logs',
|
|
12
|
+
'table',
|
|
13
|
+
'record',
|
|
14
|
+
'not-found',
|
|
15
|
+
'generic',
|
|
16
|
+
]);
|
|
17
|
+
const ART = {
|
|
18
|
+
// 无消息: a speech bubble in front of a second one.
|
|
19
|
+
messages: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M48 24h4a4 4 0 0 1 4 4v10a4 4 0 0 1-4 4h-3v5l-6-5h-9" }), _jsx("path", { d: "M12 16h28a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H24l-7 6v-6h-5a4 4 0 0 1-4-4V20a4 4 0 0 1 4-4z" }), _jsx("path", { d: "M16 24h20" }), _jsx("path", { d: "M16 30h12" }), _jsx("path", { d: "M54 8v6M51 11h6" })] })),
|
|
20
|
+
// 无任务: a clipboard with two ticked items and an open one.
|
|
21
|
+
tasks: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M22 14h-6a4 4 0 0 0-4 4v32a4 4 0 0 0 4 4h28a4 4 0 0 0 4-4V18a4 4 0 0 0-4-4h-6" }), _jsx("path", { d: "M25 10h10a3 3 0 0 1 3 3v2a3 3 0 0 1-3 3H25a3 3 0 0 1-3-3v-2a3 3 0 0 1 3-3z" }), _jsx("path", { d: "M19 27l2.5 2.5L26 25" }), _jsx("path", { d: "M30 27h11" }), _jsx("path", { d: "M19 36l2.5 2.5L26 34" }), _jsx("path", { d: "M30 36h11" }), _jsx("circle", { cx: "22.5", cy: "45", r: "2.5" }), _jsx("path", { d: "M30 45h7" })] })),
|
|
22
|
+
// 无日志: a terminal window with a prompt and nothing after it.
|
|
23
|
+
logs: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M12 12h40a4 4 0 0 1 4 4v32a4 4 0 0 1-4 4H12a4 4 0 0 1-4-4V16a4 4 0 0 1 4-4z" }), _jsx("path", { d: "M8 20h48" }), _jsx("path", { d: "M13 16h.01M17 16h.01M21 16h.01" }), _jsx("path", { d: "M15 29l4 3-4 3" }), _jsx("path", { d: "M23 35h8" }), _jsx("path", { d: "M15 43h18M37 43h6" })] })),
|
|
24
|
+
// 未选中数据表: a database with a pointer — pick a table first.
|
|
25
|
+
table: (_jsxs(_Fragment, { children: [_jsx("ellipse", { cx: "28", cy: "16", rx: "14", ry: "5" }), _jsx("path", { d: "M14 16v28c0 2.8 6.3 5 14 5s14-2.2 14-5V16" }), _jsx("path", { d: "M14 26c0 2.8 6.3 5 14 5s14-2.2 14-5" }), _jsx("path", { d: "M14 35c0 2.8 6.3 5 14 5s14-2.2 14-5" }), _jsx("path", { d: "M45 39l11 4.5-5 2-2 5z" })] })),
|
|
26
|
+
// 未选中记录: a list whose middle row is waiting to be picked.
|
|
27
|
+
record: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "8", y: "10", width: "40", height: "11", rx: "3" }), _jsx("rect", { x: "8", y: "26.5", width: "40", height: "11", rx: "3", strokeDasharray: "3 3" }), _jsx("rect", { x: "8", y: "43", width: "40", height: "11", rx: "3" }), _jsx("path", { d: "M13 15.5h16M13 48.5h12" }), _jsx("path", { d: "M42 30l11 4.5-5 2-2 5z" })] })),
|
|
28
|
+
// 找不到页面: a page with a folded corner and a question mark.
|
|
29
|
+
'not-found': (_jsxs(_Fragment, { children: [_jsx("path", { d: "M20 8h18l12 12v32a4 4 0 0 1-4 4H20a4 4 0 0 1-4-4V12a4 4 0 0 1 4-4z" }), _jsx("path", { d: "M38 8v8a4 4 0 0 0 4 4h8" }), _jsx("path", { d: "M28 30a5 5 0 1 1 7.5 4.3c-1.5.9-2.5 2-2.5 3.7V39" }), _jsx("path", { d: "M33 45h.01" })] })),
|
|
30
|
+
// 通用空: an empty tray.
|
|
31
|
+
generic: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M8 36l8-18h32l8 18" }), _jsx("path", { d: "M8 36v12a4 4 0 0 0 4 4h40a4 4 0 0 0 4-4V36" }), _jsx("path", { d: "M8 36h14l3 6h14l3-6h14" }), _jsx("path", { d: "M32 6v6M22 9l2.5 4M42 9l-2.5 4" })] })),
|
|
32
|
+
};
|
|
33
|
+
/** One empty-state illustration (decorative: `aria-hidden`). */
|
|
34
|
+
export function EmptyIllustration({ name, size, className }) {
|
|
35
|
+
return (_jsx("svg", { className: cn('console-empty-art', className), "data-illustration": name, style: size === undefined ? undefined : { width: size, height: size }, viewBox: "0 0 64 64", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", children: ART[name] }));
|
|
36
|
+
}
|
|
@@ -1,15 +1,35 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import type { LucideIcon } from 'lucide-react';
|
|
3
|
+
import { type EmptyIllustrationName } from './empty-illustrations.js';
|
|
4
|
+
/** The one action of an empty state (ADR 0063 D28): a `soft` button by default, `primary` on request. */
|
|
5
|
+
export interface EmptyStateAction {
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly onSelect?: () => void;
|
|
8
|
+
/** Renders a link styled as the button instead of a `<button>`. */
|
|
9
|
+
readonly href?: string;
|
|
10
|
+
/** `soft` (default) or `primary`. A view keeps at most one `primary` (D25). */
|
|
11
|
+
readonly variant?: 'primary' | 'soft';
|
|
12
|
+
readonly icon?: LucideIcon;
|
|
13
|
+
readonly disabled?: boolean;
|
|
14
|
+
}
|
|
2
15
|
export interface EmptyStateProps {
|
|
16
|
+
/** Line-art illustration (64px, 48px when compact); takes precedence over `icon`. */
|
|
17
|
+
illustration?: EmptyIllustrationName;
|
|
18
|
+
/** Lucide icon, used when there is no `illustration` (kept for compatibility). */
|
|
3
19
|
icon?: LucideIcon;
|
|
4
20
|
title?: string;
|
|
21
|
+
/** The one sentence of the empty state. Without `title` and `description` the illustration's default sentence is used. */
|
|
5
22
|
description?: string;
|
|
23
|
+
/** One action: an `EmptyStateAction` (rendered as a soft or primary `Button`) or your own element. */
|
|
24
|
+
action?: EmptyStateAction | ReactNode;
|
|
6
25
|
className?: string;
|
|
7
26
|
/** 嵌入表格/卡片内时使用更紧凑的样式 */
|
|
8
27
|
compact?: boolean;
|
|
9
28
|
}
|
|
10
29
|
/**
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
30
|
+
* 统一空状态组件(ADR 0063 D28):64px 线稿插画(或图标)+ 一句说明 + 可选的一个操作。
|
|
31
|
+
* - 插画与图标都是 `brand-text` 单色、1.5px 描边,不再是半透明的灰图标
|
|
32
|
+
* - 只给了插画时用插画的默认说明;不再单独显示「暂无数据」
|
|
13
33
|
* - compact 模式用于表格行/卡片内嵌场景
|
|
14
34
|
*/
|
|
15
|
-
export declare function EmptyState({ icon: Icon, title, description, className, compact }: EmptyStateProps): import("react").JSX.Element;
|
|
35
|
+
export declare function EmptyState({ illustration, icon: Icon, title, description, action, className, compact }: EmptyStateProps): import("react").JSX.Element;
|
|
@@ -1,15 +1,43 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement } from 'react';
|
|
2
3
|
import { useConsoleUiI18n } from '../i18n/index.js';
|
|
3
4
|
import { cn } from '../cn.js';
|
|
5
|
+
import { Button } from './ui/button.js';
|
|
6
|
+
import { EmptyIllustration } from './empty-illustrations.js';
|
|
7
|
+
import { CONSOLE_ICON_STROKE_WIDTH } from './icon.js';
|
|
8
|
+
const DEFAULT_COPY = {
|
|
9
|
+
messages: 'empty.messages',
|
|
10
|
+
tasks: 'empty.tasks',
|
|
11
|
+
logs: 'empty.logs',
|
|
12
|
+
table: 'empty.table',
|
|
13
|
+
record: 'empty.record',
|
|
14
|
+
'not-found': 'empty.notFound',
|
|
15
|
+
generic: 'empty.noData',
|
|
16
|
+
};
|
|
17
|
+
function isAction(action) {
|
|
18
|
+
return typeof action === 'object' && action !== null && !isValidElement(action) && 'label' in action;
|
|
19
|
+
}
|
|
20
|
+
function EmptyStateActionButton({ action }) {
|
|
21
|
+
const Icon = action.icon;
|
|
22
|
+
const variant = action.variant ?? 'soft';
|
|
23
|
+
const content = _jsxs(_Fragment, { children: [Icon ? _jsx(Icon, { "aria-hidden": "true", strokeWidth: CONSOLE_ICON_STROKE_WIDTH }) : null, action.label] });
|
|
24
|
+
if (action.href !== undefined && !action.disabled) {
|
|
25
|
+
return _jsx(Button, { asChild: true, variant: variant, children: _jsx("a", { href: action.href, onClick: action.onSelect, children: content }) });
|
|
26
|
+
}
|
|
27
|
+
return _jsx(Button, { type: "button", variant: variant, disabled: action.disabled, onClick: action.onSelect, children: content });
|
|
28
|
+
}
|
|
4
29
|
/**
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
30
|
+
* 统一空状态组件(ADR 0063 D28):64px 线稿插画(或图标)+ 一句说明 + 可选的一个操作。
|
|
31
|
+
* - 插画与图标都是 `brand-text` 单色、1.5px 描边,不再是半透明的灰图标
|
|
32
|
+
* - 只给了插画时用插画的默认说明;不再单独显示「暂无数据」
|
|
7
33
|
* - compact 模式用于表格行/卡片内嵌场景
|
|
8
34
|
*/
|
|
9
|
-
export function EmptyState({ icon: Icon, title, description, className, compact }) {
|
|
35
|
+
export function EmptyState({ illustration, icon: Icon, title, description, action, className, compact }) {
|
|
10
36
|
const i18n = useConsoleUiI18n();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
const sentence = description ?? (title ? undefined : i18n.t(DEFAULT_COPY[illustration ?? 'generic']));
|
|
38
|
+
const art = illustration
|
|
39
|
+
? _jsx(EmptyIllustration, { name: illustration })
|
|
40
|
+
: Icon ? _jsx(Icon, { "aria-hidden": "true", className: "console-empty-icon", strokeWidth: 1.5 }) : null;
|
|
41
|
+
const actionNode = action == null || action === false ? null : isAction(action) ? _jsx(EmptyStateActionButton, { action: action }) : action;
|
|
42
|
+
return (_jsxs("div", { className: cn('console-empty', className), "data-slot": "empty-state", "data-compact": compact ? '' : undefined, children: [art, title ? (compact ? _jsx("p", { className: "console-empty-title", children: title }) : _jsx("h3", { className: "console-empty-title", children: title })) : null, sentence ? _jsx("p", { className: "console-empty-description", children: sentence }) : null, actionNode ? _jsx("div", { className: "console-empty-action", children: actionNode }) : null] }));
|
|
15
43
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useConsoleUiI18n } from '../i18n/index.js';
|
|
3
3
|
import { AlertCircle, RefreshCw, Info } from 'lucide-react';
|
|
4
|
+
import { CONSOLE_ICON_STROKE_WIDTH } from './icon.js';
|
|
4
5
|
import { Alert, AlertDescription } from './ui/alert.js';
|
|
5
6
|
import { Button } from './ui/button.js';
|
|
6
7
|
function variantForKind(kind) {
|
|
@@ -18,5 +19,5 @@ function variantForKind(kind) {
|
|
|
18
19
|
export function ErrorAlert({ error, onRetry, className, kind = 'other', technicalDetail }) {
|
|
19
20
|
const i18n = useConsoleUiI18n();
|
|
20
21
|
const Icon = kind === '404' ? Info : AlertCircle;
|
|
21
|
-
return (_jsxs(Alert, { variant: variantForKind(kind), className: className, children: [_jsx(Icon, { className: "
|
|
22
|
+
return (_jsxs(Alert, { variant: variantForKind(kind), className: className, children: [_jsx(Icon, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-4" }), _jsxs(AlertDescription, { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("span", { children: error }), onRetry && (_jsxs(Button, { variant: "outline", size: "sm", onClick: onRetry, className: "shrink-0", children: [_jsx(RefreshCw, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, "aria-hidden": "true" }), i18n.t("error.retry")] }))] }), technicalDetail ? (_jsxs("details", { className: "text-label", children: [_jsx("summary", { className: "min-h-touch-min cursor-pointer", children: i18n.t("error.technicalDetail") }), _jsx("pre", { className: "mt-2 whitespace-pre-wrap break-words", children: technicalDetail })] })) : null] })] }));
|
|
22
23
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icon rules of @zhin.js/console-ui (ADR 0063 D30, zhinjs/console#125): lucide icons only, one
|
|
3
|
+
* stroke width everywhere, 16px inside controls and 18px in navigation. Icons sit directly on the
|
|
4
|
+
* surface; lists, ⌘K and toolbars never put them in a tinted square.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CONSOLE_ICON_STROKE_WIDTH = 1.75;
|
|
7
|
+
/** Icon sizes in px: `control` inside buttons, inputs, menus and badges; `nav` in navigation. */
|
|
8
|
+
export declare const CONSOLE_ICON_SIZE: Readonly<{
|
|
9
|
+
readonly control: 16;
|
|
10
|
+
readonly nav: 18;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icon rules of @zhin.js/console-ui (ADR 0063 D30, zhinjs/console#125): lucide icons only, one
|
|
3
|
+
* stroke width everywhere, 16px inside controls and 18px in navigation. Icons sit directly on the
|
|
4
|
+
* surface; lists, ⌘K and toolbars never put them in a tinted square.
|
|
5
|
+
*/
|
|
6
|
+
export const CONSOLE_ICON_STROKE_WIDTH = 1.75;
|
|
7
|
+
/** Icon sizes in px: `control` inside buttons, inputs, menus and badges; `nav` in navigation. */
|
|
8
|
+
export const CONSOLE_ICON_SIZE = Object.freeze({ control: 16, nav: 18 });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export interface SectionProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
3
|
+
title?: ReactNode;
|
|
4
|
+
/** Said once, under the title (D15 第 2 条). */
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
actions?: ReactNode;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A content block of a page: title, one description, actions, then its content (stack gap). */
|
|
11
|
+
export declare function Section({ title, description, actions, children, className, ...rest }: SectionProps): import("react").JSX.Element;
|
|
12
|
+
export interface GridProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/** Narrowest column before the grid drops a column; default 16rem. */
|
|
15
|
+
min?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Accessible name when the grid is a landmark of its own. */
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Card grid: `repeat(auto-fit, minmax(min(100%, min), 1fr))` with the grid gap (D18 第 3 条). */
|
|
21
|
+
export declare function Grid({ children, min, className, label, style: ownStyle, ...rest }: GridProps): import("react").JSX.Element;
|
|
22
|
+
export interface ListDetailProps {
|
|
23
|
+
/** The list (usually a Table). */
|
|
24
|
+
list: ReactNode;
|
|
25
|
+
/** Detail of the selected item; `null` / `undefined` when nothing is selected. */
|
|
26
|
+
detail?: ReactNode;
|
|
27
|
+
/** Title of the detail panel (used by the sheet on narrow containers). */
|
|
28
|
+
detailTitle?: ReactNode;
|
|
29
|
+
/** Called when the user closes the detail sheet on narrow containers. */
|
|
30
|
+
onDetailClose?: () => void;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List + detail (ADR 0063 D18 第 5 条): from 90rem of container width the detail sits in a right
|
|
35
|
+
* column next to the list; below that it opens in a side sheet. Pages must not build this
|
|
36
|
+
* themselves.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ListDetail({ list, detail, detailTitle, onDetailClose, className }: ListDetailProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { cn } from '../cn.js';
|
|
4
|
+
import { useConsoleUiI18n } from '../i18n/index.js';
|
|
5
|
+
import { Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle } from './ui/sheet.js';
|
|
6
|
+
import { CONSOLE_BREAKPOINTS_REM, useContainerAtLeast } from './use-container-width.js';
|
|
7
|
+
/** A content block of a page: title, one description, actions, then its content (stack gap). */
|
|
8
|
+
export function Section({ title, description, actions, children, className, ...rest }) {
|
|
9
|
+
return (_jsxs("section", { className: cn('console-section', className), "data-slot": "section", ...rest, children: [title != null || description != null || actions != null ? (_jsxs("div", { className: "console-section-header", children: [_jsxs("div", { className: "console-section-heading", children: [title != null ? _jsx("h2", { className: "console-section-title", children: title }) : null, description != null ? _jsx("p", { className: "console-section-description", children: description }) : null] }), actions != null ? _jsx("div", { className: "console-page-actions", children: actions }) : null] })) : null, children] }));
|
|
10
|
+
}
|
|
11
|
+
/** Card grid: `repeat(auto-fit, minmax(min(100%, min), 1fr))` with the grid gap (D18 第 3 条). */
|
|
12
|
+
export function Grid({ children, min, className, label, style: ownStyle, ...rest }) {
|
|
13
|
+
const style = min ? { ...ownStyle, '--grid-min': min } : ownStyle;
|
|
14
|
+
return (_jsx("div", { className: cn('console-grid', className), style: style, "data-slot": "grid", role: label ? 'group' : undefined, "aria-label": label, ...rest, children: children }));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* List + detail (ADR 0063 D18 第 5 条): from 90rem of container width the detail sits in a right
|
|
18
|
+
* column next to the list; below that it opens in a side sheet. Pages must not build this
|
|
19
|
+
* themselves.
|
|
20
|
+
*/
|
|
21
|
+
export function ListDetail({ list, detail, detailTitle, onDetailClose, className }) {
|
|
22
|
+
const i18n = useConsoleUiI18n();
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
const split = useContainerAtLeast(ref, CONSOLE_BREAKPOINTS_REM.xl) ?? false;
|
|
25
|
+
const hasDetail = detail != null;
|
|
26
|
+
return (_jsxs("div", { ref: ref, className: cn('console-list-detail-frame', className), "data-slot": "list-detail", children: [_jsxs("div", { className: "console-list-detail", "data-split": split && hasDetail ? 'true' : undefined, children: [_jsx("div", { className: "console-list-detail-list", children: list }), split && hasDetail ? (_jsx("aside", { className: "console-list-detail-aside", "aria-label": typeof detailTitle === 'string' ? detailTitle : i18n.t('listDetail.detail'), children: detail })) : null] }), !split ? (_jsx(Sheet, { open: hasDetail, onOpenChange: open => { if (!open)
|
|
27
|
+
onDetailClose?.(); }, children: _jsxs(SheetContent, { side: "right", children: [_jsx(SheetHeader, { children: _jsx(SheetTitle, { children: detailTitle ?? i18n.t('listDetail.detail') }) }), _jsx(SheetBody, { children: detail })] }) })) : null] }));
|
|
28
|
+
}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type RefreshControlProps } from './RefreshControl.js';
|
|
3
|
+
import { type PageAction } from './actions.js';
|
|
3
4
|
/**
|
|
4
5
|
* Page chrome a page hands to the shell (ADR 0063 决策 2): the shell places the header actions and
|
|
5
6
|
* the refresh control; the page itself renders only its content.
|
|
6
7
|
*/
|
|
7
8
|
export interface PageChrome {
|
|
9
|
+
/**
|
|
10
|
+
* Page title the content knows better than the route (e.g. a localized blueprint title). A shell
|
|
11
|
+
* that already has a title area (the plugin detail page) may keep its own and use this as the tab label.
|
|
12
|
+
*/
|
|
13
|
+
readonly title?: string;
|
|
14
|
+
/** One-line description under the title. */
|
|
15
|
+
readonly description?: string;
|
|
8
16
|
/** Header actions (buttons, menus). */
|
|
9
17
|
readonly actions?: ReactNode;
|
|
10
18
|
/** Shows a RefreshControl in the header. */
|
|
11
19
|
readonly refresh?: RefreshControlProps;
|
|
20
|
+
/** Labelled actions: buttons on wide headers, folded into 「更多」 below 40rem (D18 第 7 条). */
|
|
21
|
+
readonly menuActions?: readonly PageAction[];
|
|
22
|
+
/** Actions that always live in the 「更多」 menu. */
|
|
23
|
+
readonly moreActions?: readonly PageAction[];
|
|
12
24
|
}
|
|
13
25
|
export interface PageChromeStore {
|
|
14
26
|
get(): PageChrome | undefined;
|