@snack-uikit/calendar 0.13.19 → 0.13.20-preview-ff470bb3.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 +1 -0
- package/dist/cjs/components/TimePicker/TimePicker.d.ts +7 -2
- package/dist/cjs/components/TimePicker/TimePicker.js +3 -1
- package/dist/cjs/helperComponents/CalendarContext/CalendarContext.d.ts +3 -1
- package/dist/cjs/helperComponents/Footer/Footer.js +6 -3
- package/dist/cjs/helperComponents/Footer/styles.module.css +7 -3
- package/dist/cjs/types.d.ts +6 -0
- package/dist/esm/components/TimePicker/TimePicker.d.ts +7 -2
- package/dist/esm/components/TimePicker/TimePicker.js +2 -1
- package/dist/esm/helperComponents/CalendarContext/CalendarContext.d.ts +3 -1
- package/dist/esm/helperComponents/Footer/Footer.js +3 -3
- package/dist/esm/helperComponents/Footer/styles.module.css +7 -3
- package/dist/esm/types.d.ts +6 -0
- package/package.json +2 -2
- package/src/components/TimePicker/TimePicker.tsx +8 -1
- package/src/helperComponents/CalendarContext/CalendarContext.tsx +3 -0
- package/src/helperComponents/Footer/Footer.tsx +6 -2
- package/src/helperComponents/Footer/styles.module.scss +6 -0
- package/src/types.ts +7 -0
package/README.md
CHANGED
|
@@ -128,6 +128,7 @@ function TimePickerExample() {
|
|
|
128
128
|
| defaultValue | `TimeValue` | - | Значение по-умолчанию для uncontrolled. |
|
|
129
129
|
| onChangeValue | `(value?: TimeValue) => void` | - | Колбек выбора значения |
|
|
130
130
|
| showSeconds | `boolean` | true | Показывать ли секунды |
|
|
131
|
+
| footerMode | enum TimePickerFooterMode: `"current-time-and-apply"`, `"apply-only"` | current-time-and-apply | Режим футера: выбор текущего времени (кнопка «Текущее») и компактная «Применить», либо одна широкая «Применить» с подписью. |
|
|
131
132
|
| size | enum Size: `"s"`, `"m"`, `"l"` | m | Размер |
|
|
132
133
|
| className | `string` | - | CSS-класс контейнера |
|
|
133
134
|
| fitToContainer | `boolean` | true | Отключает предустановленный размер, заставляя компонент подстраиваться к размеру контейнра: (width: 100%, height: 100%). |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
-
import { FocusDirection, Size, TimeValue } from '../../types';
|
|
3
|
+
import { FocusDirection, Size, TimePickerFooterMode, TimeValue } from '../../types';
|
|
4
4
|
export type TimePickerProps = WithSupportProps<{
|
|
5
5
|
/** Выбранное значение.*/
|
|
6
6
|
value?: TimeValue;
|
|
@@ -12,6 +12,11 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
12
12
|
onChangeValue?(value?: TimeValue): void;
|
|
13
13
|
/** Показывать ли секунды */
|
|
14
14
|
showSeconds?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Режим футера: выбор текущего времени (кнопка «Текущее») и компактная «Применить», либо одна широкая «Применить» с подписью.
|
|
17
|
+
* @default current-time-and-apply
|
|
18
|
+
*/
|
|
19
|
+
footerMode?: TimePickerFooterMode;
|
|
15
20
|
/**
|
|
16
21
|
* Размер
|
|
17
22
|
* @default m
|
|
@@ -31,4 +36,4 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
31
36
|
focus(): void;
|
|
32
37
|
}>;
|
|
33
38
|
}>;
|
|
34
|
-
export declare function TimePicker({ className, size, fitToContainer, value: valueProp, defaultValue, onChangeValue, onFocusLeave, 'data-test-id': testId, navigationStartRef, showSeconds, today: todayProp, }: TimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function TimePicker({ className, size, fitToContainer, value: valueProp, defaultValue, onChangeValue, onFocusLeave, 'data-test-id': testId, navigationStartRef, showSeconds, today: todayProp, footerMode, }: TimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -36,7 +36,8 @@ function TimePicker(_ref) {
|
|
|
36
36
|
'data-test-id': testId,
|
|
37
37
|
navigationStartRef,
|
|
38
38
|
showSeconds = true,
|
|
39
|
-
today: todayProp
|
|
39
|
+
today: todayProp,
|
|
40
|
+
footerMode = 'current-time-and-apply'
|
|
40
41
|
} = _ref;
|
|
41
42
|
const [value, setValueState] = (0, uncontrollable_1.useUncontrolledProp)(valueProp, defaultValue, onChangeValue);
|
|
42
43
|
const setValueEventHandler = (0, utils_1.useEventHandler)(setValueState);
|
|
@@ -110,6 +111,7 @@ function TimePicker(_ref) {
|
|
|
110
111
|
onFocusLeave,
|
|
111
112
|
navigationStartRef,
|
|
112
113
|
showSeconds,
|
|
114
|
+
footerMode,
|
|
113
115
|
dateAndTime,
|
|
114
116
|
onTimeChange,
|
|
115
117
|
onDateAndTimeChange,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MutableRefObject, RefObject } from 'react';
|
|
2
2
|
import { ListProps } from '@snack-uikit/list';
|
|
3
|
-
import { BuildCellPropsFunction, CalendarMode, DateAndTime, FocusDirection, Range, Size, TimeValue, ViewMode } from '../../types';
|
|
3
|
+
import { BuildCellPropsFunction, CalendarMode, DateAndTime, FocusDirection, Range, Size, TimePickerFooterMode, TimeValue, ViewMode } from '../../types';
|
|
4
4
|
export type CalendarContextType = {
|
|
5
5
|
size: Size;
|
|
6
6
|
/** Дата текущего дня */
|
|
@@ -21,6 +21,8 @@ export type CalendarContextType = {
|
|
|
21
21
|
viewShift: number;
|
|
22
22
|
focus?: string;
|
|
23
23
|
locale: Intl.Locale;
|
|
24
|
+
/** Режим футера time-picker */
|
|
25
|
+
footerMode?: TimePickerFooterMode;
|
|
24
26
|
onFocusLeave?(direction: FocusDirection): void;
|
|
25
27
|
buildCellProps?: BuildCellPropsFunction;
|
|
26
28
|
setFocus(address: string | undefined): void;
|
|
@@ -13,7 +13,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
13
13
|
const react_1 = require("react");
|
|
14
14
|
const button_1 = require("@snack-uikit/button");
|
|
15
15
|
const divider_1 = require("@snack-uikit/divider");
|
|
16
|
-
const icons_1 = require("@snack-uikit/icons");
|
|
17
16
|
const list_1 = require("@snack-uikit/list");
|
|
18
17
|
const locale_1 = require("@snack-uikit/locale");
|
|
19
18
|
const constants_1 = require("../../constants");
|
|
@@ -40,8 +39,10 @@ function Footer() {
|
|
|
40
39
|
getTestId,
|
|
41
40
|
referenceDate,
|
|
42
41
|
setViewShift,
|
|
43
|
-
onFocusLeave
|
|
42
|
+
onFocusLeave,
|
|
43
|
+
footerMode = 'current-time-and-apply'
|
|
44
44
|
} = (0, react_1.useContext)(CalendarContext_1.CalendarContext);
|
|
45
|
+
const isApplyOnlyFooter = footerMode === 'apply-only';
|
|
45
46
|
const {
|
|
46
47
|
t
|
|
47
48
|
} = (0, locale_1.useLocale)('Calendar');
|
|
@@ -106,6 +107,8 @@ function Footer() {
|
|
|
106
107
|
className: styles_module_scss_1.default.currentWrapper,
|
|
107
108
|
"data-size": size,
|
|
108
109
|
children: [(0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
|
|
110
|
+
className: styles_module_scss_1.default.currentButton,
|
|
111
|
+
"data-hidden": isApplyOnlyFooter,
|
|
109
112
|
label: t('current'),
|
|
110
113
|
size: size === 's' ? 'xs' : 's',
|
|
111
114
|
onClick: handleCurrentClick,
|
|
@@ -113,7 +116,7 @@ function Footer() {
|
|
|
113
116
|
onKeyDown: handleCurrentKeyDown,
|
|
114
117
|
"data-test-id": getTestId('current-button')
|
|
115
118
|
}), (0, jsx_runtime_1.jsx)(button_1.ButtonFilled, {
|
|
116
|
-
|
|
119
|
+
label: t('apply'),
|
|
117
120
|
size: size === 's' ? 'xs' : 's',
|
|
118
121
|
disabled: isApplyButtonDisabled,
|
|
119
122
|
onClick: handleApplySelection,
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
padding-left:var(--space-drop-list-item-s-container-horizontal-padding, 8px);
|
|
30
30
|
padding-right:var(--space-drop-list-item-s-container-horizontal-padding, 8px);
|
|
31
31
|
gap:var(--space-drop-list-item-s-container-gap, 8px);
|
|
32
|
-
gap:var(--
|
|
32
|
+
gap:var(--dimension-theme-general-4px, 4px);
|
|
33
33
|
}
|
|
34
34
|
.currentWrapper[data-size=m]{
|
|
35
35
|
padding-top:var(--space-drop-list-item-m-container-vertical-padding, 8px);
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
padding-left:var(--space-drop-list-item-m-container-horizontal-padding, 10px);
|
|
38
38
|
padding-right:var(--space-drop-list-item-m-container-horizontal-padding, 10px);
|
|
39
39
|
gap:var(--space-drop-list-item-m-container-gap, 8px);
|
|
40
|
-
gap:var(--
|
|
40
|
+
gap:var(--dimension-050m, 4px);
|
|
41
41
|
}
|
|
42
42
|
.currentWrapper[data-size=l]{
|
|
43
43
|
padding-top:var(--space-drop-list-item-l-container-vertical-padding, 12px);
|
|
@@ -45,5 +45,9 @@
|
|
|
45
45
|
padding-left:var(--space-drop-list-item-l-container-horizontal-padding, 12px);
|
|
46
46
|
padding-right:var(--space-drop-list-item-l-container-horizontal-padding, 12px);
|
|
47
47
|
gap:var(--space-drop-list-item-l-container-gap, 8px);
|
|
48
|
-
gap:var(--
|
|
48
|
+
gap:var(--dimension-050m, 4px);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.currentButton[data-hidden=true]{
|
|
52
|
+
visibility:hidden;
|
|
49
53
|
}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -38,6 +38,12 @@ export type TimeValue = {
|
|
|
38
38
|
minutes?: number;
|
|
39
39
|
seconds?: number;
|
|
40
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Режим футера time-picker:
|
|
43
|
+
* - `current-time-and-apply` — кнопка выбора текущего времени и компактная «Применить»;
|
|
44
|
+
* - `apply-only` — одна широкая «Применить» с подписью.
|
|
45
|
+
*/
|
|
46
|
+
export type TimePickerFooterMode = 'current-time-and-apply' | 'apply-only';
|
|
41
47
|
export type DateAndTime = TimeValue & {
|
|
42
48
|
year?: number;
|
|
43
49
|
month?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
-
import { FocusDirection, Size, TimeValue } from '../../types';
|
|
3
|
+
import { FocusDirection, Size, TimePickerFooterMode, TimeValue } from '../../types';
|
|
4
4
|
export type TimePickerProps = WithSupportProps<{
|
|
5
5
|
/** Выбранное значение.*/
|
|
6
6
|
value?: TimeValue;
|
|
@@ -12,6 +12,11 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
12
12
|
onChangeValue?(value?: TimeValue): void;
|
|
13
13
|
/** Показывать ли секунды */
|
|
14
14
|
showSeconds?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Режим футера: выбор текущего времени (кнопка «Текущее») и компактная «Применить», либо одна широкая «Применить» с подписью.
|
|
17
|
+
* @default current-time-and-apply
|
|
18
|
+
*/
|
|
19
|
+
footerMode?: TimePickerFooterMode;
|
|
15
20
|
/**
|
|
16
21
|
* Размер
|
|
17
22
|
* @default m
|
|
@@ -31,4 +36,4 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
31
36
|
focus(): void;
|
|
32
37
|
}>;
|
|
33
38
|
}>;
|
|
34
|
-
export declare function TimePicker({ className, size, fitToContainer, value: valueProp, defaultValue, onChangeValue, onFocusLeave, 'data-test-id': testId, navigationStartRef, showSeconds, today: todayProp, }: TimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function TimePicker({ className, size, fitToContainer, value: valueProp, defaultValue, onChangeValue, onFocusLeave, 'data-test-id': testId, navigationStartRef, showSeconds, today: todayProp, footerMode, }: TimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,7 +13,7 @@ import { getLocale, getTestIdBuilder } from '../../utils';
|
|
|
13
13
|
import styles from './styles.module.css';
|
|
14
14
|
const stubDate = new Date();
|
|
15
15
|
const stubFunc = () => { };
|
|
16
|
-
export function TimePicker({ className, size = SIZE.M, fitToContainer = true, value: valueProp, defaultValue, onChangeValue, onFocusLeave, 'data-test-id': testId, navigationStartRef, showSeconds = true, today: todayProp, }) {
|
|
16
|
+
export function TimePicker({ className, size = SIZE.M, fitToContainer = true, value: valueProp, defaultValue, onChangeValue, onFocusLeave, 'data-test-id': testId, navigationStartRef, showSeconds = true, today: todayProp, footerMode = 'current-time-and-apply', }) {
|
|
17
17
|
const [value, setValueState] = useUncontrolledProp(valueProp, defaultValue, onChangeValue);
|
|
18
18
|
const setValueEventHandler = useEventHandler(setValueState);
|
|
19
19
|
const [internalValue, setInternalValue] = useState();
|
|
@@ -55,6 +55,7 @@ export function TimePicker({ className, size = SIZE.M, fitToContainer = true, va
|
|
|
55
55
|
onFocusLeave,
|
|
56
56
|
navigationStartRef,
|
|
57
57
|
showSeconds,
|
|
58
|
+
footerMode,
|
|
58
59
|
dateAndTime,
|
|
59
60
|
onTimeChange,
|
|
60
61
|
onDateAndTimeChange,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MutableRefObject, RefObject } from 'react';
|
|
2
2
|
import { ListProps } from '@snack-uikit/list';
|
|
3
|
-
import { BuildCellPropsFunction, CalendarMode, DateAndTime, FocusDirection, Range, Size, TimeValue, ViewMode } from '../../types';
|
|
3
|
+
import { BuildCellPropsFunction, CalendarMode, DateAndTime, FocusDirection, Range, Size, TimePickerFooterMode, TimeValue, ViewMode } from '../../types';
|
|
4
4
|
export type CalendarContextType = {
|
|
5
5
|
size: Size;
|
|
6
6
|
/** Дата текущего дня */
|
|
@@ -21,6 +21,8 @@ export type CalendarContextType = {
|
|
|
21
21
|
viewShift: number;
|
|
22
22
|
focus?: string;
|
|
23
23
|
locale: Intl.Locale;
|
|
24
|
+
/** Режим футера time-picker */
|
|
25
|
+
footerMode?: TimePickerFooterMode;
|
|
24
26
|
onFocusLeave?(direction: FocusDirection): void;
|
|
25
27
|
buildCellProps?: BuildCellPropsFunction;
|
|
26
28
|
setFocus(address: string | undefined): void;
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { ButtonFilled, ButtonFunction } from '@snack-uikit/button';
|
|
4
4
|
import { Divider } from '@snack-uikit/divider';
|
|
5
|
-
import { CheckSVG } from '@snack-uikit/icons';
|
|
6
5
|
import { getDefaultItemId } from '@snack-uikit/list';
|
|
7
6
|
import { useLocale } from '@snack-uikit/locale';
|
|
8
7
|
import { CALENDAR_MODE } from '../../constants';
|
|
@@ -10,7 +9,8 @@ import { getMonthShift } from '../../utils';
|
|
|
10
9
|
import { CalendarContext } from '../CalendarContext';
|
|
11
10
|
import styles from './styles.module.css';
|
|
12
11
|
export function Footer() {
|
|
13
|
-
const { size, viewMode, mode, today, setValue, dateAndTime, isTimeFilled, isDateAndTimeFilled, onDateAndTimeChange, applyButtonRef, currentButtonRef, hoursKeyboardNavigationRef, minutesKeyboardNavigationRef, secondsKeyboardNavigationRef, showSeconds, getTestId, referenceDate, setViewShift, onFocusLeave, } = useContext(CalendarContext);
|
|
12
|
+
const { size, viewMode, mode, today, setValue, dateAndTime, isTimeFilled, isDateAndTimeFilled, onDateAndTimeChange, applyButtonRef, currentButtonRef, hoursKeyboardNavigationRef, minutesKeyboardNavigationRef, secondsKeyboardNavigationRef, showSeconds, getTestId, referenceDate, setViewShift, onFocusLeave, footerMode = 'current-time-and-apply', } = useContext(CalendarContext);
|
|
13
|
+
const isApplyOnlyFooter = footerMode === 'apply-only';
|
|
14
14
|
const { t } = useLocale('Calendar');
|
|
15
15
|
if (![CALENDAR_MODE.DateTime, 'time'].includes(mode) || viewMode !== 'month') {
|
|
16
16
|
return null;
|
|
@@ -59,5 +59,5 @@ export function Footer() {
|
|
|
59
59
|
const newDate = new Date(year, month, day, hours, minutes, showSeconds ? seconds : 0);
|
|
60
60
|
setValue([newDate, newDate]);
|
|
61
61
|
};
|
|
62
|
-
return (_jsxs("div", { className: styles.footer, "data-size": size, children: [_jsx(Divider, { className: styles.divider }), _jsxs("div", { className: styles.currentWrapper, "data-size": size, children: [_jsx(ButtonFunction, { label: t('current'), size: size === 's' ? 'xs' : 's', onClick: handleCurrentClick, ref: currentButtonRef, onKeyDown: handleCurrentKeyDown, "data-test-id": getTestId('current-button') }), _jsx(ButtonFilled, {
|
|
62
|
+
return (_jsxs("div", { className: styles.footer, "data-size": size, children: [_jsx(Divider, { className: styles.divider }), _jsxs("div", { className: styles.currentWrapper, "data-size": size, children: [_jsx(ButtonFunction, { className: styles.currentButton, "data-hidden": isApplyOnlyFooter, label: t('current'), size: size === 's' ? 'xs' : 's', onClick: handleCurrentClick, ref: currentButtonRef, onKeyDown: handleCurrentKeyDown, "data-test-id": getTestId('current-button') }), _jsx(ButtonFilled, { label: t('apply'), size: size === 's' ? 'xs' : 's', disabled: isApplyButtonDisabled, onClick: handleApplySelection, ref: applyButtonRef, onKeyDown: handleApplyKeyDown, "data-test-id": getTestId('apply-button') })] })] }));
|
|
63
63
|
}
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
padding-left:var(--space-drop-list-item-s-container-horizontal-padding, 8px);
|
|
30
30
|
padding-right:var(--space-drop-list-item-s-container-horizontal-padding, 8px);
|
|
31
31
|
gap:var(--space-drop-list-item-s-container-gap, 8px);
|
|
32
|
-
gap:var(--
|
|
32
|
+
gap:var(--dimension-theme-general-4px, 4px);
|
|
33
33
|
}
|
|
34
34
|
.currentWrapper[data-size=m]{
|
|
35
35
|
padding-top:var(--space-drop-list-item-m-container-vertical-padding, 8px);
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
padding-left:var(--space-drop-list-item-m-container-horizontal-padding, 10px);
|
|
38
38
|
padding-right:var(--space-drop-list-item-m-container-horizontal-padding, 10px);
|
|
39
39
|
gap:var(--space-drop-list-item-m-container-gap, 8px);
|
|
40
|
-
gap:var(--
|
|
40
|
+
gap:var(--dimension-050m, 4px);
|
|
41
41
|
}
|
|
42
42
|
.currentWrapper[data-size=l]{
|
|
43
43
|
padding-top:var(--space-drop-list-item-l-container-vertical-padding, 12px);
|
|
@@ -45,5 +45,9 @@
|
|
|
45
45
|
padding-left:var(--space-drop-list-item-l-container-horizontal-padding, 12px);
|
|
46
46
|
padding-right:var(--space-drop-list-item-l-container-horizontal-padding, 12px);
|
|
47
47
|
gap:var(--space-drop-list-item-l-container-gap, 8px);
|
|
48
|
-
gap:var(--
|
|
48
|
+
gap:var(--dimension-050m, 4px);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.currentButton[data-hidden=true]{
|
|
52
|
+
visibility:hidden;
|
|
49
53
|
}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -38,6 +38,12 @@ export type TimeValue = {
|
|
|
38
38
|
minutes?: number;
|
|
39
39
|
seconds?: number;
|
|
40
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Режим футера time-picker:
|
|
43
|
+
* - `current-time-and-apply` — кнопка выбора текущего времени и компактная «Применить»;
|
|
44
|
+
* - `apply-only` — одна широкая «Применить» с подписью.
|
|
45
|
+
*/
|
|
46
|
+
export type TimePickerFooterMode = 'current-time-and-apply' | 'apply-only';
|
|
41
47
|
export type DateAndTime = TimeValue & {
|
|
42
48
|
year?: number;
|
|
43
49
|
month?: number;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Calendar",
|
|
7
|
-
"version": "0.13.
|
|
7
|
+
"version": "0.13.20-preview-ff470bb3.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@snack-uikit/locale": "*"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "9cb3640f627845ea5054cf3a16998c30419f1691"
|
|
52
52
|
}
|
|
@@ -11,7 +11,7 @@ import { CalendarContext } from '../../helperComponents/CalendarContext';
|
|
|
11
11
|
import { Footer } from '../../helperComponents/Footer';
|
|
12
12
|
import { TimePickerBase } from '../../helperComponents/TimePickerBase';
|
|
13
13
|
import { useDateAndTime } from '../../hooks';
|
|
14
|
-
import { FocusDirection, Range, Size, TimeValue } from '../../types';
|
|
14
|
+
import { FocusDirection, Range, Size, TimePickerFooterMode, TimeValue } from '../../types';
|
|
15
15
|
import { getLocale, getTestIdBuilder } from '../../utils';
|
|
16
16
|
import styles from './styles.module.scss';
|
|
17
17
|
|
|
@@ -29,6 +29,11 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
29
29
|
onChangeValue?(value?: TimeValue): void;
|
|
30
30
|
/** Показывать ли секунды */
|
|
31
31
|
showSeconds?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Режим футера: выбор текущего времени (кнопка «Текущее») и компактная «Применить», либо одна широкая «Применить» с подписью.
|
|
34
|
+
* @default current-time-and-apply
|
|
35
|
+
*/
|
|
36
|
+
footerMode?: TimePickerFooterMode;
|
|
32
37
|
|
|
33
38
|
/**
|
|
34
39
|
* Размер
|
|
@@ -61,6 +66,7 @@ export function TimePicker({
|
|
|
61
66
|
navigationStartRef,
|
|
62
67
|
showSeconds = true,
|
|
63
68
|
today: todayProp,
|
|
69
|
+
footerMode = 'current-time-and-apply',
|
|
64
70
|
}: TimePickerProps) {
|
|
65
71
|
const [value, setValueState] = useUncontrolledProp<TimeValue | undefined>(valueProp, defaultValue, onChangeValue);
|
|
66
72
|
const setValueEventHandler = useEventHandler(setValueState);
|
|
@@ -127,6 +133,7 @@ export function TimePicker({
|
|
|
127
133
|
onFocusLeave,
|
|
128
134
|
navigationStartRef,
|
|
129
135
|
showSeconds,
|
|
136
|
+
footerMode,
|
|
130
137
|
dateAndTime,
|
|
131
138
|
onTimeChange,
|
|
132
139
|
onDateAndTimeChange,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
FocusDirection,
|
|
11
11
|
Range,
|
|
12
12
|
Size,
|
|
13
|
+
TimePickerFooterMode,
|
|
13
14
|
TimeValue,
|
|
14
15
|
ViewMode,
|
|
15
16
|
} from '../../types';
|
|
@@ -35,6 +36,8 @@ export type CalendarContextType = {
|
|
|
35
36
|
viewShift: number;
|
|
36
37
|
focus?: string;
|
|
37
38
|
locale: Intl.Locale;
|
|
39
|
+
/** Режим футера time-picker */
|
|
40
|
+
footerMode?: TimePickerFooterMode;
|
|
38
41
|
onFocusLeave?(direction: FocusDirection): void;
|
|
39
42
|
buildCellProps?: BuildCellPropsFunction;
|
|
40
43
|
setFocus(address: string | undefined): void;
|
|
@@ -2,7 +2,6 @@ import { KeyboardEventHandler, useContext } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { ButtonFilled, ButtonFunction } from '@snack-uikit/button';
|
|
4
4
|
import { Divider } from '@snack-uikit/divider';
|
|
5
|
-
import { CheckSVG } from '@snack-uikit/icons';
|
|
6
5
|
import { getDefaultItemId } from '@snack-uikit/list';
|
|
7
6
|
import { useLocale } from '@snack-uikit/locale';
|
|
8
7
|
|
|
@@ -32,8 +31,11 @@ export function Footer() {
|
|
|
32
31
|
referenceDate,
|
|
33
32
|
setViewShift,
|
|
34
33
|
onFocusLeave,
|
|
34
|
+
footerMode = 'current-time-and-apply',
|
|
35
35
|
} = useContext(CalendarContext);
|
|
36
36
|
|
|
37
|
+
const isApplyOnlyFooter = footerMode === 'apply-only';
|
|
38
|
+
|
|
37
39
|
const { t } = useLocale('Calendar');
|
|
38
40
|
|
|
39
41
|
if (![CALENDAR_MODE.DateTime, 'time'].includes(mode) || viewMode !== 'month') {
|
|
@@ -106,6 +108,8 @@ export function Footer() {
|
|
|
106
108
|
|
|
107
109
|
<div className={styles.currentWrapper} data-size={size}>
|
|
108
110
|
<ButtonFunction
|
|
111
|
+
className={styles.currentButton}
|
|
112
|
+
data-hidden={isApplyOnlyFooter}
|
|
109
113
|
label={t('current')}
|
|
110
114
|
size={size === 's' ? 'xs' : 's'}
|
|
111
115
|
onClick={handleCurrentClick}
|
|
@@ -115,7 +119,7 @@ export function Footer() {
|
|
|
115
119
|
/>
|
|
116
120
|
|
|
117
121
|
<ButtonFilled
|
|
118
|
-
|
|
122
|
+
label={t('apply')}
|
|
119
123
|
size={size === 's' ? 'xs' : 's'}
|
|
120
124
|
disabled={isApplyButtonDisabled}
|
|
121
125
|
onClick={handleApplySelection}
|
package/src/types.ts
CHANGED
|
@@ -46,6 +46,13 @@ export type TimeValue = {
|
|
|
46
46
|
seconds?: number;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Режим футера time-picker:
|
|
51
|
+
* - `current-time-and-apply` — кнопка выбора текущего времени и компактная «Применить»;
|
|
52
|
+
* - `apply-only` — одна широкая «Применить» с подписью.
|
|
53
|
+
*/
|
|
54
|
+
export type TimePickerFooterMode = 'current-time-and-apply' | 'apply-only';
|
|
55
|
+
|
|
49
56
|
export type DateAndTime = TimeValue & {
|
|
50
57
|
year?: number;
|
|
51
58
|
month?: number;
|