(null);
useResizeObserver({
ref: controlsContainer,
onResize: () => {
const element = controlsContainer.current;
if (element) {
setAvailableWidth(element.clientWidth);
}
},
});
useEffect(() => {
const { fontSize } = theme.typography;
const text = options.map((option) => option.label || option.value || '').join(' ');
const textWidth = measureText(text, fontSize).width;
const additionalWidthPerItem = 32;
setLabelSelectorRequiredWidth(textWidth + additionalWidthPerItem * options.length);
}, [options, theme]);
return (
{useHorizontalLabelSelector ? (
) : (
);
}
function getStyles(theme: GrafanaTheme2) {
return {
select: css({
maxWidth: theme.spacing(16),
}),
};
}