1 line
7.2 KiB
Plaintext
1 line
7.2 KiB
Plaintext
{"version":3,"file":"htmlToSpan-D4DA0RUe.js","sources":["../src/components/passwordInputField.ts","../src/components/monkeys/password.ts","../src/helpers/dom/htmlToSpan.ts"],"sourcesContent":["/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nimport cancelEvent from '../helpers/dom/cancelEvent';\nimport Icon from './icon';\nimport InputField, {InputFieldOptions} from './inputField';\n\nexport class PasswordInputHelpers {\n public passwordVisible = false;\n public toggleVisible: HTMLElement;\n public onVisibilityClickAdditional: () => void;\n\n constructor(public container: HTMLElement, public input: HTMLInputElement) {\n input.type = 'password';\n input.setAttribute('required', '');\n input.name = 'notsearch_password';\n input.autocomplete = 'off';\n\n // * https://stackoverflow.com/a/35949954/6758968\n const stealthy = document.createElement('input');\n stealthy.classList.add('stealthy');\n stealthy.tabIndex = -1;\n stealthy.type = 'password';\n input.parentElement.prepend(stealthy);\n input.parentElement.insertBefore(stealthy.cloneNode(), input.nextSibling);\n\n /* if(IS_SAFARI && !IS_MOBILE_SAFARI) {\n input.setAttribute('readonly', '');\n input.addEventListener('focus', () => {\n input.removeAttribute('readonly');\n }, {once: true});\n } */\n\n const toggleVisible = this.toggleVisible = document.createElement('span');\n toggleVisible.classList.add('toggle-visible');\n toggleVisible.append(Icon('eye1'));\n\n container.classList.add('input-field-password');\n container.append(toggleVisible);\n\n toggleVisible.addEventListener('click', this.onVisibilityClick);\n toggleVisible.addEventListener('touchend', this.onVisibilityClick);\n }\n\n public onVisibilityClick = (e: Event) => {\n cancelEvent(e);\n this.passwordVisible = !this.passwordVisible;\n\n this.toggleVisible.replaceChildren(Icon(this.passwordVisible ? 'eye2' : 'eye1'));\n (this.input as HTMLInputElement).type = this.passwordVisible ? 'text' : 'password';\n this.onVisibilityClickAdditional?.();\n };\n}\n\nexport default class PasswordInputField extends InputField {\n public helpers: PasswordInputHelpers;\n\n constructor(options: InputFieldOptions = {}) {\n super({\n plainText: true,\n allowStartingSpace: true,\n ...options\n });\n\n this.helpers = new PasswordInputHelpers(this.container, this.input as HTMLInputElement);\n }\n}\n","/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nimport lottieLoader, {LottieLoader} from '../../lib/rlottie/lottieLoader';\nimport RLottiePlayer from '../../lib/rlottie/rlottiePlayer';\nimport PasswordInputField from '../passwordInputField';\n\nexport default class PasswordMonkey {\n public container: HTMLElement;\n public animation: RLottiePlayer;\n public needFrame = 0;\n protected loadPromise: ReturnType<LottieLoader['waitForFirstFrame']>;\n\n constructor(protected passwordInputField: PasswordInputField, protected size: number) {\n this.container = document.createElement('div');\n this.container.classList.add('media-sticker-wrapper');\n }\n\n public load() {\n if(this.loadPromise) return this.loadPromise;\n return this.loadPromise = lottieLoader.loadAnimationAsAsset({\n container: this.container,\n loop: false,\n autoplay: false,\n width: this.size,\n height: this.size,\n noCache: true\n // }, 'assets/img/TwoFactorSetupMonkeyClose.tgs').then((_animation) => {\n }, 'TwoFactorSetupMonkeyPeek').then((_animation) => {\n // return;\n this.animation = _animation;\n this.animation.addEventListener('enterFrame', currentFrame => {\n // console.log('enterFrame', currentFrame, this.needFrame);\n\n if((this.animation.direction === 1 && currentFrame >= this.needFrame) ||\n (this.animation.direction === -1 && currentFrame <= this.needFrame)) {\n this.animation.setSpeed(1);\n this.animation.pause();\n }\n });\n\n this.passwordInputField.helpers.onVisibilityClickAdditional = () => {\n if(this.passwordInputField.helpers.passwordVisible) {\n this.animation.setDirection(1);\n this.animation.curFrame = 0;\n this.needFrame = 16;\n this.animation.play();\n } else {\n this.animation.setDirection(-1);\n this.animation.curFrame = 16;\n this.needFrame = 0;\n this.animation.play();\n }\n };\n\n return lottieLoader.waitForFirstFrame(_animation);\n });\n }\n\n public remove() {\n if(this.animation) {\n this.animation.remove();\n }\n }\n}\n","/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nexport default function htmlToSpan(html: string | DocumentFragment) {\n const span = document.createElement('span');\n if(typeof(html) === 'string') span.innerHTML = html;\n else span.append(html);\n return span;\n}\n"],"names":["PasswordInputHelpers","container","input","e","cancelEvent","Icon","stealthy","toggleVisible","PasswordInputField","InputField","options","PasswordMonkey","passwordInputField","size","lottieLoader","_animation","currentFrame","htmlToSpan","html","span"],"mappings":"wIAUO,MAAMA,CAAqB,CAKhC,YAAmBC,EAA+BC,EAAyB,CAAxD,KAAA,UAAAD,EAA+B,KAAA,MAAAC,EAJlD,KAAO,gBAAkB,GAoClB,KAAA,kBAAqBC,GAAa,CACvCC,EAAYD,CAAC,EACR,KAAA,gBAAkB,CAAC,KAAK,gBAE7B,KAAK,cAAc,gBAAgBE,EAAK,KAAK,gBAAkB,OAAS,MAAM,CAAC,EAC9E,KAAK,MAA2B,KAAO,KAAK,gBAAkB,OAAS,WACxE,KAAK,8BAA8B,CAAA,EArCnCH,EAAM,KAAO,WACPA,EAAA,aAAa,WAAY,EAAE,EACjCA,EAAM,KAAO,qBACbA,EAAM,aAAe,MAGf,MAAAI,EAAW,SAAS,cAAc,OAAO,EACtCA,EAAA,UAAU,IAAI,UAAU,EACjCA,EAAS,SAAW,GACpBA,EAAS,KAAO,WACVJ,EAAA,cAAc,QAAQI,CAAQ,EACpCJ,EAAM,cAAc,aAAaI,EAAS,YAAaJ,EAAM,WAAW,EASxE,MAAMK,EAAgB,KAAK,cAAgB,SAAS,cAAc,MAAM,EAC1DA,EAAA,UAAU,IAAI,gBAAgB,EAC9BA,EAAA,OAAOF,EAAK,MAAM,CAAC,EAEvBJ,EAAA,UAAU,IAAI,sBAAsB,EAC9CA,EAAU,OAAOM,CAAa,EAEhBA,EAAA,iBAAiB,QAAS,KAAK,iBAAiB,EAChDA,EAAA,iBAAiB,WAAY,KAAK,i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