media-trigger
Advanced tools
@@ -1,1 +0,1 @@ | ||
| "use strict";var n=Object.defineProperty;var a=(e,t,i)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var h=(e,t,i)=>a(e,typeof t!="symbol"?t+"":t,i);module.exports=class{constructor({media:e,entry:t=null,exit:i=null,change:s=null}){h(this,"MQ");h(this,"entry");h(this,"exit");h(this,"change");h(this,"trigger",e=>{var i;const t=e.matches;t&&this.entry?this.entry(this.MQ):!t&&this.exit&&this.exit(this.MQ),(i=this.change)==null||i.call(this,this.MQ)});h(this,"handleChange",e=>{this.trigger(e)});window.matchMedia&&(this.MQ=window.matchMedia(e),this.entry=t,this.exit=i,this.change=s)}init(){this.MQ.addEventListener("change",this.handleChange),this.trigger(this.MQ)}destroy(){this.MQ.removeEventListener("change",this.handleChange)}}; | ||
| "use strict";var r=Object.defineProperty;var a=(i,e,t)=>e in i?r(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>a(i,typeof e!="symbol"?e+"":e,t);module.exports=class{constructor({media:i,entry:e,exit:t,change:h}){s(this,"mediaQueryList");s(this,"entry");s(this,"exit");s(this,"change");s(this,"handleChange",i=>{this.trigger(i)});typeof window<"u"&&window.matchMedia&&(this.mediaQueryList=window.matchMedia(i)),this.entry=e,this.exit=t,this.change=h}trigger(i){var t;if(!this.mediaQueryList)return;const e=i.matches;e&&this.entry?this.entry(this.mediaQueryList):!e&&this.exit&&this.exit(this.mediaQueryList),(t=this.change)==null||t.call(this,this.mediaQueryList)}init(){this.mediaQueryList&&(this.mediaQueryList.addEventListener("change",this.handleChange),this.trigger(this.mediaQueryList))}destroy(){this.mediaQueryList&&this.mediaQueryList.removeEventListener("change",this.handleChange)}}; |
+12
-10
@@ -0,12 +1,14 @@ | ||
| type MediaTriggerCallback = (mq: MediaQueryList) => void; | ||
| interface MediaTriggerOptions { | ||
| media: string; | ||
| entry?: MediaTriggerCallback; | ||
| exit?: MediaTriggerCallback; | ||
| change?: MediaTriggerCallback; | ||
| } | ||
| declare class MediaTrigger { | ||
| private readonly MQ; | ||
| private readonly entry; | ||
| private readonly exit; | ||
| private readonly change; | ||
| constructor({ media, entry, exit, change, }: { | ||
| media: string; | ||
| entry?: ((mq: MediaQueryList) => void) | null; | ||
| exit?: ((mq: MediaQueryList) => void) | null; | ||
| change?: ((mq: MediaQueryList) => void) | null; | ||
| }); | ||
| private readonly mediaQueryList?; | ||
| private readonly entry?; | ||
| private readonly exit?; | ||
| private readonly change?; | ||
| constructor({ media, entry, exit, change }: MediaTriggerOptions); | ||
| private trigger; | ||
@@ -13,0 +15,0 @@ private handleChange; |
+21
-20
@@ -1,29 +0,30 @@ | ||
| var a = Object.defineProperty; | ||
| var r = (h, t, e) => t in h ? a(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e; | ||
| var i = (h, t, e) => r(h, typeof t != "symbol" ? t + "" : t, e); | ||
| class c { | ||
| constructor({ media: t, entry: e = null, exit: n = null, change: s = null }) { | ||
| i(this, "MQ"); | ||
| i(this, "entry"); | ||
| i(this, "exit"); | ||
| i(this, "change"); | ||
| i(this, "trigger", (t) => { | ||
| var n; | ||
| const e = t.matches; | ||
| e && this.entry ? this.entry(this.MQ) : !e && this.exit && this.exit(this.MQ), (n = this.change) == null || n.call(this, this.MQ); | ||
| var r = Object.defineProperty; | ||
| var n = (t, e, i) => e in t ? r(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i; | ||
| var s = (t, e, i) => n(t, typeof e != "symbol" ? e + "" : e, i); | ||
| class y { | ||
| constructor({ media: e, entry: i, exit: h, change: a }) { | ||
| s(this, "mediaQueryList"); | ||
| s(this, "entry"); | ||
| s(this, "exit"); | ||
| s(this, "change"); | ||
| s(this, "handleChange", (e) => { | ||
| this.trigger(e); | ||
| }); | ||
| i(this, "handleChange", (t) => { | ||
| this.trigger(t); | ||
| }); | ||
| window.matchMedia && (this.MQ = window.matchMedia(t), this.entry = e, this.exit = n, this.change = s); | ||
| typeof window < "u" && window.matchMedia && (this.mediaQueryList = window.matchMedia(e)), this.entry = i, this.exit = h, this.change = a; | ||
| } | ||
| trigger(e) { | ||
| var h; | ||
| if (!this.mediaQueryList) return; | ||
| const i = e.matches; | ||
| i && this.entry ? this.entry(this.mediaQueryList) : !i && this.exit && this.exit(this.mediaQueryList), (h = this.change) == null || h.call(this, this.mediaQueryList); | ||
| } | ||
| init() { | ||
| this.MQ.addEventListener("change", this.handleChange), this.trigger(this.MQ); | ||
| this.mediaQueryList && (this.mediaQueryList.addEventListener("change", this.handleChange), this.trigger(this.mediaQueryList)); | ||
| } | ||
| destroy() { | ||
| this.MQ.removeEventListener("change", this.handleChange); | ||
| this.mediaQueryList && this.mediaQueryList.removeEventListener("change", this.handleChange); | ||
| } | ||
| } | ||
| export { | ||
| c as default | ||
| y as default | ||
| }; |
@@ -1,1 +0,1 @@ | ||
| (function(t,e){typeof exports=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self).MediaTrigger=e()})(this,function(){"use strict";var s=Object.defineProperty;var a=(t,e,i)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var n=(t,e,i)=>a(t,typeof e!="symbol"?e+"":e,i);return class{constructor({media:t,entry:e=null,exit:i=null,change:h=null}){n(this,"MQ");n(this,"entry");n(this,"exit");n(this,"change");n(this,"trigger",t=>{var i;const e=t.matches;e&&this.entry?this.entry(this.MQ):!e&&this.exit&&this.exit(this.MQ),(i=this.change)==null||i.call(this,this.MQ)});n(this,"handleChange",t=>{this.trigger(t)});window.matchMedia&&(this.MQ=window.matchMedia(t),this.entry=e,this.exit=i,this.change=h)}init(){this.MQ.addEventListener("change",this.handleChange),this.trigger(this.MQ)}destroy(){this.MQ.removeEventListener("change",this.handleChange)}}}); | ||
| (function(i,e){typeof exports=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(i=typeof globalThis<"u"?globalThis:i||self).MediaTrigger=e()})(this,function(){"use strict";var h=Object.defineProperty;var r=(i,e,t)=>e in i?h(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>r(i,typeof e!="symbol"?e+"":e,t);return class{constructor({media:i,entry:e,exit:t,change:n}){s(this,"mediaQueryList");s(this,"entry");s(this,"exit");s(this,"change");s(this,"handleChange",i=>{this.trigger(i)});typeof window<"u"&&window.matchMedia&&(this.mediaQueryList=window.matchMedia(i)),this.entry=e,this.exit=t,this.change=n}trigger(i){var t;if(!this.mediaQueryList)return;const e=i.matches;e&&this.entry?this.entry(this.mediaQueryList):!e&&this.exit&&this.exit(this.mediaQueryList),(t=this.change)==null||t.call(this,this.mediaQueryList)}init(){this.mediaQueryList&&(this.mediaQueryList.addEventListener("change",this.handleChange),this.trigger(this.mediaQueryList))}destroy(){this.mediaQueryList&&this.mediaQueryList.removeEventListener("change",this.handleChange)}}}); |
+20
-16
| { | ||
| "name": "media-trigger", | ||
| "version": "4.2.0", | ||
| "version": "4.2.1-dev.0", | ||
| "description": "MediaTrigger is designed to control the response to changes in media queries, allowing you to perform specific actions when entering or exiting a particular media state, or any change to a media state.", | ||
@@ -19,5 +19,5 @@ "author": "ux-ui.pro", | ||
| "build": "vite build", | ||
| "lint:js": "eslint **/*.{ts,js}", | ||
| "lint:fix:js": "eslint **/*.{ts,js} --fix", | ||
| "format:js": "prettier --write **/*.{ts,js}", | ||
| "lint:js": "eslint src/**/*.{ts,js}", | ||
| "lint:fix:js": "eslint src/**/*.{ts,js} --fix", | ||
| "format:js": "prettier --write src/**/*.{ts,js}", | ||
| "lint:fix": "yarn lint:fix:js && yarn format:js" | ||
@@ -28,7 +28,11 @@ }, | ||
| "module": "dist/index.es.js", | ||
| "browser": "./dist/index.umd.js", | ||
| "types": "dist/index.d.ts", | ||
| "exports": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.es.js", | ||
| "require": "./dist/index.cjs.js" | ||
| ".": { | ||
| "require": "./dist/index.cjs.js", | ||
| "import": "./dist/index.es.js", | ||
| "default": "./dist/index.umd.js" | ||
| }, | ||
| "./dist/*": "./dist/*" | ||
| }, | ||
@@ -39,17 +43,17 @@ "files": [ | ||
| "devDependencies": { | ||
| "@eslint/js": "9.21.0", | ||
| "@eslint/js": "9.22.0", | ||
| "@rollup/plugin-terser": "0.4.4", | ||
| "@types/node": "22.13.8", | ||
| "@typescript-eslint/eslint-plugin": "8.25.0", | ||
| "@typescript-eslint/parser": "8.25.0", | ||
| "eslint": "9.18.0", | ||
| "eslint-config-prettier": "10.0.2", | ||
| "@types/node": "22.13.10", | ||
| "@typescript-eslint/eslint-plugin": "8.26.0", | ||
| "@typescript-eslint/parser": "8.26.0", | ||
| "eslint": "9.22.0", | ||
| "eslint-config-prettier": "10.1.1", | ||
| "eslint-import-resolver-typescript": "3.8.3", | ||
| "eslint-plugin-import": "2.31.0", | ||
| "globals": "16.0.0", | ||
| "prettier": "3.5.2", | ||
| "prettier": "3.5.3", | ||
| "rimraf": "6.0.1", | ||
| "typescript": "5.8.2", | ||
| "vite": "6.2.0", | ||
| "vite-plugin-dts": "4.5.1" | ||
| "vite": "6.2.1", | ||
| "vite-plugin-dts": "4.5.3" | ||
| }, | ||
@@ -56,0 +60,0 @@ "keywords": [ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10110
6.81%58
9.43%0
-100%3
50%