@formio/js 5.0.0-rc.20 → 5.0.0-rc.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. package/dist/formio.embed.css +1 -39
  2. package/dist/formio.embed.js +2 -90
  3. package/dist/formio.embed.min.js +1 -1
  4. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  5. package/dist/formio.form.js +58 -36
  6. package/dist/formio.form.min.js +1 -1
  7. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  8. package/dist/formio.full.js +59 -37
  9. package/dist/formio.full.min.js +1 -1
  10. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  11. package/dist/formio.js +2 -2
  12. package/dist/formio.min.js +1 -1
  13. package/dist/formio.min.js.LICENSE.txt +1 -1
  14. package/dist/formio.utils.js +1 -1
  15. package/dist/formio.utils.min.js +1 -1
  16. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  17. package/lib/cjs/CDN.d.ts +1 -0
  18. package/lib/cjs/CDN.js +1 -0
  19. package/lib/cjs/Element.js +5 -0
  20. package/lib/cjs/Embed.d.ts +21 -1
  21. package/lib/cjs/Embed.js +211 -308
  22. package/lib/cjs/Form.d.ts +1 -1
  23. package/lib/cjs/Form.js +1 -1
  24. package/lib/cjs/Webform.d.ts +6 -6
  25. package/lib/cjs/Webform.js +6 -6
  26. package/lib/cjs/WebformBuilder.js +1 -1
  27. package/lib/cjs/components/_classes/component/Component.d.ts +16 -6
  28. package/lib/cjs/components/_classes/component/Component.js +26 -6
  29. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +1 -0
  30. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +4 -0
  31. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
  32. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +4 -0
  33. package/lib/cjs/components/address/Address.js +5 -0
  34. package/lib/cjs/components/button/Button.d.ts +1 -0
  35. package/lib/cjs/components/button/Button.js +3 -0
  36. package/lib/cjs/components/checkbox/Checkbox.d.ts +28 -0
  37. package/lib/cjs/components/checkbox/Checkbox.js +17 -2
  38. package/lib/cjs/components/columns/Columns.d.ts +1 -0
  39. package/lib/cjs/components/columns/Columns.js +3 -0
  40. package/lib/cjs/components/container/Container.js +3 -0
  41. package/lib/cjs/components/content/Content.d.ts +1 -0
  42. package/lib/cjs/components/content/Content.js +3 -0
  43. package/lib/cjs/components/datamap/DataMap.d.ts +1 -0
  44. package/lib/cjs/components/datamap/DataMap.js +3 -0
  45. package/lib/cjs/components/datetime/DateTime.d.ts +19 -0
  46. package/lib/cjs/components/datetime/DateTime.js +9 -10
  47. package/lib/cjs/components/day/Day.d.ts +21 -0
  48. package/lib/cjs/components/day/Day.js +12 -10
  49. package/lib/cjs/components/day/fixtures/comp5.d.ts +29 -0
  50. package/lib/cjs/components/day/fixtures/comp5.js +32 -0
  51. package/lib/cjs/components/day/fixtures/index.d.ts +2 -1
  52. package/lib/cjs/components/day/fixtures/index.js +3 -1
  53. package/lib/cjs/components/fieldset/Fieldset.d.ts +1 -0
  54. package/lib/cjs/components/fieldset/Fieldset.js +3 -0
  55. package/lib/cjs/components/file/File.d.ts +21 -1
  56. package/lib/cjs/components/file/File.js +15 -7
  57. package/lib/cjs/components/form/Form.d.ts +1 -0
  58. package/lib/cjs/components/form/Form.js +5 -1
  59. package/lib/cjs/components/html/HTML.d.ts +1 -0
  60. package/lib/cjs/components/html/HTML.js +3 -0
  61. package/lib/cjs/components/number/Number.d.ts +20 -1
  62. package/lib/cjs/components/number/Number.js +10 -15
  63. package/lib/cjs/components/panel/Panel.d.ts +1 -0
  64. package/lib/cjs/components/panel/Panel.js +3 -0
  65. package/lib/cjs/components/radio/Radio.d.ts +19 -0
  66. package/lib/cjs/components/radio/Radio.js +30 -0
  67. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -0
  68. package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -0
  69. package/lib/cjs/components/select/Select.d.ts +19 -1
  70. package/lib/cjs/components/select/Select.js +39 -4
  71. package/lib/cjs/components/select/fixtures/comp19.d.ts +23 -0
  72. package/lib/cjs/components/select/fixtures/comp19.js +36 -0
  73. package/lib/cjs/components/select/fixtures/index.d.ts +2 -1
  74. package/lib/cjs/components/select/fixtures/index.js +3 -1
  75. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +26 -1
  76. package/lib/cjs/components/selectboxes/SelectBoxes.js +8 -1
  77. package/lib/cjs/components/signature/Signature.d.ts +21 -0
  78. package/lib/cjs/components/signature/Signature.js +9 -1
  79. package/lib/cjs/components/survey/Survey.d.ts +21 -0
  80. package/lib/cjs/components/survey/Survey.js +7 -1
  81. package/lib/cjs/components/table/Table.d.ts +1 -0
  82. package/lib/cjs/components/table/Table.js +3 -0
  83. package/lib/cjs/components/tabs/Tabs.d.ts +1 -0
  84. package/lib/cjs/components/tabs/Tabs.js +3 -0
  85. package/lib/cjs/components/tags/Tags.d.ts +21 -0
  86. package/lib/cjs/components/tags/Tags.js +11 -1
  87. package/lib/cjs/components/tags/fixtures/comp6.d.ts +17 -0
  88. package/lib/cjs/components/tags/fixtures/comp6.js +20 -0
  89. package/lib/cjs/components/tags/fixtures/index.d.ts +2 -1
  90. package/lib/cjs/components/tags/fixtures/index.js +3 -1
  91. package/lib/cjs/components/textfield/TextField.d.ts +21 -0
  92. package/lib/cjs/components/textfield/TextField.js +7 -1
  93. package/lib/cjs/components/time/Time.d.ts +8 -1
  94. package/lib/cjs/components/well/Well.d.ts +1 -0
  95. package/lib/cjs/components/well/Well.js +3 -0
  96. package/lib/cjs/formio.embed.d.ts +2 -1
  97. package/lib/cjs/formio.embed.js +96 -1
  98. package/lib/cjs/formio.form.d.ts +4 -3
  99. package/lib/cjs/formio.form.js +17 -8
  100. package/lib/cjs/licenses/Licenses.d.ts +7 -0
  101. package/lib/cjs/licenses/Licenses.js +22 -0
  102. package/lib/cjs/licenses/index.d.ts +2 -0
  103. package/lib/cjs/licenses/index.js +7 -0
  104. package/lib/cjs/utils/utils.d.ts +10 -0
  105. package/lib/cjs/utils/utils.js +21 -1
  106. package/lib/mjs/CDN.d.ts +1 -0
  107. package/lib/mjs/CDN.js +1 -0
  108. package/lib/mjs/Element.js +5 -0
  109. package/lib/mjs/Embed.d.ts +21 -1
  110. package/lib/mjs/Embed.js +208 -322
  111. package/lib/mjs/Form.d.ts +1 -1
  112. package/lib/mjs/Form.js +1 -1
  113. package/lib/mjs/Webform.d.ts +6 -6
  114. package/lib/mjs/Webform.js +6 -6
  115. package/lib/mjs/WebformBuilder.js +1 -1
  116. package/lib/mjs/components/_classes/component/Component.d.ts +16 -6
  117. package/lib/mjs/components/_classes/component/Component.js +26 -6
  118. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +1 -0
  119. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +4 -0
  120. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
  121. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +4 -0
  122. package/lib/mjs/components/address/Address.js +5 -0
  123. package/lib/mjs/components/button/Button.d.ts +1 -0
  124. package/lib/mjs/components/button/Button.js +4 -1
  125. package/lib/mjs/components/checkbox/Checkbox.d.ts +28 -0
  126. package/lib/mjs/components/checkbox/Checkbox.js +18 -3
  127. package/lib/mjs/components/columns/Columns.d.ts +1 -0
  128. package/lib/mjs/components/columns/Columns.js +3 -0
  129. package/lib/mjs/components/container/Container.js +4 -1
  130. package/lib/mjs/components/content/Content.d.ts +1 -0
  131. package/lib/mjs/components/content/Content.js +3 -0
  132. package/lib/mjs/components/datamap/DataMap.d.ts +1 -0
  133. package/lib/mjs/components/datamap/DataMap.js +4 -1
  134. package/lib/mjs/components/datetime/DateTime.d.ts +19 -0
  135. package/lib/mjs/components/datetime/DateTime.js +11 -12
  136. package/lib/mjs/components/day/Day.d.ts +21 -0
  137. package/lib/mjs/components/day/Day.js +16 -14
  138. package/lib/mjs/components/day/fixtures/comp5.d.ts +29 -0
  139. package/lib/mjs/components/day/fixtures/comp5.js +30 -0
  140. package/lib/mjs/components/day/fixtures/index.d.ts +2 -1
  141. package/lib/mjs/components/day/fixtures/index.js +2 -1
  142. package/lib/mjs/components/fieldset/Fieldset.d.ts +1 -0
  143. package/lib/mjs/components/fieldset/Fieldset.js +3 -0
  144. package/lib/mjs/components/file/File.d.ts +21 -1
  145. package/lib/mjs/components/file/File.js +16 -8
  146. package/lib/mjs/components/form/Form.d.ts +1 -0
  147. package/lib/mjs/components/form/Form.js +6 -2
  148. package/lib/mjs/components/html/HTML.d.ts +1 -0
  149. package/lib/mjs/components/html/HTML.js +3 -0
  150. package/lib/mjs/components/number/Number.d.ts +20 -1
  151. package/lib/mjs/components/number/Number.js +11 -12
  152. package/lib/mjs/components/panel/Panel.d.ts +1 -0
  153. package/lib/mjs/components/panel/Panel.js +3 -0
  154. package/lib/mjs/components/radio/Radio.d.ts +19 -0
  155. package/lib/mjs/components/radio/Radio.js +34 -1
  156. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -0
  157. package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -0
  158. package/lib/mjs/components/select/Select.d.ts +19 -1
  159. package/lib/mjs/components/select/Select.js +41 -6
  160. package/lib/mjs/components/select/fixtures/comp19.d.ts +23 -0
  161. package/lib/mjs/components/select/fixtures/comp19.js +34 -0
  162. package/lib/mjs/components/select/fixtures/index.d.ts +2 -1
  163. package/lib/mjs/components/select/fixtures/index.js +2 -1
  164. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +26 -1
  165. package/lib/mjs/components/selectboxes/SelectBoxes.js +8 -1
  166. package/lib/mjs/components/signature/Signature.d.ts +21 -0
  167. package/lib/mjs/components/signature/Signature.js +9 -1
  168. package/lib/mjs/components/survey/Survey.d.ts +21 -0
  169. package/lib/mjs/components/survey/Survey.js +8 -2
  170. package/lib/mjs/components/table/Table.d.ts +1 -0
  171. package/lib/mjs/components/table/Table.js +3 -0
  172. package/lib/mjs/components/tabs/Tabs.d.ts +1 -0
  173. package/lib/mjs/components/tabs/Tabs.js +3 -0
  174. package/lib/mjs/components/tags/Tags.d.ts +21 -0
  175. package/lib/mjs/components/tags/Tags.js +12 -2
  176. package/lib/mjs/components/tags/fixtures/comp6.d.ts +17 -0
  177. package/lib/mjs/components/tags/fixtures/comp6.js +18 -0
  178. package/lib/mjs/components/tags/fixtures/index.d.ts +2 -1
  179. package/lib/mjs/components/tags/fixtures/index.js +2 -1
  180. package/lib/mjs/components/textfield/TextField.d.ts +21 -0
  181. package/lib/mjs/components/textfield/TextField.js +8 -2
  182. package/lib/mjs/components/time/Time.d.ts +8 -1
  183. package/lib/mjs/components/well/Well.d.ts +1 -0
  184. package/lib/mjs/components/well/Well.js +3 -0
  185. package/lib/mjs/formio.embed.d.ts +2 -1
  186. package/lib/mjs/formio.embed.js +96 -2
  187. package/lib/mjs/formio.form.d.ts +4 -3
  188. package/lib/mjs/formio.form.js +16 -8
  189. package/lib/mjs/licenses/Licenses.d.ts +7 -0
  190. package/lib/mjs/licenses/Licenses.js +17 -0
  191. package/lib/mjs/licenses/index.d.ts +2 -0
  192. package/lib/mjs/licenses/index.js +2 -0
  193. package/lib/mjs/utils/utils.d.ts +10 -0
  194. package/lib/mjs/utils/utils.js +19 -0
  195. package/package.json +5 -1
  196. package/types/index.d.ts +1 -0
  197. package/types/licenses.d.ts +7 -0
  198. package/types/utils.d.ts +2 -0
@@ -7,6 +7,27 @@ export default class FileComponent extends Field {
7
7
  weight: number;
8
8
  schema: any;
9
9
  };
10
+ static get serverConditionSettings(): {
11
+ operators: string[];
12
+ constructor: Function;
13
+ toString(): string;
14
+ toLocaleString(): string;
15
+ valueOf(): Object;
16
+ hasOwnProperty(v: PropertyKey): boolean;
17
+ isPrototypeOf(v: Object): boolean;
18
+ propertyIsEnumerable(v: PropertyKey): boolean;
19
+ };
20
+ static get conditionOperatorsSettings(): {
21
+ operators: string[];
22
+ constructor: Function;
23
+ toString(): string;
24
+ toLocaleString(): string;
25
+ valueOf(): Object;
26
+ hasOwnProperty(v: PropertyKey): boolean;
27
+ isPrototypeOf(v: Object): boolean;
28
+ propertyIsEnumerable(v: PropertyKey): boolean;
29
+ };
30
+ static savedValueTypes(schema: any): string[];
10
31
  support: {
11
32
  filereader: boolean;
12
33
  formdata: boolean;
@@ -54,7 +75,6 @@ export default class FileComponent extends Field {
54
75
  validateMaxSize(file: any, val: any): boolean;
55
76
  upload(files: any): void;
56
77
  filesUploading: any[] | undefined;
57
- abortUpload: any;
58
78
  getFile(fileInfo: any): any;
59
79
  focus(): void;
60
80
  }
@@ -1,5 +1,5 @@
1
1
  import Field from '../_classes/field/Field';
2
- import { uniqueName } from '../../utils/utils';
2
+ import { componentValueTypes, getComponentSavedTypes, uniqueName } from '../../utils/utils';
3
3
  import download from 'downloadjs';
4
4
  import _ from 'lodash';
5
5
  import fileProcessor from '../../providers/processor/fileProcessor';
@@ -54,11 +54,18 @@ export default class FileComponent extends Field {
54
54
  };
55
55
  }
56
56
  static get serverConditionSettings() {
57
+ return FileComponent.conditionOperatorsSettings;
58
+ }
59
+ static get conditionOperatorsSettings() {
57
60
  return {
58
- ...super.serverConditionSettings,
61
+ ...super.conditionOperatorsSettings,
59
62
  operators: ['isEmpty', 'isNotEmpty'],
60
63
  };
61
64
  }
65
+ static savedValueTypes(schema) {
66
+ schema = schema || {};
67
+ return getComponentSavedTypes(schema) || [componentValueTypes.object];
68
+ }
62
69
  init() {
63
70
  super.init();
64
71
  webViewCamera = navigator.camera || Camera;
@@ -353,8 +360,10 @@ export default class FileComponent extends Field {
353
360
  this.refs.fileStatusRemove.forEach((fileStatusRemove, index) => {
354
361
  this.addEventListener(fileStatusRemove, 'click', (event) => {
355
362
  event.preventDefault();
356
- if (this.abortUpload) {
357
- this.abortUpload();
363
+ const fileUpload = this.statuses[index];
364
+ _.pull(this.filesUploading, fileUpload.originalName);
365
+ if (fileUpload.abort) {
366
+ fileUpload.abort();
358
367
  }
359
368
  this.statuses.splice(index, 1);
360
369
  this.redraw();
@@ -560,6 +569,7 @@ export default class FileComponent extends Field {
560
569
  const fileName = uniqueName(file.name, this.component.fileNameTemplate, this.evalContext());
561
570
  const escapedFileName = file.name ? file.name.replaceAll('<', '&lt;').replaceAll('>', '&gt;') : file.name;
562
571
  const fileUpload = {
572
+ abort: () => null,
563
573
  originalName: escapedFileName,
564
574
  name: fileName,
565
575
  size: file.size,
@@ -678,7 +688,7 @@ export default class FileComponent extends Field {
678
688
  }
679
689
  }
680
690
  }
681
- fileUpload.message = this.t('Starting upload.');
691
+ fileUpload.message = this.t('Starting upload...');
682
692
  this.redraw();
683
693
  const filePromise = fileService.uploadFile(storage, processedFile || file, fileName, dir,
684
694
  // Progress callback
@@ -691,9 +701,7 @@ export default class FileComponent extends Field {
691
701
  // Upload start callback
692
702
  () => {
693
703
  this.emit('fileUploadingStart', filePromise);
694
- },
695
- // Abort upload callback
696
- (abort) => this.abortUpload = abort).then((fileInfo) => {
704
+ }, (abort) => fileUpload.abort = abort).then((fileInfo) => {
697
705
  const index = this.statuses.indexOf(fileUpload);
698
706
  if (index !== -1) {
699
707
  this.statuses.splice(index, 1);
@@ -7,6 +7,7 @@ export default class FormComponent extends Component {
7
7
  weight: number;
8
8
  schema: any;
9
9
  };
10
+ static savedValueTypes(): string[];
10
11
  init(): any;
11
12
  formObj: any;
12
13
  valueChanged: boolean | undefined;
@@ -2,7 +2,7 @@ import _ from 'lodash';
2
2
  import Component from '../_classes/component/Component';
3
3
  import ComponentModal from '../_classes/componentModal/ComponentModal';
4
4
  import EventEmitter from 'eventemitter3';
5
- import { isMongoId, eachComponent, getStringFromComponentPath, getArrayFromComponentPath } from '../../utils/utils';
5
+ import { isMongoId, eachComponent, getStringFromComponentPath, getArrayFromComponentPath, componentValueTypes } from '../../utils/utils';
6
6
  import { Formio } from '../../Formio';
7
7
  import Form from '../../Form';
8
8
  export default class FormComponent extends Component {
@@ -28,6 +28,9 @@ export default class FormComponent extends Component {
28
28
  schema: FormComponent.schema()
29
29
  };
30
30
  }
31
+ static savedValueTypes() {
32
+ return [componentValueTypes.object];
33
+ }
31
34
  init() {
32
35
  super.init();
33
36
  this.formObj = {
@@ -382,7 +385,8 @@ export default class FormComponent extends Component {
382
385
  if (this.builderMode || this.isHidden() || (this.isSubFormLazyLoad() && !fromAttach)) {
383
386
  return Promise.resolve();
384
387
  }
385
- if (this.hasLoadedForm && !this.isRevisionChanged) {
388
+ if (this.hasLoadedForm && !this.isRevisionChanged &&
389
+ !(this.options.pdf && this.useOriginalRevision && _.isNull(this.subForm) && !this.subFormLoading)) {
386
390
  // Pass config down to sub forms.
387
391
  if (this.root && this.root.form && this.root.form.config && !this.formObj.config) {
388
392
  this.formObj.config = this.root.form.config;
@@ -8,6 +8,7 @@ export default class HTMLComponent extends Component {
8
8
  showPreview: boolean;
9
9
  schema: any;
10
10
  };
11
+ static savedValueTypes(): never[];
11
12
  get content(): any;
12
13
  get singleTags(): string[];
13
14
  checkRefreshOn(changed: any): void;
@@ -23,6 +23,9 @@ export default class HTMLComponent extends Component {
23
23
  schema: HTMLComponent.schema()
24
24
  };
25
25
  }
26
+ static savedValueTypes() {
27
+ return [];
28
+ }
26
29
  get defaultSchema() {
27
30
  return HTMLComponent.schema();
28
31
  }
@@ -8,9 +8,28 @@ export default class NumberComponent extends Input {
8
8
  schema: any;
9
9
  };
10
10
  static get serverConditionSettings(): {
11
- operators: string[];
11
+ operators: any[];
12
12
  valueComponent(classComp: any): any;
13
+ constructor: Function;
14
+ toString(): string;
15
+ toLocaleString(): string;
16
+ valueOf(): Object;
17
+ hasOwnProperty(v: PropertyKey): boolean;
18
+ isPrototypeOf(v: Object): boolean;
19
+ propertyIsEnumerable(v: PropertyKey): boolean;
13
20
  };
21
+ static get conditionOperatorsSettings(): {
22
+ operators: any[];
23
+ valueComponent(classComp: any): any;
24
+ constructor: Function;
25
+ toString(): string;
26
+ toLocaleString(): string;
27
+ valueOf(): Object;
28
+ hasOwnProperty(v: PropertyKey): boolean;
29
+ isPrototypeOf(v: Object): boolean;
30
+ propertyIsEnumerable(v: PropertyKey): boolean;
31
+ };
32
+ static savedValueTypes(schema: any): string[];
14
33
  constructor(...args: any[]);
15
34
  validators: string[];
16
35
  delimiter: any;
@@ -1,8 +1,8 @@
1
1
  import { createNumberMask } from '@formio/text-mask-addons';
2
2
  import { conformToMask, maskInput } from '@formio/vanilla-text-mask';
3
3
  import _ from 'lodash';
4
- import { getNumberDecimalLimit, getNumberSeparators } from '../../utils/utils';
5
4
  import Input from '../_classes/input/Input';
5
+ import { getNumberSeparators, getNumberDecimalLimit, componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
6
6
  export default class NumberComponent extends Input {
7
7
  static schema(...extend) {
8
8
  return Input.schema({
@@ -28,22 +28,21 @@ export default class NumberComponent extends Input {
28
28
  };
29
29
  }
30
30
  static get serverConditionSettings() {
31
+ return NumberComponent.conditionOperatorsSettings;
32
+ }
33
+ static get conditionOperatorsSettings() {
31
34
  return {
32
- operators: [
33
- 'isEqual',
34
- 'isNotEqual',
35
- 'isEmpty',
36
- 'isNotEmpty',
37
- 'greaterThan',
38
- 'greaterThanOrEqual',
39
- 'lessThan',
40
- 'lessThanOrEqual',
41
- ],
35
+ ...super.conditionOperatorsSettings,
36
+ operators: [...super.conditionOperatorsSettings.operators, 'lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'],
42
37
  valueComponent(classComp) {
43
38
  return { ...classComp, type: 'number' };
44
- },
39
+ }
45
40
  };
46
41
  }
42
+ static savedValueTypes(schema) {
43
+ schema = schema || {};
44
+ return getComponentSavedTypes(schema) || [componentValueTypes.number];
45
+ }
47
46
  constructor(...args) {
48
47
  super(...args);
49
48
  this.validators = this.validators.concat(['min', 'max']);
@@ -7,6 +7,7 @@ export default class PanelComponent extends NestedComponent {
7
7
  weight: number;
8
8
  schema: any;
9
9
  };
10
+ static savedValueTypes(): never[];
10
11
  constructor(...args: any[]);
11
12
  noField: boolean;
12
13
  getComponent(path: any, fn: any, originalPath: any): Object;
@@ -33,6 +33,9 @@ export default class PanelComponent extends NestedComponent {
33
33
  get templateName() {
34
34
  return 'panel';
35
35
  }
36
+ static savedValueTypes() {
37
+ return [];
38
+ }
36
39
  constructor(...args) {
37
40
  super(...args);
38
41
  this.noField = true;
@@ -7,6 +7,25 @@ export default class RadioComponent extends ListComponent {
7
7
  documentation: string;
8
8
  schema: any;
9
9
  };
10
+ static get conditionOperatorsSettings(): {
11
+ valueComponent(classComp: any): {
12
+ type: string;
13
+ dataSrc: string;
14
+ valueProperty: string;
15
+ dataType: any;
16
+ data: {
17
+ custom(): any;
18
+ };
19
+ };
20
+ constructor: Function;
21
+ toString(): string;
22
+ toLocaleString(): string;
23
+ valueOf(): Object;
24
+ hasOwnProperty(v: PropertyKey): boolean;
25
+ isPrototypeOf(v: Object): boolean;
26
+ propertyIsEnumerable(v: PropertyKey): boolean;
27
+ };
28
+ static savedValueTypes(schema: any): any[];
10
29
  constructor(component: any, options: any, data: any);
11
30
  previousValue: any;
12
31
  get inputInfo(): {
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import ListComponent from '../_classes/list/ListComponent';
3
3
  import { Formio } from '../../Formio';
4
- import { boolValue } from '../../utils/utils';
4
+ import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
5
5
  export default class RadioComponent extends ListComponent {
6
6
  static schema(...extend) {
7
7
  return ListComponent.schema({
@@ -26,6 +26,39 @@ export default class RadioComponent extends ListComponent {
26
26
  schema: RadioComponent.schema()
27
27
  };
28
28
  }
29
+ static get conditionOperatorsSettings() {
30
+ return {
31
+ ...super.conditionOperatorsSettings,
32
+ valueComponent(classComp) {
33
+ return {
34
+ type: 'select',
35
+ dataSrc: 'custom',
36
+ valueProperty: 'value',
37
+ dataType: classComp.dataType || '',
38
+ data: {
39
+ custom() {
40
+ return classComp.values;
41
+ }
42
+ },
43
+ };
44
+ }
45
+ };
46
+ }
47
+ static savedValueTypes(schema) {
48
+ const { boolean, string, number, object, array } = componentValueTypes;
49
+ const { dataType } = schema;
50
+ const types = getComponentSavedTypes(schema);
51
+ if (types) {
52
+ return types;
53
+ }
54
+ if (dataType === 'object') {
55
+ return [object, array];
56
+ }
57
+ if (componentValueTypes[dataType]) {
58
+ return [componentValueTypes[dataType]];
59
+ }
60
+ return [boolean, string, number, object, array];
61
+ }
29
62
  constructor(component, options, data) {
30
63
  super(component, options, data);
31
64
  this.previousValue = this.dataValue || null;
@@ -7,6 +7,7 @@ export default class ReCaptchaComponent extends Component {
7
7
  weight: number;
8
8
  schema: any;
9
9
  };
10
+ static savedValueTypes(): never[];
10
11
  render(): any;
11
12
  recaptchaResult: any;
12
13
  createInput(): void;
@@ -21,6 +21,9 @@ export default class ReCaptchaComponent extends Component {
21
21
  schema: ReCaptchaComponent.schema()
22
22
  };
23
23
  }
24
+ static savedValueTypes() {
25
+ return [];
26
+ }
24
27
  render() {
25
28
  this.recaptchaResult = null;
26
29
  if (this.builderMode) {
@@ -9,8 +9,25 @@ export default class SelectComponent extends ListComponent {
9
9
  };
10
10
  static get serverConditionSettings(): {
11
11
  valueComponent(classComp: any): any;
12
- operators: string[];
12
+ constructor: Function;
13
+ toString(): string;
14
+ toLocaleString(): string;
15
+ valueOf(): Object;
16
+ hasOwnProperty(v: PropertyKey): boolean;
17
+ isPrototypeOf(v: Object): boolean;
18
+ propertyIsEnumerable(v: PropertyKey): boolean;
13
19
  };
20
+ static get conditionOperatorsSettings(): {
21
+ valueComponent(classComp: any): any;
22
+ constructor: Function;
23
+ toString(): string;
24
+ toLocaleString(): string;
25
+ valueOf(): Object;
26
+ hasOwnProperty(v: PropertyKey): boolean;
27
+ isPrototypeOf(v: Object): boolean;
28
+ propertyIsEnumerable(v: PropertyKey): boolean;
29
+ };
30
+ static savedValueTypes(schema: any): any[];
14
31
  templateData: {} | undefined;
15
32
  triggerUpdate: ((...args: any[]) => any) | undefined;
16
33
  set itemsLoaded(arg: any);
@@ -40,6 +57,7 @@ export default class SelectComponent extends ListComponent {
40
57
  get isSelectResource(): boolean;
41
58
  get itemsFromUrl(): boolean;
42
59
  get isInfiniteScrollProvided(): boolean;
60
+ get shouldInitialLoad(): any;
43
61
  isEntireObjectDisplay(): boolean;
44
62
  selectValueAndLabel(data: any): {
45
63
  value: any;
@@ -1,8 +1,9 @@
1
1
  import _ from 'lodash';
2
2
  import { Formio } from '../../Formio';
3
3
  import ListComponent from '../_classes/list/ListComponent';
4
+ import Input from '../_classes/input/Input';
4
5
  import Form from '../../Form';
5
- import { getRandomComponentId, boolValue, isPromise } from '../../utils/utils';
6
+ import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
6
7
  import Choices from '../../utils/ChoicesWrapper';
7
8
  export default class SelectComponent extends ListComponent {
8
9
  static schema(...extend) {
@@ -54,13 +55,34 @@ export default class SelectComponent extends ListComponent {
54
55
  };
55
56
  }
56
57
  static get serverConditionSettings() {
58
+ return SelectComponent.conditionOperatorsSettings;
59
+ }
60
+ static get conditionOperatorsSettings() {
57
61
  return {
58
- ...super.serverConditionSettings,
62
+ ...super.conditionOperatorsSettings,
59
63
  valueComponent(classComp) {
60
64
  return { ...classComp, type: 'select' };
61
- },
65
+ }
62
66
  };
63
67
  }
68
+ static savedValueTypes(schema) {
69
+ const { boolean, string, number, object, array } = componentValueTypes;
70
+ const { dataType, reference } = schema;
71
+ const types = getComponentSavedTypes(schema);
72
+ if (types) {
73
+ return types;
74
+ }
75
+ if (reference) {
76
+ return [object];
77
+ }
78
+ if (dataType === 'object') {
79
+ return [object, array];
80
+ }
81
+ if (componentValueTypes[dataType]) {
82
+ return [componentValueTypes[dataType]];
83
+ }
84
+ return [boolean, string, number, object, array];
85
+ }
64
86
  init() {
65
87
  super.init();
66
88
  this.templateData = {};
@@ -172,6 +194,15 @@ export default class SelectComponent extends ListComponent {
172
194
  get shouldDisabled() {
173
195
  return super.shouldDisabled || this.parentDisabled;
174
196
  }
197
+ get shouldInitialLoad() {
198
+ if (this.component.widget === 'html5' &&
199
+ this.isEntireObjectDisplay() &&
200
+ this.component.searchField &&
201
+ this.dataValue) {
202
+ return false;
203
+ }
204
+ return super.shouldLoad;
205
+ }
175
206
  isEntireObjectDisplay() {
176
207
  return this.component.dataSrc === 'resource' && this.valueProperty === 'data';
177
208
  }
@@ -482,7 +513,11 @@ export default class SelectComponent extends ListComponent {
482
513
  });
483
514
  // Add search capability.
484
515
  if (this.component.searchField && search) {
485
- const searchValue = Array.isArray(search) ? search.join(',') : search;
516
+ const searchValue = Array.isArray(search)
517
+ ? search.join(',')
518
+ : typeof search === 'object'
519
+ ? JSON.stringify(search)
520
+ : search;
486
521
  query[this.component.searchField] = this.component.searchField.endsWith('__regex')
487
522
  ? _.escapeRegExp(searchValue)
488
523
  : searchValue;
@@ -803,7 +838,7 @@ export default class SelectComponent extends ListComponent {
803
838
  this.choices.containerOuter.element.setAttribute('tabIndex', '-1');
804
839
  this.addEventListener(this.choices.containerOuter.element, 'focus', () => this.focusableElement.focus());
805
840
  }
806
- this.addFocusBlurEvents(this.focusableElement);
841
+ Input.prototype.addFocusBlurEvents.call(this, this.focusableElement);
807
842
  if (this.itemsFromUrl && !this.component.noRefreshOnScroll) {
808
843
  this.scrollList = this.choices.choiceList.element;
809
844
  this.addEventListener(this.scrollList, 'scroll', () => this.onScroll());
@@ -1195,7 +1230,7 @@ export default class SelectComponent extends ListComponent {
1195
1230
  !this.active &&
1196
1231
  !this.selectOptions.length &&
1197
1232
  hasValue &&
1198
- this.shouldLoad &&
1233
+ this.shouldInitialLoad &&
1199
1234
  this.visible && (this.component.searchField || this.component.valueProperty);
1200
1235
  }
1201
1236
  setChoicesValue(value, hasPreviousValue, flags = {}) {
@@ -0,0 +1,23 @@
1
+ declare namespace _default {
2
+ const type: string;
3
+ const display: string;
4
+ const components: {
5
+ label: string;
6
+ widget: string;
7
+ tableView: boolean;
8
+ data: {
9
+ values: {
10
+ label: string;
11
+ value: string;
12
+ }[];
13
+ };
14
+ validateOn: string;
15
+ validate: {
16
+ custom: string;
17
+ };
18
+ key: string;
19
+ type: string;
20
+ input: boolean;
21
+ }[];
22
+ }
23
+ export default _default;
@@ -0,0 +1,34 @@
1
+ export default {
2
+ type: 'form',
3
+ display: 'form',
4
+ components: [
5
+ {
6
+ label: 'Select',
7
+ widget: 'choicesjs',
8
+ tableView: true,
9
+ data: {
10
+ values: [
11
+ {
12
+ label: 'Banana',
13
+ value: 'banana'
14
+ },
15
+ {
16
+ label: 'Apple',
17
+ value: 'apple'
18
+ },
19
+ {
20
+ label: 'Pineapple',
21
+ value: 'pineapple'
22
+ }
23
+ ]
24
+ },
25
+ validateOn: 'blur',
26
+ validate: {
27
+ custom: "valid = data.select == 'apple' ? true : 'You must select an apple';"
28
+ },
29
+ key: 'select',
30
+ type: 'select',
31
+ input: true
32
+ },
33
+ ]
34
+ };
@@ -15,5 +15,6 @@ import comp15 from './comp15';
15
15
  import comp16 from './comp16';
16
16
  import comp17 from './comp17';
17
17
  import comp18 from './comp18';
18
- export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18 };
18
+ import comp19 from './comp19';
19
+ export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19 };
19
20
  export { multiSelect, multiSelectOptions } from "./comp3";
@@ -16,4 +16,5 @@ import comp15 from './comp15';
16
16
  import comp16 from './comp16';
17
17
  import comp17 from './comp17';
18
18
  import comp18 from './comp18';
19
- export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18 };
19
+ import comp19 from './comp19';
20
+ export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19 };
@@ -9,8 +9,33 @@ export default class SelectBoxesComponent extends RadioComponent {
9
9
  custom: string;
10
10
  };
11
11
  };
12
- operators: string[];
12
+ constructor: Function;
13
+ toString(): string;
14
+ toLocaleString(): string;
15
+ valueOf(): Object;
16
+ hasOwnProperty(v: PropertyKey): boolean;
17
+ isPrototypeOf(v: Object): boolean;
18
+ propertyIsEnumerable(v: PropertyKey): boolean;
13
19
  };
20
+ static get conditionOperatorsSettings(): {
21
+ valueComponent(classComp: any): {
22
+ type: string;
23
+ dataSrc: string;
24
+ valueProperty: string;
25
+ valueType: string;
26
+ data: {
27
+ custom: string;
28
+ };
29
+ };
30
+ constructor: Function;
31
+ toString(): string;
32
+ toLocaleString(): string;
33
+ valueOf(): Object;
34
+ hasOwnProperty(v: PropertyKey): boolean;
35
+ isPrototypeOf(v: Object): boolean;
36
+ propertyIsEnumerable(v: PropertyKey): boolean;
37
+ };
38
+ static savedValueTypes(schema: any): string[];
14
39
  constructor(...args: any[]);
15
40
  validators: string[];
16
41
  get emptyValue(): any;
@@ -1,4 +1,5 @@
1
1
  import _ from 'lodash';
2
+ import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
2
3
  import RadioComponent from '../radio/Radio';
3
4
  export default class SelectBoxesComponent extends RadioComponent {
4
5
  static schema(...extend) {
@@ -20,8 +21,11 @@ export default class SelectBoxesComponent extends RadioComponent {
20
21
  };
21
22
  }
22
23
  static get serverConditionSettings() {
24
+ return SelectBoxesComponent.conditionOperatorsSettings;
25
+ }
26
+ static get conditionOperatorsSettings() {
23
27
  return {
24
- ...super.serverConditionSettings,
28
+ ...super.conditionOperatorsSettings,
25
29
  valueComponent(classComp) {
26
30
  return {
27
31
  type: 'select',
@@ -35,6 +39,9 @@ export default class SelectBoxesComponent extends RadioComponent {
35
39
  }
36
40
  };
37
41
  }
42
+ static savedValueTypes(schema) {
43
+ return getComponentSavedTypes(schema) || [componentValueTypes.object];
44
+ }
38
45
  constructor(...args) {
39
46
  super(...args);
40
47
  this.validators = this.validators.concat('minSelectedCount', 'maxSelectedCount', 'availableValueProperty');
@@ -7,6 +7,27 @@ export default class SignatureComponent extends Input {
7
7
  documentation: string;
8
8
  schema: any;
9
9
  };
10
+ static get serverConditionSettings(): {
11
+ operators: string[];
12
+ constructor: Function;
13
+ toString(): string;
14
+ toLocaleString(): string;
15
+ valueOf(): Object;
16
+ hasOwnProperty(v: PropertyKey): boolean;
17
+ isPrototypeOf(v: Object): boolean;
18
+ propertyIsEnumerable(v: PropertyKey): boolean;
19
+ };
20
+ static get conditionOperatorsSettings(): {
21
+ operators: string[];
22
+ constructor: Function;
23
+ toString(): string;
24
+ toLocaleString(): string;
25
+ valueOf(): Object;
26
+ hasOwnProperty(v: PropertyKey): boolean;
27
+ isPrototypeOf(v: Object): boolean;
28
+ propertyIsEnumerable(v: PropertyKey): boolean;
29
+ };
30
+ static savedValueTypes(schema: any): string[];
10
31
  currentWidth: any;
11
32
  scale: any;
12
33
  ratio: number | undefined;