shirkasoft-ui-components 2.0.0 → 2.0.1
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/README.md +8 -1
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs +79 -6
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs +74 -3
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-price-input.mjs +70 -2
- package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-select.mjs +76 -14
- package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-text-field.mjs +80 -18
- package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs +36 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shirkasoft-ui-components-date-picker.d.ts +35 -1
- package/types/shirkasoft-ui-components-file-upload.d.ts +35 -1
- package/types/shirkasoft-ui-components-price-input.d.ts +36 -2
- package/types/shirkasoft-ui-components-select.d.ts +36 -2
- package/types/shirkasoft-ui-components-text-field.d.ts +36 -4
- package/types/shirkasoft-ui-components-utils.d.ts +34 -1
|
@@ -8,7 +8,7 @@ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
|
8
8
|
import { merge } from "rxjs";
|
|
9
9
|
import { TranslocoService } from "@jsverse/transloco";
|
|
10
10
|
import { LucideEye, ShkIconDirective } from "shirkasoft-ui-components/icons";
|
|
11
|
-
import { getIcon } from "shirkasoft-ui-components/utils";
|
|
11
|
+
import { errorMessagesFromMap, getIcon, signalErrorsToMap } from "shirkasoft-ui-components/utils";
|
|
12
12
|
var TextFieldComponent = class TextFieldComponent {
|
|
13
13
|
get _value() {
|
|
14
14
|
return this.value;
|
|
@@ -28,6 +28,10 @@ var TextFieldComponent = class TextFieldComponent {
|
|
|
28
28
|
this.formGroup = input(void 0, ...ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []);
|
|
29
29
|
this.control = input(void 0, ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
30
30
|
this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
31
|
+
this.errors = input([], ...ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []);
|
|
32
|
+
this.invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
33
|
+
this.touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
34
|
+
this.dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
31
35
|
this.errorMessage = input("", ...ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []);
|
|
32
36
|
this.isTextArea = input(false, ...ngDevMode ? [{ debugName: "isTextArea" }] : /* istanbul ignore next */ []);
|
|
33
37
|
this.textAreaHeight = input("h-28", ...ngDevMode ? [{ debugName: "textAreaHeight" }] : /* istanbul ignore next */ []);
|
|
@@ -58,14 +62,16 @@ var TextFieldComponent = class TextFieldComponent {
|
|
|
58
62
|
const lbl = this.label();
|
|
59
63
|
if (fg && lbl) return fg.get(lbl) ?? void 0;
|
|
60
64
|
}, ...ngDevMode ? [{ debugName: "externalControl" }] : /* istanbul ignore next */ []);
|
|
61
|
-
this.
|
|
65
|
+
this.usesSignalForms = computed(() => !this.externalControl(), ...ngDevMode ? [{ debugName: "usesSignalForms" }] : /* istanbul ignore next */ []);
|
|
62
66
|
this.actualControl = computed(() => this.externalControl() ?? this.innerControl, ...ngDevMode ? [{ debugName: "actualControl" }] : /* istanbul ignore next */ []);
|
|
63
67
|
this.shouldShowError = computed(() => {
|
|
68
|
+
if (this.usesSignalForms()) return this.invalid() && (this.touched() || this.dirty());
|
|
64
69
|
this.errorTracker();
|
|
65
70
|
const ctrl = this.actualControl();
|
|
66
71
|
return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);
|
|
67
72
|
}, ...ngDevMode ? [{ debugName: "shouldShowError" }] : /* istanbul ignore next */ []);
|
|
68
73
|
this.wasFixedError = computed(() => {
|
|
74
|
+
if (this.usesSignalForms()) return this.hadError() && !this.invalid() && this.touched();
|
|
69
75
|
this.errorTracker();
|
|
70
76
|
const ctrl = this.actualControl();
|
|
71
77
|
return this.hadError() && ctrl?.valid && ctrl?.touched;
|
|
@@ -74,21 +80,12 @@ var TextFieldComponent = class TextFieldComponent {
|
|
|
74
80
|
this.errorTracker();
|
|
75
81
|
const customError = this.errorMessage();
|
|
76
82
|
if (customError) return [customError];
|
|
83
|
+
const customErrors = this.errorMessages();
|
|
84
|
+
const translate = (key, params) => this.transloco.translate(key, params);
|
|
85
|
+
if (this.usesSignalForms()) return errorMessagesFromMap(signalErrorsToMap(this.errors()), customErrors, translate);
|
|
77
86
|
const ctrl = this.actualControl();
|
|
78
87
|
if (!ctrl?.errors) return [];
|
|
79
|
-
|
|
80
|
-
const t = this.transloco;
|
|
81
|
-
return Object.keys(ctrl.errors).map((errorKey) => {
|
|
82
|
-
if (customErrors[errorKey]) return customErrors[errorKey];
|
|
83
|
-
switch (errorKey) {
|
|
84
|
-
case "required": return t.translate("validation.required");
|
|
85
|
-
case "email": return t.translate("validation.email");
|
|
86
|
-
case "minlength": return t.translate("validation.minlength", { min: ctrl.errors["minlength"].requiredLength });
|
|
87
|
-
case "maxlength": return t.translate("validation.maxlength", { max: ctrl.errors["maxlength"].requiredLength });
|
|
88
|
-
case "pattern": return t.translate("validation.pattern");
|
|
89
|
-
default: return t.translate("validation.invalid");
|
|
90
|
-
}
|
|
91
|
-
});
|
|
88
|
+
return errorMessagesFromMap(ctrl.errors, customErrors, translate);
|
|
92
89
|
}, ...ngDevMode ? [{ debugName: "getErrorMessages" }] : /* istanbul ignore next */ []);
|
|
93
90
|
this.effectiveType = computed(() => {
|
|
94
91
|
if (this.isTextArea()) return "text";
|
|
@@ -100,7 +97,7 @@ var TextFieldComponent = class TextFieldComponent {
|
|
|
100
97
|
this.onTouched = () => {};
|
|
101
98
|
this.destroyRef = inject(DestroyRef);
|
|
102
99
|
effect(() => {
|
|
103
|
-
if (!this.
|
|
100
|
+
if (!this.usesSignalForms()) return;
|
|
104
101
|
const value = this.value() ?? "";
|
|
105
102
|
const disabled = this.isDisabled();
|
|
106
103
|
untracked(() => {
|
|
@@ -109,6 +106,10 @@ var TextFieldComponent = class TextFieldComponent {
|
|
|
109
106
|
if (!disabled && this.innerControl.disabled) this.innerControl.enable({ emitEvent: false });
|
|
110
107
|
});
|
|
111
108
|
});
|
|
109
|
+
effect(() => {
|
|
110
|
+
if (!this.usesSignalForms()) return;
|
|
111
|
+
if (this.invalid() && (this.touched() || this.dirty())) this.hadError.set(true);
|
|
112
|
+
});
|
|
112
113
|
effect(() => {
|
|
113
114
|
const ctrl = this.actualControl();
|
|
114
115
|
const shouldDisable = this.isDisabled();
|
|
@@ -163,6 +164,7 @@ var TextFieldComponent = class TextFieldComponent {
|
|
|
163
164
|
this.onTouched();
|
|
164
165
|
this.touch.emit();
|
|
165
166
|
this.errorTracker.update((v) => v + 1);
|
|
167
|
+
if (this.usesSignalForms()) return;
|
|
166
168
|
const ctrl = this.actualControl();
|
|
167
169
|
if (ctrl?.invalid && ctrl?.touched) this.hadError.set(true);
|
|
168
170
|
}
|
|
@@ -343,6 +345,34 @@ var TextFieldComponent = class TextFieldComponent {
|
|
|
343
345
|
isRequired: false,
|
|
344
346
|
transformFunction: null
|
|
345
347
|
},
|
|
348
|
+
errors: {
|
|
349
|
+
classPropertyName: "errors",
|
|
350
|
+
publicName: "errors",
|
|
351
|
+
isSignal: true,
|
|
352
|
+
isRequired: false,
|
|
353
|
+
transformFunction: null
|
|
354
|
+
},
|
|
355
|
+
invalid: {
|
|
356
|
+
classPropertyName: "invalid",
|
|
357
|
+
publicName: "invalid",
|
|
358
|
+
isSignal: true,
|
|
359
|
+
isRequired: false,
|
|
360
|
+
transformFunction: null
|
|
361
|
+
},
|
|
362
|
+
touched: {
|
|
363
|
+
classPropertyName: "touched",
|
|
364
|
+
publicName: "touched",
|
|
365
|
+
isSignal: true,
|
|
366
|
+
isRequired: false,
|
|
367
|
+
transformFunction: null
|
|
368
|
+
},
|
|
369
|
+
dirty: {
|
|
370
|
+
classPropertyName: "dirty",
|
|
371
|
+
publicName: "dirty",
|
|
372
|
+
isSignal: true,
|
|
373
|
+
isRequired: false,
|
|
374
|
+
transformFunction: null
|
|
375
|
+
},
|
|
346
376
|
errorMessage: {
|
|
347
377
|
classPropertyName: "errorMessage",
|
|
348
378
|
publicName: "errorMessage",
|
|
@@ -417,7 +447,7 @@ var TextFieldComponent = class TextFieldComponent {
|
|
|
417
447
|
isSignal: true
|
|
418
448
|
}],
|
|
419
449
|
ngImport: i0,
|
|
420
|
-
template: "<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n @if (!isTextArea()) {\n <div class=\"flex\">\n @if (searchMode()) {\n @let isDisabledSearch = actualControl()
|
|
450
|
+
template: "<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n @if (!isTextArea()) {\n <div class=\"flex\">\n @if (searchMode()) {\n @let isDisabledSearch = actualControl().disabled || isDisabled();\n <input\n #input\n [id]=\"id()\"\n type=\"text\"\n [value]=\"displayValue() || ''\"\n [placeholder]=\"placeholder() || label()\"\n [readOnly]=\"true\"\n [disabled]=\"isDisabledSearch\"\n (click)=\"!isDisabledSearch && searchButtonClick.emit()\"\n (keydown.enter)=\"!isDisabledSearch && searchButtonClick.emit()\"\n (blur)=\"onBlur()\"\n autocomplete=\"off\"\n [attr.aria-invalid]=\"(shouldShowError() && !isDisabledSearch) || null\"\n [class.cursor-pointer]=\"!isDisabledSearch\"\n [class.cursor-not-allowed]=\"isDisabledSearch\"\n [class._shk-bg-surface-50]=\"isDisabledSearch\"\n [class._shk-text-surface-400]=\"isDisabledSearch\"\n class=\"shk-control shk-control-addon block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-l-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500': shouldShowError() && !isDisabledSearch,\n '_shk-border': !shouldShowError() || isDisabledSearch,\n 'cursor-pointer': !isDisabledSearch,\n 'cursor-not-allowed _shk-text-surface-400 dark:[color:var(--shk-surface-400)]': isDisabledSearch\n }\"\n />\n <button\n type=\"button\"\n (click)=\"searchButtonClick.emit()\"\n tabindex=\"-1\"\n [disabled]=\"isDisabledSearch\"\n class=\"px-3 flex items-center justify-center shrink-0 _shk-bg-primary hover:[background-color:var(--shk-primary-700)] text-white border _shk-border-primary rounded-r-lg transition-colors duration-200 disabled:[background-color:var(--shk-surface-300)] dark:disabled:[background-color:var(--shk-surface-200)] disabled:[border-color:var(--shk-surface-300)] dark:disabled:[border-color:var(--shk-surface-200)] disabled:cursor-not-allowed\"\n >\n <svg [shkIcon]=\"getIcon('search')\" class=\"w-4 h-4\"></svg>\n </button>\n }\n\n @if (!searchMode()) {\n <input\n #input\n [id]=\"id()\"\n [maxlength]=\"maxLength() || (formatCard() ? 19 : null)\"\n [min]=\"type() === 'number' && preventNegative() ? '0' : null\"\n (keypress)=\"type() === 'number' || numbersOnly() ? numberValidation($event) : null\"\n [type]=\"effectiveType()\"\n [formControl]=\"$any(actualControl())\"\n [placeholder]=\"placeholder() || label()\"\n (input)=\"onInput($event)\"\n [autocomplete]=\"autocomplete()\"\n (blur)=\"onBlur()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class.shk-control-valid]=\"wasFixedError()\"\n class=\"shk-control block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': shouldShowError(),\n 'border-green-500 focus:border-green-500 focus:ring-green-500': wasFixedError(),\n '_shk-border focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !shouldShowError() && !wasFixedError()\n }\"\n [class.pr-8]=\"type() === 'password' && actualControl().value?.length > 0\"\n [class.pr-3]=\"type() !== 'password' || !actualControl().value?.length\"\n />\n\n @if (type() === 'password' && actualControl().value?.length > 0) {\n <button\n type=\"button\"\n (click)=\"togglePasswordVisibility()\"\n [disabled]=\"actualControl().disabled\"\n class=\"absolute right-3 top-1/2 -translate-y-1/2 _shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-600)] focus:outline-none\"\n >\n @if (showPassword()) {\n <svg [shkIcon]=\"getIcon('eye-off')\" class=\"w-4 h-4\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('eye')\" class=\"w-4 h-4\"></svg>\n }\n </button>\n }\n }\n </div>\n }\n\n @if (isTextArea()) {\n <textarea\n #textarea\n [id]=\"id()\"\n [formControl]=\"$any(actualControl())\"\n [placeholder]=\"placeholder() || label()\"\n (input)=\"onInput($event)\"\n (blur)=\"onBlur()\"\n [class]=\"isTextArea() ? textAreaHeight() : 'h-28'\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class.shk-control-valid]=\"wasFixedError()\"\n class=\"shk-control block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 resize-none disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed disabled:[color:var(--shk-surface-400)] dark:disabled:[color:var(--shk-surface-400)] sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': shouldShowError(),\n 'border-green-500 focus:border-green-500 focus:ring-green-500': wasFixedError(),\n '_shk-border focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !shouldShowError() && !wasFixedError()\n }\"\n ></textarea>\n }\n </div>\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>\n",
|
|
421
451
|
dependencies: [
|
|
422
452
|
{
|
|
423
453
|
kind: "ngmodule",
|
|
@@ -497,7 +527,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
497
527
|
useExisting: forwardRef(() => TextFieldComponent),
|
|
498
528
|
multi: true
|
|
499
529
|
}],
|
|
500
|
-
template: "<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n @if (!isTextArea()) {\n <div class=\"flex\">\n @if (searchMode()) {\n @let isDisabledSearch = actualControl()
|
|
530
|
+
template: "<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n @if (!isTextArea()) {\n <div class=\"flex\">\n @if (searchMode()) {\n @let isDisabledSearch = actualControl().disabled || isDisabled();\n <input\n #input\n [id]=\"id()\"\n type=\"text\"\n [value]=\"displayValue() || ''\"\n [placeholder]=\"placeholder() || label()\"\n [readOnly]=\"true\"\n [disabled]=\"isDisabledSearch\"\n (click)=\"!isDisabledSearch && searchButtonClick.emit()\"\n (keydown.enter)=\"!isDisabledSearch && searchButtonClick.emit()\"\n (blur)=\"onBlur()\"\n autocomplete=\"off\"\n [attr.aria-invalid]=\"(shouldShowError() && !isDisabledSearch) || null\"\n [class.cursor-pointer]=\"!isDisabledSearch\"\n [class.cursor-not-allowed]=\"isDisabledSearch\"\n [class._shk-bg-surface-50]=\"isDisabledSearch\"\n [class._shk-text-surface-400]=\"isDisabledSearch\"\n class=\"shk-control shk-control-addon block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-l-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500': shouldShowError() && !isDisabledSearch,\n '_shk-border': !shouldShowError() || isDisabledSearch,\n 'cursor-pointer': !isDisabledSearch,\n 'cursor-not-allowed _shk-text-surface-400 dark:[color:var(--shk-surface-400)]': isDisabledSearch\n }\"\n />\n <button\n type=\"button\"\n (click)=\"searchButtonClick.emit()\"\n tabindex=\"-1\"\n [disabled]=\"isDisabledSearch\"\n class=\"px-3 flex items-center justify-center shrink-0 _shk-bg-primary hover:[background-color:var(--shk-primary-700)] text-white border _shk-border-primary rounded-r-lg transition-colors duration-200 disabled:[background-color:var(--shk-surface-300)] dark:disabled:[background-color:var(--shk-surface-200)] disabled:[border-color:var(--shk-surface-300)] dark:disabled:[border-color:var(--shk-surface-200)] disabled:cursor-not-allowed\"\n >\n <svg [shkIcon]=\"getIcon('search')\" class=\"w-4 h-4\"></svg>\n </button>\n }\n\n @if (!searchMode()) {\n <input\n #input\n [id]=\"id()\"\n [maxlength]=\"maxLength() || (formatCard() ? 19 : null)\"\n [min]=\"type() === 'number' && preventNegative() ? '0' : null\"\n (keypress)=\"type() === 'number' || numbersOnly() ? numberValidation($event) : null\"\n [type]=\"effectiveType()\"\n [formControl]=\"$any(actualControl())\"\n [placeholder]=\"placeholder() || label()\"\n (input)=\"onInput($event)\"\n [autocomplete]=\"autocomplete()\"\n (blur)=\"onBlur()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class.shk-control-valid]=\"wasFixedError()\"\n class=\"shk-control block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': shouldShowError(),\n 'border-green-500 focus:border-green-500 focus:ring-green-500': wasFixedError(),\n '_shk-border focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !shouldShowError() && !wasFixedError()\n }\"\n [class.pr-8]=\"type() === 'password' && actualControl().value?.length > 0\"\n [class.pr-3]=\"type() !== 'password' || !actualControl().value?.length\"\n />\n\n @if (type() === 'password' && actualControl().value?.length > 0) {\n <button\n type=\"button\"\n (click)=\"togglePasswordVisibility()\"\n [disabled]=\"actualControl().disabled\"\n class=\"absolute right-3 top-1/2 -translate-y-1/2 _shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-600)] focus:outline-none\"\n >\n @if (showPassword()) {\n <svg [shkIcon]=\"getIcon('eye-off')\" class=\"w-4 h-4\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('eye')\" class=\"w-4 h-4\"></svg>\n }\n </button>\n }\n }\n </div>\n }\n\n @if (isTextArea()) {\n <textarea\n #textarea\n [id]=\"id()\"\n [formControl]=\"$any(actualControl())\"\n [placeholder]=\"placeholder() || label()\"\n (input)=\"onInput($event)\"\n (blur)=\"onBlur()\"\n [class]=\"isTextArea() ? textAreaHeight() : 'h-28'\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class.shk-control-valid]=\"wasFixedError()\"\n class=\"shk-control block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 resize-none disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed disabled:[color:var(--shk-surface-400)] dark:disabled:[color:var(--shk-surface-400)] sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': shouldShowError(),\n 'border-green-500 focus:border-green-500 focus:ring-green-500': wasFixedError(),\n '_shk-border focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !shouldShowError() && !wasFixedError()\n }\"\n ></textarea>\n }\n </div>\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>\n"
|
|
501
531
|
}]
|
|
502
532
|
}],
|
|
503
533
|
ctorParameters: () => [],
|
|
@@ -606,6 +636,38 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
606
636
|
required: false
|
|
607
637
|
}]
|
|
608
638
|
}],
|
|
639
|
+
errors: [{
|
|
640
|
+
type: i0.Input,
|
|
641
|
+
args: [{
|
|
642
|
+
isSignal: true,
|
|
643
|
+
alias: "errors",
|
|
644
|
+
required: false
|
|
645
|
+
}]
|
|
646
|
+
}],
|
|
647
|
+
invalid: [{
|
|
648
|
+
type: i0.Input,
|
|
649
|
+
args: [{
|
|
650
|
+
isSignal: true,
|
|
651
|
+
alias: "invalid",
|
|
652
|
+
required: false
|
|
653
|
+
}]
|
|
654
|
+
}],
|
|
655
|
+
touched: [{
|
|
656
|
+
type: i0.Input,
|
|
657
|
+
args: [{
|
|
658
|
+
isSignal: true,
|
|
659
|
+
alias: "touched",
|
|
660
|
+
required: false
|
|
661
|
+
}]
|
|
662
|
+
}],
|
|
663
|
+
dirty: [{
|
|
664
|
+
type: i0.Input,
|
|
665
|
+
args: [{
|
|
666
|
+
isSignal: true,
|
|
667
|
+
alias: "dirty",
|
|
668
|
+
required: false
|
|
669
|
+
}]
|
|
670
|
+
}],
|
|
609
671
|
errorMessage: [{
|
|
610
672
|
type: i0.Input,
|
|
611
673
|
args: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-text-field.mjs","names":["getIconFromCentral"],"sources":["../../../projects/ui-components/text-field/text-field.component.ts","../../../projects/ui-components/text-field/text-field.component.html"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n input,\n model,\n forwardRef,\n signal,\n computed,\n effect,\n viewChild,\n ElementRef,\n ChangeDetectionStrategy,\n DestroyRef,\n inject,\n output,\n ChangeDetectorRef,\n untracked,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormGroup,\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n} from '@angular/forms';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { merge, Subscription } from 'rxjs';\nimport type { FormValueControl } from '@angular/forms/signals';\nimport { TranslocoService } from '@jsverse/transloco';\nimport {\n ShkIconDirective,\n LucideEye,\n} from 'shirkasoft-ui-components/icons';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Text input (or textarea) that implements ControlValueAccessor with built-in\n * validation messages, card/number formatting, password reveal and search mode.\n */\n@Component({\n selector: 'shk-text-field',\n imports: [CommonModule, ReactiveFormsModule, ShkIconDirective],\n templateUrl: './text-field.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => TextFieldComponent),\n multi: true,\n },\n ],\n})\nexport class TextFieldComponent implements ControlValueAccessor, FormValueControl<any> {\n private cdr = inject(ChangeDetectorRef);\n\n /** id attribute applied to the native input. */\n id = input<string>('');\n /** Formats the value as a credit card number (XXXX-XXXX-XXXX-XXXX). */\n formatCard = input<boolean>(false);\n /** Blocks the minus sign from being typed. */\n preventNegative = input<boolean>(false);\n /** Label rendered above the field. */\n label = input<string>('');\n /** Native input type ('text', 'password', 'number', etc.). */\n type = input<string>('text');\n /** Allows digits only, stripping any other character. */\n numbersOnly = input<boolean>(false);\n /** When true, allows decimals and normalizes ',' to '.'. */\n allowDecimals = input<boolean>(false);\n /** Maximum number of characters the user can type. */\n maxLength = input<number | undefined>(undefined);\n /** Placeholder text of the native input. */\n placeholder = input<string>('');\n /** Custom messages keyed by validation error name. */\n errorMessages = input<{ [key: string]: string }>({});\n /** Parent reactive form used to resolve the control by label. */\n formGroup = input<FormGroup | undefined>(undefined);\n /** Reactive control bound directly to this field. */\n control = input<FormControl | undefined>(undefined);\n /** Disables the field. */\n disabled = input<boolean>(false);\n /** Custom error message shown regardless of validation errors. */\n errorMessage = input<string>('');\n /** Renders a textarea instead of an input. */\n isTextArea = input<boolean>(false);\n /** Height classes applied when `isTextArea` is true. */\n textAreaHeight = input<string>('h-28');\n /** Renders the field as a read-only search trigger. */\n searchMode = input<boolean>(false);\n /** Value shown when `searchMode` is enabled. */\n displayValue = input<string>('');\n /** Native autocomplete attribute. */\n autocomplete = input<string>('');\n /** Emitted when the search button is clicked (search mode). */\n searchButtonClick = output<void>();\n /** Emitted on blur so Signal Forms can mark the field as touched. */\n touch = output<void>();\n protected readonly getIcon = (name: any) => getIconFromCentral(name, LucideEye);\n\n /** Reference to the native input element. */\n inputElement = viewChild<ElementRef<HTMLInputElement>>('input');\n /** Reference to the native textarea element. */\n textareaElement = viewChild<ElementRef<HTMLTextAreaElement>>('textarea');\n\n /** Field value. Two-way bindable and used by Signal Forms `[formField]`. */\n value = model<any>('');\n /** Internal alias kept for the existing implementation. */\n private get _value() {\n return this.value;\n }\n /** Reactive disabled state from the form control. */\n private _disabledState = signal<boolean>(false);\n /** Whether the password is currently revealed. */\n showPassword = signal<boolean>(false);\n /** Tracks whether the control was in error at some point (for \"was fixed\" UX). */\n hadError = signal<boolean>(false);\n /** Counter bumped to trigger recomputation of derived error signals. */\n private errorTracker = signal<number>(0);\n\n /** Text displayed in search mode when `displayValue` is set. */\n displayLabel = computed(() => {\n if (this.searchMode() && this.displayValue()) {\n return this.displayValue();\n }\n return '';\n });\n /** Control whose status/value changes are currently observed. */\n private observedControl: FormControl | null = null;\n /** Subscription to `observedControl`; replaced when the control changes. */\n private controlSubscription?: Subscription;\n\n /** Effective disabled state combining the input and the form binding. */\n isDisabled = computed(() => this.disabled() || this._disabledState());\n\n /**\n * Internal control used when no reactive control is supplied (`[formField]`,\n * `formControlName`/`ngModel` on the host, or plain `[(value)]`). The native\n * input always needs a control for its `[formControl]` binding.\n */\n private readonly innerControl = new FormControl<any>('');\n\n /** Explicit `control`, or `formGroup.get(label)`, or `undefined` if none. */\n private externalControl = computed<FormControl | undefined>(() => {\n const ctrl = this.control();\n if (ctrl) return ctrl;\n\n const fg = this.formGroup();\n const lbl = this.label();\n if (fg && lbl) {\n return (fg.get(lbl) as FormControl | null) ?? undefined;\n }\n return undefined;\n });\n\n /** True when the field is driven by its internal control (no reactive control given). */\n private usesInnerControl = computed(() => !this.externalControl());\n\n /** Resolves the reactive control: external one if any, otherwise the internal one. */\n actualControl = computed<FormControl>(() => this.externalControl() ?? this.innerControl);\n\n /** True when the resolved control is invalid and dirty or touched. */\n shouldShowError = computed(() => {\n this.errorTracker();\n\n const ctrl = this.actualControl();\n return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);\n });\n\n /** True when the control had an error before and is now valid (success state). */\n wasFixedError = computed(() => {\n this.errorTracker();\n\n const ctrl = this.actualControl();\n return this.hadError() && ctrl?.valid && ctrl?.touched;\n });\n\n /** Resolved list of error messages for the current control state. */\n getErrorMessages = computed(() => {\n this.errorTracker();\n\n const customError = this.errorMessage();\n if (customError) {\n return [customError];\n }\n\n const ctrl = this.actualControl();\n if (!ctrl?.errors) return [];\n\n const customErrors = this.errorMessages();\n const t = this.transloco;\n\n return Object.keys(ctrl.errors).map((errorKey) => {\n if (customErrors[errorKey]) return customErrors[errorKey];\n\n switch (errorKey) {\n case 'required':\n return t.translate('validation.required');\n case 'email':\n return t.translate('validation.email');\n case 'minlength':\n return t.translate('validation.minlength', {\n min: ctrl.errors!['minlength'].requiredLength,\n });\n case 'maxlength':\n return t.translate('validation.maxlength', {\n max: ctrl.errors!['maxlength'].requiredLength,\n });\n case 'pattern':\n return t.translate('validation.pattern');\n default:\n return t.translate('validation.invalid');\n }\n });\n });\n\n /** Effective input type (handles textarea and password reveal). */\n effectiveType = computed(() => {\n if (this.isTextArea()) return 'text';\n if (this.type() === 'password' && this.showPassword()) return 'text';\n return this.type();\n });\n\n private transloco = inject(TranslocoService);\n /** Callback notified with the new value (ControlValueAccessor). */\n private onChange: (value: any) => void = () => {};\n\n /** Callback notified when the field is touched (ControlValueAccessor). */\n private onTouched: () => void = () => {};\n private destroyRef = inject(DestroyRef);\n\n constructor() {\n // Internal-control mode: mirror the value model and disabled state into it\n // so the native input shows what the form (CVA / Signal Forms) writes.\n effect(() => {\n if (!this.usesInnerControl()) return;\n const value = this.value() ?? '';\n const disabled = this.isDisabled();\n untracked(() => {\n if (this.innerControl.value !== value) {\n this.innerControl.setValue(value, { emitEvent: false });\n }\n if (disabled && this.innerControl.enabled) this.innerControl.disable({ emitEvent: false });\n if (!disabled && this.innerControl.disabled) this.innerControl.enable({ emitEvent: false });\n });\n });\n\n effect(() => {\n const ctrl = this.actualControl();\n const shouldDisable = this.isDisabled();\n\n if (ctrl && shouldDisable) {\n Promise.resolve().then(() => {\n ctrl.disable();\n });\n }\n });\n\n // Observe the current control's status/value changes. Re-subscribes when\n // the control changes (e.g. `[control]` arrives after init, or the field\n // switches from its internal control to an external one).\n effect(() => {\n const ctrl = this.actualControl();\n if (ctrl === this.observedControl) return;\n\n this.controlSubscription?.unsubscribe();\n this.observedControl = ctrl;\n\n if (ctrl.invalid && ctrl.touched) {\n this.hadError.set(true);\n }\n\n this.controlSubscription = merge(ctrl.statusChanges, ctrl.valueChanges).subscribe(() => {\n this.errorTracker.update((v) => v + 1);\n if (ctrl.invalid && ctrl.touched) {\n this.hadError.set(true);\n }\n });\n });\n this.destroyRef.onDestroy(() => this.controlSubscription?.unsubscribe());\n\n this.transloco.langChanges$\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => {\n this.errorTracker.update((v) => v + 1);\n });\n }\n\n /** Prevents disallowed characters based on the `numbersOnly`/`allowDecimals` config. */\n numberValidation(event: KeyboardEvent) {\n const allowedKeys = [\n 'Backspace',\n 'Tab',\n 'End',\n 'Home',\n 'ArrowLeft',\n 'ArrowRight',\n 'Delete',\n ];\n\n if (this.numbersOnly()) {\n const isNumber = /^\\d$/.test(event.key);\n if (!isNumber && !allowedKeys.includes(event.key)) {\n event.preventDefault();\n }\n return;\n }\n\n if (this.allowDecimals() || this.type() === 'number') {\n allowedKeys.push('.');\n }\n\n const isDecimal = event.key === '.' || event.key === ',';\n const isNumber = !isNaN(Number(event.key));\n\n if (allowedKeys.includes(event.key)) {\n if (isDecimal) {\n const input = event.target as HTMLInputElement;\n const currentValue = input.value;\n\n const hasDecimalSeparator =\n currentValue.includes('.') || currentValue.includes(',');\n\n if (hasDecimalSeparator) {\n event.preventDefault();\n }\n }\n return;\n }\n\n if (isNumber) {\n return;\n }\n\n event.preventDefault();\n }\n\n /** Marks the field as touched and refreshes the error state. */\n onBlur(): void {\n this.onTouched();\n this.touch.emit();\n\n this.errorTracker.update((v) => v + 1);\n\n const ctrl = this.actualControl();\n if (ctrl?.invalid && ctrl?.touched) {\n this.hadError.set(true);\n }\n }\n\n /** Formats the raw input as a credit card number and notifies the control. */\n onCardInput(event: Event): void {\n const input = event.target as HTMLInputElement;\n let value = input.value.replace(/[^0-9]/g, '');\n\n if (value.length > 16) {\n value = value.substring(0, 16);\n }\n\n let formatted = '';\n for (let i = 0; i < value.length; i++) {\n if (i > 0 && i % 4 === 0) {\n formatted += '-';\n }\n formatted += value[i];\n }\n\n input.value = formatted;\n this._value.set(formatted);\n this.onChange(formatted);\n }\n\n /** Handles raw input: applies number/card/max-length formatting and notifies the control. */\n onInput(event: Event): void {\n const input = event.target as HTMLInputElement | HTMLTextAreaElement;\n let newValue = input.value;\n\n if (this.allowDecimals()) {\n newValue = newValue.replace(/,/g, '.');\n\n const parts = newValue.split('.');\n if (parts.length > 2) {\n newValue = parts[0] + '.' + parts.slice(1).join('');\n }\n\n if (parts.length > 1 && parts[1].length > 2) {\n newValue = parts[0] + '.' + parts[1].substring(0, 2);\n }\n }\n\n if (this.numbersOnly()) {\n newValue = newValue.replace(/[^0-9]/g, '');\n }\n\n const maxLen = this.maxLength();\n if (maxLen && newValue.length > maxLen) {\n newValue = newValue.substring(0, maxLen);\n input.value = newValue;\n\n const ctrl = this.actualControl();\n setTimeout(() => {\n ctrl?.updateValueAndValidity();\n this.errorTracker.update((v) => v + 1);\n });\n }\n\n if (this.formatCard()) {\n this.onCardInput(event);\n } else {\n this._value.set(newValue);\n this.onChange(newValue);\n }\n }\n\n /** Toggles the visibility of a password field. */\n togglePasswordVisibility(): void {\n this.showPassword.update((v) => !v);\n }\n\n /** Sets the value from the form control applying the same formatting rules. */\n writeValue(value: any): void {\n let processedValue = value;\n\n if (this.allowDecimals() && value) {\n processedValue = String(value).replace(/,/g, '.');\n }\n\n if (this.numbersOnly() && value) {\n processedValue = value.toString().replace(/[^0-9]/g, '');\n }\n\n const maxLen = this.maxLength();\n if (maxLen && processedValue?.length > maxLen) {\n processedValue = processedValue.substring(0, maxLen);\n }\n\n if (this.formatCard() && processedValue) {\n const cleaned = processedValue.replace(/[^0-9]/g, '');\n let formatted = '';\n for (let i = 0; i < cleaned.length; i++) {\n if (i > 0 && i % 4 === 0) formatted += '-';\n formatted += cleaned[i];\n }\n this._value.set(formatted);\n } else {\n this._value.set(processedValue);\n }\n }\n\n /** Registers the callback invoked on value changes (ControlValueAccessor). */\n registerOnChange(fn: any): void {\n this.onChange = fn;\n }\n\n /** Registers the callback invoked when the field is touched. */\n registerOnTouched(fn: any): void {\n this.onTouched = fn;\n }\n\n /** Reflects the disabled state of the form control. */\n setDisabledState(isDisabled: boolean): void {\n this._disabledState.set(isDisabled);\n this.cdr.markForCheck();\n }\n}\n","<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n @if (!isTextArea()) {\n <div class=\"flex\">\n @if (searchMode()) {\n @let isDisabledSearch = actualControl()?.disabled || isDisabled();\n <input\n #input\n [id]=\"id()\"\n type=\"text\"\n [value]=\"displayValue() || ''\"\n [placeholder]=\"placeholder() || label()\"\n [readOnly]=\"true\"\n [disabled]=\"isDisabledSearch\"\n (click)=\"!isDisabledSearch && searchButtonClick.emit()\"\n (keydown.enter)=\"!isDisabledSearch && searchButtonClick.emit()\"\n (blur)=\"onBlur()\"\n autocomplete=\"off\"\n [attr.aria-invalid]=\"(shouldShowError() && !isDisabledSearch) || null\"\n [class.cursor-pointer]=\"!isDisabledSearch\"\n [class.cursor-not-allowed]=\"isDisabledSearch\"\n [class._shk-bg-surface-50]=\"isDisabledSearch\"\n [class._shk-text-surface-400]=\"isDisabledSearch\"\n class=\"shk-control shk-control-addon block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-l-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500': shouldShowError() && !isDisabledSearch,\n '_shk-border': !shouldShowError() || isDisabledSearch,\n 'cursor-pointer': !isDisabledSearch,\n 'cursor-not-allowed _shk-text-surface-400 dark:[color:var(--shk-surface-400)]': isDisabledSearch\n }\"\n />\n <button\n type=\"button\"\n (click)=\"searchButtonClick.emit()\"\n tabindex=\"-1\"\n [disabled]=\"isDisabledSearch\"\n class=\"px-3 flex items-center justify-center shrink-0 _shk-bg-primary hover:[background-color:var(--shk-primary-700)] text-white border _shk-border-primary rounded-r-lg transition-colors duration-200 disabled:[background-color:var(--shk-surface-300)] dark:disabled:[background-color:var(--shk-surface-200)] disabled:[border-color:var(--shk-surface-300)] dark:disabled:[border-color:var(--shk-surface-200)] disabled:cursor-not-allowed\"\n >\n <svg [shkIcon]=\"getIcon('search')\" class=\"w-4 h-4\"></svg>\n </button>\n }\n\n @if (!searchMode()) {\n <input\n #input\n [id]=\"id()\"\n [maxlength]=\"maxLength() || (formatCard() ? 19 : null)\"\n [min]=\"type() === 'number' && preventNegative() ? '0' : null\"\n (keypress)=\"type() === 'number' || numbersOnly() ? numberValidation($event) : null\"\n [type]=\"effectiveType()\"\n [formControl]=\"$any(actualControl())\"\n [placeholder]=\"placeholder() || label()\"\n (input)=\"onInput($event)\"\n [autocomplete]=\"autocomplete()\"\n (blur)=\"onBlur()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class.shk-control-valid]=\"wasFixedError()\"\n class=\"shk-control block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': shouldShowError(),\n 'border-green-500 focus:border-green-500 focus:ring-green-500': wasFixedError(),\n '_shk-border focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !shouldShowError() && !wasFixedError()\n }\"\n [class.pr-8]=\"type() === 'password' && actualControl()?.value?.length > 0\"\n [class.pr-3]=\"type() !== 'password' || !actualControl()?.value?.length\"\n />\n\n @if (type() === 'password' && actualControl()?.value?.length > 0) {\n <button\n type=\"button\"\n (click)=\"togglePasswordVisibility()\"\n [disabled]=\"actualControl()?.disabled\"\n class=\"absolute right-3 top-1/2 -translate-y-1/2 _shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-600)] focus:outline-none\"\n >\n @if (showPassword()) {\n <svg [shkIcon]=\"getIcon('eye-off')\" class=\"w-4 h-4\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('eye')\" class=\"w-4 h-4\"></svg>\n }\n </button>\n }\n }\n </div>\n }\n\n @if (isTextArea()) {\n <textarea\n #textarea\n [id]=\"id()\"\n [formControl]=\"$any(actualControl())\"\n [placeholder]=\"placeholder() || label()\"\n (input)=\"onInput($event)\"\n (blur)=\"onBlur()\"\n [class]=\"isTextArea() ? textAreaHeight() : 'h-28'\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class.shk-control-valid]=\"wasFixedError()\"\n class=\"shk-control block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 resize-none disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed disabled:[color:var(--shk-surface-400)] dark:disabled:[color:var(--shk-surface-400)] sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': shouldShowError(),\n 'border-green-500 focus:border-green-500 focus:ring-green-500': wasFixedError(),\n '_shk-border focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !shouldShowError() && !wasFixedError()\n }\"\n ></textarea>\n }\n </div>\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>\n"],"mappings":";;;;;;;;;;;AA0DA,IAAa,qBAAb,MAAa,mBAAkB;CAuD7B,IAAY,SAAM;EAChB,OAAO,KAAK;CACd;CAyHA,cAAA;EAjLQ,KAAA,MAAM,OAAO,iBAAiB;EAGtC,KAAA,KAAK,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;EAEtB,KAAA,aAAa,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;EAElC,KAAA,kBAAkB,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,kBAAA,CAAA,+BAAA,CAAA,CAAA;EAEvC,KAAA,QAAQ,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAEzB,KAAA,OAAO,MAAc,QAAO,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;EAE5B,KAAA,cAAc,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BA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;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,cAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,cAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,mBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,mBAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAA;EAAA,CAAA;EAAA,cAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,iBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAED,YAAU,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-text-field.mjs","names":["getIconFromCentral"],"sources":["../../../projects/ui-components/text-field/text-field.component.ts","../../../projects/ui-components/text-field/text-field.component.html"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n input,\n model,\n forwardRef,\n signal,\n computed,\n effect,\n viewChild,\n ElementRef,\n ChangeDetectionStrategy,\n DestroyRef,\n inject,\n output,\n ChangeDetectorRef,\n untracked,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormGroup,\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n} from '@angular/forms';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { merge, Subscription } from 'rxjs';\nimport type { FormValueControl, ValidationError } from '@angular/forms/signals';\nimport { TranslocoService } from '@jsverse/transloco';\nimport {\n ShkIconDirective,\n LucideEye,\n} from 'shirkasoft-ui-components/icons';\nimport {\n errorMessagesFromMap,\n getIcon as getIconFromCentral,\n signalErrorsToMap,\n} from 'shirkasoft-ui-components/utils';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Text input (or textarea) that implements ControlValueAccessor with built-in\n * validation messages, card/number formatting, password reveal and search mode.\n */\n@Component({\n selector: 'shk-text-field',\n imports: [CommonModule, ReactiveFormsModule, ShkIconDirective],\n templateUrl: './text-field.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => TextFieldComponent),\n multi: true,\n },\n ],\n})\nexport class TextFieldComponent implements ControlValueAccessor, FormValueControl<any> {\n private cdr = inject(ChangeDetectorRef);\n\n /** id attribute applied to the native input. */\n id = input<string>('');\n /** Formats the value as a credit card number (XXXX-XXXX-XXXX-XXXX). */\n formatCard = input<boolean>(false);\n /** Blocks the minus sign from being typed. */\n preventNegative = input<boolean>(false);\n /** Label rendered above the field. */\n label = input<string>('');\n /** Native input type ('text', 'password', 'number', etc.). */\n type = input<string>('text');\n /** Allows digits only, stripping any other character. */\n numbersOnly = input<boolean>(false);\n /** When true, allows decimals and normalizes ',' to '.'. */\n allowDecimals = input<boolean>(false);\n /** Maximum number of characters the user can type. */\n maxLength = input<number | undefined>(undefined);\n /** Placeholder text of the native input. */\n placeholder = input<string>('');\n /** Custom messages keyed by validation error name. */\n errorMessages = input<{ [key: string]: string }>({});\n /** Parent reactive form used to resolve the control by label. */\n formGroup = input<FormGroup | undefined>(undefined);\n /** Reactive control bound directly to this field. */\n control = input<FormControl | undefined>(undefined);\n /** Disables the field. */\n disabled = input<boolean>(false);\n /** Errors bound automatically by the Signal Forms `[formField]` directive. */\n errors = input<readonly ValidationError.WithOptionalFieldTree[]>([]);\n /** Invalid status bound automatically by `[formField]`. */\n invalid = input<boolean>(false);\n /** Touched status bound automatically by `[formField]`. */\n touched = input<boolean>(false);\n /** Dirty status bound automatically by `[formField]`. */\n dirty = input<boolean>(false);\n /** Custom error message shown regardless of validation errors. */\n errorMessage = input<string>('');\n /** Renders a textarea instead of an input. */\n isTextArea = input<boolean>(false);\n /** Height classes applied when `isTextArea` is true. */\n textAreaHeight = input<string>('h-28');\n /** Renders the field as a read-only search trigger. */\n searchMode = input<boolean>(false);\n /** Value shown when `searchMode` is enabled. */\n displayValue = input<string>('');\n /** Native autocomplete attribute. */\n autocomplete = input<string>('');\n /** Emitted when the search button is clicked (search mode). */\n searchButtonClick = output<void>();\n /** Emitted on blur so Signal Forms can mark the field as touched. */\n touch = output<void>();\n protected readonly getIcon = (name: any) => getIconFromCentral(name, LucideEye);\n\n /** Reference to the native input element. */\n inputElement = viewChild<ElementRef<HTMLInputElement>>('input');\n /** Reference to the native textarea element. */\n textareaElement = viewChild<ElementRef<HTMLTextAreaElement>>('textarea');\n\n /** Field value. Two-way bindable and used by Signal Forms `[formField]`. */\n value = model<any>('');\n /** Internal alias kept for the existing implementation. */\n private get _value() {\n return this.value;\n }\n /** Reactive disabled state from the form control. */\n private _disabledState = signal<boolean>(false);\n /** Whether the password is currently revealed. */\n showPassword = signal<boolean>(false);\n /** Tracks whether the control was in error at some point (for \"was fixed\" UX). */\n hadError = signal<boolean>(false);\n /** Counter bumped to trigger recomputation of derived error signals. */\n private errorTracker = signal<number>(0);\n\n /** Text displayed in search mode when `displayValue` is set. */\n displayLabel = computed(() => {\n if (this.searchMode() && this.displayValue()) {\n return this.displayValue();\n }\n return '';\n });\n /** Control whose status/value changes are currently observed. */\n private observedControl: FormControl | null = null;\n /** Subscription to `observedControl`; replaced when the control changes. */\n private controlSubscription?: Subscription;\n\n /** Effective disabled state combining the input and the form binding. */\n isDisabled = computed(() => this.disabled() || this._disabledState());\n\n /**\n * Internal control used when no reactive control is supplied (`[formField]`,\n * `formControlName`/`ngModel` on the host, or plain `[(value)]`). The native\n * input always needs a control for its `[formControl]` binding.\n */\n private readonly innerControl = new FormControl<any>('');\n\n /** Explicit `control`, or `formGroup.get(label)`, or `undefined` if none. */\n private externalControl = computed<FormControl | undefined>(() => {\n const ctrl = this.control();\n if (ctrl) return ctrl;\n\n const fg = this.formGroup();\n const lbl = this.label();\n if (fg && lbl) {\n return (fg.get(lbl) as FormControl | null) ?? undefined;\n }\n return undefined;\n });\n\n /**\n * True when the field is driven by Signal Forms (or plain `[(value)]`) instead\n * of a reactive control. Detected by the absence of an external control:\n * `[formField]` then provides `errors`/`invalid`/`touched`/`dirty`.\n */\n protected usesSignalForms = computed(() => !this.externalControl());\n\n /** Resolves the reactive control: external one if any, otherwise the internal one. */\n actualControl = computed<FormControl>(() => this.externalControl() ?? this.innerControl);\n\n /** True when the field should display its validation errors. */\n shouldShowError = computed(() => {\n if (this.usesSignalForms()) {\n return this.invalid() && (this.touched() || this.dirty());\n }\n\n this.errorTracker();\n\n const ctrl = this.actualControl();\n return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);\n });\n\n /** True when the control had an error before and is now valid (success state). */\n wasFixedError = computed(() => {\n if (this.usesSignalForms()) {\n return this.hadError() && !this.invalid() && this.touched();\n }\n\n this.errorTracker();\n\n const ctrl = this.actualControl();\n return this.hadError() && ctrl?.valid && ctrl?.touched;\n });\n\n /** Resolved list of error messages for the current control state. */\n getErrorMessages = computed(() => {\n this.errorTracker();\n\n const customError = this.errorMessage();\n if (customError) {\n return [customError];\n }\n\n const customErrors = this.errorMessages();\n const translate = (key: string, params?: Record<string, any>) =>\n this.transloco.translate(key, params);\n\n if (this.usesSignalForms()) {\n return errorMessagesFromMap(signalErrorsToMap(this.errors()), customErrors, translate);\n }\n\n const ctrl = this.actualControl();\n if (!ctrl?.errors) return [];\n\n return errorMessagesFromMap(ctrl.errors, customErrors, translate);\n });\n\n /** Effective input type (handles textarea and password reveal). */\n effectiveType = computed(() => {\n if (this.isTextArea()) return 'text';\n if (this.type() === 'password' && this.showPassword()) return 'text';\n return this.type();\n });\n\n private transloco = inject(TranslocoService);\n /** Callback notified with the new value (ControlValueAccessor). */\n private onChange: (value: any) => void = () => {};\n\n /** Callback notified when the field is touched (ControlValueAccessor). */\n private onTouched: () => void = () => {};\n private destroyRef = inject(DestroyRef);\n\n constructor() {\n // Internal-control mode: mirror the value model and disabled state into it\n // so the native input shows what the form (CVA / Signal Forms) writes.\n effect(() => {\n if (!this.usesSignalForms()) return;\n const value = this.value() ?? '';\n const disabled = this.isDisabled();\n untracked(() => {\n if (this.innerControl.value !== value) {\n this.innerControl.setValue(value, { emitEvent: false });\n }\n if (disabled && this.innerControl.enabled) this.innerControl.disable({ emitEvent: false });\n if (!disabled && this.innerControl.disabled) this.innerControl.enable({ emitEvent: false });\n });\n });\n\n // Signal Forms: remember when the field entered the error state so the\n // \"fixed\" (green) state can be shown once the user corrects it.\n effect(() => {\n if (!this.usesSignalForms()) return;\n\n if (this.invalid() && (this.touched() || this.dirty())) {\n this.hadError.set(true);\n }\n });\n\n effect(() => {\n const ctrl = this.actualControl();\n const shouldDisable = this.isDisabled();\n\n if (ctrl && shouldDisable) {\n Promise.resolve().then(() => {\n ctrl.disable();\n });\n }\n });\n\n // Observe the current control's status/value changes. Re-subscribes when\n // the control changes (e.g. `[control]` arrives after init, or the field\n // switches from its internal control to an external one).\n effect(() => {\n const ctrl = this.actualControl();\n if (ctrl === this.observedControl) return;\n\n this.controlSubscription?.unsubscribe();\n this.observedControl = ctrl;\n\n if (ctrl.invalid && ctrl.touched) {\n this.hadError.set(true);\n }\n\n this.controlSubscription = merge(ctrl.statusChanges, ctrl.valueChanges).subscribe(() => {\n this.errorTracker.update((v) => v + 1);\n if (ctrl.invalid && ctrl.touched) {\n this.hadError.set(true);\n }\n });\n });\n this.destroyRef.onDestroy(() => this.controlSubscription?.unsubscribe());\n\n this.transloco.langChanges$\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => {\n this.errorTracker.update((v) => v + 1);\n });\n }\n\n /** Prevents disallowed characters based on the `numbersOnly`/`allowDecimals` config. */\n numberValidation(event: KeyboardEvent) {\n const allowedKeys = [\n 'Backspace',\n 'Tab',\n 'End',\n 'Home',\n 'ArrowLeft',\n 'ArrowRight',\n 'Delete',\n ];\n\n if (this.numbersOnly()) {\n const isNumber = /^\\d$/.test(event.key);\n if (!isNumber && !allowedKeys.includes(event.key)) {\n event.preventDefault();\n }\n return;\n }\n\n if (this.allowDecimals() || this.type() === 'number') {\n allowedKeys.push('.');\n }\n\n const isDecimal = event.key === '.' || event.key === ',';\n const isNumber = !isNaN(Number(event.key));\n\n if (allowedKeys.includes(event.key)) {\n if (isDecimal) {\n const input = event.target as HTMLInputElement;\n const currentValue = input.value;\n\n const hasDecimalSeparator =\n currentValue.includes('.') || currentValue.includes(',');\n\n if (hasDecimalSeparator) {\n event.preventDefault();\n }\n }\n return;\n }\n\n if (isNumber) {\n return;\n }\n\n event.preventDefault();\n }\n\n /** Marks the field as touched and refreshes the error state. */\n onBlur(): void {\n this.onTouched();\n this.touch.emit();\n\n this.errorTracker.update((v) => v + 1);\n\n if (this.usesSignalForms()) {\n return;\n }\n\n const ctrl = this.actualControl();\n if (ctrl?.invalid && ctrl?.touched) {\n this.hadError.set(true);\n }\n }\n\n /** Formats the raw input as a credit card number and notifies the control. */\n onCardInput(event: Event): void {\n const input = event.target as HTMLInputElement;\n let value = input.value.replace(/[^0-9]/g, '');\n\n if (value.length > 16) {\n value = value.substring(0, 16);\n }\n\n let formatted = '';\n for (let i = 0; i < value.length; i++) {\n if (i > 0 && i % 4 === 0) {\n formatted += '-';\n }\n formatted += value[i];\n }\n\n input.value = formatted;\n this._value.set(formatted);\n this.onChange(formatted);\n }\n\n /** Handles raw input: applies number/card/max-length formatting and notifies the control. */\n onInput(event: Event): void {\n const input = event.target as HTMLInputElement | HTMLTextAreaElement;\n let newValue = input.value;\n\n if (this.allowDecimals()) {\n newValue = newValue.replace(/,/g, '.');\n\n const parts = newValue.split('.');\n if (parts.length > 2) {\n newValue = parts[0] + '.' + parts.slice(1).join('');\n }\n\n if (parts.length > 1 && parts[1].length > 2) {\n newValue = parts[0] + '.' + parts[1].substring(0, 2);\n }\n }\n\n if (this.numbersOnly()) {\n newValue = newValue.replace(/[^0-9]/g, '');\n }\n\n const maxLen = this.maxLength();\n if (maxLen && newValue.length > maxLen) {\n newValue = newValue.substring(0, maxLen);\n input.value = newValue;\n\n const ctrl = this.actualControl();\n setTimeout(() => {\n ctrl?.updateValueAndValidity();\n this.errorTracker.update((v) => v + 1);\n });\n }\n\n if (this.formatCard()) {\n this.onCardInput(event);\n } else {\n this._value.set(newValue);\n this.onChange(newValue);\n }\n }\n\n /** Toggles the visibility of a password field. */\n togglePasswordVisibility(): void {\n this.showPassword.update((v) => !v);\n }\n\n /** Sets the value from the form control applying the same formatting rules. */\n writeValue(value: any): void {\n let processedValue = value;\n\n if (this.allowDecimals() && value) {\n processedValue = String(value).replace(/,/g, '.');\n }\n\n if (this.numbersOnly() && value) {\n processedValue = value.toString().replace(/[^0-9]/g, '');\n }\n\n const maxLen = this.maxLength();\n if (maxLen && processedValue?.length > maxLen) {\n processedValue = processedValue.substring(0, maxLen);\n }\n\n if (this.formatCard() && processedValue) {\n const cleaned = processedValue.replace(/[^0-9]/g, '');\n let formatted = '';\n for (let i = 0; i < cleaned.length; i++) {\n if (i > 0 && i % 4 === 0) formatted += '-';\n formatted += cleaned[i];\n }\n this._value.set(formatted);\n } else {\n this._value.set(processedValue);\n }\n }\n\n /** Registers the callback invoked on value changes (ControlValueAccessor). */\n registerOnChange(fn: any): void {\n this.onChange = fn;\n }\n\n /** Registers the callback invoked when the field is touched. */\n registerOnTouched(fn: any): void {\n this.onTouched = fn;\n }\n\n /** Reflects the disabled state of the form control. */\n setDisabledState(isDisabled: boolean): void {\n this._disabledState.set(isDisabled);\n this.cdr.markForCheck();\n }\n}\n","<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n @if (!isTextArea()) {\n <div class=\"flex\">\n @if (searchMode()) {\n @let isDisabledSearch = actualControl().disabled || isDisabled();\n <input\n #input\n [id]=\"id()\"\n type=\"text\"\n [value]=\"displayValue() || ''\"\n [placeholder]=\"placeholder() || label()\"\n [readOnly]=\"true\"\n [disabled]=\"isDisabledSearch\"\n (click)=\"!isDisabledSearch && searchButtonClick.emit()\"\n (keydown.enter)=\"!isDisabledSearch && searchButtonClick.emit()\"\n (blur)=\"onBlur()\"\n autocomplete=\"off\"\n [attr.aria-invalid]=\"(shouldShowError() && !isDisabledSearch) || null\"\n [class.cursor-pointer]=\"!isDisabledSearch\"\n [class.cursor-not-allowed]=\"isDisabledSearch\"\n [class._shk-bg-surface-50]=\"isDisabledSearch\"\n [class._shk-text-surface-400]=\"isDisabledSearch\"\n class=\"shk-control shk-control-addon block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-l-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500': shouldShowError() && !isDisabledSearch,\n '_shk-border': !shouldShowError() || isDisabledSearch,\n 'cursor-pointer': !isDisabledSearch,\n 'cursor-not-allowed _shk-text-surface-400 dark:[color:var(--shk-surface-400)]': isDisabledSearch\n }\"\n />\n <button\n type=\"button\"\n (click)=\"searchButtonClick.emit()\"\n tabindex=\"-1\"\n [disabled]=\"isDisabledSearch\"\n class=\"px-3 flex items-center justify-center shrink-0 _shk-bg-primary hover:[background-color:var(--shk-primary-700)] text-white border _shk-border-primary rounded-r-lg transition-colors duration-200 disabled:[background-color:var(--shk-surface-300)] dark:disabled:[background-color:var(--shk-surface-200)] disabled:[border-color:var(--shk-surface-300)] dark:disabled:[border-color:var(--shk-surface-200)] disabled:cursor-not-allowed\"\n >\n <svg [shkIcon]=\"getIcon('search')\" class=\"w-4 h-4\"></svg>\n </button>\n }\n\n @if (!searchMode()) {\n <input\n #input\n [id]=\"id()\"\n [maxlength]=\"maxLength() || (formatCard() ? 19 : null)\"\n [min]=\"type() === 'number' && preventNegative() ? '0' : null\"\n (keypress)=\"type() === 'number' || numbersOnly() ? numberValidation($event) : null\"\n [type]=\"effectiveType()\"\n [formControl]=\"$any(actualControl())\"\n [placeholder]=\"placeholder() || label()\"\n (input)=\"onInput($event)\"\n [autocomplete]=\"autocomplete()\"\n (blur)=\"onBlur()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class.shk-control-valid]=\"wasFixedError()\"\n class=\"shk-control block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': shouldShowError(),\n 'border-green-500 focus:border-green-500 focus:ring-green-500': wasFixedError(),\n '_shk-border focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !shouldShowError() && !wasFixedError()\n }\"\n [class.pr-8]=\"type() === 'password' && actualControl().value?.length > 0\"\n [class.pr-3]=\"type() !== 'password' || !actualControl().value?.length\"\n />\n\n @if (type() === 'password' && actualControl().value?.length > 0) {\n <button\n type=\"button\"\n (click)=\"togglePasswordVisibility()\"\n [disabled]=\"actualControl().disabled\"\n class=\"absolute right-3 top-1/2 -translate-y-1/2 _shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-600)] focus:outline-none\"\n >\n @if (showPassword()) {\n <svg [shkIcon]=\"getIcon('eye-off')\" class=\"w-4 h-4\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('eye')\" class=\"w-4 h-4\"></svg>\n }\n </button>\n }\n }\n </div>\n }\n\n @if (isTextArea()) {\n <textarea\n #textarea\n [id]=\"id()\"\n [formControl]=\"$any(actualControl())\"\n [placeholder]=\"placeholder() || label()\"\n (input)=\"onInput($event)\"\n (blur)=\"onBlur()\"\n [class]=\"isTextArea() ? textAreaHeight() : 'h-28'\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class.shk-control-valid]=\"wasFixedError()\"\n class=\"shk-control block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 resize-none disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed disabled:[color:var(--shk-surface-400)] dark:disabled:[color:var(--shk-surface-400)] sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': shouldShowError(),\n 'border-green-500 focus:border-green-500 focus:ring-green-500': wasFixedError(),\n '_shk-border focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !shouldShowError() && !wasFixedError()\n }\"\n ></textarea>\n }\n </div>\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>\n"],"mappings":";;;;;;;;;;;AA8DA,IAAa,qBAAb,MAAa,mBAAkB;CA+D7B,IAAY,S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;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -99,6 +99,41 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
99
99
|
}],
|
|
100
100
|
ctorParameters: () => []
|
|
101
101
|
});
|
|
102
|
-
|
|
102
|
+
function signalErrorsToMap(errors) {
|
|
103
|
+
if (!errors || errors.length === 0) return null;
|
|
104
|
+
const map = {};
|
|
105
|
+
for (const error of errors) {
|
|
106
|
+
const params = {};
|
|
107
|
+
for (const [key, value] of Object.entries(error)) if (key !== "kind" && key !== "message" && key !== "fieldTree" && key !== "formField") params[key] = value;
|
|
108
|
+
map[error.kind] = {
|
|
109
|
+
...params,
|
|
110
|
+
message: error.message
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return map;
|
|
114
|
+
}
|
|
115
|
+
function errorMessagesFromMap(errors, customErrors, translate) {
|
|
116
|
+
if (!errors) return [];
|
|
117
|
+
return Object.keys(errors).map((key) => {
|
|
118
|
+
if (customErrors[key]) return customErrors[key];
|
|
119
|
+
const detail = errors[key] ?? {};
|
|
120
|
+
if (typeof detail.message === "string" && detail.message) return detail.message;
|
|
121
|
+
switch (key) {
|
|
122
|
+
case "required": return translate("validation.required");
|
|
123
|
+
case "email": return translate("validation.email");
|
|
124
|
+
case "minlength":
|
|
125
|
+
case "minLength": return translate("validation.minlength", { requiredLength: detail.requiredLength ?? detail.minLength });
|
|
126
|
+
case "maxlength":
|
|
127
|
+
case "maxLength": return translate("validation.maxlength", { requiredLength: detail.requiredLength ?? detail.maxLength });
|
|
128
|
+
case "pattern": return translate("validation.pattern");
|
|
129
|
+
case "min": return translate("validation.min", { min: detail.min });
|
|
130
|
+
case "max": return translate("validation.max", { max: detail.max });
|
|
131
|
+
case "minDate": return translate("validation.minDate", { minDate: detail.minDate });
|
|
132
|
+
case "maxDate": return translate("validation.maxDate", { maxDate: detail.maxDate });
|
|
133
|
+
default: return translate("validation.invalid");
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export { ICONS, PortalDirective, errorMessagesFromMap, getIcon, isIconResolver, portalToBody, signalErrorsToMap };
|
|
103
138
|
|
|
104
139
|
//# sourceMappingURL=shirkasoft-ui-components-utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-utils.mjs","names":[],"sources":["../../../projects/ui-components/utils/icons.ts","../../../projects/ui-components/utils/portal.ts"],"sourcesContent":["/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\nimport {\n LucideArrowDown,\n LucideArrowLeft,\n LucideArrowUp,\n LucideArrowUpDown,\n LucideCalendarDays,\n LucideCheck,\n LucideChevronDown,\n LucideChevronLeft,\n LucideChevronRight,\n LucideChevronsLeft,\n LucideChevronsRight,\n LucideCircleQuestionMark,\n LucideCirclePlus,\n LucideDownload,\n LucideEllipsisVertical,\n LucideEye,\n LucideEyeOff,\n LucideFile,\n LucideFileSpreadsheet,\n LucideFileText,\n LucideFunnel,\n LucideGlobe,\n LucideLanguages,\n LucideInbox,\n LucideInfo,\n LucideLoader,\n LucideLoaderCircle,\n LucideLogOut,\n LucideMaximize2,\n LucideMenu,\n LucideMinimize2,\n LucidePanelRight,\n LucidePlus,\n LucideRefreshCw,\n LucideSearch,\n LucideTrash2,\n LucideTriangleAlert,\n LucideUpload,\n LucideX,\n} from 'shirkasoft-ui-components/icons';\nimport { ICON_BY_NAME } from 'shirkasoft-ui-components/icons';\nimport type { IconNode } from 'shirkasoft-ui-components/icons';\n\n/** Maps the icon names used across the library to their SVG data. */\nexport const ICONS: Record<string, IconNode> = {\n 'arrow-left': LucideArrowLeft,\n 'arrow-down': LucideArrowDown,\n 'arrow-up': LucideArrowUp,\n 'arrow-up-down': LucideArrowUpDown,\n check: LucideCheck,\n 'calendar-days': LucideCalendarDays,\n 'chevron-down': LucideChevronDown,\n 'chevron-left': LucideChevronLeft,\n 'chevron-right': LucideChevronRight,\n 'chevrons-left': LucideChevronsLeft,\n 'chevrons-right': LucideChevronsRight,\n 'circle-help': LucideCircleQuestionMark,\n 'circle-plus': LucideCirclePlus,\n download: LucideDownload,\n 'ellipsis-vertical': LucideEllipsisVertical,\n eye: LucideEye,\n 'eye-off': LucideEyeOff,\n file: LucideFile,\n 'file-spreadsheet': LucideFileSpreadsheet,\n 'file-text': LucideFileText,\n filter: LucideFunnel,\n globe: LucideGlobe,\n languages: LucideLanguages,\n inbox: LucideInbox,\n info: LucideInfo,\n loader: LucideLoader,\n 'loader-circle': LucideLoaderCircle,\n 'log-out': LucideLogOut,\n 'maximize-2': LucideMaximize2,\n menu: LucideMenu,\n 'minimize-2': LucideMinimize2,\n 'panel-right': LucidePanelRight,\n plus: LucidePlus,\n refresh: LucideRefreshCw,\n search: LucideSearch,\n 'trash-2': LucideTrash2,\n 'triangle-alert': LucideTriangleAlert,\n upload: LucideUpload,\n x: LucideX,\n};\n\n/**\n * True when `icon` is a per-item resolver function such as `(row) => 'pencil'`.\n *\n * Classes are functions too, but must never be called: a v1 `@lucide/angular`\n * component passed by an app that has not migrated yet would throw\n * \"Class constructor cannot be invoked without 'new'\". Those fall through to\n * `getIcon()`, which renders the fallback icon instead.\n */\nexport function isIconResolver(icon: unknown): icon is (...args: any[]) => unknown {\n return typeof icon === 'function' && !/^class[\\s{]/.test(Function.prototype.toString.call(icon));\n}\n\n/**\n * Resolves the icon passed to a component into SVG data.\n * Accepts a registered string name or an icon node array.\n */\nexport function getIcon(icon?: any, fallback: any = LucideCircleQuestionMark): IconNode | null {\n if (!icon) return null;\n if (typeof icon === 'string') {\n return ICONS[icon] ?? ICON_BY_NAME[icon] ?? fallback;\n }\n if (Array.isArray(icon)) {\n return icon;\n }\n return fallback;\n}","import { Directive, DestroyRef, ElementRef, afterNextRender, inject } from '@angular/core';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Moves a floating element (dropdown panel, popup, overlay) to `document.body`\n * so it always renders above the rest of the page.\n *\n * `position: fixed` + a high `z-index` is not enough on its own: an ancestor\n * with `transform`, `filter`, `backdrop-filter`, `contain`, or its own stacking\n * context (`z-index` + `position`, `sticky`, `opacity < 1`...) traps the element\n * inside it. Rendering it as a direct child of `body` avoids all of that.\n *\n * The element keeps being managed by Angular (bindings and listeners keep\n * working, and Angular removes it with `node.remove()` when it is hidden).\n * If the anchor lives inside a `.dark` container, the class is copied onto the\n * element so the dark theme (CSS variables, Tailwind `dark:` variants and\n * component `.dark .x` rules) still applies once it is outside the host.\n *\n * Returns a function that removes the element from the DOM; call it when the\n * owner component is destroyed so the element does not stay orphaned in `body`.\n */\nexport function portalToBody(element: HTMLElement, anchor?: HTMLElement | null): () => void {\n const doc = element.ownerDocument;\n if (element.parentNode !== doc.body) {\n doc.body.appendChild(element);\n }\n element.classList.toggle('dark', !!anchor?.closest('.dark'));\n return () => element.remove();\n}\n\n/**\n * Renders the host element in `document.body` (see `portalToBody`) once it is\n * rendered, and removes it when the element or its owner is destroyed.\n *\n * ```html\n * @if (isOpen()) {\n * <div shkPortal class=\"fixed z-[9999]\" [style.top.px]=\"top\">...</div>\n * }\n * ```\n */\n@Directive({ selector: '[shkPortal]' })\nexport class PortalDirective {\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n constructor() {\n let remove: (() => void) | null = null;\n afterNextRender(() => {\n const node = this.el.nativeElement;\n remove = portalToBody(node, node.parentElement);\n });\n inject(DestroyRef).onDestroy(() => remove?.());\n }\n}\n"],"mappings":";;;AAkDA,MAAa,QAAkC;CAC7C,cAAc;CACd,cAAc;CACd,YAAY;CACZ,iBAAiB;CACjB,OAAO;CACP,iBAAiB;C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,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAe,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAf;EAAA,KAAA,OAAA,GAAA,qBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,MAAA;GAAe,cAAA;GAAA,UAAA;GAAA,UAAA;EAAA,CAAA;CAAA;;AAAf,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAe,YAAA,CAAA;EAD3B,MAAA;EAAU,MAAA,CAAA,EAAE,UAAU,cAAa,CAAE"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-utils.mjs","names":[],"sources":["../../../projects/ui-components/utils/icons.ts","../../../projects/ui-components/utils/portal.ts","../../../projects/ui-components/utils/field-errors.ts"],"sourcesContent":["/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\nimport {\n LucideArrowDown,\n LucideArrowLeft,\n LucideArrowUp,\n LucideArrowUpDown,\n LucideCalendarDays,\n LucideCheck,\n LucideChevronDown,\n LucideChevronLeft,\n LucideChevronRight,\n LucideChevronsLeft,\n LucideChevronsRight,\n LucideCircleQuestionMark,\n LucideCirclePlus,\n LucideDownload,\n LucideEllipsisVertical,\n LucideEye,\n LucideEyeOff,\n LucideFile,\n LucideFileSpreadsheet,\n LucideFileText,\n LucideFunnel,\n LucideGlobe,\n LucideLanguages,\n LucideInbox,\n LucideInfo,\n LucideLoader,\n LucideLoaderCircle,\n LucideLogOut,\n LucideMaximize2,\n LucideMenu,\n LucideMinimize2,\n LucidePanelRight,\n LucidePlus,\n LucideRefreshCw,\n LucideSearch,\n LucideTrash2,\n LucideTriangleAlert,\n LucideUpload,\n LucideX,\n} from 'shirkasoft-ui-components/icons';\nimport { ICON_BY_NAME } from 'shirkasoft-ui-components/icons';\nimport type { IconNode } from 'shirkasoft-ui-components/icons';\n\n/** Maps the icon names used across the library to their SVG data. */\nexport const ICONS: Record<string, IconNode> = {\n 'arrow-left': LucideArrowLeft,\n 'arrow-down': LucideArrowDown,\n 'arrow-up': LucideArrowUp,\n 'arrow-up-down': LucideArrowUpDown,\n check: LucideCheck,\n 'calendar-days': LucideCalendarDays,\n 'chevron-down': LucideChevronDown,\n 'chevron-left': LucideChevronLeft,\n 'chevron-right': LucideChevronRight,\n 'chevrons-left': LucideChevronsLeft,\n 'chevrons-right': LucideChevronsRight,\n 'circle-help': LucideCircleQuestionMark,\n 'circle-plus': LucideCirclePlus,\n download: LucideDownload,\n 'ellipsis-vertical': LucideEllipsisVertical,\n eye: LucideEye,\n 'eye-off': LucideEyeOff,\n file: LucideFile,\n 'file-spreadsheet': LucideFileSpreadsheet,\n 'file-text': LucideFileText,\n filter: LucideFunnel,\n globe: LucideGlobe,\n languages: LucideLanguages,\n inbox: LucideInbox,\n info: LucideInfo,\n loader: LucideLoader,\n 'loader-circle': LucideLoaderCircle,\n 'log-out': LucideLogOut,\n 'maximize-2': LucideMaximize2,\n menu: LucideMenu,\n 'minimize-2': LucideMinimize2,\n 'panel-right': LucidePanelRight,\n plus: LucidePlus,\n refresh: LucideRefreshCw,\n search: LucideSearch,\n 'trash-2': LucideTrash2,\n 'triangle-alert': LucideTriangleAlert,\n upload: LucideUpload,\n x: LucideX,\n};\n\n/**\n * True when `icon` is a per-item resolver function such as `(row) => 'pencil'`.\n *\n * Classes are functions too, but must never be called: a v1 `@lucide/angular`\n * component passed by an app that has not migrated yet would throw\n * \"Class constructor cannot be invoked without 'new'\". Those fall through to\n * `getIcon()`, which renders the fallback icon instead.\n */\nexport function isIconResolver(icon: unknown): icon is (...args: any[]) => unknown {\n return typeof icon === 'function' && !/^class[\\s{]/.test(Function.prototype.toString.call(icon));\n}\n\n/**\n * Resolves the icon passed to a component into SVG data.\n * Accepts a registered string name or an icon node array.\n */\nexport function getIcon(icon?: any, fallback: any = LucideCircleQuestionMark): IconNode | null {\n if (!icon) return null;\n if (typeof icon === 'string') {\n return ICONS[icon] ?? ICON_BY_NAME[icon] ?? fallback;\n }\n if (Array.isArray(icon)) {\n return icon;\n }\n return fallback;\n}","import { Directive, DestroyRef, ElementRef, afterNextRender, inject } from '@angular/core';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Moves a floating element (dropdown panel, popup, overlay) to `document.body`\n * so it always renders above the rest of the page.\n *\n * `position: fixed` + a high `z-index` is not enough on its own: an ancestor\n * with `transform`, `filter`, `backdrop-filter`, `contain`, or its own stacking\n * context (`z-index` + `position`, `sticky`, `opacity < 1`...) traps the element\n * inside it. Rendering it as a direct child of `body` avoids all of that.\n *\n * The element keeps being managed by Angular (bindings and listeners keep\n * working, and Angular removes it with `node.remove()` when it is hidden).\n * If the anchor lives inside a `.dark` container, the class is copied onto the\n * element so the dark theme (CSS variables, Tailwind `dark:` variants and\n * component `.dark .x` rules) still applies once it is outside the host.\n *\n * Returns a function that removes the element from the DOM; call it when the\n * owner component is destroyed so the element does not stay orphaned in `body`.\n */\nexport function portalToBody(element: HTMLElement, anchor?: HTMLElement | null): () => void {\n const doc = element.ownerDocument;\n if (element.parentNode !== doc.body) {\n doc.body.appendChild(element);\n }\n element.classList.toggle('dark', !!anchor?.closest('.dark'));\n return () => element.remove();\n}\n\n/**\n * Renders the host element in `document.body` (see `portalToBody`) once it is\n * rendered, and removes it when the element or its owner is destroyed.\n *\n * ```html\n * @if (isOpen()) {\n * <div shkPortal class=\"fixed z-[9999]\" [style.top.px]=\"top\">...</div>\n * }\n * ```\n */\n@Directive({ selector: '[shkPortal]' })\nexport class PortalDirective {\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n constructor() {\n let remove: (() => void) | null = null;\n afterNextRender(() => {\n const node = this.el.nativeElement;\n remove = portalToBody(node, node.parentElement);\n });\n inject(DestroyRef).onDestroy(() => remove?.());\n }\n}\n","import type { ValidationError } from '@angular/forms/signals';\n\n/**\n * Messages keyed by error kind. Accepts both Reactive Forms keys\n * (`required`, `minlength`, `maxlength`…) and Signal Forms keys\n * (`required`, `minLength`, `maxLength`, `minDate`…).\n */\nexport type ShkErrorMessages = { [kind: string]: string };\n\n/**\n * Converts Signal Forms errors (the ones the `FormField` directive delivers to\n * the `errors` input) into the same map exposed by `AbstractControl.errors`.\n *\n * This way controls reuse a single message mapping for Reactive Forms and\n * Signal Forms, and the error parameters (`minLength`, `min`, `maxDate`…) are\n * available under the names Signal Forms uses.\n */\nexport function signalErrorsToMap(\n errors: readonly ValidationError.WithOptionalFieldTree[] | undefined,\n): Record<string, any> | null {\n if (!errors || errors.length === 0) {\n return null;\n }\n\n const map: Record<string, any> = {};\n\n for (const error of errors) {\n const params: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(error)) {\n if (key !== 'kind' && key !== 'message' && key !== 'fieldTree' && key !== 'formField') {\n params[key] = value;\n }\n }\n\n map[error.kind] = { ...params, message: error.message };\n }\n\n return map;\n}\n\n/**\n * Builds the readable message list for an error map.\n *\n * The map may come from `AbstractControl.errors` (Reactive Forms) or from\n * `signalErrorsToMap` (Signal Forms). Priority order:\n * 1. Message configured in `errorMessages`.\n * 2. The error's own message (`message`), e.g. `requiredError({ message })`.\n * 3. Translated message for the error kind.\n *\n * Signal Forms `minLength`/`maxLength` keys are translated with the same\n * `validation.minlength`/`validation.maxlength` keys Reactive Forms uses, so no\n * extra translations are needed.\n */\nexport function errorMessagesFromMap(\n errors: Record<string, any> | null | undefined,\n customErrors: ShkErrorMessages,\n translate: (key: string, params?: Record<string, any>) => string,\n): string[] {\n if (!errors) {\n return [];\n }\n\n return Object.keys(errors).map((key) => {\n if (customErrors[key]) {\n return customErrors[key];\n }\n\n const detail = errors[key] ?? {};\n if (typeof detail.message === 'string' && detail.message) {\n return detail.message;\n }\n\n switch (key) {\n case 'required':\n return translate('validation.required');\n case 'email':\n return translate('validation.email');\n case 'minlength':\n case 'minLength':\n return translate('validation.minlength', {\n requiredLength: detail.requiredLength ?? detail.minLength,\n });\n case 'maxlength':\n case 'maxLength':\n return translate('validation.maxlength', {\n requiredLength: detail.requiredLength ?? detail.maxLength,\n });\n case 'pattern':\n return translate('validation.pattern');\n case 'min':\n return translate('validation.min', { min: detail.min });\n case 'max':\n return translate('validation.max', { max: detail.max });\n case 'minDate':\n return translate('validation.minDate', { minDate: detail.minDate });\n case 'maxDate':\n return translate('validation.maxDate', { maxDate: detail.maxDate });\n default:\n return translate('validation.invalid');\n }\n });\n}\n"],"mappings":";;;AAkDA,MAAa,QAAkC;CAC7C,cAAc;CACd,cAAc;CACd,YAAY;CACZ,iBAAiB;CACjB,OAAO;CACP,iBAAiB;CACjB,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,kBAAkB;CAClB,eAAe;CACf,eAAe;CACf,UAAU;CACV,qBAAqB;CACrB,KAAK;CACL,WAAW;CACX,MAAM;CACN,oBAAoB;CACpB,aAAa;CACb,QAAQ;CACR,OAAO;CACP,WAAW;CACX,OAAO;CACP,MAAM;CACN,QAAQ;CACR,iBAAiB;CACjB,WAAW;CACX,cAAc;CACd,MAAM;CACN,cAAc;CACd,eAAe;CACf,MAAM;CACN,SAAS;CACT,QAAQ;CACR,WAAW;CACX,kBAAkB;CAClB,QAAQ;CACR,GAAG;AACJ;AAUD,SAAgB,eAAe,MAAa;CAC1C,OAAO,OAAO,SAAS,cAAc,CAAC,cAAc,KAAK,SAAS,UAAU,SAAS,KAAK,IAAI,CAAC;AACjG;AAMA,SAAgB,QAAQ,MAAY,WAAgB,0BAAwB;CAC1E,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,OAAO,SAAS,UAClB,OAAO,MAAM,SAAS,aAAa,SAAS;CAE9C,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO;CAET,OAAO;AACT;AC3FA,SAAgB,aAAa,SAAsB,QAA2B;CAC5E,MAAM,MAAM,QAAQ;CACpB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ACd,QACA,cACA,WAAgE;CAEhE,IAAI,CAAC,QACH,OAAO,CAAA;CAGT,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,KAAK,QAAO;EACrC,IAAI,aAAa,MACf,OAAO,aAAa;EAGtB,MAAM,SAAS,OAAO,QAAQ,CAAA;EAC9B,IAAI,OAAO,OAAO,YAAY,YAAY,OAAO,SAC/C,OAAO,OAAO;EAGhB,QAAQ,KAAR;GACE,KAAK,YACH,OAAO,UAAU,qBAAqB;GACxC,KAAK,SACH,OAAO,UAAU,kBAAkB;GACrC,KAAK;GACL,KAAK,aACH,OAAO,UAAU,wBAAwB,EACvC,gBAAgB,OAAO,kBAAkB,OAAO,UACjD,CAAA;GACH,KAAK;GACL,KAAK,aACH,OAAO,UAAU,wBAAwB,EACvC,gBAAgB,OAAO,kBAAkB,OAAO,UACjD,CAAA;GACH,KAAK,WACH,OAAO,UAAU,oBAAoB;GACvC,KAAK,OACH,OAAO,UAAU,kBAAkB,EAAE,KAAK,OAAO,IAAG,CAAE;GACxD,KAAK,OACH,OAAO,UAAU,kBAAkB,EAAE,KAAK,OAAO,IAAG,CAAE;GACxD,KAAK,WACH,OAAO,UAAU,sBAAsB,EAAE,SAAS,OAAO,QAAO,CAAE;GACpE,KAAK,WACH,OAAO,UAAU,sBAAsB,EAAE,SAAS,OAAO,QAAO,CAAE;GACpE,SACE,OAAO,UAAU,oBAAoB;EACzC;CACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
4
|
import { ControlValueAccessor, FormControl, FormGroup } from "@angular/forms";
|
|
5
|
-
import { FormValueControl } from "@angular/forms/signals";
|
|
5
|
+
import { FormValueControl, ValidationError } from "@angular/forms/signals";
|
|
6
6
|
import { ShkDateDisplayStyle } from "shirkasoft-ui-components/config";
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
/** Which granularity the picker edits: a day, a week, a month or a year. */
|
|
@@ -70,6 +70,14 @@ export declare class DatePickerComponent implements ControlValueAccessor, FormVa
|
|
|
70
70
|
control: import("@angular/core").InputSignal<FormControl<any> | undefined>;
|
|
71
71
|
/** Disables the picker. */
|
|
72
72
|
disabled: import("@angular/core").InputSignal<boolean>;
|
|
73
|
+
/** Errors bound automatically by the Signal Forms `[formField]` directive. */
|
|
74
|
+
errors: import("@angular/core").InputSignal<readonly ValidationError.WithOptionalFieldTree[]>;
|
|
75
|
+
/** Invalid status bound automatically by `[formField]`. */
|
|
76
|
+
invalid: import("@angular/core").InputSignal<boolean>;
|
|
77
|
+
/** Touched status bound automatically by `[formField]`. */
|
|
78
|
+
touched: import("@angular/core").InputSignal<boolean>;
|
|
79
|
+
/** Dirty status bound automatically by `[formField]`. */
|
|
80
|
+
dirty: import("@angular/core").InputSignal<boolean>;
|
|
73
81
|
/** Custom error message displayed (overrides translated ones). */
|
|
74
82
|
errorMessage: import("@angular/core").InputSignal<string>;
|
|
75
83
|
/** Per-validation-key custom error messages. */
|
|
@@ -185,6 +193,12 @@ export declare class DatePickerComponent implements ControlValueAccessor, FormVa
|
|
|
185
193
|
isDisabled: import("@angular/core").Signal<boolean>;
|
|
186
194
|
/** Resolves the control from `control` input or `formGroup`+`controlName`. */
|
|
187
195
|
actualControl: import("@angular/core").Signal<FormControl<any> | undefined>;
|
|
196
|
+
/**
|
|
197
|
+
* True when the picker is driven by Signal Forms instead of a reactive control.
|
|
198
|
+
* Detected by the absence of a reactive control: `[formField]` provides the
|
|
199
|
+
* state through its `errors`/`invalid`/`touched`/`dirty` inputs.
|
|
200
|
+
*/
|
|
201
|
+
protected readonly usesSignalForms: import("@angular/core").Signal<boolean>;
|
|
188
202
|
shouldShowError: import("@angular/core").Signal<boolean | undefined>;
|
|
189
203
|
wasFixedError: import("@angular/core").Signal<boolean | undefined>;
|
|
190
204
|
getErrorMessages: import("@angular/core").Signal<string[]>;
|
|
@@ -475,6 +489,26 @@ export declare class DatePickerComponent implements ControlValueAccessor, FormVa
|
|
|
475
489
|
"required": false;
|
|
476
490
|
"isSignal": true;
|
|
477
491
|
};
|
|
492
|
+
"errors": {
|
|
493
|
+
"alias": "errors";
|
|
494
|
+
"required": false;
|
|
495
|
+
"isSignal": true;
|
|
496
|
+
};
|
|
497
|
+
"invalid": {
|
|
498
|
+
"alias": "invalid";
|
|
499
|
+
"required": false;
|
|
500
|
+
"isSignal": true;
|
|
501
|
+
};
|
|
502
|
+
"touched": {
|
|
503
|
+
"alias": "touched";
|
|
504
|
+
"required": false;
|
|
505
|
+
"isSignal": true;
|
|
506
|
+
};
|
|
507
|
+
"dirty": {
|
|
508
|
+
"alias": "dirty";
|
|
509
|
+
"required": false;
|
|
510
|
+
"isSignal": true;
|
|
511
|
+
};
|
|
478
512
|
"errorMessage": {
|
|
479
513
|
"alias": "errorMessage";
|
|
480
514
|
"required": false;
|