@cclr/front 0.1.17 → 0.1.19

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 (2) hide show
  1. package/lib/type/index.d.ts +141 -27
  2. package/package.json +4 -4
@@ -29,60 +29,174 @@ declare const delDom: (dom: Element) => void;
29
29
  */
30
30
  declare const getEmptyImage: () => HTMLImageElement;
31
31
 
32
- type CommonDOMEventTypes = 'click' | 'dblclick' | 'mousedown' | 'mouseup' | 'mousemove' | 'mouseover' | 'mouseout' | 'keydown' | 'keyup' | 'keypress' | 'touchstart' | 'touchend' | 'touchmove' | 'touchcancel' | 'dragstart' | 'drag' | 'dragend' | 'dragenter' | 'dragover' | 'dragleave' | 'drop' | 'scroll' | 'scroll' | 'scroll' | 'wheel' | 'resize';
32
+ type CommonDOMEventTypes = 'click' | 'dblclick' | 'mousedown' | 'mouseup' | 'mousemove' | 'mouseover' | 'mouseout' | 'keydown' | 'keyup' | 'keypress' | 'touchstart' | 'touchend' | 'touchmove' | 'touchcancel' | 'dragstart' | 'drag' | 'dragend' | 'dragenter' | 'dragover' | 'dragleave' | 'drop' | 'scroll' | 'wheel' | 'resize' | 'mouseenter' | 'mouseleave' | 'contextmenu' | 'focus' | 'blur' | 'input' | 'change' | 'submit' | 'reset' | 'focusin' | 'focusout' | 'select' | 'pointerdown' | 'pointerup' | 'pointermove' | 'pointerover' | 'pointerout' | 'pointerenter' | 'pointerleave' | 'pointercancel' | 'gotpointercapture' | 'lostpointercapture';
33
33
  type EventListenerOptions = boolean | AddEventListenerOptions;
34
- type TEventMap = Partial<{
35
- click: (e: MouseEvent) => void;
36
- dblclick: (e: MouseEvent) => void;
37
- mousedown: (e: MouseEvent) => void;
38
- mouseup: (e: MouseEvent) => void;
39
- mousemove: (e: MouseEvent) => void;
40
- mouseover: (e: MouseEvent) => void;
41
- mouseout: (e: MouseEvent) => void;
42
- keydown: (e: KeyboardEvent) => void;
43
- keyup: (e: KeyboardEvent) => void;
44
- keypress: (e: KeyboardEvent) => void;
45
- touchstart: (e: TouchEvent) => void;
46
- touchend: (e: TouchEvent) => void;
47
- touchmove: (e: TouchEvent) => void;
48
- touchcancel: (e: TouchEvent) => void;
34
+ type TEventMap<T = HTMLElement> = Partial<{
35
+ click: (e: MouseEvent & {
36
+ target: T;
37
+ }) => void;
38
+ dblclick: (e: MouseEvent & {
39
+ target: T;
40
+ }) => void;
41
+ mousedown: (e: MouseEvent & {
42
+ target: T;
43
+ }) => void;
44
+ mouseup: (e: MouseEvent & {
45
+ target: T;
46
+ }) => void;
47
+ mousemove: (e: MouseEvent & {
48
+ target: T;
49
+ }) => void;
50
+ mouseover: (e: MouseEvent & {
51
+ target: T;
52
+ }) => void;
53
+ mouseout: (e: MouseEvent & {
54
+ target: T;
55
+ }) => void;
56
+ mouseenter: (e: MouseEvent & {
57
+ target: T;
58
+ }) => void;
59
+ mouseleave: (e: MouseEvent & {
60
+ target: T;
61
+ }) => void;
62
+ keydown: (e: KeyboardEvent & {
63
+ target: T;
64
+ }) => void;
65
+ keyup: (e: KeyboardEvent & {
66
+ target: T;
67
+ }) => void;
68
+ keypress: (e: KeyboardEvent & {
69
+ target: T;
70
+ }) => void;
71
+ touchstart: (e: TouchEvent & {
72
+ target: T;
73
+ }) => void;
74
+ touchend: (e: TouchEvent & {
75
+ target: T;
76
+ }) => void;
77
+ touchmove: (e: TouchEvent & {
78
+ target: T;
79
+ }) => void;
80
+ touchcancel: (e: TouchEvent & {
81
+ target: T;
82
+ }) => void;
49
83
  /**
50
84
  * 拖动元素开始触发
51
85
  * dataTransfer.setData()方法设置数据类型和拖动的数据
52
86
  * e.dataTransfer.setData("Text", event.target.id);
53
87
  */
54
- dragstart: (e: DragEvent) => void;
88
+ dragstart: (e: DragEvent & {
89
+ target: T;
90
+ }) => void;
55
91
  /**
56
92
  * 拖动元素时触发
57
93
  */
58
- drag: (e: DragEvent) => void;
94
+ drag: (e: DragEvent & {
95
+ target: T;
96
+ }) => void;
59
97
  /**
60
98
  * 拖动元素结束触发
61
99
  */
62
- dragend: (e: DragEvent) => void;
100
+ dragend: (e: DragEvent & {
101
+ target: T;
102
+ }) => void;
63
103
  /**
64
104
  * 接收元素,进入时触发
65
105
  */
66
- dragenter: (e: DragEvent) => void;
106
+ dragenter: (e: DragEvent & {
107
+ target: T;
108
+ }) => void;
67
109
  /**
68
110
  * 接收元素,内部移动时触发
69
111
  * 如果使用drop,必须防止元素的默认处理
70
112
  * event.preventDefault();
71
113
  */
72
- dragover: (e: DragEvent) => void;
114
+ dragover: (e: DragEvent & {
115
+ target: T;
116
+ }) => void;
73
117
  /**
74
118
  * 接收元素,离开时触发
75
119
  */
76
- dragleave: (e: DragEvent) => void;
120
+ dragleave: (e: DragEvent & {
121
+ target: T;
122
+ }) => void;
77
123
  /**
78
124
  * 接收元素,拖动完成后触发
79
125
  * dataTransfer.getData()方法获得拖放数据
80
126
  * e.dataTransfer.getData("Text");
81
127
  */
82
- drop: (e: DragEvent) => void;
83
- scroll: (e: Event) => void;
84
- wheel: (e: WheelEvent) => void;
85
- resize: (e: Event) => void;
128
+ drop: (e: DragEvent & {
129
+ target: T;
130
+ }) => void;
131
+ scroll: (e: Event & {
132
+ target: T;
133
+ }) => void;
134
+ wheel: (e: WheelEvent & {
135
+ target: T;
136
+ }) => void;
137
+ resize: (e: Event & {
138
+ target: T;
139
+ }) => void;
140
+ contextmenu: (e: MouseEvent & {
141
+ target: T;
142
+ }) => void;
143
+ focus: (e: FocusEvent & {
144
+ target: T;
145
+ }) => void;
146
+ blur: (e: FocusEvent & {
147
+ target: T;
148
+ }) => void;
149
+ input: (e: InputEvent & {
150
+ target: T;
151
+ }) => void;
152
+ change: (e: Event & {
153
+ target: T;
154
+ }) => void;
155
+ submit: (e: Event & {
156
+ target: T;
157
+ }) => void;
158
+ reset: (e: Event & {
159
+ target: T;
160
+ }) => void;
161
+ focusin: (e: FocusEvent & {
162
+ target: T;
163
+ }) => void;
164
+ focusout: (e: FocusEvent & {
165
+ target: T;
166
+ }) => void;
167
+ select: (e: Event & {
168
+ target: T;
169
+ }) => void;
170
+ pointerdown: (e: PointerEvent & {
171
+ target: T;
172
+ }) => void;
173
+ pointerup: (e: PointerEvent & {
174
+ target: T;
175
+ }) => void;
176
+ pointermove: (e: PointerEvent & {
177
+ target: T;
178
+ }) => void;
179
+ pointerover: (e: PointerEvent & {
180
+ target: T;
181
+ }) => void;
182
+ pointerout: (e: PointerEvent & {
183
+ target: T;
184
+ }) => void;
185
+ pointerenter: (e: PointerEvent & {
186
+ target: T;
187
+ }) => void;
188
+ pointerleave: (e: PointerEvent & {
189
+ target: T;
190
+ }) => void;
191
+ pointercancel: (e: PointerEvent & {
192
+ target: T;
193
+ }) => void;
194
+ gotpointercapture: (e: PointerEvent & {
195
+ target: T;
196
+ }) => void;
197
+ lostpointercapture: (e: PointerEvent & {
198
+ target: T;
199
+ }) => void;
86
200
  }>;
87
201
 
88
202
  /**
@@ -103,7 +217,7 @@ declare const addEventListener: <T extends HTMLElement = HTMLElement>(dom: T, ty
103
217
  * @param options 事件监听选项
104
218
  * @returns 移除事件监听的函数
105
219
  */
106
- declare const addEventListenerMultiple: <T extends HTMLElement = HTMLElement>(dom: T, listenerMap: TEventMap, options?: EventListenerOptions) => () => void;
220
+ declare const addEventListenerMultiple: <T extends HTMLElement = HTMLElement>(dom: T, listenerMap: TEventMap<T>, options?: EventListenerOptions) => () => void;
107
221
 
108
222
  /**
109
223
  * 添加样式表
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cclr/front",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "前端开发使用工具",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
@@ -27,9 +27,9 @@
27
27
  "g:test": "vitest run",
28
28
  "g:build": "ccf build"
29
29
  },
30
- "gitHead": "5463a4bf24b98f18f5e349347c9b048f2670c990",
30
+ "gitHead": "8f3b61a1d4597514d1fe34d639be849f717bd2c4",
31
31
  "dependencies": {
32
- "@cclr/lang": "0.1.17",
33
- "@cclr/utils": "0.1.17"
32
+ "@cclr/lang": "0.1.19",
33
+ "@cclr/utils": "0.1.19"
34
34
  }
35
35
  }