@tapcart/mobile-components 0.2.12 → 0.3.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-infinite-scroll.d.ts +1 -0
- package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
- package/dist/components/hooks/use-infinite-scroll.js +3 -2
- package/dist/components/hooks/use-scroll-direction.d.ts +1 -1
- package/dist/components/hooks/use-scroll-direction.d.ts.map +1 -1
- package/dist/components/hooks/use-scroll-direction.js +17 -5
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +49 -14
- package/dist/components/ui/checkbox.js +2 -2
- package/dist/components/ui/chip.d.ts.map +1 -1
- package/dist/components/ui/chip.js +3 -3
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/icon.d.ts.map +1 -1
- package/dist/components/ui/icon.js +5 -1
- package/dist/components/ui/image.d.ts +157 -0
- package/dist/components/ui/image.d.ts.map +1 -0
- package/dist/components/ui/image.js +318 -0
- package/dist/components/ui/line-item-text-icons.d.ts +14 -0
- package/dist/components/ui/line-item-text-icons.d.ts.map +1 -0
- package/dist/components/ui/line-item-text-icons.js +22 -0
- package/dist/components/ui/product-card.d.ts +5 -19
- package/dist/components/ui/product-card.d.ts.map +1 -1
- package/dist/components/ui/product-card.js +77 -24
- package/dist/components/ui/quantity-picker.d.ts +14 -0
- package/dist/components/ui/quantity-picker.d.ts.map +1 -0
- package/dist/components/ui/quantity-picker.js +23 -0
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/selectors.d.ts +1 -1
- package/dist/components/ui/selectors.d.ts.map +1 -1
- package/dist/components/ui/selectors.js +20 -4
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/slider.d.ts +14 -0
- package/dist/components/ui/slider.d.ts.map +1 -0
- package/dist/components/ui/slider.js +50 -0
- package/dist/components/ui/subscription.d.ts +15 -0
- package/dist/components/ui/subscription.d.ts.map +1 -0
- package/dist/components/ui/subscription.js +24 -0
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +2 -2
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/styles.css +108 -88
- package/package.json +9 -3
- package/dist/components/ThemeProvider.d.ts +0 -3
- package/dist/components/ThemeProvider.d.ts.map +0 -1
- package/dist/components/ThemeProvider.js +0 -18
- package/dist/components/ThemeToggle.d.ts +0 -2
- package/dist/components/ThemeToggle.d.ts.map +0 -1
- package/dist/components/ThemeToggle.js +0 -8
|
@@ -0,0 +1,318 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
13
|
+
/* eslint-disable react/display-name */
|
|
14
|
+
/* eslint-disable @next/next/no-img-element */
|
|
15
|
+
import * as React from "react";
|
|
16
|
+
/**
|
|
17
|
+
* Tapcart’s Image component is a wrapper around the HTML image element.
|
|
18
|
+
* It supports the same props as the HTML `img` element, but automatically
|
|
19
|
+
* generates the srcSet and sizes attributes for you. For most use cases,
|
|
20
|
+
* you’ll want to set the `aspectRatio` prop to ensure the image is sized
|
|
21
|
+
* correctly.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - `decoding` is set to `async` by default.
|
|
25
|
+
* - `loading` is set to `lazy` by default.
|
|
26
|
+
* - `alt` will automatically be set to the `altText` from the Storefront API if passed in the `data` prop
|
|
27
|
+
* - `src` will automatically be set to the `url` from the Storefront API if passed in the `data` prop
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* A responsive image with a 4:5 aspect ratio:
|
|
31
|
+
* ```
|
|
32
|
+
* <Image
|
|
33
|
+
* data={product.featuredImage}
|
|
34
|
+
* aspectRatio="4:5"
|
|
35
|
+
* sizes="(min-width: 45em) 40vw, 100vw"
|
|
36
|
+
* />
|
|
37
|
+
* ```
|
|
38
|
+
* @example
|
|
39
|
+
* A fixed size image:
|
|
40
|
+
* ```
|
|
41
|
+
* <Image
|
|
42
|
+
* data={product.featuredImage}
|
|
43
|
+
* width={100}
|
|
44
|
+
* height={100}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* {@link https://shopify.dev/docs/api/hydrogen-react/components/image}
|
|
49
|
+
*/
|
|
50
|
+
export const Image = React.forwardRef((_a, ref) => {
|
|
51
|
+
var _b;
|
|
52
|
+
var { alt, aspectRatio, crop = "center", data, decoding = "async", height = "auto", loader = shopifyLoader, loading = "lazy", sizes, src, srcSetOptions = {
|
|
53
|
+
intervals: 15,
|
|
54
|
+
startingWidth: 100,
|
|
55
|
+
incrementSize: 100,
|
|
56
|
+
placeholderWidth: 100,
|
|
57
|
+
}, width = "100%", objectFit = "cover" } = _a, passthroughProps = __rest(_a, ["alt", "aspectRatio", "crop", "data", "decoding", "height", "loader", "loading", "sizes", "src", "srcSetOptions", "width", "objectFit"]);
|
|
58
|
+
/*
|
|
59
|
+
* Gets normalized values for width, height from data prop
|
|
60
|
+
*/
|
|
61
|
+
const normalizedData = React.useMemo(() => {
|
|
62
|
+
/* Only use data width if height is also set */
|
|
63
|
+
const dataWidth = (data === null || data === void 0 ? void 0 : data.width) && (data === null || data === void 0 ? void 0 : data.height) ? data === null || data === void 0 ? void 0 : data.width : undefined;
|
|
64
|
+
const dataHeight = (data === null || data === void 0 ? void 0 : data.width) && (data === null || data === void 0 ? void 0 : data.height) ? data === null || data === void 0 ? void 0 : data.height : undefined;
|
|
65
|
+
return {
|
|
66
|
+
width: dataWidth,
|
|
67
|
+
height: dataHeight,
|
|
68
|
+
unitsMatch: Boolean(unitsMatch(dataWidth, dataHeight)),
|
|
69
|
+
};
|
|
70
|
+
}, [data]);
|
|
71
|
+
/*
|
|
72
|
+
* Gets normalized values for width, height, src, alt, and aspectRatio props
|
|
73
|
+
* supporting the presence of `data` in addition to flat props.
|
|
74
|
+
*/
|
|
75
|
+
const normalizedProps = React.useMemo(() => {
|
|
76
|
+
const nWidthProp = width || "100%";
|
|
77
|
+
const widthParts = getUnitValueParts(nWidthProp.toString());
|
|
78
|
+
const nWidth = `${widthParts.number}${widthParts.unit}`;
|
|
79
|
+
const autoHeight = height === "auto" || height === undefined || height === null;
|
|
80
|
+
const heightParts = autoHeight
|
|
81
|
+
? null
|
|
82
|
+
: getUnitValueParts(height.toString());
|
|
83
|
+
const fixedHeight = heightParts
|
|
84
|
+
? `${heightParts.number}${heightParts.unit}`
|
|
85
|
+
: "";
|
|
86
|
+
const nHeight = autoHeight ? "auto" : fixedHeight;
|
|
87
|
+
const nSrc = src || (data === null || data === void 0 ? void 0 : data.url);
|
|
88
|
+
const nAlt = (data === null || data === void 0 ? void 0 : data.altText) && !alt ? data === null || data === void 0 ? void 0 : data.altText : alt || "";
|
|
89
|
+
const nAspectRatio = aspectRatio
|
|
90
|
+
? aspectRatio
|
|
91
|
+
: normalizedData.unitsMatch
|
|
92
|
+
? [
|
|
93
|
+
getNormalizedFixedUnit(normalizedData.width),
|
|
94
|
+
getNormalizedFixedUnit(normalizedData.height),
|
|
95
|
+
].join(":")
|
|
96
|
+
: undefined;
|
|
97
|
+
// Map Tapcart properties "fill" and "fit" to CSS object-fit values
|
|
98
|
+
const nObjectFit = objectFit === "fill"
|
|
99
|
+
? "cover"
|
|
100
|
+
: objectFit === "fit"
|
|
101
|
+
? "contain"
|
|
102
|
+
: objectFit;
|
|
103
|
+
return {
|
|
104
|
+
width: nWidth,
|
|
105
|
+
height: nHeight,
|
|
106
|
+
src: nSrc,
|
|
107
|
+
alt: nAlt,
|
|
108
|
+
aspectRatio: nAspectRatio,
|
|
109
|
+
objectFit: nObjectFit,
|
|
110
|
+
};
|
|
111
|
+
}, [
|
|
112
|
+
width,
|
|
113
|
+
height,
|
|
114
|
+
src,
|
|
115
|
+
data,
|
|
116
|
+
alt,
|
|
117
|
+
aspectRatio,
|
|
118
|
+
normalizedData,
|
|
119
|
+
passthroughProps === null || passthroughProps === void 0 ? void 0 : passthroughProps.key,
|
|
120
|
+
]);
|
|
121
|
+
const { intervals, startingWidth, incrementSize, placeholderWidth } = srcSetOptions;
|
|
122
|
+
/*
|
|
123
|
+
* This function creates an array of widths to be used in srcSet
|
|
124
|
+
*/
|
|
125
|
+
const imageWidths = React.useMemo(() => {
|
|
126
|
+
return generateImageWidths(width, intervals, startingWidth, incrementSize);
|
|
127
|
+
}, [width, intervals, startingWidth, incrementSize]);
|
|
128
|
+
const fixedWidth = isFixedWidth(normalizedProps.width);
|
|
129
|
+
const [isLoaded, setIsLoaded] = React.useState(false);
|
|
130
|
+
const [hasError, setHasError] = React.useState(false);
|
|
131
|
+
const handleImageLoad = () => {
|
|
132
|
+
setIsLoaded(true);
|
|
133
|
+
};
|
|
134
|
+
const handleImageError = () => {
|
|
135
|
+
setHasError(true);
|
|
136
|
+
};
|
|
137
|
+
const imgClassName = `opacity-0 transition-opacity duration-500 ease-in-out ${isLoaded ? "opacity-100" : ""}`;
|
|
138
|
+
const aspectRatioPadding = aspectRatio
|
|
139
|
+
? {
|
|
140
|
+
paddingBottom: `${(parseFloat(aspectRatio.split(":")[1]) /
|
|
141
|
+
parseFloat(aspectRatio.split(":")[0])) *
|
|
142
|
+
100}%`,
|
|
143
|
+
}
|
|
144
|
+
: { paddingBottom: "100%" };
|
|
145
|
+
const wrapperStyle = {
|
|
146
|
+
paddingBottom: !isLoaded ? aspectRatioPadding.paddingBottom : undefined,
|
|
147
|
+
aspectRatio: (_b = normalizedProps.aspectRatio) === null || _b === void 0 ? void 0 : _b.replace(":", "/"),
|
|
148
|
+
};
|
|
149
|
+
return (_jsx("div", Object.assign({ className: "relative w-full bg-stateColors-skeleton ", style: wrapperStyle }, { children: !hasError && normalizedProps.src ? (_jsx("img", Object.assign({ ref: ref, alt: normalizedProps.alt, decoding: decoding, height: normalizedProps.height, loading: loading, src: normalizedProps.src, srcSet: generateSrcSet(normalizedProps.src, generateSizes(imageWidths, normalizedProps.aspectRatio, crop), loader, objectFit === "contain"), width: normalizedProps.width, className: imgClassName, onLoad: handleImageLoad, onError: handleImageError, sizes: sizes, style: {
|
|
150
|
+
objectFit: normalizedProps.objectFit,
|
|
151
|
+
maxHeight: "100%",
|
|
152
|
+
height: "100%",
|
|
153
|
+
} }, passthroughProps))) : (_jsx("div", { className: "absolute top-0 left-0 w-full h-full bg-stateColors-skeleton " })) })));
|
|
154
|
+
});
|
|
155
|
+
/**
|
|
156
|
+
* The shopifyLoader function is a simple utility function that takes a src, width,
|
|
157
|
+
* height, and crop and returns a string that can be used as the src for an image.
|
|
158
|
+
* It can be used with the Tapcart Image component or with the next/image component.
|
|
159
|
+
* (or any others that accept equivalent configuration)
|
|
160
|
+
* @param src - The source URL of the image, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg`
|
|
161
|
+
* @param width - The width of the image, e.g. `100`
|
|
162
|
+
* @param height - The height of the image, e.g. `100`
|
|
163
|
+
* @param crop - The crop of the image, e.g. `center`
|
|
164
|
+
* @returns A Shopify image URL with the correct query parameters, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=100&height=100&crop=center`
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```
|
|
168
|
+
* shopifyLoader({
|
|
169
|
+
* src: 'https://cdn.shopify.com/static/sample-images/garnished.jpeg',
|
|
170
|
+
* width: 100,
|
|
171
|
+
* height: 100,
|
|
172
|
+
* crop: 'center',
|
|
173
|
+
* })
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export function shopifyLoader({ src, width, height, crop, isContained, }) {
|
|
177
|
+
if (!src) {
|
|
178
|
+
return "";
|
|
179
|
+
}
|
|
180
|
+
const url = new URL(src);
|
|
181
|
+
if (width && !isContained) {
|
|
182
|
+
url.searchParams.append("width", Math.round(width).toString());
|
|
183
|
+
}
|
|
184
|
+
if (height) {
|
|
185
|
+
url.searchParams.append("height", Math.round(height).toString());
|
|
186
|
+
}
|
|
187
|
+
if (crop && !isContained) {
|
|
188
|
+
url.searchParams.append("crop", crop);
|
|
189
|
+
}
|
|
190
|
+
return url.href;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Checks whether the width and height share the same unit type
|
|
194
|
+
* @param width - The width of the image, e.g. 100% | 10px
|
|
195
|
+
* @param height - The height of the image, e.g. auto | 100px
|
|
196
|
+
* @returns Whether the width and height share the same unit type (boolean)
|
|
197
|
+
*/
|
|
198
|
+
function unitsMatch(width = "100%", height = "auto") {
|
|
199
|
+
return (getUnitValueParts(width.toString()).unit ===
|
|
200
|
+
getUnitValueParts(height.toString()).unit);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Given a CSS size, returns the unit and number parts of the value
|
|
204
|
+
* @param value - The CSS size, e.g. 100px
|
|
205
|
+
* @returns The unit and number parts of the value, e.g. \{unit: 'px', number: 100\}
|
|
206
|
+
*/
|
|
207
|
+
function getUnitValueParts(value) {
|
|
208
|
+
const unit = value.replace(/[0-9.]/g, "");
|
|
209
|
+
const number = parseFloat(value.replace(unit, ""));
|
|
210
|
+
return {
|
|
211
|
+
unit: unit === "" ? (number === undefined ? "auto" : "px") : unit,
|
|
212
|
+
number,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Given a value, returns the width of the image as an integer in pixels
|
|
217
|
+
* @param value - The width of the image, e.g. 16px | 1rem | 1em | 16
|
|
218
|
+
* @returns The width of the image in pixels, e.g. 16, or undefined if the value is not a fixed unit
|
|
219
|
+
*/
|
|
220
|
+
function getNormalizedFixedUnit(value) {
|
|
221
|
+
if (value === undefined)
|
|
222
|
+
return;
|
|
223
|
+
const { unit, number } = getUnitValueParts(value.toString());
|
|
224
|
+
switch (unit) {
|
|
225
|
+
case "em":
|
|
226
|
+
case "rem":
|
|
227
|
+
return number * 16;
|
|
228
|
+
case "px":
|
|
229
|
+
case "":
|
|
230
|
+
return number;
|
|
231
|
+
default:
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* This function checks whether a width is fixed or not.
|
|
237
|
+
* @param width - The width of the image, e.g. 100 | '100px' | '100em' | '100rem'
|
|
238
|
+
* @returns Whether the width is fixed or not
|
|
239
|
+
*/
|
|
240
|
+
function isFixedWidth(width) {
|
|
241
|
+
const fixedEndings = /\d(px|em|rem)$/;
|
|
242
|
+
return (typeof width === "number" ||
|
|
243
|
+
(typeof width === "string" && fixedEndings.test(width)));
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* This function generates a srcSet for Shopify images.
|
|
247
|
+
* @param src - The source URL of the image, e.g. https://cdn.shopify.com/static/sample-images/garnished.jpeg
|
|
248
|
+
* @param sizesArray - An array of objects containing the `width`, `height`, and `crop` of the image, e.g. [\{width: 200, height: 200, crop: 'center'\}, \{width: 400, height: 400, crop: 'center'\}]
|
|
249
|
+
* @param loader - A function that takes a Shopify image URL and returns a Shopify image URL with the correct query parameters
|
|
250
|
+
* @returns A srcSet for Shopify images, e.g. 'https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=200&height=200&crop=center 200w, https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=400&height=400&crop=center 400w'
|
|
251
|
+
*/
|
|
252
|
+
export function generateSrcSet(src, sizesArray, loader = shopifyLoader, isContained = false) {
|
|
253
|
+
if (!src)
|
|
254
|
+
return "";
|
|
255
|
+
if (!sizesArray || sizesArray.length === 0)
|
|
256
|
+
return src;
|
|
257
|
+
const srcSet = sizesArray
|
|
258
|
+
.map((size, i) => {
|
|
259
|
+
var _a;
|
|
260
|
+
return `${loader({
|
|
261
|
+
src,
|
|
262
|
+
width: size.width,
|
|
263
|
+
height: size.height,
|
|
264
|
+
crop: size.crop,
|
|
265
|
+
isContained,
|
|
266
|
+
})} ${sizesArray.length === 3 ? `${i + 1}x` : `${(_a = size.width) !== null && _a !== void 0 ? _a : 0}w`}`;
|
|
267
|
+
})
|
|
268
|
+
.join(`, `);
|
|
269
|
+
return srcSet;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* This function generates an array of sizes for Shopify images, for both fixed and responsive images.
|
|
273
|
+
* @param width - The CSS width of the image
|
|
274
|
+
* @param intervals - The number of intervals to generate
|
|
275
|
+
* @param startingWidth - The starting width of the image
|
|
276
|
+
* @param incrementSize - The size of each interval
|
|
277
|
+
* @returns An array of widths
|
|
278
|
+
*/
|
|
279
|
+
export function generateImageWidths(width = "100%", intervals, startingWidth, incrementSize) {
|
|
280
|
+
const responsive = Array.from({ length: intervals }, (_, i) => i * incrementSize + startingWidth);
|
|
281
|
+
const fixed = Array.from({ length: 3 }, (_, i) => { var _a; return (i + 1) * ((_a = getNormalizedFixedUnit(width)) !== null && _a !== void 0 ? _a : 0); });
|
|
282
|
+
return isFixedWidth(width) ? fixed : responsive;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Simple utility function to convert an aspect ratio CSS string to a decimal, currently only supports values like `1:1`, not `0.5`, or `auto`
|
|
286
|
+
* @param aspectRatio - The aspect ratio of the image, e.g. `1:1`
|
|
287
|
+
* @returns The aspect ratio as a number, e.g. `1`
|
|
288
|
+
*
|
|
289
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio}
|
|
290
|
+
*/
|
|
291
|
+
export function parseAspectRatio(aspectRatio) {
|
|
292
|
+
if (!aspectRatio)
|
|
293
|
+
return;
|
|
294
|
+
const [width, height] = aspectRatio.split(":");
|
|
295
|
+
return Number(width) / Number(height);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Generate sizes for Imagery loader
|
|
299
|
+
* @param imageWidths
|
|
300
|
+
* @param aspectRatio
|
|
301
|
+
* @param crop
|
|
302
|
+
* @returns
|
|
303
|
+
*/
|
|
304
|
+
export function generateSizes(imageWidths, aspectRatio, crop = "center") {
|
|
305
|
+
if (!imageWidths)
|
|
306
|
+
return;
|
|
307
|
+
const sizes = imageWidths.map((width) => {
|
|
308
|
+
var _a;
|
|
309
|
+
return ({
|
|
310
|
+
width,
|
|
311
|
+
height: aspectRatio
|
|
312
|
+
? width / ((_a = parseAspectRatio(aspectRatio)) !== null && _a !== void 0 ? _a : 1)
|
|
313
|
+
: undefined,
|
|
314
|
+
crop,
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
return sizes;
|
|
318
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface LineItemTextIconProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
primaryText: string;
|
|
4
|
+
secondaryText: string;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
showIcon?: boolean;
|
|
7
|
+
showSecondaryText?: boolean;
|
|
8
|
+
showChevron?: boolean;
|
|
9
|
+
onClick?: () => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const LineItemTextIcon: React.ForwardRefExoticComponent<LineItemTextIconProps & React.RefAttributes<HTMLButtonElement>>;
|
|
13
|
+
export { LineItemTextIcon };
|
|
14
|
+
//# sourceMappingURL=line-item-text-icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-item-text-icons.d.ts","sourceRoot":"","sources":["../../../components/ui/line-item-text-icons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,MAAM,WAAW,qBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,gBAAgB,iGA0DrB,CAAA;AAID,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { Text } from "./text";
|
|
15
|
+
import { cn } from "../../lib/utils";
|
|
16
|
+
import { Icon } from "./icon";
|
|
17
|
+
const LineItemTextIcon = React.forwardRef((_a, ref) => {
|
|
18
|
+
var { primaryText, secondaryText, selected = false, showIcon = true, showSecondaryText = true, showChevron = true, onClick, className } = _a, props = __rest(_a, ["primaryText", "secondaryText", "selected", "showIcon", "showSecondaryText", "showChevron", "onClick", "className"]);
|
|
19
|
+
return (_jsxs("button", Object.assign({ className: cn("flex flex-row p-4 gap-2 w-full border-b border-coreColors-dividingLines", selected ? "bg-stateColors-skeleton" : "", className), ref: ref, onClick: onClick }, props, { children: [_jsx(Icon, { name: "map-pin", size: "sm", color: "coreColors-secondaryIcon", className: `${showIcon ? "" : "opacity-0"}` }), _jsxs("div", Object.assign({ className: "flex flex-col w-full items-start gap-1 overflow-hidden" }, { children: [_jsx(Text, Object.assign({ type: "body-primary", className: "text-textColors-primaryColor max-w-full truncate" }, { children: primaryText })), _jsx(Text, Object.assign({ type: "body-secondary", className: `text-textColors-secondaryColor line-clamp-2 text-left ${showSecondaryText ? "" : "opacity-0"}` }, { children: secondaryText }))] })), _jsx(Icon, { name: "chevron-right", size: "sm", color: "coreColors-secondaryIcon", className: `my-auto ${showChevron ? "" : "opacity-0"}` })] })));
|
|
20
|
+
});
|
|
21
|
+
LineItemTextIcon.displayName = "LineItemTextIcon";
|
|
22
|
+
export { LineItemTextIcon };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { Product } from "app-studio-types";
|
|
2
3
|
type Config = {
|
|
3
4
|
gridLayout?: string;
|
|
4
5
|
productImage?: {
|
|
@@ -66,24 +67,6 @@ type TapcartData = {
|
|
|
66
67
|
};
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
|
-
export type Product = {
|
|
70
|
-
variants: {
|
|
71
|
-
compareAtPrice: {
|
|
72
|
-
amount: string;
|
|
73
|
-
currencyCode: string;
|
|
74
|
-
} | undefined;
|
|
75
|
-
price: {
|
|
76
|
-
amount: string;
|
|
77
|
-
currencyCode: string;
|
|
78
|
-
};
|
|
79
|
-
}[];
|
|
80
|
-
images: {
|
|
81
|
-
src: string;
|
|
82
|
-
}[];
|
|
83
|
-
title: string;
|
|
84
|
-
tags: string[];
|
|
85
|
-
availableForSale: boolean;
|
|
86
|
-
};
|
|
87
70
|
export type ProductCardProps = {
|
|
88
71
|
config: Config;
|
|
89
72
|
tapcartData: TapcartData;
|
|
@@ -92,7 +75,10 @@ export type ProductCardProps = {
|
|
|
92
75
|
favorited?: boolean;
|
|
93
76
|
onFavoriteClick?: (event: React.MouseEvent<HTMLButtonElement>, product: Product) => void;
|
|
94
77
|
onQuickAdd?: (event: React.MouseEvent<HTMLButtonElement>, product: Product) => void;
|
|
95
|
-
openProduct?: (
|
|
78
|
+
openProduct?: (params: {
|
|
79
|
+
productId: string;
|
|
80
|
+
variantId?: string;
|
|
81
|
+
}) => void;
|
|
96
82
|
};
|
|
97
83
|
declare const ProductCard: React.FC<ProductCardProps>;
|
|
98
84
|
export { ProductCard };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../components/ui/product-card.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,KAAK,MAAM,GAAG;IACZ,UAAU,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../components/ui/product-card.tsx"],"names":[],"mappings":"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"}
|
|
@@ -4,10 +4,12 @@ import { Badge } from "./badge";
|
|
|
4
4
|
import { Favorite } from "./favorite";
|
|
5
5
|
import { Button } from "./button";
|
|
6
6
|
import { Text } from "./text";
|
|
7
|
+
import * as React from "react";
|
|
7
8
|
import { Price } from "./price";
|
|
8
9
|
import { Skeleton } from "./skeleton";
|
|
9
10
|
import { cn } from "../../lib/utils";
|
|
10
11
|
import { cva } from "class-variance-authority";
|
|
12
|
+
import { Image } from "./image";
|
|
11
13
|
const aspectScalingVariants = cva("w-full", {
|
|
12
14
|
variants: {
|
|
13
15
|
aspectRatio: {
|
|
@@ -16,14 +18,14 @@ const aspectScalingVariants = cva("w-full", {
|
|
|
16
18
|
"4:5": "aspect-[4/5]",
|
|
17
19
|
},
|
|
18
20
|
scaling: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
21
|
+
fill: "object-cover",
|
|
22
|
+
fit: "object-contain",
|
|
23
|
+
},
|
|
22
24
|
},
|
|
23
25
|
defaultVariants: {
|
|
24
26
|
aspectRatio: "2:3",
|
|
25
|
-
scaling: "fill"
|
|
26
|
-
}
|
|
27
|
+
scaling: "fill",
|
|
28
|
+
},
|
|
27
29
|
});
|
|
28
30
|
const productCardBadgeVariants = cva("absolute truncate", {
|
|
29
31
|
variants: {
|
|
@@ -61,7 +63,7 @@ const productCardFavoriteVariants = cva("absolute ", {
|
|
|
61
63
|
showSoldOutBadge: {
|
|
62
64
|
true: "",
|
|
63
65
|
false: "",
|
|
64
|
-
}
|
|
66
|
+
},
|
|
65
67
|
},
|
|
66
68
|
compoundVariants: [
|
|
67
69
|
{
|
|
@@ -99,22 +101,26 @@ const productCardFavoriteVariants = cva("absolute ", {
|
|
|
99
101
|
},
|
|
100
102
|
});
|
|
101
103
|
const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFavoriteClick, onQuickAdd, openProduct, }) => {
|
|
102
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
|
|
105
|
+
const { variants, images, title, tags } = product;
|
|
106
|
+
// Select the variant that has the lowest price that is available or just the lowest price if none are available
|
|
107
|
+
let searchVariants = variants.filter((variant) => variant.available);
|
|
108
|
+
if (searchVariants.length === 0) {
|
|
109
|
+
searchVariants = variants;
|
|
110
|
+
}
|
|
111
|
+
const variant = searchVariants.reduce((lowest, current) => {
|
|
112
|
+
return current.price.amount < lowest.price.amount ? current : lowest;
|
|
113
|
+
});
|
|
114
|
+
const src = ((_a = images[0]) === null || _a === void 0 ? void 0 : _a.url) || "";
|
|
115
|
+
const [isSelected, setIsSelected] = React.useState(false);
|
|
116
|
+
const handleFavoriteClick = () => {
|
|
117
|
+
setIsSelected((prevState) => !prevState);
|
|
111
118
|
};
|
|
112
|
-
const
|
|
113
|
-
const iconPosition = ((_a = config.favoritesIcon) === null || _a === void 0 ? void 0 : _a.layoutType) || "below-image-on-right";
|
|
119
|
+
const iconPosition = ((_b = config.favoritesIcon) === null || _b === void 0 ? void 0 : _b.layoutType) || "below-image-on-right";
|
|
114
120
|
if (isLoading) {
|
|
115
121
|
return (_jsxs("div", Object.assign({ className: "w-1/2 rounded" }, { children: [_jsx(Skeleton, { className: "w-full h-64 rounded" }), _jsx(Skeleton, { className: "h-6 w-1/2 mt-2 rounded" }), _jsx(Skeleton, { className: "h-4 w-full mt-2 rounded" })] })));
|
|
116
122
|
}
|
|
117
|
-
const productBadgesPDP = (
|
|
123
|
+
const productBadgesPDP = (_c = tapcartData === null || tapcartData === void 0 ? void 0 : tapcartData["product-badges"]) === null || _c === void 0 ? void 0 : _c.pdp;
|
|
118
124
|
const aboveBadgeKeys = Object.keys(productBadgesPDP).filter((key) => key !== "below");
|
|
119
125
|
const aboveBadges = aboveBadgeKeys.flatMap((key) => {
|
|
120
126
|
const badges = productBadgesPDP === null || productBadgesPDP === void 0 ? void 0 : productBadgesPDP[key];
|
|
@@ -126,22 +132,69 @@ const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFav
|
|
|
126
132
|
const aboveBadge = aboveBadges.length ? aboveBadges[0] : null;
|
|
127
133
|
const belowBadges = productBadgesPDP.below;
|
|
128
134
|
const belowBadge = (belowBadges === null || belowBadges === void 0 ? void 0 : belowBadges.length) ? belowBadges[0] : null;
|
|
129
|
-
const showSoldOutBadge = !product.availableForSale && !((
|
|
130
|
-
|
|
135
|
+
const showSoldOutBadge = !product.availableForSale && !((_d = config.quickAdd) === null || _d === void 0 ? void 0 : _d.enabled);
|
|
136
|
+
// Remove Shopify GID info from product id
|
|
137
|
+
const productId = product.id;
|
|
138
|
+
const variantId = variant.id;
|
|
139
|
+
// Prepare Product Open
|
|
140
|
+
const _openProduct = () => openProduct === null || openProduct === void 0 ? void 0 : openProduct({ productId, variantId });
|
|
141
|
+
const getImageSizes = (config) => {
|
|
142
|
+
switch (config.gridLayout) {
|
|
143
|
+
case "1x1":
|
|
144
|
+
return "100vw";
|
|
145
|
+
case "2x2":
|
|
146
|
+
return "50vw";
|
|
147
|
+
case "3x3":
|
|
148
|
+
return "33vw";
|
|
149
|
+
default:
|
|
150
|
+
return "100vw";
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const sizes = getImageSizes(config);
|
|
154
|
+
return (_jsx("div", Object.assign({ className: `w-1/2` }, { children: _jsxs("div", Object.assign({ className: "w-full active:opacity-70", onClick: () => {
|
|
155
|
+
_openProduct();
|
|
156
|
+
} }, { children: [((_e = config.productImage) === null || _e === void 0 ? void 0 : _e.enabled) && (_jsxs("div", Object.assign({ className: "relative w-full overflow-hidden", style: {
|
|
131
157
|
borderTopLeftRadius: `${config.productImage.cornerRadius}px`,
|
|
132
158
|
borderTopRightRadius: `${config.productImage.cornerRadius}px`,
|
|
133
|
-
} }, { children: [_jsx(
|
|
159
|
+
} }, { children: [_jsx(Image, { alt: product.title, aspectRatio: (_g = (_f = tapcartData.theme) === null || _f === void 0 ? void 0 : _f.productImages) === null || _g === void 0 ? void 0 : _g.aspectRatio, data: product.featuredImage || product.images[0], sizes: sizes, objectFit: (_j = (_h = tapcartData.theme) === null || _h === void 0 ? void 0 : _h.productImages) === null || _j === void 0 ? void 0 : _j.scaling }), aboveBadge && product.availableForSale && (_jsx(Badge, Object.assign({ size: "plp-layout", className: cn(productCardBadgeVariants({
|
|
134
160
|
verticalPosition: aboveBadge.verticalPosition,
|
|
135
161
|
horizontalPosition: aboveBadge.horizontalPosition,
|
|
136
162
|
})), style: {
|
|
137
163
|
color: aboveBadge.fontColor,
|
|
138
164
|
backgroundColor: aboveBadge.backgroundColor,
|
|
139
|
-
}, alignment: aboveBadge.horizontalPosition, cornerRadius: aboveBadge.cornerRadius, icon: aboveBadge.image }, { children: aboveBadge.text }))), showSoldOutBadge && (_jsx(Badge, Object.assign({ size: "plp-layout", className: "absolute left-0 bottom-0 mb-2 bg-stateColors-disabled", alignment: "start", cornerRadius: "rounded", type: "text-only" }, { children: "Sold Out" }))), ((
|
|
165
|
+
}, alignment: aboveBadge.horizontalPosition, cornerRadius: aboveBadge.cornerRadius, icon: aboveBadge.image }, { children: aboveBadge.text }))), showSoldOutBadge && (_jsx(Badge, Object.assign({ size: "plp-layout", className: "absolute left-0 bottom-0 mb-2 bg-stateColors-disabled", alignment: "start", cornerRadius: "rounded", type: "text-only" }, { children: "Sold Out" }))), ((_k = config.favoritesIcon) === null || _k === void 0 ? void 0 : _k.enabled) &&
|
|
166
|
+
iconPosition !== "below-image-on-right" && (_jsx(Favorite, { className: cn(productCardFavoriteVariants({
|
|
167
|
+
iconPosition,
|
|
168
|
+
badgeHorizontalPosition: aboveBadge === null || aboveBadge === void 0 ? void 0 : aboveBadge.horizontalPosition,
|
|
169
|
+
badgeVerticalPosition: aboveBadge === null || aboveBadge === void 0 ? void 0 : aboveBadge.verticalPosition,
|
|
170
|
+
showSoldOutBadge,
|
|
171
|
+
})), selected: favorited, onClick: (e) => {
|
|
172
|
+
onFavoriteClick === null || onFavoriteClick === void 0 ? void 0 : onFavoriteClick(e, product);
|
|
173
|
+
}, icon: ((_m = (_l = config.favoritesIcon) === null || _l === void 0 ? void 0 : _l.icon) === null || _m === void 0 ? void 0 : _m.type) === "internal"
|
|
174
|
+
? (_p = (_o = config.favoritesIcon) === null || _o === void 0 ? void 0 : _o.icon) === null || _p === void 0 ? void 0 : _p.url
|
|
175
|
+
: undefined }))] }))), ((_q = config.quickAdd) === null || _q === void 0 ? void 0 : _q.enabled) && (_jsx(Button, Object.assign({ className: "outline-0", style: {
|
|
140
176
|
borderBottomLeftRadius: `${config.quickAdd.cornerRadius}px`,
|
|
141
177
|
borderBottomRightRadius: `${config.quickAdd.cornerRadius}px`,
|
|
142
|
-
}, labelClassName: cn("outline-0 w-full", {
|
|
178
|
+
}, labelClassName: cn("outline-0 w-full", { uppercase: (_r = config.quickAdd) === null || _r === void 0 ? void 0 : _r.uppercase }, { "text-left": ((_s = config.quickAdd) === null || _s === void 0 ? void 0 : _s.textAlignment) === "left" }, { "text-right": ((_t = config.quickAdd) === null || _t === void 0 ? void 0 : _t.textAlignment) === "right" }, { "text-center": ((_u = config.quickAdd) === null || _u === void 0 ? void 0 : _u.textAlignment) === "center" }), labelStyle: { fontSize: (_v = config.quickAdd) === null || _v === void 0 ? void 0 : _v.fontSize }, variant: "quickadd", size: "default", onClick: (e) => {
|
|
143
179
|
e.stopPropagation();
|
|
144
180
|
onQuickAdd === null || onQuickAdd === void 0 ? void 0 : onQuickAdd(e, product);
|
|
145
|
-
} }, { children: "+ Quick add" }))), _jsxs("div", Object.assign({ className: "w-full flex-col justify-start items-start gap-0 inline-flex" }, { children: [belowBadge && (_jsx("div", Object.assign({ className: cn("mt-2 w-full flex justify-start", {
|
|
181
|
+
} }, { children: "+ Quick add" }))), _jsxs("div", Object.assign({ className: "w-full flex-col justify-start items-start gap-0 inline-flex" }, { children: [belowBadge && (_jsx("div", Object.assign({ className: cn("mt-2 w-full flex justify-start", {
|
|
182
|
+
"justify-end": belowBadge.horizontalPosition === "end",
|
|
183
|
+
}) }, { children: _jsx(Badge, Object.assign({ size: "plp-layout", alignment: belowBadge.horizontalPosition, icon: belowBadge.image, className: cn("truncate", { rounded: belowBadge.cornerRadius === "rounded" }, { "rounded-none": belowBadge.cornerRadius === "square" }) }, { children: belowBadge.text })) }))), ((_w = config.productTitle) === null || _w === void 0 ? void 0 : _w.enabled) && (_jsx("div", Object.assign({ className: "mt-2 w-full" }, { children: _jsx(Text, Object.assign({ type: "body-secondary", className: cn({ uppercase: (_x = config.productTitle) === null || _x === void 0 ? void 0 : _x.uppercase }, {
|
|
184
|
+
"text-left": ((_y = config.productTitle) === null || _y === void 0 ? void 0 : _y.textAlignment) === "left",
|
|
185
|
+
}, {
|
|
186
|
+
"text-right": ((_z = config.productTitle) === null || _z === void 0 ? void 0 : _z.textAlignment) === "right",
|
|
187
|
+
}, {
|
|
188
|
+
"text-center": ((_0 = config.productTitle) === null || _0 === void 0 ? void 0 : _0.textAlignment) === "center",
|
|
189
|
+
}, { truncate: !((_1 = config.productTitle) === null || _1 === void 0 ? void 0 : _1.wrapText) }, { "text-wrap": (_2 = config.productTitle) === null || _2 === void 0 ? void 0 : _2.wrapText }, "text-textColors-productTitle"), style: { fontSize: (_3 = config.productTitle) === null || _3 === void 0 ? void 0 : _3.fontSize } }, { children: title })) }))), _jsxs("div", Object.assign({ className: cn("flex flex-row w-full gap-2 mt-1 justify-end", { "justify-start": ((_4 = config.price) === null || _4 === void 0 ? void 0 : _4.textAlignment) === "left" }, { "justify-end": ((_5 = config.price) === null || _5 === void 0 ? void 0 : _5.textAlignment) === "right" }, { "justify-center": ((_6 = config.price) === null || _6 === void 0 ? void 0 : _6.textAlignment) === "center" }) }, { children: [((_7 = config.price) === null || _7 === void 0 ? void 0 : _7.enabled) && (_jsx(Price, { price: parseFloat(variant.price.amount), isSale: !!variant.compareAtPrice &&
|
|
190
|
+
variant.compareAtPrice &&
|
|
191
|
+
parseFloat((_8 = variant.compareAtPrice) === null || _8 === void 0 ? void 0 : _8.amount) >
|
|
192
|
+
parseFloat(variant.price.amount), compareAtPrice: variant.compareAtPrice &&
|
|
193
|
+
parseFloat((_9 = variant.compareAtPrice) === null || _9 === void 0 ? void 0 : _9.amount), currency: tapcartData.currency.code, locale: tapcartData.currency.locale, fontSize: (_10 = config.price) === null || _10 === void 0 ? void 0 : _10.fontSize })), ((_11 = config.favoritesIcon) === null || _11 === void 0 ? void 0 : _11.enabled) &&
|
|
194
|
+
config.favoritesIcon.layoutType === "below-image-on-right" && (_jsx("div", Object.assign({ className: "w-8 h-8 flex items-center justify-center" }, { children: _jsx(Favorite, { selected: favorited, onClick: (e) => {
|
|
195
|
+
onFavoriteClick === null || onFavoriteClick === void 0 ? void 0 : onFavoriteClick(e, product);
|
|
196
|
+
}, size: "small", icon: ((_13 = (_12 = config.favoritesIcon) === null || _12 === void 0 ? void 0 : _12.icon) === null || _13 === void 0 ? void 0 : _13.type) === "internal"
|
|
197
|
+
? (_15 = (_14 = config.favoritesIcon) === null || _14 === void 0 ? void 0 : _14.icon) === null || _15 === void 0 ? void 0 : _15.url
|
|
198
|
+
: undefined }) })))] }))] }))] })) })));
|
|
146
199
|
};
|
|
147
200
|
export { ProductCard };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface QuantityPickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
decreaseIcon: string;
|
|
4
|
+
increaseIcon: string;
|
|
5
|
+
deleteIcon: string;
|
|
6
|
+
onDecreaseClick: React.ReactEventHandler;
|
|
7
|
+
onIncreaseClick: React.ReactEventHandler;
|
|
8
|
+
value: number;
|
|
9
|
+
setValue: (_: number) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const QuantityPicker: React.ForwardRefExoticComponent<QuantityPickerProps & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export { QuantityPicker };
|
|
14
|
+
//# sourceMappingURL=quantity-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantity-picker.d.ts","sourceRoot":"","sources":["../../../components/ui/quantity-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAgBD,QAAA,MAAM,cAAc,4FAyCnB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import * as React from "react";
|
|
15
|
+
import { cn } from "../../lib/utils";
|
|
16
|
+
import { Icon } from "./icon";
|
|
17
|
+
const IconButton = ({ icon, handler, className }) => (_jsx("button", Object.assign({ onClick: handler, className: cn("flex items-center justify-center h-8 w-8 bg-stateColors-skeleton outline outline-1 outline-stateColors-skeleton", className) }, { children: _jsx(Icon, { name: icon, size: "sm", color: "coreColors-secondaryIcon" }) })));
|
|
18
|
+
const QuantityPicker = React.forwardRef((_a, ref) => {
|
|
19
|
+
var { className, decreaseIcon, increaseIcon, deleteIcon, onDecreaseClick, onIncreaseClick, value, setValue } = _a, props = __rest(_a, ["className", "decreaseIcon", "increaseIcon", "deleteIcon", "onDecreaseClick", "onIncreaseClick", "value", "setValue"]);
|
|
20
|
+
return (_jsxs("div", Object.assign({ className: cn("flex", className), ref: ref }, props, { children: [_jsx(IconButton, { handler: onDecreaseClick, icon: value === 1 ? deleteIcon : decreaseIcon, className: "rounded-tl rounded-bl" }), _jsx("div", Object.assign({ className: "w-12 py-1 flex justify-center bg-coreColors-inputBackground outline outline-1 outline-coreColors-dividingLines text-[15px] font-sfpro-roboto leading-[160%] font-normal text-textColors-primaryColor" }, { children: _jsx("input", { type: "tel", pattern: "[0-9]*", value: value, onBlur: (e) => (e.target.value = value.toString()), onFocus: (e) => (e.target.value = ""), onChange: (e) => setValue(parseInt(e.target.value) || 0), className: "w-8 focus-visible:outline-none text-center" }) })), _jsx(IconButton, { handler: onIncreaseClick, icon: increaseIcon, className: "rounded-tr rounded-br" })] })));
|
|
21
|
+
});
|
|
22
|
+
QuantityPicker.displayName = "QuantityPicker";
|
|
23
|
+
export { QuantityPicker };
|