@ozen-ui/kit 0.74.0 → 0.75.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/__inner__/cjs/components/Calendar/Calendar.js +26 -2
- package/__inner__/cjs/components/Calendar/CalendarContext.d.ts +8 -1
- package/__inner__/cjs/components/Calendar/CalendarContext.js +10 -1
- package/__inner__/cjs/components/Calendar/__tests__/utils.d.ts +11 -0
- package/__inner__/cjs/components/Calendar/__tests__/utils.js +58 -0
- package/__inner__/cjs/components/Calendar/components/CalendarGrid/CalendarGrid.js +4 -3
- package/__inner__/cjs/components/Calendar/components/CalendarItem/CalendarItem.js +25 -2
- package/__inner__/cjs/components/Calendar/components/CalendarItem/CalendarItemContext.d.ts +1 -0
- package/__inner__/cjs/components/Calendar/components/CalendarItem/CalendarItemContext.js +1 -0
- package/__inner__/cjs/components/Calendar/components/CalendarModeRange/CalendarModeRange.js +68 -13
- package/__inner__/cjs/components/Calendar/components/CalendarModeSingle/CalendarModeSingle.js +62 -16
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/CalendarSwitcher.js +6 -7
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/CalendarSwitcherText.d.ts +3 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/CalendarSwitcherText.js +13 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/index.d.ts +2 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/index.js +5 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/types.d.ts +4 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/types.js +2 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/components/index.d.ts +1 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/components/index.js +4 -0
- package/__inner__/cjs/components/Calendar/constants.d.ts +2 -0
- package/__inner__/cjs/components/Calendar/constants.js +7 -1
- package/__inner__/cjs/components/Calendar/index.d.ts +1 -0
- package/__inner__/cjs/components/Calendar/index.js +1 -0
- package/__inner__/cjs/components/Calendar/types.d.ts +13 -5
- package/__inner__/cjs/components/Calendar/utils.d.ts +10 -1
- package/__inner__/cjs/components/Calendar/utils.js +12 -1
- package/__inner__/cjs/components/DatePicker/components/DateInput/DateInput.js +4 -3
- package/__inner__/cjs/components/DatePicker/components/DateInput/types.d.ts +6 -2
- package/__inner__/cjs/components/DatePicker/components/DateInput/utils/dateInputMask/dateInputMask.d.ts +2 -1
- package/__inner__/cjs/components/DatePicker/components/DateInput/utils/dateInputMask/dateInputMask.js +67 -7
- package/__inner__/cjs/components/DatePicker/components/DatePickerModeDate/DatePickerModeDate.js +32 -20
- package/__inner__/cjs/components/DatePicker/components/DatePickerModeDateRange/DatePickerModeDateRange.js +74 -51
- package/__inner__/cjs/components/DatePicker/constants.d.ts +2 -0
- package/__inner__/cjs/components/DatePicker/constants.js +4 -1
- package/__inner__/cjs/components/DatePicker/types.d.ts +10 -6
- package/__inner__/cjs/components/DatePicker/types.js +3 -1
- package/__inner__/cjs/components/DatePicker/utils/formatDateToString/formatDateToString.d.ts +2 -1
- package/__inner__/cjs/components/DatePicker/utils/formatDateToString/formatDateToString.js +18 -5
- package/__inner__/cjs/components/DatePicker/utils/formatStringToDate/formatStringToDate.d.ts +2 -1
- package/__inner__/cjs/components/DatePicker/utils/formatStringToDate/formatStringToDate.js +6 -5
- package/__inner__/cjs/components/DatePicker/utils/getCommonCalendarProps/getCommonCalendarProps.js +2 -2
- package/__inner__/cjs/components/DatePicker/utils/index.d.ts +2 -0
- package/__inner__/cjs/components/DatePicker/utils/index.js +2 -0
- package/__inner__/cjs/components/DatePicker/utils/isValidDateString/isValidDateString.d.ts +2 -1
- package/__inner__/cjs/components/DatePicker/utils/isValidDateString/isValidDateString.js +9 -8
- package/__inner__/cjs/components/DatePicker/utils/maskPastedDate/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/maskPastedDate/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/utils/maskPastedDate/maskPastedDate.d.ts +6 -0
- package/__inner__/cjs/components/DatePicker/utils/maskPastedDate/maskPastedDate.js +43 -0
- package/__inner__/cjs/components/DatePicker/utils/parseDateString/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/parseDateString/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/utils/parseDateString/parseDateString.d.ts +6 -0
- package/__inner__/cjs/components/DatePicker/utils/parseDateString/parseDateString.js +66 -0
- package/__inner__/cjs/components/ListCardItem/hooks/useListCardItemRatio.js +10 -14
- package/__inner__/cjs/components/OzenProvider/providers/theme/tokens/color/b-business-dark/color-b-business-dark.css +1 -1
- package/__inner__/cjs/components/OzenProvider/providers/theme/tokens/color/b-business-default/color-b-business-default.css +1 -1
- package/__inner__/cjs/components/OzenProvider/providers/theme/tokens/color/ozen-dark/color-ozen-dark.css +1 -1
- package/__inner__/cjs/components/OzenProvider/providers/theme/tokens/color/ozen-default/color-ozen-default.css +1 -1
- package/__inner__/cjs/components/OzenProvider/providers/theme/tokens/color/vip-dark/color-vip-dark.css +1 -1
- package/__inner__/cjs/components/OzenProvider/providers/theme/tokens/color/vip-default/color-vip-default.css +1 -1
- package/__inner__/cjs/components/OzenProvider/providers/theme/tokens/shadow/ozen-default/shadow-ozen-default.css +1 -1
- package/__inner__/cjs/components/Stack/Stack.css +3 -0
- package/__inner__/cjs/components/Stack/Stack.js +2 -1
- package/__inner__/cjs/components/Stack/constants.d.ts +1 -0
- package/__inner__/cjs/components/Stack/constants.js +2 -1
- package/__inner__/cjs/components/Stack/types.d.ts +4 -0
- package/__inner__/cjs/components/Stack/types.js +2 -1
- package/__inner__/cjs/hooks/useDevEffect/index.d.ts +1 -0
- package/__inner__/cjs/hooks/useDevEffect/index.js +4 -0
- package/__inner__/cjs/hooks/useDevEffect/useDevEffect.d.ts +3 -0
- package/__inner__/cjs/hooks/useDevEffect/useDevEffect.js +13 -0
- package/__inner__/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js +3 -2
- package/__inner__/cjs/locale/locale.js +39 -3
- package/__inner__/cjs/utils/array/createFilled/createFilledArray.d.ts +1 -1
- package/__inner__/cjs/utils/array/createFilled/createFilledArray.js +6 -1
- package/__inner__/esm/components/Calendar/Calendar.js +27 -3
- package/__inner__/esm/components/Calendar/CalendarContext.d.ts +8 -1
- package/__inner__/esm/components/Calendar/CalendarContext.js +10 -1
- package/__inner__/esm/components/Calendar/__tests__/utils.d.ts +11 -0
- package/__inner__/esm/components/Calendar/__tests__/utils.js +45 -0
- package/__inner__/esm/components/Calendar/components/CalendarGrid/CalendarGrid.js +4 -3
- package/__inner__/esm/components/Calendar/components/CalendarItem/CalendarItem.js +25 -2
- package/__inner__/esm/components/Calendar/components/CalendarItem/CalendarItemContext.d.ts +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarItem/CalendarItemContext.js +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarModeRange/CalendarModeRange.js +70 -15
- package/__inner__/esm/components/Calendar/components/CalendarModeSingle/CalendarModeSingle.js +64 -18
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/CalendarSwitcher.js +6 -7
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/CalendarSwitcherText.d.ts +3 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/CalendarSwitcherText.js +9 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/index.d.ts +2 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/index.js +2 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/types.d.ts +4 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/components/CalendarSwitcherText/types.js +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/components/index.d.ts +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/components/index.js +1 -0
- package/__inner__/esm/components/Calendar/constants.d.ts +2 -0
- package/__inner__/esm/components/Calendar/constants.js +6 -0
- package/__inner__/esm/components/Calendar/index.d.ts +1 -0
- package/__inner__/esm/components/Calendar/index.js +1 -0
- package/__inner__/esm/components/Calendar/types.d.ts +13 -5
- package/__inner__/esm/components/Calendar/utils.d.ts +10 -1
- package/__inner__/esm/components/Calendar/utils.js +9 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/DateInput.js +3 -2
- package/__inner__/esm/components/DatePicker/components/DateInput/types.d.ts +6 -2
- package/__inner__/esm/components/DatePicker/components/DateInput/utils/dateInputMask/dateInputMask.d.ts +2 -1
- package/__inner__/esm/components/DatePicker/components/DateInput/utils/dateInputMask/dateInputMask.js +67 -7
- package/__inner__/esm/components/DatePicker/components/DatePickerModeDate/DatePickerModeDate.js +33 -21
- package/__inner__/esm/components/DatePicker/components/DatePickerModeDateRange/DatePickerModeDateRange.js +68 -45
- package/__inner__/esm/components/DatePicker/constants.d.ts +2 -0
- package/__inner__/esm/components/DatePicker/constants.js +3 -0
- package/__inner__/esm/components/DatePicker/types.d.ts +10 -6
- package/__inner__/esm/components/DatePicker/types.js +2 -0
- package/__inner__/esm/components/DatePicker/utils/formatDateToString/formatDateToString.d.ts +2 -1
- package/__inner__/esm/components/DatePicker/utils/formatDateToString/formatDateToString.js +18 -5
- package/__inner__/esm/components/DatePicker/utils/formatStringToDate/formatStringToDate.d.ts +2 -1
- package/__inner__/esm/components/DatePicker/utils/formatStringToDate/formatStringToDate.js +6 -5
- package/__inner__/esm/components/DatePicker/utils/getCommonCalendarProps/getCommonCalendarProps.js +2 -2
- package/__inner__/esm/components/DatePicker/utils/index.d.ts +2 -0
- package/__inner__/esm/components/DatePicker/utils/index.js +2 -0
- package/__inner__/esm/components/DatePicker/utils/isValidDateString/isValidDateString.d.ts +2 -1
- package/__inner__/esm/components/DatePicker/utils/isValidDateString/isValidDateString.js +8 -7
- package/__inner__/esm/components/DatePicker/utils/maskPastedDate/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/maskPastedDate/index.js +1 -0
- package/__inner__/esm/components/DatePicker/utils/maskPastedDate/maskPastedDate.d.ts +6 -0
- package/__inner__/esm/components/DatePicker/utils/maskPastedDate/maskPastedDate.js +39 -0
- package/__inner__/esm/components/DatePicker/utils/parseDateString/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/parseDateString/index.js +1 -0
- package/__inner__/esm/components/DatePicker/utils/parseDateString/parseDateString.d.ts +6 -0
- package/__inner__/esm/components/DatePicker/utils/parseDateString/parseDateString.js +62 -0
- package/__inner__/esm/components/ListCardItem/hooks/useListCardItemRatio.js +10 -14
- package/__inner__/esm/components/OzenProvider/providers/theme/tokens/color/b-business-dark/color-b-business-dark.css +1 -1
- package/__inner__/esm/components/OzenProvider/providers/theme/tokens/color/b-business-default/color-b-business-default.css +1 -1
- package/__inner__/esm/components/OzenProvider/providers/theme/tokens/color/ozen-dark/color-ozen-dark.css +1 -1
- package/__inner__/esm/components/OzenProvider/providers/theme/tokens/color/ozen-default/color-ozen-default.css +1 -1
- package/__inner__/esm/components/OzenProvider/providers/theme/tokens/color/vip-dark/color-vip-dark.css +1 -1
- package/__inner__/esm/components/OzenProvider/providers/theme/tokens/color/vip-default/color-vip-default.css +1 -1
- package/__inner__/esm/components/OzenProvider/providers/theme/tokens/shadow/ozen-default/shadow-ozen-default.css +1 -1
- package/__inner__/esm/components/Stack/Stack.css +3 -0
- package/__inner__/esm/components/Stack/Stack.js +3 -2
- package/__inner__/esm/components/Stack/constants.d.ts +1 -0
- package/__inner__/esm/components/Stack/constants.js +1 -0
- package/__inner__/esm/components/Stack/types.d.ts +4 -0
- package/__inner__/esm/components/Stack/types.js +1 -0
- package/__inner__/esm/hooks/useDevEffect/index.d.ts +1 -0
- package/__inner__/esm/hooks/useDevEffect/index.js +1 -0
- package/__inner__/esm/hooks/useDevEffect/useDevEffect.d.ts +3 -0
- package/__inner__/esm/hooks/useDevEffect/useDevEffect.js +9 -0
- package/__inner__/esm/hooks/useIntersectionObserver/useIntersectionObserver.js +3 -2
- package/__inner__/esm/locale/locale.js +39 -3
- package/__inner__/esm/utils/array/createFilled/createFilledArray.d.ts +1 -1
- package/__inner__/esm/utils/array/createFilled/createFilledArray.js +6 -1
- package/package.json +4 -4
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ChangeEvent, ComponentRef, ReactNode } from 'react';
|
|
2
2
|
import type { ExtendableComponentPropsWithRef } from '../../types/ExtendableComponentPropsWithRef';
|
|
3
3
|
import type { WithDisplayName } from '../../types/react';
|
|
4
|
-
import type { CalendarProps } from '../Calendar';
|
|
4
|
+
import type { CalendarPropCalendars, CalendarProps, CalendarSteps } from '../Calendar';
|
|
5
5
|
import type { FieldHintProps } from '../FieldHint';
|
|
6
6
|
import type { FieldInputProps } from '../FieldInput';
|
|
7
7
|
import type { FieldLabelProps } from '../FieldLabel';
|
|
8
|
-
import type { InputProps
|
|
8
|
+
import type { InputProps } from '../Input';
|
|
9
9
|
import type { PopoverBaseProps } from '../Popover';
|
|
10
10
|
import type { StackProps } from '../Stack';
|
|
11
11
|
import type { DATE_PICKER_DEFAULT_MODE } from './constants';
|
|
@@ -19,7 +19,11 @@ export type DatePickerPropOnChange<MODE extends DatePickerModeVariant> = (date:
|
|
|
19
19
|
type InputPropLabel = InputProps['label'];
|
|
20
20
|
type InputPropRenderLeft = InputProps['renderLeft'];
|
|
21
21
|
type InputPropRenderRight = InputProps['renderRight'];
|
|
22
|
-
type
|
|
22
|
+
type InputPropPlaceholderString = InputProps['placeholder'];
|
|
23
|
+
type InputPropPlaceholderFunction = (steps: CalendarSteps) => InputPropPlaceholderString;
|
|
24
|
+
export type InputPropPlaceholder = InputPropPlaceholderString | InputPropPlaceholderFunction;
|
|
25
|
+
export declare const datePickerSizeVariant: readonly ["2xs", "xs", "s", "m", "l"];
|
|
26
|
+
export type DatePickerSizeVariant = (typeof datePickerSizeVariant)[number];
|
|
23
27
|
export type DatePickerPropLabel<MODE> = MODE extends Range ? [InputPropLabel?, InputPropLabel?] | InputPropLabel : InputPropLabel;
|
|
24
28
|
export type DatePickerPropRenderLeft<MODE> = MODE extends Range ? [InputPropRenderLeft?, InputPropRenderLeft?] | InputPropRenderLeft : InputPropRenderLeft;
|
|
25
29
|
export type DatePickerPropRenderRight<MODE> = MODE extends Range ? [InputPropRenderRight?, InputPropRenderRight?] | InputPropRenderRight : InputPropRenderRight;
|
|
@@ -96,7 +100,7 @@ export type DatePickerProps<MODE extends DatePickerModeVariant = typeof DATE_PIC
|
|
|
96
100
|
/** Cвойства FieldHint */
|
|
97
101
|
hintProps?: Omit<FieldHintProps, 'children'>;
|
|
98
102
|
/** Размер компонента */
|
|
99
|
-
size?:
|
|
103
|
+
size?: DatePickerSizeVariant;
|
|
100
104
|
/** Если `true` растягивает поле на всю ширину */
|
|
101
105
|
fullWidth?: boolean;
|
|
102
106
|
/** Если `true` делает элемент обязательным к заполнению */
|
|
@@ -108,8 +112,8 @@ export type DatePickerProps<MODE extends DatePickerModeVariant = typeof DATE_PIC
|
|
|
108
112
|
/** Свойства обертки для текстовых полей. Принимает свойства компонента [Stack](https://ozen-ui.bereke.tech/?path=/docs/components-stack--docs) */
|
|
109
113
|
fieldsProps?: DatePickerPropFieldsProps<MODE>;
|
|
110
114
|
/** Количество отображаемых календарей в компоненте: один или два */
|
|
111
|
-
calendars?:
|
|
112
|
-
} & Pick<CalendarProps, 'minDate' | 'maxDate' | 'exclude'> & Pick<InputProps, 'onKeyDown'>, 'div'>;
|
|
115
|
+
calendars?: CalendarPropCalendars;
|
|
116
|
+
} & Pick<CalendarProps, 'minDate' | 'maxDate' | 'exclude' | 'steps' | 'initialStep'> & Pick<InputProps, 'onKeyDown'>, 'div'>;
|
|
113
117
|
export type DatePickerComponent = WithDisplayName<(<MODE extends DatePickerModeVariant = typeof DATE_PICKER_DEFAULT_MODE>(props: DatePickerProps<MODE>) => ReactNode)>;
|
|
114
118
|
export type DatePickerModeComponent<MODE extends DatePickerModeVariant> = WithDisplayName<(props: Omit<DatePickerProps<MODE>, 'mode'>) => ReactNode>;
|
|
115
119
|
export {};
|
package/__inner__/esm/components/DatePicker/utils/formatDateToString/formatDateToString.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CalendarSteps } from '../../../Calendar';
|
|
2
|
+
export declare const formatDateToString: (date: Date | undefined | null, steps: CalendarSteps) => string;
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
export var formatDateToString = function (date) {
|
|
1
|
+
export var formatDateToString = function (date, steps) {
|
|
2
2
|
if (!date) {
|
|
3
3
|
return '';
|
|
4
4
|
}
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
5
|
+
var hasYearsStep = steps.includes('years');
|
|
6
|
+
var hasMonthsStep = steps.includes('months');
|
|
7
|
+
var hasDaysStep = steps.includes('days');
|
|
8
|
+
var parts = [];
|
|
9
|
+
if (hasDaysStep) {
|
|
10
|
+
var day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date);
|
|
11
|
+
parts.push(day);
|
|
12
|
+
}
|
|
13
|
+
if (hasMonthsStep) {
|
|
14
|
+
var month = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(date);
|
|
15
|
+
parts.push(month);
|
|
16
|
+
}
|
|
17
|
+
if (hasYearsStep) {
|
|
18
|
+
var year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(date);
|
|
19
|
+
parts.push(year);
|
|
20
|
+
}
|
|
21
|
+
return parts.join('.');
|
|
9
22
|
};
|
package/__inner__/esm/components/DatePicker/utils/formatStringToDate/formatStringToDate.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CalendarSteps } from '../../../Calendar';
|
|
2
|
+
export declare const formatStringToDate: (value: string, steps: CalendarSteps) => Date | null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export var formatStringToDate = function (value) {
|
|
3
|
-
var
|
|
4
|
-
if (!
|
|
1
|
+
import { parseDateString } from '../parseDateString';
|
|
2
|
+
export var formatStringToDate = function (value, steps) {
|
|
3
|
+
var parsedDate = parseDateString(value, steps);
|
|
4
|
+
if (!parsedDate) {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
var day = parsedDate.day, month = parsedDate.month, year = parsedDate.year;
|
|
8
|
+
return new Date(+year, +month - 1, +day);
|
|
8
9
|
};
|
package/__inner__/esm/components/DatePicker/utils/getCommonCalendarProps/getCommonCalendarProps.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { getCalendarSizeToFormElement } from '../getCalendarSizeToFormElement';
|
|
3
3
|
export var getCommonCalendarProps = function (props) {
|
|
4
|
-
var minDate = props.minDate, maxDate = props.maxDate, exclude = props.exclude, _a = props.size, size = _a === void 0 ? 'm' : _a, ref = props.ref, calendarProps = props.calendarProps;
|
|
4
|
+
var minDate = props.minDate, maxDate = props.maxDate, exclude = props.exclude, _a = props.size, size = _a === void 0 ? 'm' : _a, ref = props.ref, calendarProps = props.calendarProps, steps = props.steps, initialStep = props.initialStep;
|
|
5
5
|
/** Соотношение размера календаря к размеру элемента контроля */
|
|
6
6
|
var calendarSize = getCalendarSizeToFormElement(size);
|
|
7
7
|
/** Предотвращаем переход фокуса с текстового поля на интерактивные элементы календаря */
|
|
8
8
|
var handleMouseDownCalendar = function (e) {
|
|
9
9
|
e.preventDefault();
|
|
10
10
|
};
|
|
11
|
-
return __assign(__assign({ minDate: minDate, maxDate: maxDate, exclude: exclude, size: calendarSize }, calendarProps), { ref: ref, onMouseDown: handleMouseDownCalendar });
|
|
11
|
+
return __assign(__assign({ minDate: minDate, maxDate: maxDate, exclude: exclude, size: calendarSize }, calendarProps), { ref: ref, onMouseDown: handleMouseDownCalendar, steps: steps, initialStep: initialStep });
|
|
12
12
|
};
|
|
@@ -6,4 +6,6 @@ export * from './isInExclude';
|
|
|
6
6
|
export * from './getCommonPopoverProps';
|
|
7
7
|
export * from './getCommonCalendarProps';
|
|
8
8
|
export * from './isValidDateString';
|
|
9
|
+
export * from './maskPastedDate';
|
|
10
|
+
export * from './parseDateString';
|
|
9
11
|
export * from './useCalendarKeyboard';
|
|
@@ -6,4 +6,6 @@ export * from './isInExclude';
|
|
|
6
6
|
export * from './getCommonPopoverProps';
|
|
7
7
|
export * from './getCommonCalendarProps';
|
|
8
8
|
export * from './isValidDateString';
|
|
9
|
+
export * from './maskPastedDate';
|
|
10
|
+
export * from './parseDateString';
|
|
9
11
|
export * from './useCalendarKeyboard';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CalendarSteps } from '../../../Calendar';
|
|
2
|
+
export declare const isValidDateString: (value: string | null | undefined, steps: CalendarSteps) => boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export var isValidDateString = function (value) {
|
|
1
|
+
import { isNotNil } from '../../../../utils';
|
|
2
|
+
import { parseDateString } from '../parseDateString';
|
|
3
|
+
export var isValidDateString = function (value, steps) {
|
|
5
4
|
if (!isNotNil(value)) {
|
|
6
5
|
return false;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
if (value === '') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
var parsedDate = parseDateString(value, steps);
|
|
11
|
+
return !!parsedDate;
|
|
11
12
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './maskPastedDate';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './maskPastedDate';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CalendarSteps } from '../../../Calendar';
|
|
2
|
+
/**
|
|
3
|
+
* Функция для обработки вставленного значения.
|
|
4
|
+
* Умеет обрабатывать форматы DD.MM.YYYY/DDMMYYYY, либо сочетания вида DDMM/DD.MM.
|
|
5
|
+
*/
|
|
6
|
+
export declare const maskPastedDate: (value: string, steps: CalendarSteps) => string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Функция для обработки вставленного значения.
|
|
3
|
+
* Умеет обрабатывать форматы DD.MM.YYYY/DDMMYYYY, либо сочетания вида DDMM/DD.MM.
|
|
4
|
+
*/
|
|
5
|
+
export var maskPastedDate = function (value, steps) {
|
|
6
|
+
var digits = value.replace(/\D/g, '').slice(0, 8); // максимум 8 цифр
|
|
7
|
+
var hasYearsStep = steps.includes('years');
|
|
8
|
+
var hasMonthsStep = steps.includes('months');
|
|
9
|
+
var hasDaysStep = steps.includes('days');
|
|
10
|
+
// DD
|
|
11
|
+
if (hasDaysStep && !hasMonthsStep && !hasYearsStep) {
|
|
12
|
+
return digits.slice(0, 2);
|
|
13
|
+
}
|
|
14
|
+
// MM
|
|
15
|
+
if (!hasDaysStep && hasMonthsStep && !hasYearsStep) {
|
|
16
|
+
return digits.slice(0, 2);
|
|
17
|
+
}
|
|
18
|
+
// YYYY
|
|
19
|
+
if (!hasDaysStep && !hasMonthsStep && hasYearsStep) {
|
|
20
|
+
return digits.slice(0, 4);
|
|
21
|
+
}
|
|
22
|
+
// DD.MM.YYYY
|
|
23
|
+
if (hasDaysStep && hasMonthsStep && hasYearsStep) {
|
|
24
|
+
return "".concat(digits.slice(0, 2), ".").concat(digits.slice(2, 4), ".").concat(digits.slice(4, 8));
|
|
25
|
+
}
|
|
26
|
+
// DD.MM
|
|
27
|
+
if (hasDaysStep && hasMonthsStep && !hasYearsStep) {
|
|
28
|
+
return "".concat(digits.slice(0, 2), ".").concat(digits.slice(2, 4));
|
|
29
|
+
}
|
|
30
|
+
// DD.YYYY
|
|
31
|
+
if (hasDaysStep && !hasMonthsStep && hasYearsStep) {
|
|
32
|
+
return "".concat(digits.slice(0, 2), ".").concat(digits.slice(2, 6));
|
|
33
|
+
}
|
|
34
|
+
// MM.YYYY
|
|
35
|
+
if (!hasDaysStep && hasMonthsStep && hasYearsStep) {
|
|
36
|
+
return "".concat(digits.slice(0, 2), ".").concat(digits.slice(2, 6));
|
|
37
|
+
}
|
|
38
|
+
throw new Error('Не удалось сделать маску для значения');
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './parseDateString';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './parseDateString';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isNotNil, isValidDate } from '../../../../utils';
|
|
2
|
+
export var parseDateString = function (value, steps) {
|
|
3
|
+
if (!isNotNil(value)) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
if (value === '') {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
var hasYearsSteps = steps.includes('years');
|
|
10
|
+
var hasMonthsSteps = steps.includes('months');
|
|
11
|
+
var hasDaysSteps = steps.includes('days');
|
|
12
|
+
var splitted = value.split('.');
|
|
13
|
+
var day;
|
|
14
|
+
var month;
|
|
15
|
+
var year;
|
|
16
|
+
var offset = 0;
|
|
17
|
+
if (hasDaysSteps) {
|
|
18
|
+
day = splitted[offset];
|
|
19
|
+
offset += 1;
|
|
20
|
+
}
|
|
21
|
+
if (hasMonthsSteps) {
|
|
22
|
+
month = splitted[offset];
|
|
23
|
+
offset += 1;
|
|
24
|
+
}
|
|
25
|
+
if (hasYearsSteps) {
|
|
26
|
+
year = splitted[offset];
|
|
27
|
+
}
|
|
28
|
+
var parts = [];
|
|
29
|
+
if (hasYearsSteps) {
|
|
30
|
+
parts.push(year);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
var now = new Date();
|
|
34
|
+
parts.push(now.getFullYear().toString());
|
|
35
|
+
}
|
|
36
|
+
if (hasMonthsSteps) {
|
|
37
|
+
parts.push(month);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// 3 месяц для кейса, где пользователь вводит 31 день месяца
|
|
41
|
+
parts.push('03');
|
|
42
|
+
}
|
|
43
|
+
if (hasDaysSteps) {
|
|
44
|
+
parts.push(day);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
parts.push('01');
|
|
48
|
+
}
|
|
49
|
+
var filteredParts = parts.filter(function (part) { return part !== undefined; });
|
|
50
|
+
if (filteredParts.length !== 3) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
var stringDate = filteredParts.join('-');
|
|
54
|
+
if (stringDate.length !== 10 || !isValidDate(stringDate)) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
year: parts[0],
|
|
59
|
+
month: parts[1],
|
|
60
|
+
day: parts[2],
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
1
|
import { logger } from '@ozen-ui/logger';
|
|
3
|
-
import {
|
|
2
|
+
import { useDevEffect } from '../../../hooks/useDevEffect';
|
|
4
3
|
export var useListCardItemRatio = function (contentTrailingRatio) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
}, [contentTrailingRatio]);
|
|
16
|
-
}
|
|
4
|
+
useDevEffect(function () {
|
|
5
|
+
if (contentTrailingRatio < 0) {
|
|
6
|
+
logger.error('Свойство «contentTrailingRatio» у компонента ListCardItem не может быть меньше 0');
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (contentTrailingRatio > 1) {
|
|
10
|
+
logger.error('Свойство «contentTrailingRatio» у компонента ListCardItem не может быть больше 1');
|
|
11
|
+
}
|
|
12
|
+
}, [contentTrailingRatio]);
|
|
17
13
|
var contentRatio = contentTrailingRatio * 100;
|
|
18
14
|
var trailingRatio = 100 - contentRatio;
|
|
19
15
|
return { content: contentRatio, trailing: trailingRatio };
|
|
@@ -5,7 +5,7 @@ import { classnames } from '@bem-react/classnames';
|
|
|
5
5
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
6
6
|
import { cn } from '../../utils/classname';
|
|
7
7
|
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
8
|
-
import { STACK_DEFAULT_TAG } from './constants';
|
|
8
|
+
import { STACK_DEFAULT_DISPLAY, STACK_DEFAULT_TAG } from './constants';
|
|
9
9
|
import { generateDirectionCn, generateGapCn } from './utils';
|
|
10
10
|
export var cnStack = cn('Stack');
|
|
11
11
|
export var Stack = polymorphicComponentWithRef(function (inProps, ref) {
|
|
@@ -13,7 +13,7 @@ export var Stack = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
13
13
|
props: inProps,
|
|
14
14
|
name: 'Stack',
|
|
15
15
|
});
|
|
16
|
-
var _a = props.as, Tag = _a === void 0 ? STACK_DEFAULT_TAG : _a, _b = props.direction, direction = _b === void 0 ? 'row' : _b, divider = props.divider, _c = props.shouldWrapChildren, shouldWrapChildren = _c === void 0 ? false : _c, fullWidth = props.fullWidth, children = props.children, align = props.align, justify = props.justify, gap = props.gap, wrap = props.wrap, className = props.className, other = __rest(props, ["as", "direction", "divider", "shouldWrapChildren", "fullWidth", "children", "align", "justify", "gap", "wrap", "className"]);
|
|
16
|
+
var _a = props.as, Tag = _a === void 0 ? STACK_DEFAULT_TAG : _a, _b = props.direction, direction = _b === void 0 ? 'row' : _b, divider = props.divider, _c = props.shouldWrapChildren, shouldWrapChildren = _c === void 0 ? false : _c, _d = props.display, display = _d === void 0 ? STACK_DEFAULT_DISPLAY : _d, fullWidth = props.fullWidth, children = props.children, align = props.align, justify = props.justify, gap = props.gap, wrap = props.wrap, className = props.className, other = __rest(props, ["as", "direction", "divider", "shouldWrapChildren", "display", "fullWidth", "children", "align", "justify", "gap", "wrap", "className"]);
|
|
17
17
|
var childNodes = Children.toArray(children);
|
|
18
18
|
if (!childNodes.length) {
|
|
19
19
|
return null;
|
|
@@ -35,6 +35,7 @@ export var Stack = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
35
35
|
justify: justify,
|
|
36
36
|
fullWidth: fullWidth,
|
|
37
37
|
wrap: wrap,
|
|
38
|
+
display: display === 'inline' ? undefined : display,
|
|
38
39
|
}), generateDirectionCn(cnStack, direction), generateGapCn(cnStack, gap), className), ref: ref }), resolveChildren()));
|
|
39
40
|
});
|
|
40
41
|
Stack.displayName = 'Stack';
|
|
@@ -3,6 +3,7 @@ import type { ResponsiveValue } from '../../types/ResponsiveValue';
|
|
|
3
3
|
import type { PolymorphicComponentPropsWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
4
4
|
import type { STACK_DEFAULT_TAG } from './constants';
|
|
5
5
|
export declare const stackGapVariant: readonly ["0", "xs", "s", "m", "l", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "7xl", "8xl"];
|
|
6
|
+
export declare const stackDisplayVariant: readonly ["inline", "block"];
|
|
6
7
|
export declare const stackDirectionVariant: readonly ["row", "column", "rowReverse", "columnReverse"];
|
|
7
8
|
export declare const stackAlignVariant: readonly ["center", "start", "end", "baseline"];
|
|
8
9
|
export declare const stackJustifyVariant: readonly ["start", "center", "end", "spaceBetween", "spaceAround"];
|
|
@@ -10,9 +11,12 @@ export type StackGapVariant = (typeof stackGapVariant)[number];
|
|
|
10
11
|
export type StackDirectionVariant = (typeof stackDirectionVariant)[number];
|
|
11
12
|
export type StackAlignVariant = (typeof stackAlignVariant)[number];
|
|
12
13
|
export type StackJustifyVariant = (typeof stackJustifyVariant)[number];
|
|
14
|
+
export type StackDisplayVariant = (typeof stackDisplayVariant)[number];
|
|
13
15
|
export type StackBaseProps = {
|
|
14
16
|
/** Направление */
|
|
15
17
|
direction?: ResponsiveValue<StackDirectionVariant>;
|
|
18
|
+
/** Display */
|
|
19
|
+
display?: StackDisplayVariant;
|
|
16
20
|
/** Выравнивание */
|
|
17
21
|
align?: StackAlignVariant;
|
|
18
22
|
/** Пространство между элементами */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useDevEffect';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useDevEffect';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { isDev } from '../../constants/environment';
|
|
3
|
+
/** Эффект, отрабатывающий только в dev-режиме */
|
|
4
|
+
export var useDevEffect = function (effect, deps) {
|
|
5
|
+
if (isDev) {
|
|
6
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
7
|
+
useEffect(effect, deps);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
@@ -16,7 +16,7 @@ options) {
|
|
|
16
16
|
var savedOnHidden = useMutableRef(options === null || options === void 0 ? void 0 : options.onHidden);
|
|
17
17
|
var entry = useStoredValue(undefined);
|
|
18
18
|
var inView = useStoredValue(false);
|
|
19
|
-
var observer = useStoredValue(
|
|
19
|
+
var observer = useStoredValue(null);
|
|
20
20
|
var connect = useCallback(function () {
|
|
21
21
|
if (!isEnabled) {
|
|
22
22
|
return;
|
|
@@ -60,7 +60,8 @@ options) {
|
|
|
60
60
|
isEnabled,
|
|
61
61
|
]);
|
|
62
62
|
var disconnect = useCallback(function () {
|
|
63
|
-
|
|
63
|
+
var _a;
|
|
64
|
+
(_a = observer.current) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
64
65
|
}, [observer]);
|
|
65
66
|
var reconnect = useCallback(function () {
|
|
66
67
|
disconnect();
|
|
@@ -87,7 +87,19 @@ export var ruRU = {
|
|
|
87
87
|
},
|
|
88
88
|
DatePicker: {
|
|
89
89
|
clearText: 'Очистить',
|
|
90
|
-
placeholder:
|
|
90
|
+
placeholder: function (steps) {
|
|
91
|
+
var parts = [];
|
|
92
|
+
if (steps.includes('days')) {
|
|
93
|
+
parts.push('ДД');
|
|
94
|
+
}
|
|
95
|
+
if (steps.includes('months')) {
|
|
96
|
+
parts.push('ММ');
|
|
97
|
+
}
|
|
98
|
+
if (steps.includes('years')) {
|
|
99
|
+
parts.push('ГГГГ');
|
|
100
|
+
}
|
|
101
|
+
return parts.join('.');
|
|
102
|
+
},
|
|
91
103
|
},
|
|
92
104
|
},
|
|
93
105
|
};
|
|
@@ -179,7 +191,19 @@ export var kkKZ = {
|
|
|
179
191
|
},
|
|
180
192
|
DatePicker: {
|
|
181
193
|
clearText: 'Тазалау',
|
|
182
|
-
placeholder:
|
|
194
|
+
placeholder: function (steps) {
|
|
195
|
+
var parts = [];
|
|
196
|
+
if (steps.includes('days')) {
|
|
197
|
+
parts.push('КК');
|
|
198
|
+
}
|
|
199
|
+
if (steps.includes('months')) {
|
|
200
|
+
parts.push('АА');
|
|
201
|
+
}
|
|
202
|
+
if (steps.includes('years')) {
|
|
203
|
+
parts.push('ЖЖЖЖ');
|
|
204
|
+
}
|
|
205
|
+
return parts.join('.');
|
|
206
|
+
},
|
|
183
207
|
},
|
|
184
208
|
},
|
|
185
209
|
};
|
|
@@ -272,7 +296,19 @@ export var enUS = {
|
|
|
272
296
|
},
|
|
273
297
|
DatePicker: {
|
|
274
298
|
clearText: 'Clear',
|
|
275
|
-
placeholder:
|
|
299
|
+
placeholder: function (steps) {
|
|
300
|
+
var parts = [];
|
|
301
|
+
if (steps.includes('days')) {
|
|
302
|
+
parts.push('DD');
|
|
303
|
+
}
|
|
304
|
+
if (steps.includes('months')) {
|
|
305
|
+
parts.push('MM');
|
|
306
|
+
}
|
|
307
|
+
if (steps.includes('years')) {
|
|
308
|
+
parts.push('YYYY');
|
|
309
|
+
}
|
|
310
|
+
return parts.join('.');
|
|
311
|
+
},
|
|
276
312
|
},
|
|
277
313
|
},
|
|
278
314
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createFilledArray: <Value>(length: number, value: Value) => Value[];
|
|
1
|
+
export declare const createFilledArray: <Value>(length: number, value: Value | ((index: number) => Value)) => Value[];
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { isFunction } from '../../isFunction';
|
|
1
2
|
export var createFilledArray = function (length, value) {
|
|
2
|
-
|
|
3
|
+
var array = [];
|
|
4
|
+
for (var i = 0; i < length; i++) {
|
|
5
|
+
array.push(isFunction(value) ? value(i) : value);
|
|
6
|
+
}
|
|
7
|
+
return array;
|
|
3
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ozen-ui/kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.0",
|
|
4
4
|
"description": "React component library",
|
|
5
5
|
"files": [
|
|
6
6
|
"*"
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"react-popper": "^2.3.0",
|
|
30
30
|
"react-transition-group": "^4.4.5",
|
|
31
31
|
"tslib": "^2.6.3",
|
|
32
|
-
"@ozen-ui/
|
|
33
|
-
"@ozen-ui/
|
|
34
|
-
"@ozen-ui/logger": "0.
|
|
32
|
+
"@ozen-ui/fonts": "0.75.0",
|
|
33
|
+
"@ozen-ui/icons": "0.75.0",
|
|
34
|
+
"@ozen-ui/logger": "0.75.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/lodash.isequal": "^4.5.0"
|