diff --git a/packages/components/package.json b/packages/components/package.json index 18fb79d0..4a54ef38 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -24,10 +24,12 @@ "@tippyjs/react": "^4.2.5", "classnames": "^2.3.1", "clsx": "^1.1.1", + "dayjs": "^1.10.7", "rc-dialog": "^8.6.0", "rc-field-form": "^1.21.2", "rc-input-number": "^7.3.0", "rc-motion": "^2.4.4", + "rc-picker": "^2.5.18", "rc-select": "^12.1.13", "react-hot-toast": "^2.1.1", "react-textarea-autosize": "^8.3.2", diff --git a/packages/components/src/ConfigProvider/LocaleProvider/types.ts b/packages/components/src/ConfigProvider/LocaleProvider/types.ts index 88aac2f5..775e7268 100644 --- a/packages/components/src/ConfigProvider/LocaleProvider/types.ts +++ b/packages/components/src/ConfigProvider/LocaleProvider/types.ts @@ -1,5 +1,8 @@ import { ModalLocale } from '../../Modal/locale'; +// eslint-disable-next-line import/no-cycle +import { PickerLocale } from '../../DatePicker/generatePicker'; export interface ILocale { Modal?: ModalLocale; + DatePicker?: PickerLocale; } diff --git a/packages/components/src/ConfigProvider/locales/default.ts b/packages/components/src/ConfigProvider/locales/default.ts index 94625eba..37aff7eb 100644 --- a/packages/components/src/ConfigProvider/locales/default.ts +++ b/packages/components/src/ConfigProvider/locales/default.ts @@ -1,4 +1,7 @@ +// eslint-disable-next-line import/no-cycle import { ILocale } from '../LocaleProvider/types'; +// eslint-disable-next-line import/no-cycle +import PickerLocale from '../../DatePicker/locales/en_US'; const localeValues: ILocale = { Modal: { @@ -6,6 +9,7 @@ const localeValues: ILocale = { cancelText: 'Cancel', justOkText: 'OK', }, + DatePicker: PickerLocale, }; export default localeValues; diff --git a/packages/components/src/DatePicker/DatePicker.story.tsx b/packages/components/src/DatePicker/DatePicker.story.tsx new file mode 100644 index 00000000..edbcb6e7 --- /dev/null +++ b/packages/components/src/DatePicker/DatePicker.story.tsx @@ -0,0 +1,10 @@ +import * as React from 'react'; +import DatePicker from './DatePicker'; + +// const { MonthPicker } = DatePicker; + +export default { + title: 'Components/DatePicker', +}; + +export const Basic = () => ; diff --git a/packages/components/src/DatePicker/DatePicker.tsx b/packages/components/src/DatePicker/DatePicker.tsx new file mode 100644 index 00000000..f4692ec8 --- /dev/null +++ b/packages/components/src/DatePicker/DatePicker.tsx @@ -0,0 +1,18 @@ +// https://github.com/ant-design/ant-design/blob/master/components/date-picker/index.tsx +import { Dayjs } from 'dayjs'; +import dayjsGenerateConfig from 'rc-picker/es/generate/dayjs'; +// eslint-disable-next-line import/no-cycle +import generatePicker, { + PickerProps, + PickerDateProps, + RangePickerProps as BaseRangePickerProps, +} from './generatePicker'; + +export type DatePickerProps = PickerProps; +export type MonthPickerProps = Omit, 'picker'>; +export type WeekPickerProps = Omit, 'picker'>; +export type RangePickerProps = BaseRangePickerProps; + +const DatePicker = generatePicker(dayjsGenerateConfig); + +export default DatePicker; diff --git a/packages/components/src/DatePicker/PickerButton.tsx b/packages/components/src/DatePicker/PickerButton.tsx new file mode 100644 index 00000000..734064ce --- /dev/null +++ b/packages/components/src/DatePicker/PickerButton.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { Button, ButtonProps } from '../Button/Button'; + +export default function PickerButton(props: ButtonProps) { + return