diff --git a/packages/react/package.json b/packages/react/package.json index f5c9438..5445e48 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -41,7 +41,6 @@ }, "devDependencies": { "@jest/types": "^29.6.3", - "@react-types/shared": "^3.22.1", "@storybook/addon-backgrounds": "^8.0.1", "@storybook/addon-essentials": "8.0.1", "@storybook/addon-interactions": "8.0.1", diff --git a/packages/react/src/components/link/Link.stories.tsx b/packages/react/src/components/link/Link.stories.tsx index dcf4650..31cdc16 100644 --- a/packages/react/src/components/link/Link.stories.tsx +++ b/packages/react/src/components/link/Link.stories.tsx @@ -12,10 +12,12 @@ const Component: Meta = { } const defaultProps = { + href: 'www.giantnodes.com', ...link.defaultVariants, } -export const Default: StoryFn = (args: LinkProps) => There were 2 errors with your submission +export const Default: StoryFn = (args: LinkProps) => Default Link + Default.args = { ...defaultProps, } diff --git a/packages/react/src/components/link/Link.tsx b/packages/react/src/components/link/Link.tsx index 72c82ee..f9ef26c 100644 --- a/packages/react/src/components/link/Link.tsx +++ b/packages/react/src/components/link/Link.tsx @@ -5,16 +5,10 @@ import { link } from '@giantnodes/theme' import React from 'react' import { Link } from 'react-aria-components' -import { useDomRef } from '@/hooks/use-dom-ref' -import { useLink } from '@/hooks/use-link.hook' - type ComponentProps = ComponentWithoutAs<'a'> & LinkProps const Component = React.forwardRef((props, ref) => { - const { children, className } = props - - const dom = useDomRef(ref) - const { ...rest } = useLink(props, dom) + const { children, className, ...rest } = props const slots = React.useMemo(() => link({}), []) diff --git a/packages/react/src/hooks/use-design-system.tsx b/packages/react/src/hooks/use-design-system.tsx index d78bb6d..82fc42a 100644 --- a/packages/react/src/hooks/use-design-system.tsx +++ b/packages/react/src/hooks/use-design-system.tsx @@ -1,7 +1,5 @@ import { RouterProvider } from '@react-aria/utils' -import { createContext } from '@/utilities/context' - export type UseDesignSystemProps = React.PropsWithChildren & { /** * Provides a client side router to all components that contain links @@ -9,9 +7,7 @@ export type UseDesignSystemProps = React.PropsWithChildren & { navigate?: (path: string) => void } -export type UseDesignSystemReturn = ReturnType - -export const useDesignSystem = ({ navigate, children }: UseDesignSystemProps) => { +export const DesignSystemProvider: React.FC = ({ navigate, children }) => { let contents = children if (navigate) { @@ -20,10 +16,3 @@ export const useDesignSystem = ({ navigate, children }: UseDesignSystemProps) => return contents } - -export const [DesignSystemContext, useDesignSystemContext] = createContext({ - name: 'DesignSystemContext', - strict: true, - errorMessage: - 'useDesignSystemContext: `context` is undefined. Seems you forgot to wrap component within ', -}) diff --git a/packages/react/src/hooks/use-link.hook.ts b/packages/react/src/hooks/use-link.hook.ts deleted file mode 100644 index f8ff8e5..0000000 --- a/packages/react/src/hooks/use-link.hook.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { FocusableElement, PressEvent } from '@react-types/shared' -import type React from 'react' -import type { AriaLinkOptions } from 'react-aria' - -import { shouldClientNavigate, useRouter } from '@react-aria/utils' -import { useLink as useAriaLink } from 'react-aria' - -export const useLink = (props: AriaLinkOptions, ref: React.RefObject) => { - const { onPress: onAriaPress, ...rest } = props - const router = useRouter() - - const onPress = (event: PressEvent) => { - const { target } = event - - if (!(target instanceof HTMLAnchorElement)) return - - if (!router.isNative && target.href && shouldClientNavigate(target, event)) { - router.open(target, event) - } - } - - return useAriaLink({ ...rest, onPress }, ref) -} - -export type UseLinkReturn = ReturnType diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7d5e522..4adffe7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -90,9 +90,6 @@ importers: '@jest/types': specifier: ^29.6.3 version: 29.6.3 - '@react-types/shared': - specifier: ^3.22.1 - version: 3.22.1(react@18.2.0) '@storybook/addon-backgrounds': specifier: ^8.0.1 version: 8.0.1 @@ -4163,6 +4160,7 @@ packages: react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 dependencies: react: 18.2.0 + dev: false /@react-types/slider@3.7.1(react@18.2.0): resolution: {integrity: sha512-FKO3YZYdrBs00XbBW5acP+0L1cCdevl/uRJiXbnLpGysO5PrSFIRS7Wlv4M7ztf6gT7b1Ao4FNC9crbxBr6BzA==}