@elliemae/ds-swipe-card 3.53.0-alpha.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.
- package/dist/cjs/DSSwipeCard.js +99 -0
- package/dist/cjs/DSSwipeCard.js.map +7 -0
- package/dist/cjs/config/slidePositionHelpers.js +44 -0
- package/dist/cjs/config/slidePositionHelpers.js.map +7 -0
- package/dist/cjs/config/touchHandlers.js +77 -0
- package/dist/cjs/config/touchHandlers.js.map +7 -0
- package/dist/cjs/config/useSwipeCard.js +91 -0
- package/dist/cjs/config/useSwipeCard.js.map +7 -0
- package/dist/cjs/config/useValidateProps.js +40 -0
- package/dist/cjs/config/useValidateProps.js.map +7 -0
- package/dist/cjs/constants/index.js +45 -0
- package/dist/cjs/constants/index.js.map +7 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/react-desc-prop-types.js +69 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/styled.js +108 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/esm/DSSwipeCard.js +69 -0
- package/dist/esm/DSSwipeCard.js.map +7 -0
- package/dist/esm/config/slidePositionHelpers.js +14 -0
- package/dist/esm/config/slidePositionHelpers.js.map +7 -0
- package/dist/esm/config/touchHandlers.js +47 -0
- package/dist/esm/config/touchHandlers.js.map +7 -0
- package/dist/esm/config/useSwipeCard.js +61 -0
- package/dist/esm/config/useSwipeCard.js.map +7 -0
- package/dist/esm/config/useValidateProps.js +10 -0
- package/dist/esm/config/useValidateProps.js.map +7 -0
- package/dist/esm/constants/index.js +15 -0
- package/dist/esm/constants/index.js.map +7 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +7 -0
- package/dist/esm/react-desc-prop-types.js +44 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/styled.js +78 -0
- package/dist/esm/styled.js.map +7 -0
- package/dist/types/DSSwipeCard.d.ts +7 -0
- package/dist/types/config/slidePositionHelpers.d.ts +8 -0
- package/dist/types/config/touchHandlers.d.ts +23 -0
- package/dist/types/config/useSwipeCard.d.ts +22 -0
- package/dist/types/config/useValidateProps.d.ts +3 -0
- package/dist/types/constants/index.d.ts +11 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/react-desc-prop-types.d.ts +31 -0
- package/dist/types/styled.d.ts +28 -0
- package/package.json +73 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var styled_exports = {};
|
|
30
|
+
__export(styled_exports, {
|
|
31
|
+
StyledScrollContainer: () => StyledScrollContainer,
|
|
32
|
+
StyledSlide: () => StyledSlide,
|
|
33
|
+
StyledWrapper: () => StyledWrapper
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(styled_exports);
|
|
36
|
+
var React = __toESM(require("react"));
|
|
37
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
38
|
+
var import_ds_grid = require("@elliemae/ds-grid");
|
|
39
|
+
var import_constants = require("./constants/index.js");
|
|
40
|
+
const StyledWrapper = (0, import_ds_system.styled)(import_ds_grid.Grid, {
|
|
41
|
+
name: import_constants.DSSwipeCardName,
|
|
42
|
+
slot: import_constants.SWIPE_CARD_SLOTS.ROOT
|
|
43
|
+
})`
|
|
44
|
+
position: relative;
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: 100%;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
min-height: 0;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
`;
|
|
51
|
+
const StyledScrollContainer = (0, import_ds_system.styled)("div", {
|
|
52
|
+
name: import_constants.DSSwipeCardName,
|
|
53
|
+
slot: import_constants.SWIPE_CARD_SLOTS.SCROLL_CONTAINER
|
|
54
|
+
})`
|
|
55
|
+
position: relative;
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 100%;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
min-height: 0;
|
|
60
|
+
min-width: 0;
|
|
61
|
+
|
|
62
|
+
${({ $disabled = false }) => $disabled && `
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
touch-action: none;
|
|
65
|
+
`}
|
|
66
|
+
`;
|
|
67
|
+
const StyledSlide = (0, import_ds_system.styled)("div", {
|
|
68
|
+
name: import_constants.DSSwipeCardName,
|
|
69
|
+
slot: import_constants.SWIPE_CARD_SLOTS.SLIDE
|
|
70
|
+
})`
|
|
71
|
+
@keyframes slide {
|
|
72
|
+
100% {
|
|
73
|
+
left: 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
position: relative;
|
|
78
|
+
top: 0;
|
|
79
|
+
width: 100%;
|
|
80
|
+
height: 100%;
|
|
81
|
+
max-width: 100%;
|
|
82
|
+
overflow: auto;
|
|
83
|
+
min-height: 0;
|
|
84
|
+
min-width: 0;
|
|
85
|
+
|
|
86
|
+
${({ $isFirstRender, $enableAnimation, $animationDuration }) => {
|
|
87
|
+
if ($isFirstRender || !$enableAnimation)
|
|
88
|
+
return import_ds_system.css`
|
|
89
|
+
left: 0;
|
|
90
|
+
`;
|
|
91
|
+
return import_ds_system.css`
|
|
92
|
+
left: 100%;
|
|
93
|
+
animation: slide ${$animationDuration}ms forwards;
|
|
94
|
+
`;
|
|
95
|
+
}}
|
|
96
|
+
|
|
97
|
+
${({ $isActive }) => {
|
|
98
|
+
if ($isActive)
|
|
99
|
+
return import_ds_system.css`
|
|
100
|
+
pointer-events: auto;
|
|
101
|
+
`;
|
|
102
|
+
return import_ds_system.css`
|
|
103
|
+
pointer-events: none;
|
|
104
|
+
display: none;
|
|
105
|
+
`;
|
|
106
|
+
}}
|
|
107
|
+
`;
|
|
108
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/styled.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { css, styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSSwipeCardName, SWIPE_CARD_SLOTS } from './constants/index.js';\n\n/**\n * Root wrapper of the Swipe Card component.\n */\nexport const StyledWrapper = styled(Grid, {\n name: DSSwipeCardName,\n slot: SWIPE_CARD_SLOTS.ROOT,\n})`\n position: relative;\n width: 100%;\n height: 100%;\n overflow: hidden;\n min-height: 0;\n min-width: 0;\n`;\n\n/**\n * Props applied to the scroll container styled component.\n */\nexport interface StyledScrollContainerProps {\n $disabled?: boolean;\n $enableTouch?: boolean;\n}\n/**\n * Container that holds the active slide and manages touch behavior.\n */\nexport const StyledScrollContainer = styled('div', {\n name: DSSwipeCardName,\n slot: SWIPE_CARD_SLOTS.SCROLL_CONTAINER,\n})<StyledScrollContainerProps>`\n position: relative;\n width: 100%;\n height: 100%;\n overflow: hidden;\n min-height: 0;\n min-width: 0;\n\n ${({ $disabled = false }) =>\n $disabled &&\n `\n pointer-events: none;\n touch-action: none;\n `}\n`;\n\n/**\n * Props that dictate the slide animation\n */\nexport interface StyledSlideProps {\n $isFirstRender: boolean;\n $isActive: boolean;\n $enableAnimation: boolean;\n $animationDuration: number;\n}\n/**\n * Single slide element. Positioned absolutely and animated in.\n */\nexport const StyledSlide = styled('div', {\n name: DSSwipeCardName,\n slot: SWIPE_CARD_SLOTS.SLIDE,\n})<StyledSlideProps>`\n @keyframes slide {\n 100% {\n left: 0;\n }\n }\n\n position: relative;\n top: 0;\n width: 100%;\n height: 100%;\n max-width: 100%;\n overflow: auto;\n min-height: 0;\n min-width: 0;\n\n ${({ $isFirstRender, $enableAnimation, $animationDuration }) => {\n // scenarios that requires no animation at all:\n // - it's the first render\n // - the app side developer said they don't want the animation ($enableAnimation === false)\n // we check those condition and just do left: 0 in those scenarios\n if ($isFirstRender || !$enableAnimation)\n return css`\n left: 0;\n `;\n // now we know that the animation must happen, so we just configure the animation duration and the starting left position\n return css`\n left: 100%;\n animation: slide ${$animationDuration}ms forwards;\n `;\n }}\n\n ${({ $isActive }) => {\n if ($isActive)\n return css`\n pointer-events: auto;\n `;\n return css`\n pointer-events: none;\n display: none;\n `;\n }}\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA4B;AAC5B,qBAAqB;AACrB,uBAAkD;AAK3C,MAAM,oBAAgB,yBAAO,qBAAM;AAAA,EACxC,MAAM;AAAA,EACN,MAAM,kCAAiB;AACzB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBM,MAAM,4BAAwB,yBAAO,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,MAAM,kCAAiB;AACzB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQG,CAAC,EAAE,YAAY,MAAM,MACrB,aACA;AAAA;AAAA;AAAA,GAGD;AAAA;AAeI,MAAM,kBAAc,yBAAO,OAAO;AAAA,EACvC,MAAM;AAAA,EACN,MAAM,kCAAiB;AACzB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBG,CAAC,EAAE,gBAAgB,kBAAkB,mBAAmB,MAAM;AAK9D,MAAI,kBAAkB,CAAC;AACrB,WAAO;AAAA;AAAA;AAIT,SAAO;AAAA;AAAA,yBAEc,kBAAkB;AAAA;AAEzC,CAAC;AAAA;AAAA,IAEC,CAAC,EAAE,UAAU,MAAM;AACnB,MAAI;AACF,WAAO;AAAA;AAAA;AAGT,SAAO;AAAA;AAAA;AAAA;AAIT,CAAC;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { describe, useOwnerProps } from "@elliemae/ds-props-helpers";
|
|
5
|
+
import { uid } from "uid";
|
|
6
|
+
import { useSwipeCard } from "./config/useSwipeCard.js";
|
|
7
|
+
import { DSSwipeCardName } from "./constants/index.js";
|
|
8
|
+
import { DSSwipeCardPropTypesSchema } from "./react-desc-prop-types.js";
|
|
9
|
+
import { StyledScrollContainer, StyledSlide, StyledWrapper } from "./styled.js";
|
|
10
|
+
const DSSwipeCard = (props) => {
|
|
11
|
+
const {
|
|
12
|
+
propsWithDefault,
|
|
13
|
+
xstyledProps,
|
|
14
|
+
instanceUid,
|
|
15
|
+
isFirstRender,
|
|
16
|
+
onTouchStart,
|
|
17
|
+
onTouchMove,
|
|
18
|
+
onTouchEnd,
|
|
19
|
+
globalAttributes
|
|
20
|
+
} = useSwipeCard(props);
|
|
21
|
+
const { wrap, ...restGlobalAttributes } = globalAttributes;
|
|
22
|
+
const { disabled, animationDuration, enableTouch, CardRender, slidesProps, enableAnimation } = propsWithDefault;
|
|
23
|
+
const ownerPropsConfig = useOwnerProps(propsWithDefault);
|
|
24
|
+
const [renderKey, setRenderKey] = React2.useState(`render-key-${uid(5)}`);
|
|
25
|
+
const handleAnimationStart = React2.useCallback(() => {
|
|
26
|
+
requestAnimationFrame(() => setRenderKey(`render-key-${uid(5)}`));
|
|
27
|
+
}, [setRenderKey]);
|
|
28
|
+
return /* @__PURE__ */ jsx(StyledWrapper, { ...ownerPropsConfig, ...xstyledProps, ...restGlobalAttributes, children: /* @__PURE__ */ jsx(
|
|
29
|
+
StyledScrollContainer,
|
|
30
|
+
{
|
|
31
|
+
$disabled: disabled,
|
|
32
|
+
$enableTouch: enableTouch,
|
|
33
|
+
onTouchStart,
|
|
34
|
+
onTouchMove,
|
|
35
|
+
onTouchEnd,
|
|
36
|
+
...ownerPropsConfig,
|
|
37
|
+
children: slidesProps.map((slide, i) => /* @__PURE__ */ jsx(
|
|
38
|
+
StyledSlide,
|
|
39
|
+
{
|
|
40
|
+
...ownerPropsConfig,
|
|
41
|
+
$animationDuration: animationDuration,
|
|
42
|
+
$isFirstRender: isFirstRender,
|
|
43
|
+
$enableAnimation: enableAnimation,
|
|
44
|
+
$isActive: i === propsWithDefault.activeSlide,
|
|
45
|
+
"aria-hidden": i !== propsWithDefault.activeSlide,
|
|
46
|
+
onAnimationStart: isFirstRender ? void 0 : handleAnimationStart,
|
|
47
|
+
children: /* @__PURE__ */ jsx(
|
|
48
|
+
CardRender,
|
|
49
|
+
{
|
|
50
|
+
dsIndex: i,
|
|
51
|
+
...slide,
|
|
52
|
+
renderKey
|
|
53
|
+
},
|
|
54
|
+
`slide-${instanceUid}-${i === propsWithDefault.activeSlide}`
|
|
55
|
+
)
|
|
56
|
+
},
|
|
57
|
+
`slide-${instanceUid}-${i}`
|
|
58
|
+
))
|
|
59
|
+
}
|
|
60
|
+
) });
|
|
61
|
+
};
|
|
62
|
+
DSSwipeCard.displayName = DSSwipeCardName;
|
|
63
|
+
const DSSwipeCardWithSchema = describe(DSSwipeCard);
|
|
64
|
+
DSSwipeCardWithSchema.propTypes = DSSwipeCardPropTypesSchema;
|
|
65
|
+
export {
|
|
66
|
+
DSSwipeCard,
|
|
67
|
+
DSSwipeCardWithSchema
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=DSSwipeCard.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSSwipeCard.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe, useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { uid } from 'uid';\nimport { useSwipeCard } from './config/useSwipeCard.js';\nimport { DSSwipeCardName } from './constants/index.js';\nimport { type DSSwipeCardT, DSSwipeCardPropTypesSchema } from './react-desc-prop-types.js';\nimport { StyledScrollContainer, StyledSlide, StyledWrapper } from './styled.js';\n\nconst DSSwipeCard = <T extends DSSwipeCardT.CustomInterface>(props: DSSwipeCardT.Props<T>) => {\n const {\n propsWithDefault,\n xstyledProps,\n instanceUid,\n isFirstRender,\n onTouchStart,\n onTouchMove,\n onTouchEnd,\n globalAttributes,\n } = useSwipeCard(props);\n\n const { wrap, ...restGlobalAttributes } = globalAttributes;\n const { disabled, animationDuration, enableTouch, CardRender, slidesProps, enableAnimation } = propsWithDefault;\n const ownerPropsConfig = useOwnerProps(propsWithDefault);\n const [renderKey, setRenderKey] = React.useState(`render-key-${uid(5)}`);\n const handleAnimationStart = React.useCallback(() => {\n // we change the key to force RENDERING of slides, to avoid wrong calculations of width/height on virtualization\n requestAnimationFrame(() => setRenderKey(`render-key-${uid(5)}`));\n }, [setRenderKey]);\n return (\n <StyledWrapper {...ownerPropsConfig} {...xstyledProps} {...restGlobalAttributes}>\n <StyledScrollContainer\n $disabled={disabled}\n $enableTouch={enableTouch}\n onTouchStart={onTouchStart}\n onTouchMove={onTouchMove}\n onTouchEnd={onTouchEnd}\n {...ownerPropsConfig}\n >\n {slidesProps.map((slide, i) => (\n <StyledSlide\n // we can use the i as a key BECAUSE WE ALSO ADD THE ${instanceUid}\n // the eslint rule is to avoid repeated keys in the VDOM, but we are not repeating it thanks to UID\n // eslint-disable-next-line react/no-array-index-key\n key={`slide-${instanceUid}-${i}`}\n {...ownerPropsConfig}\n $animationDuration={animationDuration}\n $isFirstRender={isFirstRender}\n $enableAnimation={enableAnimation}\n $isActive={i === propsWithDefault.activeSlide}\n aria-hidden={i !== propsWithDefault.activeSlide}\n onAnimationStart={isFirstRender ? undefined : handleAnimationStart}\n >\n <CardRender\n key={`slide-${instanceUid}-${i === propsWithDefault.activeSlide}`}\n dsIndex={i}\n {...slide}\n renderKey={renderKey}\n />\n </StyledSlide>\n ))}\n </StyledScrollContainer>\n </StyledWrapper>\n );\n};\n\nDSSwipeCard.displayName = DSSwipeCardName;\nconst DSSwipeCardWithSchema = describe(DSSwipeCard);\nDSSwipeCardWithSchema.propTypes = DSSwipeCardPropTypesSchema;\n\nexport { DSSwipeCard, DSSwipeCardWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoDX;AApDZ,OAAOA,YAAW;AAClB,SAAS,UAAU,qBAAqB;AACxC,SAAS,WAAW;AACpB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAA4B,kCAAkC;AAC9D,SAAS,uBAAuB,aAAa,qBAAqB;AAElE,MAAM,cAAc,CAAyC,UAAiC;AAC5F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,aAAa,KAAK;AAEtB,QAAM,EAAE,MAAM,GAAG,qBAAqB,IAAI;AAC1C,QAAM,EAAE,UAAU,mBAAmB,aAAa,YAAY,aAAa,gBAAgB,IAAI;AAC/F,QAAM,mBAAmB,cAAc,gBAAgB;AACvD,QAAM,CAAC,WAAW,YAAY,IAAIA,OAAM,SAAS,cAAc,IAAI,CAAC,CAAC,EAAE;AACvE,QAAM,uBAAuBA,OAAM,YAAY,MAAM;AAEnD,0BAAsB,MAAM,aAAa,cAAc,IAAI,CAAC,CAAC,EAAE,CAAC;AAAA,EAClE,GAAG,CAAC,YAAY,CAAC;AACjB,SACE,oBAAC,iBAAe,GAAG,kBAAmB,GAAG,cAAe,GAAG,sBACzD;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,MACX,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MAEH,sBAAY,IAAI,CAAC,OAAO,MACvB;AAAA,QAAC;AAAA;AAAA,UAKE,GAAG;AAAA,UACJ,oBAAoB;AAAA,UACpB,gBAAgB;AAAA,UAChB,kBAAkB;AAAA,UAClB,WAAW,MAAM,iBAAiB;AAAA,UAClC,eAAa,MAAM,iBAAiB;AAAA,UACpC,kBAAkB,gBAAgB,SAAY;AAAA,UAE9C;AAAA,YAAC;AAAA;AAAA,cAEC,SAAS;AAAA,cACR,GAAG;AAAA,cACJ;AAAA;AAAA,YAHK,SAAS,WAAW,IAAI,MAAM,iBAAiB,WAAW;AAAA,UAIjE;AAAA;AAAA,QAdK,SAAS,WAAW,IAAI,CAAC;AAAA,MAehC,CACD;AAAA;AAAA,EACH,GACF;AAEJ;AAEA,YAAY,cAAc;AAC1B,MAAM,wBAAwB,SAAS,WAAW;AAClD,sBAAsB,YAAY;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const calculateSwipeTarget = (deltaX, currentSlide, totalSlides) => {
|
|
3
|
+
if (deltaX > 0 && currentSlide > 0) {
|
|
4
|
+
return { targetSlide: currentSlide - 1, direction: "right" };
|
|
5
|
+
}
|
|
6
|
+
if (deltaX < 0 && currentSlide < totalSlides - 1) {
|
|
7
|
+
return { targetSlide: currentSlide + 1, direction: "left" };
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
calculateSwipeTarget
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=slidePositionHelpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/slidePositionHelpers.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export interface SwipeTarget {\n targetSlide: number;\n direction: 'left' | 'right';\n}\n\n/**\n * Calculate swipe target slide based on gesture\n */\nexport const calculateSwipeTarget = (deltaX: number, currentSlide: number, totalSlides: number): SwipeTarget | null => {\n if (deltaX > 0 && currentSlide > 0) {\n return { targetSlide: currentSlide - 1, direction: 'right' };\n }\n if (deltaX < 0 && currentSlide < totalSlides - 1) {\n return { targetSlide: currentSlide + 1, direction: 'left' };\n }\n return null;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACQhB,MAAM,uBAAuB,CAAC,QAAgB,cAAsB,gBAA4C;AACrH,MAAI,SAAS,KAAK,eAAe,GAAG;AAClC,WAAO,EAAE,aAAa,eAAe,GAAG,WAAW,QAAQ;AAAA,EAC7D;AACA,MAAI,SAAS,KAAK,eAAe,cAAc,GAAG;AAChD,WAAO,EAAE,aAAa,eAAe,GAAG,WAAW,OAAO;AAAA,EAC5D;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { calculateSwipeTarget } from "./slidePositionHelpers.js";
|
|
4
|
+
const useTouchHandlers = (options) => {
|
|
5
|
+
const { enableTouch, disabled, activeSlide, totalSlides, onSwipe } = options;
|
|
6
|
+
const startXRef = React2.useRef(0);
|
|
7
|
+
const startYRef = React2.useRef(0);
|
|
8
|
+
const isDraggingRef = React2.useRef(false);
|
|
9
|
+
const onTouchStart = React2.useCallback((e) => {
|
|
10
|
+
const touch = e.touches[0];
|
|
11
|
+
startXRef.current = touch.clientX;
|
|
12
|
+
startYRef.current = touch.clientY;
|
|
13
|
+
isDraggingRef.current = true;
|
|
14
|
+
}, []);
|
|
15
|
+
const onTouchMove = React2.useCallback(() => {
|
|
16
|
+
}, []);
|
|
17
|
+
const onTouchEnd = React2.useCallback(
|
|
18
|
+
(e) => {
|
|
19
|
+
if (!isDraggingRef.current) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const touch = e.changedTouches[0];
|
|
23
|
+
const deltaX = touch.clientX - startXRef.current;
|
|
24
|
+
const deltaY = touch.clientY - startYRef.current;
|
|
25
|
+
if (Math.abs(deltaX) > Math.abs(deltaY) && Math.abs(deltaX) > 50) {
|
|
26
|
+
const swipeResult = calculateSwipeTarget(deltaX, activeSlide, totalSlides);
|
|
27
|
+
if (swipeResult) {
|
|
28
|
+
onSwipe(swipeResult.targetSlide, swipeResult.direction);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
isDraggingRef.current = false;
|
|
32
|
+
},
|
|
33
|
+
[activeSlide, totalSlides, onSwipe]
|
|
34
|
+
);
|
|
35
|
+
if (!enableTouch || disabled) {
|
|
36
|
+
return {
|
|
37
|
+
onTouchStart: void 0,
|
|
38
|
+
onTouchMove: void 0,
|
|
39
|
+
onTouchEnd: void 0
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return { onTouchStart, onTouchMove, onTouchEnd };
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
useTouchHandlers
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=touchHandlers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/touchHandlers.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { calculateSwipeTarget } from './slidePositionHelpers.js';\n\nexport interface TouchHandlerOptions {\n enableTouch: boolean;\n disabled: boolean;\n activeSlide: number;\n totalSlides: number;\n onSwipe: (targetSlide: number, direction: 'left' | 'right') => void;\n}\n\n/**\n * useTouchHandlers\n *\n * Provides touch event handlers for swipe detection using React refs for mutable state\n * and React.useCallback for stable handler identities.\n */\nexport const useTouchHandlers = (options: TouchHandlerOptions) => {\n const { enableTouch, disabled, activeSlide, totalSlides, onSwipe } = options;\n\n // Mutable refs for gesture tracking to avoid re-renders\n const startXRef = React.useRef<number>(0);\n const startYRef = React.useRef<number>(0);\n const isDraggingRef = React.useRef<boolean>(false);\n\n const onTouchStart = React.useCallback((e: React.TouchEvent<HTMLDivElement>) => {\n const touch = e.touches[0];\n startXRef.current = touch.clientX;\n startYRef.current = touch.clientY;\n isDraggingRef.current = true;\n }, []);\n\n const onTouchMove = React.useCallback(() => {\n // We don't need to handle move for swipe detection\n }, []);\n\n const onTouchEnd = React.useCallback(\n (e: React.TouchEvent<HTMLDivElement>) => {\n if (!isDraggingRef.current) {\n return;\n }\n const touch = e.changedTouches[0];\n const deltaX = touch.clientX - startXRef.current;\n const deltaY = touch.clientY - startYRef.current;\n\n // Trigger swipe only for significant horizontal movement\n if (Math.abs(deltaX) > Math.abs(deltaY) && Math.abs(deltaX) > 50) {\n const swipeResult = calculateSwipeTarget(deltaX, activeSlide, totalSlides);\n if (swipeResult) {\n onSwipe(swipeResult.targetSlide, swipeResult.direction);\n }\n }\n\n isDraggingRef.current = false;\n },\n [activeSlide, totalSlides, onSwipe],\n );\n\n // If touch is disabled, expose null so consumers can skip attaching handlers\n if (!enableTouch || disabled) {\n return {\n onTouchStart: undefined,\n onTouchMove: undefined,\n onTouchEnd: undefined,\n };\n }\n\n return { onTouchStart, onTouchMove, onTouchEnd };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAClB,SAAS,4BAA4B;AAgB9B,MAAM,mBAAmB,CAAC,YAAiC;AAChE,QAAM,EAAE,aAAa,UAAU,aAAa,aAAa,QAAQ,IAAI;AAGrE,QAAM,YAAYA,OAAM,OAAe,CAAC;AACxC,QAAM,YAAYA,OAAM,OAAe,CAAC;AACxC,QAAM,gBAAgBA,OAAM,OAAgB,KAAK;AAEjD,QAAM,eAAeA,OAAM,YAAY,CAAC,MAAwC;AAC9E,UAAM,QAAQ,EAAE,QAAQ,CAAC;AACzB,cAAU,UAAU,MAAM;AAC1B,cAAU,UAAU,MAAM;AAC1B,kBAAc,UAAU;AAAA,EAC1B,GAAG,CAAC,CAAC;AAEL,QAAM,cAAcA,OAAM,YAAY,MAAM;AAAA,EAE5C,GAAG,CAAC,CAAC;AAEL,QAAM,aAAaA,OAAM;AAAA,IACvB,CAAC,MAAwC;AACvC,UAAI,CAAC,cAAc,SAAS;AAC1B;AAAA,MACF;AACA,YAAM,QAAQ,EAAE,eAAe,CAAC;AAChC,YAAM,SAAS,MAAM,UAAU,UAAU;AACzC,YAAM,SAAS,MAAM,UAAU,UAAU;AAGzC,UAAI,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,IAAI,IAAI;AAChE,cAAM,cAAc,qBAAqB,QAAQ,aAAa,WAAW;AACzE,YAAI,aAAa;AACf,kBAAQ,YAAY,aAAa,YAAY,SAAS;AAAA,QACxD;AAAA,MACF;AAEA,oBAAc,UAAU;AAAA,IAC1B;AAAA,IACA,CAAC,aAAa,aAAa,OAAO;AAAA,EACpC;AAGA,MAAI,CAAC,eAAe,UAAU;AAC5B,WAAO;AAAA,MACL,cAAc;AAAA,MACd,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAO,EAAE,cAAc,aAAa,WAAW;AACjD;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { uid } from "uid";
|
|
5
|
+
import { DSSwipeCardPropTypes, DSSwipeCardDefaultProps } from "../react-desc-prop-types.js";
|
|
6
|
+
import { useValidateProps } from "./useValidateProps.js";
|
|
7
|
+
import { useTouchHandlers } from "./touchHandlers.js";
|
|
8
|
+
const useFirstRender = () => {
|
|
9
|
+
const ref = React2.useRef(true);
|
|
10
|
+
const firstRender = ref.current;
|
|
11
|
+
ref.current = false;
|
|
12
|
+
return firstRender;
|
|
13
|
+
};
|
|
14
|
+
const useSwipeCard = (propsFromUser) => {
|
|
15
|
+
const propsWithDefault = useMemoMergePropsWithDefault(
|
|
16
|
+
propsFromUser,
|
|
17
|
+
DSSwipeCardDefaultProps
|
|
18
|
+
);
|
|
19
|
+
useValidateProps(propsWithDefault, DSSwipeCardPropTypes);
|
|
20
|
+
const xstyledProps = useGetXstyledProps(propsWithDefault);
|
|
21
|
+
const instanceUid = React2.useMemo(() => `swipe-card-${uid(5)}`, []);
|
|
22
|
+
const globalAttributes = useGetGlobalAttributes(propsWithDefault);
|
|
23
|
+
const { activeSlide, slidesProps, enableTouch, disabled, onSwipe } = propsWithDefault;
|
|
24
|
+
const isFirstRender = useFirstRender();
|
|
25
|
+
const totalSlides = slidesProps.length;
|
|
26
|
+
const touchHandlers = useTouchHandlers({
|
|
27
|
+
enableTouch,
|
|
28
|
+
disabled: disabled ?? false,
|
|
29
|
+
activeSlide,
|
|
30
|
+
totalSlides,
|
|
31
|
+
onSwipe
|
|
32
|
+
});
|
|
33
|
+
const { onTouchStart, onTouchMove, onTouchEnd } = touchHandlers;
|
|
34
|
+
return React2.useMemo(
|
|
35
|
+
() => ({
|
|
36
|
+
propsWithDefault,
|
|
37
|
+
xstyledProps,
|
|
38
|
+
globalAttributes,
|
|
39
|
+
instanceUid,
|
|
40
|
+
isFirstRender,
|
|
41
|
+
// handlers to attach directly to the element to avoid extra effects
|
|
42
|
+
onTouchStart,
|
|
43
|
+
onTouchMove,
|
|
44
|
+
onTouchEnd
|
|
45
|
+
}),
|
|
46
|
+
[
|
|
47
|
+
propsWithDefault,
|
|
48
|
+
xstyledProps,
|
|
49
|
+
instanceUid,
|
|
50
|
+
isFirstRender,
|
|
51
|
+
onTouchStart,
|
|
52
|
+
onTouchMove,
|
|
53
|
+
onTouchEnd,
|
|
54
|
+
globalAttributes
|
|
55
|
+
]
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
useSwipeCard
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=useSwipeCard.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useSwipeCard.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport React from 'react';\nimport { uid } from 'uid';\nimport { DSSwipeCardPropTypes, DSSwipeCardDefaultProps, type DSSwipeCardT } from '../react-desc-prop-types.js';\nimport { useValidateProps } from './useValidateProps.js';\nimport { useTouchHandlers } from './touchHandlers.js';\n\nconst useFirstRender = () => {\n const ref = React.useRef(true);\n const firstRender = ref.current;\n ref.current = false;\n return firstRender;\n};\n\ninterface SwipeCardCTX<T extends DSSwipeCardT.CustomInterface> {\n propsWithDefault: DSSwipeCardT.InternalProps<T>;\n xstyledProps: ReturnType<typeof useGetXstyledProps>;\n globalAttributes: ReturnType<typeof useGetGlobalAttributes>;\n instanceUid: string;\n isFirstRender: boolean;\n // React touch handlers (no effects needed)\n onTouchStart?: (e: React.TouchEvent<HTMLDivElement>) => void;\n onTouchMove?: (e: React.TouchEvent<HTMLDivElement>) => void;\n onTouchEnd?: (e: React.TouchEvent<HTMLDivElement>) => void;\n}\n/**\n * useSwipeCard\n *\n * Orchestrates the controlled carousel behavior:\n * - It validates and merges props with defaults\n * - exposes touch handlers\n */\nexport const useSwipeCard = <T extends DSSwipeCardT.CustomInterface>(\n propsFromUser: DSSwipeCardT.Props<T>,\n): SwipeCardCTX<T> => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSSwipeCardT.InternalProps<T>>(\n propsFromUser,\n DSSwipeCardDefaultProps,\n );\n useValidateProps(propsWithDefault, DSSwipeCardPropTypes);\n\n // =============================================================================\n // XSTYLED PROPS AND INSTANCE UID\n // =============================================================================\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n const instanceUid = React.useMemo(() => `swipe-card-${uid(5)}`, []);\n // =============================================================================\n // GLOBAL ATTRIBUTES\n // =============================================================================\n const globalAttributes = useGetGlobalAttributes(propsWithDefault);\n\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { activeSlide, slidesProps, enableTouch, disabled, onSwipe } = propsWithDefault;\n\n const isFirstRender = useFirstRender();\n const totalSlides = slidesProps.length;\n\n // =============================================================================\n // TOUCH/SWIPE DETECTION\n // =============================================================================\n const touchHandlers = useTouchHandlers({\n enableTouch,\n disabled: disabled ?? false,\n activeSlide,\n totalSlides,\n onSwipe,\n });\n const { onTouchStart, onTouchMove, onTouchEnd } = touchHandlers;\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n xstyledProps,\n globalAttributes,\n instanceUid,\n isFirstRender,\n // handlers to attach directly to the element to avoid extra effects\n onTouchStart,\n onTouchMove,\n onTouchEnd,\n }),\n [\n propsWithDefault,\n xstyledProps,\n instanceUid,\n isFirstRender,\n onTouchStart,\n onTouchMove,\n onTouchEnd,\n globalAttributes,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,wBAAwB,oBAAoB,oCAAoC;AACzF,OAAOA,YAAW;AAClB,SAAS,WAAW;AACpB,SAAS,sBAAsB,+BAAkD;AACjF,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAEjC,MAAM,iBAAiB,MAAM;AAC3B,QAAM,MAAMA,OAAM,OAAO,IAAI;AAC7B,QAAM,cAAc,IAAI;AACxB,MAAI,UAAU;AACd,SAAO;AACT;AAoBO,MAAM,eAAe,CAC1B,kBACoB;AAIpB,QAAM,mBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,mBAAiB,kBAAkB,oBAAoB;AAKvD,QAAM,eAAe,mBAAmB,gBAAgB;AACxD,QAAM,cAAcA,OAAM,QAAQ,MAAM,cAAc,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAIlE,QAAM,mBAAmB,uBAAuB,gBAAgB;AAKhE,QAAM,EAAE,aAAa,aAAa,aAAa,UAAU,QAAQ,IAAI;AAErE,QAAM,gBAAgB,eAAe;AACrC,QAAM,cAAc,YAAY;AAKhC,QAAM,gBAAgB,iBAAiB;AAAA,IACrC;AAAA,IACA,UAAU,YAAY;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,EAAE,cAAc,aAAa,WAAW,IAAI;AAElD,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
|
|
3
|
+
import { DSSwipeCardName } from "../constants/index.js";
|
|
4
|
+
const useValidateProps = (props, propTypes) => {
|
|
5
|
+
useValidateTypescriptPropTypes(props, propTypes, DSSwipeCardName);
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
useValidateProps
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useValidateProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useValidateProps.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { ValidationMap } from '@elliemae/ds-props-helpers';\nimport { type DSSwipeCardT } from '../react-desc-prop-types.js';\nimport { DSSwipeCardName } from '../constants/index.js';\n\nexport const useValidateProps = <T extends DSSwipeCardT.CustomInterface>(\n props: DSSwipeCardT.InternalProps<T>,\n propTypes: ValidationMap<unknown>,\n): void => {\n // we validate the \"required if\" via 'isRequiredIf from our custom PropTypes\n useValidateTypescriptPropTypes(props, propTypes, DSSwipeCardName);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,sCAAsC;AAG/C,SAAS,uBAAuB;AAEzB,MAAM,mBAAmB,CAC9B,OACA,cACS;AAET,iCAA+B,OAAO,WAAW,eAAe;AAClE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { slotObjectToDataTestIds } from "@elliemae/ds-system";
|
|
3
|
+
const DSSwipeCardName = "DSSwipecard";
|
|
4
|
+
const SWIPE_CARD_SLOTS = {
|
|
5
|
+
ROOT: "root",
|
|
6
|
+
SCROLL_CONTAINER: "scroll-container",
|
|
7
|
+
SLIDE: "slide"
|
|
8
|
+
};
|
|
9
|
+
const SWIPE_CARD_DATA_TESTID = slotObjectToDataTestIds(DSSwipeCardName, SWIPE_CARD_SLOTS);
|
|
10
|
+
export {
|
|
11
|
+
DSSwipeCardName,
|
|
12
|
+
SWIPE_CARD_DATA_TESTID,
|
|
13
|
+
SWIPE_CARD_SLOTS
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/constants/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSSwipeCardName = 'DSSwipecard';\n\n// we are naming this with the ${component_name}_slots convention to namespace & avoid errors on duplicate exports variables in aggregators\nexport const SWIPE_CARD_SLOTS = {\n ROOT: 'root',\n SCROLL_CONTAINER: 'scroll-container',\n SLIDE: 'slide',\n} as const;\n\n// we are naming this with the ${component_name}_data_testid convention to namespace & avoid errors on duplicate exports variables in aggregators\nexport const SWIPE_CARD_DATA_TESTID = slotObjectToDataTestIds(DSSwipeCardName, SWIPE_CARD_SLOTS);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AAEjC,MAAM,kBAAkB;AAGxB,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,kBAAkB;AAAA,EAClB,OAAO;AACT;AAGO,MAAM,yBAAyB,wBAAwB,iBAAiB,gBAAgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DSSwipeCard, DSSwipeCardWithSchema } from "./DSSwipeCard.js";
|
|
3
|
+
import { DSSwipeCardPropTypes } from "./react-desc-prop-types.js";
|
|
4
|
+
import { SWIPE_CARD_SLOTS, SWIPE_CARD_DATA_TESTID } from "./constants/index.js";
|
|
5
|
+
export {
|
|
6
|
+
DSSwipeCard,
|
|
7
|
+
DSSwipeCardPropTypes,
|
|
8
|
+
DSSwipeCardWithSchema,
|
|
9
|
+
SWIPE_CARD_DATA_TESTID,
|
|
10
|
+
SWIPE_CARD_SLOTS
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// this is a workaround to typescript error TS2742\n// https://github.com/microsoft/TypeScript/issues/47663\nimport type {} from '@xstyled/system';\nexport { DSSwipeCard, DSSwipeCardWithSchema } from './DSSwipeCard.js';\nexport { type DSSwipeCardT, DSSwipeCardPropTypes } from './react-desc-prop-types.js';\nexport { SWIPE_CARD_SLOTS, SWIPE_CARD_DATA_TESTID } from './constants/index.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,aAAa,6BAA6B;AACnD,SAA4B,4BAA4B;AACxD,SAAS,kBAAkB,8BAA8B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
PropTypes,
|
|
4
|
+
getPropsPerSlotPropTypes,
|
|
5
|
+
globalAttributesPropTypes,
|
|
6
|
+
xstyledPropTypes
|
|
7
|
+
} from "@elliemae/ds-props-helpers";
|
|
8
|
+
import { DSSwipeCardName, SWIPE_CARD_SLOTS } from "./constants/index.js";
|
|
9
|
+
const noop = () => {
|
|
10
|
+
};
|
|
11
|
+
const DSSwipeCardDefaultProps = {
|
|
12
|
+
enableAnimation: true,
|
|
13
|
+
enableTouch: true,
|
|
14
|
+
animationDuration: 300,
|
|
15
|
+
onSwipe: noop
|
|
16
|
+
};
|
|
17
|
+
const DSSwipeCardPropTypes = {
|
|
18
|
+
...getPropsPerSlotPropTypes(DSSwipeCardName, SWIPE_CARD_SLOTS),
|
|
19
|
+
...globalAttributesPropTypes,
|
|
20
|
+
...xstyledPropTypes,
|
|
21
|
+
slidesProps: PropTypes.arrayOf(
|
|
22
|
+
PropTypes.shape({
|
|
23
|
+
userRenderProps: PropTypes.object
|
|
24
|
+
})
|
|
25
|
+
).description("An array of props that your CardRender will receive, one object per slide").isRequired,
|
|
26
|
+
CardRender: PropTypes.func.description(
|
|
27
|
+
"The react component that will be used to render slides, receiving your slide props + dsIndex that indicates the position of the slide in the array"
|
|
28
|
+
).isRequired,
|
|
29
|
+
activeSlide: PropTypes.number.description(
|
|
30
|
+
"Controlled props that allows application to declare which slide needs to be displayed right now"
|
|
31
|
+
).isRequired,
|
|
32
|
+
onSwipe: PropTypes.func.description("When in touch screens and enabling touch/swipe gestures, this callback is fired on swipe").defaultValue("(()=>{})"),
|
|
33
|
+
enableAnimation: PropTypes.bool.description("When the the active slide changes, should an animation happens?").defaultValue(true),
|
|
34
|
+
enableTouch: PropTypes.bool.description("Should touch/swipe gestures be enabled?").defaultValue(true),
|
|
35
|
+
animationDuration: PropTypes.number.description("If an animation is enabled, this prop controls the duration in milliseconds").defaultValue(300),
|
|
36
|
+
disabled: PropTypes.bool.description("Whether the swipe card is disabled")
|
|
37
|
+
};
|
|
38
|
+
const DSSwipeCardPropTypesSchema = DSSwipeCardPropTypes;
|
|
39
|
+
export {
|
|
40
|
+
DSSwipeCardDefaultProps,
|
|
41
|
+
DSSwipeCardPropTypes,
|
|
42
|
+
DSSwipeCardPropTypesSchema
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type { DSPropTypesSchema, GlobalAttributesT, ValidationMap, XstyledProps } from '@elliemae/ds-props-helpers';\nimport {\n PropTypes,\n getPropsPerSlotPropTypes,\n globalAttributesPropTypes,\n xstyledPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport type { TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type React from 'react';\nimport { DSSwipeCardName, SWIPE_CARD_SLOTS } from './constants/index.js';\n\nconst noop = (): void => {};\n\nexport declare namespace DSSwipeCardT {\n export type CustomInterface<T extends Record<string, unknown> = Record<string, unknown>> = T;\n export type CardRenderProps<T extends Record<string, unknown> = Record<string, unknown>> = T & {\n dsIndex: number;\n renderKey: string;\n };\n\n export interface RequiredProps<T extends Record<string, unknown> = Record<string, unknown>> {\n slidesProps: CustomInterface<T>[];\n CardRender: React.ComponentType<CardRenderProps<T>>;\n activeSlide: number;\n }\n\n export interface DefaultProps {\n onSwipe: (newActiveSlide: number, direction: 'left' | 'right') => void;\n enableTouch: boolean;\n animationDuration: number;\n enableAnimation: boolean;\n }\n\n export interface OptionalProps\n extends TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSSwipeCardName, typeof SWIPE_CARD_SLOTS> {}\n\n export interface Props<T extends CustomInterface = CustomInterface>\n extends RequiredProps<T>,\n Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof RequiredProps | keyof DefaultProps | keyof OptionalProps>,\n XstyledProps {}\n\n export interface InternalProps<T extends CustomInterface = CustomInterface>\n extends RequiredProps<T>,\n DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof RequiredProps | keyof DefaultProps | keyof OptionalProps>,\n XstyledProps {}\n}\n\nexport const DSSwipeCardDefaultProps: DSSwipeCardT.DefaultProps = {\n enableAnimation: true,\n enableTouch: true,\n animationDuration: 300,\n onSwipe: noop,\n};\n\nexport const DSSwipeCardPropTypes: DSPropTypesSchema<DSSwipeCardT.Props> = {\n ...getPropsPerSlotPropTypes(DSSwipeCardName, SWIPE_CARD_SLOTS),\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n slidesProps: PropTypes.arrayOf(\n PropTypes.shape({\n userRenderProps: PropTypes.object,\n }),\n ).description('An array of props that your CardRender will receive, one object per slide').isRequired,\n CardRender: PropTypes.func.description(\n 'The react component that will be used to render slides, receiving your slide props + dsIndex that indicates the position of the slide in the array',\n ).isRequired,\n activeSlide: PropTypes.number.description(\n 'Controlled props that allows application to declare which slide needs to be displayed right now',\n ).isRequired,\n onSwipe: PropTypes.func\n .description('When in touch screens and enabling touch/swipe gestures, this callback is fired on swipe')\n .defaultValue('(()=>{})'),\n enableAnimation: PropTypes.bool\n .description('When the the active slide changes, should an animation happens?')\n .defaultValue(true),\n enableTouch: PropTypes.bool.description('Should touch/swipe gestures be enabled?').defaultValue(true),\n animationDuration: PropTypes.number\n .description('If an animation is enabled, this prop controls the duration in milliseconds')\n .defaultValue(300),\n disabled: PropTypes.bool.description('Whether the swipe card is disabled'),\n};\n\nexport const DSSwipeCardPropTypesSchema = DSSwipeCardPropTypes as unknown as ValidationMap<DSSwipeCardT.Props>;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,iBAAiB,wBAAwB;AAElD,MAAM,OAAO,MAAY;AAAC;AAwCnB,MAAM,0BAAqD;AAAA,EAChE,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,SAAS;AACX;AAEO,MAAM,uBAA8D;AAAA,EACzE,GAAG,yBAAyB,iBAAiB,gBAAgB;AAAA,EAC7D,GAAG;AAAA,EACH,GAAG;AAAA,EACH,aAAa,UAAU;AAAA,IACrB,UAAU,MAAM;AAAA,MACd,iBAAiB,UAAU;AAAA,IAC7B,CAAC;AAAA,EACH,EAAE,YAAY,2EAA2E,EAAE;AAAA,EAC3F,YAAY,UAAU,KAAK;AAAA,IACzB;AAAA,EACF,EAAE;AAAA,EACF,aAAa,UAAU,OAAO;AAAA,IAC5B;AAAA,EACF,EAAE;AAAA,EACF,SAAS,UAAU,KAChB,YAAY,0FAA0F,EACtG,aAAa,UAAU;AAAA,EAC1B,iBAAiB,UAAU,KACxB,YAAY,iEAAiE,EAC7E,aAAa,IAAI;AAAA,EACpB,aAAa,UAAU,KAAK,YAAY,yCAAyC,EAAE,aAAa,IAAI;AAAA,EACpG,mBAAmB,UAAU,OAC1B,YAAY,6EAA6E,EACzF,aAAa,GAAG;AAAA,EACnB,UAAU,UAAU,KAAK,YAAY,oCAAoC;AAC3E;AAEO,MAAM,6BAA6B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { css, styled } from "@elliemae/ds-system";
|
|
3
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
4
|
+
import { DSSwipeCardName, SWIPE_CARD_SLOTS } from "./constants/index.js";
|
|
5
|
+
const StyledWrapper = styled(Grid, {
|
|
6
|
+
name: DSSwipeCardName,
|
|
7
|
+
slot: SWIPE_CARD_SLOTS.ROOT
|
|
8
|
+
})`
|
|
9
|
+
position: relative;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
min-height: 0;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
`;
|
|
16
|
+
const StyledScrollContainer = styled("div", {
|
|
17
|
+
name: DSSwipeCardName,
|
|
18
|
+
slot: SWIPE_CARD_SLOTS.SCROLL_CONTAINER
|
|
19
|
+
})`
|
|
20
|
+
position: relative;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
min-height: 0;
|
|
25
|
+
min-width: 0;
|
|
26
|
+
|
|
27
|
+
${({ $disabled = false }) => $disabled && `
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
touch-action: none;
|
|
30
|
+
`}
|
|
31
|
+
`;
|
|
32
|
+
const StyledSlide = styled("div", {
|
|
33
|
+
name: DSSwipeCardName,
|
|
34
|
+
slot: SWIPE_CARD_SLOTS.SLIDE
|
|
35
|
+
})`
|
|
36
|
+
@keyframes slide {
|
|
37
|
+
100% {
|
|
38
|
+
left: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
position: relative;
|
|
43
|
+
top: 0;
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 100%;
|
|
46
|
+
max-width: 100%;
|
|
47
|
+
overflow: auto;
|
|
48
|
+
min-height: 0;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
|
|
51
|
+
${({ $isFirstRender, $enableAnimation, $animationDuration }) => {
|
|
52
|
+
if ($isFirstRender || !$enableAnimation)
|
|
53
|
+
return css`
|
|
54
|
+
left: 0;
|
|
55
|
+
`;
|
|
56
|
+
return css`
|
|
57
|
+
left: 100%;
|
|
58
|
+
animation: slide ${$animationDuration}ms forwards;
|
|
59
|
+
`;
|
|
60
|
+
}}
|
|
61
|
+
|
|
62
|
+
${({ $isActive }) => {
|
|
63
|
+
if ($isActive)
|
|
64
|
+
return css`
|
|
65
|
+
pointer-events: auto;
|
|
66
|
+
`;
|
|
67
|
+
return css`
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
display: none;
|
|
70
|
+
`;
|
|
71
|
+
}}
|
|
72
|
+
`;
|
|
73
|
+
export {
|
|
74
|
+
StyledScrollContainer,
|
|
75
|
+
StyledSlide,
|
|
76
|
+
StyledWrapper
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/styled.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { css, styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSSwipeCardName, SWIPE_CARD_SLOTS } from './constants/index.js';\n\n/**\n * Root wrapper of the Swipe Card component.\n */\nexport const StyledWrapper = styled(Grid, {\n name: DSSwipeCardName,\n slot: SWIPE_CARD_SLOTS.ROOT,\n})`\n position: relative;\n width: 100%;\n height: 100%;\n overflow: hidden;\n min-height: 0;\n min-width: 0;\n`;\n\n/**\n * Props applied to the scroll container styled component.\n */\nexport interface StyledScrollContainerProps {\n $disabled?: boolean;\n $enableTouch?: boolean;\n}\n/**\n * Container that holds the active slide and manages touch behavior.\n */\nexport const StyledScrollContainer = styled('div', {\n name: DSSwipeCardName,\n slot: SWIPE_CARD_SLOTS.SCROLL_CONTAINER,\n})<StyledScrollContainerProps>`\n position: relative;\n width: 100%;\n height: 100%;\n overflow: hidden;\n min-height: 0;\n min-width: 0;\n\n ${({ $disabled = false }) =>\n $disabled &&\n `\n pointer-events: none;\n touch-action: none;\n `}\n`;\n\n/**\n * Props that dictate the slide animation\n */\nexport interface StyledSlideProps {\n $isFirstRender: boolean;\n $isActive: boolean;\n $enableAnimation: boolean;\n $animationDuration: number;\n}\n/**\n * Single slide element. Positioned absolutely and animated in.\n */\nexport const StyledSlide = styled('div', {\n name: DSSwipeCardName,\n slot: SWIPE_CARD_SLOTS.SLIDE,\n})<StyledSlideProps>`\n @keyframes slide {\n 100% {\n left: 0;\n }\n }\n\n position: relative;\n top: 0;\n width: 100%;\n height: 100%;\n max-width: 100%;\n overflow: auto;\n min-height: 0;\n min-width: 0;\n\n ${({ $isFirstRender, $enableAnimation, $animationDuration }) => {\n // scenarios that requires no animation at all:\n // - it's the first render\n // - the app side developer said they don't want the animation ($enableAnimation === false)\n // we check those condition and just do left: 0 in those scenarios\n if ($isFirstRender || !$enableAnimation)\n return css`\n left: 0;\n `;\n // now we know that the animation must happen, so we just configure the animation duration and the starting left position\n return css`\n left: 100%;\n animation: slide ${$animationDuration}ms forwards;\n `;\n }}\n\n ${({ $isActive }) => {\n if ($isActive)\n return css`\n pointer-events: auto;\n `;\n return css`\n pointer-events: none;\n display: none;\n `;\n }}\n`;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,KAAK,cAAc;AAC5B,SAAS,YAAY;AACrB,SAAS,iBAAiB,wBAAwB;AAK3C,MAAM,gBAAgB,OAAO,MAAM;AAAA,EACxC,MAAM;AAAA,EACN,MAAM,iBAAiB;AACzB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBM,MAAM,wBAAwB,OAAO,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,MAAM,iBAAiB;AACzB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQG,CAAC,EAAE,YAAY,MAAM,MACrB,aACA;AAAA;AAAA;AAAA,GAGD;AAAA;AAeI,MAAM,cAAc,OAAO,OAAO;AAAA,EACvC,MAAM;AAAA,EACN,MAAM,iBAAiB;AACzB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBG,CAAC,EAAE,gBAAgB,kBAAkB,mBAAmB,MAAM;AAK9D,MAAI,kBAAkB,CAAC;AACrB,WAAO;AAAA;AAAA;AAIT,SAAO;AAAA;AAAA,yBAEc,kBAAkB;AAAA;AAEzC,CAAC;AAAA;AAAA,IAEC,CAAC,EAAE,UAAU,MAAM;AACnB,MAAI;AACF,WAAO;AAAA;AAAA;AAGT,SAAO;AAAA;AAAA;AAAA;AAIT,CAAC;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type DSSwipeCardT } from './react-desc-prop-types.js';
|
|
2
|
+
declare const DSSwipeCard: {
|
|
3
|
+
<T extends DSSwipeCardT.CustomInterface>(props: DSSwipeCardT.Props<T>): import("react/jsx-runtime.js").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
declare const DSSwipeCardWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<DSSwipeCardT.Props<Record<string, unknown>>>;
|
|
7
|
+
export { DSSwipeCard, DSSwipeCardWithSchema };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface SwipeTarget {
|
|
2
|
+
targetSlide: number;
|
|
3
|
+
direction: 'left' | 'right';
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Calculate swipe target slide based on gesture
|
|
7
|
+
*/
|
|
8
|
+
export declare const calculateSwipeTarget: (deltaX: number, currentSlide: number, totalSlides: number) => SwipeTarget | null;
|