@formio/js 5.0.0-rc.58 → 5.0.0-rc.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. package/dist/formio.builder.css +0 -4
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.js +1 -1
  4. package/dist/formio.embed.min.js +1 -1
  5. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  6. package/dist/formio.form.css +0 -4
  7. package/dist/formio.form.js +26 -37
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.form.min.js.LICENSE.txt +11 -3
  11. package/dist/formio.full.css +0 -4
  12. package/dist/formio.full.js +30 -41
  13. package/dist/formio.full.min.css +1 -1
  14. package/dist/formio.full.min.js +1 -1
  15. package/dist/formio.full.min.js.LICENSE.txt +11 -3
  16. package/dist/formio.js +3 -3
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +1 -1
  19. package/dist/formio.utils.js +15 -36
  20. package/dist/formio.utils.min.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +2 -4
  22. package/lib/cjs/Formio.js +11 -0
  23. package/lib/cjs/Webform.d.ts +1 -1
  24. package/lib/cjs/Webform.js +11 -9
  25. package/lib/cjs/WebformBuilder.d.ts +1 -1
  26. package/lib/cjs/WebformBuilder.js +12 -17
  27. package/lib/cjs/components/_classes/component/Component.js +2 -2
  28. package/lib/cjs/components/button/Button.d.ts +1 -1
  29. package/lib/cjs/components/button/Button.js +7 -7
  30. package/lib/cjs/components/radio/Radio.d.ts +1 -1
  31. package/lib/cjs/components/radio/Radio.js +5 -3
  32. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -8
  33. package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +2 -1
  34. package/lib/cjs/components/recaptcha/ReCaptcha.form.js +3 -2
  35. package/lib/cjs/components/recaptcha/ReCaptcha.js +1 -8
  36. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +33 -2
  37. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +13 -2
  38. package/lib/cjs/components/select/Select.js +6 -1
  39. package/lib/cjs/components/select/editForm/Select.edit.data.js +16 -2
  40. package/lib/cjs/components/select/fixtures/comp22.js +1 -1
  41. package/lib/cjs/components/select/fixtures/comp23.d.ts +58 -0
  42. package/lib/cjs/components/select/fixtures/comp23.js +49 -0
  43. package/lib/cjs/components/select/fixtures/comp24.d.ts +47 -0
  44. package/lib/cjs/components/select/fixtures/comp24.js +40 -0
  45. package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
  46. package/lib/cjs/components/select/fixtures/index.js +5 -1
  47. package/lib/cjs/components/selectboxes/SelectBoxes.js +4 -1
  48. package/lib/cjs/translations/en.d.ts +1 -0
  49. package/lib/cjs/translations/en.js +1 -0
  50. package/lib/cjs/utils/utils.d.ts +6 -0
  51. package/lib/cjs/utils/utils.js +16 -2
  52. package/lib/mjs/Formio.js +11 -0
  53. package/lib/mjs/Webform.d.ts +1 -1
  54. package/lib/mjs/Webform.js +12 -10
  55. package/lib/mjs/WebformBuilder.d.ts +1 -1
  56. package/lib/mjs/WebformBuilder.js +12 -16
  57. package/lib/mjs/components/_classes/component/Component.js +3 -3
  58. package/lib/mjs/components/button/Button.d.ts +1 -1
  59. package/lib/mjs/components/button/Button.js +7 -7
  60. package/lib/mjs/components/radio/Radio.d.ts +1 -1
  61. package/lib/mjs/components/radio/Radio.js +5 -3
  62. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -8
  63. package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +2 -1
  64. package/lib/mjs/components/recaptcha/ReCaptcha.form.js +3 -2
  65. package/lib/mjs/components/recaptcha/ReCaptcha.js +1 -8
  66. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +33 -2
  67. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +13 -2
  68. package/lib/mjs/components/select/Select.js +6 -1
  69. package/lib/mjs/components/select/editForm/Select.edit.data.js +16 -2
  70. package/lib/mjs/components/select/fixtures/comp22.js +1 -1
  71. package/lib/mjs/components/select/fixtures/comp23.d.ts +58 -0
  72. package/lib/mjs/components/select/fixtures/comp23.js +47 -0
  73. package/lib/mjs/components/select/fixtures/comp24.d.ts +47 -0
  74. package/lib/mjs/components/select/fixtures/comp24.js +38 -0
  75. package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
  76. package/lib/mjs/components/select/fixtures/index.js +3 -1
  77. package/lib/mjs/components/selectboxes/SelectBoxes.js +4 -1
  78. package/lib/mjs/translations/en.d.ts +1 -0
  79. package/lib/mjs/translations/en.js +1 -0
  80. package/lib/mjs/utils/utils.d.ts +6 -0
  81. package/lib/mjs/utils/utils.js +13 -0
  82. package/package.json +4 -4
@@ -18,11 +18,9 @@
18
18
  * MIT licensed
19
19
  */
20
20
 
21
- /*! @license DOMPurify 3.1.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.3/LICENSE */
21
+ /*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */
22
22
 
23
- /*! @license DOMPurify 3.1.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.4/LICENSE */
24
-
25
- /*! formiojs v5.0.0-rc.58 | https://unpkg.com/formiojs@5.0.0-rc.58/LICENSE.txt */
23
+ /*! formiojs v5.0.0-rc.59 | https://unpkg.com/formiojs@5.0.0-rc.59/LICENSE.txt */
26
24
 
27
25
  /**
28
26
  * @license
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
+ }
@@ -445,7 +445,7 @@ declare class Webform extends NestedDataComponent {
445
445
  */
446
446
  submit(before?: boolean, options?: any): Promise<any>;
447
447
  submitUrl(URL: any, headers: any): void;
448
- triggerRecaptcha(): void;
448
+ triggerCaptcha(): void;
449
449
  _nosubmit: any;
450
450
  get conditions(): any;
451
451
  get variables(): any;
@@ -646,7 +646,7 @@ class Webform extends NestedDataComponent_1.default {
646
646
  const rebuild = this.rebuild() || Promise.resolve();
647
647
  return rebuild.then(() => {
648
648
  this.emit("formLoad", form);
649
- this.triggerRecaptcha();
649
+ this.triggerCaptcha();
650
650
  // Make sure to trigger onChange after a render event occurs to speed up form rendering.
651
651
  setTimeout(() => {
652
652
  this.onChange(flags);
@@ -738,7 +738,7 @@ class Webform extends NestedDataComponent_1.default {
738
738
  }
739
739
  const draft = (0, utils_1.fastCloneDeep)(this.submission);
740
740
  draft.state = "draft";
741
- if (!this.savingDraft) {
741
+ if (!this.savingDraft && !this.submitting) {
742
742
  this.emit("saveDraftBegin");
743
743
  this.savingDraft = true;
744
744
  this.formio
@@ -816,7 +816,7 @@ class Webform extends NestedDataComponent_1.default {
816
816
  };
817
817
  }
818
818
  // Metadata needs to be available before setValue
819
- this._submission.metadata = submission.metadata || {};
819
+ this._submission.metadata = submission.metadata ? lodash_1.default.cloneDeep(submission.metadata) : {};
820
820
  this.editing = !!submission._id;
821
821
  // Set the timezone in the options if available.
822
822
  if (!this.options.submissionTimezone &&
@@ -1504,16 +1504,18 @@ class Webform extends NestedDataComponent_1.default {
1504
1504
  return console.warn("You should add a URL to this button.");
1505
1505
  }
1506
1506
  }
1507
- triggerRecaptcha() {
1507
+ triggerCaptcha() {
1508
1508
  if (!this || !this.components) {
1509
1509
  return;
1510
1510
  }
1511
- const recaptchaComponent = (0, utils_1.searchComponents)(this.components, {
1512
- "component.type": "recaptcha",
1513
- "component.eventType": "formLoad",
1511
+ const captchaComponent = [];
1512
+ (0, formUtils_1.eachComponent)(this.components, (component) => {
1513
+ if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1514
+ captchaComponent.push(component);
1515
+ }
1514
1516
  });
1515
- if (recaptchaComponent.length > 0) {
1516
- recaptchaComponent[0].verify(`${this.form.name ? this.form.name : "form"}Load`);
1517
+ if (captchaComponent.length > 0) {
1518
+ captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1517
1519
  }
1518
1520
  }
1519
1521
  set nosubmit(value) {
@@ -73,7 +73,7 @@ export default class WebformBuilder extends Component {
73
73
  onDrop(element: any, target: any, source: any, sibling: any): any;
74
74
  setForm(form: any): any;
75
75
  keyboardActionsEnabled: any;
76
- populateRecaptchaSettings(form: any): void;
76
+ populateCaptchaSettings(form: any): void;
77
77
  removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
78
78
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
79
79
  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
  }
@@ -1119,16 +1119,11 @@ class WebformBuilder extends Component_1.default {
1119
1119
  const repeatablePaths = this.findRepeatablePaths();
1120
1120
  let hasInvalidComponents = false;
1121
1121
  this.webform.everyComponent((comp) => {
1122
- var _a;
1123
1122
  const path = comp.path;
1124
- const errors = comp.visibleErrors || [];
1125
1123
  if (repeatablePaths.includes(path)) {
1126
- comp.setCustomValidity(`API Key is not unique: ${comp.key}`);
1124
+ comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1127
1125
  hasInvalidComponents = true;
1128
1126
  }
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
1127
  });
1133
1128
  this.emit('builderFormValidityChange', hasInvalidComponents);
1134
1129
  }
@@ -3500,7 +3500,7 @@ Component.requireLibrary = function (name, property, src, polling) {
3500
3500
  }.bind(Component.externalLibraries[name]);
3501
3501
  }
3502
3502
  // See if the plugin already exists.
3503
- const plugin = lodash_1.default.get(window, property);
3503
+ const plugin = (0, utils_1.getScriptPlugin)(property);
3504
3504
  if (plugin) {
3505
3505
  Component.externalLibraries[name].resolve(plugin);
3506
3506
  }
@@ -3543,7 +3543,7 @@ Component.requireLibrary = function (name, property, src, polling) {
3543
3543
  // if no callback is provided, then check periodically for the script.
3544
3544
  if (polling) {
3545
3545
  setTimeout(function checkLibrary() {
3546
- const plugin = lodash_1.default.get(window, property);
3546
+ const plugin = (0, utils_1.getScriptPlugin)(property);
3547
3547
  if (plugin) {
3548
3548
  Component.externalLibraries[name].resolve(plugin);
3549
3549
  }
@@ -31,6 +31,6 @@ export default class ButtonComponent extends Field {
31
31
  openOauth(settings: any): void;
32
32
  get oauthComponentPath(): any;
33
33
  focus(): void;
34
- triggerReCaptcha(): void;
34
+ triggerCaptcha(): void;
35
35
  }
36
36
  import Field from '../_classes/field/Field';
@@ -273,7 +273,7 @@ class ButtonComponent extends Field_1.default {
273
273
  super.detach();
274
274
  }
275
275
  onClick(event) {
276
- this.triggerReCaptcha();
276
+ this.triggerCaptcha();
277
277
  // Don't click if disabled or in builder mode.
278
278
  if (this.disabled || this.options.attachMode === 'builder') {
279
279
  return;
@@ -459,20 +459,20 @@ class ButtonComponent extends Field_1.default {
459
459
  this.refs.button.focus();
460
460
  }
461
461
  }
462
- triggerReCaptcha() {
462
+ triggerCaptcha() {
463
463
  if (!this.root) {
464
464
  return;
465
465
  }
466
- let recaptchaComponent;
466
+ let captchaComponent;
467
467
  this.root.everyComponent((component) => {
468
- if (component.component.type === 'recaptcha' &&
468
+ if (/^(re)?captcha$/.test(component.component.type) &&
469
469
  component.component.eventType === 'buttonClick' &&
470
470
  component.component.buttonKey === this.component.key) {
471
- recaptchaComponent = component;
471
+ captchaComponent = component;
472
472
  }
473
473
  });
474
- if (recaptchaComponent) {
475
- recaptchaComponent.verify(`${this.component.key}Click`);
474
+ if (captchaComponent) {
475
+ captchaComponent.verify(`${this.component.key}Click`);
476
476
  }
477
477
  }
478
478
  }
@@ -48,7 +48,7 @@ export default class RadioComponent extends ListComponent {
48
48
  detach(element: any): void;
49
49
  validateValueProperty(): boolean;
50
50
  validateValueAvailability(setting: any, value: any): boolean;
51
- getValueAsString(value: any): any;
51
+ getValueAsString(value: any, options?: {}): any;
52
52
  setValueAt(index: any, value: any): void;
53
53
  loadItems(url: any, search: any, headers: any, options: any, method: any, body: any): void;
54
54
  loadItemsFromMetadata(): void;
@@ -226,17 +226,19 @@ class RadioComponent extends ListComponent_1.default {
226
226
  }
227
227
  return false;
228
228
  }
229
- getValueAsString(value) {
229
+ getValueAsString(value, options = {}) {
230
230
  if (lodash_1.default.isObject(value)) {
231
231
  value = JSON.stringify(value);
232
232
  }
233
233
  else if (!lodash_1.default.isString(value)) {
234
234
  value = lodash_1.default.toString(value);
235
235
  }
236
- if (this.component.dataSrc !== 'values') {
236
+ const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
237
+ if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
237
238
  return value;
238
239
  }
239
- const option = lodash_1.default.find(this.component.values, (v) => v.value === value);
240
+ const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
241
+ const option = lodash_1.default.find(values, (v) => v.value === value);
240
242
  if (!value) {
241
243
  return lodash_1.default.get(option, 'label', '');
242
244
  }
@@ -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(): string;
12
5
  recaptchaResult: any;
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * The Edit Form function.
3
+ * @param {...any} extend - The components that extend the edit form.
3
4
  * @returns {import('@formio/core').Component[]} - The edit form components.
4
5
  */
5
- export default function _default(): import('@formio/core').Component[];
6
+ export default function _default(...extend: any[]): import('@formio/core').Component[];
@@ -7,9 +7,10 @@ const Components_1 = __importDefault(require("../Components"));
7
7
  const ReCaptcha_edit_display_1 = __importDefault(require("./editForm/ReCaptcha.edit.display"));
8
8
  /**
9
9
  * The Edit Form function.
10
+ * @param {...any} extend - The components that extend the edit form.
10
11
  * @returns {import('@formio/core').Component[]} - The edit form components.
11
12
  */
12
- function default_1() {
13
+ function default_1(...extend) {
13
14
  return Components_1.default.baseEditForm([
14
15
  {
15
16
  key: 'display',
@@ -31,6 +32,6 @@ function default_1() {
31
32
  key: 'logic',
32
33
  ignore: true
33
34
  },
34
- ]);
35
+ ], ...extend);
35
36
  }
36
37
  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;
@@ -7,7 +24,13 @@ declare const _default: ({
7
24
  label: string;
8
25
  value: string;
9
26
  }[];
27
+ validate: {
28
+ required: boolean;
29
+ };
10
30
  weight: number;
31
+ tag?: undefined;
32
+ className?: undefined;
33
+ content?: undefined;
11
34
  input?: undefined;
12
35
  dataSrc?: undefined;
13
36
  valueProperty?: undefined;
@@ -27,16 +50,24 @@ declare const _default: ({
27
50
  data: {
28
51
  custom(context: any): any[];
29
52
  };
53
+ tag?: undefined;
54
+ className?: undefined;
55
+ content?: undefined;
30
56
  values?: undefined;
57
+ validate?: undefined;
31
58
  ignore?: undefined;
32
59
  } | {
33
60
  key: string;
34
61
  ignore: boolean;
62
+ weight?: undefined;
63
+ type?: undefined;
64
+ tag?: undefined;
65
+ className?: undefined;
66
+ content?: undefined;
35
67
  label?: undefined;
36
68
  tooltip?: undefined;
37
- type?: undefined;
38
69
  values?: undefined;
39
- weight?: undefined;
70
+ validate?: undefined;
40
71
  input?: undefined;
41
72
  dataSrc?: undefined;
42
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
  {
@@ -17,6 +25,9 @@ exports.default = [
17
25
  value: 'buttonClick'
18
26
  }
19
27
  ],
28
+ validate: {
29
+ required: true
30
+ },
20
31
  weight: 650
21
32
  },
22
33
  {
@@ -26,7 +37,7 @@ exports.default = [
26
37
  key: 'buttonKey',
27
38
  dataSrc: 'custom',
28
39
  valueProperty: 'value',
29
- 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',
30
41
  weight: 660,
31
42
  customConditional(context) {
32
43
  return context.data.eventType === 'buttonClick';
@@ -228,9 +228,10 @@ class SelectComponent extends ListComponent_1.default {
228
228
  }
229
229
  selectValueAndLabel(data) {
230
230
  const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
231
+ const readOnlyResourceLabelData = this.options.readOnly && (this.component.dataSrc === 'resource' || this.component.dataSrc === 'url') && this.selectData;
231
232
  return {
232
233
  value,
233
- label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : data, value)
234
+ label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : readOnlyResourceLabelData || data, value)
234
235
  };
235
236
  }
236
237
  itemTemplate(data, value) {
@@ -1467,6 +1468,10 @@ class SelectComponent extends ListComponent_1.default {
1467
1468
  asString(value, options = {}) {
1468
1469
  var _a;
1469
1470
  value = value !== null && value !== void 0 ? value : this.getValue();
1471
+ if (options.modalPreview && this.selectData) {
1472
+ const { label } = this.selectValueAndLabel(value);
1473
+ return label;
1474
+ }
1470
1475
  //need to convert values to strings to be able to compare values with available options that are strings
1471
1476
  const convertToString = (data, valueProperty) => {
1472
1477
  if (valueProperty) {
@@ -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: {
@@ -0,0 +1,58 @@
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
+ url: string;
14
+ headers: {
15
+ key: string;
16
+ value: string;
17
+ }[];
18
+ };
19
+ multiple: boolean;
20
+ valueProperty: string;
21
+ validateWhenHidden: boolean;
22
+ key: string;
23
+ type: string;
24
+ input: boolean;
25
+ defaultValue: string[];
26
+ selectValues: string;
27
+ disableLimit: boolean;
28
+ noRefreshOnScroll: boolean;
29
+ selectData: {
30
+ value1: {
31
+ label: string;
32
+ };
33
+ value3: {
34
+ label: string;
35
+ };
36
+ };
37
+ disableOnInvalid?: undefined;
38
+ } | {
39
+ type: string;
40
+ label: string;
41
+ key: string;
42
+ disableOnInvalid: boolean;
43
+ input: boolean;
44
+ tableView: boolean;
45
+ widget?: undefined;
46
+ dataSrc?: undefined;
47
+ data?: undefined;
48
+ multiple?: undefined;
49
+ valueProperty?: undefined;
50
+ validateWhenHidden?: undefined;
51
+ defaultValue?: undefined;
52
+ selectValues?: undefined;
53
+ disableLimit?: undefined;
54
+ noRefreshOnScroll?: undefined;
55
+ selectData?: undefined;
56
+ })[];
57
+ }
58
+ export default _default;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ title: 'FIO-8281',
5
+ name: 'fio8281',
6
+ path: 'fio8281',
7
+ type: 'form',
8
+ display: 'form',
9
+ components: [{
10
+ label: 'Select',
11
+ widget: 'choicesjs',
12
+ tableView: true,
13
+ dataSrc: 'url',
14
+ data: {
15
+ url: 'https://fake_url.com',
16
+ headers: [
17
+ {
18
+ key: '',
19
+ value: ''
20
+ },
21
+ ],
22
+ },
23
+ multiple: true,
24
+ valueProperty: 'value',
25
+ validateWhenHidden: false,
26
+ key: 'select',
27
+ type: 'select',
28
+ input: true,
29
+ defaultValue: ['value1', 'value3'],
30
+ selectValues: 'data',
31
+ disableLimit: false,
32
+ noRefreshOnScroll: false,
33
+ selectData: {
34
+ value1: {
35
+ label: 'Label 1',
36
+ },
37
+ value3: {
38
+ label: 'Label 3',
39
+ },
40
+ },
41
+ }, {
42
+ type: 'button',
43
+ label: 'Submit',
44
+ key: 'submit',
45
+ disableOnInvalid: true,
46
+ input: true,
47
+ tableView: false,
48
+ }]
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;