@rjsf/core 5.1.0 → 5.2.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/LICENSE.md +183 -183
- package/README.md +1 -1
- package/dist/core.cjs.development.js +898 -763
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +865 -730
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +899 -766
- package/dist/core.umd.development.js.map +1 -1
- package/dist/core.umd.production.min.js +1 -1
- package/dist/core.umd.production.min.js.map +1 -1
- package/dist/index.d.ts +23 -17
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { StrictRJSFSchema, RJSFSchema, FormContextType, ValidatorType, UiSchema, RegistryFieldsType, TemplatesType, RegistryWidgetsType, RJSFValidationError, CustomValidator, ErrorSchema, ErrorTransformer, IdSchema, SchemaUtilsType, ValidationData,
|
|
1
|
+
import { ReactNode, FormEvent, ElementType, Ref, Component, RefObject, ComponentType } from 'react';
|
|
2
|
+
import { StrictRJSFSchema, RJSFSchema, FormContextType, ValidatorType, UiSchema, RegistryFieldsType, TemplatesType, RegistryWidgetsType, RJSFValidationError, CustomValidator, ErrorSchema, ErrorTransformer, Registry, IdSchema, SchemaUtilsType, ValidationData, PathSchema } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
/** The properties that are passed to the `Form` */
|
|
5
5
|
interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
@@ -8,7 +8,7 @@ interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
8
8
|
/** An implementation of the `ValidatorType` interface that is needed for form validation to work */
|
|
9
9
|
validator: ValidatorType<T, S, F>;
|
|
10
10
|
/** The optional children for the form, if provided, it will replace the default `SubmitButton` */
|
|
11
|
-
children?:
|
|
11
|
+
children?: ReactNode;
|
|
12
12
|
/** The uiSchema for the form */
|
|
13
13
|
uiSchema?: UiSchema<T, S, F>;
|
|
14
14
|
/** The data for the form, used to prefill a form with existing data */
|
|
@@ -40,8 +40,8 @@ interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
40
40
|
/** The dictionary of registered fields in the form */
|
|
41
41
|
fields?: RegistryFieldsType<T, S, F>;
|
|
42
42
|
/** The dictionary of registered templates in the form; Partial allows a subset to be provided beyond the defaults */
|
|
43
|
-
templates?: Partial<Omit<TemplatesType<T, S, F>,
|
|
44
|
-
ButtonTemplates?: Partial<TemplatesType<T, S, F>[
|
|
43
|
+
templates?: Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & {
|
|
44
|
+
ButtonTemplates?: Partial<TemplatesType<T, S, F>['ButtonTemplates']>;
|
|
45
45
|
};
|
|
46
46
|
/** The dictionary of registered widgets in the form */
|
|
47
47
|
widgets?: RegistryWidgetsType<T, S, F>;
|
|
@@ -58,7 +58,7 @@ interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
58
58
|
* and its data are valid. It will be passed a result object having a `formData` attribute, which is the valid form
|
|
59
59
|
* data you're usually after. The original event will also be passed as a second parameter
|
|
60
60
|
*/
|
|
61
|
-
onSubmit?: (data: IChangeEvent<T, S, F>, event:
|
|
61
|
+
onSubmit?: (data: IChangeEvent<T, S, F>, event: FormEvent<any>) => void;
|
|
62
62
|
/** Sometimes you may want to trigger events or modify external state when a field has been touched, so you can pass
|
|
63
63
|
* an `onBlur` handler, which will receive the id of the input that was blurred and the field value
|
|
64
64
|
*/
|
|
@@ -92,7 +92,7 @@ interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
92
92
|
* nesting forms. However, native browser form behaviour, such as submitting when the `Enter` key is pressed, may no
|
|
93
93
|
* longer work
|
|
94
94
|
*/
|
|
95
|
-
tagName?:
|
|
95
|
+
tagName?: ElementType;
|
|
96
96
|
/** The value of this prop will be passed to the `target` HTML attribute on the form */
|
|
97
97
|
target?: string;
|
|
98
98
|
/** Formerly the `validate` prop; Takes a function that specifies custom validation rules for the form */
|
|
@@ -123,7 +123,7 @@ interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
123
123
|
/** When this prop is set to `top` or 'bottom', a list of errors (or the custom error list defined in the `ErrorList`) will also
|
|
124
124
|
* show. When set to false, only inline input validation errors will be shown. Set to `top` by default
|
|
125
125
|
*/
|
|
126
|
-
showErrorList?: false |
|
|
126
|
+
showErrorList?: false | 'top' | 'bottom';
|
|
127
127
|
/** A function can be passed to this prop in order to make modifications to the default errors resulting from JSON
|
|
128
128
|
* Schema validation
|
|
129
129
|
*/
|
|
@@ -131,6 +131,12 @@ interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
131
131
|
/** If set to true, then the first field with an error will receive the focus when the form is submitted with errors
|
|
132
132
|
*/
|
|
133
133
|
focusOnFirstError?: boolean;
|
|
134
|
+
/** Optional string translation function, if provided, allows users to change the translation of the RJSF internal
|
|
135
|
+
* strings. Some strings contain replaceable parameter values as indicated by `%1`, `%2`, etc. The number after the
|
|
136
|
+
* `%` indicates the order of the parameter. The ordering of parameters is important because some languages may choose
|
|
137
|
+
* to put the second parameter before the first in its translation.
|
|
138
|
+
*/
|
|
139
|
+
translateString?: Registry['translateString'];
|
|
134
140
|
/**
|
|
135
141
|
* _internalFormWrapper is currently used by the semantic-ui theme to provide a custom wrapper around `<Form />`
|
|
136
142
|
* that supports the proper rendering of those themes. To use this prop, one must pass a component that takes two
|
|
@@ -146,10 +152,10 @@ interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
146
152
|
*
|
|
147
153
|
* Use at your own risk as this prop is private and may change at any time without notice.
|
|
148
154
|
*/
|
|
149
|
-
_internalFormWrapper?:
|
|
155
|
+
_internalFormWrapper?: ElementType;
|
|
150
156
|
/** Support receiving a React ref to the Form
|
|
151
157
|
*/
|
|
152
|
-
ref?:
|
|
158
|
+
ref?: Ref<Form<T, S, F>>;
|
|
153
159
|
}
|
|
154
160
|
/** The data that is contained within the state for the `Form` */
|
|
155
161
|
interface FormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
@@ -181,16 +187,16 @@ interface FormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
181
187
|
/** The event data passed when changes have been made to the form, includes everything from the `FormState` except
|
|
182
188
|
* the schema validation errors. An additional `status` is added when returned from `onSubmit`
|
|
183
189
|
*/
|
|
184
|
-
interface IChangeEvent<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Omit<FormState<T, S, F>,
|
|
190
|
+
interface IChangeEvent<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Omit<FormState<T, S, F>, 'schemaValidationErrors' | 'schemaValidationErrorSchema'> {
|
|
185
191
|
/** The status of the form when submitted */
|
|
186
|
-
status?:
|
|
192
|
+
status?: 'submitted';
|
|
187
193
|
}
|
|
188
194
|
/** The `Form` component renders the outer form and all the fields defined in the `schema` */
|
|
189
195
|
declare class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Component<FormProps<T, S, F>, FormState<T, S, F>> {
|
|
190
196
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
191
197
|
* provide any possible type here
|
|
192
198
|
*/
|
|
193
|
-
formElement:
|
|
199
|
+
formElement: RefObject<any>;
|
|
194
200
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
195
201
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
196
202
|
* state construction.
|
|
@@ -277,7 +283,7 @@ declare class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
277
283
|
*
|
|
278
284
|
* @param event - The submit HTML form event
|
|
279
285
|
*/
|
|
280
|
-
onSubmit: (event:
|
|
286
|
+
onSubmit: (event: FormEvent<any>) => void;
|
|
281
287
|
/** Returns the registry for the form */
|
|
282
288
|
getRegistry(): Registry<T, S, F>;
|
|
283
289
|
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
@@ -304,14 +310,14 @@ declare class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
304
310
|
/** The properties for the `withTheme` function, essentially a subset of properties from the `FormProps` that can be
|
|
305
311
|
* overridden while creating a theme
|
|
306
312
|
*/
|
|
307
|
-
type ThemeProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Pick<FormProps<T, S, F>,
|
|
313
|
+
type ThemeProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Pick<FormProps<T, S, F>, 'fields' | 'templates' | 'widgets' | '_internalFormWrapper'>;
|
|
308
314
|
/** A Higher-Order component that creates a wrapper around a `Form` with the overrides from the `WithThemeProps` */
|
|
309
|
-
declare function withTheme<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(themeProps: ThemeProps<T, S, F>):
|
|
315
|
+
declare function withTheme<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(themeProps: ThemeProps<T, S, F>): ComponentType<FormProps<T, S, F>>;
|
|
310
316
|
|
|
311
317
|
/** The default registry consists of all the fields, templates and widgets provided in the core implementation,
|
|
312
318
|
* plus an empty `rootSchema` and `formContext. We omit schemaUtils here because it cannot be defaulted without a
|
|
313
319
|
* rootSchema and validator. It will be added into the computed registry later in the Form.
|
|
314
320
|
*/
|
|
315
|
-
declare function getDefaultRegistry<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(): Omit<Registry<T, S, F>,
|
|
321
|
+
declare function getDefaultRegistry<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(): Omit<Registry<T, S, F>, 'schemaUtils'>;
|
|
316
322
|
|
|
317
323
|
export { FormProps, FormState, IChangeEvent, ThemeProps, Form as default, getDefaultRegistry, withTheme };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/core",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "A simple React component capable of building HTML forms out of a JSON schema.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist && dts build --rollupTypes --format cjs,esm,umd",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"lodash": "^4.17.15",
|
|
41
41
|
"lodash-es": "^4.17.15",
|
|
42
|
+
"markdown-to-jsx": "^7.1.9",
|
|
42
43
|
"nanoid": "^3.3.4",
|
|
43
44
|
"prop-types": "^15.7.2"
|
|
44
45
|
},
|
|
@@ -52,9 +53,9 @@
|
|
|
52
53
|
"@babel/preset-env": "^7.20.2",
|
|
53
54
|
"@babel/preset-react": "^7.18.6",
|
|
54
55
|
"@babel/register": "^7.18.9",
|
|
55
|
-
"@rjsf/utils": "^5.1
|
|
56
|
-
"@rjsf/validator-ajv6": "^5.1
|
|
57
|
-
"@rjsf/validator-ajv8": "^5.1
|
|
56
|
+
"@rjsf/utils": "^5.2.1",
|
|
57
|
+
"@rjsf/validator-ajv6": "^5.2.1",
|
|
58
|
+
"@rjsf/validator-ajv8": "^5.2.1",
|
|
58
59
|
"@types/lodash": "^4.14.191",
|
|
59
60
|
"@types/react": "^17.0.39",
|
|
60
61
|
"@types/react-dom": "^17.0.11",
|
|
@@ -93,5 +94,5 @@
|
|
|
93
94
|
"publishConfig": {
|
|
94
95
|
"access": "public"
|
|
95
96
|
},
|
|
96
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "461f74b2f51c17e1cdaa327f63ef0fd88060fde0"
|
|
97
98
|
}
|