@formio/js 5.0.0-dev.5707.d029d4d → 5.0.0-dev.5710.e2e8388

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 (40) hide show
  1. package/Changelog.md +1 -0
  2. package/dist/formio.embed.js +1 -1
  3. package/dist/formio.embed.min.js +1 -1
  4. package/dist/formio.form.js +6 -102
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.full.js +7 -7
  7. package/dist/formio.full.min.js +1 -1
  8. package/dist/formio.js +1 -1
  9. package/dist/formio.min.js +1 -1
  10. package/lib/cjs/CDN.d.ts +1 -0
  11. package/lib/cjs/CDN.js +1 -0
  12. package/lib/cjs/Webform.js +0 -2
  13. package/lib/cjs/WebformBuilder.d.ts +5 -0
  14. package/lib/cjs/WebformBuilder.js +22 -15
  15. package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
  16. package/lib/cjs/components/_classes/component/Component.js +18 -0
  17. package/lib/cjs/components/datagrid/DataGrid.d.ts +2 -0
  18. package/lib/cjs/components/datagrid/DataGrid.js +38 -26
  19. package/lib/cjs/components/datamap/DataMap.js +2 -2
  20. package/lib/cjs/components/editgrid/EditGrid.js +2 -1
  21. package/lib/cjs/components/editgrid/fixtures/comp16.d.ts +52 -0
  22. package/lib/cjs/components/editgrid/fixtures/comp16.js +71 -0
  23. package/lib/cjs/components/editgrid/fixtures/index.d.ts +2 -1
  24. package/lib/cjs/components/editgrid/fixtures/index.js +3 -1
  25. package/lib/mjs/CDN.d.ts +1 -0
  26. package/lib/mjs/CDN.js +1 -0
  27. package/lib/mjs/Webform.js +0 -2
  28. package/lib/mjs/WebformBuilder.d.ts +5 -0
  29. package/lib/mjs/WebformBuilder.js +22 -15
  30. package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
  31. package/lib/mjs/components/_classes/component/Component.js +7 -0
  32. package/lib/mjs/components/datagrid/DataGrid.d.ts +2 -0
  33. package/lib/mjs/components/datagrid/DataGrid.js +37 -25
  34. package/lib/mjs/components/datamap/DataMap.js +1 -1
  35. package/lib/mjs/components/editgrid/EditGrid.js +2 -1
  36. package/lib/mjs/components/editgrid/fixtures/comp16.d.ts +52 -0
  37. package/lib/mjs/components/editgrid/fixtures/comp16.js +69 -0
  38. package/lib/mjs/components/editgrid/fixtures/index.d.ts +2 -1
  39. package/lib/mjs/components/editgrid/fixtures/index.js +2 -1
  40. package/package.json +1 -1
@@ -1,8 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
3
3
  import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
4
- import { Components } from '../Components';
5
- import dragula from 'dragula';
4
+ import Components from '../Components';
6
5
  export default class DataGridComponent extends NestedArrayComponent {
7
6
  static schema(...extend) {
8
7
  return NestedArrayComponent.schema({
@@ -39,6 +38,9 @@ export default class DataGridComponent extends NestedArrayComponent {
39
38
  if (this.initRows || !_.isEqual(this.dataValue, this.emptyValue)) {
40
39
  this.createRows(true);
41
40
  }
41
+ if (this.allowReorder) {
42
+ this.dragulaReady = this.getDragula();
43
+ }
42
44
  this.visibleColumns = {};
43
45
  this.prevHasAddButton = this.hasAddButton();
44
46
  this.checkColumns();
@@ -279,31 +281,25 @@ export default class DataGridComponent extends NestedArrayComponent {
279
281
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
280
282
  row.dragInfo = { index };
281
283
  });
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
- }
284
+ this.dragulaReady.then((dragula) => {
285
+ // The drop event may call redraw twice which calls attach twice and because this block of code is asynchronous
286
+ // BOTH redraws may be called before this block of code runs (which causes this block of code to run twice sequentially).
287
+ // This causes two dragula() calls on the same container which breaks dragula. To fix this the return value must
288
+ // be saved in this.dragula and have its container contents reset if it exists
289
+ if (this.dragula && this.dragula.containers) {
290
+ this.dragula.containers = [];
290
291
  }
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;
292
+ this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
293
+ moves: (_draggedElement, _oldParent, clickedElement) => {
294
+ const clickedElementKey = clickedElement.getAttribute('data-key');
295
+ const oldParentKey = _oldParent.getAttribute('data-key');
296
+ //Check if the clicked button belongs to that container, if false, it belongs to the nested container
297
+ if (oldParentKey === clickedElementKey) {
298
+ return clickedElement.classList.contains('formio-drag-button');
298
299
  }
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
- }
300
+ }
301
+ }).on('drop', this.onReorder.bind(this))
302
+ .on('cloned', this.onCloned.bind(this));
307
303
  });
308
304
  }
309
305
  this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
@@ -370,6 +366,22 @@ export default class DataGridComponent extends NestedArrayComponent {
370
366
  this.setValue(dataValue, { isReordered: true });
371
367
  this.rebuild();
372
368
  }
369
+ onCloned(el, original) {
370
+ if (el && el.children && original && original.children) {
371
+ _.each(original.children, (child, index) => {
372
+ const styles = getComputedStyle(child, null);
373
+ if (styles.cssText !== '') {
374
+ el.children[index].style.cssText = styles.cssText;
375
+ }
376
+ else {
377
+ const cssText = Object.values(styles).reduce((css, propertyName) => {
378
+ return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
379
+ }, '');
380
+ el.children[index].style.cssText = cssText;
381
+ }
382
+ });
383
+ }
384
+ }
373
385
  focusOnNewRowElement(row) {
374
386
  Object.keys(row).find((key) => {
375
387
  const element = row[key].element;
@@ -3,7 +3,7 @@ import DataGridComponent from '../datagrid/DataGrid';
3
3
  import _ from 'lodash';
4
4
  import EventEmitter from 'eventemitter3';
5
5
  import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/utils';
6
- import { Components } from '../Components';
6
+ import Components from '../Components';
7
7
  export default class DataMapComponent extends DataGridComponent {
8
8
  static schema(...extend) {
9
9
  return Component.schema({
@@ -1089,7 +1089,8 @@ export default class EditGridComponent extends NestedArrayComponent {
1089
1089
  return false;
1090
1090
  }
1091
1091
  else if (rowsEditing && this.saveEditMode && !this.component.openWhenEmpty) {
1092
- this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);
1092
+ this._errors = this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);
1093
+ errors.push(...this._errors);
1093
1094
  return false;
1094
1095
  }
1095
1096
  const message = this.invalid || this.invalidMessage(data, dirty, false, row);
@@ -0,0 +1,52 @@
1
+ declare namespace _default {
2
+ let type: string;
3
+ let display: string;
4
+ let components: ({
5
+ title: string;
6
+ breadcrumbClickable: boolean;
7
+ buttonSettings: {
8
+ previous: boolean;
9
+ cancel: boolean;
10
+ next: boolean;
11
+ };
12
+ collapsible: boolean;
13
+ tableView: boolean;
14
+ key: string;
15
+ type: string;
16
+ label: string;
17
+ input: boolean;
18
+ components: {
19
+ label: string;
20
+ tableView: boolean;
21
+ rowDrafts: boolean;
22
+ key: string;
23
+ type: string;
24
+ input: boolean;
25
+ components: {
26
+ label: string;
27
+ tableView: boolean;
28
+ key: string;
29
+ type: string;
30
+ input: boolean;
31
+ alwaysEnabled: boolean;
32
+ }[];
33
+ alwaysEnabled: boolean;
34
+ }[];
35
+ alwaysEnabled: boolean;
36
+ showValidations?: undefined;
37
+ } | {
38
+ label: string;
39
+ showValidations: boolean;
40
+ alwaysEnabled: boolean;
41
+ tableView: boolean;
42
+ key: string;
43
+ type: string;
44
+ input: boolean;
45
+ title?: undefined;
46
+ breadcrumbClickable?: undefined;
47
+ buttonSettings?: undefined;
48
+ collapsible?: undefined;
49
+ components?: undefined;
50
+ })[];
51
+ }
52
+ export default _default;
@@ -0,0 +1,69 @@
1
+ export default {
2
+ type: 'form',
3
+ display: 'wizard',
4
+ components: [
5
+ {
6
+ title: 'Page 1',
7
+ breadcrumbClickable: true,
8
+ buttonSettings: {
9
+ previous: true,
10
+ cancel: true,
11
+ next: true
12
+ },
13
+ collapsible: false,
14
+ tableView: false,
15
+ key: 'page3',
16
+ type: 'panel',
17
+ label: 'Page 2',
18
+ input: false,
19
+ components: [
20
+ {
21
+ label: 'Edit Grid',
22
+ tableView: true,
23
+ rowDrafts: false,
24
+ key: 'editGrid',
25
+ type: 'editgrid',
26
+ input: true,
27
+ components: [
28
+ {
29
+ label: 'Text Field',
30
+ tableView: true,
31
+ key: 'textField',
32
+ type: 'textfield',
33
+ input: true,
34
+ alwaysEnabled: false
35
+ }
36
+ ],
37
+ alwaysEnabled: false
38
+ }
39
+ ],
40
+ alwaysEnabled: false
41
+ },
42
+ {
43
+ title: 'Page 2',
44
+ breadcrumbClickable: true,
45
+ buttonSettings: {
46
+ previous: true,
47
+ cancel: true,
48
+ next: true
49
+ },
50
+ collapsible: false,
51
+ tableView: false,
52
+ key: 'page2',
53
+ type: 'panel',
54
+ label: 'Page 1',
55
+ input: false,
56
+ alwaysEnabled: false,
57
+ components: []
58
+ },
59
+ {
60
+ label: 'Submit',
61
+ showValidations: false,
62
+ alwaysEnabled: false,
63
+ tableView: false,
64
+ key: 'submit',
65
+ type: 'button',
66
+ input: true
67
+ }
68
+ ]
69
+ };
@@ -13,8 +13,9 @@ import comp6 from './comp6';
13
13
  import comp7 from './comp7';
14
14
  import comp8 from './comp8';
15
15
  import comp9 from './comp9';
16
+ import comp16 from './comp16';
16
17
  import compOpenWhenEmpty from './comp-openWhenEmpty';
17
18
  import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
18
19
  import compWithCustomDefaultValue from './comp-with-custom-default-value';
19
20
  import compTestEvents from './comp-test-events';
20
- export { comp1, comp2, comp3, comp10, comp11, comp12, comp13, comp14, comp15, comp4, comp5, comp6, comp7, comp8, comp9, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
21
+ export { comp1, comp2, comp3, comp10, comp11, comp12, comp13, comp14, comp15, comp4, comp5, comp6, comp7, comp8, comp9, comp16, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
@@ -13,8 +13,9 @@ import comp12 from './comp12';
13
13
  import comp13 from './comp13';
14
14
  import comp14 from './comp14';
15
15
  import comp15 from './comp15';
16
+ import comp16 from './comp16';
16
17
  import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
17
18
  import compOpenWhenEmpty from './comp-openWhenEmpty';
18
19
  import compWithCustomDefaultValue from './comp-with-custom-default-value';
19
20
  import compTestEvents from './comp-test-events';
20
- export { comp1, comp2, comp3, comp10, comp11, comp12, comp13, comp14, comp15, comp4, comp5, comp6, comp7, comp8, comp9, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
21
+ export { comp1, comp2, comp3, comp10, comp11, comp12, comp13, comp14, comp15, comp4, comp5, comp6, comp7, comp8, comp9, comp16, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5707.d029d4d",
3
+ "version": "5.0.0-dev.5710.e2e8388",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {