Spaccogram/webk/public/htmlToSpan-D4DA0RUe.js.map

1 line
7.2 KiB
Plaintext
Raw Normal View History

{"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 && c