fix @grafana/ui type errors
This commit is contained in:
@@ -763,11 +763,6 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/grafana-ui/src/components/Select/resetSelectStyles.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/grafana-ui/src/components/Select/types.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 6
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { autoUpdate, autoPlacement, size, useFloating } from '@floating-ui/react';
|
||||
import { useMemo, useRef, useState } from 'react';
|
||||
import { CSSProperties, type RefObject, useMemo, useRef, useState } from 'react';
|
||||
|
||||
import { BOUNDARY_ELEMENT_ID } from '../../utils/floating';
|
||||
import { measureText } from '../../utils/measureText';
|
||||
@@ -21,7 +21,21 @@ const POPOVER_PADDING = 16;
|
||||
|
||||
const SCROLL_CONTAINER_PADDING = 8;
|
||||
|
||||
export const useComboboxFloat = (items: Array<ComboboxOption<string | number>>, isOpen: boolean) => {
|
||||
interface UseComboboxFloatReturn {
|
||||
inputRef: RefObject<HTMLInputElement | null>;
|
||||
floatingRef: RefObject<HTMLDivElement | null>;
|
||||
scrollRef: RefObject<HTMLDivElement | null>;
|
||||
floatStyles: CSSProperties & {
|
||||
width: number;
|
||||
maxWidth: number;
|
||||
maxHeight: number;
|
||||
};
|
||||
}
|
||||
|
||||
export const useComboboxFloat = (
|
||||
items: Array<ComboboxOption<string | number>>,
|
||||
isOpen: boolean
|
||||
): UseComboboxFloatReturn => {
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const floatingRef = useRef<HTMLDivElement>(null);
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useMemo } from 'react';
|
||||
import { CSSObjectWithLabel } from 'react-select';
|
||||
import { StylesConfig } from 'react-select';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
|
||||
export default function resetSelectStyles(theme: GrafanaTheme2) {
|
||||
export default function resetSelectStyles(theme: GrafanaTheme2): Partial<StylesConfig> {
|
||||
return {
|
||||
clearIndicator: () => ({}),
|
||||
container: () => ({}),
|
||||
@@ -13,7 +13,7 @@ export default function resetSelectStyles(theme: GrafanaTheme2) {
|
||||
groupHeading: () => ({}),
|
||||
indicatorsContainer: () => ({}),
|
||||
indicatorSeparator: () => ({}),
|
||||
input: function (originalStyles: CSSObjectWithLabel) {
|
||||
input: function (originalStyles) {
|
||||
return {
|
||||
...originalStyles,
|
||||
color: 'inherit',
|
||||
@@ -27,7 +27,7 @@ export default function resetSelectStyles(theme: GrafanaTheme2) {
|
||||
loadingIndicator: () => ({}),
|
||||
loadingMessage: () => ({}),
|
||||
menu: () => ({}),
|
||||
menuList: ({ maxHeight }: { maxHeight: number }) => ({
|
||||
menuList: ({ maxHeight }) => ({
|
||||
maxHeight,
|
||||
}),
|
||||
multiValue: () => ({}),
|
||||
@@ -38,7 +38,7 @@ export default function resetSelectStyles(theme: GrafanaTheme2) {
|
||||
multiValueRemove: () => ({}),
|
||||
noOptionsMessage: () => ({}),
|
||||
option: () => ({}),
|
||||
placeholder: (originalStyles: CSSObjectWithLabel) => ({
|
||||
placeholder: (originalStyles) => ({
|
||||
...originalStyles,
|
||||
color: theme.colors.text.secondary,
|
||||
}),
|
||||
@@ -47,11 +47,11 @@ export default function resetSelectStyles(theme: GrafanaTheme2) {
|
||||
};
|
||||
}
|
||||
|
||||
export function useCustomSelectStyles(theme: GrafanaTheme2, width: number | string | undefined) {
|
||||
export function useCustomSelectStyles(theme: GrafanaTheme2, width: number | string | undefined): Partial<StylesConfig> {
|
||||
return useMemo(() => {
|
||||
return {
|
||||
...resetSelectStyles(theme),
|
||||
menuPortal: (base: CSSObjectWithLabel) => {
|
||||
menuPortal: (base) => {
|
||||
// Would like to correct top position when menu is placed bottom, but have props are not sent to this style function.
|
||||
// Only state is. https://github.com/JedWatson/react-select/blob/master/packages/react-select/src/components/Menu.tsx#L605
|
||||
return {
|
||||
@@ -60,7 +60,7 @@ export function useCustomSelectStyles(theme: GrafanaTheme2, width: number | stri
|
||||
};
|
||||
},
|
||||
//These are required for the menu positioning to function
|
||||
menu: ({ top, bottom, position }: CSSObjectWithLabel) => {
|
||||
menu: ({ top, bottom, position }) => {
|
||||
return {
|
||||
top,
|
||||
bottom,
|
||||
@@ -73,7 +73,7 @@ export function useCustomSelectStyles(theme: GrafanaTheme2, width: number | stri
|
||||
width: width ? theme.spacing(width) : '100%',
|
||||
display: width === 'auto' ? 'inline-flex' : 'flex',
|
||||
}),
|
||||
option: (provided: CSSObjectWithLabel, state: any) => ({
|
||||
option: (provided, state) => ({
|
||||
...provided,
|
||||
opacity: state.isDisabled ? 0.5 : 1,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user