@tapcart/mobile-components 0.7.19 → 0.7.21

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.
Files changed (57) hide show
  1. package/dist/components/contexts/translationContext.d.ts +9 -0
  2. package/dist/components/contexts/translationContext.d.ts.map +1 -0
  3. package/dist/components/contexts/translationContext.js +5 -0
  4. package/dist/components/hooks/use-destination.d.ts +23 -0
  5. package/dist/components/hooks/use-destination.d.ts.map +1 -0
  6. package/dist/components/hooks/use-destination.js +13 -0
  7. package/dist/components/hooks/use-mock-products.d.ts +17 -0
  8. package/dist/components/hooks/use-mock-products.d.ts.map +1 -0
  9. package/dist/components/hooks/use-mock-products.js +37 -0
  10. package/dist/components/hooks/use-products.js +1 -1
  11. package/dist/components/ui/html.d.ts +9 -0
  12. package/dist/components/ui/html.d.ts.map +1 -0
  13. package/dist/components/ui/html.js +7 -0
  14. package/dist/components/ui/use-tap.d.ts +8 -0
  15. package/dist/components/ui/use-tap.d.ts.map +1 -0
  16. package/dist/components/ui/use-tap.js +100 -0
  17. package/dist/components/ui/video copy.d.ts +18 -0
  18. package/dist/components/ui/video copy.d.ts.map +1 -0
  19. package/dist/components/ui/video copy.js +70 -0
  20. package/dist/components/ui/video.v2.d.ts +18 -0
  21. package/dist/components/ui/video.v2.d.ts.map +1 -0
  22. package/dist/components/ui/video.v2.js +70 -0
  23. package/dist/index copy.d.ts +59 -0
  24. package/dist/index copy.d.ts.map +1 -0
  25. package/dist/index copy.js +59 -0
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2 -0
  29. package/dist/lib/utils/destination.d.ts +17 -0
  30. package/dist/lib/utils/destination.d.ts.map +1 -0
  31. package/dist/lib/utils/destination.js +15 -0
  32. package/dist/lib/utils/id.d.ts +5 -0
  33. package/dist/lib/utils/id.d.ts.map +1 -0
  34. package/dist/lib/utils/id.js +29 -0
  35. package/dist/lib/utils/index.d.ts +18 -0
  36. package/dist/lib/utils/index.d.ts.map +1 -0
  37. package/dist/lib/utils/index.js +55 -0
  38. package/dist/lib/utils/misc.d.ts +1 -0
  39. package/dist/lib/utils/misc.d.ts.map +1 -0
  40. package/dist/lib/utils/misc.js +1 -0
  41. package/dist/lib/utils/style.d.ts +154 -0
  42. package/dist/lib/utils/style.d.ts.map +1 -0
  43. package/dist/lib/utils/style.js +148 -0
  44. package/dist/lib/utils.deprecated.d.ts +181 -0
  45. package/dist/lib/utils.deprecated.d.ts.map +1 -0
  46. package/dist/lib/utils.deprecated.js +222 -0
  47. package/dist/styles.css +0 -3
  48. package/dist/v2.d.ts +59 -0
  49. package/dist/v2.d.ts.map +1 -0
  50. package/dist/v2.js +59 -0
  51. package/package.json +2 -1
  52. package/dist/components/hooks/use-customer.d.ts +0 -10
  53. package/dist/components/hooks/use-customer.d.ts.map +0 -1
  54. package/dist/components/hooks/use-customer.js +0 -24
  55. package/dist/components/ui/apple-pay-button.d.ts +0 -6
  56. package/dist/components/ui/apple-pay-button.d.ts.map +0 -1
  57. package/dist/components/ui/apple-pay-button.js +0 -144
@@ -0,0 +1,222 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ import dayjs from "dayjs";
4
+ import relativeTime from "dayjs/plugin/relativeTime";
5
+ export function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+ export const iconColorLevels = [
9
+ "coreColors-primaryIcon",
10
+ "coreColors-secondaryIcon",
11
+ "coreColors-headerIcon",
12
+ "coreColors-brandColorPrimary",
13
+ "stateColors-subscriptions",
14
+ "stateColors-favorites",
15
+ "stateColors-reviews",
16
+ "stateColors-success",
17
+ "stateColors-error",
18
+ "stateColors-warning",
19
+ "stateColors-disabled",
20
+ "buttonColors-primaryText",
21
+ "buttonColors-secondaryText",
22
+ ];
23
+ export const iconColorVariantClasses = {};
24
+ for (let iconColorLevel of iconColorLevels) {
25
+ iconColorVariantClasses[iconColorLevel] = `text-${iconColorLevel}`;
26
+ }
27
+ export { cva } from "class-variance-authority";
28
+ export const getColor = (colorOption) => {
29
+ if ((colorOption === null || colorOption === void 0 ? void 0 : colorOption.value) === null) {
30
+ return undefined;
31
+ }
32
+ return colorOption
33
+ ? (colorOption === null || colorOption === void 0 ? void 0 : colorOption.type) === "brand-kit"
34
+ ? `var(--${colorOption.value})`
35
+ : colorOption.value
36
+ : undefined;
37
+ };
38
+ export const getBorderSidesStyle = (borderSides) => {
39
+ const style = (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
40
+ ? { borderWidth: "1px" }
41
+ : {
42
+ borderTopWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("top")) ? "1px" : 0,
43
+ borderBottomWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("bottom")) ? "1px" : 0,
44
+ borderLeftWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("left")) ? "1px" : 0,
45
+ borderRightWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("right")) ? "1px" : 0,
46
+ };
47
+ return style;
48
+ };
49
+ export const getVerticalAlignmentStyle = (alignmentAndSpacing) => {
50
+ const { alignment, spacing } = alignmentAndSpacing;
51
+ switch (alignment) {
52
+ case "bottom":
53
+ return { bottom: `${spacing.bottom}px`, top: "auto" };
54
+ case "middle":
55
+ return { top: "50%", transform: "translateY(-50%)" };
56
+ case "top":
57
+ return { top: `${spacing.top}px`, bottom: "auto" };
58
+ default:
59
+ return {};
60
+ }
61
+ };
62
+ export const getPaddingStyle = (padding) => {
63
+ if (!padding)
64
+ return {};
65
+ return {
66
+ paddingTop: (padding === null || padding === void 0 ? void 0 : padding.top) !== undefined ? `${padding.top}px` : undefined,
67
+ paddingBottom: (padding === null || padding === void 0 ? void 0 : padding.bottom) !== undefined ? `${padding.bottom}px` : undefined,
68
+ paddingLeft: (padding === null || padding === void 0 ? void 0 : padding.left) !== undefined ? `${padding.left}px` : undefined,
69
+ paddingRight: (padding === null || padding === void 0 ? void 0 : padding.right) !== undefined ? `${padding.right}px` : undefined,
70
+ };
71
+ };
72
+ export const getBackgroundAndPaddingStyle = (backgroundAndPadding) => {
73
+ const { backgroundColor, borderSides, borderColor, cornerRadius, padding, borderRadius, } = backgroundAndPadding;
74
+ const radius = cornerRadius || borderRadius;
75
+ const defaultBorderWidth = borderSides ? "0px" : undefined;
76
+ return Object.assign(Object.assign({}, getPaddingStyle(padding)), { backgroundColor: getColor(backgroundColor), borderColor: getColor(borderColor), borderTopWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("top")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
77
+ ? "1px"
78
+ : defaultBorderWidth, borderBottomWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("bottom")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
79
+ ? "1px"
80
+ : defaultBorderWidth, borderLeftWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("left")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
81
+ ? "1px"
82
+ : defaultBorderWidth, borderRightWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("right")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
83
+ ? "1px"
84
+ : defaultBorderWidth, borderStyle: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.length) ? "solid" : undefined, borderRadius: radius !== undefined ? `${radius}px` : undefined });
85
+ };
86
+ export const getBackgroundAndSpacingStyle = (backgroundAndSpacing) => {
87
+ const { spacing, borderColor, backgroundColor, backgroundCorners } = backgroundAndSpacing;
88
+ return {
89
+ padding: `${spacing.top}px ${spacing.right}px ${spacing.bottom}px ${spacing.left}px`,
90
+ borderColor: borderColor ? borderColor.value : "transparent",
91
+ backgroundColor: getColor(backgroundColor) || "transparent",
92
+ borderRadius: `${backgroundCorners !== null && backgroundCorners !== void 0 ? backgroundCorners : 0}px`,
93
+ };
94
+ };
95
+ export const getTextStyle = (textStyle) => {
96
+ const { font, size, color, uppercase, textAlignment, wrapText } = textStyle;
97
+ return {
98
+ fontFamily: font.family === "initial" ? undefined : font.family,
99
+ fontWeight: font.weight === "initial" ? undefined : font.weight,
100
+ fontSize: size,
101
+ color: getColor(color),
102
+ textTransform: uppercase ? "uppercase" : "none",
103
+ textAlign: textAlignment,
104
+ textWrap: wrapText ? "wrap" : "nowrap",
105
+ };
106
+ };
107
+ export const getVerticalAlignment = (alignment, padding = { top: 0, bottom: 0 }) => {
108
+ if (alignment === "bottom") {
109
+ return { bottom: `${padding.bottom}px`, top: "auto" };
110
+ }
111
+ else if (alignment === "middle") {
112
+ return { top: "50%", transform: `translateY(-50%)` };
113
+ }
114
+ else if (alignment === "top") {
115
+ return { top: `${padding.top}px`, bottom: "auto" };
116
+ }
117
+ else {
118
+ return {};
119
+ }
120
+ };
121
+ const alignmentClasses = {
122
+ left: "justify-start",
123
+ middle: "justify-center",
124
+ right: "justify-end",
125
+ };
126
+ export const mapFlexToAlignment = (flexClass) => {
127
+ if (flexClass in alignmentClasses)
128
+ return alignmentClasses[flexClass];
129
+ return "";
130
+ };
131
+ export function getIdFromGid(gid) {
132
+ if (!gid)
133
+ return "";
134
+ const arr = gid.split("/");
135
+ return arr[arr.length - 1] || "";
136
+ }
137
+ export function productGidFromId(id) {
138
+ if (!id)
139
+ return null;
140
+ if (id.startsWith("gid://shopify/Product/"))
141
+ return id;
142
+ return `gid://shopify/Product/${id}`;
143
+ }
144
+ export function variantGidFromId(id) {
145
+ if (!id)
146
+ return null;
147
+ if (id.startsWith("gid://shopify/ProductVariant/"))
148
+ return id;
149
+ return `gid://shopify/ProductVariant/${id}`;
150
+ }
151
+ // Use to prevent multiple clicks in quick succession
152
+ export function throttleFunction(fn, wait) {
153
+ let throttle = false;
154
+ return [
155
+ function () {
156
+ return throttle;
157
+ },
158
+ function (...args) {
159
+ if (!throttle) {
160
+ fn(...args);
161
+ throttle = true;
162
+ setInterval(() => {
163
+ throttle = false;
164
+ }, wait);
165
+ }
166
+ },
167
+ ];
168
+ }
169
+ export function formatRelativeTime(inputDate) {
170
+ dayjs.extend(relativeTime);
171
+ return dayjs(inputDate).fromNow();
172
+ }
173
+ export const stringRatioToInt = (string) => {
174
+ const [numerator, denominator] = string
175
+ .replace(":", "/")
176
+ .split("/")
177
+ .map((part) => part.trim())
178
+ .map(Number);
179
+ return numerator / denominator;
180
+ };
181
+ export const getOverlayStyle = (opacity) => {
182
+ const opacityDecimal = opacity / 100;
183
+ return {
184
+ position: "absolute",
185
+ top: 0,
186
+ left: 0,
187
+ right: 0,
188
+ bottom: 0,
189
+ backgroundColor: `rgba(0, 0, 0, ${opacityDecimal})`,
190
+ };
191
+ };
192
+ const DESTINATION_HANDLERS = {
193
+ "app-screen": (location, actions) => actions.openScreen({ destination: { type: "internal", url: location } }),
194
+ url: (location, actions) => actions.openScreen({
195
+ destination: {
196
+ type: "web",
197
+ url: location.includes("https://") ? location : `https://${location}`,
198
+ },
199
+ }),
200
+ product: (location, actions) => actions.openProduct({ productId: location }),
201
+ collection: (location, actions) => actions.openCollection({ collectionId: location }),
202
+ none: () => { },
203
+ };
204
+ export const getDestinationHandler = (type) => {
205
+ return DESTINATION_HANDLERS[type];
206
+ };
207
+ export function getProductGidsFromIds(ids) {
208
+ return ids.map((id) => {
209
+ if (id.startsWith("gid://shopify/Product/")) {
210
+ return id;
211
+ }
212
+ return `gid://shopify/Product/${id}`;
213
+ });
214
+ }
215
+ export const createCollectionImageMap = (collections) => {
216
+ return collections.reduce((imageMap, collection) => {
217
+ if (collection.customImage && collection.image) {
218
+ imageMap[collection.id] = collection.image;
219
+ }
220
+ return imageMap;
221
+ }, {});
222
+ };
package/dist/styles.css CHANGED
@@ -841,9 +841,6 @@ video {
841
841
  .ml-2 {
842
842
  margin-left: 0.5rem;
843
843
  }
844
- .ml-4 {
845
- margin-left: 1rem;
846
- }
847
844
  .mr-2 {
848
845
  margin-right: 0.5rem;
849
846
  }
package/dist/v2.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, getDestinationHandler, createCollectionImageMap, } from "./lib/utils";
2
+ export * from "./components/hooks/use-collection";
3
+ export * from "./components/hooks/use-infinite-scroll";
4
+ export * from "./components/hooks/use-recommendations";
5
+ export * from "./components/hooks/use-products";
6
+ export * from "./components/hooks/use-scroll-direction";
7
+ export * from "./components/hooks/use-sort-filter";
8
+ export * from "./components/hooks/use-product-options";
9
+ export * from "./components/hooks/use-shop";
10
+ export * from "./components/hooks/use-tap";
11
+ export * from "./components/ui/accordion";
12
+ export * from "./components/ui/aspect-ratio";
13
+ export * from "./components/ui/badge";
14
+ export * from "./components/ui/button";
15
+ export * from "./components/ui/carousel";
16
+ export * from "./components/ui/checkbox";
17
+ export * from "./components/ui/chip";
18
+ export * from "./components/ui/color-swatch";
19
+ export * from "./components/ui/container";
20
+ export * from "./components/ui/drawer";
21
+ export * from "./components/ui/dropdown";
22
+ export * from "./components/ui/empty-message";
23
+ export * from "./components/ui/favorite";
24
+ export * from "./components/ui/grid";
25
+ export * from "./components/ui/icon";
26
+ export * from "./components/ui/image";
27
+ export * from "./components/ui/Input/input";
28
+ export * from "./components/ui/label";
29
+ export * from "./components/ui/line-item-text-icons";
30
+ export * from "./components/ui/money";
31
+ export * from "./components/ui/price";
32
+ export * from "./components/ui/product-card";
33
+ export * from "./components/ui/quantity-picker";
34
+ export * from "./components/ui/radio-group";
35
+ export * from "./components/ui/scroll-area";
36
+ export * from "./components/ui/selectors";
37
+ export * from "./components/ui/separator";
38
+ export * from "./components/ui/skeleton";
39
+ export * from "./components/ui/slider";
40
+ export * from "./components/ui/subscription";
41
+ export * from "./components/ui/switch";
42
+ export * from "./components/ui/tabs";
43
+ export * from "./components/ui/text";
44
+ export * from "./components/ui/textarea";
45
+ export * from "./components/ui/toast";
46
+ export * from "./components/ui/toaster";
47
+ export * from "./components/ui/toggle-group";
48
+ export * from "./components/ui/toggle";
49
+ export * from "./components/ui/use-toast";
50
+ export * from "./components/ui/video";
51
+ export * from "./components/ui/video.v2";
52
+ export * from "./components/ui/wishlist";
53
+ export * from "./components/ui/wishlist-select";
54
+ export * from "./components/hooks/use-shop";
55
+ export * from "./components/libs/sort-filter/search-integration";
56
+ export * from "./components/hooks/use-reviews";
57
+ export * from "./components/ui/subcollection-tabs";
58
+ export * from "./components/libs/sort-filter/search-integration";
59
+ //# sourceMappingURL=v2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../v2.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,QAAQ,EACR,4BAA4B,EAC5B,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,aAAa,CAAA;AACpB,cAAc,mCAAmC,CAAA;AACjD,cAAc,wCAAwC,CAAA;AACtD,cAAc,wCAAwC,CAAA;AACtD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yCAAyC,CAAA;AACvD,cAAc,oCAAoC,CAAA;AAClD,cAAc,wCAAwC,CAAA;AACtD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,sCAAsC,CAAA;AACpD,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,kDAAkD,CAAA"}
package/dist/v2.js ADDED
@@ -0,0 +1,59 @@
1
+ // component exports
2
+ export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, getDestinationHandler, createCollectionImageMap, } from "./lib/utils";
3
+ export * from "./components/hooks/use-collection";
4
+ export * from "./components/hooks/use-infinite-scroll";
5
+ export * from "./components/hooks/use-recommendations";
6
+ export * from "./components/hooks/use-products";
7
+ export * from "./components/hooks/use-scroll-direction";
8
+ export * from "./components/hooks/use-sort-filter";
9
+ export * from "./components/hooks/use-product-options";
10
+ export * from "./components/hooks/use-shop";
11
+ export * from "./components/hooks/use-tap";
12
+ export * from "./components/ui/accordion";
13
+ export * from "./components/ui/aspect-ratio";
14
+ export * from "./components/ui/badge";
15
+ export * from "./components/ui/button";
16
+ export * from "./components/ui/carousel";
17
+ export * from "./components/ui/checkbox";
18
+ export * from "./components/ui/chip";
19
+ export * from "./components/ui/color-swatch";
20
+ export * from "./components/ui/container";
21
+ export * from "./components/ui/drawer";
22
+ export * from "./components/ui/dropdown";
23
+ export * from "./components/ui/empty-message";
24
+ export * from "./components/ui/favorite";
25
+ export * from "./components/ui/grid";
26
+ export * from "./components/ui/icon";
27
+ export * from "./components/ui/image";
28
+ export * from "./components/ui/Input/input";
29
+ export * from "./components/ui/label";
30
+ export * from "./components/ui/line-item-text-icons";
31
+ export * from "./components/ui/money";
32
+ export * from "./components/ui/price";
33
+ export * from "./components/ui/product-card";
34
+ export * from "./components/ui/quantity-picker";
35
+ export * from "./components/ui/radio-group";
36
+ export * from "./components/ui/scroll-area";
37
+ export * from "./components/ui/selectors";
38
+ export * from "./components/ui/separator";
39
+ export * from "./components/ui/skeleton";
40
+ export * from "./components/ui/slider";
41
+ export * from "./components/ui/subscription";
42
+ export * from "./components/ui/switch";
43
+ export * from "./components/ui/tabs";
44
+ export * from "./components/ui/text";
45
+ export * from "./components/ui/textarea";
46
+ export * from "./components/ui/toast";
47
+ export * from "./components/ui/toaster";
48
+ export * from "./components/ui/toggle-group";
49
+ export * from "./components/ui/toggle";
50
+ export * from "./components/ui/use-toast";
51
+ export * from "./components/ui/video";
52
+ export * from "./components/ui/video.v2";
53
+ export * from "./components/ui/wishlist";
54
+ export * from "./components/ui/wishlist-select";
55
+ export * from "./components/hooks/use-shop";
56
+ export * from "./components/libs/sort-filter/search-integration";
57
+ export * from "./components/hooks/use-reviews";
58
+ export * from "./components/ui/subcollection-tabs";
59
+ export * from "./components/libs/sort-filter/search-integration";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.19",
3
+ "version": "0.7.21",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -69,6 +69,7 @@
69
69
  "class-variance-authority": "^0.6.0",
70
70
  "clsx": "^1.2.1",
71
71
  "dayjs": "^1.11.13",
72
+ "dompurify": "^3.2.2",
72
73
  "embla-carousel-react": "^8.3.0",
73
74
  "lucide-react": "^0.248.0",
74
75
  "next": "^14.2.5",
@@ -1,10 +0,0 @@
1
- type Customer = {
2
- isAuthenticated: boolean;
3
- };
4
- type UseCustomerProps = {};
5
- type UseCustomerReturn = {
6
- customer: Customer;
7
- };
8
- export declare const useCustomer: (props: UseCustomerProps | null) => UseCustomerReturn;
9
- export {};
10
- //# sourceMappingURL=use-customer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-customer.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-customer.ts"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAGD,KAAK,gBAAgB,GAAG,EAAE,CAAA;AAE1B,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,WAAW,UACf,gBAAgB,GAAG,IAAI,KAC7B,iBAuBF,CAAA"}
@@ -1,24 +0,0 @@
1
- "use client";
2
- import { useState, useEffect } from "react";
3
- // @ts-ignore -- webbridge-react is not typed (yet)
4
- import { useActions } from "@tapcart/webbridge-react";
5
- export const useCustomer = (props) => {
6
- const [isAuthenticated, setIsAuthenticated] = useState(false);
7
- const [customer, setCustomer] = useState({});
8
- const actions = useActions();
9
- // verify customer
10
- useEffect(() => {
11
- try {
12
- // webbridge method to get customerIdentity
13
- actions.getCustomerIdentity(null, {
14
- onSuccess: (user) => setIsAuthenticated(!!(user === null || user === void 0 ? void 0 : user.email)),
15
- });
16
- }
17
- catch (e) {
18
- console.log("unable to get customer identity ", e);
19
- }
20
- }, [actions]);
21
- return {
22
- customer: Object.assign({ isAuthenticated }, customer),
23
- };
24
- };
@@ -1,6 +0,0 @@
1
- import * as React from "react";
2
- export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
- }
4
- declare const ApplePayButton: React.ForwardRefExoticComponent<ApplePayButtonProps & React.RefAttributes<HTMLButtonElement>>;
5
- export { ApplePayButton };
6
- //# sourceMappingURL=apple-pay-button.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apple-pay-button.d.ts","sourceRoot":"","sources":["../../../components/ui/apple-pay-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;CACtD;AAED,QAAA,MAAM,cAAc,+FAyJnB,CAAA;AAGD,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,144 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
- import * as React from "react";
23
- import ApplePayButtonComponent from 'apple-pay-button';
24
- const ApplePayButton = React.forwardRef((_a, ref) => {
25
- var props = __rest(_a, []);
26
- const onClick = () => {
27
- // Define ApplePayPaymentRequest
28
- const applePayRequest = {
29
- countryCode: 'US',
30
- currencyCode: 'USD',
31
- merchantCapabilities: [
32
- "supports3DS"
33
- ],
34
- supportedNetworks: [
35
- "visa",
36
- "masterCard",
37
- "amex",
38
- "discover"
39
- ],
40
- total: {
41
- label: "Merchant Name",
42
- type: "final",
43
- amount: "10.00",
44
- }
45
- };
46
- // Create ApplePaySession
47
- const session = new ApplePaySession(3, applePayRequest);
48
- handleEventsForApplePay(session);
49
- session.begin();
50
- };
51
- const defaultFetcher = (url, body) => fetch(url, {
52
- method: body ? "POST" : "GET",
53
- headers: {
54
- "Content-Type": "application/json",
55
- },
56
- body: body ? JSON.stringify(body) : undefined,
57
- }).then((res) => res.json());
58
- // const fetcher = defaultFetcher
59
- // const { data, error } = useSWR(url ? [url, body] : null, ([url, body]) =>
60
- // fetcher(url, body)
61
- // )
62
- const validateMerchant = (validationURL, merchantIdentifier, domainName, displayName) => __awaiter(void 0, void 0, void 0, function* () {
63
- let url = "http://localhost:3000/3Mo5UakuRa/api/v1/applePay/merchantVerification";
64
- let body = {
65
- validationURL,
66
- merchantIdentifier,
67
- domainName,
68
- displayName
69
- };
70
- return defaultFetcher(url, body);
71
- });
72
- const handleEventsForApplePay = (session) => {
73
- session.onvalidatemerchant = (event) => __awaiter(void 0, void 0, void 0, function* () {
74
- const merchantSession = yield validateMerchant(event.validationURL, "merchantId", "domainName", "displayName");
75
- if (merchantSession) {
76
- session.completeMerchantValidation(merchantSession);
77
- }
78
- else {
79
- console.error("Error during validating merchant");
80
- }
81
- });
82
- session.onpaymentmethodselected = (event) => {
83
- // Define ApplePayPaymentMethodUpdate based on the selected payment method.
84
- // No updates or errors are needed, pass an empty object.
85
- const update = {
86
- newTotal: {
87
- label: "Merchant Name",
88
- type: "final",
89
- amount: "10.00",
90
- }
91
- };
92
- session.completePaymentMethodSelection(update);
93
- };
94
- session.onshippingmethodselected = (event) => {
95
- // Define ApplePayShippingMethodUpdate based on the selected shipping method.
96
- // No updates or errors are needed, pass an empty object.
97
- const update = {
98
- newTotal: {
99
- label: "Merchant Name",
100
- type: "final",
101
- amount: "10.00",
102
- }
103
- };
104
- session.completeShippingMethodSelection(update);
105
- };
106
- session.onshippingcontactselected = (event) => {
107
- // Define ApplePayShippingContactUpdate based on the selected shipping contact.
108
- const update = {
109
- newTotal: {
110
- label: "Merchant Name",
111
- type: "final",
112
- amount: "10.00",
113
- }
114
- };
115
- session.completeShippingContactSelection(update);
116
- };
117
- session.onpaymentauthorized = (event) => __awaiter(void 0, void 0, void 0, function* () {
118
- // Define ApplePayPaymentAuthorizationResult
119
- const paymentData = event.payment;
120
- if (paymentData.token) {
121
- // Forward token to your gateway for processing payment and return result to apple pay session
122
- const result = {
123
- status: ApplePaySession.STATUS_SUCCESS,
124
- };
125
- session.completePayment(result);
126
- }
127
- else {
128
- const result = {
129
- status: ApplePaySession.STATUS_FAILURE,
130
- };
131
- session.completePayment(result);
132
- }
133
- });
134
- session.oncancel = (event) => {
135
- console.log("Session Cancelled.");
136
- };
137
- };
138
- return (_jsx("div", { children: _jsx(ApplePayButtonComponent, { onClick: onClick, style: {
139
- width: '100%',
140
- borderRadius: '8px',
141
- }, type: "continue" }) }));
142
- });
143
- ApplePayButton.displayName = "ApplePayButton";
144
- export { ApplePayButton };