@via-profit/ui-kit 0.6.0 → 0.7.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.
- package/CHANGELOG.md +17 -0
- package/Swiper/Swiper.d.ts +68 -0
- package/Swiper/Swiper.js +268 -135
- package/Swiper/SwiperSlide.js +3 -0
- package/Swiper/SwiperSlidesRenderer.d.ts +4 -0
- package/Swiper/SwiperSlidesRenderer.js +2 -1
- package/Swiper/SwiperTrack.d.ts +20 -0
- package/Swiper/SwiperTrack.js +28 -5
- package/Swiper/SwiperWrapper.d.ts +3 -0
- package/Swiper/SwiperWrapper.js +5 -4
- package/esm/Swiper/Swiper.js +268 -135
- package/esm/Swiper/SwiperSlide.js +3 -0
- package/esm/Swiper/SwiperSlidesRenderer.js +2 -1
- package/esm/Swiper/SwiperTrack.js +28 -5
- package/esm/Swiper/SwiperWrapper.js +5 -4
- package/package.json +1 -1
package/Swiper/SwiperSlide.js
CHANGED
|
@@ -54,6 +54,9 @@ const StyledSlide = styled_1.default.div `
|
|
|
54
54
|
flex-grow: 0;
|
|
55
55
|
flex-shrink: 0;
|
|
56
56
|
flex-basis: calc(100% / ${({ $slidesPerView }) => $slidesPerView});
|
|
57
|
+
/* The size of the slide is set by slidesPerView, not by its content: the track positions rely on it */
|
|
58
|
+
min-width: 0;
|
|
59
|
+
min-height: 0;
|
|
57
60
|
height: 100%;
|
|
58
61
|
display: flex;
|
|
59
62
|
align-items: center;
|
|
@@ -14,6 +14,10 @@ export type SwiperSlidesRendererProps = {
|
|
|
14
14
|
readonly realSlidesCount: number;
|
|
15
15
|
readonly getSlideRealIndex: (index: number) => number;
|
|
16
16
|
readonly slideLabel: (index: number, total: number) => string;
|
|
17
|
+
/**
|
|
18
|
+
* The index of the slide in the DOM shown by the fade effect, `null` for the slide effect
|
|
19
|
+
*/
|
|
20
|
+
readonly activeDomIndex?: number | null;
|
|
17
21
|
};
|
|
18
22
|
declare const _default: React.NamedExoticComponent<SwiperSlidesRendererProps>;
|
|
19
23
|
export default _default;
|
|
@@ -37,7 +37,7 @@ const React = __importStar(require("react"));
|
|
|
37
37
|
// React 19 supports the boolean `inert`, React 18 passes only the string value to the DOM
|
|
38
38
|
const INERT_VALUE = parseInt(React.version, 10) >= 19 ? true : '';
|
|
39
39
|
const SwiperSlidesRenderer = props => {
|
|
40
|
-
const { slides, slidesPerView, realIndex, realSlidesCount, getSlideRealIndex, slideLabel, firstVisibleIndex = realIndex, visibleCount = slidesPerView, } = props;
|
|
40
|
+
const { slides, slidesPerView, realIndex, realSlidesCount, getSlideRealIndex, slideLabel, firstVisibleIndex = realIndex, visibleCount = Math.ceil(slidesPerView), activeDomIndex = null, } = props;
|
|
41
41
|
const visibilityMap = React.useMemo(() => {
|
|
42
42
|
const map = new Map();
|
|
43
43
|
if (realSlidesCount <= visibleCount) {
|
|
@@ -80,6 +80,7 @@ const SwiperSlidesRenderer = props => {
|
|
|
80
80
|
'aria-hidden': isClone || !isVisible ? true : undefined,
|
|
81
81
|
inert: isVisible && !isClone ? undefined : INERT_VALUE,
|
|
82
82
|
'data-index': i,
|
|
83
|
+
'data-active': activeDomIndex === null ? undefined : activeDomIndex === i,
|
|
83
84
|
'data-real-index': slideRealIndex,
|
|
84
85
|
});
|
|
85
86
|
})));
|
package/Swiper/SwiperTrack.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export type SwiperTrackProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
3
3
|
readonly children: React.ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* The position of the track in slides. It is fractional with a fractional `slidesPerView`
|
|
6
|
+
* and with the centered slides
|
|
7
|
+
*/
|
|
4
8
|
readonly index: number;
|
|
5
9
|
readonly offset: number;
|
|
6
10
|
readonly dragging: boolean;
|
|
@@ -10,9 +14,19 @@ export type SwiperTrackProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
10
14
|
*/
|
|
11
15
|
readonly momentum?: boolean;
|
|
12
16
|
readonly slidesPerView: number;
|
|
17
|
+
readonly vertical?: boolean;
|
|
18
|
+
readonly effect?: 'slide' | 'fade';
|
|
19
|
+
/**
|
|
20
|
+
* The duration of the slide change in milliseconds
|
|
21
|
+
*/
|
|
22
|
+
readonly speed?: number;
|
|
13
23
|
};
|
|
14
24
|
export declare const SwiperTrack: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
15
25
|
readonly children: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* The position of the track in slides. It is fractional with a fractional `slidesPerView`
|
|
28
|
+
* and with the centered slides
|
|
29
|
+
*/
|
|
16
30
|
readonly index: number;
|
|
17
31
|
readonly offset: number;
|
|
18
32
|
readonly dragging: boolean;
|
|
@@ -22,5 +36,11 @@ export declare const SwiperTrack: React.ForwardRefExoticComponent<React.HTMLAttr
|
|
|
22
36
|
*/
|
|
23
37
|
readonly momentum?: boolean;
|
|
24
38
|
readonly slidesPerView: number;
|
|
39
|
+
readonly vertical?: boolean;
|
|
40
|
+
readonly effect?: "slide" | "fade";
|
|
41
|
+
/**
|
|
42
|
+
* The duration of the slide change in milliseconds
|
|
43
|
+
*/
|
|
44
|
+
readonly speed?: number;
|
|
25
45
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
26
46
|
export default SwiperTrack;
|
package/Swiper/SwiperTrack.js
CHANGED
|
@@ -50,21 +50,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.SwiperTrack = void 0;
|
|
51
51
|
const React = __importStar(require("react"));
|
|
52
52
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
53
|
+
const react_1 = require("@emotion/react");
|
|
53
54
|
const StyledTrack = styled_1.default.div `
|
|
54
55
|
display: flex;
|
|
56
|
+
flex-direction: ${({ $vertical }) => ($vertical ? 'column' : 'row')};
|
|
55
57
|
height: 100%;
|
|
56
|
-
transition: ${({ $dragging, $disableAnimation, $momentum }) => {
|
|
58
|
+
transition: ${({ $dragging, $disableAnimation, $momentum, $speed }) => {
|
|
57
59
|
if ($dragging || $disableAnimation) {
|
|
58
60
|
return 'none';
|
|
59
61
|
}
|
|
60
|
-
return $momentum
|
|
62
|
+
return $momentum
|
|
63
|
+
? 'transform 0.6s cubic-bezier(0.25, 1, 0.5, 1)'
|
|
64
|
+
: `transform ${$speed}ms ease`;
|
|
61
65
|
}};
|
|
62
66
|
will-change: transform;
|
|
63
|
-
transform: ${({ $index, $offset, $slidesPerView }) =>
|
|
67
|
+
transform: ${({ $index, $offset, $slidesPerView, $vertical }) => `${$vertical ? 'translateY' : 'translateX'}(calc(${-(($index * 100) / $slidesPerView)}% + ${$offset}px))`};
|
|
68
|
+
|
|
69
|
+
${({ $fade, $speed }) => $fade &&
|
|
70
|
+
(0, react_1.css) `
|
|
71
|
+
/* The slides lie on top of each other, the current one is opaque */
|
|
72
|
+
display: grid;
|
|
73
|
+
transform: none;
|
|
74
|
+
will-change: auto;
|
|
75
|
+
|
|
76
|
+
& > * {
|
|
77
|
+
grid-area: 1 / 1;
|
|
78
|
+
opacity: 0;
|
|
79
|
+
transition: opacity ${$speed}ms ease;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
& > [data-active='true'] {
|
|
83
|
+
opacity: 1;
|
|
84
|
+
z-index: 1;
|
|
85
|
+
}
|
|
86
|
+
`}
|
|
64
87
|
`;
|
|
65
88
|
exports.SwiperTrack = React.forwardRef((props, ref) => {
|
|
66
|
-
const { children, index, offset, dragging, disableAnimation, momentum, slidesPerView } = props, restProps = __rest(props, ["children", "index", "offset", "dragging", "disableAnimation", "momentum", "slidesPerView"]);
|
|
67
|
-
return (React.createElement(StyledTrack, Object.assign({ "$dragging": dragging, "$index": index, "$offset": offset, "$disableAnimation": disableAnimation, "$momentum": momentum, "$slidesPerView": slidesPerView }, restProps, { ref: ref }), children));
|
|
89
|
+
const { children, index, offset, dragging, disableAnimation, momentum, slidesPerView, vertical = false, effect = 'slide', speed = 300 } = props, restProps = __rest(props, ["children", "index", "offset", "dragging", "disableAnimation", "momentum", "slidesPerView", "vertical", "effect", "speed"]);
|
|
90
|
+
return (React.createElement(StyledTrack, Object.assign({ "$dragging": dragging, "$index": index, "$offset": offset, "$disableAnimation": disableAnimation, "$momentum": momentum, "$slidesPerView": slidesPerView, "$vertical": vertical, "$fade": effect === 'fade', "$speed": speed }, restProps, { ref: ref }), children));
|
|
68
91
|
});
|
|
69
92
|
exports.SwiperTrack.displayName = 'SwiperTrack';
|
|
70
93
|
exports.default = exports.SwiperTrack;
|
|
@@ -2,15 +2,18 @@ import * as React from 'react';
|
|
|
2
2
|
export type SwiperWrapperProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
3
3
|
readonly draggable: boolean;
|
|
4
4
|
readonly slidesPerView: number;
|
|
5
|
+
readonly vertical?: boolean;
|
|
5
6
|
};
|
|
6
7
|
export declare const StyledWrapper: import("@emotion/styled").StyledComponent<{
|
|
7
8
|
theme?: import("@emotion/react").Theme;
|
|
8
9
|
as?: React.ElementType;
|
|
9
10
|
} & {
|
|
10
11
|
$draggable: boolean;
|
|
12
|
+
$vertical: boolean;
|
|
11
13
|
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
12
14
|
declare const SwiperWrapper: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
13
15
|
readonly draggable: boolean;
|
|
14
16
|
readonly slidesPerView: number;
|
|
17
|
+
readonly vertical?: boolean;
|
|
15
18
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
16
19
|
export default SwiperWrapper;
|
package/Swiper/SwiperWrapper.js
CHANGED
|
@@ -58,9 +58,10 @@ exports.StyledWrapper = styled_1.default.div `
|
|
|
58
58
|
overflow: hidden;
|
|
59
59
|
user-select: none;
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
/* The page still scrolls across the swiper on the touch screens */
|
|
62
|
+
${({ $draggable, $vertical }) => $draggable &&
|
|
62
63
|
(0, react_1.css) `
|
|
63
|
-
touch-action: pan-y;
|
|
64
|
+
touch-action: ${$vertical ? 'pan-x' : 'pan-y'};
|
|
64
65
|
`};
|
|
65
66
|
|
|
66
67
|
/* Inside: the container clips the outer outline */
|
|
@@ -73,8 +74,8 @@ exports.StyledWrapper = styled_1.default.div `
|
|
|
73
74
|
const SwiperWrapper = React.forwardRef((props, ref) => {
|
|
74
75
|
// slidesPerView is for the overrides only, it is not a DOM attribute
|
|
75
76
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
76
|
-
const { children, draggable, slidesPerView } = props, restProps = __rest(props, ["children", "draggable", "slidesPerView"]);
|
|
77
|
-
return (React.createElement(exports.StyledWrapper, Object.assign({}, restProps, { ref: ref, "$draggable": draggable }), children));
|
|
77
|
+
const { children, draggable, slidesPerView, vertical = false } = props, restProps = __rest(props, ["children", "draggable", "slidesPerView", "vertical"]);
|
|
78
|
+
return (React.createElement(exports.StyledWrapper, Object.assign({}, restProps, { ref: ref, "$draggable": draggable, "$vertical": vertical }), children));
|
|
78
79
|
});
|
|
79
80
|
SwiperWrapper.displayName = 'SwiperWrapper';
|
|
80
81
|
exports.default = SwiperWrapper;
|