@formio/js 5.0.0-rc.97 → 5.0.0-rc.99

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.
@@ -20,7 +20,7 @@
20
20
 
21
21
  /*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
22
22
 
23
- /*! formiojs v5.0.0-rc.97 | https://unpkg.com/formiojs@5.0.0-rc.97/LICENSE.txt */
23
+ /*! formiojs v5.0.0-rc.99 | https://unpkg.com/formiojs@5.0.0-rc.99/LICENSE.txt */
24
24
 
25
25
  /**
26
26
  * @license
@@ -3224,12 +3224,6 @@ class Component extends Element_1.default {
3224
3224
  return (this.component.protected || !this.component.persistent || (this.component.persistent === 'client-only'));
3225
3225
  }
3226
3226
  shouldSkipValidation(data, row, flags = {}) {
3227
- const { validateWhenHidden = false } = this.component || {};
3228
- const forceValidOnHidden = (!this.visible || !this.checkCondition(row, data)) && !validateWhenHidden;
3229
- if (forceValidOnHidden) {
3230
- // If this component is forced valid when it is hidden, then we also need to reset the errors for this component.
3231
- this._errors = [];
3232
- }
3233
3227
  const rules = [
3234
3228
  // Do not validate if the flags say not too.
3235
3229
  () => flags.noValidate,
@@ -3240,7 +3234,14 @@ class Component extends Element_1.default {
3240
3234
  // Check to see if we are editing and if so, check component persistence.
3241
3235
  () => this.isValueHidden(),
3242
3236
  // Force valid if component is hidden.
3243
- () => forceValidOnHidden
3237
+ () => {
3238
+ if (!this.component.validateWhenHidden && (!this.visible || !this.checkCondition(row, data))) {
3239
+ // If this component is forced valid when it is hidden, then we also need to reset the errors for this component.
3240
+ this._errors = [];
3241
+ return true;
3242
+ }
3243
+ return false;
3244
+ }
3244
3245
  ];
3245
3246
  return rules.some(pred => pred());
3246
3247
  }
@@ -332,9 +332,8 @@ class RadioComponent extends ListComponent_1.default {
332
332
  label: this.component.valueProperty ? this.itemTemplate(item, valueAtProperty) : this.itemTemplate(item, item, i)
333
333
  };
334
334
  listData.push(this.templateData[this.component.valueProperty ? valueAtProperty : i]);
335
- if ((this.component.valueProperty || !this.isRadio) && (lodash_1.default.isUndefined(valueAtProperty) ||
336
- (!this.isRadio && lodash_1.default.isObject(valueAtProperty)) ||
337
- (!this.isRadio && lodash_1.default.isBoolean(valueAtProperty)))) {
335
+ const value = this.loadedOptions[i].value;
336
+ if (!this.isRadio && (lodash_1.default.isObject(value) || lodash_1.default.isBoolean(value) || lodash_1.default.isUndefined(value))) {
338
337
  this.loadedOptions[i].invalid = true;
339
338
  }
340
339
  });
@@ -79,7 +79,12 @@ class I18n {
79
79
  this.languages[language] = strings;
80
80
  }
81
81
  t(text, ...args) {
82
+ var _a;
82
83
  if (this.currentLanguage[text]) {
84
+ const customTranslationFieldName = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.field;
85
+ if (customTranslationFieldName && this.currentLanguage[customTranslationFieldName]) {
86
+ args[0].field = this.currentLanguage[customTranslationFieldName];
87
+ }
83
88
  return utils_1.Evaluator.interpolateString(this.currentLanguage[text], ...args);
84
89
  }
85
90
  return utils_1.Evaluator.interpolateString(text, ...args);
@@ -3189,12 +3189,6 @@ export default class Component extends Element {
3189
3189
  return (this.component.protected || !this.component.persistent || (this.component.persistent === 'client-only'));
3190
3190
  }
3191
3191
  shouldSkipValidation(data, row, flags = {}) {
3192
- const { validateWhenHidden = false } = this.component || {};
3193
- const forceValidOnHidden = (!this.visible || !this.checkCondition(row, data)) && !validateWhenHidden;
3194
- if (forceValidOnHidden) {
3195
- // If this component is forced valid when it is hidden, then we also need to reset the errors for this component.
3196
- this._errors = [];
3197
- }
3198
3192
  const rules = [
3199
3193
  // Do not validate if the flags say not too.
3200
3194
  () => flags.noValidate,
@@ -3205,7 +3199,14 @@ export default class Component extends Element {
3205
3199
  // Check to see if we are editing and if so, check component persistence.
3206
3200
  () => this.isValueHidden(),
3207
3201
  // Force valid if component is hidden.
3208
- () => forceValidOnHidden
3202
+ () => {
3203
+ if (!this.component.validateWhenHidden && (!this.visible || !this.checkCondition(row, data))) {
3204
+ // If this component is forced valid when it is hidden, then we also need to reset the errors for this component.
3205
+ this._errors = [];
3206
+ return true;
3207
+ }
3208
+ return false;
3209
+ }
3209
3210
  ];
3210
3211
  return rules.some(pred => pred());
3211
3212
  }
@@ -332,9 +332,8 @@ export default class RadioComponent extends ListComponent {
332
332
  label: this.component.valueProperty ? this.itemTemplate(item, valueAtProperty) : this.itemTemplate(item, item, i)
333
333
  };
334
334
  listData.push(this.templateData[this.component.valueProperty ? valueAtProperty : i]);
335
- if ((this.component.valueProperty || !this.isRadio) && (_.isUndefined(valueAtProperty) ||
336
- (!this.isRadio && _.isObject(valueAtProperty)) ||
337
- (!this.isRadio && _.isBoolean(valueAtProperty)))) {
335
+ const value = this.loadedOptions[i].value;
336
+ if (!this.isRadio && (_.isObject(value) || _.isBoolean(value) || _.isUndefined(value))) {
338
337
  this.loadedOptions[i].invalid = true;
339
338
  }
340
339
  });
@@ -74,6 +74,10 @@ export class I18n {
74
74
  }
75
75
  t(text, ...args) {
76
76
  if (this.currentLanguage[text]) {
77
+ const customTranslationFieldName = args[0]?.field;
78
+ if (customTranslationFieldName && this.currentLanguage[customTranslationFieldName]) {
79
+ args[0].field = this.currentLanguage[customTranslationFieldName];
80
+ }
77
81
  return Evaluator.interpolateString(this.currentLanguage[text], ...args);
78
82
  }
79
83
  return Evaluator.interpolateString(text, ...args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.97",
3
+ "version": "5.0.0-rc.99",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -81,7 +81,7 @@
81
81
  "dependencies": {
82
82
  "@formio/bootstrap": "3.0.0-rc.41",
83
83
  "@formio/choices.js": "^10.2.1",
84
- "@formio/core": "2.3.0-rc.21",
84
+ "@formio/core": "2.3.0-rc.22",
85
85
  "@formio/text-mask-addons": "^3.8.0-formio.3",
86
86
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
87
87
  "abortcontroller-polyfill": "^1.7.5",