@formio/js 5.0.0-rc.81 → 5.0.0-rc.83

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,12 +29,12 @@ export default class Multivalue extends Field {
29
29
  }
30
30
  else {
31
31
  if (Array.isArray(value) && !underlyingValueShouldBeArray) {
32
+ if (Utils.getModelType(this.component) === 'any') {
33
+ return super.normalizeValue(value, flags);
34
+ }
32
35
  if (this.component.storeas === 'string') {
33
36
  return super.normalizeValue(value.join(this.delimiter || ''), flags);
34
37
  }
35
- if (this.component.type === 'hidden' && value.length > 1) {
36
- return super.normalizeValue(value, flags);
37
- }
38
38
  return super.normalizeValue(value[0] || emptyValue, flags);
39
39
  }
40
40
  else {
@@ -418,7 +418,9 @@ export default class DayComponent extends Field {
418
418
  DAY = null;
419
419
  }
420
420
  if (!this.showMonth) {
421
- DAY = DAY === 0 ? 0 : DAY - 1;
421
+ if (!_.isNull(DAY)) {
422
+ DAY = DAY === 0 ? 0 : DAY - 1;
423
+ }
422
424
  YEAR = YEAR - 1;
423
425
  MONTH = null;
424
426
  }
@@ -136,6 +136,7 @@ export default class SelectComponent extends ListComponent {
136
136
  normalizeSingleValue(value: any): any;
137
137
  setMetadata(value: any): any;
138
138
  updateValue(value: any, flags: any): boolean;
139
+ undoValueTyping(value: any): any;
139
140
  setValue(value: any, flags?: {}): boolean;
140
141
  lazyLoadInit: boolean | undefined;
141
142
  isInitApiCallNeeded(hasValue: any): any;
@@ -238,10 +238,9 @@ export default class SelectComponent extends ListComponent {
238
238
  }
239
239
  selectValueAndLabel(data) {
240
240
  const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
241
- const readOnlyResourceLabelData = this.options.readOnly && (this.component.dataSrc === 'resource' || this.component.dataSrc === 'url') && this.selectData;
242
241
  return {
243
242
  value,
244
- label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : readOnlyResourceLabelData || data, value)
243
+ label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : data, value)
245
244
  };
246
245
  }
247
246
  itemTemplate(data, value) {
@@ -258,8 +257,7 @@ export default class SelectComponent extends ListComponent {
258
257
  const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
259
258
  return this.sanitize(value, this.shouldSanitizeValue);
260
259
  }
261
- if (this.component.multiple
262
- && _.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === value)) {
260
+ if (this.component.multiple && _.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === this.normalizeSingleValue(value))) {
263
261
  const selectData = this.selectData;
264
262
  if (selectData) {
265
263
  const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
@@ -1289,6 +1287,23 @@ export default class SelectComponent extends ListComponent {
1289
1287
  }
1290
1288
  return changed;
1291
1289
  }
1290
+ undoValueTyping(value) {
1291
+ let untypedValue = value;
1292
+ if (this.component.multiple && Array.isArray(value)) {
1293
+ untypedValue = value.map(v => {
1294
+ if (typeof v === 'boolean' || typeof v === 'number') {
1295
+ return v.toString();
1296
+ }
1297
+ return v;
1298
+ });
1299
+ }
1300
+ else {
1301
+ if (typeof value === 'boolean' || typeof value === 'number') {
1302
+ untypedValue = value.toString();
1303
+ }
1304
+ }
1305
+ return untypedValue;
1306
+ }
1292
1307
  setValue(value, flags = {}) {
1293
1308
  const previousValue = this.dataValue;
1294
1309
  const changed = this.updateValue(value, flags);
@@ -1299,19 +1314,7 @@ export default class SelectComponent extends ListComponent {
1299
1314
  const hasPreviousValue = !this.isEmpty(previousValue);
1300
1315
  const hasValue = !this.isEmpty(value);
1301
1316
  // Undo typing when searching to set the value.
1302
- if (this.component.multiple && Array.isArray(value)) {
1303
- value = value.map(value => {
1304
- if (typeof value === 'boolean' || typeof value === 'number') {
1305
- return value.toString();
1306
- }
1307
- return value;
1308
- });
1309
- }
1310
- else {
1311
- if (typeof value === 'boolean' || typeof value === 'number') {
1312
- value = value.toString();
1313
- }
1314
- }
1317
+ value = this.undoValueTyping(value);
1315
1318
  if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
1316
1319
  this.itemsLoaded.then(() => {
1317
1320
  this.redraw();
@@ -1509,9 +1512,9 @@ export default class SelectComponent extends ListComponent {
1509
1512
  }
1510
1513
  asString(value, options = {}) {
1511
1514
  value = value ?? this.getValue();
1512
- if (options.modalPreview && this.selectData) {
1513
- const { label } = this.selectValueAndLabel(value);
1514
- return label;
1515
+ if (options.modalPreview) {
1516
+ const template = this.itemTemplate(value, value);
1517
+ return template;
1515
1518
  }
1516
1519
  //need to convert values to strings to be able to compare values with available options that are strings
1517
1520
  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.
@@ -145,6 +145,11 @@ export function checkCalculated(component, submission, rowData) {
145
145
  * @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
146
146
  * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
147
147
  */
148
+ /**
149
+ *
150
+ * @param conditionPaths
151
+ * @param data
152
+ */
148
153
  function getConditionalPathsRecursive(conditionPaths, data) {
149
154
  let currentGlobalIndex = 0;
150
155
  const conditionalPathsArray = [];
@@ -183,6 +188,14 @@ function getConditionalPathsRecursive(conditionPaths, data) {
183
188
  getConditionalPaths(data);
184
189
  return conditionalPathsArray;
185
190
  }
191
+ /**
192
+ *
193
+ * @param component
194
+ * @param condition
195
+ * @param row
196
+ * @param data
197
+ * @param instance
198
+ */
186
199
  export function checkSimpleConditional(component, condition, row, data, instance) {
187
200
  if (condition.when) {
188
201
  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-rc.81",
3
+ "version": "5.0.0-rc.83",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {