diff --git a/packages/react/src/components/alert/Alert.tsx b/packages/react/src/components/alert/Alert.tsx index d89cf98..9418eb7 100644 --- a/packages/react/src/components/alert/Alert.tsx +++ b/packages/react/src/components/alert/Alert.tsx @@ -3,24 +3,25 @@ import type { AlertVariantProps } from '@giantnodes/theme' import React from 'react' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { AlertContext, useAlertValue } from '~/components/alert/use-alert.hook' const __ELEMENT_TYPE__ = 'div' type ComponentOwnProps = AlertVariantProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, color, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, level = 3, ...rest } = props const Element = as ?? Heading @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, color, radius, size, zoomed, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -51,5 +52,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, color, radius, size, zoomed, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, className, icon, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, color, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -43,5 +44,7 @@ const Component: ComponentType = React.forwardRef = BreadcrumbsProps & Breadcr type ComponentProps< TData extends object, TElement extends React.ElementType = typeof __ELEMENT_TYPE__, -> = Polymophic.ComponentPropsWithRef> +> = Polymorphic.ComponentPropsWithRef> -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, children, className, size, separator, ...rest } = props @@ -50,5 +51,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'Breadcrumb.Root' + export type { ComponentOwnProps as BreadcrumbOwnProps, ComponentProps as BreadcrumbProps } export default Component diff --git a/packages/react/src/components/breadcrumb/BreadcrumbItem.tsx b/packages/react/src/components/breadcrumb/BreadcrumbItem.tsx index ff93112..149bca7 100644 --- a/packages/react/src/components/breadcrumb/BreadcrumbItem.tsx +++ b/packages/react/src/components/breadcrumb/BreadcrumbItem.tsx @@ -4,7 +4,7 @@ import type { BreadcrumbProps } from 'react-aria-components' import React from 'react' import { Breadcrumb, Link } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useBreadcrumb } from '~/components/breadcrumb/use-breadcrumb.hook' import { cn } from '~/utilities' @@ -14,17 +14,18 @@ type ComponentOwnProps = BreadcrumbProps & { href?: string } -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, href, ...rest } = props const Element = as ?? Breadcrumb @@ -53,5 +54,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, isLoading = false, isDisabled = false, color, size, ...rest } = props const Element = as ?? Button @@ -55,5 +56,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, size, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, className, color, size, ...rest } = props const Element = as ?? Checkbox @@ -58,5 +59,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, color, size, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -43,5 +44,7 @@ const Component: ComponentType = React.forwardRef = ComboBoxProps & ComboBoxVa type ComponentProps< TData extends object, TElement extends React.ElementType = typeof __ELEMENT_TYPE__, -> = Polymophic.ComponentPropsWithRef> +> = Polymorphic.ComponentPropsWithRef> -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, children, className, size, status, ...rest } = props @@ -50,5 +51,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'ComboBox.Root' + export type { ComponentOwnProps as ComboBoxOwnProps, ComponentProps as ComboBoxProps } export default Component diff --git a/packages/react/src/components/combo-box/ComboBoxItem.tsx b/packages/react/src/components/combo-box/ComboBoxItem.tsx index 326f60e..66d50e2 100644 --- a/packages/react/src/components/combo-box/ComboBoxItem.tsx +++ b/packages/react/src/components/combo-box/ComboBoxItem.tsx @@ -4,24 +4,25 @@ import type { ListBoxItemProps } from 'react-aria-components' import React from 'react' import { ListBoxItem } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useComboBox } from '~/components/combo-box/use-combo-box.hook' const __ELEMENT_TYPE__ = 'div' type ComponentOwnProps = ListBoxItemProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? ListBoxItem @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = ListBoxProps type ComponentProps< TData extends object, TElement extends React.ElementType = typeof __ELEMENT_TYPE__, -> = Polymophic.ComponentPropsWithRef> +> = Polymorphic.ComponentPropsWithRef> -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, children, className, ...rest } = props @@ -47,5 +48,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'ComboBox.List' + export type { ComponentOwnProps as ComboBoxListOwnProps, ComponentProps as ComboBoxListProps } export default Component diff --git a/packages/react/src/components/combo-box/ComboBoxPopover.tsx b/packages/react/src/components/combo-box/ComboBoxPopover.tsx index 706102b..f5db814 100644 --- a/packages/react/src/components/combo-box/ComboBoxPopover.tsx +++ b/packages/react/src/components/combo-box/ComboBoxPopover.tsx @@ -4,24 +4,25 @@ import type { PopoverProps } from 'react-aria-components' import React from 'react' import { Popover } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useComboBox } from '~/components/combo-box/use-combo-box.hook' const __ELEMENT_TYPE__ = 'div' type ComponentOwnProps = PopoverProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Popover @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Dialog @@ -46,5 +47,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentProps< +type ComponentProps = Polymorphic.ComponentProps< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType -const Component: ComponentType = (props: ComponentProps) => { - const { as, children, ...component } = props +const Component: ComponentType = React.forwardRef, ComponentOwnProps>( + (props: ComponentProps, _: Polymorphic.Ref) => { + const { as, children, ...component } = props - const Element = as ?? DialogTrigger + const Element = as ?? DialogTrigger - return {children} -} + return {children} + } +) + +Component.displayName = 'Dialog.Trigger' export type { ComponentOwnProps as DialogTriggerOwnProps, ComponentProps as DialogTriggerProps } export default Component diff --git a/packages/react/src/components/divider/Divider.tsx b/packages/react/src/components/divider/Divider.tsx index d6d9531..a8f3c7e 100644 --- a/packages/react/src/components/divider/Divider.tsx +++ b/packages/react/src/components/divider/Divider.tsx @@ -4,23 +4,24 @@ import type { DividerVariantProps } from '@giantnodes/theme' import React from 'react' import { divider } from '@giantnodes/theme' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' const __ELEMENT_TYPE__ = 'hr' type ComponentOwnProps = DividerVariantProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, orientation, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, color, ...rest } = props const Element = as ?? Form @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, type, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -49,5 +50,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, name, success, info, warning, error, onChange, onBlur, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -68,5 +69,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Label @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, color, size, shape, variant, ...rest } = props const Element = as ?? Group @@ -49,5 +50,7 @@ const Component: ComponentType = React.forwardRef void } -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, className, country, color, size, shape, variant, onTemplateChange, ...rest } = props const Element = as ?? TextField @@ -187,5 +188,8 @@ const CountryFlag: React.FC = ({ country }) => { return {`${country.toLowerCase()}-flag-icon`} } +CountryFlag.displayName = 'Input.PhoneCountryFlag' +Component.displayName = 'Input.Phone' + export type { ComponentOwnProps as InputPhoneOwnProps, ComponentProps as InputPhoneProps } export default Component diff --git a/packages/react/src/components/input/InputText.tsx b/packages/react/src/components/input/InputText.tsx index 195c246..519af50 100644 --- a/packages/react/src/components/input/InputText.tsx +++ b/packages/react/src/components/input/InputText.tsx @@ -5,7 +5,7 @@ import type { InputProps, TextFieldProps } from 'react-aria-components' import React from 'react' import { Input, TextField } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useFormGroup } from '~/components/form/use-form-group.hook' import { useInput, useInputValue } from '~/components/input/use-input.hook' import { cn } from '~/utilities' @@ -17,17 +17,18 @@ type ComponentOwnProps = InputVariantProps & directory?: boolean } -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, className, color, size, shape, variant, directory, ...rest } = props const Element = as ?? TextField @@ -75,5 +76,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, className, color, size, shape, variant, ...rest } = props const Element = as ?? TextField @@ -70,5 +71,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, underline, ...rest } = props const Element = as ?? Link @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentProps< +type ComponentProps = Polymorphic.ComponentProps< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode - -const Component: ComponentType = (props: ComponentProps) => { - const { as, children, className, size, color, ...rest } = props - - const Element = as ?? MenuTrigger - - const context = useMenuValue({ size, color }) - - const component = React.useMemo>( - () => ({ - className: context.slots.menu({ className }), - ...rest, - }), - [className, context.slots, rest] - ) - - return ( - - {children} - - ) -} +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType + +const Component: ComponentType = React.forwardRef, ComponentOwnProps>( + (props: ComponentProps, _: Polymorphic.Ref) => { + const { as, children, className, size, color, ...rest } = props + + const Element = as ?? MenuTrigger + + const context = useMenuValue({ size, color }) + + const component = React.useMemo>( + () => ({ + className: context.slots.menu({ className }), + ...rest, + }), + [className, context.slots, rest] + ) + + return ( + + {children} + + ) + } +) + +Component.displayName = 'Menu.Root' export type { ComponentOwnProps as MenuOwnProps, ComponentProps as MenuProps } export default Component diff --git a/packages/react/src/components/menu/MenuItem.tsx b/packages/react/src/components/menu/MenuItem.tsx index 8e0c368..040a9fa 100644 --- a/packages/react/src/components/menu/MenuItem.tsx +++ b/packages/react/src/components/menu/MenuItem.tsx @@ -4,24 +4,25 @@ import type { MenuItemProps } from 'react-aria-components' import React from 'react' import { MenuItem } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useMenu } from '~/components/menu/use-menu.hook' const __ELEMENT_TYPE__ = 'div' type ComponentOwnProps = MenuItemProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? MenuItem @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = MenuProps type ComponentProps< TData extends object, TElement extends React.ElementType = typeof __ELEMENT_TYPE__, -> = Polymophic.ComponentPropsWithRef> +> = Polymorphic.ComponentPropsWithRef> -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, children, className, ...rest } = props @@ -47,5 +48,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'Menu.List' + export type { ComponentOwnProps as MenuListOwnProps, ComponentProps as MenuListProps } export default Component diff --git a/packages/react/src/components/menu/MenuPopover.tsx b/packages/react/src/components/menu/MenuPopover.tsx index 986cbe9..9cbf394 100644 --- a/packages/react/src/components/menu/MenuPopover.tsx +++ b/packages/react/src/components/menu/MenuPopover.tsx @@ -4,24 +4,25 @@ import type { PopoverProps } from 'react-aria-components' import React from 'react' import { Popover } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useMenu } from '~/components/menu/use-menu.hook' const __ELEMENT_TYPE__ = 'div' type ComponentOwnProps = PopoverProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Popover @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Button @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, blur, placement, position, ...rest } = props const Element = as ?? ModalOverlay @@ -48,5 +49,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Modal @@ -46,5 +47,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, orientation, position, size, variant, isBordered, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -51,5 +52,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef & { isSelected?: boolean } -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, variant, isSelected, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Link @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -42,5 +43,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Button @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, radius, size, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, style, color, width, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -50,5 +51,7 @@ const Component: ComponentType = React.forwardRef = SelectVariantProps & type ComponentProps< TData extends object, TElement extends React.ElementType = typeof __ELEMENT_TYPE__, -> = Polymophic.ComponentPropsWithRef> +> = Polymorphic.ComponentPropsWithRef> -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, @@ -176,5 +177,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'Select.Root' + export type { ComponentOwnProps as SelectOwnProps, ComponentProps as SelectProps } export default Component diff --git a/packages/react/src/components/select/SelectOption.tsx b/packages/react/src/components/select/SelectOption.tsx index 6348b64..2747717 100644 --- a/packages/react/src/components/select/SelectOption.tsx +++ b/packages/react/src/components/select/SelectOption.tsx @@ -4,24 +4,25 @@ import type { ListBoxItemProps } from 'react-aria-components' import React from 'react' import { ListBoxItem } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useSelect } from '~/components/select/use-select.hook' const __ELEMENT_TYPE__ = 'option' type ComponentOwnProps = ListBoxItemProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? ListBoxItem @@ -66,5 +67,7 @@ const Component: ComponentType = React.forwardRef = SelectValueProps type ComponentProps< TData extends object, TElement extends React.ElementType = typeof __ELEMENT_TYPE__, -> = Polymophic.ComponentPropsWithRef> +> = Polymorphic.ComponentPropsWithRef> -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, className, ...rest } = props @@ -50,5 +51,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'Select.Value' + export type { ComponentOwnProps as SelectValueOwnProps, ComponentProps as SelectValueProps } export default Component diff --git a/packages/react/src/components/spinner/Spinner.tsx b/packages/react/src/components/spinner/Spinner.tsx index 7e267c7..ef3221f 100644 --- a/packages/react/src/components/spinner/Spinner.tsx +++ b/packages/react/src/components/spinner/Spinner.tsx @@ -4,23 +4,24 @@ import type { SpinnerVariantProps } from '@giantnodes/theme' import React from 'react' import { spinner } from '@giantnodes/theme' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' const __ELEMENT_TYPE__ = 'svg' type ComponentOwnProps = SpinnerVariantProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, className, size, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -48,5 +49,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, className, color, size, ...rest } = props const Element = as ?? Switch @@ -52,5 +53,7 @@ const Component: ComponentType = React.forwardRef mode?: 'none' | 'single' | 'multiple' } -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, behavior, mode, size, sticky, striped, headingless, ...rest } = props const Element = as ?? Table @@ -53,5 +54,7 @@ const Component: ComponentType = React.forwardRef = TableBodyProps type ComponentProps< TData extends object, TElement extends React.ElementType = typeof __ELEMENT_TYPE__, -> = Polymophic.ComponentPropsWithRef> +> = Polymorphic.ComponentPropsWithRef> -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, children, className, ...rest } = props @@ -47,5 +48,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'Table.Body' + export type { ComponentOwnProps as TableBodyOwnProps, ComponentProps as TableBodyProps } export default Component diff --git a/packages/react/src/components/table/TableCell.tsx b/packages/react/src/components/table/TableCell.tsx index d76fbe2..3765654 100644 --- a/packages/react/src/components/table/TableCell.tsx +++ b/packages/react/src/components/table/TableCell.tsx @@ -5,24 +5,25 @@ import type { CellProps } from 'react-aria-components' import React from 'react' import { Cell } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useTable } from '~/components/table/use-table.hook' const __ELEMENT_TYPE__ = 'td' type ComponentOwnProps = CellProps & Pick -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, size, ...rest } = props const Element = as ?? Cell @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, size, ...rest } = props const Element = as ?? Column @@ -45,5 +46,7 @@ const Component: ComponentType = React.forwardRef = TableHeaderProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, children, className, columns, ...rest } = props @@ -56,5 +57,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'Table.Head' + export type { ComponentOwnProps as TableHeadOwnProps, ComponentProps as TableHeadProps } export default Component diff --git a/packages/react/src/components/table/TableRow.tsx b/packages/react/src/components/table/TableRow.tsx index 779af11..55aaacb 100644 --- a/packages/react/src/components/table/TableRow.tsx +++ b/packages/react/src/components/table/TableRow.tsx @@ -4,7 +4,7 @@ import type { RowProps } from 'react-aria-components' import React from 'react' import { Button, Collection, Row, useTableOptions } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import Checkbox from '~/components/checkbox/Checkbox' import TableCell from '~/components/table/TableCell' import { useTable } from '~/components/table/use-table.hook' @@ -16,16 +16,17 @@ type ComponentOwnProps = RowProps type ComponentProps< TData extends object, TElement extends React.ElementType = typeof __ELEMENT_TYPE__, -> = Polymophic.ComponentPropsWithRef> +> = Polymorphic.ComponentPropsWithRef> -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef( ( props: ComponentProps, - ref: Polymophic.Ref + ref: Polymorphic.Ref ) => { const { as, children, className, columns, ...rest } = props @@ -62,5 +63,7 @@ const Component: ComponentType = React.forwardRef( } ) +Component.displayName = 'Table.Row' + export type { ComponentOwnProps as TableRowOwnProps, ComponentProps as TableRowProps } export default Component diff --git a/packages/react/src/components/tooltip/Tooltip.tsx b/packages/react/src/components/tooltip/Tooltip.tsx index 20fd58c..2ab003d 100644 --- a/packages/react/src/components/tooltip/Tooltip.tsx +++ b/packages/react/src/components/tooltip/Tooltip.tsx @@ -5,7 +5,7 @@ import type { TooltipTriggerComponentProps } from 'react-aria-components' import React from 'react' import { TooltipTrigger } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { TooltipContext, useTooltipValue } from '~/components/tooltip/use-tooltip.hook' import { cn } from '~/utilities' @@ -13,36 +13,41 @@ const __ELEMENT_TYPE__ = 'div' type ComponentOwnProps = TooltipVariantProps & TooltipTriggerComponentProps -type ComponentProps = Polymophic.ComponentProps< +type ComponentProps = Polymorphic.ComponentProps< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode - -const Component: ComponentType = (props: ComponentProps) => { - const { as, children, className, ...rest } = props - - const Element = as ?? TooltipTrigger - - const context = useTooltipValue({}) - - const component = React.useMemo>( - () => ({ - className: context.slots.root({ className: cn(className) }), - ...rest, - }), - [className, context.slots, rest] - ) - - return ( - - {children} - - ) -} +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType + +const Component: ComponentType = React.forwardRef, ComponentOwnProps>( + (props: ComponentProps, _: Polymorphic.Ref) => { + const { as, children, className, ...rest } = props + + const Element = as ?? TooltipTrigger + + const context = useTooltipValue({}) + + const component = React.useMemo>( + () => ({ + className: context.slots.root({ className: cn(className) }), + ...rest, + }), + [className, context.slots, rest] + ) + + return ( + + {children} + + ) + } +) + +Component.displayName = 'Tooltip.Root' export type { ComponentOwnProps as TooltipOwnProps, ComponentProps as TooltipProps } export default Component diff --git a/packages/react/src/components/tooltip/TooltipArrow.tsx b/packages/react/src/components/tooltip/TooltipArrow.tsx index 1c4dccc..632a392 100644 --- a/packages/react/src/components/tooltip/TooltipArrow.tsx +++ b/packages/react/src/components/tooltip/TooltipArrow.tsx @@ -4,24 +4,25 @@ import type { OverlayArrowProps } from 'react-aria-components' import React from 'react' import { OverlayArrow } from 'react-aria-components' -import type * as Polymophic from '~/utilities/polymorphic' +import type * as Polymorphic from '~/utilities/polymorphic' import { useTooltip } from '~/components/tooltip/use-tooltip.hook' const __ELEMENT_TYPE__ = 'div' type ComponentOwnProps = OverlayArrowProps -type ComponentProps = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, className, ...rest } = props const Element = as ?? OverlayArrow @@ -38,5 +39,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Tooltip @@ -49,5 +50,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, ...rest } = props const Element = as ?? Button @@ -44,5 +45,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, level, ...rest } = props const Element = as ?? Heading @@ -58,5 +59,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, size, variant, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -43,5 +44,7 @@ const Component: ComponentType = React.forwardRef = Polymophic.ComponentPropsWithRef< +type ComponentProps = Polymorphic.ComponentPropsWithRef< TElement, ComponentOwnProps > -type ComponentType = ( +type ComponentType = (( props: ComponentProps -) => React.ReactNode +) => Polymorphic.ExoticComponentReturn) & + Polymorphic.NamedExoticComponentType const Component: ComponentType = React.forwardRef, ComponentOwnProps>( - (props: ComponentProps, ref: Polymophic.Ref) => { + (props: ComponentProps, ref: Polymorphic.Ref) => { const { as, children, className, size, variant, ...rest } = props const Element = as ?? __ELEMENT_TYPE__ @@ -43,5 +44,7 @@ const Component: ComponentType = React.forwardRef = TComponent extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[TComponent] : TComponent - -// import type React from 'react' -// -// type PropsOf = React.ComponentPropsWithoutRef -// -// type AsProp = { -// as?: C -// } -// -// type ExtendableProps, OverrideProps = Record> = OverrideProps & -// Omit -// -// type InheritableElementProps> = ExtendableProps< -// PropsOf, -// Props -// > -// -// type ComponentProps> = InheritableElementProps< -// C, -// Props & AsProp -// > -// -// type Ref = React.ComponentPropsWithRef['ref'] -// -// type ComponentPropsWithRef> = ComponentProps & { -// ref?: Ref -// } -// -// export type { ComponentPropsWithRef, ComponentProps, Ref }