ice-web-components 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +487 -0
  3. package/dist/index.cjs +1 -0
  4. package/dist/index.mjs +1 -0
  5. package/dist/index.umd.js +1 -0
  6. package/dist/types/components/ICEAlert.d.ts +28 -0
  7. package/dist/types/components/ICEAnchor.d.ts +69 -0
  8. package/dist/types/components/ICEAutoComplete.d.ts +71 -0
  9. package/dist/types/components/ICEAvatar.d.ts +11 -0
  10. package/dist/types/components/ICEAvatarGroup.d.ts +40 -0
  11. package/dist/types/components/ICEBackTop.d.ts +39 -0
  12. package/dist/types/components/ICEBadge.d.ts +17 -0
  13. package/dist/types/components/ICEBreadcrumb.d.ts +82 -0
  14. package/dist/types/components/ICEButton.d.ts +25 -0
  15. package/dist/types/components/ICECalendar.d.ts +84 -0
  16. package/dist/types/components/ICECard.d.ts +22 -0
  17. package/dist/types/components/ICECarousel.d.ts +86 -0
  18. package/dist/types/components/ICECascader.d.ts +84 -0
  19. package/dist/types/components/ICECheckBox.d.ts +21 -0
  20. package/dist/types/components/ICECheckboxGroup.d.ts +75 -0
  21. package/dist/types/components/ICECollapse.d.ts +49 -0
  22. package/dist/types/components/ICEColorPicker.d.ts +52 -0
  23. package/dist/types/components/ICEComment.d.ts +36 -0
  24. package/dist/types/components/ICEDatePicker.d.ts +90 -0
  25. package/dist/types/components/ICEDescriptions.d.ts +40 -0
  26. package/dist/types/components/ICEDrawer.d.ts +59 -0
  27. package/dist/types/components/ICEDropdown.d.ts +63 -0
  28. package/dist/types/components/ICEEmpty.d.ts +28 -0
  29. package/dist/types/components/ICEFloatButton.d.ts +63 -0
  30. package/dist/types/components/ICEForm.d.ts +48 -0
  31. package/dist/types/components/ICEFormItem.d.ts +65 -0
  32. package/dist/types/components/ICEGrid.d.ts +59 -0
  33. package/dist/types/components/ICEIcon.d.ts +9 -0
  34. package/dist/types/components/ICEIconTile.d.ts +53 -0
  35. package/dist/types/components/ICEImagePreview.d.ts +91 -0
  36. package/dist/types/components/ICEImageView.d.ts +62 -0
  37. package/dist/types/components/ICEInputNumber.d.ts +54 -0
  38. package/dist/types/components/ICEKanban.d.ts +85 -0
  39. package/dist/types/components/ICELabel.d.ts +28 -0
  40. package/dist/types/components/ICEList.d.ts +59 -0
  41. package/dist/types/components/ICEMenu.d.ts +48 -0
  42. package/dist/types/components/ICEModal.d.ts +73 -0
  43. package/dist/types/components/ICEPagination.d.ts +62 -0
  44. package/dist/types/components/ICEPanel.d.ts +7 -0
  45. package/dist/types/components/ICEPasswordField.d.ts +18 -0
  46. package/dist/types/components/ICEPopconfirm.d.ts +21 -0
  47. package/dist/types/components/ICEPopover.d.ts +48 -0
  48. package/dist/types/components/ICEProgressBar.d.ts +37 -0
  49. package/dist/types/components/ICERadioButton.d.ts +21 -0
  50. package/dist/types/components/ICERadioGroup.d.ts +71 -0
  51. package/dist/types/components/ICERate.d.ts +43 -0
  52. package/dist/types/components/ICEResult.d.ts +30 -0
  53. package/dist/types/components/ICEScrollPane.d.ts +72 -0
  54. package/dist/types/components/ICESegmented.d.ts +34 -0
  55. package/dist/types/components/ICESelect.d.ts +85 -0
  56. package/dist/types/components/ICESeparator.d.ts +7 -0
  57. package/dist/types/components/ICESkeleton.d.ts +29 -0
  58. package/dist/types/components/ICESlider.d.ts +63 -0
  59. package/dist/types/components/ICESpace.d.ts +51 -0
  60. package/dist/types/components/ICESpin.d.ts +33 -0
  61. package/dist/types/components/ICESplitter.d.ts +85 -0
  62. package/dist/types/components/ICEStatCard.d.ts +14 -0
  63. package/dist/types/components/ICEStatistic.d.ts +78 -0
  64. package/dist/types/components/ICESteps.d.ts +31 -0
  65. package/dist/types/components/ICESvgIcon.d.ts +9 -0
  66. package/dist/types/components/ICESwitch.d.ts +23 -0
  67. package/dist/types/components/ICETable.d.ts +250 -0
  68. package/dist/types/components/ICETabs.d.ts +17 -0
  69. package/dist/types/components/ICETag.d.ts +15 -0
  70. package/dist/types/components/ICETextArea.d.ts +8 -0
  71. package/dist/types/components/ICETextField.d.ts +80 -0
  72. package/dist/types/components/ICETileMap.d.ts +152 -0
  73. package/dist/types/components/ICETimePicker.d.ts +81 -0
  74. package/dist/types/components/ICETimeline.d.ts +33 -0
  75. package/dist/types/components/ICETooltip.d.ts +55 -0
  76. package/dist/types/components/ICETour.d.ts +97 -0
  77. package/dist/types/components/ICETransfer.d.ts +68 -0
  78. package/dist/types/components/ICETree.d.ts +107 -0
  79. package/dist/types/components/ICETreeSelect.d.ts +64 -0
  80. package/dist/types/components/ICETypography.d.ts +67 -0
  81. package/dist/types/components/ICEUpload.d.ts +75 -0
  82. package/dist/types/components/ICEVirtualList.d.ts +100 -0
  83. package/dist/types/components/ICEWatermark.d.ts +49 -0
  84. package/dist/types/components/ICEWindow.d.ts +159 -0
  85. package/dist/types/core/ICEContainer.d.ts +10 -0
  86. package/dist/types/core/ICEFocusManager.d.ts +70 -0
  87. package/dist/types/core/ICEHoverManager.d.ts +26 -0
  88. package/dist/types/core/ICEManager.d.ts +24 -0
  89. package/dist/types/core/ICEMessageManager.d.ts +80 -0
  90. package/dist/types/core/ICEOverlayManager.d.ts +92 -0
  91. package/dist/types/core/ICEPainter.d.ts +12 -0
  92. package/dist/types/core/ICEWidget.d.ts +86 -0
  93. package/dist/types/i18n/ICEI18n.d.ts +35 -0
  94. package/dist/types/index.d.ts +111 -0
  95. package/dist/types/model/ICE2048Model.d.ts +90 -0
  96. package/dist/types/model/ICEBoundedRangeModel.d.ts +20 -0
  97. package/dist/types/model/ICEButtonModel.d.ts +16 -0
  98. package/dist/types/model/ICEFormModel.d.ts +105 -0
  99. package/dist/types/model/ICEHighScoreModel.d.ts +60 -0
  100. package/dist/types/model/ICEMinesweeperModel.d.ts +102 -0
  101. package/dist/types/model/ICESelectionModel.d.ts +31 -0
  102. package/dist/types/model/ICESnakeModel.d.ts +90 -0
  103. package/dist/types/model/ICETetrisModel.d.ts +118 -0
  104. package/dist/types/model/ICEToggleModel.d.ts +14 -0
  105. package/dist/types/theme/ICEArcadeTheme.d.ts +22 -0
  106. package/dist/types/theme/ICETheme.d.ts +120 -0
  107. package/dist/types/util/ICEAccessibilityMirror.d.ts +55 -0
  108. package/dist/types/util/ICEAnimation.d.ts +71 -0
  109. package/dist/types/util/ICEDragReorder.d.ts +102 -0
  110. package/dist/types/util/ICENativeInput.d.ts +65 -0
  111. package/dist/types/util/ICEOverlayPosition.d.ts +52 -0
  112. package/dist/types/util/ICEStyle.d.ts +60 -0
  113. package/dist/types/util/ICEWorldBox.d.ts +14 -0
  114. package/package.json +56 -0
@@ -0,0 +1,64 @@
1
+ import { ICEWidget } from '../core/ICEWidget';
2
+ import { ICETree, ICETreeNode } from './ICETree';
3
+ import { ICEOverlayManager } from '../core/ICEOverlayManager';
4
+ /**
5
+ * 树选择器(Ant TreeSelect):下拉里放一棵 ICETree,选中节点后回写值。
6
+ *
7
+ * - 字段区与 ICESelect 同构(选中标签 / placeholder + ▾),错误态边框标红;
8
+ * - 下拉内容直接复用 `ICETree`(层级展开、缩进、箭头命中区、选择模型都在那边);
9
+ * - 浮层自己管关闭(`closeOnOutsideClick: false` + 自身命中盒)—— 浮层的命中盒判定会在
10
+ * click 派发前关掉浮层,树节点就收不到点击(Select/AutoComplete 都踩过这个坑);
11
+ * - 值就是节点 key,表单语义同 ICETextField(getFormValue / setFormValue)。
12
+ */
13
+ export interface ICETreeSelectOptions {
14
+ /** 组件 id(引擎会用它做唯一标识,e2e/调试时可按 id 定位) */
15
+ id?: string;
16
+ nodes: ICETreeNode[];
17
+ value?: string;
18
+ placeholder?: string;
19
+ disabled?: boolean;
20
+ left?: number;
21
+ top?: number;
22
+ width?: number;
23
+ height?: number;
24
+ treeHeight?: number;
25
+ defaultExpandAll?: boolean;
26
+ onChange?: (key: string, node: ICETreeNode) => void;
27
+ manager?: ICEOverlayManager;
28
+ }
29
+ export declare class ICETreeSelect extends ICEWidget {
30
+ private nodes;
31
+ private value;
32
+ private placeholder;
33
+ private disabled;
34
+ private treeHeight;
35
+ private defaultExpandAll;
36
+ private manager;
37
+ private handle;
38
+ private panel;
39
+ private tree;
40
+ private fieldLabel;
41
+ private onChangeCallback;
42
+ private running;
43
+ constructor(props: ICETreeSelectOptions);
44
+ protected afterAddHandler(): void;
45
+ getValue(): string | null;
46
+ setValue(key: string | null): this;
47
+ getFormValue(): any;
48
+ setFormValue(value: any): void;
49
+ getFieldLabel(): string;
50
+ isOpen(): boolean;
51
+ getTree(): ICETree | null;
52
+ activate(): void;
53
+ toggle(): this;
54
+ open(): this;
55
+ close(): this;
56
+ private __pick;
57
+ private __onClick;
58
+ private __onKeyDown;
59
+ /** 点外关闭:点在自身与下拉面板之外就收起。 */
60
+ private __onGlobalMouseDown;
61
+ private __worldBox;
62
+ private __syncField;
63
+ private __findNode;
64
+ }
@@ -0,0 +1,67 @@
1
+ import { ICEWidget } from '../core/ICEWidget';
2
+ import { ICELabel } from './ICELabel';
3
+ /**
4
+ * 按宽度把文本切成若干行,超出部分用 `…` 收尾。
5
+ *
6
+ * 为什么要自己折行:画布文本**没有裁剪也不会自动换行**,业务页里长文案要么压出色块、
7
+ * 要么被邻居盖住。这里按「中文 1em / 其余 0.6em」的估算宽度切行,
8
+ * 保证每行都不超过 `maxWidth`(与 `estimateTextWidth` 同一套口径)。
9
+ */
10
+ export declare function truncateTextLines(text: string, options: {
11
+ maxWidth: number;
12
+ fontSize: number;
13
+ maxLines?: number;
14
+ }): string[];
15
+ export declare type ICETypographyVariant = 'title' | 'paragraph' | 'text' | 'link';
16
+ export declare type ICETypographyType = 'default' | 'secondary' | 'success' | 'warning' | 'danger' | 'primary';
17
+ /**
18
+ * 排版文本(Ant Typography):标题层级 / 正文 / 链接,自带省略与折行。
19
+ *
20
+ * - `variant: 'title'` + `level: 1..5`:五级标题,字号递减;
21
+ * - `variant: 'paragraph'`:正文,配合 `rows` 做多行折行(末行补 `…`);
22
+ * - `variant: 'link'`:主色 + 可点击(触发 `click` 与 `onClick`)且可聚焦;
23
+ * - `type`:语义色(`secondary` / `success` / `warning` / `danger` / `primary`);
24
+ * - `ellipsis: true`(或给了 `rows`)时按宽度截断——画布不会自动换行,长文案必须显式处理。
25
+ */
26
+ export interface ICETypographyOptions {
27
+ /** 组件 id(引擎会用它做唯一标识,e2e/调试时可按 id 定位) */
28
+ id?: string;
29
+ text: string;
30
+ variant?: ICETypographyVariant;
31
+ /** 标题层级,1 最大(默认 1) */
32
+ level?: number;
33
+ type?: ICETypographyType;
34
+ /** 省略:true = 单行省略;配合 rows > 1 = 多行折行省略 */
35
+ ellipsis?: boolean;
36
+ rows?: number;
37
+ strong?: boolean;
38
+ left?: number;
39
+ top?: number;
40
+ width?: number;
41
+ height?: number;
42
+ fontSize?: number;
43
+ onClick?: () => void;
44
+ }
45
+ export declare class ICETypography extends ICEWidget {
46
+ private text;
47
+ private variant;
48
+ private type;
49
+ private fontSize;
50
+ private rows;
51
+ private lineHeight;
52
+ private lines;
53
+ private labelNodes;
54
+ private onClick;
55
+ constructor(props: ICETypographyOptions);
56
+ getText(): string;
57
+ /** 当前渲染出来的行(省略/折行后的结果)。 */
58
+ getLines(): string[];
59
+ getFontSize(): number;
60
+ getTextColor(): string;
61
+ getLabelNodes(): ICELabel[];
62
+ setText(text: string): this;
63
+ setType(type: ICETypographyType): this;
64
+ private __color;
65
+ protected __applyHoverState(): void;
66
+ private __render;
67
+ }
@@ -0,0 +1,75 @@
1
+ import { ICEWidget } from '../core/ICEWidget';
2
+ /**
3
+ * 上传选择器(Ant Upload 的最小版)。
4
+ *
5
+ * - 上:虚线拖拽区(点击唤起隐藏的 `<input type="file">`);
6
+ * - 下:文件列表(名称 / 大小 / 删除);
7
+ * - 校验:`accept`(扩展名或 MIME,支持 `image/*`)、`maxSize`、`maxCount`、`beforeUpload`;
8
+ * - 被拒时 `addFile` 返回 false 并记录原因(`getLastRejectReason()`),列表与回调都不动;
9
+ * - 文件对象是**纯数据**(`{uid,name,size,type,url}`),不依赖 DOM,便于测试与序列化。
10
+ */
11
+ export interface ICEUploadFile {
12
+ uid: string;
13
+ name: string;
14
+ size?: number;
15
+ type?: string;
16
+ url?: string;
17
+ }
18
+ export interface ICEUploadOptions {
19
+ /** 组件 id(引擎会用它做唯一标识,e2e/调试时可按 id 定位) */
20
+ id?: string;
21
+ accept?: string;
22
+ multiple?: boolean;
23
+ maxCount?: number;
24
+ /** 单文件大小上限(字节) */
25
+ maxSize?: number;
26
+ disabled?: boolean;
27
+ text?: string;
28
+ hint?: string;
29
+ left?: number;
30
+ top?: number;
31
+ width?: number;
32
+ height?: number;
33
+ rowHeight?: number;
34
+ beforeUpload?: (file: ICEUploadFile) => boolean | string | undefined;
35
+ onChange?: (files: ICEUploadFile[]) => void;
36
+ }
37
+ export declare class ICEUpload extends ICEWidget {
38
+ private files;
39
+ private accept;
40
+ private multiple;
41
+ private maxCount;
42
+ private maxSize;
43
+ private disabled;
44
+ private text;
45
+ private hint;
46
+ private rowHeight;
47
+ private beforeUpload;
48
+ private onChangeCallback;
49
+ private lastRejectReason;
50
+ private dropZone;
51
+ private fileNodes;
52
+ private inputEl;
53
+ private seq;
54
+ constructor(props?: ICEUploadOptions);
55
+ getFileList(): ICEUploadFile[];
56
+ isDisabled(): boolean;
57
+ getLastRejectReason(): string | null;
58
+ getDropZoneNode(): ICEWidget | null;
59
+ /** 上传区提示文案(测试 / QA 用)。 */
60
+ getHintText(): string;
61
+ getFileNode(uid: string): ICEWidget | null;
62
+ /** 加入一个文件(真实选择结果或调用方构造的数据);被拒时返回 false。 */
63
+ addFile(file: Partial<ICEUploadFile>): boolean;
64
+ removeFile(uid: string): this;
65
+ clear(): this;
66
+ setDisabled(disabled: boolean): this;
67
+ /** 唤起系统文件选择框(无 DOM 环境返回 false)。 */
68
+ openPicker(): boolean;
69
+ activate(): void;
70
+ private __defaultHint;
71
+ private __rejectReason;
72
+ private __accepts;
73
+ private __emit;
74
+ private __render;
75
+ }
@@ -0,0 +1,100 @@
1
+ import { ICEWidget } from '../core/ICEWidget';
2
+ import { ICEScrollPane } from './ICEScrollPane';
3
+ /**
4
+ * 虚拟列表:**只渲染可视区**的列表,一万条数据也只用十几个节点。
5
+ *
6
+ * 为什么要有它:`ICETable` / `ICEList` 都是「有多少行建多少节点」——几千行就开始卡,
7
+ * 上万行直接不能上。虚拟滚动的做法是:内容盒按「总高度」撑开(滚动条对得上),
8
+ * 但只把「可视区 + 缓冲」那几条真的建出来,滚动时换窗口、复用节点。
9
+ *
10
+ * ```
11
+ * ICEVirtualList (固定高度)
12
+ * └── ICEScrollPane 滚轮 / 滚动条 / 子树裁剪都交给它
13
+ * └── content (总高 = itemCount × itemHeight)
14
+ * ├── item[97] ← 只建窗口内的
15
+ * ├── item[98]
16
+ * └── …
17
+ * ```
18
+ *
19
+ * 窗口计算抽成了纯函数 `computeVirtualRange`(缓冲、贴底、空列表、越界都在那里守),
20
+ * 组件层只管把窗口映射成节点。
21
+ */
22
+ /** 当前该渲染的区间:`[start, end)`。 */
23
+ export interface ICEVirtualRange {
24
+ start: number;
25
+ end: number;
26
+ count: number;
27
+ }
28
+ export interface ICEVirtualWindowOptions {
29
+ /** 当前滚动位置,默认 0 */
30
+ scrollTop?: number;
31
+ viewportHeight: number;
32
+ itemHeight: number;
33
+ itemCount: number;
34
+ /** 上下各多渲染几条(默认 0),滚动时不容易看到白边 */
35
+ buffer?: number;
36
+ }
37
+ /**
38
+ * 纯窗口计算:给定滚动位置、视口高度、行高与总数,算出该渲染哪一段。
39
+ *
40
+ * - `end` 是**开区间**(`slice(start, end)` 语义);
41
+ * - 半露出的那一条也要渲染(`scrollTop + viewportHeight - 1` 取整);
42
+ * - 越界、空列表、非法入参一律返回空窗口或夹取后的结果,不抛异常、不给负数。
43
+ */
44
+ export declare function computeVirtualRange(options: ICEVirtualWindowOptions): ICEVirtualRange;
45
+ export interface ICEVirtualListOptions {
46
+ id?: string;
47
+ left?: number;
48
+ top?: number;
49
+ width?: number;
50
+ /** 视口高度(列表本身的尺寸,内容由它决定滚动范围) */
51
+ height?: number;
52
+ /** 每行高度(固定行高才谈得上虚拟滚动) */
53
+ itemHeight: number;
54
+ /** 上下缓冲条数,默认 2 */
55
+ buffer?: number;
56
+ items?: any[];
57
+ /** 渲染一条:拿到的是**数据下标**(不是节点下标),可以复用传入的 node */
58
+ renderItem?: (index: number, item: any, node: any) => void;
59
+ /** 是否显示滚动条,默认 true */
60
+ scrollbar?: boolean;
61
+ [key: string]: any;
62
+ }
63
+ export declare class ICEVirtualList extends ICEWidget {
64
+ private itemHeight;
65
+ private buffer;
66
+ private items;
67
+ private pane;
68
+ private content;
69
+ /** 当前渲染出来的节点:数据下标 → 节点 */
70
+ private nodes;
71
+ private scrollTop;
72
+ private renderItem;
73
+ constructor(props: ICEVirtualListOptions);
74
+ getItemCount(): number;
75
+ getItemHeight(): number;
76
+ getBuffer(): number;
77
+ getItems(): any[];
78
+ /** 内容总高度(撑开滚动条用)。 */
79
+ getContentHeight(): number;
80
+ getScrollTop(): number;
81
+ /** 当前窗口(查询前会先同步一次,保证拿到的是最新状态)。 */
82
+ getRange(): ICEVirtualRange;
83
+ /** 当前真正渲染出来的节点(按下标升序)。 */
84
+ getRenderedNodes(): Array<{
85
+ index: number;
86
+ node: any;
87
+ }>;
88
+ getRenderedCount(): number;
89
+ /** 对外暴露滚动视口(需要挂滚动监听时用)。 */
90
+ getScrollPane(): ICEScrollPane;
91
+ setItems(items: any[]): this;
92
+ setScrollTop(scrollTop: number): this;
93
+ /** 把某一条滚进视口(贴顶对齐),下标会被夹进合法范围。 */
94
+ scrollToIndex(index: number): this;
95
+ private __width;
96
+ private __height;
97
+ private __range;
98
+ /** 把当前窗口映射成节点:窗口外的拆掉、窗口内的补上;重复调用是幂等的。 */
99
+ private __syncWindow;
100
+ }
@@ -0,0 +1,49 @@
1
+ import { ICEWidget } from '../core/ICEWidget';
2
+ import { ICELabel } from './ICELabel';
3
+ /**
4
+ * 水印(Ant Watermark):把一段旋转文字平铺在自己的区域上。
5
+ *
6
+ * - 用于「内部资料 / 草稿 / 不可外传」这类页面级标记;
7
+ * - 不参与交互(`interactive: false`),不会挡住底下的点击;
8
+ * - 裁剪在自己的区域内(`clipChildren`):边缘瓦片被切掉半截,不会溢出到邻居身上;
9
+ * - 瓦片数量 = `(⌈width/gapX⌉ + 1) × (⌈height/gapY⌉ + 1)`,`gap` 不传时按文字宽度自适应;
10
+ * - 颜色默认半透明灰(`rgba(0,0,0,0.08)`),可用 `color` / `opacity` 调整。
11
+ */
12
+ export interface ICEWatermarkOptions {
13
+ /** 组件 id(引擎会用它做唯一标识,e2e/调试时可按 id 定位) */
14
+ id?: string;
15
+ text: string;
16
+ fontSize?: number;
17
+ /** 文字颜色,默认 `rgba(0,0,0,0.08)` */
18
+ color?: string;
19
+ /** 整体不透明度,默认 1(颜色本身已经半透明) */
20
+ opacity?: number;
21
+ /** 旋转角度(度),默认 -22 */
22
+ rotate?: number;
23
+ /** 水平间距,默认按文字宽度 + 60 自适应 */
24
+ gapX?: number;
25
+ /** 垂直间距,默认 72 */
26
+ gapY?: number;
27
+ left?: number;
28
+ top?: number;
29
+ width?: number;
30
+ height?: number;
31
+ }
32
+ export declare class ICEWatermark extends ICEWidget {
33
+ private text;
34
+ private fontSize;
35
+ private color;
36
+ private rotate;
37
+ private gapX;
38
+ private gapY;
39
+ private opacity;
40
+ private tiles;
41
+ constructor(props: ICEWatermarkOptions);
42
+ getText(): string;
43
+ getTileCount(): number;
44
+ getTileNodes(): ICELabel[];
45
+ setText(text: string): this;
46
+ /** 改尺寸后重排瓦片(数量跟着变)。 */
47
+ setSize(width: number, height: number): this;
48
+ private __render;
49
+ }
@@ -0,0 +1,159 @@
1
+ import { ICEWidget } from '../core/ICEWidget';
2
+ /**
3
+ * 通用窗口外壳(桌面 / 多窗口场景的底座):标题栏 + 按钮 + 客户端区域 + 缩放手柄。
4
+ *
5
+ * - **拖动**:按住标题栏移动(受 `bounds` 限制,拖不出桌面);点在按钮上不触发拖动;
6
+ * - **焦点**:`active` 决定标题栏配色(XP 蓝 / 灰),点窗口任意位置会 `activate()` 并广播
7
+ * `activate` 事件 —— 由外部窗口管理器据此抬 zIndex;
8
+ * - **最大化 / 还原**:记住还原前的盒子,按 `bounds` 铺满;`minimize()` 只广播事件,
9
+ * 怎么藏(隐藏 or 收到任务栏)交给调用方;
10
+ * - **缩放**:右下角手柄(`resizable: false` 可关),受 `minWidth` / `minHeight` 限制;
11
+ * - **内容**:`content` 或 `setContent()` 装进客户端区域,自动铺满。
12
+ *
13
+ * 外观默认走 Windows XP Luna 配色(可传 `appearance` 覆盖),与组件库主题无关 ——
14
+ * 这类“拟物外壳”本来就要固定配色。
15
+ */
16
+ export declare type ICEWindowAppearance = {
17
+ /** 激活态标题栏渐变(两段色) */
18
+ titleActive?: [string, string];
19
+ /** 非激活态标题栏渐变 */
20
+ titleInactive?: [string, string];
21
+ titleText?: string;
22
+ titleTextInactive?: string;
23
+ body?: string;
24
+ border?: string;
25
+ };
26
+ export interface ICEWindowOptions {
27
+ /** 组件 id(引擎会用它做唯一标识,e2e/调试时可按 id 定位) */
28
+ id?: string;
29
+ title?: string;
30
+ /** 标题栏左侧的图标字形 */
31
+ icon?: string;
32
+ /** 自绘图标节点(给了它就代替 `icon` 字形),会在标题栏左侧居中 */
33
+ iconNode?: any;
34
+ left?: number;
35
+ top?: number;
36
+ width?: number;
37
+ height?: number;
38
+ /** 拖动 / 最大化的活动范围(一般是桌面工作区) */
39
+ bounds?: {
40
+ left: number;
41
+ top: number;
42
+ width: number;
43
+ height: number;
44
+ };
45
+ titleBarHeight?: number;
46
+ movable?: boolean;
47
+ resizable?: boolean;
48
+ closable?: boolean;
49
+ minimizable?: boolean;
50
+ maximizable?: boolean;
51
+ active?: boolean;
52
+ minWidth?: number;
53
+ minHeight?: number;
54
+ /** 客户端内容(会铺满客户端区域) */
55
+ content?: any;
56
+ appearance?: ICEWindowAppearance;
57
+ onClose?: () => void;
58
+ onMinimize?: () => void;
59
+ onMaximize?: (maximized: boolean) => void;
60
+ onActivate?: () => void;
61
+ onMove?: (left: number, top: number) => void;
62
+ onResize?: (width: number, height: number) => void;
63
+ }
64
+ /** 标题栏上的小按钮(hover 亮、按下沉)。 */
65
+ declare class ICEWindowButton extends ICEWidget {
66
+ private glyph;
67
+ private baseColor;
68
+ constructor(props: {
69
+ left: number;
70
+ top: number;
71
+ size: number;
72
+ text: string;
73
+ onClick: () => void;
74
+ });
75
+ protected __applyHoverState(): void;
76
+ }
77
+ export declare class ICEWindow extends ICEWidget {
78
+ private titleBar;
79
+ private titleLabel;
80
+ private iconNode;
81
+ private client;
82
+ private closeButton;
83
+ private minimizeButton;
84
+ private maximizeButton;
85
+ private resizeHandle;
86
+ private titleBands;
87
+ private appearance;
88
+ private titleBarHeight;
89
+ private active;
90
+ private maximized;
91
+ private restoreBox;
92
+ private bounds;
93
+ private minWidth;
94
+ private minHeight;
95
+ private movable;
96
+ private resizable;
97
+ private content;
98
+ private dragOffset;
99
+ private resizing;
100
+ private resizeStart;
101
+ private bound;
102
+ private readonly options;
103
+ constructor(props?: ICEWindowOptions);
104
+ getTitle(): string;
105
+ setTitle(title: string): this;
106
+ getTitleBar(): ICEWidget;
107
+ getTitleBarHeight(): number;
108
+ /** 客户端区域的盒子(相对窗口自身)。 */
109
+ getClientBox(): {
110
+ left: number;
111
+ top: number;
112
+ width: number;
113
+ height: number;
114
+ };
115
+ getClientNode(): ICEWidget;
116
+ getCloseButton(): ICEWindowButton;
117
+ getMinimizeButton(): ICEWindowButton;
118
+ getMaximizeButton(): ICEWindowButton;
119
+ getResizeHandle(): ICEWidget;
120
+ /** 标题栏当前色(激活/非激活的中间色)——测试与主题调试用。 */
121
+ getTitleBarColor(): string;
122
+ isActive(): boolean;
123
+ setActive(active: boolean): this;
124
+ /** 激活窗口并广播(外部据此抬 zIndex)。已经激活时也会广播,方便“置顶”)。 */
125
+ activate(): this;
126
+ isMaximized(): boolean;
127
+ maximize(): this;
128
+ restore(): this;
129
+ setContent(node: any): this;
130
+ getContent(): any;
131
+ isDragging(): boolean;
132
+ isResizing(): boolean;
133
+ setBounds(bounds: {
134
+ left: number;
135
+ top: number;
136
+ width: number;
137
+ height: number;
138
+ }): this;
139
+ setSize(width: number, height: number): this;
140
+ protected afterAddHandler(): void;
141
+ revalidate(): this;
142
+ /** 窗口尺寸被程序式改动时(setState)也要重排内部结构。 */
143
+ protected __afterStateMerge(sizeChanged: boolean): void;
144
+ private __bounds;
145
+ /** 标题栏渐变(激活 / 非激活两套色)+ 标题文字色。 */
146
+ private __syncTitleBands;
147
+ /** 窗口尺寸变化后重排标题栏 / 客户端 / 按钮 / 手柄。 */
148
+ private __layout;
149
+ /** 节点在世界坐标里的盒子(窗口自身 + 到 this 为止的子级偏移)。 */
150
+ private __nodeBoxWorld;
151
+ private __pointIn;
152
+ private __hitOwnButton;
153
+ /** 窗口在父容器坐标系里的原点(拖拽时用它把世界坐标换算回去)。 */
154
+ private __parentOrigin;
155
+ private __onGlobalMouseDown;
156
+ private __onGlobalMouseMove;
157
+ private __onGlobalMouseUp;
158
+ }
159
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ICELayoutManager } from 'ice-render';
2
+ import { ICEWidget } from './ICEWidget';
3
+ /**
4
+ * 容器基类:在此挂布局策略(`setLayout`,链式返回自身)。
5
+ */
6
+ export declare class ICEContainer extends ICEWidget {
7
+ constructor(props?: any);
8
+ /** 设置布局策略(引擎 ICEGroup.setLayout 的链式版本)。 */
9
+ setLayout(layout: ICELayoutManager): this;
10
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * 键盘焦点与焦点环。
3
+ *
4
+ * 引擎只负责「键盘事件派发给谁」(`ice.setFocusedComponent` + DOMEventDispatcher),
5
+ * 上层的策略在这里:
6
+ * - **可聚焦集合**:`ICEWidget.isFocusable()`(控件显式声明 + 启用 + 可见),按文档序;
7
+ * - **Tab / Shift+Tab** 循环轮转,**Escape** 取消焦点,**Enter / Space** 激活
8
+ * (调用控件的 `activate()`,勾选/开关/单选会覆盖成对应的切换动作);
9
+ * - **鼠标点击**同样会聚焦:命中后沿父链上溯到最近的可聚焦控件(点标签也能聚焦按钮),
10
+ * 点在非控件区域则取消焦点;
11
+ * - **焦点环**画在 ICE 工具层(非交互、绘制在所有组件之上),外扩 2px 跟随焦点组件。
12
+ *
13
+ * 焦点环跟随组件移动:组件触发 AFTER_MOVE 时重算(拖拽、布局变化都能跟上)。
14
+ */
15
+ export declare class ICEFocusManager {
16
+ private ice;
17
+ private toolNode;
18
+ private ring;
19
+ private focused;
20
+ /** 当前焦点的来源:鼠标点出来的焦点不画环(除非控件声明 always) */
21
+ private focusOrigin;
22
+ private bound;
23
+ private ringPadding;
24
+ /** 焦点范围(模态对话框用):非空时 Tab 只在该子树里轮转。 */
25
+ private scope;
26
+ constructor(ice: any);
27
+ /** 幂等:创建焦点环(挂 ICE 工具层)并绑定键盘/鼠标事件。 */
28
+ start(): this;
29
+ /** 解绑事件、清空焦点并摘除焦点环。 */
30
+ stop(): this;
31
+ /** 当前焦点控件(无焦点返回 null)。 */
32
+ getFocused(): any;
33
+ /** 焦点环组件(测试与自定义样式用)。 */
34
+ getRing(): any;
35
+ /** 当前焦点是怎么来的(mouse / keyboard / api)。 */
36
+ getFocusOrigin(): 'mouse' | 'keyboard' | 'api';
37
+ /** 焦点环此刻是否可见(`:focus-visible` 的结果)。 */
38
+ isRingVisible(): boolean;
39
+ /** 按文档序返回当前可聚焦的控件。 */
40
+ getFocusables(): any[];
41
+ /**
42
+ * 限制焦点范围(模态对话框 / 抽屉的「焦点陷阱」)。
43
+ *
44
+ * 传入容器后,Tab/Shift+Tab 只在该子树内轮转;当前焦点若在范围之外会被清掉
45
+ * (调用方随后可 `focusNext()` 把焦点移进对话框)。传 null 恢复全场景。
46
+ */
47
+ setFocusScope(container: any): this;
48
+ getFocusScope(): any;
49
+ /**
50
+ * 设置焦点(传 null 取消焦点)。非可聚焦对象会被忽略成取消焦点。
51
+ *
52
+ * `options.origin` 决定要不要画焦点环:`keyboard` 画、`mouse`/`api` 默认不画
53
+ * (控件自己的 `shouldShowFocusRing()` 说了算)。
54
+ */
55
+ focus(component: any, options?: {
56
+ origin?: 'mouse' | 'keyboard' | 'api';
57
+ }): this;
58
+ /** Tab:聚焦下一个(未聚焦时聚焦第一个;到末尾回绕)。 */
59
+ focusNext(): this;
60
+ /** Shift+Tab:聚焦上一个。 */
61
+ focusPrev(): this;
62
+ private __onKeyDown;
63
+ private __onMouseDown;
64
+ /** 焦点组件移动(拖拽/布局变化)时让焦点环跟上。 */
65
+ private __watchMove;
66
+ private __onFocusedMoved;
67
+ private __syncRing;
68
+ }
69
+ /** 每个 ICE 实例一个焦点管理器(懒创建)。 */
70
+ export declare function getICEFocusManager(ice: any): ICEFocusManager;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * ICE 内核的移动类事件为了性能不会在 mousemove 时做全量命中检测,
3
+ * 因此 Canvas 组件没有内置 mouseenter/mouseleave 语义。
4
+ *
5
+ * ICEHoverManager 通过事件总线的 mousemove + ice.hitTest() 自己维护当前 hover 组件,
6
+ * 并把状态同步到带 setHovered() 的 ICEWidget 上,实现接近 HTML 组件的 hover 效果。
7
+ */
8
+ export declare class ICEHoverManager {
9
+ private ice;
10
+ private current;
11
+ private running;
12
+ private lastX;
13
+ private lastY;
14
+ private rafId;
15
+ private __onMouseMove;
16
+ private __onLeave;
17
+ constructor(ice: any);
18
+ start(): this;
19
+ stop(): this;
20
+ getHoveredComponent(): any;
21
+ private __schedule;
22
+ private __cancelRaf;
23
+ private __flush;
24
+ private __findHoverTarget;
25
+ private setHovered;
26
+ }
@@ -0,0 +1,24 @@
1
+ import { ICEThemeTokens } from '../theme/ICETheme';
2
+ /** 内置 `light` / `dark`;也可以用 `registerTheme()` 注册自定义(例如 `xp`)。 */
3
+ export declare type ICEThemeName = string;
4
+ /**
5
+ * 主题管理单例(`iceUIManager`):持有当前 token 表,组件构造时从这里取主题。
6
+ *
7
+ * - 内置 `light` / `dark`;
8
+ * - `registerTheme(name, tokens)` 注册自定义主题(例如库内置的 `ICE_XP_THEME`),
9
+ * 然后 `setTheme('xp')` 切换;
10
+ * - **主题在组件构造时读取一次**,要热切换就重建组件(见 docs/guides/theming.md)。
11
+ */
12
+ export declare class ICEManager {
13
+ private themeName;
14
+ private themes;
15
+ setTheme(name: ICEThemeName): this;
16
+ getThemeName(): ICEThemeName;
17
+ /** 注册(或覆盖)一套主题 token。 */
18
+ registerTheme(name: string, tokens: ICEThemeTokens): this;
19
+ hasTheme(name: string): boolean;
20
+ /** 已注册的主题名(内置 + 自定义)。 */
21
+ getThemeNames(): string[];
22
+ getTheme(): ICEThemeTokens;
23
+ }
24
+ export declare const iceUIManager: ICEManager;