-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix v11.0.0 types that removed the default export (#1406)
* Fix v11.0.0 types that removed the default export Fixes #1396 My original intent was to remove the default export (a breaking change) as part of the major 11.0.0 release but I totally flopped on that by not also actually providing the named export in the code. Now that the major release ship has sailed, this change fixes the types by reinstating the default export in the typings but marking it deprecated, while also providing the new named export alternative as the way forward. * Props no longer extend from AllHTMLAttributes
- Loading branch information
1 parent
ea9d453
commit cd75caa
Showing
16 changed files
with
79 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'focus-trap-react': patch | ||
--- | ||
|
||
Fix missing default export in typings; props no longer extend `React.AllHTMLAttributes<any>` to allow things like `className` (those extra props have always been ignored anyway); deprecate default export; add named export in code ([#1396](https://github.com/focus-trap/focus-trap-react/issues/1396)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,56 @@ | ||
import { Options as FocusTrapOptions } from 'focus-trap'; | ||
import * as React from 'react'; | ||
|
||
export interface FocusTrapProps { | ||
/** | ||
* __Single container child__ for the trap. Use `containerElements` instead | ||
* if you need a trap with multiple containers. | ||
*/ | ||
children?: React.ReactNode; | ||
|
||
/** | ||
* By default, the trap will be active when it mounts, so it's activated by | ||
* mounting, and deactivated by unmounting. Use this prop to control when | ||
* it's active while it's mounted, or if it's initially inactive. | ||
*/ | ||
active?: boolean; | ||
|
||
/** | ||
* To pause or unpause the trap while it's `active`. Primarily for use when | ||
* you need to manage multiple traps in the same view. When paused, the trap | ||
* retains its various event listeners, but ignores all events. | ||
*/ | ||
paused?: boolean; | ||
|
||
/** | ||
* See Focus-trap's [createOptions](https://github.com/focus-trap/focus-trap?tab=readme-ov-file#createoptions) | ||
* for more details on available options. | ||
*/ | ||
focusTrapOptions?: FocusTrapOptions; | ||
|
||
/** | ||
* If specified, these elements will be used as the boundaries for the | ||
* trap, __instead of the child__ specified in `children` (though | ||
* `children` will still be rendered). | ||
*/ | ||
containerElements?: Array<HTMLElement>; | ||
} | ||
|
||
export declare class FocusTrap extends React.Component<FocusTrapProps> { } | ||
|
||
/** | ||
* Default export of the FocusTrap component. | ||
* @deprecated 🔺 Use the named import `{ FocusTrap }` instead. | ||
* @description 🔺 The default export will be removed in a future release. Migrate to the named | ||
* import `{ FocusTrap }` today to ensure future compatibility. | ||
*/ | ||
declare namespace FocusTrap { | ||
export interface Props extends React.AllHTMLAttributes<any> { | ||
children?: React.ReactNode; | ||
active?: boolean; | ||
paused?: boolean; | ||
focusTrapOptions?: FocusTrapOptions; | ||
containerElements?: Array<HTMLElement>; | ||
} | ||
export type Props = FocusTrapProps; | ||
} | ||
|
||
export declare class FocusTrap extends React.Component<FocusTrap.Props> { } | ||
/** | ||
* @deprecated 🔺 Use the named import `{ FocusTrap }` instead. | ||
* @description 🔺 The default export will be removed in a future release. Migrate to the named | ||
* import `{ FocusTrap }` today to ensure future compatibility. | ||
*/ | ||
export default FocusTrap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters