@wix/design-system
Version:
@wix/design-system
55 lines (50 loc) • 1.64 kB
TypeScript
import * as React from 'react';
import { FocusOptionsPolyfill, PopoverCommonProps } from '../common';
import {
DropdownLayoutValueOption,
DropdownLayoutProps,
} from '../DropdownLayout';
import { InputProps } from '../Input';
export interface InputWithOptionsProps<
ManualInputFn = ManualInputFnSignature,
OnSelectFn = OnSelectFnSignature,
> extends InputProps,
Omit<DropdownLayoutProps, 'onSelect' | 'size'> {
autocomplete?: string;
inputElement?: React.ReactElement;
closeOnSelect?: boolean;
onManuallyInput?: ManualInputFn;
valueParser?: (
option: DropdownLayoutValueOption,
) => DropdownLayoutValueOption['value'];
dropdownWidth?: string;
dropdownOffsetLeft?: string;
customDropdownContent?: React.ReactNode;
showOptionsIfEmptyInput?: boolean;
highlight?: boolean;
native?: boolean;
popoverProps?: PopoverCommonProps;
onSelect?: OnSelectFn;
onOptionsShow?: () => void;
onOptionsHide?: () => void;
}
export default class InputWithOptions<
ManualInputFn = ManualInputFnSignature,
OnSelectFn = OnSelectFnSignature,
T extends InputWithOptionsProps<
ManualInputFn,
OnSelectFn
> = InputWithOptionsProps<ManualInputFn, OnSelectFn>,
> extends React.Component<T> {
focus: (options?: FocusOptionsPolyfill) => FocusOptionsPolyfill;
blur: () => void;
select: () => void;
showOptions: () => void;
hideOptions: () => void;
clear: (event?: React.ChangeEvent<HTMLInputElement>) => void;
}
export type ManualInputFnSignature = (
inputValue: string,
suggestedOption: DropdownLayoutValueOption,
) => void;
export type OnSelectFnSignature = DropdownLayoutProps['onSelect'];