@grafana/ui
Version:
Grafana Components Library
81 lines (78 loc) • 2.1 kB
JavaScript
import { useMemo } from 'react';
;
function resetSelectStyles(theme) {
return {
clearIndicator: () => ({}),
container: () => ({}),
control: () => ({}),
dropdownIndicator: () => ({}),
group: () => ({}),
groupHeading: () => ({}),
indicatorsContainer: () => ({}),
indicatorSeparator: () => ({}),
input: function(originalStyles) {
return {
...originalStyles,
color: "inherit",
margin: 0,
padding: 0,
// Set an explicit z-index here to ensure this element always overlays the singleValue
zIndex: 1,
overflow: "hidden"
};
},
loadingIndicator: () => ({}),
loadingMessage: () => ({}),
menu: () => ({}),
menuList: ({ maxHeight }) => ({
maxHeight
}),
multiValue: () => ({}),
multiValueLabel: () => ({
overflow: "hidden",
textOverflow: "ellipsis"
}),
multiValueRemove: () => ({}),
noOptionsMessage: () => ({}),
option: () => ({}),
placeholder: (originalStyles) => ({
...originalStyles,
color: theme.colors.text.secondary
}),
singleValue: () => ({}),
valueContainer: () => ({})
};
}
function useCustomSelectStyles(theme, width) {
return useMemo(() => {
return {
...resetSelectStyles(theme),
menuPortal: (base) => {
return {
...base,
zIndex: theme.zIndex.portal
};
},
//These are required for the menu positioning to function
menu: ({ top, bottom, position }) => {
return {
top,
bottom,
position,
minWidth: "100%",
zIndex: theme.zIndex.dropdown
};
},
container: () => ({
width: width ? theme.spacing(width) : "100%",
display: width === "auto" ? "inline-flex" : "flex"
}),
option: (provided, state) => ({
...provided,
opacity: state.isDisabled ? 0.5 : 1
})
};
}, [theme, width]);
}
export { resetSelectStyles as default, useCustomSelectStyles };
//# sourceMappingURL=resetSelectStyles.mjs.map