carbon-components-angular
Version:
Next generation components
1 lines • 5.08 kB
Source Map (JSON)
{"version":3,"file":"carbon-components-angular-theme.mjs","sources":["../../src/theme/theme.directive.ts","../../src/theme/theme.module.ts","../../src/theme/carbon-components-angular-theme.ts"],"sourcesContent":["import {\n\tAfterContentChecked,\n\tContentChildren,\n\tDirective,\n\tHostBinding,\n\tInput,\n\tQueryList\n} from \"@angular/core\";\nimport { LayerDirective } from \"carbon-components-angular/layer\";\n\nexport type ThemeType = \"white\" | \"g10\" | \"g90\" | \"g100\";\n\n/**\n * Applies theme styles to the div container it is applied to. Get started with importing the module:\n *\n * ```typescript\n * import { ThemeModule } from 'carbon-components-angular';\n * ```\n *\n * [See demo](../../?path=/story/components-theme--basic)\n */\n@Directive({\n\tselector: \"[cdsTheme], [ibmTheme]\",\n\texportAs: \"theme\"\n})\nexport class ThemeDirective implements AfterContentChecked {\n\t/**\n\t * @deprecated as of v5 - Use `cdsTheme` input property instead\n\t */\n\t@Input() set ibmTheme(type: ThemeType | \"\") {\n\t\tthis.cdsTheme = type;\n\t}\n\n\t/**\n\t * Sets the theme for the content\n\t * Accepts `ThemeType` or nothing (empty string which is equivalent to \"white\")\n\t * Empty string has been added as an option for Angular 16+ to resolve type errors\n\t */\n\t@Input() cdsTheme: ThemeType | \"\" = \"white\";\n\n\t@ContentChildren(LayerDirective, { descendants: false }) layerChildren: QueryList<LayerDirective>;\n\n\t/**\n\t * Using host bindings with classes to ensure we do not\n\t * overwrite user added classes\n\t */\n\t@HostBinding(\"class.cds--white\") get whiteThemeClass() {\n\t\treturn this.cdsTheme === \"white\" || !this.cdsTheme;\n\t}\n\n\t@HostBinding(\"class.cds--g10\") get g10ThemeClass() {\n\t\treturn this.cdsTheme === \"g10\";\n\t}\n\n\t@HostBinding(\"class.cds--g90\") get g90ThemeClass() {\n\t\treturn this.cdsTheme === \"g90\";\n\t}\n\n\t@HostBinding(\"class.cds--g100\") get g100ThemeClass() {\n\t\treturn this.cdsTheme === \"g100\";\n\t}\n\n\t@HostBinding(\"class.cds--layer-one\") layerClass = true;\n\n\tngAfterContentChecked(): void {\n\t\t/**\n\t\t * Resets next layer level in theme\n\t\t * If not found, the layer will be 1 by default\n\t\t */\n\t\tthis.layerChildren.toArray().forEach(layer => {\n\t\t\tif (typeof layer.cdsLayer !== \"number\") {\n\t\t\t\tlayer.cdsLayer = 1;\n\t\t\t}\n\t\t});\n\t}\n}\n","import { NgModule } from \"@angular/core\";\nimport { CommonModule } from \"@angular/common\";\n\nimport { ThemeDirective } from \"./theme.directive\";\nimport { LayerModule } from \"carbon-components-angular/layer\";\n\n@NgModule({\n\tdeclarations: [ThemeDirective],\n\texports: [ThemeDirective],\n\timports: [CommonModule, LayerModule]\n})\nexport class ThemeModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAYA;;;;;;;;AAQG;MAKU,cAAc,CAAA;AAJ3B,IAAA,WAAA,GAAA;AAYC;;;;AAIG;AACM,QAAA,IAAQ,CAAA,QAAA,GAAmB,OAAO,CAAC;AAwBP,QAAA,IAAU,CAAA,UAAA,GAAG,IAAI,CAAC;KAavD;AAjDA;;AAEG;IACH,IAAa,QAAQ,CAAC,IAAoB,EAAA;AACzC,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;KACrB;AAWD;;;AAGG;AACH,IAAA,IAAqC,eAAe,GAAA;QACnD,OAAO,IAAI,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KACnD;AAED,IAAA,IAAmC,aAAa,GAAA;AAC/C,QAAA,OAAO,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC;KAC/B;AAED,IAAA,IAAmC,aAAa,GAAA;AAC/C,QAAA,OAAO,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC;KAC/B;AAED,IAAA,IAAoC,cAAc,GAAA;AACjD,QAAA,OAAO,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC;KAChC;IAID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