@rinova/devtools 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +25 -25
- package/dist/core/network-capture.d.ts +7 -0
- package/dist/core/runtime.d.ts +6 -7
- package/dist/index.d.ts +34 -1
- package/dist/index.js +4824 -1219
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/master-detail.d.ts +65 -0
- package/dist/plugins/storage.d.ts +1 -1
- package/dist/plugins/table-state.d.ts +11 -0
- package/dist/types.d.ts +20 -7
- package/dist/ui/choice-groups.d.ts +28 -0
- package/dist/ui/code-editor.d.ts +15 -0
- package/dist/ui/component.d.ts +20 -0
- package/dist/ui/date-picker.d.ts +18 -0
- package/dist/ui/dialog.d.ts +27 -0
- package/dist/ui/dom.d.ts +37 -9
- package/dist/ui/form-controls.d.ts +109 -0
- package/dist/ui/inspectors.d.ts +32 -0
- package/dist/ui/layout-watch.d.ts +10 -0
- package/dist/ui/layout.d.ts +43 -0
- package/dist/ui/maximize.d.ts +30 -0
- package/dist/ui/overlays.d.ts +54 -0
- package/dist/ui/page-layer.d.ts +9 -0
- package/dist/ui/popup.d.ts +26 -0
- package/dist/ui/select.d.ts +43 -0
- package/dist/ui/shell-chrome.d.ts +28 -0
- package/dist/ui/shell.d.ts +44 -20
- package/dist/ui/splitter.d.ts +16 -0
- package/dist/ui/table.d.ts +79 -0
- package/dist/ui/tabs.d.ts +20 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/utils/hotkey.d.ts +0 -22
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DevtoolsPlugin } from '../types.js';
|
|
2
2
|
import type { Runtime } from '../core/runtime.js';
|
|
3
|
-
export declare const BUILTIN_PLUGIN_IDS: readonly ["config", "
|
|
3
|
+
export declare const BUILTIN_PLUGIN_IDS: readonly ["config", "actions", "network", "console", "storage", "settings"];
|
|
4
4
|
/** 内置面板按侧栏顺序创建;第三方插件用 order 插空 */
|
|
5
5
|
export declare function createBuiltinPlugins(rt: Runtime): DevtoolsPlugin[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Runtime, SplitPlugin } from '../core/runtime.js';
|
|
2
|
+
/** 插件内容区实宽 W 达到该值且详情打开时才分栏(交互设计 6.4) */
|
|
3
|
+
export declare const SPLIT_MIN_WIDTH = 584;
|
|
4
|
+
/** Splitter 手柄宽度,两栏可分配宽度 A = W − 8 */
|
|
5
|
+
export declare const SPLIT_HANDLE = 8;
|
|
6
|
+
/** 列表默认占 A 的百分比;双击回到该值 */
|
|
7
|
+
export declare const SPLIT_DEFAULT = 67;
|
|
8
|
+
/** 列表比例的绝对下限 / 上限(%) */
|
|
9
|
+
export declare const SPLIT_MIN = 50;
|
|
10
|
+
export declare const SPLIT_MAX = 75;
|
|
11
|
+
/** 详情宽度下限(px) */
|
|
12
|
+
export declare const SPLIT_DETAIL_MIN = 176;
|
|
13
|
+
/** 列表宽度下限 L(px):默认列合计 + 18px 滚动条与舍入余量 */
|
|
14
|
+
export declare const SPLIT_LIST_MIN: Readonly<Record<SplitPlugin, number>>;
|
|
15
|
+
/**
|
|
16
|
+
* 按插件内容区实宽 W 计算列表比例的拖动范围(交互设计 6.4、设计规范 5.4):
|
|
17
|
+
* A = W − 8;min = max(50, ceil(100 × L / A));max = min(75, floor(100 × (A − 176) / A))。
|
|
18
|
+
* 窄到上下限交叉时(W 低于阈值,本不该分栏)上限取下限,保证范围非空。
|
|
19
|
+
*/
|
|
20
|
+
export declare function splitRange(width: number, plugin: SplitPlugin): {
|
|
21
|
+
min: number;
|
|
22
|
+
max: number;
|
|
23
|
+
};
|
|
24
|
+
export interface MasterDetail {
|
|
25
|
+
/** 承载列表与详情的容器 */
|
|
26
|
+
readonly el: HTMLElement;
|
|
27
|
+
/** 详情顶栏「返回」之后的标题区 */
|
|
28
|
+
readonly title: HTMLElement;
|
|
29
|
+
/** 详情顶栏之下的可滚动内容区 */
|
|
30
|
+
readonly content: HTMLElement;
|
|
31
|
+
/** 当前是否显示详情 */
|
|
32
|
+
isOpen(): boolean;
|
|
33
|
+
/** 当前是否为分栏形态 */
|
|
34
|
+
isSplit(): boolean;
|
|
35
|
+
/** 打开详情(已打开时只换内容,不重放进入动效) */
|
|
36
|
+
open(): void;
|
|
37
|
+
/** 关闭详情回到列表占满;`focus` 为 true 时调用 onClosed 让插件把焦点还给列表 */
|
|
38
|
+
close(focus?: boolean): void;
|
|
39
|
+
/** 重新判断分栏 / 替换形态 */
|
|
40
|
+
relayout(): void;
|
|
41
|
+
/** 把 Escape 监听挂到插件根(含工具栏、页签与详情),焦点在其中任一处都能先关详情 */
|
|
42
|
+
bindEscape(scope: HTMLElement): void;
|
|
43
|
+
dispose(): void;
|
|
44
|
+
}
|
|
45
|
+
export interface MasterDetailOptions {
|
|
46
|
+
rt: Runtime;
|
|
47
|
+
plugin: SplitPlugin;
|
|
48
|
+
/** 列表区域(工具栏之下) */
|
|
49
|
+
list: HTMLElement;
|
|
50
|
+
/** 列表的滚动容器,形态切换时保留其滚动位置 */
|
|
51
|
+
scroller: () => HTMLElement | null;
|
|
52
|
+
detailLabel: string;
|
|
53
|
+
/** 用户点「返回」或按 Escape 关闭详情后调用 */
|
|
54
|
+
onClosed: (focus: boolean) => void;
|
|
55
|
+
}
|
|
56
|
+
/** 网络、存储共用的「列表 + 详情」两栏:宽时官方 Splitter,窄时详情替换列表 */
|
|
57
|
+
export declare function createMasterDetail(options: MasterDetailOptions): MasterDetail;
|
|
58
|
+
/**
|
|
59
|
+
* 一个委托式 Tooltip:鼠标停在或焦点落在 `[data-tip]` 元素上时立即显示全文。
|
|
60
|
+
* 千行表格里不必为每个单元格各挂一个 Tooltip。
|
|
61
|
+
*/
|
|
62
|
+
export declare function createCellTooltip(root: HTMLElement): {
|
|
63
|
+
hide: () => void;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Runtime } from '../core/runtime.js';
|
|
2
|
-
export declare function storagePlugin(
|
|
2
|
+
export declare function storagePlugin(rt: Runtime): import('../types.js').DevtoolsPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TableSort } from '../ui/table.js';
|
|
2
|
+
/** 表格排序与列宽持久化到插件命名空间(ctx.storage),刷新后恢复 */
|
|
3
|
+
export declare function persistTableState(storage: {
|
|
4
|
+
get<T>(key: string, fallback: T): T;
|
|
5
|
+
set(key: string, value: unknown): void;
|
|
6
|
+
}, key?: string): {
|
|
7
|
+
defaultSort: TableSort | undefined;
|
|
8
|
+
defaultColumnWidths: Record<string, number> | undefined;
|
|
9
|
+
onSortChange: (next: TableSort | null) => void;
|
|
10
|
+
onColumnWidthChange: (next: Record<string, number>) => void;
|
|
11
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type DevtoolsBuiltinTheme = 'dark' | 'light' | 'auto';
|
|
|
8
8
|
export type DevtoolsTheme = DevtoolsBuiltinTheme | (string & {});
|
|
9
9
|
/** 面板视图大小档位:小 (300×320) · 默认 (380×420) · 大 (580×520 双栏) */
|
|
10
10
|
export type PanelSize = 'sm' | 'md' | 'lg';
|
|
11
|
+
/** 面板与悬浮球的出厂默认角,同时约束首次展开、缩小落点、悬浮球初始位置和复位位置 */
|
|
12
|
+
export type DefaultCorner = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
11
13
|
export interface PanelPosition {
|
|
12
14
|
x: number;
|
|
13
15
|
y: number;
|
|
@@ -108,14 +110,15 @@ export interface ConfigGroup {
|
|
|
108
110
|
label: string;
|
|
109
111
|
description?: string;
|
|
110
112
|
}
|
|
111
|
-
export type IconName = 'activity' | 'alert-circle' | 'arrow-left' | 'arrow-up-right' | 'box' | 'bug' | 'check' | 'chevron-down' | 'chevron-right' | 'chevron-up' | 'circle' | 'clipboard' | 'copy' | 'database' | 'eraser' | 'external-link' | 'eye' | 'eye-off' | 'filter' | 'ghost' | 'globe' | 'key' | 'layers' | 'list-filter' | 'maximize-2' | 'minimize-2' | 'minus' | 'moon' | 'palette' | 'panel-bottom' | 'panel-left' | 'panel-right' | 'pip' | 'play' | 'plus' | 'radar' | 'refresh-cw' | 'rotate-ccw' | 'search' | 'send' | 'settings' | 'sliders-horizontal' | 'sparkles' | 'square-terminal' | 'sun' | 'terminal' | 'trash' | 'x' | 'zap';
|
|
113
|
+
export type IconName = 'activity' | 'alert-circle' | 'arrow-down' | 'arrow-left' | 'arrow-up' | 'arrow-up-down' | 'arrow-up-right' | 'box' | 'bug' | 'calendar' | 'check' | 'chevron-down' | 'chevron-right' | 'chevron-up' | 'circle' | 'clipboard' | 'copy' | 'database' | 'eraser' | 'external-link' | 'eye' | 'eye-off' | 'filter' | 'ghost' | 'globe' | 'key' | 'layers' | 'list-filter' | 'maximize-2' | 'minimize-2' | 'minus' | 'moon' | 'palette' | 'panel-bottom' | 'panel-left' | 'panel-right' | 'pip' | 'play' | 'plus' | 'radar' | 'refresh-cw' | 'rotate-ccw' | 'search' | 'send' | 'settings' | 'sliders-horizontal' | 'sparkles' | 'square-terminal' | 'sun' | 'terminal' | 'trash' | 'users' | 'x' | 'zap';
|
|
112
114
|
export interface NetworkEntry {
|
|
113
115
|
id: string;
|
|
114
|
-
kind: 'fetch' | 'xhr';
|
|
116
|
+
kind: 'fetch' | 'xhr' | 'img' | 'socket';
|
|
115
117
|
method: string;
|
|
116
118
|
url: string;
|
|
117
119
|
status: number;
|
|
118
120
|
statusText: string;
|
|
121
|
+
/** 状态码为 2xx / 3xx 时为 true(Fetch、XHR 与 IMG 同口径;Socket 握手成功为 true);网络错误或其它状态为 false */
|
|
119
122
|
ok: boolean;
|
|
120
123
|
pending: boolean;
|
|
121
124
|
startAt: number;
|
|
@@ -169,6 +172,12 @@ export interface PluginContext {
|
|
|
169
172
|
root: ShadowRoot;
|
|
170
173
|
/** 插件独占的内容容器(面板切换时保留现场) */
|
|
171
174
|
container: HTMLElement;
|
|
175
|
+
/** 当前插件内容是否正在显示(已选中、面板已打开且未折叠) */
|
|
176
|
+
isActive(): boolean;
|
|
177
|
+
/** 在插件内容从隐藏变为显示时调用,返回取消监听函数 */
|
|
178
|
+
onActivate(fn: () => void): () => void;
|
|
179
|
+
/** 向共享 ShadowRoot 注入样式,返回移除函数;插件卸载时自动清理 */
|
|
180
|
+
addStyle(cssText: string): () => void;
|
|
172
181
|
app: {
|
|
173
182
|
name: string;
|
|
174
183
|
version: string;
|
|
@@ -206,7 +215,7 @@ export interface DevtoolsPlugin {
|
|
|
206
215
|
/** 侧栏角标,返回 null 表示不显示 */
|
|
207
216
|
badge?: () => number | string | null;
|
|
208
217
|
/**
|
|
209
|
-
*
|
|
218
|
+
* 渲染入口。注册时创建容器并渲染,之后切换标签不复建。
|
|
210
219
|
* 需要清理的资源请用 ctx.onDispose 注册。
|
|
211
220
|
*/
|
|
212
221
|
render(container: HTMLElement, ctx: PluginContext): void;
|
|
@@ -234,8 +243,14 @@ export interface DevtoolsOptions {
|
|
|
234
243
|
theme?: DevtoolsTheme;
|
|
235
244
|
/** 自定义主题列表,也可在运行时通过 registerTheme 动态添加 */
|
|
236
245
|
themes?: DevtoolsThemeDefinition[];
|
|
237
|
-
/** 面板视图大小档位:'sm'(小)| 'md'
|
|
246
|
+
/** 面板视图大小档位:'sm'(小)| 'md'(中)| 'lg'(大),出厂默认 'lg' */
|
|
238
247
|
size?: PanelSize;
|
|
248
|
+
/**
|
|
249
|
+
* 面板与悬浮球的出厂默认角,默认 `'bottom-left'`。
|
|
250
|
+
* 同一取值同时约束:无拖拽记忆时的首次展开停靠、悬浮球初始位置、缩小落点和「复位位置」。
|
|
251
|
+
* 用户拖拽后的本地记忆优先,直到复位。
|
|
252
|
+
*/
|
|
253
|
+
defaultCorner?: DefaultCorner;
|
|
239
254
|
/** @deprecated 已移除视图停靠切换,请使用 size 控制视图档位,面板支持直接拖拽 */
|
|
240
255
|
dock?: DockSide;
|
|
241
256
|
/** @deprecated 请使用 size: 'sm' | 'md' | 'lg' */
|
|
@@ -246,10 +261,8 @@ export interface DevtoolsOptions {
|
|
|
246
261
|
minWidth?: number;
|
|
247
262
|
/** @deprecated 请使用 size: 'sm' | 'md' | 'lg' */
|
|
248
263
|
maxWidth?: number;
|
|
249
|
-
/** 悬浮球;false
|
|
264
|
+
/** 悬浮球;false 表示不显示(只保留程序调用) */
|
|
250
265
|
launcher?: boolean | LauncherOptions;
|
|
251
|
-
/** 快捷键,默认 alt+shift+d;false 关闭。用户在设置面板修改后以本地保存值为准 */
|
|
252
|
-
shortcut?: string | false;
|
|
253
266
|
/**
|
|
254
267
|
* 严格 CSP 环境下的 style nonce:`style-src 'nonce-...'`。
|
|
255
268
|
* 传入函数时每次挂载重新求值(适配服务端注入的随机 nonce)。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ComponentDef } from './component.js';
|
|
2
|
+
export interface ChoiceGroupOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ChoiceGroupProps<Value> {
|
|
8
|
+
label: string;
|
|
9
|
+
options: readonly ChoiceGroupOption[];
|
|
10
|
+
name?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
readonly?: boolean;
|
|
13
|
+
orientation?: 'horizontal' | 'vertical';
|
|
14
|
+
value?: Value;
|
|
15
|
+
defaultValue?: Value;
|
|
16
|
+
onChange?: (value: Value) => void;
|
|
17
|
+
}
|
|
18
|
+
export type RadioGroupProps = ChoiceGroupProps<string | null>;
|
|
19
|
+
export type CheckboxGroupProps = ChoiceGroupProps<readonly string[]>;
|
|
20
|
+
export declare const RadioGroup: ComponentDef<RadioGroupProps, {
|
|
21
|
+
change: string | null;
|
|
22
|
+
}, HTMLFieldSetElement>;
|
|
23
|
+
export declare const CheckboxGroup: ComponentDef<CheckboxGroupProps, {
|
|
24
|
+
change: readonly string[];
|
|
25
|
+
}, HTMLFieldSetElement>;
|
|
26
|
+
export declare function radioGroup({ value, ...props }: RadioGroupProps): HTMLFieldSetElement;
|
|
27
|
+
export declare function checkboxGroup({ value, ...props }: CheckboxGroupProps): HTMLFieldSetElement;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CopyResult } from './inspectors.js';
|
|
2
|
+
/** 超过该行数时不再做语法高亮,只保留纯文本与行号 */
|
|
3
|
+
export declare const CODE_EDITOR_HIGHLIGHT_MAX_LINES = 500;
|
|
4
|
+
export interface CodeEditorProps {
|
|
5
|
+
code: string;
|
|
6
|
+
language?: 'text' | 'json' | 'js' | 'css' | 'html';
|
|
7
|
+
ariaLabel?: string;
|
|
8
|
+
lineNumbers?: boolean;
|
|
9
|
+
toolbar?: boolean;
|
|
10
|
+
searchable?: boolean;
|
|
11
|
+
onCopy?: (result: CopyResult) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const CodeEditor: import("./component.js").ComponentDef<CodeEditorProps, {
|
|
14
|
+
copy: CopyResult;
|
|
15
|
+
}, HTMLElement>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ComponentView<P, El extends HTMLElement = HTMLElement> {
|
|
2
|
+
el: El;
|
|
3
|
+
update(props: P): void;
|
|
4
|
+
dispose?(): void;
|
|
5
|
+
}
|
|
6
|
+
export interface ComponentDef<P, E, El extends HTMLElement = HTMLElement> {
|
|
7
|
+
name: string;
|
|
8
|
+
create(props: P, emit: <K extends keyof E>(event: K, payload: E[K]) => void): ComponentView<P, El>;
|
|
9
|
+
}
|
|
10
|
+
export interface ComponentHandle<P, E, El extends HTMLElement = HTMLElement> {
|
|
11
|
+
readonly el: El;
|
|
12
|
+
/** Replace the current props with a complete snapshot. Framework adapters should keep using this. */
|
|
13
|
+
setProps(props: P): void;
|
|
14
|
+
/** Shallow-merge props for imperative plugin use. Does not replace unspecified keys. */
|
|
15
|
+
patchProps(props: Partial<P>): void;
|
|
16
|
+
on<K extends keyof E>(event: K, fn: (payload: E[K]) => void): () => void;
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function defineComponent<P, E, El extends HTMLElement = HTMLElement>(def: ComponentDef<P, E, El>): ComponentDef<P, E, El>;
|
|
20
|
+
export declare function mount<P, E, El extends HTMLElement>(def: ComponentDef<P, E, El>, props: P, parent?: HTMLElement): ComponentHandle<P, E, El>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type DateRange = readonly [start: string, end: string];
|
|
2
|
+
export type DatePickerValue = string | DateRange | null;
|
|
3
|
+
export interface DatePickerProps {
|
|
4
|
+
ariaLabel: string;
|
|
5
|
+
range?: boolean;
|
|
6
|
+
value?: DatePickerValue;
|
|
7
|
+
defaultValue?: DatePickerValue;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
min?: string;
|
|
11
|
+
max?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
onChange?: (value: DatePickerValue) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const DatePicker: import("./component.js").ComponentDef<DatePickerProps, {
|
|
17
|
+
change: DatePickerValue;
|
|
18
|
+
}, HTMLElement>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type DialogResult = 'confirm' | 'cancel';
|
|
2
|
+
export interface DialogProps {
|
|
3
|
+
label?: string;
|
|
4
|
+
title: string;
|
|
5
|
+
content?: Node | string;
|
|
6
|
+
trigger?: Node;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
confirmLabel?: string;
|
|
10
|
+
cancelLabel?: string;
|
|
11
|
+
confirmTone?: 'primary' | 'danger';
|
|
12
|
+
confirmDisabled?: boolean;
|
|
13
|
+
hideCancel?: boolean;
|
|
14
|
+
closeOnBackdrop?: boolean;
|
|
15
|
+
/** `page` locks the host page without `showModal()` so window chrome stays usable; `panel` scopes the backdrop to the panel content area. */
|
|
16
|
+
modal?: 'page' | 'panel';
|
|
17
|
+
/**
|
|
18
|
+
* 是否显示遮罩,默认 true。与 `modal`、`closeOnBackdrop` 独立。
|
|
19
|
+
* 无遮罩时不可点遮罩关闭;若仍是模态,焦点仍锁在对话框内。
|
|
20
|
+
*/
|
|
21
|
+
mask?: boolean;
|
|
22
|
+
onConfirm?: () => void | Promise<void>;
|
|
23
|
+
onClose?: (result: DialogResult) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const Dialog: import("./component.js").ComponentDef<DialogProps, {
|
|
26
|
+
close: DialogResult;
|
|
27
|
+
}, HTMLElement>;
|
package/dist/ui/dom.d.ts
CHANGED
|
@@ -17,22 +17,50 @@ export interface ElementAttrs {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: ElementAttrs | null, children?: Children): HTMLElementTagNameMap[K];
|
|
19
19
|
export declare function append(parent: Element, children?: Children): void;
|
|
20
|
-
export declare function icon(name: IconName | undefined, size?: number, strokeWidth?: number): SVGSVGElement;
|
|
20
|
+
export declare function icon(name: IconName | undefined, size?: number | 'sm' | 'md', strokeWidth?: number): SVGSVGElement;
|
|
21
21
|
export declare function clear(node: Element): void;
|
|
22
|
-
export
|
|
22
|
+
export interface ButtonOptions {
|
|
23
23
|
icon?: IconName;
|
|
24
24
|
tone?: 'default' | 'primary' | 'danger' | 'ghost';
|
|
25
|
-
|
|
25
|
+
size?: 'sm' | 'md';
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
loading?: boolean;
|
|
26
28
|
title?: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export declare function
|
|
31
|
-
export declare function
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
onClick?: (event: MouseEvent) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function paintButton(el: HTMLButtonElement, label: string, opts: ButtonOptions): void;
|
|
33
|
+
export declare function button(label: string, opts?: ButtonOptions): HTMLButtonElement;
|
|
34
|
+
export declare const COPY_FEEDBACK_MS = 1200;
|
|
35
|
+
/** 复制反馈默认使用绿色对勾,也可以临时切换按钮中预留的文案。 */
|
|
36
|
+
export declare function flashCopied(btn: HTMLButtonElement, feedback?: {
|
|
37
|
+
label: string;
|
|
38
|
+
ok: boolean;
|
|
39
|
+
}): void;
|
|
40
|
+
export interface FieldOptions {
|
|
41
|
+
hint?: string;
|
|
42
|
+
error?: string;
|
|
43
|
+
layout?: 'vertical' | 'horizontal';
|
|
44
|
+
}
|
|
45
|
+
/** Associate a Field label with the first focusable control and mark error state. */
|
|
46
|
+
export declare function bindFieldControl(control: Node | undefined, options: {
|
|
47
|
+
id: string;
|
|
48
|
+
invalid?: boolean;
|
|
49
|
+
describedBy?: string;
|
|
50
|
+
}): string | undefined;
|
|
51
|
+
export declare function field(label: string, control: Node, hint?: string | FieldOptions): HTMLElement;
|
|
52
|
+
export interface EmptyOptions {
|
|
53
|
+
icon?: IconName;
|
|
54
|
+
action?: Node;
|
|
55
|
+
compact?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare function empty(text: string, iconName?: IconName | EmptyOptions): HTMLElement;
|
|
32
58
|
export declare function tag(text: string, tone?: 'neutral' | 'ok' | 'warn' | 'error' | 'info'): HTMLElement;
|
|
33
59
|
export declare function segmented<T extends string>(items: Array<{
|
|
34
60
|
value: T;
|
|
35
61
|
label: string;
|
|
36
62
|
icon?: IconName;
|
|
37
|
-
}>, value: T, onPick: (value: T) => void
|
|
63
|
+
}>, value: T, onPick: (value: T) => void, options?: {
|
|
64
|
+
ariaLabel?: string;
|
|
65
|
+
}): HTMLElement;
|
|
38
66
|
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type ButtonOptions } from './dom.js';
|
|
2
|
+
import type { IconName } from '../types.js';
|
|
3
|
+
/** 两段式确认倒计时,与快捷操作一致 */
|
|
4
|
+
export declare const BUTTON_CONFIRM_MS = 2600;
|
|
5
|
+
export interface ButtonProps extends ButtonOptions {
|
|
6
|
+
label: string;
|
|
7
|
+
/** 为 true 时使用默认文案;为字符串时使用自定义确认文案 */
|
|
8
|
+
confirm?: boolean | string;
|
|
9
|
+
}
|
|
10
|
+
export declare const Button: import("./component.js").ComponentDef<ButtonProps, {
|
|
11
|
+
click: MouseEvent;
|
|
12
|
+
}, HTMLButtonElement>;
|
|
13
|
+
export interface InputProps {
|
|
14
|
+
value?: string;
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
type?: 'text' | 'search' | 'password' | 'email' | 'url' | 'tel' | 'number';
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
readonly?: boolean;
|
|
20
|
+
clearable?: boolean;
|
|
21
|
+
mono?: boolean;
|
|
22
|
+
prefixIcon?: IconName;
|
|
23
|
+
size?: 'sm' | 'md';
|
|
24
|
+
ariaLabel?: string;
|
|
25
|
+
onInput?: (value: string) => void;
|
|
26
|
+
onChange?: (value: string) => void;
|
|
27
|
+
onEnter?: (value: string) => void;
|
|
28
|
+
}
|
|
29
|
+
type InputEvents = {
|
|
30
|
+
input: string;
|
|
31
|
+
change: string;
|
|
32
|
+
enter: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const Input: import("./component.js").ComponentDef<InputProps, InputEvents, HTMLElement>;
|
|
35
|
+
export interface TextareaProps {
|
|
36
|
+
value?: string;
|
|
37
|
+
defaultValue?: string;
|
|
38
|
+
placeholder?: string;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
readonly?: boolean;
|
|
41
|
+
mono?: boolean;
|
|
42
|
+
rows?: number;
|
|
43
|
+
ariaLabel?: string;
|
|
44
|
+
onInput?: (value: string) => void;
|
|
45
|
+
onChange?: (value: string) => void;
|
|
46
|
+
}
|
|
47
|
+
type TextareaEvents = {
|
|
48
|
+
input: string;
|
|
49
|
+
change: string;
|
|
50
|
+
};
|
|
51
|
+
export declare const Textarea: import("./component.js").ComponentDef<TextareaProps, TextareaEvents, HTMLTextAreaElement>;
|
|
52
|
+
export interface TagProps {
|
|
53
|
+
text: string;
|
|
54
|
+
tone?: 'neutral' | 'ok' | 'warn' | 'error' | 'info';
|
|
55
|
+
}
|
|
56
|
+
export declare const Tag: import("./component.js").ComponentDef<TagProps, Record<string, never>, HTMLSpanElement>;
|
|
57
|
+
export interface SegmentedItem<T extends string = string> {
|
|
58
|
+
value: T;
|
|
59
|
+
label: string;
|
|
60
|
+
icon?: IconName;
|
|
61
|
+
}
|
|
62
|
+
export interface SegmentedProps<T extends string = string> {
|
|
63
|
+
items: Array<SegmentedItem<T>>;
|
|
64
|
+
value?: T;
|
|
65
|
+
defaultValue?: T;
|
|
66
|
+
ariaLabel?: string;
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
readonly?: boolean;
|
|
69
|
+
onChange?: (value: T) => void;
|
|
70
|
+
}
|
|
71
|
+
export declare const Segmented: import("./component.js").ComponentDef<SegmentedProps<string>, {
|
|
72
|
+
change: string;
|
|
73
|
+
}, HTMLElement>;
|
|
74
|
+
type BooleanEvent = {
|
|
75
|
+
change: boolean;
|
|
76
|
+
};
|
|
77
|
+
export interface SwitchProps {
|
|
78
|
+
ariaLabel: string;
|
|
79
|
+
value?: boolean;
|
|
80
|
+
defaultValue?: boolean;
|
|
81
|
+
disabled?: boolean;
|
|
82
|
+
readonly?: boolean;
|
|
83
|
+
onChange?: (value: boolean) => void;
|
|
84
|
+
}
|
|
85
|
+
export declare const Switch: import("./component.js").ComponentDef<SwitchProps, BooleanEvent, HTMLButtonElement>;
|
|
86
|
+
interface ChoiceProps {
|
|
87
|
+
label: string;
|
|
88
|
+
checked?: boolean;
|
|
89
|
+
defaultChecked?: boolean;
|
|
90
|
+
disabled?: boolean;
|
|
91
|
+
readonly?: boolean;
|
|
92
|
+
name?: string;
|
|
93
|
+
value?: string;
|
|
94
|
+
onChange?: (checked: boolean) => void;
|
|
95
|
+
}
|
|
96
|
+
export interface CheckboxProps extends ChoiceProps {
|
|
97
|
+
indeterminate?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface RadioProps extends ChoiceProps {
|
|
100
|
+
name: string;
|
|
101
|
+
}
|
|
102
|
+
export declare const Checkbox: import("./component.js").ComponentDef<CheckboxProps, BooleanEvent, HTMLLabelElement>;
|
|
103
|
+
export declare const Radio: import("./component.js").ComponentDef<RadioProps, BooleanEvent, HTMLLabelElement>;
|
|
104
|
+
export declare function input(props?: InputProps): HTMLInputElement;
|
|
105
|
+
export declare function textarea(props?: TextareaProps): HTMLTextAreaElement;
|
|
106
|
+
export declare function switchControl({ value, ...props }: SwitchProps): HTMLButtonElement;
|
|
107
|
+
export declare function checkbox(props: CheckboxProps): HTMLLabelElement;
|
|
108
|
+
export declare function radio(props: RadioProps): HTMLLabelElement;
|
|
109
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface CopyResult {
|
|
2
|
+
text: string;
|
|
3
|
+
ok: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface KeyValueItem {
|
|
6
|
+
key: string;
|
|
7
|
+
value: unknown;
|
|
8
|
+
copyable?: boolean;
|
|
9
|
+
render?: (value: unknown) => Node | string | number;
|
|
10
|
+
}
|
|
11
|
+
export interface KeyValueProps {
|
|
12
|
+
items: readonly KeyValueItem[];
|
|
13
|
+
columns?: number;
|
|
14
|
+
empty?: string;
|
|
15
|
+
compact?: boolean;
|
|
16
|
+
onCopy?: (result: CopyResult) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const KeyValue: import("./component.js").ComponentDef<KeyValueProps, {
|
|
19
|
+
copy: CopyResult;
|
|
20
|
+
}, HTMLDListElement>;
|
|
21
|
+
/** JsonView 超大数组按该页大小分片展开 */
|
|
22
|
+
export declare const JSON_VIEW_PAGE_SIZE = 100;
|
|
23
|
+
export interface JsonViewProps {
|
|
24
|
+
value: unknown;
|
|
25
|
+
/** Number of initially expanded levels (default 1). */
|
|
26
|
+
depth?: number;
|
|
27
|
+
collapsed?: boolean;
|
|
28
|
+
onCopy?: (result: CopyResult) => void;
|
|
29
|
+
}
|
|
30
|
+
export declare const JsonView: import("./component.js").ComponentDef<JsonViewProps, {
|
|
31
|
+
copy: CopyResult;
|
|
32
|
+
}, HTMLElement>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** 面板拖拽 / 尺寸变化时派发,供 popup 与 Dialog 重新定位或关闭 */
|
|
2
|
+
export declare const PANEL_MOVE_EVENT = "rdt-panel-move";
|
|
3
|
+
export interface LayoutWatch {
|
|
4
|
+
stop(): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 用 scroll(capture)、resize、ResizeObserver 和面板拖拽事件驱动回调。
|
|
8
|
+
* 只用一次性 rAF 合并同一帧内的多次事件,不再常驻每帧空转。
|
|
9
|
+
*/
|
|
10
|
+
export declare function watchLayout(targets: Array<Element | null | undefined>, onChange: () => void): LayoutWatch;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type EmptyOptions, type FieldOptions } from './dom.js';
|
|
2
|
+
export type LayoutNode = Node | string;
|
|
3
|
+
export type LayoutContent = LayoutNode | readonly LayoutNode[];
|
|
4
|
+
type NoEvents = Record<never, never>;
|
|
5
|
+
declare function slot(el: HTMLElement): (value?: LayoutContent) => void;
|
|
6
|
+
export interface ToolbarProps {
|
|
7
|
+
title?: string;
|
|
8
|
+
content?: LayoutContent;
|
|
9
|
+
actions?: LayoutContent;
|
|
10
|
+
}
|
|
11
|
+
export declare const Toolbar: import("./component.js").ComponentDef<ToolbarProps, NoEvents, HTMLElement>;
|
|
12
|
+
export interface StatusBarProps {
|
|
13
|
+
status?: LayoutContent;
|
|
14
|
+
detail?: LayoutContent;
|
|
15
|
+
}
|
|
16
|
+
export declare const StatusBar: import("./component.js").ComponentDef<StatusBarProps, NoEvents, HTMLElement>;
|
|
17
|
+
export interface SectionProps {
|
|
18
|
+
title: string;
|
|
19
|
+
content?: LayoutContent;
|
|
20
|
+
collapsible?: boolean;
|
|
21
|
+
defaultOpen?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const Section: import("./component.js").ComponentDef<SectionProps, NoEvents, HTMLElement>;
|
|
24
|
+
export interface ScrollAreaProps {
|
|
25
|
+
content?: LayoutContent;
|
|
26
|
+
ariaLabel?: string;
|
|
27
|
+
maxHeight?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare const ScrollArea: import("./component.js").ComponentDef<ScrollAreaProps, NoEvents, HTMLElement>;
|
|
30
|
+
export interface FieldProps extends FieldOptions {
|
|
31
|
+
label: string;
|
|
32
|
+
control?: Node;
|
|
33
|
+
}
|
|
34
|
+
export declare const Field: import("./component.js").ComponentDef<FieldProps, NoEvents, HTMLElement>;
|
|
35
|
+
export interface EmptyProps extends EmptyOptions {
|
|
36
|
+
text: string;
|
|
37
|
+
}
|
|
38
|
+
export declare const Empty: import("./component.js").ComponentDef<EmptyProps, NoEvents, HTMLElement>;
|
|
39
|
+
export declare const toolbar: (props: ToolbarProps) => HTMLElement;
|
|
40
|
+
export declare const statusBar: (props: StatusBarProps) => HTMLElement;
|
|
41
|
+
export declare const section: (props: SectionProps) => HTMLElement;
|
|
42
|
+
export declare const scrollArea: (props: ScrollAreaProps) => HTMLElement;
|
|
43
|
+
export { slot as createLayoutSlot };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DefaultCorner } from '../types.js';
|
|
2
|
+
/** 视口安全边距(防越界) */
|
|
3
|
+
export declare const SAFE_GAP = 8;
|
|
4
|
+
export declare const MIN_PANEL_WIDTH = 280;
|
|
5
|
+
export declare const MIN_PANEL_HEIGHT = 220;
|
|
6
|
+
export interface PanelRect {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ViewportSize {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 放大锚定角(交互设计 6.2):
|
|
18
|
+
* - 停在默认角(未拖过或复位之后):锚定默认角;
|
|
19
|
+
* - 拖离默认角:按面板中心所在象限选最近的视口角;中心恰在中线上时水平取左、垂直取下。
|
|
20
|
+
*/
|
|
21
|
+
export declare function pickMaximizeAnchor(base: PanelRect, viewport: ViewportSize, defaultCorner: DefaultCorner, docked: boolean): DefaultCorner;
|
|
22
|
+
/**
|
|
23
|
+
* 原位放大矩形(设计规范 5.2):锚定角不动,另外两边长到视口安全边距。
|
|
24
|
+
* - 放大前尺寸先按视口可用区域(视口减两侧安全边距)收窄,再不低于最小尺寸;与壳层 resolveDimensions 同一口径;
|
|
25
|
+
* - 锚点越界先夹回安全区(唯一允许移动锚点的情况);
|
|
26
|
+
* - 只增不减:每个方向取 max(收窄后的放大前尺寸, 可长到的尺寸);
|
|
27
|
+
* - 可用区域小于最小尺寸时取最小尺寸,锚定角所在一侧贴安全边距,超出部分落在对边之外;
|
|
28
|
+
* - 长大区域与悬浮球相交时,该方向止于悬浮球外 SAFE_GAP。
|
|
29
|
+
*/
|
|
30
|
+
export declare function maximizedRect(base: PanelRect, anchor: DefaultCorner, viewport: ViewportSize, launcher: PanelRect | null): PanelRect;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type PopupCloseReason, type PopupPlacement } from './popup.js';
|
|
2
|
+
import type { IconName } from '../types.js';
|
|
3
|
+
type PopupEvents = {
|
|
4
|
+
open: undefined;
|
|
5
|
+
close: PopupCloseReason;
|
|
6
|
+
};
|
|
7
|
+
export interface OverlayProps {
|
|
8
|
+
label?: string;
|
|
9
|
+
trigger?: Node;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
placement?: PopupPlacement;
|
|
13
|
+
onOpen?: () => void;
|
|
14
|
+
onClose?: (reason: PopupCloseReason) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function resolveTrigger(props: {
|
|
17
|
+
label?: string;
|
|
18
|
+
trigger?: Node;
|
|
19
|
+
}, tone?: 'ghost'): {
|
|
20
|
+
trigger: HTMLElement;
|
|
21
|
+
defaultTrigger: boolean;
|
|
22
|
+
};
|
|
23
|
+
export interface TooltipProps extends OverlayProps {
|
|
24
|
+
text: string;
|
|
25
|
+
delay?: number;
|
|
26
|
+
maxWidth?: number;
|
|
27
|
+
/** 仅侧栏图标使用:指针或焦点离开即刻收起,不保留 120ms 尾巴。默认 'delayed'。 */
|
|
28
|
+
dismiss?: 'delayed' | 'immediate';
|
|
29
|
+
}
|
|
30
|
+
export declare const Tooltip: import("./component.js").ComponentDef<TooltipProps, PopupEvents, HTMLElement>;
|
|
31
|
+
export interface PopoverProps extends OverlayProps {
|
|
32
|
+
content?: string | Node;
|
|
33
|
+
ariaLabel?: string;
|
|
34
|
+
closeOnOutside?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare const Popover: import("./component.js").ComponentDef<PopoverProps, PopupEvents, HTMLElement>;
|
|
37
|
+
export type ContextMenuItem = {
|
|
38
|
+
value: string;
|
|
39
|
+
label: string;
|
|
40
|
+
icon?: IconName;
|
|
41
|
+
danger?: boolean;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
divider?: false;
|
|
44
|
+
} | {
|
|
45
|
+
divider: true;
|
|
46
|
+
};
|
|
47
|
+
export interface ContextMenuProps extends OverlayProps {
|
|
48
|
+
items: readonly ContextMenuItem[];
|
|
49
|
+
onSelect?: (value: string) => void;
|
|
50
|
+
}
|
|
51
|
+
export declare const ContextMenu: import("./component.js").ComponentDef<ContextMenuProps, PopupEvents & {
|
|
52
|
+
select: string;
|
|
53
|
+
}, HTMLElement>;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Light-DOM host for official popups that have no `.rdt-root` / ShadowRoot to mount into. */
|
|
2
|
+
export declare const PAGE_OVERLAY_HOST_ID = "rdt-page-overlays";
|
|
3
|
+
/**
|
|
4
|
+
* Return the style-bearing `.rdt-root` used when `createPopup` falls back outside
|
|
5
|
+
* the DevTools Shadow DOM. The host is `position: fixed` and ignores pointer
|
|
6
|
+
* events, so opening a page-level Popover does not shove the document or
|
|
7
|
+
* collapse into an unthemed in-flow bar.
|
|
8
|
+
*/
|
|
9
|
+
export declare function pageOverlayRoot(doc?: Document): HTMLElement;
|