@formio/js 5.1.0-dev.6115.a496b38 → 5.1.0-dev.6126.7fb6eb6

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 (141) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.form.js +113 -124
  4. package/dist/formio.form.min.js +1 -1
  5. package/dist/formio.full.js +120 -131
  6. package/dist/formio.full.min.js +1 -1
  7. package/dist/formio.js +62 -51
  8. package/dist/formio.min.js +1 -1
  9. package/dist/formio.utils.js +72 -72
  10. package/dist/formio.utils.min.js +1 -1
  11. package/lib/cjs/Element.js +13 -36
  12. package/lib/cjs/Embed.js +9 -1
  13. package/lib/cjs/EventEmitter.js +2 -25
  14. package/lib/cjs/Form.js +2 -25
  15. package/lib/cjs/PDF.js +1 -1
  16. package/lib/cjs/PDFBuilder.js +4 -5
  17. package/lib/cjs/Webform.js +5 -6
  18. package/lib/cjs/WebformBuilder.js +9 -10
  19. package/lib/cjs/Wizard.js +1 -1
  20. package/lib/cjs/WizardBuilder.js +1 -1
  21. package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
  22. package/lib/cjs/components/_classes/component/Component.js +33 -54
  23. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  24. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  25. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
  26. package/lib/cjs/components/_classes/input/Input.js +1 -1
  27. package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
  28. package/lib/cjs/components/_classes/nested/NestedComponent.js +6 -6
  29. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  30. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  31. package/lib/cjs/components/address/Address.js +1 -1
  32. package/lib/cjs/components/alert/Alert.js +1 -1
  33. package/lib/cjs/components/button/Button.d.ts +1 -1
  34. package/lib/cjs/components/button/Button.js +4 -4
  35. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  36. package/lib/cjs/components/container/Container.js +1 -1
  37. package/lib/cjs/components/currency/Currency.js +1 -1
  38. package/lib/cjs/components/datagrid/DataGrid.js +1 -1
  39. package/lib/cjs/components/datamap/DataMap.d.ts +1 -1
  40. package/lib/cjs/components/datamap/DataMap.js +4 -4
  41. package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
  42. package/lib/cjs/components/datetime/DateTime.js +15 -13
  43. package/lib/cjs/components/day/Day.js +1 -1
  44. package/lib/cjs/components/editgrid/EditGrid.js +1 -1
  45. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  46. package/lib/cjs/components/file/File.js +1 -1
  47. package/lib/cjs/components/form/Form.js +1 -1
  48. package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
  49. package/lib/cjs/components/number/Number.js +1 -1
  50. package/lib/cjs/components/panel/Panel.js +1 -1
  51. package/lib/cjs/components/radio/Radio.js +1 -1
  52. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  53. package/lib/cjs/components/select/Select.js +1 -1
  54. package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
  55. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  56. package/lib/cjs/components/signature/Signature.js +1 -1
  57. package/lib/cjs/components/survey/Survey.js +1 -1
  58. package/lib/cjs/components/tags/Tags.js +1 -1
  59. package/lib/cjs/components/textarea/TextArea.js +3 -3
  60. package/lib/cjs/components/textfield/TextField.js +7 -30
  61. package/lib/cjs/components/time/Time.js +1 -1
  62. package/lib/cjs/formio.form.js +3 -3
  63. package/lib/cjs/i18n.js +1 -1
  64. package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
  65. package/lib/cjs/utils/Evaluator.d.ts +13 -6
  66. package/lib/cjs/utils/Evaluator.js +27 -15
  67. package/lib/cjs/utils/builder.js +5 -5
  68. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  69. package/lib/cjs/utils/i18n.js +3 -3
  70. package/lib/cjs/utils/index.d.ts +161 -2
  71. package/lib/cjs/utils/index.js +12 -2
  72. package/lib/cjs/utils/utils.d.ts +18 -33
  73. package/lib/cjs/utils/utils.js +52 -130
  74. package/lib/cjs/widgets/CalendarWidget.d.ts +0 -7
  75. package/lib/cjs/widgets/CalendarWidget.js +15 -39
  76. package/lib/mjs/Element.js +6 -6
  77. package/lib/mjs/Embed.js +9 -1
  78. package/lib/mjs/EventEmitter.js +2 -2
  79. package/lib/mjs/Form.js +1 -1
  80. package/lib/mjs/PDF.js +1 -1
  81. package/lib/mjs/PDFBuilder.js +1 -2
  82. package/lib/mjs/Webform.js +3 -4
  83. package/lib/mjs/WebformBuilder.js +1 -2
  84. package/lib/mjs/Wizard.js +1 -1
  85. package/lib/mjs/WizardBuilder.js +1 -1
  86. package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
  87. package/lib/mjs/components/_classes/component/Component.js +6 -4
  88. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  89. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  90. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
  91. package/lib/mjs/components/_classes/input/Input.js +1 -1
  92. package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
  93. package/lib/mjs/components/_classes/nested/NestedComponent.js +6 -6
  94. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  95. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  96. package/lib/mjs/components/address/Address.js +1 -1
  97. package/lib/mjs/components/alert/Alert.js +1 -1
  98. package/lib/mjs/components/button/Button.d.ts +1 -1
  99. package/lib/mjs/components/button/Button.js +1 -1
  100. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  101. package/lib/mjs/components/container/Container.js +1 -1
  102. package/lib/mjs/components/currency/Currency.js +1 -1
  103. package/lib/mjs/components/datagrid/DataGrid.js +1 -1
  104. package/lib/mjs/components/datamap/DataMap.d.ts +1 -1
  105. package/lib/mjs/components/datamap/DataMap.js +1 -1
  106. package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
  107. package/lib/mjs/components/datetime/DateTime.js +15 -13
  108. package/lib/mjs/components/day/Day.js +1 -1
  109. package/lib/mjs/components/editgrid/EditGrid.js +1 -1
  110. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  111. package/lib/mjs/components/file/File.js +1 -1
  112. package/lib/mjs/components/form/Form.js +1 -1
  113. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
  114. package/lib/mjs/components/number/Number.js +1 -1
  115. package/lib/mjs/components/panel/Panel.js +1 -1
  116. package/lib/mjs/components/radio/Radio.js +1 -1
  117. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  118. package/lib/mjs/components/select/Select.js +1 -1
  119. package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
  120. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  121. package/lib/mjs/components/signature/Signature.js +1 -1
  122. package/lib/mjs/components/survey/Survey.js +1 -1
  123. package/lib/mjs/components/tags/Tags.js +1 -1
  124. package/lib/mjs/components/textarea/TextArea.js +3 -3
  125. package/lib/mjs/components/textfield/TextField.js +1 -1
  126. package/lib/mjs/components/time/Time.js +1 -1
  127. package/lib/mjs/formio.form.js +2 -2
  128. package/lib/mjs/i18n.js +1 -1
  129. package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
  130. package/lib/mjs/utils/Evaluator.d.ts +13 -6
  131. package/lib/mjs/utils/Evaluator.js +21 -13
  132. package/lib/mjs/utils/builder.js +1 -1
  133. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  134. package/lib/mjs/utils/i18n.js +1 -1
  135. package/lib/mjs/utils/index.d.ts +161 -2
  136. package/lib/mjs/utils/index.js +11 -1
  137. package/lib/mjs/utils/utils.d.ts +18 -33
  138. package/lib/mjs/utils/utils.js +45 -105
  139. package/lib/mjs/widgets/CalendarWidget.d.ts +0 -7
  140. package/lib/mjs/widgets/CalendarWidget.js +15 -39
  141. package/package.json +3 -2
@@ -3,11 +3,11 @@ 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 Formio_1 = require("../Formio");
7
- const InputWidget_1 = __importDefault(require("./InputWidget"));
8
- const utils_1 = require("../utils/utils");
9
6
  const moment_1 = __importDefault(require("moment"));
10
7
  const lodash_1 = __importDefault(require("lodash"));
8
+ const Formio_1 = require("../Formio");
9
+ const InputWidget_1 = __importDefault(require("./InputWidget"));
10
+ const utils_1 = require("../utils");
11
11
  const DEFAULT_FORMAT = 'yyyy-MM-dd hh:mm a';
12
12
  const ISO_8601_FORMAT = 'yyyy-MM-ddTHH:mm:ssZ';
13
13
  const isIEBrowser = (0, utils_1.getBrowserInfo)().ie;
@@ -51,29 +51,6 @@ class CalendarWidget extends InputWidget_1.default {
51
51
  else if (this.settings.time_24hr) {
52
52
  this.settings.format = this.settings.format.replace(/hh:mm a$/g, 'HH:mm');
53
53
  }
54
- this.zoneLoading = false;
55
- this.timezonesUrl = `${Formio_1.Formio.cdn['moment-timezone']}/data/packed/latest.json`;
56
- }
57
- /**
58
- * Load the timezones.
59
- * @returns {boolean} TRUE if the zones are loading, FALSE otherwise.
60
- */
61
- loadZones() {
62
- const timezone = this.timezone;
63
- if (this.zoneLoading) {
64
- return true;
65
- }
66
- if (!(0, utils_1.zonesLoaded)() && (0, utils_1.shouldLoadZones)(timezone)) {
67
- this.zoneLoading = true;
68
- (0, utils_1.loadZones)(this.timezonesUrl, timezone).then(() => {
69
- this.zoneLoading = false;
70
- this.emit('redraw');
71
- });
72
- // Return zones are loading.
73
- return true;
74
- }
75
- // Zones are already loaded.
76
- return false;
77
54
  }
78
55
  attach(input) {
79
56
  var _a;
@@ -85,7 +62,7 @@ class CalendarWidget extends InputWidget_1.default {
85
62
  };
86
63
  this.closedOn = 0;
87
64
  this.valueFormat = (this.settings.saveAs === 'date') ? ISO_8601_FORMAT : this.settings.dateFormat || ISO_8601_FORMAT;
88
- this.valueMomentFormat = (0, utils_1.convertFormatToMoment)(this.valueFormat);
65
+ this.valueMomentFormat = (0, utils_1.convertFormatToDayjs)(this.valueFormat);
89
66
  const isReadOnly = this.settings.readOnly;
90
67
  this.settings.minDate = isReadOnly ? null : (0, utils_1.getDateSetting)(this.settings.minDate);
91
68
  this.settings.maxDate = isReadOnly ? null : (0, utils_1.getDateSetting)(this.settings.maxDate);
@@ -249,9 +226,9 @@ class CalendarWidget extends InputWidget_1.default {
249
226
  */
250
227
  getDateValue(date, format, useTimezone) {
251
228
  if (useTimezone) {
252
- return (0, utils_1.momentDate)(date, this.valueFormat, this.timezone).format((0, utils_1.convertFormatToMoment)(format));
229
+ return (0, utils_1.dayjsDate)(date, this.valueFormat, this.timezone).format((0, utils_1.convertFormatToDayjs)(format));
253
230
  }
254
- return (0, moment_1.default)(date).format((0, utils_1.convertFormatToMoment)(format));
231
+ return (0, moment_1.default)(date).format((0, utils_1.convertFormatToDayjs)(format));
255
232
  }
256
233
  /**
257
234
  * Return the value of the selected date.
@@ -283,7 +260,7 @@ class CalendarWidget extends InputWidget_1.default {
283
260
  setValue(value) {
284
261
  const saveAsText = (this.settings.saveAs === 'text');
285
262
  if (!this.calendar) {
286
- value = value ? (0, utils_1.formatDate)(this.timezonesUrl, value, (0, utils_1.convertFormatToMoment)(this.settings.format), this.timezone, (0, utils_1.convertFormatToMoment)(this.valueMomentFormat)) : value;
263
+ value = value ? (0, utils_1.formatDate)(value, (0, utils_1.convertFormatToDayjs)(this.settings.format), this.timezone, (0, utils_1.convertFormatToDayjs)(this.valueMomentFormat)) : value;
287
264
  return super.setValue(value);
288
265
  }
289
266
  // If the component is a textfield that does not have timezone information included in the string value then skip
@@ -291,10 +268,9 @@ class CalendarWidget extends InputWidget_1.default {
291
268
  if (this.component.type === 'textfield' && !(0, utils_1.hasEncodedTimezone)(value)) {
292
269
  this.settings.skipOffset = true;
293
270
  }
294
- const zonesLoading = this.loadZones();
295
271
  if (value) {
296
- if (!saveAsText && this.settings.readOnly && !zonesLoading) {
297
- this.calendar.setDate((0, utils_1.momentDate)(value, this.valueFormat, this.timezone).format(), false);
272
+ if (!saveAsText && this.settings.readOnly) {
273
+ this.calendar.setDate((0, utils_1.dayjsDate)(value, this.valueFormat, this.timezone).format(), false);
298
274
  }
299
275
  else if (this.isValueISO8601(value)) {
300
276
  this.calendar.setDate(value, false);
@@ -311,9 +287,9 @@ class CalendarWidget extends InputWidget_1.default {
311
287
  const inputFormat = format || this.dateFormat;
312
288
  const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
313
289
  if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
314
- return (0, moment_1.default)(value, (0, utils_1.convertFormatToMoment)(valueFormat)).format((0, utils_1.convertFormatToMoment)(valueFormat));
290
+ return (0, moment_1.default)(value, (0, utils_1.convertFormatToDayjs)(valueFormat)).format((0, utils_1.convertFormatToDayjs)(valueFormat));
315
291
  }
316
- return (0, utils_1.formatDate)(this.timezonesUrl, value, inputFormat, this.timezone, (0, utils_1.convertFormatToMoment)(valueFormat));
292
+ return (0, utils_1.formatDate)(value, inputFormat, this.timezone, (0, utils_1.convertFormatToDayjs)(valueFormat));
317
293
  }
318
294
  setErrorClasses(hasErrors) {
319
295
  if (!this.input) {
@@ -406,7 +382,7 @@ class CalendarWidget extends InputWidget_1.default {
406
382
  const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
407
383
  if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
408
384
  const inputValue = this.calendar.input.value;
409
- const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.convertFormatToMoment)(this.valueFormat)).toDate() : inputValue;
385
+ const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.convertFormatToDayjs)(this.valueFormat)).toDate() : inputValue;
410
386
  this.calendar.setDate(dateValue, true, this.settings.altFormat);
411
387
  }
412
388
  else if (!this.calendar.input.value && this.calendar.config.noCalendar) {
@@ -458,14 +434,14 @@ class CalendarWidget extends InputWidget_1.default {
458
434
  return (date, format) => {
459
435
  // Only format this if this is the altFormat and the form is readOnly.
460
436
  if (this.settings.readOnly && (format === this.settings.altFormat)) {
461
- if (!this.settings.enableTime || this.loadZones() || this.settings.skipOffset) {
437
+ if (!this.settings.enableTime || this.settings.skipOffset) {
462
438
  return Flatpickr.formatDate(date, format);
463
439
  }
464
440
  const currentValue = new Date(this.getValue());
465
441
  if (currentValue.toString() === date.toString()) {
466
- return (0, utils_1.formatOffset)(this.timezonesUrl, Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
442
+ return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
467
443
  }
468
- return (0, utils_1.formatOffset)(this.timezonesUrl, Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
444
+ return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
469
445
  }
470
446
  return Flatpickr.formatDate(date, format);
471
447
  };
@@ -1,10 +1,10 @@
1
- import EventEmitter from './EventEmitter';
2
- import { Formio } from './Formio';
3
- import * as FormioUtils from './utils/utils';
4
- import { I18n } from './utils/i18n';
5
1
  import _ from 'lodash';
6
2
  import moment from 'moment';
7
3
  import maskInput from '@formio/vanilla-text-mask';
4
+ import EventEmitter from './EventEmitter';
5
+ import { Formio } from './Formio';
6
+ import { I18n } from './utils/i18n';
7
+ import FormioUtils from './utils';
8
8
  /**
9
9
  * The root component for all elements within the Form.io renderer.
10
10
  */
@@ -523,9 +523,9 @@ export default class Element {
523
523
  if (this.component.filter === string && !this.options.building) {
524
524
  const evalContext = this.evalContext(data);
525
525
  evalContext.data = _.mapValues(evalContext.data, (val) => _.isString(val) ? encodeURIComponent(val) : val);
526
- return FormioUtils.interpolate(string, evalContext, options);
526
+ return FormioUtils.Evaluator.interpolate(string, evalContext, options);
527
527
  }
528
- return FormioUtils.interpolate(string, this.evalContext(data), options);
528
+ return FormioUtils.Evaluator.interpolate(string, this.evalContext(data), options);
529
529
  }
530
530
  /**
531
531
  * Performs an evaluation using the evaluation context of this component.
package/lib/mjs/Embed.js CHANGED
@@ -270,7 +270,7 @@ export class Formio {
270
270
  src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),
271
271
  url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");
272
272
  }`
273
- }
273
+ },
274
274
  };
275
275
  // Add all bootswatch templates.
276
276
  ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {
@@ -338,6 +338,14 @@ export class Formio {
338
338
  }
339
339
  }
340
340
  await Formio.addStyles(libWrapper, Formio.formioScript(Formio.config.style || `${Formio.cdn.js}/${renderer}.css`, builder));
341
+ // In some cases (dropdown list of autocomplete or confirmation popup of skethpad) we render elements outside of shadow dom
342
+ // and as result we can't get access to this styles outside of shadow dom. Here i added needed styles to work it properly
343
+ if (useShadowDom) {
344
+ await Formio.addStyles(document.body, Formio.formioScript(Formio.config.style || `${Formio.cdn.js}/${renderer}.css`, builder));
345
+ const toGlobalStyleLibs = ["bootstrap", "bootstrap4", "bootstrap-icons"];
346
+ const libHrefs = toGlobalStyleLibs.map(key => Formio.config.libs[key]).filter(Boolean).map(href => href.css);
347
+ await Formio.addStyles(document.body, libHrefs, builder);
348
+ }
341
349
  if (Formio.config.before) {
342
350
  await Formio.config.before(Formio.FormioClass, element, Formio.config);
343
351
  }
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter as EventEmitter3 } from 'eventemitter3';
2
- import * as utils from './utils/utils';
2
+ import { observeOverload } from './utils';
3
3
  export default class EventEmitter extends EventEmitter3 {
4
4
  constructor(conf = {}) {
5
5
  const { loadLimit = 1000, eventsSafeInterval = 300 } = conf;
@@ -7,7 +7,7 @@ export default class EventEmitter extends EventEmitter3 {
7
7
  const overloadHandler = () => {
8
8
  console.warn(`There were more than ${loadLimit} events emitted in ${eventsSafeInterval} ms. It might be caused by events' infinite loop`, this.id);
9
9
  };
10
- const dispatch = utils.observeOverload(overloadHandler, {
10
+ const dispatch = observeOverload(overloadHandler, {
11
11
  limit: loadLimit,
12
12
  delay: eventsSafeInterval
13
13
  });
package/lib/mjs/Form.js CHANGED
@@ -2,7 +2,7 @@ import Element from './Element';
2
2
  import { Formio } from './Formio';
3
3
  import Displays from './displays';
4
4
  import templates from './templates';
5
- import * as FormioUtils from './utils/utils';
5
+ import FormioUtils from './utils';
6
6
  export default class Form extends Element {
7
7
  /**
8
8
  * Represents a JSON value.
package/lib/mjs/PDF.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Formio } from './Formio';
2
2
  import Webform from './Webform';
3
- import { fastCloneDeep, eachComponent } from './utils/utils';
3
+ import { fastCloneDeep, eachComponent } from './utils';
4
4
  export default class PDF extends Webform {
5
5
  constructor(element, options) {
6
6
  options.display = 'pdf';
@@ -1,8 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import { Formio } from './Formio';
3
3
  import WebformBuilder from './WebformBuilder';
4
- import { fastCloneDeep, getElementRect, getBrowserInfo } from './utils/utils';
5
- import { eachComponent } from './utils/formUtils';
4
+ import { fastCloneDeep, getElementRect, getBrowserInfo, eachComponent } from './utils';
6
5
  import BuilderUtils from './utils/builder';
7
6
  import PDF from './PDF';
8
7
  export default class PDFBuilder extends WebformBuilder {
@@ -1,13 +1,12 @@
1
1
  import _ from 'lodash';
2
- import moment from 'moment';
3
2
  import { compareVersions } from 'compare-versions';
4
3
  import EventEmitter from './EventEmitter';
5
4
  import i18nDefaults from './i18n';
6
5
  import { Formio } from './Formio';
7
6
  import Components from './components/Components';
8
7
  import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
9
- import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from './utils/utils';
10
- import { eachComponent } from './utils/formUtils';
8
+ import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, eachComponent } from './utils';
9
+ import dayjs from "dayjs";
11
10
  // We need this here because dragula pulls in CustomEvent class that requires global to exist.
12
11
  if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
13
12
  window.global = window;
@@ -1317,7 +1316,7 @@ export default class Webform extends NestedDataComponent {
1317
1316
  submission.metadata = submission.metadata || {};
1318
1317
  _.defaults(submission.metadata, {
1319
1318
  timezone: _.get(this, '_submission.metadata.timezone', currentTimezone()),
1320
- offset: parseInt(_.get(this, '_submission.metadata.offset', moment().utcOffset()), 10),
1319
+ offset: parseInt(_.get(this, '_submission.metadata.offset', dayjs().utcOffset()), 10),
1321
1320
  origin: document.location.origin,
1322
1321
  referrer: document.referrer,
1323
1322
  browserName: navigator.appName,
@@ -3,8 +3,7 @@ import Component from './components/_classes/component/Component';
3
3
  import tippy from 'tippy.js';
4
4
  import Components from './components/Components';
5
5
  import { Formio } from './Formio';
6
- import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath } from './utils/utils';
7
- import { eachComponent, getComponent } from './utils/formUtils';
6
+ import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, } from './utils';
8
7
  import BuilderUtils from './utils/builder';
9
8
  import _ from 'lodash';
10
9
  import autoScroll from 'dom-autoscroller';
package/lib/mjs/Wizard.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import Webform from './Webform';
3
3
  import { Formio } from './Formio';
4
- import { fastCloneDeep, checkCondition, firstNonNil, uniqueKey, eachComponent, } from './utils/utils';
4
+ import { fastCloneDeep, checkCondition, firstNonNil, uniqueKey, eachComponent, } from './utils';
5
5
  export default class Wizard extends Webform {
6
6
  /**
7
7
  * Constructor for wizard-based forms.
@@ -2,7 +2,7 @@ import WebformBuilder from './WebformBuilder';
2
2
  import Webform from './Webform';
3
3
  import BuilderUtils from './utils/builder';
4
4
  import _ from 'lodash';
5
- import { fastCloneDeep } from './utils/utils';
5
+ import { fastCloneDeep } from './utils';
6
6
  export default class WizardBuilder extends WebformBuilder {
7
7
  constructor() {
8
8
  let element, options;
@@ -165,7 +165,6 @@ declare class Component extends Element {
165
165
  get componentsMap(): object;
166
166
  /**
167
167
  * Returns if the parent should conditionally clear.
168
- *
169
168
  * @returns {boolean} - If the parent should conditionally clear.
170
169
  */
171
170
  parentShouldConditionallyClear(): boolean;
@@ -5,8 +5,8 @@ import _ from 'lodash';
5
5
  import isMobile from 'ismobilejs';
6
6
  import { processOne, processOneSync, validateProcessInfo } from '@formio/core/process';
7
7
  import { Formio } from '../../../Formio';
8
- import * as FormioUtils from '../../../utils/utils';
9
- import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils/utils';
8
+ import FormioUtils from '../../../utils';
9
+ import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils';
10
10
  import Element from '../../../Element';
11
11
  import ComponentModal from '../componentModal/ComponentModal';
12
12
  import Widgets from '../../../widgets';
@@ -424,7 +424,6 @@ export default class Component extends Element {
424
424
  }
425
425
  /**
426
426
  * Returns if the parent should conditionally clear.
427
- *
428
427
  * @returns {boolean} - If the parent should conditionally clear.
429
428
  */
430
429
  parentShouldConditionallyClear() {
@@ -2683,13 +2682,16 @@ export default class Component extends Element {
2683
2682
  }
2684
2683
  const isArray = Array.isArray(value);
2685
2684
  const valueInput = this.refs.fileLink || this.refs.input;
2685
+ const isFilelink = !!this.refs.fileLink;
2686
2686
  if (isArray &&
2687
2687
  Array.isArray(this.defaultValue) &&
2688
2688
  this.refs.hasOwnProperty('input') &&
2689
2689
  valueInput &&
2690
2690
  (valueInput.length !== value.length) &&
2691
2691
  this.visible) {
2692
- this.redraw();
2692
+ if (isFilelink || valueInput.length) {
2693
+ this.redraw();
2694
+ }
2693
2695
  }
2694
2696
  if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
2695
2697
  this.redraw();
@@ -1,5 +1,5 @@
1
1
  import EditFormUtils from './utils';
2
- import { getContextComponents } from '../../../../utils/utils';
2
+ import { getContextComponents } from '../../../../utils';
3
3
  /* eslint-disable quotes, max-len */
4
4
  export default [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import EditFormUtils from './utils';
2
- import { getContextComponents } from '../../../../utils/utils';
2
+ import { getContextComponents } from '../../../../utils';
3
3
  /* eslint-disable quotes, max-len */
4
4
  export default [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { fastCloneDeep } from '../../../utils/utils';
2
+ import { fastCloneDeep } from '../../../utils';
3
3
  export default class ComponentModal {
4
4
  static render(component, data, topLevel) {
5
5
  const children = component.renderTemplate('component', data, topLevel);
@@ -1,5 +1,5 @@
1
1
  import Multivalue from '../multivalue/Multivalue';
2
- import { convertStringToHTMLElement } from '../../../utils/utils';
2
+ import { convertStringToHTMLElement } from '../../../utils';
3
3
  import Widgets from '../../../widgets';
4
4
  import _ from 'lodash';
5
5
  export default class Input extends Multivalue {
@@ -1,7 +1,7 @@
1
1
  import Field from '../field/Field';
2
2
  import { Formio } from '../../../Formio';
3
3
  import _ from 'lodash';
4
- import { getItemTemplateKeys } from '../../../utils/utils';
4
+ import { getItemTemplateKeys } from '../../../utils';
5
5
  export default class ListComponent extends Field {
6
6
  static schema(...extend) {
7
7
  return Field.schema({
@@ -3,7 +3,7 @@ import _ from 'lodash';
3
3
  import Field from '../field/Field';
4
4
  import Components from '../../Components';
5
5
  '';
6
- import { getComponentPaths, getRandomComponentId, componentMatches, getBestMatch, getStringFromComponentPath } from '../../../utils/utils';
6
+ import FormioUtils from '../../../utils';
7
7
  import { process as processAsync, processSync } from '@formio/core/process';
8
8
  /**
9
9
  * NestedComponent class.
@@ -204,7 +204,7 @@ export default class NestedComponent extends Field {
204
204
  */
205
205
  set rowIndex(value) {
206
206
  this._rowIndex = value;
207
- this.paths = getComponentPaths(this.component, this.parent?.component, {
207
+ this.paths = FormioUtils.getComponentPaths(this.component, this.parent?.component, {
208
208
  ...(this.parent?.paths || {}),
209
209
  ...{ dataIndex: value }
210
210
  });
@@ -308,7 +308,7 @@ export default class NestedComponent extends Field {
308
308
  * @returns {any} - The component that is located.
309
309
  */
310
310
  getComponent(path) {
311
- path = getStringFromComponentPath(path);
311
+ path = FormioUtils.getStringFromComponentPath(path);
312
312
  const matches = {
313
313
  path: undefined,
314
314
  fullPath: undefined,
@@ -320,7 +320,7 @@ export default class NestedComponent extends Field {
320
320
  };
321
321
  this.everyComponent((component) => {
322
322
  // All searches are relative to this component so replace this path from the child paths.
323
- componentMatches(component.component, {
323
+ FormioUtils.componentMatches(component.component, {
324
324
  path: component.paths?.path?.replace(new RegExp(`^${this.paths?.path}\\.?`), ''),
325
325
  fullPath: component.paths?.fullPath?.replace(new RegExp(`^${this.paths?.fullPath}\\.?`), ''),
326
326
  localPath: component.paths?.localPath?.replace(new RegExp(`^${this.paths?.localPath}\\.?`), ''),
@@ -332,7 +332,7 @@ export default class NestedComponent extends Field {
332
332
  return match;
333
333
  });
334
334
  });
335
- return getBestMatch(matches)?.instance;
335
+ return FormioUtils.getBestMatch(matches)?.instance;
336
336
  }
337
337
  /**
338
338
  * Return a component provided the Id of the component.
@@ -374,7 +374,7 @@ export default class NestedComponent extends Field {
374
374
  options.localRoot = this.localRoot;
375
375
  options.skipInit = true;
376
376
  if (!(options.display === 'pdf' && this.builderMode)) {
377
- component.id = getRandomComponentId();
377
+ component.id = FormioUtils.getRandomComponentId();
378
378
  }
379
379
  const comp = Components.create(component, options, data, true);
380
380
  comp.init();
@@ -2,7 +2,7 @@
2
2
  import _ from 'lodash';
3
3
  import { Utils } from '@formio/core/utils';
4
4
  const { getComponentPaths } = Utils;
5
- import { componentValueTypes, isLayoutComponent } from '../../../utils/utils';
5
+ import { componentValueTypes, isLayoutComponent } from '../../../utils';
6
6
  import Component from '../component/Component';
7
7
  import NestedDataComponent from '../nesteddata/NestedDataComponent';
8
8
  export default class NestedArrayComponent extends NestedDataComponent {
@@ -2,7 +2,7 @@
2
2
  import Component from '../component/Component';
3
3
  import NestedComponent from '../nested/NestedComponent';
4
4
  import _ from 'lodash';
5
- import { componentValueTypes, getComponentSavedTypes } from '../../../utils/utils';
5
+ import { componentValueTypes, getComponentSavedTypes } from '../../../utils';
6
6
  export default class NestedDataComponent extends NestedComponent {
7
7
  hasChanged(newValue, oldValue) {
8
8
  // If we do not have a value and are getting set to anything other than undefined or null, then we changed.
@@ -5,7 +5,7 @@ import { GoogleAddressProvider } from '../../providers/address/GoogleAddressProv
5
5
  import Field from '../_classes/field/Field';
6
6
  import NestedComponent from '../_classes/nested/NestedComponent';
7
7
  import ContainerComponent from '../container/Container';
8
- import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
8
+ import { componentValueTypes, getComponentSavedTypes } from '../../utils';
9
9
  export const AddressComponentMode = {
10
10
  Autocomplete: 'autocomplete',
11
11
  Manual: 'manual',
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { getStringFromComponentPath } from '../../utils/utils';
2
+ import { getStringFromComponentPath } from '../../utils';
3
3
  export default class Alert {
4
4
  constructor(container, component) {
5
5
  this.container = container;
@@ -7,7 +7,7 @@ export default class ButtonComponent extends Field {
7
7
  weight: number;
8
8
  schema: any;
9
9
  };
10
- static savedValueTypes(schema: any): string[];
10
+ static savedValueTypes(schema: any): any;
11
11
  constructor(component: any, options: any, data: any);
12
12
  filesUploading: number;
13
13
  get inputInfo(): any;
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import Field from '../_classes/field/Field';
3
3
  import Input from '../_classes/input/Input';
4
- import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils/utils';
4
+ import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils/formUtils';
5
5
  export default class ButtonComponent extends Field {
6
6
  static schema(...extend) {
7
7
  return Input.schema({
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
2
+ import { componentValueTypes, getComponentSavedTypes } from '../../utils';
3
3
  import Field from '../_classes/field/Field';
4
4
  export default class CheckBoxComponent extends Field {
5
5
  static schema(...extend) {
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { componentValueTypes, getComponentSavedTypes, getFocusableElements } from '../../utils/utils';
2
+ import { componentValueTypes, getComponentSavedTypes, getFocusableElements } from '../../utils';
3
3
  import Component from '../_classes/component/Component';
4
4
  import Field from '../_classes/field/Field';
5
5
  import NestedDataComponent from '../_classes/nesteddata/NestedDataComponent';
@@ -1,7 +1,7 @@
1
1
  import { createNumberMask } from '@formio/text-mask-addons';
2
2
  import { maskInput } from '@formio/vanilla-text-mask';
3
3
  import _ from 'lodash';
4
- import { getCurrencyAffixes } from '../../utils/utils';
4
+ import { getCurrencyAffixes } from '../../utils';
5
5
  import NumberComponent from '../number/Number';
6
6
  export default class CurrencyComponent extends NumberComponent {
7
7
  static schema(...extend) {
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
3
- import { fastCloneDeep, getFocusableElements, getComponent } from '../../utils/utils';
3
+ import { fastCloneDeep, getFocusableElements, getComponent } from '../../utils';
4
4
  export default class DataGridComponent extends NestedArrayComponent {
5
5
  static schema(...extend) {
6
6
  return NestedArrayComponent.schema({
@@ -1,5 +1,5 @@
1
1
  export default class DataMapComponent extends DataGridComponent {
2
- static savedValueTypes(schema: any): string[];
2
+ static savedValueTypes(schema: any): any;
3
3
  constructor(component: any, options: any, data: any);
4
4
  get schema(): any;
5
5
  get emptyValue(): {};
@@ -2,7 +2,7 @@ import Component from '../_classes/component/Component';
2
2
  import DataGridComponent from '../datagrid/DataGrid';
3
3
  import _ from 'lodash';
4
4
  import EventEmitter from 'eventemitter3';
5
- import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/utils';
5
+ import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/formUtils';
6
6
  export default class DataMapComponent extends DataGridComponent {
7
7
  static schema(...extend) {
8
8
  return Component.schema({
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
- import moment from 'moment';
2
+ import dayjs from 'dayjs';
3
3
  import FormioUtils from '../../utils';
4
- import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils/utils';
4
+ import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils';
5
5
  import Input from '../_classes/input/Input';
6
6
  export default class DateTimeComponent extends Input {
7
7
  static schema(...extend) {
@@ -147,8 +147,8 @@ export default class DateTimeComponent extends Input {
147
147
  get emptyValue() {
148
148
  return '';
149
149
  }
150
- get momentFormat() {
151
- return FormioUtils.convertFormatToMoment(this.component.format);
150
+ get dayjsFormat() {
151
+ return FormioUtils.convertFormatToDayjs(this.component.format);
152
152
  }
153
153
  isEmpty(value = this.dataValue) {
154
154
  if (value && (value.toString() === 'Invalid Date')) {
@@ -157,12 +157,14 @@ export default class DateTimeComponent extends Input {
157
157
  return super.isEmpty(value);
158
158
  }
159
159
  formatValue(input) {
160
- const result = moment.utc(input).toISOString();
161
- return result === 'Invalid date' ? input : result;
160
+ if (dayjs(input).isValid()) {
161
+ return dayjs.utc(input).toISOString();
162
+ }
163
+ return input;
162
164
  }
163
165
  isEqual(valueA, valueB = this.dataValue) {
164
166
  return (this.isEmpty(valueA) && this.isEmpty(valueB))
165
- || moment.utc(valueA).format(this.momentFormat) === moment.utc(valueB).format(this.momentFormat);
167
+ || dayjs.utc(valueA).format(this.dayjsFormat) === dayjs.utc(valueB).format(this.dayjsFormat);
166
168
  }
167
169
  createWrapper() {
168
170
  return false;
@@ -178,18 +180,18 @@ export default class DateTimeComponent extends Input {
178
180
  return super.checkValidity(data, dirty, rowData);
179
181
  }
180
182
  getValueAsString(value, options) {
181
- let format = FormioUtils.convertFormatToMoment(this.component.format);
182
- format += format.match(/z$/) ? '' : ' z';
183
+ let format = FormioUtils.convertFormatToDayjs(this.component.format);
183
184
  const timezone = this.timezone;
184
185
  if (value && !this.attached && timezone) {
186
+ format += format.match(/z$/) ? '' : ' z';
185
187
  if (Array.isArray(value) && this.component.multiple) {
186
- return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format))).join(', ');
188
+ return value.map(item => _.trim(FormioUtils.dayjsDate(item, format, timezone, options).format(format))).join(', ');
187
189
  }
188
- return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
190
+ return _.trim(FormioUtils.dayjsDate(value, format, timezone, options).format(format));
189
191
  }
190
192
  if (Array.isArray(value) && this.component.multiple) {
191
- return value.map(item => _.trim(moment(item).format(format))).join(', ');
193
+ return value.map(item => _.trim(dayjs(item).format(format))).join(', ');
192
194
  }
193
- return (value ? _.trim(moment(value).format(format)) : value) || '';
195
+ return (value ? _.trim(dayjs(value).format(format)) : value) || '';
194
196
  }
195
197
  }
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import moment from 'moment';
3
3
  import Field from '../_classes/field/Field';
4
- import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils/utils';
4
+ import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils';
5
5
  import { getDayFormat } from '@formio/core';
6
6
  export default class DayComponent extends Field {
7
7
  static schema(...extend) {