@formio/js 5.1.0-dev.6002.16f1966 → 5.1.0-dev.6011.fddfe5e

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.
@@ -190,7 +190,10 @@ declare class Webform extends NestedDataComponent {
190
190
  get language(): string;
191
191
  root: this;
192
192
  localRoot: this;
193
+ beforeInit(): void;
194
+ executeFormController: any;
193
195
  get emptyValue(): null;
196
+ get shouldCallFormController(): any;
194
197
  get shadowRoot(): any;
195
198
  /**
196
199
  * Add a language for translations
@@ -360,7 +363,7 @@ declare class Webform extends NestedDataComponent {
360
363
  * @returns {Promise} - The promise that is triggered when the form is built.
361
364
  */
362
365
  init(): Promise<any>;
363
- executeFormController(): false | undefined;
366
+ _executeFormController(): void;
364
367
  build(element: any): Promise<any>;
365
368
  getClassName(): string;
366
369
  render(): string;
@@ -315,12 +315,24 @@ class Webform extends NestedDataComponent_1.default {
315
315
  this.localRoot = this;
316
316
  }
317
317
  /* eslint-enable max-statements */
318
+ beforeInit() {
319
+ this.executeFormController = lodash_1.default.once(this._executeFormController);
320
+ }
318
321
  get language() {
319
322
  return this.options.language;
320
323
  }
321
324
  get emptyValue() {
322
325
  return null;
323
326
  }
327
+ get shouldCallFormController() {
328
+ // If no controller value or
329
+ // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
330
+ return (this.form &&
331
+ this.form.controller &&
332
+ !((!this.visible || this.component.hidden) &&
333
+ this.component.clearOnHide &&
334
+ !this.rootPristine));
335
+ }
324
336
  componentContext() {
325
337
  return this._data;
326
338
  }
@@ -899,19 +911,12 @@ class Webform extends NestedDataComponent_1.default {
899
911
  this.on('resetForm', () => this.resetValue(), true);
900
912
  this.on('deleteSubmission', () => this.deleteSubmission(), true);
901
913
  this.on('refreshData', () => this.updateValue(), true);
902
- this.executeFormController();
914
+ if (this.shouldCallFormController) {
915
+ this.executeFormController();
916
+ }
903
917
  return this.formReady;
904
918
  }
905
- executeFormController() {
906
- // If no controller value or
907
- // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
908
- if (!this.form ||
909
- !this.form.controller ||
910
- ((!this.visible || this.component.hidden) &&
911
- this.component.clearOnHide &&
912
- !this.rootPristine)) {
913
- return false;
914
- }
919
+ _executeFormController() {
915
920
  this.formReady.then(() => {
916
921
  this.evaluate(this.form.controller, {
917
922
  components: this.components,
@@ -453,6 +453,9 @@ class Component extends Element_1.default {
453
453
  // Allow anyone to hook into the component creation.
454
454
  this.hook('component');
455
455
  if (!this.options.skipInit) {
456
+ if (typeof this.beforeInit === 'function') {
457
+ this.beforeInit();
458
+ }
456
459
  this.init();
457
460
  }
458
461
  }
@@ -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(', ');
@@ -11,7 +11,7 @@ exports.default = [
11
11
  {
12
12
  weight: 140,
13
13
  type: 'checkbox',
14
- label: 'Clear Value When Hidden',
14
+ label: 'Omit Value From Submission Data When Conditionally Hidden',
15
15
  key: 'clearOnHide',
16
16
  defaultValue: true,
17
17
  tooltip: 'When a field is hidden, clear the value.',
@@ -69,7 +69,7 @@ exports.default = [
69
69
  input: true,
70
70
  weight: 20,
71
71
  key: 'reference',
72
- label: 'Save as reference',
73
- tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.'
72
+ label: 'Submit as reference',
73
+ tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
74
74
  }
75
75
  ];
@@ -641,8 +641,8 @@ exports.default = [
641
641
  input: true,
642
642
  weight: 25,
643
643
  key: 'reference',
644
- label: 'Save as reference',
645
- tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.',
644
+ label: 'Submit as reference',
645
+ tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
646
646
  conditional: {
647
647
  json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
648
648
  },
@@ -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;
@@ -190,7 +190,10 @@ declare class Webform extends NestedDataComponent {
190
190
  get language(): string;
191
191
  root: this;
192
192
  localRoot: this;
193
+ beforeInit(): void;
194
+ executeFormController: any;
193
195
  get emptyValue(): null;
196
+ get shouldCallFormController(): any;
194
197
  get shadowRoot(): any;
195
198
  /**
196
199
  * Add a language for translations
@@ -360,7 +363,7 @@ declare class Webform extends NestedDataComponent {
360
363
  * @returns {Promise} - The promise that is triggered when the form is built.
361
364
  */
362
365
  init(): Promise<any>;
363
- executeFormController(): false | undefined;
366
+ _executeFormController(): void;
364
367
  build(element: any): Promise<any>;
365
368
  getClassName(): string;
366
369
  render(): string;
@@ -287,12 +287,24 @@ export default class Webform extends NestedDataComponent {
287
287
  this.localRoot = this;
288
288
  }
289
289
  /* eslint-enable max-statements */
290
+ beforeInit() {
291
+ this.executeFormController = _.once(this._executeFormController);
292
+ }
290
293
  get language() {
291
294
  return this.options.language;
292
295
  }
293
296
  get emptyValue() {
294
297
  return null;
295
298
  }
299
+ get shouldCallFormController() {
300
+ // If no controller value or
301
+ // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
302
+ return (this.form &&
303
+ this.form.controller &&
304
+ !((!this.visible || this.component.hidden) &&
305
+ this.component.clearOnHide &&
306
+ !this.rootPristine));
307
+ }
296
308
  componentContext() {
297
309
  return this._data;
298
310
  }
@@ -902,19 +914,12 @@ export default class Webform extends NestedDataComponent {
902
914
  this.on('resetForm', () => this.resetValue(), true);
903
915
  this.on('deleteSubmission', () => this.deleteSubmission(), true);
904
916
  this.on('refreshData', () => this.updateValue(), true);
905
- this.executeFormController();
917
+ if (this.shouldCallFormController) {
918
+ this.executeFormController();
919
+ }
906
920
  return this.formReady;
907
921
  }
908
- executeFormController() {
909
- // If no controller value or
910
- // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
911
- if (!this.form ||
912
- !this.form.controller ||
913
- ((!this.visible || this.component.hidden) &&
914
- this.component.clearOnHide &&
915
- !this.rootPristine)) {
916
- return false;
917
- }
922
+ _executeFormController() {
918
923
  this.formReady.then(() => {
919
924
  this.evaluate(this.form.controller, {
920
925
  components: this.components,
@@ -418,6 +418,9 @@ export default class Component extends Element {
418
418
  // Allow anyone to hook into the component creation.
419
419
  this.hook('component');
420
420
  if (!this.options.skipInit) {
421
+ if (typeof this.beforeInit === 'function') {
422
+ this.beforeInit();
423
+ }
421
424
  this.init();
422
425
  }
423
426
  }
@@ -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(', ');
@@ -6,7 +6,7 @@ export default [
6
6
  {
7
7
  weight: 140,
8
8
  type: 'checkbox',
9
- label: 'Clear Value When Hidden',
9
+ label: 'Omit Value From Submission Data When Conditionally Hidden',
10
10
  key: 'clearOnHide',
11
11
  defaultValue: true,
12
12
  tooltip: 'When a field is hidden, clear the value.',
@@ -66,7 +66,7 @@ export default [
66
66
  input: true,
67
67
  weight: 20,
68
68
  key: 'reference',
69
- label: 'Save as reference',
70
- tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.'
69
+ label: 'Submit as reference',
70
+ tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
71
71
  }
72
72
  ];
@@ -635,8 +635,8 @@ export default [
635
635
  input: true,
636
636
  weight: 25,
637
637
  key: 'reference',
638
- label: 'Save as reference',
639
- tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.',
638
+ label: 'Submit as reference',
639
+ tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
640
640
  conditional: {
641
641
  json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
642
642
  },
@@ -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.6002.16f1966",
3
+ "version": "5.1.0-dev.6011.fddfe5e",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {