Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function SegmentSelect({
value,
options = [],
onChange,
onClickOutside,
width,
noOptionsMessage = '',
allowCustomValue = false,
}: React.PropsWithChildren>) {
const ref = useRef(null);
useClickAway(ref, () => {
onClickOutside();
});
return (
<div>
<select> 120 ? width : 120}px;
`
)}
noOptionsMessage={() => noOptionsMessage}
placeholder=""
autoFocus={true}
isOpen={true}
onChange={onChange}</select></div>
openOffCanvas();
} else {
onReverseComplete();
}
}, [renderOffCanvas]);
const classes = cx(
'offCanvas',
{
'offCanvas--right': align === 'right',
},
className
);
useClickAway(offCanvasPanelRef, () => onOffCanvasToggle());
useLockBodyScroll(renderOffCanvas);
return (
renderOffCanvas &&
ReactDOM.createPortal(
<div>
<div>
{children}
</div>
</div>,
document.body
)
);
};
const rect = menuElement.getBoundingClientRect();
const OFFSET = 5;
const collisions = {
right: window.innerWidth < x + rect.width,
bottom: window.innerHeight < rect.bottom + rect.height + OFFSET,
};
setPositionStyles({
position: 'fixed',
left: collisions.right ? x - rect.width - OFFSET : x - OFFSET,
top: collisions.bottom ? y - rect.height - OFFSET : y + OFFSET,
});
}
}, [menuRef.current]);
useClickAway(menuRef, () => {
if (onClose) {
onClose();
}
});
const styles = getContextMenuStyles(theme);
return (
<div style="{positionStyles}">
{renderHeader && <div>{renderHeader()}</div>}
{
return (
<>
</div>
export const DataLinkSuggestions: React.FC = ({ suggestions, ...otherProps }) => {
const ref = useRef(null);
const theme = useContext(ThemeContext);
useClickAway(ref, () => {
if (otherProps.onClose) {
otherProps.onClose();
}
});
const groupedSuggestions = useMemo(() => {
return _.groupBy(suggestions, s => s.origin);
}, [suggestions]);
const styles = getStyles(theme);
return (
<div>
{Object.keys(groupedSuggestions).map((key, i) => {
const indexOffset =
i === 0
? 0</div>
openModal();
} else {
onReverseComplete();
}
}, [renderModal]);
const modalClasses = cx(
'modal',
{
'modal--small': size === 'small',
'modal--large': size === 'large',
},
className
);
useClickAway(modalDialogRef, () => onOutsideModalClick());
useLockBodyScroll(renderModal);
return (
renderModal &&
ReactDOM.createPortal(
<div>
<div>
{children}
</div>
</div>,
document.body
)
);
};
const wrapperRef = useRef(null);
const [open, setOpen] = useState(false);
const optionKeys = useMemo(() => Object.keys(options), [options]);
const labelHeight = useMemo(() => {
switch (props.size) {
case 'small':
return 20;
case 'large':
return 27;
default:
return 22;
}
}, [props.size]);
useClickAway(wrapperRef, () => {
setOpen(false);
});
function handleClick() {
setOpen(prevOpen => !prevOpen);
}
return (
<button>
{optionKeys.map(key => (
<spacer>{options[key]}</spacer>
))}
<label>{options[value]}</label>
</button>
export function SegmentInput({
value: initialValue,
onChange,
Component,
className,
placeholder,
autofocus = false,
}: React.PropsWithChildren>) {
const ref = useRef(null);
const [value, setValue] = useState(initialValue);
const [inputWidth, setInputWidth] = useState(measureText((initialValue || '').toString(), FONT_SIZE).width);
const [Label, , expanded, setExpanded] = useExpandableLabel(autofocus);
useClickAway(ref, () => {
setExpanded(false);
onChange(value);
});
if (!expanded) {
return (
<label placeholder="">
{initialValue || placeholder}
)
}
/>
);</label>