@snack-uikit/calendar 0.13.15 → 0.13.16-preview-0aba136f.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 +3 -1
- package/dist/cjs/components/TimePicker/TimePicker.js +3 -1
- package/dist/cjs/helperComponents/CalendarContext/CalendarContext.d.ts +2 -0
- package/dist/cjs/helperComponents/Footer/Footer.js +5 -2
- package/dist/esm/components/TimePicker/TimePicker.d.ts +3 -1
- package/dist/esm/components/TimePicker/TimePicker.js +2 -1
- package/dist/esm/helperComponents/CalendarContext/CalendarContext.d.ts +2 -0
- package/dist/esm/helperComponents/Footer/Footer.js +2 -2
- package/package.json +3 -3
- package/src/components/TimePicker/TimePicker.tsx +4 -0
- package/src/helperComponents/CalendarContext/CalendarContext.tsx +2 -0
- package/src/helperComponents/Footer/Footer.tsx +13 -8
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
|
+
| showCurrentButton | `boolean` | - | Показывать ли кнопку выбора текущего времени |
|
|
131
132
|
| size | enum Size: `"s"`, `"m"`, `"l"` | m | Размер |
|
|
132
133
|
| className | `string` | - | CSS-класс контейнера |
|
|
133
134
|
| fitToContainer | `boolean` | true | Отключает предустановленный размер, заставляя компонент подстраиваться к размеру контейнра: (width: 100%, height: 100%). |
|
|
@@ -12,6 +12,8 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
12
12
|
onChangeValue?(value?: TimeValue): void;
|
|
13
13
|
/** Показывать ли секунды */
|
|
14
14
|
showSeconds?: boolean;
|
|
15
|
+
/** Показывать ли кнопку выбора текущего времени */
|
|
16
|
+
showCurrentButton?: boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Размер
|
|
17
19
|
* @default m
|
|
@@ -31,4 +33,4 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
31
33
|
focus(): void;
|
|
32
34
|
}>;
|
|
33
35
|
}>;
|
|
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;
|
|
36
|
+
export declare function TimePicker({ className, size, fitToContainer, value: valueProp, defaultValue, onChangeValue, onFocusLeave, 'data-test-id': testId, navigationStartRef, showSeconds, today: todayProp, showCurrentButton, }: 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
|
+
showCurrentButton
|
|
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
|
+
showCurrentButton,
|
|
113
115
|
dateAndTime,
|
|
114
116
|
onTimeChange,
|
|
115
117
|
onDateAndTimeChange,
|
|
@@ -21,6 +21,8 @@ export type CalendarContextType = {
|
|
|
21
21
|
viewShift: number;
|
|
22
22
|
focus?: string;
|
|
23
23
|
locale: Intl.Locale;
|
|
24
|
+
/** Показывать ли кнопку выбора текущего времени в футере */
|
|
25
|
+
showCurrentButton?: boolean;
|
|
24
26
|
onFocusLeave?(direction: FocusDirection): void;
|
|
25
27
|
buildCellProps?: BuildCellPropsFunction;
|
|
26
28
|
setFocus(address: string | undefined): void;
|
|
@@ -40,7 +40,8 @@ function Footer() {
|
|
|
40
40
|
getTestId,
|
|
41
41
|
referenceDate,
|
|
42
42
|
setViewShift,
|
|
43
|
-
onFocusLeave
|
|
43
|
+
onFocusLeave,
|
|
44
|
+
showCurrentButton = true
|
|
44
45
|
} = (0, react_1.useContext)(CalendarContext_1.CalendarContext);
|
|
45
46
|
const {
|
|
46
47
|
t
|
|
@@ -105,7 +106,7 @@ function Footer() {
|
|
|
105
106
|
}), (0, jsx_runtime_1.jsxs)("div", {
|
|
106
107
|
className: styles_module_scss_1.default.currentWrapper,
|
|
107
108
|
"data-size": size,
|
|
108
|
-
children: [(0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
|
|
109
|
+
children: [showCurrentButton && (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
|
|
109
110
|
label: t('current'),
|
|
110
111
|
size: size === 's' ? 'xs' : 's',
|
|
111
112
|
onClick: handleCurrentClick,
|
|
@@ -113,6 +114,8 @@ function Footer() {
|
|
|
113
114
|
onKeyDown: handleCurrentKeyDown,
|
|
114
115
|
"data-test-id": getTestId('current-button')
|
|
115
116
|
}), (0, jsx_runtime_1.jsx)(button_1.ButtonFilled, {
|
|
117
|
+
label: !showCurrentButton ? t('apply') : undefined,
|
|
118
|
+
fullWidth: !showCurrentButton,
|
|
116
119
|
icon: (0, jsx_runtime_1.jsx)(icons_1.CheckSVG, {}),
|
|
117
120
|
size: size === 's' ? 'xs' : 's',
|
|
118
121
|
disabled: isApplyButtonDisabled,
|
|
@@ -12,6 +12,8 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
12
12
|
onChangeValue?(value?: TimeValue): void;
|
|
13
13
|
/** Показывать ли секунды */
|
|
14
14
|
showSeconds?: boolean;
|
|
15
|
+
/** Показывать ли кнопку выбора текущего времени */
|
|
16
|
+
showCurrentButton?: boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Размер
|
|
17
19
|
* @default m
|
|
@@ -31,4 +33,4 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
31
33
|
focus(): void;
|
|
32
34
|
}>;
|
|
33
35
|
}>;
|
|
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;
|
|
36
|
+
export declare function TimePicker({ className, size, fitToContainer, value: valueProp, defaultValue, onChangeValue, onFocusLeave, 'data-test-id': testId, navigationStartRef, showSeconds, today: todayProp, showCurrentButton, }: 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, showCurrentButton, }) {
|
|
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
|
+
showCurrentButton,
|
|
58
59
|
dateAndTime,
|
|
59
60
|
onTimeChange,
|
|
60
61
|
onDateAndTimeChange,
|
|
@@ -21,6 +21,8 @@ export type CalendarContextType = {
|
|
|
21
21
|
viewShift: number;
|
|
22
22
|
focus?: string;
|
|
23
23
|
locale: Intl.Locale;
|
|
24
|
+
/** Показывать ли кнопку выбора текущего времени в футере */
|
|
25
|
+
showCurrentButton?: boolean;
|
|
24
26
|
onFocusLeave?(direction: FocusDirection): void;
|
|
25
27
|
buildCellProps?: BuildCellPropsFunction;
|
|
26
28
|
setFocus(address: string | undefined): void;
|
|
@@ -10,7 +10,7 @@ import { getMonthShift } from '../../utils';
|
|
|
10
10
|
import { CalendarContext } from '../CalendarContext';
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
12
|
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);
|
|
13
|
+
const { size, viewMode, mode, today, setValue, dateAndTime, isTimeFilled, isDateAndTimeFilled, onDateAndTimeChange, applyButtonRef, currentButtonRef, hoursKeyboardNavigationRef, minutesKeyboardNavigationRef, secondsKeyboardNavigationRef, showSeconds, getTestId, referenceDate, setViewShift, onFocusLeave, showCurrentButton = true, } = useContext(CalendarContext);
|
|
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, { icon: _jsx(CheckSVG, {}), size: size === 's' ? 'xs' : 's', disabled: isApplyButtonDisabled, onClick: handleApplySelection, ref: applyButtonRef, onKeyDown: handleApplyKeyDown, "data-test-id": getTestId('apply-button') })] })] }));
|
|
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: [showCurrentButton && (_jsx(ButtonFunction, { label: t('current'), size: size === 's' ? 'xs' : 's', onClick: handleCurrentClick, ref: currentButtonRef, onKeyDown: handleCurrentKeyDown, "data-test-id": getTestId('current-button') })), _jsx(ButtonFilled, { label: !showCurrentButton ? t('apply') : undefined, fullWidth: !showCurrentButton, icon: _jsx(CheckSVG, {}), size: size === 's' ? 'xs' : 's', disabled: isApplyButtonDisabled, onClick: handleApplySelection, ref: applyButtonRef, onKeyDown: handleApplyKeyDown, "data-test-id": getTestId('apply-button') })] })] }));
|
|
63
63
|
}
|
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.16-preview-0aba136f.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@snack-uikit/button": "0.19.17",
|
|
40
40
|
"@snack-uikit/divider": "3.2.11",
|
|
41
41
|
"@snack-uikit/icons": "0.27.7",
|
|
42
|
-
"@snack-uikit/list": "0.32.
|
|
42
|
+
"@snack-uikit/list": "0.32.15-preview-0aba136f.0",
|
|
43
43
|
"@snack-uikit/utils": "4.0.1",
|
|
44
44
|
"classnames": "2.5.1",
|
|
45
45
|
"uncontrollable": "8.0.4",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@snack-uikit/locale": "*"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "a2db41da4366417b6ff322f3a1ba73da8ba96222"
|
|
52
52
|
}
|
|
@@ -29,6 +29,8 @@ export type TimePickerProps = WithSupportProps<{
|
|
|
29
29
|
onChangeValue?(value?: TimeValue): void;
|
|
30
30
|
/** Показывать ли секунды */
|
|
31
31
|
showSeconds?: boolean;
|
|
32
|
+
/** Показывать ли кнопку выбора текущего времени */
|
|
33
|
+
showCurrentButton?: boolean;
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Размер
|
|
@@ -61,6 +63,7 @@ export function TimePicker({
|
|
|
61
63
|
navigationStartRef,
|
|
62
64
|
showSeconds = true,
|
|
63
65
|
today: todayProp,
|
|
66
|
+
showCurrentButton,
|
|
64
67
|
}: TimePickerProps) {
|
|
65
68
|
const [value, setValueState] = useUncontrolledProp<TimeValue | undefined>(valueProp, defaultValue, onChangeValue);
|
|
66
69
|
const setValueEventHandler = useEventHandler(setValueState);
|
|
@@ -127,6 +130,7 @@ export function TimePicker({
|
|
|
127
130
|
onFocusLeave,
|
|
128
131
|
navigationStartRef,
|
|
129
132
|
showSeconds,
|
|
133
|
+
showCurrentButton,
|
|
130
134
|
dateAndTime,
|
|
131
135
|
onTimeChange,
|
|
132
136
|
onDateAndTimeChange,
|
|
@@ -35,6 +35,8 @@ export type CalendarContextType = {
|
|
|
35
35
|
viewShift: number;
|
|
36
36
|
focus?: string;
|
|
37
37
|
locale: Intl.Locale;
|
|
38
|
+
/** Показывать ли кнопку выбора текущего времени в футере */
|
|
39
|
+
showCurrentButton?: boolean;
|
|
38
40
|
onFocusLeave?(direction: FocusDirection): void;
|
|
39
41
|
buildCellProps?: BuildCellPropsFunction;
|
|
40
42
|
setFocus(address: string | undefined): void;
|
|
@@ -32,6 +32,7 @@ export function Footer() {
|
|
|
32
32
|
referenceDate,
|
|
33
33
|
setViewShift,
|
|
34
34
|
onFocusLeave,
|
|
35
|
+
showCurrentButton = true,
|
|
35
36
|
} = useContext(CalendarContext);
|
|
36
37
|
|
|
37
38
|
const { t } = useLocale('Calendar');
|
|
@@ -105,16 +106,20 @@ export function Footer() {
|
|
|
105
106
|
<Divider className={styles.divider} />
|
|
106
107
|
|
|
107
108
|
<div className={styles.currentWrapper} data-size={size}>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
{showCurrentButton && (
|
|
110
|
+
<ButtonFunction
|
|
111
|
+
label={t('current')}
|
|
112
|
+
size={size === 's' ? 'xs' : 's'}
|
|
113
|
+
onClick={handleCurrentClick}
|
|
114
|
+
ref={currentButtonRef}
|
|
115
|
+
onKeyDown={handleCurrentKeyDown}
|
|
116
|
+
data-test-id={getTestId('current-button')}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
116
119
|
|
|
117
120
|
<ButtonFilled
|
|
121
|
+
label={!showCurrentButton ? t('apply') : undefined}
|
|
122
|
+
fullWidth={!showCurrentButton}
|
|
118
123
|
icon={<CheckSVG />}
|
|
119
124
|
size={size === 's' ? 'xs' : 's'}
|
|
120
125
|
disabled={isApplyButtonDisabled}
|