@descope/web-components-ui 1.0.369 → 1.0.370

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@
2
2
 
3
3
  var merge = require('lodash.merge');
4
4
  var Color = require('color');
5
+ var DOMPurify = require('dompurify');
5
6
  var MarkdownIt = require('markdown-it');
6
7
  require('lodash.debounce');
7
8
  var hljs = require('highlight.js');
@@ -2633,8 +2634,11 @@ const createImgEle = (src) => {
2633
2634
  };
2634
2635
 
2635
2636
  const createSvgEle = (text) => {
2637
+ // we want to purify the SVG to avoid XSS attacks
2638
+ const clean = DOMPurify.sanitize(text, { USE_PROFILES: { svg: true, svgFilters: true } });
2639
+
2636
2640
  const parser = new DOMParser();
2637
- const ele = parser.parseFromString(text, 'image/svg+xml').querySelector('svg');
2641
+ const ele = parser.parseFromString(clean, 'image/svg+xml').querySelector('svg');
2638
2642
  return ele;
2639
2643
  };
2640
2644
 
@@ -13214,7 +13218,7 @@ const componentName$3 = getComponentName('list');
13214
13218
 
13215
13219
  class RawList extends createBaseClass({ componentName: componentName$3, baseSelector: '.wrapper' }) {
13216
13220
  static get observedAttributes() {
13217
- return ['variant'];
13221
+ return ['variant', 'readonly'];
13218
13222
  }
13219
13223
 
13220
13224
  constructor() {
@@ -13297,6 +13301,18 @@ class RawList extends createBaseClass({ componentName: componentName$3, baseSele
13297
13301
  observeChildren(this, () => {
13298
13302
  this.#handleEmptyState();
13299
13303
  this.#handleItemsVariant();
13304
+ this.#handleReadOnly();
13305
+ });
13306
+ }
13307
+
13308
+ get isReadOnly() {
13309
+ return this.getAttribute('readonly') === 'true';
13310
+ }
13311
+
13312
+ #handleReadOnly() {
13313
+ this.items.forEach((item) => {
13314
+ if (this.isReadOnly) item.setAttribute('inert', '');
13315
+ else item.removeAttribute('inert');
13300
13316
  });
13301
13317
  }
13302
13318
 
@@ -13307,6 +13323,8 @@ class RawList extends createBaseClass({ componentName: componentName$3, baseSele
13307
13323
 
13308
13324
  if (name === 'variant') {
13309
13325
  this.#handleItemsVariant();
13326
+ } else if (name === 'readonly') {
13327
+ this.#handleReadOnly();
13310
13328
  }
13311
13329
  }
13312
13330
  }
@@ -13520,16 +13538,51 @@ const createDynamicDataMixin =
13520
13538
  super.init?.();
13521
13539
 
13522
13540
  if (rerenderAttrsList.length) {
13523
- observeAttributes(this, () => this.#renderItems(), { includeAttrs: rerenderAttrsList });
13541
+ observeAttributes(
13542
+ this,
13543
+ (attrs) => {
13544
+ if (attrs.includes('data')) this.#handleDataAttr();
13545
+ if (attrs.some((attr) => attr !== 'data')) this.#renderItems();
13546
+ },
13547
+ { includeAttrs: [...rerenderAttrsList, 'data'] }
13548
+ );
13524
13549
  } else {
13525
13550
  this.#renderItems();
13526
13551
  }
13527
13552
  }
13553
+
13554
+ #handleDataAttr() {
13555
+ const dataAttr = this.getAttribute('data');
13556
+
13557
+ if (!dataAttr) return;
13558
+
13559
+ try {
13560
+ this.#data = JSON.parse(dataAttr);
13561
+ } catch (e) {
13562
+ // eslint-disable-next-line no-console
13563
+ console.warn('Invalid JSON data', dataAttr);
13564
+ }
13565
+ }
13566
+
13567
+ attributeChangedCallback(name, oldValue, newValue) {
13568
+ super.attributeChangedCallback?.(name, oldValue, newValue);
13569
+
13570
+ if (newValue === oldValue) return;
13571
+
13572
+ if (name === 'data') {
13573
+ try {
13574
+ this.data = JSON.parse(newValue);
13575
+ } catch (e) {
13576
+ // eslint-disable-next-line no-console
13577
+ console.warn('Invalid JSON data', newValue);
13578
+ }
13579
+ }
13580
+ }
13528
13581
  };
13529
13582
 
13530
13583
  const componentName$2 = getComponentName('apps-list');
13531
13584
 
13532
- const limitAbbreviation = (str, limit = 3) =>
13585
+ const limitAbbreviation = (str, limit = 2) =>
13533
13586
  str
13534
13587
  .trim()
13535
13588
  .split(' ')
@@ -13538,12 +13591,11 @@ const limitAbbreviation = (str, limit = 3) =>
13538
13591
  .join('');
13539
13592
 
13540
13593
  const itemRenderer = ({ name, icon, url }, _, ref) => `
13541
- <a href="${url}" target="_blank" title="${url}">
13594
+ <a ${url ? `href="${url}" title="${url}"` : ''} target="_blank">
13542
13595
  <descope-list-item>
13543
13596
  <descope-avatar
13544
- img="${icon}"
13545
- display-name="${name}"
13546
- abbr=${limitAbbreviation(name)}
13597
+ ${icon ? `img="${icon}"` : ''}
13598
+ ${name ? `display-name="${name}" abbr=${limitAbbreviation(name)}` : ''}
13547
13599
  size=${ref.size}
13548
13600
  ></descope-avatar>
13549
13601
  <descope-text
@@ -13589,7 +13641,7 @@ const AppsListClass = compose(
13589
13641
  createProxy({
13590
13642
  slots: ['empty-state'],
13591
13643
  wrappedEleName: 'descope-list',
13592
- excludeAttrsSync: ['tabindex', 'class'],
13644
+ excludeAttrsSync: ['tabindex', 'class', 'empty'],
13593
13645
  componentName: componentName$2,
13594
13646
  style: () => `
13595
13647
  :host {