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

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 (80) hide show
  1. package/README.md +24 -30
  2. package/dist/formio.builder.css +2 -0
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.js +1 -1
  5. package/dist/formio.embed.min.js +1 -1
  6. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.form.css +2 -0
  8. package/dist/formio.form.js +14 -25
  9. package/dist/formio.form.min.css +1 -1
  10. package/dist/formio.form.min.js +1 -1
  11. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  12. package/dist/formio.full.css +2 -0
  13. package/dist/formio.full.js +15 -26
  14. package/dist/formio.full.min.css +1 -1
  15. package/dist/formio.full.min.js +1 -1
  16. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  17. package/dist/formio.js +1 -1
  18. package/dist/formio.min.js +1 -1
  19. package/dist/formio.min.js.LICENSE.txt +1 -1
  20. package/dist/formio.utils.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  22. package/lib/cjs/Embed.d.ts +4 -2
  23. package/lib/cjs/Embed.js +55 -42
  24. package/lib/cjs/WebformBuilder.js +1 -1
  25. package/lib/cjs/components/_classes/component/Component.js +3 -3
  26. package/lib/cjs/components/_classes/field/Field.d.ts +1 -0
  27. package/lib/cjs/components/_classes/field/Field.js +14 -0
  28. package/lib/cjs/components/_classes/list/ListComponent.d.ts +2 -2
  29. package/lib/cjs/components/_classes/list/ListComponent.js +6 -3
  30. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
  31. package/lib/cjs/components/_classes/multivalue/Multivalue.js +0 -14
  32. package/lib/cjs/components/day/Day.d.ts +0 -1
  33. package/lib/cjs/components/day/Day.js +34 -14
  34. package/lib/cjs/components/day/fixtures/comp6.d.ts +81 -0
  35. package/lib/cjs/components/day/fixtures/comp6.js +76 -0
  36. package/lib/cjs/components/day/fixtures/index.d.ts +2 -1
  37. package/lib/cjs/components/day/fixtures/index.js +3 -1
  38. package/lib/cjs/components/radio/Radio.js +22 -12
  39. package/lib/cjs/components/select/Select.d.ts +2 -0
  40. package/lib/cjs/components/select/Select.js +6 -1
  41. package/lib/cjs/components/selectboxes/SelectBoxes.js +9 -0
  42. package/lib/cjs/components/selectboxes/fixtures/comp7.d.ts +18 -0
  43. package/lib/cjs/components/selectboxes/fixtures/comp7.js +31 -0
  44. package/lib/cjs/components/selectboxes/fixtures/index.d.ts +2 -1
  45. package/lib/cjs/components/selectboxes/fixtures/index.js +3 -1
  46. package/lib/cjs/components/signature/Signature.d.ts +1 -2
  47. package/lib/cjs/components/signature/Signature.js +1 -2
  48. package/lib/cjs/utils/ChoicesWrapper.d.ts +1 -0
  49. package/lib/cjs/utils/ChoicesWrapper.js +19 -0
  50. package/lib/cjs/utils/utils.js +3 -3
  51. package/lib/mjs/Embed.d.ts +4 -2
  52. package/lib/mjs/Embed.js +54 -43
  53. package/lib/mjs/WebformBuilder.js +1 -1
  54. package/lib/mjs/components/_classes/component/Component.js +3 -3
  55. package/lib/mjs/components/_classes/field/Field.d.ts +1 -0
  56. package/lib/mjs/components/_classes/field/Field.js +13 -0
  57. package/lib/mjs/components/_classes/list/ListComponent.d.ts +2 -2
  58. package/lib/mjs/components/_classes/list/ListComponent.js +6 -3
  59. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
  60. package/lib/mjs/components/_classes/multivalue/Multivalue.js +0 -13
  61. package/lib/mjs/components/day/Day.d.ts +0 -1
  62. package/lib/mjs/components/day/Day.js +33 -14
  63. package/lib/mjs/components/day/fixtures/comp6.d.ts +81 -0
  64. package/lib/mjs/components/day/fixtures/comp6.js +74 -0
  65. package/lib/mjs/components/day/fixtures/index.d.ts +2 -1
  66. package/lib/mjs/components/day/fixtures/index.js +2 -1
  67. package/lib/mjs/components/radio/Radio.js +22 -12
  68. package/lib/mjs/components/select/Select.d.ts +2 -0
  69. package/lib/mjs/components/select/Select.js +6 -1
  70. package/lib/mjs/components/selectboxes/SelectBoxes.js +10 -1
  71. package/lib/mjs/components/selectboxes/fixtures/comp7.d.ts +18 -0
  72. package/lib/mjs/components/selectboxes/fixtures/comp7.js +29 -0
  73. package/lib/mjs/components/selectboxes/fixtures/index.d.ts +2 -1
  74. package/lib/mjs/components/selectboxes/fixtures/index.js +2 -1
  75. package/lib/mjs/components/signature/Signature.d.ts +1 -2
  76. package/lib/mjs/components/signature/Signature.js +1 -2
  77. package/lib/mjs/utils/ChoicesWrapper.d.ts +1 -0
  78. package/lib/mjs/utils/ChoicesWrapper.js +19 -0
  79. package/lib/mjs/utils/utils.js +3 -3
  80. package/package.json +3 -4
package/lib/mjs/Embed.js CHANGED
@@ -67,7 +67,7 @@ class Formio {
67
67
  }, 100);
68
68
  });
69
69
  }
70
- static async addStyles(href, addGlobally = false) {
70
+ static async addStyles(href) {
71
71
  if (!href) {
72
72
  return;
73
73
  }
@@ -76,14 +76,6 @@ class Formio {
76
76
  return;
77
77
  }
78
78
  Formio.debug('Adding Styles', href);
79
- const link = Formio.createElement('link', {
80
- rel: 'stylesheet',
81
- href
82
- });
83
- if (addGlobally) {
84
- // Add globally as well.
85
- document.head.appendChild(link);
86
- }
87
79
  Formio.wrapper.appendChild(Formio.createElement('link', {
88
80
  rel: 'stylesheet',
89
81
  href
@@ -117,37 +109,12 @@ class Formio {
117
109
  }
118
110
  }
119
111
  }
120
- static async renderForm(form, options) {
121
- if (Formio.config.before) {
122
- await Formio.config.before(Formio.FormioClass, Formio.element, Formio.config);
123
- }
124
- Formio.FormioClass.license = true;
125
- return Formio.FormioClass.createForm(Formio.element, form, {
126
- ...options,
127
- ...{ noLoader: true }
128
- }).then((instance) => {
129
- Formio.debug('Form created', instance);
130
- // Remove the loader.
131
- Formio.debug('Removing loader');
132
- Formio.wrapper.removeChild(Formio.loader);
133
- // Set the default submission data.
134
- if (Formio.config.submission) {
135
- Formio.debug('Setting submission', Formio.config.submission);
136
- instance.submission = Formio.config.submission;
137
- }
138
- // Allow them to provide additional configs.
139
- Formio.debug('Triggering embed event');
140
- Formio.FormioClass.events.emit('formEmbedded', instance);
141
- // Trigger the after handler.
142
- if (Formio.config.after) {
143
- Formio.debug('Calling ready callback');
144
- Formio.config.after(instance, Formio.config);
145
- }
146
- return instance;
147
- });
112
+ // Return the full script if the builder is being used.
113
+ static formioScript(script, builder) {
114
+ return builder ? script.replace('formio.form', 'formio.full') : script;
148
115
  }
149
116
  // eslint-disable-next-line max-statements
150
- static async createForm(element, form, options) {
117
+ static async init(element, builder = false) {
151
118
  Formio.element = element;
152
119
  Formio.cdn = new CDN(Formio.config.cdn);
153
120
  Formio.config.libs = Formio.config.libs || {
@@ -188,7 +155,7 @@ class Formio {
188
155
  }]
189
156
  }]);
190
157
  Formio.wrapper.appendChild(Formio.loader);
191
- Formio.FormioClass = await Formio.addScript(Formio.config.script || `${Formio.cdn.js}/formio.form.min.js`, 'Formio');
158
+ Formio.FormioClass = await Formio.addScript(Formio.formioScript(Formio.config.script || `${Formio.cdn.js}/formio.form.min.js`, builder), 'Formio');
192
159
  Formio.FormioClass.setBaseUrl(Formio.baseUrl || Formio.config.base);
193
160
  Formio.FormioClass.setProjectUrl(Formio.projectUrl || Formio.config.project);
194
161
  Formio.FormioClass.language = Formio.language;
@@ -206,7 +173,7 @@ class Formio {
206
173
  await Formio.addStyles(Formio.config.libs[Formio.config.template].css);
207
174
  await Formio.addScript(Formio.config.libs[Formio.config.template].js);
208
175
  if (Formio.config.libs[Formio.config.template].fa) {
209
- await Formio.addStyles(Formio.config.libs.fontawesome.css, true);
176
+ await Formio.addStyles(Formio.config.libs.fontawesome.css);
210
177
  }
211
178
  }
212
179
  if (Formio.cdn[Formio.config.template]) {
@@ -222,7 +189,7 @@ class Formio {
222
189
  }
223
190
  // Default bootstrap + fontawesome.
224
191
  else if (Formio.config.includeLibs) {
225
- await Formio.addStyles(Formio.config.libs.fontawesome.css, true);
192
+ await Formio.addStyles(Formio.config.libs.fontawesome.css);
226
193
  await Formio.addStyles(Formio.config.libs.bootstrap.css);
227
194
  }
228
195
  if (Formio.config.premium) {
@@ -230,8 +197,52 @@ class Formio {
230
197
  Formio.debug('Using premium');
231
198
  Formio.FormioClass.use(await Formio.addScript(Formio.config.premium.js, 'premium'));
232
199
  }
233
- await Formio.addStyles(Formio.config.style || `${Formio.cdn.js}/formio.form.min.css`);
234
- return await Formio.renderForm(form, options);
200
+ await Formio.addStyles(Formio.formioScript(Formio.config.style || `${Formio.cdn.js}/formio.form.min.css`, builder));
201
+ if (Formio.config.before) {
202
+ await Formio.config.before(Formio.FormioClass, Formio.element, Formio.config);
203
+ }
204
+ Formio.FormioClass.license = true;
205
+ }
206
+ static async createForm(element, form, options) {
207
+ await Formio.init(element);
208
+ return Formio.FormioClass.createForm(Formio.element, form, {
209
+ ...options,
210
+ ...{ noLoader: true }
211
+ }).then((instance) => {
212
+ Formio.debug('Form created', instance);
213
+ // Remove the loader.
214
+ Formio.debug('Removing loader');
215
+ Formio.wrapper.removeChild(Formio.loader);
216
+ // Set the default submission data.
217
+ if (Formio.config.submission) {
218
+ Formio.debug('Setting submission', Formio.config.submission);
219
+ instance.submission = Formio.config.submission;
220
+ }
221
+ // Allow them to provide additional configs.
222
+ Formio.debug('Triggering embed event');
223
+ Formio.FormioClass.events.emit('formEmbedded', instance);
224
+ // Trigger the after handler.
225
+ if (Formio.config.after) {
226
+ Formio.debug('Calling ready callback');
227
+ Formio.config.after(instance, Formio.config);
228
+ }
229
+ return instance;
230
+ });
231
+ }
232
+ static async builder(element, form, options) {
233
+ await Formio.init(element, true);
234
+ return Formio.FormioClass.builder(Formio.element, form, options).then((instance) => {
235
+ Formio.debug('Builder created', instance);
236
+ Formio.debug('Removing loader');
237
+ Formio.wrapper.removeChild(Formio.loader);
238
+ Formio.debug('Triggering embed event');
239
+ Formio.FormioClass.events.emit('builderEmbedded', instance);
240
+ if (Formio.config.after) {
241
+ Formio.debug('Calling ready callback');
242
+ Formio.config.after(instance, Formio.config);
243
+ }
244
+ return instance;
245
+ });
235
246
  }
236
247
  }
237
248
  export { Formio };
@@ -1028,7 +1028,7 @@ export default class WebformBuilder extends Component {
1028
1028
  return false;
1029
1029
  });
1030
1030
  });
1031
- if (tabIndex !== -1 && index !== -1 && changed && changed.value) {
1031
+ if (tabIndex !== -1 && index !== -1 && changed && !_.isNil(changed.value)) {
1032
1032
  const sibling = parentComponent.tabs[tabIndex][index + 1];
1033
1033
  parentComponent.removeComponent(defaultValueComponent);
1034
1034
  const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
@@ -1506,16 +1506,16 @@ export default class Component extends Element {
1506
1506
  if (this.refs.input?.length) {
1507
1507
  const { selection, index } = this.root.currentSelection;
1508
1508
  let input = this.refs.input[index];
1509
- const isInputRangeSelectable = /text|search|password|tel|url/i.test(input.type || '');
1509
+ const isInputRangeSelectable = (i) => /text|search|password|tel|url/i.test(i?.type || '');
1510
1510
  if (input) {
1511
- if (isInputRangeSelectable) {
1511
+ if (isInputRangeSelectable(input)) {
1512
1512
  input.setSelectionRange(...selection);
1513
1513
  }
1514
1514
  }
1515
1515
  else {
1516
1516
  input = this.refs.input[this.refs.input.length];
1517
1517
  const lastCharacter = input.value?.length || 0;
1518
- if (isInputRangeSelectable) {
1518
+ if (isInputRangeSelectable(input)) {
1519
1519
  input.setSelectionRange(lastCharacter, lastCharacter);
1520
1520
  }
1521
1521
  }
@@ -1,4 +1,5 @@
1
1
  export default class Field extends Component {
2
2
  render(element: any): any;
3
+ saveCaretPosition(element: any, index: any): void;
3
4
  }
4
5
  import Component from '../component/Component';
@@ -18,4 +18,17 @@ export default class Field extends Component {
18
18
  }));
19
19
  }
20
20
  }
21
+ // Saves current caret position to restore it after the component is redrawn
22
+ saveCaretPosition(element, index) {
23
+ if (this.root?.focusedComponent?.path === this.path) {
24
+ try {
25
+ this.root.currentSelection = { selection: [element.selectionStart, element.selectionEnd], index };
26
+ }
27
+ catch (e) {
28
+ if (!(e instanceof DOMException)) {
29
+ console.debug(e);
30
+ }
31
+ }
32
+ }
33
+ }
21
34
  }
@@ -8,8 +8,8 @@ export default class ListComponent extends Field {
8
8
  setItems(): void;
9
9
  updateCustomItems(): void;
10
10
  loadItems(): void;
11
- getOptionTemplate(data: any, value: any): any;
12
- itemTemplate(data: any, value: any): any;
11
+ getOptionTemplate(data: any, value: any, index: any): any;
12
+ itemTemplate(data: any, value: any, index: any): any;
13
13
  handleLoadingError(err: any): void;
14
14
  loading: boolean | undefined;
15
15
  networkError: boolean | undefined;
@@ -78,7 +78,7 @@ export default class ListComponent extends Field {
78
78
  setItems() { }
79
79
  updateCustomItems() { }
80
80
  loadItems() { }
81
- getOptionTemplate(data, value) {
81
+ getOptionTemplate(data, value, index) {
82
82
  if (!this.component.template) {
83
83
  return data.label;
84
84
  }
@@ -94,13 +94,16 @@ export default class ListComponent extends Field {
94
94
  // If the value is not an object, then we need to save the template data off for when it is selected.
95
95
  this.templateData[templateValue] = options.data.item;
96
96
  }
97
+ if (_.isNumber(index)) {
98
+ this.templateData[index] = options.data.item;
99
+ }
97
100
  return template;
98
101
  }
99
- itemTemplate(data, value) {
102
+ itemTemplate(data, value, index) {
100
103
  if (_.isEmpty(data)) {
101
104
  return '';
102
105
  }
103
- const template = this.sanitize(this.getOptionTemplate(data, value), this.shouldSanitizeValue);
106
+ const template = this.sanitize(this.getOptionTemplate(data, value, index), this.shouldSanitizeValue);
104
107
  if (template) {
105
108
  const label = template.replace(/<\/?[^>]+(>|$)/g, '');
106
109
  if (!label)
@@ -12,7 +12,6 @@ export default class Multivalue extends Field {
12
12
  * @param index
13
13
  */
14
14
  attachElement(element: any, index: any): void;
15
- saveCaretPosition(element: any, index: any): void;
16
15
  onSelectMaskHandler(event: any): void;
17
16
  getMaskPattern(maskName: any): any;
18
17
  multiMasks: {} | undefined;
@@ -177,19 +177,6 @@ export default class Multivalue extends Field {
177
177
  }
178
178
  }
179
179
  }
180
- // Saves current caret position to restore it after the component is redrawn
181
- saveCaretPosition(element, index) {
182
- if (this.root?.focusedComponent?.path === this.path) {
183
- try {
184
- this.root.currentSelection = { selection: [element.selectionStart, element.selectionEnd], index };
185
- }
186
- catch (e) {
187
- if (!(e instanceof DOMException)) {
188
- console.debug(e);
189
- }
190
- }
191
- }
192
- }
193
180
  onSelectMaskHandler(event) {
194
181
  this.updateMask(event.target.maskInput, this.getMaskPattern(event.target.value));
195
182
  }
@@ -157,7 +157,6 @@ export default class DayComponent extends Field {
157
157
  * @return {null}
158
158
  */
159
159
  getValueAsString(value: any): null;
160
- focus(): void;
161
160
  isPartialDay(value: any): boolean;
162
161
  getValidationFormat(): "DD-MM-YYYY" | "MM-DD-YYYY";
163
162
  }
@@ -1,7 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import moment from 'moment';
3
3
  import Field from '../_classes/field/Field';
4
- import Input from '../_classes/input/Input';
5
4
  import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils/utils';
6
5
  export default class DayComponent extends Field {
7
6
  static schema(...extend) {
@@ -256,6 +255,17 @@ export default class DayComponent extends Field {
256
255
  attach(element) {
257
256
  this.loadRefs(element, { day: 'single', month: 'single', year: 'single', input: 'multiple' });
258
257
  const superAttach = super.attach(element);
258
+ const updateValueAndSaveFocus = (element, name) => () => {
259
+ try {
260
+ this.saveCaretPosition(element, name);
261
+ }
262
+ catch (err) {
263
+ console.warn('An error occurred while trying to save caret position', err);
264
+ }
265
+ this.updateValue(null, {
266
+ modified: true,
267
+ });
268
+ };
259
269
  if (this.shouldDisabled) {
260
270
  this.setDisabled(this.refs.day, true);
261
271
  this.setDisabled(this.refs.month, true);
@@ -265,9 +275,7 @@ export default class DayComponent extends Field {
265
275
  }
266
276
  }
267
277
  else {
268
- this.addEventListener(this.refs.day, 'input', () => this.updateValue(null, {
269
- modified: true
270
- }));
278
+ this.addEventListener(this.refs.day, 'input', updateValueAndSaveFocus(this.refs.day, 'day'));
271
279
  // TODO: Need to rework this to work with day select as well.
272
280
  // Change day max input when month changes.
273
281
  this.addEventListener(this.refs.month, 'input', () => {
@@ -280,18 +288,14 @@ export default class DayComponent extends Field {
280
288
  if (maxDay && day > maxDay) {
281
289
  this.refs.day.value = this.refs.day.max;
282
290
  }
283
- this.updateValue(null, {
284
- modified: true
285
- });
291
+ updateValueAndSaveFocus(this.refs.month, 'month')();
286
292
  });
287
- this.addEventListener(this.refs.year, 'input', () => this.updateValue(null, {
288
- modified: true
289
- }));
293
+ this.addEventListener(this.refs.year, 'input', updateValueAndSaveFocus(this.refs.year, 'year'));
290
294
  this.addEventListener(this.refs.input, this.info.changeEvent, () => this.updateValue(null, {
291
295
  modified: true
292
296
  }));
293
- [this.refs.day, this.refs.month, this.refs.year].forEach((element) => {
294
- Input.prototype.addFocusBlurEvents.call(this, element);
297
+ [this.refs.day, this.refs.month, this.refs.year].filter((element) => !!element).forEach((element) => {
298
+ super.addFocusBlurEvents(element);
295
299
  });
296
300
  }
297
301
  this.setValue(this.dataValue);
@@ -524,8 +528,11 @@ export default class DayComponent extends Field {
524
528
  getValueAsString(value) {
525
529
  return this.getDate(value) || '';
526
530
  }
527
- focus() {
528
- if (this.dayFirst && this.showDay || !this.dayFirst && !this.showMonth && this.showDay) {
531
+ focus(field) {
532
+ if (field && typeof field === 'string' && this.refs[field]) {
533
+ this.refs[field].focus();
534
+ }
535
+ else if (this.dayFirst && this.showDay || !this.dayFirst && !this.showMonth && this.showDay) {
529
536
  this.refs.day?.focus();
530
537
  }
531
538
  else if (this.dayFirst && !this.showDay && this.showMonth || !this.dayFirst && this.showMonth) {
@@ -535,6 +542,18 @@ export default class DayComponent extends Field {
535
542
  this.refs.year?.focus();
536
543
  }
537
544
  }
545
+ restoreCaretPosition() {
546
+ if (this.root?.currentSelection) {
547
+ const { selection, index } = this.root.currentSelection;
548
+ if (this.refs[index]) {
549
+ const input = this.refs[index];
550
+ const isInputRangeSelectable = (i) => /text|search|password|tel|url/i.test(i?.type || '');
551
+ if (isInputRangeSelectable(input)) {
552
+ input.setSelectionRange(...selection);
553
+ }
554
+ }
555
+ }
556
+ }
538
557
  isPartialDay(value) {
539
558
  if (!value) {
540
559
  return false;
@@ -0,0 +1,81 @@
1
+ declare namespace _default {
2
+ const type: string;
3
+ const display: string;
4
+ const components: ({
5
+ label: string;
6
+ applyMaskOn: string;
7
+ tableView: boolean;
8
+ key: string;
9
+ type: string;
10
+ input: boolean;
11
+ hideInputLabels?: undefined;
12
+ inputsLabelPosition?: undefined;
13
+ useLocaleSettings?: undefined;
14
+ fields?: undefined;
15
+ defaultValue?: undefined;
16
+ logic?: undefined;
17
+ disableOnInvalid?: undefined;
18
+ } | {
19
+ label: string;
20
+ hideInputLabels: boolean;
21
+ inputsLabelPosition: string;
22
+ useLocaleSettings: boolean;
23
+ tableView: boolean;
24
+ fields: {
25
+ day: {
26
+ hide: boolean;
27
+ };
28
+ month: {
29
+ hide: boolean;
30
+ };
31
+ year: {
32
+ hide: boolean;
33
+ };
34
+ };
35
+ defaultValue: string;
36
+ key: string;
37
+ logic: {
38
+ name: string;
39
+ trigger: {
40
+ type: string;
41
+ simple: {
42
+ show: boolean;
43
+ conjunction: string;
44
+ conditions: {
45
+ component: string;
46
+ operator: string;
47
+ }[];
48
+ };
49
+ };
50
+ actions: {
51
+ name: string;
52
+ type: string;
53
+ property: {
54
+ label: string;
55
+ value: string;
56
+ type: string;
57
+ };
58
+ state: boolean;
59
+ }[];
60
+ }[];
61
+ type: string;
62
+ input: boolean;
63
+ applyMaskOn?: undefined;
64
+ disableOnInvalid?: undefined;
65
+ } | {
66
+ type: string;
67
+ label: string;
68
+ key: string;
69
+ disableOnInvalid: boolean;
70
+ input: boolean;
71
+ tableView: boolean;
72
+ applyMaskOn?: undefined;
73
+ hideInputLabels?: undefined;
74
+ inputsLabelPosition?: undefined;
75
+ useLocaleSettings?: undefined;
76
+ fields?: undefined;
77
+ defaultValue?: undefined;
78
+ logic?: undefined;
79
+ })[];
80
+ }
81
+ export default _default;
@@ -0,0 +1,74 @@
1
+ export default {
2
+ type: 'form',
3
+ display: 'form',
4
+ components: [
5
+ {
6
+ label: 'Text Field',
7
+ applyMaskOn: 'change',
8
+ tableView: true,
9
+ key: 'textField',
10
+ type: 'textfield',
11
+ input: true,
12
+ },
13
+ {
14
+ label: 'Day',
15
+ hideInputLabels: false,
16
+ inputsLabelPosition: 'top',
17
+ useLocaleSettings: false,
18
+ tableView: false,
19
+ fields: {
20
+ day: {
21
+ hide: true,
22
+ },
23
+ month: {
24
+ hide: false,
25
+ },
26
+ year: {
27
+ hide: false,
28
+ },
29
+ },
30
+ defaultValue: '00/00/0000',
31
+ key: 'day',
32
+ logic: [
33
+ {
34
+ name: 'Disable when Test is empty',
35
+ trigger: {
36
+ type: 'simple',
37
+ simple: {
38
+ show: true,
39
+ conjunction: 'all',
40
+ conditions: [
41
+ {
42
+ component: 'textField',
43
+ operator: 'isEmpty',
44
+ },
45
+ ],
46
+ },
47
+ },
48
+ actions: [
49
+ {
50
+ name: 'Disable',
51
+ type: 'property',
52
+ property: {
53
+ label: 'Disabled',
54
+ value: 'disabled',
55
+ type: 'boolean',
56
+ },
57
+ state: true,
58
+ },
59
+ ],
60
+ },
61
+ ],
62
+ type: 'day',
63
+ input: true,
64
+ },
65
+ {
66
+ type: 'button',
67
+ label: 'Submit',
68
+ key: 'submit',
69
+ disableOnInvalid: true,
70
+ input: true,
71
+ tableView: false,
72
+ },
73
+ ],
74
+ };
@@ -3,4 +3,5 @@ import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
- export { comp1, comp2, comp3, comp4, comp5 };
6
+ import comp6 from './comp6';
7
+ export { comp1, comp2, comp3, comp4, comp5, comp6 };
@@ -3,4 +3,5 @@ import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
- export { comp1, comp2, comp3, comp4, comp5 };
6
+ import comp6 from './comp6';
7
+ export { comp1, comp2, comp3, comp4, comp5, comp6 };
@@ -150,7 +150,12 @@ export default class RadioComponent extends ListComponent {
150
150
  if (!_.isString(this.dataValue)) {
151
151
  dataValue = _.toString(this.dataValue);
152
152
  }
153
- input.checked = (dataValue === input.value && (input.value || this.component.dataSrc !== 'url'));
153
+ if (this.isSelectURL && _.isObject(this.loadedOptions[index].value)) {
154
+ input.checked = _.isEqual(this.loadedOptions[index].value, this.dataValue);
155
+ }
156
+ else {
157
+ input.checked = (dataValue === input.value && (input.value || this.component.dataSrc !== 'url'));
158
+ }
154
159
  this.addEventListener(input, 'keyup', (event) => {
155
160
  if (event.key === ' ' && dataValue === input.value) {
156
161
  event.preventDefault();
@@ -180,9 +185,11 @@ export default class RadioComponent extends ListComponent {
180
185
  return this.dataValue;
181
186
  }
182
187
  let value = this.dataValue;
183
- this.refs.input.forEach((input) => {
188
+ this.refs.input.forEach((input, index) => {
184
189
  if (input.checked) {
185
- value = input.value;
190
+ value = (this.isSelectURL && _.isObject(this.loadedOptions[index].value)) ?
191
+ this.loadedOptions[index].value :
192
+ input.value;
186
193
  }
187
194
  });
188
195
  return value;
@@ -204,7 +211,10 @@ export default class RadioComponent extends ListComponent {
204
211
  return false;
205
212
  }
206
213
  getValueAsString(value) {
207
- if (!_.isString(value)) {
214
+ if (_.isObject(value)) {
215
+ value = JSON.stringify(value);
216
+ }
217
+ else if (!_.isString(value)) {
208
218
  value = _.toString(value);
209
219
  }
210
220
  if (this.component.dataSrc !== 'values') {
@@ -226,7 +236,7 @@ export default class RadioComponent extends ListComponent {
226
236
  if (this.optionsLoaded) {
227
237
  return;
228
238
  }
229
- if (!this.shouldLoad) {
239
+ if (!this.shouldLoad && this.listData) {
230
240
  this.loadItemsFromMetadata();
231
241
  return;
232
242
  }
@@ -257,7 +267,7 @@ export default class RadioComponent extends ListComponent {
257
267
  this.loadedOptions[i] = {
258
268
  label: this.itemTemplate(item)
259
269
  };
260
- if (_.isEqual(item, this.selectData)) {
270
+ if (_.isEqual(item, this.selectData || _.pick(this.dataValue, _.keys(item)))) {
261
271
  this.loadedOptions[i].value = this.dataValue;
262
272
  }
263
273
  });
@@ -268,13 +278,13 @@ export default class RadioComponent extends ListComponent {
268
278
  const listData = [];
269
279
  items?.forEach((item, i) => {
270
280
  this.loadedOptions[i] = {
271
- value: item[this.component.valueProperty],
272
- label: this.itemTemplate(item, item[this.component.valueProperty])
281
+ value: this.component.valueProperty ? item[this.component.valueProperty] : item,
282
+ label: this.component.valueProperty ? this.itemTemplate(item, item[this.component.valueProperty]) : this.itemTemplate(item, item, i)
273
283
  };
274
- listData.push(this.templateData[item[this.component.valueProperty]]);
275
- if (_.isUndefined(item[this.component.valueProperty]) ||
276
- _.isObject(item[this.component.valueProperty]) ||
277
- (!this.isRadio && _.isBoolean(item[this.component.valueProperty]))) {
284
+ listData.push(this.templateData[this.component.valueProperty ? item[this.component.valueProperty] : i]);
285
+ if ((this.component.valueProperty || !this.isRadio) && (_.isUndefined(item[this.component.valueProperty]) ||
286
+ (!this.isRadio && _.isObject(item[this.component.valueProperty])) ||
287
+ (!this.isRadio && _.isBoolean(item[this.component.valueProperty])))) {
278
288
  this.loadedOptions[i].invalid = true;
279
289
  }
280
290
  });
@@ -63,6 +63,7 @@ export default class SelectComponent extends ListComponent {
63
63
  value: any;
64
64
  label: any;
65
65
  };
66
+ itemTemplate(data: any, value: any): any;
66
67
  /**
67
68
  * Adds an option to the select dropdown.
68
69
  *
@@ -102,6 +103,7 @@ export default class SelectComponent extends ListComponent {
102
103
  focusableElement: any;
103
104
  choices: Choices | null | undefined;
104
105
  scrollList: any;
106
+ isRemoveButtonPressed: boolean | undefined;
105
107
  get isLoadingAvailable(): any;
106
108
  onScroll(): void;
107
109
  attachRefreshOnBlur(): void;
@@ -429,7 +429,7 @@ export default class SelectComponent extends ListComponent {
429
429
  const searching = fromSearch && this.choices?.input?.isFocussed;
430
430
  if (!searching) {
431
431
  // If a value is provided, then select it.
432
- if (!this.isEmpty()) {
432
+ if (!this.isEmpty() || this.isRemoveButtonPressed) {
433
433
  this.setValue(this.dataValue, {
434
434
  noUpdateEvent: true
435
435
  });
@@ -843,6 +843,11 @@ export default class SelectComponent extends ListComponent {
843
843
  this.scrollList = this.choices.choiceList.element;
844
844
  this.addEventListener(this.scrollList, 'scroll', () => this.onScroll());
845
845
  }
846
+ if (choicesOptions.removeItemButton) {
847
+ this.addEventListener(input, 'removeItem', () => {
848
+ this.isRemoveButtonPressed = true;
849
+ });
850
+ }
846
851
  }
847
852
  this.focusableElement.setAttribute('tabIndex', tabIndex);
848
853
  // If a search field is provided, then add an event listener to update items on search.