@zhin.js/console-ui 0.0.0-stage → 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 +54 -0
- package/LICENSE +21 -0
- package/README.md +195 -2
- 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/cn.d.ts +4 -0
- package/dist/cn.js +6 -0
- package/dist/components/BrandMark.d.ts +16 -0
- package/dist/components/BrandMark.js +21 -0
- package/dist/components/InfoHint.d.ts +12 -0
- package/dist/components/InfoHint.js +13 -0
- package/dist/components/PageHeader.d.ts +18 -0
- package/dist/components/PageHeader.js +11 -0
- package/dist/components/PageShell.d.ts +26 -0
- package/dist/components/PageShell.js +10 -0
- package/dist/components/RefreshControl.d.ts +28 -0
- package/dist/components/RefreshControl.js +68 -0
- package/dist/components/StatCard.d.ts +41 -0
- package/dist/components/StatCard.js +53 -0
- 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-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 +72 -0
- 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 +35 -0
- package/dist/components/empty-state.js +43 -0
- package/dist/components/error-alert.d.ts +15 -0
- package/dist/components/error-alert.js +23 -0
- 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 +53 -0
- package/dist/components/page-chrome.js +66 -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 +15 -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 +30 -0
- package/dist/components/ui/button.d.ts +20 -0
- package/dist/components/ui/button.js +52 -0
- package/dist/components/ui/card.d.ts +17 -0
- package/dist/components/ui/card.js +17 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +10 -0
- 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.d.ts +24 -0
- package/dist/components/ui/dialog.js +27 -0
- package/dist/components/ui/dropdown-menu.d.ts +19 -0
- package/dist/components/ui/dropdown-menu.js +26 -0
- package/dist/components/ui/input.d.ts +8 -0
- package/dist/components/ui/input.js +9 -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 +26 -0
- package/dist/components/ui/searchable-select.js +85 -0
- package/dist/components/ui/select.d.ts +29 -0
- package/dist/components/ui/select.js +39 -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 +27 -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 +27 -0
- package/dist/components/ui/table.js +47 -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 +8 -0
- package/dist/components/ui/textarea.js +9 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +11 -0
- 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 +178 -0
- package/dist/i18n/index.d.ts +27 -0
- package/dist/i18n/index.js +33 -0
- package/dist/i18n/messages.d.ts +55 -0
- package/dist/i18n/messages.js +110 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +55 -0
- package/dist/scale.json +643 -0
- package/dist/shared-module.d.ts +28 -0
- package/dist/shared-module.js +24 -0
- package/dist/styles.css +3399 -0
- package/dist/theme.css +469 -0
- package/dist/tokens.css +652 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +2 -0
- 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 +103 -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,178 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhin.js/console-ui",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"exports": [
|
|
5
|
+
"Accordion",
|
|
6
|
+
"AccordionContent",
|
|
7
|
+
"AccordionItem",
|
|
8
|
+
"AccordionTrigger",
|
|
9
|
+
"Alert",
|
|
10
|
+
"AlertDescription",
|
|
11
|
+
"AlertTitle",
|
|
12
|
+
"Badge",
|
|
13
|
+
"BrandMark",
|
|
14
|
+
"Button",
|
|
15
|
+
"CONSOLE_BREAKPOINTS_REM",
|
|
16
|
+
"CONSOLE_ICON_SIZE",
|
|
17
|
+
"CONSOLE_ICON_STROKE_WIDTH",
|
|
18
|
+
"CONSOLE_PRODUCT_NAME",
|
|
19
|
+
"CONSOLE_SHARED_MODULE_ISSUES_KEY",
|
|
20
|
+
"CONSOLE_SHARED_MODULE_ISSUE_EVENT",
|
|
21
|
+
"CONSOLE_SHARED_MODULE_VERSIONS_KEY",
|
|
22
|
+
"CONSOLE_UI_LOCALES",
|
|
23
|
+
"CONSOLE_UI_MESSAGES",
|
|
24
|
+
"CONSOLE_UI_MODULE_ID",
|
|
25
|
+
"CONSOLE_UI_VERSION",
|
|
26
|
+
"Card",
|
|
27
|
+
"CardContent",
|
|
28
|
+
"CardDescription",
|
|
29
|
+
"CardFooter",
|
|
30
|
+
"CardHeader",
|
|
31
|
+
"CardTitle",
|
|
32
|
+
"Checkbox",
|
|
33
|
+
"CodeText",
|
|
34
|
+
"ConfirmDialog",
|
|
35
|
+
"ConsoleUiI18nProvider",
|
|
36
|
+
"ConsoleUiText",
|
|
37
|
+
"ContentStack",
|
|
38
|
+
"DEFAULT_CONSOLE_UI_LOCALE",
|
|
39
|
+
"DEFAULT_REFRESH_INTERVALS",
|
|
40
|
+
"DateField",
|
|
41
|
+
"DateTimeField",
|
|
42
|
+
"Dialog",
|
|
43
|
+
"DialogClose",
|
|
44
|
+
"DialogContent",
|
|
45
|
+
"DialogDescription",
|
|
46
|
+
"DialogFooter",
|
|
47
|
+
"DialogHeader",
|
|
48
|
+
"DialogOverlay",
|
|
49
|
+
"DialogPortal",
|
|
50
|
+
"DialogTitle",
|
|
51
|
+
"DialogTrigger",
|
|
52
|
+
"Disclosure",
|
|
53
|
+
"DropdownMenu",
|
|
54
|
+
"DropdownMenuCheckboxItem",
|
|
55
|
+
"DropdownMenuContent",
|
|
56
|
+
"DropdownMenuGroup",
|
|
57
|
+
"DropdownMenuItem",
|
|
58
|
+
"DropdownMenuLabel",
|
|
59
|
+
"DropdownMenuPortal",
|
|
60
|
+
"DropdownMenuRadioGroup",
|
|
61
|
+
"DropdownMenuRadioItem",
|
|
62
|
+
"DropdownMenuSeparator",
|
|
63
|
+
"DropdownMenuSub",
|
|
64
|
+
"DropdownMenuTrigger",
|
|
65
|
+
"EMPTY_ILLUSTRATIONS",
|
|
66
|
+
"EmptyIllustration",
|
|
67
|
+
"EmptyState",
|
|
68
|
+
"ErrorAlert",
|
|
69
|
+
"FormField",
|
|
70
|
+
"Grid",
|
|
71
|
+
"InfoHint",
|
|
72
|
+
"InlineCode",
|
|
73
|
+
"Input",
|
|
74
|
+
"JsonBlock",
|
|
75
|
+
"KeyValueList",
|
|
76
|
+
"ListDetail",
|
|
77
|
+
"ListItemButton",
|
|
78
|
+
"LoadingBlock",
|
|
79
|
+
"MediaPreview",
|
|
80
|
+
"MiniRingGauge",
|
|
81
|
+
"MoreMenu",
|
|
82
|
+
"PageActions",
|
|
83
|
+
"PageChromeActions",
|
|
84
|
+
"PageChromeProvider",
|
|
85
|
+
"PageHeader",
|
|
86
|
+
"PageShell",
|
|
87
|
+
"Popover",
|
|
88
|
+
"PopoverAnchor",
|
|
89
|
+
"PopoverContent",
|
|
90
|
+
"PopoverTrigger",
|
|
91
|
+
"ProgressMeter",
|
|
92
|
+
"RadioGroup",
|
|
93
|
+
"RadioGroupItem",
|
|
94
|
+
"RecordCard",
|
|
95
|
+
"RefreshControl",
|
|
96
|
+
"RowActions",
|
|
97
|
+
"ScrollArea",
|
|
98
|
+
"ScrollBar",
|
|
99
|
+
"SearchableSelectField",
|
|
100
|
+
"Section",
|
|
101
|
+
"Select",
|
|
102
|
+
"SelectContent",
|
|
103
|
+
"SelectField",
|
|
104
|
+
"SelectGroup",
|
|
105
|
+
"SelectItem",
|
|
106
|
+
"SelectScrollDownButton",
|
|
107
|
+
"SelectScrollUpButton",
|
|
108
|
+
"SelectSeparator",
|
|
109
|
+
"SelectTrigger",
|
|
110
|
+
"SelectValue",
|
|
111
|
+
"Separator",
|
|
112
|
+
"Sheet",
|
|
113
|
+
"SheetBody",
|
|
114
|
+
"SheetClose",
|
|
115
|
+
"SheetContent",
|
|
116
|
+
"SheetDescription",
|
|
117
|
+
"SheetFooter",
|
|
118
|
+
"SheetHeader",
|
|
119
|
+
"SheetOverlay",
|
|
120
|
+
"SheetPortal",
|
|
121
|
+
"SheetTitle",
|
|
122
|
+
"SheetTrigger",
|
|
123
|
+
"Skeleton",
|
|
124
|
+
"Sparkline",
|
|
125
|
+
"StatCard",
|
|
126
|
+
"StatGrid",
|
|
127
|
+
"StatusBadge",
|
|
128
|
+
"Switch",
|
|
129
|
+
"Table",
|
|
130
|
+
"TableBody",
|
|
131
|
+
"TableCell",
|
|
132
|
+
"TableHead",
|
|
133
|
+
"TableHeader",
|
|
134
|
+
"TableRow",
|
|
135
|
+
"Tabs",
|
|
136
|
+
"TabsContent",
|
|
137
|
+
"TabsList",
|
|
138
|
+
"TabsTrigger",
|
|
139
|
+
"Textarea",
|
|
140
|
+
"Timeline",
|
|
141
|
+
"Tooltip",
|
|
142
|
+
"TooltipContent",
|
|
143
|
+
"TooltipProvider",
|
|
144
|
+
"TooltipTrigger",
|
|
145
|
+
"addDays",
|
|
146
|
+
"addMonths",
|
|
147
|
+
"badgeVariants",
|
|
148
|
+
"buttonVariants",
|
|
149
|
+
"calendarMonth",
|
|
150
|
+
"canSubmitConfirm",
|
|
151
|
+
"cn",
|
|
152
|
+
"confirmErrorMessage",
|
|
153
|
+
"confirmTextMatches",
|
|
154
|
+
"createConsoleUiI18n",
|
|
155
|
+
"createPageChromeStore",
|
|
156
|
+
"formatConsoleUiMessage",
|
|
157
|
+
"formatDateTimeValue",
|
|
158
|
+
"formatDateValue",
|
|
159
|
+
"formatRefreshTime",
|
|
160
|
+
"groupSelectOptions",
|
|
161
|
+
"isAttentionStatus",
|
|
162
|
+
"isZeroValue",
|
|
163
|
+
"navigableValues",
|
|
164
|
+
"optionMatches",
|
|
165
|
+
"optionSearchText",
|
|
166
|
+
"parseDateTimeValue",
|
|
167
|
+
"parseDateValue",
|
|
168
|
+
"refreshIntervalOptions",
|
|
169
|
+
"registerConsoleUiSharedModule",
|
|
170
|
+
"resolveConsoleUiLocale",
|
|
171
|
+
"syncTableCellLabels",
|
|
172
|
+
"useConfirm",
|
|
173
|
+
"useConsoleUiI18n",
|
|
174
|
+
"useContainerAtLeast",
|
|
175
|
+
"usePageChrome",
|
|
176
|
+
"usePageChromeState"
|
|
177
|
+
]
|
|
178
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ConsoleUiLocale, type ConsoleUiMessageKey, type ConsoleUiMessages } from './messages.js';
|
|
3
|
+
export { CONSOLE_UI_LOCALES, CONSOLE_UI_MESSAGES, DEFAULT_CONSOLE_UI_LOCALE, formatConsoleUiMessage, resolveConsoleUiLocale, type ConsoleUiLocale, type ConsoleUiMessageKey, type ConsoleUiMessages, } from './messages.js';
|
|
4
|
+
export interface ConsoleUiI18n {
|
|
5
|
+
readonly locale: ConsoleUiLocale;
|
|
6
|
+
/** Built-in copy for `key` in the current locale (host overrides first), with `{n}` filled from `values`. */
|
|
7
|
+
t(key: ConsoleUiMessageKey, values?: readonly unknown[]): string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createConsoleUiI18n(locale?: string | null, messages?: Partial<ConsoleUiMessages>): ConsoleUiI18n;
|
|
10
|
+
export interface ConsoleUiI18nProviderProps {
|
|
11
|
+
/** Current host locale (any BCP 47 tag; `zh*` → zh-CN, `en*` → en, otherwise zh-CN). */
|
|
12
|
+
readonly locale?: string | null;
|
|
13
|
+
/** Host overrides for the current locale; missing keys fall back to the built-in copy. */
|
|
14
|
+
readonly messages?: Partial<ConsoleUiMessages>;
|
|
15
|
+
readonly children?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Language and copy for every `@zhin.js/console-ui` component. Components never read the host's
|
|
19
|
+
* own i18n; without a provider they render the zh-CN defaults.
|
|
20
|
+
*/
|
|
21
|
+
export declare function ConsoleUiI18nProvider({ locale, messages, children }: ConsoleUiI18nProviderProps): import("react").JSX.Element;
|
|
22
|
+
export declare function useConsoleUiI18n(): ConsoleUiI18n;
|
|
23
|
+
/** Renders one built-in message; for places that cannot call the hook (e.g. inside forwardRef bodies shared with class components). */
|
|
24
|
+
export declare function ConsoleUiText({ id, values }: {
|
|
25
|
+
readonly id: ConsoleUiMessageKey;
|
|
26
|
+
readonly values?: readonly unknown[];
|
|
27
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
import { CONSOLE_UI_MESSAGES, DEFAULT_CONSOLE_UI_LOCALE, formatConsoleUiMessage, resolveConsoleUiLocale, } from './messages.js';
|
|
4
|
+
export { CONSOLE_UI_LOCALES, CONSOLE_UI_MESSAGES, DEFAULT_CONSOLE_UI_LOCALE, formatConsoleUiMessage, resolveConsoleUiLocale, } from './messages.js';
|
|
5
|
+
export function createConsoleUiI18n(locale, messages) {
|
|
6
|
+
const resolved = resolveConsoleUiLocale(locale);
|
|
7
|
+
const table = CONSOLE_UI_MESSAGES[resolved];
|
|
8
|
+
return Object.freeze({
|
|
9
|
+
locale: resolved,
|
|
10
|
+
t(key, values) {
|
|
11
|
+
const override = messages?.[key];
|
|
12
|
+
const template = typeof override === 'string' ? override : (table[key] ?? key);
|
|
13
|
+
return formatConsoleUiMessage(template, values);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const ConsoleUiI18nContext = createContext(createConsoleUiI18n(DEFAULT_CONSOLE_UI_LOCALE));
|
|
18
|
+
/**
|
|
19
|
+
* Language and copy for every `@zhin.js/console-ui` component. Components never read the host's
|
|
20
|
+
* own i18n; without a provider they render the zh-CN defaults.
|
|
21
|
+
*/
|
|
22
|
+
export function ConsoleUiI18nProvider({ locale, messages, children }) {
|
|
23
|
+
const value = useMemo(() => createConsoleUiI18n(locale, messages), [locale, messages]);
|
|
24
|
+
return _jsx(ConsoleUiI18nContext.Provider, { value: value, children: children });
|
|
25
|
+
}
|
|
26
|
+
export function useConsoleUiI18n() {
|
|
27
|
+
return useContext(ConsoleUiI18nContext);
|
|
28
|
+
}
|
|
29
|
+
/** Renders one built-in message; for places that cannot call the hook (e.g. inside forwardRef bodies shared with class components). */
|
|
30
|
+
export function ConsoleUiText({ id, values }) {
|
|
31
|
+
const { t } = useConsoleUiI18n();
|
|
32
|
+
return _jsx(_Fragment, { children: t(id, values) });
|
|
33
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in UI copy of `@zhin.js/console-ui` (ADR 0063 决策 1 第 5 条).
|
|
3
|
+
* Keys are stable ids; values use `{0}`, `{1}` … placeholders.
|
|
4
|
+
* The zh-CN / en strings are the ones the Console used before the components moved here.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CONSOLE_UI_LOCALES: readonly ["zh-CN", "en"];
|
|
7
|
+
export type ConsoleUiLocale = (typeof CONSOLE_UI_LOCALES)[number];
|
|
8
|
+
export declare const DEFAULT_CONSOLE_UI_LOCALE: ConsoleUiLocale;
|
|
9
|
+
declare const zhCN: {
|
|
10
|
+
readonly 'dialog.close': "关闭";
|
|
11
|
+
readonly 'confirm.cancel': "取消";
|
|
12
|
+
readonly 'confirm.confirm': "确认";
|
|
13
|
+
readonly 'confirm.processing': "处理中...";
|
|
14
|
+
readonly 'confirm.failed': "操作失败,请重试或取消。";
|
|
15
|
+
readonly 'confirm.notCompleted': "操作未完成:{0}";
|
|
16
|
+
readonly 'confirm.typeToConfirm': "请输入 {0} 以确认:";
|
|
17
|
+
readonly 'empty.noData': "这里还没有内容";
|
|
18
|
+
readonly 'empty.messages': "还没有消息";
|
|
19
|
+
readonly 'empty.tasks': "还没有任务";
|
|
20
|
+
readonly 'empty.logs': "还没有日志";
|
|
21
|
+
readonly 'empty.table': "在左侧选择一个数据表";
|
|
22
|
+
readonly 'empty.record': "选择一条记录查看详情";
|
|
23
|
+
readonly 'empty.notFound': "找不到这个页面";
|
|
24
|
+
readonly 'date.placeholder': "选择日期";
|
|
25
|
+
readonly 'date.placeholderDateTime': "选择日期和时间";
|
|
26
|
+
readonly 'date.clear': "清除";
|
|
27
|
+
readonly 'date.prevMonth': "上个月";
|
|
28
|
+
readonly 'date.nextMonth': "下个月";
|
|
29
|
+
readonly 'date.today': "今天";
|
|
30
|
+
readonly 'date.now': "现在";
|
|
31
|
+
readonly 'date.time': "时间";
|
|
32
|
+
readonly 'date.hour': "时";
|
|
33
|
+
readonly 'date.minute': "分";
|
|
34
|
+
readonly 'date.done': "完成";
|
|
35
|
+
readonly 'error.retry': "重试";
|
|
36
|
+
readonly 'error.technicalDetail': "技术详情";
|
|
37
|
+
readonly 'select.searchPlaceholder': "搜索…";
|
|
38
|
+
readonly 'select.noMatch': "没有匹配的选项";
|
|
39
|
+
readonly 'refresh.updatedAt': "更新于 {0}";
|
|
40
|
+
readonly 'refresh.notYet': "尚未更新";
|
|
41
|
+
readonly 'refresh.refresh': "刷新";
|
|
42
|
+
readonly 'refresh.refreshing': "刷新中…";
|
|
43
|
+
readonly 'refresh.interval': "自动刷新间隔";
|
|
44
|
+
readonly 'refresh.manual': "手动刷新";
|
|
45
|
+
readonly 'refresh.auto': "{0}s 自动";
|
|
46
|
+
readonly 'actions.more': "更多";
|
|
47
|
+
readonly 'listDetail.detail': "详情";
|
|
48
|
+
};
|
|
49
|
+
export type ConsoleUiMessageKey = keyof typeof zhCN;
|
|
50
|
+
export type ConsoleUiMessages = Readonly<Record<ConsoleUiMessageKey, string>>;
|
|
51
|
+
export declare const CONSOLE_UI_MESSAGES: Readonly<Record<ConsoleUiLocale, ConsoleUiMessages>>;
|
|
52
|
+
/** Maps any BCP 47 tag onto a built-in locale: `zh*` → zh-CN, `en*` → en, otherwise the default. */
|
|
53
|
+
export declare function resolveConsoleUiLocale(locale: string | undefined | null): ConsoleUiLocale;
|
|
54
|
+
export declare function formatConsoleUiMessage(template: string, values?: readonly unknown[]): string;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in UI copy of `@zhin.js/console-ui` (ADR 0063 决策 1 第 5 条).
|
|
3
|
+
* Keys are stable ids; values use `{0}`, `{1}` … placeholders.
|
|
4
|
+
* The zh-CN / en strings are the ones the Console used before the components moved here.
|
|
5
|
+
*/
|
|
6
|
+
export const CONSOLE_UI_LOCALES = Object.freeze(['zh-CN', 'en']);
|
|
7
|
+
export const DEFAULT_CONSOLE_UI_LOCALE = 'zh-CN';
|
|
8
|
+
const zhCN = {
|
|
9
|
+
'dialog.close': '关闭',
|
|
10
|
+
'confirm.cancel': '取消',
|
|
11
|
+
'confirm.confirm': '确认',
|
|
12
|
+
'confirm.processing': '处理中...',
|
|
13
|
+
'confirm.failed': '操作失败,请重试或取消。',
|
|
14
|
+
'confirm.notCompleted': '操作未完成:{0}',
|
|
15
|
+
'confirm.typeToConfirm': '请输入 {0} 以确认:',
|
|
16
|
+
'empty.noData': '这里还没有内容',
|
|
17
|
+
'empty.messages': '还没有消息',
|
|
18
|
+
'empty.tasks': '还没有任务',
|
|
19
|
+
'empty.logs': '还没有日志',
|
|
20
|
+
'empty.table': '在左侧选择一个数据表',
|
|
21
|
+
'empty.record': '选择一条记录查看详情',
|
|
22
|
+
'empty.notFound': '找不到这个页面',
|
|
23
|
+
'date.placeholder': '选择日期',
|
|
24
|
+
'date.placeholderDateTime': '选择日期和时间',
|
|
25
|
+
'date.clear': '清除',
|
|
26
|
+
'date.prevMonth': '上个月',
|
|
27
|
+
'date.nextMonth': '下个月',
|
|
28
|
+
'date.today': '今天',
|
|
29
|
+
'date.now': '现在',
|
|
30
|
+
'date.time': '时间',
|
|
31
|
+
'date.hour': '时',
|
|
32
|
+
'date.minute': '分',
|
|
33
|
+
'date.done': '完成',
|
|
34
|
+
'error.retry': '重试',
|
|
35
|
+
'error.technicalDetail': '技术详情',
|
|
36
|
+
'select.searchPlaceholder': '搜索…',
|
|
37
|
+
'select.noMatch': '没有匹配的选项',
|
|
38
|
+
'refresh.updatedAt': '更新于 {0}',
|
|
39
|
+
'refresh.notYet': '尚未更新',
|
|
40
|
+
'refresh.refresh': '刷新',
|
|
41
|
+
'refresh.refreshing': '刷新中…',
|
|
42
|
+
'refresh.interval': '自动刷新间隔',
|
|
43
|
+
'refresh.manual': '手动刷新',
|
|
44
|
+
'refresh.auto': '{0}s 自动',
|
|
45
|
+
'actions.more': '更多',
|
|
46
|
+
'listDetail.detail': '详情',
|
|
47
|
+
};
|
|
48
|
+
const en = {
|
|
49
|
+
'dialog.close': 'Close',
|
|
50
|
+
'confirm.cancel': 'Cancel',
|
|
51
|
+
'confirm.confirm': 'Confirm',
|
|
52
|
+
'confirm.processing': 'Processing…',
|
|
53
|
+
'confirm.failed': 'The action failed. Try again or cancel.',
|
|
54
|
+
'confirm.notCompleted': 'Not completed: {0}',
|
|
55
|
+
'confirm.typeToConfirm': 'Type {0} to confirm:',
|
|
56
|
+
'empty.noData': 'Nothing here yet',
|
|
57
|
+
'empty.messages': 'No messages yet',
|
|
58
|
+
'empty.tasks': 'No tasks yet',
|
|
59
|
+
'empty.logs': 'No logs yet',
|
|
60
|
+
'empty.table': 'Select a table on the left',
|
|
61
|
+
'empty.record': 'Select a record to see its details',
|
|
62
|
+
'empty.notFound': 'Page not found',
|
|
63
|
+
'date.placeholder': 'Pick a date',
|
|
64
|
+
'date.placeholderDateTime': 'Pick a date and time',
|
|
65
|
+
'date.clear': 'Clear',
|
|
66
|
+
'date.prevMonth': 'Previous month',
|
|
67
|
+
'date.nextMonth': 'Next month',
|
|
68
|
+
'date.today': 'Today',
|
|
69
|
+
'date.now': 'Now',
|
|
70
|
+
'date.time': 'Time',
|
|
71
|
+
'date.hour': 'Hour',
|
|
72
|
+
'date.minute': 'Minute',
|
|
73
|
+
'date.done': 'Done',
|
|
74
|
+
'error.retry': 'Retry',
|
|
75
|
+
'error.technicalDetail': 'Technical details',
|
|
76
|
+
'select.searchPlaceholder': 'Search…',
|
|
77
|
+
'select.noMatch': 'No matching options',
|
|
78
|
+
'refresh.updatedAt': 'Updated {0}',
|
|
79
|
+
'refresh.notYet': 'Not updated yet',
|
|
80
|
+
'refresh.refresh': 'Refresh',
|
|
81
|
+
'refresh.refreshing': 'Refreshing…',
|
|
82
|
+
'refresh.interval': 'Auto refresh interval',
|
|
83
|
+
'refresh.manual': 'Manual refresh',
|
|
84
|
+
'refresh.auto': '{0}s auto',
|
|
85
|
+
'actions.more': 'More',
|
|
86
|
+
'listDetail.detail': 'Details',
|
|
87
|
+
};
|
|
88
|
+
export const CONSOLE_UI_MESSAGES = Object.freeze({
|
|
89
|
+
'zh-CN': Object.freeze({ ...zhCN }),
|
|
90
|
+
en: Object.freeze({ ...en }),
|
|
91
|
+
});
|
|
92
|
+
/** Maps any BCP 47 tag onto a built-in locale: `zh*` → zh-CN, `en*` → en, otherwise the default. */
|
|
93
|
+
export function resolveConsoleUiLocale(locale) {
|
|
94
|
+
if (!locale)
|
|
95
|
+
return DEFAULT_CONSOLE_UI_LOCALE;
|
|
96
|
+
const lower = locale.toLowerCase();
|
|
97
|
+
if (lower.startsWith('zh'))
|
|
98
|
+
return 'zh-CN';
|
|
99
|
+
if (lower.startsWith('en'))
|
|
100
|
+
return 'en';
|
|
101
|
+
return DEFAULT_CONSOLE_UI_LOCALE;
|
|
102
|
+
}
|
|
103
|
+
export function formatConsoleUiMessage(template, values) {
|
|
104
|
+
if (!values || values.length === 0)
|
|
105
|
+
return template;
|
|
106
|
+
return template.replace(/\{(\d+)\}/gu, (match, index) => {
|
|
107
|
+
const value = values[Number(index)];
|
|
108
|
+
return value === undefined ? match : String(value);
|
|
109
|
+
});
|
|
110
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zhin.js/console-ui — the one component library of the Zhin Console and plugin pages (ADR 0063).
|
|
3
|
+
* Styles ship precompiled: import `@zhin.js/console-ui/styles.css` (tokens + components) once, or
|
|
4
|
+
* `@zhin.js/console-ui/tokens.css` for the tokens alone.
|
|
5
|
+
*/
|
|
6
|
+
export { cn, type ClassValue } from './cn.js';
|
|
7
|
+
export { CONSOLE_UI_VERSION } from './version.js';
|
|
8
|
+
export { CONSOLE_UI_MODULE_ID, CONSOLE_SHARED_MODULE_VERSIONS_KEY, CONSOLE_SHARED_MODULE_ISSUE_EVENT, CONSOLE_SHARED_MODULE_ISSUES_KEY, registerConsoleUiSharedModule, type ConsoleSharedModuleIssue, } from './shared-module.js';
|
|
9
|
+
export * from './i18n/index.js';
|
|
10
|
+
export * from './components/ui/accordion.js';
|
|
11
|
+
export * from './components/ui/alert.js';
|
|
12
|
+
export * from './components/ui/badge.js';
|
|
13
|
+
export * from './components/ui/button.js';
|
|
14
|
+
export * from './components/ui/card.js';
|
|
15
|
+
export * from './components/ui/checkbox.js';
|
|
16
|
+
export type { ControlVariant } from './components/ui/control-variant.js';
|
|
17
|
+
export * from './components/ui/date-field.js';
|
|
18
|
+
export { addDays, addMonths, calendarMonth, formatDateTimeValue, formatDateValue, parseDateTimeValue, parseDateValue, type CalendarDate, type CalendarDateTime, } from './components/ui/date-field-model.js';
|
|
19
|
+
export * from './components/ui/dialog.js';
|
|
20
|
+
export * from './components/ui/dropdown-menu.js';
|
|
21
|
+
export * from './components/ui/input.js';
|
|
22
|
+
export * from './components/ui/list-item-button.js';
|
|
23
|
+
export * from './components/ui/popover.js';
|
|
24
|
+
export * from './components/ui/radio-group.js';
|
|
25
|
+
export * from './components/ui/scroll-area.js';
|
|
26
|
+
export * from './components/ui/searchable-select.js';
|
|
27
|
+
export { groupSelectOptions, navigableValues, optionMatches, optionSearchText, type SearchableSelectGroup, } from './components/ui/searchable-select-model.js';
|
|
28
|
+
export * from './components/ui/select.js';
|
|
29
|
+
export * from './components/ui/separator.js';
|
|
30
|
+
export * from './components/ui/sheet.js';
|
|
31
|
+
export * from './components/ui/skeleton.js';
|
|
32
|
+
export * from './components/ui/switch.js';
|
|
33
|
+
export * from './components/ui/table.js';
|
|
34
|
+
export * from './components/ui/tabs.js';
|
|
35
|
+
export * from './components/ui/textarea.js';
|
|
36
|
+
export * from './components/ui/tooltip.js';
|
|
37
|
+
export * from './components/PageShell.js';
|
|
38
|
+
export * from './components/PageHeader.js';
|
|
39
|
+
export * from './components/confirm-dialog.js';
|
|
40
|
+
export { canSubmitConfirm, confirmErrorMessage, confirmTextMatches } from './components/confirm-dialog-model.js';
|
|
41
|
+
export * from './components/StatCard.js';
|
|
42
|
+
export * from './components/BrandMark.js';
|
|
43
|
+
export * from './components/empty-state.js';
|
|
44
|
+
export * from './components/empty-illustrations.js';
|
|
45
|
+
export * from './components/code.js';
|
|
46
|
+
export { CONSOLE_ICON_SIZE, CONSOLE_ICON_STROKE_WIDTH } from './components/icon.js';
|
|
47
|
+
export * from './components/error-alert.js';
|
|
48
|
+
export * from './components/InfoHint.js';
|
|
49
|
+
export * from './components/RefreshControl.js';
|
|
50
|
+
export { DEFAULT_REFRESH_INTERVALS, formatRefreshTime, refreshIntervalOptions, } from './components/refresh-control-model.js';
|
|
51
|
+
export * from './components/page-chrome.js';
|
|
52
|
+
export * from './components/actions.js';
|
|
53
|
+
export * from './components/layout.js';
|
|
54
|
+
export * from './components/StatusBadge.js';
|
|
55
|
+
export { useContainerAtLeast, CONSOLE_BREAKPOINTS_REM } from './components/use-container-width.js';
|
|
56
|
+
export * from './components/content-blocks.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zhin.js/console-ui — the one component library of the Zhin Console and plugin pages (ADR 0063).
|
|
3
|
+
* Styles ship precompiled: import `@zhin.js/console-ui/styles.css` (tokens + components) once, or
|
|
4
|
+
* `@zhin.js/console-ui/tokens.css` for the tokens alone.
|
|
5
|
+
*/
|
|
6
|
+
export { cn } from './cn.js';
|
|
7
|
+
export { CONSOLE_UI_VERSION } from './version.js';
|
|
8
|
+
export { CONSOLE_UI_MODULE_ID, CONSOLE_SHARED_MODULE_VERSIONS_KEY, CONSOLE_SHARED_MODULE_ISSUE_EVENT, CONSOLE_SHARED_MODULE_ISSUES_KEY, registerConsoleUiSharedModule, } from './shared-module.js';
|
|
9
|
+
export * from './i18n/index.js';
|
|
10
|
+
export * from './components/ui/accordion.js';
|
|
11
|
+
export * from './components/ui/alert.js';
|
|
12
|
+
export * from './components/ui/badge.js';
|
|
13
|
+
export * from './components/ui/button.js';
|
|
14
|
+
export * from './components/ui/card.js';
|
|
15
|
+
export * from './components/ui/checkbox.js';
|
|
16
|
+
export * from './components/ui/date-field.js';
|
|
17
|
+
export { addDays, addMonths, calendarMonth, formatDateTimeValue, formatDateValue, parseDateTimeValue, parseDateValue, } from './components/ui/date-field-model.js';
|
|
18
|
+
export * from './components/ui/dialog.js';
|
|
19
|
+
export * from './components/ui/dropdown-menu.js';
|
|
20
|
+
export * from './components/ui/input.js';
|
|
21
|
+
export * from './components/ui/list-item-button.js';
|
|
22
|
+
export * from './components/ui/popover.js';
|
|
23
|
+
export * from './components/ui/radio-group.js';
|
|
24
|
+
export * from './components/ui/scroll-area.js';
|
|
25
|
+
export * from './components/ui/searchable-select.js';
|
|
26
|
+
export { groupSelectOptions, navigableValues, optionMatches, optionSearchText, } from './components/ui/searchable-select-model.js';
|
|
27
|
+
export * from './components/ui/select.js';
|
|
28
|
+
export * from './components/ui/separator.js';
|
|
29
|
+
export * from './components/ui/sheet.js';
|
|
30
|
+
export * from './components/ui/skeleton.js';
|
|
31
|
+
export * from './components/ui/switch.js';
|
|
32
|
+
export * from './components/ui/table.js';
|
|
33
|
+
export * from './components/ui/tabs.js';
|
|
34
|
+
export * from './components/ui/textarea.js';
|
|
35
|
+
export * from './components/ui/tooltip.js';
|
|
36
|
+
export * from './components/PageShell.js';
|
|
37
|
+
export * from './components/PageHeader.js';
|
|
38
|
+
export * from './components/confirm-dialog.js';
|
|
39
|
+
export { canSubmitConfirm, confirmErrorMessage, confirmTextMatches } from './components/confirm-dialog-model.js';
|
|
40
|
+
export * from './components/StatCard.js';
|
|
41
|
+
export * from './components/BrandMark.js';
|
|
42
|
+
export * from './components/empty-state.js';
|
|
43
|
+
export * from './components/empty-illustrations.js';
|
|
44
|
+
export * from './components/code.js';
|
|
45
|
+
export { CONSOLE_ICON_SIZE, CONSOLE_ICON_STROKE_WIDTH } from './components/icon.js';
|
|
46
|
+
export * from './components/error-alert.js';
|
|
47
|
+
export * from './components/InfoHint.js';
|
|
48
|
+
export * from './components/RefreshControl.js';
|
|
49
|
+
export { DEFAULT_REFRESH_INTERVALS, formatRefreshTime, refreshIntervalOptions, } from './components/refresh-control-model.js';
|
|
50
|
+
export * from './components/page-chrome.js';
|
|
51
|
+
export * from './components/actions.js';
|
|
52
|
+
export * from './components/layout.js';
|
|
53
|
+
export * from './components/StatusBadge.js';
|
|
54
|
+
export { useContainerAtLeast, CONSOLE_BREAKPOINTS_REM } from './components/use-container-width.js';
|
|
55
|
+
export * from './components/content-blocks.js';
|