diff --git a/types/react-jsonschema-form/index.d.ts b/types/react-jsonschema-form/index.d.ts index 2f5681a39f..ea032d5480 100644 --- a/types/react-jsonschema-form/index.d.ts +++ b/types/react-jsonschema-form/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-jsonschema-form 1.3 +// Type definitions for react-jsonschema-form 1.6.1 // Project: https://github.com/mozilla-services/react-jsonschema-form // Definitions by: Dan Fox // Ivan Jiang @@ -8,8 +8,9 @@ // Sebastian Busch // Mehdi Lahlou // Saad Tazi +// Agustin N. R. Ramirez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 3.5 declare module "react-jsonschema-form" { @@ -244,6 +245,10 @@ declare module "react-jsonschema-form" { type FormSubmit = { formData: T; }; + + export function withTheme( + themeProps: Omit, 'schema'> + ): React.ComponentClass> | React.StatelessComponent>; } declare module "react-jsonschema-form/lib/utils" { diff --git a/types/react-jsonschema-form/react-jsonschema-form-tests.tsx b/types/react-jsonschema-form/react-jsonschema-form-tests.tsx index c3a92d6d26..701495f3bd 100644 --- a/types/react-jsonschema-form/react-jsonschema-form-tests.tsx +++ b/types/react-jsonschema-form/react-jsonschema-form-tests.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import Form, { UiSchema, ErrorListProps, WidgetProps, ErrorSchema } from "react-jsonschema-form"; +import Form, { UiSchema, ErrorListProps, WidgetProps, ErrorSchema, withTheme } from 'react-jsonschema-form'; import { JSONSchema6 } from "json-schema"; // example taken from the react-jsonschema-form playground: @@ -128,7 +128,7 @@ export const FuncExample = (props: FuncExampleProps) => { ErrorList={ErrorListExample} onChange={(formData, errorSchema) => { onChange(formData); - onError(errorSchema) + errorSchema && onError(errorSchema); }} /> ); @@ -157,3 +157,13 @@ export const NullCustomWidget: React.SFC = (props) => onFocus={()=> props.onFocus('id', null)} onBlur={()=> props.onFocus('id', null)} /> + +export const withThemeExample = () => { + const Form = withTheme({ + showErrorList: false, + noValidate: false, + noHtml5Validate: false, + }); + + return
; +}; diff --git a/types/react-jsonschema-form/tsconfig.json b/types/react-jsonschema-form/tsconfig.json index a4f7127522..a7b41a0da1 100644 --- a/types/react-jsonschema-form/tsconfig.json +++ b/types/react-jsonschema-form/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -22,4 +22,4 @@ "index.d.ts", "react-jsonschema-form-tests.tsx" ] -} \ No newline at end of file +}