@preline/toggle-password 2.0.0 → 2.0.2
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.d.ts +7 -17
- package/index.js +17 -2
- package/package.json +3 -28
package/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
export interface ITogglePasswordOptions {
|
|
2
3
|
target: string | string[] | HTMLInputElement | HTMLInputElement[];
|
|
3
4
|
}
|
|
@@ -16,22 +17,13 @@ declare class HSBasePlugin<O, E = HTMLElement> implements IBasePlugin<O, E> {
|
|
|
16
17
|
options: O;
|
|
17
18
|
events?: any;
|
|
18
19
|
constructor(el: E, options: O, events?: any);
|
|
19
|
-
isIOS(): boolean;
|
|
20
|
-
isIpadOS(): boolean;
|
|
21
20
|
createCollection(collection: any[], element: any): void;
|
|
22
21
|
fireEvent(evt: string, payload?: any): any;
|
|
23
|
-
dispatch(evt: string, element: any, payload?: any): void;
|
|
24
22
|
on(evt: string, cb: Function): void;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
htmlToElement(html: string): HTMLElement;
|
|
30
|
-
classToClassList(classes: string, target: HTMLElement, splitter?: string): void;
|
|
31
|
-
debounce(func: Function, timeout?: number): (...args: any[]) => void;
|
|
32
|
-
checkIfFormElement(target: HTMLElement): boolean;
|
|
33
|
-
static isEnoughSpace(el: HTMLElement, toggle: HTMLElement, preferredPosition?: "top" | "bottom" | "auto", space?: number, wrapper?: HTMLElement | null): boolean;
|
|
34
|
-
static isParentOrElementHidden(element: any): any;
|
|
23
|
+
}
|
|
24
|
+
export interface ICollectionItem<T> {
|
|
25
|
+
id: string | number;
|
|
26
|
+
element: T;
|
|
35
27
|
}
|
|
36
28
|
declare class HSTogglePassword extends HSBasePlugin<ITogglePasswordOptions> implements ITogglePassword {
|
|
37
29
|
private readonly target;
|
|
@@ -43,10 +35,8 @@ declare class HSTogglePassword extends HSBasePlugin<ITogglePasswordOptions> impl
|
|
|
43
35
|
private getMultipleToggles;
|
|
44
36
|
show(): void;
|
|
45
37
|
hide(): void;
|
|
46
|
-
static getInstance(target: HTMLElement | string, isInstance?: boolean): HSTogglePassword |
|
|
47
|
-
|
|
48
|
-
element: HSTogglePassword;
|
|
49
|
-
};
|
|
38
|
+
static getInstance(target: HTMLElement | string, isInstance?: boolean): HSTogglePassword | ICollectionItem<HSTogglePassword>;
|
|
39
|
+
static autoInit(): void;
|
|
50
40
|
}
|
|
51
41
|
|
|
52
42
|
export {
|
package/index.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 n=e();for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(self,(()=>(()=>{"use strict";var t={737:(t,e)=>{
|
|
2
|
+
/*
|
|
3
|
+
* HSBasePlugin
|
|
4
|
+
* @version: 2.0.3
|
|
5
|
+
* @author: HTMLStream
|
|
6
|
+
* @license: Licensed under MIT (https://preline.co/docs/license.html)
|
|
7
|
+
* Copyright 2023 HTMLStream
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e,n){this.el=t,this.options=e,this.events=n,this.el=t,this.options=e,this.events={}}return t.prototype.createCollection=function(t,e){var n;t.push({id:(null===(n=null==e?void 0:e.el)||void 0===n?void 0:n.id)||t.length+1,element:e})},t.prototype.fireEvent=function(t,e){if(void 0===e&&(e=null),this.events.hasOwnProperty(t))return this.events[t](e)},t.prototype.on=function(t,e){this.events[t]=e},t}();e.default=n},366:function(t,e,n){
|
|
10
|
+
/*
|
|
11
|
+
* HSTogglePassword
|
|
12
|
+
* @version: 2.0.3
|
|
13
|
+
* @author: HTMLStream
|
|
14
|
+
* @license: Licensed under MIT (https://preline.co/docs/license.html)
|
|
15
|
+
* Copyright 2023 HTMLStream
|
|
16
|
+
*/
|
|
17
|
+
var o,i=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var s=n(969),l=function(t){function e(e,n){var o=t.call(this,e,n)||this,i=e.getAttribute("data-hs-toggle-password"),l=i?JSON.parse(i):{},a=r(r({},l),n),u=[];(null==a?void 0:a.target)&&"string"==typeof(null==a?void 0:a.target)?(null==a?void 0:a.target.split(",")).forEach((function(t){u.push(document.querySelector(t))})):(null==a?void 0:a.target)&&"object"==typeof(null==a?void 0:a.target)?a.target.forEach((function(t){return u.push(document.querySelector(t))})):a.target.forEach((function(t){return u.push(t)}));return o.target=u,o.isShown=!!o.el.hasAttribute("type")&&o.el.checked,o.eventType=(0,s.isFormElement)(o.el)?"change":"click",o.isMultiple=o.target.length>1&&!!o.el.closest("[data-hs-toggle-password-group]"),o.target&&o.init(),o}return i(e,t),e.prototype.init=function(){var t=this;this.createCollection(window.$hsTogglePasswordCollection,this),this.isShown?this.show():this.hide(),this.el.addEventListener(this.eventType,(function(){t.isShown?t.hide():t.show(),t.fireEvent("toggle",t.target),(0,s.dispatch)("toggle.hs.toggle-select",t.el,t.target)}))},e.prototype.getMultipleToggles=function(){var t=this.el.closest("[data-hs-toggle-password-group]").querySelectorAll("[data-hs-toggle-password]"),n=[];return t.forEach((function(t){n.push(e.getInstance(t))})),n},e.prototype.show=function(){this.isMultiple?(this.getMultipleToggles().forEach((function(t){return!!t&&(t.isShown=!0)})),this.el.closest("[data-hs-toggle-password-group]").classList.add("active")):(this.isShown=!0,this.el.classList.add("active"));this.target.forEach((function(t){t.type="text"}))},e.prototype.hide=function(){this.isMultiple?(this.getMultipleToggles().forEach((function(t){return!!t&&(t.isShown=!1)})),this.el.closest("[data-hs-toggle-password-group]").classList.remove("active")):(this.isShown=!1,this.el.classList.remove("active"));this.target.forEach((function(t){t.type="password"}))},e.getInstance=function(t,e){var n=window.$hsTogglePasswordCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return n?e?n:n.element:null},e.autoInit=function(){window.$hsTogglePasswordCollection||(window.$hsTogglePasswordCollection=[]),document.querySelectorAll("[data-hs-toggle-password]:not(.--prevent-on-load-init)").forEach((function(t){window.$hsTogglePasswordCollection.find((function(e){var n;return(null===(n=null==e?void 0:e.element)||void 0===n?void 0:n.el)===t}))||new e(t)}))},e}(n(737).default);window.addEventListener("load",(function(){l.autoInit()})),"undefined"!=typeof window&&(window.HSTogglePassword=l),e.default=l},969:function(t,e){var n=this;Object.defineProperty(e,"__esModule",{value:!0}),e.menuSearchHistory=e.classToClassList=e.htmlToElement=e.afterTransition=e.dispatch=e.debounce=e.isFormElement=e.isParentOrElementHidden=e.isEnoughSpace=e.isIpadOS=e.isIOS=e.getClassPropertyAlt=e.getClassProperty=void 0;e.getClassProperty=function(t,e,n){return void 0===n&&(n=""),(window.getComputedStyle(t).getPropertyValue(e)||n).replace(" ","")};e.getClassPropertyAlt=function(t,e,n){void 0===n&&(n="");var o="";return t.classList.forEach((function(t){t.includes(e)&&(o=t)})),o.match(/:(.*)]/)?o.match(/:(.*)]/)[1]:n};e.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isEnoughSpace=function(t,e,n,o,i){void 0===n&&(n="auto"),void 0===o&&(o=10),void 0===i&&(i=null);var r=e.getBoundingClientRect(),s=i?i.getBoundingClientRect():null,l=window.innerHeight,a=s?r.top-s.top:r.top,u=(i?s.bottom:l)-r.bottom,c=t.clientHeight+o;return"bottom"===n?u>=c:"top"===n?a>=c:a>=c||u>=c};e.isFormElement=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement};var o=function(t){return!!t&&("none"===window.getComputedStyle(t).display||o(t.parentElement))};e.isParentOrElementHidden=o;e.debounce=function(t,e){var o;return void 0===e&&(e=200),function(){for(var i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];clearTimeout(o),o=setTimeout((function(){t.apply(n,i)}),e)}};e.dispatch=function(t,e,n){void 0===n&&(n=null);var o=new CustomEvent(t,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(o)};e.afterTransition=function(t,e){var n=function(){e(),t.removeEventListener("transitionend",n,!0)};"all 0s ease 0s"!==window.getComputedStyle(t,null).getPropertyValue("transition")?t.addEventListener("transitionend",n,!0):e()};e.htmlToElement=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=function(t,e,n){void 0===n&&(n=" "),t.split(n).forEach((function(t){return e.classList.add(t)}))};e.menuSearchHistory={historyIndex:-1,addHistory:function(t){this.historyIndex=t},existsInHistory:function(t){return t>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},e={};var n=function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={exports:{}};return t[o].call(r.exports,r,r.exports,n),r.exports}(366);return n})()));
|
package/package.json
CHANGED
|
@@ -1,40 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preline/toggle-password",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
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",
|
|
7
7
|
"repository": "https://github.com/htmlstreamofficial/preline.git",
|
|
8
8
|
"homepage": "https://preline.co/plugins.html",
|
|
9
|
-
"keywords": [
|
|
10
|
-
"preline",
|
|
11
|
-
"html",
|
|
12
|
-
"css",
|
|
13
|
-
"next",
|
|
14
|
-
"nuxt",
|
|
15
|
-
"vue",
|
|
16
|
-
"react",
|
|
17
|
-
"angular",
|
|
18
|
-
"javascript",
|
|
19
|
-
"typescript",
|
|
20
|
-
"tailwind",
|
|
21
|
-
"tailwind components",
|
|
22
|
-
"tailwind elements",
|
|
23
|
-
"tailwind library",
|
|
24
|
-
"tailwind sections",
|
|
25
|
-
"tailwind css",
|
|
26
|
-
"tailwind ui",
|
|
27
|
-
"tailwind css react",
|
|
28
|
-
"tailwind css vue",
|
|
29
|
-
"tailwind css angular",
|
|
30
|
-
"tailwind css laravel",
|
|
31
|
-
"tailwindcss plugin",
|
|
32
|
-
"tailwindcss plugins",
|
|
33
|
-
"toggle password"
|
|
34
|
-
],
|
|
9
|
+
"keywords": ["preline", "html", "css", "next", "nuxt", "vue", "react", "angular", "javascript", "typescript", "tailwind", "tailwind components", "tailwind elements", "tailwind library", "tailwind sections", "tailwind css", "tailwind ui", "tailwind css react", "tailwind css vue", "tailwind css angular", "tailwind css laravel", "tailwindcss plugin", "tailwindcss plugins", "accordion"],
|
|
35
10
|
"author": "Htmlstream",
|
|
36
11
|
"license": "MIT",
|
|
37
12
|
"publishConfig": {
|
|
38
13
|
"access": "public"
|
|
39
14
|
}
|
|
40
|
-
}
|
|
15
|
+
}
|