@rjsf/core 4.2.2 → 5.0.0-beta.2

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.
Files changed (78) hide show
  1. package/README.md +2 -2
  2. package/dist/components/Form.d.ts +274 -45
  3. package/dist/components/fields/ArrayField.d.ts +6 -51
  4. package/dist/components/fields/BooleanField.d.ts +7 -44
  5. package/dist/components/fields/MultiSchemaField.d.ts +42 -38
  6. package/dist/components/fields/NullField.d.ts +7 -5
  7. package/dist/components/fields/NumberField.d.ts +3 -46
  8. package/dist/components/fields/ObjectField.d.ts +71 -20
  9. package/dist/components/fields/SchemaField.d.ts +9 -38
  10. package/dist/components/fields/StringField.d.ts +6 -44
  11. package/dist/components/fields/index.d.ts +3 -26
  12. package/dist/components/templates/ArrayFieldDescriptionTemplate.d.ts +7 -0
  13. package/dist/components/templates/ArrayFieldItemTemplate.d.ts +6 -0
  14. package/dist/components/templates/ArrayFieldTemplate.d.ts +6 -0
  15. package/dist/components/templates/ArrayFieldTitleTemplate.d.ts +7 -0
  16. package/dist/components/templates/BaseInputTemplate.d.ts +8 -0
  17. package/dist/components/templates/ButtonTemplates/AddButton.d.ts +4 -0
  18. package/dist/components/templates/ButtonTemplates/IconButton.d.ts +5 -0
  19. package/dist/components/templates/ButtonTemplates/SubmitButton.d.ts +4 -0
  20. package/dist/components/templates/ButtonTemplates/index.d.ts +3 -0
  21. package/dist/components/templates/DescriptionField.d.ts +6 -0
  22. package/dist/components/templates/ErrorList.d.ts +6 -0
  23. package/dist/components/templates/FieldTemplate/FieldTemplate.d.ts +7 -0
  24. package/dist/components/templates/FieldTemplate/Label.d.ts +13 -0
  25. package/dist/components/templates/FieldTemplate/WrapIfAdditional.d.ts +12 -0
  26. package/dist/components/templates/FieldTemplate/index.d.ts +2 -0
  27. package/dist/components/templates/ObjectFieldTemplate.d.ts +8 -0
  28. package/dist/components/templates/TitleField.d.ts +6 -0
  29. package/dist/components/templates/UnsupportedField.d.ts +8 -0
  30. package/dist/components/templates/index.d.ts +3 -0
  31. package/dist/components/widgets/AltDateTimeWidget.d.ts +7 -21
  32. package/dist/components/widgets/AltDateWidget.d.ts +5 -21
  33. package/dist/components/widgets/CheckboxWidget.d.ts +7 -17
  34. package/dist/components/widgets/CheckboxesWidget.d.ts +7 -25
  35. package/dist/components/widgets/ColorWidget.d.ts +7 -15
  36. package/dist/components/widgets/DateTimeWidget.d.ts +7 -8
  37. package/dist/components/widgets/DateWidget.d.ts +7 -8
  38. package/dist/components/widgets/EmailWidget.d.ts +6 -8
  39. package/dist/components/widgets/FileWidget.d.ts +6 -18
  40. package/dist/components/widgets/HiddenWidget.d.ts +7 -11
  41. package/dist/components/widgets/PasswordWidget.d.ts +6 -8
  42. package/dist/components/widgets/RadioWidget.d.ts +7 -21
  43. package/dist/components/widgets/RangeWidget.d.ts +7 -8
  44. package/dist/components/widgets/SelectWidget.d.ts +7 -23
  45. package/dist/components/widgets/TextWidget.d.ts +6 -9
  46. package/dist/components/widgets/TextareaWidget.d.ts +10 -22
  47. package/dist/components/widgets/URLWidget.d.ts +6 -8
  48. package/dist/components/widgets/UpDownWidget.d.ts +6 -8
  49. package/dist/components/widgets/index.d.ts +3 -43
  50. package/dist/core.cjs.development.js +2947 -4606
  51. package/dist/core.cjs.development.js.map +1 -1
  52. package/dist/core.cjs.production.min.js +1 -1
  53. package/dist/core.cjs.production.min.js.map +1 -1
  54. package/dist/core.esm.js +2897 -4566
  55. package/dist/core.esm.js.map +1 -1
  56. package/dist/core.umd.development.js +4049 -0
  57. package/dist/core.umd.development.js.map +1 -0
  58. package/dist/core.umd.production.min.js +2 -0
  59. package/dist/core.umd.production.min.js.map +1 -0
  60. package/dist/getDefaultRegistry.d.ts +6 -0
  61. package/dist/index.d.ts +5 -70
  62. package/dist/withTheme.d.ts +7 -9
  63. package/package.json +41 -68
  64. package/dist/components/AddButton.d.ts +0 -5
  65. package/dist/components/ErrorList.d.ts +0 -1
  66. package/dist/components/IconButton.d.ts +0 -1
  67. package/dist/components/fields/DescriptionField.d.ts +0 -9
  68. package/dist/components/fields/TitleField.d.ts +0 -10
  69. package/dist/components/fields/UnsupportedField.d.ts +0 -14
  70. package/dist/components/widgets/BaseInput.d.ts +0 -23
  71. package/dist/components/widgets/SubmitButton.d.ts +0 -3
  72. package/dist/defaultRegistry.d.ts +0 -41
  73. package/dist/react-jsonschema-form.js +0 -26
  74. package/dist/react-jsonschema-form.js.map +0 -1
  75. package/dist/types.d.ts +0 -50
  76. package/dist/utils.d.ts +0 -81
  77. package/dist/validate.d.ts +0 -21
  78. package/index.d.ts +0 -500
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  <p align="center">
16
16
  Core logic and classic Bootstrap 3 theme for <a href="https://github.com/rjsf-team/react-jsonschema-form/"><code>react-jsonschema-form</code></a>.
17
17
  <br />
18
- <a href="https://react-jsonschema-form.readthedocs.io/en/latest/"><strong>Explore the docs »</strong></a>
18
+ <a href="https://react-jsonschema-form.readthedocs.io/en/stable/"><strong>Explore the docs »</strong></a>
19
19
  <br />
20
20
  <br />
21
21
  <a href="https://rjsf-team.github.io/react-jsonschema-form/">View Playground</a>
@@ -86,7 +86,7 @@ See the general [open issues](https://github.com/rjsf-team/react-jsonschema-form
86
86
 
87
87
  ## Contributing
88
88
 
89
- Read our [contributors' guide](https://react-jsonschema-form.readthedocs.io/en/latest/contributing/) to get started.
89
+ Read our [contributors' guide](https://react-jsonschema-form.readthedocs.io/en/stable/contributing/) to get started.
90
90
 
91
91
  <!-- CONTACT -->
92
92
 
@@ -1,48 +1,277 @@
1
- export default class Form extends React.Component<any, any, any> {
2
- static defaultProps: {
3
- uiSchema: {};
4
- noValidate: boolean;
5
- liveValidate: boolean;
6
- disabled: boolean;
7
- readonly: boolean;
8
- noHtml5Validate: boolean;
9
- ErrorList: typeof DefaultErrorList;
10
- omitExtraData: boolean;
11
- };
12
- constructor(props: any);
13
- formElement: any;
14
- getStateFromProps(props: any, inputFormData: any): {
15
- schema: any;
16
- uiSchema: any;
17
- idSchema: any;
18
- formData: any;
19
- edit: boolean;
20
- errors: any;
21
- errorSchema: any;
22
- additionalMetaSchemas: any;
23
- };
24
- validate(formData: any, schema?: any, additionalMetaSchemas?: any, customFormats?: any): {
25
- errors: any[];
26
- errorSchema: any;
27
- };
28
- renderErrors(): JSX.Element | null;
29
- getUsedFormData: (formData: any, fields: any) => any;
30
- getFieldNames: (pathSchema: any, formData: any) => any[];
31
- onChange: (formData: any, newErrorSchema: any) => void;
32
- onBlur: (...args: any[]) => void;
33
- onFocus: (...args: any[]) => void;
34
- onSubmit: (event: any) => void;
35
- getRegistry(): {
36
- fields: any;
37
- widgets: any;
38
- ArrayFieldTemplate: any;
39
- ObjectFieldTemplate: any;
40
- FieldTemplate: any;
41
- definitions: any;
42
- rootSchema: any;
43
- formContext: any;
1
+ import React, { Component } from "react";
2
+ import { CustomValidator, ErrorSchema, ErrorTransformer, IdSchema, PathSchema, RJSFSchema, RJSFValidationError, Registry, RegistryWidgetsType, RegistryFieldsType, SchemaUtilsType, TemplatesType, UiSchema, ValidationData, ValidatorType } from "@rjsf/utils";
3
+ /** The properties that are passed to the `Form` */
4
+ export interface FormProps<T = any, F = any> {
5
+ /** The JSON schema object for the form */
6
+ schema: RJSFSchema;
7
+ /** An implementation of the `ValidatorType` interface that is needed for form validation to work */
8
+ validator: ValidatorType<T>;
9
+ /** The uiSchema for the form */
10
+ uiSchema?: UiSchema<T, F>;
11
+ /** The data for the form, used to prefill a form with existing data */
12
+ formData?: T;
13
+ /** You can provide a `formContext` object to the form, which is passed down to all fields and widgets. Useful for
14
+ * implementing context aware fields and widgets.
15
+ *
16
+ * NOTE: Setting `{readonlyAsDisabled: false}` on the formContext will make the antd theme treat readOnly fields as
17
+ * disabled.
18
+ */
19
+ formContext?: F;
20
+ /** To avoid collisions with existing ids in the DOM, it is possible to change the prefix used for ids;
21
+ * Default is `root`
22
+ */
23
+ idPrefix?: string;
24
+ /** To avoid using a path separator that is present in field names, it is possible to change the separator used for
25
+ * ids (Default is `_`)
26
+ */
27
+ idSeparator?: string;
28
+ /** It's possible to disable the whole form by setting the `disabled` prop. The `disabled` prop is then forwarded down
29
+ * to each field of the form. If you just want to disable some fields, see the `ui:disabled` parameter in `uiSchema`
30
+ */
31
+ disabled?: boolean;
32
+ /** It's possible to make the whole form read-only by setting the `readonly` prop. The `readonly` prop is then
33
+ * forwarded down to each field of the form. If you just want to make some fields read-only, see the `ui:readonly`
34
+ * parameter in `uiSchema`
35
+ */
36
+ readonly?: boolean;
37
+ /** The dictionary of registered fields in the form */
38
+ fields?: RegistryFieldsType<T, F>;
39
+ /** The dictionary of registered templates in the form; Partial allows a subset to be provided beyond the defaults */
40
+ templates?: Partial<Omit<TemplatesType<T, F>, "ButtonTemplates">> & {
41
+ ButtonTemplates?: Partial<TemplatesType<T, F>["ButtonTemplates"]>;
44
42
  };
43
+ /** The dictionary of registered widgets in the form */
44
+ widgets?: RegistryWidgetsType<T, F>;
45
+ /** If you plan on being notified every time the form data are updated, you can pass an `onChange` handler, which will
46
+ * receive the same args as `onSubmit` any time a value is updated in the form
47
+ */
48
+ onChange?: (data: IChangeEvent<T, F>) => void;
49
+ /** To react when submitted form data are invalid, pass an `onError` handler. It will be passed the list of
50
+ * encountered errors
51
+ */
52
+ onError?: (errors: RJSFValidationError[]) => void;
53
+ /** You can pass a function as the `onSubmit` prop of your `Form` component to listen to when the form is submitted
54
+ * and its data are valid. It will be passed a result object having a `formData` attribute, which is the valid form
55
+ * data you're usually after. The original event will also be passed as a second parameter
56
+ */
57
+ onSubmit?: (data: IChangeEvent<T, F>, event: React.FormEvent<any>) => void;
58
+ /** Sometimes you may want to trigger events or modify external state when a field has been touched, so you can pass
59
+ * an `onBlur` handler, which will receive the id of the input that was blurred and the field value
60
+ */
61
+ onBlur?: (id: string, data: any) => void;
62
+ /** Sometimes you may want to trigger events or modify external state when a field has been focused, so you can pass
63
+ * an `onFocus` handler, which will receive the id of the input that is focused and the field value
64
+ */
65
+ onFocus?: (id: string, data: any) => void;
66
+ /** The value of this prop will be passed to the `accept-charset` HTML attribute on the form */
67
+ acceptcharset?: string;
68
+ /** The value of this prop will be passed to the `action` HTML attribute on the form
69
+ *
70
+ * NOTE: this just renders the `action` attribute in the HTML markup. There is no real network request being sent to
71
+ * this `action` on submit. Instead, react-jsonschema-form catches the submit event with `event.preventDefault()`
72
+ * and then calls the `onSubmit` function, where you could send a request programmatically with `fetch` or similar.
73
+ */
74
+ action?: string;
75
+ /** The value of this prop will be passed to the `autocomplete` HTML attribute on the form */
76
+ autoComplete?: string;
77
+ /** The value of this prop will be passed to the `class` HTML attribute on the form */
78
+ className?: string;
79
+ /** The value of this prop will be passed to the `enctype` HTML attribute on the form */
80
+ enctype?: string;
81
+ /** The value of this prop will be passed to the `id` HTML attribute on the form */
82
+ id?: string;
83
+ /** The value of this prop will be passed to the `name` HTML attribute on the form */
84
+ name?: string;
85
+ /** The value of this prop will be passed to the `method` HTML attribute on the form */
86
+ method?: string;
87
+ /** It's possible to change the default `form` tag name to a different HTML tag, which can be helpful if you are
88
+ * nesting forms. However, native browser form behaviour, such as submitting when the `Enter` key is pressed, may no
89
+ * longer work
90
+ */
91
+ tagName?: React.ElementType;
92
+ /** The value of this prop will be passed to the `target` HTML attribute on the form */
93
+ target?: string;
94
+ /** Formerly the `validate` prop; Takes a function that specifies custom validation rules for the form */
95
+ customValidate?: CustomValidator<T>;
96
+ /** This prop allows passing in custom errors that are augmented with the existing JSON Schema errors on the form; it
97
+ * can be used to implement asynchronous validation
98
+ */
99
+ extraErrors?: ErrorSchema<T>;
100
+ /** If set to true, turns off HTML5 validation on the form; Set to `false` by default */
101
+ noHtml5Validate?: boolean;
102
+ /** If set to true, turns off all validation. Set to `false` by default
103
+ *
104
+ * @deprecated - In a future release, this switch may be replaced by making `validator` prop optional
105
+ */
106
+ noValidate?: boolean;
107
+ /** If set to true, the form will perform validation and show any validation errors whenever the form data is changed,
108
+ * rather than just on submit
109
+ */
110
+ liveValidate?: boolean;
111
+ /** If `omitExtraData` and `liveOmit` are both set to true, then extra form data values that are not in any form field
112
+ * will be removed whenever `onChange` is called. Set to `false` by default
113
+ */
114
+ liveOmit?: boolean;
115
+ /** If set to true, then extra form data values that are not in any form field will be removed whenever `onSubmit` is
116
+ * called. Set to `false` by default.
117
+ */
118
+ omitExtraData?: boolean;
119
+ /** When this prop is set to true, a list of errors (or the custom error list defined in the `ErrorList`) will also
120
+ * show. When set to false, only inline input validation errors will be shown. Set to `true` by default
121
+ */
122
+ showErrorList?: boolean;
123
+ /** A function can be passed to this prop in order to make modifications to the default errors resulting from JSON
124
+ * Schema validation
125
+ */
126
+ transformErrors?: ErrorTransformer;
127
+ /**
128
+ * _internalFormWrapper is currently used by the semantic-ui theme to provide a custom wrapper around `<Form />`
129
+ * that supports the proper rendering of those themes. To use this prop, one must pass a component that takes two
130
+ * props: `children` and `as`. That component, at minimum, should render the `children` inside of a <form /> tag
131
+ * unless `as` is provided, in which case, use the `as` prop in place of `<form />`.
132
+ * i.e.:
133
+ * ```
134
+ * export default function InternalForm({ children, as }) {
135
+ * const FormTag = as || 'form';
136
+ * return <FormTag>{children}</FormTag>;
137
+ * }
138
+ * ```
139
+ *
140
+ * Use at your own risk as this prop is private and may change at any time without notice.
141
+ */
142
+ _internalFormWrapper?: React.ElementType;
143
+ }
144
+ /** The data that is contained within the state for the `Form` */
145
+ export interface FormState<T = any, F = any> {
146
+ /** The JSON schema object for the form */
147
+ schema: RJSFSchema;
148
+ /** The uiSchema for the form */
149
+ uiSchema: UiSchema<T, F>;
150
+ /** The `IdSchema` for the form, computed from the `schema`, the `rootFieldId`, the `formData` and the `idPrefix` and
151
+ * `idSeparator` props.
152
+ */
153
+ idSchema: IdSchema<T>;
154
+ /** The schemaUtils implementation used by the `Form`, created from the `validator` and the `schema` */
155
+ schemaUtils: SchemaUtilsType<T>;
156
+ /** The current data for the form, computed from the `formData` prop and the changes made by the user */
157
+ formData: T;
158
+ /** Flag indicating whether the form is in edit mode, true when `formData` is passed to the form, otherwise false */
159
+ edit: boolean;
160
+ /** The current list of errors for the form, includes `extraErrors` */
161
+ errors: RJSFValidationError[];
162
+ /** The current errors, in `ErrorSchema` format, for the form, includes `extraErrors` */
163
+ errorSchema: ErrorSchema<T>;
164
+ /** The current list of errors for the form directly from schema validation, does NOT include `extraErrors` */
165
+ schemaValidationErrors: RJSFValidationError[];
166
+ /** The current errors, in `ErrorSchema` format, for the form directly from schema validation, does NOT include
167
+ * `extraErrors`
168
+ */
169
+ schemaValidationErrorSchema: ErrorSchema<T>;
170
+ }
171
+ /** The event data passed when changes have been made to the form, includes everything from the `FormState` except
172
+ * the schema validation errors. An additional `status` is added when returned from `onSubmit`
173
+ */
174
+ export interface IChangeEvent<T = any, F = any> extends Omit<FormState<T, F>, "schemaValidationErrors" | "schemaValidationErrorSchema"> {
175
+ /** The status of the form when submitted */
176
+ status?: "submitted";
177
+ }
178
+ /** The `Form` component renders the outer form and all the fields defined in the `schema` */
179
+ export default class Form<T = any, F = any> extends Component<FormProps<T, F>, FormState<T, F>> {
180
+ /** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
181
+ * provide any possible type here
182
+ */
183
+ formElement: React.RefObject<any>;
184
+ /** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
185
+ * `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
186
+ * state construction.
187
+ *
188
+ * @param props - The initial props for the `Form`
189
+ */
190
+ constructor(props: FormProps<T, F>);
191
+ /** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
192
+ * will also call the`onChange` handler if the `formData` is modified to add missing default values as part of the
193
+ * state construction.
194
+ *
195
+ * @param nextProps - The new set of props about to be applied to the `Form`
196
+ */
197
+ UNSAFE_componentWillReceiveProps(nextProps: FormProps<T, F>): void;
198
+ /** Extracts the updated state from the given `props` and `inputFormData`. As part of this process, the
199
+ * `inputFormData` is first processed to add any missing required defaults. After that, the data is run through the
200
+ * validation process IF required by the `props`.
201
+ *
202
+ * @param props - The props passed to the `Form`
203
+ * @param inputFormData - The new or current data for the `Form`
204
+ * @returns - The new state for the `Form`
205
+ */
206
+ getStateFromProps(props: FormProps<T, F>, inputFormData?: T): FormState<T, F>;
207
+ /** React lifecycle method that is used to determine whether component should be updated.
208
+ *
209
+ * @param nextProps - The next version of the props
210
+ * @param nextState - The next version of the state
211
+ * @returns - True if the component should be updated, false otherwise
212
+ */
213
+ shouldComponentUpdate(nextProps: FormProps<T, F>, nextState: FormState<T, F>): boolean;
214
+ /** Validates the `formData` against the `schema` using the `schemaUtils`, returning the results.
215
+ *
216
+ * @param schemaUtils - The schemaUtils to use for validation
217
+ * @param formData - The new form data to validate
218
+ * @param schema - The schema used to validate against
219
+ */
220
+ validate(schemaUtils: SchemaUtilsType<T>, formData: T, schema?: import("json-schema").JSONSchema7): ValidationData<T>;
221
+ /** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
222
+ renderErrors(registry: Registry<T, F>): JSX.Element | null;
223
+ /** Returns the `formData` with only the elements specified in the `fields` list
224
+ *
225
+ * @param formData - The data for the `Form`
226
+ * @param fields - The fields to keep while filtering
227
+ */
228
+ getUsedFormData: (formData: T, fields: string[]) => T;
229
+ /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
230
+ *
231
+ * @param pathSchema - The `PathSchema` object for the form
232
+ * @param formData - The form data to use while checking for empty objects/arrays
233
+ */
234
+ getFieldNames: (pathSchema: PathSchema<T>, formData: T) => string[];
235
+ /** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
236
+ * `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
237
+ * then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filterer to remove any extra data not
238
+ * in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
239
+ * updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
240
+ * callback will be called if specified with the updated state.
241
+ *
242
+ * @param formData - The new form data from a change to a field
243
+ * @param newErrorSchema - The new `ErrorSchema` based on the field change
244
+ */
245
+ onChange: (formData: T, newErrorSchema?: ErrorSchema<T>) => void;
246
+ /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
247
+ * was provided.
248
+ *
249
+ * @param id - The unique `id` of the field that was blurred
250
+ * @param data - The data associated with the field that was blurred
251
+ */
252
+ onBlur: (id: string, data: any) => void;
253
+ /** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
254
+ * was provided.
255
+ *
256
+ * @param id - The unique `id` of the field that was focused
257
+ * @param data - The data associated with the field that was focused
258
+ */
259
+ onFocus: (id: string, data: any) => void;
260
+ /** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
261
+ * happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
262
+ * `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
263
+ * via the `onError()` callback unless validation is disabled. Finally it will add in any `extraErrors` and then call
264
+ * back the `onSubmit` callback if it was provided.
265
+ *
266
+ * @param event - The submit HTML form event
267
+ */
268
+ onSubmit: (event: React.FormEvent<any>) => void;
269
+ /** Returns the registry for the form */
270
+ getRegistry(): Registry<T, F>;
271
+ /** Provides a function that can be used to programmatically submit the `Form` */
45
272
  submit(): void;
273
+ /** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
274
+ * needed along with the submit button or any children of the form.
275
+ */
276
+ render(): JSX.Element;
46
277
  }
47
- import React from "react";
48
- import { default as DefaultErrorList } from "./ErrorList";
@@ -1,51 +1,6 @@
1
- export default ArrayField;
2
- declare class ArrayField extends React.Component<any, any, any> {
3
- static defaultProps: {
4
- uiSchema: {};
5
- formData: never[];
6
- idSchema: {};
7
- required: boolean;
8
- disabled: boolean;
9
- readonly: boolean;
10
- autofocus: boolean;
11
- };
12
- static getDerivedStateFromProps(nextProps: any, prevState: any): {
13
- updatedKeyedFormData: boolean;
14
- keyedFormData?: undefined;
15
- } | {
16
- keyedFormData: any;
17
- updatedKeyedFormData?: undefined;
18
- };
19
- constructor(props: any);
20
- get itemTitle(): any;
21
- isItemRequired(itemSchema: any): boolean;
22
- canAddItem(formItems: any): any;
23
- _getNewFormDataRow: () => any;
24
- onAddClick: (event: any) => void;
25
- onAddIndexClick: (index: any) => (event: any) => void;
26
- onDropIndexClick: (index: any) => (event: any) => void;
27
- onReorderClick: (index: any, newIndex: any) => (event: any) => void;
28
- onChangeForIndex: (index: any) => (value: any, errorSchema: any) => void;
29
- onSelectChange: (value: any) => void;
30
- renderNormalArray(): JSX.Element;
31
- renderCustomWidget(): JSX.Element;
32
- renderMultiSelect(): JSX.Element;
33
- renderFiles(): JSX.Element;
34
- renderFixedArray(): JSX.Element;
35
- renderArrayFieldItem(props: any): {
36
- children: JSX.Element;
37
- className: string;
38
- disabled: any;
39
- hasToolbar: any;
40
- hasMoveUp: any;
41
- hasMoveDown: any;
42
- hasRemove: any;
43
- index: any;
44
- key: any;
45
- onAddIndexClick: (index: any) => (event: any) => void;
46
- onDropIndexClick: (index: any) => (event: any) => void;
47
- onReorderClick: (index: any, newIndex: any) => (event: any) => void;
48
- readonly: any;
49
- };
50
- }
51
- import React from "react";
1
+ import { Field } from "@rjsf/utils";
2
+ /** `ArrayField` is `React.ComponentType<FieldProps<T[], F>>` (necessarily) but the `registry` requires things to be a
3
+ * `Field` which is defined as `React.ComponentType<FieldProps<T, F>>`, so cast it to make `registry` happy.
4
+ */
5
+ declare const _default: Field<any, any>;
6
+ export default _default;
@@ -1,45 +1,8 @@
1
+ import { FieldProps } from "@rjsf/utils";
2
+ /** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
3
+ * two boolean values based on the various alternatives in the schema.
4
+ *
5
+ * @param props - The `FieldProps` for this template
6
+ */
7
+ declare function BooleanField<T = any, F = any>(props: FieldProps<T, F>): JSX.Element;
1
8
  export default BooleanField;
2
- declare function BooleanField(props: any): JSX.Element;
3
- declare namespace BooleanField {
4
- export const propTypes: {
5
- autofocus: import("prop-types").Requireable<boolean>;
6
- disabled: import("prop-types").Requireable<boolean>;
7
- errorSchema: import("prop-types").Requireable<object>;
8
- formData: import("prop-types").Requireable<any>;
9
- idSchema: import("prop-types").Requireable<object>;
10
- onBlur: import("prop-types").Requireable<(...args: any[]) => any>;
11
- onChange: import("prop-types").Validator<(...args: any[]) => any>;
12
- onFocus: import("prop-types").Requireable<(...args: any[]) => any>;
13
- rawErrors: import("prop-types").Requireable<(string | null | undefined)[]>;
14
- readonly: import("prop-types").Requireable<boolean>;
15
- registry: import("prop-types").Validator<import("prop-types").InferProps<{
16
- ArrayFieldTemplate: import("prop-types").Requireable<import("prop-types").ReactComponentLike>;
17
- FieldTemplate: import("prop-types").Requireable<import("prop-types").ReactComponentLike>;
18
- ObjectFieldTemplate: import("prop-types").Requireable<import("prop-types").ReactComponentLike>;
19
- definitions: import("prop-types").Validator<object>;
20
- rootSchema: import("prop-types").Requireable<object>;
21
- fields: import("prop-types").Validator<{
22
- [x: string]: string | ((props: any, context?: any) => any) | (new (props: any, context?: any) => any) | null | undefined;
23
- }>;
24
- formContext: import("prop-types").Validator<object>;
25
- widgets: import("prop-types").Validator<{
26
- [x: string]: object | null | undefined;
27
- }>;
28
- }>>;
29
- required: import("prop-types").Requireable<boolean>;
30
- schema: import("prop-types").Validator<object>;
31
- uiSchema: import("prop-types").Requireable<import("prop-types").InferProps<{
32
- "ui:options": import("prop-types").Requireable<import("prop-types").InferProps<{
33
- addable: import("prop-types").Requireable<boolean>;
34
- orderable: import("prop-types").Requireable<boolean>;
35
- removable: import("prop-types").Requireable<boolean>;
36
- }>>;
37
- }>>;
38
- };
39
- export const defaultProps: {
40
- uiSchema: {};
41
- disabled: boolean;
42
- readonly: boolean;
43
- autofocus: boolean;
44
- };
45
- }
@@ -1,40 +1,44 @@
1
- export default AnyOfField;
2
- declare class AnyOfField extends React.Component<any, any, any> {
3
- constructor(props: any);
4
- getMatchingOption(formData: any, options: any): any;
1
+ import { Component } from "react";
2
+ import { FieldProps, RJSFSchema } from "@rjsf/utils";
3
+ /** Type used for the state of the `AnyOfField` component */
4
+ declare type AnyOfFieldState = {
5
+ /** The currently selected option */
6
+ selectedOption: number;
7
+ };
8
+ /** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
9
+ * the currently selected option and cleans up any irrelevant data in `formData`.
10
+ *
11
+ * @param props - The `FieldProps` for this template
12
+ */
13
+ declare class AnyOfField<T = any, F = any> extends Component<FieldProps<T, F>, AnyOfFieldState> {
14
+ /** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
15
+ *
16
+ * @param props - The `FieldProps` for this template
17
+ */
18
+ constructor(props: FieldProps<T, F>);
19
+ /** React lifecycle methos that is called when the props and/or state for this component is updated. It recomputes the
20
+ * currently selected option based on the overall `formData`
21
+ *
22
+ * @param prevProps - The previous `FieldProps` for this template
23
+ * @param prevState - The previous `AnyOfFieldState` for this template
24
+ */
25
+ componentDidUpdate(prevProps: Readonly<FieldProps<T, F>>, prevState: Readonly<AnyOfFieldState>): void;
26
+ /** Determines the best matching option for the given `formData` and `options`.
27
+ *
28
+ * @param formData - The new formData
29
+ * @param options - The list of options to choose from
30
+ * @return - The index of the `option` that best matches the `formData`
31
+ */
32
+ getMatchingOption(selectedOption: number, formData: T, options: RJSFSchema[]): number;
33
+ /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
34
+ * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
35
+ * the `onChange` handler.
36
+ *
37
+ * @param option -
38
+ */
5
39
  onOptionChange: (option: any) => void;
40
+ /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
41
+ */
42
+ render(): JSX.Element;
6
43
  }
7
- declare namespace AnyOfField {
8
- export const defaultProps: {
9
- disabled: boolean;
10
- readonly: boolean;
11
- hideError: boolean;
12
- errorSchema: {};
13
- idSchema: {};
14
- uiSchema: {};
15
- };
16
- export namespace propTypes {
17
- export const options: PropTypes.Validator<(object | null | undefined)[]>;
18
- export const baseType: PropTypes.Requireable<string>;
19
- export const uiSchema: PropTypes.Requireable<object>;
20
- export const idSchema: PropTypes.Requireable<object>;
21
- export const formData: PropTypes.Requireable<any>;
22
- export const errorSchema: PropTypes.Requireable<object>;
23
- export const registry: PropTypes.Validator<PropTypes.InferProps<{
24
- ArrayFieldTemplate: PropTypes.Requireable<PropTypes.ReactComponentLike>;
25
- FieldTemplate: PropTypes.Requireable<PropTypes.ReactComponentLike>;
26
- ObjectFieldTemplate: PropTypes.Requireable<PropTypes.ReactComponentLike>;
27
- definitions: PropTypes.Validator<object>;
28
- rootSchema: PropTypes.Requireable<object>;
29
- fields: PropTypes.Validator<{
30
- [x: string]: string | ((props: any, context?: any) => any) | (new (props: any, context?: any) => any) | null | undefined;
31
- }>;
32
- formContext: PropTypes.Validator<object>;
33
- widgets: PropTypes.Validator<{
34
- [x: string]: object | null | undefined;
35
- }>;
36
- }>>;
37
- }
38
- }
39
- import React from "react";
40
- import PropTypes from "prop-types";
44
+ export default AnyOfField;
@@ -1,6 +1,8 @@
1
+ import { FieldProps } from "@rjsf/utils";
2
+ /** The `NullField` component is used to render a field in the schema is null. It also ensures that the `formData` is
3
+ * also set to null if it has no value.
4
+ *
5
+ * @param props - The `FieldProps` for this template
6
+ */
7
+ declare function NullField<T = any, F = any>(props: FieldProps<T, F>): null;
1
8
  export default NullField;
2
- declare class NullField extends Component<any, any, any> {
3
- constructor(props: any);
4
- constructor(props: any, context: any);
5
- }
6
- import { Component } from "react";
@@ -1,4 +1,4 @@
1
- export default NumberField;
1
+ import { FieldProps } from "@rjsf/utils";
2
2
  /**
3
3
  * The NumberField class has some special handling for dealing with trailing
4
4
  * decimal points and/or zeroes. This logic is designed to allow trailing values
@@ -16,48 +16,5 @@ export default NumberField;
16
16
  * value cached in the state. If it matches the cached value, the cached
17
17
  * value is passed to the input instead of the formData value
18
18
  */
19
- declare class NumberField extends React.Component<any, any, any> {
20
- constructor(props: any);
21
- handleChange: (value: any) => void;
22
- }
23
- declare namespace NumberField {
24
- export const propTypes: {
25
- autofocus: import("prop-types").Requireable<boolean>;
26
- disabled: import("prop-types").Requireable<boolean>;
27
- errorSchema: import("prop-types").Requireable<object>;
28
- formData: import("prop-types").Requireable<any>;
29
- idSchema: import("prop-types").Requireable<object>;
30
- onBlur: import("prop-types").Requireable<(...args: any[]) => any>;
31
- onChange: import("prop-types").Validator<(...args: any[]) => any>;
32
- onFocus: import("prop-types").Requireable<(...args: any[]) => any>;
33
- rawErrors: import("prop-types").Requireable<(string | null | undefined)[]>;
34
- readonly: import("prop-types").Requireable<boolean>;
35
- registry: import("prop-types").Validator<import("prop-types").InferProps<{
36
- ArrayFieldTemplate: import("prop-types").Requireable<import("prop-types").ReactComponentLike>;
37
- FieldTemplate: import("prop-types").Requireable<import("prop-types").ReactComponentLike>;
38
- ObjectFieldTemplate: import("prop-types").Requireable<import("prop-types").ReactComponentLike>;
39
- definitions: import("prop-types").Validator<object>;
40
- rootSchema: import("prop-types").Requireable<object>;
41
- fields: import("prop-types").Validator<{
42
- [x: string]: string | ((props: any, context?: any) => any) | (new (props: any, context?: any) => any) | null | undefined;
43
- }>;
44
- formContext: import("prop-types").Validator<object>;
45
- widgets: import("prop-types").Validator<{
46
- [x: string]: object | null | undefined;
47
- }>;
48
- }>>;
49
- required: import("prop-types").Requireable<boolean>;
50
- schema: import("prop-types").Validator<object>;
51
- uiSchema: import("prop-types").Requireable<import("prop-types").InferProps<{
52
- "ui:options": import("prop-types").Requireable<import("prop-types").InferProps<{
53
- addable: import("prop-types").Requireable<boolean>;
54
- orderable: import("prop-types").Requireable<boolean>;
55
- removable: import("prop-types").Requireable<boolean>;
56
- }>>;
57
- }>>;
58
- };
59
- export namespace defaultProps {
60
- export const uiSchema: {};
61
- }
62
- }
63
- import React from "react";
19
+ declare function NumberField<T = any, F = any>(props: FieldProps<T, F>): JSX.Element;
20
+ export default NumberField;