@nolwenture/formik-jsonschema-form 0.9.3 → 0.9.4

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,6 +2,9 @@ import { useEffect } from "react";
2
2
  import { useField } from "formik";
3
3
  import { getDefaultValueForType } from "../utils/getTypes";
4
4
  export const useSetDefault = (props) => {
5
+ if (!props.name) {
6
+ return;
7
+ }
5
8
  const [{ value }, _, { setValue }] = useField(props.name);
6
9
  useEffect(() => {
7
10
  if (!value) {
@@ -2,6 +2,9 @@ import type { FieldProps } from "../types";
2
2
  export declare const getEnums: ({ schema }: {
3
3
  schema: FieldProps["schema"];
4
4
  }) => {
5
+ values: never[];
6
+ type?: undefined;
7
+ } | {
5
8
  type: string;
6
9
  values: {
7
10
  const: any;
@@ -1,4 +1,7 @@
1
1
  export const getEnums = ({ schema }) => {
2
+ if (!schema) {
3
+ return { values: [] };
4
+ }
2
5
  const numberOfDefined = [schema.enum, schema.oneOf, schema.anyOf].filter((x) => x).length;
3
6
  if (numberOfDefined === 0) {
4
7
  return;
@@ -59,12 +59,14 @@ export const resolveSchema = (_a, value) => {
59
59
  return schema;
60
60
  }, schemaCopy);
61
61
  }
62
- const usedProperties = Object.keys((_b = schemaCopy.properties) !== null && _b !== void 0 ? _b : {});
63
- Object.keys(value).map((key) => {
64
- if (!usedProperties.includes(key)) {
65
- valuesToRemoveDeps.push(key);
66
- }
67
- });
62
+ if (dependencies) {
63
+ const usedProperties = Object.keys((_b = schemaCopy.properties) !== null && _b !== void 0 ? _b : {});
64
+ Object.keys(value).map((key) => {
65
+ if (!usedProperties.includes(key)) {
66
+ valuesToRemoveDeps.push(key);
67
+ }
68
+ });
69
+ }
68
70
  if (!allOf && dependencies) {
69
71
  return [schemaCopy, valuesToRemoveDeps];
70
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolwenture/formik-jsonschema-form",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Formik form generation from json schema",
5
5
  "author": "Antti Vikman <antti.vikman@nolwenture.com>",
6
6
  "contributors": [