@abgov/angular-components 5.2.0-dev.4 → 5.2.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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ElementRef, forwardRef, HostListener, Directive, Renderer2, CUSTOM_ELEMENTS_SCHEMA, NgModule, Input, Component, booleanAttribute, ViewChild, ChangeDetectorRef, EventEmitter, Output, numberAttribute, TemplateRef, HostBinding } from '@angular/core';
2
+ import { inject, ElementRef, forwardRef, HostListener, Directive, Renderer2, CUSTOM_ELEMENTS_SCHEMA, NgModule, Input, Component, booleanAttribute, ViewChild, ChangeDetectorRef, EventEmitter, Output, numberAttribute, TemplateRef, HostBinding, signal, effect, Injectable } from '@angular/core';
3
3
  import { NG_VALUE_ACCESSOR, CheckboxControlValueAccessor } from '@angular/forms';
4
4
  import { NgTemplateOutlet } from '@angular/common';
5
5
  import { Once, CalendarDate } from '@abgov/ui-components-common';
@@ -7123,9 +7123,61 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
7123
7123
  type: Output
7124
7124
  }] } });
7125
7125
 
7126
+ const STORAGE_KEY = "goab-theme";
7127
+ const ATTRIBUTE = "data-theme";
7128
+ class GoabThemeService {
7129
+ constructor() {
7130
+ this._mode = signal(this.readInitialMode(), ...(ngDevMode ? [{ debugName: "_mode" }] : /* istanbul ignore next */ []));
7131
+ /** Read-only signal for consumers. Use in templates: theme.mode() === 'dark'. */
7132
+ this.mode = this._mode.asReadonly();
7133
+ effect(() => {
7134
+ const current = this._mode();
7135
+ if (typeof document === "undefined")
7136
+ return;
7137
+ document.documentElement.setAttribute(ATTRIBUTE, current);
7138
+ try {
7139
+ window.localStorage.setItem(STORAGE_KEY, current);
7140
+ }
7141
+ catch {
7142
+ // localStorage blocked: fail silently.
7143
+ }
7144
+ });
7145
+ }
7146
+ setMode(next) {
7147
+ this._mode.set(next);
7148
+ }
7149
+ toggle() {
7150
+ this._mode.update((prev) => (prev === "light" ? "dark" : "light"));
7151
+ }
7152
+ readInitialMode() {
7153
+ if (typeof window === "undefined")
7154
+ return "light";
7155
+ try {
7156
+ const stored = window.localStorage.getItem(STORAGE_KEY);
7157
+ if (stored === "light" || stored === "dark")
7158
+ return stored;
7159
+ }
7160
+ catch {
7161
+ // fall through
7162
+ }
7163
+ const fromAttribute = document.documentElement.getAttribute(ATTRIBUTE);
7164
+ if (fromAttribute === "light" || fromAttribute === "dark")
7165
+ return fromAttribute;
7166
+ if (window.matchMedia("(prefers-color-scheme: dark)").matches)
7167
+ return "dark";
7168
+ return "light";
7169
+ }
7170
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: GoabThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
7171
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: GoabThemeService, providedIn: "root" }); }
7172
+ }
7173
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: GoabThemeService, decorators: [{
7174
+ type: Injectable,
7175
+ args: [{ providedIn: "root" }]
7176
+ }], ctorParameters: () => [] });
7177
+
7126
7178
  /**
7127
7179
  * Generated bundle index. Do not edit.
7128
7180
  */
7129
7181
 
7130
- export { AngularComponentsModule, CheckedDirective, GoabAccordion, GoabAppFooter, GoabAppFooterMetaSection, GoabAppFooterNavSection, GoabAppHeader, GoabAppHeaderMenu, GoabBadge, GoabBlock, GoabButton, GoabButtonGroup, GoabCalendar, GoabCallout, GoabCard, GoabCardActions, GoabCardContent, GoabCardImage, GoabCheckbox, GoabCheckboxList, GoabChip, GoabCircularProgress, GoabColumnLayout, GoabContainer, GoabDataGrid, GoabDatePicker, GoabDetails, GoabDivider, GoabDrawer, GoabDropdown, GoabDropdownItem, GoabFieldset, GoabFileUploadCard, GoabFileUploadInput, GoabFilterChip, GoabFormItem, GoabFormItemSlot, GoabFormStep, GoabFormStepper, GoabGrid, GoabHeroBanner, GoabIcon, GoabIconButton, GoabInput, GoabInputNumber, GoabLinearProgress, GoabLink, GoabMenuAction, GoabMenuButton, GoabMicrositeHeader, GoabModal, GoabNotification, GoabPageBlock, GoabPages, GoabPagination, GoabPopover, GoabPublicForm, GoabPublicFormPage, GoabPublicFormSummary, GoabPublicFormTask, GoabPublicFormTaskList, GoabPublicSubform, GoabPublicSubformIndex, GoabPushDrawer, GoabRadioGroup, GoabRadioItem, GoabSideMenu, GoabSideMenuGroup, GoabSideMenuHeading, GoabSkeleton, GoabSpacer, GoabTab, GoabTable, GoabTableSortHeader, GoabTabs, GoabTemporaryNotificationCtrl, GoabText, GoabTextArea, GoabTooltip, GoabWorkSideMenu, GoabWorkSideMenuGroup, GoabWorkSideMenuItem, GoabWorkSideNotificationItem, GoabWorkSideNotificationPanel, ValueDirective, ValueListDirective };
7182
+ export { AngularComponentsModule, CheckedDirective, GoabAccordion, GoabAppFooter, GoabAppFooterMetaSection, GoabAppFooterNavSection, GoabAppHeader, GoabAppHeaderMenu, GoabBadge, GoabBlock, GoabButton, GoabButtonGroup, GoabCalendar, GoabCallout, GoabCard, GoabCardActions, GoabCardContent, GoabCardImage, GoabCheckbox, GoabCheckboxList, GoabChip, GoabCircularProgress, GoabColumnLayout, GoabContainer, GoabDataGrid, GoabDatePicker, GoabDetails, GoabDivider, GoabDrawer, GoabDropdown, GoabDropdownItem, GoabFieldset, GoabFileUploadCard, GoabFileUploadInput, GoabFilterChip, GoabFormItem, GoabFormItemSlot, GoabFormStep, GoabFormStepper, GoabGrid, GoabHeroBanner, GoabIcon, GoabIconButton, GoabInput, GoabInputNumber, GoabLinearProgress, GoabLink, GoabMenuAction, GoabMenuButton, GoabMicrositeHeader, GoabModal, GoabNotification, GoabPageBlock, GoabPages, GoabPagination, GoabPopover, GoabPublicForm, GoabPublicFormPage, GoabPublicFormSummary, GoabPublicFormTask, GoabPublicFormTaskList, GoabPublicSubform, GoabPublicSubformIndex, GoabPushDrawer, GoabRadioGroup, GoabRadioItem, GoabSideMenu, GoabSideMenuGroup, GoabSideMenuHeading, GoabSkeleton, GoabSpacer, GoabTab, GoabTable, GoabTableSortHeader, GoabTabs, GoabTemporaryNotificationCtrl, GoabText, GoabTextArea, GoabThemeService, GoabTooltip, GoabWorkSideMenu, GoabWorkSideMenuGroup, GoabWorkSideMenuItem, GoabWorkSideNotificationItem, GoabWorkSideNotificationPanel, ValueDirective, ValueListDirective };
7131
7183
  //# sourceMappingURL=abgov-angular-components.mjs.map