@formio/js 5.1.0-rc.15 → 5.1.0-rc.17

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 (50) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +7 -7
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.full.js +7 -7
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  10. package/dist/formio.js +2 -2
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +1 -1
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  16. package/lib/cjs/Embed.js +1 -1
  17. package/lib/cjs/Formio.js +1 -1
  18. package/lib/cjs/Webform.js +2 -2
  19. package/lib/cjs/components/_classes/component/Component.js +7 -1
  20. package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
  21. package/lib/cjs/components/datetime/DateTime.js +7 -3
  22. package/lib/cjs/components/datetime/fixtures/index.d.ts +6 -5
  23. package/lib/cjs/components/datetime/fixtures/index.js +5 -1
  24. package/lib/cjs/components/datetime/fixtures/requiredFieldLogicComp.d.ts +57 -0
  25. package/lib/cjs/components/datetime/fixtures/requiredFieldLogicComp.js +64 -0
  26. package/lib/cjs/components/textfield/TextField.js +3 -0
  27. package/lib/cjs/components/textfield/fixtures/index.d.ts +2 -1
  28. package/lib/cjs/components/textfield/fixtures/index.js +3 -1
  29. package/lib/cjs/components/textfield/fixtures/requiredFieldLogicComp.d.ts +48 -0
  30. package/lib/cjs/components/textfield/fixtures/requiredFieldLogicComp.js +55 -0
  31. package/lib/cjs/utils/utils.d.ts +2 -1
  32. package/lib/cjs/utils/utils.js +3 -2
  33. package/lib/mjs/Embed.js +1 -1
  34. package/lib/mjs/Formio.js +1 -1
  35. package/lib/mjs/Webform.js +2 -2
  36. package/lib/mjs/components/_classes/component/Component.js +7 -1
  37. package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
  38. package/lib/mjs/components/datetime/DateTime.js +8 -4
  39. package/lib/mjs/components/datetime/fixtures/index.d.ts +6 -5
  40. package/lib/mjs/components/datetime/fixtures/index.js +3 -1
  41. package/lib/mjs/components/datetime/fixtures/requiredFieldLogicComp.d.ts +57 -0
  42. package/lib/mjs/components/datetime/fixtures/requiredFieldLogicComp.js +62 -0
  43. package/lib/mjs/components/textfield/TextField.js +3 -0
  44. package/lib/mjs/components/textfield/fixtures/index.d.ts +2 -1
  45. package/lib/mjs/components/textfield/fixtures/index.js +2 -1
  46. package/lib/mjs/components/textfield/fixtures/requiredFieldLogicComp.d.ts +48 -0
  47. package/lib/mjs/components/textfield/fixtures/requiredFieldLogicComp.js +53 -0
  48. package/lib/mjs/utils/utils.d.ts +2 -1
  49. package/lib/mjs/utils/utils.js +3 -2
  50. package/package.json +1 -1
@@ -20,7 +20,7 @@
20
20
 
21
21
  /*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */
22
22
 
23
- /*! formiojs v5.1.0-rc.15 | https://unpkg.com/formiojs@5.1.0-rc.15/LICENSE.txt */
23
+ /*! formiojs v5.1.0-rc.17 | https://unpkg.com/formiojs@5.1.0-rc.17/LICENSE.txt */
24
24
 
25
25
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
26
26
 
package/lib/cjs/Embed.js CHANGED
@@ -418,7 +418,7 @@ Formio.formioReady = new Promise((ready, reject) => {
418
418
  _a._formioReady = ready;
419
419
  _a._formioReadyReject = reject;
420
420
  });
421
- Formio.version = '5.1.0-rc.15';
421
+ Formio.version = '5.1.0-rc.17';
422
422
  // Create a report.
423
423
  Formio.Report = {
424
424
  create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
package/lib/cjs/Formio.js CHANGED
@@ -11,7 +11,7 @@ const CDN_1 = __importDefault(require("./CDN"));
11
11
  const providers_1 = __importDefault(require("./providers"));
12
12
  sdk_1.Formio.cdn = new CDN_1.default();
13
13
  sdk_1.Formio.Providers = providers_1.default;
14
- sdk_1.Formio.version = '5.1.0-rc.15';
14
+ sdk_1.Formio.version = '5.1.0-rc.17';
15
15
  CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
16
16
  const isNil = (val) => val === null || val === undefined;
17
17
  sdk_1.Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
@@ -1532,11 +1532,11 @@ class Webform extends NestedDataComponent_1.default {
1532
1532
  return;
1533
1533
  }
1534
1534
  const captchaComponent = [];
1535
- this.eachComponent((component) => {
1535
+ (0, formUtils_1.eachComponent)(this.components, (component) => {
1536
1536
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1537
1537
  captchaComponent.push(component);
1538
1538
  }
1539
- });
1539
+ }, true);
1540
1540
  if (captchaComponent.length > 0) {
1541
1541
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1542
1542
  }
@@ -1938,15 +1938,21 @@ class Component extends Element_1.default {
1938
1938
  }
1939
1939
  // Check advanced conditions (and cache the result)
1940
1940
  const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1941
+ let shouldClear = false;
1941
1942
  if (isConditionallyHidden !== this._conditionallyHidden) {
1942
1943
  this._conditionallyHidden = isConditionallyHidden;
1943
- this.clearOnHide();
1944
+ shouldClear = true;
1944
1945
  }
1945
1946
  // Check visibility
1946
1947
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1947
1948
  if (this.visible !== visible) {
1948
1949
  this.visible = visible;
1949
1950
  }
1951
+ // Wait for visibility to update for nested components, so the component state is up-to-date when
1952
+ // calling clearOnHide
1953
+ if (shouldClear) {
1954
+ this.clearOnHide();
1955
+ }
1950
1956
  return visible;
1951
1957
  }
1952
1958
  /**
@@ -20,6 +20,6 @@ export default class DateTimeComponent extends Input {
20
20
  get momentFormat(): string;
21
21
  createWrapper(): boolean;
22
22
  checkValidity(data: any, dirty: any, rowData: any): boolean;
23
- getValueAsString(value: any): any;
23
+ getValueAsString(value: any, options: any): any;
24
24
  }
25
25
  import Input from '../_classes/input/Input';
@@ -103,6 +103,10 @@ class DateTimeComponent extends Input_1.default {
103
103
  }
104
104
  /* eslint-disable camelcase */
105
105
  this.component.widget = Object.assign({ type: 'calendar', timezone, displayInTimezone: lodash_1.default.get(this.component, 'displayInTimezone', 'viewer'), locale: this.options.language, useLocaleSettings: lodash_1.default.get(this.component, 'useLocaleSettings', false), allowInput: lodash_1.default.get(this.component, 'allowInput', true), mode: 'single', enableTime: lodash_1.default.get(this.component, 'enableTime', true), noCalendar: !lodash_1.default.get(this.component, 'enableDate', true), format: this.component.format, hourIncrement: lodash_1.default.get(this.component, 'timePicker.hourStep', 1), minuteIncrement: lodash_1.default.get(this.component, 'timePicker.minuteStep', 5), time_24hr: time24hr, readOnly: this.options.readOnly, minDate: lodash_1.default.get(this.component, 'datePicker.minDate'), disabledDates: lodash_1.default.get(this.component, 'datePicker.disable'), disableWeekends: lodash_1.default.get(this.component, 'datePicker.disableWeekends'), disableWeekdays: lodash_1.default.get(this.component, 'datePicker.disableWeekdays'), disableFunction: lodash_1.default.get(this.component, 'datePicker.disableFunction'), maxDate: lodash_1.default.get(this.component, 'datePicker.maxDate') }, customOptions);
106
+ // update originalComponent to include widget and other updated settings
107
+ // it is done here since these settings depend on properties present after the component is initialized
108
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
109
+ this.originalComponent = (0, utils_2.fastCloneDeep)(this.component);
106
110
  /* eslint-enable camelcase */
107
111
  }
108
112
  get defaultSchema() {
@@ -149,15 +153,15 @@ class DateTimeComponent extends Input_1.default {
149
153
  }
150
154
  return super.checkValidity(data, dirty, rowData);
151
155
  }
152
- getValueAsString(value) {
156
+ getValueAsString(value, options) {
153
157
  let format = utils_1.default.convertFormatToMoment(this.component.format);
154
158
  format += format.match(/z$/) ? '' : ' z';
155
159
  const timezone = this.timezone;
156
160
  if (value && !this.attached && timezone) {
157
161
  if (Array.isArray(value) && this.component.multiple) {
158
- return value.map(item => lodash_1.default.trim(utils_1.default.momentDate(item, format, timezone).format(format))).join(', ');
162
+ return value.map(item => lodash_1.default.trim(utils_1.default.momentDate(item, format, timezone, options).format(format))).join(', ');
159
163
  }
160
- return lodash_1.default.trim(utils_1.default.momentDate(value, format, timezone).format(format));
164
+ return lodash_1.default.trim(utils_1.default.momentDate(value, format, timezone, options).format(format));
161
165
  }
162
166
  if (Array.isArray(value) && this.component.multiple) {
163
167
  return value.map(item => lodash_1.default.trim((0, moment_1.default)(item).format(format))).join(', ');
@@ -1,8 +1,4 @@
1
1
  import comp1 from './comp1';
2
- import comp10 from './comp10';
3
- import comp11 from './comp11';
4
- import comp12 from './comp12';
5
- import comp13 from './comp13';
6
2
  import comp2 from './comp2';
7
3
  import comp3 from './comp3';
8
4
  import comp5 from './comp5';
@@ -10,4 +6,9 @@ import comp6 from './comp6';
10
6
  import comp7 from './comp7';
11
7
  import comp8 from './comp8';
12
8
  import comp9 from './comp9';
13
- export { comp1, comp10, comp11, comp12, comp13, comp2, comp3, comp5, comp6, comp7, comp8, comp9 };
9
+ import comp10 from './comp10';
10
+ import comp11 from './comp11';
11
+ import comp12 from './comp12';
12
+ import comp13 from './comp13';
13
+ import requiredFieldLogicComp from './requiredFieldLogicComp';
14
+ export { comp1, comp2, comp3, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, requiredFieldLogicComp };
@@ -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.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp3 = exports.comp2 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp1 = void 0;
6
+ exports.requiredFieldLogicComp = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = 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"));
@@ -28,3 +28,7 @@ const comp12_1 = __importDefault(require("./comp12"));
28
28
  exports.comp12 = comp12_1.default;
29
29
  const comp13_1 = __importDefault(require("./comp13"));
30
30
  exports.comp13 = comp13_1.default;
31
+ const comp14_1 = __importDefault(require("./comp14"));
32
+ exports.comp14 = comp14_1.default;
33
+ const requiredFieldLogicComp_1 = __importDefault(require("./requiredFieldLogicComp"));
34
+ exports.requiredFieldLogicComp = requiredFieldLogicComp_1.default;
@@ -0,0 +1,57 @@
1
+ declare namespace _default {
2
+ let components: {
3
+ label: string;
4
+ displayInTimezone: string;
5
+ format: string;
6
+ tableView: boolean;
7
+ datePicker: {
8
+ disableWeekends: boolean;
9
+ disableWeekdays: boolean;
10
+ };
11
+ timePicker: {
12
+ showMeridian: boolean;
13
+ };
14
+ enableMinDateInput: boolean;
15
+ enableMaxDateInput: boolean;
16
+ validateWhenHidden: boolean;
17
+ key: string;
18
+ logic: {
19
+ name: string;
20
+ trigger: {
21
+ type: string;
22
+ javascript: string;
23
+ };
24
+ actions: {
25
+ name: string;
26
+ type: string;
27
+ property: {
28
+ label: string;
29
+ value: string;
30
+ type: string;
31
+ };
32
+ state: boolean;
33
+ }[];
34
+ }[];
35
+ type: string;
36
+ input: boolean;
37
+ widget: {
38
+ type: string;
39
+ displayInTimezone: string;
40
+ locale: string;
41
+ useLocaleSettings: boolean;
42
+ allowInput: boolean;
43
+ mode: string;
44
+ enableTime: boolean;
45
+ noCalendar: boolean;
46
+ format: string;
47
+ hourIncrement: number;
48
+ minuteIncrement: number;
49
+ time_24hr: boolean;
50
+ minDate: null;
51
+ disableWeekends: boolean;
52
+ disableWeekdays: boolean;
53
+ maxDate: null;
54
+ };
55
+ }[];
56
+ }
57
+ export default _default;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ components: [
5
+ {
6
+ "label": "dateTime",
7
+ "displayInTimezone": "submission",
8
+ "format": "MM/dd/yyyy:HH:mm:ss",
9
+ "tableView": false,
10
+ "datePicker": {
11
+ "disableWeekends": false,
12
+ "disableWeekdays": false
13
+ },
14
+ "timePicker": {
15
+ "showMeridian": false
16
+ },
17
+ "enableMinDateInput": false,
18
+ "enableMaxDateInput": false,
19
+ "validateWhenHidden": false,
20
+ "key": "dateTime",
21
+ "logic": [
22
+ {
23
+ "name": "requiredLogic",
24
+ "trigger": {
25
+ "type": "javascript",
26
+ "javascript": "result = true;"
27
+ },
28
+ "actions": [
29
+ {
30
+ "name": "setRequired",
31
+ "type": "property",
32
+ "property": {
33
+ "label": "Required",
34
+ "value": "validate.required",
35
+ "type": "boolean"
36
+ },
37
+ "state": true
38
+ }
39
+ ]
40
+ }
41
+ ],
42
+ "type": "datetime",
43
+ "input": true,
44
+ "widget": {
45
+ "type": "calendar",
46
+ "displayInTimezone": "submission",
47
+ "locale": "en",
48
+ "useLocaleSettings": false,
49
+ "allowInput": true,
50
+ "mode": "single",
51
+ "enableTime": true,
52
+ "noCalendar": false,
53
+ "format": "MM/dd/yyyy:HH:mm:ss",
54
+ "hourIncrement": 1,
55
+ "minuteIncrement": 1,
56
+ "time_24hr": true,
57
+ "minDate": null,
58
+ "disableWeekends": false,
59
+ "disableWeekdays": false,
60
+ "maxDate": null
61
+ }
62
+ }
63
+ ]
64
+ };
@@ -102,6 +102,9 @@ class TextFieldComponent extends Input_1.default {
102
102
  if (((_c = this.component.widget) === null || _c === void 0 ? void 0 : _c.type) === 'calendar') {
103
103
  this.component.widget = Object.assign(Object.assign({}, this.component.widget), { readOnly: this.options.readOnly, timezone,
104
104
  displayInTimezone, locale: this.component.widget.locale || this.options.language, saveAs: 'text' });
105
+ // update originalComponent to include widget settings after component initialization
106
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
107
+ this.originalComponent = FormioUtils.fastCloneDeep(this.component);
105
108
  }
106
109
  }
107
110
  attach(element) {
@@ -6,4 +6,5 @@ import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
7
  import comp7 from './comp7';
8
8
  import withDisplayAndInputMasks from './comp-with-display-and-value-masks';
9
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, withDisplayAndInputMasks };
9
+ import requiredFieldLogicComp from './requiredFieldLogicComp';
10
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, withDisplayAndInputMasks, requiredFieldLogicComp };
@@ -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.withDisplayAndInputMasks = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.requiredFieldLogicComp = exports.withDisplayAndInputMasks = 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"));
@@ -20,3 +20,5 @@ const comp_with_display_and_value_masks_1 = __importDefault(require("./comp-with
20
20
  exports.withDisplayAndInputMasks = comp_with_display_and_value_masks_1.default;
21
21
  const comp7_1 = __importDefault(require("./comp7"));
22
22
  exports.comp7 = comp7_1.default;
23
+ const requiredFieldLogicComp_1 = __importDefault(require("./requiredFieldLogicComp"));
24
+ exports.requiredFieldLogicComp = requiredFieldLogicComp_1.default;
@@ -0,0 +1,48 @@
1
+ declare namespace _default {
2
+ let components: {
3
+ label: string;
4
+ widget: {
5
+ type: string;
6
+ altInput: boolean;
7
+ allowInput: boolean;
8
+ clickOpens: boolean;
9
+ enableDate: boolean;
10
+ enableTime: boolean;
11
+ mode: string;
12
+ noCalendar: boolean;
13
+ format: string;
14
+ dateFormat: string;
15
+ useLocaleSettings: boolean;
16
+ hourIncrement: number;
17
+ minuteIncrement: number;
18
+ time_24hr: boolean;
19
+ saveAs: string;
20
+ displayInTimezone: string;
21
+ locale: string;
22
+ };
23
+ applyMaskOn: string;
24
+ tableView: boolean;
25
+ validateWhenHidden: boolean;
26
+ key: string;
27
+ logic: {
28
+ name: string;
29
+ trigger: {
30
+ type: string;
31
+ javascript: string;
32
+ };
33
+ actions: {
34
+ name: string;
35
+ type: string;
36
+ property: {
37
+ label: string;
38
+ value: string;
39
+ type: string;
40
+ };
41
+ state: boolean;
42
+ }[];
43
+ }[];
44
+ type: string;
45
+ input: boolean;
46
+ }[];
47
+ }
48
+ export default _default;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ components: [
5
+ {
6
+ "label": "Text Field",
7
+ "widget": {
8
+ "type": "calendar",
9
+ "altInput": true,
10
+ "allowInput": true,
11
+ "clickOpens": true,
12
+ "enableDate": true,
13
+ "enableTime": true,
14
+ "mode": "single",
15
+ "noCalendar": false,
16
+ "format": "MM/dd/yyyy:HH:mm:ss",
17
+ "dateFormat": "MM/dd/yyyy:HH:mm:ss",
18
+ "useLocaleSettings": false,
19
+ "hourIncrement": 1,
20
+ "minuteIncrement": 5,
21
+ "time_24hr": false,
22
+ "saveAs": "text",
23
+ "displayInTimezone": "viewer",
24
+ "locale": "en"
25
+ },
26
+ "applyMaskOn": "change",
27
+ "tableView": true,
28
+ "validateWhenHidden": false,
29
+ "key": "textField",
30
+ "logic": [
31
+ {
32
+ "name": "requiredLogic",
33
+ "trigger": {
34
+ "type": "javascript",
35
+ "javascript": "result = true;"
36
+ },
37
+ "actions": [
38
+ {
39
+ "name": "setRequired",
40
+ "type": "property",
41
+ "property": {
42
+ "label": "Required",
43
+ "value": "validate.required",
44
+ "type": "boolean"
45
+ },
46
+ "state": true
47
+ }
48
+ ]
49
+ }
50
+ ],
51
+ "type": "textfield",
52
+ "input": true
53
+ }
54
+ ]
55
+ };
@@ -208,9 +208,10 @@ export function loadZones(url: string, timezone: string): Promise<any> | any;
208
208
  * @param {string|Date} value - The value to convert into a moment date.
209
209
  * @param {string} format - The format to convert the date to.
210
210
  * @param {string} timezone - The timezone to convert the date to.
211
+ * @param {object} options - The options object
211
212
  * @returns {Date} - The moment date object.
212
213
  */
213
- export function momentDate(value: string | Date, format: string, timezone: string): Date;
214
+ export function momentDate(value: string | Date, format: string, timezone: string, options: object): Date;
214
215
  /**
215
216
  * Format a date provided a value, format, and timezone object.
216
217
  * @param {string} timezonesUrl - The URL to load the timezone data from.
@@ -687,9 +687,10 @@ exports.loadZones = loadZones;
687
687
  * @param {string|Date} value - The value to convert into a moment date.
688
688
  * @param {string} format - The format to convert the date to.
689
689
  * @param {string} timezone - The timezone to convert the date to.
690
+ * @param {object} options - The options object
690
691
  * @returns {Date} - The moment date object.
691
692
  */
692
- function momentDate(value, format, timezone) {
693
+ function momentDate(value, format, timezone, options) {
693
694
  const momentDate = (0, moment_timezone_1.default)(value);
694
695
  if (!timezone) {
695
696
  return momentDate;
@@ -697,7 +698,7 @@ function momentDate(value, format, timezone) {
697
698
  if (timezone === 'UTC') {
698
699
  timezone = 'Etc/UTC';
699
700
  }
700
- if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && moment_timezone_1.default.zonesLoaded) {
701
+ if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (moment_timezone_1.default.zonesLoaded || (options === null || options === void 0 ? void 0 : options.email))) {
701
702
  return momentDate.tz(timezone);
702
703
  }
703
704
  return momentDate;
package/lib/mjs/Embed.js CHANGED
@@ -14,7 +14,7 @@ export class Formio {
14
14
  Formio._formioReady = ready;
15
15
  Formio._formioReadyReject = reject;
16
16
  });
17
- static version = '5.1.0-rc.15';
17
+ static version = '5.1.0-rc.17';
18
18
  static setLicense(license, norecurse = false) {
19
19
  Formio.license = license;
20
20
  if (!norecurse && Formio.FormioClass) {
package/lib/mjs/Formio.js CHANGED
@@ -4,7 +4,7 @@ import CDN from './CDN';
4
4
  import Providers from './providers';
5
5
  FormioCore.cdn = new CDN();
6
6
  FormioCore.Providers = Providers;
7
- FormioCore.version = '5.1.0-rc.15';
7
+ FormioCore.version = '5.1.0-rc.17';
8
8
  CDN.defaultCDN = FormioCore.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
9
9
  const isNil = (val) => val === null || val === undefined;
10
10
  FormioCore.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
@@ -1533,11 +1533,11 @@ export default class Webform extends NestedDataComponent {
1533
1533
  return;
1534
1534
  }
1535
1535
  const captchaComponent = [];
1536
- this.eachComponent((component) => {
1536
+ eachComponent(this.components, (component) => {
1537
1537
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1538
1538
  captchaComponent.push(component);
1539
1539
  }
1540
- });
1540
+ }, true);
1541
1541
  if (captchaComponent.length > 0) {
1542
1542
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1543
1543
  }
@@ -1913,15 +1913,21 @@ export default class Component extends Element {
1913
1913
  }
1914
1914
  // Check advanced conditions (and cache the result)
1915
1915
  const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1916
+ let shouldClear = false;
1916
1917
  if (isConditionallyHidden !== this._conditionallyHidden) {
1917
1918
  this._conditionallyHidden = isConditionallyHidden;
1918
- this.clearOnHide();
1919
+ shouldClear = true;
1919
1920
  }
1920
1921
  // Check visibility
1921
1922
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1922
1923
  if (this.visible !== visible) {
1923
1924
  this.visible = visible;
1924
1925
  }
1926
+ // Wait for visibility to update for nested components, so the component state is up-to-date when
1927
+ // calling clearOnHide
1928
+ if (shouldClear) {
1929
+ this.clearOnHide();
1930
+ }
1925
1931
  return visible;
1926
1932
  }
1927
1933
  /**
@@ -20,6 +20,6 @@ export default class DateTimeComponent extends Input {
20
20
  get momentFormat(): string;
21
21
  createWrapper(): boolean;
22
22
  checkValidity(data: any, dirty: any, rowData: any): boolean;
23
- getValueAsString(value: any): any;
23
+ getValueAsString(value: any, options: any): any;
24
24
  }
25
25
  import Input from '../_classes/input/Input';
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import moment from 'moment';
3
3
  import FormioUtils from '../../utils';
4
- import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
4
+ import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils/utils';
5
5
  import Input from '../_classes/input/Input';
6
6
  export default class DateTimeComponent extends Input {
7
7
  static schema(...extend) {
@@ -127,6 +127,10 @@ export default class DateTimeComponent extends Input {
127
127
  maxDate: _.get(this.component, 'datePicker.maxDate'),
128
128
  ...customOptions,
129
129
  };
130
+ // update originalComponent to include widget and other updated settings
131
+ // it is done here since these settings depend on properties present after the component is initialized
132
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
133
+ this.originalComponent = fastCloneDeep(this.component);
130
134
  /* eslint-enable camelcase */
131
135
  }
132
136
  get defaultSchema() {
@@ -173,15 +177,15 @@ export default class DateTimeComponent extends Input {
173
177
  }
174
178
  return super.checkValidity(data, dirty, rowData);
175
179
  }
176
- getValueAsString(value) {
180
+ getValueAsString(value, options) {
177
181
  let format = FormioUtils.convertFormatToMoment(this.component.format);
178
182
  format += format.match(/z$/) ? '' : ' z';
179
183
  const timezone = this.timezone;
180
184
  if (value && !this.attached && timezone) {
181
185
  if (Array.isArray(value) && this.component.multiple) {
182
- return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone).format(format))).join(', ');
186
+ return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format))).join(', ');
183
187
  }
184
- return _.trim(FormioUtils.momentDate(value, format, timezone).format(format));
188
+ return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
185
189
  }
186
190
  if (Array.isArray(value) && this.component.multiple) {
187
191
  return value.map(item => _.trim(moment(item).format(format))).join(', ');
@@ -1,8 +1,4 @@
1
1
  import comp1 from './comp1';
2
- import comp10 from './comp10';
3
- import comp11 from './comp11';
4
- import comp12 from './comp12';
5
- import comp13 from './comp13';
6
2
  import comp2 from './comp2';
7
3
  import comp3 from './comp3';
8
4
  import comp5 from './comp5';
@@ -10,4 +6,9 @@ import comp6 from './comp6';
10
6
  import comp7 from './comp7';
11
7
  import comp8 from './comp8';
12
8
  import comp9 from './comp9';
13
- export { comp1, comp10, comp11, comp12, comp13, comp2, comp3, comp5, comp6, comp7, comp8, comp9 };
9
+ import comp10 from './comp10';
10
+ import comp11 from './comp11';
11
+ import comp12 from './comp12';
12
+ import comp13 from './comp13';
13
+ import requiredFieldLogicComp from './requiredFieldLogicComp';
14
+ export { comp1, comp2, comp3, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, requiredFieldLogicComp };
@@ -10,4 +10,6 @@ import comp10 from './comp10';
10
10
  import comp11 from './comp11';
11
11
  import comp12 from './comp12';
12
12
  import comp13 from './comp13';
13
- export { comp1, comp10, comp11, comp12, comp13, comp2, comp3, comp5, comp6, comp7, comp8, comp9 };
13
+ import comp14 from './comp14';
14
+ import requiredFieldLogicComp from './requiredFieldLogicComp';
15
+ export { comp1, comp2, comp3, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, requiredFieldLogicComp };
@@ -0,0 +1,57 @@
1
+ declare namespace _default {
2
+ let components: {
3
+ label: string;
4
+ displayInTimezone: string;
5
+ format: string;
6
+ tableView: boolean;
7
+ datePicker: {
8
+ disableWeekends: boolean;
9
+ disableWeekdays: boolean;
10
+ };
11
+ timePicker: {
12
+ showMeridian: boolean;
13
+ };
14
+ enableMinDateInput: boolean;
15
+ enableMaxDateInput: boolean;
16
+ validateWhenHidden: boolean;
17
+ key: string;
18
+ logic: {
19
+ name: string;
20
+ trigger: {
21
+ type: string;
22
+ javascript: string;
23
+ };
24
+ actions: {
25
+ name: string;
26
+ type: string;
27
+ property: {
28
+ label: string;
29
+ value: string;
30
+ type: string;
31
+ };
32
+ state: boolean;
33
+ }[];
34
+ }[];
35
+ type: string;
36
+ input: boolean;
37
+ widget: {
38
+ type: string;
39
+ displayInTimezone: string;
40
+ locale: string;
41
+ useLocaleSettings: boolean;
42
+ allowInput: boolean;
43
+ mode: string;
44
+ enableTime: boolean;
45
+ noCalendar: boolean;
46
+ format: string;
47
+ hourIncrement: number;
48
+ minuteIncrement: number;
49
+ time_24hr: boolean;
50
+ minDate: null;
51
+ disableWeekends: boolean;
52
+ disableWeekdays: boolean;
53
+ maxDate: null;
54
+ };
55
+ }[];
56
+ }
57
+ export default _default;