@molecule/app-cookie-banner-angular 0.0.0-stage → 0.0.1-stage

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,407 @@
1
- # Temporary Holding Version
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-11-18T20:20:19.831Z
7
+ -->
2
8
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
9
+ # @molecule/app-cookie-banner-angular
10
+
11
+ Angular GDPR cookie consent banner — the counterpart of
12
+ `@molecule/app-cookie-banner-react`: the same props and the same DOM for the
13
+ same input.
14
+
15
+ Exports `<CookieBanner>` and the `CookieCategory` type. Two modes: Accept /
16
+ Reject only, or per-category switches behind "Customize" when `categories`
17
+ are supplied.
18
+
19
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
20
+ > It is written to be read by coding agents as much as by people, and is generated from this
21
+ > package's source — edit `src/index.ts` JSDoc, not this file.
22
+
23
+ ## Quick Start
24
+
25
+ ```ts
26
+ import { Component } from '@angular/core'
27
+ import { CookieBanner } from '@molecule/app-cookie-banner-angular'
28
+
29
+ @Component({
30
+ selector: 'app-consent',
31
+ standalone: true,
32
+ imports: [CookieBanner],
33
+ template: `
34
+ <div
35
+ mol-cookie-banner
36
+ [visible]="!consentGiven"
37
+ [policyHref]="'/privacy'"
38
+ [categories]="categories"
39
+ [onAcceptAll]="acceptAll"
40
+ [onRejectAll]="rejectAll"
41
+ [onSave]="save"
42
+ [onDismiss]="dismiss"
43
+ ></div>
44
+ `,
45
+ })
46
+ export class Consent {
47
+ consentGiven = false
48
+ categories = [
49
+ { id: 'essential', label: 'Essential', required: true },
50
+ { id: 'analytics', label: 'Analytics', defaultEnabled: false },
51
+ ]
52
+ acceptAll = (): void => saveConsent('all')
53
+ rejectAll = (): void => saveConsent('essential')
54
+ save = (enabled: Record<string, boolean>): void => saveConsent(enabled)
55
+ dismiss = (): void => {
56
+ this.consentGiven = true
57
+ }
58
+ }
59
+ ```
60
+
61
+ ## Type
62
+
63
+ `feature`
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ npm install @molecule/app-cookie-banner-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
69
+ ```
70
+
71
+ ## API
72
+
73
+ ### Interfaces
74
+
75
+ #### `CookieCategory`
76
+
77
+ Describes a single cookie category offered in the granular consent UI.
78
+
79
+ ```typescript
80
+ interface CookieCategory {
81
+ /** Stable category id (also the key of the consent map). */
82
+ id: string
83
+ /** Display label — text, or a projected template. */
84
+ label: NodeValue
85
+ /** Optional explanation — text, or a projected template. */
86
+ description?: NodeValue
87
+ /** Whether this category is required (always on). */
88
+ required?: boolean
89
+ /** Initial enabled state. */
90
+ defaultEnabled?: boolean
91
+ }
92
+ ```
93
+
94
+ #### `CookieBannerProps`
95
+
96
+ Props accepted by {@link CookieBanner} — the same props
97
+ `@molecule/app-cookie-banner-react` accepts. Node props (`title`,
98
+ `description`) are projected content in Angular (an input cannot carry a
99
+ node), so they are typed `unknown`: pass them in the host template, not as
100
+ values. `visible` defaults to true at read time.
101
+
102
+ ```typescript
103
+ interface CookieBannerProps {
104
+ /** Cookie categories to offer (omit for a simple accept/reject banner). */
105
+ categories?: CookieCategory[]
106
+ /** Called when accept-all is clicked. */
107
+ onAcceptAll?: () => void
108
+ /** Called when reject-non-essential is clicked. */
109
+ onRejectAll?: () => void
110
+ /** Called when "Save preferences" is clicked. */
111
+ onSave?: (enabled: Record<string, boolean>) => void
112
+ /** Optional title, projected as `[slot=title]` content or passed as text. */
113
+ title?: unknown
114
+ /** Optional description, projected as `[slot=description]` content or passed as text. */
115
+ description?: unknown
116
+ /** Privacy policy link URL. */
117
+ policyHref?: string
118
+ /** Whether the banner is visible (controlled). */
119
+ visible?: boolean
120
+ /** Called when dismissed via Save / Accept / Reject. */
121
+ onDismiss?: () => void
122
+ /** Extra classes. */
123
+ className?: string
124
+ }
125
+ ```
126
+
127
+ ### Classes
128
+
129
+ #### `CookieBanner`
130
+
131
+ CookieBanner component.
132
+
133
+ GDPR / cookie-consent banner: two modes, Accept / Reject only or per-category
134
+ switches behind "Customize" when `categories` are supplied. The host IS the
135
+ root `<div>` (`div[mol-cookie-banner]`), matching React's root exactly, so the
136
+ banner's ClassMap classes, `role`, `aria-label` and inline style are the
137
+ host's.
138
+
139
+ React renders `null` while `visible` is false — Angular's host element always
140
+ exists, so it is detached from the DOM in that state and restored when the
141
+ banner is shown again. The node props are projected slots: `title` renders
142
+ inside the `<h3>`, `description` inside the `<p>`; plain string inputs render
143
+ as text instead, the same values React renders.
144
+
145
+ ```typescript
146
+ @Component({
147
+ selector: 'div[mol-cookie-banner]',
148
+ standalone: true,
149
+ imports: [Button, NgTemplateOutlet, Switch],
150
+ inputs: [
151
+ 'categories',
152
+ 'onAcceptAll',
153
+ 'onRejectAll',
154
+ 'onSave',
155
+ 'title',
156
+ 'description',
157
+ 'policyHref',
158
+ 'visible',
159
+ 'onDismiss',
160
+ 'className',
161
+ ],
162
+ host: {
163
+ role: 'dialog',
164
+ '[attr.aria-label]': 'ariaLabel()',
165
+ '[class]': 'classes()',
166
+ '[style]': 'hostStyle()',
167
+ },
168
+ template: `<header [class]="cm().stack(1)"><h3 [class]="titleClasses()"><span #titleFallback>{{ titleText() }}</span><span #titleSlot><ng-content select="[slot=title]"></ng-content></span></h3><p [class]="cm().textSize('sm')"><span #descriptionFallback>{{ descriptionText() }}</span><span #descriptionSlot><ng-content select="[slot=description]"></ng-content></span>@if (policyHref) {<ng-container>{{ leadingSpace }}</ng-container><a [class]="cm().link" [attr.href]="policyHref">{{ learnMoreText() }}</a>.}</p></header>@if (showDetails && hasCategories()) {<div [attr.id]="detailsId" [class]="cm().stack(2)">@for (category of categories ?? []; track category.id; let i = $index) {<div [class]="rowClasses()"><div [class]="textColumnClasses()"><span [attr.id]="labelId(i)" [class]="labelClasses()">@if (isTemplate(category.label)) {<ng-container [ngTemplateOutlet]="asTemplate(category.label)" />} @else {{{ category.label }}}</span>@if (category.description) {<span [attr.id]="descriptionId(i)" [class]="cm().textSize('xs')">@if (isTemplate(category.description)) {<ng-container [ngTemplateOutlet]="asTemplate(category.description)" />} @else {{{ category.description }}}</span>}</div><mol-switch [checked]="isChecked(category)" [disabled]="category.required === true" [attr.aria-labelledby]="labelId(i)" [attr.aria-describedby]="category.description ? descriptionId(i) : null" (change)="toggle(category, $event)"></mol-switch></div>}</div>}<footer [class]="footerClasses()">@if (hasCategories()) {<button mol-button [variant]="'ghost'" [size]="'sm'" [attr.aria-expanded]="showDetails" [attr.aria-controls]="showDetails && hasCategories() ? detailsId : null" (click)="toggleDetails()">{{ detailsLabel() }}</button>}<button mol-button [variant]="'ghost'" (click)="reject()">{{ rejectText() }}</button>@if (saveVisible()) {<button mol-button [variant]="'outline'" (click)="save()">{{ saveText() }}</button>}<button mol-button [variant]="'solid'" [color]="'primary'" (click)="accept()">{{ acceptText() }}</button></footer>`,
169
+ })
170
+ export class CookieBanner implements OnInit, AfterViewInit, DoCheck, OnDestroy {
171
+ categories?: CookieCategory[]
172
+ onAcceptAll?: () => void
173
+ onRejectAll?: () => void
174
+ onSave?: (enabled: Record<string, boolean>) => void
175
+ title?: unknown
176
+ description?: unknown
177
+ policyHref?: string
178
+ visible?: boolean
179
+ onDismiss?: () => void
180
+ className?: string
181
+
182
+ @ViewChild('titleFallback') titleFallback?: ElementRef<HTMLElement>
183
+ @ViewChild('titleSlot') titleSlot?: ElementRef<HTMLElement>
184
+ @ViewChild('descriptionFallback') descriptionFallback?: ElementRef<HTMLElement>
185
+ @ViewChild('descriptionSlot') descriptionSlot?: ElementRef<HTMLElement>
186
+
187
+ showDetails = false
188
+
189
+ readonly leadingSpace = ' '
190
+
191
+ private static nextId = 0
192
+ readonly detailsId = `mol-cookie-banner-details-${CookieBanner.nextId++}`
193
+ private readonly nameBase = `mol-cookie-banner-name-${CookieBanner.nextId++}`
194
+
195
+ private readonly i18n = useTranslation()
196
+
197
+ private readonly el = inject(ElementRef)
198
+
199
+ private readonly enabled = new Map<string, boolean>()
200
+
201
+ private hasTitleSlot = false
202
+ private hasDescriptionSlot = false
203
+ private nodeLayoutApplied = false
204
+ private detachedParent: Node | null = null
205
+ private detachedAnchor: Node | null = null
206
+
207
+ cm(): UIClassMap {
208
+ return getClassMap()
209
+ }
210
+
211
+ ngOnInit(): void {
212
+ for (const category of this.categories ?? [])
213
+ this.enabled.set(category.id, category.required === true || !!category.defaultEnabled)
214
+ }
215
+
216
+ ngAfterViewInit(): void {
217
+ this.hasTitleSlot = hasNodes(this.titleSlot?.nativeElement)
218
+ this.hasDescriptionSlot = hasNodes(this.descriptionSlot?.nativeElement)
219
+ this.applyNodeProps()
220
+ this.syncHostVisibility()
221
+ }
222
+
223
+ ngDoCheck(): void {
224
+ this.syncHostVisibility()
225
+ }
226
+
227
+ ngOnDestroy(): void {
228
+ const host = this.el.nativeElement as HTMLElement
229
+ if (!host.isConnected && this.detachedParent) {
230
+ this.detachedParent.insertBefore(host, this.detachedAnchor)
231
+ this.detachedParent = null
232
+ this.detachedAnchor = null
233
+ }
234
+ }
235
+
236
+ classes(): string {
237
+ return this.cm().cn(this.cm().stack(3), this.cm().sp('p', 4), this.className)
238
+ }
239
+
240
+ hostStyle(): string | null {
241
+ return styleText(BANNER_STYLE)
242
+ }
243
+
244
+ ariaLabel(): string {
245
+ return this.i18n.t('cookieBanner.title', {}, { defaultValue: 'Cookie preferences' })
246
+ }
247
+
248
+ titleClasses(): string {
249
+ return this.cm().cn(this.cm().textSize('base'), this.cm().fontWeight('semibold'))
250
+ }
251
+
252
+ rowClasses(): string {
253
+ return this.cm().flex({ align: 'center', justify: 'between', gap: 'sm' })
254
+ }
255
+
256
+ textColumnClasses(): string {
257
+ return this.cm().cn(this.cm().flex1, this.cm().stack(0))
258
+ }
259
+
260
+ labelClasses(): string {
261
+ return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('semibold'))
262
+ }
263
+
264
+ labelId(index: number): string {
265
+ return `${this.nameBase}-${index}`
266
+ }
267
+
268
+ descriptionId(index: number): string {
269
+ return `${this.nameBase}-${index}-description`
270
+ }
271
+
272
+ footerClasses(): string {
273
+ return this.cm().flex({ align: 'center', justify: 'end', gap: 'sm', wrap: 'wrap' })
274
+ }
275
+
276
+ titleText(): string {
277
+ if (this.hasTitleSlot) return ''
278
+ const value = this.title
279
+ if (typeof value === 'string' || typeof value === 'number') return String(value)
280
+ if (value === null || value === undefined) return this.ariaLabel()
281
+ return ''
282
+ }
283
+
284
+ descriptionText(): string {
285
+ if (this.hasDescriptionSlot) return ''
286
+ const value = this.description
287
+ if (typeof value === 'string' || typeof value === 'number') return String(value)
288
+ if (value === null || value === undefined)
289
+ return this.i18n.t(
290
+ 'cookieBanner.description',
291
+ {},
292
+ { defaultValue: 'We use cookies to improve your experience and analyse traffic.' },
293
+ )
294
+ return ''
295
+ }
296
+
297
+ learnMoreText(): string {
298
+ return this.i18n.t('cookieBanner.learnMore', {}, { defaultValue: 'Learn more' })
299
+ }
300
+
301
+ detailsLabel(): string {
302
+ return this.showDetails
303
+ ? this.i18n.t('cookieBanner.hideDetails', {}, { defaultValue: 'Hide details' })
304
+ : this.i18n.t('cookieBanner.customize', {}, { defaultValue: 'Customize' })
305
+ }
306
+
307
+ rejectText(): string {
308
+ return this.i18n.t('cookieBanner.reject', {}, { defaultValue: 'Reject all' })
309
+ }
310
+
311
+ saveText(): string {
312
+ return this.i18n.t('cookieBanner.save', {}, { defaultValue: 'Save preferences' })
313
+ }
314
+
315
+ acceptText(): string {
316
+ return this.i18n.t('cookieBanner.accept', {}, { defaultValue: 'Accept all' })
317
+ }
318
+
319
+ hasCategories(): boolean {
320
+ return this.categories !== null && this.categories !== undefined
321
+ }
322
+
323
+ saveVisible(): boolean {
324
+ return this.showDetails && this.hasCategories() && !!this.onSave
325
+ }
326
+
327
+ isTemplate(value: unknown): value is TemplateRef<unknown> {
328
+ return isTemplate(value)
329
+ }
330
+
331
+ asTemplate(value: unknown): TemplateRef<unknown> {
332
+ return value as TemplateRef<unknown>
333
+ }
334
+
335
+ isChecked(category: CookieCategory): boolean {
336
+ return !!this.enabled.get(category.id) || category.required === true
337
+ }
338
+
339
+ toggleDetails(): void {
340
+ this.showDetails = !this.showDetails
341
+ }
342
+
343
+ toggle(category: CookieCategory, event: Event): void {
344
+ const checked = (event.target as HTMLInputElement | null)?.checked ?? false
345
+ this.enabled.set(category.id, checked)
346
+ }
347
+
348
+ enabledMap(): Record<string, boolean> {
349
+ const out: Record<string, boolean> = {}
350
+ for (const [id, enabled] of this.enabled) out[id] = enabled
351
+ return out
352
+ }
353
+
354
+ reject(): void {
355
+ this.dismissAfter(this.onRejectAll)
356
+ }
357
+
358
+ save(): void {
359
+ this.dismissAfter(() => this.onSave?.(this.enabledMap()))
360
+ }
361
+ // … truncated — 4 more members: accept, dismissAfter, applyNodeProps, syncHostVisibility; the full declaration is in node_modules/@molecule/app-cookie-banner-angular/dist/cookie-banner.component.d.ts
362
+ ```
363
+
364
+ _(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-cookie-banner-angular/dist/cookie-banner.component.d.ts`.)_
365
+
366
+ ## Injection Notes
367
+
368
+ ### Requirements
369
+
370
+ Peer dependencies:
371
+
372
+ - `@angular/common` ^22.0.0
373
+ - `@angular/core` ^22.0.0
374
+ - `@angular/platform-browser` ^22.0.0
375
+ - `@molecule/app-angular` ^3.5.0
376
+ - `@molecule/app-ui` ^1.0.1
377
+ - `@molecule/app-ui-angular` ^1.1.0
378
+
379
+ ### Runtime Dependencies
380
+
381
+ - `@angular/common`
382
+ - `@angular/core`
383
+ - `@angular/platform-browser`
384
+ - `@molecule/app-angular`
385
+ - `@molecule/app-ui`
386
+ - `@molecule/app-ui-angular`
387
+
388
+ The banner is UI-only — it stores nothing. `onAcceptAll` / `onRejectAll`
389
+ receive NO arguments (derive "all on"/"essential only" yourself); only
390
+ `onSave` receives the per-category `Record<string, boolean>`, and the
391
+ "Save preferences" button renders only when `categories` AND `onSave` are
392
+ provided and the user opened "Customize". Category toggle state is
393
+ captured from `categories` on first render — later input changes do not
394
+ reset it. Visibility is controlled: keep `visible` false once consent is
395
+ stored (the host element leaves the DOM, as React renders null). Text uses
396
+ `cookieBanner.*` i18n keys (companion bond:
397
+ `@molecule/app-locales-cookie-banner`); `title`/`description`/category
398
+ labels you pass in should already be translated.
399
+
400
+ Node props are projected content or plain text: `title` renders inside the
401
+ `<h3>` (as `[slot=title]` content or as a string input), `description`
402
+ inside the `<p>` (`[slot=description]`), and a category's `label` /
403
+ `description` are strings or projected templates.
404
+
405
+ ## Translations
406
+
407
+ Translation strings are provided by `@molecule/app-locales-cookie-banner`.