@formio/js 5.3.0 → 5.3.1

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 (58) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +602 -602
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.full.js +775 -775
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  10. package/dist/formio.js +514 -514
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +485 -485
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  16. package/lib/cjs/Embed.js +1 -1
  17. package/lib/cjs/Formio.js +1 -1
  18. package/lib/cjs/PDF.js +9 -1
  19. package/lib/cjs/Webform.js +1 -1
  20. package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
  21. package/lib/cjs/components/_classes/component/Component.js +14 -1
  22. package/lib/cjs/components/_classes/input/Input.js +17 -2
  23. package/lib/cjs/components/address/Address.js +2 -1
  24. package/lib/cjs/components/datagrid/DataGrid.js +12 -1
  25. package/lib/cjs/components/fieldset/Fieldset.d.ts +1 -0
  26. package/lib/cjs/components/fieldset/Fieldset.js +7 -0
  27. package/lib/cjs/components/select/Select.js +13 -8
  28. package/lib/cjs/components/tags/Tags.js +2 -1
  29. package/lib/cjs/package.json +1 -1
  30. package/lib/cjs/utils/conditionOperators/IsEqualTo.d.ts +1 -3
  31. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +6 -12
  32. package/lib/cjs/utils/conditionOperators/index.d.ts +2 -1
  33. package/lib/cjs/utils/index.d.ts +2 -1
  34. package/lib/cjs/utils/utils.d.ts +9 -0
  35. package/lib/cjs/utils/utils.js +132 -2
  36. package/lib/cjs/widgets/CalendarWidget.js +2 -1
  37. package/lib/mjs/Embed.js +1 -1
  38. package/lib/mjs/Formio.js +1 -1
  39. package/lib/mjs/PDF.js +9 -1
  40. package/lib/mjs/Webform.js +1 -1
  41. package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
  42. package/lib/mjs/components/_classes/component/Component.js +12 -1
  43. package/lib/mjs/components/_classes/input/Input.js +16 -3
  44. package/lib/mjs/components/address/Address.js +1 -1
  45. package/lib/mjs/components/datagrid/DataGrid.js +11 -1
  46. package/lib/mjs/components/fieldset/Fieldset.d.ts +1 -0
  47. package/lib/mjs/components/fieldset/Fieldset.js +7 -0
  48. package/lib/mjs/components/select/Select.js +11 -8
  49. package/lib/mjs/components/tags/Tags.js +1 -1
  50. package/lib/mjs/package.json +1 -1
  51. package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +1 -3
  52. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +6 -11
  53. package/lib/mjs/utils/conditionOperators/index.d.ts +2 -1
  54. package/lib/mjs/utils/index.d.ts +2 -1
  55. package/lib/mjs/utils/utils.d.ts +9 -0
  56. package/lib/mjs/utils/utils.js +130 -1
  57. package/lib/mjs/widgets/CalendarWidget.js +1 -1
  58. package/package.json +3 -3
@@ -22,7 +22,7 @@
22
22
 
23
23
  /*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */
24
24
 
25
- /*! formiojs v5.3.0 | https://unpkg.com/formiojs@5.3.0/LICENSE.txt */
25
+ /*! formiojs v5.3.1 | https://unpkg.com/formiojs@5.3.1/LICENSE.txt */
26
26
 
27
27
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
28
28
 
package/lib/cjs/Embed.js CHANGED
@@ -453,7 +453,7 @@ Formio.formioReady = new Promise((ready, reject) => {
453
453
  _a._formioReady = ready;
454
454
  _a._formioReadyReject = reject;
455
455
  });
456
- Formio.version = '5.3.0';
456
+ Formio.version = '5.3.1';
457
457
  // Create a report.
458
458
  Formio.Report = {
459
459
  create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
package/lib/cjs/Formio.js CHANGED
@@ -11,7 +11,7 @@ const CDN_1 = __importDefault(require("./CDN"));
11
11
  const providers_1 = __importDefault(require("./providers"));
12
12
  sdk_1.Formio.cdn = new CDN_1.default();
13
13
  sdk_1.Formio.Providers = providers_1.default;
14
- sdk_1.Formio.version = '5.3.0';
14
+ sdk_1.Formio.version = '5.3.1';
15
15
  CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc')
16
16
  ? 'https://cdn.test-form.io'
17
17
  : 'https://cdn.form.io';
package/lib/cjs/PDF.js CHANGED
@@ -286,7 +286,15 @@ if (typeof window !== 'undefined') {
286
286
  eventData.name &&
287
287
  eventData.formId &&
288
288
  Formio_1.Formio.forms.hasOwnProperty(eventData.formId)) {
289
- Formio_1.Formio.forms[eventData.formId].emit(`iframe-${eventData.name}`, eventData.data);
289
+ if (eventData.compPath) {
290
+ const comp = Formio_1.Formio.forms[eventData.formId].getComponent(eventData.compPath);
291
+ if (comp) {
292
+ comp.emit(eventData.name, eventData.data);
293
+ }
294
+ }
295
+ else {
296
+ Formio_1.Formio.forms[eventData.formId].emit(`iframe-${eventData.name}`, eventData.data);
297
+ }
290
298
  }
291
299
  });
292
300
  }
@@ -259,7 +259,7 @@ class Webform extends NestedDataComponent_1.default {
259
259
  if (err) {
260
260
  return;
261
261
  }
262
- this.rebuild();
262
+ this.redraw();
263
263
  this.emit('languageChanged');
264
264
  });
265
265
  }
@@ -187,6 +187,7 @@ declare class Component extends Element {
187
187
  tooltipClass: string;
188
188
  for: any;
189
189
  };
190
+ getFieldsetLegendIds(): string;
190
191
  init(): void;
191
192
  /**
192
193
  * Disable this component.
@@ -507,6 +507,18 @@ class Component extends Element_1.default {
507
507
  }
508
508
  return label;
509
509
  }
510
+ getFieldsetLegendIds() {
511
+ var _a, _b;
512
+ const legendIds = [];
513
+ let currentParent = this.parent;
514
+ while (currentParent) {
515
+ if (((_a = currentParent.component) === null || _a === void 0 ? void 0 : _a.type) === 'fieldset' && ((_b = currentParent.component) === null || _b === void 0 ? void 0 : _b.legend)) {
516
+ legendIds.push(`l-${currentParent.id}-legend`);
517
+ }
518
+ currentParent = currentParent.parent;
519
+ }
520
+ return legendIds.reverse().join(' ');
521
+ }
510
522
  init() {
511
523
  var _a;
512
524
  this.disabled = this.shouldDisabled;
@@ -3677,13 +3689,14 @@ class Component extends Element_1.default {
3677
3689
  * @returns {*} - The components "input" DOM element information.
3678
3690
  */
3679
3691
  elementInfo() {
3692
+ var _a;
3680
3693
  const attributes = {
3681
3694
  name: this.options.name,
3682
3695
  type: this.component.inputType || 'text',
3683
3696
  class: 'form-control',
3684
3697
  lang: this.options.language,
3685
3698
  };
3686
- if (this.component.placeholder) {
3699
+ if (this.component.placeholder && !((_a = this.options) === null || _a === void 0 ? void 0 : _a.readOnly)) {
3687
3700
  attributes.placeholder = this.t(this.component.placeholder, { _userInput: true });
3688
3701
  }
3689
3702
  if (this.component.tabindex) {
@@ -20,6 +20,7 @@ class Input extends Multivalue_1.default {
20
20
  }, ...extend);
21
21
  }
22
22
  get inputInfo() {
23
+ var _a;
23
24
  const attr = {
24
25
  name: this.options.name,
25
26
  type: this.component.inputType || 'text',
@@ -34,7 +35,7 @@ class Input extends Multivalue_1.default {
34
35
  if (this.component.inputMode) {
35
36
  attr.inputmode = this.component.inputMode;
36
37
  }
37
- if (this.component.placeholder) {
38
+ if (this.component.placeholder && !((_a = this.options) === null || _a === void 0 ? void 0 : _a.readOnly)) {
38
39
  attr.placeholder = this.getFormattedAttribute(this.component.placeholder);
39
40
  }
40
41
  if (this.component.tabindex) {
@@ -166,6 +167,9 @@ class Input extends Multivalue_1.default {
166
167
  }
167
168
  }
168
169
  updateValueAt(value, flags, index) {
170
+ if (flags.modified) {
171
+ (0, index_1.announceScreenReaderMessage)(this, value, index);
172
+ }
169
173
  flags = flags || {};
170
174
  if (lodash_1.default.get(this.component, 'showWordCount', false)) {
171
175
  if (this.refs.wordcount && this.refs.wordcount[index]) {
@@ -190,7 +194,7 @@ class Input extends Multivalue_1.default {
190
194
  updateValue(value, flags, index) {
191
195
  flags = flags || {};
192
196
  const changed = super.updateValue(value, flags);
193
- this.triggerUpdateValueAt(this.dataValue, flags, index);
197
+ this.triggerUpdateValueAt(this.dataValue, Object.assign({}, flags), index);
194
198
  return changed;
195
199
  }
196
200
  parseValue(value) {
@@ -201,6 +205,7 @@ class Input extends Multivalue_1.default {
201
205
  }
202
206
  attach(element) {
203
207
  this.loadRefs(element, {
208
+ announceMessage: 'multiple',
204
209
  charcount: 'multiple',
205
210
  wordcount: 'multiple',
206
211
  prefix: 'multiple',
@@ -244,6 +249,16 @@ class Input extends Multivalue_1.default {
244
249
  }
245
250
  });
246
251
  }
252
+ this.on('focus', (comp) => {
253
+ (0, index_1.announceScreenReaderMessage)(comp, comp.dataValue, 0, true);
254
+ });
255
+ this.on('blur', (comp) => {
256
+ var _a, _b;
257
+ const el = (_b = (_a = comp.refs) === null || _a === void 0 ? void 0 : _a["announceMessage"]) === null || _b === void 0 ? void 0 : _b[0];
258
+ if (el) {
259
+ el.textContent = "";
260
+ }
261
+ });
247
262
  return promise;
248
263
  }
249
264
  /**
@@ -310,6 +310,7 @@ class AddressComponent extends Container_1.default {
310
310
  return this.refs ? this.refs[AddressComponent.removeRowButtonRef] || null : null;
311
311
  }
312
312
  get searchInputAttributes() {
313
+ var _a;
313
314
  const attr = {
314
315
  name: this.options.name,
315
316
  type: 'text',
@@ -317,7 +318,7 @@ class AddressComponent extends Container_1.default {
317
318
  lang: this.options.language,
318
319
  tabindex: this.component.tabindex || 0,
319
320
  };
320
- if (this.component.placeholder) {
321
+ if (this.component.placeholder && !((_a = this.options) === null || _a === void 0 ? void 0 : _a.readOnly)) {
321
322
  ((attr.placeholder = this.t(this.component.placeholder)), { _userInput: true });
322
323
  }
323
324
  if (this.disabled) {
@@ -113,6 +113,17 @@ class DataGridComponent extends NestedArrayComponent_1.default {
113
113
  for (let dIndex = defaultValue.length; dIndex < this.minLength; dIndex++) {
114
114
  defaultValue.push({});
115
115
  }
116
+ if (this.component.customDefaultValue) {
117
+ return defaultValue;
118
+ }
119
+ if (defaultValue.length === 1 && this.columns) {
120
+ (0, utils_1.eachComponent)(this.components, (comp, path) => {
121
+ var _a;
122
+ if (((_a = comp.component) === null || _a === void 0 ? void 0 : _a.input) && comp.defaultValue) {
123
+ lodash_1.default.set(defaultValue[0], path, comp.defaultValue);
124
+ }
125
+ });
126
+ }
116
127
  return defaultValue;
117
128
  }
118
129
  set disabled(disabled) {
@@ -437,7 +448,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
437
448
  });
438
449
  (0, utils_1.screenReaderSpeech)('Row has been added');
439
450
  this.checkConditions();
440
- (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this, { modified: true });
451
+ (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this, { modified: true, noPristineChangeOnModified: true });
441
452
  this.redraw().then(() => {
442
453
  this.focusOnNewRowElement(this.rows[index]);
443
454
  });
@@ -10,6 +10,7 @@ export default class FieldsetComponent extends NestedComponent {
10
10
  };
11
11
  static savedValueTypes(): never[];
12
12
  constructor(...args: any[]);
13
+ attach(element: any): Promise<void>;
13
14
  noField: boolean;
14
15
  }
15
16
  import NestedComponent from '../_classes/nested/NestedComponent';
@@ -39,6 +39,13 @@ class FieldsetComponent extends NestedComponent_1.default {
39
39
  get templateName() {
40
40
  return 'fieldset';
41
41
  }
42
+ attach(element) {
43
+ return super.attach(element).then(() => {
44
+ if (this.component.legend && this.refs.header) {
45
+ this.refs.header.setAttribute('id', `l-${this.id}-legend`);
46
+ }
47
+ });
48
+ }
42
49
  constructor(...args) {
43
50
  super(...args);
44
51
  this.noField = true;
@@ -276,9 +276,9 @@ class SelectComponent extends ListComponent_1.default {
276
276
  // Inside DataTable component won't have dataValue set
277
277
  const shouldUseSelectData = (this.component.multiple && lodash_1.default.isArray(this.dataValue)
278
278
  ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
279
- : this.dataValue === this.normalizeSingleValue(value)) || this.inDataTable;
279
+ : this.dataValue === this.normalizeSingleValue(value)) || (this.inDataTable && !this.element);
280
280
  if (shouldUseSelectData) {
281
- const selectData = this.selectData;
281
+ const selectData = (this.inDataTable && !this.element) ? this.component.selectData : this.selectData;
282
282
  if (selectData) {
283
283
  const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
284
284
  if (!this.templateData || !this.templateData[templateValue]) {
@@ -766,7 +766,8 @@ class SelectComponent extends ListComponent_1.default {
766
766
  }
767
767
  }
768
768
  addPlaceholder() {
769
- if (!this.component.placeholder) {
769
+ var _a;
770
+ if (!this.component.placeholder || ((_a = this.options) === null || _a === void 0 ? void 0 : _a.readOnly)) {
770
771
  return;
771
772
  }
772
773
  this.addOption('', this.component.placeholder, { placeholder: true });
@@ -830,10 +831,12 @@ class SelectComponent extends ListComponent_1.default {
830
831
  : element;
831
832
  }
832
833
  choicesOptions() {
834
+ var _a;
833
835
  const useSearch = this.component.hasOwnProperty('searchEnabled')
834
836
  ? this.component.searchEnabled
835
837
  : true;
836
- const placeholderValue = this.t(this.component.placeholder, { _userInput: true });
838
+ const hasPlaceholder = !!this.component.placeholder && !((_a = this.options) === null || _a === void 0 ? void 0 : _a.readOnly);
839
+ const placeholderValue = hasPlaceholder ? this.t(this.component.placeholder, { _userInput: true }) : null;
837
840
  let customOptions = this.component.customOptions || {};
838
841
  if (typeof customOptions == 'string') {
839
842
  try {
@@ -857,7 +860,7 @@ class SelectComponent extends ListComponent_1.default {
857
860
  'formio-choices',
858
861
  ],
859
862
  containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
860
- }, addItemText: false, allowHTML: true, placeholder: !!this.component.placeholder, placeholderValue: placeholderValue, noResultsText: this.t('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), shouldSort: false, position: this.component.dropdown || 'auto', searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', [
863
+ }, addItemText: false, allowHTML: true, placeholder: hasPlaceholder, placeholderValue: placeholderValue, noResultsText: this.t('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), shouldSort: false, position: this.component.dropdown || 'auto', searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', [
861
864
  'label',
862
865
  ]), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch
863
866
  ? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false, duplicateItemsAllowed: false }, customOptions);
@@ -1296,7 +1299,8 @@ class SelectComponent extends ListComponent_1.default {
1296
1299
  }
1297
1300
  setMetadata(value, flags = {}) {
1298
1301
  var _a, _b;
1299
- if (lodash_1.default.isNil(value)) {
1302
+ if (lodash_1.default.isNil(value) ||
1303
+ (this.inDataTable && this.component.dataSrc === 'values')) {
1300
1304
  return;
1301
1305
  }
1302
1306
  const valueIsObject = lodash_1.default.isObject(value);
@@ -1306,7 +1310,7 @@ class SelectComponent extends ListComponent_1.default {
1306
1310
  }
1307
1311
  // Check to see if we need to save off the template data into our metadata.
1308
1312
  const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
1309
- const shouldSaveData = (!valueIsObject || this.component.reference) && !this.inDataTable;
1313
+ const shouldSaveData = (!valueIsObject || this.component.reference) && !(this.inDataTable && this.row === '');
1310
1314
  if (!lodash_1.default.isNil(templateValue) &&
1311
1315
  shouldSaveData &&
1312
1316
  this.templateData &&
@@ -1592,7 +1596,8 @@ class SelectComponent extends ListComponent_1.default {
1592
1596
  asString(value, options = {}) {
1593
1597
  var _a;
1594
1598
  value = value !== null && value !== void 0 ? value : this.getValue();
1595
- if (options.modalPreview || this.inDataTable) {
1599
+ if (options.modalPreview ||
1600
+ ((this.inDataTable || this.inEditGrid) && !['values', 'custom'].includes(this.component.dataSrc))) {
1596
1601
  if (this.inDataTable) {
1597
1602
  value = this.undoValueTyping(value);
1598
1603
  }
@@ -63,6 +63,7 @@ class TagsComponent extends Input_1.default {
63
63
  return this.component.delimeter || ',';
64
64
  }
65
65
  attachElement(element, index) {
66
+ var _a;
66
67
  super.attachElement(element, index);
67
68
  if (!element) {
68
69
  return;
@@ -76,7 +77,7 @@ class TagsComponent extends Input_1.default {
76
77
  if (!choices_js_1.default) {
77
78
  return;
78
79
  }
79
- const hasPlaceholder = !!this.component.placeholder;
80
+ const hasPlaceholder = !!this.component.placeholder && !((_a = this.options) === null || _a === void 0 ? void 0 : _a.readOnly);
80
81
  this.choices = new choices_js_1.default(element, {
81
82
  delimiter: this.delimiter,
82
83
  editItems: true,
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "type": "commonjs",
3
- "version": "5.3.0"
3
+ "version": "5.3.1"
4
4
  }
@@ -1,9 +1,7 @@
1
1
  export default class IsEqualTo extends ConditionOperator {
2
- execute({ value, comparedValue, instance, path }: {
2
+ execute({ value, comparedValue }: {
3
3
  value: any;
4
4
  comparedValue: any;
5
- instance: any;
6
- path: any;
7
5
  }): any;
8
6
  }
9
7
  import ConditionOperator from './ConditionOperator';
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const ConditionOperator_1 = __importDefault(require("./ConditionOperator"));
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
- const __1 = require("../");
9
8
  class IsEqualTo extends ConditionOperator_1.default {
10
9
  static get operatorKey() {
11
10
  return 'isEqual';
@@ -13,8 +12,7 @@ class IsEqualTo extends ConditionOperator_1.default {
13
12
  static get displayedName() {
14
13
  return 'Is Equal To';
15
14
  }
16
- execute({ value, comparedValue, instance, path }) {
17
- var _a, _b;
15
+ execute({ value, comparedValue }) {
18
16
  if ((value || value === false) &&
19
17
  comparedValue &&
20
18
  typeof value !== typeof comparedValue &&
@@ -26,19 +24,15 @@ class IsEqualTo extends ConditionOperator_1.default {
26
24
  // ignore
27
25
  }
28
26
  }
29
- if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
30
- const conditionTriggerComponent = instance.root.getComponent(path);
31
- if (conditionTriggerComponent &&
32
- (0, __1.isSelectResourceWithObjectValue)(conditionTriggerComponent.component) &&
33
- ((_b = conditionTriggerComponent.component) === null || _b === void 0 ? void 0 : _b.template)) {
34
- return (0, __1.compareSelectResourceWithObjectTypeValues)(value, comparedValue, conditionTriggerComponent.component);
35
- }
36
- }
37
27
  //special check for select boxes
38
28
  if (lodash_1.default.isObject(value) && comparedValue && lodash_1.default.isBoolean(value[comparedValue])) {
39
29
  return value[comparedValue];
40
30
  }
41
- return lodash_1.default.isEqual(value, comparedValue);
31
+ const valuesAreObjects = typeof comparedValue === 'object' &&
32
+ comparedValue !== null &&
33
+ typeof value === 'object' &&
34
+ value !== null;
35
+ return valuesAreObjects ? lodash_1.default.isMatch(value, comparedValue) : lodash_1.default.isEqual(comparedValue, value);
42
36
  }
43
37
  }
44
38
  exports.default = IsEqualTo;
@@ -1,6 +1,7 @@
1
1
  export default ConditionOperators;
2
2
  declare const ConditionOperators: {
3
- [x: string]: typeof IsEqualTo | typeof DateGreaterThan;
3
+ [x: string]: typeof IsEqualTo | typeof IsEmptyValue | typeof DateGreaterThan;
4
4
  };
5
5
  import IsEqualTo from './IsEqualTo';
6
+ import IsEmptyValue from './IsEmptyValue';
6
7
  import DateGreaterThan from './DateGreaterThan';
@@ -5,7 +5,7 @@ declare const FormioUtils: {
5
5
  Evaluator: DefaultEvaluator;
6
6
  interpolate: typeof interpolate;
7
7
  ConditionOperators: {
8
- [x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
8
+ [x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/IsEmptyValue").default | typeof import("./conditionOperators/DateGreaterThan").default;
9
9
  };
10
10
  _: any;
11
11
  moment: typeof moment;
@@ -150,6 +150,7 @@ declare const FormioUtils: {
150
150
  getFocusableElements(element: HTMLElement): NodeList<HTMLElement>;
151
151
  getComponentSavedTypes(fullSchema: import("@formio/core").Component): string[] | null;
152
152
  hasEncodedTimezone(value: string): boolean;
153
+ announceScreenReaderMessage(component: any, value: any, index?: any, forFocus?: any): undefined;
153
154
  screenReaderSpeech(text: string): void;
154
155
  firstNonNil: any;
155
156
  componentValueTypes: {
@@ -499,6 +499,15 @@ export function getComponentSavedTypes(fullSchema: import('@formio/core').Compon
499
499
  * @returns {boolean} if value has encoded timezone
500
500
  */
501
501
  export function hasEncodedTimezone(value: string): boolean;
502
+ /**
503
+ * The function for announcing messages via a screen reader
504
+ * @param {component} component - The component instance
505
+ * @param {value} value - The current component value
506
+ * @param {index} index - The component index
507
+ * @param {forFocus} forFocus - Whether the component is focused or not
508
+ * @returns {undefined}
509
+ */
510
+ export function announceScreenReaderMessage(component: any, value: any, index?: any, forFocus?: any): undefined;
502
511
  /**
503
512
  * Outputs text to screen reader
504
513
  * @param {string} text The text to output to screen readers
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getContextComponents = exports.observeOverload = 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.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 = void 0;
7
- exports.screenReaderSpeech = exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports.getFocusableElements = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = void 0;
7
+ exports.screenReaderSpeech = exports.announceScreenReaderMessage = exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports.getFocusableElements = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = void 0;
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
10
10
  const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
@@ -150,7 +150,7 @@ function getConditionalPathsRecursive(conditionPaths, data) {
150
150
  if (currentData.some((element) => typeof element !== 'object')) {
151
151
  return;
152
152
  }
153
- const hasInnerDataArray = currentData.find((x) => Array.isArray(x[conditionPaths[currentLocalIndex]]));
153
+ const hasInnerDataArray = currentData.find((x) => x && conditionPaths && Array.isArray(x[conditionPaths[currentLocalIndex]]));
154
154
  if (hasInnerDataArray) {
155
155
  currentData.forEach((_, indexOutside) => {
156
156
  const innerCompDataPath = `${currentPath}[${indexOutside}].${conditionPaths[currentLocalIndex]}`;
@@ -1691,6 +1691,136 @@ function hasEncodedTimezone(value) {
1691
1691
  value.match(/[+|-][0-9]{2}:[0-9]{2}$/));
1692
1692
  }
1693
1693
  exports.hasEncodedTimezone = hasEncodedTimezone;
1694
+ // Types for min max validation if value = string
1695
+ const TYPES = new Map([["char", "Length"], ["word", "Words"]]);
1696
+ // The number from which the remaining character(words) count message starts being read
1697
+ const REMAIN_COUNT = new Map([["char", 10], ["word", 5]]);
1698
+ function getWordOrCharacterLabel(isWordType, count) {
1699
+ const base = isWordType ? "word" : "character";
1700
+ return Math.abs(count) === 1 ? base : `${base}s`;
1701
+ }
1702
+ /**
1703
+ * The function calculates the message values depending on the type and the current component settings.
1704
+ * @param {component} component - The component instance
1705
+ * @param {type} type - The type of validation max and min
1706
+ * @param {value} value - The current component value
1707
+ * @param {forFocus} forFocus - Whether the component is focused or not
1708
+ * @returns {string} - The messsage string
1709
+ */
1710
+ function getScreenReaderMessage(component, type, value) {
1711
+ const isWordType = type === "word";
1712
+ const maxKey = typeof value === "string" && (type === "char" || isWordType)
1713
+ ? `validate.max${TYPES.get(type)}`
1714
+ : "validate.max";
1715
+ const minKey = typeof value === "string" && (type === "char" || isWordType)
1716
+ ? `validate.min${TYPES.get(type)}`
1717
+ : "validate.min";
1718
+ const max = lodash_1.default.parseInt(lodash_1.default.get(component.component, maxKey), 10);
1719
+ const min = lodash_1.default.parseInt(lodash_1.default.get(component.component, minKey), 10);
1720
+ let message = "";
1721
+ if (typeof value === "string") {
1722
+ const currentLength = isWordType ? component.getWordCount(value) : value.length;
1723
+ if (!isNaN(max)) {
1724
+ const remains = max - currentLength;
1725
+ if (value) {
1726
+ const threshold = REMAIN_COUNT.get(type) || max;
1727
+ if (remains > 0 && remains < threshold) {
1728
+ message += `${remains} ${getWordOrCharacterLabel(isWordType, remains)} remaining. `;
1729
+ }
1730
+ else if (remains < 0) {
1731
+ const removeCount = Math.abs(remains);
1732
+ message += `${removeCount} ${getWordOrCharacterLabel(isWordType, removeCount)} should be removed. `;
1733
+ }
1734
+ else if (remains === 0) {
1735
+ message += `No ${getWordOrCharacterLabel(isWordType, 0)} remaining.`;
1736
+ }
1737
+ }
1738
+ else {
1739
+ message += `Maximum ${max} ${getWordOrCharacterLabel(isWordType, max)}. `;
1740
+ }
1741
+ }
1742
+ if (!isNaN(min)) {
1743
+ if (value) {
1744
+ const remains = min - currentLength;
1745
+ if (remains > 0) {
1746
+ message += `${remains} ${getWordOrCharacterLabel(isWordType, remains)} should be added.`;
1747
+ }
1748
+ if (remains === 0) {
1749
+ message += ``;
1750
+ }
1751
+ }
1752
+ else {
1753
+ message += `Minimum ${min} ${getWordOrCharacterLabel(isWordType, min)}. `;
1754
+ }
1755
+ }
1756
+ }
1757
+ else if (typeof value === "number" || value === null) {
1758
+ if (value != null && value !== "") {
1759
+ if (!isNaN(max) && value > max) {
1760
+ message += `Number cannot be greater than ${max}. `;
1761
+ }
1762
+ if (!isNaN(min) && value < min) {
1763
+ message += `Number cannot be less than ${min}.`;
1764
+ }
1765
+ }
1766
+ else {
1767
+ if (!isNaN(min))
1768
+ message += `Minimum value ${min}. `;
1769
+ if (!isNaN(max))
1770
+ message += `Maximum value ${max}. `;
1771
+ }
1772
+ }
1773
+ return message.trim();
1774
+ }
1775
+ /**
1776
+ * The function for announcing messages via a screen reader
1777
+ * @param {component} component - The component instance
1778
+ * @param {value} value - The current component value
1779
+ * @param {index} index - The component index
1780
+ * @param {forFocus} forFocus - Whether the component is focused or not
1781
+ * @returns {undefined}
1782
+ */
1783
+ function announceScreenReaderMessage(component, value, index = 0, forFocus = false) {
1784
+ if (typeof value !== "string" && typeof value !== "number" && value !== null) {
1785
+ return;
1786
+ }
1787
+ // The ref for announcing messages
1788
+ const messageSpan = "announceMessage";
1789
+ if (!component.refs[messageSpan])
1790
+ return;
1791
+ const el = component.refs[messageSpan][index];
1792
+ if (!el)
1793
+ return;
1794
+ // Define types for validation
1795
+ const typesToCheck = [];
1796
+ if (typeof value === "string")
1797
+ typesToCheck.push("char", "word");
1798
+ if (typeof value === "number" || value === null)
1799
+ typesToCheck.push("number");
1800
+ // Construct the combined message
1801
+ const combinedMessage = typesToCheck
1802
+ .map(type => getScreenReaderMessage(component, type, value))
1803
+ .filter(msg => msg)
1804
+ .join(" ")
1805
+ .trim();
1806
+ if (forFocus) {
1807
+ setTimeout(() => {
1808
+ el.textContent = "";
1809
+ requestAnimationFrame(() => {
1810
+ el.textContent = combinedMessage;
1811
+ });
1812
+ }, 150);
1813
+ return;
1814
+ }
1815
+ clearTimeout(el._announceTimer);
1816
+ el._announceTimer = setTimeout(() => {
1817
+ el.textContent = "";
1818
+ requestAnimationFrame(() => {
1819
+ el.textContent = combinedMessage;
1820
+ });
1821
+ }, 500);
1822
+ }
1823
+ exports.announceScreenReaderMessage = announceScreenReaderMessage;
1694
1824
  /**
1695
1825
  * Outputs text to screen reader
1696
1826
  * @param {string} text The text to output to screen readers
@@ -452,7 +452,8 @@ class CalendarWidget extends InputWidget_1.default {
452
452
  // If other fields are used to calculate disabled dates, we need to redraw calendar to refresh disabled dates
453
453
  if (this.settings.disableFunction && this.componentInstance && this.componentInstance.root) {
454
454
  this.changeHandler = (e) => {
455
- if (e.changed && this.calendar) {
455
+ var _a;
456
+ if (e.changed && ((_a = this.calendar) === null || _a === void 0 ? void 0 : _a.config)) {
456
457
  this.calendar.redraw();
457
458
  }
458
459
  };
package/lib/mjs/Embed.js CHANGED
@@ -14,7 +14,7 @@ export class Formio {
14
14
  Formio._formioReady = ready;
15
15
  Formio._formioReadyReject = reject;
16
16
  });
17
- static version = '5.3.0';
17
+ static version = '5.3.1';
18
18
  static setLicense(license, norecurse = false) {
19
19
  Formio.license = license;
20
20
  if (!norecurse && Formio.FormioClass) {
package/lib/mjs/Formio.js CHANGED
@@ -4,7 +4,7 @@ import CDN from './CDN';
4
4
  import Providers from './providers';
5
5
  FormioCore.cdn = new CDN();
6
6
  FormioCore.Providers = Providers;
7
- FormioCore.version = '5.3.0';
7
+ FormioCore.version = '5.3.1';
8
8
  CDN.defaultCDN = FormioCore.version.includes('rc')
9
9
  ? 'https://cdn.test-form.io'
10
10
  : 'https://cdn.form.io';
package/lib/mjs/PDF.js CHANGED
@@ -279,7 +279,15 @@ if (typeof window !== 'undefined') {
279
279
  eventData.name &&
280
280
  eventData.formId &&
281
281
  Formio.forms.hasOwnProperty(eventData.formId)) {
282
- Formio.forms[eventData.formId].emit(`iframe-${eventData.name}`, eventData.data);
282
+ if (eventData.compPath) {
283
+ const comp = Formio.forms[eventData.formId].getComponent(eventData.compPath);
284
+ if (comp) {
285
+ comp.emit(eventData.name, eventData.data);
286
+ }
287
+ }
288
+ else {
289
+ Formio.forms[eventData.formId].emit(`iframe-${eventData.name}`, eventData.data);
290
+ }
283
291
  }
284
292
  });
285
293
  }
@@ -227,7 +227,7 @@ export default class Webform extends NestedDataComponent {
227
227
  if (err) {
228
228
  return;
229
229
  }
230
- this.rebuild();
230
+ this.redraw();
231
231
  this.emit('languageChanged');
232
232
  });
233
233
  }