compelem 0.28.0 → 0.28.2
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/.agents/skills/compelem-usage/SKILL.md +303 -0
- package/README.md +35 -20
- package/dist/CompElem.d.ts +107 -0
- package/dist/IComponent.d.ts +71 -0
- package/dist/config.d.ts +10 -0
- package/dist/constants.d.ts +64 -0
- package/dist/decorator/Decorator.d.ts +35 -0
- package/dist/decorator/index.d.ts +32 -0
- package/dist/decorators/computed.d.ts +9 -0
- package/dist/decorators/csscope.d.ts +14 -0
- package/dist/decorators/debounced.d.ts +1 -0
- package/dist/decorators/emits.d.ts +14 -0
- package/dist/decorators/event.d.ts +7 -0
- package/dist/decorators/onced.d.ts +1 -0
- package/dist/decorators/prop.d.ts +8 -0
- package/dist/decorators/query.d.ts +8 -0
- package/dist/decorators/state.d.ts +14 -0
- package/dist/decorators/tag.d.ts +7 -0
- package/dist/decorators/throttled.d.ts +1 -0
- package/dist/decorators/watch.d.ts +9 -0
- package/dist/devtools.d.ts +38 -0
- package/dist/directive/index.d.ts +11 -0
- package/dist/directives/Bind.d.ts +5 -0
- package/dist/directives/Classes.d.ts +6 -0
- package/dist/directives/ForEach.d.ts +7 -0
- package/dist/directives/Html.d.ts +6 -0
- package/dist/directives/IfElse.d.ts +7 -0
- package/dist/directives/IfTrue.d.ts +7 -0
- package/dist/directives/Model.d.ts +16 -0
- package/dist/directives/Show.d.ts +9 -0
- package/dist/directives/Slot.d.ts +7 -0
- package/dist/directives/Styles.d.ts +7 -0
- package/dist/directives/When.d.ts +22 -0
- package/dist/events/event.d.ts +22 -0
- package/dist/events/extends.d.ts +4 -0
- package/dist/helpers.d.ts +18 -0
- package/dist/index.cjs.js +7 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.esm.js +7 -0
- package/dist/reactive.d.ts +34 -0
- package/dist/render/CssTemplate.d.ts +11 -0
- package/dist/render/Template.d.ts +27 -0
- package/dist/render/TemplateMeta.d.ts +17 -0
- package/dist/render/UpdatePoint.d.ts +32 -0
- package/dist/render/UpdatePointMeta.d.ts +28 -0
- package/dist/render/render.d.ts +53 -0
- package/dist/transition/index.d.ts +62 -0
- package/dist/types.d.ts +197 -0
- package/dist/utils.d.ts +19 -0
- package/dist/viewTransition.d.ts +10 -0
- package/dist-dev/compelem.umd.js +6262 -0
- package/dist-dev/devtools.d.ts +38 -0
- package/dist-dev/index.cjs.js +6258 -0
- package/dist-dev/index.esm.js +6177 -0
- package/llms.txt +92 -0
- package/package.json +47 -8
- package/CHANGELOG.md +0 -1
- package/index.js +0 -7
- /package/{CompElem.d.ts → dist-dev/CompElem.d.ts} +0 -0
- /package/{IComponent.d.ts → dist-dev/IComponent.d.ts} +0 -0
- /package/{config.d.ts → dist-dev/config.d.ts} +0 -0
- /package/{constants.d.ts → dist-dev/constants.d.ts} +0 -0
- /package/{decorator → dist-dev/decorator}/Decorator.d.ts +0 -0
- /package/{decorator → dist-dev/decorator}/index.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/computed.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/csscope.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/debounced.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/emits.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/event.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/onced.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/prop.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/query.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/state.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/tag.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/throttled.d.ts +0 -0
- /package/{decorators → dist-dev/decorators}/watch.d.ts +0 -0
- /package/{directive → dist-dev/directive}/index.d.ts +0 -0
- /package/{directives → dist-dev/directives}/Bind.d.ts +0 -0
- /package/{directives → dist-dev/directives}/Classes.d.ts +0 -0
- /package/{directives → dist-dev/directives}/ForEach.d.ts +0 -0
- /package/{directives → dist-dev/directives}/Html.d.ts +0 -0
- /package/{directives → dist-dev/directives}/IfElse.d.ts +0 -0
- /package/{directives → dist-dev/directives}/IfTrue.d.ts +0 -0
- /package/{directives → dist-dev/directives}/Model.d.ts +0 -0
- /package/{directives → dist-dev/directives}/Show.d.ts +0 -0
- /package/{directives → dist-dev/directives}/Slot.d.ts +0 -0
- /package/{directives → dist-dev/directives}/Styles.d.ts +0 -0
- /package/{directives → dist-dev/directives}/When.d.ts +0 -0
- /package/{events → dist-dev/events}/event.d.ts +0 -0
- /package/{events → dist-dev/events}/extends.d.ts +0 -0
- /package/{helpers.d.ts → dist-dev/helpers.d.ts} +0 -0
- /package/{index.d.ts → dist-dev/index.d.ts} +0 -0
- /package/{reactive.d.ts → dist-dev/reactive.d.ts} +0 -0
- /package/{render → dist-dev/render}/CssTemplate.d.ts +0 -0
- /package/{render → dist-dev/render}/Template.d.ts +0 -0
- /package/{render → dist-dev/render}/TemplateMeta.d.ts +0 -0
- /package/{render → dist-dev/render}/UpdatePoint.d.ts +0 -0
- /package/{render → dist-dev/render}/UpdatePointMeta.d.ts +0 -0
- /package/{render → dist-dev/render}/render.d.ts +0 -0
- /package/{transition → dist-dev/transition}/index.d.ts +0 -0
- /package/{types.d.ts → dist-dev/types.d.ts} +0 -0
- /package/{utils.d.ts → dist-dev/utils.d.ts} +0 -0
- /package/{viewTransition.d.ts → dist-dev/viewTransition.d.ts} +0 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author holyhigh2
|
|
3
|
+
*/
|
|
4
|
+
import { CompElem } from "./CompElem";
|
|
5
|
+
import { Template } from "./render/Template";
|
|
6
|
+
export type Constructor<T> = new (...args: any[]) => T;
|
|
7
|
+
export type Getter = () => any;
|
|
8
|
+
export type Updater = (...args: any[]) => any;
|
|
9
|
+
/**
|
|
10
|
+
* 插槽配置对象
|
|
11
|
+
*/
|
|
12
|
+
export type SlotOptions = {
|
|
13
|
+
props: Record<string, any>;
|
|
14
|
+
hook: Function;
|
|
15
|
+
};
|
|
16
|
+
export type TplFn = (...args: any[]) => Template;
|
|
17
|
+
export type KeyFn = (item: any, k: string | number, i: number) => string | number;
|
|
18
|
+
export type UpdatedSource = {
|
|
19
|
+
value: any;
|
|
20
|
+
chain?: string[];
|
|
21
|
+
oldValue?: any;
|
|
22
|
+
end?: boolean;
|
|
23
|
+
subNewValue?: any;
|
|
24
|
+
subOldValue?: any;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 属性定义
|
|
28
|
+
*/
|
|
29
|
+
export declare enum EnterPointType {
|
|
30
|
+
ATTR = "attr",//属性,文本内容,可以内嵌多插值
|
|
31
|
+
PROP = "prop",//参数,智能内嵌一个插值
|
|
32
|
+
TEXT = "text",
|
|
33
|
+
SLOT = "slot",
|
|
34
|
+
TAG = "tag"
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 监控定义
|
|
38
|
+
*/
|
|
39
|
+
export type WatchOptions = {
|
|
40
|
+
/**
|
|
41
|
+
* 是否立即执行
|
|
42
|
+
*/
|
|
43
|
+
immediate?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 是否深度监控
|
|
46
|
+
*/
|
|
47
|
+
deep?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* 是否仅执行一次
|
|
50
|
+
*/
|
|
51
|
+
once?: boolean;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 事件选项
|
|
55
|
+
*/
|
|
56
|
+
export type QueryOption = {
|
|
57
|
+
/**
|
|
58
|
+
* 指示是否返回任何可用子<slot>元素的指定节点(true)或不返回(false)
|
|
59
|
+
*/
|
|
60
|
+
flatten?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 对节点列表进行过滤
|
|
63
|
+
*/
|
|
64
|
+
selector?: string;
|
|
65
|
+
/**
|
|
66
|
+
* 缓存标识
|
|
67
|
+
*/
|
|
68
|
+
cache?: string;
|
|
69
|
+
};
|
|
70
|
+
export type StateOption = {
|
|
71
|
+
/**
|
|
72
|
+
* 是否浅层监控,默认false
|
|
73
|
+
*/
|
|
74
|
+
shallow?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* 指定prop进行初始化,如果时对象类型时
|
|
77
|
+
*/
|
|
78
|
+
prop?: string;
|
|
79
|
+
/**
|
|
80
|
+
* 是否发生变更,如果未指定使用严格相等
|
|
81
|
+
* @param newValue
|
|
82
|
+
* @param oldValue
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
hasChanged?: (newValue: any, oldValue: any, changeChain: string[], subNewValue: any, subOldValue: any) => boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* 属性定义
|
|
89
|
+
*/
|
|
90
|
+
export type PropOption = {
|
|
91
|
+
/**
|
|
92
|
+
* 是否浅层监控,默认false。如果属性值是由上级组件传递的state且已经指定shallow,则忽略该属性
|
|
93
|
+
*/
|
|
94
|
+
shallow?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* 参数类型
|
|
97
|
+
*/
|
|
98
|
+
type: Constructor<any> | Array<Constructor<any>>;
|
|
99
|
+
/**
|
|
100
|
+
* 是否必填,默认false
|
|
101
|
+
*/
|
|
102
|
+
required?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* 是否声明为一个双向绑定属性,默认false
|
|
105
|
+
*/
|
|
106
|
+
model?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* 是否关联属性,prop会生成dom属性且当属性变动时自动更新值。默认true
|
|
109
|
+
*/
|
|
110
|
+
attribute?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* 是否发生变更,如果未指定使用严格相等
|
|
113
|
+
* @param newValue
|
|
114
|
+
* @param oldValue
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
hasChanged?: (newValue: any, oldValue: any, changeChain: string[], subNewValue: any, subOldValue: any) => boolean;
|
|
118
|
+
/**
|
|
119
|
+
* 当传递参数值为string类型且参数类型不是string时会调用转换器进行转换
|
|
120
|
+
* @param stringValue
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
converter?: (stringValue: string) => any;
|
|
124
|
+
_defaultValue?: any;
|
|
125
|
+
/**
|
|
126
|
+
* 属性校验器,可动态校验值是否合法
|
|
127
|
+
* @param value
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
isValid?: (value: any, props?: Record<string, any>) => boolean;
|
|
131
|
+
};
|
|
132
|
+
export type DirectiveExecutor = (node: Node, newArgs: any[], oldArgs: any[] | undefined, meta?: {
|
|
133
|
+
pointType?: string;
|
|
134
|
+
renderComponent?: CompElem;
|
|
135
|
+
slotComponent?: CompElem;
|
|
136
|
+
varChain?: string[];
|
|
137
|
+
attrName?: string;
|
|
138
|
+
updatedMap?: Record<string, UpdatedSource>;
|
|
139
|
+
}) => [DirectiveUpdateTag, ...any] | void;
|
|
140
|
+
export type DirectiveInstance = [
|
|
141
|
+
DirectiveExecutor,
|
|
142
|
+
Array<any>,
|
|
143
|
+
Function,
|
|
144
|
+
any[]
|
|
145
|
+
];
|
|
146
|
+
export declare enum DirectiveUpdateTag {
|
|
147
|
+
NONE = "NONE",//框架不处理
|
|
148
|
+
REFRESH = "REFRESH",//刷新视图
|
|
149
|
+
REMOVE = "REMOVE",//删除指令创建的节点
|
|
150
|
+
REPLACE = "REPLACE",//删除已有节点后插入
|
|
151
|
+
UPDATE = "UPDATE",//对比更新
|
|
152
|
+
INIT = "INIT"
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 新旧内容交替模式
|
|
156
|
+
* - default:离场与入场同时进行
|
|
157
|
+
* - out-in:旧内容离场完成后新内容再入场
|
|
158
|
+
* - in-out:新内容入场完成后旧内容再离场
|
|
159
|
+
*/
|
|
160
|
+
export type TransitionMode = 'default' | 'out-in' | 'in-out';
|
|
161
|
+
/**
|
|
162
|
+
* transition指令选项
|
|
163
|
+
*/
|
|
164
|
+
export type TransitionOptions = Record<string, Function> & {
|
|
165
|
+
/**
|
|
166
|
+
* 新旧内容交替模式,默认default
|
|
167
|
+
*/
|
|
168
|
+
mode?: TransitionMode;
|
|
169
|
+
/**
|
|
170
|
+
* 首次渲染时是否播放入场动画,默认false
|
|
171
|
+
*/
|
|
172
|
+
appear?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* 显式动画时长(ms),设置后不再自动探测transition/animation时长
|
|
175
|
+
*/
|
|
176
|
+
duration?: number;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* 解析后的过渡动画配置
|
|
180
|
+
*/
|
|
181
|
+
export type TransitionCfg = {
|
|
182
|
+
name: string;
|
|
183
|
+
mode?: TransitionMode;
|
|
184
|
+
appear?: boolean;
|
|
185
|
+
duration?: number;
|
|
186
|
+
hooks?: Record<string, Function>;
|
|
187
|
+
};
|
|
188
|
+
export type DefaultProps = Partial<{
|
|
189
|
+
css: Array<string | CSSStyleSheet>;
|
|
190
|
+
global: Record<string, any>;
|
|
191
|
+
[key: string]: Record<string, any>;
|
|
192
|
+
}>;
|
|
193
|
+
export type StyleValueObjectType = {
|
|
194
|
+
value: number | string;
|
|
195
|
+
important?: boolean;
|
|
196
|
+
};
|
|
197
|
+
export type StyleValueType = string | number | StyleValueObjectType;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CompElem } from "./CompElem";
|
|
2
|
+
export declare function showError(msg: string): void;
|
|
3
|
+
export declare function showTagError(tagName: string, msg: string): void;
|
|
4
|
+
export declare function showWarn(...args: unknown[]): void;
|
|
5
|
+
export declare function showTagWarn(tagName: string, msg: string): void;
|
|
6
|
+
export declare function _getSuper(cls: CompElem): any;
|
|
7
|
+
export declare function isBooleanProp(type: any): boolean;
|
|
8
|
+
export declare function getBooleanValue(v: any): any;
|
|
9
|
+
export declare const DomUtil: {
|
|
10
|
+
getNodes(startNode: Node, endNode: Node): Node[];
|
|
11
|
+
insertBefore: (node: Node, newNodes: any[]) => void;
|
|
12
|
+
remove: (startNode: Node, endNode: Node) => void;
|
|
13
|
+
clear(container: Element | ShadowRoot | null): void;
|
|
14
|
+
};
|
|
15
|
+
export declare function isCompElemNode(node: Element): boolean;
|
|
16
|
+
export declare function addUninitializedSubComponentProp(wrapperComponent: CompElem, node: Element, props: Record<string, any>): void;
|
|
17
|
+
export declare function getCssVarKey(ctor: Function, k: string): string;
|
|
18
|
+
export declare function camelCaseCached(name: string): string;
|
|
19
|
+
export declare function typeNameLower(et: Function): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View Transitions API 封装:在浏览器支持的环境下返回过渡的 finished Promise,
|
|
3
|
+
* 可用 ::view-transition-old(root) / ::view-transition-new(root) CSS 控制过渡效果。
|
|
4
|
+
* 不支持时(如Firefox)降级为直接执行回调。
|
|
5
|
+
*
|
|
6
|
+
* 适合整页级路由切换:
|
|
7
|
+
* @example
|
|
8
|
+
* startViewTransition(() => { location.href = '#/next' })
|
|
9
|
+
*/
|
|
10
|
+
export declare function startViewTransition(callback: () => void | Promise<void>): Promise<void> | undefined;
|