Skip to content

Commit

Permalink
Keep prop-types
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Jan 3, 2025
1 parent 2a1fc7d commit 2b70f5d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
13 changes: 12 additions & 1 deletion packages/react/src/popover/root/PopoverRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { PortalContext } from '../../portal/PortalContext';
* Documentation: [Base UI Popover](https://base-ui.com/react/components/popover)
*/
const PopoverRoot: React.FC<PopoverRoot.Props> = function PopoverRoot(props) {
const { onOpenChange, openOnHover = false, delay, closeDelay = 0 } = props;
const { defaultOpen, open, onOpenChange, openOnHover = false, delay, closeDelay = 0 } = props;

const delayWithDefault = delay ?? OPEN_DELAY;

Expand Down Expand Up @@ -66,6 +66,13 @@ PopoverRoot.propTypes /* remove-proptypes */ = {
* @default 0
*/
closeDelay: PropTypes.number,
/**
* Whether the popover is initially open.
*
* To render a controlled popover, use the `open` prop instead.
* @default false
*/
defaultOpen: PropTypes.bool,
/**
* How long to wait before the popover may be opened on hover. Specified in milliseconds.
*
Expand All @@ -77,6 +84,10 @@ PopoverRoot.propTypes /* remove-proptypes */ = {
* Event handler called when the popover is opened or closed.
*/
onOpenChange: PropTypes.func,
/**
* Whether the popover is currently open.
*/
open: PropTypes.bool,
/**
* Whether the popover should also open when the trigger is hovered.
* @default false
Expand Down
13 changes: 12 additions & 1 deletion packages/react/src/preview-card/root/PreviewCardRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { PortalContext } from '../../portal/PortalContext';
* Documentation: [Base UI Preview Card](https://base-ui.com/react/components/preview-card)
*/
const PreviewCardRoot: React.FC<PreviewCardRoot.Props> = function PreviewCardRoot(props) {
const { onOpenChange, delay, closeDelay } = props;
const { defaultOpen, open, onOpenChange, delay, closeDelay } = props;

const delayWithDefault = delay ?? OPEN_DELAY;
const closeDelayWithDefault = closeDelay ?? CLOSE_DELAY;
Expand Down Expand Up @@ -64,6 +64,13 @@ PreviewCardRoot.propTypes /* remove-proptypes */ = {
* @default 300
*/
closeDelay: PropTypes.number,
/**
* Whether the preview card is initially open.
*
* To render a controlled preview card, use the `open` prop instead.
* @default false
*/
defaultOpen: PropTypes.bool,
/**
* How long to wait before the preview card opens. Specified in milliseconds.
* @default 600
Expand All @@ -73,6 +80,10 @@ PreviewCardRoot.propTypes /* remove-proptypes */ = {
* Event handler called when the preview card is opened or closed.
*/
onOpenChange: PropTypes.func,
/**
* Whether the preview card is currently open.
*/
open: PropTypes.bool,
} as any;

export { PreviewCardRoot };
21 changes: 20 additions & 1 deletion packages/react/src/tooltip/root/TooltipRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ import { PortalContext } from '../../portal/PortalContext';
* Documentation: [Base UI Tooltip](https://base-ui.com/react/components/tooltip)
*/
const TooltipRoot: React.FC<TooltipRoot.Props> = function TooltipRoot(props) {
const { onOpenChange, delay, closeDelay, hoverable = true, trackCursorAxis = 'none' } = props;
const {
defaultOpen,
open,
onOpenChange,
delay,
closeDelay,
hoverable = true,
trackCursorAxis = 'none',
} = props;

const delayWithDefault = delay ?? OPEN_DELAY;
const closeDelayWithDefault = closeDelay ?? 0;
Expand Down Expand Up @@ -65,6 +73,13 @@ TooltipRoot.propTypes /* remove-proptypes */ = {
* @default 0
*/
closeDelay: PropTypes.number,
/**
* Whether the tooltip is initially open.
*
* To render a controlled tooltip, use the `open` prop instead.
* @default false
*/
defaultOpen: PropTypes.bool,
/**
* How long to wait before opening the tooltip. Specified in milliseconds.
* @default 600
Expand All @@ -79,6 +94,10 @@ TooltipRoot.propTypes /* remove-proptypes */ = {
* Event handler called when the tooltip is opened or closed.
*/
onOpenChange: PropTypes.func,
/**
* Whether the tooltip is currently open.
*/
open: PropTypes.bool,
/**
* Determines which axis the tooltip should track the cursor on.
* @default 'none'
Expand Down

0 comments on commit 2b70f5d

Please sign in to comment.