diff --git a/apps/docs/app/examples/perf/page.tsx b/apps/docs/app/examples/perf/page.tsx index 7ceb787cf8..baae246b0c 100644 --- a/apps/docs/app/examples/perf/page.tsx +++ b/apps/docs/app/examples/perf/page.tsx @@ -253,9 +253,7 @@ export default function NextUIPerf() { - - Press Me! - + Press Me! ); } diff --git a/apps/docs/components/navbar.tsx b/apps/docs/components/navbar.tsx index cde6aac5e4..19e38ffc3a 100644 --- a/apps/docs/components/navbar.tsx +++ b/apps/docs/components/navbar.tsx @@ -54,7 +54,7 @@ export const Navbar: FC = ({children, routes, slug, tag}) => { const [isMenuOpen, setIsMenuOpen] = useState(false); const [commandKey, setCommandKey] = useState<"ctrl" | "command">("command"); - const ref = useRef(null); + const ref = useRef(null); const isMounted = useIsMounted(); const pathname = usePathname(); diff --git a/apps/docs/content/docs/customization/custom-variants.mdx b/apps/docs/content/docs/customization/custom-variants.mdx index 0141771a7a..dc5884801f 100644 --- a/apps/docs/content/docs/customization/custom-variants.mdx +++ b/apps/docs/content/docs/customization/custom-variants.mdx @@ -231,4 +231,51 @@ import customVariantsSlots from "@/content/customization/custom-variants/slots-c All NextUI components have the `Styles source` link on top of the page. This link will take you to the styles source code of the component. You can use this as a reference when creating your own custom component. - \ No newline at end of file + + + +### Types + +### Main Function + +```jsx +const Component = extendVariants(BaseComponent, options, config) + +/** + * BaseComponent -> NextUI component to extend + * options -> the variants to add/modify + * config -> config to extend the component + */ + +``` + +### Options + +```ts +type ExtendVariantsOptions = { + variants?: Record>, + defaultVariants?: Record, + compoundVariants?: Array & ClassProp> +} + +``` + +### Config + +```ts + /** + * Whether to merge the class names with `tailwind-merge` library. + * It's avoid to have duplicate tailwind classes. (Recommended) + * @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/README.md + * @default true + */ + twMerge?: boolean; + /** + * The config object for `tailwind-merge` library. + * @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/docs/configuration.md + */ + twMergeConfig?: TWMergeConfig; + ``` + +> **Note**: See the [Tailwind Merge Config](https://github.com/dcastil/tailwind-merge/blob/v1.8.1/docs/configuration.md) to learn more about it. + diff --git a/packages/components/accordion/package.json b/packages/components/accordion/package.json index 3955a40e93..8c3d42aa74 100644 --- a/packages/components/accordion/package.json +++ b/packages/components/accordion/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/accordion", - "version": "0.0.0-dev-v2-20230729132654", + "version": "0.0.0-dev-v2-20230729152229", "description": "Collapse display a list of high-level options that can expand/collapse to reveal more information.", "keywords": [ "react", diff --git a/packages/components/accordion/src/accordion-item.tsx b/packages/components/accordion/src/accordion-item.tsx index b511e3a54a..cc8a1724ea 100644 --- a/packages/components/accordion/src/accordion-item.tsx +++ b/packages/components/accordion/src/accordion-item.tsx @@ -1,4 +1,4 @@ -import {forwardRef} from "react"; +import {forwardRef} from "@nextui-org/system"; import {useMemo, ReactNode} from "react"; import {ChevronIcon} from "@nextui-org/shared-icons"; import {AnimatePresence, motion, useWillChange} from "framer-motion"; @@ -6,9 +6,9 @@ import {TRANSITION_VARIANTS} from "@nextui-org/framer-transitions"; import {UseAccordionItemProps, useAccordionItem} from "./use-accordion-item"; -export interface AccordionItemProps extends Omit {} +export interface AccordionItemProps extends UseAccordionItemProps {} -const AccordionItem = forwardRef((props, ref) => { +const AccordionItem = forwardRef<"button", AccordionItemProps>((props, ref) => { const { Component, classNames, @@ -30,7 +30,7 @@ const AccordionItem = forwardRef((props, getSubtitleProps, getContentProps, getIndicatorProps, - } = useAccordionItem({ref, ...props}); + } = useAccordionItem({...props, ref}); const willChange = useWillChange(); diff --git a/packages/components/accordion/src/accordion.tsx b/packages/components/accordion/src/accordion.tsx index be40d08ff1..168cab9d02 100644 --- a/packages/components/accordion/src/accordion.tsx +++ b/packages/components/accordion/src/accordion.tsx @@ -1,4 +1,4 @@ -import {forwardRef} from "react"; +import {forwardRef} from "@nextui-org/system"; import {LayoutGroup} from "framer-motion"; import {Divider} from "@nextui-org/divider"; import {Fragment, Key, useCallback, useMemo} from "react"; @@ -6,9 +6,9 @@ import {Fragment, Key, useCallback, useMemo} from "react"; import {UseAccordionProps, useAccordion} from "./use-accordion"; import AccordionItem from "./accordion-item"; -export interface AccordionProps extends Omit {} +export interface AccordionProps extends UseAccordionProps {} -const AccordionGroup = forwardRef((props, ref) => { +const AccordionGroup = forwardRef<"div", AccordionProps>((props, ref) => { const { Component, values, @@ -20,8 +20,8 @@ const AccordionGroup = forwardRef((props, ref) = handleFocusChanged: handleFocusChangedProps, itemClasses, } = useAccordion({ - ref, ...props, + ref, }); const handleFocusChanged = useCallback( (isFocused: boolean, key: Key) => handleFocusChangedProps(isFocused, key), diff --git a/packages/components/accordion/stories/accordion.stories.tsx b/packages/components/accordion/stories/accordion.stories.tsx index 691a9804b0..fc34b866d8 100644 --- a/packages/components/accordion/stories/accordion.stories.tsx +++ b/packages/components/accordion/stories/accordion.stories.tsx @@ -1,5 +1,5 @@ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {accordionItem} from "@nextui-org/theme"; import { AnchorIcon, @@ -52,7 +52,7 @@ const defaultProps = { const defaultContent = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."; -const Template: ComponentStory = (args: AccordionProps) => ( +const Template = (args: AccordionProps) => ( {defaultContent} @@ -66,7 +66,7 @@ const Template: ComponentStory = (args: AccordionProps) => ( ); -const TemplateWithSubtitle: ComponentStory = (args: AccordionProps) => ( +const TemplateWithSubtitle = (args: AccordionProps) => ( {defaultContent} @@ -89,7 +89,7 @@ const TemplateWithSubtitle: ComponentStory = (args: AccordionP ); -const TemplateWithStartContent: ComponentStory = (args: AccordionProps) => ( +const TemplateWithStartContent = (args: AccordionProps) => ( = (args: Accord ); -const VariantsTemplate: ComponentStory = (args: AccordionProps) => ( +const VariantsTemplate = (args: AccordionProps) => (

Default

@@ -207,7 +207,7 @@ const VariantsTemplate: ComponentStory = (args: AccordionProps
); -const CustomInidicatorTemplate: ComponentStory = (args: AccordionProps) => ( +const CustomInidicatorTemplate = (args: AccordionProps) => ( } title="Anchor"> {defaultContent} @@ -221,7 +221,7 @@ const CustomInidicatorTemplate: ComponentStory = (args: Accord ); -const ControlledTemplate: ComponentStory = (args: AccordionProps) => { +const ControlledTemplate = (args: AccordionProps) => { const [selectedKeys, setSelectedKeys] = React.useState(new Set(["1"])); // eslint-disable-next-line no-console @@ -242,7 +242,7 @@ const ControlledTemplate: ComponentStory = (args: AccordionPro ); }; -const CustomWithClassNamesTemplate: ComponentStory = (args: AccordionProps) => { +const CustomWithClassNamesTemplate = (args: AccordionProps) => { const itemClasses: AccordionItemProps["classNames"] = { base: "py-0 w-full", title: "font-normal text-base", diff --git a/packages/components/avatar/package.json b/packages/components/avatar/package.json index 93b604e88f..cc97782c54 100644 --- a/packages/components/avatar/package.json +++ b/packages/components/avatar/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/avatar", - "version": "0.0.0-dev-v2-20230729132654", + "version": "0.0.0-dev-v2-20230729152229", "description": "The Avatar component is used to represent a user, and displays the profile picture, initials or fallback icon.", "keywords": [ "avatar" diff --git a/packages/components/avatar/src/avatar-group.tsx b/packages/components/avatar/src/avatar-group.tsx index e43d96ef3c..f164e70b68 100644 --- a/packages/components/avatar/src/avatar-group.tsx +++ b/packages/components/avatar/src/avatar-group.tsx @@ -1,12 +1,12 @@ -import {forwardRef} from "react"; +import {forwardRef} from "@nextui-org/system"; import {AvatarGroupProvider} from "./avatar-group-context"; import {useAvatarGroup, UseAvatarGroupProps} from "./use-avatar-group"; import Avatar from "./avatar"; -export interface AvatarGroupProps extends Omit {} +export interface AvatarGroupProps extends UseAvatarGroupProps {} -const AvatarGroup = forwardRef((props, ref) => { +const AvatarGroup = forwardRef<"div", AvatarGroupProps>((props, ref) => { const { Component, clones, @@ -15,8 +15,8 @@ const AvatarGroup = forwardRef((props, ref) => renderCount = (count) => , getAvatarGroupProps, } = useAvatarGroup({ - ref, ...props, + ref, }); return ( diff --git a/packages/components/avatar/src/avatar.tsx b/packages/components/avatar/src/avatar.tsx index d0601125b1..4a0c2ad0ed 100644 --- a/packages/components/avatar/src/avatar.tsx +++ b/packages/components/avatar/src/avatar.tsx @@ -1,11 +1,12 @@ -import {useMemo, forwardRef} from "react"; +import {useMemo} from "react"; +import {forwardRef} from "@nextui-org/system"; import {AvatarIcon} from "./avatar-icon"; import {useAvatar, UseAvatarProps} from "./use-avatar"; -export interface AvatarProps extends Omit {} +export interface AvatarProps extends UseAvatarProps {} -const Avatar = forwardRef((props, ref) => { +const Avatar = forwardRef<"span", AvatarProps>((props, ref) => { const { Component, ImgComponent, @@ -21,8 +22,8 @@ const Avatar = forwardRef((props, ref) => { getAvatarProps, getImageProps, } = useAvatar({ - ref, ...props, + ref, }); const fallback = useMemo(() => { diff --git a/packages/components/avatar/src/use-avatar.ts b/packages/components/avatar/src/use-avatar.ts index c9ae9c0f1f..156b22f4b2 100644 --- a/packages/components/avatar/src/use-avatar.ts +++ b/packages/components/avatar/src/use-avatar.ts @@ -1,4 +1,4 @@ -import type {AvatarVariantProps, AvatarSlots, SlotsToClasses} from "@nextui-org/theme"; +import type {AvatarSlots, AvatarVariantProps, SlotsToClasses} from "@nextui-org/theme"; import {avatar} from "@nextui-org/theme"; import {HTMLNextUIProps, PropGetter} from "@nextui-org/system"; @@ -13,11 +13,7 @@ import {useHover} from "@react-aria/interactions"; import {useAvatarGroupContext} from "./avatar-group-context"; -export interface UseAvatarProps - extends Omit< - HTMLNextUIProps<"span", AvatarVariantProps>, - "children" | "isInGroup" | "isInGridGroup" - > { +interface Props extends HTMLNextUIProps<"span"> { /** * Ref to the DOM node. */ @@ -97,6 +93,9 @@ export interface UseAvatarProps classNames?: SlotsToClasses; } +export type UseAvatarProps = Props & + Omit; + export function useAvatar(props: UseAvatarProps = {}) { const groupContext = useAvatarGroupContext(); const isInGroup = !!groupContext; diff --git a/packages/components/avatar/stories/avatar-group.stories.tsx b/packages/components/avatar/stories/avatar-group.stories.tsx index b70a3ccf05..4587c60d6e 100644 --- a/packages/components/avatar/stories/avatar-group.stories.tsx +++ b/packages/components/avatar/stories/avatar-group.stories.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/display-name */ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {Avatar, AvatarGroup, AvatarGroupProps} from "../src"; @@ -34,7 +34,7 @@ export default { }, } as ComponentMeta; -const Template: ComponentStory = (args: AvatarGroupProps) => ( +const Template = (args: AvatarGroupProps) => ( diff --git a/packages/components/avatar/stories/avatar.stories.tsx b/packages/components/avatar/stories/avatar.stories.tsx index c06b6de6e3..2313bae7ab 100644 --- a/packages/components/avatar/stories/avatar.stories.tsx +++ b/packages/components/avatar/stories/avatar.stories.tsx @@ -1,5 +1,5 @@ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {Activity, Camera} from "@nextui-org/shared-icons"; import {avatar} from "@nextui-org/theme"; @@ -30,7 +30,7 @@ export default { }, } as ComponentMeta; -const Template: ComponentStory = (args: AvatarProps) => ; +const Template = (args: AvatarProps) => ; const defaultProps = { ...avatar.defaultVariants, diff --git a/packages/components/badge/package.json b/packages/components/badge/package.json index 95dde13736..658db07d82 100644 --- a/packages/components/badge/package.json +++ b/packages/components/badge/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/badge", - "version": "0.0.0-dev-v2-20230729132654", + "version": "0.0.0-dev-v2-20230729152229", "description": "Badges are used as a small numerical value or status descriptor for UI elements.", "keywords": [ "badge" diff --git a/packages/components/badge/src/badge.tsx b/packages/components/badge/src/badge.tsx index 65b403651e..2d953643ad 100644 --- a/packages/components/badge/src/badge.tsx +++ b/packages/components/badge/src/badge.tsx @@ -1,17 +1,17 @@ import type {ReactNode} from "react"; -import {forwardRef} from "react"; +import {forwardRef} from "@nextui-org/system"; import {UseBadgeProps, useBadge} from "./use-badge"; -export interface BadgeProps extends Omit { +export interface BadgeProps extends UseBadgeProps { children: ReactNode; } -const Badge = forwardRef((props, ref) => { +const Badge = forwardRef<"span", BadgeProps>((props, ref) => { const {Component, children, content, slots, classNames, getBadgeProps} = useBadge({ - ref, ...props, + ref, }); return ( diff --git a/packages/components/badge/src/use-badge.ts b/packages/components/badge/src/use-badge.ts index 0052459c0b..e5135f0eaa 100644 --- a/packages/components/badge/src/use-badge.ts +++ b/packages/components/badge/src/use-badge.ts @@ -8,7 +8,7 @@ import {clsx} from "@nextui-org/shared-utils"; import {ReactRef} from "@nextui-org/react-utils"; import {useMemo} from "react"; -export interface Props extends Omit, "content"> { +interface Props extends HTMLNextUIProps<"span", "content"> { /** * Ref to the DOM node. */ diff --git a/packages/components/badge/stories/badge.stories.tsx b/packages/components/badge/stories/badge.stories.tsx index 0a51f830db..d0800316dc 100644 --- a/packages/components/badge/stories/badge.stories.tsx +++ b/packages/components/badge/stories/badge.stories.tsx @@ -1,5 +1,5 @@ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {badge} from "@nextui-org/theme"; import {Avatar} from "@nextui-org/avatar"; import {CheckIcon} from "@nextui-org/shared-icons"; @@ -65,7 +65,7 @@ const defaultProps = { content: 5, }; -const Template: ComponentStory = (args: BadgeProps) => ( +const Template = (args: BadgeProps) => ( = (args: BadgeProps) => ( ); -const ShapesTemplate: ComponentStory = (args: BadgeProps) => ( +const ShapesTemplate = (args: BadgeProps) => (
@@ -86,7 +86,7 @@ const ShapesTemplate: ComponentStory = (args: BadgeProps) => (
); -const InvisibleTemplate: ComponentStory = (args: BadgeProps) => { +const InvisibleTemplate = (args: BadgeProps) => { const [isInvisible, setIsInvisible] = React.useState(false); return ( diff --git a/packages/components/button/package.json b/packages/components/button/package.json index 21bae6622c..696b57b696 100644 --- a/packages/components/button/package.json +++ b/packages/components/button/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/button", - "version": "0.0.0-dev-v2-20230729132654", + "version": "0.0.0-dev-v2-20230729152229", "description": "Buttons allow users to perform actions and choose with a single tap.", "keywords": [ "button" diff --git a/packages/components/button/src/button-group.tsx b/packages/components/button/src/button-group.tsx index 402caf3d75..848c864d59 100644 --- a/packages/components/button/src/button-group.tsx +++ b/packages/components/button/src/button-group.tsx @@ -1,14 +1,14 @@ -import {forwardRef} from "react"; +import {forwardRef} from "@nextui-org/system"; import {ButtonGroupProvider} from "./button-group-context"; import {UseButtonGroupProps, useButtonGroup} from "./use-button-group"; -export interface ButtonGroupProps extends Omit {} +export interface ButtonGroupProps extends UseButtonGroupProps {} -const ButtonGroup = forwardRef((props, ref) => { +const ButtonGroup = forwardRef<"div", ButtonGroupProps>((props, ref) => { const {Component, domRef, context, children, classNames, getButtonGroupProps} = useButtonGroup({ - ref, ...props, + ref, }); return ( diff --git a/packages/components/button/src/button.tsx b/packages/components/button/src/button.tsx index 04a97f0a76..d95b193495 100644 --- a/packages/components/button/src/button.tsx +++ b/packages/components/button/src/button.tsx @@ -1,12 +1,12 @@ import {Spinner} from "@nextui-org/spinner"; import {Ripple} from "@nextui-org/ripple"; -import {forwardRef} from "react"; +import {forwardRef} from "@nextui-org/system"; import {UseButtonProps, useButton} from "./use-button"; -export interface ButtonProps extends Omit {} +export interface ButtonProps extends UseButtonProps {} -const Button = forwardRef((props, ref) => { +const Button = forwardRef<"button", ButtonProps>((props, ref) => { const { Component, domRef, @@ -22,8 +22,8 @@ const Button = forwardRef((props, ref) => { disableRipple, getButtonProps, } = useButton({ - ref, ...props, + ref, }); return ( diff --git a/packages/components/button/src/use-button-group.ts b/packages/components/button/src/use-button-group.ts index b05296d430..c11fc46a5e 100644 --- a/packages/components/button/src/use-button-group.ts +++ b/packages/components/button/src/use-button-group.ts @@ -6,7 +6,7 @@ import {buttonGroup} from "@nextui-org/theme"; import {HTMLNextUIProps, PropGetter, mapPropsVariants} from "@nextui-org/system"; import {useDOMRef} from "@nextui-org/react-utils"; import {useMemo, useCallback} from "react"; -interface Props extends HTMLNextUIProps<"div">, ButtonGroupVariantProps { +interface Props extends HTMLNextUIProps, ButtonGroupVariantProps { /** * Ref to the DOM node. */ diff --git a/packages/components/button/stories/button-group.stories.tsx b/packages/components/button/stories/button-group.stories.tsx index 0d6c8113bc..2e77f76288 100644 --- a/packages/components/button/stories/button-group.stories.tsx +++ b/packages/components/button/stories/button-group.stories.tsx @@ -1,5 +1,5 @@ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {button, buttonGroup} from "@nextui-org/theme"; import {Button, ButtonGroup, ButtonGroupProps} from "../src"; @@ -55,7 +55,7 @@ const defaultProps = { ...buttonGroup.defaultVariants, }; -const Template: ComponentStory = (args: ButtonGroupProps) => ( +const Template = (args: ButtonGroupProps) => ( diff --git a/packages/components/button/stories/button.stories.tsx b/packages/components/button/stories/button.stories.tsx index 6f67fb2daf..14bb2875f2 100644 --- a/packages/components/button/stories/button.stories.tsx +++ b/packages/components/button/stories/button.stories.tsx @@ -1,5 +1,5 @@ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {button} from "@nextui-org/theme"; import {Camera, HeadphonesIcon, Notification} from "@nextui-org/shared-icons"; @@ -68,9 +68,9 @@ const defaultProps = { ...button.defaultVariants, }; -const Template: ComponentStory = (args: ButtonProps) => @@ -133,11 +129,7 @@ const Template: ComponentStory = ({ ); -const DividerTemplate: ComponentStory = ({ - color, - variant, - ...args -}: DropdownProps & DropdownMenuProps) => ( +const DividerTemplate = ({color, variant, ...args}: DropdownProps & DropdownMenuProps) => ( @@ -153,11 +145,7 @@ const DividerTemplate: ComponentStory = ({ ); -const DisabledKeysTemplate: ComponentStory = ({ - color, - variant, - ...args -}: DropdownProps & DropdownMenuProps) => ( +const DisabledKeysTemplate = ({color, variant, ...args}: DropdownProps & DropdownMenuProps) => ( @@ -179,11 +167,7 @@ const DisabledKeysTemplate: ComponentStory = ({ ); -const SingleSelectionTemplate: ComponentStory = ({ - color, - variant, - ...args -}: DropdownProps & DropdownMenuProps) => { +const SingleSelectionTemplate = ({color, variant, ...args}: DropdownProps & DropdownMenuProps) => { const [selected, setSelected] = React.useState>(new Set(["text"])); const selectedValue = React.useMemo( @@ -218,7 +202,7 @@ const SingleSelectionTemplate: ComponentStory = ({ ); }; -const MultipleSelectionTemplate: ComponentStory = ({ +const MultipleSelectionTemplate = ({ color, variant, ...args @@ -258,7 +242,7 @@ const MultipleSelectionTemplate: ComponentStory = ({ ); }; -const WithShortcutTemplate: ComponentStory = ({color, variant, ...args}) => ( +const WithShortcutTemplate = ({color, variant, ...args}) => ( @@ -280,12 +264,12 @@ const WithShortcutTemplate: ComponentStory = ({color, variant, ...args}) => ); -const WithStartContentTemplate: ComponentStory = ({ +const WithStartContentTemplate = ({ color, variant, disableAnimation, ...args -}) => { +}: DropdownProps & DropdownMenuProps) => { const iconClasses = "text-2xl text-secondary pointer-events-none flex-shrink-0"; return ( @@ -331,12 +315,7 @@ const WithStartContentTemplate: ComponentStory = ({ ); }; -const WithEndContentTemplate: ComponentStory = ({ - color, - variant, - disableAnimation, - ...args -}) => { +const WithEndContentTemplate = ({color, variant, disableAnimation, ...args}) => { const iconClasses = "text-2xl text-default-500 pointer-events-none flex-shrink-0"; return ( @@ -369,12 +348,7 @@ const WithEndContentTemplate: ComponentStory = ({ ); }; -const WithDescriptionTemplate: ComponentStory = ({ - color, - variant, - disableAnimation, - ...args -}) => { +const WithDescriptionTemplate = ({color, variant, disableAnimation, ...args}) => { const iconClasses = "text-2xl text-secondary pointer-events-none flex-shrink-0"; return ( @@ -424,7 +398,7 @@ const WithDescriptionTemplate: ComponentStory = ({ ); }; -const WithSectionsTemplate: ComponentStory = ({color, variant, disableAnimation, ...args}) => { +const WithSectionsTemplate = ({color, variant, disableAnimation, ...args}) => { const iconClasses = "text-2xl text-secondary pointer-events-none flex-shrink-0"; return ( @@ -484,7 +458,7 @@ const WithSectionsTemplate: ComponentStory = ({color, variant, disableAnima ); }; -const CustomTriggerTemplate: ComponentStory = ({variant, ...args}) => { +const CustomTriggerTemplate = ({variant, ...args}) => { return (
diff --git a/packages/components/image/package.json b/packages/components/image/package.json index d89aed85c7..9ed43b9ae8 100644 --- a/packages/components/image/package.json +++ b/packages/components/image/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/image", - "version": "0.0.0-dev-v2-20230729132654", + "version": "0.0.0-dev-v2-20230729152229", "description": "A simple image component", "keywords": [ "image" diff --git a/packages/components/image/src/image.tsx b/packages/components/image/src/image.tsx index d99bad2750..1a242bf836 100644 --- a/packages/components/image/src/image.tsx +++ b/packages/components/image/src/image.tsx @@ -1,10 +1,11 @@ -import {cloneElement, forwardRef} from "react"; +import {cloneElement} from "react"; +import {forwardRef} from "@nextui-org/system"; import {UseImageProps, useImage} from "./use-image"; -export interface ImageProps extends Omit {} +export interface ImageProps extends Omit {} -const Image = forwardRef((props, ref) => { +const Image = forwardRef<"img", ImageProps>((props, ref) => { const { Component, domRef, @@ -19,8 +20,8 @@ const Image = forwardRef((props, ref) => { getWrapperProps, getBlurredImgProps, } = useImage({ - ref, ...props, + ref, }); const img = ; diff --git a/packages/components/image/stories/image.stories.tsx b/packages/components/image/stories/image.stories.tsx index bd6cc2fa1c..dcbec31a66 100644 --- a/packages/components/image/stories/image.stories.tsx +++ b/packages/components/image/stories/image.stories.tsx @@ -1,5 +1,5 @@ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {image} from "@nextui-org/theme"; import {Image, ImageProps} from "../src"; @@ -52,9 +52,9 @@ const defaultProps = { disableSkeleton: true, }; -const Template: ComponentStory = (args: ImageProps) => ; +const Template = (args: ImageProps) => ; -const LoadingTemplate: ComponentStory = (args: ImageProps) => { +const LoadingTemplate = (args: ImageProps) => { const [isLoading, setIsLoading] = React.useState(true); React.useEffect(() => { diff --git a/packages/components/input/package.json b/packages/components/input/package.json index a04c313b7c..c703d3e486 100644 --- a/packages/components/input/package.json +++ b/packages/components/input/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/input", - "version": "0.0.0-dev-v2-20230729132654", + "version": "0.0.0-dev-v2-20230729152229", "description": "The input component is designed for capturing user input within a text field.", "keywords": [ "input" diff --git a/packages/components/input/src/input.tsx b/packages/components/input/src/input.tsx index 9c654f833a..ef05772415 100644 --- a/packages/components/input/src/input.tsx +++ b/packages/components/input/src/input.tsx @@ -1,12 +1,12 @@ import {CloseFilledIcon} from "@nextui-org/shared-icons"; -import {useMemo, forwardRef} from "react"; +import {useMemo} from "react"; +import {forwardRef} from "@nextui-org/system"; import {UseInputProps, useInput} from "./use-input"; -export interface InputProps - extends Omit {} +export interface InputProps extends Omit {} -const Input = forwardRef((props, ref) => { +const Input = forwardRef<"input", InputProps>((props, ref) => { const { Component, label, @@ -30,7 +30,7 @@ const Input = forwardRef((props, ref) => { getDescriptionProps, getErrorMessageProps, getClearButtonProps, - } = useInput({ref, ...props}); + } = useInput({...props, ref}); const labelContent = label ? : null; diff --git a/packages/components/input/src/textarea.tsx b/packages/components/input/src/textarea.tsx index 56874fec9a..54d685735c 100644 --- a/packages/components/input/src/textarea.tsx +++ b/packages/components/input/src/textarea.tsx @@ -1,4 +1,4 @@ -import {forwardRef} from "react"; +import {forwardRef} from "@nextui-org/system"; import {mergeProps} from "@react-aria/utils"; import TextareaAutosize from "react-textarea-autosize"; @@ -24,7 +24,7 @@ export type TextareaHeightChangeMeta = { rowHeight: number; }; -export interface TextAreaProps extends Omit { +export interface TextAreaProps extends Omit { /** * Minimum number of rows to show for textarea * @default 3 @@ -51,7 +51,7 @@ export interface TextAreaProps extends Omit void; } -const Textarea = forwardRef( +const Textarea = forwardRef<"textarea", TextAreaProps>( ( {style, minRows = 3, maxRows = 8, cacheMeasurements = false, onHeightChange, ...otherProps}, ref, @@ -70,7 +70,7 @@ const Textarea = forwardRef( getHelperWrapperProps, getDescriptionProps, getErrorMessageProps, - } = useInput({ref, ...otherProps, isMultiline: true}); + } = useInput({...otherProps, ref, isMultiline: true}); const labelContent = ; const inputProps = getInputProps(); diff --git a/packages/components/input/stories/input.stories.tsx b/packages/components/input/stories/input.stories.tsx index 779a9c286c..10cb091869 100644 --- a/packages/components/input/stories/input.stories.tsx +++ b/packages/components/input/stories/input.stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable jsx-a11y/interactive-supports-focus */ /* eslint-disable jsx-a11y/click-events-have-key-events */ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {input} from "@nextui-org/theme"; import { MailFilledIcon, @@ -11,7 +11,7 @@ import { CloseFilledIcon, } from "@nextui-org/shared-icons"; -import {Input, useInput} from "../src"; +import {Input, InputProps, useInput} from "../src"; export default { title: "Components/Input", @@ -67,20 +67,20 @@ const defaultProps = { label: "Email", }; -const Template: ComponentStory = (args) => ( +const Template = (args) => (
); -const MirrorTemplate: ComponentStory = (args) => ( +const MirrorTemplate = (args) => (
); -const PasswordTemplate: ComponentStory = (args) => { +const PasswordTemplate = (args) => { const [isPasswordVisible, setIsPasswordVisible] = React.useState(false); const togglePasswordVisibility = () => setIsPasswordVisible(!isPasswordVisible); @@ -109,7 +109,7 @@ const PasswordTemplate: ComponentStory = (args) => { ); }; -const RegexValidationTemplate: ComponentStory = (args) => { +const RegexValidationTemplate = (args) => { const [value, setValue] = React.useState(""); const validateEmail = (value) => value.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i); @@ -134,7 +134,7 @@ const RegexValidationTemplate: ComponentStory = (args) => { ); }; -const ControlledTemplate: ComponentStory = (args) => { +const ControlledTemplate = (args) => { const [value, setValue] = React.useState(""); return ( @@ -145,7 +145,7 @@ const ControlledTemplate: ComponentStory = (args) => { ); }; -const LabelPlacementTemplate: ComponentStory = (args) => ( +const LabelPlacementTemplate = (args) => (

Without placeholder

@@ -166,7 +166,7 @@ const LabelPlacementTemplate: ComponentStory = (args) => (
); -const StartContentTemplate: ComponentStory = (args) => ( +const StartContentTemplate = (args) => (
= (args) => (
); -const EndContentTemplate: ComponentStory = (args) => ( +const EndContentTemplate = (args) => (
= (args) => (
); -const StartAndEndContentTemplate: ComponentStory = (args) => ( +const StartAndEndContentTemplate = (args) => (
= (args) => (
); -const InputTypesTemplate: ComponentStory = (args) => ( +const InputTypesTemplate = (args) => (
@@ -311,7 +311,7 @@ const InputTypesTemplate: ComponentStory = (args) => (
); -const CustomWithClassNamesTemplate: ComponentStory = (args) => ( +const CustomWithClassNamesTemplate = (args) => (
= (args) => (
); -const CustomWithHooksTemplate: ComponentStory = (args) => { +const CustomWithHooksTemplate = (args: InputProps) => { const { Component, label, diff --git a/packages/components/input/stories/textarea.stories.tsx b/packages/components/input/stories/textarea.stories.tsx index 2a375ad0a9..420d74d2a6 100644 --- a/packages/components/input/stories/textarea.stories.tsx +++ b/packages/components/input/stories/textarea.stories.tsx @@ -1,5 +1,5 @@ import React from "react"; -import {ComponentStory, ComponentMeta} from "@storybook/react"; +import {ComponentMeta} from "@storybook/react"; import {input} from "@nextui-org/theme"; import {Textarea, TextAreaProps} from "../src"; @@ -59,13 +59,13 @@ const defaultProps = { placeholder: "Enter your description", }; -const Template: ComponentStory = (args: TextAreaProps) => ( +const Template = (args: TextAreaProps) => (