@formio/js 5.0.0-dev.5631.2d9a450 → 5.0.0-dev.5633.3b83d8c

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.
@@ -356,6 +356,12 @@ declare class Webform extends NestedDataComponent {
356
356
  * @returns {Object}
357
357
  */
358
358
  get submission(): Object;
359
+ /**
360
+ * @param submission
361
+ * @param flags
362
+ * @return {void}
363
+ */
364
+ onSetSubmission(submission: any, flags?: {}): void;
359
365
  /**
360
366
  * Sets a submission and returns the promise when it is ready.
361
367
  * @param submission
@@ -716,6 +716,17 @@ class Webform extends NestedDataComponent_1.default {
716
716
  set submission(submission) {
717
717
  this.setSubmission(submission);
718
718
  }
719
+ /**
720
+ * @param submission
721
+ * @param flags
722
+ * @return {void}
723
+ */
724
+ onSetSubmission(submission, flags = {}) {
725
+ this.submissionSet = true;
726
+ this.triggerChange(flags);
727
+ this.emit('beforeSetSubmission', submission);
728
+ this.setValue(submission, flags);
729
+ }
719
730
  /**
720
731
  * Sets a submission and returns the promise when it is ready.
721
732
  * @param submission
@@ -728,10 +739,7 @@ class Webform extends NestedDataComponent_1.default {
728
739
  if (resolveFlags) {
729
740
  flags = Object.assign(Object.assign({}, flags), resolveFlags);
730
741
  }
731
- this.submissionSet = true;
732
- this.triggerChange(flags);
733
- this.emit('beforeSetSubmission', submission);
734
- this.setValue(submission, flags);
742
+ this.onSetSubmission(submission, flags);
735
743
  return this.submissionReadyResolve(submission);
736
744
  }, (err) => this.submissionReadyReject(err)).catch((err) => this.submissionReadyReject(err));
737
745
  }
@@ -327,10 +327,12 @@ declare class Component extends Element {
327
327
  */
328
328
  loadRefs(element: HTMLElement, refs: object, referenceAttributeName?: string | undefined): void;
329
329
  setOpenModalElement(template: any): void;
330
+ renderModalPreview(ctx: any): any;
330
331
  getModalPreviewTemplate(): any;
331
332
  build(element: any): Promise<void>;
332
333
  get hasModalSaveButton(): boolean;
333
334
  render(children?: string, topLevel?: boolean): any;
335
+ createTooltip(tooltipEl: any, settings?: {}): import("tippy.js").Instance<import("tippy.js").Props>[];
334
336
  attachTooltips(toolTipsRefs: any): void;
335
337
  createComponentModal(element: any, modalShouldBeOpened: any, currentValue: any): ComponentModal;
336
338
  attach(element: any): Promise<void>;
@@ -1029,6 +1029,9 @@ class Component extends Element_1.default {
1029
1029
  setOpenModalElement(template) {
1030
1030
  this.componentModal.setOpenModalElement(template || this.getModalPreviewTemplate());
1031
1031
  }
1032
+ renderModalPreview(ctx) {
1033
+ return this.renderTemplate('modalPreview', ctx || {});
1034
+ }
1032
1035
  getModalPreviewTemplate() {
1033
1036
  var _a;
1034
1037
  const dataValue = this.component.type === 'password' ? this.dataValue.replace(/./g, '•') : this.dataValue;
@@ -1036,7 +1039,7 @@ class Component extends Element_1.default {
1036
1039
  if (this.hasInput && ((_a = this.component.validate) === null || _a === void 0 ? void 0 : _a.required) && !this.isPDFReadOnlyMode) {
1037
1040
  modalLabel = { className: 'field-required' };
1038
1041
  }
1039
- return this.renderTemplate('modalPreview', {
1042
+ return this.renderModalPreview({
1040
1043
  previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('Click to set value'),
1041
1044
  messages: '',
1042
1045
  labelInfo: modalLabel,
@@ -1074,21 +1077,17 @@ class Component extends Element_1.default {
1074
1077
  }, topLevel);
1075
1078
  }
1076
1079
  }
1080
+ createTooltip(tooltipEl, settings = {}) {
1081
+ const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
1082
+ const tooltipDataTitle = tooltipEl.getAttribute('data-title');
1083
+ const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1084
+ .replace(/(?:\r\n|\r|\n)/g, '<br />');
1085
+ return (0, tippy_js_1.default)(tooltipEl, Object.assign(Object.assign({ allowHTML: true, trigger: 'mouseenter click focus', placement: 'right', zIndex: 10000, interactive: true }, settings), { content: this.t(this.sanitize(tooltipText), { _userInput: true }) }));
1086
+ }
1077
1087
  attachTooltips(toolTipsRefs) {
1078
1088
  toolTipsRefs === null || toolTipsRefs === void 0 ? void 0 : toolTipsRefs.forEach((tooltip, index) => {
1079
1089
  if (tooltip) {
1080
- const tooltipAttribute = tooltip.getAttribute('data-tooltip');
1081
- const tooltipDataTitle = tooltip.getAttribute('data-title');
1082
- const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1083
- .replace(/(?:\r\n|\r|\n)/g, '<br />');
1084
- this.tooltips[index] = (0, tippy_js_1.default)(tooltip, {
1085
- allowHTML: true,
1086
- trigger: 'mouseenter click focus',
1087
- placement: 'right',
1088
- zIndex: 10000,
1089
- interactive: true,
1090
- content: this.t(this.sanitize(tooltipText), { _userInput: true }),
1091
- });
1090
+ this.tooltips[index] = this.createTooltip(tooltip);
1092
1091
  }
1093
1092
  });
1094
1093
  }
@@ -79,6 +79,7 @@ export default class FormComponent extends Component {
79
79
  isHidden(): boolean;
80
80
  setValue(submission: any, flags?: {}): boolean;
81
81
  setSubFormValue(submission: any, flags: any): void;
82
+ onSetSubFormValue(submission: any, flags: any): void;
82
83
  areAllComponentsEmpty(data: any): boolean;
83
84
  updateSubFormVisibility(): void;
84
85
  /**
@@ -645,9 +645,12 @@ class FormComponent extends Component_1.default {
645
645
  });
646
646
  }
647
647
  else {
648
- this.subForm.setValue(submission, flags);
648
+ this.onSetSubFormValue(submission, flags);
649
649
  }
650
650
  }
651
+ onSetSubFormValue(submission, flags) {
652
+ this.subForm.setValue(submission, flags);
653
+ }
651
654
  isEmpty(value = this.dataValue) {
652
655
  return value === null || lodash_1.default.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value === null || value === void 0 ? void 0 : value.data) && !(value === null || value === void 0 ? void 0 : value._id));
653
656
  }
@@ -172,7 +172,7 @@ class SignatureComponent extends Input_1.default {
172
172
  return false;
173
173
  }
174
174
  getModalPreviewTemplate() {
175
- return this.renderTemplate('modalPreview', {
175
+ return this.renderModalPreview({
176
176
  previewText: this.dataValue ?
177
177
  `<img src=${this.dataValue} ${this._referenceAttributeName}='openModal' style="width: 100%;height: 100%;" />` :
178
178
  this.t('Click to Sign')
@@ -356,6 +356,12 @@ declare class Webform extends NestedDataComponent {
356
356
  * @returns {Object}
357
357
  */
358
358
  get submission(): Object;
359
+ /**
360
+ * @param submission
361
+ * @param flags
362
+ * @return {void}
363
+ */
364
+ onSetSubmission(submission: any, flags?: {}): void;
359
365
  /**
360
366
  * Sets a submission and returns the promise when it is ready.
361
367
  * @param submission
@@ -714,6 +714,17 @@ export default class Webform extends NestedDataComponent {
714
714
  set submission(submission) {
715
715
  this.setSubmission(submission);
716
716
  }
717
+ /**
718
+ * @param submission
719
+ * @param flags
720
+ * @return {void}
721
+ */
722
+ onSetSubmission(submission, flags = {}) {
723
+ this.submissionSet = true;
724
+ this.triggerChange(flags);
725
+ this.emit('beforeSetSubmission', submission);
726
+ this.setValue(submission, flags);
727
+ }
717
728
  /**
718
729
  * Sets a submission and returns the promise when it is ready.
719
730
  * @param submission
@@ -732,10 +743,7 @@ export default class Webform extends NestedDataComponent {
732
743
  ...resolveFlags
733
744
  };
734
745
  }
735
- this.submissionSet = true;
736
- this.triggerChange(flags);
737
- this.emit('beforeSetSubmission', submission);
738
- this.setValue(submission, flags);
746
+ this.onSetSubmission(submission, flags);
739
747
  return this.submissionReadyResolve(submission);
740
748
  }, (err) => this.submissionReadyReject(err)).catch((err) => this.submissionReadyReject(err));
741
749
  }
@@ -327,10 +327,12 @@ declare class Component extends Element {
327
327
  */
328
328
  loadRefs(element: HTMLElement, refs: object, referenceAttributeName?: string | undefined): void;
329
329
  setOpenModalElement(template: any): void;
330
+ renderModalPreview(ctx: any): any;
330
331
  getModalPreviewTemplate(): any;
331
332
  build(element: any): Promise<void>;
332
333
  get hasModalSaveButton(): boolean;
333
334
  render(children?: string, topLevel?: boolean): any;
335
+ createTooltip(tooltipEl: any, settings?: {}): import("tippy.js").Instance<import("tippy.js").Props>[];
334
336
  attachTooltips(toolTipsRefs: any): void;
335
337
  createComponentModal(element: any, modalShouldBeOpened: any, currentValue: any): ComponentModal;
336
338
  attach(element: any): Promise<void>;
@@ -996,13 +996,16 @@ export default class Component extends Element {
996
996
  setOpenModalElement(template) {
997
997
  this.componentModal.setOpenModalElement(template || this.getModalPreviewTemplate());
998
998
  }
999
+ renderModalPreview(ctx) {
1000
+ return this.renderTemplate('modalPreview', ctx || {});
1001
+ }
999
1002
  getModalPreviewTemplate() {
1000
1003
  const dataValue = this.component.type === 'password' ? this.dataValue.replace(/./g, '•') : this.dataValue;
1001
1004
  let modalLabel;
1002
1005
  if (this.hasInput && this.component.validate?.required && !this.isPDFReadOnlyMode) {
1003
1006
  modalLabel = { className: 'field-required' };
1004
1007
  }
1005
- return this.renderTemplate('modalPreview', {
1008
+ return this.renderModalPreview({
1006
1009
  previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('Click to set value'),
1007
1010
  messages: '',
1008
1011
  labelInfo: modalLabel,
@@ -1040,21 +1043,25 @@ export default class Component extends Element {
1040
1043
  }, topLevel);
1041
1044
  }
1042
1045
  }
1046
+ createTooltip(tooltipEl, settings = {}) {
1047
+ const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
1048
+ const tooltipDataTitle = tooltipEl.getAttribute('data-title');
1049
+ const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1050
+ .replace(/(?:\r\n|\r|\n)/g, '<br />');
1051
+ return tippy(tooltipEl, {
1052
+ allowHTML: true,
1053
+ trigger: 'mouseenter click focus',
1054
+ placement: 'right',
1055
+ zIndex: 10000,
1056
+ interactive: true,
1057
+ ...settings,
1058
+ content: this.t(this.sanitize(tooltipText), { _userInput: true }),
1059
+ });
1060
+ }
1043
1061
  attachTooltips(toolTipsRefs) {
1044
1062
  toolTipsRefs?.forEach((tooltip, index) => {
1045
1063
  if (tooltip) {
1046
- const tooltipAttribute = tooltip.getAttribute('data-tooltip');
1047
- const tooltipDataTitle = tooltip.getAttribute('data-title');
1048
- const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1049
- .replace(/(?:\r\n|\r|\n)/g, '<br />');
1050
- this.tooltips[index] = tippy(tooltip, {
1051
- allowHTML: true,
1052
- trigger: 'mouseenter click focus',
1053
- placement: 'right',
1054
- zIndex: 10000,
1055
- interactive: true,
1056
- content: this.t(this.sanitize(tooltipText), { _userInput: true }),
1057
- });
1064
+ this.tooltips[index] = this.createTooltip(tooltip);
1058
1065
  }
1059
1066
  });
1060
1067
  }
@@ -79,6 +79,7 @@ export default class FormComponent extends Component {
79
79
  isHidden(): boolean;
80
80
  setValue(submission: any, flags?: {}): boolean;
81
81
  setSubFormValue(submission: any, flags: any): void;
82
+ onSetSubFormValue(submission: any, flags: any): void;
82
83
  areAllComponentsEmpty(data: any): boolean;
83
84
  updateSubFormVisibility(): void;
84
85
  /**
@@ -635,9 +635,12 @@ export default class FormComponent extends Component {
635
635
  });
636
636
  }
637
637
  else {
638
- this.subForm.setValue(submission, flags);
638
+ this.onSetSubFormValue(submission, flags);
639
639
  }
640
640
  }
641
+ onSetSubFormValue(submission, flags) {
642
+ this.subForm.setValue(submission, flags);
643
+ }
641
644
  isEmpty(value = this.dataValue) {
642
645
  return value === null || _.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value?.data) && !value?._id);
643
646
  }
@@ -169,7 +169,7 @@ export default class SignatureComponent extends Input {
169
169
  return false;
170
170
  }
171
171
  getModalPreviewTemplate() {
172
- return this.renderTemplate('modalPreview', {
172
+ return this.renderModalPreview({
173
173
  previewText: this.dataValue ?
174
174
  `<img src=${this.dataValue} ${this._referenceAttributeName}='openModal' style="width: 100%;height: 100%;" />` :
175
175
  this.t('Click to Sign')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5631.2d9a450",
3
+ "version": "5.0.0-dev.5633.3b83d8c",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {