@hh.ru/magritte-ui-scrollable-container 5.3.0 → 6.0.1
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/ObservableValue.d.ts +13 -0
- package/ObservableValue.js +24 -0
- package/ObservableValue.js.map +1 -0
- package/ScrollStateProvider.d.ts +35 -0
- package/ScrollStateProvider.js +22 -0
- package/ScrollStateProvider.js.map +1 -0
- package/ScrollableContainer.d.ts +19 -12
- package/ScrollableContainer.js +48 -104
- package/ScrollableContainer.js.map +1 -1
- package/ScrollableContainerButton.d.ts +4 -0
- package/ScrollableContainerButton.js +28 -0
- package/ScrollableContainerButton.js.map +1 -0
- package/ScrollableContainerDefaultLayout.d.ts +3 -0
- package/ScrollableContainerDefaultLayout.js +72 -0
- package/ScrollableContainerDefaultLayout.js.map +1 -0
- package/ScrollableContainerDotPages.d.ts +3 -0
- package/ScrollableContainerDotPages.js +67 -0
- package/ScrollableContainerDotPages.js.map +1 -0
- package/ScrollableContainerGallery.d.ts +4 -0
- package/ScrollableContainerGallery.js +76 -0
- package/ScrollableContainerGallery.js.map +1 -0
- package/ScrollableItem.d.ts +3 -2
- package/ScrollableItem.js +15 -10
- package/ScrollableItem.js.map +1 -1
- package/index.css +18 -44
- package/index.d.ts +5 -3
- package/index.js +16 -6
- package/index.js.map +1 -1
- package/index.mock.d.ts +5 -4
- package/index.mock.js +35 -11
- package/index.mock.js.map +1 -1
- package/package.json +4 -3
- package/scrollableContainer-DSb3wQO4.js +5 -0
- package/scrollableContainer-DSb3wQO4.js.map +1 -0
- package/types.d.ts +61 -83
- package/types.js.map +1 -1
- package/useScrollContainer.d.ts +20 -13
- package/useScrollContainer.js +190 -7
- package/useScrollContainer.js.map +1 -1
- package/useScrollableControls.d.ts +4 -0
- package/useScrollableControls.js +60 -0
- package/useScrollableControls.js.map +1 -0
- package/utils.d.ts +80 -0
- package/utils.js +277 -1
- package/utils.js.map +1 -1
- package/useScrollContainer-DvtB6-c_.js +0 -491
- package/useScrollContainer-DvtB6-c_.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollableContainerDotPages.js","sources":["../src/ScrollableContainerDotPages.tsx"],"sourcesContent":["import { type FC, useState, useEffect, useRef } from 'react';\n\nimport { clamp } from '@hh.ru/magritte-internal-custom-scroll/initScrollHandlers';\nimport { DotPages } from '@hh.ru/magritte-ui-dot-pages';\nimport { useScrollState } from '@hh.ru/magritte-ui-scrollable-container/ScrollStateProvider';\nimport { OFFSET_ATTR, ScrollableContainerDotPagesProps } from '@hh.ru/magritte-ui-scrollable-container/types';\nimport { useInitOnce, findIndexNearestToSnapPoint } from '@hh.ru/magritte-ui-scrollable-container/utils';\nimport { VSpacing } from '@hh.ru/magritte-ui-spacing';\n\nimport styles from './scrollableContainer.less';\n\nconst DEFAULT_DOT = 1;\n\nexport const ScrollableContainerDotPages: FC<ScrollableContainerDotPagesProps> = ({\n onChangeDot,\n dotPagesProps,\n offsetTop = 8,\n}) => {\n const scrollState = useScrollState();\n const [activeDot, setActiveDot] = useState(DEFAULT_DOT);\n const [itemsCount, setItemsCount] = useState(0);\n const activeDotRef = useRef(DEFAULT_DOT);\n const onChangeDotRef = useRef(onChangeDot);\n onChangeDotRef.current = onChangeDot;\n\n const setDotAndEmitOnChange = useInitOnce(() => (dot: number) => {\n if (dot === activeDotRef.current) {\n return;\n }\n setActiveDot(dot);\n onChangeDotRef.current?.(dot);\n activeDotRef.current = dot;\n });\n\n const updateActiveDot = useInitOnce(() => () => {\n const { viewportWidth, scrollPosition, items } = scrollState;\n const center = viewportWidth.get() / 2 + Math.abs(scrollPosition.get());\n const activeDotItem = items.get()[activeDotRef.current - 1]?.current;\n if (\n !activeDotItem ||\n !activeDotItem[OFFSET_ATTR] ||\n (activeDotItem[OFFSET_ATTR].left <= center && activeDotItem[OFFSET_ATTR].right >= center)\n ) {\n return;\n }\n setDotAndEmitOnChange(findIndexNearestToSnapPoint(scrollState) + 1);\n });\n\n useEffect(() => {\n const unsubscribe = [\n scrollState.scrollPosition.on('change', updateActiveDot),\n scrollState.items.on('change', (items) => {\n setItemsCount(items.length);\n // удалили последний элемент и он был активный\n if (activeDotRef.current > items.length && items.length !== 0) {\n setDotAndEmitOnChange(clamp(activeDotRef.current, 0, items.length - 1));\n return;\n }\n updateActiveDot();\n }),\n ];\n return () => {\n unsubscribe.forEach((fn) => fn());\n };\n }, [scrollState, updateActiveDot, setDotAndEmitOnChange]);\n\n if (itemsCount === 0) {\n return null;\n }\n\n return (\n <div>\n <VSpacing default={offsetTop} />\n <div className={styles.dotContainer}>\n <DotPages\n active={activeDot}\n count={itemsCount}\n data-qa={dotPagesProps?.['data-qa'] || 'scrollable-container__dot-pages'}\n {...dotPagesProps}\n />\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;AAWA,MAAM,WAAW,GAAG,CAAC,CAAC;AAEf,MAAM,2BAA2B,GAAyC,CAAC,EAC9E,WAAW,EACX,aAAa,EACb,SAAS,GAAG,CAAC,GAChB,KAAI;AACD,IAAA,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IACxD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAChD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AACzC,IAAA,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAC3C,IAAA,cAAc,CAAC,OAAO,GAAG,WAAW,CAAC;IAErC,MAAM,qBAAqB,GAAG,WAAW,CAAC,MAAM,CAAC,GAAW,KAAI;AAC5D,QAAA,IAAI,GAAG,KAAK,YAAY,CAAC,OAAO,EAAE;YAC9B,OAAO;SACV;QACD,YAAY,CAAC,GAAG,CAAC,CAAC;AAClB,QAAA,cAAc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,GAAG,CAAC,CAAC,CAAC,CAAC;oBACxE,OAAO;iBACV;AACD,gBAAA,eAAe,EAAE,CAAC;AACtB,aAAC,CAAC;SACL,CAAC;AACF,QAAA,OAAO,MAAK;YACR,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AACtC,SAAC,CAAC;KACL,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAE1D,IAAA,IAAI,UAAU,KAAK,CAAC,EAAE;AAClB,QAAA,OAAO,IAAI,CAAC;KACf;AAED,IAAA,QACIA,IACI,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,CAAAC,GAAA,CAAC,QAAQ,EAAC,EAAA,OAAO,EAAE,SAAS,EAAA,CAAI,EAChCA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA,QAAA,EAC/BA,IAAC,QAAQ,EAAA,EACL,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,UAAU,EAAA,SAAA,EACR,aAAa,GAAG,SAAS,CAAC,IAAI,iCAAiC,EACpE,GAAA,aAAa,GACnB,EACA,CAAA,CAAA,EAAA,CACJ,EACR;AACN;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import type { ScrollableContainerGalleryProps, RegisterAndRemoveItem } from '@hh.ru/magritte-ui-scrollable-container/types';
|
|
3
|
+
export declare const useGalleryContext: () => RegisterAndRemoveItem;
|
|
4
|
+
export declare const ScrollableContainerGallery: FC<ScrollableContainerGalleryProps>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { createContext, useContext, useRef, useEffect } from 'react';
|
|
4
|
+
import { useSpring, motion, animate } from 'motion/react';
|
|
5
|
+
import { clamp } from '@hh.ru/magritte-internal-custom-scroll/initScrollHandlers';
|
|
6
|
+
import { useScrollState } from './ScrollStateProvider.js';
|
|
7
|
+
import { useScrollContainer } from './useScrollContainer.js';
|
|
8
|
+
import { getDisableState, findIndexNearestToSnapPoint, computeScrollSnapBehavior } from './utils.js';
|
|
9
|
+
import { s as styles } from './scrollableContainer-DSb3wQO4.js';
|
|
10
|
+
import './ObservableValue.js';
|
|
11
|
+
import '@hh.ru/magritte-common-func-utils';
|
|
12
|
+
import '@hh.ru/magritte-internal-custom-scroll';
|
|
13
|
+
import './types.js';
|
|
14
|
+
import './useScrollableControls.js';
|
|
15
|
+
import '@hh.ru/magritte-ui-breakpoint';
|
|
16
|
+
|
|
17
|
+
const GalleryContext = createContext({
|
|
18
|
+
registerItem: () => null,
|
|
19
|
+
removeItem: () => null,
|
|
20
|
+
});
|
|
21
|
+
const useGalleryContext = () => useContext(GalleryContext);
|
|
22
|
+
const ScrollableContainerGallery = ({ children, onScroll, onReady, onChangeSize, }) => {
|
|
23
|
+
const scrollState = useScrollState();
|
|
24
|
+
const onReadyRef = useRef(onReady);
|
|
25
|
+
const onScrollRef = useRef(onScroll);
|
|
26
|
+
const onChangeSizeRef = useRef(onChangeSize);
|
|
27
|
+
onReadyRef.current = onReady;
|
|
28
|
+
onScrollRef.current = onScroll;
|
|
29
|
+
onChangeSizeRef.current = onChangeSize;
|
|
30
|
+
const { registerItem, removeItem, initScrollHandlers, containerRef, positionContainerRef, isTouch } = useScrollContainer();
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const { scrollPosition, viewportWidth, contentWidth } = scrollState;
|
|
33
|
+
const updateScrollPositionByResize = () => {
|
|
34
|
+
const index = findIndexNearestToSnapPoint(scrollState);
|
|
35
|
+
const scrollSnapBehavior = computeScrollSnapBehavior(scrollState);
|
|
36
|
+
const target = scrollSnapBehavior(scrollState, index);
|
|
37
|
+
if (target === null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const position = clamp(target, viewportWidth.get() - contentWidth.get(), 0);
|
|
41
|
+
onChangeSizeRef.current?.(getDisableState(scrollState));
|
|
42
|
+
if (scrollPosition.get() === position) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
animate(scrollPosition, position, {
|
|
46
|
+
velocity: Math.max(scrollPosition.getVelocity(), 1),
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const unsubscribe = [
|
|
50
|
+
scrollPosition.on('change', () => {
|
|
51
|
+
onScrollRef.current?.(getDisableState(scrollState));
|
|
52
|
+
}),
|
|
53
|
+
viewportWidth.on('change', updateScrollPositionByResize),
|
|
54
|
+
contentWidth.on('change', updateScrollPositionByResize),
|
|
55
|
+
];
|
|
56
|
+
return () => {
|
|
57
|
+
unsubscribe.forEach((fn) => fn());
|
|
58
|
+
};
|
|
59
|
+
}, [scrollState]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
onReadyRef.current?.(getDisableState(scrollState));
|
|
62
|
+
return initScrollHandlers();
|
|
63
|
+
}, [initScrollHandlers, scrollState]);
|
|
64
|
+
const springScrollPosition = useSpring(scrollState.scrollPosition, {
|
|
65
|
+
stiffness: 1800,
|
|
66
|
+
damping: 75,
|
|
67
|
+
mass: 0.5,
|
|
68
|
+
});
|
|
69
|
+
return (jsx(GalleryContext.Provider, { value: {
|
|
70
|
+
registerItem,
|
|
71
|
+
removeItem,
|
|
72
|
+
}, children: jsx("div", { ref: containerRef, className: styles.scrollableContainer, "data-qa": "scrollable-container__overflow-container", children: jsx(motion.div, { ref: positionContainerRef, "data-qa": "scrollable-container__position-container", className: styles.positionContainer, style: { x: isTouch ? scrollState.scrollPosition : springScrollPosition }, children: children }) }) }));
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export { ScrollableContainerGallery, useGalleryContext };
|
|
76
|
+
//# sourceMappingURL=ScrollableContainerGallery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollableContainerGallery.js","sources":["../src/ScrollableContainerGallery.tsx"],"sourcesContent":["import { type FC, createContext, useContext, useEffect, useRef } from 'react';\nimport { animate, motion, useSpring } from 'motion/react';\n\nimport { clamp } from '@hh.ru/magritte-internal-custom-scroll/initScrollHandlers';\nimport { useScrollState } from '@hh.ru/magritte-ui-scrollable-container/ScrollStateProvider';\nimport type {\n ScrollableContainerGalleryProps,\n RegisterAndRemoveItem,\n} from '@hh.ru/magritte-ui-scrollable-container/types';\nimport { useScrollContainer } from '@hh.ru/magritte-ui-scrollable-container/useScrollContainer';\nimport {\n getDisableState,\n findIndexNearestToSnapPoint,\n computeScrollSnapBehavior,\n} from '@hh.ru/magritte-ui-scrollable-container/utils';\n\nimport styles from './scrollableContainer.less';\n\nconst GalleryContext = createContext<RegisterAndRemoveItem>({\n registerItem: () => null,\n removeItem: () => null,\n});\n\nexport const useGalleryContext = (): RegisterAndRemoveItem => useContext(GalleryContext);\n\nexport const ScrollableContainerGallery: FC<ScrollableContainerGalleryProps> = ({\n children,\n onScroll,\n onReady,\n onChangeSize,\n}) => {\n const scrollState = useScrollState();\n const onReadyRef = useRef(onReady);\n const onScrollRef = useRef(onScroll);\n const onChangeSizeRef = useRef(onChangeSize);\n onReadyRef.current = onReady;\n onScrollRef.current = onScroll;\n onChangeSizeRef.current = onChangeSize;\n\n const { registerItem, removeItem, initScrollHandlers, containerRef, positionContainerRef, isTouch } =\n useScrollContainer();\n\n useEffect(() => {\n const { scrollPosition, viewportWidth, contentWidth } = scrollState;\n const updateScrollPositionByResize = () => {\n const index = findIndexNearestToSnapPoint(scrollState);\n const scrollSnapBehavior = computeScrollSnapBehavior(scrollState);\n const target = scrollSnapBehavior(scrollState, index);\n if (target === null) {\n return;\n }\n const position = clamp(target, viewportWidth.get() - contentWidth.get(), 0);\n onChangeSizeRef.current?.(getDisableState(scrollState));\n if (scrollPosition.get() === position) {\n return;\n }\n animate(scrollPosition, position, {\n velocity: Math.max(scrollPosition.getVelocity(), 1),\n });\n };\n const unsubscribe = [\n scrollPosition.on('change', () => {\n onScrollRef.current?.(getDisableState(scrollState));\n }),\n viewportWidth.on('change', updateScrollPositionByResize),\n contentWidth.on('change', updateScrollPositionByResize),\n ];\n return () => {\n unsubscribe.forEach((fn) => fn());\n };\n }, [scrollState]);\n\n useEffect(() => {\n onReadyRef.current?.(getDisableState(scrollState));\n return initScrollHandlers();\n }, [initScrollHandlers, scrollState]);\n\n const springScrollPosition = useSpring(scrollState.scrollPosition, {\n stiffness: 1800,\n damping: 75,\n mass: 0.5,\n });\n\n return (\n <GalleryContext.Provider\n value={{\n registerItem,\n removeItem,\n }}\n >\n <div\n ref={containerRef}\n className={styles.scrollableContainer}\n data-qa=\"scrollable-container__overflow-container\"\n >\n <motion.div\n ref={positionContainerRef}\n data-qa=\"scrollable-container__position-container\"\n className={styles.positionContainer}\n style={{ x: isTouch ? scrollState.scrollPosition : springScrollPosition }}\n >\n {children}\n </motion.div>\n </div>\n </GalleryContext.Provider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAM,cAAc,GAAG,aAAa,CAAwB;AACxD,IAAA,YAAY,EAAE,MAAM,IAAI;AACxB,IAAA,UAAU,EAAE,MAAM,IAAI;AACzB,CAAA,CAAC,CAAC;AAEU,MAAA,iBAAiB,GAAG,MAA6B,UAAU,CAAC,cAAc,EAAE;AAElF,MAAM,0BAA0B,GAAwC,CAAC,EAC5E,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,YAAY,GACf,KAAI;AACD,IAAA,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;AACrC,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AACnC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AACrC,IAAA,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAC7C,IAAA,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;AAC7B,IAAA,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;AAC/B,IAAA,eAAe,CAAC,OAAO,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|
2
|
+
import type { ScrollableItemProps } from '@hh.ru/magritte-ui-scrollable-container/types';
|
|
3
|
+
export declare const ScrollableItem: FC<ScrollableItemProps>;
|
package/ScrollableItem.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useRef, useLayoutEffect } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
7
|
-
import '@hh.ru/magritte-
|
|
8
|
-
import '
|
|
9
|
-
import './
|
|
4
|
+
import { useGalleryContext } from './ScrollableContainerGallery.js';
|
|
5
|
+
import { useScrollableControls } from './useScrollableControls.js';
|
|
6
|
+
import 'motion/react';
|
|
7
|
+
import '@hh.ru/magritte-internal-custom-scroll/initScrollHandlers';
|
|
8
|
+
import './ScrollStateProvider.js';
|
|
9
|
+
import './ObservableValue.js';
|
|
10
|
+
import './useScrollContainer.js';
|
|
10
11
|
import '@hh.ru/magritte-common-func-utils';
|
|
11
12
|
import '@hh.ru/magritte-internal-custom-scroll';
|
|
12
13
|
import './types.js';
|
|
13
14
|
import './utils.js';
|
|
14
|
-
import '@hh.ru/magritte-ui-
|
|
15
|
+
import '@hh.ru/magritte-ui-breakpoint';
|
|
16
|
+
import './scrollableContainer-DSb3wQO4.js';
|
|
15
17
|
|
|
16
18
|
const ScrollableItem = ({ children, ...props }) => {
|
|
17
19
|
const ref = useRef(null);
|
|
18
|
-
const { registerItem, removeItem
|
|
20
|
+
const { registerItem, removeItem } = useGalleryContext();
|
|
21
|
+
const { scrollToItem } = useScrollableControls();
|
|
19
22
|
useLayoutEffect(() => {
|
|
20
23
|
registerItem(ref);
|
|
21
|
-
return () =>
|
|
24
|
+
return () => {
|
|
25
|
+
removeItem(ref);
|
|
26
|
+
};
|
|
22
27
|
}, [registerItem, removeItem]);
|
|
23
|
-
return (jsx("div", { ref: ref, onClick: () => scrollToItem(ref),
|
|
28
|
+
return (jsx("div", { ref: ref, ...props, onClick: () => scrollToItem(ref), children: children }));
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
export { ScrollableItem };
|
package/ScrollableItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollableItem.js","sources":["../src/ScrollableItem.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ScrollableItem.js","sources":["../src/ScrollableItem.tsx"],"sourcesContent":["import { useRef, useLayoutEffect, type FC } from 'react';\n\nimport { useGalleryContext } from '@hh.ru/magritte-ui-scrollable-container/ScrollableContainerGallery';\nimport type { ScrollableItemProps } from '@hh.ru/magritte-ui-scrollable-container/types';\nimport { useScrollableControls } from '@hh.ru/magritte-ui-scrollable-container/useScrollableControls';\n\nexport const ScrollableItem: FC<ScrollableItemProps> = ({ children, ...props }) => {\n const ref = useRef<HTMLDivElement>(null);\n const { registerItem, removeItem } = useGalleryContext();\n const { scrollToItem } = useScrollableControls();\n\n useLayoutEffect(() => {\n registerItem(ref);\n return () => {\n removeItem(ref);\n };\n }, [registerItem, removeItem]);\n\n return (\n <div ref={ref} {...props} onClick={() => scrollToItem(ref)}>\n {children}\n </div>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;AAMO,MAAM,cAAc,GAA4B,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,KAAI;AAC9E,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,iBAAiB,EAAE,CAAC;AACzD,IAAA,MAAM,EAAE,YAAY,EAAE,GAAG,qBAAqB,EAAE,CAAC;IAEjD,eAAe,CAAC,MAAK;QACjB,YAAY,CAAC,GAAG,CAAC,CAAC;AAClB,QAAA,OAAO,MAAK;YACR,UAAU,CAAC,GAAG,CAAC,CAAC;AACpB,SAAC,CAAC;AACN,KAAC,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;IAE/B,QACIA,aAAK,GAAG,EAAE,GAAG,EAAM,GAAA,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC,GAAG,CAAC,EACrD,QAAA,EAAA,QAAQ,EACP,CAAA,EACR;AACN;;;;"}
|
package/index.css
CHANGED
|
@@ -1,72 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
--magritte-semantic-animation-ease-in-out-tiger-200-timing-function-v24-3-0:cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
3
|
-
--magritte-semantic-animation-ease-in-out-tiger-200-duration-v24-3-0:200ms;
|
|
4
|
-
}
|
|
5
|
-
.magritte-scroll-wrapper___vTdZl_5-3-0{
|
|
1
|
+
.magritte-scroll-wrapper___vTdZl_6-0-1{
|
|
6
2
|
position:relative;
|
|
7
3
|
touch-action:pan-y pinch-zoom;
|
|
8
4
|
}
|
|
9
|
-
.magritte-scrollable-
|
|
5
|
+
.magritte-scrollable-container___AKIUp_6-0-1{
|
|
10
6
|
display:block;
|
|
11
7
|
overflow-x:hidden;
|
|
12
8
|
overflow-x:clip;
|
|
13
9
|
overflow-y:visible;
|
|
14
10
|
width:100%;
|
|
15
11
|
min-height:40px;
|
|
16
|
-
padding:4px;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
padding:4px 0;
|
|
21
|
-
margin:-4px 0;
|
|
22
|
-
--both-sides-mask:linear-gradient(90deg, transparent 0, transparent 36px, #000 100.504px, #000 calc(100% - 100.50399999999999px), transparent calc(100% - 36px));
|
|
23
|
-
-webkit-mask:var(--both-sides-mask);
|
|
24
|
-
mask:var(--both-sides-mask);
|
|
12
|
+
padding-left:var(--magritte-ui-scrollabe-container-pl, 4px);
|
|
13
|
+
padding-right:var(--magritte-ui-scrollabe-container-pr, 4px);
|
|
14
|
+
margin-left:var(--magritte-ui-scrollabe-container-ml, -4px);
|
|
15
|
+
margin-right:var(--magritte-ui-scrollabe-container-mr, -4px);
|
|
25
16
|
}
|
|
26
|
-
.magritte-
|
|
27
|
-
|
|
28
|
-
padding-left:0;
|
|
29
|
-
--left-fade-mask:linear-gradient(90deg, transparent 0, transparent 36px, #000 100.504px);
|
|
30
|
-
-webkit-mask:var(--left-fade-mask);
|
|
31
|
-
mask:var(--left-fade-mask);
|
|
17
|
+
.magritte-scroll-buttons-container___ZeI5a_6-0-1{
|
|
18
|
+
position:relative;
|
|
32
19
|
}
|
|
33
|
-
.magritte-
|
|
34
|
-
padding-right:0;
|
|
35
|
-
margin-right:0;
|
|
20
|
+
.magritte-scroll-buttons___0SjoR_6-0-1{
|
|
36
21
|
--right-fade-mask:linear-gradient(90deg, #000 0, #000 calc(100% - 100.50399999999999px), transparent calc(100% - 36px));
|
|
37
|
-
-
|
|
38
|
-
mask:
|
|
22
|
+
--left-fade-mask:linear-gradient(90deg, transparent 0, transparent 36px, #000 100.504px);
|
|
23
|
+
--both-sides-mask:linear-gradient(90deg, transparent 0, transparent 36px, #000 100.504px, #000 calc(100% - 100.50399999999999px), transparent calc(100% - 36px));
|
|
24
|
+
-webkit-mask:'none';
|
|
25
|
+
mask:'none';
|
|
39
26
|
}
|
|
40
|
-
.magritte-scroll-
|
|
27
|
+
.magritte-scroll-button___4GQu3_6-0-1{
|
|
41
28
|
display:none;
|
|
42
29
|
position:absolute;
|
|
43
30
|
top:50%;
|
|
44
31
|
transform:translateY(-50%);
|
|
45
32
|
}
|
|
46
|
-
.magritte-scroll-button-
|
|
33
|
+
.magritte-scroll-button-left___UueEY_6-0-1{
|
|
47
34
|
left:0;
|
|
48
35
|
}
|
|
49
|
-
.magritte-
|
|
50
|
-
.magritte-fade-both-sides___pBan7_5-3-0:not(.magritte-no-buttons___eCwO-_5-3-0) .magritte-scroll-button-left___UueEY_5-3-0{
|
|
51
|
-
display:block;
|
|
52
|
-
}
|
|
53
|
-
.magritte-scroll-button-right___wZOn-_5-3-0{
|
|
36
|
+
.magritte-scroll-button-right___wZOn-_6-0-1{
|
|
54
37
|
right:0;
|
|
55
38
|
}
|
|
56
|
-
.magritte-
|
|
57
|
-
.magritte-fade-both-sides___pBan7_5-3-0:not(.magritte-no-buttons___eCwO-_5-3-0) .magritte-scroll-button-right___wZOn-_5-3-0{
|
|
58
|
-
display:block;
|
|
59
|
-
}
|
|
60
|
-
.magritte-position-container___1A4Bv_5-3-0{
|
|
39
|
+
.magritte-position-container___1A4Bv_6-0-1{
|
|
61
40
|
box-sizing:border-box;
|
|
62
41
|
width:100%;
|
|
63
42
|
}
|
|
64
|
-
.magritte-
|
|
65
|
-
transition-property:transform;
|
|
66
|
-
transition-duration:var(--magritte-semantic-animation-ease-in-out-tiger-200-duration-v24-3-0);
|
|
67
|
-
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-tiger-200-timing-function-v24-3-0);
|
|
68
|
-
}
|
|
69
|
-
.magritte-dot-container___ahtlG_5-3-0{
|
|
43
|
+
.magritte-dot-container___ahtlG_6-0-1{
|
|
70
44
|
display:flex;
|
|
71
45
|
justify-content:center;
|
|
72
46
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export { ScrollableContainer
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { ScrollableContainer } from '@hh.ru/magritte-ui-scrollable-container/ScrollableContainer';
|
|
2
|
+
export { useScrollableControls } from '@hh.ru/magritte-ui-scrollable-container/useScrollableControls';
|
|
3
|
+
export { useGalleryContext } from '@hh.ru/magritte-ui-scrollable-container/ScrollableContainerGallery';
|
|
4
|
+
export { useScrollState } from '@hh.ru/magritte-ui-scrollable-container/ScrollStateProvider';
|
|
5
|
+
export type { RegisterAndRemoveItem, ScrollableContainerProps, SpacingCorrectionProps, ScrollableControls, ScrollableItemProps, ScrollableContainerGalleryProps, ScrollableContainerDotPagesProps, ScrollDisableState, ScrollableContainerButtonProps, ScrollableContainerDefaultLayoutProps, ScrollSnapAlign, } from '@hh.ru/magritte-ui-scrollable-container/types';
|
package/index.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import './index.css';
|
|
2
|
-
export { ScrollableContainer
|
|
3
|
-
export {
|
|
2
|
+
export { ScrollableContainer } from './ScrollableContainer.js';
|
|
3
|
+
export { useScrollableControls } from './useScrollableControls.js';
|
|
4
|
+
export { useGalleryContext } from './ScrollableContainerGallery.js';
|
|
5
|
+
export { useScrollState } from './ScrollStateProvider.js';
|
|
4
6
|
import 'react/jsx-runtime';
|
|
5
7
|
import 'react';
|
|
6
8
|
import 'classnames';
|
|
7
9
|
import '@hh.ru/magritte-ui-breakpoint';
|
|
8
|
-
import '
|
|
10
|
+
import './ScrollableContainerButton.js';
|
|
11
|
+
import './ScrollableContainerDefaultLayout.js';
|
|
12
|
+
import 'motion/react';
|
|
9
13
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
10
|
-
import './
|
|
11
|
-
import '@hh.ru/magritte-common-func-utils';
|
|
14
|
+
import './utils.js';
|
|
12
15
|
import '@hh.ru/magritte-internal-custom-scroll';
|
|
13
16
|
import './types.js';
|
|
14
|
-
import './
|
|
17
|
+
import './scrollableContainer-DSb3wQO4.js';
|
|
18
|
+
import './ScrollableContainerDotPages.js';
|
|
19
|
+
import '@hh.ru/magritte-internal-custom-scroll/initScrollHandlers';
|
|
20
|
+
import '@hh.ru/magritte-ui-dot-pages';
|
|
15
21
|
import '@hh.ru/magritte-ui-spacing';
|
|
22
|
+
import './ScrollableItem.js';
|
|
23
|
+
import './useScrollContainer.js';
|
|
24
|
+
import '@hh.ru/magritte-common-func-utils';
|
|
25
|
+
import './ObservableValue.js';
|
|
16
26
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.mock.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
1
|
+
export type { RegisterAndRemoveItem, ScrollableContainerProps, SpacingCorrectionProps, ScrollableControls, ScrollableItemProps, ScrollableContainerGalleryProps, ScrollableContainerDotPagesProps, ScrollDisableState, ScrollableContainerButtonProps, ScrollableContainerDefaultLayoutProps, ScrollSnapAlign, } from '@hh.ru/magritte-ui-scrollable-container/types';
|
|
2
|
+
export declare const ScrollableContainer: import("react").ForwardRefExoticComponent<Record<string, unknown>>;
|
|
3
|
+
export { useScrollableControls } from '@hh.ru/magritte-ui-scrollable-container/useScrollableControls';
|
|
4
|
+
export { useGalleryContext } from '@hh.ru/magritte-ui-scrollable-container/ScrollableContainerGallery';
|
|
5
|
+
export { useScrollState } from '@hh.ru/magritte-ui-scrollable-container/ScrollStateProvider';
|
package/index.mock.js
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { mockComponent } from '@hh.ru/magritte-ui-mock-component';
|
|
3
|
-
export {
|
|
4
|
-
|
|
3
|
+
export { useScrollableControls } from './useScrollableControls.js';
|
|
4
|
+
export { useGalleryContext } from './ScrollableContainerGallery.js';
|
|
5
|
+
export { useScrollState } from './ScrollStateProvider.js';
|
|
5
6
|
import 'react';
|
|
6
|
-
import 'classnames';
|
|
7
|
-
import '@hh.ru/magritte-ui-breakpoint';
|
|
8
|
-
import '@hh.ru/magritte-ui-dot-pages';
|
|
9
|
-
import '@hh.ru/magritte-ui-icon/icon';
|
|
10
|
-
import './useScrollContainer-DvtB6-c_.js';
|
|
11
|
-
import '@hh.ru/magritte-common-func-utils';
|
|
12
7
|
import '@hh.ru/magritte-internal-custom-scroll';
|
|
13
|
-
import './types.js';
|
|
14
8
|
import './utils.js';
|
|
15
|
-
import '
|
|
9
|
+
import 'motion/react';
|
|
10
|
+
import '@hh.ru/magritte-ui-breakpoint';
|
|
11
|
+
import './types.js';
|
|
12
|
+
import 'react/jsx-runtime';
|
|
13
|
+
import '@hh.ru/magritte-internal-custom-scroll/initScrollHandlers';
|
|
14
|
+
import './useScrollContainer.js';
|
|
15
|
+
import '@hh.ru/magritte-common-func-utils';
|
|
16
|
+
import './scrollableContainer-DSb3wQO4.js';
|
|
17
|
+
import './ObservableValue.js';
|
|
16
18
|
|
|
17
|
-
const
|
|
19
|
+
const staticProps = {
|
|
20
|
+
Left: mockComponent('Left', undefined, {
|
|
21
|
+
withChildren: true,
|
|
22
|
+
}),
|
|
23
|
+
Right: mockComponent('Right', undefined, {
|
|
24
|
+
withChildren: true,
|
|
25
|
+
}),
|
|
26
|
+
Item: mockComponent('Item', undefined, {
|
|
27
|
+
withChildren: true,
|
|
28
|
+
}),
|
|
29
|
+
Gallery: mockComponent('Gallery', undefined, {
|
|
30
|
+
withChildren: true,
|
|
31
|
+
}),
|
|
32
|
+
DefaultLayout: mockComponent('DefaultLayout', undefined, {
|
|
33
|
+
withChildren: true,
|
|
34
|
+
}),
|
|
35
|
+
DotPages: mockComponent('DotPages', undefined, {
|
|
36
|
+
withChildren: true,
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
const ScrollableContainer = mockComponent('ScrollableContainer', staticProps, {
|
|
40
|
+
withChildren: true,
|
|
41
|
+
});
|
|
18
42
|
|
|
19
43
|
export { ScrollableContainer };
|
|
20
44
|
//# sourceMappingURL=index.mock.js.map
|
package/index.mock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mock.js","sources":["../src/index.mock.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.mock.js","sources":["../src/index.mock.ts"],"sourcesContent":["import { mockComponent } from '@hh.ru/magritte-ui-mock-component';\n\nexport type {\n RegisterAndRemoveItem,\n ScrollableContainerProps,\n SpacingCorrectionProps,\n ScrollableControls,\n ScrollableItemProps,\n ScrollableContainerGalleryProps,\n ScrollableContainerDotPagesProps,\n ScrollDisableState,\n ScrollableContainerButtonProps,\n ScrollableContainerDefaultLayoutProps,\n ScrollSnapAlign,\n} from '@hh.ru/magritte-ui-scrollable-container/types';\n\nconst staticProps = {\n Left: mockComponent('Left', undefined, {\n withChildren: true,\n }),\n Right: mockComponent('Right', undefined, {\n withChildren: true,\n }),\n Item: mockComponent('Item', undefined, {\n withChildren: true,\n }),\n Gallery: mockComponent('Gallery', undefined, {\n withChildren: true,\n }),\n DefaultLayout: mockComponent('DefaultLayout', undefined, {\n withChildren: true,\n }),\n DotPages: mockComponent('DotPages', undefined, {\n withChildren: true,\n }),\n};\n\nexport const ScrollableContainer = mockComponent('ScrollableContainer', staticProps, {\n withChildren: true,\n});\n\nexport { useScrollableControls } from '@hh.ru/magritte-ui-scrollable-container/useScrollableControls';\nexport { useGalleryContext } from '@hh.ru/magritte-ui-scrollable-container/ScrollableContainerGallery';\nexport { useScrollState } from '@hh.ru/magritte-ui-scrollable-container/ScrollStateProvider';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAM,WAAW,GAAG;AAChB,IAAA,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE;AACnC,QAAA,YAAY,EAAE,IAAI;KACrB,CAAC;AACF,IAAA,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE;AACrC,QAAA,YAAY,EAAE,IAAI;KACrB,CAAC;AACF,IAAA,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE;AACnC,QAAA,YAAY,EAAE,IAAI;KACrB,CAAC;AACF,IAAA,OAAO,EAAE,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE;AACzC,QAAA,YAAY,EAAE,IAAI;KACrB,CAAC;AACF,IAAA,aAAa,EAAE,aAAa,CAAC,eAAe,EAAE,SAAS,EAAE;AACrD,QAAA,YAAY,EAAE,IAAI;KACrB,CAAC;AACF,IAAA,QAAQ,EAAE,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE;AAC3C,QAAA,YAAY,EAAE,IAAI;KACrB,CAAC;CACL,CAAC;MAEW,mBAAmB,GAAG,aAAa,CAAC,qBAAqB,EAAE,WAAW,EAAE;AACjF,IAAA,YAAY,EAAE,IAAI;AACrB,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-scrollable-container",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@hh.ru/magritte-common-func-utils": "1.3.14",
|
|
23
23
|
"@hh.ru/magritte-design-tokens": "24.3.0",
|
|
24
|
-
"@hh.ru/magritte-internal-custom-scroll": "2.0
|
|
24
|
+
"@hh.ru/magritte-internal-custom-scroll": "2.1.0",
|
|
25
25
|
"@hh.ru/magritte-ui-breakpoint": "6.0.6",
|
|
26
26
|
"@hh.ru/magritte-ui-dot-pages": "4.0.16",
|
|
27
27
|
"@hh.ru/magritte-ui-icon": "13.8.0",
|
|
@@ -30,10 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"classnames": ">=2.3.2",
|
|
33
|
+
"motion": "^12.23.12",
|
|
33
34
|
"react": ">=18.2.0"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public"
|
|
37
38
|
},
|
|
38
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "804842d14ed7eaf72f6da2970970d8a1b03c476d"
|
|
39
40
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
var styles = {"scroll-wrapper":"magritte-scroll-wrapper___vTdZl_6-0-1","scrollWrapper":"magritte-scroll-wrapper___vTdZl_6-0-1","scrollable-container":"magritte-scrollable-container___AKIUp_6-0-1","scrollableContainer":"magritte-scrollable-container___AKIUp_6-0-1","scroll-buttons-container":"magritte-scroll-buttons-container___ZeI5a_6-0-1","scrollButtonsContainer":"magritte-scroll-buttons-container___ZeI5a_6-0-1","scroll-buttons":"magritte-scroll-buttons___0SjoR_6-0-1","scrollButtons":"magritte-scroll-buttons___0SjoR_6-0-1","scroll-button":"magritte-scroll-button___4GQu3_6-0-1","scrollButton":"magritte-scroll-button___4GQu3_6-0-1","scroll-button-left":"magritte-scroll-button-left___UueEY_6-0-1","scrollButtonLeft":"magritte-scroll-button-left___UueEY_6-0-1","scroll-button-right":"magritte-scroll-button-right___wZOn-_6-0-1","scrollButtonRight":"magritte-scroll-button-right___wZOn-_6-0-1","position-container":"magritte-position-container___1A4Bv_6-0-1","positionContainer":"magritte-position-container___1A4Bv_6-0-1","dot-container":"magritte-dot-container___ahtlG_6-0-1","dotContainer":"magritte-dot-container___ahtlG_6-0-1"};
|
|
3
|
+
|
|
4
|
+
export { styles as s };
|
|
5
|
+
//# sourceMappingURL=scrollableContainer-DSb3wQO4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollableContainer-DSb3wQO4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { HTMLAttributes, RefObject,
|
|
2
|
-
import {
|
|
1
|
+
import type { HTMLAttributes, RefObject, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
import { TokenBaseStaticSpace } from '@hh.ru/magritte-design-tokens/types';
|
|
3
|
+
import type { DotPagesProps } from '@hh.ru/magritte-ui-dot-pages';
|
|
3
4
|
export declare const OFFSET_ATTR: unique symbol;
|
|
4
5
|
export interface ItemWithOffset {
|
|
5
6
|
[OFFSET_ATTR]: {
|
|
@@ -7,82 +8,31 @@ export interface ItemWithOffset {
|
|
|
7
8
|
right: number;
|
|
8
9
|
};
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export interface
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
/** ширина контейнера определяющего видимую область */
|
|
26
|
-
containerWidth: number;
|
|
27
|
-
/** список элементов которые скроллятся */
|
|
28
|
-
items: RefObject<HTMLElement & ItemWithOffset>[];
|
|
29
|
-
/** размер коррекции отступов */
|
|
30
|
-
correction: {
|
|
31
|
-
leftCorrection: number;
|
|
32
|
-
rightCorrection: number;
|
|
33
|
-
};
|
|
34
|
-
/** флаг режима без кнопок */
|
|
35
|
-
disableButtons: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* флаг сигнализирующий о том, что происходит анимация подскролла к элементу
|
|
38
|
-
* когда флаг установлен отключаются обработчики wheel и touch cобытий
|
|
39
|
-
* */
|
|
40
|
-
scrollAnimationInProgress: boolean;
|
|
41
|
-
scrollToItemInProgress: RefObject<unknown> | null;
|
|
42
|
-
/**
|
|
43
|
-
* если при маунте дочерних компонентов был вызван scrollToItem, то элемент к которому нужно
|
|
44
|
-
* подскроллить сохраняется здесь мы не можем сразу после маунта скроллить, т.к. неизвестна ширина
|
|
45
|
-
* контейнера позиционирования, кроме того в этом случае подскролл должен происходить без анимации
|
|
46
|
-
*/
|
|
47
|
-
scrollToOnMount: RefObject<HTMLElement> | null;
|
|
48
|
-
/**
|
|
49
|
-
* флаг, сигнализирующий о том, что в контейнере зарегистрированы элементы, для которых не произведен расчет позиции
|
|
50
|
-
* это может произойти из-за того, что расчет позиции дебаунсится
|
|
51
|
-
* при наличии этого флага во всех функциях оcуществляющих скролл нужно предварительно синхронно рассчитать позиции
|
|
52
|
-
* всех зарегистрированных элементов
|
|
53
|
-
*/
|
|
54
|
-
recalcRequired: boolean;
|
|
55
|
-
/** нужно ли центрировать элемент при событии touchend/inertial end animate */
|
|
56
|
-
needCorrectionOnScrollEnd: boolean;
|
|
57
|
-
/** флаг режима снаппинга */
|
|
58
|
-
snapToNearestItem: boolean;
|
|
59
|
-
/** текущий dot */
|
|
60
|
-
activeDot: number;
|
|
61
|
-
/** экшн для обновления dot */
|
|
62
|
-
setActiveDot: Dispatch<SetStateAction<number>>;
|
|
63
|
-
setCountItems: Dispatch<SetStateAction<number>>;
|
|
64
|
-
/** элемент, на котором был пользователь до скролла */
|
|
65
|
-
previousActiveIndexItem: number;
|
|
66
|
-
/** направление скролла */
|
|
67
|
-
directionRight: boolean;
|
|
68
|
-
/** Колбэк при прокрутке контейнера */
|
|
69
|
-
onScroll?: () => void;
|
|
70
|
-
wasInteracted: boolean;
|
|
71
|
-
isMobile: boolean;
|
|
11
|
+
export interface ControlWithClick {
|
|
12
|
+
onClick?: MouseEventHandler;
|
|
13
|
+
'data-qa'?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RegisterAndRemoveItem {
|
|
16
|
+
/** колбэк для регистрации элемента галерии */
|
|
17
|
+
registerItem: (ref: RefObject<HTMLElement>) => void;
|
|
18
|
+
/** колбэк для удаления элемента галерии */
|
|
19
|
+
removeItem: (ref: RefObject<HTMLElement>) => void;
|
|
20
|
+
}
|
|
21
|
+
export interface ScrollDisableState {
|
|
22
|
+
/** заблокирован ли скролл влево */
|
|
23
|
+
isScrollRightDisabled: boolean;
|
|
24
|
+
/** заблокирован ли скролл вправо */
|
|
25
|
+
isScrollLeftDisabled: boolean;
|
|
72
26
|
}
|
|
73
27
|
export interface ScrollableControls {
|
|
74
|
-
/** двигаем ScrollableContainer
|
|
28
|
+
/** двигаем ScrollableContainer налево */
|
|
75
29
|
scrollLeft: () => void;
|
|
76
|
-
/** двигаем ScrollableContainer
|
|
30
|
+
/** двигаем ScrollableContainer направо */
|
|
77
31
|
scrollRight: () => void;
|
|
78
|
-
/** двигаем ScrollableContainer к первому
|
|
32
|
+
/** двигаем ScrollableContainer к первому элементу */
|
|
79
33
|
scrollToFirstItem: () => void;
|
|
80
|
-
/** двигаем ScrollableContainer к последнему
|
|
34
|
+
/** двигаем ScrollableContainer к последнему элементу */
|
|
81
35
|
scrollToLastItem: () => void;
|
|
82
|
-
/** функция, возвращающая true если ScrollableContainer до конца прокручен вправо */
|
|
83
|
-
isScrollRightDisabled: () => boolean;
|
|
84
|
-
/** функция, возвращающая true если ScrollableContainer до конца прокручен влево */
|
|
85
|
-
isScrollLeftDisabled: () => boolean;
|
|
86
36
|
/** скролл к элементу по индексу, элементы сортируются по расположению справа на лево */
|
|
87
37
|
scrollToIndex: (index: number) => void;
|
|
88
38
|
/**
|
|
@@ -140,18 +90,46 @@ export interface SpacingCorrectionProps {
|
|
|
140
90
|
/** Величина коррекции отступа справа для разрешения XXL и больше, положительное число или 0 */
|
|
141
91
|
correctionRightXXL?: number;
|
|
142
92
|
}
|
|
143
|
-
export
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
93
|
+
export type ScrollSnapAlign = 'start' | 'end' | 'center' | 'none';
|
|
94
|
+
export type ScrollableContainerProps = SpacingCorrectionProps & {
|
|
95
|
+
/** Контент ScrollableContainer */
|
|
96
|
+
children: ReactNode;
|
|
97
|
+
/**
|
|
98
|
+
* Определяет, как ближайший элемент будет размещён во вьюпорте при автоматическом скролле
|
|
99
|
+
*
|
|
100
|
+
* - `center` - ближайший элемент центрируется во вьюпорте
|
|
101
|
+
* - `start` - ближайший элемент выравнивается по левой границе вьюпорта
|
|
102
|
+
* - `end` - ближайший элемент выравнивается по правой границе вьюпорта
|
|
103
|
+
*/
|
|
104
|
+
scrollSnapAlign?: ScrollSnapAlign;
|
|
105
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
106
|
+
export interface ScrollableItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
107
|
+
/** Элемент галереи */
|
|
108
|
+
children: ReactNode;
|
|
109
|
+
}
|
|
110
|
+
export interface ScrollableContainerGalleryProps {
|
|
111
|
+
/** Колбэк при прокрутке контейнера */
|
|
112
|
+
onScroll?: (scrollInfo: ScrollDisableState) => void;
|
|
113
|
+
/** Колбэк при инициализации контейнера */
|
|
114
|
+
onReady?: (scrollInfo: ScrollDisableState) => void;
|
|
115
|
+
/** Колбэк при изменении размеров контейнера */
|
|
116
|
+
onChangeSize?: (scrollInfo: ScrollDisableState) => void;
|
|
117
|
+
/** Элементы галереи, которые отображаются внутри контейнера и прокручиваются по горизонтали */
|
|
118
|
+
children: ReactNode;
|
|
119
|
+
}
|
|
120
|
+
export interface ScrollableContainerDotPagesProps {
|
|
150
121
|
/** Колбэк при изменении active dot в компоненте dot-pages*/
|
|
151
122
|
onChangeDot?: (dot: number) => void;
|
|
152
123
|
/** Свойства dot-pages*/
|
|
153
|
-
dotPagesProps?: Omit<DotPagesProps, 'active' | 'count'
|
|
154
|
-
/**
|
|
155
|
-
|
|
124
|
+
dotPagesProps?: Omit<DotPagesProps, 'active' | 'count'>;
|
|
125
|
+
/** Верхний отступ для DotPages */
|
|
126
|
+
offsetTop?: TokenBaseStaticSpace;
|
|
127
|
+
}
|
|
128
|
+
export interface ScrollableContainerButtonProps {
|
|
129
|
+
/** Кнопка для скрола налево/направо */
|
|
130
|
+
children: ReactNode;
|
|
131
|
+
}
|
|
132
|
+
export interface ScrollableContainerDefaultLayoutProps {
|
|
133
|
+
/** Контент ScrollableContainerGallery */
|
|
134
|
+
children: ReactNode;
|
|
156
135
|
}
|
|
157
|
-
export type ScrollableContainerProps = Omit<HTMLAttributes<HTMLDivElement>, keyof SpacingCorrectionProps | 'disableButtons' | 'onScroll'> & ScrollableContainerBaseProps & SpacingCorrectionProps;
|