@descope/web-components-ui 1.72.0 → 1.73.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.
- package/dist/cjs/index.cjs.js +52 -14
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +52 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/DescopeDev.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +13 -13
package/dist/index.esm.js
CHANGED
@@ -326,19 +326,19 @@ const observeChildren = (ele, callback) => {
|
|
326
326
|
|
327
327
|
const createSyncAttrsCb =
|
328
328
|
(srcEle, targetEle, mapAttrs = {}) =>
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
329
|
+
(attrNames) => {
|
330
|
+
attrNames.forEach((attrName) => {
|
331
|
+
const targetAttrName = mapAttrs[attrName] || attrName;
|
332
|
+
const srcAttrVal = srcEle.getAttribute(attrName);
|
333
|
+
if (srcAttrVal !== null) {
|
334
|
+
if (targetEle.getAttribute(targetAttrName) !== srcAttrVal) {
|
335
|
+
targetEle.setAttribute(targetAttrName, srcAttrVal);
|
336
|
+
}
|
337
|
+
} else {
|
338
|
+
targetEle.removeAttribute(targetAttrName);
|
336
339
|
}
|
337
|
-
}
|
338
|
-
|
339
|
-
}
|
340
|
-
});
|
341
|
-
};
|
340
|
+
});
|
341
|
+
};
|
342
342
|
|
343
343
|
const syncAttrs = (ele1, ele2, options) => {
|
344
344
|
observeAttributes(ele1, createSyncAttrsCb(ele1, ele2), options);
|
@@ -375,8 +375,16 @@ const forwardProps$2 = (src, target, props = []) => {
|
|
375
375
|
Object.defineProperties(target, config);
|
376
376
|
};
|
377
377
|
|
378
|
-
const injectStyle = (cssString, ref, {prepend = false} = {}) => {
|
379
|
-
|
378
|
+
const injectStyle = (cssString, ref, { prepend = false } = {}) => {
|
379
|
+
|
380
|
+
let style;
|
381
|
+
try {
|
382
|
+
style = new CSSStyleSheet();
|
383
|
+
} catch (e) {
|
384
|
+
// fallback for browsers that don't support CSSStyleSheet
|
385
|
+
return generateStyleTagFallback(cssString, ref, { prepend });
|
386
|
+
}
|
387
|
+
|
380
388
|
const _ref = ref?.shadowRoot || ref;
|
381
389
|
if (cssString) {
|
382
390
|
style.replaceSync(cssString);
|
@@ -391,6 +399,36 @@ const injectStyle = (cssString, ref, {prepend = false} = {}) => {
|
|
391
399
|
return style;
|
392
400
|
};
|
393
401
|
|
402
|
+
// we should mimic the CSSStyleSheet API for the fns we are using
|
403
|
+
class CSSStyleSheetMock {
|
404
|
+
constructor(cssString, ref, { prepend = false } = {}) {
|
405
|
+
this.styleEle = document.createElement('style');
|
406
|
+
this.styleEle.textContent = cssString;
|
407
|
+
this.styleEle.setAttribute('nonce', window.DESCOPE_NONCE);
|
408
|
+
this.ref = ref?.shadowRoot || ref;
|
409
|
+
|
410
|
+
if (!this.ref) {
|
411
|
+
return
|
412
|
+
}
|
413
|
+
|
414
|
+
if (prepend) {
|
415
|
+
this.ref.prepend(this.styleEle);
|
416
|
+
} else {
|
417
|
+
this.ref.append(this.styleEle);
|
418
|
+
}
|
419
|
+
}
|
420
|
+
|
421
|
+
replaceSync(cssString) {
|
422
|
+
this.styleEle.textContent = cssString;
|
423
|
+
}
|
424
|
+
|
425
|
+
get cssRules() {
|
426
|
+
return this.styleEle.sheet?.cssRules;
|
427
|
+
}
|
428
|
+
}
|
429
|
+
|
430
|
+
const generateStyleTagFallback = (cssString, ref, { prepend = false } = {}) => new CSSStyleSheetMock(cssString, ref, { prepend });
|
431
|
+
|
394
432
|
class ComponentsThemeManager {
|
395
433
|
static mountOnPropName = 'DescopeThemeManager';
|
396
434
|
|