@hh.ru/magritte-ui-swipe 5.0.6 → 5.1.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/Swipe.js CHANGED
@@ -1,18 +1,22 @@
1
1
  import './index.css';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { useRef, useState, useCallback, useEffect } from 'react';
3
+ import { useRef, useState, useCallback, useEffect, useId, useContext, Fragment } from 'react';
4
4
  import { useSpring, config, animated } from '@react-spring/web';
5
5
  import classNames from 'classnames';
6
6
  import { useDebounce } from '@hh.ru/magritte-common-func-utils';
7
- import { useSwipe, MAIN_AXIS_THRESHOLD_PX } from '@hh.ru/magritte-common-use-swipe/useSwipe';
7
+ import { useResize } from '@hh.ru/magritte-common-resize';
8
+ import { MAIN_AXIS_THRESHOLD_PX, useSwipe } from '@hh.ru/magritte-common-use-swipe/useSwipe';
9
+ import { useWhenFontLoaded } from '@hh.ru/magritte-common-use-when-font-loaded';
8
10
  import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
9
11
  import { Layer, LayerName } from '@hh.ru/magritte-ui-layer';
12
+ import { SwipeContext } from './context.js';
10
13
 
11
- var styles = {"text":"magritte-text___gUsfc_5-0-6","text_max-lines":"magritte-text_max-lines___foe9-_5-0-6","textMaxLines":"magritte-text_max-lines___foe9-_5-0-6","text-dynamic":"magritte-text-dynamic___KzitV_5-0-6","textDynamic":"magritte-text-dynamic___KzitV_5-0-6","text-dynamic_stretched":"magritte-text-dynamic_stretched___hv3Th_5-0-6","textDynamicStretched":"magritte-text-dynamic_stretched___hv3Th_5-0-6","text_style-primary":"magritte-text_style-primary___vYlpl_5-0-6","textStylePrimary":"magritte-text_style-primary___vYlpl_5-0-6","text-dynamic-disabled":"magritte-text-dynamic-disabled___M1GFt_5-0-6","textDynamicDisabled":"magritte-text-dynamic-disabled___M1GFt_5-0-6","text_style-secondary":"magritte-text_style-secondary___qb-4O_5-0-6","textStyleSecondary":"magritte-text_style-secondary___qb-4O_5-0-6","text_style-tertiary":"magritte-text_style-tertiary___atZvg_5-0-6","textStyleTertiary":"magritte-text_style-tertiary___atZvg_5-0-6","text_style-accent":"magritte-text_style-accent___JDNe4_5-0-6","textStyleAccent":"magritte-text_style-accent___JDNe4_5-0-6","text_style-accent-secondary":"magritte-text_style-accent-secondary___JM6z5_5-0-6","textStyleAccentSecondary":"magritte-text_style-accent-secondary___JM6z5_5-0-6","text_style-positive":"magritte-text_style-positive___OjJIB_5-0-6","textStylePositive":"magritte-text_style-positive___OjJIB_5-0-6","text_style-positive-secondary":"magritte-text_style-positive-secondary___LkPe1_5-0-6","textStylePositiveSecondary":"magritte-text_style-positive-secondary___LkPe1_5-0-6","text_style-negative":"magritte-text_style-negative___wBLmp_5-0-6","textStyleNegative":"magritte-text_style-negative___wBLmp_5-0-6","text_style-negative-secondary":"magritte-text_style-negative-secondary___CO58y_5-0-6","textStyleNegativeSecondary":"magritte-text_style-negative-secondary___CO58y_5-0-6","text_style-warning":"magritte-text_style-warning___23C3Y_5-0-6","textStyleWarning":"magritte-text_style-warning___23C3Y_5-0-6","text_style-warning-secondary":"magritte-text_style-warning-secondary___ZJ3uf_5-0-6","textStyleWarningSecondary":"magritte-text_style-warning-secondary___ZJ3uf_5-0-6","text_style-special":"magritte-text_style-special___LaqKY_5-0-6","textStyleSpecial":"magritte-text_style-special___LaqKY_5-0-6","text_style-special-secondary":"magritte-text_style-special-secondary___-whB-_5-0-6","textStyleSpecialSecondary":"magritte-text_style-special-secondary___-whB-_5-0-6","text_style-contrast":"magritte-text_style-contrast___Bx24w_5-0-6","textStyleContrast":"magritte-text_style-contrast___Bx24w_5-0-6","text_style-contrast-secondary":"magritte-text_style-contrast-secondary___xMS2f_5-0-6","textStyleContrastSecondary":"magritte-text_style-contrast-secondary___xMS2f_5-0-6","text_typography-title-1-semibold":"magritte-text_typography-title-1-semibold___WDZXM_5-0-6","textTypographyTitle1Semibold":"magritte-text-typography-title-1-semibold___RE-5E_5-0-6","text_typography-title-2-semibold":"magritte-text_typography-title-2-semibold___4PvYn_5-0-6","textTypographyTitle2Semibold":"magritte-text-typography-title-2-semibold___r-gyn_5-0-6","text_typography-title-3-semibold":"magritte-text_typography-title-3-semibold___E7pmd_5-0-6","textTypographyTitle3Semibold":"magritte-text-typography-title-3-semibold___AxOn9_5-0-6","text_typography-title-4-semibold":"magritte-text_typography-title-4-semibold___u-8Kd_5-0-6","textTypographyTitle4Semibold":"magritte-text-typography-title-4-semibold___4FOf2_5-0-6","text_typography-title-5-semibold":"magritte-text_typography-title-5-semibold___PRTQc_5-0-6","textTypographyTitle5Semibold":"magritte-text-typography-title-5-semibold___ayTa0_5-0-6","text_typography-subtitle-1-semibold":"magritte-text_typography-subtitle-1-semibold___TNYKE_5-0-6","textTypographySubtitle1Semibold":"magritte-text_typography-subtitle-1-semibold___TNYKE_5-0-6","text_typography-subtitle-2-semibold":"magritte-text_typography-subtitle-2-semibold___8GJr9_5-0-6","textTypographySubtitle2Semibold":"magritte-text_typography-subtitle-2-semibold___8GJr9_5-0-6","text_typography-subtitle-3-semibold":"magritte-text_typography-subtitle-3-semibold___scHMl_5-0-6","textTypographySubtitle3Semibold":"magritte-text_typography-subtitle-3-semibold___scHMl_5-0-6","text_typography-subtitle-4-semibold":"magritte-text_typography-subtitle-4-semibold___Yr4Bt_5-0-6","textTypographySubtitle4Semibold":"magritte-text_typography-subtitle-4-semibold___Yr4Bt_5-0-6","text_typography-label-1-regular":"magritte-text_typography-label-1-regular___JMO56_5-0-6","textTypographyLabel1Regular":"magritte-text_typography-label-1-regular___JMO56_5-0-6","text_typography-label-2-regular":"magritte-text_typography-label-2-regular___7gS1P_5-0-6","textTypographyLabel2Regular":"magritte-text_typography-label-2-regular___7gS1P_5-0-6","text_typography-label-3-regular":"magritte-text_typography-label-3-regular___DogGv_5-0-6","textTypographyLabel3Regular":"magritte-text_typography-label-3-regular___DogGv_5-0-6","text_typography-label-4-regular":"magritte-text_typography-label-4-regular___TIPoS_5-0-6","textTypographyLabel4Regular":"magritte-text_typography-label-4-regular___TIPoS_5-0-6","text_typography-label-5-regular":"magritte-text_typography-label-5-regular___y55-P_5-0-6","textTypographyLabel5Regular":"magritte-text_typography-label-5-regular___y55-P_5-0-6","text_typography-paragraph-1-regular":"magritte-text_typography-paragraph-1-regular___ZvHBC_5-0-6","textTypographyParagraph1Regular":"magritte-text_typography-paragraph-1-regular___ZvHBC_5-0-6","text_typography-paragraph-2-regular":"magritte-text_typography-paragraph-2-regular___ndKyc_5-0-6","textTypographyParagraph2Regular":"magritte-text_typography-paragraph-2-regular___ndKyc_5-0-6","text_typography-paragraph-3-regular":"magritte-text_typography-paragraph-3-regular___g0oZF_5-0-6","textTypographyParagraph3Regular":"magritte-text_typography-paragraph-3-regular___g0oZF_5-0-6","text_typography-paragraph-4-regular":"magritte-text_typography-paragraph-4-regular___Iy3Zy_5-0-6","textTypographyParagraph4Regular":"magritte-text_typography-paragraph-4-regular___Iy3Zy_5-0-6","text_typography-custom-1-semibold":"magritte-text_typography-custom-1-semibold___Pv6Lp_5-0-6","textTypographyCustom1Semibold":"magritte-text_typography-custom-1-semibold___Pv6Lp_5-0-6","text_typography-custom-2-semibold":"magritte-text_typography-custom-2-semibold___UP1hj_5-0-6","textTypographyCustom2Semibold":"magritte-text_typography-custom-2-semibold___UP1hj_5-0-6","text_typography-custom-3-semibold":"magritte-text_typography-custom-3-semibold___6yO4m_5-0-6","textTypographyCustom3Semibold":"magritte-text_typography-custom-3-semibold___6yO4m_5-0-6","text_typography-custom-4-semibold":"magritte-text_typography-custom-4-semibold___NEahp_5-0-6","textTypographyCustom4Semibold":"magritte-text_typography-custom-4-semibold___NEahp_5-0-6","text_typography-custom-5-semibold":"magritte-text_typography-custom-5-semibold___-UJfV_5-0-6","textTypographyCustom5Semibold":"magritte-text_typography-custom-5-semibold___-UJfV_5-0-6","text_typography-custom-1-italic":"magritte-text_typography-custom-1-italic___-CpMs_5-0-6","textTypographyCustom1Italic":"magritte-text_typography-custom-1-italic___-CpMs_5-0-6","text_typography-custom-2-italic":"magritte-text_typography-custom-2-italic___SvOG4_5-0-6","textTypographyCustom2Italic":"magritte-text_typography-custom-2-italic___SvOG4_5-0-6","text_typography-custom-3-italic":"magritte-text_typography-custom-3-italic___-g0na_5-0-6","textTypographyCustom3Italic":"magritte-text_typography-custom-3-italic___-g0na_5-0-6","text_typography-custom-4-italic":"magritte-text_typography-custom-4-italic___gOGey_5-0-6","textTypographyCustom4Italic":"magritte-text_typography-custom-4-italic___gOGey_5-0-6","text_typography-custom-5-italic":"magritte-text_typography-custom-5-italic___VR9wy_5-0-6","textTypographyCustom5Italic":"magritte-text_typography-custom-5-italic___VR9wy_5-0-6","text_typography-custom-1-medium":"magritte-text_typography-custom-1-medium___hik0e_5-0-6","textTypographyCustom1Medium":"magritte-text_typography-custom-1-medium___hik0e_5-0-6","text_typography-custom-2-medium":"magritte-text_typography-custom-2-medium___-f6Sh_5-0-6","textTypographyCustom2Medium":"magritte-text_typography-custom-2-medium___-f6Sh_5-0-6","text_typography-custom-3-medium":"magritte-text_typography-custom-3-medium___pLvIb_5-0-6","textTypographyCustom3Medium":"magritte-text_typography-custom-3-medium___pLvIb_5-0-6","text_typography-custom-4-medium":"magritte-text_typography-custom-4-medium___zZteM_5-0-6","textTypographyCustom4Medium":"magritte-text_typography-custom-4-medium___zZteM_5-0-6","text_typography-custom-5-medium":"magritte-text_typography-custom-5-medium___gW1Y8_5-0-6","textTypographyCustom5Medium":"magritte-text_typography-custom-5-medium___gW1Y8_5-0-6","text-typography-title-1-semibold":"magritte-text-typography-title-1-semibold___RE-5E_5-0-6","text-typography-title-2-semibold":"magritte-text-typography-title-2-semibold___r-gyn_5-0-6","text-typography-title-3-semibold":"magritte-text-typography-title-3-semibold___AxOn9_5-0-6","text-typography-title-4-semibold":"magritte-text-typography-title-4-semibold___4FOf2_5-0-6","text-typography-title-5-semibold":"magritte-text-typography-title-5-semibold___ayTa0_5-0-6","root":"magritte-root___gbkM-_5-0-6","swipeble":"magritte-swipeble___EVyAI_5-0-6","childrenWrapper":"magritte-childrenWrapper___1tUbf_5-0-6","buttons":"magritte-buttons___PHNdL_5-0-6","buttons-left":"magritte-buttons-left___WPiN4_5-0-6","buttonsLeft":"magritte-buttons-left___WPiN4_5-0-6","buttons-right":"magritte-buttons-right___G3u6y_5-0-6","buttonsRight":"magritte-buttons-right___G3u6y_5-0-6","button":"magritte-button___jZvyY_5-0-6","button-hide":"magritte-button-hide___5AEdR_5-0-6","buttonHide":"magritte-button-hide___5AEdR_5-0-6","button-grow":"magritte-button-grow___IT4MK_5-0-6","buttonGrow":"magritte-button-grow___IT4MK_5-0-6","button-content":"magritte-button-content___hlzd-_5-0-6","buttonContent":"magritte-button-content___hlzd-_5-0-6","button-content-column":"magritte-button-content-column___48Tzo_5-0-6","buttonContentColumn":"magritte-button-content-column___48Tzo_5-0-6","button-label":"magritte-button-label___l03VO_5-0-6","buttonLabel":"magritte-button-label___l03VO_5-0-6","button_style-neutral":"magritte-button_style-neutral___1yyqh_5-0-6","buttonStyleNeutral":"magritte-button_style-neutral___1yyqh_5-0-6","button_style-accent":"magritte-button_style-accent___L9krS_5-0-6","buttonStyleAccent":"magritte-button_style-accent___L9krS_5-0-6","button_style-positive":"magritte-button_style-positive___2pgae_5-0-6","buttonStylePositive":"magritte-button_style-positive___2pgae_5-0-6","button_style-negative":"magritte-button_style-negative___UClE4_5-0-6","buttonStyleNegative":"magritte-button_style-negative___UClE4_5-0-6","button_style-special":"magritte-button_style-special___sGvAc_5-0-6","buttonStyleSpecial":"magritte-button_style-special___sGvAc_5-0-6","button_style-warning":"magritte-button_style-warning___5bEK0_5-0-6","buttonStyleWarning":"magritte-button_style-warning___5bEK0_5-0-6","icon-wrapper":"magritte-icon-wrapper___0xJZX_5-0-6","iconWrapper":"magritte-icon-wrapper___0xJZX_5-0-6"};
14
+ var styles = {"text":"magritte-text___gUsfc_5-1-0","text_max-lines":"magritte-text_max-lines___foe9-_5-1-0","textMaxLines":"magritte-text_max-lines___foe9-_5-1-0","text-dynamic":"magritte-text-dynamic___KzitV_5-1-0","textDynamic":"magritte-text-dynamic___KzitV_5-1-0","text-dynamic_stretched":"magritte-text-dynamic_stretched___hv3Th_5-1-0","textDynamicStretched":"magritte-text-dynamic_stretched___hv3Th_5-1-0","text_style-primary":"magritte-text_style-primary___vYlpl_5-1-0","textStylePrimary":"magritte-text_style-primary___vYlpl_5-1-0","text-dynamic-disabled":"magritte-text-dynamic-disabled___M1GFt_5-1-0","textDynamicDisabled":"magritte-text-dynamic-disabled___M1GFt_5-1-0","text_style-secondary":"magritte-text_style-secondary___qb-4O_5-1-0","textStyleSecondary":"magritte-text_style-secondary___qb-4O_5-1-0","text_style-tertiary":"magritte-text_style-tertiary___atZvg_5-1-0","textStyleTertiary":"magritte-text_style-tertiary___atZvg_5-1-0","text_style-accent":"magritte-text_style-accent___JDNe4_5-1-0","textStyleAccent":"magritte-text_style-accent___JDNe4_5-1-0","text_style-accent-secondary":"magritte-text_style-accent-secondary___JM6z5_5-1-0","textStyleAccentSecondary":"magritte-text_style-accent-secondary___JM6z5_5-1-0","text_style-positive":"magritte-text_style-positive___OjJIB_5-1-0","textStylePositive":"magritte-text_style-positive___OjJIB_5-1-0","text_style-positive-secondary":"magritte-text_style-positive-secondary___LkPe1_5-1-0","textStylePositiveSecondary":"magritte-text_style-positive-secondary___LkPe1_5-1-0","text_style-negative":"magritte-text_style-negative___wBLmp_5-1-0","textStyleNegative":"magritte-text_style-negative___wBLmp_5-1-0","text_style-negative-secondary":"magritte-text_style-negative-secondary___CO58y_5-1-0","textStyleNegativeSecondary":"magritte-text_style-negative-secondary___CO58y_5-1-0","text_style-warning":"magritte-text_style-warning___23C3Y_5-1-0","textStyleWarning":"magritte-text_style-warning___23C3Y_5-1-0","text_style-warning-secondary":"magritte-text_style-warning-secondary___ZJ3uf_5-1-0","textStyleWarningSecondary":"magritte-text_style-warning-secondary___ZJ3uf_5-1-0","text_style-special":"magritte-text_style-special___LaqKY_5-1-0","textStyleSpecial":"magritte-text_style-special___LaqKY_5-1-0","text_style-special-secondary":"magritte-text_style-special-secondary___-whB-_5-1-0","textStyleSpecialSecondary":"magritte-text_style-special-secondary___-whB-_5-1-0","text_style-contrast":"magritte-text_style-contrast___Bx24w_5-1-0","textStyleContrast":"magritte-text_style-contrast___Bx24w_5-1-0","text_style-contrast-secondary":"magritte-text_style-contrast-secondary___xMS2f_5-1-0","textStyleContrastSecondary":"magritte-text_style-contrast-secondary___xMS2f_5-1-0","text_typography-title-1-semibold":"magritte-text_typography-title-1-semibold___WDZXM_5-1-0","textTypographyTitle1Semibold":"magritte-text-typography-title-1-semibold___RE-5E_5-1-0","text_typography-title-2-semibold":"magritte-text_typography-title-2-semibold___4PvYn_5-1-0","textTypographyTitle2Semibold":"magritte-text-typography-title-2-semibold___r-gyn_5-1-0","text_typography-title-3-semibold":"magritte-text_typography-title-3-semibold___E7pmd_5-1-0","textTypographyTitle3Semibold":"magritte-text-typography-title-3-semibold___AxOn9_5-1-0","text_typography-title-4-semibold":"magritte-text_typography-title-4-semibold___u-8Kd_5-1-0","textTypographyTitle4Semibold":"magritte-text-typography-title-4-semibold___4FOf2_5-1-0","text_typography-title-5-semibold":"magritte-text_typography-title-5-semibold___PRTQc_5-1-0","textTypographyTitle5Semibold":"magritte-text-typography-title-5-semibold___ayTa0_5-1-0","text_typography-subtitle-1-semibold":"magritte-text_typography-subtitle-1-semibold___TNYKE_5-1-0","textTypographySubtitle1Semibold":"magritte-text_typography-subtitle-1-semibold___TNYKE_5-1-0","text_typography-subtitle-2-semibold":"magritte-text_typography-subtitle-2-semibold___8GJr9_5-1-0","textTypographySubtitle2Semibold":"magritte-text_typography-subtitle-2-semibold___8GJr9_5-1-0","text_typography-subtitle-3-semibold":"magritte-text_typography-subtitle-3-semibold___scHMl_5-1-0","textTypographySubtitle3Semibold":"magritte-text_typography-subtitle-3-semibold___scHMl_5-1-0","text_typography-subtitle-4-semibold":"magritte-text_typography-subtitle-4-semibold___Yr4Bt_5-1-0","textTypographySubtitle4Semibold":"magritte-text_typography-subtitle-4-semibold___Yr4Bt_5-1-0","text_typography-label-1-regular":"magritte-text_typography-label-1-regular___JMO56_5-1-0","textTypographyLabel1Regular":"magritte-text_typography-label-1-regular___JMO56_5-1-0","text_typography-label-2-regular":"magritte-text_typography-label-2-regular___7gS1P_5-1-0","textTypographyLabel2Regular":"magritte-text_typography-label-2-regular___7gS1P_5-1-0","text_typography-label-3-regular":"magritte-text_typography-label-3-regular___DogGv_5-1-0","textTypographyLabel3Regular":"magritte-text_typography-label-3-regular___DogGv_5-1-0","text_typography-label-4-regular":"magritte-text_typography-label-4-regular___TIPoS_5-1-0","textTypographyLabel4Regular":"magritte-text_typography-label-4-regular___TIPoS_5-1-0","text_typography-label-5-regular":"magritte-text_typography-label-5-regular___y55-P_5-1-0","textTypographyLabel5Regular":"magritte-text_typography-label-5-regular___y55-P_5-1-0","text_typography-paragraph-1-regular":"magritte-text_typography-paragraph-1-regular___ZvHBC_5-1-0","textTypographyParagraph1Regular":"magritte-text_typography-paragraph-1-regular___ZvHBC_5-1-0","text_typography-paragraph-2-regular":"magritte-text_typography-paragraph-2-regular___ndKyc_5-1-0","textTypographyParagraph2Regular":"magritte-text_typography-paragraph-2-regular___ndKyc_5-1-0","text_typography-paragraph-3-regular":"magritte-text_typography-paragraph-3-regular___g0oZF_5-1-0","textTypographyParagraph3Regular":"magritte-text_typography-paragraph-3-regular___g0oZF_5-1-0","text_typography-paragraph-4-regular":"magritte-text_typography-paragraph-4-regular___Iy3Zy_5-1-0","textTypographyParagraph4Regular":"magritte-text_typography-paragraph-4-regular___Iy3Zy_5-1-0","text_typography-custom-1-semibold":"magritte-text_typography-custom-1-semibold___Pv6Lp_5-1-0","textTypographyCustom1Semibold":"magritte-text_typography-custom-1-semibold___Pv6Lp_5-1-0","text_typography-custom-2-semibold":"magritte-text_typography-custom-2-semibold___UP1hj_5-1-0","textTypographyCustom2Semibold":"magritte-text_typography-custom-2-semibold___UP1hj_5-1-0","text_typography-custom-3-semibold":"magritte-text_typography-custom-3-semibold___6yO4m_5-1-0","textTypographyCustom3Semibold":"magritte-text_typography-custom-3-semibold___6yO4m_5-1-0","text_typography-custom-4-semibold":"magritte-text_typography-custom-4-semibold___NEahp_5-1-0","textTypographyCustom4Semibold":"magritte-text_typography-custom-4-semibold___NEahp_5-1-0","text_typography-custom-5-semibold":"magritte-text_typography-custom-5-semibold___-UJfV_5-1-0","textTypographyCustom5Semibold":"magritte-text_typography-custom-5-semibold___-UJfV_5-1-0","text_typography-custom-1-italic":"magritte-text_typography-custom-1-italic___-CpMs_5-1-0","textTypographyCustom1Italic":"magritte-text_typography-custom-1-italic___-CpMs_5-1-0","text_typography-custom-2-italic":"magritte-text_typography-custom-2-italic___SvOG4_5-1-0","textTypographyCustom2Italic":"magritte-text_typography-custom-2-italic___SvOG4_5-1-0","text_typography-custom-3-italic":"magritte-text_typography-custom-3-italic___-g0na_5-1-0","textTypographyCustom3Italic":"magritte-text_typography-custom-3-italic___-g0na_5-1-0","text_typography-custom-4-italic":"magritte-text_typography-custom-4-italic___gOGey_5-1-0","textTypographyCustom4Italic":"magritte-text_typography-custom-4-italic___gOGey_5-1-0","text_typography-custom-5-italic":"magritte-text_typography-custom-5-italic___VR9wy_5-1-0","textTypographyCustom5Italic":"magritte-text_typography-custom-5-italic___VR9wy_5-1-0","text_typography-custom-1-medium":"magritte-text_typography-custom-1-medium___hik0e_5-1-0","textTypographyCustom1Medium":"magritte-text_typography-custom-1-medium___hik0e_5-1-0","text_typography-custom-2-medium":"magritte-text_typography-custom-2-medium___-f6Sh_5-1-0","textTypographyCustom2Medium":"magritte-text_typography-custom-2-medium___-f6Sh_5-1-0","text_typography-custom-3-medium":"magritte-text_typography-custom-3-medium___pLvIb_5-1-0","textTypographyCustom3Medium":"magritte-text_typography-custom-3-medium___pLvIb_5-1-0","text_typography-custom-4-medium":"magritte-text_typography-custom-4-medium___zZteM_5-1-0","textTypographyCustom4Medium":"magritte-text_typography-custom-4-medium___zZteM_5-1-0","text_typography-custom-5-medium":"magritte-text_typography-custom-5-medium___gW1Y8_5-1-0","textTypographyCustom5Medium":"magritte-text_typography-custom-5-medium___gW1Y8_5-1-0","text-typography-title-1-semibold":"magritte-text-typography-title-1-semibold___RE-5E_5-1-0","text-typography-title-2-semibold":"magritte-text-typography-title-2-semibold___r-gyn_5-1-0","text-typography-title-3-semibold":"magritte-text-typography-title-3-semibold___AxOn9_5-1-0","text-typography-title-4-semibold":"magritte-text-typography-title-4-semibold___4FOf2_5-1-0","text-typography-title-5-semibold":"magritte-text-typography-title-5-semibold___ayTa0_5-1-0","fixed-container":"magritte-fixed-container___gruvI_5-1-0","fixedContainer":"magritte-fixed-container___gruvI_5-1-0","swipe-container":"magritte-swipe-container___HCz0Y_5-1-0","swipeContainer":"magritte-swipe-container___HCz0Y_5-1-0","content":"magritte-content___oKEcs_5-1-0","buttons":"magritte-buttons___PHNdL_5-1-0","swipe-container_in-progress":"magritte-swipe-container_in-progress___D4pLw_5-1-0","swipeContainerInProgress":"magritte-swipe-container_in-progress___D4pLw_5-1-0","left-buttons-animation":"magritte-left-buttons-animation___KnKbA_5-1-0","leftButtonsAnimation":"magritte-left-buttons-animation___KnKbA_5-1-0","right-buttons-animation":"magritte-right-buttons-animation___Wgsss_5-1-0","rightButtonsAnimation":"magritte-right-buttons-animation___Wgsss_5-1-0","button-wrapper":"magritte-button-wrapper___fp3-5_5-1-0","buttonWrapper":"magritte-button-wrapper___fp3-5_5-1-0","button-wrapper-hide":"magritte-button-wrapper-hide___MN7-s_5-1-0","buttonWrapperHide":"magritte-button-wrapper-hide___MN7-s_5-1-0","button-wrapper-grow":"magritte-button-wrapper-grow___-hbrz_5-1-0","buttonWrapperGrow":"magritte-button-wrapper-grow___-hbrz_5-1-0","button":"magritte-button___jZvyY_5-1-0","button-grow":"magritte-button-grow___IT4MK_5-1-0","buttonGrow":"magritte-button-grow___IT4MK_5-1-0","gap":"magritte-gap___3z9to_5-1-0","button-content":"magritte-button-content___hlzd-_5-1-0","buttonContent":"magritte-button-content___hlzd-_5-1-0","button-content-column":"magritte-button-content-column___48Tzo_5-1-0","buttonContentColumn":"magritte-button-content-column___48Tzo_5-1-0","button-label":"magritte-button-label___l03VO_5-1-0","buttonLabel":"magritte-button-label___l03VO_5-1-0","button_style-neutral":"magritte-button_style-neutral___1yyqh_5-1-0","buttonStyleNeutral":"magritte-button_style-neutral___1yyqh_5-1-0","button_style-accent":"magritte-button_style-accent___L9krS_5-1-0","buttonStyleAccent":"magritte-button_style-accent___L9krS_5-1-0","button_style-positive":"magritte-button_style-positive___2pgae_5-1-0","buttonStylePositive":"magritte-button_style-positive___2pgae_5-1-0","button_style-negative":"magritte-button_style-negative___UClE4_5-1-0","buttonStyleNegative":"magritte-button_style-negative___UClE4_5-1-0","button_style-special":"magritte-button_style-special___sGvAc_5-1-0","buttonStyleSpecial":"magritte-button_style-special___sGvAc_5-1-0","button_style-warning":"magritte-button_style-warning___5bEK0_5-1-0","buttonStyleWarning":"magritte-button_style-warning___5bEK0_5-1-0","icon-wrapper":"magritte-icon-wrapper___0xJZX_5-1-0","iconWrapper":"magritte-icon-wrapper___0xJZX_5-1-0"};
12
15
 
13
16
  const MIN_BUTTON_WIDTH = 76;
14
17
  const OPEN_THRESHOLD = 1 / 3;
15
18
  const MIN_SWIPE_DISTANCE = MIN_BUTTON_WIDTH * OPEN_THRESHOLD;
19
+ const GAP_WIDTH = 12;
16
20
  var ButtonsState;
17
21
  (function (ButtonsState) {
18
22
  ButtonsState["Close"] = "close";
@@ -25,11 +29,11 @@ var LongState;
25
29
  LongState["Left"] = "left";
26
30
  LongState["Right"] = "right";
27
31
  })(LongState || (LongState = {}));
28
- const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLongSwipe = true, 'data-qa': dataQa, demo = false, twoSidedDemoMode = 'right-to-left', demoAppearTime = 200, demoIdleTime = 300, demoDisappearTime = 200, onFinishDemo, onStartDemo, onResetDemo, }) => {
29
- const rootRef = useRef(null);
30
- const swipeableRef = useRef(null);
31
- const childrenWrapperRef = useRef(null);
32
- const [swipeableWidth, setSwipeableWidth] = useState(0);
32
+ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLongSwipe = true, 'data-qa': dataQa, demo = false, twoSidedDemoMode = 'right-to-left', demoAppearTime = 200, demoIdleTime = 300, demoDisappearTime = 200, onFinishDemo, onStartDemo, onResetDemo, gap = false, borderRadius, }) => {
33
+ const fixedContainerRef = useRef(null);
34
+ const swipeContainerRef = useRef(null);
35
+ const contentRef = useRef(null);
36
+ const [swipeContainerWidth, setSwipeContainerWidth] = useState(0);
33
37
  const leftButtonsRef = useRef(null);
34
38
  const rightButtonsRef = useRef(null);
35
39
  const sumRefs = useRef([]); // ссылки на кнопки, по которым считается реальный размер
@@ -41,12 +45,11 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
41
45
  const swipeThresholdRef = useRef({ max: MIN_SWIPE_DISTANCE });
42
46
  const swipeLockRef = useRef(false);
43
47
  const { isMobile } = useBreakpoint();
44
- const [leftBlockStyles, leftBlockApi] = useSpring(() => ({
45
- width: 0,
46
- }));
47
- const [rightBlockStyles, rightBlockApi] = useSpring(() => ({
48
- width: 0,
49
- }));
48
+ const [isFontLoaded, setFontLoaded] = useState(false);
49
+ const visible = isMobile && isFontLoaded;
50
+ useWhenFontLoaded(() => setFontLoaded(true));
51
+ const [leftBlockStyles, leftBlockApi] = useSpring(() => ({ width: 0 }));
52
+ const [rightBlockStyles, rightBlockApi] = useSpring(() => ({ width: 0 }));
50
53
  const [longState, setLongState] = useState(LongState.Off);
51
54
  const stateRef = useRef({
52
55
  candidate: ButtonsState.Close,
@@ -62,30 +65,23 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
62
65
  rightButtonsRef.current.style.transitionProperty = flag ? 'width' : 'none';
63
66
  }
64
67
  }, []);
65
- const setWidth = useDebounce(useCallback(() => {
66
- if (swipeableRef.current && childrenWrapperRef.current && rootRef.current) {
67
- const value = rootRef.current.getBoundingClientRect().width;
68
+ const recalcSwipeContainerWidth = useCallback(() => {
69
+ if (swipeContainerRef.current && contentRef.current && fixedContainerRef.current) {
70
+ const width = Math.round(fixedContainerRef.current.getBoundingClientRect().width);
68
71
  // устанавливаем размер области равной размеру контента,
69
72
  // чтобы она не растягивалась, когда растягиваются кнопки
70
- setSwipeableWidth(value);
71
- swipeableRef.current.style.width = `${value}px`;
72
- childrenWrapperRef.current.style.width = `${value}px`;
73
- childrenWrapperRef.current.style.minWidth = `${value}px`;
73
+ setSwipeContainerWidth(width);
74
+ swipeContainerRef.current.style.width = `${width}px`;
75
+ contentRef.current.style.width = `${width}px`;
76
+ contentRef.current.style.minWidth = `${width}px`;
74
77
  }
75
- }, [setSwipeableWidth]), 64);
78
+ }, [setSwipeContainerWidth]);
76
79
  useEffect(() => {
77
- setWidth();
78
- }, [setWidth]);
79
- useEffect(() => {
80
- if (window && isMobile) {
81
- window.addEventListener('resize', setWidth);
80
+ if (visible) {
81
+ recalcSwipeContainerWidth();
82
82
  }
83
- return () => {
84
- if (window && isMobile) {
85
- window.removeEventListener('resize', setWidth);
86
- }
87
- };
88
- }, [setWidth, isMobile]);
83
+ }, [visible, recalcSwipeContainerWidth]);
84
+ useResize(useDebounce(recalcSwipeContainerWidth, 50));
89
85
  // обновляет порог срабатывания для useSwipe в зависимости от состояния
90
86
  const updateSwipeThreshold = useCallback(() => {
91
87
  const { now, candidate } = stateRef.current;
@@ -148,15 +144,27 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
148
144
  // то для правой стороны нужно поменять знак начальной скорости
149
145
  api = toState === ButtonsState.LeftOpen ? leftBlockApi : rightBlockApi;
150
146
  const v = toState === ButtonsState.LeftOpen ? velocity : -velocity;
151
- animationConfig.width = Math.min(swipeableWidth, (toState === ButtonsState.LeftOpen ? leftButtonsSumSizeRef : rightButtonsSumSizeRef).current);
147
+ animationConfig.width = Math.min(swipeContainerWidth, (toState === ButtonsState.LeftOpen ? leftButtonsSumSizeRef : rightButtonsSumSizeRef).current);
152
148
  animationConfig.config.velocity = v / 1000;
153
149
  }
154
150
  void api.start(animationConfig)[0].then(({ finished }) => {
155
151
  if (finished) {
156
152
  stateRef.current.candidate = ButtonsState.Close;
153
+ if (swipeContainerRef.current !== null) {
154
+ swipeContainerRef.current.classList.remove(styles.swipeContainerInProgress);
155
+ }
157
156
  }
158
157
  });
159
- }, [leftBlockApi, rightBlockApi, swipeableWidth]);
158
+ }, [leftBlockApi, rightBlockApi, swipeContainerWidth]);
159
+ const id = useId();
160
+ const swipeContext = useContext(SwipeContext);
161
+ useEffect(() => {
162
+ if (visible && swipeContext !== null) {
163
+ swipeContext.register(id, () => {
164
+ animateToState(ButtonsState.Close, 0);
165
+ });
166
+ }
167
+ }, [visible, swipeContext, id, animateToState]);
160
168
  const handleSwipeStart = useCallback(() => {
161
169
  if (demoInProgress || swipeLockRef.current) {
162
170
  return;
@@ -181,7 +189,7 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
181
189
  longState,
182
190
  setAnimateButtonsWidth,
183
191
  ]);
184
- const handleChangeButtonsSizeByDistance = useCallback((distance) => {
192
+ const recalcButtonsSizes = useCallback((distance) => {
185
193
  // работаем с изменением дистанции, чтобы добавлять ее к существующей ширине
186
194
  const distanceDelta = distance - prevDistance.current;
187
195
  if (distanceDelta === 0) {
@@ -212,8 +220,9 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
212
220
  // если раскрыты слева, то контент должен уходить за пределы области в право, ставим flex-start
213
221
  // если раскрыты справа, то контент должен уходить за пределы области в лево, ставим flex-end
214
222
  // визуально ничего не меняется, потому что контент в контейнере растянут на всю ширину
215
- if (swipeableRef.current) {
216
- swipeableRef.current.style.justifyContent =
223
+ if (swipeContainerRef.current) {
224
+ swipeContainerRef.current.classList.toggle(styles.swipeContainerInProgress, width > 0);
225
+ swipeContainerRef.current.style.justifyContent =
217
226
  stateRef.current.candidate === ButtonsState.RightOpen ? 'flex-end' : 'flex-start';
218
227
  }
219
228
  // определяем выполнены ли условия для перевода компонента в состояние длинного свайпа
@@ -226,16 +235,19 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
226
235
  else {
227
236
  setLongState(LongState.Off);
228
237
  }
229
- }, [leftBlockApi, rightBlockApi, useLongSwipe, updateSwipeThreshold]);
238
+ if (Math.abs(distance) > MAIN_AXIS_THRESHOLD_PX) {
239
+ swipeContext?.onShown(id);
240
+ }
241
+ }, [leftBlockApi, rightBlockApi, useLongSwipe, updateSwipeThreshold, id, swipeContext]);
230
242
  const handleSwipeMove = useCallback((event) => {
231
243
  if (demoInProgress || swipeLockRef.current) {
232
244
  return;
233
245
  }
234
- // сдвиг в след за пальцем, можем делать длинный свайп
235
- handleChangeButtonsSizeByDistance(event.distanceX);
236
- }, [demoInProgress, handleChangeButtonsSizeByDistance]);
246
+ // сдвиг вслед за пальцем, можем делать длинный свайп
247
+ recalcButtonsSizes(event.distanceX);
248
+ }, [demoInProgress, recalcButtonsSizes]);
237
249
  const runSwipeAnimation = useCallback(() => {
238
- if (!swipeableRef.current) {
250
+ if (!swipeContainerRef.current) {
239
251
  return;
240
252
  }
241
253
  if (stateRef.current.next === ButtonsState.Close) {
@@ -253,7 +265,7 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
253
265
  else if (stateRef.current.next === ButtonsState.LeftOpen) {
254
266
  // выполнено условие раскрытия слева
255
267
  // раскрываем кнопки на ширину их контента, но не больше ширины контейнера
256
- const maxLeftSize = Math.min(swipeableWidth, leftButtonsSumSizeRef.current);
268
+ const maxLeftSize = Math.min(swipeContainerWidth, leftButtonsSumSizeRef.current);
257
269
  if (leftButtonsRef.current) {
258
270
  leftButtonsRef.current.style.width = `${maxLeftSize}px`;
259
271
  }
@@ -263,7 +275,7 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
263
275
  else if (stateRef.current.next === ButtonsState.RightOpen) {
264
276
  // выполнено условие раскрытия справа
265
277
  // раскрываем кнопки на ширину их контента, но не больше ширины контейнера
266
- const maxRightSize = Math.min(swipeableWidth, rightButtonsSumSizeRef.current);
278
+ const maxRightSize = Math.min(swipeContainerWidth, rightButtonsSumSizeRef.current);
267
279
  if (rightButtonsRef.current) {
268
280
  rightButtonsRef.current.style.width = `${maxRightSize}px`;
269
281
  }
@@ -271,13 +283,13 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
271
283
  leftButtonsSizeRef.current = 0;
272
284
  }
273
285
  stateRef.current.now = stateRef.current.next;
274
- }, [swipeableWidth]);
275
- const handleSwipeFinish = useCallback((event) => {
286
+ }, [swipeContainerWidth]);
287
+ const handleSwipeEnd = useCallback((event) => {
276
288
  if (demoInProgress) {
277
289
  return;
278
290
  }
279
291
  onFinish?.();
280
- // если это длинный свайп, то трггерим клик на соответствующую кнопку, и закрываем блок кнопок
292
+ // если это длинный свайп, то триггерим клик на соответствующую кнопку, и закрываем блок кнопок
281
293
  // если не установлен флаг keepStateAfterLong
282
294
  if (longState !== LongState.Off) {
283
295
  const buttons = longState === LongState.Left ? leftButtons : rightButtons;
@@ -303,26 +315,22 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
303
315
  thresholdXRef: swipeThresholdRef,
304
316
  onSwipeStart: handleSwipeStart,
305
317
  onSwipeMove: handleSwipeMove,
306
- onSwipeEnd: handleSwipeFinish,
318
+ onSwipeEnd: handleSwipeEnd,
307
319
  onSwipeCancel: handleSwipeCancel,
308
320
  });
309
- const preventHorizontalScroll = useCallback((e) => {
310
- if (Math.abs(prevDistance.current) > MAIN_AXIS_THRESHOLD_PX) {
311
- e.preventDefault();
312
- }
313
- }, []);
314
- const swipebleRefCurrent = swipeableRef.current;
315
- // выключаем вертикальный скролл, если у нас был минимальный горизонтальный скролл, чтобы не дергалось
316
321
  useEffect(() => {
317
- if (swipebleRefCurrent) {
318
- swipebleRefCurrent.addEventListener('touchmove', preventHorizontalScroll, { passive: false });
322
+ const swipeContainer = swipeContainerRef.current;
323
+ if (!visible || !swipeContainer) {
324
+ return void 0;
319
325
  }
320
- return () => {
321
- if (swipebleRefCurrent) {
322
- swipebleRefCurrent.removeEventListener('touchmove', preventHorizontalScroll);
326
+ const preventScroll = (event) => {
327
+ if (Math.abs(prevDistance.current) > MAIN_AXIS_THRESHOLD_PX) {
328
+ event.preventDefault();
323
329
  }
324
330
  };
325
- }, [preventHorizontalScroll, swipebleRefCurrent]);
331
+ swipeContainer.addEventListener('touchmove', preventScroll, { passive: false });
332
+ return () => swipeContainer.removeEventListener('touchmove', preventScroll);
333
+ }, [visible]);
326
334
  const getButtonsFromSide = useCallback((side = stateRef.current.now) => {
327
335
  const buttons = side === ButtonsState.RightOpen ? rightButtonsRef.current : leftButtonsRef.current;
328
336
  const oppositeButtons = buttons === rightButtonsRef.current ? leftButtonsRef.current : rightButtonsRef.current;
@@ -339,8 +347,8 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
339
347
  : !!leftButtonsRef.current;
340
348
  const buttons = isLeft ? leftButtonsRef.current : rightButtonsRef.current;
341
349
  buttons?.removeEventListener('transitionend', unmountDemoEndHandler);
342
- rootRef.current?.style.removeProperty('--transition-duration');
343
- rootRef.current?.style.removeProperty('--transition-delay');
350
+ fixedContainerRef.current?.style.removeProperty('--transition-duration');
351
+ fixedContainerRef.current?.style.removeProperty('--transition-delay');
344
352
  onResetDemo?.();
345
353
  onFinishDemo?.();
346
354
  }, [onFinishDemo, onResetDemo, twoSidedDemoMode]);
@@ -355,9 +363,9 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
355
363
  ((currentSide === ButtonsState.LeftOpen && twoSidedDemoMode === 'left-to-right') ||
356
364
  (currentSide === ButtonsState.RightOpen && twoSidedDemoMode === 'right-to-left'));
357
365
  buttons?.removeEventListener('transitionend', demoSideAppearHandler);
358
- if (rootRef.current) {
359
- rootRef.current.style.setProperty('--transition-duration', `${appearedIsFirstOfSides ? demoAppearTime : demoDisappearTime}ms`);
360
- rootRef.current.style.setProperty('--transition-delay', `${demoIdleTime}ms`);
366
+ if (fixedContainerRef.current) {
367
+ fixedContainerRef.current.style.setProperty('--transition-duration', `${appearedIsFirstOfSides ? demoAppearTime : demoDisappearTime}ms`);
368
+ fixedContainerRef.current.style.setProperty('--transition-delay', `${demoIdleTime}ms`);
361
369
  }
362
370
  stateRef.current.next = ButtonsState.Close;
363
371
  stateRef.current.candidate = stateRef.current.next;
@@ -369,9 +377,9 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
369
377
  runSwipeAnimation();
370
378
  const twiceSideTransitionHandler = () => {
371
379
  oppositeButtons?.removeEventListener('transitionstart', twiceSideTransitionHandler);
372
- if (oppositeButtons && childrenWrapperRef.current) {
380
+ if (oppositeButtons && contentRef.current) {
373
381
  const isRight = currentSide === ButtonsState.RightOpen;
374
- childrenWrapperRef.current.style.transform = `translateX(${isRight ? leftButtonsSumSizeRef.current : -rightButtonsSumSizeRef.current}px)`;
382
+ contentRef.current.style.transform = `translateX(${isRight ? leftButtonsSumSizeRef.current : -rightButtonsSumSizeRef.current}px)`;
375
383
  }
376
384
  };
377
385
  oppositeButtons?.addEventListener('transitionstart', twiceSideTransitionHandler);
@@ -380,7 +388,7 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
380
388
  else {
381
389
  const startDestroyDemoHandler = () => {
382
390
  buttons?.removeEventListener('transitionstart', startDestroyDemoHandler);
383
- childrenWrapperRef.current?.style.removeProperty('transform');
391
+ contentRef.current?.style.removeProperty('transform');
384
392
  };
385
393
  buttons?.addEventListener('transitionstart', startDestroyDemoHandler);
386
394
  buttons?.addEventListener('transitionend', unmountDemoEndHandler);
@@ -401,11 +409,12 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
401
409
  stateRef.current.now = ButtonsState.Close;
402
410
  stateRef.current.next = side;
403
411
  stateRef.current.candidate = side;
404
- if (swipeableRef.current) {
405
- swipeableRef.current.style.justifyContent = side === ButtonsState.RightOpen ? 'flex-end' : 'flex-start';
412
+ if (swipeContainerRef.current) {
413
+ swipeContainerRef.current.style.justifyContent =
414
+ side === ButtonsState.RightOpen ? 'flex-end' : 'flex-start';
406
415
  }
407
- if (rootRef.current) {
408
- rootRef.current.style.setProperty('--transition-duration', `${demoAppearTime}ms`);
416
+ if (fixedContainerRef.current) {
417
+ fixedContainerRef.current.style.setProperty('--transition-duration', `${demoAppearTime}ms`);
409
418
  }
410
419
  setLongState(LongState.Off);
411
420
  setAnimateButtonsWidth(true);
@@ -425,7 +434,7 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
425
434
  if (demo &&
426
435
  !demoInProgress &&
427
436
  stateRef.current.now === ButtonsState.Close &&
428
- swipeableRef.current?.style.width) {
437
+ swipeContainerRef.current?.style.width) {
429
438
  const isTwoSidedSwipe = Boolean(rightButtonsRef.current && leftButtonsRef.current);
430
439
  if (isTwoSidedSwipe) {
431
440
  startDemo(twoSidedDemoMode === 'right' || twoSidedDemoMode === 'right-to-left'
@@ -447,69 +456,72 @@ const Swipe = ({ children, leftButtons, rightButtons, onStart, onFinish, useLong
447
456
  }, [demo, twoSidedDemoMode, startDemo, demoInProgress, isMobile, onResetDemo]);
448
457
  // подсчитываем реальный необходимый размер для кнопок
449
458
  // и назначаем проперти исходя из положения кнопки (последняя/не последняя)
450
- const handleButtonContentRef = useCallback((left, isGrow) => (ref) => {
451
- // нужно чтобы посчитать размеры для каждой кнопки один раз (не придумал, как сделать лучше)
459
+ const handleButtonContentRef = useCallback((side, grow) => (ref) => {
460
+ // нужно чтобы посчитать размеры для каждой кнопки один раз
452
461
  if (sumRefs.current.includes(ref) || !ref) {
453
462
  return;
454
463
  }
455
464
  const width = ref?.offsetWidth ?? 0;
456
- if (!isGrow) {
465
+ if (!grow) {
457
466
  ref.style.maxWidth = `${width}px`;
458
467
  }
459
468
  sumRefs.current.push(ref);
460
- if (left) {
461
- leftButtonsSumSizeRef.current += width;
469
+ const widthWithGap = gap && width > 0 ? width + GAP_WIDTH : width;
470
+ if (side === 'left') {
471
+ leftButtonsSumSizeRef.current += widthWithGap;
462
472
  }
463
473
  else {
464
- rightButtonsSumSizeRef.current += width;
474
+ rightButtonsSumSizeRef.current += widthWithGap;
465
475
  }
466
- }, []);
467
- const renderButtons = (buttons, ref, left) => {
476
+ }, [gap]);
477
+ const renderButtons = (buttons, ref, side) => {
468
478
  const isTwoSidedDemoInProgress = leftButtons && rightButtons && demoInProgress;
469
- return (jsx(Layer, { layer: LayerName.Content, children: jsx(animated.div, { className: classNames(styles.buttons, {
470
- [styles.buttonsLeft]: left && twoSidedDemoMode === 'right-to-left' && isTwoSidedDemoInProgress,
471
- [styles.buttonsRight]: !left && twoSidedDemoMode === 'left-to-right' && isTwoSidedDemoInProgress,
479
+ return (jsx(Layer, { layer: LayerName.Content, children: jsxs(animated.div, { className: classNames(styles.buttons, {
480
+ [styles.leftButtonsAnimation]: side === 'left' && twoSidedDemoMode === 'right-to-left' && isTwoSidedDemoInProgress,
481
+ [styles.rightButtonsAnimation]: side === 'right' && twoSidedDemoMode === 'left-to-right' && isTwoSidedDemoInProgress,
472
482
  }),
473
483
  // "длинная" кнопка растягивается максимум на ширину контейнера (buttons)
474
484
  // чтобы не было видно пустоты между ней и контейнером
475
485
  // нужно устанавливать выравнивание в зависимости от стороны
476
486
  style: {
477
- justifyContent: left ? 'flex-start' : 'flex-end',
478
- ...(left ? leftBlockStyles : rightBlockStyles),
479
- }, ref: ref, "data-qa": `swipe-buttons-${left ? 'left' : 'right'}`, children: buttons.map((item, index) => {
480
- if (!item) {
481
- return null;
482
- }
483
- const isGrow = left ? index === 0 : index === buttons.length - 1;
484
- const isHide = (left && index !== 0 && longState === LongState.Left) ||
485
- (!left && index !== buttons.length - 1 && longState === LongState.Right);
486
- const Icon = item.icon;
487
- const iconProps = item.showLabel
488
- ? { 'aria-hidden': true, focusable: false }
489
- : { 'aria-label': item.label };
490
- return (jsx("button", { className: classNames(styles.button, {
491
- [styles.buttonGrow]: isGrow,
492
- [styles.buttonHide]: isHide,
493
- [styles[`button_style-${item.style}`]]: item.style,
494
- }),
495
- // это нужно чтобы анимировался длинный свайп.
496
- // Здесь должно быть значение максимально близкое к тому,
497
- // какой максимум может занимать одна кнопка, если кнопок больше 1
498
- style: isGrow ? { maxWidth: `${swipeableWidth}px` } : {}, onClick: () => {
499
- if (demoInProgress) {
500
- return;
501
- }
502
- if (item.closeOnAction) {
503
- animateToState(ButtonsState.Close, 0);
504
- }
505
- item.onClick();
506
- }, "data-qa": `swipe-button-${left ? 'left' : 'right'}-${index}`, children: jsx("div", { className: styles.buttonContent, ref: handleButtonContentRef(left, isGrow), "data-qa": `swipe-button-content-${left ? 'left' : 'right'}-${index}`, children: jsxs("div", { className: styles.buttonContentColumn, children: [Icon && (jsx("div", { className: styles.iconWrapper, children: jsx(Icon, { ...iconProps }) })), item.showLabel && jsx("span", { className: styles.buttonLabel, children: item.label })] }) }) }, index));
507
- }) }) }));
487
+ ...(side === 'left' ? { justifyContent: 'flex-start', ...leftBlockStyles } : {}),
488
+ ...(side === 'right' ? { justifyContent: 'flex-end', ...rightBlockStyles } : {}),
489
+ }, ref: ref, "data-qa": `swipe-buttons-${side}`, children: [gap && side === 'right' && longState === LongState.Right && jsx("div", { className: styles.gap }), buttons.map((item, index) => {
490
+ if (!item) {
491
+ return null;
492
+ }
493
+ const grow = side === 'left' ? index === 0 : index === buttons.length - 1;
494
+ const hide = (side === 'left' && index !== 0 && longState === LongState.Left) ||
495
+ (side === 'right' && index !== buttons.length - 1 && longState === LongState.Right);
496
+ const Icon = item.icon;
497
+ const iconProps = item.showLabel
498
+ ? { 'aria-hidden': true, focusable: false }
499
+ : { 'aria-label': item.label };
500
+ return (jsxs(Fragment, { children: [gap && side === 'right' && longState !== LongState.Right && (jsx("div", { className: styles.gap })), jsx("div", { className: classNames(styles.buttonWrapper, {
501
+ [styles.buttonWrapperGrow]: grow,
502
+ [styles.buttonWrapperHide]: hide,
503
+ }),
504
+ // это нужно чтобы анимировался длинный свайп.
505
+ // Здесь должно быть значение максимально близкое к тому,
506
+ // какой максимум может занимать одна кнопка, если кнопок больше 1
507
+ style: grow ? { maxWidth: `${swipeContainerWidth}px` } : {}, children: jsx("button", { className: classNames(styles.button, {
508
+ [styles.buttonGrow]: grow,
509
+ [styles[`button_style-${item.style}`]]: item.style,
510
+ }), onClick: () => {
511
+ if (demoInProgress) {
512
+ return;
513
+ }
514
+ if (item.closeOnAction) {
515
+ animateToState(ButtonsState.Close, 0);
516
+ }
517
+ item.onClick();
518
+ }, style: gap ? { borderRadius } : {}, "data-qa": `swipe-button-${side}-${index}`, children: jsx("div", { className: styles.buttonContent, ref: handleButtonContentRef(side, grow), "data-qa": `swipe-button-content-${side}-${index}`, children: jsxs("div", { className: styles.buttonContentColumn, children: [Icon && (jsx("div", { className: styles.iconWrapper, children: jsx(Icon, { ...iconProps }) })), item.showLabel && (jsx("span", { className: styles.buttonLabel, children: item.label }))] }) }) }) }), gap && side === 'left' && jsx("div", { className: styles.gap })] }, index));
519
+ })] }) }));
508
520
  };
509
- if (!isMobile) {
521
+ if (!visible) {
510
522
  return null;
511
523
  }
512
- return (jsx("div", { className: styles.root, ref: rootRef, "data-qa": dataQa ?? 'swipe-root', children: jsxs("div", { className: classNames(styles.swipeble), ref: swipeableRef, ...swipeHandlers, "data-qa": "swipe-swipeable", children: [!!leftButtons?.length && renderButtons(leftButtons, leftButtonsRef, true), jsx("div", { ref: childrenWrapperRef, className: styles.childrenWrapper, children: children }), !!rightButtons?.length && renderButtons(rightButtons, rightButtonsRef, false)] }) }));
524
+ return (jsx("div", { className: styles.fixedContainer, ref: fixedContainerRef, "data-qa": dataQa ?? 'swipe-root', children: jsxs("div", { className: classNames(styles.swipeContainer), ref: swipeContainerRef, ...swipeHandlers, "data-qa": "swipe-swipeable", children: [!!leftButtons?.length && renderButtons(leftButtons, leftButtonsRef, 'left'), jsx("div", { ref: contentRef, className: styles.content, children: children }), !!rightButtons?.length && renderButtons(rightButtons, rightButtonsRef, 'right')] }) }));
513
525
  };
514
526
 
515
527
  export { Swipe };