@molecule/app-announcement-bar-angular 0.0.0-stage → 1.1.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.
@@ -0,0 +1,150 @@
1
+ import { type AfterViewInit, type DoCheck, type OnDestroy, type TemplateRef } from '@angular/core';
2
+ import type { UIClassMap } from '@molecule/app-ui';
3
+ import type { AnnouncementBarProps, AnnouncementKind } from './types.js';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * AnnouncementBar component.
7
+ *
8
+ * Persistent announcement banner — product updates, promos, outage notices,
9
+ * feature callouts. Long-lived and prominent, unlike a Toast; carries an
10
+ * action + dismiss, unlike an Alert. The host IS the root `<div>`
11
+ * (`div[mol-announcement-bar]`), matching React's root exactly: `role`,
12
+ * `data-kind` and `data-mol-id` live on it.
13
+ *
14
+ * React renders null while the bar is hidden — Angular's host element always
15
+ * exists, so it is detached from the DOM in that state (the same approach
16
+ * `@molecule/app-bulk-action-toolbar-angular` takes) and restored when the
17
+ * controlled `visible` input or the internal dismissal state shows it again.
18
+ *
19
+ * `kind` is exposed as `data-kind` only; it does not change the bar's colors
20
+ * by itself. The dismiss label comes from `useTranslation()`
21
+ * (`announcement.dismiss`), read reactively so a locale switch refreshes it.
22
+ */
23
+ export declare class AnnouncementBar implements AfterViewInit, DoCheck, OnDestroy {
24
+ /** Optional leading icon: text, a template ref, or `[slot=icon]` content. */
25
+ icon?: TemplateRef<unknown> | string | null;
26
+ /** Optional call-to-action (link or button). */
27
+ action?: NonNullable<AnnouncementBarProps['action']> | null;
28
+ /** Semantic kind (defaults to `'info'` at read time). */
29
+ kind?: AnnouncementKind;
30
+ /** Show a dismiss (×) button (defaults to true at read time). */
31
+ dismissible?: boolean;
32
+ /** Called when the bar is dismissed (React's `onDismiss`; takes no arguments). */
33
+ onDismiss?: () => void;
34
+ /** Controlled visibility — when provided, overrides internal state. */
35
+ visible?: boolean;
36
+ /** Extra classes. */
37
+ className?: string;
38
+ /** `data-mol-id` for AI-agent selectors. */
39
+ dataMolId?: string;
40
+ /**
41
+ * Reactive translation, read in the injection context. Its `t` reads the
42
+ * locale, so the view re-renders the text on a locale switch (the static `t`
43
+ * does not).
44
+ */
45
+ private readonly i18n;
46
+ /** The host element (the root `<div>`), for the null-render detach. */
47
+ private readonly el;
48
+ /** Whether the bar is visible when `visible` is not given (React's `useState`). */
49
+ private readonly internalVisible;
50
+ /** Where the detached host lives, for the restore. */
51
+ private detachedParent;
52
+ /** The node the detached host is restored before. */
53
+ private detachedAnchor;
54
+ /**
55
+ * The current class map.
56
+ * @returns The UIClassMap.
57
+ */
58
+ cm(): UIClassMap;
59
+ /**
60
+ * The wrapper class list (React's `cm.cn(cm.flex({…}), cm.sp('px', 4), cm.sp('py', 2), className)`).
61
+ * @returns The class string.
62
+ */
63
+ classes(): string;
64
+ /**
65
+ * The inner rows' class (React's `cm.flex({ align: 'center', gap: 'sm' })`).
66
+ * @returns The class string.
67
+ */
68
+ rowClasses(): string;
69
+ /**
70
+ * The message span's class (React's `cm.textSize('sm')`).
71
+ * @returns The class string.
72
+ */
73
+ messageClasses(): string;
74
+ /**
75
+ * The action's class list (React's
76
+ * `cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'), cm.link)`).
77
+ * @returns The class string.
78
+ */
79
+ actionClasses(): string;
80
+ /**
81
+ * The dismiss button's class list (React's
82
+ * `cm.cn(cm.w(6), cm.h(6), cm.flex({ align: 'center', justify: 'center' }))`).
83
+ * @returns The class string.
84
+ */
85
+ dismissClasses(): string;
86
+ /**
87
+ * The text fallback used when a value is not a template.
88
+ *
89
+ * @param value - The prop value.
90
+ * @returns The text to render.
91
+ */
92
+ textOf(value: unknown): string;
93
+ /**
94
+ * The icon as a template, when the caller passed a node.
95
+ * @returns The icon template, or null.
96
+ */
97
+ iconTemplate(): TemplateRef<unknown> | null;
98
+ /**
99
+ * Whether the icon input renders as text (React renders any non-empty
100
+ * string node; `''` and `null` render nothing).
101
+ * @returns True when the icon text renders.
102
+ */
103
+ hasIconText(): boolean;
104
+ /**
105
+ * The action label as a template, when the caller passed a node.
106
+ * @returns The label template, or null.
107
+ */
108
+ labelTemplate(): TemplateRef<unknown> | null;
109
+ /**
110
+ * The dismiss button's accessible label (React's `announcement.dismiss`).
111
+ * @returns The label text.
112
+ */
113
+ dismissLabel(): string;
114
+ /**
115
+ * Whether the bar renders (React's `visible ?? internalVisible`).
116
+ * @returns True while visible.
117
+ */
118
+ isVisible(): boolean;
119
+ /**
120
+ * Hides the bar (internal state, unless `visible` controls it) and fires
121
+ * `onDismiss` — React's `dismiss`.
122
+ */
123
+ dismiss(): void;
124
+ /**
125
+ * Calls the action's `onClick` with the click event, as React's DOM handler
126
+ * does.
127
+ *
128
+ * @param event - The native click event.
129
+ */
130
+ runAction(event: MouseEvent): void;
131
+ /**
132
+ * Removes the host element from the DOM while React would render null, and
133
+ * restores it when the bar is shown again.
134
+ */
135
+ syncHostVisibility(): void;
136
+ /**
137
+ * Reconciles host visibility once the view is in the document: the first
138
+ * ngDoCheck of a cycle runs before Angular has inserted a freshly created
139
+ * view, so the mount-time decision (React renders null while hidden) is
140
+ * applied here, where the host is connected and can be detached.
141
+ */
142
+ ngAfterViewInit(): void;
143
+ /** Re-reconciles host visibility after input writes. */
144
+ ngDoCheck(): void;
145
+ /** Restores the host before Angular removes it (unmount). */
146
+ ngOnDestroy(): void;
147
+ static ɵfac: i0.ɵɵFactoryDeclaration<AnnouncementBar, never>;
148
+ static ɵcmp: i0.ɵɵComponentDeclaration<AnnouncementBar, "div[mol-announcement-bar]", never, { "icon": { "alias": "icon"; "required": false; }; "action": { "alias": "action"; "required": false; }; "kind": { "alias": "kind"; "required": false; }; "dismissible": { "alias": "dismissible"; "required": false; }; "onDismiss": { "alias": "onDismiss"; "required": false; }; "visible": { "alias": "visible"; "required": false; }; "className": { "alias": "className"; "required": false; }; "dataMolId": { "alias": "dataMolId"; "required": false; }; }, {}, never, ["[slot=icon]", "*"], true, never>;
149
+ }
150
+ //# sourceMappingURL=announcement-bar.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announcement-bar.component.d.ts","sourceRoot":"","sources":["../src/announcement-bar.component.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,OAAO,EAGZ,KAAK,SAAS,EAEd,KAAK,WAAW,EACjB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;;AAwBxE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBA2Da,eAAgB,YAAW,aAAa,EAAE,OAAO,EAAE,SAAS;IACvE,6EAA6E;IAC7E,IAAI,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3C,gDAAgD;IAChD,MAAM,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAA;IAC3D,yDAAyD;IACzD,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,iEAAiE;IACjE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IACxC,uEAAuE;IACvE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAqB;IACxC,mFAAmF;IACnF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAe;IAC/C,sDAAsD;IACtD,OAAO,CAAC,cAAc,CAAoB;IAC1C,qDAAqD;IACrD,OAAO,CAAC,cAAc,CAAoB;IAE1C;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;OAGG;IACH,OAAO,IAAI,MAAM;IASjB;;;OAGG;IACH,UAAU,IAAI,MAAM;IAIpB;;;OAGG;IACH,cAAc,IAAI,MAAM;IAIxB;;;;OAIG;IACH,aAAa,IAAI,MAAM;IAIvB;;;;OAIG;IACH,cAAc,IAAI,MAAM;IAQxB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;IAI9B;;;OAGG;IACH,YAAY,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAI3C;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACH,aAAa,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAI5C;;;OAGG;IACH,YAAY,IAAI,MAAM;IAItB;;;OAGG;IACH,SAAS,IAAI,OAAO;IAIpB;;;OAGG;IACH,OAAO,IAAI,IAAI;IAKf;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAIlC;;;OAGG;IACH,kBAAkB,IAAI,IAAI;IAe1B;;;;;OAKG;IACH,eAAe,IAAI,IAAI;IAIvB,wDAAwD;IACxD,SAAS,IAAI,IAAI;IAIjB,6DAA6D;IAC7D,WAAW,IAAI,IAAI;yCArMR,eAAe;2CAAf,eAAe;CA8M3B"}
@@ -0,0 +1,402 @@
1
+ /**
2
+ * AnnouncementBar component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { NgTemplateOutlet } from '@angular/common';
7
+ import { Component, ElementRef, inject, signal, } from '@angular/core';
8
+ import { useTranslation } from '@molecule/app-angular';
9
+ import { getClassMap } from '@molecule/app-ui';
10
+ import * as i0 from "@angular/core";
11
+ const _c0 = [[["", "slot", "icon"]], "*"];
12
+ const _c1 = ["[slot=icon]", "*"];
13
+ function AnnouncementBar_Conditional_2_Template(rf, ctx) { if (rf & 1) {
14
+ i0.ɵɵelementContainer(0, 0);
15
+ } if (rf & 2) {
16
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
17
+ } }
18
+ function AnnouncementBar_Conditional_3_Template(rf, ctx) { if (rf & 1) {
19
+ i0.ɵɵelementContainerStart(0);
20
+ i0.ɵɵtext(1);
21
+ i0.ɵɵelementContainerEnd();
22
+ } if (rf & 2) {
23
+ const ctx_r0 = i0.ɵɵnextContext();
24
+ i0.ɵɵadvance();
25
+ i0.ɵɵtextInterpolate(ctx_r0.textOf(ctx_r0.icon));
26
+ } }
27
+ function AnnouncementBar_Conditional_7_Conditional_1_Template(rf, ctx) { if (rf & 1) {
28
+ i0.ɵɵelementContainer(0, 0);
29
+ } if (rf & 2) {
30
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
31
+ } }
32
+ function AnnouncementBar_Conditional_7_Conditional_2_Template(rf, ctx) { if (rf & 1) {
33
+ i0.ɵɵelementContainerStart(0);
34
+ i0.ɵɵtext(1);
35
+ i0.ɵɵelementContainerEnd();
36
+ } if (rf & 2) {
37
+ const ctx_r0 = i0.ɵɵnextContext(2);
38
+ i0.ɵɵadvance();
39
+ i0.ɵɵtextInterpolate(ctx_r0.textOf(ctx_r0.action.label));
40
+ } }
41
+ function AnnouncementBar_Conditional_7_Template(rf, ctx) { if (rf & 1) {
42
+ i0.ɵɵelementStart(0, "a");
43
+ i0.ɵɵconditionalCreate(1, AnnouncementBar_Conditional_7_Conditional_1_Template, 1, 1, "ng-container", 0)(2, AnnouncementBar_Conditional_7_Conditional_2_Template, 2, 1, "ng-container");
44
+ i0.ɵɵelementEnd();
45
+ } if (rf & 2) {
46
+ let tmp_3_0;
47
+ const ctx_r0 = i0.ɵɵnextContext();
48
+ i0.ɵɵclassMap(ctx_r0.actionClasses());
49
+ i0.ɵɵattribute("href", ctx_r0.action.href, i0.ɵɵsanitizeUrl);
50
+ i0.ɵɵadvance();
51
+ i0.ɵɵconditional((tmp_3_0 = ctx_r0.labelTemplate()) ? 1 : 2, tmp_3_0);
52
+ } }
53
+ function AnnouncementBar_Conditional_8_Conditional_1_Template(rf, ctx) { if (rf & 1) {
54
+ i0.ɵɵelementContainer(0, 0);
55
+ } if (rf & 2) {
56
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
57
+ } }
58
+ function AnnouncementBar_Conditional_8_Conditional_2_Template(rf, ctx) { if (rf & 1) {
59
+ i0.ɵɵelementContainerStart(0);
60
+ i0.ɵɵtext(1);
61
+ i0.ɵɵelementContainerEnd();
62
+ } if (rf & 2) {
63
+ const ctx_r0 = i0.ɵɵnextContext(2);
64
+ i0.ɵɵadvance();
65
+ i0.ɵɵtextInterpolate(ctx_r0.textOf(ctx_r0.action.label));
66
+ } }
67
+ function AnnouncementBar_Conditional_8_Template(rf, ctx) { if (rf & 1) {
68
+ const _r2 = i0.ɵɵgetCurrentView();
69
+ i0.ɵɵelementStart(0, "button", 3);
70
+ i0.ɵɵlistener("click", function AnnouncementBar_Conditional_8_Template_button_click_0_listener($event) { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.runAction($event)); });
71
+ i0.ɵɵconditionalCreate(1, AnnouncementBar_Conditional_8_Conditional_1_Template, 1, 1, "ng-container", 0)(2, AnnouncementBar_Conditional_8_Conditional_2_Template, 2, 1, "ng-container");
72
+ i0.ɵɵelementEnd();
73
+ } if (rf & 2) {
74
+ let tmp_2_0;
75
+ const ctx_r0 = i0.ɵɵnextContext();
76
+ i0.ɵɵclassMap(ctx_r0.actionClasses());
77
+ i0.ɵɵadvance();
78
+ i0.ɵɵconditional((tmp_2_0 = ctx_r0.labelTemplate()) ? 1 : 2, tmp_2_0);
79
+ } }
80
+ function AnnouncementBar_Conditional_9_Template(rf, ctx) { if (rf & 1) {
81
+ const _r3 = i0.ɵɵgetCurrentView();
82
+ i0.ɵɵelementStart(0, "button", 3);
83
+ i0.ɵɵlistener("click", function AnnouncementBar_Conditional_9_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.dismiss()); });
84
+ i0.ɵɵtext(1, " \u00D7 ");
85
+ i0.ɵɵelementEnd();
86
+ } if (rf & 2) {
87
+ const ctx_r0 = i0.ɵɵnextContext();
88
+ i0.ɵɵclassMap(ctx_r0.dismissClasses());
89
+ i0.ɵɵattribute("aria-label", ctx_r0.dismissLabel());
90
+ } }
91
+ /**
92
+ * Whether a node-valued prop is an Angular template (a projected node) rather
93
+ * than plain text. Checked structurally — `TemplateRef` is a type-only import
94
+ * in the emitted metadata, so `instanceof` is not dependable across bundles.
95
+ *
96
+ * @param value - The prop value.
97
+ * @returns True when it can be rendered with `ngTemplateOutlet`.
98
+ */
99
+ const isTemplate = (value) => typeof value === 'object' &&
100
+ value !== null &&
101
+ typeof value.createEmbeddedView === 'function';
102
+ /**
103
+ * Renders a text value the way React renders a node string.
104
+ *
105
+ * @param value - The prop value.
106
+ * @returns The text to render, or `''` when there is nothing.
107
+ */
108
+ const textOf = (value) => value === null || value === undefined ? '' : String(value);
109
+ /**
110
+ * AnnouncementBar component.
111
+ *
112
+ * Persistent announcement banner — product updates, promos, outage notices,
113
+ * feature callouts. Long-lived and prominent, unlike a Toast; carries an
114
+ * action + dismiss, unlike an Alert. The host IS the root `<div>`
115
+ * (`div[mol-announcement-bar]`), matching React's root exactly: `role`,
116
+ * `data-kind` and `data-mol-id` live on it.
117
+ *
118
+ * React renders null while the bar is hidden — Angular's host element always
119
+ * exists, so it is detached from the DOM in that state (the same approach
120
+ * `@molecule/app-bulk-action-toolbar-angular` takes) and restored when the
121
+ * controlled `visible` input or the internal dismissal state shows it again.
122
+ *
123
+ * `kind` is exposed as `data-kind` only; it does not change the bar's colors
124
+ * by itself. The dismiss label comes from `useTranslation()`
125
+ * (`announcement.dismiss`), read reactively so a locale switch refreshes it.
126
+ */
127
+ export class AnnouncementBar {
128
+ /** Optional leading icon: text, a template ref, or `[slot=icon]` content. */
129
+ icon;
130
+ /** Optional call-to-action (link or button). */
131
+ action;
132
+ /** Semantic kind (defaults to `'info'` at read time). */
133
+ kind;
134
+ /** Show a dismiss (×) button (defaults to true at read time). */
135
+ dismissible;
136
+ /** Called when the bar is dismissed (React's `onDismiss`; takes no arguments). */
137
+ onDismiss;
138
+ /** Controlled visibility — when provided, overrides internal state. */
139
+ visible;
140
+ /** Extra classes. */
141
+ className;
142
+ /** `data-mol-id` for AI-agent selectors. */
143
+ dataMolId;
144
+ /**
145
+ * Reactive translation, read in the injection context. Its `t` reads the
146
+ * locale, so the view re-renders the text on a locale switch (the static `t`
147
+ * does not).
148
+ */
149
+ i18n = useTranslation();
150
+ /** The host element (the root `<div>`), for the null-render detach. */
151
+ el = inject(ElementRef);
152
+ /** Whether the bar is visible when `visible` is not given (React's `useState`). */
153
+ internalVisible = signal(true, /* @ts-ignore */
154
+ ...(ngDevMode ? [{ debugName: "internalVisible" }] : /* istanbul ignore next */ []));
155
+ /** Where the detached host lives, for the restore. */
156
+ detachedParent = null;
157
+ /** The node the detached host is restored before. */
158
+ detachedAnchor = null;
159
+ /**
160
+ * The current class map.
161
+ * @returns The UIClassMap.
162
+ */
163
+ cm() {
164
+ return getClassMap();
165
+ }
166
+ /**
167
+ * The wrapper class list (React's `cm.cn(cm.flex({…}), cm.sp('px', 4), cm.sp('py', 2), className)`).
168
+ * @returns The class string.
169
+ */
170
+ classes() {
171
+ return this.cm().cn(this.cm().flex({ align: 'center', justify: 'between', gap: 'md', wrap: 'wrap' }), this.cm().sp('px', 4), this.cm().sp('py', 2), this.className);
172
+ }
173
+ /**
174
+ * The inner rows' class (React's `cm.flex({ align: 'center', gap: 'sm' })`).
175
+ * @returns The class string.
176
+ */
177
+ rowClasses() {
178
+ return this.cm().flex({ align: 'center', gap: 'sm' });
179
+ }
180
+ /**
181
+ * The message span's class (React's `cm.textSize('sm')`).
182
+ * @returns The class string.
183
+ */
184
+ messageClasses() {
185
+ return this.cm().textSize('sm');
186
+ }
187
+ /**
188
+ * The action's class list (React's
189
+ * `cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'), cm.link)`).
190
+ * @returns The class string.
191
+ */
192
+ actionClasses() {
193
+ return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('semibold'), this.cm().link);
194
+ }
195
+ /**
196
+ * The dismiss button's class list (React's
197
+ * `cm.cn(cm.w(6), cm.h(6), cm.flex({ align: 'center', justify: 'center' }))`).
198
+ * @returns The class string.
199
+ */
200
+ dismissClasses() {
201
+ return this.cm().cn(this.cm().w(6), this.cm().h(6), this.cm().flex({ align: 'center', justify: 'center' }));
202
+ }
203
+ /**
204
+ * The text fallback used when a value is not a template.
205
+ *
206
+ * @param value - The prop value.
207
+ * @returns The text to render.
208
+ */
209
+ textOf(value) {
210
+ return textOf(value);
211
+ }
212
+ /**
213
+ * The icon as a template, when the caller passed a node.
214
+ * @returns The icon template, or null.
215
+ */
216
+ iconTemplate() {
217
+ return isTemplate(this.icon) ? this.icon : null;
218
+ }
219
+ /**
220
+ * Whether the icon input renders as text (React renders any non-empty
221
+ * string node; `''` and `null` render nothing).
222
+ * @returns True when the icon text renders.
223
+ */
224
+ hasIconText() {
225
+ return typeof this.icon === 'string' ? this.icon !== '' : typeof this.icon === 'number';
226
+ }
227
+ /**
228
+ * The action label as a template, when the caller passed a node.
229
+ * @returns The label template, or null.
230
+ */
231
+ labelTemplate() {
232
+ return isTemplate(this.action?.label) ? this.action.label : null;
233
+ }
234
+ /**
235
+ * The dismiss button's accessible label (React's `announcement.dismiss`).
236
+ * @returns The label text.
237
+ */
238
+ dismissLabel() {
239
+ return this.i18n.t('announcement.dismiss', {}, { defaultValue: 'Dismiss' });
240
+ }
241
+ /**
242
+ * Whether the bar renders (React's `visible ?? internalVisible`).
243
+ * @returns True while visible.
244
+ */
245
+ isVisible() {
246
+ return this.visible ?? this.internalVisible();
247
+ }
248
+ /**
249
+ * Hides the bar (internal state, unless `visible` controls it) and fires
250
+ * `onDismiss` — React's `dismiss`.
251
+ */
252
+ dismiss() {
253
+ if (this.visible === undefined)
254
+ this.internalVisible.set(false);
255
+ this.onDismiss?.();
256
+ }
257
+ /**
258
+ * Calls the action's `onClick` with the click event, as React's DOM handler
259
+ * does.
260
+ *
261
+ * @param event - The native click event.
262
+ */
263
+ runAction(event) {
264
+ this.action?.onClick?.(event);
265
+ }
266
+ /**
267
+ * Removes the host element from the DOM while React would render null, and
268
+ * restores it when the bar is shown again.
269
+ */
270
+ syncHostVisibility() {
271
+ const host = this.el.nativeElement;
272
+ if (!this.isVisible()) {
273
+ if (host.isConnected) {
274
+ this.detachedParent = host.parentNode;
275
+ this.detachedAnchor = host.nextSibling;
276
+ host.parentNode?.removeChild(host);
277
+ }
278
+ }
279
+ else if (this.detachedParent && !host.isConnected) {
280
+ this.detachedParent.insertBefore(host, this.detachedAnchor);
281
+ this.detachedParent = null;
282
+ this.detachedAnchor = null;
283
+ }
284
+ }
285
+ /**
286
+ * Reconciles host visibility once the view is in the document: the first
287
+ * ngDoCheck of a cycle runs before Angular has inserted a freshly created
288
+ * view, so the mount-time decision (React renders null while hidden) is
289
+ * applied here, where the host is connected and can be detached.
290
+ */
291
+ ngAfterViewInit() {
292
+ this.syncHostVisibility();
293
+ }
294
+ /** Re-reconciles host visibility after input writes. */
295
+ ngDoCheck() {
296
+ this.syncHostVisibility();
297
+ }
298
+ /** Restores the host before Angular removes it (unmount). */
299
+ ngOnDestroy() {
300
+ const host = this.el.nativeElement;
301
+ // The host must be inside its parent for Angular's own removal to succeed.
302
+ if (!host.isConnected && this.detachedParent) {
303
+ this.detachedParent.insertBefore(host, this.detachedAnchor);
304
+ this.detachedParent = null;
305
+ this.detachedAnchor = null;
306
+ }
307
+ }
308
+ static ɵfac = function AnnouncementBar_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AnnouncementBar)(); };
309
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AnnouncementBar, selectors: [["div", "mol-announcement-bar", ""]], hostAttrs: ["role", "status"], hostVars: 4, hostBindings: function AnnouncementBar_HostBindings(rf, ctx) { if (rf & 2) {
310
+ i0.ɵɵattribute("data-mol-id", ctx.dataMolId ?? null)("data-kind", ctx.kind ?? "info");
311
+ i0.ɵɵclassMap(ctx.classes());
312
+ } }, inputs: { icon: "icon", action: "action", kind: "kind", dismissible: "dismissible", onDismiss: "onDismiss", visible: "visible", className: "className", dataMolId: "dataMolId" }, ngContentSelectors: _c1, decls: 10, vars: 9, consts: [[3, "ngTemplateOutlet"], [3, "class"], ["type", "button", 3, "class"], ["type", "button", 3, "click"]], template: function AnnouncementBar_Template(rf, ctx) { if (rf & 1) {
313
+ i0.ɵɵprojectionDef(_c0);
314
+ i0.ɵɵelementStart(0, "div");
315
+ i0.ɵɵprojection(1);
316
+ i0.ɵɵconditionalCreate(2, AnnouncementBar_Conditional_2_Template, 1, 1, "ng-container", 0)(3, AnnouncementBar_Conditional_3_Template, 2, 1, "ng-container");
317
+ i0.ɵɵelementStart(4, "span");
318
+ i0.ɵɵprojection(5, 1);
319
+ i0.ɵɵelementEnd()();
320
+ i0.ɵɵelementStart(6, "div");
321
+ i0.ɵɵconditionalCreate(7, AnnouncementBar_Conditional_7_Template, 3, 4, "a", 1)(8, AnnouncementBar_Conditional_8_Template, 3, 3, "button", 2);
322
+ i0.ɵɵconditionalCreate(9, AnnouncementBar_Conditional_9_Template, 2, 3, "button", 2);
323
+ i0.ɵɵelementEnd();
324
+ } if (rf & 2) {
325
+ let tmp_1_0;
326
+ i0.ɵɵclassMap(ctx.rowClasses());
327
+ i0.ɵɵadvance(2);
328
+ i0.ɵɵconditional((tmp_1_0 = ctx.iconTemplate()) ? 2 : ctx.hasIconText() ? 3 : -1, tmp_1_0);
329
+ i0.ɵɵadvance(2);
330
+ i0.ɵɵclassMap(ctx.messageClasses());
331
+ i0.ɵɵadvance(2);
332
+ i0.ɵɵclassMap(ctx.rowClasses());
333
+ i0.ɵɵadvance();
334
+ i0.ɵɵconditional(ctx.action?.href ? 7 : ctx.action ? 8 : -1);
335
+ i0.ɵɵadvance(2);
336
+ i0.ɵɵconditional(ctx.dismissible ?? true ? 9 : -1);
337
+ } }, dependencies: [NgTemplateOutlet], encapsulation: 2 });
338
+ }
339
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AnnouncementBar, [{
340
+ type: Component,
341
+ args: [{
342
+ selector: 'div[mol-announcement-bar]',
343
+ standalone: true,
344
+ imports: [NgTemplateOutlet],
345
+ inputs: [
346
+ 'icon',
347
+ 'action',
348
+ 'kind',
349
+ 'dismissible',
350
+ 'onDismiss',
351
+ 'visible',
352
+ 'className',
353
+ 'dataMolId',
354
+ ],
355
+ host: {
356
+ role: 'status',
357
+ '[attr.data-mol-id]': 'dataMolId ?? null',
358
+ '[attr.data-kind]': 'kind ?? "info"',
359
+ '[class]': 'classes()',
360
+ },
361
+ template: `<div [class]="rowClasses()">
362
+ <ng-content select="[slot=icon]"></ng-content>
363
+ @if (iconTemplate(); as tpl) {
364
+ <ng-container [ngTemplateOutlet]="tpl" />
365
+ } @else if (hasIconText()) {
366
+ <ng-container>{{ textOf(icon) }}</ng-container>
367
+ }
368
+ <span [class]="messageClasses()"><ng-content></ng-content></span>
369
+ </div>
370
+ <div [class]="rowClasses()">
371
+ @if (action?.href) {
372
+ <a [attr.href]="action.href" [class]="actionClasses()">
373
+ @if (labelTemplate(); as tpl) {
374
+ <ng-container [ngTemplateOutlet]="tpl" />
375
+ } @else {
376
+ <ng-container>{{ textOf(action.label) }}</ng-container>
377
+ }
378
+ </a>
379
+ } @else if (action) {
380
+ <button type="button" (click)="runAction($event)" [class]="actionClasses()">
381
+ @if (labelTemplate(); as tpl) {
382
+ <ng-container [ngTemplateOutlet]="tpl" />
383
+ } @else {
384
+ <ng-container>{{ textOf(action.label) }}</ng-container>
385
+ }
386
+ </button>
387
+ }
388
+ @if (dismissible ?? true) {
389
+ <button
390
+ type="button"
391
+ (click)="dismiss()"
392
+ [attr.aria-label]="dismissLabel()"
393
+ [class]="dismissClasses()"
394
+ >
395
+ ×
396
+ </button>
397
+ }
398
+ </div>`,
399
+ }]
400
+ }], null, null); })();
401
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AnnouncementBar, { className: "AnnouncementBar", filePath: "announcement-bar.component.ts", lineNumber: 124 }); })();
402
+ //# sourceMappingURL=announcement-bar.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announcement-bar.component.js","sourceRoot":"","sources":["../src/announcement-bar.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAEL,SAAS,EAET,UAAU,EACV,MAAM,EAEN,MAAM,GAEP,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;;;;;IAmEtC,2BAAyC;;IAA3B,sCAAwB;;;IAEtC,6BAAc;IAAA,YAAkB;;;;IAAlB,cAAkB;IAAlB,gDAAkB;;;IAQ5B,2BAAyC;;IAA3B,sCAAwB;;;IAEtC,6BAAc;IAAA,YAA0B;;;;IAA1B,cAA0B;IAA1B,wDAA0B;;;IAJ5C,yBAAuD;IAGnD,AAFF,wGAA+B,+EAEtB;IAGX,iBAAI;;;;IANyB,qCAAyB;;IACpD,cAIC;IAJD,qEAIC;;;IAKC,2BAAyC;;IAA3B,sCAAwB;;;IAEtC,6BAAc;IAAA,YAA0B;;;;IAA1B,cAA0B;IAA1B,wDAA0B;;;;IAJ5C,iCAA4E;IAAtD,yLAAS,wBAAiB,KAAC;IAG7C,AAFF,wGAA+B,+EAEtB;IAGX,iBAAS;;;;IANyC,qCAAyB;IACzE,cAIC;IAJD,qEAIC;;;;IAIH,iCAKC;IAHC,mLAAS,gBAAS,KAAC;IAInB,wBACF;IAAA,iBAAS;;;IAHP,sCAA0B;;;AA5FpC;;;;;;;GAOG;AACH,MAAM,U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B,mCAA0B;YAE7B,eAAsB;YAAtB,+BAAsB;YACzB,cAgBC;YAhBD,4DAgBC;YACD,eASC;YATD,kDASC;4BArDK,gBAAgB;;iFAwDf,eAAe;cA3D3B,SAAS;eAAC;gBACT,QAAQ,EAAE,2BAA2B;gBACrC,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,gBAAgB,CAAC;gBAC3B,MAAM,EAAE;oBACN,MAAM;oBACN,QAAQ;oBACR,MAAM;oBACN,aAAa;oBACb,WAAW;oBACX,SAAS;oBACT,WAAW;oBACX,WAAW;iBACZ;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,oBAAoB,EAAE,mBAAmB;oBACzC,kBAAkB,EAAE,gBAAgB;oBACpC,SAAS,EAAE,WAAW;iBACvB;gBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAqCD;aACV;;kFACY,eAAe"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Angular announcement / promo bar.
3
+ *
4
+ * Exports `<AnnouncementBar>` — persistent top-of-page banner with icon,
5
+ * message, optional action (link or button), and optional dismiss (×).
6
+ * Long-lived and prominent, unlike a Toast; carries an action slot +
7
+ * dismiss, unlike an Alert. It is the Angular counterpart of
8
+ * `@molecule/app-announcement-bar-react`: same props (React names), same DOM
9
+ * for the same input, same ClassMap tokens and i18n keys.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { Component } from '@angular/core'
14
+ * import { AnnouncementBar } from '@molecule/app-announcement-bar-angular'
15
+ *
16
+ * @Component({
17
+ * selector: 'app-page',
18
+ * standalone: true,
19
+ * imports: [AnnouncementBar],
20
+ * template: `
21
+ * <div
22
+ * mol-announcement-bar
23
+ * [kind]="'promo'"
24
+ * [icon]="'🎉'"
25
+ * [action]="{ label: 'Learn more', href: '/pricing' }"
26
+ * [onDismiss]="() => onDismissed()"
27
+ * [dataMolId]="'promo-bar'"
28
+ * >
29
+ * New Pro plan — 3 months free for early adopters.
30
+ * </div>
31
+ * `,
32
+ * })
33
+ * export class Page {
34
+ * onDismissed(): void {
35
+ * console.log('dismissed')
36
+ * }
37
+ * }
38
+ * ```
39
+ *
40
+ * @remarks
41
+ * `kind` is exposed as a `data-kind` attribute on the root — it does NOT
42
+ * change the bar's colors by itself; style per-kind via `className` or a
43
+ * `[data-kind="…"]` selector. Dismissal is uncontrolled by default
44
+ * (internal state; the bar stays hidden until remount) — bind `visible`
45
+ * to control it, e.g. to persist dismissal per user. `dismissible`
46
+ * defaults to `true`. There is no default `data-mol-id`; bind `dataMolId`
47
+ * so agents/E2E can target the bar. The message is projected content and
48
+ * the icon is either the `icon` input (text or an `<ng-template>` ref) or
49
+ * `[slot=icon]` content. The dismiss label comes from the companion
50
+ * `@molecule/app-locales-announcement-bar` locale bond.
51
+ *
52
+ * @module
53
+ */
54
+ export * from './announcement-bar.component.js';
55
+ export * from './types.js';
56
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,cAAc,iCAAiC,CAAA;AAC/C,cAAc,YAAY,CAAA"}