@formio/js 5.0.0-dev.5620.dedc19b → 5.0.0-dev.5625.779293f

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 (74) hide show
  1. package/Changelog.md +5 -0
  2. package/dist/formio.builder.css +0 -4
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.form.css +0 -4
  5. package/dist/formio.form.js +54 -42
  6. package/dist/formio.form.min.css +1 -1
  7. package/dist/formio.form.min.js +1 -1
  8. package/dist/formio.full.css +0 -4
  9. package/dist/formio.full.js +58 -46
  10. package/dist/formio.full.min.css +1 -1
  11. package/dist/formio.full.min.js +1 -1
  12. package/dist/formio.js +2 -2
  13. package/dist/formio.min.js +1 -1
  14. package/dist/formio.utils.js +2 -2
  15. package/dist/formio.utils.min.js +1 -1
  16. package/lib/cjs/Formio.js +11 -0
  17. package/lib/cjs/Webform.d.ts +1 -1
  18. package/lib/cjs/Webform.js +14 -9
  19. package/lib/cjs/WebformBuilder.d.ts +1 -1
  20. package/lib/cjs/WebformBuilder.js +20 -19
  21. package/lib/cjs/components/_classes/component/Component.d.ts +5 -3
  22. package/lib/cjs/components/_classes/component/Component.js +2 -6
  23. package/lib/cjs/components/button/Button.d.ts +1 -1
  24. package/lib/cjs/components/button/Button.js +7 -7
  25. package/lib/cjs/components/form/Form.js +3 -2
  26. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -8
  27. package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +1 -1
  28. package/lib/cjs/components/recaptcha/ReCaptcha.form.js +2 -2
  29. package/lib/cjs/components/recaptcha/ReCaptcha.js +1 -8
  30. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +28 -2
  31. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +10 -2
  32. package/lib/cjs/components/select/Select.js +1 -1
  33. package/lib/cjs/components/select/editForm/Select.edit.data.js +16 -2
  34. package/lib/cjs/components/select/fixtures/comp22.js +1 -1
  35. package/lib/cjs/components/select/fixtures/comp23.d.ts +26 -15
  36. package/lib/cjs/components/select/fixtures/comp23.js +28 -19
  37. package/lib/cjs/components/select/fixtures/comp24.d.ts +47 -0
  38. package/lib/cjs/components/select/fixtures/comp24.js +40 -0
  39. package/lib/cjs/components/select/fixtures/index.d.ts +2 -1
  40. package/lib/cjs/components/select/fixtures/index.js +3 -1
  41. package/lib/cjs/translations/en.d.ts +1 -0
  42. package/lib/cjs/translations/en.js +1 -0
  43. package/lib/cjs/utils/utils.d.ts +6 -0
  44. package/lib/cjs/utils/utils.js +15 -4
  45. package/lib/mjs/Formio.js +11 -0
  46. package/lib/mjs/Webform.d.ts +1 -1
  47. package/lib/mjs/Webform.js +15 -10
  48. package/lib/mjs/WebformBuilder.d.ts +1 -1
  49. package/lib/mjs/WebformBuilder.js +20 -18
  50. package/lib/mjs/components/_classes/component/Component.d.ts +5 -3
  51. package/lib/mjs/components/_classes/component/Component.js +2 -6
  52. package/lib/mjs/components/button/Button.d.ts +1 -1
  53. package/lib/mjs/components/button/Button.js +7 -7
  54. package/lib/mjs/components/form/Form.js +3 -2
  55. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -8
  56. package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +1 -1
  57. package/lib/mjs/components/recaptcha/ReCaptcha.form.js +2 -2
  58. package/lib/mjs/components/recaptcha/ReCaptcha.js +1 -8
  59. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +28 -2
  60. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +10 -2
  61. package/lib/mjs/components/select/Select.js +2 -2
  62. package/lib/mjs/components/select/editForm/Select.edit.data.js +16 -2
  63. package/lib/mjs/components/select/fixtures/comp22.js +1 -1
  64. package/lib/mjs/components/select/fixtures/comp23.d.ts +26 -15
  65. package/lib/mjs/components/select/fixtures/comp23.js +28 -19
  66. package/lib/mjs/components/select/fixtures/comp24.d.ts +47 -0
  67. package/lib/mjs/components/select/fixtures/comp24.js +38 -0
  68. package/lib/mjs/components/select/fixtures/index.d.ts +2 -1
  69. package/lib/mjs/components/select/fixtures/index.js +2 -1
  70. package/lib/mjs/translations/en.d.ts +1 -0
  71. package/lib/mjs/translations/en.js +1 -0
  72. package/lib/mjs/utils/utils.d.ts +6 -0
  73. package/lib/mjs/utils/utils.js +12 -2
  74. package/package.json +2 -2
package/lib/cjs/Formio.js CHANGED
@@ -114,3 +114,14 @@ sdk_1.Formio.createForm = Embed_1.Formio.createForm;
114
114
  sdk_1.Formio.submitDone = Embed_1.Formio.submitDone;
115
115
  sdk_1.Formio.addLibrary = Embed_1.Formio.addLibrary;
116
116
  sdk_1.Formio.addLoader = Embed_1.Formio.addLoader;
117
+ sdk_1.Formio.addToGlobal = (global) => {
118
+ if (typeof global === 'object' && !global.Formio) {
119
+ global.Formio = sdk_1.Formio;
120
+ }
121
+ };
122
+ if (typeof global !== 'undefined') {
123
+ sdk_1.Formio.addToGlobal(global);
124
+ }
125
+ if (typeof window !== 'undefined') {
126
+ sdk_1.Formio.addToGlobal(window);
127
+ }
@@ -471,7 +471,7 @@ declare class Webform extends NestedDataComponent {
471
471
  */
472
472
  submit(before: boolean, options?: {}): Promise<any>;
473
473
  submitUrl(URL: any, headers: any): void;
474
- triggerRecaptcha(): void;
474
+ triggerCaptcha(): void;
475
475
  _nosubmit: any;
476
476
  get conditions(): any;
477
477
  get variables(): any;
@@ -659,7 +659,7 @@ class Webform extends NestedDataComponent_1.default {
659
659
  const rebuild = this.rebuild() || Promise.resolve();
660
660
  return rebuild.then(() => {
661
661
  this.emit('formLoad', form);
662
- this.triggerRecaptcha();
662
+ this.triggerCaptcha();
663
663
  // Make sure to trigger onChange after a render event occurs to speed up form rendering.
664
664
  setTimeout(() => {
665
665
  this.onChange(flags);
@@ -787,7 +787,8 @@ class Webform extends NestedDataComponent_1.default {
787
787
  formio.loadSubmissions({
788
788
  params: {
789
789
  state: 'draft',
790
- owner: userId
790
+ owner: userId,
791
+ sort: '-created'
791
792
  }
792
793
  }).then(submissions => {
793
794
  if (submissions.length > 0 && !this.options.skipDraftRestore) {
@@ -830,7 +831,9 @@ class Webform extends NestedDataComponent_1.default {
830
831
  };
831
832
  }
832
833
  // Metadata needs to be available before setValue
833
- this._submission.metadata = submission.metadata || {};
834
+ this._submission.metadata = submission.metadata
835
+ ? lodash_1.default.cloneDeep(submission.metadata)
836
+ : {};
834
837
  this.editing = !!submission._id;
835
838
  // Set the timezone in the options if available.
836
839
  if (!this.options.submissionTimezone &&
@@ -1489,16 +1492,18 @@ class Webform extends NestedDataComponent_1.default {
1489
1492
  return console.warn('You should add a URL to this button.');
1490
1493
  }
1491
1494
  }
1492
- triggerRecaptcha() {
1495
+ triggerCaptcha() {
1493
1496
  if (!this || !this.components) {
1494
1497
  return;
1495
1498
  }
1496
- const recaptchaComponent = (0, utils_1.searchComponents)(this.components, {
1497
- 'component.type': 'recaptcha',
1498
- 'component.eventType': 'formLoad'
1499
+ const captchaComponent = [];
1500
+ (0, formUtils_1.eachComponent)(this.components, (component) => {
1501
+ if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1502
+ captchaComponent.push(component);
1503
+ }
1499
1504
  });
1500
- if (recaptchaComponent.length > 0) {
1501
- recaptchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1505
+ if (captchaComponent.length > 0) {
1506
+ captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1502
1507
  }
1503
1508
  }
1504
1509
  set nosubmit(value) {
@@ -72,7 +72,7 @@ export default class WebformBuilder extends Component {
72
72
  onDrop(element: any, target: any, source: any, sibling: any): any;
73
73
  setForm(form: any): any;
74
74
  keyboardActionsEnabled: any;
75
- populateRecaptchaSettings(form: any): void;
75
+ populateCaptchaSettings(form: any): void;
76
76
  removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
77
77
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
78
78
  updateComponent(component: any, changed: any): void;
@@ -486,7 +486,7 @@ class WebformBuilder extends Component_1.default {
486
486
  }
487
487
  attach(element) {
488
488
  this.on('change', (form) => {
489
- this.populateRecaptchaSettings(form);
489
+ this.populateCaptchaSettings(form);
490
490
  this.webform.setAlert(false);
491
491
  });
492
492
  return super.attach(element).then(() => {
@@ -939,24 +939,24 @@ class WebformBuilder extends Component_1.default {
939
939
  }
940
940
  return Promise.resolve(form);
941
941
  }
942
- populateRecaptchaSettings(form) {
943
- //populate isEnabled for recaptcha form settings
944
- let isRecaptchaEnabled = false;
942
+ populateCaptchaSettings(form) {
943
+ //populate isEnabled for captcha form settings
944
+ let isCaptchaEnabled = false;
945
945
  if (this.form.components) {
946
946
  (0, formUtils_1.eachComponent)(form.components, component => {
947
- if (isRecaptchaEnabled) {
947
+ if (isCaptchaEnabled) {
948
948
  return;
949
949
  }
950
- if (component.type === 'recaptcha') {
951
- isRecaptchaEnabled = true;
950
+ if (component.type === 'captcha') {
951
+ isCaptchaEnabled = true;
952
952
  return false;
953
953
  }
954
954
  });
955
- if (isRecaptchaEnabled) {
956
- lodash_1.default.set(form, 'settings.recaptcha.isEnabled', true);
955
+ if (isCaptchaEnabled) {
956
+ lodash_1.default.set(form, 'settings.captcha.isEnabled', true);
957
957
  }
958
- else if (lodash_1.default.get(form, 'settings.recaptcha.isEnabled')) {
959
- lodash_1.default.set(form, 'settings.recaptcha.isEnabled', false);
958
+ else if (lodash_1.default.get(form, 'settings.captcha.isEnabled')) {
959
+ lodash_1.default.set(form, 'settings.captcha.isEnabled', false);
960
960
  }
961
961
  }
962
962
  }
@@ -986,8 +986,14 @@ class WebformBuilder extends Component_1.default {
986
986
  else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {
987
987
  parent.formioComponent.removeChildComponent(component);
988
988
  }
989
- if (component.input && componentInstance && componentInstance.parent) {
990
- lodash_1.default.unset(componentInstance._data, componentInstance.key);
989
+ if (component.input && componentInstance && parent.formioComponent) {
990
+ const parentDefaultValue = lodash_1.default.get(parent.formioComponent, 'component.defaultValue', null);
991
+ if (Array.isArray(parentDefaultValue)) {
992
+ parentDefaultValue.forEach(v => lodash_1.default.unset(v, componentInstance.key));
993
+ }
994
+ else if (typeof parentDefaultValue === 'object') {
995
+ lodash_1.default.unset(parentDefaultValue, componentInstance.key);
996
+ }
991
997
  }
992
998
  const rebuild = parent.formioComponent.rebuild() || Promise.resolve();
993
999
  rebuild.then(() => {
@@ -1119,16 +1125,11 @@ class WebformBuilder extends Component_1.default {
1119
1125
  const repeatablePaths = this.findRepeatablePaths();
1120
1126
  let hasInvalidComponents = false;
1121
1127
  this.webform.everyComponent((comp) => {
1122
- var _a;
1123
1128
  const path = comp.path;
1124
- const errors = comp.visibleErrors || [];
1125
1129
  if (repeatablePaths.includes(path)) {
1126
- comp.setCustomValidity(`API Key is not unique: ${comp.key}`);
1130
+ comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1127
1131
  hasInvalidComponents = true;
1128
1132
  }
1129
- else if (errors.length && ((_a = errors[0].message) === null || _a === void 0 ? void 0 : _a.startsWith('API Key is not unique'))) {
1130
- comp.setCustomValidity('');
1131
- }
1132
1133
  });
1133
1134
  this.emit('builderFormValidityChange', hasInvalidComponents);
1134
1135
  }
@@ -492,10 +492,12 @@ declare class Component extends Element {
492
492
  /**
493
493
  * Add a new input error to this element.
494
494
  *
495
- * @param message
496
- * @param dirty
495
+ * @param {{level: string, message: string}[]} messages
497
496
  */
498
- addMessages(messages: any): void;
497
+ addMessages(messages: {
498
+ level: string;
499
+ message: string;
500
+ }[]): void;
499
501
  setErrorClasses(elements: any, dirty: any, hasErrors: any, hasMessages: any, element?: any): void;
500
502
  setElementInvalid(element: any, invalid: any): void;
501
503
  clearOnHide(): void;
@@ -1831,8 +1831,7 @@ class Component extends Element_1.default {
1831
1831
  /**
1832
1832
  * Add a new input error to this element.
1833
1833
  *
1834
- * @param message
1835
- * @param dirty
1834
+ * @param {{level: string, message: string}[]} messages
1836
1835
  */
1837
1836
  addMessages(messages) {
1838
1837
  if (!messages) {
@@ -1851,9 +1850,6 @@ class Component extends Element_1.default {
1851
1850
  messages = lodash_1.default.uniqBy(messages, message => message.message);
1852
1851
  if (this.refs.messageContainer) {
1853
1852
  this.setContent(this.refs.messageContainer, messages.map((message) => {
1854
- if (message.message && typeof message.message === 'string') {
1855
- message.message = message.message.replaceAll('<', '&lt;').replaceAll('>', '&gt;');
1856
- }
1857
1853
  return this.renderTemplate('message', Object.assign({}, message));
1858
1854
  }).join(''));
1859
1855
  }
@@ -2563,7 +2559,7 @@ class Component extends Element_1.default {
2563
2559
  }
2564
2560
  this.calculatedValue = (0, utils_1.fastCloneDeep)(calculatedValue);
2565
2561
  if (changed) {
2566
- if (!flags.noPristineChangeOnModified) {
2562
+ if (!flags.noPristineChangeOnModified && this.root.initialized) {
2567
2563
  this.pristine = false;
2568
2564
  }
2569
2565
  flags.triggeredComponentId = this.id;
@@ -40,6 +40,6 @@ export default class ButtonComponent extends Field {
40
40
  openOauth(settings: any): void;
41
41
  get oauthComponentPath(): any;
42
42
  focus(): void;
43
- triggerReCaptcha(): void;
43
+ triggerCaptcha(): void;
44
44
  }
45
45
  import Field from '../_classes/field/Field';
@@ -268,7 +268,7 @@ class ButtonComponent extends Field_1.default {
268
268
  super.detach();
269
269
  }
270
270
  onClick(event) {
271
- this.triggerReCaptcha();
271
+ this.triggerCaptcha();
272
272
  // Don't click if disabled or in builder mode.
273
273
  if (this.disabled || this.options.attachMode === 'builder') {
274
274
  return;
@@ -454,20 +454,20 @@ class ButtonComponent extends Field_1.default {
454
454
  this.refs.button.focus();
455
455
  }
456
456
  }
457
- triggerReCaptcha() {
457
+ triggerCaptcha() {
458
458
  if (!this.root) {
459
459
  return;
460
460
  }
461
- let recaptchaComponent;
461
+ let captchaComponent;
462
462
  this.root.everyComponent((component) => {
463
- if (component.component.type === 'recaptcha' &&
463
+ if (/^(re)?captcha$/.test(component.component.type) &&
464
464
  component.component.eventType === 'buttonClick' &&
465
465
  component.component.buttonKey === this.component.key) {
466
- recaptchaComponent = component;
466
+ captchaComponent = component;
467
467
  }
468
468
  });
469
- if (recaptchaComponent) {
470
- recaptchaComponent.verify(`${this.component.key}Click`);
469
+ if (captchaComponent) {
470
+ captchaComponent.verify(`${this.component.key}Click`);
471
471
  }
472
472
  }
473
473
  }
@@ -630,9 +630,10 @@ class FormComponent extends Component_1.default {
630
630
  && submission._id
631
631
  && this.subForm.formio
632
632
  && lodash_1.default.isEmpty(submission.data);
633
- if (shouldLoadSubmissionById) {
633
+ const shouldLoadDraftById = this.options.saveDraft && lodash_1.default.isEmpty(submission.data) && lodash_1.default.get(this.subForm, 'submission._id');
634
+ if (shouldLoadSubmissionById || shouldLoadDraftById) {
634
635
  const formId = submission.form || this.formObj.form || this.component.form;
635
- const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id}`;
636
+ const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id || this.subForm.submission._id}`;
636
637
  const options = ((_a = this.root.formio) === null || _a === void 0 ? void 0 : _a.base) && ((_b = this.root.formio) === null || _b === void 0 ? void 0 : _b.projectUrl)
637
638
  ? {
638
639
  base: this.root.formio.base,
@@ -1,12 +1,5 @@
1
1
  export default class ReCaptchaComponent extends Component {
2
- static get builderInfo(): {
3
- title: string;
4
- group: string;
5
- icon: string;
6
- documentation: string;
7
- weight: number;
8
- schema: any;
9
- };
2
+ static get builderInfo(): {};
10
3
  static savedValueTypes(): never[];
11
4
  render(): any;
12
5
  recaptchaResult: any;
@@ -1,3 +1,3 @@
1
- export default function _default(): {
1
+ export default function _default(...extend: any[]): {
2
2
  components: any;
3
3
  };
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Components_1 = __importDefault(require("../Components"));
7
7
  const ReCaptcha_edit_display_1 = __importDefault(require("./editForm/ReCaptcha.edit.display"));
8
- function default_1() {
8
+ function default_1(...extend) {
9
9
  return Components_1.default.baseEditForm([
10
10
  {
11
11
  key: 'display',
@@ -27,6 +27,6 @@ function default_1() {
27
27
  key: 'logic',
28
28
  ignore: true
29
29
  },
30
- ]);
30
+ ], ...extend);
31
31
  }
32
32
  exports.default = default_1;
@@ -26,14 +26,7 @@ class ReCaptchaComponent extends Component_1.default {
26
26
  }, ...extend);
27
27
  }
28
28
  static get builderInfo() {
29
- return {
30
- title: 'reCAPTCHA',
31
- group: 'premium',
32
- icon: 'refresh',
33
- documentation: '/userguide/form-building/premium-components#recaptcha',
34
- weight: 40,
35
- schema: ReCaptchaComponent.schema()
36
- };
29
+ return {};
37
30
  }
38
31
  static savedValueTypes() {
39
32
  return [];
@@ -1,4 +1,21 @@
1
1
  declare const _default: ({
2
+ key: string;
3
+ weight: number;
4
+ type: string;
5
+ tag: string;
6
+ className: string;
7
+ content: string;
8
+ label?: undefined;
9
+ tooltip?: undefined;
10
+ values?: undefined;
11
+ validate?: undefined;
12
+ input?: undefined;
13
+ dataSrc?: undefined;
14
+ valueProperty?: undefined;
15
+ customConditional?: undefined;
16
+ data?: undefined;
17
+ ignore?: undefined;
18
+ } | {
2
19
  key: string;
3
20
  label: string;
4
21
  tooltip: string;
@@ -11,6 +28,9 @@ declare const _default: ({
11
28
  required: boolean;
12
29
  };
13
30
  weight: number;
31
+ tag?: undefined;
32
+ className?: undefined;
33
+ content?: undefined;
14
34
  input?: undefined;
15
35
  dataSrc?: undefined;
16
36
  valueProperty?: undefined;
@@ -30,18 +50,24 @@ declare const _default: ({
30
50
  data: {
31
51
  custom(context: any): any[];
32
52
  };
53
+ tag?: undefined;
54
+ className?: undefined;
55
+ content?: undefined;
33
56
  values?: undefined;
34
57
  validate?: undefined;
35
58
  ignore?: undefined;
36
59
  } | {
37
60
  key: string;
38
61
  ignore: boolean;
62
+ weight?: undefined;
63
+ type?: undefined;
64
+ tag?: undefined;
65
+ className?: undefined;
66
+ content?: undefined;
39
67
  label?: undefined;
40
68
  tooltip?: undefined;
41
- type?: undefined;
42
69
  values?: undefined;
43
70
  validate?: undefined;
44
- weight?: undefined;
45
71
  input?: undefined;
46
72
  dataSrc?: undefined;
47
73
  valueProperty?: undefined;
@@ -2,10 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../../../utils/utils");
4
4
  exports.default = [
5
+ {
6
+ key: 'recaptchaInfo',
7
+ weight: -10,
8
+ type: 'htmlelement',
9
+ tag: 'div',
10
+ className: 'alert alert-danger',
11
+ content: 'This component has been deprecated and will be removed. Use the CAPTCHA component instead.',
12
+ },
5
13
  {
6
14
  key: 'eventType',
7
15
  label: 'Type of event',
8
- tooltip: 'Specify type of event that this reCAPTCHA would react to',
16
+ tooltip: 'Specify type of event that this CAPTCHA would react to. If Button Click is selected, then the CAPTCHA widget will be displayed and verification will occur after clicking on the button.',
9
17
  type: 'radio',
10
18
  values: [
11
19
  {
@@ -29,7 +37,7 @@ exports.default = [
29
37
  key: 'buttonKey',
30
38
  dataSrc: 'custom',
31
39
  valueProperty: 'value',
32
- tooltip: 'Specify key of button on this form that this reCAPTCHA should react to',
40
+ tooltip: 'Specify key of button on this form that this CAPTCHA should react to',
33
41
  weight: 660,
34
42
  customConditional(context) {
35
43
  return context.data.eventType === 'buttonClick';
@@ -1526,7 +1526,7 @@ class SelectComponent extends ListComponent_1.default {
1526
1526
  const getTemplateValue = (v) => {
1527
1527
  const itemTemplate = this.itemTemplate(v);
1528
1528
  return options.csv && itemTemplate
1529
- ? (0, utils_1.unescapeHTML)(itemTemplate)
1529
+ ? (0, utils_1.removeHTML)(itemTemplate)
1530
1530
  : itemTemplate;
1531
1531
  };
1532
1532
  if (Array.isArray(value)) {
@@ -5,15 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const utils_1 = require("../../../utils/utils");
8
- const calculateSelectData = (context) => {
8
+ const calculateSingleSelectData = (context, defaultValue) => {
9
9
  const { instance, data } = context;
10
- const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) === instance.getValue());
10
+ const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) === defaultValue);
11
11
  const options = { data: {}, noeval: true };
12
12
  instance.interpolate(data.template, {
13
13
  item: rawDefaultValue,
14
14
  }, options);
15
15
  return options.data.item;
16
16
  };
17
+ const calculateSelectData = (context) => {
18
+ const { instance } = context;
19
+ const defaultValue = instance.getValue();
20
+ if (instance.component.multiple) {
21
+ const multiSelectData = {};
22
+ (defaultValue !== null && defaultValue !== void 0 ? defaultValue : []).forEach((defaultValueItem) => {
23
+ multiSelectData[defaultValueItem] = calculateSingleSelectData(context, defaultValueItem);
24
+ });
25
+ return multiSelectData;
26
+ }
27
+ else {
28
+ return calculateSingleSelectData(context, defaultValue);
29
+ }
30
+ };
17
31
  const setSelectData = (context) => {
18
32
  // Wait before downloadedResources will be set
19
33
  setTimeout(() => {
@@ -8,7 +8,7 @@ exports.default = {
8
8
  display: 'form',
9
9
  components: [{
10
10
  label: 'Select',
11
- widget: 'choicesjs',
11
+ widget: 'html5',
12
12
  tableView: true,
13
13
  dataSrc: 'url',
14
14
  data: {
@@ -10,20 +10,30 @@ declare namespace _default {
10
10
  tableView: boolean;
11
11
  dataSrc: string;
12
12
  data: {
13
- resource: string;
14
- };
15
- template: string;
16
- validate: {
17
- select: boolean;
13
+ url: string;
14
+ headers: {
15
+ key: string;
16
+ value: string;
17
+ }[];
18
18
  };
19
+ multiple: boolean;
20
+ valueProperty: string;
21
+ validateWhenHidden: boolean;
19
22
  key: string;
20
23
  type: string;
21
- searchField: string;
22
24
  input: boolean;
25
+ defaultValue: string[];
26
+ selectValues: string;
27
+ disableLimit: boolean;
23
28
  noRefreshOnScroll: boolean;
24
- addResource: boolean;
25
- reference: boolean;
26
- valueProperty: string;
29
+ selectData: {
30
+ value1: {
31
+ label: string;
32
+ };
33
+ value3: {
34
+ label: string;
35
+ };
36
+ };
27
37
  disableOnInvalid?: undefined;
28
38
  } | {
29
39
  type: string;
@@ -35,13 +45,14 @@ declare namespace _default {
35
45
  widget?: undefined;
36
46
  dataSrc?: undefined;
37
47
  data?: undefined;
38
- template?: undefined;
39
- validate?: undefined;
40
- searchField?: undefined;
41
- noRefreshOnScroll?: undefined;
42
- addResource?: undefined;
43
- reference?: undefined;
48
+ multiple?: undefined;
44
49
  valueProperty?: undefined;
50
+ validateWhenHidden?: undefined;
51
+ defaultValue?: undefined;
52
+ selectValues?: undefined;
53
+ disableLimit?: undefined;
54
+ noRefreshOnScroll?: undefined;
55
+ selectData?: undefined;
45
56
  })[];
46
57
  }
47
58
  export default _default;
@@ -1,40 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
- title: 'FIO-8234',
5
- name: 'fio8234',
6
- path: 'fio8234',
4
+ title: 'FIO-8281',
5
+ name: 'fio8281',
6
+ path: 'fio8281',
7
7
  type: 'form',
8
8
  display: 'form',
9
- components: [
10
- {
9
+ components: [{
11
10
  label: 'Select',
12
11
  widget: 'choicesjs',
13
12
  tableView: true,
14
- dataSrc: 'resource',
13
+ dataSrc: 'url',
15
14
  data: {
16
- resource: '665446284c9b0163c3e0c7e6',
17
- },
18
- template: '<span>{{ item.data.textField1 }}</span>',
19
- validate: {
20
- select: false,
15
+ url: 'https://fake_url.com',
16
+ headers: [
17
+ {
18
+ key: '',
19
+ value: ''
20
+ },
21
+ ],
21
22
  },
23
+ multiple: true,
24
+ valueProperty: 'value',
25
+ validateWhenHidden: false,
22
26
  key: 'select',
23
27
  type: 'select',
24
- searchField: 'data.textField2__regex',
25
28
  input: true,
29
+ defaultValue: ['value1', 'value3'],
30
+ selectValues: 'data',
31
+ disableLimit: false,
26
32
  noRefreshOnScroll: false,
27
- addResource: false,
28
- reference: false,
29
- valueProperty: 'data.textField2',
30
- },
31
- {
33
+ selectData: {
34
+ value1: {
35
+ label: 'Label 1',
36
+ },
37
+ value3: {
38
+ label: 'Label 3',
39
+ },
40
+ },
41
+ }, {
32
42
  type: 'button',
33
43
  label: 'Submit',
34
44
  key: 'submit',
35
45
  disableOnInvalid: true,
36
46
  input: true,
37
47
  tableView: false,
38
- },
39
- ],
48
+ }]
40
49
  };
@@ -0,0 +1,47 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ widget: string;
10
+ tableView: boolean;
11
+ dataSrc: string;
12
+ data: {
13
+ resource: string;
14
+ };
15
+ template: string;
16
+ validate: {
17
+ select: boolean;
18
+ };
19
+ key: string;
20
+ type: string;
21
+ searchField: string;
22
+ input: boolean;
23
+ noRefreshOnScroll: boolean;
24
+ addResource: boolean;
25
+ reference: boolean;
26
+ valueProperty: string;
27
+ disableOnInvalid?: undefined;
28
+ } | {
29
+ type: string;
30
+ label: string;
31
+ key: string;
32
+ disableOnInvalid: boolean;
33
+ input: boolean;
34
+ tableView: boolean;
35
+ widget?: undefined;
36
+ dataSrc?: undefined;
37
+ data?: undefined;
38
+ template?: undefined;
39
+ validate?: undefined;
40
+ searchField?: undefined;
41
+ noRefreshOnScroll?: undefined;
42
+ addResource?: undefined;
43
+ reference?: undefined;
44
+ valueProperty?: undefined;
45
+ })[];
46
+ }
47
+ export default _default;