@descope/web-components-ui 1.0.362 → 1.0.363

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -8783,33 +8783,44 @@ const isValidDataType = (data) => {
8783
8783
 
8784
8784
  const isPlainObject = (value) => value?.constructor === Object;
8785
8785
 
8786
+ const isXml = (str) => /^\s*<[\s\S]*>/.test(str);
8787
+
8788
+ const escapeXML = (s) => {
8789
+ const dom = document.createElement('div');
8790
+ dom.textContent = s;
8791
+ return dom.innerHTML;
8792
+ };
8793
+
8786
8794
  const getValueType = (value) => {
8787
8795
  if (isPlainObject(value)) return 'object';
8788
8796
  if (Array.isArray(value)) return 'array';
8797
+ if (isXml(value)) return 'xml';
8789
8798
 
8790
8799
  return 'text';
8791
8800
  };
8792
8801
 
8793
- const renderCodeSnippet = (value) =>
8794
- `<descope-code-snippet lang="json" class="row-details__value json">${JSON.stringify(
8795
- value,
8796
- null,
8797
- 2
8798
- )}</descope-code-snippet>`;
8802
+ const renderCodeSnippet = (value, lang) =>
8803
+ `<descope-code-snippet lang="${lang}" class="row-details__value code">${value}</descope-code-snippet>`;
8799
8804
 
8800
8805
  const renderText = (text) =>
8801
8806
  `<div class="row-details__value text" title="${text}">${text}</div>`;
8807
+ const renderJson = (value) => renderCodeSnippet(JSON.stringify(value, null, 2), 'json');
8808
+ const renderXml = (value) => renderCodeSnippet(escapeXML(value), 'xml');
8802
8809
 
8803
8810
  const defaultRowDetailsValueRenderer = (value) => {
8804
8811
  const valueType = getValueType(value);
8805
8812
 
8806
8813
  if (valueType === 'object') {
8807
- return renderCodeSnippet(value);
8814
+ return renderJson(value);
8815
+ }
8816
+
8817
+ if (valueType === 'xml') {
8818
+ return renderXml(value);
8808
8819
  }
8809
8820
 
8810
8821
  if (valueType === 'array') {
8811
8822
  if (value.some((v) => getValueType(v) === 'object')) {
8812
- return renderCodeSnippet(value);
8823
+ return renderJson(value);
8813
8824
  }
8814
8825
  return renderText(value.join(',\n'));
8815
8826
  }
@@ -9166,7 +9177,7 @@ const GridClass = compose(
9166
9177
  grid-template-columns: repeat(auto-fit, minmax(max(200px, calc(100%/4 - var(${GridClass.cssVarList.detailsPanelItemsGap}))), 1fr));
9167
9178
  width: 100%;
9168
9179
  }
9169
- vaadin-grid .row-details__item:has(.row-details__value.json) {
9180
+ vaadin-grid .row-details__item:has(.row-details__value.code) {
9170
9181
  grid-column: 1 / -1;
9171
9182
  order: 2;
9172
9183
  }
@@ -9175,7 +9186,7 @@ const GridClass = compose(
9175
9186
  text-overflow: ellipsis;
9176
9187
  white-space: pre;
9177
9188
  }
9178
- vaadin-grid .row-details__value.json {
9189
+ vaadin-grid .row-details__value.code {
9179
9190
  margin-top: 5px;
9180
9191
  max-height: 120px;
9181
9192
  overflow: scroll;