@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.d.ts +1 -1
- package/Swipe.js +520 -499
- package/Swipe.js.map +1 -1
- package/SwipeGroup.js +10 -12
- package/SwipeGroup.js.map +1 -1
- package/context.js.map +1 -1
- package/index.css +368 -368
- package/index.d.ts +4 -4
- package/package.json +12 -11
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
-
|
|
545
|
+
) });
|
|
525
546
|
};
|
|
526
547
|
|
|
527
548
|
export { Swipe };
|