@cleartrip/ct-design-horizontal-scroll 4.0.0-TEST.3 → 5.0.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.
Files changed (45) hide show
  1. package/README.md +85 -0
  2. package/dist/HorizontalScroll.d.ts +3 -3
  3. package/dist/HorizontalScroll.d.ts.map +1 -1
  4. package/dist/HorizontalScroll.native.d.ts +5 -0
  5. package/dist/HorizontalScroll.native.d.ts.map +1 -0
  6. package/dist/constants.d.ts +10 -0
  7. package/dist/constants.d.ts.map +1 -0
  8. package/dist/ct-design-horizontal-scroll.browser.cjs.js +14 -1
  9. package/dist/ct-design-horizontal-scroll.browser.cjs.js.map +1 -1
  10. package/dist/ct-design-horizontal-scroll.browser.esm.js +14 -1
  11. package/dist/ct-design-horizontal-scroll.browser.esm.js.map +1 -1
  12. package/dist/ct-design-horizontal-scroll.cjs.js +40 -128
  13. package/dist/ct-design-horizontal-scroll.cjs.js.map +1 -1
  14. package/dist/ct-design-horizontal-scroll.esm.js +42 -128
  15. package/dist/ct-design-horizontal-scroll.esm.js.map +1 -1
  16. package/dist/ct-design-horizontal-scroll.umd.js +1619 -1871
  17. package/dist/ct-design-horizontal-scroll.umd.js.map +1 -1
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.native.d.ts +4 -0
  21. package/dist/index.native.d.ts.map +1 -0
  22. package/dist/style.d.ts +40 -0
  23. package/dist/style.d.ts.map +1 -0
  24. package/dist/type.d.ts +21 -27
  25. package/dist/type.d.ts.map +1 -1
  26. package/package.json +31 -12
  27. package/src/HorizontalScroll.native.tsx +80 -0
  28. package/src/HorizontalScroll.tsx +62 -0
  29. package/src/constants.ts +10 -0
  30. package/src/index.native.ts +3 -0
  31. package/src/index.ts +3 -0
  32. package/src/style.ts +86 -0
  33. package/src/type.ts +67 -0
  34. package/dist/StyledHorizontalScroll/StyledHorizontalScroll.d.ts +0 -6
  35. package/dist/StyledHorizontalScroll/StyledHorizontalScroll.d.ts.map +0 -1
  36. package/dist/StyledHorizontalScroll/index.d.ts +0 -2
  37. package/dist/StyledHorizontalScroll/index.d.ts.map +0 -1
  38. package/dist/StyledLeftShadow/StyledLeftShadow.d.ts +0 -11
  39. package/dist/StyledLeftShadow/StyledLeftShadow.d.ts.map +0 -1
  40. package/dist/StyledLeftShadow/index.d.ts +0 -2
  41. package/dist/StyledLeftShadow/index.d.ts.map +0 -1
  42. package/dist/StyledRightShadow/StyledRightShadow.d.ts +0 -11
  43. package/dist/StyledRightShadow/StyledRightShadow.d.ts.map +0 -1
  44. package/dist/StyledRightShadow/index.d.ts +0 -2
  45. package/dist/StyledRightShadow/index.d.ts.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as HorizontalScroll } from './HorizontalScroll';
2
- export * from './StyledHorizontalScroll';
3
- export * from './type';
2
+ export type * from './type';
3
+ export * from './constants';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../packages/components/HorizontalScroll/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,cAAc,0BAA0B,CAAC;AACzC,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../packages/components/HorizontalScroll/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,mBAAmB,QAAQ,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as HorizontalScroll } from './HorizontalScroll.native';
2
+ export type * from './type';
3
+ export * from './constants';
4
+ //# sourceMappingURL=index.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../packages/components/HorizontalScroll/src/index.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACxE,mBAAmB,QAAQ,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,40 @@
1
+ export declare const DEFAULT_LEFT_SHADOW_GRADIENT = "linear-gradient(90deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%)";
2
+ export declare const DEFAULT_RIGHT_SHADOW_GRADIENT = "linear-gradient(270deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%)";
3
+ export declare const DEFAULT_SHADOW_WIDTH = "64px";
4
+ declare const staticHorizontalScrollStyles: {
5
+ nativeContent: {
6
+ display: "flex";
7
+ flexDirection: "row";
8
+ gap: 12;
9
+ };
10
+ webScrollWrapper: {
11
+ display: "flex";
12
+ whiteSpace: string;
13
+ overflowX: string;
14
+ scrollBehavior: string;
15
+ WebkitTapHighlightColor: string;
16
+ scrollbarWidth: string;
17
+ msOverflowStyle: string;
18
+ '&::-webkit-scrollbar': {
19
+ display: string;
20
+ };
21
+ };
22
+ webShadowBase: {
23
+ position: "absolute";
24
+ top: number;
25
+ height: "100%";
26
+ display: "flex";
27
+ alignItems: "center";
28
+ zIndex: number;
29
+ };
30
+ webLeftShadow: {
31
+ left: number;
32
+ justifyContent: "flex-start";
33
+ };
34
+ webRightShadow: {
35
+ right: number;
36
+ justifyContent: "flex-end";
37
+ };
38
+ };
39
+ export default staticHorizontalScrollStyles;
40
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../packages/components/HorizontalScroll/src/style.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,4BAA4B,oEAAoE,CAAC;AAO9G,eAAO,MAAM,6BAA6B,qEAAqE,CAAC;AAMhH,eAAO,MAAM,oBAAoB,SAAS,CAAC;AAS3C,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsD/B,CAAC;AAEJ,eAAe,4BAA4B,CAAC"}
package/dist/type.d.ts CHANGED
@@ -1,32 +1,26 @@
1
- import { ReactNode } from 'react';
2
- import { HorizontallScrollStyleConfigProps } from '@cleartrip/ct-design-types';
3
- export interface IShadowWidth {
4
- left?: string;
5
- right?: string;
6
- }
7
- export declare enum ARROW_SIZE {
8
- SM = "sm",
9
- MD = "md",
10
- LG = "lg"
1
+ import { Styles, ViewStyle } from '@cleartrip/ct-design-types';
2
+ import { IScrollContainer } from '@cleartrip/ct-design-scroll-container';
3
+ import { ARROW_SIZE } from './constants';
4
+ export interface IHorizontalScroll extends IScrollContainer {
5
+ children?: React.ReactNode;
6
+ styleConfig?: {
7
+ root?: Styles[];
8
+ childContainer?: Styles[];
9
+ };
10
+ width?: number;
11
+ onIndexChange?: (index: number) => void;
12
+ currentActiveIndex?: number;
13
+ pagingEnabled?: boolean;
14
+ snapToOffsets?: number[];
15
+ decelerationRate?: number;
16
+ totalItemsLength?: number;
17
+ customContentContainerStyle?: ViewStyle;
18
+ wrapIntersectionObserver?: boolean;
19
+ arrowSize?: `${ARROW_SIZE}`;
20
+ shadowGradientStyle?: IShadowGradient;
11
21
  }
12
- export interface IShadowGradientStyle {
22
+ export interface IShadowGradient {
13
23
  left: string;
14
24
  right: string;
15
25
  }
16
- export interface HorizontallScrollProps {
17
- children?: ReactNode;
18
- className?: string;
19
- showShadow?: boolean;
20
- showArrow?: boolean;
21
- containerClassname?: string;
22
- childrenClassname?: string;
23
- shadowWidth?: IShadowWidth;
24
- arrowSize?: `${ARROW_SIZE}`;
25
- shadowGradientStyle?: IShadowGradientStyle;
26
- styleConfig?: HorizontallScrollStyleConfigProps;
27
- }
28
- export declare enum ARROW_DIRECTION {
29
- LEFT = "LEFT",
30
- RIGHT = "RIGHT"
31
- }
32
26
  //# sourceMappingURL=type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/HorizontalScroll/src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAE/E,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,UAAU;IACpB,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;CACV;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,SAAS,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;IAC5B,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAC3C,WAAW,CAAC,EAAE,iCAAiC,CAAC;CACjD;AAED,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/HorizontalScroll/src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAI3B,WAAW,CAAC,EAAE;QAKZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAIhB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAIxC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAI5B,aAAa,CAAC,EAAE,OAAO,CAAC;IAIxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAIzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,2BAA2B,CAAC,EAAE,SAAS,CAAC;IAIxC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAKnC,SAAS,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;IAI5B,mBAAmB,CAAC,EAAE,eAAe,CAAC;CACvC;AACD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf"}
package/package.json CHANGED
@@ -1,34 +1,51 @@
1
1
  {
2
2
  "name": "@cleartrip/ct-design-horizontal-scroll",
3
- "version": "4.0.0-TEST.3",
3
+ "version": "5.0.0",
4
4
  "description": "HorizontalScroll Component",
5
5
  "types": "dist/index.d.ts",
6
- "main": "dist/ct-design-horizontal-scroll.cjs.js",
6
+ "main": "./dist/ct-design-horizontal-scroll.cjs.js",
7
7
  "jsnext:main": "dist/ct-design-horizontal-scroll.esm.js",
8
8
  "module": "dist/ct-design-horizontal-scroll.esm.js",
9
+ "react-native": "src/index.native.ts",
9
10
  "sideEffects": false,
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/ct-design-horizontal-scroll.esm.js",
15
+ "default": "./dist/ct-design-horizontal-scroll.cjs.js"
16
+ }
17
+ },
10
18
  "browser": {
11
19
  "./dist/ct-design-horizontal-scroll.esm.js": "./dist/ct-design-horizontal-scroll.browser.esm.js",
12
20
  "./dist/ct-design-horizontal-scroll.cjs.js": "./dist/ct-design-horizontal-scroll.browser.cjs.js"
13
21
  },
14
22
  "files": [
15
- "dist"
23
+ "dist",
24
+ "src"
16
25
  ],
17
26
  "dependencies": {
18
- "@cleartrip/ct-design-common-utils": "4.0.0-TEST.3",
19
- "@cleartrip/ct-design-icons": "39.0.0-TEST.3",
20
- "@cleartrip/ct-design-theme": "3.20.0",
21
- "@cleartrip/ct-design-container": "3.20.0",
22
- "@cleartrip/ct-design-use-merge-refs": "3.20.0"
27
+ "@cleartrip/ct-design-common-utils": "5.0.0",
28
+ "@cleartrip/ct-design-container": "5.0.0",
29
+ "@cleartrip/ct-design-scroll-container": "5.0.0",
30
+ "@cleartrip/ct-design-style-manager": "5.0.0",
31
+ "@cleartrip/ct-design-icons": "5.0.0",
32
+ "@cleartrip/ct-design-theme": "5.0.0",
33
+ "@cleartrip/ct-design-use-merge-refs": "5.0.0",
34
+ "@cleartrip/ct-design-intersection-observer": "5.0.0",
35
+ "@cleartrip/ct-design-tooltip": "5.0.0"
23
36
  },
24
37
  "devDependencies": {
25
- "@cleartrip/ct-design-types": "3.20.0",
26
- "@cleartrip/ct-design-tooltip-v2": "4.0.0-TEST.3"
38
+ "@cleartrip/ct-design-types": "5.0.0"
27
39
  },
28
40
  "peerDependencies": {
29
41
  "react": ">=16.8.0",
30
42
  "react-dom": ">=16.8.0",
31
- "styled-components": "^5.3.6"
43
+ "react-native": ">=0.68.0"
44
+ },
45
+ "peerDependenciesMeta": {
46
+ "react-native": {
47
+ "optional": true
48
+ }
32
49
  },
33
50
  "publishConfig": {
34
51
  "access": "public"
@@ -39,6 +56,8 @@
39
56
  "test": "echo \"Error: no test specified\" && exit 1",
40
57
  "watch-package": "rollup -c -w",
41
58
  "build-package": "rollup -c",
42
- "build-package:clean": "rm -rf dist && rollup -c"
59
+ "build-package:clean": "rm -rf dist && rollup -c",
60
+ "publish-package:local": "yalc publish --no-scripts",
61
+ "publish-package:local:registry": "pnpm publish --registry http://localhost:4873 --no-git-checks --access public"
43
62
  }
44
63
  }
@@ -0,0 +1,80 @@
1
+ import { forwardRef, useState } from 'react';
2
+
3
+ import { IntersectionObserver } from '@cleartrip/ct-design-intersection-observer';
4
+ import { ScrollContainer, ScrollContainerRef } from '@cleartrip/ct-design-scroll-container';
5
+ import { IHorizontalScroll } from './type';
6
+ import staticHorizontalScrollStyles from './style';
7
+
8
+ /**
9
+ * Native implementation of HorizontalScroll.
10
+ *
11
+ * Migrated from yagami (aldenui) per `Migration.MD`:
12
+ * - Public prop contract lives in a single shared `./type`.
13
+ * - Static row layout (`flexDirection: 'row'` + theme gap) comes
14
+ * from the shared `staticHorizontalScrollStyles.nativeContent`
15
+ * slot in `./style`.
16
+ * - Wraps `ScrollContainer` inside an `IntersectionObserver`
17
+ * (threshold `0.5`) so `ScrollContainer` can pause its internal
18
+ * work when the scroller isn't on screen. The `wrapIntersectionObserver`
19
+ * prop lets callers opt out when they're already orchestrating
20
+ * visibility externally.
21
+ */
22
+ const HorizontalScroll = forwardRef<ScrollContainerRef, IHorizontalScroll>(
23
+ (
24
+ {
25
+ children,
26
+ styleConfig,
27
+ width,
28
+ onIndexChange,
29
+ currentActiveIndex,
30
+ snapToOffsets,
31
+ pagingEnabled = false,
32
+ totalItemsLength,
33
+ customContentContainerStyle,
34
+ wrapIntersectionObserver = true,
35
+ ...rest
36
+ },
37
+ ref,
38
+ ) => {
39
+ const { childContainer = [] } = styleConfig || { childContainer: [] };
40
+ const [isVisible, setIsVisible] = useState(false);
41
+
42
+ const contentContainerStyle = customContentContainerStyle
43
+ ? [customContentContainerStyle, ...childContainer]
44
+ : [staticHorizontalScrollStyles.nativeContent, ...childContainer];
45
+
46
+ return (
47
+ <IntersectionObserver
48
+ wrapped={wrapIntersectionObserver}
49
+ onIntersection={() => {
50
+ setIsVisible(true);
51
+ }}
52
+ onIntersectionComplete={() => {
53
+ setIsVisible(false);
54
+ }}
55
+ threshold={[0.5]}
56
+ >
57
+ <ScrollContainer
58
+ horizontal
59
+ ref={ref}
60
+ showsHorizontalScrollIndicator={false}
61
+ contentContainerStyle={contentContainerStyle}
62
+ width={width}
63
+ onIndexChange={onIndexChange}
64
+ currentActiveIndex={currentActiveIndex}
65
+ pagingEnabled={pagingEnabled}
66
+ snapToOffsets={snapToOffsets}
67
+ totalItemsLength={totalItemsLength}
68
+ isVisible={isVisible}
69
+ {...rest}
70
+ >
71
+ {children}
72
+ </ScrollContainer>
73
+ </IntersectionObserver>
74
+ );
75
+ },
76
+ );
77
+
78
+ HorizontalScroll.displayName = 'HorizontalScroll';
79
+
80
+ export default HorizontalScroll;
@@ -0,0 +1,62 @@
1
+ import { forwardRef, useRef } from 'react';
2
+
3
+ import { css } from '@emotion/css';
4
+ import { Container } from '@cleartrip/ct-design-container';
5
+ import { IHorizontalScroll } from './type';
6
+ import useMergeRefs from '@cleartrip/ct-design-use-merge-refs';
7
+ import { useWebMergeStyles } from '@cleartrip/ct-design-style-manager';
8
+ import { ScrollContainerRef } from '@cleartrip/ct-design-scroll-container';
9
+
10
+ // todo @raghav to revisit this
11
+
12
+ const horizontalScrollStyles = css`
13
+ display: flex;
14
+ white-space: no-wrap;
15
+ overflow-x: auto;
16
+ scroll-behavior: smooth;
17
+ -webkit-tap-highlight-color: transparent;
18
+ scrollbar-width: none; /* Firefox */
19
+ -ms-overflow-style: none; /* Internet Explorer 10+ */
20
+
21
+ &::-webkit-scrollbar {
22
+ /* WebKit */
23
+ display: none;
24
+ }
25
+ `;
26
+
27
+ const HorizontalScroll = forwardRef<ScrollContainerRef, IHorizontalScroll>(
28
+ ({ children, styleConfig = {}, onScroll }, forwardRef) => {
29
+ const { root, childContainer } = styleConfig;
30
+
31
+ const horizontalScrollRef = useRef<HTMLDivElement>(null);
32
+ const parentContainerRef = useRef<HTMLDivElement>(null);
33
+ const childContainerRef = useRef<HTMLElement>(null);
34
+ const combinedParentContainerRef = useMergeRefs(parentContainerRef, forwardRef);
35
+ const combinedParenAndChildContainerRef = useMergeRefs(parentContainerRef, childContainerRef);
36
+
37
+ const rootStyles = useWebMergeStyles([...(root || []), horizontalScrollStyles], [root]);
38
+
39
+ const handleScroll = (event: React.UIEvent<HTMLDivElement>) => {
40
+ onScroll?.({
41
+ nativeEvent: {
42
+ contentOffset: { x: event.currentTarget.scrollLeft, y: event.currentTarget.scrollTop },
43
+ layoutMeasurement: { height: event.currentTarget.clientHeight, width: event.currentTarget.clientWidth },
44
+ contentSize: { height: event.currentTarget.scrollHeight, width: event.currentTarget.scrollWidth },
45
+ },
46
+ });
47
+ };
48
+
49
+ return (
50
+ <div ref={horizontalScrollRef} onScroll={handleScroll}>
51
+ <div ref={combinedParentContainerRef} className={rootStyles}>
52
+ <Container styleConfig={{ root: childContainer }} ref={combinedParenAndChildContainerRef}>
53
+ {children}
54
+ </Container>
55
+ </div>
56
+ </div>
57
+ );
58
+ },
59
+ );
60
+
61
+ HorizontalScroll.displayName = 'HorizontalScroll';
62
+ export default HorizontalScroll;
@@ -0,0 +1,10 @@
1
+ export enum ARROW_DIRECTION {
2
+ LEFT = 'LEFT',
3
+ RIGHT = 'RIGHT',
4
+ }
5
+
6
+ export enum ARROW_SIZE {
7
+ SM = 'sm',
8
+ MD = 'md',
9
+ LG = 'lg',
10
+ }
@@ -0,0 +1,3 @@
1
+ export { default as HorizontalScroll } from './HorizontalScroll.native';
2
+ export type * from './type';
3
+ export * from './constants';
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { default as HorizontalScroll } from './HorizontalScroll';
2
+ export type * from './type';
3
+ export * from './constants';
package/src/style.ts ADDED
@@ -0,0 +1,86 @@
1
+ import { makeStyles } from '@cleartrip/ct-design-style-manager';
2
+
3
+ /**
4
+ * Default fade-out gradient for the left edge shadow when the caller
5
+ * hasn't supplied `shadowGradientStyle.left`.
6
+ * @web
7
+ */
8
+ export const DEFAULT_LEFT_SHADOW_GRADIENT = 'linear-gradient(90deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%)';
9
+
10
+ /**
11
+ * Default fade-out gradient for the right edge shadow when the caller
12
+ * hasn't supplied `shadowGradientStyle.right`.
13
+ * @web
14
+ */
15
+ export const DEFAULT_RIGHT_SHADOW_GRADIENT = 'linear-gradient(270deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%)';
16
+
17
+ /**
18
+ * Default horizontal extent of the shadow overlays on either side.
19
+ * @web
20
+ */
21
+ export const DEFAULT_SHADOW_WIDTH = '64px';
22
+
23
+ /**
24
+ * Static, theme-independent styles shared by the HorizontalScroll
25
+ * web and native implementations. The keys prefixed `native*` are
26
+ * only consumed by `HorizontalScroll.native.tsx`; `web*` keys and
27
+ * the shared layout keys are consumed by `HorizontalScroll.tsx` via
28
+ * `useWebMergeStyles`.
29
+ */
30
+ const staticHorizontalScrollStyles = makeStyles((theme) => ({
31
+ /**
32
+ * Native content-container default: horizontal row with
33
+ * theme-driven gap so siblings fall into a horizontal flow.
34
+ */
35
+ nativeContent: {
36
+ display: 'flex',
37
+ flexDirection: 'row',
38
+ gap: theme?.spacing[3],
39
+ },
40
+ /**
41
+ * Web scroll viewport. Hides the native scrollbar across all
42
+ * engines and enables smooth horizontal scroll. Nested selector
43
+ * is processed by emotion under the hood.
44
+ */
45
+ webScrollWrapper: {
46
+ display: 'flex',
47
+ whiteSpace: 'nowrap',
48
+ overflowX: 'auto',
49
+ scrollBehavior: 'smooth',
50
+ WebkitTapHighlightColor: 'transparent',
51
+ scrollbarWidth: 'none',
52
+ msOverflowStyle: 'none',
53
+ '&::-webkit-scrollbar': {
54
+ display: 'none',
55
+ },
56
+ },
57
+ /**
58
+ * Shared layout for the edge shadow overlays on web. Dynamic
59
+ * width + gradient are applied on top via useStyles in the
60
+ * component.
61
+ */
62
+ webShadowBase: {
63
+ position: 'absolute',
64
+ top: 0,
65
+ height: '100%',
66
+ display: 'flex',
67
+ alignItems: 'center',
68
+ zIndex: 10,
69
+ },
70
+ /**
71
+ * Left-shadow-specific overrides layered over `webShadowBase`.
72
+ */
73
+ webLeftShadow: {
74
+ left: 0,
75
+ justifyContent: 'flex-start',
76
+ },
77
+ /**
78
+ * Right-shadow-specific overrides layered over `webShadowBase`.
79
+ */
80
+ webRightShadow: {
81
+ right: 0,
82
+ justifyContent: 'flex-end',
83
+ },
84
+ }));
85
+
86
+ export default staticHorizontalScrollStyles;
package/src/type.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { Styles, ViewStyle } from '@cleartrip/ct-design-types';
2
+ import { IScrollContainer } from '@cleartrip/ct-design-scroll-container';
3
+ import { ARROW_SIZE } from './constants';
4
+
5
+ export interface IHorizontalScroll extends IScrollContainer {
6
+ children?: React.ReactNode;
7
+ /**
8
+ * Style configuration for Horizontal Scroll component
9
+ */
10
+ styleConfig?: {
11
+ /**
12
+ * Style configuration for root container for Horizonatal Scroll
13
+ * !NOTE: This works only in case of web
14
+ */
15
+ root?: Styles[];
16
+ /**
17
+ * Style configuration for child container for Horizonatal Scroll
18
+ */
19
+ childContainer?: Styles[];
20
+ };
21
+ width?: number; // Fixed width of each child container
22
+ /**
23
+ * @description Triggers when index changes
24
+ */
25
+ onIndexChange?: (index: number) => void; // Triggers when index changes
26
+ /**
27
+ * @description Current active index
28
+ */
29
+ currentActiveIndex?: number;
30
+ /**
31
+ * @description Paging enabled
32
+ */
33
+ pagingEnabled?: boolean;
34
+ /**
35
+ * @description Snap to offsets
36
+ */
37
+ snapToOffsets?: number[];
38
+ /**
39
+ * @description Deceleration rate
40
+ */
41
+ decelerationRate?: number;
42
+ /**
43
+ * @description Total items length
44
+ */
45
+ totalItemsLength?: number;
46
+ /**
47
+ * @description Custom content container style
48
+ */
49
+ customContentContainerStyle?: ViewStyle;
50
+ /**
51
+ * @description Wrap intersection observer
52
+ */
53
+ wrapIntersectionObserver?: boolean;
54
+
55
+ /**
56
+ * @description Arrow size
57
+ */
58
+ arrowSize?: `${ARROW_SIZE}`;
59
+ /**
60
+ * @description Shadow gradient style
61
+ */
62
+ shadowGradientStyle?: IShadowGradient;
63
+ }
64
+ export interface IShadowGradient {
65
+ left: string;
66
+ right: string;
67
+ }
@@ -1,6 +0,0 @@
1
- import { CSSProperties } from 'styled-components';
2
- declare const StyledHorizontalScroll: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
3
- css?: CSSProperties | undefined;
4
- }, never>;
5
- export default StyledHorizontalScroll;
6
- //# sourceMappingURL=StyledHorizontalScroll.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StyledHorizontalScroll.d.ts","sourceRoot":"","sources":["../../packages/components/HorizontalScroll/src/StyledHorizontalScroll/StyledHorizontalScroll.tsx"],"names":[],"mappings":"AAAA,OAAe,EAAc,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEtE,QAAA,MAAM,sBAAsB;;SAkB3B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -1,2 +0,0 @@
1
- export { default as StyledHorizontalScroll } from './StyledHorizontalScroll';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/components/HorizontalScroll/src/StyledHorizontalScroll/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,11 +0,0 @@
1
- import { CSSProperties } from "styled-components";
2
- import { IShadowGradientStyle } from '../type';
3
- export interface StyledLeftShadowProps {
4
- width?: string;
5
- shadowGradientStyle?: IShadowGradientStyle;
6
- }
7
- declare const StyledLeftShadow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledLeftShadowProps & {
8
- css?: CSSProperties | undefined;
9
- }, never>;
10
- export default StyledLeftShadow;
11
- //# sourceMappingURL=StyledLeftShadow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StyledLeftShadow.d.ts","sourceRoot":"","sources":["../../packages/components/HorizontalScroll/src/StyledLeftShadow/StyledLeftShadow.tsx"],"names":[],"mappings":"AAAA,OAAe,EAAc,aAAa,EAAE,MAAO,mBAAmB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C,MAAM,WAAW,qBAAqB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;CAC3C;AAED,QAAA,MAAM,gBAAgB;;SAiBrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,2 +0,0 @@
1
- export { default as StyledLeftShadow } from './StyledLeftShadow';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/components/HorizontalScroll/src/StyledLeftShadow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,11 +0,0 @@
1
- import { CSSProperties } from 'styled-components';
2
- import { IShadowGradientStyle } from '../type';
3
- export interface StyledRightShadowProps {
4
- width?: string;
5
- shadowGradientStyle?: IShadowGradientStyle;
6
- }
7
- declare const StyledRightShadow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledRightShadowProps & {
8
- css?: CSSProperties | undefined;
9
- }, never>;
10
- export default StyledRightShadow;
11
- //# sourceMappingURL=StyledRightShadow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StyledRightShadow.d.ts","sourceRoot":"","sources":["../../packages/components/HorizontalScroll/src/StyledRightShadow/StyledRightShadow.tsx"],"names":[],"mappings":"AAAA,OAAe,EAAe,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,sBAAsB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;CAC3C;AAED,QAAA,MAAM,iBAAiB;;SAiBtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,2 +0,0 @@
1
- export { default as StyledRightShadow } from './StyledRightShadow';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/components/HorizontalScroll/src/StyledRightShadow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}