oasys-lib 2.23.0 → 2.24.0-theming.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, Directive, Injectable, DOCUMENT, Inject, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, InjectionToken, HostListener, EventEmitter, ViewChild, Output, ContentChild, NgModule, HostBinding, signal, forwardRef, computed, input, CUSTOM_ELEMENTS_SCHEMA, ViewChildren, ContentChildren } from '@angular/core';
2
+ import { inject, ElementRef, Directive, Injectable, DOCUMENT, Inject, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, InjectionToken, HostListener, EventEmitter, ViewChild, Output, ContentChild, NgModule, HostBinding, signal, forwardRef, computed, input, CUSTOM_ELEMENTS_SCHEMA, ViewChildren, ContentChildren, effect } from '@angular/core';
3
3
  import { BehaviorSubject, Subject, Observable } from 'rxjs';
4
4
  import { takeUntil, take, map } from 'rxjs/operators';
5
5
  import * as i1 from '@angular/cdk/layout';
@@ -4195,6 +4195,98 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
4195
4195
  }]
4196
4196
  }] });
4197
4197
 
4198
+ const THEME_VALUE = {
4199
+ DEFAULT: 'default',
4200
+ TIER_1: 'loyalty-tier-1',
4201
+ TIER_2: 'loyalty-tier-2',
4202
+ };
4203
+ const SCOPED_THEME_CLASSES = [THEME_VALUE.TIER_1, THEME_VALUE.TIER_2];
4204
+ class OasysThemeDirective {
4205
+ uiThemeDashed = input(THEME_VALUE.DEFAULT, ...(ngDevMode ? [{ debugName: "uiThemeDashed", alias: 'ui-theme' }] : [{ alias: 'ui-theme' }]));
4206
+ uiThemeCamel = input(undefined, ...(ngDevMode ? [{ debugName: "uiThemeCamel", alias: 'uiTheme' }] : [{ alias: 'uiTheme' }]));
4207
+ elementRef = inject(ElementRef);
4208
+ appliedDefaultBrandClass;
4209
+ appliedTheme;
4210
+ constructor() {
4211
+ effect(() => {
4212
+ const nextTheme = this.uiThemeCamel() ?? this.uiThemeDashed();
4213
+ this.applyTheme(nextTheme);
4214
+ });
4215
+ }
4216
+ applyTheme(nextTheme) {
4217
+ if (nextTheme === this.appliedTheme)
4218
+ return;
4219
+ const host = this.elementRef.nativeElement;
4220
+ const classList = host.classList;
4221
+ if (nextTheme !== THEME_VALUE.DEFAULT) {
4222
+ // Remove previously applied default reset class.
4223
+ if (this.appliedDefaultBrandClass) {
4224
+ classList.remove(this.appliedDefaultBrandClass);
4225
+ this.appliedDefaultBrandClass = undefined;
4226
+ }
4227
+ // Remove all scoped theme classes before applying the next one.
4228
+ SCOPED_THEME_CLASSES.forEach((themeClass) => {
4229
+ classList.remove(themeClass);
4230
+ });
4231
+ if (!classList.contains(nextTheme))
4232
+ classList.add(nextTheme);
4233
+ this.appliedTheme = nextTheme;
4234
+ return;
4235
+ }
4236
+ SCOPED_THEME_CLASSES.forEach((themeClass) => {
4237
+ classList.remove(themeClass);
4238
+ });
4239
+ const defaultBrandClass = this.findNearestBrandTokenClass(host);
4240
+ if (defaultBrandClass) {
4241
+ if (this.appliedDefaultBrandClass && this.appliedDefaultBrandClass !== defaultBrandClass) {
4242
+ classList.remove(this.appliedDefaultBrandClass);
4243
+ }
4244
+ classList.add(defaultBrandClass);
4245
+ this.appliedDefaultBrandClass = defaultBrandClass;
4246
+ }
4247
+ else if (this.appliedDefaultBrandClass) {
4248
+ classList.remove(this.appliedDefaultBrandClass);
4249
+ this.appliedDefaultBrandClass = undefined;
4250
+ }
4251
+ this.appliedTheme = nextTheme;
4252
+ }
4253
+ findNearestBrandTokenClass(host) {
4254
+ let node = host.parentElement;
4255
+ while (node) {
4256
+ const classList = node.classList;
4257
+ for (let i = 0; i < classList.length; i += 1) {
4258
+ const className = classList.item(i);
4259
+ if (className?.startsWith('brand-tokens-'))
4260
+ return className;
4261
+ }
4262
+ node = node.parentElement;
4263
+ }
4264
+ return undefined;
4265
+ }
4266
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: OasysThemeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
4267
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.16", type: OasysThemeDirective, isStandalone: true, selector: "[ui-theme], [uiTheme]", inputs: { uiThemeDashed: { classPropertyName: "uiThemeDashed", publicName: "ui-theme", isSignal: true, isRequired: false, transformFunction: null }, uiThemeCamel: { classPropertyName: "uiThemeCamel", publicName: "uiTheme", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
4268
+ }
4269
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: OasysThemeDirective, decorators: [{
4270
+ type: Directive,
4271
+ args: [{
4272
+ selector: '[ui-theme], [uiTheme]',
4273
+ standalone: true,
4274
+ }]
4275
+ }], ctorParameters: () => [], propDecorators: { uiThemeDashed: [{ type: i0.Input, args: [{ isSignal: true, alias: "ui-theme", required: false }] }], uiThemeCamel: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiTheme", required: false }] }] } });
4276
+
4277
+ class OasysDirectivesModule {
4278
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: OasysDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4279
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.16", ngImport: i0, type: OasysDirectivesModule, imports: [OasysHrefDirective, OasysAutofocusDirective, OasysThemeDirective], exports: [OasysHrefDirective, OasysAutofocusDirective, OasysThemeDirective] });
4280
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: OasysDirectivesModule });
4281
+ }
4282
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: OasysDirectivesModule, decorators: [{
4283
+ type: NgModule,
4284
+ args: [{
4285
+ imports: [OasysHrefDirective, OasysAutofocusDirective, OasysThemeDirective],
4286
+ exports: [OasysHrefDirective, OasysAutofocusDirective, OasysThemeDirective],
4287
+ }]
4288
+ }] });
4289
+
4198
4290
  /*
4199
4291
  * Public API Surface of oasys-lib
4200
4292
  */
@@ -4203,5 +4295,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
4203
4295
  * Generated bundle index. Do not edit.
4204
4296
  */
4205
4297
 
4206
- export { BannerComponent, BreadcrumbsComponent, CardComponent, CarouselComponent, CheckboxComponent, ChipComponent, ComboboxComponent, DividerComponent, FormErrorsComponent, FormGroupComponent, HeroComponent, IconComponent, ImageComponent, LayoutBoxComponent, LayoutContainerComponent, LayoutGridColumnComponent, LayoutGridComponent, LayoutStackComponent, MEDIA_BASE_URL_TOKEN, OasysAlertCancelDirective, OasysAlertComponent, OasysAlertConfirmDirective, OasysAlertContentDirective, OasysAlertModule, OasysAlertTitleDirective, BannerComponent as OasysBannerComponent, OasysBannerModule, OasysBreadcrumbModule, BreadcrumbsComponent as OasysBreadcrumbsComponent, OasysButtonComponent, OasysButtonGroupComponent, OasysButtonGroupModule, OasysButtonModule, CardComponent as OasysCardComponent, OasysCardModule, CarouselComponent as OasysCarouselComponent, OasysCarouselModule, CheckboxComponent as OasysCheckboxComponent, OasysCheckboxModule, ChipComponent as OasysChipComponent, OasysChipModule, ComboboxComponent as OasysComboboxComponent, OasysComboboxModule, DividerComponent as OasysDividerComponent, OasysDividerModule, FormErrorsComponent as OasysFormErrorsComponent, OasysFormErrorsModule, OasysFormErrorsSummaryComponent, OasysFormErrorsSummaryItemComponent, OasysFormErrorsSummaryTitleComponent, FormGroupComponent as OasysFormGroupComponent, OasysFormGroupModule, OasysHeadingComponent, OasysHeadingModule, HeroComponent as OasysHeroComponent, OasysHeroModule, IconComponent as OasysIconComponent, OasysIconModule, ImageComponent as OasysImageComponent, OasysImageModule, LayoutBoxComponent as OasysLayoutBoxComponent, LayoutContainerComponent as OasysLayoutContainerComponent, LayoutGridColumnComponent as OasysLayoutGridColumnComponent, LayoutGridComponent as OasysLayoutGridComponent, OasysLayoutModule, LayoutStackComponent as OasysLayoutStackComponent, OasysPillComponent, OasysPillGroupComponent, OasysPillGroupModule, OasysPillModule, ProgressBarComponent as OasysProgressBarComponent, PromoCardComponent as OasysPromoCardComponent, OasysPromoCardModule, RadioComponent as OasysRadioComponent, OasysRadioModule, SectionComponent as OasysSectionComponent, SelectCardComponent as OasysSelectCardComponent, OasysSelectCardModule, SeoBlockComponent as OasysSeoBlockComponent, OasysSeoBlockModule, OasysTabComponent, OasysTabGroupComponent, OasysTabsModule, TextComponent as OasysTextComponent, TextInputComponent as OasysTextInputComponent, OasysTextInputModule, OasysTextModule, ProgressBarComponent, PromoCardComponent, ROUTING_HANDLER, RadioComponent, SWIPER_PROVIDER_TOKEN, SectionComponent, SectionModule, SelectCardComponent, SeoBlockComponent, SwiperProvider, TextComponent };
4298
+ export { BannerComponent, BreadcrumbsComponent, CardComponent, CarouselComponent, CheckboxComponent, ChipComponent, ComboboxComponent, DividerComponent, FormErrorsComponent, FormGroupComponent, HeroComponent, IconComponent, ImageComponent, LayoutBoxComponent, LayoutContainerComponent, LayoutGridColumnComponent, LayoutGridComponent, LayoutStackComponent, MEDIA_BASE_URL_TOKEN, OasysAlertCancelDirective, OasysAlertComponent, OasysAlertConfirmDirective, OasysAlertContentDirective, OasysAlertModule, OasysAlertTitleDirective, OasysAutofocusDirective, BannerComponent as OasysBannerComponent, OasysBannerModule, OasysBreadcrumbModule, BreadcrumbsComponent as OasysBreadcrumbsComponent, OasysButtonComponent, OasysButtonGroupComponent, OasysButtonGroupModule, OasysButtonModule, CardComponent as OasysCardComponent, OasysCardModule, CarouselComponent as OasysCarouselComponent, OasysCarouselModule, CheckboxComponent as OasysCheckboxComponent, OasysCheckboxModule, ChipComponent as OasysChipComponent, OasysChipModule, ComboboxComponent as OasysComboboxComponent, OasysComboboxModule, OasysDirectivesModule, DividerComponent as OasysDividerComponent, OasysDividerModule, FormErrorsComponent as OasysFormErrorsComponent, OasysFormErrorsModule, OasysFormErrorsSummaryComponent, OasysFormErrorsSummaryItemComponent, OasysFormErrorsSummaryTitleComponent, FormGroupComponent as OasysFormGroupComponent, OasysFormGroupModule, OasysHeadingComponent, OasysHeadingModule, HeroComponent as OasysHeroComponent, OasysHeroModule, OasysHrefDirective, IconComponent as OasysIconComponent, OasysIconModule, ImageComponent as OasysImageComponent, OasysImageModule, LayoutBoxComponent as OasysLayoutBoxComponent, LayoutContainerComponent as OasysLayoutContainerComponent, LayoutGridColumnComponent as OasysLayoutGridColumnComponent, LayoutGridComponent as OasysLayoutGridComponent, OasysLayoutModule, LayoutStackComponent as OasysLayoutStackComponent, OasysPillComponent, OasysPillGroupComponent, OasysPillGroupModule, OasysPillModule, ProgressBarComponent as OasysProgressBarComponent, PromoCardComponent as OasysPromoCardComponent, OasysPromoCardModule, RadioComponent as OasysRadioComponent, OasysRadioModule, SectionComponent as OasysSectionComponent, SelectCardComponent as OasysSelectCardComponent, OasysSelectCardModule, SeoBlockComponent as OasysSeoBlockComponent, OasysSeoBlockModule, OasysTabComponent, OasysTabGroupComponent, OasysTabsModule, TextComponent as OasysTextComponent, TextInputComponent as OasysTextInputComponent, OasysTextInputModule, OasysTextModule, OasysThemeDirective, ProgressBarComponent, PromoCardComponent, ROUTING_HANDLER, RadioComponent, SWIPER_PROVIDER_TOKEN, SectionComponent, SectionModule, SelectCardComponent, SeoBlockComponent, SwiperProvider, TextComponent };
4207
4299
  //# sourceMappingURL=oasys-lib.mjs.map