@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.
- package/dist/@canonical/maas-react-components.es.js +2 -689
- package/dist/components/DynamicTable/DynamicTable.d.ts +3 -3
- package/dist/components/DynamicTable/DynamicTable.stories.d.ts +1 -1
- package/dist/components/FileUpload/FileUpload.stories.d.ts +1 -1
- package/dist/components/GenericTable/GenericTable.stories.d.ts +1 -1
- package/dist/components/GenericTable/components/PaginationBar/ControlsBar/ControlsBar.d.ts +2 -2
- package/dist/components/GenericTable/components/TableCheckbox/TableCheckbox.d.ts +2 -2
- package/dist/components/GenericTable/utils/renderDataRows.d.ts +1 -1
- package/dist/components/GenericTable/utils/renderLoadingRows.d.ts +1 -1
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +1 -1
- package/dist/components/NestedFormGroup/NestedFormGroup.d.ts +1 -1
- package/dist/components/NestedFormGroup/NestedFormGroup.stories.d.ts +2 -2
- package/dist/components/Pagination/Pagination.stories.d.ts +3 -3
- package/dist/components/QueryInput/QueryInput.stories.d.ts +1 -1
- package/dist/components/Stepper/Stepper.stories.d.ts +1 -1
- package/dist/components/TableCaption/TableCaption.d.ts +3 -3
- package/dist/components/TableCaption/TableCaption.stories.d.ts +1 -1
- package/dist/constants.d.ts +6 -0
- package/dist/elements/ExternalLink/ExternalLink.d.ts +1 -1
- package/dist/elements/ExternalLink/ExternalLink.stories.d.ts +1 -1
- package/dist/elements/Meter/Meter.d.ts +2 -2
- package/dist/elements/Meter/Meter.stories.d.ts +2 -2
- package/dist/elements/Placeholder/Placeholder.stories.d.ts +1 -1
- package/dist/lib-BEVV6FLF.mjs +2018 -0
- package/dist/maas-react-components.css +2 -1
- package/dist/sections/ContentSection/ContentSection.d.ts +6 -6
- package/dist/sections/ContentSection/ContentSection.stories.d.ts +5 -5
- package/dist/sections/FormSection/FormSection.d.ts +4 -4
- package/dist/sections/FormSection/FormSection.stories.d.ts +3 -3
- package/dist/sections/InputGroup/InputGroup.d.ts +3 -3
- package/dist/sections/InputGroup/InputGroup.stories.d.ts +3 -3
- package/dist/sections/MainToolbar/MainToolbar.d.ts +4 -4
- package/dist/sections/MainToolbar/MainToolbar.stories.d.ts +2 -2
- package/dist/sections/Navigation/Banner/Banner.d.ts +1 -1
- package/dist/sections/Navigation/Banner/Banner.stories.d.ts +2 -2
- package/dist/sections/Navigation/CollapseToggle/CollapseToggle.stories.d.ts +1 -1
- package/dist/sections/Navigation/Content/Content.d.ts +1 -1
- package/dist/sections/Navigation/Content/Content.stories.d.ts +2 -2
- package/dist/sections/Navigation/Controls/Controls.d.ts +1 -1
- package/dist/sections/Navigation/Controls/Controls.stories.d.ts +2 -2
- package/dist/sections/Navigation/Drawer/Drawer.d.ts +1 -1
- package/dist/sections/Navigation/Drawer/Drawer.stories.d.ts +2 -2
- package/dist/sections/Navigation/Footer/Footer.d.ts +1 -1
- package/dist/sections/Navigation/Footer/Footer.stories.d.ts +2 -2
- package/dist/sections/Navigation/Header/Header.d.ts +1 -1
- package/dist/sections/Navigation/Header/Header.stories.d.ts +2 -2
- package/dist/sections/Navigation/Icon/Icon.d.ts +1 -1
- package/dist/sections/Navigation/Icon/Icon.stories.d.ts +1 -1
- package/dist/sections/Navigation/Item/Item.d.ts +1 -1
- package/dist/sections/Navigation/Item/Item.stories.d.ts +3 -3
- package/dist/sections/Navigation/Label/Label.d.ts +1 -1
- package/dist/sections/Navigation/Label/Label.stories.d.ts +1 -1
- package/dist/sections/Navigation/Link/Link.d.ts +2 -2
- package/dist/sections/Navigation/Link/Link.stories.d.ts +3 -3
- package/dist/sections/Navigation/List/List.d.ts +1 -1
- package/dist/sections/Navigation/List/List.stories.d.ts +2 -2
- package/dist/sections/Navigation/Logo/Logo.d.ts +2 -2
- package/dist/sections/Navigation/Logo/Logo.stories.d.ts +2 -2
- package/dist/sections/Navigation/LogoIcon/LogoIcon.stories.d.ts +2 -2
- package/dist/sections/Navigation/LogoName/LogoName.d.ts +1 -1
- package/dist/sections/Navigation/LogoName/LogoName.stories.d.ts +1 -1
- package/dist/sections/Navigation/LogoTag/LogoTag.d.ts +1 -1
- package/dist/sections/Navigation/LogoTag/LogoTag.stories.d.ts +2 -2
- package/dist/sections/Navigation/LogoText/LogoText.d.ts +1 -1
- package/dist/sections/Navigation/MenuButton/MenuButton.d.ts +1 -1
- package/dist/sections/Navigation/MenuButton/MenuButton.stories.d.ts +1 -1
- package/dist/sections/Navigation/Navigation.d.ts +19 -19
- package/dist/sections/Navigation/Navigation.stories.d.ts +3 -3
- package/dist/sections/Navigation/Text/Text.d.ts +1 -1
- package/dist/sections/SidePanel/SidePanel.stories.d.ts +1 -1
- package/dist/testing/index.es.js +112 -129
- package/dist/testing/mockSidePanel.d.ts +3 -2
- package/dist/testing/spyOnMutation.d.ts +2 -1
- package/dist/types.d.ts +7 -0
- package/dist/utils/formatBytes/formatBytes.stories.d.ts +1 -1
- package/package.json +12 -15
- package/dist/QueryInput-D7uXzKgr.mjs +0 -1648
package/dist/testing/index.es.js
CHANGED
|
@@ -1,129 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import "@
|
|
8
|
-
import "
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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:
|
|
6
|
-
mockClose:
|
|
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) =>
|
|
9
|
+
export declare const spyOnMutation: (obj: unknown, methodName: string) => Mock<(...args: unknown[]) => unknown>;
|
package/dist/types.d.ts
ADDED
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.
|
|
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": "^
|
|
67
|
-
"@storybook/addon-
|
|
68
|
-
"@storybook/addon-
|
|
69
|
-
"@storybook/
|
|
70
|
-
"@storybook/
|
|
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": "^
|
|
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": "^
|
|
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": "^
|
|
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": "^
|
|
103
|
+
"vite": "^8.0.16",
|
|
107
104
|
"vite-plugin-dts": "^4.5.3",
|
|
108
|
-
"vitest": "^
|
|
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": "^
|
|
127
|
+
"vitest": "^4.0.0"
|
|
131
128
|
},
|
|
132
129
|
"peerDependenciesMeta": {
|
|
133
130
|
"@testing-library/react": {
|