From e2d32471ad1f50c83feceef7e55e720772ddad25 Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Thu, 31 Aug 2023 12:13:43 -0400 Subject: [PATCH] docs: update docs about new clearChildValidation prop --- packages/core/test/data/widgets.mock.ts | 1 + packages/docs/content/docs/custom-widgets.mdx | 73 +++++++------------ 2 files changed, 26 insertions(+), 48 deletions(-) diff --git a/packages/core/test/data/widgets.mock.ts b/packages/core/test/data/widgets.mock.ts index b19c06fb..4f73e17d 100644 --- a/packages/core/test/data/widgets.mock.ts +++ b/packages/core/test/data/widgets.mock.ts @@ -73,6 +73,7 @@ export const createMockWidgetControlProps = < controlled: false, theme: 'light', onChange: jest.fn(), + clearChildValidation: jest.fn(), query: jest.fn(), t: jest.fn(), ...extra, diff --git a/packages/docs/content/docs/custom-widgets.mdx b/packages/docs/content/docs/custom-widgets.mdx index 09dfd730..1d9fa98a 100644 --- a/packages/docs/content/docs/custom-widgets.mdx +++ b/packages/docs/content/docs/custom-widgets.mdx @@ -39,54 +39,31 @@ CMS.registerWidget(name, control, [preview], [{ schema }]); The react component that renders the control. It receives the following props: -| Param | Type | Description | -| ------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| label | string | The label for 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 | -| field | object | The field configuration for the current widget. See [Widget Options](/docs/widgets#common-widget-options) | -| collection | object | The collection configuration for the current widget. See [Collections](/docs/collection-overview) | -| collectionFile | object | The collection file configuration for the current widget if entry is part of a [File Collection](/docs/collection-types#file-collections) | -| config | object | The current Static CMS config. See [configuration options](/docs/configuration-options) | -| entry | object | Object with a `data` field that contains the current value of all widgets in the editor | -| path | string | `.` separated string donating the path to the current widget within the entry | -| hasErrors | boolean | Specifies if there are validation errors with the current widget | -| fieldsErrors | object | Key/value object of field names mapping to validation errors | -| disabled | boolean | Specifies if the widget control should be disabled | -| submitted | boolean | Specifies if a save attempt has been made in the editor session | -| forList | boolean | Specifies if the widget is within a `list` widget | -| forSingleList | boolean | Specifies if the widget is within a singleton `list` widget (string array, number array, etc) | -| duplicate | function | Specifies if that field is an i18n duplicate | -| hidden | function | Specifies if that field should be hidden | -| locale | string
\| undefined | The current locale of the editor | -| mediaPaths | object | Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0. Key/value object of control IDs (passed to the media library) mapping to media paths | -| clearMediaControl | function | Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0. Clears a control ID's value from the internal store | -| openMediaLibrary | function | Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0. Opens the media library popup. See [Open Media Library](#open-media-library) | -| removeInsertedMedia | function | Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0. Removes draft media for a give control ID | -| removeMediaControl | function | Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. Will be removed in v3.0.0. Clears a control ID completely from the internal store | -| 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'
\| 'dark' | The current theme being used by the app | - -#### Open Media Library - - - Deprecated. Use [useMediaInsert](/docs/custom-widgets#interacting-with-the-media-library) instead. - Will be removed in v3.0.0. - - -`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
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 | +| Param | Type | Description | +| -------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | +| label | string | The label for 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 | +| clearChildValidation | function | Clears all validation errors for children of the widget | +| field | object | The field configuration for the current widget. See [Widget Options](/docs/widgets#common-widget-options) | +| collection | object | The collection configuration for the current widget. See [Collections](/docs/collection-overview) | +| collectionFile | object | The collection file configuration for the current widget if entry is part of a [File Collection](/docs/collection-types#file-collections) | +| config | object | The current Static CMS config. See [configuration options](/docs/configuration-options) | +| entry | object | Object with a `data` field that contains the current value of all widgets in the editor | +| path | string | `.` separated string donating the path to the current widget within the entry | +| hasErrors | boolean | Specifies if there are validation errors with the current widget | +| fieldsErrors | object | Key/value object of field names mapping to validation errors | +| disabled | boolean | Specifies if the widget control should be disabled | +| submitted | boolean | Specifies if a save attempt has been made in the editor session | +| forList | boolean | Specifies if the widget is within a `list` widget | +| forSingleList | boolean | Specifies if the widget is within a singleton `list` widget (string array, number array, etc) | +| duplicate | function | Specifies if that field is an i18n duplicate | +| hidden | function | Specifies if that field should be hidden | +| locale | string
\| undefined | The current locale of the editor | +| 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'
\| 'dark' | The current theme being used by the app | #### Query