@cclr/front 0.1.16 → 0.1.18
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/lib/cjs/index.js +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/type/index.d.ts +149 -28
- package/package.json +4 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@cclr/lang");function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var r=function(){for(var t=[],o=0;o<arguments.length;o++){var i=o<0||arguments.length<=o?void 0:arguments[o];if(i)if("string"!=typeof i&&"number"!=typeof i){if(e.isArray(i)){var a=r.apply(void 0,n(i));a&&t.push(a)}else if("object"==typeof i){if(i.toString!==Object.prototype.toString){t.push(i.toString());continue}for(var
|
|
1
|
+
"use strict";var e=require("@cclr/lang");function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var r=function(){for(var t=[],o=0;o<arguments.length;o++){var i=o<0||arguments.length<=o?void 0:arguments[o];if(i)if("string"!=typeof i&&"number"!=typeof i){if(e.isArray(i)){var a=r.apply(void 0,n(i));a&&t.push(a)}else if("object"==typeof i){if(i.toString!==Object.prototype.toString){t.push(i.toString());continue}for(var u in i)e.hasOwn(i,u)&&i[u]&&t.push(u)}}else t.push(i)}return t.join(" ")},o="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",i=function(t,n,r,o){if(null==t||!t.addEventListener)throw new Error("The provided DOM element is not have addEventListener.");if("string"!=typeof n)throw new Error("The event type must be a string.");if(!(e.isFunction(r)||r instanceof Object))throw new Error("The listener must be a function or an EventListenerObject.");return t.addEventListener(n,r,o),function(){t.removeEventListener(n,r,o)}};exports.addEventListener=i,exports.addEventListenerMultiple=function(e,t,n){var r=[];return Object.keys(t).forEach((function(o){r.push(i(e,o,t[o],n))})),function(){r.forEach((function(e){return null==e?void 0:e()}))}},exports.addStyleSheet=function(t){var n=document.createElement("style");if(n.setAttribute("type","text/css"),n.styleSheet)n.styleSheet.cssText=t;else{var r=document.createTextNode(t);n.appendChild(r)}var o=document.getElementsByTagName("head"),i=e.noop;return o.length?(o[0].appendChild(n),i=function(){o[0].removeChild(n)}):(document.documentElement.appendChild(n),i=function(){document.documentElement.removeChild(n)}),i},exports.classNames=r,exports.delDom=function(e){e&&(null!=e&&e.remove?e.remove():null!=e&&e.parentNode&&e.parentNode.removeChild(e))},exports.emptyImgBase64=o,exports.getEmptyImage=function(){var e=new Image;return e.src=o,e};
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isArray as e,hasOwn as t,isFunction as n,noop as r}from"@cclr/lang";function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var a=function(){for(var n=[],r=0;r<arguments.length;r++){var o=r<0||arguments.length<=r?void 0:arguments[r];if(o)if("string"!=typeof o&&"number"!=typeof o){if(e(o)){var u=a.apply(void 0,i(o));u&&n.push(u)}else if("object"==typeof o){if(o.toString!==Object.prototype.toString){n.push(o.toString());continue}for(var
|
|
1
|
+
import{isArray as e,hasOwn as t,isFunction as n,noop as r}from"@cclr/lang";function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var a=function(){for(var n=[],r=0;r<arguments.length;r++){var o=r<0||arguments.length<=r?void 0:arguments[r];if(o)if("string"!=typeof o&&"number"!=typeof o){if(e(o)){var u=a.apply(void 0,i(o));u&&n.push(u)}else if("object"==typeof o){if(o.toString!==Object.prototype.toString){n.push(o.toString());continue}for(var l in o)t(o,l)&&o[l]&&n.push(l)}}else n.push(o)}return n.join(" ")},u="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",l=function(e){e&&(null!=e&&e.remove?e.remove():null!=e&&e.parentNode&&e.parentNode.removeChild(e))},c=function(){var e=new Image;return e.src=u,e},f=function(e,t,r,o){if(null==e||!e.addEventListener)throw new Error("The provided DOM element is not have addEventListener.");if("string"!=typeof t)throw new Error("The event type must be a string.");if(!(n(r)||r instanceof Object))throw new Error("The listener must be a function or an EventListenerObject.");return e.addEventListener(t,r,o),function(){e.removeEventListener(t,r,o)}},s=function(e,t,n){var r=[];return Object.keys(t).forEach((function(o){r.push(f(e,o,t[o],n))})),function(){r.forEach((function(e){return null==e?void 0:e()}))}};function d(e){var t=document.createElement("style");if(t.setAttribute("type","text/css"),t.styleSheet)t.styleSheet.cssText=e;else{var n=document.createTextNode(e);t.appendChild(n)}var o=document.getElementsByTagName("head"),i=r;return o.length?(o[0].appendChild(t),i=function(){o[0].removeChild(t)}):(document.documentElement.appendChild(t),i=function(){document.documentElement.removeChild(t)}),i}export{f as addEventListener,s as addEventListenerMultiple,d as addStyleSheet,a as classNames,l as delDom,u as emptyImgBase64,c as getEmptyImage};
|
package/lib/type/index.d.ts
CHANGED
|
@@ -16,66 +16,187 @@ declare const classNames: (...args: ClassValue[]) => string;
|
|
|
16
16
|
*/
|
|
17
17
|
declare const emptyImgBase64 = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* 删除一个dom节点
|
|
21
|
+
* @param dom
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
declare const delDom: (dom: Element) => void;
|
|
25
|
+
|
|
19
26
|
/**
|
|
20
27
|
* 获取 1*1 像素的透明图片
|
|
21
28
|
* @returns dom
|
|
22
29
|
*/
|
|
23
30
|
declare const getEmptyImage: () => HTMLImageElement;
|
|
24
31
|
|
|
25
|
-
type CommonDOMEventTypes = 'click' | 'dblclick' | 'mousedown' | 'mouseup' | 'mousemove' | 'mouseover' | 'mouseout' | 'keydown' | 'keyup' | 'keypress' | 'touchstart' | 'touchend' | 'touchmove' | 'touchcancel' | 'dragstart' | 'drag' | 'dragend' | 'dragenter' | 'dragover' | 'dragleave' | 'drop' | 'scroll' | '
|
|
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';
|
|
26
33
|
type EventListenerOptions = boolean | AddEventListenerOptions;
|
|
27
|
-
type TEventMap = Partial<{
|
|
28
|
-
click: (e: MouseEvent
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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;
|
|
42
83
|
/**
|
|
43
84
|
* 拖动元素开始触发
|
|
44
85
|
* dataTransfer.setData()方法设置数据类型和拖动的数据
|
|
45
86
|
* e.dataTransfer.setData("Text", event.target.id);
|
|
46
87
|
*/
|
|
47
|
-
dragstart: (e: DragEvent
|
|
88
|
+
dragstart: (e: DragEvent & {
|
|
89
|
+
target: T;
|
|
90
|
+
}) => void;
|
|
48
91
|
/**
|
|
49
92
|
* 拖动元素时触发
|
|
50
93
|
*/
|
|
51
|
-
drag: (e: DragEvent
|
|
94
|
+
drag: (e: DragEvent & {
|
|
95
|
+
target: T;
|
|
96
|
+
}) => void;
|
|
52
97
|
/**
|
|
53
98
|
* 拖动元素结束触发
|
|
54
99
|
*/
|
|
55
|
-
dragend: (e: DragEvent
|
|
100
|
+
dragend: (e: DragEvent & {
|
|
101
|
+
target: T;
|
|
102
|
+
}) => void;
|
|
56
103
|
/**
|
|
57
104
|
* 接收元素,进入时触发
|
|
58
105
|
*/
|
|
59
|
-
dragenter: (e: DragEvent
|
|
106
|
+
dragenter: (e: DragEvent & {
|
|
107
|
+
target: T;
|
|
108
|
+
}) => void;
|
|
60
109
|
/**
|
|
61
110
|
* 接收元素,内部移动时触发
|
|
62
111
|
* 如果使用drop,必须防止元素的默认处理
|
|
63
112
|
* event.preventDefault();
|
|
64
113
|
*/
|
|
65
|
-
dragover: (e: DragEvent
|
|
114
|
+
dragover: (e: DragEvent & {
|
|
115
|
+
target: T;
|
|
116
|
+
}) => void;
|
|
66
117
|
/**
|
|
67
118
|
* 接收元素,离开时触发
|
|
68
119
|
*/
|
|
69
|
-
dragleave: (e: DragEvent
|
|
120
|
+
dragleave: (e: DragEvent & {
|
|
121
|
+
target: T;
|
|
122
|
+
}) => void;
|
|
70
123
|
/**
|
|
71
124
|
* 接收元素,拖动完成后触发
|
|
72
125
|
* dataTransfer.getData()方法获得拖放数据
|
|
73
126
|
* e.dataTransfer.getData("Text");
|
|
74
127
|
*/
|
|
75
|
-
drop: (e: DragEvent
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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;
|
|
79
200
|
}>;
|
|
80
201
|
|
|
81
202
|
/**
|
|
@@ -96,7 +217,7 @@ declare const addEventListener: <T extends HTMLElement = HTMLElement>(dom: T, ty
|
|
|
96
217
|
* @param options 事件监听选项
|
|
97
218
|
* @returns 移除事件监听的函数
|
|
98
219
|
*/
|
|
99
|
-
declare const addEventListenerMultiple: <T extends HTMLElement = HTMLElement>(dom: T, listenerMap: TEventMap
|
|
220
|
+
declare const addEventListenerMultiple: <T extends HTMLElement = HTMLElement>(dom: T, listenerMap: TEventMap<T>, options?: EventListenerOptions) => () => void;
|
|
100
221
|
|
|
101
222
|
/**
|
|
102
223
|
* 添加样式表
|
|
@@ -105,4 +226,4 @@ declare const addEventListenerMultiple: <T extends HTMLElement = HTMLElement>(do
|
|
|
105
226
|
*/
|
|
106
227
|
declare function addStyleSheet(cssStr: string): () => void;
|
|
107
228
|
|
|
108
|
-
export { type CommonDOMEventTypes, type EventListenerOptions, type TEventMap, addEventListener, addEventListenerMultiple, addStyleSheet, classNames, emptyImgBase64, getEmptyImage };
|
|
229
|
+
export { type CommonDOMEventTypes, type EventListenerOptions, type TEventMap, addEventListener, addEventListenerMultiple, addStyleSheet, classNames, delDom, emptyImgBase64, getEmptyImage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cclr/front",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
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": "
|
|
30
|
+
"gitHead": "f0b2dc8e54b6ddfcca0ff36488c17df73a658e49",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cclr/lang": "0.1.
|
|
33
|
-
"@cclr/utils": "0.1.
|
|
32
|
+
"@cclr/lang": "0.1.18",
|
|
33
|
+
"@cclr/utils": "0.1.18"
|
|
34
34
|
}
|
|
35
35
|
}
|