@formio/js 5.0.0-dev.5664.1af299f → 5.0.0-dev.5664.50b8944

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 (82) hide show
  1. package/Changelog.md +15 -2
  2. package/dist/formio.form.js +14 -14
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.full.js +14 -14
  5. package/dist/formio.full.min.js +1 -1
  6. package/dist/formio.js +2 -2
  7. package/dist/formio.min.js +1 -1
  8. package/dist/formio.utils.js +1 -1
  9. package/dist/formio.utils.min.js +1 -1
  10. package/lib/cjs/Formio.js +1 -0
  11. package/lib/cjs/Webform.d.ts +7 -0
  12. package/lib/cjs/Webform.js +18 -5
  13. package/lib/cjs/components/_classes/component/Component.d.ts +13 -0
  14. package/lib/cjs/components/_classes/component/Component.js +27 -13
  15. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
  16. package/lib/cjs/components/_classes/component/fixtures/comp7.d.ts +84 -0
  17. package/lib/cjs/components/_classes/component/fixtures/comp7.js +86 -0
  18. package/lib/cjs/components/_classes/component/fixtures/index.d.ts +2 -1
  19. package/lib/cjs/components/_classes/component/fixtures/index.js +3 -1
  20. package/lib/cjs/components/_classes/input/Input.js +23 -1
  21. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  22. package/lib/cjs/components/_classes/multivalue/Multivalue.js +8 -1
  23. package/lib/cjs/components/datagrid/DataGrid.js +3 -0
  24. package/lib/cjs/components/datagrid/fixtures/comp9.d.ts +41 -0
  25. package/lib/cjs/components/datagrid/fixtures/comp9.js +44 -0
  26. package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
  27. package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
  28. package/lib/cjs/components/editgrid/EditGrid.js +2 -2
  29. package/lib/cjs/components/form/Form.d.ts +7 -0
  30. package/lib/cjs/components/form/Form.js +10 -1
  31. package/lib/cjs/components/number/Number.js +1 -1
  32. package/lib/cjs/components/number/fixtures/comp8.d.ts +32 -0
  33. package/lib/cjs/components/number/fixtures/comp8.js +28 -0
  34. package/lib/cjs/components/number/fixtures/index.d.ts +2 -1
  35. package/lib/cjs/components/number/fixtures/index.js +3 -1
  36. package/lib/cjs/components/phonenumber/fixtures/comp2.d.ts +16 -0
  37. package/lib/cjs/components/phonenumber/fixtures/comp2.js +25 -0
  38. package/lib/cjs/components/phonenumber/fixtures/index.d.ts +2 -1
  39. package/lib/cjs/components/phonenumber/fixtures/index.js +3 -1
  40. package/lib/cjs/components/select/Select.js +1 -2
  41. package/lib/cjs/components/signature/Signature.d.ts +0 -1
  42. package/lib/cjs/components/signature/Signature.js +1 -1
  43. package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
  44. package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
  45. package/lib/cjs/utils/utils.js +0 -4
  46. package/lib/mjs/Formio.js +1 -0
  47. package/lib/mjs/Webform.d.ts +7 -0
  48. package/lib/mjs/Webform.js +18 -5
  49. package/lib/mjs/components/_classes/component/Component.d.ts +13 -0
  50. package/lib/mjs/components/_classes/component/Component.js +35 -13
  51. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
  52. package/lib/mjs/components/_classes/component/fixtures/comp7.d.ts +84 -0
  53. package/lib/mjs/components/_classes/component/fixtures/comp7.js +84 -0
  54. package/lib/mjs/components/_classes/component/fixtures/index.d.ts +2 -1
  55. package/lib/mjs/components/_classes/component/fixtures/index.js +2 -1
  56. package/lib/mjs/components/_classes/input/Input.js +22 -1
  57. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  58. package/lib/mjs/components/_classes/multivalue/Multivalue.js +8 -1
  59. package/lib/mjs/components/datagrid/DataGrid.js +3 -0
  60. package/lib/mjs/components/datagrid/fixtures/comp9.d.ts +41 -0
  61. package/lib/mjs/components/datagrid/fixtures/comp9.js +42 -0
  62. package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
  63. package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
  64. package/lib/mjs/components/editgrid/EditGrid.js +2 -2
  65. package/lib/mjs/components/form/Form.d.ts +7 -0
  66. package/lib/mjs/components/form/Form.js +10 -1
  67. package/lib/mjs/components/number/Number.js +1 -1
  68. package/lib/mjs/components/number/fixtures/comp8.d.ts +32 -0
  69. package/lib/mjs/components/number/fixtures/comp8.js +26 -0
  70. package/lib/mjs/components/number/fixtures/index.d.ts +2 -1
  71. package/lib/mjs/components/number/fixtures/index.js +2 -1
  72. package/lib/mjs/components/phonenumber/fixtures/comp2.d.ts +16 -0
  73. package/lib/mjs/components/phonenumber/fixtures/comp2.js +23 -0
  74. package/lib/mjs/components/phonenumber/fixtures/index.d.ts +2 -1
  75. package/lib/mjs/components/phonenumber/fixtures/index.js +2 -1
  76. package/lib/mjs/components/select/Select.js +1 -2
  77. package/lib/mjs/components/signature/Signature.d.ts +0 -1
  78. package/lib/mjs/components/signature/Signature.js +1 -1
  79. package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
  80. package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
  81. package/lib/mjs/utils/utils.js +0 -4
  82. package/package.json +1 -2
@@ -0,0 +1,32 @@
1
+ declare namespace _default {
2
+ let components: ({
3
+ label: string;
4
+ applyMaskOn: string;
5
+ mask: boolean;
6
+ tableView: boolean;
7
+ delimiter: boolean;
8
+ requireDecimal: boolean;
9
+ inputFormat: string;
10
+ truncateMultipleSpaces: boolean;
11
+ key: string;
12
+ type: string;
13
+ input: boolean;
14
+ decimalSymbol: string;
15
+ disableOnInvalid?: undefined;
16
+ } | {
17
+ type: string;
18
+ label: string;
19
+ key: string;
20
+ disableOnInvalid: boolean;
21
+ input: boolean;
22
+ tableView: boolean;
23
+ applyMaskOn?: undefined;
24
+ mask?: undefined;
25
+ delimiter?: undefined;
26
+ requireDecimal?: undefined;
27
+ inputFormat?: undefined;
28
+ truncateMultipleSpaces?: undefined;
29
+ decimalSymbol?: undefined;
30
+ })[];
31
+ }
32
+ export default _default;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ components: [
5
+ {
6
+ "label": "Number",
7
+ "applyMaskOn": "change",
8
+ "mask": false,
9
+ "tableView": false,
10
+ "delimiter": false,
11
+ "requireDecimal": false,
12
+ "inputFormat": "plain",
13
+ "truncateMultipleSpaces": false,
14
+ "key": "number",
15
+ "type": "number",
16
+ "input": true,
17
+ "decimalSymbol": "-"
18
+ },
19
+ {
20
+ "type": "button",
21
+ "label": "Submit",
22
+ "key": "submit",
23
+ "disableOnInvalid": true,
24
+ "input": true,
25
+ "tableView": false
26
+ }
27
+ ]
28
+ };
@@ -5,4 +5,5 @@ import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
7
  import comp7 from './comp7';
8
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
8
+ import comp8 from './comp8';
9
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8 };
@@ -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.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.comp8 = 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"));
@@ -18,3 +18,5 @@ const comp6_1 = __importDefault(require("./comp6"));
18
18
  exports.comp6 = comp6_1.default;
19
19
  const comp7_1 = __importDefault(require("./comp7"));
20
20
  exports.comp7 = comp7_1.default;
21
+ const comp8_1 = __importDefault(require("./comp8"));
22
+ exports.comp8 = comp8_1.default;
@@ -0,0 +1,16 @@
1
+ declare namespace _default {
2
+ let components: {
3
+ label: string;
4
+ applyMaskOn: string;
5
+ allowMultipleMasks: boolean;
6
+ tableView: boolean;
7
+ key: string;
8
+ type: string;
9
+ inputMasks: {
10
+ label: string;
11
+ mask: string;
12
+ }[];
13
+ input: boolean;
14
+ }[];
15
+ }
16
+ export default _default;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ components: [
5
+ {
6
+ "label": "Phone Number",
7
+ "applyMaskOn": "change",
8
+ "allowMultipleMasks": true,
9
+ "tableView": true,
10
+ "key": "phoneNumber",
11
+ "type": "phoneNumber",
12
+ "inputMasks": [
13
+ {
14
+ "label": "Canada",
15
+ "mask": "(999) 999-9999"
16
+ },
17
+ {
18
+ "label": "Other",
19
+ "mask": ""
20
+ }
21
+ ],
22
+ "input": true
23
+ }
24
+ ]
25
+ };
@@ -1,2 +1,3 @@
1
- export { comp1 };
2
1
  import comp1 from './comp1';
2
+ import comp2 from './comp2';
3
+ export { comp1, comp2 };
@@ -3,6 +3,8 @@ 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.comp1 = void 0;
6
+ exports.comp2 = exports.comp1 = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
+ const comp2_1 = __importDefault(require("./comp2"));
10
+ exports.comp2 = comp2_1.default;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const Formio_1 = require("../../Formio");
8
8
  const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
9
- const Input_1 = __importDefault(require("../_classes/input/Input"));
10
9
  const Form_1 = __importDefault(require("../../Form"));
11
10
  const utils_1 = require("../../utils/utils");
12
11
  const ChoicesWrapper_1 = __importDefault(require("../../utils/ChoicesWrapper"));
@@ -834,7 +833,7 @@ class SelectComponent extends ListComponent_1.default {
834
833
  this.choices.containerOuter.element.setAttribute('tabIndex', '-1');
835
834
  this.addEventListener(this.choices.containerOuter.element, 'focus', () => this.focusableElement.focus());
836
835
  }
837
- Input_1.default.prototype.addFocusBlurEvents.call(this, this.focusableElement);
836
+ this.addFocusBlurEvents(this.choices.input.element);
838
837
  if (this.itemsFromUrl && !this.component.noRefreshOnScroll) {
839
838
  this.scrollList = this.choices.choiceList.element;
840
839
  this.addEventListener(this.scrollList, 'scroll', () => this.onScroll());
@@ -22,7 +22,6 @@ export default class SignatureComponent extends Input {
22
22
  showCanvas(show: any): void;
23
23
  onDisabled(): void;
24
24
  checkSize(force: any, scale: any): void;
25
- getModalPreviewTemplate(): any;
26
25
  signaturePad: SignaturePad | null | undefined;
27
26
  observer: any;
28
27
  getValueAsString(value: any): "" | "Yes" | "No";
@@ -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')
@@ -82,6 +82,11 @@ export class GoogleAddressProvider extends AddressProvider {
82
82
  search(): Promise<void>;
83
83
  makeRequest(): Promise<void>;
84
84
  getDisplayValue(address: any): any;
85
+ /**
86
+ * Tries to remove the library if api key for loaded script is different.
87
+ * @param {ProviderOptions} options - The options for the provider.
88
+ */
89
+ tryRemoveLibrary(options?: ProviderOptions): void;
85
90
  }
86
91
  export type AutocompleteOptions = {
87
92
  /**
@@ -8,6 +8,9 @@ exports.GoogleAddressProvider = void 0;
8
8
  const Formio_1 = require("../../Formio");
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
10
  const AddressProvider_1 = require("./AddressProvider");
11
+ const GOOGLE_MAPS_BASE_URL = 'https://maps.googleapis.com';
12
+ const GOOGLE_MAPS_JS_URL = `${GOOGLE_MAPS_BASE_URL}/maps/api/js`;
13
+ const GOOGLE_MAPS_JS_WITH_PARAMS_URL = `${GOOGLE_MAPS_JS_URL}?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback`;
11
14
  /**
12
15
  * @typedef {object} AutocompleteOptions
13
16
  * @property {string[]} fields - The fields to include in the autocomplete response.
@@ -55,10 +58,11 @@ class GoogleAddressProvider extends AddressProvider_1.AddressProvider {
55
58
  var _a;
56
59
  super(options);
57
60
  this.setAutocompleteOptions();
58
- let src = 'https://maps.googleapis.com/maps/api/js?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback';
61
+ let src = GOOGLE_MAPS_JS_WITH_PARAMS_URL;
59
62
  if ((_a = options.params) === null || _a === void 0 ? void 0 : _a.key) {
60
63
  src += `&key=${options.params.key}`;
61
64
  }
65
+ this.tryRemoveLibrary(options);
62
66
  Formio_1.Formio.requireLibrary(this.getLibraryName(), 'google.maps.places', src);
63
67
  }
64
68
  /**
@@ -185,5 +189,23 @@ class GoogleAddressProvider extends AddressProvider_1.AddressProvider {
185
189
  : this.alternativeDisplayValueProperty;
186
190
  return lodash_1.default.get(address, displayedProperty, '');
187
191
  }
192
+ /**
193
+ * Tries to remove the library if api key for loaded script is different.
194
+ * @param {ProviderOptions} options - The options for the provider.
195
+ */
196
+ tryRemoveLibrary(options = {}) {
197
+ var _a, _b, _c;
198
+ if (!Formio_1.Formio.libraries[this.getLibraryName()]) {
199
+ return;
200
+ }
201
+ const existingScript = document.querySelector(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
202
+ if (existingScript && ((_a = options.params) === null || _a === void 0 ? void 0 : _a.key) && !existingScript.attributes.src.value.endsWith(options.params.key)) {
203
+ const googleMapsScripts = (_b = document.querySelectorAll(`script[src^="${GOOGLE_MAPS_BASE_URL}"]`)) !== null && _b !== void 0 ? _b : [];
204
+ googleMapsScripts.forEach(script => script.parentNode.removeChild(script));
205
+ delete Formio_1.Formio.libraries[this.getLibraryName()];
206
+ (_c = global === null || global === void 0 ? void 0 : global.google) === null || _c === void 0 ? true : delete _c.maps;
207
+ delete global[`${this.getLibraryName()}Callback`];
208
+ }
209
+ }
188
210
  }
189
211
  exports.GoogleAddressProvider = GoogleAddressProvider;
@@ -34,7 +34,6 @@ exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.unique
34
34
  exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
35
35
  const lodash_1 = __importDefault(require("lodash"));
36
36
  exports._ = lodash_1.default;
37
- const fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
38
37
  const json_logic_js_1 = __importDefault(require("json-logic-js"));
39
38
  exports.jsonLogic = json_logic_js_1.default;
40
39
  const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
@@ -48,9 +47,6 @@ const conditionOperators_1 = __importDefault(require("./conditionOperators"));
48
47
  exports.ConditionOperators = conditionOperators_1.default;
49
48
  const interpolate = Evaluator_1.Evaluator.interpolate;
50
49
  exports.interpolate = interpolate;
51
- const { fetch } = (0, fetch_ponyfill_1.default)({
52
- Promise: Promise
53
- });
54
50
  __exportStar(require("./formUtils"), exports);
55
51
  // Configure JsonLogic
56
52
  operators_1.lodashOperators.forEach((name) => json_logic_js_1.default.add_operation(`_${name}`, lodash_1.default[name]));
package/lib/mjs/Formio.js CHANGED
@@ -118,4 +118,5 @@ if (typeof global !== 'undefined') {
118
118
  if (typeof window !== 'undefined') {
119
119
  FormioCore.addToGlobal(window);
120
120
  }
121
+ FormioEmbed._formioReady(FormioCore);
121
122
  export { FormioCore as Formio };
@@ -330,6 +330,13 @@ declare class Webform extends NestedDataComponent {
330
330
  * @returns {object} - The submission object.
331
331
  */
332
332
  get submission(): object;
333
+ /**
334
+ * Sets the submission value
335
+ * @param {object|null|undefined} submission - The submission to set.
336
+ * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
337
+ * @returns {void}
338
+ */
339
+ onSetSubmission(submission: object | null | undefined, flags?: object | null | undefined): void;
333
340
  /**
334
341
  * Sets a submission and returns the promise when it is ready.
335
342
  * @param {any} submission - The submission to set.
@@ -8,6 +8,7 @@ import Components from "./components/Components";
8
8
  import NestedDataComponent from "./components/_classes/nesteddata/NestedDataComponent";
9
9
  import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from "./utils/utils";
10
10
  import { eachComponent } from "./utils/formUtils";
11
+ import dragula from "dragula";
11
12
  // Initialize the available forms.
12
13
  Formio.forms = {};
13
14
  // Allow people to register components.
@@ -281,6 +282,7 @@ export default class Webform extends NestedDataComponent {
281
282
  // Ensure the root is set to this component.
282
283
  this.root = this;
283
284
  this.localRoot = this;
285
+ this.root.dragulaLib = dragula;
284
286
  }
285
287
  /* eslint-enable max-statements */
286
288
  get language() {
@@ -696,6 +698,18 @@ export default class Webform extends NestedDataComponent {
696
698
  set submission(submission) {
697
699
  this.setSubmission(submission);
698
700
  }
701
+ /**
702
+ * Sets the submission value
703
+ * @param {object|null|undefined} submission - The submission to set.
704
+ * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
705
+ * @returns {void}
706
+ */
707
+ onSetSubmission(submission, flags = {}) {
708
+ this.submissionSet = true;
709
+ this.triggerChange(flags);
710
+ this.emit('beforeSetSubmission', submission);
711
+ this.setValue(submission, flags);
712
+ }
699
713
  /**
700
714
  * Sets a submission and returns the promise when it is ready.
701
715
  * @param {any} submission - The submission to set.
@@ -715,10 +729,7 @@ export default class Webform extends NestedDataComponent {
715
729
  ...resolveFlags,
716
730
  };
717
731
  }
718
- this.submissionSet = true;
719
- this.triggerChange(flags);
720
- this.emit("beforeSetSubmission", submission);
721
- this.setValue(submission, flags);
732
+ this.onSetSubmission(submission, flags);
722
733
  return this.submissionReadyResolve(submission);
723
734
  }, (err) => this.submissionReadyReject(err))
724
735
  .catch((err) => this.submissionReadyReject(err)));
@@ -877,7 +888,9 @@ export default class Webform extends NestedDataComponent {
877
888
  this.addComponents();
878
889
  this.on("submitButton", (options) => {
879
890
  this.submit(false, options).catch((e) => {
880
- options.instance.loading = false;
891
+ if (options?.instance) {
892
+ options.instance.loading = false;
893
+ }
881
894
  return e !== false && e !== undefined && console.log(e);
882
895
  });
883
896
  }, true);
@@ -343,6 +343,12 @@ declare class Component extends Element {
343
343
  * @param {string} template - The template to use for the modal dialog.
344
344
  */
345
345
  setOpenModalElement(template?: string): void;
346
+ /**
347
+ * Renders a modal preview template and returns the markup as a string
348
+ * @param {object|null|undefined} ctx - The rendering context
349
+ * @returns {string} - The modal preview markup
350
+ */
351
+ renderModalPreview(ctx: object | null | undefined): string;
346
352
  /**
347
353
  * Returns the modal preview template.
348
354
  * @returns {string} - The modal preview template.
@@ -362,6 +368,13 @@ declare class Component extends Element {
362
368
  * @returns {string} - The rendered HTML string of a component.
363
369
  */
364
370
  render(children?: string, topLevel?: boolean): string;
371
+ /**
372
+ * Creates the tooltip instance using tippy.js and returns it
373
+ * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
374
+ * @param {object|null|undefined} settings - tippy.js options
375
+ * @returns {import('tippy.js').Tippy} - tippy.js instance
376
+ */
377
+ createTooltip(tooltipEl: HTMLElement, settings?: object | null | undefined): import('tippy.js').Tippy;
365
378
  /**
366
379
  * Attaches all the tooltips provided the refs object.
367
380
  * @param {object} toolTipsRefs - The refs for the tooltips within your template.
@@ -1013,6 +1013,14 @@ export default class Component extends Element {
1013
1013
  setOpenModalElement(template = null) {
1014
1014
  this.componentModal.setOpenModalElement(template || this.getModalPreviewTemplate());
1015
1015
  }
1016
+ /**
1017
+ * Renders a modal preview template and returns the markup as a string
1018
+ * @param {object|null|undefined} ctx - The rendering context
1019
+ * @returns {string} - The modal preview markup
1020
+ */
1021
+ renderModalPreview(ctx) {
1022
+ return this.renderTemplate('modalPreview', ctx || {});
1023
+ }
1016
1024
  /**
1017
1025
  * Returns the modal preview template.
1018
1026
  * @returns {string} - The modal preview template.
@@ -1023,7 +1031,7 @@ export default class Component extends Element {
1023
1031
  if (this.hasInput && this.component.validate?.required && !this.isPDFReadOnlyMode) {
1024
1032
  modalLabel = { className: 'field-required' };
1025
1033
  }
1026
- return this.renderTemplate('modalPreview', {
1034
+ return this.renderModalPreview({
1027
1035
  previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('Click to set value'),
1028
1036
  messages: '',
1029
1037
  labelInfo: modalLabel,
@@ -1072,6 +1080,27 @@ export default class Component extends Element {
1072
1080
  }, topLevel);
1073
1081
  }
1074
1082
  }
1083
+ /**
1084
+ * Creates the tooltip instance using tippy.js and returns it
1085
+ * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
1086
+ * @param {object|null|undefined} settings - tippy.js options
1087
+ * @returns {import('tippy.js').Tippy} - tippy.js instance
1088
+ */
1089
+ createTooltip(tooltipEl, settings = {}) {
1090
+ const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
1091
+ const tooltipDataTitle = tooltipEl.getAttribute('data-title');
1092
+ const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1093
+ .replace(/(?:\r\n|\r|\n)/g, '<br />');
1094
+ return tippy(tooltipEl, {
1095
+ allowHTML: true,
1096
+ trigger: 'mouseenter click focus',
1097
+ placement: 'right',
1098
+ zIndex: 10000,
1099
+ interactive: true,
1100
+ ...settings,
1101
+ content: this.t(this.sanitize(tooltipText), { _userInput: true }),
1102
+ });
1103
+ }
1075
1104
  /**
1076
1105
  * Attaches all the tooltips provided the refs object.
1077
1106
  * @param {object} toolTipsRefs - The refs for the tooltips within your template.
@@ -1080,18 +1109,7 @@ export default class Component extends Element {
1080
1109
  attachTooltips(toolTipsRefs) {
1081
1110
  toolTipsRefs?.forEach((tooltip, index) => {
1082
1111
  if (tooltip) {
1083
- const tooltipAttribute = tooltip.getAttribute('data-tooltip');
1084
- const tooltipDataTitle = tooltip.getAttribute('data-title');
1085
- const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1086
- .replace(/(?:\r\n|\r|\n)/g, '<br />');
1087
- this.tooltips[index] = tippy(tooltip, {
1088
- allowHTML: true,
1089
- trigger: 'mouseenter click focus',
1090
- placement: 'right',
1091
- zIndex: 10000,
1092
- interactive: true,
1093
- content: this.t(this.sanitize(tooltipText), { _userInput: true }),
1094
- });
1112
+ this.tooltips[index] = this.createTooltip(tooltip);
1095
1113
  }
1096
1114
  });
1097
1115
  }
@@ -3343,6 +3361,10 @@ export default class Component extends Element {
3343
3361
  const disabled = this.shouldDisabled;
3344
3362
  // Change states which won't be recalculated during redrawing
3345
3363
  if (this.visible !== visible) {
3364
+ // If the logic is triggered by an event and the action sets the hidden state then the original
3365
+ // component definition must be changed so that the components hidden state does not get flipped back by
3366
+ // the fieldLogic function
3367
+ this.originalComponent.hidden = !visible;
3346
3368
  this.visible = visible;
3347
3369
  }
3348
3370
  if (this.disabled !== disabled) {
@@ -187,5 +187,13 @@ export default [
187
187
  key: 'tableView',
188
188
  input: true
189
189
  },
190
+ {
191
+ weight: 1600,
192
+ type: 'checkbox',
193
+ label: 'Modal Edit',
194
+ tooltip: 'Opens up a modal to edit the value of this component.',
195
+ key: 'modalEdit',
196
+ input: true
197
+ }
190
198
  ];
191
199
  /* eslint-enable max-len */
@@ -0,0 +1,84 @@
1
+ declare namespace _default {
2
+ let components: ({
3
+ label: string;
4
+ action: string;
5
+ showValidations: boolean;
6
+ tableView: boolean;
7
+ key: string;
8
+ type: string;
9
+ event: string;
10
+ input: boolean;
11
+ theme?: undefined;
12
+ collapsible?: undefined;
13
+ hidden?: undefined;
14
+ logic?: undefined;
15
+ collapsed?: undefined;
16
+ components?: undefined;
17
+ applyMaskOn?: undefined;
18
+ } | {
19
+ label: string;
20
+ action: string;
21
+ showValidations: boolean;
22
+ theme: string;
23
+ tableView: boolean;
24
+ key: string;
25
+ type: string;
26
+ event: string;
27
+ input: boolean;
28
+ collapsible?: undefined;
29
+ hidden?: undefined;
30
+ logic?: undefined;
31
+ collapsed?: undefined;
32
+ components?: undefined;
33
+ applyMaskOn?: undefined;
34
+ } | {
35
+ collapsible: boolean;
36
+ hidden: boolean;
37
+ key: string;
38
+ logic: {
39
+ name: string;
40
+ trigger: {
41
+ type: string;
42
+ event: string;
43
+ };
44
+ actions: {
45
+ name: string;
46
+ type: string;
47
+ property: {
48
+ label: string;
49
+ value: string;
50
+ type: string;
51
+ };
52
+ state: boolean;
53
+ }[];
54
+ }[];
55
+ type: string;
56
+ label: string;
57
+ collapsed: boolean;
58
+ input: boolean;
59
+ tableView: boolean;
60
+ components: never[];
61
+ action?: undefined;
62
+ showValidations?: undefined;
63
+ event?: undefined;
64
+ theme?: undefined;
65
+ applyMaskOn?: undefined;
66
+ } | {
67
+ label: string;
68
+ applyMaskOn: string;
69
+ tableView: boolean;
70
+ key: string;
71
+ type: string;
72
+ input: boolean;
73
+ action?: undefined;
74
+ showValidations?: undefined;
75
+ event?: undefined;
76
+ theme?: undefined;
77
+ collapsible?: undefined;
78
+ hidden?: undefined;
79
+ logic?: undefined;
80
+ collapsed?: undefined;
81
+ components?: undefined;
82
+ })[];
83
+ }
84
+ export default _default;
@@ -0,0 +1,84 @@
1
+ export default {
2
+ components: [
3
+ {
4
+ "label": "Show",
5
+ "action": "event",
6
+ "showValidations": false,
7
+ "tableView": false,
8
+ "key": "show",
9
+ "type": "button",
10
+ "event": "show",
11
+ "input": true
12
+ },
13
+ {
14
+ "label": "Hide",
15
+ "action": "event",
16
+ "showValidations": false,
17
+ "theme": "danger",
18
+ "tableView": false,
19
+ "key": "hide",
20
+ "type": "button",
21
+ "event": "hide",
22
+ "input": true
23
+ },
24
+ {
25
+ "collapsible": true,
26
+ "hidden": true,
27
+ "key": "panel",
28
+ "logic": [
29
+ {
30
+ "name": "ShowPanel",
31
+ "trigger": {
32
+ "type": "event",
33
+ "event": "show"
34
+ },
35
+ "actions": [
36
+ {
37
+ "name": "Show",
38
+ "type": "property",
39
+ "property": {
40
+ "label": "Hidden",
41
+ "value": "hidden",
42
+ "type": "boolean"
43
+ },
44
+ "state": false
45
+ }
46
+ ]
47
+ },
48
+ {
49
+ "name": "HidePanel",
50
+ "trigger": {
51
+ "type": "event",
52
+ "event": "hide"
53
+ },
54
+ "actions": [
55
+ {
56
+ "name": "Hide",
57
+ "type": "property",
58
+ "property": {
59
+ "label": "Hidden",
60
+ "value": "hidden",
61
+ "type": "boolean"
62
+ },
63
+ "state": true
64
+ }
65
+ ]
66
+ }
67
+ ],
68
+ "type": "panel",
69
+ "label": "Panel",
70
+ "collapsed": false,
71
+ "input": false,
72
+ "tableView": false,
73
+ "components": []
74
+ },
75
+ {
76
+ "label": "Text Field",
77
+ "applyMaskOn": "change",
78
+ "tableView": true,
79
+ "key": "textField1",
80
+ "type": "textfield",
81
+ "input": true
82
+ }
83
+ ]
84
+ };
@@ -4,4 +4,5 @@ import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
- export { comp1, comp2, comp3, comp4, comp5, comp6 };
7
+ import comp7 from './comp7';
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
@@ -4,4 +4,5 @@ import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
- export { comp1, comp2, comp3, comp4, comp5, comp6 };
7
+ import comp7 from './comp7';
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };