@forgeroute/ui 0.5.32 → 0.5.34
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/forgeroute-ui-conversations.mjs +1 -0
- package/fesm2022/forgeroute-ui-conversations.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-core.mjs +20 -2
- package/fesm2022/forgeroute-ui-core.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-editor.mjs +97 -18
- package/fesm2022/forgeroute-ui-editor.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-messaging.mjs +1 -0
- package/fesm2022/forgeroute-ui-messaging.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-notification-bell.mjs +1 -0
- package/fesm2022/forgeroute-ui-notification-bell.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-offline.mjs +1 -0
- package/fesm2022/forgeroute-ui-offline.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-payments.mjs +3 -0
- package/fesm2022/forgeroute-ui-payments.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-phone-number-picker.mjs +1 -0
- package/fesm2022/forgeroute-ui-phone-number-picker.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-stripe.mjs +1 -0
- package/fesm2022/forgeroute-ui-stripe.mjs.map +1 -1
- package/package.json +1 -1
- package/types/forgeroute-ui-core.d.ts +10 -3
- package/types/forgeroute-ui-editor.d.ts +43 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgeroute-ui-notification-bell.mjs","names":[],"sources":["../../../projects/forgeroute-ui/notification-bell/src/lib/notification-bell/notification-bell.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, effect, inject, input, model, output, signal, untracked } from '@angular/core';\nimport { UiLabelsService } from '@forgeroute/ui/core';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { BadgeComponent } from '@forgeroute/ui/badge';\nimport { ButtonComponent } from '@forgeroute/ui/core';\nimport { EmptyStateComponent } from '@forgeroute/ui/empty-state';\nimport { ErrorStateComponent } from '@forgeroute/ui/error-state';\nimport { IconComponent } from '@forgeroute/ui/icon';\nimport { ListItemComponent } from '@forgeroute/ui/list-item';\nimport { SidePanelComponent } from '@forgeroute/ui/core';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { StackComponent } from '@forgeroute/ui/stack';\n\n/** One row of the notification list. `time` is the text to show (the host formats it: \"5 min ago\", \"Nov 10\"); `read` false = unread (highlighted, \"New\" badge, a Mark read button). */\nexport interface NotificationItem {\n id: string;\n title: string;\n body?: string | null;\n time?: string | null;\n read: boolean;\n}\n\n/**\n * The notification bell: a bell button with an unread count, that opens a side panel listing the user's notifications\n * (`<ui-notification-bell [items]=\"items()\" [unreadCount]=\"unread()\" [(open)]=\"open\" (opened)=\"load()\" (itemSelect)=\"go($event)\" (markRead)=\"read($event)\" (markAllRead)=\"readAll()\" />`).\n *\n * The component owns the look and the keyboard / screen-reader behaviour and holds NO http: the host loads the list (when `(opened)` fires), formats the times, keeps the unread count\n * current (the bell shows `unreadCount` even while the panel is closed) and answers `(markRead)` / `(markAllRead)` / `(loadMore)` / `(retry)`. Selecting a row emits `(itemSelect)` (the host\n * marks it read, navigates, and closes the panel with `open.set(false)`); the \"Mark read\" button of an unread row emits `(markRead)` only. Built from the library's own button, icon, badge,\n * side panel, list item, empty / error state and skeleton, so it follows their theming, focus rings and 44px touch targets.\n *\n * Accessibility: the trigger is a real button named \"Notifications, N unread\" (`ariaLabel` + the count), `aria-expanded` follows the panel; the count badge is decorative (the name already\n * carries it, so it is `aria-hidden`); a read row has no \"New\" badge; \"Mark read\" buttons carry the row title in their name. A visually hidden polite live region announces every CHANGE of\n * the unread count (\"You have 3 unread notifications.\", \"You have no unread notifications.\") - never the count the bell was first shown with, so a page load is silent.\n *\n * Text: every word comes from the label service (keys `notificationBell.*`, English and Spanish); `ariaLabel`, `panelTitle` and `emptyMessage` override the defaults when the host wants\n * its own wording.\n */\n@Component({\n selector: 'ui-notification-bell',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [BadgeComponent, ButtonComponent, EmptyStateComponent, ErrorStateComponent, IconComponent, ListItemComponent, LiveRegionComponent, SidePanelComponent, SkeletonComponent, StackComponent],\n template: `\n <span class=\"bell-wrap\">\n <ui-button variant=\"icon\" [ariaLabel]=\"triggerLabel()\" [ariaExpanded]=\"open()\" data-testid=\"notification-bell\" (click)=\"toggle()\">\n <ui-icon name=\"bell\" [size]=\"20\" [interactive]=\"false\" />\n </ui-button>\n @if (unreadCount() > 0) {\n <ui-badge class=\"bell-count\" aria-hidden=\"true\" [label]=\"countText()\" variant=\"red\" data-testid=\"notification-count\" />\n }\n </span>\n <ui-live-region [message]=\"announcement()\" data-testid=\"notification-live\" />\n\n <ui-side-panel [open]=\"open()\" [title]=\"panelTitleText()\" [cancelLabel]=\"labels.t('notificationBell.close')\" (closed)=\"close()\">\n <ui-stack gap=\"12px\">\n <div class=\"bell-head\">\n <span class=\"bell-summary\" data-testid=\"notification-summary\" role=\"status\">{{ summaryText() }}</span>\n <ui-button variant=\"link\" size=\"sm\" [disabled]=\"unreadCount() === 0\" data-testid=\"notification-mark-all\" (click)=\"markAllRead.emit()\">{{ labels.t('notificationBell.markAllRead') }}</ui-button>\n </div>\n\n @if (loading() && items().length === 0) {\n <div role=\"status\" aria-busy=\"true\" [attr.aria-label]=\"labels.t('notificationBell.loading')\" data-testid=\"notification-loading\">\n <ui-skeleton [height]=\"56\" [mb]=\"8\" />\n <ui-skeleton [height]=\"56\" [mb]=\"8\" />\n <ui-skeleton [height]=\"56\" />\n </div>\n } @else if (error()) {\n <div data-testid=\"notification-error\"><ui-error-state [message]=\"error()\" [retryLabel]=\"labels.t('notificationBell.retry')\" (retry)=\"retry.emit()\" /></div>\n } @else if (items().length === 0) {\n <ui-empty-state iconType=\"message\" [message]=\"emptyText()\" data-testid=\"notification-empty\" />\n } @else {\n <ui-stack gap=\"8px\" data-testid=\"notification-list\">\n @for (n of items(); track n.id) {\n <ui-list-item [attr.data-testid]=\"'notification-' + n.id\" [bordered]=\"true\" [highlighted]=\"!n.read\" [title]=\"n.title\" [details]=\"[n.body, n.time]\"\n [badge]=\"n.read ? null : labels.t('notificationBell.new')\" badgeVariant=\"blue\" [alwaysShowBadge]=\"true\" [wrapText]=\"true\" (select)=\"itemSelect.emit(n)\">\n @if (!n.read) {\n <ui-button list-item-action variant=\"secondary\" size=\"xs\" [ariaLabel]=\"labels.t('notificationBell.markReadNamed', { title: n.title })\" [attr.data-testid]=\"'notification-read-' + n.id\" (click)=\"markRead.emit(n)\">{{ labels.t('notificationBell.markRead') }}</ui-button>\n }\n </ui-list-item>\n }\n </ui-stack>\n @if (hasMore()) {\n <ui-button variant=\"secondary\" size=\"sm\" [loading]=\"loadingMore()\" data-testid=\"notification-more\" (click)=\"loadMore.emit()\">{{ labels.t('notificationBell.loadMore') }}</ui-button>\n }\n }\n </ui-stack>\n </ui-side-panel>\n `,\n styles: [`\n :host { display: inline-flex; position: relative; }\n .bell-wrap { position: relative; display: inline-flex; }\n .bell-count { position: absolute; top: -4px; right: -6px; pointer-events: none; }\n .bell-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n .bell-summary { font-size: 0.8125rem; color: #475569; }\n `],\n})\nexport class NotificationBellComponent {\n /** The notifications to list, newest first. */\n readonly items = input<readonly NotificationItem[]>([]);\n /** How many notifications are unread (shown on the bell even while the panel is closed). */\n readonly unreadCount = input(0);\n readonly loading = input(false);\n readonly loadingMore = input(false);\n /** A load failure message ('' = none): shown with a Retry button instead of the list. */\n readonly error = input('');\n /** More pages exist: shows a \"Load more\" button under the list. */\n readonly hasMore = input(false);\n /** Overrides the bell's accessible name (default: the label service's \"Notifications\"). */\n readonly ariaLabelInput = input<string | null>(null, { alias: 'ariaLabel' });\n /** Overrides the panel title (default: \"Notifications\"). */\n readonly panelTitleInput = input<string | null>(null, { alias: 'panelTitle' });\n /** Overrides the empty-list message (default: \"You have no notifications.\"). */\n readonly emptyMessageInput = input<string | null>(null, { alias: 'emptyMessage' });\n /** Counts above this show as \"<max>+\" on the bell. */\n readonly maxCount = input(99);\n /** Whether the panel is open (two-way: `[(open)]`). */\n readonly open = model(false);\n\n /** Fires every time the panel is opened by the bell: the host (re)loads the list. */\n readonly opened = output<void>();\n readonly itemSelect = output<NotificationItem>();\n readonly markRead = output<NotificationItem>();\n readonly markAllRead = output<void>();\n readonly loadMore = output<void>();\n readonly retry = output<void>();\n\n protected readonly labels = inject(UiLabelsService);\n /** The text a screen reader hears when the unread count changes ('' until it does). */\n protected readonly announcement = signal('');\n\n protected readonly baseLabel = computed(() => this.ariaLabelInput() ?? this.labels.t('notificationBell.label'));\n protected readonly panelTitleText = computed(() => this.panelTitleInput() ?? this.labels.t('notificationBell.label'));\n protected readonly emptyText = computed(() => this.emptyMessageInput() ?? this.labels.t('notificationBell.empty'));\n protected readonly countText = computed(() => this.unreadCount() > this.maxCount() ? `${this.maxCount()}+` : String(this.unreadCount()));\n protected readonly triggerLabel = computed(() => this.unreadCount() > 0 ? this.labels.t('notificationBell.labelUnread', { label: this.baseLabel(), count: this.unreadCount() }) : this.baseLabel());\n protected readonly summaryText = computed(() => this.unreadCount() > 0 ? this.labels.t('notificationBell.unread', { count: this.unreadCount() }) : this.labels.t('notificationBell.allCaughtUp'));\n\n /** The unread count the live region last saw (null until the first render, so the count the bell starts with is never announced). */\n private lastCount: number | null = null;\n\n constructor() {\n effect(() => {\n const count = this.unreadCount();\n untracked(() => {\n const previous = this.lastCount;\n this.lastCount = count;\n if (previous === null || previous === count) return;\n this.announcement.set(count === 0 ? this.labels.t('notificationBell.announce.none') : count === 1 ? this.labels.t('notificationBell.announce.one') : this.labels.t('notificationBell.announce.other', { count }));\n });\n });\n }\n\n toggle(): void {\n const next = !this.open();\n this.open.set(next);\n if (next) this.opened.emit();\n }\n\n close(): void { this.open.set(false); }\n}\n"],"mappings":";;;;;;;;;;;AAiGA,IAAa,4BAAb,MAAa,0BAAyB;CA4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;IAAA;KAAA,MAAA;KAAA,MAAE;KAAiB,UAAA;KAAA,QAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;KAAA;KAAA,SAAA,CAAA,QAAA;IAAA;IAAA;KAAA,MAAA;KAAA,MAAE;KAAmB,UAAA;KAAA,QAAA;MAAA;MAAA;MAAA;MAAA;KAAA;IAAA;IAAA;KAAA,MAAA;KAAA,MAAE;KAAkB,UAAA;KAAA,QAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;KAAA;KAAA,SAAA,CAAA,UAAA,cAAA;IAAA;IAAA;KAAA,MAAA;KAAA,MAAE;KAAiB,UAAA;KAAA,QAAA;MAAA;MAAA;MAAA;MAAA;MAAA;KAAA;IAAA;IAAA;KAAA,MAAA;KAAA,MAAE;KAAc,UAAA;KAAA,QAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;KAAA;IAAA;GAAA;GAAA,iBAAA,GAAA,wBAAA;EAAA,CAAA;CAAA;;AAuDtL,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAyB,YAAA,CAAA;EA3DrC,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAsB,YACpB;GAAI,iBACC,wBAAwB;GAAM,SACtC;IAAC;IAAgB;IAAiB;IAAqB;IAAqB;IAAe;IAAmB;IAAqB;IAAoB;IAAmB;GAAc;GAAC,UACxL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CT,QAAA,CAAA,wSAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"forgeroute-ui-notification-bell.mjs","names":[],"sources":["../../../projects/forgeroute-ui/notification-bell/src/lib/notification-bell/notification-bell.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, effect, inject, input, model, output, signal, untracked } from '@angular/core';\nimport { UiLabelsService } from '@forgeroute/ui/core';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { BadgeComponent } from '@forgeroute/ui/badge';\nimport { ButtonComponent } from '@forgeroute/ui/core';\nimport { EmptyStateComponent } from '@forgeroute/ui/empty-state';\nimport { ErrorStateComponent } from '@forgeroute/ui/error-state';\nimport { IconComponent } from '@forgeroute/ui/icon';\nimport { ListItemComponent } from '@forgeroute/ui/list-item';\nimport { SidePanelComponent } from '@forgeroute/ui/core';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { StackComponent } from '@forgeroute/ui/stack';\n\n/** One row of the notification list. `time` is the text to show (the host formats it: \"5 min ago\", \"Nov 10\"); `read` false = unread (highlighted, \"New\" badge, a Mark read button). */\nexport interface NotificationItem {\n id: string;\n title: string;\n body?: string | null;\n time?: string | null;\n read: boolean;\n}\n\n/**\n * The notification bell: a bell button with an unread count, that opens a side panel listing the user's notifications\n * (`<ui-notification-bell [items]=\"items()\" [unreadCount]=\"unread()\" [(open)]=\"open\" (opened)=\"load()\" (itemSelect)=\"go($event)\" (markRead)=\"read($event)\" (markAllRead)=\"readAll()\" />`).\n *\n * The component owns the look and the keyboard / screen-reader behaviour and holds NO http: the host loads the list (when `(opened)` fires), formats the times, keeps the unread count\n * current (the bell shows `unreadCount` even while the panel is closed) and answers `(markRead)` / `(markAllRead)` / `(loadMore)` / `(retry)`. Selecting a row emits `(itemSelect)` (the host\n * marks it read, navigates, and closes the panel with `open.set(false)`); the \"Mark read\" button of an unread row emits `(markRead)` only. Built from the library's own button, icon, badge,\n * side panel, list item, empty / error state and skeleton, so it follows their theming, focus rings and 44px touch targets.\n *\n * Accessibility: the trigger is a real button named \"Notifications, N unread\" (`ariaLabel` + the count), `aria-expanded` follows the panel; the count badge is decorative (the name already\n * carries it, so it is `aria-hidden`); a read row has no \"New\" badge; \"Mark read\" buttons carry the row title in their name. A visually hidden polite live region announces every CHANGE of\n * the unread count (\"You have 3 unread notifications.\", \"You have no unread notifications.\") - never the count the bell was first shown with, so a page load is silent.\n *\n * Text: every word comes from the label service (keys `notificationBell.*`, English and Spanish); `ariaLabel`, `panelTitle` and `emptyMessage` override the defaults when the host wants\n * its own wording.\n */\n@Component({\n selector: 'ui-notification-bell',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [BadgeComponent, ButtonComponent, EmptyStateComponent, ErrorStateComponent, IconComponent, ListItemComponent, LiveRegionComponent, SidePanelComponent, SkeletonComponent, StackComponent],\n template: `\n <span class=\"bell-wrap\">\n <ui-button variant=\"icon\" [ariaLabel]=\"triggerLabel()\" [ariaExpanded]=\"open()\" data-testid=\"notification-bell\" (click)=\"toggle()\">\n <ui-icon name=\"bell\" [size]=\"20\" [interactive]=\"false\" />\n </ui-button>\n @if (unreadCount() > 0) {\n <ui-badge class=\"bell-count\" aria-hidden=\"true\" [label]=\"countText()\" variant=\"red\" data-testid=\"notification-count\" />\n }\n </span>\n <ui-live-region [message]=\"announcement()\" data-testid=\"notification-live\" />\n\n <ui-side-panel [open]=\"open()\" [title]=\"panelTitleText()\" [cancelLabel]=\"labels.t('notificationBell.close')\" (closed)=\"close()\">\n <ui-stack gap=\"12px\">\n <div class=\"bell-head\">\n <span class=\"bell-summary\" data-testid=\"notification-summary\" role=\"status\">{{ summaryText() }}</span>\n <ui-button variant=\"link\" size=\"sm\" [disabled]=\"unreadCount() === 0\" data-testid=\"notification-mark-all\" (click)=\"markAllRead.emit()\">{{ labels.t('notificationBell.markAllRead') }}</ui-button>\n </div>\n\n @if (loading() && items().length === 0) {\n <div role=\"status\" aria-busy=\"true\" [attr.aria-label]=\"labels.t('notificationBell.loading')\" data-testid=\"notification-loading\">\n <ui-skeleton [height]=\"56\" [mb]=\"8\" />\n <ui-skeleton [height]=\"56\" [mb]=\"8\" />\n <ui-skeleton [height]=\"56\" />\n </div>\n } @else if (error()) {\n <div data-testid=\"notification-error\"><ui-error-state [message]=\"error()\" [retryLabel]=\"labels.t('notificationBell.retry')\" (retry)=\"retry.emit()\" /></div>\n } @else if (items().length === 0) {\n <ui-empty-state iconType=\"message\" [message]=\"emptyText()\" data-testid=\"notification-empty\" />\n } @else {\n <ui-stack gap=\"8px\" data-testid=\"notification-list\">\n @for (n of items(); track n.id) {\n <ui-list-item [attr.data-testid]=\"'notification-' + n.id\" [bordered]=\"true\" [highlighted]=\"!n.read\" [title]=\"n.title\" [details]=\"[n.body, n.time]\"\n [badge]=\"n.read ? null : labels.t('notificationBell.new')\" badgeVariant=\"blue\" [alwaysShowBadge]=\"true\" [wrapText]=\"true\" (select)=\"itemSelect.emit(n)\">\n @if (!n.read) {\n <ui-button list-item-action variant=\"secondary\" size=\"xs\" [ariaLabel]=\"labels.t('notificationBell.markReadNamed', { title: n.title })\" [attr.data-testid]=\"'notification-read-' + n.id\" (click)=\"markRead.emit(n)\">{{ labels.t('notificationBell.markRead') }}</ui-button>\n }\n </ui-list-item>\n }\n </ui-stack>\n @if (hasMore()) {\n <ui-button variant=\"secondary\" size=\"sm\" [loading]=\"loadingMore()\" data-testid=\"notification-more\" (click)=\"loadMore.emit()\">{{ labels.t('notificationBell.loadMore') }}</ui-button>\n }\n }\n </ui-stack>\n </ui-side-panel>\n `,\n styles: [`\n :host { display: inline-flex; position: relative; }\n .bell-wrap { position: relative; display: inline-flex; }\n .bell-count { position: absolute; top: -4px; right: -6px; pointer-events: none; }\n .bell-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n .bell-summary { font-size: 0.8125rem; color: #475569; }\n `],\n})\nexport class NotificationBellComponent {\n /** The notifications to list, newest first. */\n readonly items = input<readonly NotificationItem[]>([]);\n /** How many notifications are unread (shown on the bell even while the panel is closed). */\n readonly unreadCount = input(0);\n readonly loading = input(false);\n readonly loadingMore = input(false);\n /** A load failure message ('' = none): shown with a Retry button instead of the list. */\n readonly error = input('');\n /** More pages exist: shows a \"Load more\" button under the list. */\n readonly hasMore = input(false);\n /** Overrides the bell's accessible name (default: the label service's \"Notifications\"). */\n readonly ariaLabelInput = input<string | null>(null, { alias: 'ariaLabel' });\n /** Overrides the panel title (default: \"Notifications\"). */\n readonly panelTitleInput = input<string | null>(null, { alias: 'panelTitle' });\n /** Overrides the empty-list message (default: \"You have no notifications.\"). */\n readonly emptyMessageInput = input<string | null>(null, { alias: 'emptyMessage' });\n /** Counts above this show as \"<max>+\" on the bell. */\n readonly maxCount = input(99);\n /** Whether the panel is open (two-way: `[(open)]`). */\n readonly open = model(false);\n\n /** Fires every time the panel is opened by the bell: the host (re)loads the list. */\n readonly opened = output<void>();\n readonly itemSelect = output<NotificationItem>();\n readonly markRead = output<NotificationItem>();\n readonly markAllRead = output<void>();\n readonly loadMore = output<void>();\n readonly retry = output<void>();\n\n protected readonly labels = inject(UiLabelsService);\n /** The text a screen reader hears when the unread count changes ('' until it does). */\n protected readonly announcement = signal('');\n\n protected readonly baseLabel = computed(() => this.ariaLabelInput() ?? this.labels.t('notificationBell.label'));\n protected readonly panelTitleText = computed(() => this.panelTitleInput() ?? this.labels.t('notificationBell.label'));\n protected readonly emptyText = computed(() => this.emptyMessageInput() ?? this.labels.t('notificationBell.empty'));\n protected readonly countText = computed(() => this.unreadCount() > this.maxCount() ? `${this.maxCount()}+` : String(this.unreadCount()));\n protected readonly triggerLabel = computed(() => this.unreadCount() > 0 ? this.labels.t('notificationBell.labelUnread', { label: this.baseLabel(), count: this.unreadCount() }) : this.baseLabel());\n protected readonly summaryText = computed(() => this.unreadCount() > 0 ? this.labels.t('notificationBell.unread', { count: this.unreadCount() }) : this.labels.t('notificationBell.allCaughtUp'));\n\n /** The unread count the live region last saw (null until the first render, so the count the bell starts with is never announced). */\n private lastCount: number | null = null;\n\n constructor() {\n effect(() => {\n const count = this.unreadCount();\n untracked(() => {\n const previous = this.lastCount;\n this.lastCount = count;\n if (previous === null || previous === count) return;\n this.announcement.set(count === 0 ? this.labels.t('notificationBell.announce.none') : count === 1 ? this.labels.t('notificationBell.announce.one') : this.labels.t('notificationBell.announce.other', { count }));\n });\n });\n }\n\n toggle(): void {\n const next = !this.open();\n this.open.set(next);\n if (next) this.opened.emit();\n }\n\n close(): void { this.open.set(false); }\n}\n"],"mappings":";;;;;;;;;;;AAiGA,IAAa,4BAAb,MAAa,0BAAyB;CA4CpC,cAAA;EA1CS,KAAA,QAAQ,MAAmC,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAE9C,KAAA,cAAc,MAAM,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;EACtB,KAAA,UAAU,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EACtB,KAAA,cAAc,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;EAE1B,KAAA,QAAQ,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAEjB,KAAA,UAAU,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EAEtB,KAAA,iBAAiB,MAAqB,MAAI;GAAA,GAAA,YAAA,EAAA,WAAA,iBAAA,+BAAA,CAAA;GAAI,OAAO;EAAW,CAAA;EAEhE,KAAA,kBAAkB,MAAqB,MAAI;GAAA,GAAA,YAAA,EAAA,WAAA,kBAAA,+BAAA,CAAA;GAAI,OAAO;EAAY,CAAA;EAElE,KAAA,oBAAoB,MAAqB,MAAI;GAAA,GAAA,YAAA,EAAA,WAAA,oBAAA,+BAAA,CAAA;GAAI,OAAO;EAAc,CAAA;EAEtE,KAAA,WAAW,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;EAEpB,KAAA,OAAO,MAAM,OAAM,GAAA,YAAA,C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