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.
- package/README.md +4 -8
- package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs +189 -100
- package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-button.mjs +363 -69
- package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-chart.mjs +206 -142
- package/fesm2022/shirkasoft-ui-components-chart.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-config.mjs +905 -843
- package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +307 -142
- package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs +1624 -1440
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-fieldset.mjs +347 -92
- package/fesm2022/shirkasoft-ui-components-fieldset.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs +484 -300
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-icons.mjs +1028 -533
- package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-knob.mjs +389 -201
- package/fesm2022/shirkasoft-ui-components-knob.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-loading.mjs +505 -128
- package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-modal.mjs +311 -314
- package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-notification.mjs +188 -142
- package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-price-input.mjs +517 -327
- package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +669 -289
- package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-select.mjs +1014 -819
- package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-sidebar.mjs +508 -184
- package/fesm2022/shirkasoft-ui-components-sidebar.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-skeleton.mjs +197 -57
- package/fesm2022/shirkasoft-ui-components-skeleton.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-table.mjs +1916 -1698
- package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -175
- package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tag.mjs +175 -49
- package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-text-field.mjs +687 -402
- package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +310 -124
- package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-theme.mjs +141 -174
- package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -203
- package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-toggle.mjs +179 -109
- package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tooltip.mjs +244 -180
- package/fesm2022/shirkasoft-ui-components-tooltip.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs +95 -134
- package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -165
- package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components.mjs +0 -9
- package/package.json +5 -5
- package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
- package/types/shirkasoft-ui-components-button.d.ts +142 -49
- package/types/shirkasoft-ui-components-chart.d.ts +59 -44
- package/types/shirkasoft-ui-components-config.d.ts +193 -204
- package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -66
- package/types/shirkasoft-ui-components-date-picker.d.ts +527 -398
- package/types/shirkasoft-ui-components-fieldset.d.ts +135 -60
- package/types/shirkasoft-ui-components-file-upload.d.ts +176 -112
- package/types/shirkasoft-ui-components-icons.d.ts +1302 -1294
- package/types/shirkasoft-ui-components-knob.d.ts +144 -78
- package/types/shirkasoft-ui-components-loading.d.ts +155 -64
- package/types/shirkasoft-ui-components-modal.d.ts +134 -136
- package/types/shirkasoft-ui-components-notification.d.ts +63 -59
- package/types/shirkasoft-ui-components-price-input.d.ts +198 -113
- package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
- package/types/shirkasoft-ui-components-select.d.ts +301 -196
- package/types/shirkasoft-ui-components-sidebar.d.ts +198 -93
- package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
- package/types/shirkasoft-ui-components-table.d.ts +849 -660
- package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
- package/types/shirkasoft-ui-components-tag.d.ts +54 -23
- package/types/shirkasoft-ui-components-text-field.d.ts +231 -127
- package/types/shirkasoft-ui-components-theme-picker.d.ts +92 -58
- package/types/shirkasoft-ui-components-theme.d.ts +56 -64
- package/types/shirkasoft-ui-components-timeline.d.ts +325 -150
- package/types/shirkasoft-ui-components-toggle.d.ts +73 -49
- package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
- package/types/shirkasoft-ui-components-utils.d.ts +15 -16
- package/types/shirkasoft-ui-components-wizard.d.ts +236 -87
- package/types/shirkasoft-ui-components.d.ts +1 -2
- package/fesm2022/shirkasoft-ui-components.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-modal.mjs","sources":["../../../projects/ui-components/modal/modal.service.ts","../../../projects/ui-components/modal/modal.component.ts","../../../projects/ui-components/modal/modal.component.html","../../../projects/ui-components/modal/shirkasoft-ui-components-modal.ts"],"sourcesContent":["import { Injectable, Type, signal, computed, inject, DestroyRef } from '@angular/core';\nimport { Router } from '@angular/router';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/** Options for opening a modal through the service. */\nexport interface ModalConfig {\n /** Title shown in the modal header. */\n title: string;\n /** Component rendered inside the modal body. */\n component: Type<any>;\n /** Data passed to the modal component via inputs. */\n data?: Record<string, any>;\n /** Modal width (CSS value). */\n width?: string;\n /** Whether the accept/cancel buttons are shown. */\n showButtons?: boolean;\n /** Whether the expand (fullscreen) button is shown. */\n showExpandButton?: boolean;\n /** Label of the accept button. */\n acceptLabel?: string;\n /** Label of the cancel button. */\n cancelLabel?: string;\n /** Optional callback invoked when the modal closes. */\n onClose?: () => void;\n /**\n * Optional callback invoked when the modal is accepted, with the payload of\n * the dynamic component: the value emitted by its `submitSuccess` output or,\n * when it emits nothing, the raw value of its `form`. Omit it to keep the\n * previous behaviour.\n */\n onAccept?: (payload: any) => void;\n}\n\n/**\n * Global modal manager. Opens modals on a stack, exposing reactive access to\n * the current modal and the top-most opened config.\n */\n@Injectable({ providedIn: 'root' })\nexport class ModalService {\n /** Stack of open modals (top-most renders on top). */\n private stackSignal = signal<ModalConfig[]>([]);\n /** Counter emitted on each close, used to trigger close animations. */\n private closeRequestSignal = signal<number>(0);\n private router = inject(Router);\n private destroyRef = inject(DestroyRef);\n\n constructor() {\n // Close all modals on navigation and on service destruction.\n this.router.events.subscribe(() => {\n this.stackSignal.set([]);\n });\n this.destroyRef.onDestroy(() => this.stackSignal.set([]));\n }\n\n /** Reactive list of open modals. */\n modalStack = computed(() => this.stackSignal());\n /** Top-most modal on the stack, or null. */\n currentModal = computed<ModalConfig | null>(() => {\n const stack = this.stackSignal();\n return stack.length > 0 ? stack[stack.length - 1] : null;\n });\n /** Reactive close-request counter. */\n closeRequest = computed(() => this.closeRequestSignal());\n\n /** Opens a new modal on top of the stack. */\n open(config: ModalConfig) {\n this.stackSignal.update((stack) => [...stack, config]);\n }\n\n /** Alias of `close()` used by the accept button. */\n accept() {\n this.close();\n }\n\n /** Closes the top-most modal, invoking its onClose callback. */\n close() {\n const stack = this.stackSignal();\n if (stack.length > 0) {\n stack[stack.length - 1]?.onClose?.();\n this.stackSignal.set(stack.slice(0, -1));\n this.closeRequestSignal.update((v) => v + 1);\n }\n }\n\n /** Closes all open modals at once. */\n clear() {\n this.stackSignal.set([]);\n }\n}","import {\n Component,\n viewChild,\n ViewContainerRef,\n ComponentRef,\n inject,\n effect,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n signal,\n DestroyRef,\n computed,\n untracked,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport {\n ShkIconDirective,\n LucideX,\n} from 'shirkasoft-ui-components/icons';\nimport { Subscription } from 'rxjs';\nimport { TranslocoService } from '@jsverse/transloco';\nimport { ModalService, ModalConfig } from './modal.service';\nimport { NotificationService } from 'shirkasoft-ui-components/notification';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Minimal structural view of a reactive-form control.\n *\n * The modal only needs to walk errors and mark controls as touched, so it\n * checks the shape instead of importing `@angular/forms` at runtime. This\n * keeps the whole forms package out of apps that use the modal without forms.\n */\ninterface FormControlLike {\n errors: Record<string, unknown> | null;\n controls?: Record<string, FormControlLike> | FormControlLike[];\n markAsTouched(): void;\n updateValueAndValidity(options?: {\n onlySelf?: boolean;\n emitEvent?: boolean;\n }): void;\n getRawValue?(): unknown;\n}\n\n/**\n * Minimal structural view of an Angular Signal Forms `FieldState`\n * (what calling a `FieldTree` such as `form(model)` returns).\n */\ninterface SignalFieldStateLike {\n value(): unknown;\n errorSummary(): ReadonlyArray<{ kind: string }>;\n markAsTouched(): void;\n}\n\n/** A form the modal knows how to validate. */\ntype ModalForm = FormControlLike | SignalFieldStateLike;\n\n/**\n * Modal dialog that renders a dynamically loaded component, tracks its\n * form validity and submit outputs, and delegates accept/cancel to the\n * shared ModalService.\n */\n@Component({\n selector: 'shk-modal',\n imports: [CommonModule, ShkIconDirective],\n templateUrl: './modal.component.html',\n styles: [\n `\n /* Own enter animation (the animate-in/zoom-in utilities used before\n need a Tailwind plugin that isn't part of the library). */\n .shk-dialog-backdrop {\n animation: shk-dialog-fade 0.15s ease-out;\n }\n .shk-dialog-panel {\n border: 1px solid var(--shk-surface-200);\n box-shadow:\n 0 24px 48px -12px rgba(0, 0, 0, 0.25),\n 0 8px 16px -8px rgba(0, 0, 0, 0.1);\n animation: shk-dialog-in 0.2s cubic-bezier(0.21, 1.02, 0.73, 1);\n }\n :host-context(.dark) .shk-dialog-panel {\n box-shadow:\n 0 24px 48px -12px rgba(0, 0, 0, 0.7),\n 0 8px 16px -8px rgba(0, 0, 0, 0.5);\n }\n @keyframes shk-dialog-fade {\n from {\n opacity: 0;\n }\n }\n @keyframes shk-dialog-in {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.97);\n }\n }\n .shk-modal-header {\n padding-top: 1.25rem;\n }\n `,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ModalComponent {\n protected getIcon = (name: any) => getIconFromCentral(name, LucideX);\n\n private notificationSrv = inject(NotificationService);\n private destroyRef = inject(DestroyRef);\n private modalSrv = inject(ModalService);\n private transloco = inject(TranslocoService);\n private cdr = inject(ChangeDetectorRef);\n\n /** Reference where the dynamic content is rendered. */\n container = viewChild('dynamicContent', { read: ViewContainerRef });\n\n /** Configuration of the modal currently open (from the service). */\n currentConfig = signal<ModalConfig | null>(null);\n /** Modal title. */\n title = signal('');\n /** Whether the modal is visible. */\n visible = signal(false);\n /** Generic loading flag for the footer actions. */\n loading = signal(false);\n /** Whether the accept action is being processed. */\n isProcessing = signal(false);\n /** Whether the modal is currently expanded to fullscreen. */\n isExpanded = signal(false);\n /** True when the dynamic component reports a valid form. */\n isFormValid = signal(false);\n\n /** Reference to the dynamically created component. */\n componentRef: ComponentRef<any> | null = null;\n /** Subscriptions to the dynamic component outputs. */\n private subscriptions: Subscription[] = [];\n\n /** Width of the modal (fullscreen when expanded). */\n computedModalWidth = computed(() => {\n return this.isExpanded() ? '100vw' : (this.currentConfig()?.width ?? '560px');\n });\n\n /** Whether the footer buttons should be rendered. */\n modalButtonsVisible = computed(() => this.currentConfig()?.showButtons ?? true);\n /** Whether the expand/fullscreen button is shown. */\n showExpandButton = computed(() => this.currentConfig()?.showExpandButton ?? false);\n /** Resolved cancel button label. */\n cancelLabel = computed(() => this.currentConfig()?.cancelLabel || 'Cancelar');\n /** Resolved accept button label. */\n acceptLabel = computed(() => this.currentConfig()?.acceptLabel || 'Aceptar');\n\n constructor() {\n effect(() => {\n const config = this.modalSrv.currentModal();\n if (config) {\n this.currentConfig.set(config);\n this.title.set(config.title);\n this.isExpanded.set(false);\n this.visible.set(true);\n this.isProcessing.set(false);\n this.loading.set(false);\n this.cdr.markForCheck();\n setTimeout(() => {\n untracked(() => this.loadComponent(config));\n });\n } else {\n this.visible.set(false);\n this.currentConfig.set(null);\n this.cdr.markForCheck();\n }\n });\n\n this.destroyRef.onDestroy(() => this.cleanup());\n }\n\n /** Updates visibility when the backdrop/close controls change. */\n onVisibleChange(show: boolean) {\n this.visible.set(show);\n if (!show) {\n this.closeModal();\n }\n this.cdr.markForCheck();\n }\n\n /** Creates the dynamic component and wires its form/submit outputs. */\n private loadComponent(config: ModalConfig) {\n const containerRef = this.container();\n if (!containerRef) return;\n\n this.cleanup();\n containerRef.clear();\n\n this.componentRef = containerRef.createComponent(config.component);\n\n if (config.data) {\n Object.entries(config.data).forEach(([key, value]) => {\n this.componentRef?.setInput(key, value);\n });\n }\n\n const instance = this.componentRef.instance;\n\n this.subscribeToOutput(instance.formValid, (valid: boolean) => {\n this.isFormValid.set(valid);\n this.cdr.markForCheck();\n });\n this.subscribeToOutput(instance.submitSuccess, (payload: any) =>\n this.handleSubmit(true, payload),\n );\n this.subscribeToOutput(instance.submitError, () =>\n this.handleSubmit(false),\n );\n\n this.componentRef.changeDetectorRef.markForCheck();\n this.cdr.markForCheck();\n }\n\n /** Subscribes to a dynamic component output if it exists. */\n private subscribeToOutput(output: any, callback: (value: any) => void) {\n if (output?.subscribe) {\n this.subscriptions.push(output.subscribe(callback));\n }\n }\n\n /** Finalizes the submit flow, accepting the modal on success. */\n private handleSubmit(success: boolean, payload?: any) {\n this.isProcessing.set(false);\n this.loading.set(false);\n this.cdr.markForCheck();\n if (success) {\n // Hand the payload to `onAccept` (only when the modal config defines it).\n const onAccept = this.currentConfig()?.onAccept;\n if (onAccept) {\n untracked(() => onAccept(payload !== undefined ? payload : this.getFormValue()));\n }\n untracked(() => this.modalSrv.accept());\n }\n }\n\n /** Raw value of the dynamic component's form, or undefined when it has none. */\n private getFormValue(): any {\n const instance = this.componentRef?.instance;\n const form = instance ? this.getForm(instance) : null;\n if (!form) return undefined;\n return this.isSignalField(form) ? form.value() : form.getRawValue?.();\n }\n\n /** Closes the modal, calling the dynamic component's `handleCancel` if any. */\n closeModal() {\n if (this.componentRef?.instance?.handleCancel) {\n this.componentRef.instance.handleCancel();\n }\n this.doClose();\n }\n\n /** Performs the actual close sequence and cleanup. */\n doClose() {\n this.visible.set(false);\n this.isProcessing.set(false);\n this.loading.set(false);\n if (this.isExpanded()) {\n this.isExpanded.set(false);\n }\n this.cdr.markForCheck();\n setTimeout(() => {\n this.cleanup();\n this.modalSrv.close();\n }, 100);\n }\n\n /** Toggles between normal width and fullscreen. */\n toggleExpand() {\n this.isExpanded.update((v) => !v);\n this.cdr.markForCheck();\n }\n\n /** Validates the dynamic component form and triggers its `onSubmit`. */\n onAccept() {\n if (!this.componentRef || !this.isDynamicComponent(this.componentRef.instance)) return;\n\n if (this.isProcessing()) return;\n\n const instance = this.componentRef.instance;\n const form = this.getForm(instance);\n\n if (form) {\n // Signal Forms: markAsTouched() already cascades to every descendant.\n if (this.isSignalField(form)) form.markAsTouched();\n else this.markAllAsTouched(form);\n this.componentRef.changeDetectorRef.markForCheck();\n this.cdr.markForCheck();\n\n const invalid = this.isSignalField(form)\n ? form.errorSummary().some((error) => error.kind !== 'warning')\n : this.hasRealErrors(form);\n if (invalid) {\n this.notificationSrv.addNotification(\n this.transloco.translate('modal.formInvalid'),\n 'warning',\n );\n return;\n }\n }\n\n this.isProcessing.set(true);\n this.loading.set(true);\n this.cdr.markForCheck();\n instance.onSubmit();\n }\n\n /**\n * Resolves the dynamic component's form: a reactive form (property or getter\n * function) or a Signal Forms `FieldTree`, which is itself a function that\n * returns its `FieldState`.\n */\n private getForm(instance: any): ModalForm | null {\n if (!instance['form']) return null;\n return typeof instance['form'] === 'function'\n ? instance['form']()\n : instance['form'];\n }\n\n /** True when the form is a Signal Forms `FieldState`, not a reactive control. */\n private isSignalField(form: ModalForm): form is SignalFieldStateLike {\n return typeof (form as SignalFieldStateLike).errorSummary === 'function';\n }\n\n /** Recursively checks for real validation errors (ignoring 'warning'). */\n private hasRealErrors(control: FormControlLike): boolean {\n const errors = control.errors;\n if (errors && Object.keys(errors).some((key) => key !== 'warning')) {\n return true;\n }\n\n // A leaf control has no `controls`; groups and arrays do.\n return this.childControls(control).some((child) =>\n this.hasRealErrors(child),\n );\n }\n\n /** Marks a form (and all its descendants) as touched. */\n private markAllAsTouched(control: FormControlLike): void {\n control.markAsTouched();\n control.updateValueAndValidity({ onlySelf: true, emitEvent: true });\n\n this.childControls(control).forEach((child) =>\n this.markAllAsTouched(child),\n );\n }\n\n /** Normalizes `controls` (record for groups, array for form arrays). */\n private childControls(control: FormControlLike): FormControlLike[] {\n if (!control.controls) return [];\n return Array.isArray(control.controls)\n ? control.controls\n : Object.values(control.controls);\n }\n\n /**\n * True when the component exposes `onSubmit`. The `form` is optional:\n * without it, validation is skipped and `onSubmit` runs directly.\n */\n private isDynamicComponent(instance: any): boolean {\n return typeof instance?.onSubmit === 'function';\n }\n\n /** Unsubscribes outputs and destroys the dynamic component. */\n private cleanup() {\n this.subscriptions.forEach((sub) => sub.unsubscribe());\n this.subscriptions = [];\n\n if (this.componentRef) {\n this.componentRef.destroy();\n this.componentRef = null;\n }\n }\n}\n","@if (visible()) {\n <div\n class=\"shk-dialog-backdrop fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getIconFromCentral"],"mappings":";;;;;;;;;AAsCA;;;AAGG;MAEU,YAAY,CAAA;AAQvB,IAAA,WAAA,GAAA;;AANQ,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAgB,EAAE,kFAAC;;AAEvC,QAAA,IAAA,CAAA,k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A,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,cAAc,6JAUuB,gBAAgB,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECtHlE,u1GAyEA,EAAA,MAAA,EAAA,CAAA,wfAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDJY,YAAY,+BAAE,gBAAgB,EAAA,QAAA,EAAA,cAAA,EAAA,MAAA,EAAA,CAAA,SAAA,EAAA,MAAA,EAAA,aAAA,EAAA,OAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAuC7B,cAAc,EAAA,UAAA,EAAA,CAAA;kBAzC1B,SAAS;+BACE,WAAW,EAAA,OAAA,EACZ,CAAC,YAAY,EAAE,gBAAgB,CAAC,EAAA,eAAA,EAqCxB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,u1GAAA,EAAA,MAAA,EAAA,CAAA,wfAAA,CAAA,EAAA;AAYzB,SAAA,CAAA,EAAA,cAAA,EAAA,MAAA,EAAA,EAAA,cAAA,EAAA,EAAA,SAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,SAAA,EAAA,IAAA,EAAA,CAAA,gBAAgB,EAAA,EAAA,GAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEtHpE;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-modal.mjs","names":["getIconFromCentral"],"sources":["../../../projects/ui-components/modal/modal.service.ts","../../../projects/ui-components/modal/modal.component.ts","../../../projects/ui-components/modal/modal.component.html"],"sourcesContent":["import { Injectable, Type, signal, computed, inject, DestroyRef } from '@angular/core';\nimport { Router } from '@angular/router';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/** Options for opening a modal through the service. */\nexport interface ModalConfig {\n /** Title shown in the modal header. */\n title: string;\n /** Component rendered inside the modal body. */\n component: Type<any>;\n /** Data passed to the modal component via inputs. */\n data?: Record<string, any>;\n /** Modal width (CSS value). */\n width?: string;\n /** Whether the accept/cancel buttons are shown. */\n showButtons?: boolean;\n /** Whether the expand (fullscreen) button is shown. */\n showExpandButton?: boolean;\n /** Label of the accept button. */\n acceptLabel?: string;\n /** Label of the cancel button. */\n cancelLabel?: string;\n /** Optional callback invoked when the modal closes. */\n onClose?: () => void;\n /**\n * Optional callback invoked when the modal is accepted, with the payload of\n * the dynamic component: the value emitted by its `submitSuccess` output or,\n * when it emits nothing, the raw value of its `form`. Omit it to keep the\n * previous behaviour.\n */\n onAccept?: (payload: any) => void;\n}\n\n/**\n * Global modal manager. Opens modals on a stack, exposing reactive access to\n * the current modal and the top-most opened config.\n */\n@Injectable({ providedIn: 'root' })\nexport class ModalService {\n /** Stack of open modals (top-most renders on top). */\n private stackSignal = signal<ModalConfig[]>([]);\n /** Counter emitted on each close, used to trigger close animations. */\n private closeRequestSignal = signal<number>(0);\n private router = inject(Router);\n private destroyRef = inject(DestroyRef);\n\n constructor() {\n // Close all modals on navigation and on service destruction.\n this.router.events.subscribe(() => {\n this.stackSignal.set([]);\n });\n this.destroyRef.onDestroy(() => this.stackSignal.set([]));\n }\n\n /** Reactive list of open modals. */\n modalStack = computed(() => this.stackSignal());\n /** Top-most modal on the stack, or null. */\n currentModal = computed<ModalConfig | null>(() => {\n const stack = this.stackSignal();\n return stack.length > 0 ? stack[stack.length - 1] : null;\n });\n /** Reactive close-request counter. */\n closeRequest = computed(() => this.closeRequestSignal());\n\n /** Opens a new modal on top of the stack. */\n open(config: ModalConfig) {\n this.stackSignal.update((stack) => [...stack, config]);\n }\n\n /** Alias of `close()` used by the accept button. */\n accept() {\n this.close();\n }\n\n /** Closes the top-most modal, invoking its onClose callback. */\n close() {\n const stack = this.stackSignal();\n if (stack.length > 0) {\n stack[stack.length - 1]?.onClose?.();\n this.stackSignal.set(stack.slice(0, -1));\n this.closeRequestSignal.update((v) => v + 1);\n }\n }\n\n /** Closes all open modals at once. */\n clear() {\n this.stackSignal.set([]);\n }\n}","import {\n Component,\n viewChild,\n ViewContainerRef,\n ComponentRef,\n inject,\n effect,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n signal,\n DestroyRef,\n computed,\n untracked,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport {\n ShkIconDirective,\n LucideX,\n} from 'shirkasoft-ui-components/icons';\nimport { Subscription } from 'rxjs';\nimport { TranslocoService } from '@jsverse/transloco';\nimport { ModalService, ModalConfig } from './modal.service';\nimport { NotificationService } from 'shirkasoft-ui-components/notification';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Minimal structural view of a reactive-form control.\n *\n * The modal only needs to walk errors and mark controls as touched, so it\n * checks the shape instead of importing `@angular/forms` at runtime. This\n * keeps the whole forms package out of apps that use the modal without forms.\n */\ninterface FormControlLike {\n errors: Record<string, unknown> | null;\n controls?: Record<string, FormControlLike> | FormControlLike[];\n markAsTouched(): void;\n updateValueAndValidity(options?: {\n onlySelf?: boolean;\n emitEvent?: boolean;\n }): void;\n getRawValue?(): unknown;\n}\n\n/**\n * Minimal structural view of an Angular Signal Forms `FieldState`\n * (what calling a `FieldTree` such as `form(model)` returns).\n */\ninterface SignalFieldStateLike {\n value(): unknown;\n errorSummary(): ReadonlyArray<{ kind: string }>;\n markAsTouched(): void;\n}\n\n/** A form the modal knows how to validate. */\ntype ModalForm = FormControlLike | SignalFieldStateLike;\n\n/**\n * Modal dialog that renders a dynamically loaded component, tracks its\n * form validity and submit outputs, and delegates accept/cancel to the\n * shared ModalService.\n */\n@Component({\n selector: 'shk-modal',\n imports: [CommonModule, ShkIconDirective],\n templateUrl: './modal.component.html',\n styles: [\n `\n /* Own enter animation (the animate-in/zoom-in utilities used before\n need a Tailwind plugin that isn't part of the library). */\n .shk-dialog-backdrop {\n animation: shk-dialog-fade 0.15s ease-out;\n }\n .shk-dialog-panel {\n border: 1px solid var(--shk-surface-200);\n box-shadow:\n 0 24px 48px -12px rgba(0, 0, 0, 0.25),\n 0 8px 16px -8px rgba(0, 0, 0, 0.1);\n animation: shk-dialog-in 0.2s cubic-bezier(0.21, 1.02, 0.73, 1);\n }\n :host-context(.dark) .shk-dialog-panel {\n box-shadow:\n 0 24px 48px -12px rgba(0, 0, 0, 0.7),\n 0 8px 16px -8px rgba(0, 0, 0, 0.5);\n }\n @keyframes shk-dialog-fade {\n from {\n opacity: 0;\n }\n }\n @keyframes shk-dialog-in {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.97);\n }\n }\n .shk-modal-header {\n padding-top: 1.25rem;\n }\n `,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ModalComponent {\n protected getIcon = (name: any) => getIconFromCentral(name, LucideX);\n\n private notificationSrv = inject(NotificationService);\n private destroyRef = inject(DestroyRef);\n private modalSrv = inject(ModalService);\n private transloco = inject(TranslocoService);\n private cdr = inject(ChangeDetectorRef);\n\n /** Reference where the dynamic content is rendered. */\n container = viewChild('dynamicContent', { read: ViewContainerRef });\n\n /** Configuration of the modal currently open (from the service). */\n currentConfig = signal<ModalConfig | null>(null);\n /** Modal title. */\n title = signal('');\n /** Whether the modal is visible. */\n visible = signal(false);\n /** Generic loading flag for the footer actions. */\n loading = signal(false);\n /** Whether the accept action is being processed. */\n isProcessing = signal(false);\n /** Whether the modal is currently expanded to fullscreen. */\n isExpanded = signal(false);\n /** True when the dynamic component reports a valid form. */\n isFormValid = signal(false);\n\n /** Reference to the dynamically created component. */\n componentRef: ComponentRef<any> | null = null;\n /** Subscriptions to the dynamic component outputs. */\n private subscriptions: Subscription[] = [];\n\n /** Width of the modal (fullscreen when expanded). */\n computedModalWidth = computed(() => {\n return this.isExpanded() ? '100vw' : (this.currentConfig()?.width ?? '560px');\n });\n\n /** Whether the footer buttons should be rendered. */\n modalButtonsVisible = computed(() => this.currentConfig()?.showButtons ?? true);\n /** Whether the expand/fullscreen button is shown. */\n showExpandButton = computed(() => this.currentConfig()?.showExpandButton ?? false);\n /** Resolved cancel button label. */\n cancelLabel = computed(() => this.currentConfig()?.cancelLabel || 'Cancelar');\n /** Resolved accept button label. */\n acceptLabel = computed(() => this.currentConfig()?.acceptLabel || 'Aceptar');\n\n constructor() {\n effect(() => {\n const config = this.modalSrv.currentModal();\n if (config) {\n this.currentConfig.set(config);\n this.title.set(config.title);\n this.isExpanded.set(false);\n this.visible.set(true);\n this.isProcessing.set(false);\n this.loading.set(false);\n this.cdr.markForCheck();\n setTimeout(() => {\n untracked(() => this.loadComponent(config));\n });\n } else {\n this.visible.set(false);\n this.currentConfig.set(null);\n this.cdr.markForCheck();\n }\n });\n\n this.destroyRef.onDestroy(() => this.cleanup());\n }\n\n /** Updates visibility when the backdrop/close controls change. */\n onVisibleChange(show: boolean) {\n this.visible.set(show);\n if (!show) {\n this.closeModal();\n }\n this.cdr.markForCheck();\n }\n\n /** Creates the dynamic component and wires its form/submit outputs. */\n private loadComponent(config: ModalConfig) {\n const containerRef = this.container();\n if (!containerRef) return;\n\n this.cleanup();\n containerRef.clear();\n\n this.componentRef = containerRef.createComponent(config.component);\n\n if (config.data) {\n Object.entries(config.data).forEach(([key, value]) => {\n this.componentRef?.setInput(key, value);\n });\n }\n\n const instance = this.componentRef.instance;\n\n this.subscribeToOutput(instance.formValid, (valid: boolean) => {\n this.isFormValid.set(valid);\n this.cdr.markForCheck();\n });\n this.subscribeToOutput(instance.submitSuccess, (payload: any) =>\n this.handleSubmit(true, payload),\n );\n this.subscribeToOutput(instance.submitError, () =>\n this.handleSubmit(false),\n );\n\n this.componentRef.changeDetectorRef.markForCheck();\n this.cdr.markForCheck();\n }\n\n /** Subscribes to a dynamic component output if it exists. */\n private subscribeToOutput(output: any, callback: (value: any) => void) {\n if (output?.subscribe) {\n this.subscriptions.push(output.subscribe(callback));\n }\n }\n\n /** Finalizes the submit flow, accepting the modal on success. */\n private handleSubmit(success: boolean, payload?: any) {\n this.isProcessing.set(false);\n this.loading.set(false);\n this.cdr.markForCheck();\n if (success) {\n // Hand the payload to `onAccept` (only when the modal config defines it).\n const onAccept = this.currentConfig()?.onAccept;\n if (onAccept) {\n untracked(() => onAccept(payload !== undefined ? payload : this.getFormValue()));\n }\n untracked(() => this.modalSrv.accept());\n }\n }\n\n /** Raw value of the dynamic component's form, or undefined when it has none. */\n private getFormValue(): any {\n const instance = this.componentRef?.instance;\n const form = instance ? this.getForm(instance) : null;\n if (!form) return undefined;\n return this.isSignalField(form) ? form.value() : form.getRawValue?.();\n }\n\n /** Closes the modal, calling the dynamic component's `handleCancel` if any. */\n closeModal() {\n if (this.componentRef?.instance?.handleCancel) {\n this.componentRef.instance.handleCancel();\n }\n this.doClose();\n }\n\n /** Performs the actual close sequence and cleanup. */\n doClose() {\n this.visible.set(false);\n this.isProcessing.set(false);\n this.loading.set(false);\n if (this.isExpanded()) {\n this.isExpanded.set(false);\n }\n this.cdr.markForCheck();\n setTimeout(() => {\n this.cleanup();\n this.modalSrv.close();\n }, 100);\n }\n\n /** Toggles between normal width and fullscreen. */\n toggleExpand() {\n this.isExpanded.update((v) => !v);\n this.cdr.markForCheck();\n }\n\n /** Validates the dynamic component form and triggers its `onSubmit`. */\n onAccept() {\n if (!this.componentRef || !this.isDynamicComponent(this.componentRef.instance)) return;\n\n if (this.isProcessing()) return;\n\n const instance = this.componentRef.instance;\n const form = this.getForm(instance);\n\n if (form) {\n // Signal Forms: markAsTouched() already cascades to every descendant.\n if (this.isSignalField(form)) form.markAsTouched();\n else this.markAllAsTouched(form);\n this.componentRef.changeDetectorRef.markForCheck();\n this.cdr.markForCheck();\n\n const invalid = this.isSignalField(form)\n ? form.errorSummary().some((error) => error.kind !== 'warning')\n : this.hasRealErrors(form);\n if (invalid) {\n this.notificationSrv.addNotification(\n this.transloco.translate('modal.formInvalid'),\n 'warning',\n );\n return;\n }\n }\n\n this.isProcessing.set(true);\n this.loading.set(true);\n this.cdr.markForCheck();\n instance.onSubmit();\n }\n\n /**\n * Resolves the dynamic component's form: a reactive form (property or getter\n * function) or a Signal Forms `FieldTree`, which is itself a function that\n * returns its `FieldState`.\n */\n private getForm(instance: any): ModalForm | null {\n if (!instance['form']) return null;\n return typeof instance['form'] === 'function'\n ? instance['form']()\n : instance['form'];\n }\n\n /** True when the form is a Signal Forms `FieldState`, not a reactive control. */\n private isSignalField(form: ModalForm): form is SignalFieldStateLike {\n return typeof (form as SignalFieldStateLike).errorSummary === 'function';\n }\n\n /** Recursively checks for real validation errors (ignoring 'warning'). */\n private hasRealErrors(control: FormControlLike): boolean {\n const errors = control.errors;\n if (errors && Object.keys(errors).some((key) => key !== 'warning')) {\n return true;\n }\n\n // A leaf control has no `controls`; groups and arrays do.\n return this.childControls(control).some((child) =>\n this.hasRealErrors(child),\n );\n }\n\n /** Marks a form (and all its descendants) as touched. */\n private markAllAsTouched(control: FormControlLike): void {\n control.markAsTouched();\n control.updateValueAndValidity({ onlySelf: true, emitEvent: true });\n\n this.childControls(control).forEach((child) =>\n this.markAllAsTouched(child),\n );\n }\n\n /** Normalizes `controls` (record for groups, array for form arrays). */\n private childControls(control: FormControlLike): FormControlLike[] {\n if (!control.controls) return [];\n return Array.isArray(control.controls)\n ? control.controls\n : Object.values(control.controls);\n }\n\n /**\n * True when the component exposes `onSubmit`. The `form` is optional:\n * without it, validation is skipped and `onSubmit` runs directly.\n */\n private isDynamicComponent(instance: any): boolean {\n return typeof instance?.onSubmit === 'function';\n }\n\n /** Unsubscribes outputs and destroys the dynamic component. */\n private cleanup() {\n this.subscriptions.forEach((sub) => sub.unsubscribe());\n this.subscriptions = [];\n\n if (this.componentRef) {\n this.componentRef.destroy();\n this.componentRef = null;\n }\n }\n}\n","@if (visible()) {\n <div\n class=\"shk-dialog-backdrop fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-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"],"mappings":";;;;;;;;AA2CA,IAAa,eAAb,MAAa,aAAY;CAQvB,cAAA;EANQ,KAAA,cAAc,OAAsB,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;EAEvC,KAAA,qBAAqB,OAAe,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,qBAAA,CAAA,+BAAA,CAAA,CAAA;EACtC,KAAA,SAAS,OAAO,MAAM;EACtB,KAAA,aAAa,OAAO,UAAU;EAWtC,KAAA,aAAa,eAAe,KAAK,YAAW,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;EAE/C,KAAA,eAAe,eAAkC;GAC/C,MAAM,QAAQ,KAAK,YAAW;GAC9B,OAAO,MAAM,SAAS,IAAI,MAAM,MAAM,SAAS,KAAK;EACtD,GAAE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;AAuC7B,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAc,YAAA,CAAA;EAzC1B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAW,SACZ,CAAC,cAAc,gBAAgB;GAAC,iBAqCxB,wBAAwB;GAAM,UAAA;GAAA,QAAA,CAAA,wfAAA;EAAA,CAAA;CAYzB,CAAA;CAAA,sBAAA,CAAA;CAAA,gBAAA,EAAA,WAAA,CAAA;EAAA,MAAA,GAAA;EAAA,MAAA,CAAA,kBAAgB;GAAI,MAAM;GAAkB,UAAA;EAAA,CAAA;CAAA,CAAA,EAAA;AAAA,CAAA"}
|
|
@@ -1,143 +1,189 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import * as i1 from
|
|
4
|
-
import { CommonModule } from
|
|
5
|
-
import { LucideInfo, ShkIconDirective } from
|
|
6
|
-
import { getIcon } from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Injectable, computed, inject, input, signal } from "@angular/core";
|
|
3
|
+
import * as i1 from "@angular/common";
|
|
4
|
+
import { CommonModule } from "@angular/common";
|
|
5
|
+
import { LucideInfo, ShkIconDirective } from "shirkasoft-ui-components/icons";
|
|
6
|
+
import { getIcon } from "shirkasoft-ui-components/utils";
|
|
7
|
+
var NotificationService = class NotificationService {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.notificationsSignal = signal([], ...ngDevMode ? [{ debugName: "notificationsSignal" }] : /* istanbul ignore next */ []);
|
|
10
|
+
this.currentId = 0;
|
|
11
|
+
this.notifications = this.notificationsSignal.asReadonly();
|
|
12
|
+
}
|
|
13
|
+
addNotification(message, type = "info", showProgress = false, duration = 5e3) {
|
|
14
|
+
const id = (++this.currentId).toString();
|
|
15
|
+
const notification = {
|
|
16
|
+
id,
|
|
17
|
+
message,
|
|
18
|
+
type,
|
|
19
|
+
progress: showProgress ? 0 : void 0,
|
|
20
|
+
showProgress
|
|
21
|
+
};
|
|
22
|
+
this.notificationsSignal.update((notifications) => [...notifications, notification]);
|
|
23
|
+
if (duration > 0 && !showProgress) setTimeout(() => this.removeNotificationById(id), duration);
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
26
|
+
updateProgress(notificationId, progress) {
|
|
27
|
+
const currentNotifications = this.notificationsSignal();
|
|
28
|
+
const index = currentNotifications.findIndex((n) => n.id === notificationId);
|
|
29
|
+
if (index > -1 && currentNotifications[index].showProgress) {
|
|
30
|
+
const updatedProgress = Math.min(100, Math.max(0, progress));
|
|
31
|
+
this.notificationsSignal.update((notifications) => notifications.map((n, i) => i === index ? {
|
|
32
|
+
...n,
|
|
33
|
+
progress: updatedProgress
|
|
34
|
+
} : n));
|
|
35
|
+
if (progress >= 100) setTimeout(() => this.removeNotificationById(notificationId), 2e3);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
removeNotification(notification) {
|
|
39
|
+
this.removeNotificationById(notification.id);
|
|
40
|
+
}
|
|
41
|
+
removeNotificationById(notificationId) {
|
|
42
|
+
this.notificationsSignal.update((notifications) => notifications.filter((n) => n.id !== notificationId));
|
|
43
|
+
}
|
|
44
|
+
clearAll() {
|
|
45
|
+
this.notificationsSignal.set([]);
|
|
46
|
+
}
|
|
47
|
+
static {
|
|
48
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
49
|
+
minVersion: "12.0.0",
|
|
50
|
+
version: "22.3.2",
|
|
51
|
+
ngImport: i0,
|
|
52
|
+
type: NotificationService,
|
|
53
|
+
deps: [],
|
|
54
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
static {
|
|
58
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
59
|
+
minVersion: "12.0.0",
|
|
60
|
+
version: "22.3.2",
|
|
61
|
+
ngImport: i0,
|
|
62
|
+
type: NotificationService,
|
|
63
|
+
providedIn: "root"
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
68
|
+
minVersion: "12.0.0",
|
|
69
|
+
version: "22.3.2",
|
|
70
|
+
ngImport: i0,
|
|
71
|
+
type: NotificationService,
|
|
72
|
+
decorators: [{
|
|
73
|
+
type: Injectable,
|
|
74
|
+
args: [{ providedIn: "root" }]
|
|
75
|
+
}]
|
|
76
|
+
});
|
|
77
|
+
var NotificationComponent = class NotificationComponent {
|
|
78
|
+
constructor() {
|
|
79
|
+
this.position = input("center-top", ...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
|
|
80
|
+
this.notificationService = inject(NotificationService);
|
|
81
|
+
this.getIcon = (name) => getIcon(name, LucideInfo);
|
|
82
|
+
this.iconMap = {
|
|
83
|
+
success: "check",
|
|
84
|
+
error: "circle-x",
|
|
85
|
+
info: "info",
|
|
86
|
+
warning: "triangle-alert"
|
|
87
|
+
};
|
|
88
|
+
this.notifications = this.notificationService.notifications;
|
|
89
|
+
this.sortedNotifications = computed(() => [...this.notifications()].reverse(), ...ngDevMode ? [{ debugName: "sortedNotifications" }] : /* istanbul ignore next */ []);
|
|
90
|
+
this.hasNotifications = computed(() => this.notifications().length > 0, ...ngDevMode ? [{ debugName: "hasNotifications" }] : /* istanbul ignore next */ []);
|
|
91
|
+
this.positionClass = computed(() => {
|
|
92
|
+
const base = "fixed top-4 z-[9999] space-y-4 sm:space-y-6 sm:top-6 lg:top-8";
|
|
93
|
+
switch (this.position()) {
|
|
94
|
+
case "right-top": return `${base} right-4`;
|
|
95
|
+
case "left-top": return `${base} left-4`;
|
|
96
|
+
default: return `${base} left-1/2 -translate-x-1/2`;
|
|
97
|
+
}
|
|
98
|
+
}, ...ngDevMode ? [{ debugName: "positionClass" }] : /* istanbul ignore next */ []);
|
|
99
|
+
}
|
|
100
|
+
getNotificationIcon(type) {
|
|
101
|
+
return this.iconMap[type] || "info";
|
|
102
|
+
}
|
|
103
|
+
removeNotification(notification) {
|
|
104
|
+
this.notificationService.removeNotification(notification);
|
|
105
|
+
}
|
|
106
|
+
roundProgress(progress) {
|
|
107
|
+
return Math.round(progress || 0);
|
|
108
|
+
}
|
|
109
|
+
static {
|
|
110
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
111
|
+
minVersion: "12.0.0",
|
|
112
|
+
version: "22.3.2",
|
|
113
|
+
ngImport: i0,
|
|
114
|
+
type: NotificationComponent,
|
|
115
|
+
deps: [],
|
|
116
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
static {
|
|
120
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
121
|
+
minVersion: "17.0.0",
|
|
122
|
+
version: "22.3.2",
|
|
123
|
+
type: NotificationComponent,
|
|
124
|
+
isStandalone: true,
|
|
125
|
+
selector: "shk-notification",
|
|
126
|
+
inputs: { position: {
|
|
127
|
+
classPropertyName: "position",
|
|
128
|
+
publicName: "position",
|
|
129
|
+
isSignal: true,
|
|
130
|
+
isRequired: false,
|
|
131
|
+
transformFunction: null
|
|
132
|
+
} },
|
|
133
|
+
ngImport: i0,
|
|
134
|
+
template: "<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n class=\"shk-toast mb-4\"\n [ngClass]=\"'shk-toast-' + notification.type\"\n role=\"alert\"\n >\n <div class=\"shk-toast-icon\">\n <svg [shkIcon]=\"getIcon(getNotificationIcon(notification.type))\"></svg>\n </div>\n <div class=\"shk-toast-message\">\n {{ notification.message }}\n </div>\n <button\n type=\"button\"\n (click)=\"removeNotification(notification)\"\n aria-label=\"Close\"\n class=\"shk-toast-close\"\n >\n <svg [shkIcon]=\"getIcon('x')\"></svg>\n </button>\n </div>\n }\n</div>\n",
|
|
135
|
+
styles: [".shk-toast{--shk-toast-accent: var(--shk-info-600);display:flex;align-items:center;gap:.75rem;width:100%;min-width:320px;max-width:28rem;padding:.75rem .75rem .75rem .875rem;border-radius:.75rem;background-color:#fff;border:1px solid var(--shk-surface-200);color:var(--shk-surface-800);box-shadow:0 12px 32px -8px #0000002e,0 4px 10px -4px #00000014;animation:shk-toast-in .25s cubic-bezier(.21,1.02,.73,1)}:host-context(.dark) .shk-toast{background-color:var(--shk-surface-100);border-color:var(--shk-surface-200);box-shadow:0 12px 32px -8px #0009,0 4px 10px -4px #0006}.shk-toast-success{--shk-toast-accent: var(--shk-success-600)}.shk-toast-error{--shk-toast-accent: var(--shk-error-600)}:host-context(.dark) .shk-toast-error{--shk-toast-accent: var(--shk-error-500)}.shk-toast-warning{--shk-toast-accent: var(--shk-warning-600)}.shk-toast-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:2rem;border-radius:9999px;color:var(--shk-toast-accent);background-color:color-mix(in srgb,var(--shk-toast-accent) 14%,transparent)}.shk-toast-icon svg{width:1.125rem;height:1.125rem}.shk-toast-message{flex:1;min-width:0;font-size:.875rem;line-height:1.25rem;font-weight:500;overflow-wrap:break-word}.shk-toast-close{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1.75rem;height:1.75rem;border-radius:.375rem;background:transparent;color:var(--shk-surface-400);transition:background-color .15s ease,color .15s ease}.shk-toast-close:hover{color:var(--shk-surface-700);background-color:var(--shk-surface-100)}:host-context(.dark) .shk-toast-close:hover{background-color:var(--shk-surface-200)}.shk-toast-close:focus-visible{outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--shk-primary-500) 45%,transparent)}.shk-toast-close svg{width:1rem;height:1rem}@keyframes shk-toast-in{0%{opacity:0;transform:translateY(-8px) scale(.97)}}\n"],
|
|
136
|
+
dependencies: [
|
|
137
|
+
{
|
|
138
|
+
kind: "ngmodule",
|
|
139
|
+
type: CommonModule
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
kind: "directive",
|
|
143
|
+
type: i1.NgClass,
|
|
144
|
+
selector: "[ngClass]",
|
|
145
|
+
inputs: ["class", "ngClass"]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
kind: "directive",
|
|
149
|
+
type: ShkIconDirective,
|
|
150
|
+
selector: "svg[shkIcon]",
|
|
151
|
+
inputs: [
|
|
152
|
+
"shkIcon",
|
|
153
|
+
"size",
|
|
154
|
+
"strokeWidth",
|
|
155
|
+
"color"
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
164
|
+
minVersion: "12.0.0",
|
|
165
|
+
version: "22.3.2",
|
|
166
|
+
ngImport: i0,
|
|
167
|
+
type: NotificationComponent,
|
|
168
|
+
decorators: [{
|
|
169
|
+
type: Component,
|
|
170
|
+
args: [{
|
|
171
|
+
selector: "shk-notification",
|
|
172
|
+
imports: [CommonModule, ShkIconDirective],
|
|
173
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
174
|
+
template: "<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n class=\"shk-toast mb-4\"\n [ngClass]=\"'shk-toast-' + notification.type\"\n role=\"alert\"\n >\n <div class=\"shk-toast-icon\">\n <svg [shkIcon]=\"getIcon(getNotificationIcon(notification.type))\"></svg>\n </div>\n <div class=\"shk-toast-message\">\n {{ notification.message }}\n </div>\n <button\n type=\"button\"\n (click)=\"removeNotification(notification)\"\n aria-label=\"Close\"\n class=\"shk-toast-close\"\n >\n <svg [shkIcon]=\"getIcon('x')\"></svg>\n </button>\n </div>\n }\n</div>\n",
|
|
175
|
+
styles: [".shk-toast{--shk-toast-accent: var(--shk-info-600);display:flex;align-items:center;gap:.75rem;width:100%;min-width:320px;max-width:28rem;padding:.75rem .75rem .75rem .875rem;border-radius:.75rem;background-color:#fff;border:1px solid var(--shk-surface-200);color:var(--shk-surface-800);box-shadow:0 12px 32px -8px #0000002e,0 4px 10px -4px #00000014;animation:shk-toast-in .25s cubic-bezier(.21,1.02,.73,1)}:host-context(.dark) .shk-toast{background-color:var(--shk-surface-100);border-color:var(--shk-surface-200);box-shadow:0 12px 32px -8px #0009,0 4px 10px -4px #0006}.shk-toast-success{--shk-toast-accent: var(--shk-success-600)}.shk-toast-error{--shk-toast-accent: var(--shk-error-600)}:host-context(.dark) .shk-toast-error{--shk-toast-accent: var(--shk-error-500)}.shk-toast-warning{--shk-toast-accent: var(--shk-warning-600)}.shk-toast-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:2rem;border-radius:9999px;color:var(--shk-toast-accent);background-color:color-mix(in srgb,var(--shk-toast-accent) 14%,transparent)}.shk-toast-icon svg{width:1.125rem;height:1.125rem}.shk-toast-message{flex:1;min-width:0;font-size:.875rem;line-height:1.25rem;font-weight:500;overflow-wrap:break-word}.shk-toast-close{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1.75rem;height:1.75rem;border-radius:.375rem;background:transparent;color:var(--shk-surface-400);transition:background-color .15s ease,color .15s ease}.shk-toast-close:hover{color:var(--shk-surface-700);background-color:var(--shk-surface-100)}:host-context(.dark) .shk-toast-close:hover{background-color:var(--shk-surface-200)}.shk-toast-close:focus-visible{outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--shk-primary-500) 45%,transparent)}.shk-toast-close svg{width:1rem;height:1rem}@keyframes shk-toast-in{0%{opacity:0;transform:translateY(-8px) scale(.97)}}\n"]
|
|
176
|
+
}]
|
|
177
|
+
}],
|
|
178
|
+
propDecorators: { position: [{
|
|
179
|
+
type: i0.Input,
|
|
180
|
+
args: [{
|
|
181
|
+
isSignal: true,
|
|
182
|
+
alias: "position",
|
|
183
|
+
required: false
|
|
184
|
+
}]
|
|
185
|
+
}] }
|
|
186
|
+
});
|
|
142
187
|
export { NotificationComponent, NotificationService };
|
|
143
|
-
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=shirkasoft-ui-components-notification.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-notification.mjs","sources":["../../../projects/ui-components/notification/notification.service.ts","../../../projects/ui-components/notification/notification.component.ts","../../../projects/ui-components/notification/notification.component.html","../../../projects/ui-components/notification/shirkasoft-ui-components-notification.ts"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/** Toast-style notification entry. */\nexport interface Notification {\n id: string;\n message: string;\n type: 'success' | 'error' | 'warning' | 'info';\n /** Current progress 0-100 when `showProgress` is true. */\n progress?: number;\n /** Whether the notification renders a progress indicator. */\n showProgress?: boolean;\n}\n\n/**\n * Central notification store. Components push/update/remove notifications\n * reactively through signals for the notification component to render.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class NotificationService {\n /** Reactive list of visible notifications. */\n private notificationsSignal = signal<Notification[]>([]);\n /** Monotonic id counter for new notifications. */\n private currentId = 0;\n\n /** Readonly reactive list of visible notifications. */\n notifications = this.notificationsSignal.asReadonly();\n\n /**\n * Adds a notification and returns its id. When `showProgress` is false and\n * `duration` is positive, it auto-removes after that many ms.\n */\n addNotification(\n message: string,\n type: Notification['type'] = 'info',\n showProgress: boolean = false,\n duration: number = 5000\n ): string {\n const id = (++this.currentId).toString();\n const notification: Notification = {\n id,\n message,\n type,\n progress: showProgress ? 0 : undefined,\n showProgress,\n };\n\n this.notificationsSignal.update((notifications) => [\n ...notifications,\n notification,\n ]);\n\n if (duration > 0 && !showProgress) {\n setTimeout(() => this.removeNotificationById(id), duration);\n }\n\n return id;\n }\n\n /** Updates a progress notification; auto-removes when progress hits 100. */\n updateProgress(notificationId: string, progress: number) {\n const currentNotifications = this.notificationsSignal();\n const index = currentNotifications.findIndex(\n (n) => n.id === notificationId\n );\n\n if (index > -1 && currentNotifications[index].showProgress) {\n const updatedProgress = Math.min(100, Math.max(0, progress));\n\n this.notificationsSignal.update((notifications) =>\n notifications.map((n, i) =>\n i === index ? { ...n, progress: updatedProgress } : n\n )\n );\n\n if (progress >= 100) {\n setTimeout(() => this.removeNotificationById(notificationId), 2000);\n }\n }\n }\n\n /** Removes the given notification. */\n removeNotification(notification: Notification): void {\n this.removeNotificationById(notification.id);\n }\n\n /** Removes the notification with the given id. */\n removeNotificationById(notificationId: string): void {\n this.notificationsSignal.update((notifications) =>\n notifications.filter((n) => n.id !== notificationId)\n );\n }\n\n /** Removes every visible notification. */\n clearAll(): void {\n this.notificationsSignal.set([]);\n }\n}","import {\n Component,\n input,\n inject,\n ChangeDetectionStrategy,\n computed,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport {\n NotificationService,\n Notification,\n} from './notification.service';\nimport {\n ShkIconDirective,\n LucideInfo,\n LucideTriangleAlert,\n} from 'shirkasoft-ui-components/icons';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\nexport type NotificationPosition = 'center-top' | 'right-top' | 'left-top';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Toast notification host that renders the notifications pushed through the\n * NotificationService in the configured position.\n */\n@Component({\n selector: 'shk-notification',\n templateUrl: './notification.component.html',\n imports: [CommonModule, ShkIconDirective],\n changeDetection: ChangeDetectionStrategy.OnPush,\n styles: [\n `\n .shk-toast {\n --shk-toast-accent: var(--shk-info-600);\n display: flex;\n align-items: center;\n gap: 0.75rem;\n width: 100%;\n min-width: 320px;\n max-width: 28rem;\n padding: 0.75rem 0.75rem 0.75rem 0.875rem;\n border-radius: 0.75rem;\n background-color: #fff;\n border: 1px solid var(--shk-surface-200);\n color: var(--shk-surface-800);\n box-shadow:\n 0 12px 32px -8px rgba(0, 0, 0, 0.18),\n 0 4px 10px -4px rgba(0, 0, 0, 0.08);\n animation: shk-toast-in 0.25s cubic-bezier(0.21, 1.02, 0.73, 1);\n }\n :host-context(.dark) .shk-toast {\n background-color: var(--shk-surface-100);\n border-color: var(--shk-surface-200);\n box-shadow:\n 0 12px 32px -8px rgba(0, 0, 0, 0.6),\n 0 4px 10px -4px rgba(0, 0, 0, 0.4);\n }\n .shk-toast-success {\n --shk-toast-accent: var(--shk-success-600);\n }\n .shk-toast-error {\n --shk-toast-accent: var(--shk-error-600);\n }\n :host-context(.dark) .shk-toast-error {\n --shk-toast-accent: var(--shk-error-500);\n }\n .shk-toast-warning {\n --shk-toast-accent: var(--shk-warning-600);\n }\n .shk-toast-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 2rem;\n height: 2rem;\n border-radius: 9999px;\n color: var(--shk-toast-accent);\n background-color: color-mix(in srgb, var(--shk-toast-accent) 14%, transparent);\n }\n .shk-toast-icon svg {\n width: 1.125rem;\n height: 1.125rem;\n }\n .shk-toast-message {\n flex: 1;\n min-width: 0;\n font-size: 0.875rem;\n line-height: 1.25rem;\n font-weight: 500;\n overflow-wrap: break-word;\n }\n .shk-toast-close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 1.75rem;\n height: 1.75rem;\n border-radius: 0.375rem;\n background: transparent;\n color: var(--shk-surface-400);\n transition:\n background-color 0.15s ease,\n color 0.15s ease;\n }\n .shk-toast-close:hover {\n color: var(--shk-surface-700);\n background-color: var(--shk-surface-100);\n }\n :host-context(.dark) .shk-toast-close:hover {\n background-color: var(--shk-surface-200);\n }\n .shk-toast-close:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--shk-primary-500) 45%, transparent);\n }\n .shk-toast-close svg {\n width: 1rem;\n height: 1rem;\n }\n @keyframes shk-toast-in {\n from {\n opacity: 0;\n transform: translateY(-8px) scale(0.97);\n }\n }\n `,\n ],\n})\nexport class NotificationComponent {\n /** Position of the notification stack: center, right or left top. */\n position = input<NotificationPosition>('center-top');\n\n private notificationService = inject(NotificationService);\n protected getIcon = (name: any) => getIconFromCentral(name, LucideInfo);\n\n /** Maps each notification type to its internal icon name. */\n private readonly iconMap: Record<string, string> = {\n success: 'check',\n error: 'circle-x',\n info: 'info',\n warning: 'triangle-alert',\n };\n\n /** Resolves the icon name for a notification type. */\n getNotificationIcon(type: string): string {\n return this.iconMap[type] || 'info';\n }\n\n /** Live list of active notifications. */\n notifications = this.notificationService.notifications;\n\n /** Notifications sorted with the newest first. */\n sortedNotifications = computed(\n () => [...this.notifications()].reverse(),\n );\n\n /** Removes a notification through the service. */\n removeNotification(notification: Notification): void {\n this.notificationService.removeNotification(notification);\n }\n\n /** Rounds the progress value of a notification. */\n roundProgress(progress: number | undefined): number {\n return Math.round(progress || 0);\n }\n\n /** Whether there are notifications to show. */\n hasNotifications = computed(() => this.notifications().length > 0);\n\n /** CSS classes positioning the stack according to `position`. */\n positionClass = computed(() => {\n const base = 'fixed top-4 z-[9999] space-y-4 sm:space-y-6 sm:top-6 lg:top-8';\n switch (this.position()) {\n case 'right-top':\n return `${base} right-4`;\n case 'left-top':\n return `${base} left-4`;\n default:\n return `${base} left-1/2 -translate-x-1/2`;\n }\n });\n}\n","<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n class=\"shk-toast mb-4\"\n [ngClass]=\"'shk-toast-' + notification.type\"\n role=\"alert\"\n >\n <div class=\"shk-toast-icon\">\n <svg [shkIcon]=\"getIcon(getNotificationIcon(notification.type))\"></svg>\n </div>\n <div class=\"shk-toast-message\">\n {{ notification.message }}\n </div>\n <button\n type=\"button\"\n (click)=\"removeNotification(notification)\"\n aria-label=\"Close\"\n class=\"shk-toast-close\"\n >\n <svg [shkIcon]=\"getIcon('x')\"></svg>\n </button>\n </div>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getIconFromCentral"],"mappings":";;;;;;;AAmBA;;;AAGG;MAIU,mBAAmB,CAAA;AAHhC,IAAA,WAAA,GAAA;;AAKU,QAAA,IAAA,CAAA,mBAAmB,GAAG,MAAM,CAAiB,EAAE,0FAAC;;QAEhD,IAAA,CAAA,SAAS,GAAG,CAAC;;AAGrB,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE;AAuEtD,IAAA;AArEC;;;AAGG;IACH,eAAe,CACb,OAAe,EACf,IAAA,GAA6B,MAAM,EACnC,YAAA,GAAwB,KAAK,EAC7B,QAAA,GAAmB,IAAI,EAAA;QAEvB,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE;AACxC,QAAA,MAAM,YAAY,GAAiB;YACjC,EAAE;YACF,OAAO;YACP,IAAI;YACJ,QAAQ,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS;YACtC,YAAY;SACb;QAED,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,aAAa,KAAK;AACjD,YAAA,GAAG,aAAa;YAChB,YAAY;AACb,SAAA,CAAC;AAEF,QAAA,IAAI,QAAQ,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE;AACjC,YAAA,UAAU,CAAC,MAAM,IAAI,CAAC,sBAAsB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;QAC7D;AAEA,QAAA,OAAO,EAAE;IACX;;IAGA,cAAc,CAAC,cAAsB,EAAE,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EAAA,UAAA,EAAA,IAAA,EDUY,YAAY,6HAAE,gBAAgB,EAAA,QAAA,EAAA,cAAA,EAAA,MAAA,EAAA,CAAA,SAAA,EAAA,MAAA,EAAA,aAAA,EAAA,OAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAsG7B,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAzGjC,SAAS;+BACE,kBAAkB,EAAA,OAAA,EAEnB,CAAC,YAAY,EAAE,gBAAgB,CAAC,EAAA,eAAA,EACxB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,+sBAAA,EAAA,MAAA,EAAA,CAAA,23DAAA,CAAA,EAAA;;;AEnCjD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-notification.mjs","names":["getIconFromCentral"],"sources":["../../../projects/ui-components/notification/notification.service.ts","../../../projects/ui-components/notification/notification.component.ts","../../../projects/ui-components/notification/notification.component.html"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/** Toast-style notification entry. */\nexport interface Notification {\n id: string;\n message: string;\n type: 'success' | 'error' | 'warning' | 'info';\n /** Current progress 0-100 when `showProgress` is true. */\n progress?: number;\n /** Whether the notification renders a progress indicator. */\n showProgress?: boolean;\n}\n\n/**\n * Central notification store. Components push/update/remove notifications\n * reactively through signals for the notification component to render.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class NotificationService {\n /** Reactive list of visible notifications. */\n private notificationsSignal = signal<Notification[]>([]);\n /** Monotonic id counter for new notifications. */\n private currentId = 0;\n\n /** Readonly reactive list of visible notifications. */\n notifications = this.notificationsSignal.asReadonly();\n\n /**\n * Adds a notification and returns its id. When `showProgress` is false and\n * `duration` is positive, it auto-removes after that many ms.\n */\n addNotification(\n message: string,\n type: Notification['type'] = 'info',\n showProgress: boolean = false,\n duration: number = 5000\n ): string {\n const id = (++this.currentId).toString();\n const notification: Notification = {\n id,\n message,\n type,\n progress: showProgress ? 0 : undefined,\n showProgress,\n };\n\n this.notificationsSignal.update((notifications) => [\n ...notifications,\n notification,\n ]);\n\n if (duration > 0 && !showProgress) {\n setTimeout(() => this.removeNotificationById(id), duration);\n }\n\n return id;\n }\n\n /** Updates a progress notification; auto-removes when progress hits 100. */\n updateProgress(notificationId: string, progress: number) {\n const currentNotifications = this.notificationsSignal();\n const index = currentNotifications.findIndex(\n (n) => n.id === notificationId\n );\n\n if (index > -1 && currentNotifications[index].showProgress) {\n const updatedProgress = Math.min(100, Math.max(0, progress));\n\n this.notificationsSignal.update((notifications) =>\n notifications.map((n, i) =>\n i === index ? { ...n, progress: updatedProgress } : n\n )\n );\n\n if (progress >= 100) {\n setTimeout(() => this.removeNotificationById(notificationId), 2000);\n }\n }\n }\n\n /** Removes the given notification. */\n removeNotification(notification: Notification): void {\n this.removeNotificationById(notification.id);\n }\n\n /** Removes the notification with the given id. */\n removeNotificationById(notificationId: string): void {\n this.notificationsSignal.update((notifications) =>\n notifications.filter((n) => n.id !== notificationId)\n );\n }\n\n /** Removes every visible notification. */\n clearAll(): void {\n this.notificationsSignal.set([]);\n }\n}","import {\n Component,\n input,\n inject,\n ChangeDetectionStrategy,\n computed,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport {\n NotificationService,\n Notification,\n} from './notification.service';\nimport {\n ShkIconDirective,\n LucideInfo,\n LucideTriangleAlert,\n} from 'shirkasoft-ui-components/icons';\nimport { getIcon as getIconFromCentral } from 'shirkasoft-ui-components/utils';\n\nexport type NotificationPosition = 'center-top' | 'right-top' | 'left-top';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Toast notification host that renders the notifications pushed through the\n * NotificationService in the configured position.\n */\n@Component({\n selector: 'shk-notification',\n templateUrl: './notification.component.html',\n imports: [CommonModule, ShkIconDirective],\n changeDetection: ChangeDetectionStrategy.OnPush,\n styles: [\n `\n .shk-toast {\n --shk-toast-accent: var(--shk-info-600);\n display: flex;\n align-items: center;\n gap: 0.75rem;\n width: 100%;\n min-width: 320px;\n max-width: 28rem;\n padding: 0.75rem 0.75rem 0.75rem 0.875rem;\n border-radius: 0.75rem;\n background-color: #fff;\n border: 1px solid var(--shk-surface-200);\n color: var(--shk-surface-800);\n box-shadow:\n 0 12px 32px -8px rgba(0, 0, 0, 0.18),\n 0 4px 10px -4px rgba(0, 0, 0, 0.08);\n animation: shk-toast-in 0.25s cubic-bezier(0.21, 1.02, 0.73, 1);\n }\n :host-context(.dark) .shk-toast {\n background-color: var(--shk-surface-100);\n border-color: var(--shk-surface-200);\n box-shadow:\n 0 12px 32px -8px rgba(0, 0, 0, 0.6),\n 0 4px 10px -4px rgba(0, 0, 0, 0.4);\n }\n .shk-toast-success {\n --shk-toast-accent: var(--shk-success-600);\n }\n .shk-toast-error {\n --shk-toast-accent: var(--shk-error-600);\n }\n :host-context(.dark) .shk-toast-error {\n --shk-toast-accent: var(--shk-error-500);\n }\n .shk-toast-warning {\n --shk-toast-accent: var(--shk-warning-600);\n }\n .shk-toast-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 2rem;\n height: 2rem;\n border-radius: 9999px;\n color: var(--shk-toast-accent);\n background-color: color-mix(in srgb, var(--shk-toast-accent) 14%, transparent);\n }\n .shk-toast-icon svg {\n width: 1.125rem;\n height: 1.125rem;\n }\n .shk-toast-message {\n flex: 1;\n min-width: 0;\n font-size: 0.875rem;\n line-height: 1.25rem;\n font-weight: 500;\n overflow-wrap: break-word;\n }\n .shk-toast-close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 1.75rem;\n height: 1.75rem;\n border-radius: 0.375rem;\n background: transparent;\n color: var(--shk-surface-400);\n transition:\n background-color 0.15s ease,\n color 0.15s ease;\n }\n .shk-toast-close:hover {\n color: var(--shk-surface-700);\n background-color: var(--shk-surface-100);\n }\n :host-context(.dark) .shk-toast-close:hover {\n background-color: var(--shk-surface-200);\n }\n .shk-toast-close:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--shk-primary-500) 45%, transparent);\n }\n .shk-toast-close svg {\n width: 1rem;\n height: 1rem;\n }\n @keyframes shk-toast-in {\n from {\n opacity: 0;\n transform: translateY(-8px) scale(0.97);\n }\n }\n `,\n ],\n})\nexport class NotificationComponent {\n /** Position of the notification stack: center, right or left top. */\n position = input<NotificationPosition>('center-top');\n\n private notificationService = inject(NotificationService);\n protected getIcon = (name: any) => getIconFromCentral(name, LucideInfo);\n\n /** Maps each notification type to its internal icon name. */\n private readonly iconMap: Record<string, string> = {\n success: 'check',\n error: 'circle-x',\n info: 'info',\n warning: 'triangle-alert',\n };\n\n /** Resolves the icon name for a notification type. */\n getNotificationIcon(type: string): string {\n return this.iconMap[type] || 'info';\n }\n\n /** Live list of active notifications. */\n notifications = this.notificationService.notifications;\n\n /** Notifications sorted with the newest first. */\n sortedNotifications = computed(\n () => [...this.notifications()].reverse(),\n );\n\n /** Removes a notification through the service. */\n removeNotification(notification: Notification): void {\n this.notificationService.removeNotification(notification);\n }\n\n /** Rounds the progress value of a notification. */\n roundProgress(progress: number | undefined): number {\n return Math.round(progress || 0);\n }\n\n /** Whether there are notifications to show. */\n hasNotifications = computed(() => this.notifications().length > 0);\n\n /** CSS classes positioning the stack according to `position`. */\n positionClass = computed(() => {\n const base = 'fixed top-4 z-[9999] space-y-4 sm:space-y-6 sm:top-6 lg:top-8';\n switch (this.position()) {\n case 'right-top':\n return `${base} right-4`;\n case 'left-top':\n return `${base} left-4`;\n default:\n return `${base} left-1/2 -translate-x-1/2`;\n }\n });\n}\n","<div [class]=\"positionClass()\">\n @for (notification of sortedNotifications(); track notification.id) {\n <div\n class=\"shk-toast mb-4\"\n [ngClass]=\"'shk-toast-' + notification.type\"\n role=\"alert\"\n >\n <div class=\"shk-toast-icon\">\n <svg [shkIcon]=\"getIcon(getNotificationIcon(notification.type))\"></svg>\n </div>\n <div class=\"shk-toast-message\">\n {{ notification.message }}\n </div>\n <button\n type=\"button\"\n (click)=\"removeNotification(notification)\"\n aria-label=\"Close\"\n class=\"shk-toast-close\"\n >\n <svg [shkIcon]=\"getIcon('x')\"></svg>\n </button>\n </div>\n }\n</div>\n"],"mappings":";;;;;;AA0BA,IAAa,sBAAb,MAAa,oBAAmB;CAHhC,cAAA;EAKU,KAAA,sBAAsB,OAAuB,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,sBAAA,CAAA,+BAAA,CAAA,CAAA;EAEhD,KAAA,YAAY;EAGpB,KAAA,gBAAgB,KAAK,oBAAoB,WAAU;CAuEpD;CAjEC,gBACE,SACA,OAA6B,QAC7B,eAAwB,OACxB,WAAmB,KAAI;EAEvB,MAAM,MAAM,EAAE,KAAK,UAAA,CAAW,SAAQ;EACtC,MAAM,eAA6B;GACjC;GACA;GACA;GACA,UAAU,eAAe,IAAI;GAC7B;EACD;EAED,KAAK,oBAAoB,QAAQ,kBAAkB,CACjD,GAAG,eACH,YACD,CAAA;EAED,IAAI,WAAW,KAAK,CAAC,cACnB,iBAAiB,KAAK,uBAAuB,EAAE,GAAG,QAAQ;EAG5D,OAAO;CACT;CAGA,eAAe,gBAAwB,UAAgB;EACrD,MAAM,uBAAuB,KAAK,oBAAmB;EACrD,MAAM,QAAQ,qBAAqB,WAChC,MAAM,EAAE,OAAO,cAAc;EAGhC,IAAI,QAAQ,MAAM,qBAAqB,MAAM,CAAC,cAAc;GAC1D,MAAM,kBAAkB,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,QAAQ,CAAC;GAE3D,KAAK,oBAAoB,QAAQ,kBAC/B,cAAc,KAAK,GAAG,MACpB,MAAM,QAAQ;IAAE,GAAG;IAAG,UAAU;GAAe,IAAK,CAAC,C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