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
|
@@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, Component, computed, inject, input, model, out
|
|
|
3
3
|
import { CommonModule } from "@angular/common";
|
|
4
4
|
import { TranslocoService } from "@jsverse/transloco";
|
|
5
5
|
import { LucideUpload, ShkIconDirective } from "shirkasoft-ui-components/icons";
|
|
6
|
-
import { getIcon } from "shirkasoft-ui-components/utils";
|
|
6
|
+
import { errorMessagesFromMap, getIcon, signalErrorsToMap } from "shirkasoft-ui-components/utils";
|
|
7
7
|
var FileUploadComponent = class FileUploadComponent {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.getIcon = (name) => getIcon(name, LucideUpload);
|
|
@@ -18,6 +18,10 @@ var FileUploadComponent = class FileUploadComponent {
|
|
|
18
18
|
this.multiple = input(false, ...ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []);
|
|
19
19
|
this.existingFiles = input([], ...ngDevMode ? [{ debugName: "existingFiles" }] : /* istanbul ignore next */ []);
|
|
20
20
|
this.existingDisplay = input("chips", ...ngDevMode ? [{ debugName: "existingDisplay" }] : /* istanbul ignore next */ []);
|
|
21
|
+
this.errors = input([], ...ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []);
|
|
22
|
+
this.invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
23
|
+
this.touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
24
|
+
this.dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
21
25
|
this.fileSelected = output();
|
|
22
26
|
this.fileRemoved = output();
|
|
23
27
|
this.fileError = output();
|
|
@@ -28,6 +32,13 @@ var FileUploadComponent = class FileUploadComponent {
|
|
|
28
32
|
this.touch = output();
|
|
29
33
|
this.errorMessage = signal("", ...ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []);
|
|
30
34
|
this.isDragOver = signal(false, ...ngDevMode ? [{ debugName: "isDragOver" }] : /* istanbul ignore next */ []);
|
|
35
|
+
this.displayError = computed(() => {
|
|
36
|
+
const local = this.errorMessage();
|
|
37
|
+
if (local) return local;
|
|
38
|
+
if (!this.invalid() || !this.touched() && !this.dirty()) return "";
|
|
39
|
+
const translate = (key, params) => this.transloco.translate(key, params);
|
|
40
|
+
return errorMessagesFromMap(signalErrorsToMap(this.errors()), {}, translate)[0] ?? "";
|
|
41
|
+
}, ...ngDevMode ? [{ debugName: "displayError" }] : /* istanbul ignore next */ []);
|
|
31
42
|
this.previewUrls = /* @__PURE__ */ new Map();
|
|
32
43
|
this.canAddMore = computed(() => {
|
|
33
44
|
if (!this.multiple()) return this.selectedFiles().length === 0;
|
|
@@ -306,6 +317,34 @@ var FileUploadComponent = class FileUploadComponent {
|
|
|
306
317
|
isRequired: false,
|
|
307
318
|
transformFunction: null
|
|
308
319
|
},
|
|
320
|
+
errors: {
|
|
321
|
+
classPropertyName: "errors",
|
|
322
|
+
publicName: "errors",
|
|
323
|
+
isSignal: true,
|
|
324
|
+
isRequired: false,
|
|
325
|
+
transformFunction: null
|
|
326
|
+
},
|
|
327
|
+
invalid: {
|
|
328
|
+
classPropertyName: "invalid",
|
|
329
|
+
publicName: "invalid",
|
|
330
|
+
isSignal: true,
|
|
331
|
+
isRequired: false,
|
|
332
|
+
transformFunction: null
|
|
333
|
+
},
|
|
334
|
+
touched: {
|
|
335
|
+
classPropertyName: "touched",
|
|
336
|
+
publicName: "touched",
|
|
337
|
+
isSignal: true,
|
|
338
|
+
isRequired: false,
|
|
339
|
+
transformFunction: null
|
|
340
|
+
},
|
|
341
|
+
dirty: {
|
|
342
|
+
classPropertyName: "dirty",
|
|
343
|
+
publicName: "dirty",
|
|
344
|
+
isSignal: true,
|
|
345
|
+
isRequired: false,
|
|
346
|
+
transformFunction: null
|
|
347
|
+
},
|
|
309
348
|
value: {
|
|
310
349
|
classPropertyName: "value",
|
|
311
350
|
publicName: "value",
|
|
@@ -325,7 +364,7 @@ var FileUploadComponent = class FileUploadComponent {
|
|
|
325
364
|
touch: "touch"
|
|
326
365
|
},
|
|
327
366
|
ngImport: i0,
|
|
328
|
-
template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"text-sm font-medium _shk-text-surface-700\">\n {{ label() }}\n </label>\n }\n\n @if (canAddMore()) {\n <div\n class=\"shk-dropzone relative border-2 border-dashed _shk-border rounded-lg p-4 transition-colors hover:[border-color:var(--shk-primary-400)] dark:hover:[border-color:var(--shk-primary-500)]\"\n [attr.aria-invalid]=\"
|
|
367
|
+
template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"text-sm font-medium _shk-text-surface-700\">\n {{ label() }}\n </label>\n }\n\n @if (canAddMore()) {\n <div\n class=\"shk-dropzone relative border-2 border-dashed _shk-border rounded-lg p-4 transition-colors hover:[border-color:var(--shk-primary-400)] dark:hover:[border-color:var(--shk-primary-500)]\"\n [attr.aria-invalid]=\"displayError() ? true : null\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\"\n >\n <input\n #fileInput\n type=\"file\"\n [accept]=\"accept()\"\n [multiple]=\"multiple()\"\n (change)=\"onFileChange($event)\"\n class=\"hidden\"\n />\n\n <div\n class=\"flex flex-col items-center gap-2 cursor-pointer\"\n (click)=\"fileInput.click()\"\n [class.drag-over]=\"isDragOver()\"\n >\n <svg [shkIcon]=\"getIcon('upload')\" class=\"w-8 h-8 _shk-icon-subtle\"></svg>\n <span class=\"text-sm _shk-text-surface-700\">\n {{ fileUploadText() }}\n </span>\n @if (fileRecommendation()) {\n <span class=\"text-xs _shk-text-surface-400\">\n {{ fileRecommendation() }}\n </span>\n }\n </div>\n </div>\n }\n\n @if (maxReached()) {\n <div class=\"text-xs _shk-text-surface-400 text-center py-2\">\n Máximo {{ maxFiles() }} archivos alcanzado\n </div>\n }\n\n @if (selectedFiles().length > 0) {\n <div class=\"flex flex-wrap gap-3\">\n @for (file of selectedFiles(); track file.name + file.size + file.lastModified) {\n <div class=\"relative group\">\n @if (isImageFile(file)) {\n <img\n [src]=\"previewUrl(file)\"\n [alt]=\"file.name\"\n class=\"w-20 h-20 object-cover rounded-lg _shk-border\"\n />\n } @else {\n <div class=\"w-20 h-20 rounded-lg _shk-border flex flex-col items-center justify-center _shk-bg-surface-50 gap-1\">\n <svg [shkIcon]=\"getIcon('file')\" class=\"w-6 h-6 _shk-text-surface-400\"></svg>\n <span class=\"text-[10px] _shk-text-surface-400 truncate max-w-[70px] px-1 text-center\">{{ file.name }}</span>\n </div>\n }\n <button\n type=\"button\"\n (click)=\"removeFile(file)\"\n class=\"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 text-white rounded-full text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition shadow\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3 h-3\"></svg>\n </button>\n </div>\n }\n </div>\n @if (!multiple()) {\n <button\n type=\"button\"\n (click)=\"changeFiles()\"\n class=\"text-xs _shk-text-primary hover:[color:var(--shk-primary-700)] dark:[color:var(--shk-primary-400)] dark:hover:[color:var(--shk-primary-300)] underline cursor-pointer bg-transparent border-0\"\n >\n {{ changeFilesText() }}\n </button>\n }\n }\n\n @if (existingFiles().length > 0) {\n <div class=\"flex flex-wrap gap-3\">\n @for (file of existingFiles(); track trackExistingFile(file)) {\n @if (existingDisplay() === 'tiles') {\n @let badge = getExistingBadge(file);\n <div class=\"relative group w-[80px]\">\n <div\n class=\"w-20 h-20 rounded-lg border _shk-border overflow-hidden cursor-pointer relative\"\n (click)=\"onExistingAction(file)\"\n [title]=\"file.name\"\n >\n @if (isExistingImage(file) && file.url) {\n <img [src]=\"file.url\" [alt]=\"file.name\" class=\"w-full h-full object-cover\" />\n } @else {\n <div class=\"w-full h-full flex flex-col items-center justify-center gap-1 _shk-bg-surface-50\">\n <svg [shkIcon]=\"getIcon(badge.icon)\" class=\"w-6 h-6 _shk-text-surface-400\"></svg>\n <span class=\"px-1.5 py-0.5 rounded text-[9px] font-semibold leading-none\" [class]=\"badge.color\">\n {{ badge.label }}\n </span>\n </div>\n }\n <div\n class=\"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 flex items-center justify-center transition rounded-lg\"\n >\n <svg [shkIcon]=\"getIcon('download')\" class=\"w-5 h-5 text-white\"></svg>\n </div>\n </div>\n <button\n type=\"button\"\n (click)=\"onExistingRemove(file)\"\n class=\"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition shadow\"\n aria-label=\"Remove\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3 h-3\"></svg>\n </button>\n <span class=\"block text-[10px] _shk-text-surface-400 truncate text-center mt-1 max-w-[80px]\" [title]=\"file.name\">\n {{ file.name }}\n </span>\n </div>\n } @else {\n @let badge = getExistingBadge(file);\n <div class=\"flex items-center gap-2 _shk-bg-surface-50 border _shk-border rounded-full pl-3 pr-1.5 py-1 text-sm _shk-text-surface-700\">\n <svg [shkIcon]=\"getIcon(badge.icon)\" class=\"w-4 h-4 _shk-text-surface-400 shrink-0\"></svg>\n <span class=\"max-w-[200px] truncate\" [title]=\"file.name\">{{ file.name }}</span>\n <button\n type=\"button\"\n (click)=\"onExistingAction(file)\"\n [title]=\"file.name\"\n class=\"p-1 rounded-full hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 hover:[color:var(--shk-primary-600)]\"\n >\n <svg [shkIcon]=\"getIcon('download')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"onExistingRemove(file)\"\n class=\"p-1 rounded-full hover:[background-color:var(--shk-error-50)] _shk-text-surface-500 hover:[color:var(--shk-error-600)]\"\n aria-label=\"Remove\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n </div>\n }\n }\n </div>\n }\n\n @if (displayError()) {\n <p class=\"text-xs _shk-text-red-500\">{{ displayError() }}</p>\n }\n</div>",
|
|
329
368
|
dependencies: [{
|
|
330
369
|
kind: "ngmodule",
|
|
331
370
|
type: CommonModule
|
|
@@ -355,7 +394,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
355
394
|
selector: "shk-file-upload",
|
|
356
395
|
imports: [CommonModule, ShkIconDirective],
|
|
357
396
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
358
|
-
template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"text-sm font-medium _shk-text-surface-700\">\n {{ label() }}\n </label>\n }\n\n @if (canAddMore()) {\n <div\n class=\"shk-dropzone relative border-2 border-dashed _shk-border rounded-lg p-4 transition-colors hover:[border-color:var(--shk-primary-400)] dark:hover:[border-color:var(--shk-primary-500)]\"\n [attr.aria-invalid]=\"
|
|
397
|
+
template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"text-sm font-medium _shk-text-surface-700\">\n {{ label() }}\n </label>\n }\n\n @if (canAddMore()) {\n <div\n class=\"shk-dropzone relative border-2 border-dashed _shk-border rounded-lg p-4 transition-colors hover:[border-color:var(--shk-primary-400)] dark:hover:[border-color:var(--shk-primary-500)]\"\n [attr.aria-invalid]=\"displayError() ? true : null\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\"\n >\n <input\n #fileInput\n type=\"file\"\n [accept]=\"accept()\"\n [multiple]=\"multiple()\"\n (change)=\"onFileChange($event)\"\n class=\"hidden\"\n />\n\n <div\n class=\"flex flex-col items-center gap-2 cursor-pointer\"\n (click)=\"fileInput.click()\"\n [class.drag-over]=\"isDragOver()\"\n >\n <svg [shkIcon]=\"getIcon('upload')\" class=\"w-8 h-8 _shk-icon-subtle\"></svg>\n <span class=\"text-sm _shk-text-surface-700\">\n {{ fileUploadText() }}\n </span>\n @if (fileRecommendation()) {\n <span class=\"text-xs _shk-text-surface-400\">\n {{ fileRecommendation() }}\n </span>\n }\n </div>\n </div>\n }\n\n @if (maxReached()) {\n <div class=\"text-xs _shk-text-surface-400 text-center py-2\">\n Máximo {{ maxFiles() }} archivos alcanzado\n </div>\n }\n\n @if (selectedFiles().length > 0) {\n <div class=\"flex flex-wrap gap-3\">\n @for (file of selectedFiles(); track file.name + file.size + file.lastModified) {\n <div class=\"relative group\">\n @if (isImageFile(file)) {\n <img\n [src]=\"previewUrl(file)\"\n [alt]=\"file.name\"\n class=\"w-20 h-20 object-cover rounded-lg _shk-border\"\n />\n } @else {\n <div class=\"w-20 h-20 rounded-lg _shk-border flex flex-col items-center justify-center _shk-bg-surface-50 gap-1\">\n <svg [shkIcon]=\"getIcon('file')\" class=\"w-6 h-6 _shk-text-surface-400\"></svg>\n <span class=\"text-[10px] _shk-text-surface-400 truncate max-w-[70px] px-1 text-center\">{{ file.name }}</span>\n </div>\n }\n <button\n type=\"button\"\n (click)=\"removeFile(file)\"\n class=\"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 text-white rounded-full text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition shadow\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3 h-3\"></svg>\n </button>\n </div>\n }\n </div>\n @if (!multiple()) {\n <button\n type=\"button\"\n (click)=\"changeFiles()\"\n class=\"text-xs _shk-text-primary hover:[color:var(--shk-primary-700)] dark:[color:var(--shk-primary-400)] dark:hover:[color:var(--shk-primary-300)] underline cursor-pointer bg-transparent border-0\"\n >\n {{ changeFilesText() }}\n </button>\n }\n }\n\n @if (existingFiles().length > 0) {\n <div class=\"flex flex-wrap gap-3\">\n @for (file of existingFiles(); track trackExistingFile(file)) {\n @if (existingDisplay() === 'tiles') {\n @let badge = getExistingBadge(file);\n <div class=\"relative group w-[80px]\">\n <div\n class=\"w-20 h-20 rounded-lg border _shk-border overflow-hidden cursor-pointer relative\"\n (click)=\"onExistingAction(file)\"\n [title]=\"file.name\"\n >\n @if (isExistingImage(file) && file.url) {\n <img [src]=\"file.url\" [alt]=\"file.name\" class=\"w-full h-full object-cover\" />\n } @else {\n <div class=\"w-full h-full flex flex-col items-center justify-center gap-1 _shk-bg-surface-50\">\n <svg [shkIcon]=\"getIcon(badge.icon)\" class=\"w-6 h-6 _shk-text-surface-400\"></svg>\n <span class=\"px-1.5 py-0.5 rounded text-[9px] font-semibold leading-none\" [class]=\"badge.color\">\n {{ badge.label }}\n </span>\n </div>\n }\n <div\n class=\"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 flex items-center justify-center transition rounded-lg\"\n >\n <svg [shkIcon]=\"getIcon('download')\" class=\"w-5 h-5 text-white\"></svg>\n </div>\n </div>\n <button\n type=\"button\"\n (click)=\"onExistingRemove(file)\"\n class=\"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition shadow\"\n aria-label=\"Remove\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3 h-3\"></svg>\n </button>\n <span class=\"block text-[10px] _shk-text-surface-400 truncate text-center mt-1 max-w-[80px]\" [title]=\"file.name\">\n {{ file.name }}\n </span>\n </div>\n } @else {\n @let badge = getExistingBadge(file);\n <div class=\"flex items-center gap-2 _shk-bg-surface-50 border _shk-border rounded-full pl-3 pr-1.5 py-1 text-sm _shk-text-surface-700\">\n <svg [shkIcon]=\"getIcon(badge.icon)\" class=\"w-4 h-4 _shk-text-surface-400 shrink-0\"></svg>\n <span class=\"max-w-[200px] truncate\" [title]=\"file.name\">{{ file.name }}</span>\n <button\n type=\"button\"\n (click)=\"onExistingAction(file)\"\n [title]=\"file.name\"\n class=\"p-1 rounded-full hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 hover:[color:var(--shk-primary-600)]\"\n >\n <svg [shkIcon]=\"getIcon('download')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"onExistingRemove(file)\"\n class=\"p-1 rounded-full hover:[background-color:var(--shk-error-50)] _shk-text-surface-500 hover:[color:var(--shk-error-600)]\"\n aria-label=\"Remove\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n </div>\n }\n }\n </div>\n }\n\n @if (displayError()) {\n <p class=\"text-xs _shk-text-red-500\">{{ displayError() }}</p>\n }\n</div>"
|
|
359
398
|
}]
|
|
360
399
|
}],
|
|
361
400
|
propDecorators: {
|
|
@@ -439,6 +478,38 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
439
478
|
required: false
|
|
440
479
|
}]
|
|
441
480
|
}],
|
|
481
|
+
errors: [{
|
|
482
|
+
type: i0.Input,
|
|
483
|
+
args: [{
|
|
484
|
+
isSignal: true,
|
|
485
|
+
alias: "errors",
|
|
486
|
+
required: false
|
|
487
|
+
}]
|
|
488
|
+
}],
|
|
489
|
+
invalid: [{
|
|
490
|
+
type: i0.Input,
|
|
491
|
+
args: [{
|
|
492
|
+
isSignal: true,
|
|
493
|
+
alias: "invalid",
|
|
494
|
+
required: false
|
|
495
|
+
}]
|
|
496
|
+
}],
|
|
497
|
+
touched: [{
|
|
498
|
+
type: i0.Input,
|
|
499
|
+
args: [{
|
|
500
|
+
isSignal: true,
|
|
501
|
+
alias: "touched",
|
|
502
|
+
required: false
|
|
503
|
+
}]
|
|
504
|
+
}],
|
|
505
|
+
dirty: [{
|
|
506
|
+
type: i0.Input,
|
|
507
|
+
args: [{
|
|
508
|
+
isSignal: true,
|
|
509
|
+
alias: "dirty",
|
|
510
|
+
required: false
|
|
511
|
+
}]
|
|
512
|
+
}],
|
|
442
513
|
fileSelected: [{
|
|
443
514
|
type: i0.Output,
|
|
444
515
|
args: ["fileSelected"]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-file-upload.mjs","names":["getIconFromCentral"],"sources":["../../../projects/ui-components/file-upload/file-upload.component.ts","../../../projects/ui-components/file-upload/file-upload.component.html"],"sourcesContent":["import {\n Component,\n input,\n model,\n output,\n signal,\n computed,\n ChangeDetectionStrategy,\n inject,\n OnDestroy,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { TranslocoService } from '@jsverse/transloco';\nimport { ShkIconDirective, LucideUpload } from 'shirkasoft-ui-components/icons';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nexport interface FileUploadError {\n type: 'size' | 'type';\n message: string;\n file: File;\n}\n\nexport interface ExistingFile {\n id?: number | string;\n name: string;\n url?: string;\n mimeType?: string;\n size?: number;\n}\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 * Drag & drop file uploader with file type/size validation, image previews,\n * multiple files support and localized error messages.\n */\n@Component({\n selector: 'shk-file-upload',\n imports: [CommonModule, ShkIconDirective],\n templateUrl: './file-upload.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class FileUploadComponent implements OnDestroy, FormValueControl<File[]> {\n protected getIcon = (name: any) => getIconFromCentral(name, LucideUpload);\n private transloco = inject(TranslocoService);\n\n /** Main label of the uploader. */\n label = input<string>('Cargar archivo');\n /** Accepted MIME types/extensions (e.g. 'image/*', '.pdf'). */\n accept = input<string>('image/*');\n /** Maximum allowed size per file (bytes). */\n maxFileSize = input<number>(2 * 1024 * 1024);\n /** Maximum number of files (0 = unlimited). */\n maxFiles = input<number>(0);\n /** Text of the file picker button. */\n fileUploadText = input<string>('Seleccionar archivo');\n /** Helper text shown next to the label. */\n fileRecommendation = input<string>('');\n /** Text shown when files are already loaded. */\n changeFilesText = input<string>('Cambiar archivos');\n /** Enables selecting more than one file at once. */\n multiple = input<boolean>(false);\n /** Files already stored by the parent (read-only; the component only emits events). */\n existingFiles = input<ExistingFile[]>([]);\n /** How existing files are rendered. */\n existingDisplay = input<'chips' | 'tiles'>('chips');\n\n /** Emitted with the currently selected files. */\n fileSelected = output<File[]>();\n /** Emitted when the last selected file is removed. */\n fileRemoved = output<void>();\n /** Emitted when a file fails validation (type/size). */\n fileError = output<FileUploadError>();\n /** Emitted when a file is near the size limit. */\n fileWarning = output<FileUploadError>();\n /** Emitted when an existing file is requested for download/view. */\n existingFileAction = output<ExistingFile>();\n /** Emitted when an existing file should be removed (parent deletes it). */\n existingFileRemove = output<ExistingFile>();\n\n /** Currently selected files. Two-way bindable and used by `[formField]`. */\n value = model<File[]>([]);\n /** Alias kept for the existing implementation and templates. */\n get selectedFiles() {\n return this.value;\n }\n /** Emitted when the selection changes so Signal Forms marks the field as touched. */\n touch = output<void>();\n /** Localized error message displayed to the user. */\n errorMessage = signal<string>('');\n /** Whether the user is dragging files over the zone. */\n isDragOver = signal<boolean>(false);\n\n /** Object URLs used for image previews. */\n private previewUrls = new Map<File, string>();\n\n /** Whether another selection is allowed. */\n canAddMore = computed(() => {\n if (!this.multiple()) return this.selectedFiles().length === 0;\n const max = this.maxFiles();\n if (max <= 0) return true;\n return this.selectedFiles().length < max;\n });\n\n /** True when the maximum number of files has been reached. */\n maxReached = computed(() => {\n const max = this.maxFiles();\n if (max <= 0) return false;\n return this.selectedFiles().length >= max;\n });\n\n /** Whether the file is an image (used for previews). */\n isImageFile(file: File): boolean {\n return file.type.startsWith('image/');\n }\n\n /** Returns (creating on demand) the object URL for a file preview. */\n previewUrl(file: File): string {\n if (!this.previewUrls.has(file)) {\n this.previewUrls.set(file, URL.createObjectURL(file));\n }\n return this.previewUrls.get(file) ?? '';\n }\n\n /** Marks the drop zone as active while dragging over it. */\n onDragOver(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(true);\n }\n\n /** Clears the drag-over state when the drag leaves the zone. */\n onDragLeave(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(false);\n }\n\n /** Processes the files dropped on the zone. */\n onDrop(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(false);\n\n const files = event.dataTransfer?.files;\n if (files && files.length > 0) {\n this.processFiles(Array.from(files));\n }\n }\n\n /** Processes the files picked from the native file input. */\n onFileChange(event: Event): void {\n const input = event.target as HTMLInputElement;\n const files = input.files;\n if (files && files.length > 0) {\n this.processFiles(Array.from(files));\n }\n input.value = '';\n }\n\n /** Validates and appends the received files, emitting errors/warnings. */\n private processFiles(files: File[]): void {\n this.errorMessage.set('');\n const validFiles: File[] = [];\n\n for (const file of files) {\n const error = this.validateFile(file);\n if (error) {\n this.fileError.emit(error);\n this.errorMessage.set(error.message);\n return;\n }\n\n const warning = this.checkSizeWarning(file);\n if (warning) {\n this.fileWarning.emit(warning);\n }\n\n validFiles.push(file);\n }\n\n const max = this.maxFiles();\n if (max > 0) {\n const currentCount = this.selectedFiles().length;\n const allowed = max - currentCount;\n if (validFiles.length > allowed) {\n const errorMsg = this.transloco.translate('fileUpload.maxFiles', undefined, `Máximo ${max} archivos permitidos`);\n this.errorMessage.set(errorMsg);\n return;\n }\n }\n\n if (this.multiple()) {\n this.selectedFiles.set([...this.selectedFiles(), ...validFiles]);\n } else {\n this.clearPreviews();\n this.selectedFiles.set(validFiles);\n }\n\n this.touch.emit();\n this.fileSelected.emit(this.selectedFiles());\n }\n\n /** Validates a file against `accept` and `maxFileSize`. */\n private validateFile(file: File): FileUploadError | null {\n const acceptStr = this.accept();\n if (acceptStr && acceptStr !== '*') {\n const acceptTypes = acceptStr.split(',').map((t) => t.trim());\n const valid = acceptTypes.some((type) => {\n if (type.endsWith('/*')) {\n const category = type.replace('/*', '');\n return file.type.startsWith(category);\n }\n if (type.startsWith('.')) {\n const ext = type.slice(1).toLowerCase();\n return file.name.toLowerCase().endsWith('.' + ext);\n }\n if (type.includes('/')) {\n return file.type === type;\n }\n return false;\n });\n\n if (!valid) {\n return {\n type: 'type',\n message: this.transloco.translate('fileUpload.invalidType', { accept: acceptStr }, `Tipo de archivo no válido. Formatos aceptados: ${acceptStr}`),\n file,\n };\n }\n }\n\n if (this.maxFileSize() > 0 && file.size > this.maxFileSize()) {\n return {\n type: 'size',\n message: this.transloco.translate('fileUpload.fileTooLarge', { size: this.formatFileSize(this.maxFileSize()) }, `El archivo excede el tamaño máximo de ${this.formatFileSize(this.maxFileSize())}`),\n file,\n };\n }\n\n return null;\n }\n\n /** Emits a warning when the file is close to the size limit (>90%). */\n private checkSizeWarning(file: File): FileUploadError | null {\n if (this.maxFileSize() > 0 && file.size > this.maxFileSize() * 0.9) {\n return {\n type: 'size',\n message: this.transloco.translate('fileUpload.sizeWarning', { size: this.formatFileSize(this.maxFileSize()) }, `El archivo está cerca del límite de tamaño (${this.formatFileSize(this.maxFileSize())})`),\n file,\n };\n }\n return null;\n }\n\n /** Removes a file, revoking its preview URL. */\n removeFile(file: File): void {\n const url = this.previewUrls.get(file);\n if (url) {\n URL.revokeObjectURL(url);\n this.previewUrls.delete(file);\n }\n\n this.selectedFiles.update((files) => files.filter((f) => f !== file));\n this.errorMessage.set('');\n\n if (this.selectedFiles().length === 0) {\n this.fileRemoved.emit();\n }\n }\n\n /** Clears all selected files and previews. */\n changeFiles(): void {\n this.clearPreviews();\n this.selectedFiles.set([]);\n this.errorMessage.set('');\n }\n\n /** Revokes every stored preview object URL. */\n private clearPreviews(): void {\n for (const [file, url] of this.previewUrls) {\n URL.revokeObjectURL(url);\n }\n this.previewUrls.clear();\n }\n\n /** Revokes pending preview URLs when the component is destroyed. */\n ngOnDestroy(): void {\n this.clearPreviews();\n }\n\n /** Emits the action (download/view) for an existing file. */\n onExistingAction(file: ExistingFile): void {\n this.existingFileAction.emit(file);\n }\n\n /** Emits the removal request for an existing file. */\n onExistingRemove(file: ExistingFile): void {\n this.existingFileRemove.emit(file);\n }\n\n /** Whether an existing file is an image (by mime type or extension). */\n isExistingImage(file: ExistingFile): boolean {\n const mime = (file.mimeType || '').toLowerCase();\n if (mime.startsWith('image/')) return true;\n const ext = this.getExtension(file.name).toLowerCase();\n return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'].includes(ext);\n }\n\n /** Resolves the extension of a file name. */\n getExtension(name: string): string {\n return name.split('.').pop()?.toLowerCase() || '';\n }\n\n /** Icon + colored badge shown for non-image files, hinting at the type. */\n getExistingBadge(file: ExistingFile): { label: string; color: string; icon: string } {\n const ext = this.getExtension(file.name);\n switch (ext) {\n case 'pdf':\n return { label: 'PDF', color: 'bg-red-100 text-red-600', icon: 'file-text' };\n case 'doc':\n case 'docx':\n return { label: 'DOC', color: 'bg-blue-100 text-blue-600', icon: 'file-text' };\n case 'xls':\n case 'xlsx':\n return { label: 'XLS', color: 'bg-green-100 text-green-600', icon: 'file-spreadsheet' };\n default:\n return { label: ext.toUpperCase() || 'FILE', color: 'bg-slate-100 text-slate-500', icon: 'file' };\n }\n }\n\n /** trackBy for existing files. */\n trackExistingFile(file: ExistingFile): any {\n return file.id ?? file.name;\n }\n\n /** Human readable size (B/KB/MB). */\n private formatFileSize(bytes: number): string {\n if (bytes < 1024) return bytes + ' B';\n if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';\n return (bytes / (1024 * 1024)).toFixed(1) + ' MB';\n }\n}","<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"text-sm font-medium _shk-text-surface-700\">\n {{ label() }}\n </label>\n }\n\n @if (canAddMore()) {\n <div\n class=\"shk-dropzone relative border-2 border-dashed _shk-border rounded-lg p-4 transition-colors hover:[border-color:var(--shk-primary-400)] dark:hover:[border-color:var(--shk-primary-500)]\"\n [attr.aria-invalid]=\"errorMessage() ? true : null\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\"\n >\n <input\n #fileInput\n type=\"file\"\n [accept]=\"accept()\"\n [multiple]=\"multiple()\"\n (change)=\"onFileChange($event)\"\n class=\"hidden\"\n />\n\n <div\n class=\"flex flex-col items-center gap-2 cursor-pointer\"\n (click)=\"fileInput.click()\"\n [class.drag-over]=\"isDragOver()\"\n >\n <svg [shkIcon]=\"getIcon('upload')\" class=\"w-8 h-8 _shk-icon-subtle\"></svg>\n <span class=\"text-sm _shk-text-surface-700\">\n {{ fileUploadText() }}\n </span>\n @if (fileRecommendation()) {\n <span class=\"text-xs _shk-text-surface-400\">\n {{ fileRecommendation() }}\n </span>\n }\n </div>\n </div>\n }\n\n @if (maxReached()) {\n <div class=\"text-xs _shk-text-surface-400 text-center py-2\">\n Máximo {{ maxFiles() }} archivos alcanzado\n </div>\n }\n\n @if (selectedFiles().length > 0) {\n <div class=\"flex flex-wrap gap-3\">\n @for (file of selectedFiles(); track file.name + file.size + file.lastModified) {\n <div class=\"relative group\">\n @if (isImageFile(file)) {\n <img\n [src]=\"previewUrl(file)\"\n [alt]=\"file.name\"\n class=\"w-20 h-20 object-cover rounded-lg _shk-border\"\n />\n } @else {\n <div class=\"w-20 h-20 rounded-lg _shk-border flex flex-col items-center justify-center _shk-bg-surface-50 gap-1\">\n <svg [shkIcon]=\"getIcon('file')\" class=\"w-6 h-6 _shk-text-surface-400\"></svg>\n <span class=\"text-[10px] _shk-text-surface-400 truncate max-w-[70px] px-1 text-center\">{{ file.name }}</span>\n </div>\n }\n <button\n type=\"button\"\n (click)=\"removeFile(file)\"\n class=\"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 text-white rounded-full text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition shadow\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3 h-3\"></svg>\n </button>\n </div>\n }\n </div>\n @if (!multiple()) {\n <button\n type=\"button\"\n (click)=\"changeFiles()\"\n class=\"text-xs _shk-text-primary hover:[color:var(--shk-primary-700)] dark:[color:var(--shk-primary-400)] dark:hover:[color:var(--shk-primary-300)] underline cursor-pointer bg-transparent border-0\"\n >\n {{ changeFilesText() }}\n </button>\n }\n }\n\n @if (existingFiles().length > 0) {\n <div class=\"flex flex-wrap gap-3\">\n @for (file of existingFiles(); track trackExistingFile(file)) {\n @if (existingDisplay() === 'tiles') {\n @let badge = getExistingBadge(file);\n <div class=\"relative group w-[80px]\">\n <div\n class=\"w-20 h-20 rounded-lg border _shk-border overflow-hidden cursor-pointer relative\"\n (click)=\"onExistingAction(file)\"\n [title]=\"file.name\"\n >\n @if (isExistingImage(file) && file.url) {\n <img [src]=\"file.url\" [alt]=\"file.name\" class=\"w-full h-full object-cover\" />\n } @else {\n <div class=\"w-full h-full flex flex-col items-center justify-center gap-1 _shk-bg-surface-50\">\n <svg [shkIcon]=\"getIcon(badge.icon)\" class=\"w-6 h-6 _shk-text-surface-400\"></svg>\n <span class=\"px-1.5 py-0.5 rounded text-[9px] font-semibold leading-none\" [class]=\"badge.color\">\n {{ badge.label }}\n </span>\n </div>\n }\n <div\n class=\"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 flex items-center justify-center transition rounded-lg\"\n >\n <svg [shkIcon]=\"getIcon('download')\" class=\"w-5 h-5 text-white\"></svg>\n </div>\n </div>\n <button\n type=\"button\"\n (click)=\"onExistingRemove(file)\"\n class=\"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition shadow\"\n aria-label=\"Remove\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3 h-3\"></svg>\n </button>\n <span class=\"block text-[10px] _shk-text-surface-400 truncate text-center mt-1 max-w-[80px]\" [title]=\"file.name\">\n {{ file.name }}\n </span>\n </div>\n } @else {\n @let badge = getExistingBadge(file);\n <div class=\"flex items-center gap-2 _shk-bg-surface-50 border _shk-border rounded-full pl-3 pr-1.5 py-1 text-sm _shk-text-surface-700\">\n <svg [shkIcon]=\"getIcon(badge.icon)\" class=\"w-4 h-4 _shk-text-surface-400 shrink-0\"></svg>\n <span class=\"max-w-[200px] truncate\" [title]=\"file.name\">{{ file.name }}</span>\n <button\n type=\"button\"\n (click)=\"onExistingAction(file)\"\n [title]=\"file.name\"\n class=\"p-1 rounded-full hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 hover:[color:var(--shk-primary-600)]\"\n >\n <svg [shkIcon]=\"getIcon('download')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"onExistingRemove(file)\"\n class=\"p-1 rounded-full hover:[background-color:var(--shk-error-50)] _shk-text-surface-500 hover:[color:var(--shk-error-600)]\"\n aria-label=\"Remove\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n </div>\n }\n }\n </div>\n }\n\n @if (errorMessage()) {\n <p class=\"text-xs _shk-text-red-500\">{{ errorMessage() }}</p>\n }\n</div>"],"mappings":";;;;;;AA+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A;KAAA,mBAAA;IAAA;IAAA,UAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;IAAA,eAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;IAAA,iBAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;IAAA,OAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;GAAA;GAAA,SAAA;IAAA,cAAA;IAAA,aAAA;IAAA,WAAA;IAAA,aAAA;IAAA,oBAAA;IAAA,oBAAA;IAAA,OAAA;IAAA,OAAA;GAAA;GAAA,UAAA;GAAA,UC/ChC;GA0JM,cAAA,CAAA;IAAA,MAAA;IAAA,MD/GM;GAAY,GAAA;IAAA,MAAA;IAAA,MAAE;IAAgB,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;IAAA;GAAA,CAAA;GAAA,iBAAA,GAAA,wBAAA;EAAA,CAAA;CAAA;;AAI7B,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAmB,YAAA,CAAA;EAN/B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAiB,SAClB,CAAC,cAAc,gBAAgB;GAAC,iBAExB,wBAAwB;GAAM,UAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-file-upload.mjs","names":["getIconFromCentral"],"sources":["../../../projects/ui-components/file-upload/file-upload.component.ts","../../../projects/ui-components/file-upload/file-upload.component.html"],"sourcesContent":["import {\n Component,\n input,\n model,\n output,\n signal,\n computed,\n ChangeDetectionStrategy,\n inject,\n OnDestroy,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { TranslocoService } from '@jsverse/transloco';\nimport { ShkIconDirective, LucideUpload } from 'shirkasoft-ui-components/icons';\nimport {\n errorMessagesFromMap,\n getIcon as getIconFromCentral,\n signalErrorsToMap,\n} from 'shirkasoft-ui-components/utils';\nimport { type FormValueControl, type ValidationError } from '@angular/forms/signals';\n\nexport interface FileUploadError {\n type: 'size' | 'type';\n message: string;\n file: File;\n}\n\nexport interface ExistingFile {\n id?: number | string;\n name: string;\n url?: string;\n mimeType?: string;\n size?: number;\n}\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 * Drag & drop file uploader with file type/size validation, image previews,\n * multiple files support and localized error messages.\n */\n@Component({\n selector: 'shk-file-upload',\n imports: [CommonModule, ShkIconDirective],\n templateUrl: './file-upload.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class FileUploadComponent implements OnDestroy, FormValueControl<File[]> {\n protected getIcon = (name: any) => getIconFromCentral(name, LucideUpload);\n private transloco = inject(TranslocoService);\n /** Main label of the uploader. */\n label = input<string>('Cargar archivo');\n /** Accepted MIME types/extensions (e.g. 'image/*', '.pdf'). */\n accept = input<string>('image/*');\n /** Maximum allowed size per file (bytes). */\n maxFileSize = input<number>(2 * 1024 * 1024);\n /** Maximum number of files (0 = unlimited). */\n maxFiles = input<number>(0);\n /** Text of the file picker button. */\n fileUploadText = input<string>('Seleccionar archivo');\n /** Helper text shown next to the label. */\n fileRecommendation = input<string>('');\n /** Text shown when files are already loaded. */\n changeFilesText = input<string>('Cambiar archivos');\n /** Enables selecting more than one file at once. */\n multiple = input<boolean>(false);\n /** Files already stored by the parent (read-only; the component only emits events). */\n existingFiles = input<ExistingFile[]>([]);\n /** How existing files are rendered. */\n existingDisplay = input<'chips' | 'tiles'>('chips');\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\n /** Emitted with the currently selected files. */\n fileSelected = output<File[]>();\n /** Emitted when the last selected file is removed. */\n fileRemoved = output<void>();\n /** Emitted when a file fails validation (type/size). */\n fileError = output<FileUploadError>();\n /** Emitted when a file is near the size limit. */\n fileWarning = output<FileUploadError>();\n /** Emitted when an existing file is requested for download/view. */\n existingFileAction = output<ExistingFile>();\n /** Emitted when an existing file should be removed (parent deletes it). */\n existingFileRemove = output<ExistingFile>();\n\n /** Currently selected files. Two-way bindable and used by `[formField]`. */\n value = model<File[]>([]);\n /** Alias kept for the existing implementation and templates. */\n get selectedFiles() {\n return this.value;\n }\n /** Emitted when the selection changes so Signal Forms marks the field as touched. */\n touch = output<void>();\n /** Localized error message displayed to the user. */\n errorMessage = signal<string>('');\n /** Whether the user is dragging files over the zone. */\n isDragOver = signal<boolean>(false);\n\n /**\n * Error message rendered under the uploader. Local type/size errors take\n * precedence; otherwise the first Signal Forms error is shown once the field\n * has been touched or modified.\n */\n displayError = computed(() => {\n const local = this.errorMessage();\n if (local) return local;\n\n if (!this.invalid() || (!this.touched() && !this.dirty())) return '';\n\n const translate = (key: string, params?: Record<string, any>) =>\n this.transloco.translate(key, params);\n\n return (\n errorMessagesFromMap(signalErrorsToMap(this.errors()), {}, translate)[0] ?? ''\n );\n });\n\n /** Object URLs used for image previews. */\n private previewUrls = new Map<File, string>();\n\n /** Whether another selection is allowed. */\n canAddMore = computed(() => {\n if (!this.multiple()) return this.selectedFiles().length === 0;\n const max = this.maxFiles();\n if (max <= 0) return true;\n return this.selectedFiles().length < max;\n });\n\n /** True when the maximum number of files has been reached. */\n maxReached = computed(() => {\n const max = this.maxFiles();\n if (max <= 0) return false;\n return this.selectedFiles().length >= max;\n });\n\n /** Whether the file is an image (used for previews). */\n isImageFile(file: File): boolean {\n return file.type.startsWith('image/');\n }\n\n /** Returns (creating on demand) the object URL for a file preview. */\n previewUrl(file: File): string {\n if (!this.previewUrls.has(file)) {\n this.previewUrls.set(file, URL.createObjectURL(file));\n }\n return this.previewUrls.get(file) ?? '';\n }\n\n /** Marks the drop zone as active while dragging over it. */\n onDragOver(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(true);\n }\n\n /** Clears the drag-over state when the drag leaves the zone. */\n onDragLeave(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(false);\n }\n\n /** Processes the files dropped on the zone. */\n onDrop(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(false);\n\n const files = event.dataTransfer?.files;\n if (files && files.length > 0) {\n this.processFiles(Array.from(files));\n }\n }\n\n /** Processes the files picked from the native file input. */\n onFileChange(event: Event): void {\n const input = event.target as HTMLInputElement;\n const files = input.files;\n if (files && files.length > 0) {\n this.processFiles(Array.from(files));\n }\n input.value = '';\n }\n\n /** Validates and appends the received files, emitting errors/warnings. */\n private processFiles(files: File[]): void {\n this.errorMessage.set('');\n const validFiles: File[] = [];\n\n for (const file of files) {\n const error = this.validateFile(file);\n if (error) {\n this.fileError.emit(error);\n this.errorMessage.set(error.message);\n return;\n }\n\n const warning = this.checkSizeWarning(file);\n if (warning) {\n this.fileWarning.emit(warning);\n }\n\n validFiles.push(file);\n }\n\n const max = this.maxFiles();\n if (max > 0) {\n const currentCount = this.selectedFiles().length;\n const allowed = max - currentCount;\n if (validFiles.length > allowed) {\n const errorMsg = this.transloco.translate('fileUpload.maxFiles', undefined, `Máximo ${max} archivos permitidos`);\n this.errorMessage.set(errorMsg);\n return;\n }\n }\n\n if (this.multiple()) {\n this.selectedFiles.set([...this.selectedFiles(), ...validFiles]);\n } else {\n this.clearPreviews();\n this.selectedFiles.set(validFiles);\n }\n\n this.touch.emit();\n this.fileSelected.emit(this.selectedFiles());\n }\n\n /** Validates a file against `accept` and `maxFileSize`. */\n private validateFile(file: File): FileUploadError | null {\n const acceptStr = this.accept();\n if (acceptStr && acceptStr !== '*') {\n const acceptTypes = acceptStr.split(',').map((t) => t.trim());\n const valid = acceptTypes.some((type) => {\n if (type.endsWith('/*')) {\n const category = type.replace('/*', '');\n return file.type.startsWith(category);\n }\n if (type.startsWith('.')) {\n const ext = type.slice(1).toLowerCase();\n return file.name.toLowerCase().endsWith('.' + ext);\n }\n if (type.includes('/')) {\n return file.type === type;\n }\n return false;\n });\n\n if (!valid) {\n return {\n type: 'type',\n message: this.transloco.translate('fileUpload.invalidType', { accept: acceptStr }, `Tipo de archivo no válido. Formatos aceptados: ${acceptStr}`),\n file,\n };\n }\n }\n\n if (this.maxFileSize() > 0 && file.size > this.maxFileSize()) {\n return {\n type: 'size',\n message: this.transloco.translate('fileUpload.fileTooLarge', { size: this.formatFileSize(this.maxFileSize()) }, `El archivo excede el tamaño máximo de ${this.formatFileSize(this.maxFileSize())}`),\n file,\n };\n }\n\n return null;\n }\n\n /** Emits a warning when the file is close to the size limit (>90%). */\n private checkSizeWarning(file: File): FileUploadError | null {\n if (this.maxFileSize() > 0 && file.size > this.maxFileSize() * 0.9) {\n return {\n type: 'size',\n message: this.transloco.translate('fileUpload.sizeWarning', { size: this.formatFileSize(this.maxFileSize()) }, `El archivo está cerca del límite de tamaño (${this.formatFileSize(this.maxFileSize())})`),\n file,\n };\n }\n return null;\n }\n\n /** Removes a file, revoking its preview URL. */\n removeFile(file: File): void {\n const url = this.previewUrls.get(file);\n if (url) {\n URL.revokeObjectURL(url);\n this.previewUrls.delete(file);\n }\n\n this.selectedFiles.update((files) => files.filter((f) => f !== file));\n this.errorMessage.set('');\n\n if (this.selectedFiles().length === 0) {\n this.fileRemoved.emit();\n }\n }\n\n /** Clears all selected files and previews. */\n changeFiles(): void {\n this.clearPreviews();\n this.selectedFiles.set([]);\n this.errorMessage.set('');\n }\n\n /** Revokes every stored preview object URL. */\n private clearPreviews(): void {\n for (const [file, url] of this.previewUrls) {\n URL.revokeObjectURL(url);\n }\n this.previewUrls.clear();\n }\n\n /** Revokes pending preview URLs when the component is destroyed. */\n ngOnDestroy(): void {\n this.clearPreviews();\n }\n\n /** Emits the action (download/view) for an existing file. */\n onExistingAction(file: ExistingFile): void {\n this.existingFileAction.emit(file);\n }\n\n /** Emits the removal request for an existing file. */\n onExistingRemove(file: ExistingFile): void {\n this.existingFileRemove.emit(file);\n }\n\n /** Whether an existing file is an image (by mime type or extension). */\n isExistingImage(file: ExistingFile): boolean {\n const mime = (file.mimeType || '').toLowerCase();\n if (mime.startsWith('image/')) return true;\n const ext = this.getExtension(file.name).toLowerCase();\n return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'].includes(ext);\n }\n\n /** Resolves the extension of a file name. */\n getExtension(name: string): string {\n return name.split('.').pop()?.toLowerCase() || '';\n }\n\n /** Icon + colored badge shown for non-image files, hinting at the type. */\n getExistingBadge(file: ExistingFile): { label: string; color: string; icon: string } {\n const ext = this.getExtension(file.name);\n switch (ext) {\n case 'pdf':\n return { label: 'PDF', color: 'bg-red-100 text-red-600', icon: 'file-text' };\n case 'doc':\n case 'docx':\n return { label: 'DOC', color: 'bg-blue-100 text-blue-600', icon: 'file-text' };\n case 'xls':\n case 'xlsx':\n return { label: 'XLS', color: 'bg-green-100 text-green-600', icon: 'file-spreadsheet' };\n default:\n return { label: ext.toUpperCase() || 'FILE', color: 'bg-slate-100 text-slate-500', icon: 'file' };\n }\n }\n\n /** trackBy for existing files. */\n trackExistingFile(file: ExistingFile): any {\n return file.id ?? file.name;\n }\n\n /** Human readable size (B/KB/MB). */\n private formatFileSize(bytes: number): string {\n if (bytes < 1024) return bytes + ' B';\n if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';\n return (bytes / (1024 * 1024)).toFixed(1) + ' MB';\n }\n}","<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"text-sm font-medium _shk-text-surface-700\">\n {{ label() }}\n </label>\n }\n\n @if (canAddMore()) {\n <div\n class=\"shk-dropzone relative border-2 border-dashed _shk-border rounded-lg p-4 transition-colors hover:[border-color:var(--shk-primary-400)] dark:hover:[border-color:var(--shk-primary-500)]\"\n [attr.aria-invalid]=\"displayError() ? true : null\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\"\n >\n <input\n #fileInput\n type=\"file\"\n [accept]=\"accept()\"\n [multiple]=\"multiple()\"\n (change)=\"onFileChange($event)\"\n class=\"hidden\"\n />\n\n <div\n class=\"flex flex-col items-center gap-2 cursor-pointer\"\n (click)=\"fileInput.click()\"\n [class.drag-over]=\"isDragOver()\"\n >\n <svg [shkIcon]=\"getIcon('upload')\" class=\"w-8 h-8 _shk-icon-subtle\"></svg>\n <span class=\"text-sm _shk-text-surface-700\">\n {{ fileUploadText() }}\n </span>\n @if (fileRecommendation()) {\n <span class=\"text-xs _shk-text-surface-400\">\n {{ fileRecommendation() }}\n </span>\n }\n </div>\n </div>\n }\n\n @if (maxReached()) {\n <div class=\"text-xs _shk-text-surface-400 text-center py-2\">\n Máximo {{ maxFiles() }} archivos alcanzado\n </div>\n }\n\n @if (selectedFiles().length > 0) {\n <div class=\"flex flex-wrap gap-3\">\n @for (file of selectedFiles(); track file.name + file.size + file.lastModified) {\n <div class=\"relative group\">\n @if (isImageFile(file)) {\n <img\n [src]=\"previewUrl(file)\"\n [alt]=\"file.name\"\n class=\"w-20 h-20 object-cover rounded-lg _shk-border\"\n />\n } @else {\n <div class=\"w-20 h-20 rounded-lg _shk-border flex flex-col items-center justify-center _shk-bg-surface-50 gap-1\">\n <svg [shkIcon]=\"getIcon('file')\" class=\"w-6 h-6 _shk-text-surface-400\"></svg>\n <span class=\"text-[10px] _shk-text-surface-400 truncate max-w-[70px] px-1 text-center\">{{ file.name }}</span>\n </div>\n }\n <button\n type=\"button\"\n (click)=\"removeFile(file)\"\n class=\"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 text-white rounded-full text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition shadow\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3 h-3\"></svg>\n </button>\n </div>\n }\n </div>\n @if (!multiple()) {\n <button\n type=\"button\"\n (click)=\"changeFiles()\"\n class=\"text-xs _shk-text-primary hover:[color:var(--shk-primary-700)] dark:[color:var(--shk-primary-400)] dark:hover:[color:var(--shk-primary-300)] underline cursor-pointer bg-transparent border-0\"\n >\n {{ changeFilesText() }}\n </button>\n }\n }\n\n @if (existingFiles().length > 0) {\n <div class=\"flex flex-wrap gap-3\">\n @for (file of existingFiles(); track trackExistingFile(file)) {\n @if (existingDisplay() === 'tiles') {\n @let badge = getExistingBadge(file);\n <div class=\"relative group w-[80px]\">\n <div\n class=\"w-20 h-20 rounded-lg border _shk-border overflow-hidden cursor-pointer relative\"\n (click)=\"onExistingAction(file)\"\n [title]=\"file.name\"\n >\n @if (isExistingImage(file) && file.url) {\n <img [src]=\"file.url\" [alt]=\"file.name\" class=\"w-full h-full object-cover\" />\n } @else {\n <div class=\"w-full h-full flex flex-col items-center justify-center gap-1 _shk-bg-surface-50\">\n <svg [shkIcon]=\"getIcon(badge.icon)\" class=\"w-6 h-6 _shk-text-surface-400\"></svg>\n <span class=\"px-1.5 py-0.5 rounded text-[9px] font-semibold leading-none\" [class]=\"badge.color\">\n {{ badge.label }}\n </span>\n </div>\n }\n <div\n class=\"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 flex items-center justify-center transition rounded-lg\"\n >\n <svg [shkIcon]=\"getIcon('download')\" class=\"w-5 h-5 text-white\"></svg>\n </div>\n </div>\n <button\n type=\"button\"\n (click)=\"onExistingRemove(file)\"\n class=\"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition shadow\"\n aria-label=\"Remove\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3 h-3\"></svg>\n </button>\n <span class=\"block text-[10px] _shk-text-surface-400 truncate text-center mt-1 max-w-[80px]\" [title]=\"file.name\">\n {{ file.name }}\n </span>\n </div>\n } @else {\n @let badge = getExistingBadge(file);\n <div class=\"flex items-center gap-2 _shk-bg-surface-50 border _shk-border rounded-full pl-3 pr-1.5 py-1 text-sm _shk-text-surface-700\">\n <svg [shkIcon]=\"getIcon(badge.icon)\" class=\"w-4 h-4 _shk-text-surface-400 shrink-0\"></svg>\n <span class=\"max-w-[200px] truncate\" [title]=\"file.name\">{{ file.name }}</span>\n <button\n type=\"button\"\n (click)=\"onExistingAction(file)\"\n [title]=\"file.name\"\n class=\"p-1 rounded-full hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 hover:[color:var(--shk-primary-600)]\"\n >\n <svg [shkIcon]=\"getIcon('download')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"onExistingRemove(file)\"\n class=\"p-1 rounded-full hover:[background-color:var(--shk-error-50)] _shk-text-surface-500 hover:[color:var(--shk-error-600)]\"\n aria-label=\"Remove\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n </div>\n }\n }\n </div>\n }\n\n @if (displayError()) {\n <p class=\"text-xs _shk-text-red-500\">{{ displayError() }}</p>\n }\n</div>"],"mappings":";;;;;;AAmDA,IAAa,sBAAb,MAAa,oBAAmB;CANhC,cAAA;EAOY,KAAA,WAAW,SAAcA,QAAmB,MAAM,YAAY;EAChE,KAAA,YAAY,OAAO,gBAAgB;EAE3C,KAAA,QAAQ,MAAc,kBAAiB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAEvC,KAAA,SAAS,MAAc,WAAU,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;EAEjC,KAAA,cAAc,MAAc,SAAgB,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;EAE5C,KAAA,WAAW,MAAc,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,C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AAA;GAAA,CAAA;GAAA,iBAAA,GAAA,wBAAA;EAAA,CAAA;CAAA;;AAI7B,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAmB,YAAA,CAAA;EAN/B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAiB,SAClB,CAAC,cAAc,gBAAgB;GAAC,iBAExB,wBAAwB;GAAM,UAAA;EAAA,CAAA"}
|
|
@@ -6,6 +6,7 @@ import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from "@angular/forms";
|
|
|
6
6
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
7
7
|
import { TranslocoService } from "@jsverse/transloco";
|
|
8
8
|
import { ShkConfigService, currencyDecimals, currencySymbol, formatNumber, numberSeparators } from "shirkasoft-ui-components/config";
|
|
9
|
+
import { errorMessagesFromMap, signalErrorsToMap } from "shirkasoft-ui-components/utils";
|
|
9
10
|
var PriceInputComponent = class PriceInputComponent {
|
|
10
11
|
constructor() {
|
|
11
12
|
this.control = input(void 0, ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
@@ -15,6 +16,10 @@ var PriceInputComponent = class PriceInputComponent {
|
|
|
15
16
|
this.inputId = input("", ...ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []);
|
|
16
17
|
this.required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
17
18
|
this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
19
|
+
this.errors = input([], ...ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []);
|
|
20
|
+
this.invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
21
|
+
this.touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
22
|
+
this.dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
18
23
|
this.min = input(0, ...ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []);
|
|
19
24
|
this.max = input(Infinity, ...ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []);
|
|
20
25
|
this.decimals = input(void 0, ...ngDevMode ? [{ debugName: "decimals" }] : /* istanbul ignore next */ []);
|
|
@@ -37,7 +42,9 @@ var PriceInputComponent = class PriceInputComponent {
|
|
|
37
42
|
this.controlDisabled = signal(false, ...ngDevMode ? [{ debugName: "controlDisabled" }] : /* istanbul ignore next */ []);
|
|
38
43
|
this.ctrlSubscribed = false;
|
|
39
44
|
this.statusTick = signal(0, ...ngDevMode ? [{ debugName: "statusTick" }] : /* istanbul ignore next */ []);
|
|
45
|
+
this.usesSignalForms = computed(() => !this.control(), ...ngDevMode ? [{ debugName: "usesSignalForms" }] : /* istanbul ignore next */ []);
|
|
40
46
|
this.hasError = computed(() => {
|
|
47
|
+
if (this.usesSignalForms()) return this.showError() || this.invalid() && (this.touched() || this.dirty());
|
|
41
48
|
this.statusTick();
|
|
42
49
|
if (this.showError()) return true;
|
|
43
50
|
const ctrl = this.control();
|
|
@@ -47,10 +54,11 @@ var PriceInputComponent = class PriceInputComponent {
|
|
|
47
54
|
this.statusTick();
|
|
48
55
|
const custom = this.errorMessage();
|
|
49
56
|
if (custom) return custom;
|
|
57
|
+
const translate = (key, params) => this.transloco.translate(key, params);
|
|
58
|
+
if (this.usesSignalForms()) return errorMessagesFromMap(signalErrorsToMap(this.errors()), {}, translate)[0] ?? "";
|
|
50
59
|
const errors = this.control()?.errors;
|
|
51
60
|
if (!errors) return "";
|
|
52
|
-
|
|
53
|
-
return this.transloco.translate("validation.invalid");
|
|
61
|
+
return errorMessagesFromMap(errors, {}, translate)[0] ?? "";
|
|
54
62
|
}, ...ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []);
|
|
55
63
|
this.isDisabled = computed(() => this.disabled() || this.controlDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
|
|
56
64
|
this.onChange = () => {};
|
|
@@ -256,6 +264,34 @@ var PriceInputComponent = class PriceInputComponent {
|
|
|
256
264
|
isRequired: false,
|
|
257
265
|
transformFunction: null
|
|
258
266
|
},
|
|
267
|
+
errors: {
|
|
268
|
+
classPropertyName: "errors",
|
|
269
|
+
publicName: "errors",
|
|
270
|
+
isSignal: true,
|
|
271
|
+
isRequired: false,
|
|
272
|
+
transformFunction: null
|
|
273
|
+
},
|
|
274
|
+
invalid: {
|
|
275
|
+
classPropertyName: "invalid",
|
|
276
|
+
publicName: "invalid",
|
|
277
|
+
isSignal: true,
|
|
278
|
+
isRequired: false,
|
|
279
|
+
transformFunction: null
|
|
280
|
+
},
|
|
281
|
+
touched: {
|
|
282
|
+
classPropertyName: "touched",
|
|
283
|
+
publicName: "touched",
|
|
284
|
+
isSignal: true,
|
|
285
|
+
isRequired: false,
|
|
286
|
+
transformFunction: null
|
|
287
|
+
},
|
|
288
|
+
dirty: {
|
|
289
|
+
classPropertyName: "dirty",
|
|
290
|
+
publicName: "dirty",
|
|
291
|
+
isSignal: true,
|
|
292
|
+
isRequired: false,
|
|
293
|
+
transformFunction: null
|
|
294
|
+
},
|
|
259
295
|
min: {
|
|
260
296
|
classPropertyName: "min",
|
|
261
297
|
publicName: "min",
|
|
@@ -435,6 +471,38 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
435
471
|
required: false
|
|
436
472
|
}]
|
|
437
473
|
}],
|
|
474
|
+
errors: [{
|
|
475
|
+
type: i0.Input,
|
|
476
|
+
args: [{
|
|
477
|
+
isSignal: true,
|
|
478
|
+
alias: "errors",
|
|
479
|
+
required: false
|
|
480
|
+
}]
|
|
481
|
+
}],
|
|
482
|
+
invalid: [{
|
|
483
|
+
type: i0.Input,
|
|
484
|
+
args: [{
|
|
485
|
+
isSignal: true,
|
|
486
|
+
alias: "invalid",
|
|
487
|
+
required: false
|
|
488
|
+
}]
|
|
489
|
+
}],
|
|
490
|
+
touched: [{
|
|
491
|
+
type: i0.Input,
|
|
492
|
+
args: [{
|
|
493
|
+
isSignal: true,
|
|
494
|
+
alias: "touched",
|
|
495
|
+
required: false
|
|
496
|
+
}]
|
|
497
|
+
}],
|
|
498
|
+
dirty: [{
|
|
499
|
+
type: i0.Input,
|
|
500
|
+
args: [{
|
|
501
|
+
isSignal: true,
|
|
502
|
+
alias: "dirty",
|
|
503
|
+
required: false
|
|
504
|
+
}]
|
|
505
|
+
}],
|
|
438
506
|
min: [{
|
|
439
507
|
type: i0.Input,
|
|
440
508
|
args: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-price-input.mjs","names":[],"sources":["../../../projects/ui-components/price-input/price-input.component.ts","../../../projects/ui-components/price-input/price-input.component.html"],"sourcesContent":["import {\n Component,\n model,\n input,\n signal,\n computed,\n effect,\n inject,\n output,\n forwardRef,\n DestroyRef,\n ChangeDetectionStrategy,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport {\n ControlValueAccessor,\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n} from '@angular/forms';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { FormValueControl } from '@angular/forms/signals';\nimport { TranslocoService } from '@jsverse/transloco';\nimport {\n ShkConfigService,\n currencyDecimals,\n currencySymbol,\n formatNumber,\n numberSeparators,\n} from 'shirkasoft-ui-components/config';\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 * Currency/percentage numeric input with reactive forms support.\n *\n * Binding modes (highest precedence first):\n * - `control`: a FormControl (or use it inside a form with `formControlName`).\n * - `value`/`valueChange` or `[(value)]`: two-way model signals.\n *\n * Text-based input (`type=\"text\"` + `inputmode=\"decimal\"`) with decimal\n * precision control, min/max clamping on blur and thousands formatting.\n */\n@Component({\n selector: 'shk-price-input',\n imports: [CommonModule, ReactiveFormsModule],\n templateUrl: './price-input.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => PriceInputComponent),\n multi: true,\n },\n ],\n})\nexport class PriceInputComponent implements ControlValueAccessor, FormValueControl<number | null> {\n /** Reactive control. When provided it takes precedence over `value`/`valueChange`. */\n control = input<FormControl<number | null> | undefined>(undefined);\n /** Numeric value (two-way), used when no `control` is bound. */\n value = model<number | null>(0);\n /** Whether the input works as a percentage (two-way). */\n isPercentage = model<boolean>(false);\n /** Label displayed above the field. */\n label = input<string>('');\n /** id attribute applied to the native input. */\n inputId = input<string>('');\n /** Marks the field as required. */\n required = input<boolean>(false);\n /** Disables the input. */\n disabled = input<boolean>(false);\n /** Minimum allowed value (clamped on blur). */\n min = input<number | undefined>(0);\n /** Maximum allowed value (clamped on blur). */\n max = input<number | undefined>(Infinity);\n /**\n * Maximum number of decimal places (0 = integer). Unset = the `numbers.decimals`\n * option, else the digits of the `numbers.currency` option (2 for USD).\n */\n decimals = input<number | undefined>(undefined);\n /**\n * Symbol shown in the mode toggle button when not a percentage. Empty = the\n * `numbers.currencySymbol` option, else the symbol of `numbers.currency` ('$').\n */\n currency = input<string>('');\n /** Placeholder text of the native input. */\n placeholder = input<string>('');\n /** Accessible label; falls back to `label`. */\n ariaLabel = input<string>('');\n /** Blocks the minus sign from being typed. */\n preventNegative = input<boolean>(false);\n /** Shows the error styling on the field. */\n showError = input<boolean>(false);\n /** Message rendered when the field is in error state. */\n errorMessage = input<string>('');\n /** Emitted on blur so Signal Forms can mark the field as touched. */\n touch = output<void>();\n\n private destroyRef = inject(DestroyRef);\n private transloco = inject(TranslocoService);\n /** Library-wide options: currency, decimals and number separators. */\n private readonly config = inject(ShkConfigService);\n\n /** Decimal places actually used. */\n private readonly effectiveDecimals = computed(() =>\n Math.max(\n 0,\n this.decimals() ??\n this.config.get('numbers.decimals')() ??\n currencyDecimals(this.config.get('numbers.currency')()),\n ),\n );\n /** Locale of the grouping/decimal separators. */\n private readonly numbersLocale = computed(() => this.config.get('numbers.locale')());\n /** Decimal separator of the locale (`.` or `,`), used while editing. */\n private readonly decimalSeparator = computed(() => numberSeparators(this.numbersLocale()).decimal);\n /** Symbol shown in the toggle: input, `numbers.currencySymbol`, or the currency's symbol. */\n readonly displaySymbol = computed(\n () =>\n this.currency() ||\n this.config.get('numbers.currencySymbol')() ||\n currencySymbol(this.config.get('numbers.currency')(), this.numbersLocale()),\n );\n\n /** Text currently shown in the input (raw while focused, formatted on blur). */\n displayText = signal<string>('');\n /** Whether the native input currently has focus. */\n focused = signal<boolean>(false);\n /** Disabled state coming from the reactive control. */\n private controlDisabled = signal<boolean>(false);\n /** Prevents re-subscribing to the same form control. */\n private ctrlSubscribed = false;\n\n /** Bumped on control status changes / blur so error computeds refresh. */\n private statusTick = signal(0);\n\n /**\n * Whether the error state is shown: forced with `showError`, or when the\n * bound `control` is invalid and has been touched or modified.\n */\n hasError = computed(() => {\n this.statusTick();\n if (this.showError()) return true;\n const ctrl = this.control();\n return !!ctrl && ctrl.invalid && (ctrl.touched || ctrl.dirty);\n });\n\n /** Message shown under the field: `errorMessage` or one derived from the control errors. */\n errorText = computed(() => {\n this.statusTick();\n const custom = this.errorMessage();\n if (custom) return custom;\n const errors = this.control()?.errors;\n if (!errors) return '';\n if (errors['required']) return this.transloco.translate('validation.required');\n return this.transloco.translate('validation.invalid');\n });\n\n /** Effective disabled state combining the input and the form binding. */\n isDisabled = computed(() => this.disabled() || this.controlDisabled());\n\n /** Callbacks used by the ControlValueAccessor contract. */\n private onChange: (value: number | null) => void = () => {};\n private onTouched: () => void = () => {};\n\n constructor() {\n // Subscribe once to the bound control for change/status tracking.\n effect(() => {\n const ctrl = this.control();\n if (!ctrl || this.ctrlSubscribed) return;\n this.ctrlSubscribed = true;\n this.controlDisabled.set(ctrl.disabled);\n\n ctrl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((v) => {\n if (!this.focused()) {\n this.displayText.set(this.formatNumber(v ?? 0));\n }\n });\n ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n this.controlDisabled.set(ctrl.disabled);\n this.statusTick.update((v) => v + 1);\n });\n // Also refresh on touched/pristine changes (e.g. markAllAsTouched()).\n ctrl.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n this.statusTick.update((v) => v + 1);\n });\n });\n\n // Reflect the effective value into the display (unless the user is typing).\n effect(() => {\n const ctrl = this.control();\n const v = ctrl ? (ctrl.value as number | null) : this.value();\n if (!this.focused()) {\n this.displayText.set(this.formatNumber(v ?? 0));\n }\n });\n }\n\n /** Toggles between amount and percentage modes (unless disabled). */\n toggleMode(): void {\n if (this.isDisabled()) return;\n this.isPercentage.update((v) => !v);\n }\n\n /**\n * Switches to the editable form (no grouping, locale decimal separator) and\n * selects it so the user can type over it or edit in the middle safely.\n */\n onFocus(event: FocusEvent): void {\n const input = event.target as HTMLInputElement;\n this.focused.set(true);\n this.displayText.set(this.editableNumber(this.currentValue()));\n // Select once the new text is rendered.\n setTimeout(() => {\n if (this.focused()) input.select();\n });\n }\n\n /** Clamps, rounds and formats the value when the field loses focus. */\n onBlur(): void {\n this.focused.set(false);\n this.onTouched();\n this.touch.emit();\n\n let v = this.parseEditable(this.displayText());\n if (isNaN(v)) v = 0;\n\n const min = this.min() ?? 0;\n const max = this.max() ?? Infinity;\n if (isFinite(min) && v < min) v = min;\n if (isFinite(max) && v > max) v = max;\n\n v = this.roundTo(v);\n this.setValue(v);\n this.displayText.set(this.formatNumber(v));\n this.control()?.markAsTouched();\n this.statusTick.update((n) => n + 1);\n }\n\n /** Blocks characters that would break the numeric format. */\n onKeydown(event: KeyboardEvent): void {\n const allowed = [\n 'Backspace',\n 'Tab',\n 'End',\n 'Home',\n 'ArrowLeft',\n 'ArrowRight',\n 'Delete',\n 'Enter',\n 'Escape',\n ];\n if (allowed.includes(event.key)) return;\n if (/^\\d$/.test(event.key)) return;\n\n if (event.key === '.' || event.key === ',') {\n const input = event.target as HTMLInputElement;\n if (input.value.includes('.') || input.value.includes(',')) event.preventDefault();\n return;\n }\n\n if (event.key === '-') {\n const input = event.target as HTMLInputElement;\n if (this.preventNegative() || (this.min() ?? 0) >= 0) {\n event.preventDefault();\n } else if (input.value.includes('-')) {\n event.preventDefault();\n }\n return;\n }\n\n event.preventDefault();\n }\n\n /** Sanitizes the raw input (digits + one separator + optional sign) and writes the value once. */\n onInput(event: Event): void {\n const input = event.target as HTMLInputElement;\n const pos = input.selectionStart ?? input.value.length;\n\n let cleaned = input.value.replace(/[^0-9.,-]/g, '');\n if (this.preventNegative() || (this.min() ?? 0) >= 0) cleaned = cleaned.replace(/-/g, '');\n // Either `.` or `,` is accepted as the decimal separator while typing.\n cleaned = cleaned.replace(/,/g, '.');\n\n const dot = cleaned.indexOf('.');\n if (dot >= 0) {\n const dec = this.effectiveDecimals();\n const intPart = cleaned.slice(0, dot);\n const decPart = cleaned.slice(dot + 1, dot + 1 + dec).replace(/\\./g, '');\n cleaned = dec > 0 ? intPart + '.' + decPart : intPart;\n }\n\n // Show the locale's decimal separator; keep `.` for parsing.\n const shown = cleaned.replace('.', this.decimalSeparator());\n input.value = shown;\n const newPos = Math.min(pos, shown.length);\n input.setSelectionRange(newPos, newPos);\n this.displayText.set(shown);\n\n const num = parseFloat(cleaned);\n this.setValue(isNaN(num) ? 0 : num);\n }\n\n /** Writes the value to the effective binding source. */\n private setValue(v: number): void {\n const ctrl = this.control();\n if (ctrl) {\n ctrl.setValue(v, { emitEvent: true });\n } else {\n this.value.set(v);\n }\n this.onChange(v);\n }\n\n private roundTo(v: number): number {\n const factor = Math.pow(10, this.effectiveDecimals());\n return Math.round(v * factor) / factor;\n }\n\n /** Formats a number with the locale's separators and up to `decimals` places. */\n private formatNumber(v: number): string {\n if (v == null || isNaN(v)) return '0';\n return formatNumber(v, this.numbersLocale(), this.effectiveDecimals());\n }\n\n /** Number as edited: no grouping, locale decimal separator (\"1234,5\" for es-ES). */\n private editableNumber(v: number | null | undefined): string {\n if (v == null || isNaN(v)) return '';\n return String(this.roundTo(v)).replace('.', this.decimalSeparator());\n }\n\n /** Parses the editable text back to a number (either separator is accepted). */\n private parseEditable(text: string): number {\n return parseFloat(text.replace(/\\s/g, '').replace(/,/g, '.'));\n }\n\n /** Value of the effective binding source (control or `value`). */\n private currentValue(): number | null {\n const ctrl = this.control();\n return ctrl ? (ctrl.value as number | null) : this.value();\n }\n\n // ── ControlValueAccessor ───────────────────────────────────────────────────\n\n writeValue(value: any): void {\n if (!this.focused()) {\n this.displayText.set(this.formatNumber(value ?? 0));\n }\n }\n\n registerOnChange(fn: any): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: any): void {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.controlDisabled.set(isDisabled);\n }\n}\n","<div>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-400\">*</span>\n }\n </div>\n }\n <div class=\"flex\">\n <input\n [id]=\"inputId()\"\n type=\"text\"\n inputmode=\"decimal\"\n autocomplete=\"off\"\n [value]=\"displayText()\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"ariaLabel() || label()\"\n [attr.aria-invalid]=\"hasError() || null\"\n [disabled]=\"isDisabled()\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n (input)=\"onInput($event)\"\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: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': hasError(),\n '_shk-border dark:[border-color:var(--shk-surface-200)] focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !hasError()\n }\"\n />\n <button\n type=\"button\"\n (click)=\"toggleMode()\"\n [disabled]=\"isDisabled()\"\n class=\"px-3 py-2 text-sm font-medium border rounded-r-lg transition-colors shrink-0\"\n [ngClass]=\"{\n '_shk-bg-primary-soft _shk-border-primary-200 _shk-text-primary-700 dark:[background-color:var(--shk-primary-900)] dark:[border-color:var(--shk-primary-700)] dark:[color:var(--shk-primary-300)]': isPercentage(),\n '_shk-bg-white _shk-border _shk-text-surface-500 dark:[background-color:var(--shk-surface-100)] dark:[border-color:var(--shk-surface-200)] dark:[color:var(--shk-surface-400)]': !isPercentage(),\n 'cursor-not-allowed opacity-50': isDisabled()\n }\"\n >\n {{ isPercentage() ? '%' : displaySymbol() }}\n </button>\n </div>\n @if (hasError() && errorText()) {\n <div class=\"text-xs _shk-text-red-500 mt-1\">\n {{ errorText() }}\n </div>\n }\n</div>\n"],"mappings":";;;;;;;;AA4DA,IAAa,sBAAb,MAAa,oBAAmB;CA6G9B,cAAA;EA3GA,KAAA,UAAU,MAA8C,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EAElE,KAAA,QAAQ,MAAqB,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAE/B,KAAA,eAAe,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,eAAA,CAAA,+BAAA,CAAA,CAAA;EAEpC,KAAA,QAAQ,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAEzB,KAAA,UAAU,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EAE3B,KA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,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;GAAA;GAAA,SAAA;IAAA,OAAA;IAAA,cAAA;IAAA,OAAA;GAAA;GAAA,WARnB,CACT;IACE,SAAS;IACT,aAAa,iBAAiB,mBAAmB;IACjD,OAAO;GACR,CACF;GAAA,UAAA;GAAA,UC1DH;GAkDA,cAAA;IAAA;KAAA,MAAA;KAAA,MDDY;IAAY;IAAA;KAAA,MAAA;KAAA,MAAA,GAAA;KAAA,UAAA;KAAA,QAAA,CAAA,SAAA,SAAA;IAAA;IAAA;KAAA,MAAA;KAAA,MAAE;IAAmB;GAAA;GAAA,iBAAA,GAAA,wBAAA;EAAA,CAAA;CAAA;;AAWhC,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAmB,YAAA,CAAA;EAb/B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAiB,SAClB,CAAC,cAAc,mBAAmB;GAAC,iBAE3B,wBAAwB;GAAM,WACpC,CACT;IACE,SAAS;IACT,aAAa,iBAAgB,mBAAoB;IACjD,OAAO;GACR,CACF;GAAA,UAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-price-input.mjs","names":[],"sources":["../../../projects/ui-components/price-input/price-input.component.ts","../../../projects/ui-components/price-input/price-input.component.html"],"sourcesContent":["import {\n Component,\n model,\n input,\n signal,\n computed,\n effect,\n inject,\n output,\n forwardRef,\n DestroyRef,\n ChangeDetectionStrategy,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport {\n ControlValueAccessor,\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n} from '@angular/forms';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { type FormValueControl, type ValidationError } from '@angular/forms/signals';\nimport { TranslocoService } from '@jsverse/transloco';\nimport {\n ShkConfigService,\n currencyDecimals,\n currencySymbol,\n formatNumber,\n numberSeparators,\n} from 'shirkasoft-ui-components/config';\nimport {\n errorMessagesFromMap,\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 * Currency/percentage numeric input with reactive forms support.\n *\n * Binding modes (highest precedence first):\n * - `control`: a FormControl (or use it inside a form with `formControlName`).\n * - `value`/`valueChange` or `[(value)]`: two-way model signals.\n *\n * Text-based input (`type=\"text\"` + `inputmode=\"decimal\"`) with decimal\n * precision control, min/max clamping on blur and thousands formatting.\n */\n@Component({\n selector: 'shk-price-input',\n imports: [CommonModule, ReactiveFormsModule],\n templateUrl: './price-input.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => PriceInputComponent),\n multi: true,\n },\n ],\n})\nexport class PriceInputComponent implements ControlValueAccessor, FormValueControl<number | null> {\n /** Reactive control. When provided it takes precedence over `value`/`valueChange`. */\n control = input<FormControl<number | null> | undefined>(undefined);\n /** Numeric value (two-way), used when no `control` is bound. */\n value = model<number | null>(0);\n /** Whether the input works as a percentage (two-way). */\n isPercentage = model<boolean>(false);\n /** Label displayed above the field. */\n label = input<string>('');\n /** id attribute applied to the native input. */\n inputId = input<string>('');\n /** Marks the field as required. */\n required = input<boolean>(false);\n /** Disables the input. */\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 /** Minimum allowed value (clamped on blur). */\n min = input<number | undefined>(0);\n /** Maximum allowed value (clamped on blur). */\n max = input<number | undefined>(Infinity);\n /**\n * Maximum number of decimal places (0 = integer). Unset = the `numbers.decimals`\n * option, else the digits of the `numbers.currency` option (2 for USD).\n */\n decimals = input<number | undefined>(undefined);\n /**\n * Symbol shown in the mode toggle button when not a percentage. Empty = the\n * `numbers.currencySymbol` option, else the symbol of `numbers.currency` ('$').\n */\n currency = input<string>('');\n /** Placeholder text of the native input. */\n placeholder = input<string>('');\n /** Accessible label; falls back to `label`. */\n ariaLabel = input<string>('');\n /** Blocks the minus sign from being typed. */\n preventNegative = input<boolean>(false);\n /** Shows the error styling on the field. */\n showError = input<boolean>(false);\n /** Message rendered when the field is in error state. */\n errorMessage = input<string>('');\n /** Emitted on blur so Signal Forms can mark the field as touched. */\n touch = output<void>();\n\n private destroyRef = inject(DestroyRef);\n private transloco = inject(TranslocoService);\n /** Library-wide options: currency, decimals and number separators. */\n private readonly config = inject(ShkConfigService);\n\n /** Decimal places actually used. */\n private readonly effectiveDecimals = computed(() =>\n Math.max(\n 0,\n this.decimals() ??\n this.config.get('numbers.decimals')() ??\n currencyDecimals(this.config.get('numbers.currency')()),\n ),\n );\n /** Locale of the grouping/decimal separators. */\n private readonly numbersLocale = computed(() => this.config.get('numbers.locale')());\n /** Decimal separator of the locale (`.` or `,`), used while editing. */\n private readonly decimalSeparator = computed(() => numberSeparators(this.numbersLocale()).decimal);\n /** Symbol shown in the toggle: input, `numbers.currencySymbol`, or the currency's symbol. */\n readonly displaySymbol = computed(\n () =>\n this.currency() ||\n this.config.get('numbers.currencySymbol')() ||\n currencySymbol(this.config.get('numbers.currency')(), this.numbersLocale()),\n );\n\n /** Text currently shown in the input (raw while focused, formatted on blur). */\n displayText = signal<string>('');\n /** Whether the native input currently has focus. */\n focused = signal<boolean>(false);\n /** Disabled state coming from the reactive control. */\n private controlDisabled = signal<boolean>(false);\n /** Prevents re-subscribing to the same form control. */\n private ctrlSubscribed = false;\n\n /** Bumped on control status changes / blur so error computeds refresh. */\n private statusTick = signal(0);\n\n /**\n * True when the input is driven by Signal Forms instead of a reactive control.\n * Detected by the absence of a reactive control: `[formField]` provides the\n * state through its `errors`/`invalid`/`touched`/`dirty` inputs.\n */\n protected readonly usesSignalForms = computed(() => !this.control());\n\n /**\n * Whether the error state is shown: forced with `showError`, or when the\n * bound `control` is invalid and has been touched or modified.\n */\n hasError = computed(() => {\n if (this.usesSignalForms()) {\n return this.showError() || (this.invalid() && (this.touched() || this.dirty()));\n }\n\n this.statusTick();\n if (this.showError()) return true;\n const ctrl = this.control();\n return !!ctrl && ctrl.invalid && (ctrl.touched || ctrl.dirty);\n });\n\n /** Message shown under the field: `errorMessage` or one derived from the errors. */\n errorText = computed(() => {\n this.statusTick();\n const custom = this.errorMessage();\n if (custom) return custom;\n\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()), {}, translate)[0] ?? '';\n }\n\n const errors = this.control()?.errors;\n if (!errors) return '';\n\n return errorMessagesFromMap(errors, {}, translate)[0] ?? '';\n });\n\n /** Effective disabled state combining the input and the form binding. */\n isDisabled = computed(() => this.disabled() || this.controlDisabled());\n\n /** Callbacks used by the ControlValueAccessor contract. */\n private onChange: (value: number | null) => void = () => {};\n private onTouched: () => void = () => {};\n\n constructor() {\n // Subscribe once to the bound control for change/status tracking.\n effect(() => {\n const ctrl = this.control();\n if (!ctrl || this.ctrlSubscribed) return;\n this.ctrlSubscribed = true;\n this.controlDisabled.set(ctrl.disabled);\n\n ctrl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((v) => {\n if (!this.focused()) {\n this.displayText.set(this.formatNumber(v ?? 0));\n }\n });\n ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n this.controlDisabled.set(ctrl.disabled);\n this.statusTick.update((v) => v + 1);\n });\n // Also refresh on touched/pristine changes (e.g. markAllAsTouched()).\n ctrl.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n this.statusTick.update((v) => v + 1);\n });\n });\n\n // Reflect the effective value into the display (unless the user is typing).\n effect(() => {\n const ctrl = this.control();\n const v = ctrl ? (ctrl.value as number | null) : this.value();\n if (!this.focused()) {\n this.displayText.set(this.formatNumber(v ?? 0));\n }\n });\n }\n\n /** Toggles between amount and percentage modes (unless disabled). */\n toggleMode(): void {\n if (this.isDisabled()) return;\n this.isPercentage.update((v) => !v);\n }\n\n /**\n * Switches to the editable form (no grouping, locale decimal separator) and\n * selects it so the user can type over it or edit in the middle safely.\n */\n onFocus(event: FocusEvent): void {\n const input = event.target as HTMLInputElement;\n this.focused.set(true);\n this.displayText.set(this.editableNumber(this.currentValue()));\n // Select once the new text is rendered.\n setTimeout(() => {\n if (this.focused()) input.select();\n });\n }\n\n /** Clamps, rounds and formats the value when the field loses focus. */\n onBlur(): void {\n this.focused.set(false);\n this.onTouched();\n this.touch.emit();\n\n let v = this.parseEditable(this.displayText());\n if (isNaN(v)) v = 0;\n\n const min = this.min() ?? 0;\n const max = this.max() ?? Infinity;\n if (isFinite(min) && v < min) v = min;\n if (isFinite(max) && v > max) v = max;\n\n v = this.roundTo(v);\n this.setValue(v);\n this.displayText.set(this.formatNumber(v));\n this.control()?.markAsTouched();\n this.statusTick.update((n) => n + 1);\n }\n\n /** Blocks characters that would break the numeric format. */\n onKeydown(event: KeyboardEvent): void {\n const allowed = [\n 'Backspace',\n 'Tab',\n 'End',\n 'Home',\n 'ArrowLeft',\n 'ArrowRight',\n 'Delete',\n 'Enter',\n 'Escape',\n ];\n if (allowed.includes(event.key)) return;\n if (/^\\d$/.test(event.key)) return;\n\n if (event.key === '.' || event.key === ',') {\n const input = event.target as HTMLInputElement;\n if (input.value.includes('.') || input.value.includes(',')) event.preventDefault();\n return;\n }\n\n if (event.key === '-') {\n const input = event.target as HTMLInputElement;\n if (this.preventNegative() || (this.min() ?? 0) >= 0) {\n event.preventDefault();\n } else if (input.value.includes('-')) {\n event.preventDefault();\n }\n return;\n }\n\n event.preventDefault();\n }\n\n /** Sanitizes the raw input (digits + one separator + optional sign) and writes the value once. */\n onInput(event: Event): void {\n const input = event.target as HTMLInputElement;\n const pos = input.selectionStart ?? input.value.length;\n\n let cleaned = input.value.replace(/[^0-9.,-]/g, '');\n if (this.preventNegative() || (this.min() ?? 0) >= 0) cleaned = cleaned.replace(/-/g, '');\n // Either `.` or `,` is accepted as the decimal separator while typing.\n cleaned = cleaned.replace(/,/g, '.');\n\n const dot = cleaned.indexOf('.');\n if (dot >= 0) {\n const dec = this.effectiveDecimals();\n const intPart = cleaned.slice(0, dot);\n const decPart = cleaned.slice(dot + 1, dot + 1 + dec).replace(/\\./g, '');\n cleaned = dec > 0 ? intPart + '.' + decPart : intPart;\n }\n\n // Show the locale's decimal separator; keep `.` for parsing.\n const shown = cleaned.replace('.', this.decimalSeparator());\n input.value = shown;\n const newPos = Math.min(pos, shown.length);\n input.setSelectionRange(newPos, newPos);\n this.displayText.set(shown);\n\n const num = parseFloat(cleaned);\n this.setValue(isNaN(num) ? 0 : num);\n }\n\n /** Writes the value to the effective binding source. */\n private setValue(v: number): void {\n const ctrl = this.control();\n if (ctrl) {\n ctrl.setValue(v, { emitEvent: true });\n } else {\n this.value.set(v);\n }\n this.onChange(v);\n }\n\n private roundTo(v: number): number {\n const factor = Math.pow(10, this.effectiveDecimals());\n return Math.round(v * factor) / factor;\n }\n\n /** Formats a number with the locale's separators and up to `decimals` places. */\n private formatNumber(v: number): string {\n if (v == null || isNaN(v)) return '0';\n return formatNumber(v, this.numbersLocale(), this.effectiveDecimals());\n }\n\n /** Number as edited: no grouping, locale decimal separator (\"1234,5\" for es-ES). */\n private editableNumber(v: number | null | undefined): string {\n if (v == null || isNaN(v)) return '';\n return String(this.roundTo(v)).replace('.', this.decimalSeparator());\n }\n\n /** Parses the editable text back to a number (either separator is accepted). */\n private parseEditable(text: string): number {\n return parseFloat(text.replace(/\\s/g, '').replace(/,/g, '.'));\n }\n\n /** Value of the effective binding source (control or `value`). */\n private currentValue(): number | null {\n const ctrl = this.control();\n return ctrl ? (ctrl.value as number | null) : this.value();\n }\n\n // ── ControlValueAccessor ───────────────────────────────────────────────────\n\n writeValue(value: any): void {\n if (!this.focused()) {\n this.displayText.set(this.formatNumber(value ?? 0));\n }\n }\n\n registerOnChange(fn: any): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: any): void {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.controlDisabled.set(isDisabled);\n }\n}\n","<div>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-400\">*</span>\n }\n </div>\n }\n <div class=\"flex\">\n <input\n [id]=\"inputId()\"\n type=\"text\"\n inputmode=\"decimal\"\n autocomplete=\"off\"\n [value]=\"displayText()\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"ariaLabel() || label()\"\n [attr.aria-invalid]=\"hasError() || null\"\n [disabled]=\"isDisabled()\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n (input)=\"onInput($event)\"\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: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': hasError(),\n '_shk-border dark:[border-color:var(--shk-surface-200)] focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !hasError()\n }\"\n />\n <button\n type=\"button\"\n (click)=\"toggleMode()\"\n [disabled]=\"isDisabled()\"\n class=\"px-3 py-2 text-sm font-medium border rounded-r-lg transition-colors shrink-0\"\n [ngClass]=\"{\n '_shk-bg-primary-soft _shk-border-primary-200 _shk-text-primary-700 dark:[background-color:var(--shk-primary-900)] dark:[border-color:var(--shk-primary-700)] dark:[color:var(--shk-primary-300)]': isPercentage(),\n '_shk-bg-white _shk-border _shk-text-surface-500 dark:[background-color:var(--shk-surface-100)] dark:[border-color:var(--shk-surface-200)] dark:[color:var(--shk-surface-400)]': !isPercentage(),\n 'cursor-not-allowed opacity-50': isDisabled()\n }\"\n >\n {{ isPercentage() ? '%' : displaySymbol() }}\n </button>\n </div>\n @if (hasError() && errorText()) {\n <div class=\"text-xs _shk-text-red-500 mt-1\">\n {{ errorText() }}\n </div>\n }\n</div>\n"],"mappings":";;;;;;;;;AAgEA,IAAa,sBAAb,MAAa,oBAAmB;CAwI9B,cAAA;EAtIA,KAAA,UAAU,MAA8C,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EAElE,KAAA,QAAQ,MAAqB,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAE/B,KAAA,eAAe,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,eAAA,CAAA,+BAAA,CAAA,CAAA;EAEpC,KAAA,QAAQ,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAEzB,KAAA,UAAU,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EAE3B,KAAA,WAAW,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;EAEhC,KAAA,WAAW,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;EAEhC,KAAA,SAAS,MAAwD,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;EAEpE,KAAA,UAAU,MAAe,OAAM,GA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