@canonical/maas-react-components 2.7.1 → 2.7.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 (77) hide show
  1. package/dist/@canonical/maas-react-components.es.js +2 -689
  2. package/dist/components/DynamicTable/DynamicTable.d.ts +3 -3
  3. package/dist/components/DynamicTable/DynamicTable.stories.d.ts +1 -1
  4. package/dist/components/FileUpload/FileUpload.stories.d.ts +1 -1
  5. package/dist/components/GenericTable/GenericTable.stories.d.ts +1 -1
  6. package/dist/components/GenericTable/components/PaginationBar/ControlsBar/ControlsBar.d.ts +2 -2
  7. package/dist/components/GenericTable/components/TableCheckbox/TableCheckbox.d.ts +2 -2
  8. package/dist/components/GenericTable/utils/renderDataRows.d.ts +1 -1
  9. package/dist/components/GenericTable/utils/renderLoadingRows.d.ts +1 -1
  10. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +1 -1
  11. package/dist/components/NestedFormGroup/NestedFormGroup.d.ts +1 -1
  12. package/dist/components/NestedFormGroup/NestedFormGroup.stories.d.ts +2 -2
  13. package/dist/components/Pagination/Pagination.stories.d.ts +3 -3
  14. package/dist/components/QueryInput/QueryInput.stories.d.ts +1 -1
  15. package/dist/components/Stepper/Stepper.stories.d.ts +1 -1
  16. package/dist/components/TableCaption/TableCaption.d.ts +3 -3
  17. package/dist/components/TableCaption/TableCaption.stories.d.ts +1 -1
  18. package/dist/constants.d.ts +6 -0
  19. package/dist/elements/ExternalLink/ExternalLink.d.ts +1 -1
  20. package/dist/elements/ExternalLink/ExternalLink.stories.d.ts +1 -1
  21. package/dist/elements/Meter/Meter.d.ts +2 -2
  22. package/dist/elements/Meter/Meter.stories.d.ts +2 -2
  23. package/dist/elements/Placeholder/Placeholder.stories.d.ts +1 -1
  24. package/dist/lib-BEVV6FLF.mjs +2018 -0
  25. package/dist/maas-react-components.css +2 -1
  26. package/dist/sections/ContentSection/ContentSection.d.ts +6 -6
  27. package/dist/sections/ContentSection/ContentSection.stories.d.ts +5 -5
  28. package/dist/sections/FormSection/FormSection.d.ts +4 -4
  29. package/dist/sections/FormSection/FormSection.stories.d.ts +3 -3
  30. package/dist/sections/InputGroup/InputGroup.d.ts +3 -3
  31. package/dist/sections/InputGroup/InputGroup.stories.d.ts +3 -3
  32. package/dist/sections/MainToolbar/MainToolbar.d.ts +4 -4
  33. package/dist/sections/MainToolbar/MainToolbar.stories.d.ts +2 -2
  34. package/dist/sections/Navigation/Banner/Banner.d.ts +1 -1
  35. package/dist/sections/Navigation/Banner/Banner.stories.d.ts +2 -2
  36. package/dist/sections/Navigation/CollapseToggle/CollapseToggle.stories.d.ts +1 -1
  37. package/dist/sections/Navigation/Content/Content.d.ts +1 -1
  38. package/dist/sections/Navigation/Content/Content.stories.d.ts +2 -2
  39. package/dist/sections/Navigation/Controls/Controls.d.ts +1 -1
  40. package/dist/sections/Navigation/Controls/Controls.stories.d.ts +2 -2
  41. package/dist/sections/Navigation/Drawer/Drawer.d.ts +1 -1
  42. package/dist/sections/Navigation/Drawer/Drawer.stories.d.ts +2 -2
  43. package/dist/sections/Navigation/Footer/Footer.d.ts +1 -1
  44. package/dist/sections/Navigation/Footer/Footer.stories.d.ts +2 -2
  45. package/dist/sections/Navigation/Header/Header.d.ts +1 -1
  46. package/dist/sections/Navigation/Header/Header.stories.d.ts +2 -2
  47. package/dist/sections/Navigation/Icon/Icon.d.ts +1 -1
  48. package/dist/sections/Navigation/Icon/Icon.stories.d.ts +1 -1
  49. package/dist/sections/Navigation/Item/Item.d.ts +1 -1
  50. package/dist/sections/Navigation/Item/Item.stories.d.ts +3 -3
  51. package/dist/sections/Navigation/Label/Label.d.ts +1 -1
  52. package/dist/sections/Navigation/Label/Label.stories.d.ts +1 -1
  53. package/dist/sections/Navigation/Link/Link.d.ts +2 -2
  54. package/dist/sections/Navigation/Link/Link.stories.d.ts +3 -3
  55. package/dist/sections/Navigation/List/List.d.ts +1 -1
  56. package/dist/sections/Navigation/List/List.stories.d.ts +2 -2
  57. package/dist/sections/Navigation/Logo/Logo.d.ts +2 -2
  58. package/dist/sections/Navigation/Logo/Logo.stories.d.ts +2 -2
  59. package/dist/sections/Navigation/LogoIcon/LogoIcon.stories.d.ts +2 -2
  60. package/dist/sections/Navigation/LogoName/LogoName.d.ts +1 -1
  61. package/dist/sections/Navigation/LogoName/LogoName.stories.d.ts +1 -1
  62. package/dist/sections/Navigation/LogoTag/LogoTag.d.ts +1 -1
  63. package/dist/sections/Navigation/LogoTag/LogoTag.stories.d.ts +2 -2
  64. package/dist/sections/Navigation/LogoText/LogoText.d.ts +1 -1
  65. package/dist/sections/Navigation/MenuButton/MenuButton.d.ts +1 -1
  66. package/dist/sections/Navigation/MenuButton/MenuButton.stories.d.ts +1 -1
  67. package/dist/sections/Navigation/Navigation.d.ts +19 -19
  68. package/dist/sections/Navigation/Navigation.stories.d.ts +3 -3
  69. package/dist/sections/Navigation/Text/Text.d.ts +1 -1
  70. package/dist/sections/SidePanel/SidePanel.stories.d.ts +1 -1
  71. package/dist/testing/index.es.js +112 -129
  72. package/dist/testing/mockSidePanel.d.ts +3 -2
  73. package/dist/testing/spyOnMutation.d.ts +2 -1
  74. package/dist/types.d.ts +7 -0
  75. package/dist/utils/formatBytes/formatBytes.stories.d.ts +1 -1
  76. package/package.json +12 -15
  77. package/dist/QueryInput-D7uXzKgr.mjs +0 -1648
@@ -1,129 +1,112 @@
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
- };
1
+ import { y as e } from "../lib-BEVV6FLF.mjs";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { RouterProvider as n, createMemoryRouter as r } from "react-router";
4
+ import { render as i, renderHook as a, screen as o } from "@testing-library/react";
5
+ import s from "@testing-library/user-event";
6
+ import { vi as c } from "vitest";
7
+ import { QueryClient as l, QueryClientProvider as u } from "@tanstack/react-query";
8
+ import { setupServer as d } from "msw/node";
9
+ //#region src/lib/testing/expectTooltipOnHover.ts
10
+ var f = async (e, t) => {
11
+ if (expect(o.queryByRole("tooltip", { name: t })).not.toBeInTheDocument(), !e) throw Error("expectTooltipOnHover: the element was null or undefined");
12
+ await s.hover(e), e.querySelector("i") && await s.hover(e.querySelector("i")), await c.waitFor(() => expect(o.getAllByRole("tooltip", { name: t })).toHaveLength(1));
13
+ }, p = () => {
14
+ c.doMock("@tanstack/react-query", async () => ({
15
+ ...await c.importActual("@tanstack/react-query"),
16
+ useQuery: c.fn().mockReturnValueOnce({
17
+ data: null,
18
+ isPending: !0,
19
+ failureReason: void 0,
20
+ isFetched: !1
21
+ })
22
+ })), afterEach(() => {
23
+ c.doUnmock("@tanstack/react-query");
24
+ });
25
+ }, m = async () => {
26
+ let e = c.spyOn(await import("../@canonical/maas-react-components.es.js"), "useSidePanel"), t = c.fn(), n = c.fn(), r = !1, i = () => ({
27
+ isOpen: r,
28
+ title: "",
29
+ size: "regular",
30
+ component: null,
31
+ props: {},
32
+ openSidePanel: t,
33
+ closeSidePanel: n,
34
+ setSidePanelSize: c.fn()
35
+ });
36
+ return beforeEach(() => {
37
+ c.clearAllMocks(), r = !1, t.mockImplementation(() => {
38
+ r = !0, e.mockReturnValue(i());
39
+ }), n.mockImplementation(() => {
40
+ r = !1, e.mockReturnValue(i());
41
+ }), e.mockReturnValue(i());
42
+ }), {
43
+ mockOpen: t,
44
+ mockClose: n
45
+ };
46
+ }, h = (n, r) => {
47
+ let i = new l({ defaultOptions: { queries: {
48
+ retry: !1,
49
+ staleTime: Infinity
50
+ } } }), o = r?.AdditionalProviders;
51
+ return {
52
+ result: a(n, { wrapper: ({ children: n }) => /* @__PURE__ */ t(u, {
53
+ client: i,
54
+ children: /* @__PURE__ */ t(e, { children: o ? /* @__PURE__ */ t(o, { children: n }) : n })
55
+ }) }).result,
56
+ queryClient: i
57
+ };
58
+ }, g = (a, o) => {
59
+ let s = new l({ defaultOptions: { queries: {
60
+ retry: !1,
61
+ staleTime: Infinity
62
+ } } }), c = r([{
63
+ path: o?.pattern ?? "*",
64
+ element: a
65
+ }], { initialEntries: o?.initialEntries || ["/"] }), d = o?.AdditionalProviders, f = i(/* @__PURE__ */ t(n, { router: c }), {
66
+ wrapper: ({ children: n }) => /* @__PURE__ */ t(u, {
67
+ client: s,
68
+ children: /* @__PURE__ */ t(e, { children: d ? /* @__PURE__ */ t(d, { children: n }) : n })
69
+ }),
70
+ ...o
71
+ });
72
+ return {
73
+ result: f,
74
+ rerender: (e) => {
75
+ let i = r([{
76
+ path: o?.pattern ?? "*",
77
+ element: e
78
+ }], { initialEntries: o?.initialEntries || ["/"] });
79
+ return f.rerender(/* @__PURE__ */ t(n, { router: i }));
80
+ },
81
+ router: c
82
+ };
83
+ }, _ = (e, t, ...n) => {
84
+ e.setConfig({ baseUrl: t });
85
+ let r = d(...n);
86
+ return beforeAll(() => {
87
+ r.listen({ onUnhandledRequest: "error" });
88
+ }), afterEach(() => {
89
+ r.resetHandlers();
90
+ }), afterAll(() => {
91
+ r.close();
92
+ }), r;
93
+ }, v = (e, t) => {
94
+ let n = c.fn();
95
+ return c.spyOn(e, t).mockImplementation(() => ({
96
+ mutate: n,
97
+ mutateAsync: c.fn(),
98
+ data: void 0,
99
+ variables: void 0,
100
+ error: null,
101
+ isError: !1,
102
+ isPending: !1,
103
+ isIdle: !0,
104
+ isSuccess: !1,
105
+ status: "idle",
106
+ reset: c.fn()
107
+ })), afterEach(() => {
108
+ c.clearAllMocks();
109
+ }), n;
110
+ }, y = async (e = "Loading", t) => await c.waitFor(() => expect(o.queryByText(new RegExp(e, "i"))).not.toBeInTheDocument(), t);
111
+ //#endregion
112
+ export { f as expectTooltipOnHover, p as mockIsPending, m as mockSidePanel, h as renderHookWithProviders, g as renderWithProviders, _ as setupMockServer, v as spyOnMutation, y as waitForLoading };
@@ -1,7 +1,8 @@
1
+ import { Mock } from 'vitest';
1
2
  /**
2
3
  * Mocks the `useSidePanel` hook, returning `mockOpen`/`mockClose` spies.
3
4
  */
4
5
  export declare const mockSidePanel: () => Promise<{
5
- mockOpen: import('vitest').Mock<(...args: any[]) => any>;
6
- mockClose: import('vitest').Mock<(...args: any[]) => any>;
6
+ mockOpen: Mock<(...args: unknown[]) => unknown>;
7
+ mockClose: Mock<(...args: unknown[]) => unknown>;
7
8
  }>;
@@ -1,3 +1,4 @@
1
+ import { Mock } from 'vitest';
1
2
  /**
2
3
  * Spies on a given mutation hook to observe the mutate function.
3
4
  *
@@ -5,4 +6,4 @@
5
6
  * @param methodName - The name of the mutation hook to spy on.
6
7
  * @returns A mock `mutate` function that can be observed with `expect`.
7
8
  */
8
- export declare const spyOnMutation: (obj: unknown, methodName: string) => import('vitest').Mock<(...args: any[]) => any>;
9
+ export declare const spyOnMutation: (obj: unknown, methodName: string) => Mock<(...args: unknown[]) => unknown>;
@@ -0,0 +1,7 @@
1
+ import { ElementType } from 'react';
2
+ export type Prettify<T> = {
3
+ [K in keyof T]: T[K];
4
+ } & {};
5
+ export interface AsProp<C extends ElementType> {
6
+ as?: C;
7
+ }
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/react';
1
+ import { Meta } from '@storybook/react-vite';
2
2
  import { formatBytes } from '..';
3
3
  declare const meta: Meta<typeof formatBytes>;
4
4
  export default meta;
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.7.1",
4
+ "version": "2.7.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/canonical/maas-react-components.git"
@@ -63,14 +63,11 @@
63
63
  "@remix-run/router": "^1.23.3",
64
64
  "@semantic-release/changelog": "^6.0.3",
65
65
  "@semantic-release/git": "^10.0.1",
66
- "@storybook/addon-a11y": "^8.6.12",
67
- "@storybook/addon-essentials": "^8.6.12",
68
- "@storybook/addon-interactions": "^8.6.12",
69
- "@storybook/addon-links": "^8.6.12",
70
- "@storybook/blocks": "^8.6.12",
71
- "@storybook/react": "^8.6.12",
72
- "@storybook/react-vite": "^8.6.12",
73
- "@storybook/theming": "^8.6.12",
66
+ "@storybook/addon-a11y": "^10.5.8",
67
+ "@storybook/addon-docs": "^10.5.8",
68
+ "@storybook/addon-links": "^10.5.8",
69
+ "@storybook/react": "^10.5.8",
70
+ "@storybook/react-vite": "^10.5.8",
74
71
  "@tanstack/react-query": "^5.100.11",
75
72
  "@testing-library/jest-dom": "^6.1.3",
76
73
  "@testing-library/react": "^16.3.0",
@@ -78,7 +75,7 @@
78
75
  "@types/react-dom": "^19.1.3",
79
76
  "@typescript-eslint/eslint-plugin": "^7.0.0",
80
77
  "@typescript-eslint/parser": "^7.0.0",
81
- "@vitejs/plugin-react": "^4.1.0",
78
+ "@vitejs/plugin-react": "^6.0.5",
82
79
  "eslint": "^8.57.1",
83
80
  "eslint-config-prettier": "^9.0.0",
84
81
  "eslint-import-resolver-typescript": "^3.6.1",
@@ -88,7 +85,7 @@
88
85
  "eslint-plugin-prettier": "^5.2.3",
89
86
  "eslint-plugin-react": "^7.33.2",
90
87
  "eslint-plugin-react-hooks": "^4.6.0",
91
- "eslint-plugin-storybook": "^0.12.0",
88
+ "eslint-plugin-storybook": "^10.5.8",
92
89
  "eslint-plugin-unused-imports": "^3.2.0",
93
90
  "jsdom": "^26.0.0",
94
91
  "msw": "^2.14.6",
@@ -99,13 +96,13 @@
99
96
  "react-dom": "^19.1.0",
100
97
  "sass": "^1.85.1",
101
98
  "semantic-release": "^24.2.3",
102
- "storybook": "^8.6.12",
99
+ "storybook": "^10.5.8",
103
100
  "storybook-addon-tags": "^0.0.1",
104
101
  "stylelint": "^15.11.0",
105
102
  "stylelint-config-standard-scss": "^11.1.0",
106
- "vite": "^6.2.1",
103
+ "vite": "^8.0.16",
107
104
  "vite-plugin-dts": "^4.5.3",
108
- "vitest": "^3.0.8"
105
+ "vitest": "^4.1.10"
109
106
  },
110
107
  "overrides": {
111
108
  "@canonical/react-components": {
@@ -127,7 +124,7 @@
127
124
  "react-dom": "^19.1.0",
128
125
  "react-dropzone": "^14.3.8",
129
126
  "react-router": ">=6.0.0",
130
- "vitest": "^3.0.0"
127
+ "vitest": "^4.0.0"
131
128
  },
132
129
  "peerDependenciesMeta": {
133
130
  "@testing-library/react": {