@genesislcap/foundation-ui 14.293.2 → 14.293.3-alpha-16ba6c2.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,61 +1,5 @@
1
1
  import { FoundationElement } from '@microsoft/fast-foundation';
2
- import { FaSize } from '../icon';
3
- /**
4
- * Environment configuration interface
5
- * @public
6
- */
7
- export interface EnvironmentConfig {
8
- /**
9
- * The environment level
10
- */
11
- level: string;
12
- /**
13
- * Whether to show an icon for this environment
14
- */
15
- showIcon?: boolean;
16
- /**
17
- * The icon name to use
18
- * Valid values are from the free set of font awesome icons which can be found here https://fontawesome.com/search?ic=free
19
- */
20
- icon?: string;
21
- /**
22
- * The size of the icon
23
- */
24
- iconSize?: FaSize;
25
- /**
26
- * The background color for this environment
27
- */
28
- backgroundColor?: string;
29
- /**
30
- * The text color for this environment
31
- */
32
- textColor?: string;
33
- /**
34
- * The size of the indicator
35
- */
36
- size?: 'sm' | 'lg';
37
- /**
38
- * The label to display
39
- */
40
- label?: string;
41
- }
42
- /**
43
- * Default environment level configuration
44
- */
45
- export declare const DEFAULT_ENVIRONMENT_LEVEL_CONFIG: EnvironmentConfig;
46
- /**
47
- * Environment indicator configuration interface
48
- * @public
49
- */
50
- export interface EnvironmentIndicatorConfig {
51
- currentLevel?: typeof this.level;
52
- configs: EnvironmentConfig[];
53
- }
54
- /**
55
- * EnvironmentConfigs DI token.
56
- * @public
57
- */
58
- export declare const EnvironmentIndicatorConfigToken: import("@microsoft/fast-foundation").InterfaceSymbol<EnvironmentIndicatorConfig>;
2
+ import { EnvironmentConfig, EnvironmentIndicatorConfig } from './types';
59
3
  /**
60
4
  * @tagname %%prefix%%-environment-indicator
61
5
  * @description Displays an environment indicator with a label and an icon
@@ -93,7 +37,11 @@ export declare class EnvironmentIndicator extends FoundationElement {
93
37
  /**
94
38
  * @attr icon-size - the size of the icon
95
39
  */
96
- iconSize: FaSize;
40
+ iconSize: EnvironmentConfig['iconSize'];
41
+ /**
42
+ * @attr use-default-config - whether to use the default config
43
+ */
44
+ useDefaultConfig: boolean;
97
45
  /**
98
46
  * Current environment configuration
99
47
  */
@@ -103,6 +51,15 @@ export declare class EnvironmentIndicator extends FoundationElement {
103
51
  */
104
52
  envConfigs: EnvironmentConfig[];
105
53
  envConfigsChanged(): void;
54
+ /**
55
+ * Current environment configuration from DI
56
+ */
57
+ diConfig: EnvironmentIndicatorConfig;
58
+ diConfigChanged(): void;
59
+ private unsubscribeConfig?;
60
+ subscribeToDiConfig(): void;
61
+ connectedCallback(): void;
62
+ disconnectedCallback(): void;
106
63
  /**
107
64
  * Helper function to get config from attributes
108
65
  * @returns the config from attributes
@@ -112,8 +69,7 @@ export declare class EnvironmentIndicator extends FoundationElement {
112
69
  * Get the current environment level based on priority order
113
70
  */
114
71
  private getCurrentEnvironmentLevel;
115
- getEnvConfigByLevel(): EnvironmentConfig;
116
- connectedCallback(): void;
72
+ getEnvConfigByLevel(): EnvironmentConfig | undefined;
117
73
  /**
118
74
  * Handle config change when attributes change
119
75
  */
@@ -1 +1 @@
1
- {"version":3,"file":"environment-indicator.d.ts","sourceRoot":"","sources":["../../../src/environment-indicator/environment-indicator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAKjC;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAOD;;GAEG;AACH,eAAO,MAAM,gCAAgC,EAAE,iBAO9C,CAAC;AAuBF;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,YAAY,CAAC,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC;IACjC,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED;;;GAGG;AACH,eAAO,MAAM,+BAA+B,kFAG3C,CAAC;AAEF;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD;;OAEG;IACG,KAAK,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACG,KAAK,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACgD,QAAQ,EAAE,OAAO,CAAC;IAErE;;OAEG;IACG,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE/B;;OAEG;IACsC,eAAe,EAAE,MAAM,CAAC;IAEjE;;OAEG;IACgC,SAAS,EAAE,MAAM,CAAa;IAEjE;;OAEG;IACG,IAAI,EAAE,MAAM,CAAkB;IAEpC;;OAEG;IAC+B,QAAQ,EAAE,MAAM,CAAQ;IAE1D;;OAEG;IACS,MAAM,EAAE,iBAAiB,CAAoC;IAEzE;;OAEG;IACS,UAAU,EAAE,iBAAiB,EAAE,CAA+B;IAC1E,iBAAiB;IAIjB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA0BlC,mBAAmB,IAAI,iBAAiB;IAgDxC,iBAAiB;IAKjB;;OAEG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAmBzE;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,iBAAiB,EAAE;CAG9C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;+BAIzC,CAAC"}
1
+ {"version":3,"file":"environment-indicator.d.ts","sourceRoot":"","sources":["../../../src/environment-indicator/environment-indicator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAUxE;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD;;OAEG;IACG,KAAK,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACG,KAAK,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACgD,QAAQ,EAAE,OAAO,CAAC;IAErE;;OAEG;IACG,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE/B;;OAEG;IACsC,eAAe,EAAE,MAAM,CAAC;IAEjE;;OAEG;IACgC,SAAS,EAAE,MAAM,CAAa;IAEjE;;OAEG;IACG,IAAI,EAAE,MAAM,CAAkB;IAEpC;;OAEG;IAC+B,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAQ;IAEjF;;OAEG;IACyD,gBAAgB,EAAE,OAAO,CAAS;IAE9F;;OAEG;IACS,MAAM,EAAE,iBAAiB,CAAoC;IAEzE;;OAEG;IACS,UAAU,EAAE,iBAAiB,EAAE,CAA+B;IAC1E,iBAAiB;IAIjB;;OAEG;IACS,QAAQ,EAAE,0BAA0B,CAAC;IACjD,eAAe;IAIf,OAAO,CAAC,iBAAiB,CAAC,CAAa;IAEvC,mBAAmB;IAYnB,iBAAiB;IAQjB,oBAAoB;IASpB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA+BlC,mBAAmB,IAAI,iBAAiB,GAAG,SAAS;IA8CpD;;OAEG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAmBzE;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,iBAAiB,EAAE;CAG9C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;+BAIzC,CAAC"}
@@ -2,4 +2,5 @@ export * from './environment-indicator';
2
2
  export * from './environment-indicator.styles';
3
3
  export * from './environment-indicator.template';
4
4
  export { configureEnvironmentIndicator } from './utils/configure';
5
+ export * from './types';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/environment-indicator/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/environment-indicator/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,cAAc,SAAS,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { FaSize } from '../icon';
2
+ /**
3
+ * Environment configuration interface
4
+ * @public
5
+ */
6
+ export interface EnvironmentConfig {
7
+ /**
8
+ * The environment level
9
+ */
10
+ level: string;
11
+ /**
12
+ * Whether to show an icon for this environment
13
+ */
14
+ showIcon?: boolean;
15
+ /**
16
+ * The icon name to use
17
+ * Valid values are from the free set of font awesome icons which can be found here https://fontawesome.com/search?ic=free
18
+ */
19
+ icon?: string;
20
+ /**
21
+ * The size of the icon
22
+ */
23
+ iconSize?: FaSize;
24
+ /**
25
+ * The background color for this environment
26
+ */
27
+ backgroundColor?: string;
28
+ /**
29
+ * The text color for this environment
30
+ */
31
+ textColor?: string;
32
+ /**
33
+ * The size of the indicator
34
+ */
35
+ size?: 'sm' | 'lg';
36
+ /**
37
+ * The label to display
38
+ */
39
+ label?: string;
40
+ }
41
+ /**
42
+ * Environment indicator configuration interface
43
+ * @public
44
+ */
45
+ export interface EnvironmentIndicatorConfig {
46
+ currentLevel?: typeof this.level;
47
+ configs: EnvironmentConfig[];
48
+ }
49
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/environment-indicator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,YAAY,CAAC,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC;IACjC,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B"}
@@ -1,3 +1,27 @@
1
- import type { EnvironmentIndicatorConfig } from '../environment-indicator';
1
+ import type { EnvironmentConfig, EnvironmentIndicatorConfig } from '../types';
2
+ /**
3
+ * Default environment level
4
+ */
5
+ export declare const DEFAULT_ENVIRONMENT_LEVEL = "default";
6
+ /**
7
+ * Default environment level configuration
8
+ */
9
+ export declare const DEFAULT_ENVIRONMENT_LEVEL_CONFIG: EnvironmentConfig;
10
+ /**
11
+ * Default environment configurations
12
+ */
13
+ export declare const DEFAULT_ENVIRONMENT_CONFIGS: EnvironmentConfig[];
14
+ export declare const EnvironmentIndicatorConfigObserver: import("@genesislcap/foundation-utils").Observer<EnvironmentIndicatorConfig>;
15
+ export declare const EnvironmentIndicatorConfigObserverToken: import("@microsoft/fast-foundation").InterfaceSymbol<import("@genesislcap/foundation-utils").Observer<EnvironmentIndicatorConfig>>;
16
+ export declare const EnvironmentIndicatorConfigToken: import("@microsoft/fast-foundation").InterfaceSymbol<EnvironmentIndicatorConfig>;
17
+ /**
18
+ * Configure the environment indicator
19
+ * @param options - the options to configure the environment indicator
20
+ */
2
21
  export declare function configureEnvironmentIndicator(options?: EnvironmentIndicatorConfig): Promise<void>;
22
+ /**
23
+ * Get the current environment indicator configuration from DI
24
+ * @returns the current configuration or default if not found
25
+ */
26
+ export declare function getCurrentEnvironmentIndicatorConfig(): EnvironmentIndicatorConfig | undefined;
3
27
  //# sourceMappingURL=configure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/environment-indicator/utils/configure.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAM3E,wBAAsB,6BAA6B,CACjD,OAAO,GAAE,0BAA4C,iBAYtD"}
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/environment-indicator/utils/configure.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,yBAAyB,YAAY,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,gCAAgC,EAAE,iBAO9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,iBAAiB,EAgB1D,CAAC;AAGF,eAAO,MAAM,kCAAkC,8EAA+C,CAAC;AAG/F,eAAO,MAAM,uCAAuC,oIAKnD,CAAC;AAGF,eAAO,MAAM,+BAA+B,kFAE3C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,GAAE,0BAA4C,iBAkBtD;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,IAAI,0BAA0B,GAAG,SAAS,CAU7F"}
@@ -4,47 +4,8 @@ import { attr, observable } from '@microsoft/fast-element';
4
4
  import { DI, FoundationElement } from '@microsoft/fast-foundation';
5
5
  import { environmentIndicatorStyles as styles } from './environment-indicator.styles';
6
6
  import { foundationEnvironmentIndicatorTemplate as template } from './environment-indicator.template';
7
+ import { DEFAULT_ENVIRONMENT_CONFIGS, DEFAULT_ENVIRONMENT_LEVEL, DEFAULT_ENVIRONMENT_LEVEL_CONFIG, EnvironmentIndicatorConfigObserverToken, getCurrentEnvironmentIndicatorConfig, } from './utils/configure';
7
8
  import { environmentIndicatorLogger } from './utils/logger';
8
- /**
9
- * Default environment level
10
- */
11
- const DEFAULT_ENVIRONMENT_LEVEL = 'default';
12
- /**
13
- * Default environment level configuration
14
- */
15
- export const DEFAULT_ENVIRONMENT_LEVEL_CONFIG = {
16
- level: DEFAULT_ENVIRONMENT_LEVEL,
17
- showIcon: false,
18
- iconSize: 'sm',
19
- backgroundColor: '#2222ff',
20
- textColor: '#ffffff',
21
- label: 'DEFAULT',
22
- };
23
- /**
24
- * Default environment configurations
25
- */
26
- const DEFAULT_ENVIRONMENT_CONFIGS = [
27
- DEFAULT_ENVIRONMENT_LEVEL_CONFIG,
28
- {
29
- level: 'dev',
30
- showIcon: false,
31
- icon: 'code',
32
- backgroundColor: '#ff6b35',
33
- label: 'DEV',
34
- },
35
- {
36
- level: 'prod',
37
- showIcon: false,
38
- icon: 'check-circle',
39
- backgroundColor: '#28a745',
40
- label: 'PROD',
41
- },
42
- ];
43
- /**
44
- * EnvironmentConfigs DI token.
45
- * @public
46
- */
47
- export const EnvironmentIndicatorConfigToken = DI.createInterface((x) => x.instance({ configs: [] }), (configurator) => configurator.instance({ configs: [] }));
48
9
  /**
49
10
  * @tagname %%prefix%%-environment-indicator
50
11
  * @description Displays an environment indicator with a label and an icon
@@ -69,6 +30,10 @@ export class EnvironmentIndicator extends FoundationElement {
69
30
  * @attr icon-size - the size of the icon
70
31
  */
71
32
  this.iconSize = 'sm';
33
+ /**
34
+ * @attr use-default-config - whether to use the default config
35
+ */
36
+ this.useDefaultConfig = false;
72
37
  /**
73
38
  * Current environment configuration
74
39
  */
@@ -81,6 +46,34 @@ export class EnvironmentIndicator extends FoundationElement {
81
46
  envConfigsChanged() {
82
47
  this.config = this.getEnvConfigByLevel();
83
48
  }
49
+ diConfigChanged() {
50
+ this.config = this.getEnvConfigByLevel();
51
+ }
52
+ subscribeToDiConfig() {
53
+ const container = DI.getOrCreateDOMContainer();
54
+ const observer = container.get(EnvironmentIndicatorConfigObserverToken);
55
+ if (observer && typeof observer.subscribe === 'function') {
56
+ this.unsubscribeConfig = observer.subscribe((configFromDi) => {
57
+ this.diConfig = configFromDi;
58
+ });
59
+ }
60
+ else {
61
+ environmentIndicatorLogger.error('Observer not found or invalid in DI container');
62
+ }
63
+ }
64
+ connectedCallback() {
65
+ super.connectedCallback();
66
+ this.diConfig = getCurrentEnvironmentIndicatorConfig();
67
+ this.subscribeToDiConfig();
68
+ this.config = this.getEnvConfigByLevel();
69
+ }
70
+ disconnectedCallback() {
71
+ super.disconnectedCallback();
72
+ if (this.unsubscribeConfig) {
73
+ this.unsubscribeConfig();
74
+ this.unsubscribeConfig = undefined;
75
+ }
76
+ }
84
77
  /**
85
78
  * Helper function to get config from attributes
86
79
  * @returns the config from attributes
@@ -102,35 +95,44 @@ export class EnvironmentIndicator extends FoundationElement {
102
95
  if (this.level) {
103
96
  return this.level;
104
97
  }
105
- // 2. Check current config level
106
- if (this.config && this.config.level && this.config.level !== DEFAULT_ENVIRONMENT_LEVEL) {
107
- return this.config.level;
108
- }
109
- // 3. Check DI configuration
110
- try {
111
- const container = DI.getOrCreateDOMContainer();
112
- const { currentLevel } = container.get(EnvironmentIndicatorConfigToken);
113
- if (currentLevel) {
114
- return currentLevel;
98
+ // 2. Check DI
99
+ if (this.diConfig) {
100
+ try {
101
+ const { currentLevel } = this.diConfig;
102
+ if (currentLevel) {
103
+ return currentLevel;
104
+ }
115
105
  }
106
+ catch (error) {
107
+ environmentIndicatorLogger.error(error);
108
+ }
109
+ }
110
+ // 3. Return environment levelvariable if it is not default
111
+ if (ENVIRONMENT_LEVEL !== DEFAULT_ENVIRONMENT_LEVEL) {
112
+ return ENVIRONMENT_LEVEL;
116
113
  }
117
- catch (error) {
118
- environmentIndicatorLogger.error(error);
114
+ // 4. Return default level if useDefaultConfig is true
115
+ if (this.useDefaultConfig) {
116
+ return DEFAULT_ENVIRONMENT_LEVEL;
119
117
  }
120
- // 4. Return environment variable or return default
121
- return ENVIRONMENT_LEVEL || DEFAULT_ENVIRONMENT_LEVEL;
118
+ return undefined;
122
119
  }
123
120
  getEnvConfigByLevel() {
124
121
  const attributesConfig = this.getAttributesConfig();
125
122
  const currentLevel = this.getCurrentEnvironmentLevel();
123
+ if (!currentLevel) {
124
+ if (this.useDefaultConfig) {
125
+ return DEFAULT_ENVIRONMENT_LEVEL_CONFIG;
126
+ }
127
+ return undefined;
128
+ }
126
129
  // If label is set, use attributes as config with current level
127
130
  if (this.label) {
128
131
  return Object.assign(Object.assign(Object.assign({}, DEFAULT_ENVIRONMENT_LEVEL_CONFIG), { level: currentLevel }), attributesConfig);
129
132
  }
130
- // Try to find config for current level in DI container first
131
- try {
132
- const container = DI.getOrCreateDOMContainer();
133
- const { configs } = container.get(EnvironmentIndicatorConfigToken) || {};
133
+ // If there is DI config, return it with attributes config
134
+ if (this.diConfig) {
135
+ const { configs } = this.diConfig;
134
136
  if (configs && configs.length > 0) {
135
137
  const config = configs.find(({ level }) => level === currentLevel);
136
138
  if (config) {
@@ -138,20 +140,12 @@ export class EnvironmentIndicator extends FoundationElement {
138
140
  }
139
141
  }
140
142
  }
141
- catch (error) {
142
- environmentIndicatorLogger.error(error);
143
- }
144
143
  // Try to find config in envConfigs
145
144
  const envConfig = this.envConfigs.find(({ level }) => level === currentLevel);
146
- // If no env config found, return default config with current level
147
- if (!envConfig) {
148
- return Object.assign(Object.assign(Object.assign({}, DEFAULT_ENVIRONMENT_LEVEL_CONFIG), { level: currentLevel }), attributesConfig);
145
+ // If envConfig is found, return it with attributes config
146
+ if (envConfig) {
147
+ return Object.assign(Object.assign({}, envConfig), attributesConfig);
149
148
  }
150
- return Object.assign(Object.assign({}, envConfig), attributesConfig);
151
- }
152
- connectedCallback() {
153
- super.connectedCallback();
154
- this.config = this.getEnvConfigByLevel();
155
149
  }
156
150
  /**
157
151
  * Handle config change when attributes change
@@ -204,12 +198,18 @@ __decorate([
204
198
  __decorate([
205
199
  attr({ attribute: 'icon-size' })
206
200
  ], EnvironmentIndicator.prototype, "iconSize", void 0);
201
+ __decorate([
202
+ attr({ mode: 'boolean', attribute: 'use-default-config' })
203
+ ], EnvironmentIndicator.prototype, "useDefaultConfig", void 0);
207
204
  __decorate([
208
205
  observable
209
206
  ], EnvironmentIndicator.prototype, "config", void 0);
210
207
  __decorate([
211
208
  observable
212
209
  ], EnvironmentIndicator.prototype, "envConfigs", void 0);
210
+ __decorate([
211
+ observable
212
+ ], EnvironmentIndicator.prototype, "diConfig", void 0);
213
213
  /**
214
214
  * The Foundation Environment indicator
215
215
  *
@@ -2,3 +2,4 @@ export * from './environment-indicator';
2
2
  export * from './environment-indicator.styles';
3
3
  export * from './environment-indicator.template';
4
4
  export { configureEnvironmentIndicator } from './utils/configure';
5
+ export * from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,51 @@
1
1
  import { __awaiter } from "tslib";
2
+ import { createObserver } from '@genesislcap/foundation-utils';
2
3
  import { DI, Registration } from '@microsoft/fast-foundation';
3
- import { DEFAULT_ENVIRONMENT_LEVEL_CONFIG, EnvironmentIndicatorConfigToken, } from '../environment-indicator';
4
+ /**
5
+ * Default environment level
6
+ */
7
+ export const DEFAULT_ENVIRONMENT_LEVEL = 'default';
8
+ /**
9
+ * Default environment level configuration
10
+ */
11
+ export const DEFAULT_ENVIRONMENT_LEVEL_CONFIG = {
12
+ level: DEFAULT_ENVIRONMENT_LEVEL,
13
+ showIcon: false,
14
+ iconSize: 'sm',
15
+ backgroundColor: '#2222ff',
16
+ textColor: '#ffffff',
17
+ label: 'DEFAULT',
18
+ };
19
+ /**
20
+ * Default environment configurations
21
+ */
22
+ export const DEFAULT_ENVIRONMENT_CONFIGS = [
23
+ DEFAULT_ENVIRONMENT_LEVEL_CONFIG,
24
+ {
25
+ level: 'dev',
26
+ showIcon: false,
27
+ icon: 'code',
28
+ backgroundColor: '#ff6b35',
29
+ label: 'DEV',
30
+ },
31
+ {
32
+ level: 'prod',
33
+ showIcon: false,
34
+ icon: 'check-circle',
35
+ backgroundColor: '#28a745',
36
+ label: 'PROD',
37
+ },
38
+ ];
39
+ // Global singleton observer
40
+ export const EnvironmentIndicatorConfigObserver = createObserver();
41
+ // DI token for the observer
42
+ export const EnvironmentIndicatorConfigObserverToken = DI.createInterface((x) => x.instance(EnvironmentIndicatorConfigObserver), (configurator) => configurator.instance(EnvironmentIndicatorConfigObserver));
43
+ // DI token for the current configuration value
44
+ export const EnvironmentIndicatorConfigToken = DI.createInterface('EnvironmentIndicatorConfig');
45
+ /**
46
+ * Configure the environment indicator
47
+ * @param options - the options to configure the environment indicator
48
+ */
4
49
  export function configureEnvironmentIndicator(options = { configs: [] }) {
5
50
  return __awaiter(this, void 0, void 0, function* () {
6
51
  const { configs, currentLevel } = options;
@@ -9,6 +54,23 @@ export function configureEnvironmentIndicator(options = { configs: [] }) {
9
54
  configs: configs && configs.length > 0 ? configs : [DEFAULT_ENVIRONMENT_LEVEL_CONFIG],
10
55
  };
11
56
  const container = DI.getOrCreateDOMContainer();
12
- container.register(Registration.instance(EnvironmentIndicatorConfigToken, value));
57
+ container.register(Registration.instance(EnvironmentIndicatorConfigObserverToken, EnvironmentIndicatorConfigObserver), Registration.instance(EnvironmentIndicatorConfigToken, value));
58
+ EnvironmentIndicatorConfigObserver.publish(value);
13
59
  });
14
60
  }
61
+ /**
62
+ * Get the current environment indicator configuration from DI
63
+ * @returns the current configuration or default if not found
64
+ */
65
+ export function getCurrentEnvironmentIndicatorConfig() {
66
+ try {
67
+ const container = DI.getOrCreateDOMContainer();
68
+ const config = container.get(EnvironmentIndicatorConfigToken);
69
+ if (config) {
70
+ return config;
71
+ }
72
+ }
73
+ catch (error) {
74
+ return undefined;
75
+ }
76
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-ui",
3
3
  "description": "Genesis Foundation UI",
4
- "version": "14.293.2",
4
+ "version": "14.293.3-alpha-16ba6c2.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -83,13 +83,13 @@
83
83
  }
84
84
  },
85
85
  "devDependencies": {
86
- "@genesislcap/foundation-testing": "14.293.2",
87
- "@genesislcap/genx": "14.293.2",
88
- "@genesislcap/rollup-builder": "14.293.2",
89
- "@genesislcap/ts-builder": "14.293.2",
90
- "@genesislcap/uvu-playwright-builder": "14.293.2",
91
- "@genesislcap/vite-builder": "14.293.2",
92
- "@genesislcap/webpack-builder": "14.293.2",
86
+ "@genesislcap/foundation-testing": "14.293.3-alpha-16ba6c2.0",
87
+ "@genesislcap/genx": "14.293.3-alpha-16ba6c2.0",
88
+ "@genesislcap/rollup-builder": "14.293.3-alpha-16ba6c2.0",
89
+ "@genesislcap/ts-builder": "14.293.3-alpha-16ba6c2.0",
90
+ "@genesislcap/uvu-playwright-builder": "14.293.3-alpha-16ba6c2.0",
91
+ "@genesislcap/vite-builder": "14.293.3-alpha-16ba6c2.0",
92
+ "@genesislcap/webpack-builder": "14.293.3-alpha-16ba6c2.0",
93
93
  "copyfiles": "^2.4.1",
94
94
  "rimraf": "^5.0.0",
95
95
  "rxjs": "^7.5.4"
@@ -100,15 +100,15 @@
100
100
  "@fortawesome/free-regular-svg-icons": "^6.2.1",
101
101
  "@fortawesome/free-solid-svg-icons": "^6.2.1",
102
102
  "@genesiscommunitysuccess/analyzer-import-alias-plugin": "^5.0.3",
103
- "@genesislcap/expression-builder": "14.293.2",
104
- "@genesislcap/foundation-comms": "14.293.2",
105
- "@genesislcap/foundation-criteria": "14.293.2",
106
- "@genesislcap/foundation-errors": "14.293.2",
107
- "@genesislcap/foundation-events": "14.293.2",
108
- "@genesislcap/foundation-logger": "14.293.2",
109
- "@genesislcap/foundation-notifications": "14.293.2",
110
- "@genesislcap/foundation-user": "14.293.2",
111
- "@genesislcap/foundation-utils": "14.293.2",
103
+ "@genesislcap/expression-builder": "14.293.3-alpha-16ba6c2.0",
104
+ "@genesislcap/foundation-comms": "14.293.3-alpha-16ba6c2.0",
105
+ "@genesislcap/foundation-criteria": "14.293.3-alpha-16ba6c2.0",
106
+ "@genesislcap/foundation-errors": "14.293.3-alpha-16ba6c2.0",
107
+ "@genesislcap/foundation-events": "14.293.3-alpha-16ba6c2.0",
108
+ "@genesislcap/foundation-logger": "14.293.3-alpha-16ba6c2.0",
109
+ "@genesislcap/foundation-notifications": "14.293.3-alpha-16ba6c2.0",
110
+ "@genesislcap/foundation-user": "14.293.3-alpha-16ba6c2.0",
111
+ "@genesislcap/foundation-utils": "14.293.3-alpha-16ba6c2.0",
112
112
  "@microsoft/fast-colors": "5.3.1",
113
113
  "@microsoft/fast-components": "2.30.6",
114
114
  "@microsoft/fast-element": "1.14.0",
@@ -130,5 +130,5 @@
130
130
  "access": "public"
131
131
  },
132
132
  "customElements": "dist/custom-elements.json",
133
- "gitHead": "a5107ae0a1670f5ed14eef84504d7e16385a0601"
133
+ "gitHead": "33a251fdcc15e1d5686652bd56838f3c13fcb73b"
134
134
  }