diff --git a/.gitignore b/.gitignore index 9de1556..302b56f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ dist/ # misc .DS_Store +.idea *.pem # debug diff --git a/packages/react/src/components/alert/Alert.tsx b/packages/react/src/components/alert/Alert.tsx index a75fa93..89e6496 100644 --- a/packages/react/src/components/alert/Alert.tsx +++ b/packages/react/src/components/alert/Alert.tsx @@ -4,7 +4,7 @@ import type { AlertVariantProps } from '@giantnodes/theme' import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { AlertContext, useAlert } from '~/components/alert/use-alert.hook' +import { AlertContext, useAlertValue } from '~/components/alert/use-alert.hook' const __ELEMENT_TYPE__ = 'div' @@ -28,7 +28,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useAlert({ color }) + const context = useAlertValue({ color }) const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/alert/AlertBody.tsx b/packages/react/src/components/alert/AlertBody.tsx index 81b5712..6756200 100644 --- a/packages/react/src/components/alert/AlertBody.tsx +++ b/packages/react/src/components/alert/AlertBody.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useAlertContext } from '~/components/alert/use-alert.hook' +import { useAlert } from '~/components/alert/use-alert.hook' const __ELEMENT_TYPE__ = 'div' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useAlertContext() + const { slots } = useAlert() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/alert/AlertHeading.tsx b/packages/react/src/components/alert/AlertHeading.tsx index c50c8d9..3bff640 100644 --- a/packages/react/src/components/alert/AlertHeading.tsx +++ b/packages/react/src/components/alert/AlertHeading.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Heading } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useAlertContext } from '~/components/alert/use-alert.hook' +import { useAlert } from '~/components/alert/use-alert.hook' const __ELEMENT_TYPE__ = 'h1' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Heading - const { slots } = useAlertContext() + const { slots } = useAlert() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/alert/AlertItem.tsx b/packages/react/src/components/alert/AlertItem.tsx index f9bb83c..1bd5f1a 100644 --- a/packages/react/src/components/alert/AlertItem.tsx +++ b/packages/react/src/components/alert/AlertItem.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useAlertContext } from '~/components/alert/use-alert.hook' +import { useAlert } from '~/components/alert/use-alert.hook' const __ELEMENT_TYPE__ = 'li' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useAlertContext() + const { slots } = useAlert() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/alert/AlertList.tsx b/packages/react/src/components/alert/AlertList.tsx index d102ce0..eec867b 100644 --- a/packages/react/src/components/alert/AlertList.tsx +++ b/packages/react/src/components/alert/AlertList.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useAlertContext } from '~/components/alert/use-alert.hook' +import { useAlert } from '~/components/alert/use-alert.hook' const __ELEMENT_TYPE__ = 'ul' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useAlertContext() + const { slots } = useAlert() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/alert/use-alert.hook.ts b/packages/react/src/components/alert/use-alert.hook.ts index 789a234..9d5990e 100644 --- a/packages/react/src/components/alert/use-alert.hook.ts +++ b/packages/react/src/components/alert/use-alert.hook.ts @@ -4,13 +4,13 @@ import type { AlertVariantProps } from '@giantnodes/theme' import React from 'react' import { alert } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' type UseAlertProps = AlertVariantProps -type UseAlertReturn = ReturnType +type AlertContextType = ReturnType -export const useAlert = (props: UseAlertProps) => { +export const useAlertValue = (props: UseAlertProps) => { const { color } = props const slots = React.useMemo(() => alert({ color }), [color]) @@ -20,8 +20,8 @@ export const useAlert = (props: UseAlertProps) => { } } -export const [AlertContext, useAlertContext] = createContext({ +export const [AlertContext, useAlert] = create({ name: 'AlertContext', strict: true, - errorMessage: 'useAlertContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useAlert: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/avatar/Avatar.tsx b/packages/react/src/components/avatar/Avatar.tsx index 655ea3f..f5809db 100644 --- a/packages/react/src/components/avatar/Avatar.tsx +++ b/packages/react/src/components/avatar/Avatar.tsx @@ -4,7 +4,7 @@ import type { AvatarVariantProps } from '@giantnodes/theme' import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { AvatarContext, useAvatar, useAvatarContext } from '~/components/avatar/use-avatar.hook' +import { AvatarContext, useAvatar, useAvatarValue } from '~/components/avatar/use-avatar.hook' const __ELEMENT_TYPE__ = 'span' @@ -28,8 +28,8 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const parent = useAvatarContext() - const context = useAvatar({ + const parent = useAvatar() + const context = useAvatarValue({ color: parent?.color ?? color, radius: parent?.radius ?? radius, size: parent?.size ?? size, diff --git a/packages/react/src/components/avatar/AvatarGroup.tsx b/packages/react/src/components/avatar/AvatarGroup.tsx index e506c10..ab96ee0 100644 --- a/packages/react/src/components/avatar/AvatarGroup.tsx +++ b/packages/react/src/components/avatar/AvatarGroup.tsx @@ -4,7 +4,7 @@ import type { AvatarVariantProps } from '@giantnodes/theme' import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { AvatarContext, useAvatar } from '~/components/avatar/use-avatar.hook' +import { AvatarContext, useAvatarValue } from '~/components/avatar/use-avatar.hook' const __ELEMENT_TYPE__ = 'span' @@ -28,7 +28,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useAvatar({ color, radius, size, zoomed }) + const context = useAvatarValue({ color, radius, size, zoomed }) const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/avatar/AvatarIcon.tsx b/packages/react/src/components/avatar/AvatarIcon.tsx index 1ed29e6..b04b7bd 100644 --- a/packages/react/src/components/avatar/AvatarIcon.tsx +++ b/packages/react/src/components/avatar/AvatarIcon.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useAvatarContext } from '~/components/avatar/use-avatar.hook' +import { useAvatar } from '~/components/avatar/use-avatar.hook' const __ELEMENT_TYPE__ = 'span' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useAvatarContext() + const context = useAvatar() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/avatar/AvatarImage.tsx b/packages/react/src/components/avatar/AvatarImage.tsx index 7b5fb51..85be98b 100644 --- a/packages/react/src/components/avatar/AvatarImage.tsx +++ b/packages/react/src/components/avatar/AvatarImage.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useAvatarContext } from '~/components/avatar/use-avatar.hook' +import { useAvatar } from '~/components/avatar/use-avatar.hook' const __ELEMENT_TYPE__ = 'img' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useAvatarContext() + const context = useAvatar() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/avatar/AvatarNotification.tsx b/packages/react/src/components/avatar/AvatarNotification.tsx index 0296c1a..a26d32a 100644 --- a/packages/react/src/components/avatar/AvatarNotification.tsx +++ b/packages/react/src/components/avatar/AvatarNotification.tsx @@ -4,7 +4,7 @@ import type { AvatarVariantProps } from '@giantnodes/theme' import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useAvatarContext } from '~/components/avatar/use-avatar.hook' +import { useAvatar } from '~/components/avatar/use-avatar.hook' const __ELEMENT_TYPE__ = 'span' @@ -28,7 +28,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useAvatarContext() + const context = useAvatar() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/avatar/use-avatar.hook.ts b/packages/react/src/components/avatar/use-avatar.hook.ts index c98d786..369fd13 100644 --- a/packages/react/src/components/avatar/use-avatar.hook.ts +++ b/packages/react/src/components/avatar/use-avatar.hook.ts @@ -4,13 +4,13 @@ import type { AvatarVariantProps } from '@giantnodes/theme' import React from 'react' import { avatar } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' type UseAvatarProps = AvatarVariantProps -type UseAvatarReturn = ReturnType +type AvatarContextType = ReturnType -export const useAvatar = (props: UseAvatarProps) => { +export const useAvatarValue = (props: UseAvatarProps) => { const { color, radius, size, zoomed } = props const slots = React.useMemo( @@ -33,8 +33,8 @@ export const useAvatar = (props: UseAvatarProps) => { } } -export const [AvatarContext, useAvatarContext] = createContext({ +export const [AvatarContext, useAvatar] = create({ name: 'AvatarContext', strict: false, - errorMessage: 'useAvatarContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useAvatar: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/breadcrumb/Breadcrumb.tsx b/packages/react/src/components/breadcrumb/Breadcrumb.tsx index e00c257..bb64726 100644 --- a/packages/react/src/components/breadcrumb/Breadcrumb.tsx +++ b/packages/react/src/components/breadcrumb/Breadcrumb.tsx @@ -6,7 +6,7 @@ import React from 'react' import { Breadcrumbs } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { BreadcrumbContext, useBreadcrumb } from '~/components/breadcrumb/use-breadcrumb.hook' +import { BreadcrumbContext, useBreadcrumbValue } from '~/components/breadcrumb/use-breadcrumb.hook' const __ELEMENT_TYPE__ = 'ol' @@ -30,7 +30,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Breadcrumbs - const context = useBreadcrumb({ size, separator }) + const context = useBreadcrumbValue({ size, separator }) const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/breadcrumb/BreadcrumbItem.tsx b/packages/react/src/components/breadcrumb/BreadcrumbItem.tsx index d03c147..5d632b4 100644 --- a/packages/react/src/components/breadcrumb/BreadcrumbItem.tsx +++ b/packages/react/src/components/breadcrumb/BreadcrumbItem.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Breadcrumb, Link } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useBreadcrumbContext } from '~/components/breadcrumb/use-breadcrumb.hook' +import { useBreadcrumb } from '~/components/breadcrumb/use-breadcrumb.hook' import { cn } from '~/utilities' const __ELEMENT_TYPE__ = 'span' @@ -32,7 +32,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Breadcrumb - const { slots, separator } = useBreadcrumbContext() + const { slots, separator } = useBreadcrumb() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/breadcrumb/use-breadcrumb.hook.ts b/packages/react/src/components/breadcrumb/use-breadcrumb.hook.ts index 5329bcd..4f9188e 100644 --- a/packages/react/src/components/breadcrumb/use-breadcrumb.hook.ts +++ b/packages/react/src/components/breadcrumb/use-breadcrumb.hook.ts @@ -4,15 +4,15 @@ import type { BreadcrumbVariantProps } from '@giantnodes/theme' import React from 'react' import { breadcrumb } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' -type UseBreadcrumbProps = { +type UseBreadcrumbProps = BreadcrumbVariantProps & { separator?: React.ReactNode -} & BreadcrumbVariantProps +} -type UseBreadcrumbReturn = ReturnType +type BreadcrumbContextType = ReturnType -export const useBreadcrumb = (props: UseBreadcrumbProps) => { +export const useBreadcrumbValue = (props: UseBreadcrumbProps) => { const { size, separator = '/' } = props const slots = React.useMemo(() => breadcrumb({ size }), [size]) @@ -23,9 +23,8 @@ export const useBreadcrumb = (props: UseBreadcrumbProps) => { } } -export const [BreadcrumbContext, useBreadcrumbContext] = createContext({ +export const [BreadcrumbContext, useBreadcrumb] = create({ name: 'BreadcrumbContext', strict: true, - errorMessage: - 'useBreadcrumbContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useBreadcrumb: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/card/Card.tsx b/packages/react/src/components/card/Card.tsx index 095cc25..08facf2 100644 --- a/packages/react/src/components/card/Card.tsx +++ b/packages/react/src/components/card/Card.tsx @@ -4,7 +4,7 @@ import type { CardVariantProps } from '@giantnodes/theme' import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { CardContext, useCard } from '~/components/card/use-card.hook' +import { CardContext, useCardValue } from '~/components/card/use-card.hook' const __ELEMENT_TYPE__ = 'div' @@ -28,7 +28,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useCard() + const context = useCardValue() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/card/CardBody.tsx b/packages/react/src/components/card/CardBody.tsx index f90095d..a6ea81e 100644 --- a/packages/react/src/components/card/CardBody.tsx +++ b/packages/react/src/components/card/CardBody.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useCardContext } from '~/components/card/use-card.hook' +import { useCard } from '~/components/card/use-card.hook' const __ELEMENT_TYPE__ = 'div' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useCardContext() + const { slots } = useCard() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/card/CardFooter.tsx b/packages/react/src/components/card/CardFooter.tsx index c47c363..31d9982 100644 --- a/packages/react/src/components/card/CardFooter.tsx +++ b/packages/react/src/components/card/CardFooter.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useCardContext } from '~/components/card/use-card.hook' +import { useCard } from '~/components/card/use-card.hook' const __ELEMENT_TYPE__ = 'div' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useCardContext() + const { slots } = useCard() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/card/CardHeader.tsx b/packages/react/src/components/card/CardHeader.tsx index 5388d9c..f86248f 100644 --- a/packages/react/src/components/card/CardHeader.tsx +++ b/packages/react/src/components/card/CardHeader.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useCardContext } from '~/components/card/use-card.hook' +import { useCard } from '~/components/card/use-card.hook' const __ELEMENT_TYPE__ = 'div' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useCardContext() + const { slots } = useCard() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/card/use-card.hook.ts b/packages/react/src/components/card/use-card.hook.ts index 0f27a3a..763787e 100644 --- a/packages/react/src/components/card/use-card.hook.ts +++ b/packages/react/src/components/card/use-card.hook.ts @@ -3,11 +3,11 @@ import React from 'react' import { card } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' -type UseCardReturn = ReturnType +type CardContextType = ReturnType -export const useCard = () => { +export const useCardValue = () => { const slots = React.useMemo(() => card({}), []) return { @@ -15,8 +15,8 @@ export const useCard = () => { } } -export const [CardContext, useCardContext] = createContext({ +export const [CardContext, useCard] = create({ name: 'CardContext', strict: true, - errorMessage: 'useCardContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useCard: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/combo-box/ComboBox.tsx b/packages/react/src/components/combo-box/ComboBox.tsx index db03253..f6d780f 100644 --- a/packages/react/src/components/combo-box/ComboBox.tsx +++ b/packages/react/src/components/combo-box/ComboBox.tsx @@ -6,7 +6,7 @@ import React from 'react' import { ComboBox } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { ComboBoxContext, useComboBox } from '~/components/combo-box/use-combo-box.hook' +import { ComboBoxContext, useComboBoxValue } from '~/components/combo-box/use-combo-box.hook' const __ELEMENT_TYPE__ = 'div' @@ -30,7 +30,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? ComboBox - const context = useComboBox({ size, status }) + const context = useComboBoxValue({ size, status }) const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/combo-box/ComboBoxItem.tsx b/packages/react/src/components/combo-box/ComboBoxItem.tsx index 407cc6e..692eb64 100644 --- a/packages/react/src/components/combo-box/ComboBoxItem.tsx +++ b/packages/react/src/components/combo-box/ComboBoxItem.tsx @@ -5,7 +5,7 @@ import React from 'react' import { ListBoxItem } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useComboBoxContext } from '~/components/combo-box/use-combo-box.hook' +import { useComboBox } from '~/components/combo-box/use-combo-box.hook' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? ListBoxItem - const { slots } = useComboBoxContext() + const { slots } = useComboBox() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/combo-box/ComboBoxList.tsx b/packages/react/src/components/combo-box/ComboBoxList.tsx index 77032c0..9d0b785 100644 --- a/packages/react/src/components/combo-box/ComboBoxList.tsx +++ b/packages/react/src/components/combo-box/ComboBoxList.tsx @@ -5,7 +5,7 @@ import React from 'react' import { ListBox } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useComboBoxContext } from '~/components/combo-box/use-combo-box.hook' +import { useComboBox } from '~/components/combo-box/use-combo-box.hook' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? ListBox - const { slots } = useComboBoxContext() + const { slots } = useComboBox() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/combo-box/ComboBoxPopover.tsx b/packages/react/src/components/combo-box/ComboBoxPopover.tsx index 23f8682..52d4a8d 100644 --- a/packages/react/src/components/combo-box/ComboBoxPopover.tsx +++ b/packages/react/src/components/combo-box/ComboBoxPopover.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Popover } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useComboBoxContext } from '~/components/combo-box/use-combo-box.hook' +import { useComboBox } from '~/components/combo-box/use-combo-box.hook' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Popover - const { slots } = useComboBoxContext() + const { slots } = useComboBox() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/combo-box/use-combo-box.hook.ts b/packages/react/src/components/combo-box/use-combo-box.hook.ts index 98acae5..76c2b48 100644 --- a/packages/react/src/components/combo-box/use-combo-box.hook.ts +++ b/packages/react/src/components/combo-box/use-combo-box.hook.ts @@ -4,13 +4,13 @@ import type { ComboBoxVariantProps } from '@giantnodes/theme' import React from 'react' import { combobox } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' type UseComboBoxProps = ComboBoxVariantProps -type UseComboBoxReturn = ReturnType +type ComboBoxContextType = ReturnType -export const useComboBox = (props: UseComboBoxProps) => { +export const useComboBoxValue = (props: UseComboBoxProps) => { const { size, status } = props const slots = React.useMemo(() => combobox({ size, status }), [size, status]) @@ -20,8 +20,8 @@ export const useComboBox = (props: UseComboBoxProps) => { } } -export const [ComboBoxContext, useComboBoxContext] = createContext({ +export const [ComboBoxContext, useComboBox] = create({ name: 'ComboBoxContext', strict: true, - errorMessage: 'useComboBox: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useComboBox: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/dialog/Dialog.tsx b/packages/react/src/components/dialog/Dialog.tsx index 64beca8..e923db6 100644 --- a/packages/react/src/components/dialog/Dialog.tsx +++ b/packages/react/src/components/dialog/Dialog.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Dialog } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { DialogContext, useDialog } from '~/components/dialog/use-dialog.hook' +import { DialogContext, useDialogValue } from '~/components/dialog/use-dialog.hook' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Dialog - const context = useDialog({}) + const context = useDialogValue({}) const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/dialog/use-dialog.hook.ts b/packages/react/src/components/dialog/use-dialog.hook.ts index c71259b..2d567ad 100644 --- a/packages/react/src/components/dialog/use-dialog.hook.ts +++ b/packages/react/src/components/dialog/use-dialog.hook.ts @@ -4,13 +4,13 @@ import type { DialogVariantProps } from '@giantnodes/theme' import React from 'react' import { dialog } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' -export type UseDialogProps = DialogVariantProps +type UseDialogProps = DialogVariantProps -export type UseDialogReturn = ReturnType +type DialogContextType = ReturnType -export const useDialog = (_: UseDialogProps) => { +export const useDialogValue = (_: UseDialogProps) => { const slots = React.useMemo(() => dialog(), []) return { @@ -18,8 +18,8 @@ export const useDialog = (_: UseDialogProps) => { } } -export const [DialogContext, useDialogContext] = createContext({ +export const [DialogContext, useDialog] = create({ name: 'DialogContext', strict: true, - errorMessage: 'useDialogContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useDialog: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/form/FormCaption.tsx b/packages/react/src/components/form/FormCaption.tsx index 8664b21..ebe133a 100644 --- a/packages/react/src/components/form/FormCaption.tsx +++ b/packages/react/src/components/form/FormCaption.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useFormGroupContext } from '~/components/form/use-form-group.hook' +import { useFormGroup } from '~/components/form/use-form-group.hook' const __ELEMENT_TYPE__ = 'span' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useFormGroupContext() + const context = useFormGroup() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/form/FormFeedback.tsx b/packages/react/src/components/form/FormFeedback.tsx index fcae66c..176b2ce 100644 --- a/packages/react/src/components/form/FormFeedback.tsx +++ b/packages/react/src/components/form/FormFeedback.tsx @@ -4,7 +4,7 @@ import React from 'react' import type { FeedbackType } from '~/components/form/use-form-group.hook' import type * as Polymophic from '~/utilities/polymorphic' -import { useFormGroupContext } from '~/components/form/use-form-group.hook' +import { useFormGroup } from '~/components/form/use-form-group.hook' import { cn } from '~/utilities' const __ELEMENT_TYPE__ = 'span' @@ -31,7 +31,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useFormGroupContext() + const context = useFormGroup() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/form/FormGroup.tsx b/packages/react/src/components/form/FormGroup.tsx index 3242457..3b47580 100644 --- a/packages/react/src/components/form/FormGroup.tsx +++ b/packages/react/src/components/form/FormGroup.tsx @@ -4,7 +4,7 @@ import React from 'react' import { useField } from 'react-aria' import type * as Polymophic from '~/utilities/polymorphic' -import { FormGroupContext, useFormGroup } from '~/components/form/use-form-group.hook' +import { FormGroupContext, useFormGroupValue } from '~/components/form/use-form-group.hook' const __ELEMENT_TYPE__ = 'span' @@ -34,7 +34,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ const { labelProps, fieldProps } = useField({ ...props, label: name }) - const context = useFormGroup({ + const context = useFormGroupValue({ ref, name, labelProps, diff --git a/packages/react/src/components/form/FormLabel.tsx b/packages/react/src/components/form/FormLabel.tsx index 709963f..83b51e4 100644 --- a/packages/react/src/components/form/FormLabel.tsx +++ b/packages/react/src/components/form/FormLabel.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Label } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useFormGroupContext } from '~/components/form/use-form-group.hook' +import { useFormGroup } from '~/components/form/use-form-group.hook' const __ELEMENT_TYPE__ = 'label' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Label - const context = useFormGroupContext() + const context = useFormGroup() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/form/use-form-group.hook.tsx b/packages/react/src/components/form/use-form-group.hook.ts similarity index 76% rename from packages/react/src/components/form/use-form-group.hook.tsx rename to packages/react/src/components/form/use-form-group.hook.ts index 110ec72..867b82f 100644 --- a/packages/react/src/components/form/use-form-group.hook.tsx +++ b/packages/react/src/components/form/use-form-group.hook.ts @@ -6,7 +6,7 @@ import React from 'react' import { form } from '@giantnodes/theme' import type { ChangeHandler } from '~/utilities/types' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' export type FeedbackType = 'success' | 'info' | 'warning' | 'error' @@ -18,9 +18,9 @@ type UseFormGroupProps = LabelAria & { onBlur?: ChangeHandler } -type UseFormGroupReturn = ReturnType +type FormGroupContextType = ReturnType -export const useFormGroup = (props: UseFormGroupProps) => { +export const useFormGroupValue = (props: UseFormGroupProps) => { const { ref, name, fieldProps, labelProps, onChange, onBlur } = props const [feedback, setFeedback] = React.useState(null) @@ -56,8 +56,8 @@ export const useFormGroup = (props: UseFormGroupProps) => { } } -export const [FormGroupContext, useFormGroupContext] = createContext({ +export const [FormGroupContext, useFormGroup] = create({ name: 'FormGroupContext', strict: false, - errorMessage: 'useFormGroupContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useFormGroup: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/input/InputAddon.tsx b/packages/react/src/components/input/InputAddon.tsx index a7b7d07..043d17e 100644 --- a/packages/react/src/components/input/InputAddon.tsx +++ b/packages/react/src/components/input/InputAddon.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useInputContext } from '~/components/input/use-input.hook' +import { useInput } from '~/components/input/use-input.hook' const __ELEMENT_TYPE__ = 'span' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useInputContext() + const context = useInput() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/input/InputGroup.tsx b/packages/react/src/components/input/InputGroup.tsx index 24aa42a..f048bb9 100644 --- a/packages/react/src/components/input/InputGroup.tsx +++ b/packages/react/src/components/input/InputGroup.tsx @@ -6,8 +6,8 @@ import React from 'react' import { Group } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useFormGroupContext } from '~/components/form/use-form-group.hook' -import { InputContext, useInput } from '~/components/input/use-input.hook' +import { useFormGroup } from '~/components/form/use-form-group.hook' +import { InputContext, useInputValue } from '~/components/input/use-input.hook' const __ELEMENT_TYPE__ = 'div' @@ -31,8 +31,8 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Group - const group = useFormGroupContext() - const context = useInput({ color: color ?? group?.status, size, shape, variant }) + const group = useFormGroup() + const context = useInputValue({ color: color ?? group?.status, size, shape, variant }) const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/input/InputPhone.tsx b/packages/react/src/components/input/InputPhone.tsx index 5abd380..158e475 100644 --- a/packages/react/src/components/input/InputPhone.tsx +++ b/packages/react/src/components/input/InputPhone.tsx @@ -9,9 +9,9 @@ import examples from 'libphonenumber-js/mobile/examples' import { Input } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useFormGroupContext } from '~/components/form/use-form-group.hook' +import { useFormGroup } from '~/components/form/use-form-group.hook' import { Addon } from '~/components/input/component.parts' -import { useInput, useInputContext } from '~/components/input/use-input.hook' +import { useInput, useInputValue } from '~/components/input/use-input.hook' import { cn } from '~/utilities' const __ELEMENT_TYPE__ = 'input' @@ -38,10 +38,10 @@ const Component: ComponentType = React.forwardRef( const { as, children, className, country, color, size, shape, variant, onTemplateChange, ...rest } = props const Element = as ?? Input - const group = useFormGroupContext() - const context = useInputContext() + const group = useFormGroup() + const context = useInput() - const { slots } = useInput({ + const { slots } = useInputValue({ color: color ?? group?.status ?? context?.color, size: size ?? context?.size, shape: shape ?? context?.shape, diff --git a/packages/react/src/components/input/InputText.tsx b/packages/react/src/components/input/InputText.tsx index 8b4c7d8..e78143b 100644 --- a/packages/react/src/components/input/InputText.tsx +++ b/packages/react/src/components/input/InputText.tsx @@ -6,8 +6,8 @@ import React from 'react' import { Input } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useFormGroupContext } from '~/components/form/use-form-group.hook' -import { useInput, useInputContext } from '~/components/input/use-input.hook' +import { useFormGroup } from '~/components/form/use-form-group.hook' +import { useInput, useInputValue } from '~/components/input/use-input.hook' import { cn } from '~/utilities' const __ELEMENT_TYPE__ = 'input' @@ -32,10 +32,10 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Input - const group = useFormGroupContext() - const context = useInputContext() + const group = useFormGroup() + const context = useInput() - const { slots } = useInput({ + const { slots } = useInputValue({ color: color ?? group?.status ?? context?.color, size: size ?? context?.size, shape: shape ?? context?.shape, diff --git a/packages/react/src/components/input/InputTextArea.tsx b/packages/react/src/components/input/InputTextArea.tsx index acae6e3..89aecfb 100644 --- a/packages/react/src/components/input/InputTextArea.tsx +++ b/packages/react/src/components/input/InputTextArea.tsx @@ -6,8 +6,8 @@ import React from 'react' import { TextArea } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useFormGroupContext } from '~/components/form/use-form-group.hook' -import { useInput, useInputContext } from '~/components/input/use-input.hook' +import { useFormGroup } from '~/components/form/use-form-group.hook' +import { useInput, useInputValue } from '~/components/input/use-input.hook' import { cn } from '~/utilities' const __ELEMENT_TYPE__ = 'textarea' @@ -32,15 +32,15 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? TextArea - const context = useInputContext() - const { slots } = useInput({ + const context = useInput() + const { slots } = useInputValue({ color: color ?? context?.color, size: size ?? context?.size, shape: shape ?? context?.shape, variant: variant ?? context?.variant, }) - const group = useFormGroupContext() + const group = useFormGroup() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/input/use-input.hook.tsx b/packages/react/src/components/input/use-input.hook.ts similarity index 56% rename from packages/react/src/components/input/use-input.hook.tsx rename to packages/react/src/components/input/use-input.hook.ts index 9111f04..7bec90b 100644 --- a/packages/react/src/components/input/use-input.hook.tsx +++ b/packages/react/src/components/input/use-input.hook.ts @@ -4,13 +4,13 @@ import type { InputVariantProps } from '@giantnodes/theme' import React from 'react' import { input } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' type UseInputProps = InputVariantProps -type UseInputReturn = ReturnType +type InputContextType = ReturnType -export const useInput = (props: UseInputProps) => { +export const useInputValue = (props: UseInputProps) => { const { color, size, shape, variant } = props const slots = React.useMemo(() => input({ color, size, shape, variant }), [color, size, shape, variant]) @@ -24,8 +24,8 @@ export const useInput = (props: UseInputProps) => { } } -export const [InputContext, useInputContext] = createContext({ +export const [InputContext, useInput] = create({ name: 'InputContext', strict: false, - errorMessage: 'useInputContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useInput: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/menu/Menu.tsx b/packages/react/src/components/menu/Menu.tsx index 532a90c..8c64151 100644 --- a/packages/react/src/components/menu/Menu.tsx +++ b/packages/react/src/components/menu/Menu.tsx @@ -6,7 +6,7 @@ import React from 'react' import { MenuTrigger } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { MenuContext, useMenu } from '~/components/menu/use-menu.hook' +import { MenuContext, useMenuValue } from '~/components/menu/use-menu.hook' const __ELEMENT_TYPE__ = 'div' @@ -28,7 +28,7 @@ const Component: ComponentType = >( () => ({ diff --git a/packages/react/src/components/menu/MenuItem.tsx b/packages/react/src/components/menu/MenuItem.tsx index fef05e5..032324b 100644 --- a/packages/react/src/components/menu/MenuItem.tsx +++ b/packages/react/src/components/menu/MenuItem.tsx @@ -5,7 +5,7 @@ import React from 'react' import { MenuItem } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useMenuContext } from '~/components/menu/use-menu.hook' +import { useMenu } from '~/components/menu/use-menu.hook' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? MenuItem - const { slots } = useMenuContext() + const { slots } = useMenu() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/menu/MenuList.tsx b/packages/react/src/components/menu/MenuList.tsx index 35dfb03..6fb0362 100644 --- a/packages/react/src/components/menu/MenuList.tsx +++ b/packages/react/src/components/menu/MenuList.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Menu } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useMenuContext } from '~/components/menu/use-menu.hook' +import { useMenu } from '~/components/menu/use-menu.hook' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Menu - const { slots } = useMenuContext() + const { slots } = useMenu() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/menu/MenuPopover.tsx b/packages/react/src/components/menu/MenuPopover.tsx index d145759..ca4e219 100644 --- a/packages/react/src/components/menu/MenuPopover.tsx +++ b/packages/react/src/components/menu/MenuPopover.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Popover } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useMenuContext } from '~/components/menu/use-menu.hook' +import { useMenu } from '~/components/menu/use-menu.hook' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Popover - const { slots } = useMenuContext() + const { slots } = useMenu() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/menu/MenuTrigger.tsx b/packages/react/src/components/menu/MenuTrigger.tsx index b6cd60a..0bb6ffe 100644 --- a/packages/react/src/components/menu/MenuTrigger.tsx +++ b/packages/react/src/components/menu/MenuTrigger.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Button } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useMenuContext } from '~/components/menu/use-menu.hook' +import { useMenu } from '~/components/menu/use-menu.hook' const __ELEMENT_TYPE__ = 'button' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Button - const { slots } = useMenuContext() + const { slots } = useMenu() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/menu/use-menu.hook.ts b/packages/react/src/components/menu/use-menu.hook.ts index 82f563e..f06300e 100644 --- a/packages/react/src/components/menu/use-menu.hook.ts +++ b/packages/react/src/components/menu/use-menu.hook.ts @@ -4,13 +4,13 @@ import type { MenuVariantProps } from '@giantnodes/theme' import React from 'react' import { menu } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context.jsx' type UseMenuProps = MenuVariantProps -type UseMenuReturn = ReturnType +type MenuContextType = ReturnType -export const useMenu = (props: UseMenuProps) => { +export const useMenuValue = (props: UseMenuProps) => { const { size, color } = props const slots = React.useMemo(() => menu({ size, color }), [size, color]) @@ -20,8 +20,8 @@ export const useMenu = (props: UseMenuProps) => { } } -export const [MenuContext, useMenuContext] = createContext({ +export const [MenuContext, useMenu] = create({ name: 'MenuContext', strict: true, - errorMessage: 'useMenuContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useMenu: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/modal/Modal.tsx b/packages/react/src/components/modal/Modal.tsx index 8767cc9..d6db473 100644 --- a/packages/react/src/components/modal/Modal.tsx +++ b/packages/react/src/components/modal/Modal.tsx @@ -6,7 +6,7 @@ import React from 'react' import { ModalOverlay } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { ModalContext, useModal } from '~/components/modal/use-modal.hook' +import { ModalContext, useModalValue } from '~/components/modal/use-modal.hook' import { cn } from '~/utilities' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = ( () => ({ diff --git a/packages/react/src/components/modal/ModalContent.tsx b/packages/react/src/components/modal/ModalContent.tsx index a5ec8d8..3e67e0e 100644 --- a/packages/react/src/components/modal/ModalContent.tsx +++ b/packages/react/src/components/modal/ModalContent.tsx @@ -6,7 +6,7 @@ import React from 'react' import { Modal } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useModalContext } from '~/components/modal/use-modal.hook' +import { useModal } from '~/components/modal/use-modal.hook' import { cn } from '~/utilities' const __ELEMENT_TYPE__ = 'div' @@ -29,7 +29,7 @@ const Component: ComponentType = ( () => ({ diff --git a/packages/react/src/components/modal/use-modal.hook.ts b/packages/react/src/components/modal/use-modal.hook.ts index 68e5ab4..0a96e55 100644 --- a/packages/react/src/components/modal/use-modal.hook.ts +++ b/packages/react/src/components/modal/use-modal.hook.ts @@ -4,13 +4,13 @@ import type { ModalVariantProps } from '@giantnodes/theme' import React from 'react' import { modal } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' -export type UseModalProps = ModalVariantProps +type UseModalProps = ModalVariantProps -export type UseModalReturn = ReturnType +type ModalContextType = ReturnType -export const useModal = (props: UseModalProps) => { +export const useModalValue = (props: UseModalProps) => { const { blur, placement, position } = props const slots = React.useMemo(() => modal({ blur, placement, position }), [blur, placement, position]) @@ -20,8 +20,8 @@ export const useModal = (props: UseModalProps) => { } } -export const [ModalContext, useModalContext] = createContext({ +export const [ModalContext, useModal] = create({ name: 'ModalContext', strict: true, - errorMessage: 'useModalContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useModal: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/navigation/Navigation.tsx b/packages/react/src/components/navigation/Navigation.tsx index bb8a4bb..8250eff 100644 --- a/packages/react/src/components/navigation/Navigation.tsx +++ b/packages/react/src/components/navigation/Navigation.tsx @@ -4,7 +4,7 @@ import type { NavigationVariantProps } from '@giantnodes/theme' import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { NavigationContext, useNavigation } from '~/components/navigation/use-navigation.hook' +import { NavigationContext, useNavigationValue } from '~/components/navigation/use-navigation.hook' const __ELEMENT_TYPE__ = 'nav' @@ -28,7 +28,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useNavigation({ + const context = useNavigationValue({ orientation, position, size, diff --git a/packages/react/src/components/navigation/NavigationBrand.tsx b/packages/react/src/components/navigation/NavigationBrand.tsx index 56c7302..6732595 100644 --- a/packages/react/src/components/navigation/NavigationBrand.tsx +++ b/packages/react/src/components/navigation/NavigationBrand.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useNavigationContext } from '~/components/navigation/use-navigation.hook' +import { useNavigation } from '~/components/navigation/use-navigation.hook' const __ELEMENT_TYPE__ = 'div' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useNavigationContext() + const { slots } = useNavigation() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/navigation/NavigationDivider.tsx b/packages/react/src/components/navigation/NavigationDivider.tsx index 0cdca2e..2c41ea7 100644 --- a/packages/react/src/components/navigation/NavigationDivider.tsx +++ b/packages/react/src/components/navigation/NavigationDivider.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useNavigationContext } from '~/components/navigation/use-navigation.hook' +import { useNavigation } from '~/components/navigation/use-navigation.hook' const __ELEMENT_TYPE__ = 'hr' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useNavigationContext() + const { slots } = useNavigation() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/navigation/NavigationItem.tsx b/packages/react/src/components/navigation/NavigationItem.tsx index 38ae280..cee54b3 100644 --- a/packages/react/src/components/navigation/NavigationItem.tsx +++ b/packages/react/src/components/navigation/NavigationItem.tsx @@ -4,7 +4,7 @@ import type { NavigationVariantProps } from '@giantnodes/theme' import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useNavigationContext } from '~/components/navigation/use-navigation.hook' +import { useNavigation } from '~/components/navigation/use-navigation.hook' const __ELEMENT_TYPE__ = 'li' @@ -30,7 +30,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useNavigationContext() + const { slots } = useNavigation() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/navigation/NavigationLink.tsx b/packages/react/src/components/navigation/NavigationLink.tsx index 3d9fb46..59c9326 100644 --- a/packages/react/src/components/navigation/NavigationLink.tsx +++ b/packages/react/src/components/navigation/NavigationLink.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Link } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useNavigationContext } from '~/components/navigation/use-navigation.hook' +import { useNavigation } from '~/components/navigation/use-navigation.hook' const __ELEMENT_TYPE__ = 'a' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Link - const { slots } = useNavigationContext() + const { slots } = useNavigation() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/navigation/NavigationSegment.tsx b/packages/react/src/components/navigation/NavigationSegment.tsx index 923d1c3..fd9677f 100644 --- a/packages/react/src/components/navigation/NavigationSegment.tsx +++ b/packages/react/src/components/navigation/NavigationSegment.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useNavigationContext } from '~/components/navigation/use-navigation.hook' +import { useNavigation } from '~/components/navigation/use-navigation.hook' const __ELEMENT_TYPE__ = 'ul' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useNavigationContext() + const { slots } = useNavigation() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/navigation/NavigationTitle.tsx b/packages/react/src/components/navigation/NavigationTitle.tsx index d922f25..4d9d3f2 100644 --- a/packages/react/src/components/navigation/NavigationTitle.tsx +++ b/packages/react/src/components/navigation/NavigationTitle.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useNavigationContext } from '~/components/navigation/use-navigation.hook' +import { useNavigation } from '~/components/navigation/use-navigation.hook' const __ELEMENT_TYPE__ = 'span' @@ -27,7 +27,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const { slots } = useNavigationContext() + const { slots } = useNavigation() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/navigation/NavigationTrigger.tsx b/packages/react/src/components/navigation/NavigationTrigger.tsx index 21f47ea..9477d4e 100644 --- a/packages/react/src/components/navigation/NavigationTrigger.tsx +++ b/packages/react/src/components/navigation/NavigationTrigger.tsx @@ -5,7 +5,7 @@ import React from 'react' import { Button } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useNavigationContext } from '~/components/navigation/use-navigation.hook' +import { useNavigation } from '~/components/navigation/use-navigation.hook' const __ELEMENT_TYPE__ = 'button' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Button - const { slots } = useNavigationContext() + const { slots } = useNavigation() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/navigation/use-navigation.hook.ts b/packages/react/src/components/navigation/use-navigation.hook.ts index 4d15bd9..a41ce2c 100644 --- a/packages/react/src/components/navigation/use-navigation.hook.ts +++ b/packages/react/src/components/navigation/use-navigation.hook.ts @@ -4,13 +4,13 @@ import type { NavigationVariantProps } from '@giantnodes/theme' import React from 'react' import { navigation } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' type UseNavigationProps = NavigationVariantProps -type UseNavigationReturn = ReturnType +type NavigationContextType = ReturnType -export const useNavigation = (props: UseNavigationProps) => { +export const useNavigationValue = (props: UseNavigationProps) => { const { orientation, position, size, variant, isBordered } = props const slots = React.useMemo( @@ -30,9 +30,8 @@ export const useNavigation = (props: UseNavigationProps) => { } } -export const [NavigationContext, useNavigationContext] = createContext({ +export const [NavigationContext, useNavigation] = create({ name: 'NavigationContext', strict: true, - errorMessage: - 'useNavigationContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useNavigation: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/progress/Progress.tsx b/packages/react/src/components/progress/Progress.tsx index eb4b20b..7f2e3a3 100644 --- a/packages/react/src/components/progress/Progress.tsx +++ b/packages/react/src/components/progress/Progress.tsx @@ -4,7 +4,7 @@ import type { ProgressVariantProps } from '@giantnodes/theme' import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { ProgressContext, useProgress } from '~/components/progress/use-progress.hook' +import { ProgressContext, useProgressValue } from '~/components/progress/use-progress.hook' const __ELEMENT_TYPE__ = 'div' @@ -28,7 +28,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useProgress({ radius, size }) + const context = useProgressValue({ radius, size }) const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/progress/ProgressBar.tsx b/packages/react/src/components/progress/ProgressBar.tsx index 2e71e1a..aa6d3a4 100644 --- a/packages/react/src/components/progress/ProgressBar.tsx +++ b/packages/react/src/components/progress/ProgressBar.tsx @@ -3,7 +3,7 @@ import React from 'react' import type * as Polymophic from '~/utilities/polymorphic' -import { useProgressContext } from '~/components/progress/use-progress.hook' +import { useProgress } from '~/components/progress/use-progress.hook' const __ELEMENT_TYPE__ = 'span' @@ -30,7 +30,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? __ELEMENT_TYPE__ - const context = useProgressContext() + const context = useProgress() const component = React.useMemo>( () => ({ diff --git a/packages/react/src/components/progress/use-progress.hook.ts b/packages/react/src/components/progress/use-progress.hook.ts index ea21fc6..8369b82 100644 --- a/packages/react/src/components/progress/use-progress.hook.ts +++ b/packages/react/src/components/progress/use-progress.hook.ts @@ -4,13 +4,13 @@ import type { ProgressVariantProps } from '@giantnodes/theme' import React from 'react' import { progress } from '@giantnodes/theme' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' type UseProgressProps = ProgressVariantProps -type UseProgressReturn = ReturnType +type ProgressContextType = ReturnType -export const useProgress = (props: UseProgressProps) => { +export const useProgressValue = (props: UseProgressProps) => { const { radius, size } = props const slots = React.useMemo(() => progress({ radius, size }), [radius, size]) @@ -20,8 +20,8 @@ export const useProgress = (props: UseProgressProps) => { } } -export const [ProgressContext, useProgressContext] = createContext({ +export const [ProgressContext, useProgress] = create({ name: 'ProgressContext', strict: true, - errorMessage: 'useProgressContext: `context` is undefined. Seems you forgot to wrap component within ', + errorMessage: 'useProgress: `context` is undefined. Seems you forgot to wrap component within ', }) diff --git a/packages/react/src/components/select/Select.tsx b/packages/react/src/components/select/Select.tsx index 0fdcb60..0c2dc37 100644 --- a/packages/react/src/components/select/Select.tsx +++ b/packages/react/src/components/select/Select.tsx @@ -7,9 +7,9 @@ import { Button, ListBox, Popover, Select } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' import type { Override } from '~/utilities/types' -import { useFormGroupContext } from '~/components/form/use-form-group.hook' +import { useFormGroup } from '~/components/form/use-form-group.hook' import SelectValue from '~/components/select/SelectValue' -import { SelectContext, useSelect } from '~/components/select/use-select.hook' +import { SelectContext, useSelectValue } from '~/components/select/use-select.hook' const __ELEMENT_TYPE__ = 'select' @@ -67,9 +67,9 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? Select - const group = useFormGroupContext() + const group = useFormGroup() - const context = useSelect({ + const context = useSelectValue({ ref: (group?.ref as React.RefObject | undefined) ?? ref, name: group?.name, behavior, diff --git a/packages/react/src/components/select/SelectOption.tsx b/packages/react/src/components/select/SelectOption.tsx index 90ce958..0850394 100644 --- a/packages/react/src/components/select/SelectOption.tsx +++ b/packages/react/src/components/select/SelectOption.tsx @@ -5,7 +5,7 @@ import React from 'react' import { ListBoxItem } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useSelectContext } from '~/components/select/use-select.hook' +import { useSelect } from '~/components/select/use-select.hook' const __ELEMENT_TYPE__ = 'option' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? ListBoxItem - const { slots } = useSelectContext() + const { slots } = useSelect() const component = React.useMemo( () => ({ diff --git a/packages/react/src/components/select/SelectValue.tsx b/packages/react/src/components/select/SelectValue.tsx index 9da62cd..204edc1 100644 --- a/packages/react/src/components/select/SelectValue.tsx +++ b/packages/react/src/components/select/SelectValue.tsx @@ -5,7 +5,7 @@ import React from 'react' import { SelectStateContext, SelectValue } from 'react-aria-components' import type * as Polymophic from '~/utilities/polymorphic' -import { useSelectContext } from '~/components/select/use-select.hook' +import { useSelect } from '~/components/select/use-select.hook' const __ELEMENT_TYPE__ = 'span' @@ -29,7 +29,7 @@ const Component: ComponentType = React.forwardRef( const Element = as ?? SelectValue - const { slots } = useSelectContext() + const { slots } = useSelect() const { selectedItem } = React.useContext(SelectStateContext) const component = React.useMemo>( diff --git a/packages/react/src/components/select/use-select.hook.ts b/packages/react/src/components/select/use-select.hook.ts index 82b45b8..a9e14a2 100644 --- a/packages/react/src/components/select/use-select.hook.ts +++ b/packages/react/src/components/select/use-select.hook.ts @@ -6,7 +6,7 @@ import React from 'react' import { select } from '@giantnodes/theme' import type { ChangeHandler } from '~/utilities/types' -import { createContext } from '~/utilities/context' +import { create } from '~/utilities/create-context' type UseSelectProps = SelectVariantProps & Pick, 'onSelectionChange'> & { @@ -17,9 +17,9 @@ type UseSelectProps = SelectVariantProps & onChange?: ChangeHandler } -type UseSelectReturn = ReturnType +type SelectContextType = ReturnType -export const useSelect = (props: UseSelectProps) => { +export const useSelectValue = (props: UseSelectProps) => { const { ref, name, size, status, onChange, onSelectionChange } = props const slots = React.useMemo(() => select({ size, status }), [size, status]) @@ -45,8 +45,8 @@ export const useSelect = (props: UseSelectProps({ +export const [SelectContext, useSelect] = create({ name: 'SelectContext', strict: true, - errorMessage: 'useSelectContext: `context` is undefined. Seems you forgot to wrap component within