diff --git a/apps/docs/content/docs/components/input-otp.mdx b/apps/docs/content/docs/components/input-otp.mdx index 38e03653b1..854a35ec30 100644 --- a/apps/docs/content/docs/components/input-otp.mdx +++ b/apps/docs/content/docs/components/input-otp.mdx @@ -303,6 +303,12 @@ You can customize the styles of the `InputOtp` component using the `classNames` description: "Allows to set custom class names for the Input slots.", default: "-" }, + { + attribute: "autoFocus", + type: "boolean", + description: "Whether the element should receive focus on render.", + default: "false" + }, { attribute: "textAlign", type: "left | center | right", diff --git a/apps/docs/content/docs/components/radio-group.mdx b/apps/docs/content/docs/components/radio-group.mdx index 4a2ae2545a..5518af4fb4 100644 --- a/apps/docs/content/docs/components/radio-group.mdx +++ b/apps/docs/content/docs/components/radio-group.mdx @@ -83,6 +83,7 @@ You can use the `value` and `onValueChange` properties to control the radio inpu - Radio Slots - **base**: Radio root wrapper, it wraps all elements. - **wrapper**: Radio wrapper, it wraps the control element. + - **hiddenInput**: The hidden input element that is used to handle the radio state. - **labelWrapper**: Label and description wrapper. - **label**: Label slot for the radio. - **control**: Control element, it is the circle element. diff --git a/apps/docs/content/docs/components/switch.mdx b/apps/docs/content/docs/components/switch.mdx index 292446bb05..f6d577a314 100644 --- a/apps/docs/content/docs/components/switch.mdx +++ b/apps/docs/content/docs/components/switch.mdx @@ -79,6 +79,7 @@ You can also add icons to start and end of the switch by using `startContent` an - **base**: Base slot for the switch. It is the main wrapper. - **wrapper**: The wrapper of the start icon, end icon and thumb. +- **hiddenInput**: The hidden input element that is used to handle the switch state. - **thumb**: The thumb element of the switch. It is the circle element. - **label**: The label slot of the switch. - **startContent**: The icon slot at the start of the switch. diff --git a/packages/components/alert/CHANGELOG.md b/packages/components/alert/CHANGELOG.md index 5696ec9a54..ab6eb1a147 100644 --- a/packages/components/alert/CHANGELOG.md +++ b/packages/components/alert/CHANGELOG.md @@ -1,5 +1,12 @@ # @nextui-org/alert +## 2.2.5 + +### Patch Changes + +- Updated dependencies [[`dfefdd6`](https://github.com/nextui-org/nextui/commit/dfefdd6250eb81ae653e611a8dff12b2ae29a09c)]: + - @nextui-org/button@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/components/alert/package.json b/packages/components/alert/package.json index e239b75d8a..4986112a83 100644 --- a/packages/components/alert/package.json +++ b/packages/components/alert/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/alert", - "version": "2.2.4", + "version": "2.2.5", "description": "Alerts are temporary notifications that provide concise feedback about an action or event.", "keywords": [ "alert" diff --git a/packages/components/autocomplete/CHANGELOG.md b/packages/components/autocomplete/CHANGELOG.md index a7b906af4f..f5552c1879 100644 --- a/packages/components/autocomplete/CHANGELOG.md +++ b/packages/components/autocomplete/CHANGELOG.md @@ -1,5 +1,18 @@ # @nextui-org/autocomplete +## 2.3.5 + +### Patch Changes + +- Updated dependencies [[`11eae5c`](https://github.com/nextui-org/nextui/commit/11eae5cc808e10db07b509f4e06d30441bb1937a), [`dfefdd6`](https://github.com/nextui-org/nextui/commit/dfefdd6250eb81ae653e611a8dff12b2ae29a09c)]: + - @nextui-org/listbox@2.3.5 + - @nextui-org/button@2.2.5 + - @nextui-org/form@2.1.5 + - @nextui-org/popover@2.3.5 + - @nextui-org/input@2.4.5 + - @nextui-org/scroll-shadow@2.3.3 + - @nextui-org/spinner@2.2.4 + ## 2.3.4 ### Patch Changes diff --git a/packages/components/autocomplete/package.json b/packages/components/autocomplete/package.json index 1182626e04..6718f5788d 100644 --- a/packages/components/autocomplete/package.json +++ b/packages/components/autocomplete/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/autocomplete", - "version": "2.3.4", + "version": "2.3.5", "description": "An autocomplete combines a text input with a listbox, allowing users to filter a list of options to items matching a query.", "keywords": [ "autocomplete" diff --git a/packages/components/button/CHANGELOG.md b/packages/components/button/CHANGELOG.md index bf668239d8..3a13697029 100644 --- a/packages/components/button/CHANGELOG.md +++ b/packages/components/button/CHANGELOG.md @@ -1,5 +1,15 @@ # @nextui-org/button +## 2.2.5 + +### Patch Changes + +- [#4284](https://github.com/nextui-org/nextui/pull/4284) [`dfefdd6`](https://github.com/nextui-org/nextui/commit/dfefdd6250eb81ae653e611a8dff12b2ae29a09c) Thanks [@sudongyuer](https://github.com/sudongyuer)! - Refactor Button & Card Ripple + +- Updated dependencies [[`dfefdd6`](https://github.com/nextui-org/nextui/commit/dfefdd6250eb81ae653e611a8dff12b2ae29a09c)]: + - @nextui-org/ripple@2.2.4 + - @nextui-org/spinner@2.2.4 + ## 2.2.4 ### Patch Changes diff --git a/packages/components/button/package.json b/packages/components/button/package.json index 727a64c028..4485f37dea 100644 --- a/packages/components/button/package.json +++ b/packages/components/button/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/button", - "version": "2.2.4", + "version": "2.2.5", "description": "Buttons allow users to perform actions and choose with a single tap.", "keywords": [ "button" diff --git a/packages/components/button/src/use-button.ts b/packages/components/button/src/use-button.ts index 78dd90929f..626a0bf43d 100644 --- a/packages/components/button/src/use-button.ts +++ b/packages/components/button/src/use-button.ts @@ -14,7 +14,7 @@ import {useDOMRef, filterDOMProps} from "@nextui-org/react-utils"; import {button} from "@nextui-org/theme"; import {isValidElement, cloneElement, useMemo} from "react"; import {useAriaButton} from "@nextui-org/use-aria-button"; -import {useHover} from "@react-aria/interactions"; +import {PressEvent, useHover} from "@react-aria/interactions"; import {SpinnerProps} from "@nextui-org/spinner"; import {useRipple} from "@nextui-org/ripple"; @@ -135,22 +135,22 @@ export function useButton(props: UseButtonProps) { ], ); - const {onClick: onRippleClickHandler, onClear: onClearRipple, ripples} = useRipple(); + const {onPress: onRipplePressHandler, onClear: onClearRipple, ripples} = useRipple(); - const handleClick = useCallback( - (e: React.MouseEvent) => { + const handlePress = useCallback( + (e: PressEvent) => { if (disableRipple || isDisabled || disableAnimation) return; - domRef.current && onRippleClickHandler(e); + domRef.current && onRipplePressHandler(e); }, - [disableRipple, isDisabled, disableAnimation, domRef, onRippleClickHandler], + [disableRipple, isDisabled, disableAnimation, domRef, onRipplePressHandler], ); const {buttonProps: ariaButtonProps, isPressed} = useAriaButton( { elementType: as, isDisabled, - onPress, - onClick: chain(onClick, handleClick), + onPress: chain(onPress, handlePress), + onClick: onClick, ...otherProps, } as AriaButtonProps, domRef, diff --git a/packages/components/calendar/CHANGELOG.md b/packages/components/calendar/CHANGELOG.md index b526f9e667..808cda1437 100644 --- a/packages/components/calendar/CHANGELOG.md +++ b/packages/components/calendar/CHANGELOG.md @@ -1,5 +1,12 @@ # @nextui-org/calendar +## 2.2.5 + +### Patch Changes + +- Updated dependencies [[`dfefdd6`](https://github.com/nextui-org/nextui/commit/dfefdd6250eb81ae653e611a8dff12b2ae29a09c)]: + - @nextui-org/button@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/components/calendar/package.json b/packages/components/calendar/package.json index 6249fd7a21..3a5152a661 100644 --- a/packages/components/calendar/package.json +++ b/packages/components/calendar/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/calendar", - "version": "2.2.4", + "version": "2.2.5", "description": "A calendar displays one or more date grids and allows users to select a single date.", "keywords": [ "calendar" diff --git a/packages/components/card/CHANGELOG.md b/packages/components/card/CHANGELOG.md index 50214ebaaf..b72535e9be 100644 --- a/packages/components/card/CHANGELOG.md +++ b/packages/components/card/CHANGELOG.md @@ -1,5 +1,14 @@ # @nextui-org/card +## 2.2.5 + +### Patch Changes + +- [#4284](https://github.com/nextui-org/nextui/pull/4284) [`dfefdd6`](https://github.com/nextui-org/nextui/commit/dfefdd6250eb81ae653e611a8dff12b2ae29a09c) Thanks [@sudongyuer](https://github.com/sudongyuer)! - Refactor Button & Card Ripple + +- Updated dependencies [[`dfefdd6`](https://github.com/nextui-org/nextui/commit/dfefdd6250eb81ae653e611a8dff12b2ae29a09c)]: + - @nextui-org/ripple@2.2.4 + ## 2.2.4 ### Patch Changes diff --git a/packages/components/card/package.json b/packages/components/card/package.json index 585f47ffc5..4a169568d4 100644 --- a/packages/components/card/package.json +++ b/packages/components/card/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/card", - "version": "2.2.4", + "version": "2.2.5", "description": "Card is a container for text, photos, and actions in the context of a single subject.", "keywords": [ "card" diff --git a/packages/components/card/src/use-card.ts b/packages/components/card/src/use-card.ts index 913d3a8f27..ceb0f7f2c8 100644 --- a/packages/components/card/src/use-card.ts +++ b/packages/components/card/src/use-card.ts @@ -4,10 +4,10 @@ import type {AriaButtonProps} from "@nextui-org/use-aria-button"; import type {RippleProps} from "@nextui-org/ripple"; import {card} from "@nextui-org/theme"; -import {MouseEvent, ReactNode, useCallback, useMemo} from "react"; +import {ReactNode, useCallback, useMemo} from "react"; import {chain, mergeProps} from "@react-aria/utils"; import {useFocusRing} from "@react-aria/focus"; -import {useHover} from "@react-aria/interactions"; +import {PressEvent, useHover} from "@react-aria/interactions"; import {useAriaButton} from "@nextui-org/use-aria-button"; import { HTMLNextUIProps, @@ -96,20 +96,22 @@ export function useCard(originalProps: UseCardProps) { const baseStyles = clsx(classNames?.base, className); - const {onClick: onRippleClickHandler, onClear: onClearRipple, ripples} = useRipple(); + const {onClear: onClearRipple, onPress: onRipplePressHandler, ripples} = useRipple(); - const handleClick = (e: MouseEvent) => { - if (!disableAnimation && !disableRipple && domRef.current) { - onRippleClickHandler(e); - } - }; + const handlePress = useCallback( + (e: PressEvent) => { + if (disableRipple || disableAnimation) return; + domRef.current && onRipplePressHandler(e); + }, + [disableRipple, disableAnimation, domRef, onRipplePressHandler], + ); const {buttonProps, isPressed} = useAriaButton( { - onPress, + onPress: chain(onPress, handlePress), elementType: as, isDisabled: !originalProps.isPressable, - onClick: chain(onClick, handleClick), + onClick: onClick, allowTextSelectionOnPress, ...otherProps, } as unknown as AriaButtonProps<"button">, @@ -209,7 +211,7 @@ export function useCard(originalProps: UseCardProps) { isPressable: originalProps.isPressable, isHoverable: originalProps.isHoverable, disableRipple, - handleClick, + handlePress, isFocusVisible, getCardProps, getRippleProps, diff --git a/packages/components/checkbox/CHANGELOG.md b/packages/components/checkbox/CHANGELOG.md index b82efedcec..4b0f3c4ac2 100644 --- a/packages/components/checkbox/CHANGELOG.md +++ b/packages/components/checkbox/CHANGELOG.md @@ -1,5 +1,14 @@ # @nextui-org/checkbox +## 2.3.5 + +### Patch Changes + +- [#4311](https://github.com/nextui-org/nextui/pull/4311) [`03abf1d`](https://github.com/nextui-org/nextui/commit/03abf1daf4fe5ee74f4766cd4fd78068ac25ed78) Thanks [@jrgarciadev](https://github.com/jrgarciadev)! - Fix #4252 #4260 interactive elements were not working properly + +- Updated dependencies []: + - @nextui-org/form@2.1.5 + ## 2.3.4 ### Patch Changes diff --git a/packages/components/checkbox/package.json b/packages/components/checkbox/package.json index f778fd0e0e..decee9d17f 100644 --- a/packages/components/checkbox/package.json +++ b/packages/components/checkbox/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/checkbox", - "version": "2.3.4", + "version": "2.3.5", "description": "Checkboxes allow users to select multiple items from a list of individual items, or to mark one individual item as selected.", "keywords": [ "checkbox" diff --git a/packages/components/checkbox/src/checkbox.tsx b/packages/components/checkbox/src/checkbox.tsx index 9ca4ee6e2a..2fc2a18c2d 100644 --- a/packages/components/checkbox/src/checkbox.tsx +++ b/packages/components/checkbox/src/checkbox.tsx @@ -1,5 +1,4 @@ import {forwardRef} from "@nextui-org/system"; -import {VisuallyHidden} from "@react-aria/visually-hidden"; import {cloneElement, ReactElement} from "react"; import {UseCheckboxProps, useCheckbox} from "./use-checkbox"; @@ -26,9 +25,7 @@ const Checkbox = forwardRef<"input", CheckboxProps>((props, ref) => { return ( - - - + {clonedIcon} {children && {children}} diff --git a/packages/components/checkbox/src/use-checkbox.ts b/packages/components/checkbox/src/use-checkbox.ts index 376541cb1d..bba104f6d6 100644 --- a/packages/components/checkbox/src/use-checkbox.ts +++ b/packages/components/checkbox/src/use-checkbox.ts @@ -310,9 +310,10 @@ export function useCheckbox(props: UseCheckboxProps = {}) { return { ref: mergeRefs(inputRef, ref), ...mergeProps(inputProps, focusProps), + className: slots.hiddenInput({class: classNames?.hiddenInput}), onChange: chain(inputProps.onChange, handleCheckboxChange), }; - }, [inputProps, focusProps, handleCheckboxChange]); + }, [inputProps, focusProps, handleCheckboxChange, classNames?.hiddenInput]); const getLabelProps: PropGetter = useCallback( () => ({ diff --git a/packages/components/date-input/CHANGELOG.md b/packages/components/date-input/CHANGELOG.md index c9592e74f6..00654359a5 100644 --- a/packages/components/date-input/CHANGELOG.md +++ b/packages/components/date-input/CHANGELOG.md @@ -1,5 +1,12 @@ # @nextui-org/date-input +## 2.3.5 + +### Patch Changes + +- Updated dependencies []: + - @nextui-org/form@2.1.5 + ## 2.3.4 ### Patch Changes diff --git a/packages/components/date-input/package.json b/packages/components/date-input/package.json index 3925824465..62d741f788 100644 --- a/packages/components/date-input/package.json +++ b/packages/components/date-input/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/date-input", - "version": "2.3.4", + "version": "2.3.5", "description": "A date input allows users to enter and edit date and time values using a keyboard.", "keywords": [ "date-field" diff --git a/packages/components/date-picker/CHANGELOG.md b/packages/components/date-picker/CHANGELOG.md index 0b7987ab0f..cf2ad78cf2 100644 --- a/packages/components/date-picker/CHANGELOG.md +++ b/packages/components/date-picker/CHANGELOG.md @@ -1,5 +1,16 @@ # @nextui-org/date-picker +## 2.3.5 + +### Patch Changes + +- Updated dependencies [[`dfefdd6`](https://github.com/nextui-org/nextui/commit/dfefdd6250eb81ae653e611a8dff12b2ae29a09c)]: + - @nextui-org/button@2.2.5 + - @nextui-org/calendar@2.2.5 + - @nextui-org/form@2.1.5 + - @nextui-org/popover@2.3.5 + - @nextui-org/date-input@2.3.5 + ## 2.3.4 ### Patch Changes diff --git a/packages/components/date-picker/package.json b/packages/components/date-picker/package.json index cfb8ce97e2..1b274d55e8 100644 --- a/packages/components/date-picker/package.json +++ b/packages/components/date-picker/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/date-picker", - "version": "2.3.4", + "version": "2.3.5", "description": "A date picker combines a DateInput and a Calendar popover to allow users to enter or select a date and time value.", "keywords": [ "date-picker" diff --git a/packages/components/dropdown/CHANGELOG.md b/packages/components/dropdown/CHANGELOG.md index eae239d45b..0f3c346e29 100644 --- a/packages/components/dropdown/CHANGELOG.md +++ b/packages/components/dropdown/CHANGELOG.md @@ -1,5 +1,15 @@ # @nextui-org/dropdown +## 2.3.5 + +### Patch Changes + +- [#4288](https://github.com/nextui-org/nextui/pull/4288) [`aa5ea19`](https://github.com/nextui-org/nextui/commit/aa5ea19a3c990f8f6d47abacf321f0cbce67b927) Thanks [@ryo-manba](https://github.com/ryo-manba)! - Fix initial animation direction to match fallback placement (#4251) + +- Updated dependencies [[`11eae5c`](https://github.com/nextui-org/nextui/commit/11eae5cc808e10db07b509f4e06d30441bb1937a)]: + - @nextui-org/menu@2.2.5 + - @nextui-org/popover@2.3.5 + ## 2.3.4 ### Patch Changes diff --git a/packages/components/dropdown/package.json b/packages/components/dropdown/package.json index de9882bb41..7062fc85f3 100644 --- a/packages/components/dropdown/package.json +++ b/packages/components/dropdown/package.json @@ -1,6 +1,6 @@ { "name": "@nextui-org/dropdown", - "version": "2.3.4", + "version": "2.3.5", "description": "A dropdown displays a list of actions or options that a user can choose.", "keywords": [ "dropdown" @@ -48,6 +48,7 @@ "@nextui-org/shared-utils": "workspace:*", "@react-aria/focus": "3.19.0", "@react-aria/menu": "3.16.0", + "@react-aria/overlays": "3.24.0", "@react-aria/utils": "3.26.0", "@react-stately/menu": "3.9.0", "@react-types/menu": "3.9.13" diff --git a/packages/components/dropdown/src/use-dropdown.ts b/packages/components/dropdown/src/use-dropdown.ts index 4deb06b42b..df74fed07b 100644 --- a/packages/components/dropdown/src/use-dropdown.ts +++ b/packages/components/dropdown/src/use-dropdown.ts @@ -9,11 +9,12 @@ import {useMenuTrigger} from "@react-aria/menu"; import {dropdown} from "@nextui-org/theme"; import {clsx} from "@nextui-org/shared-utils"; import {ReactRef, mergeRefs} from "@nextui-org/react-utils"; -import {ariaShouldCloseOnInteractOutside} from "@nextui-org/aria-utils"; +import {ariaShouldCloseOnInteractOutside, toReactAriaPlacement} from "@nextui-org/aria-utils"; import {useMemo, useRef} from "react"; import {mergeProps} from "@react-aria/utils"; import {MenuProps} from "@nextui-org/menu"; import {CollectionElement} from "@react-types/shared"; +import {useOverlayPosition} from "@react-aria/overlays"; interface Props extends HTMLNextUIProps<"div"> { /** @@ -77,6 +78,8 @@ const getCloseOnSelect = ( return props?.closeOnSelect; }; +const DEFAULT_PLACEMENT = "bottom"; + export function useDropdown(props: UseDropdownProps): UseDropdownReturn { const globalContext = useProviderContext(); @@ -89,13 +92,17 @@ export function useDropdown(props: UseDropdownProps): UseDropdownReturn { isDisabled, type = "menu", trigger = "press", - placement = "bottom", + placement: placementProp = DEFAULT_PLACEMENT, closeOnSelect = true, shouldBlockScroll = true, classNames: classNamesProp, disableAnimation = globalContext?.disableAnimation ?? false, onClose, className, + containerPadding = 12, + offset = 7, + crossOffset = 0, + shouldFlip = true, ...otherProps } = props; @@ -132,6 +139,17 @@ export function useDropdown(props: UseDropdownProps): UseDropdownReturn { [className], ); + const {placement} = useOverlayPosition({ + isOpen: state.isOpen, + targetRef: triggerRef, + overlayRef: popoverRef, + placement: toReactAriaPlacement(placementProp), + offset, + crossOffset, + shouldFlip, + containerPadding, + }); + const onMenuAction = (menuCloseOnSelect?: boolean) => { if (menuCloseOnSelect !== undefined && !menuCloseOnSelect) { return; @@ -146,7 +164,7 @@ export function useDropdown(props: UseDropdownProps): UseDropdownReturn { return { state, - placement, + placement: placement || DEFAULT_PLACEMENT, ref: popoverRef, disableAnimation, shouldBlockScroll, diff --git a/packages/components/dropdown/stories/dropdown.stories.tsx b/packages/components/dropdown/stories/dropdown.stories.tsx index 0c26be0ad1..6a4f7c6939 100644 --- a/packages/components/dropdown/stories/dropdown.stories.tsx +++ b/packages/components/dropdown/stories/dropdown.stories.tsx @@ -137,10 +137,15 @@ const items = [ }, ]; -const Template = ({color, variant, ...args}: DropdownProps & DropdownMenuProps) => ( +const Template = ({ + color, + variant, + label = "Trigger", + ...args +}: DropdownProps & DropdownMenuProps & {label: string}) => ( - + New file @@ -782,3 +787,29 @@ export const ItemCloseOnSelect = { ...defaultProps, }, }; + +export const WithFallbackPlacements = { + args: { + ...defaultProps, + }, + render: (args) => ( +
+
+