@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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Placement } from '@floating-ui/dom';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare const AnchoredOverlay: React.ForwardRefExoticComponent<{
|
|
4
|
+
/** A target element or ref to attach the overlay anchor element. */
|
|
5
|
+
target: HTMLElement | React.RefObject<HTMLElement> | React.MutableRefObject<HTMLElement>;
|
|
6
|
+
/** Positional placement value to anchor the overlay element relative to its anchored target. */
|
|
7
|
+
placement?: "auto" | Placement | "auto-start" | "auto-end" | undefined;
|
|
8
|
+
/** Determines if the overlay anchor is currently visible. */
|
|
9
|
+
open?: boolean | undefined;
|
|
10
|
+
/** A callback function that is called when the overlay state changes. */
|
|
11
|
+
onOpenChange?: ((open: boolean) => void) | undefined;
|
|
12
|
+
/** A callback function that is called when the placement of the overlay changes. */
|
|
13
|
+
onPlacementChange?: ((placement: Placement) => void) | undefined;
|
|
14
|
+
/** An optional offset number to position the anchor element from its anchored target. */
|
|
15
|
+
offset?: number | undefined;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
} & React.HTMLAttributes<HTMLElement> & {
|
|
18
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
19
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
20
|
+
export default AnchoredOverlay;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import AriaIsolate from '../../utils/aria-isolate';
|
|
3
2
|
export interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
3
|
children: React.ReactNode;
|
|
5
4
|
className?: string;
|
|
@@ -14,31 +13,8 @@ export interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
14
13
|
closeButtonText?: string;
|
|
15
14
|
portal?: React.RefObject<HTMLElement> | HTMLElement;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
export default class Dialog extends React.Component<DialogProps, DialogState> {
|
|
21
|
-
static defaultProps: {
|
|
22
|
-
onClose: () => void;
|
|
23
|
-
forceAction: boolean;
|
|
24
|
-
closeButtonText: string;
|
|
25
|
-
};
|
|
26
|
-
private element;
|
|
27
|
-
private heading;
|
|
28
|
-
private headingId;
|
|
29
|
-
constructor(props: DialogProps);
|
|
30
|
-
componentDidMount(): void;
|
|
31
|
-
componentWillUnmount(): void;
|
|
32
|
-
componentDidUpdate(prevProps: DialogProps): void;
|
|
33
|
-
private attachIsolator;
|
|
34
|
-
render(): React.JSX.Element | null;
|
|
35
|
-
close(): void;
|
|
36
|
-
handleClickOutside(): void;
|
|
37
|
-
focusHeading(): void;
|
|
38
|
-
private handleEscape;
|
|
39
|
-
private attachEventListeners;
|
|
40
|
-
private removeEventListeners;
|
|
41
|
-
}
|
|
16
|
+
declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export default Dialog;
|
|
42
18
|
interface DialogAlignmentProps {
|
|
43
19
|
align?: 'left' | 'center' | 'right';
|
|
44
20
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ElementOrRef } from '../../types';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
export interface DrawerProps<T extends HTMLElement = HTMLElement> extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
children: React.ReactNode;
|
|
@@ -5,8 +6,8 @@ export interface DrawerProps<T extends HTMLElement = HTMLElement> extends React.
|
|
|
5
6
|
open?: boolean;
|
|
6
7
|
behavior?: 'modal' | 'non-modal';
|
|
7
8
|
focusOptions?: {
|
|
8
|
-
initialFocus?:
|
|
9
|
-
returnFocus?:
|
|
9
|
+
initialFocus?: ElementOrRef<T>;
|
|
10
|
+
returnFocus?: ElementOrRef<T>;
|
|
10
11
|
};
|
|
11
12
|
onClose?: () => void;
|
|
12
13
|
portal?: React.RefObject<HTMLElement> | HTMLElement;
|
|
@@ -2,15 +2,29 @@ import React from 'react';
|
|
|
2
2
|
import type { ListboxOption } from './ListboxContext';
|
|
3
3
|
import type { ListboxValue } from './ListboxOption';
|
|
4
4
|
import type { PolymorphicProps, PolymorphicComponent } from '../../utils/polymorphicComponent';
|
|
5
|
-
interface
|
|
6
|
-
value?: ListboxValue;
|
|
5
|
+
interface BaseListboxProps extends PolymorphicProps<Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'defaultValue'>> {
|
|
7
6
|
navigation?: 'cycle' | 'bound';
|
|
8
|
-
|
|
7
|
+
onActiveChange?: (option: ListboxOption) => void;
|
|
8
|
+
}
|
|
9
|
+
interface SingleSelectListboxProps extends BaseListboxProps {
|
|
10
|
+
multiselect?: false;
|
|
11
|
+
value?: ListboxValue;
|
|
12
|
+
defaultValue?: ListboxValue;
|
|
13
|
+
onSelectionChange?: <T extends HTMLElement = HTMLElement>(props: {
|
|
9
14
|
target: T;
|
|
10
15
|
previousValue: ListboxValue;
|
|
11
16
|
value: ListboxValue;
|
|
12
17
|
}) => void;
|
|
13
|
-
onActiveChange?: (option: ListboxOption) => void;
|
|
14
18
|
}
|
|
15
|
-
|
|
19
|
+
interface MultiSelectListboxProps extends BaseListboxProps {
|
|
20
|
+
multiselect: true;
|
|
21
|
+
value?: ListboxValue[];
|
|
22
|
+
defaultValue?: ListboxValue[];
|
|
23
|
+
onSelectionChange?: <T extends HTMLElement = HTMLElement>(props: {
|
|
24
|
+
target: T;
|
|
25
|
+
previousValue: ListboxValue[];
|
|
26
|
+
value: ListboxValue[];
|
|
27
|
+
}) => void;
|
|
28
|
+
}
|
|
29
|
+
declare const Listbox: PolymorphicComponent<SingleSelectListboxProps | MultiSelectListboxProps>;
|
|
16
30
|
export default Listbox;
|
|
@@ -8,7 +8,8 @@ type ListboxOption<Element = HTMLElement, Value = string | number> = {
|
|
|
8
8
|
type ListboxContext<T extends ListboxOption> = {
|
|
9
9
|
options: T[];
|
|
10
10
|
active: T | null;
|
|
11
|
-
selected: T | null;
|
|
11
|
+
selected: T[] | null;
|
|
12
|
+
multiselect: boolean;
|
|
12
13
|
setOptions: React.Dispatch<React.SetStateAction<T[]>>;
|
|
13
14
|
onSelect: (option: T) => void;
|
|
14
15
|
};
|
|
@@ -19,9 +20,10 @@ declare const ListboxContext: React.Context<{
|
|
|
19
20
|
options: never[];
|
|
20
21
|
active: null;
|
|
21
22
|
selected: null;
|
|
23
|
+
multiselect: boolean;
|
|
22
24
|
setOptions: () => null;
|
|
23
25
|
onSelect: () => null;
|
|
24
26
|
}>;
|
|
25
|
-
declare function ListboxProvider<T extends ListboxOption>({ options, active, selected, setOptions, onSelect, children }: ListboxProvider<T>): React.JSX.Element;
|
|
27
|
+
declare function ListboxProvider<T extends ListboxOption>({ options, active, selected, multiselect, setOptions, onSelect, children }: ListboxProvider<T>): React.JSX.Element;
|
|
26
28
|
declare function useListboxContext<T extends ListboxOption>(): ListboxContext<T>;
|
|
27
29
|
export { ListboxProvider, useListboxContext, ListboxOption };
|
|
@@ -4,6 +4,7 @@ export type ListboxValue = Readonly<string | number | undefined>;
|
|
|
4
4
|
interface ListboxOptionProps extends PolymorphicProps<React.HTMLAttributes<HTMLElement>> {
|
|
5
5
|
value?: ListboxValue;
|
|
6
6
|
disabled?: boolean;
|
|
7
|
+
selected?: boolean;
|
|
7
8
|
activeClass?: string;
|
|
8
9
|
}
|
|
9
10
|
declare const ListboxOption: PolymorphicComponent<ListboxOptionProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import type AnchoredOverlay from '../AnchoredOverlay';
|
|
3
3
|
import { ContentNode } from '../../types';
|
|
4
4
|
interface Props extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
totalItems: number;
|
|
@@ -15,7 +15,7 @@ interface Props extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
15
15
|
onPreviousPageClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
16
16
|
onFirstPageClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
17
17
|
onLastPageClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
18
|
-
tooltipPlacement?:
|
|
18
|
+
tooltipPlacement?: React.ComponentProps<typeof AnchoredOverlay>['placement'];
|
|
19
19
|
thin?: boolean;
|
|
20
20
|
className?: string;
|
|
21
21
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { Placement } from '@popperjs/core';
|
|
3
2
|
import { Cauldron } from '../../types';
|
|
3
|
+
import AnchoredOverlay from '../AnchoredOverlay';
|
|
4
4
|
export type PopoverVariant = 'prompt' | 'custom';
|
|
5
5
|
type BaseProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
6
6
|
target: React.RefObject<HTMLElement> | HTMLElement;
|
|
7
7
|
variant?: PopoverVariant;
|
|
8
8
|
show: boolean;
|
|
9
9
|
onClose: () => void;
|
|
10
|
-
placement?:
|
|
10
|
+
placement?: React.ComponentProps<typeof AnchoredOverlay>['placement'];
|
|
11
11
|
portal?: React.RefObject<HTMLElement> | HTMLElement;
|
|
12
12
|
};
|
|
13
13
|
type CustomProps = BaseProps & {
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
export type Column = {
|
|
3
3
|
align: ColumnAlignment;
|
|
4
4
|
width?: ColumnWidth;
|
|
5
|
+
maxWidth?: ColumnWidth;
|
|
5
6
|
};
|
|
6
7
|
export type ColumnAlignment = 'start' | 'center' | 'end';
|
|
7
8
|
export type ColumnWidth = 'auto' | 'min-content' | 'max-content' | `${number}` | `${number}%` | `${number}fr`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import AnchoredOverlay from '../AnchoredOverlay';
|
|
3
3
|
export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
className?: string;
|
|
@@ -8,7 +8,7 @@ export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
8
8
|
association?: 'aria-labelledby' | 'aria-describedby' | 'none';
|
|
9
9
|
show?: boolean | undefined;
|
|
10
10
|
defaultShow?: boolean;
|
|
11
|
-
placement?:
|
|
11
|
+
placement?: React.ComponentProps<typeof AnchoredOverlay>['placement'];
|
|
12
12
|
portal?: React.RefObject<HTMLElement> | HTMLElement;
|
|
13
13
|
hideElementOnHidden?: boolean;
|
|
14
14
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export { default as TextEllipsis } from './components/TextEllipsis';
|
|
|
61
61
|
export { default as CopyButton } from './components/CopyButton';
|
|
62
62
|
export { default as Drawer } from './components/Drawer';
|
|
63
63
|
export { default as BottomSheet } from './components/BottomSheet';
|
|
64
|
+
export { default as AnchoredOverlay } from './components/AnchoredOverlay';
|
|
64
65
|
/**
|
|
65
66
|
* Helpers / Utils
|
|
66
67
|
*/
|