@cclr/front 0.1.11 → 0.1.13
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 +19 -1
- package/package.json +4 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";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 s in i)e.hasOwn(i,s)&&i[s]&&t.push(s)}}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.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
|
|
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 c in o)t(o,c)&&o[c]&&n.push(c)}}else n.push(o)}return n.join(" ")},u="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",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)}},l=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 s(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,l as addEventListenerMultiple,s as addStyleSheet,a as classNames,u as emptyImgBase64,c as getEmptyImage};
|
package/lib/type/index.d.ts
CHANGED
|
@@ -11,6 +11,17 @@ type ClassObject = Record<string, TAny>;
|
|
|
11
11
|
*/
|
|
12
12
|
declare const classNames: (...args: ClassValue[]) => string;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* 1*1 像素的透明图片
|
|
16
|
+
*/
|
|
17
|
+
declare const emptyImgBase64 = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 获取 1*1 像素的透明图片
|
|
21
|
+
* @returns dom
|
|
22
|
+
*/
|
|
23
|
+
declare const getEmptyImage: () => HTMLImageElement;
|
|
24
|
+
|
|
14
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' | 'scroll' | 'scroll' | 'wheel' | 'resize';
|
|
15
26
|
type EventListenerOptions = boolean | AddEventListenerOptions;
|
|
16
27
|
type TEventMap = Partial<{
|
|
@@ -87,4 +98,11 @@ declare const addEventListener: <T extends HTMLElement = HTMLElement>(dom: T, ty
|
|
|
87
98
|
*/
|
|
88
99
|
declare const addEventListenerMultiple: <T extends HTMLElement = HTMLElement>(dom: T, listenerMap: TEventMap, options?: EventListenerOptions) => () => void;
|
|
89
100
|
|
|
90
|
-
|
|
101
|
+
/**
|
|
102
|
+
* 添加样式表
|
|
103
|
+
* @param cssStr 样式表字符串
|
|
104
|
+
* @returns cb 移除样式表的回调
|
|
105
|
+
*/
|
|
106
|
+
declare function addStyleSheet(cssStr: string): () => void;
|
|
107
|
+
|
|
108
|
+
export { type CommonDOMEventTypes, type EventListenerOptions, type TEventMap, addEventListener, addEventListenerMultiple, addStyleSheet, classNames, 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.13",
|
|
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": "731ccef207bc8ed3120229b2041a42ee9cb5dd7f",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cclr/lang": "0.1.
|
|
33
|
-
"@cclr/utils": "0.1.
|
|
32
|
+
"@cclr/lang": "0.1.12",
|
|
33
|
+
"@cclr/utils": "0.1.12"
|
|
34
34
|
}
|
|
35
35
|
}
|