Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Типы в defaultProps #2760

Closed
wants to merge 13 commits into from
4 changes: 2 additions & 2 deletions packages/react-ui/components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import { ThemeContext } from '../../lib/theming/ThemeContext';
import { Theme } from '../../lib/theming/Theme';
import { isKeyArrowDown, isKeyArrowUp, isKeyEnter, isKeyEscape } from '../../lib/events/keyboard/identifiers';
import { Input, InputProps } from '../Input';
import { Input, InputProps, InputSize } from '../Input';
import { DropdownContainer } from '../../internal/DropdownContainer';
import { Menu } from '../../internal/Menu';
import { MenuItem } from '../MenuItem';
Expand Down Expand Up @@ -101,7 +101,7 @@ export class Autocomplete extends React.Component<AutocompleteProps, Autocomplet

public static defaultProps = {
renderItem,
size: 'small',
size: 'small' as InputSize,
disablePortal: false,
hasShadow: true,
menuMaxHeight: 300,
JackUait marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Center/Center.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Center extends React.Component<CenterProps> {
public static __KONTUR_REACT_UI__ = 'Center';

public static defaultProps = {
align: 'center',
align: 'center' as HorizontalAlign,
};
private setRootNode!: TSetRootNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export class CurrencyInput extends React.PureComponent<CurrencyInputProps, Curre
fractionDigits: 2,
hideTrailingZeros: false,
value: null,
inputMode: 'decimal',
};

public state: CurrencyInputState = {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const INPUT_PASS_PROPS = {

export const MIN_WIDTH = 120;

export interface DatePickerProps<T> extends CommonProps {
export interface DatePickerProps<T = string> extends CommonProps {
autoFocus?: boolean;
disabled?: boolean;
enableTodayLink?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/DropdownMenu/DropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class DropdownMenu extends React.Component<DropdownMenuProps> {

public static defaultProps = {
disableAnimations: isTestEnv,
positions: ['bottom left', 'bottom right', 'top left', 'top right'],
positions: ['bottom left', 'bottom right', 'top left', 'top right'] as PopupPositionsType[],
};

private popupMenu: Nullable<PopupMenu> = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/FxInput/FxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class FxInput extends React.Component<FxInputProps> {

public static defaultProps = {
width: 250,
type: 'text',
type: 'text' as 'currency' | InputProps['type'],
value: '',
};

Expand Down
6 changes: 2 additions & 4 deletions packages/react-ui/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ export interface InputState {
export class Input extends React.Component<InputProps, InputState> {
public static __KONTUR_REACT_UI__ = 'Input';

public static defaultProps: {
size: InputSize;
} = {
size: 'small',
public static defaultProps = {
size: 'small' as InputSize,
};

public state: InputState = {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Kebab/Kebab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class Kebab extends React.Component<KebabProps, KebabState> {
public static defaultProps = {
onOpen: () => undefined,
onClose: () => undefined,
positions: ['bottom left', 'bottom right', 'top left', 'top right'],
positions: ['bottom left', 'bottom right', 'top left', 'top right'] as PopupPositionsType[],
size: 'small',
disableAnimations: isTestEnv,
icon: <MenuKebabIcon />,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/PasswordInput/PasswordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';

import { isKeyCapsLock } from '../../lib/events/keyboard/identifiers';
import { KeyboardEventCodes as Codes } from '../../lib/events/keyboard/KeyboardEventCodes';
import { Input, InputProps } from '../Input';
import { Input, InputProps, InputSize } from '../Input';
import { Nullable } from '../../typings/utility-types';
import { EyeClosedIcon, EyeOpenedIcon } from '../../internal/icons/16px';
import { isIE11 } from '../../lib/client';
Expand Down Expand Up @@ -39,7 +39,7 @@ export class PasswordInput extends React.PureComponent<PasswordInputProps, Passw
};

public static defaultProps = {
size: 'small',
size: 'small' as InputSize,
};

public state: PasswordInputState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ScrollContainer extends React.Component<ScrollContainerProps> {

public static defaultProps = {
invert: false,
scrollBehaviour: 'auto',
scrollBehaviour: 'auto' as ScrollBehaviour,
preventWindowScroll: false,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class Select<TValue = {}, TItem = {}> extends React.Component<SelectProps
renderItem,
areValuesEqual,
filterItem,
use: 'default',
use: 'default' as ButtonUse,
};

public static Item = Item;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Spinner extends React.Component<SpinnerProps> {
};

public static defaultProps: SpinnerProps = {
type: 'normal',
type: 'normal' as SpinnerType,
};

public static Types: typeof types = types;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/TokenInput/TokenInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ export class TokenInput<T = string> extends React.PureComponent<TokenInputProps<
onFocus: emptyHandler,
onMouseEnter: emptyHandler,
onMouseLeave: emptyHandler,
menuWidth: 'auto',
menuAlign: 'cursor',
menuWidth: 'auto' as React.CSSProperties['width'],
menuAlign: 'cursor' as TokenInputMenuAlign,
};

public state: TokenInputState<T> = DefaultState;
Expand Down
5 changes: 2 additions & 3 deletions packages/react-ui/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ export class Tooltip extends React.PureComponent<TooltipProps, TooltipState> {
};

public static defaultProps = {
pos: DefaultPosition,
trigger: 'hover',
pos: DefaultPosition as PopupPositionsType,
trigger: 'hover' as TooltipTrigger,
allowedPositions: Positions,
disableAnimations: isTestEnv,
useWrapper: false,
closeOnChildrenMouseLeave: false,
};

public static delay = 100;
Expand Down
5 changes: 2 additions & 3 deletions packages/react-ui/internal/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,16 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> {
public static __KONTUR_REACT_UI__ = 'Calendar';

public static defaultProps = {
holidays: [],
minDate: {
year: MIN_YEAR,
month: MIN_MONTH,
date: MIN_DATE,
},
} as CalendarDateShape,
maxDate: {
year: MAX_YEAR,
month: MAX_MONTH,
date: MAX_DATE,
},
} as CalendarDateShape,
};

private theme!: Theme;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/internal/InputLikeText/InputLikeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MouseDrag, MouseDragEventHandler } from '../../lib/events/MouseDrag';
import { isEdge, isIE11, isMobile } from '../../lib/client';
import { Nullable } from '../../typings/utility-types';
import { removeAllSelections, selectNodeContents } from '../../components/DateInput/helpers/SelectionHelpers';
import { InputProps, InputIconType, InputState } from '../../components/Input';
import { InputProps, InputIconType, InputState, InputSize } from '../../components/Input';
import { styles as jsInputStyles } from '../../components/Input/Input.styles';
import { ThemeContext } from '../../lib/theming/ThemeContext';
import { Theme } from '../../lib/theming/Theme';
Expand Down Expand Up @@ -34,7 +34,7 @@ export type InputLikeTextState = Omit<InputState, 'polyfillPlaceholder'>;
export class InputLikeText extends React.Component<InputLikeTextProps, InputLikeTextState> {
public static __KONTUR_REACT_UI__ = 'InputLikeText';

public static defaultProps = { size: 'small' };
public static defaultProps = { size: 'small' as InputSize };

public state = { blinking: false, focused: false };

Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/internal/Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class Popup extends React.Component<PopupProps, PopupState> {
disableAnimations: isTestEnv,
useWrapper: false,
ignoreHover: false,
width: 'auto',
width: 'auto' as React.CSSProperties['width'],
};

public state: PopupState = { location: this.props.opened ? DUMMY_LOCATION : null };
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/internal/ZIndex/ZIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ZIndex extends React.Component<ZIndexProps> {
public static defaultProps = {
delta: 10,
priority: 0,
style: {},
style: {} as React.CSSProperties,
applyZIndex: true,
coverChildren: false,
createStackingContext: false,
Expand Down