@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,66 @@
|
|
|
1
|
+
import { ReactNode, HTMLProps } from "react";
|
|
2
|
+
import type { GenerateLink, NavItem, LogoProps } from "./types";
|
|
3
|
+
import { PropsWithSpread, SubComponentProps } from "../../types";
|
|
4
|
+
import { SearchBoxProps } from "../SearchBox";
|
|
5
|
+
import { Theme } from "../../enums";
|
|
6
|
+
export type Props = PropsWithSpread<{
|
|
7
|
+
/**
|
|
8
|
+
* By default the header is constrained to the width of the grid. Use this
|
|
9
|
+
* option to make the header take the full width of the page.
|
|
10
|
+
*/
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* This function can be used to generate link elements when you don't want to
|
|
14
|
+
* use a standard HTML anchor.
|
|
15
|
+
*/
|
|
16
|
+
generateLink?: GenerateLink | null;
|
|
17
|
+
/**
|
|
18
|
+
* The main navigation items that appear on the left hand side next to the logo.
|
|
19
|
+
*/
|
|
20
|
+
items?: NavItem[] | null;
|
|
21
|
+
/**
|
|
22
|
+
* Additional navigation items that appear on the right hand side of the
|
|
23
|
+
* navigation banner.
|
|
24
|
+
*/
|
|
25
|
+
itemsRight?: NavItem[] | null;
|
|
26
|
+
/**
|
|
27
|
+
* Additional props to be applied to the nav element that wraps the main
|
|
28
|
+
* navigation items on the left hand side.
|
|
29
|
+
*/
|
|
30
|
+
leftNavProps?: HTMLProps<HTMLUListElement> | null;
|
|
31
|
+
/**
|
|
32
|
+
* The logo can be defined either by providing props for the standard logo
|
|
33
|
+
* or the full logo markup when a custom logo is needed.
|
|
34
|
+
*/
|
|
35
|
+
logo: LogoProps | ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Additional props to be applied to the nav element that wraps the
|
|
38
|
+
* left and right nav items.
|
|
39
|
+
*/
|
|
40
|
+
navProps?: HTMLProps<HTMLElement> | null;
|
|
41
|
+
/**
|
|
42
|
+
* Additional props to be applied to the nav element that wraps the
|
|
43
|
+
* navigation items on the right hand side.
|
|
44
|
+
*/
|
|
45
|
+
rightNavProps?: HTMLProps<HTMLUListElement> | null;
|
|
46
|
+
/**
|
|
47
|
+
* Props to pass to the SearchBox component. When these props are provided the
|
|
48
|
+
* search box will appear.
|
|
49
|
+
*/
|
|
50
|
+
searchProps?: SubComponentProps<SearchBoxProps> | null;
|
|
51
|
+
/**
|
|
52
|
+
* The header theme. When this is not provided the header will use the default
|
|
53
|
+
* theme defined in the Vanilla settings.
|
|
54
|
+
*/
|
|
55
|
+
theme?: Theme | null;
|
|
56
|
+
}, HTMLProps<HTMLElement>>;
|
|
57
|
+
/**
|
|
58
|
+
This is the [React](https://reactjs.org/) component for the Vanilla
|
|
59
|
+
[Navigation](https://vanillaframework.io/docs/patterns/navigation) pattern. It
|
|
60
|
+
is a simple navigation bar that you can add to the top of your site or app.
|
|
61
|
+
|
|
62
|
+
The navigation items are collapsed behind a "Menu" link in small screens and
|
|
63
|
+
displayed horizontally on larger screens.
|
|
64
|
+
*/
|
|
65
|
+
declare const Navigation: ({ fullWidth, generateLink, items, itemsRight, leftNavProps, logo, navProps, rightNavProps, searchProps, theme, ...headerProps }: Props) => JSX.Element;
|
|
66
|
+
export default Navigation;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GenerateLink, NavLink } from "../types";
|
|
2
|
+
type Props = {
|
|
3
|
+
generateLink?: GenerateLink;
|
|
4
|
+
link: NavLink;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* This component is used internally to display links inside the Navigation component.
|
|
8
|
+
*/
|
|
9
|
+
declare const NavigationLink: ({ generateLink, link }: Props) => JSX.Element | null;
|
|
10
|
+
export default NavigationLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./NavigationLink";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HTMLProps } from "react";
|
|
2
|
+
import type { GenerateLink, NavMenu } from "../types";
|
|
3
|
+
import { PropsWithSpread } from "../../../types";
|
|
4
|
+
type Props = PropsWithSpread<NavMenu & {
|
|
5
|
+
generateLink?: GenerateLink;
|
|
6
|
+
}, HTMLProps<HTMLLIElement>>;
|
|
7
|
+
/**
|
|
8
|
+
* This component is used internally to display menus inside the Navigation component.
|
|
9
|
+
*/
|
|
10
|
+
declare const NavigationMenu: ({ alignRight, generateLink, items, label, ...props }: Props) => JSX.Element;
|
|
11
|
+
export default NavigationMenu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./NavigationMenu";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { HTMLAttributes, HTMLProps, ReactNode } from "react";
|
|
2
|
+
import { PropsWithSpread } from "../../types";
|
|
3
|
+
export type NavLinkBase = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether this nav item is currently selected.
|
|
6
|
+
*/
|
|
7
|
+
isSelected?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The label of the link.
|
|
10
|
+
*/
|
|
11
|
+
label: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* The URL of the link.
|
|
14
|
+
*/
|
|
15
|
+
url?: string;
|
|
16
|
+
};
|
|
17
|
+
export type NavLinkAnchor = PropsWithSpread<NavLinkBase & {
|
|
18
|
+
url: string;
|
|
19
|
+
}, HTMLAttributes<HTMLAnchorElement>>;
|
|
20
|
+
export type NavLinkButton = PropsWithSpread<NavLinkBase & {
|
|
21
|
+
url?: never;
|
|
22
|
+
}, HTMLAttributes<HTMLButtonElement>>;
|
|
23
|
+
export type NavLink = NavLinkAnchor | NavLinkButton;
|
|
24
|
+
export type NavMenu = {
|
|
25
|
+
/**
|
|
26
|
+
* Whether to align the dropdown to the right edge of the navigation item.
|
|
27
|
+
*/
|
|
28
|
+
alignRight?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The links to appear in the dropdown.
|
|
31
|
+
*/
|
|
32
|
+
items: NavLink[];
|
|
33
|
+
/**
|
|
34
|
+
* The label of the navigation item that opens the menu.
|
|
35
|
+
*/
|
|
36
|
+
label: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Navigation items which can be either a link or a menu containing links.
|
|
40
|
+
*/
|
|
41
|
+
export type NavItem = NavLink | NavMenu;
|
|
42
|
+
/**
|
|
43
|
+
* A function that can be used to generate link elements when you don't want to
|
|
44
|
+
* use a standard HTML anchor.
|
|
45
|
+
*/
|
|
46
|
+
export type GenerateLink = (item: NavLink) => ReactNode;
|
|
47
|
+
export type LogoProps = PropsWithSpread<{
|
|
48
|
+
/**
|
|
49
|
+
* An icon to display in the tag.
|
|
50
|
+
*/
|
|
51
|
+
icon?: ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* The logo image source URL.
|
|
54
|
+
*/
|
|
55
|
+
src?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The site's title.
|
|
58
|
+
*/
|
|
59
|
+
title: string;
|
|
60
|
+
/**
|
|
61
|
+
* The URL to navigate to when the logo is clicked.
|
|
62
|
+
*/
|
|
63
|
+
url: string;
|
|
64
|
+
}, HTMLProps<HTMLDivElement>>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ElementType } from "react";
|
|
2
|
+
import type { HTMLProps, ReactNode } from "react";
|
|
3
|
+
import type { ClassName, PropsWithSpread, ValueOf } from "../../types";
|
|
4
|
+
export declare enum Label {
|
|
5
|
+
Close = "Close notification"
|
|
6
|
+
}
|
|
7
|
+
export declare const NotificationSeverity: {
|
|
8
|
+
readonly CAUTION: "caution";
|
|
9
|
+
readonly INFORMATION: "information";
|
|
10
|
+
readonly NEGATIVE: "negative";
|
|
11
|
+
readonly POSITIVE: "positive";
|
|
12
|
+
};
|
|
13
|
+
export declare const DefaultTitles: {
|
|
14
|
+
caution: string;
|
|
15
|
+
information: string;
|
|
16
|
+
negative: string;
|
|
17
|
+
positive: string;
|
|
18
|
+
};
|
|
19
|
+
type NotificationAction = {
|
|
20
|
+
label: string;
|
|
21
|
+
onClick: () => void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The props for the Notification component.
|
|
25
|
+
*/
|
|
26
|
+
export type Props = PropsWithSpread<{
|
|
27
|
+
/**
|
|
28
|
+
* A list of up to two actions that the notification can perform.
|
|
29
|
+
*/
|
|
30
|
+
actions?: NotificationAction[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether the notification should not have a border.
|
|
33
|
+
*/
|
|
34
|
+
borderless?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The notification message content.
|
|
37
|
+
*/
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Optional class(es) to apply to the parent notification element.
|
|
41
|
+
*/
|
|
42
|
+
className?: ClassName;
|
|
43
|
+
/**
|
|
44
|
+
* **Deprecated**. Use `onDismiss` instead.
|
|
45
|
+
*/
|
|
46
|
+
close?: never;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the title should display inline with the message.
|
|
49
|
+
*/
|
|
50
|
+
inline?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The function to run when dismissing/closing the notification.
|
|
53
|
+
*/
|
|
54
|
+
onDismiss?: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* The severity of the notification.
|
|
57
|
+
*/
|
|
58
|
+
severity?: ValueOf<typeof NotificationSeverity>;
|
|
59
|
+
/**
|
|
60
|
+
* **Deprecated**. Use `title` instead.
|
|
61
|
+
*/
|
|
62
|
+
status?: never;
|
|
63
|
+
/**
|
|
64
|
+
* The amount of time (in ms) until the notification is automatically dismissed.
|
|
65
|
+
*/
|
|
66
|
+
timeout?: number;
|
|
67
|
+
/**
|
|
68
|
+
* A relevant timestamp for the notification, e.g. when it was created.
|
|
69
|
+
*/
|
|
70
|
+
timestamp?: ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* The title of the notification.
|
|
73
|
+
*/
|
|
74
|
+
title?: ReactNode;
|
|
75
|
+
/**
|
|
76
|
+
* Optional element or component to use for the title.
|
|
77
|
+
*/
|
|
78
|
+
titleElement?: ElementType;
|
|
79
|
+
/**
|
|
80
|
+
* **Deprecated**. Use `severity` instead.
|
|
81
|
+
*/
|
|
82
|
+
type?: never;
|
|
83
|
+
}, HTMLProps<HTMLDivElement>>;
|
|
84
|
+
/**
|
|
85
|
+
This is a [React](https://reactjs.org/) component for the Vanilla [Notification](https://docs.vanillaframework.io/patterns/notification/).
|
|
86
|
+
|
|
87
|
+
Notifications are used to display global information, our notification variants consist of default, caution, negative or positive.
|
|
88
|
+
|
|
89
|
+
The `NotificationProvider` component can be used to manage the notification state globally. Wrap your application components with it and then in any child component you can get the helper with `const notify = useNotify()` to easily trigger notifications:
|
|
90
|
+
|
|
91
|
+
* `notify.info("You should keep this in mind")`
|
|
92
|
+
* `notify.failure("Error when fooing a bar", errorObjectFromCatch)`
|
|
93
|
+
* `notify.success("The bar was foo'd", "Success")`
|
|
94
|
+
|
|
95
|
+
The `NotificationConsumer` component can be used to display notifications. It will automatically display any notifications that are added to the `NotificationProvider` state.
|
|
96
|
+
|
|
97
|
+
The Notification API has changed since v0.18 in order to support new variants
|
|
98
|
+
and align with our component prop naming conventions.
|
|
99
|
+
|
|
100
|
+
| Deprecated prop names | Replaced by |
|
|
101
|
+
| --------------------- | ----------- |
|
|
102
|
+
| `type` | `severity` |
|
|
103
|
+
| `status` | `title` |
|
|
104
|
+
| `close` | `onDismiss` |
|
|
105
|
+
|
|
106
|
+
The `notificationTypes` const has also been replaced with `NotificationSeverity`
|
|
107
|
+
to reflect the new prop name.
|
|
108
|
+
*/
|
|
109
|
+
declare const Notification: ({ actions, borderless, children, className, close, inline, onDismiss, severity, status, timeout, timestamp, title, titleElement: TitleComponent, type, ...props }: Props) => JSX.Element;
|
|
110
|
+
export default Notification;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { NotificationHelper, NotifyProviderProps } from "./types";
|
|
3
|
+
export declare const NotificationProvider: FC<NotifyProviderProps>;
|
|
4
|
+
export declare function useNotify(): NotificationHelper;
|
|
5
|
+
export declare const NotificationConsumer: FC;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { NotificationConsumer, NotificationProvider, useNotify, } from "./NotificationProvider";
|
|
2
|
+
export { info, success, failure, queue } from "./messageBuilder";
|
|
3
|
+
export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./types";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NotificationAction, NotificationType, QueuedNotification } from "./types";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export declare const queue: (notification: NotificationType) => QueuedNotification;
|
|
4
|
+
export declare const info: (message: ReactNode, title?: string) => NotificationType;
|
|
5
|
+
export declare const success: (message: ReactNode, title?: string) => NotificationType;
|
|
6
|
+
export declare const failure: (title: string, error: unknown, message?: ReactNode, actions?: NotificationAction[]) => NotificationType;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ValueOf } from "../../types";
|
|
3
|
+
import { NotificationSeverity } from "../Notification";
|
|
4
|
+
export interface NotifyProviderProps {
|
|
5
|
+
state?: {
|
|
6
|
+
queuedNotification: NotificationType | null;
|
|
7
|
+
};
|
|
8
|
+
pathname?: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export interface NotificationAction {
|
|
12
|
+
label: string;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
}
|
|
15
|
+
export interface NotificationType {
|
|
16
|
+
actions?: NotificationAction[];
|
|
17
|
+
message: ReactNode;
|
|
18
|
+
title?: string;
|
|
19
|
+
type: ValueOf<typeof NotificationSeverity>;
|
|
20
|
+
}
|
|
21
|
+
export interface QueuedNotification {
|
|
22
|
+
state?: {
|
|
23
|
+
queuedNotification: NotificationType | null;
|
|
24
|
+
};
|
|
25
|
+
pathname?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface NotificationHelper {
|
|
28
|
+
notification: NotificationType | null;
|
|
29
|
+
clear: () => void;
|
|
30
|
+
failure: (title: string, error: unknown, message?: ReactNode, actions?: NotificationAction[]) => NotificationType;
|
|
31
|
+
info: (message: ReactNode, title?: string) => NotificationType;
|
|
32
|
+
success: (message: ReactNode, title?: string) => NotificationType;
|
|
33
|
+
queue: (notification: NotificationType) => QueuedNotification;
|
|
34
|
+
setDeduplicated: (value: NotificationType) => NotificationType;
|
|
35
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { HTMLProps } from "react";
|
|
2
|
+
import type { PropsWithSpread } from "../../types";
|
|
3
|
+
type BaseProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to scroll to the top of the list on page change.
|
|
6
|
+
*/
|
|
7
|
+
scrollToTop?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The number of pages at which to truncate the pagination items.
|
|
10
|
+
*/
|
|
11
|
+
truncateThreshold?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the pagination is ceneterd on the page.
|
|
14
|
+
*/
|
|
15
|
+
centered?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to show the labels for forward and back buttons.
|
|
18
|
+
*/
|
|
19
|
+
showLabels?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether forward button is disabled.
|
|
22
|
+
*/
|
|
23
|
+
forwardDisabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether back button is disabled.
|
|
26
|
+
*/
|
|
27
|
+
backDisabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Custom label for forward button.
|
|
30
|
+
*/
|
|
31
|
+
forwardLabel?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Custom label for back button.
|
|
34
|
+
*/
|
|
35
|
+
backLabel?: string;
|
|
36
|
+
};
|
|
37
|
+
type NumberedPagination = BaseProps & {
|
|
38
|
+
/**
|
|
39
|
+
* The current page being viewed.<br>
|
|
40
|
+
* **Required for Numbered Pagination.**
|
|
41
|
+
*/
|
|
42
|
+
currentPage: number;
|
|
43
|
+
/**
|
|
44
|
+
* The number of items to show per page.<br>
|
|
45
|
+
* **Required for numbered pagination.**
|
|
46
|
+
*/
|
|
47
|
+
itemsPerPage: number;
|
|
48
|
+
/**
|
|
49
|
+
* Function to handle paginating the items.<br>
|
|
50
|
+
* **Required for numbered pagination.**
|
|
51
|
+
*/
|
|
52
|
+
paginate: (page: number) => void;
|
|
53
|
+
/**
|
|
54
|
+
* The total number of items.<br>
|
|
55
|
+
* **Required for numbered pagination.**
|
|
56
|
+
*/
|
|
57
|
+
totalItems: number;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to hide the pagination items.
|
|
60
|
+
*/
|
|
61
|
+
hideNumbers?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Function to handle page transition to a higher-numbered page for
|
|
64
|
+
* numbered pagination and to next page for buttons-only pagination.<br>
|
|
65
|
+
* _Called with page parameter for numbered pagination and_
|
|
66
|
+
* _with no parameter for buttons-only pagination._<br>
|
|
67
|
+
* **Required for buttons-only pagination.**
|
|
68
|
+
*/
|
|
69
|
+
onForward?: (page: number) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Function to handle page transition to a lower-numbered page for
|
|
72
|
+
* numbered pagination and to next page for buttons-only pagination.<br>
|
|
73
|
+
* _Called with page parameter for numbered pagination and_
|
|
74
|
+
* _with no parameter for buttons-only pagination._<br>
|
|
75
|
+
* **Required for buttons-only pagination.**
|
|
76
|
+
*/
|
|
77
|
+
onBack?: (page: number) => void;
|
|
78
|
+
};
|
|
79
|
+
type ButtonsOnlyPagination = BaseProps & {
|
|
80
|
+
itemsPerPage?: never;
|
|
81
|
+
totalItems?: never;
|
|
82
|
+
currentPage?: never;
|
|
83
|
+
paginate?: never;
|
|
84
|
+
hideNumbers?: never;
|
|
85
|
+
onForward: () => void;
|
|
86
|
+
onBack: () => void;
|
|
87
|
+
};
|
|
88
|
+
export type Props = PropsWithSpread<NumberedPagination | ButtonsOnlyPagination, HTMLProps<HTMLElement>>;
|
|
89
|
+
/**
|
|
90
|
+
This is a [React](https://reactjs.org/) component for the Vanilla [Pagination](https://docs.vanillaframework.io/patterns/pagination/).
|
|
91
|
+
|
|
92
|
+
The pagination component should be used to navigate between pages of content. There are two types of pagination being provided:
|
|
93
|
+
|
|
94
|
+
* **Numbered Pagination:** used when the total number of items is known.<br />
|
|
95
|
+
Depending on the length provided, the pagination component will automatically scale.<br />
|
|
96
|
+
**Required props:** itemsPerPage, totalItems, paginate, currentPage.
|
|
97
|
+
|
|
98
|
+
* **Buttons-only Pagination:** used when the total number of items is unknown.<br />
|
|
99
|
+
**Required props:** onForward, onBack.
|
|
100
|
+
*/
|
|
101
|
+
declare const Pagination: ({ itemsPerPage, totalItems, paginate, currentPage, scrollToTop, truncateThreshold, centered, showLabels, hideNumbers, onForward, onBack, forwardDisabled, backDisabled, forwardLabel, backLabel, ...navProps }: Props) => JSX.Element;
|
|
102
|
+
export default Pagination;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MouseEventHandler } from "react";
|
|
2
|
+
export declare enum Label {
|
|
3
|
+
Next = "Next page",
|
|
4
|
+
Previous = "Previous page"
|
|
5
|
+
}
|
|
6
|
+
export type PaginationDirection = "forward" | "back";
|
|
7
|
+
export type Props = {
|
|
8
|
+
/**
|
|
9
|
+
* The direction of the pagination.
|
|
10
|
+
*/
|
|
11
|
+
direction: PaginationDirection;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the pagination button should be disabled.
|
|
14
|
+
*/
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Function to handle clicking the pagination button.
|
|
18
|
+
*/
|
|
19
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to show the label for button.
|
|
22
|
+
*/
|
|
23
|
+
showLabel?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Custom label for button.
|
|
26
|
+
*/
|
|
27
|
+
label?: string;
|
|
28
|
+
};
|
|
29
|
+
declare const PaginationButton: ({ direction, onClick, disabled, showLabel, label, }: Props) => JSX.Element;
|
|
30
|
+
export default PaginationButton;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MouseEventHandler } from "react";
|
|
2
|
+
export type Props = {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the pagination item is active, i.e. the current page is this page.
|
|
5
|
+
*/
|
|
6
|
+
isActive?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The page number.
|
|
9
|
+
*/
|
|
10
|
+
number: number;
|
|
11
|
+
/**
|
|
12
|
+
* Function to handle clicking the pagination item.
|
|
13
|
+
*/
|
|
14
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
15
|
+
};
|
|
16
|
+
declare const PaginationItem: ({ number, onClick, isActive, }: Props) => JSX.Element;
|
|
17
|
+
export default PaginationItem;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PropsWithSpread } from "../../types";
|
|
3
|
+
import type { ComponentType, ElementType, HTMLProps, PropsWithChildren, ReactNode } from "react";
|
|
4
|
+
import type { ExclusiveProps } from "../../types";
|
|
5
|
+
export type LogoDefaultElement = HTMLProps<HTMLAnchorElement>;
|
|
6
|
+
type PanelLogo<L = LogoDefaultElement> = ReactNode | PropsWithSpread<{
|
|
7
|
+
/**
|
|
8
|
+
* The url of the icon image.
|
|
9
|
+
*/
|
|
10
|
+
icon: string;
|
|
11
|
+
/**
|
|
12
|
+
* The alt text for the icon image.
|
|
13
|
+
*/
|
|
14
|
+
iconAlt?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The url of the name image.
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* The alt text for the name image.
|
|
21
|
+
*/
|
|
22
|
+
nameAlt?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The element or component to use for displaying the logo e.g. `a` or `NavLink`.
|
|
25
|
+
* @default a
|
|
26
|
+
*/
|
|
27
|
+
component?: ElementType | ComponentType<L>;
|
|
28
|
+
}, L>;
|
|
29
|
+
type PanelToggle = {
|
|
30
|
+
/**
|
|
31
|
+
* The panel toggle label.
|
|
32
|
+
*/
|
|
33
|
+
label: string;
|
|
34
|
+
/**
|
|
35
|
+
* The function to call when clicking the panel toggle.
|
|
36
|
+
*/
|
|
37
|
+
onClick: () => void;
|
|
38
|
+
};
|
|
39
|
+
type LogoProps<L = LogoDefaultElement> = {
|
|
40
|
+
/**
|
|
41
|
+
* The panel logo content or attributes.
|
|
42
|
+
*/
|
|
43
|
+
logo?: PanelLogo<L>;
|
|
44
|
+
};
|
|
45
|
+
type TitleProps = {
|
|
46
|
+
/**
|
|
47
|
+
* The panel title.
|
|
48
|
+
*/
|
|
49
|
+
title: ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Classes to apply to the title element.
|
|
52
|
+
*/
|
|
53
|
+
titleClassName?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The element to use for the panel title e.g. `h1`.
|
|
56
|
+
* @default h4
|
|
57
|
+
*/
|
|
58
|
+
titleComponent?: ElementType;
|
|
59
|
+
/**
|
|
60
|
+
* An ID for the title element.
|
|
61
|
+
*/
|
|
62
|
+
titleId?: string;
|
|
63
|
+
};
|
|
64
|
+
type HeaderProps<L = LogoDefaultElement> = ExclusiveProps<{
|
|
65
|
+
/**
|
|
66
|
+
* This prop can be used to replace the header area of the panel when the default implementation is not sufficient.
|
|
67
|
+
*/
|
|
68
|
+
header: ReactNode;
|
|
69
|
+
}, {
|
|
70
|
+
/**
|
|
71
|
+
* Content that will be displayed in the controls area.
|
|
72
|
+
*/
|
|
73
|
+
controls?: ReactNode;
|
|
74
|
+
/**
|
|
75
|
+
* Classes that will be applied to the controls element.
|
|
76
|
+
*/
|
|
77
|
+
controlsClassName?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Whether the header should be sticky.
|
|
80
|
+
*/
|
|
81
|
+
stickyHeader?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The panel toggle attributes.
|
|
84
|
+
*/
|
|
85
|
+
toggle?: PanelToggle;
|
|
86
|
+
} & ExclusiveProps<LogoProps<L>, TitleProps>>;
|
|
87
|
+
export type Props<L = LogoDefaultElement> = {
|
|
88
|
+
/**
|
|
89
|
+
* The panel content.
|
|
90
|
+
*/
|
|
91
|
+
children?: PropsWithChildren["children"];
|
|
92
|
+
/**
|
|
93
|
+
* Classes that are applied to the content container (when using `wrapContent`).
|
|
94
|
+
*/
|
|
95
|
+
contentClassName?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Classes that are applied to the top level panel element.
|
|
98
|
+
*/
|
|
99
|
+
className?: string | null;
|
|
100
|
+
/**
|
|
101
|
+
* Whether to use the dark theme.
|
|
102
|
+
*/
|
|
103
|
+
dark?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the panel should wrap the content in the `p-panel__content` element.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
wrapContent?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* A ref to pass to the top level panel element.
|
|
111
|
+
*/
|
|
112
|
+
forwardRef?: React.Ref<HTMLDivElement> | null;
|
|
113
|
+
} & HeaderProps<L>;
|
|
114
|
+
/**
|
|
115
|
+
* This is a [React](https://reactjs.org/) component for panels in the
|
|
116
|
+
* [Vanilla](https://vanillaframework.io/docs/) layouts.
|
|
117
|
+
*
|
|
118
|
+
* The Panel component can be used in many areas of the application layout. It
|
|
119
|
+
* can be the child element of `AppAside`, `AppMain`, `AppNavigation`, `AppNavigationBar`
|
|
120
|
+
* and `AppStatus`.
|
|
121
|
+
*/
|
|
122
|
+
declare const Panel: <L = LogoDefaultElement>({ forwardRef, children, className, contentClassName, controlsClassName, controls, dark, header, logo, stickyHeader, title, titleClassName, titleComponent: TitleComponent, titleId, toggle, wrapContent, ...props }: Props<L>) => React.JSX.Element;
|
|
123
|
+
export default Panel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type Props as PanelProps, type LogoDefaultElement as PanelLogoDefaultElement, } from "./Panel";
|