aeb-ui-kit 10.0.0-mr.1206-feature-fix-error-message → 10.0.0-mr.1211-feature-update-code-input
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 +41 -17
- package/package.json +1 -1
- package/types/aeb-ui-kit.d.ts +6 -5
package/fesm2022/aeb-ui-kit.mjs
CHANGED
|
@@ -341,6 +341,7 @@ class CodeInput {
|
|
|
341
341
|
constructor() {
|
|
342
342
|
this._destroy$ = new Subject();
|
|
343
343
|
this._timerSub = null;
|
|
344
|
+
this._isComposing = false;
|
|
344
345
|
this._disabled = signal(false, ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
|
|
345
346
|
this._isFocus = signal(false, ...(ngDevMode ? [{ debugName: "_isFocus" }] : /* istanbul ignore next */ []));
|
|
346
347
|
this._inputValue = signal('', ...(ngDevMode ? [{ debugName: "_inputValue" }] : /* istanbul ignore next */ []));
|
|
@@ -377,27 +378,47 @@ class CodeInput {
|
|
|
377
378
|
this._destroy$.complete();
|
|
378
379
|
}
|
|
379
380
|
inputChangeHandler(event) {
|
|
381
|
+
if (!(event.target instanceof HTMLInputElement)) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
if (event.type === 'compositionstart') {
|
|
385
|
+
this._isComposing = true;
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (event.type === 'compositionend') {
|
|
389
|
+
this._isComposing = false;
|
|
390
|
+
}
|
|
391
|
+
else if (this._isComposing ||
|
|
392
|
+
(event instanceof InputEvent && event.isComposing)) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
380
395
|
const target = event.target;
|
|
381
|
-
|
|
382
|
-
this.
|
|
383
|
-
if (
|
|
384
|
-
|
|
396
|
+
const rawValue = target.value;
|
|
397
|
+
const value = this.normalizeValue(rawValue);
|
|
398
|
+
if (rawValue !== value) {
|
|
399
|
+
const start = target.selectionStart;
|
|
400
|
+
const end = target.selectionEnd;
|
|
401
|
+
const direction = target.selectionDirection;
|
|
402
|
+
target.value = value;
|
|
403
|
+
if (start !== null && end !== null) {
|
|
404
|
+
target.setSelectionRange(this.normalizeValue(rawValue.slice(0, start)).length, this.normalizeValue(rawValue.slice(0, end)).length, direction ?? undefined);
|
|
405
|
+
}
|
|
385
406
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const key = e.key;
|
|
389
|
-
if (/\d/.test(key)) {
|
|
390
|
-
return true;
|
|
407
|
+
if (value === this.inputValue) {
|
|
408
|
+
return;
|
|
391
409
|
}
|
|
392
|
-
|
|
393
|
-
|
|
410
|
+
this.inputValue = value;
|
|
411
|
+
this.onChange(value);
|
|
412
|
+
if (this.inputValue === value && value.length === this.codeLength()) {
|
|
413
|
+
this.codeCompleted.emit(value);
|
|
394
414
|
}
|
|
395
415
|
}
|
|
396
416
|
writeValue(value) {
|
|
397
|
-
this.
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
417
|
+
const normalizedValue = this.normalizeValue(value ?? '');
|
|
418
|
+
this._inputValue.set(normalizedValue);
|
|
419
|
+
const target = this.input()?.nativeElement;
|
|
420
|
+
if (target && target.value !== normalizedValue) {
|
|
421
|
+
target.value = normalizedValue;
|
|
401
422
|
}
|
|
402
423
|
}
|
|
403
424
|
setDisabledState(isDisabled) {
|
|
@@ -452,6 +473,9 @@ class CodeInput {
|
|
|
452
473
|
this.isFocus = true;
|
|
453
474
|
}
|
|
454
475
|
}
|
|
476
|
+
normalizeValue(value) {
|
|
477
|
+
return value.replace(/[^0-9]/g, '').slice(0, this.codeLength());
|
|
478
|
+
}
|
|
455
479
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: CodeInput, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
456
480
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: CodeInput, isStandalone: true, selector: "aeb-code-input", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, tip: { classPropertyName: "tip", publicName: "tip", isSignal: true, isRequired: false, transformFunction: null }, initialDisabled: { classPropertyName: "initialDisabled", publicName: "initialDisabled", isSignal: true, isRequired: false, transformFunction: null }, hasError: { classPropertyName: "hasError", publicName: "hasError", isSignal: true, isRequired: false, transformFunction: null }, isResendable: { classPropertyName: "isResendable", publicName: "isResendable", isSignal: true, isRequired: false, transformFunction: null }, secondsUntilRetry: { classPropertyName: "secondsUntilRetry", publicName: "secondsUntilRetry", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, codeLength: { classPropertyName: "codeLength", publicName: "codeLength", isSignal: true, isRequired: false, transformFunction: null }, isAutofocus: { classPropertyName: "isAutofocus", publicName: "isAutofocus", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { codeCompleted: "codeCompleted", timeOut: "timeOut", resendClick: "resendClick" }, host: { classAttribute: "aeb-code-input" }, providers: [
|
|
457
481
|
{
|
|
@@ -459,7 +483,7 @@ class CodeInput {
|
|
|
459
483
|
useExisting: forwardRef(() => CodeInput),
|
|
460
484
|
multi: true
|
|
461
485
|
}
|
|
462
|
-
], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (title()) {\n<h2 class=\"aeb-code-input__title\">{{ title() }}</h2>\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 [
|
|
486
|
+
], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (title()) {\n<h2 class=\"aeb-code-input__title\">{{ title() }}</h2>\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 [value]=\"inputValue\"\n [disabled]=\"disabled\"\n inputmode=\"numeric\"\n [autofocus]=\"isAutofocus()\"\n autocomplete=\"one-time-code\"\n pattern=\"[0-9]*\"\n (blur)=\"handleInputBlur()\"\n (input)=\"inputChangeHandler($event)\"\n (compositionstart)=\"inputChangeHandler($event)\"\n (compositionend)=\"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 } @if (isResendable()) { @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\">{{ seconds() }}</span>\n </div>\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</div>\n}\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:var(--z-dropdown);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: AutofocusDirective, selector: "[autofocus]", inputs: ["autofocus"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
463
487
|
}
|
|
464
488
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: CodeInput, decorators: [{
|
|
465
489
|
type: Component,
|
|
@@ -471,7 +495,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
|
|
|
471
495
|
}
|
|
472
496
|
], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [AutofocusDirective, NgClass], host: {
|
|
473
497
|
class: 'aeb-code-input'
|
|
474
|
-
}, template: "@if (title()) {\n<h2 class=\"aeb-code-input__title\">{{ title() }}</h2>\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 [
|
|
498
|
+
}, template: "@if (title()) {\n<h2 class=\"aeb-code-input__title\">{{ title() }}</h2>\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 [value]=\"inputValue\"\n [disabled]=\"disabled\"\n inputmode=\"numeric\"\n [autofocus]=\"isAutofocus()\"\n autocomplete=\"one-time-code\"\n pattern=\"[0-9]*\"\n (blur)=\"handleInputBlur()\"\n (input)=\"inputChangeHandler($event)\"\n (compositionstart)=\"inputChangeHandler($event)\"\n (compositionend)=\"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 } @if (isResendable()) { @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\">{{ seconds() }}</span>\n </div>\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</div>\n}\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:var(--z-dropdown);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"] }]
|
|
475
499
|
}], ctorParameters: () => [], propDecorators: { input: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], tip: [{ type: i0.Input, args: [{ isSignal: true, alias: "tip", required: false }] }], initialDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialDisabled", required: false }] }], hasError: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasError", required: false }] }], isResendable: [{ type: i0.Input, args: [{ isSignal: true, alias: "isResendable", required: false }] }], secondsUntilRetry: [{ type: i0.Input, args: [{ isSignal: true, alias: "secondsUntilRetry", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], codeLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "codeLength", required: false }] }], isAutofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "isAutofocus", required: false }] }], codeCompleted: [{ type: i0.Output, args: ["codeCompleted"] }], timeOut: [{ type: i0.Output, args: ["timeOut"] }], resendClick: [{ type: i0.Output, args: ["resendClick"] }] } });
|
|
476
500
|
|
|
477
501
|
class CodeInputModule {
|
package/package.json
CHANGED
package/types/aeb-ui-kit.d.ts
CHANGED
|
@@ -37,14 +37,15 @@ declare class ButtonModule {
|
|
|
37
37
|
static ɵinj: _angular_core.ɵɵInjectorDeclaration<ButtonModule>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
type CodeLength = 4 | 6;
|
|
40
|
+
type CodeLength = 2 | 4 | 5 | 6;
|
|
41
41
|
declare class CodeInput implements OnInit, OnDestroy, ControlValueAccessor {
|
|
42
42
|
private readonly _destroy$;
|
|
43
43
|
private _timerSub;
|
|
44
|
+
private _isComposing;
|
|
44
45
|
private _disabled;
|
|
45
46
|
private _isFocus;
|
|
46
47
|
private _inputValue;
|
|
47
|
-
readonly input: _angular_core.Signal<ElementRef<
|
|
48
|
+
readonly input: _angular_core.Signal<ElementRef<HTMLInputElement> | undefined>;
|
|
48
49
|
readonly title: _angular_core.InputSignal<string | undefined>;
|
|
49
50
|
readonly tip: _angular_core.InputSignal<string | undefined>;
|
|
50
51
|
readonly initialDisabled: _angular_core.InputSignal<boolean>;
|
|
@@ -72,10 +73,9 @@ declare class CodeInput implements OnInit, OnDestroy, ControlValueAccessor {
|
|
|
72
73
|
ngOnInit(): void;
|
|
73
74
|
ngOnDestroy(): void;
|
|
74
75
|
inputChangeHandler(event: Event): void;
|
|
75
|
-
|
|
76
|
-
writeValue(value: string): void;
|
|
76
|
+
writeValue(value: string | null | undefined): void;
|
|
77
77
|
setDisabledState(isDisabled: boolean): void;
|
|
78
|
-
registerOnChange(fn: () => void): void;
|
|
78
|
+
registerOnChange(fn: (value: string) => void): void;
|
|
79
79
|
registerOnTouched(fn: () => void): void;
|
|
80
80
|
startTimer(): void;
|
|
81
81
|
stopTimer(): void;
|
|
@@ -84,6 +84,7 @@ declare class CodeInput implements OnInit, OnDestroy, ControlValueAccessor {
|
|
|
84
84
|
handleInputBlur(): void;
|
|
85
85
|
focus(): void;
|
|
86
86
|
private handleAutofocus;
|
|
87
|
+
private normalizeValue;
|
|
87
88
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CodeInput, never>;
|
|
88
89
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CodeInput, "aeb-code-input", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; "tip": { "alias": "tip"; "required": false; "isSignal": true; }; "initialDisabled": { "alias": "initialDisabled"; "required": false; "isSignal": true; }; "hasError": { "alias": "hasError"; "required": false; "isSignal": true; }; "isResendable": { "alias": "isResendable"; "required": false; "isSignal": true; }; "secondsUntilRetry": { "alias": "secondsUntilRetry"; "required": false; "isSignal": true; }; "errorMessage": { "alias": "errorMessage"; "required": false; "isSignal": true; }; "codeLength": { "alias": "codeLength"; "required": false; "isSignal": true; }; "isAutofocus": { "alias": "isAutofocus"; "required": false; "isSignal": true; }; }, { "codeCompleted": "codeCompleted"; "timeOut": "timeOut"; "resendClick": "resendClick"; }, never, never, true, never>;
|
|
89
90
|
}
|