@formio/js 5.2.3 → 5.2.4

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 (66) 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 +22 -22
  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 +24 -24
  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 +3 -3
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +1 -1
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  16. package/lib/cjs/Element.js +6 -3
  17. package/lib/cjs/Embed.js +3 -2
  18. package/lib/cjs/Formio.js +1 -1
  19. package/lib/cjs/Webform.js +4 -2
  20. package/lib/cjs/WebformBuilder.js +8 -4
  21. package/lib/cjs/Wizard.js +3 -3
  22. package/lib/cjs/components/_classes/component/Component.js +19 -11
  23. package/lib/cjs/components/address/Address.js +7 -5
  24. package/lib/cjs/components/button/Button.js +21 -15
  25. package/lib/cjs/components/datagrid/DataGrid.js +6 -5
  26. package/lib/cjs/components/datamap/DataMap.js +4 -2
  27. package/lib/cjs/components/day/Day.js +2 -1
  28. package/lib/cjs/components/editgrid/EditGrid.js +10 -8
  29. package/lib/cjs/components/file/File.js +11 -6
  30. package/lib/cjs/components/file/editForm/File.edit.file.d.ts +37 -16
  31. package/lib/cjs/components/file/editForm/File.edit.file.js +78 -25
  32. package/lib/cjs/components/form/Form.js +10 -4
  33. package/lib/cjs/components/radio/Radio.js +6 -3
  34. package/lib/cjs/components/recaptcha/ReCaptcha.js +5 -3
  35. package/lib/cjs/components/select/Select.js +12 -1
  36. package/lib/cjs/components/selectboxes/SelectBoxes.js +5 -2
  37. package/lib/cjs/components/signature/Signature.js +2 -1
  38. package/lib/cjs/components/table/Table.js +2 -1
  39. package/lib/cjs/components/tabs/Tabs.js +2 -1
  40. package/lib/cjs/package.json +1 -1
  41. package/lib/mjs/Element.js +3 -3
  42. package/lib/mjs/Embed.js +2 -2
  43. package/lib/mjs/Formio.js +1 -1
  44. package/lib/mjs/Webform.js +2 -2
  45. package/lib/mjs/WebformBuilder.js +4 -4
  46. package/lib/mjs/Wizard.js +1 -1
  47. package/lib/mjs/components/_classes/component/Component.js +10 -10
  48. package/lib/mjs/components/address/Address.js +3 -3
  49. package/lib/mjs/components/button/Button.js +15 -15
  50. package/lib/mjs/components/datagrid/DataGrid.js +4 -4
  51. package/lib/mjs/components/datamap/DataMap.js +2 -2
  52. package/lib/mjs/components/day/Day.js +1 -1
  53. package/lib/mjs/components/editgrid/EditGrid.js +5 -5
  54. package/lib/mjs/components/file/File.js +6 -6
  55. package/lib/mjs/components/file/editForm/File.edit.file.d.ts +37 -16
  56. package/lib/mjs/components/file/editForm/File.edit.file.js +78 -25
  57. package/lib/mjs/components/form/Form.js +7 -4
  58. package/lib/mjs/components/radio/Radio.js +3 -3
  59. package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -3
  60. package/lib/mjs/components/select/Select.js +12 -1
  61. package/lib/mjs/components/selectboxes/SelectBoxes.js +4 -2
  62. package/lib/mjs/components/signature/Signature.js +1 -1
  63. package/lib/mjs/components/table/Table.js +1 -1
  64. package/lib/mjs/components/tabs/Tabs.js +1 -1
  65. package/lib/mjs/package.json +1 -1
  66. package/package.json +2 -2
@@ -17,6 +17,7 @@ declare const _default: ({
17
17
  rows?: undefined;
18
18
  editor?: undefined;
19
19
  as?: undefined;
20
+ logic?: undefined;
20
21
  optionsLabelPosition?: undefined;
21
22
  inline?: undefined;
22
23
  defaultValue?: undefined;
@@ -33,7 +34,6 @@ declare const _default: ({
33
34
  var: string;
34
35
  })[];
35
36
  in?: undefined;
36
- '!=='?: undefined;
37
37
  '=='?: undefined;
38
38
  };
39
39
  };
@@ -47,6 +47,7 @@ declare const _default: ({
47
47
  rows?: undefined;
48
48
  editor?: undefined;
49
49
  as?: undefined;
50
+ logic?: undefined;
50
51
  optionsLabelPosition?: undefined;
51
52
  inline?: undefined;
52
53
  defaultValue?: undefined;
@@ -81,7 +82,6 @@ declare const _default: ({
81
82
  var: string;
82
83
  })[];
83
84
  in?: undefined;
84
- '!=='?: undefined;
85
85
  '=='?: undefined;
86
86
  };
87
87
  };
@@ -94,6 +94,7 @@ declare const _default: ({
94
94
  rows?: undefined;
95
95
  editor?: undefined;
96
96
  as?: undefined;
97
+ logic?: undefined;
97
98
  optionsLabelPosition?: undefined;
98
99
  inline?: undefined;
99
100
  defaultValue?: undefined;
@@ -112,7 +113,6 @@ declare const _default: ({
112
113
  var: string;
113
114
  })[];
114
115
  in?: undefined;
115
- '!=='?: undefined;
116
116
  '=='?: undefined;
117
117
  };
118
118
  };
@@ -124,6 +124,7 @@ declare const _default: ({
124
124
  rows?: undefined;
125
125
  editor?: undefined;
126
126
  as?: undefined;
127
+ logic?: undefined;
127
128
  optionsLabelPosition?: undefined;
128
129
  inline?: undefined;
129
130
  defaultValue?: undefined;
@@ -141,7 +142,6 @@ declare const _default: ({
141
142
  var: string;
142
143
  })[];
143
144
  '==='?: undefined;
144
- '!=='?: undefined;
145
145
  '=='?: undefined;
146
146
  };
147
147
  };
@@ -154,6 +154,7 @@ declare const _default: ({
154
154
  rows?: undefined;
155
155
  editor?: undefined;
156
156
  as?: undefined;
157
+ logic?: undefined;
157
158
  optionsLabelPosition?: undefined;
158
159
  inline?: undefined;
159
160
  defaultValue?: undefined;
@@ -175,7 +176,6 @@ declare const _default: ({
175
176
  var: string;
176
177
  })[];
177
178
  in?: undefined;
178
- '!=='?: undefined;
179
179
  '=='?: undefined;
180
180
  };
181
181
  };
@@ -184,6 +184,7 @@ declare const _default: ({
184
184
  data?: undefined;
185
185
  tableView?: undefined;
186
186
  components?: undefined;
187
+ logic?: undefined;
187
188
  optionsLabelPosition?: undefined;
188
189
  inline?: undefined;
189
190
  defaultValue?: undefined;
@@ -196,19 +197,35 @@ declare const _default: ({
196
197
  placeholder: string;
197
198
  tooltip: string;
198
199
  weight: number;
199
- conditional: {
200
- json: {
201
- '!==': (string | {
202
- var: string;
203
- })[];
204
- '==='?: undefined;
205
- in?: undefined;
206
- '=='?: undefined;
200
+ logic: {
201
+ name: string;
202
+ trigger: {
203
+ type: string;
204
+ simple: {
205
+ show: boolean;
206
+ conjunction: string;
207
+ conditions: {
208
+ component: string;
209
+ operator: string;
210
+ value: string;
211
+ }[];
212
+ };
207
213
  };
208
- };
214
+ actions: {
215
+ name: string;
216
+ type: string;
217
+ property: {
218
+ label: string;
219
+ value: string;
220
+ type: string;
221
+ };
222
+ text: string;
223
+ }[];
224
+ }[];
209
225
  valueProperty?: undefined;
210
226
  dataSrc?: undefined;
211
227
  data?: undefined;
228
+ conditional?: undefined;
212
229
  tableView?: undefined;
213
230
  components?: undefined;
214
231
  rows?: undefined;
@@ -235,6 +252,7 @@ declare const _default: ({
235
252
  rows?: undefined;
236
253
  editor?: undefined;
237
254
  as?: undefined;
255
+ logic?: undefined;
238
256
  optionsLabelPosition?: undefined;
239
257
  inline?: undefined;
240
258
  defaultValue?: undefined;
@@ -256,6 +274,7 @@ declare const _default: ({
256
274
  rows?: undefined;
257
275
  editor?: undefined;
258
276
  as?: undefined;
277
+ logic?: undefined;
259
278
  optionsLabelPosition?: undefined;
260
279
  inline?: undefined;
261
280
  defaultValue?: undefined;
@@ -273,7 +292,6 @@ declare const _default: ({
273
292
  var: string;
274
293
  })[];
275
294
  in?: undefined;
276
- '!=='?: undefined;
277
295
  '=='?: undefined;
278
296
  };
279
297
  };
@@ -286,6 +304,7 @@ declare const _default: ({
286
304
  rows?: undefined;
287
305
  editor?: undefined;
288
306
  as?: undefined;
307
+ logic?: undefined;
289
308
  optionsLabelPosition?: undefined;
290
309
  inline?: undefined;
291
310
  defaultValue?: undefined;
@@ -305,7 +324,6 @@ declare const _default: ({
305
324
  })[];
306
325
  '==='?: undefined;
307
326
  in?: undefined;
308
- '!=='?: undefined;
309
327
  };
310
328
  };
311
329
  valueProperty?: undefined;
@@ -316,6 +334,7 @@ declare const _default: ({
316
334
  rows?: undefined;
317
335
  editor?: undefined;
318
336
  as?: undefined;
337
+ logic?: undefined;
319
338
  optionsLabelPosition?: undefined;
320
339
  inline?: undefined;
321
340
  defaultValue?: undefined;
@@ -344,6 +363,7 @@ declare const _default: ({
344
363
  rows?: undefined;
345
364
  editor?: undefined;
346
365
  as?: undefined;
366
+ logic?: undefined;
347
367
  } | {
348
368
  type: string;
349
369
  input: boolean;
@@ -366,6 +386,7 @@ declare const _default: ({
366
386
  rows?: undefined;
367
387
  editor?: undefined;
368
388
  as?: undefined;
389
+ logic?: undefined;
369
390
  optionsLabelPosition?: undefined;
370
391
  inline?: undefined;
371
392
  defaultValue?: undefined;
@@ -147,8 +147,7 @@ export default [
147
147
  }, 'url']
148
148
  }
149
149
  }
150
- },
151
- {
150
+ }, {
152
151
  type: 'textfield',
153
152
  input: true,
154
153
  key: 'dir',
@@ -156,29 +155,83 @@ export default [
156
155
  placeholder: '(optional) Enter a directory for the files',
157
156
  tooltip: 'This will place all the files uploaded in this field in the directory',
158
157
  weight: 20,
159
- conditional: {
160
- json: {
161
- '!==': [{
162
- var: 'data.storage'
163
- }, 'googledrive']
164
- }
165
- }
166
- },
167
- {
168
- type: 'textfield',
169
- input: true,
170
- key: 'dir',
171
- label: 'Folder ID',
172
- placeholder: '(optional) Enter an ID of the folder for the files',
173
- tooltip: 'This will place all the files uploaded in this field in the folder',
174
- weight: 20,
175
- conditional: {
176
- json: {
177
- '===': [{
178
- var: 'data.storage'
179
- }, 'googledrive']
180
- }
181
- }
158
+ logic: [
159
+ {
160
+ name: 'Change To File ID',
161
+ trigger: {
162
+ type: 'simple',
163
+ simple: {
164
+ show: true,
165
+ conjunction: 'all',
166
+ conditions: [
167
+ {
168
+ component: 'storage',
169
+ operator: 'isEqual',
170
+ value: 'googledrive',
171
+ },
172
+ ],
173
+ },
174
+ },
175
+ actions: [
176
+ {
177
+ name: 'Change placeholder',
178
+ type: 'property',
179
+ property: {
180
+ label: 'Placeholder',
181
+ value: 'placeholder',
182
+ type: 'string',
183
+ },
184
+ text: '(optional) Enter an ID of the folder for the files',
185
+ }, {
186
+ name: 'Change label',
187
+ type: 'property',
188
+ property: {
189
+ label: 'Label',
190
+ value: 'label',
191
+ type: 'string',
192
+ },
193
+ text: 'Folder ID',
194
+ },
195
+ ],
196
+ }, {
197
+ name: 'Change to Directory',
198
+ trigger: {
199
+ type: 'simple',
200
+ simple: {
201
+ show: true,
202
+ conjunction: 'all',
203
+ conditions: [
204
+ {
205
+ component: 'storage',
206
+ operator: 'isNotEqual',
207
+ value: 'googledrive',
208
+ },
209
+ ],
210
+ },
211
+ },
212
+ actions: [
213
+ {
214
+ name: 'Change placeholder',
215
+ type: 'property',
216
+ property: {
217
+ label: 'Placeholder',
218
+ value: 'placeholder',
219
+ type: 'string',
220
+ },
221
+ text: '(optional) Enter a directory for the files',
222
+ }, {
223
+ name: 'Change label',
224
+ type: 'property',
225
+ property: {
226
+ label: 'Label',
227
+ value: 'label',
228
+ type: 'string',
229
+ },
230
+ text: 'Directory',
231
+ },
232
+ ],
233
+ },
234
+ ],
182
235
  },
183
236
  {
184
237
  type: 'textfield',
@@ -298,7 +298,7 @@ export default class FormComponent extends Component {
298
298
  };
299
299
  if (this.subForm) {
300
300
  if (this.isNestedWizard) {
301
- element = this.root.element;
301
+ element = this.root?.element;
302
302
  }
303
303
  return this.subForm.attach(element).then(() => {
304
304
  this.valueChanged = this.hasSetValue;
@@ -428,7 +428,7 @@ export default class FormComponent extends Component {
428
428
  this.subForm.on('change', () => {
429
429
  if (this.subForm && !this.shouldConditionallyClear()) {
430
430
  this.dataValue = this.subForm.getValue();
431
- this.triggerChange({
431
+ this.triggerChange?.({
432
432
  noEmit: true
433
433
  });
434
434
  }
@@ -538,7 +538,10 @@ export default class FormComponent extends Component {
538
538
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
539
539
  */
540
540
  get shouldSubmit() {
541
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.shouldConditionallyClear();
541
+ return (this.subFormReady &&
542
+ (!this.component.hasOwnProperty('reference') || this.component.reference) &&
543
+ !this.shouldConditionallyClear() &&
544
+ !(this.component.hidden && this.component.clearOnHide));
542
545
  }
543
546
  /**
544
547
  * Returns the data for the subform.
@@ -746,7 +749,7 @@ export default class FormComponent extends Component {
746
749
  isNestedWizard ? this.rebuild() : this.redraw();
747
750
  }
748
751
  if (!value && isNestedWizard) {
749
- this.root.redraw();
752
+ this.root?.redraw();
750
753
  }
751
754
  }
752
755
  get parentVisible() {
@@ -348,7 +348,7 @@ export default class RadioComponent extends ListComponent {
348
348
  }
349
349
  });
350
350
  if (this.isSelectURL) {
351
- const submission = this.root.submission;
351
+ const submission = this.root?.submission;
352
352
  if (!submission.metadata) {
353
353
  submission.metadata = {};
354
354
  }
@@ -395,7 +395,7 @@ export default class RadioComponent extends ListComponent {
395
395
  const shouldResetValue = flags && flags.modified && !flags.noUpdateEvent && this.previousValue === this.currentValue;
396
396
  if (shouldResetValue) {
397
397
  this.resetValue();
398
- this.triggerChange(flags);
398
+ this.triggerChange?.(flags);
399
399
  this.setSelectedClasses();
400
400
  }
401
401
  this.previousValue = this.dataValue;
@@ -439,7 +439,7 @@ export default class RadioComponent extends ListComponent {
439
439
  break;
440
440
  }
441
441
  if (this.isSelectURL && this.templateData && this.templateData[value]) {
442
- const submission = this.root.submission;
442
+ const submission = this.root?.submission;
443
443
  if (!submission.metadata.selectData) {
444
444
  submission.metadata.selectData = {};
445
445
  }
@@ -41,7 +41,7 @@ export default class ReCaptchaComponent extends Component {
41
41
  this.append(this.text(this.name));
42
42
  }
43
43
  else {
44
- const siteKey = _get(this.root.form, 'settings.recaptcha.siteKey');
44
+ const siteKey = _get(this.root?.form, 'settings.recaptcha.siteKey');
45
45
  if (siteKey) {
46
46
  const recaptchaApiScriptUrl = `https://www.google.com/recaptcha/api.js?render=${siteKey}`;
47
47
  this.recaptchaApiReady = Formio.requireLibrary('googleRecaptcha', 'grecaptcha', recaptchaApiScriptUrl, true);
@@ -58,13 +58,13 @@ export default class ReCaptchaComponent extends Component {
58
58
  return true;
59
59
  }
60
60
  async verify(actionName) {
61
- const siteKey = _get(this.root.form, 'settings.recaptcha.siteKey');
61
+ const siteKey = _get(this.root?.form, 'settings.recaptcha.siteKey');
62
62
  if (!siteKey) {
63
63
  console.warn('There is no Site Key specified in settings in form JSON');
64
64
  return;
65
65
  }
66
66
  if (!this.recaptchaApiReady) {
67
- const recaptchaApiScriptUrl = `https://www.google.com/recaptcha/api.js?render=${_get(this.root.form, 'settings.recaptcha.siteKey')}`;
67
+ const recaptchaApiScriptUrl = `https://www.google.com/recaptcha/api.js?render=${_get(this.root?.form, 'settings.recaptcha.siteKey')}`;
68
68
  this.recaptchaApiReady = Formio.requireLibrary('googleRecaptcha', 'grecaptcha', recaptchaApiScriptUrl, true);
69
69
  }
70
70
  try {
@@ -226,7 +226,14 @@ export default class SelectComponent extends ListComponent {
226
226
  return this.component.dataSrc === 'resource' && this.valueProperty === 'data';
227
227
  }
228
228
  selectValueAndLabel(data) {
229
- const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
229
+ let value;
230
+ // If the select is a resource reference, use the actual object value
231
+ if (this.component.reference && this.isSelectResource) {
232
+ value = this.getOptionValue(data);
233
+ }
234
+ else {
235
+ value = this.getOptionValue(this.isEntireObjectDisplay() && !this.itemValue(data) ? data : this.itemValue(data));
236
+ }
230
237
  return {
231
238
  value,
232
239
  label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : data, value)
@@ -265,6 +272,10 @@ export default class SelectComponent extends ListComponent {
265
272
  else {
266
273
  data = selectData;
267
274
  }
275
+ // use template data for reference fields to make sure the data is updated
276
+ if (this.component.reference && this.templateData[templateValue]) {
277
+ data = this.templateData[templateValue];
278
+ }
268
279
  }
269
280
  }
270
281
  if (typeof data === 'string' || typeof data === 'number') {
@@ -135,8 +135,10 @@ export default class SelectBoxesComponent extends RadioComponent {
135
135
  });
136
136
  }
137
137
  const checkedValues = _.keys(_.pickBy(value, (val) => val));
138
- if (this.isSelectURL && this.templateData && _.every(checkedValues, (val) => this.templateData[val])) {
139
- const submission = this.root.submission;
138
+ if (this.isSelectURL &&
139
+ this.templateData &&
140
+ _.every(checkedValues, (val) => this.templateData[val])) {
141
+ const submission = this.root?.submission;
140
142
  if (!submission.metadata.selectData) {
141
143
  submission.metadata.selectData = {};
142
144
  }
@@ -89,7 +89,7 @@ export default class SignatureComponent extends Input {
89
89
  this.signaturePad.clear();
90
90
  }
91
91
  else if (changed) {
92
- this.triggerChange();
92
+ this.triggerChange?.();
93
93
  }
94
94
  }
95
95
  if (this.signaturePad && this.dataValue && this.signaturePad.isEmpty()) {
@@ -120,7 +120,7 @@ export default class TableComponent extends NestedComponent {
120
120
  }
121
121
  else if (lastNonEmptyRow[colIndex]) {
122
122
  column.components = _.cloneDeep(lastNonEmptyRow[colIndex].components);
123
- BuilderUtils.uniquify(this.root._form.components, column);
123
+ BuilderUtils.uniquify(this.root?._form.components, column);
124
124
  }
125
125
  }
126
126
  _.each(column.components, (comp) => {
@@ -139,7 +139,7 @@ export default class TabsComponent extends NestedComponent {
139
139
  this.addClass(this.refs[this.tabLinkKey][index], 'formio-tab-link-active');
140
140
  }
141
141
  this.setValue(this.data);
142
- this.triggerChange();
142
+ this.triggerChange?.();
143
143
  }
144
144
  beforeFocus(component) {
145
145
  if ('beforeFocus' in this.parent) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "5.2.3"
3
+ "version": "5.2.4"
4
4
 
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.2.3",
3
+ "version": "5.2.4",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -92,7 +92,7 @@
92
92
  "uuid": "^9.0.0",
93
93
  "vanilla-picker": "^2.12.3",
94
94
  "@formio/bootstrap": "^3.1.3",
95
- "@formio/core": "^2.5.2"
95
+ "@formio/core": "^2.5.3"
96
96
  },
97
97
  "devDependencies": {
98
98
  "@types/node": "^22.15.19",