@sphereon/ui-components.ssi-react 0.4.1-unstable.63 → 0.4.1-unstable.69

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.
@@ -3,45 +3,30 @@ import { JsonForms } from '@jsonforms/react';
3
3
  import { materialCells } from '@jsonforms/material-renderers';
4
4
  import { jsonFormsMaterialRenderers } from '../../../renders/jsonFormsRenders';
5
5
  import Ajv from 'ajv';
6
- import { formatDateToISO } from '../../../helpers';
7
- const initializeDefaultValues = (schema, currentData = {}) => {
8
- const result = { ...currentData };
9
- if (!schema.properties) {
10
- return result;
11
- }
12
- Object.entries(schema.properties).forEach(([key, property]) => {
13
- if (typeof property === 'object') {
14
- if (property.const && (!(key in result) || !result[key])) {
15
- result[key] = property.const;
16
- }
17
- if (property.default !== undefined && !(key in result)) {
18
- if (property.format?.startsWith('date') || property.format?.startsWith('time')) {
19
- result[key] = formatDateToISO(property.default, property.format);
20
- }
21
- else if (typeof property.default === 'object') {
22
- result[key] = Array.isArray(property.default)
23
- ? [...property.default]
24
- : { ...property.default };
25
- }
26
- else {
27
- result[key] = property.default;
28
- }
29
- }
30
- if (property.properties) {
31
- if (!result[key]) {
32
- result[key] = {};
33
- }
34
- result[key] = initializeDefaultValues(property, result[key]);
6
+ import addFormats from "ajv-formats";
7
+ const defaultAjv = new Ajv({ useDefaults: true });
8
+ addFormats(defaultAjv);
9
+ defaultAjv.addKeyword({
10
+ keyword: 'isoDateFormat',
11
+ modifying: true,
12
+ validate: function (schema, data, parentSchema, dataCxt) {
13
+ if (typeof data === 'string') {
14
+ const date = data === 'now' ? new Date() : new Date(data);
15
+ if (!isNaN(date.getTime()) && dataCxt?.parentData && dataCxt.parentDataProperty !== undefined) {
16
+ dataCxt.parentData[dataCxt.parentDataProperty] =
17
+ schema === 'date-time'
18
+ ? date.toISOString().slice(0, 19).replace('T', ' ')
19
+ : schema === 'date'
20
+ ? date.toISOString().slice(0, 10)
21
+ : date.toISOString().slice(11, 19);
35
22
  }
23
+ return true;
36
24
  }
37
- });
38
- return result;
39
- };
25
+ return false;
26
+ }
27
+ });
40
28
  const FormView = (props) => {
41
- const { data, schema, uiSchema, validationMode = 'ValidateAndShow', renderers = jsonFormsMaterialRenderers, cells = materialCells, style, middleware, ajv = new Ajv({
42
- useDefaults: true,
43
- allErrors: true
44
- }), onFormStateChange, readonly = false, config, } = props;
29
+ const { data, schema, uiSchema, validationMode = 'ValidateAndShow', renderers = jsonFormsMaterialRenderers, cells = materialCells, style, middleware, ajv = defaultAjv, onFormStateChange, readonly = false, config, } = props;
45
30
  const onFormStateChanged = (state) => {
46
31
  void onFormStateChange?.(state);
47
32
  };
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.63+6597aef",
4
+ "version": "0.4.1-unstable.69+79c9ca4",
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,8 +50,10 @@
50
50
  "@mui/x-date-pickers": "^6.19.5",
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.63+6597aef",
53
+ "@sphereon/ui-components.core": "0.4.1-unstable.69+79c9ca4",
54
54
  "@tanstack/react-table": "^8.9.3",
55
+ "ajv": "^8.17.1",
56
+ "ajv-formats": "^3.0.1",
55
57
  "react-dom": "npm:react-dom@18.3.1",
56
58
  "react-json-tree": "^0.18.0",
57
59
  "react-loader-spinner": "5.4.5",
@@ -63,12 +65,11 @@
63
65
  "devDependencies": {
64
66
  "@tailwindcss/cli": "^4.1.11",
65
67
  "@types/react": "~18.3.18",
66
- "ajv": "^8.12.0",
67
68
  "tailwindcss": "^4.1.11",
68
69
  "typescript": "4.9.5"
69
70
  },
70
71
  "peerDependencies": {
71
72
  "react": ">= 18"
72
73
  },
73
- "gitHead": "6597aef9236ea7eda4b6e702673666e6240b1397"
74
+ "gitHead": "79c9ca403698368d3c037f7fa884e4e888513dbb"
74
75
  }