@whitesev/pops 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/dist/index.amd.js +4651 -0
- package/dist/index.amd.js.map +1 -0
- package/dist/index.cjs.js +4649 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm.js +4647 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.iife.js +4652 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.system.js +4654 -0
- package/dist/index.system.js.map +1 -0
- package/dist/index.umd.js +4655 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/src/Config.d.ts +1 -0
- package/dist/types/src/Core.d.ts +18 -0
- package/dist/types/src/Pops.d.ts +171 -0
- package/dist/types/src/components/alert/index.d.ts +4 -0
- package/dist/types/src/components/confirm/index.d.ts +4 -0
- package/dist/types/src/components/drawer/index.d.ts +2 -0
- package/dist/types/src/components/folder/index.d.ts +2 -0
- package/dist/types/src/components/iframe/index.d.ts +2 -0
- package/dist/types/src/components/loading/index.d.ts +2 -0
- package/dist/types/src/components/panel/index.d.ts +2 -0
- package/dist/types/src/components/prompt/index.d.ts +2 -0
- package/dist/types/src/components/rightClickMenu/index.d.ts +2 -0
- package/dist/types/src/components/tooltip/index.d.ts +2 -0
- package/dist/types/src/handler/PopsElementHandler.d.ts +54 -0
- package/dist/types/src/handler/PopsHandler.d.ts +210 -0
- package/dist/types/src/utils/AnyTouch.d.ts +17 -0
- package/dist/types/src/utils/PopsDOMUtils.d.ts +278 -0
- package/dist/types/src/utils/PopsDOMUtilsEvent.d.ts +332 -0
- package/dist/types/src/utils/PopsMathUtils.d.ts +25 -0
- package/dist/types/src/utils/PopsUIUtils.d.ts +85 -0
- package/dist/types/src/utils/PopsUtils.d.ts +123 -0
- package/package.json +42 -0
- package/src/types/PopsDOMUtilsEventType.d.ts +248 -0
- package/src/types/animation.d.ts +19 -0
- package/src/types/button.d.ts +216 -0
- package/src/types/components.d.ts +197 -0
- package/src/types/event.d.ts +60 -0
- package/src/types/global.d.ts +11 -0
- package/src/types/icon.d.ts +30 -0
- package/src/types/layer.d.ts +20 -0
- package/src/types/main.d.ts +89 -0
- package/src/types/mask.d.ts +35 -0
- package/src/types/position.d.ts +60 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
declare class PopsDOMUtilsEvent {
|
|
2
|
+
/**
|
|
3
|
+
* 绑定事件
|
|
4
|
+
* @param element 需要绑定的元素|元素数组|window
|
|
5
|
+
* @param eventType 需要监听的事件
|
|
6
|
+
* @param callback 绑定事件触发的回调函数
|
|
7
|
+
* @param option
|
|
8
|
+
* + capture 表示事件是否在捕获阶段触发。默认为false,即在冒泡阶段触发
|
|
9
|
+
* + once 表示事件是否只触发一次。默认为false
|
|
10
|
+
* + passive 表示事件监听器是否不会调用preventDefault()。默认为false
|
|
11
|
+
* @example
|
|
12
|
+
* // 监听元素a.xx的click事件
|
|
13
|
+
* DOMUtils.on(document.querySelector("a.xx"),"click",(event)=>{
|
|
14
|
+
* console.log("事件触发",event)
|
|
15
|
+
* })
|
|
16
|
+
* DOMUtils.on("a.xx","click",(event)=>{
|
|
17
|
+
* console.log("事件触发",event)
|
|
18
|
+
* })
|
|
19
|
+
*/
|
|
20
|
+
on(element: PopsDOMUtilsElementEventType, eventType: string | string[], callback: (event: Event) => void, option?: boolean | AddEventListenerOptions): void;
|
|
21
|
+
on<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], callback: (event: PopsDOMUtils_Event[T]) => void, option?: boolean | AddEventListenerOptions): void;
|
|
22
|
+
/**
|
|
23
|
+
* 绑定事件
|
|
24
|
+
* @param element 需要绑定的元素|元素数组|window
|
|
25
|
+
* @param eventType 需要监听的事件
|
|
26
|
+
* @param callback 绑定事件触发的回调函数
|
|
27
|
+
* @param option
|
|
28
|
+
* + capture 表示事件是否在捕获阶段触发。默认为false,即在冒泡阶段触发
|
|
29
|
+
* + once 表示事件是否只触发一次。默认为false
|
|
30
|
+
* + passive 表示事件监听器是否不会调用preventDefault()。默认为false
|
|
31
|
+
* @example
|
|
32
|
+
* // 监听元素a.xx的click事件
|
|
33
|
+
* DOMUtils.on(document.querySelector("a.xx"),"click",(event)=>{
|
|
34
|
+
* console.log("事件触发",event)
|
|
35
|
+
* })
|
|
36
|
+
* DOMUtils.on("a.xx","click",(event)=>{
|
|
37
|
+
* console.log("事件触发",event)
|
|
38
|
+
* })
|
|
39
|
+
*/
|
|
40
|
+
on<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string, callback: (event: T) => void, option?: boolean | AddEventListenerOptions): void;
|
|
41
|
+
/**
|
|
42
|
+
* 绑定事件
|
|
43
|
+
* @param element 需要绑定的元素|元素数组|window
|
|
44
|
+
* @param eventType 需要监听的事件
|
|
45
|
+
* @param selector 子元素选择器
|
|
46
|
+
* @param callback 绑定事件触发的回调函数
|
|
47
|
+
* @param option
|
|
48
|
+
* + capture 表示事件是否在捕获阶段触发。默认为false,即在冒泡阶段触发
|
|
49
|
+
* + once 表示事件是否只触发一次。默认为false
|
|
50
|
+
* + passive 表示事件监听器是否不会调用preventDefault()。默认为false
|
|
51
|
+
* @example
|
|
52
|
+
* // 监听元素a.xx的click、tap、hover事件
|
|
53
|
+
* DOMUtils.on(document.querySelector("a.xx"),"click tap hover",(event)=>{
|
|
54
|
+
* console.log("事件触发",event)
|
|
55
|
+
* })
|
|
56
|
+
* DOMUtils.on("a.xx",["click","tap","hover"],(event)=>{
|
|
57
|
+
* console.log("事件触发",event)
|
|
58
|
+
* })
|
|
59
|
+
* @example
|
|
60
|
+
* // 监听全局document下的子元素a.xx的click事件
|
|
61
|
+
* DOMUtils.on(document,"click tap hover","a.xx",(event)=>{
|
|
62
|
+
* console.log("事件触发",event)
|
|
63
|
+
* })
|
|
64
|
+
*/
|
|
65
|
+
on<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], selector: string | undefined | null, callback: (event: PopsDOMUtils_Event[T]) => void, option?: boolean | AddEventListenerOptions): void;
|
|
66
|
+
/**
|
|
67
|
+
* 绑定事件
|
|
68
|
+
* @param element 需要绑定的元素|元素数组|window
|
|
69
|
+
* @param eventType 需要监听的事件
|
|
70
|
+
* @param selector 子元素选择器
|
|
71
|
+
* @param callback 绑定事件触发的回调函数
|
|
72
|
+
* @param option
|
|
73
|
+
* + capture 表示事件是否在捕获阶段触发。默认为false,即在冒泡阶段触发
|
|
74
|
+
* + once 表示事件是否只触发一次。默认为false
|
|
75
|
+
* + passive 表示事件监听器是否不会调用preventDefault()。默认为false
|
|
76
|
+
* @example
|
|
77
|
+
* // 监听元素a.xx的click、tap、hover事件
|
|
78
|
+
* DOMUtils.on(document.querySelector("a.xx"),"click tap hover",(event)=>{
|
|
79
|
+
* console.log("事件触发",event)
|
|
80
|
+
* })
|
|
81
|
+
* DOMUtils.on("a.xx",["click","tap","hover"],(event)=>{
|
|
82
|
+
* console.log("事件触发",event)
|
|
83
|
+
* })
|
|
84
|
+
* @example
|
|
85
|
+
* // 监听全局document下的子元素a.xx的click事件
|
|
86
|
+
* DOMUtils.on(document,"click tap hover","a.xx",(event)=>{
|
|
87
|
+
* console.log("事件触发",event)
|
|
88
|
+
* })
|
|
89
|
+
*/
|
|
90
|
+
on<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string, selector: string | undefined | null, callback: (event: T) => void, option?: boolean | AddEventListenerOptions): void;
|
|
91
|
+
/**
|
|
92
|
+
* 取消绑定事件
|
|
93
|
+
* @param element 需要取消绑定的元素|元素数组
|
|
94
|
+
* @param eventType 需要取消监听的事件
|
|
95
|
+
* @param callback 通过DOMUtils.on绑定的事件函数
|
|
96
|
+
* @param option
|
|
97
|
+
* + capture 如果在添加事件监听器时指定了useCapture为true,则在移除事件监听器时也必须指定为true
|
|
98
|
+
* @param filter (可选)过滤函数,对元素属性上的事件进行过滤出想要删除的事件
|
|
99
|
+
* @example
|
|
100
|
+
* // 取消监听元素a.xx的click事件
|
|
101
|
+
* DOMUtils.off(document.querySelector("a.xx"),"click")
|
|
102
|
+
* DOMUtils.off("a.xx","click")
|
|
103
|
+
*/
|
|
104
|
+
off(element: PopsDOMUtilsElementEventType, eventType: string | string[], callback?: (event: Event) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
105
|
+
off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], callback?: (event: PopsDOMUtils_Event[T]) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
106
|
+
/**
|
|
107
|
+
* 取消绑定事件
|
|
108
|
+
* @param element 需要取消绑定的元素|元素数组
|
|
109
|
+
* @param eventType 需要取消监听的事件
|
|
110
|
+
* @param callback 通过DOMUtils.on绑定的事件函数
|
|
111
|
+
* @param option
|
|
112
|
+
* + capture 如果在添加事件监听器时指定了useCapture为true,则在移除事件监听器时也必须指定为true
|
|
113
|
+
* @param filter (可选)过滤函数,对元素属性上的事件进行过滤出想要删除的事件
|
|
114
|
+
* @example
|
|
115
|
+
* // 取消监听元素a.xx的click事件
|
|
116
|
+
* DOMUtils.off(document.querySelector("a.xx"),"click")
|
|
117
|
+
* DOMUtils.off("a.xx","click")
|
|
118
|
+
*/
|
|
119
|
+
off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string, callback?: (event: T) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
120
|
+
/**
|
|
121
|
+
* 取消绑定事件
|
|
122
|
+
* @param element 需要取消绑定的元素|元素数组
|
|
123
|
+
* @param eventType 需要取消监听的事件
|
|
124
|
+
* @param selector 子元素选择器
|
|
125
|
+
* @param callback 通过DOMUtils.on绑定的事件函数
|
|
126
|
+
* @param option
|
|
127
|
+
* + capture 如果在添加事件监听器时指定了useCapture为true,则在移除事件监听器时也必须指定为true
|
|
128
|
+
* @param filter (可选)过滤函数,对元素属性上的事件进行过滤出想要删除的事件
|
|
129
|
+
* @example
|
|
130
|
+
* // 取消监听元素a.xx的click、tap、hover事件
|
|
131
|
+
* DOMUtils.off(document.querySelector("a.xx"),"click tap hover")
|
|
132
|
+
* DOMUtils.off("a.xx",["click","tap","hover"])
|
|
133
|
+
*/
|
|
134
|
+
off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], selector?: string | undefined, callback?: (event: PopsDOMUtils_Event[T]) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
135
|
+
/**
|
|
136
|
+
* 取消绑定事件
|
|
137
|
+
* @param element 需要取消绑定的元素|元素数组
|
|
138
|
+
* @param eventType 需要取消监听的事件
|
|
139
|
+
* @param selector 子元素选择器
|
|
140
|
+
* @param callback 通过DOMUtils.on绑定的事件函数
|
|
141
|
+
* @param option
|
|
142
|
+
* + capture 如果在添加事件监听器时指定了useCapture为true,则在移除事件监听器时也必须指定为true
|
|
143
|
+
* @param filter (可选)过滤函数,对元素属性上的事件进行过滤出想要删除的事件
|
|
144
|
+
* @example
|
|
145
|
+
* // 取消监听元素a.xx的click、tap、hover事件
|
|
146
|
+
* DOMUtils.off(document.querySelector("a.xx"),"click tap hover")
|
|
147
|
+
* DOMUtils.off("a.xx",["click","tap","hover"])
|
|
148
|
+
*/
|
|
149
|
+
off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], selector?: string | undefined, callback?: (event: T) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
150
|
+
/**
|
|
151
|
+
* 取消绑定所有的事件
|
|
152
|
+
* @param element 需要取消绑定的元素|元素数组
|
|
153
|
+
* @param eventType (可选)需要取消监听的事件
|
|
154
|
+
*/
|
|
155
|
+
offAll(element: PopsDOMUtilsElementEventType, eventType?: string): void;
|
|
156
|
+
/**
|
|
157
|
+
* 取消绑定所有的事件
|
|
158
|
+
* @param element 需要取消绑定的元素|元素数组
|
|
159
|
+
* @param eventType (可选)需要取消监听的事件
|
|
160
|
+
*/
|
|
161
|
+
offAll(element: PopsDOMUtilsElementEventType, eventType?: PopsDOMUtils_EventType | PopsDOMUtils_EventType[]): void;
|
|
162
|
+
/**
|
|
163
|
+
* 等待文档加载完成后执行指定的函数
|
|
164
|
+
* @param callback 需要执行的函数
|
|
165
|
+
* @example
|
|
166
|
+
* DOMUtils.ready(function(){
|
|
167
|
+
* console.log("文档加载完毕")
|
|
168
|
+
* })
|
|
169
|
+
*/
|
|
170
|
+
ready<T extends Function>(callback: T): void;
|
|
171
|
+
/**
|
|
172
|
+
* 主动触发事件
|
|
173
|
+
* @param element 需要触发的元素|元素数组|window
|
|
174
|
+
* @param eventType 需要触发的事件
|
|
175
|
+
* @param details 赋予触发的Event的额外属性,如果是Event类型,那么将自动代替默认new的Event对象
|
|
176
|
+
* @param useDispatchToTriggerEvent 是否使用dispatchEvent来触发事件,默认true
|
|
177
|
+
* @example
|
|
178
|
+
* // 触发元素a.xx的click事件
|
|
179
|
+
* DOMUtils.trigger(document.querySelector("a.xx"),"click")
|
|
180
|
+
* DOMUtils.trigger("a.xx","click")
|
|
181
|
+
* // 触发元素a.xx的click、tap、hover事件
|
|
182
|
+
* DOMUtils.trigger(document.querySelector("a.xx"),"click tap hover")
|
|
183
|
+
* DOMUtils.trigger("a.xx",["click","tap","hover"])
|
|
184
|
+
*/
|
|
185
|
+
trigger(element: HTMLElement | string | NodeList | any[] | Window | Document, eventType: string | string[], details?: object, useDispatchToTriggerEvent?: boolean): void;
|
|
186
|
+
/**
|
|
187
|
+
* 主动触发事件
|
|
188
|
+
* @param element 需要触发的元素|元素数组|window
|
|
189
|
+
* @param eventType 需要触发的事件
|
|
190
|
+
* @param details 赋予触发的Event的额外属性,如果是Event类型,那么将自动代替默认new的Event对象
|
|
191
|
+
* @param useDispatchToTriggerEvent 是否使用dispatchEvent来触发事件,默认true
|
|
192
|
+
* @example
|
|
193
|
+
* // 触发元素a.xx的click事件
|
|
194
|
+
* DOMUtils.trigger(document.querySelector("a.xx"),"click")
|
|
195
|
+
* DOMUtils.trigger("a.xx","click")
|
|
196
|
+
* // 触发元素a.xx的click、tap、hover事件
|
|
197
|
+
* DOMUtils.trigger(document.querySelector("a.xx"),"click tap hover")
|
|
198
|
+
* DOMUtils.trigger("a.xx",["click","tap","hover"])
|
|
199
|
+
*/
|
|
200
|
+
trigger(element: HTMLElement | string | NodeList | any[] | Window | Document, eventType: PopsDOMUtils_EventType | PopsDOMUtils_EventType[], details?: object, useDispatchToTriggerEvent?: boolean): void;
|
|
201
|
+
/**
|
|
202
|
+
* 绑定或触发元素的click事件
|
|
203
|
+
* @param element 目标元素
|
|
204
|
+
* @param handler (可选)事件处理函数
|
|
205
|
+
* @param details (可选)赋予触发的Event的额外属性
|
|
206
|
+
* @param useDispatchToTriggerEvent (可选)是否使用dispatchEvent来触发事件,默认true
|
|
207
|
+
* @example
|
|
208
|
+
* // 触发元素a.xx的click事件
|
|
209
|
+
* DOMUtils.click(document.querySelector("a.xx"))
|
|
210
|
+
* DOMUtils.click("a.xx")
|
|
211
|
+
* DOMUtils.click("a.xx",function(){
|
|
212
|
+
* console.log("触发click事件成功")
|
|
213
|
+
* })
|
|
214
|
+
* */
|
|
215
|
+
click(element: HTMLElement | string | Window, handler?: (event: PopsDOMUtils_Event["click"]) => void, details?: any, useDispatchToTriggerEvent?: boolean): void;
|
|
216
|
+
/**
|
|
217
|
+
* 绑定或触发元素的blur事件
|
|
218
|
+
* @param element 目标元素
|
|
219
|
+
* @param handler (可选)事件处理函数
|
|
220
|
+
* @param details (可选)赋予触发的Event的额外属性
|
|
221
|
+
* @param useDispatchToTriggerEvent (可选)是否使用dispatchEvent来触发事件,默认true
|
|
222
|
+
* @example
|
|
223
|
+
* // 触发元素a.xx的blur事件
|
|
224
|
+
* DOMUtils.blur(document.querySelector("a.xx"))
|
|
225
|
+
* DOMUtils.blur("a.xx")
|
|
226
|
+
* DOMUtils.blur("a.xx",function(){
|
|
227
|
+
* console.log("触发blur事件成功")
|
|
228
|
+
* })
|
|
229
|
+
* */
|
|
230
|
+
blur(element: HTMLElement | string | Window, handler?: (event: PopsDOMUtils_Event["blur"]) => void, details?: object, useDispatchToTriggerEvent?: boolean): void;
|
|
231
|
+
/**
|
|
232
|
+
* 绑定或触发元素的focus事件
|
|
233
|
+
* @param element 目标元素
|
|
234
|
+
* @param handler (可选)事件处理函数
|
|
235
|
+
* @param details (可选)赋予触发的Event的额外属性
|
|
236
|
+
* @param useDispatchToTriggerEvent (可选)是否使用dispatchEvent来触发事件,默认true
|
|
237
|
+
* @example
|
|
238
|
+
* // 触发元素a.xx的focus事件
|
|
239
|
+
* DOMUtils.focus(document.querySelector("a.xx"))
|
|
240
|
+
* DOMUtils.focus("a.xx")
|
|
241
|
+
* DOMUtils.focus("a.xx",function(){
|
|
242
|
+
* console.log("触发focus事件成功")
|
|
243
|
+
* })
|
|
244
|
+
* */
|
|
245
|
+
focus(element: HTMLElement | string | Window, handler?: (event: PopsDOMUtils_Event["focus"]) => void, details?: object, useDispatchToTriggerEvent?: boolean): void;
|
|
246
|
+
/**
|
|
247
|
+
* 当鼠标移入或移出元素时触发事件
|
|
248
|
+
* @param element 当前元素
|
|
249
|
+
* @param handler 事件处理函数
|
|
250
|
+
* @param option 配置
|
|
251
|
+
* @example
|
|
252
|
+
* // 监听a.xx元素的移入或移出
|
|
253
|
+
* DOMUtils.hover(document.querySelector("a.xx"),()=>{
|
|
254
|
+
* console.log("移入/移除");
|
|
255
|
+
* })
|
|
256
|
+
* DOMUtils.hover("a.xx",()=>{
|
|
257
|
+
* console.log("移入/移除");
|
|
258
|
+
* })
|
|
259
|
+
*/
|
|
260
|
+
hover(element: HTMLElement | string, handler: (event: PopsDOMUtils_Event["hover"]) => void, option?: boolean | AddEventListenerOptions): void;
|
|
261
|
+
/**
|
|
262
|
+
* 当按键松开时触发事件
|
|
263
|
+
* keydown - > keypress - > keyup
|
|
264
|
+
* @param target 当前元素
|
|
265
|
+
* @param handler 事件处理函数
|
|
266
|
+
* @param option 配置
|
|
267
|
+
* @example
|
|
268
|
+
* // 监听a.xx元素的按键松开
|
|
269
|
+
* DOMUtils.keyup(document.querySelector("a.xx"),()=>{
|
|
270
|
+
* console.log("按键松开");
|
|
271
|
+
* })
|
|
272
|
+
* DOMUtils.keyup("a.xx",()=>{
|
|
273
|
+
* console.log("按键松开");
|
|
274
|
+
* })
|
|
275
|
+
*/
|
|
276
|
+
keyup(target: HTMLElement | string | Window | typeof globalThis, handler: (event: PopsDOMUtils_Event["keyup"]) => void, option?: boolean | AddEventListenerOptions): void;
|
|
277
|
+
/**
|
|
278
|
+
* 当按键按下时触发事件
|
|
279
|
+
* keydown - > keypress - > keyup
|
|
280
|
+
* @param target 目标
|
|
281
|
+
* @param handler 事件处理函数
|
|
282
|
+
* @param option 配置
|
|
283
|
+
* @example
|
|
284
|
+
* // 监听a.xx元素的按键按下
|
|
285
|
+
* DOMUtils.keydown(document.querySelector("a.xx"),()=>{
|
|
286
|
+
* console.log("按键按下");
|
|
287
|
+
* })
|
|
288
|
+
* DOMUtils.keydown("a.xx",()=>{
|
|
289
|
+
* console.log("按键按下");
|
|
290
|
+
* })
|
|
291
|
+
*/
|
|
292
|
+
keydown(target: HTMLElement | Window | typeof globalThis | string, handler: (event: PopsDOMUtils_Event["keydown"]) => void, option?: boolean | AddEventListenerOptions): void;
|
|
293
|
+
/**
|
|
294
|
+
* 当按键按下时触发事件
|
|
295
|
+
* keydown - > keypress - > keyup
|
|
296
|
+
* @param target 目标
|
|
297
|
+
* @param handler 事件处理函数
|
|
298
|
+
* @param option 配置
|
|
299
|
+
* @example
|
|
300
|
+
* // 监听a.xx元素的按键按下
|
|
301
|
+
* DOMUtils.keypress(document.querySelector("a.xx"),()=>{
|
|
302
|
+
* console.log("按键按下");
|
|
303
|
+
* })
|
|
304
|
+
* DOMUtils.keypress("a.xx",()=>{
|
|
305
|
+
* console.log("按键按下");
|
|
306
|
+
* })
|
|
307
|
+
*/
|
|
308
|
+
keypress(target: HTMLElement | Window | typeof globalThis | string, handler: (event: PopsDOMUtils_Event["keypress"]) => void, option?: boolean | AddEventListenerOptions): void;
|
|
309
|
+
/**
|
|
310
|
+
* 阻止事件传递
|
|
311
|
+
* @param element 要进行处理的元素
|
|
312
|
+
* @param eventNameList (可选)要阻止的事件名|列表
|
|
313
|
+
* @param capture (可选)是否捕获,默认false
|
|
314
|
+
* @example
|
|
315
|
+
* Utils.preventEvent(document.querySelector("a"),"click")
|
|
316
|
+
* @example
|
|
317
|
+
* Utils.preventEvent(event);
|
|
318
|
+
*/
|
|
319
|
+
preventEvent(event: Event): boolean;
|
|
320
|
+
/**
|
|
321
|
+
* 阻止事件传递
|
|
322
|
+
* @param element 要进行处理的元素
|
|
323
|
+
* @param eventNameList (可选)要阻止的事件名|列表
|
|
324
|
+
* @param capture (可选)是否捕获,默认false
|
|
325
|
+
* @example
|
|
326
|
+
* Utils.preventEvent(document.querySelector("a"),"click")
|
|
327
|
+
* @example
|
|
328
|
+
* Utils.preventEvent(event);
|
|
329
|
+
*/
|
|
330
|
+
preventEvent(element: HTMLElement, eventNameList?: string | string[], capture?: boolean): boolean;
|
|
331
|
+
}
|
|
332
|
+
export { PopsDOMUtilsEvent };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const PopsMathFloatUtils: {
|
|
2
|
+
/**
|
|
3
|
+
* 判断数字是否是浮点数
|
|
4
|
+
* @param num
|
|
5
|
+
*/
|
|
6
|
+
isFloat(num: number): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 浮点数加法
|
|
9
|
+
* @param number1
|
|
10
|
+
* @param number2
|
|
11
|
+
*/
|
|
12
|
+
add(number1: number, number2: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* 减法
|
|
15
|
+
* @param number1
|
|
16
|
+
* @param number2
|
|
17
|
+
*/
|
|
18
|
+
sub(number1: number, number2: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* 除法
|
|
21
|
+
* @param number1
|
|
22
|
+
* @param number2
|
|
23
|
+
*/
|
|
24
|
+
division(number1: number, number2: number): number;
|
|
25
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { PopsAlertDetails } from "../components/alert/types";
|
|
2
|
+
import type { PopsConfirmDetails } from "../components/confirm/types";
|
|
3
|
+
import type { PopsDrawerDetails } from "../components/drawer/types";
|
|
4
|
+
import type { PopsFolderDetails } from "../components/folder/types";
|
|
5
|
+
import type { PopsIframeDetails } from "../components/iframe/types";
|
|
6
|
+
import type { PopsLoadingDetails } from "../components/loading/types";
|
|
7
|
+
import type { PopsPanelDetails } from "../components/panel/types";
|
|
8
|
+
import type { PopsPromptDetails } from "../components/prompt/types";
|
|
9
|
+
import type { PopsLayerMode } from "../types/main";
|
|
10
|
+
export declare const PopsUIUtils: {
|
|
11
|
+
/**
|
|
12
|
+
* 获取所有弹窗中的最大的z-index
|
|
13
|
+
* @param defaultValue
|
|
14
|
+
*/
|
|
15
|
+
getPopsMaxZIndex(defaultValue: number): {
|
|
16
|
+
zIndex: number;
|
|
17
|
+
animElement: HTMLDivElement;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 获取CSS Rule
|
|
21
|
+
* @param sheet
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
getKeyFrames(sheet: CSSStyleSheet): {};
|
|
25
|
+
/**
|
|
26
|
+
* 删除配置中对应的对象
|
|
27
|
+
* @param moreLayerConfigList 配置实例列表
|
|
28
|
+
* @param guid 唯一标识
|
|
29
|
+
* @param removeAll 是否全部删除
|
|
30
|
+
*/
|
|
31
|
+
configRemove(moreLayerConfigList: PopsLayerCommonConfig[][], guid: string, removeAll?: boolean): PopsLayerCommonConfig[][];
|
|
32
|
+
/**
|
|
33
|
+
* 隐藏
|
|
34
|
+
* @param popsType
|
|
35
|
+
* @param layerConfigList
|
|
36
|
+
* @param guid
|
|
37
|
+
* @param config
|
|
38
|
+
* @param animElement
|
|
39
|
+
* @param maskElement
|
|
40
|
+
*/
|
|
41
|
+
hide(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement: HTMLElement): void;
|
|
42
|
+
/**
|
|
43
|
+
* 显示
|
|
44
|
+
* @param popsType
|
|
45
|
+
* @param layerConfigList
|
|
46
|
+
* @param guid
|
|
47
|
+
* @param config
|
|
48
|
+
* @param animElement
|
|
49
|
+
* @param maskElement
|
|
50
|
+
*/
|
|
51
|
+
show(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement: HTMLElement): void;
|
|
52
|
+
/**
|
|
53
|
+
* 关闭
|
|
54
|
+
* @param popsType
|
|
55
|
+
* @param layerConfigList
|
|
56
|
+
* @param guid
|
|
57
|
+
* @param config
|
|
58
|
+
* @param animElement
|
|
59
|
+
*/
|
|
60
|
+
close(popsType: string, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement): void;
|
|
61
|
+
/**
|
|
62
|
+
* 拖拽元素
|
|
63
|
+
* 说明:
|
|
64
|
+
* + 元素的position为absolute或者fixed
|
|
65
|
+
* + 会为元素的
|
|
66
|
+
* @param moveElement 需要拖拽的元素
|
|
67
|
+
* @param options 配置
|
|
68
|
+
*/
|
|
69
|
+
drag(moveElement: HTMLElement, options: {
|
|
70
|
+
dragElement: HTMLElement;
|
|
71
|
+
limit: boolean;
|
|
72
|
+
extraDistance: number;
|
|
73
|
+
container?: Window | typeof globalThis | HTMLElement;
|
|
74
|
+
moveCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
75
|
+
endCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
76
|
+
preventEvent?: (event: TouchEvent | PointerEvent) => boolean;
|
|
77
|
+
}): void;
|
|
78
|
+
/**
|
|
79
|
+
* 排序数组
|
|
80
|
+
* @param getBeforeValueFun
|
|
81
|
+
* @param getAfterValueFun
|
|
82
|
+
* @param sortByDesc 排序是否降序,默认降序
|
|
83
|
+
*/
|
|
84
|
+
sortElementListByProperty<T extends unknown>(getBeforeValueFun: (value: T) => T, getAfterValueFun: (value: T) => T, sortByDesc?: boolean): (after_obj: T, before_obj: T) => 1 | 0 | -1;
|
|
85
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
declare class PopsUtils {
|
|
2
|
+
/**
|
|
3
|
+
* 判断是否是window,例如window、self、globalThis
|
|
4
|
+
* @param target
|
|
5
|
+
*/
|
|
6
|
+
isWin(target: any): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 判断对象是否是元素
|
|
9
|
+
* @param target
|
|
10
|
+
* @returns
|
|
11
|
+
* + true 是元素
|
|
12
|
+
* + false 不是元素
|
|
13
|
+
* @example
|
|
14
|
+
* Utils.isDOM(document.querySelector("a"))
|
|
15
|
+
* > true
|
|
16
|
+
*/
|
|
17
|
+
isDOM(target: any): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 删除对象上的属性
|
|
20
|
+
* @param target
|
|
21
|
+
* @param propName
|
|
22
|
+
*/
|
|
23
|
+
delete(target: any, propName: any): void;
|
|
24
|
+
/**
|
|
25
|
+
* JSON数据从源端替换到目标端中,如果目标端存在该数据则替换,不添加,返回结果为目标端替换完毕的结果
|
|
26
|
+
* @param target 目标数据
|
|
27
|
+
* @param source 源数据
|
|
28
|
+
* @param isAdd 是否可以追加键,默认false
|
|
29
|
+
* @example
|
|
30
|
+
* Utils.assign({"1":1,"2":{"3":3}}, {"2":{"3":4}});
|
|
31
|
+
* >
|
|
32
|
+
* {
|
|
33
|
+
"1": 1,
|
|
34
|
+
"2": {
|
|
35
|
+
"3": 4
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
*/
|
|
39
|
+
assign<T1, T2 extends object, T3 extends boolean>(target: T1, source: T2, isAdd?: T3): T3 extends true ? T1 & T2 : T1;
|
|
40
|
+
/**
|
|
41
|
+
* 生成uuid
|
|
42
|
+
*/
|
|
43
|
+
getRandomGUID(): string;
|
|
44
|
+
/**
|
|
45
|
+
* 字符串转HTMLElement
|
|
46
|
+
* @param elementString
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
parseTextToDOM<R extends HTMLElement>(elementString: string): R;
|
|
50
|
+
/**
|
|
51
|
+
* 判断元素/页面中是否包含该元素
|
|
52
|
+
* @param target 需要判断的元素
|
|
53
|
+
* @param context 默认为body
|
|
54
|
+
*/
|
|
55
|
+
contains(target: HTMLElement[] | HTMLElement): boolean;
|
|
56
|
+
contains(target: HTMLElement[] | HTMLElement, context: Document | Element | Node): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 获取格式化后的时间
|
|
59
|
+
* @param text (可选)需要格式化的字符串或者时间戳,默认:new Date()
|
|
60
|
+
* @param formatType (可选)格式化成的显示类型,默认:yyyy-MM-dd HH:mm:ss
|
|
61
|
+
* + yyyy 年
|
|
62
|
+
* + MM 月
|
|
63
|
+
* + dd 天
|
|
64
|
+
* + HH 时 (24小时制)
|
|
65
|
+
* + hh 时 (12小时制)
|
|
66
|
+
* + mm 分
|
|
67
|
+
* + ss 秒
|
|
68
|
+
* @returns {string} 返回格式化后的时间
|
|
69
|
+
* @example
|
|
70
|
+
* Utils.formatTime("2022-08-21 23:59:00","HH:mm:ss");
|
|
71
|
+
* > '23:59:00'
|
|
72
|
+
* @example
|
|
73
|
+
* Utils.formatTime(1899187424988,"HH:mm:ss");
|
|
74
|
+
* > '15:10:13'
|
|
75
|
+
* @example
|
|
76
|
+
* Utils.formatTime()
|
|
77
|
+
* > '2023-1-1 00:00:00'
|
|
78
|
+
**/
|
|
79
|
+
formatTime(text?: string | number | Date, formatType?: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* 获取格式化后的时间
|
|
82
|
+
* @param text (可选)需要格式化的字符串或者时间戳,默认:new Date()
|
|
83
|
+
* @param formatType (可选)格式化成的显示类型,默认:yyyy-MM-dd HH:mm:ss
|
|
84
|
+
* + yyyy 年
|
|
85
|
+
* + MM 月
|
|
86
|
+
* + dd 天
|
|
87
|
+
* + HH 时 (24小时制)
|
|
88
|
+
* + hh 时 (12小时制)
|
|
89
|
+
* + mm 分
|
|
90
|
+
* + ss 秒
|
|
91
|
+
* @returns {string} 返回格式化后的时间
|
|
92
|
+
* @example
|
|
93
|
+
* Utils.formatTime("2022-08-21 23:59:00","HH:mm:ss");
|
|
94
|
+
* > '23:59:00'
|
|
95
|
+
* @example
|
|
96
|
+
* Utils.formatTime(1899187424988,"HH:mm:ss");
|
|
97
|
+
* > '15:10:13'
|
|
98
|
+
* @example
|
|
99
|
+
* Utils.formatTime()
|
|
100
|
+
* > '2023-1-1 00:00:00'
|
|
101
|
+
**/
|
|
102
|
+
formatTime(text?: string | number | Date, formatType?: "yyyy-MM-dd HH:mm:ss" | "yyyy/MM/dd HH:mm:ss" | "yyyy_MM_dd_HH_mm_ss" | "yyyy年MM月dd日 HH时mm分ss秒" | "yyyy年MM月dd日 hh:mm:ss" | "yyyy年MM月dd日 HH:mm:ss" | "yyyy-MM-dd" | "yyyyMMdd" | "HH:mm:ss"): string;
|
|
103
|
+
/**
|
|
104
|
+
* 格式化byte为KB、MB、GB、TB、PB、EB、ZB、YB、BB、NB、DB
|
|
105
|
+
* @param byteSize 字节
|
|
106
|
+
* @param addType (可选)是否添加单位
|
|
107
|
+
* + true (默认) 添加单位
|
|
108
|
+
* + false 不添加单位
|
|
109
|
+
* @returns
|
|
110
|
+
* + {string} 当addType为true时,且保留小数点末尾2位
|
|
111
|
+
* + {number} 当addType为false时,且保留小数点末尾2位
|
|
112
|
+
* @example
|
|
113
|
+
* Utils.formatByteToSize("812304");
|
|
114
|
+
* > '793.27KB'
|
|
115
|
+
* @example
|
|
116
|
+
* Utils.formatByteToSize("812304",false);
|
|
117
|
+
* > 793.27
|
|
118
|
+
**/
|
|
119
|
+
formatByteToSize<T extends boolean>(byteSize: number | string, addType?: T): T extends true ? string : number;
|
|
120
|
+
AnyTouch: () => any;
|
|
121
|
+
}
|
|
122
|
+
declare const popsUtils: PopsUtils;
|
|
123
|
+
export { popsUtils };
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@whitesev/pops",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "弹窗库",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/node/index.esm.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"jsdelivr": "dist/index.umd.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.esm.js",
|
|
13
|
+
"require": "./dist/index.cjs.js",
|
|
14
|
+
"types": "./dist/types/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"src/types"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rollup --config"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"typescript",
|
|
26
|
+
"pops",
|
|
27
|
+
"dialog"
|
|
28
|
+
],
|
|
29
|
+
"author": "WhiteSev",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@rollup/plugin-commonjs": "^25.0.8",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
34
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
35
|
+
"rollup-plugin-clear": "^2.0.7",
|
|
36
|
+
"tslib": "^2.6.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"rollup-plugin-import-css": "^3.5.0",
|
|
40
|
+
"typescript": "^5.4.5"
|
|
41
|
+
}
|
|
42
|
+
}
|