@formio/js 5.0.0-dev.5675.508790e → 5.0.0-dev.5676.625f434

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.
@@ -334,7 +334,7 @@ declare class Webform extends NestedDataComponent {
334
334
  * Sets the submission value
335
335
  * @param {object|null|undefined} submission - The submission to set.
336
336
  * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
337
- * @returns {void}
337
+ * @return {void}
338
338
  */
339
339
  onSetSubmission(submission: object | null | undefined, flags?: object | null | undefined): void;
340
340
  /**
@@ -702,7 +702,7 @@ class Webform extends NestedDataComponent_1.default {
702
702
  * Sets the submission value
703
703
  * @param {object|null|undefined} submission - The submission to set.
704
704
  * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
705
- * @returns {void}
705
+ * @return {void}
706
706
  */
707
707
  onSetSubmission(submission, flags = {}) {
708
708
  this.submissionSet = true;
@@ -882,9 +882,7 @@ class Webform extends NestedDataComponent_1.default {
882
882
  this.addComponents();
883
883
  this.on("submitButton", (options) => {
884
884
  this.submit(false, options).catch((e) => {
885
- if (options === null || options === void 0 ? void 0 : options.instance) {
886
- options.instance.loading = false;
887
- }
885
+ options.instance.loading = false;
888
886
  return e !== false && e !== undefined && console.log(e);
889
887
  });
890
888
  }, true);
@@ -346,7 +346,7 @@ declare class Component extends Element {
346
346
  /**
347
347
  * Renders a modal preview template and returns the markup as a string
348
348
  * @param {object|null|undefined} ctx - The rendering context
349
- * @returns {string} - The modal preview markup
349
+ * @return {string} - The modal preview markup
350
350
  */
351
351
  renderModalPreview(ctx: object | null | undefined): string;
352
352
  /**
@@ -372,7 +372,7 @@ declare class Component extends Element {
372
372
  * Creates the tooltip instance using tippy.js and returns it
373
373
  * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
374
374
  * @param {object|null|undefined} settings - tippy.js options
375
- * @returns {import('tippy.js').Tippy} - tippy.js instance
375
+ * @return {import('tippy.js').Tippy} - tippy.js instance
376
376
  */
377
377
  createTooltip(tooltipEl: HTMLElement, settings?: object | null | undefined): import('tippy.js').Tippy;
378
378
  /**
@@ -1049,7 +1049,7 @@ class Component extends Element_1.default {
1049
1049
  /**
1050
1050
  * Renders a modal preview template and returns the markup as a string
1051
1051
  * @param {object|null|undefined} ctx - The rendering context
1052
- * @returns {string} - The modal preview markup
1052
+ * @return {string} - The modal preview markup
1053
1053
  */
1054
1054
  renderModalPreview(ctx) {
1055
1055
  return this.renderTemplate('modalPreview', ctx || {});
@@ -1118,7 +1118,7 @@ class Component extends Element_1.default {
1118
1118
  * Creates the tooltip instance using tippy.js and returns it
1119
1119
  * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
1120
1120
  * @param {object|null|undefined} settings - tippy.js options
1121
- * @returns {import('tippy.js').Tippy} - tippy.js instance
1121
+ * @return {import('tippy.js').Tippy} - tippy.js instance
1122
1122
  */
1123
1123
  createTooltip(tooltipEl, settings = {}) {
1124
1124
  const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
@@ -3388,6 +3388,10 @@ class Component extends Element_1.default {
3388
3388
  const disabled = this.shouldDisabled;
3389
3389
  // Change states which won't be recalculated during redrawing
3390
3390
  if (this.visible !== visible) {
3391
+ // If the logic is triggered by an event and the action sets the hidden state then the original
3392
+ // component definition must be changed so that the components hidden state does not get flipped back by
3393
+ // the fieldLogic function
3394
+ this.originalComponent.hidden = !visible;
3391
3395
  this.visible = visible;
3392
3396
  }
3393
3397
  if (this.disabled !== disabled) {
@@ -0,0 +1,84 @@
1
+ declare namespace _default {
2
+ let components: ({
3
+ label: string;
4
+ action: string;
5
+ showValidations: boolean;
6
+ tableView: boolean;
7
+ key: string;
8
+ type: string;
9
+ event: string;
10
+ input: boolean;
11
+ theme?: undefined;
12
+ collapsible?: undefined;
13
+ hidden?: undefined;
14
+ logic?: undefined;
15
+ collapsed?: undefined;
16
+ components?: undefined;
17
+ applyMaskOn?: undefined;
18
+ } | {
19
+ label: string;
20
+ action: string;
21
+ showValidations: boolean;
22
+ theme: string;
23
+ tableView: boolean;
24
+ key: string;
25
+ type: string;
26
+ event: string;
27
+ input: boolean;
28
+ collapsible?: undefined;
29
+ hidden?: undefined;
30
+ logic?: undefined;
31
+ collapsed?: undefined;
32
+ components?: undefined;
33
+ applyMaskOn?: undefined;
34
+ } | {
35
+ collapsible: boolean;
36
+ hidden: boolean;
37
+ key: string;
38
+ logic: {
39
+ name: string;
40
+ trigger: {
41
+ type: string;
42
+ event: string;
43
+ };
44
+ actions: {
45
+ name: string;
46
+ type: string;
47
+ property: {
48
+ label: string;
49
+ value: string;
50
+ type: string;
51
+ };
52
+ state: boolean;
53
+ }[];
54
+ }[];
55
+ type: string;
56
+ label: string;
57
+ collapsed: boolean;
58
+ input: boolean;
59
+ tableView: boolean;
60
+ components: never[];
61
+ action?: undefined;
62
+ showValidations?: undefined;
63
+ event?: undefined;
64
+ theme?: undefined;
65
+ applyMaskOn?: undefined;
66
+ } | {
67
+ label: string;
68
+ applyMaskOn: string;
69
+ tableView: boolean;
70
+ key: string;
71
+ type: string;
72
+ input: boolean;
73
+ action?: undefined;
74
+ showValidations?: undefined;
75
+ event?: undefined;
76
+ theme?: undefined;
77
+ collapsible?: undefined;
78
+ hidden?: undefined;
79
+ logic?: undefined;
80
+ collapsed?: undefined;
81
+ components?: undefined;
82
+ })[];
83
+ }
84
+ export default _default;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ components: [
5
+ {
6
+ "label": "Show",
7
+ "action": "event",
8
+ "showValidations": false,
9
+ "tableView": false,
10
+ "key": "show",
11
+ "type": "button",
12
+ "event": "show",
13
+ "input": true
14
+ },
15
+ {
16
+ "label": "Hide",
17
+ "action": "event",
18
+ "showValidations": false,
19
+ "theme": "danger",
20
+ "tableView": false,
21
+ "key": "hide",
22
+ "type": "button",
23
+ "event": "hide",
24
+ "input": true
25
+ },
26
+ {
27
+ "collapsible": true,
28
+ "hidden": true,
29
+ "key": "panel",
30
+ "logic": [
31
+ {
32
+ "name": "ShowPanel",
33
+ "trigger": {
34
+ "type": "event",
35
+ "event": "show"
36
+ },
37
+ "actions": [
38
+ {
39
+ "name": "Show",
40
+ "type": "property",
41
+ "property": {
42
+ "label": "Hidden",
43
+ "value": "hidden",
44
+ "type": "boolean"
45
+ },
46
+ "state": false
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ "name": "HidePanel",
52
+ "trigger": {
53
+ "type": "event",
54
+ "event": "hide"
55
+ },
56
+ "actions": [
57
+ {
58
+ "name": "Hide",
59
+ "type": "property",
60
+ "property": {
61
+ "label": "Hidden",
62
+ "value": "hidden",
63
+ "type": "boolean"
64
+ },
65
+ "state": true
66
+ }
67
+ ]
68
+ }
69
+ ],
70
+ "type": "panel",
71
+ "label": "Panel",
72
+ "collapsed": false,
73
+ "input": false,
74
+ "tableView": false,
75
+ "components": []
76
+ },
77
+ {
78
+ "label": "Text Field",
79
+ "applyMaskOn": "change",
80
+ "tableView": true,
81
+ "key": "textField1",
82
+ "type": "textfield",
83
+ "input": true
84
+ }
85
+ ]
86
+ };
@@ -4,4 +4,5 @@ import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
- export { comp1, comp2, comp3, comp4, comp5, comp6 };
7
+ import comp7 from './comp7';
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
@@ -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.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ 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"));
@@ -16,3 +16,5 @@ const comp5_1 = __importDefault(require("./comp5"));
16
16
  exports.comp5 = comp5_1.default;
17
17
  const comp6_1 = __importDefault(require("./comp6"));
18
18
  exports.comp6 = comp6_1.default;
19
+ const comp7_1 = __importDefault(require("./comp7"));
20
+ exports.comp7 = comp7_1.default;
@@ -234,33 +234,11 @@ class Input extends Multivalue_1.default {
234
234
  this.addFocusBlurEvents(element);
235
235
  if (this.options.submitOnEnter) {
236
236
  this.addEventListener(element, 'keypress', (event) => {
237
- var _a;
238
237
  const key = event.keyCode || event.which;
239
238
  if (key === 13) {
240
239
  event.preventDefault();
241
240
  event.stopPropagation();
242
- let submitButton = null;
243
- if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.everyComponent) {
244
- this.root.everyComponent((component) => {
245
- if ((component === null || component === void 0 ? void 0 : component.component.type) === 'button' &&
246
- (component === null || component === void 0 ? void 0 : component.component.action) === 'submit') {
247
- submitButton = component;
248
- return false;
249
- }
250
- });
251
- }
252
- const options = {};
253
- if (submitButton) {
254
- options.instance = submitButton;
255
- options.component = submitButton.component;
256
- options.noValidate = this.component.state === 'draft';
257
- options.state = this.component.state || 'submitted';
258
- submitButton.loading = true;
259
- this.emit('submitButton', options);
260
- }
261
- else {
262
- this.emit('submitButton', options);
263
- }
241
+ this.emit('submitButton');
264
242
  }
265
243
  });
266
244
  }
@@ -94,7 +94,7 @@ export default class FormComponent extends Component {
94
94
  * Sets the subform value
95
95
  * @param {object|null|undefined} submission - The submission to set.
96
96
  * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
97
- * @returns {void}
97
+ * @return {void}
98
98
  */
99
99
  onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
100
100
  areAllComponentsEmpty(data: any): boolean;
@@ -656,7 +656,7 @@ class FormComponent extends Component_1.default {
656
656
  * Sets the subform value
657
657
  * @param {object|null|undefined} submission - The submission to set.
658
658
  * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
659
- * @returns {void}
659
+ * @return {void}
660
660
  */
661
661
  onSetSubFormValue(submission, flags) {
662
662
  this.subForm.setValue(submission, flags);
@@ -334,7 +334,7 @@ declare class Webform extends NestedDataComponent {
334
334
  * Sets the submission value
335
335
  * @param {object|null|undefined} submission - The submission to set.
336
336
  * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
337
- * @returns {void}
337
+ * @return {void}
338
338
  */
339
339
  onSetSubmission(submission: object | null | undefined, flags?: object | null | undefined): void;
340
340
  /**
@@ -700,7 +700,7 @@ export default class Webform extends NestedDataComponent {
700
700
  * Sets the submission value
701
701
  * @param {object|null|undefined} submission - The submission to set.
702
702
  * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
703
- * @returns {void}
703
+ * @return {void}
704
704
  */
705
705
  onSetSubmission(submission, flags = {}) {
706
706
  this.submissionSet = true;
@@ -886,9 +886,7 @@ export default class Webform extends NestedDataComponent {
886
886
  this.addComponents();
887
887
  this.on("submitButton", (options) => {
888
888
  this.submit(false, options).catch((e) => {
889
- if (options?.instance) {
890
- options.instance.loading = false;
891
- }
889
+ options.instance.loading = false;
892
890
  return e !== false && e !== undefined && console.log(e);
893
891
  });
894
892
  }, true);
@@ -346,7 +346,7 @@ declare class Component extends Element {
346
346
  /**
347
347
  * Renders a modal preview template and returns the markup as a string
348
348
  * @param {object|null|undefined} ctx - The rendering context
349
- * @returns {string} - The modal preview markup
349
+ * @return {string} - The modal preview markup
350
350
  */
351
351
  renderModalPreview(ctx: object | null | undefined): string;
352
352
  /**
@@ -372,7 +372,7 @@ declare class Component extends Element {
372
372
  * Creates the tooltip instance using tippy.js and returns it
373
373
  * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
374
374
  * @param {object|null|undefined} settings - tippy.js options
375
- * @returns {import('tippy.js').Tippy} - tippy.js instance
375
+ * @return {import('tippy.js').Tippy} - tippy.js instance
376
376
  */
377
377
  createTooltip(tooltipEl: HTMLElement, settings?: object | null | undefined): import('tippy.js').Tippy;
378
378
  /**
@@ -1016,7 +1016,7 @@ export default class Component extends Element {
1016
1016
  /**
1017
1017
  * Renders a modal preview template and returns the markup as a string
1018
1018
  * @param {object|null|undefined} ctx - The rendering context
1019
- * @returns {string} - The modal preview markup
1019
+ * @return {string} - The modal preview markup
1020
1020
  */
1021
1021
  renderModalPreview(ctx) {
1022
1022
  return this.renderTemplate('modalPreview', ctx || {});
@@ -1084,7 +1084,7 @@ export default class Component extends Element {
1084
1084
  * Creates the tooltip instance using tippy.js and returns it
1085
1085
  * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
1086
1086
  * @param {object|null|undefined} settings - tippy.js options
1087
- * @returns {import('tippy.js').Tippy} - tippy.js instance
1087
+ * @return {import('tippy.js').Tippy} - tippy.js instance
1088
1088
  */
1089
1089
  createTooltip(tooltipEl, settings = {}) {
1090
1090
  const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
@@ -3361,6 +3361,10 @@ export default class Component extends Element {
3361
3361
  const disabled = this.shouldDisabled;
3362
3362
  // Change states which won't be recalculated during redrawing
3363
3363
  if (this.visible !== visible) {
3364
+ // If the logic is triggered by an event and the action sets the hidden state then the original
3365
+ // component definition must be changed so that the components hidden state does not get flipped back by
3366
+ // the fieldLogic function
3367
+ this.originalComponent.hidden = !visible;
3364
3368
  this.visible = visible;
3365
3369
  }
3366
3370
  if (this.disabled !== disabled) {
@@ -0,0 +1,84 @@
1
+ declare namespace _default {
2
+ let components: ({
3
+ label: string;
4
+ action: string;
5
+ showValidations: boolean;
6
+ tableView: boolean;
7
+ key: string;
8
+ type: string;
9
+ event: string;
10
+ input: boolean;
11
+ theme?: undefined;
12
+ collapsible?: undefined;
13
+ hidden?: undefined;
14
+ logic?: undefined;
15
+ collapsed?: undefined;
16
+ components?: undefined;
17
+ applyMaskOn?: undefined;
18
+ } | {
19
+ label: string;
20
+ action: string;
21
+ showValidations: boolean;
22
+ theme: string;
23
+ tableView: boolean;
24
+ key: string;
25
+ type: string;
26
+ event: string;
27
+ input: boolean;
28
+ collapsible?: undefined;
29
+ hidden?: undefined;
30
+ logic?: undefined;
31
+ collapsed?: undefined;
32
+ components?: undefined;
33
+ applyMaskOn?: undefined;
34
+ } | {
35
+ collapsible: boolean;
36
+ hidden: boolean;
37
+ key: string;
38
+ logic: {
39
+ name: string;
40
+ trigger: {
41
+ type: string;
42
+ event: string;
43
+ };
44
+ actions: {
45
+ name: string;
46
+ type: string;
47
+ property: {
48
+ label: string;
49
+ value: string;
50
+ type: string;
51
+ };
52
+ state: boolean;
53
+ }[];
54
+ }[];
55
+ type: string;
56
+ label: string;
57
+ collapsed: boolean;
58
+ input: boolean;
59
+ tableView: boolean;
60
+ components: never[];
61
+ action?: undefined;
62
+ showValidations?: undefined;
63
+ event?: undefined;
64
+ theme?: undefined;
65
+ applyMaskOn?: undefined;
66
+ } | {
67
+ label: string;
68
+ applyMaskOn: string;
69
+ tableView: boolean;
70
+ key: string;
71
+ type: string;
72
+ input: boolean;
73
+ action?: undefined;
74
+ showValidations?: undefined;
75
+ event?: undefined;
76
+ theme?: undefined;
77
+ collapsible?: undefined;
78
+ hidden?: undefined;
79
+ logic?: undefined;
80
+ collapsed?: undefined;
81
+ components?: undefined;
82
+ })[];
83
+ }
84
+ export default _default;
@@ -0,0 +1,84 @@
1
+ export default {
2
+ components: [
3
+ {
4
+ "label": "Show",
5
+ "action": "event",
6
+ "showValidations": false,
7
+ "tableView": false,
8
+ "key": "show",
9
+ "type": "button",
10
+ "event": "show",
11
+ "input": true
12
+ },
13
+ {
14
+ "label": "Hide",
15
+ "action": "event",
16
+ "showValidations": false,
17
+ "theme": "danger",
18
+ "tableView": false,
19
+ "key": "hide",
20
+ "type": "button",
21
+ "event": "hide",
22
+ "input": true
23
+ },
24
+ {
25
+ "collapsible": true,
26
+ "hidden": true,
27
+ "key": "panel",
28
+ "logic": [
29
+ {
30
+ "name": "ShowPanel",
31
+ "trigger": {
32
+ "type": "event",
33
+ "event": "show"
34
+ },
35
+ "actions": [
36
+ {
37
+ "name": "Show",
38
+ "type": "property",
39
+ "property": {
40
+ "label": "Hidden",
41
+ "value": "hidden",
42
+ "type": "boolean"
43
+ },
44
+ "state": false
45
+ }
46
+ ]
47
+ },
48
+ {
49
+ "name": "HidePanel",
50
+ "trigger": {
51
+ "type": "event",
52
+ "event": "hide"
53
+ },
54
+ "actions": [
55
+ {
56
+ "name": "Hide",
57
+ "type": "property",
58
+ "property": {
59
+ "label": "Hidden",
60
+ "value": "hidden",
61
+ "type": "boolean"
62
+ },
63
+ "state": true
64
+ }
65
+ ]
66
+ }
67
+ ],
68
+ "type": "panel",
69
+ "label": "Panel",
70
+ "collapsed": false,
71
+ "input": false,
72
+ "tableView": false,
73
+ "components": []
74
+ },
75
+ {
76
+ "label": "Text Field",
77
+ "applyMaskOn": "change",
78
+ "tableView": true,
79
+ "key": "textField1",
80
+ "type": "textfield",
81
+ "input": true
82
+ }
83
+ ]
84
+ };
@@ -4,4 +4,5 @@ import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
- export { comp1, comp2, comp3, comp4, comp5, comp6 };
7
+ import comp7 from './comp7';
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
@@ -4,4 +4,5 @@ import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
- export { comp1, comp2, comp3, comp4, comp5, comp6 };
7
+ import comp7 from './comp7';
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
@@ -233,28 +233,7 @@ export default class Input extends Multivalue {
233
233
  if (key === 13) {
234
234
  event.preventDefault();
235
235
  event.stopPropagation();
236
- let submitButton = null;
237
- if (this.root?.everyComponent) {
238
- this.root.everyComponent((component) => {
239
- if (component?.component.type === 'button' &&
240
- component?.component.action === 'submit') {
241
- submitButton = component;
242
- return false;
243
- }
244
- });
245
- }
246
- const options = {};
247
- if (submitButton) {
248
- options.instance = submitButton;
249
- options.component = submitButton.component;
250
- options.noValidate = this.component.state === 'draft';
251
- options.state = this.component.state || 'submitted';
252
- submitButton.loading = true;
253
- this.emit('submitButton', options);
254
- }
255
- else {
256
- this.emit('submitButton', options);
257
- }
236
+ this.emit('submitButton');
258
237
  }
259
238
  });
260
239
  }
@@ -94,7 +94,7 @@ export default class FormComponent extends Component {
94
94
  * Sets the subform value
95
95
  * @param {object|null|undefined} submission - The submission to set.
96
96
  * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
97
- * @returns {void}
97
+ * @return {void}
98
98
  */
99
99
  onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
100
100
  areAllComponentsEmpty(data: any): boolean;
@@ -646,7 +646,7 @@ export default class FormComponent extends Component {
646
646
  * Sets the subform value
647
647
  * @param {object|null|undefined} submission - The submission to set.
648
648
  * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
649
- * @returns {void}
649
+ * @return {void}
650
650
  */
651
651
  onSetSubFormValue(submission, flags) {
652
652
  this.subForm.setValue(submission, flags);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5675.508790e",
3
+ "version": "5.0.0-dev.5676.625f434",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {