shirkasoft-ui-components 1.13.18 → 2.0.0

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.
Files changed (98) hide show
  1. package/README.md +415 -42
  2. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs +189 -100
  3. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs.map +1 -1
  4. package/fesm2022/shirkasoft-ui-components-button.mjs +367 -73
  5. package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
  6. package/fesm2022/shirkasoft-ui-components-chart.mjs +206 -142
  7. package/fesm2022/shirkasoft-ui-components-chart.mjs.map +1 -1
  8. package/fesm2022/shirkasoft-ui-components-config.mjs +976 -0
  9. package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -0
  10. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +307 -142
  11. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
  12. package/fesm2022/shirkasoft-ui-components-date-picker.mjs +1624 -1400
  13. package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
  14. package/fesm2022/shirkasoft-ui-components-fieldset.mjs +347 -92
  15. package/fesm2022/shirkasoft-ui-components-fieldset.mjs.map +1 -1
  16. package/fesm2022/shirkasoft-ui-components-file-upload.mjs +484 -293
  17. package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
  18. package/fesm2022/shirkasoft-ui-components-icons.mjs +1141 -0
  19. package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -0
  20. package/fesm2022/shirkasoft-ui-components-knob.mjs +395 -180
  21. package/fesm2022/shirkasoft-ui-components-knob.mjs.map +1 -1
  22. package/fesm2022/shirkasoft-ui-components-loading.mjs +505 -128
  23. package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
  24. package/fesm2022/shirkasoft-ui-components-modal.mjs +311 -303
  25. package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
  26. package/fesm2022/shirkasoft-ui-components-notification.mjs +188 -142
  27. package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
  28. package/fesm2022/shirkasoft-ui-components-price-input.mjs +517 -277
  29. package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
  30. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +669 -289
  31. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
  32. package/fesm2022/shirkasoft-ui-components-select.mjs +1014 -814
  33. package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
  34. package/fesm2022/shirkasoft-ui-components-sidebar.mjs +508 -184
  35. package/fesm2022/shirkasoft-ui-components-sidebar.mjs.map +1 -1
  36. package/fesm2022/shirkasoft-ui-components-skeleton.mjs +197 -57
  37. package/fesm2022/shirkasoft-ui-components-skeleton.mjs.map +1 -1
  38. package/fesm2022/shirkasoft-ui-components-table.mjs +1918 -1676
  39. package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
  40. package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -177
  41. package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
  42. package/fesm2022/shirkasoft-ui-components-tag.mjs +177 -51
  43. package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
  44. package/fesm2022/shirkasoft-ui-components-text-field.mjs +687 -369
  45. package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
  46. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +466 -0
  47. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -0
  48. package/fesm2022/shirkasoft-ui-components-theme.mjs +147 -0
  49. package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -0
  50. package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -215
  51. package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
  52. package/fesm2022/shirkasoft-ui-components-toggle.mjs +205 -128
  53. package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
  54. package/fesm2022/shirkasoft-ui-components-tooltip.mjs +244 -180
  55. package/fesm2022/shirkasoft-ui-components-tooltip.mjs.map +1 -1
  56. package/fesm2022/shirkasoft-ui-components-utils.mjs +97 -125
  57. package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
  58. package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -166
  59. package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
  60. package/fesm2022/shirkasoft-ui-components.mjs +0 -9
  61. package/package.json +37 -7
  62. package/src/baseline.css +2472 -0
  63. package/src/theme.css +15 -543
  64. package/src/themes/ocean.css +56 -0
  65. package/src/themes/sunset.css +55 -0
  66. package/src/themes/violet.css +25 -0
  67. package/src/tokens.css +612 -0
  68. package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
  69. package/types/shirkasoft-ui-components-button.d.ts +142 -49
  70. package/types/shirkasoft-ui-components-chart.d.ts +59 -44
  71. package/types/shirkasoft-ui-components-config.d.ts +357 -0
  72. package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -65
  73. package/types/shirkasoft-ui-components-date-picker.d.ts +527 -373
  74. package/types/shirkasoft-ui-components-fieldset.d.ts +135 -59
  75. package/types/shirkasoft-ui-components-file-upload.d.ts +176 -106
  76. package/types/shirkasoft-ui-components-icons.d.ts +1430 -0
  77. package/types/shirkasoft-ui-components-knob.d.ts +151 -64
  78. package/types/shirkasoft-ui-components-loading.d.ts +155 -64
  79. package/types/shirkasoft-ui-components-modal.d.ts +134 -132
  80. package/types/shirkasoft-ui-components-notification.d.ts +63 -58
  81. package/types/shirkasoft-ui-components-price-input.d.ts +198 -85
  82. package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
  83. package/types/shirkasoft-ui-components-select.d.ts +301 -192
  84. package/types/shirkasoft-ui-components-sidebar.d.ts +198 -92
  85. package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
  86. package/types/shirkasoft-ui-components-table.d.ts +849 -649
  87. package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
  88. package/types/shirkasoft-ui-components-tag.d.ts +54 -23
  89. package/types/shirkasoft-ui-components-text-field.d.ts +231 -111
  90. package/types/shirkasoft-ui-components-theme-picker.d.ts +117 -0
  91. package/types/shirkasoft-ui-components-theme.d.ts +80 -0
  92. package/types/shirkasoft-ui-components-timeline.d.ts +326 -150
  93. package/types/shirkasoft-ui-components-toggle.d.ts +76 -45
  94. package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
  95. package/types/shirkasoft-ui-components-utils.d.ts +26 -17
  96. package/types/shirkasoft-ui-components-wizard.d.ts +236 -86
  97. package/types/shirkasoft-ui-components.d.ts +1 -2
  98. package/fesm2022/shirkasoft-ui-components.mjs.map +0 -1
@@ -1,143 +1,308 @@
1
- import * as i0 from '@angular/core';
2
- import { input, signal, output, ChangeDetectionStrategy, Component, inject, DestroyRef, ApplicationRef, EnvironmentInjector, createComponent, Injectable } from '@angular/core';
3
- import * as i1 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
5
- import { LucideTriangleAlert, LucideDynamicIcon } from '@lucide/angular';
6
- import { getIcon } from 'shirkasoft-ui-components/utils';
7
-
8
- /**
9
- * Shirkasoft UI Components.
10
- * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
11
- * Belongs to Shirkasoft.
12
- */
13
- /**
14
- * Confirmation dialog opened via `show()` which resolves a Promise<boolean>
15
- * with the user's choice.
16
- */
17
- class ConfirmDialogComponent {
18
- constructor() {
19
- this.getIcon = (name) => getIcon(name, LucideTriangleAlert);
20
- /** Title shown in the dialog header. */
21
- this.title = input('Confirmar acción', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
22
- /** Message body of the dialog. */
23
- this.message = input('¿Está seguro de realizar esta acción?', ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
24
- /** Label of the confirm button. */
25
- this.confirmLabel = input('Confirmar', ...(ngDevMode ? [{ debugName: "confirmLabel" }] : /* istanbul ignore next */ []));
26
- /** Label of the cancel button. */
27
- this.cancelLabel = input('Cancelar', ...(ngDevMode ? [{ debugName: "cancelLabel" }] : /* istanbul ignore next */ []));
28
- /** Text shown on the confirm button while `loading` is true. */
29
- this.loadingText = input('Procesando…', ...(ngDevMode ? [{ debugName: "loadingText" }] : /* istanbul ignore next */ []));
30
- /** Visual style: 'danger', 'info' or 'warning'. */
31
- this.type = input('danger', ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
32
- /** Shows a spinner and disables the confirm button. */
33
- this.loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
34
- /** Whether the cancel button is shown. */
35
- this.showCancel = input(true, ...(ngDevMode ? [{ debugName: "showCancel" }] : /* istanbul ignore next */ []));
36
- /** Controls dialog visibility. */
37
- this.visible = signal(false, ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
38
- /** Resolver of the currently pending confirmation promise. */
39
- this.resolveRef = signal(null, ...(ngDevMode ? [{ debugName: "resolveRef" }] : /* istanbul ignore next */ []));
40
- /** Emitted whenever the dialog is closed (confirm or cancel). */
41
- this.closed = output();
42
- }
43
- /** Opens the dialog and returns a promise resolving with the user choice. */
44
- show() {
45
- this.visible.set(true);
46
- return new Promise((resolve) => {
47
- this.resolveRef.set(resolve);
48
- });
49
- }
50
- /** Resolves with `true` when the user confirms. */
51
- onConfirm() {
52
- this.visible.set(false);
53
- const resolve = this.resolveRef();
54
- if (resolve) {
55
- resolve(true);
56
- this.resolveRef.set(null);
57
- }
58
- this.closed.emit();
59
- }
60
- /** Resolves with `false` when the user cancels. */
61
- onCancel() {
62
- this.visible.set(false);
63
- const resolve = this.resolveRef();
64
- if (resolve) {
65
- resolve(false);
66
- this.resolveRef.set(null);
67
- }
68
- this.closed.emit();
69
- }
70
- /** Clears the pending resolver on destroy. */
71
- ngOnDestroy() {
72
- this.resolveRef.set(null);
73
- }
74
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ConfirmDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
75
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.23", type: ConfirmDialogComponent, isStandalone: true, selector: "shk-confirm-dialog", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, confirmLabel: { classPropertyName: "confirmLabel", publicName: "confirmLabel", isSignal: true, isRequired: false, transformFunction: null }, cancelLabel: { classPropertyName: "cancelLabel", publicName: "cancelLabel", isSignal: true, isRequired: false, transformFunction: null }, loadingText: { classPropertyName: "loadingText", publicName: "loadingText", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, showCancel: { classPropertyName: "showCancel", publicName: "showCancel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed" }, ngImport: i0, template: "@if (visible()) {\n <div\n class=\"shk-dialog-backdrop fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-[9999] p-4\"\n (click)=\"onCancel()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-2xl shadow-2xl max-w-sm w-full overflow-hidden\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"p-6\">\n <div class=\"flex items-start gap-4 mb-4\">\n <div\n class=\"w-12 h-12 rounded-full flex items-center justify-center shrink-0\"\n [ngClass]=\"{\n 'bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400': type() === 'danger',\n 'bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400': type() === 'info',\n 'bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400': type() === 'warning',\n }\"\n >\n @if (type() === 'info') {\n <svg [lucideIcon]=\"getIcon('info')\" class=\"w-6 h-6\"></svg>\n } @else {\n <svg [lucideIcon]=\"getIcon('triangle-alert')\" class=\"w-6 h-6\"></svg>\n }\n </div>\n <div>\n <h3 class=\"text-lg font-bold _shk-text-surface-800 dark:[color:var(--shk-surface-800)]\">{{ title() }}</h3>\n <p class=\"_shk-text-surface-500 dark:[color:var(--shk-surface-400)] text-sm leading-relaxed mb-6\">{{ message() }}</p>\n </div>\n </div>\n <div class=\"flex gap-3\">\n @if (showCancel()) {\n <button\n type=\"button\"\n (click)=\"onCancel()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold _shk-text-surface-600 dark:[color:var(--shk-surface-600)] _shk-bg-surface-100 dark:[background-color:var(--shk-surface-200)] hover:[background-color:var(--shk-surface-200)] dark:hover:[background-color:var(--shk-surface-300)] rounded-lg transition-colors flex items-center justify-center gap-2\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n }\n <button\n type=\"button\"\n (click)=\"onConfirm()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold text-white rounded-lg shadow-md transition-all flex items-center justify-center gap-2\"\n [class.bg-red-600]=\"type() === 'danger'\"\n [class.hover:bg-red-700]=\"type() === 'danger'\"\n [class.shadow-red-500/20]=\"type() === 'danger'\"\n [class.bg-primary-600]=\"type() === 'info'\"\n [class.hover:bg-primary-700]=\"type() === 'info'\"\n [class.shadow-primary-500/20]=\"type() === 'info'\"\n [class.bg-amber-600]=\"type() === 'warning'\"\n [class.hover:bg-amber-700]=\"type() === 'warning'\"\n [class.shadow-amber-500/20]=\"type() === 'warning'\"\n >\n @if (loading()) {\n <svg [lucideIcon]=\"getIcon('loader')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else if (type() === 'danger') {\n <svg [lucideIcon]=\"getIcon('trash-2')\" class=\"w-4 h-4\"></svg>\n }\n {{ loading() ? loadingText() : confirmLabel() }}\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n", styles: [".shk-dialog-backdrop{animation:shk-dialog-fade .15s ease-out}.shk-dialog-panel{border:1px solid var(--shk-surface-200);box-shadow:0 24px 48px -12px #00000040,0 8px 16px -8px #0000001a;animation:shk-dialog-in .2s cubic-bezier(.21,1.02,.73,1)}:host-context(.dark) .shk-dialog-panel{box-shadow:0 24px 48px -12px #000000b3,0 8px 16px -8px #00000080}@keyframes shk-dialog-fade{0%{opacity:0}}@keyframes shk-dialog-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 }); }
76
- }
77
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ConfirmDialogComponent, decorators: [{
78
- type: Component,
79
- args: [{ selector: 'shk-confirm-dialog', standalone: true, imports: [CommonModule, LucideDynamicIcon], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (visible()) {\n <div\n class=\"shk-dialog-backdrop fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-[9999] p-4\"\n (click)=\"onCancel()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-2xl shadow-2xl max-w-sm w-full overflow-hidden\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"p-6\">\n <div class=\"flex items-start gap-4 mb-4\">\n <div\n class=\"w-12 h-12 rounded-full flex items-center justify-center shrink-0\"\n [ngClass]=\"{\n 'bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400': type() === 'danger',\n 'bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400': type() === 'info',\n 'bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400': type() === 'warning',\n }\"\n >\n @if (type() === 'info') {\n <svg [lucideIcon]=\"getIcon('info')\" class=\"w-6 h-6\"></svg>\n } @else {\n <svg [lucideIcon]=\"getIcon('triangle-alert')\" class=\"w-6 h-6\"></svg>\n }\n </div>\n <div>\n <h3 class=\"text-lg font-bold _shk-text-surface-800 dark:[color:var(--shk-surface-800)]\">{{ title() }}</h3>\n <p class=\"_shk-text-surface-500 dark:[color:var(--shk-surface-400)] text-sm leading-relaxed mb-6\">{{ message() }}</p>\n </div>\n </div>\n <div class=\"flex gap-3\">\n @if (showCancel()) {\n <button\n type=\"button\"\n (click)=\"onCancel()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold _shk-text-surface-600 dark:[color:var(--shk-surface-600)] _shk-bg-surface-100 dark:[background-color:var(--shk-surface-200)] hover:[background-color:var(--shk-surface-200)] dark:hover:[background-color:var(--shk-surface-300)] rounded-lg transition-colors flex items-center justify-center gap-2\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n }\n <button\n type=\"button\"\n (click)=\"onConfirm()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold text-white rounded-lg shadow-md transition-all flex items-center justify-center gap-2\"\n [class.bg-red-600]=\"type() === 'danger'\"\n [class.hover:bg-red-700]=\"type() === 'danger'\"\n [class.shadow-red-500/20]=\"type() === 'danger'\"\n [class.bg-primary-600]=\"type() === 'info'\"\n [class.hover:bg-primary-700]=\"type() === 'info'\"\n [class.shadow-primary-500/20]=\"type() === 'info'\"\n [class.bg-amber-600]=\"type() === 'warning'\"\n [class.hover:bg-amber-700]=\"type() === 'warning'\"\n [class.shadow-amber-500/20]=\"type() === 'warning'\"\n >\n @if (loading()) {\n <svg [lucideIcon]=\"getIcon('loader')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else if (type() === 'danger') {\n <svg [lucideIcon]=\"getIcon('trash-2')\" class=\"w-4 h-4\"></svg>\n }\n {{ loading() ? loadingText() : confirmLabel() }}\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n", styles: [".shk-dialog-backdrop{animation:shk-dialog-fade .15s ease-out}.shk-dialog-panel{border:1px solid var(--shk-surface-200);box-shadow:0 24px 48px -12px #00000040,0 8px 16px -8px #0000001a;animation:shk-dialog-in .2s cubic-bezier(.21,1.02,.73,1)}:host-context(.dark) .shk-dialog-panel{box-shadow:0 24px 48px -12px #000000b3,0 8px 16px -8px #00000080}@keyframes shk-dialog-fade{0%{opacity:0}}@keyframes shk-dialog-in{0%{opacity:0;transform:translateY(8px) scale(.97)}}\n"] }]
80
- }], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], confirmLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "confirmLabel", required: false }] }], cancelLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cancelLabel", required: false }] }], loadingText: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingText", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], showCancel: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCancel", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }] } });
81
-
82
- /**
83
- * Programmatically opens the confirmation dialog and resolves a Promise
84
- * with the user's decision (true = confirm, false = cancel).
85
- */
86
- class ConfirmDialogService {
87
- constructor() {
88
- /** Reference to the currently open dialog, if any. */
89
- this.dialogRef = null;
90
- this.destroyRef = inject(DestroyRef);
91
- this.appRef = inject(ApplicationRef);
92
- this.injector = inject(EnvironmentInjector);
93
- this.destroyRef.onDestroy(() => this.cleanupDialog());
94
- }
95
- /**
96
- * Opens a confirmation dialog with the given configuration and returns a
97
- * promise resolving with the user's choice.
98
- */
99
- async confirm(config) {
100
- if (this.dialogRef)
101
- this.cleanupDialog();
102
- this.dialogRef = createComponent(ConfirmDialogComponent, {
103
- environmentInjector: this.injector,
104
- });
105
- this.dialogRef.setInput('title', config.title ?? 'Confirmar acción');
106
- this.dialogRef.setInput('message', config.message);
107
- this.dialogRef.setInput('confirmLabel', config.confirmLabel ?? 'Confirmar');
108
- this.dialogRef.setInput('cancelLabel', config.cancelLabel ?? 'Cancelar');
109
- this.dialogRef.setInput('loadingText', config.loadingText ?? 'Procesando…');
110
- this.dialogRef.setInput('type', config.type ?? 'danger');
111
- this.dialogRef.setInput('showCancel', config.showCancel ?? true);
112
- this.dialogRef.setInput('loading', config.loading ?? false);
113
- document.body.appendChild(this.dialogRef.location.nativeElement);
114
- this.appRef.attachView(this.dialogRef.hostView);
115
- try {
116
- return await this.dialogRef.instance.show();
117
- }
118
- finally {
119
- this.cleanupDialog();
120
- }
121
- }
122
- /** Detaches and destroys the mounted dialog if present. */
123
- cleanupDialog() {
124
- if (this.dialogRef) {
125
- this.appRef.detachView(this.dialogRef.hostView);
126
- this.dialogRef.destroy();
127
- this.dialogRef = null;
128
- }
129
- }
130
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ConfirmDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
131
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ConfirmDialogService, providedIn: 'root' }); }
132
- }
133
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ConfirmDialogService, decorators: [{
134
- type: Injectable,
135
- args: [{ providedIn: 'root' }]
136
- }], ctorParameters: () => [] });
137
-
138
- /**
139
- * Generated bundle index. Do not edit.
140
- */
141
-
1
+ import * as i0 from "@angular/core";
2
+ import { ApplicationRef, ChangeDetectionStrategy, Component, DestroyRef, EnvironmentInjector, Injectable, createComponent, inject, input, output, signal } from "@angular/core";
3
+ import * as i1 from "@angular/common";
4
+ import { CommonModule } from "@angular/common";
5
+ import { LucideTriangleAlert, ShkIconDirective } from "shirkasoft-ui-components/icons";
6
+ import { getIcon } from "shirkasoft-ui-components/utils";
7
+ var ConfirmDialogComponent = class ConfirmDialogComponent {
8
+ constructor() {
9
+ this.getIcon = (name) => getIcon(name, LucideTriangleAlert);
10
+ this.title = input("Confirmar acción", ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
11
+ this.message = input("¿Está seguro de realizar esta acción?", ...ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []);
12
+ this.confirmLabel = input("Confirmar", ...ngDevMode ? [{ debugName: "confirmLabel" }] : /* istanbul ignore next */ []);
13
+ this.cancelLabel = input("Cancelar", ...ngDevMode ? [{ debugName: "cancelLabel" }] : /* istanbul ignore next */ []);
14
+ this.loadingText = input("Procesando…", ...ngDevMode ? [{ debugName: "loadingText" }] : /* istanbul ignore next */ []);
15
+ this.type = input("danger", ...ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []);
16
+ this.loading = input(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
17
+ this.showCancel = input(true, ...ngDevMode ? [{ debugName: "showCancel" }] : /* istanbul ignore next */ []);
18
+ this.visible = signal(false, ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
19
+ this.resolveRef = signal(null, ...ngDevMode ? [{ debugName: "resolveRef" }] : /* istanbul ignore next */ []);
20
+ this.closed = output();
21
+ }
22
+ show() {
23
+ this.visible.set(true);
24
+ return new Promise((resolve) => {
25
+ this.resolveRef.set(resolve);
26
+ });
27
+ }
28
+ onConfirm() {
29
+ this.visible.set(false);
30
+ const resolve = this.resolveRef();
31
+ if (resolve) {
32
+ resolve(true);
33
+ this.resolveRef.set(null);
34
+ }
35
+ this.closed.emit();
36
+ }
37
+ onCancel() {
38
+ this.visible.set(false);
39
+ const resolve = this.resolveRef();
40
+ if (resolve) {
41
+ resolve(false);
42
+ this.resolveRef.set(null);
43
+ }
44
+ this.closed.emit();
45
+ }
46
+ ngOnDestroy() {
47
+ this.resolveRef.set(null);
48
+ }
49
+ static {
50
+ this.ɵfac = i0.ɵɵngDeclareFactory({
51
+ minVersion: "12.0.0",
52
+ version: "22.3.2",
53
+ ngImport: i0,
54
+ type: ConfirmDialogComponent,
55
+ deps: [],
56
+ target: i0.ɵɵFactoryTarget.Component
57
+ });
58
+ }
59
+ static {
60
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
61
+ minVersion: "17.0.0",
62
+ version: "22.3.2",
63
+ type: ConfirmDialogComponent,
64
+ isStandalone: true,
65
+ selector: "shk-confirm-dialog",
66
+ inputs: {
67
+ title: {
68
+ classPropertyName: "title",
69
+ publicName: "title",
70
+ isSignal: true,
71
+ isRequired: false,
72
+ transformFunction: null
73
+ },
74
+ message: {
75
+ classPropertyName: "message",
76
+ publicName: "message",
77
+ isSignal: true,
78
+ isRequired: false,
79
+ transformFunction: null
80
+ },
81
+ confirmLabel: {
82
+ classPropertyName: "confirmLabel",
83
+ publicName: "confirmLabel",
84
+ isSignal: true,
85
+ isRequired: false,
86
+ transformFunction: null
87
+ },
88
+ cancelLabel: {
89
+ classPropertyName: "cancelLabel",
90
+ publicName: "cancelLabel",
91
+ isSignal: true,
92
+ isRequired: false,
93
+ transformFunction: null
94
+ },
95
+ loadingText: {
96
+ classPropertyName: "loadingText",
97
+ publicName: "loadingText",
98
+ isSignal: true,
99
+ isRequired: false,
100
+ transformFunction: null
101
+ },
102
+ type: {
103
+ classPropertyName: "type",
104
+ publicName: "type",
105
+ isSignal: true,
106
+ isRequired: false,
107
+ transformFunction: null
108
+ },
109
+ loading: {
110
+ classPropertyName: "loading",
111
+ publicName: "loading",
112
+ isSignal: true,
113
+ isRequired: false,
114
+ transformFunction: null
115
+ },
116
+ showCancel: {
117
+ classPropertyName: "showCancel",
118
+ publicName: "showCancel",
119
+ isSignal: true,
120
+ isRequired: false,
121
+ transformFunction: null
122
+ }
123
+ },
124
+ outputs: { closed: "closed" },
125
+ ngImport: i0,
126
+ template: "@if (visible()) {\n <div\n class=\"shk-dialog-backdrop fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-[9999] p-4\"\n (click)=\"onCancel()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-2xl shadow-2xl max-w-sm w-full overflow-hidden\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"p-6\">\n <div class=\"flex items-start gap-4 mb-4\">\n <div\n class=\"w-12 h-12 rounded-full flex items-center justify-center shrink-0\"\n [ngClass]=\"{\n 'bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400': type() === 'danger',\n 'bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400': type() === 'info',\n 'bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400': type() === 'warning',\n }\"\n >\n @if (type() === 'info') {\n <svg [shkIcon]=\"getIcon('info')\" class=\"w-6 h-6\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('triangle-alert')\" class=\"w-6 h-6\"></svg>\n }\n </div>\n <div>\n <h3 class=\"text-lg font-bold _shk-text-surface-800\">{{ title() }}</h3>\n <p class=\"_shk-text-surface-500 text-sm leading-relaxed mb-6\">{{ message() }}</p>\n </div>\n </div>\n <div class=\"flex gap-3\">\n @if (showCancel()) {\n <button\n type=\"button\"\n (click)=\"onCancel()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold _shk-text-surface-600 _shk-bg-surface-100 hover:[background-color:var(--shk-surface-200)] dark:hover:[background-color:var(--shk-surface-300)] rounded-lg transition-colors flex items-center justify-center gap-2\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n }\n <button\n type=\"button\"\n (click)=\"onConfirm()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold text-white rounded-lg shadow-md transition-all flex items-center justify-center gap-2\"\n [class.bg-red-600]=\"type() === 'danger'\"\n [class.hover:bg-red-700]=\"type() === 'danger'\"\n [class.shadow-red-500/20]=\"type() === 'danger'\"\n [class.bg-primary-600]=\"type() === 'info'\"\n [class.hover:bg-primary-700]=\"type() === 'info'\"\n [class.shadow-primary-500/20]=\"type() === 'info'\"\n [class.bg-amber-600]=\"type() === 'warning'\"\n [class.hover:bg-amber-700]=\"type() === 'warning'\"\n [class.shadow-amber-500/20]=\"type() === 'warning'\"\n >\n @if (loading()) {\n <svg [shkIcon]=\"getIcon('loader')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else if (type() === 'danger') {\n <svg [shkIcon]=\"getIcon('trash-2')\" class=\"w-4 h-4\"></svg>\n }\n {{ loading() ? loadingText() : confirmLabel() }}\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n",
127
+ styles: [".shk-dialog-backdrop{animation:shk-dialog-fade .15s ease-out}.shk-dialog-panel{border:1px solid var(--shk-surface-200);box-shadow:0 24px 48px -12px #00000040,0 8px 16px -8px #0000001a;animation:shk-dialog-in .2s cubic-bezier(.21,1.02,.73,1)}:host-context(.dark) .shk-dialog-panel{box-shadow:0 24px 48px -12px #000000b3,0 8px 16px -8px #00000080}@keyframes shk-dialog-fade{0%{opacity:0}}@keyframes shk-dialog-in{0%{opacity:0;transform:translateY(8px) scale(.97)}}\n"],
128
+ dependencies: [
129
+ {
130
+ kind: "ngmodule",
131
+ type: CommonModule
132
+ },
133
+ {
134
+ kind: "directive",
135
+ type: i1.NgClass,
136
+ selector: "[ngClass]",
137
+ inputs: ["class", "ngClass"]
138
+ },
139
+ {
140
+ kind: "directive",
141
+ type: ShkIconDirective,
142
+ selector: "svg[shkIcon]",
143
+ inputs: [
144
+ "shkIcon",
145
+ "size",
146
+ "strokeWidth",
147
+ "color"
148
+ ]
149
+ }
150
+ ],
151
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
152
+ });
153
+ }
154
+ };
155
+ i0.ɵɵngDeclareClassMetadata({
156
+ minVersion: "12.0.0",
157
+ version: "22.3.2",
158
+ ngImport: i0,
159
+ type: ConfirmDialogComponent,
160
+ decorators: [{
161
+ type: Component,
162
+ args: [{
163
+ selector: "shk-confirm-dialog",
164
+ imports: [CommonModule, ShkIconDirective],
165
+ changeDetection: ChangeDetectionStrategy.OnPush,
166
+ template: "@if (visible()) {\n <div\n class=\"shk-dialog-backdrop fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-[9999] p-4\"\n (click)=\"onCancel()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-2xl shadow-2xl max-w-sm w-full overflow-hidden\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"p-6\">\n <div class=\"flex items-start gap-4 mb-4\">\n <div\n class=\"w-12 h-12 rounded-full flex items-center justify-center shrink-0\"\n [ngClass]=\"{\n 'bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400': type() === 'danger',\n 'bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400': type() === 'info',\n 'bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400': type() === 'warning',\n }\"\n >\n @if (type() === 'info') {\n <svg [shkIcon]=\"getIcon('info')\" class=\"w-6 h-6\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('triangle-alert')\" class=\"w-6 h-6\"></svg>\n }\n </div>\n <div>\n <h3 class=\"text-lg font-bold _shk-text-surface-800\">{{ title() }}</h3>\n <p class=\"_shk-text-surface-500 text-sm leading-relaxed mb-6\">{{ message() }}</p>\n </div>\n </div>\n <div class=\"flex gap-3\">\n @if (showCancel()) {\n <button\n type=\"button\"\n (click)=\"onCancel()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold _shk-text-surface-600 _shk-bg-surface-100 hover:[background-color:var(--shk-surface-200)] dark:hover:[background-color:var(--shk-surface-300)] rounded-lg transition-colors flex items-center justify-center gap-2\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n }\n <button\n type=\"button\"\n (click)=\"onConfirm()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold text-white rounded-lg shadow-md transition-all flex items-center justify-center gap-2\"\n [class.bg-red-600]=\"type() === 'danger'\"\n [class.hover:bg-red-700]=\"type() === 'danger'\"\n [class.shadow-red-500/20]=\"type() === 'danger'\"\n [class.bg-primary-600]=\"type() === 'info'\"\n [class.hover:bg-primary-700]=\"type() === 'info'\"\n [class.shadow-primary-500/20]=\"type() === 'info'\"\n [class.bg-amber-600]=\"type() === 'warning'\"\n [class.hover:bg-amber-700]=\"type() === 'warning'\"\n [class.shadow-amber-500/20]=\"type() === 'warning'\"\n >\n @if (loading()) {\n <svg [shkIcon]=\"getIcon('loader')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else if (type() === 'danger') {\n <svg [shkIcon]=\"getIcon('trash-2')\" class=\"w-4 h-4\"></svg>\n }\n {{ loading() ? loadingText() : confirmLabel() }}\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n",
167
+ styles: [".shk-dialog-backdrop{animation:shk-dialog-fade .15s ease-out}.shk-dialog-panel{border:1px solid var(--shk-surface-200);box-shadow:0 24px 48px -12px #00000040,0 8px 16px -8px #0000001a;animation:shk-dialog-in .2s cubic-bezier(.21,1.02,.73,1)}:host-context(.dark) .shk-dialog-panel{box-shadow:0 24px 48px -12px #000000b3,0 8px 16px -8px #00000080}@keyframes shk-dialog-fade{0%{opacity:0}}@keyframes shk-dialog-in{0%{opacity:0;transform:translateY(8px) scale(.97)}}\n"]
168
+ }]
169
+ }],
170
+ propDecorators: {
171
+ title: [{
172
+ type: i0.Input,
173
+ args: [{
174
+ isSignal: true,
175
+ alias: "title",
176
+ required: false
177
+ }]
178
+ }],
179
+ message: [{
180
+ type: i0.Input,
181
+ args: [{
182
+ isSignal: true,
183
+ alias: "message",
184
+ required: false
185
+ }]
186
+ }],
187
+ confirmLabel: [{
188
+ type: i0.Input,
189
+ args: [{
190
+ isSignal: true,
191
+ alias: "confirmLabel",
192
+ required: false
193
+ }]
194
+ }],
195
+ cancelLabel: [{
196
+ type: i0.Input,
197
+ args: [{
198
+ isSignal: true,
199
+ alias: "cancelLabel",
200
+ required: false
201
+ }]
202
+ }],
203
+ loadingText: [{
204
+ type: i0.Input,
205
+ args: [{
206
+ isSignal: true,
207
+ alias: "loadingText",
208
+ required: false
209
+ }]
210
+ }],
211
+ type: [{
212
+ type: i0.Input,
213
+ args: [{
214
+ isSignal: true,
215
+ alias: "type",
216
+ required: false
217
+ }]
218
+ }],
219
+ loading: [{
220
+ type: i0.Input,
221
+ args: [{
222
+ isSignal: true,
223
+ alias: "loading",
224
+ required: false
225
+ }]
226
+ }],
227
+ showCancel: [{
228
+ type: i0.Input,
229
+ args: [{
230
+ isSignal: true,
231
+ alias: "showCancel",
232
+ required: false
233
+ }]
234
+ }],
235
+ closed: [{
236
+ type: i0.Output,
237
+ args: ["closed"]
238
+ }]
239
+ }
240
+ });
241
+ var ConfirmDialogService = class ConfirmDialogService {
242
+ constructor() {
243
+ this.dialogRef = null;
244
+ this.destroyRef = inject(DestroyRef);
245
+ this.appRef = inject(ApplicationRef);
246
+ this.injector = inject(EnvironmentInjector);
247
+ this.destroyRef.onDestroy(() => this.cleanupDialog());
248
+ }
249
+ async confirm(config) {
250
+ if (this.dialogRef) this.cleanupDialog();
251
+ this.dialogRef = createComponent(ConfirmDialogComponent, { environmentInjector: this.injector });
252
+ this.dialogRef.setInput("title", config.title ?? "Confirmar acción");
253
+ this.dialogRef.setInput("message", config.message);
254
+ this.dialogRef.setInput("confirmLabel", config.confirmLabel ?? "Confirmar");
255
+ this.dialogRef.setInput("cancelLabel", config.cancelLabel ?? "Cancelar");
256
+ this.dialogRef.setInput("loadingText", config.loadingText ?? "Procesando…");
257
+ this.dialogRef.setInput("type", config.type ?? "danger");
258
+ this.dialogRef.setInput("showCancel", config.showCancel ?? true);
259
+ this.dialogRef.setInput("loading", config.loading ?? false);
260
+ document.body.appendChild(this.dialogRef.location.nativeElement);
261
+ this.appRef.attachView(this.dialogRef.hostView);
262
+ try {
263
+ return await this.dialogRef.instance.show();
264
+ } finally {
265
+ this.cleanupDialog();
266
+ }
267
+ }
268
+ cleanupDialog() {
269
+ if (this.dialogRef) {
270
+ this.appRef.detachView(this.dialogRef.hostView);
271
+ this.dialogRef.destroy();
272
+ this.dialogRef = null;
273
+ }
274
+ }
275
+ static {
276
+ this.ɵfac = i0.ɵɵngDeclareFactory({
277
+ minVersion: "12.0.0",
278
+ version: "22.3.2",
279
+ ngImport: i0,
280
+ type: ConfirmDialogService,
281
+ deps: [],
282
+ target: i0.ɵɵFactoryTarget.Injectable
283
+ });
284
+ }
285
+ static {
286
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
287
+ minVersion: "12.0.0",
288
+ version: "22.3.2",
289
+ ngImport: i0,
290
+ type: ConfirmDialogService,
291
+ providedIn: "root"
292
+ });
293
+ }
294
+ };
295
+ i0.ɵɵngDeclareClassMetadata({
296
+ minVersion: "12.0.0",
297
+ version: "22.3.2",
298
+ ngImport: i0,
299
+ type: ConfirmDialogService,
300
+ decorators: [{
301
+ type: Injectable,
302
+ args: [{ providedIn: "root" }]
303
+ }],
304
+ ctorParameters: () => []
305
+ });
142
306
  export { ConfirmDialogComponent, ConfirmDialogService };
143
- //# sourceMappingURL=shirkasoft-ui-components-confirm-dialog.mjs.map
307
+
308
+ //# sourceMappingURL=shirkasoft-ui-components-confirm-dialog.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"shirkasoft-ui-components-confirm-dialog.mjs","sources":["../../../projects/ui-components/confirm-dialog/confirm-dialog.component.ts","../../../projects/ui-components/confirm-dialog/confirm-dialog.component.html","../../../projects/ui-components/confirm-dialog/confirm-dialog.service.ts","../../../projects/ui-components/confirm-dialog/shirkasoft-ui-components-confirm-dialog.ts"],"sourcesContent":["import { Component, ChangeDetectionStrategy, input, output, signal, OnDestroy } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { LucideDynamicIcon, LucideTriangleAlert } from '@lucide/angular';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Confirmation dialog opened via `show()` which resolves a Promise<boolean>\n * with the user's choice.\n */\n@Component({\n selector: 'shk-confirm-dialog',\n standalone: true,\n imports: [CommonModule, LucideDynamicIcon],\n templateUrl: './confirm-dialog.component.html',\n styles: [\n `\n /* Own enter animation (the animate-in/zoom-in utilities used before\n need a Tailwind plugin that isn't part of the library). */\n .shk-dialog-backdrop {\n animation: shk-dialog-fade 0.15s ease-out;\n }\n .shk-dialog-panel {\n border: 1px solid var(--shk-surface-200);\n box-shadow:\n 0 24px 48px -12px rgba(0, 0, 0, 0.25),\n 0 8px 16px -8px rgba(0, 0, 0, 0.1);\n animation: shk-dialog-in 0.2s cubic-bezier(0.21, 1.02, 0.73, 1);\n }\n :host-context(.dark) .shk-dialog-panel {\n box-shadow:\n 0 24px 48px -12px rgba(0, 0, 0, 0.7),\n 0 8px 16px -8px rgba(0, 0, 0, 0.5);\n }\n @keyframes shk-dialog-fade {\n from {\n opacity: 0;\n }\n }\n @keyframes shk-dialog-in {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.97);\n }\n }\n `,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ConfirmDialogComponent implements OnDestroy {\n protected getIcon = (name: any) => getIconFromCentral(name, LucideTriangleAlert);\n\n /** Title shown in the dialog header. */\n title = input<string>('Confirmar acción');\n /** Message body of the dialog. */\n message = input<string>('¿Está seguro de realizar esta acción?');\n /** Label of the confirm button. */\n confirmLabel = input<string>('Confirmar');\n /** Label of the cancel button. */\n cancelLabel = input<string>('Cancelar');\n /** Text shown on the confirm button while `loading` is true. */\n loadingText = input<string>('Procesando…');\n /** Visual style: 'danger', 'info' or 'warning'. */\n type = input<'danger' | 'info' | 'warning'>('danger');\n /** Shows a spinner and disables the confirm button. */\n loading = input<boolean>(false);\n /** Whether the cancel button is shown. */\n showCancel = input<boolean>(true);\n\n /** Controls dialog visibility. */\n visible = signal<boolean>(false);\n /** Resolver of the currently pending confirmation promise. */\n private resolveRef = signal<((value: boolean) => void) | null>(null);\n\n /** Emitted whenever the dialog is closed (confirm or cancel). */\n closed = output<void>();\n\n /** Opens the dialog and returns a promise resolving with the user choice. */\n show(): Promise<boolean> {\n this.visible.set(true);\n return new Promise((resolve) => {\n this.resolveRef.set(resolve);\n });\n }\n\n /** Resolves with `true` when the user confirms. */\n onConfirm() {\n this.visible.set(false);\n const resolve = this.resolveRef();\n if (resolve) {\n resolve(true);\n this.resolveRef.set(null);\n }\n this.closed.emit();\n }\n\n /** Resolves with `false` when the user cancels. */\n onCancel() {\n this.visible.set(false);\n const resolve = this.resolveRef();\n if (resolve) {\n resolve(false);\n this.resolveRef.set(null);\n }\n this.closed.emit();\n }\n\n /** Clears the pending resolver on destroy. */\n ngOnDestroy() {\n this.resolveRef.set(null);\n }\n}\n","@if (visible()) {\n <div\n class=\"shk-dialog-backdrop fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-[9999] p-4\"\n (click)=\"onCancel()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-2xl shadow-2xl max-w-sm w-full overflow-hidden\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"p-6\">\n <div class=\"flex items-start gap-4 mb-4\">\n <div\n class=\"w-12 h-12 rounded-full flex items-center justify-center shrink-0\"\n [ngClass]=\"{\n 'bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400': type() === 'danger',\n 'bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400': type() === 'info',\n 'bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400': type() === 'warning',\n }\"\n >\n @if (type() === 'info') {\n <svg [lucideIcon]=\"getIcon('info')\" class=\"w-6 h-6\"></svg>\n } @else {\n <svg [lucideIcon]=\"getIcon('triangle-alert')\" class=\"w-6 h-6\"></svg>\n }\n </div>\n <div>\n <h3 class=\"text-lg font-bold _shk-text-surface-800 dark:[color:var(--shk-surface-800)]\">{{ title() }}</h3>\n <p class=\"_shk-text-surface-500 dark:[color:var(--shk-surface-400)] text-sm leading-relaxed mb-6\">{{ message() }}</p>\n </div>\n </div>\n <div class=\"flex gap-3\">\n @if (showCancel()) {\n <button\n type=\"button\"\n (click)=\"onCancel()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold _shk-text-surface-600 dark:[color:var(--shk-surface-600)] _shk-bg-surface-100 dark:[background-color:var(--shk-surface-200)] hover:[background-color:var(--shk-surface-200)] dark:hover:[background-color:var(--shk-surface-300)] rounded-lg transition-colors flex items-center justify-center gap-2\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n }\n <button\n type=\"button\"\n (click)=\"onConfirm()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold text-white rounded-lg shadow-md transition-all flex items-center justify-center gap-2\"\n [class.bg-red-600]=\"type() === 'danger'\"\n [class.hover:bg-red-700]=\"type() === 'danger'\"\n [class.shadow-red-500/20]=\"type() === 'danger'\"\n [class.bg-primary-600]=\"type() === 'info'\"\n [class.hover:bg-primary-700]=\"type() === 'info'\"\n [class.shadow-primary-500/20]=\"type() === 'info'\"\n [class.bg-amber-600]=\"type() === 'warning'\"\n [class.hover:bg-amber-700]=\"type() === 'warning'\"\n [class.shadow-amber-500/20]=\"type() === 'warning'\"\n >\n @if (loading()) {\n <svg [lucideIcon]=\"getIcon('loader')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else if (type() === 'danger') {\n <svg [lucideIcon]=\"getIcon('trash-2')\" class=\"w-4 h-4\"></svg>\n }\n {{ loading() ? loadingText() : confirmLabel() }}\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n","import {\n Injectable,\n ComponentRef,\n ApplicationRef,\n createComponent,\n EnvironmentInjector,\n DestroyRef,\n inject,\n} from '@angular/core';\nimport { ConfirmDialogComponent } from './confirm-dialog.component';\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/** Options for opening a confirmation dialog. */\nexport interface ConfirmConfig {\n title?: string;\n message: string;\n confirmLabel?: string;\n cancelLabel?: string;\n loadingText?: string;\n type?: 'danger' | 'info' | 'warning';\n showCancel?: boolean;\n loading?: boolean;\n}\n\n/**\n * Programmatically opens the confirmation dialog and resolves a Promise\n * with the user's decision (true = confirm, false = cancel).\n */\n@Injectable({ providedIn: 'root' })\nexport class ConfirmDialogService {\n /** Reference to the currently open dialog, if any. */\n private dialogRef: ComponentRef<ConfirmDialogComponent> | null = null;\n\n private destroyRef = inject(DestroyRef);\n private appRef = inject(ApplicationRef);\n private injector = inject(EnvironmentInjector);\n\n constructor() {\n this.destroyRef.onDestroy(() => this.cleanupDialog());\n }\n\n /**\n * Opens a confirmation dialog with the given configuration and returns a\n * promise resolving with the user's choice.\n */\n async confirm(config: ConfirmConfig): Promise<boolean> {\n if (this.dialogRef) this.cleanupDialog();\n\n this.dialogRef = createComponent(ConfirmDialogComponent, {\n environmentInjector: this.injector,\n });\n\n this.dialogRef.setInput('title', config.title ?? 'Confirmar acción');\n this.dialogRef.setInput('message', config.message);\n this.dialogRef.setInput('confirmLabel', config.confirmLabel ?? 'Confirmar');\n this.dialogRef.setInput('cancelLabel', config.cancelLabel ?? 'Cancelar');\n this.dialogRef.setInput('loadingText', config.loadingText ?? 'Procesando…');\n this.dialogRef.setInput('type', config.type ?? 'danger');\n this.dialogRef.setInput('showCancel', config.showCancel ?? true);\n this.dialogRef.setInput('loading', config.loading ?? false);\n\n document.body.appendChild(this.dialogRef.location.nativeElement);\n this.appRef.attachView(this.dialogRef.hostView);\n try {\n return await this.dialogRef.instance.show();\n } finally {\n this.cleanupDialog();\n }\n }\n\n /** Detaches and destroys the mounted dialog if present. */\n private cleanupDialog(): void {\n if (this.dialogRef) {\n this.appRef.detachView(this.dialogRef.hostView);\n this.dialogRef.destroy();\n this.dialogRef = null;\n }\n }\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getIconFromCentral"],"mappings":";;;;;;;AAKA;;;;AAIG;AAEH;;;AAGG;MAwCU,sBAAsB,CAAA;AAvCnC,IAAA,WAAA,GAAA;AAwCY,QAAA,IAAA,CAAA,OAAO,GAAG,CAAC,IAAS,KAAKA,OAAkB,CAAC,IAAI,EAAE,mBAAmB,CAAC;;AAGhF,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAS,kBAAkB,4EAAC;;AAEzC,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAS,uCAAuC,8EAAC;;AAEhE,QAAA,IAAA,CAAA,YAAY,GAAG,KAAK,CAAS,WAAW,mFAAC;;AAEzC,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAS,UAAU,kFAAC;;AAEvC,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAS,aAAa,kFAAC;;AAE1C,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK,CAAgC,QAAQ,2EAAC;;AAErD,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAU,KAAK,8EAAC;;AAE/B,QAAA,IAAA,CAAA,UAAU,GAAG,KAAK,CAAU,IAAI,iFAAC;;AAGjC,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAAU,KAAK,8EAAC;;AAExB,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAoC,IAAI,iFAAC;;QAG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,QAAQ,CAAC;AAC/C,YAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;AACxB,YAAA,IAAI,CAAC,SAAS,GAAG,IAAI;QACvB;IACF;+GAhDW,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAApB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,cADP,MAAM,EAAA,CAAA,CAAA;;4FACnB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACjClC;;AAEG;;;;"}
1
+ {"version":3,"file":"shirkasoft-ui-components-confirm-dialog.mjs","names":["getIconFromCentral"],"sources":["../../../projects/ui-components/confirm-dialog/confirm-dialog.component.ts","../../../projects/ui-components/confirm-dialog/confirm-dialog.component.html","../../../projects/ui-components/confirm-dialog/confirm-dialog.service.ts"],"sourcesContent":["import { Component, ChangeDetectionStrategy, input, output, signal, OnDestroy } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ShkIconDirective, LucideTriangleAlert } from 'shirkasoft-ui-components/icons';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Confirmation dialog opened via `show()` which resolves a Promise<boolean>\n * with the user's choice.\n */\n@Component({\n selector: 'shk-confirm-dialog',\n imports: [CommonModule, ShkIconDirective],\n templateUrl: './confirm-dialog.component.html',\n styles: [\n `\n /* Own enter animation (the animate-in/zoom-in utilities used before\n need a Tailwind plugin that isn't part of the library). */\n .shk-dialog-backdrop {\n animation: shk-dialog-fade 0.15s ease-out;\n }\n .shk-dialog-panel {\n border: 1px solid var(--shk-surface-200);\n box-shadow:\n 0 24px 48px -12px rgba(0, 0, 0, 0.25),\n 0 8px 16px -8px rgba(0, 0, 0, 0.1);\n animation: shk-dialog-in 0.2s cubic-bezier(0.21, 1.02, 0.73, 1);\n }\n :host-context(.dark) .shk-dialog-panel {\n box-shadow:\n 0 24px 48px -12px rgba(0, 0, 0, 0.7),\n 0 8px 16px -8px rgba(0, 0, 0, 0.5);\n }\n @keyframes shk-dialog-fade {\n from {\n opacity: 0;\n }\n }\n @keyframes shk-dialog-in {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.97);\n }\n }\n `,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ConfirmDialogComponent implements OnDestroy {\n protected getIcon = (name: any) => getIconFromCentral(name, LucideTriangleAlert);\n\n /** Title shown in the dialog header. */\n title = input<string>('Confirmar acción');\n /** Message body of the dialog. */\n message = input<string>('¿Está seguro de realizar esta acción?');\n /** Label of the confirm button. */\n confirmLabel = input<string>('Confirmar');\n /** Label of the cancel button. */\n cancelLabel = input<string>('Cancelar');\n /** Text shown on the confirm button while `loading` is true. */\n loadingText = input<string>('Procesando…');\n /** Visual style: 'danger', 'info' or 'warning'. */\n type = input<'danger' | 'info' | 'warning'>('danger');\n /** Shows a spinner and disables the confirm button. */\n loading = input<boolean>(false);\n /** Whether the cancel button is shown. */\n showCancel = input<boolean>(true);\n\n /** Controls dialog visibility. */\n visible = signal<boolean>(false);\n /** Resolver of the currently pending confirmation promise. */\n private resolveRef = signal<((value: boolean) => void) | null>(null);\n\n /** Emitted whenever the dialog is closed (confirm or cancel). */\n closed = output<void>();\n\n /** Opens the dialog and returns a promise resolving with the user choice. */\n show(): Promise<boolean> {\n this.visible.set(true);\n return new Promise((resolve) => {\n this.resolveRef.set(resolve);\n });\n }\n\n /** Resolves with `true` when the user confirms. */\n onConfirm() {\n this.visible.set(false);\n const resolve = this.resolveRef();\n if (resolve) {\n resolve(true);\n this.resolveRef.set(null);\n }\n this.closed.emit();\n }\n\n /** Resolves with `false` when the user cancels. */\n onCancel() {\n this.visible.set(false);\n const resolve = this.resolveRef();\n if (resolve) {\n resolve(false);\n this.resolveRef.set(null);\n }\n this.closed.emit();\n }\n\n /** Clears the pending resolver on destroy. */\n ngOnDestroy() {\n this.resolveRef.set(null);\n }\n}\n","@if (visible()) {\n <div\n class=\"shk-dialog-backdrop fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-[9999] p-4\"\n (click)=\"onCancel()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-2xl shadow-2xl max-w-sm w-full overflow-hidden\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"p-6\">\n <div class=\"flex items-start gap-4 mb-4\">\n <div\n class=\"w-12 h-12 rounded-full flex items-center justify-center shrink-0\"\n [ngClass]=\"{\n 'bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400': type() === 'danger',\n 'bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400': type() === 'info',\n 'bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400': type() === 'warning',\n }\"\n >\n @if (type() === 'info') {\n <svg [shkIcon]=\"getIcon('info')\" class=\"w-6 h-6\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('triangle-alert')\" class=\"w-6 h-6\"></svg>\n }\n </div>\n <div>\n <h3 class=\"text-lg font-bold _shk-text-surface-800\">{{ title() }}</h3>\n <p class=\"_shk-text-surface-500 text-sm leading-relaxed mb-6\">{{ message() }}</p>\n </div>\n </div>\n <div class=\"flex gap-3\">\n @if (showCancel()) {\n <button\n type=\"button\"\n (click)=\"onCancel()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold _shk-text-surface-600 _shk-bg-surface-100 hover:[background-color:var(--shk-surface-200)] dark:hover:[background-color:var(--shk-surface-300)] rounded-lg transition-colors flex items-center justify-center gap-2\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n }\n <button\n type=\"button\"\n (click)=\"onConfirm()\"\n [disabled]=\"loading()\"\n class=\"flex-1 px-4 py-2 text-sm font-semibold text-white rounded-lg shadow-md transition-all flex items-center justify-center gap-2\"\n [class.bg-red-600]=\"type() === 'danger'\"\n [class.hover:bg-red-700]=\"type() === 'danger'\"\n [class.shadow-red-500/20]=\"type() === 'danger'\"\n [class.bg-primary-600]=\"type() === 'info'\"\n [class.hover:bg-primary-700]=\"type() === 'info'\"\n [class.shadow-primary-500/20]=\"type() === 'info'\"\n [class.bg-amber-600]=\"type() === 'warning'\"\n [class.hover:bg-amber-700]=\"type() === 'warning'\"\n [class.shadow-amber-500/20]=\"type() === 'warning'\"\n >\n @if (loading()) {\n <svg [shkIcon]=\"getIcon('loader')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else if (type() === 'danger') {\n <svg [shkIcon]=\"getIcon('trash-2')\" class=\"w-4 h-4\"></svg>\n }\n {{ loading() ? loadingText() : confirmLabel() }}\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n","import {\n Injectable,\n ComponentRef,\n ApplicationRef,\n createComponent,\n EnvironmentInjector,\n DestroyRef,\n inject,\n} from '@angular/core';\nimport { ConfirmDialogComponent } from './confirm-dialog.component';\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/** Options for opening a confirmation dialog. */\nexport interface ConfirmConfig {\n title?: string;\n message: string;\n confirmLabel?: string;\n cancelLabel?: string;\n loadingText?: string;\n type?: 'danger' | 'info' | 'warning';\n showCancel?: boolean;\n loading?: boolean;\n}\n\n/**\n * Programmatically opens the confirmation dialog and resolves a Promise\n * with the user's decision (true = confirm, false = cancel).\n */\n@Injectable({ providedIn: 'root' })\nexport class ConfirmDialogService {\n /** Reference to the currently open dialog, if any. */\n private dialogRef: ComponentRef<ConfirmDialogComponent> | null = null;\n\n private destroyRef = inject(DestroyRef);\n private appRef = inject(ApplicationRef);\n private injector = inject(EnvironmentInjector);\n\n constructor() {\n this.destroyRef.onDestroy(() => this.cleanupDialog());\n }\n\n /**\n * Opens a confirmation dialog with the given configuration and returns a\n * promise resolving with the user's choice.\n */\n async confirm(config: ConfirmConfig): Promise<boolean> {\n if (this.dialogRef) this.cleanupDialog();\n\n this.dialogRef = createComponent(ConfirmDialogComponent, {\n environmentInjector: this.injector,\n });\n\n this.dialogRef.setInput('title', config.title ?? 'Confirmar acción');\n this.dialogRef.setInput('message', config.message);\n this.dialogRef.setInput('confirmLabel', config.confirmLabel ?? 'Confirmar');\n this.dialogRef.setInput('cancelLabel', config.cancelLabel ?? 'Cancelar');\n this.dialogRef.setInput('loadingText', config.loadingText ?? 'Procesando…');\n this.dialogRef.setInput('type', config.type ?? 'danger');\n this.dialogRef.setInput('showCancel', config.showCancel ?? true);\n this.dialogRef.setInput('loading', config.loading ?? false);\n\n document.body.appendChild(this.dialogRef.location.nativeElement);\n this.appRef.attachView(this.dialogRef.hostView);\n try {\n return await this.dialogRef.instance.show();\n } finally {\n this.cleanupDialog();\n }\n }\n\n /** Detaches and destroys the mounted dialog if present. */\n private cleanupDialog(): void {\n if (this.dialogRef) {\n this.appRef.detachView(this.dialogRef.hostView);\n this.dialogRef.destroy();\n this.dialogRef = null;\n }\n }\n}"],"mappings":";;;;;;AAqDA,IAAa,yBAAb,MAAa,uBAAsB;CAtCnC,cAAA;EAuCY,KAAA,WAAW,SAAcA,QAAmB,MAAM,mBAAmB;EAG/E,KAAA,QAAQ,MAAc,oBAAmB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAEzC,KAAA,UAAU,MAAc,yCAAwC,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EAEhE,KAAA,eAAe,MAAc,aAAY,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