@formio/js 5.0.0-dev.5584.9c8ee6a → 5.0.0-dev.5586.9e84922

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.
@@ -291,12 +291,19 @@ class Webform extends NestedDataComponent_1.default {
291
291
  // Set language after everything is established.
292
292
  this.language = this.i18next.language;
293
293
  // See if we need to restore the draft from a user.
294
- if (this.options.saveDraft && !this.options.skipDraftRestore) {
294
+ if (this.options.saveDraft) {
295
295
  this.formReady.then(() => {
296
- const user = Formio_1.Formio.getUser();
297
- // Only restore a draft if the submission isn't explicitly set.
298
- if (user && !this.submissionSet) {
299
- this.restoreDraft(user._id);
296
+ if (!this.options.skipDraftRestore) {
297
+ const user = Formio_1.Formio.getUser();
298
+ // Only restore a draft if the submission isn't explicitly set.
299
+ if (user && !this.submissionSet) {
300
+ this.restoreDraft(user._id);
301
+ }
302
+ }
303
+ else {
304
+ // Enable drafts
305
+ this.draftEnabled = true;
306
+ this.savingDraft = false;
300
307
  }
301
308
  });
302
309
  }
@@ -179,15 +179,8 @@ class CheckBoxComponent extends Field_1.default {
179
179
  return value;
180
180
  }
181
181
  setValue(value, flags = {}) {
182
- if (this.setCheckedState(value) !== undefined ||
183
- (!this.input && value !== undefined && (this.visible || this.conditionallyVisible() || !this.component.clearOnHide))) {
184
- const changed = this.updateValue(value, flags);
185
- if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
186
- this.redraw();
187
- }
188
- return changed;
189
- }
190
- return false;
182
+ this.setCheckedState(value);
183
+ return super.setValue(value, flags);
191
184
  }
192
185
  getValueAsString(value) {
193
186
  const { name: componentName, value: componentValue } = this.component;
@@ -0,0 +1,34 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ tableView: boolean;
10
+ validateWhenHidden: boolean;
11
+ key: string;
12
+ conditional: {
13
+ show: boolean;
14
+ conjunction: string;
15
+ conditions: {
16
+ component: string;
17
+ operator: string;
18
+ }[];
19
+ };
20
+ type: string;
21
+ input: boolean;
22
+ applyMaskOn?: undefined;
23
+ } | {
24
+ label: string;
25
+ applyMaskOn: string;
26
+ tableView: boolean;
27
+ key: string;
28
+ type: string;
29
+ input: boolean;
30
+ validateWhenHidden?: undefined;
31
+ conditional?: undefined;
32
+ })[];
33
+ }
34
+ export default _default;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ title: '7595',
5
+ name: '7595',
6
+ path: '7595',
7
+ type: 'form',
8
+ display: 'form',
9
+ components: [
10
+ {
11
+ label: 'Checkbox',
12
+ tableView: false,
13
+ validateWhenHidden: false,
14
+ key: 'checkboxBefore',
15
+ conditional: {
16
+ show: true,
17
+ conjunction: 'all',
18
+ conditions: [
19
+ {
20
+ component: 'textField',
21
+ operator: 'isNotEmpty'
22
+ }
23
+ ]
24
+ },
25
+ type: 'checkbox',
26
+ input: true
27
+ },
28
+ {
29
+ label: 'Text Field',
30
+ applyMaskOn: 'change',
31
+ tableView: true,
32
+ key: 'textField',
33
+ type: 'textfield',
34
+ input: true
35
+ },
36
+ {
37
+ label: 'Checkbox',
38
+ tableView: false,
39
+ validateWhenHidden: false,
40
+ key: 'checkboxAfter',
41
+ conditional: {
42
+ show: true,
43
+ conjunction: 'all',
44
+ conditions: [
45
+ {
46
+ component: 'textField',
47
+ operator: 'isNotEmpty'
48
+ }
49
+ ]
50
+ },
51
+ type: 'checkbox',
52
+ input: true
53
+ },
54
+ ]
55
+ };
@@ -2,5 +2,6 @@ import comp1 from './comp1';
2
2
  import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
+ import comp5 from './comp5';
5
6
  import customDefaultComponent from './customDefaultComponent';
6
- export { comp1, comp2, comp3, comp4, customDefaultComponent };
7
+ export { comp1, comp2, comp3, comp4, comp5, customDefaultComponent };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.customDefaultComponent = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.customDefaultComponent = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const customDefaultComponent_1 = __importDefault(require("./customDefaultComponent"));
@@ -14,3 +14,5 @@ const comp3_1 = __importDefault(require("./comp3"));
14
14
  exports.comp3 = comp3_1.default;
15
15
  const comp4_1 = __importDefault(require("./comp4"));
16
16
  exports.comp4 = comp4_1.default;
17
+ const comp5_1 = __importDefault(require("./comp5"));
18
+ exports.comp5 = comp5_1.default;
@@ -71,7 +71,7 @@ export default class RadioComponent extends ListComponent {
71
71
  detach(element: any): void;
72
72
  validateValueProperty(): boolean;
73
73
  validateValueAvailability(setting: any, value: any): boolean;
74
- getValueAsString(value: any): any;
74
+ getValueAsString(value: any, options?: {}): any;
75
75
  setValueAt(index: any, value: any): void;
76
76
  loadItems(url: any, search: any, headers: any, options: any, method: any, body: any): void;
77
77
  loadItemsFromMetadata(): void;
@@ -226,17 +226,19 @@ class RadioComponent extends ListComponent_1.default {
226
226
  }
227
227
  return false;
228
228
  }
229
- getValueAsString(value) {
229
+ getValueAsString(value, options = {}) {
230
230
  if (lodash_1.default.isObject(value)) {
231
231
  value = JSON.stringify(value);
232
232
  }
233
233
  else if (!lodash_1.default.isString(value)) {
234
234
  value = lodash_1.default.toString(value);
235
235
  }
236
- if (this.component.dataSrc !== 'values') {
236
+ const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
237
+ if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
237
238
  return value;
238
239
  }
239
- const option = lodash_1.default.find(this.component.values, (v) => v.value === value);
240
+ const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
241
+ const option = lodash_1.default.find(values, (v) => v.value === value);
240
242
  if (!value) {
241
243
  return lodash_1.default.get(option, 'label', '');
242
244
  }
@@ -1470,6 +1470,10 @@ class SelectComponent extends ListComponent_1.default {
1470
1470
  asString(value, options = {}) {
1471
1471
  var _a;
1472
1472
  value = value !== null && value !== void 0 ? value : this.getValue();
1473
+ if (options.modalPreview && this.selectData) {
1474
+ const { label } = this.selectValueAndLabel(value);
1475
+ return label;
1476
+ }
1473
1477
  //need to convert values to strings to be able to compare values with available options that are strings
1474
1478
  const convertToString = (data, valueProperty) => {
1475
1479
  if (valueProperty) {
@@ -164,11 +164,14 @@ class SelectBoxesComponent extends Radio_1.default {
164
164
  }
165
165
  return changed;
166
166
  }
167
- getValueAsString(value) {
167
+ getValueAsString(value, options = {}) {
168
168
  if (!value) {
169
169
  return '';
170
170
  }
171
171
  if (this.isSelectURL) {
172
+ if (options.modalPreview && this.loadedOptions) {
173
+ return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
174
+ }
172
175
  return (0, lodash_1.default)(value).pickBy((val) => val).keys().join(', ');
173
176
  }
174
177
  return (0, lodash_1.default)(this.component.values || [])
@@ -263,12 +263,19 @@ export default class Webform extends NestedDataComponent {
263
263
  // Set language after everything is established.
264
264
  this.language = this.i18next.language;
265
265
  // See if we need to restore the draft from a user.
266
- if (this.options.saveDraft && !this.options.skipDraftRestore) {
266
+ if (this.options.saveDraft) {
267
267
  this.formReady.then(() => {
268
- const user = Formio.getUser();
269
- // Only restore a draft if the submission isn't explicitly set.
270
- if (user && !this.submissionSet) {
271
- this.restoreDraft(user._id);
268
+ if (!this.options.skipDraftRestore) {
269
+ const user = Formio.getUser();
270
+ // Only restore a draft if the submission isn't explicitly set.
271
+ if (user && !this.submissionSet) {
272
+ this.restoreDraft(user._id);
273
+ }
274
+ }
275
+ else {
276
+ // Enable drafts
277
+ this.draftEnabled = true;
278
+ this.savingDraft = false;
272
279
  }
273
280
  });
274
281
  }
@@ -178,15 +178,8 @@ export default class CheckBoxComponent extends Field {
178
178
  return value;
179
179
  }
180
180
  setValue(value, flags = {}) {
181
- if (this.setCheckedState(value) !== undefined ||
182
- (!this.input && value !== undefined && (this.visible || this.conditionallyVisible() || !this.component.clearOnHide))) {
183
- const changed = this.updateValue(value, flags);
184
- if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
185
- this.redraw();
186
- }
187
- return changed;
188
- }
189
- return false;
181
+ this.setCheckedState(value);
182
+ return super.setValue(value, flags);
190
183
  }
191
184
  getValueAsString(value) {
192
185
  const { name: componentName, value: componentValue } = this.component;
@@ -0,0 +1,34 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ tableView: boolean;
10
+ validateWhenHidden: boolean;
11
+ key: string;
12
+ conditional: {
13
+ show: boolean;
14
+ conjunction: string;
15
+ conditions: {
16
+ component: string;
17
+ operator: string;
18
+ }[];
19
+ };
20
+ type: string;
21
+ input: boolean;
22
+ applyMaskOn?: undefined;
23
+ } | {
24
+ label: string;
25
+ applyMaskOn: string;
26
+ tableView: boolean;
27
+ key: string;
28
+ type: string;
29
+ input: boolean;
30
+ validateWhenHidden?: undefined;
31
+ conditional?: undefined;
32
+ })[];
33
+ }
34
+ export default _default;
@@ -0,0 +1,53 @@
1
+ export default {
2
+ title: '7595',
3
+ name: '7595',
4
+ path: '7595',
5
+ type: 'form',
6
+ display: 'form',
7
+ components: [
8
+ {
9
+ label: 'Checkbox',
10
+ tableView: false,
11
+ validateWhenHidden: false,
12
+ key: 'checkboxBefore',
13
+ conditional: {
14
+ show: true,
15
+ conjunction: 'all',
16
+ conditions: [
17
+ {
18
+ component: 'textField',
19
+ operator: 'isNotEmpty'
20
+ }
21
+ ]
22
+ },
23
+ type: 'checkbox',
24
+ input: true
25
+ },
26
+ {
27
+ label: 'Text Field',
28
+ applyMaskOn: 'change',
29
+ tableView: true,
30
+ key: 'textField',
31
+ type: 'textfield',
32
+ input: true
33
+ },
34
+ {
35
+ label: 'Checkbox',
36
+ tableView: false,
37
+ validateWhenHidden: false,
38
+ key: 'checkboxAfter',
39
+ conditional: {
40
+ show: true,
41
+ conjunction: 'all',
42
+ conditions: [
43
+ {
44
+ component: 'textField',
45
+ operator: 'isNotEmpty'
46
+ }
47
+ ]
48
+ },
49
+ type: 'checkbox',
50
+ input: true
51
+ },
52
+ ]
53
+ };
@@ -2,5 +2,6 @@ import comp1 from './comp1';
2
2
  import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
+ import comp5 from './comp5';
5
6
  import customDefaultComponent from './customDefaultComponent';
6
- export { comp1, comp2, comp3, comp4, customDefaultComponent };
7
+ export { comp1, comp2, comp3, comp4, comp5, customDefaultComponent };
@@ -3,4 +3,5 @@ import customDefaultComponent from './customDefaultComponent';
3
3
  import comp2 from './comp2';
4
4
  import comp3 from './comp3';
5
5
  import comp4 from './comp4';
6
- export { comp1, comp2, comp3, comp4, customDefaultComponent };
6
+ import comp5 from './comp5';
7
+ export { comp1, comp2, comp3, comp4, comp5, customDefaultComponent };
@@ -71,7 +71,7 @@ export default class RadioComponent extends ListComponent {
71
71
  detach(element: any): void;
72
72
  validateValueProperty(): boolean;
73
73
  validateValueAvailability(setting: any, value: any): boolean;
74
- getValueAsString(value: any): any;
74
+ getValueAsString(value: any, options?: {}): any;
75
75
  setValueAt(index: any, value: any): void;
76
76
  loadItems(url: any, search: any, headers: any, options: any, method: any, body: any): void;
77
77
  loadItemsFromMetadata(): void;
@@ -226,17 +226,19 @@ export default class RadioComponent extends ListComponent {
226
226
  }
227
227
  return false;
228
228
  }
229
- getValueAsString(value) {
229
+ getValueAsString(value, options = {}) {
230
230
  if (_.isObject(value)) {
231
231
  value = JSON.stringify(value);
232
232
  }
233
233
  else if (!_.isString(value)) {
234
234
  value = _.toString(value);
235
235
  }
236
- if (this.component.dataSrc !== 'values') {
236
+ const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
237
+ if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
237
238
  return value;
238
239
  }
239
- const option = _.find(this.component.values, (v) => v.value === value);
240
+ const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
241
+ const option = _.find(values, (v) => v.value === value);
240
242
  if (!value) {
241
243
  return _.get(option, 'label', '');
242
244
  }
@@ -1495,6 +1495,10 @@ export default class SelectComponent extends ListComponent {
1495
1495
  }
1496
1496
  asString(value, options = {}) {
1497
1497
  value = value ?? this.getValue();
1498
+ if (options.modalPreview && this.selectData) {
1499
+ const { label } = this.selectValueAndLabel(value);
1500
+ return label;
1501
+ }
1498
1502
  //need to convert values to strings to be able to compare values with available options that are strings
1499
1503
  const convertToString = (data, valueProperty) => {
1500
1504
  if (valueProperty) {
@@ -162,11 +162,14 @@ export default class SelectBoxesComponent extends RadioComponent {
162
162
  }
163
163
  return changed;
164
164
  }
165
- getValueAsString(value) {
165
+ getValueAsString(value, options = {}) {
166
166
  if (!value) {
167
167
  return '';
168
168
  }
169
169
  if (this.isSelectURL) {
170
+ if (options.modalPreview && this.loadedOptions) {
171
+ return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
172
+ }
170
173
  return _(value).pickBy((val) => val).keys().join(', ');
171
174
  }
172
175
  return _(this.component.values || [])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5584.9c8ee6a",
3
+ "version": "5.0.0-dev.5586.9e84922",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {