Skip to content

Commit

Permalink
fix(lint): add tsconfig (ant-design#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
kerm1it authored Dec 25, 2020
1 parent 77bf546 commit 26726d2
Show file tree
Hide file tree
Showing 104 changed files with 276 additions and 273 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ package-lock.json
coverage/
.doc
.history
tsconfig.json
6 changes: 3 additions & 3 deletions src/PanelContext.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import { OnSelect } from './interface';
import type { OnSelect } from './interface';

export type ContextOperationRefProps = {
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => boolean;
onClose?: () => void;
};

export interface PanelContextProps {
export type PanelContextProps = {
operationRef?: React.MutableRefObject<ContextOperationRefProps | null>;
/** Only work with time panel */
hideHeader?: boolean;
Expand All @@ -21,7 +21,7 @@ export interface PanelContextProps {

/** Only used for TimePicker and this is a deprecated prop */
defaultOpenValue?: any;
}
};

const PanelContext = React.createContext<PanelContextProps>({});

Expand Down
38 changes: 17 additions & 21 deletions src/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,33 @@

import * as React from 'react';
import classNames from 'classnames';
import { AlignType } from 'rc-trigger/lib/interface';
import type { AlignType } from 'rc-trigger/lib/interface';
import warning from 'rc-util/lib/warning';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import PickerPanel, {
import type {
PickerPanelBaseProps,
PickerPanelDateProps,
PickerPanelTimeProps,
} from './PickerPanel';
import PickerPanel from './PickerPanel';
import PickerTrigger from './PickerTrigger';
import { formatValue, isEqual, parseValue } from './utils/dateUtil';
import getDataOrAriaProps, { toArray } from './utils/miscUtil';
import PanelContext, { ContextOperationRefProps } from './PanelContext';
import { CustomFormat, PickerMode } from './interface';
import type { ContextOperationRefProps } from './PanelContext';
import PanelContext from './PanelContext';
import type { CustomFormat, PickerMode } from './interface';
import { getDefaultFormat, getInputSize, elementsContains } from './utils/uiUtil';
import usePickerInput from './hooks/usePickerInput';
import useTextValueMapping from './hooks/useTextValueMapping';
import useValueTexts from './hooks/useValueTexts';
import useHoverValue from './hooks/useHoverValue';

export interface PickerRefConfig {
export type PickerRefConfig = {
focus: () => void;
blur: () => void;
}
};

export interface PickerSharedProps<DateType> extends React.AriaAttributes {
export type PickerSharedProps<DateType> = {
dropdownClassName?: string;
dropdownAlign?: AlignType;
popupStyle?: React.CSSProperties;
Expand All @@ -54,7 +56,7 @@ export interface PickerSharedProps<DateType> extends React.AriaAttributes {
id?: string;

// Value
format?: string | CustomFormat<DateType> | Array<string | CustomFormat<DateType>>;
format?: string | CustomFormat<DateType> | (string | CustomFormat<DateType>)[];

// Render
suffixIcon?: React.ReactNode;
Expand Down Expand Up @@ -89,31 +91,25 @@ export interface PickerSharedProps<DateType> extends React.AriaAttributes {

autoComplete?: string;
direction?: 'ltr' | 'rtl';
}
} & React.AriaAttributes;

type OmitPanelProps<Props> = Omit<
Props,
'onChange' | 'hideHeader' | 'pickerValue' | 'onPickerValueChange'
>;

export interface PickerBaseProps<DateType>
extends PickerSharedProps<DateType>,
OmitPanelProps<PickerPanelBaseProps<DateType>> {}
export type PickerBaseProps<DateType> = {} & PickerSharedProps<DateType> & OmitPanelProps<PickerPanelBaseProps<DateType>>;

export interface PickerDateProps<DateType>
extends PickerSharedProps<DateType>,
OmitPanelProps<PickerPanelDateProps<DateType>> {}
export type PickerDateProps<DateType> = {} & PickerSharedProps<DateType> & OmitPanelProps<PickerPanelDateProps<DateType>>;

export interface PickerTimeProps<DateType>
extends PickerSharedProps<DateType>,
Omit<OmitPanelProps<PickerPanelTimeProps<DateType>>, 'format'> {
export type PickerTimeProps<DateType> = {
picker: 'time';
/**
* @deprecated Please use `defaultValue` directly instead
* since `defaultOpenValue` will confuse user of current value status
*/
defaultOpenValue?: DateType;
}
} & PickerSharedProps<DateType> & Omit<OmitPanelProps<PickerPanelTimeProps<DateType>>, 'format'>;

export type PickerProps<DateType> =
| PickerBaseProps<DateType>
Expand All @@ -124,9 +120,9 @@ export type PickerProps<DateType> =
type OmitType<DateType> = Omit<PickerBaseProps<DateType>, 'picker'> &
Omit<PickerDateProps<DateType>, 'picker'> &
Omit<PickerTimeProps<DateType>, 'picker'>;
interface MergedPickerProps<DateType> extends OmitType<DateType> {
type MergedPickerProps<DateType> = {
picker?: PickerMode;
}
} & OmitType<DateType>;

function InnerPicker<DateType>(props: PickerProps<DateType>) {
const {
Expand Down
35 changes: 16 additions & 19 deletions src/PickerPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */

/**
* Logic:
* When `mode` === `picker`,
Expand All @@ -12,16 +10,17 @@ import classNames from 'classnames';
import KeyCode from 'rc-util/lib/KeyCode';
import warning from 'rc-util/lib/warning';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import TimePanel, { SharedTimeProps } from './panels/TimePanel';
import type { SharedTimeProps } from './panels/TimePanel';
import TimePanel from './panels/TimePanel';
import DatetimePanel from './panels/DatetimePanel';
import DatePanel from './panels/DatePanel';
import WeekPanel from './panels/WeekPanel';
import MonthPanel from './panels/MonthPanel';
import QuarterPanel from './panels/QuarterPanel';
import YearPanel from './panels/YearPanel';
import DecadePanel from './panels/DecadePanel';
import { GenerateConfig } from './generate';
import {
import type { GenerateConfig } from './generate';
import type {
Locale,
PanelMode,
PanelRefProps,
Expand All @@ -32,15 +31,15 @@ import {
} from './interface';
import { isEqual } from './utils/dateUtil';
import PanelContext from './PanelContext';
import { DateRender } from './panels/DatePanel/DateBody';
import type { DateRender } from './panels/DatePanel/DateBody';
import { PickerModeMap } from './utils/uiUtil';
import { MonthCellRender } from './panels/MonthPanel/MonthBody';
import type { MonthCellRender } from './panels/MonthPanel/MonthBody';
import RangeContext from './RangeContext';
import getExtraFooter from './utils/getExtraFooter';
import getRanges from './utils/getRanges';
import { getLowerBoundTime, setTime } from './utils/timeUtil';

export interface PickerPanelSharedProps<DateType> {
export type PickerPanelSharedProps<DateType> = {
prefixCls?: string;
className?: string;
style?: React.CSSProperties;
Expand Down Expand Up @@ -84,27 +83,25 @@ export interface PickerPanelSharedProps<DateType> {

/** @private Internal usage. Do not use in your production env */
components?: Components;
}
};

export interface PickerPanelBaseProps<DateType> extends PickerPanelSharedProps<DateType> {
export type PickerPanelBaseProps<DateType> = {
picker: Exclude<PickerMode, 'date' | 'time'>;
}
} & PickerPanelSharedProps<DateType>;

export interface PickerPanelDateProps<DateType> extends PickerPanelSharedProps<DateType> {
export type PickerPanelDateProps<DateType> = {
picker?: 'date';
showToday?: boolean;
showNow?: boolean;

// Time
showTime?: boolean | SharedTimeProps<DateType>;
disabledTime?: DisabledTime<DateType>;
}
} & PickerPanelSharedProps<DateType>;

export interface PickerPanelTimeProps<DateType>
extends PickerPanelSharedProps<DateType>,
SharedTimeProps<DateType> {
export type PickerPanelTimeProps<DateType> = {
picker: 'time';
}
} & PickerPanelSharedProps<DateType> & SharedTimeProps<DateType>;

export type PickerPanelProps<DateType> =
| PickerPanelBaseProps<DateType>
Expand All @@ -115,9 +112,9 @@ export type PickerPanelProps<DateType> =
type OmitType<DateType> = Omit<PickerPanelBaseProps<DateType>, 'picker'> &
Omit<PickerPanelDateProps<DateType>, 'picker'> &
Omit<PickerPanelTimeProps<DateType>, 'picker'>;
interface MergedPickerPanelProps<DateType> extends OmitType<DateType> {
type MergedPickerPanelProps<DateType> = {
picker?: PickerMode;
}
} & OmitType<DateType>;

function PickerPanel<DateType>(props: PickerPanelProps<DateType>) {
const {
Expand Down
6 changes: 3 additions & 3 deletions src/PickerTrigger.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import classNames from 'classnames';
import Trigger from 'rc-trigger';
import { AlignType } from 'rc-trigger/lib/interface';
import type { AlignType } from 'rc-trigger/lib/interface';

const BUILT_IN_PLACEMENTS = {
bottomLeft: {
Expand Down Expand Up @@ -40,7 +40,7 @@ const BUILT_IN_PLACEMENTS = {

type Placement = 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';

export interface PickerTriggerProps {
export type PickerTriggerProps = {
prefixCls: string;
visible: boolean;
popupElement: React.ReactElement;
Expand All @@ -53,7 +53,7 @@ export interface PickerTriggerProps {
range?: boolean;
popupPlacement?: Placement;
direction?: 'ltr' | 'rtl';
}
};

function PickerTrigger({
prefixCls,
Expand Down
6 changes: 3 additions & 3 deletions src/RangeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { NullableDateType, RangeValue } from './interface';
import type { NullableDateType, RangeValue } from './interface';

export interface RangeContextProps {
export type RangeContextProps = {
/**
* Set displayed range value style.
* Panel only has one value, this is only style effect.
Expand All @@ -10,7 +10,7 @@ export interface RangeContextProps {
hoverRangedValue?: RangeValue<any>;
inRange?: boolean;
panelPosition?: 'left' | 'right' | false;
}
};

const RangeContext = React.createContext<RangeContextProps>({});

Expand Down
43 changes: 19 additions & 24 deletions src/RangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { useRef, useEffect, useState } from 'react';
import classNames from 'classnames';
import warning from 'rc-util/lib/warning';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import { DisabledTimes, PanelMode, PickerMode, RangeValue, EventValue } from './interface';
import { PickerBaseProps, PickerDateProps, PickerTimeProps, PickerRefConfig } from './Picker';
import { SharedTimeProps } from './panels/TimePanel';
import type { DisabledTimes, PanelMode, PickerMode, RangeValue, EventValue } from './interface';
import type { PickerBaseProps, PickerDateProps, PickerTimeProps, PickerRefConfig } from './Picker';
import type { SharedTimeProps } from './panels/TimePanel';
import PickerTrigger from './PickerTrigger';
import PickerPanel from './PickerPanel';
import usePickerInput from './hooks/usePickerInput';
import getDataOrAriaProps, { toArray, getValue, updateValues } from './utils/miscUtil';
import { getDefaultFormat, getInputSize, elementsContains } from './utils/uiUtil';
import PanelContext, { ContextOperationRefProps } from './PanelContext';
import type { ContextOperationRefProps } from './PanelContext';
import PanelContext from './PanelContext';
import {
isEqual,
getClosingViewDate,
Expand All @@ -23,14 +24,14 @@ import {
} from './utils/dateUtil';
import useValueTexts from './hooks/useValueTexts';
import useTextValueMapping from './hooks/useTextValueMapping';
import { GenerateConfig } from './generate';
import { PickerPanelProps } from '.';
import type { GenerateConfig } from './generate';
import type { PickerPanelProps } from '.';
import RangeContext from './RangeContext';
import useRangeDisabled from './hooks/useRangeDisabled';
import getExtraFooter from './utils/getExtraFooter';
import getRanges from './utils/getRanges';
import useRangeViewDates from './hooks/useRangeViewDates';
import { DateRender } from './panels/DatePanel/DateBody';
import type { DateRender } from './panels/DatePanel/DateBody';
import useHoverValue from './hooks/useHoverValue';

function reorderValues<DateType>(
Expand Down Expand Up @@ -67,17 +68,17 @@ function canValueTrigger<DateType>(

export type RangeType = 'start' | 'end';

export interface RangeInfo {
export type RangeInfo = {
range: RangeType;
}
};

export type RangeDateRender<DateType> = (
currentDate: DateType,
today: DateType,
info: RangeInfo,
) => React.ReactNode;

export interface RangePickerSharedProps<DateType> {
export type RangePickerSharedProps<DateType> = {
id?: string;
value?: RangeValue<DateType>;
defaultValue?: RangeValue<DateType>;
Expand Down Expand Up @@ -108,7 +109,7 @@ export interface RangePickerSharedProps<DateType> {
activePickerIndex?: 0 | 1;
dateRender?: RangeDateRender<DateType>;
panelRender?: (originPanel: React.ReactNode) => React.ReactNode;
}
};

type OmitPickerProps<Props> = Omit<
Props,
Expand All @@ -134,21 +135,15 @@ type RangeShowTimeObject<DateType> = Omit<SharedTimeProps<DateType>, 'defaultVal
defaultValue?: DateType[];
};

export interface RangePickerBaseProps<DateType>
extends RangePickerSharedProps<DateType>,
OmitPickerProps<PickerBaseProps<DateType>> {}
export type RangePickerBaseProps<DateType> = {} & RangePickerSharedProps<DateType> & OmitPickerProps<PickerBaseProps<DateType>>;

export interface RangePickerDateProps<DateType>
extends RangePickerSharedProps<DateType>,
OmitPickerProps<PickerDateProps<DateType>> {
export type RangePickerDateProps<DateType> = {
showTime?: boolean | RangeShowTimeObject<DateType>;
}
} & RangePickerSharedProps<DateType> & OmitPickerProps<PickerDateProps<DateType>>;

export interface RangePickerTimeProps<DateType>
extends RangePickerSharedProps<DateType>,
OmitPickerProps<PickerTimeProps<DateType>> {
export type RangePickerTimeProps<DateType> = {
order?: boolean;
}
} & RangePickerSharedProps<DateType> & OmitPickerProps<PickerTimeProps<DateType>>;

export type RangePickerProps<DateType> =
| RangePickerBaseProps<DateType>
Expand All @@ -160,9 +155,9 @@ type OmitType<DateType> = Omit<RangePickerBaseProps<DateType>, 'picker'> &
Omit<RangePickerDateProps<DateType>, 'picker'> &
Omit<RangePickerTimeProps<DateType>, 'picker'>;

interface MergedRangePickerProps<DateType> extends OmitType<DateType> {
type MergedRangePickerProps<DateType> = {
picker?: PickerMode;
}
} & OmitType<DateType>;

function InnerRangePicker<DateType>(props: RangePickerProps<DateType>) {
const {
Expand Down
2 changes: 1 addition & 1 deletion src/generate/dateFns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
parse as parseDate,
} from 'date-fns';
import * as Locale from 'date-fns/locale';
import { GenerateConfig } from '.';
import type { GenerateConfig } from '.';

const dealLocal = (str: string) => {
return str.replace(/_/g, '');
Expand Down
Loading

0 comments on commit 26726d2

Please sign in to comment.