@shopify/shop-minis-react 0.0.22 → 0.0.24
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/_virtual/index10.js +2 -2
- package/dist/_virtual/index4.js +2 -2
- package/dist/_virtual/index5.js +2 -2
- package/dist/_virtual/index6.js +2 -3
- package/dist/_virtual/index6.js.map +1 -1
- package/dist/_virtual/index7.js +3 -2
- package/dist/_virtual/index7.js.map +1 -1
- package/dist/_virtual/index9.js +2 -2
- package/dist/components/commerce/quantity-selector.js +80 -0
- package/dist/components/commerce/quantity-selector.js.map +1 -0
- package/dist/index.js +213 -211
- package/dist/index.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/@radix-ui_react-use-is-hydrated@0.1.0_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/minus.js +13 -0
- package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/minus.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/plus.js +16 -0
- package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/plus.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mpd-parser@1.3.1/node_modules/mpd-parser/dist/mpd-parser.es.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.0/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/package.json +5 -5
- package/src/components/commerce/quantity-selector.tsx +92 -0
- package/src/components/index.ts +1 -0
package/dist/_virtual/index10.js
CHANGED
package/dist/_virtual/index4.js
CHANGED
package/dist/_virtual/index5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __require as r } from "../shop-minis-react/node_modules/.pnpm
|
|
1
|
+
import { __require as r } from "../shop-minis-react/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.0/node_modules/use-sync-external-store/shim/index.js";
|
|
2
2
|
var i = r();
|
|
3
3
|
export {
|
|
4
|
-
i as
|
|
4
|
+
i as s
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=index5.js.map
|
package/dist/_virtual/index6.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var i = r();
|
|
1
|
+
var e = { exports: {} };
|
|
3
2
|
export {
|
|
4
|
-
|
|
3
|
+
e as __module
|
|
5
4
|
};
|
|
6
5
|
//# sourceMappingURL=index6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index6.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/_virtual/index7.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index7.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/_virtual/index9.js
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as t, Fragment as y, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useEffect as u, useCallback as m } from "react";
|
|
3
|
+
import { cn as n } from "../../lib/utils.js";
|
|
4
|
+
import { IconButton as p } from "../atoms/icon-button.js";
|
|
5
|
+
import k from "../../shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/minus.js";
|
|
6
|
+
import w from "../../shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/plus.js";
|
|
7
|
+
const C = ({
|
|
8
|
+
quantity: r,
|
|
9
|
+
onQuantityChange: d,
|
|
10
|
+
maxQuantity: s,
|
|
11
|
+
minQuantity: o = 1,
|
|
12
|
+
disabled: f = !1
|
|
13
|
+
}) => {
|
|
14
|
+
const [e, c] = h(r);
|
|
15
|
+
u(() => {
|
|
16
|
+
c(r);
|
|
17
|
+
}, [r]), u(() => {
|
|
18
|
+
d(e);
|
|
19
|
+
}, [e, d]);
|
|
20
|
+
const i = f || e >= s, l = f || e <= o, x = m(() => {
|
|
21
|
+
if (i) return;
|
|
22
|
+
const a = e + 1 > s ? e : e + 1;
|
|
23
|
+
c(a);
|
|
24
|
+
}, [i, e, s]), b = m(() => {
|
|
25
|
+
if (l) return;
|
|
26
|
+
const a = e - 1 < o ? e : e - 1;
|
|
27
|
+
c(a);
|
|
28
|
+
}, [l, e, o]);
|
|
29
|
+
return /* @__PURE__ */ t(y, { children: /* @__PURE__ */ t(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
"data-testid": "QuantitySelector",
|
|
33
|
+
className: n("inline-flex w-auto bg-tertiary rounded-[8px]"),
|
|
34
|
+
children: /* @__PURE__ */ g(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
className: n(
|
|
38
|
+
"flex h-space-32 items-center self-center overflow-hidden rounded-radius-8 bg-bg-fill-secondary",
|
|
39
|
+
"p-space-8"
|
|
40
|
+
),
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ t(
|
|
43
|
+
p,
|
|
44
|
+
{
|
|
45
|
+
Icon: k,
|
|
46
|
+
onClick: b,
|
|
47
|
+
buttonStyles: "transition bg-transparent",
|
|
48
|
+
filled: !1,
|
|
49
|
+
size: "sm",
|
|
50
|
+
iconStyles: n(
|
|
51
|
+
l ? "text-background" : "text-foreground",
|
|
52
|
+
"stroke-3"
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ t("div", { className: n("grow", "w-[20px]"), children: /* @__PURE__ */ t("span", { className: "flex items-center justify-center w-full h-full font-medium text-[10px]", children: e }) }),
|
|
57
|
+
/* @__PURE__ */ t(
|
|
58
|
+
p,
|
|
59
|
+
{
|
|
60
|
+
Icon: w,
|
|
61
|
+
onClick: x,
|
|
62
|
+
buttonStyles: "transition bg-transparent",
|
|
63
|
+
filled: !1,
|
|
64
|
+
size: "sm",
|
|
65
|
+
iconStyles: n(
|
|
66
|
+
i ? "text-background" : "text-secondary",
|
|
67
|
+
"stroke-3"
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
) });
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
C as QuantitySelector
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=quantity-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantity-selector.js","sources":["../../../src/components/commerce/quantity-selector.tsx"],"sourcesContent":["import {useCallback, useEffect, useState} from 'react'\n\nimport {Minus, Plus} from 'lucide-react'\n\nimport {cn} from '../../lib/utils'\nimport {IconButton} from '../atoms/icon-button'\n\ninterface QuantitySelectorProps {\n quantity: number\n onQuantityChange: (quantity: number) => void\n maxQuantity: number\n minQuantity?: number\n disabled?: boolean\n}\n\nexport const QuantitySelector = ({\n quantity: _quantity,\n onQuantityChange,\n maxQuantity,\n minQuantity = 1,\n disabled = false,\n}: QuantitySelectorProps) => {\n const [quantity, setQuantity] = useState(_quantity)\n\n useEffect(() => {\n setQuantity(_quantity)\n }, [_quantity])\n\n useEffect(() => {\n onQuantityChange(quantity)\n }, [quantity, onQuantityChange])\n\n const incrementDisabled = disabled || quantity >= maxQuantity\n const decrementDisabled = disabled || quantity <= minQuantity\n\n const incrementQuantity = useCallback(() => {\n if (incrementDisabled) return\n const newQuantity = quantity + 1 > maxQuantity ? quantity : quantity + 1\n setQuantity(newQuantity)\n }, [incrementDisabled, quantity, maxQuantity])\n\n const decrementQuantity = useCallback(() => {\n if (decrementDisabled) return\n const newQuantity = quantity - 1 < minQuantity ? quantity : quantity - 1\n setQuantity(newQuantity)\n }, [decrementDisabled, quantity, minQuantity])\n\n return (\n <>\n <div\n data-testid=\"QuantitySelector\"\n className={cn('inline-flex w-auto bg-tertiary rounded-[8px]')}\n >\n <div\n className={cn(\n 'flex h-space-32 items-center self-center overflow-hidden rounded-radius-8 bg-bg-fill-secondary',\n `p-space-8`\n )}\n >\n <IconButton\n Icon={Minus}\n onClick={decrementQuantity}\n buttonStyles=\"transition bg-transparent\"\n filled={false}\n size=\"sm\"\n iconStyles={cn(\n decrementDisabled ? 'text-background' : 'text-foreground',\n 'stroke-3'\n )}\n />\n\n <div className={cn('grow', `w-[20px]`)}>\n <span className=\"flex items-center justify-center w-full h-full font-medium text-[10px]\">\n {quantity}\n </span>\n </div>\n <IconButton\n Icon={Plus}\n onClick={incrementQuantity}\n buttonStyles=\"transition bg-transparent\"\n filled={false}\n size=\"sm\"\n iconStyles={cn(\n incrementDisabled ? 'text-background' : 'text-secondary',\n 'stroke-3'\n )}\n />\n </div>\n </div>\n </>\n )\n}\n"],"names":["QuantitySelector","_quantity","onQuantityChange","maxQuantity","minQuantity","disabled","quantity","setQuantity","useState","useEffect","incrementDisabled","decrementDisabled","incrementQuantity","useCallback","newQuantity","decrementQuantity","jsx","Fragment","cn","jsxs","IconButton","Minus","Plus"],"mappings":";;;;;;AAeO,MAAMA,IAAmB,CAAC;AAAA,EAC/B,UAAUC;AAAA,EACV,kBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,UAAAC,IAAW;AACb,MAA6B;AAC3B,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAASP,CAAS;AAElD,EAAAQ,EAAU,MAAM;AACd,IAAAF,EAAYN,CAAS;AAAA,EAAA,GACpB,CAACA,CAAS,CAAC,GAEdQ,EAAU,MAAM;AACd,IAAAP,EAAiBI,CAAQ;AAAA,EAAA,GACxB,CAACA,GAAUJ,CAAgB,CAAC;AAEzB,QAAAQ,IAAoBL,KAAYC,KAAYH,GAC5CQ,IAAoBN,KAAYC,KAAYF,GAE5CQ,IAAoBC,EAAY,MAAM;AAC1C,QAAIH,EAAmB;AACvB,UAAMI,IAAcR,IAAW,IAAIH,IAAcG,IAAWA,IAAW;AACvE,IAAAC,EAAYO,CAAW;AAAA,EACtB,GAAA,CAACJ,GAAmBJ,GAAUH,CAAW,CAAC,GAEvCY,IAAoBF,EAAY,MAAM;AAC1C,QAAIF,EAAmB;AACvB,UAAMG,IAAcR,IAAW,IAAIF,IAAcE,IAAWA,IAAW;AACvE,IAAAC,EAAYO,CAAW;AAAA,EACtB,GAAA,CAACH,GAAmBL,GAAUF,CAAW,CAAC;AAE7C,SAEI,gBAAAY,EAAAC,GAAA,EAAA,UAAA,gBAAAD;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAY;AAAA,MACZ,WAAWE,EAAG,8CAA8C;AAAA,MAE5D,UAAA,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWD;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,UAEA,UAAA;AAAA,YAAA,gBAAAF;AAAA,cAACI;AAAA,cAAA;AAAA,gBACC,MAAMC;AAAA,gBACN,SAASN;AAAA,gBACT,cAAa;AAAA,gBACb,QAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,YAAYG;AAAA,kBACVP,IAAoB,oBAAoB;AAAA,kBACxC;AAAA,gBAAA;AAAA,cACF;AAAA,YACF;AAAA,YAEC,gBAAAK,EAAA,OAAA,EAAI,WAAWE,EAAG,QAAQ,UAAU,GACnC,UAAA,gBAAAF,EAAC,QAAK,EAAA,WAAU,0EACb,UAAAV,EACH,CAAA,GACF;AAAA,YACA,gBAAAU;AAAA,cAACI;AAAA,cAAA;AAAA,gBACC,MAAME;AAAA,gBACN,SAASV;AAAA,gBACT,cAAa;AAAA,gBACb,QAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,YAAYM;AAAA,kBACVR,IAAoB,oBAAoB;AAAA,kBACxC;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA,GAEJ;AAEJ;"}
|
package/dist/index.js
CHANGED
|
@@ -5,226 +5,228 @@ import { ProductLink as s } from "./components/commerce/product-link.js";
|
|
|
5
5
|
import { MerchantCard as u, MerchantCardPrimitive as x } from "./components/commerce/merchant-card.js";
|
|
6
6
|
import { ProductCardSkeleton as c } from "./components/commerce/product-card-skeleton.js";
|
|
7
7
|
import { MerchantCardSkeleton as g } from "./components/commerce/merchant-card-skeleton.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
8
|
+
import { QuantitySelector as D } from "./components/commerce/quantity-selector.js";
|
|
9
|
+
import { TransitionContainer as C } from "./components/navigation/transition-container.js";
|
|
10
|
+
import { TransitionLink as T } from "./components/navigation/transition-link.js";
|
|
11
|
+
import { Button as I } from "./components/atoms/button.js";
|
|
12
|
+
import { FavoriteButton as v } from "./components/atoms/favorite-button.js";
|
|
13
|
+
import { IconButton as b } from "./components/atoms/icon-button.js";
|
|
14
|
+
import { ThumbhashImage as k } from "./components/atoms/thumbhash-image.js";
|
|
15
|
+
import { Touchable as E } from "./components/atoms/touchable.js";
|
|
16
|
+
import { AlertDialogAtom as N } from "./components/atoms/alert-dialog.js";
|
|
17
|
+
import { List as L } from "./components/atoms/list.js";
|
|
18
|
+
import { VideoPlayer as H } from "./components/atoms/video-player.js";
|
|
19
|
+
import { Accordion as V, AccordionContent as U, AccordionItem as z, AccordionTrigger as _ } from "./components/ui/accordion.js";
|
|
20
|
+
import { Alert as Q, AlertDescription as W, AlertTitle as j } from "./components/ui/alert.js";
|
|
21
|
+
import { AlertDialog as J, AlertDialogAction as K, AlertDialogCancel as X, AlertDialogContent as Z, AlertDialogDescription as $, AlertDialogFooter as rr, AlertDialogHeader as er, AlertDialogOverlay as or, AlertDialogPortal as tr, AlertDialogTitle as ar, AlertDialogTrigger as ir } from "./components/ui/alert-dialog.js";
|
|
22
|
+
import { Avatar as pr, AvatarFallback as mr, AvatarImage as sr } from "./components/ui/avatar.js";
|
|
23
|
+
import { Badge as ur, badgeVariants as xr } from "./components/ui/badge.js";
|
|
24
|
+
import { Card as cr, CardAction as dr, CardContent as gr, CardDescription as Sr, CardFooter as Dr, CardHeader as Ar, CardTitle as Cr } from "./components/ui/card.js";
|
|
25
|
+
import { Carousel as Tr, CarouselContent as hr, CarouselItem as Ir, CarouselNext as wr, CarouselPrevious as vr } from "./components/ui/carousel.js";
|
|
26
|
+
import { Checkbox as br } from "./components/ui/checkbox.js";
|
|
27
|
+
import { Dialog as kr, DialogClose as Br, DialogContent as Er, DialogDescription as Mr, DialogFooter as Nr, DialogHeader as yr, DialogOverlay as Lr, DialogPortal as Gr, DialogTitle as Hr, DialogTrigger as Or } from "./components/ui/dialog.js";
|
|
28
|
+
import { Drawer as Ur, DrawerClose as zr, DrawerContent as _r, DrawerDescription as Yr, DrawerFooter as Qr, DrawerHeader as Wr, DrawerOverlay as jr, DrawerPortal as qr, DrawerTitle as Jr, DrawerTrigger as Kr } from "./components/ui/drawer.js";
|
|
29
|
+
import { Input as Zr } from "./components/ui/input.js";
|
|
30
|
+
import { Label as re } from "./components/ui/label.js";
|
|
31
|
+
import { Progress as oe } from "./components/ui/progress.js";
|
|
32
|
+
import { RadioGroup as ae, RadioGroupItem as ie } from "./components/ui/radio-group.js";
|
|
33
|
+
import { ResizableHandle as pe, ResizablePanel as me, ResizablePanelGroup as se } from "./components/ui/resizable.js";
|
|
34
|
+
import { ScrollArea as ue, ScrollBar as xe } from "./components/ui/scroll-area.js";
|
|
35
|
+
import { Select as ce, SelectContent as de, SelectGroup as ge, SelectItem as Se, SelectLabel as De, SelectScrollDownButton as Ae, SelectScrollUpButton as Ce, SelectSeparator as Pe, SelectTrigger as Te, SelectValue as he } from "./components/ui/select.js";
|
|
36
|
+
import { Separator as we } from "./components/ui/separator.js";
|
|
37
|
+
import { Sheet as Re, SheetClose as be, SheetContent as Fe, SheetDescription as ke, SheetFooter as Be, SheetHeader as Ee, SheetTitle as Me, SheetTrigger as Ne } from "./components/ui/sheet.js";
|
|
38
|
+
import { Toaster as Le } from "./components/ui/sonner.js";
|
|
39
|
+
import { Skeleton as He } from "./components/ui/skeleton.js";
|
|
40
|
+
import { useRecentProducts as Ve } from "./hooks/user/useRecentProducts.js";
|
|
41
|
+
import { useRecentShops as ze } from "./hooks/user/useRecentShops.js";
|
|
42
|
+
import { useSavedProducts as Ye } from "./hooks/user/useSavedProducts.js";
|
|
43
|
+
import { useSavedProductsActions as We } from "./hooks/user/useSavedProductsActions.js";
|
|
44
|
+
import { useFollowedShops as qe } from "./hooks/user/useFollowedShops.js";
|
|
45
|
+
import { useFollowedShopsActions as Ke } from "./hooks/user/useFollowedShopsActions.js";
|
|
46
|
+
import { useCurrentUser as Ze } from "./hooks/user/useCurrentUser.js";
|
|
47
|
+
import { useOrders as ro } from "./hooks/user/useOrders.js";
|
|
48
|
+
import { useBuyerAttributes as oo } from "./hooks/user/useBuyerAttributes.js";
|
|
49
|
+
import { useProductListActions as ao } from "./hooks/product/useProductListActions.js";
|
|
50
|
+
import { useProductLists as lo } from "./hooks/product/useProductLists.js";
|
|
51
|
+
import { useProductList as mo } from "./hooks/product/useProductList.js";
|
|
52
|
+
import { useProduct as no } from "./hooks/product/useProduct.js";
|
|
53
|
+
import { useProducts as xo } from "./hooks/product/useProducts.js";
|
|
54
|
+
import { useProductVariants as co } from "./hooks/product/useProductVariants.js";
|
|
55
|
+
import { useProductMedia as So } from "./hooks/product/useProductMedia.js";
|
|
56
|
+
import { useProductSearch as Ao } from "./hooks/product/useProductSearch.js";
|
|
57
|
+
import { useRecommendedProducts as Po } from "./hooks/product/useRecommendedProducts.js";
|
|
58
|
+
import { usePopularProducts as ho } from "./hooks/product/usePopularProducts.js";
|
|
59
|
+
import { useCuratedProducts as wo } from "./hooks/product/useCuratedProducts.js";
|
|
60
|
+
import { useAsyncStorage as Ro } from "./hooks/storage/useAsyncStorage.js";
|
|
61
|
+
import { useSecureStorage as Fo } from "./hooks/storage/useSecureStorage.js";
|
|
62
|
+
import { useImageUpload as Bo } from "./hooks/storage/useImageUpload.js";
|
|
63
|
+
import { useShopNavigation as Mo } from "./hooks/navigation/useShopNavigation.js";
|
|
64
|
+
import { useCloseMini as yo } from "./hooks/navigation/useCloseMini.js";
|
|
65
|
+
import { useDeeplink as Go } from "./hooks/navigation/useDeeplink.js";
|
|
66
|
+
import { useNavigateWithTransition as Oo } from "./hooks/navigation/useNavigateWithTransition.js";
|
|
67
|
+
import { useShop as Uo } from "./hooks/shop/useShop.js";
|
|
68
|
+
import { useShopCartActions as _o } from "./hooks/shop/useShopCartActions.js";
|
|
69
|
+
import { useRecommendedShops as Qo } from "./hooks/shop/useRecommendedShops.js";
|
|
70
|
+
import { useErrorToast as jo } from "./hooks/util/useErrorToast.js";
|
|
71
|
+
import { useErrorScreen as Jo } from "./hooks/util/useErrorScreen.js";
|
|
72
|
+
import { useShare as Xo } from "./hooks/util/useShare.js";
|
|
73
|
+
import { useImagePicker as $o } from "./hooks/util/useImagePicker.js";
|
|
74
|
+
import { MiniEntityNotFoundError as et, MiniError as ot, MiniNetworkError as tt, formatError as at } from "./utils/errors.js";
|
|
75
|
+
import { extractBrandTheme as lt, formatReviewCount as pt, getFeaturedImages as mt, normalizeRating as st } from "./utils/merchant-card.js";
|
|
76
|
+
import { parseUrl as ut } from "./utils/parseUrl.js";
|
|
77
|
+
import { Consent as ft, ConsentStatus as ct } from "./shop-minis-platform/src/types/permissions.js";
|
|
77
78
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
79
|
+
V as Accordion,
|
|
80
|
+
U as AccordionContent,
|
|
81
|
+
z as AccordionItem,
|
|
82
|
+
_ as AccordionTrigger,
|
|
83
|
+
Q as Alert,
|
|
84
|
+
W as AlertDescription,
|
|
85
|
+
J as AlertDialog,
|
|
86
|
+
K as AlertDialogAction,
|
|
87
|
+
N as AlertDialogAtom,
|
|
88
|
+
X as AlertDialogCancel,
|
|
89
|
+
Z as AlertDialogContent,
|
|
90
|
+
$ as AlertDialogDescription,
|
|
91
|
+
rr as AlertDialogFooter,
|
|
92
|
+
er as AlertDialogHeader,
|
|
93
|
+
or as AlertDialogOverlay,
|
|
94
|
+
tr as AlertDialogPortal,
|
|
95
|
+
ar as AlertDialogTitle,
|
|
96
|
+
ir as AlertDialogTrigger,
|
|
97
|
+
j as AlertTitle,
|
|
98
|
+
pr as Avatar,
|
|
99
|
+
mr as AvatarFallback,
|
|
100
|
+
sr as AvatarImage,
|
|
101
|
+
ur as Badge,
|
|
102
|
+
I as Button,
|
|
103
|
+
cr as Card,
|
|
104
|
+
dr as CardAction,
|
|
105
|
+
gr as CardContent,
|
|
106
|
+
Sr as CardDescription,
|
|
107
|
+
Dr as CardFooter,
|
|
108
|
+
Ar as CardHeader,
|
|
109
|
+
Cr as CardTitle,
|
|
110
|
+
Tr as Carousel,
|
|
111
|
+
hr as CarouselContent,
|
|
112
|
+
Ir as CarouselItem,
|
|
113
|
+
wr as CarouselNext,
|
|
114
|
+
vr as CarouselPrevious,
|
|
115
|
+
br as Checkbox,
|
|
116
|
+
ft as Consent,
|
|
117
|
+
ct as ConsentStatus,
|
|
117
118
|
o as DATA_NAVIGATION_TYPE_ATTRIBUTE,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
119
|
+
kr as Dialog,
|
|
120
|
+
Br as DialogClose,
|
|
121
|
+
Er as DialogContent,
|
|
122
|
+
Mr as DialogDescription,
|
|
123
|
+
Nr as DialogFooter,
|
|
124
|
+
yr as DialogHeader,
|
|
125
|
+
Lr as DialogOverlay,
|
|
126
|
+
Gr as DialogPortal,
|
|
127
|
+
Hr as DialogTitle,
|
|
128
|
+
Or as DialogTrigger,
|
|
129
|
+
Ur as Drawer,
|
|
130
|
+
zr as DrawerClose,
|
|
131
|
+
_r as DrawerContent,
|
|
132
|
+
Yr as DrawerDescription,
|
|
133
|
+
Qr as DrawerFooter,
|
|
134
|
+
Wr as DrawerHeader,
|
|
135
|
+
jr as DrawerOverlay,
|
|
136
|
+
qr as DrawerPortal,
|
|
137
|
+
Jr as DrawerTitle,
|
|
138
|
+
Kr as DrawerTrigger,
|
|
139
|
+
v as FavoriteButton,
|
|
140
|
+
b as IconButton,
|
|
141
|
+
Zr as Input,
|
|
142
|
+
re as Label,
|
|
143
|
+
L as List,
|
|
143
144
|
u as MerchantCard,
|
|
144
145
|
x as MerchantCardPrimitive,
|
|
145
146
|
g as MerchantCardSkeleton,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
et as MiniEntityNotFoundError,
|
|
148
|
+
ot as MiniError,
|
|
149
|
+
tt as MiniNetworkError,
|
|
149
150
|
i as MinisContainer,
|
|
150
151
|
t as NAVIGATION_TYPES,
|
|
151
152
|
p as ProductCard,
|
|
152
153
|
c as ProductCardSkeleton,
|
|
153
154
|
s as ProductLink,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
ie as
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
se as
|
|
161
|
-
|
|
162
|
-
xe as
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
he as
|
|
173
|
-
we as
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
C as
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
st as
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
ao as
|
|
214
|
-
|
|
215
|
-
So as
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Ve as
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
Ye as
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
Uo as
|
|
228
|
-
|
|
155
|
+
oe as Progress,
|
|
156
|
+
D as QuantitySelector,
|
|
157
|
+
ae as RadioGroup,
|
|
158
|
+
ie as RadioGroupItem,
|
|
159
|
+
pe as ResizableHandle,
|
|
160
|
+
me as ResizablePanel,
|
|
161
|
+
se as ResizablePanelGroup,
|
|
162
|
+
ue as ScrollArea,
|
|
163
|
+
xe as ScrollBar,
|
|
164
|
+
ce as Select,
|
|
165
|
+
de as SelectContent,
|
|
166
|
+
ge as SelectGroup,
|
|
167
|
+
Se as SelectItem,
|
|
168
|
+
De as SelectLabel,
|
|
169
|
+
Ae as SelectScrollDownButton,
|
|
170
|
+
Ce as SelectScrollUpButton,
|
|
171
|
+
Pe as SelectSeparator,
|
|
172
|
+
Te as SelectTrigger,
|
|
173
|
+
he as SelectValue,
|
|
174
|
+
we as Separator,
|
|
175
|
+
Re as Sheet,
|
|
176
|
+
be as SheetClose,
|
|
177
|
+
Fe as SheetContent,
|
|
178
|
+
ke as SheetDescription,
|
|
179
|
+
Be as SheetFooter,
|
|
180
|
+
Ee as SheetHeader,
|
|
181
|
+
Me as SheetTitle,
|
|
182
|
+
Ne as SheetTrigger,
|
|
183
|
+
He as Skeleton,
|
|
184
|
+
k as ThumbhashImage,
|
|
185
|
+
Le as Toaster,
|
|
186
|
+
E as Touchable,
|
|
187
|
+
C as TransitionContainer,
|
|
188
|
+
T as TransitionLink,
|
|
189
|
+
H as VideoPlayer,
|
|
190
|
+
xr as badgeVariants,
|
|
191
|
+
lt as extractBrandTheme,
|
|
192
|
+
at as formatError,
|
|
193
|
+
pt as formatReviewCount,
|
|
194
|
+
mt as getFeaturedImages,
|
|
195
|
+
st as normalizeRating,
|
|
196
|
+
ut as parseUrl,
|
|
197
|
+
Ro as useAsyncStorage,
|
|
198
|
+
oo as useBuyerAttributes,
|
|
199
|
+
yo as useCloseMini,
|
|
200
|
+
wo as useCuratedProducts,
|
|
201
|
+
Ze as useCurrentUser,
|
|
202
|
+
Go as useDeeplink,
|
|
203
|
+
Jo as useErrorScreen,
|
|
204
|
+
jo as useErrorToast,
|
|
205
|
+
qe as useFollowedShops,
|
|
206
|
+
Ke as useFollowedShopsActions,
|
|
207
|
+
$o as useImagePicker,
|
|
208
|
+
Bo as useImageUpload,
|
|
209
|
+
Oo as useNavigateWithTransition,
|
|
210
|
+
ro as useOrders,
|
|
211
|
+
ho as usePopularProducts,
|
|
212
|
+
no as useProduct,
|
|
213
|
+
mo as useProductList,
|
|
214
|
+
ao as useProductListActions,
|
|
215
|
+
lo as useProductLists,
|
|
216
|
+
So as useProductMedia,
|
|
217
|
+
Ao as useProductSearch,
|
|
218
|
+
co as useProductVariants,
|
|
219
|
+
xo as useProducts,
|
|
220
|
+
Ve as useRecentProducts,
|
|
221
|
+
ze as useRecentShops,
|
|
222
|
+
Po as useRecommendedProducts,
|
|
223
|
+
Qo as useRecommendedShops,
|
|
224
|
+
Ye as useSavedProducts,
|
|
225
|
+
We as useSavedProductsActions,
|
|
226
|
+
Fo as useSecureStorage,
|
|
227
|
+
Xo as useShare,
|
|
228
|
+
Uo as useShop,
|
|
229
|
+
_o as useShopCartActions,
|
|
230
|
+
Mo as useShopNavigation
|
|
229
231
|
};
|
|
230
232
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as q } from "../../../../../../../../_virtual/
|
|
1
|
+
import { __module as q } from "../../../../../../../../_virtual/index6.js";
|
|
2
2
|
import { __require as F } from "../../../../../global@4.4.0/node_modules/global/window.js";
|
|
3
3
|
import { __require as N } from "../../../../../@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/extends.js";
|
|
4
4
|
import { __require as J } from "../../../../../is-function@1.0.2/node_modules/is-function/index.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import o from "../createLucideIcon.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license lucide-react v0.513.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
const e = [["path", { d: "M5 12h14", key: "1ays0h" }]], c = o("minus", e);
|
|
9
|
+
export {
|
|
10
|
+
e as __iconNode,
|
|
11
|
+
c as default
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=minus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minus.js","sources":["../../../../../../../../../../node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/minus.js"],"sourcesContent":["/**\n * @license lucide-react v0.513.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [[\"path\", { d: \"M5 12h14\", key: \"1ays0h\" }]];\nconst Minus = createLucideIcon(\"minus\", __iconNode);\n\nexport { __iconNode, Minus as default };\n//# sourceMappingURL=minus.js.map\n"],"names":["__iconNode","Minus","createLucideIcon"],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASK,MAACA,IAAa,CAAC,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,UAAU,CAAC,GACxDC,IAAQC,EAAiB,SAASF,CAAU;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import e from "../createLucideIcon.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license lucide-react v0.513.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
const o = [
|
|
9
|
+
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
10
|
+
["path", { d: "M12 5v14", key: "s699le" }]
|
|
11
|
+
], s = e("plus", o);
|
|
12
|
+
export {
|
|
13
|
+
o as __iconNode,
|
|
14
|
+
s as default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=plus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plus.js","sources":["../../../../../../../../../../node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/plus.js"],"sourcesContent":["/**\n * @license lucide-react v0.513.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M5 12h14\", key: \"1ays0h\" }],\n [\"path\", { d: \"M12 5v14\", key: \"s699le\" }]\n];\nconst Plus = createLucideIcon(\"plus\", __iconNode);\n\nexport { __iconNode, Plus as default };\n//# sourceMappingURL=plus.js.map\n"],"names":["__iconNode","Plus","createLucideIcon"],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASK,MAACA,IAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAQ,CAAE;AAAA,EACzC,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAU,CAAA;AAC3C,GACMC,IAAOC,EAAiB,QAAQF,CAAU;","x_google_ignoreList":[0]}
|
|
@@ -2,7 +2,7 @@ import L from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-ut
|
|
|
2
2
|
import T from "../../../../../../../_virtual/window.js";
|
|
3
3
|
import { forEachMediaGroup as Z } from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-groups.js";
|
|
4
4
|
import J from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js";
|
|
5
|
-
import { l as Q } from "../../../../../../../_virtual/
|
|
5
|
+
import { l as Q } from "../../../../../../../_virtual/index7.js";
|
|
6
6
|
/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */
|
|
7
7
|
const w = (e) => !!e && typeof e == "object", E = (...e) => e.reduce((n, t) => (typeof t != "object" || Object.keys(t).forEach((r) => {
|
|
8
8
|
Array.isArray(n[r]) && Array.isArray(t[r]) ? n[r] = n[r].concat(t[r]) : w(n[r]) && w(t[r]) ? n[r] = E(n[r], t[r]) : n[r] = t[r];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as r } from "../../../../../../../_virtual/
|
|
1
|
+
import { __module as r } from "../../../../../../../_virtual/index9.js";
|
|
2
2
|
import { __require as o } from "../cjs/use-sync-external-store-shim.production.js";
|
|
3
3
|
import { __require as i } from "../cjs/use-sync-external-store-shim.development.js";
|
|
4
4
|
var e;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/shop-minis-react",
|
|
3
3
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.24",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@shopify/shop-minis-platform": "0.0.7",
|
|
42
42
|
"@tailwindcss/vite": "4.1.8",
|
|
43
43
|
"@types/url-parse": "1.4.9",
|
|
44
|
+
"@types/video.js": "7.3.58",
|
|
44
45
|
"@vitejs/plugin-react": "4.5.1",
|
|
45
46
|
"class-variance-authority": "0.7.1",
|
|
46
47
|
"clsx": "2.1.1",
|
|
@@ -62,7 +63,8 @@
|
|
|
62
63
|
"thumbhash": "^0.1.1",
|
|
63
64
|
"tw-animate-css": "1.3.4",
|
|
64
65
|
"url-parse": "1.5.10",
|
|
65
|
-
"vaul": "1.1.2"
|
|
66
|
+
"vaul": "1.1.2",
|
|
67
|
+
"video.js": "8.23.3"
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
70
|
"@shopify/generate-docs": "^0.16.6",
|
|
@@ -73,14 +75,12 @@
|
|
|
73
75
|
"@types/react": "^19.1.6",
|
|
74
76
|
"@types/react-dom": "^19.1.2",
|
|
75
77
|
"@types/react-window": "^1.8.8",
|
|
76
|
-
"@types/video.js": "^7.3.58",
|
|
77
78
|
"eslint": "^8.57.0",
|
|
78
79
|
"eslint-plugin-storybook": "^9.0.16",
|
|
79
80
|
"react": "^19.1.0",
|
|
80
81
|
"react-dom": "^19.1.0",
|
|
81
82
|
"storybook": "^9.0.16",
|
|
82
83
|
"typescript": "^5.8.3",
|
|
83
|
-
"video.js": "^8.23.3",
|
|
84
84
|
"vite": "^6.3.3",
|
|
85
85
|
"vite-plugin-dts": "^4.3.0"
|
|
86
86
|
},
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"type-check": "tsc --noEmit",
|
|
110
110
|
"clean": "rm -rf dist",
|
|
111
111
|
"storybook": "storybook dev -p 6006",
|
|
112
|
-
"build-storybook": "storybook build",
|
|
112
|
+
"build-storybook": "storybook build -o ../../web/public/minis-playground",
|
|
113
113
|
"lint": "eslint . --format codeframe --cache",
|
|
114
114
|
"lint:fix": "eslint . --format codeframe --cache --fix"
|
|
115
115
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {useCallback, useEffect, useState} from 'react'
|
|
2
|
+
|
|
3
|
+
import {Minus, Plus} from 'lucide-react'
|
|
4
|
+
|
|
5
|
+
import {cn} from '../../lib/utils'
|
|
6
|
+
import {IconButton} from '../atoms/icon-button'
|
|
7
|
+
|
|
8
|
+
interface QuantitySelectorProps {
|
|
9
|
+
quantity: number
|
|
10
|
+
onQuantityChange: (quantity: number) => void
|
|
11
|
+
maxQuantity: number
|
|
12
|
+
minQuantity?: number
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const QuantitySelector = ({
|
|
17
|
+
quantity: _quantity,
|
|
18
|
+
onQuantityChange,
|
|
19
|
+
maxQuantity,
|
|
20
|
+
minQuantity = 1,
|
|
21
|
+
disabled = false,
|
|
22
|
+
}: QuantitySelectorProps) => {
|
|
23
|
+
const [quantity, setQuantity] = useState(_quantity)
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setQuantity(_quantity)
|
|
27
|
+
}, [_quantity])
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
onQuantityChange(quantity)
|
|
31
|
+
}, [quantity, onQuantityChange])
|
|
32
|
+
|
|
33
|
+
const incrementDisabled = disabled || quantity >= maxQuantity
|
|
34
|
+
const decrementDisabled = disabled || quantity <= minQuantity
|
|
35
|
+
|
|
36
|
+
const incrementQuantity = useCallback(() => {
|
|
37
|
+
if (incrementDisabled) return
|
|
38
|
+
const newQuantity = quantity + 1 > maxQuantity ? quantity : quantity + 1
|
|
39
|
+
setQuantity(newQuantity)
|
|
40
|
+
}, [incrementDisabled, quantity, maxQuantity])
|
|
41
|
+
|
|
42
|
+
const decrementQuantity = useCallback(() => {
|
|
43
|
+
if (decrementDisabled) return
|
|
44
|
+
const newQuantity = quantity - 1 < minQuantity ? quantity : quantity - 1
|
|
45
|
+
setQuantity(newQuantity)
|
|
46
|
+
}, [decrementDisabled, quantity, minQuantity])
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
<div
|
|
51
|
+
data-testid="QuantitySelector"
|
|
52
|
+
className={cn('inline-flex w-auto bg-tertiary rounded-[8px]')}
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
className={cn(
|
|
56
|
+
'flex h-space-32 items-center self-center overflow-hidden rounded-radius-8 bg-bg-fill-secondary',
|
|
57
|
+
`p-space-8`
|
|
58
|
+
)}
|
|
59
|
+
>
|
|
60
|
+
<IconButton
|
|
61
|
+
Icon={Minus}
|
|
62
|
+
onClick={decrementQuantity}
|
|
63
|
+
buttonStyles="transition bg-transparent"
|
|
64
|
+
filled={false}
|
|
65
|
+
size="sm"
|
|
66
|
+
iconStyles={cn(
|
|
67
|
+
decrementDisabled ? 'text-background' : 'text-foreground',
|
|
68
|
+
'stroke-3'
|
|
69
|
+
)}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<div className={cn('grow', `w-[20px]`)}>
|
|
73
|
+
<span className="flex items-center justify-center w-full h-full font-medium text-[10px]">
|
|
74
|
+
{quantity}
|
|
75
|
+
</span>
|
|
76
|
+
</div>
|
|
77
|
+
<IconButton
|
|
78
|
+
Icon={Plus}
|
|
79
|
+
onClick={incrementQuantity}
|
|
80
|
+
buttonStyles="transition bg-transparent"
|
|
81
|
+
filled={false}
|
|
82
|
+
size="sm"
|
|
83
|
+
iconStyles={cn(
|
|
84
|
+
incrementDisabled ? 'text-background' : 'text-secondary',
|
|
85
|
+
'stroke-3'
|
|
86
|
+
)}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</>
|
|
91
|
+
)
|
|
92
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './commerce/product-link'
|
|
|
5
5
|
export * from './commerce/merchant-card'
|
|
6
6
|
export * from './commerce/product-card-skeleton'
|
|
7
7
|
export * from './commerce/merchant-card-skeleton'
|
|
8
|
+
export * from './commerce/quantity-selector'
|
|
8
9
|
|
|
9
10
|
export * from './navigation/transition-container'
|
|
10
11
|
export * from './navigation/transition-link'
|