@shopify/shop-minis-react 0.0.0-snapshot.20260112135741 → 0.0.0-snapshot.20260112135844
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/navigation/minis-router.js +15 -8
- package/dist/components/navigation/minis-router.js.map +1 -1
- package/dist/hooks/events/useOnNavigateBack.js +14 -0
- package/dist/hooks/events/useOnNavigateBack.js.map +1 -0
- package/dist/hooks/navigation/useNavigateWithTransition.js +6 -6
- package/dist/hooks/navigation/useNavigateWithTransition.js.map +1 -1
- package/dist/index.js +96 -94
- package/dist/index.js.map +1 -1
- package/dist/internal/navigation-manager.js +12 -0
- package/dist/internal/navigation-manager.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/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 +2 -2
- package/src/components/navigation/minis-router.tsx +9 -1
- package/src/hooks/events/useOnNavigateBack.ts +16 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/navigation/useNavigateWithTransition.test.ts +17 -3
- package/src/hooks/navigation/useNavigateWithTransition.ts +9 -4
- package/src/internal/navigation-manager.tsx +13 -0
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { BrowserRouter as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { jsxs as t, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { BrowserRouter as n } from "../../shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js";
|
|
3
|
+
import { NavigationManager as e } from "../../internal/navigation-manager.js";
|
|
4
|
+
import { TransitionContainer as a } from "./transition-container.js";
|
|
5
|
+
function x({
|
|
5
6
|
children: o,
|
|
6
|
-
viewTransitions:
|
|
7
|
-
...
|
|
7
|
+
viewTransitions: m = !1,
|
|
8
|
+
...i
|
|
8
9
|
}) {
|
|
9
|
-
return
|
|
10
|
+
return m ? /* @__PURE__ */ t(n, { ...i, children: [
|
|
11
|
+
/* @__PURE__ */ r(e, {}),
|
|
12
|
+
/* @__PURE__ */ r(a, { children: o })
|
|
13
|
+
] }) : /* @__PURE__ */ t(n, { ...i, children: [
|
|
14
|
+
/* @__PURE__ */ r(e, {}),
|
|
15
|
+
o
|
|
16
|
+
] });
|
|
10
17
|
}
|
|
11
18
|
export {
|
|
12
|
-
|
|
19
|
+
x as MinisRouter
|
|
13
20
|
};
|
|
14
21
|
//# sourceMappingURL=minis-router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minis-router.js","sources":["../../../src/components/navigation/minis-router.tsx"],"sourcesContent":["import {BrowserRouter, BrowserRouterProps} from 'react-router'\n\nimport {TransitionContainer} from './transition-container'\n\nexport interface MinisRouterProps extends BrowserRouterProps {\n viewTransitions?: boolean\n}\n\nexport function MinisRouter({\n children,\n viewTransitions = false,\n ...props\n}: MinisRouterProps) {\n if (viewTransitions) {\n return (\n <BrowserRouter {...props}>\n <TransitionContainer>{children}</TransitionContainer>\n </BrowserRouter>\n )\n }\n\n return <BrowserRouter {...props}
|
|
1
|
+
{"version":3,"file":"minis-router.js","sources":["../../../src/components/navigation/minis-router.tsx"],"sourcesContent":["import {BrowserRouter, BrowserRouterProps} from 'react-router'\n\nimport {NavigationManager} from '../../internal/navigation-manager'\n\nimport {TransitionContainer} from './transition-container'\n\nexport interface MinisRouterProps extends BrowserRouterProps {\n viewTransitions?: boolean\n}\n\nexport function MinisRouter({\n children,\n viewTransitions = false,\n ...props\n}: MinisRouterProps) {\n if (viewTransitions) {\n return (\n <BrowserRouter {...props}>\n <NavigationManager />\n <TransitionContainer>{children}</TransitionContainer>\n </BrowserRouter>\n )\n }\n\n return (\n <BrowserRouter {...props}>\n <NavigationManager />\n {children}\n </BrowserRouter>\n )\n}\n"],"names":["MinisRouter","children","viewTransitions","props","jsxs","BrowserRouter","jsx","NavigationManager","TransitionContainer"],"mappings":";;;;AAUO,SAASA,EAAY;AAAA,EAC1B,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,GAAGC;AACL,GAAqB;AACnB,SAAID,IAEA,gBAAAE,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA;AAAA,IAAA,gBAAAG,EAACC,GAAkB,EAAA;AAAA,IACnB,gBAAAD,EAACE,KAAqB,UAAAP,EAAS,CAAA;AAAA,EAAA,GACjC,IAKF,gBAAAG,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA;AAAA,IAAA,gBAAAG,EAACC,GAAkB,EAAA;AAAA,IAClBN;AAAA,EAAA,GACH;AAEJ;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useRef as i, useEffect as o } from "react";
|
|
2
|
+
function s(n) {
|
|
3
|
+
const e = i(n);
|
|
4
|
+
e.current = n, o(() => {
|
|
5
|
+
const t = window.minisEvents.on("NAVIGATE_BACK", () => {
|
|
6
|
+
e.current();
|
|
7
|
+
});
|
|
8
|
+
return () => window.minisEvents.off(t);
|
|
9
|
+
}, []);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
s as useOnNavigateBack
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useOnNavigateBack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnNavigateBack.js","sources":["../../../src/hooks/events/useOnNavigateBack.ts"],"sourcesContent":["import {useEffect, useRef} from 'react'\n\nexport function useOnNavigateBack(callback: () => void) {\n // Using a ref allows the callback to be updated without triggering a re-render\n // This makes the hook nicer to use because developers don't need useCallback\n const callbackRef = useRef(callback)\n callbackRef.current = callback\n\n useEffect(() => {\n const listenerId = window.minisEvents.on('NAVIGATE_BACK', () => {\n callbackRef.current()\n })\n\n return () => window.minisEvents.off(listenerId)\n }, [])\n}\n"],"names":["useOnNavigateBack","callback","callbackRef","useRef","useEffect","listenerId"],"mappings":";AAEO,SAASA,EAAkBC,GAAsB;AAGhD,QAAAC,IAAcC,EAAOF,CAAQ;AACnC,EAAAC,EAAY,UAAUD,GAEtBG,EAAU,MAAM;AACd,UAAMC,IAAa,OAAO,YAAY,GAAG,iBAAiB,MAAM;AAC9D,MAAAH,EAAY,QAAQ;AAAA,IAAA,CACrB;AAED,WAAO,MAAM,OAAO,YAAY,IAAIG,CAAU;AAAA,EAChD,GAAG,EAAE;AACP;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useNavigate as
|
|
1
|
+
import { useNavigate as u, useLocation as m } from "../../shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js";
|
|
2
2
|
import { DATA_NAVIGATION_TYPE_ATTRIBUTE as r } from "../../types/index.js";
|
|
3
|
-
function
|
|
4
|
-
const e =
|
|
3
|
+
function f() {
|
|
4
|
+
const e = u(), o = m();
|
|
5
5
|
return (t, n) => {
|
|
6
6
|
if (typeof t == "number") {
|
|
7
7
|
if (document.startViewTransition)
|
|
@@ -18,10 +18,10 @@ function d() {
|
|
|
18
18
|
return e(t);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const a = t === o.pathname;
|
|
21
|
+
const a = t === o.pathname, s = t === "/";
|
|
22
22
|
if (document.startViewTransition)
|
|
23
23
|
document.startViewTransition(() => {
|
|
24
|
-
e(t, {
|
|
24
|
+
s ? e(-window.history.state.idx) : e(t, {
|
|
25
25
|
replace: a,
|
|
26
26
|
...n
|
|
27
27
|
}), n?.preventScrollReset !== !0 && window.scrollTo(0, 0);
|
|
@@ -37,6 +37,6 @@ function d() {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
f as useNavigateWithTransition
|
|
41
41
|
};
|
|
42
42
|
//# sourceMappingURL=useNavigateWithTransition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigateWithTransition.js","sources":["../../../src/hooks/navigation/useNavigateWithTransition.ts"],"sourcesContent":["import {useLocation, useNavigate, NavigateOptions} from 'react-router'\n\nimport {DATA_NAVIGATION_TYPE_ATTRIBUTE} from '../../types'\n\ntype UseNavigateWithTransitionReturns = (\n to: string | number,\n options?: NavigateOptions\n) => void | Promise<void>\n\nexport function useNavigateWithTransition(): UseNavigateWithTransitionReturns {\n const navigate = useNavigate()\n const location = useLocation()\n\n const transitionNavigate = (\n to: string | number,\n options?: NavigateOptions\n ) => {\n if (typeof to === 'number') {\n // Delta navigation - no options parameter\n if (document.startViewTransition) {\n const transition = document.startViewTransition(() => {\n navigate(to)\n })\n\n transition.finished\n .then(() => {\n document.documentElement.removeAttribute(\n DATA_NAVIGATION_TYPE_ATTRIBUTE\n )\n })\n .catch(error => {\n console.error('View transition error:', error)\n })\n } else {\n return navigate(to)\n }\n return\n }\n\n const isSameRoute = to === location.pathname\n\n // Path navigation - with options\n if (document.startViewTransition) {\n const transition = document.startViewTransition(() => {\n navigate(to, {\n
|
|
1
|
+
{"version":3,"file":"useNavigateWithTransition.js","sources":["../../../src/hooks/navigation/useNavigateWithTransition.ts"],"sourcesContent":["import {useLocation, useNavigate, NavigateOptions} from 'react-router'\n\nimport {DATA_NAVIGATION_TYPE_ATTRIBUTE} from '../../types'\n\ntype UseNavigateWithTransitionReturns = (\n to: string | number,\n options?: NavigateOptions\n) => void | Promise<void>\n\nexport function useNavigateWithTransition(): UseNavigateWithTransitionReturns {\n const navigate = useNavigate()\n const location = useLocation()\n\n const transitionNavigate = (\n to: string | number,\n options?: NavigateOptions\n ) => {\n if (typeof to === 'number') {\n // Delta navigation - no options parameter\n if (document.startViewTransition) {\n const transition = document.startViewTransition(() => {\n navigate(to)\n })\n\n transition.finished\n .then(() => {\n document.documentElement.removeAttribute(\n DATA_NAVIGATION_TYPE_ATTRIBUTE\n )\n })\n .catch(error => {\n console.error('View transition error:', error)\n })\n } else {\n return navigate(to)\n }\n return\n }\n\n const isSameRoute = to === location.pathname\n const isNavigatingToHomeRoute = to === '/'\n\n // Path navigation - with options\n if (document.startViewTransition) {\n const transition = document.startViewTransition(() => {\n if (isNavigatingToHomeRoute) {\n navigate(-window.history.state.idx)\n } else {\n navigate(to, {\n replace: isSameRoute,\n ...options,\n })\n }\n\n if (options?.preventScrollReset !== true) {\n window.scrollTo(0, 0)\n }\n })\n\n transition.finished\n .then(() => {\n document.documentElement.removeAttribute(\n DATA_NAVIGATION_TYPE_ATTRIBUTE\n )\n })\n .catch(error => {\n console.error('View transition error:', error)\n })\n } else {\n return navigate(to, options)\n }\n }\n\n return transitionNavigate\n}\n"],"names":["useNavigateWithTransition","navigate","useNavigate","location","useLocation","to","options","DATA_NAVIGATION_TYPE_ATTRIBUTE","error","isSameRoute","isNavigatingToHomeRoute"],"mappings":";;AASO,SAASA,IAA8D;AAC5E,QAAMC,IAAWC,EAAY,GACvBC,IAAWC,EAAY;AA8DtB,SA5DoB,CACzBC,GACAC,MACG;AACC,QAAA,OAAOD,KAAO,UAAU;AAE1B,UAAI,SAAS;AAKA,QAJQ,SAAS,oBAAoB,MAAM;AACpD,UAAAJ,EAASI,CAAE;AAAA,QAAA,CACZ,EAEU,SACR,KAAK,MAAM;AACV,mBAAS,gBAAgB;AAAA,YACvBE;AAAA,UACF;AAAA,QAAA,CACD,EACA,MAAM,CAASC,MAAA;AACN,kBAAA,MAAM,0BAA0BA,CAAK;AAAA,QAAA,CAC9C;AAAA;AAEH,eAAOP,EAASI,CAAE;AAEpB;AAAA,IAAA;AAGI,UAAAI,IAAcJ,MAAOF,EAAS,UAC9BO,IAA0BL,MAAO;AAGvC,QAAI,SAAS;AAgBA,MAfQ,SAAS,oBAAoB,MAAM;AACpD,QAAIK,IACFT,EAAS,CAAC,OAAO,QAAQ,MAAM,GAAG,IAElCA,EAASI,GAAI;AAAA,UACX,SAASI;AAAA,UACT,GAAGH;AAAA,QAAA,CACJ,GAGCA,GAAS,uBAAuB,MAC3B,OAAA,SAAS,GAAG,CAAC;AAAA,MACtB,CACD,EAEU,SACR,KAAK,MAAM;AACV,iBAAS,gBAAgB;AAAA,UACvBC;AAAA,QACF;AAAA,MAAA,CACD,EACA,MAAM,CAASC,MAAA;AACN,gBAAA,MAAM,0BAA0BA,CAAK;AAAA,MAAA,CAC9C;AAAA;AAEI,aAAAP,EAASI,GAAIC,CAAO;AAAA,EAE/B;AAGF;"}
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,13 @@ import { DATA_NAVIGATION_TYPE_ATTRIBUTE as o, NAVIGATION_TYPES as t } from "./ty
|
|
|
2
2
|
import { MinisContainer as i } from "./components/MinisContainer.js";
|
|
3
3
|
import { AddToCartButton as n } from "./components/commerce/add-to-cart.js";
|
|
4
4
|
import { BuyNowButton as s } from "./components/commerce/buy-now.js";
|
|
5
|
-
import { ProductCard as u, ProductCardBadge as f, ProductCardContainer as x, ProductCardFavoriteButton as
|
|
5
|
+
import { ProductCard as u, ProductCardBadge as f, ProductCardContainer as x, ProductCardFavoriteButton as c, ProductCardImage as d, ProductCardImageContainer as C, ProductCardInfo as g, ProductCardPrice as S, ProductCardReviewStars as A, ProductCardTitle as D } from "./components/commerce/product-card.js";
|
|
6
6
|
import { ProductLink as T } from "./components/commerce/product-link.js";
|
|
7
|
-
import { MerchantCard as I, MerchantCardContainer as R, MerchantCardHeader as
|
|
8
|
-
import { ProductCardSkeleton as
|
|
7
|
+
import { MerchantCard as I, MerchantCardContainer as R, MerchantCardHeader as B, MerchantCardInfo as E, MerchantCardName as M, MerchantCardRating as v } from "./components/commerce/merchant-card.js";
|
|
8
|
+
import { ProductCardSkeleton as F } from "./components/commerce/product-card-skeleton.js";
|
|
9
9
|
import { MerchantCardSkeleton as L } from "./components/commerce/merchant-card-skeleton.js";
|
|
10
10
|
import { QuantitySelector as N } from "./components/commerce/quantity-selector.js";
|
|
11
|
-
import { Search as
|
|
11
|
+
import { Search as O, SearchInput as _, SearchProvider as y, SearchResultsList as G } from "./components/commerce/search.js";
|
|
12
12
|
import { FavoriteButton as V } from "./components/commerce/favorite-button.js";
|
|
13
13
|
import { ImageContentWrapper as W } from "./components/content/image-content-wrapper.js";
|
|
14
14
|
import { MinisRouter as q } from "./components/navigation/minis-router.js";
|
|
@@ -22,23 +22,23 @@ import { AlertDialogAtom as pr } from "./components/atoms/alert-dialog.js";
|
|
|
22
22
|
import { List as mr } from "./components/atoms/list.js";
|
|
23
23
|
import { VideoPlayer as lr } from "./components/atoms/video-player.js";
|
|
24
24
|
import { TextInput as fr } from "./components/atoms/text-input.js";
|
|
25
|
-
import { ContentWrapper as
|
|
25
|
+
import { ContentWrapper as cr } from "./components/atoms/content-wrapper.js";
|
|
26
26
|
import { ProductVariantPrice as Cr } from "./components/atoms/product-variant-price.js";
|
|
27
27
|
import { Accordion as Sr, AccordionContent as Ar, AccordionItem as Dr, AccordionTrigger as Pr } from "./components/ui/accordion.js";
|
|
28
28
|
import { Alert as hr, AlertDescription as Ir, AlertTitle as Rr } from "./components/ui/alert.js";
|
|
29
|
-
import { AlertDialog as
|
|
30
|
-
import { Avatar as
|
|
29
|
+
import { AlertDialog as Er, AlertDialogAction as Mr, AlertDialogCancel as vr, AlertDialogContent as wr, AlertDialogDescription as Fr, AlertDialogFooter as Ur, AlertDialogHeader as Lr, AlertDialogOverlay as br, AlertDialogPortal as Nr, AlertDialogTitle as kr, AlertDialogTrigger as Or } from "./components/ui/alert-dialog.js";
|
|
30
|
+
import { Avatar as yr, AvatarFallback as Gr, AvatarImage as Hr } from "./components/ui/avatar.js";
|
|
31
31
|
import { Badge as zr, badgeVariants as Wr } from "./components/ui/badge.js";
|
|
32
32
|
import { Card as qr, CardAction as Kr, CardContent as Qr, CardDescription as Zr, CardFooter as jr, CardHeader as Jr, CardTitle as Xr } from "./components/ui/card.js";
|
|
33
33
|
import { Carousel as re, CarouselContent as ee, CarouselItem as oe, CarouselNext as te, CarouselPrevious as ae } from "./components/ui/carousel.js";
|
|
34
34
|
import { Checkbox as pe } from "./components/ui/checkbox.js";
|
|
35
|
-
import { Dialog as me, DialogClose as se, DialogContent as le, DialogDescription as ue, DialogFooter as fe, DialogHeader as xe, DialogOverlay as
|
|
36
|
-
import { Drawer as Ae, DrawerClose as De, DrawerContent as Pe, DrawerDescription as Te, DrawerFooter as he, DrawerHeader as Ie, DrawerOverlay as Re, DrawerPortal as
|
|
37
|
-
import { Input as
|
|
35
|
+
import { Dialog as me, DialogClose as se, DialogContent as le, DialogDescription as ue, DialogFooter as fe, DialogHeader as xe, DialogOverlay as ce, DialogPortal as de, DialogTitle as Ce, DialogTrigger as ge } from "./components/ui/dialog.js";
|
|
36
|
+
import { Drawer as Ae, DrawerClose as De, DrawerContent as Pe, DrawerDescription as Te, DrawerFooter as he, DrawerHeader as Ie, DrawerOverlay as Re, DrawerPortal as Be, DrawerTitle as Ee, DrawerTrigger as Me } from "./components/ui/drawer.js";
|
|
37
|
+
import { Input as we } from "./components/ui/input.js";
|
|
38
38
|
import { Label as Ue } from "./components/ui/label.js";
|
|
39
39
|
import { Progress as be } from "./components/ui/progress.js";
|
|
40
|
-
import { RadioGroup as ke, RadioGroupItem as
|
|
41
|
-
import { ResizableHandle as
|
|
40
|
+
import { RadioGroup as ke, RadioGroupItem as Oe } from "./components/ui/radio-group.js";
|
|
41
|
+
import { ResizableHandle as ye, ResizablePanel as Ge, ResizablePanelGroup as He } from "./components/ui/resizable.js";
|
|
42
42
|
import { ScrollArea as ze, ScrollBar as We } from "./components/ui/scroll-area.js";
|
|
43
43
|
import { Select as qe, SelectContent as Ke, SelectGroup as Qe, SelectItem as Ze, SelectLabel as je, SelectScrollDownButton as Je, SelectScrollUpButton as Xe, SelectSeparator as $e, SelectTrigger as ro, SelectValue as eo } from "./components/ui/select.js";
|
|
44
44
|
import { Separator as to } from "./components/ui/separator.js";
|
|
@@ -49,13 +49,13 @@ import { Skeleton as Ao } from "./components/ui/skeleton.js";
|
|
|
49
49
|
import { useRecentProducts as Po } from "./hooks/user/useRecentProducts.js";
|
|
50
50
|
import { useRecentShops as ho } from "./hooks/user/useRecentShops.js";
|
|
51
51
|
import { useSavedProducts as Ro } from "./hooks/user/useSavedProducts.js";
|
|
52
|
-
import { useSavedProductsActions as
|
|
53
|
-
import { useFollowedShops as
|
|
54
|
-
import { useFollowedShopsActions as
|
|
52
|
+
import { useSavedProductsActions as Eo } from "./hooks/user/useSavedProductsActions.js";
|
|
53
|
+
import { useFollowedShops as vo } from "./hooks/user/useFollowedShops.js";
|
|
54
|
+
import { useFollowedShopsActions as Fo } from "./hooks/user/useFollowedShopsActions.js";
|
|
55
55
|
import { useCurrentUser as Lo } from "./hooks/user/useCurrentUser.js";
|
|
56
56
|
import { useOrders as No } from "./hooks/user/useOrders.js";
|
|
57
|
-
import { useBuyerAttributes as
|
|
58
|
-
import { useGenerateUserToken as
|
|
57
|
+
import { useBuyerAttributes as Oo } from "./hooks/user/useBuyerAttributes.js";
|
|
58
|
+
import { useGenerateUserToken as yo } from "./hooks/user/useGenerateUserToken.js";
|
|
59
59
|
import { useProductListActions as Ho } from "./hooks/product/useProductListActions.js";
|
|
60
60
|
import { useProductLists as zo } from "./hooks/product/useProductLists.js";
|
|
61
61
|
import { useProductList as Yo } from "./hooks/product/useProductList.js";
|
|
@@ -70,32 +70,33 @@ import { useCuratedProducts as nt } from "./hooks/product/useCuratedProducts.js"
|
|
|
70
70
|
import { useAsyncStorage as st } from "./hooks/storage/useAsyncStorage.js";
|
|
71
71
|
import { useSecureStorage as ut } from "./hooks/storage/useSecureStorage.js";
|
|
72
72
|
import { useImageUpload as xt } from "./hooks/storage/useImageUpload.js";
|
|
73
|
-
import { useShopNavigation as
|
|
73
|
+
import { useShopNavigation as dt } from "./hooks/navigation/useShopNavigation.js";
|
|
74
74
|
import { useCloseMini as gt } from "./hooks/navigation/useCloseMini.js";
|
|
75
75
|
import { useDeeplink as At } from "./hooks/navigation/useDeeplink.js";
|
|
76
76
|
import { useNavigateWithTransition as Pt } from "./hooks/navigation/useNavigateWithTransition.js";
|
|
77
77
|
import { useShop as ht } from "./hooks/shop/useShop.js";
|
|
78
78
|
import { useRecommendedShops as Rt } from "./hooks/shop/useRecommendedShops.js";
|
|
79
|
-
import { useCreateImageContent as
|
|
80
|
-
import { useErrorToast as
|
|
81
|
-
import { useErrorScreen as
|
|
79
|
+
import { useCreateImageContent as Et } from "./hooks/content/useCreateImageContent.js";
|
|
80
|
+
import { useErrorToast as vt } from "./hooks/util/useErrorToast.js";
|
|
81
|
+
import { useErrorScreen as Ft } from "./hooks/util/useErrorScreen.js";
|
|
82
82
|
import { useShare as Lt } from "./hooks/util/useShare.js";
|
|
83
83
|
import { useImagePicker as Nt } from "./hooks/util/useImagePicker.js";
|
|
84
|
-
import { useKeyboardAvoidingView as
|
|
85
|
-
import { useRequestPermissions as
|
|
84
|
+
import { useKeyboardAvoidingView as Ot } from "./hooks/util/useKeyboardAvoidingView.js";
|
|
85
|
+
import { useRequestPermissions as yt } from "./hooks/util/useRequestPermissions.js";
|
|
86
86
|
import { useOnMiniFocus as Ht } from "./hooks/events/useOnMiniFocus.js";
|
|
87
87
|
import { useOnMiniBlur as zt } from "./hooks/events/useOnMiniBlur.js";
|
|
88
88
|
import { useOnMiniClose as Yt } from "./hooks/events/useOnMiniClose.js";
|
|
89
89
|
import { useOnAppStateChange as Kt } from "./hooks/events/useOnAppStateChange.js";
|
|
90
|
-
import {
|
|
91
|
-
import {
|
|
92
|
-
import {
|
|
93
|
-
import {
|
|
94
|
-
import {
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
90
|
+
import { useOnNavigateBack as Zt } from "./hooks/events/useOnNavigateBack.js";
|
|
91
|
+
import { MiniEntityNotFoundError as Jt, MiniError as Xt, MiniNetworkError as $t, formatError as ra } from "./utils/errors.js";
|
|
92
|
+
import { extractBrandTheme as oa, formatReviewCount as ta, getFeaturedImages as aa, normalizeRating as ia } from "./utils/merchant-card.js";
|
|
93
|
+
import { parseUrl as na } from "./utils/parseUrl.js";
|
|
94
|
+
import { dataURLToBlob as sa, fileToDataUri as la, getResizedImageUrl as ua, getThumbhashBlobURL as fa, getThumbhashDataURL as xa } from "./utils/image.js";
|
|
95
|
+
import { formatMoney as da } from "./utils/formatMoney.js";
|
|
96
|
+
import { UserState as ga, UserTokenGenerateUserErrorCode as Sa } from "./shop-minis-platform/src/types/user.js";
|
|
97
|
+
import { ContentCreateUserErrorCode as Da, MinisContentStatus as Pa } from "./shop-minis-platform/src/types/content.js";
|
|
98
|
+
import { Social as ha } from "./shop-minis-platform/src/types/share.js";
|
|
99
|
+
import { DATA_FETCHING_DEFAULT_FETCH_POLICY as Ra, DATA_FETCHING_DEFAULT_PAGE_SIZE as Ba } from "./shop-minis-platform/src/constants.js";
|
|
99
100
|
export {
|
|
100
101
|
Sr as Accordion,
|
|
101
102
|
Ar as AccordionContent,
|
|
@@ -104,21 +105,21 @@ export {
|
|
|
104
105
|
n as AddToCartButton,
|
|
105
106
|
hr as Alert,
|
|
106
107
|
Ir as AlertDescription,
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
Er as AlertDialog,
|
|
109
|
+
Mr as AlertDialogAction,
|
|
109
110
|
pr as AlertDialogAtom,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
vr as AlertDialogCancel,
|
|
112
|
+
wr as AlertDialogContent,
|
|
113
|
+
Fr as AlertDialogDescription,
|
|
113
114
|
Ur as AlertDialogFooter,
|
|
114
115
|
Lr as AlertDialogHeader,
|
|
115
116
|
br as AlertDialogOverlay,
|
|
116
117
|
Nr as AlertDialogPortal,
|
|
117
118
|
kr as AlertDialogTitle,
|
|
118
|
-
|
|
119
|
+
Or as AlertDialogTrigger,
|
|
119
120
|
Rr as AlertTitle,
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
yr as Avatar,
|
|
122
|
+
Gr as AvatarFallback,
|
|
122
123
|
Hr as AvatarImage,
|
|
123
124
|
zr as Badge,
|
|
124
125
|
j as Button,
|
|
@@ -136,10 +137,10 @@ export {
|
|
|
136
137
|
te as CarouselNext,
|
|
137
138
|
ae as CarouselPrevious,
|
|
138
139
|
pe as Checkbox,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
Da as ContentCreateUserErrorCode,
|
|
141
|
+
cr as ContentWrapper,
|
|
142
|
+
Ra as DATA_FETCHING_DEFAULT_FETCH_POLICY,
|
|
143
|
+
Ba as DATA_FETCHING_DEFAULT_PAGE_SIZE,
|
|
143
144
|
o as DATA_NAVIGATION_TYPE_ATTRIBUTE,
|
|
144
145
|
me as Dialog,
|
|
145
146
|
se as DialogClose,
|
|
@@ -147,8 +148,8 @@ export {
|
|
|
147
148
|
ue as DialogDescription,
|
|
148
149
|
fe as DialogFooter,
|
|
149
150
|
xe as DialogHeader,
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
ce as DialogOverlay,
|
|
152
|
+
de as DialogPortal,
|
|
152
153
|
Ce as DialogTitle,
|
|
153
154
|
ge as DialogTrigger,
|
|
154
155
|
Ae as Drawer,
|
|
@@ -158,57 +159,57 @@ export {
|
|
|
158
159
|
he as DrawerFooter,
|
|
159
160
|
Ie as DrawerHeader,
|
|
160
161
|
Re as DrawerOverlay,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
Be as DrawerPortal,
|
|
163
|
+
Ee as DrawerTitle,
|
|
164
|
+
Me as DrawerTrigger,
|
|
164
165
|
V as FavoriteButton,
|
|
165
166
|
X as IconButton,
|
|
166
167
|
rr as Image,
|
|
167
168
|
W as ImageContentWrapper,
|
|
168
|
-
|
|
169
|
+
we as Input,
|
|
169
170
|
Ue as Label,
|
|
170
171
|
mr as List,
|
|
171
172
|
ar as LongPressDetector,
|
|
172
173
|
I as MerchantCard,
|
|
173
174
|
R as MerchantCardContainer,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
B as MerchantCardHeader,
|
|
176
|
+
E as MerchantCardInfo,
|
|
177
|
+
M as MerchantCardName,
|
|
178
|
+
v as MerchantCardRating,
|
|
178
179
|
L as MerchantCardSkeleton,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
Jt as MiniEntityNotFoundError,
|
|
181
|
+
Xt as MiniError,
|
|
182
|
+
$t as MiniNetworkError,
|
|
182
183
|
i as MinisContainer,
|
|
183
|
-
|
|
184
|
+
Pa as MinisContentStatus,
|
|
184
185
|
q as MinisRouter,
|
|
185
186
|
t as NAVIGATION_TYPES,
|
|
186
187
|
u as ProductCard,
|
|
187
188
|
f as ProductCardBadge,
|
|
188
189
|
x as ProductCardContainer,
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
c as ProductCardFavoriteButton,
|
|
191
|
+
d as ProductCardImage,
|
|
191
192
|
C as ProductCardImageContainer,
|
|
192
193
|
g as ProductCardInfo,
|
|
193
194
|
S as ProductCardPrice,
|
|
194
195
|
A as ProductCardReviewStars,
|
|
195
|
-
|
|
196
|
+
F as ProductCardSkeleton,
|
|
196
197
|
D as ProductCardTitle,
|
|
197
198
|
T as ProductLink,
|
|
198
199
|
Cr as ProductVariantPrice,
|
|
199
200
|
be as Progress,
|
|
200
201
|
N as QuantitySelector,
|
|
201
202
|
ke as RadioGroup,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
Oe as RadioGroupItem,
|
|
204
|
+
ye as ResizableHandle,
|
|
205
|
+
Ge as ResizablePanel,
|
|
205
206
|
He as ResizablePanelGroup,
|
|
206
207
|
ze as ScrollArea,
|
|
207
208
|
We as ScrollBar,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
O as Search,
|
|
210
|
+
_ as SearchInput,
|
|
211
|
+
y as SearchProvider,
|
|
212
|
+
G as SearchResultsList,
|
|
212
213
|
qe as Select,
|
|
213
214
|
Ke as SelectContent,
|
|
214
215
|
Qe as SelectGroup,
|
|
@@ -229,48 +230,49 @@ export {
|
|
|
229
230
|
uo as SheetTitle,
|
|
230
231
|
fo as SheetTrigger,
|
|
231
232
|
Ao as Skeleton,
|
|
232
|
-
|
|
233
|
+
ha as Social,
|
|
233
234
|
fr as TextInput,
|
|
234
235
|
co as Toaster,
|
|
235
236
|
or as Touchable,
|
|
236
237
|
Q as TransitionLink,
|
|
237
|
-
|
|
238
|
-
|
|
238
|
+
ga as UserState,
|
|
239
|
+
Sa as UserTokenGenerateUserErrorCode,
|
|
239
240
|
lr as VideoPlayer,
|
|
240
241
|
Wr as badgeVariants,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
242
|
+
sa as dataURLToBlob,
|
|
243
|
+
oa as extractBrandTheme,
|
|
244
|
+
la as fileToDataUri,
|
|
245
|
+
ra as formatError,
|
|
246
|
+
da as formatMoney,
|
|
247
|
+
ta as formatReviewCount,
|
|
248
|
+
aa as getFeaturedImages,
|
|
249
|
+
ua as getResizedImageUrl,
|
|
250
|
+
fa as getThumbhashBlobURL,
|
|
251
|
+
xa as getThumbhashDataURL,
|
|
252
|
+
ia as normalizeRating,
|
|
253
|
+
na as parseUrl,
|
|
253
254
|
go as toast,
|
|
254
255
|
st as useAsyncStorage,
|
|
255
|
-
|
|
256
|
+
Oo as useBuyerAttributes,
|
|
256
257
|
gt as useCloseMini,
|
|
257
|
-
|
|
258
|
+
Et as useCreateImageContent,
|
|
258
259
|
nt as useCuratedProducts,
|
|
259
260
|
Lo as useCurrentUser,
|
|
260
261
|
At as useDeeplink,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
Ft as useErrorScreen,
|
|
263
|
+
vt as useErrorToast,
|
|
264
|
+
vo as useFollowedShops,
|
|
265
|
+
Fo as useFollowedShopsActions,
|
|
266
|
+
yo as useGenerateUserToken,
|
|
266
267
|
Nt as useImagePicker,
|
|
267
268
|
xt as useImageUpload,
|
|
268
|
-
|
|
269
|
+
Ot as useKeyboardAvoidingView,
|
|
269
270
|
Pt as useNavigateWithTransition,
|
|
270
271
|
Kt as useOnAppStateChange,
|
|
271
272
|
zt as useOnMiniBlur,
|
|
272
273
|
Yt as useOnMiniClose,
|
|
273
274
|
Ht as useOnMiniFocus,
|
|
275
|
+
Zt as useOnNavigateBack,
|
|
274
276
|
No as useOrders,
|
|
275
277
|
it as usePopularProducts,
|
|
276
278
|
Ko as useProduct,
|
|
@@ -285,12 +287,12 @@ export {
|
|
|
285
287
|
ho as useRecentShops,
|
|
286
288
|
tt as useRecommendedProducts,
|
|
287
289
|
Rt as useRecommendedShops,
|
|
288
|
-
|
|
290
|
+
yt as useRequestPermissions,
|
|
289
291
|
Ro as useSavedProducts,
|
|
290
|
-
|
|
292
|
+
Eo as useSavedProductsActions,
|
|
291
293
|
ut as useSecureStorage,
|
|
292
294
|
Lt as useShare,
|
|
293
295
|
ht as useShop,
|
|
294
|
-
|
|
296
|
+
dt as useShopNavigation
|
|
295
297
|
};
|
|
296
298
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useOnNavigateBack as t } from "../hooks/events/useOnNavigateBack.js";
|
|
2
|
+
import { useNavigateWithTransition as i } from "../hooks/navigation/useNavigateWithTransition.js";
|
|
3
|
+
function r() {
|
|
4
|
+
const a = i();
|
|
5
|
+
return t(() => {
|
|
6
|
+
a(-1);
|
|
7
|
+
}), null;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
r as NavigationManager
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=navigation-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-manager.js","sources":["../../src/internal/navigation-manager.tsx"],"sourcesContent":["import {useOnNavigateBack} from '../hooks/events/useOnNavigateBack'\nimport {useNavigateWithTransition} from '../hooks/navigation/useNavigateWithTransition'\n\nexport function NavigationManager() {\n const navigate = useNavigateWithTransition()\n\n // Handle native back button press\n useOnNavigateBack(() => {\n navigate(-1)\n })\n\n return null\n}\n"],"names":["NavigationManager","navigate","useNavigateWithTransition","useOnNavigateBack"],"mappings":";;AAGO,SAASA,IAAoB;AAClC,QAAMC,IAAWC,EAA0B;AAG3C,SAAAC,EAAkB,MAAM;AACtB,IAAAF,EAAS,EAAE;AAAA,EAAA,CACZ,GAEM;AACT;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as r } from "../../../../../../../_virtual/
|
|
1
|
+
import { __module as r } from "../../../../../../../_virtual/index10.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.0-snapshot.
|
|
4
|
+
"version": "0.0.0-snapshot.20260112135844",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": ">=5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@shopify/shop-minis-platform": "0.0.0-snapshot.
|
|
49
|
+
"@shopify/shop-minis-platform": "0.0.0-snapshot.20260112135844",
|
|
50
50
|
"@tailwindcss/vite": "4.1.8",
|
|
51
51
|
"@tanstack/react-query": "5.86.0",
|
|
52
52
|
"@types/color": "3.0.6",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {BrowserRouter, BrowserRouterProps} from 'react-router'
|
|
2
2
|
|
|
3
|
+
import {NavigationManager} from '../../internal/navigation-manager'
|
|
4
|
+
|
|
3
5
|
import {TransitionContainer} from './transition-container'
|
|
4
6
|
|
|
5
7
|
export interface MinisRouterProps extends BrowserRouterProps {
|
|
@@ -14,10 +16,16 @@ export function MinisRouter({
|
|
|
14
16
|
if (viewTransitions) {
|
|
15
17
|
return (
|
|
16
18
|
<BrowserRouter {...props}>
|
|
19
|
+
<NavigationManager />
|
|
17
20
|
<TransitionContainer>{children}</TransitionContainer>
|
|
18
21
|
</BrowserRouter>
|
|
19
22
|
)
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
return
|
|
25
|
+
return (
|
|
26
|
+
<BrowserRouter {...props}>
|
|
27
|
+
<NavigationManager />
|
|
28
|
+
{children}
|
|
29
|
+
</BrowserRouter>
|
|
30
|
+
)
|
|
23
31
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {useEffect, useRef} from 'react'
|
|
2
|
+
|
|
3
|
+
export function useOnNavigateBack(callback: () => void) {
|
|
4
|
+
// Using a ref allows the callback to be updated without triggering a re-render
|
|
5
|
+
// This makes the hook nicer to use because developers don't need useCallback
|
|
6
|
+
const callbackRef = useRef(callback)
|
|
7
|
+
callbackRef.current = callback
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const listenerId = window.minisEvents.on('NAVIGATE_BACK', () => {
|
|
11
|
+
callbackRef.current()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
return () => window.minisEvents.off(listenerId)
|
|
15
|
+
}, [])
|
|
16
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -290,15 +290,29 @@ describe('useNavigateWithTransition', () => {
|
|
|
290
290
|
})
|
|
291
291
|
})
|
|
292
292
|
|
|
293
|
-
it('handles navigation to root path', async () => {
|
|
293
|
+
it('handles navigation to root path using history delta', async () => {
|
|
294
|
+
// Mock history state with idx
|
|
295
|
+
const originalHistoryState = window.history.state
|
|
296
|
+
Object.defineProperty(window.history, 'state', {
|
|
297
|
+
value: {idx: 3},
|
|
298
|
+
writable: true,
|
|
299
|
+
configurable: true,
|
|
300
|
+
})
|
|
301
|
+
|
|
294
302
|
const {result} = renderHook(() => useNavigateWithTransition())
|
|
295
303
|
|
|
296
304
|
await act(async () => {
|
|
297
305
|
result.current('/')
|
|
298
306
|
})
|
|
299
307
|
|
|
300
|
-
|
|
301
|
-
|
|
308
|
+
// Should navigate back using delta based on history index
|
|
309
|
+
expect(mockNavigate).toHaveBeenCalledWith(-3)
|
|
310
|
+
|
|
311
|
+
// Restore original state
|
|
312
|
+
Object.defineProperty(window.history, 'state', {
|
|
313
|
+
value: originalHistoryState,
|
|
314
|
+
writable: true,
|
|
315
|
+
configurable: true,
|
|
302
316
|
})
|
|
303
317
|
})
|
|
304
318
|
|
|
@@ -38,14 +38,19 @@ export function useNavigateWithTransition(): UseNavigateWithTransitionReturns {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const isSameRoute = to === location.pathname
|
|
41
|
+
const isNavigatingToHomeRoute = to === '/'
|
|
41
42
|
|
|
42
43
|
// Path navigation - with options
|
|
43
44
|
if (document.startViewTransition) {
|
|
44
45
|
const transition = document.startViewTransition(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if (isNavigatingToHomeRoute) {
|
|
47
|
+
navigate(-window.history.state.idx)
|
|
48
|
+
} else {
|
|
49
|
+
navigate(to, {
|
|
50
|
+
replace: isSameRoute,
|
|
51
|
+
...options,
|
|
52
|
+
})
|
|
53
|
+
}
|
|
49
54
|
|
|
50
55
|
if (options?.preventScrollReset !== true) {
|
|
51
56
|
window.scrollTo(0, 0)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {useOnNavigateBack} from '../hooks/events/useOnNavigateBack'
|
|
2
|
+
import {useNavigateWithTransition} from '../hooks/navigation/useNavigateWithTransition'
|
|
3
|
+
|
|
4
|
+
export function NavigationManager() {
|
|
5
|
+
const navigate = useNavigateWithTransition()
|
|
6
|
+
|
|
7
|
+
// Handle native back button press
|
|
8
|
+
useOnNavigateBack(() => {
|
|
9
|
+
navigate(-1)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
return null
|
|
13
|
+
}
|