@formio/js 5.0.0-rc.77 → 5.0.0-rc.79

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +21 -21
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +2 -2
  7. package/dist/formio.full.js +28 -28
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +2 -2
  10. package/dist/formio.js +3 -3
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +12 -12
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +2 -2
  16. package/lib/cjs/Webform.js +5 -2
  17. package/lib/cjs/components/_classes/component/Component.js +2 -2
  18. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +8 -0
  19. package/lib/cjs/components/_classes/multivalue/Multivalue.js +18 -12
  20. package/lib/cjs/components/day/Day.d.ts +5 -0
  21. package/lib/cjs/components/day/Day.js +52 -12
  22. package/lib/cjs/components/day/editForm/Day.edit.day.d.ts +17 -0
  23. package/lib/cjs/components/day/editForm/Day.edit.day.js +19 -0
  24. package/lib/cjs/components/day/editForm/Day.edit.month.d.ts +5 -0
  25. package/lib/cjs/components/day/editForm/Day.edit.month.js +19 -0
  26. package/lib/cjs/components/day/editForm/Day.edit.year.d.ts +5 -0
  27. package/lib/cjs/components/day/editForm/Day.edit.year.js +13 -0
  28. package/lib/cjs/components/radio/Radio.js +1 -1
  29. package/lib/cjs/components/select/Select.d.ts +38 -0
  30. package/lib/cjs/components/select/Select.js +15 -2
  31. package/lib/cjs/components/select/editForm/Select.edit.validation.js +2 -1
  32. package/lib/cjs/components/select/fixtures/comp25.d.ts +44 -0
  33. package/lib/cjs/components/select/fixtures/comp25.js +59 -0
  34. package/lib/cjs/components/select/fixtures/comp27.d.ts +18 -0
  35. package/lib/cjs/components/select/fixtures/comp27.js +19 -0
  36. package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
  37. package/lib/cjs/components/select/fixtures/index.js +7 -1
  38. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  39. package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +2 -1
  40. package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  41. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
  42. package/lib/cjs/utils/formUtils.d.ts +1 -2
  43. package/lib/cjs/utils/formUtils.js +2 -3
  44. package/lib/mjs/Webform.js +9 -2
  45. package/lib/mjs/components/_classes/component/Component.js +2 -2
  46. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +8 -0
  47. package/lib/mjs/components/_classes/multivalue/Multivalue.js +18 -12
  48. package/lib/mjs/components/day/Day.d.ts +5 -0
  49. package/lib/mjs/components/day/Day.js +52 -12
  50. package/lib/mjs/components/day/editForm/Day.edit.day.d.ts +17 -0
  51. package/lib/mjs/components/day/editForm/Day.edit.day.js +16 -0
  52. package/lib/mjs/components/day/editForm/Day.edit.month.d.ts +5 -0
  53. package/lib/mjs/components/day/editForm/Day.edit.month.js +16 -0
  54. package/lib/mjs/components/day/editForm/Day.edit.year.d.ts +5 -0
  55. package/lib/mjs/components/day/editForm/Day.edit.year.js +10 -0
  56. package/lib/mjs/components/radio/Radio.js +1 -1
  57. package/lib/mjs/components/select/Select.d.ts +38 -0
  58. package/lib/mjs/components/select/Select.js +18 -3
  59. package/lib/mjs/components/select/editForm/Select.edit.validation.js +2 -1
  60. package/lib/mjs/components/select/fixtures/comp25.d.ts +44 -0
  61. package/lib/mjs/components/select/fixtures/comp25.js +57 -0
  62. package/lib/mjs/components/select/fixtures/comp27.d.ts +18 -0
  63. package/lib/mjs/components/select/fixtures/comp27.js +17 -0
  64. package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
  65. package/lib/mjs/components/select/fixtures/index.js +4 -1
  66. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  67. package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +1 -1
  68. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  69. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
  70. package/lib/mjs/utils/formUtils.d.ts +1 -2
  71. package/lib/mjs/utils/formUtils.js +2 -2
  72. package/package.json +2 -2
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ type: 'select',
5
+ label: 'Select',
6
+ widget: 'choicesjs',
7
+ tableView: true,
8
+ dataSrc: 'custom',
9
+ data: {
10
+ custom: 'values = data.dataSource;'
11
+ },
12
+ dataType: 'string',
13
+ idPath: 'name',
14
+ valueProperty: 'name',
15
+ template: '<span>{{ item.name }}</span>',
16
+ validateWhenHidden: false,
17
+ key: 'select',
18
+ input: true
19
+ };
@@ -21,5 +21,7 @@ import comp21 from './comp21';
21
21
  import comp22 from './comp22';
22
22
  import comp23 from './comp23';
23
23
  import comp24 from './comp24';
24
- export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22, comp23, comp24 };
24
+ import comp25 from './comp25';
25
+ import comp27 from './comp27';
26
+ export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22, comp23, comp24, comp25, comp26, comp27 };
25
27
  export { multiSelect, multiSelectOptions } from "./comp3";
@@ -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.comp24 = exports.comp23 = exports.comp22 = exports.comp21 = exports.comp20 = exports.comp19 = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp2 = exports.comp1 = exports.multiSelectOptions = exports.multiSelect = void 0;
6
+ exports.comp27 = exports.comp26 = exports.comp25 = exports.comp24 = exports.comp23 = exports.comp22 = exports.comp21 = exports.comp20 = exports.comp19 = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp2 = exports.comp1 = exports.multiSelectOptions = exports.multiSelect = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const comp2_1 = __importDefault(require("./comp2"));
@@ -53,3 +53,9 @@ const comp23_1 = __importDefault(require("./comp23"));
53
53
  exports.comp23 = comp23_1.default;
54
54
  const comp24_1 = __importDefault(require("./comp24"));
55
55
  exports.comp24 = comp24_1.default;
56
+ const comp25_1 = __importDefault(require("./comp25"));
57
+ exports.comp25 = comp25_1.default;
58
+ const comp26_1 = __importDefault(require("./comp26"));
59
+ exports.comp26 = comp26_1.default;
60
+ const comp27_1 = __importDefault(require("./comp27"));
61
+ exports.comp27 = comp27_1.default;
@@ -254,7 +254,7 @@ class SelectBoxesComponent extends Radio_1.default {
254
254
  if (!(0, utils_1.boolValue)(setting) || !value) {
255
255
  return true;
256
256
  }
257
- const values = this.component.values;
257
+ const values = this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions;
258
258
  const availableValueKeys = (values || []).map(({ value: optionValue }) => optionValue);
259
259
  const valueKeys = Object.keys(value);
260
260
  return valueKeys.every((key) => availableValueKeys.includes(key));
@@ -19,12 +19,13 @@ class DateGeaterThan extends ConditionOperator_1.default {
19
19
  return { date, comparedDate };
20
20
  }
21
21
  execute(options, functionName = 'isAfter') {
22
+ var _a;
22
23
  const { value, instance, conditionComponentPath } = options;
23
24
  if (!value) {
24
25
  return false;
25
26
  }
26
27
  let conditionTriggerComponent = null;
27
- if (instance && instance.root) {
28
+ if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
28
29
  conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
29
30
  }
30
31
  if (conditionTriggerComponent && conditionTriggerComponent.isPartialDay && conditionTriggerComponent.isPartialDay(value)) {
@@ -18,8 +18,8 @@ class IsEmptyValue extends ConditionOperator_1.default {
18
18
  execute({ value, instance, conditionComponentPath }) {
19
19
  var _a;
20
20
  const isEmptyValue = lodash_1.default.isEmpty(lodash_1.default.isNumber(value) ? String(value) : value);
21
- if (instance && instance.root) {
22
- const conditionTriggerComponent = ((_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) && instance.root.getComponent(conditionComponentPath);
21
+ if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
22
+ const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
23
23
  return (conditionTriggerComponent === null || conditionTriggerComponent === void 0 ? void 0 : conditionTriggerComponent.isEmpty) ? conditionTriggerComponent.isEmpty() : isEmptyValue;
24
24
  }
25
25
  return isEmptyValue;
@@ -22,8 +22,8 @@ class IsEqualTo extends ConditionOperator_1.default {
22
22
  // eslint-disable-next-line no-empty
23
23
  catch (e) { }
24
24
  }
25
- if (instance && instance.root) {
26
- const conditionTriggerComponent = ((_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) && instance.root.getComponent(conditionComponentPath);
25
+ if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
26
+ const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
27
27
  if (conditionTriggerComponent
28
28
  && (0, utils_1.isSelectResourceWithObjectValue)(conditionTriggerComponent.component)
29
29
  && ((_b = conditionTriggerComponent.component) === null || _b === void 0 ? void 0 : _b.template)) {
@@ -8,11 +8,10 @@ export function findComponents(components: import('@formio/core').Component[], q
8
8
  export const flattenComponents: typeof Utils.flattenComponents;
9
9
  export const guid: typeof Utils.guid;
10
10
  export const uniqueName: typeof Utils.uniqueName;
11
- export const MODEL_TYPES: Record<string, string[]>;
11
+ export const MODEL_TYPES: any;
12
12
  export const getModelType: typeof Utils.getModelType;
13
13
  export const getComponentAbsolutePath: typeof Utils.getComponentAbsolutePath;
14
14
  export const getComponentPath: typeof Utils.getComponentPath;
15
- export const isComponentModelType: typeof Utils.isComponentModelType;
16
15
  export const isComponentNestedDataType: typeof Utils.isComponentNestedDataType;
17
16
  export const componentPath: typeof Utils.componentPath;
18
17
  export const componentChildPath: any;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.eachComponentAsync = exports.eachComponent = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.eachComponentData = exports.eachComponentDataAsync = exports.componentChildPath = exports.componentPath = exports.isComponentNestedDataType = exports.isComponentModelType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES = exports.uniqueName = exports.guid = exports.flattenComponents = exports.findComponents = void 0;
3
+ exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.eachComponentAsync = exports.eachComponent = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.eachComponentData = exports.eachComponentDataAsync = exports.componentChildPath = exports.componentPath = exports.isComponentNestedDataType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES = exports.uniqueName = exports.guid = exports.flattenComponents = exports.findComponents = void 0;
4
4
  const core_1 = require("@formio/core");
5
- const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentModelType, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty } = core_1.Utils;
5
+ const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty } = core_1.Utils;
6
6
  exports.flattenComponents = flattenComponents;
7
7
  exports.guid = guid;
8
8
  exports.uniqueName = uniqueName;
@@ -10,7 +10,6 @@ exports.MODEL_TYPES = MODEL_TYPES;
10
10
  exports.getModelType = getModelType;
11
11
  exports.getComponentAbsolutePath = getComponentAbsolutePath;
12
12
  exports.getComponentPath = getComponentPath;
13
- exports.isComponentModelType = isComponentModelType;
14
13
  exports.isComponentNestedDataType = isComponentNestedDataType;
15
14
  exports.componentPath = componentPath;
16
15
  exports.componentChildPath = componentChildPath;
@@ -1093,6 +1093,9 @@ export default class Webform extends NestedDataComponent {
1093
1093
  if (!Array.isArray(errors)) {
1094
1094
  errors = [errors];
1095
1095
  }
1096
+ if (Array.isArray(this.errors)) {
1097
+ errors = _.union(errors, this.errors);
1098
+ }
1096
1099
  errors = errors.concat(this.customErrors).filter((err) => !!err);
1097
1100
  if (!errors.length) {
1098
1101
  this.setAlert(false);
@@ -1238,10 +1241,14 @@ export default class Webform extends NestedDataComponent {
1238
1241
  }
1239
1242
  this.checkData(value.data, flags);
1240
1243
  const shouldValidate = !flags.noValidate ||
1241
- flags.fromIFrame ||
1244
+ flags.fromIframe ||
1242
1245
  (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1243
1246
  const errors = shouldValidate
1244
- ? this.validate(value.data, { ...flags, process: "change" })
1247
+ ? this.validate(value.data, {
1248
+ ...flags,
1249
+ noValidate: false,
1250
+ process: 'change'
1251
+ })
1245
1252
  : [];
1246
1253
  value.isValid = errors.length === 0;
1247
1254
  this.loading = false;
@@ -2963,7 +2963,7 @@ export default class Component extends Element {
2963
2963
  this.parent.childErrors.push(...errors);
2964
2964
  }
2965
2965
  else {
2966
- _.remove(this.parent.childErrors, (err) => err.component.key === this.component.key);
2966
+ _.remove(this.parent.childErrors, (err) => (err?.component?.key || err?.context?.key) === this.component.key);
2967
2967
  }
2968
2968
  }
2969
2969
  this.showValidationErrors(errors, data, row, flags);
@@ -2979,7 +2979,7 @@ export default class Component extends Element {
2979
2979
  this.parent.childErrors.push(...errors);
2980
2980
  }
2981
2981
  else {
2982
- _.remove(this.parent.childErrors, (err) => err.component.key === this.component.key);
2982
+ _.remove(this.parent.childErrors, (err) => (err?.component?.key || err?.context?.key) === this.component.key);
2983
2983
  }
2984
2984
  }
2985
2985
  return errors.length === 0;
@@ -1,4 +1,12 @@
1
1
  export default class Multivalue extends Field {
2
+ /**
3
+ * Normalize values coming into updateValue.
4
+ * @param {*} value - The value to normalize before setting.
5
+ * @param {object} flags - Flags to use when normalizing the value.
6
+ * @param {*} emptyValue - The empty value for the field.
7
+ * @returns {*} - The normalized value.
8
+ */
9
+ normalizeValue(value: any, flags?: object, emptyValue?: any): any;
2
10
  get addAnother(): string;
3
11
  /**
4
12
  * @returns {Field} - The created field.
@@ -1,40 +1,46 @@
1
1
  import Field from '../field/Field';
2
2
  import _ from 'lodash';
3
+ import { Utils } from '@formio/core';
3
4
  export default class Multivalue extends Field {
4
5
  /**
5
6
  * Normalize values coming into updateValue.
6
7
  * @param {*} value - The value to normalize before setting.
8
+ * @param {object} flags - Flags to use when normalizing the value.
9
+ * @param {*} emptyValue - The empty value for the field.
7
10
  * @returns {*} - The normalized value.
8
11
  */
9
- normalizeValue(value) {
12
+ normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
13
+ const underlyingValueShouldBeArray = Utils.getModelType(this.component) === 'array' || this.component.storeas === 'array' || Array.isArray(emptyValue);
10
14
  if (this.component.multiple) {
11
15
  if (Array.isArray(value)) {
12
- if (value.length === 0) {
13
- return [this.emptyValue];
16
+ if (underlyingValueShouldBeArray) {
17
+ if (value.length === 0 || !Array.isArray(value[0])) {
18
+ return [value];
19
+ }
14
20
  }
15
- if (this.component.storeas === 'array') {
16
- return super.normalizeValue([value]);
21
+ if (value.length === 0) {
22
+ return [emptyValue];
17
23
  }
18
- return super.normalizeValue(value);
24
+ return super.normalizeValue(value, flags);
19
25
  }
20
26
  else {
21
- return super.normalizeValue(value == null ? [this.emptyValue] : [value]);
27
+ return super.normalizeValue(value == null ? [emptyValue] : [value], flags);
22
28
  }
23
29
  }
24
30
  else {
25
- if (Array.isArray(value) && this.component.storeas !== 'array') {
31
+ if (Array.isArray(value) && !underlyingValueShouldBeArray) {
26
32
  if (this.component.storeas === 'string') {
27
- return super.normalizeValue(value.join(this.delimiter || ''));
33
+ return super.normalizeValue(value.join(this.delimiter || ''), flags);
28
34
  }
29
- return super.normalizeValue(value[0] || this.emptyValue);
35
+ return super.normalizeValue(value[0] || emptyValue, flags);
30
36
  }
31
37
  else {
32
- return super.normalizeValue(value);
38
+ return super.normalizeValue(value, flags);
33
39
  }
34
40
  }
35
41
  }
36
42
  get dataValue() {
37
- return super.dataValue;
43
+ return this.normalizeValue(super.dataValue);
38
44
  }
39
45
  set dataValue(value) {
40
46
  super.dataValue = value;
@@ -97,6 +97,11 @@ export default class DayComponent extends Field {
97
97
  * @returns {null|void} - Returns null if the value is invalid, otherwise void.
98
98
  */
99
99
  setValueAt(index: number, value: any): null | void;
100
+ getDayWithHiddenFields(parts: any): {
101
+ month: any;
102
+ day: any;
103
+ year: any;
104
+ };
100
105
  getFieldValue(name: any): number;
101
106
  get parts(): {
102
107
  day: number;
@@ -342,6 +342,18 @@ export default class DayComponent extends Field {
342
342
  const valueParts = value.split('/');
343
343
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
344
344
  const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
345
+ let defaultDay = '';
346
+ let defaultMonth = '';
347
+ let defaultYear = '';
348
+ if (defaultValue) {
349
+ const hasHiddenFields = defaultValue.length !== 3;
350
+ defaultDay = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).day : defaultValue[DAY];
351
+ defaultMonth = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).month : defaultValue[MONTH];
352
+ defaultYear = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).year : defaultValue[YEAR];
353
+ }
354
+ if (this.options.building && defaultValue.length === 3) {
355
+ return this.component.defaultValue;
356
+ }
345
357
  const getNextPart = (shouldTake, defaultValue) => {
346
358
  // Only push the part if it's not an empty string
347
359
  const part = shouldTake ? valueParts.shift() : defaultValue;
@@ -350,13 +362,13 @@ export default class DayComponent extends Field {
350
362
  }
351
363
  };
352
364
  if (this.dayFirst) {
353
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
365
+ getNextPart(this.showDay, defaultDay);
354
366
  }
355
- getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '');
367
+ getNextPart(this.showMonth, defaultMonth);
356
368
  if (!this.dayFirst) {
357
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
369
+ getNextPart(this.showDay, defaultDay);
358
370
  }
359
- getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '');
371
+ getNextPart(this.showYear, defaultYear);
360
372
  return dateParts.join('/');
361
373
  }
362
374
  /**
@@ -371,16 +383,23 @@ export default class DayComponent extends Field {
371
383
  if (value === 'Invalid date') {
372
384
  return null;
373
385
  }
386
+ let day, month, year;
374
387
  const parts = value.split('/');
375
- let day;
376
- if (this.component.dayFirst) {
377
- day = parts.shift();
388
+ if (parts.length !== 3) {
389
+ day = this.getDayWithHiddenFields(parts).day;
390
+ month = this.getDayWithHiddenFields(parts).month;
391
+ year = this.getDayWithHiddenFields(parts).year;
378
392
  }
379
- const month = parts.shift();
380
- if (!this.component.dayFirst) {
381
- day = parts.shift();
393
+ else {
394
+ if (this.component.dayFirst) {
395
+ day = parts.shift();
396
+ }
397
+ month = parts.shift();
398
+ if (!this.component.dayFirst) {
399
+ day = parts.shift();
400
+ }
401
+ year = parts.shift();
382
402
  }
383
- const year = parts.shift();
384
403
  if (this.refs.day && this.showDay) {
385
404
  this.refs.day.value = day === '00' ? '' : parseInt(day, 10);
386
405
  }
@@ -391,6 +410,27 @@ export default class DayComponent extends Field {
391
410
  this.refs.year.value = year === '0000' ? '' : parseInt(year, 10);
392
411
  }
393
412
  }
413
+ getDayWithHiddenFields(parts) {
414
+ let [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
415
+ if (!this.showDay) {
416
+ MONTH = MONTH === 0 ? 0 : MONTH - 1;
417
+ YEAR = YEAR - 1;
418
+ DAY = null;
419
+ }
420
+ if (!this.showMonth) {
421
+ DAY = DAY === 0 ? 0 : DAY - 1;
422
+ YEAR = YEAR - 1;
423
+ MONTH = null;
424
+ }
425
+ if (!this.showYear) {
426
+ YEAR = null;
427
+ }
428
+ return {
429
+ month: _.isNull(MONTH) ? '' : parts[MONTH],
430
+ day: _.isNull(DAY) ? '' : parts[DAY],
431
+ year: _.isNull(YEAR) ? '' : parts[YEAR],
432
+ };
433
+ }
394
434
  getFieldValue(name) {
395
435
  const parts = this.dataValue ? this.dataValue.split('/') : [];
396
436
  let val = 0;
@@ -557,7 +597,7 @@ export default class DayComponent extends Field {
557
597
  }
558
598
  isPartialDay(value) {
559
599
  if (!value) {
560
- return false;
600
+ return true;
561
601
  }
562
602
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
563
603
  const values = value.split('/');
@@ -14,6 +14,7 @@ declare const _default: ({
14
14
  input?: undefined;
15
15
  placeholder?: undefined;
16
16
  tooltip?: undefined;
17
+ onChange?: undefined;
17
18
  } | {
18
19
  weight: number;
19
20
  type: string;
@@ -25,16 +26,32 @@ declare const _default: ({
25
26
  wieght?: undefined;
26
27
  datasrc?: undefined;
27
28
  data?: undefined;
29
+ onChange?: undefined;
28
30
  } | {
29
31
  weight: number;
30
32
  type: string;
31
33
  label: string;
32
34
  tooltip: string;
33
35
  key: string;
36
+ onChange: ({ data }: {
37
+ data: any;
38
+ }) => void;
34
39
  input: boolean;
35
40
  wieght?: undefined;
36
41
  datasrc?: undefined;
37
42
  data?: undefined;
38
43
  placeholder?: undefined;
44
+ } | {
45
+ weight: number;
46
+ type: string;
47
+ label: string;
48
+ tooltip: string;
49
+ key: string;
50
+ input: boolean;
51
+ wieght?: undefined;
52
+ datasrc?: undefined;
53
+ data?: undefined;
54
+ placeholder?: undefined;
55
+ onChange?: undefined;
39
56
  })[];
40
57
  export default _default;
@@ -1,3 +1,4 @@
1
+ import _ from 'lodash';
1
2
  export default [
2
3
  {
3
4
  wieght: 200,
@@ -33,6 +34,21 @@ export default [
33
34
  label: 'Hidden',
34
35
  tooltip: 'Hide the Day part of the component.',
35
36
  key: 'fields.day.hide',
37
+ onChange: ({ data }) => {
38
+ if (data.defaultValue) {
39
+ const defaultValueParts = data.defaultValue.split('/');
40
+ if (!data.fields.day.hide && defaultValueParts.length !== 3) {
41
+ const newDefaultValue = ['00'];
42
+ if (!data.fields.month.hide) {
43
+ data.dayFirst ? newDefaultValue.push(defaultValueParts[0]) : newDefaultValue.unshift(defaultValueParts[0]);
44
+ }
45
+ if (!data.fields.year.hide) {
46
+ newDefaultValue.push(defaultValueParts[1]);
47
+ }
48
+ _.set(data, 'defaultValue', newDefaultValue.join('/'));
49
+ }
50
+ }
51
+ },
36
52
  input: true
37
53
  },
38
54
  {
@@ -14,6 +14,7 @@ declare const _default: ({
14
14
  input?: undefined;
15
15
  placeholder?: undefined;
16
16
  tooltip?: undefined;
17
+ onChange?: undefined;
17
18
  } | {
18
19
  weight: number;
19
20
  type: string;
@@ -25,12 +26,16 @@ declare const _default: ({
25
26
  wieght?: undefined;
26
27
  datasrc?: undefined;
27
28
  data?: undefined;
29
+ onChange?: undefined;
28
30
  } | {
29
31
  weight: number;
30
32
  type: string;
31
33
  label: string;
32
34
  tooltip: string;
33
35
  key: string;
36
+ onChange: ({ data }: {
37
+ data: any;
38
+ }) => void;
34
39
  input: boolean;
35
40
  wieght?: undefined;
36
41
  datasrc?: undefined;
@@ -1,3 +1,4 @@
1
+ import _ from 'lodash';
1
2
  export default [
2
3
  {
3
4
  wieght: 200,
@@ -33,6 +34,21 @@ export default [
33
34
  label: 'Hidden',
34
35
  tooltip: 'Hide the Month part of the component.',
35
36
  key: 'fields.month.hide',
37
+ onChange: ({ data }) => {
38
+ if (data.defaultValue) {
39
+ const defaultValueParts = data.defaultValue.split('/');
40
+ if (!data.fields.month.hide && defaultValueParts.length !== 3) {
41
+ const newDefaultValue = ['00'];
42
+ if (!data.fields.day.hide) {
43
+ data.dayFirst ? newDefaultValue.unshift(defaultValueParts[0]) : newDefaultValue.push(defaultValueParts[0]);
44
+ }
45
+ if (!data.fields.year.hide) {
46
+ newDefaultValue.push(defaultValueParts[1]);
47
+ }
48
+ _.set(data, 'defaultValue', newDefaultValue.join('/'));
49
+ }
50
+ }
51
+ },
36
52
  input: true
37
53
  },
38
54
  ];
@@ -14,6 +14,7 @@ declare const _default: ({
14
14
  input?: undefined;
15
15
  placeholder?: undefined;
16
16
  tooltip?: undefined;
17
+ onChange?: undefined;
17
18
  } | {
18
19
  weight: number;
19
20
  type: string;
@@ -25,12 +26,16 @@ declare const _default: ({
25
26
  wieght?: undefined;
26
27
  datasrc?: undefined;
27
28
  data?: undefined;
29
+ onChange?: undefined;
28
30
  } | {
29
31
  weight: number;
30
32
  type: string;
31
33
  label: string;
32
34
  tooltip: string;
33
35
  key: string;
36
+ onChange: ({ data }: {
37
+ data: any;
38
+ }) => void;
34
39
  input: boolean;
35
40
  wieght?: undefined;
36
41
  datasrc?: undefined;
@@ -1,3 +1,4 @@
1
+ import _ from 'lodash';
1
2
  export default [
2
3
  {
3
4
  wieght: 200,
@@ -51,6 +52,15 @@ export default [
51
52
  label: 'Hidden',
52
53
  tooltip: 'Hide the Year part of the component.',
53
54
  key: 'fields.year.hide',
55
+ onChange: ({ data }) => {
56
+ if (data.defaultValue) {
57
+ const defaultValueParts = data.defaultValue.split('/');
58
+ if (!data.fields.month.hide && defaultValueParts.length !== 3) {
59
+ defaultValueParts.push('0000');
60
+ _.set(data, 'defaultValue', defaultValueParts.join('/'));
61
+ }
62
+ }
63
+ },
54
64
  input: true
55
65
  },
56
66
  ];
@@ -212,7 +212,7 @@ export default class RadioComponent extends ListComponent {
212
212
  if (!boolValue(setting) || !value) {
213
213
  return true;
214
214
  }
215
- const values = this.component.values;
215
+ const values = this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions;
216
216
  if (values) {
217
217
  return values.findIndex(({ value: optionValue }) => this.normalizeValue(optionValue) === value) !== -1;
218
218
  }
@@ -9,9 +9,47 @@ export default class SelectComponent extends ListComponent {
9
9
  };
10
10
  static get serverConditionSettings(): {
11
11
  valueComponent(classComp: any): any;
12
+ dataTypeOperators: {
13
+ number: string[];
14
+ };
15
+ dataTypeValueComponents: {
16
+ number: {
17
+ lessThan: () => {
18
+ type: string;
19
+ };
20
+ greaterThan: () => {
21
+ type: string;
22
+ };
23
+ lessThanOrEqual: () => {
24
+ type: string;
25
+ };
26
+ greaterThanOrEqual: () => {
27
+ type: string;
28
+ };
29
+ };
30
+ };
12
31
  };
13
32
  static get conditionOperatorsSettings(): {
14
33
  valueComponent(classComp: any): any;
34
+ dataTypeOperators: {
35
+ number: string[];
36
+ };
37
+ dataTypeValueComponents: {
38
+ number: {
39
+ lessThan: () => {
40
+ type: string;
41
+ };
42
+ greaterThan: () => {
43
+ type: string;
44
+ };
45
+ lessThanOrEqual: () => {
46
+ type: string;
47
+ };
48
+ greaterThanOrEqual: () => {
49
+ type: string;
50
+ };
51
+ };
52
+ };
15
53
  };
16
54
  static savedValueTypes(schema: any): any[];
17
55
  templateData: {} | undefined;
@@ -58,6 +58,7 @@ export default class SelectComponent extends ListComponent {
58
58
  return SelectComponent.conditionOperatorsSettings;
59
59
  }
60
60
  static get conditionOperatorsSettings() {
61
+ const numberType = () => ({ type: 'number' });
61
62
  return {
62
63
  ...super.conditionOperatorsSettings,
63
64
  valueComponent(classComp) {
@@ -74,7 +75,18 @@ export default class SelectComponent extends ListComponent {
74
75
  `;
75
76
  }
76
77
  return valueComp;
77
- }
78
+ },
79
+ dataTypeOperators: {
80
+ number: ['lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'],
81
+ },
82
+ dataTypeValueComponents: {
83
+ number: {
84
+ lessThan: numberType,
85
+ greaterThan: numberType,
86
+ lessThanOrEqual: numberType,
87
+ greaterThanOrEqual: numberType,
88
+ },
89
+ },
78
90
  };
79
91
  }
80
92
  static savedValueTypes(schema) {
@@ -1446,6 +1458,9 @@ export default class SelectComponent extends ListComponent {
1446
1458
  case 'custom':
1447
1459
  rawItems = this.getCustomItems();
1448
1460
  break;
1461
+ case 'url':
1462
+ rawItems = this.selectItems;
1463
+ break;
1449
1464
  }
1450
1465
  if (typeof rawItems === 'string') {
1451
1466
  try {
@@ -1503,7 +1518,7 @@ export default class SelectComponent extends ListComponent {
1503
1518
  if (Array.isArray(data)) {
1504
1519
  data.forEach((item) => item[valueProperty] = item[valueProperty].toString());
1505
1520
  }
1506
- else {
1521
+ else if (_.isObject(data)) {
1507
1522
  data[valueProperty] = data[valueProperty].toString();
1508
1523
  }
1509
1524
  return data;
@@ -1538,7 +1553,7 @@ export default class SelectComponent extends ListComponent {
1538
1553
  };
1539
1554
  value = (this.component.multiple && Array.isArray(value))
1540
1555
  ? _.filter(items, (item) => value.includes(item.value))
1541
- : valueProperty
1556
+ : (valueProperty && items)
1542
1557
  ? getFromValues() ?? { value, label: value }
1543
1558
  : value;
1544
1559
  }