@descope/web-components-ui 1.0.362 → 1.0.364

Sign up to get free protection for your applications and to get access to all the features.
@@ -9883,33 +9883,44 @@ const isValidDataType = (data) => {
9883
9883
 
9884
9884
  const isPlainObject = (value) => value?.constructor === Object;
9885
9885
 
9886
+ const isXml = (str) => /^\s*<[\s\S]*>/.test(str);
9887
+
9888
+ const escapeXML = (s) => {
9889
+ const dom = document.createElement('div');
9890
+ dom.textContent = s;
9891
+ return dom.innerHTML;
9892
+ };
9893
+
9886
9894
  const getValueType = (value) => {
9887
9895
  if (isPlainObject(value)) return 'object';
9888
9896
  if (Array.isArray(value)) return 'array';
9897
+ if (isXml(value)) return 'xml';
9889
9898
 
9890
9899
  return 'text';
9891
9900
  };
9892
9901
 
9893
- const renderCodeSnippet = (value) =>
9894
- `<descope-code-snippet lang="json" class="row-details__value json">${JSON.stringify(
9895
- value,
9896
- null,
9897
- 2
9898
- )}</descope-code-snippet>`;
9902
+ const renderCodeSnippet = (value, lang) =>
9903
+ `<descope-code-snippet lang="${lang}" class="row-details__value code">${value}</descope-code-snippet>`;
9899
9904
 
9900
9905
  const renderText = (text) =>
9901
9906
  `<div class="row-details__value text" title="${text}">${text}</div>`;
9907
+ const renderJson = (value) => renderCodeSnippet(JSON.stringify(value, null, 2), 'json');
9908
+ const renderXml = (value) => renderCodeSnippet(escapeXML(value), 'xml');
9902
9909
 
9903
9910
  const defaultRowDetailsValueRenderer = (value) => {
9904
9911
  const valueType = getValueType(value);
9905
9912
 
9906
9913
  if (valueType === 'object') {
9907
- return renderCodeSnippet(value);
9914
+ return renderJson(value);
9915
+ }
9916
+
9917
+ if (valueType === 'xml') {
9918
+ return renderXml(value);
9908
9919
  }
9909
9920
 
9910
9921
  if (valueType === 'array') {
9911
9922
  if (value.some((v) => getValueType(v) === 'object')) {
9912
- return renderCodeSnippet(value);
9923
+ return renderJson(value);
9913
9924
  }
9914
9925
  return renderText(value.join(',\n'));
9915
9926
  }
@@ -10266,7 +10277,7 @@ const GridClass = compose(
10266
10277
  grid-template-columns: repeat(auto-fit, minmax(max(200px, calc(100%/4 - var(${GridClass.cssVarList.detailsPanelItemsGap}))), 1fr));
10267
10278
  width: 100%;
10268
10279
  }
10269
- vaadin-grid .row-details__item:has(.row-details__value.json) {
10280
+ vaadin-grid .row-details__item:has(.row-details__value.code) {
10270
10281
  grid-column: 1 / -1;
10271
10282
  order: 2;
10272
10283
  }
@@ -10275,7 +10286,7 @@ const GridClass = compose(
10275
10286
  text-overflow: ellipsis;
10276
10287
  white-space: pre;
10277
10288
  }
10278
- vaadin-grid .row-details__value.json {
10289
+ vaadin-grid .row-details__value.code {
10279
10290
  margin-top: 5px;
10280
10291
  max-height: 120px;
10281
10292
  overflow: scroll;