oasys-lib 2.36.2 → 2.37.0-theming.1

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.
@@ -4174,6 +4174,98 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
4174
4174
  }]
4175
4175
  }] });
4176
4176
 
4177
+ const THEME_VALUE = {
4178
+ DEFAULT: 'default',
4179
+ TIER_1: 'loyalty-tier-1',
4180
+ TIER_2: 'loyalty-tier-2',
4181
+ };
4182
+ const SCOPED_THEME_CLASSES = [THEME_VALUE.TIER_1, THEME_VALUE.TIER_2];
4183
+ class OasysThemeDirective {
4184
+ uiThemeDashed = input(THEME_VALUE.DEFAULT, ...(ngDevMode ? [{ debugName: "uiThemeDashed", alias: 'ui-theme' }] : [{ alias: 'ui-theme' }]));
4185
+ uiThemeCamel = input(undefined, ...(ngDevMode ? [{ debugName: "uiThemeCamel", alias: 'uiTheme' }] : [{ alias: 'uiTheme' }]));
4186
+ elementRef = inject(ElementRef);
4187
+ appliedDefaultBrandClass;
4188
+ appliedTheme;
4189
+ constructor() {
4190
+ effect(() => {
4191
+ const nextTheme = this.uiThemeCamel() ?? this.uiThemeDashed();
4192
+ this.applyTheme(nextTheme);
4193
+ });
4194
+ }
4195
+ applyTheme(nextTheme) {
4196
+ if (nextTheme === this.appliedTheme)
4197
+ return;
4198
+ const host = this.elementRef.nativeElement;
4199
+ const classList = host.classList;
4200
+ if (nextTheme !== THEME_VALUE.DEFAULT) {
4201
+ // Remove previously applied default reset class.
4202
+ if (this.appliedDefaultBrandClass) {
4203
+ classList.remove(this.appliedDefaultBrandClass);
4204
+ this.appliedDefaultBrandClass = undefined;
4205
+ }
4206
+ // Remove all scoped theme classes before applying the next one.
4207
+ SCOPED_THEME_CLASSES.forEach((themeClass) => {
4208
+ classList.remove(themeClass);
4209
+ });
4210
+ if (!classList.contains(nextTheme))
4211
+ classList.add(nextTheme);
4212
+ this.appliedTheme = nextTheme;
4213
+ return;
4214
+ }
4215
+ SCOPED_THEME_CLASSES.forEach((themeClass) => {
4216
+ classList.remove(themeClass);
4217
+ });
4218
+ const defaultBrandClass = this.findNearestBrandTokenClass(host);
4219
+ if (defaultBrandClass) {
4220
+ if (this.appliedDefaultBrandClass && this.appliedDefaultBrandClass !== defaultBrandClass) {
4221
+ classList.remove(this.appliedDefaultBrandClass);
4222
+ }
4223
+ classList.add(defaultBrandClass);
4224
+ this.appliedDefaultBrandClass = defaultBrandClass;
4225
+ }
4226
+ else if (this.appliedDefaultBrandClass) {
4227
+ classList.remove(this.appliedDefaultBrandClass);
4228
+ this.appliedDefaultBrandClass = undefined;
4229
+ }
4230
+ this.appliedTheme = nextTheme;
4231
+ }
4232
+ findNearestBrandTokenClass(host) {
4233
+ let node = host.parentElement;
4234
+ while (node) {
4235
+ const classList = node.classList;
4236
+ for (let i = 0; i < classList.length; i += 1) {
4237
+ const className = classList.item(i);
4238
+ if (className?.startsWith('brand-tokens-'))
4239
+ return className;
4240
+ }
4241
+ node = node.parentElement;
4242
+ }
4243
+ return undefined;
4244
+ }
4245
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: OasysThemeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
4246
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.25", 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 });
4247
+ }
4248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: OasysThemeDirective, decorators: [{
4249
+ type: Directive,
4250
+ args: [{
4251
+ selector: '[ui-theme], [uiTheme]',
4252
+ standalone: true,
4253
+ }]
4254
+ }], 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 }] }] } });
4255
+
4256
+ class OasysDirectivesModule {
4257
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: OasysDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4258
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.25", ngImport: i0, type: OasysDirectivesModule, imports: [OasysHrefDirective, OasysAutofocusDirective, OasysThemeDirective], exports: [OasysHrefDirective, OasysAutofocusDirective, OasysThemeDirective] });
4259
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: OasysDirectivesModule });
4260
+ }
4261
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: OasysDirectivesModule, decorators: [{
4262
+ type: NgModule,
4263
+ args: [{
4264
+ imports: [OasysHrefDirective, OasysAutofocusDirective, OasysThemeDirective],
4265
+ exports: [OasysHrefDirective, OasysAutofocusDirective, OasysThemeDirective],
4266
+ }]
4267
+ }] });
4268
+
4177
4269
  /*
4178
4270
  * Public API Surface of oasys-lib
4179
4271
  */
@@ -4182,5 +4274,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
4182
4274
  * Generated bundle index. Do not edit.
4183
4275
  */
4184
4276
 
4185
- export { BannerComponent, BreadcrumbsComponent, CardComponent, CarouselComponent, CheckboxComponent, ChipComponent, DividerComponent, FormErrorsComponent, FormGroupComponent, HeroComponent, IMAGE_BREAKPOINTS, IMAGE_URL_PROVIDER, IconComponent, ImageComponent, LayoutBoxComponent, LayoutContainerComponent, LayoutGridColumnComponent, LayoutGridComponent, LayoutStackComponent, 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, OasysComboboxComponent, 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, TextareaComponent as OasysTextareaComponent, ProgressBarComponent, PromoCardComponent, ROUTING_HANDLER, RadioComponent, SWIPER_PROVIDER_TOKEN, SectionComponent, SectionModule, SelectCardComponent, SeoBlockComponent, SwiperProvider, TextComponent, TextareaComponent };
4277
+ export { BannerComponent, BreadcrumbsComponent, CardComponent, CarouselComponent, CheckboxComponent, ChipComponent, DividerComponent, FormErrorsComponent, FormGroupComponent, HeroComponent, IMAGE_BREAKPOINTS, IMAGE_URL_PROVIDER, IconComponent, ImageComponent, LayoutBoxComponent, LayoutContainerComponent, LayoutGridColumnComponent, LayoutGridComponent, LayoutStackComponent, 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, OasysComboboxComponent, 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, TextareaComponent as OasysTextareaComponent, OasysThemeDirective, ProgressBarComponent, PromoCardComponent, ROUTING_HANDLER, RadioComponent, SWIPER_PROVIDER_TOKEN, SectionComponent, SectionModule, SelectCardComponent, SeoBlockComponent, SwiperProvider, TextComponent, TextareaComponent };
4186
4278
  //# sourceMappingURL=oasys-lib.mjs.map