aeb-ui-kit 9.1.0-preview.1093 → 9.1.0-preview.1095
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/fesm2022/aeb-ui-kit.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import * as i1 from '@angular/common';
|
|
|
4
4
|
import { CommonModule, DOCUMENT, formatDate, formatNumber } from '@angular/common';
|
|
5
5
|
import * as i3 from '@angular/forms';
|
|
6
6
|
import { NG_VALUE_ACCESSOR, FormsModule, FormBuilder, FormControl, Validators, ReactiveFormsModule, NgControl } from '@angular/forms';
|
|
7
|
-
import { timer, map, takeUntil,
|
|
7
|
+
import { Subject, timer, map, takeUntil, Subscription, Observable, BehaviorSubject, withLatestFrom, filter, switchMap, take, merge, startWith, mergeMap, iif, of, tap, fromEvent, debounce, debounceTime } from 'rxjs';
|
|
8
8
|
import { trigger, state, transition, style, animate } from '@angular/animations';
|
|
9
9
|
import * as i2 from '@angular/platform-browser';
|
|
10
10
|
import { addWeeks, addDays, isSameMonth, getWeeksInMonth, startOfMonth, startOfWeek, addMonths, subMonths, eachYearOfInterval, getYear, addYears, subYears, differenceInYears, startOfYear, isToday, isValid, isSameDay, getMonth, setMonth, areIntervalsOverlapping, startOfDay, endOfDay, parse, format, getDaysInMonth, isExists, compareAsc, getDate } from 'date-fns';
|
|
@@ -558,6 +558,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
|
|
|
558
558
|
|
|
559
559
|
class CodeInputComponent {
|
|
560
560
|
constructor() {
|
|
561
|
+
this.destroy$ = new Subject();
|
|
561
562
|
this.secondsUntilRetry = 60;
|
|
562
563
|
this.errorMessage = 'Неверный код';
|
|
563
564
|
this.codeLength = 6;
|
|
@@ -572,13 +573,19 @@ class CodeInputComponent {
|
|
|
572
573
|
this.isFocus = false;
|
|
573
574
|
this.showTimer = false;
|
|
574
575
|
this.showCodeText = false;
|
|
576
|
+
this.onChange = () => { };
|
|
577
|
+
this.onTouch = () => { };
|
|
575
578
|
}
|
|
576
579
|
get arrayInputValue() {
|
|
577
580
|
return this.inputValue.split('');
|
|
578
581
|
}
|
|
579
582
|
ngOnInit() {
|
|
580
583
|
this.startTimer();
|
|
581
|
-
this.
|
|
584
|
+
this.handleAutofocus();
|
|
585
|
+
}
|
|
586
|
+
ngOnDestroy() {
|
|
587
|
+
this.destroy$.next();
|
|
588
|
+
this.destroy$.complete();
|
|
582
589
|
}
|
|
583
590
|
inputChangeHandler(event) {
|
|
584
591
|
const target = event.target;
|
|
@@ -614,13 +621,14 @@ class CodeInputComponent {
|
|
|
614
621
|
}
|
|
615
622
|
startTimer() {
|
|
616
623
|
this.showTimer = true;
|
|
617
|
-
|
|
624
|
+
this.showCodeText = false;
|
|
625
|
+
this.seconds$ = timer(0, 1000).pipe(map((i) => this.secondsUntilRetry - i), takeUntil(this.destroy$));
|
|
626
|
+
// Auto-stop timer when it reaches 0
|
|
627
|
+
this.seconds$.pipe(takeUntil(this.destroy$)).subscribe((seconds) => {
|
|
618
628
|
if (seconds <= 0) {
|
|
619
629
|
this.stopTimer();
|
|
620
630
|
}
|
|
621
|
-
|
|
622
|
-
}), takeUntil(timer((this.secondsUntilRetry + 1) * 1000)));
|
|
623
|
-
this.seconds$ = countdown$.pipe((i) => i);
|
|
631
|
+
});
|
|
624
632
|
}
|
|
625
633
|
stopTimer() {
|
|
626
634
|
this.showTimer = false;
|
|
@@ -638,10 +646,16 @@ class CodeInputComponent {
|
|
|
638
646
|
this.input.nativeElement.focus();
|
|
639
647
|
this.isFocus = true;
|
|
640
648
|
}
|
|
641
|
-
|
|
649
|
+
handleInputBlur() {
|
|
642
650
|
this.isFocus = false;
|
|
643
651
|
}
|
|
644
|
-
|
|
652
|
+
focus() {
|
|
653
|
+
if (this.input?.nativeElement) {
|
|
654
|
+
this.input.nativeElement.focus();
|
|
655
|
+
this.isFocus = true;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
handleAutofocus() {
|
|
645
659
|
if (this.isAutofocus) {
|
|
646
660
|
this.isFocus = true;
|
|
647
661
|
}
|
|
@@ -653,7 +667,7 @@ class CodeInputComponent {
|
|
|
653
667
|
useExisting: forwardRef(() => CodeInputComponent),
|
|
654
668
|
multi: true
|
|
655
669
|
}
|
|
656
|
-
], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true }], ngImport: i0, template: "<div class=\"aeb-code-input\">\n @if (title) {\n <h2 class=\"aeb-code-input__title\">{{ title }}</h2>\n }\n @if (tip) {\n <span class=\"aeb-code-input__tip\">{{ tip }}</span>\n }\n <div\n class=\"aeb-code-input__field-wrapper\"\n (click)=\"input.focus(); isFocus = true\"\n >\n <input\n class=\"aeb-code-input__field\"\n #input\n [maxLength]=\"codeLength\"\n [value]=\"inputValue\"\n [disabled]=\"disabled\"\n inputmode=\"numeric\"\n [autofocus]=\"isAutofocus\"\n autocomplete=\"one-time-code\"\n pattern=\"[0-9]\"\n (blur)=\"
|
|
670
|
+
], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true }], ngImport: i0, template: "<div class=\"aeb-code-input\">\n @if (title) {\n <h2 class=\"aeb-code-input__title\">{{ title }}</h2>\n }\n @if (tip) {\n <span class=\"aeb-code-input__tip\">{{ tip }}</span>\n }\n <div\n class=\"aeb-code-input__field-wrapper\"\n (click)=\"input.focus(); isFocus = true\"\n >\n <input\n class=\"aeb-code-input__field\"\n #input\n [maxLength]=\"codeLength\"\n [value]=\"inputValue\"\n [disabled]=\"disabled\"\n inputmode=\"numeric\"\n [autofocus]=\"isAutofocus\"\n autocomplete=\"one-time-code\"\n pattern=\"[0-9]\"\n (blur)=\"handleInputBlur()\"\n (keypress)=\"numbersOnly($event)\"\n (input)=\"inputChangeHandler($event)\"\n />\n @for (value of [].constructor(codeLength); track $index) {\n <span\n class=\"aeb-code-input__field-input\"\n [ngClass]=\"{\n 'aeb-code-input__field-input--active':\n inputValue.length === $index && isFocus && !disabled,\n 'aeb-code-input__field-input--has-error': hasError\n }\"\n >\n {{ arrayInputValue[$index] }}\n <div\n [ngClass]=\"{\n 'aeb-code-input__field-input-caret':\n inputValue.length === $index && isFocus && !disabled,\n 'aeb-code-input__field-input-caret--has-error':\n inputValue.length === $index && isFocus && !disabled && hasError\n }\"\n ></div>\n </span>\n }\n </div>\n @if (hasError || isResendable) {\n <div class=\"aeb-code-input__text\">\n @if (hasError) {\n <span class=\"aeb-code-input__text-wrong\">{{ errorMessage }}</span>\n }\n @if (isResendable) {\n @if (showTimer) {\n <div class=\"aeb-code-input__text-wrapper\">\n <span class=\"aeb-code-input__text-info\"\n >\u0417\u0430\u043F\u0440\u043E\u0441\u0438\u0442\u044C \u043F\u043E\u0432\u0442\u043E\u0440\u043D\u0443\u044E \u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0443 \u043C\u043E\u0436\u043D\u043E \u0447\u0435\u0440\u0435\u0437\n </span>\n <span class=\"aeb-code-input__text-time\">{{\n seconds$ | async\n }}</span>\n </div>\n }\n @if (showCodeText) {\n <span class=\"aeb-code-input__text-again\" (click)=\"resend()\"\n >\u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u0434 \u043F\u043E\u0432\u0442\u043E\u0440\u043D\u043E</span\n >\n }\n }\n </div>\n }\n</div>\n", styles: [".aeb-code-input{display:flex;flex-direction:column;align-items:center;color:var(--c-t-primary);background-color:none}@media screen and (max-width: 599px){.aeb-code-input{width:100%;box-sizing:border-box}}.aeb-code-input__field-wrapper{position:relative;display:flex;justify-content:center;gap:16px}.aeb-code-input__field{position:absolute;width:100%;height:56px;box-sizing:border-box;background:transparent;border:none;color:transparent;outline:none;-webkit-user-select:none;user-select:none;caret-color:transparent;z-index:10;pointer-events:none}.aeb-code-input__field::selection{background:transparent}.aeb-code-input__field-input{width:56px;height:64px;display:flex;justify-content:center;align-items:center;border:var(--border-skinny) solid var(--c-bg-surface-medium);border-radius:var(--border-rounded);box-sizing:border-box;font-size:var(--font-size-lm);font-weight:500;cursor:text}@media screen and (max-width: 599px){.aeb-code-input__field-input{width:48px;height:56px;font-size:var(--font-size-l)}}.aeb-code-input__field-input--active{border:var(--border-skinny) solid var(--c-t-links)}.aeb-code-input__field-input--has-error{border:var(--border-skinny) solid var(--c-t-critical);background-color:var(--c-btn-ws-default)}.aeb-code-input__field-input-caret{width:2px;height:24px;background-color:var(--c-t-links);animation-name:flicker;animation-duration:1s;animation-iteration-count:infinite}.aeb-code-input__field-input-caret--has-error{background-color:var(--c-t-critical)}@keyframes flicker{0%{opacity:0}to{opacity:1}}.aeb-code-input__title{width:fit-content;margin:0 0 16px;font-size:var(--font-size-l);text-align:center;font-weight:500}@media screen and (max-width: 599px){.aeb-code-input__title{font-size:18px;margin:0 0 8px}}.aeb-code-input__tip{margin-bottom:32px;text-align:center;color:var(--c-t-secondary)}@media screen and (max-width: 599px){.aeb-code-input__tip{font-size:14px;margin-bottom:24px}}.aeb-code-input__text{display:flex;flex-direction:column;align-items:center;margin-top:32px;font-size:var(--font-size-s);line-height:20px}@media screen and (max-width: 599px){.aeb-code-input__text{margin-top:24px;font-size:14px}}.aeb-code-input__text-wrapper{text-align:center}.aeb-code-input__text-info{color:var(--c-t-secondary)}.aeb-code-input__text-time{color:var(--c-t-links)}.aeb-code-input__text-again{color:var(--c-t-links);cursor:pointer}.aeb-code-input__text-wrong{color:var(--c-t-critical);text-align:center;font-size:16px}@media screen and (max-width: 599px){.aeb-code-input__text-wrong{font-size:12px}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: AutofocusDirective, selector: "[autofocus]", inputs: ["autofocus"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
657
671
|
}
|
|
658
672
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: CodeInputComponent, decorators: [{
|
|
659
673
|
type: Component,
|
|
@@ -663,7 +677,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
|
|
|
663
677
|
useExisting: forwardRef(() => CodeInputComponent),
|
|
664
678
|
multi: true
|
|
665
679
|
}
|
|
666
|
-
], encapsulation: ViewEncapsulation.None, standalone: false, template: "<div class=\"aeb-code-input\">\n @if (title) {\n <h2 class=\"aeb-code-input__title\">{{ title }}</h2>\n }\n @if (tip) {\n <span class=\"aeb-code-input__tip\">{{ tip }}</span>\n }\n <div\n class=\"aeb-code-input__field-wrapper\"\n (click)=\"input.focus(); isFocus = true\"\n >\n <input\n class=\"aeb-code-input__field\"\n #input\n [maxLength]=\"codeLength\"\n [value]=\"inputValue\"\n [disabled]=\"disabled\"\n inputmode=\"numeric\"\n [autofocus]=\"isAutofocus\"\n autocomplete=\"one-time-code\"\n pattern=\"[0-9]\"\n (blur)=\"
|
|
680
|
+
], encapsulation: ViewEncapsulation.None, standalone: false, template: "<div class=\"aeb-code-input\">\n @if (title) {\n <h2 class=\"aeb-code-input__title\">{{ title }}</h2>\n }\n @if (tip) {\n <span class=\"aeb-code-input__tip\">{{ tip }}</span>\n }\n <div\n class=\"aeb-code-input__field-wrapper\"\n (click)=\"input.focus(); isFocus = true\"\n >\n <input\n class=\"aeb-code-input__field\"\n #input\n [maxLength]=\"codeLength\"\n [value]=\"inputValue\"\n [disabled]=\"disabled\"\n inputmode=\"numeric\"\n [autofocus]=\"isAutofocus\"\n autocomplete=\"one-time-code\"\n pattern=\"[0-9]\"\n (blur)=\"handleInputBlur()\"\n (keypress)=\"numbersOnly($event)\"\n (input)=\"inputChangeHandler($event)\"\n />\n @for (value of [].constructor(codeLength); track $index) {\n <span\n class=\"aeb-code-input__field-input\"\n [ngClass]=\"{\n 'aeb-code-input__field-input--active':\n inputValue.length === $index && isFocus && !disabled,\n 'aeb-code-input__field-input--has-error': hasError\n }\"\n >\n {{ arrayInputValue[$index] }}\n <div\n [ngClass]=\"{\n 'aeb-code-input__field-input-caret':\n inputValue.length === $index && isFocus && !disabled,\n 'aeb-code-input__field-input-caret--has-error':\n inputValue.length === $index && isFocus && !disabled && hasError\n }\"\n ></div>\n </span>\n }\n </div>\n @if (hasError || isResendable) {\n <div class=\"aeb-code-input__text\">\n @if (hasError) {\n <span class=\"aeb-code-input__text-wrong\">{{ errorMessage }}</span>\n }\n @if (isResendable) {\n @if (showTimer) {\n <div class=\"aeb-code-input__text-wrapper\">\n <span class=\"aeb-code-input__text-info\"\n >\u0417\u0430\u043F\u0440\u043E\u0441\u0438\u0442\u044C \u043F\u043E\u0432\u0442\u043E\u0440\u043D\u0443\u044E \u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0443 \u043C\u043E\u0436\u043D\u043E \u0447\u0435\u0440\u0435\u0437\n </span>\n <span class=\"aeb-code-input__text-time\">{{\n seconds$ | async\n }}</span>\n </div>\n }\n @if (showCodeText) {\n <span class=\"aeb-code-input__text-again\" (click)=\"resend()\"\n >\u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u0434 \u043F\u043E\u0432\u0442\u043E\u0440\u043D\u043E</span\n >\n }\n }\n </div>\n }\n</div>\n", styles: [".aeb-code-input{display:flex;flex-direction:column;align-items:center;color:var(--c-t-primary);background-color:none}@media screen and (max-width: 599px){.aeb-code-input{width:100%;box-sizing:border-box}}.aeb-code-input__field-wrapper{position:relative;display:flex;justify-content:center;gap:16px}.aeb-code-input__field{position:absolute;width:100%;height:56px;box-sizing:border-box;background:transparent;border:none;color:transparent;outline:none;-webkit-user-select:none;user-select:none;caret-color:transparent;z-index:10;pointer-events:none}.aeb-code-input__field::selection{background:transparent}.aeb-code-input__field-input{width:56px;height:64px;display:flex;justify-content:center;align-items:center;border:var(--border-skinny) solid var(--c-bg-surface-medium);border-radius:var(--border-rounded);box-sizing:border-box;font-size:var(--font-size-lm);font-weight:500;cursor:text}@media screen and (max-width: 599px){.aeb-code-input__field-input{width:48px;height:56px;font-size:var(--font-size-l)}}.aeb-code-input__field-input--active{border:var(--border-skinny) solid var(--c-t-links)}.aeb-code-input__field-input--has-error{border:var(--border-skinny) solid var(--c-t-critical);background-color:var(--c-btn-ws-default)}.aeb-code-input__field-input-caret{width:2px;height:24px;background-color:var(--c-t-links);animation-name:flicker;animation-duration:1s;animation-iteration-count:infinite}.aeb-code-input__field-input-caret--has-error{background-color:var(--c-t-critical)}@keyframes flicker{0%{opacity:0}to{opacity:1}}.aeb-code-input__title{width:fit-content;margin:0 0 16px;font-size:var(--font-size-l);text-align:center;font-weight:500}@media screen and (max-width: 599px){.aeb-code-input__title{font-size:18px;margin:0 0 8px}}.aeb-code-input__tip{margin-bottom:32px;text-align:center;color:var(--c-t-secondary)}@media screen and (max-width: 599px){.aeb-code-input__tip{font-size:14px;margin-bottom:24px}}.aeb-code-input__text{display:flex;flex-direction:column;align-items:center;margin-top:32px;font-size:var(--font-size-s);line-height:20px}@media screen and (max-width: 599px){.aeb-code-input__text{margin-top:24px;font-size:14px}}.aeb-code-input__text-wrapper{text-align:center}.aeb-code-input__text-info{color:var(--c-t-secondary)}.aeb-code-input__text-time{color:var(--c-t-links)}.aeb-code-input__text-again{color:var(--c-t-links);cursor:pointer}.aeb-code-input__text-wrong{color:var(--c-t-critical);text-align:center;font-size:16px}@media screen and (max-width: 599px){.aeb-code-input__text-wrong{font-size:12px}}\n"] }]
|
|
667
681
|
}], propDecorators: { title: [{
|
|
668
682
|
type: Input
|
|
669
683
|
}], secondsUntilRetry: [{
|