@shopify/shop-minis-react 0.0.20 → 0.0.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/hooks/storage/useImageUpload.js.map +1 -1
- package/dist/hooks/util/useErrorScreen.js.map +1 -1
- package/dist/hooks/util/useErrorToast.js.map +1 -1
- package/dist/index.js +167 -164
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/index.ts +1 -0
- package/src/hooks/navigation/useCloseMini.example.tsx +1 -1
- package/src/hooks/navigation/useShopNavigation.example.tsx +12 -9
- package/src/hooks/product/useProductListActions.example.tsx +19 -16
- package/src/hooks/shop/useShopCartActions.example.tsx +2 -2
- package/src/hooks/storage/useImageUpload.example.tsx +1 -1
- package/src/hooks/storage/useImageUpload.ts +3 -2
- package/src/hooks/user/useFollowedShopsActions.example.tsx +6 -8
- package/src/hooks/user/useSavedProductsActions.example.tsx +8 -6
- package/src/hooks/util/useErrorScreen.example.tsx +1 -2
- package/src/hooks/util/useErrorScreen.ts +2 -1
- package/src/hooks/util/useErrorToast.example.tsx +1 -1
- package/src/hooks/util/useErrorToast.ts +2 -1
- package/src/hooks/util/useImagePicker.example.tsx +4 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImageUpload.js","sources":["../../../src/hooks/storage/useImageUpload.ts"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {UploadTarget} from '
|
|
1
|
+
{"version":3,"file":"useImageUpload.js","sources":["../../../src/hooks/storage/useImageUpload.ts"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {useShopActions} from '../../internal/useShopActions'\n\nimport type {UploadTarget} from '@shopify/shop-minis-platform/actions'\n\nexport interface UploadImageParams {\n /**\n * The MIME type of the image.\n */\n mimeType: string\n /**\n * The size of the image in bytes.\n */\n fileSize: number\n /**\n * The URI of the image to upload.\n */\n uri: string\n}\n\nexport interface UploadedImage {\n /**\n * The ID of the uploaded image.\n */\n id: string\n /**\n * The URL of the uploaded image.\n */\n imageUrl?: string\n /**\n * The resource URL of the uploaded image.\n */\n resourceUrl?: string\n}\n\ninterface UseImageUploadReturns {\n /**\n * Upload an image attached to the current user.\n */\n uploadImage: (params: UploadImageParams[]) => Promise<UploadedImage[]>\n}\n\nconst uploadFileToGCS = async (\n image: UploadImageParams,\n target: UploadTarget\n) => {\n const formData = new FormData()\n target.parameters.forEach(({name, value}: {name: string; value: string}) => {\n formData.append(name, value)\n })\n // Append the actual file data last\n formData.append('file', new Blob([image.uri], {type: image.mimeType}))\n\n const uploadResponse = await fetch(target.url, {\n method: 'POST',\n body: formData,\n })\n\n if (!uploadResponse.ok) {\n console.error('Failed to upload image', {\n response: await uploadResponse.text(),\n })\n return {error: 'Failed to upload image'}\n }\n\n return {}\n}\n\nexport const useImageUpload = (): UseImageUploadReturns => {\n const {createImageUploadLink, completeImageUpload} = useShopActions()\n\n const uploadImage = useCallback(\n async (params: UploadImageParams[]) => {\n if (params.length > 1) {\n throw new Error('Multiple image upload is not supported yet')\n }\n\n const links = await createImageUploadLink({\n input: params.map(image => ({\n mimeType: image.mimeType,\n fileSize: image.fileSize,\n })),\n })\n\n if (!links.ok) {\n throw new Error(links.error.message)\n }\n\n // Upload single file to GCS\n // TODO: Upload multiple files to GCS\n const {error: uploadError} = await uploadFileToGCS(\n params[0],\n links?.data?.targets?.[0]!\n )\n\n if (uploadError) {\n throw new Error(uploadError)\n }\n\n // 10 second polling for image upload\n let count = 0\n while (count < 30) {\n const result = await completeImageUpload({\n resourceUrls:\n links?.data?.targets?.map(target => target.resourceUrl) || [],\n })\n\n if (!result.ok) {\n throw new Error(result.error.message)\n }\n\n // TODO: Add support for multiple files\n if (result.data?.files?.[0]?.fileStatus === 'READY') {\n return [\n {\n id: result.data.files[0].id,\n imageUrl: result.data.files[0].image?.url,\n resourceUrl: links?.data?.targets?.[0]?.resourceUrl,\n },\n ]\n }\n\n await new Promise(resolve => setTimeout(resolve, 1000))\n count++\n }\n\n throw new Error('Image upload completion timed out')\n },\n [createImageUploadLink, completeImageUpload]\n )\n\n return {\n uploadImage,\n }\n}\n"],"names":["uploadFileToGCS","image","target","formData","name","value","uploadResponse","useImageUpload","createImageUploadLink","completeImageUpload","useShopActions","useCallback","params","links","uploadError","count","result","resolve"],"mappings":";;AA2CA,MAAMA,IAAkB,OACtBC,GACAC,MACG;AACG,QAAAC,IAAW,IAAI,SAAS;AAC9B,EAAAD,EAAO,WAAW,QAAQ,CAAC,EAAC,MAAAE,GAAM,OAAAC,QAA0C;AACjE,IAAAF,EAAA,OAAOC,GAAMC,CAAK;AAAA,EAAA,CAC5B,GAEDF,EAAS,OAAO,QAAQ,IAAI,KAAK,CAACF,EAAM,GAAG,GAAG,EAAC,MAAMA,EAAM,SAAS,CAAA,CAAC;AAErE,QAAMK,IAAiB,MAAM,MAAMJ,EAAO,KAAK;AAAA,IAC7C,QAAQ;AAAA,IACR,MAAMC;AAAA,EAAA,CACP;AAEG,SAACG,EAAe,KAOb,CAAC,KANN,QAAQ,MAAM,0BAA0B;AAAA,IACtC,UAAU,MAAMA,EAAe,KAAK;AAAA,EAAA,CACrC,GACM,EAAC,OAAO,yBAAwB;AAI3C,GAEaC,IAAiB,MAA6B;AACzD,QAAM,EAAC,uBAAAC,GAAuB,qBAAAC,EAAmB,IAAIC,EAAe;AA8D7D,SAAA;AAAA,IACL,aA7DkBC;AAAA,MAClB,OAAOC,MAAgC;AACjC,YAAAA,EAAO,SAAS;AACZ,gBAAA,IAAI,MAAM,4CAA4C;AAGxD,cAAAC,IAAQ,MAAML,EAAsB;AAAA,UACxC,OAAOI,EAAO,IAAI,CAAUX,OAAA;AAAA,YAC1B,UAAUA,EAAM;AAAA,YAChB,UAAUA,EAAM;AAAA,UAAA,EAChB;AAAA,QAAA,CACH;AAEG,YAAA,CAACY,EAAM;AACT,gBAAM,IAAI,MAAMA,EAAM,MAAM,OAAO;AAKrC,cAAM,EAAC,OAAOC,EAAW,IAAI,MAAMd;AAAA,UACjCY,EAAO,CAAC;AAAA,UACRC,GAAO,MAAM,UAAU,CAAC;AAAA,QAC1B;AAEA,YAAIC;AACI,gBAAA,IAAI,MAAMA,CAAW;AAI7B,YAAIC,IAAQ;AACZ,eAAOA,IAAQ,MAAI;AACX,gBAAAC,IAAS,MAAMP,EAAoB;AAAA,YACvC,cACEI,GAAO,MAAM,SAAS,IAAI,CAAUX,MAAAA,EAAO,WAAW,KAAK,CAAA;AAAA,UAAC,CAC/D;AAEG,cAAA,CAACc,EAAO;AACV,kBAAM,IAAI,MAAMA,EAAO,MAAM,OAAO;AAItC,cAAIA,EAAO,MAAM,QAAQ,CAAC,GAAG,eAAe;AACnC,mBAAA;AAAA,cACL;AAAA,gBACE,IAAIA,EAAO,KAAK,MAAM,CAAC,EAAE;AAAA,gBACzB,UAAUA,EAAO,KAAK,MAAM,CAAC,EAAE,OAAO;AAAA,gBACtC,aAAaH,GAAO,MAAM,UAAU,CAAC,GAAG;AAAA,cAAA;AAAA,YAE5C;AAGF,gBAAM,IAAI,QAAQ,CAAAI,MAAW,WAAWA,GAAS,GAAI,CAAC,GACtDF;AAAA,QAAA;AAGI,cAAA,IAAI,MAAM,mCAAmC;AAAA,MACrD;AAAA,MACA,CAACP,GAAuBC,CAAmB;AAAA,IAC7C;AAAA,EAIA;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useErrorScreen.js","sources":["../../../src/hooks/util/useErrorScreen.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useErrorScreen.js","sources":["../../../src/hooks/util/useErrorScreen.ts"],"sourcesContent":["import {ShopActions} from '@shopify/shop-minis-platform/actions'\n\nimport {useShopActions} from '../../internal/useShopActions'\n\ninterface UseErrorScreenReturns {\n /**\n * Show an error screen with the given error message.\n */\n showErrorScreen: ShopActions['showErrorScreen']\n}\n\nexport const useErrorScreen = (): UseErrorScreenReturns => {\n const {showErrorScreen} = useShopActions()\n\n return {showErrorScreen}\n}\n"],"names":["useErrorScreen","showErrorScreen","useShopActions"],"mappings":";AAWO,MAAMA,IAAiB,MAA6B;AACnD,QAAA,EAAC,iBAAAC,EAAe,IAAIC,EAAe;AAEzC,SAAO,EAAC,iBAAAD,EAAe;AACzB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useErrorToast.js","sources":["../../../src/hooks/util/useErrorToast.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useErrorToast.js","sources":["../../../src/hooks/util/useErrorToast.ts"],"sourcesContent":["import {ShopActions} from '@shopify/shop-minis-platform/actions'\n\nimport {useShopActions} from '../../internal/useShopActions'\n\ninterface UseErrorToastReturns {\n /**\n * Show an error toast with the given error message.\n */\n showErrorToast: ShopActions['showErrorToast']\n}\n\nexport const useErrorToast = (): UseErrorToastReturns => {\n const {showErrorToast} = useShopActions()\n\n return {showErrorToast}\n}\n"],"names":["useErrorToast","showErrorToast","useShopActions"],"mappings":";AAWO,MAAMA,IAAgB,MAA4B;AACjD,QAAA,EAAC,gBAAAC,EAAc,IAAIC,EAAe;AAExC,SAAO,EAAC,gBAAAD,EAAc;AACxB;"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ProductCard as p } from "./components/commerce/product-card.js";
|
|
|
4
4
|
import { ProductLink as m } 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
|
-
import { MerchantCardSkeleton as
|
|
7
|
+
import { MerchantCardSkeleton as g } from "./components/commerce/merchant-card-skeleton.js";
|
|
8
8
|
import { TransitionContainer as D } from "./components/navigation/transition-container.js";
|
|
9
9
|
import { TransitionLink as C } from "./components/navigation/transition-link.js";
|
|
10
10
|
import { Button as T } from "./components/atoms/button.js";
|
|
@@ -12,65 +12,66 @@ import { FavoriteButton as I } from "./components/atoms/favorite-button.js";
|
|
|
12
12
|
import { IconButton as v } from "./components/atoms/icon-button.js";
|
|
13
13
|
import { ThumbhashImage as k } from "./components/atoms/thumbhash-image.js";
|
|
14
14
|
import { Touchable as F } from "./components/atoms/touchable.js";
|
|
15
|
-
import { AlertDialogAtom as
|
|
16
|
-
import { List as
|
|
15
|
+
import { AlertDialogAtom as B } from "./components/atoms/alert-dialog.js";
|
|
16
|
+
import { List as N } from "./components/atoms/list.js";
|
|
17
17
|
import { Accordion as y, AccordionContent as G, AccordionItem as H, AccordionTrigger as O } from "./components/ui/accordion.js";
|
|
18
18
|
import { Alert as V, AlertDescription as _, AlertTitle as z } from "./components/ui/alert.js";
|
|
19
19
|
import { AlertDialog as W, AlertDialogAction as j, AlertDialogCancel as q, AlertDialogContent as J, AlertDialogDescription as K, AlertDialogFooter as Q, AlertDialogHeader as X, AlertDialogOverlay as Z, AlertDialogPortal as $, AlertDialogTitle as rr, AlertDialogTrigger as er } from "./components/ui/alert-dialog.js";
|
|
20
20
|
import { Avatar as tr, AvatarFallback as ar, AvatarImage as ir } from "./components/ui/avatar.js";
|
|
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 {
|
|
21
|
+
import { Badge as pr, badgeVariants as sr } from "./components/ui/badge.js";
|
|
22
|
+
import { Card as nr, CardAction as ur, CardContent as xr, CardDescription as fr, CardFooter as cr, CardHeader as dr, CardTitle as gr } from "./components/ui/card.js";
|
|
23
|
+
import { Carousel as Dr, CarouselContent as Ar, CarouselItem as Cr, CarouselNext as Pr, CarouselPrevious as Tr } from "./components/ui/carousel.js";
|
|
24
|
+
import { Checkbox as Ir } from "./components/ui/checkbox.js";
|
|
25
|
+
import { Dialog as vr, DialogClose as br, DialogContent as kr, DialogDescription as Er, DialogFooter as Fr, DialogHeader as Rr, DialogOverlay as Br, DialogPortal as Mr, DialogTitle as Nr, DialogTrigger as Lr } from "./components/ui/dialog.js";
|
|
26
|
+
import { Drawer as Gr, DrawerClose as Hr, DrawerContent as Or, DrawerDescription as Ur, DrawerFooter as Vr, DrawerHeader as _r, DrawerOverlay as zr, DrawerPortal as Yr, DrawerTitle as Wr, DrawerTrigger as jr } from "./components/ui/drawer.js";
|
|
27
|
+
import { Input as Jr } from "./components/ui/input.js";
|
|
28
|
+
import { Label as Qr } from "./components/ui/label.js";
|
|
29
|
+
import { Progress as Zr } from "./components/ui/progress.js";
|
|
30
|
+
import { RadioGroup as re, RadioGroupItem as ee } from "./components/ui/radio-group.js";
|
|
31
|
+
import { ResizableHandle as te, ResizablePanel as ae, ResizablePanelGroup as ie } from "./components/ui/resizable.js";
|
|
32
|
+
import { ScrollArea as pe, ScrollBar as se } from "./components/ui/scroll-area.js";
|
|
33
|
+
import { Select as ne, SelectContent as ue, SelectGroup as xe, SelectItem as fe, SelectLabel as ce, SelectScrollDownButton as de, SelectScrollUpButton as ge, SelectSeparator as Se, SelectTrigger as De, SelectValue as Ae } from "./components/ui/select.js";
|
|
34
|
+
import { Separator as Pe } from "./components/ui/separator.js";
|
|
35
|
+
import { Sheet as he, SheetClose as Ie, SheetContent as we, SheetDescription as ve, SheetFooter as be, SheetHeader as ke, SheetTitle as Ee, SheetTrigger as Fe } from "./components/ui/sheet.js";
|
|
36
|
+
import { Toaster as Be } from "./components/ui/sonner.js";
|
|
37
|
+
import { Skeleton as Ne } from "./components/ui/skeleton.js";
|
|
38
|
+
import { useRecentProducts as ye } from "./hooks/user/useRecentProducts.js";
|
|
39
|
+
import { useRecentShops as He } from "./hooks/user/useRecentShops.js";
|
|
40
|
+
import { useSavedProducts as Ue } from "./hooks/user/useSavedProducts.js";
|
|
41
|
+
import { useSavedProductsActions as _e } from "./hooks/user/useSavedProductsActions.js";
|
|
42
|
+
import { useFollowedShops as Ye } from "./hooks/user/useFollowedShops.js";
|
|
43
|
+
import { useFollowedShopsActions as je } from "./hooks/user/useFollowedShopsActions.js";
|
|
44
|
+
import { useCurrentUser as Je } from "./hooks/user/useCurrentUser.js";
|
|
45
|
+
import { useOrders as Qe } from "./hooks/user/useOrders.js";
|
|
46
|
+
import { useBuyerAttributes as Ze } from "./hooks/user/useBuyerAttributes.js";
|
|
47
|
+
import { useProductListActions as ro } from "./hooks/product/useProductListActions.js";
|
|
48
|
+
import { useProductLists as oo } from "./hooks/product/useProductLists.js";
|
|
49
|
+
import { useProductList as ao } from "./hooks/product/useProductList.js";
|
|
50
|
+
import { useProduct as lo } from "./hooks/product/useProduct.js";
|
|
51
|
+
import { useProducts as so } from "./hooks/product/useProducts.js";
|
|
52
|
+
import { useProductVariants as no } from "./hooks/product/useProductVariants.js";
|
|
53
|
+
import { useProductMedia as xo } from "./hooks/product/useProductMedia.js";
|
|
54
|
+
import { useProductSearch as co } from "./hooks/product/useProductSearch.js";
|
|
55
|
+
import { useRecommendedProducts as So } from "./hooks/product/useRecommendedProducts.js";
|
|
56
|
+
import { usePopularProducts as Ao } from "./hooks/product/usePopularProducts.js";
|
|
57
|
+
import { useCuratedProducts as Po } from "./hooks/product/useCuratedProducts.js";
|
|
58
|
+
import { useAsyncStorage as ho } from "./hooks/storage/useAsyncStorage.js";
|
|
59
|
+
import { useSecureStorage as wo } from "./hooks/storage/useSecureStorage.js";
|
|
60
|
+
import { useImageUpload as bo } from "./hooks/storage/useImageUpload.js";
|
|
61
|
+
import { useShopNavigation as Eo } from "./hooks/navigation/useShopNavigation.js";
|
|
62
|
+
import { useCloseMini as Ro } from "./hooks/navigation/useCloseMini.js";
|
|
63
|
+
import { useDeeplink as Mo } from "./hooks/navigation/useDeeplink.js";
|
|
64
|
+
import { useNavigateWithTransition as Lo } from "./hooks/navigation/useNavigateWithTransition.js";
|
|
65
|
+
import { useShop as Go } from "./hooks/shop/useShop.js";
|
|
66
|
+
import { useShopCartActions as Oo } from "./hooks/shop/useShopCartActions.js";
|
|
67
|
+
import { useRecommendedShops as Vo } from "./hooks/shop/useRecommendedShops.js";
|
|
68
|
+
import { useErrorToast as zo } from "./hooks/util/useErrorToast.js";
|
|
69
|
+
import { useErrorScreen as Wo } from "./hooks/util/useErrorScreen.js";
|
|
70
|
+
import { useShare as qo } from "./hooks/util/useShare.js";
|
|
71
|
+
import { useImagePicker as Ko } from "./hooks/util/useImagePicker.js";
|
|
72
|
+
import { MiniEntityNotFoundError as Xo, MiniError as Zo, MiniNetworkError as $o, formatError as rt } from "./utils/errors.js";
|
|
73
|
+
import { parseUrl as ot } from "./utils/parseUrl.js";
|
|
74
|
+
import { Consent as at, ConsentStatus as it } from "./shop-minis-platform/src/types/permissions.js";
|
|
74
75
|
export {
|
|
75
76
|
y as Accordion,
|
|
76
77
|
G as AccordionContent,
|
|
@@ -80,7 +81,7 @@ export {
|
|
|
80
81
|
_ as AlertDescription,
|
|
81
82
|
W as AlertDialog,
|
|
82
83
|
j as AlertDialogAction,
|
|
83
|
-
|
|
84
|
+
B as AlertDialogAtom,
|
|
84
85
|
q as AlertDialogCancel,
|
|
85
86
|
J as AlertDialogContent,
|
|
86
87
|
K as AlertDialogDescription,
|
|
@@ -94,127 +95,129 @@ export {
|
|
|
94
95
|
tr as Avatar,
|
|
95
96
|
ar as AvatarFallback,
|
|
96
97
|
ir as AvatarImage,
|
|
98
|
+
pr as Badge,
|
|
97
99
|
T as Button,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
nr as Card,
|
|
101
|
+
ur as CardAction,
|
|
102
|
+
xr as CardContent,
|
|
103
|
+
fr as CardDescription,
|
|
104
|
+
cr as CardFooter,
|
|
105
|
+
dr as CardHeader,
|
|
106
|
+
gr as CardTitle,
|
|
107
|
+
Dr as Carousel,
|
|
108
|
+
Ar as CarouselContent,
|
|
109
|
+
Cr as CarouselItem,
|
|
110
|
+
Pr as CarouselNext,
|
|
111
|
+
Tr as CarouselPrevious,
|
|
112
|
+
Ir as Checkbox,
|
|
113
|
+
at as Consent,
|
|
114
|
+
it as ConsentStatus,
|
|
113
115
|
o as DATA_NAVIGATION_TYPE_ATTRIBUTE,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
116
|
+
vr as Dialog,
|
|
117
|
+
br as DialogClose,
|
|
118
|
+
kr as DialogContent,
|
|
119
|
+
Er as DialogDescription,
|
|
120
|
+
Fr as DialogFooter,
|
|
121
|
+
Rr as DialogHeader,
|
|
122
|
+
Br as DialogOverlay,
|
|
123
|
+
Mr as DialogPortal,
|
|
124
|
+
Nr as DialogTitle,
|
|
125
|
+
Lr as DialogTrigger,
|
|
126
|
+
Gr as Drawer,
|
|
127
|
+
Hr as DrawerClose,
|
|
128
|
+
Or as DrawerContent,
|
|
129
|
+
Ur as DrawerDescription,
|
|
130
|
+
Vr as DrawerFooter,
|
|
131
|
+
_r as DrawerHeader,
|
|
132
|
+
zr as DrawerOverlay,
|
|
133
|
+
Yr as DrawerPortal,
|
|
134
|
+
Wr as DrawerTitle,
|
|
135
|
+
jr as DrawerTrigger,
|
|
134
136
|
I as FavoriteButton,
|
|
135
137
|
v as IconButton,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
Jr as Input,
|
|
139
|
+
Qr as Label,
|
|
140
|
+
N as List,
|
|
139
141
|
u as MerchantCard,
|
|
140
142
|
x as MerchantCardPrimitive,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
g as MerchantCardSkeleton,
|
|
144
|
+
Xo as MiniEntityNotFoundError,
|
|
145
|
+
Zo as MiniError,
|
|
146
|
+
$o as MiniNetworkError,
|
|
145
147
|
i as MinisContainer,
|
|
146
148
|
t as NAVIGATION_TYPES,
|
|
147
149
|
p as ProductCard,
|
|
148
150
|
c as ProductCardSkeleton,
|
|
149
151
|
m as ProductLink,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
152
|
+
Zr as Progress,
|
|
153
|
+
re as RadioGroup,
|
|
154
|
+
ee as RadioGroupItem,
|
|
155
|
+
te as ResizableHandle,
|
|
156
|
+
ae as ResizablePanel,
|
|
157
|
+
ie as ResizablePanelGroup,
|
|
158
|
+
pe as ScrollArea,
|
|
159
|
+
se as ScrollBar,
|
|
160
|
+
ne as Select,
|
|
161
|
+
ue as SelectContent,
|
|
162
|
+
xe as SelectGroup,
|
|
163
|
+
fe as SelectItem,
|
|
164
|
+
ce as SelectLabel,
|
|
165
|
+
de as SelectScrollDownButton,
|
|
166
|
+
ge as SelectScrollUpButton,
|
|
167
|
+
Se as SelectSeparator,
|
|
168
|
+
De as SelectTrigger,
|
|
169
|
+
Ae as SelectValue,
|
|
170
|
+
Pe as Separator,
|
|
171
|
+
he as Sheet,
|
|
172
|
+
Ie as SheetClose,
|
|
173
|
+
we as SheetContent,
|
|
174
|
+
ve as SheetDescription,
|
|
175
|
+
be as SheetFooter,
|
|
176
|
+
ke as SheetHeader,
|
|
177
|
+
Ee as SheetTitle,
|
|
178
|
+
Fe as SheetTrigger,
|
|
179
|
+
Ne as Skeleton,
|
|
178
180
|
k as ThumbhashImage,
|
|
179
|
-
|
|
181
|
+
Be as Toaster,
|
|
180
182
|
F as Touchable,
|
|
181
183
|
D as TransitionContainer,
|
|
182
184
|
C as TransitionLink,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
185
|
+
sr as badgeVariants,
|
|
186
|
+
rt as formatError,
|
|
187
|
+
ot as parseUrl,
|
|
188
|
+
ho as useAsyncStorage,
|
|
189
|
+
Ze as useBuyerAttributes,
|
|
190
|
+
Ro as useCloseMini,
|
|
191
|
+
Po as useCuratedProducts,
|
|
192
|
+
Je as useCurrentUser,
|
|
193
|
+
Mo as useDeeplink,
|
|
194
|
+
Wo as useErrorScreen,
|
|
195
|
+
zo as useErrorToast,
|
|
196
|
+
Ye as useFollowedShops,
|
|
197
|
+
je as useFollowedShopsActions,
|
|
198
|
+
Ko as useImagePicker,
|
|
199
|
+
bo as useImageUpload,
|
|
200
|
+
Lo as useNavigateWithTransition,
|
|
201
|
+
Qe as useOrders,
|
|
202
|
+
Ao as usePopularProducts,
|
|
203
|
+
lo as useProduct,
|
|
204
|
+
ao as useProductList,
|
|
205
|
+
ro as useProductListActions,
|
|
206
|
+
oo as useProductLists,
|
|
207
|
+
xo as useProductMedia,
|
|
208
|
+
co as useProductSearch,
|
|
209
|
+
no as useProductVariants,
|
|
210
|
+
so as useProducts,
|
|
211
|
+
ye as useRecentProducts,
|
|
212
|
+
He as useRecentShops,
|
|
213
|
+
So as useRecommendedProducts,
|
|
214
|
+
Vo as useRecommendedShops,
|
|
215
|
+
Ue as useSavedProducts,
|
|
216
|
+
_e as useSavedProductsActions,
|
|
217
|
+
wo as useSecureStorage,
|
|
218
|
+
qo as useShare,
|
|
219
|
+
Go as useShop,
|
|
220
|
+
Oo as useShopCartActions,
|
|
221
|
+
Eo as useShopNavigation
|
|
219
222
|
};
|
|
220
223
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
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.21",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"clean": "rm -rf dist",
|
|
107
107
|
"storybook": "storybook dev -p 6006",
|
|
108
108
|
"build-storybook": "storybook build",
|
|
109
|
-
"lint": "eslint . --format codeframe --cache
|
|
109
|
+
"lint": "eslint . --format codeframe --cache",
|
|
110
110
|
"lint:fix": "eslint . --format codeframe --cache --fix"
|
|
111
111
|
}
|
|
112
112
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -7,23 +7,26 @@ export default function MyComponent() {
|
|
|
7
7
|
return (
|
|
8
8
|
<>
|
|
9
9
|
<Button
|
|
10
|
-
|
|
10
|
+
onClick={() =>
|
|
11
11
|
navigateToProduct({productId: 'gid://shopify/Product/123'})
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
>
|
|
14
|
+
View Product
|
|
15
|
+
</Button>
|
|
15
16
|
<Button
|
|
16
|
-
|
|
17
|
+
onClick={() =>
|
|
17
18
|
navigateToShop({
|
|
18
19
|
shopId: 'gid://shopify/Shop/123',
|
|
19
20
|
})
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
>
|
|
23
|
+
Go to Shop
|
|
24
|
+
</Button>
|
|
23
25
|
<Button
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
onClick={() => navigateToOrder({orderId: 'gid://shopify/Order/123'})}
|
|
27
|
+
>
|
|
28
|
+
View Order
|
|
29
|
+
</Button>
|
|
27
30
|
</>
|
|
28
31
|
)
|
|
29
32
|
}
|
|
@@ -11,25 +11,26 @@ export default function MyComponent() {
|
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<>
|
|
14
|
+
<Button onClick={() => addProductList({name: 'My product list'})}>
|
|
15
|
+
Add product list
|
|
16
|
+
</Button>
|
|
14
17
|
<Button
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
onClick={() => removeProductList({id: 'gid://shopapp/ProductList/123'})}
|
|
19
|
+
>
|
|
20
|
+
Remove product list
|
|
21
|
+
</Button>
|
|
18
22
|
<Button
|
|
19
|
-
|
|
20
|
-
text="Remove product list"
|
|
21
|
-
/>
|
|
22
|
-
<Button
|
|
23
|
-
onPress={() =>
|
|
23
|
+
onClick={() =>
|
|
24
24
|
renameProductList({
|
|
25
25
|
id: 'gid://shopapp/ProductList/123',
|
|
26
26
|
name: 'My renamed product list',
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
>
|
|
30
|
+
Rename product list
|
|
31
|
+
</Button>
|
|
31
32
|
<Button
|
|
32
|
-
|
|
33
|
+
onClick={() =>
|
|
33
34
|
addProductListItem({
|
|
34
35
|
shopId: 'gid://shopify/Shop/42',
|
|
35
36
|
productId: 'gid://shopify/Product/123',
|
|
@@ -38,10 +39,11 @@ export default function MyComponent() {
|
|
|
38
39
|
publicListId: 'abc123',
|
|
39
40
|
})
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
>
|
|
43
|
+
Add product to list
|
|
44
|
+
</Button>
|
|
43
45
|
<Button
|
|
44
|
-
|
|
46
|
+
onClick={() =>
|
|
45
47
|
removeProductListItem({
|
|
46
48
|
shopId: 'gid://shopify/Shop/42',
|
|
47
49
|
productId: 'gid://shopify/Product/123',
|
|
@@ -50,8 +52,9 @@ export default function MyComponent() {
|
|
|
50
52
|
publicListId: 'abc123',
|
|
51
53
|
})
|
|
52
54
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
>
|
|
56
|
+
Remove product from list
|
|
57
|
+
</Button>
|
|
55
58
|
</>
|
|
56
59
|
)
|
|
57
60
|
}
|
|
@@ -21,8 +21,8 @@ export default function MyComponent() {
|
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<>
|
|
24
|
-
<Button
|
|
25
|
-
<Button
|
|
24
|
+
<Button onClick={handleAddToCart}>Add to cart</Button>
|
|
25
|
+
<Button onClick={handleBuyNow}>Buy now</Button>
|
|
26
26
|
</>
|
|
27
27
|
)
|
|
28
28
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {useCallback} from 'react'
|
|
2
2
|
|
|
3
3
|
import {useShopActions} from '../../internal/useShopActions'
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import type {UploadTarget} from '@shopify/shop-minis-platform/actions'
|
|
5
6
|
|
|
6
7
|
export interface UploadImageParams {
|
|
7
8
|
/**
|
|
@@ -45,7 +46,7 @@ const uploadFileToGCS = async (
|
|
|
45
46
|
target: UploadTarget
|
|
46
47
|
) => {
|
|
47
48
|
const formData = new FormData()
|
|
48
|
-
target.parameters.forEach(({name, value}) => {
|
|
49
|
+
target.parameters.forEach(({name, value}: {name: string; value: string}) => {
|
|
49
50
|
formData.append(name, value)
|
|
50
51
|
})
|
|
51
52
|
// Append the actual file data last
|
|
@@ -5,14 +5,12 @@ export default function MyComponent() {
|
|
|
5
5
|
|
|
6
6
|
return (
|
|
7
7
|
<>
|
|
8
|
-
<Button
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
text="Unfollow shop"
|
|
15
|
-
/>
|
|
8
|
+
<Button onClick={() => followShop({shopId: 'gid://shopify/Shop/123'})}>
|
|
9
|
+
Follow shop
|
|
10
|
+
</Button>
|
|
11
|
+
<Button onClick={() => unfollowShop({shopId: 'gid://shopify/Shop/123'})}>
|
|
12
|
+
Unfollow shop
|
|
13
|
+
</Button>
|
|
16
14
|
</>
|
|
17
15
|
)
|
|
18
16
|
}
|
|
@@ -6,25 +6,27 @@ export default function MyComponent() {
|
|
|
6
6
|
return (
|
|
7
7
|
<>
|
|
8
8
|
<Button
|
|
9
|
-
|
|
9
|
+
onClick={() =>
|
|
10
10
|
saveProduct({
|
|
11
11
|
productId: 'gid://shopify/Product/123',
|
|
12
12
|
productVariantId: 'gid://shopify/ProductVariant/456',
|
|
13
13
|
shopId: 'gid://shopify/Shop/42',
|
|
14
14
|
})
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
>
|
|
17
|
+
Save product
|
|
18
|
+
</Button>
|
|
18
19
|
<Button
|
|
19
|
-
|
|
20
|
+
onClick={() =>
|
|
20
21
|
unsaveProduct({
|
|
21
22
|
productId: 'gid://shopify/Product/123',
|
|
22
23
|
productVariantId: 'gid://shopify/ProductVariant/456',
|
|
23
24
|
shopId: 'gid://shopify/Shop/42',
|
|
24
25
|
})
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
>
|
|
28
|
+
Unsave product
|
|
29
|
+
</Button>
|
|
28
30
|
</>
|
|
29
31
|
)
|
|
30
32
|
}
|
|
@@ -8,9 +8,8 @@ export default function MyComponent() {
|
|
|
8
8
|
const handleError = useCallback(() => {
|
|
9
9
|
showErrorScreen({
|
|
10
10
|
message: 'Something went wrong',
|
|
11
|
-
title: 'Error',
|
|
12
11
|
})
|
|
13
12
|
}, [showErrorScreen])
|
|
14
13
|
|
|
15
|
-
return <Button
|
|
14
|
+
return <Button onClick={handleError}>Show error screen</Button>
|
|
16
15
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React, {useState} from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {Button} from '../../components/atoms/button'
|
|
5
4
|
import {Alert, AlertDescription, AlertTitle} from '../../components/ui/alert'
|
|
6
|
-
import {Button} from '../../components/ui/button'
|
|
7
5
|
import {
|
|
8
6
|
Card,
|
|
9
7
|
CardContent,
|
|
@@ -16,14 +14,12 @@ import {useImagePicker} from './useImagePicker'
|
|
|
16
14
|
export const UseImagePickerExample = () => {
|
|
17
15
|
const [selectedImage, setSelectedImage] = useState<string | null>(null)
|
|
18
16
|
const [error, setError] = useState<string | null>(null)
|
|
19
|
-
const {openCamera, openGallery
|
|
20
|
-
cameraFacing: 'user',
|
|
21
|
-
})
|
|
17
|
+
const {openCamera, openGallery} = useImagePicker()
|
|
22
18
|
|
|
23
19
|
const handleCameraCapture = async () => {
|
|
24
20
|
try {
|
|
25
21
|
setError(null)
|
|
26
|
-
const file = await openCamera()
|
|
22
|
+
const file = await openCamera('front')
|
|
27
23
|
const url = URL.createObjectURL(file)
|
|
28
24
|
setSelectedImage(url)
|
|
29
25
|
} catch (err) {
|
|
@@ -48,16 +44,12 @@ export const UseImagePickerExample = () => {
|
|
|
48
44
|
<CardTitle>Image Picker Example</CardTitle>
|
|
49
45
|
</CardHeader>
|
|
50
46
|
<CardContent className="space-y-4">
|
|
51
|
-
<ImagePickerInputs />
|
|
52
|
-
|
|
53
47
|
<div className="flex gap-2">
|
|
54
|
-
<Button onClick={handleCameraCapture} variant="
|
|
55
|
-
<Camera className="mr-2 h-4 w-4" />
|
|
48
|
+
<Button onClick={handleCameraCapture} variant="default">
|
|
56
49
|
Open Camera
|
|
57
50
|
</Button>
|
|
58
51
|
|
|
59
52
|
<Button onClick={handleGallerySelect} variant="secondary">
|
|
60
|
-
<Image className="mr-2 h-4 w-4" />
|
|
61
53
|
Open Gallery
|
|
62
54
|
</Button>
|
|
63
55
|
</div>
|