mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Add withTheme definition for react-jsonschema-form (#36507)
* Add withTheme definition * Prettier changes * Change react-jsonschema-form version correctly
This commit is contained in:
committed by
Ryan Cavanaugh
parent
fd7bdc3e18
commit
352f08ca1e
+7
-2
@@ -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 <https://github.com/iamdanfox>
|
||||
// Ivan Jiang <https://github.com/iplus26>
|
||||
@@ -8,8 +8,9 @@
|
||||
// Sebastian Busch <https://github.com/sbusch>
|
||||
// Mehdi Lahlou <https://github.com/medfreeman>
|
||||
// Saad Tazi <https://github.com/saadtazi>
|
||||
// Agustin N. R. Ramirez <https://github.com/agustin107>
|
||||
// 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<T> = {
|
||||
formData: T;
|
||||
};
|
||||
|
||||
export function withTheme<T>(
|
||||
themeProps: Omit<FormProps<T>, 'schema'>
|
||||
): React.ComponentClass<FormProps<T>> | React.StatelessComponent<FormProps<T>>;
|
||||
}
|
||||
|
||||
declare module "react-jsonschema-form/lib/utils" {
|
||||
|
||||
@@ -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<WidgetProps> = (props) =>
|
||||
onFocus={()=> props.onFocus('id', null)}
|
||||
onBlur={()=> props.onFocus('id', null)}
|
||||
/>
|
||||
|
||||
export const withThemeExample = () => {
|
||||
const Form = withTheme({
|
||||
showErrorList: false,
|
||||
noValidate: false,
|
||||
noHtml5Validate: false,
|
||||
});
|
||||
|
||||
return <Form schema={schema} />;
|
||||
};
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user