UNPKG

@cerberus-design/react

Version:

The Cerberus Design React component library.

81 lines (79 loc) 1.67 kB
import { createNavTriggerProps } from "./chunk-C3FEINCR.js"; import { useNavMenuContext } from "./chunk-FXWN3SPS.js"; import { Show } from "./chunk-NUXMADXV.js"; // src/components/deprecated/NavMenuTrigger.tsx import { useCallback } from "react"; import { cx } from "styled-system/css"; import { button } from "styled-system/recipes"; import { jsx } from "react/jsx-runtime"; function NavMenuTrigger(props) { const { as, palette, usage, shape, controls, expanded: propsExpanded, onClick, ...nativeProps } = props; const { triggerRef, onToggle, expanded } = useNavMenuContext(); const ariaProps = createNavTriggerProps({ controls, expanded: propsExpanded ?? expanded }); const hasAs = Boolean(as); const AsSub = as; const handleClick = useCallback( (e) => { if (onClick) return onClick(e); onToggle(); }, [onClick, onToggle] ); return /* @__PURE__ */ jsx( Show, { when: hasAs, fallback: /* @__PURE__ */ jsx( "button", { ...nativeProps, ...ariaProps, className: cx( nativeProps.className, button({ palette, usage, shape }) ), onClick: handleClick, ref: triggerRef, children: props.children } ), children: hasAs && /* @__PURE__ */ jsx( AsSub, { ...nativeProps, ...ariaProps, onClick: handleClick, ref: triggerRef } ) } ); } export { NavMenuTrigger }; //# sourceMappingURL=chunk-75VWN4C7.js.map