@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.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import '@vaadin/button';
2
2
  import 'element-internals-polyfill';
3
+ import DOMPurify from 'dompurify';
3
4
  import '@vaadin/checkbox';
4
5
  import '@vaadin/text-field';
5
6
  import '@vaadin/email-field';
@@ -1412,8 +1413,11 @@ const createImgEle = (src) => {
1412
1413
  };
1413
1414
 
1414
1415
  const createSvgEle = (text) => {
1416
+ // we want to purify the SVG to avoid XSS attacks
1417
+ const clean = DOMPurify.sanitize(text, { USE_PROFILES: { svg: true, svgFilters: true } });
1418
+
1415
1419
  const parser = new DOMParser();
1416
- const ele = parser.parseFromString(text, 'image/svg+xml').querySelector('svg');
1420
+ const ele = parser.parseFromString(clean, 'image/svg+xml').querySelector('svg');
1417
1421
  return ele;
1418
1422
  };
1419
1423
 
@@ -11954,7 +11958,7 @@ const componentName$2 = getComponentName('list');
11954
11958
 
11955
11959
  class RawList extends createBaseClass({ componentName: componentName$2, baseSelector: '.wrapper' }) {
11956
11960
  static get observedAttributes() {
11957
- return ['variant'];
11961
+ return ['variant', 'readonly'];
11958
11962
  }
11959
11963
 
11960
11964
  constructor() {
@@ -12037,6 +12041,18 @@ class RawList extends createBaseClass({ componentName: componentName$2, baseSele
12037
12041
  observeChildren(this, () => {
12038
12042
  this.#handleEmptyState();
12039
12043
  this.#handleItemsVariant();
12044
+ this.#handleReadOnly();
12045
+ });
12046
+ }
12047
+
12048
+ get isReadOnly() {
12049
+ return this.getAttribute('readonly') === 'true';
12050
+ }
12051
+
12052
+ #handleReadOnly() {
12053
+ this.items.forEach((item) => {
12054
+ if (this.isReadOnly) item.setAttribute('inert', '');
12055
+ else item.removeAttribute('inert');
12040
12056
  });
12041
12057
  }
12042
12058
 
@@ -12047,6 +12063,8 @@ class RawList extends createBaseClass({ componentName: componentName$2, baseSele
12047
12063
 
12048
12064
  if (name === 'variant') {
12049
12065
  this.#handleItemsVariant();
12066
+ } else if (name === 'readonly') {
12067
+ this.#handleReadOnly();
12050
12068
  }
12051
12069
  }
12052
12070
  }
@@ -12164,16 +12182,51 @@ const createDynamicDataMixin =
12164
12182
  super.init?.();
12165
12183
 
12166
12184
  if (rerenderAttrsList.length) {
12167
- observeAttributes(this, () => this.#renderItems(), { includeAttrs: rerenderAttrsList });
12185
+ observeAttributes(
12186
+ this,
12187
+ (attrs) => {
12188
+ if (attrs.includes('data')) this.#handleDataAttr();
12189
+ if (attrs.some((attr) => attr !== 'data')) this.#renderItems();
12190
+ },
12191
+ { includeAttrs: [...rerenderAttrsList, 'data'] }
12192
+ );
12168
12193
  } else {
12169
12194
  this.#renderItems();
12170
12195
  }
12171
12196
  }
12197
+
12198
+ #handleDataAttr() {
12199
+ const dataAttr = this.getAttribute('data');
12200
+
12201
+ if (!dataAttr) return;
12202
+
12203
+ try {
12204
+ this.#data = JSON.parse(dataAttr);
12205
+ } catch (e) {
12206
+ // eslint-disable-next-line no-console
12207
+ console.warn('Invalid JSON data', dataAttr);
12208
+ }
12209
+ }
12210
+
12211
+ attributeChangedCallback(name, oldValue, newValue) {
12212
+ super.attributeChangedCallback?.(name, oldValue, newValue);
12213
+
12214
+ if (newValue === oldValue) return;
12215
+
12216
+ if (name === 'data') {
12217
+ try {
12218
+ this.data = JSON.parse(newValue);
12219
+ } catch (e) {
12220
+ // eslint-disable-next-line no-console
12221
+ console.warn('Invalid JSON data', newValue);
12222
+ }
12223
+ }
12224
+ }
12172
12225
  };
12173
12226
 
12174
12227
  const componentName$1 = getComponentName('apps-list');
12175
12228
 
12176
- const limitAbbreviation = (str, limit = 3) =>
12229
+ const limitAbbreviation = (str, limit = 2) =>
12177
12230
  str
12178
12231
  .trim()
12179
12232
  .split(' ')
@@ -12182,12 +12235,11 @@ const limitAbbreviation = (str, limit = 3) =>
12182
12235
  .join('');
12183
12236
 
12184
12237
  const itemRenderer = ({ name, icon, url }, _, ref) => `
12185
- <a href="${url}" target="_blank" title="${url}">
12238
+ <a ${url ? `href="${url}" title="${url}"` : ''} target="_blank">
12186
12239
  <descope-list-item>
12187
12240
  <descope-avatar
12188
- img="${icon}"
12189
- display-name="${name}"
12190
- abbr=${limitAbbreviation(name)}
12241
+ ${icon ? `img="${icon}"` : ''}
12242
+ ${name ? `display-name="${name}" abbr=${limitAbbreviation(name)}` : ''}
12191
12243
  size=${ref.size}
12192
12244
  ></descope-avatar>
12193
12245
  <descope-text
@@ -12233,7 +12285,7 @@ const AppsListClass = compose(
12233
12285
  createProxy({
12234
12286
  slots: ['empty-state'],
12235
12287
  wrappedEleName: 'descope-list',
12236
- excludeAttrsSync: ['tabindex', 'class'],
12288
+ excludeAttrsSync: ['tabindex', 'class', 'empty'],
12237
12289
  componentName: componentName$1,
12238
12290
  style: () => `
12239
12291
  :host {