@abgov/jsonforms-components 1.14.0 → 1.14.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.
package/index.esm.js CHANGED
@@ -3999,6 +3999,24 @@ const RenderStepElements = props => {
3999
3999
  );
4000
4000
  };
4001
4001
 
4002
+ const validateData = (jsonSchema, data, ajv) => {
4003
+ const newSchema = JSON.parse(JSON.stringify(jsonSchema));
4004
+ Object.keys(newSchema.properties || {}).forEach(propertyName => {
4005
+ var _a;
4006
+ const property = newSchema.properties || {};
4007
+ property[propertyName].enum = getData(propertyName);
4008
+ if (((_a = property[propertyName]) === null || _a === void 0 ? void 0 : _a.format) === 'file-urn') {
4009
+ delete property[propertyName].format;
4010
+ }
4011
+ });
4012
+ try {
4013
+ const validate = ajv.compile(newSchema);
4014
+ return validate(data).valueOf();
4015
+ } catch (e) {
4016
+ return false;
4017
+ }
4018
+ };
4019
+
4002
4020
  const FormStepper = props => {
4003
4021
  var _a, _b, _c, _d;
4004
4022
  const {
@@ -4052,17 +4070,8 @@ const FormStepper = props => {
4052
4070
  setStepStatuses(statuses);
4053
4071
  }, [inputStatuses, categories]);
4054
4072
  useEffect(() => {
4055
- const newSchema = JSON.parse(JSON.stringify(schema));
4056
- Object.keys(newSchema.properties || {}).forEach(propertyName => {
4057
- var _a;
4058
- const property = newSchema.properties || {};
4059
- property[propertyName].enum = getData(propertyName);
4060
- if (((_a = property[propertyName]) === null || _a === void 0 ? void 0 : _a.format) === 'file-urn') {
4061
- delete property[propertyName].format;
4062
- }
4063
- });
4064
- const validate = ajv.compile(newSchema);
4065
- setIsFormValid(validate(data));
4073
+ const isValid = validateData(schema, data, ajv);
4074
+ setIsFormValid(isValid);
4066
4075
  }, [ajv, data, schema]);
4067
4076
  useEffect(() => {
4068
4077
  var _a, _b;
@@ -4226,6 +4235,7 @@ const FormStepper = props => {
4226
4235
  type: "primary",
4227
4236
  onClick: handleSubmit,
4228
4237
  disabled: !isFormValid || !enabled,
4238
+ testId: "stepper-submit-btn",
4229
4239
  children: "Submit"
4230
4240
  })
4231
4241
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
6
6
  "repository": "https://github.com/GovAlta/adsp-monorepo",
@@ -5,6 +5,5 @@ export interface CategorizationStepperLayoutRendererProps extends StatePropsOfLa
5
5
  data: unknown;
6
6
  }
7
7
  export declare const FormStepper: (props: CategorizationStepperLayoutRendererProps) => JSX.Element;
8
- export declare const flattenObject: (obj: Record<string, string>) => Record<string, string>;
9
8
  export declare const FormStepperControl: (props: CategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => import("react/jsx-runtime").JSX.Element;
10
9
  export default FormStepper;
@@ -0,0 +1,3 @@
1
+ import { JsonSchema } from '@jsonforms/core';
2
+ import Ajv from 'ajv8';
3
+ export declare const validateData: (jsonSchema: JsonSchema, data: unknown, ajv: Ajv) => boolean;