@formio/js 5.1.0-dev.6109.79f22ad → 5.1.0-dev.6112.86987a5

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.
Files changed (168) hide show
  1. package/README.md +7 -0
  2. package/dist/formio.builder.css +1 -0
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.form.css +1 -0
  5. package/dist/formio.form.js +116 -149
  6. package/dist/formio.form.min.css +1 -1
  7. package/dist/formio.form.min.js +1 -1
  8. package/dist/formio.full.css +1 -0
  9. package/dist/formio.full.js +123 -156
  10. package/dist/formio.full.min.css +1 -1
  11. package/dist/formio.full.min.js +1 -1
  12. package/dist/formio.js +65 -54
  13. package/dist/formio.min.js +1 -1
  14. package/dist/formio.utils.js +76 -76
  15. package/dist/formio.utils.min.js +1 -1
  16. package/lib/cjs/Element.d.ts +2 -1
  17. package/lib/cjs/Element.js +18 -39
  18. package/lib/cjs/EventEmitter.js +2 -25
  19. package/lib/cjs/Form.js +2 -25
  20. package/lib/cjs/PDF.js +1 -1
  21. package/lib/cjs/PDFBuilder.d.ts +1 -0
  22. package/lib/cjs/PDFBuilder.js +10 -11
  23. package/lib/cjs/Webform.d.ts +2 -2
  24. package/lib/cjs/Webform.js +9 -9
  25. package/lib/cjs/WebformBuilder.d.ts +1 -1
  26. package/lib/cjs/WebformBuilder.js +45 -21
  27. package/lib/cjs/Wizard.d.ts +1 -2
  28. package/lib/cjs/Wizard.js +18 -24
  29. package/lib/cjs/WizardBuilder.js +1 -1
  30. package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
  31. package/lib/cjs/components/_classes/component/Component.js +57 -62
  32. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  33. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  34. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
  35. package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
  36. package/lib/cjs/components/_classes/input/Input.js +3 -3
  37. package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
  38. package/lib/cjs/components/_classes/nested/NestedComponent.js +7 -7
  39. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  40. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  41. package/lib/cjs/components/address/Address.js +1 -1
  42. package/lib/cjs/components/alert/Alert.js +1 -1
  43. package/lib/cjs/components/button/Button.js +1 -1
  44. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  45. package/lib/cjs/components/container/Container.js +1 -1
  46. package/lib/cjs/components/currency/Currency.js +1 -1
  47. package/lib/cjs/components/datagrid/DataGrid.js +1 -1
  48. package/lib/cjs/components/datamap/DataMap.js +7 -2
  49. package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
  50. package/lib/cjs/components/datetime/DateTime.js +15 -13
  51. package/lib/cjs/components/day/Day.js +2 -2
  52. package/lib/cjs/components/editgrid/EditGrid.js +1 -1
  53. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  54. package/lib/cjs/components/fieldset/Fieldset.js +1 -0
  55. package/lib/cjs/components/file/File.js +1 -1
  56. package/lib/cjs/components/form/Form.js +14 -2
  57. package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
  58. package/lib/cjs/components/number/Number.js +1 -1
  59. package/lib/cjs/components/panel/Panel.js +1 -1
  60. package/lib/cjs/components/radio/Radio.d.ts +8 -0
  61. package/lib/cjs/components/radio/Radio.js +16 -6
  62. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  63. package/lib/cjs/components/select/Select.js +7 -3
  64. package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
  65. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  66. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  67. package/lib/cjs/components/signature/Signature.js +1 -1
  68. package/lib/cjs/components/survey/Survey.js +1 -1
  69. package/lib/cjs/components/tags/Tags.js +1 -1
  70. package/lib/cjs/components/textarea/TextArea.js +9 -4
  71. package/lib/cjs/components/textfield/TextField.js +13 -31
  72. package/lib/cjs/components/time/Time.js +1 -1
  73. package/lib/cjs/formio.form.js +5 -5
  74. package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
  75. package/lib/cjs/translations/en.d.ts +1 -232
  76. package/lib/cjs/translations/en.js +4 -2
  77. package/lib/cjs/utils/Evaluator.d.ts +20 -6
  78. package/lib/cjs/utils/Evaluator.js +38 -15
  79. package/lib/cjs/utils/builder.js +5 -5
  80. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  81. package/lib/cjs/utils/formUtils.d.ts +2 -2
  82. package/lib/cjs/utils/index.d.ts +169 -2
  83. package/lib/cjs/utils/index.js +22 -2
  84. package/lib/cjs/utils/utils.d.ts +22 -37
  85. package/lib/cjs/utils/utils.js +64 -135
  86. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
  87. package/lib/cjs/widgets/CalendarWidget.js +17 -43
  88. package/lib/mjs/Element.d.ts +2 -1
  89. package/lib/mjs/Element.js +11 -9
  90. package/lib/mjs/EventEmitter.js +2 -2
  91. package/lib/mjs/Form.js +1 -1
  92. package/lib/mjs/PDF.js +1 -1
  93. package/lib/mjs/PDFBuilder.d.ts +1 -0
  94. package/lib/mjs/PDFBuilder.js +9 -10
  95. package/lib/mjs/Webform.d.ts +2 -2
  96. package/lib/mjs/Webform.js +7 -7
  97. package/lib/mjs/WebformBuilder.d.ts +1 -1
  98. package/lib/mjs/WebformBuilder.js +36 -13
  99. package/lib/mjs/Wizard.d.ts +1 -2
  100. package/lib/mjs/Wizard.js +17 -23
  101. package/lib/mjs/WizardBuilder.js +1 -1
  102. package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
  103. package/lib/mjs/components/_classes/component/Component.js +30 -12
  104. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  105. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  106. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
  107. package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
  108. package/lib/mjs/components/_classes/input/Input.js +3 -3
  109. package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
  110. package/lib/mjs/components/_classes/nested/NestedComponent.js +7 -7
  111. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  112. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  113. package/lib/mjs/components/address/Address.js +1 -1
  114. package/lib/mjs/components/alert/Alert.js +1 -1
  115. package/lib/mjs/components/button/Button.js +1 -1
  116. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  117. package/lib/mjs/components/container/Container.js +1 -1
  118. package/lib/mjs/components/currency/Currency.js +1 -1
  119. package/lib/mjs/components/datagrid/DataGrid.js +1 -1
  120. package/lib/mjs/components/datamap/DataMap.js +7 -2
  121. package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
  122. package/lib/mjs/components/datetime/DateTime.js +15 -13
  123. package/lib/mjs/components/day/Day.js +2 -2
  124. package/lib/mjs/components/editgrid/EditGrid.js +1 -1
  125. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  126. package/lib/mjs/components/fieldset/Fieldset.js +1 -0
  127. package/lib/mjs/components/file/File.js +1 -1
  128. package/lib/mjs/components/form/Form.js +13 -2
  129. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
  130. package/lib/mjs/components/number/Number.js +1 -1
  131. package/lib/mjs/components/panel/Panel.js +1 -1
  132. package/lib/mjs/components/radio/Radio.d.ts +8 -0
  133. package/lib/mjs/components/radio/Radio.js +16 -6
  134. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  135. package/lib/mjs/components/select/Select.js +7 -3
  136. package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
  137. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  138. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  139. package/lib/mjs/components/signature/Signature.js +1 -1
  140. package/lib/mjs/components/survey/Survey.js +1 -1
  141. package/lib/mjs/components/tags/Tags.js +1 -1
  142. package/lib/mjs/components/textarea/TextArea.js +9 -4
  143. package/lib/mjs/components/textfield/TextField.js +7 -2
  144. package/lib/mjs/components/time/Time.js +1 -1
  145. package/lib/mjs/formio.form.js +3 -3
  146. package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
  147. package/lib/mjs/translations/en.d.ts +1 -232
  148. package/lib/mjs/translations/en.js +8 -47
  149. package/lib/mjs/utils/Evaluator.d.ts +20 -6
  150. package/lib/mjs/utils/Evaluator.js +31 -13
  151. package/lib/mjs/utils/builder.js +1 -1
  152. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  153. package/lib/mjs/utils/formUtils.d.ts +2 -2
  154. package/lib/mjs/utils/index.d.ts +169 -2
  155. package/lib/mjs/utils/index.js +18 -1
  156. package/lib/mjs/utils/utils.d.ts +22 -37
  157. package/lib/mjs/utils/utils.js +57 -109
  158. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
  159. package/lib/mjs/widgets/CalendarWidget.js +17 -43
  160. package/package.json +5 -3
  161. package/lib/cjs/i18n.d.ts +0 -13
  162. package/lib/cjs/i18n.js +0 -19
  163. package/lib/cjs/utils/i18n.d.ts +0 -19
  164. package/lib/cjs/utils/i18n.js +0 -120
  165. package/lib/mjs/i18n.d.ts +0 -13
  166. package/lib/mjs/i18n.js +0 -14
  167. package/lib/mjs/utils/i18n.d.ts +0 -19
  168. package/lib/mjs/utils/i18n.js +0 -112
@@ -17,7 +17,7 @@ export default class DateTimeComponent extends Input {
17
17
  };
18
18
  static savedValueTypes(schema: any): string[];
19
19
  get emptyValue(): string;
20
- get momentFormat(): string;
20
+ get dayjsFormat(): string;
21
21
  createWrapper(): boolean;
22
22
  checkValidity(data: any, dirty: any, rowData: any): boolean;
23
23
  getValueAsString(value: any, options: any): any;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
- const moment_1 = __importDefault(require("moment"));
7
+ const dayjs_1 = __importDefault(require("dayjs"));
8
8
  const utils_1 = __importDefault(require("../../utils"));
9
- const utils_2 = require("../../utils/utils");
9
+ const utils_2 = require("../../utils");
10
10
  const Input_1 = __importDefault(require("../_classes/input/Input"));
11
11
  class DateTimeComponent extends Input_1.default {
12
12
  static schema(...extend) {
@@ -123,8 +123,8 @@ class DateTimeComponent extends Input_1.default {
123
123
  get emptyValue() {
124
124
  return '';
125
125
  }
126
- get momentFormat() {
127
- return utils_1.default.convertFormatToMoment(this.component.format);
126
+ get dayjsFormat() {
127
+ return utils_1.default.convertFormatToDayjs(this.component.format);
128
128
  }
129
129
  isEmpty(value = this.dataValue) {
130
130
  if (value && (value.toString() === 'Invalid Date')) {
@@ -133,12 +133,14 @@ class DateTimeComponent extends Input_1.default {
133
133
  return super.isEmpty(value);
134
134
  }
135
135
  formatValue(input) {
136
- const result = moment_1.default.utc(input).toISOString();
137
- return result === 'Invalid date' ? input : result;
136
+ if ((0, dayjs_1.default)(input).isValid()) {
137
+ return dayjs_1.default.utc(input).toISOString();
138
+ }
139
+ return input;
138
140
  }
139
141
  isEqual(valueA, valueB = this.dataValue) {
140
142
  return (this.isEmpty(valueA) && this.isEmpty(valueB))
141
- || moment_1.default.utc(valueA).format(this.momentFormat) === moment_1.default.utc(valueB).format(this.momentFormat);
143
+ || dayjs_1.default.utc(valueA).format(this.dayjsFormat) === dayjs_1.default.utc(valueB).format(this.dayjsFormat);
142
144
  }
143
145
  createWrapper() {
144
146
  return false;
@@ -154,19 +156,19 @@ class DateTimeComponent extends Input_1.default {
154
156
  return super.checkValidity(data, dirty, rowData);
155
157
  }
156
158
  getValueAsString(value, options) {
157
- let format = utils_1.default.convertFormatToMoment(this.component.format);
158
- format += format.match(/z$/) ? '' : ' z';
159
+ let format = utils_1.default.convertFormatToDayjs(this.component.format);
159
160
  const timezone = this.timezone;
160
161
  if (value && !this.attached && timezone) {
162
+ format += format.match(/z$/) ? '' : ' z';
161
163
  if (Array.isArray(value) && this.component.multiple) {
162
- return value.map(item => lodash_1.default.trim(utils_1.default.momentDate(item, format, timezone, options).format(format))).join(', ');
164
+ return value.map(item => lodash_1.default.trim(utils_1.default.dayjsDate(item, format, timezone, options).format(format))).join(', ');
163
165
  }
164
- return lodash_1.default.trim(utils_1.default.momentDate(value, format, timezone, options).format(format));
166
+ return lodash_1.default.trim(utils_1.default.dayjsDate(value, format, timezone, options).format(format));
165
167
  }
166
168
  if (Array.isArray(value) && this.component.multiple) {
167
- return value.map(item => lodash_1.default.trim((0, moment_1.default)(item).format(format))).join(', ');
169
+ return value.map(item => lodash_1.default.trim((0, dayjs_1.default)(item).format(format))).join(', ');
168
170
  }
169
- return (value ? lodash_1.default.trim((0, moment_1.default)(value).format(format)) : value) || '';
171
+ return (value ? lodash_1.default.trim((0, dayjs_1.default)(value).format(format)) : value) || '';
170
172
  }
171
173
  }
172
174
  exports.default = DateTimeComponent;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  const Field_1 = __importDefault(require("../_classes/field/Field"));
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  const core_1 = require("@formio/core");
11
11
  class DayComponent extends Field_1.default {
12
12
  static schema(...extend) {
@@ -53,7 +53,7 @@ class DayComponent extends Field_1.default {
53
53
  return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
54
54
  }
55
55
  constructor(component, options, data) {
56
- if (!options.inFormBuilder && !options.building) {
56
+ if (options && !options.inFormBuilder && !options.building) {
57
57
  if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
58
  component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
59
59
  }
@@ -9,7 +9,7 @@ const components_1 = require("@formio/bootstrap/components");
9
9
  const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
10
10
  const Component_1 = __importDefault(require("../_classes/component/Component"));
11
11
  const Alert_1 = __importDefault(require("../alert/Alert"));
12
- const utils_1 = require("../../utils/utils");
12
+ const utils_1 = require("../../utils");
13
13
  const EditRowState = {
14
14
  New: 'new',
15
15
  Editing: 'editing',
@@ -35,7 +35,7 @@ exports.default = [
35
35
  weight: 1002,
36
36
  input: false,
37
37
  customConditional() {
38
- return !Evaluator_1.Evaluator.noeval;
38
+ return !Evaluator_1.Evaluator.noeval || !Evaluator_1.Evaluator.protectedEval;
39
39
  },
40
40
  },
41
41
  {
@@ -12,6 +12,7 @@ class FieldsetComponent extends NestedComponent_1.default {
12
12
  type: 'fieldset',
13
13
  legend: '',
14
14
  components: [],
15
+ clearOnHide: false,
15
16
  input: false,
16
17
  persistent: false
17
18
  }, ...extend);
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const Field_1 = __importDefault(require("../_classes/field/Field"));
16
- const utils_1 = require("../../utils/utils");
16
+ const utils_1 = require("../../utils");
17
17
  const downloadjs_1 = __importDefault(require("downloadjs"));
18
18
  const lodash_1 = __importDefault(require("lodash"));
19
19
  const fileProcessor_1 = __importDefault(require("../../providers/processor/fileProcessor"));
@@ -8,7 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
8
8
  const Component_1 = __importDefault(require("../_classes/component/Component"));
9
9
  const ComponentModal_1 = __importDefault(require("../_classes/componentModal/ComponentModal"));
10
10
  const eventemitter3_1 = __importDefault(require("eventemitter3"));
11
- const utils_1 = require("../../utils/utils");
11
+ const utils_1 = require("../../utils");
12
12
  const Formio_1 = require("../../Formio");
13
13
  const Form_1 = __importDefault(require("../../Form"));
14
14
  class FormComponent extends Component_1.default {
@@ -278,6 +278,9 @@ class FormComponent extends Component_1.default {
278
278
  if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
279
279
  this.createSubForm(true);
280
280
  }
281
+ if (!this.subFormReady) {
282
+ return Promise.resolve();
283
+ }
281
284
  return this.subFormReady.then(() => {
282
285
  this.empty(element);
283
286
  if (this.options.builder) {
@@ -408,13 +411,15 @@ class FormComponent extends Component_1.default {
408
411
  }
409
412
  // Render the form.
410
413
  return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
414
+ var _a, _b;
411
415
  this.subForm = instance;
412
416
  this.subForm.currentForm = this;
413
417
  this.subForm.parentVisible = this.visible;
414
418
  const componentsMap = this.componentsMap;
415
419
  const formComponentsMap = this.subForm.componentsMap;
416
420
  lodash_1.default.assign(componentsMap, formComponentsMap);
417
- this.component.components = this.subForm.components.map((comp) => comp.component);
421
+ this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
422
+ this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
418
423
  this.subForm.on('change', () => {
419
424
  if (this.subForm && !this.shouldConditionallyClear()) {
420
425
  this.dataValue = this.subForm.getValue();
@@ -699,6 +704,13 @@ class FormComponent extends Component_1.default {
699
704
  }
700
705
  return errors;
701
706
  }
707
+ conditionallyHidden() {
708
+ const conditionallyHidden = super.conditionallyHidden();
709
+ if (this.subForm) {
710
+ this.subForm._conditionallyHidden = conditionallyHidden;
711
+ }
712
+ return conditionallyHidden;
713
+ }
702
714
  updateSubFormVisibility() {
703
715
  if (this.subForm) {
704
716
  this.subForm.parentVisible = this.visible;
@@ -32,10 +32,11 @@ exports.default = [
32
32
  tooltip: 'if it is checked, the subform is loaded after navigation to the page with this component within the wizard.',
33
33
  input: true,
34
34
  customConditional({ instance, data }) {
35
- var _a, _b, _c, _d;
36
- const formInfo = (_b = (_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent('form')) === null || _b === void 0 ? void 0 : _b.defaultDownloadedResources.find(res => res._id === data.form);
35
+ var _a, _b, _c;
36
+ const formComp = (_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent('form');
37
+ const formInfo = formComp === null || formComp === void 0 ? void 0 : formComp.defaultDownloadedResources.find(res => res._id === data.form);
37
38
  const displayMode = 'wizard';
38
- return ((_d = (_c = instance.options) === null || _c === void 0 ? void 0 : _c.editForm) === null || _d === void 0 ? void 0 : _d.display) === displayMode && formInfo && formInfo.display !== displayMode;
39
+ return ((_c = (_b = instance.options) === null || _b === void 0 ? void 0 : _b.editForm) === null || _c === void 0 ? void 0 : _c.display) === displayMode && ((data.form && !formInfo) || (formInfo && formInfo.display !== displayMode));
39
40
  },
40
41
  },
41
42
  {
@@ -7,7 +7,7 @@ const text_mask_addons_1 = require("@formio/text-mask-addons");
7
7
  const vanilla_text_mask_1 = require("@formio/vanilla-text-mask");
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const Input_1 = __importDefault(require("../_classes/input/Input"));
10
- const utils_1 = require("../../utils/utils");
10
+ const utils_1 = require("../../utils/");
11
11
  class NumberComponent extends Input_1.default {
12
12
  static schema(...extend) {
13
13
  return Input_1.default.schema({
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const NestedComponent_1 = __importDefault(require("../_classes/nested/NestedComponent"));
7
- const utils_1 = require("../../utils/utils");
7
+ const utils_1 = require("../../utils");
8
8
  class PanelComponent extends NestedComponent_1.default {
9
9
  static schema(...extend) {
10
10
  return NestedComponent_1.default.schema({
@@ -28,6 +28,7 @@ export default class RadioComponent extends ListComponent {
28
28
  optionsLoaded: boolean | undefined;
29
29
  loadedOptions: any[] | undefined;
30
30
  beforeSubmit(): Promise<any>;
31
+ convertValues(values: any): any;
31
32
  render(): string;
32
33
  attach(element: any): Promise<void>;
33
34
  detach(element: any): void;
@@ -41,5 +42,12 @@ export default class RadioComponent extends ListComponent {
41
42
  setSelectedClasses(): void;
42
43
  updateValue(value: any, flags: any): boolean;
43
44
  currentValue: any;
45
+ /**
46
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
47
+ * @param {*} value - The value to normalize
48
+ * @returns {*} - Returns the normalized value
49
+ */
50
+ convertByDataType(value: any): any;
51
+ normalizeValue(value: any): any;
44
52
  }
45
53
  import ListComponent from '../_classes/list/ListComponent';
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
8
8
  const Formio_1 = require("../../Formio");
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  class RadioComponent extends ListComponent_1.default {
11
11
  static schema(...extend) {
12
12
  return ListComponent_1.default.schema({
@@ -153,6 +153,12 @@ class RadioComponent extends ListComponent_1.default {
153
153
  this.dataReady.then(() => res(true));
154
154
  });
155
155
  }
156
+ convertValues(values) {
157
+ if (this.options.renderMode === 'html' && this.type === 'radio') {
158
+ return values.map(x => (Object.assign(Object.assign({}, x), { value: this.convertByDataType(x.value) })));
159
+ }
160
+ return values;
161
+ }
156
162
  render() {
157
163
  if (!this.optionsLoaded) {
158
164
  return super.render(this.renderTemplate('loader'));
@@ -160,7 +166,7 @@ class RadioComponent extends ListComponent_1.default {
160
166
  return super.render(this.renderTemplate('radio', {
161
167
  input: this.inputInfo,
162
168
  inline: this.component.inline,
163
- values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
169
+ values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
164
170
  value: this.dataValue,
165
171
  row: this.row,
166
172
  }));
@@ -406,7 +412,7 @@ class RadioComponent extends ListComponent_1.default {
406
412
  * @param {*} value - The value to normalize
407
413
  * @returns {*} - Returns the normalized value
408
414
  */
409
- normalizeValue(value) {
415
+ convertByDataType(value) {
410
416
  const dataType = this.component.dataType || 'auto';
411
417
  if (value === this.emptyValue) {
412
418
  return value;
@@ -438,14 +444,18 @@ class RadioComponent extends ListComponent_1.default {
438
444
  value = !(!value || value.toString() === 'false');
439
445
  break;
440
446
  }
441
- if (this.isSelectURL && this.templateData && this.templateData[value]) {
447
+ return value;
448
+ }
449
+ normalizeValue(value) {
450
+ const valueConverted = this.convertByDataType(value);
451
+ if (this.isSelectURL && this.templateData && this.templateData[valueConverted]) {
442
452
  const submission = this.root.submission;
443
453
  if (!submission.metadata.selectData) {
444
454
  submission.metadata.selectData = {};
445
455
  }
446
- lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[value]);
456
+ lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
447
457
  }
448
- return super.normalizeValue(value);
458
+ return super.normalizeValue(valueConverted);
449
459
  }
450
460
  }
451
461
  exports.default = RadioComponent;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../../utils/utils");
3
+ const utils_1 = require("../../../utils");
4
4
  exports.default = [
5
5
  {
6
6
  key: 'recaptchaInfo',
@@ -7,7 +7,7 @@ const lodash_1 = __importDefault(require("lodash"));
7
7
  const Formio_1 = require("../../Formio");
8
8
  const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
9
9
  const Form_1 = __importDefault(require("../../Form"));
10
- const utils_1 = require("../../utils/utils");
10
+ const utils_1 = require("../../utils");
11
11
  const ChoicesWrapper_1 = __importDefault(require("../../utils/ChoicesWrapper"));
12
12
  class SelectComponent extends ListComponent_1.default {
13
13
  static schema(...extend) {
@@ -915,8 +915,9 @@ class SelectComponent extends ListComponent_1.default {
915
915
  });
916
916
  }
917
917
  // Add value options.
918
+ const value = this.undoValueTyping(this.dataValue);
918
919
  this.addValueOptions();
919
- this.setChoicesValue(this.dataValue);
920
+ this.setChoicesValue(value);
920
921
  if (this.isSelectResource && this.refs.addResource) {
921
922
  this.addEventListener(this.refs.addResource, 'click', (event) => {
922
923
  event.preventDefault();
@@ -1231,7 +1232,7 @@ class SelectComponent extends ListComponent_1.default {
1231
1232
  }
1232
1233
  lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
1233
1234
  }
1234
- if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission) && !this.options.readOnly) {
1235
+ if (flags.resetValue && !flags.fromSubmission && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission) && !this.options.readOnly) {
1235
1236
  const submission = this.root.submission;
1236
1237
  if (!submission.metadata) {
1237
1238
  submission.metadata = {};
@@ -1295,6 +1296,9 @@ class SelectComponent extends ListComponent_1.default {
1295
1296
  this.lazyLoadInit = true;
1296
1297
  const searchProperty = this.component.searchField || this.component.valueProperty;
1297
1298
  this.triggerUpdate(lodash_1.default.get(value.data || value, searchProperty, value), true);
1299
+ this.itemsLoaded.then(() => {
1300
+ this.setChoicesValue(value, hasPreviousValue, flags);
1301
+ });
1298
1302
  return changed;
1299
1303
  }
1300
1304
  // Add the value options.
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
- const utils_1 = require("../../../utils/utils");
7
+ const utils_1 = require("../../../utils");
8
8
  const calculateSingleSelectData = (context, defaultValue) => {
9
9
  const { instance, data } = context;
10
10
  const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) === defaultValue);
@@ -8,6 +8,12 @@ export default class SelectBoxesComponent extends RadioComponent {
8
8
  * @returns {boolean} - If the value is empty.
9
9
  */
10
10
  isEmpty(value?: any): boolean;
11
+ /**
12
+ * Normalize values coming into updateValue.
13
+ * @param {any} value - The value to normalize.
14
+ * @returns {*} - The normalized value
15
+ */
16
+ normalizeValue(value: any): any;
11
17
  setInputsDisabled(value: any, onlyUnchecked: any): void;
12
18
  checkComponentValidity(data: any, dirty: any, rowData: any, options: any, errors?: any[]): boolean;
13
19
  }
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
- const utils_1 = require("../../utils/utils");
7
+ const utils_1 = require("../../utils");
8
8
  const Radio_1 = __importDefault(require("../radio/Radio"));
9
9
  class SelectBoxesComponent extends Radio_1.default {
10
10
  static schema(...extend) {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const signature_pad_1 = __importDefault(require("signature_pad"));
7
7
  const Input_1 = __importDefault(require("../_classes/input/Input"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  class SignatureComponent extends Input_1.default {
11
11
  static schema(...extend) {
12
12
  return Input_1.default.schema({
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const Field_1 = __importDefault(require("../_classes/field/Field"));
8
- const utils_1 = require("../../utils/utils");
8
+ const utils_1 = require("../../utils");
9
9
  class SurveyComponent extends Field_1.default {
10
10
  static schema(...extend) {
11
11
  return Field_1.default.schema({
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const utils_1 = require("../../utils/utils");
6
+ const utils_1 = require("../../utils");
7
7
  const Input_1 = __importDefault(require("../_classes/input/Input"));
8
8
  const choices_js_1 = __importDefault(require("choices.js"));
9
9
  class TagsComponent extends Input_1.default {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* global Quill */
7
7
  const TextField_1 = __importDefault(require("../textfield/TextField"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  class TextAreaComponent extends TextField_1.default {
11
11
  static schema(...extend) {
12
12
  return TextField_1.default.schema({
@@ -63,8 +63,8 @@ class TextAreaComponent extends TextField_1.default {
63
63
  if ((this.options.readOnly || this.disabled) && !this.isHtmlRenderMode()) {
64
64
  const elementStyle = this.info.attr.style || '';
65
65
  const children = `
66
- <div ${this._referenceAttributeName}="input"
67
- class="formio-editor-read-only-content"
66
+ <div ${this._referenceAttributeName}="input"
67
+ class="formio-editor-read-only-content"
68
68
  ${elementStyle ? `style='${elementStyle}'` : ''}
69
69
  role="textbox"
70
70
  aria-multiline="true"
@@ -193,7 +193,12 @@ class TextAreaComponent extends TextField_1.default {
193
193
  const editorHeight = (numRows * 31) + 14;
194
194
  editor.ui.view.editable.editableElement.style.height = `${(editorHeight)}px`;
195
195
  }
196
- editor.isReadOnly = isReadOnly;
196
+ if (isReadOnly) {
197
+ editor.enableReadOnlyMode(this.id);
198
+ }
199
+ else {
200
+ editor.disableReadOnlyMode(this.id);
201
+ }
197
202
  editor.data.set(value);
198
203
  }
199
204
  editorReady(editor);
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
@@ -29,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
6
  const Input_1 = __importDefault(require("../_classes/input/Input"));
30
7
  const vanilla_text_mask_1 = require("@formio/vanilla-text-mask");
31
8
  const inputmask_1 = __importDefault(require("inputmask"));
32
- const FormioUtils = __importStar(require("../../utils/utils"));
9
+ const utils_1 = __importDefault(require("../../utils"));
33
10
  const lodash_1 = __importDefault(require("lodash"));
34
11
  class TextFieldComponent extends Input_1.default {
35
12
  static schema(...extend) {
@@ -71,7 +48,7 @@ class TextFieldComponent extends Input_1.default {
71
48
  } });
72
49
  }
73
50
  static savedValueTypes(schema) {
74
- return FormioUtils.getComponentSavedTypes(schema) || [FormioUtils.componentValueTypes.string];
51
+ return utils_1.default.getComponentSavedTypes(schema) || [utils_1.default.componentValueTypes.string];
75
52
  }
76
53
  get defaultSchema() {
77
54
  return TextFieldComponent.schema();
@@ -104,7 +81,7 @@ class TextFieldComponent extends Input_1.default {
104
81
  displayInTimezone, locale: this.component.widget.locale || this.options.language, saveAs: 'text' });
105
82
  // update originalComponent to include widget settings after component initialization
106
83
  // originalComponent is used to restore the component (and widget) after evaluating field logic
107
- this.originalComponent = FormioUtils.fastCloneDeep(this.component);
84
+ this.originalComponent = utils_1.default.fastCloneDeep(this.component);
108
85
  }
109
86
  }
110
87
  attach(element) {
@@ -130,7 +107,12 @@ class TextFieldComponent extends Input_1.default {
130
107
  // If no value is provided, then set the defaultValue.
131
108
  if (!value.value) {
132
109
  const defaultValue = flags.noDefault ? this.emptyValue : this.defaultValue;
133
- value.value = Array.isArray(defaultValue) ? defaultValue[0] : defaultValue;
110
+ if (Array.isArray(defaultValue)) {
111
+ value.value = lodash_1.default.isObject(defaultValue[0]) ? defaultValue[0].value : defaultValue;
112
+ }
113
+ else {
114
+ value.value = lodash_1.default.isObject(defaultValue) ? defaultValue.value : defaultValue;
115
+ }
134
116
  }
135
117
  return value;
136
118
  }
@@ -175,7 +157,7 @@ class TextFieldComponent extends Input_1.default {
175
157
  }
176
158
  else {
177
159
  const placeholderChar = this.placeholderChar;
178
- textInput.value = (0, vanilla_text_mask_1.conformToMask)(textValue, FormioUtils.getInputMask(mask), { placeholderChar }).conformedValue;
160
+ textInput.value = (0, vanilla_text_mask_1.conformToMask)(textValue, utils_1.default.getInputMask(mask), { placeholderChar }).conformedValue;
179
161
  }
180
162
  }
181
163
  else {
@@ -183,8 +165,8 @@ class TextFieldComponent extends Input_1.default {
183
165
  }
184
166
  }
185
167
  unmaskValue(value, format = this.component.displayMask) {
186
- const mask = FormioUtils.getInputMask(format, this.placeholderChar);
187
- return FormioUtils.unmaskValue(value, mask, this.placeholderChar);
168
+ const mask = utils_1.default.getInputMask(format, this.placeholderChar);
169
+ return utils_1.default.unmaskValue(value, mask, this.placeholderChar);
188
170
  }
189
171
  /**
190
172
  * Returns the value at this index.
@@ -245,7 +227,7 @@ class TextFieldComponent extends Input_1.default {
245
227
  return;
246
228
  }
247
229
  inputMask = inputMask || this.component.displayMask || this.component.inputMask;
248
- const mask = FormioUtils.getInputMask(inputMask, this.placeholderChar);
230
+ const mask = utils_1.default.getInputMask(inputMask, this.placeholderChar);
249
231
  this.defaultMask = mask;
250
232
  if (input && inputMask) {
251
233
  try {
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const moment_1 = __importDefault(require("moment"));
7
7
  const TextField_1 = __importDefault(require("../textfield/TextField"));
8
- const utils_1 = require("../../utils/utils");
8
+ const utils_1 = require("../../utils");
9
9
  const defaultDataFormat = 'HH:mm:ss';
10
10
  class TimeComponent extends TextField_1.default {
11
11
  static schema(...extend) {
@@ -22,14 +22,14 @@ const Form_1 = __importDefault(require("./Form"));
22
22
  exports.Form = Form_1.default;
23
23
  const utils_1 = __importDefault(require("./utils"));
24
24
  exports.Utils = utils_1.default;
25
- const Evaluator_1 = require("./utils/Evaluator");
26
25
  const licenses_1 = __importDefault(require("./licenses"));
27
26
  exports.Licenses = licenses_1.default;
28
27
  const EventEmitter_1 = __importDefault(require("./EventEmitter"));
29
28
  exports.EventEmitter = EventEmitter_1.default;
30
29
  const Webform_1 = __importDefault(require("./Webform"));
31
30
  exports.Webform = Webform_1.default;
32
- const i18n_1 = require("./utils/i18n");
31
+ const core_1 = require("@formio/core");
32
+ const utils_2 = require("./utils");
33
33
  Formio_1.Formio.loadModules = (path = `${Formio_1.Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
34
34
  Formio_1.Formio.requireLibrary(name, name, path, true)
35
35
  .then((modules) => {
@@ -45,7 +45,7 @@ Formio_1.Formio.Form = Form_1.default;
45
45
  Formio_1.Formio.Displays = Displays_1.default;
46
46
  Formio_1.Formio.Providers = providers_1.default;
47
47
  Formio_1.Formio.Widgets = widgets_1.default;
48
- Formio_1.Formio.Evaluator = Evaluator_1.Evaluator;
48
+ Formio_1.Formio.Evaluator = utils_2.Evaluator;
49
49
  Formio_1.Formio.AllComponents = components_1.default;
50
50
  Formio_1.Formio.Licenses = licenses_1.default;
51
51
  // This is strange, but is needed for "premium" components to import correctly.
@@ -100,10 +100,10 @@ function registerModule(mod, defaultFn = null, options = {}) {
100
100
  Formio_1.Formio.Displays.addDisplays(mod.displays);
101
101
  break;
102
102
  case 'evaluator':
103
- Formio_1.Formio.Evaluator.registerEvaluator(mod.evaluator);
103
+ (0, utils_2.registerEvaluator)(mod.evaluator);
104
104
  break;
105
105
  case 'translations':
106
- i18n_1.I18n.setDefaultTranslations(mod.translations);
106
+ core_1.I18n.setDefaultTranslations(mod.translations);
107
107
  break;
108
108
  case 'library':
109
109
  options.license
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFormioUploadAdapterPlugin = void 0;
4
- const utils_1 = require("../../utils/utils");
4
+ const utils_1 = require("../../utils");
5
5
  /**
6
6
  * UploadAdapter for CKEditor https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/upload-adapter.html
7
7
  */