@via-profit/ui-kit 0.6.0 → 0.8.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 +25 -0
- package/Modal/Drawer/DrawerInner.d.ts +6 -0
- package/Modal/Drawer/DrawerInner.js +91 -2
- package/Modal/Drawer/index.d.ts +8 -0
- package/Modal/Drawer/index.js +3 -3
- package/Modal/Drawer/useSwipeToClose.d.ts +30 -0
- package/Modal/Drawer/useSwipeToClose.js +238 -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/Modal/Drawer/DrawerInner.js +91 -2
- package/esm/Modal/Drawer/index.js +3 -3
- package/esm/Modal/Drawer/useSwipeToClose.js +233 -0
- 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 +6 -1
|
@@ -15,6 +15,9 @@ const StyledSlide = styled.div `
|
|
|
15
15
|
flex-grow: 0;
|
|
16
16
|
flex-shrink: 0;
|
|
17
17
|
flex-basis: calc(100% / ${({ $slidesPerView }) => $slidesPerView});
|
|
18
|
+
/* The size of the slide is set by slidesPerView, not by its content: the track positions rely on it */
|
|
19
|
+
min-width: 0;
|
|
20
|
+
min-height: 0;
|
|
18
21
|
height: 100%;
|
|
19
22
|
display: flex;
|
|
20
23
|
align-items: center;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
// React 19 supports the boolean `inert`, React 18 passes only the string value to the DOM
|
|
3
3
|
const INERT_VALUE = parseInt(React.version, 10) >= 19 ? true : '';
|
|
4
4
|
const SwiperSlidesRenderer = props => {
|
|
5
|
-
const { slides, slidesPerView, realIndex, realSlidesCount, getSlideRealIndex, slideLabel, firstVisibleIndex = realIndex, visibleCount = slidesPerView, } = props;
|
|
5
|
+
const { slides, slidesPerView, realIndex, realSlidesCount, getSlideRealIndex, slideLabel, firstVisibleIndex = realIndex, visibleCount = Math.ceil(slidesPerView), activeDomIndex = null, } = props;
|
|
6
6
|
const visibilityMap = React.useMemo(() => {
|
|
7
7
|
const map = new Map();
|
|
8
8
|
if (realSlidesCount <= visibleCount) {
|
|
@@ -45,6 +45,7 @@ const SwiperSlidesRenderer = props => {
|
|
|
45
45
|
'aria-hidden': isClone || !isVisible ? true : undefined,
|
|
46
46
|
inert: isVisible && !isClone ? undefined : INERT_VALUE,
|
|
47
47
|
'data-index': i,
|
|
48
|
+
'data-active': activeDomIndex === null ? undefined : activeDomIndex === i,
|
|
48
49
|
'data-real-index': slideRealIndex,
|
|
49
50
|
});
|
|
50
51
|
})));
|
|
@@ -11,21 +11,44 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import * as React from 'react';
|
|
13
13
|
import styled from '@emotion/styled';
|
|
14
|
+
import { css } from '@emotion/react';
|
|
14
15
|
const StyledTrack = styled.div `
|
|
15
16
|
display: flex;
|
|
17
|
+
flex-direction: ${({ $vertical }) => ($vertical ? 'column' : 'row')};
|
|
16
18
|
height: 100%;
|
|
17
|
-
transition: ${({ $dragging, $disableAnimation, $momentum }) => {
|
|
19
|
+
transition: ${({ $dragging, $disableAnimation, $momentum, $speed }) => {
|
|
18
20
|
if ($dragging || $disableAnimation) {
|
|
19
21
|
return 'none';
|
|
20
22
|
}
|
|
21
|
-
return $momentum
|
|
23
|
+
return $momentum
|
|
24
|
+
? 'transform 0.6s cubic-bezier(0.25, 1, 0.5, 1)'
|
|
25
|
+
: `transform ${$speed}ms ease`;
|
|
22
26
|
}};
|
|
23
27
|
will-change: transform;
|
|
24
|
-
transform: ${({ $index, $offset, $slidesPerView }) =>
|
|
28
|
+
transform: ${({ $index, $offset, $slidesPerView, $vertical }) => `${$vertical ? 'translateY' : 'translateX'}(calc(${-(($index * 100) / $slidesPerView)}% + ${$offset}px))`};
|
|
29
|
+
|
|
30
|
+
${({ $fade, $speed }) => $fade &&
|
|
31
|
+
css `
|
|
32
|
+
/* The slides lie on top of each other, the current one is opaque */
|
|
33
|
+
display: grid;
|
|
34
|
+
transform: none;
|
|
35
|
+
will-change: auto;
|
|
36
|
+
|
|
37
|
+
& > * {
|
|
38
|
+
grid-area: 1 / 1;
|
|
39
|
+
opacity: 0;
|
|
40
|
+
transition: opacity ${$speed}ms ease;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
& > [data-active='true'] {
|
|
44
|
+
opacity: 1;
|
|
45
|
+
z-index: 1;
|
|
46
|
+
}
|
|
47
|
+
`}
|
|
25
48
|
`;
|
|
26
49
|
export const SwiperTrack = React.forwardRef((props, ref) => {
|
|
27
|
-
const { children, index, offset, dragging, disableAnimation, momentum, slidesPerView } = props, restProps = __rest(props, ["children", "index", "offset", "dragging", "disableAnimation", "momentum", "slidesPerView"]);
|
|
28
|
-
return (React.createElement(StyledTrack, Object.assign({ "$dragging": dragging, "$index": index, "$offset": offset, "$disableAnimation": disableAnimation, "$momentum": momentum, "$slidesPerView": slidesPerView }, restProps, { ref: ref }), children));
|
|
50
|
+
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"]);
|
|
51
|
+
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));
|
|
29
52
|
});
|
|
30
53
|
SwiperTrack.displayName = 'SwiperTrack';
|
|
31
54
|
export default SwiperTrack;
|
|
@@ -19,9 +19,10 @@ export const StyledWrapper = styled.div `
|
|
|
19
19
|
overflow: hidden;
|
|
20
20
|
user-select: none;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
/* The page still scrolls across the swiper on the touch screens */
|
|
23
|
+
${({ $draggable, $vertical }) => $draggable &&
|
|
23
24
|
css `
|
|
24
|
-
touch-action: pan-y;
|
|
25
|
+
touch-action: ${$vertical ? 'pan-x' : 'pan-y'};
|
|
25
26
|
`};
|
|
26
27
|
|
|
27
28
|
/* Inside: the container clips the outer outline */
|
|
@@ -34,8 +35,8 @@ export const StyledWrapper = styled.div `
|
|
|
34
35
|
const SwiperWrapper = React.forwardRef((props, ref) => {
|
|
35
36
|
// slidesPerView is for the overrides only, it is not a DOM attribute
|
|
36
37
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
-
const { children, draggable, slidesPerView } = props, restProps = __rest(props, ["children", "draggable", "slidesPerView"]);
|
|
38
|
-
return (React.createElement(StyledWrapper, Object.assign({}, restProps, { ref: ref, "$draggable": draggable }), children));
|
|
38
|
+
const { children, draggable, slidesPerView, vertical = false } = props, restProps = __rest(props, ["children", "draggable", "slidesPerView", "vertical"]);
|
|
39
|
+
return (React.createElement(StyledWrapper, Object.assign({}, restProps, { ref: ref, "$draggable": draggable, "$vertical": vertical }), children));
|
|
39
40
|
});
|
|
40
41
|
SwiperWrapper.displayName = 'SwiperWrapper';
|
|
41
42
|
export default SwiperWrapper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@via-profit/ui-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "UI Kit",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -770,6 +770,11 @@
|
|
|
770
770
|
"import": "./esm/Modal/Drawer/index.js",
|
|
771
771
|
"require": "./Modal/Drawer/index.js"
|
|
772
772
|
},
|
|
773
|
+
"./Modal/Drawer/useSwipeToClose": {
|
|
774
|
+
"types": "./Modal/Drawer/useSwipeToClose.d.ts",
|
|
775
|
+
"import": "./esm/Modal/Drawer/useSwipeToClose.js",
|
|
776
|
+
"require": "./Modal/Drawer/useSwipeToClose.js"
|
|
777
|
+
},
|
|
773
778
|
"./Modal/MessageBox/MessageBoxContainer": {
|
|
774
779
|
"types": "./Modal/MessageBox/MessageBoxContainer.d.ts",
|
|
775
780
|
"import": "./esm/Modal/MessageBox/MessageBoxContainer.js",
|