@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.
Files changed (174) hide show
  1. package/dist/components/Accordion/Accordion.d.ts +46 -0
  2. package/dist/components/Accordion/AccordionSection/AccordionSection.d.ts +34 -0
  3. package/dist/components/Accordion/AccordionSection/index.d.ts +2 -0
  4. package/dist/components/Accordion/index.d.ts +2 -0
  5. package/dist/components/ActionButton/ActionButton.d.ts +48 -0
  6. package/dist/components/ActionButton/index.d.ts +2 -0
  7. package/dist/components/ApplicationLayout/AppAside/AppAside.d.ts +33 -0
  8. package/dist/components/ApplicationLayout/AppAside/index.d.ts +2 -0
  9. package/dist/components/ApplicationLayout/AppMain/AppMain.d.ts +14 -0
  10. package/dist/components/ApplicationLayout/AppMain/index.d.ts +2 -0
  11. package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.d.ts +26 -0
  12. package/dist/components/ApplicationLayout/AppNavigation/index.d.ts +2 -0
  13. package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.d.ts +18 -0
  14. package/dist/components/ApplicationLayout/AppNavigationBar/index.d.ts +2 -0
  15. package/dist/components/ApplicationLayout/AppStatus/AppStatus.d.ts +14 -0
  16. package/dist/components/ApplicationLayout/AppStatus/index.d.ts +2 -0
  17. package/dist/components/ApplicationLayout/Application/Application.d.ts +15 -0
  18. package/dist/components/ApplicationLayout/Application/index.d.ts +2 -0
  19. package/dist/components/ApplicationLayout/ApplicationLayout.d.ts +89 -0
  20. package/dist/components/ApplicationLayout/index.d.ts +7 -0
  21. package/dist/components/ArticlePagination/ArticlePagination.d.ts +31 -0
  22. package/dist/components/ArticlePagination/index.d.ts +2 -0
  23. package/dist/components/Badge/Badge.d.ts +34 -0
  24. package/dist/components/Badge/index.d.ts +2 -0
  25. package/dist/components/Button/Button.d.ts +64 -0
  26. package/dist/components/Button/index.d.ts +2 -0
  27. package/dist/components/Card/Card.d.ts +35 -0
  28. package/dist/components/Card/index.d.ts +2 -0
  29. package/dist/components/CheckboxInput/CheckableInput/CheckableInput.d.ts +27 -0
  30. package/dist/components/CheckboxInput/CheckableInput/index.d.ts +2 -0
  31. package/dist/components/CheckboxInput/CheckboxInput.d.ts +9 -0
  32. package/dist/components/CheckboxInput/index.d.ts +2 -0
  33. package/dist/components/Chip/Chip.d.ts +56 -0
  34. package/dist/components/Chip/index.d.ts +2 -0
  35. package/dist/components/Code/Code.d.ts +13 -0
  36. package/dist/components/Code/index.d.ts +2 -0
  37. package/dist/components/CodeSnippet/CodeSnippet.d.ts +21 -0
  38. package/dist/components/CodeSnippet/CodeSnippetBlock.d.ts +40 -0
  39. package/dist/components/CodeSnippet/CodeSnippetDropdown.d.ts +18 -0
  40. package/dist/components/CodeSnippet/index.d.ts +5 -0
  41. package/dist/components/Col/Col.d.ts +53 -0
  42. package/dist/components/Col/index.d.ts +2 -0
  43. package/dist/components/ConfirmationButton/ConfirmationButton.d.ts +28 -0
  44. package/dist/components/ConfirmationButton/index.d.ts +2 -0
  45. package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +53 -0
  46. package/dist/components/ConfirmationModal/index.d.ts +2 -0
  47. package/dist/components/ContextualMenu/ContextualMenu.d.ts +110 -0
  48. package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +43 -0
  49. package/dist/components/ContextualMenu/ContextualMenuDropdown/index.d.ts +2 -0
  50. package/dist/components/ContextualMenu/index.d.ts +3 -0
  51. package/dist/components/EmptyState/EmptyState.d.ts +25 -0
  52. package/dist/components/EmptyState/index.d.ts +2 -0
  53. package/dist/components/Field/Field.d.ts +77 -0
  54. package/dist/components/Field/index.d.ts +2 -0
  55. package/dist/components/Form/Form.d.ts +21 -0
  56. package/dist/components/Form/index.d.ts +2 -0
  57. package/dist/components/FormikField/FormikField.d.ts +25 -0
  58. package/dist/components/FormikField/index.d.ts +1 -0
  59. package/dist/components/Icon/Icon.d.ts +59 -0
  60. package/dist/components/Icon/index.d.ts +2 -0
  61. package/dist/components/Input/Input.d.ts +70 -0
  62. package/dist/components/Input/index.d.ts +2 -0
  63. package/dist/components/Label/Label.d.ts +25 -0
  64. package/dist/components/Label/index.d.ts +2 -0
  65. package/dist/components/Link/Link.d.ts +31 -0
  66. package/dist/components/Link/index.d.ts +2 -0
  67. package/dist/components/List/List.d.ts +36 -0
  68. package/dist/components/List/index.d.ts +2 -0
  69. package/dist/components/Loader/Loader.d.ts +6 -0
  70. package/dist/components/Loader/index.d.ts +1 -0
  71. package/dist/components/LoginPageLayout/LoginPageLayout.d.ts +17 -0
  72. package/dist/components/LoginPageLayout/index.d.ts +2 -0
  73. package/dist/components/MainTable/MainTable.d.ts +102 -0
  74. package/dist/components/MainTable/index.d.ts +2 -0
  75. package/dist/components/Modal/Modal.d.ts +36 -0
  76. package/dist/components/Modal/index.d.ts +2 -0
  77. package/dist/components/ModularTable/ModularTable.d.ts +105 -0
  78. package/dist/components/ModularTable/index.d.ts +2 -0
  79. package/dist/components/MultiSelect/FadeInDown/FadeInDown.d.ts +10 -0
  80. package/dist/components/MultiSelect/FadeInDown/index.d.ts +1 -0
  81. package/dist/components/MultiSelect/MultiSelect.d.ts +57 -0
  82. package/dist/components/MultiSelect/index.d.ts +1 -0
  83. package/dist/components/Navigation/Navigation.d.ts +66 -0
  84. package/dist/components/Navigation/NavigationLink/NavigationLink.d.ts +10 -0
  85. package/dist/components/Navigation/NavigationLink/index.d.ts +1 -0
  86. package/dist/components/Navigation/NavigationMenu/NavigationMenu.d.ts +11 -0
  87. package/dist/components/Navigation/NavigationMenu/index.d.ts +1 -0
  88. package/dist/components/Navigation/index.d.ts +3 -0
  89. package/dist/components/Navigation/types.d.ts +64 -0
  90. package/dist/components/Notification/Notification.d.ts +110 -0
  91. package/dist/components/Notification/index.d.ts +2 -0
  92. package/dist/components/NotificationProvider/NotificationProvider.d.ts +5 -0
  93. package/dist/components/NotificationProvider/index.d.ts +3 -0
  94. package/dist/components/NotificationProvider/messageBuilder.d.ts +6 -0
  95. package/dist/components/NotificationProvider/types.d.ts +35 -0
  96. package/dist/components/Pagination/Pagination.d.ts +102 -0
  97. package/dist/components/Pagination/PaginationButton/PaginationButton.d.ts +30 -0
  98. package/dist/components/Pagination/PaginationButton/index.d.ts +2 -0
  99. package/dist/components/Pagination/PaginationItem/PaginationItem.d.ts +17 -0
  100. package/dist/components/Pagination/PaginationItem/index.d.ts +2 -0
  101. package/dist/components/Pagination/index.d.ts +2 -0
  102. package/dist/components/Panel/Panel.d.ts +123 -0
  103. package/dist/components/Panel/index.d.ts +1 -0
  104. package/dist/components/PasswordToggle/PasswordToggle.d.ts +108 -0
  105. package/dist/components/PasswordToggle/index.d.ts +2 -0
  106. package/dist/components/RadioInput/RadioInput.d.ts +9 -0
  107. package/dist/components/RadioInput/index.d.ts +2 -0
  108. package/dist/components/Row/Row.d.ts +19 -0
  109. package/dist/components/Row/index.d.ts +2 -0
  110. package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.d.ts +25 -0
  111. package/dist/components/SearchAndFilter/FilterPanelSection/index.d.ts +1 -0
  112. package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +33 -0
  113. package/dist/components/SearchAndFilter/index.d.ts +2 -0
  114. package/dist/components/SearchAndFilter/types.d.ts +11 -0
  115. package/dist/components/SearchAndFilter/utils.d.ts +13 -0
  116. package/dist/components/SearchBox/SearchBox.d.ts +63 -0
  117. package/dist/components/SearchBox/index.d.ts +2 -0
  118. package/dist/components/Select/Select.d.ts +71 -0
  119. package/dist/components/Select/index.d.ts +2 -0
  120. package/dist/components/SideNavigation/SideNavigation.d.ts +50 -0
  121. package/dist/components/SideNavigation/SideNavigationBase/SideNavigationBase.d.ts +31 -0
  122. package/dist/components/SideNavigation/SideNavigationBase/index.d.ts +1 -0
  123. package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.d.ts +20 -0
  124. package/dist/components/SideNavigation/SideNavigationItem/index.d.ts +1 -0
  125. package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.d.ts +18 -0
  126. package/dist/components/SideNavigation/SideNavigationLink/index.d.ts +1 -0
  127. package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.d.ts +7 -0
  128. package/dist/components/SideNavigation/SideNavigationText/index.d.ts +1 -0
  129. package/dist/components/SideNavigation/index.d.ts +5 -0
  130. package/dist/components/Slider/Slider.d.ts +62 -0
  131. package/dist/components/Slider/index.d.ts +2 -0
  132. package/dist/components/Spinner/Spinner.d.ts +29 -0
  133. package/dist/components/Spinner/index.d.ts +2 -0
  134. package/dist/components/StatusLabel/StatusLabel.d.ts +33 -0
  135. package/dist/components/StatusLabel/index.d.ts +2 -0
  136. package/dist/components/Strip/Strip.d.ts +64 -0
  137. package/dist/components/Strip/index.d.ts +2 -0
  138. package/dist/components/SummaryButton/SummaryButton.d.ts +29 -0
  139. package/dist/components/SummaryButton/index.d.ts +2 -0
  140. package/dist/components/Switch/Switch.d.ts +17 -0
  141. package/dist/components/Switch/index.d.ts +2 -0
  142. package/dist/components/Table/Table.d.ts +22 -0
  143. package/dist/components/Table/index.d.ts +2 -0
  144. package/dist/components/TableCell/TableCell.d.ts +26 -0
  145. package/dist/components/TableCell/index.d.ts +2 -0
  146. package/dist/components/TableHeader/TableHeader.d.ts +14 -0
  147. package/dist/components/TableHeader/index.d.ts +2 -0
  148. package/dist/components/TablePagination/TablePagination.d.ts +98 -0
  149. package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.d.ts +24 -0
  150. package/dist/components/TablePagination/TablePaginationControls/index.d.ts +2 -0
  151. package/dist/components/TablePagination/index.d.ts +2 -0
  152. package/dist/components/TablePagination/utils.d.ts +27 -0
  153. package/dist/components/TableRow/TableRow.d.ts +10 -0
  154. package/dist/components/TableRow/index.d.ts +2 -0
  155. package/dist/components/Tabs/Tabs.d.ts +45 -0
  156. package/dist/components/Tabs/index.d.ts +2 -0
  157. package/dist/components/Textarea/Textarea.d.ts +70 -0
  158. package/dist/components/Textarea/index.d.ts +2 -0
  159. package/dist/components/Tooltip/Tooltip.d.ts +75 -0
  160. package/dist/components/Tooltip/index.d.ts +2 -0
  161. package/dist/enums.d.ts +13 -0
  162. package/dist/hooks/index.d.ts +9 -0
  163. package/dist/hooks/useId.d.ts +4 -0
  164. package/dist/hooks/useListener.d.ts +11 -0
  165. package/dist/hooks/useOnClickOutside.d.ts +12 -0
  166. package/dist/hooks/useOnEscapePressed.d.ts +6 -0
  167. package/dist/hooks/usePagination.d.ts +19 -0
  168. package/dist/hooks/usePrevious.d.ts +7 -0
  169. package/dist/hooks/useThrottle.d.ts +9 -0
  170. package/dist/hooks/useWindowFitment.d.ts +54 -0
  171. package/dist/index.d.ts +132 -0
  172. package/dist/types/index.d.ts +38 -0
  173. package/dist/utils.d.ts +27 -0
  174. package/package.json +9 -10
@@ -0,0 +1,59 @@
1
+ import type { HTMLProps } from "react";
2
+ import type { ClassName, PropsWithSpread, ValueOf } from "../../types";
3
+ export declare const ICONS: {
4
+ readonly anchor: "anchor";
5
+ readonly chevronDown: "chevron-down";
6
+ readonly chevronUp: "chevron-up";
7
+ readonly close: "close";
8
+ readonly code: "code";
9
+ readonly collapse: "collapse";
10
+ readonly copy: "copy";
11
+ readonly delete: "delete";
12
+ readonly drag: "drag";
13
+ readonly error: "error";
14
+ readonly expand: "expand";
15
+ readonly externalLink: "external-link";
16
+ readonly help: "help";
17
+ readonly information: "information";
18
+ readonly menu: "menu";
19
+ readonly minus: "minus";
20
+ readonly plus: "plus";
21
+ readonly search: "search";
22
+ readonly share: "share";
23
+ readonly spinner: "spinner";
24
+ readonly success: "success";
25
+ readonly user: "user";
26
+ readonly warning: "warning";
27
+ readonly facebook: "facebook";
28
+ readonly twitter: "twitter";
29
+ readonly instagram: "instagram";
30
+ readonly linkedin: "linkedin";
31
+ readonly youtube: "youtube";
32
+ readonly github: "github";
33
+ readonly rss: "rss";
34
+ readonly email: "email";
35
+ };
36
+ export type Props = PropsWithSpread<{
37
+ /**
38
+ * Optional classes to add to the icon element.
39
+ */
40
+ className?: ClassName;
41
+ /**
42
+ * Whether to show the light variant of the icon.
43
+ */
44
+ light?: boolean;
45
+ /**
46
+ * The name of the icon.
47
+ */
48
+ name: ValueOf<typeof ICONS> | string;
49
+ }, HTMLProps<HTMLElement>>;
50
+ /**
51
+ * This is a [React](https://reactjs.org/) component for the Vanilla [Icon](https://docs.vanillaframework.io/patterns/icons/).
52
+ *
53
+ * Icons provide visual context and enhance usability.
54
+ *
55
+ * @param name One of built-in Vanilla icons or a name of a custom icon that follows `p-icon--{name}` convention.
56
+ * @returns Icon
57
+ */
58
+ declare const Icon: ({ className, light, name, ...props }: Props) => JSX.Element;
59
+ export default Icon;
@@ -0,0 +1,2 @@
1
+ export { default, ICONS } from "./Icon";
2
+ export type { Props as IconProps } from "./Icon";
@@ -0,0 +1,70 @@
1
+ import type { InputHTMLAttributes, ReactNode } from "react";
2
+ import type { ClassName, PropsWithSpread } from "../../types";
3
+ /**
4
+ * The props for the Input component.
5
+ */
6
+ export type Props = PropsWithSpread<{
7
+ /**
8
+ * The content for caution validation.
9
+ */
10
+ caution?: ReactNode;
11
+ /**
12
+ * Optional class(es) to pass to the input element.
13
+ */
14
+ className?: ClassName;
15
+ /**
16
+ * The content for error validation message. Controls the value of aria-invalid attribute.
17
+ */
18
+ error?: ReactNode;
19
+ /**
20
+ * Help text to show below the field.
21
+ */
22
+ help?: ReactNode;
23
+ /**
24
+ * Optional class(es) to pass to the help text element.
25
+ */
26
+ helpClassName?: ReactNode;
27
+ /**
28
+ * The id of the input.
29
+ */
30
+ id?: string;
31
+ /**
32
+ * The label for the field.
33
+ */
34
+ label?: ReactNode;
35
+ /**
36
+ * Optional class(es) to pass to the label component.
37
+ */
38
+ labelClassName?: string;
39
+ /**
40
+ * Whether the field is required.
41
+ */
42
+ required?: boolean;
43
+ /**
44
+ * Whether the form field should have a stacked appearance.
45
+ */
46
+ stacked?: boolean;
47
+ /**
48
+ * The content for success validation.
49
+ */
50
+ success?: ReactNode;
51
+ /**
52
+ * Whether to focus on the input on initial render.
53
+ */
54
+ takeFocus?: boolean;
55
+ /**
56
+ * Delay takeFocus in milliseconds i.e. to let animations finish
57
+ */
58
+ takeFocusDelay?: number;
59
+ /**
60
+ * Optional class(es) to pass to the wrapping Field component
61
+ */
62
+ wrapperClassName?: string;
63
+ }, InputHTMLAttributes<HTMLInputElement>>;
64
+ /**
65
+ * This is a [React](https://reactjs.org/) component for the Vanilla [Input](https://docs.vanillaframework.io/base/forms/#input).
66
+ *
67
+ * An input field where the user can enter data, which can vary in many ways, depending on the type attribute.
68
+ */
69
+ declare const Input: ({ caution, className, error, help, helpClassName, id, label, labelClassName, required, stacked, success, takeFocus, takeFocusDelay, type, wrapperClassName, ...inputProps }: Props) => JSX.Element;
70
+ export default Input;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Input";
2
+ export type { Props as InputProps } from "./Input";
@@ -0,0 +1,25 @@
1
+ import type { LabelHTMLAttributes, ReactNode } from "react";
2
+ import type { ClassName, PropsWithSpread } from "../../types";
3
+ /**
4
+ * The props for the Label component.
5
+ */
6
+ export type Props = PropsWithSpread<{
7
+ /**
8
+ * The label content.
9
+ */
10
+ children?: ReactNode;
11
+ /**
12
+ * Optional class(es) to give to the label element.
13
+ */
14
+ className?: ClassName;
15
+ /**
16
+ * The id of the input this label is connected to.
17
+ */
18
+ forId?: string;
19
+ /**
20
+ * Whether to apply required styling to the label.
21
+ */
22
+ required?: boolean;
23
+ }, LabelHTMLAttributes<HTMLLabelElement>>;
24
+ declare const Label: ({ children, className, forId, required, ...props }: Props) => JSX.Element;
25
+ export default Label;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Label";
2
+ export type { Props as LabelProps } from "./Label";
@@ -0,0 +1,31 @@
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 link.
6
+ */
7
+ children: ReactNode;
8
+ /**
9
+ * Optional class(es) to pass to the wrapping anchor element.
10
+ */
11
+ className?: ClassName;
12
+ /**
13
+ * Whether the link should have inverted styling.
14
+ */
15
+ inverted?: boolean;
16
+ /**
17
+ * Whether the link should have soft styling.
18
+ */
19
+ soft?: boolean;
20
+ /**
21
+ * Whether the link should have "back to top" styling.
22
+ */
23
+ top?: boolean;
24
+ }, HTMLProps<HTMLAnchorElement>>;
25
+ /**
26
+ * This is a [React](https://reactjs.org/) component for the Vanilla [Link](https://docs.vanillaframework.io/patterns/links/).
27
+ *
28
+ * Links are used to embed actions or pathways to more information, allowing users to click their way from page to page.
29
+ */
30
+ declare const Link: ({ children, className, href, inverted, soft, top, ...props }: Props) => JSX.Element;
31
+ export default Link;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Link";
2
+ export type { Props as LinkProps } from "./Link";
@@ -0,0 +1,36 @@
1
+ import type { HTMLProps, ReactNode } from "react";
2
+ import { ClassName, Headings, PropsWithSpread } from "../../types";
3
+ export type ListItem = ReactNode | PropsWithSpread<{
4
+ content: ReactNode;
5
+ }, HTMLProps<HTMLLIElement>>;
6
+ export type SteppedListItem = PropsWithSpread<{
7
+ content: ReactNode;
8
+ title: ReactNode;
9
+ titleElement?: Headings;
10
+ }, HTMLProps<HTMLLIElement>>;
11
+ export type Props = {
12
+ /**
13
+ * Optional class(es) to pass to the wrapping element.
14
+ */
15
+ className?: ClassName;
16
+ /**
17
+ * The list's items.
18
+ */
19
+ items: ListItem[] | SteppedListItem[];
20
+ detailed?: boolean;
21
+ divided?: boolean;
22
+ inline?: boolean;
23
+ isDark?: boolean;
24
+ middot?: boolean;
25
+ split?: boolean;
26
+ stepped?: boolean;
27
+ stretch?: boolean;
28
+ ticked?: boolean;
29
+ } & Omit<HTMLProps<HTMLOListElement>, "type">;
30
+ /**
31
+ * This is a [React](https://reactjs.org/) component for the Vanilla [List](https://docs.vanillaframework.io/patterns/lists/).
32
+ *
33
+ * If you want to display lists in a way that is more visually distinctive than the standard `<ol>` and `<ul>`, we have 7 list styles at your disposal.
34
+ */
35
+ declare const List: ({ className, detailed, divided, inline, isDark, items, middot, stretch, split, stepped, ticked, ...props }: Props) => JSX.Element;
36
+ export default List;
@@ -0,0 +1,2 @@
1
+ export { default } from "./List";
2
+ export type { Props as ListProps } from "./List";
@@ -0,0 +1,6 @@
1
+ import type { SpinnerProps } from "../Spinner";
2
+ /**
3
+ * @deprecated Loader component is deprecated. Use Spinner component instead.
4
+ */
5
+ declare const Loader: (props: SpinnerProps) => JSX.Element;
6
+ export default Loader;
@@ -0,0 +1 @@
1
+ export { default } from "./Loader";
@@ -0,0 +1,17 @@
1
+ import { FC, ReactNode } from "react";
2
+ import "./LoginPageLayout.scss";
3
+ export type Props = {
4
+ title: string;
5
+ children?: ReactNode;
6
+ logo?: {
7
+ src: string;
8
+ title: string;
9
+ url: string;
10
+ };
11
+ };
12
+ /**
13
+ * This is a layout component that is used to display a page with a title and children.
14
+ * The LoginPageLayout recommended usages are in the login flow like registration, sign up and error pages.
15
+ */
16
+ declare const LoginPageLayout: FC<Props>;
17
+ export default LoginPageLayout;
@@ -0,0 +1,2 @@
1
+ export { default } from "./LoginPageLayout";
2
+ export type { Props as LoginPageLayoutProps } from "./LoginPageLayout";
@@ -0,0 +1,102 @@
1
+ import type { HTMLProps, ReactNode } from "react";
2
+ import type { ClassName, PropsWithSpread, SortDirection } from "../../types";
3
+ import type { TableProps } from "../Table";
4
+ import type { TableCellProps } from "../TableCell";
5
+ export type MainTableHeader = PropsWithSpread<{
6
+ /**
7
+ * The content of the table header.
8
+ */
9
+ content?: ReactNode;
10
+ /**
11
+ * Optional classes to apply to the table header.
12
+ */
13
+ className?: ClassName;
14
+ /**
15
+ * A key to sort the rows by. It should match a key given to the row `sortData`.
16
+ */
17
+ sortKey?: string | null;
18
+ /**
19
+ * Replacement value for data-heading if content is not a string.
20
+ */
21
+ heading?: string;
22
+ }, HTMLProps<HTMLTableHeaderCellElement>>;
23
+ export type MainTableCell = PropsWithSpread<{
24
+ /**
25
+ * The content of the table cell.
26
+ */
27
+ content?: ReactNode;
28
+ }, Omit<TableCellProps, "children">>;
29
+ export type MainTableRow = PropsWithSpread<{
30
+ /**
31
+ * Optional class(es) to apply to the row.
32
+ */
33
+ className?: ClassName;
34
+ /**
35
+ * The columns in this row.
36
+ */
37
+ columns?: MainTableCell[];
38
+ /**
39
+ * Whether this row should display as expanded.
40
+ */
41
+ expanded?: boolean;
42
+ /**
43
+ * The content to display when this column is expanded.
44
+ */
45
+ expandedContent?: ReactNode;
46
+ /**
47
+ * An optional key to identify this table row.
48
+ */
49
+ key?: number | string | null;
50
+ /**
51
+ * An object of data for use when sorting the rows. The keys of this object
52
+ * should match the header sort keys.
53
+ */
54
+ sortData?: Record<string, unknown>;
55
+ }, HTMLProps<HTMLTableRowElement>>;
56
+ export type Props = PropsWithSpread<{
57
+ /**
58
+ * The default key to sort the rows by.
59
+ */
60
+ defaultSort?: MainTableHeader["sortKey"];
61
+ /**
62
+ * The default direction the row data should be sorted by.
63
+ */
64
+ defaultSortDirection?: SortDirection;
65
+ /**
66
+ * A message to display when there are no table rows.
67
+ */
68
+ emptyStateMsg?: ReactNode;
69
+ /**
70
+ * The header columns for this table.
71
+ */
72
+ headers?: MainTableHeader[];
73
+ /**
74
+ * A function that is called when the sort key is changed.
75
+ */
76
+ onUpdateSort?: (sortKey: MainTableHeader["sortKey"]) => void;
77
+ /**
78
+ * A number of rows to paginate by.
79
+ */
80
+ paginate?: number | null;
81
+ /**
82
+ * The rows to display in the table.
83
+ */
84
+ rows?: MainTableRow[];
85
+ /**
86
+ * Whether this table should be sortable.
87
+ */
88
+ sortable?: boolean;
89
+ /**
90
+ * A function to be used when sorting.
91
+ */
92
+ sortFunction?: (a: MainTableRow, b: MainTableRow, currentSortDirection: SortDirection, currentSortKey: MainTableHeader["sortKey"]) => -1 | 0 | 1;
93
+ /**
94
+ * A hidden caption to display on the table for screen readers
95
+ */
96
+ hiddenCaption?: string | null;
97
+ }, TableProps>;
98
+ /**
99
+ * This is a [React](https://reactjs.org/) component to support many table use cases.
100
+ */
101
+ declare const MainTable: ({ defaultSort, defaultSortDirection, emptyStateMsg, expanding, headers, onUpdateSort, paginate, rows, responsive, sortable, sortFunction, hiddenCaption, ...props }: Props) => JSX.Element;
102
+ export default MainTable;
@@ -0,0 +1,2 @@
1
+ export { default } from "./MainTable";
2
+ export type { Props as MainTableProps } from "./MainTable";
@@ -0,0 +1,36 @@
1
+ import { ReactElement } from "react";
2
+ import type { HTMLProps, ReactNode } from "react";
3
+ import { ClassName, PropsWithSpread } from "../../types";
4
+ export type Props = PropsWithSpread<{
5
+ /**
6
+ * Buttons to display underneath the main modal content.
7
+ */
8
+ buttonRow?: ReactNode | null;
9
+ /**
10
+ * Optional class(es) to apply to the wrapping element.
11
+ */
12
+ className?: ClassName;
13
+ /**
14
+ * The content of the modal.
15
+ */
16
+ children: ReactNode;
17
+ /**
18
+ * Function to handle closing the modal.
19
+ */
20
+ close?: () => void | null;
21
+ /**
22
+ * The title of the modal.
23
+ */
24
+ title?: ReactNode | null;
25
+ /**
26
+ * Whether the button click event should propagate.
27
+ */
28
+ shouldPropagateClickEvent?: boolean;
29
+ }, HTMLProps<HTMLDivElement>>;
30
+ /**
31
+ * This is a [React](https://reactjs.org/) component for the Vanilla [Modal](https://docs.vanillaframework.io/patterns/modal/).
32
+ *
33
+ * The modal component can be used to overlay an area of the screen which can contain a prompt, dialog or interaction.
34
+ */
35
+ export declare const Modal: ({ buttonRow, children, className, close, title, shouldPropagateClickEvent, ...wrapperProps }: Props) => ReactElement;
36
+ export default Modal;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Modal";
2
+ export type { Props as ModalProps } from "./Modal";
@@ -0,0 +1,105 @@
1
+ import { ReactNode, HTMLProps } from "react";
2
+ import { TableCellProps, TableHeaderProps, TableRowProps } from "react-table";
3
+ import type { Column, UseTableOptions, Cell, Row, HeaderGroup } from "react-table";
4
+ import { PropsWithSpread } from "../../types";
5
+ export type Props<D extends Record<string, unknown>> = PropsWithSpread<{
6
+ /**
7
+ * The columns of the table.
8
+ */
9
+ columns: Column<D>[];
10
+ /**
11
+ * The data of the table.
12
+ */
13
+ data: D[];
14
+ /**
15
+ * A message to display if data is empty.
16
+ */
17
+ emptyMsg?: string;
18
+ /**
19
+ * Optional extra row to display underneath the main table content.
20
+ */
21
+ footer?: ReactNode;
22
+ /**
23
+ * Optional argument to make the tables be sortable and use the `useSortBy` plugin.
24
+ */
25
+ sortable?: boolean;
26
+ /**
27
+ * This function is used to resolve any props needed for a particular column's header cell.
28
+ */
29
+ getHeaderProps?: (header: HeaderGroup<D>) => Partial<TableHeaderProps & HTMLProps<HTMLTableHeaderCellElement>>;
30
+ /**
31
+ * This function is used to resolve any props needed for a particular row.
32
+ */
33
+ getRowProps?: (row: Row<D>) => Partial<TableRowProps & HTMLProps<HTMLTableRowElement>>;
34
+ /**
35
+ * This function is used to resolve any props needed for a particular cell.
36
+ */
37
+ getCellProps?: (cell: Cell<D>) => Partial<TableCellProps & HTMLProps<HTMLTableCellElement>>;
38
+ getRowId?: UseTableOptions<D>["getRowId"];
39
+ /**
40
+ * The column that the table will be sorted by (this should match a cell selector).
41
+ */
42
+ initialSortColumn?: string;
43
+ /**
44
+ * The direction of the initial sort.
45
+ */
46
+ initialSortDirection?: "ascending" | "descending";
47
+ /**
48
+ * Whether the sort by needs to be reset after each data change.
49
+ */
50
+ autoResetSortBy?: boolean;
51
+ }, HTMLProps<HTMLTableElement>>;
52
+ /**
53
+ This is a [React](https://reactjs.org/) component to support many table use cases.
54
+
55
+ ModularTable components accepts `columns` and `data` arguments in the same format as [`useTable`](https://react-table.tanstack.com/docs/api/useTable) hook of the ReactTable library.
56
+
57
+ `columns` - The core columns configuration object for the entire table. https://react-table.tanstack.com/docs/api/useTable#column-options
58
+ `data` - The data array that you want to display on the table.
59
+ ### Important note!
60
+ Values passed to both of these params have to me memoized (for example via{" "}
61
+ <code>React.useMemo</code>). Memoization ensures that our data isn't recreated
62
+ on every render. If we didn't use <code>React.useMemo</code>, the table would
63
+ think it was receiving new data on every render and attempt to recalulate a
64
+ lot of logic every single time.
65
+
66
+ #### Custom column options
67
+
68
+ In addition to standard column propeties from [`useTable`](https://react-table.tanstack.com/docs/api/useTable) `ModularTable` accepts some custom properties.
69
+
70
+ ##### Class names
71
+
72
+ Custom `className` can be used to provide a specific CSS class name that will be added to all cells in given column.
73
+ You can also provide `getHeaderProps`, `getRowProps` and `getCellProps` to resolve additional custom props for a specific element. More on this in [`useTable - cell properties`](https://react-table.tanstack.com/docs/api/useTable#cell-properties).
74
+
75
+ ```js
76
+ getCellProps={({ value, column }) => ({
77
+ className: `table__cell--${column.id} ${value === "1 minute" ? "p-heading--5" : ""}`,
78
+ })}
79
+ columns = {
80
+ Header: "Hidden on mobile",
81
+ accessor: "example",
82
+ className: "u-hide--small"
83
+ }
84
+ ```
85
+
86
+ ##### Icons
87
+
88
+ To show an icon in the cells of a column `getCellIcon` function should be defined. The function takes a cell data as an argument and should return one of built in icons (from the `ICONS` const), a string with a custom icon name, or `false` if no icon should be shown.
89
+
90
+ The `ICONS` const contains all [the Vanilla built in icons](https://vanillaframework.io/docs/patterns/icons) such as "plus", "minus", "success", "error", etc.
91
+
92
+ Product specific icons can be used as well, assuming that the product provides the necessary CSS styling and the icon follows the Vanilla naming convention `p-icon--{name}`.
93
+
94
+ ```js
95
+ columns = {
96
+ Header: "With icons",
97
+ accessor: "status",
98
+ getCellIcon: ({ value }) => {
99
+ return value === "released" ? ICONS.success : false;
100
+ },
101
+ };
102
+ ```
103
+ */
104
+ declare function ModularTable<D extends Record<string, unknown>>({ data, columns, emptyMsg, footer, sortable, getHeaderProps, getRowProps, getCellProps, getRowId, initialSortColumn, initialSortDirection, autoResetSortBy, ...props }: Props<D>): JSX.Element;
105
+ export default ModularTable;
@@ -0,0 +1,2 @@
1
+ export { default } from "./ModularTable";
2
+ export type { Props as ModularTableProps } from "./ModularTable";
@@ -0,0 +1,10 @@
1
+ import { FC, PropsWithChildren } from "react";
2
+ import "./FadeInDown.scss";
3
+ export interface FadeInDownProps extends PropsWithChildren {
4
+ isVisible: boolean;
5
+ className?: string;
6
+ }
7
+ /**
8
+ * EXPERIMENTAL: This component is experimental and should be used internally only.
9
+ */
10
+ export declare const FadeInDown: FC<FadeInDownProps>;
@@ -0,0 +1 @@
1
+ export * from "./FadeInDown";
@@ -0,0 +1,57 @@
1
+ import type { ReactNode } from "react";
2
+ import React from "react";
3
+ import "./MultiSelect.scss";
4
+ export type MultiSelectItem = {
5
+ label: string;
6
+ value: string | number;
7
+ group?: string;
8
+ };
9
+ export type MultiSelectProps = {
10
+ disabled?: boolean;
11
+ error?: string;
12
+ selectedItems?: MultiSelectItem[];
13
+ help?: string;
14
+ label?: string | null;
15
+ listSelected?: boolean;
16
+ onDeselectItem?: (item: MultiSelectItem) => void;
17
+ onItemsUpdate?: (items: MultiSelectItem[]) => void;
18
+ onSelectItem?: (item: MultiSelectItem) => void;
19
+ placeholder?: string;
20
+ required?: boolean;
21
+ items: MultiSelectItem[];
22
+ disabledItems?: MultiSelectItem[];
23
+ renderItem?: (item: MultiSelectItem) => ReactNode;
24
+ dropdownHeader?: ReactNode;
25
+ dropdownFooter?: ReactNode;
26
+ showDropdownFooter?: boolean;
27
+ variant?: "condensed" | "search";
28
+ };
29
+ type GroupFn = (items: Parameters<typeof getGroupedItems>[0]) => ReturnType<typeof getGroupedItems>;
30
+ type SortFn = typeof sortAlphabetically;
31
+ type MultiSelectDropdownProps = {
32
+ isOpen: boolean;
33
+ items: MultiSelectItem[];
34
+ selectedItems: MultiSelectItem[];
35
+ disabledItems: MultiSelectItem[];
36
+ header?: ReactNode;
37
+ updateItems: (newItems: MultiSelectItem[]) => void;
38
+ onDeselectItem?: (item: MultiSelectItem) => void;
39
+ onSelectItem?: (item: MultiSelectItem) => void;
40
+ footer?: ReactNode;
41
+ groupFn?: GroupFn;
42
+ sortFn?: SortFn;
43
+ } & React.HTMLAttributes<HTMLDivElement>;
44
+ declare const sortAlphabetically: (a: MultiSelectItem, b: MultiSelectItem) => number;
45
+ declare const getGroupedItems: (items: MultiSelectItem[]) => {
46
+ group: string;
47
+ items: MultiSelectItem[];
48
+ }[];
49
+ export declare const MultiSelectDropdown: React.FC<MultiSelectDropdownProps>;
50
+ /**
51
+ * Component allowing to select multiple items from a list of options.
52
+ *
53
+ * `MultiSelectDropdown` displays the dropdown with options which are grouped and sorted alphabetically.
54
+ * `SearchBox` or `Button` is used to trigger the dropdown depending on the variant.
55
+ */
56
+ export declare const MultiSelect: React.FC<MultiSelectProps>;
57
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./MultiSelect";