@descope-ui/common 0.0.11 → 0.0.13

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.13](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.12...@descope-ui/common-0.0.13) (2025-06-09)
6
+
7
+ ## [0.0.12](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.11...@descope-ui/common-0.0.12) (2025-05-28)
8
+
5
9
  ## [0.0.11](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.10...@descope-ui/common-0.0.11) (2025-04-29)
6
10
 
7
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope-ui/common",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "dependencies": {
5
5
  "element-internals-polyfill": "^1.3.9",
6
6
  "color": "^4.2.3",
@@ -1,8 +1,19 @@
1
- import { BASE_THEME_SECTION, CSS_SELECTOR_SPECIFIER_MULTIPLY } from '../../../constants';
1
+ import {
2
+ BASE_THEME_SECTION,
3
+ CSS_SELECTOR_SPECIFIER_MULTIPLY,
4
+ } from '../../../constants';
2
5
  import { kebabCaseJoin } from '../../../utils';
3
- import { getCssVarName, injectStyle, observeAttributes } from '../../../componentsHelpers';
6
+ import {
7
+ getCssVarName,
8
+ injectStyle,
9
+ observeAttributes,
10
+ } from '../../../componentsHelpers';
4
11
  import { componentsThemeManager } from '../../../themeHelpers';
5
- import { createStyle, createCssVarsList, createClassSelectorSpecifier } from './helpers';
12
+ import {
13
+ createStyle,
14
+ createCssVarsList,
15
+ createClassSelectorSpecifier,
16
+ } from './helpers';
6
17
 
7
18
  const STYLE_OVERRIDE_ATTR_PREFIX = 'st';
8
19
 
@@ -54,8 +65,10 @@ export const createStyleMixin =
54
65
  this.#baseSelector = baseSelector ?? this.baseSelector;
55
66
  this.#getRootElement = getRootElement;
56
67
 
57
- this.#styleAttributes = Object.keys(CustomStyleMixinClass.cssVarList).map((key) =>
58
- kebabCaseJoin(STYLE_OVERRIDE_ATTR_PREFIX, componentNameSuffix, key)
68
+ this.#styleAttributes = Object.keys(
69
+ CustomStyleMixinClass.cssVarList,
70
+ ).map((key) =>
71
+ kebabCaseJoin(STYLE_OVERRIDE_ATTR_PREFIX, componentNameSuffix, key),
59
72
  );
60
73
  }
61
74
 
@@ -65,14 +78,23 @@ export const createStyleMixin =
65
78
  }
66
79
 
67
80
  #onComponentThemeChange() {
68
- this.#themeStyleEle.replaceSync(this.#componentTheme[this.#themeSection]);
81
+ this.#themeStyleEle.replaceSync(
82
+ this.#componentTheme[this.#themeSection],
83
+ );
84
+ this.currentThemeName = componentsThemeManager.currentThemeName;
85
+ // `onThemeChange` - This function is a hook for the component, so it can be implemented in the component
86
+ // and is executed once theme is change.
87
+ this.onThemeChange?.(componentsThemeManager.currentThemeName);
69
88
  }
70
89
 
71
90
  #createComponentTheme() {
72
- this.#themeStyleEle = injectStyle('', this.#rootElement, { prepend: true });
73
- this.#disconnectThemeManager = componentsThemeManager.onCurrentThemeChange(
74
- this.#onComponentThemeChange.bind(this)
75
- );
91
+ this.#themeStyleEle = injectStyle('', this.#rootElement, {
92
+ prepend: true,
93
+ });
94
+ this.#disconnectThemeManager =
95
+ componentsThemeManager.onCurrentThemeChange(
96
+ this.#onComponentThemeChange.bind(this),
97
+ );
76
98
  this.#onComponentThemeChange();
77
99
  }
78
100
 
@@ -80,10 +102,13 @@ export const createStyleMixin =
80
102
  if (this.#styleAttributes.length) {
81
103
  const classSpecifier = createClassSelectorSpecifier(
82
104
  componentName,
83
- CSS_SELECTOR_SPECIFIER_MULTIPLY
105
+ CSS_SELECTOR_SPECIFIER_MULTIPLY,
84
106
  );
85
107
 
86
- this.#overrideStyleEle = injectStyle(`:host(${classSpecifier}) {}`, this.#rootElement);
108
+ this.#overrideStyleEle = injectStyle(
109
+ `:host(${classSpecifier}) {}`,
110
+ this.#rootElement,
111
+ );
87
112
  }
88
113
  }
89
114
 
@@ -94,7 +119,7 @@ export const createStyleMixin =
94
119
 
95
120
  const varName = getCssVarName(
96
121
  componentName,
97
- attrName.replace(new RegExp(`^${STYLE_OVERRIDE_ATTR_PREFIX}-`), '')
122
+ attrName.replace(new RegExp(`^${STYLE_OVERRIDE_ATTR_PREFIX}-`), ''),
98
123
  );
99
124
 
100
125
  if (value) style?.setProperty(varName, value);
@@ -117,7 +142,7 @@ export const createStyleMixin =
117
142
  const style = createStyle(
118
143
  kebabCaseJoin(componentName, this.#componentNameSuffix),
119
144
  this.#baseSelector,
120
- mappings
145
+ mappings,
121
146
  );
122
147
 
123
148
  injectStyle(style, this.#rootElement, { prepend: true });
@@ -125,13 +150,16 @@ export const createStyleMixin =
125
150
  }
126
151
 
127
152
  #addClassName(className) {
128
- (this.#rootElement.classList || this.#rootElement.host.classList).add(className);
153
+ (this.#rootElement.classList || this.#rootElement.host.classList).add(
154
+ className,
155
+ );
129
156
  }
130
157
 
131
158
  async init() {
132
159
  super.init?.();
133
160
  if (this.shadowRoot.isConnected) {
134
- this.#rootElement = (await this.#getRootElement?.(this)) || this.shadowRoot;
161
+ this.#rootElement =
162
+ (await this.#getRootElement?.(this)) || this.shadowRoot;
135
163
 
136
164
  this.#addClassName(componentName);
137
165
 
@@ -12,7 +12,9 @@ export const inputEventsDispatchingMixin = (superclass) =>
12
12
  #blockNativeEvents() {
13
13
  ['blur', 'focus', 'focusin', 'focusout'].forEach((event) => {
14
14
  this.addEventListener(event, (e) => {
15
- e.isTrusted && e.target === this && e.stopImmediatePropagation();
15
+ if (e.isTrusted && e.target === this) {
16
+ e.stopImmediatePropagation()
17
+ };
16
18
  });
17
19
  });
18
20
  }