@sphereon/ui-components.ssi-react 0.4.1-unstable.147 → 0.4.1-unstable.149
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.
|
@@ -2,10 +2,31 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { JsonForms } from '@jsonforms/react';
|
|
4
4
|
import { materialCells } from '@jsonforms/material-renderers';
|
|
5
|
+
import Ajv from 'ajv';
|
|
6
|
+
import addFormats from "ajv-formats";
|
|
7
|
+
import { formatDate } from '../../../helpers';
|
|
5
8
|
import { jsonFormsMaterialRenderers } from '../../../renders/jsonFormsRenders';
|
|
6
|
-
|
|
9
|
+
const defaultAjv = new Ajv({ useDefaults: true });
|
|
10
|
+
addFormats(defaultAjv);
|
|
11
|
+
defaultAjv.addKeyword({
|
|
12
|
+
keyword: 'isoDateFormat',
|
|
13
|
+
modifying: true,
|
|
14
|
+
validate: (schema, data, parentSchema, dataCxt) => {
|
|
15
|
+
if (typeof data === 'string') {
|
|
16
|
+
if (!dataCxt?.parentData || dataCxt.parentDataProperty === undefined) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
const formatted = formatDate(data, schema);
|
|
20
|
+
if (formatted && formatted !== 'Invalid date') {
|
|
21
|
+
dataCxt.parentData[dataCxt.parentDataProperty] = formatted;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
7
28
|
const FormView = (props) => {
|
|
8
|
-
const { schema, uiSchema, validationMode = 'ValidateAndShow', renderers = jsonFormsMaterialRenderers, cells = materialCells, style, middleware, ajv =
|
|
29
|
+
const { schema, uiSchema, validationMode = 'ValidateAndShow', renderers = jsonFormsMaterialRenderers, cells = materialCells, style, middleware, ajv = defaultAjv, onFormStateChange, readonly = false, config, } = props;
|
|
9
30
|
const [data, setData] = useState(props.data);
|
|
10
31
|
useEffect(() => {
|
|
11
32
|
const validate = ajv.compile(schema);
|
|
@@ -16,4 +37,4 @@ const FormView = (props) => {
|
|
|
16
37
|
return (_jsx("div", { style: style, children: _jsx(JsonForms, { schema: schema, uischema: uiSchema, data: data, renderers: renderers, cells: cells, onChange: onFormStateChange, validationMode: validationMode, middleware: middleware, ajv: ajv, readonly: readonly, config: config }) }));
|
|
17
38
|
};
|
|
18
39
|
export default FormView;
|
|
19
|
-
export const getFormViewAjv = () =>
|
|
40
|
+
export const getFormViewAjv = () => defaultAjv;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ui-components.ssi-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.4.1-unstable.
|
|
4
|
+
"version": "0.4.1-unstable.149+0c03f45",
|
|
5
5
|
"description": "SSI UI components for React",
|
|
6
6
|
"repository": "git@github.com:Sphereon-Opensource/UI-Components.git",
|
|
7
7
|
"author": "Sphereon <dev@sphereon.com>",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@mui/x-date-pickers": "^8.18.0",
|
|
51
51
|
"@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.45.94",
|
|
52
52
|
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.45.94",
|
|
53
|
-
"@sphereon/ui-components.core": "0.4.1-unstable.
|
|
53
|
+
"@sphereon/ui-components.core": "0.4.1-unstable.149+0c03f45",
|
|
54
54
|
"@tanstack/react-table": "^8.9.3",
|
|
55
55
|
"ajv": "^8.17.1",
|
|
56
56
|
"ajv-formats": "^3.0.1",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"react": ">= 18"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "0c03f4551d5f06113f7d789b9310ef8ddacfb018"
|
|
76
76
|
}
|
package/dist/utils/Ajv.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DateFormat } from '../helpers';
|
|
2
|
-
import Ajv, { AnySchemaObject } from 'ajv';
|
|
3
|
-
import { DataValidationCxt } from 'ajv/dist/types';
|
|
4
|
-
export declare const createFormViewAjv: () => Ajv;
|
|
5
|
-
export declare const isDateFormatAjvKeyword: {
|
|
6
|
-
keyword: string;
|
|
7
|
-
modifying: boolean;
|
|
8
|
-
validate: (schema: DateFormat, data: any, parentSchema?: AnySchemaObject, dataCxt?: DataValidationCxt) => boolean;
|
|
9
|
-
};
|
package/dist/utils/Ajv.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { formatDate } from '../helpers';
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
|
-
import addFormats from 'ajv-formats';
|
|
4
|
-
export const createFormViewAjv = () => {
|
|
5
|
-
const ajv = new Ajv({ useDefaults: true });
|
|
6
|
-
addFormats(ajv);
|
|
7
|
-
ajv.addKeyword(isDateFormatAjvKeyword);
|
|
8
|
-
return ajv;
|
|
9
|
-
};
|
|
10
|
-
export const isDateFormatAjvKeyword = {
|
|
11
|
-
keyword: 'isoDateFormat',
|
|
12
|
-
modifying: true,
|
|
13
|
-
validate: (schema, data, parentSchema, dataCxt) => {
|
|
14
|
-
if (typeof data === 'string') {
|
|
15
|
-
if (!dataCxt?.parentData || dataCxt.parentDataProperty === undefined) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
const formatted = formatDate(data, schema);
|
|
19
|
-
if (formatted && formatted !== 'Invalid date') {
|
|
20
|
-
dataCxt.parentData[dataCxt.parentDataProperty] = formatted;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
};
|