mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
ESLint: Remove ts-ignore (#10961)
* Fix prop types of styled * Fix props in windowed
This commit is contained in:
parent
4a4fdb1e02
commit
91fd06e093
@ -16,7 +16,7 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import React, { SyntheticEvent, MutableRefObject } from 'react';
|
import React, { SyntheticEvent, MutableRefObject, ComponentType } from 'react';
|
||||||
import { merge } from 'lodash';
|
import { merge } from 'lodash';
|
||||||
import BasicSelect, {
|
import BasicSelect, {
|
||||||
OptionTypeBase,
|
OptionTypeBase,
|
||||||
@ -39,6 +39,7 @@ import {
|
|||||||
SortableContainerProps,
|
SortableContainerProps,
|
||||||
} from 'react-sortable-hoc';
|
} from 'react-sortable-hoc';
|
||||||
import arrayMove from 'array-move';
|
import arrayMove from 'array-move';
|
||||||
|
import { Props as SelectProps } from 'react-select/src/Select';
|
||||||
import {
|
import {
|
||||||
WindowedSelectComponentType,
|
WindowedSelectComponentType,
|
||||||
WindowedSelectProps,
|
WindowedSelectProps,
|
||||||
@ -93,9 +94,11 @@ export type SupersetStyledSelectProps<
|
|||||||
|
|
||||||
function styled<
|
function styled<
|
||||||
OptionType extends OptionTypeBase,
|
OptionType extends OptionTypeBase,
|
||||||
SelectComponentType extends WindowedSelectComponentType<
|
SelectComponentType extends
|
||||||
|
| WindowedSelectComponentType<OptionType>
|
||||||
|
| ComponentType<SelectProps<OptionType>> = WindowedSelectComponentType<
|
||||||
OptionType
|
OptionType
|
||||||
> = WindowedSelectComponentType<OptionType>
|
>
|
||||||
>(SelectComponent: SelectComponentType) {
|
>(SelectComponent: SelectComponentType) {
|
||||||
type SelectProps = SupersetStyledSelectProps<OptionType>;
|
type SelectProps = SupersetStyledSelectProps<OptionType>;
|
||||||
type Components = SelectComponents<OptionType>;
|
type Components = SelectComponents<OptionType>;
|
||||||
@ -287,7 +290,5 @@ export const Select = styled(WindowedSelect);
|
|||||||
export const AsyncSelect = styled(WindowedAsyncSelect);
|
export const AsyncSelect = styled(WindowedAsyncSelect);
|
||||||
export const CreatableSelect = styled(WindowedCreatableSelect);
|
export const CreatableSelect = styled(WindowedCreatableSelect);
|
||||||
export const AsyncCreatableSelect = styled(WindowedAsyncCreatableSelect);
|
export const AsyncCreatableSelect = styled(WindowedAsyncCreatableSelect);
|
||||||
// Wrap with async pagination (infinite scroll). Cannot use windowed since options are appended dynamically which causes focus jumping
|
|
||||||
// @ts-ignore
|
|
||||||
export const PaginatedSelect = withAsyncPaginate(styled(BasicSelect));
|
export const PaginatedSelect = withAsyncPaginate(styled(BasicSelect));
|
||||||
export default Select;
|
export default Select;
|
||||||
|
@ -22,6 +22,7 @@ import React, {
|
|||||||
Component,
|
Component,
|
||||||
FunctionComponent,
|
FunctionComponent,
|
||||||
RefObject,
|
RefObject,
|
||||||
|
ReactElement,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import {
|
import {
|
||||||
ListChildComponentProps,
|
ListChildComponentProps,
|
||||||
@ -53,10 +54,15 @@ export type WindowedMenuListProps = {
|
|||||||
* If may also be `Component<GroupProps<OptionType>>[]` but we are not supporting
|
* If may also be `Component<GroupProps<OptionType>>[]` but we are not supporting
|
||||||
* grouped options just yet.
|
* grouped options just yet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
type MenuListPropsChildren<OptionType> =
|
||||||
|
| Component<OptionProps<OptionType>>[]
|
||||||
|
| ReactElement[];
|
||||||
|
|
||||||
export type MenuListProps<
|
export type MenuListProps<
|
||||||
OptionType extends OptionTypeBase
|
OptionType extends OptionTypeBase
|
||||||
> = MenuListComponentProps<OptionType> & {
|
> = MenuListComponentProps<OptionType> & {
|
||||||
children: Component<OptionProps<OptionType>>[];
|
children: MenuListPropsChildren<OptionType>;
|
||||||
// theme is not present with built-in @types/react-select, but is actually
|
// theme is not present with built-in @types/react-select, but is actually
|
||||||
// available via CommonProps.
|
// available via CommonProps.
|
||||||
theme?: ThemeConfig;
|
theme?: ThemeConfig;
|
||||||
@ -68,7 +74,7 @@ const DEFAULT_OPTION_HEIGHT = 30;
|
|||||||
/**
|
/**
|
||||||
* Get the index of the last selected option.
|
* Get the index of the last selected option.
|
||||||
*/
|
*/
|
||||||
function getLastSelected(children: Component<any>[]) {
|
function getLastSelected(children: MenuListPropsChildren<any>) {
|
||||||
return Array.isArray(children)
|
return Array.isArray(children)
|
||||||
? children.findIndex(
|
? children.findIndex(
|
||||||
({ props: { isFocused = false } = {} }) => isFocused,
|
({ props: { isFocused = false } = {} }) => isFocused,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import React, { ComponentType, FunctionComponent } from 'react';
|
import React, { ComponentType, FunctionComponent, ReactElement } from 'react';
|
||||||
import Select, {
|
import Select, {
|
||||||
Props as SelectProps,
|
Props as SelectProps,
|
||||||
OptionTypeBase,
|
OptionTypeBase,
|
||||||
@ -47,8 +47,11 @@ export function MenuList<OptionType extends OptionTypeBase>({
|
|||||||
}) {
|
}) {
|
||||||
const { windowThreshold = DEFAULT_WINDOW_THRESHOLD } = props.selectProps;
|
const { windowThreshold = DEFAULT_WINDOW_THRESHOLD } = props.selectProps;
|
||||||
if (Array.isArray(children) && children.length > windowThreshold) {
|
if (Array.isArray(children) && children.length > windowThreshold) {
|
||||||
// @ts-ignore
|
return (
|
||||||
return <WindowedMenuList {...props}>{children}</WindowedMenuList>;
|
<WindowedMenuList {...props}>
|
||||||
|
{children as ReactElement[]}
|
||||||
|
</WindowedMenuList>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return <DefaultMenuList {...props}>{children}</DefaultMenuList>;
|
return <DefaultMenuList {...props}>{children}</DefaultMenuList>;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user