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.
- package/LICENSE +21 -0
- package/README.md +487 -0
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.umd.js +1 -0
- package/dist/types/components/ICEAlert.d.ts +28 -0
- package/dist/types/components/ICEAnchor.d.ts +69 -0
- package/dist/types/components/ICEAutoComplete.d.ts +71 -0
- package/dist/types/components/ICEAvatar.d.ts +11 -0
- package/dist/types/components/ICEAvatarGroup.d.ts +40 -0
- package/dist/types/components/ICEBackTop.d.ts +39 -0
- package/dist/types/components/ICEBadge.d.ts +17 -0
- package/dist/types/components/ICEBreadcrumb.d.ts +82 -0
- package/dist/types/components/ICEButton.d.ts +25 -0
- package/dist/types/components/ICECalendar.d.ts +84 -0
- package/dist/types/components/ICECard.d.ts +22 -0
- package/dist/types/components/ICECarousel.d.ts +86 -0
- package/dist/types/components/ICECascader.d.ts +84 -0
- package/dist/types/components/ICECheckBox.d.ts +21 -0
- package/dist/types/components/ICECheckboxGroup.d.ts +75 -0
- package/dist/types/components/ICECollapse.d.ts +49 -0
- package/dist/types/components/ICEColorPicker.d.ts +52 -0
- package/dist/types/components/ICEComment.d.ts +36 -0
- package/dist/types/components/ICEDatePicker.d.ts +90 -0
- package/dist/types/components/ICEDescriptions.d.ts +40 -0
- package/dist/types/components/ICEDrawer.d.ts +59 -0
- package/dist/types/components/ICEDropdown.d.ts +63 -0
- package/dist/types/components/ICEEmpty.d.ts +28 -0
- package/dist/types/components/ICEFloatButton.d.ts +63 -0
- package/dist/types/components/ICEForm.d.ts +48 -0
- package/dist/types/components/ICEFormItem.d.ts +65 -0
- package/dist/types/components/ICEGrid.d.ts +59 -0
- package/dist/types/components/ICEIcon.d.ts +9 -0
- package/dist/types/components/ICEIconTile.d.ts +53 -0
- package/dist/types/components/ICEImagePreview.d.ts +91 -0
- package/dist/types/components/ICEImageView.d.ts +62 -0
- package/dist/types/components/ICEInputNumber.d.ts +54 -0
- package/dist/types/components/ICEKanban.d.ts +85 -0
- package/dist/types/components/ICELabel.d.ts +28 -0
- package/dist/types/components/ICEList.d.ts +59 -0
- package/dist/types/components/ICEMenu.d.ts +48 -0
- package/dist/types/components/ICEModal.d.ts +73 -0
- package/dist/types/components/ICEPagination.d.ts +62 -0
- package/dist/types/components/ICEPanel.d.ts +7 -0
- package/dist/types/components/ICEPasswordField.d.ts +18 -0
- package/dist/types/components/ICEPopconfirm.d.ts +21 -0
- package/dist/types/components/ICEPopover.d.ts +48 -0
- package/dist/types/components/ICEProgressBar.d.ts +37 -0
- package/dist/types/components/ICERadioButton.d.ts +21 -0
- package/dist/types/components/ICERadioGroup.d.ts +71 -0
- package/dist/types/components/ICERate.d.ts +43 -0
- package/dist/types/components/ICEResult.d.ts +30 -0
- package/dist/types/components/ICEScrollPane.d.ts +72 -0
- package/dist/types/components/ICESegmented.d.ts +34 -0
- package/dist/types/components/ICESelect.d.ts +85 -0
- package/dist/types/components/ICESeparator.d.ts +7 -0
- package/dist/types/components/ICESkeleton.d.ts +29 -0
- package/dist/types/components/ICESlider.d.ts +63 -0
- package/dist/types/components/ICESpace.d.ts +51 -0
- package/dist/types/components/ICESpin.d.ts +33 -0
- package/dist/types/components/ICESplitter.d.ts +85 -0
- package/dist/types/components/ICEStatCard.d.ts +14 -0
- package/dist/types/components/ICEStatistic.d.ts +78 -0
- package/dist/types/components/ICESteps.d.ts +31 -0
- package/dist/types/components/ICESvgIcon.d.ts +9 -0
- package/dist/types/components/ICESwitch.d.ts +23 -0
- package/dist/types/components/ICETable.d.ts +250 -0
- package/dist/types/components/ICETabs.d.ts +17 -0
- package/dist/types/components/ICETag.d.ts +15 -0
- package/dist/types/components/ICETextArea.d.ts +8 -0
- package/dist/types/components/ICETextField.d.ts +80 -0
- package/dist/types/components/ICETileMap.d.ts +152 -0
- package/dist/types/components/ICETimePicker.d.ts +81 -0
- package/dist/types/components/ICETimeline.d.ts +33 -0
- package/dist/types/components/ICETooltip.d.ts +55 -0
- package/dist/types/components/ICETour.d.ts +97 -0
- package/dist/types/components/ICETransfer.d.ts +68 -0
- package/dist/types/components/ICETree.d.ts +107 -0
- package/dist/types/components/ICETreeSelect.d.ts +64 -0
- package/dist/types/components/ICETypography.d.ts +67 -0
- package/dist/types/components/ICEUpload.d.ts +75 -0
- package/dist/types/components/ICEVirtualList.d.ts +100 -0
- package/dist/types/components/ICEWatermark.d.ts +49 -0
- package/dist/types/components/ICEWindow.d.ts +159 -0
- package/dist/types/core/ICEContainer.d.ts +10 -0
- package/dist/types/core/ICEFocusManager.d.ts +70 -0
- package/dist/types/core/ICEHoverManager.d.ts +26 -0
- package/dist/types/core/ICEManager.d.ts +24 -0
- package/dist/types/core/ICEMessageManager.d.ts +80 -0
- package/dist/types/core/ICEOverlayManager.d.ts +92 -0
- package/dist/types/core/ICEPainter.d.ts +12 -0
- package/dist/types/core/ICEWidget.d.ts +86 -0
- package/dist/types/i18n/ICEI18n.d.ts +35 -0
- package/dist/types/index.d.ts +111 -0
- package/dist/types/model/ICE2048Model.d.ts +90 -0
- package/dist/types/model/ICEBoundedRangeModel.d.ts +20 -0
- package/dist/types/model/ICEButtonModel.d.ts +16 -0
- package/dist/types/model/ICEFormModel.d.ts +105 -0
- package/dist/types/model/ICEHighScoreModel.d.ts +60 -0
- package/dist/types/model/ICEMinesweeperModel.d.ts +102 -0
- package/dist/types/model/ICESelectionModel.d.ts +31 -0
- package/dist/types/model/ICESnakeModel.d.ts +90 -0
- package/dist/types/model/ICETetrisModel.d.ts +118 -0
- package/dist/types/model/ICEToggleModel.d.ts +14 -0
- package/dist/types/theme/ICEArcadeTheme.d.ts +22 -0
- package/dist/types/theme/ICETheme.d.ts +120 -0
- package/dist/types/util/ICEAccessibilityMirror.d.ts +55 -0
- package/dist/types/util/ICEAnimation.d.ts +71 -0
- package/dist/types/util/ICEDragReorder.d.ts +102 -0
- package/dist/types/util/ICENativeInput.d.ts +65 -0
- package/dist/types/util/ICEOverlayPosition.d.ts +52 -0
- package/dist/types/util/ICEStyle.d.ts +60 -0
- package/dist/types/util/ICEWorldBox.d.ts +14 -0
- package/package.json +56 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI 过渡:极简补间 + 常用动效助手(淡入淡出 / 滑入 / 缩放进入)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么不用引擎的 AnimationManager:那套是「按 props.animations 声明、每帧写 state 的点路径补间」,
|
|
5
|
+
* 适合常驻动画(蚂蚁线等),但没有**完成回调**与「一次性过渡」的语义。浮层/抽屉/消息这类
|
|
6
|
+
* 「进入-结束-回调」的过渡用它更别扭,所以这里做一层薄薄的 rAF 补间:
|
|
7
|
+
*
|
|
8
|
+
* - 纯函数式:只依赖注入的 frame driver(测试里可手动 step);
|
|
9
|
+
* - 每个 tween 返回句柄,可 cancel(cancel 不触发 onFinish);
|
|
10
|
+
* - duration ≤ 0 时同步落到终点并回调。
|
|
11
|
+
*
|
|
12
|
+
* 渐变类动效改的是组件 `state.opacity`(引擎按子树相乘,整棵子树一起透明,见 ice-render 的
|
|
13
|
+
* 子树不透明度支持);滑块类是直接改 left/top;缩放改 `transform.scale`。
|
|
14
|
+
*/
|
|
15
|
+
export declare type ICEEasingName = 'linear' | 'easeIn' | 'easeOut' | 'easeInOut';
|
|
16
|
+
export declare type ICEEasing = ICEEasingName | ((t: number) => number);
|
|
17
|
+
export interface ICEFrameDriver {
|
|
18
|
+
request(callback: (time: number) => void): any;
|
|
19
|
+
cancel(handle: any): void;
|
|
20
|
+
}
|
|
21
|
+
export interface ICETweenOptions {
|
|
22
|
+
from?: number;
|
|
23
|
+
to: number;
|
|
24
|
+
/** 毫秒;≤ 0 或非法时同步落到终点 */
|
|
25
|
+
duration?: number;
|
|
26
|
+
delay?: number;
|
|
27
|
+
easing?: ICEEasing;
|
|
28
|
+
onUpdate: (value: number) => void;
|
|
29
|
+
onFinish?: () => void;
|
|
30
|
+
driver?: ICEFrameDriver;
|
|
31
|
+
}
|
|
32
|
+
export interface ICETweenHandle {
|
|
33
|
+
cancel(): void;
|
|
34
|
+
}
|
|
35
|
+
export declare function easeInQuad(t: number): number;
|
|
36
|
+
export declare function easeOutCubic(t: number): number;
|
|
37
|
+
export declare function easeInOutCubic(t: number): number;
|
|
38
|
+
export declare function resolveICEEasing(easing?: ICEEasing): (t: number) => number;
|
|
39
|
+
/** 单值补间(frame driver 可注入,测试里手动 step)。 */
|
|
40
|
+
export declare function tween(options: ICETweenOptions): ICETweenHandle;
|
|
41
|
+
/** 过渡公共参数(不含 from/to)。 */
|
|
42
|
+
export interface ICETransitionOptions {
|
|
43
|
+
duration?: number;
|
|
44
|
+
delay?: number;
|
|
45
|
+
easing?: ICEEasing;
|
|
46
|
+
onFinish?: () => void;
|
|
47
|
+
driver?: ICEFrameDriver;
|
|
48
|
+
}
|
|
49
|
+
/** 把不透明度过渡到指定值。 */
|
|
50
|
+
export declare function fadeTo(component: any, to: number, options?: ICETransitionOptions): ICETweenHandle;
|
|
51
|
+
/** 淡入:从 0 到 1。 */
|
|
52
|
+
export declare function fadeIn(component: any, options?: ICETransitionOptions): ICETweenHandle;
|
|
53
|
+
/** 淡出:从当前值到 0(完成后通常再移除组件)。 */
|
|
54
|
+
export declare function fadeOut(component: any, options?: ICETransitionOptions): ICETweenHandle;
|
|
55
|
+
export interface ICESlideOptions extends ICETransitionOptions {
|
|
56
|
+
/** 从哪一侧滑入(目标位置保持不变) */
|
|
57
|
+
from: 'top' | 'bottom' | 'left' | 'right';
|
|
58
|
+
distance?: number;
|
|
59
|
+
/** 是否同时淡入,默认 true */
|
|
60
|
+
fade?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** 滑入:从指定方向的偏移位置移到当前位置(可选同时淡入)。 */
|
|
63
|
+
export declare function slideIn(component: any, options: ICESlideOptions): ICETweenHandle;
|
|
64
|
+
export interface ICEScaleInOptions extends ICETransitionOptions {
|
|
65
|
+
/** 起始缩放(默认 0.96) */
|
|
66
|
+
from?: number;
|
|
67
|
+
/** 是否同时淡入,默认 true */
|
|
68
|
+
fade?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** 缩放进入:scale 从 from 到 1(可选同时淡入)。 */
|
|
71
|
+
export declare function scaleIn(component: any, options?: ICEScaleInOptions): ICETweenHandle;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 拖拽排序的纯逻辑(表格行 / 树节点 / 看板卡共用)。
|
|
3
|
+
*
|
|
4
|
+
* 交互里最容易错的两件事——「指针落在第几行的上/下半格」和「移动之后数组长什么样」——
|
|
5
|
+
* 都在这里用纯函数解决,交互层只负责读指针、画指示线、松手时调用 `moveItem`。
|
|
6
|
+
*/
|
|
7
|
+
/** 落点:插到第 `index` 行的之前 / 之后。 */
|
|
8
|
+
export interface ICEDropTarget {
|
|
9
|
+
index: number;
|
|
10
|
+
position: 'before' | 'after';
|
|
11
|
+
}
|
|
12
|
+
export interface ICEDropTargetOptions {
|
|
13
|
+
/** 指针相对列表内容顶部的纵坐标(已减去滚动偏移) */
|
|
14
|
+
pointerY: number;
|
|
15
|
+
itemHeight: number;
|
|
16
|
+
itemCount: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 指针坐标 → 落点。
|
|
20
|
+
*
|
|
21
|
+
* - 上半格 = `before`,下半格 = `after`(正好压在分界线算 after,边界行为稳定);
|
|
22
|
+
* - 拖到列表上下方会夹到首尾,不会给出越界下标;
|
|
23
|
+
* - 空列表或非法行高返回 `null`(调用方据此不画指示线)。
|
|
24
|
+
*/
|
|
25
|
+
export declare function computeDropTarget(options: ICEDropTargetOptions): ICEDropTarget | null;
|
|
26
|
+
export interface ICEMoveResult<T> {
|
|
27
|
+
items: T[];
|
|
28
|
+
/** 移动后的新下标 */
|
|
29
|
+
to: number;
|
|
30
|
+
/** 是否真的移动了(拖回原位 / 相邻等价位置都算没动) */
|
|
31
|
+
moved: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 把第 `from` 项移到落点处,返回新数组。
|
|
35
|
+
*
|
|
36
|
+
* - 不改原数组(返回的是浅拷贝);
|
|
37
|
+
* - 落点换算成「移除后数组里的插入下标」,所以往回拖不会错一位;
|
|
38
|
+
* - 拖到自己身上、或拖到与自己相邻的等价位置,一律 `moved: false`;
|
|
39
|
+
* - 任一下标越界也当作没动。
|
|
40
|
+
*/
|
|
41
|
+
export declare function moveItem<T>(items: T[], from: number, target: ICEDropTarget): ICEMoveResult<T>;
|
|
42
|
+
/** 树拖拽的落点:`inside` = 放进节点里当子节点。 */
|
|
43
|
+
export interface ICETreeDropTarget {
|
|
44
|
+
index: number;
|
|
45
|
+
position: 'before' | 'inside' | 'after';
|
|
46
|
+
}
|
|
47
|
+
export interface ICETreeDropTargetOptions {
|
|
48
|
+
/** 指针相对**内容顶部**的纵坐标(已减去滚动偏移) */
|
|
49
|
+
pointerY: number;
|
|
50
|
+
itemHeight: number;
|
|
51
|
+
itemCount: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 树的行内三分法:上 1/3 插到前面、中 1/3 放进去当子节点、下 1/3 插到后面。
|
|
55
|
+
*
|
|
56
|
+
* 为什么是三分而不是列表的两分:树拖拽必须能表达「成为它的子节点」这件事,
|
|
57
|
+
* 只用上下两半就只能同级移动了。三分法也是各家树控件的通行做法(手感最好)。
|
|
58
|
+
*/
|
|
59
|
+
export declare function computeTreeDropTarget(options: ICETreeDropTargetOptions): ICETreeDropTarget | null;
|
|
60
|
+
export interface ICETreeNodeLike {
|
|
61
|
+
key: string;
|
|
62
|
+
children?: ICETreeNodeLike[];
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
}
|
|
65
|
+
export interface ICETreeMoveResult<T> {
|
|
66
|
+
nodes: T[];
|
|
67
|
+
moved: boolean;
|
|
68
|
+
/** 移动后的父节点 key(根级为 null) */
|
|
69
|
+
parentKey: string | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 把 `dragKey` 节点移到 `targetKey` 的 before / inside / after。
|
|
73
|
+
*
|
|
74
|
+
* - 返回**新树**(不改原数组/原节点);
|
|
75
|
+
* - **不能拖进自己的后代**(那样整棵子树会凭空消失)—— 直接 `moved: false`;
|
|
76
|
+
* - 位置没变(例如同级 before 到紧邻的下一项)也算没动;
|
|
77
|
+
* - `before/after` 是插到目标的**同级**,`inside` 则成为目标的最后一个子节点。
|
|
78
|
+
*/
|
|
79
|
+
export declare function moveTreeNode<T extends ICETreeNodeLike>(nodes: T[], dragKey: string, targetKey: string, position: ICETreeDropTarget['position'], childrenKey?: string): ICETreeMoveResult<T>;
|
|
80
|
+
/** 看板列(结构最小化:只要 key + cards)。 */
|
|
81
|
+
export interface ICEKanbanColumnLike<T = any> {
|
|
82
|
+
key: string;
|
|
83
|
+
cards: T[];
|
|
84
|
+
[field: string]: any;
|
|
85
|
+
}
|
|
86
|
+
export interface ICEKanbanMoveResult<C> {
|
|
87
|
+
columns: C[];
|
|
88
|
+
moved: boolean;
|
|
89
|
+
/** 移动后所在的列 */
|
|
90
|
+
columnKey: string | null;
|
|
91
|
+
/** 移动后在列内的下标 */
|
|
92
|
+
index: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 看板卡片移动:从原列取出,插到目标列的 `index` 位置。
|
|
96
|
+
*
|
|
97
|
+
* - 卡片对象**引用不变**地搬过去(业务字段不丢);
|
|
98
|
+
* - `index` 超界收到末尾(插到列尾 / 空列都是合法落点);
|
|
99
|
+
* - 未知卡片 / 未知列 / 同列原位(移动前后下标相同)都返回 `moved: false` 且结构不变;
|
|
100
|
+
* - 返回新结构(浅拷贝列数组 + 新卡片数组),原结构不动。
|
|
101
|
+
*/
|
|
102
|
+
export declare function moveKanbanCard<C extends ICEKanbanColumnLike>(columns: C[], cardKey: string, targetColumnKey: string, index: number): ICEKanbanMoveResult<C>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 原生输入替身(canvas 里支持中文 IME 的关键一步)。
|
|
3
|
+
*
|
|
4
|
+
* 问题:canvas 组件自己处理 `keydown` 只能吃单字符键 —— **中文输入法在组字阶段根本没有
|
|
5
|
+
* keydown**,所以「打中文」一直打不进去(只能 `setValue`)。
|
|
6
|
+
*
|
|
7
|
+
* 做法(和引擎 `ICEText.startEditing()` 同一套路):聚焦时在组件上方挂一个**完全透明**的
|
|
8
|
+
* 原生 `<input>` / `<textarea>`,让浏览器和输入法去做它们擅长的事,再把结果回写:
|
|
9
|
+
* - `input`:普通输入(打字、粘贴、删除)
|
|
10
|
+
* - `compositionend`:输入法组字结束(中文/日文/韩文走这条)
|
|
11
|
+
* - `Enter` / `Escape` / `blur`:交给组件决定(提交、取消、收尾)
|
|
12
|
+
*
|
|
13
|
+
* 元素是透明的(文字透明、背景透明、无边框),**画面仍然由 canvas 画**,元素只提供光标与输入法。
|
|
14
|
+
*
|
|
15
|
+
* 没有 `document` 的运行时(Node / 小程序)里 `mount()` 是空操作,组件据此降级回 keydown 输入。
|
|
16
|
+
*/
|
|
17
|
+
export interface ICENativeInputBox {
|
|
18
|
+
left: number;
|
|
19
|
+
top: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ICENativeInputOptions {
|
|
24
|
+
/** 注入 document(测试用假对象);不传则取全局 document */
|
|
25
|
+
doc?: any;
|
|
26
|
+
/** 组件的世界坐标盒(CSS 像素,相对画布左上角) */
|
|
27
|
+
box: ICENativeInputBox;
|
|
28
|
+
value?: string;
|
|
29
|
+
/** 与 canvas 完全一致的字体串(`400 14px Tahoma`),否则光标与文本对不齐 */
|
|
30
|
+
font?: string;
|
|
31
|
+
caretColor?: string;
|
|
32
|
+
/** 0 / 不传 = 不限制 */
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
/** 多行模式:创建 textarea(Enter 换行,不触发 onEnter) */
|
|
35
|
+
multiline?: boolean;
|
|
36
|
+
onInput?: (value: string) => void;
|
|
37
|
+
onEnter?: () => void;
|
|
38
|
+
onEscape?: () => void;
|
|
39
|
+
onBlur?: () => void;
|
|
40
|
+
}
|
|
41
|
+
export declare class ICENativeInput {
|
|
42
|
+
private options;
|
|
43
|
+
private element;
|
|
44
|
+
private doc;
|
|
45
|
+
private value;
|
|
46
|
+
private maxLength;
|
|
47
|
+
private multiline;
|
|
48
|
+
constructor(options: ICENativeInputOptions);
|
|
49
|
+
isMounted(): boolean;
|
|
50
|
+
getElement(): any;
|
|
51
|
+
getValue(): string;
|
|
52
|
+
/** 挂载:创建元素、定位、聚焦、把光标放到末尾。重复调用是幂等的。 */
|
|
53
|
+
mount(): this;
|
|
54
|
+
/** 卸载并解绑;重复调用安全。 */
|
|
55
|
+
unmount(): void;
|
|
56
|
+
/** 外部改值(例如 setValue):同步到元素并把光标移到末尾。 */
|
|
57
|
+
setValue(value: string): this;
|
|
58
|
+
focus(): this;
|
|
59
|
+
private __normalize;
|
|
60
|
+
private __moveCaretToEnd;
|
|
61
|
+
/** `input` 与 `compositionend` 共用:截断 → 回写元素 → 通知组件。 */
|
|
62
|
+
private __handleInput;
|
|
63
|
+
private __handleKeyDown;
|
|
64
|
+
private __handleBlur;
|
|
65
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 浮层定位:纯函数,不依赖 canvas / ICE,便于单测。
|
|
3
|
+
*
|
|
4
|
+
* 语义参照 Ant Design:placement 由「边」+「对齐」组成(如 bottomLeft = 锚点下方、左对齐),
|
|
5
|
+
* 空间不够时自动翻到对侧(flip),最后再夹到容器可见范围内(clamp)。
|
|
6
|
+
*/
|
|
7
|
+
export declare type ICEOverlayPlacement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight' | 'left' | 'leftTop' | 'leftBottom' | 'right' | 'rightTop' | 'rightBottom';
|
|
8
|
+
export interface ICEOverlayBox {
|
|
9
|
+
left: number;
|
|
10
|
+
top: number;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ICEOverlayPositionInput {
|
|
15
|
+
/** 锚点盒(世界坐标) */
|
|
16
|
+
anchor: ICEOverlayBox;
|
|
17
|
+
/** 浮层内容尺寸 */
|
|
18
|
+
content: {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 可见容器(世界坐标)。默认左上角在原点;带视口平移时传 left/top,
|
|
24
|
+
* 内部会在「容器局部坐标」里计算再换回世界坐标。
|
|
25
|
+
*/
|
|
26
|
+
container: {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
left?: number;
|
|
30
|
+
top?: number;
|
|
31
|
+
};
|
|
32
|
+
placement?: ICEOverlayPlacement;
|
|
33
|
+
/** 浮层与锚点的间距(默认 8) */
|
|
34
|
+
offset?: number;
|
|
35
|
+
/** 浮层与容器边缘的最小留白(默认 4) */
|
|
36
|
+
padding?: number;
|
|
37
|
+
/** 空间不足时是否翻到对侧(默认 true) */
|
|
38
|
+
flip?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ICEOverlayPosition {
|
|
41
|
+
left: number;
|
|
42
|
+
top: number;
|
|
43
|
+
/** 实际使用的 placement(可能因 flip 与请求值不同) */
|
|
44
|
+
placement: ICEOverlayPlacement;
|
|
45
|
+
/** 是否发生了翻转 */
|
|
46
|
+
flipped: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 计算浮层位置:优先用请求的 placement;放不下且 flip 打开时翻到对侧;
|
|
50
|
+
* 最后把结果夹进容器(内容比容器还大时夹到起始边,保证左上角可见)。
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveICEOverlayPosition(input: ICEOverlayPositionInput): ICEOverlayPosition;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ICEText } from 'ice-render';
|
|
2
|
+
import type { ICEThemeTokens } from '../theme/ICETheme';
|
|
3
|
+
export declare type ICEStatusColor = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info';
|
|
4
|
+
/**
|
|
5
|
+
* 极简文本宽度估算(给「按最长文字定容器宽度」用的)。
|
|
6
|
+
*
|
|
7
|
+
* 画布文本**没有裁剪**:容器(tooltip / dropdown 面板)算窄了,中文会直接压出色块外面。
|
|
8
|
+
* 中日韩与全角字符按 1em、其余按 0.6em 估算——够用且不依赖 ctx(构造期就能算)。
|
|
9
|
+
*/
|
|
10
|
+
export declare function estimateTextWidth(text: string, fontSize: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* 从 `hoverchange` 事件里读取 hovered。
|
|
13
|
+
*
|
|
14
|
+
* 引擎的 `trigger(name, evt, param)` 把第三个参数放进 `event.param`(不是平铺在事件上),
|
|
15
|
+
* 而手写的 `trigger('hoverchange', { hovered })` 又是平铺的 —— 两种都要兼容。
|
|
16
|
+
* 只读 `evt.hovered` 会永远拿到 undefined,表现为「悬停反馈静默失效」。
|
|
17
|
+
*/
|
|
18
|
+
export declare function readHovered(evt: any): boolean;
|
|
19
|
+
export declare type ICEStatusColors = {
|
|
20
|
+
background: string;
|
|
21
|
+
border: string;
|
|
22
|
+
/** 状态实色(白底上的文字 / 进度条等填充) */
|
|
23
|
+
text: string;
|
|
24
|
+
/** subtle 浅底上的强调文字色(Bootstrap `*-text-emphasis`) */
|
|
25
|
+
strong: string;
|
|
26
|
+
/** 实底填充(Bootstrap `.text-bg-*` 的 background) */
|
|
27
|
+
solid: string;
|
|
28
|
+
/** 实底上的文字色(亮色底为黑字) */
|
|
29
|
+
onSolid: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function getStatusColors(theme: ICEThemeTokens, status?: ICEStatusColor): {
|
|
32
|
+
background: string;
|
|
33
|
+
border: string;
|
|
34
|
+
text: string;
|
|
35
|
+
strong: string;
|
|
36
|
+
solid: string;
|
|
37
|
+
onSolid: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 创建一段按照 ICE 约定居中显示的文本。
|
|
41
|
+
* width/height 不传时交给 ICEText 自动测量,并保持左上角文本语义。
|
|
42
|
+
*/
|
|
43
|
+
export declare function createTextNode(props: {
|
|
44
|
+
text?: string;
|
|
45
|
+
left?: number;
|
|
46
|
+
top?: number;
|
|
47
|
+
width?: number;
|
|
48
|
+
height?: number;
|
|
49
|
+
fillStyle?: string;
|
|
50
|
+
fontFamily?: string;
|
|
51
|
+
fontSize?: number;
|
|
52
|
+
fontWeight?: string;
|
|
53
|
+
align?: 'left' | 'center' | 'right';
|
|
54
|
+
verticalAlign?: 'top' | 'middle' | 'bottom';
|
|
55
|
+
}): ICEText;
|
|
56
|
+
export declare function centerTextNode(text: string, theme: ICEThemeTokens, width: number, height: number, options?: {
|
|
57
|
+
fontSize?: number;
|
|
58
|
+
fontWeight?: string;
|
|
59
|
+
fillStyle?: string;
|
|
60
|
+
}): ICEText;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI 组件的世界盒(`left/top/width/height`)。
|
|
3
|
+
*
|
|
4
|
+
* UI 组件不旋转,父子关系就是简单的偏移叠加:沿父链累加 left/top 即可,
|
|
5
|
+
* 不依赖引擎的 composedMatrix 是否新鲜(浮层定位、焦点环、命中范围判断都要用)。
|
|
6
|
+
*/
|
|
7
|
+
export interface ICEWorldBox {
|
|
8
|
+
left: number;
|
|
9
|
+
top: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function getICEWorldBox(component: any): ICEWorldBox;
|
|
14
|
+
export declare function isPointInsideICEBox(box: ICEWorldBox, x: number, y: number): boolean;
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ice-web-components",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Swing-style Canvas UI components built on ice-render.",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"browser": "dist/index.umd.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "npm run clean && npm run build:types && npm run build:js",
|
|
14
|
+
"build:js": "rollup -c --environment NODE_ENV:production",
|
|
15
|
+
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
16
|
+
"clean": "rimraf dist",
|
|
17
|
+
"dev": "rollup -c -w --environment NODE_ENV:development",
|
|
18
|
+
"test": "jest --runInBand",
|
|
19
|
+
"types:check": "tsc --noEmit",
|
|
20
|
+
"qa:admin": "node scripts/qa-admin.mjs",
|
|
21
|
+
"qa:gallery": "node scripts/qa-gallery.mjs",
|
|
22
|
+
"qa:workbench": "node scripts/qa-workbench.mjs",
|
|
23
|
+
"qa:xp": "node scripts/qa-xp.mjs",
|
|
24
|
+
"qa:arcade": "node scripts/qa-arcade.mjs",
|
|
25
|
+
"docs:api": "node scripts/gen-docs.mjs",
|
|
26
|
+
"docs:check": "node scripts/check-docs.mjs",
|
|
27
|
+
"docs": "npm run docs:api && npm run docs:check",
|
|
28
|
+
"verify": "npm run types:check && npm test && npm run build && npm run docs"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"ice-render": "^1.3.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/core": "7.17.8",
|
|
35
|
+
"@babel/preset-env": "7.16.11",
|
|
36
|
+
"@babel/preset-typescript": "7.9.0",
|
|
37
|
+
"@rollup/plugin-commonjs": "21.0.2",
|
|
38
|
+
"@rollup/plugin-json": "4.1.0",
|
|
39
|
+
"@rollup/plugin-node-resolve": "13.1.3",
|
|
40
|
+
"@types/jest": "^27.5.2",
|
|
41
|
+
"@types/node": "^14.18.63",
|
|
42
|
+
"jest": "25.4.0",
|
|
43
|
+
"rimraf": "3.0.2",
|
|
44
|
+
"rollup": "2.70.1",
|
|
45
|
+
"rollup-plugin-babel": "4.4.0",
|
|
46
|
+
"rollup-plugin-terser": "5.3.0",
|
|
47
|
+
"typescript": "4.6.2"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"canvas",
|
|
51
|
+
"ui",
|
|
52
|
+
"ice-render",
|
|
53
|
+
"swing"
|
|
54
|
+
],
|
|
55
|
+
"license": "MIT"
|
|
56
|
+
}
|