@genesislcap/foundation-forms 14.70.3 → 14.70.4-es2021.1

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.
@@ -118,6 +118,117 @@
118
118
  "name": "reset",
119
119
  "description": "Reset the form state",
120
120
  "privacy": "public"
121
+ },
122
+ {
123
+ "kind": "field",
124
+ "name": "_presentation",
125
+ "type": {
126
+ "text": "ComponentPresentation | null | undefined"
127
+ },
128
+ "privacy": "private",
129
+ "default": "void 0",
130
+ "inheritedFrom": {
131
+ "name": "FoundationElement",
132
+ "module": "src/foundation-element/foundation-element.ts"
133
+ }
134
+ },
135
+ {
136
+ "kind": "field",
137
+ "name": "$presentation",
138
+ "type": {
139
+ "text": "ComponentPresentation | null"
140
+ },
141
+ "privacy": "public",
142
+ "description": "A property which resolves the ComponentPresentation instance\nfor the current component.",
143
+ "inheritedFrom": {
144
+ "name": "FoundationElement",
145
+ "module": "src/foundation-element/foundation-element.ts"
146
+ }
147
+ },
148
+ {
149
+ "kind": "field",
150
+ "name": "template",
151
+ "type": {
152
+ "text": "ElementViewTemplate | void | null"
153
+ },
154
+ "privacy": "public",
155
+ "description": "Sets the template of the element instance. When undefined,\nthe element will attempt to resolve the template from\nthe associated presentation or custom element definition.",
156
+ "inheritedFrom": {
157
+ "name": "FoundationElement",
158
+ "module": "src/foundation-element/foundation-element.ts"
159
+ }
160
+ },
161
+ {
162
+ "kind": "method",
163
+ "name": "templateChanged",
164
+ "privacy": "protected",
165
+ "return": {
166
+ "type": {
167
+ "text": "void"
168
+ }
169
+ },
170
+ "inheritedFrom": {
171
+ "name": "FoundationElement",
172
+ "module": "src/foundation-element/foundation-element.ts"
173
+ }
174
+ },
175
+ {
176
+ "kind": "field",
177
+ "name": "styles",
178
+ "type": {
179
+ "text": "ElementStyles | void | null"
180
+ },
181
+ "privacy": "public",
182
+ "description": "Sets the default styles for the element instance. When undefined,\nthe element will attempt to resolve default styles from\nthe associated presentation or custom element definition.",
183
+ "inheritedFrom": {
184
+ "name": "FoundationElement",
185
+ "module": "src/foundation-element/foundation-element.ts"
186
+ }
187
+ },
188
+ {
189
+ "kind": "method",
190
+ "name": "stylesChanged",
191
+ "privacy": "protected",
192
+ "return": {
193
+ "type": {
194
+ "text": "void"
195
+ }
196
+ },
197
+ "inheritedFrom": {
198
+ "name": "FoundationElement",
199
+ "module": "src/foundation-element/foundation-element.ts"
200
+ }
201
+ },
202
+ {
203
+ "kind": "method",
204
+ "name": "compose",
205
+ "privacy": "public",
206
+ "static": true,
207
+ "return": {
208
+ "type": {
209
+ "text": "(\n overrideDefinition?: OverrideFoundationElementDefinition<T>\n ) => FoundationElementRegistry<T, K>"
210
+ }
211
+ },
212
+ "parameters": [
213
+ {
214
+ "name": "this",
215
+ "type": {
216
+ "text": "K"
217
+ }
218
+ },
219
+ {
220
+ "name": "elementDefinition",
221
+ "type": {
222
+ "text": "T"
223
+ },
224
+ "description": "The definition of the element to create the registry\nfunction for."
225
+ }
226
+ ],
227
+ "description": "Defines an element registry function with a set of element definition defaults.",
228
+ "inheritedFrom": {
229
+ "name": "FoundationElement",
230
+ "module": "src/foundation-element/foundation-element.ts"
231
+ }
121
232
  }
122
233
  ],
123
234
  "attributes": [
@@ -374,6 +485,117 @@
374
485
  {
375
486
  "kind": "method",
376
487
  "name": "valueChanged"
488
+ },
489
+ {
490
+ "kind": "field",
491
+ "name": "_presentation",
492
+ "type": {
493
+ "text": "ComponentPresentation | null | undefined"
494
+ },
495
+ "privacy": "private",
496
+ "default": "void 0",
497
+ "inheritedFrom": {
498
+ "name": "FoundationElement",
499
+ "module": "src/foundation-element/foundation-element.ts"
500
+ }
501
+ },
502
+ {
503
+ "kind": "field",
504
+ "name": "$presentation",
505
+ "type": {
506
+ "text": "ComponentPresentation | null"
507
+ },
508
+ "privacy": "public",
509
+ "description": "A property which resolves the ComponentPresentation instance\nfor the current component.",
510
+ "inheritedFrom": {
511
+ "name": "FoundationElement",
512
+ "module": "src/foundation-element/foundation-element.ts"
513
+ }
514
+ },
515
+ {
516
+ "kind": "field",
517
+ "name": "template",
518
+ "type": {
519
+ "text": "ElementViewTemplate | void | null"
520
+ },
521
+ "privacy": "public",
522
+ "description": "Sets the template of the element instance. When undefined,\nthe element will attempt to resolve the template from\nthe associated presentation or custom element definition.",
523
+ "inheritedFrom": {
524
+ "name": "FoundationElement",
525
+ "module": "src/foundation-element/foundation-element.ts"
526
+ }
527
+ },
528
+ {
529
+ "kind": "method",
530
+ "name": "templateChanged",
531
+ "privacy": "protected",
532
+ "return": {
533
+ "type": {
534
+ "text": "void"
535
+ }
536
+ },
537
+ "inheritedFrom": {
538
+ "name": "FoundationElement",
539
+ "module": "src/foundation-element/foundation-element.ts"
540
+ }
541
+ },
542
+ {
543
+ "kind": "field",
544
+ "name": "styles",
545
+ "type": {
546
+ "text": "ElementStyles | void | null"
547
+ },
548
+ "privacy": "public",
549
+ "description": "Sets the default styles for the element instance. When undefined,\nthe element will attempt to resolve default styles from\nthe associated presentation or custom element definition.",
550
+ "inheritedFrom": {
551
+ "name": "FoundationElement",
552
+ "module": "src/foundation-element/foundation-element.ts"
553
+ }
554
+ },
555
+ {
556
+ "kind": "method",
557
+ "name": "stylesChanged",
558
+ "privacy": "protected",
559
+ "return": {
560
+ "type": {
561
+ "text": "void"
562
+ }
563
+ },
564
+ "inheritedFrom": {
565
+ "name": "FoundationElement",
566
+ "module": "src/foundation-element/foundation-element.ts"
567
+ }
568
+ },
569
+ {
570
+ "kind": "method",
571
+ "name": "compose",
572
+ "privacy": "public",
573
+ "static": true,
574
+ "return": {
575
+ "type": {
576
+ "text": "(\n overrideDefinition?: OverrideFoundationElementDefinition<T>\n ) => FoundationElementRegistry<T, K>"
577
+ }
578
+ },
579
+ "parameters": [
580
+ {
581
+ "name": "this",
582
+ "type": {
583
+ "text": "K"
584
+ }
585
+ },
586
+ {
587
+ "name": "elementDefinition",
588
+ "type": {
589
+ "text": "T"
590
+ },
591
+ "description": "The definition of the element to create the registry\nfunction for."
592
+ }
593
+ ],
594
+ "description": "Defines an element registry function with a set of element definition defaults.",
595
+ "inheritedFrom": {
596
+ "name": "FoundationElement",
597
+ "module": "src/foundation-element/foundation-element.ts"
598
+ }
377
599
  }
378
600
  ],
379
601
  "events": [
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { Connect } from '@genesislcap/foundation-comms';
3
3
  import { CriteriaBuilder, Join } from '@genesislcap/foundation-criteria';
4
4
  import { createLogger } from '@genesislcap/foundation-utils';
@@ -64,16 +64,13 @@ let Filters = class Filters extends FoundationElement {
64
64
  */
65
65
  this.data = {};
66
66
  }
67
- resourceNameChanged() {
68
- var _a, _b, _c;
69
- return __awaiter(this, void 0, void 0, function* () {
70
- this.jsonSchema = undefined;
71
- if (this.resourceName) {
72
- const jsonSchemaResponse = yield this.connect.getJSONSchema(this.resourceName);
73
- this.jsonSchema = (_b = (_a = jsonSchemaResponse === null || jsonSchemaResponse === void 0 ? void 0 : jsonSchemaResponse.OUTBOUND) === null || _a === void 0 ? void 0 : _a.$defs) === null || _b === void 0 ? void 0 : _b['global.genesis.message.core.dataserver.QueryRow'];
74
- (_c = this.jsonSchema) === null || _c === void 0 ? true : delete _c.properties['DETAILS'];
75
- }
76
- });
67
+ async resourceNameChanged() {
68
+ this.jsonSchema = undefined;
69
+ if (this.resourceName) {
70
+ const jsonSchemaResponse = await this.connect.getJSONSchema(this.resourceName);
71
+ this.jsonSchema = jsonSchemaResponse?.OUTBOUND?.$defs?.['global.genesis.message.core.dataserver.QueryRow'];
72
+ delete this.jsonSchema?.properties['DETAILS'];
73
+ }
77
74
  }
78
75
  clearFiltersData() {
79
76
  this.data = {};
@@ -87,7 +84,7 @@ let Filters = class Filters extends FoundationElement {
87
84
  */
88
85
  searchFilters() {
89
86
  this.value = '';
90
- const payload = Object.assign({}, this.data);
87
+ const payload = { ...this.data };
91
88
  const expressions = createExpressions(payload);
92
89
  const criteriaBuilder = new CriteriaBuilder();
93
90
  filtersLogger.debug({ payload });
package/dist/esm/form.js CHANGED
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { Connect } from '@genesislcap/foundation-comms';
3
3
  import { createLogger } from '@genesislcap/foundation-utils';
4
4
  import { isControl, isStringControl, mapStateToControlProps, rankWith, } from '@jsonforms/core';
@@ -71,15 +71,12 @@ let Form = class Form extends FoundationElement {
71
71
  */
72
72
  this.data = {};
73
73
  }
74
- resourceNameChanged() {
75
- var _a, _b;
76
- return __awaiter(this, void 0, void 0, function* () {
77
- this.jsonSchema = undefined;
78
- if (this.resourceName) {
79
- const jsonSchemaResponse = yield this.connect.getJSONSchema(this.resourceName);
80
- this.jsonSchema = (_b = (_a = jsonSchemaResponse === null || jsonSchemaResponse === void 0 ? void 0 : jsonSchemaResponse.INBOUND) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.DETAILS;
81
- }
82
- });
74
+ async resourceNameChanged() {
75
+ this.jsonSchema = undefined;
76
+ if (this.resourceName) {
77
+ const jsonSchemaResponse = await this.connect.getJSONSchema(this.resourceName);
78
+ this.jsonSchema = jsonSchemaResponse?.INBOUND?.properties?.DETAILS;
79
+ }
83
80
  }
84
81
  removeDataProperties() {
85
82
  if (!this.jsonSchema || !this.data) {
@@ -97,37 +94,35 @@ let Form = class Form extends FoundationElement {
97
94
  });
98
95
  // force update of the data object to trigger error validation
99
96
  if (removedPropertiesCount > 0) {
100
- this.data = Object.assign({}, this.data);
97
+ this.data = { ...this.data };
101
98
  }
102
99
  return removedPropertiesCount > 0;
103
100
  }
104
101
  /**
105
102
  * @internal
106
103
  */
107
- _submit() {
108
- return __awaiter(this, void 0, void 0, function* () {
109
- if (this.submitting) {
110
- return;
111
- }
112
- if (this.removeDataProperties()) {
113
- yield DOM.nextUpdate();
104
+ async _submit() {
105
+ if (this.submitting) {
106
+ return;
107
+ }
108
+ if (this.removeDataProperties()) {
109
+ await DOM.nextUpdate();
110
+ }
111
+ this.submitted = true;
112
+ const payload = { ...this.data };
113
+ logger.debug({ payload, errors: this.errors });
114
+ this.$emit('submit', { payload, errors: this.errors });
115
+ if (Object.entries(payload).length !== 0 && this.resourceName) {
116
+ this.submitting = true;
117
+ const formSubmitReq = await this.connect.commitEvent(this.resourceName, { DETAILS: payload });
118
+ this.submitting = false;
119
+ if (formSubmitReq.ERROR) {
120
+ this.$emit('submit-failure', { payload, errors: formSubmitReq.ERROR });
114
121
  }
115
- this.submitted = true;
116
- const payload = Object.assign({}, this.data);
117
- logger.debug({ payload, errors: this.errors });
118
- this.$emit('submit', { payload, errors: this.errors });
119
- if (Object.entries(payload).length !== 0 && this.resourceName) {
120
- this.submitting = true;
121
- const formSubmitReq = yield this.connect.commitEvent(this.resourceName, { DETAILS: payload });
122
- this.submitting = false;
123
- if (formSubmitReq.ERROR) {
124
- this.$emit('submit-failure', { payload, errors: formSubmitReq.ERROR });
125
- }
126
- else {
127
- this.$emit('submit-success', { payload });
128
- }
122
+ else {
123
+ this.$emit('submit-success', { payload });
129
124
  }
130
- });
125
+ }
131
126
  }
132
127
  /**
133
128
  * @internal
@@ -15,14 +15,16 @@ const template = html `
15
15
  </template>
16
16
  `;
17
17
  const errorTranslator = (error, t, uischema) => {
18
- var _a, _b, _c, _d;
19
- return ((_d = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.i18n) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c[error.keyword]) !== null && _d !== void 0 ? _d : genesisErrorTranslator(error, t, uischema));
18
+ return (uischema?.options?.i18n?.error?.[error.keyword] ?? genesisErrorTranslator(error, t, uischema));
20
19
  };
21
20
  let JSONForms = class JSONForms extends FASTElement {
22
21
  constructor() {
23
22
  super(...arguments);
24
23
  this.dispatch = (action) => {
25
- this.jsonforms = Object.assign(Object.assign({}, this.jsonforms), { core: coreReducer(this.jsonforms.core, action) });
24
+ this.jsonforms = {
25
+ ...this.jsonforms,
26
+ core: coreReducer(this.jsonforms.core, action),
27
+ };
26
28
  this.$emit('data-change', {
27
29
  data: this.jsonforms.core.data,
28
30
  errors: this.jsonforms.core.errors,
@@ -34,19 +36,17 @@ let JSONForms = class JSONForms extends FASTElement {
34
36
  * @returns ErrorObject[] that will be passed to JsonFormsCore as additionalErrors
35
37
  */
36
38
  this.validate = (uischema) => {
37
- var _a, _b, _c;
38
- const data = (_b = (_a = this.jsonforms) === null || _a === void 0 ? void 0 : _a.core) === null || _b === void 0 ? void 0 : _b.data;
39
+ const data = this.jsonforms?.core?.data;
39
40
  if (!data)
40
41
  return [];
41
42
  const errors = [];
42
- (_c = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _c === void 0 ? void 0 : _c.forEach((e) => {
43
- var _a, _b, _c, _d;
44
- const validator = (_a = e === null || e === void 0 ? void 0 : e.options) === null || _a === void 0 ? void 0 : _a.validateFn;
43
+ uischema?.elements?.forEach((e) => {
44
+ const validator = e?.options?.validateFn;
45
45
  if (typeof validator !== 'function')
46
46
  return;
47
- const path = (_c = (_b = e === null || e === void 0 ? void 0 : e.scope) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop();
48
- const label = e === null || e === void 0 ? void 0 : e.label;
49
- let newErrors = (_d = validator(data, path, label)) !== null && _d !== void 0 ? _d : [];
47
+ const path = e?.scope?.split('/')?.pop();
48
+ const label = e?.label;
49
+ let newErrors = validator(data, path, label) ?? [];
50
50
  // the validator function is supposed to return an array of errors but let's not explode if it returns a single one
51
51
  if (!Array.isArray(newErrors)) {
52
52
  newErrors = [newErrors];
@@ -57,11 +57,10 @@ let JSONForms = class JSONForms extends FASTElement {
57
57
  };
58
58
  }
59
59
  schemaChanged() {
60
- var _a, _b, _c, _d;
61
60
  if (!this.schema) {
62
61
  return;
63
62
  }
64
- const uischemaToUse = (_a = this.uischema) !== null && _a !== void 0 ? _a : Generate.uiSchema(this.schema);
63
+ const uischemaToUse = this.uischema ?? Generate.uiSchema(this.schema);
65
64
  if (!this.uischema) {
66
65
  console.log('UI schema not provided. Auto generated schema:', uischemaToUse);
67
66
  }
@@ -82,7 +81,7 @@ let JSONForms = class JSONForms extends FASTElement {
82
81
  this.jsonforms = {
83
82
  core: initCore(),
84
83
  config: configReducer(undefined, Actions.setConfig(this.config)),
85
- i18n: i18nReducer(this.i18n, Actions.updateI18n((_b = this.i18n) === null || _b === void 0 ? void 0 : _b.locale, (_c = this.i18n) === null || _c === void 0 ? void 0 : _c.translate, ((_d = this.i18n) === null || _d === void 0 ? void 0 : _d.translateError) || errorTranslator)),
84
+ i18n: i18nReducer(this.i18n, Actions.updateI18n(this.i18n?.locale, this.i18n?.translate, this.i18n?.translateError || errorTranslator)),
86
85
  renderers: this.renderers,
87
86
  readonly: this.readonly,
88
87
  };
@@ -113,11 +112,10 @@ let JSONForms = class JSONForms extends FASTElement {
113
112
  this.schemaChanged();
114
113
  }
115
114
  get props() {
116
- var _a;
117
115
  if (!this.schema && !this.uischema) {
118
116
  return undefined;
119
117
  }
120
- const uischema = (_a = this.uischema) !== null && _a !== void 0 ? _a : Generate.uiSchema(this.schema);
118
+ const uischema = this.uischema ?? Generate.uiSchema(this.schema);
121
119
  return {
122
120
  uischema,
123
121
  schema: this.schema,
@@ -62,14 +62,14 @@ let ArrayListWrapper = class ArrayListWrapper extends FASTElement {
62
62
  }
63
63
  this.schema = this.control.schema.properties[this.pathName].items;
64
64
  const arrayUiSchema = Generate.uiSchema(this.schema);
65
- this.uiSchema = Object.assign(Object.assign({}, arrayUiSchema), { type: 'HorizontalLayout' });
65
+ this.uiSchema = { ...arrayUiSchema, type: 'HorizontalLayout' };
66
66
  console.log('Auto generated uiSchema for layout array:', this.uiSchema);
67
67
  }
68
68
  addItem() {
69
69
  const items = this.control.data[this.pathName] && Object.keys(this.control.data[this.pathName]).length !== 0
70
70
  ? [...this.control.data[this.pathName], {}]
71
71
  : [{}];
72
- const data = Object.assign(Object.assign({}, this.control.data), { [this.pathName]: items });
72
+ const data = { ...this.control.data, [this.pathName]: items };
73
73
  this.$emit('data-change', {
74
74
  data,
75
75
  });
@@ -78,7 +78,7 @@ let ArrayListWrapper = class ArrayListWrapper extends FASTElement {
78
78
  const allItems = this.control.data[this.pathName];
79
79
  const valueToRemove = [allItems[index]];
80
80
  const items = allItems.filter((element) => !valueToRemove.includes(element));
81
- const data = Object.assign(Object.assign({}, this.control.data), { [this.pathName]: items });
81
+ const data = { ...this.control.data, [this.pathName]: items };
82
82
  this.$emit('data-change', {
83
83
  data,
84
84
  });
@@ -4,7 +4,7 @@ export const CategorizationWrapperRendererTemplate = (prefix = 'zero') => html `
4
4
  <template>
5
5
  <${prefix}-tabs class="tabs-container">
6
6
  ${repeat((x) => x.control.uischema.elements, html `
7
- <${prefix}-tab class="tab-control">${(x, ctx) => { var _a; return (_a = x.label) !== null && _a !== void 0 ? _a : `Category ${ctx.index + 1}`; }}</${prefix}-tab>
7
+ <${prefix}-tab class="tab-control">${(x, ctx) => x.label ?? `Category ${ctx.index + 1}`}</${prefix}-tab>
8
8
  `, { positioning: true })}
9
9
  ${repeat((x) => x.control.uischema.elements, html `
10
10
  <${prefix}-tab-panel class="tab-panel-control">
@@ -22,10 +22,10 @@ export const ConnectedMultiselectControlRendererTemplate = (prefix = 'zero') =>
22
22
  data-test-id=${(x) => x.control.path}
23
23
  >
24
24
  <multiselect-datasource
25
- resourceName=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.allOptionsResourceName; }}
26
- value-field=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.valueField; }}
27
- label-field=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.labelField; }}
28
- :datasourceConfig=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.datasourceConfig; }}
25
+ resourceName=${(x) => x.control.uischema.options?.allOptionsResourceName}
26
+ value-field=${(x) => x.control.uischema.options?.valueField}
27
+ label-field=${(x) => x.control.uischema.options?.labelField}
28
+ :datasourceConfig=${(x) => x.control.uischema.options?.datasourceConfig}
29
29
  ></multiselect-datasource>
30
30
  </${prefix}-multiselect>
31
31
  </control-wrapper>
@@ -16,8 +16,7 @@ export const ConnectedSelectControlRendererTemplate = (prefix = 'zero') => html
16
16
  placeholder=${(x) => x.control.uischema.placeholder || x.control.label}
17
17
  ?disabled=${(x) => !x.control.enabled}
18
18
  @value-change=${(x, c) => {
19
- var _a;
20
- const value = (_a = c.event.detail) === null || _a === void 0 ? void 0 : _a.value;
19
+ const value = c.event.detail?.value;
21
20
  x.control.handleChange(x.control.path, value);
22
21
  x.onBlur();
23
22
  }}
@@ -25,11 +24,11 @@ export const ConnectedSelectControlRendererTemplate = (prefix = 'zero') => html
25
24
  data-test-id=${(x) => x.control.path}
26
25
  >
27
26
  <options-datasource
28
- resourceName=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.allOptionsResourceName; }}
29
- value-field=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.valueField; }}
30
- label-field=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.labelField; }}
31
- :datasourceConfig=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.datasourceConfig; }}
32
- :data=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.data; }}
27
+ resourceName=${(x) => x.control.uischema.options?.allOptionsResourceName}
28
+ value-field=${(x) => x.control.uischema.options?.valueField}
29
+ label-field=${(x) => x.control.uischema.options?.labelField}
30
+ :datasourceConfig=${(x) => x.control.uischema.options?.datasourceConfig}
31
+ :data=${(x) => x.control.uischema.options?.data}
33
32
  :initialSelectedValue=${(x) => x.control.data}
34
33
  ></options-datasource>
35
34
  </${prefix}-combobox>
@@ -3,7 +3,7 @@ import { computeLabel, isDescriptionHidden } from '@jsonforms/core';
3
3
  import { html, css, when, observable, customElement, FASTElement, volatile, } from '@microsoft/fast-element';
4
4
  export const ControlWrapperRendererTemplate = html `
5
5
  <template>
6
- ${when((x) => { var _a; return (_a = x.control) === null || _a === void 0 ? void 0 : _a.visible; }, html `
6
+ ${when((x) => x.control?.visible, html `
7
7
  <div
8
8
  class="wrapperRoot"
9
9
  id=${(x) => x.control.path + '-wrapper'}
@@ -11,7 +11,10 @@ export const mapStateToEnumControlProps = (state, ownProps) => {
11
11
  (props.schema.const && [
12
12
  enumToEnumOptionMapper(props.schema.const, getTranslator()(state), getI18nKeyPrefix(props.schema, props.uischema, props.path)),
13
13
  ]);
14
- return Object.assign(Object.assign({}, props), { options });
14
+ return {
15
+ ...props,
16
+ options,
17
+ };
15
18
  };
16
19
  export const EnumControlRendererTemplate = (prefix = 'zero') => html `
17
20
  <template>
@@ -23,10 +26,10 @@ export const EnumControlRendererTemplate = (prefix = 'zero') => html `
23
26
  <${prefix}-combobox
24
27
  style="width: 100%"
25
28
  ?disabled=${(x) => !x.control.enabled}
26
- :value=${(x) => { var _a; return ((_a = x.control.options.find((option) => option.value === x.control.data)) === null || _a === void 0 ? void 0 : _a.label) || ''; }}
29
+ :value=${(x) => x.control.options.find((option) => option.value === x.control.data)?.label || ''}
27
30
  @change=${(x, c) => {
28
- var _a;
29
- x.control.handleChange(x.control.path, (_a = x.control.options.find((option) => option.label === c.event.target.value)) === null || _a === void 0 ? void 0 : _a.value);
31
+ x.control.handleChange(x.control.path, x.control.options.find((option) => option.label === c.event.target.value)
32
+ ?.value);
30
33
  x.onBlur();
31
34
  }}
32
35
  id=${(x) => x.control.path}
@@ -6,25 +6,21 @@ export const DateControlRendererTemplate = (prefix = 'zero') => html `
6
6
  <template>
7
7
  <control-wrapper :control=${(x) => x.control} ?submitted=${(x) => x.submitted}>
8
8
  <${prefix}-text-field
9
- :value=${(x) => {
10
- var _a, _b;
11
- return ((_a = x.control.data) === null || _a === void 0 ? void 0 : _a.min) === undefined || ((_b = x.control.data) === null || _b === void 0 ? void 0 : _b.min) === null
12
- ? ''
13
- : new Intl.DateTimeFormat('fr-CA', {
14
- year: 'numeric',
15
- month: '2-digit',
16
- day: '2-digit',
17
- }).format(x.control.data.min);
18
- }}
9
+ :value=${(x) => x.control.data?.min === undefined || x.control.data?.min === null
10
+ ? ''
11
+ : new Intl.DateTimeFormat('fr-CA', {
12
+ year: 'numeric',
13
+ month: '2-digit',
14
+ day: '2-digit',
15
+ }).format(x.control.data.min)}
19
16
  id=${(x) => `min-${x.control.path}`}
20
17
  type="date"
21
18
  data-test-id=${(x) => `min-${x.control.path}`}
22
19
  @blur=${(x, c) => {
23
- var _a, _b;
24
20
  const value = c.event.target.control.valueAsNumber;
25
21
  x.control.handleChange(x.control.path, {
26
22
  min: value ? value : undefined,
27
- max: ((_a = x.control.data) === null || _a === void 0 ? void 0 : _a.max) < value ? undefined : (_b = x.control.data) === null || _b === void 0 ? void 0 : _b.max,
23
+ max: x.control.data?.max < value ? undefined : x.control.data?.max,
28
24
  type: 'date',
29
25
  });
30
26
  x.onBlur();
@@ -32,24 +28,20 @@ export const DateControlRendererTemplate = (prefix = 'zero') => html `
32
28
  style="width: 100%"
33
29
  ></${prefix}-text-field>
34
30
  <${prefix}-text-field
35
- :value=${(x) => {
36
- var _a, _b;
37
- return ((_a = x.control.data) === null || _a === void 0 ? void 0 : _a.max) === undefined || ((_b = x.control.data) === null || _b === void 0 ? void 0 : _b.max) === null
38
- ? ''
39
- : new Intl.DateTimeFormat('fr-CA', {
40
- year: 'numeric',
41
- month: '2-digit',
42
- day: '2-digit',
43
- }).format(x.control.data.max);
44
- }}
31
+ :value=${(x) => x.control.data?.max === undefined || x.control.data?.max === null
32
+ ? ''
33
+ : new Intl.DateTimeFormat('fr-CA', {
34
+ year: 'numeric',
35
+ month: '2-digit',
36
+ day: '2-digit',
37
+ }).format(x.control.data.max)}
45
38
  id=${(x) => `max-${x.control.path}`}
46
39
  type="date"
47
40
  data-test-id=${(x) => `max-${x.control.path}`}
48
41
  @blur=${(x, c) => {
49
- var _a, _b;
50
42
  const value = c.event.target.control.valueAsNumber;
51
43
  x.control.handleChange(x.control.path, {
52
- min: ((_a = x.control.data) === null || _a === void 0 ? void 0 : _a.min) > value ? undefined : (_b = x.control.data) === null || _b === void 0 ? void 0 : _b.min,
44
+ min: x.control.data?.min > value ? undefined : x.control.data?.min,
53
45
  max: value ? value : undefined,
54
46
  type: 'date',
55
47
  });
@@ -6,17 +6,16 @@ export const FilterNumberControlRendererTemplate = (prefix = 'zero') => html `
6
6
  <template>
7
7
  <control-wrapper :control=${(x) => x.control} ?submitted=${(x) => x.submitted}>
8
8
  <${prefix}-text-field
9
- :value=${(x) => { var _a; return (((_a = x.control.data) === null || _a === void 0 ? void 0 : _a.min) === undefined ? '' : x.control.data.min); }}
9
+ :value=${(x) => (x.control.data?.min === undefined ? '' : x.control.data.min)}
10
10
  @change=${(x, c) => {
11
- var _a, _b;
12
11
  const value = parseFloat(c.event.target.value);
13
12
  return x.control.handleChange(x.control.path, !isNaN(value)
14
13
  ? {
15
14
  min: value,
16
- max: ((_a = x.control.data) === null || _a === void 0 ? void 0 : _a.max) < value ? undefined : (_b = x.control.data) === null || _b === void 0 ? void 0 : _b.max,
15
+ max: x.control.data?.max < value ? undefined : x.control.data?.max,
17
16
  type: 'number',
18
17
  }
19
- : Object.assign(Object.assign({}, x.control.data), { min: undefined }));
18
+ : { ...x.control.data, min: undefined });
20
19
  }}
21
20
  placeholder="Min"
22
21
  id=${(x) => `min-${x.control.path}`}
@@ -32,17 +31,16 @@ export const FilterNumberControlRendererTemplate = (prefix = 'zero') => html `
32
31
  -
33
32
  </span>
34
33
  <${prefix}-text-field
35
- :value=${(x) => { var _a; return (((_a = x.control.data) === null || _a === void 0 ? void 0 : _a.max) === undefined ? '' : x.control.data.max); }}
34
+ :value=${(x) => (x.control.data?.max === undefined ? '' : x.control.data.max)}
36
35
  @change=${(x, c) => {
37
- var _a, _b;
38
36
  const value = parseFloat(c.event.target.value);
39
37
  return x.control.handleChange(x.control.path, !isNaN(value)
40
38
  ? {
41
- min: ((_a = x.control.data) === null || _a === void 0 ? void 0 : _a.min) > value ? undefined : (_b = x.control.data) === null || _b === void 0 ? void 0 : _b.min,
39
+ min: x.control.data?.min > value ? undefined : x.control.data?.min,
42
40
  max: value,
43
41
  type: 'number',
44
42
  }
45
- : Object.assign(Object.assign({}, x.control.data), { max: undefined }));
43
+ : { ...x.control.data, max: undefined });
46
44
  }}
47
45
  placeholder="Max"
48
46
  id=${(x) => `max-${x.control.path}`}
@@ -10,8 +10,8 @@ export const NumberControlRendererTemplate = (prefix = 'zero') => html `
10
10
  ?submitted=${(x) => x.submitted}
11
11
  >
12
12
  <${prefix}-number-field
13
- withFormatting=${(x) => { var _a; return (((_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.withoutFormatting) ? false : true); }}
14
- :options=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.formatOptions; }}
13
+ withFormatting=${(x) => (x.control.uischema.options?.withoutFormatting ? false : true)}
14
+ :options=${(x) => x.control.uischema.options?.formatOptions}
15
15
  :value=${(x) => (x.control.data === undefined ? '' : String(x.control.data))}
16
16
  @change=${(x, c) => {
17
17
  const value = parseFloat(c.event.target.value);
@@ -8,7 +8,7 @@ export const getStringControlRendererTemplate = (prefix = 'zero') => html `
8
8
  ?submitted=${(x) => x.submitted}
9
9
  >
10
10
  <${prefix}-text-field
11
- type=${(x) => { var _a, _b; return (((_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.isPassword) ? 'password' : 'text'); }}
11
+ type=${(x) => (x.control.uischema?.options?.isPassword ? 'password' : 'text')}
12
12
  :value=${(x) => x.control.data || ''}
13
13
  @change=${(x, c) => {
14
14
  const inputValue = c.event.target.value;
@@ -1,4 +1,4 @@
1
- import { __decorate, __rest } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { mapDispatchToControlProps, mapStateToJsonFormsRendererProps } from '@jsonforms/core';
3
3
  import { FASTElement, html, css, observable, attr, customElement } from '@microsoft/fast-element';
4
4
  import maxBy from 'lodash/maxBy';
@@ -7,9 +7,14 @@ const template = html `
7
7
  `;
8
8
  const styles = css ``;
9
9
  const useControl = (props, jsonforms, dispatch, stateMapper) => {
10
- const control = Object.assign({}, stateMapper({ jsonforms }, props));
11
- const dispatchMethods = mapDispatchToControlProps === null || mapDispatchToControlProps === void 0 ? void 0 : mapDispatchToControlProps(dispatch);
12
- return Object.assign(Object.assign({}, control), dispatchMethods);
10
+ const control = {
11
+ ...stateMapper({ jsonforms }, props),
12
+ };
13
+ const dispatchMethods = mapDispatchToControlProps?.(dispatch);
14
+ return {
15
+ ...control,
16
+ ...dispatchMethods,
17
+ };
13
18
  };
14
19
  let DispatchRenderer = class DispatchRenderer extends FASTElement {
15
20
  constructor() {
@@ -19,7 +24,7 @@ let DispatchRenderer = class DispatchRenderer extends FASTElement {
19
24
  return;
20
25
  }
21
26
  const rawProps = mapStateToJsonFormsRendererProps({ jsonforms: this.jsonforms }, this.props);
22
- const { rootSchema } = rawProps, renderer = __rest(rawProps, ["rootSchema"]);
27
+ const { rootSchema, ...renderer } = rawProps;
23
28
  this.renderer = renderer;
24
29
  this.control = useControl(this.props, this.jsonforms, this.dispatch,
25
30
  // @ts-ignore
@@ -1,4 +1,3 @@
1
1
  export const isInvisible = (uischema, schema, context) => {
2
- var _a, _b;
3
- return (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.hidden) !== null && _b !== void 0 ? _b : false;
2
+ return uischema?.options?.hidden ?? false;
4
3
  };
@@ -61,14 +61,14 @@ const dateNumberExpressions = (key, value, type) => {
61
61
  const startExpression = value.min
62
62
  ? new ExpressionBuilder()
63
63
  .withField(key)
64
- .withValue(startDay !== null && startDay !== void 0 ? startDay : value.min)
64
+ .withValue(startDay ?? value.min)
65
65
  .withSerialiser(startDay ? Serialisers.dateIsGreaterEqual : Serialisers.GE)
66
66
  .build()
67
67
  : undefined;
68
68
  const endExpression = value.max
69
69
  ? new ExpressionBuilder()
70
70
  .withField(key)
71
- .withValue(endDay !== null && endDay !== void 0 ? endDay : value.max)
71
+ .withValue(endDay ?? value.max)
72
72
  .withSerialiser(endDay ? Serialisers.dateIsLessEqual : Serialisers.LE)
73
73
  .build()
74
74
  : undefined;
@@ -10,9 +10,8 @@ const MAP = {
10
10
  };
11
11
  /** @public */
12
12
  export const genesisErrorTranslator = (error, t, uischema) => {
13
- var _a;
14
- if ((error === null || error === void 0 ? void 0 : error.keyword) === 'pattern') {
15
- return (_a = MAP[error.params.pattern]) !== null && _a !== void 0 ? _a : 'Invalid pattern.';
13
+ if (error?.keyword === 'pattern') {
14
+ return MAP[error.params.pattern] ?? 'Invalid pattern.';
16
15
  }
17
16
  return defaultErrorTranslator(error, t, uischema);
18
17
  };
@@ -6,11 +6,11 @@
6
6
  */
7
7
  export const mustMatch = (target) => {
8
8
  return (data, path, label) => {
9
- if (!(path === null || path === void 0 ? void 0 : path.length) || !(target === null || target === void 0 ? void 0 : target.length) || !data)
9
+ if (!path?.length || !target?.length || !data)
10
10
  return [];
11
- const value1 = data === null || data === void 0 ? void 0 : data[target];
12
- const value2 = data === null || data === void 0 ? void 0 : data[path];
13
- if (!(value1 === null || value1 === void 0 ? void 0 : value1.length) || !(value2 === null || value2 === void 0 ? void 0 : value2.length) || value1 === value2)
11
+ const value1 = data?.[target];
12
+ const value2 = data?.[path];
13
+ if (!value1?.length || !value2?.length || value1 === value2)
14
14
  return [];
15
15
  return [
16
16
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-forms",
3
3
  "description": "Genesis Foundation Forms",
4
- "version": "14.70.3",
4
+ "version": "14.70.4-es2021.1",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -40,18 +40,18 @@
40
40
  "test:debug": "genx test --debug"
41
41
  },
42
42
  "devDependencies": {
43
- "@genesislcap/foundation-testing": "14.70.3",
44
- "@genesislcap/genx": "14.70.3",
43
+ "@genesislcap/foundation-testing": "14.70.4-es2021.1",
44
+ "@genesislcap/genx": "14.70.4-es2021.1",
45
45
  "@types/json-schema": "^7.0.11",
46
46
  "@types/ua-parser-js": "^0.7.36",
47
47
  "analytics": "^0.8.0",
48
48
  "rimraf": "^3.0.2"
49
49
  },
50
50
  "dependencies": {
51
- "@genesislcap/foundation-comms": "14.70.3",
52
- "@genesislcap/foundation-criteria": "14.70.3",
53
- "@genesislcap/foundation-ui": "14.70.3",
54
- "@genesislcap/foundation-utils": "14.70.3",
51
+ "@genesislcap/foundation-comms": "14.70.4-es2021.1",
52
+ "@genesislcap/foundation-criteria": "14.70.4-es2021.1",
53
+ "@genesislcap/foundation-ui": "14.70.4-es2021.1",
54
+ "@genesislcap/foundation-utils": "14.70.4-es2021.1",
55
55
  "@jsonforms/core": "^3.0.0",
56
56
  "@microsoft/fast-components": "^2.21.3",
57
57
  "@microsoft/fast-element": "^1.7.0",
@@ -72,5 +72,5 @@
72
72
  "access": "public"
73
73
  },
74
74
  "customElements": "dist/custom-elements.json",
75
- "gitHead": "2bd15e0c3928fa0fbfa60ccb7e4f89e956afda73"
75
+ "gitHead": "5d0d8ee36cfd068cfc6211033b326d0a978cfc05"
76
76
  }