@canonical/react-components 0.38.0 → 0.39.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/dist/components/Accordion/Accordion.d.ts +2 -2
- package/dist/components/Accordion/AccordionSection/AccordionSection.d.ts +2 -2
- package/dist/components/ActionButton/ActionButton.d.ts +1 -1
- package/dist/components/ArticlePagination/ArticlePagination.d.ts +1 -1
- package/dist/components/Badge/Badge.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/CheckboxInput/CheckableInput/CheckableInput.d.ts +1 -1
- package/dist/components/CheckboxInput/CheckboxInput.d.ts +1 -1
- package/dist/components/Chip/Chip.d.ts +1 -1
- package/dist/components/Code/Code.d.ts +1 -1
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/dist/components/CodeSnippet/CodeSnippetBlock.d.ts +1 -1
- package/dist/components/CodeSnippet/CodeSnippetDropdown.d.ts +2 -2
- package/dist/components/Col/Col.d.ts +2 -2
- package/dist/components/ContextualMenu/ContextualMenu.d.ts +1 -1
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +3 -3
- package/dist/components/Field/Field.d.ts +2 -2
- package/dist/components/Form/Form.d.ts +1 -1
- package/dist/components/Icon/Icon.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Input/Input.js +2 -2
- package/dist/components/Label/Label.d.ts +1 -1
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/List/List.d.ts +4 -4
- package/dist/components/List/List.js +1 -1
- package/dist/components/MainTable/MainTable.d.ts +4 -4
- package/dist/components/Modal/Modal.d.ts +1 -1
- package/dist/components/ModularTable/ModularTable.d.ts +1 -1
- package/dist/components/Navigation/Navigation.d.ts +1 -1
- package/dist/components/Navigation/NavigationLink/NavigationLink.d.ts +1 -1
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.d.ts +1 -1
- package/dist/components/Navigation/types.d.ts +8 -8
- package/dist/components/Notification/Notification.d.ts +2 -2
- package/dist/components/Pagination/Pagination.d.ts +1 -1
- package/dist/components/Pagination/PaginationButton/PaginationButton.d.ts +2 -2
- package/dist/components/Pagination/PaginationItem/PaginationItem.d.ts +1 -1
- package/dist/components/PasswordToggle/PasswordToggle.d.ts +1 -1
- package/dist/components/RadioInput/RadioInput.d.ts +1 -1
- package/dist/components/Row/Row.d.ts +1 -1
- package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.d.ts +1 -1
- package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +1 -1
- package/dist/components/SearchAndFilter/types.d.ts +2 -2
- package/dist/components/SearchBox/SearchBox.d.ts +10 -2
- package/dist/components/SearchBox/SearchBox.js +7 -3
- package/dist/components/Select/Select.d.ts +2 -2
- package/dist/components/Slider/Slider.d.ts +1 -1
- package/dist/components/Spinner/Spinner.d.ts +1 -1
- package/dist/components/StatusLabel/StatusLabel.d.ts +1 -1
- package/dist/components/Strip/Strip.d.ts +1 -1
- package/dist/components/SummaryButton/SummaryButton.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +1 -1
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/TableCell/TableCell.d.ts +1 -1
- package/dist/components/TableHeader/TableHeader.d.ts +1 -1
- package/dist/components/TableRow/TableRow.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +2 -2
- package/dist/components/Textarea/Textarea.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +4 -4
- package/dist/components/Tooltip/Tooltip.js +8 -3
- package/dist/hooks/useThrottle.d.ts +1 -1
- package/dist/hooks/useWindowFitment.d.ts +1 -1
- package/dist/testing/mock-scss.js +4 -0
- package/dist/types/index.d.ts +7 -7
- package/package.json +47 -47
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { HTMLProps } from "react";
|
|
2
2
|
import type { AccordionHeadings, AccordionSectionProps } from "./AccordionSection";
|
|
3
3
|
import type { ClassName, PropsWithSpread } from "../../types";
|
|
4
|
-
export
|
|
4
|
+
export type Section = AccordionSectionProps & {
|
|
5
5
|
/**
|
|
6
6
|
* An optional key for the section component. It will also be
|
|
7
7
|
* used to track which section is selected.
|
|
8
8
|
*/
|
|
9
9
|
key?: string | number;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type Props = PropsWithSpread<{
|
|
12
12
|
/**
|
|
13
13
|
* Optional classes applied to the parent element.
|
|
14
14
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { Headings } from "../../../types";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type AccordionHeadings = Exclude<Headings, "h1">;
|
|
4
|
+
export type Props = {
|
|
5
5
|
/**
|
|
6
6
|
* The content of the section.
|
|
7
7
|
*/
|
|
@@ -12,7 +12,7 @@ export declare const ButtonAppearance: {
|
|
|
12
12
|
* The type of the Button props.
|
|
13
13
|
* @template P - The type of the props if providing a component to `element`
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type Props<P = null> = {
|
|
16
16
|
/**
|
|
17
17
|
* The appearance of the button.
|
|
18
18
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HTMLProps } from "react";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import type { PropsWithSpread } from "../../../types";
|
|
4
|
-
export
|
|
4
|
+
export type Props = PropsWithSpread<{
|
|
5
5
|
/**
|
|
6
6
|
* The type of the input element.
|
|
7
7
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CheckableInputProps } from "./CheckableInput";
|
|
2
|
-
export
|
|
2
|
+
export type Props = Omit<CheckableInputProps, "inputType">;
|
|
3
3
|
declare const CheckboxInput: ({ label, indeterminate, ...checkboxProps }: Props) => JSX.Element;
|
|
4
4
|
export default CheckboxInput;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HTMLProps } from "react";
|
|
2
2
|
import type { Props as CodeSnippetBlockProps } from "./CodeSnippetBlock";
|
|
3
3
|
import type { ClassName, PropsWithSpread } from "../../types";
|
|
4
|
-
export
|
|
4
|
+
export type Props = PropsWithSpread<{
|
|
5
5
|
/**
|
|
6
6
|
* Optional class(es) to pass to the wrapping div element.
|
|
7
7
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ChangeEventHandler, HTMLProps } from "react";
|
|
2
|
-
export
|
|
2
|
+
export type DropdownOptionProps = {
|
|
3
3
|
/**
|
|
4
4
|
* The label of the dropdown option.
|
|
5
5
|
*/
|
|
6
6
|
label: string;
|
|
7
7
|
} & HTMLProps<HTMLOptionElement>;
|
|
8
|
-
export
|
|
8
|
+
export type Props = {
|
|
9
9
|
/**
|
|
10
10
|
* Function for handling the select value changing.
|
|
11
11
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ElementType, HTMLProps, ReactNode } from "react";
|
|
2
2
|
import type { ClassName, PropsWithSpread } from "../../types";
|
|
3
|
-
export
|
|
3
|
+
export type ColSize = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
4
4
|
export declare const colSizes: ColSize[];
|
|
5
|
-
export
|
|
5
|
+
export type Props = PropsWithSpread<{
|
|
6
6
|
/**
|
|
7
7
|
* The content of the column.
|
|
8
8
|
*/
|
|
@@ -11,7 +11,7 @@ export declare enum Label {
|
|
|
11
11
|
* The props for the ContextualMenu component.
|
|
12
12
|
* @template L - The type of the link props.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type Props<L> = PropsWithSpread<{
|
|
15
15
|
/**
|
|
16
16
|
* Whether the menu should adjust to fit in the screen.
|
|
17
17
|
*/
|
|
@@ -8,13 +8,13 @@ export declare enum Label {
|
|
|
8
8
|
* The type of the menu links.
|
|
9
9
|
* @template L - The type of the link props.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type MenuLink<L = null> = string | ButtonProps<L> | ButtonProps<L>[];
|
|
12
|
+
export type Position = "left" | "center" | "right";
|
|
13
13
|
/**
|
|
14
14
|
* The props for the ContextualMenuDropdown component.
|
|
15
15
|
* @template L - The type of the link props.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type Props<L = null> = {
|
|
18
18
|
adjustedPosition?: Position;
|
|
19
19
|
autoAdjust?: boolean;
|
|
20
20
|
closePortal?: (evt?: MouseEvent) => void;
|
|
@@ -3,7 +3,7 @@ import type { ClassName } from "../../types";
|
|
|
3
3
|
/**
|
|
4
4
|
* The props for the Field component.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type Props = {
|
|
7
7
|
/**
|
|
8
8
|
* The content for caution validation.
|
|
9
9
|
*/
|
|
@@ -31,7 +31,7 @@ export declare type Props = {
|
|
|
31
31
|
/**
|
|
32
32
|
* Optional class(es) to pass to the help text element.
|
|
33
33
|
*/
|
|
34
|
-
helpClassName?:
|
|
34
|
+
helpClassName?: string;
|
|
35
35
|
/**
|
|
36
36
|
* An id to give to the help element.
|
|
37
37
|
*/
|
|
@@ -82,7 +82,7 @@ var Input = function Input(_ref) {
|
|
|
82
82
|
inputRef.current.focus();
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
}, [takeFocus]);
|
|
85
|
+
}, [takeFocus, takeFocusDelay]);
|
|
86
86
|
var input;
|
|
87
87
|
|
|
88
88
|
if (type === "checkbox") {
|
|
@@ -109,7 +109,7 @@ var Input = function Input(_ref) {
|
|
|
109
109
|
error: error,
|
|
110
110
|
forId: id,
|
|
111
111
|
help: help,
|
|
112
|
-
helpClassName: helpClassName,
|
|
112
|
+
helpClassName: helpClassName + "",
|
|
113
113
|
helpId: helpId,
|
|
114
114
|
isTickElement: type === "checkbox" || type === "radio",
|
|
115
115
|
label: fieldLabel,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { HTMLProps, ReactNode } from "react";
|
|
2
2
|
import type { ClassName, Headings } from "../../types";
|
|
3
|
-
export
|
|
3
|
+
export type ListItem = ReactNode | ({
|
|
4
4
|
content: ReactNode;
|
|
5
5
|
} & HTMLProps<HTMLLIElement>);
|
|
6
|
-
export
|
|
6
|
+
export type SteppedListItem = {
|
|
7
7
|
content: ReactNode;
|
|
8
8
|
title: ReactNode;
|
|
9
9
|
titleElement?: Headings;
|
|
10
|
-
} & HTMLProps<HTMLLIElement>;
|
|
11
|
-
export
|
|
10
|
+
} & Omit<HTMLProps<HTMLLIElement>, "title" | "content">;
|
|
11
|
+
export type Props = {
|
|
12
12
|
/**
|
|
13
13
|
* Optional class(es) to pass to the wrapping element.
|
|
14
14
|
*/
|
|
@@ -62,7 +62,7 @@ var generateItems = function generateItems(_ref) {
|
|
|
62
62
|
if (stepped) {
|
|
63
63
|
body = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TitleComponent, {
|
|
64
64
|
className: "p-stepped-list__title"
|
|
65
|
-
}, title), /*#__PURE__*/_react.default.createElement("
|
|
65
|
+
}, title), /*#__PURE__*/_react.default.createElement("div", {
|
|
66
66
|
className: "p-stepped-list__content"
|
|
67
67
|
}, content));
|
|
68
68
|
} else {
|
|
@@ -2,7 +2,7 @@ import type { HTMLProps, ReactNode } from "react";
|
|
|
2
2
|
import type { ClassName, PropsWithSpread, SortDirection } from "../../types";
|
|
3
3
|
import type { TableProps } from "../Table";
|
|
4
4
|
import type { TableCellProps } from "../TableCell";
|
|
5
|
-
export
|
|
5
|
+
export type MainTableHeader = PropsWithSpread<{
|
|
6
6
|
/**
|
|
7
7
|
* The content of the table header.
|
|
8
8
|
*/
|
|
@@ -20,13 +20,13 @@ export declare type MainTableHeader = PropsWithSpread<{
|
|
|
20
20
|
*/
|
|
21
21
|
heading?: string;
|
|
22
22
|
}, HTMLProps<HTMLTableHeaderCellElement>>;
|
|
23
|
-
export
|
|
23
|
+
export type MainTableCell = PropsWithSpread<{
|
|
24
24
|
/**
|
|
25
25
|
* The content of the table cell.
|
|
26
26
|
*/
|
|
27
27
|
content?: ReactNode;
|
|
28
28
|
}, Omit<TableCellProps, "children">>;
|
|
29
|
-
export
|
|
29
|
+
export type MainTableRow = PropsWithSpread<{
|
|
30
30
|
/**
|
|
31
31
|
* Optional class(es) to apply to the row.
|
|
32
32
|
*/
|
|
@@ -53,7 +53,7 @@ export declare type MainTableRow = PropsWithSpread<{
|
|
|
53
53
|
*/
|
|
54
54
|
sortData?: Record<string, unknown>;
|
|
55
55
|
}, HTMLProps<HTMLTableRowElement>>;
|
|
56
|
-
export
|
|
56
|
+
export type Props = PropsWithSpread<{
|
|
57
57
|
/**
|
|
58
58
|
* The default key to sort the rows by.
|
|
59
59
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
2
|
import type { HTMLProps, ReactNode } from "react";
|
|
3
3
|
import { ClassName, PropsWithSpread } from "../../types";
|
|
4
|
-
export
|
|
4
|
+
export type Props = PropsWithSpread<{
|
|
5
5
|
/**
|
|
6
6
|
* Buttons to display underneath the main modal content.
|
|
7
7
|
*/
|
|
@@ -2,7 +2,7 @@ import { ReactNode, HTMLProps } from "react";
|
|
|
2
2
|
import { TableCellProps, TableHeaderProps, TableRowProps } from "react-table";
|
|
3
3
|
import type { Column, UseTableOptions, Cell, Row, HeaderGroup } from "react-table";
|
|
4
4
|
import { PropsWithSpread } from "../../types";
|
|
5
|
-
export
|
|
5
|
+
export type Props<D extends Record<string, unknown>> = PropsWithSpread<{
|
|
6
6
|
/**
|
|
7
7
|
* The columns of the table.
|
|
8
8
|
*/
|
|
@@ -3,7 +3,7 @@ import type { GenerateLink, NavItem, LogoProps } from "./types";
|
|
|
3
3
|
import { PropsWithSpread, SubComponentProps } from "../../types";
|
|
4
4
|
import { SearchBoxProps } from "../SearchBox";
|
|
5
5
|
import { Theme } from "../../enums";
|
|
6
|
-
export
|
|
6
|
+
export type Props = PropsWithSpread<{
|
|
7
7
|
/**
|
|
8
8
|
* By default the header is constrained to the width of the grid. Use this
|
|
9
9
|
* option to make the header take the full width of the page.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HTMLProps } from "react";
|
|
2
2
|
import type { GenerateLink, NavMenu } from "../types";
|
|
3
3
|
import { PropsWithSpread } from "../../../types";
|
|
4
|
-
|
|
4
|
+
type Props = PropsWithSpread<NavMenu & {
|
|
5
5
|
generateLink?: GenerateLink;
|
|
6
6
|
}, HTMLProps<HTMLLIElement>>;
|
|
7
7
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HTMLAttributes, HTMLProps, ReactNode } from "react";
|
|
2
2
|
import { PropsWithSpread } from "../../types";
|
|
3
|
-
export
|
|
3
|
+
export type NavLinkBase = {
|
|
4
4
|
/**
|
|
5
5
|
* Whether this nav item is currently selected.
|
|
6
6
|
*/
|
|
@@ -14,14 +14,14 @@ export declare type NavLinkBase = {
|
|
|
14
14
|
*/
|
|
15
15
|
url?: string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type NavLinkAnchor = PropsWithSpread<NavLinkBase & {
|
|
18
18
|
url: string;
|
|
19
19
|
}, HTMLAttributes<HTMLAnchorElement>>;
|
|
20
|
-
export
|
|
20
|
+
export type NavLinkButton = PropsWithSpread<NavLinkBase & {
|
|
21
21
|
url?: never;
|
|
22
22
|
}, HTMLAttributes<HTMLButtonElement>>;
|
|
23
|
-
export
|
|
24
|
-
export
|
|
23
|
+
export type NavLink = NavLinkAnchor | NavLinkButton;
|
|
24
|
+
export type NavMenu = {
|
|
25
25
|
/**
|
|
26
26
|
* Whether to align the dropdown to the right edge of the navigation item.
|
|
27
27
|
*/
|
|
@@ -38,13 +38,13 @@ export declare type NavMenu = {
|
|
|
38
38
|
/**
|
|
39
39
|
* Navigation items which can be either a link or a menu containing links.
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
41
|
+
export type NavItem = NavLink | NavMenu;
|
|
42
42
|
/**
|
|
43
43
|
* A function that can be used to generate link elements when you don't want to
|
|
44
44
|
* use a standard HTML anchor.
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
47
|
-
export
|
|
46
|
+
export type GenerateLink = (item: NavLink) => ReactNode;
|
|
47
|
+
export type LogoProps = PropsWithSpread<{
|
|
48
48
|
/**
|
|
49
49
|
* An icon to display in the tag.
|
|
50
50
|
*/
|
|
@@ -9,14 +9,14 @@ export declare const NotificationSeverity: {
|
|
|
9
9
|
readonly NEGATIVE: "negative";
|
|
10
10
|
readonly POSITIVE: "positive";
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type NotificationAction = {
|
|
13
13
|
label: string;
|
|
14
14
|
onClick: () => void;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* The props for the Notification component.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type Props = PropsWithSpread<{
|
|
20
20
|
/**
|
|
21
21
|
* A list of up to two actions that the notification can perform.
|
|
22
22
|
*/
|
|
@@ -3,8 +3,8 @@ export declare enum Label {
|
|
|
3
3
|
Next = "Next page",
|
|
4
4
|
Previous = "Previous page"
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type PaginationDirection = "forward" | "back";
|
|
7
|
+
export type Props = {
|
|
8
8
|
/**
|
|
9
9
|
* The direction of the pagination.
|
|
10
10
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CheckableInputProps } from "../CheckboxInput/CheckableInput";
|
|
2
|
-
export
|
|
2
|
+
export type Props = Omit<CheckableInputProps, "inputType">;
|
|
3
3
|
declare const RadioInput: ({ label, ...radioProps }: Props) => JSX.Element;
|
|
4
4
|
export default RadioInput;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type SearchAndFilterChip = {
|
|
2
2
|
id?: number;
|
|
3
3
|
lead?: string;
|
|
4
4
|
quoteValue?: boolean;
|
|
5
5
|
value: string;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type SearchAndFilterData = {
|
|
8
8
|
id: number;
|
|
9
9
|
chips?: SearchAndFilterChip[];
|
|
10
10
|
heading?: string;
|
|
@@ -4,7 +4,7 @@ export declare enum Label {
|
|
|
4
4
|
Clear = "Clear search field",
|
|
5
5
|
Search = "Search"
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type Props = PropsWithSpread<{
|
|
8
8
|
/**
|
|
9
9
|
* Whether autocomplete should be enabled for the search input.
|
|
10
10
|
*/
|
|
@@ -29,10 +29,18 @@ export declare type Props = PropsWithSpread<{
|
|
|
29
29
|
* A function that is called when the user clicks the search icon
|
|
30
30
|
*/
|
|
31
31
|
onSearch?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* A function that is called when the user clicks the reset icon
|
|
34
|
+
*/
|
|
35
|
+
onClear?: () => void;
|
|
32
36
|
/**
|
|
33
37
|
* A search input placeholder message.
|
|
34
38
|
*/
|
|
35
39
|
placeholder?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the search input should receive focus after pressing the reset button
|
|
42
|
+
*/
|
|
43
|
+
shouldRefocusAfterReset?: boolean;
|
|
36
44
|
/**
|
|
37
45
|
* A ref that is passed to the input element.
|
|
38
46
|
*/
|
|
@@ -42,5 +50,5 @@ export declare type Props = PropsWithSpread<{
|
|
|
42
50
|
*/
|
|
43
51
|
value?: string;
|
|
44
52
|
}, HTMLProps<HTMLInputElement>>;
|
|
45
|
-
declare const SearchBox: React.ForwardRefExoticComponent<
|
|
53
|
+
declare const SearchBox: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
46
54
|
export default SearchBox;
|
|
@@ -13,7 +13,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
|
|
14
14
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
15
15
|
|
|
16
|
-
var _excluded = ["autocomplete", "className", "disabled", "externallyControlled", "onChange", "onSearch", "placeholder", "value"];
|
|
16
|
+
var _excluded = ["autocomplete", "className", "disabled", "externallyControlled", "onChange", "onSearch", "onClear", "placeholder", "shouldRefocusAfterReset", "value"];
|
|
17
17
|
|
|
18
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
19
|
|
|
@@ -43,18 +43,22 @@ var SearchBox = /*#__PURE__*/_react.default.forwardRef(function (_ref, forwarded
|
|
|
43
43
|
externallyControlled = _ref.externallyControlled,
|
|
44
44
|
_onChange = _ref.onChange,
|
|
45
45
|
onSearch = _ref.onSearch,
|
|
46
|
+
onClear = _ref.onClear,
|
|
46
47
|
_ref$placeholder = _ref.placeholder,
|
|
47
48
|
placeholder = _ref$placeholder === void 0 ? "Search" : _ref$placeholder,
|
|
49
|
+
shouldRefocusAfterReset = _ref.shouldRefocusAfterReset,
|
|
48
50
|
value = _ref.value,
|
|
49
51
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
50
52
|
|
|
51
53
|
var internalRef = (0, _react.useRef)();
|
|
52
54
|
|
|
53
55
|
var resetInput = function resetInput() {
|
|
54
|
-
_onChange
|
|
56
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange("");
|
|
57
|
+
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
55
58
|
|
|
56
59
|
if (internalRef.current) {
|
|
57
60
|
internalRef.current.value = "";
|
|
61
|
+
if (shouldRefocusAfterReset) internalRef.current.focus();
|
|
58
62
|
}
|
|
59
63
|
};
|
|
60
64
|
|
|
@@ -74,7 +78,7 @@ var SearchBox = /*#__PURE__*/_react.default.forwardRef(function (_ref, forwarded
|
|
|
74
78
|
id: "search",
|
|
75
79
|
name: "search",
|
|
76
80
|
onChange: function onChange(evt) {
|
|
77
|
-
return _onChange(evt.target.value);
|
|
81
|
+
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(evt.target.value);
|
|
78
82
|
},
|
|
79
83
|
placeholder: placeholder,
|
|
80
84
|
ref: function ref(input) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ChangeEventHandler, ReactNode, OptionHTMLAttributes, SelectHTMLAttributes } from "react";
|
|
2
2
|
import type { ClassName, PropsWithSpread } from "../../types";
|
|
3
|
-
|
|
3
|
+
type Option = OptionHTMLAttributes<HTMLOptionElement>;
|
|
4
4
|
/**
|
|
5
5
|
* The props for the Select component.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type Props = PropsWithSpread<{
|
|
8
8
|
/**
|
|
9
9
|
* The content for caution validation.
|
|
10
10
|
*/
|
|
@@ -2,7 +2,7 @@ import type { ChangeEventHandler, HTMLProps, ReactNode } from "react";
|
|
|
2
2
|
import type { PropsWithSpread } from "../../types";
|
|
3
3
|
export declare const FILLED_COLOR = "#0066CC";
|
|
4
4
|
export declare const EMPTY_COLOR = "#D9D9D9";
|
|
5
|
-
export
|
|
5
|
+
export type Props = PropsWithSpread<{
|
|
6
6
|
/**
|
|
7
7
|
* Field caution message.
|
|
8
8
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ElementType, HTMLProps, ReactNode } from "react";
|
|
2
2
|
import type { ColSize } from "../Col/Col";
|
|
3
3
|
import type { ClassName, PropsWithSpread } from "../../types";
|
|
4
|
-
export
|
|
4
|
+
export type Props = PropsWithSpread<{
|
|
5
5
|
/**
|
|
6
6
|
* The content of the strip.
|
|
7
7
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HTMLProps, ElementType, ReactNode, ComponentType } from "react";
|
|
2
2
|
import type { ClassName } from "../../types";
|
|
3
|
-
export
|
|
3
|
+
export type TabLink<P = null> = {
|
|
4
4
|
/**
|
|
5
5
|
* Whether the tab link should have active styling.
|
|
6
6
|
*/
|
|
@@ -22,7 +22,7 @@ export declare type TabLink<P = null> = {
|
|
|
22
22
|
*/
|
|
23
23
|
listItemClassName?: string;
|
|
24
24
|
} & (HTMLProps<HTMLElement> | P);
|
|
25
|
-
export
|
|
25
|
+
export type Props<P = null> = {
|
|
26
26
|
/**
|
|
27
27
|
* Optional classes applied to the parent "nav" element.
|
|
28
28
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { WindowFitment } from "../../hooks";
|
|
3
3
|
import type { ClassName, ValueOf } from "../../types";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type CSSPosition = "static" | "absolute" | "fixed" | "relative" | "sticky" | "initial" | "inherit";
|
|
5
|
+
export type PositionStyle = {
|
|
6
6
|
left: number;
|
|
7
7
|
pointerEvents?: string;
|
|
8
8
|
position: CSSPosition;
|
|
@@ -18,8 +18,8 @@ export declare const position: {
|
|
|
18
18
|
readonly topLeft: "top-left";
|
|
19
19
|
readonly topRight: "top-right";
|
|
20
20
|
};
|
|
21
|
-
export
|
|
22
|
-
export
|
|
21
|
+
export type Position = ValueOf<typeof position>;
|
|
22
|
+
export type Props = {
|
|
23
23
|
/**
|
|
24
24
|
* Whether the tooltip should adjust to fit in the screen.
|
|
25
25
|
*/
|
|
@@ -186,8 +186,8 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
186
186
|
position: "absolute",
|
|
187
187
|
// Initially position the tooltip of the screen in case it gets shown
|
|
188
188
|
// before setting the position.
|
|
189
|
-
left: -
|
|
190
|
-
top: -
|
|
189
|
+
left: -9999999,
|
|
190
|
+
top: -9999999
|
|
191
191
|
}),
|
|
192
192
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
193
193
|
positionStyle = _useState4[0],
|
|
@@ -282,7 +282,12 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
282
282
|
"u-off-screen": !isOpen
|
|
283
283
|
}, tooltipClassName),
|
|
284
284
|
"data-testid": "tooltip-portal",
|
|
285
|
-
style: positionStyle
|
|
285
|
+
style: positionStyle // style={
|
|
286
|
+
// isOpen
|
|
287
|
+
// ? (positionStyle as React.CSSProperties)
|
|
288
|
+
// : { left: -9999 }
|
|
289
|
+
// }
|
|
290
|
+
|
|
286
291
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
287
292
|
role: "tooltip",
|
|
288
293
|
className: "p-tooltip__message",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,36 +2,36 @@
|
|
|
2
2
|
* This type should be used for all className props in order to ensure
|
|
3
3
|
* consistency across components.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type ClassName = string | null;
|
|
6
6
|
/**
|
|
7
7
|
* The allowable heading levels.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type Headings = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
10
10
|
/**
|
|
11
11
|
* This type can be used when defining props that also spread the props of
|
|
12
12
|
* something else. It ensures that the defined component props are never
|
|
13
13
|
* overwritten by the spread props.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type PropsWithSpread<P, H> = P & Omit<H, keyof P>;
|
|
16
16
|
/**
|
|
17
17
|
* The allowable sort directions e.g. for a sortable table.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type SortDirection = "none" | "ascending" | "descending";
|
|
20
20
|
/**
|
|
21
21
|
* This type can be used when passing props to a sub component. It makes all
|
|
22
22
|
* component props optional.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export type SubComponentProps<P> = Partial<P> & {
|
|
25
25
|
[prop: string]: unknown;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* This type is simply an alias for the 'any' type and should be used sparingly,
|
|
29
29
|
* if at all.
|
|
30
30
|
*/
|
|
31
|
-
export
|
|
31
|
+
export type TSFixMe = any;
|
|
32
32
|
/**
|
|
33
33
|
* This type allows for converting an object const into an enum-like construct,
|
|
34
34
|
* e.g. value: ValueOf<typeof EnumLike> will only allow value to be a value
|
|
35
35
|
* defined in EnumLike.
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export type ValueOf<T> = T[keyof T];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -22,88 +22,88 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://canonical.github.io/react-components",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "7.
|
|
26
|
-
"@babel/eslint-parser": "7.
|
|
25
|
+
"@babel/cli": "7.20.7",
|
|
26
|
+
"@babel/eslint-parser": "7.19.1",
|
|
27
27
|
"@babel/preset-typescript": "7.18.6",
|
|
28
|
-
"@percy/cli": "1.
|
|
29
|
-
"@percy/storybook": "4.3.
|
|
30
|
-
"@storybook/addon-a11y": "6.5.
|
|
31
|
-
"@storybook/addon-controls": "6.5.
|
|
32
|
-
"@storybook/addon-docs": "6.
|
|
33
|
-
"@storybook/addons": "6.5.
|
|
34
|
-
"@storybook/builder-webpack5": "6.5.
|
|
35
|
-
"@storybook/manager-webpack5": "6.5.
|
|
36
|
-
"@storybook/react": "6.5.
|
|
37
|
-
"@storybook/theming": "6.5.
|
|
38
|
-
"@testing-library/cypress": "8.0.
|
|
39
|
-
"@testing-library/dom": "8.
|
|
40
|
-
"@testing-library/jest-dom": "5.16.
|
|
28
|
+
"@percy/cli": "1.18.0",
|
|
29
|
+
"@percy/storybook": "4.3.4",
|
|
30
|
+
"@storybook/addon-a11y": "6.5.16",
|
|
31
|
+
"@storybook/addon-controls": "6.5.16",
|
|
32
|
+
"@storybook/addon-docs": "6.5.16",
|
|
33
|
+
"@storybook/addons": "6.5.16",
|
|
34
|
+
"@storybook/builder-webpack5": "6.5.16",
|
|
35
|
+
"@storybook/manager-webpack5": "6.5.16",
|
|
36
|
+
"@storybook/react": "6.5.16",
|
|
37
|
+
"@storybook/theming": "6.5.16",
|
|
38
|
+
"@testing-library/cypress": "8.0.7",
|
|
39
|
+
"@testing-library/dom": "8.20.0",
|
|
40
|
+
"@testing-library/jest-dom": "5.16.5",
|
|
41
41
|
"@testing-library/react": "12.1.5",
|
|
42
42
|
"@testing-library/react-hooks": "8.0.1",
|
|
43
|
-
"@testing-library/user-event": "14.3
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
45
|
-
"@typescript-eslint/parser": "5.
|
|
43
|
+
"@testing-library/user-event": "14.4.3",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "5.51.0",
|
|
45
|
+
"@typescript-eslint/parser": "5.51.0",
|
|
46
46
|
"babel-jest": "27.5.1",
|
|
47
|
-
"babel-loader": "
|
|
48
|
-
"babel-plugin-module-resolver": "
|
|
47
|
+
"babel-loader": "9.1.2",
|
|
48
|
+
"babel-plugin-module-resolver": "5.0.0",
|
|
49
49
|
"babel-plugin-typescript-to-proptypes": "2.0.0",
|
|
50
|
-
"concurrently": "7.
|
|
51
|
-
"css-loader": "6.7.
|
|
50
|
+
"concurrently": "7.6.0",
|
|
51
|
+
"css-loader": "6.7.3",
|
|
52
52
|
"cypress": "9.7.0",
|
|
53
|
-
"deepmerge": "4.
|
|
54
|
-
"eslint": "8.
|
|
55
|
-
"eslint-config-prettier": "8.
|
|
53
|
+
"deepmerge": "4.3.0",
|
|
54
|
+
"eslint": "8.33.0",
|
|
55
|
+
"eslint-config-prettier": "8.6.0",
|
|
56
56
|
"eslint-config-react-app": "7.0.1",
|
|
57
57
|
"eslint-plugin-cypress": "2.12.1",
|
|
58
58
|
"eslint-plugin-flowtype": "8.0.3",
|
|
59
|
-
"eslint-plugin-import": "2.
|
|
60
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
59
|
+
"eslint-plugin-import": "2.27.5",
|
|
60
|
+
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
61
61
|
"eslint-plugin-prettier": "4.2.1",
|
|
62
|
-
"eslint-plugin-react": "7.
|
|
62
|
+
"eslint-plugin-react": "7.32.2",
|
|
63
63
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
64
|
-
"eslint-plugin-testing-library": "5.
|
|
64
|
+
"eslint-plugin-testing-library": "5.10.0",
|
|
65
65
|
"jest": "27.5.1",
|
|
66
66
|
"npm-package-json-lint": "5.4.2",
|
|
67
|
-
"prettier": "2.
|
|
67
|
+
"prettier": "2.8.4",
|
|
68
68
|
"react": "17.0.2",
|
|
69
69
|
"react-docgen-typescript-loader": "3.7.2",
|
|
70
70
|
"react-dom": "17.0.2",
|
|
71
|
-
"sass": "1.
|
|
72
|
-
"sass-loader": "10.
|
|
71
|
+
"sass": "1.58.0",
|
|
72
|
+
"sass-loader": "10.4.1",
|
|
73
73
|
"style-loader": "3.3.1",
|
|
74
|
-
"stylelint": "14.
|
|
75
|
-
"stylelint-config-prettier": "9.0.
|
|
74
|
+
"stylelint": "14.16.1",
|
|
75
|
+
"stylelint-config-prettier": "9.0.4",
|
|
76
76
|
"stylelint-config-recommended-scss": "5.0.2",
|
|
77
77
|
"stylelint-order": "5.0.0",
|
|
78
78
|
"stylelint-prettier": "2.0.0",
|
|
79
79
|
"ts-jest": "27.1.5",
|
|
80
|
-
"tsc-alias": "1.
|
|
81
|
-
"typescript": "4.
|
|
82
|
-
"vanilla-framework": "3.11.
|
|
80
|
+
"tsc-alias": "1.8.2",
|
|
81
|
+
"typescript": "4.9.5",
|
|
82
|
+
"vanilla-framework": "3.11.1",
|
|
83
83
|
"wait-on": "5.3.0",
|
|
84
|
-
"webpack": "5.
|
|
84
|
+
"webpack": "5.75.0"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@types/jest": "27.5.2",
|
|
88
|
-
"@types/node": "16.
|
|
89
|
-
"@types/react": "
|
|
90
|
-
"@types/react-dom": "17.0.
|
|
91
|
-
"@types/react-table": "7.7.
|
|
92
|
-
"classnames": "2.3.
|
|
88
|
+
"@types/node": "16.18.12",
|
|
89
|
+
"@types/react": "18.0.28",
|
|
90
|
+
"@types/react-dom": "17.0.18",
|
|
91
|
+
"@types/react-table": "7.7.14",
|
|
92
|
+
"classnames": "2.3.2",
|
|
93
93
|
"nanoid": "3.3.4",
|
|
94
94
|
"prop-types": "15.8.1",
|
|
95
95
|
"react-table": "7.8.0",
|
|
96
96
|
"react-useportal": "1.0.17"
|
|
97
97
|
},
|
|
98
98
|
"resolutions": {
|
|
99
|
-
"@types/react": "
|
|
100
|
-
"@types/react-dom": "17.0.
|
|
99
|
+
"@types/react": "18.0.28",
|
|
100
|
+
"@types/react-dom": "17.0.18",
|
|
101
101
|
"postcss": "^8.3.11"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^17.0.2 || ^18.0.0",
|
|
105
105
|
"react-dom": "^17.0.2 || ^18.0.0",
|
|
106
|
-
"vanilla-framework": "3.11.
|
|
106
|
+
"vanilla-framework": "3.11.1"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
|
109
109
|
"build": "rm -rf dist && yarn build-local; yarn build-declaration",
|