diff --git a/packages/vkui/src/components/Calendar/Calendar.e2e-playground.tsx b/packages/vkui/src/components/Calendar/Calendar.e2e-playground.tsx index be08e6493f..0b657d6c15 100644 --- a/packages/vkui/src/components/Calendar/Calendar.e2e-playground.tsx +++ b/packages/vkui/src/components/Calendar/Calendar.e2e-playground.tsx @@ -63,6 +63,10 @@ export const CalendarPlayground = (props: ComponentPlaygroundProps) => { minDateTime: [new Date('1970-05-03')], maxDateTime: [new Date('1970-05-10')], }, + { + value: [new Date('1970-05-05')], + dir: ['rtl'], + }, ]} > {(props: CalendarProps) => } diff --git a/packages/vkui/src/components/Calendar/Calendar.tsx b/packages/vkui/src/components/Calendar/Calendar.tsx index 84088748de..e09ee0a62d 100644 --- a/packages/vkui/src/components/Calendar/Calendar.tsx +++ b/packages/vkui/src/components/Calendar/Calendar.tsx @@ -3,7 +3,13 @@ import * as React from 'react'; import { classNames } from '@vkontakte/vkjs'; import { isSameDay, isSameMonth } from 'date-fns'; +import { + CalendarDirectionContext, + type CalendarDirectionContextProps, +} from '../../context/CalendarDirectionContext'; import { useCalendar } from '../../hooks/useCalendar'; +import { useDirection } from '../../hooks/useDirection'; +import { useExternRef } from '../../hooks/useExternRef'; import { clamp, isFirstDay, isLastDay, navigateDate, setTimeEqual } from '../../lib/calendar'; import { useIsomorphicLayoutEffect } from '../../lib/useIsomorphicLayoutEffect'; import { warnOnce } from '../../lib/warnOnce'; @@ -99,6 +105,7 @@ const warn = warnOnce('Calendar'); * @see https://vkcom.github.io/VKUI/#/Calendar */ export const Calendar = ({ + getRootRef, value, onChange, disablePast, @@ -167,6 +174,8 @@ export const Calendar = ({ minDateTime, maxDateTime, }); + const [directionRef, textDirection = 'ltr'] = useDirection(); + const rootRef = useExternRef(directionRef, getRootRef); useIsomorphicLayoutEffect(() => { if (value) { @@ -214,70 +223,83 @@ export const Calendar = ({ [value], ); + const directionContextValue = React.useMemo( + () => ({ + direction: textDirection, + }), + [textDirection], + ); + return ( - - - - {enableTime && value && size !== 's' && ( -
- -
- )} -
+ + + + + {enableTime && value && size !== 's' && ( +
+ +
+ )} +
+
); }; diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-android-chromium-dark-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-android-chromium-dark-1-snap.png index b2385d2897..31b48eedf7 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-android-chromium-dark-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-android-chromium-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ceebf8e26bef928e7bd3e5f41c9b7eb857c623c6ecf4348563f3b1949bc61e26 -size 329359 +oid sha256:e5d755c29141a0185abc5927e7b82b555ca4fc94b25f60d618f1b38ad18bfe7c +size 343577 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-android-chromium-light-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-android-chromium-light-1-snap.png index 1d50cf1f72..fb47a14306 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-android-chromium-light-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-android-chromium-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5e7325b60ef8e9a8945a3509ee77e5825981d4501d9e6b53e38ee6ecd0d7de2 -size 298500 +oid sha256:a844fd47b0d8e419babc7833ec2ccc39354dd8e4adce51fcd0baae8e3f683936 +size 311553 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-ios-webkit-dark-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-ios-webkit-dark-1-snap.png index 787373c018..af26f6f5ac 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-ios-webkit-dark-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-ios-webkit-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed13fbd1a96f92fabe46238bb7e359d8b6fc5ac5861bbd30d2ac29dc388013f2 -size 460644 +oid sha256:e28799de14b6726a2e92a7bfac4049f65d4947e9e4e7246e523524b33b518a5f +size 480141 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-ios-webkit-light-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-ios-webkit-light-1-snap.png index 18b841c36c..a4f18f6fe9 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-ios-webkit-light-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-ios-webkit-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd64e778286ee7aba8105774aadf11221579dada4dd3443c29c0e4c91967b271 -size 458664 +oid sha256:d123bfe4ca32327d060b6c1ef30a43c7e2dddf6999f04f073e867c70dee2a5be +size 477809 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-chromium-dark-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-chromium-dark-1-snap.png index 9d8554fa0e..9e1add3af7 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-chromium-dark-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-chromium-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e948a4960c7e6f98e783ec3afacc12b0ba6b120a16c74d261c9a9992a6899948 -size 340740 +oid sha256:70c5fdb086fbeb8b58cec8e02e680795ab5e6b4d0079d00ebc181b0ee5811081 +size 355712 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-chromium-light-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-chromium-light-1-snap.png index e6e7f471ba..27bb31f66f 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-chromium-light-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-chromium-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06da3733af32e67b02977907c04ac32e196cebee7896aa15d56f0f878a112b18 -size 312687 +oid sha256:2ad29cb5d7e5b50faa56d1f1c9361af435fad2073c57d68299717d408660a0d9 +size 326581 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-firefox-dark-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-firefox-dark-1-snap.png index 27f92cff0a..2539c1cc83 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-firefox-dark-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-firefox-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d5d14c68f319f676ad481c4bb1396121de506d1ce8a9b10a861a5604540f7bc -size 564905 +oid sha256:42c7107f595cc67a84154a3465c98366cdf04c5ce50e0f8a60702bcc09109f89 +size 590137 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-firefox-light-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-firefox-light-1-snap.png index 2bc60a8474..1d734fb445 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-firefox-light-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-firefox-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:34d31d7f143eb57de538e8b054a7ed190145889e5074914220c325ac9df3f941 -size 557212 +oid sha256:4fa70ac52d822dafc1d472b86e541e67deb26f3e8289c7b84c13d42edd79b5fa +size 582039 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-webkit-dark-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-webkit-dark-1-snap.png index c690db9de5..ed5acb177e 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-webkit-dark-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-webkit-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90b07361828a53a9cc6a8a3a40391fd3dfaa320d1c78036df03ab2943da6a57c -size 471416 +oid sha256:4a8c1d6eb19dfa11f5cf570b2b749297fb9ef020372b7a37c668bebcd415e380 +size 491641 diff --git a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-webkit-light-1-snap.png b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-webkit-light-1-snap.png index e6f2e18cab..efc0a8fb08 100644 --- a/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-webkit-light-1-snap.png +++ b/packages/vkui/src/components/Calendar/__image_snapshots__/calendar-vkcom-webkit-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:596f1fa5b92159f0d08eb4e3401641c9906151c04ecf7e62f8e9cc09bbdb698d -size 475651 +oid sha256:1c25e08947054d262a6afcd4c0d94e2fd97117901f5ffa20c68f25b2107e6f3b +size 495900 diff --git a/packages/vkui/src/components/CalendarDay/CalendarDay.module.css b/packages/vkui/src/components/CalendarDay/CalendarDay.module.css index 2064065069..5298837a57 100644 --- a/packages/vkui/src/components/CalendarDay/CalendarDay.module.css +++ b/packages/vkui/src/components/CalendarDay/CalendarDay.module.css @@ -61,6 +61,10 @@ transform: translateX(-50%); } +.rtl .today .dayNumber::after { + transform: translateX(50%); +} + .today .innerActive .dayNumber::after { border-block-end-color: var(--vkui--color_stroke_contrast); } diff --git a/packages/vkui/src/components/CalendarDay/CalendarDay.tsx b/packages/vkui/src/components/CalendarDay/CalendarDay.tsx index 7b27bcdf45..09a43050a7 100644 --- a/packages/vkui/src/components/CalendarDay/CalendarDay.tsx +++ b/packages/vkui/src/components/CalendarDay/CalendarDay.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { classNames } from '@vkontakte/vkjs'; +import { useCalendarDirectionContext } from '../../context/CalendarDirectionContext'; import { ENABLE_KEYBOARD_INPUT_EVENT_NAME } from '../../hooks/useKeyboardInputTracker'; import { useConfigProvider } from '../ConfigProvider/ConfigProviderContext'; import { Tappable } from '../Tappable/Tappable'; @@ -68,6 +69,7 @@ export const CalendarDay: React.FC = React.memo( }: CalendarDayProps) => { const { locale } = useConfigProvider(); const ref = React.useRef(null); + const { direction } = useCalendarDirectionContext(); const onClick = React.useCallback(() => onChange(day), [day, onChange]); const handleEnter = React.useCallback(() => onEnter?.(day), [day, onEnter]); const handleLeave = React.useCallback(() => onLeave?.(day), [day, onLeave]); @@ -104,7 +106,11 @@ export const CalendarDay: React.FC = React.memo( return ( { const { locale } = useConfigProvider(); + const { direction } = useCalendarDirectionContext(); + const onMonthsChange = React.useCallback( (_: ChangeEvent, newValue: SelectProps['value']) => onChange(setMonth(viewDate, Number(newValue))), @@ -176,7 +179,7 @@ export const CalendarHeader = ({ {prevMonthLabel}, {formatter.format(subMonths(viewDate, 1))} - {prevMonthIcon} + {direction === 'ltr' ? prevMonthIcon : nextMonthIcon} )} @@ -242,7 +245,7 @@ export const CalendarHeader = ({ {nextMonthLabel}, {formatter.format(addMonths(viewDate, 1))} - {nextMonthIcon} + {direction === 'ltr' ? nextMonthIcon : prevMonthIcon} )} diff --git a/packages/vkui/src/components/CalendarRange/CalendarRange.e2e-playground.tsx b/packages/vkui/src/components/CalendarRange/CalendarRange.e2e-playground.tsx index e4b7c5c519..552d16e225 100644 --- a/packages/vkui/src/components/CalendarRange/CalendarRange.e2e-playground.tsx +++ b/packages/vkui/src/components/CalendarRange/CalendarRange.e2e-playground.tsx @@ -33,6 +33,10 @@ export const CalendarRangePlayground = (props: ComponentPlaygroundProps) => { , ], }, + { + value: [[new Date('1970-05-05'), new Date('1970-06-05')]], + dir: ['rtl'], + }, ]} > {(props: CalendarRangeProps) => } diff --git a/packages/vkui/src/components/CalendarRange/CalendarRange.tsx b/packages/vkui/src/components/CalendarRange/CalendarRange.tsx index dd0d3f7aa4..d22fcdf529 100644 --- a/packages/vkui/src/components/CalendarRange/CalendarRange.tsx +++ b/packages/vkui/src/components/CalendarRange/CalendarRange.tsx @@ -12,7 +12,13 @@ import { startOfDay, subMonths, } from 'date-fns'; +import { + CalendarDirectionContext, + type CalendarDirectionContextProps, +} from '../../context/CalendarDirectionContext'; import { useCalendar } from '../../hooks/useCalendar'; +import { useDirection } from '../../hooks/useDirection'; +import { useExternRef } from '../../hooks/useExternRef'; import { isFirstDay, isLastDay, navigateDate } from '../../lib/calendar'; import type { HTMLAttributesWithRootRef } from '../../types'; import { @@ -97,6 +103,7 @@ export const CalendarRange = ({ dayTestId, leftPartHeaderTestsData, rightPartHeaderTestsData, + getRootRef, ...props }: CalendarRangeProps): React.ReactNode => { const { @@ -112,6 +119,10 @@ export const CalendarRange = ({ isMonthDisabled, isYearDisabled, } = useCalendar({ value, disableFuture, disablePast, shouldDisableDate }); + + const [directionRef, textDirection = 'ltr'] = useDirection(); + const rootRef = useExternRef(directionRef, getRootRef); + const [hintedDate, setHintedDate] = React.useState(); const secondViewDate = addMonths(viewDate, 1); @@ -213,90 +224,99 @@ export const CalendarRange = ({ [setViewDate], ); + const directionContextValue = React.useMemo( + () => ({ + direction: textDirection, + }), + [textDirection], + ); + return ( - -
- - -
-
- - -
-
+ + +
+ + +
+
+ + +
+
+
); }; diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-android-chromium-dark-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-android-chromium-dark-1-snap.png index c69c51718f..feaba73c78 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-android-chromium-dark-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-android-chromium-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f13443dec96e5ccf52663de62552ade81f8f72e795ebdc323d84ef41adae823f -size 139189 +oid sha256:9871b56f2eaceac01345c4bc3150906813ad245a92e7bfbf0319c74dec264faa +size 154172 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-android-chromium-light-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-android-chromium-light-1-snap.png index dd78a66f1d..0affd4a654 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-android-chromium-light-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-android-chromium-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c08b7b011640d40822a04e695f179da76abb07dcf640cad99ea2e234c27ae02a -size 152727 +oid sha256:151710dfbfebf142a4d7e55b22a154d0969312434cf8f0f46bd2cc53b8106be0 +size 152942 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-ios-webkit-dark-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-ios-webkit-dark-1-snap.png index 3755a1b761..ad192ce47b 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-ios-webkit-dark-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-ios-webkit-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4be089b8def3a84b277b2d1699286f9be2f483d63569c21748bdbe874e0a999c -size 188840 +oid sha256:5afe4dcaaa93ec31d29df3a4cf07d71b715e0c5a9dc063487971890ede7e3582 +size 208470 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-ios-webkit-light-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-ios-webkit-light-1-snap.png index 2cd5712eaa..8da451efe6 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-ios-webkit-light-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-ios-webkit-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:589172c7df3576316257b44e66ca5b527ee328db401361477994629aa42a530f -size 189394 +oid sha256:00bde81ee3886219d1c9dc77e2de3a529b58c6b3262c980c5e3583fb92ee705d +size 208919 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-chromium-dark-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-chromium-dark-1-snap.png index d801cb9381..d8e63b52ad 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-chromium-dark-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-chromium-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e28f25da83e7e7eb83ed8a7c76256f69e9c4f2054959bd2f248c392f22323340 -size 197120 +oid sha256:823db0a4662bb120fd5807448e3b93cbb5e0b9612db81bbf5884bfe6fc137be0 +size 221111 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-chromium-light-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-chromium-light-1-snap.png index b01d2743aa..ce7cbc7f47 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-chromium-light-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-chromium-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4df26b0dc4af440b76cca907eb1c82b9a1f338ac2a649b65b6880be7cc889518 -size 185603 +oid sha256:dc127d8265407bee9a00479cca9044b180bb1729659fe2dd9004fef9885cb636 +size 207963 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-firefox-dark-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-firefox-dark-1-snap.png index 952f5ba93e..35df687ce8 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-firefox-dark-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-firefox-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d619cc6b1e937f5cf3b5d564d79169bcc57737286b5a4e5a6b1eb337d59f3612 -size 309404 +oid sha256:d1db5e97591c39f45a7a2db356d50049ac47c82f8b848f722611db3325ab44e6 +size 344768 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-firefox-light-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-firefox-light-1-snap.png index 3718e0bdb2..163f08b82b 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-firefox-light-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-firefox-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:71cda104f02491f2c491e6aabef49c42c0fe75d26c6b65fa223757d7d94276f8 -size 312072 +oid sha256:8ceade78c35ce6775c83d64fb28489c61696cecd0ae4f4c0993aa8ad56f7a744 +size 348318 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-webkit-dark-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-webkit-dark-1-snap.png index b30a8178ba..d1ff89d9b2 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-webkit-dark-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-webkit-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4dbdafd34c66c05cac65f682f571ae68ae39c969d96860250aaa6d7933df1250 -size 268829 +oid sha256:6f5047f63fdb976f5c6b6e3f4cc92da540f1f4c055befb878f6f6a4d7dc465f2 +size 300222 diff --git a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-webkit-light-1-snap.png b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-webkit-light-1-snap.png index 8e9ed87c16..367d00ec7a 100644 --- a/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-webkit-light-1-snap.png +++ b/packages/vkui/src/components/CalendarRange/__image_snapshots__/calendarrange-vkcom-webkit-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d40d7ec9f18aa6905f78df921d2ab9186be7a2893f9659914e338443b2e94bf2 -size 272269 +oid sha256:5351de44f4cab6b8d9fa605f0cdfd736c22656859f5f40a91808fc411e7c7a8e +size 303696 diff --git a/packages/vkui/src/context/CalendarDirectionContext.ts b/packages/vkui/src/context/CalendarDirectionContext.ts new file mode 100644 index 0000000000..6763b1675b --- /dev/null +++ b/packages/vkui/src/context/CalendarDirectionContext.ts @@ -0,0 +1,12 @@ +import { createContext, useContext } from 'react'; +import { type Direction } from '../hooks/useDirection'; + +export interface CalendarDirectionContextProps { + direction: Direction; +} + +export const CalendarDirectionContext = createContext({ + direction: 'ltr', +}); + +export const useCalendarDirectionContext = () => useContext(CalendarDirectionContext); diff --git a/packages/vkui/src/hooks/useDirection.ts b/packages/vkui/src/hooks/useDirection.ts index 80a0116fb0..9f6f448961 100644 --- a/packages/vkui/src/hooks/useDirection.ts +++ b/packages/vkui/src/hooks/useDirection.ts @@ -2,7 +2,7 @@ import * as React from 'react'; import { useDOM } from '../lib/dom'; import { useIsomorphicLayoutEffect } from '../lib/useIsomorphicLayoutEffect'; -type Direction = 'ltr' | 'rtl'; +export type Direction = 'ltr' | 'rtl'; type WritingMode = 'horizontal-tb' | 'vertical-rl' | 'vertical-lr'; /**