Skip to content

Commit b302ebb

Browse files
burnettkheath-freenome
authored andcommitted
Fix documentation to add missing Form imports
Fix rjsf-team#4127 to add missing `Form` import in documentation - Updated many of the documentation files to add missing imports of `Form` - Updated the `CHANGELOG.md` accordingly
1 parent c70d81f commit b302ebb

File tree

8 files changed

+53
-3
lines changed

8 files changed

+53
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ should change the heading of the (upcoming) version to include a major version b
2929
## Dev / docs / playground
3030

3131
- Updated the documentation to describe how to use the `skipEmptyDefault` option.
32+
- Fixed missing import of `Form` in usage documentation - fixing [#4127](https://github.com/rjsf-team/react-jsonschema-form/issues/4127)
3233

3334
# 5.17.1
3435

packages/docs/docs/00-introduction.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ $ npm install @rjsf/core @rjsf/utils @rjsf/validator-ajv8 --save
3333
Then import the dependencies as follows:
3434

3535
```ts
36-
import validator from '@rjsf/validator-ajv8';
3736
import Form from '@rjsf/core';
37+
import validator from '@rjsf/validator-ajv8';
3838
```
3939

40-
Our latest version requires React 16+. You can also install `react-jsonschema-form` (the 1.x version) which works with React 15+.
40+
Our latest version requires React 16+.
4141

4242
## Usage
4343

4444
```tsx
45+
import Form from '@rjsf/core';
4546
import { RJSFSchema } from '@rjsf/utils';
4647
import validator from '@rjsf/validator-ajv8';
4748

packages/docs/docs/01-quickstart.md

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ NOTE: As of version 5, the `Form` now requires you to provide a `validator` impl
88
First, specify a schema using the [JSON Schema specification](https://json-schema.org/). The below schema renders a single string field:
99

1010
```tsx
11+
import Form from '@rjsf/core';
1112
import { RJSFSchema } from '@rjsf/utils';
1213
import validator from '@rjsf/validator-ajv8';
1314

@@ -22,6 +23,7 @@ render(<Form schema={schema} validator={validator} />, document.getElementById('
2223
You can also render an object with multiple fields with the below schema:
2324

2425
```tsx
26+
import Form from '@rjsf/core';
2527
import { RJSFSchema } from '@rjsf/utils';
2628
import validator from '@rjsf/validator-ajv8';
2729

@@ -49,6 +51,7 @@ The uiSchema is used to add more customization to the form's look and feel. Use
4951
attribute of the uiSchema to add a custom CSS class name to the form:
5052

5153
```tsx
54+
import Form from '@rjsf/core';
5255
import { RJSFSchema, UiSchema } from '@rjsf/utils';
5356
import validator from '@rjsf/validator-ajv8';
5457

@@ -69,6 +72,7 @@ uiSchema should be `{key: value}`, where `key` is the property key and `value` i
6972
object with the uiSchema configuration for that particular property. For example:
7073

7174
```tsx
75+
import Form from '@rjsf/core';
7276
import { RJSFSchema, UiSchema } from '@rjsf/utils';
7377
import validator from '@rjsf/validator-ajv8';
7478

@@ -102,6 +106,7 @@ render(<Form schema={schema} validator={validator} />, document.getElementById('
102106
Often you'll want to prefill a form with existing data; this is done by passing a `formData` prop object matching the schema:
103107

104108
```tsx
109+
import Form from '@rjsf/core';
105110
import { RJSFSchema } from '@rjsf/utils';
106111
import validator from '@rjsf/validator-ajv8';
107112

@@ -139,6 +144,7 @@ By default, `<Form />` is an [uncontrolled component](https://reactjs.org/docs/u
139144
`onChange` and `formData` props as in the below example:
140145

141146
```tsx
147+
import Form from '@rjsf/core';
142148
import validator from '@rjsf/validator-ajv8';
143149

144150
const App = () => {

packages/docs/docs/api-reference/form-props.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ You can provide custom buttons to your form via the `Form` component's `children
3333
For other ways to modify the default `Submit` button, see both the [Submit Button Options](./uiSchema.md#submitbuttonoptions) and the [SubmitButton Template](../advanced-customization/custom-templates.md#submitbutton) documentation.
3434

3535
```tsx
36+
import { Form } from '@rjsf/core';
3637
import { RJSFSchema } from '@rjsf/utils';
3738
import validator from '@rjsf/validator-ajv8';
3839

@@ -102,6 +103,7 @@ Optional enumerated flag controlling how empty object fields are populated, defa
102103
| `skipEmptyDefaults` | Does not set an empty default. It will still apply the default value if a default property is defined in your schema |
103104

104105
```tsx
106+
import { Form } from '@rjsf/core';
105107
import { RJSFSchema } from '@rjsf/utils';
106108
import validator from '@rjsf/validator-ajv8';
107109

@@ -133,6 +135,7 @@ Optional enumerated flag controlling how empty defaults are populated when `allO
133135
| `populateDefaults` | Generate default values for properties in the `allOf` schema including `if-then-else` syntax |
134136

135137
```tsx
138+
import { Form } from '@rjsf/core';
136139
import { RJSFSchema } from '@rjsf/utils';
137140
import validator from '@rjsf/validator-ajv8';
138141

@@ -190,6 +193,7 @@ render(
190193
It's possible to disable the whole form by setting the `disabled` prop. The `disabled` prop is then forwarded down to each field of the form.
191194

192195
```tsx
196+
import { Form } from '@rjsf/core';
193197
import { RJSFSchema } from '@rjsf/utils';
194198
import validator from '@rjsf/validator-ajv8';
195199

@@ -207,6 +211,7 @@ If you just want to disable some fields, see the `ui:disabled` parameter in `uiS
207211
It's possible to make the whole form read-only by setting the `readonly` prop. The `readonly` prop is then forwarded down to each field of the form.
208212

209213
```tsx
214+
import { Form } from '@rjsf/core';
210215
import { RJSFSchema } from '@rjsf/utils';
211216
import validator from '@rjsf/validator-ajv8';
212217

@@ -244,7 +249,9 @@ If set to true, then the first field with an error will receive the focus when t
244249
You can also provide a custom callback function to handle what happens when this function is called.
245250

246251
```tsx
252+
import { Form } from '@rjsf/core';
247253
import { RJSFSchema, RJSFValidationError } from '@rjsf/utils';
254+
import validator from '@rjsf/validator-ajv8';
248255

249256
const schema: RJSFSchema = {
250257
type: 'string',
@@ -254,7 +261,7 @@ const focusOnError = (error: RJSFValidationError) => {
254261
console.log('I need to handle focusing this error');
255262
};
256263

257-
render(<Form schema={schema} focusOnFirstError={focusOnError} />, document.getElementById('app'));
264+
render(<Form schema={schema} validator={validator} focusOnFirstError={focusOnError} />, document.getElementById('app'));
258265
```
259266

260267
## formContext
@@ -277,6 +284,7 @@ The value of this prop will be passed to the `id` [HTML attribute on the form](h
277284
To avoid collisions with existing ids in the DOM, it is possible to change the prefix used for ids (the default is `root`).
278285

279286
```tsx
287+
import { Form } from '@rjsf/core';
280288
import { RJSFSchema } from '@rjsf/utils';
281289
import validator from '@rjsf/validator-ajv8';
282290

@@ -294,6 +302,7 @@ This will render `<input id="rjsf_prefix_key">` instead of `<input id="root_key"
294302
To avoid using a path separator that is present in field names, it is possible to change the separator used for ids (the default is `_`).
295303

296304
```tsx
305+
import { Form } from '@rjsf/core';
297306
import { RJSFSchema } from '@rjsf/utils';
298307
import validator from '@rjsf/validator-ajv8';
299308

@@ -356,6 +365,7 @@ In the case of adding/removing of new fields in arrays or objects with `addition
356365
To react when submitted form data are invalid, pass an `onError` handler. It will be passed the list of encountered errors:
357366

358367
```tsx
368+
import { Form } from '@rjsf/core';
359369
import { RJSFSchema } from '@rjsf/utils';
360370
import validator from '@rjsf/validator-ajv8';
361371

@@ -378,6 +388,7 @@ It will be passed a result object having a `formData` attribute, which is the va
378388
The original event will also be passed as a second parameter:
379389

380390
```tsx
391+
import { Form } from '@rjsf/core';
381392
import { RJSFSchema } from '@rjsf/utils';
382393
import validator from '@rjsf/validator-ajv8';
383394

packages/docs/docs/api-reference/uiSchema.md

+5
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ Field labels are rendered by default.
293293
Labels may be omitted on a per-field by setting the `label` option to `false` in the `ui:options` uiSchema directive.
294294

295295
```tsx
296+
import { Form } from '@rjsf/core';
296297
import { RJSFSchema, UiSchema } from '@rjsf/utils';
297298
import validator from '@rjsf/validator-ajv8';
298299

@@ -309,6 +310,7 @@ render(<Form schema={schema} uiSchema={uiSchema} validator={validator} />, docum
309310
They can also be omitted globally by setting the `label` option to `false` in the `ui:globalOptions` uiSchema directive.
310311

311312
```tsx
313+
import { Form } from '@rjsf/core';
312314
import { RJSFSchema, UiSchema } from '@rjsf/utils';
313315
import validator from '@rjsf/validator-ajv8';
314316

@@ -331,6 +333,7 @@ This property allows you to reorder the properties that are shown for a particul
331333
You can add placeholder text to an input by using the `ui:placeholder` uiSchema directive:
332334

333335
```tsx
336+
import { Form } from '@rjsf/core';
334337
import { RJSFSchema, UiSchema } from '@rjsf/utils';
335338
import validator from '@rjsf/validator-ajv8';
336339

@@ -345,6 +348,7 @@ render(<Form schema={schema} uiSchema={uiSchema} validator={validator} />, docum
345348
Fields using `enum` can also use `ui:placeholder`. The value will be used as the text for the empty option in the select widget.
346349

347350
```tsx
351+
import { Form } from '@rjsf/core';
348352
import { RJSFSchema, UiSchema } from '@rjsf/utils';
349353
import validator from '@rjsf/validator-ajv8';
350354

@@ -367,6 +371,7 @@ The `ui:readonly` uiSchema directive will mark all child widgets from a given fi
367371
You can set the initial height of a textarea widget by specifying `rows` option.
368372

369373
```tsx
374+
import { Form } from '@rjsf/core';
370375
import { RJSFSchema, UiSchema } from '@rjsf/utils';
371376
import validator from '@rjsf/validator-ajv8';
372377

packages/docs/docs/json-schema/objects.md

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Objects are defined with a type equal to `object` and properties specified in the `properties` keyword.
66

77
```tsx
8+
import { Form } from '@rjsf/core';
89
import { RJSFSchema } from '@rjsf/utils';
910
import validator from '@rjsf/validator-ajv8';
1011

@@ -30,6 +31,7 @@ render(<Form schema={schema} validator={validator} />, document.getElementById('
3031
You can specify which properties are required using the `required` attribute:
3132

3233
```tsx
34+
import { Form } from '@rjsf/core';
3335
import { RJSFSchema } from '@rjsf/utils';
3436
import validator from '@rjsf/validator-ajv8';
3537

@@ -56,6 +58,7 @@ render(<Form schema={schema} validator={validator} />, document.getElementById('
5658
Since the order of object properties in Javascript and JSON is not guaranteed, the `uiSchema` object spec allows you to define the order in which properties are rendered using the `ui:order` property:
5759

5860
```tsx
61+
import { Form } from '@rjsf/core';
5962
import { RJSFSchema, UiSchema } from '@rjsf/utils';
6063
import validator from '@rjsf/validator-ajv8';
6164

@@ -89,6 +92,7 @@ const uiSchema: UiSchema = {
8992
The `additionalProperties` keyword allows the user to add properties with arbitrary key names. Set this keyword equal to a schema object:
9093

9194
```tsx
95+
import { Form } from '@rjsf/core';
9296
import { RJSFSchema } from '@rjsf/utils';
9397
import validator from '@rjsf/validator-ajv8';
9498

packages/docs/docs/usage/validation.md

+18
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ You can enable live form data validation by passing a `liveValidate` prop to the
229229
Be warned that this is an expensive strategy, with possibly strong impact on performances.
230230

231231
```tsx
232+
import { Form } from '@rjsf/core';
232233
import { RJSFSchema } from '@rjsf/utils';
233234
import validator from '@rjsf/validator-ajv8';
234235

@@ -251,6 +252,7 @@ If you have provided an `onError` callback it will be called with the list of er
251252

252253
```tsx
253254
import { createRef } from 'react';
255+
import { Form } from '@rjsf/core';
254256
import { RJSFSchema } from '@rjsf/utils';
255257
import validator from '@rjsf/validator-ajv8';
256258

@@ -273,6 +275,7 @@ if (formRef.current.validateForm()) {
273275
By default, the form uses HTML5 validation. This may cause unintuitive results because the HTML5 validation errors (such as when a field is `required`) may be displayed before the form is submitted, and thus these errors will display differently from the react-jsonschema-form validation errors. You can turn off HTML validation by setting the `noHtml5Validate` to `true`.
274276

275277
```tsx
278+
import { Form } from '@rjsf/core';
276279
import { RJSFSchema } from '@rjsf/utils';
277280
import validator from '@rjsf/validator-ajv8';
278281

@@ -297,6 +300,7 @@ But it is possible to define your own custom validation rules that will run in a
297300
This is especially useful when the validation depends on several interdependent fields.
298301

299302
```tsx
303+
import { Form } from '@rjsf/core';
300304
import { RJSFSchema } from '@rjsf/utils';
301305
import validator from '@rjsf/validator-ajv8';
302306

@@ -331,6 +335,7 @@ Validation error messages are provided by the JSON Schema validation by default.
331335
If you need to change these messages or make any other modifications to the errors from the JSON Schema validation, you can define a transform function that receives the list of JSON Schema errors and returns a new list.
332336

333337
```tsx
338+
import { Form } from '@rjsf/core';
334339
import { RJSFSchema } from '@rjsf/utils';
335340
import validator from '@rjsf/validator-ajv8';
336341

@@ -379,6 +384,7 @@ This list is the form global error list that appears at the top of your forms.
379384
An error list template is basically a React stateless component being passed errors as props, so you can render them as you like:
380385

381386
```tsx
387+
import { Form } from '@rjsf/core';
382388
import { RJSFSchema, ErrorListProps } from "@rjsf/utils";
383389
import validator from "@rjsf/validator-ajv8";
384390

@@ -461,6 +467,7 @@ const metaSchemaDraft04 = require('ajv/lib/refs/json-schema-draft-04.json');
461467
In this example `schema` passed as props to `Form` component can be validated against draft-07 (default) and by draft-04 (added), depending on the value of `$schema` attribute.
462468

463469
```tsx
470+
import { Form } from '@rjsf/core';
464471
import { RJSFSchema } from '@rjsf/utils';
465472
import { customizeValidator } from '@rjsf/validator-ajv6';
466473

@@ -479,6 +486,7 @@ return <Form schema={schema} validator={validator} />;
479486
NOTE: This syntax works only for the `@rjsf/validator-ajv6` validator; if you only use the `draft-04` schema, and you want to use the `@rjsf/validator-ajv8` you can do the following:
480487

481488
```tsx
489+
import { Form } from '@rjsf/core';
482490
import { RJSFSchema } from '@rjsf/utils';
483491
import { customizeValidator } from '@rjsf/validator-ajv8';
484492
import AjvDraft04 from 'ajv-draft-04';
@@ -500,6 +508,7 @@ react-jsonschema-form adds two formats, `color` and `data-url`, to support certa
500508
To add formats of your own, you can create and pass to the `Form` component a customized `@rjsf/validator-ajv8`:
501509

502510
```tsx
511+
import { Form } from '@rjsf/core';
503512
import { RJSFSchema } from '@rjsf/utils';
504513
import { customizeValidator } from '@rjsf/validator-ajv8';
505514

@@ -526,6 +535,7 @@ Handling async errors is an important part of many applications. Support for thi
526535
For example, a request could be made to some backend when the user submits the form. If that request fails, the errors returned by the backend should be formatted like in the following example.
527536

528537
```tsx
538+
import { Form } from '@rjsf/core';
529539
import { RJSFSchema, ErrorSchema } from '@rjsf/utils';
530540
import validator from '@rjsf/validator-ajv8';
531541

@@ -568,6 +578,7 @@ In version 5, with the advent of the decoupling of the validation implementation
568578
For instance, if you need more information from `ajv` about errors via the `verbose` option, now you can turn it on!
569579

570580
```tsx
581+
import { Form } from '@rjsf/core';
571582
import { RJSFSchema } from '@rjsf/utils';
572583
import { customizeValidator } from '@rjsf/validator-ajv8';
573584

@@ -621,6 +632,7 @@ Finally, the Ajv 8 validator supports the localization of error messages.
621632
By default, ALL formats are being added to the default `@rjsf/validator-ajv8` that you get when you import it.
622633

623634
```tsx
635+
import { Form } from '@rjsf/core';
624636
import { RJSFSchema } from '@rjsf/utils';
625637
import validator from '@rjsf/validator-ajv8';
626638

@@ -635,6 +647,7 @@ render(<Form schema={schema} validator={validator} />, document.getElementById('
635647
If you don't actually need any of the [ajv-formats](https://github.com/ajv-validator/ajv-formats#formats) and want to reduce the memory footprint, then you can turn it off as follows:
636648

637649
```tsx
650+
import { Form } from '@rjsf/core';
638651
import { RJSFSchema } from '@rjsf/utils';
639652
import { customizeValidator } from '@rjsf/validator-ajv8';
640653

@@ -650,6 +663,7 @@ render(<Form schema={schema} validator={validator} />, document.getElementById('
650663
If you only need some of them, you can pass any of the [options](https://github.com/ajv-validator/ajv-formats#options) to the formatter:
651664

652665
```tsx
666+
import { Form } from '@rjsf/core';
653667
import { RJSFSchema } from '@rjsf/utils';
654668
import { customizeValidator } from '@rjsf/validator-ajv8';
655669

@@ -672,6 +686,7 @@ It is possible to use one of the other version it supports, like `draft-2019-09`
672686
NOTE: `draft-2020-12` has breaking changes and hasn't been fully tested with `@rjsf`.
673687

674688
```tsx
689+
import { Form } from '@rjsf/core';
675690
import { RJSFSchema } from '@rjsf/utils';
676691
import { customizeValidator } from '@rjsf/validator-ajv8';
677692
import Ajv2019 from 'ajv/dist/2019';
@@ -707,6 +722,7 @@ NOTE: The `ajv-i18n` validators implement the `Localizer` interface.
707722
Using a specific locale while including all of `ajv-i18n`:
708723

709724
```tsx
725+
import { Form } from '@rjsf/core';
710726
import { RJSFSchema } from '@rjsf/utils';
711727
import { customizeValidator } from '@rjsf/validator-ajv8';
712728
import localizer from 'ajv-i18n';
@@ -723,6 +739,7 @@ render(<Form schema={schema} validator={validator} />, document.getElementById('
723739
Using a specific locale minimizing the bundle size
724740

725741
```tsx
742+
import { Form } from '@rjsf/core';
726743
import { RJSFSchema } from '@rjsf/utils';
727744
import { customizeValidator } from '@rjsf/validator-ajv8';
728745
import spanishLocalizer from 'ajv-i18n/localize/es';
@@ -739,6 +756,7 @@ render(<Form schema={schema} validator={validator} />, document.getElementById('
739756
An example of a custom `Localizer` implementation:
740757

741758
```tsx
759+
import { Form } from '@rjsf/core';
742760
import { RJSFSchema } from '@rjsf/utils';
743761
import { customizeValidator } from '@rjsf/validator-ajv8';
744762
import { ErrorObject } from 'ajv';

0 commit comments

Comments
 (0)