@semcore/carousel 16.1.1 → 16.1.2-prerelease.3
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/CHANGELOG.md +6 -0
- package/README.md +1 -31
- package/lib/cjs/Carousel.js +122 -121
- package/lib/cjs/Carousel.js.map +1 -1
- package/lib/cjs/Carousel.types.js.map +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +4 -5
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/Carousel.js +120 -118
- package/lib/es6/Carousel.js.map +1 -1
- package/lib/es6/Carousel.types.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/Carousel.mjs +117 -113
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
- package/lib/types/Carousel.d.ts +1 -1
- package/lib/types/Carousel.types.d.ts +2 -2
- package/package.json +9 -9
- package/src/Carousel.tsx +107 -94
- package/src/Carousel.types.ts +2 -2
- package/src/translations/__intergalactic-dynamic-locales.ts +2 -2
package/src/Carousel.tsx
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
1
|
+
import { createBreakpoints } from '@semcore/breakpoints';
|
|
3
2
|
import Button from '@semcore/button';
|
|
4
|
-
import
|
|
5
|
-
import { Box, Flex } from '@semcore/flex-box';
|
|
6
|
-
import ChevronRight from '@semcore/icon/ChevronRight/l';
|
|
7
|
-
import ChevronLeft from '@semcore/icon/ChevronLeft/l';
|
|
8
|
-
import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
|
|
3
|
+
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
9
4
|
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
10
|
-
import {
|
|
5
|
+
import { findAllComponents } from '@semcore/core/lib/utils/findComponent';
|
|
11
6
|
import logger from '@semcore/core/lib/utils/logger';
|
|
12
|
-
import
|
|
13
|
-
import
|
|
7
|
+
import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
|
|
8
|
+
import { Box, Flex } from '@semcore/flex-box';
|
|
9
|
+
import type { BoxProps } from '@semcore/flex-box';
|
|
10
|
+
import ChevronLeft from '@semcore/icon/ChevronLeft/l';
|
|
11
|
+
import ChevronRight from '@semcore/icon/ChevronRight/l';
|
|
12
|
+
import Modal from '@semcore/modal';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
|
|
15
|
+
import type CarouselType from './Carousel.types';
|
|
16
|
+
import type {
|
|
14
17
|
CarouselProps,
|
|
15
18
|
CarouselState,
|
|
16
19
|
CarouselContext,
|
|
@@ -20,9 +23,8 @@ import CarouselType, {
|
|
|
20
23
|
CarouselIndicatorsProps,
|
|
21
24
|
CarouselIndicatorProps,
|
|
22
25
|
} from './Carousel.types';
|
|
23
|
-
import
|
|
24
|
-
import {
|
|
25
|
-
import { createBreakpoints } from '@semcore/breakpoints';
|
|
26
|
+
import style from './style/carousel.shadow.css';
|
|
27
|
+
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
26
28
|
|
|
27
29
|
const MAP_TRANSFORM: Record<string, 'left' | 'right'> = {
|
|
28
30
|
ArrowLeft: 'left',
|
|
@@ -38,7 +40,7 @@ class CarouselRoot extends Component<
|
|
|
38
40
|
CarouselProps,
|
|
39
41
|
CarouselContext,
|
|
40
42
|
CarouselState,
|
|
41
|
-
|
|
43
|
+
typeof enhance
|
|
42
44
|
> {
|
|
43
45
|
static displayName = 'Carousel';
|
|
44
46
|
static defaultProps = {
|
|
@@ -325,7 +327,7 @@ class CarouselRoot extends Component<
|
|
|
325
327
|
};
|
|
326
328
|
}
|
|
327
329
|
|
|
328
|
-
getItemProps(
|
|
330
|
+
getItemProps(_props: CarouselItemProps, index: number) {
|
|
329
331
|
const { zoom } = this.asProps;
|
|
330
332
|
const isCurrent = this.isSelected(index);
|
|
331
333
|
|
|
@@ -371,10 +373,10 @@ class CarouselRoot extends Component<
|
|
|
371
373
|
disabled = selectedIndex === 0;
|
|
372
374
|
}
|
|
373
375
|
return {
|
|
374
|
-
onClick: this.bindHandlerClick('left'),
|
|
375
|
-
onKeyDown: this.bindHandlerKeydownControl('left'),
|
|
376
|
+
'onClick': this.bindHandlerClick('left'),
|
|
377
|
+
'onKeyDown': this.bindHandlerKeydownControl('left'),
|
|
376
378
|
disabled,
|
|
377
|
-
label: getI18nText('prev'),
|
|
379
|
+
'label': getI18nText('prev'),
|
|
378
380
|
'aria-controls': `igc-${uid}-carousel`,
|
|
379
381
|
};
|
|
380
382
|
}
|
|
@@ -388,10 +390,10 @@ class CarouselRoot extends Component<
|
|
|
388
390
|
}
|
|
389
391
|
|
|
390
392
|
return {
|
|
391
|
-
onClick: this.bindHandlerClick('right'),
|
|
392
|
-
onKeyDown: this.bindHandlerKeydownControl('right'),
|
|
393
|
+
'onClick': this.bindHandlerClick('right'),
|
|
394
|
+
'onKeyDown': this.bindHandlerKeydownControl('right'),
|
|
393
395
|
disabled,
|
|
394
|
-
label: getI18nText('next'),
|
|
396
|
+
'label': getI18nText('next'),
|
|
395
397
|
'aria-controls': `igc-${uid}-carousel`,
|
|
396
398
|
};
|
|
397
399
|
}
|
|
@@ -401,13 +403,13 @@ class CarouselRoot extends Component<
|
|
|
401
403
|
const { getI18nText } = this.asProps;
|
|
402
404
|
|
|
403
405
|
return {
|
|
404
|
-
items: items.map((
|
|
406
|
+
'items': items.map((_item, key) => ({
|
|
405
407
|
active: this.isSelected(key),
|
|
406
408
|
onClick: this.bindHandlerClickIndicator(key),
|
|
407
409
|
key,
|
|
408
410
|
})),
|
|
409
|
-
role: 'tablist',
|
|
410
|
-
tabIndex: 0,
|
|
411
|
+
'role': 'tablist',
|
|
412
|
+
'tabIndex': 0,
|
|
411
413
|
'aria-label': getI18nText('slides'),
|
|
412
414
|
};
|
|
413
415
|
}
|
|
@@ -417,7 +419,7 @@ class CarouselRoot extends Component<
|
|
|
417
419
|
const { getI18nText } = this.asProps;
|
|
418
420
|
|
|
419
421
|
return {
|
|
420
|
-
role: 'tab',
|
|
422
|
+
'role': 'tab',
|
|
421
423
|
'aria-selected': isCurrent,
|
|
422
424
|
'aria-controls': `igc-${this.asProps.uid}-carousel-item-${index}`,
|
|
423
425
|
'aria-label': getI18nText('slide', { slideNumber: index + 1 }),
|
|
@@ -430,9 +432,9 @@ class CarouselRoot extends Component<
|
|
|
430
432
|
const direction = selectedIndex > 0 ? 1 : -1;
|
|
431
433
|
const count = items.length === 0 ? 0 : Math.floor(selectedIndex / items.length) * direction;
|
|
432
434
|
const transform =
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
435
|
+
selectedIndex > 0 && selectedIndex < items.length
|
|
436
|
+
? 0
|
|
437
|
+
: 100 * direction * count * items.length;
|
|
436
438
|
|
|
437
439
|
return transform;
|
|
438
440
|
}
|
|
@@ -502,14 +504,16 @@ class CarouselRoot extends Component<
|
|
|
502
504
|
})}
|
|
503
505
|
</SModalContainer>
|
|
504
506
|
</SModalBox>
|
|
505
|
-
{isSmall
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
507
|
+
{isSmall
|
|
508
|
+
? (
|
|
509
|
+
<Flex justifyContent='center' mt={2}>
|
|
510
|
+
<Carousel.Prev inverted={true} />
|
|
511
|
+
<Carousel.Next inverted={true} />
|
|
512
|
+
</Flex>
|
|
513
|
+
)
|
|
514
|
+
: (
|
|
515
|
+
<Carousel.Next inverted={true} />
|
|
516
|
+
)}
|
|
513
517
|
</Flex>
|
|
514
518
|
{!isSmall && <Carousel.Indicators inverted={true} />}
|
|
515
519
|
</Modal>,
|
|
@@ -546,39 +550,40 @@ class CarouselRoot extends Component<
|
|
|
546
550
|
id={`igc-${uid}-carousel`}
|
|
547
551
|
aria-roledescription={ariaRoledescription}
|
|
548
552
|
>
|
|
549
|
-
{Controls.length === 0
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
553
|
+
{Controls.length === 0
|
|
554
|
+
? (
|
|
555
|
+
<>
|
|
556
|
+
<Flex>
|
|
557
|
+
<Carousel.Prev />
|
|
558
|
+
<Carousel.ContentBox>
|
|
559
|
+
<Carousel.Container aria-label={ariaLabel}>
|
|
560
|
+
<Children />
|
|
561
|
+
</Carousel.Container>
|
|
562
|
+
</Carousel.ContentBox>
|
|
563
|
+
<Carousel.Next />
|
|
564
|
+
</Flex>
|
|
565
|
+
{indicators === 'default' && <Carousel.Indicators />}
|
|
566
|
+
{indicators === 'preview' && (
|
|
567
|
+
<Carousel.Indicators>
|
|
568
|
+
{() =>
|
|
569
|
+
ComponentItems.map((item, index) => (
|
|
570
|
+
<Carousel.Indicator
|
|
571
|
+
{...item.props}
|
|
572
|
+
key={item.key}
|
|
573
|
+
w={100}
|
|
574
|
+
h={100}
|
|
575
|
+
aria-roledescription='slide'
|
|
576
|
+
active={this.isSelected(index)}
|
|
577
|
+
onClick={this.bindHandlerClickIndicator(index)}
|
|
578
|
+
/>
|
|
579
|
+
))}
|
|
580
|
+
</Carousel.Indicators>
|
|
581
|
+
)}
|
|
582
|
+
</>
|
|
583
|
+
)
|
|
584
|
+
: (
|
|
585
|
+
<Children />
|
|
577
586
|
)}
|
|
578
|
-
</>
|
|
579
|
-
) : (
|
|
580
|
-
<Children />
|
|
581
|
-
)}
|
|
582
587
|
{hasZoom && (
|
|
583
588
|
<BreakPoints>
|
|
584
589
|
<BreakPoints.Context.Consumer>
|
|
@@ -614,7 +619,9 @@ class Item extends Component<CarouselItemProps> {
|
|
|
614
619
|
const { toggleItem, transform } = this.props;
|
|
615
620
|
const refItem = this.refItem.current;
|
|
616
621
|
|
|
617
|
-
toggleItem && refItem
|
|
622
|
+
if (toggleItem && refItem) {
|
|
623
|
+
toggleItem({ node: refItem });
|
|
624
|
+
}
|
|
618
625
|
|
|
619
626
|
if (transform && refItem) {
|
|
620
627
|
refItem.style.transform = `translateX(${transform}%)`;
|
|
@@ -625,7 +632,9 @@ class Item extends Component<CarouselItemProps> {
|
|
|
625
632
|
const { toggleItem } = this.props;
|
|
626
633
|
const refItem = this.refItem.current;
|
|
627
634
|
|
|
628
|
-
toggleItem && refItem
|
|
635
|
+
if (toggleItem && refItem) {
|
|
636
|
+
toggleItem({ node: refItem }, true);
|
|
637
|
+
}
|
|
629
638
|
}
|
|
630
639
|
|
|
631
640
|
componentDidUpdate(prevProps: CarouselItemProps) {
|
|
@@ -664,18 +673,20 @@ const Prev = (props: CarouselButtonProps) => {
|
|
|
664
673
|
|
|
665
674
|
return sstyled(styles)(
|
|
666
675
|
<SPrev render={Box} top={top}>
|
|
667
|
-
{children
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
676
|
+
{children
|
|
677
|
+
? (
|
|
678
|
+
<Children />
|
|
679
|
+
)
|
|
680
|
+
: (
|
|
681
|
+
<SPrevButton
|
|
682
|
+
addonLeft={ChevronLeft}
|
|
683
|
+
aria-label={label}
|
|
684
|
+
theme={inverted ? 'invert' : 'muted'}
|
|
685
|
+
use='tertiary'
|
|
686
|
+
size='l'
|
|
687
|
+
innerOutline
|
|
688
|
+
/>
|
|
689
|
+
)}
|
|
679
690
|
</SPrev>,
|
|
680
691
|
);
|
|
681
692
|
};
|
|
@@ -687,18 +698,20 @@ const Next = (props: CarouselButtonProps) => {
|
|
|
687
698
|
|
|
688
699
|
return sstyled(styles)(
|
|
689
700
|
<SNext render={Box} top={top}>
|
|
690
|
-
{children
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
701
|
+
{children
|
|
702
|
+
? (
|
|
703
|
+
<Children />
|
|
704
|
+
)
|
|
705
|
+
: (
|
|
706
|
+
<SNextButton
|
|
707
|
+
addonLeft={ChevronRight}
|
|
708
|
+
aria-label={label}
|
|
709
|
+
theme={inverted ? 'invert' : 'muted'}
|
|
710
|
+
use='tertiary'
|
|
711
|
+
size='l'
|
|
712
|
+
innerOutline
|
|
713
|
+
/>
|
|
714
|
+
)}
|
|
702
715
|
</SNext>,
|
|
703
716
|
);
|
|
704
717
|
};
|
package/src/Carousel.types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PropGetterFn, UnknownProperties, Intergalactic, IRootComponentProps } from '@semcore/core';
|
|
2
|
-
import { BoxProps } from '@semcore/flex-box';
|
|
1
|
+
import type { PropGetterFn, UnknownProperties, Intergalactic, IRootComponentProps } from '@semcore/core';
|
|
2
|
+
import type { BoxProps } from '@semcore/flex-box';
|
|
3
3
|
|
|
4
4
|
/** @deprecated */
|
|
5
5
|
export interface ICarouselProps extends CarouselProps, UnknownProperties {}
|
|
@@ -6,12 +6,12 @@ import it from './it.json';
|
|
|
6
6
|
import ja from './ja.json';
|
|
7
7
|
import ko from './ko.json';
|
|
8
8
|
import nl from './nl.json';
|
|
9
|
+
import pl from './pl.json';
|
|
9
10
|
import pt from './pt.json';
|
|
11
|
+
import sv from './sv.json';
|
|
10
12
|
import tr from './tr.json';
|
|
11
13
|
import vi from './vi.json';
|
|
12
14
|
import zh from './zh.json';
|
|
13
|
-
import pl from './pl.json';
|
|
14
|
-
import sv from './sv.json';
|
|
15
15
|
|
|
16
16
|
export const localizedMessages = {
|
|
17
17
|
de,
|