@koalarx/ui
Version:
Koala UI is a modern and accessible component library designed to speed up interface development in Angular projects. With simple integration and clear documentation, you can easily build robust and visually appealing applications.
1 lines • 6.37 kB
Source Map (JSON)
{"version":3,"file":"koalarx-ui-shared-components-alert.mjs","sources":["../../projects/koala-ui/shared/components/alert/alert-content.ts","../../projects/koala-ui/shared/components/alert/alert-content.html","../../projects/koala-ui/shared/components/alert/alert.ts","../../projects/koala-ui/shared/components/alert/koalarx-ui-shared-components-alert.ts"],"sourcesContent":["import { Component, inject } from '@angular/core';\nimport {\n DIALOG_DATA,\n DialogContent,\n DialogRef,\n} from '@koalarx/ui/shared/components/dialog';\nimport { Button } from '@koalarx/ui/shared/directives';\nimport { AlertData } from './alert';\n\n@Component({\n selector: 'kl-alert-content',\n templateUrl: './alert-content.html',\n imports: [DialogContent, Button],\n})\nexport class AlertContent {\n private readonly dialogRef = inject(DialogRef);\n\n data = inject<AlertData>(DIALOG_DATA);\n\n close() {\n this.dialogRef.dismiss('close');\n }\n}\n","<kl-dialog-content>\n @if (data.title) {\n <h2>{{ data.title }}</h2>\n }\n\n <div class=\"flex flex-col items-center justify-center gap-4\" content>\n @switch (data.type) {\n @case ('info') {\n <i class=\"fa-solid fa-circle-info text-6xl text-indigo-500\"></i>\n }\n @case ('success') {\n <i class=\"fa-solid fa-circle-check text-6xl text-green-500\"></i>\n }\n @case ('warning') {\n <i class=\"fa-solid fa-triangle-exclamation text-6xl text-yellow-500\"></i>\n\n }\n @case ('error') {\n <i class=\"fa-solid fa-circle-xmark text-6xl text-red-500\"></i>\n }\n }\n\n <p [innerHTML]=\"data.message\"></p>\n </div>\n\n <div class=\"flex items-center justify-center w-full\" actions>\n <button klButton outline [color]=\"data.type\" (click)=\"close()\">\n {{ data.okButtonText ?? 'OK' }}\n </button>\n </div>\n</kl-dialog-content>\n","import { inject, Injectable } from '@angular/core';\nimport { Dialog } from '@koalarx/ui/shared/components/dialog';\nimport { AlertContent } from './alert-content';\n\nexport interface AlertData {\n type: 'info' | 'warning' | 'error' | 'success';\n message: string;\n title?: string;\n okButtonText?: string;\n}\n\nexport interface AlertConfig {\n data: AlertData;\n onClose?: () => void;\n}\n\nexport interface AlertOptions extends Omit<AlertData, 'type'> {\n onClose?: () => void;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class Alert {\n private readonly dialog = inject(Dialog);\n\n private open(config: AlertConfig) {\n this.dialog.open(AlertContent, {\n data: config.data,\n afterClosed: config.onClose\n ? {\n trigger: 'close',\n callback: config.onClose,\n }\n : undefined,\n });\n }\n\n success(options: AlertOptions) {\n this.open({\n data: {\n type: 'success',\n message: options.message,\n title: options.title,\n okButtonText: options.okButtonText,\n },\n onClose: options.onClose,\n });\n }\n\n error(options: AlertOptions) {\n this.open({\n data: {\n type: 'error',\n message: options.message,\n title: options.title,\n okButtonText: options.okButtonText,\n },\n onClose: options.onClose,\n });\n }\n\n info(options: AlertOptions) {\n this.open({\n data: {\n type: 'info',\n message: options.message,\n title: options.title,\n okButtonText: options.okButtonText,\n },\n onClose: options.onClose,\n });\n }\n\n warning(options: AlertOptions) {\n this.open({\n data: {\n type: 'warning',\n message: options.message,\n title: options.title,\n okButtonText: options.okButtonText,\n },\n onClose: options.onClose,\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAca,YAAY,CAAA;AACN,IAAA,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;AAE9C,IAAA,IAAI,GAAG,MAAM,CAAY,WAAW,CAAC;IAErC,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;;uGANtB,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAZ,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,Y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