@hh.ru/magritte-ui-swipe 8.2.47 → 8.2.49

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
@@ -11,517 +11,538 @@ import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
11
11
  import { Layer } from '@hh.ru/magritte-ui-layer';
12
12
  import { SwipeContext } from './context.js';
13
13
 
14
- var styles = {"text":"magritte-text___gUsfc_8-2-47","text_max-lines":"magritte-text_max-lines___foe9-_8-2-47","textMaxLines":"magritte-text_max-lines___foe9-_8-2-47","text-ellipsis":"magritte-text-ellipsis___oTw5J_8-2-47","textEllipsis":"magritte-text-ellipsis___oTw5J_8-2-47","text-nowrap":"magritte-text-nowrap___S5GzV_8-2-47","textNowrap":"magritte-text-nowrap___S5GzV_8-2-47","text-dynamic":"magritte-text-dynamic___KzitV_8-2-47","textDynamic":"magritte-text-dynamic___KzitV_8-2-47","text-dynamic_stretched":"magritte-text-dynamic_stretched___hv3Th_8-2-47","textDynamicStretched":"magritte-text-dynamic_stretched___hv3Th_8-2-47","text_style-primary":"magritte-text_style-primary___vYlpl_8-2-47","textStylePrimary":"magritte-text_style-primary___vYlpl_8-2-47","text-dynamic-disabled":"magritte-text-dynamic-disabled___M1GFt_8-2-47","textDynamicDisabled":"magritte-text-dynamic-disabled___M1GFt_8-2-47","text_style-secondary":"magritte-text_style-secondary___qb-4O_8-2-47","textStyleSecondary":"magritte-text_style-secondary___qb-4O_8-2-47","text_style-tertiary":"magritte-text_style-tertiary___atZvg_8-2-47","textStyleTertiary":"magritte-text_style-tertiary___atZvg_8-2-47","text_style-dense":"magritte-text_style-dense___n493a_8-2-47","textStyleDense":"magritte-text_style-dense___n493a_8-2-47","text_style-accent":"magritte-text_style-accent___JDNe4_8-2-47","textStyleAccent":"magritte-text_style-accent___JDNe4_8-2-47","text_style-accent-secondary":"magritte-text_style-accent-secondary___JM6z5_8-2-47","textStyleAccentSecondary":"magritte-text_style-accent-secondary___JM6z5_8-2-47","text_style-positive":"magritte-text_style-positive___OjJIB_8-2-47","textStylePositive":"magritte-text_style-positive___OjJIB_8-2-47","text_style-positive-secondary":"magritte-text_style-positive-secondary___LkPe1_8-2-47","textStylePositiveSecondary":"magritte-text_style-positive-secondary___LkPe1_8-2-47","text_style-negative":"magritte-text_style-negative___wBLmp_8-2-47","textStyleNegative":"magritte-text_style-negative___wBLmp_8-2-47","text_style-negative-secondary":"magritte-text_style-negative-secondary___CO58y_8-2-47","textStyleNegativeSecondary":"magritte-text_style-negative-secondary___CO58y_8-2-47","text_style-warning":"magritte-text_style-warning___23C3Y_8-2-47","textStyleWarning":"magritte-text_style-warning___23C3Y_8-2-47","text_style-warning-secondary":"magritte-text_style-warning-secondary___ZJ3uf_8-2-47","textStyleWarningSecondary":"magritte-text_style-warning-secondary___ZJ3uf_8-2-47","text_style-special":"magritte-text_style-special___LaqKY_8-2-47","textStyleSpecial":"magritte-text_style-special___LaqKY_8-2-47","text_style-special-secondary":"magritte-text_style-special-secondary___-whB-_8-2-47","textStyleSpecialSecondary":"magritte-text_style-special-secondary___-whB-_8-2-47","text_style-constant":"magritte-text_style-constant___tlPqQ_8-2-47","textStyleConstant":"magritte-text_style-constant___tlPqQ_8-2-47","text_style-constant-secondary":"magritte-text_style-constant-secondary___7aNBk_8-2-47","textStyleConstantSecondary":"magritte-text_style-constant-secondary___7aNBk_8-2-47","text_style-inverse":"magritte-text_style-inverse___HYELZ_8-2-47","textStyleInverse":"magritte-text_style-inverse___HYELZ_8-2-47","text_style-inverse-secondary":"magritte-text_style-inverse-secondary___L83fz_8-2-47","textStyleInverseSecondary":"magritte-text_style-inverse-secondary___L83fz_8-2-47","text_style-lovely":"magritte-text_style-lovely___Z46BQ_8-2-47","textStyleLovely":"magritte-text_style-lovely___Z46BQ_8-2-47","text_style-lovely-secondary":"magritte-text_style-lovely-secondary___QL13-_8-2-47","textStyleLovelySecondary":"magritte-text_style-lovely-secondary___QL13-_8-2-47","text_style-dreamy":"magritte-text_style-dreamy___poXej_8-2-47","textStyleDreamy":"magritte-text_style-dreamy___poXej_8-2-47","text_style-dreamy-secondary":"magritte-text_style-dreamy-secondary___PXO7I_8-2-47","textStyleDreamySecondary":"magritte-text_style-dreamy-secondary___PXO7I_8-2-47","text_style-vivid":"magritte-text_style-vivid___dVXNc_8-2-47","textStyleVivid":"magritte-text_style-vivid___dVXNc_8-2-47","text_style-vivid-secondary":"magritte-text_style-vivid-secondary___O1e2o_8-2-47","textStyleVividSecondary":"magritte-text_style-vivid-secondary___O1e2o_8-2-47","text_typography-title-1-semibold":"magritte-text_typography-title-1-semibold___WDZXM_8-2-47","textTypographyTitle1Semibold":"magritte-text-typography-title-1-semibold___RE-5E_8-2-47","text_typography-title-2-semibold":"magritte-text_typography-title-2-semibold___4PvYn_8-2-47","textTypographyTitle2Semibold":"magritte-text-typography-title-2-semibold___r-gyn_8-2-47","text_typography-title-3-semibold":"magritte-text_typography-title-3-semibold___E7pmd_8-2-47","textTypographyTitle3Semibold":"magritte-text-typography-title-3-semibold___AxOn9_8-2-47","text_typography-title-4-semibold":"magritte-text_typography-title-4-semibold___u-8Kd_8-2-47","textTypographyTitle4Semibold":"magritte-text-typography-title-4-semibold___4FOf2_8-2-47","text_typography-title-5-semibold":"magritte-text_typography-title-5-semibold___PRTQc_8-2-47","textTypographyTitle5Semibold":"magritte-text-typography-title-5-semibold___ayTa0_8-2-47","text_typography-subtitle-1-semibold":"magritte-text_typography-subtitle-1-semibold___TNYKE_8-2-47","textTypographySubtitle1Semibold":"magritte-text_typography-subtitle-1-semibold___TNYKE_8-2-47","text_typography-subtitle-2-semibold":"magritte-text_typography-subtitle-2-semibold___8GJr9_8-2-47","textTypographySubtitle2Semibold":"magritte-text_typography-subtitle-2-semibold___8GJr9_8-2-47","text_typography-subtitle-3-semibold":"magritte-text_typography-subtitle-3-semibold___scHMl_8-2-47","textTypographySubtitle3Semibold":"magritte-text_typography-subtitle-3-semibold___scHMl_8-2-47","text_typography-subtitle-4-semibold":"magritte-text_typography-subtitle-4-semibold___Yr4Bt_8-2-47","textTypographySubtitle4Semibold":"magritte-text_typography-subtitle-4-semibold___Yr4Bt_8-2-47","text_typography-label-1-regular":"magritte-text_typography-label-1-regular___JMO56_8-2-47","textTypographyLabel1Regular":"magritte-text_typography-label-1-regular___JMO56_8-2-47","text_typography-label-2-regular":"magritte-text_typography-label-2-regular___7gS1P_8-2-47","textTypographyLabel2Regular":"magritte-text_typography-label-2-regular___7gS1P_8-2-47","text_typography-label-3-regular":"magritte-text_typography-label-3-regular___DogGv_8-2-47","textTypographyLabel3Regular":"magritte-text_typography-label-3-regular___DogGv_8-2-47","text_typography-label-4-regular":"magritte-text_typography-label-4-regular___TIPoS_8-2-47","textTypographyLabel4Regular":"magritte-text_typography-label-4-regular___TIPoS_8-2-47","text_typography-label-5-regular":"magritte-text_typography-label-5-regular___y55-P_8-2-47","textTypographyLabel5Regular":"magritte-text_typography-label-5-regular___y55-P_8-2-47","text_typography-paragraph-1-regular":"magritte-text_typography-paragraph-1-regular___ZvHBC_8-2-47","textTypographyParagraph1Regular":"magritte-text_typography-paragraph-1-regular___ZvHBC_8-2-47","text_typography-paragraph-2-regular":"magritte-text_typography-paragraph-2-regular___ndKyc_8-2-47","textTypographyParagraph2Regular":"magritte-text_typography-paragraph-2-regular___ndKyc_8-2-47","text_typography-paragraph-3-regular":"magritte-text_typography-paragraph-3-regular___g0oZF_8-2-47","textTypographyParagraph3Regular":"magritte-text_typography-paragraph-3-regular___g0oZF_8-2-47","text_typography-paragraph-4-regular":"magritte-text_typography-paragraph-4-regular___Iy3Zy_8-2-47","textTypographyParagraph4Regular":"magritte-text_typography-paragraph-4-regular___Iy3Zy_8-2-47","text_typography-custom-1-semibold":"magritte-text_typography-custom-1-semibold___Pv6Lp_8-2-47","textTypographyCustom1Semibold":"magritte-text_typography-custom-1-semibold___Pv6Lp_8-2-47","text_typography-custom-2-semibold":"magritte-text_typography-custom-2-semibold___UP1hj_8-2-47","textTypographyCustom2Semibold":"magritte-text_typography-custom-2-semibold___UP1hj_8-2-47","text_typography-custom-3-semibold":"magritte-text_typography-custom-3-semibold___6yO4m_8-2-47","textTypographyCustom3Semibold":"magritte-text_typography-custom-3-semibold___6yO4m_8-2-47","text_typography-custom-4-semibold":"magritte-text_typography-custom-4-semibold___NEahp_8-2-47","textTypographyCustom4Semibold":"magritte-text_typography-custom-4-semibold___NEahp_8-2-47","text_typography-custom-5-semibold":"magritte-text_typography-custom-5-semibold___-UJfV_8-2-47","textTypographyCustom5Semibold":"magritte-text_typography-custom-5-semibold___-UJfV_8-2-47","text_typography-custom-1-italic":"magritte-text_typography-custom-1-italic___-CpMs_8-2-47","textTypographyCustom1Italic":"magritte-text_typography-custom-1-italic___-CpMs_8-2-47","text_typography-custom-2-italic":"magritte-text_typography-custom-2-italic___SvOG4_8-2-47","textTypographyCustom2Italic":"magritte-text_typography-custom-2-italic___SvOG4_8-2-47","text_typography-custom-3-italic":"magritte-text_typography-custom-3-italic___-g0na_8-2-47","textTypographyCustom3Italic":"magritte-text_typography-custom-3-italic___-g0na_8-2-47","text_typography-custom-4-italic":"magritte-text_typography-custom-4-italic___gOGey_8-2-47","textTypographyCustom4Italic":"magritte-text_typography-custom-4-italic___gOGey_8-2-47","text_typography-custom-5-italic":"magritte-text_typography-custom-5-italic___VR9wy_8-2-47","textTypographyCustom5Italic":"magritte-text_typography-custom-5-italic___VR9wy_8-2-47","text_typography-custom-1-medium":"magritte-text_typography-custom-1-medium___hik0e_8-2-47","textTypographyCustom1Medium":"magritte-text_typography-custom-1-medium___hik0e_8-2-47","text_typography-custom-2-medium":"magritte-text_typography-custom-2-medium___-f6Sh_8-2-47","textTypographyCustom2Medium":"magritte-text_typography-custom-2-medium___-f6Sh_8-2-47","text_typography-custom-3-medium":"magritte-text_typography-custom-3-medium___pLvIb_8-2-47","textTypographyCustom3Medium":"magritte-text_typography-custom-3-medium___pLvIb_8-2-47","text_typography-custom-4-medium":"magritte-text_typography-custom-4-medium___zZteM_8-2-47","textTypographyCustom4Medium":"magritte-text_typography-custom-4-medium___zZteM_8-2-47","text_typography-custom-5-medium":"magritte-text_typography-custom-5-medium___gW1Y8_8-2-47","textTypographyCustom5Medium":"magritte-text_typography-custom-5-medium___gW1Y8_8-2-47","text_typography-display-1-display":"magritte-text_typography-display-1-display___74lcX_8-2-47","textTypographyDisplay1Display":"magritte-text_typography-display-1-display___74lcX_8-2-47","text_typography-display-2-display":"magritte-text_typography-display-2-display___naML1_8-2-47","textTypographyDisplay2Display":"magritte-text_typography-display-2-display___naML1_8-2-47","text_typography-display-3-display":"magritte-text_typography-display-3-display___EYcBk_8-2-47","textTypographyDisplay3Display":"magritte-text_typography-display-3-display___EYcBk_8-2-47","text_typography-display-4-display":"magritte-text_typography-display-4-display___2oLzQ_8-2-47","textTypographyDisplay4Display":"magritte-text_typography-display-4-display___2oLzQ_8-2-47","text_typography-display-5-display":"magritte-text_typography-display-5-display___S5wBT_8-2-47","textTypographyDisplay5Display":"magritte-text_typography-display-5-display___S5wBT_8-2-47","text_typography-display-6-display":"magritte-text_typography-display-6-display___mhZQp_8-2-47","textTypographyDisplay6Display":"magritte-text_typography-display-6-display___mhZQp_8-2-47","text_typography-display-7-display":"magritte-text_typography-display-7-display___4O6kW_8-2-47","textTypographyDisplay7Display":"magritte-text_typography-display-7-display___4O6kW_8-2-47","text_typography-display-8-display":"magritte-text_typography-display-8-display___HkNzC_8-2-47","textTypographyDisplay8Display":"magritte-text_typography-display-8-display___HkNzC_8-2-47","text-typography-title-1-semibold":"magritte-text-typography-title-1-semibold___RE-5E_8-2-47","text-typography-title-2-semibold":"magritte-text-typography-title-2-semibold___r-gyn_8-2-47","text-typography-title-3-semibold":"magritte-text-typography-title-3-semibold___AxOn9_8-2-47","text-typography-title-4-semibold":"magritte-text-typography-title-4-semibold___4FOf2_8-2-47","text-typography-title-5-semibold":"magritte-text-typography-title-5-semibold___ayTa0_8-2-47","fixed-container":"magritte-fixed-container___gruvI_8-2-47","fixedContainer":"magritte-fixed-container___gruvI_8-2-47","swipe-container":"magritte-swipe-container___HCz0Y_8-2-47","swipeContainer":"magritte-swipe-container___HCz0Y_8-2-47","content":"magritte-content___oKEcs_8-2-47","buttons":"magritte-buttons___PHNdL_8-2-47","swipe-container_in-progress":"magritte-swipe-container_in-progress___D4pLw_8-2-47","swipeContainerInProgress":"magritte-swipe-container_in-progress___D4pLw_8-2-47","left-buttons-animation":"magritte-left-buttons-animation___KnKbA_8-2-47","leftButtonsAnimation":"magritte-left-buttons-animation___KnKbA_8-2-47","right-buttons-animation":"magritte-right-buttons-animation___Wgsss_8-2-47","rightButtonsAnimation":"magritte-right-buttons-animation___Wgsss_8-2-47","button-wrapper":"magritte-button-wrapper___fp3-5_8-2-47","buttonWrapper":"magritte-button-wrapper___fp3-5_8-2-47","button-wrapper-hide":"magritte-button-wrapper-hide___MN7-s_8-2-47","buttonWrapperHide":"magritte-button-wrapper-hide___MN7-s_8-2-47","button-wrapper-grow":"magritte-button-wrapper-grow___-hbrz_8-2-47","buttonWrapperGrow":"magritte-button-wrapper-grow___-hbrz_8-2-47","button":"magritte-button___jZvyY_8-2-47","button-grow":"magritte-button-grow___IT4MK_8-2-47","buttonGrow":"magritte-button-grow___IT4MK_8-2-47","gap":"magritte-gap___3z9to_8-2-47","button-content":"magritte-button-content___hlzd-_8-2-47","buttonContent":"magritte-button-content___hlzd-_8-2-47","button-content-column":"magritte-button-content-column___48Tzo_8-2-47","buttonContentColumn":"magritte-button-content-column___48Tzo_8-2-47","button-label":"magritte-button-label___l03VO_8-2-47","buttonLabel":"magritte-button-label___l03VO_8-2-47","button_style-neutral":"magritte-button_style-neutral___1yyqh_8-2-47","buttonStyleNeutral":"magritte-button_style-neutral___1yyqh_8-2-47","button_style-accent":"magritte-button_style-accent___L9krS_8-2-47","buttonStyleAccent":"magritte-button_style-accent___L9krS_8-2-47","button_style-positive":"magritte-button_style-positive___2pgae_8-2-47","buttonStylePositive":"magritte-button_style-positive___2pgae_8-2-47","button_style-negative":"magritte-button_style-negative___UClE4_8-2-47","buttonStyleNegative":"magritte-button_style-negative___UClE4_8-2-47","button_style-special":"magritte-button_style-special___sGvAc_8-2-47","buttonStyleSpecial":"magritte-button_style-special___sGvAc_8-2-47","button_style-warning":"magritte-button_style-warning___5bEK0_8-2-47","buttonStyleWarning":"magritte-button_style-warning___5bEK0_8-2-47","icon-wrapper":"magritte-icon-wrapper___0xJZX_8-2-47","iconWrapper":"magritte-icon-wrapper___0xJZX_8-2-47"};
14
+ var styles = {"text":"magritte-text___gUsfc_8-2-49","text_max-lines":"magritte-text_max-lines___foe9-_8-2-49","textMaxLines":"magritte-text_max-lines___foe9-_8-2-49","text-ellipsis":"magritte-text-ellipsis___oTw5J_8-2-49","textEllipsis":"magritte-text-ellipsis___oTw5J_8-2-49","text-nowrap":"magritte-text-nowrap___S5GzV_8-2-49","textNowrap":"magritte-text-nowrap___S5GzV_8-2-49","text-dynamic":"magritte-text-dynamic___KzitV_8-2-49","textDynamic":"magritte-text-dynamic___KzitV_8-2-49","text-dynamic_stretched":"magritte-text-dynamic_stretched___hv3Th_8-2-49","textDynamicStretched":"magritte-text-dynamic_stretched___hv3Th_8-2-49","text_style-primary":"magritte-text_style-primary___vYlpl_8-2-49","textStylePrimary":"magritte-text_style-primary___vYlpl_8-2-49","text-dynamic-disabled":"magritte-text-dynamic-disabled___M1GFt_8-2-49","textDynamicDisabled":"magritte-text-dynamic-disabled___M1GFt_8-2-49","text_style-secondary":"magritte-text_style-secondary___qb-4O_8-2-49","textStyleSecondary":"magritte-text_style-secondary___qb-4O_8-2-49","text_style-tertiary":"magritte-text_style-tertiary___atZvg_8-2-49","textStyleTertiary":"magritte-text_style-tertiary___atZvg_8-2-49","text_style-dense":"magritte-text_style-dense___n493a_8-2-49","textStyleDense":"magritte-text_style-dense___n493a_8-2-49","text_style-accent":"magritte-text_style-accent___JDNe4_8-2-49","textStyleAccent":"magritte-text_style-accent___JDNe4_8-2-49","text_style-accent-secondary":"magritte-text_style-accent-secondary___JM6z5_8-2-49","textStyleAccentSecondary":"magritte-text_style-accent-secondary___JM6z5_8-2-49","text_style-positive":"magritte-text_style-positive___OjJIB_8-2-49","textStylePositive":"magritte-text_style-positive___OjJIB_8-2-49","text_style-positive-secondary":"magritte-text_style-positive-secondary___LkPe1_8-2-49","textStylePositiveSecondary":"magritte-text_style-positive-secondary___LkPe1_8-2-49","text_style-negative":"magritte-text_style-negative___wBLmp_8-2-49","textStyleNegative":"magritte-text_style-negative___wBLmp_8-2-49","text_style-negative-secondary":"magritte-text_style-negative-secondary___CO58y_8-2-49","textStyleNegativeSecondary":"magritte-text_style-negative-secondary___CO58y_8-2-49","text_style-warning":"magritte-text_style-warning___23C3Y_8-2-49","textStyleWarning":"magritte-text_style-warning___23C3Y_8-2-49","text_style-warning-secondary":"magritte-text_style-warning-secondary___ZJ3uf_8-2-49","textStyleWarningSecondary":"magritte-text_style-warning-secondary___ZJ3uf_8-2-49","text_style-special":"magritte-text_style-special___LaqKY_8-2-49","textStyleSpecial":"magritte-text_style-special___LaqKY_8-2-49","text_style-special-secondary":"magritte-text_style-special-secondary___-whB-_8-2-49","textStyleSpecialSecondary":"magritte-text_style-special-secondary___-whB-_8-2-49","text_style-constant":"magritte-text_style-constant___tlPqQ_8-2-49","textStyleConstant":"magritte-text_style-constant___tlPqQ_8-2-49","text_style-constant-secondary":"magritte-text_style-constant-secondary___7aNBk_8-2-49","textStyleConstantSecondary":"magritte-text_style-constant-secondary___7aNBk_8-2-49","text_style-inverse":"magritte-text_style-inverse___HYELZ_8-2-49","textStyleInverse":"magritte-text_style-inverse___HYELZ_8-2-49","text_style-inverse-secondary":"magritte-text_style-inverse-secondary___L83fz_8-2-49","textStyleInverseSecondary":"magritte-text_style-inverse-secondary___L83fz_8-2-49","text_style-lovely":"magritte-text_style-lovely___Z46BQ_8-2-49","textStyleLovely":"magritte-text_style-lovely___Z46BQ_8-2-49","text_style-lovely-secondary":"magritte-text_style-lovely-secondary___QL13-_8-2-49","textStyleLovelySecondary":"magritte-text_style-lovely-secondary___QL13-_8-2-49","text_style-dreamy":"magritte-text_style-dreamy___poXej_8-2-49","textStyleDreamy":"magritte-text_style-dreamy___poXej_8-2-49","text_style-dreamy-secondary":"magritte-text_style-dreamy-secondary___PXO7I_8-2-49","textStyleDreamySecondary":"magritte-text_style-dreamy-secondary___PXO7I_8-2-49","text_style-vivid":"magritte-text_style-vivid___dVXNc_8-2-49","textStyleVivid":"magritte-text_style-vivid___dVXNc_8-2-49","text_style-vivid-secondary":"magritte-text_style-vivid-secondary___O1e2o_8-2-49","textStyleVividSecondary":"magritte-text_style-vivid-secondary___O1e2o_8-2-49","text_typography-title-1-semibold":"magritte-text_typography-title-1-semibold___WDZXM_8-2-49","textTypographyTitle1Semibold":"magritte-text-typography-title-1-semibold___RE-5E_8-2-49","text_typography-title-2-semibold":"magritte-text_typography-title-2-semibold___4PvYn_8-2-49","textTypographyTitle2Semibold":"magritte-text-typography-title-2-semibold___r-gyn_8-2-49","text_typography-title-3-semibold":"magritte-text_typography-title-3-semibold___E7pmd_8-2-49","textTypographyTitle3Semibold":"magritte-text-typography-title-3-semibold___AxOn9_8-2-49","text_typography-title-4-semibold":"magritte-text_typography-title-4-semibold___u-8Kd_8-2-49","textTypographyTitle4Semibold":"magritte-text-typography-title-4-semibold___4FOf2_8-2-49","text_typography-title-5-semibold":"magritte-text_typography-title-5-semibold___PRTQc_8-2-49","textTypographyTitle5Semibold":"magritte-text-typography-title-5-semibold___ayTa0_8-2-49","text_typography-subtitle-1-semibold":"magritte-text_typography-subtitle-1-semibold___TNYKE_8-2-49","textTypographySubtitle1Semibold":"magritte-text_typography-subtitle-1-semibold___TNYKE_8-2-49","text_typography-subtitle-2-semibold":"magritte-text_typography-subtitle-2-semibold___8GJr9_8-2-49","textTypographySubtitle2Semibold":"magritte-text_typography-subtitle-2-semibold___8GJr9_8-2-49","text_typography-subtitle-3-semibold":"magritte-text_typography-subtitle-3-semibold___scHMl_8-2-49","textTypographySubtitle3Semibold":"magritte-text_typography-subtitle-3-semibold___scHMl_8-2-49","text_typography-subtitle-4-semibold":"magritte-text_typography-subtitle-4-semibold___Yr4Bt_8-2-49","textTypographySubtitle4Semibold":"magritte-text_typography-subtitle-4-semibold___Yr4Bt_8-2-49","text_typography-label-1-regular":"magritte-text_typography-label-1-regular___JMO56_8-2-49","textTypographyLabel1Regular":"magritte-text_typography-label-1-regular___JMO56_8-2-49","text_typography-label-2-regular":"magritte-text_typography-label-2-regular___7gS1P_8-2-49","textTypographyLabel2Regular":"magritte-text_typography-label-2-regular___7gS1P_8-2-49","text_typography-label-3-regular":"magritte-text_typography-label-3-regular___DogGv_8-2-49","textTypographyLabel3Regular":"magritte-text_typography-label-3-regular___DogGv_8-2-49","text_typography-label-4-regular":"magritte-text_typography-label-4-regular___TIPoS_8-2-49","textTypographyLabel4Regular":"magritte-text_typography-label-4-regular___TIPoS_8-2-49","text_typography-label-5-regular":"magritte-text_typography-label-5-regular___y55-P_8-2-49","textTypographyLabel5Regular":"magritte-text_typography-label-5-regular___y55-P_8-2-49","text_typography-paragraph-1-regular":"magritte-text_typography-paragraph-1-regular___ZvHBC_8-2-49","textTypographyParagraph1Regular":"magritte-text_typography-paragraph-1-regular___ZvHBC_8-2-49","text_typography-paragraph-2-regular":"magritte-text_typography-paragraph-2-regular___ndKyc_8-2-49","textTypographyParagraph2Regular":"magritte-text_typography-paragraph-2-regular___ndKyc_8-2-49","text_typography-paragraph-3-regular":"magritte-text_typography-paragraph-3-regular___g0oZF_8-2-49","textTypographyParagraph3Regular":"magritte-text_typography-paragraph-3-regular___g0oZF_8-2-49","text_typography-paragraph-4-regular":"magritte-text_typography-paragraph-4-regular___Iy3Zy_8-2-49","textTypographyParagraph4Regular":"magritte-text_typography-paragraph-4-regular___Iy3Zy_8-2-49","text_typography-custom-1-semibold":"magritte-text_typography-custom-1-semibold___Pv6Lp_8-2-49","textTypographyCustom1Semibold":"magritte-text_typography-custom-1-semibold___Pv6Lp_8-2-49","text_typography-custom-2-semibold":"magritte-text_typography-custom-2-semibold___UP1hj_8-2-49","textTypographyCustom2Semibold":"magritte-text_typography-custom-2-semibold___UP1hj_8-2-49","text_typography-custom-3-semibold":"magritte-text_typography-custom-3-semibold___6yO4m_8-2-49","textTypographyCustom3Semibold":"magritte-text_typography-custom-3-semibold___6yO4m_8-2-49","text_typography-custom-4-semibold":"magritte-text_typography-custom-4-semibold___NEahp_8-2-49","textTypographyCustom4Semibold":"magritte-text_typography-custom-4-semibold___NEahp_8-2-49","text_typography-custom-5-semibold":"magritte-text_typography-custom-5-semibold___-UJfV_8-2-49","textTypographyCustom5Semibold":"magritte-text_typography-custom-5-semibold___-UJfV_8-2-49","text_typography-custom-1-italic":"magritte-text_typography-custom-1-italic___-CpMs_8-2-49","textTypographyCustom1Italic":"magritte-text_typography-custom-1-italic___-CpMs_8-2-49","text_typography-custom-2-italic":"magritte-text_typography-custom-2-italic___SvOG4_8-2-49","textTypographyCustom2Italic":"magritte-text_typography-custom-2-italic___SvOG4_8-2-49","text_typography-custom-3-italic":"magritte-text_typography-custom-3-italic___-g0na_8-2-49","textTypographyCustom3Italic":"magritte-text_typography-custom-3-italic___-g0na_8-2-49","text_typography-custom-4-italic":"magritte-text_typography-custom-4-italic___gOGey_8-2-49","textTypographyCustom4Italic":"magritte-text_typography-custom-4-italic___gOGey_8-2-49","text_typography-custom-5-italic":"magritte-text_typography-custom-5-italic___VR9wy_8-2-49","textTypographyCustom5Italic":"magritte-text_typography-custom-5-italic___VR9wy_8-2-49","text_typography-custom-1-medium":"magritte-text_typography-custom-1-medium___hik0e_8-2-49","textTypographyCustom1Medium":"magritte-text_typography-custom-1-medium___hik0e_8-2-49","text_typography-custom-2-medium":"magritte-text_typography-custom-2-medium___-f6Sh_8-2-49","textTypographyCustom2Medium":"magritte-text_typography-custom-2-medium___-f6Sh_8-2-49","text_typography-custom-3-medium":"magritte-text_typography-custom-3-medium___pLvIb_8-2-49","textTypographyCustom3Medium":"magritte-text_typography-custom-3-medium___pLvIb_8-2-49","text_typography-custom-4-medium":"magritte-text_typography-custom-4-medium___zZteM_8-2-49","textTypographyCustom4Medium":"magritte-text_typography-custom-4-medium___zZteM_8-2-49","text_typography-custom-5-medium":"magritte-text_typography-custom-5-medium___gW1Y8_8-2-49","textTypographyCustom5Medium":"magritte-text_typography-custom-5-medium___gW1Y8_8-2-49","text_typography-display-1-display":"magritte-text_typography-display-1-display___74lcX_8-2-49","textTypographyDisplay1Display":"magritte-text_typography-display-1-display___74lcX_8-2-49","text_typography-display-2-display":"magritte-text_typography-display-2-display___naML1_8-2-49","textTypographyDisplay2Display":"magritte-text_typography-display-2-display___naML1_8-2-49","text_typography-display-3-display":"magritte-text_typography-display-3-display___EYcBk_8-2-49","textTypographyDisplay3Display":"magritte-text_typography-display-3-display___EYcBk_8-2-49","text_typography-display-4-display":"magritte-text_typography-display-4-display___2oLzQ_8-2-49","textTypographyDisplay4Display":"magritte-text_typography-display-4-display___2oLzQ_8-2-49","text_typography-display-5-display":"magritte-text_typography-display-5-display___S5wBT_8-2-49","textTypographyDisplay5Display":"magritte-text_typography-display-5-display___S5wBT_8-2-49","text_typography-display-6-display":"magritte-text_typography-display-6-display___mhZQp_8-2-49","textTypographyDisplay6Display":"magritte-text_typography-display-6-display___mhZQp_8-2-49","text_typography-display-7-display":"magritte-text_typography-display-7-display___4O6kW_8-2-49","textTypographyDisplay7Display":"magritte-text_typography-display-7-display___4O6kW_8-2-49","text_typography-display-8-display":"magritte-text_typography-display-8-display___HkNzC_8-2-49","textTypographyDisplay8Display":"magritte-text_typography-display-8-display___HkNzC_8-2-49","text-typography-title-1-semibold":"magritte-text-typography-title-1-semibold___RE-5E_8-2-49","text-typography-title-2-semibold":"magritte-text-typography-title-2-semibold___r-gyn_8-2-49","text-typography-title-3-semibold":"magritte-text-typography-title-3-semibold___AxOn9_8-2-49","text-typography-title-4-semibold":"magritte-text-typography-title-4-semibold___4FOf2_8-2-49","text-typography-title-5-semibold":"magritte-text-typography-title-5-semibold___ayTa0_8-2-49","fixed-container":"magritte-fixed-container___gruvI_8-2-49","fixedContainer":"magritte-fixed-container___gruvI_8-2-49","swipe-container":"magritte-swipe-container___HCz0Y_8-2-49","swipeContainer":"magritte-swipe-container___HCz0Y_8-2-49","content":"magritte-content___oKEcs_8-2-49","buttons":"magritte-buttons___PHNdL_8-2-49","swipe-container_in-progress":"magritte-swipe-container_in-progress___D4pLw_8-2-49","swipeContainerInProgress":"magritte-swipe-container_in-progress___D4pLw_8-2-49","left-buttons-animation":"magritte-left-buttons-animation___KnKbA_8-2-49","leftButtonsAnimation":"magritte-left-buttons-animation___KnKbA_8-2-49","right-buttons-animation":"magritte-right-buttons-animation___Wgsss_8-2-49","rightButtonsAnimation":"magritte-right-buttons-animation___Wgsss_8-2-49","button-wrapper":"magritte-button-wrapper___fp3-5_8-2-49","buttonWrapper":"magritte-button-wrapper___fp3-5_8-2-49","button-wrapper-hide":"magritte-button-wrapper-hide___MN7-s_8-2-49","buttonWrapperHide":"magritte-button-wrapper-hide___MN7-s_8-2-49","button-wrapper-grow":"magritte-button-wrapper-grow___-hbrz_8-2-49","buttonWrapperGrow":"magritte-button-wrapper-grow___-hbrz_8-2-49","button":"magritte-button___jZvyY_8-2-49","button-grow":"magritte-button-grow___IT4MK_8-2-49","buttonGrow":"magritte-button-grow___IT4MK_8-2-49","gap":"magritte-gap___3z9to_8-2-49","button-content":"magritte-button-content___hlzd-_8-2-49","buttonContent":"magritte-button-content___hlzd-_8-2-49","button-content-column":"magritte-button-content-column___48Tzo_8-2-49","buttonContentColumn":"magritte-button-content-column___48Tzo_8-2-49","button-label":"magritte-button-label___l03VO_8-2-49","buttonLabel":"magritte-button-label___l03VO_8-2-49","button_style-neutral":"magritte-button_style-neutral___1yyqh_8-2-49","buttonStyleNeutral":"magritte-button_style-neutral___1yyqh_8-2-49","button_style-accent":"magritte-button_style-accent___L9krS_8-2-49","buttonStyleAccent":"magritte-button_style-accent___L9krS_8-2-49","button_style-positive":"magritte-button_style-positive___2pgae_8-2-49","buttonStylePositive":"magritte-button_style-positive___2pgae_8-2-49","button_style-negative":"magritte-button_style-negative___UClE4_8-2-49","buttonStyleNegative":"magritte-button_style-negative___UClE4_8-2-49","button_style-special":"magritte-button_style-special___sGvAc_8-2-49","buttonStyleSpecial":"magritte-button_style-special___sGvAc_8-2-49","button_style-warning":"magritte-button_style-warning___5bEK0_8-2-49","buttonStyleWarning":"magritte-button_style-warning___5bEK0_8-2-49","icon-wrapper":"magritte-icon-wrapper___0xJZX_8-2-49","iconWrapper":"magritte-icon-wrapper___0xJZX_8-2-49"};
15
15
 
16
16
  const MIN_BUTTON_WIDTH = 76;
17
17
  const OPEN_THRESHOLD = 1 / 3;
18
18
  const MIN_SWIPE_DISTANCE = MIN_BUTTON_WIDTH * OPEN_THRESHOLD;
19
19
  const GAP_WIDTH = 16;
20
- var ButtonsState;
21
- (function (ButtonsState) {
22
- ButtonsState["Close"] = "close";
23
- ButtonsState["LeftOpen"] = "leftOpen";
24
- ButtonsState["RightOpen"] = "rightOpen";
25
- })(ButtonsState || (ButtonsState = {}));
26
- var LongState;
27
- (function (LongState) {
28
- LongState["Off"] = "off";
29
- LongState["Left"] = "left";
30
- LongState["Right"] = "right";
31
- })(LongState || (LongState = {}));
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);
37
- const leftButtonsRef = useRef(null);
38
- const rightButtonsRef = useRef(null);
39
- const sumRefs = useRef([]); // ссылки на кнопки, по которым считается реальный размер
40
- const leftButtonsSumSizeRef = useRef(0); // реальный размер, требуемый левым кнопкам
41
- const rightButtonsSumSizeRef = useRef(0); // реальный размер, требуемый правым кнопкам
42
- const leftButtonsSizeRef = useRef(0); // установленный размер левых кнопок
43
- const rigthButtonsSizeRef = useRef(0); // установленный размер правых кнопок
44
- const prevDistance = useRef(0);
45
- const swipeThresholdRef = useRef({ max: MIN_SWIPE_DISTANCE });
46
- const swipeLockRef = useRef(false);
47
- const { isMobile } = useBreakpoint();
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 }));
53
- const [longState, setLongState] = useState(LongState.Off);
54
- const stateRef = useRef({
55
- candidate: ButtonsState.Close, // предполагаемое состояние, нужно чтобы нельзя было двигать влево-вправо за один раз
56
- now: ButtonsState.Close, // текущее состояние
57
- next: ButtonsState.Close, // следующее состояние, после завершения свайпа
58
- });
59
- const [demoInProgress, setDemoInProgress] = useState(false);
60
- const setAnimateButtonsWidth = useCallback((flag) => {
61
- if (leftButtonsRef.current) {
62
- leftButtonsRef.current.style.transitionProperty = flag ? 'width' : 'none';
63
- }
64
- if (rightButtonsRef.current) {
65
- rightButtonsRef.current.style.transitionProperty = flag ? 'width' : 'none';
66
- }
67
- }, []);
68
- const recalcSwipeContainerWidth = useCallback(() => {
69
- if (swipeContainerRef.current && contentRef.current && fixedContainerRef.current) {
70
- const width = Math.round(fixedContainerRef.current.getBoundingClientRect().width);
71
- // устанавливаем размер области равной размеру контента,
72
- // чтобы она не растягивалась, когда растягиваются кнопки
73
- setSwipeContainerWidth(width);
74
- swipeContainerRef.current.style.width = `${width}px`;
75
- contentRef.current.style.width = `${width}px`;
76
- contentRef.current.style.minWidth = `${width}px`;
77
- }
78
- }, [setSwipeContainerWidth]);
79
- useEffect(() => {
80
- if (visible) {
81
- recalcSwipeContainerWidth();
82
- }
83
- }, [visible, recalcSwipeContainerWidth]);
84
- useResize(useDebounce(recalcSwipeContainerWidth, 50));
85
- // обновляет порог срабатывания для useSwipe в зависимости от состояния
86
- const updateSwipeThreshold = useCallback(() => {
87
- const { now, candidate } = stateRef.current;
88
- // если открыта одна из сторон, то мы можем свайпнуть к закрытию, или к активации длинного свайпа
89
- if ([ButtonsState.LeftOpen, ButtonsState.RightOpen].includes(now)) {
90
- swipeThresholdRef.current =
91
- now === ButtonsState.LeftOpen
92
- ? {
93
- // свайп к закрытию
94
- minDelta: -MIN_SWIPE_DISTANCE,
95
- // свайп к активации длинного свайпа
96
- maxDelta: useLongSwipe ? MIN_SWIPE_DISTANCE : Number.MAX_SAFE_INTEGER,
97
- }
98
- : {
99
- // свайп к закрытию
100
- maxDelta: MIN_SWIPE_DISTANCE,
101
- // свайп к активации длинного свайпа
102
- minDelta: useLongSwipe ? -MIN_SWIPE_DISTANCE : -Number.MAX_SAFE_INTEGER,
103
- };
104
- }
105
- else if (candidate === ButtonsState.LeftOpen) {
106
- // если кандидат на открытие слева, то мы можем свайпнуть к открытию слева
107
- swipeThresholdRef.current = { maxDelta: MIN_SWIPE_DISTANCE };
108
- }
109
- else if (candidate === ButtonsState.RightOpen) {
110
- // если кандидат на открытие справа, то мы можем свайпнуть к открытию справа, дельта с отрицательным знаком
111
- // потому что свайпаем вправо
112
- swipeThresholdRef.current = { minDelta: -MIN_SWIPE_DISTANCE };
113
- }
114
- }, [useLongSwipe]);
115
- // анимирует размер кнопок для перехода в переданное состояние
116
- const animateToState = useCallback((toState, velocity) => {
117
- leftBlockApi.stop();
118
- rightBlockApi.stop();
119
- stateRef.current.now = toState;
120
- const animationConfig = {
121
- width: 0,
122
- config: {
123
- ...config.gentle,
124
- clamp: true,
125
- velocity: 0,
126
- },
127
- };
128
- let api;
129
- // если нужно закрыть кнопки, то сначала определяем с какой стороны кнопки открыты
130
- // получаем апи для акнимации кнопок с нужной стороны
131
- // вычисляем начальную скорость, т.к. анимация закрытия кнопок с разных сторон направлена в разные стороны
132
- // то для правой стороны нужно поменять знак начальной скорости
133
- if (toState === ButtonsState.Close) {
134
- const fromLeft = leftBlockApi.current[0].get().width > 0;
135
- api = fromLeft ? leftBlockApi : rightBlockApi;
136
- const v = fromLeft ? velocity : -velocity;
137
- // скорость делим на 1000 т.к. в событии приходит скорость в пикселях в секунду
138
- // а нужна в пикселях в миллисекунду
139
- animationConfig.config.velocity = v / 1000;
140
- }
141
- else {
142
- // если нужно открыть кнопки, то получаем апи для анимации блока кнопок с нужной стороны
143
- // вычисляем начальную скорость, т.к. анимация открытия кнопок с разных сторон направлена в разные стороны
144
- // то для правой стороны нужно поменять знак начальной скорости
145
- api = toState === ButtonsState.LeftOpen ? leftBlockApi : rightBlockApi;
146
- const v = toState === ButtonsState.LeftOpen ? velocity : -velocity;
147
- animationConfig.width = Math.min(swipeContainerWidth, (toState === ButtonsState.LeftOpen ? leftButtonsSumSizeRef : rightButtonsSumSizeRef).current);
148
- animationConfig.config.velocity = v / 1000;
149
- }
150
- void api.start(animationConfig)[0].then(({ finished }) => {
151
- if (finished) {
152
- stateRef.current.candidate = ButtonsState.Close;
153
- if (swipeContainerRef.current !== null) {
154
- swipeContainerRef.current.classList.remove(styles.swipeContainerInProgress);
155
- }
156
- }
157
- });
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]);
168
- const handleSwipeStart = useCallback(() => {
169
- if (demoInProgress || swipeLockRef.current) {
170
- return;
171
- }
172
- rightBlockApi.stop();
173
- leftBlockApi.stop();
174
- onStart?.();
175
- onResetDemo?.();
20
+ const Swipe = ({
21
+ children,
22
+ leftButtons,
23
+ rightButtons,
24
+ onStart,
25
+ onFinish,
26
+ useLongSwipe = true,
27
+ "data-qa": dataQa,
28
+ demo = false,
29
+ twoSidedDemoMode = "right-to-left",
30
+ demoAppearTime = 200,
31
+ demoIdleTime = 300,
32
+ demoDisappearTime = 200,
33
+ onFinishDemo,
34
+ onStartDemo,
35
+ onResetDemo,
36
+ gap = false,
37
+ borderRadius
38
+ }) => {
39
+ const fixedContainerRef = useRef(null);
40
+ const swipeContainerRef = useRef(null);
41
+ const contentRef = useRef(null);
42
+ const [swipeContainerWidth, setSwipeContainerWidth] = useState(0);
43
+ const leftButtonsRef = useRef(null);
44
+ const rightButtonsRef = useRef(null);
45
+ const sumRefs = useRef([]);
46
+ const leftButtonsSumSizeRef = useRef(0);
47
+ const rightButtonsSumSizeRef = useRef(0);
48
+ const leftButtonsSizeRef = useRef(0);
49
+ const rigthButtonsSizeRef = useRef(0);
50
+ const prevDistance = useRef(0);
51
+ const swipeThresholdRef = useRef({ max: MIN_SWIPE_DISTANCE });
52
+ const swipeLockRef = useRef(false);
53
+ const { isMobile } = useBreakpoint();
54
+ const [isFontLoaded, setFontLoaded] = useState(false);
55
+ const visible = isMobile && isFontLoaded;
56
+ useWhenFontLoaded(() => setFontLoaded(true));
57
+ const [leftBlockStyles, leftBlockApi] = useSpring(() => ({ width: 0 }));
58
+ const [rightBlockStyles, rightBlockApi] = useSpring(() => ({ width: 0 }));
59
+ const [longState, setLongState] = useState("off" /* Off */);
60
+ const stateRef = useRef({
61
+ candidate: "close" /* Close */,
62
+ // предполагаемое состояние, нужно чтобы нельзя было двигать влево-вправо за один раз
63
+ now: "close" /* Close */,
64
+ // текущее состояние
65
+ next: "close" /* Close */
66
+ // следующее состояние, после завершения свайпа
67
+ });
68
+ const [demoInProgress, setDemoInProgress] = useState(false);
69
+ const setAnimateButtonsWidth = useCallback((flag) => {
70
+ if (leftButtonsRef.current) {
71
+ leftButtonsRef.current.style.transitionProperty = flag ? "width" : "none";
72
+ }
73
+ if (rightButtonsRef.current) {
74
+ rightButtonsRef.current.style.transitionProperty = flag ? "width" : "none";
75
+ }
76
+ }, []);
77
+ const recalcSwipeContainerWidth = useCallback(() => {
78
+ if (swipeContainerRef.current && contentRef.current && fixedContainerRef.current) {
79
+ const width = Math.round(fixedContainerRef.current.getBoundingClientRect().width);
80
+ setSwipeContainerWidth(width);
81
+ swipeContainerRef.current.style.width = `${width}px`;
82
+ contentRef.current.style.width = `${width}px`;
83
+ contentRef.current.style.minWidth = `${width}px`;
84
+ }
85
+ }, [setSwipeContainerWidth]);
86
+ useEffect(() => {
87
+ if (visible) {
88
+ recalcSwipeContainerWidth();
89
+ }
90
+ }, [visible, recalcSwipeContainerWidth]);
91
+ useResize(useDebounce(recalcSwipeContainerWidth, 50));
92
+ const updateSwipeThreshold = useCallback(() => {
93
+ const { now, candidate } = stateRef.current;
94
+ if (["leftOpen" /* LeftOpen */, "rightOpen" /* RightOpen */].includes(now)) {
95
+ swipeThresholdRef.current = now === "leftOpen" /* LeftOpen */ ? {
96
+ // свайп к закрытию
97
+ minDelta: -MIN_SWIPE_DISTANCE,
98
+ // свайп к активации длинного свайпа
99
+ maxDelta: useLongSwipe ? MIN_SWIPE_DISTANCE : Number.MAX_SAFE_INTEGER
100
+ } : {
101
+ // свайп к закрытию
102
+ maxDelta: MIN_SWIPE_DISTANCE,
103
+ // свайп к активации длинного свайпа
104
+ minDelta: useLongSwipe ? -MIN_SWIPE_DISTANCE : -Number.MAX_SAFE_INTEGER
105
+ };
106
+ } else if (candidate === "leftOpen" /* LeftOpen */) {
107
+ swipeThresholdRef.current = { maxDelta: MIN_SWIPE_DISTANCE };
108
+ } else if (candidate === "rightOpen" /* RightOpen */) {
109
+ swipeThresholdRef.current = { minDelta: -MIN_SWIPE_DISTANCE };
110
+ }
111
+ }, [useLongSwipe]);
112
+ const animateToState = useCallback(
113
+ (toState, velocity) => {
114
+ leftBlockApi.stop();
115
+ rightBlockApi.stop();
116
+ stateRef.current.now = toState;
117
+ const animationConfig = {
118
+ width: 0,
119
+ config: {
120
+ ...config.gentle,
121
+ clamp: true,
122
+ velocity: 0
123
+ }
124
+ };
125
+ let api;
126
+ if (toState === "close" /* Close */) {
127
+ const fromLeft = leftBlockApi.current[0].get().width > 0;
128
+ api = fromLeft ? leftBlockApi : rightBlockApi;
129
+ const v = fromLeft ? velocity : -velocity;
130
+ animationConfig.config.velocity = v / 1e3;
131
+ } else {
132
+ api = toState === "leftOpen" /* LeftOpen */ ? leftBlockApi : rightBlockApi;
133
+ const v = toState === "leftOpen" /* LeftOpen */ ? velocity : -velocity;
134
+ animationConfig.width = Math.min(
135
+ swipeContainerWidth,
136
+ (toState === "leftOpen" /* LeftOpen */ ? leftButtonsSumSizeRef : rightButtonsSumSizeRef).current
137
+ );
138
+ animationConfig.config.velocity = v / 1e3;
139
+ }
140
+ void api.start(animationConfig)[0].then(({ finished }) => {
141
+ if (finished) {
142
+ stateRef.current.candidate = "close" /* Close */;
143
+ if (swipeContainerRef.current !== null) {
144
+ swipeContainerRef.current.classList.remove(styles.swipeContainerInProgress);
145
+ }
146
+ }
147
+ });
148
+ },
149
+ [leftBlockApi, rightBlockApi, swipeContainerWidth]
150
+ );
151
+ const id = useId();
152
+ const swipeContext = useContext(SwipeContext);
153
+ useEffect(() => {
154
+ if (visible && swipeContext !== null) {
155
+ swipeContext.register(id, () => {
156
+ animateToState("close" /* Close */, 0);
157
+ });
158
+ }
159
+ }, [visible, swipeContext, id, animateToState]);
160
+ const handleSwipeStart = useCallback(() => {
161
+ if (demoInProgress || swipeLockRef.current) {
162
+ return;
163
+ }
164
+ rightBlockApi.stop();
165
+ leftBlockApi.stop();
166
+ onStart?.();
167
+ onResetDemo?.();
168
+ updateSwipeThreshold();
169
+ if (longState !== "off" /* Off */) {
170
+ setLongState("off" /* Off */);
171
+ }
172
+ prevDistance.current = 0;
173
+ setAnimateButtonsWidth(false);
174
+ }, [
175
+ demoInProgress,
176
+ rightBlockApi,
177
+ leftBlockApi,
178
+ onStart,
179
+ onResetDemo,
180
+ updateSwipeThreshold,
181
+ longState,
182
+ setAnimateButtonsWidth
183
+ ]);
184
+ const recalcButtonsSizes = useCallback(
185
+ (distance) => {
186
+ const distanceDelta = distance - prevDistance.current;
187
+ if (distanceDelta === 0) {
188
+ return;
189
+ }
190
+ prevDistance.current = distance;
191
+ const isLeft = stateRef.current.now === "leftOpen" /* LeftOpen */ || stateRef.current.candidate === "leftOpen" /* LeftOpen */ || stateRef.current.now !== "rightOpen" /* RightOpen */ && stateRef.current.candidate === "close" /* Close */ && distanceDelta > 0;
192
+ const hasButtons = isLeft ? !!leftButtonsRef.current : !!rightButtonsRef.current;
193
+ const api = isLeft ? leftBlockApi : rightBlockApi;
194
+ const currentWidth = api.current[0].get().width;
195
+ if (!hasButtons) {
196
+ return;
197
+ }
198
+ const width = Math.max(currentWidth + (isLeft ? distanceDelta : -distanceDelta), 0);
199
+ api.set({ width });
200
+ if (width > 0) {
201
+ stateRef.current.candidate = isLeft ? "leftOpen" /* LeftOpen */ : "rightOpen" /* RightOpen */;
176
202
  updateSwipeThreshold();
177
- if (longState !== LongState.Off) {
178
- setLongState(LongState.Off);
179
- }
180
- prevDistance.current = 0;
181
- setAnimateButtonsWidth(false);
182
- }, [
183
- demoInProgress,
184
- rightBlockApi,
185
- leftBlockApi,
186
- onStart,
187
- onResetDemo,
188
- updateSwipeThreshold,
189
- longState,
190
- setAnimateButtonsWidth,
191
- ]);
192
- const recalcButtonsSizes = useCallback((distance) => {
193
- // работаем с изменением дистанции, чтобы добавлять ее к существующей ширине
194
- const distanceDelta = distance - prevDistance.current;
195
- if (distanceDelta === 0) {
196
- return;
197
- }
198
- prevDistance.current = distance;
199
- // определяем сторону свайпа, проверяем есть ли с этой стороны кнопки, если есть меняем ширину блока кнопок
200
- const isLeft = stateRef.current.now === ButtonsState.LeftOpen ||
201
- stateRef.current.candidate === ButtonsState.LeftOpen ||
202
- (stateRef.current.now !== ButtonsState.RightOpen &&
203
- stateRef.current.candidate === ButtonsState.Close &&
204
- distanceDelta > 0);
205
- const hasButtons = isLeft ? !!leftButtonsRef.current : !!rightButtonsRef.current;
206
- const api = isLeft ? leftBlockApi : rightBlockApi;
207
- const currentWidth = api.current[0].get().width;
208
- if (!hasButtons) {
209
- return;
210
- }
211
- const width = Math.max(currentWidth + (isLeft ? distanceDelta : -distanceDelta), 0);
212
- api.set({ width });
213
- // если ширина блока кнопок > 0 фиксируем сторону-кандидат
214
- // чтобы не было возможности двигать влево-вправо за один свайп
215
- if (width > 0) {
216
- stateRef.current.candidate = isLeft ? ButtonsState.LeftOpen : ButtonsState.RightOpen;
217
- updateSwipeThreshold();
218
- }
219
- // определяем значение justifyContent у контейнера в зависимости от того, с какой стороны сейчас раскрыты кнопки
220
- // если раскрыты слева, то контент должен уходить за пределы области в право, ставим flex-start
221
- // если раскрыты справа, то контент должен уходить за пределы области в лево, ставим flex-end
222
- // визуально ничего не меняется, потому что контент в контейнере растянут на всю ширину
223
- if (swipeContainerRef.current) {
224
- swipeContainerRef.current.classList.toggle(styles.swipeContainerInProgress, width > 0);
225
- swipeContainerRef.current.style.justifyContent =
226
- stateRef.current.candidate === ButtonsState.RightOpen ? 'flex-end' : 'flex-start';
227
- }
228
- // определяем выполнены ли условия для перевода компонента в состояние длинного свайпа
229
- // длинный свайп может быть отключен вообще или может быть недоступен если это сдвиг на проекцию
230
- const sumSize = isLeft ? leftButtonsSumSizeRef.current : rightButtonsSumSizeRef.current;
231
- if (useLongSwipe && width > sumSize + MIN_SWIPE_DISTANCE) {
232
- setLongState(isLeft ? LongState.Left : LongState.Right);
233
- stateRef.current.next = ButtonsState.Close;
234
- }
235
- else {
236
- setLongState(LongState.Off);
237
- }
238
- if (Math.abs(distance) > MAIN_AXIS_THRESHOLD_PX) {
239
- swipeContext?.onShown(id);
240
- }
241
- }, [leftBlockApi, rightBlockApi, useLongSwipe, updateSwipeThreshold, id, swipeContext]);
242
- const handleSwipeMove = useCallback((event) => {
243
- if (demoInProgress || swipeLockRef.current) {
244
- return;
245
- }
246
- // сдвиг вслед за пальцем, можем делать длинный свайп
247
- recalcButtonsSizes(event.distanceX);
248
- }, [demoInProgress, recalcButtonsSizes]);
249
- const runSwipeAnimation = useCallback(() => {
250
- if (!swipeContainerRef.current) {
251
- return;
252
- }
253
- if (stateRef.current.next === ButtonsState.Close) {
254
- // свайп завершен, кнопки должны закрыться, потому что не выполнен минимальный размер раскрытия
255
- // сбрасываем ширину в 0
256
- if (leftButtonsRef.current) {
257
- leftButtonsRef.current.style.width = '0';
258
- }
259
- leftButtonsSizeRef.current = 0;
260
- if (rightButtonsRef.current) {
261
- rightButtonsRef.current.style.width = '0';
262
- }
263
- rigthButtonsSizeRef.current = 0;
264
- }
265
- else if (stateRef.current.next === ButtonsState.LeftOpen) {
266
- // выполнено условие раскрытия слева
267
- // раскрываем кнопки на ширину их контента, но не больше ширины контейнера
268
- const maxLeftSize = Math.min(swipeContainerWidth, leftButtonsSumSizeRef.current);
269
- if (leftButtonsRef.current) {
270
- leftButtonsRef.current.style.width = `${maxLeftSize}px`;
271
- }
272
- leftButtonsSizeRef.current = maxLeftSize;
273
- rigthButtonsSizeRef.current = 0;
274
- }
275
- else if (stateRef.current.next === ButtonsState.RightOpen) {
276
- // выполнено условие раскрытия справа
277
- // раскрываем кнопки на ширину их контента, но не больше ширины контейнера
278
- const maxRightSize = Math.min(swipeContainerWidth, rightButtonsSumSizeRef.current);
279
- if (rightButtonsRef.current) {
280
- rightButtonsRef.current.style.width = `${maxRightSize}px`;
281
- }
282
- rigthButtonsSizeRef.current = maxRightSize;
283
- leftButtonsSizeRef.current = 0;
284
- }
285
- stateRef.current.now = stateRef.current.next;
286
- }, [swipeContainerWidth]);
287
- const handleSwipeEnd = useCallback((event) => {
288
- if (demoInProgress) {
289
- return;
290
- }
291
- onFinish?.();
292
- // если это длинный свайп, то триггерим клик на соответствующую кнопку, и закрываем блок кнопок
293
- // если не установлен флаг keepStateAfterLong
294
- if (longState !== LongState.Off) {
295
- const buttons = longState === LongState.Left ? leftButtons : rightButtons;
296
- const button = longState === LongState.Left ? buttons?.[0] : buttons?.[buttons.length - 1];
297
- button?.onClick();
298
- onResetDemo?.();
299
- swipeLockRef.current = !!button?.keepStateAfterLong;
300
- if (!button?.keepStateAfterLong) {
301
- animateToState(ButtonsState.Close, event.velocityX);
302
- }
303
- return;
304
- }
305
- // если это не длинный свайп, то анимируем к соответствующему состоянию
306
- // если открыт левый или правый блок, то анимируем в закрытое состояние
307
- // если закрыты оба блока, то анимируем к открытию стороны-кадидата
308
- const { now, candidate } = stateRef.current;
309
- animateToState([ButtonsState.LeftOpen, ButtonsState.RightOpen].includes(now) ? ButtonsState.Close : candidate, event.velocityX);
310
- }, [demoInProgress, longState, leftButtons, rightButtons, onFinish, onResetDemo, animateToState]);
311
- const handleSwipeCancel = useCallback((event) => {
312
- animateToState(stateRef.current.now, event.velocityX);
313
- }, [animateToState]);
314
- const swipeHandlers = useSwipe({
315
- thresholdXRef: swipeThresholdRef,
316
- onSwipeStart: handleSwipeStart,
317
- onSwipeMove: handleSwipeMove,
318
- onSwipeEnd: handleSwipeEnd,
319
- onSwipeCancel: handleSwipeCancel,
320
- });
321
- useEffect(() => {
322
- const swipeContainer = swipeContainerRef.current;
323
- if (!visible || !swipeContainer) {
324
- return void 0;
325
- }
326
- const preventScroll = (event) => {
327
- if (Math.abs(prevDistance.current) > MAIN_AXIS_THRESHOLD_PX) {
328
- event.preventDefault();
329
- }
330
- };
331
- swipeContainer.addEventListener('touchmove', preventScroll, { passive: false });
332
- return () => swipeContainer.removeEventListener('touchmove', preventScroll);
333
- }, [visible]);
334
- const getButtonsFromSide = useCallback((side = stateRef.current.now) => {
335
- const buttons = side === ButtonsState.RightOpen ? rightButtonsRef.current : leftButtonsRef.current;
336
- const oppositeButtons = buttons === rightButtonsRef.current ? leftButtonsRef.current : rightButtonsRef.current;
337
- return { buttons, oppositeButtons };
338
- }, []);
339
- const unmountDemoEndHandler = useCallback((event) => {
340
- if (event.propertyName !== 'width') {
341
- return;
342
- }
343
- setDemoInProgress(false);
344
- const isTwoSidedSwipe = !!rightButtonsRef.current && !!leftButtonsRef.current;
345
- const isLeft = isTwoSidedSwipe
346
- ? twoSidedDemoMode === 'right-to-left' || twoSidedDemoMode === 'left'
347
- : !!leftButtonsRef.current;
348
- const buttons = isLeft ? leftButtonsRef.current : rightButtonsRef.current;
349
- buttons?.removeEventListener('transitionend', unmountDemoEndHandler);
350
- fixedContainerRef.current?.style.removeProperty('--transition-duration');
351
- fixedContainerRef.current?.style.removeProperty('--transition-delay');
203
+ }
204
+ if (swipeContainerRef.current) {
205
+ swipeContainerRef.current.classList.toggle(styles.swipeContainerInProgress, width > 0);
206
+ swipeContainerRef.current.style.justifyContent = stateRef.current.candidate === "rightOpen" /* RightOpen */ ? "flex-end" : "flex-start";
207
+ }
208
+ const sumSize = isLeft ? leftButtonsSumSizeRef.current : rightButtonsSumSizeRef.current;
209
+ if (useLongSwipe && width > sumSize + MIN_SWIPE_DISTANCE) {
210
+ setLongState(isLeft ? "left" /* Left */ : "right" /* Right */);
211
+ stateRef.current.next = "close" /* Close */;
212
+ } else {
213
+ setLongState("off" /* Off */);
214
+ }
215
+ if (Math.abs(distance) > MAIN_AXIS_THRESHOLD_PX) {
216
+ swipeContext?.onShown(id);
217
+ }
218
+ },
219
+ [leftBlockApi, rightBlockApi, useLongSwipe, updateSwipeThreshold, id, swipeContext]
220
+ );
221
+ const handleSwipeMove = useCallback(
222
+ (event) => {
223
+ if (demoInProgress || swipeLockRef.current) {
224
+ return;
225
+ }
226
+ recalcButtonsSizes(event.distanceX);
227
+ },
228
+ [demoInProgress, recalcButtonsSizes]
229
+ );
230
+ const runSwipeAnimation = useCallback(() => {
231
+ if (!swipeContainerRef.current) {
232
+ return;
233
+ }
234
+ if (stateRef.current.next === "close" /* Close */) {
235
+ if (leftButtonsRef.current) {
236
+ leftButtonsRef.current.style.width = "0";
237
+ }
238
+ leftButtonsSizeRef.current = 0;
239
+ if (rightButtonsRef.current) {
240
+ rightButtonsRef.current.style.width = "0";
241
+ }
242
+ rigthButtonsSizeRef.current = 0;
243
+ } else if (stateRef.current.next === "leftOpen" /* LeftOpen */) {
244
+ const maxLeftSize = Math.min(swipeContainerWidth, leftButtonsSumSizeRef.current);
245
+ if (leftButtonsRef.current) {
246
+ leftButtonsRef.current.style.width = `${maxLeftSize}px`;
247
+ }
248
+ leftButtonsSizeRef.current = maxLeftSize;
249
+ rigthButtonsSizeRef.current = 0;
250
+ } else if (stateRef.current.next === "rightOpen" /* RightOpen */) {
251
+ const maxRightSize = Math.min(swipeContainerWidth, rightButtonsSumSizeRef.current);
252
+ if (rightButtonsRef.current) {
253
+ rightButtonsRef.current.style.width = `${maxRightSize}px`;
254
+ }
255
+ rigthButtonsSizeRef.current = maxRightSize;
256
+ leftButtonsSizeRef.current = 0;
257
+ }
258
+ stateRef.current.now = stateRef.current.next;
259
+ }, [swipeContainerWidth]);
260
+ const handleSwipeEnd = useCallback(
261
+ (event) => {
262
+ if (demoInProgress) {
263
+ return;
264
+ }
265
+ onFinish?.();
266
+ if (longState !== "off" /* Off */) {
267
+ const buttons = longState === "left" /* Left */ ? leftButtons : rightButtons;
268
+ const button = longState === "left" /* Left */ ? buttons?.[0] : buttons?.[buttons.length - 1];
269
+ button?.onClick();
352
270
  onResetDemo?.();
353
- onFinishDemo?.();
354
- }, [onFinishDemo, onResetDemo, twoSidedDemoMode]);
355
- const demoSideAppearHandler = useCallback((event) => {
356
- if (event.propertyName !== 'width') {
357
- return;
358
- }
359
- const currentSide = stateRef.current.now;
360
- const { buttons, oppositeButtons } = getButtonsFromSide(currentSide);
361
- const appearedIsFirstOfSides = !!rightButtonsRef.current &&
362
- !!leftButtonsRef.current &&
363
- ((currentSide === ButtonsState.LeftOpen && twoSidedDemoMode === 'left-to-right') ||
364
- (currentSide === ButtonsState.RightOpen && twoSidedDemoMode === 'right-to-left'));
365
- buttons?.removeEventListener('transitionend', demoSideAppearHandler);
366
- if (fixedContainerRef.current) {
367
- fixedContainerRef.current.style.setProperty('--transition-duration', `${appearedIsFirstOfSides ? demoAppearTime : demoDisappearTime}ms`);
368
- fixedContainerRef.current.style.setProperty('--transition-delay', `${demoIdleTime}ms`);
369
- }
370
- stateRef.current.next = ButtonsState.Close;
271
+ swipeLockRef.current = !!button?.keepStateAfterLong;
272
+ if (!button?.keepStateAfterLong) {
273
+ animateToState("close" /* Close */, event.velocityX);
274
+ }
275
+ return;
276
+ }
277
+ const { now, candidate } = stateRef.current;
278
+ animateToState(
279
+ ["leftOpen" /* LeftOpen */, "rightOpen" /* RightOpen */].includes(now) ? "close" /* Close */ : candidate,
280
+ event.velocityX
281
+ );
282
+ },
283
+ [demoInProgress, longState, leftButtons, rightButtons, onFinish, onResetDemo, animateToState]
284
+ );
285
+ const handleSwipeCancel = useCallback(
286
+ (event) => {
287
+ animateToState(stateRef.current.now, event.velocityX);
288
+ },
289
+ [animateToState]
290
+ );
291
+ const swipeHandlers = useSwipe({
292
+ thresholdXRef: swipeThresholdRef,
293
+ onSwipeStart: handleSwipeStart,
294
+ onSwipeMove: handleSwipeMove,
295
+ onSwipeEnd: handleSwipeEnd,
296
+ onSwipeCancel: handleSwipeCancel
297
+ });
298
+ useEffect(() => {
299
+ const swipeContainer = swipeContainerRef.current;
300
+ if (!visible || !swipeContainer) {
301
+ return void 0;
302
+ }
303
+ const preventScroll = (event) => {
304
+ if (Math.abs(prevDistance.current) > MAIN_AXIS_THRESHOLD_PX) {
305
+ event.preventDefault();
306
+ }
307
+ };
308
+ swipeContainer.addEventListener("touchmove", preventScroll, { passive: false });
309
+ return () => swipeContainer.removeEventListener("touchmove", preventScroll);
310
+ }, [visible]);
311
+ const getButtonsFromSide = useCallback((side = stateRef.current.now) => {
312
+ const buttons = side === "rightOpen" /* RightOpen */ ? rightButtonsRef.current : leftButtonsRef.current;
313
+ const oppositeButtons = buttons === rightButtonsRef.current ? leftButtonsRef.current : rightButtonsRef.current;
314
+ return { buttons, oppositeButtons };
315
+ }, []);
316
+ const unmountDemoEndHandler = useCallback(
317
+ (event) => {
318
+ if (event.propertyName !== "width") {
319
+ return;
320
+ }
321
+ setDemoInProgress(false);
322
+ const isTwoSidedSwipe = !!rightButtonsRef.current && !!leftButtonsRef.current;
323
+ const isLeft = isTwoSidedSwipe ? twoSidedDemoMode === "right-to-left" || twoSidedDemoMode === "left" : !!leftButtonsRef.current;
324
+ const buttons = isLeft ? leftButtonsRef.current : rightButtonsRef.current;
325
+ buttons?.removeEventListener("transitionend", unmountDemoEndHandler);
326
+ fixedContainerRef.current?.style.removeProperty("--transition-duration");
327
+ fixedContainerRef.current?.style.removeProperty("--transition-delay");
328
+ onResetDemo?.();
329
+ onFinishDemo?.();
330
+ },
331
+ [onFinishDemo, onResetDemo, twoSidedDemoMode]
332
+ );
333
+ const demoSideAppearHandler = useCallback(
334
+ (event) => {
335
+ if (event.propertyName !== "width") {
336
+ return;
337
+ }
338
+ const currentSide = stateRef.current.now;
339
+ const { buttons, oppositeButtons } = getButtonsFromSide(currentSide);
340
+ const appearedIsFirstOfSides = !!rightButtonsRef.current && !!leftButtonsRef.current && (currentSide === "leftOpen" /* LeftOpen */ && twoSidedDemoMode === "left-to-right" || currentSide === "rightOpen" /* RightOpen */ && twoSidedDemoMode === "right-to-left");
341
+ buttons?.removeEventListener("transitionend", demoSideAppearHandler);
342
+ if (fixedContainerRef.current) {
343
+ fixedContainerRef.current.style.setProperty(
344
+ "--transition-duration",
345
+ `${appearedIsFirstOfSides ? demoAppearTime : demoDisappearTime}ms`
346
+ );
347
+ fixedContainerRef.current.style.setProperty("--transition-delay", `${demoIdleTime}ms`);
348
+ }
349
+ stateRef.current.next = "close" /* Close */;
350
+ stateRef.current.candidate = stateRef.current.next;
351
+ runSwipeAnimation();
352
+ if (appearedIsFirstOfSides) {
353
+ stateRef.current.next = currentSide === "leftOpen" /* LeftOpen */ ? "rightOpen" /* RightOpen */ : "leftOpen" /* LeftOpen */;
371
354
  stateRef.current.candidate = stateRef.current.next;
372
355
  runSwipeAnimation();
373
- if (appearedIsFirstOfSides) {
374
- stateRef.current.next =
375
- currentSide === ButtonsState.LeftOpen ? ButtonsState.RightOpen : ButtonsState.LeftOpen;
376
- stateRef.current.candidate = stateRef.current.next;
377
- runSwipeAnimation();
378
- const twiceSideTransitionHandler = () => {
379
- oppositeButtons?.removeEventListener('transitionstart', twiceSideTransitionHandler);
380
- if (oppositeButtons && contentRef.current) {
381
- const isRight = currentSide === ButtonsState.RightOpen;
382
- contentRef.current.style.transform = `translateX(${isRight ? leftButtonsSumSizeRef.current : -rightButtonsSumSizeRef.current}px)`;
383
- }
384
- };
385
- oppositeButtons?.addEventListener('transitionstart', twiceSideTransitionHandler);
386
- oppositeButtons?.addEventListener('transitionend', demoSideAppearHandler);
387
- }
388
- else {
389
- const startDestroyDemoHandler = () => {
390
- buttons?.removeEventListener('transitionstart', startDestroyDemoHandler);
391
- contentRef.current?.style.removeProperty('transform');
392
- };
393
- buttons?.addEventListener('transitionstart', startDestroyDemoHandler);
394
- buttons?.addEventListener('transitionend', unmountDemoEndHandler);
395
- }
396
- }, [
397
- getButtonsFromSide,
398
- twoSidedDemoMode,
399
- runSwipeAnimation,
400
- demoAppearTime,
401
- demoDisappearTime,
402
- demoIdleTime,
403
- unmountDemoEndHandler,
404
- ]);
405
- const startDemo = useCallback((side) => {
406
- onResetDemo?.();
407
- onStartDemo?.();
408
- setDemoInProgress(true);
409
- stateRef.current.now = ButtonsState.Close;
410
- stateRef.current.next = side;
411
- stateRef.current.candidate = side;
412
- if (swipeContainerRef.current) {
413
- swipeContainerRef.current.style.justifyContent =
414
- side === ButtonsState.RightOpen ? 'flex-end' : 'flex-start';
415
- }
416
- if (fixedContainerRef.current) {
417
- fixedContainerRef.current.style.setProperty('--transition-duration', `${demoAppearTime}ms`);
418
- }
419
- setLongState(LongState.Off);
420
- setAnimateButtonsWidth(true);
421
- runSwipeAnimation();
422
- const { buttons } = getButtonsFromSide(side);
423
- buttons?.addEventListener('transitionend', demoSideAppearHandler);
424
- }, [
425
- demoAppearTime,
426
- demoSideAppearHandler,
427
- getButtonsFromSide,
428
- runSwipeAnimation,
429
- onResetDemo,
430
- onStartDemo,
431
- setAnimateButtonsWidth,
432
- ]);
433
- useEffect(() => {
434
- if (demo &&
435
- !demoInProgress &&
436
- stateRef.current.now === ButtonsState.Close &&
437
- swipeContainerRef.current?.style.width) {
438
- const isTwoSidedSwipe = Boolean(rightButtonsRef.current && leftButtonsRef.current);
439
- if (isTwoSidedSwipe) {
440
- startDemo(twoSidedDemoMode === 'right' || twoSidedDemoMode === 'right-to-left'
441
- ? ButtonsState.RightOpen
442
- : ButtonsState.LeftOpen);
443
- }
444
- else {
445
- startDemo(rightButtonsRef.current ? ButtonsState.RightOpen : ButtonsState.LeftOpen);
356
+ const twiceSideTransitionHandler = () => {
357
+ oppositeButtons?.removeEventListener("transitionstart", twiceSideTransitionHandler);
358
+ if (oppositeButtons && contentRef.current) {
359
+ const isRight = currentSide === "rightOpen" /* RightOpen */;
360
+ contentRef.current.style.transform = `translateX(${isRight ? leftButtonsSumSizeRef.current : -rightButtonsSumSizeRef.current}px)`;
361
+ }
362
+ };
363
+ oppositeButtons?.addEventListener("transitionstart", twiceSideTransitionHandler);
364
+ oppositeButtons?.addEventListener("transitionend", demoSideAppearHandler);
365
+ } else {
366
+ const startDestroyDemoHandler = () => {
367
+ buttons?.removeEventListener("transitionstart", startDestroyDemoHandler);
368
+ contentRef.current?.style.removeProperty("transform");
369
+ };
370
+ buttons?.addEventListener("transitionstart", startDestroyDemoHandler);
371
+ buttons?.addEventListener("transitionend", unmountDemoEndHandler);
372
+ }
373
+ },
374
+ [
375
+ getButtonsFromSide,
376
+ twoSidedDemoMode,
377
+ runSwipeAnimation,
378
+ demoAppearTime,
379
+ demoDisappearTime,
380
+ demoIdleTime,
381
+ unmountDemoEndHandler
382
+ ]
383
+ );
384
+ const startDemo = useCallback(
385
+ (side) => {
386
+ onResetDemo?.();
387
+ onStartDemo?.();
388
+ setDemoInProgress(true);
389
+ stateRef.current.now = "close" /* Close */;
390
+ stateRef.current.next = side;
391
+ stateRef.current.candidate = side;
392
+ if (swipeContainerRef.current) {
393
+ swipeContainerRef.current.style.justifyContent = side === "rightOpen" /* RightOpen */ ? "flex-end" : "flex-start";
394
+ }
395
+ if (fixedContainerRef.current) {
396
+ fixedContainerRef.current.style.setProperty("--transition-duration", `${demoAppearTime}ms`);
397
+ }
398
+ setLongState("off" /* Off */);
399
+ setAnimateButtonsWidth(true);
400
+ runSwipeAnimation();
401
+ const { buttons } = getButtonsFromSide(side);
402
+ buttons?.addEventListener("transitionend", demoSideAppearHandler);
403
+ },
404
+ [
405
+ demoAppearTime,
406
+ demoSideAppearHandler,
407
+ getButtonsFromSide,
408
+ runSwipeAnimation,
409
+ onResetDemo,
410
+ onStartDemo,
411
+ setAnimateButtonsWidth
412
+ ]
413
+ );
414
+ useEffect(() => {
415
+ if (demo && !demoInProgress && stateRef.current.now === "close" /* Close */ && swipeContainerRef.current?.style.width) {
416
+ const isTwoSidedSwipe = Boolean(rightButtonsRef.current && leftButtonsRef.current);
417
+ if (isTwoSidedSwipe) {
418
+ startDemo(
419
+ twoSidedDemoMode === "right" || twoSidedDemoMode === "right-to-left" ? "rightOpen" /* RightOpen */ : "leftOpen" /* LeftOpen */
420
+ );
421
+ } else {
422
+ startDemo(rightButtonsRef.current ? "rightOpen" /* RightOpen */ : "leftOpen" /* LeftOpen */);
423
+ }
424
+ }
425
+ if (!isMobile && demoInProgress) {
426
+ setDemoInProgress(false);
427
+ stateRef.current = {
428
+ candidate: "close" /* Close */,
429
+ now: "close" /* Close */,
430
+ next: "close" /* Close */
431
+ };
432
+ }
433
+ }, [demo, twoSidedDemoMode, startDemo, demoInProgress, isMobile, onResetDemo]);
434
+ const handleButtonContentRef = useCallback(
435
+ (side, grow) => (ref) => {
436
+ if (sumRefs.current.includes(ref) || !ref) {
437
+ return;
438
+ }
439
+ const width = ref?.offsetWidth ?? 0;
440
+ if (!grow) {
441
+ ref.style.maxWidth = `${width}px`;
442
+ }
443
+ sumRefs.current.push(ref);
444
+ const widthWithGap = gap && width > 0 ? width + GAP_WIDTH : width;
445
+ if (side === "left") {
446
+ leftButtonsSumSizeRef.current += widthWithGap;
447
+ } else {
448
+ rightButtonsSumSizeRef.current += widthWithGap;
449
+ }
450
+ },
451
+ [gap]
452
+ );
453
+ const renderButtons = (buttons, ref, side) => {
454
+ const isTwoSidedDemoInProgress = leftButtons && rightButtons && demoInProgress;
455
+ return /* @__PURE__ */ jsx(Layer, { layer: "content", children: /* @__PURE__ */ jsxs(
456
+ animated.div,
457
+ {
458
+ className: classNames(styles.buttons, {
459
+ [styles.leftButtonsAnimation]: side === "left" && twoSidedDemoMode === "right-to-left" && isTwoSidedDemoInProgress,
460
+ [styles.rightButtonsAnimation]: side === "right" && twoSidedDemoMode === "left-to-right" && isTwoSidedDemoInProgress
461
+ }),
462
+ style: {
463
+ ...side === "left" ? { justifyContent: "flex-start", ...leftBlockStyles } : {},
464
+ ...side === "right" ? { justifyContent: "flex-end", ...rightBlockStyles } : {}
465
+ },
466
+ ref,
467
+ "data-qa": `swipe-buttons-${side}`,
468
+ children: [
469
+ gap && side === "right" && longState === "right" /* Right */ && /* @__PURE__ */ jsx("div", { className: styles.gap }),
470
+ buttons.map((item, index) => {
471
+ if (!item) {
472
+ return null;
446
473
  }
447
- }
448
- if (!isMobile && demoInProgress) {
449
- setDemoInProgress(false);
450
- stateRef.current = {
451
- candidate: ButtonsState.Close,
452
- now: ButtonsState.Close,
453
- next: ButtonsState.Close,
454
- };
455
- }
456
- }, [demo, twoSidedDemoMode, startDemo, demoInProgress, isMobile, onResetDemo]);
457
- // подсчитываем реальный необходимый размер для кнопок
458
- // и назначаем проперти исходя из положения кнопки (последняя/не последняя)
459
- const handleButtonContentRef = useCallback((side, grow) => (ref) => {
460
- // нужно чтобы посчитать размеры для каждой кнопки один раз
461
- if (sumRefs.current.includes(ref) || !ref) {
462
- return;
463
- }
464
- const width = ref?.offsetWidth ?? 0;
465
- if (!grow) {
466
- ref.style.maxWidth = `${width}px`;
467
- }
468
- sumRefs.current.push(ref);
469
- const widthWithGap = gap && width > 0 ? width + GAP_WIDTH : width;
470
- if (side === 'left') {
471
- leftButtonsSumSizeRef.current += widthWithGap;
472
- }
473
- else {
474
- rightButtonsSumSizeRef.current += widthWithGap;
475
- }
476
- }, [gap]);
477
- const renderButtons = (buttons, ref, side) => {
478
- const isTwoSidedDemoInProgress = leftButtons && rightButtons && demoInProgress;
479
- return (jsx(Layer, { layer: "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,
482
- }),
483
- // "длинная" кнопка растягивается максимум на ширину контейнера (buttons)
484
- // чтобы не было видно пустоты между ней и контейнером
485
- // нужно устанавливать выравнивание в зависимости от стороны
486
- style: {
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;
474
+ const grow = side === "left" ? index === 0 : index === buttons.length - 1;
475
+ const hide = side === "left" && index !== 0 && longState === "left" /* Left */ || side === "right" && index !== buttons.length - 1 && longState === "right" /* Right */;
476
+ const Icon = item.icon;
477
+ const iconProps = item.showLabel ? { "aria-hidden": true, focusable: false } : { "aria-label": item.label };
478
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
479
+ gap && side === "right" && longState !== "right" /* Right */ && /* @__PURE__ */ jsx("div", { className: styles.gap }),
480
+ /* @__PURE__ */ jsx(
481
+ "div",
482
+ {
483
+ className: classNames(styles.buttonWrapper, {
484
+ [styles.buttonWrapperGrow]: grow,
485
+ [styles.buttonWrapperHide]: hide
486
+ }),
487
+ style: grow ? { maxWidth: `${swipeContainerWidth}px` } : {},
488
+ children: /* @__PURE__ */ jsx(
489
+ "button",
490
+ {
491
+ className: classNames(styles.button, {
492
+ [styles.buttonGrow]: grow,
493
+ [styles[`button_style-${item.style}`]]: item.style
494
+ }),
495
+ onClick: () => {
496
+ if (demoInProgress) {
497
+ return;
492
498
  }
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
- })] }) }));
520
- };
521
- if (!visible) {
522
- return null;
499
+ if (item.closeOnAction) {
500
+ animateToState("close" /* Close */, 0);
501
+ }
502
+ item.onClick();
503
+ },
504
+ style: gap ? { borderRadius } : {},
505
+ "data-qa": `swipe-button-${side}-${index}`,
506
+ children: /* @__PURE__ */ jsx(
507
+ "div",
508
+ {
509
+ className: styles.buttonContent,
510
+ ref: handleButtonContentRef(side, grow),
511
+ "data-qa": `swipe-button-content-${side}-${index}`,
512
+ children: /* @__PURE__ */ jsxs("div", { className: styles.buttonContentColumn, children: [
513
+ Icon && /* @__PURE__ */ jsx("div", { className: styles.iconWrapper, children: /* @__PURE__ */ jsx(Icon, { ...iconProps }) }),
514
+ item.showLabel && /* @__PURE__ */ jsx("span", { className: styles.buttonLabel, children: item.label })
515
+ ] })
516
+ }
517
+ )
518
+ }
519
+ )
520
+ }
521
+ ),
522
+ gap && side === "left" && /* @__PURE__ */ jsx("div", { className: styles.gap })
523
+ ] }, index);
524
+ })
525
+ ]
526
+ }
527
+ ) });
528
+ };
529
+ if (!visible) {
530
+ return null;
531
+ }
532
+ return /* @__PURE__ */ jsx("div", { className: styles.fixedContainer, ref: fixedContainerRef, "data-qa": dataQa ?? "swipe-root", children: /* @__PURE__ */ jsxs(
533
+ "div",
534
+ {
535
+ className: classNames(styles.swipeContainer),
536
+ ref: swipeContainerRef,
537
+ ...swipeHandlers,
538
+ "data-qa": "swipe-swipeable",
539
+ children: [
540
+ !!leftButtons?.length && renderButtons(leftButtons, leftButtonsRef, "left"),
541
+ /* @__PURE__ */ jsx("div", { ref: contentRef, className: styles.content, children }),
542
+ !!rightButtons?.length && renderButtons(rightButtons, rightButtonsRef, "right")
543
+ ]
523
544
  }
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')] }) }));
545
+ ) });
525
546
  };
526
547
 
527
548
  export { Swipe };