Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript: Convert notices package to TypeScript #67565

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 26 additions & 35 deletions docs/reference-guides/data/data-core-notices.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Namespace: `core/notices`.

## Selectors

<!-- START TOKEN(Autogenerated selectors|../../../packages/notices/src/store/selectors.js) -->
<!-- START TOKEN(Autogenerated selectors|../../../packages/notices/src/store/selectors.ts) -->

### getNotices

Expand Down Expand Up @@ -32,18 +32,18 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Notices state.
- _context_ `?string`: Optional grouping context.
- _state_ `Record< string, Array< Notice > >`: Notices state.
- _context_ Optional grouping context.

_Returns_

- `WPNotice[]`: Array of notices.
- Array of notices.

<!-- END TOKEN(Autogenerated selectors|../../../packages/notices/src/store/selectors.js) -->
<!-- END TOKEN(Autogenerated selectors|../../../packages/notices/src/store/selectors.ts) -->

## Actions

<!-- START TOKEN(Autogenerated actions|../../../packages/notices/src/store/actions.js) -->
<!-- START TOKEN(Autogenerated actions|../../../packages/notices/src/store/actions.ts) -->

### createErrorNotice

Expand Down Expand Up @@ -83,11 +83,11 @@ const ExampleComponent = () => {
_Parameters_

- _content_ `string`: Notice message.
- _options_ `[Object]`: Optional notice options.
- _options_ `[NoticeOptions]`: Optional notice options.

_Returns_

- `Object`: Action object.
- Action object.

### createInfoNotice

Expand Down Expand Up @@ -124,11 +124,11 @@ const ExampleComponent = () => {
_Parameters_

- _content_ `string`: Notice message.
- _options_ `[Object]`: Optional notice options.
- _options_ `[NoticeOptions]`: Optional notice options.

_Returns_

- `Object`: Action object.
- Action object.

### createNotice

Expand Down Expand Up @@ -156,22 +156,13 @@ const ExampleComponent = () => {

_Parameters_

- _status_ `string|undefined`: Notice status ("info" if undefined is passed).
- _status_ Notice status ("info" if undefined is passed).
- _content_ `string`: Notice message.
- _options_ `[Object]`: Notice options.
- _options.context_ `[string]`: Context under which to group notice.
- _options.id_ `[string]`: Identifier for notice. Automatically assigned if not specified.
- _options.isDismissible_ `[boolean]`: Whether the notice can be dismissed by user.
- _options.type_ `[string]`: Type of notice, one of `default`, or `snackbar`.
- _options.speak_ `[boolean]`: Whether the notice content should be announced to screen readers.
- _options.actions_ `[Array<WPNoticeAction>]`: User actions to be presented with notice.
- _options.icon_ `[string]`: An icon displayed with the notice. Only used when type is set to `snackbar`.
- _options.explicitDismiss_ `[boolean]`: Whether the notice includes an explicit dismiss button and can't be dismissed by clicking the body of the notice. Only applies when type is set to `snackbar`.
- _options.onDismiss_ `[Function]`: Called when the notice is dismissed.
- _options_ `[NoticeOptions]`: Notice options.

_Returns_

- `Object`: Action object.
- `Extract< ReducerAction, { type: 'CREATE_NOTICE'; } >`: Action object.

### createSuccessNotice

Expand Down Expand Up @@ -209,11 +200,11 @@ const ExampleComponent = () => {
_Parameters_

- _content_ `string`: Notice message.
- _options_ `[Object]`: Optional notice options.
- _options_ `[NoticeOptions]`: Optional notice options.

_Returns_

- `Object`: Action object.
- Action object.

### createWarningNotice

Expand Down Expand Up @@ -255,11 +246,11 @@ const ExampleComponent = () => {
_Parameters_

- _content_ `string`: Notice message.
- _options_ `[Object]`: Optional notice options.
- _options_ `[NoticeOptions]`: Optional notice options.

_Returns_

- `Object`: Action object.
- Action object.

### removeAllNotices

Expand Down Expand Up @@ -301,12 +292,12 @@ export const ExampleComponent = () => {

_Parameters_

- _noticeType_ `string`: The context to remove all notices from.
- _context_ `string`: The context to remove all notices from.
- _noticeType_ The context to remove all notices from.
- _context_ The context to remove all notices from.

_Returns_

- `Object`: Action object.
- `Extract< ReducerAction, { type: 'REMOVE_ALL_NOTICES'; } >`: Action object.

### removeNotice

Expand Down Expand Up @@ -350,11 +341,11 @@ const ExampleComponent = () => {
_Parameters_

- _id_ `string`: Notice unique identifier.
- _context_ `[string]`: Optional context (grouping) in which the notice is intended to appear. Defaults to default context.
- _context_ Optional context (grouping) in which the notice is intended to appear. Defaults to 'default' context.

_Returns_

- `Object`: Action object.
- `Extract< ReducerAction, { type: 'REMOVE_NOTICE'; } >`: Action object.

### removeNotices

Expand Down Expand Up @@ -394,11 +385,11 @@ const ExampleComponent = () => {

_Parameters_

- _ids_ `string[]`: List of unique notice identifiers.
- _context_ `[string]`: Optional context (grouping) in which the notices are intended to appear. Defaults to default context.
- _ids_ `Array< string >`: List of unique notice identifiers.
- _context_ Optional context (grouping) in which the notices are intended to appear. Defaults to 'default' context.

_Returns_

- `Object`: Action object.
- `Extract< ReducerAction, { type: 'REMOVE_NOTICES'; } >`: Action object.

<!-- END TOKEN(Autogenerated actions|../../../packages/notices/src/store/actions.js) -->
<!-- END TOKEN(Autogenerated actions|../../../packages/notices/src/store/actions.ts) -->
4 changes: 4 additions & 0 deletions packages/notices/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- Improved TypeScript definitions ([#67565](https://github.com/WordPress/gutenberg/pull/67565)).

## 5.13.0 (2024-11-27)

## 5.12.0 (2024-11-16)
Expand Down
File renamed without changes.
Loading
Loading