@tapcart/mobile-components 0.7.20 → 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.
- package/dist/components/contexts/translationContext.d.ts +9 -0
- package/dist/components/contexts/translationContext.d.ts.map +1 -0
- package/dist/components/contexts/translationContext.js +5 -0
- package/dist/components/hooks/use-destination.d.ts +23 -0
- package/dist/components/hooks/use-destination.d.ts.map +1 -0
- package/dist/components/hooks/use-destination.js +13 -0
- package/dist/components/hooks/use-mock-products.d.ts +17 -0
- package/dist/components/hooks/use-mock-products.d.ts.map +1 -0
- package/dist/components/hooks/use-mock-products.js +37 -0
- package/dist/components/hooks/use-products.js +1 -1
- package/dist/components/ui/use-tap.d.ts +8 -0
- package/dist/components/ui/use-tap.d.ts.map +1 -0
- package/dist/components/ui/use-tap.js +100 -0
- package/dist/components/ui/video copy.d.ts +18 -0
- package/dist/components/ui/video copy.d.ts.map +1 -0
- package/dist/components/ui/video copy.js +70 -0
- package/dist/components/ui/video.v2.d.ts +18 -0
- package/dist/components/ui/video.v2.d.ts.map +1 -0
- package/dist/components/ui/video.v2.js +70 -0
- package/dist/index copy.d.ts +59 -0
- package/dist/index copy.d.ts.map +1 -0
- package/dist/index copy.js +59 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/utils/destination.d.ts +17 -0
- package/dist/lib/utils/destination.d.ts.map +1 -0
- package/dist/lib/utils/destination.js +15 -0
- package/dist/lib/utils/id.d.ts +5 -0
- package/dist/lib/utils/id.d.ts.map +1 -0
- package/dist/lib/utils/id.js +29 -0
- package/dist/lib/utils/index.d.ts +18 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/index.js +55 -0
- package/dist/lib/utils/misc.d.ts +1 -0
- package/dist/lib/utils/misc.d.ts.map +1 -0
- package/dist/lib/utils/misc.js +1 -0
- package/dist/lib/utils/style.d.ts +154 -0
- package/dist/lib/utils/style.d.ts.map +1 -0
- package/dist/lib/utils/style.js +148 -0
- package/dist/lib/utils.deprecated.d.ts +181 -0
- package/dist/lib/utils.deprecated.d.ts.map +1 -0
- package/dist/lib/utils.deprecated.js +222 -0
- package/dist/styles.css +0 -3
- package/dist/v2.d.ts +59 -0
- package/dist/v2.d.ts.map +1 -0
- package/dist/v2.js +59 -0
- package/package.json +18 -18
- package/dist/components/ui/input.d.ts +0 -17
- package/dist/components/ui/input.d.ts.map +0 -1
- package/dist/components/ui/input.js +0 -35
- package/dist/components/ui/product-grid.d.ts +0 -15
- package/dist/components/ui/product-grid.d.ts.map +0 -1
- package/dist/components/ui/product-grid.js +0 -22
|
@@ -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
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
|
package/dist/v2.d.ts.map
ADDED
|
@@ -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.
|
|
3
|
+
"version": "0.7.21",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -11,6 +11,18 @@
|
|
|
11
11
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
12
12
|
"author": "Tapcart Inc.",
|
|
13
13
|
"homepage": "https://tapcart.com",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"lint": "eslint \"**/*.ts*\"",
|
|
16
|
+
"ui:add": "pnpm dlx shadcn-ui@latest add",
|
|
17
|
+
"build:styles": "postcss styles/globals.css -o dist/styles.css",
|
|
18
|
+
"build:ts": "tsc -p tsconfig.json && tsc-alias",
|
|
19
|
+
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
20
|
+
"dev:ts": "tsc -w -p tsconfig.json",
|
|
21
|
+
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
22
|
+
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
|
|
23
|
+
"test": "jest",
|
|
24
|
+
"test:watch": "jest --watch"
|
|
25
|
+
},
|
|
14
26
|
"peerDependencies": {
|
|
15
27
|
"react": "^17.0.2 || ^18.0.0",
|
|
16
28
|
"react-dom": "^17.0.2 || ^18.0.0"
|
|
@@ -20,19 +32,19 @@
|
|
|
20
32
|
"@types/lodash": "4.17.5",
|
|
21
33
|
"@types/react": "^18.2.0",
|
|
22
34
|
"@types/react-dom": "^18.2.0",
|
|
35
|
+
"app-studio-types": "workspace:*",
|
|
23
36
|
"autoprefixer": "^10.4.14",
|
|
24
37
|
"chokidar-cli": "^3.0.0",
|
|
25
38
|
"concurrently": "^8.2.2",
|
|
26
39
|
"eslint": "^7.32.0",
|
|
40
|
+
"eslint-config-custom": "workspace:*",
|
|
27
41
|
"jest": "^29.7.0",
|
|
28
42
|
"postcss": "^8.4.24",
|
|
29
43
|
"tailwindcss": "^3.3.2",
|
|
30
44
|
"ts-jest": "^29.2.5",
|
|
31
45
|
"tsc-alias": "^1.8.10",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"eslint-config-custom": "0.0.0",
|
|
35
|
-
"tsconfig": "0.0.0"
|
|
46
|
+
"tsconfig": "workspace:*",
|
|
47
|
+
"typescript": "^4.5.2"
|
|
36
48
|
},
|
|
37
49
|
"dependencies": {
|
|
38
50
|
"@radix-ui/react-accordion": "^1.1.2",
|
|
@@ -69,17 +81,5 @@
|
|
|
69
81
|
"tailwind-merge": "^1.13.2",
|
|
70
82
|
"tailwindcss-animate": "^1.0.6",
|
|
71
83
|
"vaul": "0.9.1"
|
|
72
|
-
},
|
|
73
|
-
"scripts": {
|
|
74
|
-
"lint": "eslint \"**/*.ts*\"",
|
|
75
|
-
"ui:add": "pnpm dlx shadcn-ui@latest add",
|
|
76
|
-
"build:styles": "postcss styles/globals.css -o dist/styles.css",
|
|
77
|
-
"build:ts": "tsc -p tsconfig.json && tsc-alias",
|
|
78
|
-
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
79
|
-
"dev:ts": "tsc -w -p tsconfig.json",
|
|
80
|
-
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
81
|
-
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
|
|
82
|
-
"test": "jest",
|
|
83
|
-
"test:watch": "jest --watch"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { type VariantProps } from "class-variance-authority";
|
|
3
|
-
declare const inputVariants: (props?: ({
|
|
4
|
-
error?: boolean | null | undefined;
|
|
5
|
-
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
6
|
-
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange">, VariantProps<typeof inputVariants> {
|
|
7
|
-
id: string;
|
|
8
|
-
label?: string;
|
|
9
|
-
icon?: string;
|
|
10
|
-
asChild?: boolean;
|
|
11
|
-
value: string;
|
|
12
|
-
placeholder: string;
|
|
13
|
-
onChange: (_: string) => void;
|
|
14
|
-
}
|
|
15
|
-
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
16
|
-
export { Input };
|
|
17
|
-
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../components/ui/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,aAAa;;mFAalB,CAAA;AAED,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,EACnE,YAAY,CAAC,OAAO,aAAa,CAAC;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B;AAED,QAAA,MAAM,KAAK,qFAkDV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import * as React from "react";
|
|
14
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
15
|
-
import { cva } from "class-variance-authority";
|
|
16
|
-
import { cn } from "../../lib/utils";
|
|
17
|
-
import { Icon } from "./icon";
|
|
18
|
-
const inputVariants = cva("flex h-14 w-full rounded border border-coreColors-dividingLines bg-coreColors-inputBackground px-4 pt-5 pb-2 placeholder-shown:p-4 text-textColors-primaryColor text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-textColors-secondaryColor focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50 focus:border-coreColors-brandColorPrimary peer data-[icon=true]:pr-10", {
|
|
19
|
-
variants: {
|
|
20
|
-
error: {
|
|
21
|
-
true: "border-stateColors-error text-stateColors-error placeholder:text-stateColors-error focus:border-stateColors-error [&+label]:text-stateColors-error",
|
|
22
|
-
false: "",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
defaultVariants: {
|
|
26
|
-
error: false,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
const Input = React.forwardRef((_a, ref) => {
|
|
30
|
-
var { className, error = false, id, type, label, icon, asChild, value, placeholder, onChange } = _a, props = __rest(_a, ["className", "error", "id", "type", "label", "icon", "asChild", "value", "placeholder", "onChange"]);
|
|
31
|
-
const Comp = asChild ? Slot : "div";
|
|
32
|
-
return (_jsxs(Comp, Object.assign({ className: "relative group" }, { children: [_jsx("input", Object.assign({ placeholder: placeholder, value: value, onChange: (e) => onChange(e.target.value), id: id, type: type, className: cn(inputVariants({ error }), className), "data-icon": !!icon, ref: ref }, props)), label ? (_jsx("label", Object.assign({ htmlFor: id, className: "absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] start-4 opacity-100 peer-placeholder-shown:opacity-0" }, { children: label }))) : null, icon ? (_jsx(Icon, { name: icon, "data-error": error, size: "sm", className: "absolute w-5 aspect-square fill-current text-textColors-secondaryColor top-[18px] z-10 origin-[0] end-4 peer-pr-8 icon data-[error=true]:text-stateColors-error" })) : null] })));
|
|
33
|
-
});
|
|
34
|
-
Input.displayName = "Input";
|
|
35
|
-
export { Input };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type Product = any;
|
|
2
|
-
interface PageData {
|
|
3
|
-
products: Product[];
|
|
4
|
-
cursorBlob?: string;
|
|
5
|
-
filtersData: any;
|
|
6
|
-
}
|
|
7
|
-
interface ProductGridItemsProps {
|
|
8
|
-
initialData: PageData;
|
|
9
|
-
loadMoreProducts: (params: any) => Promise<PageData>;
|
|
10
|
-
queryVariables: Record<string, any>;
|
|
11
|
-
config: Record<string, any>;
|
|
12
|
-
}
|
|
13
|
-
declare function ProductGrid({ loadMoreProducts, initialData, queryVariables, config, }: ProductGridItemsProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export { ProductGrid };
|
|
15
|
-
//# sourceMappingURL=product-grid.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product-grid.d.ts","sourceRoot":"","sources":["../../../components/ui/product-grid.tsx"],"names":[],"mappings":"AAkBA,KAAK,OAAO,GAAG,GAAG,CAAA;AAClB,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;CACjB;AAED,UAAU,qBAAqB;IAC7B,WAAW,EAAE,QAAQ,CAAA;IACrB,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACpD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B;AAED,iBAAS,WAAW,CAAC,EACnB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,MAAM,GACP,EAAE,qBAAqB,2CAmCvB;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useInfiniteScroll } from "../hooks/use-infinite-scroll";
|
|
4
|
-
import { ProductCard } from "./product-card";
|
|
5
|
-
const Loader = () => (_jsx("div", Object.assign({ className: "grid-cols-2 lg:grid-cols-3" }, { children: Array(4)
|
|
6
|
-
.fill(0)
|
|
7
|
-
.map((_, index) => (_jsx("div", { className: "aspect-[2/3] animate-pulse bg-neutral-100 dark:bg-neutral-900" }, index))) })));
|
|
8
|
-
function ProductGrid({ loadMoreProducts, initialData, queryVariables, config, }) {
|
|
9
|
-
const { data, error, isLoadingInitialData, isLoadingMore, isEmpty, isReachingEnd, ref, products, } = useInfiniteScroll({
|
|
10
|
-
initialData,
|
|
11
|
-
loadMoreProducts,
|
|
12
|
-
queryVariables,
|
|
13
|
-
});
|
|
14
|
-
if (error)
|
|
15
|
-
return _jsx("div", { children: "Failed to load data" });
|
|
16
|
-
if (isLoadingInitialData)
|
|
17
|
-
return _jsx(Loader, {});
|
|
18
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({ className: "grid-cols-2 lg:grid-cols-3" }, { children: products.map((product, i) => (_jsx(ProductCard, {
|
|
19
|
-
// @ts-expect-error
|
|
20
|
-
product: product, config: config, isLoading: false }, product.handle))) })), isLoadingMore ? _jsx(Loader, {}) : _jsx("div", { ref: ref })] }));
|
|
21
|
-
}
|
|
22
|
-
export { ProductGrid };
|