@canonical/react-components 1.3.0 → 1.3.2
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/dist/components/Accordion/Accordion.d.ts +46 -0
- package/dist/components/Accordion/AccordionSection/AccordionSection.d.ts +34 -0
- package/dist/components/Accordion/AccordionSection/index.d.ts +2 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/ActionButton/ActionButton.d.ts +48 -0
- package/dist/components/ActionButton/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppAside/AppAside.d.ts +33 -0
- package/dist/components/ApplicationLayout/AppAside/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppMain/AppMain.d.ts +14 -0
- package/dist/components/ApplicationLayout/AppMain/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.d.ts +26 -0
- package/dist/components/ApplicationLayout/AppNavigation/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.d.ts +18 -0
- package/dist/components/ApplicationLayout/AppNavigationBar/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppStatus/AppStatus.d.ts +14 -0
- package/dist/components/ApplicationLayout/AppStatus/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/Application/Application.d.ts +15 -0
- package/dist/components/ApplicationLayout/Application/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/ApplicationLayout.d.ts +89 -0
- package/dist/components/ApplicationLayout/index.d.ts +7 -0
- package/dist/components/ArticlePagination/ArticlePagination.d.ts +31 -0
- package/dist/components/ArticlePagination/index.d.ts +2 -0
- package/dist/components/Badge/Badge.d.ts +34 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +64 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Card/Card.d.ts +35 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/CheckboxInput/CheckableInput/CheckableInput.d.ts +27 -0
- package/dist/components/CheckboxInput/CheckableInput/index.d.ts +2 -0
- package/dist/components/CheckboxInput/CheckboxInput.d.ts +9 -0
- package/dist/components/CheckboxInput/index.d.ts +2 -0
- package/dist/components/Chip/Chip.d.ts +56 -0
- package/dist/components/Chip/index.d.ts +2 -0
- package/dist/components/Code/Code.d.ts +13 -0
- package/dist/components/Code/index.d.ts +2 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +21 -0
- package/dist/components/CodeSnippet/CodeSnippetBlock.d.ts +40 -0
- package/dist/components/CodeSnippet/CodeSnippetDropdown.d.ts +18 -0
- package/dist/components/CodeSnippet/index.d.ts +5 -0
- package/dist/components/Col/Col.d.ts +53 -0
- package/dist/components/Col/index.d.ts +2 -0
- package/dist/components/ConfirmationButton/ConfirmationButton.d.ts +28 -0
- package/dist/components/ConfirmationButton/index.d.ts +2 -0
- package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +53 -0
- package/dist/components/ConfirmationModal/index.d.ts +2 -0
- package/dist/components/ContextualMenu/ContextualMenu.d.ts +110 -0
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +43 -0
- package/dist/components/ContextualMenu/ContextualMenuDropdown/index.d.ts +2 -0
- package/dist/components/ContextualMenu/index.d.ts +3 -0
- package/dist/components/EmptyState/EmptyState.d.ts +25 -0
- package/dist/components/EmptyState/index.d.ts +2 -0
- package/dist/components/Field/Field.d.ts +77 -0
- package/dist/components/Field/index.d.ts +2 -0
- package/dist/components/Form/Form.d.ts +21 -0
- package/dist/components/Form/index.d.ts +2 -0
- package/dist/components/FormikField/FormikField.d.ts +25 -0
- package/dist/components/FormikField/index.d.ts +1 -0
- package/dist/components/Icon/Icon.d.ts +59 -0
- package/dist/components/Icon/index.d.ts +2 -0
- package/dist/components/Input/Input.d.ts +70 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Label/Label.d.ts +25 -0
- package/dist/components/Label/index.d.ts +2 -0
- package/dist/components/Link/Link.d.ts +31 -0
- package/dist/components/Link/index.d.ts +2 -0
- package/dist/components/List/List.d.ts +36 -0
- package/dist/components/List/index.d.ts +2 -0
- package/dist/components/Loader/Loader.d.ts +6 -0
- package/dist/components/Loader/index.d.ts +1 -0
- package/dist/components/LoginPageLayout/LoginPageLayout.d.ts +17 -0
- package/dist/components/LoginPageLayout/index.d.ts +2 -0
- package/dist/components/MainTable/MainTable.d.ts +102 -0
- package/dist/components/MainTable/index.d.ts +2 -0
- package/dist/components/Modal/Modal.d.ts +36 -0
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/ModularTable/ModularTable.d.ts +105 -0
- package/dist/components/ModularTable/index.d.ts +2 -0
- package/dist/components/MultiSelect/FadeInDown/FadeInDown.d.ts +10 -0
- package/dist/components/MultiSelect/FadeInDown/index.d.ts +1 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +57 -0
- package/dist/components/MultiSelect/index.d.ts +1 -0
- package/dist/components/Navigation/Navigation.d.ts +66 -0
- package/dist/components/Navigation/NavigationLink/NavigationLink.d.ts +10 -0
- package/dist/components/Navigation/NavigationLink/index.d.ts +1 -0
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.d.ts +11 -0
- package/dist/components/Navigation/NavigationMenu/index.d.ts +1 -0
- package/dist/components/Navigation/index.d.ts +3 -0
- package/dist/components/Navigation/types.d.ts +64 -0
- package/dist/components/Notification/Notification.d.ts +110 -0
- package/dist/components/Notification/index.d.ts +2 -0
- package/dist/components/NotificationProvider/NotificationProvider.d.ts +5 -0
- package/dist/components/NotificationProvider/index.d.ts +3 -0
- package/dist/components/NotificationProvider/messageBuilder.d.ts +6 -0
- package/dist/components/NotificationProvider/types.d.ts +35 -0
- package/dist/components/Pagination/Pagination.d.ts +102 -0
- package/dist/components/Pagination/PaginationButton/PaginationButton.d.ts +30 -0
- package/dist/components/Pagination/PaginationButton/index.d.ts +2 -0
- package/dist/components/Pagination/PaginationItem/PaginationItem.d.ts +17 -0
- package/dist/components/Pagination/PaginationItem/index.d.ts +2 -0
- package/dist/components/Pagination/index.d.ts +2 -0
- package/dist/components/Panel/Panel.d.ts +123 -0
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/PasswordToggle/PasswordToggle.d.ts +108 -0
- package/dist/components/PasswordToggle/index.d.ts +2 -0
- package/dist/components/RadioInput/RadioInput.d.ts +9 -0
- package/dist/components/RadioInput/index.d.ts +2 -0
- package/dist/components/Row/Row.d.ts +19 -0
- package/dist/components/Row/index.d.ts +2 -0
- package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.d.ts +25 -0
- package/dist/components/SearchAndFilter/FilterPanelSection/index.d.ts +1 -0
- package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +33 -0
- package/dist/components/SearchAndFilter/index.d.ts +2 -0
- package/dist/components/SearchAndFilter/types.d.ts +11 -0
- package/dist/components/SearchAndFilter/utils.d.ts +13 -0
- package/dist/components/SearchBox/SearchBox.d.ts +63 -0
- package/dist/components/SearchBox/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +71 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/SideNavigation/SideNavigation.d.ts +50 -0
- package/dist/components/SideNavigation/SideNavigationBase/SideNavigationBase.d.ts +31 -0
- package/dist/components/SideNavigation/SideNavigationBase/index.d.ts +1 -0
- package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.d.ts +20 -0
- package/dist/components/SideNavigation/SideNavigationItem/index.d.ts +1 -0
- package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.d.ts +18 -0
- package/dist/components/SideNavigation/SideNavigationLink/index.d.ts +1 -0
- package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.d.ts +7 -0
- package/dist/components/SideNavigation/SideNavigationText/index.d.ts +1 -0
- package/dist/components/SideNavigation/index.d.ts +5 -0
- package/dist/components/Slider/Slider.d.ts +62 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Spinner/Spinner.d.ts +29 -0
- package/dist/components/Spinner/index.d.ts +2 -0
- package/dist/components/StatusLabel/StatusLabel.d.ts +33 -0
- package/dist/components/StatusLabel/index.d.ts +2 -0
- package/dist/components/Strip/Strip.d.ts +64 -0
- package/dist/components/Strip/index.d.ts +2 -0
- package/dist/components/SummaryButton/SummaryButton.d.ts +29 -0
- package/dist/components/SummaryButton/index.d.ts +2 -0
- package/dist/components/Switch/Switch.d.ts +17 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Table/Table.d.ts +22 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/TableCell/TableCell.d.ts +26 -0
- package/dist/components/TableCell/index.d.ts +2 -0
- package/dist/components/TableHeader/TableHeader.d.ts +14 -0
- package/dist/components/TableHeader/index.d.ts +2 -0
- package/dist/components/TablePagination/TablePagination.d.ts +98 -0
- package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.d.ts +24 -0
- package/dist/components/TablePagination/TablePaginationControls/index.d.ts +2 -0
- package/dist/components/TablePagination/index.d.ts +2 -0
- package/dist/components/TablePagination/utils.d.ts +27 -0
- package/dist/components/TableRow/TableRow.d.ts +10 -0
- package/dist/components/TableRow/index.d.ts +2 -0
- package/dist/components/Tabs/Tabs.d.ts +45 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Textarea/Textarea.d.ts +70 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +75 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/enums.d.ts +13 -0
- package/dist/hooks/index.d.ts +9 -0
- package/dist/hooks/useId.d.ts +4 -0
- package/dist/hooks/useListener.d.ts +11 -0
- package/dist/hooks/useOnClickOutside.d.ts +12 -0
- package/dist/hooks/useOnEscapePressed.d.ts +6 -0
- package/dist/hooks/usePagination.d.ts +19 -0
- package/dist/hooks/usePrevious.d.ts +7 -0
- package/dist/hooks/useThrottle.d.ts +9 -0
- package/dist/hooks/useWindowFitment.d.ts +54 -0
- package/dist/index.d.ts +132 -0
- package/dist/types/index.d.ts +38 -0
- package/dist/utils.d.ts +27 -0
- package/package.json +9 -10
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { MouseEvent, HTMLProps } from "react";
|
|
2
|
+
import { ValueOf, PropsWithSpread } from "../../types";
|
|
3
|
+
export declare enum Label {
|
|
4
|
+
Dismiss = "Dismiss"
|
|
5
|
+
}
|
|
6
|
+
export declare const ChipType: {
|
|
7
|
+
readonly CAUTION: "caution";
|
|
8
|
+
readonly INFORMATION: "information";
|
|
9
|
+
readonly NEGATIVE: "negative";
|
|
10
|
+
readonly POSITIVE: "positive";
|
|
11
|
+
};
|
|
12
|
+
export type Props = PropsWithSpread<{
|
|
13
|
+
/**
|
|
14
|
+
* The appearance of the chip.
|
|
15
|
+
*/
|
|
16
|
+
appearance?: ValueOf<typeof ChipType>;
|
|
17
|
+
/**
|
|
18
|
+
* The lead for the chip.
|
|
19
|
+
*/
|
|
20
|
+
lead?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Function for handling chip div click event.
|
|
23
|
+
*/
|
|
24
|
+
onClick?: (event: MouseEvent<HTMLButtonElement> | {
|
|
25
|
+
lead: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Function for handling dismissing a chip.
|
|
30
|
+
*/
|
|
31
|
+
onDismiss?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the chip is selected.
|
|
34
|
+
*/
|
|
35
|
+
selected?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* A substring to emphasise if it is part of the chip's value,
|
|
38
|
+
* e.g. "sit" => poSITive
|
|
39
|
+
*/
|
|
40
|
+
subString?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to wrap the value in quotation marks.
|
|
43
|
+
*/
|
|
44
|
+
quoteValue?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The value of the chip.
|
|
47
|
+
*/
|
|
48
|
+
value: string;
|
|
49
|
+
}, HTMLProps<HTMLButtonElement>>;
|
|
50
|
+
/**
|
|
51
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Chip](https://vanillaframework.io/docs/patterns/chip).
|
|
52
|
+
*
|
|
53
|
+
* It can be used to display a small value attached to a component.
|
|
54
|
+
*/
|
|
55
|
+
declare const Chip: ({ appearance, lead, onClick, onDismiss, quoteValue, selected, subString, value, ...props }: Props) => JSX.Element;
|
|
56
|
+
export default Chip;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ClassName } from "../../types";
|
|
2
|
+
export type Props = {
|
|
3
|
+
children: string;
|
|
4
|
+
className?: ClassName;
|
|
5
|
+
inline?: boolean;
|
|
6
|
+
copyable?: boolean;
|
|
7
|
+
numbered?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Code component is deprecated. Use CodeSnippet component or inline `<code>` instead.
|
|
11
|
+
*/
|
|
12
|
+
declare const Code: ({ children, className, inline, copyable, numbered, ...props }: Props) => JSX.Element;
|
|
13
|
+
export default Code;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HTMLProps } from "react";
|
|
2
|
+
import type { Props as CodeSnippetBlockProps } from "./CodeSnippetBlock";
|
|
3
|
+
import type { ClassName, PropsWithSpread } from "../../types";
|
|
4
|
+
export type Props = PropsWithSpread<{
|
|
5
|
+
/**
|
|
6
|
+
* Optional class(es) to pass to the wrapping div element.
|
|
7
|
+
*/
|
|
8
|
+
className?: ClassName;
|
|
9
|
+
/**
|
|
10
|
+
* A list of code blocks to display.
|
|
11
|
+
*/
|
|
12
|
+
blocks: CodeSnippetBlockProps[];
|
|
13
|
+
}, HTMLProps<HTMLDivElement>>;
|
|
14
|
+
/**
|
|
15
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Code snippet](https://docs.vanillaframework.io/base/code#code-snippet).
|
|
16
|
+
*
|
|
17
|
+
* #### Blocks
|
|
18
|
+
*
|
|
19
|
+
* A single `CodeSnippet` component can render multiple separate code blocks. Blocks are provided as an array via the `blocks` prop. Each block object defines values of props for each code block of the snippet.
|
|
20
|
+
*/
|
|
21
|
+
export default function CodeSnippet({ className, blocks, ...props }: Props): JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { Props as CodeSnippetDropdownProps } from "./CodeSnippetDropdown";
|
|
3
|
+
import type { ValueOf } from "../../types";
|
|
4
|
+
export declare const CodeSnippetBlockAppearance: {
|
|
5
|
+
readonly LINUX_PROMPT: "linuxPrompt";
|
|
6
|
+
readonly NUMBERED: "numbered";
|
|
7
|
+
readonly URL: "url";
|
|
8
|
+
readonly WINDOWS_PROMPT: "windowsPrompt";
|
|
9
|
+
};
|
|
10
|
+
export type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* The appearance of the code block.
|
|
13
|
+
*/
|
|
14
|
+
appearance?: ValueOf<typeof CodeSnippetBlockAppearance>;
|
|
15
|
+
/**
|
|
16
|
+
* The code snippet to display.
|
|
17
|
+
*/
|
|
18
|
+
code: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Content to show below the code snippet.
|
|
21
|
+
*/
|
|
22
|
+
content?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* A list of dropdowns to display in the header.
|
|
25
|
+
*/
|
|
26
|
+
dropdowns?: CodeSnippetDropdownProps[];
|
|
27
|
+
/**
|
|
28
|
+
* Whether the title should display stacked on top of the dropdowns.
|
|
29
|
+
*/
|
|
30
|
+
stacked?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The title of the code block.
|
|
33
|
+
*/
|
|
34
|
+
title?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to enable line wrapping inside the code block.
|
|
37
|
+
*/
|
|
38
|
+
wrapLines?: boolean;
|
|
39
|
+
};
|
|
40
|
+
export default function CodeSnippetBlock({ appearance, code, content, dropdowns, stacked, title, wrapLines, }: Props): JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChangeEventHandler, HTMLProps } from "react";
|
|
2
|
+
export type DropdownOptionProps = {
|
|
3
|
+
/**
|
|
4
|
+
* The label of the dropdown option.
|
|
5
|
+
*/
|
|
6
|
+
label: string;
|
|
7
|
+
} & HTMLProps<HTMLOptionElement>;
|
|
8
|
+
export type Props = {
|
|
9
|
+
/**
|
|
10
|
+
* Function for handling the select value changing.
|
|
11
|
+
*/
|
|
12
|
+
onChange: ChangeEventHandler<HTMLSelectElement>;
|
|
13
|
+
/**
|
|
14
|
+
* Options to pass to the select.
|
|
15
|
+
*/
|
|
16
|
+
options: DropdownOptionProps[];
|
|
17
|
+
} & HTMLProps<HTMLSelectElement>;
|
|
18
|
+
export default function CodeSnippetDropdown({ options, onChange, ...props }: Props): JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default } from "./CodeSnippet";
|
|
2
|
+
export type { Props as CodeSnippetProps } from "./CodeSnippet";
|
|
3
|
+
export { CodeSnippetBlockAppearance } from "./CodeSnippetBlock";
|
|
4
|
+
export type { Props as CodeSnippetBlockProps } from "./CodeSnippetBlock";
|
|
5
|
+
export type { Props as CodeSnippetDropdownProps } from "./CodeSnippetDropdown";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ElementType, HTMLProps, ReactNode } from "react";
|
|
2
|
+
import type { ClassName, PropsWithSpread } from "../../types";
|
|
3
|
+
export type ColSize = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
4
|
+
export declare const colSizes: ColSize[];
|
|
5
|
+
export type Props = PropsWithSpread<{
|
|
6
|
+
/**
|
|
7
|
+
* The content of the column.
|
|
8
|
+
*/
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Optional class(es) to pass to the wrapping element.
|
|
12
|
+
*/
|
|
13
|
+
className?: ClassName;
|
|
14
|
+
/**
|
|
15
|
+
* Optional element type to give the wrapper if not "div".
|
|
16
|
+
*/
|
|
17
|
+
element?: ElementType;
|
|
18
|
+
/**
|
|
19
|
+
* The number of columns to skip before starting on large screens.
|
|
20
|
+
*/
|
|
21
|
+
emptyLarge?: ColSize;
|
|
22
|
+
/**
|
|
23
|
+
* The number of columns to skip before starting on medium screens.
|
|
24
|
+
*/
|
|
25
|
+
emptyMedium?: ColSize;
|
|
26
|
+
/**
|
|
27
|
+
* The number of columns to skip before starting on small screens.
|
|
28
|
+
*/
|
|
29
|
+
emptySmall?: ColSize;
|
|
30
|
+
/**
|
|
31
|
+
* Override for the number of columns the content occupies on large screens.
|
|
32
|
+
*/
|
|
33
|
+
large?: ColSize;
|
|
34
|
+
/**
|
|
35
|
+
* Override for the number of columns the content occupies on medium screens.
|
|
36
|
+
*/
|
|
37
|
+
medium?: ColSize;
|
|
38
|
+
/**
|
|
39
|
+
* The number of columns the content occupies.
|
|
40
|
+
*/
|
|
41
|
+
size: ColSize;
|
|
42
|
+
/**
|
|
43
|
+
* Override for the number of columns the content occupies on small screens.
|
|
44
|
+
*/
|
|
45
|
+
small?: ColSize;
|
|
46
|
+
}, HTMLProps<HTMLElement>>;
|
|
47
|
+
/**
|
|
48
|
+
* This is a [React](https://reactjs.org/) component for use within the Vanilla [Grid](https://docs.vanillaframework.io/patterns/grid/).
|
|
49
|
+
*
|
|
50
|
+
* Vanilla has a responsive grid using a combination of rows and columns.
|
|
51
|
+
*/
|
|
52
|
+
declare const Col: ({ children, className, element: Component, emptyLarge, emptyMedium, emptySmall, large, medium, size, small, ...props }: Props) => JSX.Element;
|
|
53
|
+
export default Col;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { PropsWithSpread, SubComponentProps } from "../../types";
|
|
3
|
+
import { ActionButtonProps } from "../ActionButton";
|
|
4
|
+
import { ConfirmationModalProps } from "../ConfirmationModal";
|
|
5
|
+
export type Props = PropsWithSpread<{
|
|
6
|
+
/**
|
|
7
|
+
* Additional props to pass to the confirmation modal.
|
|
8
|
+
*/
|
|
9
|
+
confirmationModalProps: SubComponentProps<ConfirmationModalProps>;
|
|
10
|
+
/**
|
|
11
|
+
* An optional text to be shown when hovering over the button.<br/>
|
|
12
|
+
* Defaults to the label of the confirm button in the modal.
|
|
13
|
+
*/
|
|
14
|
+
onHoverText?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to enable the SHIFT+Click shortcut to skip the confirmation modal and perform the action.
|
|
17
|
+
*/
|
|
18
|
+
shiftClickEnabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to show a hint about the SHIFT+Click shortcut to skip the confirmation modal.
|
|
21
|
+
*/
|
|
22
|
+
showShiftClickHint?: boolean;
|
|
23
|
+
}, ActionButtonProps>;
|
|
24
|
+
/**
|
|
25
|
+
* `ConfirmationButton` is a specialised version of the [ActionButton](?path=/docs/actionbutton--default-story) component that uses a [ConfirmationModal](?path=/docs/confirmationmodal--default-story) to prompt a confirmation from the user before executing an action.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ConfirmationButton: ({ confirmationModalProps, onHoverText, shiftClickEnabled, showShiftClickHint, ...actionButtonProps }: Props) => ReactElement;
|
|
28
|
+
export default ConfirmationButton;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { MouseEvent, ReactElement } from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import { PropsWithSpread, ValueOf } from "../../types";
|
|
4
|
+
import { ButtonAppearance, ButtonProps } from "../Button";
|
|
5
|
+
import { ModalProps } from "../Modal";
|
|
6
|
+
import { ActionButtonProps } from "../ActionButton";
|
|
7
|
+
export type Props = PropsWithSpread<{
|
|
8
|
+
/**
|
|
9
|
+
* Label for the cancel button.
|
|
10
|
+
*/
|
|
11
|
+
cancelButtonLabel?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Additional props to be spread on the cancel button.
|
|
14
|
+
*/
|
|
15
|
+
cancelButtonProps?: Partial<ButtonProps>;
|
|
16
|
+
/**
|
|
17
|
+
* The content of the modal.
|
|
18
|
+
*/
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Appearance of the confirm button.
|
|
22
|
+
*/
|
|
23
|
+
confirmButtonAppearance?: ValueOf<typeof ButtonAppearance> | string;
|
|
24
|
+
/**
|
|
25
|
+
* Label for the confirm button.
|
|
26
|
+
*/
|
|
27
|
+
confirmButtonLabel: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Additional props to be spread on the confirm button.
|
|
30
|
+
*/
|
|
31
|
+
confirmButtonProps?: Partial<ActionButtonProps>;
|
|
32
|
+
/**
|
|
33
|
+
* Extra elements to be placed in the button row of the modal.
|
|
34
|
+
*/
|
|
35
|
+
confirmExtra?: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Function to perform the action prompted by the modal.
|
|
38
|
+
*/
|
|
39
|
+
onConfirm: (event: MouseEvent<HTMLElement>) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the confirm button should be in the loading state.
|
|
42
|
+
*/
|
|
43
|
+
confirmButtonLoading?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the confirm button should be disabled.
|
|
46
|
+
*/
|
|
47
|
+
confirmButtonDisabled?: boolean;
|
|
48
|
+
}, Omit<ModalProps, "buttonRow">>;
|
|
49
|
+
/**
|
|
50
|
+
* `ConfirmationModal` is a specialised version of the [Modal](?path=/docs/modal--default-story) component to prompt a confirmation from the user before executing an action.
|
|
51
|
+
*/
|
|
52
|
+
export declare const ConfirmationModal: ({ cancelButtonLabel, cancelButtonProps, children, confirmButtonAppearance, confirmButtonLabel, confirmExtra, onConfirm, confirmButtonLoading, confirmButtonDisabled, confirmButtonProps, ...props }: Props) => ReactElement;
|
|
53
|
+
export default ConfirmationModal;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { HTMLProps, ReactNode } from "react";
|
|
3
|
+
import type { ButtonProps } from "../Button";
|
|
4
|
+
import type { ContextualMenuDropdownProps } from "./ContextualMenuDropdown";
|
|
5
|
+
import type { MenuLink, Position } from "./ContextualMenuDropdown";
|
|
6
|
+
import { ClassName, ExclusiveProps, PropsWithSpread, SubComponentProps } from "../../types";
|
|
7
|
+
export declare enum Label {
|
|
8
|
+
Toggle = "Toggle menu"
|
|
9
|
+
}
|
|
10
|
+
export type BaseProps<L> = PropsWithSpread<{
|
|
11
|
+
/**
|
|
12
|
+
* Whether the menu should adjust its horizontal position to fit on the screen.
|
|
13
|
+
*/
|
|
14
|
+
autoAdjust?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The menu content (if the links prop is not supplied).
|
|
17
|
+
*/
|
|
18
|
+
children?: ContextualMenuDropdownProps["dropdownContent"];
|
|
19
|
+
/**
|
|
20
|
+
* An optional class to apply to the wrapping element.
|
|
21
|
+
*/
|
|
22
|
+
className?: ClassName;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the menu should close when the escape key is pressed.
|
|
25
|
+
*/
|
|
26
|
+
closeOnEsc?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the menu should close when clicking outside the menu.
|
|
29
|
+
*/
|
|
30
|
+
closeOnOutsideClick?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the menu's width should match the toggle's width.
|
|
33
|
+
*/
|
|
34
|
+
constrainPanelWidth?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* An optional class to apply to the dropdown.
|
|
37
|
+
*/
|
|
38
|
+
dropdownClassName?: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Additional props to pass to the dropdown.
|
|
41
|
+
*/
|
|
42
|
+
dropdownProps?: SubComponentProps<ContextualMenuDropdownProps>;
|
|
43
|
+
/**
|
|
44
|
+
* A list of links to display in the menu (if the children prop is not supplied.)
|
|
45
|
+
*/
|
|
46
|
+
links?: MenuLink<L>[] | null;
|
|
47
|
+
/**
|
|
48
|
+
* A function to call when the menu is toggled.
|
|
49
|
+
*/
|
|
50
|
+
onToggleMenu?: (isOpen: boolean) => void | null;
|
|
51
|
+
/**
|
|
52
|
+
* The horizontal position of the menu.
|
|
53
|
+
*/
|
|
54
|
+
position?: Position | null;
|
|
55
|
+
/**
|
|
56
|
+
* An element to make the menu relative to.
|
|
57
|
+
*/
|
|
58
|
+
positionNode?: HTMLElement | null;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the dropdown should scroll if it is too long to fit on the screen.
|
|
61
|
+
*/
|
|
62
|
+
scrollOverflow?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the menu should be visible.
|
|
65
|
+
*/
|
|
66
|
+
visible?: boolean;
|
|
67
|
+
}, HTMLProps<HTMLSpanElement>>;
|
|
68
|
+
/**
|
|
69
|
+
* The props for the ContextualMenu component.
|
|
70
|
+
* @template L - The type of the link props.
|
|
71
|
+
*/
|
|
72
|
+
export type Props<L> = BaseProps<L> & ExclusiveProps<{
|
|
73
|
+
/**
|
|
74
|
+
* Whether the toggle should display a chevron icon.
|
|
75
|
+
*/
|
|
76
|
+
hasToggleIcon?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* The appearance of the toggle button.
|
|
79
|
+
*/
|
|
80
|
+
toggleAppearance?: ButtonProps["appearance"] | null;
|
|
81
|
+
/**
|
|
82
|
+
* A class to apply to the toggle button.
|
|
83
|
+
*/
|
|
84
|
+
toggleClassName?: string | null;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the toggle button should be disabled.
|
|
87
|
+
*/
|
|
88
|
+
toggleDisabled?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The toggle button's label.
|
|
91
|
+
*/
|
|
92
|
+
toggleLabel?: React.ReactNode | null;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the toggle lable or icon should appear first.
|
|
95
|
+
*/
|
|
96
|
+
toggleLabelFirst?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Additional props to pass to the toggle button.
|
|
99
|
+
*/
|
|
100
|
+
toggleProps?: SubComponentProps<ButtonProps>;
|
|
101
|
+
}, {
|
|
102
|
+
toggle: ReactNode;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Contextual menu](https://docs.vanillaframework.io/patterns//contextual-menu/).
|
|
106
|
+
*
|
|
107
|
+
* A contextual menu can be used in conjunction with any page element to provide a contextual menu.
|
|
108
|
+
*/
|
|
109
|
+
declare const ContextualMenu: <L>({ autoAdjust, children, className, closeOnEsc, closeOnOutsideClick, constrainPanelWidth, dropdownClassName, dropdownProps, hasToggleIcon, links, onToggleMenu, position, positionNode, scrollOverflow, toggle, toggleAppearance, toggleClassName, toggleDisabled, toggleLabel, toggleLabelFirst, toggleProps, visible, ...wrapperProps }: Props<L>) => JSX.Element;
|
|
110
|
+
export default ContextualMenu;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import type { HTMLProps, ReactNode } from "react";
|
|
3
|
+
import type { ButtonProps } from "../../Button";
|
|
4
|
+
import type { WindowFitment } from "../../../hooks";
|
|
5
|
+
export declare enum Label {
|
|
6
|
+
Dropdown = "submenu"
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The type of the menu links.
|
|
10
|
+
* @template L - The type of the link props.
|
|
11
|
+
*/
|
|
12
|
+
export type MenuLink<L = null> = string | ButtonProps<L> | ButtonProps<L>[];
|
|
13
|
+
export type Position = "left" | "center" | "right";
|
|
14
|
+
/**
|
|
15
|
+
* The props for the ContextualMenuDropdown component.
|
|
16
|
+
* @template L - The type of the link props.
|
|
17
|
+
*/
|
|
18
|
+
export type Props<L = null> = {
|
|
19
|
+
adjustedPosition?: Position;
|
|
20
|
+
autoAdjust?: boolean;
|
|
21
|
+
handleClose?: (evt?: MouseEvent) => void;
|
|
22
|
+
constrainPanelWidth?: boolean;
|
|
23
|
+
dropdownClassName?: string;
|
|
24
|
+
dropdownContent?: ReactNode | ((close: () => void) => ReactElement);
|
|
25
|
+
id?: string;
|
|
26
|
+
isOpen?: boolean;
|
|
27
|
+
links?: MenuLink<L>[];
|
|
28
|
+
position?: Position;
|
|
29
|
+
positionCoords?: DOMRect;
|
|
30
|
+
positionNode?: HTMLElement;
|
|
31
|
+
scrollOverflow?: boolean;
|
|
32
|
+
setAdjustedPosition?: (position: Position) => void;
|
|
33
|
+
contextualMenuClassName?: string;
|
|
34
|
+
} & HTMLProps<HTMLSpanElement>;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate the adjusted position in relation to the window.
|
|
37
|
+
* @param position - The requested position.
|
|
38
|
+
* @param fitsWindow - The window fitment info.
|
|
39
|
+
* @return The new position.
|
|
40
|
+
*/
|
|
41
|
+
export declare const adjustForWindow: (position: Position, fitsWindow: WindowFitment) => Position;
|
|
42
|
+
declare const ContextualMenuDropdown: <L>({ adjustedPosition, autoAdjust, handleClose, constrainPanelWidth, dropdownClassName, dropdownContent, id, isOpen, links, position, positionCoords, positionNode, scrollOverflow, setAdjustedPosition, contextualMenuClassName, ...props }: Props<L>) => JSX.Element;
|
|
43
|
+
export default ContextualMenuDropdown;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode, HTMLProps, ReactElement } from "react";
|
|
2
|
+
import { PropsWithSpread } from "../../types";
|
|
3
|
+
export type Props = PropsWithSpread<{
|
|
4
|
+
/**
|
|
5
|
+
* The content of the empty state.
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Optional class(es) to add to the wrapping element.
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* An image representing the empty state.
|
|
14
|
+
*/
|
|
15
|
+
image: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* The title of the empty state.
|
|
18
|
+
*/
|
|
19
|
+
title: string;
|
|
20
|
+
}, HTMLProps<HTMLDivElement>>;
|
|
21
|
+
/**
|
|
22
|
+
* This is a [React](https://reactjs.org/) component to represent an empty state.
|
|
23
|
+
*/
|
|
24
|
+
export declare const EmptyState: ({ children, className, image, title, ...props }: Props) => ReactElement;
|
|
25
|
+
export default EmptyState;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ClassName } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* The props for the Field component.
|
|
5
|
+
*/
|
|
6
|
+
export type Props = {
|
|
7
|
+
/**
|
|
8
|
+
* The content for caution validation.
|
|
9
|
+
*/
|
|
10
|
+
caution?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The content of the Field component.
|
|
13
|
+
*/
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Optional class(es) to pass to the Field wrapper div.
|
|
17
|
+
*/
|
|
18
|
+
className?: ClassName;
|
|
19
|
+
/**
|
|
20
|
+
* The content for error validation.
|
|
21
|
+
*/
|
|
22
|
+
error?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The id of the input this Field component is controlling.
|
|
25
|
+
*/
|
|
26
|
+
forId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Help text to show below the field.
|
|
29
|
+
*/
|
|
30
|
+
help?: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Optional class(es) to pass to the help text element.
|
|
33
|
+
*/
|
|
34
|
+
helpClassName?: string;
|
|
35
|
+
/**
|
|
36
|
+
* An id to give to the help element.
|
|
37
|
+
*/
|
|
38
|
+
helpId?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the component is wrapping a select element.
|
|
41
|
+
*/
|
|
42
|
+
isSelect?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the component is wrapping a checkbox or radio element.
|
|
45
|
+
*/
|
|
46
|
+
isTickElement?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The label for the field.
|
|
49
|
+
*/
|
|
50
|
+
label?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Optional class(es) to pass to the label component.
|
|
53
|
+
*/
|
|
54
|
+
labelClassName?: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the label should show before the input.
|
|
57
|
+
*/
|
|
58
|
+
labelFirst?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the field is required.
|
|
61
|
+
*/
|
|
62
|
+
required?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the form field should have a stacked appearance.
|
|
65
|
+
*/
|
|
66
|
+
stacked?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The content for success validation.
|
|
69
|
+
*/
|
|
70
|
+
success?: ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* An id to give to the caution, error or success element.
|
|
73
|
+
*/
|
|
74
|
+
validationId?: string;
|
|
75
|
+
};
|
|
76
|
+
declare const Field: ({ caution, children, className, error, forId, help, helpClassName, helpId, isSelect, isTickElement, label, labelClassName, labelFirst, required, stacked, success, validationId, ...props }: Props) => JSX.Element;
|
|
77
|
+
export default Field;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HTMLProps, ReactNode } from "react";
|
|
2
|
+
import type { ClassName, PropsWithSpread } from "../../types";
|
|
3
|
+
export type Props = PropsWithSpread<{
|
|
4
|
+
/**
|
|
5
|
+
* The content of the form.
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Optional class(es) to pass to the form element.
|
|
10
|
+
*/
|
|
11
|
+
className?: ClassName;
|
|
12
|
+
inline?: boolean;
|
|
13
|
+
stacked?: boolean;
|
|
14
|
+
}, HTMLProps<HTMLFormElement>>;
|
|
15
|
+
/**
|
|
16
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Form](https://docs.vanillaframework.io/base/forms).
|
|
17
|
+
*
|
|
18
|
+
* Form controls have global styling defined at the HTML element level. Labels and most input types are 100% width of the `<form>` parent element.
|
|
19
|
+
*/
|
|
20
|
+
declare const Form: ({ children, className, inline, stacked, ...props }: Props) => JSX.Element;
|
|
21
|
+
export default Form;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ComponentProps, type ComponentType, type ElementType, type HTMLProps } from "react";
|
|
2
|
+
import Input from "../Input";
|
|
3
|
+
export type Props<C extends ElementType | ComponentType = typeof Input> = {
|
|
4
|
+
/**
|
|
5
|
+
* The component to display.
|
|
6
|
+
* @default Input
|
|
7
|
+
*/
|
|
8
|
+
component?: C;
|
|
9
|
+
/**
|
|
10
|
+
* This can be used to hide errors returned by Formik.
|
|
11
|
+
*/
|
|
12
|
+
displayError?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The name of the field as given to Formik.
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
value?: HTMLProps<HTMLElement>["value"];
|
|
18
|
+
} & ComponentProps<C>;
|
|
19
|
+
/**
|
|
20
|
+
* This component makes it easier to use Vanilla form inputs with Formik. It
|
|
21
|
+
* makes use of Formik's context to automatically map errors, values, states
|
|
22
|
+
* etc. onto the provided field.
|
|
23
|
+
*/
|
|
24
|
+
declare const FormikField: <C extends ElementType | ComponentType = ({ caution, className, error, help, helpClassName, id, label, labelClassName, required, stacked, success, takeFocus, takeFocusDelay, type, wrapperClassName, ...inputProps }: import("../Input").InputProps) => JSX.Element>({ component: Component, displayError, name, value, label, ...props }: Props<C>) => JSX.Element;
|
|
25
|
+
export default FormikField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type Props as FormikFieldProps } from "./FormikField";
|