@true-engineering/true-react-common-ui-kit 3.51.0 → 3.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/components/DatePicker/DatePicker.d.ts +2 -2
- package/dist/components/DatePicker/helpers.d.ts +3 -0
- package/dist/components/DatePicker/types.d.ts +3 -1
- package/dist/true-react-common-ui-kit.js +4982 -4973
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +4982 -4973
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/DatePicker/DatePicker.tsx +9 -4
- package/src/components/DatePicker/helpers.ts +13 -1
- package/src/components/DatePicker/types.ts +4 -1
package/package.json
CHANGED
|
@@ -14,13 +14,18 @@ import { ICommonProps } from '../../types';
|
|
|
14
14
|
import { DateInput, EMPTY_DATE_INPUT_VALUE, IDateInputProps } from '../DateInput';
|
|
15
15
|
import { DatePickerHeader, PopperContainer } from './components';
|
|
16
16
|
import { DatePickerComponent, DEFAULT_DATE_FORMAT } from './constants';
|
|
17
|
-
import {
|
|
18
|
-
|
|
17
|
+
import {
|
|
18
|
+
areDatesEquals,
|
|
19
|
+
getDateFormatter,
|
|
20
|
+
getDateValueParser,
|
|
21
|
+
preparateDatePickerLocale,
|
|
22
|
+
} from './helpers';
|
|
23
|
+
import { IDatePickerBaseProps, IDatePickerLocale, IRange } from './types';
|
|
19
24
|
import { useStyles, IDatePickerStyles } from './DatePicker.styles';
|
|
20
25
|
|
|
21
26
|
export interface IDatePickerProps extends IDatePickerBaseProps, ICommonProps<IDatePickerStyles> {
|
|
22
27
|
selectedDate?: Date | null;
|
|
23
|
-
locale:
|
|
28
|
+
locale: IDatePickerLocale;
|
|
24
29
|
months?: string[];
|
|
25
30
|
/** @default 'dd.MM.yyyy' */
|
|
26
31
|
dateFormat?: string;
|
|
@@ -242,7 +247,7 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
242
247
|
ref={ref}
|
|
243
248
|
minDate={minDate}
|
|
244
249
|
maxDate={maxDate}
|
|
245
|
-
locale={locale}
|
|
250
|
+
locale={preparateDatePickerLocale(locale)}
|
|
246
251
|
dateFormat={dateFormat}
|
|
247
252
|
placeholderText={placeholder}
|
|
248
253
|
calendarStartDay={calendarStartDay}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { parse, format, isSameDay } from 'date-fns';
|
|
1
|
+
import { parse, format, isSameDay, type Locale } from 'date-fns';
|
|
2
|
+
import { ru as ruLocale, enUS as enLocale } from 'date-fns/locale';
|
|
2
3
|
import {
|
|
3
4
|
isEmpty,
|
|
4
5
|
isNotEmpty,
|
|
5
6
|
isStringNotEmpty,
|
|
6
7
|
} from '@true-engineering/true-react-platform-helpers';
|
|
7
8
|
import { EMPTY_DATE_INPUT_VALUE } from '../DateInput';
|
|
9
|
+
import { IDatePickerLocale } from './types';
|
|
8
10
|
|
|
9
11
|
export const getDateFormatter =
|
|
10
12
|
(dateFormat: string) =>
|
|
@@ -21,3 +23,13 @@ export const getDateValueParser =
|
|
|
21
23
|
export const areDatesEquals = (date1?: Date | null, date2?: Date | null): boolean =>
|
|
22
24
|
(isEmpty(date1) && isEmpty(date2)) ||
|
|
23
25
|
(isNotEmpty(date1) && isNotEmpty(date2) && isSameDay(date1, date2));
|
|
26
|
+
|
|
27
|
+
export const preparateDatePickerLocale = (locale: IDatePickerLocale): Locale => {
|
|
28
|
+
if (locale === 'ru') {
|
|
29
|
+
return ruLocale;
|
|
30
|
+
}
|
|
31
|
+
if (locale === 'en') {
|
|
32
|
+
return enLocale;
|
|
33
|
+
}
|
|
34
|
+
return locale;
|
|
35
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ReactDatePickerProps } from 'react-datepicker';
|
|
2
|
-
import {
|
|
2
|
+
import { type Locale } from 'date-fns';
|
|
3
|
+
import { type IDateInputProps } from '../DateInput';
|
|
3
4
|
|
|
4
5
|
export type IRange = [Date | null, Date | null] | null;
|
|
5
6
|
|
|
7
|
+
export type IDatePickerLocale = 'ru' | 'en' | Locale;
|
|
8
|
+
|
|
6
9
|
export type IDatePickerBaseProps = Pick<
|
|
7
10
|
ReactDatePickerProps,
|
|
8
11
|
| 'startDate'
|