@descope-ui/common 2.1.16 → 2.1.18

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,15 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [2.1.18](https://github.com/descope/web-components-ui/compare/web-components-ui-2.1.17...web-components-ui-2.1.18) (2025-10-26)
6
+
7
+ ## [2.1.17](https://github.com/descope/web-components-ui/compare/web-components-ui-2.1.16...web-components-ui-2.1.17) (2025-10-20)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * issue 12430 ([#757](https://github.com/descope/web-components-ui/issues/757)) ([a8d2701](https://github.com/descope/web-components-ui/commit/a8d2701ace8ee9910d445689f5376505add76cfe))
13
+
5
14
  ## [2.1.16](https://github.com/descope/web-components-ui/compare/web-components-ui-2.1.15...web-components-ui-2.1.16) (2025-10-19)
6
15
 
7
16
  ## [2.1.15](https://github.com/descope/web-components-ui/compare/web-components-ui-2.1.14...web-components-ui-2.1.15) (2025-10-16)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope-ui/common",
3
- "version": "2.1.16",
3
+ "version": "2.1.18",
4
4
  "dependencies": {
5
5
  "element-internals-polyfill": "^1.3.9",
6
6
  "color": "^4.2.3",
@@ -126,6 +126,10 @@ export const injectStyle = (cssString, ref, { prepend = false } = {}) => {
126
126
  _ref.adoptedStyleSheets = adoptedStyleSheets;
127
127
  }
128
128
 
129
+ if(cssString && !style.cssRules[0]?.style){
130
+ console.warn(`No style rules were created, make sure the CSS is valid:\n "${cssString}"`)
131
+ }
132
+
129
133
  return style;
130
134
  };
131
135
 
@@ -1,16 +1,25 @@
1
1
  import { camelCaseJoin, isFunction, kebabCase, kebabCaseJoin } from '../../../utils';
2
2
  import { getCssVarName } from '../../../componentsHelpers';
3
3
 
4
- const createCssVar = (varName, fallback) => `var(${varName}${fallback ? `, ${fallback}` : ''})`;
4
+ const getOverrideCssVarName = (origVarName) => `${origVarName}__override`;
5
+
6
+ const createCssVar = (varName, fallback, createOverride = false) => {
7
+ const ret = `var(${varName}${fallback ? `, ${fallback}` : ''})`;
8
+
9
+ if (!createOverride) return ret;
10
+
11
+ // we are generating an override css var to allow override with fallback to the default var
12
+ const overrideVarName = getOverrideCssVarName(varName);
13
+ return `var(${overrideVarName}, ${ret})`;
14
+ };
5
15
 
6
16
  const createCssSelector = (baseSelector = '', relativeSelectorOrSelectorFn = '') =>
7
17
  isFunction(relativeSelectorOrSelectorFn)
8
18
  ? relativeSelectorOrSelectorFn(baseSelector)
9
- : `${baseSelector}${
10
- /^[A-Za-z]/.test(relativeSelectorOrSelectorFn)
11
- ? ` ${relativeSelectorOrSelectorFn}`
12
- : relativeSelectorOrSelectorFn
13
- }`;
19
+ : `${baseSelector}${/^[A-Za-z]/.test(relativeSelectorOrSelectorFn)
20
+ ? ` ${relativeSelectorOrSelectorFn}`
21
+ : relativeSelectorOrSelectorFn
22
+ }`;
14
23
 
15
24
  class StyleBuilder {
16
25
  constructor() {
@@ -50,6 +59,7 @@ const getFallbackVarName = (origVarName, suffix = 'fallback') => kebabCaseJoin(o
50
59
 
51
60
  export const createStyle = (componentName, baseSelector, mappings) => {
52
61
  const style = new StyleBuilder();
62
+ // we generate all the fallback vars recursively
53
63
  const createFallbackVar = (fallback, origVarName) => {
54
64
  if (!fallback) return '';
55
65
  if (typeof fallback === 'string') return fallback;
@@ -69,7 +79,7 @@ export const createStyle = (componentName, baseSelector, mappings) => {
69
79
  style.add(
70
80
  createCssSelector(baseSelector, relativeSelectorOrSelectorFn),
71
81
  isFunction(property) ? property() : property,
72
- createCssVar(cssVarName, fallbackValue) + (important ? '!important' : '')
82
+ createCssVar(cssVarName, fallbackValue, true) + (important ? '!important' : '')
73
83
  );
74
84
  }
75
85
  );
@@ -96,6 +106,8 @@ export const createCssVarsList = (componentName, mappings) =>
96
106
  return Object.assign(
97
107
  acc,
98
108
  { [attr]: varName },
109
+ // we are exposing the override css var names, the convention is to add 'Override' suffix to the attribute name
110
+ { [attr + 'Override']: getOverrideCssVarName(varName) },
99
111
  getFallbackVarsNames(attr, varName, mappings[attr])
100
112
  );
101
113
  }, {});
@@ -108,7 +108,7 @@ export const createStyleMixin =
108
108
  if (elementId) {
109
109
  // basically this is enough to make the selector more specific
110
110
  // but just in case there is no id, we will also add the class multiple times
111
- classSpecifier += `#${elementId}`;
111
+ classSpecifier += `#${CSS.escape(elementId)}`;
112
112
  }
113
113
 
114
114
  this.#overrideStyleEle = injectStyle(`:host(${classSpecifier}) {}`, this.#rootElement);
@@ -117,7 +117,7 @@ export const createStyleMixin =
117
117
 
118
118
 
119
119
  #setAttrOverride(attrName, value) {
120
- const style = this.#overrideStyleEle?.cssRules[0]?.style;
120
+ const style = this.#overrideStyleEle.cssRules[0].style;
121
121
 
122
122
  if (!style) return;
123
123