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,304 +1,312 @@
1
- import * as i0 from '@angular/core';
2
- import { signal, inject, DestroyRef, computed, Injectable, ChangeDetectorRef, viewChild, ViewContainerRef, effect, untracked, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import { CommonModule } from '@angular/common';
4
- import { LucideX, LucideDynamicIcon } from '@lucide/angular';
5
- import { FormControl, FormGroup } from '@angular/forms';
6
- import { TranslocoService } from '@jsverse/transloco';
7
- import { Router } from '@angular/router';
8
- import { NotificationService } from 'shirkasoft-ui-components/notification';
9
- import { getIcon } from 'shirkasoft-ui-components/utils';
10
-
11
- /**
12
- * Global modal manager. Opens modals on a stack, exposing reactive access to
13
- * the current modal and the top-most opened config.
14
- */
15
- class ModalService {
16
- constructor() {
17
- /** Stack of open modals (top-most renders on top). */
18
- this.stackSignal = signal([], ...(ngDevMode ? [{ debugName: "stackSignal" }] : /* istanbul ignore next */ []));
19
- /** Counter emitted on each close, used to trigger close animations. */
20
- this.closeRequestSignal = signal(0, ...(ngDevMode ? [{ debugName: "closeRequestSignal" }] : /* istanbul ignore next */ []));
21
- this.router = inject(Router);
22
- this.destroyRef = inject(DestroyRef);
23
- /** Reactive list of open modals. */
24
- this.modalStack = computed(() => this.stackSignal(), ...(ngDevMode ? [{ debugName: "modalStack" }] : /* istanbul ignore next */ []));
25
- /** Top-most modal on the stack, or null. */
26
- this.currentModal = computed(() => {
27
- const stack = this.stackSignal();
28
- return stack.length > 0 ? stack[stack.length - 1] : null;
29
- }, ...(ngDevMode ? [{ debugName: "currentModal" }] : /* istanbul ignore next */ []));
30
- /** Reactive close-request counter. */
31
- this.closeRequest = computed(() => this.closeRequestSignal(), ...(ngDevMode ? [{ debugName: "closeRequest" }] : /* istanbul ignore next */ []));
32
- // Close all modals on navigation and on service destruction.
33
- this.router.events.subscribe(() => {
34
- this.stackSignal.set([]);
35
- });
36
- this.destroyRef.onDestroy(() => this.stackSignal.set([]));
37
- }
38
- /** Opens a new modal on top of the stack. */
39
- open(config) {
40
- this.stackSignal.update((stack) => [...stack, config]);
41
- }
42
- /** Alias of `close()` used by the accept button. */
43
- accept() {
44
- this.close();
45
- }
46
- /** Closes the top-most modal, invoking its onClose callback. */
47
- close() {
48
- const stack = this.stackSignal();
49
- if (stack.length > 0) {
50
- stack[stack.length - 1]?.onClose?.();
51
- this.stackSignal.set(stack.slice(0, -1));
52
- this.closeRequestSignal.update((v) => v + 1);
53
- }
54
- }
55
- /** Closes all open modals at once. */
56
- clear() {
57
- this.stackSignal.set([]);
58
- }
59
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ModalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
60
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ModalService, providedIn: 'root' }); }
61
- }
62
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ModalService, decorators: [{
63
- type: Injectable,
64
- args: [{ providedIn: 'root' }]
65
- }], ctorParameters: () => [] });
66
-
67
- /**
68
- * Shirkasoft UI Components.
69
- * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
70
- * Belongs to Shirkasoft.
71
- */
72
- /**
73
- * Modal dialog that renders a dynamically loaded component, tracks its
74
- * form validity and submit outputs, and delegates accept/cancel to the
75
- * shared ModalService.
76
- */
77
- class ModalComponent {
78
- constructor() {
79
- this.getIcon = (name) => getIcon(name, LucideX);
80
- this.notificationSrv = inject(NotificationService);
81
- this.destroyRef = inject(DestroyRef);
82
- this.modalSrv = inject(ModalService);
83
- this.transloco = inject(TranslocoService);
84
- this.cdr = inject(ChangeDetectorRef);
85
- /** Reference where the dynamic content is rendered. */
86
- this.container = viewChild('dynamicContent', { ...(ngDevMode ? { debugName: "container" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
87
- /** Configuration of the modal currently open (from the service). */
88
- this.currentConfig = signal(null, ...(ngDevMode ? [{ debugName: "currentConfig" }] : /* istanbul ignore next */ []));
89
- /** Modal title. */
90
- this.title = signal('', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
91
- /** Whether the modal is visible. */
92
- this.visible = signal(false, ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
93
- /** Generic loading flag for the footer actions. */
94
- this.loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
95
- /** Whether the accept action is being processed. */
96
- this.isProcessing = signal(false, ...(ngDevMode ? [{ debugName: "isProcessing" }] : /* istanbul ignore next */ []));
97
- /** Whether the modal is currently expanded to fullscreen. */
98
- this.isExpanded = signal(false, ...(ngDevMode ? [{ debugName: "isExpanded" }] : /* istanbul ignore next */ []));
99
- /** True when the dynamic component reports a valid form. */
100
- this.isFormValid = signal(false, ...(ngDevMode ? [{ debugName: "isFormValid" }] : /* istanbul ignore next */ []));
101
- /** Reference to the dynamically created component. */
102
- this.componentRef = null;
103
- /** Subscriptions to the dynamic component outputs. */
104
- this.subscriptions = [];
105
- /** Width of the modal (fullscreen when expanded). */
106
- this.computedModalWidth = computed(() => {
107
- return this.isExpanded() ? '100vw' : (this.currentConfig()?.width ?? '560px');
108
- }, ...(ngDevMode ? [{ debugName: "computedModalWidth" }] : /* istanbul ignore next */ []));
109
- /** Whether the footer buttons should be rendered. */
110
- this.modalButtonsVisible = computed(() => this.currentConfig()?.showButtons ?? true, ...(ngDevMode ? [{ debugName: "modalButtonsVisible" }] : /* istanbul ignore next */ []));
111
- /** Whether the expand/fullscreen button is shown. */
112
- this.showExpandButton = computed(() => this.currentConfig()?.showExpandButton ?? false, ...(ngDevMode ? [{ debugName: "showExpandButton" }] : /* istanbul ignore next */ []));
113
- /** Resolved cancel button label. */
114
- this.cancelLabel = computed(() => this.currentConfig()?.cancelLabel || 'Cancelar', ...(ngDevMode ? [{ debugName: "cancelLabel" }] : /* istanbul ignore next */ []));
115
- /** Resolved accept button label. */
116
- this.acceptLabel = computed(() => this.currentConfig()?.acceptLabel || 'Aceptar', ...(ngDevMode ? [{ debugName: "acceptLabel" }] : /* istanbul ignore next */ []));
117
- effect(() => {
118
- const config = this.modalSrv.currentModal();
119
- if (config) {
120
- this.currentConfig.set(config);
121
- this.title.set(config.title);
122
- this.isExpanded.set(false);
123
- this.visible.set(true);
124
- this.isProcessing.set(false);
125
- this.loading.set(false);
126
- this.cdr.markForCheck();
127
- setTimeout(() => {
128
- untracked(() => this.loadComponent(config));
129
- });
130
- }
131
- else {
132
- this.visible.set(false);
133
- this.currentConfig.set(null);
134
- this.cdr.markForCheck();
135
- }
136
- });
137
- this.destroyRef.onDestroy(() => this.cleanup());
138
- }
139
- /** Updates visibility when the backdrop/close controls change. */
140
- onVisibleChange(show) {
141
- this.visible.set(show);
142
- if (!show) {
143
- this.closeModal();
144
- }
145
- this.cdr.markForCheck();
146
- }
147
- /** Creates the dynamic component and wires its form/submit outputs. */
148
- loadComponent(config) {
149
- const containerRef = this.container();
150
- if (!containerRef)
151
- return;
152
- this.cleanup();
153
- containerRef.clear();
154
- this.componentRef = containerRef.createComponent(config.component);
155
- if (config.data) {
156
- Object.entries(config.data).forEach(([key, value]) => {
157
- this.componentRef?.setInput(key, value);
158
- });
159
- }
160
- const instance = this.componentRef.instance;
161
- this.subscribeToOutput(instance.formValid, (valid) => {
162
- this.isFormValid.set(valid);
163
- this.cdr.markForCheck();
164
- });
165
- this.subscribeToOutput(instance.submitSuccess, (payload) => this.handleSubmit(true, payload));
166
- this.subscribeToOutput(instance.submitError, () => this.handleSubmit(false));
167
- this.componentRef.changeDetectorRef.markForCheck();
168
- this.cdr.markForCheck();
169
- }
170
- /** Subscribes to a dynamic component output if it exists. */
171
- subscribeToOutput(output, callback) {
172
- if (output?.subscribe) {
173
- this.subscriptions.push(output.subscribe(callback));
174
- }
175
- }
176
- /** Finalizes the submit flow, accepting the modal on success. */
177
- handleSubmit(success, payload) {
178
- this.isProcessing.set(false);
179
- this.loading.set(false);
180
- this.cdr.markForCheck();
181
- if (success) {
182
- // Hand the payload to `onAccept` (only when the modal config defines it).
183
- const onAccept = this.currentConfig()?.onAccept;
184
- if (onAccept) {
185
- untracked(() => onAccept(payload !== undefined ? payload : this.getFormValue()));
186
- }
187
- untracked(() => this.modalSrv.accept());
188
- }
189
- }
190
- /** Raw value of the dynamic component's form, or undefined when it has none. */
191
- getFormValue() {
192
- const instance = this.componentRef?.instance;
193
- const form = instance ? this.getForm(instance) : null;
194
- return form ? form.getRawValue() : undefined;
195
- }
196
- /** Closes the modal, calling the dynamic component's `handleCancel` if any. */
197
- closeModal() {
198
- if (this.componentRef?.instance?.handleCancel) {
199
- this.componentRef.instance.handleCancel();
200
- }
201
- this.doClose();
202
- }
203
- /** Performs the actual close sequence and cleanup. */
204
- doClose() {
205
- this.visible.set(false);
206
- this.isProcessing.set(false);
207
- this.loading.set(false);
208
- if (this.isExpanded()) {
209
- this.isExpanded.set(false);
210
- }
211
- this.cdr.markForCheck();
212
- setTimeout(() => {
213
- this.cleanup();
214
- this.modalSrv.close();
215
- }, 100);
216
- }
217
- /** Toggles between normal width and fullscreen. */
218
- toggleExpand() {
219
- this.isExpanded.update((v) => !v);
220
- this.cdr.markForCheck();
221
- }
222
- /** Validates the dynamic component form and triggers its `onSubmit`. */
223
- onAccept() {
224
- if (!this.componentRef || !this.isDynamicComponent(this.componentRef.instance))
225
- return;
226
- if (this.isProcessing())
227
- return;
228
- const instance = this.componentRef.instance;
229
- const form = this.getForm(instance);
230
- if (form) {
231
- this.markAllAsTouched(form);
232
- this.componentRef.changeDetectorRef.markForCheck();
233
- this.cdr.markForCheck();
234
- if (this.hasRealErrors(form)) {
235
- this.notificationSrv.addNotification(this.transloco.translate('modal.formInvalid'), 'warning');
236
- return;
237
- }
238
- }
239
- this.isProcessing.set(true);
240
- this.loading.set(true);
241
- this.cdr.markForCheck();
242
- instance.onSubmit();
243
- }
244
- /** Resolves the dynamic component's form (property or getter function). */
245
- getForm(instance) {
246
- if (!instance['form'])
247
- return null;
248
- return typeof instance['form'] === 'function'
249
- ? instance['form']()
250
- : instance['form'];
251
- }
252
- /** Recursively checks for real validation errors (ignoring 'warning'). */
253
- hasRealErrors(control) {
254
- if (control instanceof FormControl) {
255
- const errors = control.errors;
256
- return errors
257
- ? Object.keys(errors).some((key) => key !== 'warning')
258
- : false;
259
- }
260
- const groupErrors = control.errors;
261
- if (groupErrors &&
262
- Object.keys(groupErrors).some((key) => key !== 'warning')) {
263
- return true;
264
- }
265
- return Object.values(control.controls).some((child) => this.hasRealErrors(child));
266
- }
267
- /** Marks a form (and all its descendants) as touched. */
268
- markAllAsTouched(control) {
269
- control.markAsTouched();
270
- control.updateValueAndValidity({ onlySelf: true, emitEvent: true });
271
- if (control instanceof FormGroup) {
272
- Object.values(control.controls).forEach((child) => this.markAllAsTouched(child));
273
- }
274
- }
275
- /**
276
- * True when the component exposes `onSubmit`. The `form` is optional:
277
- * without it, validation is skipped and `onSubmit` runs directly.
278
- */
279
- isDynamicComponent(instance) {
280
- return typeof instance?.onSubmit === 'function';
281
- }
282
- /** Unsubscribes outputs and destroys the dynamic component. */
283
- cleanup() {
284
- this.subscriptions.forEach((sub) => sub.unsubscribe());
285
- this.subscriptions = [];
286
- if (this.componentRef) {
287
- this.componentRef.destroy();
288
- this.componentRef = null;
289
- }
290
- }
291
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
292
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.23", type: ModalComponent, isStandalone: true, selector: "shk-modal", viewQueries: [{ propertyName: "container", first: true, predicate: ["dynamicContent"], descendants: true, read: ViewContainerRef, isSignal: true }], 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-40 p-4 pt-4 overflow-y-auto _shk-scrollbar\"\n (click)=\"closeModal()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-xl shadow-2xl overflow-hidden flex flex-col\"\n [class.w-[95vw]]=\"isExpanded()\"\n [class.h-[90vh]]=\"isExpanded()\"\n [class.w-full]=\"!isExpanded()\"\n [style.max-width]=\"isExpanded() ? undefined : computedModalWidth()\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"shk-modal-header flex items-center justify-between px-6 pt-4 pb-2 shrink-0\">\n <span class=\"font-semibold text-lg _shk-text-surface-800 dark:[color:var(--shk-surface-800)]\">{{ title() }}</span>\n <div class=\"flex items-center gap-2\">\n @if (showExpandButton()) {\n <button\n type=\"button\"\n (click)=\"toggleExpand()\"\n class=\"p-1.5 rounded-lg hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 dark:[color:var(--shk-surface-500)] transition-colors\"\n >\n @if (isExpanded()) {\n <svg [lucideIcon]=\"getIcon('minimize-2')\" class=\"w-4 h-4\"></svg>\n } @else {\n <svg [lucideIcon]=\"getIcon('maximize-2')\" class=\"w-4 h-4\"></svg>\n }\n </button>\n }\n <button\n type=\"button\"\n (click)=\"closeModal()\"\n class=\"p-1.5 rounded-lg hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 dark:[color:var(--shk-surface-500)] transition-colors\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n </div>\n\n <div class=\"overflow-y-auto px-6 py-4 flex-1 max-h-[70vh] _shk-scrollbar\">\n <ng-container #dynamicContent></ng-container>\n </div>\n\n @if (modalButtonsVisible()) {\n <hr class=\"border-t _shk-border dark:[border-color:var(--shk-surface-200)] shrink-0\" />\n <div class=\"flex justify-end gap-3 px-6 py-4 shrink-0\">\n <button\n type=\"button\"\n (click)=\"closeModal()\"\n [disabled]=\"loading()\"\n class=\"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 gap-2 disabled:opacity-50\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n <button\n type=\"button\"\n (click)=\"onAccept()\"\n [disabled]=\"loading()\"\n class=\"px-4 py-2 text-sm font-semibold _shk-text-white _shk-bg-emerald hover:[background-color:var(--shk-emerald-700)] rounded-lg shadow-md transition-all flex items-center gap-2 disabled:opacity-50\"\n >\n @if (loading()) {\n <svg [lucideIcon]=\"getIcon('loader-circle')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else {\n <svg [lucideIcon]=\"getIcon('check')\" class=\"w-4 h-4\"></svg>\n }\n {{ acceptLabel() }}\n </button>\n </div>\n }\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)}}.shk-modal-header{padding-top:1.25rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
293
- }
294
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: ModalComponent, decorators: [{
295
- type: Component,
296
- args: [{ selector: 'shk-modal', 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-40 p-4 pt-4 overflow-y-auto _shk-scrollbar\"\n (click)=\"closeModal()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-xl shadow-2xl overflow-hidden flex flex-col\"\n [class.w-[95vw]]=\"isExpanded()\"\n [class.h-[90vh]]=\"isExpanded()\"\n [class.w-full]=\"!isExpanded()\"\n [style.max-width]=\"isExpanded() ? undefined : computedModalWidth()\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"shk-modal-header flex items-center justify-between px-6 pt-4 pb-2 shrink-0\">\n <span class=\"font-semibold text-lg _shk-text-surface-800 dark:[color:var(--shk-surface-800)]\">{{ title() }}</span>\n <div class=\"flex items-center gap-2\">\n @if (showExpandButton()) {\n <button\n type=\"button\"\n (click)=\"toggleExpand()\"\n class=\"p-1.5 rounded-lg hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 dark:[color:var(--shk-surface-500)] transition-colors\"\n >\n @if (isExpanded()) {\n <svg [lucideIcon]=\"getIcon('minimize-2')\" class=\"w-4 h-4\"></svg>\n } @else {\n <svg [lucideIcon]=\"getIcon('maximize-2')\" class=\"w-4 h-4\"></svg>\n }\n </button>\n }\n <button\n type=\"button\"\n (click)=\"closeModal()\"\n class=\"p-1.5 rounded-lg hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 dark:[color:var(--shk-surface-500)] transition-colors\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n </div>\n\n <div class=\"overflow-y-auto px-6 py-4 flex-1 max-h-[70vh] _shk-scrollbar\">\n <ng-container #dynamicContent></ng-container>\n </div>\n\n @if (modalButtonsVisible()) {\n <hr class=\"border-t _shk-border dark:[border-color:var(--shk-surface-200)] shrink-0\" />\n <div class=\"flex justify-end gap-3 px-6 py-4 shrink-0\">\n <button\n type=\"button\"\n (click)=\"closeModal()\"\n [disabled]=\"loading()\"\n class=\"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 gap-2 disabled:opacity-50\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n <button\n type=\"button\"\n (click)=\"onAccept()\"\n [disabled]=\"loading()\"\n class=\"px-4 py-2 text-sm font-semibold _shk-text-white _shk-bg-emerald hover:[background-color:var(--shk-emerald-700)] rounded-lg shadow-md transition-all flex items-center gap-2 disabled:opacity-50\"\n >\n @if (loading()) {\n <svg [lucideIcon]=\"getIcon('loader-circle')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else {\n <svg [lucideIcon]=\"getIcon('check')\" class=\"w-4 h-4\"></svg>\n }\n {{ acceptLabel() }}\n </button>\n </div>\n }\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)}}.shk-modal-header{padding-top:1.25rem}\n"] }]
297
- }], ctorParameters: () => [], propDecorators: { container: [{ type: i0.ViewChild, args: ['dynamicContent', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
298
-
299
- /**
300
- * Generated bundle index. Do not edit.
301
- */
302
-
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, Injectable, ViewContainerRef, computed, effect, inject, signal, untracked, viewChild } from "@angular/core";
3
+ import { CommonModule } from "@angular/common";
4
+ import { LucideX, ShkIconDirective } from "shirkasoft-ui-components/icons";
5
+ import { TranslocoService } from "@jsverse/transloco";
6
+ import { Router } from "@angular/router";
7
+ import { NotificationService } from "shirkasoft-ui-components/notification";
8
+ import { getIcon } from "shirkasoft-ui-components/utils";
9
+ var ModalService = class ModalService {
10
+ constructor() {
11
+ this.stackSignal = signal([], ...ngDevMode ? [{ debugName: "stackSignal" }] : /* istanbul ignore next */ []);
12
+ this.closeRequestSignal = signal(0, ...ngDevMode ? [{ debugName: "closeRequestSignal" }] : /* istanbul ignore next */ []);
13
+ this.router = inject(Router);
14
+ this.destroyRef = inject(DestroyRef);
15
+ this.modalStack = computed(() => this.stackSignal(), ...ngDevMode ? [{ debugName: "modalStack" }] : /* istanbul ignore next */ []);
16
+ this.currentModal = computed(() => {
17
+ const stack = this.stackSignal();
18
+ return stack.length > 0 ? stack[stack.length - 1] : null;
19
+ }, ...ngDevMode ? [{ debugName: "currentModal" }] : /* istanbul ignore next */ []);
20
+ this.closeRequest = computed(() => this.closeRequestSignal(), ...ngDevMode ? [{ debugName: "closeRequest" }] : /* istanbul ignore next */ []);
21
+ this.router.events.subscribe(() => {
22
+ this.stackSignal.set([]);
23
+ });
24
+ this.destroyRef.onDestroy(() => this.stackSignal.set([]));
25
+ }
26
+ open(config) {
27
+ this.stackSignal.update((stack) => [...stack, config]);
28
+ }
29
+ accept() {
30
+ this.close();
31
+ }
32
+ close() {
33
+ const stack = this.stackSignal();
34
+ if (stack.length > 0) {
35
+ stack[stack.length - 1]?.onClose?.();
36
+ this.stackSignal.set(stack.slice(0, -1));
37
+ this.closeRequestSignal.update((v) => v + 1);
38
+ }
39
+ }
40
+ clear() {
41
+ this.stackSignal.set([]);
42
+ }
43
+ static {
44
+ this.ɵfac = i0.ɵɵngDeclareFactory({
45
+ minVersion: "12.0.0",
46
+ version: "22.3.2",
47
+ ngImport: i0,
48
+ type: ModalService,
49
+ deps: [],
50
+ target: i0.ɵɵFactoryTarget.Injectable
51
+ });
52
+ }
53
+ static {
54
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
55
+ minVersion: "12.0.0",
56
+ version: "22.3.2",
57
+ ngImport: i0,
58
+ type: ModalService,
59
+ providedIn: "root"
60
+ });
61
+ }
62
+ };
63
+ i0.ɵɵngDeclareClassMetadata({
64
+ minVersion: "12.0.0",
65
+ version: "22.3.2",
66
+ ngImport: i0,
67
+ type: ModalService,
68
+ decorators: [{
69
+ type: Injectable,
70
+ args: [{ providedIn: "root" }]
71
+ }],
72
+ ctorParameters: () => []
73
+ });
74
+ var ModalComponent = class ModalComponent {
75
+ constructor() {
76
+ this.getIcon = (name) => getIcon(name, LucideX);
77
+ this.notificationSrv = inject(NotificationService);
78
+ this.destroyRef = inject(DestroyRef);
79
+ this.modalSrv = inject(ModalService);
80
+ this.transloco = inject(TranslocoService);
81
+ this.cdr = inject(ChangeDetectorRef);
82
+ this.container = viewChild("dynamicContent", {
83
+ ...ngDevMode ? { debugName: "container" } : /* istanbul ignore next */ {},
84
+ read: ViewContainerRef
85
+ });
86
+ this.currentConfig = signal(null, ...ngDevMode ? [{ debugName: "currentConfig" }] : /* istanbul ignore next */ []);
87
+ this.title = signal("", ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
88
+ this.visible = signal(false, ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
89
+ this.loading = signal(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
90
+ this.isProcessing = signal(false, ...ngDevMode ? [{ debugName: "isProcessing" }] : /* istanbul ignore next */ []);
91
+ this.isExpanded = signal(false, ...ngDevMode ? [{ debugName: "isExpanded" }] : /* istanbul ignore next */ []);
92
+ this.isFormValid = signal(false, ...ngDevMode ? [{ debugName: "isFormValid" }] : /* istanbul ignore next */ []);
93
+ this.componentRef = null;
94
+ this.subscriptions = [];
95
+ this.computedModalWidth = computed(() => {
96
+ return this.isExpanded() ? "100vw" : this.currentConfig()?.width ?? "560px";
97
+ }, ...ngDevMode ? [{ debugName: "computedModalWidth" }] : /* istanbul ignore next */ []);
98
+ this.modalButtonsVisible = computed(() => this.currentConfig()?.showButtons ?? true, ...ngDevMode ? [{ debugName: "modalButtonsVisible" }] : /* istanbul ignore next */ []);
99
+ this.showExpandButton = computed(() => this.currentConfig()?.showExpandButton ?? false, ...ngDevMode ? [{ debugName: "showExpandButton" }] : /* istanbul ignore next */ []);
100
+ this.cancelLabel = computed(() => this.currentConfig()?.cancelLabel || "Cancelar", ...ngDevMode ? [{ debugName: "cancelLabel" }] : /* istanbul ignore next */ []);
101
+ this.acceptLabel = computed(() => this.currentConfig()?.acceptLabel || "Aceptar", ...ngDevMode ? [{ debugName: "acceptLabel" }] : /* istanbul ignore next */ []);
102
+ effect(() => {
103
+ const config = this.modalSrv.currentModal();
104
+ if (config) {
105
+ this.currentConfig.set(config);
106
+ this.title.set(config.title);
107
+ this.isExpanded.set(false);
108
+ this.visible.set(true);
109
+ this.isProcessing.set(false);
110
+ this.loading.set(false);
111
+ this.cdr.markForCheck();
112
+ setTimeout(() => {
113
+ untracked(() => this.loadComponent(config));
114
+ });
115
+ } else {
116
+ this.visible.set(false);
117
+ this.currentConfig.set(null);
118
+ this.cdr.markForCheck();
119
+ }
120
+ });
121
+ this.destroyRef.onDestroy(() => this.cleanup());
122
+ }
123
+ onVisibleChange(show) {
124
+ this.visible.set(show);
125
+ if (!show) this.closeModal();
126
+ this.cdr.markForCheck();
127
+ }
128
+ loadComponent(config) {
129
+ const containerRef = this.container();
130
+ if (!containerRef) return;
131
+ this.cleanup();
132
+ containerRef.clear();
133
+ this.componentRef = containerRef.createComponent(config.component);
134
+ if (config.data) Object.entries(config.data).forEach(([key, value]) => {
135
+ this.componentRef?.setInput(key, value);
136
+ });
137
+ const instance = this.componentRef.instance;
138
+ this.subscribeToOutput(instance.formValid, (valid) => {
139
+ this.isFormValid.set(valid);
140
+ this.cdr.markForCheck();
141
+ });
142
+ this.subscribeToOutput(instance.submitSuccess, (payload) => this.handleSubmit(true, payload));
143
+ this.subscribeToOutput(instance.submitError, () => this.handleSubmit(false));
144
+ this.componentRef.changeDetectorRef.markForCheck();
145
+ this.cdr.markForCheck();
146
+ }
147
+ subscribeToOutput(output, callback) {
148
+ if (output?.subscribe) this.subscriptions.push(output.subscribe(callback));
149
+ }
150
+ handleSubmit(success, payload) {
151
+ this.isProcessing.set(false);
152
+ this.loading.set(false);
153
+ this.cdr.markForCheck();
154
+ if (success) {
155
+ const onAccept = this.currentConfig()?.onAccept;
156
+ if (onAccept) untracked(() => onAccept(payload !== void 0 ? payload : this.getFormValue()));
157
+ untracked(() => this.modalSrv.accept());
158
+ }
159
+ }
160
+ getFormValue() {
161
+ const instance = this.componentRef?.instance;
162
+ const form = instance ? this.getForm(instance) : null;
163
+ if (!form) return void 0;
164
+ return this.isSignalField(form) ? form.value() : form.getRawValue?.();
165
+ }
166
+ closeModal() {
167
+ if (this.componentRef?.instance?.handleCancel) this.componentRef.instance.handleCancel();
168
+ this.doClose();
169
+ }
170
+ doClose() {
171
+ this.visible.set(false);
172
+ this.isProcessing.set(false);
173
+ this.loading.set(false);
174
+ if (this.isExpanded()) this.isExpanded.set(false);
175
+ this.cdr.markForCheck();
176
+ setTimeout(() => {
177
+ this.cleanup();
178
+ this.modalSrv.close();
179
+ }, 100);
180
+ }
181
+ toggleExpand() {
182
+ this.isExpanded.update((v) => !v);
183
+ this.cdr.markForCheck();
184
+ }
185
+ onAccept() {
186
+ if (!this.componentRef || !this.isDynamicComponent(this.componentRef.instance)) return;
187
+ if (this.isProcessing()) return;
188
+ const instance = this.componentRef.instance;
189
+ const form = this.getForm(instance);
190
+ if (form) {
191
+ if (this.isSignalField(form)) form.markAsTouched();
192
+ else this.markAllAsTouched(form);
193
+ this.componentRef.changeDetectorRef.markForCheck();
194
+ this.cdr.markForCheck();
195
+ if (this.isSignalField(form) ? form.errorSummary().some((error) => error.kind !== "warning") : this.hasRealErrors(form)) {
196
+ this.notificationSrv.addNotification(this.transloco.translate("modal.formInvalid"), "warning");
197
+ return;
198
+ }
199
+ }
200
+ this.isProcessing.set(true);
201
+ this.loading.set(true);
202
+ this.cdr.markForCheck();
203
+ instance.onSubmit();
204
+ }
205
+ getForm(instance) {
206
+ if (!instance["form"]) return null;
207
+ return typeof instance["form"] === "function" ? instance["form"]() : instance["form"];
208
+ }
209
+ isSignalField(form) {
210
+ return typeof form.errorSummary === "function";
211
+ }
212
+ hasRealErrors(control) {
213
+ const errors = control.errors;
214
+ if (errors && Object.keys(errors).some((key) => key !== "warning")) return true;
215
+ return this.childControls(control).some((child) => this.hasRealErrors(child));
216
+ }
217
+ markAllAsTouched(control) {
218
+ control.markAsTouched();
219
+ control.updateValueAndValidity({
220
+ onlySelf: true,
221
+ emitEvent: true
222
+ });
223
+ this.childControls(control).forEach((child) => this.markAllAsTouched(child));
224
+ }
225
+ childControls(control) {
226
+ if (!control.controls) return [];
227
+ return Array.isArray(control.controls) ? control.controls : Object.values(control.controls);
228
+ }
229
+ isDynamicComponent(instance) {
230
+ return typeof instance?.onSubmit === "function";
231
+ }
232
+ cleanup() {
233
+ this.subscriptions.forEach((sub) => sub.unsubscribe());
234
+ this.subscriptions = [];
235
+ if (this.componentRef) {
236
+ this.componentRef.destroy();
237
+ this.componentRef = null;
238
+ }
239
+ }
240
+ static {
241
+ this.ɵfac = i0.ɵɵngDeclareFactory({
242
+ minVersion: "12.0.0",
243
+ version: "22.3.2",
244
+ ngImport: i0,
245
+ type: ModalComponent,
246
+ deps: [],
247
+ target: i0.ɵɵFactoryTarget.Component
248
+ });
249
+ }
250
+ static {
251
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
252
+ minVersion: "17.0.0",
253
+ version: "22.3.2",
254
+ type: ModalComponent,
255
+ isStandalone: true,
256
+ selector: "shk-modal",
257
+ viewQueries: [{
258
+ propertyName: "container",
259
+ first: true,
260
+ predicate: ["dynamicContent"],
261
+ descendants: true,
262
+ read: ViewContainerRef,
263
+ isSignal: true
264
+ }],
265
+ ngImport: i0,
266
+ 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-40 p-4 pt-4 overflow-y-auto _shk-scrollbar\"\n (click)=\"closeModal()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-xl shadow-2xl overflow-hidden flex flex-col\"\n [class.w-[95vw]]=\"isExpanded()\"\n [class.h-[90vh]]=\"isExpanded()\"\n [class.w-full]=\"!isExpanded()\"\n [style.max-width]=\"isExpanded() ? undefined : computedModalWidth()\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"shk-modal-header flex items-center justify-between px-6 pt-4 pb-2 shrink-0\">\n <span class=\"font-semibold text-lg _shk-text-surface-800\">{{ title() }}</span>\n <div class=\"flex items-center gap-2\">\n @if (showExpandButton()) {\n <button\n type=\"button\"\n (click)=\"toggleExpand()\"\n class=\"p-1.5 rounded-lg hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 transition-colors\"\n >\n @if (isExpanded()) {\n <svg [shkIcon]=\"getIcon('minimize-2')\" class=\"w-4 h-4\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('maximize-2')\" class=\"w-4 h-4\"></svg>\n }\n </button>\n }\n <button\n type=\"button\"\n (click)=\"closeModal()\"\n class=\"p-1.5 rounded-lg hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n </div>\n\n <div class=\"overflow-y-auto px-6 py-4 flex-1 max-h-[70vh] _shk-scrollbar\">\n <ng-container #dynamicContent></ng-container>\n </div>\n\n @if (modalButtonsVisible()) {\n <hr class=\"border-t _shk-border shrink-0\" />\n <div class=\"flex justify-end gap-3 px-6 py-4 shrink-0\">\n <button\n type=\"button\"\n (click)=\"closeModal()\"\n [disabled]=\"loading()\"\n class=\"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 gap-2 disabled:opacity-50\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n <button\n type=\"button\"\n (click)=\"onAccept()\"\n [disabled]=\"loading()\"\n class=\"px-4 py-2 text-sm font-semibold _shk-text-white _shk-bg-emerald hover:[background-color:var(--shk-emerald-700)] rounded-lg shadow-md transition-all flex items-center gap-2 disabled:opacity-50\"\n >\n @if (loading()) {\n <svg [shkIcon]=\"getIcon('loader-circle')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('check')\" class=\"w-4 h-4\"></svg>\n }\n {{ acceptLabel() }}\n </button>\n </div>\n }\n </div>\n </div>\n}\n",
267
+ 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)}}.shk-modal-header{padding-top:1.25rem}\n"],
268
+ dependencies: [{
269
+ kind: "ngmodule",
270
+ type: CommonModule
271
+ }, {
272
+ kind: "directive",
273
+ type: ShkIconDirective,
274
+ selector: "svg[shkIcon]",
275
+ inputs: [
276
+ "shkIcon",
277
+ "size",
278
+ "strokeWidth",
279
+ "color"
280
+ ]
281
+ }],
282
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
283
+ });
284
+ }
285
+ };
286
+ i0.ɵɵngDeclareClassMetadata({
287
+ minVersion: "12.0.0",
288
+ version: "22.3.2",
289
+ ngImport: i0,
290
+ type: ModalComponent,
291
+ decorators: [{
292
+ type: Component,
293
+ args: [{
294
+ selector: "shk-modal",
295
+ imports: [CommonModule, ShkIconDirective],
296
+ changeDetection: ChangeDetectionStrategy.OnPush,
297
+ 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-40 p-4 pt-4 overflow-y-auto _shk-scrollbar\"\n (click)=\"closeModal()\"\n >\n <div\n class=\"shk-dialog-panel bg-white dark:[background-color:var(--shk-surface-100)] rounded-xl shadow-2xl overflow-hidden flex flex-col\"\n [class.w-[95vw]]=\"isExpanded()\"\n [class.h-[90vh]]=\"isExpanded()\"\n [class.w-full]=\"!isExpanded()\"\n [style.max-width]=\"isExpanded() ? undefined : computedModalWidth()\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"shk-modal-header flex items-center justify-between px-6 pt-4 pb-2 shrink-0\">\n <span class=\"font-semibold text-lg _shk-text-surface-800\">{{ title() }}</span>\n <div class=\"flex items-center gap-2\">\n @if (showExpandButton()) {\n <button\n type=\"button\"\n (click)=\"toggleExpand()\"\n class=\"p-1.5 rounded-lg hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 transition-colors\"\n >\n @if (isExpanded()) {\n <svg [shkIcon]=\"getIcon('minimize-2')\" class=\"w-4 h-4\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('maximize-2')\" class=\"w-4 h-4\"></svg>\n }\n </button>\n }\n <button\n type=\"button\"\n (click)=\"closeModal()\"\n class=\"p-1.5 rounded-lg hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] _shk-text-surface-500 transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n </div>\n\n <div class=\"overflow-y-auto px-6 py-4 flex-1 max-h-[70vh] _shk-scrollbar\">\n <ng-container #dynamicContent></ng-container>\n </div>\n\n @if (modalButtonsVisible()) {\n <hr class=\"border-t _shk-border shrink-0\" />\n <div class=\"flex justify-end gap-3 px-6 py-4 shrink-0\">\n <button\n type=\"button\"\n (click)=\"closeModal()\"\n [disabled]=\"loading()\"\n class=\"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 gap-2 disabled:opacity-50\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-4 h-4\"></svg>\n {{ cancelLabel() }}\n </button>\n <button\n type=\"button\"\n (click)=\"onAccept()\"\n [disabled]=\"loading()\"\n class=\"px-4 py-2 text-sm font-semibold _shk-text-white _shk-bg-emerald hover:[background-color:var(--shk-emerald-700)] rounded-lg shadow-md transition-all flex items-center gap-2 disabled:opacity-50\"\n >\n @if (loading()) {\n <svg [shkIcon]=\"getIcon('loader-circle')\" class=\"w-4 h-4 animate-spin\"></svg>\n } @else {\n <svg [shkIcon]=\"getIcon('check')\" class=\"w-4 h-4\"></svg>\n }\n {{ acceptLabel() }}\n </button>\n </div>\n }\n </div>\n </div>\n}\n",
298
+ 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)}}.shk-modal-header{padding-top:1.25rem}\n"]
299
+ }]
300
+ }],
301
+ ctorParameters: () => [],
302
+ propDecorators: { container: [{
303
+ type: i0.ViewChild,
304
+ args: ["dynamicContent", {
305
+ read: ViewContainerRef,
306
+ isSignal: true
307
+ }]
308
+ }] }
309
+ });
303
310
  export { ModalComponent, ModalService };
304
- //# sourceMappingURL=shirkasoft-ui-components-modal.mjs.map
311
+
312
+ //# sourceMappingURL=shirkasoft-ui-components-modal.mjs.map