@genesislcap/foundation-forms 14.437.4 → 14.437.5-canary.gs-datepicker
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.
|
@@ -51,9 +51,10 @@ export declare class JSONForms extends FASTElement {
|
|
|
51
51
|
/**
|
|
52
52
|
* Performs client-side validation by running the validator defined in the UI schema.
|
|
53
53
|
* @param uischema the UI schema
|
|
54
|
+
* @param data the data to validate against (defaults to the current core data)
|
|
54
55
|
* @returns ErrorObject[] that will be passed to JsonFormsCore as additionalErrors
|
|
55
56
|
*/
|
|
56
|
-
validate: (uischema: any) => ErrorObject[];
|
|
57
|
+
validate: (uischema: UISchemaElement, data?: any) => ErrorObject[];
|
|
57
58
|
copyUISchemaToClipboard(): Promise<void>;
|
|
58
59
|
}
|
|
59
60
|
//# sourceMappingURL=json-forms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-forms.d.ts","sourceRoot":"","sources":["../../../src/jsonforms/json-forms.ts"],"names":[],"mappings":"AACA,OAAO,EASL,8BAA8B,EAE9B,aAAa,
|
|
1
|
+
{"version":3,"file":"json-forms.d.ts","sourceRoot":"","sources":["../../../src/jsonforms/json-forms.ts"],"names":[],"mappings":"AACA,OAAO,EASL,8BAA8B,EAE9B,aAAa,EAGb,eAAe,EACf,YAAY,EACZ,cAAc,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAIL,WAAW,EAKZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,GAAG,EAAE,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAmCzC;;;;;;GAMG;AACH,qBAUa,SAAU,SAAQ,WAAW;IACxC,OAAO,CAAC,UAAU,CAAS;IAE3B,IAAI,SAAS,IAAI,OAAO,CAGvB;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAG3B;IAEW,MAAM,MAAC;IACnB,aAAa;IAGD,SAAS,MAAC;IACV,IAAI,MAAC;IACL,YAAY,MAAC;IAEb,MAAM,MAAC;IACnB,aAAa;IAmDD,QAAQ,EAAE,eAAe,CAAC;IACtC,eAAe;IAIH,IAAI,MAAC;IACjB,WAAW;IAkCC,SAAS,EAAE,8BAA8B,EAAE,CAAC;IACxD,gBAAgB;IAIJ,cAAc,EAAE,cAAc,CAAC;IAC3C,qBAAqB;IAIT,GAAG,EAAE,GAAG,CAAiD;IACrE,UAAU;IAIiB,QAAQ,EAAE,OAAO,CAAC;IAC7C,eAAe;IAIH,MAAM,EAAE,GAAG,CAAC;IACxB,aAAa;IAIb;;;OAGG;IACS,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAa;IACtE,wBAAwB;IAUxB;;;OAGG;IACS,UAAU,EAAE,OAAO,CAAS;IACxC,iBAAiB;IAUjB,IAAI,KAAK,IAAI,aAAa,CAuBzB;IAED,QAAQ,GAAI,QAAQ,YAAY,UAoB9B;IAEF;;;;;OAKG;IACH,QAAQ,GAAI,UAAU,eAAe,EAAE,UAAiC,KAAG,WAAW,EAAE,CAoDtF;IAEI,uBAAuB;CAQ9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
|
2
2
|
import { isDev } from '@genesislcap/foundation-utils';
|
|
3
|
-
import { Actions, configReducer, coreReducer, createAjv, Generate, i18nReducer, } from '@jsonforms/core';
|
|
3
|
+
import { Actions, configReducer, coreReducer, createAjv, Generate, i18nReducer, Resolve, } from '@jsonforms/core';
|
|
4
4
|
import { attr, css, customElement, FASTElement, html, Observable, observable, when, } from '@microsoft/fast-element';
|
|
5
5
|
import { genesisErrorTranslator, logger } from '../utils';
|
|
6
6
|
const TIMESTAMP_FIELD = '#/properties/TIMESTAMP';
|
|
@@ -49,26 +49,31 @@ let JSONForms = class JSONForms extends FASTElement {
|
|
|
49
49
|
*/
|
|
50
50
|
this.bulkInsert = false;
|
|
51
51
|
this.dispatch = (action) => {
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
// fresh
|
|
55
|
-
//
|
|
56
|
-
const
|
|
52
|
+
// Re-run custom validators against the updated data and push the result
|
|
53
|
+
// back into core so renderers (which read `core.additionalErrors`) see
|
|
54
|
+
// the fresh errors. Without this, the value baked in by `Actions.init`
|
|
55
|
+
// sticks forever even when validators would now return [].
|
|
56
|
+
const nextCore = coreReducer(this.jsonforms.core, action);
|
|
57
|
+
// Validate against the post-action data, not `this.jsonforms.core.data`
|
|
58
|
+
// (which is still the pre-action snapshot at this point).
|
|
59
|
+
const additionalErrors = this.validate(this.uichemaToUse, nextCore.data);
|
|
60
|
+
this.jsonforms = Object.assign(Object.assign({}, this.jsonforms), { core: Object.assign(Object.assign({}, nextCore), { additionalErrors }) });
|
|
57
61
|
this.$emit('data-change', {
|
|
58
62
|
data: this.jsonforms.core.data,
|
|
59
63
|
errors: this.jsonforms.core.errors,
|
|
60
|
-
additionalErrors
|
|
64
|
+
additionalErrors,
|
|
61
65
|
path: action.path,
|
|
62
66
|
});
|
|
63
67
|
};
|
|
64
68
|
/**
|
|
65
69
|
* Performs client-side validation by running the validator defined in the UI schema.
|
|
66
70
|
* @param uischema the UI schema
|
|
71
|
+
* @param data the data to validate against (defaults to the current core data)
|
|
67
72
|
* @returns ErrorObject[] that will be passed to JsonFormsCore as additionalErrors
|
|
68
73
|
*/
|
|
69
|
-
this.validate = (uischema) => {
|
|
70
|
-
var _a, _b
|
|
71
|
-
|
|
74
|
+
this.validate = (uischema, data) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (data === void 0) { data = (_b = (_a = this.jsonforms) === null || _a === void 0 ? void 0 : _a.core) === null || _b === void 0 ? void 0 : _b.data; }
|
|
72
77
|
const errors = [];
|
|
73
78
|
// Recursive function to traverse all elements in the UI schema
|
|
74
79
|
const validateElement = (element) => {
|
|
@@ -83,6 +88,19 @@ let JSONForms = class JSONForms extends FASTElement {
|
|
|
83
88
|
if (!Array.isArray(newErrors)) {
|
|
84
89
|
newErrors = [newErrors];
|
|
85
90
|
}
|
|
91
|
+
// Attach `parentSchema` resolved from the element's scope. Without it,
|
|
92
|
+
// @jsonforms/core's `errorsAt` filter drops the custom error whenever
|
|
93
|
+
// root-level combinator errors (anyOf/oneOf) exist, hiding the
|
|
94
|
+
// validator's message from the per-field renderer.
|
|
95
|
+
if ((element === null || element === void 0 ? void 0 : element.scope) && this.schema && newErrors.length) {
|
|
96
|
+
const fieldSchema = Resolve.schema(this.schema, element.scope, this.schema);
|
|
97
|
+
if (fieldSchema) {
|
|
98
|
+
newErrors = newErrors.map((e) => {
|
|
99
|
+
var _a;
|
|
100
|
+
return (Object.assign(Object.assign({}, e), { parentSchema: (_a = e.parentSchema) !== null && _a !== void 0 ? _a : fieldSchema }));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
86
104
|
errors.push(...newErrors);
|
|
87
105
|
}
|
|
88
106
|
// Recursively check child elements
|
|
@@ -98,10 +116,10 @@ let JSONForms = class JSONForms extends FASTElement {
|
|
|
98
116
|
});
|
|
99
117
|
}
|
|
100
118
|
};
|
|
101
|
-
// Start
|
|
102
|
-
(
|
|
103
|
-
|
|
104
|
-
|
|
119
|
+
// Start from the root. `validateElement` already handles both controls
|
|
120
|
+
// (validateFn at the node) and layouts (recurse via `.elements`), so the
|
|
121
|
+
// same call works whether the root is a Layout or a single Control.
|
|
122
|
+
validateElement(uischema);
|
|
105
123
|
return errors;
|
|
106
124
|
};
|
|
107
125
|
}
|
|
@@ -134,7 +152,7 @@ let JSONForms = class JSONForms extends FASTElement {
|
|
|
134
152
|
const core = coreReducer(initialCore, Actions.init(this.data, this.schema, this.uichemaToUse, {
|
|
135
153
|
validationMode: this.validationMode || 'ValidateAndShow',
|
|
136
154
|
ajv: this.ajv,
|
|
137
|
-
additionalErrors: this.validate(this.uichemaToUse),
|
|
155
|
+
additionalErrors: this.validate(this.uichemaToUse, this.data),
|
|
138
156
|
}));
|
|
139
157
|
return core;
|
|
140
158
|
};
|
|
@@ -147,7 +165,7 @@ let JSONForms = class JSONForms extends FASTElement {
|
|
|
147
165
|
rowSubmitStatuses: this.rowSubmitStatuses,
|
|
148
166
|
bulkInsert: this.bulkInsert,
|
|
149
167
|
};
|
|
150
|
-
const additionalErrors = this.validate(this.uichemaToUse);
|
|
168
|
+
const additionalErrors = this.validate(this.uichemaToUse, this.data);
|
|
151
169
|
this.$emit('data-change', {
|
|
152
170
|
data: this.jsonforms.core.data,
|
|
153
171
|
errors: this.jsonforms.core.errors,
|
|
@@ -173,8 +191,11 @@ let JSONForms = class JSONForms extends FASTElement {
|
|
|
173
191
|
}
|
|
174
192
|
// External data update (e.g. reset, CSV import) — fold into core state
|
|
175
193
|
// without re-running Actions.init, then emit a single data-change.
|
|
176
|
-
|
|
177
|
-
|
|
194
|
+
const nextCore = coreReducer(this.jsonforms.core, Actions.updateCore(this.data, this.schema, this.uichemaToUse));
|
|
195
|
+
// Validate against the freshly-reduced data, not the still-assigned
|
|
196
|
+
// `this.jsonforms.core.data` (which is the pre-action snapshot).
|
|
197
|
+
const additionalErrors = this.validate(this.uichemaToUse, nextCore.data);
|
|
198
|
+
this.jsonforms = Object.assign(Object.assign({}, this.jsonforms), { core: Object.assign(Object.assign({}, nextCore), { additionalErrors }) });
|
|
178
199
|
this.$emit('data-change', {
|
|
179
200
|
data: this.jsonforms.core.data,
|
|
180
201
|
errors: this.jsonforms.core.errors,
|
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.437.
|
|
4
|
+
"version": "14.437.5-canary.gs-datepicker",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -55,23 +55,23 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@genesislcap/foundation-testing": "14.437.
|
|
59
|
-
"@genesislcap/genx": "14.437.
|
|
60
|
-
"@genesislcap/rollup-builder": "14.437.
|
|
61
|
-
"@genesislcap/ts-builder": "14.437.
|
|
62
|
-
"@genesislcap/uvu-playwright-builder": "14.437.
|
|
63
|
-
"@genesislcap/vite-builder": "14.437.
|
|
64
|
-
"@genesislcap/webpack-builder": "14.437.
|
|
58
|
+
"@genesislcap/foundation-testing": "14.437.5-canary.gs-datepicker",
|
|
59
|
+
"@genesislcap/genx": "14.437.5-canary.gs-datepicker",
|
|
60
|
+
"@genesislcap/rollup-builder": "14.437.5-canary.gs-datepicker",
|
|
61
|
+
"@genesislcap/ts-builder": "14.437.5-canary.gs-datepicker",
|
|
62
|
+
"@genesislcap/uvu-playwright-builder": "14.437.5-canary.gs-datepicker",
|
|
63
|
+
"@genesislcap/vite-builder": "14.437.5-canary.gs-datepicker",
|
|
64
|
+
"@genesislcap/webpack-builder": "14.437.5-canary.gs-datepicker",
|
|
65
65
|
"@types/json-schema": "^7.0.11",
|
|
66
66
|
"@types/papaparse": "^5.3.14"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@genesislcap/foundation-comms": "14.437.
|
|
70
|
-
"@genesislcap/foundation-criteria": "14.437.
|
|
71
|
-
"@genesislcap/foundation-logger": "14.437.
|
|
72
|
-
"@genesislcap/foundation-notifications": "14.437.
|
|
73
|
-
"@genesislcap/foundation-ui": "14.437.
|
|
74
|
-
"@genesislcap/foundation-utils": "14.437.
|
|
69
|
+
"@genesislcap/foundation-comms": "14.437.5-canary.gs-datepicker",
|
|
70
|
+
"@genesislcap/foundation-criteria": "14.437.5-canary.gs-datepicker",
|
|
71
|
+
"@genesislcap/foundation-logger": "14.437.5-canary.gs-datepicker",
|
|
72
|
+
"@genesislcap/foundation-notifications": "14.437.5-canary.gs-datepicker",
|
|
73
|
+
"@genesislcap/foundation-ui": "14.437.5-canary.gs-datepicker",
|
|
74
|
+
"@genesislcap/foundation-utils": "14.437.5-canary.gs-datepicker",
|
|
75
75
|
"@json-schema-tools/dereferencer": "^1.6.1",
|
|
76
76
|
"@jsonforms/core": "^3.2.1",
|
|
77
77
|
"@microsoft/fast-components": "2.30.6",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
95
|
"customElements": "dist/custom-elements.json",
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "d926dcc5c1273bf6824c3e8121331ea88cdfc9e1"
|
|
97
97
|
}
|