@am92/react-design-system 2.8.3 → 2.9.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.
@@ -1,46 +1,39 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { DsIconButton } from '../../DsIconButton';
3
3
  import { DsRemixIcon } from '../../DsRemixIcon';
4
- const DsCarouselNavigation = (props) => {
5
- const { uid, isEnabled, NavigationProps = {} } = props;
4
+ import { DsBox } from '../../DsBox';
5
+ const DsCarouselNavigation = props => {
6
+ const { isEnabled, NavigationProps = {} } = props;
6
7
  if (!isEnabled) {
7
8
  return false;
8
9
  }
9
- const { PrevButtonProps = {}, NextButtonProps = {} } = NavigationProps;
10
+ const { PrevButtonProps = {}, NextButtonProps = {}, NavigationWrapperProps } = NavigationProps;
10
11
  const { IconProps: PrevIconProps, ...PrevIconButtonProps } = PrevButtonProps;
11
12
  const { IconProps: NextIconProps, ...NextIconButtonProps } = NextButtonProps;
12
- return (_jsxs(_Fragment, { children: [_jsx(DsIconButton, { className: `swiper-button-prev-${uid}`, ...PrevIconButtonProps, sx: {
13
- position: 'absolute',
14
- top: '50%',
15
- transform: 'translateY(-50%)',
16
- left: 'var(--ds-spacing-mild)',
17
- p: 'var(--ds-spacing-quickFreeze)',
18
- borderRadius: 'var(--ds-radius-bitterCold)',
19
- backgroundColor: 'var(--ds-colour-surfaceSecondary)',
20
- zIndex: 1,
21
- '&:hover': {
22
- backgroundColor: 'var(--ds-colour-stateSelectedPrimaryHover)'
23
- },
24
- '&.Mui-disabled': {
25
- pointerEvents: 'unset'
26
- },
27
- ...PrevIconButtonProps?.sx
28
- }, children: _jsx(DsRemixIcon, { className: "ri-arrow-left-s-line", ...PrevIconProps }) }), _jsx(DsIconButton, { className: `swiper-button-next-${uid}`, ...NextIconButtonProps, sx: {
29
- position: 'absolute',
30
- top: '50%',
31
- transform: 'translateY(-50%)',
32
- right: 'var(--ds-spacing-mild)',
33
- p: 'var(--ds-spacing-quickFreeze)',
34
- borderRadius: 'var(--ds-radius-bitterCold)',
35
- backgroundColor: 'var(--ds-colour-surfaceSecondary)',
36
- zIndex: 1,
37
- '&:hover': {
38
- backgroundColor: 'var(--ds-colour-stateSelectedPrimaryHover)'
39
- },
40
- '&.Mui-disabled': {
41
- pointerEvents: 'unset'
42
- },
43
- ...NextIconButtonProps?.sx
44
- }, children: _jsx(DsRemixIcon, { className: "ri-arrow-right-s-line", ...NextIconProps }) })] }));
13
+ return (_jsxs(DsBox, { sx: {
14
+ height: '100%',
15
+ width: '100%',
16
+ position: 'absolute',
17
+ top: 0,
18
+ left: 0,
19
+ display: 'flex',
20
+ justifyContent: 'space-between',
21
+ alignItems: 'center',
22
+ paddingBottom: 'inherit',
23
+ px: 'var(--ds-spacing-mild)',
24
+ '> .MuiIconButton-root': {
25
+ p: 'var(--ds-spacing-quickFreeze)',
26
+ borderRadius: 'var(--ds-radius-bitterCold)',
27
+ backgroundColor: 'var(--ds-colour-surfaceSecondary)',
28
+ zIndex: 1,
29
+ '&:hover': {
30
+ backgroundColor: 'var(--ds-colour-stateSelectedPrimaryHover)'
31
+ },
32
+ '&.Mui-disabled': {
33
+ pointerEvents: 'unset'
34
+ }
35
+ },
36
+ ...NavigationWrapperProps?.sx
37
+ }, ...NavigationWrapperProps, children: [_jsx(DsIconButton, { className: `swiper-button-prev-custom`, ...PrevIconButtonProps, children: _jsx(DsRemixIcon, { className: 'ri-arrow-left-s-line', ...PrevIconProps }) }), _jsx(DsIconButton, { className: `swiper-button-next-custom`, ...NextIconButtonProps, children: _jsx(DsRemixIcon, { className: 'ri-arrow-right-s-line', ...NextIconProps }) })] }));
45
38
  };
46
39
  export default DsCarouselNavigation;
@@ -0,0 +1,4 @@
1
+ import { SwiperContainerWrapperProps } from '../DsCarousel.Types';
2
+ export declare const DsCarouselStyledWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
4
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & SwiperContainerWrapperProps, {}, {}>;
@@ -0,0 +1,90 @@
1
+ import { styled } from '@mui/material';
2
+ import { DsBox } from '../../DsBox';
3
+ export const DsCarouselStyledWrapper = styled(DsBox, {
4
+ shouldForwardProp: prop => !['isAutoplayEnabled', 'transitionSpeed', 'isExternalPagination'].includes(prop)
5
+ })(({ isAutoplayEnabled, transitionSpeed, isExternalPagination, sx }) => ({
6
+ '.swiper-pagination': {
7
+ position: 'absolute',
8
+ textAlign: 'center',
9
+ transition: '300ms opacity',
10
+ transform: 'translate3d(0, 0, 0)',
11
+ zIndex: 1,
12
+ '>.swiper-pagination-hidden': {
13
+ opacity: 0
14
+ },
15
+ '&.swiper-pagination-disabled': {
16
+ display: 'none !important'
17
+ },
18
+ '> .swiper-pagination-bullet': {
19
+ width: '6px',
20
+ height: '6px',
21
+ display: 'inline-block',
22
+ borderRadius: 'var(--ds-radius-bitterCold)',
23
+ opacity: 1,
24
+ margin: 'var(--ds-spacing-deepFreeze)',
25
+ background: 'linear-gradient(to right, var(--ds-colour-actionSecondary), var(--ds-colour-actionSecondary)) no-repeat, linear-gradient(to right, var(--ds-colour-stateUnselectedDefault), var(--ds-colour-stateUnselectedDefault)) no-repeat',
26
+ backgroundSize: '0% 100%, 100% 100%',
27
+ backgroundPosition: '0 0, 0 0',
28
+ '&:only-child': {
29
+ display: 'none !important'
30
+ },
31
+ '&.swiper-pagination-bullet-active': {
32
+ width: isAutoplayEnabled ? '20px' : '16px',
33
+ background: isAutoplayEnabled
34
+ ? 'linear-gradient(to right, var(--ds-colour-actionSecondary), var(--ds-colour-actionSecondary)) no-repeat, linear-gradient(to right, var(--ds-colour-stateUnselectedDefault), var(--ds-colour-stateUnselectedDefault)) no-repeat'
35
+ : 'var(--ds-colour-actionSecondary)',
36
+ opacity: 1,
37
+ borderRadius: 'var(--ds-radius-bitterCold)',
38
+ backgroundSize: '100% 100%, 100% 100%',
39
+ backgroundPosition: '0 0 , 100% 0',
40
+ transition: `width 0.5s, background-size ${transitionSpeed / 1000}s`
41
+ }
42
+ },
43
+ '&.swiper-pagination-clickable > .swiper-pagination-bullet': {
44
+ cursor: 'pointer'
45
+ },
46
+ '&.swiper-pagination-bullets-dynamic': {
47
+ overflow: 'hidden',
48
+ fontSize: 0,
49
+ '> .swiper-pagination-bullet': {
50
+ transform: 'scale(0.33)',
51
+ position: 'relative',
52
+ '&.swiper-pagination-bullet-active': {
53
+ transform: 'scale(1)'
54
+ },
55
+ '&.swiper-pagination-bullet-active-prev': {
56
+ transform: 'scale(0.66)'
57
+ },
58
+ '&.swiper-pagination-bullet-active-prev-prev': {
59
+ transform: 'scale(0.33)'
60
+ },
61
+ '&.swiper-pagination-bullet-active-next': {
62
+ transform: 'scale(0.66)'
63
+ },
64
+ '&.swiper-pagination-bullet-active-next-next': {
65
+ transform: 'scale(0.33)'
66
+ }
67
+ }
68
+ },
69
+ '&.swiper-pagination-horizontal.swiper-pagination-bullets': {
70
+ bottom: !isExternalPagination
71
+ ? 'var(--ds-spacing-frostbite)'
72
+ : 'var(--ds-spacing-zero)',
73
+ top: 'auto',
74
+ left: 0,
75
+ width: '100%',
76
+ '&.swiper-pagination-bullets-dynamic': {
77
+ left: '50%',
78
+ transform: 'translateX(-50%)',
79
+ whiteSpace: 'nowrap',
80
+ '> .swiper-pagination-bullet': {
81
+ transition: '200ms transform, 200ms left',
82
+ '&.swiper-pagination-bullet-active': {
83
+ transition: `width 0.5s, background-size ${transitionSpeed / 1000}s, 200ms transform, 200ms left`
84
+ }
85
+ }
86
+ }
87
+ },
88
+ ...sx
89
+ }
90
+ }));
@@ -1,3 +1,3 @@
1
- import { FC } from 'react';
1
+ import 'swiper/swiper-bundle.css';
2
2
  import { DsCarouselProps } from '../DsCarousel.Types';
3
- export declare const DsCarousel: FC<DsCarouselProps>;
3
+ export declare const DsCarousel: (props: DsCarouselProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,31 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useEffect } from 'react';
3
- import { Autoplay, Navigation, Pagination } from 'swiper/modules';
4
- import { register } from 'swiper/element';
5
- import { CAROUSEL_DEFAULT_SETTINGS, SWIPER_AUTOPLAY_SETTINGS, SWIPER_NAVIGATION_SETTINGS, SWIPER_PAGINATION_SETTINGS } from '../DsCarousel.Types';
2
+ import React, { useMemo } from 'react';
3
+ import { Swiper, SwiperSlide } from 'swiper/react';
4
+ import { Navigation, Pagination, Autoplay } from 'swiper/modules';
5
+ import 'swiper/swiper-bundle.css';
6
+ import { SWIPER_AUTOPLAY_SETTINGS, SWIPER_NAVIGATION_SETTINGS, SWIPER_PAGINATION_SETTINGS } from '../DsCarousel.Types';
6
7
  import DsCarouselNavigation from './DsCarouselNavigation';
7
- import DsCarouselPagination from './DsCarouselPagination';
8
- import { DsBox } from '../../DsBox';
9
- if (register && typeof register === 'function') {
10
- register();
11
- }
12
- const generateUid = () => {
13
- const random = Math.trunc((Math.random() + 1) * 1000000);
14
- return `${random.toString(36)}`;
15
- };
8
+ import { DsCarouselStyledWrapper } from './DsCarouselStyledWrapper';
16
9
  export const DsCarousel = (props) => {
17
- let SwiperContainer = null;
18
- const uid = generateUid();
19
- useEffect(() => {
20
- initialize();
21
- }, []);
22
- const _isNavigationEnabled = () => {
23
- const { navigation } = props;
24
- return !(navigation === false ||
25
- (navigation &&
26
- typeof navigation !== 'boolean' &&
27
- navigation.enabled === false));
28
- };
29
10
  const _isPaginationEnabled = () => {
30
11
  const { pagination } = props;
31
12
  return !(pagination === false ||
@@ -33,35 +14,28 @@ export const DsCarousel = (props) => {
33
14
  typeof pagination !== 'boolean' &&
34
15
  pagination.enabled === false));
35
16
  };
36
- const _isAutoplayEnabled = () => {
37
- const { autoplay } = props;
38
- return !(autoplay === false);
39
- };
40
- const _getNavigationSettings = () => {
41
- const { navigation } = props;
42
- const isEnabled = _isNavigationEnabled();
43
- const defaultSettings = {
44
- ...SWIPER_NAVIGATION_SETTINGS,
45
- nextEl: `${SWIPER_NAVIGATION_SETTINGS.nextEl}-${uid}`,
46
- prevEl: `${SWIPER_NAVIGATION_SETTINGS.prevEl}-${uid}`
47
- };
48
- if (typeof navigation !== 'boolean') {
49
- return isEnabled ? { ...defaultSettings, ...navigation } : undefined;
50
- }
51
- return (isEnabled && { ...defaultSettings }) || undefined;
52
- };
53
17
  const _getPaginationSettings = () => {
54
18
  const { pagination } = props;
55
19
  const isEnabled = _isPaginationEnabled();
56
20
  const defaultSettings = {
57
- ...SWIPER_PAGINATION_SETTINGS,
58
- el: `${SWIPER_PAGINATION_SETTINGS.el}-${uid}`
21
+ ...SWIPER_PAGINATION_SETTINGS
59
22
  };
60
23
  if (typeof pagination !== 'boolean') {
61
24
  return isEnabled ? { ...defaultSettings, ...pagination } : undefined;
62
25
  }
63
26
  return (isEnabled && { ...defaultSettings }) || undefined;
64
27
  };
28
+ const _isAutoplayEnabled = () => {
29
+ const { autoplay } = props;
30
+ return autoplay ? !(autoplay === false) : false;
31
+ };
32
+ const _isNavigationEnabled = () => {
33
+ const { navigation } = props;
34
+ return !(navigation === false ||
35
+ (navigation &&
36
+ typeof navigation !== 'boolean' &&
37
+ navigation.enabled === false));
38
+ };
65
39
  const _getAutoPlaySettings = () => {
66
40
  const { autoplay } = props;
67
41
  const isEnabled = _isAutoplayEnabled();
@@ -88,43 +62,33 @@ export const DsCarousel = (props) => {
88
62
  }
89
63
  return sanitizedModule;
90
64
  };
91
- const initialize = () => {
92
- const { children, PaginationProps, NavigationProps, PaginationWrapperProps, SwiperConatinerStyles, SwiperConatinerWrapperProps, modules, ...swiperProps } = props;
93
- const sanitizedModule = _sanitizeModuleProps(modules);
94
- // swiper parameters
95
- const swiperParams = {
96
- ...CAROUSEL_DEFAULT_SETTINGS,
97
- ...swiperProps,
98
- // Vertical mode not supported
99
- direction: 'horizontal',
100
- modules: sanitizedModule,
101
- navigation: _getNavigationSettings() || false,
102
- pagination: _getPaginationSettings() || false,
103
- autoplay: _getAutoPlaySettings() || false
65
+ const _getNavigationSettings = () => {
66
+ const { navigation } = props;
67
+ const isEnabled = _isNavigationEnabled();
68
+ const defaultSettings = {
69
+ ...SWIPER_NAVIGATION_SETTINGS
104
70
  };
105
- // swiperParams = handleNavigationModule(swiperParams)
106
- // now we need to assign all parameters to Swiper element
107
- Object.assign(SwiperContainer || {}, swiperParams);
108
- // and now initialize it
109
- SwiperContainer?.initialize();
110
- // set the default theme
111
- document.documentElement.style.setProperty('--swiper-theme-color', 'var(--ds-colour-actionSecondary)');
112
- };
113
- const setRef = (swiperRef) => {
114
- SwiperContainer = swiperRef;
71
+ if (typeof navigation !== 'boolean') {
72
+ return isEnabled ? { ...defaultSettings, ...navigation } : undefined;
73
+ }
74
+ return (isEnabled && { ...defaultSettings }) || undefined;
115
75
  };
116
- const { PaginationWrapperProps, SwiperConatinerWrapperProps, SwiperConatinerStyles, children, NavigationProps, PaginationProps } = props;
117
- const paginationSettings = _getPaginationSettings();
118
- return (_jsxs(DsBox, { ...PaginationWrapperProps, sx: {
119
- position: 'relative',
120
- pb: paginationSettings?.mode === 'external' ? '44px' : undefined,
121
- ...PaginationWrapperProps?.sx
122
- }, children: [_jsxs(DsBox, { ...SwiperConatinerWrapperProps, sx: {
123
- position: 'relative',
124
- ...SwiperConatinerWrapperProps?.sx
125
- }, children: [_jsx("swiper-container", { ref: setRef, init: false, style: {
126
- ...SwiperConatinerStyles
127
- }, children: React.Children.map(children, (child, index) => {
128
- return (_jsx("swiper-slide", { children: child }, `${name}-${index}`));
129
- }) }), _jsx(DsCarouselNavigation, { uid: uid, isEnabled: _isNavigationEnabled(), NavigationProps: NavigationProps })] }), _jsx(DsCarouselPagination, { uid: uid, isEnabled: _isPaginationEnabled(), isAutoplayEnabled: _isAutoplayEnabled(), AutoplaySettings: _getAutoPlaySettings(), PaginationSettings: paginationSettings, PaginationProps: PaginationProps })] }));
76
+ const { SwiperContainerWrapperProps, SwiperContainerStyles, children, NavigationProps, pagination, navigation, autoplay, modules, ...swiperProps } = props;
77
+ const paginationSettings = useMemo(() => _getPaginationSettings(), [pagination]);
78
+ const navigationSettings = useMemo(() => _getNavigationSettings(), [navigation]);
79
+ const autoPlaySettings = useMemo(() => _getAutoPlaySettings(), [autoplay]);
80
+ const moduleSettings = useMemo(() => _sanitizeModuleProps(modules), [modules]);
81
+ let transitionSpeed = 0;
82
+ const isAutoplayEnabled = _isAutoplayEnabled();
83
+ if (isAutoplayEnabled) {
84
+ transitionSpeed =
85
+ (typeof autoPlaySettings !== 'boolean' && autoPlaySettings?.delay) || 3000;
86
+ }
87
+ const isExternalPagination = paginationSettings?.mode === 'external';
88
+ return (_jsx(DsCarouselStyledWrapper, { isAutoplayEnabled: isAutoplayEnabled, transitionSpeed: transitionSpeed, isExternalPagination: isExternalPagination, ...SwiperContainerWrapperProps, children: _jsxs(Swiper, { pagination: paginationSettings, navigation: navigationSettings, modules: moduleSettings, autoplay: autoPlaySettings, style: {
89
+ paddingBottom: isExternalPagination ? '44px' : undefined,
90
+ ...SwiperContainerStyles
91
+ }, ...swiperProps,
92
+ // Vertical mode not supported
93
+ direction: 'horizontal', children: [React.Children.map(children, (child, index) => (_jsx(SwiperSlide, { children: child }, `${name}-${index}`))), _jsx(DsCarouselNavigation, { isEnabled: _isNavigationEnabled(), NavigationProps: NavigationProps })] }) }));
130
94
  };
@@ -4,35 +4,49 @@ import { DsBoxProps } from '../DsBox';
4
4
  import { DsIconButtonProps } from '../DsIconButton';
5
5
  import { DsRemixIconProps } from '../DsRemixIcon';
6
6
  export interface DsCarouselNavigationButtonProps extends DsIconButtonProps {
7
+ /** This Propperty can be used to pass icon props to the navigation buttons. */
7
8
  IconProps?: Omit<DsRemixIconProps, 'ref'>;
8
9
  }
9
10
  export interface DsCarouselNavigationProps {
10
- uid: string;
11
11
  isEnabled: boolean;
12
+ /** This Property can be used to pass Navigation props
13
+ * @enum PrevButtonProps, NextButtonProps, NavigationWrapperProps
14
+ */
12
15
  NavigationProps?: {
16
+ /** This property can be used to provide props to Icon navigation buttons
17
+ * @default DsIconButtonProps
18
+ */
13
19
  PrevButtonProps?: DsCarouselNavigationButtonProps;
20
+ /** This property can be used to provide props to Icon navigation buttons
21
+ * @default DsIconButtonProps
22
+ */
14
23
  NextButtonProps?: DsCarouselNavigationButtonProps;
24
+ /** This property can be used to provide navigation wrapper props as DsBoxProps */
25
+ NavigationWrapperProps?: DsBoxProps;
15
26
  };
16
27
  }
17
- export interface DsCarouselPaginationProps {
18
- uid: string;
19
- isEnabled: boolean;
20
- isAutoplayEnabled: boolean;
21
- AutoplaySettings: DsCarouselProps['autoplay'];
22
- PaginationSettings?: DsCarouselProps['pagination'];
23
- PaginationProps?: DsBoxProps;
24
- }
25
28
  type DsCarouselPaginationMode = 'internal' | 'external';
26
29
  export type DsCaroselPaginationSettings = SwiperProps['pagination'] & {
30
+ /** This property can be used to prove the position mode for pagination */
27
31
  mode?: DsCarouselPaginationMode;
28
32
  };
29
- export interface DsCarouselProps extends Omit<SwiperProps, 'direction' | 'pagination'>, Omit<DsCarouselNavigationProps, 'uid' | 'isEnabled'>, Omit<DsCarouselPaginationProps, 'uid' | 'isEnabled' | 'isAutoplayEnabled' | 'AutoplaySettings'> {
30
- PaginationWrapperProps?: DsBoxProps;
31
- SwiperConatinerWrapperProps?: DsBoxProps;
32
- SwiperConatinerStyles?: React.CSSProperties;
33
+ export interface DsCarouselProps extends Omit<SwiperProps, 'direction' | 'pagination'>, Omit<DsCarouselNavigationProps, 'isEnabled'> {
34
+ /** This property can be used to pass Swiper Wrapper props which is BoxProps */
35
+ SwiperContainerWrapperProps?: Omit<SwiperContainerWrapperProps, 'transitionSpeed' | 'isAutoplayEnabled' | 'isExternalPagination'>;
36
+ /** This property can be used to add container styled to Swiper element */
37
+ SwiperContainerStyles?: React.CSSProperties;
38
+ /** This property can be used to provide swiper direction */
33
39
  direction?: 'horizontal';
40
+ /** This property can be used to provide pagination props
41
+ * @enum mode
42
+ */
34
43
  pagination?: DsCaroselPaginationSettings;
35
44
  }
45
+ export interface SwiperContainerWrapperProps extends DsBoxProps {
46
+ transitionSpeed: number;
47
+ isAutoplayEnabled: boolean;
48
+ isExternalPagination: boolean;
49
+ }
36
50
  export declare const CAROUSEL_DEFAULT_SETTINGS: DsCarouselProps;
37
51
  export declare const DsCarouselDefaultProps: DsCarouselProps;
38
52
  export declare const SWIPER_NAVIGATION_SETTINGS: {
@@ -44,7 +58,6 @@ export declare const SWIPER_NAVIGATION_SETTINGS: {
44
58
  };
45
59
  export declare const SWIPER_PAGINATION_SETTINGS: {
46
60
  enabled: boolean;
47
- el: string;
48
61
  mode: DsCarouselPaginationMode;
49
62
  };
50
63
  export declare const SWIPER_AUTOPLAY_SETTINGS: {
@@ -7,14 +7,13 @@ export const CAROUSEL_DEFAULT_SETTINGS = {
7
7
  export const DsCarouselDefaultProps = CAROUSEL_DEFAULT_SETTINGS;
8
8
  export const SWIPER_NAVIGATION_SETTINGS = {
9
9
  enabled: true,
10
- nextEl: '.swiper-button-next',
11
- prevEl: '.swiper-button-prev',
10
+ nextEl: '.swiper-button-next-custom',
11
+ prevEl: '.swiper-button-prev-custom',
12
12
  disabledClass: 'Mui-disabled',
13
13
  navigationDisabledClass: 'Mui-disabled'
14
14
  };
15
15
  export const SWIPER_PAGINATION_SETTINGS = {
16
16
  enabled: true,
17
- el: '.swiper-pagination',
18
17
  mode: 'internal'
19
18
  };
20
19
  export const SWIPER_AUTOPLAY_SETTINGS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@am92/react-design-system",
3
- "version": "2.8.3",
3
+ "version": "2.9.1",
4
4
  "description": "ReactJS Design System using Material UI",
5
5
  "sideEffects": false,
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { DsCarouselPaginationProps } from '../DsCarousel.Types';
3
- declare const DsCarouselPagination: React.FC<DsCarouselPaginationProps>;
4
- export default DsCarouselPagination;
@@ -1,130 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { DsBox } from '../../DsBox';
4
- const DsCarouselPagination = (props) => {
5
- const paginationRef = React.useRef();
6
- React.useEffect(() => {
7
- handleFirstTransition();
8
- }, []);
9
- const handleFirstTransition = () => {
10
- const firstActiveBullet = paginationRef.current?.getElementsByClassName('swiper-pagination-bullet-active')[0];
11
- if (firstActiveBullet) {
12
- firstActiveBullet.classList.remove('swiper-pagination-bullet-active');
13
- setTimeout(() => {
14
- firstActiveBullet.classList.add('swiper-pagination-bullet-active');
15
- }, 0);
16
- }
17
- };
18
- const { uid, isEnabled, isAutoplayEnabled, PaginationSettings, AutoplaySettings, PaginationProps } = props;
19
- if (!isEnabled) {
20
- return false;
21
- }
22
- let className = `swiper-pagination-${uid}`;
23
- let transitionSpeed = 0;
24
- if (isAutoplayEnabled) {
25
- className = `swiper-pagination-${uid} rds-pilled`;
26
- transitionSpeed =
27
- (typeof AutoplaySettings !== 'boolean' && AutoplaySettings?.delay) ||
28
- 3000;
29
- }
30
- return (_jsx(DsBox, { ref: paginationRef, className: className, ...PaginationProps, sx: {
31
- position: 'absolute',
32
- textAlign: 'center',
33
- transition: '300ms opacity',
34
- transform: 'translate3d(0, 0, 0)',
35
- zIndex: 1,
36
- '&.swiper-pagination-hidden': {
37
- opacity: 0
38
- },
39
- '&.swiper-pagination-disabled': {
40
- '&.swiper-pagination-disabled': {
41
- display: 'none !important'
42
- }
43
- },
44
- '&.swiper-pagination-bullets': {
45
- '> .swiper-pagination-bullet': {
46
- width: '6px',
47
- height: '6px',
48
- display: 'inline-block',
49
- borderRadius: 'var(--ds-radius-bitterCold)',
50
- opacity: 1,
51
- mx: 'var(--ds-spacing-deepFreeze)',
52
- background: 'linear-gradient(to right, var(--ds-colour-actionSecondary), var(--ds-colour-actionSecondary)) no-repeat, linear-gradient(to right, var(--ds-colour-stateUnselectedDefault), var(--ds-colour-stateUnselectedDefault)) no-repeat',
53
- backgroundSize: '0% 100%, 100% 100%',
54
- backgroundPosition: '0 0, 0 0',
55
- '&:only-child': {
56
- display: 'none !important'
57
- },
58
- '&.swiper-pagination-bullet-active': {
59
- width: '16px',
60
- background: 'var(--ds-colour-actionSecondary)',
61
- opacity: 1
62
- }
63
- }
64
- },
65
- '&.swiper-pagination-bullets.rds-pilled': {
66
- '> .swiper-pagination-bullet': {
67
- '&.swiper-pagination-bullet-active': {
68
- width: '20px',
69
- background: 'linear-gradient(to right, var(--ds-colour-actionSecondary), var(--ds-colour-actionSecondary)) no-repeat, linear-gradient(to right, var(--ds-colour-stateUnselectedDefault), var(--ds-colour-stateUnselectedDefault)) no-repeat',
70
- borderRadius: 'var(--ds-radius-bitterCold)',
71
- backgroundSize: '100% 100%, 100% 100%',
72
- backgroundPosition: '0 0 , 100% 0',
73
- transition: `width 0.5s, background-size ${transitionSpeed / 1000}s`
74
- }
75
- }
76
- },
77
- '&.swiper-pagination-clickable': {
78
- '> .swiper-pagination-bullet': {
79
- cursor: 'pointer'
80
- }
81
- },
82
- '&.swiper-pagination-bullets-dynamic': {
83
- overflow: 'hidden',
84
- fontSize: 0,
85
- '> .swiper-pagination-bullet': {
86
- transform: 'scale(0.33)',
87
- position: 'relative',
88
- '&.swiper-pagination-bullet-active': {
89
- transform: 'scale(1)'
90
- },
91
- '&.swiper-pagination-bullet-active-main': {
92
- transform: 'scale(1)'
93
- },
94
- '&.swiper-pagination-bullet-active-prev': {
95
- transform: 'scale(0.66)'
96
- },
97
- '&.swiper-pagination-bullet-active-prev-prev': {
98
- transform: 'scale(0.33)'
99
- },
100
- '&.swiper-pagination-bullet-active-next': {
101
- transform: 'scale(0.66)'
102
- },
103
- '&.swiper-pagination-bullet-active-next-next': {
104
- transform: 'scale(0.33)'
105
- }
106
- }
107
- },
108
- '&.swiper-pagination-horizontal.swiper-pagination-bullets': {
109
- bottom: PaginationSettings?.mode === 'internal'
110
- ? 'var(--ds-spacing-frostbite)'
111
- : 'var(--ds-spacing-zero)',
112
- top: 'auto',
113
- left: 0,
114
- width: '100%',
115
- '&.swiper-pagination-bullets-dynamic': {
116
- left: '50%',
117
- transform: 'translateX(-50%)',
118
- whiteSpace: 'nowrap',
119
- '> .swiper-pagination-bullet': {
120
- transition: `200ms transform, 200ms left`,
121
- '&.swiper-pagination-bullet-active': {
122
- transition: `width 0.5s, background-size ${transitionSpeed / 1000}s, 200ms transform, 200ms left`
123
- }
124
- }
125
- }
126
- },
127
- ...PaginationProps?.sx
128
- } }));
129
- };
130
- export default DsCarouselPagination;