@formio/js 5.0.0-dev.5818.039b965 → 5.0.0-dev.5820.db7ef4f

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.
@@ -237,10 +237,9 @@ export default class SelectComponent extends ListComponent {
237
237
  }
238
238
  selectValueAndLabel(data) {
239
239
  const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
240
- const readOnlyResourceLabelData = this.options.readOnly && (this.component.dataSrc === 'resource' || this.component.dataSrc === 'url') && this.selectData;
241
240
  return {
242
241
  value,
243
- label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : readOnlyResourceLabelData || data, value)
242
+ label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : data, value)
244
243
  };
245
244
  }
246
245
  itemTemplate(data, value) {
@@ -257,8 +256,7 @@ export default class SelectComponent extends ListComponent {
257
256
  const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
258
257
  return this.sanitize(value, this.shouldSanitizeValue);
259
258
  }
260
- if (this.component.multiple
261
- && _.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === value)) {
259
+ if (this.component.multiple && _.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === this.normalizeSingleValue(value))) {
262
260
  const selectData = this.selectData;
263
261
  if (selectData) {
264
262
  const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
@@ -1288,6 +1286,23 @@ export default class SelectComponent extends ListComponent {
1288
1286
  }
1289
1287
  return changed;
1290
1288
  }
1289
+ undoValueTyping(value) {
1290
+ let untypedValue = value;
1291
+ if (this.component.multiple && Array.isArray(value)) {
1292
+ untypedValue = value.map(v => {
1293
+ if (typeof v === 'boolean' || typeof v === 'number') {
1294
+ return v.toString();
1295
+ }
1296
+ return v;
1297
+ });
1298
+ }
1299
+ else {
1300
+ if (typeof value === 'boolean' || typeof value === 'number') {
1301
+ untypedValue = value.toString();
1302
+ }
1303
+ }
1304
+ return untypedValue;
1305
+ }
1291
1306
  setValue(value, flags = {}) {
1292
1307
  const previousValue = this.dataValue;
1293
1308
  const changed = this.updateValue(value, flags);
@@ -1298,19 +1313,7 @@ export default class SelectComponent extends ListComponent {
1298
1313
  const hasPreviousValue = !this.isEmpty(previousValue);
1299
1314
  const hasValue = !this.isEmpty(value);
1300
1315
  // Undo typing when searching to set the value.
1301
- if (this.component.multiple && Array.isArray(value)) {
1302
- value = value.map(value => {
1303
- if (typeof value === 'boolean' || typeof value === 'number') {
1304
- return value.toString();
1305
- }
1306
- return value;
1307
- });
1308
- }
1309
- else {
1310
- if (typeof value === 'boolean' || typeof value === 'number') {
1311
- value = value.toString();
1312
- }
1313
- }
1316
+ value = this.undoValueTyping(value);
1314
1317
  if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
1315
1318
  this.itemsLoaded.then(() => {
1316
1319
  this.redraw();
@@ -1508,9 +1511,9 @@ export default class SelectComponent extends ListComponent {
1508
1511
  }
1509
1512
  asString(value, options = {}) {
1510
1513
  value = value ?? this.getValue();
1511
- if (options.modalPreview && this.selectData) {
1512
- const { label } = this.selectValueAndLabel(value);
1513
- return label;
1514
+ if (options.modalPreview) {
1515
+ const template = this.itemTemplate(value, value);
1516
+ return template;
1514
1517
  }
1515
1518
  //need to convert values to strings to be able to compare values with available options that are strings
1516
1519
  const convertToString = (data, valueProperty) => {
@@ -56,6 +56,14 @@ export function isMongoId(text: string): boolean;
56
56
  * @param {*} rowData - The contextual row data for the component.
57
57
  */
58
58
  export function checkCalculated(component: import('@formio/core').Component, submission: import('@formio/core').Submission, rowData: any): void;
59
+ /**
60
+ *
61
+ * @param component
62
+ * @param condition
63
+ * @param row
64
+ * @param data
65
+ * @param instance
66
+ */
59
67
  export function checkSimpleConditional(component: any, condition: any, row: any, data: any, instance: any): boolean;
60
68
  /**
61
69
  * Returns a components normalized value.
@@ -144,6 +144,11 @@ export function checkCalculated(component, submission, rowData) {
144
144
  * @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
145
145
  * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
146
146
  */
147
+ /**
148
+ *
149
+ * @param conditionPaths
150
+ * @param data
151
+ */
147
152
  function getConditionalPathsRecursive(conditionPaths, data) {
148
153
  let currentGlobalIndex = 0;
149
154
  const conditionalPathsArray = [];
@@ -182,6 +187,14 @@ function getConditionalPathsRecursive(conditionPaths, data) {
182
187
  getConditionalPaths(data);
183
188
  return conditionalPathsArray;
184
189
  }
190
+ /**
191
+ *
192
+ * @param component
193
+ * @param condition
194
+ * @param row
195
+ * @param data
196
+ * @param instance
197
+ */
185
198
  export function checkSimpleConditional(component, condition, row, data, instance) {
186
199
  if (condition.when) {
187
200
  const value = getComponentActualValue(condition.when, data, row);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5818.039b965",
3
+ "version": "5.0.0-dev.5820.db7ef4f",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {