UNPKG

material-ui-popup-state

Version:

easiest way to create menus, popovers, and poppers with material-ui

2 lines (1 loc) 3.27 kB
{"version":3,"file":"HoverPopover.mjs","names":["React","Popover","_Popover","interopRequireDefault","HoverPopover","forwardRef","props","ref","_props$slotProps2","_props$PaperProps","paperSlotProps","useMemo","_props$slotProps","wrapped","slotProps","paper","Function","ownerProps","base","style","pointerEvents","createElement","_extends","PaperProps"],"sources":["src/HoverPopover.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated */\nimport * as React from 'react'\nimport { Popover as _Popover, type PopoverProps } from '@mui/material'\nimport { interopRequireDefault } from './util/interopRequireDefault'\n// work around https://github.com/vercel/next.js/issues/57285\nconst Popover = interopRequireDefault(_Popover)\n\nconst HoverPopover: React.ComponentType<PopoverProps> = React.forwardRef(\n function HoverPopover(props: PopoverProps, ref): any {\n const paperSlotProps = React.useMemo(() => {\n const wrapped = props.slotProps?.paper\n if (wrapped instanceof Function) {\n return (ownerProps: Parameters<typeof wrapped>[0]) => {\n const base = wrapped(ownerProps)\n return {\n ...base,\n style: {\n pointerEvents: 'auto',\n ...base.style,\n },\n } as const\n }\n }\n return {\n ...wrapped,\n style: { pointerEvents: 'auto', ...wrapped?.style },\n } as const\n }, [props.slotProps?.paper])\n\n return (\n <Popover\n {...props}\n ref={ref}\n style={{ pointerEvents: 'none', ...props.style }}\n PaperProps={{\n ...props.PaperProps,\n style: {\n pointerEvents: 'auto',\n ...props.PaperProps?.style,\n },\n }}\n slotProps={{\n ...props.slotProps,\n paper: paperSlotProps,\n }}\n />\n )\n }\n)\n\nexport default HoverPopover\n"],"mappings":";AAAA;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,OAAO,IAAIC,QAAQ,QAA2B,eAAe;AACtE,SAASC,qBAAqB;AAC9B;AACA,MAAMF,OAAO,GAAGE,qBAAqB,CAACD,QAAQ,CAAC;AAE/C,MAAME,YAA+C,gBAAGJ,KAAK,CAACK,UAAU,CACtE,SAASD,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