@formio/js 5.0.0-dev.5870.aa1e3d9 → 5.0.0-dev.5873.124778a

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.
package/lib/cjs/Wizard.js CHANGED
@@ -916,7 +916,7 @@ class Wizard extends Webform_1.default {
916
916
  const components = !currentPageOnly || this.isLastPage()
917
917
  ? this.getComponents()
918
918
  : this.currentPage.components;
919
- return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, childErrors) && check, true);
919
+ return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
920
920
  }
921
921
  get errors() {
922
922
  if (!this.isLastPage()) {
@@ -21,6 +21,7 @@ export default class RadioComponent extends ListComponent {
21
21
  get isRadio(): boolean;
22
22
  get optionSelectedClass(): string;
23
23
  get listData(): any;
24
+ get selectMetadata(): any;
24
25
  templateData: {} | undefined;
25
26
  triggerUpdate: ((...args: any[]) => any) | undefined;
26
27
  itemsLoadedResolve: ((value: any) => void) | undefined;
@@ -109,6 +109,12 @@ class RadioComponent extends ListComponent_1.default {
109
109
  const listData = lodash_1.default.get(this.root, 'submission.metadata.listData', {});
110
110
  return lodash_1.default.get(listData, this.path);
111
111
  }
112
+ get selectMetadata() {
113
+ return super.selectData;
114
+ }
115
+ get selectData() {
116
+ return this.selectMetadata || this.component.selectData;
117
+ }
112
118
  init() {
113
119
  super.init();
114
120
  this.templateData = {};
@@ -244,12 +250,15 @@ class RadioComponent extends ListComponent_1.default {
244
250
  else if (!lodash_1.default.isString(value)) {
245
251
  value = lodash_1.default.toString(value);
246
252
  }
247
- const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
248
- if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
253
+ const shouldUseSelectData = (options.modalPreview || this.inDataTable)
254
+ && this.component.dataSrc === 'url' && (this.loadedOptions.length || this.selectData);
255
+ if (this.component.dataSrc !== 'values' && !shouldUseSelectData) {
249
256
  return value;
250
257
  }
251
- const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
252
- const option = lodash_1.default.find(values, (v) => v.value === value);
258
+ const values = shouldUseSelectData ? this.loadedOptions : this.component.values;
259
+ const option = !(values === null || values === void 0 ? void 0 : values.length) && shouldUseSelectData ? {
260
+ label: this.itemTemplate(this.selectData),
261
+ } : lodash_1.default.find(values, (v) => v.value === value);
253
262
  if (!value) {
254
263
  return lodash_1.default.get(option, 'label', '');
255
264
  }
@@ -166,12 +166,19 @@ class SelectBoxesComponent extends Radio_1.default {
166
166
  return changed;
167
167
  }
168
168
  getValueAsString(value, options = {}) {
169
+ var _a, _b;
169
170
  if (!value) {
170
171
  return '';
171
172
  }
172
173
  if (this.isSelectURL) {
173
- if (options.modalPreview && this.loadedOptions) {
174
- return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
174
+ if (options.modalPreview || this.options.readOnly || this.inDataTable) {
175
+ const checkedItems = lodash_1.default.keys(lodash_1.default.pickBy(value, (val) => val));
176
+ if (((_a = this.selectData) === null || _a === void 0 ? void 0 : _a.length) === checkedItems.length) {
177
+ return this.selectData.map(item => this.itemTemplate(item)).join(', ');
178
+ }
179
+ else if ((_b = this.loadedOptions) === null || _b === void 0 ? void 0 : _b.length) {
180
+ return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
181
+ }
175
182
  }
176
183
  return (0, lodash_1.default)(value).pickBy((val) => val).keys().join(', ');
177
184
  }
@@ -20,10 +20,10 @@ export default class TextAreaComponent extends TextFieldComponent {
20
20
  setReadOnlyValue(value: any, index: any): void;
21
21
  get isJsonValue(): any;
22
22
  /**
23
- * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
24
- * @param {*} value - The value to normalize
25
- * @returns {*} - Returns the normalized value
26
- */
23
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
24
+ * @param {*} value - The value to normalize
25
+ * @returns {*} - Returns the normalized value
26
+ */
27
27
  normalizeValue(value: any): any;
28
28
  normalizeSingleValue(value: any): any;
29
29
  setConvertedValue(value: any, index: any): any;
@@ -310,10 +310,10 @@ class TextAreaComponent extends TextField_1.default {
310
310
  return this.component.as && this.component.as === 'json';
311
311
  }
312
312
  /**
313
- * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
314
- * @param {*} value - The value to normalize
315
- * @returns {*} - Returns the normalized value
316
- */
313
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
314
+ * @param {*} value - The value to normalize
315
+ * @returns {*} - Returns the normalized value
316
+ */
317
317
  normalizeValue(value) {
318
318
  if (this.component.multiple && Array.isArray(value)) {
319
319
  return value.map((singleValue) => this.normalizeSingleValue(singleValue));
package/lib/mjs/Wizard.js CHANGED
@@ -903,7 +903,7 @@ export default class Wizard extends Webform {
903
903
  const components = !currentPageOnly || this.isLastPage()
904
904
  ? this.getComponents()
905
905
  : this.currentPage.components;
906
- return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, childErrors) && check, true);
906
+ return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
907
907
  }
908
908
  get errors() {
909
909
  if (!this.isLastPage()) {
@@ -21,6 +21,7 @@ export default class RadioComponent extends ListComponent {
21
21
  get isRadio(): boolean;
22
22
  get optionSelectedClass(): string;
23
23
  get listData(): any;
24
+ get selectMetadata(): any;
24
25
  templateData: {} | undefined;
25
26
  triggerUpdate: ((...args: any[]) => any) | undefined;
26
27
  itemsLoadedResolve: ((value: any) => void) | undefined;
@@ -109,6 +109,12 @@ export default class RadioComponent extends ListComponent {
109
109
  const listData = _.get(this.root, 'submission.metadata.listData', {});
110
110
  return _.get(listData, this.path);
111
111
  }
112
+ get selectMetadata() {
113
+ return super.selectData;
114
+ }
115
+ get selectData() {
116
+ return this.selectMetadata || this.component.selectData;
117
+ }
112
118
  init() {
113
119
  super.init();
114
120
  this.templateData = {};
@@ -244,12 +250,15 @@ export default class RadioComponent extends ListComponent {
244
250
  else if (!_.isString(value)) {
245
251
  value = _.toString(value);
246
252
  }
247
- const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
248
- if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
253
+ const shouldUseSelectData = (options.modalPreview || this.inDataTable)
254
+ && this.component.dataSrc === 'url' && (this.loadedOptions.length || this.selectData);
255
+ if (this.component.dataSrc !== 'values' && !shouldUseSelectData) {
249
256
  return value;
250
257
  }
251
- const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
252
- const option = _.find(values, (v) => v.value === value);
258
+ const values = shouldUseSelectData ? this.loadedOptions : this.component.values;
259
+ const option = !values?.length && shouldUseSelectData ? {
260
+ label: this.itemTemplate(this.selectData),
261
+ } : _.find(values, (v) => v.value === value);
253
262
  if (!value) {
254
263
  return _.get(option, 'label', '');
255
264
  }
@@ -172,8 +172,14 @@ export default class SelectBoxesComponent extends RadioComponent {
172
172
  return '';
173
173
  }
174
174
  if (this.isSelectURL) {
175
- if (options.modalPreview && this.loadedOptions) {
176
- return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
175
+ if (options.modalPreview || this.options.readOnly || this.inDataTable) {
176
+ const checkedItems = _.keys(_.pickBy(value, (val) => val));
177
+ if (this.selectData?.length === checkedItems.length) {
178
+ return this.selectData.map(item => this.itemTemplate(item)).join(', ');
179
+ }
180
+ else if (this.loadedOptions?.length) {
181
+ return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
182
+ }
177
183
  }
178
184
  return _(value).pickBy((val) => val).keys().join(', ');
179
185
  }
@@ -20,10 +20,10 @@ export default class TextAreaComponent extends TextFieldComponent {
20
20
  setReadOnlyValue(value: any, index: any): void;
21
21
  get isJsonValue(): any;
22
22
  /**
23
- * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
24
- * @param {*} value - The value to normalize
25
- * @returns {*} - Returns the normalized value
26
- */
23
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
24
+ * @param {*} value - The value to normalize
25
+ * @returns {*} - Returns the normalized value
26
+ */
27
27
  normalizeValue(value: any): any;
28
28
  normalizeSingleValue(value: any): any;
29
29
  setConvertedValue(value: any, index: any): any;
@@ -305,10 +305,10 @@ export default class TextAreaComponent extends TextFieldComponent {
305
305
  return this.component.as && this.component.as === 'json';
306
306
  }
307
307
  /**
308
- * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
309
- * @param {*} value - The value to normalize
310
- * @returns {*} - Returns the normalized value
311
- */
308
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
309
+ * @param {*} value - The value to normalize
310
+ * @returns {*} - Returns the normalized value
311
+ */
312
312
  normalizeValue(value) {
313
313
  if (this.component.multiple && Array.isArray(value)) {
314
314
  return value.map((singleValue) => this.normalizeSingleValue(singleValue));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5870.aa1e3d9",
3
+ "version": "5.0.0-dev.5873.124778a",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {