@semcore/carousel 3.45.1 → 3.45.2

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 +1 @@
1
- {"version":3,"file":"Carousel.types.js","names":[],"sources":["../../src/Carousel.types.ts"],"sourcesContent":["import { PropGetterFn, UnknownProperties, Intergalactic, IRootComponentProps } from '@semcore/core';\nimport { BoxProps } from '@semcore/flex-box';\n\n/** @deprecated */\nexport interface ICarouselProps extends CarouselProps, UnknownProperties {}\nexport type CarouselProps = BoxProps & {\n /** Index active item */\n index?: number;\n /**\n * Index of the active item selected by default\n * @default 0\n */\n defaultIndex?: number;\n /** Called when the selection is changed */\n onIndexChange?: (index: number) => void;\n /** Animation duration\n * @default 300 */\n duration?: number;\n /** Disables infinite items change in the carousel\n * @default false */\n bounded?: boolean;\n /** @ignore */\n step?: number;\n locale?: string;\n /** Enable zoom feature for carousel items */\n zoom?: boolean;\n /** Width for items in zooming modal */\n zoomWidth?: number;\n /** Type of indicators */\n indicators?: 'default' | 'hide' | 'preview';\n};\n\n/** @deprecated */\nexport interface ICarouselContext extends CarouselContext, UnknownProperties {}\nexport type CarouselContext = {\n getContainerProps: PropGetterFn;\n getItemProps: PropGetterFn;\n getPrevProps: PropGetterFn;\n getNextProps: PropGetterFn;\n getIndicatorsProps: PropGetterFn;\n};\n\nexport type CarouselItem = {\n node: HTMLElement;\n};\n\nexport type CarouselItemProps = BoxProps & {\n /** Flag for css cursor\n * @private\n */\n zoomIn?: boolean;\n /** Flag for css cursor\n * @private\n */\n zoomOut?: boolean;\n\n /** Function to add item to list in Carousel\n * @private\n */\n toggleItem?: (item: CarouselItem, toRemove?: boolean) => void;\n\n /** Index of item in carousel */\n index?: number;\n\n uid?: string;\n\n /** Flag - is current item shown now */\n current?: boolean;\n\n /** Handler for show item in modal window\n * @private\n */\n onToggleZoomModal?: () => void;\n\n /** Value for transform item\n * @private\n */\n transform?: number;\n};\n\n/** @deprecated */\nexport interface ICarouselState extends CarouselState, UnknownProperties {}\nexport type CarouselState = {\n isOpenZoom: boolean;\n selectedIndex: number;\n items: CarouselItem[];\n};\n\nexport type CarouselButtonProps = IRootComponentProps &\n BoxProps & {\n label?: string;\n inverted?: boolean;\n tabIndex?: number;\n };\n\nexport type CarouselIndicatorsProps = IRootComponentProps &\n BoxProps & {\n items?: CarouselItem[];\n inverted?: boolean;\n };\n\nexport type CarouselIndicatorProps = IRootComponentProps &\n Omit<BoxProps, 'position'> & {\n active?: boolean;\n onClick?: () => void;\n inverted?: boolean;\n } & CarouselItem;\n\ndeclare const CarouselType: Intergalactic.Component<\n 'div',\n CarouselProps,\n CarouselContext & CarouselState\n> & {\n Container: Intergalactic.Component<'div', BoxProps>;\n Indicators: Intergalactic.Component<'div', CarouselIndicatorsProps, CarouselState>;\n Indicator: Intergalactic.Component<'div', CarouselIndicatorProps>;\n Item: Intergalactic.Component<'div', CarouselItemProps>;\n Prev: Intergalactic.Component<'div', CarouselButtonProps>;\n Next: Intergalactic.Component<'div', CarouselButtonProps>;\n};\n\nexport default CarouselType;\n"],"mappings":""}
1
+ {"version":3,"file":"Carousel.types.js","names":[],"sources":["../../src/Carousel.types.ts"],"sourcesContent":["import { PropGetterFn, UnknownProperties, Intergalactic, IRootComponentProps } from '@semcore/core';\nimport { BoxProps } from '@semcore/flex-box';\n\n/** @deprecated */\nexport interface ICarouselProps extends CarouselProps, UnknownProperties {}\nexport type CarouselProps = BoxProps & {\n /** Index active item */\n index?: number;\n /**\n * Index of the active item selected by default\n * @default 0\n */\n defaultIndex?: number;\n /** Called when the selection is changed */\n onIndexChange?: (index: number) => void;\n /** Animation duration\n * @default 300 */\n duration?: number;\n /** Disables infinite items change in the carousel\n * @default false */\n bounded?: boolean;\n /** @ignore */\n step?: number;\n locale?: string;\n /** Enable zoom feature for carousel items */\n zoom?: boolean;\n /** Width for items in zooming modal */\n zoomWidth?: number;\n /** Type of indicators */\n indicators?: 'default' | 'hide' | 'preview';\n};\n\n/** @deprecated */\nexport interface ICarouselContext extends CarouselContext, UnknownProperties {}\nexport type CarouselContext = {\n getContainerProps: PropGetterFn;\n getItemProps: PropGetterFn;\n getPrevProps: PropGetterFn;\n getNextProps: PropGetterFn;\n getIndicatorsProps: PropGetterFn;\n};\n\nexport type CarouselItem = {\n node: HTMLElement;\n};\n\nexport type CarouselItemProps = BoxProps & {\n /** Flag for css cursor\n * @private\n */\n zoomIn?: boolean;\n /** Flag for css cursor\n * @private\n */\n zoomOut?: boolean;\n\n /** Function to add item to list in Carousel\n * @private\n */\n toggleItem?: (item: CarouselItem, toRemove?: boolean) => void;\n\n /** Index of item in carousel */\n index?: number;\n\n uid?: string;\n\n /** Flag - is current item shown now */\n current?: boolean;\n\n /** Handler for show item in modal window\n * @private\n */\n onToggleZoomModal?: () => void;\n\n /** Value for transform item\n * @private\n */\n transform?: number;\n\n /**\n * Flag data zoomed\n * @private\n */\n isOpenZoom?: boolean;\n};\n\n/** @deprecated */\nexport interface ICarouselState extends CarouselState, UnknownProperties {}\nexport type CarouselState = {\n isOpenZoom: boolean;\n selectedIndex: number;\n items: CarouselItem[];\n};\n\nexport type CarouselButtonProps = IRootComponentProps &\n BoxProps & {\n label?: string;\n inverted?: boolean;\n tabIndex?: number;\n };\n\nexport type CarouselIndicatorsProps = IRootComponentProps &\n BoxProps & {\n items?: CarouselItem[];\n inverted?: boolean;\n };\n\nexport type CarouselIndicatorProps = IRootComponentProps &\n Omit<BoxProps, 'position'> & {\n active?: boolean;\n onClick?: () => void;\n inverted?: boolean;\n } & CarouselItem;\n\ndeclare const CarouselType: Intergalactic.Component<\n 'div',\n CarouselProps,\n CarouselContext & CarouselState\n> & {\n Container: Intergalactic.Component<'div', BoxProps>;\n ContentBox: Intergalactic.Component<'div', BoxProps>;\n Indicators: Intergalactic.Component<'div', CarouselIndicatorsProps, CarouselState>;\n Indicator: Intergalactic.Component<'div', CarouselIndicatorProps>;\n Item: Intergalactic.Component<'div', CarouselItemProps>;\n Prev: Intergalactic.Component<'div', CarouselButtonProps>;\n Next: Intergalactic.Component<'div', CarouselButtonProps>;\n};\n\nexport default CarouselType;\n"],"mappings":""}
@@ -108,7 +108,6 @@ SNext {
108
108
  margin-left: calc(2 * var(--intergalactic-spacing-1x, 4px) - 1px);
109
109
  margin-right: calc(2 * var(--intergalactic-spacing-1x, 4px) - 1px);
110
110
  }
111
-
112
111
  }
113
112
 
114
113
  SPrevButton, SNextButton {
@@ -68,6 +68,11 @@ export type CarouselItemProps = BoxProps & {
68
68
  * @private
69
69
  */
70
70
  transform?: number;
71
+ /**
72
+ * Flag data zoomed
73
+ * @private
74
+ */
75
+ isOpenZoom?: boolean;
71
76
  };
72
77
  /** @deprecated */
73
78
  export interface ICarouselState extends CarouselState, UnknownProperties {
@@ -93,6 +98,7 @@ export type CarouselIndicatorProps = IRootComponentProps & Omit<BoxProps, 'posit
93
98
  } & CarouselItem;
94
99
  declare const CarouselType: Intergalactic.Component<'div', CarouselProps, CarouselContext & CarouselState> & {
95
100
  Container: Intergalactic.Component<'div', BoxProps>;
101
+ ContentBox: Intergalactic.Component<'div', BoxProps>;
96
102
  Indicators: Intergalactic.Component<'div', CarouselIndicatorsProps, CarouselState>;
97
103
  Indicator: Intergalactic.Component<'div', CarouselIndicatorProps>;
98
104
  Item: Intergalactic.Component<'div', CarouselItemProps>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/carousel",
3
3
  "description": "Semrush Carousel Component",
4
- "version": "3.45.1",
4
+ "version": "3.45.2",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -9,12 +9,12 @@
9
9
  "author": "UI-kit team <ui-kit-team@semrush.com>",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@semcore/flex-box": "5.39.0",
13
- "@semcore/icon": "4.53.0",
14
- "@semcore/utils": "4.44.0",
15
- "@semcore/button": "5.40.1",
16
- "@semcore/modal": "4.50.0",
17
- "@semcore/breakpoints": "1.39.0"
12
+ "@semcore/flex-box": "5.39.1",
13
+ "@semcore/icon": "4.53.1",
14
+ "@semcore/utils": "4.44.1",
15
+ "@semcore/button": "5.40.2",
16
+ "@semcore/modal": "4.50.1",
17
+ "@semcore/breakpoints": "1.39.1"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@semcore/core": "^2.17.5",
package/src/Carousel.tsx CHANGED
@@ -154,6 +154,14 @@ class CarouselRoot extends Component<
154
154
  this.slideToValue(lastSlide);
155
155
  }
156
156
  }
157
+
158
+ if (
159
+ (e.key === 'Enter' || e.key === ' ') &&
160
+ e.target instanceof HTMLDivElement &&
161
+ e.target.role === 'tabpanel'
162
+ ) {
163
+ this.handleToggleZoomModal();
164
+ }
157
165
  };
158
166
 
159
167
  toggleItem = (item: CarouselItem, removeItem = false) => {
@@ -330,6 +338,7 @@ class CarouselRoot extends Component<
330
338
  zoomIn: zoom,
331
339
  onToggleZoomModal: this.handleToggleZoomModal,
332
340
  transform: isCurrent ? this.getTransform() : undefined,
341
+ isOpenZoom: this.state.isOpenZoom,
333
342
  };
334
343
  }
335
344
 
@@ -507,7 +516,6 @@ class CarouselRoot extends Component<
507
516
 
508
517
  render() {
509
518
  const SCarousel = Root;
510
- const SContentBox = Box;
511
519
  const {
512
520
  styles,
513
521
  Children,
@@ -540,11 +548,11 @@ class CarouselRoot extends Component<
540
548
  <>
541
549
  <Flex>
542
550
  <Carousel.Prev />
543
- <SContentBox>
551
+ <Carousel.ContentBox>
544
552
  <Carousel.Container aria-label={ariaLabel}>
545
553
  <Children />
546
554
  </Carousel.Container>
547
- </SContentBox>
555
+ </Carousel.ContentBox>
548
556
  <Carousel.Next />
549
557
  </Flex>
550
558
  {indicators === 'default' && <Carousel.Indicators />}
@@ -590,6 +598,13 @@ const Container = (props: BoxProps & { duration?: number }) => {
590
598
  );
591
599
  };
592
600
 
601
+ const ContentBox = (props: BoxProps) => {
602
+ const SContentBox = Root;
603
+ const { styles } = props;
604
+
605
+ return sstyled(styles)(<SContentBox render={Box} />);
606
+ };
607
+
593
608
  class Item extends Component<CarouselItemProps> {
594
609
  refItem = React.createRef<HTMLElement>();
595
610
  keepFocusTimeout: NodeJS.Timeout | undefined;
@@ -633,6 +648,16 @@ class Item extends Component<CarouselItemProps> {
633
648
  }
634
649
  }, 100);
635
650
  }
651
+ if (
652
+ prevProps.isOpenZoom === true &&
653
+ this.props.isOpenZoom === false &&
654
+ this.props.current &&
655
+ !this.props.zoomOut
656
+ ) {
657
+ this.keepFocusTimeout = setTimeout(() => {
658
+ this.refItem.current?.focus();
659
+ }, 200);
660
+ }
636
661
  }
637
662
 
638
663
  render() {
@@ -729,6 +754,7 @@ const Indicator = ({ styles, Children }: CarouselIndicatorProps) => {
729
754
 
730
755
  const Carousel: typeof CarouselType = createComponent(CarouselRoot, {
731
756
  Container,
757
+ ContentBox,
732
758
  Indicators,
733
759
  Indicator,
734
760
  Item,
@@ -76,6 +76,12 @@ export type CarouselItemProps = BoxProps & {
76
76
  * @private
77
77
  */
78
78
  transform?: number;
79
+
80
+ /**
81
+ * Flag data zoomed
82
+ * @private
83
+ */
84
+ isOpenZoom?: boolean;
79
85
  };
80
86
 
81
87
  /** @deprecated */
@@ -112,6 +118,7 @@ declare const CarouselType: Intergalactic.Component<
112
118
  CarouselContext & CarouselState
113
119
  > & {
114
120
  Container: Intergalactic.Component<'div', BoxProps>;
121
+ ContentBox: Intergalactic.Component<'div', BoxProps>;
115
122
  Indicators: Intergalactic.Component<'div', CarouselIndicatorsProps, CarouselState>;
116
123
  Indicator: Intergalactic.Component<'div', CarouselIndicatorProps>;
117
124
  Item: Intergalactic.Component<'div', CarouselItemProps>;
@@ -108,7 +108,6 @@ SNext {
108
108
  margin-left: calc(2 * var(--intergalactic-spacing-1x, 4px) - 1px);
109
109
  margin-right: calc(2 * var(--intergalactic-spacing-1x, 4px) - 1px);
110
110
  }
111
-
112
111
  }
113
112
 
114
113
  SPrevButton, SNextButton {