From 6a08b8217138f8ba232bfb1738067a02cb45ac3f Mon Sep 17 00:00:00 2001 From: Josh Wooding <12938082+joshwooding@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:06:29 +0000 Subject: [PATCH] Fix circular dependencies (#4396) --- .changeset/stupid-pets-shout.md | 6 ++++++ packages/core/src/aria-announcer/useAriaAnnouncer.ts | 2 +- packages/core/src/breakpoints/BreakpointProvider.tsx | 3 ++- packages/core/src/salt-provider/SaltProvider.tsx | 2 +- packages/core/src/utils/useValueEffect.ts | 2 +- packages/core/src/viewport/ViewportProvider.tsx | 2 +- packages/lab/src/date-picker/DatePickerActions.tsx | 2 +- packages/lab/src/date-picker/DatePickerSinglePanel.tsx | 2 +- packages/lab/src/responsive/useOverflowLayout.ts | 5 ++++- packages/lab/src/window/ElectronWindow.tsx | 6 +++++- 10 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 .changeset/stupid-pets-shout.md diff --git a/.changeset/stupid-pets-shout.md b/.changeset/stupid-pets-shout.md new file mode 100644 index 00000000000..d02a2cd7ad1 --- /dev/null +++ b/.changeset/stupid-pets-shout.md @@ -0,0 +1,6 @@ +--- +"@salt-ds/core": patch +"@salt-ds/lab": patch +--- + +Fixed circular dependencies in code. diff --git a/packages/core/src/aria-announcer/useAriaAnnouncer.ts b/packages/core/src/aria-announcer/useAriaAnnouncer.ts index d3874909418..cf3618cff81 100644 --- a/packages/core/src/aria-announcer/useAriaAnnouncer.ts +++ b/packages/core/src/aria-announcer/useAriaAnnouncer.ts @@ -1,5 +1,5 @@ import { useCallback, useContext, useEffect, useMemo, useRef } from "react"; -import { debounce } from "../utils"; +import { debounce } from "../utils/debounce"; import { type AriaAnnouncer, AriaAnnouncerContext, diff --git a/packages/core/src/breakpoints/BreakpointProvider.tsx b/packages/core/src/breakpoints/BreakpointProvider.tsx index b2d871b078b..f23753db042 100644 --- a/packages/core/src/breakpoints/BreakpointProvider.tsx +++ b/packages/core/src/breakpoints/BreakpointProvider.tsx @@ -1,5 +1,6 @@ import { type ReactNode, useContext, useState } from "react"; -import { createContext, useIsomorphicLayoutEffect } from "../utils"; +import { createContext } from "../utils/createContext"; +import { useIsomorphicLayoutEffect } from "../utils/useIsomorphicLayoutEffect"; import type { Breakpoints } from "./Breakpoints"; type Breakpoint = keyof Breakpoints; diff --git a/packages/core/src/salt-provider/SaltProvider.tsx b/packages/core/src/salt-provider/SaltProvider.tsx index 1098a4a4116..fbc26f5d69c 100644 --- a/packages/core/src/salt-provider/SaltProvider.tsx +++ b/packages/core/src/salt-provider/SaltProvider.tsx @@ -30,7 +30,7 @@ import type { Mode, ThemeName, } from "../theme"; -import { useIsomorphicLayoutEffect } from "../utils"; +import { useIsomorphicLayoutEffect } from "../utils/useIsomorphicLayoutEffect"; import { ViewportProvider } from "../viewport"; import saltProviderCss from "./SaltProvider.css"; diff --git a/packages/core/src/utils/useValueEffect.ts b/packages/core/src/utils/useValueEffect.ts index 02b60b61531..3186e26dc01 100644 --- a/packages/core/src/utils/useValueEffect.ts +++ b/packages/core/src/utils/useValueEffect.ts @@ -11,8 +11,8 @@ */ import { type Dispatch, type MutableRefObject, useRef, useState } from "react"; -import { useIsomorphicLayoutEffect } from "../index"; import { useEventCallback } from "./useEventCallback"; +import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect"; type SetValueAction = (prev: S) => Generator; diff --git a/packages/core/src/viewport/ViewportProvider.tsx b/packages/core/src/viewport/ViewportProvider.tsx index 90b1cebc130..5c936b238fe 100644 --- a/packages/core/src/viewport/ViewportProvider.tsx +++ b/packages/core/src/viewport/ViewportProvider.tsx @@ -1,5 +1,5 @@ import { type ReactNode, createContext, useContext, useState } from "react"; -import { useIsomorphicLayoutEffect } from "../utils"; +import { useIsomorphicLayoutEffect } from "../utils/useIsomorphicLayoutEffect"; const ViewportContext = createContext(null); diff --git a/packages/lab/src/date-picker/DatePickerActions.tsx b/packages/lab/src/date-picker/DatePickerActions.tsx index e6873a5ccbf..3f201d06f6b 100644 --- a/packages/lab/src/date-picker/DatePickerActions.tsx +++ b/packages/lab/src/date-picker/DatePickerActions.tsx @@ -13,7 +13,7 @@ import { type RangeDatePickerState, type SingleDatePickerState, useDatePickerContext, -} from "./index"; +} from "./DatePickerContext"; import "./DatePickerActions.css"; import { useComponentCssInjection } from "@salt-ds/styles"; import { useWindow } from "@salt-ds/window"; diff --git a/packages/lab/src/date-picker/DatePickerSinglePanel.tsx b/packages/lab/src/date-picker/DatePickerSinglePanel.tsx index 0d428452359..0f2d9717f1b 100644 --- a/packages/lab/src/date-picker/DatePickerSinglePanel.tsx +++ b/packages/lab/src/date-picker/DatePickerSinglePanel.tsx @@ -35,8 +35,8 @@ import { getCurrentLocale, } from "../calendar"; import { Calendar, type SingleDateSelection } from "../calendar"; +import { useDatePickerContext } from "./DatePickerContext"; import datePickerPanelCss from "./DatePickerPanel.css"; -import { useDatePickerContext } from "./index"; /** * Props for the DatePickerSinglePanel component. diff --git a/packages/lab/src/responsive/useOverflowLayout.ts b/packages/lab/src/responsive/useOverflowLayout.ts index bec71902366..aad81b4add6 100644 --- a/packages/lab/src/responsive/useOverflowLayout.ts +++ b/packages/lab/src/responsive/useOverflowLayout.ts @@ -6,7 +6,10 @@ import type { OverflowLayoutHookProps, } from "./overflowTypes"; -import { type ResizeHandler, useResizeObserver } from "../responsive"; +import { + type ResizeHandler, + useResizeObserver, +} from "../responsive/useResizeObserver"; import { getIsOverflowed, measureContainerOverflow } from "./overflowUtils"; import { useDynamicCollapse } from "./useDynamicCollapse"; import { useInstantCollapse } from "./useInstantCollapse"; diff --git a/packages/lab/src/window/ElectronWindow.tsx b/packages/lab/src/window/ElectronWindow.tsx index 69f16c32a04..31f5d70eb33 100644 --- a/packages/lab/src/window/ElectronWindow.tsx +++ b/packages/lab/src/window/ElectronWindow.tsx @@ -5,7 +5,11 @@ import { } from "@salt-ds/core"; import { forwardRef, useCallback, useEffect, useRef, useState } from "react"; import ReactDOM from "react-dom"; -import { Window as SaltWindow, type WindowProps, isDesktop } from "../window"; +import { + Window as SaltWindow, + type WindowProps, + isDesktop, +} from "./WindowContext"; import { useComponentCssInjection } from "@salt-ds/styles"; import { useWindow } from "@salt-ds/window";