@salutejs/plasma-new-hope 0.326.0-canary.2016.15556762192.0 → 0.326.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Carousel/CarouselNew/Carousel.css +41 -0
- package/cjs/components/Carousel/CarouselNew/Carousel.js +110 -0
- package/cjs/components/Carousel/CarouselNew/Carousel.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/Carousel.styles.js +43 -0
- package/cjs/components/Carousel/CarouselNew/Carousel.styles.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/Carousel.styles_151pk3s.css +5 -0
- package/cjs/components/Carousel/CarouselNew/Carousel.tokens.js +24 -0
- package/cjs/components/Carousel/CarouselNew/Carousel.tokens.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/hooks/useCarousel.js +384 -0
- package/cjs/components/Carousel/CarouselNew/hooks/useCarousel.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.css +5 -0
- package/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.js +227 -0
- package/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.styles.js +39 -0
- package/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.styles.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.styles_ea836d.css +5 -0
- package/cjs/components/Carousel/CarouselNew/ui/Dots/utils/index.js +47 -0
- package/cjs/components/Carousel/CarouselNew/ui/Dots/utils/index.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/variations/_size/base.js +9 -0
- package/cjs/components/Carousel/CarouselNew/variations/_size/base.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/variations/_size/base_x642ct.css +1 -0
- package/cjs/components/Carousel/CarouselNew/variations/_view/base.js +9 -0
- package/cjs/components/Carousel/CarouselNew/variations/_view/base.js.map +1 -0
- package/cjs/components/Carousel/CarouselNew/variations/_view/base_x642ct.css +1 -0
- package/cjs/components/Carousel/CarouselOld/Carousel.css +4 -0
- package/cjs/components/Carousel/{Carousel.js → CarouselOld/Carousel.js} +1 -1
- package/cjs/components/Carousel/CarouselOld/Carousel.js.map +1 -0
- package/cjs/components/Carousel/{Carousel.styles.js → CarouselOld/Carousel.styles.js} +9 -9
- package/cjs/components/Carousel/CarouselOld/Carousel.styles.js.map +1 -0
- package/cjs/components/Carousel/CarouselOld/Carousel.styles_12r304j.css +4 -0
- package/cjs/components/Carousel/{CarouselItem.js → CarouselOld/CarouselItem.js} +5 -5
- package/cjs/components/Carousel/CarouselOld/CarouselItem.js.map +1 -0
- package/cjs/components/Carousel/CarouselOld/CarouselItem_cghzk7.css +1 -0
- package/cjs/components/Carousel/CarouselOld/useCarousel.js.map +1 -0
- package/cjs/components/Carousel/{useDragScroll.js → CarouselOld/useDragScroll.js} +1 -1
- package/cjs/components/Carousel/CarouselOld/useDragScroll.js.map +1 -0
- package/cjs/components/Mask/Mask.js +3 -3
- package/cjs/components/Mask/Mask.js.map +1 -1
- package/cjs/hooks/useDidMountLayoutEffect.js +19 -0
- package/cjs/hooks/useDidMountLayoutEffect.js.map +1 -0
- package/cjs/index.css +17 -5
- package/cjs/index.js +10 -3
- package/cjs/index.js.map +1 -1
- package/emotion/cjs/components/Carousel/CarouselNew/Carousel.js +110 -0
- package/emotion/cjs/components/Carousel/CarouselNew/Carousel.styles.js +64 -0
- package/emotion/cjs/components/Carousel/CarouselNew/Carousel.tokens.js +22 -0
- package/emotion/cjs/components/Carousel/CarouselNew/hooks/useCarousel.js +376 -0
- package/emotion/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.js +229 -0
- package/emotion/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.styles.js +38 -0
- package/emotion/cjs/components/Carousel/CarouselNew/ui/Dots/utils/index.js +44 -0
- package/emotion/cjs/components/Carousel/CarouselNew/ui/index.js +16 -0
- package/emotion/cjs/components/Carousel/CarouselNew/variations/_size/base.js +8 -0
- package/emotion/cjs/components/Carousel/CarouselNew/variations/_size/tokens.json +1 -0
- package/emotion/cjs/components/Carousel/CarouselNew/variations/_view/base.js +8 -0
- package/emotion/cjs/components/Carousel/CarouselNew/variations/_view/tokens.json +1 -0
- package/emotion/cjs/components/Carousel/CarouselOld/Carousel.styles.js +49 -0
- package/emotion/cjs/components/Carousel/CarouselOld/Carousel.types.js +5 -0
- package/emotion/cjs/components/Carousel/{CarouselItem.js → CarouselOld/CarouselItem.js} +2 -2
- package/emotion/cjs/components/Carousel/CarouselOld/index.js +32 -0
- package/emotion/cjs/components/Carousel/index.js +23 -3
- package/emotion/cjs/components/Mask/Mask.js +3 -3
- package/emotion/cjs/examples/plasma_b2c/components/Carousel/Carousel.config.js +14 -2
- package/emotion/cjs/examples/plasma_b2c/components/Carousel/Carousel.js +1 -1
- package/emotion/cjs/examples/plasma_b2c/components/Carousel/Carousel.stories.tsx +90 -32
- package/emotion/cjs/examples/plasma_web/components/Carousel/Carousel.config.js +14 -2
- package/emotion/cjs/examples/plasma_web/components/Carousel/Carousel.js +1 -1
- package/emotion/cjs/examples/plasma_web/components/Carousel/Carousel.stories.tsx +91 -32
- package/emotion/cjs/hooks/index.js +7 -0
- package/emotion/cjs/hooks/useDidMountLayoutEffect.js +17 -0
- package/emotion/es/components/Carousel/CarouselNew/Carousel.js +101 -0
- package/emotion/es/components/Carousel/CarouselNew/Carousel.styles.js +57 -0
- package/emotion/es/components/Carousel/CarouselNew/Carousel.tokens.js +16 -0
- package/emotion/es/components/Carousel/CarouselNew/hooks/useCarousel.js +366 -0
- package/emotion/es/components/Carousel/CarouselNew/ui/Dots/Dots.js +219 -0
- package/emotion/es/components/Carousel/CarouselNew/ui/Dots/Dots.styles.js +31 -0
- package/emotion/es/components/Carousel/CarouselNew/ui/Dots/utils/index.js +38 -0
- package/emotion/es/components/Carousel/CarouselNew/ui/index.js +1 -0
- package/emotion/es/components/Carousel/CarouselNew/variations/_size/base.js +2 -0
- package/emotion/es/components/Carousel/CarouselNew/variations/_size/tokens.json +1 -0
- package/emotion/es/components/Carousel/CarouselNew/variations/_view/base.js +2 -0
- package/emotion/es/components/Carousel/CarouselNew/variations/_view/tokens.json +1 -0
- package/emotion/es/components/Carousel/CarouselOld/Carousel.styles.js +42 -0
- package/emotion/es/components/Carousel/CarouselOld/Carousel.types.js +1 -0
- package/emotion/es/components/Carousel/{CarouselItem.js → CarouselOld/CarouselItem.js} +2 -2
- package/emotion/es/components/Carousel/CarouselOld/index.js +3 -0
- package/emotion/es/components/Carousel/index.js +7 -3
- package/emotion/es/components/Mask/Mask.js +3 -3
- package/emotion/es/examples/plasma_b2c/components/Carousel/Carousel.config.js +14 -2
- package/emotion/es/examples/plasma_b2c/components/Carousel/Carousel.js +2 -2
- package/emotion/es/examples/plasma_b2c/components/Carousel/Carousel.stories.tsx +90 -32
- package/emotion/es/examples/plasma_web/components/Carousel/Carousel.config.js +14 -2
- package/emotion/es/examples/plasma_web/components/Carousel/Carousel.js +2 -2
- package/emotion/es/examples/plasma_web/components/Carousel/Carousel.stories.tsx +91 -32
- package/emotion/es/hooks/index.js +1 -0
- package/emotion/es/hooks/useDidMountLayoutEffect.js +11 -0
- package/es/components/Carousel/CarouselNew/Carousel.css +41 -0
- package/es/components/Carousel/CarouselNew/Carousel.js +101 -0
- package/es/components/Carousel/CarouselNew/Carousel.js.map +1 -0
- package/es/components/Carousel/CarouselNew/Carousel.styles.js +34 -0
- package/es/components/Carousel/CarouselNew/Carousel.styles.js.map +1 -0
- package/es/components/Carousel/CarouselNew/Carousel.styles_151pk3s.css +5 -0
- package/es/components/Carousel/CarouselNew/Carousel.tokens.js +19 -0
- package/es/components/Carousel/CarouselNew/Carousel.tokens.js.map +1 -0
- package/es/components/Carousel/CarouselNew/hooks/useCarousel.js +369 -0
- package/es/components/Carousel/CarouselNew/hooks/useCarousel.js.map +1 -0
- package/es/components/Carousel/CarouselNew/ui/Dots/Dots.css +5 -0
- package/es/components/Carousel/CarouselNew/ui/Dots/Dots.js +218 -0
- package/es/components/Carousel/CarouselNew/ui/Dots/Dots.js.map +1 -0
- package/es/components/Carousel/CarouselNew/ui/Dots/Dots.styles.js +31 -0
- package/es/components/Carousel/CarouselNew/ui/Dots/Dots.styles.js.map +1 -0
- package/es/components/Carousel/CarouselNew/ui/Dots/Dots.styles_ea836d.css +5 -0
- package/es/components/Carousel/CarouselNew/ui/Dots/utils/index.js +41 -0
- package/es/components/Carousel/CarouselNew/ui/Dots/utils/index.js.map +1 -0
- package/es/components/Carousel/CarouselNew/variations/_size/base.js +5 -0
- package/es/components/Carousel/CarouselNew/variations/_size/base.js.map +1 -0
- package/es/components/Carousel/CarouselNew/variations/_size/base_x642ct.css +1 -0
- package/es/components/Carousel/CarouselNew/variations/_view/base.js +5 -0
- package/es/components/Carousel/CarouselNew/variations/_view/base.js.map +1 -0
- package/es/components/Carousel/CarouselNew/variations/_view/base_x642ct.css +1 -0
- package/es/components/Carousel/CarouselOld/Carousel.css +4 -0
- package/es/components/Carousel/{Carousel.js → CarouselOld/Carousel.js} +1 -1
- package/es/components/Carousel/CarouselOld/Carousel.js.map +1 -0
- package/es/components/Carousel/{Carousel.styles.js → CarouselOld/Carousel.styles.js} +9 -9
- package/es/components/Carousel/CarouselOld/Carousel.styles.js.map +1 -0
- package/es/components/Carousel/CarouselOld/Carousel.styles_12r304j.css +4 -0
- package/es/components/Carousel/{CarouselItem.js → CarouselOld/CarouselItem.js} +5 -5
- package/es/components/Carousel/CarouselOld/CarouselItem.js.map +1 -0
- package/es/components/Carousel/CarouselOld/CarouselItem_cghzk7.css +1 -0
- package/es/components/Carousel/CarouselOld/useCarousel.js.map +1 -0
- package/es/components/Carousel/{useDragScroll.js → CarouselOld/useDragScroll.js} +1 -1
- package/es/components/Carousel/CarouselOld/useDragScroll.js.map +1 -0
- package/es/components/Mask/Mask.js +3 -3
- package/es/components/Mask/Mask.js.map +1 -1
- package/es/hooks/useDidMountLayoutEffect.js +15 -0
- package/es/hooks/useDidMountLayoutEffect.js.map +1 -0
- package/es/index.css +17 -5
- package/es/index.js +6 -3
- package/es/index.js.map +1 -1
- package/package.json +5 -5
- package/styled-components/cjs/components/Carousel/CarouselNew/Carousel.js +110 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/Carousel.styles.js +28 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/Carousel.tokens.js +22 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/Carousel.types.js +5 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/hooks/useCarousel.js +376 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.js +229 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.styles.js +24 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.types.js +5 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/ui/Dots/utils/index.js +44 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/ui/index.js +16 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/variations/_size/base.js +8 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/variations/_size/tokens.json +1 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/variations/_view/base.js +8 -0
- package/styled-components/cjs/components/Carousel/CarouselNew/variations/_view/tokens.json +1 -0
- package/styled-components/cjs/components/Carousel/{Carousel.styles.js → CarouselOld/Carousel.styles.js} +3 -3
- package/styled-components/cjs/components/Carousel/CarouselOld/Carousel.types.js +5 -0
- package/styled-components/cjs/components/Carousel/{CarouselItem.js → CarouselOld/CarouselItem.js} +2 -2
- package/styled-components/cjs/components/Carousel/CarouselOld/index.js +32 -0
- package/styled-components/cjs/components/Carousel/index.js +23 -3
- package/styled-components/cjs/components/Mask/Mask.js +3 -3
- package/styled-components/cjs/examples/plasma_b2c/components/Carousel/Carousel.config.js +14 -2
- package/styled-components/cjs/examples/plasma_b2c/components/Carousel/Carousel.js +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Carousel/Carousel.stories.tsx +90 -32
- package/styled-components/cjs/examples/plasma_web/components/Carousel/Carousel.config.js +14 -2
- package/styled-components/cjs/examples/plasma_web/components/Carousel/Carousel.js +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Carousel/Carousel.stories.tsx +91 -32
- package/styled-components/cjs/hooks/index.js +7 -0
- package/styled-components/cjs/hooks/useDidMountLayoutEffect.js +17 -0
- package/styled-components/es/components/Carousel/CarouselNew/Carousel.js +101 -0
- package/styled-components/es/components/Carousel/CarouselNew/Carousel.styles.js +20 -0
- package/styled-components/es/components/Carousel/CarouselNew/Carousel.tokens.js +16 -0
- package/styled-components/es/components/Carousel/CarouselNew/Carousel.types.js +1 -0
- package/styled-components/es/components/Carousel/CarouselNew/hooks/useCarousel.js +366 -0
- package/styled-components/es/components/Carousel/CarouselNew/ui/Dots/Dots.js +219 -0
- package/styled-components/es/components/Carousel/CarouselNew/ui/Dots/Dots.styles.js +17 -0
- package/styled-components/es/components/Carousel/CarouselNew/ui/Dots/Dots.types.js +1 -0
- package/styled-components/es/components/Carousel/CarouselNew/ui/Dots/utils/index.js +38 -0
- package/styled-components/es/components/Carousel/CarouselNew/ui/index.js +1 -0
- package/styled-components/es/components/Carousel/CarouselNew/variations/_size/base.js +2 -0
- package/styled-components/es/components/Carousel/CarouselNew/variations/_size/tokens.json +1 -0
- package/styled-components/es/components/Carousel/CarouselNew/variations/_view/base.js +2 -0
- package/styled-components/es/components/Carousel/CarouselNew/variations/_view/tokens.json +1 -0
- package/styled-components/es/components/Carousel/{Carousel.styles.js → CarouselOld/Carousel.styles.js} +3 -3
- package/styled-components/es/components/Carousel/CarouselOld/Carousel.types.js +1 -0
- package/styled-components/es/components/Carousel/{CarouselItem.js → CarouselOld/CarouselItem.js} +2 -2
- package/styled-components/es/components/Carousel/CarouselOld/index.js +3 -0
- package/styled-components/es/components/Carousel/index.js +7 -3
- package/styled-components/es/components/Mask/Mask.js +3 -3
- package/styled-components/es/examples/plasma_b2c/components/Carousel/Carousel.config.js +14 -2
- package/styled-components/es/examples/plasma_b2c/components/Carousel/Carousel.js +2 -2
- package/styled-components/es/examples/plasma_b2c/components/Carousel/Carousel.stories.tsx +90 -32
- package/styled-components/es/examples/plasma_web/components/Carousel/Carousel.config.js +14 -2
- package/styled-components/es/examples/plasma_web/components/Carousel/Carousel.js +2 -2
- package/styled-components/es/examples/plasma_web/components/Carousel/Carousel.stories.tsx +91 -32
- package/styled-components/es/hooks/index.js +1 -0
- package/styled-components/es/hooks/useDidMountLayoutEffect.js +11 -0
- package/types/components/Carousel/CarouselNew/Carousel.d.ts +26 -0
- package/types/components/Carousel/CarouselNew/Carousel.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/Carousel.styles.d.ts +91 -0
- package/types/components/Carousel/CarouselNew/Carousel.styles.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/Carousel.tokens.d.ts +17 -0
- package/types/components/Carousel/CarouselNew/Carousel.tokens.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/Carousel.types.d.ts +45 -0
- package/types/components/Carousel/CarouselNew/Carousel.types.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/hooks/useCarousel.d.ts +63 -0
- package/types/components/Carousel/CarouselNew/hooks/useCarousel.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/ui/Dots/Dots.d.ts +4 -0
- package/types/components/Carousel/CarouselNew/ui/Dots/Dots.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/ui/Dots/Dots.styles.d.ts +6 -0
- package/types/components/Carousel/CarouselNew/ui/Dots/Dots.styles.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/ui/Dots/Dots.types.d.ts +29 -0
- package/types/components/Carousel/CarouselNew/ui/Dots/Dots.types.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/ui/Dots/utils/index.d.ts +4 -0
- package/types/components/Carousel/CarouselNew/ui/Dots/utils/index.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/ui/index.d.ts +2 -0
- package/types/components/Carousel/CarouselNew/ui/index.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/variations/_size/base.d.ts +2 -0
- package/types/components/Carousel/CarouselNew/variations/_size/base.d.ts.map +1 -0
- package/types/components/Carousel/CarouselNew/variations/_view/base.d.ts +2 -0
- package/types/components/Carousel/CarouselNew/variations/_view/base.d.ts.map +1 -0
- package/types/components/Carousel/{Carousel.d.ts → CarouselOld/Carousel.d.ts} +1 -1
- package/types/components/Carousel/CarouselOld/Carousel.d.ts.map +1 -0
- package/types/components/Carousel/CarouselOld/Carousel.styles.d.ts.map +1 -0
- package/types/components/Carousel/{Carousel.types.d.ts → CarouselOld/Carousel.types.d.ts} +1 -1
- package/types/components/Carousel/CarouselOld/Carousel.types.d.ts.map +1 -0
- package/types/components/Carousel/CarouselOld/CarouselItem.d.ts.map +1 -0
- package/types/components/Carousel/CarouselOld/index.d.ts +5 -0
- package/types/components/Carousel/CarouselOld/index.d.ts.map +1 -0
- package/types/components/Carousel/CarouselOld/useCarousel.d.ts.map +1 -0
- package/types/components/Carousel/CarouselOld/useDragScroll.d.ts.map +1 -0
- package/types/components/Carousel/index.d.ts +7 -4
- package/types/components/Carousel/index.d.ts.map +1 -1
- package/types/hooks/index.d.ts +1 -0
- package/types/hooks/index.d.ts.map +1 -1
- package/types/hooks/useDidMountLayoutEffect.d.ts +2 -0
- package/types/hooks/useDidMountLayoutEffect.d.ts.map +1 -0
- package/cjs/components/Carousel/Carousel.css +0 -4
- package/cjs/components/Carousel/Carousel.js.map +0 -1
- package/cjs/components/Carousel/Carousel.styles.js.map +0 -1
- package/cjs/components/Carousel/Carousel.styles_zmchjj.css +0 -4
- package/cjs/components/Carousel/CarouselItem.js.map +0 -1
- package/cjs/components/Carousel/CarouselItem_cqjszm.css +0 -1
- package/cjs/components/Carousel/useCarousel.js.map +0 -1
- package/cjs/components/Carousel/useDragScroll.js.map +0 -1
- package/emotion/cjs/components/Carousel/Carousel.styles.js +0 -49
- package/emotion/es/components/Carousel/Carousel.styles.js +0 -42
- package/es/components/Carousel/Carousel.css +0 -4
- package/es/components/Carousel/Carousel.js.map +0 -1
- package/es/components/Carousel/Carousel.styles.js.map +0 -1
- package/es/components/Carousel/Carousel.styles_zmchjj.css +0 -4
- package/es/components/Carousel/CarouselItem.js.map +0 -1
- package/es/components/Carousel/CarouselItem_cqjszm.css +0 -1
- package/es/components/Carousel/useCarousel.js.map +0 -1
- package/es/components/Carousel/useDragScroll.js.map +0 -1
- package/types/components/Carousel/Carousel.d.ts.map +0 -1
- package/types/components/Carousel/Carousel.styles.d.ts.map +0 -1
- package/types/components/Carousel/Carousel.types.d.ts.map +0 -1
- package/types/components/Carousel/CarouselItem.d.ts.map +0 -1
- package/types/components/Carousel/useCarousel.d.ts.map +0 -1
- package/types/components/Carousel/useDragScroll.d.ts.map +0 -1
- /package/cjs/components/Carousel/{useCarousel.js → CarouselOld/useCarousel.js} +0 -0
- /package/emotion/cjs/components/Carousel/{Carousel.types.js → CarouselNew/Carousel.types.js} +0 -0
- /package/{styled-components/cjs/components/Carousel/Carousel.types.js → emotion/cjs/components/Carousel/CarouselNew/ui/Dots/Dots.types.js} +0 -0
- /package/emotion/cjs/components/Carousel/{Carousel.js → CarouselOld/Carousel.js} +0 -0
- /package/emotion/cjs/components/Carousel/{useCarousel.js → CarouselOld/useCarousel.js} +0 -0
- /package/emotion/cjs/components/Carousel/{useDragScroll.js → CarouselOld/useDragScroll.js} +0 -0
- /package/emotion/es/components/Carousel/{Carousel.types.js → CarouselNew/Carousel.types.js} +0 -0
- /package/{styled-components/es/components/Carousel/Carousel.types.js → emotion/es/components/Carousel/CarouselNew/ui/Dots/Dots.types.js} +0 -0
- /package/emotion/es/components/Carousel/{Carousel.js → CarouselOld/Carousel.js} +0 -0
- /package/emotion/es/components/Carousel/{useCarousel.js → CarouselOld/useCarousel.js} +0 -0
- /package/emotion/es/components/Carousel/{useDragScroll.js → CarouselOld/useDragScroll.js} +0 -0
- /package/es/components/Carousel/{useCarousel.js → CarouselOld/useCarousel.js} +0 -0
- /package/styled-components/cjs/components/Carousel/{Carousel.js → CarouselOld/Carousel.js} +0 -0
- /package/styled-components/cjs/components/Carousel/{useCarousel.js → CarouselOld/useCarousel.js} +0 -0
- /package/styled-components/cjs/components/Carousel/{useDragScroll.js → CarouselOld/useDragScroll.js} +0 -0
- /package/styled-components/es/components/Carousel/{Carousel.js → CarouselOld/Carousel.js} +0 -0
- /package/styled-components/es/components/Carousel/{useCarousel.js → CarouselOld/useCarousel.js} +0 -0
- /package/styled-components/es/components/Carousel/{useDragScroll.js → CarouselOld/useDragScroll.js} +0 -0
- /package/types/components/Carousel/{Carousel.styles.d.ts → CarouselOld/Carousel.styles.d.ts} +0 -0
- /package/types/components/Carousel/{CarouselItem.d.ts → CarouselOld/CarouselItem.d.ts} +0 -0
- /package/types/components/Carousel/{useCarousel.d.ts → CarouselOld/useCarousel.d.ts} +0 -0
- /package/types/components/Carousel/{useDragScroll.d.ts → CarouselOld/useDragScroll.d.ts} +0 -0
@@ -0,0 +1,366 @@
|
|
1
|
+
import { useEffect, useCallback, useRef, useMemo } from 'react';
|
2
|
+
import throttle from 'lodash.throttle';
|
3
|
+
/**
|
4
|
+
* Подсчет смещения из-за паддингов.
|
5
|
+
*/
|
6
|
+
export var getCalculatedOffset = function getCalculatedOffset(scrollEl, trackEl) {
|
7
|
+
var paddingProp = 'paddingLeft';
|
8
|
+
return parseInt(getComputedStyle(scrollEl)[paddingProp], 10) + parseInt(getComputedStyle(trackEl)[paddingProp], 10);
|
9
|
+
};
|
10
|
+
var positionModByScrollAlign = function positionModByScrollAlign(_ref) {
|
11
|
+
var scrollAlign = _ref.scrollAlign,
|
12
|
+
position = _ref.position,
|
13
|
+
carouselSize = _ref.carouselSize,
|
14
|
+
itemSize = _ref.itemSize,
|
15
|
+
offset = _ref.offset,
|
16
|
+
scrollStart = _ref.scrollStart;
|
17
|
+
if (scrollAlign === 'start') {
|
18
|
+
var paddingOffset = 0;
|
19
|
+
return position + paddingOffset;
|
20
|
+
}
|
21
|
+
if (scrollAlign === 'center') {
|
22
|
+
return position - carouselSize / 2 + itemSize / 2;
|
23
|
+
}
|
24
|
+
if (scrollAlign === 'end') {
|
25
|
+
return position - carouselSize + itemSize + offset;
|
26
|
+
}
|
27
|
+
if (scrollAlign === 'activeDirection') {
|
28
|
+
if (position >= scrollStart + carouselSize - itemSize) {
|
29
|
+
return position - carouselSize + itemSize + offset;
|
30
|
+
}
|
31
|
+
if (position > scrollStart) {
|
32
|
+
return scrollStart;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return position;
|
36
|
+
};
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Подсчет скролла до переданного индекса.
|
40
|
+
*/
|
41
|
+
export var getCalculatedPos = function getCalculatedPos(_ref2) {
|
42
|
+
var _items$item$offsetWid2, _items$item2;
|
43
|
+
var scrollEl = _ref2.scrollEl,
|
44
|
+
items = _ref2.items,
|
45
|
+
index = _ref2.index,
|
46
|
+
offset = _ref2.offset,
|
47
|
+
scrollAlign = _ref2.scrollAlign;
|
48
|
+
var position = scrollAlign === 'center' ? offset : 0;
|
49
|
+
if (items.item(index) === null) {
|
50
|
+
return position;
|
51
|
+
}
|
52
|
+
for (var i = 0; i < index; i++) {
|
53
|
+
var _items$item$offsetWid, _items$item;
|
54
|
+
position += (_items$item$offsetWid = (_items$item = items.item(i)) === null || _items$item === void 0 ? void 0 : _items$item.offsetWidth) !== null && _items$item$offsetWid !== void 0 ? _items$item$offsetWid : 0;
|
55
|
+
}
|
56
|
+
var carouselSize = scrollEl.offsetWidth;
|
57
|
+
var itemSize = (_items$item$offsetWid2 = (_items$item2 = items.item(index)) === null || _items$item2 === void 0 ? void 0 : _items$item2.offsetWidth) !== null && _items$item$offsetWid2 !== void 0 ? _items$item$offsetWid2 : 0;
|
58
|
+
var scrollStart = scrollEl.scrollLeft;
|
59
|
+
return positionModByScrollAlign({
|
60
|
+
scrollAlign: scrollAlign,
|
61
|
+
position: position,
|
62
|
+
carouselSize: carouselSize,
|
63
|
+
itemSize: itemSize,
|
64
|
+
offset: offset,
|
65
|
+
scrollStart: scrollStart
|
66
|
+
});
|
67
|
+
};
|
68
|
+
var DEFAULT_DURATION = 300;
|
69
|
+
|
70
|
+
// https://css-tricks.com/emulating-css-timing-functions-javascript/
|
71
|
+
var tfs = {
|
72
|
+
linear: function linear(t) {
|
73
|
+
return t;
|
74
|
+
},
|
75
|
+
// eslint-disable-next-line
|
76
|
+
easeIn: function easeIn(t) {
|
77
|
+
return Math.pow(t, 1.675);
|
78
|
+
},
|
79
|
+
// eslint-disable-next-line
|
80
|
+
easeOut: function easeOut(t) {
|
81
|
+
return 1 - Math.pow(1 - t, 1.675);
|
82
|
+
},
|
83
|
+
easeInOut: function easeInOut(t) {
|
84
|
+
return 0.5 * (Math.sin((t - 0.5) * Math.PI) + 1);
|
85
|
+
}
|
86
|
+
};
|
87
|
+
/**
|
88
|
+
* Плавная прокрутка по горизонтали
|
89
|
+
* @param {Element} elem
|
90
|
+
* @param {number} pos
|
91
|
+
* @param {number} duration
|
92
|
+
* @param {string} timingFunction
|
93
|
+
*/
|
94
|
+
export var animatedScrollToX = function animatedScrollToX(elem, pos) {
|
95
|
+
var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_DURATION;
|
96
|
+
var timingFunction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'easeInOut';
|
97
|
+
var startTime;
|
98
|
+
var startX = elem.scrollLeft;
|
99
|
+
var endX = Math.max(0, Math.min(elem.scrollWidth - elem.clientWidth, pos));
|
100
|
+
var handleNewAnimationFrame = function handleNewAnimationFrame() {
|
101
|
+
startTime = startTime || Date.now();
|
102
|
+
var timePos = Math.min(1, Math.max(1, Date.now() - startTime) / duration);
|
103
|
+
var scrollPos = tfs[timingFunction](timePos);
|
104
|
+
var left = startX + (endX - startX) * scrollPos;
|
105
|
+
elem.scrollTo({
|
106
|
+
left: left
|
107
|
+
});
|
108
|
+
if (timePos !== 1) window.requestAnimationFrame(handleNewAnimationFrame);
|
109
|
+
};
|
110
|
+
window.requestAnimationFrame(handleNewAnimationFrame);
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Прокрутка к указанной позиции с анимацией или без.
|
115
|
+
*/
|
116
|
+
export var scrollToPos = function scrollToPos(_ref3) {
|
117
|
+
var scrollEl = _ref3.scrollEl,
|
118
|
+
pos = _ref3.pos,
|
119
|
+
animated = _ref3.animated,
|
120
|
+
duration = _ref3.duration,
|
121
|
+
timingFunction = _ref3.timingFunction;
|
122
|
+
if (Math.abs(pos - scrollEl.scrollLeft) > 1) {
|
123
|
+
if (animated) {
|
124
|
+
animatedScrollToX(scrollEl, pos, duration, timingFunction);
|
125
|
+
} else {
|
126
|
+
scrollEl.scrollTo({
|
127
|
+
left: pos
|
128
|
+
});
|
129
|
+
}
|
130
|
+
}
|
131
|
+
};
|
132
|
+
var round = function round(n) {
|
133
|
+
return Math.round(n * 100) / 100;
|
134
|
+
};
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Получить позицию (слот) айтема в каруселе.
|
138
|
+
* Каждый айтем имеет свой слот относительно вьюпорта карусели.
|
139
|
+
*/
|
140
|
+
export var getItemSlot = function getItemSlot(itemIndex, itemEnd, itemSize, scrollStart, scrollSize, scrollAlign) {
|
141
|
+
var prevIndex = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
|
142
|
+
var offset = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
|
143
|
+
/**
|
144
|
+
* Граница и центр скролла (видимой части).
|
145
|
+
* Смещение + размер.
|
146
|
+
*/
|
147
|
+
var scrollEnd = scrollStart + scrollSize;
|
148
|
+
var scrollCenter = scrollStart + scrollSize / 2;
|
149
|
+
var itemCenter = itemEnd - itemSize / 2;
|
150
|
+
if (scrollAlign === 'center') {
|
151
|
+
return round((itemCenter - scrollCenter) / itemSize);
|
152
|
+
}
|
153
|
+
if (scrollAlign === 'start') {
|
154
|
+
return round((itemEnd - itemSize - scrollStart) / itemSize);
|
155
|
+
}
|
156
|
+
if (scrollAlign === 'end') {
|
157
|
+
return round((itemEnd - (scrollSize + scrollStart)) / itemSize);
|
158
|
+
}
|
159
|
+
if (scrollAlign === 'activeDirection') {
|
160
|
+
var prevStart = offset + itemSize * prevIndex;
|
161
|
+
var prevEnd = prevStart + itemSize;
|
162
|
+
var prevVisible = prevEnd > scrollStart && prevStart < scrollEnd;
|
163
|
+
if (!prevVisible) {
|
164
|
+
if (prevIndex < itemIndex) {
|
165
|
+
return round((itemEnd - (scrollSize + scrollStart)) / itemSize);
|
166
|
+
}
|
167
|
+
return round((itemEnd - itemSize - scrollStart) / itemSize);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
return null;
|
171
|
+
};
|
172
|
+
export function getCarouselItems(track) {
|
173
|
+
return track.children;
|
174
|
+
}
|
175
|
+
export function useDebouncedFunction(func, delay, cleanUp) {
|
176
|
+
var timeoutRef = useRef();
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Очистка таймера
|
180
|
+
*/
|
181
|
+
function clearTimer() {
|
182
|
+
if (timeoutRef.current) {
|
183
|
+
clearTimeout(timeoutRef.current);
|
184
|
+
timeoutRef.current = undefined;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Очищаем таймер при анмаунте компонента, если cleanUp выставлен в true
|
190
|
+
* и тем самым отменяем последний запланированный вызов
|
191
|
+
*/
|
192
|
+
useEffect(function () {
|
193
|
+
return cleanUp ? clearTimer : undefined;
|
194
|
+
}, [cleanUp]);
|
195
|
+
return function () {
|
196
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
197
|
+
args[_key] = arguments[_key];
|
198
|
+
}
|
199
|
+
clearTimer();
|
200
|
+
timeoutRef.current = setTimeout(function () {
|
201
|
+
return func.apply(void 0, args);
|
202
|
+
}, delay);
|
203
|
+
};
|
204
|
+
}
|
205
|
+
var THROTTLE_DEFAULT_MS = 100;
|
206
|
+
var DEBOUNCE_DEFAULT_MS = 150;
|
207
|
+
export var useCarousel = function useCarousel(_ref4) {
|
208
|
+
var index = _ref4.index,
|
209
|
+
onIndexChange = _ref4.onIndexChange,
|
210
|
+
_ref4$detectActive = _ref4.detectActive,
|
211
|
+
detectActive = _ref4$detectActive === void 0 ? false : _ref4$detectActive,
|
212
|
+
_ref4$detectThreshold = _ref4.detectThreshold,
|
213
|
+
detectThreshold = _ref4$detectThreshold === void 0 ? 0.5 : _ref4$detectThreshold,
|
214
|
+
_ref4$scrollAlign = _ref4.scrollAlign,
|
215
|
+
scrollAlign = _ref4$scrollAlign === void 0 ? 'center' : _ref4$scrollAlign,
|
216
|
+
_ref4$throttleMs = _ref4.throttleMs,
|
217
|
+
throttleMs = _ref4$throttleMs === void 0 ? THROTTLE_DEFAULT_MS : _ref4$throttleMs,
|
218
|
+
_ref4$debounceMs = _ref4.debounceMs,
|
219
|
+
debounceMs = _ref4$debounceMs === void 0 ? DEBOUNCE_DEFAULT_MS : _ref4$debounceMs;
|
220
|
+
var prevIndex = useRef(null);
|
221
|
+
var offset = useRef(0);
|
222
|
+
var scrollRef = useRef(null);
|
223
|
+
var trackRef = useRef(null);
|
224
|
+
var axis = 'x';
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Для того, чтобы не спамить изменениями индекса.
|
228
|
+
* Задержка дебаунса слегка больше, чем у тротлинга.
|
229
|
+
* Таким образом, событие срабатывает при завершении скролла.
|
230
|
+
*/
|
231
|
+
var debouncedOnIndexChange = useDebouncedFunction(function (i) {
|
232
|
+
return onIndexChange === null || onIndexChange === void 0 ? void 0 : onIndexChange(i);
|
233
|
+
}, debounceMs);
|
234
|
+
|
235
|
+
/**
|
236
|
+
* Вычисление центрального элемента.
|
237
|
+
* Подсчет: от 0 до 1, какое количество ширины/высоты
|
238
|
+
* каждого элемента находится по центру скролла.
|
239
|
+
*/
|
240
|
+
var throttledDetectActiveItem = useMemo(function () {
|
241
|
+
return throttle(function () {
|
242
|
+
if (!detectActive || scrollRef.current === null || trackRef.current === null) {
|
243
|
+
return;
|
244
|
+
}
|
245
|
+
|
246
|
+
/**
|
247
|
+
* Правая (или нижняя для Оу) граница элемента.
|
248
|
+
*/
|
249
|
+
var itemEdge = offset.current;
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Смещение (отрицательный или положительный отступ)
|
253
|
+
* и размер карусели (для Ox - ширина, для Oy - высота).
|
254
|
+
*/
|
255
|
+
var scrollPos = scrollRef.current[axis === 'x' ? 'scrollLeft' : 'scrollTop'];
|
256
|
+
var scrollSize = scrollRef.current[axis === 'x' ? 'offsetWidth' : 'offsetHeight'];
|
257
|
+
|
258
|
+
/**
|
259
|
+
* Граница скролла (видимой части).
|
260
|
+
* Смещение + размер.
|
261
|
+
*/
|
262
|
+
var scrollEdge = scrollPos + scrollSize;
|
263
|
+
var items = getCarouselItems(trackRef.current);
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Проходим по всему списку, суммируя ширины элементов,
|
267
|
+
* пока не найдем один элемент, чей центр будет в центре карусели.
|
268
|
+
*/
|
269
|
+
for (var itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
270
|
+
var _prevIndex$current;
|
271
|
+
var item = items.item(itemIndex);
|
272
|
+
if (item === null) {
|
273
|
+
// eslint-disable-next-line no-continue
|
274
|
+
continue;
|
275
|
+
}
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Для Ox - ширина, для Oy - высота.
|
279
|
+
*/
|
280
|
+
var itemSize = item[axis === 'x' ? 'offsetWidth' : 'offsetHeight'];
|
281
|
+
|
282
|
+
/**
|
283
|
+
* Все элементы правее вьюпорта выпадают из процедуры.
|
284
|
+
* Сравниваем по предыдущему элементу.
|
285
|
+
* [ ... ] ...|n| <- Левый край элемента за пределами начала видимой части
|
286
|
+
*/
|
287
|
+
if (itemEdge > scrollEdge) {
|
288
|
+
// eslint-disable-next-line no-continue
|
289
|
+
continue;
|
290
|
+
}
|
291
|
+
itemEdge += itemSize;
|
292
|
+
|
293
|
+
/**
|
294
|
+
* Все элементы левее вьюпорта выпадают из процедуры.
|
295
|
+
* Сравниваем по текущему элементу.
|
296
|
+
* Правый край элемента за пределами начала видимой части -> |p|... [ ... ]
|
297
|
+
*/
|
298
|
+
if (scrollPos > itemEdge) {
|
299
|
+
// eslint-disable-next-line no-continue
|
300
|
+
continue;
|
301
|
+
}
|
302
|
+
var itemSlot = getItemSlot(itemIndex, itemEdge, itemSize, scrollPos, scrollSize, scrollAlign, (_prevIndex$current = prevIndex.current) !== null && _prevIndex$current !== void 0 ? _prevIndex$current : 0, offset.current);
|
303
|
+
if (itemSlot !== null) {
|
304
|
+
if (detectThreshold && Math.abs(itemSlot) <= detectThreshold) {
|
305
|
+
debouncedOnIndexChange === null || debouncedOnIndexChange === void 0 || debouncedOnIndexChange(itemIndex);
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}, throttleMs);
|
310
|
+
}, [debouncedOnIndexChange, detectActive, detectThreshold, scrollAlign, throttleMs]);
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Прокрутка до нужной позиции индекса.
|
314
|
+
*/
|
315
|
+
var toIndex = useCallback(function (i) {
|
316
|
+
var scrollEl = scrollRef.current;
|
317
|
+
var items = trackRef.current ? getCarouselItems(trackRef.current) : null;
|
318
|
+
if (scrollEl && items && items.length > 0 && i >= 0) {
|
319
|
+
scrollToPos({
|
320
|
+
scrollEl: scrollEl,
|
321
|
+
pos: getCalculatedPos({
|
322
|
+
scrollEl: scrollEl,
|
323
|
+
items: items,
|
324
|
+
index: i,
|
325
|
+
offset: offset.current,
|
326
|
+
scrollAlign: scrollAlign
|
327
|
+
})
|
328
|
+
});
|
329
|
+
prevIndex.current = i;
|
330
|
+
}
|
331
|
+
}, [scrollAlign]);
|
332
|
+
useEffect(function () {
|
333
|
+
if (scrollRef.current && trackRef.current) {
|
334
|
+
offset.current = getCalculatedOffset(scrollRef.current, trackRef.current);
|
335
|
+
}
|
336
|
+
}, []);
|
337
|
+
|
338
|
+
/**
|
339
|
+
* Операции на маунте/анмаунте компонента.
|
340
|
+
* Создать слушатели событи и т.п.
|
341
|
+
*/
|
342
|
+
useEffect(function () {
|
343
|
+
var carouselElement = scrollRef.current;
|
344
|
+
if (carouselElement) {
|
345
|
+
carouselElement.addEventListener('scroll', throttledDetectActiveItem);
|
346
|
+
}
|
347
|
+
return function () {
|
348
|
+
if (carouselElement) {
|
349
|
+
carouselElement.removeEventListener('scroll', throttledDetectActiveItem);
|
350
|
+
}
|
351
|
+
};
|
352
|
+
}, [throttledDetectActiveItem]);
|
353
|
+
|
354
|
+
/**
|
355
|
+
* Прокрутка до нужной позиции индекса, если индекс изменился.
|
356
|
+
*/
|
357
|
+
useEffect(function () {
|
358
|
+
if (index !== prevIndex.current) {
|
359
|
+
toIndex(index);
|
360
|
+
}
|
361
|
+
}, [index, toIndex]);
|
362
|
+
return {
|
363
|
+
scrollRef: scrollRef,
|
364
|
+
trackRef: trackRef
|
365
|
+
};
|
366
|
+
};
|
@@ -0,0 +1,219 @@
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
7
|
+
import React, { memo, useRef, useLayoutEffect } from 'react';
|
8
|
+
import cls from 'classnames';
|
9
|
+
import { useDidMountLayoutEffect } from "../../../../../hooks";
|
10
|
+
import { classes } from "../../Carousel.tokens";
|
11
|
+
import { getActiveIndex, getTargetIndex, getInitialData } from "./utils/index";
|
12
|
+
import { Wrapper, DotWrapper, RightAnimationWrapper, LeftAnimationWrapper, TransitionWrapper } from "./Dots.styles";
|
13
|
+
var SIZE = 16; // размер точки в px
|
14
|
+
var ANIMATION_DURATION = 0.3; // скорость анимации в секундах
|
15
|
+
|
16
|
+
export var Dots = /*#__PURE__*/memo(function (_ref) {
|
17
|
+
var _ref$index = _ref.index,
|
18
|
+
originalIndex = _ref$index === void 0 ? 0 : _ref$index,
|
19
|
+
onChange = _ref.onChange,
|
20
|
+
_ref$centered = _ref.centered,
|
21
|
+
centered = _ref$centered === void 0 ? false : _ref$centered,
|
22
|
+
_ref$count = _ref.count,
|
23
|
+
count = _ref$count === void 0 ? 0 : _ref$count,
|
24
|
+
_ref$visibleCount = _ref.visibleCount,
|
25
|
+
originalVisibleCount = _ref$visibleCount === void 0 ? 0 : _ref$visibleCount;
|
26
|
+
// Трансформируем входные параметры для корректной работы в дальнейшем
|
27
|
+
var _getInitialData = getInitialData(originalIndex, count, originalVisibleCount),
|
28
|
+
_getInitialData2 = _slicedToArray(_getInitialData, 2),
|
29
|
+
index = _getInitialData2[0],
|
30
|
+
visibleCount = _getInitialData2[1];
|
31
|
+
|
32
|
+
// Рефки на DOM-ноды
|
33
|
+
var transitionWrapperRef = useRef(null);
|
34
|
+
var dotWrapperRef = useRef(null);
|
35
|
+
var leftAnimationWrapperRef = useRef(null);
|
36
|
+
var rightAnimationWrapperRef = useRef(null);
|
37
|
+
|
38
|
+
// Консистентные переменные
|
39
|
+
var isAnimating = useRef(false);
|
40
|
+
var prevIndex = useRef(-Infinity);
|
41
|
+
var prevActiveIndex = useRef(Infinity);
|
42
|
+
var isRightDirection = index > prevIndex.current;
|
43
|
+
var diffDotsRange = Math.abs(index - prevIndex.current);
|
44
|
+
var activeIndex = getActiveIndex(index, isRightDirection, count, visibleCount);
|
45
|
+
var hiddenDotsLeft = activeIndex < index;
|
46
|
+
var hiddenDotsRight = index + (visibleCount - 1 - activeIndex) < count - 1;
|
47
|
+
var handleClick = function handleClick(i) {
|
48
|
+
if (isAnimating.current) return;
|
49
|
+
if (onChange) {
|
50
|
+
onChange(index + (i - activeIndex));
|
51
|
+
}
|
52
|
+
};
|
53
|
+
var handleTransitionEnd = function handleTransitionEnd() {
|
54
|
+
if (!dotWrapperRef || !dotWrapperRef.current || !transitionWrapperRef || !transitionWrapperRef.current || !rightAnimationWrapperRef || !rightAnimationWrapperRef.current || !leftAnimationWrapperRef || !leftAnimationWrapperRef.current) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
dotWrapperRef.current.classList.remove(classes.animating);
|
58
|
+
transitionWrapperRef.current.classList.remove(classes.animating);
|
59
|
+
Array.from(dotWrapperRef.current.children).forEach(function (child) {
|
60
|
+
var _child$classList;
|
61
|
+
(_child$classList = child.classList).remove.apply(_child$classList, [classes.active, classes.animateOut, classes.temporaryNatural, classes.shrinking]);
|
62
|
+
});
|
63
|
+
dotWrapperRef.current.children[activeIndex].classList.add(classes.active);
|
64
|
+
if (centered) {
|
65
|
+
transitionWrapperRef.current.style.transform = "translateX(".concat(visibleCount * SIZE / 2 - SIZE / 2 - activeIndex * SIZE, "px)");
|
66
|
+
} else {
|
67
|
+
transitionWrapperRef.current.style.transform = 'translateX(0)';
|
68
|
+
}
|
69
|
+
setTimeout(function () {
|
70
|
+
if (transitionWrapperRef && transitionWrapperRef.current) {
|
71
|
+
isAnimating.current = false;
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
// Очищаем блоки с анимированными точками
|
76
|
+
leftAnimationWrapperRef.current.innerText = '';
|
77
|
+
rightAnimationWrapperRef.current.innerText = '';
|
78
|
+
prevIndex.current = index;
|
79
|
+
prevActiveIndex.current = activeIndex;
|
80
|
+
isAnimating.current = false;
|
81
|
+
};
|
82
|
+
useLayoutEffect(function () {
|
83
|
+
if (!dotWrapperRef || !dotWrapperRef.current || !transitionWrapperRef || !transitionWrapperRef.current) {
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
|
87
|
+
// Вычисляем начальный сдвиг по горизонтали, чтобы точка стала по центру
|
88
|
+
if (centered) {
|
89
|
+
transitionWrapperRef.current.style.transform = "translateX(".concat(visibleCount * SIZE / 2 - SIZE / 2 - activeIndex * SIZE, "px)");
|
90
|
+
}
|
91
|
+
prevIndex.current = index;
|
92
|
+
prevActiveIndex.current = activeIndex;
|
93
|
+
}, []);
|
94
|
+
useDidMountLayoutEffect(function () {
|
95
|
+
var _dotWrapperRef$curren;
|
96
|
+
if (!dotWrapperRef || !dotWrapperRef.current || !transitionWrapperRef || !transitionWrapperRef.current || !leftAnimationWrapperRef || !leftAnimationWrapperRef.current || !rightAnimationWrapperRef || !rightAnimationWrapperRef.current || isAnimating.current) {
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
isAnimating.current = true;
|
100
|
+
dotWrapperRef.current.classList.add(classes.animating);
|
101
|
+
transitionWrapperRef.current.classList.add(classes.animating);
|
102
|
+
var targetIndex = getTargetIndex(index, prevIndex.current, prevActiveIndex.current, diffDotsRange);
|
103
|
+
var dotsToAdd = Math.abs(targetIndex - activeIndex);
|
104
|
+
if (centered) {
|
105
|
+
transitionWrapperRef.current.style.transform = "translateX(".concat(visibleCount * SIZE / 2 - SIZE / 2 - targetIndex * SIZE, "px)");
|
106
|
+
} else if (dotsToAdd > 0) {
|
107
|
+
transitionWrapperRef.current.style.transform = "translateX(".concat(-SIZE * (targetIndex - activeIndex), "px)");
|
108
|
+
}
|
109
|
+
|
110
|
+
// Стираем все активные классы и устанавливаем активный класс на таргет.
|
111
|
+
// В конце анимации произойдет переопределение активного класса.
|
112
|
+
Array.from(dotWrapperRef.current.children).forEach(function (child) {
|
113
|
+
child.classList.remove(classes.active);
|
114
|
+
});
|
115
|
+
(_dotWrapperRef$curren = dotWrapperRef.current.children[targetIndex]) === null || _dotWrapperRef$curren === void 0 || _dotWrapperRef$curren.classList.add(classes.active);
|
116
|
+
if (index > prevIndex.current) {
|
117
|
+
// Двигаемся вправо
|
118
|
+
|
119
|
+
// Если мы добавляем 1 и более точек, то нужно начать
|
120
|
+
// приводить размер крайней правой точки (что будет в m размере?)
|
121
|
+
// к натуральному размеру
|
122
|
+
if (dotsToAdd >= 1) {
|
123
|
+
var _dotWrapperRef$curren2;
|
124
|
+
(_dotWrapperRef$curren2 = dotWrapperRef.current.children[visibleCount - 1]) === null || _dotWrapperRef$curren2 === void 0 || _dotWrapperRef$curren2.classList.add(classes.temporaryNatural);
|
125
|
+
}
|
126
|
+
|
127
|
+
// Т.к. мы двигаемся вправо, то нужно начать уменьшать размер крайней левой точки
|
128
|
+
// (опять же, что в m size?)
|
129
|
+
if (dotsToAdd >= 1) {
|
130
|
+
var _dotWrapperRef$curren3;
|
131
|
+
(_dotWrapperRef$curren3 = dotWrapperRef.current.children[dotsToAdd]) === null || _dotWrapperRef$curren3 === void 0 || _dotWrapperRef$curren3.classList.add(classes.shrinking);
|
132
|
+
}
|
133
|
+
if (dotsToAdd > 0) {
|
134
|
+
var _loop = function _loop() {
|
135
|
+
var _dotWrapperRef$curren4;
|
136
|
+
var node = document.createElement('div');
|
137
|
+
node.textContent = '';
|
138
|
+
node.classList.add(classes.dot);
|
139
|
+
node.style.opacity = '0';
|
140
|
+
var delay = i * (ANIMATION_DURATION / dotsToAdd);
|
141
|
+
node.style.animationDelay = "".concat(delay, "s");
|
142
|
+
rightAnimationWrapperRef.current.appendChild(node);
|
143
|
+
var duration = ANIMATION_DURATION / dotsToAdd;
|
144
|
+
requestAnimationFrame(function () {
|
145
|
+
node.classList.add(classes.animateIn);
|
146
|
+
node.style.animationDuration = "".concat(duration, "s");
|
147
|
+
});
|
148
|
+
var currentDomNode = (_dotWrapperRef$curren4 = dotWrapperRef.current.children) === null || _dotWrapperRef$curren4 === void 0 ? void 0 : _dotWrapperRef$curren4[i];
|
149
|
+
currentDomNode === null || currentDomNode === void 0 || currentDomNode.classList.add(classes.animateOut);
|
150
|
+
currentDomNode.style.animationDelay = "".concat(delay, "s");
|
151
|
+
currentDomNode.style.animationDuration = "".concat(duration, "s");
|
152
|
+
};
|
153
|
+
for (var i = 0; i < dotsToAdd; i++) {
|
154
|
+
_loop();
|
155
|
+
}
|
156
|
+
}
|
157
|
+
} else {
|
158
|
+
// Двигаемся влево
|
159
|
+
|
160
|
+
// Если мы добавляем 1 и более точек, то нужно начать
|
161
|
+
// приводить размер крайней левой точки (что будет в m размере?)
|
162
|
+
// к натуральному размеру.
|
163
|
+
if (dotsToAdd >= 1) {
|
164
|
+
var _dotWrapperRef$curren5;
|
165
|
+
(_dotWrapperRef$curren5 = dotWrapperRef.current.children[0]) === null || _dotWrapperRef$curren5 === void 0 || _dotWrapperRef$curren5.classList.add(classes.temporaryNatural);
|
166
|
+
}
|
167
|
+
|
168
|
+
// Т.к. мы двигаемся влево, то нужно начать уменьшать размер крайней правой точки
|
169
|
+
// (опять же, что в m size?)
|
170
|
+
if (dotsToAdd >= 1) {
|
171
|
+
var _dotWrapperRef$curren6;
|
172
|
+
(_dotWrapperRef$curren6 = dotWrapperRef.current.children[visibleCount - 1 - dotsToAdd]) === null || _dotWrapperRef$curren6 === void 0 || _dotWrapperRef$curren6.classList.add(classes.shrinking);
|
173
|
+
}
|
174
|
+
if (dotsToAdd > 0) {
|
175
|
+
var _loop2 = function _loop2() {
|
176
|
+
var _dotWrapperRef$curren7;
|
177
|
+
var node = document.createElement('div');
|
178
|
+
node.textContent = '';
|
179
|
+
node.classList.add(classes.dot);
|
180
|
+
node.style.opacity = '0';
|
181
|
+
var delay = (dotsToAdd - 1 - _i) * (ANIMATION_DURATION / dotsToAdd);
|
182
|
+
node.style.animationDelay = "".concat(delay, "s");
|
183
|
+
leftAnimationWrapperRef.current.prepend(node);
|
184
|
+
var duration = ANIMATION_DURATION / dotsToAdd;
|
185
|
+
requestAnimationFrame(function () {
|
186
|
+
node.classList.add(classes.animateIn);
|
187
|
+
node.style.animationDuration = "".concat(duration, "s");
|
188
|
+
});
|
189
|
+
var currentDomNode = (_dotWrapperRef$curren7 = dotWrapperRef.current.children) === null || _dotWrapperRef$curren7 === void 0 ? void 0 : _dotWrapperRef$curren7[dotWrapperRef.current.children.length - 1 - _i];
|
190
|
+
currentDomNode === null || currentDomNode === void 0 || currentDomNode.classList.add(classes.animateOut);
|
191
|
+
currentDomNode.style.animationDelay = "".concat(_i * (ANIMATION_DURATION / dotsToAdd), "s");
|
192
|
+
currentDomNode.style.animationDuration = "".concat(duration, "s");
|
193
|
+
};
|
194
|
+
for (var _i = dotsToAdd - 1; _i >= 0; _i--) {
|
195
|
+
_loop2();
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}, [index]);
|
200
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(TransitionWrapper, {
|
201
|
+
ref: transitionWrapperRef,
|
202
|
+
onTransitionEnd: handleTransitionEnd
|
203
|
+
}, /*#__PURE__*/React.createElement(LeftAnimationWrapper, {
|
204
|
+
ref: leftAnimationWrapperRef
|
205
|
+
}), /*#__PURE__*/React.createElement(DotWrapper, {
|
206
|
+
ref: dotWrapperRef,
|
207
|
+
className: cls(hiddenDotsLeft && classes.availableDotsLeft, hiddenDotsRight && classes.availableDotsRight)
|
208
|
+
}, Array(visibleCount).fill(0).map(function (_, i) {
|
209
|
+
return /*#__PURE__*/React.createElement("div", {
|
210
|
+
key: i,
|
211
|
+
className: cls(classes.dot, i === activeIndex && classes.active),
|
212
|
+
onClick: function onClick() {
|
213
|
+
return handleClick(i);
|
214
|
+
}
|
215
|
+
});
|
216
|
+
})), /*#__PURE__*/React.createElement(RightAnimationWrapper, {
|
217
|
+
ref: rightAnimationWrapperRef
|
218
|
+
})));
|
219
|
+
});
|