@tapcart/mobile-components 0.7.9 → 0.7.10-beta.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/dist/components/hooks/use-reviews.d.ts +1 -1
- package/dist/components/hooks/use-reviews.d.ts.map +1 -1
- package/dist/components/hooks/use-reviews.js +10 -32
- package/dist/components/hooks/use-tap.d.ts +8 -0
- package/dist/components/hooks/use-tap.d.ts.map +1 -0
- package/dist/components/hooks/use-tap.js +100 -0
- package/dist/components/ui/button.d.ts +0 -1
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +2 -6
- package/dist/components/ui/carousel.js +2 -2
- package/dist/components/ui/drawer.d.ts +8 -2
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +22 -11
- package/dist/components/ui/tap.d.ts.map +1 -1
- package/dist/components/ui/tap.js +1 -7
- package/dist/components/ui/video-enhanced.d.ts.map +1 -1
- package/dist/components/ui/video-enhanced.js +52 -26
- package/package.json +2 -3
- package/dist/components/hooks/use-style-utils.d.ts +0 -69
- package/dist/components/hooks/use-style-utils.d.ts.map +0 -1
- package/dist/components/hooks/use-style-utils.js +0 -77
- package/dist/lib/block-utils.d.ts +0 -97
- package/dist/lib/block-utils.d.ts.map +0 -1
- package/dist/lib/block-utils.js +0 -77
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-reviews.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-reviews.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGtF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,CAAC;IACjF,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"use-reviews.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-reviews.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGtF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,CAAC;IACjF,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,gBAAgB,CAAA;IAC3D,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,gBAAgB,CAwD1E;AAED,KAAK,wBAAwB,GAAG,gBAAgB,GAAG;IACjD,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CACtC,CAAA;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,wBAAwB,CA8F1F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback, useEffect
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
3
|
import useSWR from "swr";
|
|
4
4
|
import useSWRInfinite from "swr/infinite";
|
|
5
5
|
import { useInView } from 'react-intersection-observer';
|
|
@@ -52,13 +52,13 @@ export function useReviews(props) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
export function useReviewsInfinite(props) {
|
|
55
|
-
var _a;
|
|
55
|
+
var _a, _b;
|
|
56
56
|
let url = null;
|
|
57
57
|
const { ref, inView } = useInView({ rootMargin: "800px" });
|
|
58
58
|
let baseURL = "";
|
|
59
59
|
let queryParams = new URLSearchParams();
|
|
60
60
|
if (props) {
|
|
61
|
-
const { productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage } = props;
|
|
61
|
+
const { productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage } = props; // Destructure all relevant props
|
|
62
62
|
baseURL = props.baseURL;
|
|
63
63
|
if (productId.length > 0) {
|
|
64
64
|
queryParams.set("id", productId);
|
|
@@ -92,29 +92,12 @@ export function useReviewsInfinite(props) {
|
|
|
92
92
|
url = `${baseURL}/reviews/by-id?${queryParams.toString()}`;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
const isEndReached = useRef(false);
|
|
96
95
|
const getKey = (pageIndex, previousPageData) => {
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
if (dataType == null) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
if (previousPageData && previousPageData.pagination) {
|
|
104
|
-
const { perPage, total } = previousPageData.pagination;
|
|
105
|
-
isEndReached.current = (((pageIndex + 1) * perPage) >= total);
|
|
106
|
-
}
|
|
107
|
-
return `${baseURL}/reviews/by-id?${queryParams.toString()}&page=${pageIndex + 1}`;
|
|
108
|
-
}
|
|
109
|
-
if ((props === null || props === void 0 ? void 0 : props.provider) === "okendo") {
|
|
110
|
-
if (pageIndex === 0)
|
|
111
|
-
return `${baseURL}/reviews/by-id?${queryParams.toString()}`;
|
|
112
|
-
if (!((_a = previousPageData === null || previousPageData === void 0 ? void 0 : previousPageData.pagination) === null || _a === void 0 ? void 0 : _a.nextUrl)) {
|
|
113
|
-
isEndReached.current = true;
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
return `${baseURL}/reviews/by-id?${queryParams.toString()}&nextUrl=${((_b = previousPageData === null || previousPageData === void 0 ? void 0 : previousPageData.pagination) === null || _b === void 0 ? void 0 : _b.nextUrl) || null}`;
|
|
96
|
+
const dataType = queryParams.get("dataType") === "null" ? null : queryParams.get("dataType");
|
|
97
|
+
if (dataType == null) {
|
|
98
|
+
return null;
|
|
117
99
|
}
|
|
100
|
+
return `${baseURL}/reviews/by-id?${queryParams.toString()}&page=${pageIndex + 1}`;
|
|
118
101
|
};
|
|
119
102
|
const fetcher = (props === null || props === void 0 ? void 0 : props.fetcher) || ((url) => fetch(url).then((res) => res.json()));
|
|
120
103
|
const { data: dataInfinite, error: errorInfinite, size, setSize, isLoading, isValidating, } = useSWRInfinite(getKey, fetcher);
|
|
@@ -127,22 +110,17 @@ export function useReviewsInfinite(props) {
|
|
|
127
110
|
pagination: (dataInfinite === null || dataInfinite === void 0 ? void 0 : dataInfinite.length) ? dataInfinite[0].pagination : null,
|
|
128
111
|
reviews: mergedReviews
|
|
129
112
|
};
|
|
130
|
-
|
|
131
|
-
isEndReached.current = (mergedReviews === null || mergedReviews === void 0 ? void 0 : mergedReviews.length) === ((_a = searchResponse.pagination) === null || _a === void 0 ? void 0 : _a.total);
|
|
132
|
-
}
|
|
113
|
+
const isAllReviewsLoaded = (mergedReviews === null || mergedReviews === void 0 ? void 0 : mergedReviews.length) === ((_b = (_a = dataInfinite === null || dataInfinite === void 0 ? void 0 : dataInfinite[0]) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.total);
|
|
133
114
|
const loadMore = useCallback(() => {
|
|
134
|
-
if (!isLoading && !isValidating && !
|
|
115
|
+
if (!isLoading && !isValidating && !isAllReviewsLoaded) {
|
|
135
116
|
setSize(size + 1);
|
|
136
117
|
}
|
|
137
|
-
}, [isLoading, isValidating, setSize, size]);
|
|
118
|
+
}, [isLoading, isValidating, setSize, size, isAllReviewsLoaded]);
|
|
138
119
|
useEffect(() => {
|
|
139
120
|
if (inView) {
|
|
140
121
|
loadMore();
|
|
141
122
|
}
|
|
142
123
|
}, [inView, loadMore]);
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
isEndReached.current = false;
|
|
145
|
-
}, [props]);
|
|
146
124
|
return {
|
|
147
125
|
data: searchResponse || {},
|
|
148
126
|
error: errorInfinite,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const useTap: (tapThreshold?: number) => {
|
|
3
|
+
onTap: (handler: (event: any) => void) => (event: any) => void;
|
|
4
|
+
isPressed: boolean;
|
|
5
|
+
ref: React.MutableRefObject<null>;
|
|
6
|
+
};
|
|
7
|
+
export { useTap };
|
|
8
|
+
//# sourceMappingURL=use-tap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-tap.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-tap.ts"],"names":[],"mappings":"AACA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAuFvE,QAAA,MAAM,MAAM;6BAuBkC,GAAG,KAAK,IAAI,aACvC,GAAG;;;CAerB,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useEffect, useCallback, useRef } from "react";
|
|
3
|
+
// Shared manager for all instances of the hook
|
|
4
|
+
const tapManager = (() => {
|
|
5
|
+
const elements = new Map();
|
|
6
|
+
let isListening = false;
|
|
7
|
+
const startListening = () => {
|
|
8
|
+
if (isListening)
|
|
9
|
+
return;
|
|
10
|
+
const handleTouchStart = (e) => {
|
|
11
|
+
const touch = e.touches[0];
|
|
12
|
+
elements.forEach((data, el) => {
|
|
13
|
+
if (el.contains(touch.target)) {
|
|
14
|
+
data.touchStarted = true;
|
|
15
|
+
data.touchMoved = false;
|
|
16
|
+
data.startPosition = { x: touch.clientX, y: touch.clientY };
|
|
17
|
+
// Don't set isPressed here, wait to determine if it's a tap or drag
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const handleTouchMove = (e) => {
|
|
22
|
+
const touch = e.touches[0];
|
|
23
|
+
elements.forEach((data, el) => {
|
|
24
|
+
if (data.touchStarted) {
|
|
25
|
+
const deltaX = Math.abs(touch.clientX - data.startPosition.x);
|
|
26
|
+
const deltaY = Math.abs(touch.clientY - data.startPosition.y);
|
|
27
|
+
if (deltaX > data.tapThreshold || deltaY > data.tapThreshold) {
|
|
28
|
+
data.touchMoved = true;
|
|
29
|
+
data.setIsPressed(false);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const handleTouchEnd = () => {
|
|
35
|
+
elements.forEach((data) => {
|
|
36
|
+
if (data.touchStarted) {
|
|
37
|
+
data.touchStarted = false;
|
|
38
|
+
if (!data.touchMoved) {
|
|
39
|
+
// It's a tap, set isPressed briefly
|
|
40
|
+
data.setIsPressed(true);
|
|
41
|
+
setTimeout(() => data.setIsPressed(false), 100);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
document.addEventListener("touchstart", (e) => handleTouchStart(e), { passive: true });
|
|
47
|
+
document.addEventListener("touchmove", (e) => handleTouchMove(e), { passive: true });
|
|
48
|
+
document.addEventListener("touchend", () => handleTouchEnd(), {
|
|
49
|
+
passive: true,
|
|
50
|
+
});
|
|
51
|
+
isListening = true;
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
register: (el, data) => {
|
|
55
|
+
elements.set(el, data);
|
|
56
|
+
startListening();
|
|
57
|
+
},
|
|
58
|
+
unregister: (el) => {
|
|
59
|
+
elements.delete(el);
|
|
60
|
+
},
|
|
61
|
+
elements,
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
64
|
+
const useTap = (tapThreshold = 10) => {
|
|
65
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
66
|
+
const elementRef = useRef(null);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const element = elementRef.current;
|
|
69
|
+
if (!element)
|
|
70
|
+
return;
|
|
71
|
+
const data = {
|
|
72
|
+
touchStarted: false,
|
|
73
|
+
touchMoved: false,
|
|
74
|
+
startPosition: { x: 0, y: 0 },
|
|
75
|
+
setIsPressed,
|
|
76
|
+
tapThreshold,
|
|
77
|
+
};
|
|
78
|
+
tapManager.register(element, data);
|
|
79
|
+
return () => {
|
|
80
|
+
tapManager.unregister(element);
|
|
81
|
+
};
|
|
82
|
+
}, [tapThreshold]);
|
|
83
|
+
const onTap = useCallback((handler) => {
|
|
84
|
+
return (event) => {
|
|
85
|
+
const data = tapManager.elements.get(elementRef.current);
|
|
86
|
+
if (!data)
|
|
87
|
+
return;
|
|
88
|
+
if (event.type === "touchend" && !data.touchMoved) {
|
|
89
|
+
handler(event);
|
|
90
|
+
}
|
|
91
|
+
else if (event.type === "click" && !data.touchStarted) {
|
|
92
|
+
handler(event);
|
|
93
|
+
setIsPressed(true);
|
|
94
|
+
setTimeout(() => setIsPressed(false), 100);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
98
|
+
return { onTap, isPressed, ref: elementRef };
|
|
99
|
+
};
|
|
100
|
+
export { useTap };
|
|
@@ -17,7 +17,6 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
17
17
|
iconStrokeColor?: string;
|
|
18
18
|
iconClassName?: string;
|
|
19
19
|
iconPosition?: "left" | "right";
|
|
20
|
-
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
21
20
|
}
|
|
22
21
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
23
22
|
declare const getButtonProps: (buttonConfig: TextStyle & BackgroundAndPadding & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAGL,KAAK,EAEL,SAAS,EAET,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAGL,KAAK,EAEL,SAAS,EAET,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAIxB,QAAA,MAAM,cAAc;;;mFAgCnB,CAAA;AAwCD,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAChC;AAED,QAAA,MAAM,MAAM,uFAsGX,CAAA;AAGD,QAAA,MAAM,cAAc,iBACJ,SAAS,GACrB,oBAAoB,GAAG;IACrB,SAAS,EAAE,KAAK,CAAA;IAChB,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5B,gBAAgB,EAAE,OAAO,CAAA;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBJ,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -16,8 +16,6 @@ import { cva } from "class-variance-authority";
|
|
|
16
16
|
import { cn, getColor, getTextStyle, getBackgroundAndPaddingStyle, } from "../../lib/utils";
|
|
17
17
|
import { Icon } from "./icon";
|
|
18
18
|
import { Text } from "./text";
|
|
19
|
-
import { useTap } from "./tap";
|
|
20
|
-
import { useMergeRefs } from "../hooks/use-merge-refs";
|
|
21
19
|
const buttonVariants = cva("w-full flex rounded items-center justify-center transition-colors disabled:bg-stateColors-disabled disabled:border-stateColors-disabled disabled:pointer-events-none ring-offset-background overflow-elipse whitespace-nowrap truncate active:opacity-70 disabled:opacity-70 cursor-pointer", {
|
|
22
20
|
variants: {
|
|
23
21
|
size: {
|
|
@@ -81,9 +79,7 @@ const labelVariants = cva("truncate", {
|
|
|
81
79
|
},
|
|
82
80
|
});
|
|
83
81
|
const Button = React.forwardRef((_a, ref) => {
|
|
84
|
-
var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon, iconColor, iconStrokeColor, iconPosition, iconSize, iconUrl, iconClassName
|
|
85
|
-
const { onTap, isPressed, ref: tapRef } = useTap();
|
|
86
|
-
const mergedRef = useMergeRefs(ref, tapRef);
|
|
82
|
+
var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon, iconColor, iconStrokeColor, iconPosition, iconSize, iconUrl, iconClassName } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "variant", "size", "asChild", "loading", "icon", "iconColor", "iconStrokeColor", "iconPosition", "iconSize", "iconUrl", "iconClassName"]);
|
|
87
83
|
const Comp = asChild ? Slot : "button";
|
|
88
84
|
const IconButton = () => icon || iconUrl ? (_jsx(Icon, { name: icon, url: iconUrl, size: "sm", style: { color: iconColor } })) : null;
|
|
89
85
|
const BasicButton = () => (_jsxs(_Fragment, { children: [icon || iconUrl ? (_jsx(Icon, { name: iconUrl ? undefined : icon, url: iconUrl, size: iconSize || variant === "quickadd" ? "xs" : "sm", className: cn(iconVariants({ variant }), {
|
|
@@ -94,7 +90,7 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
94
90
|
return (_jsx(Comp, Object.assign({ className: cn(buttonVariants({ variant, size }), className, {
|
|
95
91
|
"pointer-events-none": loading,
|
|
96
92
|
"flex-row-reverse": (icon || iconUrl) && iconPosition === "right",
|
|
97
|
-
}), ref:
|
|
93
|
+
}), ref: ref }, props, { children: loading ? (_jsx(LoadingButton, {})) : typeof props.children === "object" &&
|
|
98
94
|
React.isValidElement(props.children) ? ( // if children are passed as a valid React element
|
|
99
95
|
props.children // render it
|
|
100
96
|
) : // otherwise use props
|
|
@@ -122,7 +122,7 @@ const CarouselPrevious = React.forwardRef((_a, ref) => {
|
|
|
122
122
|
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
123
123
|
return (_jsxs(Button, Object.assign({ ref: ref, variant: variant, size: size, className: cn("absolute h-8 w-8 rounded-full", orientation === "horizontal"
|
|
124
124
|
? "-left-12 top-1/2 -translate-y-1/2"
|
|
125
|
-
: "-top-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollPrev
|
|
125
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollPrev, onClick: scrollPrev }, props, { children: [_jsx(ArrowLeft, { className: "h-4 w-4" }), _jsx("span", Object.assign({ className: "sr-only" }, { children: "Previous slide" }))] })));
|
|
126
126
|
});
|
|
127
127
|
CarouselPrevious.displayName = "CarouselPrevious";
|
|
128
128
|
const CarouselNext = React.forwardRef((_a, ref) => {
|
|
@@ -130,7 +130,7 @@ const CarouselNext = React.forwardRef((_a, ref) => {
|
|
|
130
130
|
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
131
131
|
return (_jsxs(Button, Object.assign({ ref: ref, variant: variant, size: size, className: cn("absolute h-8 w-8 rounded-full", orientation === "horizontal"
|
|
132
132
|
? "-right-12 top-1/2 -translate-y-1/2"
|
|
133
|
-
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollNext
|
|
133
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollNext, onClick: scrollNext }, props, { children: [_jsx(ArrowRight, { className: "h-4 w-4" }), _jsx("span", Object.assign({ className: "sr-only" }, { children: "Next slide" }))] })));
|
|
134
134
|
});
|
|
135
135
|
CarouselNext.displayName = "CarouselNext";
|
|
136
136
|
const CarouselDots = React.forwardRef((_a, ref) => {
|
|
@@ -5,27 +5,33 @@ type DrawerTriggerProps = React.ComponentPropsWithoutRef<"button"> & {
|
|
|
5
5
|
};
|
|
6
6
|
type DrawerPortalProps = {
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
+
containerRef?: HTMLElement;
|
|
8
9
|
};
|
|
9
10
|
type DrawerCloseProps = React.ComponentPropsWithoutRef<"button"> & {
|
|
10
11
|
asChild?: boolean;
|
|
11
12
|
};
|
|
12
13
|
declare const DrawerTrigger: React.FC<DrawerTriggerProps>;
|
|
13
|
-
declare const DrawerPortal:
|
|
14
|
+
declare const DrawerPortal: {
|
|
15
|
+
({ children, containerRef }: DrawerPortalProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
14
18
|
declare const DrawerClose: React.FC<DrawerCloseProps>;
|
|
15
19
|
type DrawerProps = React.ComponentProps<typeof DrawerPrimitive.Root> & {
|
|
16
20
|
containerRef?: HTMLElement;
|
|
17
21
|
};
|
|
18
22
|
declare const Drawer: {
|
|
19
|
-
({ shouldScaleBackground, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
({ shouldScaleBackground, containerRef, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
20
24
|
displayName: string;
|
|
21
25
|
};
|
|
22
26
|
declare const DrawerOverlay: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
23
27
|
backdropHexColor?: string | undefined;
|
|
28
|
+
containerRef?: HTMLElement | undefined;
|
|
24
29
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
25
30
|
declare const DrawerContentBase: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
26
31
|
hideBackdrop?: boolean | undefined;
|
|
27
32
|
backdropHexColor?: string | undefined;
|
|
28
33
|
isSheet?: boolean | undefined;
|
|
34
|
+
containerRef?: HTMLElement | undefined;
|
|
29
35
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
30
36
|
declare const DrawerFooter: {
|
|
31
37
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../../components/ui/drawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../../components/ui/drawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,MAAM,CAAA;AAKhD,KAAK,kBAAkB,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,WAAW,CAAA;CAC3B,CAAA;AAED,KAAK,gBAAgB,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,QAAA,MAAM,aAAa,8BAA0D,CAAA;AAG7E,QAAA,MAAM,YAAY;iCAAgC,iBAAiB;;CAKlE,CAAA;AAGD,QAAA,MAAM,WAAW,4BAAsD,CAAA;AAGvE,KAAK,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG;IACrE,YAAY,CAAC,EAAE,WAAW,CAAA;CAC3B,CAAA;AAED,QAAA,MAAM,MAAM;wDAIT,WAAW;;CAgBb,CAAA;AAQD,QAAA,MAAM,aAAa;;;wCAsBlB,CAAA;AAUD,QAAA,MAAM,iBAAiB;;;;;wCAiDtB,CAAA;AA0BD,QAAA,MAAM,YAAY;8BAGf,MAAM,cAAc,CAAC,cAAc,CAAC;;CAQtC,CAAA;AAGD,QAAA,MAAM,iBAAiB,qLASrB,CAAA;AAGF,KAAK,iBAAiB,GAAG;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;CACjD,CAAA;AAED,QAAA,MAAM,YAAY,0DAKf,iBAAiB,4CA8BnB,CAAA;AAED,QAAA,MAAM,aAAa,sCAIhB,MAAM,cAAc,CAAC,cAAc,CAAC,4CAMtC,CAAA;AAED,OAAO,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,CAAA"}
|
|
@@ -15,29 +15,40 @@ import * as React from "react";
|
|
|
15
15
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
16
16
|
import { cn } from "../../lib/utils";
|
|
17
17
|
import { Icon } from "./icon";
|
|
18
|
+
import ReactDOM from "react-dom";
|
|
18
19
|
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
19
20
|
DrawerTrigger.displayName = "DrawerTrigger";
|
|
20
|
-
const DrawerPortal =
|
|
21
|
+
const DrawerPortal = ({ children, containerRef }) => {
|
|
22
|
+
if (containerRef) {
|
|
23
|
+
return ReactDOM.createPortal(children, containerRef);
|
|
24
|
+
}
|
|
25
|
+
return _jsx(DrawerPrimitive.Portal, { children: children });
|
|
26
|
+
};
|
|
21
27
|
DrawerPortal.displayName = "DrawerPortal";
|
|
22
28
|
const DrawerClose = DrawerPrimitive.Close;
|
|
23
29
|
DrawerClose.displayName = "DrawerClose";
|
|
24
30
|
const Drawer = (_a) => {
|
|
25
|
-
var { shouldScaleBackground } = _a, props = __rest(_a, ["shouldScaleBackground"]);
|
|
26
|
-
return (_jsx(DrawerPrimitive.Root, Object.assign({ shouldScaleBackground: true }, props, { noBodyStyles: true, disablePreventScroll: true })
|
|
31
|
+
var { shouldScaleBackground, containerRef } = _a, props = __rest(_a, ["shouldScaleBackground", "containerRef"]);
|
|
32
|
+
return (_jsx(DrawerPrimitive.Root, Object.assign({ shouldScaleBackground: true }, props, { noBodyStyles: true, disablePreventScroll: true }, { children: React.Children.map(props.children, (child) => {
|
|
33
|
+
if (React.isValidElement(child)) {
|
|
34
|
+
return React.cloneElement(child, { containerRef });
|
|
35
|
+
}
|
|
36
|
+
return child;
|
|
37
|
+
}) })));
|
|
27
38
|
};
|
|
28
39
|
Drawer.displayName = "Drawer";
|
|
29
40
|
const DrawerOverlay = React.forwardRef((_a, ref) => {
|
|
30
|
-
var { className, backdropHexColor = "#000000" } = _a, props = __rest(_a, ["className", "backdropHexColor"]);
|
|
31
|
-
const style = { backgroundColor: `${backdropHexColor}CC` };
|
|
32
|
-
return (_jsx(DrawerPrimitive.Overlay, Object.assign({ style: style, ref: ref, className: cn(`fixed inset-0 z-50`, className) }, props)));
|
|
41
|
+
var { className, backdropHexColor = "#000000", containerRef } = _a, props = __rest(_a, ["className", "backdropHexColor", "containerRef"]);
|
|
42
|
+
const style = Object.assign({ backgroundColor: `${backdropHexColor}CC` }, (containerRef && { position: "absolute" }));
|
|
43
|
+
return (_jsx(DrawerPrimitive.Overlay, Object.assign({ style: style, ref: ref, className: cn(`fixed inset-0 z-50`, containerRef && "absolute", className) }, props)));
|
|
33
44
|
});
|
|
34
45
|
DrawerOverlay.displayName = "DrawerOverlay";
|
|
35
46
|
const DrawerContentBase = React.forwardRef((_a, ref) => {
|
|
36
|
-
var { className, children, hideBackdrop = false, backdropHexColor, isSheet = false,
|
|
37
|
-
const styles = isSheet
|
|
47
|
+
var { className, children, hideBackdrop = false, backdropHexColor, isSheet = false, containerRef } = _a, props = __rest(_a, ["className", "children", "hideBackdrop", "backdropHexColor", "isSheet", "containerRef"]);
|
|
48
|
+
const styles = Object.assign(Object.assign({}, (isSheet
|
|
38
49
|
? { height: "calc(100vh - 112px)" }
|
|
39
|
-
: { maxHeight: "calc(100vh - 112px)" };
|
|
40
|
-
return (_jsxs(DrawerPortal, { children: [hideBackdrop ? null : (_jsx(DrawerOverlay, { backdropHexColor: backdropHexColor })), _jsxs(DrawerPrimitive.Content, Object.assign({ ref: ref, style: styles, className: cn("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground", className) }, props, { "data-testid": "drawer-content" }, { children: [_jsx("div", { className: "mx-auto mb-2 mt-2 h-[4px] w-[40px] rounded-full bg-coreColors-dividingLines" }), children] }))] }));
|
|
50
|
+
: { maxHeight: "calc(100vh - 112px)" })), (containerRef && { position: "absolute" }));
|
|
51
|
+
return (_jsxs(DrawerPortal, Object.assign({ containerRef: containerRef }, { children: [hideBackdrop ? null : (_jsx(DrawerOverlay, { backdropHexColor: backdropHexColor, containerRef: containerRef })), _jsxs(DrawerPrimitive.Content, Object.assign({ ref: ref, style: styles, className: cn("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground", containerRef && "absolute", className) }, props, { "data-testid": "drawer-content" }, { children: [_jsx("div", { className: "mx-auto mb-2 mt-2 h-[4px] w-[40px] rounded-full bg-coreColors-dividingLines" }), children] }))] })));
|
|
41
52
|
});
|
|
42
53
|
DrawerContentBase.displayName = "DrawerContentBase";
|
|
43
54
|
const DrawerHeaderBase = (_a) => {
|
|
@@ -65,6 +76,6 @@ const DrawerHeader = ({ title, iconLeftName, iconRightName, onCloseClick, }) =>
|
|
|
65
76
|
};
|
|
66
77
|
const DrawerContent = (_a) => {
|
|
67
78
|
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
68
|
-
return _jsx("div", Object.assign({ className: cn("h-full overflow-scroll", className) }, props, { children: children }));
|
|
79
|
+
return (_jsx("div", Object.assign({ className: cn("h-full overflow-scroll", className) }, props, { children: children })));
|
|
69
80
|
};
|
|
70
81
|
export { Drawer, DrawerPortal, DrawerOverlay, DrawerTrigger, DrawerClose, DrawerContentBase, DrawerContent, DrawerFooter, DrawerDescription, DrawerHeader, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../../components/ui/tap.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAMZ,SAAS,EACV,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../../components/ui/tap.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAMZ,SAAS,EACV,MAAM,OAAO,CAAA;AAuFd,QAAA,MAAM,MAAM;6BAuBkC,GAAG,KAAK,IAAI,aACvC,GAAG;;;CAerB,CAAA;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,QAAA,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAuC3B,CAAA;AAED,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React, { useState, useEffect, useCallback, useRef, } from "react";
|
|
4
|
-
// @ts-ignore -- webbridge-react is not typed (yet)
|
|
5
|
-
import { useActions } from "@tapcart/webbridge-react";
|
|
6
4
|
// Shared manager for all instances of the hook
|
|
7
5
|
const tapManager = (() => {
|
|
8
6
|
const elements = new Map();
|
|
@@ -67,7 +65,6 @@ const tapManager = (() => {
|
|
|
67
65
|
const useTap = (tapThreshold = 10) => {
|
|
68
66
|
const [isPressed, setIsPressed] = useState(false);
|
|
69
67
|
const elementRef = useRef(null);
|
|
70
|
-
const webbridgeActions = useActions();
|
|
71
68
|
useEffect(() => {
|
|
72
69
|
const element = elementRef.current;
|
|
73
70
|
if (!element)
|
|
@@ -86,22 +83,19 @@ const useTap = (tapThreshold = 10) => {
|
|
|
86
83
|
}, [tapThreshold]);
|
|
87
84
|
const onTap = useCallback((handler) => {
|
|
88
85
|
return (event) => {
|
|
89
|
-
var _a, _b;
|
|
90
86
|
const data = tapManager.elements.get(elementRef.current);
|
|
91
87
|
if (!data)
|
|
92
88
|
return;
|
|
93
89
|
if (event.type === "touchend" && !data.touchMoved) {
|
|
94
90
|
handler(event);
|
|
95
|
-
(_a = webbridgeActions.action) === null || _a === void 0 ? void 0 : _a.call(webbridgeActions, "trigger/haptic");
|
|
96
91
|
}
|
|
97
92
|
else if (event.type === "click" && !data.touchStarted) {
|
|
98
93
|
handler(event);
|
|
99
|
-
(_b = webbridgeActions.action) === null || _b === void 0 ? void 0 : _b.call(webbridgeActions, "trigger/haptic");
|
|
100
94
|
setIsPressed(true);
|
|
101
95
|
setTimeout(() => setIsPressed(false), 100);
|
|
102
96
|
}
|
|
103
97
|
};
|
|
104
|
-
}, [
|
|
98
|
+
}, []);
|
|
105
99
|
return { onTap, isPressed, ref: elementRef };
|
|
106
100
|
};
|
|
107
101
|
const Tap = ({ children }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video-enhanced.d.ts","sourceRoot":"","sources":["../../../components/ui/video-enhanced.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,UAAU,UAAW,SAAQ,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC;IACtE,GAAG,EAAE,MAAM,CAAA;IACX,eAAe,EAAE,eAAe,CAAA;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"video-enhanced.d.ts","sourceRoot":"","sources":["../../../components/ui/video-enhanced.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,UAAU,UAAW,SAAQ,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC;IACtE,GAAG,EAAE,MAAM,CAAA;IACX,eAAe,EAAE,eAAe,CAAA;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,KAAK,qFAkOV,CAAA;AAID,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,CAAA"}
|
|
@@ -29,38 +29,45 @@ const videoVariants = {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
const Video = React.forwardRef((_a, ref) => {
|
|
32
|
+
var _b;
|
|
32
33
|
var { src, videoAttributes, naturalAspectRatio = "1/1", className } = _a, props = __rest(_a, ["src", "videoAttributes", "naturalAspectRatio", "className"]);
|
|
33
|
-
const autoPlayEnabled = videoAttributes.autoplay && !videoAttributes.videoSound;
|
|
34
34
|
const internalRef = React.useRef(null);
|
|
35
35
|
const videoRef = ref || internalRef;
|
|
36
|
+
const playAttemptRef = React.useRef(false);
|
|
36
37
|
const observerRef = React.useRef(null);
|
|
37
38
|
const lastPositionRef = React.useRef(0);
|
|
38
39
|
const [isLoaded, setIsLoaded] = React.useState(false);
|
|
39
40
|
const [isVisible, setIsVisible] = React.useState(false);
|
|
40
41
|
const [isPlaying, setIsPlaying] = React.useState(false);
|
|
41
|
-
const
|
|
42
|
+
const setupVideo = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
43
|
const video = videoRef.current;
|
|
43
44
|
if (!video)
|
|
44
45
|
return;
|
|
45
46
|
try {
|
|
46
47
|
video.currentTime = lastPositionRef.current;
|
|
47
|
-
|
|
48
|
+
if (!videoAttributes.videoSound) {
|
|
49
|
+
video.muted = true;
|
|
50
|
+
}
|
|
48
51
|
yield video.play();
|
|
49
|
-
|
|
52
|
+
setIsPlaying(true);
|
|
53
|
+
playAttemptRef.current = true;
|
|
54
|
+
// If sound is enabled and autoplay was successful, unmute
|
|
55
|
+
if (videoAttributes.videoSound && videoAttributes.autoplay) {
|
|
50
56
|
video.muted = false;
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
catch (error) {
|
|
54
60
|
console.error("Error playing video:", error);
|
|
61
|
+
setIsPlaying(false);
|
|
55
62
|
}
|
|
56
|
-
}), [
|
|
63
|
+
}), [videoAttributes.autoplay, videoAttributes.videoSound, videoRef]);
|
|
57
64
|
const handlePlayPause = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
65
|
const video = videoRef.current;
|
|
59
66
|
if (!video)
|
|
60
67
|
return;
|
|
61
68
|
if (video.paused) {
|
|
62
69
|
try {
|
|
63
|
-
yield
|
|
70
|
+
yield setupVideo();
|
|
64
71
|
}
|
|
65
72
|
catch (error) {
|
|
66
73
|
console.error("Error playing video:", error);
|
|
@@ -68,9 +75,9 @@ const Video = React.forwardRef((_a, ref) => {
|
|
|
68
75
|
}
|
|
69
76
|
else {
|
|
70
77
|
video.pause();
|
|
78
|
+
setIsPlaying(false);
|
|
71
79
|
}
|
|
72
80
|
});
|
|
73
|
-
// intersection observer setup
|
|
74
81
|
React.useEffect(() => {
|
|
75
82
|
const video = videoRef.current;
|
|
76
83
|
if (!video)
|
|
@@ -81,11 +88,15 @@ const Video = React.forwardRef((_a, ref) => {
|
|
|
81
88
|
setIsVisible(entry.isIntersecting);
|
|
82
89
|
// Handle visibility change
|
|
83
90
|
if (!entry.isIntersecting && !video.paused) {
|
|
91
|
+
lastPositionRef.current = video.currentTime;
|
|
84
92
|
video.pause();
|
|
93
|
+
setIsPlaying(false);
|
|
85
94
|
}
|
|
86
|
-
else if (entry.isIntersecting &&
|
|
95
|
+
else if (entry.isIntersecting &&
|
|
96
|
+
videoAttributes.autoplay &&
|
|
97
|
+
video.paused) {
|
|
87
98
|
video.currentTime = lastPositionRef.current;
|
|
88
|
-
|
|
99
|
+
setupVideo();
|
|
89
100
|
}
|
|
90
101
|
}, {
|
|
91
102
|
threshold: 0.1, // 10% of the video needs to be visible
|
|
@@ -98,28 +109,42 @@ const Video = React.forwardRef((_a, ref) => {
|
|
|
98
109
|
video.addEventListener("play", handlePlay);
|
|
99
110
|
video.addEventListener("pause", handlePause);
|
|
100
111
|
return () => {
|
|
112
|
+
if (video && !video.paused) {
|
|
113
|
+
lastPositionRef.current = video.currentTime;
|
|
114
|
+
}
|
|
101
115
|
if (observerRef.current) {
|
|
102
116
|
observerRef.current.disconnect();
|
|
103
117
|
}
|
|
104
118
|
video.removeEventListener("play", handlePlay);
|
|
105
119
|
video.removeEventListener("pause", handlePause);
|
|
120
|
+
playAttemptRef.current = false;
|
|
106
121
|
};
|
|
107
|
-
}, [
|
|
108
|
-
//
|
|
109
|
-
// pause video when not visible
|
|
110
|
-
// play video when visible and autoplay is on
|
|
122
|
+
}, [setupVideo, videoAttributes.autoplay, videoRef]);
|
|
123
|
+
// Handle attribute changes
|
|
111
124
|
React.useEffect(() => {
|
|
112
125
|
const video = videoRef.current;
|
|
113
126
|
if (!video)
|
|
114
127
|
return;
|
|
115
|
-
if (isVisible &&
|
|
116
|
-
|
|
128
|
+
if (isVisible && videoAttributes.autoplay) {
|
|
129
|
+
setupVideo();
|
|
117
130
|
}
|
|
118
131
|
else if (!isVisible && !video.paused) {
|
|
132
|
+
lastPositionRef.current = video.currentTime;
|
|
119
133
|
video.pause();
|
|
134
|
+
setIsPlaying(false);
|
|
120
135
|
}
|
|
121
|
-
|
|
122
|
-
|
|
136
|
+
return () => {
|
|
137
|
+
if (video && !video.paused) {
|
|
138
|
+
lastPositionRef.current = video.currentTime;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}, [
|
|
142
|
+
videoAttributes.autoplay,
|
|
143
|
+
videoAttributes.videoSound,
|
|
144
|
+
isVisible,
|
|
145
|
+
videoRef,
|
|
146
|
+
setupVideo,
|
|
147
|
+
]);
|
|
123
148
|
React.useEffect(() => {
|
|
124
149
|
const video = videoRef.current;
|
|
125
150
|
if (!video)
|
|
@@ -132,14 +157,14 @@ const Video = React.forwardRef((_a, ref) => {
|
|
|
132
157
|
video.removeEventListener("timeupdate", handleTimeUpdate);
|
|
133
158
|
};
|
|
134
159
|
}, [videoRef]);
|
|
135
|
-
// metadata setup
|
|
160
|
+
// Initial load and metadata setup - only needs to run when src changes
|
|
136
161
|
React.useEffect(() => {
|
|
137
162
|
const video = videoRef.current;
|
|
138
163
|
if (!video)
|
|
139
164
|
return;
|
|
140
165
|
const handleLoadedMetadata = () => {
|
|
141
166
|
setIsLoaded(true);
|
|
142
|
-
if (
|
|
167
|
+
if (videoAttributes.autoplay && isVisible) {
|
|
143
168
|
const currentTime = lastPositionRef.current;
|
|
144
169
|
video.currentTime = currentTime;
|
|
145
170
|
video.play().catch((error) => {
|
|
@@ -148,16 +173,15 @@ const Video = React.forwardRef((_a, ref) => {
|
|
|
148
173
|
}
|
|
149
174
|
};
|
|
150
175
|
video.addEventListener("loadedmetadata", handleLoadedMetadata);
|
|
176
|
+
video.load();
|
|
151
177
|
return () => {
|
|
152
178
|
video.removeEventListener("loadedmetadata", handleLoadedMetadata);
|
|
153
179
|
};
|
|
154
|
-
}, []);
|
|
180
|
+
}, [src]);
|
|
155
181
|
React.useEffect(() => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
video.load();
|
|
160
|
-
}, [videoRef]);
|
|
182
|
+
lastPositionRef.current = 0;
|
|
183
|
+
setIsLoaded(false);
|
|
184
|
+
}, [src]);
|
|
161
185
|
const videoStyle = {
|
|
162
186
|
aspectRatio: videoAttributes.enabled && videoAttributes.aspectRatio !== "auto"
|
|
163
187
|
? videoAttributes.aspectRatio.replace(":", "/")
|
|
@@ -165,7 +189,9 @@ const Video = React.forwardRef((_a, ref) => {
|
|
|
165
189
|
};
|
|
166
190
|
return (_jsxs("div", Object.assign({ className: "relative w-full" }, { children: [_jsx("video", Object.assign({ ref: videoRef, className: cn(videoVariants.base, videoAttributes.videoFit === "fill"
|
|
167
191
|
? videoVariants.fit.cover
|
|
168
|
-
: videoVariants.fit.contain, className), style: videoStyle, preload: "metadata", playsInline: true, loop: videoAttributes.enabled, controls: false, src: src }, props)), isLoaded && !isPlaying
|
|
192
|
+
: videoVariants.fit.contain, className), style: videoStyle, preload: "metadata", playsInline: true, loop: videoAttributes.enabled, controls: false, src: src }, props)), ((isLoaded && !isPlaying) ||
|
|
193
|
+
(videoAttributes.videoSound && ((_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.muted))) &&
|
|
194
|
+
videoAttributes.enabled && (_jsx("button", Object.assign({ onClick: handlePlayPause, className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-50\n w-16 h-16 rounded-full bg-black/75 hover:bg-black/90 \n flex items-center justify-center transition-all duration-300\n hover:scale-110 focus:outline-none focus:ring-2 focus:ring-white", "aria-label": "Play video" }, { children: _jsx("div", { className: "w-0 h-0 border-y-8 border-y-transparent \n border-l-[16px] border-l-white \n translate-x-[2px]" }) })))] })));
|
|
169
195
|
});
|
|
170
196
|
Video.displayName = "Video";
|
|
171
197
|
export { Video as VideoEnhanced };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10-beta.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"@radix-ui/react-toggle": "^1.0.3",
|
|
66
66
|
"@radix-ui/react-toggle-group": "^1.0.4",
|
|
67
67
|
"@tabler/icons-react": "^3.2.0",
|
|
68
|
-
"@tapcart/webbridge-react": "^1.13.0",
|
|
69
68
|
"class-variance-authority": "^0.6.0",
|
|
70
69
|
"clsx": "^1.2.1",
|
|
71
70
|
"dayjs": "^1.11.13",
|
|
@@ -81,4 +80,4 @@
|
|
|
81
80
|
"tailwindcss-animate": "^1.0.6",
|
|
82
81
|
"vaul": "0.9.1"
|
|
83
82
|
}
|
|
84
|
-
}
|
|
83
|
+
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
type BorderSide = "all" | "top" | "bottom" | "left" | "right";
|
|
2
|
-
type BorderSides = BorderSide[];
|
|
3
|
-
declare const getBorderSidesStyle: (borderSides: BorderSides) => {
|
|
4
|
-
borderWidth: string;
|
|
5
|
-
borderTopWidth?: undefined;
|
|
6
|
-
borderBottomWidth?: undefined;
|
|
7
|
-
borderLeftWidth?: undefined;
|
|
8
|
-
borderRightWidth?: undefined;
|
|
9
|
-
} | {
|
|
10
|
-
borderTopWidth: string | number;
|
|
11
|
-
borderBottomWidth: string | number;
|
|
12
|
-
borderLeftWidth: string | number;
|
|
13
|
-
borderRightWidth: string | number;
|
|
14
|
-
borderWidth?: undefined;
|
|
15
|
-
};
|
|
16
|
-
type VerticalAlignment = "top" | "middle" | "bottom";
|
|
17
|
-
type Spacing = {
|
|
18
|
-
top: number;
|
|
19
|
-
bottom: number;
|
|
20
|
-
left: number;
|
|
21
|
-
right: number;
|
|
22
|
-
};
|
|
23
|
-
interface AlignmentAndSpacing {
|
|
24
|
-
alignment: VerticalAlignment;
|
|
25
|
-
spacing: Spacing;
|
|
26
|
-
}
|
|
27
|
-
declare const getVerticalAlignmentStyle: (alignmentAndSpacing: AlignmentAndSpacing) => {
|
|
28
|
-
bottom: string;
|
|
29
|
-
top: string;
|
|
30
|
-
transform?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
top: string;
|
|
33
|
-
transform: string;
|
|
34
|
-
bottom?: undefined;
|
|
35
|
-
} | {
|
|
36
|
-
bottom?: undefined;
|
|
37
|
-
top?: undefined;
|
|
38
|
-
transform?: undefined;
|
|
39
|
-
};
|
|
40
|
-
type BackgroundAndPadding = {
|
|
41
|
-
backgroundColor?: ColorOption;
|
|
42
|
-
borderSides?: BorderSides;
|
|
43
|
-
borderColor?: ColorOption;
|
|
44
|
-
cornerRadius?: number;
|
|
45
|
-
padding?: Partial<Spacing>;
|
|
46
|
-
};
|
|
47
|
-
type ColorOption = {
|
|
48
|
-
type: "brand-kit" | "custom";
|
|
49
|
-
value: string;
|
|
50
|
-
} | undefined;
|
|
51
|
-
declare const getColor: (colorOption: ColorOption) => string | undefined;
|
|
52
|
-
type BackgroundAndSpacing = AlignmentAndSpacing & {
|
|
53
|
-
backgroundColor?: ColorOption;
|
|
54
|
-
borderColor?: ColorOption;
|
|
55
|
-
backgroundCorners?: number;
|
|
56
|
-
};
|
|
57
|
-
type TextStyle = {
|
|
58
|
-
font: {
|
|
59
|
-
family: string;
|
|
60
|
-
weight: number | string;
|
|
61
|
-
};
|
|
62
|
-
size: number | string;
|
|
63
|
-
color: ColorOption;
|
|
64
|
-
uppercase: boolean;
|
|
65
|
-
textAlignment: "left" | "center" | "right" | "justify";
|
|
66
|
-
};
|
|
67
|
-
type Headline = TextStyle;
|
|
68
|
-
type Subtext = TextStyle;
|
|
69
|
-
//# sourceMappingURL=use-style-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-style-utils.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-style-utils.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAC7D,KAAK,WAAW,GAAG,UAAU,EAAE,CAAA;AAE/B,QAAA,MAAM,mBAAmB;;;;;;;;;;;;CAUxB,CAAA;AAED,KAAK,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEpD,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,iBAAiB,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,yBAAyB,wBACR,mBAAmB;;;;;;;;;;;;CAczC,CAAA;AAED,KAAK,oBAAoB,GAAG;IAC1B,eAAe,CAAC,EAAE,WAAW,CAAA;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAC3B,CAAA;AAED,KAAK,WAAW,GACZ;IACE,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;CACd,GACD,SAAS,CAAA;AAEb,QAAA,MAAM,QAAQ,gBAAiB,WAAW,KAAG,MAAM,GAAG,SAMrD,CAAA;AAqCD,KAAK,oBAAoB,GAAG,mBAAmB,GAAG;IAChD,eAAe,CAAC,EAAE,WAAW,CAAA;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAeD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KACxB,CAAA;IACD,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;CACvD,CAAA;AAED,KAAK,QAAQ,GAAG,SAAS,CAAA;AACzB,KAAK,OAAO,GAAG,SAAS,CAAA"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const getBorderSidesStyle = (borderSides) => {
|
|
3
|
-
const style = borderSides.includes("all")
|
|
4
|
-
? { borderWidth: "1px" }
|
|
5
|
-
: {
|
|
6
|
-
borderTopWidth: borderSides.includes("top") ? "1px" : 0,
|
|
7
|
-
borderBottomWidth: borderSides.includes("bottom") ? "1px" : 0,
|
|
8
|
-
borderLeftWidth: borderSides.includes("left") ? "1px" : 0,
|
|
9
|
-
borderRightWidth: borderSides.includes("right") ? "1px" : 0,
|
|
10
|
-
};
|
|
11
|
-
return style;
|
|
12
|
-
};
|
|
13
|
-
const getVerticalAlignmentStyle = (alignmentAndSpacing) => {
|
|
14
|
-
const { alignment, spacing } = alignmentAndSpacing;
|
|
15
|
-
switch (alignment) {
|
|
16
|
-
case "bottom":
|
|
17
|
-
return { bottom: `${spacing.bottom}px`, top: "auto" };
|
|
18
|
-
case "middle":
|
|
19
|
-
return { top: "50%", transform: "translateY(-50%)" };
|
|
20
|
-
case "top":
|
|
21
|
-
return { top: `${spacing.top}px`, bottom: "auto" };
|
|
22
|
-
default:
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const getColor = (colorOption) => {
|
|
27
|
-
return colorOption
|
|
28
|
-
? colorOption.type === "brand-kit"
|
|
29
|
-
? `var(--${colorOption.value})`
|
|
30
|
-
: colorOption.value
|
|
31
|
-
: undefined;
|
|
32
|
-
};
|
|
33
|
-
function getBackgroundAndPaddingStyle(backgroundAndPadding) {
|
|
34
|
-
const { backgroundColor, borderSides, borderColor, cornerRadius, padding } = backgroundAndPadding;
|
|
35
|
-
return {
|
|
36
|
-
backgroundColor: getColor(backgroundColor),
|
|
37
|
-
borderColor: getColor(borderColor),
|
|
38
|
-
borderTopWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("top")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
|
|
39
|
-
? "1px"
|
|
40
|
-
: undefined,
|
|
41
|
-
borderBottomWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("bottom")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
|
|
42
|
-
? "1px"
|
|
43
|
-
: undefined,
|
|
44
|
-
borderLeftWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("left")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
|
|
45
|
-
? "1px"
|
|
46
|
-
: undefined,
|
|
47
|
-
borderRightWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("right")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
|
|
48
|
-
? "1px"
|
|
49
|
-
: undefined,
|
|
50
|
-
paddingTop: (padding === null || padding === void 0 ? void 0 : padding.top) !== undefined ? `${padding.top}px` : undefined,
|
|
51
|
-
paddingBottom: (padding === null || padding === void 0 ? void 0 : padding.bottom) !== undefined ? `${padding.bottom}px` : undefined,
|
|
52
|
-
paddingLeft: (padding === null || padding === void 0 ? void 0 : padding.left) !== undefined ? `${padding.left}px` : undefined,
|
|
53
|
-
paddingRight: (padding === null || padding === void 0 ? void 0 : padding.right) !== undefined ? `${padding.right}px` : undefined,
|
|
54
|
-
borderStyle: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.length) ? "solid" : undefined,
|
|
55
|
-
borderRadius: cornerRadius !== undefined ? `${cornerRadius}px` : undefined,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function getBackgroundAndSpacingStyle(backgroundAndSpacing) {
|
|
59
|
-
const { spacing, borderColor, backgroundColor, backgroundCorners } = backgroundAndSpacing;
|
|
60
|
-
return {
|
|
61
|
-
padding: `${spacing.top}px ${spacing.right}px ${spacing.bottom}px ${spacing.left}px`,
|
|
62
|
-
borderColor: borderColor ? borderColor.value : "transparent",
|
|
63
|
-
backgroundColor: getColor(backgroundColor) || "transparent",
|
|
64
|
-
borderRadius: `${backgroundCorners !== null && backgroundCorners !== void 0 ? backgroundCorners : 0}px`,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function getTextStyle(textStyle) {
|
|
68
|
-
const { font, size, color, uppercase, textAlignment } = textStyle;
|
|
69
|
-
return {
|
|
70
|
-
fontFamily: font.family,
|
|
71
|
-
fontWeight: font.weight,
|
|
72
|
-
fontSize: size,
|
|
73
|
-
color: getColor(color),
|
|
74
|
-
textTransform: uppercase ? "uppercase" : "none",
|
|
75
|
-
textAlign: textAlignment,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
type BorderSide = "all" | "top" | "bottom" | "left" | "right";
|
|
2
|
-
type BorderSides = BorderSide[];
|
|
3
|
-
declare const getBorderSidesStyle: (borderSides: BorderSides) => {
|
|
4
|
-
borderWidth: string;
|
|
5
|
-
borderTopWidth?: undefined;
|
|
6
|
-
borderBottomWidth?: undefined;
|
|
7
|
-
borderLeftWidth?: undefined;
|
|
8
|
-
borderRightWidth?: undefined;
|
|
9
|
-
} | {
|
|
10
|
-
borderTopWidth: string | number;
|
|
11
|
-
borderBottomWidth: string | number;
|
|
12
|
-
borderLeftWidth: string | number;
|
|
13
|
-
borderRightWidth: string | number;
|
|
14
|
-
borderWidth?: undefined;
|
|
15
|
-
};
|
|
16
|
-
type VerticalAlignment = "top" | "middle" | "bottom";
|
|
17
|
-
type Spacing = {
|
|
18
|
-
top: number;
|
|
19
|
-
bottom: number;
|
|
20
|
-
left: number;
|
|
21
|
-
right: number;
|
|
22
|
-
};
|
|
23
|
-
interface AlignmentAndSpacing {
|
|
24
|
-
alignment: VerticalAlignment;
|
|
25
|
-
spacing: Spacing;
|
|
26
|
-
}
|
|
27
|
-
declare const getVerticalAlignmentStyle: (alignmentAndSpacing: AlignmentAndSpacing) => {
|
|
28
|
-
bottom: string;
|
|
29
|
-
top: string;
|
|
30
|
-
transform?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
top: string;
|
|
33
|
-
transform: string;
|
|
34
|
-
bottom?: undefined;
|
|
35
|
-
} | {
|
|
36
|
-
bottom?: undefined;
|
|
37
|
-
top?: undefined;
|
|
38
|
-
transform?: undefined;
|
|
39
|
-
};
|
|
40
|
-
type BackgroundAndPadding = {
|
|
41
|
-
backgroundColor?: ColorOption;
|
|
42
|
-
borderSides?: BorderSides;
|
|
43
|
-
borderColor?: ColorOption;
|
|
44
|
-
cornerRadius?: number;
|
|
45
|
-
padding?: Partial<Spacing>;
|
|
46
|
-
};
|
|
47
|
-
type ColorOption = {
|
|
48
|
-
type: "brand-kit" | "custom";
|
|
49
|
-
value: string;
|
|
50
|
-
} | undefined;
|
|
51
|
-
declare const getColor: (colorOption: ColorOption) => string | undefined;
|
|
52
|
-
declare function getBackgroundAndPaddingStyle(backgroundAndPadding: BackgroundAndPadding): {
|
|
53
|
-
backgroundColor: string | undefined;
|
|
54
|
-
borderColor: string | undefined;
|
|
55
|
-
borderTopWidth: string | undefined;
|
|
56
|
-
borderBottomWidth: string | undefined;
|
|
57
|
-
borderLeftWidth: string | undefined;
|
|
58
|
-
borderRightWidth: string | undefined;
|
|
59
|
-
paddingTop: string | undefined;
|
|
60
|
-
paddingBottom: string | undefined;
|
|
61
|
-
paddingLeft: string | undefined;
|
|
62
|
-
paddingRight: string | undefined;
|
|
63
|
-
borderStyle: string | undefined;
|
|
64
|
-
borderRadius: string | undefined;
|
|
65
|
-
};
|
|
66
|
-
type BackgroundAndSpacing = AlignmentAndSpacing & {
|
|
67
|
-
backgroundColor?: ColorOption;
|
|
68
|
-
borderColor?: ColorOption;
|
|
69
|
-
backgroundCorners?: number;
|
|
70
|
-
};
|
|
71
|
-
declare function getBackgroundAndSpacingStyle(backgroundAndSpacing: BackgroundAndSpacing): {
|
|
72
|
-
padding: string;
|
|
73
|
-
borderColor: string;
|
|
74
|
-
backgroundColor: string;
|
|
75
|
-
borderRadius: string;
|
|
76
|
-
};
|
|
77
|
-
type TextStyle = {
|
|
78
|
-
font: {
|
|
79
|
-
family: string;
|
|
80
|
-
weight: number | string;
|
|
81
|
-
};
|
|
82
|
-
size: number | string;
|
|
83
|
-
color: ColorOption;
|
|
84
|
-
uppercase: boolean;
|
|
85
|
-
textAlignment: "left" | "center" | "right" | "justify";
|
|
86
|
-
};
|
|
87
|
-
type Headline = TextStyle;
|
|
88
|
-
type Subtext = TextStyle;
|
|
89
|
-
declare function getTextStyle(textStyle: Headline | Subtext): {
|
|
90
|
-
fontFamily: string;
|
|
91
|
-
fontWeight: string | number;
|
|
92
|
-
fontSize: string | number;
|
|
93
|
-
color: string | undefined;
|
|
94
|
-
textTransform: string;
|
|
95
|
-
textAlign: "center" | "left" | "right" | "justify";
|
|
96
|
-
};
|
|
97
|
-
//# sourceMappingURL=block-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block-utils.d.ts","sourceRoot":"","sources":["../../lib/block-utils.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAC7D,KAAK,WAAW,GAAG,UAAU,EAAE,CAAA;AAE/B,QAAA,MAAM,mBAAmB;;;;;;;;;;;;CAUxB,CAAA;AAED,KAAK,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEpD,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,iBAAiB,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,yBAAyB,wBACR,mBAAmB;;;;;;;;;;;;CAczC,CAAA;AAED,KAAK,oBAAoB,GAAG;IAC1B,eAAe,CAAC,EAAE,WAAW,CAAA;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAC3B,CAAA;AAED,KAAK,WAAW,GACZ;IACE,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;CACd,GACD,SAAS,CAAA;AAEb,QAAA,MAAM,QAAQ,gBAAiB,WAAW,KAAG,MAAM,GAAG,SAMrD,CAAA;AAED,iBAAS,4BAA4B,CACnC,oBAAoB,EAAE,oBAAoB;;;;;;;;;;;;;EAgC3C;AAED,KAAK,oBAAoB,GAAG,mBAAmB,GAAG;IAChD,eAAe,CAAC,EAAE,WAAW,CAAA;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,iBAAS,4BAA4B,CACnC,oBAAoB,EAAE,oBAAoB;;;;;EAU3C;AAED,KAAK,SAAS,GAAG;IACf,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KACxB,CAAA;IACD,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;CACvD,CAAA;AAED,KAAK,QAAQ,GAAG,SAAS,CAAA;AACzB,KAAK,OAAO,GAAG,SAAS,CAAA;AAExB,iBAAS,YAAY,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO;;;;;;;EAUlD"}
|
package/dist/lib/block-utils.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const getBorderSidesStyle = (borderSides) => {
|
|
3
|
-
const style = borderSides.includes("all")
|
|
4
|
-
? { borderWidth: "1px" }
|
|
5
|
-
: {
|
|
6
|
-
borderTopWidth: borderSides.includes("top") ? "1px" : 0,
|
|
7
|
-
borderBottomWidth: borderSides.includes("bottom") ? "1px" : 0,
|
|
8
|
-
borderLeftWidth: borderSides.includes("left") ? "1px" : 0,
|
|
9
|
-
borderRightWidth: borderSides.includes("right") ? "1px" : 0,
|
|
10
|
-
};
|
|
11
|
-
return style;
|
|
12
|
-
};
|
|
13
|
-
const getVerticalAlignmentStyle = (alignmentAndSpacing) => {
|
|
14
|
-
const { alignment, spacing } = alignmentAndSpacing;
|
|
15
|
-
switch (alignment) {
|
|
16
|
-
case "bottom":
|
|
17
|
-
return { bottom: `${spacing.bottom}px`, top: "auto" };
|
|
18
|
-
case "middle":
|
|
19
|
-
return { top: "50%", transform: "translateY(-50%)" };
|
|
20
|
-
case "top":
|
|
21
|
-
return { top: `${spacing.top}px`, bottom: "auto" };
|
|
22
|
-
default:
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const getColor = (colorOption) => {
|
|
27
|
-
return colorOption
|
|
28
|
-
? colorOption.type === "brand-kit"
|
|
29
|
-
? `var(--${colorOption.value})`
|
|
30
|
-
: colorOption.value
|
|
31
|
-
: undefined;
|
|
32
|
-
};
|
|
33
|
-
function getBackgroundAndPaddingStyle(backgroundAndPadding) {
|
|
34
|
-
const { backgroundColor, borderSides, borderColor, cornerRadius, padding } = backgroundAndPadding;
|
|
35
|
-
return {
|
|
36
|
-
backgroundColor: getColor(backgroundColor),
|
|
37
|
-
borderColor: getColor(borderColor),
|
|
38
|
-
borderTopWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("top")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
|
|
39
|
-
? "1px"
|
|
40
|
-
: undefined,
|
|
41
|
-
borderBottomWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("bottom")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
|
|
42
|
-
? "1px"
|
|
43
|
-
: undefined,
|
|
44
|
-
borderLeftWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("left")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
|
|
45
|
-
? "1px"
|
|
46
|
-
: undefined,
|
|
47
|
-
borderRightWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("right")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
|
|
48
|
-
? "1px"
|
|
49
|
-
: undefined,
|
|
50
|
-
paddingTop: (padding === null || padding === void 0 ? void 0 : padding.top) !== undefined ? `${padding.top}px` : undefined,
|
|
51
|
-
paddingBottom: (padding === null || padding === void 0 ? void 0 : padding.bottom) !== undefined ? `${padding.bottom}px` : undefined,
|
|
52
|
-
paddingLeft: (padding === null || padding === void 0 ? void 0 : padding.left) !== undefined ? `${padding.left}px` : undefined,
|
|
53
|
-
paddingRight: (padding === null || padding === void 0 ? void 0 : padding.right) !== undefined ? `${padding.right}px` : undefined,
|
|
54
|
-
borderStyle: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.length) ? "solid" : undefined,
|
|
55
|
-
borderRadius: cornerRadius !== undefined ? `${cornerRadius}px` : undefined,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function getBackgroundAndSpacingStyle(backgroundAndSpacing) {
|
|
59
|
-
const { spacing, borderColor, backgroundColor, backgroundCorners } = backgroundAndSpacing;
|
|
60
|
-
return {
|
|
61
|
-
padding: `${spacing.top}px ${spacing.right}px ${spacing.bottom}px ${spacing.left}px`,
|
|
62
|
-
borderColor: borderColor ? borderColor.value : "transparent",
|
|
63
|
-
backgroundColor: getColor(backgroundColor) || "transparent",
|
|
64
|
-
borderRadius: `${backgroundCorners !== null && backgroundCorners !== void 0 ? backgroundCorners : 0}px`,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function getTextStyle(textStyle) {
|
|
68
|
-
const { font, size, color, uppercase, textAlignment } = textStyle;
|
|
69
|
-
return {
|
|
70
|
-
fontFamily: font.family,
|
|
71
|
-
fontWeight: font.weight,
|
|
72
|
-
fontSize: size,
|
|
73
|
-
color: getColor(color),
|
|
74
|
-
textTransform: uppercase ? "uppercase" : "none",
|
|
75
|
-
textAlign: textAlignment,
|
|
76
|
-
};
|
|
77
|
-
}
|