@formio/js 5.0.0-dev.5686.783670c → 5.0.0-dev.5687.925e544

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 (52) hide show
  1. package/Changelog.md +13 -1
  2. package/dist/formio.form.js +7 -7
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.full.js +7 -7
  5. package/dist/formio.full.min.js +1 -1
  6. package/dist/formio.js +1 -1
  7. package/dist/formio.min.js +1 -1
  8. package/lib/cjs/Webform.js +4 -0
  9. package/lib/cjs/components/_classes/component/Component.js +4 -0
  10. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
  11. package/lib/cjs/components/_classes/component/fixtures/comp7.d.ts +84 -0
  12. package/lib/cjs/components/_classes/component/fixtures/comp7.js +86 -0
  13. package/lib/cjs/components/_classes/component/fixtures/index.d.ts +2 -1
  14. package/lib/cjs/components/_classes/component/fixtures/index.js +3 -1
  15. package/lib/cjs/components/datagrid/DataGrid.d.ts +9 -0
  16. package/lib/cjs/components/datagrid/DataGrid.js +50 -32
  17. package/lib/cjs/components/datagrid/fixtures/comp-with-reorder.d.ts +100 -0
  18. package/lib/cjs/components/datagrid/fixtures/comp-with-reorder.js +139 -0
  19. package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
  20. package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
  21. package/lib/cjs/components/day/fixtures/comp8.d.ts +41 -0
  22. package/lib/cjs/components/day/fixtures/comp8.js +40 -0
  23. package/lib/cjs/components/day/fixtures/index.d.ts +2 -1
  24. package/lib/cjs/components/day/fixtures/index.js +3 -1
  25. package/lib/cjs/components/editgrid/EditGrid.js +2 -2
  26. package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
  27. package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
  28. package/lib/cjs/translations/en.d.ts +3 -0
  29. package/lib/cjs/translations/en.js +4 -1
  30. package/lib/mjs/Webform.js +4 -0
  31. package/lib/mjs/components/_classes/component/Component.js +4 -0
  32. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
  33. package/lib/mjs/components/_classes/component/fixtures/comp7.d.ts +84 -0
  34. package/lib/mjs/components/_classes/component/fixtures/comp7.js +84 -0
  35. package/lib/mjs/components/_classes/component/fixtures/index.d.ts +2 -1
  36. package/lib/mjs/components/_classes/component/fixtures/index.js +2 -1
  37. package/lib/mjs/components/datagrid/DataGrid.d.ts +9 -0
  38. package/lib/mjs/components/datagrid/DataGrid.js +50 -32
  39. package/lib/mjs/components/datagrid/fixtures/comp-with-reorder.d.ts +100 -0
  40. package/lib/mjs/components/datagrid/fixtures/comp-with-reorder.js +137 -0
  41. package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
  42. package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
  43. package/lib/mjs/components/day/fixtures/comp8.d.ts +41 -0
  44. package/lib/mjs/components/day/fixtures/comp8.js +38 -0
  45. package/lib/mjs/components/day/fixtures/index.d.ts +2 -1
  46. package/lib/mjs/components/day/fixtures/index.js +2 -1
  47. package/lib/mjs/components/editgrid/EditGrid.js +2 -2
  48. package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
  49. package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
  50. package/lib/mjs/translations/en.d.ts +3 -0
  51. package/lib/mjs/translations/en.js +4 -1
  52. package/package.json +1 -1
@@ -0,0 +1,137 @@
1
+ const form = {
2
+ _id: '66742f4146717b98a9fa280f',
3
+ title: 'test reorder',
4
+ name: 'testReorder',
5
+ path: 'testreorder',
6
+ type: 'form',
7
+ display: 'form',
8
+ components: [
9
+ {
10
+ label: 'Data Grid',
11
+ reorder: true,
12
+ addAnotherPosition: 'bottom',
13
+ layoutFixed: false,
14
+ enableRowGroups: false,
15
+ initEmpty: false,
16
+ tableView: false,
17
+ defaultValue: [
18
+ {
19
+ select: '',
20
+ },
21
+ ],
22
+ key: 'dataGrid',
23
+ type: 'datagrid',
24
+ input: true,
25
+ components: [
26
+ {
27
+ label: 'Select',
28
+ widget: 'choicesjs',
29
+ tableView: true,
30
+ dataSrc: 'resource',
31
+ data: {
32
+ resource: '66742ee946717b98a9fa1b0b',
33
+ },
34
+ dataType: 'string',
35
+ valueProperty: 'data.textField',
36
+ template: '<span>{{ item.data.number }}</span>',
37
+ validate: {
38
+ select: false,
39
+ },
40
+ key: 'select',
41
+ type: 'select',
42
+ searchField: 'data.textField__regex',
43
+ limit: 10,
44
+ noRefreshOnScroll: false,
45
+ addResource: false,
46
+ reference: false,
47
+ input: true,
48
+ },
49
+ ],
50
+ },
51
+ {
52
+ type: 'button',
53
+ label: 'Submit',
54
+ key: 'submit',
55
+ disableOnInvalid: true,
56
+ input: true,
57
+ tableView: false,
58
+ },
59
+ ],
60
+ created: '2024-06-20T13:31:45.177Z',
61
+ modified: '2024-06-25T10:32:46.577Z',
62
+ machineName: 'tifwklexhyrgxbr:testReorder',
63
+ };
64
+ const submission = {
65
+ form: '66742f4146717b98a9fa280f',
66
+ metadata: {
67
+ selectData: {
68
+ dataGrid: [
69
+ {
70
+ select: {
71
+ data: {
72
+ number: 1,
73
+ },
74
+ },
75
+ },
76
+ {
77
+ select: {
78
+ data: {
79
+ number: 2,
80
+ },
81
+ },
82
+ },
83
+ {
84
+ select: {
85
+ data: {
86
+ number: 3,
87
+ },
88
+ },
89
+ },
90
+ {
91
+ select: {
92
+ data: {
93
+ number: 4,
94
+ },
95
+ },
96
+ },
97
+ {
98
+ select: {
99
+ data: {
100
+ number: 5,
101
+ },
102
+ },
103
+ },
104
+ ],
105
+ },
106
+ },
107
+ data: {
108
+ dataGrid: [
109
+ {
110
+ select: '11',
111
+ },
112
+ {
113
+ select: '22',
114
+ },
115
+ {
116
+ select: '33',
117
+ },
118
+ {
119
+ select: '44',
120
+ },
121
+ {
122
+ select: '55',
123
+ },
124
+ ],
125
+ dataTable: [],
126
+ submit: true,
127
+ },
128
+ _id: '667ab5ee6a69739703d30def',
129
+ project: '65df46bc93bcfaa231f3db1c',
130
+ state: 'submitted',
131
+ created: '2024-06-25T12:19:58.626Z',
132
+ modified: '2024-06-25T12:19:58.627Z',
133
+ };
134
+ export default {
135
+ form,
136
+ submission,
137
+ };
@@ -16,4 +16,5 @@ import modalWithRequiredFields from './comp-modal-with-required-fields';
16
16
  import withAllowCalculateOverride from './comp-with-allow-calculate-override';
17
17
  import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
18
18
  import withCheckboxes from './comp-with-checkboxes';
19
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
19
+ import withReorder from './comp-with-reorder';
20
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes, withReorder };
@@ -16,4 +16,5 @@ import withCollapsibleRowGroups from './comp-with-collapsible-groups';
16
16
  import withAllowCalculateOverride from './comp-with-allow-calculate-override';
17
17
  import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
18
18
  import withCheckboxes from './comp-with-checkboxes';
19
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
19
+ import withReorder from './comp-with-reorder';
20
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes, withReorder };
@@ -0,0 +1,41 @@
1
+ declare namespace _default {
2
+ let components: ({
3
+ label: string;
4
+ hideInputLabels: boolean;
5
+ inputsLabelPosition: string;
6
+ useLocaleSettings: boolean;
7
+ alwaysEnabled: boolean;
8
+ tableView: boolean;
9
+ fields: {
10
+ day: {
11
+ hide: boolean;
12
+ required: boolean;
13
+ };
14
+ month: {
15
+ hide: boolean;
16
+ required: boolean;
17
+ };
18
+ year: {
19
+ hide: boolean;
20
+ required: boolean;
21
+ };
22
+ };
23
+ key: string;
24
+ type: string;
25
+ input: boolean;
26
+ showValidations?: undefined;
27
+ } | {
28
+ label: string;
29
+ showValidations: boolean;
30
+ alwaysEnabled: boolean;
31
+ tableView: boolean;
32
+ key: string;
33
+ type: string;
34
+ input: boolean;
35
+ hideInputLabels?: undefined;
36
+ inputsLabelPosition?: undefined;
37
+ useLocaleSettings?: undefined;
38
+ fields?: undefined;
39
+ })[];
40
+ }
41
+ export default _default;
@@ -0,0 +1,38 @@
1
+ export default {
2
+ "components": [
3
+ {
4
+ "label": "Day - Table",
5
+ "hideInputLabels": false,
6
+ "inputsLabelPosition": "top",
7
+ "useLocaleSettings": false,
8
+ "alwaysEnabled": false,
9
+ "tableView": false,
10
+ "fields": {
11
+ "day": {
12
+ "hide": false,
13
+ "required": true
14
+ },
15
+ "month": {
16
+ "hide": false,
17
+ "required": true
18
+ },
19
+ "year": {
20
+ "hide": false,
21
+ "required": true
22
+ }
23
+ },
24
+ "key": "dayTable",
25
+ "type": "day",
26
+ "input": true
27
+ },
28
+ {
29
+ "label": "Submit",
30
+ "showValidations": false,
31
+ "alwaysEnabled": false,
32
+ "tableView": false,
33
+ "key": "submit",
34
+ "type": "button",
35
+ "input": true
36
+ }
37
+ ]
38
+ };
@@ -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 };
@@ -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 };
@@ -83,7 +83,7 @@ export default class EditGridComponent extends NestedArrayComponent {
83
83
  {% if (!instance.options.readOnly && !instance.disabled) { %}
84
84
  <div class="col-sm-2">
85
85
  <div class="btn-group pull-right">
86
- <button class="btn btn-default btn-light btn-sm editRow"><i class="{{ iconClass('pen-fill') }}"></i></button>
86
+ <button class="btn btn-default btn-light btn-sm editRow"><i class="{{ iconClass('edit') }}"></i></button>
87
87
  {% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}
88
88
  <button class="btn btn-danger btn-sm removeRow"><i class="{{ iconClass('trash') }}"></i></button>
89
89
  {% } %}
@@ -104,7 +104,7 @@ export default class EditGridComponent extends NestedArrayComponent {
104
104
  {% if (!instance.options.readOnly && !instance.disabled) { %}
105
105
  <td class="editgrid-table-column">
106
106
  <div class="btn-group">
107
- <button class="btn btn-default btn-light btn-sm editRow" aria-label="{{ t('Edit row') }}"><i class="{{ iconClass('pen-fill') }}"></i></button>
107
+ <button class="btn btn-default btn-light btn-sm editRow" aria-label="{{ t('Edit row') }}"><i class="{{ iconClass('edit') }}"></i></button>
108
108
  {% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}
109
109
  <button class="btn btn-danger btn-sm removeRow" aria-label="{{ t('Remove row') }}"><i class="{{ iconClass('trash') }}"></i></button>
110
110
  {% } %}
@@ -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
  /**
@@ -2,6 +2,9 @@
2
2
  import { Formio } from '../../Formio';
3
3
  import _ from 'lodash';
4
4
  import { AddressProvider } from './AddressProvider';
5
+ const GOOGLE_MAPS_BASE_URL = 'https://maps.googleapis.com';
6
+ const GOOGLE_MAPS_JS_URL = `${GOOGLE_MAPS_BASE_URL}/maps/api/js`;
7
+ const GOOGLE_MAPS_JS_WITH_PARAMS_URL = `${GOOGLE_MAPS_JS_URL}?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback`;
5
8
  /**
6
9
  * @typedef {object} AutocompleteOptions
7
10
  * @property {string[]} fields - The fields to include in the autocomplete response.
@@ -48,10 +51,11 @@ export class GoogleAddressProvider extends AddressProvider {
48
51
  constructor(options = {}) {
49
52
  super(options);
50
53
  this.setAutocompleteOptions();
51
- let src = 'https://maps.googleapis.com/maps/api/js?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback';
54
+ let src = GOOGLE_MAPS_JS_WITH_PARAMS_URL;
52
55
  if (options.params?.key) {
53
56
  src += `&key=${options.params.key}`;
54
57
  }
58
+ this.tryRemoveLibrary(options);
55
59
  Formio.requireLibrary(this.getLibraryName(), 'google.maps.places', src);
56
60
  }
57
61
  /**
@@ -178,4 +182,21 @@ export class GoogleAddressProvider extends AddressProvider {
178
182
  : this.alternativeDisplayValueProperty;
179
183
  return _.get(address, displayedProperty, '');
180
184
  }
185
+ /**
186
+ * Tries to remove the library if api key for loaded script is different.
187
+ * @param {ProviderOptions} options - The options for the provider.
188
+ */
189
+ tryRemoveLibrary(options = {}) {
190
+ if (!Formio.libraries[this.getLibraryName()]) {
191
+ return;
192
+ }
193
+ const existingScript = document.querySelector(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
194
+ if (existingScript && options.params?.key && !existingScript.attributes.src.value.endsWith(options.params.key)) {
195
+ const googleMapsScripts = document.querySelectorAll(`script[src^="${GOOGLE_MAPS_BASE_URL}"]`) ?? [];
196
+ googleMapsScripts.forEach(script => script.parentNode.removeChild(script));
197
+ delete Formio.libraries[this.getLibraryName()];
198
+ delete global?.google?.maps;
199
+ delete global[`${this.getLibraryName()}Callback`];
200
+ }
201
+ }
181
202
  }
@@ -74,5 +74,8 @@ declare namespace _default {
74
74
  let apiKey: string;
75
75
  let typeRemaining: string;
76
76
  let typeCount: string;
77
+ let requiredDayField: string;
78
+ let requiredMonthField: string;
79
+ let requiredYearField: string;
77
80
  }
78
81
  export default _default;
@@ -73,5 +73,8 @@ export default {
73
73
  reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission',
74
74
  apiKey: 'API Key is not unique: {{key}}',
75
75
  typeRemaining: '{{ remaining }} {{ type }} remaining.',
76
- typeCount: '{{ count }} {{ type }}'
76
+ typeCount: '{{ count }} {{ type }}',
77
+ requiredDayField: '{{ field }} is required',
78
+ requiredMonthField: '{{ field }} is required',
79
+ requiredYearField: '{{ field }} is required'
77
80
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5686.783670c",
3
+ "version": "5.0.0-dev.5687.925e544",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {