@formio/js 5.0.0-dev.5664.1af299f → 5.0.0-dev.5670.4e330b8

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.
Files changed (30) hide show
  1. package/Changelog.md +3 -2
  2. package/dist/formio.form.js +2 -98
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.full.js +2 -2
  5. package/dist/formio.full.min.js +1 -1
  6. package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
  7. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  8. package/lib/cjs/components/checkbox/fixtures/comp6.d.ts +32 -0
  9. package/lib/cjs/components/checkbox/fixtures/comp6.js +30 -0
  10. package/lib/cjs/components/checkbox/fixtures/index.d.ts +2 -1
  11. package/lib/cjs/components/checkbox/fixtures/index.js +3 -1
  12. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -9
  13. package/lib/cjs/components/datagrid/DataGrid.js +32 -47
  14. package/lib/cjs/components/datagrid/fixtures/index.d.ts +1 -2
  15. package/lib/cjs/components/datagrid/fixtures/index.js +1 -3
  16. package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
  17. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  18. package/lib/mjs/components/checkbox/fixtures/comp6.d.ts +32 -0
  19. package/lib/mjs/components/checkbox/fixtures/comp6.js +28 -0
  20. package/lib/mjs/components/checkbox/fixtures/index.d.ts +2 -1
  21. package/lib/mjs/components/checkbox/fixtures/index.js +2 -1
  22. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -9
  23. package/lib/mjs/components/datagrid/DataGrid.js +32 -47
  24. package/lib/mjs/components/datagrid/fixtures/index.d.ts +1 -2
  25. package/lib/mjs/components/datagrid/fixtures/index.js +1 -2
  26. package/package.json +1 -1
  27. package/lib/cjs/components/datagrid/fixtures/comp-with-reorder.d.ts +0 -100
  28. package/lib/cjs/components/datagrid/fixtures/comp-with-reorder.js +0 -139
  29. package/lib/mjs/components/datagrid/fixtures/comp-with-reorder.d.ts +0 -100
  30. package/lib/mjs/components/datagrid/fixtures/comp-with-reorder.js +0 -137
@@ -43,7 +43,7 @@ export default class CheckBoxComponent extends Field {
43
43
  attach(element: any): Promise<void>;
44
44
  input: any;
45
45
  detach(element: any): void;
46
- get emptyValue(): false | null;
46
+ get emptyValue(): false | "";
47
47
  getValueAt(index: any): any;
48
48
  get checked(): boolean;
49
49
  setCheckedState(value: any): any;
@@ -117,7 +117,7 @@ class CheckBoxComponent extends Field_1.default {
117
117
  super.detach();
118
118
  }
119
119
  get emptyValue() {
120
- return this.component.inputType === 'radio' ? null : false;
120
+ return this.component.inputType === 'radio' ? '' : false;
121
121
  }
122
122
  isEmpty(value = this.dataValue) {
123
123
  return super.isEmpty(value) || value === false;
@@ -0,0 +1,32 @@
1
+ declare namespace _default {
2
+ let name: string;
3
+ let path: string;
4
+ let type: string;
5
+ let display: string;
6
+ let components: ({
7
+ label: string;
8
+ inputType: string;
9
+ tableView: boolean;
10
+ defaultValue: boolean;
11
+ key: string;
12
+ type: string;
13
+ name: string;
14
+ value: string;
15
+ input: boolean;
16
+ 'some name': boolean;
17
+ disableOnInvalid?: undefined;
18
+ } | {
19
+ type: string;
20
+ label: string;
21
+ key: string;
22
+ disableOnInvalid: boolean;
23
+ input: boolean;
24
+ tableView: boolean;
25
+ inputType?: undefined;
26
+ defaultValue?: undefined;
27
+ name?: undefined;
28
+ value?: undefined;
29
+ 'some name'?: undefined;
30
+ })[];
31
+ }
32
+ export default _default;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ name: 'ckeckbox',
5
+ path: 'ckeckbox',
6
+ type: 'form',
7
+ display: 'form',
8
+ components: [
9
+ {
10
+ label: 'Checkbox',
11
+ inputType: 'radio',
12
+ tableView: false,
13
+ defaultValue: false,
14
+ key: 'checkbox',
15
+ type: 'checkbox',
16
+ name: 'some name',
17
+ value: 'ok',
18
+ input: true,
19
+ 'some name': false
20
+ },
21
+ {
22
+ type: 'button',
23
+ label: 'Submit',
24
+ key: 'submit',
25
+ disableOnInvalid: true,
26
+ input: true,
27
+ tableView: false
28
+ }
29
+ ],
30
+ };
@@ -3,5 +3,6 @@ import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
+ import comp6 from './comp6';
6
7
  import customDefaultComponent from './customDefaultComponent';
7
- export { comp1, comp2, comp3, comp4, comp5, customDefaultComponent };
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, customDefaultComponent };
@@ -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.customDefaultComponent = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.customDefaultComponent = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const customDefaultComponent_1 = __importDefault(require("./customDefaultComponent"));
@@ -16,3 +16,5 @@ const comp4_1 = __importDefault(require("./comp4"));
16
16
  exports.comp4 = comp4_1.default;
17
17
  const comp5_1 = __importDefault(require("./comp5"));
18
18
  exports.comp5 = comp5_1.default;
19
+ const comp6_1 = __importDefault(require("./comp6"));
20
+ exports.comp6 = comp6_1.default;
@@ -61,15 +61,6 @@ export default class DataGridComponent extends NestedArrayComponent {
61
61
  loadRefs(element: any, refs: any): void;
62
62
  dragula: any;
63
63
  getComponentsContainer(): any;
64
- /**
65
- * Reorder values in array based on the old and new position
66
- * @param {any} valuesArr - An array of values.
67
- * @param {number} oldPosition - The index of the value in array before reordering.
68
- * @param {number} newPosition - The index of the value in array after reordering.
69
- * @param {boolean|any} movedBelow - Whether or not the value is moved below.
70
- * @returns {void}
71
- */
72
- reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
73
64
  onReorder(element: any, _target: any, _source: any, sibling: any): void;
74
65
  focusOnNewRowElement(row: any): void;
75
66
  addRow(): void;
@@ -7,7 +7,6 @@ const lodash_1 = __importDefault(require("lodash"));
7
7
  const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
8
8
  const utils_1 = require("../../utils/utils");
9
9
  const Components_1 = require("../Components");
10
- const dragula_1 = __importDefault(require("dragula"));
11
10
  class DataGridComponent extends NestedArrayComponent_1.default {
12
11
  static schema(...extend) {
13
12
  return NestedArrayComponent_1.default.schema({
@@ -282,32 +281,34 @@ class DataGridComponent extends NestedArrayComponent_1.default {
282
281
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
283
282
  row.dragInfo = { index };
284
283
  });
285
- this.dragula = (0, dragula_1.default)([this.refs[`${this.datagridKey}-tbody`]], {
286
- moves: (_draggedElement, _oldParent, clickedElement) => {
287
- const clickedElementKey = clickedElement.getAttribute('data-key');
288
- const oldParentKey = _oldParent.getAttribute('data-key');
289
- //Check if the clicked button belongs to that container, if false, it belongs to the nested container
290
- if (oldParentKey === clickedElementKey) {
291
- return clickedElement.classList.contains('formio-drag-button');
292
- }
293
- }
294
- }).on('drop', this.onReorder.bind(this));
295
- this.dragula.on('cloned', (el, original) => {
296
- if (el && el.children && original && original.children) {
297
- lodash_1.default.each(original.children, (child, index) => {
298
- const styles = getComputedStyle(child, null);
299
- if (styles.cssText !== '') {
300
- el.children[index].style.cssText = styles.cssText;
301
- }
302
- else {
303
- const cssText = Object.values(styles).reduce((css, propertyName) => {
304
- return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
305
- }, '');
306
- el.children[index].style.cssText = cssText;
284
+ if (this.root.dragulaLib) {
285
+ this.dragula = this.root.dragulaLib([this.refs[`${this.datagridKey}-tbody`]], {
286
+ moves: (_draggedElement, _oldParent, clickedElement) => {
287
+ const clickedElementKey = clickedElement.getAttribute('data-key');
288
+ const oldParentKey = _oldParent.getAttribute('data-key');
289
+ //Check if the clicked button belongs to that container, if false, it belongs to the nested container
290
+ if (oldParentKey === clickedElementKey) {
291
+ return clickedElement.classList.contains('formio-drag-button');
307
292
  }
308
- });
309
- }
310
- });
293
+ }
294
+ }).on('drop', this.onReorder.bind(this));
295
+ this.dragula.on('cloned', (el, original) => {
296
+ if (el && el.children && original && original.children) {
297
+ lodash_1.default.each(original.children, (child, index) => {
298
+ const styles = getComputedStyle(child, null);
299
+ if (styles.cssText !== '') {
300
+ el.children[index].style.cssText = styles.cssText;
301
+ }
302
+ else {
303
+ const cssText = Object.values(styles).reduce((css, propertyName) => {
304
+ return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
305
+ }, '');
306
+ el.children[index].style.cssText = cssText;
307
+ }
308
+ });
309
+ }
310
+ });
311
+ }
311
312
  }
312
313
  this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
313
314
  this.addEventListener(addButton, 'click', this.addRow.bind(this));
@@ -335,24 +336,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
335
336
  getComponentsContainer() {
336
337
  return this.component.components;
337
338
  }
338
- /**
339
- * Reorder values in array based on the old and new position
340
- * @param {any} valuesArr - An array of values.
341
- * @param {number} oldPosition - The index of the value in array before reordering.
342
- * @param {number} newPosition - The index of the value in array after reordering.
343
- * @param {boolean|any} movedBelow - Whether or not the value is moved below.
344
- * @returns {void}
345
- */
346
- reorderValues(valuesArr, oldPosition, newPosition, movedBelow) {
347
- if (!lodash_1.default.isArray(valuesArr) || lodash_1.default.isEmpty(valuesArr)) {
348
- return;
349
- }
350
- const draggedRowData = valuesArr[oldPosition];
351
- //insert element at new position
352
- valuesArr.splice(newPosition, 0, draggedRowData);
353
- //remove element from old position (if was moved above, after insertion it's at +1 index)
354
- valuesArr.splice(movedBelow ? oldPosition : oldPosition + 1, 1);
355
- }
356
339
  onReorder(element, _target, _source, sibling) {
357
340
  if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
358
341
  console.warn('There is no Drag Info available for either dragged or sibling element');
@@ -363,9 +346,11 @@ class DataGridComponent extends NestedArrayComponent_1.default {
363
346
  const newPosition = sibling ? sibling.dragInfo.index : this.dataValue.length;
364
347
  const movedBelow = newPosition > oldPosition;
365
348
  const dataValue = (0, utils_1.fastCloneDeep)(this.dataValue);
366
- this.reorderValues(dataValue, oldPosition, newPosition, movedBelow);
367
- //reorder select data
368
- this.reorderValues(lodash_1.default.get(this.root, `submission.metadata.selectData.${this.path}`, []), oldPosition, newPosition, movedBelow);
349
+ const draggedRowData = dataValue[oldPosition];
350
+ //insert element at new position
351
+ dataValue.splice(newPosition, 0, draggedRowData);
352
+ //remove element from old position (if was moved above, after insertion it's at +1 index)
353
+ dataValue.splice(movedBelow ? oldPosition : oldPosition + 1, 1);
369
354
  //need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
370
355
  this.setValue(dataValue, { isReordered: true });
371
356
  this.rebuild();
@@ -15,5 +15,4 @@ import modalWithRequiredFields from './comp-modal-with-required-fields';
15
15
  import withAllowCalculateOverride from './comp-with-allow-calculate-override';
16
16
  import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
17
17
  import withCheckboxes from './comp-with-checkboxes';
18
- import withReorder from './comp-with-reorder';
19
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes, withReorder };
18
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
@@ -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.withReorder = exports.withCheckboxes = exports.twoWithAllowCalculatedOverride = exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.withCheckboxes = exports.twoWithAllowCalculatedOverride = exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = 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"));
@@ -38,5 +38,3 @@ const two_comp_with_allow_calculate_override_1 = __importDefault(require("./two-
38
38
  exports.twoWithAllowCalculatedOverride = two_comp_with_allow_calculate_override_1.default;
39
39
  const comp_with_checkboxes_1 = __importDefault(require("./comp-with-checkboxes"));
40
40
  exports.withCheckboxes = comp_with_checkboxes_1.default;
41
- const comp_with_reorder_1 = __importDefault(require("./comp-with-reorder"));
42
- exports.withReorder = comp_with_reorder_1.default;
@@ -43,7 +43,7 @@ export default class CheckBoxComponent extends Field {
43
43
  attach(element: any): Promise<void>;
44
44
  input: any;
45
45
  detach(element: any): void;
46
- get emptyValue(): false | null;
46
+ get emptyValue(): false | "";
47
47
  getValueAt(index: any): any;
48
48
  get checked(): boolean;
49
49
  setCheckedState(value: any): any;
@@ -116,7 +116,7 @@ export default class CheckBoxComponent extends Field {
116
116
  super.detach();
117
117
  }
118
118
  get emptyValue() {
119
- return this.component.inputType === 'radio' ? null : false;
119
+ return this.component.inputType === 'radio' ? '' : false;
120
120
  }
121
121
  isEmpty(value = this.dataValue) {
122
122
  return super.isEmpty(value) || value === false;
@@ -0,0 +1,32 @@
1
+ declare namespace _default {
2
+ let name: string;
3
+ let path: string;
4
+ let type: string;
5
+ let display: string;
6
+ let components: ({
7
+ label: string;
8
+ inputType: string;
9
+ tableView: boolean;
10
+ defaultValue: boolean;
11
+ key: string;
12
+ type: string;
13
+ name: string;
14
+ value: string;
15
+ input: boolean;
16
+ 'some name': boolean;
17
+ disableOnInvalid?: undefined;
18
+ } | {
19
+ type: string;
20
+ label: string;
21
+ key: string;
22
+ disableOnInvalid: boolean;
23
+ input: boolean;
24
+ tableView: boolean;
25
+ inputType?: undefined;
26
+ defaultValue?: undefined;
27
+ name?: undefined;
28
+ value?: undefined;
29
+ 'some name'?: undefined;
30
+ })[];
31
+ }
32
+ export default _default;
@@ -0,0 +1,28 @@
1
+ export default {
2
+ name: 'ckeckbox',
3
+ path: 'ckeckbox',
4
+ type: 'form',
5
+ display: 'form',
6
+ components: [
7
+ {
8
+ label: 'Checkbox',
9
+ inputType: 'radio',
10
+ tableView: false,
11
+ defaultValue: false,
12
+ key: 'checkbox',
13
+ type: 'checkbox',
14
+ name: 'some name',
15
+ value: 'ok',
16
+ input: true,
17
+ 'some name': false
18
+ },
19
+ {
20
+ type: 'button',
21
+ label: 'Submit',
22
+ key: 'submit',
23
+ disableOnInvalid: true,
24
+ input: true,
25
+ tableView: false
26
+ }
27
+ ],
28
+ };
@@ -3,5 +3,6 @@ import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
+ import comp6 from './comp6';
6
7
  import customDefaultComponent from './customDefaultComponent';
7
- export { comp1, comp2, comp3, comp4, comp5, customDefaultComponent };
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, customDefaultComponent };
@@ -4,4 +4,5 @@ import comp2 from './comp2';
4
4
  import comp3 from './comp3';
5
5
  import comp4 from './comp4';
6
6
  import comp5 from './comp5';
7
- export { comp1, comp2, comp3, comp4, comp5, customDefaultComponent };
7
+ import comp6 from './comp6';
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, customDefaultComponent };
@@ -61,15 +61,6 @@ export default class DataGridComponent extends NestedArrayComponent {
61
61
  loadRefs(element: any, refs: any): void;
62
62
  dragula: any;
63
63
  getComponentsContainer(): any;
64
- /**
65
- * Reorder values in array based on the old and new position
66
- * @param {any} valuesArr - An array of values.
67
- * @param {number} oldPosition - The index of the value in array before reordering.
68
- * @param {number} newPosition - The index of the value in array after reordering.
69
- * @param {boolean|any} movedBelow - Whether or not the value is moved below.
70
- * @returns {void}
71
- */
72
- reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
73
64
  onReorder(element: any, _target: any, _source: any, sibling: any): void;
74
65
  focusOnNewRowElement(row: any): void;
75
66
  addRow(): void;
@@ -2,7 +2,6 @@ import _ from 'lodash';
2
2
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
3
3
  import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
4
4
  import { Components } from '../Components';
5
- import dragula from 'dragula';
6
5
  export default class DataGridComponent extends NestedArrayComponent {
7
6
  static schema(...extend) {
8
7
  return NestedArrayComponent.schema({
@@ -279,32 +278,34 @@ export default class DataGridComponent extends NestedArrayComponent {
279
278
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
280
279
  row.dragInfo = { index };
281
280
  });
282
- this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
283
- moves: (_draggedElement, _oldParent, clickedElement) => {
284
- const clickedElementKey = clickedElement.getAttribute('data-key');
285
- const oldParentKey = _oldParent.getAttribute('data-key');
286
- //Check if the clicked button belongs to that container, if false, it belongs to the nested container
287
- if (oldParentKey === clickedElementKey) {
288
- return clickedElement.classList.contains('formio-drag-button');
289
- }
290
- }
291
- }).on('drop', this.onReorder.bind(this));
292
- this.dragula.on('cloned', (el, original) => {
293
- if (el && el.children && original && original.children) {
294
- _.each(original.children, (child, index) => {
295
- const styles = getComputedStyle(child, null);
296
- if (styles.cssText !== '') {
297
- el.children[index].style.cssText = styles.cssText;
298
- }
299
- else {
300
- const cssText = Object.values(styles).reduce((css, propertyName) => {
301
- return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
302
- }, '');
303
- el.children[index].style.cssText = cssText;
281
+ if (this.root.dragulaLib) {
282
+ this.dragula = this.root.dragulaLib([this.refs[`${this.datagridKey}-tbody`]], {
283
+ moves: (_draggedElement, _oldParent, clickedElement) => {
284
+ const clickedElementKey = clickedElement.getAttribute('data-key');
285
+ const oldParentKey = _oldParent.getAttribute('data-key');
286
+ //Check if the clicked button belongs to that container, if false, it belongs to the nested container
287
+ if (oldParentKey === clickedElementKey) {
288
+ return clickedElement.classList.contains('formio-drag-button');
304
289
  }
305
- });
306
- }
307
- });
290
+ }
291
+ }).on('drop', this.onReorder.bind(this));
292
+ this.dragula.on('cloned', (el, original) => {
293
+ if (el && el.children && original && original.children) {
294
+ _.each(original.children, (child, index) => {
295
+ const styles = getComputedStyle(child, null);
296
+ if (styles.cssText !== '') {
297
+ el.children[index].style.cssText = styles.cssText;
298
+ }
299
+ else {
300
+ const cssText = Object.values(styles).reduce((css, propertyName) => {
301
+ return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
302
+ }, '');
303
+ el.children[index].style.cssText = cssText;
304
+ }
305
+ });
306
+ }
307
+ });
308
+ }
308
309
  }
309
310
  this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
310
311
  this.addEventListener(addButton, 'click', this.addRow.bind(this));
@@ -332,24 +333,6 @@ export default class DataGridComponent extends NestedArrayComponent {
332
333
  getComponentsContainer() {
333
334
  return this.component.components;
334
335
  }
335
- /**
336
- * Reorder values in array based on the old and new position
337
- * @param {any} valuesArr - An array of values.
338
- * @param {number} oldPosition - The index of the value in array before reordering.
339
- * @param {number} newPosition - The index of the value in array after reordering.
340
- * @param {boolean|any} movedBelow - Whether or not the value is moved below.
341
- * @returns {void}
342
- */
343
- reorderValues(valuesArr, oldPosition, newPosition, movedBelow) {
344
- if (!_.isArray(valuesArr) || _.isEmpty(valuesArr)) {
345
- return;
346
- }
347
- const draggedRowData = valuesArr[oldPosition];
348
- //insert element at new position
349
- valuesArr.splice(newPosition, 0, draggedRowData);
350
- //remove element from old position (if was moved above, after insertion it's at +1 index)
351
- valuesArr.splice(movedBelow ? oldPosition : oldPosition + 1, 1);
352
- }
353
336
  onReorder(element, _target, _source, sibling) {
354
337
  if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
355
338
  console.warn('There is no Drag Info available for either dragged or sibling element');
@@ -360,9 +343,11 @@ export default class DataGridComponent extends NestedArrayComponent {
360
343
  const newPosition = sibling ? sibling.dragInfo.index : this.dataValue.length;
361
344
  const movedBelow = newPosition > oldPosition;
362
345
  const dataValue = fastCloneDeep(this.dataValue);
363
- this.reorderValues(dataValue, oldPosition, newPosition, movedBelow);
364
- //reorder select data
365
- this.reorderValues(_.get(this.root, `submission.metadata.selectData.${this.path}`, []), oldPosition, newPosition, movedBelow);
346
+ const draggedRowData = dataValue[oldPosition];
347
+ //insert element at new position
348
+ dataValue.splice(newPosition, 0, draggedRowData);
349
+ //remove element from old position (if was moved above, after insertion it's at +1 index)
350
+ dataValue.splice(movedBelow ? oldPosition : oldPosition + 1, 1);
366
351
  //need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
367
352
  this.setValue(dataValue, { isReordered: true });
368
353
  this.rebuild();
@@ -15,5 +15,4 @@ import modalWithRequiredFields from './comp-modal-with-required-fields';
15
15
  import withAllowCalculateOverride from './comp-with-allow-calculate-override';
16
16
  import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
17
17
  import withCheckboxes from './comp-with-checkboxes';
18
- import withReorder from './comp-with-reorder';
19
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes, withReorder };
18
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
@@ -15,5 +15,4 @@ import withCollapsibleRowGroups from './comp-with-collapsible-groups';
15
15
  import withAllowCalculateOverride from './comp-with-allow-calculate-override';
16
16
  import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
17
17
  import withCheckboxes from './comp-with-checkboxes';
18
- import withReorder from './comp-with-reorder';
19
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes, withReorder };
18
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5664.1af299f",
3
+ "version": "5.0.0-dev.5670.4e330b8",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -1,100 +0,0 @@
1
- declare namespace _default {
2
- export { form };
3
- export { submission };
4
- }
5
- export default _default;
6
- declare namespace form {
7
- let _id: string;
8
- let title: string;
9
- let name: string;
10
- let path: string;
11
- let type: string;
12
- let display: string;
13
- let components: ({
14
- label: string;
15
- reorder: boolean;
16
- addAnotherPosition: string;
17
- layoutFixed: boolean;
18
- enableRowGroups: boolean;
19
- initEmpty: boolean;
20
- tableView: boolean;
21
- defaultValue: {
22
- select: string;
23
- }[];
24
- key: string;
25
- type: string;
26
- input: boolean;
27
- components: {
28
- label: string;
29
- widget: string;
30
- tableView: boolean;
31
- dataSrc: string;
32
- data: {
33
- resource: string;
34
- };
35
- dataType: string;
36
- valueProperty: string;
37
- template: string;
38
- validate: {
39
- select: boolean;
40
- };
41
- key: string;
42
- type: string;
43
- searchField: string;
44
- limit: number;
45
- noRefreshOnScroll: boolean;
46
- addResource: boolean;
47
- reference: boolean;
48
- input: boolean;
49
- }[];
50
- disableOnInvalid?: undefined;
51
- } | {
52
- type: string;
53
- label: string;
54
- key: string;
55
- disableOnInvalid: boolean;
56
- input: boolean;
57
- tableView: boolean;
58
- reorder?: undefined;
59
- addAnotherPosition?: undefined;
60
- layoutFixed?: undefined;
61
- enableRowGroups?: undefined;
62
- initEmpty?: undefined;
63
- defaultValue?: undefined;
64
- components?: undefined;
65
- })[];
66
- let created: string;
67
- let modified: string;
68
- let machineName: string;
69
- }
70
- declare namespace submission {
71
- let form_1: string;
72
- export { form_1 as form };
73
- export namespace metadata {
74
- namespace selectData {
75
- let dataGrid: {
76
- select: {
77
- data: {
78
- number: number;
79
- };
80
- };
81
- }[];
82
- }
83
- }
84
- export namespace data {
85
- let dataGrid_1: {
86
- select: string;
87
- }[];
88
- export { dataGrid_1 as dataGrid };
89
- export let dataTable: never[];
90
- export let submit: boolean;
91
- }
92
- let _id_1: string;
93
- export { _id_1 as _id };
94
- export let project: string;
95
- export let state: string;
96
- let created_1: string;
97
- export { created_1 as created };
98
- let modified_1: string;
99
- export { modified_1 as modified };
100
- }