shirkasoft-ui-components 1.14.0 → 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 (92) hide show
  1. package/README.md +4 -8
  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 +363 -69
  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 +905 -843
  9. package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -1
  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 -1440
  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 -300
  17. package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
  18. package/fesm2022/shirkasoft-ui-components-icons.mjs +1028 -533
  19. package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -1
  20. package/fesm2022/shirkasoft-ui-components-knob.mjs +389 -201
  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 -314
  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 -327
  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 -819
  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 +1916 -1698
  39. package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
  40. package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -175
  41. package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
  42. package/fesm2022/shirkasoft-ui-components-tag.mjs +175 -49
  43. package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
  44. package/fesm2022/shirkasoft-ui-components-text-field.mjs +687 -402
  45. package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
  46. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +310 -124
  47. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -1
  48. package/fesm2022/shirkasoft-ui-components-theme.mjs +141 -174
  49. package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -1
  50. package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -203
  51. package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
  52. package/fesm2022/shirkasoft-ui-components-toggle.mjs +179 -109
  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 +95 -134
  57. package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
  58. package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -165
  59. package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
  60. package/fesm2022/shirkasoft-ui-components.mjs +0 -9
  61. package/package.json +5 -5
  62. package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
  63. package/types/shirkasoft-ui-components-button.d.ts +142 -49
  64. package/types/shirkasoft-ui-components-chart.d.ts +59 -44
  65. package/types/shirkasoft-ui-components-config.d.ts +193 -204
  66. package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -66
  67. package/types/shirkasoft-ui-components-date-picker.d.ts +527 -398
  68. package/types/shirkasoft-ui-components-fieldset.d.ts +135 -60
  69. package/types/shirkasoft-ui-components-file-upload.d.ts +176 -112
  70. package/types/shirkasoft-ui-components-icons.d.ts +1302 -1294
  71. package/types/shirkasoft-ui-components-knob.d.ts +144 -78
  72. package/types/shirkasoft-ui-components-loading.d.ts +155 -64
  73. package/types/shirkasoft-ui-components-modal.d.ts +134 -136
  74. package/types/shirkasoft-ui-components-notification.d.ts +63 -59
  75. package/types/shirkasoft-ui-components-price-input.d.ts +198 -113
  76. package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
  77. package/types/shirkasoft-ui-components-select.d.ts +301 -196
  78. package/types/shirkasoft-ui-components-sidebar.d.ts +198 -93
  79. package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
  80. package/types/shirkasoft-ui-components-table.d.ts +849 -660
  81. package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
  82. package/types/shirkasoft-ui-components-tag.d.ts +54 -23
  83. package/types/shirkasoft-ui-components-text-field.d.ts +231 -127
  84. package/types/shirkasoft-ui-components-theme-picker.d.ts +92 -58
  85. package/types/shirkasoft-ui-components-theme.d.ts +56 -64
  86. package/types/shirkasoft-ui-components-timeline.d.ts +325 -150
  87. package/types/shirkasoft-ui-components-toggle.d.ts +73 -49
  88. package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
  89. package/types/shirkasoft-ui-components-utils.d.ts +15 -16
  90. package/types/shirkasoft-ui-components-wizard.d.ts +236 -87
  91. package/types/shirkasoft-ui-components.d.ts +1 -2
  92. package/fesm2022/shirkasoft-ui-components.mjs.map +0 -1
@@ -1,315 +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, 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
-
10
- /**
11
- * Global modal manager. Opens modals on a stack, exposing reactive access to
12
- * the current modal and the top-most opened config.
13
- */
14
- class ModalService {
15
- constructor() {
16
- /** Stack of open modals (top-most renders on top). */
17
- this.stackSignal = signal([], ...(ngDevMode ? [{ debugName: "stackSignal" }] : /* istanbul ignore next */ []));
18
- /** Counter emitted on each close, used to trigger close animations. */
19
- this.closeRequestSignal = signal(0, ...(ngDevMode ? [{ debugName: "closeRequestSignal" }] : /* istanbul ignore next */ []));
20
- this.router = inject(Router);
21
- this.destroyRef = inject(DestroyRef);
22
- /** Reactive list of open modals. */
23
- this.modalStack = computed(() => this.stackSignal(), ...(ngDevMode ? [{ debugName: "modalStack" }] : /* istanbul ignore next */ []));
24
- /** Top-most modal on the stack, or null. */
25
- this.currentModal = computed(() => {
26
- const stack = this.stackSignal();
27
- return stack.length > 0 ? stack[stack.length - 1] : null;
28
- }, ...(ngDevMode ? [{ debugName: "currentModal" }] : /* istanbul ignore next */ []));
29
- /** Reactive close-request counter. */
30
- this.closeRequest = computed(() => this.closeRequestSignal(), ...(ngDevMode ? [{ debugName: "closeRequest" }] : /* istanbul ignore next */ []));
31
- // Close all modals on navigation and on service destruction.
32
- this.router.events.subscribe(() => {
33
- this.stackSignal.set([]);
34
- });
35
- this.destroyRef.onDestroy(() => this.stackSignal.set([]));
36
- }
37
- /** Opens a new modal on top of the stack. */
38
- open(config) {
39
- this.stackSignal.update((stack) => [...stack, config]);
40
- }
41
- /** Alias of `close()` used by the accept button. */
42
- accept() {
43
- this.close();
44
- }
45
- /** Closes the top-most modal, invoking its onClose callback. */
46
- close() {
47
- const stack = this.stackSignal();
48
- if (stack.length > 0) {
49
- stack[stack.length - 1]?.onClose?.();
50
- this.stackSignal.set(stack.slice(0, -1));
51
- this.closeRequestSignal.update((v) => v + 1);
52
- }
53
- }
54
- /** Closes all open modals at once. */
55
- clear() {
56
- this.stackSignal.set([]);
57
- }
58
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: ModalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
59
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: ModalService, providedIn: 'root' }); }
60
- }
61
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: ModalService, decorators: [{
62
- type: Injectable,
63
- args: [{ providedIn: 'root' }]
64
- }], ctorParameters: () => [] });
65
-
66
- /**
67
- * Modal dialog that renders a dynamically loaded component, tracks its
68
- * form validity and submit outputs, and delegates accept/cancel to the
69
- * shared ModalService.
70
- */
71
- class ModalComponent {
72
- constructor() {
73
- this.getIcon = (name) => getIcon(name, LucideX);
74
- this.notificationSrv = inject(NotificationService);
75
- this.destroyRef = inject(DestroyRef);
76
- this.modalSrv = inject(ModalService);
77
- this.transloco = inject(TranslocoService);
78
- this.cdr = inject(ChangeDetectorRef);
79
- /** Reference where the dynamic content is rendered. */
80
- this.container = viewChild('dynamicContent', { ...(ngDevMode ? { debugName: "container" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
81
- /** Configuration of the modal currently open (from the service). */
82
- this.currentConfig = signal(null, ...(ngDevMode ? [{ debugName: "currentConfig" }] : /* istanbul ignore next */ []));
83
- /** Modal title. */
84
- this.title = signal('', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
85
- /** Whether the modal is visible. */
86
- this.visible = signal(false, ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
87
- /** Generic loading flag for the footer actions. */
88
- this.loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
89
- /** Whether the accept action is being processed. */
90
- this.isProcessing = signal(false, ...(ngDevMode ? [{ debugName: "isProcessing" }] : /* istanbul ignore next */ []));
91
- /** Whether the modal is currently expanded to fullscreen. */
92
- this.isExpanded = signal(false, ...(ngDevMode ? [{ debugName: "isExpanded" }] : /* istanbul ignore next */ []));
93
- /** True when the dynamic component reports a valid form. */
94
- this.isFormValid = signal(false, ...(ngDevMode ? [{ debugName: "isFormValid" }] : /* istanbul ignore next */ []));
95
- /** Reference to the dynamically created component. */
96
- this.componentRef = null;
97
- /** Subscriptions to the dynamic component outputs. */
98
- this.subscriptions = [];
99
- /** Width of the modal (fullscreen when expanded). */
100
- this.computedModalWidth = computed(() => {
101
- return this.isExpanded() ? '100vw' : (this.currentConfig()?.width ?? '560px');
102
- }, ...(ngDevMode ? [{ debugName: "computedModalWidth" }] : /* istanbul ignore next */ []));
103
- /** Whether the footer buttons should be rendered. */
104
- this.modalButtonsVisible = computed(() => this.currentConfig()?.showButtons ?? true, ...(ngDevMode ? [{ debugName: "modalButtonsVisible" }] : /* istanbul ignore next */ []));
105
- /** Whether the expand/fullscreen button is shown. */
106
- this.showExpandButton = computed(() => this.currentConfig()?.showExpandButton ?? false, ...(ngDevMode ? [{ debugName: "showExpandButton" }] : /* istanbul ignore next */ []));
107
- /** Resolved cancel button label. */
108
- this.cancelLabel = computed(() => this.currentConfig()?.cancelLabel || 'Cancelar', ...(ngDevMode ? [{ debugName: "cancelLabel" }] : /* istanbul ignore next */ []));
109
- /** Resolved accept button label. */
110
- this.acceptLabel = computed(() => this.currentConfig()?.acceptLabel || 'Aceptar', ...(ngDevMode ? [{ debugName: "acceptLabel" }] : /* istanbul ignore next */ []));
111
- effect(() => {
112
- const config = this.modalSrv.currentModal();
113
- if (config) {
114
- this.currentConfig.set(config);
115
- this.title.set(config.title);
116
- this.isExpanded.set(false);
117
- this.visible.set(true);
118
- this.isProcessing.set(false);
119
- this.loading.set(false);
120
- this.cdr.markForCheck();
121
- setTimeout(() => {
122
- untracked(() => this.loadComponent(config));
123
- });
124
- }
125
- else {
126
- this.visible.set(false);
127
- this.currentConfig.set(null);
128
- this.cdr.markForCheck();
129
- }
130
- });
131
- this.destroyRef.onDestroy(() => this.cleanup());
132
- }
133
- /** Updates visibility when the backdrop/close controls change. */
134
- onVisibleChange(show) {
135
- this.visible.set(show);
136
- if (!show) {
137
- this.closeModal();
138
- }
139
- this.cdr.markForCheck();
140
- }
141
- /** Creates the dynamic component and wires its form/submit outputs. */
142
- loadComponent(config) {
143
- const containerRef = this.container();
144
- if (!containerRef)
145
- return;
146
- this.cleanup();
147
- containerRef.clear();
148
- this.componentRef = containerRef.createComponent(config.component);
149
- if (config.data) {
150
- Object.entries(config.data).forEach(([key, value]) => {
151
- this.componentRef?.setInput(key, value);
152
- });
153
- }
154
- const instance = this.componentRef.instance;
155
- this.subscribeToOutput(instance.formValid, (valid) => {
156
- this.isFormValid.set(valid);
157
- this.cdr.markForCheck();
158
- });
159
- this.subscribeToOutput(instance.submitSuccess, (payload) => this.handleSubmit(true, payload));
160
- this.subscribeToOutput(instance.submitError, () => this.handleSubmit(false));
161
- this.componentRef.changeDetectorRef.markForCheck();
162
- this.cdr.markForCheck();
163
- }
164
- /** Subscribes to a dynamic component output if it exists. */
165
- subscribeToOutput(output, callback) {
166
- if (output?.subscribe) {
167
- this.subscriptions.push(output.subscribe(callback));
168
- }
169
- }
170
- /** Finalizes the submit flow, accepting the modal on success. */
171
- handleSubmit(success, payload) {
172
- this.isProcessing.set(false);
173
- this.loading.set(false);
174
- this.cdr.markForCheck();
175
- if (success) {
176
- // Hand the payload to `onAccept` (only when the modal config defines it).
177
- const onAccept = this.currentConfig()?.onAccept;
178
- if (onAccept) {
179
- untracked(() => onAccept(payload !== undefined ? payload : this.getFormValue()));
180
- }
181
- untracked(() => this.modalSrv.accept());
182
- }
183
- }
184
- /** Raw value of the dynamic component's form, or undefined when it has none. */
185
- getFormValue() {
186
- const instance = this.componentRef?.instance;
187
- const form = instance ? this.getForm(instance) : null;
188
- if (!form)
189
- return undefined;
190
- return this.isSignalField(form) ? form.value() : form.getRawValue?.();
191
- }
192
- /** Closes the modal, calling the dynamic component's `handleCancel` if any. */
193
- closeModal() {
194
- if (this.componentRef?.instance?.handleCancel) {
195
- this.componentRef.instance.handleCancel();
196
- }
197
- this.doClose();
198
- }
199
- /** Performs the actual close sequence and cleanup. */
200
- doClose() {
201
- this.visible.set(false);
202
- this.isProcessing.set(false);
203
- this.loading.set(false);
204
- if (this.isExpanded()) {
205
- this.isExpanded.set(false);
206
- }
207
- this.cdr.markForCheck();
208
- setTimeout(() => {
209
- this.cleanup();
210
- this.modalSrv.close();
211
- }, 100);
212
- }
213
- /** Toggles between normal width and fullscreen. */
214
- toggleExpand() {
215
- this.isExpanded.update((v) => !v);
216
- this.cdr.markForCheck();
217
- }
218
- /** Validates the dynamic component form and triggers its `onSubmit`. */
219
- onAccept() {
220
- if (!this.componentRef || !this.isDynamicComponent(this.componentRef.instance))
221
- return;
222
- if (this.isProcessing())
223
- return;
224
- const instance = this.componentRef.instance;
225
- const form = this.getForm(instance);
226
- if (form) {
227
- // Signal Forms: markAsTouched() already cascades to every descendant.
228
- if (this.isSignalField(form))
229
- form.markAsTouched();
230
- else
231
- this.markAllAsTouched(form);
232
- this.componentRef.changeDetectorRef.markForCheck();
233
- this.cdr.markForCheck();
234
- const invalid = this.isSignalField(form)
235
- ? form.errorSummary().some((error) => error.kind !== 'warning')
236
- : this.hasRealErrors(form);
237
- if (invalid) {
238
- this.notificationSrv.addNotification(this.transloco.translate('modal.formInvalid'), 'warning');
239
- return;
240
- }
241
- }
242
- this.isProcessing.set(true);
243
- this.loading.set(true);
244
- this.cdr.markForCheck();
245
- instance.onSubmit();
246
- }
247
- /**
248
- * Resolves the dynamic component's form: a reactive form (property or getter
249
- * function) or a Signal Forms `FieldTree`, which is itself a function that
250
- * returns its `FieldState`.
251
- */
252
- getForm(instance) {
253
- if (!instance['form'])
254
- return null;
255
- return typeof instance['form'] === 'function'
256
- ? instance['form']()
257
- : instance['form'];
258
- }
259
- /** True when the form is a Signal Forms `FieldState`, not a reactive control. */
260
- isSignalField(form) {
261
- return typeof form.errorSummary === 'function';
262
- }
263
- /** Recursively checks for real validation errors (ignoring 'warning'). */
264
- hasRealErrors(control) {
265
- const errors = control.errors;
266
- if (errors && Object.keys(errors).some((key) => key !== 'warning')) {
267
- return true;
268
- }
269
- // A leaf control has no `controls`; groups and arrays do.
270
- return this.childControls(control).some((child) => this.hasRealErrors(child));
271
- }
272
- /** Marks a form (and all its descendants) as touched. */
273
- markAllAsTouched(control) {
274
- control.markAsTouched();
275
- control.updateValueAndValidity({ onlySelf: true, emitEvent: true });
276
- this.childControls(control).forEach((child) => this.markAllAsTouched(child));
277
- }
278
- /** Normalizes `controls` (record for groups, array for form arrays). */
279
- childControls(control) {
280
- if (!control.controls)
281
- return [];
282
- return Array.isArray(control.controls)
283
- ? control.controls
284
- : Object.values(control.controls);
285
- }
286
- /**
287
- * True when the component exposes `onSubmit`. The `form` is optional:
288
- * without it, validation is skipped and `onSubmit` runs directly.
289
- */
290
- isDynamicComponent(instance) {
291
- return typeof instance?.onSubmit === 'function';
292
- }
293
- /** Unsubscribes outputs and destroys the dynamic component. */
294
- cleanup() {
295
- this.subscriptions.forEach((sub) => sub.unsubscribe());
296
- this.subscriptions = [];
297
- if (this.componentRef) {
298
- this.componentRef.destroy();
299
- this.componentRef = null;
300
- }
301
- }
302
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: ModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
303
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.27", 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\">{{ 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", 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: "directive", type: ShkIconDirective, selector: "svg[shkIcon]", inputs: ["shkIcon", "size", "strokeWidth", "color"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
304
- }
305
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: ModalComponent, decorators: [{
306
- type: Component,
307
- args: [{ selector: 'shk-modal', imports: [CommonModule, ShkIconDirective], 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\">{{ 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", 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"] }]
308
- }], ctorParameters: () => [], propDecorators: { container: [{ type: i0.ViewChild, args: ['dynamicContent', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
309
-
310
- /**
311
- * Generated bundle index. Do not edit.
312
- */
313
-
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
+ });
314
310
  export { ModalComponent, ModalService };
315
- //# sourceMappingURL=shirkasoft-ui-components-modal.mjs.map
311
+
312
+ //# sourceMappingURL=shirkasoft-ui-components-modal.mjs.map