agentcss 0.25.6 → 0.26.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/01-tokens/behavior/labels.js +44 -0
- package/02-primitives/combobox/combobox.js +26 -3
- package/02-primitives/date-range/date-range.js +27 -5
- package/02-primitives/popover/popover.js +22 -2
- package/02-primitives/select/select.js +23 -2
- package/02-primitives/upload/upload.js +50 -17
- package/03-patterns/content/content.css +13 -1
- package/03-patterns/content/demo.html +1 -1
- package/03-patterns/drawer/drawer.js +44 -6
- package/03-patterns/dropdown/dropdown.js +21 -1
- package/03-patterns/overlay/overlay.js +39 -2
- package/03-patterns/pagination/pagination.js +37 -10
- package/03-patterns/tooltip/tooltip.js +17 -2
- package/03-patterns/tree/tree.js +21 -1
- package/04-recipes/analysis-report/demo.html +1 -1
- package/04-recipes/data-showcase/demo.html +2 -2
- package/04-recipes/longform/content.html +989 -74
- package/04-recipes/longform/longform.html +3 -3
- package/04-recipes/report/demo.html +1 -1
- package/04-recipes/table/README.md +22 -0
- package/04-recipes/table/demo.html +6 -6
- package/09-assets/bar/bar.js +28 -4
- package/09-assets/model-viewer/model-viewer.js +44 -12
- package/09-assets/scientific-plot/demo.html +6 -6
- package/API.md +32 -0
- package/CHANGELOG.md +71 -0
- package/README.md +17 -0
- package/README.zh-CN.md +16 -0
- package/SECURITY.md +16 -4
- package/START-HERE.md +14 -14
- package/ai/components.json +9 -4
- package/ai/pdf.js +50 -8
- package/dist/01-tokens/behavior/labels.js +11 -0
- package/dist/02-primitives/combobox/combobox.js +25 -3
- package/dist/02-primitives/date-range/date-range.js +26 -5
- package/dist/02-primitives/popover/popover.js +14 -1
- package/dist/02-primitives/select/select.js +22 -2
- package/dist/02-primitives/upload/upload.js +47 -17
- package/dist/03-patterns/content/content.css +1 -1
- package/dist/03-patterns/drawer/drawer.js +32 -4
- package/dist/03-patterns/dropdown/dropdown.js +20 -1
- package/dist/03-patterns/overlay/overlay.js +25 -1
- package/dist/03-patterns/pagination/pagination.js +34 -10
- package/dist/03-patterns/tooltip/tooltip.js +14 -2
- package/dist/03-patterns/tree/tree.js +20 -1
- package/dist/09-assets/bar/bar.js +23 -4
- package/dist/09-assets/model-viewer/model-viewer.js +38 -12
- package/dist/COSTS.md +14 -14
- package/docs/ACCESSIBILITY.md +2 -2
- package/docs/L10N.md +92 -0
- package/docs/RELEASE-PROCESS.md +7 -1
- package/docs/VERIFY-RELEASE.md +7 -2
- package/index.html +1 -1
- package/llms-full.txt +2 -2
- package/package.json +3 -2
- package/types/index.d.ts +218 -13
package/types/index.d.ts
CHANGED
|
@@ -61,6 +61,101 @@ export interface Destroyable {
|
|
|
61
61
|
destroy(): void;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/* ============================================================================
|
|
65
|
+
* 本地化文案(0.26.0)
|
|
66
|
+
*
|
|
67
|
+
* 所有组件默认输出中文;传 `labels` 可覆盖**用户可见 / 读屏会念到**的文案。
|
|
68
|
+
* 值可以是字符串,也可以是函数(动态文案,如 `第 N 页`)。
|
|
69
|
+
* 不传时行为与 0.25.x **逐字相同**。
|
|
70
|
+
*
|
|
71
|
+
* ⚠️ 开发期错误信息(`throw new Error('…')`)不在覆盖范围内 ——
|
|
72
|
+
* 它们面向调用方,不经过 UI,详见 docs/L10N.md。
|
|
73
|
+
* ========================================================================== */
|
|
74
|
+
export interface PaginationLabels {
|
|
75
|
+
nav?: string;
|
|
76
|
+
prev?: string;
|
|
77
|
+
next?: string;
|
|
78
|
+
page?(page: number, isCurrent: boolean): string;
|
|
79
|
+
status?(page: number, pages: number): string;
|
|
80
|
+
live?(page: number, pages: number): string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface UploadLabels {
|
|
84
|
+
pending?: string;
|
|
85
|
+
done?: string;
|
|
86
|
+
error?: string;
|
|
87
|
+
remove?(name: string): string;
|
|
88
|
+
uploading?(pct: number): string;
|
|
89
|
+
countMax?(n: number): string;
|
|
90
|
+
sizeMax?(limit: string): string;
|
|
91
|
+
type?: string;
|
|
92
|
+
folder?: string;
|
|
93
|
+
none?(reason: string): string;
|
|
94
|
+
noDrop?: string;
|
|
95
|
+
noDropShort?: string;
|
|
96
|
+
summary?(added: number, total: number, rejected: number): string;
|
|
97
|
+
removed?(name: string, rest: number): string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface DrawerLabels {
|
|
101
|
+
dialog?: string;
|
|
102
|
+
close?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface OverlayLabels {
|
|
106
|
+
closeToast?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface SelectLabels {
|
|
110
|
+
option?: string;
|
|
111
|
+
placeholder?: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface ComboboxLabels {
|
|
115
|
+
suggest?: string;
|
|
116
|
+
input?: string;
|
|
117
|
+
noMatch?(query: string): string;
|
|
118
|
+
empty?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface TreeLabels {
|
|
122
|
+
tree?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface DropdownLabels {
|
|
126
|
+
menu?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface DateRangeLabels {
|
|
130
|
+
requiredEnd?: string;
|
|
131
|
+
requiredStart?: string;
|
|
132
|
+
order?(from: string, to: string): string;
|
|
133
|
+
min?(min: string): string;
|
|
134
|
+
max?(max: string): string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface NavLabels {
|
|
138
|
+
open?: string;
|
|
139
|
+
close?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** ⚠️ `bar` 用 `text` 而不是 `labels`:`labels` 早就是「X 轴标签」这个数据参数 */
|
|
143
|
+
export interface BarText {
|
|
144
|
+
series?(index: number): string;
|
|
145
|
+
clipped?(n: number, isStack: boolean, max: number): string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface ModelViewerLabels {
|
|
149
|
+
load?: string;
|
|
150
|
+
placeholder?: string;
|
|
151
|
+
hintBefore?: string;
|
|
152
|
+
hintBetween?: string;
|
|
153
|
+
hintStrong?: string;
|
|
154
|
+
hintTail?: string;
|
|
155
|
+
downloading?(pct: number): string;
|
|
156
|
+
noWebGL?: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
64
159
|
/* ============================================================================
|
|
65
160
|
* select —— 单选下拉
|
|
66
161
|
* ========================================================================== */
|
|
@@ -80,6 +175,8 @@ export interface SelectOptions {
|
|
|
80
175
|
value?: string;
|
|
81
176
|
placeholder?: string;
|
|
82
177
|
disabled?: boolean;
|
|
178
|
+
/** 读屏 / 占位文案覆盖(默认中文) */
|
|
179
|
+
labels?: SelectLabels;
|
|
83
180
|
/**
|
|
84
181
|
* ⭐ 变更回调。**两个参数**,不是数组。
|
|
85
182
|
* runtime:`opt.onChange(selected, 显示文本)`
|
|
@@ -129,6 +226,8 @@ export interface ComboboxOptions {
|
|
|
129
226
|
max?: number;
|
|
130
227
|
placeholder?: string;
|
|
131
228
|
disabled?: boolean;
|
|
229
|
+
/** 读屏 / 空态文案覆盖(默认中文) */
|
|
230
|
+
labels?: ComboboxLabels;
|
|
132
231
|
/** 变更回调(传已选的 value 数组) */
|
|
133
232
|
onChange?(values: string[]): void;
|
|
134
233
|
/**
|
|
@@ -197,6 +296,8 @@ export interface DateRangeOptions {
|
|
|
197
296
|
/** 是否允许手动输入 */
|
|
198
297
|
editable?: boolean;
|
|
199
298
|
disabled?: boolean;
|
|
299
|
+
/** 校验文案覆盖(默认中文) */
|
|
300
|
+
labels?: DateRangeLabels;
|
|
200
301
|
/**
|
|
201
302
|
* ⭐ 变更回调。**第一个参数是对象,第二个是布尔**。
|
|
202
303
|
* runtime:`opt.onChange({ from, to, valid }, valid)`
|
|
@@ -270,6 +371,8 @@ export interface Dropdown {
|
|
|
270
371
|
export interface TreeOptions {
|
|
271
372
|
/** 无障碍名(读屏会读它) */
|
|
272
373
|
label?: string;
|
|
374
|
+
/** 读屏文案覆盖(默认中文)—— `label` 优先级更高 */
|
|
375
|
+
labels?: TreeLabels;
|
|
273
376
|
}
|
|
274
377
|
|
|
275
378
|
/* ============================================================================
|
|
@@ -340,7 +443,7 @@ export interface PaginationApi {
|
|
|
340
443
|
/** 为一个 `[data-pagination]` 节点建实例;同一节点重复调用返回同一个。
|
|
341
444
|
* ⚠️ 实例成员未在本文件收窄(源码里只挂了内部状态),需要时读
|
|
342
445
|
* `03-patterns/pagination/README.md`。 */
|
|
343
|
-
create(node: HTMLElement): object | null;
|
|
446
|
+
create(node: HTMLElement, opts?: { labels?: PaginationLabels }): object | null;
|
|
344
447
|
/** 扫描并初始化(默认整个 document) */
|
|
345
448
|
update(root?: HTMLElement): void;
|
|
346
449
|
/** 总条数 ÷ 每页条数 → 页数(至少 1) */
|
|
@@ -353,22 +456,69 @@ export interface DismissableOverlay {
|
|
|
353
456
|
close(): void;
|
|
354
457
|
}
|
|
355
458
|
|
|
459
|
+
export interface ToastOptions {
|
|
460
|
+
title?: string;
|
|
461
|
+
desc?: string;
|
|
462
|
+
variant?: 'success' | 'error' | 'warning';
|
|
463
|
+
/** 毫秒;`0` = 不自动消失。不传时 error 为 0、其余 4000 */
|
|
464
|
+
duration?: number;
|
|
465
|
+
/** 同屏上限;超了摘掉最旧的。不传默认 4,`0` = 不限 */
|
|
466
|
+
maxVisible?: number;
|
|
467
|
+
/** 关闭按钮的读屏文案(默认「关闭提示」) */
|
|
468
|
+
labels?: OverlayLabels;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export interface DialogAction {
|
|
472
|
+
text: string;
|
|
473
|
+
value?: string;
|
|
474
|
+
/** 视觉/语义变体(源码按 `actions` 的 `kind` 判定,未知值退回默认) */
|
|
475
|
+
kind?: 'primary' | 'danger' | 'ghost';
|
|
476
|
+
onClick?(): void;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface DialogOptions {
|
|
480
|
+
title?: string;
|
|
481
|
+
desc?: string;
|
|
482
|
+
actions?: DialogAction[];
|
|
483
|
+
danger?: boolean;
|
|
484
|
+
/** 初始焦点落点;不传落在对话框容器上 */
|
|
485
|
+
initialFocus?: HTMLElement;
|
|
486
|
+
}
|
|
487
|
+
|
|
356
488
|
export interface OverlayApi {
|
|
357
|
-
/**
|
|
358
|
-
toast(opts:
|
|
489
|
+
/** 顶部提示条 */
|
|
490
|
+
toast(opts: ToastOptions): { el: HTMLElement; close(): void };
|
|
359
491
|
/** 模态对话框 —— 返回句柄,可编程关闭 */
|
|
360
|
-
dialog(opts:
|
|
492
|
+
dialog(opts: DialogOptions): DismissableOverlay;
|
|
361
493
|
}
|
|
362
494
|
|
|
363
495
|
export interface TooltipApi {
|
|
364
496
|
/** 给元素挂一个提示。`place` 决定方向(源码默认值以 README 为准) */
|
|
365
497
|
attach(el: HTMLElement, text: string, place?: string): void;
|
|
498
|
+
/** 覆盖 live region 的读屏名(默认「组件提示」) */
|
|
499
|
+
setLabels(patch: { region?: string }): void;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export interface PopoverOptions {
|
|
503
|
+
/** 有意的 HTML 入口 —— **调用方负责净化**,或接 `sanitize` / `setSanitizer` */
|
|
504
|
+
html?: string;
|
|
505
|
+
/** 浮层方向 */
|
|
506
|
+
place?: 'top' | 'bottom' | 'start' | 'end';
|
|
507
|
+
/** 无障碍名 */
|
|
508
|
+
label?: string;
|
|
509
|
+
/** 逐次净化钩子(优先于模块级 `setSanitizer`) */
|
|
510
|
+
sanitize?(html: string): string;
|
|
511
|
+
onOpen?(): void;
|
|
512
|
+
onClose?(): void;
|
|
366
513
|
}
|
|
367
514
|
|
|
368
515
|
export interface PopoverApi {
|
|
369
|
-
attach(trigger: HTMLElement, opts?:
|
|
516
|
+
attach(trigger: HTMLElement, opts?: PopoverOptions): void;
|
|
370
517
|
closeAll(): void;
|
|
371
|
-
|
|
518
|
+
/** 当前打开的那个浮层的元素;没有则为 null(不是 unknown) */
|
|
519
|
+
readonly current: HTMLElement | null;
|
|
520
|
+
/** 模块级净化钩子:`Popover.setSanitizer(DOMPurify.sanitize)`;传 null 取消 */
|
|
521
|
+
setSanitizer(fn: ((html: string) => string) | null): void;
|
|
372
522
|
}
|
|
373
523
|
|
|
374
524
|
export interface TocApi {
|
|
@@ -470,7 +620,16 @@ export interface BarApi {
|
|
|
470
620
|
host: HTMLElement;
|
|
471
621
|
/** 🔴 必填:本库铁律三,量程不得自动适配(漏了会抛错,不会悄悄自适应) */
|
|
472
622
|
max: number;
|
|
473
|
-
series?:
|
|
623
|
+
series?: Array<{ name?: string; values: number[]; cls?: string }>;
|
|
624
|
+
/** X 轴标签(**数据**,不是文案覆盖) */
|
|
625
|
+
labels?: string[];
|
|
626
|
+
/** 可见文案覆盖 —— 因为 `labels` 已被 X 轴占用,这里叫 `text` */
|
|
627
|
+
text?: BarText;
|
|
628
|
+
/** 图表整体的无障碍名(默认「柱状图」) */
|
|
629
|
+
ariaLabel?: string;
|
|
630
|
+
/** 自定义说明段落(给了就不再自动生成截断提示) */
|
|
631
|
+
note?: string;
|
|
632
|
+
threshold?: number;
|
|
474
633
|
height?: number;
|
|
475
634
|
mode?: 'group' | 'stack';
|
|
476
635
|
}): void;
|
|
@@ -498,6 +657,43 @@ export interface UploadInstance {
|
|
|
498
657
|
removeAt(index: number): void;
|
|
499
658
|
}
|
|
500
659
|
|
|
660
|
+
/* ============================================================================
|
|
661
|
+
* 其余组件的选项(0.26.0 补齐:原本这些入口都写成 `opts?: object`,
|
|
662
|
+
* TS 放行一切、拼错键名也不会报错 —— 等于没有类型)
|
|
663
|
+
* ========================================================================== */
|
|
664
|
+
export interface DropdownOptions {
|
|
665
|
+
/** 菜单的无障碍名(默认「菜单」) */
|
|
666
|
+
label?: string;
|
|
667
|
+
labels?: DropdownLabels;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
export interface NavOptions {
|
|
671
|
+
labels?: NavLabels;
|
|
672
|
+
onOpen?(): void;
|
|
673
|
+
onClose?(): void;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export interface DrawerOpenOptions {
|
|
677
|
+
place?: 'left' | 'right' | 'top' | 'bottom';
|
|
678
|
+
title?: string;
|
|
679
|
+
/** 无标题时的无障碍名(默认「抽屉」) */
|
|
680
|
+
label?: string;
|
|
681
|
+
/** 有意的 HTML 入口(字符串)—— 调用方负责净化,或接 `sanitize` */
|
|
682
|
+
content?: string | Node;
|
|
683
|
+
/** 逐次净化钩子(优先于模块级 `Drawer.setSanitizer`) */
|
|
684
|
+
sanitize?(html: string): string;
|
|
685
|
+
labels?: DrawerLabels;
|
|
686
|
+
actions?: Array<{ text: string; kind?: 'primary' | 'danger' | 'ghost'; onClick?(): void }>;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export interface UploadOptions {
|
|
690
|
+
/** 单文件大小上限(字节),0 = 不限 */
|
|
691
|
+
maxSize?: number;
|
|
692
|
+
/** 文件数上限,0 = 不限 */
|
|
693
|
+
maxFiles?: number;
|
|
694
|
+
labels?: UploadLabels;
|
|
695
|
+
}
|
|
696
|
+
|
|
501
697
|
/* ============================================================================
|
|
502
698
|
* 全局命名空间(组件脚本是 IIFE,挂到 window)
|
|
503
699
|
* ========================================================================== */
|
|
@@ -505,15 +701,18 @@ export interface FrontendLibGlobal {
|
|
|
505
701
|
DateRange: DateRangeStatics;
|
|
506
702
|
Select: { create(root: HTMLElement, opt: SelectOptions): Select };
|
|
507
703
|
Combobox: { create(root: HTMLElement, opt: ComboboxOptions): Combobox };
|
|
508
|
-
Dropdown: { create(root: HTMLElement, opt?:
|
|
704
|
+
Dropdown: { create(root: HTMLElement, opt?: DropdownOptions): Dropdown };
|
|
509
705
|
Tree: { create(root: HTMLElement, opt?: TreeOptions): Tree };
|
|
510
706
|
/** construct 形态:`new window.Accordion(root, opts)` */
|
|
511
707
|
Accordion: new (root: HTMLElement, opts?: AccordionOptions) => AccordionInstance;
|
|
512
708
|
/** construct 形态:`new window.Tabs(root, opts)` */
|
|
513
709
|
Tabs: new (root: HTMLElement, opts?: object) => TabsInstance;
|
|
514
|
-
Nav: { attach(root: HTMLElement, opts?:
|
|
710
|
+
Nav: { attach(root: HTMLElement, opts?: NavOptions): NavInstance };
|
|
515
711
|
Pagination: PaginationApi;
|
|
516
|
-
Drawer: {
|
|
712
|
+
Drawer: {
|
|
713
|
+
open(opt?: DrawerOpenOptions): DismissableOverlay;
|
|
714
|
+
setSanitizer(fn: ((html: string) => string) | null): void;
|
|
715
|
+
};
|
|
517
716
|
Overlay: OverlayApi;
|
|
518
717
|
Tooltip: TooltipApi;
|
|
519
718
|
Popover: PopoverApi;
|
|
@@ -524,14 +723,20 @@ export interface FrontendLibGlobal {
|
|
|
524
723
|
Theme: ThemeApi;
|
|
525
724
|
Chart: ChartApi;
|
|
526
725
|
ChartAdapter: ChartAdapterApi;
|
|
527
|
-
/**
|
|
528
|
-
|
|
726
|
+
/** 🔴 不是构造函数:运行时就挂在 window 上的是 `{ update, refresh, setLabels }`。
|
|
727
|
+
* 之前声明成 `new (node)` ⇒ TS 允许 `new window.ModelViewer(el)`,
|
|
728
|
+
* 运行时直接 `TypeError: ModelViewer is not a constructor`。 */
|
|
729
|
+
ModelViewer: {
|
|
730
|
+
update(root?: HTMLElement): void;
|
|
731
|
+
refresh(root?: HTMLElement): void;
|
|
732
|
+
setLabels(patch: ModelViewerLabels): void;
|
|
733
|
+
};
|
|
529
734
|
Bar: BarApi;
|
|
530
735
|
ScientificPlot: ScientificPlotApi;
|
|
531
736
|
/** construct 形态:`new window.ShellNav(root, opts)` */
|
|
532
737
|
ShellNav: new (root: HTMLElement, opts?: object) => ShellNavInstance;
|
|
533
738
|
/** construct 形态:`new window.Upload(root, opts)` */
|
|
534
|
-
Upload: new (root: HTMLElement, opts?:
|
|
739
|
+
Upload: new (root: HTMLElement, opts?: UploadOptions) => UploadInstance;
|
|
535
740
|
}
|
|
536
741
|
|
|
537
742
|
declare global {
|