@xui/alert 2.0.0-alpha.19 → 2.0.0-alpha.21
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/fesm2022/xui-alert.mjs +10 -0
- package/fesm2022/xui-alert.mjs.map +1 -1
- package/package.json +4 -4
- package/types/xui-alert.d.ts +10 -0
package/fesm2022/xui-alert.mjs
CHANGED
|
@@ -49,21 +49,31 @@ const XUI_ALERT_OPTIONS = new InjectionToken('XuiAlertOptions');
|
|
|
49
49
|
class XuiAlert {
|
|
50
50
|
wasOpen = false;
|
|
51
51
|
settled = false;
|
|
52
|
+
/** Whether the alert is showing. Two-way bindable with `[(open)]`. */
|
|
52
53
|
open = model(false, /* @ts-ignore */
|
|
53
54
|
...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
55
|
+
/**
|
|
56
|
+
* Intent of the alert. Also picks the default icon and the confirm button's colour, and promotes the dialog to
|
|
57
|
+
* `role="alert"` for `error` and `warning`.
|
|
58
|
+
*/
|
|
54
59
|
color = input('none', /* @ts-ignore */
|
|
55
60
|
...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
56
61
|
/** Override the icon the color implies. Pass `null` to show none. */
|
|
57
62
|
icon = input(undefined, /* @ts-ignore */
|
|
58
63
|
...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
64
|
+
/** Label of the confirm button. */
|
|
59
65
|
confirmText = input('Confirm', /* @ts-ignore */
|
|
60
66
|
...(ngDevMode ? [{ debugName: "confirmText" }] : /* istanbul ignore next */ []));
|
|
61
67
|
/** Omit for an acknowledge-only alert with no cancel button. */
|
|
62
68
|
cancelText = input(null, /* @ts-ignore */
|
|
63
69
|
...(ngDevMode ? [{ debugName: "cancelText" }] : /* istanbul ignore next */ []));
|
|
70
|
+
/** Let Escape dismiss the alert. On by default; turn it off for a decision the user must make explicitly. */
|
|
64
71
|
canEscapeKeyClose = input(true, { ...(ngDevMode ? { debugName: "canEscapeKeyClose" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
72
|
+
/** Let a click on the backdrop dismiss the alert. Off by default, since an alert asks a question. */
|
|
65
73
|
canOutsideClickClose = input(false, { ...(ngDevMode ? { debugName: "canOutsideClickClose" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
74
|
+
/** Emits when the confirm button is pressed. */
|
|
66
75
|
confirmed = output();
|
|
76
|
+
/** Emits when the alert is dismissed — by the cancel button, Escape, or an outside click. */
|
|
67
77
|
cancelled = output();
|
|
68
78
|
resolvedIcon = computed(() => {
|
|
69
79
|
const override = this.icon();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xui-alert.mjs","sources":["../../../../../../libs/ui/alert/xui/src/lib/alert-config.ts","../../../../../../libs/ui/alert/xui/src/lib/alert.ts","../../../../../../libs/ui/alert/xui/src/lib/alert.service.ts","../../../../../../libs/ui/alert/xui/src/index.ts","../../../../../../libs/ui/alert/xui/src/xui-alert.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\n/** The colour and default icon an alert takes. */\nexport type XuiAlertColor = 'none' | 'primary' | 'success' | 'warning' | 'error';\n\n/** Icon each color implies, unless the caller overrides it. */\nexport const XUI_ALERT_COLOR_ICON: Record<XuiAlertColor, string | null> = {\n none: null,\n primary: 'matInfoRound',\n success: 'matCheckCircleRound',\n warning: 'matWarningRound',\n error: 'matErrorRound'\n};\n\n/** Colour class for the icon, per alert colour. */\nexport const XUI_ALERT_COLOR_ICON_CLASS: Record<XuiAlertColor, string> = {\n none: 'text-foreground-muted',\n primary: 'text-primary-emphasis',\n success: 'text-success-emphasis',\n warning: 'text-warning-emphasis',\n error: 'text-error-emphasis'\n};\n\n/** Button colour that matches the alert colour — `none` confirms in the primary colour. */\nexport function alertConfirmColor(color: XuiAlertColor): 'primary' | 'success' | 'warning' | 'error' {\n return color === 'none' ? 'primary' : color;\n}\n\n/** Options for the imperative `XuiAlertService.confirm()`. */\nexport interface XuiAlertOptions {\n message: string;\n color?: XuiAlertColor;\n /** Override the icon the color implies. Pass `null` for none. */\n icon?: string | null;\n confirmText?: string;\n /** Omit for an acknowledge-only alert with no cancel button. */\n cancelText?: string;\n canEscapeKeyClose?: boolean;\n canOutsideClickClose?: boolean;\n}\n\nexport const XUI_ALERT_OPTIONS = new InjectionToken<XuiAlertOptions>('XuiAlertOptions');\n","import type { BooleanInput } from '@angular/cdk/coercion';\nimport {\n ChangeDetectionStrategy,\n Component,\n ViewEncapsulation,\n booleanAttribute,\n computed,\n effect,\n input,\n model,\n output,\n untracked\n} from '@angular/core';\nimport { NgIcon, provideIcons } from '@ng-icons/core';\nimport { matCheckCircleRound, matErrorRound, matInfoRound, matWarningRound } from '@ng-icons/material-icons/round';\nimport { XuiButtonImports } from '@xui/button';\nimport { XuiDialogImports } from '@xui/dialog';\nimport { XuiIcon } from '@xui/icon';\nimport {\n XUI_ALERT_COLOR_ICON,\n XUI_ALERT_COLOR_ICON_CLASS,\n alertConfirmColor,\n type XuiAlertColor\n} from './alert-config';\n\n/**\n * A small modal that asks the user to confirm or cancel before something\n * irreversible.\n *\n * ```html\n * <xui-alert [(open)]=\"confirming\" color=\"error\" confirmText=\"Delete\"\n * cancelText=\"Cancel\" (confirmed)=\"remove()\">\n * Delete this project? This cannot be undone.\n * </xui-alert>\n * ```\n *\n * A preset over `@xui/dialog`: no title bar, no close button, and a fixed pair\n * of actions. Dismissing it any other way — Escape, the backdrop — counts as a\n * cancel, so `(cancelled)` fires however the user backs out. For a promise-based\n * confirmation opened from code, use `XuiAlertService`.\n */\n@Component({\n selector: 'xui-alert',\n imports: [NgIcon, XuiIcon, XuiButtonImports, XuiDialogImports],\n viewProviders: [provideIcons({ matInfoRound, matCheckCircleRound, matWarningRound, matErrorRound })],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n template: `\n <xui-dialog\n [(open)]=\"open\"\n size=\"sm\"\n [showCloseButton]=\"false\"\n [canEscapeKeyClose]=\"canEscapeKeyClose()\"\n [canOutsideClickClose]=\"canOutsideClickClose()\"\n >\n <div class=\"flex gap-3 px-6 py-6\">\n @if (resolvedIcon()) {\n <ng-icon xui size=\"xl\" [name]=\"resolvedIcon()!\" [class]=\"iconClass()\" class=\"shrink-0\" />\n }\n <div class=\"text-foreground pt-0.5 text-sm\"><ng-content /></div>\n </div>\n <xui-dialog-footer>\n @if (cancelText()) {\n <button xuiButton variant=\"ghost\" (click)=\"cancel()\">{{ cancelText() }}</button>\n }\n <button xuiButton [color]=\"confirmColor()\" (click)=\"confirm()\">{{ confirmText() }}</button>\n </xui-dialog-footer>\n </xui-dialog>\n `\n})\nexport class XuiAlert {\n private wasOpen = false;\n private settled = false;\n\n readonly open = model(false);\n\n readonly color = input<XuiAlertColor>('none');\n /** Override the icon the color implies. Pass `null` to show none. */\n readonly icon = input<string | null | undefined>(undefined);\n\n readonly confirmText = input('Confirm');\n /** Omit for an acknowledge-only alert with no cancel button. */\n readonly cancelText = input<string | null>(null);\n\n readonly canEscapeKeyClose = input<boolean, BooleanInput>(true, { transform: booleanAttribute });\n readonly canOutsideClickClose = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n readonly confirmed = output<void>();\n readonly cancelled = output<void>();\n\n protected readonly resolvedIcon = computed(() => {\n const override = this.icon();\n\n return override === undefined ? XUI_ALERT_COLOR_ICON[this.color()] : override;\n });\n protected readonly iconClass = computed(() => XUI_ALERT_COLOR_ICON_CLASS[this.color()]);\n protected readonly confirmColor = computed(() => alertConfirmColor(this.color()));\n\n constructor() {\n // A close that is neither confirm nor cancel — Escape, the backdrop — is\n // still the user backing out, so report it as a cancel.\n effect(() => {\n const open = this.open();\n\n untracked(() => {\n if (open) {\n this.settled = false;\n } else if (this.wasOpen && !this.settled) {\n this.cancelled.emit();\n }\n\n this.wasOpen = open;\n });\n });\n }\n\n protected confirm(): void {\n this.settled = true;\n this.confirmed.emit();\n this.open.set(false);\n }\n\n protected cancel(): void {\n this.settled = true;\n this.cancelled.emit();\n this.open.set(false);\n }\n}\n","import { ChangeDetectionStrategy, Component, Injectable, ViewEncapsulation, computed, inject } from '@angular/core';\nimport { NgIcon, provideIcons } from '@ng-icons/core';\nimport { matCheckCircleRound, matErrorRound, matInfoRound, matWarningRound } from '@ng-icons/material-icons/round';\nimport { XuiButtonImports } from '@xui/button';\nimport { XuiDialogFooter, XuiDialogRef, XuiDialogService } from '@xui/dialog';\nimport { XuiIcon } from '@xui/icon';\nimport {\n XUI_ALERT_COLOR_ICON,\n XUI_ALERT_COLOR_ICON_CLASS,\n XUI_ALERT_OPTIONS,\n alertConfirmColor,\n type XuiAlertOptions\n} from './alert-config';\n\n/**\n * The body rendered by `XuiAlertService`. Not exported — the service is the\n * only thing that mounts it, and it closes the dialog with the boolean result\n * the promise resolves to.\n */\n@Component({\n selector: 'xui-confirm-dialog',\n imports: [NgIcon, XuiIcon, XuiButtonImports, XuiDialogFooter],\n viewProviders: [provideIcons({ matInfoRound, matCheckCircleRound, matWarningRound, matErrorRound })],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n template: `\n <div class=\"flex gap-3 px-6 py-6\">\n @if (resolvedIcon()) {\n <ng-icon xui size=\"xl\" [name]=\"resolvedIcon()!\" [class]=\"iconClass()\" class=\"shrink-0\" />\n }\n <div class=\"text-foreground pt-0.5 text-sm\">{{ options.message }}</div>\n </div>\n <xui-dialog-footer>\n @if (options.cancelText) {\n <button xuiButton variant=\"ghost\" (click)=\"close(false)\">{{ options.cancelText }}</button>\n }\n <button xuiButton [color]=\"confirmColor()\" (click)=\"close(true)\">{{ options.confirmText ?? 'Confirm' }}</button>\n </xui-dialog-footer>\n `\n})\nexport class XuiConfirmDialog {\n protected readonly options = inject(XUI_ALERT_OPTIONS);\n private readonly ref = inject<XuiDialogRef<boolean>>(XuiDialogRef);\n\n private readonly color = this.options.color ?? 'none';\n protected readonly resolvedIcon = computed(() =>\n this.options.icon === undefined ? XUI_ALERT_COLOR_ICON[this.color] : this.options.icon\n );\n protected readonly iconClass = computed(() => XUI_ALERT_COLOR_ICON_CLASS[this.color]);\n protected readonly confirmColor = computed(() => alertConfirmColor(this.color));\n\n protected close(result: boolean): void {\n this.ref.close(result);\n }\n}\n\n/**\n * Opens a confirmation from code and resolves to the user's answer.\n *\n * ```ts\n * if (await this.alerts.confirm({ message: 'Delete this?', color: 'error', confirmText: 'Delete', cancelText: 'Cancel' })) {\n * this.remove();\n * }\n * ```\n *\n * A thin layer over `XuiDialogService` that mounts a fixed confirm/cancel body\n * and settles its promise `true` on confirm, `false` on cancel or any dismissal\n * — so a caller can simply `await` the answer.\n */\n@Injectable({ providedIn: 'root' })\nexport class XuiAlertService {\n private readonly dialogs = inject(XuiDialogService);\n\n async confirm(options: XuiAlertOptions): Promise<boolean> {\n const ref = this.dialogs.open<XuiConfirmDialog, boolean>(XuiConfirmDialog, {\n size: 'sm',\n canEscapeKeyClose: options.canEscapeKeyClose ?? true,\n canOutsideClickClose: options.canOutsideClickClose ?? false,\n ariaLabel: options.message,\n providers: [{ provide: XUI_ALERT_OPTIONS, useValue: options }]\n });\n\n // A dismissal (Escape, backdrop) resolves `undefined`; treat it as declining.\n return (await ref.closed) === true;\n }\n}\n","import { XuiAlert } from './lib/alert';\n\nexport * from './lib/alert';\nexport * from './lib/alert-config';\n// XuiConfirmDialog is intentionally not exported — it is an internal of the service.\nexport { XuiAlertService } from './lib/alert.service';\n\nexport const XuiAlertImports = [XuiAlert] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAKA;AACO,MAAM,oBAAoB,GAAyC;AACxE,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,OAAO,EAAE,cAAc;AACvB,IAAA,OAAO,EAAE,qBAAqB;AAC9B,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,KAAK,EAAE;;AAGT;AACO,MAAM,0BAA0B,GAAkC;AACvE,IAAA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,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAEnD,MAAM,OAAO,CAAC,OAAwB,EAAA;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAA4B,gBAAgB,EAAE;AACzE,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,IAAI;AACpD,YAAA,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,IAAI,KAAK;YAC3D,SAAS,EAAE,OAAO,CAAC,OAAO;YAC1B,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC9D,SAAA,CAAC;;QAGF,OAAO,CAAC,MAAM,GAAG,CAAC,MAAM,MAAM,IAAI;IACpC;0HAdW,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAf,uBAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cADF,MAAM,EAAA,CAAA;;2FACnB,eAAe,EAAA,UAAA,EAAA,CAAA;kBAD3B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;AC9D3B,MAAM,eAAe,GAAG,CAAC,QAAQ;;ACPxC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"xui-alert.mjs","sources":["../../../../../../libs/ui/alert/xui/src/lib/alert-config.ts","../../../../../../libs/ui/alert/xui/src/lib/alert.ts","../../../../../../libs/ui/alert/xui/src/lib/alert.service.ts","../../../../../../libs/ui/alert/xui/src/index.ts","../../../../../../libs/ui/alert/xui/src/xui-alert.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\n/** The colour and default icon an alert takes. */\nexport type XuiAlertColor = 'none' | 'primary' | 'success' | 'warning' | 'error';\n\n/** Icon each color implies, unless the caller overrides it. */\nexport const XUI_ALERT_COLOR_ICON: Record<XuiAlertColor, string | null> = {\n none: null,\n primary: 'matInfoRound',\n success: 'matCheckCircleRound',\n warning: 'matWarningRound',\n error: 'matErrorRound'\n};\n\n/** Colour class for the icon, per alert colour. */\nexport const XUI_ALERT_COLOR_ICON_CLASS: Record<XuiAlertColor, string> = {\n none: 'text-foreground-muted',\n primary: 'text-primary-emphasis',\n success: 'text-success-emphasis',\n warning: 'text-warning-emphasis',\n error: 'text-error-emphasis'\n};\n\n/** Button colour that matches the alert colour — `none` confirms in the primary colour. */\nexport function alertConfirmColor(color: XuiAlertColor): 'primary' | 'success' | 'warning' | 'error' {\n return color === 'none' ? 'primary' : color;\n}\n\n/** Options for the imperative `XuiAlertService.confirm()`. */\nexport interface XuiAlertOptions {\n message: string;\n color?: XuiAlertColor;\n /** Override the icon the color implies. Pass `null` for none. */\n icon?: string | null;\n confirmText?: string;\n /** Omit for an acknowledge-only alert with no cancel button. */\n cancelText?: string;\n canEscapeKeyClose?: boolean;\n canOutsideClickClose?: boolean;\n}\n\nexport const XUI_ALERT_OPTIONS = new InjectionToken<XuiAlertOptions>('XuiAlertOptions');\n","import type { BooleanInput } from '@angular/cdk/coercion';\nimport {\n ChangeDetectionStrategy,\n Component,\n ViewEncapsulation,\n booleanAttribute,\n computed,\n effect,\n input,\n model,\n output,\n untracked\n} from '@angular/core';\nimport { NgIcon, provideIcons } from '@ng-icons/core';\nimport { matCheckCircleRound, matErrorRound, matInfoRound, matWarningRound } from '@ng-icons/material-icons/round';\nimport { XuiButtonImports } from '@xui/button';\nimport { XuiDialogImports } from '@xui/dialog';\nimport { XuiIcon } from '@xui/icon';\nimport {\n XUI_ALERT_COLOR_ICON,\n XUI_ALERT_COLOR_ICON_CLASS,\n alertConfirmColor,\n type XuiAlertColor\n} from './alert-config';\n\n/**\n * A small modal that asks the user to confirm or cancel before something\n * irreversible.\n *\n * ```html\n * <xui-alert [(open)]=\"confirming\" color=\"error\" confirmText=\"Delete\"\n * cancelText=\"Cancel\" (confirmed)=\"remove()\">\n * Delete this project? This cannot be undone.\n * </xui-alert>\n * ```\n *\n * A preset over `@xui/dialog`: no title bar, no close button, and a fixed pair\n * of actions. Dismissing it any other way — Escape, the backdrop — counts as a\n * cancel, so `(cancelled)` fires however the user backs out. For a promise-based\n * confirmation opened from code, use `XuiAlertService`.\n */\n@Component({\n selector: 'xui-alert',\n imports: [NgIcon, XuiIcon, XuiButtonImports, XuiDialogImports],\n viewProviders: [provideIcons({ matInfoRound, matCheckCircleRound, matWarningRound, matErrorRound })],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n template: `\n <xui-dialog\n [(open)]=\"open\"\n size=\"sm\"\n [showCloseButton]=\"false\"\n [canEscapeKeyClose]=\"canEscapeKeyClose()\"\n [canOutsideClickClose]=\"canOutsideClickClose()\"\n >\n <div class=\"flex gap-3 px-6 py-6\">\n @if (resolvedIcon()) {\n <ng-icon xui size=\"xl\" [name]=\"resolvedIcon()!\" [class]=\"iconClass()\" class=\"shrink-0\" />\n }\n <div class=\"text-foreground pt-0.5 text-sm\"><ng-content /></div>\n </div>\n <xui-dialog-footer>\n @if (cancelText()) {\n <button xuiButton variant=\"ghost\" (click)=\"cancel()\">{{ cancelText() }}</button>\n }\n <button xuiButton [color]=\"confirmColor()\" (click)=\"confirm()\">{{ confirmText() }}</button>\n </xui-dialog-footer>\n </xui-dialog>\n `\n})\nexport class XuiAlert {\n private wasOpen = false;\n private settled = false;\n\n /** Whether the alert is showing. Two-way bindable with `[(open)]`. */\n readonly open = model(false);\n\n /**\n * Intent of the alert. Also picks the default icon and the confirm button's colour, and promotes the dialog to\n * `role=\"alert\"` for `error` and `warning`.\n */\n readonly color = input<XuiAlertColor>('none');\n /** Override the icon the color implies. Pass `null` to show none. */\n readonly icon = input<string | null | undefined>(undefined);\n\n /** Label of the confirm button. */\n readonly confirmText = input('Confirm');\n /** Omit for an acknowledge-only alert with no cancel button. */\n readonly cancelText = input<string | null>(null);\n\n /** Let Escape dismiss the alert. On by default; turn it off for a decision the user must make explicitly. */\n readonly canEscapeKeyClose = input<boolean, BooleanInput>(true, { transform: booleanAttribute });\n /** Let a click on the backdrop dismiss the alert. Off by default, since an alert asks a question. */\n readonly canOutsideClickClose = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /** Emits when the confirm button is pressed. */\n readonly confirmed = output<void>();\n /** Emits when the alert is dismissed — by the cancel button, Escape, or an outside click. */\n readonly cancelled = output<void>();\n\n protected readonly resolvedIcon = computed(() => {\n const override = this.icon();\n\n return override === undefined ? XUI_ALERT_COLOR_ICON[this.color()] : override;\n });\n protected readonly iconClass = computed(() => XUI_ALERT_COLOR_ICON_CLASS[this.color()]);\n protected readonly confirmColor = computed(() => alertConfirmColor(this.color()));\n\n constructor() {\n // A close that is neither confirm nor cancel — Escape, the backdrop — is\n // still the user backing out, so report it as a cancel.\n effect(() => {\n const open = this.open();\n\n untracked(() => {\n if (open) {\n this.settled = false;\n } else if (this.wasOpen && !this.settled) {\n this.cancelled.emit();\n }\n\n this.wasOpen = open;\n });\n });\n }\n\n protected confirm(): void {\n this.settled = true;\n this.confirmed.emit();\n this.open.set(false);\n }\n\n protected cancel(): void {\n this.settled = true;\n this.cancelled.emit();\n this.open.set(false);\n }\n}\n","import { ChangeDetectionStrategy, Component, Injectable, ViewEncapsulation, computed, inject } from '@angular/core';\nimport { NgIcon, provideIcons } from '@ng-icons/core';\nimport { matCheckCircleRound, matErrorRound, matInfoRound, matWarningRound } from '@ng-icons/material-icons/round';\nimport { XuiButtonImports } from '@xui/button';\nimport { XuiDialogFooter, XuiDialogRef, XuiDialogService } from '@xui/dialog';\nimport { XuiIcon } from '@xui/icon';\nimport {\n XUI_ALERT_COLOR_ICON,\n XUI_ALERT_COLOR_ICON_CLASS,\n XUI_ALERT_OPTIONS,\n alertConfirmColor,\n type XuiAlertOptions\n} from './alert-config';\n\n/**\n * The body rendered by `XuiAlertService`. Not exported — the service is the\n * only thing that mounts it, and it closes the dialog with the boolean result\n * the promise resolves to.\n */\n@Component({\n selector: 'xui-confirm-dialog',\n imports: [NgIcon, XuiIcon, XuiButtonImports, XuiDialogFooter],\n viewProviders: [provideIcons({ matInfoRound, matCheckCircleRound, matWarningRound, matErrorRound })],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n template: `\n <div class=\"flex gap-3 px-6 py-6\">\n @if (resolvedIcon()) {\n <ng-icon xui size=\"xl\" [name]=\"resolvedIcon()!\" [class]=\"iconClass()\" class=\"shrink-0\" />\n }\n <div class=\"text-foreground pt-0.5 text-sm\">{{ options.message }}</div>\n </div>\n <xui-dialog-footer>\n @if (options.cancelText) {\n <button xuiButton variant=\"ghost\" (click)=\"close(false)\">{{ options.cancelText }}</button>\n }\n <button xuiButton [color]=\"confirmColor()\" (click)=\"close(true)\">{{ options.confirmText ?? 'Confirm' }}</button>\n </xui-dialog-footer>\n `\n})\nexport class XuiConfirmDialog {\n protected readonly options = inject(XUI_ALERT_OPTIONS);\n private readonly ref = inject<XuiDialogRef<boolean>>(XuiDialogRef);\n\n private readonly color = this.options.color ?? 'none';\n protected readonly resolvedIcon = computed(() =>\n this.options.icon === undefined ? XUI_ALERT_COLOR_ICON[this.color] : this.options.icon\n );\n protected readonly iconClass = computed(() => XUI_ALERT_COLOR_ICON_CLASS[this.color]);\n protected readonly confirmColor = computed(() => alertConfirmColor(this.color));\n\n protected close(result: boolean): void {\n this.ref.close(result);\n }\n}\n\n/**\n * Opens a confirmation from code and resolves to the user's answer.\n *\n * ```ts\n * if (await this.alerts.confirm({ message: 'Delete this?', color: 'error', confirmText: 'Delete', cancelText: 'Cancel' })) {\n * this.remove();\n * }\n * ```\n *\n * A thin layer over `XuiDialogService` that mounts a fixed confirm/cancel body\n * and settles its promise `true` on confirm, `false` on cancel or any dismissal\n * — so a caller can simply `await` the answer.\n */\n@Injectable({ providedIn: 'root' })\nexport class XuiAlertService {\n private readonly dialogs = inject(XuiDialogService);\n\n async confirm(options: XuiAlertOptions): Promise<boolean> {\n const ref = this.dialogs.open<XuiConfirmDialog, boolean>(XuiConfirmDialog, {\n size: 'sm',\n canEscapeKeyClose: options.canEscapeKeyClose ?? true,\n canOutsideClickClose: options.canOutsideClickClose ?? false,\n ariaLabel: options.message,\n providers: [{ provide: XUI_ALERT_OPTIONS, useValue: options }]\n });\n\n // A dismissal (Escape, backdrop) resolves `undefined`; treat it as declining.\n return (await ref.closed) === true;\n }\n}\n","import { XuiAlert } from './lib/alert';\n\nexport * from './lib/alert';\nexport * from './lib/alert-config';\n// XuiConfirmDialog is intentionally not exported — it is an internal of the service.\nexport { XuiAlertService } from './lib/alert.service';\n\nexport const XuiAlertImports = [XuiAlert] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAKA;AACO,MAAM,oBAAoB,GAAyC;AACxE,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,OAAO,EAAE,cAAc;AACvB,IAAA,OAAO,EAAE,qBAAqB;AAC9B,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,KAAK,EAAE;;AAGT;AACO,MAAM,0BAA0B,GAAkC;AACvE,IAAA,IAAI,EAAE,uBAAuB;AAC7B,IAAA,OAAO,EAAE,uBAAuB;AAChC,IAAA,OAAO,EAAE,uBAAuB;AAChC,IAAA,OAAO,EAAE,uBAAuB;AAChC,IAAA,KAAK,EAAE;;AAGT;AACM,SAAU,iBAAiB,CAAC,KAAoB,EAAA;IACpD,OAAO,KAAK,KAAK,MAAM,GAAG,SAAS,GAAG,KAAK;AAC7C;MAea,iBAAiB,GAAG,IAAI,cAAc,CAAkB,iBAAiB;;AChBtF;;;;;;;;;;;;;;;AAeG;MA8BU,QAAQ,CAAA;IACX,OAAO,GAAG,KAAK;IACf,OAAO,GAAG,KAAK;;IAGd,IAAI,GAAG,KAAK,CAAC,KAAK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OAAO,EAAE;AAC9D,SAAA,CAAC;;QAGF,OAAO,CAAC,MAAM,GAAG,CAAC,MAAM,MAAM,IAAI;IACpC;0HAdW,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAf,uBAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cADF,MAAM,EAAA,CAAA;;2FACnB,eAAe,EAAA,UAAA,EAAA,CAAA;kBAD3B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;AC9D3B,MAAM,eAAe,GAAG,CAAC,QAAQ;;ACPxC;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xui/alert",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.21",
|
|
4
4
|
"description": "Modern Angular 22 UI Library based on TailwindCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@angular/core": "22",
|
|
41
41
|
"@ng-icons/core": "34",
|
|
42
42
|
"@ng-icons/material-icons": "34",
|
|
43
|
-
"@xui/button": "2.0.0-alpha.
|
|
44
|
-
"@xui/dialog": "2.0.0-alpha.
|
|
45
|
-
"@xui/icon": "2.0.0-alpha.
|
|
43
|
+
"@xui/button": "2.0.0-alpha.21",
|
|
44
|
+
"@xui/dialog": "2.0.0-alpha.21",
|
|
45
|
+
"@xui/icon": "2.0.0-alpha.21"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
package/types/xui-alert.d.ts
CHANGED
|
@@ -43,16 +43,26 @@ declare const XUI_ALERT_OPTIONS: InjectionToken<XuiAlertOptions>;
|
|
|
43
43
|
declare class XuiAlert {
|
|
44
44
|
private wasOpen;
|
|
45
45
|
private settled;
|
|
46
|
+
/** Whether the alert is showing. Two-way bindable with `[(open)]`. */
|
|
46
47
|
readonly open: _angular_core.ModelSignal<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Intent of the alert. Also picks the default icon and the confirm button's colour, and promotes the dialog to
|
|
50
|
+
* `role="alert"` for `error` and `warning`.
|
|
51
|
+
*/
|
|
47
52
|
readonly color: _angular_core.InputSignal<XuiAlertColor>;
|
|
48
53
|
/** Override the icon the color implies. Pass `null` to show none. */
|
|
49
54
|
readonly icon: _angular_core.InputSignal<string | null | undefined>;
|
|
55
|
+
/** Label of the confirm button. */
|
|
50
56
|
readonly confirmText: _angular_core.InputSignal<string>;
|
|
51
57
|
/** Omit for an acknowledge-only alert with no cancel button. */
|
|
52
58
|
readonly cancelText: _angular_core.InputSignal<string | null>;
|
|
59
|
+
/** Let Escape dismiss the alert. On by default; turn it off for a decision the user must make explicitly. */
|
|
53
60
|
readonly canEscapeKeyClose: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
61
|
+
/** Let a click on the backdrop dismiss the alert. Off by default, since an alert asks a question. */
|
|
54
62
|
readonly canOutsideClickClose: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
63
|
+
/** Emits when the confirm button is pressed. */
|
|
55
64
|
readonly confirmed: _angular_core.OutputEmitterRef<void>;
|
|
65
|
+
/** Emits when the alert is dismissed — by the cancel button, Escape, or an outside click. */
|
|
56
66
|
readonly cancelled: _angular_core.OutputEmitterRef<void>;
|
|
57
67
|
protected readonly resolvedIcon: _angular_core.Signal<string | null>;
|
|
58
68
|
protected readonly iconClass: _angular_core.Signal<string>;
|