@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,11 @@
1
+ /**
2
+ * A hook that handles attaching/removing listeners and smartly reattaching if
3
+ * any of the attributes change.
4
+ * @param targetNode The node to attach the listener to.
5
+ * @param callback The function to call from the listener.
6
+ * @param eventType The event name.
7
+ * @param shouldThrottle Whether the callback calls should be throttled.
8
+ * @param shouldListen When the listener should be active.
9
+ * @param options Native event listener options.
10
+ */
11
+ export declare const useListener: (targetNode: Window | HTMLElement, callback: (...args: any[]) => any, eventType: string, shouldThrottle?: boolean, shouldListen?: boolean, options?: boolean | AddEventListenerOptions) => void;
@@ -0,0 +1,12 @@
1
+ import { MutableRefObject, useRef } from "react";
2
+ /**
3
+ * Handle clicks outside an element.
4
+ */
5
+ export declare const useOnClickOutside: <E extends HTMLElement>(elementRef: ReturnType<typeof useRef<E | null>>, onClickOutside: () => void, { isEnabled }?: {
6
+ isEnabled: boolean;
7
+ }) => void;
8
+ /**
9
+ * Handle clicks outside an element.
10
+ * @returns A ref to pass to the element to handle clicks outside of.
11
+ */
12
+ export declare const useClickOutside: <E extends HTMLElement>(onClickOutside: () => void) => MutableRefObject<E>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Handle the escape key pressed.
3
+ */
4
+ export declare const useOnEscapePressed: (onEscape: () => void, { isEnabled }?: {
5
+ isEnabled: boolean;
6
+ }) => void;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A hook that handles pagination.
3
+ * @param data - The data array to paginate.
4
+ * @param {Object} options
5
+ * @param {number} [options.itemsPerPage] - Number of items per page. Returns all items if no value has been provided.
6
+ * @param {number} [options.initialPage=1] - Initial page number. Defaults to 1.
7
+ * @param {boolean} [options.autoResetPage=false] - Whether to reset the page number to 1 when the data changes.
8
+ */
9
+ export declare function usePagination<D, I = number | null>(data: Array<D>, options?: {
10
+ itemsPerPage: I;
11
+ initialPage?: number;
12
+ autoResetPage?: boolean;
13
+ }): {
14
+ pageData: Array<D>;
15
+ currentPage: number;
16
+ paginate: (pageNumber: number) => void;
17
+ itemsPerPage: I;
18
+ totalItems: number;
19
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A hook to handle storing the previous value of anything.
3
+ * @param value - The value to watch.
4
+ * @param setInitial - Whether it should initialise with the current value.
5
+ * @return The previous value.
6
+ */
7
+ export declare const usePrevious: <T>(value: T, setInitial?: boolean) => T;
@@ -0,0 +1,9 @@
1
+ export declare const THROTTLE_DELAY: number;
2
+ export type Callback = (...args: any[]) => any;
3
+ /**
4
+ * A hook to handle throttling calls to a function.
5
+ * @param callback The function to throttle.
6
+ * @param delay The throttle delay in ms.
7
+ * @return The callback function wrapped in the throttle.
8
+ */
9
+ export declare const useThrottle: (callback: Callback, delay?: number) => Callback;
@@ -0,0 +1,54 @@
1
+ export type WindowFitment = {
2
+ fromTop: {
3
+ fitsAbove: boolean;
4
+ fitsBelow: boolean;
5
+ spaceAbove: number;
6
+ spaceBelow: number;
7
+ };
8
+ fromBottom: {
9
+ fitsAbove: boolean;
10
+ fitsBelow: boolean;
11
+ spaceAbove: number;
12
+ spaceBelow: number;
13
+ };
14
+ fromLeft: {
15
+ fitsLeft: boolean;
16
+ fitsRight: boolean;
17
+ spaceLeft: number;
18
+ spaceRight: number;
19
+ };
20
+ fromRight: {
21
+ fitsLeft: boolean;
22
+ fitsRight: boolean;
23
+ spaceLeft: number;
24
+ spaceRight: number;
25
+ };
26
+ fromCenter: {
27
+ fitsLeft: boolean;
28
+ fitsRight: boolean;
29
+ fitsAbove: boolean;
30
+ fitsBelow: boolean;
31
+ spaceLeft: number;
32
+ spaceRight: number;
33
+ spaceAbove: number;
34
+ spaceBelow: number;
35
+ fitsCentered: {
36
+ fitsAbove: boolean;
37
+ fitsBelow: boolean;
38
+ fitsLeft: boolean;
39
+ fitsRight: boolean;
40
+ };
41
+ };
42
+ };
43
+ /**
44
+ * A hook to determine if an element fits on the window.
45
+ * @param targetNode The element to try and fit on the window.
46
+ * @param referenceNode The element to use to position the target.
47
+ * @param callback The function to call when updating fitment info.
48
+ * @param spacer An additional space to leave between the target and reference.
49
+ * @param shouldCheck Whether the fitment info should be being checked.
50
+ * @param fromMouse Whether the target should be being positioned in relation
51
+ * to the mouse. In this case refernceNode will be used to
52
+ * listen for mouseover events.
53
+ */
54
+ export declare const useWindowFitment: (targetNode: HTMLElement, referenceNode: HTMLElement, callback: (fitsWindow: WindowFitment) => void, spacer?: number, shouldCheck?: boolean, fromMouse?: boolean) => void;
@@ -0,0 +1,132 @@
1
+ export { default as Accordion } from "./components/Accordion";
2
+ export { default as ActionButton } from "./components/ActionButton";
3
+ export { default as ArticlePagination } from "./components/ArticlePagination";
4
+ export { default as ApplicationLayout } from "./components/ApplicationLayout";
5
+ export { default as AppAside } from "./components/ApplicationLayout/AppAside";
6
+ export { default as Application } from "./components/ApplicationLayout/Application";
7
+ export { default as AppMain } from "./components/ApplicationLayout/AppMain";
8
+ export { default as AppNavigation } from "./components/ApplicationLayout/AppNavigation";
9
+ export { default as AppNavigationBar } from "./components/ApplicationLayout/AppNavigationBar";
10
+ export { default as AppStatus } from "./components/ApplicationLayout/AppStatus";
11
+ export { default as Badge } from "./components/Badge";
12
+ export { default as Button, ButtonAppearance } from "./components/Button";
13
+ export { default as Card } from "./components/Card";
14
+ export { default as CheckboxInput } from "./components/CheckboxInput";
15
+ export { default as Chip } from "./components/Chip";
16
+ export { default as Code } from "./components/Code";
17
+ export { default as CodeSnippet, CodeSnippetBlockAppearance, } from "./components/CodeSnippet";
18
+ export { default as Col } from "./components/Col";
19
+ export { default as ConfirmationButton } from "./components/ConfirmationButton";
20
+ export { default as ConfirmationModal } from "./components/ConfirmationModal";
21
+ export { default as ContextualMenu } from "./components/ContextualMenu";
22
+ export { default as EmptyState } from "./components/EmptyState";
23
+ export { default as Field } from "./components/Field";
24
+ export { default as Form } from "./components/Form";
25
+ export { default as FormikField } from "./components/FormikField";
26
+ export { default as Icon, ICONS } from "./components/Icon";
27
+ export { default as Input } from "./components/Input";
28
+ export { default as Label } from "./components/Label";
29
+ export { default as Link } from "./components/Link";
30
+ export { default as List } from "./components/List";
31
+ export { default as Loader } from "./components/Loader";
32
+ export { default as MainTable } from "./components/MainTable";
33
+ export { default as ModularTable } from "./components/ModularTable";
34
+ export { default as Navigation } from "./components/Navigation";
35
+ export { default as Modal } from "./components/Modal";
36
+ export * from "./components/MultiSelect";
37
+ export { default as Notification, NotificationSeverity, } from "./components/Notification";
38
+ export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue, } from "./components/NotificationProvider";
39
+ export { default as LoginPageLayout } from "./components/LoginPageLayout";
40
+ export { default as Pagination } from "./components/Pagination";
41
+ export { default as Panel } from "./components/Panel";
42
+ export { default as PasswordToggle } from "./components/PasswordToggle";
43
+ export { default as RadioInput } from "./components/RadioInput";
44
+ export { default as Row } from "./components/Row";
45
+ export { default as SearchAndFilter } from "./components/SearchAndFilter";
46
+ export { default as SearchBox } from "./components/SearchBox";
47
+ export { default as Select } from "./components/Select";
48
+ export { default as SideNavigation } from "./components/SideNavigation";
49
+ export { default as SideNavigationItem } from "./components/SideNavigation/SideNavigationItem";
50
+ export { default as SideNavigationLink } from "./components/SideNavigation/SideNavigationLink";
51
+ export { default as SideNavigationText } from "./components/SideNavigation/SideNavigationText";
52
+ export { default as Slider } from "./components/Slider";
53
+ export { default as Switch } from "./components/Switch";
54
+ export { default as Spinner } from "./components/Spinner";
55
+ export { default as StatusLabel, StatusLabelAppearance, } from "./components/StatusLabel";
56
+ export { default as Strip } from "./components/Strip";
57
+ export { default as SummaryButton } from "./components/SummaryButton";
58
+ export { default as Table } from "./components/Table";
59
+ export { default as TableCell } from "./components/TableCell";
60
+ export { default as TableHeader } from "./components/TableHeader";
61
+ export { default as TableRow } from "./components/TableRow";
62
+ export { default as Tabs } from "./components/Tabs";
63
+ export { default as Textarea } from "./components/Textarea";
64
+ export { default as Tooltip } from "./components/Tooltip";
65
+ export { default as TablePagination } from "./components/TablePagination";
66
+ export { default as TablePaginationControls } from "./components/TablePagination/TablePaginationControls";
67
+ export type { AccordionProps } from "./components/Accordion";
68
+ export type { ActionButtonProps } from "./components/ActionButton";
69
+ export type { ArticlePaginationProps } from "./components/ArticlePagination";
70
+ export type { ApplicationLayoutProps } from "./components/ApplicationLayout";
71
+ export type { AppAsideProps } from "./components/ApplicationLayout/AppAside";
72
+ export type { ApplicationProps } from "./components/ApplicationLayout/Application";
73
+ export type { AppMainProps } from "./components/ApplicationLayout/AppMain";
74
+ export type { AppNavigationProps } from "./components/ApplicationLayout/AppNavigation";
75
+ export type { AppNavigationBarProps } from "./components/ApplicationLayout/AppNavigationBar";
76
+ export type { AppStatusProps } from "./components/ApplicationLayout/AppStatus";
77
+ export type { BadgeProps } from "./components/Badge";
78
+ export type { ButtonProps } from "./components/Button";
79
+ export type { CardProps } from "./components/Card";
80
+ export type { CheckboxInputProps } from "./components/CheckboxInput";
81
+ export type { ChipProps } from "./components/Chip";
82
+ export type { CodeProps } from "./components/Code";
83
+ export type { CodeSnippetProps, CodeSnippetBlockProps, CodeSnippetDropdownProps, } from "./components/CodeSnippet";
84
+ export type { ColProps, ColSize } from "./components/Col";
85
+ export type { ConfirmationButtonProps } from "./components/ConfirmationButton";
86
+ export type { ConfirmationModalProps } from "./components/ConfirmationModal";
87
+ export type { ContextualMenuProps, ContextualMenuDropdownProps, MenuLink, Position, } from "./components/ContextualMenu";
88
+ export type { EmptyStateProps } from "./components/EmptyState";
89
+ export type { FieldProps } from "./components/Field";
90
+ export type { FormProps } from "./components/Form";
91
+ export type { FormikFieldProps } from "./components/FormikField";
92
+ export type { IconProps } from "./components/Icon";
93
+ export type { InputProps } from "./components/Input";
94
+ export type { LabelProps } from "./components/Label";
95
+ export type { LinkProps } from "./components/Link";
96
+ export type { ListProps } from "./components/List";
97
+ export type { MainTableProps } from "./components/MainTable";
98
+ export type { ModularTableProps } from "./components/ModularTable";
99
+ export type { ModalProps } from "./components/Modal";
100
+ export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, NavLinkAnchor, NavLinkBase, NavLinkButton, } from "./components/Navigation";
101
+ export type { NotificationProps } from "./components/Notification";
102
+ export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./components/NotificationProvider";
103
+ export type { LoginPageLayoutProps } from "./components/LoginPageLayout";
104
+ export type { PaginationProps } from "./components/Pagination";
105
+ export type { PanelProps } from "./components/Panel";
106
+ export type { RadioInputProps } from "./components/RadioInput";
107
+ export type { RowProps } from "./components/Row";
108
+ export type { SearchAndFilterProps } from "./components/SearchAndFilter";
109
+ export type { SearchBoxProps } from "./components/SearchBox";
110
+ export type { SelectProps } from "./components/Select";
111
+ export type { SideNavigationProps } from "./components/SideNavigation";
112
+ export type { SideNavigationItemProps } from "./components/SideNavigation/SideNavigationItem";
113
+ export type { SideNavigationLinkProps } from "./components/SideNavigation/SideNavigationLink";
114
+ export type { SideNavigationTextProps } from "./components/SideNavigation/SideNavigationText";
115
+ export type { SliderProps } from "./components/Slider";
116
+ export type { SpinnerProps } from "./components/Spinner";
117
+ export type { StatusLabelProps } from "./components/StatusLabel";
118
+ export type { StripProps } from "./components/Strip";
119
+ export type { SummaryButtonProps } from "./components/SummaryButton";
120
+ export type { TableProps } from "./components/Table";
121
+ export type { TableCellProps } from "./components/TableCell";
122
+ export type { TableHeaderProps } from "./components/TableHeader";
123
+ export type { TableRowProps } from "./components/TableRow";
124
+ export type { TabsProps } from "./components/Tabs";
125
+ export type { TextareaProps } from "./components/Textarea";
126
+ export type { TooltipProps } from "./components/Tooltip";
127
+ export type { TablePaginationProps } from "./components/TablePagination";
128
+ export { useOnClickOutside, useClickOutside, useId, useListener, useOnEscapePressed, usePagination, usePrevious, useThrottle, useWindowFitment, } from "./hooks";
129
+ export type { WindowFitment } from "./hooks";
130
+ export { isNavigationAnchor, isNavigationButton } from "./utils";
131
+ export type { ClassName, Headings, PropsWithSpread, SortDirection, SubComponentProps, TSFixMe, ValueOf, } from "./types";
132
+ export { Theme } from "./enums";
@@ -0,0 +1,38 @@
1
+ /**
2
+ * This type should be used for all className props in order to ensure
3
+ * consistency across components.
4
+ */
5
+ export type ClassName = string | null;
6
+ /**
7
+ * The allowable heading levels.
8
+ */
9
+ export type Headings = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
10
+ /**
11
+ * This type can be used when defining props that also spread the props of
12
+ * something else. It ensures that the defined component props are never
13
+ * overwritten by the spread props.
14
+ */
15
+ export type PropsWithSpread<P, H> = P & Omit<H, keyof P>;
16
+ /**
17
+ * The allowable sort directions e.g. for a sortable table.
18
+ */
19
+ export type SortDirection = "none" | "ascending" | "descending";
20
+ /**
21
+ * This type can be used when passing props to a sub component. It makes all
22
+ * component props optional.
23
+ */
24
+ export type SubComponentProps<P> = Partial<P> & {
25
+ [prop: string]: unknown;
26
+ };
27
+ /**
28
+ * This type is simply an alias for the 'any' type and should be used sparingly,
29
+ * if at all.
30
+ */
31
+ export type TSFixMe = any;
32
+ /**
33
+ * This type allows for converting an object const into an enum-like construct,
34
+ * e.g. value: ValueOf<typeof EnumLike> will only allow value to be a value
35
+ * defined in EnumLike.
36
+ */
37
+ export type ValueOf<T> = T[keyof T];
38
+ export type ExclusiveProps<A, B> = (A & Partial<Record<keyof B, never>>) | (B & Partial<Record<keyof A, never>>);
@@ -0,0 +1,27 @@
1
+ import { NavLink, NavLinkAnchor, NavLinkButton } from "./components/Navigation";
2
+ import { ReactNode } from "react";
3
+ export declare const IS_DEV: boolean;
4
+ /**
5
+ * Find substring and wrap in <strong /> tag
6
+ * @param {string} str - The string to search
7
+ * @param {string} subString - The substring to find
8
+ * @return {Obj} newStr - Object with text and match bool
9
+ */
10
+ export declare const highlightSubString: (str?: string, subString?: string) => {
11
+ text: string;
12
+ match: boolean;
13
+ };
14
+ /**
15
+ * Whether a navigation item is an anchor.
16
+ * @param link - The navigation item.
17
+ */
18
+ export declare const isNavigationAnchor: (link: NavLink) => link is NavLinkAnchor;
19
+ /**
20
+ * Whether a navigation item is a button.
21
+ * @param link - The navigation item.
22
+ */
23
+ export declare const isNavigationButton: (link: NavLink) => link is NavLinkButton;
24
+ /**
25
+ * A typeguard for whether an element is a ReactNode.
26
+ */
27
+ export declare const isReactNode: (element: unknown) => element is ReactNode;
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "main": "dist/index.js",
5
- "module": "dist-esm/index.js",
6
- "types": "dist-types/index.d.ts",
5
+ "module": "dist/index.js",
7
6
  "author": {
8
7
  "email": "webteam@canonical.com",
9
8
  "name": "Canonical Webteam"
@@ -13,6 +12,8 @@
13
12
  "dist/**/*.js",
14
13
  "dist/**/*.d.*",
15
14
  "dist/**/*.scss",
15
+ "dist-types/**/*.d.ts",
16
+ "dist-esm/**/*.js",
16
17
  "!dist/**/*.test.js",
17
18
  "!dist/testing",
18
19
  "!dist/setupTests.js"
@@ -94,7 +95,7 @@
94
95
  "tsc-alias": "1.8.10",
95
96
  "typescript": "5.5.4",
96
97
  "typescript-eslint": "8.4.0",
97
- "vanilla-framework": "4.15.0",
98
+ "vanilla-framework": "4.16.0",
98
99
  "wait-on": "8.0.0",
99
100
  "webpack": "5.94.0"
100
101
  },
@@ -127,12 +128,10 @@
127
128
  "vanilla-framework": "^3.15.1 || ^4.0.0"
128
129
  },
129
130
  "scripts": {
130
- "build": "yarn build-cjs && yarn build-declaration && yarn build-esm",
131
- "build-base": "rm -rf $OUT_DIR && NODE_ENV=production BABEL_ENV=$BABEL_ENV babel src --out-dir $OUT_DIR --copy-files --no-copy-ignored --extensions '.js,.jsx,.ts,.tsx,.snap' --ignore '**/*.test.ts','**/*.test.tsx','**/*.stories.tsx','**/__snapshots__','src/setupTests.js','src/testing'",
132
- "build-cjs": "OUT_DIR=dist BABEL_ENV=cjs yarn run build-base",
133
- "build-esm": "OUT_DIR=dist-esm BABEL_ENV=esm yarn run build-base",
134
- "build-declaration": "rm -rf dist-types && tsc --project tsconfig.build.json --outDir dist-types && tsc-alias -p tsconfig.build.json --outDir dist-types",
135
- "build-watch": "yarn run build-cjs --watch",
131
+ "build": "rm -rf dist && yarn build-local; yarn build-declaration",
132
+ "build-local": "NODE_ENV=production babel src --out-dir dist --copy-files --no-copy-ignored --extensions '.js,.jsx,.ts,.tsx,.snap' --ignore '**/*.test.ts','**/*.test.tsx','**/*.stories.tsx','**/__snapshots__','src/setupTests.js','src/testing'",
133
+ "build-declaration": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
134
+ "build-watch": "yarn run build-local --watch",
136
135
  "build-docs": "storybook build -c .storybook -o docs",
137
136
  "clean": "rm -rf node_modules dist .out",
138
137
  "docs": "storybook dev -p ${PORT:-9009} --no-open",