@genesislcap/foundation-forms 13.5.0 → 13.7.0

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.
@@ -88,10 +88,6 @@ export declare class Form extends FoundationElement {
88
88
  * @internal
89
89
  */
90
90
  submitted: boolean;
91
- /**
92
- * @internal
93
- */
94
- submissionErrors: string;
95
91
  readonly: boolean;
96
92
  /**
97
93
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/form.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,gBAAgB;AAChB,eAAO,MAAM,MAAM,gDAAkC,CAAC;AActD,cAAc;AACd,eAAO,MAAM,SAAS,OAYrB,CAAC;AACF;;;;;GAKG;AAEH,qBAKa,IAAK,SAAQ,iBAAiB;IACzC;;;;OAIG;IACG,YAAY,EAAE,MAAM,CAAC;YACb,mBAAmB;IAUjC,OAAO,CAAC,oBAAoB;IAkB5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACS,QAAQ,EAAE,eAAe,CAAC;IACtC;;;OAGG;IACS,SAAS,EAAE,aAAa,EAAE,CAAa;IACnD;;;;;;OAMG;IACS,UAAU,EAAE,WAAW,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAa;IAClB,OAAO,CAAC,OAAO,CAAW;IACnC;;;OAGG;IACS,IAAI,EAAE,GAAG,CAAM;IAE3B;;OAEG;IACS,UAAU,EAAE,OAAO,CAAC;IAChC;;OAEG;IACS,SAAS,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACS,gBAAgB,EAAE,MAAM,CAAC;IAEV,QAAQ,EAAE,OAAO,CAAC;IAE7C;;OAEG;IACG,OAAO;IAoBb;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW;IAQ3B,oBAAoB;CAOrB"}
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/form.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,gBAAgB;AAChB,eAAO,MAAM,MAAM,gDAAkC,CAAC;AActD,cAAc;AACd,eAAO,MAAM,SAAS,OAYrB,CAAC;AACF;;;;;GAKG;AAEH,qBAKa,IAAK,SAAQ,iBAAiB;IACzC;;;;OAIG;IACG,YAAY,EAAE,MAAM,CAAC;YACb,mBAAmB;IAQjC,OAAO,CAAC,oBAAoB;IA0B5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACS,QAAQ,EAAE,eAAe,CAAC;IACtC;;;OAGG;IACS,SAAS,EAAE,aAAa,EAAE,CAAa;IACnD;;;;;;OAMG;IACS,UAAU,EAAE,WAAW,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAqB;IAC1B,OAAO,CAAC,OAAO,CAAW;IACnC;;;OAGG;IACS,IAAI,EAAE,GAAG,CAAM;IAE3B;;OAEG;IACS,UAAU,EAAE,OAAO,CAAC;IAChC;;OAEG;IACS,SAAS,EAAE,OAAO,CAAC;IAEJ,QAAQ,EAAE,OAAO,CAAC;IAE7C;;OAEG;IACG,OAAO;IAwBb;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW;IAQ3B,oBAAoB;CAMrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"form.styles.d.ts","sourceRoot":"","sources":["../../src/form.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,iDA0DhC,CAAC"}
1
+ {"version":3,"file":"form.styles.d.ts","sourceRoot":"","sources":["../../src/form.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,iDAoDhC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"form.template.d.ts","sourceRoot":"","sources":["../../src/form.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AASnC,eAAO,MAAM,sBAAsB,2DA4BlC,CAAC"}
1
+ {"version":3,"file":"form.template.d.ts","sourceRoot":"","sources":["../../src/form.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AASnC,eAAO,MAAM,sBAAsB,2DA2BlC,CAAC"}
package/dist/esm/form.js CHANGED
@@ -2,7 +2,7 @@ import { __awaiter, __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';
5
- import { attr, customElement, observable } from '@microsoft/fast-element';
5
+ import { attr, customElement, DOM, observable } from '@microsoft/fast-element';
6
6
  import { FoundationElement } from '@microsoft/fast-foundation';
7
7
  import { foundationFormStyles as styles } from './form.styles';
8
8
  import { foundationFormTemplate as template } from './form.template';
@@ -71,7 +71,6 @@ let Form = class Form extends FoundationElement {
71
71
  const jsonSchemaResponse = yield this.connect.getJSONSchema(this.resourceName);
72
72
  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;
73
73
  }
74
- this.removeDataProperties();
75
74
  });
76
75
  }
77
76
  removeDataProperties() {
@@ -80,30 +79,38 @@ let Form = class Form extends FoundationElement {
80
79
  }
81
80
  // removes data provided to the form that isn't part of the schema
82
81
  const properties = Object.keys(this.jsonSchema.properties);
82
+ let removedPropertiesCount = 0;
83
83
  Object.keys(this.data).forEach((key) => {
84
84
  if (!properties.includes(key)) {
85
85
  delete this.data[key];
86
+ removedPropertiesCount = removedPropertiesCount + 1;
86
87
  logger.debug('Removing key ', key, 'from provided data because it is not part of the payload');
87
88
  }
88
89
  });
90
+ // force update of the data object to trigger error validation
91
+ if (removedPropertiesCount > 0) {
92
+ this.data = Object.assign({}, this.data);
93
+ }
94
+ return removedPropertiesCount > 0;
89
95
  }
90
96
  /**
91
97
  * @internal
92
98
  */
93
99
  _submit() {
94
100
  return __awaiter(this, void 0, void 0, function* () {
95
- const payload = Object.assign({}, this.data);
96
- this.submissionErrors = '';
101
+ if (this.removeDataProperties()) {
102
+ yield DOM.nextUpdate();
103
+ }
97
104
  this.submitted = true;
105
+ const payload = Object.assign({}, this.data);
98
106
  logger.debug({ payload, errors: this.errors });
99
107
  this.$emit('submit', { payload, errors: this.errors });
100
- if (Object.entries(payload).length !== 0 && !this.errors.length && this.resourceName) {
108
+ if (Object.entries(payload).length !== 0 && this.resourceName) {
101
109
  this.submitting = true;
102
110
  const formSubmitReq = yield this.connect.commitEvent(this.resourceName, { DETAILS: payload });
103
111
  this.submitting = false;
104
112
  if (formSubmitReq.ERROR) {
105
113
  this.$emit('submit-failure', { payload, errors: formSubmitReq.ERROR });
106
- this.submissionErrors = formSubmitReq.ERROR.map((x) => x.CODE + ': ' + x.TEXT).toString();
107
114
  }
108
115
  else {
109
116
  this.$emit('submit-success', { payload });
@@ -124,7 +131,6 @@ let Form = class Form extends FoundationElement {
124
131
  disconnectedCallback() {
125
132
  super.disconnectedCallback();
126
133
  this.submitted = false;
127
- this.submissionErrors = '';
128
134
  this.data = {};
129
135
  }
130
136
  };
@@ -152,9 +158,6 @@ __decorate([
152
158
  __decorate([
153
159
  observable
154
160
  ], Form.prototype, "submitted", void 0);
155
- __decorate([
156
- observable
157
- ], Form.prototype, "submissionErrors", void 0);
158
161
  __decorate([
159
162
  attr({ mode: 'boolean' })
160
163
  ], Form.prototype, "readonly", void 0);
@@ -1,9 +1,8 @@
1
1
  import { controlCornerRadius, designUnit, strokeWidth } from '@microsoft/fast-components';
2
2
  import { css } from '@microsoft/fast-element';
3
- import { display, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
3
+ import { forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
4
4
  import { SystemColors } from '@microsoft/fast-web-utilities';
5
5
  export const foundationFormStyles = css `
6
- ${display('block')}
7
6
  :host {
8
7
  border: calc(${strokeWidth} * 1px) solid transparent;
9
8
  margin: 0;
@@ -35,7 +34,8 @@ export const foundationFormStyles = css `
35
34
 
36
35
  .actions {
37
36
  display: flex;
38
- align-items: center;
37
+ flex-direction: column;
38
+ align-items: flex-end;
39
39
  justify-content: center;
40
40
  padding: calc(${designUnit} * 2px);
41
41
  }
@@ -44,12 +44,6 @@ export const foundationFormStyles = css `
44
44
  border-bottom: 2px solid red;
45
45
  }
46
46
 
47
- .errors {
48
- color: #f00;
49
- font-size: 11px;
50
- width: calc(100% - 70px);
51
- }
52
-
53
47
  .submit-button {
54
48
  width: 70px;
55
49
  }
@@ -18,7 +18,6 @@ export const foundationFormTemplate = html `
18
18
  ></json-forms>
19
19
  ${when((x) => !x.readonly, html `
20
20
  <div class="actions">
21
- <div class="errors">${(x) => x.submissionErrors}</div>
22
21
  <fast-button
23
22
  @click="${(x) => x._submit()}"
24
23
  ?disable=${(x) => !x.submitting}
@@ -110,10 +110,6 @@ export declare class Form extends FoundationElement {
110
110
  * @internal
111
111
  */
112
112
  submitted: boolean;
113
- /**
114
- * @internal
115
- */
116
- submissionErrors: string;
117
113
  readonly: boolean;
118
114
  /**
119
115
  * @internal
@@ -34,8 +34,6 @@ export class Form extends FoundationElement {
34
34
  // @public
35
35
  resourceName: string;
36
36
  // @internal (undocumented)
37
- submissionErrors: string;
38
- // @internal (undocumented)
39
37
  _submit(): Promise<void>;
40
38
  // @internal (undocumented)
41
39
  submitted: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-forms",
3
3
  "description": "Genesis Foundation Forms",
4
- "version": "13.5.0",
4
+ "version": "13.7.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -48,7 +48,7 @@
48
48
  "test:unit:watch": "watchlist src test -- npm run test:unit"
49
49
  },
50
50
  "devDependencies": {
51
- "@genesislcap/foundation-testing": "^13.5.0",
51
+ "@genesislcap/foundation-testing": "^13.7.0",
52
52
  "@microsoft/api-documenter": "^7.19.13",
53
53
  "@microsoft/api-extractor": "^7.31.1",
54
54
  "@module-federation/dashboard-plugin": "2.3.0",
@@ -100,8 +100,8 @@
100
100
  "webpack-merge": "^5.7.3"
101
101
  },
102
102
  "dependencies": {
103
- "@genesislcap/foundation-comms": "^13.5.0",
104
- "@genesislcap/foundation-utils": "^13.5.0",
103
+ "@genesislcap/foundation-comms": "^13.7.0",
104
+ "@genesislcap/foundation-utils": "^13.7.0",
105
105
  "@jsonforms/core": "^3.0.0",
106
106
  "@microsoft/fast-components": "^2.21.3",
107
107
  "@microsoft/fast-element": "^1.7.0",
@@ -121,5 +121,5 @@
121
121
  "publishConfig": {
122
122
  "access": "public"
123
123
  },
124
- "gitHead": "504f19a2acb7b786341393bad782257832ca78e8"
124
+ "gitHead": "0d725fd8628d9e35f7ac36f15f1e65aac897ddae"
125
125
  }