docs: update docs about new clearChildValidation prop

This commit is contained in:
Daniel Lautzenheiser 2023-08-31 12:13:43 -04:00
parent e0dadaf817
commit e2d32471ad
2 changed files with 26 additions and 48 deletions

View File

@ -73,6 +73,7 @@ export const createMockWidgetControlProps = <
controlled: false, controlled: false,
theme: 'light', theme: 'light',
onChange: jest.fn(), onChange: jest.fn(),
clearChildValidation: jest.fn(),
query: jest.fn(), query: jest.fn(),
t: jest.fn(), t: jest.fn(),
...extra, ...extra,

View File

@ -39,54 +39,31 @@ CMS.registerWidget(name, control, [preview], [{ schema }]);
The react component that renders the control. It receives the following props: The react component that renders the control. It receives the following props:
| Param | Type | Description | | Param | Type | Description |
| ------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | -------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| label | string | The label for the widget | | label | string | The label for the widget |
| value | An valid widget value | The current value of the widget | | value | An valid widget value | The current value of the widget |
| onChange | function | Function to be called when the value changes. Accepts a valid widget value | | onChange | function | Function to be called when the value changes. Accepts a valid widget value |
| field | object | The field configuration for the current widget. See [Widget Options](/docs/widgets#common-widget-options) | | clearChildValidation | function | Clears all validation errors for children of the widget |
| collection | object | The collection configuration for the current widget. See [Collections](/docs/collection-overview) | | field | object | The field configuration for the current widget. See [Widget Options](/docs/widgets#common-widget-options) |
| collectionFile | object | The collection file configuration for the current widget if entry is part of a [File Collection](/docs/collection-types#file-collections) | | collection | object | The collection configuration for the current widget. See [Collections](/docs/collection-overview) |
| config | object | The current Static CMS config. See [configuration options](/docs/configuration-options) | | collectionFile | object | The collection file configuration for the current widget if entry is part of a [File Collection](/docs/collection-types#file-collections) |
| entry | object | Object with a `data` field that contains the current value of all widgets in the editor | | config | object | The current Static CMS config. See [configuration options](/docs/configuration-options) |
| path | string | `.` separated string donating the path to the current widget within the entry | | entry | object | Object with a `data` field that contains the current value of all widgets in the editor |
| hasErrors | boolean | Specifies if there are validation errors with the current widget | | path | string | `.` separated string donating the path to the current widget within the entry |
| fieldsErrors | object | Key/value object of field names mapping to validation errors | | hasErrors | boolean | Specifies if there are validation errors with the current widget |
| disabled | boolean | Specifies if the widget control should be disabled | | fieldsErrors | object | Key/value object of field names mapping to validation errors |
| submitted | boolean | Specifies if a save attempt has been made in the editor session | | disabled | boolean | Specifies if the widget control should be disabled |
| forList | boolean | Specifies if the widget is within a `list` widget | | submitted | boolean | Specifies if a save attempt has been made in the editor session |
| forSingleList | boolean | Specifies if the widget is within a singleton `list` widget (string array, number array, etc) | | forList | boolean | Specifies if the widget is within a `list` widget |
| duplicate | function | Specifies if that field is an i18n duplicate | | forSingleList | boolean | Specifies if the widget is within a singleton `list` widget (string array, number array, etc) |
| hidden | function | Specifies if that field should be hidden | | duplicate | function | Specifies if that field is an i18n duplicate |
| locale | string<br />\| undefined | The current locale of the editor | | hidden | function | Specifies if that field should be hidden |
| mediaPaths | object | <Deprecated>Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0.</Deprecated> Key/value object of control IDs (passed to the media library) mapping to media paths | | locale | string<br />\| undefined | The current locale of the editor |
| clearMediaControl | function | <Deprecated>Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0.</Deprecated> Clears a control ID's value from the internal store | | query | function | Runs a search on another collection. See [Query](#query) |
| openMediaLibrary | function | <Deprecated>Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0.</Deprecated> Opens the media library popup. See [Open Media Library](#open-media-library) | | i18n | object | The current i18n settings |
| removeInsertedMedia | function | <Deprecated>Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0.</Deprecated> Removes draft media for a give control ID | | t | function | Translates a given key to the current locale |
| removeMediaControl | function | <Deprecated>Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0.</Deprecated> Clears a control ID completely from the internal store | | theme | 'light'<br />\| 'dark' | The current theme being used by the app |
| query | function | Runs a search on another collection. See [Query](#query) |
| i18n | object | The current i18n settings |
| t | function | Translates a given key to the current locale |
| theme | 'light'<br />\| 'dark' | The current theme being used by the app |
#### Open Media Library
<Alert severity="error">
Deprecated. Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead.
Will be removed in v3.0.0.
</Alert>
`openMediaLibrary` allows you to open up the media library popup. It accepts the following props:
| Param | Type | Default | Description |
| ------------- | --------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| controlID | string | | _Optional_ A unique identifier to which the uploaded media will be linked |
| forImage | boolean | `false` | _Optional_ If `true`, restricts upload to image files only |
| value | string<br />list of strings | | _Optional_ The current selected media value |
| allowMultiple | boolean | | _Optional_ Allow multiple files or images to be uploaded at once. Only used on media libraries that support multi upload |
| replaceIndex | number | | _Optional_ The index of the image in an list. Ignored if ` allowMultiple` is `false` |
| config | object | | _Optional_ Media library config options. Available options depend on the media library being used |
| field | object | | _Optional_ The current field configuration |
#### Query #### Query