@formio/js 5.1.0-dev.6007.fade2e3 → 5.1.0-dev.6012.8e3fc09

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.
@@ -1539,11 +1539,11 @@ class Webform extends NestedDataComponent_1.default {
1539
1539
  return;
1540
1540
  }
1541
1541
  const captchaComponent = [];
1542
- this.eachComponent((component) => {
1542
+ (0, formUtils_1.eachComponent)(this.components, (component) => {
1543
1543
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1544
1544
  captchaComponent.push(component);
1545
1545
  }
1546
- });
1546
+ }, true);
1547
1547
  if (captchaComponent.length > 0) {
1548
1548
  if (this.parent) {
1549
1549
  this.parent.subFormReady.then(() => {
@@ -1951,15 +1951,21 @@ class Component extends Element_1.default {
1951
1951
  }
1952
1952
  // Check advanced conditions (and cache the result)
1953
1953
  const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1954
+ let shouldClear = false;
1954
1955
  if (isConditionallyHidden !== this._conditionallyHidden) {
1955
1956
  this._conditionallyHidden = isConditionallyHidden;
1956
- this.clearOnHide();
1957
+ shouldClear = true;
1957
1958
  }
1958
1959
  // Check visibility
1959
1960
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1960
1961
  if (this.visible !== visible) {
1961
1962
  this.visible = visible;
1962
1963
  }
1964
+ // Wait for visibility to update for nested components, so the component state is up-to-date when
1965
+ // calling clearOnHide
1966
+ if (shouldClear) {
1967
+ this.clearOnHide();
1968
+ }
1963
1969
  return visible;
1964
1970
  }
1965
1971
  /**
@@ -115,7 +115,7 @@ function s3(formio) {
115
115
  const { changeMessage } = multipart;
116
116
  changeMessage('Completing AWS S3 multipart upload...');
117
117
  const token = formio.getToken();
118
- const response = yield fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
118
+ const response = yield xhr_1.default.fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
119
119
  method: 'POST',
120
120
  headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),
121
121
  body: JSON.stringify({ parts, uploadId: serverResponse.uploadId, key: serverResponse.key })
@@ -134,7 +134,7 @@ function s3(formio) {
134
134
  abortMultipartUpload(serverResponse) {
135
135
  const { uploadId, key } = serverResponse;
136
136
  const token = formio.getToken();
137
- fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
137
+ xhr_1.default.fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
138
138
  method: 'POST',
139
139
  headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),
140
140
  body: JSON.stringify({ uploadId, key })
@@ -148,7 +148,7 @@ function s3(formio) {
148
148
  const start = i * partSize;
149
149
  const end = (i + 1) * partSize;
150
150
  const blob = i < urls.length ? file.slice(start, end) : file.slice(start);
151
- const promise = fetch(urls[i], {
151
+ const promise = xhr_1.default.fetch(urls[i], {
152
152
  method: 'PUT',
153
153
  headers,
154
154
  body: blob,
@@ -3,6 +3,7 @@ export default XHR;
3
3
  declare namespace XHR {
4
4
  function trim(text: any): any;
5
5
  function path(items: any): any;
6
+ function fetch(url: any, options: any): Promise<Response>;
6
7
  function upload(formio: any, type: any, xhrCallback: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any, multipartOptions: any): Promise<any>;
7
8
  function makeXhrRequest(formio: any, xhrCallback: any, serverResponse: any, progressCallback: any, abortCallback: any): Promise<any>;
8
9
  }
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.setXhrHeaders = void 0;
16
16
  const trim_1 = __importDefault(require("lodash/trim"));
17
+ const Formio_1 = require("../../Formio");
17
18
  const setXhrHeaders = (formio, xhr) => {
18
19
  const { headers } = formio.options;
19
20
  if (headers) {
@@ -36,13 +37,17 @@ const XHR = {
36
37
  path(items) {
37
38
  return items.filter(item => !!item).map(XHR.trim).join('/');
38
39
  },
40
+ fetch(url, options) {
41
+ options = Formio_1.Formio.pluginAlter('requestOptions', options, url);
42
+ return fetch(url, options);
43
+ },
39
44
  upload(formio, type, xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions) {
40
45
  return __awaiter(this, void 0, void 0, function* () {
41
46
  // make request to Form.io server
42
47
  const token = formio.getToken();
43
48
  let response;
44
49
  try {
45
- response = yield fetch(`${formio.formUrl}/storage/${type}`, {
50
+ response = yield XHR.fetch(`${formio.formUrl}/storage/${type}`, {
46
51
  method: 'POST',
47
52
  headers: Object.assign({ 'Accept': 'application/json', 'Content-Type': 'application/json; charset=UTF-8' }, (token ? { 'x-jwt-token': token } : {})),
48
53
  body: JSON.stringify({
@@ -1539,11 +1539,11 @@ export default class Webform extends NestedDataComponent {
1539
1539
  return;
1540
1540
  }
1541
1541
  const captchaComponent = [];
1542
- this.eachComponent((component) => {
1542
+ eachComponent(this.components, (component) => {
1543
1543
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1544
1544
  captchaComponent.push(component);
1545
1545
  }
1546
- });
1546
+ }, true);
1547
1547
  if (captchaComponent.length > 0) {
1548
1548
  if (this.parent) {
1549
1549
  this.parent.subFormReady.then(() => {
@@ -1917,15 +1917,21 @@ export default class Component extends Element {
1917
1917
  }
1918
1918
  // Check advanced conditions (and cache the result)
1919
1919
  const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1920
+ let shouldClear = false;
1920
1921
  if (isConditionallyHidden !== this._conditionallyHidden) {
1921
1922
  this._conditionallyHidden = isConditionallyHidden;
1922
- this.clearOnHide();
1923
+ shouldClear = true;
1923
1924
  }
1924
1925
  // Check visibility
1925
1926
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1926
1927
  if (this.visible !== visible) {
1927
1928
  this.visible = visible;
1928
1929
  }
1930
+ // Wait for visibility to update for nested components, so the component state is up-to-date when
1931
+ // calling clearOnHide
1932
+ if (shouldClear) {
1933
+ this.clearOnHide();
1934
+ }
1929
1935
  return visible;
1930
1936
  }
1931
1937
  /**
@@ -75,7 +75,7 @@ function s3(formio) {
75
75
  const { changeMessage } = multipart;
76
76
  changeMessage('Completing AWS S3 multipart upload...');
77
77
  const token = formio.getToken();
78
- const response = await fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
78
+ const response = await XHR.fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
79
79
  method: 'POST',
80
80
  headers: {
81
81
  'Content-Type': 'application/json',
@@ -96,7 +96,7 @@ function s3(formio) {
96
96
  abortMultipartUpload(serverResponse) {
97
97
  const { uploadId, key } = serverResponse;
98
98
  const token = formio.getToken();
99
- fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
99
+ XHR.fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
100
100
  method: 'POST',
101
101
  headers: {
102
102
  'Content-Type': 'application/json',
@@ -113,7 +113,7 @@ function s3(formio) {
113
113
  const start = i * partSize;
114
114
  const end = (i + 1) * partSize;
115
115
  const blob = i < urls.length ? file.slice(start, end) : file.slice(start);
116
- const promise = fetch(urls[i], {
116
+ const promise = XHR.fetch(urls[i], {
117
117
  method: 'PUT',
118
118
  headers,
119
119
  body: blob,
@@ -3,6 +3,7 @@ export default XHR;
3
3
  declare namespace XHR {
4
4
  function trim(text: any): any;
5
5
  function path(items: any): any;
6
+ function fetch(url: any, options: any): Promise<Response>;
6
7
  function upload(formio: any, type: any, xhrCallback: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any, multipartOptions: any): Promise<any>;
7
8
  function makeXhrRequest(formio: any, xhrCallback: any, serverResponse: any, progressCallback: any, abortCallback: any): Promise<any>;
8
9
  }
@@ -1,4 +1,5 @@
1
1
  import _trim from 'lodash/trim';
2
+ import { Formio } from '../../Formio';
2
3
  export const setXhrHeaders = (formio, xhr) => {
3
4
  const { headers } = formio.options;
4
5
  if (headers) {
@@ -20,12 +21,16 @@ const XHR = {
20
21
  path(items) {
21
22
  return items.filter(item => !!item).map(XHR.trim).join('/');
22
23
  },
24
+ fetch(url, options) {
25
+ options = Formio.pluginAlter('requestOptions', options, url);
26
+ return fetch(url, options);
27
+ },
23
28
  async upload(formio, type, xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions) {
24
29
  // make request to Form.io server
25
30
  const token = formio.getToken();
26
31
  let response;
27
32
  try {
28
- response = await fetch(`${formio.formUrl}/storage/${type}`, {
33
+ response = await XHR.fetch(`${formio.formUrl}/storage/${type}`, {
29
34
  method: 'POST',
30
35
  headers: {
31
36
  'Accept': 'application/json',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6007.fade2e3",
3
+ "version": "5.1.0-dev.6012.8e3fc09",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {