@preline/toggle-password 5.0.0 → 5.1.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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var o in s)("object"==typeof exports?exports:t)[o]=s[o]}}(self,()=>(()=>{"use strict";var t={2961(t,e){
2
2
  /*
3
3
  * HSBasePlugin
4
- * @version: 5.0.0
4
+ * @version: 5.1.0
5
5
  * @author: Preline Labs Ltd.
6
6
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
7
7
  * Copyright 2024 Preline Labs Ltd.
@@ -9,14 +9,14 @@
9
9
  Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(t,e,s){this.el=t,this.options=e,this.events=s,this.el=t,this.options=e,this.events={}}createCollection(t,e){var s,o;let i=t;if(!Array.isArray(i)&&"undefined"!=typeof window){const t=null===(s=this.constructor)||void 0===s?void 0:s.name,e="string"==typeof t&&t.startsWith("HS")?`$hs${t.slice(2)}Collection`:null;e&&(Array.isArray(window[e])||(window[e]=[]),i=window[e])}Array.isArray(i)&&i.push({id:(null===(o=null==e?void 0:e.el)||void 0===o?void 0:o.id)||i.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}},2061(t,e,s){var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(s(8549));window.addEventListener("load",()=>{i.default.autoInit()}),"undefined"!=typeof window&&(window.HSTogglePassword=i.default)},8549(t,e,s){
10
10
  /*
11
11
  * HSTogglePassword
12
- * @version: 5.0.0
12
+ * @version: 5.1.0
13
13
  * @author: Preline Labs Ltd.
14
14
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
15
15
  * Copyright 2024 Preline Labs Ltd.
16
16
  */
17
17
  var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=s(292),n=o(s(2961));class l extends n.default{constructor(t,e){super(t,e);const s=t.getAttribute("data-hs-toggle-password"),o=s?JSON.parse(s):{},n=Object.assign(Object.assign({},o),e),l=[];if((null==n?void 0:n.target)&&"string"==typeof(null==n?void 0:n.target)){(null==n?void 0:n.target.split(",")).forEach(t=>{l.push(document.querySelector(t))})}else(null==n?void 0:n.target)&&"object"==typeof(null==n?void 0:n.target)?n.target.forEach(t=>l.push(document.querySelector(t))):n.target.forEach(t=>l.push(t));this.target=l,this.isShown=!!this.el.hasAttribute("type")&&this.el.checked,this.eventType=(0,i.isFormElement)(this.el)?"change":"click",this.isMultiple=this.target.length>1&&!!this.el.closest("[data-hs-toggle-password-group]"),this.target&&this.init()}elementAction(){this.isShown?this.hide():this.show(),this.fireEvent("toggle",this.target),(0,i.dispatch)("toggle.hs.toggle-select",this.el,this.target)}init(){this.createCollection(window.$hsTogglePasswordCollection,this),this.isShown?this.show():this.hide(),this.onElementActionListener=()=>this.elementAction(),this.el.addEventListener(this.eventType,this.onElementActionListener)}getMultipleToggles(){const t=this.el.closest("[data-hs-toggle-password-group]").querySelectorAll("[data-hs-toggle-password]"),e=[];return t.forEach(t=>{e.push(l.getInstance(t))}),e}show(){if(this.isMultiple){this.getMultipleToggles().forEach(t=>!!t&&(t.isShown=!0)),this.el.closest("[data-hs-toggle-password-group]").classList.add("active")}else this.isShown=!0,this.el.classList.add("active");this.target.forEach(t=>{t.type="text"})}hide(){if(this.isMultiple){this.getMultipleToggles().forEach(t=>!!t&&(t.isShown=!1)),this.el.closest("[data-hs-toggle-password-group]").classList.remove("active")}else this.isShown=!1,this.el.classList.remove("active");this.target.forEach(t=>{t.type="password"})}destroy(){this.isMultiple?this.el.closest("[data-hs-toggle-password-group]").classList.remove("active"):this.el.classList.remove("active"),this.target.forEach(t=>{t.type="password"}),this.el.removeEventListener(this.eventType,this.onElementActionListener),this.isShown=!1,window.$hsTogglePasswordCollection=window.$hsTogglePasswordCollection.filter(({element:t})=>t.el!==this.el)}static getInstance(t,e){const s=window.$hsTogglePasswordCollection.find(e=>e.element.el===("string"==typeof t?document.querySelector(t):t));return s?e?s:s.element:null}static autoInit(){window.$hsTogglePasswordCollection||(window.$hsTogglePasswordCollection=[]),window.$hsTogglePasswordCollection&&(window.$hsTogglePasswordCollection=window.$hsTogglePasswordCollection.filter(({element:t})=>document.contains(t.el))),document.querySelectorAll("[data-hs-toggle-password]:not(.--prevent-on-load-init)").forEach(t=>{window.$hsTogglePasswordCollection.find(e=>{var s;return(null===(s=null==e?void 0:e.element)||void 0===s?void 0:s.el)===t})||new l(t)})}}e.default=l},292(t,e){
18
18
  /*
19
- * @version: 5.0.0
19
+ * @version: 5.1.0
20
20
  * @author: Preline Labs Ltd.
21
21
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
22
22
  * Copyright 2024 Preline Labs Ltd.
package/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var t={7615(t,e,s){s.d(e,{A:()=>o});
2
2
  /*
3
3
  * HSBasePlugin
4
- * @version: 5.0.0
4
+ * @version: 5.1.0
5
5
  * @author: Preline Labs Ltd.
6
6
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
7
7
  * Copyright 2024 Preline Labs Ltd.
@@ -9,14 +9,14 @@ var t={7615(t,e,s){s.d(e,{A:()=>o});
9
9
  class o{constructor(t,e,s){this.el=t,this.options=e,this.events=s,this.el=t,this.options=e,this.events={}}createCollection(t,e){var s,o;let i=t;if(!Array.isArray(i)&&"undefined"!=typeof window){const t=null===(s=this.constructor)||void 0===s?void 0:s.name,e="string"==typeof t&&t.startsWith("HS")?`$hs${t.slice(2)}Collection`:null;e&&(Array.isArray(window[e])||(window[e]=[]),i=window[e])}Array.isArray(i)&&i.push({id:(null===(o=null==e?void 0:e.el)||void 0===o?void 0:o.id)||i.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}},847(t,e,s){s.d(e,{A:()=>n});var o=s(1926),i=s(7615);
10
10
  /*
11
11
  * HSTogglePassword
12
- * @version: 5.0.0
12
+ * @version: 5.1.0
13
13
  * @author: Preline Labs Ltd.
14
14
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
15
15
  * Copyright 2024 Preline Labs Ltd.
16
16
  */
17
17
  class l extends i.A{constructor(t,e){super(t,e);const s=t.getAttribute("data-hs-toggle-password"),i=s?JSON.parse(s):{},l=Object.assign(Object.assign({},i),e),n=[];if((null==l?void 0:l.target)&&"string"==typeof(null==l?void 0:l.target)){(null==l?void 0:l.target.split(",")).forEach(t=>{n.push(document.querySelector(t))})}else(null==l?void 0:l.target)&&"object"==typeof(null==l?void 0:l.target)?l.target.forEach(t=>n.push(document.querySelector(t))):l.target.forEach(t=>n.push(t));this.target=n,this.isShown=!!this.el.hasAttribute("type")&&this.el.checked,this.eventType=(0,o.V6)(this.el)?"change":"click",this.isMultiple=this.target.length>1&&!!this.el.closest("[data-hs-toggle-password-group]"),this.target&&this.init()}elementAction(){this.isShown?this.hide():this.show(),this.fireEvent("toggle",this.target),(0,o.JD)("toggle.hs.toggle-select",this.el,this.target)}init(){this.createCollection(window.$hsTogglePasswordCollection,this),this.isShown?this.show():this.hide(),this.onElementActionListener=()=>this.elementAction(),this.el.addEventListener(this.eventType,this.onElementActionListener)}getMultipleToggles(){const t=this.el.closest("[data-hs-toggle-password-group]").querySelectorAll("[data-hs-toggle-password]"),e=[];return t.forEach(t=>{e.push(l.getInstance(t))}),e}show(){if(this.isMultiple){this.getMultipleToggles().forEach(t=>!!t&&(t.isShown=!0)),this.el.closest("[data-hs-toggle-password-group]").classList.add("active")}else this.isShown=!0,this.el.classList.add("active");this.target.forEach(t=>{t.type="text"})}hide(){if(this.isMultiple){this.getMultipleToggles().forEach(t=>!!t&&(t.isShown=!1)),this.el.closest("[data-hs-toggle-password-group]").classList.remove("active")}else this.isShown=!1,this.el.classList.remove("active");this.target.forEach(t=>{t.type="password"})}destroy(){this.isMultiple?this.el.closest("[data-hs-toggle-password-group]").classList.remove("active"):this.el.classList.remove("active"),this.target.forEach(t=>{t.type="password"}),this.el.removeEventListener(this.eventType,this.onElementActionListener),this.isShown=!1,window.$hsTogglePasswordCollection=window.$hsTogglePasswordCollection.filter(({element:t})=>t.el!==this.el)}static getInstance(t,e){const s=window.$hsTogglePasswordCollection.find(e=>e.element.el===("string"==typeof t?document.querySelector(t):t));return s?e?s:s.element:null}static autoInit(){window.$hsTogglePasswordCollection||(window.$hsTogglePasswordCollection=[]),window.$hsTogglePasswordCollection&&(window.$hsTogglePasswordCollection=window.$hsTogglePasswordCollection.filter(({element:t})=>document.contains(t.el))),document.querySelectorAll("[data-hs-toggle-password]:not(.--prevent-on-load-init)").forEach(t=>{window.$hsTogglePasswordCollection.find(e=>{var s;return(null===(s=null==e?void 0:e.element)||void 0===s?void 0:s.el)===t})||new l(t)})}}const n=l},1926(t,e,s){s.d(e,{JD:()=>i,V6:()=>o});
18
18
  /*
19
- * @version: 5.0.0
19
+ * @version: 5.1.0
20
20
  * @author: Preline Labs Ltd.
21
21
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
22
22
  * Copyright 2024 Preline Labs Ltd.
package/non-auto.js CHANGED
@@ -1,7 +1,7 @@
1
1
  !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var o in s)("object"==typeof exports?exports:t)[o]=s[o]}}(self,()=>(()=>{"use strict";var t={2961(t,e){
2
2
  /*
3
3
  * HSBasePlugin
4
- * @version: 5.0.0
4
+ * @version: 5.1.0
5
5
  * @author: Preline Labs Ltd.
6
6
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
7
7
  * Copyright 2024 Preline Labs Ltd.
@@ -9,14 +9,14 @@
9
9
  Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(t,e,s){this.el=t,this.options=e,this.events=s,this.el=t,this.options=e,this.events={}}createCollection(t,e){var s,o;let i=t;if(!Array.isArray(i)&&"undefined"!=typeof window){const t=null===(s=this.constructor)||void 0===s?void 0:s.name,e="string"==typeof t&&t.startsWith("HS")?`$hs${t.slice(2)}Collection`:null;e&&(Array.isArray(window[e])||(window[e]=[]),i=window[e])}Array.isArray(i)&&i.push({id:(null===(o=null==e?void 0:e.el)||void 0===o?void 0:o.id)||i.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}},8549(t,e,s){
10
10
  /*
11
11
  * HSTogglePassword
12
- * @version: 5.0.0
12
+ * @version: 5.1.0
13
13
  * @author: Preline Labs Ltd.
14
14
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
15
15
  * Copyright 2024 Preline Labs Ltd.
16
16
  */
17
17
  var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=s(292),n=o(s(2961));class r extends n.default{constructor(t,e){super(t,e);const s=t.getAttribute("data-hs-toggle-password"),o=s?JSON.parse(s):{},n=Object.assign(Object.assign({},o),e),r=[];if((null==n?void 0:n.target)&&"string"==typeof(null==n?void 0:n.target)){(null==n?void 0:n.target.split(",")).forEach(t=>{r.push(document.querySelector(t))})}else(null==n?void 0:n.target)&&"object"==typeof(null==n?void 0:n.target)?n.target.forEach(t=>r.push(document.querySelector(t))):n.target.forEach(t=>r.push(t));this.target=r,this.isShown=!!this.el.hasAttribute("type")&&this.el.checked,this.eventType=(0,i.isFormElement)(this.el)?"change":"click",this.isMultiple=this.target.length>1&&!!this.el.closest("[data-hs-toggle-password-group]"),this.target&&this.init()}elementAction(){this.isShown?this.hide():this.show(),this.fireEvent("toggle",this.target),(0,i.dispatch)("toggle.hs.toggle-select",this.el,this.target)}init(){this.createCollection(window.$hsTogglePasswordCollection,this),this.isShown?this.show():this.hide(),this.onElementActionListener=()=>this.elementAction(),this.el.addEventListener(this.eventType,this.onElementActionListener)}getMultipleToggles(){const t=this.el.closest("[data-hs-toggle-password-group]").querySelectorAll("[data-hs-toggle-password]"),e=[];return t.forEach(t=>{e.push(r.getInstance(t))}),e}show(){if(this.isMultiple){this.getMultipleToggles().forEach(t=>!!t&&(t.isShown=!0)),this.el.closest("[data-hs-toggle-password-group]").classList.add("active")}else this.isShown=!0,this.el.classList.add("active");this.target.forEach(t=>{t.type="text"})}hide(){if(this.isMultiple){this.getMultipleToggles().forEach(t=>!!t&&(t.isShown=!1)),this.el.closest("[data-hs-toggle-password-group]").classList.remove("active")}else this.isShown=!1,this.el.classList.remove("active");this.target.forEach(t=>{t.type="password"})}destroy(){this.isMultiple?this.el.closest("[data-hs-toggle-password-group]").classList.remove("active"):this.el.classList.remove("active"),this.target.forEach(t=>{t.type="password"}),this.el.removeEventListener(this.eventType,this.onElementActionListener),this.isShown=!1,window.$hsTogglePasswordCollection=window.$hsTogglePasswordCollection.filter(({element:t})=>t.el!==this.el)}static getInstance(t,e){const s=window.$hsTogglePasswordCollection.find(e=>e.element.el===("string"==typeof t?document.querySelector(t):t));return s?e?s:s.element:null}static autoInit(){window.$hsTogglePasswordCollection||(window.$hsTogglePasswordCollection=[]),window.$hsTogglePasswordCollection&&(window.$hsTogglePasswordCollection=window.$hsTogglePasswordCollection.filter(({element:t})=>document.contains(t.el))),document.querySelectorAll("[data-hs-toggle-password]:not(.--prevent-on-load-init)").forEach(t=>{window.$hsTogglePasswordCollection.find(e=>{var s;return(null===(s=null==e?void 0:e.element)||void 0===s?void 0:s.el)===t})||new r(t)})}}e.default=r},292(t,e){
18
18
  /*
19
- * @version: 5.0.0
19
+ * @version: 5.1.0
20
20
  * @author: Preline Labs Ltd.
21
21
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
22
22
  * Copyright 2024 Preline Labs Ltd.
package/non-auto.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  var t={7615(t,e,s){s.d(e,{A:()=>o});
2
2
  /*
3
3
  * HSBasePlugin
4
- * @version: 5.0.0
4
+ * @version: 5.1.0
5
5
  * @author: Preline Labs Ltd.
6
6
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
7
7
  * Copyright 2024 Preline Labs Ltd.
8
8
  */
9
9
  class o{constructor(t,e,s){this.el=t,this.options=e,this.events=s,this.el=t,this.options=e,this.events={}}createCollection(t,e){var s,o;let i=t;if(!Array.isArray(i)&&"undefined"!=typeof window){const t=null===(s=this.constructor)||void 0===s?void 0:s.name,e="string"==typeof t&&t.startsWith("HS")?`$hs${t.slice(2)}Collection`:null;e&&(Array.isArray(window[e])||(window[e]=[]),i=window[e])}Array.isArray(i)&&i.push({id:(null===(o=null==e?void 0:e.el)||void 0===o?void 0:o.id)||i.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}},1926(t,e,s){s.d(e,{JD:()=>i,V6:()=>o});
10
10
  /*
11
- * @version: 5.0.0
11
+ * @version: 5.1.0
12
12
  * @author: Preline Labs Ltd.
13
13
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
14
14
  * Copyright 2024 Preline Labs Ltd.
@@ -16,7 +16,7 @@ class o{constructor(t,e,s){this.el=t,this.options=e,this.events=s,this.el=t,this
16
16
  const o=t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,i=(t,e,s=null)=>{const o=new CustomEvent(t,{detail:{payload:s},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(o)}}},e={};function s(o){var i=e[o];if(void 0!==i)return i.exports;var l=e[o]={exports:{}};return t[o](l,l.exports,s),l.exports}s.d=(t,e)=>{for(var o in e)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o={};s.d(o,{A:()=>r});var i=s(1926),l=s(7615);
17
17
  /*
18
18
  * HSTogglePassword
19
- * @version: 5.0.0
19
+ * @version: 5.1.0
20
20
  * @author: Preline Labs Ltd.
21
21
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
22
22
  * Copyright 2024 Preline Labs Ltd.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preline/toggle-password",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",