@formio/js 5.0.0-dev.5799.552d965 → 5.0.0-dev.5800.896e9df

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.
@@ -2,11 +2,11 @@ export default class Multivalue extends Field {
2
2
  /**
3
3
  * Normalize values coming into updateValue.
4
4
  * @param {*} value - The value to normalize before setting.
5
- * @param {Object} flags - Flags to use when normalizing the value.
5
+ * @param {object} flags - Flags to use when normalizing the value.
6
6
  * @param {*} emptyValue - The empty value for the field.
7
7
  * @returns {*} - The normalized value.
8
8
  */
9
- normalizeValue(value: any, flags?: Object, emptyValue?: any): any;
9
+ normalizeValue(value: any, flags?: object, emptyValue?: any): any;
10
10
  get addAnother(): string;
11
11
  /**
12
12
  * @returns {Field} - The created field.
@@ -5,23 +5,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Field_1 = __importDefault(require("../field/Field"));
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
+ const core_1 = require("@formio/core");
8
9
  class Multivalue extends Field_1.default {
9
10
  /**
10
11
  * Normalize values coming into updateValue.
11
12
  * @param {*} value - The value to normalize before setting.
12
- * @param {Object} flags - Flags to use when normalizing the value.
13
+ * @param {object} flags - Flags to use when normalizing the value.
13
14
  * @param {*} emptyValue - The empty value for the field.
14
15
  * @returns {*} - The normalized value.
15
16
  */
16
17
  normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
18
+ const underlyingValueShouldBeArray = core_1.Utils.getModelType(this.component) === 'array' || this.component.storeas === 'array' || Array.isArray(emptyValue);
17
19
  if (this.component.multiple) {
18
20
  if (Array.isArray(value)) {
21
+ if (underlyingValueShouldBeArray) {
22
+ if (value.length === 0 || !Array.isArray(value[0])) {
23
+ return [value];
24
+ }
25
+ }
19
26
  if (value.length === 0) {
20
27
  return [emptyValue];
21
28
  }
22
- if (this.component.storeas === 'array') {
23
- return super.normalizeValue([value], flags);
24
- }
25
29
  return super.normalizeValue(value, flags);
26
30
  }
27
31
  else {
@@ -29,7 +33,7 @@ class Multivalue extends Field_1.default {
29
33
  }
30
34
  }
31
35
  else {
32
- if (Array.isArray(value) && !Array.isArray(emptyValue)) {
36
+ if (Array.isArray(value) && !underlyingValueShouldBeArray) {
33
37
  if (this.component.storeas === 'string') {
34
38
  return super.normalizeValue(value.join(this.delimiter || ''), flags);
35
39
  }
@@ -561,7 +561,7 @@ class DayComponent extends Field_1.default {
561
561
  }
562
562
  isPartialDay(value) {
563
563
  if (!value) {
564
- return false;
564
+ return true;
565
565
  }
566
566
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
567
567
  const values = value.split('/');
@@ -1487,7 +1487,7 @@ class SelectComponent extends ListComponent_1.default {
1487
1487
  if (Array.isArray(data)) {
1488
1488
  data.forEach((item) => item[valueProperty] = item[valueProperty].toString());
1489
1489
  }
1490
- else if (lodash_1.default.isObject(data)) {
1490
+ else {
1491
1491
  data[valueProperty] = data[valueProperty].toString();
1492
1492
  }
1493
1493
  return data;
@@ -1522,7 +1522,7 @@ class SelectComponent extends ListComponent_1.default {
1522
1522
  };
1523
1523
  value = (this.component.multiple && Array.isArray(value))
1524
1524
  ? lodash_1.default.filter(items, (item) => value.includes(item.value))
1525
- : (valueProperty && items)
1525
+ : valueProperty
1526
1526
  ? (_a = getFromValues()) !== null && _a !== void 0 ? _a : { value, label: value }
1527
1527
  : value;
1528
1528
  }
@@ -23,6 +23,5 @@ import comp23 from './comp23';
23
23
  import comp24 from './comp24';
24
24
  import comp25 from './comp25';
25
25
  import comp26 from './comp26';
26
- import comp27 from './comp27';
27
- 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 };
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 };
28
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.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;
6
+ 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"));
@@ -57,5 +57,3 @@ const comp25_1 = __importDefault(require("./comp25"));
57
57
  exports.comp25 = comp25_1.default;
58
58
  const comp26_1 = __importDefault(require("./comp26"));
59
59
  exports.comp26 = comp26_1.default;
60
- const comp27_1 = __importDefault(require("./comp27"));
61
- exports.comp27 = comp27_1.default;
@@ -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;
@@ -2,11 +2,11 @@ export default class Multivalue extends Field {
2
2
  /**
3
3
  * Normalize values coming into updateValue.
4
4
  * @param {*} value - The value to normalize before setting.
5
- * @param {Object} flags - Flags to use when normalizing the value.
5
+ * @param {object} flags - Flags to use when normalizing the value.
6
6
  * @param {*} emptyValue - The empty value for the field.
7
7
  * @returns {*} - The normalized value.
8
8
  */
9
- normalizeValue(value: any, flags?: Object, emptyValue?: any): any;
9
+ normalizeValue(value: any, flags?: object, emptyValue?: any): any;
10
10
  get addAnother(): string;
11
11
  /**
12
12
  * @returns {Field} - The created field.
@@ -1,22 +1,26 @@
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.
7
- * @param {Object} flags - Flags to use when normalizing the value.
8
+ * @param {object} flags - Flags to use when normalizing the value.
8
9
  * @param {*} emptyValue - The empty value for the field.
9
10
  * @returns {*} - The normalized value.
10
11
  */
11
12
  normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
13
+ const underlyingValueShouldBeArray = Utils.getModelType(this.component) === 'array' || this.component.storeas === 'array' || Array.isArray(emptyValue);
12
14
  if (this.component.multiple) {
13
15
  if (Array.isArray(value)) {
16
+ if (underlyingValueShouldBeArray) {
17
+ if (value.length === 0 || !Array.isArray(value[0])) {
18
+ return [value];
19
+ }
20
+ }
14
21
  if (value.length === 0) {
15
22
  return [emptyValue];
16
23
  }
17
- if (this.component.storeas === 'array') {
18
- return super.normalizeValue([value], flags);
19
- }
20
24
  return super.normalizeValue(value, flags);
21
25
  }
22
26
  else {
@@ -24,7 +28,7 @@ export default class Multivalue extends Field {
24
28
  }
25
29
  }
26
30
  else {
27
- if (Array.isArray(value) && !Array.isArray(emptyValue)) {
31
+ if (Array.isArray(value) && !underlyingValueShouldBeArray) {
28
32
  if (this.component.storeas === 'string') {
29
33
  return super.normalizeValue(value.join(this.delimiter || ''), flags);
30
34
  }
@@ -557,7 +557,7 @@ export default class DayComponent extends Field {
557
557
  }
558
558
  isPartialDay(value) {
559
559
  if (!value) {
560
- return false;
560
+ return true;
561
561
  }
562
562
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
563
563
  const values = value.split('/');
@@ -1514,7 +1514,7 @@ export default class SelectComponent extends ListComponent {
1514
1514
  if (Array.isArray(data)) {
1515
1515
  data.forEach((item) => item[valueProperty] = item[valueProperty].toString());
1516
1516
  }
1517
- else if (_.isObject(data)) {
1517
+ else {
1518
1518
  data[valueProperty] = data[valueProperty].toString();
1519
1519
  }
1520
1520
  return data;
@@ -1549,7 +1549,7 @@ export default class SelectComponent extends ListComponent {
1549
1549
  };
1550
1550
  value = (this.component.multiple && Array.isArray(value))
1551
1551
  ? _.filter(items, (item) => value.includes(item.value))
1552
- : (valueProperty && items)
1552
+ : valueProperty
1553
1553
  ? getFromValues() ?? { value, label: value }
1554
1554
  : value;
1555
1555
  }
@@ -23,6 +23,5 @@ import comp23 from './comp23';
23
23
  import comp24 from './comp24';
24
24
  import comp25 from './comp25';
25
25
  import comp26 from './comp26';
26
- import comp27 from './comp27';
27
- 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 };
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 };
28
27
  export { multiSelect, multiSelectOptions } from "./comp3";
@@ -24,5 +24,4 @@ import comp23 from './comp23';
24
24
  import comp24 from './comp24';
25
25
  import comp25 from './comp25';
26
26
  import comp26 from './comp26';
27
- import comp27 from './comp27';
28
- 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 };
27
+ 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 };
@@ -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,5 +1,5 @@
1
1
  import { Utils } from '@formio/core';
2
- 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 } = Utils;
2
+ 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 } = Utils;
3
3
  /**
4
4
  * Deprecated version of findComponents. Renamed to searchComponents.
5
5
  * @param {import('@formio/core').Component[]} components - The components to find components within.
@@ -10,4 +10,4 @@ export function findComponents(components, query) {
10
10
  console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');
11
11
  return searchComponents(components, query);
12
12
  }
13
- export { 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 };
13
+ export { 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5799.552d965",
3
+ "version": "5.0.0-dev.5800.896e9df",
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-dev.98.17ba6ea",
83
83
  "@formio/choices.js": "^10.2.1",
84
- "@formio/core": "2.1.0-dev.145.4491833",
84
+ "@formio/core": "2.1.0-dev.146.e57530c",
85
85
  "@formio/text-mask-addons": "^3.8.0-formio.2",
86
86
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
87
87
  "abortcontroller-polyfill": "^1.7.5",
@@ -1,18 +0,0 @@
1
- declare namespace _default {
2
- let type: string;
3
- let label: string;
4
- let widget: string;
5
- let tableView: boolean;
6
- let dataSrc: string;
7
- namespace data {
8
- let custom: string;
9
- }
10
- let dataType: string;
11
- let idPath: string;
12
- let valueProperty: string;
13
- let template: string;
14
- let validateWhenHidden: boolean;
15
- let key: string;
16
- let input: boolean;
17
- }
18
- export default _default;
@@ -1,19 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
1
- declare namespace _default {
2
- let type: string;
3
- let label: string;
4
- let widget: string;
5
- let tableView: boolean;
6
- let dataSrc: string;
7
- namespace data {
8
- let custom: string;
9
- }
10
- let dataType: string;
11
- let idPath: string;
12
- let valueProperty: string;
13
- let template: string;
14
- let validateWhenHidden: boolean;
15
- let key: string;
16
- let input: boolean;
17
- }
18
- export default _default;
@@ -1,17 +0,0 @@
1
- export default {
2
- type: 'select',
3
- label: 'Select',
4
- widget: 'choicesjs',
5
- tableView: true,
6
- dataSrc: 'custom',
7
- data: {
8
- custom: 'values = data.dataSource;'
9
- },
10
- dataType: 'string',
11
- idPath: 'name',
12
- valueProperty: 'name',
13
- template: '<span>{{ item.name }}</span>',
14
- validateWhenHidden: false,
15
- key: 'select',
16
- input: true
17
- };