@formio/js 5.1.0-dev.6012.8e3fc09 → 5.1.0-dev.6017.d6efba0

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.
@@ -106,6 +106,7 @@ declare class Wizard extends Webform {
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
108
  focusOnComponent(key: any): void | Promise<void>;
109
+ triggerButtonCaptcha(page: any): void;
109
110
  }
110
111
  declare namespace Wizard {
111
112
  let setBaseUrl: any;
package/lib/cjs/Wizard.js CHANGED
@@ -669,6 +669,7 @@ class Wizard extends Webform_1.default {
669
669
  beforeSubmit() {
670
670
  const pages = this.getPages({ all: true });
671
671
  return Promise.all(pages.map((page) => {
672
+ this.triggerButtonCaptcha(page);
672
673
  page.options.beforeSubmit = true;
673
674
  return page.beforeSubmit();
674
675
  }));
@@ -941,6 +942,22 @@ class Wizard extends Webform_1.default {
941
942
  }
942
943
  return super.focusOnComponent(key);
943
944
  }
945
+ triggerButtonCaptcha(page) {
946
+ if (!page.components) {
947
+ return;
948
+ }
949
+ let captchaComponent;
950
+ page.eachComponent((component) => {
951
+ if (/^(re)?captcha$/.test(component.component.type) &&
952
+ component.component.eventType === 'buttonClick' &&
953
+ component.component.buttonKey === 'submit') {
954
+ captchaComponent = component;
955
+ }
956
+ });
957
+ if (captchaComponent) {
958
+ captchaComponent.verify(`submitClick`);
959
+ }
960
+ }
944
961
  }
945
962
  exports.default = Wizard;
946
963
  Wizard.setBaseUrl = Formio_1.Formio.setBaseUrl;
@@ -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';
@@ -104,8 +104,8 @@ class DateTimeComponent extends Input_1.default {
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
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
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
109
  this.originalComponent = (0, utils_2.fastCloneDeep)(this.component);
110
110
  /* eslint-enable camelcase */
111
111
  }
@@ -153,15 +153,15 @@ class DateTimeComponent extends Input_1.default {
153
153
  }
154
154
  return super.checkValidity(data, dirty, rowData);
155
155
  }
156
- getValueAsString(value) {
156
+ getValueAsString(value, options) {
157
157
  let format = utils_1.default.convertFormatToMoment(this.component.format);
158
158
  format += format.match(/z$/) ? '' : ' z';
159
159
  const timezone = this.timezone;
160
160
  if (value && !this.attached && timezone) {
161
161
  if (Array.isArray(value) && this.component.multiple) {
162
- 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(', ');
163
163
  }
164
- 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));
165
165
  }
166
166
  if (Array.isArray(value) && this.component.multiple) {
167
167
  return value.map(item => lodash_1.default.trim((0, moment_1.default)(item).format(format))).join(', ');
@@ -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;
@@ -106,6 +106,7 @@ declare class Wizard extends Webform {
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
108
  focusOnComponent(key: any): void | Promise<void>;
109
+ triggerButtonCaptcha(page: any): void;
109
110
  }
110
111
  declare namespace Wizard {
111
112
  let setBaseUrl: any;
package/lib/mjs/Wizard.js CHANGED
@@ -659,6 +659,7 @@ export default class Wizard extends Webform {
659
659
  beforeSubmit() {
660
660
  const pages = this.getPages({ all: true });
661
661
  return Promise.all(pages.map((page) => {
662
+ this.triggerButtonCaptcha(page);
662
663
  page.options.beforeSubmit = true;
663
664
  return page.beforeSubmit();
664
665
  }));
@@ -929,6 +930,22 @@ export default class Wizard extends Webform {
929
930
  }
930
931
  return super.focusOnComponent(key);
931
932
  }
933
+ triggerButtonCaptcha(page) {
934
+ if (!page.components) {
935
+ return;
936
+ }
937
+ let captchaComponent;
938
+ page.eachComponent((component) => {
939
+ if (/^(re)?captcha$/.test(component.component.type) &&
940
+ component.component.eventType === 'buttonClick' &&
941
+ component.component.buttonKey === 'submit') {
942
+ captchaComponent = component;
943
+ }
944
+ });
945
+ if (captchaComponent) {
946
+ captchaComponent.verify(`submitClick`);
947
+ }
948
+ }
932
949
  }
933
950
  Wizard.setBaseUrl = Formio.setBaseUrl;
934
951
  Wizard.setApiUrl = Formio.setApiUrl;
@@ -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';
@@ -128,8 +128,8 @@ export default class DateTimeComponent extends Input {
128
128
  ...customOptions,
129
129
  };
130
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
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
133
  this.originalComponent = fastCloneDeep(this.component);
134
134
  /* eslint-enable camelcase */
135
135
  }
@@ -177,15 +177,15 @@ export default class DateTimeComponent extends Input {
177
177
  }
178
178
  return super.checkValidity(data, dirty, rowData);
179
179
  }
180
- getValueAsString(value) {
180
+ getValueAsString(value, options) {
181
181
  let format = FormioUtils.convertFormatToMoment(this.component.format);
182
182
  format += format.match(/z$/) ? '' : ' z';
183
183
  const timezone = this.timezone;
184
184
  if (value && !this.attached && timezone) {
185
185
  if (Array.isArray(value) && this.component.multiple) {
186
- 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(', ');
187
187
  }
188
- return _.trim(FormioUtils.momentDate(value, format, timezone).format(format));
188
+ return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
189
189
  }
190
190
  if (Array.isArray(value) && this.component.multiple) {
191
191
  return value.map(item => _.trim(moment(item).format(format))).join(', ');
@@ -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.
@@ -632,9 +632,10 @@ export function loadZones(url, timezone) {
632
632
  * @param {string|Date} value - The value to convert into a moment date.
633
633
  * @param {string} format - The format to convert the date to.
634
634
  * @param {string} timezone - The timezone to convert the date to.
635
+ * @param {object} options - The options object
635
636
  * @returns {Date} - The moment date object.
636
637
  */
637
- export function momentDate(value, format, timezone) {
638
+ export function momentDate(value, format, timezone, options) {
638
639
  const momentDate = moment(value);
639
640
  if (!timezone) {
640
641
  return momentDate;
@@ -642,7 +643,7 @@ export function momentDate(value, format, timezone) {
642
643
  if (timezone === 'UTC') {
643
644
  timezone = 'Etc/UTC';
644
645
  }
645
- if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && moment.zonesLoaded) {
646
+ if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (moment.zonesLoaded || options?.email)) {
646
647
  return momentDate.tz(timezone);
647
648
  }
648
649
  return momentDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6012.8e3fc09",
3
+ "version": "5.1.0-dev.6017.d6efba0",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {