@formio/js 5.0.0-dev.5631.2d9a450 → 5.0.0-dev.5632.8d1873d

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.
@@ -1850,9 +1850,6 @@ class Component extends Element_1.default {
1850
1850
  messages = lodash_1.default.uniqBy(messages, message => message.message);
1851
1851
  if (this.refs.messageContainer) {
1852
1852
  this.setContent(this.refs.messageContainer, messages.map((message) => {
1853
- if (message.message && typeof message.message === 'string') {
1854
- message.message = message.message.replaceAll('<', '&lt;').replaceAll('>', '&gt;');
1855
- }
1856
1853
  return this.renderTemplate('message', Object.assign({}, message));
1857
1854
  }).join(''));
1858
1855
  }
@@ -1526,7 +1526,7 @@ class SelectComponent extends ListComponent_1.default {
1526
1526
  const getTemplateValue = (v) => {
1527
1527
  const itemTemplate = this.itemTemplate(v);
1528
1528
  return options.csv && itemTemplate
1529
- ? (0, utils_1.unescapeHTML)(itemTemplate)
1529
+ ? (0, utils_1.removeHTML)(itemTemplate)
1530
1530
  : itemTemplate;
1531
1531
  };
1532
1532
  if (Array.isArray(value)) {
@@ -107,6 +107,12 @@ export function checkCondition(component: any, row: any, data: any, form: any, i
107
107
  */
108
108
  export function checkTrigger(component: any, trigger: any, row: any, data: any, form: any, instance: any): mixed;
109
109
  export function setActionProperty(component: any, action: any, result: any, row: any, data: any, instance: any): any;
110
+ /**
111
+ * Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
112
+ * @param {string} str
113
+ * @returns {string}
114
+ */
115
+ export function removeHTML(str: string): string;
110
116
  /**
111
117
  * Unescape HTML characters like &lt, &gt, &amp and etc.
112
118
  * @param str
@@ -30,8 +30,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  return (mod && mod.__esModule) ? mod : { "default": mod };
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.withSwitch = exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
34
- exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = void 0;
33
+ exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.removeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
34
+ exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
35
35
  const lodash_1 = __importDefault(require("lodash"));
36
36
  exports._ = lodash_1.default;
37
37
  const fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
@@ -448,6 +448,16 @@ function setActionProperty(component, action, result, row, data, instance) {
448
448
  return component;
449
449
  }
450
450
  exports.setActionProperty = setActionProperty;
451
+ /**
452
+ * Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
453
+ * @param {string} str
454
+ * @returns {string}
455
+ */
456
+ function removeHTML(str) {
457
+ const doc = new window.DOMParser().parseFromString(str, 'text/html');
458
+ return (doc.body.textContent || '').trim();
459
+ }
460
+ exports.removeHTML = removeHTML;
451
461
  /**
452
462
  * Unescape HTML characters like &lt, &gt, &amp and etc.
453
463
  * @param str
@@ -457,8 +467,9 @@ function unescapeHTML(str) {
457
467
  if (typeof window === 'undefined' || !('DOMParser' in window)) {
458
468
  return str;
459
469
  }
460
- const doc = new window.DOMParser().parseFromString(str, 'text/html');
461
- return doc.documentElement.textContent;
470
+ const elem = document.createElement('textarea');
471
+ elem.innerHTML = str;
472
+ return elem.value;
462
473
  }
463
474
  exports.unescapeHTML = unescapeHTML;
464
475
  /**
@@ -1814,9 +1814,6 @@ export default class Component extends Element {
1814
1814
  messages = _.uniqBy(messages, message => message.message);
1815
1815
  if (this.refs.messageContainer) {
1816
1816
  this.setContent(this.refs.messageContainer, messages.map((message) => {
1817
- if (message.message && typeof message.message === 'string') {
1818
- message.message = message.message.replaceAll('<', '&lt;').replaceAll('>', '&gt;');
1819
- }
1820
1817
  return this.renderTemplate('message', { ...message });
1821
1818
  }).join(''));
1822
1819
  }
@@ -3,7 +3,7 @@ import { Formio } from '../../Formio';
3
3
  import ListComponent from '../_classes/list/ListComponent';
4
4
  import Input from '../_classes/input/Input';
5
5
  import Form from '../../Form';
6
- import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, unescapeHTML, isSelectResourceWithObjectValue } from '../../utils/utils';
6
+ import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, unescapeHTML, isSelectResourceWithObjectValue, removeHTML } from '../../utils/utils';
7
7
  import Choices from '../../utils/ChoicesWrapper';
8
8
  export default class SelectComponent extends ListComponent {
9
9
  static schema(...extend) {
@@ -1551,7 +1551,7 @@ export default class SelectComponent extends ListComponent {
1551
1551
  const getTemplateValue = (v) => {
1552
1552
  const itemTemplate = this.itemTemplate(v);
1553
1553
  return options.csv && itemTemplate
1554
- ? unescapeHTML(itemTemplate)
1554
+ ? removeHTML(itemTemplate)
1555
1555
  : itemTemplate;
1556
1556
  };
1557
1557
  if (Array.isArray(value)) {
@@ -107,6 +107,12 @@ export function checkCondition(component: any, row: any, data: any, form: any, i
107
107
  */
108
108
  export function checkTrigger(component: any, trigger: any, row: any, data: any, form: any, instance: any): mixed;
109
109
  export function setActionProperty(component: any, action: any, result: any, row: any, data: any, instance: any): any;
110
+ /**
111
+ * Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
112
+ * @param {string} str
113
+ * @returns {string}
114
+ */
115
+ export function removeHTML(str: string): string;
110
116
  /**
111
117
  * Unescape HTML characters like &lt, &gt, &amp and etc.
112
118
  * @param str
@@ -395,6 +395,15 @@ export function setActionProperty(component, action, result, row, data, instance
395
395
  }
396
396
  return component;
397
397
  }
398
+ /**
399
+ * Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
400
+ * @param {string} str
401
+ * @returns {string}
402
+ */
403
+ export function removeHTML(str) {
404
+ const doc = new window.DOMParser().parseFromString(str, 'text/html');
405
+ return (doc.body.textContent || '').trim();
406
+ }
398
407
  /**
399
408
  * Unescape HTML characters like &lt, &gt, &amp and etc.
400
409
  * @param str
@@ -404,8 +413,9 @@ export function unescapeHTML(str) {
404
413
  if (typeof window === 'undefined' || !('DOMParser' in window)) {
405
414
  return str;
406
415
  }
407
- const doc = new window.DOMParser().parseFromString(str, 'text/html');
408
- return doc.documentElement.textContent;
416
+ const elem = document.createElement('textarea');
417
+ elem.innerHTML = str;
418
+ return elem.value;
409
419
  }
410
420
  /**
411
421
  * Make HTML element from string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5631.2d9a450",
3
+ "version": "5.0.0-dev.5632.8d1873d",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {