shirkasoft-ui-components 1.3.8 → 1.3.10
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 +60 -14
- package/fesm2022/shirkasoft-ui-components-button.mjs +2 -2
- package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +2 -2
- package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs +206 -15
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs +2 -2
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-loading.mjs +2 -2
- package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-modal.mjs +2 -2
- package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-notification.mjs +2 -2
- package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-price-input.mjs +37 -2
- package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-select.mjs +15 -5
- package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-table.mjs +200 -13
- package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tabs.mjs +7 -12
- package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tag.mjs +3 -3
- package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-text-field.mjs +2 -2
- package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-toggle.mjs +61 -24
- package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs +62 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/src/theme.css +89 -0
- package/types/shirkasoft-ui-components-date-picker.d.ts +42 -2
- package/types/shirkasoft-ui-components-price-input.d.ts +10 -0
- package/types/shirkasoft-ui-components-select.d.ts +2 -0
- package/types/shirkasoft-ui-components-table.d.ts +86 -9
- package/types/shirkasoft-ui-components-toggle.d.ts +7 -1
- package/types/shirkasoft-ui-components-utils.d.ts +44 -1
|
@@ -128,11 +128,11 @@ class NotificationComponent {
|
|
|
128
128
|
return Math.round(progress || 0);
|
|
129
129
|
}
|
|
130
130
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: NotificationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
131
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.23", type: NotificationComponent, isStandalone: true, selector: "shk-notification", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n
|
|
131
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.23", type: NotificationComponent, isStandalone: true, selector: "shk-notification", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n class=\"shk-toast mb-4\"\n [ngClass]=\"'shk-toast-' + notification.type\"\n role=\"alert\"\n >\n <div class=\"shk-toast-icon\">\n <svg [lucideIcon]=\"getIcon(getNotificationIcon(notification.type))\"></svg>\n </div>\n <div class=\"shk-toast-message\">\n {{ notification.message }}\n </div>\n <button\n type=\"button\"\n (click)=\"removeNotification(notification)\"\n aria-label=\"Close\"\n class=\"shk-toast-close\"\n >\n <svg [lucideIcon]=\"getIcon('x')\"></svg>\n </button>\n </div>\n }\n</div>\n", styles: [".shk-toast{--shk-toast-accent: var(--shk-info-600);display:flex;align-items:center;gap:.75rem;width:100%;min-width:320px;max-width:28rem;padding:.75rem .75rem .75rem .875rem;border-radius:.75rem;background-color:#fff;border:1px solid var(--shk-surface-200);color:var(--shk-surface-800);box-shadow:0 12px 32px -8px #0000002e,0 4px 10px -4px #00000014;animation:shk-toast-in .25s cubic-bezier(.21,1.02,.73,1)}:host-context(.dark) .shk-toast{background-color:var(--shk-surface-100);border-color:var(--shk-surface-200);box-shadow:0 12px 32px -8px #0009,0 4px 10px -4px #0006}.shk-toast-success{--shk-toast-accent: var(--shk-success-600)}.shk-toast-error{--shk-toast-accent: var(--shk-error-600)}:host-context(.dark) .shk-toast-error{--shk-toast-accent: var(--shk-error-500)}.shk-toast-warning{--shk-toast-accent: var(--shk-warning-600)}.shk-toast-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:2rem;border-radius:9999px;color:var(--shk-toast-accent);background-color:color-mix(in srgb,var(--shk-toast-accent) 14%,transparent)}.shk-toast-icon svg{width:1.125rem;height:1.125rem}.shk-toast-message{flex:1;min-width:0;font-size:.875rem;line-height:1.25rem;font-weight:500;overflow-wrap:break-word}.shk-toast-close{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1.75rem;height:1.75rem;border-radius:.375rem;background:transparent;color:var(--shk-surface-400);transition:background-color .15s ease,color .15s ease}.shk-toast-close:hover{color:var(--shk-surface-700);background-color:var(--shk-surface-100)}:host-context(.dark) .shk-toast-close:hover{background-color:var(--shk-surface-200)}.shk-toast-close:focus-visible{outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--shk-primary-500) 45%,transparent)}.shk-toast-close svg{width:1rem;height:1rem}@keyframes shk-toast-in{0%{opacity:0;transform:translateY(-8px) scale(.97)}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
132
132
|
}
|
|
133
133
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: NotificationComponent, decorators: [{
|
|
134
134
|
type: Component,
|
|
135
|
-
args: [{ selector: 'shk-notification', standalone: true, imports: [CommonModule, LucideDynamicIcon], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n
|
|
135
|
+
args: [{ selector: 'shk-notification', standalone: true, imports: [CommonModule, LucideDynamicIcon], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n class=\"shk-toast mb-4\"\n [ngClass]=\"'shk-toast-' + notification.type\"\n role=\"alert\"\n >\n <div class=\"shk-toast-icon\">\n <svg [lucideIcon]=\"getIcon(getNotificationIcon(notification.type))\"></svg>\n </div>\n <div class=\"shk-toast-message\">\n {{ notification.message }}\n </div>\n <button\n type=\"button\"\n (click)=\"removeNotification(notification)\"\n aria-label=\"Close\"\n class=\"shk-toast-close\"\n >\n <svg [lucideIcon]=\"getIcon('x')\"></svg>\n </button>\n </div>\n }\n</div>\n", styles: [".shk-toast{--shk-toast-accent: var(--shk-info-600);display:flex;align-items:center;gap:.75rem;width:100%;min-width:320px;max-width:28rem;padding:.75rem .75rem .75rem .875rem;border-radius:.75rem;background-color:#fff;border:1px solid var(--shk-surface-200);color:var(--shk-surface-800);box-shadow:0 12px 32px -8px #0000002e,0 4px 10px -4px #00000014;animation:shk-toast-in .25s cubic-bezier(.21,1.02,.73,1)}:host-context(.dark) .shk-toast{background-color:var(--shk-surface-100);border-color:var(--shk-surface-200);box-shadow:0 12px 32px -8px #0009,0 4px 10px -4px #0006}.shk-toast-success{--shk-toast-accent: var(--shk-success-600)}.shk-toast-error{--shk-toast-accent: var(--shk-error-600)}:host-context(.dark) .shk-toast-error{--shk-toast-accent: var(--shk-error-500)}.shk-toast-warning{--shk-toast-accent: var(--shk-warning-600)}.shk-toast-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:2rem;border-radius:9999px;color:var(--shk-toast-accent);background-color:color-mix(in srgb,var(--shk-toast-accent) 14%,transparent)}.shk-toast-icon svg{width:1.125rem;height:1.125rem}.shk-toast-message{flex:1;min-width:0;font-size:.875rem;line-height:1.25rem;font-weight:500;overflow-wrap:break-word}.shk-toast-close{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1.75rem;height:1.75rem;border-radius:.375rem;background:transparent;color:var(--shk-surface-400);transition:background-color .15s ease,color .15s ease}.shk-toast-close:hover{color:var(--shk-surface-700);background-color:var(--shk-surface-100)}:host-context(.dark) .shk-toast-close:hover{background-color:var(--shk-surface-200)}.shk-toast-close:focus-visible{outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--shk-primary-500) 45%,transparent)}.shk-toast-close svg{width:1rem;height:1rem}@keyframes shk-toast-in{0%{opacity:0;transform:translateY(-8px) scale(.97)}}\n"] }]
|
|
136
136
|
}], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }] } });
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-notification.mjs","sources":["../../../projects/ui-components/notification/notification.service.ts","../../../projects/ui-components/notification/notification.component.ts","../../../projects/ui-components/notification/notification.component.html","../../../projects/ui-components/notification/shirkasoft-ui-components-notification.ts"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/** Toast-style notification entry. */\nexport interface Notification {\n id: string;\n message: string;\n type: 'success' | 'error' | 'warning' | 'info';\n /** Current progress 0-100 when `showProgress` is true. */\n progress?: number;\n /** Whether the notification renders a progress indicator. */\n showProgress?: boolean;\n}\n\n/**\n * Central notification store. Components push/update/remove notifications\n * reactively through signals for the notification component to render.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class NotificationService {\n /** Reactive list of visible notifications. */\n private notificationsSignal = signal<Notification[]>([]);\n /** Monotonic id counter for new notifications. */\n private currentId = 0;\n\n /** Readonly reactive list of visible notifications. */\n notifications = this.notificationsSignal.asReadonly();\n\n /**\n * Adds a notification and returns its id. When `showProgress` is false and\n * `duration` is positive, it auto-removes after that many ms.\n */\n addNotification(\n message: string,\n type: Notification['type'] = 'info',\n showProgress: boolean = false,\n duration: number = 5000\n ): string {\n const id = (++this.currentId).toString();\n const notification: Notification = {\n id,\n message,\n type,\n progress: showProgress ? 0 : undefined,\n showProgress,\n };\n\n this.notificationsSignal.update((notifications) => [\n ...notifications,\n notification,\n ]);\n\n if (duration > 0 && !showProgress) {\n setTimeout(() => this.removeNotificationById(id), duration);\n }\n\n return id;\n }\n\n /** Updates a progress notification; auto-removes when progress hits 100. */\n updateProgress(notificationId: string, progress: number) {\n const currentNotifications = this.notificationsSignal();\n const index = currentNotifications.findIndex(\n (n) => n.id === notificationId\n );\n\n if (index > -1 && currentNotifications[index].showProgress) {\n const updatedProgress = Math.min(100, Math.max(0, progress));\n\n this.notificationsSignal.update((notifications) =>\n notifications.map((n, i) =>\n i === index ? { ...n, progress: updatedProgress } : n\n )\n );\n\n if (progress >= 100) {\n setTimeout(() => this.removeNotificationById(notificationId), 2000);\n }\n }\n }\n\n /** Removes the given notification. */\n removeNotification(notification: Notification): void {\n this.removeNotificationById(notification.id);\n }\n\n /** Removes the notification with the given id. */\n removeNotificationById(notificationId: string): void {\n this.notificationsSignal.update((notifications) =>\n notifications.filter((n) => n.id !== notificationId)\n );\n }\n\n /** Removes every visible notification. */\n clearAll(): void {\n this.notificationsSignal.set([]);\n }\n}","import {\n Component,\n input,\n inject,\n ChangeDetectionStrategy,\n computed,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport {\n NotificationService,\n Notification,\n} from './notification.service';\nimport {\n LucideDynamicIcon,\n LucideInfo,\n LucideTriangleAlert,\n} from '@lucide/angular';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\nexport type NotificationPosition = 'center-top' | 'right-top' | 'left-top';\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 * Toast notification host that renders the notifications pushed through the\n * NotificationService in the configured position.\n */\n@Component({\n selector: 'shk-notification',\n templateUrl: './notification.component.html',\n standalone: true,\n imports: [CommonModule, LucideDynamicIcon],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class NotificationComponent {\n /** Position of the notification stack: center, right or left top. */\n position = input<NotificationPosition>('center-top');\n\n private notificationService = inject(NotificationService);\n protected getIcon = (name: any) => getIconFromCentral(name, LucideInfo);\n\n /** Maps each notification type to its internal icon name. */\n private readonly iconMap: Record<string, string> = {\n success: 'check',\n error: 'circle-x',\n info: 'info',\n warning: 'triangle-alert',\n };\n\n /** Resolves the icon name for a notification type. */\n getNotificationIcon(type: string): string {\n return this.iconMap[type] || 'info';\n }\n\n /** Live list of active notifications. */\n notifications = this.notificationService.notifications;\n\n /** Notifications sorted with the newest first. */\n sortedNotifications = computed(\n () => [...this.notifications()].reverse(),\n );\n\n /** Removes a notification through the service. */\n removeNotification(notification: Notification): void {\n this.notificationService.removeNotification(notification);\n }\n\n /** Rounds the progress value of a notification. */\n roundProgress(progress: number | undefined): number {\n return Math.round(progress || 0);\n }\n\n /** Whether there are notifications to show. */\n hasNotifications = computed(() => this.notifications().length > 0);\n\n /** CSS classes positioning the stack according to `position`. */\n positionClass = computed(() => {\n const base = 'fixed top-4 z-[9999] space-y-4 sm:space-y-6 sm:top-6 lg:top-8';\n switch (this.position()) {\n case 'right-top':\n return `${base} right-4`;\n case 'left-top':\n return `${base} left-4`;\n default:\n return `${base} left-1/2 -translate-x-1/2`;\n }\n });\n}\n","<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n [ngClass]=\"{\n 'bg-green-50/80 dark:bg-green-900/30 border-green-400 dark:border-green-600 text-green-800 dark:text-green-200':\n notification.type === 'success',\n 'bg-red-50/80 dark:bg-red-900/30 border-red-400 dark:border-red-600 text-red-800 dark:text-red-200':\n notification.type === 'error',\n 'bg-blue-50/80 dark:bg-blue-900/30 border-blue-400 dark:border-blue-600 text-blue-800 dark:text-blue-200':\n notification.type === 'info',\n 'bg-yellow-50/80 dark:bg-yellow-900/30 border-yellow-400 dark:border-yellow-500 text-yellow-800 dark:text-yellow-200':\n notification.type === 'warning',\n }\"\n class=\"flex items-center w-full min-w-[320px] max-w-xs sm:max-w-sm lg:max-w-md p-4 mb-4 border-l-4 rounded-lg shadow-lg backdrop-blur-sm transition-all duration-300 transform hover:scale-105 hover:shadow-xl\"\n role=\"alert\"\n >\n <div\n [ngClass]=\"{\n 'text-green-600': notification.type === 'success',\n 'text-red-600': notification.type === 'error',\n 'text-blue-600': notification.type === 'info',\n 'text-yellow-600': notification.type === 'warning',\n }\"\n class=\"inline-flex items-center justify-center flex-shrink-0 w-10 h-10 rounded-lg bg-opacity-10\"\n >\n <svg [lucideIcon]=\"getIcon(getNotificationIcon(notification.type))\" class=\"w-6 h-6\"></svg>\n </div>\n <div class=\"ms-4 flex-1 text-sm font-medium break-words\">\n {{ notification.message }}\n </div>\n <button\n type=\"button\"\n (click)=\"removeNotification(notification)\"\n aria-label=\"Close\"\n [ngClass]=\"{\n 'text-green-600 hover:text-green-800':\n notification.type === 'success',\n 'text-red-600 hover:text-red-800': notification.type === 'error',\n 'text-blue-600 hover:text-blue-800': notification.type === 'info',\n 'text-yellow-600 hover:text-yellow-800':\n notification.type === 'warning',\n }\"\n class=\"mx-2 -my-1.5 bg-transparent focus:outline-none\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getIconFromCentral"],"mappings":";;;;;;;AAmBA;;;AAGG;MAIU,mBAAmB,CAAA;AAHhC,IAAA,WAAA,GAAA;;AAKU,QAAA,IAAA,CAAA,mBAAmB,GAAG,MAAM,CAAiB,EAAE,0FAAC;;QAEhD,IAAA,CAAA,SAAS,GAAG,CAAC;;AAGrB,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE;AAuEtD,IAAA;AArEC;;;AAGG;IACH,eAAe,CACb,OAAe,EACf,IAAA,GAA6B,MAAM,EACnC,YAAA,GAAwB,KAAK,EAC7B,QAAA,GAAmB,IAAI,EAAA;QAEvB,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE;AACxC,QAAA,MAAM,YAAY,GAAiB;YACjC,EAAE;YACF,OAAO;YACP,IAAI;YACJ,QAAQ,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS;YACtC,YAAY;SACb;QAED,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,aAAa,KAAK;AACjD,YAAA,GAAG,aAAa;YAChB,YAAY;AACb,SAAA,CAAC;AAEF,QAAA,IAAI,QAAQ,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE;AACjC,YAAA,UAAU,CAAC,MAAM,IAAI,CAAC,sBAAsB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;QAC7D;AAEA,QAAA,OAAO,EAAE;IACX;;IAGA,cAAc,CAAC,cAAsB,EAAE,QAAgB,EAAA;AACrD,QAAA,MAAM,oBAAoB,GAAG,IAAI,CAA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,YAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAG9B,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAPjC,SAAS;+BACE,kBAAkB,EAAA,UAAA,EAEhB,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,EAAE,iBAAiB,CAAC,EAAA,eAAA,EACzB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,60EAAA,EAAA;;;AEpCjD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-notification.mjs","sources":["../../../projects/ui-components/notification/notification.service.ts","../../../projects/ui-components/notification/notification.component.ts","../../../projects/ui-components/notification/notification.component.html","../../../projects/ui-components/notification/shirkasoft-ui-components-notification.ts"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/** Toast-style notification entry. */\nexport interface Notification {\n id: string;\n message: string;\n type: 'success' | 'error' | 'warning' | 'info';\n /** Current progress 0-100 when `showProgress` is true. */\n progress?: number;\n /** Whether the notification renders a progress indicator. */\n showProgress?: boolean;\n}\n\n/**\n * Central notification store. Components push/update/remove notifications\n * reactively through signals for the notification component to render.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class NotificationService {\n /** Reactive list of visible notifications. */\n private notificationsSignal = signal<Notification[]>([]);\n /** Monotonic id counter for new notifications. */\n private currentId = 0;\n\n /** Readonly reactive list of visible notifications. */\n notifications = this.notificationsSignal.asReadonly();\n\n /**\n * Adds a notification and returns its id. When `showProgress` is false and\n * `duration` is positive, it auto-removes after that many ms.\n */\n addNotification(\n message: string,\n type: Notification['type'] = 'info',\n showProgress: boolean = false,\n duration: number = 5000\n ): string {\n const id = (++this.currentId).toString();\n const notification: Notification = {\n id,\n message,\n type,\n progress: showProgress ? 0 : undefined,\n showProgress,\n };\n\n this.notificationsSignal.update((notifications) => [\n ...notifications,\n notification,\n ]);\n\n if (duration > 0 && !showProgress) {\n setTimeout(() => this.removeNotificationById(id), duration);\n }\n\n return id;\n }\n\n /** Updates a progress notification; auto-removes when progress hits 100. */\n updateProgress(notificationId: string, progress: number) {\n const currentNotifications = this.notificationsSignal();\n const index = currentNotifications.findIndex(\n (n) => n.id === notificationId\n );\n\n if (index > -1 && currentNotifications[index].showProgress) {\n const updatedProgress = Math.min(100, Math.max(0, progress));\n\n this.notificationsSignal.update((notifications) =>\n notifications.map((n, i) =>\n i === index ? { ...n, progress: updatedProgress } : n\n )\n );\n\n if (progress >= 100) {\n setTimeout(() => this.removeNotificationById(notificationId), 2000);\n }\n }\n }\n\n /** Removes the given notification. */\n removeNotification(notification: Notification): void {\n this.removeNotificationById(notification.id);\n }\n\n /** Removes the notification with the given id. */\n removeNotificationById(notificationId: string): void {\n this.notificationsSignal.update((notifications) =>\n notifications.filter((n) => n.id !== notificationId)\n );\n }\n\n /** Removes every visible notification. */\n clearAll(): void {\n this.notificationsSignal.set([]);\n }\n}","import {\n Component,\n input,\n inject,\n ChangeDetectionStrategy,\n computed,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport {\n NotificationService,\n Notification,\n} from './notification.service';\nimport {\n LucideDynamicIcon,\n LucideInfo,\n LucideTriangleAlert,\n} from '@lucide/angular';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\nexport type NotificationPosition = 'center-top' | 'right-top' | 'left-top';\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 * Toast notification host that renders the notifications pushed through the\n * NotificationService in the configured position.\n */\n@Component({\n selector: 'shk-notification',\n templateUrl: './notification.component.html',\n standalone: true,\n imports: [CommonModule, LucideDynamicIcon],\n changeDetection: ChangeDetectionStrategy.OnPush,\n styles: [\n `\n .shk-toast {\n --shk-toast-accent: var(--shk-info-600);\n display: flex;\n align-items: center;\n gap: 0.75rem;\n width: 100%;\n min-width: 320px;\n max-width: 28rem;\n padding: 0.75rem 0.75rem 0.75rem 0.875rem;\n border-radius: 0.75rem;\n background-color: #fff;\n border: 1px solid var(--shk-surface-200);\n color: var(--shk-surface-800);\n box-shadow:\n 0 12px 32px -8px rgba(0, 0, 0, 0.18),\n 0 4px 10px -4px rgba(0, 0, 0, 0.08);\n animation: shk-toast-in 0.25s cubic-bezier(0.21, 1.02, 0.73, 1);\n }\n :host-context(.dark) .shk-toast {\n background-color: var(--shk-surface-100);\n border-color: var(--shk-surface-200);\n box-shadow:\n 0 12px 32px -8px rgba(0, 0, 0, 0.6),\n 0 4px 10px -4px rgba(0, 0, 0, 0.4);\n }\n .shk-toast-success {\n --shk-toast-accent: var(--shk-success-600);\n }\n .shk-toast-error {\n --shk-toast-accent: var(--shk-error-600);\n }\n :host-context(.dark) .shk-toast-error {\n --shk-toast-accent: var(--shk-error-500);\n }\n .shk-toast-warning {\n --shk-toast-accent: var(--shk-warning-600);\n }\n .shk-toast-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 2rem;\n height: 2rem;\n border-radius: 9999px;\n color: var(--shk-toast-accent);\n background-color: color-mix(in srgb, var(--shk-toast-accent) 14%, transparent);\n }\n .shk-toast-icon svg {\n width: 1.125rem;\n height: 1.125rem;\n }\n .shk-toast-message {\n flex: 1;\n min-width: 0;\n font-size: 0.875rem;\n line-height: 1.25rem;\n font-weight: 500;\n overflow-wrap: break-word;\n }\n .shk-toast-close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 1.75rem;\n height: 1.75rem;\n border-radius: 0.375rem;\n background: transparent;\n color: var(--shk-surface-400);\n transition:\n background-color 0.15s ease,\n color 0.15s ease;\n }\n .shk-toast-close:hover {\n color: var(--shk-surface-700);\n background-color: var(--shk-surface-100);\n }\n :host-context(.dark) .shk-toast-close:hover {\n background-color: var(--shk-surface-200);\n }\n .shk-toast-close:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--shk-primary-500) 45%, transparent);\n }\n .shk-toast-close svg {\n width: 1rem;\n height: 1rem;\n }\n @keyframes shk-toast-in {\n from {\n opacity: 0;\n transform: translateY(-8px) scale(0.97);\n }\n }\n `,\n ],\n})\nexport class NotificationComponent {\n /** Position of the notification stack: center, right or left top. */\n position = input<NotificationPosition>('center-top');\n\n private notificationService = inject(NotificationService);\n protected getIcon = (name: any) => getIconFromCentral(name, LucideInfo);\n\n /** Maps each notification type to its internal icon name. */\n private readonly iconMap: Record<string, string> = {\n success: 'check',\n error: 'circle-x',\n info: 'info',\n warning: 'triangle-alert',\n };\n\n /** Resolves the icon name for a notification type. */\n getNotificationIcon(type: string): string {\n return this.iconMap[type] || 'info';\n }\n\n /** Live list of active notifications. */\n notifications = this.notificationService.notifications;\n\n /** Notifications sorted with the newest first. */\n sortedNotifications = computed(\n () => [...this.notifications()].reverse(),\n );\n\n /** Removes a notification through the service. */\n removeNotification(notification: Notification): void {\n this.notificationService.removeNotification(notification);\n }\n\n /** Rounds the progress value of a notification. */\n roundProgress(progress: number | undefined): number {\n return Math.round(progress || 0);\n }\n\n /** Whether there are notifications to show. */\n hasNotifications = computed(() => this.notifications().length > 0);\n\n /** CSS classes positioning the stack according to `position`. */\n positionClass = computed(() => {\n const base = 'fixed top-4 z-[9999] space-y-4 sm:space-y-6 sm:top-6 lg:top-8';\n switch (this.position()) {\n case 'right-top':\n return `${base} right-4`;\n case 'left-top':\n return `${base} left-4`;\n default:\n return `${base} left-1/2 -translate-x-1/2`;\n }\n });\n}\n","<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n class=\"shk-toast mb-4\"\n [ngClass]=\"'shk-toast-' + notification.type\"\n role=\"alert\"\n >\n <div class=\"shk-toast-icon\">\n <svg [lucideIcon]=\"getIcon(getNotificationIcon(notification.type))\"></svg>\n </div>\n <div class=\"shk-toast-message\">\n {{ notification.message }}\n </div>\n <button\n type=\"button\"\n (click)=\"removeNotification(notification)\"\n aria-label=\"Close\"\n class=\"shk-toast-close\"\n >\n <svg [lucideIcon]=\"getIcon('x')\"></svg>\n </button>\n </div>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getIconFromCentral"],"mappings":";;;;;;;AAmBA;;;AAGG;MAIU,mBAAmB,CAAA;AAHhC,IAAA,WAAA,GAAA;;AAKU,QAAA,IAAA,CAAA,mBAAmB,GAAG,MAAM,CAAiB,EAAE,0FAAC;;QAEhD,IAAA,CAAA,SAAS,GAAG,CAAC;;AAGrB,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE;AAuEtD,IAAA;AArEC;;;AAGG;IACH,eAAe,CACb,OAAe,EACf,IAAA,GAA6B,MAAM,EACnC,YAAA,GAAwB,KAAK,EAC7B,QAAA,GAAmB,IAAI,EAAA;QAEvB,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE;AACxC,QAAA,MAAM,YAAY,GAAiB;YACjC,EAAE;YACF,OAAO;YACP,IAAI;YACJ,QAAQ,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS;YACtC,YAAY;SACb;QAED,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,aAAa,KAAK;AACjD,YAAA,GAAG,aAAa;YAChB,YAAY;AACb,SAAA,CAAC;AAEF,QAAA,IAAI,QAAQ,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE;AACjC,YAAA,UAAU,CAAC,MAAM,IAAI,CAAC,sBAAsB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;QAC7D;AAEA,QAAA,OAAO,EAAE;IACX;;IAGA,cAAc,CAAC,cAAsB,EAAE,QAAgB,EAAA;AACrD,QAAA,MAAM,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,EA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,iBAAA,EAAA,MAAA,EAAA,CAAA,YAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAsG9B,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBA1GjC,SAAS;+BACE,kBAAkB,EAAA,UAAA,EAEhB,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,EAAE,iBAAiB,CAAC,EAAA,eAAA,EACzB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,qtBAAA,EAAA,MAAA,EAAA,CAAA,23DAAA,CAAA,EAAA;;;AEpCjD;;AAEG;;;;"}
|
|
@@ -4,6 +4,7 @@ import * as i1 from '@angular/common';
|
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
6
6
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
+
import { TranslocoService } from '@jsverse/transloco';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Shirkasoft UI Components.
|
|
@@ -55,6 +56,7 @@ class PriceInputComponent {
|
|
|
55
56
|
/** Message rendered when the field is in error state. */
|
|
56
57
|
this.errorMessage = input('', ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
57
58
|
this.destroyRef = inject(DestroyRef);
|
|
59
|
+
this.transloco = inject(TranslocoService);
|
|
58
60
|
/** Text currently shown in the input (raw while focused, formatted on blur). */
|
|
59
61
|
this.displayText = signal('', ...(ngDevMode ? [{ debugName: "displayText" }] : /* istanbul ignore next */ []));
|
|
60
62
|
/** Whether the native input currently has focus. */
|
|
@@ -63,6 +65,32 @@ class PriceInputComponent {
|
|
|
63
65
|
this.controlDisabled = signal(false, ...(ngDevMode ? [{ debugName: "controlDisabled" }] : /* istanbul ignore next */ []));
|
|
64
66
|
/** Prevents re-subscribing to the same form control. */
|
|
65
67
|
this.ctrlSubscribed = false;
|
|
68
|
+
/** Bumped on control status changes / blur so error computeds refresh. */
|
|
69
|
+
this.statusTick = signal(0, ...(ngDevMode ? [{ debugName: "statusTick" }] : /* istanbul ignore next */ []));
|
|
70
|
+
/**
|
|
71
|
+
* Whether the error state is shown: forced with `showError`, or when the
|
|
72
|
+
* bound `control` is invalid and has been touched or modified.
|
|
73
|
+
*/
|
|
74
|
+
this.hasError = computed(() => {
|
|
75
|
+
this.statusTick();
|
|
76
|
+
if (this.showError())
|
|
77
|
+
return true;
|
|
78
|
+
const ctrl = this.control();
|
|
79
|
+
return !!ctrl && ctrl.invalid && (ctrl.touched || ctrl.dirty);
|
|
80
|
+
}, ...(ngDevMode ? [{ debugName: "hasError" }] : /* istanbul ignore next */ []));
|
|
81
|
+
/** Message shown under the field: `errorMessage` or one derived from the control errors. */
|
|
82
|
+
this.errorText = computed(() => {
|
|
83
|
+
this.statusTick();
|
|
84
|
+
const custom = this.errorMessage();
|
|
85
|
+
if (custom)
|
|
86
|
+
return custom;
|
|
87
|
+
const errors = this.control()?.errors;
|
|
88
|
+
if (!errors)
|
|
89
|
+
return '';
|
|
90
|
+
if (errors['required'])
|
|
91
|
+
return this.transloco.translate('validation.required');
|
|
92
|
+
return this.transloco.translate('validation.invalid');
|
|
93
|
+
}, ...(ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []));
|
|
66
94
|
/** Effective disabled state combining the input and the form binding. */
|
|
67
95
|
this.isDisabled = computed(() => this.disabled() || this.controlDisabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
|
|
68
96
|
/** Callbacks used by the ControlValueAccessor contract. */
|
|
@@ -82,6 +110,11 @@ class PriceInputComponent {
|
|
|
82
110
|
});
|
|
83
111
|
ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
84
112
|
this.controlDisabled.set(ctrl.disabled);
|
|
113
|
+
this.statusTick.update((v) => v + 1);
|
|
114
|
+
});
|
|
115
|
+
// Also refresh on touched/pristine changes (e.g. markAllAsTouched()).
|
|
116
|
+
ctrl.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
117
|
+
this.statusTick.update((v) => v + 1);
|
|
85
118
|
});
|
|
86
119
|
});
|
|
87
120
|
// Reflect the effective value into the display (unless the user is typing).
|
|
@@ -120,6 +153,8 @@ class PriceInputComponent {
|
|
|
120
153
|
v = this.roundTo(v);
|
|
121
154
|
this.setValue(v);
|
|
122
155
|
this.displayText.set(this.formatNumber(v));
|
|
156
|
+
this.control()?.markAsTouched();
|
|
157
|
+
this.statusTick.update((n) => n + 1);
|
|
123
158
|
}
|
|
124
159
|
/** Blocks characters that would break the numeric format. */
|
|
125
160
|
onKeydown(event) {
|
|
@@ -222,7 +257,7 @@ class PriceInputComponent {
|
|
|
222
257
|
useExisting: forwardRef(() => PriceInputComponent),
|
|
223
258
|
multi: true,
|
|
224
259
|
},
|
|
225
|
-
], ngImport: i0, template: "<div>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)] 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]=\"
|
|
260
|
+
], ngImport: i0, template: "<div>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)] 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 dark:[color:var(--shk-surface-700)] _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] 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() ? '%' : currency() }}\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", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
226
261
|
}
|
|
227
262
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: PriceInputComponent, decorators: [{
|
|
228
263
|
type: Component,
|
|
@@ -232,7 +267,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImpo
|
|
|
232
267
|
useExisting: forwardRef(() => PriceInputComponent),
|
|
233
268
|
multi: true,
|
|
234
269
|
},
|
|
235
|
-
], template: "<div>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)] 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]=\"
|
|
270
|
+
], template: "<div>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)] 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 dark:[color:var(--shk-surface-700)] _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] 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() ? '%' : currency() }}\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" }]
|
|
236
271
|
}], ctorParameters: () => [], propDecorators: { control: [{ type: i0.Input, args: [{ isSignal: true, alias: "control", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], isPercentage: [{ type: i0.Input, args: [{ isSignal: true, alias: "isPercentage", required: false }] }, { type: i0.Output, args: ["isPercentageChange"] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], decimals: [{ type: i0.Input, args: [{ isSignal: true, alias: "decimals", required: false }] }], currency: [{ type: i0.Input, args: [{ isSignal: true, alias: "currency", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], preventNegative: [{ type: i0.Input, args: [{ isSignal: true, alias: "preventNegative", required: false }] }], showError: [{ type: i0.Input, args: [{ isSignal: true, alias: "showError", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }] } });
|
|
237
272
|
|
|
238
273
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-price-input.mjs","sources":["../../../projects/ui-components/price-input/price-input.component.ts","../../../projects/ui-components/price-input/price-input.component.html","../../../projects/ui-components/price-input/shirkasoft-ui-components-price-input.ts"],"sourcesContent":["import {\n Component,\n model,\n input,\n signal,\n computed,\n effect,\n inject,\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';\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 standalone: true,\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 {\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>(0);\n /** Maximum allowed value (clamped on blur). */\n max = input<number>(Infinity);\n /** Maximum number of decimal places (0 = integer). */\n decimals = input<number>(2);\n /** Symbol shown in the mode toggle button when not a percentage. */\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\n private destroyRef = inject(DestroyRef);\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 /** 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 });\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 /** Selects the whole value on focus so the user can type over it. */\n onFocus(event: FocusEvent): void {\n this.focused.set(true);\n (event.target as HTMLInputElement).select();\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\n let v = parseFloat(this.displayText().replace(/,/g, ''));\n if (isNaN(v)) v = 0;\n\n const min = this.min();\n const max = this.max();\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 }\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) {\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) cleaned = cleaned.replace(/-/g, '');\n cleaned = cleaned.replace(/,/g, '.');\n\n const dot = cleaned.indexOf('.');\n if (dot >= 0) {\n const dec = Math.max(0, this.decimals());\n const intPart = cleaned.slice(0, dot);\n const decPart = cleaned.slice(dot + 1, dot + 1 + dec);\n cleaned = intPart + '.' + decPart;\n }\n\n input.value = cleaned;\n const newPos = Math.min(pos, cleaned.length);\n input.setSelectionRange(newPos, newPos);\n this.displayText.set(cleaned);\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, Math.max(0, this.decimals()));\n return Math.round(v * factor) / factor;\n }\n\n /** Formats a number with thousands separator and up to `decimals` places. */\n private formatNumber(v: number): string {\n if (v == null || isNaN(v)) return '0';\n const dec = Math.max(0, this.decimals());\n return v.toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: dec });\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 dark:[color:var(--shk-surface-600)] 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]=\"showError() || null\"\n [disabled]=\"isDisabled()\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n (input)=\"onInput($event)\"\n class=\"block w-full px-3 py-2 _shk-text-surface-700 dark:[color:var(--shk-surface-700)] _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] 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': showError(),\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)]': !showError()\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() ? '%' : currency() }}\n </button>\n </div>\n @if (showError()) {\n <div class=\"text-xs _shk-text-red-500 mt-1\">\n {{ errorMessage() }}\n </div>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAqBA;;;;AAIG;AAEH;;;;;;;;;AASG;MAeU,mBAAmB,CAAA;AAoD9B,IAAA,WAAA,GAAA;;AAlDA,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAyC,SAAS,8EAAC;;AAElE,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAgB,CAAC,4EAAC;;AAE/B,QAAA,IAAA,CAAA,YAAY,GAAG,KAAK,CAAU,KAAK,mFAAC;;AAEpC,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAS,EAAE,4EAAC;;AAEzB,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAS,EAAE,8EAAC;;AAE3B,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,+EAAC;;AAEhC,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,+EAAC;;AAEhC,QAAA,IAAA,CAAA,GAAG,GAAG,KAAK,CAAS,CAAC,0EAAC;;AAEtB,QAAA,IAAA,CAAA,GAAG,GAAG,KAAK,CAAS,QAAQ,0EAAC;;AAE7B,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAS,CAAC,+EAAC;;AAE3B,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAS,GAAG,+EAAC;;AAE7B,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAS,EAAE,kFAAC;;AAE/B,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAS,EAAE,gFAAC;;AAE7B,QAAA,IAA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,MAAA,EAAA,CAAA,OAAA,EAAA,SAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAE,mBAAmB,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAWhC,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAd/B,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,iBAAiB,EAAA,UAAA,EACf,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,EAAE,mBAAmB,CAAC,EAAA,eAAA,EAE3B,uBAAuB,CAAC,MAAM,EAAA,SAAA,EACpC;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,yBAAyB,CAAC;AAClD,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;AACF,qBAAA,EAAA,QAAA,EAAA,k9EAAA,EAAA;;;AEjDH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-price-input.mjs","sources":["../../../projects/ui-components/price-input/price-input.component.ts","../../../projects/ui-components/price-input/price-input.component.html","../../../projects/ui-components/price-input/shirkasoft-ui-components-price-input.ts"],"sourcesContent":["import {\n Component,\n model,\n input,\n signal,\n computed,\n effect,\n inject,\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 { TranslocoService } from '@jsverse/transloco';\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 standalone: true,\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 {\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>(0);\n /** Maximum allowed value (clamped on blur). */\n max = input<number>(Infinity);\n /** Maximum number of decimal places (0 = integer). */\n decimals = input<number>(2);\n /** Symbol shown in the mode toggle button when not a percentage. */\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\n private destroyRef = inject(DestroyRef);\n private transloco = inject(TranslocoService);\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 /** Selects the whole value on focus so the user can type over it. */\n onFocus(event: FocusEvent): void {\n this.focused.set(true);\n (event.target as HTMLInputElement).select();\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\n let v = parseFloat(this.displayText().replace(/,/g, ''));\n if (isNaN(v)) v = 0;\n\n const min = this.min();\n const max = this.max();\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) {\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) cleaned = cleaned.replace(/-/g, '');\n cleaned = cleaned.replace(/,/g, '.');\n\n const dot = cleaned.indexOf('.');\n if (dot >= 0) {\n const dec = Math.max(0, this.decimals());\n const intPart = cleaned.slice(0, dot);\n const decPart = cleaned.slice(dot + 1, dot + 1 + dec);\n cleaned = intPart + '.' + decPart;\n }\n\n input.value = cleaned;\n const newPos = Math.min(pos, cleaned.length);\n input.setSelectionRange(newPos, newPos);\n this.displayText.set(cleaned);\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, Math.max(0, this.decimals()));\n return Math.round(v * factor) / factor;\n }\n\n /** Formats a number with thousands separator and up to `decimals` places. */\n private formatNumber(v: number): string {\n if (v == null || isNaN(v)) return '0';\n const dec = Math.max(0, this.decimals());\n return v.toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: dec });\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 dark:[color:var(--shk-surface-600)] 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 dark:[color:var(--shk-surface-700)] _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] 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() ? '%' : currency() }}\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAsBA;;;;AAIG;AAEH;;;;;;;;;AASG;MAeU,mBAAmB,CAAA;AA8E9B,IAAA,WAAA,GAAA;;AA5EA,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAyC,SAAS,8EAAC;;AAElE,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAgB,CAAC,4EAAC;;AAE/B,QAAA,IAAA,C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f,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,EAAE,mBAAmB,CAAC,EAAA,eAAA,EAE3B,uBAAuB,CAAC,MAAM,EAAA,SAAA,EACpC;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,yBAAyB,CAAC;AAClD,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;AACF,qBAAA,EAAA,QAAA,EAAA,w/EAAA,EAAA;;;AElDH;;AAEG;;;;"}
|
|
@@ -6,7 +6,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
|
6
6
|
import * as i1 from '@jsverse/transloco';
|
|
7
7
|
import { TranslocoService, TranslocoModule } from '@jsverse/transloco';
|
|
8
8
|
import { LucideChevronDown, LucideDynamicIcon } from '@lucide/angular';
|
|
9
|
-
import { getIcon } from 'shirkasoft-ui-components/utils';
|
|
9
|
+
import { getIcon, PortalDirective } from 'shirkasoft-ui-components/utils';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Shirkasoft UI Components.
|
|
@@ -294,7 +294,7 @@ class SelectComponent {
|
|
|
294
294
|
/** Closes the dropdown when the page/container scrolls, ignoring scrolls that start inside the component (its own options list). */
|
|
295
295
|
this.scrollCloseHandler = (event) => {
|
|
296
296
|
const target = event.target;
|
|
297
|
-
if (target && this.
|
|
297
|
+
if (target && this.isInsideComponent(target))
|
|
298
298
|
return;
|
|
299
299
|
if (this.isOpen()) {
|
|
300
300
|
this.isOpen.set(false);
|
|
@@ -582,9 +582,18 @@ class SelectComponent {
|
|
|
582
582
|
this.currentPage.set(current - 1);
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
|
+
/** Whether a node belongs to the component or to its (portaled) dropdown panel. */
|
|
586
|
+
isInsideComponent(target) {
|
|
587
|
+
if (!target)
|
|
588
|
+
return false;
|
|
589
|
+
if (this.elementRef.nativeElement.contains(target))
|
|
590
|
+
return true;
|
|
591
|
+
const panel = this.dropdownContainer()?.nativeElement;
|
|
592
|
+
return !!panel && panel.contains(target);
|
|
593
|
+
}
|
|
585
594
|
/** Closes the dropdown when a click happens outside the component. */
|
|
586
595
|
onClickOutside(event) {
|
|
587
|
-
const clickedInside = this.
|
|
596
|
+
const clickedInside = this.isInsideComponent(event.target);
|
|
588
597
|
if (!clickedInside && this.isOpen()) {
|
|
589
598
|
this.markAsTouchedAndUpdate();
|
|
590
599
|
this.isOpen.set(false);
|
|
@@ -753,11 +762,12 @@ class SelectComponent {
|
|
|
753
762
|
useExisting: forwardRef(() => SelectComponent),
|
|
754
763
|
multi: true,
|
|
755
764
|
},
|
|
756
|
-
], viewQueries: [{ propertyName: "filterInput", first: true, predicate: ["filterInput"], descendants: true, isSignal: true }, { propertyName: "selectContainer", first: true, predicate: ["selectContainer"], descendants: true, isSignal: true }, { propertyName: "selectTrigger", first: true, predicate: ["selectTrigger"], descendants: true, isSignal: true }, { propertyName: "dropdownContainer", first: true, predicate: ["dropdownContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n #selectContainer\n class=\"relative w-full font-sans outline-none\"\n>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)] mb-1\">\n {{ label() }}\n </div>\n }\n\n <div\n #selectTrigger\n class=\"flex justify-between items-center w-full px-3 py-2 border _shk-border rounded-lg _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] transition-colors duration-150 cursor-pointer min-h-[2.5rem] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus-within:outline-none focus-within:[background-color:var(--shk-surface-50)] dark:focus-within:[background-color:var(--shk-surface-100)] focus-within:ring-1 focus-within:[--tw-ring-color:var(--shk-primary-500)] focus-within:[border-color:var(--shk-primary-500)] focus:outline-none focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] focus:[border-color:var(--shk-primary-500)] sm:text-sm\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (click)=\"toggleDropdown()\"\n [class.open]=\"isOpen()\"\n [class.disabled-select]=\"isDisabled()\"\n [class._shk-border-red]=\"shouldShowError()\"\n >\n <div class=\"selected-value truncate\">\n @if (isSearchable() && isOpen()) {\n <input\n #filterInput\n type=\"text\"\n class=\"w-full bg-transparent border-0 outline-none p-0 _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\"\n placeholder=\"Buscar...\"\n [value]=\"searchTerm()\"\n (input)=\"onInputChange($event)\"\n (keydown)=\"handleKeyDown($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <span\n [class._shk-text-surface-400]=\"!hasSelectedValues()\"\n [class._shk-text-surface-800]=\"hasSelectedValues()\"\n >\n {{ displayValue() }}\n </span>\n }\n </div>\n <div\n class=\"text-xs transition-transform duration-200 shrink-0 ml-2\"\n [class.rotate-180]=\"isOpen()\"\n >\n <svg\n [lucideIcon]=\"getIcon('chevron-down')\"\n class=\"w-4 h-4 _shk-text-surface-400 dark:[color:var(--shk-surface-400)]\"\n ></svg>\n </div>\n </div>\n\n @if (isOpen()) {\n <div\n #dropdownContainer\n (keydown)=\"onKeydown($event)\"\n class=\"fixed _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-lg max-h-[240px] overflow-y-auto z-[9999] shadow-lg _shk-scrollbar\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n [style.width]=\"dropdownPosition().width + 'px'\"\n >\n @if (showCustomOption()) {\n <div\n class=\"flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm\"\n (click)=\"onCustomOptionClick()\"\n >\n <span class=\"font-semibold _shk-text-primary\">Crear nuevo:</span>\n <span class=\"_shk-text-surface-700 dark:[color:var(--shk-surface-700)] ml-1\">{{ searchTerm() }}</span>\n </div>\n }\n\n @for (option of regularOptions(); track trackByFn($index, option); let i = $index) {\n <div\n class=\"flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\"\n [class.opacity-50]=\"isOptionDisabled(option)\"\n [class.select-option-active]=\"focusedIndex() === i\"\n [class._shk-text-surface-400]=\"option.value === null\"\n (click)=\"!isOptionDisabled(option) && onOptionClick(option)\"\n >\n @if (multiple()) {\n <input\n type=\"checkbox\"\n [checked]=\"isSelected(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"!isOptionDisabled(option) && toggleOption(option)\"\n class=\"flex-shrink-0 [accent-color:var(--shk-primary-600)]\"\n />\n {{ option.label }}\n } @else {\n {{ option.label }}\n }\n </div>\n }\n\n <div class=\"px-3 py-2 text-center\">\n @if (isLoading() && regularOptions().length === 0) {\n <div class=\"flex items-center justify-center gap-2 text-sm _shk-text-surface-500\">\n <svg class=\"spinner\" viewBox=\"0 0 50 50\">\n <circle\n class=\"path\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n </svg>\n Cargando m\u00E1s resultados...\n </div>\n }\n\n @if (!isLoading() && isAllDataLoaded() && regularOptions().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n No se encontraron coincidencias\n </div>\n }\n\n @if (options().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n {{ emptyMessageKey() | transloco }}\n </div>\n }\n </div>\n\n @if (usePagination() && totalPages() > 1) {\n <div class=\"flex justify-between items-center px-3 py-2 border-t _shk-border\">\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\"\n [disabled]=\"currentPage() === 1\"\n (click)=\"$event.stopPropagation(); previousPage()\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span class=\"text-sm _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\">\n {{ currentPage() }} de {{ totalPages() }}\n </span>\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\"\n [disabled]=\"currentPage() === totalPages()\"\n (click)=\"$event.stopPropagation(); nextPage()\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n </div>\n }\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>", styles: [".select-option-active{background-color:var(--shk-primary-50);outline:2px solid var(--shk-primary-500);outline-offset:-2px;color:var(--shk-primary-700)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: TranslocoModule }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }, { kind: "pipe", type: i1.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
765
|
+
], viewQueries: [{ propertyName: "filterInput", first: true, predicate: ["filterInput"], descendants: true, isSignal: true }, { propertyName: "selectContainer", first: true, predicate: ["selectContainer"], descendants: true, isSignal: true }, { propertyName: "selectTrigger", first: true, predicate: ["selectTrigger"], descendants: true, isSignal: true }, { propertyName: "dropdownContainer", first: true, predicate: ["dropdownContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n #selectContainer\n class=\"relative w-full font-sans outline-none\"\n>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)] mb-1\">\n {{ label() }}\n </div>\n }\n\n <div\n #selectTrigger\n class=\"shk-control flex justify-between items-center w-full px-3 py-2 border _shk-border rounded-lg _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] transition-colors duration-150 cursor-pointer min-h-[2.5rem] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus-within:outline-none focus-within:[background-color:var(--shk-surface-50)] dark:focus-within:[background-color:var(--shk-surface-100)] focus-within:ring-1 focus-within:[--tw-ring-color:var(--shk-primary-500)] focus-within:[border-color:var(--shk-primary-500)] focus:outline-none focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] focus:[border-color:var(--shk-primary-500)] sm:text-sm\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (click)=\"toggleDropdown()\"\n [class.open]=\"isOpen()\"\n [class.disabled-select]=\"isDisabled()\"\n [class.shk-control-disabled]=\"isDisabled()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class._shk-border-red]=\"shouldShowError()\"\n >\n <div class=\"selected-value truncate\">\n @if (isSearchable() && isOpen()) {\n <input\n #filterInput\n type=\"text\"\n class=\"w-full bg-transparent border-0 outline-none p-0 _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\"\n placeholder=\"Buscar...\"\n [value]=\"searchTerm()\"\n (input)=\"onInputChange($event)\"\n (keydown)=\"handleKeyDown($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <span\n [class._shk-text-surface-400]=\"!hasSelectedValues()\"\n [class._shk-text-surface-800]=\"hasSelectedValues()\"\n >\n {{ displayValue() }}\n </span>\n }\n </div>\n <div\n class=\"text-xs transition-transform duration-200 shrink-0 ml-2\"\n [class.rotate-180]=\"isOpen()\"\n >\n <svg\n [lucideIcon]=\"getIcon('chevron-down')\"\n class=\"w-4 h-4 _shk-text-surface-400 dark:[color:var(--shk-surface-400)]\"\n ></svg>\n </div>\n </div>\n\n @if (isOpen()) {\n <div\n #dropdownContainer\n shkPortal\n (keydown)=\"onKeydown($event)\"\n class=\"shk-select-panel fixed _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-lg max-h-[240px] overflow-y-auto z-[9999] shadow-lg _shk-scrollbar\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n [style.width]=\"dropdownPosition().width + 'px'\"\n >\n @if (showCustomOption()) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm\"\n (click)=\"onCustomOptionClick()\"\n >\n <span class=\"font-semibold _shk-text-primary\">Crear nuevo:</span>\n <span class=\"_shk-text-surface-700 dark:[color:var(--shk-surface-700)] ml-1\">{{ searchTerm() }}</span>\n </div>\n }\n\n @for (option of regularOptions(); track trackByFn($index, option); let i = $index) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\"\n [class.shk-select-option-disabled]=\"isOptionDisabled(option)\"\n [class.shk-select-option-selected]=\"!multiple() && option.value !== null && isSelected(option)\"\n [class.opacity-50]=\"isOptionDisabled(option)\"\n [class.select-option-active]=\"focusedIndex() === i\"\n [class._shk-text-surface-400]=\"option.value === null\"\n (click)=\"!isOptionDisabled(option) && onOptionClick(option)\"\n >\n @if (multiple()) {\n <input\n type=\"checkbox\"\n [checked]=\"isSelected(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"!isOptionDisabled(option) && toggleOption(option)\"\n class=\"flex-shrink-0 [accent-color:var(--shk-primary-600)]\"\n />\n {{ option.label }}\n } @else {\n <span class=\"shk-select-option-label flex-1 min-w-0\">{{ option.label }}</span>\n @if (option.value !== null && isSelected(option)) {\n <svg [lucideIcon]=\"getIcon('check')\" class=\"shk-select-check w-4 h-4 shrink-0\"></svg>\n }\n }\n </div>\n }\n\n <div class=\"px-3 py-2 text-center\">\n @if (isLoading() && regularOptions().length === 0) {\n <div class=\"flex items-center justify-center gap-2 text-sm _shk-text-surface-500\">\n <svg class=\"spinner\" viewBox=\"0 0 50 50\">\n <circle\n class=\"path\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n </svg>\n Cargando m\u00E1s resultados...\n </div>\n }\n\n @if (!isLoading() && isAllDataLoaded() && regularOptions().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n No se encontraron coincidencias\n </div>\n }\n\n @if (options().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n {{ emptyMessageKey() | transloco }}\n </div>\n }\n </div>\n\n @if (usePagination() && totalPages() > 1) {\n <div class=\"flex justify-between items-center px-3 py-2 border-t _shk-border\">\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\"\n [disabled]=\"currentPage() === 1\"\n (click)=\"$event.stopPropagation(); previousPage()\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span class=\"text-sm _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\">\n {{ currentPage() }} de {{ totalPages() }}\n </span>\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\"\n [disabled]=\"currentPage() === totalPages()\"\n (click)=\"$event.stopPropagation(); nextPage()\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n </div>\n }\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>", styles: [".shk-select-panel{padding:.25rem;border-radius:.625rem;box-shadow:0 10px 24px -6px #0000001f,0 4px 8px -4px #0000000f;animation:shk-select-in .12s ease-out}@keyframes shk-select-in{0%{opacity:0;transform:translateY(-4px) scale(.98)}}.shk-select-option{border-radius:.375rem;transition:background-color .1s ease}.shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-select-option:hover:not(.shk-select-option-disabled),.dark .shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-200)}.shk-select-option-label{overflow-wrap:anywhere}.shk-select-option-disabled{cursor:not-allowed}.shk-select-option-selected{color:var(--shk-primary-700);font-weight:500}:host-context(.dark) .shk-select-option-selected,.dark .shk-select-option-selected{color:var(--shk-primary-400)}.shk-select-check{color:var(--shk-primary-600)}:host-context(.dark) .shk-select-check,.dark .shk-select-check{color:var(--shk-primary-400)}.select-option-active{background-color:var(--shk-primary-50);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--shk-primary-500) 35%,transparent);color:var(--shk-primary-700)}:host-context(.dark) .select-option-active,.dark .select-option-active{background-color:color-mix(in srgb,var(--shk-primary-900) 40%,transparent);color:var(--shk-primary-300)}\n"], dependencies: [{ kind: "directive", type: PortalDirective, selector: "[shkPortal]" }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: TranslocoModule }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }, { kind: "pipe", type: i1.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
757
766
|
}
|
|
758
767
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: SelectComponent, decorators: [{
|
|
759
768
|
type: Component,
|
|
760
769
|
args: [{ selector: 'shk-select', standalone: true, imports: [
|
|
770
|
+
PortalDirective,
|
|
761
771
|
CommonModule,
|
|
762
772
|
ReactiveFormsModule,
|
|
763
773
|
FormsModule,
|
|
@@ -769,7 +779,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImpo
|
|
|
769
779
|
useExisting: forwardRef(() => SelectComponent),
|
|
770
780
|
multi: true,
|
|
771
781
|
},
|
|
772
|
-
], template: "<div\n #selectContainer\n class=\"relative w-full font-sans outline-none\"\n>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)] mb-1\">\n {{ label() }}\n </div>\n }\n\n <div\n #selectTrigger\n class=\"flex justify-between items-center w-full px-3 py-2 border _shk-border rounded-lg _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] transition-colors duration-150 cursor-pointer min-h-[2.5rem] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus-within:outline-none focus-within:[background-color:var(--shk-surface-50)] dark:focus-within:[background-color:var(--shk-surface-100)] focus-within:ring-1 focus-within:[--tw-ring-color:var(--shk-primary-500)] focus-within:[border-color:var(--shk-primary-500)] focus:outline-none focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] focus:[border-color:var(--shk-primary-500)] sm:text-sm\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (click)=\"toggleDropdown()\"\n [class.open]=\"isOpen()\"\n [class.disabled-select]=\"isDisabled()\"\n [class._shk-border-red]=\"shouldShowError()\"\n >\n <div class=\"selected-value truncate\">\n @if (isSearchable() && isOpen()) {\n <input\n #filterInput\n type=\"text\"\n class=\"w-full bg-transparent border-0 outline-none p-0 _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\"\n placeholder=\"Buscar...\"\n [value]=\"searchTerm()\"\n (input)=\"onInputChange($event)\"\n (keydown)=\"handleKeyDown($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <span\n [class._shk-text-surface-400]=\"!hasSelectedValues()\"\n [class._shk-text-surface-800]=\"hasSelectedValues()\"\n >\n {{ displayValue() }}\n </span>\n }\n </div>\n <div\n class=\"text-xs transition-transform duration-200 shrink-0 ml-2\"\n [class.rotate-180]=\"isOpen()\"\n >\n <svg\n [lucideIcon]=\"getIcon('chevron-down')\"\n class=\"w-4 h-4 _shk-text-surface-400 dark:[color:var(--shk-surface-400)]\"\n ></svg>\n </div>\n </div>\n\n @if (isOpen()) {\n <div\n #dropdownContainer\n (keydown)=\"onKeydown($event)\"\n class=\"fixed _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-lg max-h-[240px] overflow-y-auto z-[9999] shadow-lg _shk-scrollbar\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n [style.width]=\"dropdownPosition().width + 'px'\"\n >\n @if (showCustomOption()) {\n <div\n class=\"flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm\"\n (click)=\"onCustomOptionClick()\"\n >\n <span class=\"font-semibold _shk-text-primary\">Crear nuevo:</span>\n <span class=\"_shk-text-surface-700 dark:[color:var(--shk-surface-700)] ml-1\">{{ searchTerm() }}</span>\n </div>\n }\n\n @for (option of regularOptions(); track trackByFn($index, option); let i = $index) {\n <div\n class=\"flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\"\n [class.opacity-50]=\"isOptionDisabled(option)\"\n [class.select-option-active]=\"focusedIndex() === i\"\n [class._shk-text-surface-400]=\"option.value === null\"\n (click)=\"!isOptionDisabled(option) && onOptionClick(option)\"\n >\n @if (multiple()) {\n <input\n type=\"checkbox\"\n [checked]=\"isSelected(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"!isOptionDisabled(option) && toggleOption(option)\"\n class=\"flex-shrink-0 [accent-color:var(--shk-primary-600)]\"\n />\n {{ option.label }}\n } @else {\n {{ option.label }}\n }\n </div>\n }\n\n <div class=\"px-3 py-2 text-center\">\n @if (isLoading() && regularOptions().length === 0) {\n <div class=\"flex items-center justify-center gap-2 text-sm _shk-text-surface-500\">\n <svg class=\"spinner\" viewBox=\"0 0 50 50\">\n <circle\n class=\"path\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n </svg>\n Cargando m\u00E1s resultados...\n </div>\n }\n\n @if (!isLoading() && isAllDataLoaded() && regularOptions().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n No se encontraron coincidencias\n </div>\n }\n\n @if (options().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n {{ emptyMessageKey() | transloco }}\n </div>\n }\n </div>\n\n @if (usePagination() && totalPages() > 1) {\n <div class=\"flex justify-between items-center px-3 py-2 border-t _shk-border\">\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\"\n [disabled]=\"currentPage() === 1\"\n (click)=\"$event.stopPropagation(); previousPage()\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span class=\"text-sm _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\">\n {{ currentPage() }} de {{ totalPages() }}\n </span>\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\"\n [disabled]=\"currentPage() === totalPages()\"\n (click)=\"$event.stopPropagation(); nextPage()\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n </div>\n }\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>", styles: [".select-option-active{background-color:var(--shk-primary-50);
|
|
782
|
+
], template: "<div\n #selectContainer\n class=\"relative w-full font-sans outline-none\"\n>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)] mb-1\">\n {{ label() }}\n </div>\n }\n\n <div\n #selectTrigger\n class=\"shk-control flex justify-between items-center w-full px-3 py-2 border _shk-border rounded-lg _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] transition-colors duration-150 cursor-pointer min-h-[2.5rem] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus-within:outline-none focus-within:[background-color:var(--shk-surface-50)] dark:focus-within:[background-color:var(--shk-surface-100)] focus-within:ring-1 focus-within:[--tw-ring-color:var(--shk-primary-500)] focus-within:[border-color:var(--shk-primary-500)] focus:outline-none focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] focus:[border-color:var(--shk-primary-500)] sm:text-sm\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (click)=\"toggleDropdown()\"\n [class.open]=\"isOpen()\"\n [class.disabled-select]=\"isDisabled()\"\n [class.shk-control-disabled]=\"isDisabled()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class._shk-border-red]=\"shouldShowError()\"\n >\n <div class=\"selected-value truncate\">\n @if (isSearchable() && isOpen()) {\n <input\n #filterInput\n type=\"text\"\n class=\"w-full bg-transparent border-0 outline-none p-0 _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\"\n placeholder=\"Buscar...\"\n [value]=\"searchTerm()\"\n (input)=\"onInputChange($event)\"\n (keydown)=\"handleKeyDown($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <span\n [class._shk-text-surface-400]=\"!hasSelectedValues()\"\n [class._shk-text-surface-800]=\"hasSelectedValues()\"\n >\n {{ displayValue() }}\n </span>\n }\n </div>\n <div\n class=\"text-xs transition-transform duration-200 shrink-0 ml-2\"\n [class.rotate-180]=\"isOpen()\"\n >\n <svg\n [lucideIcon]=\"getIcon('chevron-down')\"\n class=\"w-4 h-4 _shk-text-surface-400 dark:[color:var(--shk-surface-400)]\"\n ></svg>\n </div>\n </div>\n\n @if (isOpen()) {\n <div\n #dropdownContainer\n shkPortal\n (keydown)=\"onKeydown($event)\"\n class=\"shk-select-panel fixed _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-lg max-h-[240px] overflow-y-auto z-[9999] shadow-lg _shk-scrollbar\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n [style.width]=\"dropdownPosition().width + 'px'\"\n >\n @if (showCustomOption()) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm\"\n (click)=\"onCustomOptionClick()\"\n >\n <span class=\"font-semibold _shk-text-primary\">Crear nuevo:</span>\n <span class=\"_shk-text-surface-700 dark:[color:var(--shk-surface-700)] ml-1\">{{ searchTerm() }}</span>\n </div>\n }\n\n @for (option of regularOptions(); track trackByFn($index, option); let i = $index) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\"\n [class.shk-select-option-disabled]=\"isOptionDisabled(option)\"\n [class.shk-select-option-selected]=\"!multiple() && option.value !== null && isSelected(option)\"\n [class.opacity-50]=\"isOptionDisabled(option)\"\n [class.select-option-active]=\"focusedIndex() === i\"\n [class._shk-text-surface-400]=\"option.value === null\"\n (click)=\"!isOptionDisabled(option) && onOptionClick(option)\"\n >\n @if (multiple()) {\n <input\n type=\"checkbox\"\n [checked]=\"isSelected(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"!isOptionDisabled(option) && toggleOption(option)\"\n class=\"flex-shrink-0 [accent-color:var(--shk-primary-600)]\"\n />\n {{ option.label }}\n } @else {\n <span class=\"shk-select-option-label flex-1 min-w-0\">{{ option.label }}</span>\n @if (option.value !== null && isSelected(option)) {\n <svg [lucideIcon]=\"getIcon('check')\" class=\"shk-select-check w-4 h-4 shrink-0\"></svg>\n }\n }\n </div>\n }\n\n <div class=\"px-3 py-2 text-center\">\n @if (isLoading() && regularOptions().length === 0) {\n <div class=\"flex items-center justify-center gap-2 text-sm _shk-text-surface-500\">\n <svg class=\"spinner\" viewBox=\"0 0 50 50\">\n <circle\n class=\"path\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n </svg>\n Cargando m\u00E1s resultados...\n </div>\n }\n\n @if (!isLoading() && isAllDataLoaded() && regularOptions().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n No se encontraron coincidencias\n </div>\n }\n\n @if (options().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n {{ emptyMessageKey() | transloco }}\n </div>\n }\n </div>\n\n @if (usePagination() && totalPages() > 1) {\n <div class=\"flex justify-between items-center px-3 py-2 border-t _shk-border\">\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\"\n [disabled]=\"currentPage() === 1\"\n (click)=\"$event.stopPropagation(); previousPage()\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span class=\"text-sm _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\">\n {{ currentPage() }} de {{ totalPages() }}\n </span>\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600 dark:[color:var(--shk-surface-600)]\"\n [disabled]=\"currentPage() === totalPages()\"\n (click)=\"$event.stopPropagation(); nextPage()\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n </div>\n }\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>", styles: [".shk-select-panel{padding:.25rem;border-radius:.625rem;box-shadow:0 10px 24px -6px #0000001f,0 4px 8px -4px #0000000f;animation:shk-select-in .12s ease-out}@keyframes shk-select-in{0%{opacity:0;transform:translateY(-4px) scale(.98)}}.shk-select-option{border-radius:.375rem;transition:background-color .1s ease}.shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-select-option:hover:not(.shk-select-option-disabled),.dark .shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-200)}.shk-select-option-label{overflow-wrap:anywhere}.shk-select-option-disabled{cursor:not-allowed}.shk-select-option-selected{color:var(--shk-primary-700);font-weight:500}:host-context(.dark) .shk-select-option-selected,.dark .shk-select-option-selected{color:var(--shk-primary-400)}.shk-select-check{color:var(--shk-primary-600)}:host-context(.dark) .shk-select-check,.dark .shk-select-check{color:var(--shk-primary-400)}.select-option-active{background-color:var(--shk-primary-50);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--shk-primary-500) 35%,transparent);color:var(--shk-primary-700)}:host-context(.dark) .select-option-active,.dark .select-option-active{background-color:color-mix(in srgb,var(--shk-primary-900) 40%,transparent);color:var(--shk-primary-300)}\n"] }]
|
|
773
783
|
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], validCombinations: [{ type: i0.Input, args: [{ isSignal: true, alias: "validCombinations", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], isLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "isLoading", required: false }] }], isAllDataLoaded: [{ type: i0.Input, args: [{ isSignal: true, alias: "isAllDataLoaded", required: false }] }], allowCustomEntries: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowCustomEntries", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }], isSearchable: [{ type: i0.Input, args: [{ isSignal: true, alias: "isSearchable", required: false }] }], itemsPerPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsPerPage", required: false }] }], control: [{ type: i0.Input, args: [{ isSignal: true, alias: "control", required: false }] }], usePagination: [{ type: i0.Input, args: [{ isSignal: true, alias: "usePagination", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], errorMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessages", required: false }] }], preserveSearchOnLoad: [{ type: i0.Input, args: [{ isSignal: true, alias: "preserveSearchOnLoad", required: false }] }], emptyMessageKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessageKey", required: false }] }], dropdownUpward: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownUpward", required: false }] }], showEmptyOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "showEmptyOption", required: false }] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], search: [{ type: i0.Output, args: ["search"] }], filterInput: [{ type: i0.ViewChild, args: ['filterInput', { isSignal: true }] }], selectContainer: [{ type: i0.ViewChild, args: ['selectContainer', { isSignal: true }] }], selectTrigger: [{ type: i0.ViewChild, args: ['selectTrigger', { isSignal: true }] }], dropdownContainer: [{ type: i0.ViewChild, args: ['dropdownContainer', { isSignal: true }] }], onClickOutside: [{
|
|
774
784
|
type: HostListener,
|
|
775
785
|
args: ['document:mousedown', ['$event']]
|