compelem 0.2.3-beta → 0.3.0-b1
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/CompElem.d.ts +20 -31
- package/IComponent.d.ts +9 -5
- package/README.md +50 -23
- package/constants.d.ts +16 -0
- package/decorator/Decorator.d.ts +3 -7
- package/decorator/index.d.ts +2 -1
- package/decorators/computed.d.ts +1 -2
- package/decorators/watch.d.ts +1 -8
- package/directive/Directive.d.ts +14 -15
- package/directive/index.d.ts +6 -3
- package/events/event.d.ts +4 -3
- package/events/extends.d.ts +2 -1
- package/helpers.d.ts +18 -0
- package/index.d.ts +3 -1
- package/index.js +3644 -2
- package/package.json +9 -9
- package/reactive.d.ts +24 -13
- package/render/RenderContext.d.ts +41 -26
- package/render/Template.d.ts +26 -0
- package/render/render.d.ts +7 -23
- package/types.d.ts +13 -6
package/CompElem.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { Directive } from "./directive/Directive";
|
|
2
2
|
import { IComponent } from "./IComponent";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { TmplFn } from "./types";
|
|
3
|
+
import { IView } from "./render/RenderContext";
|
|
4
|
+
import { Template } from "./render/Template";
|
|
5
|
+
import { DefaultProps, TmplFn } from "./types";
|
|
6
6
|
declare const CompElem_base: {
|
|
7
7
|
new (...args: any[]): {
|
|
8
8
|
[x: string]: any;
|
|
9
|
-
|
|
10
|
-
__expPos: Record<string, import("./types").ExpPos>;
|
|
11
|
-
__expPosMap: Record<string, Record<string, import("./types").ExpPos> | null>;
|
|
12
|
-
__directives: Record<string, Directive>;
|
|
13
|
-
slotComponent: CompElem;
|
|
9
|
+
__updatePoints: Array<import("./types").UpdatePoint>;
|
|
14
10
|
renderComponent: CompElem;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
__updateExpPos(tmpl: Template, _expPos: Record<string, import("./types").ExpPos>): void;
|
|
11
|
+
buildView(tmpl: Template): NodeListOf<ChildNode>;
|
|
12
|
+
updateView(tmpl: Template): void;
|
|
18
13
|
};
|
|
19
14
|
} & {
|
|
20
15
|
new (): HTMLElement;
|
|
@@ -29,15 +24,17 @@ declare const CompElem_base: {
|
|
|
29
24
|
export declare class CompElem extends CompElem_base implements IComponent {
|
|
30
25
|
#private;
|
|
31
26
|
static __l_globalRule: HTMLStyleElement;
|
|
27
|
+
static defaults(options: DefaultProps): void;
|
|
32
28
|
__events: Record<string, Array<Node | ((e: Event) => void)>[]>;
|
|
29
|
+
get [Symbol.toStringTag](): string;
|
|
33
30
|
get reactiveData(): Record<string, any>;
|
|
34
31
|
get attrs(): Record<string, string>;
|
|
35
32
|
get props(): Record<string, any>;
|
|
36
33
|
get renderRoot(): HTMLElement;
|
|
37
34
|
get renderRoots(): HTMLElement[];
|
|
38
|
-
get parentComponent():
|
|
35
|
+
get parentComponent(): CompElem | null;
|
|
39
36
|
get slotHooks(): Record<string, (...args: any[]) => Template>;
|
|
40
|
-
get
|
|
37
|
+
get css(): CSSStyleSheet[];
|
|
41
38
|
get isMounted(): boolean;
|
|
42
39
|
get slots(): Record<string, Array<Node>>;
|
|
43
40
|
/**
|
|
@@ -49,29 +46,17 @@ export declare class CompElem extends CompElem_base implements IComponent {
|
|
|
49
46
|
*/
|
|
50
47
|
static get styles(): Array<string | CSSStyleSheet>;
|
|
51
48
|
static get globalStyles(): Array<string>;
|
|
52
|
-
get
|
|
49
|
+
get styles(): Array<() => string>;
|
|
53
50
|
constructor(...args: any[]);
|
|
54
51
|
connectedCallback(): void;
|
|
55
52
|
disconnectedCallback(): void;
|
|
56
53
|
__init(): void;
|
|
57
|
-
|
|
58
|
-
* 初始化属性及状态,该回调内可以访问props和state
|
|
59
|
-
* 此时组件dom并未构建,但已有parent 属性,没有root属性
|
|
60
|
-
*/
|
|
61
|
-
connected(): void;
|
|
62
|
-
/**
|
|
63
|
-
* props初始化完成回调
|
|
64
|
-
*/
|
|
65
|
-
propsReady(): void;
|
|
66
|
-
/**
|
|
67
|
-
* 每次更新时调用
|
|
68
|
-
*/
|
|
54
|
+
propsReady(props: Record<string, any>): void;
|
|
69
55
|
render(): Template;
|
|
70
|
-
|
|
71
|
-
* dom渲染完毕后调用,该回调内可以query注解初始化完成
|
|
72
|
-
*/
|
|
56
|
+
beforeMount(): void;
|
|
73
57
|
mounted(): void;
|
|
74
58
|
slotChange(slot: HTMLSlotElement, name: string): void;
|
|
59
|
+
attributeChangedCallback(attributeName: string, oldValue: string | null, newValue: string | null): void;
|
|
75
60
|
/**
|
|
76
61
|
* 是否需要更新,可获取变更属性
|
|
77
62
|
* 返回true时更新
|
|
@@ -117,7 +102,7 @@ export declare class CompElem extends CompElem_base implements IComponent {
|
|
|
117
102
|
* @param rootStateKey 如果是对象内部属性变更,会返回根属性名
|
|
118
103
|
* @returns
|
|
119
104
|
*/
|
|
120
|
-
_notify(ov: any, chain: string[]):
|
|
105
|
+
_notify(ov: any, chain: string[]): any;
|
|
121
106
|
/**
|
|
122
107
|
* @deprecated
|
|
123
108
|
*/
|
|
@@ -130,8 +115,12 @@ export declare class CompElem extends CompElem_base implements IComponent {
|
|
|
130
115
|
_bindSlot(slot: HTMLSlotElement, name: string, props: Record<string, any>): void;
|
|
131
116
|
_bindSlotHook(name: string, hook: (...args: any[]) => Template): void;
|
|
132
117
|
_updateSlot(name: string, propName?: string, value?: any): void;
|
|
133
|
-
_asyncDirectives: WeakMap<TmplFn,
|
|
118
|
+
_asyncDirectives: WeakMap<TmplFn, IView>;
|
|
134
119
|
renderAsync(cbk: TmplFn, ...args: any[]): void;
|
|
120
|
+
/**
|
|
121
|
+
* todo
|
|
122
|
+
* 1. 取消上溯递归路径
|
|
123
|
+
*/
|
|
135
124
|
_regDeps(varPath: string, renderContext: CompElem | Directive): void;
|
|
136
125
|
}
|
|
137
126
|
export {};
|
package/IComponent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Template } from "./render/
|
|
1
|
+
import { Template } from "./render/Template";
|
|
2
2
|
/**
|
|
3
3
|
* 组件接口
|
|
4
4
|
* 定义组件属性、生命周期及方法
|
|
@@ -12,15 +12,19 @@ export interface IComponent {
|
|
|
12
12
|
get parentComponent(): HTMLElement | null;
|
|
13
13
|
get slots(): Record<string, Array<Node>>;
|
|
14
14
|
get slotHooks(): Record<string, (...args: any[]) => Template>;
|
|
15
|
-
get
|
|
15
|
+
get css(): CSSStyleSheet[];
|
|
16
16
|
get isMounted(): boolean;
|
|
17
|
-
|
|
18
|
-
propsReady(): void;
|
|
17
|
+
get styles(): Array<() => string>;
|
|
18
|
+
propsReady(props: Record<string, any>): void;
|
|
19
19
|
render(): Template;
|
|
20
|
+
beforeMount(): void;
|
|
20
21
|
mounted(): void;
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
disconnectedCallback(): void;
|
|
21
24
|
shouldUpdate(changed: Record<string, any>): boolean;
|
|
22
25
|
updated(changed: Record<string, any>): void;
|
|
23
|
-
slotChange(slot: HTMLSlotElement,
|
|
26
|
+
slotChange(slot: HTMLSlotElement, slotName: string): void;
|
|
27
|
+
attributeChangedCallback(attributeName: string, oldValue: string | null, newValue: string | null): void;
|
|
24
28
|
/**
|
|
25
29
|
* 抛出自定义事件
|
|
26
30
|
* @param evName 事件名称
|
package/README.md
CHANGED
|
@@ -43,11 +43,15 @@ export class PageTest extends CompElem {
|
|
|
43
43
|
}...`];
|
|
44
44
|
}
|
|
45
45
|
//动态样式
|
|
46
|
-
get
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
get styles() {
|
|
47
|
+
return [
|
|
48
|
+
() => `h2,p,i,h3{
|
|
49
|
+
background-image:${this.color};
|
|
50
|
+
}`,
|
|
51
|
+
() => `h2,p,i,h3{
|
|
52
|
+
filter:hue-rotate(${this.rotation}deg);
|
|
53
|
+
}`,
|
|
54
|
+
]
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
@query('i[name="text"]')
|
|
@@ -140,10 +144,10 @@ export class PageTest extends CompElem {
|
|
|
140
144
|
```
|
|
141
145
|
对于需要动态控制 host 元素样式可以使用组件实例 getter
|
|
142
146
|
```ts
|
|
143
|
-
get
|
|
144
|
-
return
|
|
147
|
+
get styles(){
|
|
148
|
+
return [()=>`:host{
|
|
145
149
|
${this.border?'border: 1px solid rgb(var(--l-color-border-secondary)); ':''}
|
|
146
|
-
}`
|
|
150
|
+
}`]
|
|
147
151
|
}
|
|
148
152
|
```
|
|
149
153
|
- ### 属性
|
|
@@ -250,7 +254,7 @@ export class PageTest extends CompElem {
|
|
|
250
254
|
- `readonly` shadowRoot 阴影DOM
|
|
251
255
|
- `readonly` slots 插槽元素映射
|
|
252
256
|
- `readonly` slotHooks 动态插槽钩子映射
|
|
253
|
-
- `readonly`
|
|
257
|
+
- `readonly` css 组件样式对象列表
|
|
254
258
|
- `readonly` attrs 组件特性
|
|
255
259
|
- `readonly` props 组件属性
|
|
256
260
|
- slotComponent 所在插槽组件
|
|
@@ -269,17 +273,18 @@ CompElem 组件既可以在 CompElem 环境内调用,也可以直接在原生
|
|
|
269
273
|
| ------------------------------------------------------------ | --- | ----------- |
|
|
270
274
|
| 1. 创建组件实例,完成类属性默认值设置(prop/state/...) | | |
|
|
271
275
|
| 2. 初始化类全局样式(仅一次)及 实例样式(产生 styles 数组) | | |
|
|
272
|
-
| 3.
|
|
273
|
-
| 4.
|
|
274
|
-
| 5.
|
|
275
|
-
| 6.
|
|
276
|
-
| 7.
|
|
277
|
-
| 8.
|
|
278
|
-
| 9.
|
|
279
|
-
| 10.
|
|
280
|
-
| 11.
|
|
281
|
-
| 12.
|
|
282
|
-
| 13.
|
|
276
|
+
| 3. 注入 link 外部样式表 | | |
|
|
277
|
+
| 4. 创建 shadowRoot 并挂载组件样式 | | |
|
|
278
|
+
| 5. 执行装饰器create回调 | | constructor |
|
|
279
|
+
| 6. 绑定 parentComponent | | |
|
|
280
|
+
| 7. 验证及初始化 props | | propsReady |
|
|
281
|
+
| 8. 初始化 states | | |
|
|
282
|
+
| 9. 渲染 render 及依赖绑定 | | render |
|
|
283
|
+
| 10. 绑定 renderRoot 及 renderRoots | | |
|
|
284
|
+
| 11. 初始化插槽 slots | | beforeMount |
|
|
285
|
+
| 12. 执行装饰器 beforeMount 回调 ,包括 @watch(immediate)、@computed、@event、@query | | |
|
|
286
|
+
| 13. 初始化 css getter | | mounted |
|
|
287
|
+
| 14. 执行装饰器 mounted 回调 ,包括 @watch | | |
|
|
283
288
|
|
|
284
289
|
> 更新流程【普通】
|
|
285
290
|
|
|
@@ -410,8 +415,30 @@ static get autoSlot() {
|
|
|
410
415
|
|
|
411
416
|
## 事件
|
|
412
417
|
|
|
413
|
-
|
|
418
|
+
在CompElem中事件分为三类
|
|
414
419
|
|
|
415
420
|
1. 原生事件 —— `<div @click="..."`,监听器回调参数返回原生事件对象
|
|
416
|
-
2.
|
|
417
|
-
3.
|
|
421
|
+
2. 扩展原生事件 —— `<div @resize="..."`,监听器回调参数返回`CustomEvent`事件对象
|
|
422
|
+
3. 组件自定义事件 —— `<l-select @change="..."`,监听器回调参数返回`CustomEvent`事件对象
|
|
423
|
+
|
|
424
|
+
### 事件修饰符
|
|
425
|
+
通过`.`号可使用修饰符修饰事件如 `@scroll.throttle:100="${...}"`
|
|
426
|
+
- 全部通用 —— `debounce/throttle/once` 可组合
|
|
427
|
+
- 原生通用 —— `stop/prevent/self` 可组合
|
|
428
|
+
- 鼠标 —— `left/right/middle` 不可组合
|
|
429
|
+
- 键盘 —— `ctrl/alt/shift/meta` 可组合 `esc/a/b/c/d...` 不可组合,多个key并列表示可选
|
|
430
|
+
- mutate —— `attr/child/char/tree` 可组合
|
|
431
|
+
> 部分修饰符支持参数,可使用冒号传参 —— `throttle:100 / debounce:100`。支持列表如下
|
|
432
|
+
- throttle:wait
|
|
433
|
+
- debounce:wait
|
|
434
|
+
```html
|
|
435
|
+
<!-- 示例 -->
|
|
436
|
+
<div @mutate.child.throttle:100="...">
|
|
437
|
+
<div @click.left.once="...">
|
|
438
|
+
<div @mousedown.stop.prevent="...">
|
|
439
|
+
```
|
|
440
|
+
### 扩展原生事件
|
|
441
|
+
可直接用于DOM元素的扩展事件(非组件事件),支持列表如下
|
|
442
|
+
- resize 元素尺寸变化时触发
|
|
443
|
+
- outside 鼠标点击元素外部时触发,可通过修饰符限制鼠标点击类型`outside.[mousedown/up/click/dblclick]`,默认click
|
|
444
|
+
- mutate 内容变化时触发。基于 Mutation Observer API
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 共享内容
|
|
3
|
+
*/
|
|
4
|
+
export declare const ChangedMap: WeakMap<WeakKey, any>;
|
|
5
|
+
export declare const EXP_KEY: RegExp;
|
|
6
|
+
export declare enum CollectorType {
|
|
7
|
+
CSS = 1,
|
|
8
|
+
COMPUTED = 2
|
|
9
|
+
}
|
|
10
|
+
export declare enum DecoratorKey {
|
|
11
|
+
PROPS = "__deco_props",
|
|
12
|
+
STATES = "__deco_states",
|
|
13
|
+
COMPUTED = "__deco_computed",
|
|
14
|
+
WATCH = "__deco_watch",
|
|
15
|
+
EVENTS = "__deco_events"
|
|
16
|
+
}
|
package/decorator/Decorator.d.ts
CHANGED
|
@@ -10,13 +10,9 @@ export declare enum DecoratorType {
|
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class Decorator {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param target 所在类
|
|
15
|
-
* @param deco 装饰器函数
|
|
16
|
-
* @param fieldName 装饰器应用的字段名/函数名/函数
|
|
17
|
-
* @param args 不定参数
|
|
13
|
+
* 优先级,越大越先执行
|
|
18
14
|
*/
|
|
19
|
-
static
|
|
15
|
+
static get priority(): number;
|
|
20
16
|
/**
|
|
21
17
|
* 装饰器使用范围,超出范围会报错
|
|
22
18
|
*/
|
|
@@ -36,7 +32,7 @@ export declare abstract class Decorator {
|
|
|
36
32
|
* @param setReactive 为实例设置响应属性,注意,仅是设置到了instance.reactiveData中并非this.key。如需实现this访问,可自行定义组件的properties
|
|
37
33
|
* @param args 装饰器函数参数
|
|
38
34
|
*/
|
|
39
|
-
abstract
|
|
35
|
+
abstract beforeMount(component: CompElem, setReactive: (key: string, value: any) => any, ...args: any[]): any;
|
|
40
36
|
abstract mounted(component: CompElem, setReactive: (key: string, value: any) => any, ...args: any[]): any;
|
|
41
37
|
abstract updated(component: CompElem, changed: Record<string, any>): any;
|
|
42
38
|
}
|
package/decorator/index.d.ts
CHANGED
|
@@ -19,9 +19,10 @@ export declare class DecoratorWrapper {
|
|
|
19
19
|
decoratorClass: Constructor<Decorator>;
|
|
20
20
|
instanceMap: WeakMap<CompElem, Decorator>;
|
|
21
21
|
key?: string;
|
|
22
|
+
priority: number;
|
|
22
23
|
constructor(args: any[], metadata: any[], decoratorClass: Constructor<Decorator>);
|
|
23
24
|
create(comp: CompElem): void;
|
|
24
|
-
|
|
25
|
+
beforeMount(comp: CompElem, setReactive: (key: string, value: any) => any): void;
|
|
25
26
|
mounted(comp: CompElem, setReactive: (key: string, value: any) => any): void;
|
|
26
27
|
updated(comp: CompElem, changed: Record<string, any>): void;
|
|
27
28
|
}
|
package/decorators/computed.d.ts
CHANGED
package/decorators/watch.d.ts
CHANGED
|
@@ -15,12 +15,5 @@ export type WatchOptions = {
|
|
|
15
15
|
*/
|
|
16
16
|
once?: boolean;
|
|
17
17
|
};
|
|
18
|
+
export declare function watch(source: string | string[], options?: WatchOptions): (target: any, name: any) => void;
|
|
18
19
|
export type WatchHandler = (newValue: any, oldValue: any, source: string) => any;
|
|
19
|
-
/**
|
|
20
|
-
* 装饰器
|
|
21
|
-
*/
|
|
22
|
-
export type DecoratorWatch = {
|
|
23
|
-
handler: WatchHandler;
|
|
24
|
-
options: WatchOptions;
|
|
25
|
-
};
|
|
26
|
-
export declare const watch: (source: string | string[], options?: WatchOptions | undefined, handler?: WatchHandler | undefined) => (...metadata: any[]) => any;
|
package/directive/Directive.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { Template } from "../render/
|
|
2
|
-
import { DirectiveUpdateTag
|
|
3
|
-
import { EnterPointType } from "./index";
|
|
1
|
+
import { Template } from "../render/Template";
|
|
2
|
+
import { DirectiveUpdateTag } from "../types";
|
|
3
|
+
import { EnterPoint, EnterPointType } from "./index";
|
|
4
4
|
declare const Directive_base: {
|
|
5
5
|
new (...args: any[]): {
|
|
6
6
|
[x: string]: any;
|
|
7
|
-
|
|
8
|
-
__expPos: Record<string, import("../types").ExpPos>;
|
|
9
|
-
__expPosMap: Record<string, Record<string, import("../types").ExpPos> | null>;
|
|
10
|
-
__directives: Record<string, Directive>;
|
|
11
|
-
slotComponent: import("..").CompElem;
|
|
7
|
+
__updatePoints: Array<import("../types").UpdatePoint>;
|
|
12
8
|
renderComponent: import("..").CompElem;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__updateExpPos(tmpl: Template, _expPos: Record<string, import("../types").ExpPos>): void;
|
|
9
|
+
buildView(tmpl: Template): NodeListOf<ChildNode>;
|
|
10
|
+
updateView(tmpl: Template): void;
|
|
16
11
|
};
|
|
17
12
|
} & ObjectConstructor;
|
|
18
13
|
/**
|
|
@@ -29,12 +24,16 @@ export declare abstract class Directive extends Directive_base {
|
|
|
29
24
|
* 更新时调用
|
|
30
25
|
* @param point
|
|
31
26
|
*/
|
|
32
|
-
abstract update(
|
|
27
|
+
abstract update(point: EnterPoint, newArgs: any[], oldArgs: any[]): DirectiveUpdateTag;
|
|
33
28
|
/**
|
|
34
|
-
*
|
|
35
|
-
* 如果返回tmplFn则表示异步渲染
|
|
29
|
+
* 渲染HTML内容,该回调内无法访问DOM
|
|
36
30
|
*/
|
|
37
|
-
abstract render(...args: any): Template |
|
|
31
|
+
abstract render(...args: any): Template | void;
|
|
32
|
+
/**
|
|
33
|
+
* 指令所在DOM创建后渲染前调用,可以访问插入点信息
|
|
34
|
+
* 此时可对DOM进行操作
|
|
35
|
+
*/
|
|
36
|
+
abstract created(point: EnterPoint, ...args: any): void;
|
|
38
37
|
/**
|
|
39
38
|
* 指令渲染参数变量链
|
|
40
39
|
*/
|
package/directive/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CompElem } from "../CompElem";
|
|
2
|
+
import { Template } from "../render/Template";
|
|
2
3
|
import { Directive } from "./Directive";
|
|
3
4
|
/**
|
|
4
5
|
* 属性定义
|
|
@@ -23,8 +24,9 @@ export declare class EnterPoint {
|
|
|
23
24
|
varIndex: number;
|
|
24
25
|
expressionChain: string;
|
|
25
26
|
nodes: Node[];
|
|
26
|
-
constructor(
|
|
27
|
+
constructor(node: Node, attrName: string, type: EnterPointType);
|
|
27
28
|
setVarIndex(varIndex: number): void;
|
|
29
|
+
getNodes(): Node[];
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Delay the actual time of execution of directive
|
|
@@ -40,9 +42,10 @@ export declare class DirectiveWrapper extends Function {
|
|
|
40
42
|
varChain: any[];
|
|
41
43
|
constructor(diClass: typeof Directive, ...args: any[]);
|
|
42
44
|
checkScope(scopeType: string): void;
|
|
43
|
-
render(component: CompElem):
|
|
44
|
-
update(
|
|
45
|
+
render(component: CompElem): void | Template;
|
|
46
|
+
update(point: EnterPoint, newArgs: any[], oldArgs: any[]): void;
|
|
45
47
|
getDirective(): Directive;
|
|
48
|
+
newNodeMap: Record<string, HTMLElement>;
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
51
|
* 返回指令调用函数
|
package/events/event.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { CompElem } from "../CompElem";
|
|
2
|
-
export declare const MODI_PARAM_DIVIDER = ":";
|
|
3
2
|
/*************************************************************
|
|
4
3
|
* 事件修饰符
|
|
5
4
|
* @author holyhigh2
|
|
6
5
|
*
|
|
7
|
-
*
|
|
6
|
+
* 全部通用 debounce/once/throttle 可组合
|
|
7
|
+
* 原生通用 stop/prevent/self 可组合
|
|
8
8
|
* 鼠标 left/right/middle 不可组合
|
|
9
9
|
* 键盘 ctrl/alt/shift/meta 可组合 esc/letters... 不可组合,多个key并列式表示可选
|
|
10
10
|
*
|
|
11
11
|
* 部分修饰符支持参数,使用冒号传参如:throttle:100 / debounce:100
|
|
12
12
|
*************************************************************/
|
|
13
|
-
export
|
|
13
|
+
export type EvHadler = (ev: Event, node: Element) => any;
|
|
14
|
+
export declare function addEvent(fullName: string, cbk: EvHadler, node: Element, component: CompElem): EvHadler;
|
package/events/extends.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { EvHadler } from "./event";
|
|
1
2
|
export declare function isExtEvent(evName: string): boolean;
|
|
2
|
-
export declare function addExtEvent(evName: string, node: Element, cbk:
|
|
3
|
+
export declare function addExtEvent(evName: string, node: Element, cbk: EvHadler, parts: string[]): void;
|
package/helpers.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Css 辅助类
|
|
3
|
+
*/
|
|
4
|
+
export declare class CssHelper {
|
|
5
|
+
/**
|
|
6
|
+
* 用于转换style对象为标准style字符串,会自动转换对象key为短横线格式
|
|
7
|
+
* @param styles 样式对象
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
static getCssText(styles: Record<string, string> | string): string;
|
|
11
|
+
/**
|
|
12
|
+
* 设置样式
|
|
13
|
+
* @param styles 样式字符串或样式对象
|
|
14
|
+
* @param node HTML元素
|
|
15
|
+
* @returns 每个样式的旧值map
|
|
16
|
+
*/
|
|
17
|
+
static setStyle(styles: Record<string, string> | string, node: HTMLElement): Record<string, string>;
|
|
18
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Template } from './render/Template';
|
|
2
|
+
import { buildHTML, createRef, html, RefObject } from "./render/render";
|
|
2
3
|
export * from "./decorator/Decorator";
|
|
3
4
|
export * from "./decorator/index";
|
|
4
5
|
export * from "./decorators/computed";
|
|
@@ -24,3 +25,4 @@ export * from "./directives/When";
|
|
|
24
25
|
export { buildHTML, createRef, html, RefObject, Template };
|
|
25
26
|
export * from './CompElem';
|
|
26
27
|
export * from './types';
|
|
28
|
+
export * from './helpers';
|