@cclr/front 0.1.12 → 0.1.14

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 CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@cclr/lang");function r(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function e(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t)||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 n=function(){for(var r=[],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(t.isArray(i)){var a=n.apply(void 0,e(i));a&&r.push(a)}else if("object"==typeof i){if(i.toString!==Object.prototype.toString){r.push(i.toString());continue}for(var u in i)t.hasOwn(i,u)&&i[u]&&r.push(u)}}else r.push(i)}return r.join(" ")},o=function(r,e,n,o){if(!(r instanceof HTMLElement))throw new Error("The provided DOM element is not an HTMLElement.");if("string"!=typeof e)throw new Error("The event type must be a string.");if(!(t.isFunction(n)||n instanceof Object))throw new Error("The listener must be a function or an EventListenerObject.");return r.addEventListener(e,n,o),function(){r.removeEventListener(e,n,o)}};exports.addEventListener=o,exports.addEventListenerMultiple=function(t,r,e){var n=[];return Object.keys(r).forEach((function(i){n.push(o(t,i,r[i],e))})),function(){n.forEach((function(t){return null==t?void 0:t()}))}},exports.classNames=n;
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 t,hasOwn as r,isFunction as n}from"@cclr/lang";function e(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=Array(r);n<r;n++)e[n]=t[n];return e}function o(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t)||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 i=function(){for(var n=[],e=0;e<arguments.length;e++){var a=e<0||arguments.length<=e?void 0:arguments[e];if(a)if("string"!=typeof a&&"number"!=typeof a){if(t(a)){var f=i.apply(void 0,o(a));f&&n.push(f)}else if("object"==typeof a){if(a.toString!==Object.prototype.toString){n.push(a.toString());continue}for(var u in a)r(a,u)&&a[u]&&n.push(u)}}else n.push(a)}return n.join(" ")},a=function(t,r,e,o){if(!(t instanceof HTMLElement))throw new Error("The provided DOM element is not an HTMLElement.");if("string"!=typeof r)throw new Error("The event type must be a string.");if(!(n(e)||e instanceof Object))throw new Error("The listener must be a function or an EventListenerObject.");return t.addEventListener(r,e,o),function(){t.removeEventListener(r,e,o)}},f=function(t,r,n){var e=[];return Object.keys(r).forEach((function(o){e.push(a(t,o,r[o],n))})),function(){e.forEach((function(t){return null==t?void 0:t()}))}};export{a as addEventListener,f as addEventListenerMultiple,i as classNames};
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};
@@ -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
- export { type CommonDOMEventTypes, type EventListenerOptions, type TEventMap, addEventListener, addEventListenerMultiple, classNames };
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.12",
3
+ "version": "0.1.14",
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": "5d72cd2a2b31db1d09ffc5a19aba6c23ff81abd4",
30
+ "gitHead": "c0359e7db68cd14df406cb2c8d56b5fe14a2c3bb",
31
31
  "dependencies": {
32
- "@cclr/lang": "0.1.12",
33
- "@cclr/utils": "0.1.12"
32
+ "@cclr/lang": "0.1.14",
33
+ "@cclr/utils": "0.1.14"
34
34
  }
35
35
  }