@deque/cauldron-react 6.12.0 → 6.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/AnchoredOverlay/index.d.ts +20 -0
- package/lib/components/Dialog/index.d.ts +2 -26
- package/lib/components/Drawer/index.d.ts +3 -2
- package/lib/components/Listbox/Listbox.d.ts +19 -5
- package/lib/components/Listbox/ListboxContext.d.ts +4 -2
- package/lib/components/Listbox/ListboxOption.d.ts +1 -0
- package/lib/components/Pagination/Pagination.d.ts +2 -2
- package/lib/components/Popover/index.d.ts +2 -2
- package/lib/components/Table/Table.d.ts +1 -0
- package/lib/components/Tooltip/index.d.ts +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +508 -373
- package/lib/types.d.ts +1 -0
- package/lib/utils/resolveElement.d.ts +2 -2
- package/lib/utils/useFocusTrap.d.ts +34 -0
- package/package.json +2 -4
package/lib/types.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare namespace Cauldron {
|
|
|
11
11
|
* Explicit equivalent of Exclude<ReactNode, boolean | null | undefined>
|
|
12
12
|
*/
|
|
13
13
|
export type ContentNode = string | number | ReactPortal | ReactElement;
|
|
14
|
+
export type ElementOrRef<E extends Element> = E | React.RefObject<E> | React.MutableRefObject<E>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ElementOrRef } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* When an element can be passed as a value that is either an element or an
|
|
4
4
|
* elementRef, this will resolve the property down to the resulting element
|
|
5
5
|
*/
|
|
6
|
-
export default function resolveElement<T extends Element = Element>(elementOrRef:
|
|
6
|
+
export default function resolveElement<T extends Element = Element>(elementOrRef: ElementOrRef<T> | undefined): T | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ElementOrRef } from '../types';
|
|
2
|
+
type FocusTrapMetadata = {
|
|
3
|
+
targetElement: Element;
|
|
4
|
+
lastFocusedElement: HTMLElement | null;
|
|
5
|
+
suspended: boolean;
|
|
6
|
+
};
|
|
7
|
+
type FocusTrap = {
|
|
8
|
+
initialFocusElement: HTMLElement | null;
|
|
9
|
+
destroy: () => void;
|
|
10
|
+
} & FocusTrapMetadata;
|
|
11
|
+
export default function useFocusTrap<TargetElement extends Element = Element, FocusElement extends HTMLElement = HTMLElement>(target: ElementOrRef<TargetElement>, options?: {
|
|
12
|
+
/**
|
|
13
|
+
* When set to false, deactivates the focus trap. This can be necessary if
|
|
14
|
+
* a component needs to conditionally manage focus traps.
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* When the trap is activated, an optional custom element or ref
|
|
19
|
+
* can be provided to override the default initial focus element behavior.
|
|
20
|
+
*/
|
|
21
|
+
initialFocusElement?: ElementOrRef<FocusElement>;
|
|
22
|
+
/**
|
|
23
|
+
* When set to true and the trap is deactivated, this will return focus
|
|
24
|
+
* back to the original active element or the return focus element if
|
|
25
|
+
* provided.
|
|
26
|
+
*/
|
|
27
|
+
returnFocus?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* When the trap is deactivated, an optional custom element or ref
|
|
30
|
+
* can be provided to override the default active element behavior.
|
|
31
|
+
*/
|
|
32
|
+
returnFocusElement?: ElementOrRef<FocusElement>;
|
|
33
|
+
}): React.RefObject<Readonly<FocusTrap>>;
|
|
34
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/cauldron-react",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.13.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
6
6
|
"homepage": "https://cauldron.dequelabs.com/",
|
|
@@ -23,13 +23,11 @@
|
|
|
23
23
|
"test": "jest --maxWorkers=1 --coverage"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@
|
|
26
|
+
"@floating-ui/react-dom": "^2.1.2",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
|
-
"focus-trap-react": "^10.2.3",
|
|
29
28
|
"focusable": "^2.3.0",
|
|
30
29
|
"keyname": "^0.1.0",
|
|
31
30
|
"react-id-generator": "^3.0.1",
|
|
32
|
-
"react-popper": "^2.2.4",
|
|
33
31
|
"react-syntax-highlighter": "^15.5.0",
|
|
34
32
|
"tslib": "^2.4.0"
|
|
35
33
|
},
|