@simplybusiness/mobius 8.0.1 → 9.0.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 (143) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/cjs/index.js +4773 -0
  3. package/dist/cjs/index.js.map +7 -0
  4. package/dist/cjs/meta.json +4948 -0
  5. package/dist/esm/index.js +542 -694
  6. package/dist/esm/index.js.map +4 -4
  7. package/dist/esm/meta.json +300 -532
  8. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  9. package/dist/types/src/hooks/index.d.ts +0 -7
  10. package/dist/types/src/utils/htmlDialogPolyfill.d.ts +1 -0
  11. package/dist/types/src/utils/index.d.ts +0 -1
  12. package/dist/types/src/utils/mockMatchMedia.d.ts +1 -0
  13. package/dist/types/vitest.config.d.ts +2 -0
  14. package/package.json +14 -18
  15. package/src/components/Accordion/Accordion.stories.tsx +1 -1
  16. package/src/components/Accordion/Accordion.test.tsx +12 -12
  17. package/src/components/Accordion/Accordion.tsx +1 -1
  18. package/src/components/Accordion/AccordionList.stories.tsx +1 -1
  19. package/src/components/Accordion/AccordionList.test.tsx +6 -6
  20. package/src/components/AddressLookup/AddressLookup.stories.tsx +1 -1
  21. package/src/components/AddressLookup/AddressLookup.test.tsx +19 -20
  22. package/src/components/AddressLookup/LoqateAddressLookupService.test.tsx +7 -6
  23. package/src/components/Alert/Alert.stories.tsx +1 -1
  24. package/src/components/Box/Box.stories.tsx +1 -1
  25. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
  26. package/src/components/Button/Button.stories.tsx +3 -4
  27. package/src/components/Button/Button.test.tsx +4 -4
  28. package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
  29. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  30. package/src/components/Checkbox/CheckboxGroup.stories.tsx +1 -1
  31. package/src/components/Checkbox/CheckboxGroup.test.tsx +5 -5
  32. package/src/components/Combobox/Combobox.stories.tsx +1 -1
  33. package/src/components/Combobox/Combobox.test.tsx +67 -78
  34. package/src/components/Combobox/Combobox.tsx +2 -1
  35. package/src/components/Combobox/useComboboxOptions.test.ts +30 -30
  36. package/src/components/Combobox/useComboboxOptions.ts +1 -1
  37. package/src/components/Container/Container.stories.tsx +1 -1
  38. package/src/components/DateField/DateField.stories.tsx +1 -1
  39. package/src/components/DateField/DateField.test.tsx +1 -1
  40. package/src/components/Divider/Divider.stories.tsx +1 -1
  41. package/src/components/Drawer/Drawer.stories.tsx +1 -1
  42. package/src/components/Drawer/Drawer.test.tsx +6 -6
  43. package/src/components/DropdownMenu/DropdownMenu.stories.tsx +8 -10
  44. package/src/components/DropdownMenu/DropdownMenu.test.tsx +1 -1
  45. package/src/components/ErrorMessage/ErrorMessage.stories.tsx +1 -1
  46. package/src/components/ExpandableText/ExpandableText.test.tsx +14 -14
  47. package/src/components/Fieldset/Fieldset.stories.tsx +1 -1
  48. package/src/components/Flex/Flex.stories.tsx +1 -1
  49. package/src/components/Grid/Grid.stories.tsx +4 -7
  50. package/src/components/Icon/Icon.stories.tsx +1 -1
  51. package/src/components/Image/Image.stories.tsx +1 -1
  52. package/src/components/Label/Label.stories.tsx +1 -1
  53. package/src/components/Link/Link.stories.tsx +1 -1
  54. package/src/components/Link/Link.test.tsx +1 -1
  55. package/src/components/LinkButton/LinkButton.stories.tsx +1 -1
  56. package/src/components/LinkButton/LinkButton.test.tsx +2 -2
  57. package/src/components/List/List.stories.tsx +1 -1
  58. package/src/components/LoadingIndicator/LoadingIndicator.stories.tsx +1 -1
  59. package/src/components/Logo/Logo.stories.tsx +1 -1
  60. package/src/components/Modal/Modal.stories.tsx +1 -1
  61. package/src/components/Modal/Modal.test.tsx +6 -6
  62. package/src/components/NumberField/NumberField.stories.tsx +1 -1
  63. package/src/components/NumberField/NumberField.test.tsx +5 -5
  64. package/src/components/PasswordField/PasswordField.stories.tsx +1 -1
  65. package/src/components/Popover/Popover.stories.tsx +4 -8
  66. package/src/components/Popover/Popover.test.tsx +4 -4
  67. package/src/components/Popover/Popover.tsx +1 -1
  68. package/src/components/Progress/Progress.stories.tsx +1 -1
  69. package/src/components/Radio/Radio.stories.tsx +1 -1
  70. package/src/components/Radio/Radio.test.tsx +9 -9
  71. package/src/components/SVG/SVG.stories.tsx +1 -1
  72. package/src/components/Segment/Segment.stories.tsx +1 -1
  73. package/src/components/Select/Select.stories.tsx +1 -1
  74. package/src/components/Select/Select.test.tsx +1 -1
  75. package/src/components/Slider/Slider.stories.tsx +1 -1
  76. package/src/components/Slider/Slider.test.tsx +6 -6
  77. package/src/components/Slider/helpers.test.ts +1 -1
  78. package/src/components/Stack/Stack.stories.tsx +1 -1
  79. package/src/components/Switch/Switch.stories.tsx +1 -1
  80. package/src/components/Switch/Switch.test.tsx +1 -1
  81. package/src/components/Table/Table.stories.tsx +1 -1
  82. package/src/components/Text/Text.stories.tsx +1 -1
  83. package/src/components/TextArea/TextArea.stories.tsx +1 -1
  84. package/src/components/TextArea/TextArea.test.tsx +3 -3
  85. package/src/components/TextField/TextField.stories.tsx +1 -1
  86. package/src/components/TextOrHTML/TextOrHTML.stories.tsx +1 -1
  87. package/src/components/Title/Title.stories.tsx +1 -1
  88. package/src/components/Toast/Toast.stories.tsx +1 -1
  89. package/src/components/Toast/Toast.test.tsx +6 -6
  90. package/src/components/Trust/Trust.stories.tsx +1 -1
  91. package/src/components/VisuallyHidden/VisuallyHidden.stories.tsx +1 -1
  92. package/src/hooks/index.tsx +0 -7
  93. package/src/hooks/useBreakpoint/useBreakpoint.ssr.test.tsx +18 -0
  94. package/src/hooks/useBreakpoint/useBreakpoint.stories.tsx +1 -1
  95. package/src/hooks/useBreakpoint/useBreakpoint.test.tsx +65 -5
  96. package/src/hooks/useBreakpoint/useBreakpoint.tsx +25 -39
  97. package/src/hooks/useButton/useButton.test.tsx +4 -4
  98. package/src/hooks/useDialog/useDialog.ts +1 -1
  99. package/src/hooks/useLabel/useLabel.test.tsx +1 -1
  100. package/src/hooks/useTextField/useTextField.test.tsx +4 -4
  101. package/src/public-whitelist.test.ts +1 -0
  102. package/src/utils/delay.test.ts +4 -4
  103. package/src/utils/{jestHTMLDialogPolyfill.ts → htmlDialogPolyfill.ts} +5 -5
  104. package/src/utils/index.ts +0 -1
  105. package/src/utils/mockMatchMedia.ts +16 -0
  106. package/dist/types/src/hooks/useBodyScrollLock/index.d.ts +0 -1
  107. package/dist/types/src/hooks/useBodyScrollLock/useBodyScrollLock.d.ts +0 -3
  108. package/dist/types/src/hooks/useDebouncedValue/index.d.ts +0 -1
  109. package/dist/types/src/hooks/useDebouncedValue/useDebouncedValue.d.ts +0 -1
  110. package/dist/types/src/hooks/useOnClickOutside/index.d.ts +0 -1
  111. package/dist/types/src/hooks/useOnClickOutside/useOnClickOutside.d.ts +0 -2
  112. package/dist/types/src/hooks/useOnUnmount/index.d.ts +0 -1
  113. package/dist/types/src/hooks/useOnUnmount/useOnUnmount.d.ts +0 -1
  114. package/dist/types/src/hooks/usePrefersReducedMotion/index.d.ts +0 -1
  115. package/dist/types/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.d.ts +0 -1
  116. package/dist/types/src/hooks/useRenderCount/index.d.ts +0 -1
  117. package/dist/types/src/hooks/useRenderCount/useRenderCount.d.ts +0 -1
  118. package/dist/types/src/hooks/useWindowEvent/index.d.ts +0 -1
  119. package/dist/types/src/hooks/useWindowEvent/useWindowEvent.d.ts +0 -1
  120. package/dist/types/src/utils/jestHTMLDialogPolyfill.d.ts +0 -1
  121. package/dist/types/src/utils/jestMockMatchMedia.d.ts +0 -1
  122. package/src/hooks/useBodyScrollLock/index.ts +0 -1
  123. package/src/hooks/useBodyScrollLock/useBodyScrollLock.test.ts +0 -34
  124. package/src/hooks/useBodyScrollLock/useBodyScrollLock.ts +0 -30
  125. package/src/hooks/useDebouncedValue/index.tsx +0 -1
  126. package/src/hooks/useDebouncedValue/useDebouncedValue.test.tsx +0 -62
  127. package/src/hooks/useDebouncedValue/useDebouncedValue.tsx +0 -25
  128. package/src/hooks/useOnClickOutside/index.tsx +0 -1
  129. package/src/hooks/useOnClickOutside/useOnClickOutside.test.tsx +0 -189
  130. package/src/hooks/useOnClickOutside/useOnClickOutside.tsx +0 -44
  131. package/src/hooks/useOnUnmount/index.tsx +0 -1
  132. package/src/hooks/useOnUnmount/useOnUnmount.test.tsx +0 -37
  133. package/src/hooks/useOnUnmount/useOnUnmount.tsx +0 -8
  134. package/src/hooks/usePrefersReducedMotion/index.tsx +0 -1
  135. package/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.test.tsx +0 -48
  136. package/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.tsx +0 -22
  137. package/src/hooks/useRenderCount/index.ts +0 -1
  138. package/src/hooks/useRenderCount/useRenderCount.test.ts +0 -26
  139. package/src/hooks/useRenderCount/useRenderCount.ts +0 -9
  140. package/src/hooks/useWindowEvent/index.tsx +0 -1
  141. package/src/hooks/useWindowEvent/useWindowEvent.test.tsx +0 -188
  142. package/src/hooks/useWindowEvent/useWindowEvent.tsx +0 -41
  143. package/src/utils/jestMockMatchMedia.ts +0 -16
@@ -147,7 +147,7 @@ describe("DateField", () => {
147
147
 
148
148
  describe("DateField validation on blur", () => {
149
149
  it("calls onBlur handler with correct event on blur", async () => {
150
- const handleChange = jest.fn();
150
+ const handleChange = vi.fn();
151
151
 
152
152
  render(
153
153
  <DateField
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { StoryContainer } from "../../utils/StoryContainer";
3
3
  import type { DividerProps } from "./Divider";
4
4
  import { Divider } from "./Divider";
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { useState } from "react";
3
3
  import type { DrawerProps } from ".";
4
4
  import { Drawer } from ".";
@@ -2,10 +2,10 @@ import { render, screen, waitFor } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
  import { useState } from "react";
4
4
  import { Drawer } from ".";
5
- import { jestHTMLDialogPolyfill } from "../../utils/jestHTMLDialogPolyfill";
6
- import { jestMockMatchMedia } from "../../utils/jestMockMatchMedia";
5
+ import { htmlDialogPolyfill } from "../../utils/htmlDialogPolyfill";
6
+ import { mockMatchMedia } from "../../utils/mockMatchMedia";
7
7
 
8
- jestHTMLDialogPolyfill();
8
+ htmlDialogPolyfill();
9
9
 
10
10
  const DRAWER_CLASS_NAME = "mobius-drawer";
11
11
  const DRAWER_CLOSE_CLASS_NAME = "mobius-drawer__close";
@@ -13,11 +13,11 @@ const DRAWER_TEST_CLASS_NAME = "my-test-class-name";
13
13
 
14
14
  describe("Drawer", () => {
15
15
  beforeEach(() => {
16
- jestMockMatchMedia(true);
16
+ mockMatchMedia(true);
17
17
  });
18
18
 
19
19
  afterAll(() => {
20
- jest.resetAllMocks();
20
+ vi.resetAllMocks();
21
21
  });
22
22
 
23
23
  it("should render without errors", () => {
@@ -158,7 +158,7 @@ describe("Drawer", () => {
158
158
  });
159
159
 
160
160
  it("should fire onOpen callback if supplied", async () => {
161
- const onOpen = jest.fn();
161
+ const onOpen = vi.fn();
162
162
 
163
163
  const App = () => {
164
164
  const [isOpen, setIsOpen] = useState<boolean>(false);
@@ -1,5 +1,5 @@
1
1
  import { chevronDown } from "@simplybusiness/icons";
2
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
3
  import classNames from "classnames/dedupe";
4
4
  import type { Ref } from "react";
5
5
  import type { DropdownMenuProps } from ".";
@@ -7,6 +7,8 @@ import { DropdownMenu } from ".";
7
7
  import { excludeControls } from "../../utils";
8
8
  import { StoryContainer } from "../../utils/StoryContainer";
9
9
  import { Icon } from "../Icon";
10
+ // eslint-disable-next-line no-restricted-imports -- story-only styles
11
+ import "./DropdownMenu.story.styles.css";
10
12
 
11
13
  type StoryType = StoryObj<typeof DropdownMenu>;
12
14
 
@@ -15,15 +17,11 @@ const meta: Meta<typeof DropdownMenu> = {
15
17
  component: DropdownMenu,
16
18
  argTypes: excludeControls("trigger", "style"),
17
19
  decorators: [
18
- Story => {
19
- require("./DropdownMenu.story.styles.css");
20
-
21
- return (
22
- <StoryContainer>
23
- <Story />
24
- </StoryContainer>
25
- );
26
- },
20
+ Story => (
21
+ <StoryContainer>
22
+ <Story />
23
+ </StoryContainer>
24
+ ),
27
25
  ],
28
26
  };
29
27
 
@@ -67,7 +67,7 @@ describe("DropdownMenu", () => {
67
67
  });
68
68
 
69
69
  it("should use the onClick handler on menu item", () => {
70
- const customHandler = jest.fn();
70
+ const customHandler = vi.fn();
71
71
 
72
72
  render(
73
73
  <DropdownMenu>
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { ErrorMessageProps } from ".";
3
3
  import { ErrorMessage } from ".";
4
4
 
@@ -5,27 +5,27 @@ import { ExpandableText } from "./ExpandableText";
5
5
  // Mock window.matchMedia for usePrefersReducedMotion
6
6
  Object.defineProperty(window, "matchMedia", {
7
7
  writable: true,
8
- value: jest.fn().mockImplementation(query => ({
8
+ value: vi.fn().mockImplementation(query => ({
9
9
  matches: false,
10
10
  media: query,
11
11
  onchange: null,
12
- addListener: jest.fn(), // deprecated
13
- removeListener: jest.fn(), // deprecated
14
- addEventListener: jest.fn(),
15
- removeEventListener: jest.fn(),
16
- dispatchEvent: jest.fn(),
12
+ addListener: vi.fn(), // deprecated
13
+ removeListener: vi.fn(), // deprecated
14
+ addEventListener: vi.fn(),
15
+ removeEventListener: vi.fn(),
16
+ dispatchEvent: vi.fn(),
17
17
  })),
18
18
  });
19
19
 
20
20
  // Mock useBreakpoint hook
21
21
  const mockBreakpoint = {
22
- down: jest.fn(),
23
- up: jest.fn(),
24
- only: jest.fn(),
25
- between: jest.fn(),
22
+ down: vi.fn(),
23
+ up: vi.fn(),
24
+ only: vi.fn(),
25
+ between: vi.fn(),
26
26
  };
27
27
 
28
- jest.mock("../../hooks/useBreakpoint", () => ({
28
+ vi.mock("../../hooks/useBreakpoint", () => ({
29
29
  useBreakpoint: () => mockBreakpoint,
30
30
  }));
31
31
 
@@ -35,7 +35,7 @@ describe("ExpandableText", () => {
35
35
  const shortText = "Short text.";
36
36
 
37
37
  beforeEach(() => {
38
- jest.clearAllMocks();
38
+ vi.clearAllMocks();
39
39
  mockBreakpoint.down.mockReturnValue(true);
40
40
 
41
41
  // Mock scrollHeight and clientHeight to simulate truncation
@@ -161,7 +161,7 @@ describe("ExpandableText", () => {
161
161
 
162
162
  it("calls onToggle callback when state changes", async () => {
163
163
  const user = userEvent.setup();
164
- const onToggle = jest.fn();
164
+ const onToggle = vi.fn();
165
165
  render(<ExpandableText text={longText} onToggle={onToggle} />);
166
166
 
167
167
  const readMoreButton = await screen.findByRole("button");
@@ -217,7 +217,7 @@ describe("ExpandableText", () => {
217
217
 
218
218
  it("prevents event propagation on accordion click", async () => {
219
219
  const user = userEvent.setup();
220
- const containerClickHandler = jest.fn();
220
+ const containerClickHandler = vi.fn();
221
221
 
222
222
  render(
223
223
  <div onClick={containerClickHandler}>
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { excludeControls } from "../../utils";
3
3
  import { StoryContainer } from "../../utils/StoryContainer";
4
4
  import { TextField } from "../TextField";
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { CSSProperties, ReactNode } from "react";
3
3
  import { Flex } from "./Flex";
4
4
  import { Box } from "../Box";
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { ReactNode } from "react";
3
3
  import type { GridItemProps, GridProps } from ".";
4
4
  import { Grid } from ".";
@@ -6,6 +6,8 @@ import { Box } from "../Box";
6
6
  import { Flex } from "../Flex";
7
7
  import type { GridItem } from "./Item";
8
8
  import { sizeOptions } from "../../utils";
9
+ // eslint-disable-next-line no-restricted-imports -- story-only styles
10
+ import "./Grid.story.styles.css";
9
11
 
10
12
  type StoryType = StoryObj<typeof Grid>;
11
13
 
@@ -68,12 +70,7 @@ const meta: Meta<typeof Grid> = {
68
70
  options: ["", "start", "end", "center", "stretch"],
69
71
  },
70
72
  },
71
- decorators: [
72
- Story => {
73
- require("./Grid.story.styles.css");
74
- return <Story />;
75
- },
76
- ],
73
+ decorators: [Story => <Story />],
77
74
  };
78
75
 
79
76
  type SharedProps = {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import * as baseIcons from "@simplybusiness/icons";
3
3
  import "@simplybusiness/icons/iconfont";
4
4
  import { Icon } from "./Icon";
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { ImageProps } from "./Image";
3
3
  import { Image } from "./Image";
4
4
  import testImg from "./test-image.png";
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { LabelProps } from "./Label";
3
3
  import { Label } from "./Label";
4
4
 
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { LinkProps } from "./Link";
3
3
  import { Link } from "./Link";
4
4
  import { excludeControls } from "../../utils";
@@ -10,7 +10,7 @@ describe("Test for Link", () => {
10
10
  });
11
11
 
12
12
  it("should call the onClick", async () => {
13
- const onClick = jest.fn();
13
+ const onClick = vi.fn();
14
14
  render(
15
15
  <Link href="#test" onClick={onClick}>
16
16
  Click
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { LinkButtonProps } from "./LinkButton";
3
3
  import { LinkButton } from "./LinkButton";
4
4
  import { excludeControls } from "../../utils";
@@ -48,7 +48,7 @@ describe("Test for LinkButton", () => {
48
48
  });
49
49
 
50
50
  it("should call onClick callback if supplied", async () => {
51
- const onClick = jest.fn();
51
+ const onClick = vi.fn();
52
52
  render(
53
53
  <LinkButton href="#" onClick={onClick}>
54
54
  Link
@@ -59,7 +59,7 @@ describe("Test for LinkButton", () => {
59
59
  });
60
60
 
61
61
  it("throws when href is empty", () => {
62
- const spy = jest.spyOn(console, "error");
62
+ const spy = vi.spyOn(console, "error");
63
63
  spy.mockImplementation(() => {});
64
64
 
65
65
  render(
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { cross, tick } from "@simplybusiness/icons";
3
3
  import { Icon, Text } from "../index";
4
4
  import type { ListProps } from ".";
@@ -1,5 +1,5 @@
1
1
  import { home, loading, refreshArrow } from "@simplybusiness/icons";
2
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
3
  import type { LoadingIndicatorProps } from "./LoadingIndicator";
4
4
  import { LoadingIndicator } from "./LoadingIndicator";
5
5
 
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { LogoProps } from "..";
3
3
  import { Logo } from "..";
4
4
  import { excludeControls } from "../../utils";
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { useState } from "react";
3
3
  import type { ModalProps } from ".";
4
4
  import { Modal } from ".";
@@ -2,10 +2,10 @@ import { useState } from "react";
2
2
  import { render, screen, waitFor } from "@testing-library/react";
3
3
  import userEvent from "@testing-library/user-event";
4
4
  import { Modal } from ".";
5
- import { jestHTMLDialogPolyfill } from "../../utils/jestHTMLDialogPolyfill";
6
- import { jestMockMatchMedia } from "../../utils/jestMockMatchMedia";
5
+ import { htmlDialogPolyfill } from "../../utils/htmlDialogPolyfill";
6
+ import { mockMatchMedia } from "../../utils/mockMatchMedia";
7
7
 
8
- jestHTMLDialogPolyfill();
8
+ htmlDialogPolyfill();
9
9
 
10
10
  const MODAL_CLASS_NAME = "mobius-modal";
11
11
  const MODAL_CLOSE_CLASS_NAME = "mobius-modal__close";
@@ -13,11 +13,11 @@ const MODAL_TEST_CLASS_NAME = "my-test-class-name";
13
13
 
14
14
  describe("Modal", () => {
15
15
  beforeEach(() => {
16
- jestMockMatchMedia(true);
16
+ mockMatchMedia(true);
17
17
  });
18
18
 
19
19
  afterAll(() => {
20
- jest.resetAllMocks();
20
+ vi.resetAllMocks();
21
21
  });
22
22
 
23
23
  it("should render without errors", () => {
@@ -153,7 +153,7 @@ describe("Modal", () => {
153
153
  });
154
154
 
155
155
  it("should fire onOpen callback if supplied", async () => {
156
- const onOpen = jest.fn();
156
+ const onOpen = vi.fn();
157
157
 
158
158
  const App = () => {
159
159
  const [isOpen, setIsOpen] = useState<boolean>(false);
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { excludeControls } from "../../utils";
3
3
  import { StoryContainer } from "../../utils/StoryContainer";
4
4
  import type { NumberFieldProps } from "./NumberField";
@@ -120,7 +120,7 @@ describe("NumberField", () => {
120
120
  });
121
121
 
122
122
  it("prevents setting a value < minValue (if set)", () => {
123
- const mockChange = jest.fn();
123
+ const mockChange = vi.fn();
124
124
  render(
125
125
  <NumberField
126
126
  id="test"
@@ -145,7 +145,7 @@ describe("NumberField", () => {
145
145
  });
146
146
 
147
147
  it("prevents setting a value > maxValue (if set)", () => {
148
- const mockChange = jest.fn();
148
+ const mockChange = vi.fn();
149
149
  render(
150
150
  <NumberField
151
151
  id="test"
@@ -170,7 +170,7 @@ describe("NumberField", () => {
170
170
  });
171
171
 
172
172
  it("validates step increments on blur", () => {
173
- const mockChange = jest.fn();
173
+ const mockChange = vi.fn();
174
174
  render(
175
175
  <NumberField
176
176
  id="test"
@@ -193,7 +193,7 @@ describe("NumberField", () => {
193
193
  });
194
194
 
195
195
  it("allows any values during typing (including invalid step increments)", () => {
196
- const mockChange = jest.fn();
196
+ const mockChange = vi.fn();
197
197
  render(
198
198
  <NumberField
199
199
  id="test"
@@ -219,7 +219,7 @@ describe("NumberField", () => {
219
219
  });
220
220
 
221
221
  it("allows typing intermediate values to reach final valid step value", () => {
222
- const mockChange = jest.fn();
222
+ const mockChange = vi.fn();
223
223
  render(
224
224
  <NumberField
225
225
  id="test"
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { excludeControls } from "../../utils";
3
3
  import { StoryContainer } from "../../utils/StoryContainer";
4
4
  import type { PasswordFieldProps } from "./PasswordField";
@@ -1,8 +1,10 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { circleQuestion } from "@simplybusiness/icons";
3
3
  import type { PopoverProps } from "..";
4
4
  import { Button, Flex, Popover, Icon } from "..";
5
5
  import { excludeControls } from "../../utils";
6
+ // eslint-disable-next-line no-restricted-imports -- story-only styles
7
+ import "./Popover.story.styles.css";
6
8
 
7
9
  type StoryType = StoryObj<typeof Popover>;
8
10
 
@@ -12,13 +14,7 @@ const meta: Meta<typeof Popover> = {
12
14
  argTypes: {
13
15
  ...excludeControls("trigger", "anchor", "children"),
14
16
  },
15
- decorators: [
16
- Story => {
17
- require("./Popover.story.styles.css");
18
-
19
- return <Story />;
20
- },
21
- ],
17
+ decorators: [Story => <Story />],
22
18
  };
23
19
 
24
20
  export const Default: StoryType = {
@@ -131,8 +131,8 @@ describe("Popover", () => {
131
131
  it("calls onOpen when Popover is opened", async () => {
132
132
  const sampleText = "Sample Text";
133
133
  const triggerText = "Click me";
134
- const onOpen = jest.fn();
135
- const onClose = jest.fn();
134
+ const onOpen = vi.fn();
135
+ const onClose = vi.fn();
136
136
 
137
137
  render(
138
138
  <Popover
@@ -157,8 +157,8 @@ describe("Popover", () => {
157
157
  it("calls onClose when Popover is closed", async () => {
158
158
  const sampleText = "Sample Text";
159
159
  const triggerText = "Click me";
160
- const onOpen = jest.fn();
161
- const onClose = jest.fn();
160
+ const onOpen = vi.fn();
161
+ const onClose = vi.fn();
162
162
 
163
163
  render(
164
164
  <Popover
@@ -13,7 +13,7 @@ import { cross } from "@simplybusiness/icons";
13
13
  import classNames from "classnames/dedupe";
14
14
  import type { ReactElement, ReactNode, RefAttributes } from "react";
15
15
  import { cloneElement, useRef, useState } from "react";
16
- import { useWindowEvent } from "../../hooks";
16
+ import { useWindowEvent } from "@simplybusiness/mobius-hooks";
17
17
  import type { DOMProps } from "../../types";
18
18
  import { Button } from "../Button";
19
19
  import { Icon } from "../Icon";
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { excludeControls } from "../../utils";
3
3
  import { StoryContainer } from "../../utils/StoryContainer";
4
4
  import type { ProgressProps } from "./Progress";
@@ -1,5 +1,5 @@
1
1
  import { rocketLaunch, screwdriverWrench, truck } from "@simplybusiness/icons";
2
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
3
  import { excludeControls } from "../../utils";
4
4
  import { StoryContainer } from "../../utils/StoryContainer";
5
5
  import { Divider } from "../Divider";
@@ -242,7 +242,7 @@ describe("Radio", () => {
242
242
  });
243
243
 
244
244
  it("should call onChange with the selected value when clicked", async () => {
245
- const callback = jest.fn();
245
+ const callback = vi.fn();
246
246
  const handleChange = (e: HTMLElementEvent<HTMLInputElement>) => {
247
247
  callback(e.target.value);
248
248
  };
@@ -271,7 +271,7 @@ describe("Radio", () => {
271
271
  });
272
272
 
273
273
  it("should be selectable via keyboard", async () => {
274
- const callback = jest.fn();
274
+ const callback = vi.fn();
275
275
  const redOptionText = "Red";
276
276
  const blueOptionText = "Blue";
277
277
  const redOptionValue = redOptionText.toLowerCase();
@@ -424,7 +424,7 @@ describe("Radio", () => {
424
424
  });
425
425
 
426
426
  it("sets classes for interaction states", async () => {
427
- const callback = jest.fn();
427
+ const callback = vi.fn();
428
428
  render(
429
429
  <RadioGroup label="Color" onChange={callback}>
430
430
  <Radio value="red">Red</Radio>
@@ -766,7 +766,7 @@ describe("when first child is not an Icon", () => {
766
766
 
767
767
  describe("controlled vs uncontrolled RadioGroup onChange behavior", () => {
768
768
  it("should call onChange exactly once when a radio button is clicked in controlled mode", async () => {
769
- const onChange = jest.fn();
769
+ const onChange = vi.fn();
770
770
  const redValue = "red";
771
771
  const blueValue = "blue";
772
772
 
@@ -797,7 +797,7 @@ describe("controlled vs uncontrolled RadioGroup onChange behavior", () => {
797
797
  });
798
798
 
799
799
  it("should call onChange exactly once when a radio button is clicked in uncontrolled mode", async () => {
800
- const onChange = jest.fn();
800
+ const onChange = vi.fn();
801
801
  const redValue = "red";
802
802
  const blueValue = "blue";
803
803
 
@@ -876,7 +876,7 @@ describe.skip("focus behavior", () => {
876
876
  describe("overflow detection", () => {
877
877
  describe("Radio onOverflow callback", () => {
878
878
  it("should call onOverflow with vertical overflow when content height exceeds container", () => {
879
- const onOverflow = jest.fn();
879
+ const onOverflow = vi.fn();
880
880
 
881
881
  const { container, rerender } = render(
882
882
  <Radio value="test" label="Test Label" onOverflow={onOverflow} />,
@@ -905,7 +905,7 @@ describe("overflow detection", () => {
905
905
  });
906
906
 
907
907
  it("should call onOverflow with horizontal overflow when content width exceeds container", () => {
908
- const onOverflow = jest.fn();
908
+ const onOverflow = vi.fn();
909
909
 
910
910
  const { container, rerender } = render(
911
911
  <Radio value="test" label="Test Label" onOverflow={onOverflow} />,
@@ -939,7 +939,7 @@ describe("overflow detection", () => {
939
939
  });
940
940
 
941
941
  it("should call onOverflow with both overflow types when content exceeds in both dimensions", () => {
942
- const onOverflow = jest.fn();
942
+ const onOverflow = vi.fn();
943
943
 
944
944
  const { container, rerender } = render(
945
945
  <Radio value="test" label="Test Label" onOverflow={onOverflow} />,
@@ -973,7 +973,7 @@ describe("overflow detection", () => {
973
973
  });
974
974
 
975
975
  it("should not call onOverflow when content fits within container and state has not changed", () => {
976
- const onOverflow = jest.fn();
976
+ const onOverflow = vi.fn();
977
977
 
978
978
  const { container, rerender } = render(
979
979
  <Radio value="test" label="Test Label" onOverflow={onOverflow} />,
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { SVGProps } from "./SVG";
3
3
  import { SVG } from "./SVG";
4
4
 
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import type { SegmentProps } from "./Segment";
3
3
  import { Segment } from "./Segment";
4
4
  import type { SegmentGroupProps } from "./SegmentGroup";
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { StoryContainer } from "../../utils/StoryContainer";
3
3
  import { Option } from "../Option";
4
4
  import type { SelectProps } from "./Select";
@@ -19,7 +19,7 @@ describe("Select", () => {
19
19
  });
20
20
 
21
21
  it("should call onChange when clicked", async () => {
22
- const valueCallback = jest.fn();
22
+ const valueCallback = vi.fn();
23
23
  const callback = (e: ChangeEvent<HTMLSelectElement>) =>
24
24
  valueCallback(e.target.value);
25
25
  const { getByLabelText } = render(
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/react-webpack5";
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { excludeControls } from "../../utils";
3
3
  import { StoryContainer } from "../../utils/StoryContainer";
4
4
  import type { SliderProps } from "./Slider";
@@ -55,8 +55,8 @@ describe("Slider", () => {
55
55
  */
56
56
  describe("events", () => {
57
57
  it("should call events on input change", async () => {
58
- const onChange = jest.fn();
59
- const onChangeEnd = jest.fn();
58
+ const onChange = vi.fn();
59
+ const onChangeEnd = vi.fn();
60
60
 
61
61
  const { container } = render(
62
62
  <Slider
@@ -82,8 +82,8 @@ describe("Slider", () => {
82
82
  });
83
83
 
84
84
  it("should not call onChange when value is already min", async () => {
85
- const onChange = jest.fn();
86
- const onChangeEnd = jest.fn();
85
+ const onChange = vi.fn();
86
+ const onChangeEnd = vi.fn();
87
87
 
88
88
  const { container } = render(
89
89
  <Slider
@@ -105,8 +105,8 @@ describe("Slider", () => {
105
105
  });
106
106
 
107
107
  it("should not call onChange when value is already max", async () => {
108
- const onChange = jest.fn();
109
- const onChangeEnd = jest.fn();
108
+ const onChange = vi.fn();
109
+ const onChangeEnd = vi.fn();
110
110
 
111
111
  const { container } = render(
112
112
  <Slider