@canonical/maas-react-components 2.5.0 → 2.7.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.
Files changed (191) hide show
  1. package/dist/@canonical/maas-react-components.es.js +531 -6632
  2. package/dist/QueryInput-D7uXzKgr.mjs +1648 -0
  3. package/dist/{src/lib/elements → elements}/ExternalLink/ExternalLink.d.ts +1 -2
  4. package/dist/index.d.ts +4 -2
  5. package/dist/maas-react-components.css +1 -1
  6. package/dist/sections/Layout/Layout.d.ts +18 -0
  7. package/dist/sections/Layout/components/DocumentTitle/DocumentTitle.d.ts +4 -0
  8. package/dist/sections/Layout/index.d.ts +1 -0
  9. package/dist/{src/lib/sections → sections}/index.d.ts +1 -0
  10. package/dist/testing/expectTooltipOnHover.d.ts +4 -0
  11. package/dist/testing/index.d.ts +8 -0
  12. package/dist/testing/index.es.js +129 -0
  13. package/dist/testing/mockIsPending.d.ts +6 -0
  14. package/dist/testing/mockSidePanel.d.ts +7 -0
  15. package/dist/testing/renderHookWithProviders.d.ts +24 -0
  16. package/dist/testing/renderWithProviders.d.ts +32 -0
  17. package/dist/testing/setupMockServer.d.ts +13 -0
  18. package/dist/testing/spyOnMutation.d.ts +8 -0
  19. package/dist/testing/waitForLoading.d.ts +10 -0
  20. package/dist/utils/formatBytes/formatBytes.test.d.ts +1 -0
  21. package/package.json +48 -10
  22. package/dist/@canonical/maas-react-components.umd.js +0 -55
  23. package/dist/src/constants.d.ts +0 -6
  24. package/dist/src/lib/index.d.ts +0 -4
  25. package/dist/src/types.d.ts +0 -7
  26. package/dist/src/utils.d.ts +0 -7
  27. /package/dist/{src/lib/components → components}/DynamicTable/DynamicTable.d.ts +0 -0
  28. /package/dist/{src/lib/components → components}/DynamicTable/DynamicTable.stories.d.ts +0 -0
  29. /package/dist/{src/lib/components → components}/DynamicTable/DynamicTable.test.d.ts +0 -0
  30. /package/dist/{src/lib/components → components}/DynamicTable/index.d.ts +0 -0
  31. /package/dist/{src/lib/components → components}/FadeInDown/FadeInDown.d.ts +0 -0
  32. /package/dist/{src/lib/components → components}/FadeInDown/FadeInDown.test.d.ts +0 -0
  33. /package/dist/{src/lib/components → components}/FadeInDown/index.d.ts +0 -0
  34. /package/dist/{src/lib/components → components}/FileUpload/FileUpload.d.ts +0 -0
  35. /package/dist/{src/lib/components → components}/FileUpload/FileUpload.stories.d.ts +0 -0
  36. /package/dist/{src/lib/components → components}/FileUpload/FileUpload.test.d.ts +0 -0
  37. /package/dist/{src/lib/components → components}/FileUpload/hooks.d.ts +0 -0
  38. /package/dist/{src/lib/components → components}/FileUpload/index.d.ts +0 -0
  39. /package/dist/{src/lib/components → components}/GenericTable/GenericTable.d.ts +0 -0
  40. /package/dist/{src/lib/components → components}/GenericTable/GenericTable.stories.d.ts +0 -0
  41. /package/dist/{src/lib/components → components}/GenericTable/GenericTable.test.d.ts +0 -0
  42. /package/dist/{src/lib/components → components}/GenericTable/components/ColumnHeader/ColumnHeader.d.ts +0 -0
  43. /package/dist/{src/lib/components → components}/GenericTable/components/ColumnHeader/index.d.ts +0 -0
  44. /package/dist/{src/lib/components → components}/GenericTable/components/PaginationBar/ControlsBar/ControlsBar.d.ts +0 -0
  45. /package/dist/{src/lib/components → components}/GenericTable/components/PaginationBar/ControlsBar/index.d.ts +0 -0
  46. /package/dist/{src/lib/components → components}/GenericTable/components/PaginationBar/PaginationBar.d.ts +0 -0
  47. /package/dist/{src/lib/components → components}/GenericTable/components/PaginationBar/index.d.ts +0 -0
  48. /package/dist/{src/lib/components → components}/GenericTable/components/SortingIndicator/SortingIndicator.d.ts +0 -0
  49. /package/dist/{src/lib/components → components}/GenericTable/components/SortingIndicator/index.d.ts +0 -0
  50. /package/dist/{src/lib/components → components}/GenericTable/components/TableCheckbox/TableCheckbox.d.ts +0 -0
  51. /package/dist/{src/lib/components → components}/GenericTable/components/TableCheckbox/TableCheckbox.test.d.ts +0 -0
  52. /package/dist/{src/lib/components → components}/GenericTable/components/TableCheckbox/index.d.ts +0 -0
  53. /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableExpansion.d.ts +0 -0
  54. /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableGrouping.d.ts +0 -0
  55. /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableKeyboardNavigation.d.ts +0 -0
  56. /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableScrollHeight.d.ts +0 -0
  57. /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableSorting.d.ts +0 -0
  58. /package/dist/{src/lib/components → components}/GenericTable/index.d.ts +0 -0
  59. /package/dist/{src/lib/components → components}/GenericTable/types.d.ts +0 -0
  60. /package/dist/{src/lib/components → components}/GenericTable/utils/processColumnDefs.d.ts +0 -0
  61. /package/dist/{src/lib/components → components}/GenericTable/utils/renderDataRows.d.ts +0 -0
  62. /package/dist/{src/lib/components → components}/GenericTable/utils/renderLoadingRows.d.ts +0 -0
  63. /package/dist/{src/lib/components → components}/MultiSelect/MultiSelect.d.ts +0 -0
  64. /package/dist/{src/lib/components → components}/MultiSelect/MultiSelect.stories.d.ts +0 -0
  65. /package/dist/{src/lib/components → components}/MultiSelect/MultiSelect.test.d.ts +0 -0
  66. /package/dist/{src/lib/components → components}/MultiSelect/index.d.ts +0 -0
  67. /package/dist/{src/lib/components → components}/NestedFormGroup/NestedFormGroup.d.ts +0 -0
  68. /package/dist/{src/lib/components → components}/NestedFormGroup/NestedFormGroup.stories.d.ts +0 -0
  69. /package/dist/{src/lib/components → components}/NestedFormGroup/NestedFormGroup.test.d.ts +0 -0
  70. /package/dist/{src/lib/components → components}/NestedFormGroup/index.d.ts +0 -0
  71. /package/dist/{src/lib/components → components}/Pagination/Pagination.d.ts +0 -0
  72. /package/dist/{src/lib/components → components}/Pagination/Pagination.stories.d.ts +0 -0
  73. /package/dist/{src/lib/components → components}/Pagination/Pagination.test.d.ts +0 -0
  74. /package/dist/{src/lib/components → components}/Pagination/PaginationContainer.test.d.ts +0 -0
  75. /package/dist/{src/lib/components → components}/Pagination/index.d.ts +0 -0
  76. /package/dist/{src/lib/components → components}/QueryInput/QueryInput.d.ts +0 -0
  77. /package/dist/{src/lib/components → components}/QueryInput/QueryInput.stories.d.ts +0 -0
  78. /package/dist/{src/lib/components → components}/QueryInput/QueryInput.test.d.ts +0 -0
  79. /package/dist/{src/lib/components → components}/QueryInput/index.d.ts +0 -0
  80. /package/dist/{src/lib/components → components}/Stepper/Stepper.d.ts +0 -0
  81. /package/dist/{src/lib/components → components}/Stepper/Stepper.stories.d.ts +0 -0
  82. /package/dist/{src/lib/components → components}/Stepper/Stepper.test.d.ts +0 -0
  83. /package/dist/{src/lib/components → components}/Stepper/index.d.ts +0 -0
  84. /package/dist/{src/lib/components → components}/TableCaption/TableCaption.d.ts +0 -0
  85. /package/dist/{src/lib/components → components}/TableCaption/TableCaption.stories.d.ts +0 -0
  86. /package/dist/{src/lib/components → components}/TableCaption/TableCaption.test.d.ts +0 -0
  87. /package/dist/{src/lib/components → components}/TableCaption/index.d.ts +0 -0
  88. /package/dist/{src/lib/components → components}/index.d.ts +0 -0
  89. /package/dist/{src/lib/elements → elements}/ExternalLink/ExternalLink.stories.d.ts +0 -0
  90. /package/dist/{src/lib/elements → elements}/ExternalLink/ExternalLink.test.d.ts +0 -0
  91. /package/dist/{src/lib/elements → elements}/ExternalLink/index.d.ts +0 -0
  92. /package/dist/{src/lib/elements → elements}/Meter/Meter.d.ts +0 -0
  93. /package/dist/{src/lib/elements → elements}/Meter/Meter.stories.d.ts +0 -0
  94. /package/dist/{src/lib/elements → elements}/Meter/Meter.test.d.ts +0 -0
  95. /package/dist/{src/lib/elements → elements}/Meter/index.d.ts +0 -0
  96. /package/dist/{src/lib/elements → elements}/Placeholder/Placeholder.d.ts +0 -0
  97. /package/dist/{src/lib/elements → elements}/Placeholder/Placeholder.stories.d.ts +0 -0
  98. /package/dist/{src/lib/elements → elements}/Placeholder/Placeholder.test.d.ts +0 -0
  99. /package/dist/{src/lib/elements → elements}/Placeholder/index.d.ts +0 -0
  100. /package/dist/{src/lib/elements → elements}/ProgressIndicator/ProgressIndicator.d.ts +0 -0
  101. /package/dist/{src/lib/elements → elements}/ProgressIndicator/ProgressIndicator.test.d.ts +0 -0
  102. /package/dist/{src/lib/elements → elements}/ProgressIndicator/index.d.ts +0 -0
  103. /package/dist/{src/lib/elements → elements}/index.d.ts +0 -0
  104. /package/dist/{src/lib/sections → sections}/ContentSection/ContentSection.d.ts +0 -0
  105. /package/dist/{src/lib/sections → sections}/ContentSection/ContentSection.stories.d.ts +0 -0
  106. /package/dist/{src/lib/sections → sections}/ContentSection/ContentSection.test.d.ts +0 -0
  107. /package/dist/{src/lib/sections → sections}/ContentSection/index.d.ts +0 -0
  108. /package/dist/{src/lib/sections → sections}/FormSection/FormSection.d.ts +0 -0
  109. /package/dist/{src/lib/sections → sections}/FormSection/FormSection.stories.d.ts +0 -0
  110. /package/dist/{src/lib/sections → sections}/FormSection/FormSection.test.d.ts +0 -0
  111. /package/dist/{src/lib/sections → sections}/FormSection/index.d.ts +0 -0
  112. /package/dist/{src/lib/sections → sections}/InputGroup/InputGroup.d.ts +0 -0
  113. /package/dist/{src/lib/sections → sections}/InputGroup/InputGroup.stories.d.ts +0 -0
  114. /package/dist/{src/lib/sections → sections}/InputGroup/InputGroup.test.d.ts +0 -0
  115. /package/dist/{src/lib/sections → sections}/InputGroup/index.d.ts +0 -0
  116. /package/dist/{src/lib/sections/MainToolbar/MainToolbar.test.d.ts → sections/Layout/Layout.test.d.ts} +0 -0
  117. /package/dist/{vitest-setup.d.ts → sections/Layout/components/DocumentTitle/index.d.ts} +0 -0
  118. /package/dist/{src/lib/sections → sections}/MainToolbar/MainToolbar.d.ts +0 -0
  119. /package/dist/{src/lib/sections → sections}/MainToolbar/MainToolbar.stories.d.ts +0 -0
  120. /package/dist/{src/lib/sections/Navigation/Banner/Banner.test.d.ts → sections/MainToolbar/MainToolbar.test.d.ts} +0 -0
  121. /package/dist/{src/lib/sections → sections}/MainToolbar/index.d.ts +0 -0
  122. /package/dist/{src/lib/sections → sections}/Navigation/Banner/Banner.d.ts +0 -0
  123. /package/dist/{src/lib/sections → sections}/Navigation/Banner/Banner.stories.d.ts +0 -0
  124. /package/dist/{src/lib/sections/Navigation/CollapseToggle/CollapseToggle.test.d.ts → sections/Navigation/Banner/Banner.test.d.ts} +0 -0
  125. /package/dist/{src/lib/sections → sections}/Navigation/CollapseToggle/CollapseToggle.d.ts +0 -0
  126. /package/dist/{src/lib/sections → sections}/Navigation/CollapseToggle/CollapseToggle.stories.d.ts +0 -0
  127. /package/dist/{src/lib/sections/Navigation/Content/Content.test.d.ts → sections/Navigation/CollapseToggle/CollapseToggle.test.d.ts} +0 -0
  128. /package/dist/{src/lib/sections → sections}/Navigation/Content/Content.d.ts +0 -0
  129. /package/dist/{src/lib/sections → sections}/Navigation/Content/Content.stories.d.ts +0 -0
  130. /package/dist/{src/lib/sections/Navigation/Controls/Controls.test.d.ts → sections/Navigation/Content/Content.test.d.ts} +0 -0
  131. /package/dist/{src/lib/sections → sections}/Navigation/Controls/Controls.d.ts +0 -0
  132. /package/dist/{src/lib/sections → sections}/Navigation/Controls/Controls.stories.d.ts +0 -0
  133. /package/dist/{src/lib/sections/Navigation/Drawer/Drawer.test.d.ts → sections/Navigation/Controls/Controls.test.d.ts} +0 -0
  134. /package/dist/{src/lib/sections → sections}/Navigation/Drawer/Drawer.d.ts +0 -0
  135. /package/dist/{src/lib/sections → sections}/Navigation/Drawer/Drawer.stories.d.ts +0 -0
  136. /package/dist/{src/lib/sections/Navigation/Footer/Footer.test.d.ts → sections/Navigation/Drawer/Drawer.test.d.ts} +0 -0
  137. /package/dist/{src/lib/sections → sections}/Navigation/Footer/Footer.d.ts +0 -0
  138. /package/dist/{src/lib/sections → sections}/Navigation/Footer/Footer.stories.d.ts +0 -0
  139. /package/dist/{src/lib/sections/Navigation/Header/Header.test.d.ts → sections/Navigation/Footer/Footer.test.d.ts} +0 -0
  140. /package/dist/{src/lib/sections → sections}/Navigation/Header/Header.d.ts +0 -0
  141. /package/dist/{src/lib/sections → sections}/Navigation/Header/Header.stories.d.ts +0 -0
  142. /package/dist/{src/lib/sections/Navigation/Icon/Icon.test.d.ts → sections/Navigation/Header/Header.test.d.ts} +0 -0
  143. /package/dist/{src/lib/sections → sections}/Navigation/Icon/Icon.d.ts +0 -0
  144. /package/dist/{src/lib/sections → sections}/Navigation/Icon/Icon.stories.d.ts +0 -0
  145. /package/dist/{src/lib/sections/Navigation/Item/Item.test.d.ts → sections/Navigation/Icon/Icon.test.d.ts} +0 -0
  146. /package/dist/{src/lib/sections → sections}/Navigation/Item/Item.d.ts +0 -0
  147. /package/dist/{src/lib/sections → sections}/Navigation/Item/Item.stories.d.ts +0 -0
  148. /package/dist/{src/lib/sections/Navigation/Label/Label.test.d.ts → sections/Navigation/Item/Item.test.d.ts} +0 -0
  149. /package/dist/{src/lib/sections → sections}/Navigation/Label/Label.d.ts +0 -0
  150. /package/dist/{src/lib/sections → sections}/Navigation/Label/Label.stories.d.ts +0 -0
  151. /package/dist/{src/lib/sections/Navigation/Link/Link.test.d.ts → sections/Navigation/Label/Label.test.d.ts} +0 -0
  152. /package/dist/{src/lib/sections → sections}/Navigation/Link/Link.d.ts +0 -0
  153. /package/dist/{src/lib/sections → sections}/Navigation/Link/Link.stories.d.ts +0 -0
  154. /package/dist/{src/lib/sections/Navigation/List/List.test.d.ts → sections/Navigation/Link/Link.test.d.ts} +0 -0
  155. /package/dist/{src/lib/sections → sections}/Navigation/List/List.d.ts +0 -0
  156. /package/dist/{src/lib/sections → sections}/Navigation/List/List.stories.d.ts +0 -0
  157. /package/dist/{src/lib/sections/Navigation/Logo/Logo.test.d.ts → sections/Navigation/List/List.test.d.ts} +0 -0
  158. /package/dist/{src/lib/sections → sections}/Navigation/Logo/Logo.d.ts +0 -0
  159. /package/dist/{src/lib/sections → sections}/Navigation/Logo/Logo.stories.d.ts +0 -0
  160. /package/dist/{src/lib/sections/Navigation/LogoIcon/LogoIcon.test.d.ts → sections/Navigation/Logo/Logo.test.d.ts} +0 -0
  161. /package/dist/{src/lib/sections → sections}/Navigation/LogoIcon/LogoIcon.d.ts +0 -0
  162. /package/dist/{src/lib/sections → sections}/Navigation/LogoIcon/LogoIcon.stories.d.ts +0 -0
  163. /package/dist/{src/lib/sections/Navigation/LogoName/LogoName.test.d.ts → sections/Navigation/LogoIcon/LogoIcon.test.d.ts} +0 -0
  164. /package/dist/{src/lib/sections → sections}/Navigation/LogoName/LogoName.d.ts +0 -0
  165. /package/dist/{src/lib/sections → sections}/Navigation/LogoName/LogoName.stories.d.ts +0 -0
  166. /package/dist/{src/lib/sections/Navigation/LogoTag/LogoTag.test.d.ts → sections/Navigation/LogoName/LogoName.test.d.ts} +0 -0
  167. /package/dist/{src/lib/sections → sections}/Navigation/LogoTag/LogoTag.d.ts +0 -0
  168. /package/dist/{src/lib/sections → sections}/Navigation/LogoTag/LogoTag.stories.d.ts +0 -0
  169. /package/dist/{src/lib/sections/Navigation/LogoText/LogoText.test.d.ts → sections/Navigation/LogoTag/LogoTag.test.d.ts} +0 -0
  170. /package/dist/{src/lib/sections → sections}/Navigation/LogoText/LogoText.d.ts +0 -0
  171. /package/dist/{src/lib/sections/Navigation/MenuButton/MenuButton.test.d.ts → sections/Navigation/LogoText/LogoText.test.d.ts} +0 -0
  172. /package/dist/{src/lib/sections → sections}/Navigation/MenuButton/MenuButton.d.ts +0 -0
  173. /package/dist/{src/lib/sections → sections}/Navigation/MenuButton/MenuButton.stories.d.ts +0 -0
  174. /package/dist/{src/lib/sections/Navigation/Navigation.test.d.ts → sections/Navigation/MenuButton/MenuButton.test.d.ts} +0 -0
  175. /package/dist/{src/lib/sections → sections}/Navigation/Navigation.d.ts +0 -0
  176. /package/dist/{src/lib/sections → sections}/Navigation/Navigation.stories.d.ts +0 -0
  177. /package/dist/{src/lib/sections/Navigation/NavigationBar.test.d.ts → sections/Navigation/Navigation.test.d.ts} +0 -0
  178. /package/dist/{src/lib/sections/Navigation/Text/Text.test.d.ts → sections/Navigation/NavigationBar.test.d.ts} +0 -0
  179. /package/dist/{src/lib/sections → sections}/Navigation/Text/Text.d.ts +0 -0
  180. /package/dist/{src/lib/sections/SidePanel/SidePanel.test.d.ts → sections/Navigation/Text/Text.test.d.ts} +0 -0
  181. /package/dist/{src/lib/sections → sections}/Navigation/index.d.ts +0 -0
  182. /package/dist/{src/lib/sections → sections}/SidePanel/SidePanel.d.ts +0 -0
  183. /package/dist/{src/lib/sections → sections}/SidePanel/SidePanel.stories.d.ts +0 -0
  184. /package/dist/{src/lib/utils/formatBytes/formatBytes.test.d.ts → sections/SidePanel/SidePanel.test.d.ts} +0 -0
  185. /package/dist/{src/lib/sections → sections}/SidePanel/SidePanelContextProvider/SidePanelContextProvider.d.ts +0 -0
  186. /package/dist/{src/lib/sections → sections}/SidePanel/index.d.ts +0 -0
  187. /package/dist/{src/lib/sections → sections}/SidePanel/utils.d.ts +0 -0
  188. /package/dist/{src/lib/utils → utils}/formatBytes/formatBytes.d.ts +0 -0
  189. /package/dist/{src/lib/utils → utils}/formatBytes/formatBytes.stories.d.ts +0 -0
  190. /package/dist/{src/lib/utils → utils}/formatBytes/index.d.ts +0 -0
  191. /package/dist/{src/lib/utils → utils}/index.d.ts +0 -0
@@ -0,0 +1,18 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ type LayoutProps = {
3
+ className?: string;
4
+ children: ReactNode;
5
+ pageTitle: string;
6
+ view: "settings" | "table";
7
+ isSecondaryNavVisible: boolean;
8
+ navigation: ReactNode;
9
+ secondaryNavigation: ReactNode;
10
+ statusBar?: ReactNode;
11
+ };
12
+ export declare const Layout: {
13
+ ({ className, children, pageTitle, view, isSecondaryNavVisible, navigation, secondaryNavigation, statusBar, }: LayoutProps): ReactElement;
14
+ Skeleton: ({ view, }: {
15
+ view: "settings" | "table";
16
+ }) => ReactElement;
17
+ };
18
+ export {};
@@ -0,0 +1,4 @@
1
+ declare const DocumentTitle: ({ children }: {
2
+ children: string[] | string;
3
+ }) => null;
4
+ export default DocumentTitle;
@@ -0,0 +1 @@
1
+ export { Layout } from './Layout';
@@ -1,6 +1,7 @@
1
1
  export * from './ContentSection';
2
2
  export * from './FormSection';
3
3
  export * from './InputGroup';
4
+ export * from './Layout';
4
5
  export * from './MainToolbar';
5
6
  export * from './Navigation';
6
7
  export * from './SidePanel';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Asserts that hovering an element reveals a tooltip with the given text.
3
+ */
4
+ export declare const expectTooltipOnHover: (element: Element | null, tooltipText: string | RegExp) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ export { expectTooltipOnHover } from './expectTooltipOnHover';
2
+ export { mockIsPending } from './mockIsPending';
3
+ export { mockSidePanel } from './mockSidePanel';
4
+ export { renderHookWithProviders } from './renderHookWithProviders';
5
+ export { renderWithProviders } from './renderWithProviders';
6
+ export { setupMockServer } from './setupMockServer';
7
+ export { spyOnMutation } from './spyOnMutation';
8
+ export { waitForLoading } from './waitForLoading';
@@ -0,0 +1,129 @@
1
+ import { screen as c, renderHook as v, render as h } from "@testing-library/react";
2
+ import u from "@testing-library/user-event";
3
+ import { vi as t } from "vitest";
4
+ import { jsx as l } from "react/jsx-runtime";
5
+ import { QueryClient as f, QueryClientProvider as y } from "@tanstack/react-query";
6
+ import { c as k } from "../QueryInput-D7uXzKgr.mjs";
7
+ import "@canonical/react-components";
8
+ import "react";
9
+ import "classnames";
10
+ import "react-dropzone";
11
+ import "@tanstack/react-table";
12
+ import { createMemoryRouter as d, RouterProvider as m } from "react-router";
13
+ import { setupServer as P } from "msw/node";
14
+ const V = async (r, e) => {
15
+ if (expect(
16
+ c.queryByRole("tooltip", { name: e })
17
+ ).not.toBeInTheDocument(), !r)
18
+ throw new Error("expectTooltipOnHover: the element was null or undefined");
19
+ await u.hover(r), r.querySelector("i") && await u.hover(r.querySelector("i")), await t.waitFor(
20
+ () => expect(c.getAllByRole("tooltip", { name: e })).toHaveLength(
21
+ 1
22
+ )
23
+ );
24
+ }, F = () => {
25
+ t.doMock("@tanstack/react-query", async () => ({
26
+ ...await t.importActual("@tanstack/react-query"),
27
+ useQuery: t.fn().mockReturnValueOnce({
28
+ data: null,
29
+ isPending: !0,
30
+ failureReason: void 0,
31
+ isFetched: !1
32
+ })
33
+ })), afterEach(() => {
34
+ t.doUnmock("@tanstack/react-query");
35
+ });
36
+ }, W = async () => {
37
+ const r = t.spyOn(
38
+ await import("../@canonical/maas-react-components.es.js"),
39
+ // the library's own barrel export
40
+ "useSidePanel"
41
+ ), e = t.fn(), a = t.fn();
42
+ let n = !1;
43
+ const i = () => ({
44
+ isOpen: n,
45
+ title: "",
46
+ size: "regular",
47
+ component: null,
48
+ props: {},
49
+ openSidePanel: e,
50
+ closeSidePanel: a,
51
+ setSidePanelSize: t.fn()
52
+ });
53
+ return beforeEach(() => {
54
+ t.clearAllMocks(), n = !1, e.mockImplementation(() => {
55
+ n = !0, r.mockReturnValue(i());
56
+ }), a.mockImplementation(() => {
57
+ n = !1, r.mockReturnValue(i());
58
+ }), r.mockReturnValue(i());
59
+ }), { mockOpen: e, mockClose: a };
60
+ }, b = (r, e) => {
61
+ const a = new f({
62
+ defaultOptions: { queries: { retry: !1, staleTime: 1 / 0 } }
63
+ }), n = e == null ? void 0 : e.AdditionalProviders;
64
+ return {
65
+ result: v(r, {
66
+ wrapper: ({ children: i }) => /* @__PURE__ */ l(y, { client: a, children: /* @__PURE__ */ l(k, { children: n ? /* @__PURE__ */ l(n, { children: i }) : i }) })
67
+ }).result,
68
+ queryClient: a
69
+ };
70
+ }, L = (r, e) => {
71
+ const a = new f({
72
+ defaultOptions: { queries: { retry: !1, staleTime: 1 / 0 } }
73
+ }), n = d(
74
+ [{ path: (e == null ? void 0 : e.pattern) ?? "*", element: r }],
75
+ { initialEntries: (e == null ? void 0 : e.initialEntries) || ["/"] }
76
+ ), i = e == null ? void 0 : e.AdditionalProviders, s = h(/* @__PURE__ */ l(m, { router: n }), {
77
+ wrapper: ({ children: o }) => /* @__PURE__ */ l(y, { client: a, children: /* @__PURE__ */ l(k, { children: i ? /* @__PURE__ */ l(i, { children: o }) : o }) }),
78
+ ...e
79
+ });
80
+ return { result: s, rerender: (o) => {
81
+ const p = d(
82
+ [{ path: (e == null ? void 0 : e.pattern) ?? "*", element: o }],
83
+ { initialEntries: (e == null ? void 0 : e.initialEntries) || ["/"] }
84
+ );
85
+ return s.rerender(/* @__PURE__ */ l(m, { router: p }));
86
+ }, router: n };
87
+ }, Q = (r, e, ...a) => {
88
+ r.setConfig({ baseUrl: e });
89
+ const n = P(...a);
90
+ return beforeAll(() => {
91
+ n.listen({ onUnhandledRequest: "error" });
92
+ }), afterEach(() => {
93
+ n.resetHandlers();
94
+ }), afterAll(() => {
95
+ n.close();
96
+ }), n;
97
+ }, U = (r, e) => {
98
+ const a = t.fn();
99
+ return t.spyOn(r, e).mockImplementation(() => ({
100
+ mutate: a,
101
+ mutateAsync: t.fn(),
102
+ data: void 0,
103
+ variables: void 0,
104
+ error: null,
105
+ isError: !1,
106
+ isPending: !1,
107
+ isIdle: !0,
108
+ isSuccess: !1,
109
+ status: "idle",
110
+ reset: t.fn()
111
+ })), afterEach(() => {
112
+ t.clearAllMocks();
113
+ }), a;
114
+ }, z = async (r = "Loading", e) => await t.waitFor(
115
+ () => expect(
116
+ c.queryByText(new RegExp(r, "i"))
117
+ ).not.toBeInTheDocument(),
118
+ e
119
+ );
120
+ export {
121
+ V as expectTooltipOnHover,
122
+ F as mockIsPending,
123
+ W as mockSidePanel,
124
+ b as renderHookWithProviders,
125
+ L as renderWithProviders,
126
+ Q as setupMockServer,
127
+ U as spyOnMutation,
128
+ z as waitForLoading
129
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Spies on `useQuery` from `@tanstack/react-query` to return a pending state
3
+ * for the first call in each test. Uses `vi.spyOn` (via `vi.doMock`) rather
4
+ * than mocking the return value directly, since the module is already loaded.
5
+ */
6
+ export declare const mockIsPending: () => void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Mocks the `useSidePanel` hook, returning `mockOpen`/`mockClose` spies.
3
+ */
4
+ export declare const mockSidePanel: () => Promise<{
5
+ mockOpen: import('vitest').Mock<(...args: any[]) => any>;
6
+ mockClose: import('vitest').Mock<(...args: any[]) => any>;
7
+ }>;
@@ -0,0 +1,24 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { QueryClient } from '@tanstack/react-query';
3
+ /**
4
+ * Renders a hook with all test-relevant providers (query client and side
5
+ * panel).
6
+ *
7
+ * Any project-specific providers (e.g. a Redux `Provider`, a WebSocket
8
+ * context, etc.) should be supplied via the `AdditionalProviders` option -
9
+ * this library has no dependency on Redux or any other state management
10
+ * library.
11
+ *
12
+ * @typeParam T - The return type of the hook.
13
+ */
14
+ export declare const renderHookWithProviders: <T>(hook: () => T, options?: Partial<{
15
+ initialEntries: string[];
16
+ AdditionalProviders: ComponentType<{
17
+ children: ReactNode;
18
+ }>;
19
+ }>) => {
20
+ result: {
21
+ current: T;
22
+ };
23
+ queryClient: QueryClient;
24
+ };
@@ -0,0 +1,32 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { InitialEntry } from '@remix-run/router';
3
+ import { RenderOptions, RenderResult } from '@testing-library/react';
4
+ import { createMemoryRouter } from 'react-router';
5
+ /** The router instance returned by `createMemoryRouter` / `createBrowserRouter`. */
6
+ type DataRouter = ReturnType<typeof createMemoryRouter>;
7
+ /**
8
+ * Renders a component with all test-relevant providers (query client, side
9
+ * panel, and router).
10
+ *
11
+ * Any project-specific providers (e.g. a Redux `Provider`, a WebSocket
12
+ * context, etc.) should be supplied via the `AdditionalProviders` option -
13
+ * this library has no dependency on Redux or any other state management
14
+ * library.
15
+ *
16
+ * @param ui - The component to render.
17
+ * @param options - Rendering options including router entries and an
18
+ * `AdditionalProviders` wrapper for project-specific
19
+ * providers (e.g. a Redux `Provider`, WebSocketProvider).
20
+ */
21
+ export declare const renderWithProviders: (ui: ReactNode, options?: Omit<RenderOptions, "wrapper"> & Partial<{
22
+ initialEntries: InitialEntry[];
23
+ pattern: string;
24
+ AdditionalProviders: ComponentType<{
25
+ children: ReactNode;
26
+ }>;
27
+ }>) => {
28
+ result: RenderResult;
29
+ router: DataRouter;
30
+ rerender: (ui: ReactNode) => void;
31
+ };
32
+ export {};
@@ -0,0 +1,13 @@
1
+ import { RequestHandler } from 'msw';
2
+ /**
3
+ * Sets up an MSW mock server for use in tests.
4
+ *
5
+ * @param client - The Hey-API client instance (from `@/app/apiclient/client.gen` in maas-ui).
6
+ * @param baseUrl - The base URL to configure on the client.
7
+ * @param handlers - MSW request handlers.
8
+ */
9
+ export declare const setupMockServer: (client: {
10
+ setConfig: (config: {
11
+ baseUrl: string;
12
+ }) => void;
13
+ }, baseUrl: string, ...handlers: RequestHandler[]) => import('msw/node').SetupServer;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Spies on a given mutation hook to observe the mutate function.
3
+ *
4
+ * @param obj - The module object that contains the hook.
5
+ * @param methodName - The name of the mutation hook to spy on.
6
+ * @returns A mock `mutate` function that can be observed with `expect`.
7
+ */
8
+ export declare const spyOnMutation: (obj: unknown, methodName: string) => import('vitest').Mock<(...args: any[]) => any>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Waits until the loading text is no longer present in the document.
3
+ *
4
+ * @param loadingText - Text to query for. Defaults to "Loading".
5
+ * @param options - Optional `vi.waitFor` options (`interval`, `timeout`).
6
+ */
7
+ export declare const waitForLoading: (loadingText?: string, options?: {
8
+ interval?: number;
9
+ timeout?: number;
10
+ }) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/maas-react-components",
3
3
  "description": "React components for use in MAAS UI projects.",
4
- "version": "2.5.0",
4
+ "version": "2.7.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/canonical/maas-react-components.git"
@@ -10,14 +10,19 @@
10
10
  "url": "https://github.com/canonical/maas-react-components/issues"
11
11
  },
12
12
  "homepage": "https://github.com/canonical/maas-react-components#readme",
13
- "main": "./dist/@canonical/maas-react-components.umd.js",
13
+ "main": "./dist/@canonical/maas-react-components.es.js",
14
14
  "module": "./dist/@canonical/maas-react-components.es.js",
15
15
  "types": "./dist/index.d.ts",
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
19
19
  "import": "./dist/@canonical/maas-react-components.es.js",
20
- "require": "./dist/@canonical/maas-react-components.umd.js"
20
+ "default": "./dist/@canonical/maas-react-components.es.js"
21
+ },
22
+ "./testing": {
23
+ "types": "./dist/testing/index.d.ts",
24
+ "import": "./dist/testing/index.es.js",
25
+ "default": "./dist/testing/index.es.js"
21
26
  },
22
27
  "./dist/style.css": {
23
28
  "import": "./dist/style.css",
@@ -27,6 +32,13 @@
27
32
  "files": [
28
33
  "dist"
29
34
  ],
35
+ "typesVersions": {
36
+ "*": {
37
+ "testing": [
38
+ "./dist/testing/index.d.ts"
39
+ ]
40
+ }
41
+ },
30
42
  "license": "AGPL-3.0",
31
43
  "scripts": {
32
44
  "build": "tsc && vite build",
@@ -48,6 +60,7 @@
48
60
  "devDependencies": {
49
61
  "@commitlint/cli": "^19.0.0",
50
62
  "@commitlint/config-conventional": "^19.0.0",
63
+ "@remix-run/router": "^1.23.3",
51
64
  "@semantic-release/changelog": "^6.0.3",
52
65
  "@semantic-release/git": "^10.0.1",
53
66
  "@storybook/addon-a11y": "^8.6.12",
@@ -58,10 +71,11 @@
58
71
  "@storybook/react": "^8.6.12",
59
72
  "@storybook/react-vite": "^8.6.12",
60
73
  "@storybook/theming": "^8.6.12",
74
+ "@tanstack/react-query": "^5.100.11",
61
75
  "@testing-library/jest-dom": "^6.1.3",
62
76
  "@testing-library/react": "^16.3.0",
63
77
  "@testing-library/user-event": "^14.5.1",
64
- "@types/react-dom": "19.1.3",
78
+ "@types/react-dom": "^19.1.3",
65
79
  "@typescript-eslint/eslint-plugin": "^7.0.0",
66
80
  "@typescript-eslint/parser": "^7.0.0",
67
81
  "@vitejs/plugin-react": "^4.1.0",
@@ -77,6 +91,7 @@
77
91
  "eslint-plugin-storybook": "^0.12.0",
78
92
  "eslint-plugin-unused-imports": "^3.2.0",
79
93
  "jsdom": "^26.0.0",
94
+ "msw": "^2.14.6",
80
95
  "plop": "^4.0.0",
81
96
  "prettier": "^3.5.3",
82
97
  "prop-types": "^15.8.1",
@@ -92,17 +107,40 @@
92
107
  "vite-plugin-dts": "^4.5.3",
93
108
  "vitest": "^3.0.8"
94
109
  },
110
+ "overrides": {
111
+ "@canonical/react-components": {
112
+ "@types/react": "$@types/react",
113
+ "@types/react-dom": "$@types/react-dom"
114
+ }
115
+ },
95
116
  "peerDependencies": {
96
117
  "@canonical/react-components": "^4.5.0",
118
+ "@tanstack/react-query": "^5.100.11",
97
119
  "@tanstack/react-table": "^8.15.3",
120
+ "@testing-library/react": "^16.0.0",
121
+ "@testing-library/user-event": "^14.0.0",
98
122
  "@types/react": "^19.1.2",
99
123
  "@types/react-dom": "^19.1.3",
100
124
  "classnames": "^2.3.2",
101
- "react": "19.1.0",
102
- "react-dom": "19.1.0",
103
- "react-dropzone": "14.3.8",
104
- "react-router": "^6.0.0",
105
- "react-router-dom": "^6.0.0",
106
- "vanilla-framework": "^4.10.0"
125
+ "msw": "^2.0.0",
126
+ "react": "^19.1.0",
127
+ "react-dom": "^19.1.0",
128
+ "react-dropzone": "^14.3.8",
129
+ "react-router": ">=6.0.0",
130
+ "vitest": "^3.0.0"
131
+ },
132
+ "peerDependenciesMeta": {
133
+ "@testing-library/react": {
134
+ "optional": true
135
+ },
136
+ "@testing-library/user-event": {
137
+ "optional": true
138
+ },
139
+ "msw": {
140
+ "optional": true
141
+ },
142
+ "vitest": {
143
+ "optional": true
144
+ }
107
145
  }
108
146
  }