@shopify/shop-minis-react 0.0.1 → 0.0.2
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/README.md +110 -90
- package/dist/_virtual/_commonjsHelpers.js +9 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/index.js +8 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index2.js +5 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/components/ui/alert-dialog.js +141 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/button.js +50 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/card.js +91 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/sonner.js +23 -0
- package/dist/components/ui/sonner.js.map +1 -0
- package/dist/hooks/navigation/useCloseMini.js +12 -0
- package/dist/hooks/navigation/useCloseMini.js.map +1 -0
- package/dist/hooks/navigation/useShopNavigation.js +20 -0
- package/dist/hooks/navigation/useShopNavigation.js.map +1 -0
- package/dist/hooks/product/usePopularProducts.js +20 -0
- package/dist/hooks/product/usePopularProducts.js.map +1 -0
- package/dist/hooks/product/useProductList.js +29 -0
- package/dist/hooks/product/useProductList.js.map +1 -0
- package/dist/hooks/product/useProductListActions.js +22 -0
- package/dist/hooks/product/useProductListActions.js.map +1 -0
- package/dist/hooks/product/useProductLists.js +20 -0
- package/dist/hooks/product/useProductLists.js.map +1 -0
- package/dist/hooks/product/useRecommendedProducts.js +20 -0
- package/dist/hooks/product/useRecommendedProducts.js.map +1 -0
- package/dist/hooks/shop/useRecommendedShops.js +21 -0
- package/dist/hooks/shop/useRecommendedShops.js.map +1 -0
- package/dist/hooks/shop/useShopCartActions.js +13 -0
- package/dist/hooks/shop/useShopCartActions.js.map +1 -0
- package/dist/hooks/storage/useAsyncStorage.js +22 -0
- package/dist/hooks/storage/useAsyncStorage.js.map +1 -0
- package/dist/hooks/storage/useImageUpload.js +62 -0
- package/dist/hooks/storage/useImageUpload.js.map +1 -0
- package/dist/hooks/storage/useSecureStorage.js +14 -0
- package/dist/hooks/storage/useSecureStorage.js.map +1 -0
- package/dist/hooks/user/useBuyerAttributes.js +20 -0
- package/dist/hooks/user/useBuyerAttributes.js.map +1 -0
- package/dist/hooks/user/useCurrentUser.js +20 -0
- package/dist/hooks/user/useCurrentUser.js.map +1 -0
- package/dist/hooks/user/useFollowedShopsActions.js +13 -0
- package/dist/hooks/user/useFollowedShopsActions.js.map +1 -0
- package/dist/hooks/user/useOrders.js +20 -0
- package/dist/hooks/user/useOrders.js.map +1 -0
- package/dist/hooks/user/useSavedProductsActions.js +13 -0
- package/dist/hooks/user/useSavedProductsActions.js.map +1 -0
- package/dist/hooks/util/useErrorScreen.js +9 -0
- package/dist/hooks/util/useErrorScreen.js.map +1 -0
- package/dist/hooks/util/useErrorToast.js +9 -0
- package/dist/hooks/util/useErrorToast.js.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/useHandleAction.js +13 -0
- package/dist/internal/useHandleAction.js.map +1 -0
- package/dist/internal/useShopActions.js +7 -0
- package/dist/internal/useShopActions.js.map +1 -0
- package/dist/internal/useShopActionsDataFetching.js +79 -0
- package/dist/internal/useShopActionsDataFetching.js.map +1 -0
- package/dist/internal/useShopActionsPaginatedDataFetching.js +96 -0
- package/dist/internal/useShopActionsPaginatedDataFetching.js.map +1 -0
- package/dist/lib/utils.js +9 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_primitive@1.1.2/node_modules/@radix-ui/primitive/dist/index.js +10 -0
- package/dist/node_modules/.pnpm/@radix-ui_primitive@1.1.2/node_modules/@radix-ui/primitive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-alert-dialog@1.1.14_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react_5smkpul3xqqoqjowwwfk226yey/node_modules/@radix-ui/react-alert-dialog/dist/index.js +127 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-alert-dialog@1.1.14_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react_5smkpul3xqqoqjowwwfk226yey/node_modules/@radix-ui/react-alert-dialog/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-compose-refs@1.1.2_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-compose-refs/dist/index.js +30 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-compose-refs@1.1.2_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-compose-refs/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-context@1.1.2_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-context/dist/index.js +69 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-context@1.1.2_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-context/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-dialog@1.1.14_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@19.1._sjczexpvrqz6fttoobpwnns2oa/node_modules/@radix-ui/react-dialog/dist/index.js +259 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-dialog@1.1.14_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@19.1._sjczexpvrqz6fttoobpwnns2oa/node_modules/@radix-ui/react-dialog/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-dismissable-layer@1.1.10_@types_react-dom@19.1.6_@types_react@19.1.6__@types__ipor64qsap4jnr6m7nflv4q5v4/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +128 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-dismissable-layer@1.1.10_@types_react-dom@19.1.6_@types_react@19.1.6__@types__ipor64qsap4jnr6m7nflv4q5v4/node_modules/@radix-ui/react-dismissable-layer/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-focus-guards@1.1.2_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-focus-guards/dist/index.js +18 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-focus-guards@1.1.2_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-focus-guards/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@1_zpdtvgogfsfavk62phevpdv4fu/node_modules/@radix-ui/react-focus-scope/dist/index.js +137 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@1_zpdtvgogfsfavk62phevpdv4fu/node_modules/@radix-ui/react-focus-scope/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-id@1.1.1_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-id/dist/index.js +14 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-id@1.1.1_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-id/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-portal@1.1.9_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@19.1.6_sr45arufxpp6hzdn2l7kcrtvqe/node_modules/@radix-ui/react-portal/dist/index.js +16 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-portal@1.1.9_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@19.1.6_sr45arufxpp6hzdn2l7kcrtvqe/node_modules/@radix-ui/react-portal/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.4_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@19.1_5ga5lr7i6zouk7rhd63vbsmjyu/node_modules/@radix-ui/react-presence/dist/index.js +71 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.4_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@19.1_5ga5lr7i6zouk7rhd63vbsmjyu/node_modules/@radix-ui/react-presence/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-primitive@2.1.3_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@19._5iu4xtybujtep4zwi6jviky6tu/node_modules/@radix-ui/react-primitive/dist/index.js +37 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-primitive@2.1.3_@types_react-dom@19.1.6_@types_react@19.1.6__@types_react@19._5iu4xtybujtep4zwi6jviky6tu/node_modules/@radix-ui/react-primitive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-slot/dist/index.js +59 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-slot/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +11 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-callback-ref/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +53 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +15 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-layout-effect/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/aria-hidden@1.2.6/node_modules/aria-hidden/dist/es2015/index.js +53 -0
- package/dist/node_modules/.pnpm/aria-hidden@1.2.6/node_modules/aria-hidden/dist/es2015/index.js.map +1 -0
- package/dist/node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js +36 -0
- package/dist/node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js +18 -0
- package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js.map +1 -0
- package/dist/node_modules/.pnpm/get-nonce@1.0.1/node_modules/get-nonce/dist/es2015/index.js +8 -0
- package/dist/node_modules/.pnpm/get-nonce@1.0.1/node_modules/get-nonce/dist/es2015/index.js.map +1 -0
- package/dist/node_modules/.pnpm/next-themes@0.4.6_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next-themes/dist/index.js +34 -0
- package/dist/node_modules/.pnpm/next-themes@0.4.6_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next-themes/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +44 -0
- package/dist/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll-bar/dist/es2015/component.js +72 -0
- package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll-bar/dist/es2015/component.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +8 -0
- package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll-bar/dist/es2015/constants.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +26 -0
- package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll-bar/dist/es2015/utils.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/Combination.js +12 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/Combination.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +113 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/SideEffect.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/UI.js +32 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/UI.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +17 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +69 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/handleScroll.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/medium.js +6 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/medium.js.map +1 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/sidecar.js +8 -0
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.1.6_react@19.1.0/node_modules/react-remove-scroll/dist/es2015/sidecar.js.map +1 -0
- package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.1.6_react@19.1.0/node_modules/react-style-singleton/dist/es2015/component.js +12 -0
- package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.1.6_react@19.1.0/node_modules/react-style-singleton/dist/es2015/component.js.map +1 -0
- package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.1.6_react@19.1.0/node_modules/react-style-singleton/dist/es2015/hook.js +16 -0
- package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.1.6_react@19.1.0/node_modules/react-style-singleton/dist/es2015/hook.js.map +1 -0
- package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.1.6_react@19.1.0/node_modules/react-style-singleton/dist/es2015/singleton.js +31 -0
- package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.1.6_react@19.1.0/node_modules/react-style-singleton/dist/es2015/singleton.js.map +1 -0
- package/dist/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js +25 -0
- package/dist/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js.map +1 -0
- package/dist/node_modules/.pnpm/sonner@2.0.5_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/sonner/dist/index.js +743 -0
- package/dist/node_modules/.pnpm/sonner@2.0.5_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/sonner/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/tailwind-merge@2.6.0/node_modules/tailwind-merge/dist/bundle-mjs.js +2265 -0
- package/dist/node_modules/.pnpm/tailwind-merge@2.6.0/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -0
- package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.js +28 -0
- package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js +133 -0
- package/dist/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js.map +1 -0
- package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.1.6_react@19.1.0/node_modules/use-callback-ref/dist/es2015/assignRef.js +7 -0
- package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.1.6_react@19.1.0/node_modules/use-callback-ref/dist/es2015/assignRef.js.map +1 -0
- package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.1.6_react@19.1.0/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +27 -0
- package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.1.6_react@19.1.0/node_modules/use-callback-ref/dist/es2015/useMergeRef.js.map +1 -0
- package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.1.6_react@19.1.0/node_modules/use-callback-ref/dist/es2015/useRef.js +26 -0
- package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.1.6_react@19.1.0/node_modules/use-callback-ref/dist/es2015/useRef.js.map +1 -0
- package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.1.6_react@19.1.0/node_modules/use-sidecar/dist/es2015/exports.js +19 -0
- package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.1.6_react@19.1.0/node_modules/use-sidecar/dist/es2015/exports.js.map +1 -0
- package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.1.6_react@19.1.0/node_modules/use-sidecar/dist/es2015/medium.js +68 -0
- package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.1.6_react@19.1.0/node_modules/use-sidecar/dist/es2015/medium.js.map +1 -0
- package/dist/types/minisSDK.generated.d.js +18 -0
- package/dist/types/minisSDK.generated.d.js.map +1 -0
- package/dist/utils/errors.js +39 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/parseUrl.js +8 -0
- package/dist/utils/parseUrl.js.map +1 -0
- package/package.json +29 -14
- package/src/components/index.ts +4 -7
- package/src/components/ui/alert-dialog.tsx +151 -0
- package/src/components/ui/button.tsx +60 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/dev.tsx +116 -38
- package/src/hooks/index.ts +31 -5
- package/src/hooks/navigation/useCloseMini.doc.ts +32 -0
- package/src/hooks/navigation/useCloseMini.example.tsx +7 -0
- package/src/hooks/navigation/useCloseMini.ts +17 -0
- package/src/hooks/navigation/useShopNavigation.doc.ts +32 -0
- package/src/hooks/navigation/useShopNavigation.example.tsx +29 -0
- package/src/hooks/navigation/useShopNavigation.ts +41 -0
- package/src/hooks/product/usePopularProducts.ts +37 -0
- package/src/hooks/product/useProductList.doc.ts +32 -0
- package/src/hooks/product/useProductList.example.tsx +9 -0
- package/src/hooks/product/useProductList.ts +56 -0
- package/src/hooks/product/useProductListActions.doc.ts +32 -0
- package/src/hooks/product/useProductListActions.example.tsx +57 -0
- package/src/hooks/product/useProductListActions.ts +51 -0
- package/src/hooks/product/useProductLists.doc.ts +32 -0
- package/src/hooks/product/useProductLists.example.tsx +9 -0
- package/src/hooks/product/useProductLists.ts +39 -0
- package/src/hooks/product/useRecommendedProducts.doc.ts +32 -0
- package/src/hooks/product/useRecommendedProducts.example.tsx +7 -0
- package/src/hooks/product/useRecommendedProducts.ts +37 -0
- package/src/hooks/shop/useRecommendedShops.doc.ts +32 -0
- package/src/hooks/shop/useRecommendedShops.example.tsx +7 -0
- package/src/hooks/shop/useRecommendedShops.ts +43 -0
- package/src/hooks/shop/useShopCartActions.doc.ts +32 -0
- package/src/hooks/shop/useShopCartActions.example.tsx +28 -0
- package/src/hooks/shop/useShopCartActions.ts +23 -0
- package/src/hooks/storage/useAsyncStorage.doc.ts +32 -0
- package/src/hooks/storage/useAsyncStorage.example.tsx +30 -0
- package/src/hooks/storage/useAsyncStorage.ts +48 -0
- package/src/hooks/storage/useImageUpload.doc.ts +32 -0
- package/src/hooks/storage/useImageUpload.example.tsx +20 -0
- package/src/hooks/storage/useImageUpload.ts +135 -0
- package/src/hooks/storage/useSecureStorage.doc.ts +32 -0
- package/src/hooks/storage/useSecureStorage.example.tsx +23 -0
- package/src/hooks/storage/useSecureStorage.ts +28 -0
- package/src/hooks/user/useBuyerAttributes.doc.ts +32 -0
- package/src/hooks/user/useBuyerAttributes.example.tsx +14 -0
- package/src/hooks/user/useBuyerAttributes.ts +34 -0
- package/src/hooks/user/useCurrentUser.doc.ts +31 -0
- package/src/hooks/user/useCurrentUser.example.tsx +7 -0
- package/src/hooks/user/useCurrentUser.ts +37 -0
- package/src/hooks/user/useFollowedShopsActions.doc.ts +32 -0
- package/src/hooks/user/useFollowedShopsActions.example.tsx +18 -0
- package/src/hooks/user/useFollowedShopsActions.ts +23 -0
- package/src/hooks/user/useOrders.doc.ts +32 -0
- package/src/hooks/user/useOrders.example.tsx +7 -0
- package/src/hooks/user/useOrders.ts +32 -0
- package/src/hooks/user/useSavedProductsActions.doc.ts +32 -0
- package/src/hooks/user/useSavedProductsActions.example.tsx +30 -0
- package/src/hooks/user/useSavedProductsActions.ts +23 -0
- package/src/hooks/util/useErrorScreen.doc.ts +32 -0
- package/src/hooks/util/useErrorScreen.example.tsx +16 -0
- package/src/hooks/util/useErrorScreen.ts +15 -0
- package/src/hooks/util/useErrorToast.doc.ts +32 -0
- package/src/hooks/util/useErrorToast.example.tsx +15 -0
- package/src/hooks/util/useErrorToast.ts +15 -0
- package/src/index.css +120 -2
- package/src/internal/useHandleAction.ts +24 -0
- package/src/internal/useShopActions.ts +5 -0
- package/src/internal/useShopActionsDataFetching.ts +153 -0
- package/src/internal/useShopActionsPaginatedDataFetching.ts +193 -0
- package/src/lib/utils.ts +9 -0
- package/src/types/index.ts +2 -0
- package/src/types/minisSDK.generated.d.ts +2 -74
- package/src/utils/errors.ts +86 -0
- package/src/utils/index.ts +2 -11
- package/src/utils/parseUrl.ts +5 -0
- package/tailwind.config.js +3 -0
- package/src/components/HelloWorld/HelloWorld.tsx +0 -43
- package/src/components/HelloWorld/index.ts +0 -2
- package/src/tailwind-theme.css +0 -39
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import {Slot} from '@radix-ui/react-slot'
|
|
4
|
+
import {cva, type VariantProps} from 'class-variance-authority'
|
|
5
|
+
|
|
6
|
+
import {cn} from '../../lib/utils'
|
|
7
|
+
|
|
8
|
+
const buttonVariants = cva(
|
|
9
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default:
|
|
14
|
+
'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
|
|
15
|
+
destructive:
|
|
16
|
+
'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
17
|
+
outline:
|
|
18
|
+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
|
|
19
|
+
secondary:
|
|
20
|
+
'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
|
|
21
|
+
ghost:
|
|
22
|
+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
|
23
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
24
|
+
},
|
|
25
|
+
size: {
|
|
26
|
+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
|
27
|
+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
|
|
28
|
+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
|
29
|
+
icon: 'size-9',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: 'default',
|
|
34
|
+
size: 'default',
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
function Button({
|
|
40
|
+
className,
|
|
41
|
+
variant,
|
|
42
|
+
size,
|
|
43
|
+
asChild = false,
|
|
44
|
+
...props
|
|
45
|
+
}: React.ComponentProps<'button'> &
|
|
46
|
+
VariantProps<typeof buttonVariants> & {
|
|
47
|
+
asChild?: boolean
|
|
48
|
+
}) {
|
|
49
|
+
const Comp = asChild ? Slot : 'button'
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Comp
|
|
53
|
+
data-slot="button"
|
|
54
|
+
className={cn(buttonVariants({variant, size, className}))}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {Button, buttonVariants}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import {cn} from '../../lib/utils'
|
|
4
|
+
|
|
5
|
+
function Card({className, ...props}: React.ComponentProps<'div'>) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="card"
|
|
9
|
+
className={cn(
|
|
10
|
+
'bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm',
|
|
11
|
+
className
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function CardHeader({className, ...props}: React.ComponentProps<'div'>) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="card-header"
|
|
22
|
+
className={cn(
|
|
23
|
+
'@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6',
|
|
24
|
+
className
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function CardTitle({className, ...props}: React.ComponentProps<'div'>) {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
data-slot="card-title"
|
|
35
|
+
className={cn('leading-none font-semibold', className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function CardDescription({className, ...props}: React.ComponentProps<'div'>) {
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
data-slot="card-description"
|
|
45
|
+
className={cn('text-muted-foreground text-sm', className)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function CardAction({className, ...props}: React.ComponentProps<'div'>) {
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
data-slot="card-action"
|
|
55
|
+
className={cn(
|
|
56
|
+
'col-start-2 row-span-2 row-start-1 self-start justify-self-end',
|
|
57
|
+
className
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function CardContent({className, ...props}: React.ComponentProps<'div'>) {
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
data-slot="card-content"
|
|
68
|
+
className={cn('px-6', className)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function CardFooter({className, ...props}: React.ComponentProps<'div'>) {
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
data-slot="card-footer"
|
|
78
|
+
className={cn('flex items-center px-6 [.border-t]:pt-6', className)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
Card,
|
|
86
|
+
CardHeader,
|
|
87
|
+
CardFooter,
|
|
88
|
+
CardTitle,
|
|
89
|
+
CardAction,
|
|
90
|
+
CardDescription,
|
|
91
|
+
CardContent,
|
|
92
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {useTheme} from 'next-themes'
|
|
2
|
+
import {Toaster as Sonner, ToasterProps} from 'sonner'
|
|
3
|
+
|
|
4
|
+
const Toaster = ({...props}: ToasterProps) => {
|
|
5
|
+
const {theme = 'system'} = useTheme()
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<Sonner
|
|
9
|
+
theme={theme as ToasterProps['theme']}
|
|
10
|
+
className="toaster group"
|
|
11
|
+
style={
|
|
12
|
+
{
|
|
13
|
+
'--normal-bg': 'var(--popover)',
|
|
14
|
+
'--normal-text': 'var(--popover-foreground)',
|
|
15
|
+
'--normal-border': 'var(--border)',
|
|
16
|
+
} as React.CSSProperties
|
|
17
|
+
}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {Toaster}
|
package/src/dev.tsx
CHANGED
|
@@ -1,57 +1,135 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, {useState} from 'react'
|
|
2
2
|
|
|
3
3
|
import ReactDOM from 'react-dom/client'
|
|
4
|
+
import {toast} from 'sonner'
|
|
4
5
|
|
|
5
|
-
import {HelloWorld} from './components'
|
|
6
6
|
import './index.css'
|
|
7
|
+
import {
|
|
8
|
+
AlertDialog,
|
|
9
|
+
AlertDialogAction,
|
|
10
|
+
AlertDialogCancel,
|
|
11
|
+
AlertDialogContent,
|
|
12
|
+
AlertDialogDescription,
|
|
13
|
+
AlertDialogFooter,
|
|
14
|
+
AlertDialogHeader,
|
|
15
|
+
AlertDialogTitle,
|
|
16
|
+
AlertDialogTrigger,
|
|
17
|
+
} from './components/ui/alert-dialog'
|
|
18
|
+
import {Button} from './components/ui/button'
|
|
19
|
+
import {
|
|
20
|
+
Card,
|
|
21
|
+
CardHeader,
|
|
22
|
+
CardTitle,
|
|
23
|
+
CardDescription,
|
|
24
|
+
CardContent,
|
|
25
|
+
CardAction,
|
|
26
|
+
CardFooter,
|
|
27
|
+
} from './components/ui/card'
|
|
28
|
+
import {Toaster} from './components/ui/sonner'
|
|
7
29
|
|
|
8
30
|
function App() {
|
|
31
|
+
const [alertOpen, setAlertOpen] = useState(false)
|
|
32
|
+
|
|
9
33
|
return (
|
|
10
34
|
<div className="min-h-screen bg-gray-50 flex items-center justify-center p-8">
|
|
11
|
-
<div className="space-y-8">
|
|
35
|
+
<div className="space-y-8 w-full max-w-4xl">
|
|
12
36
|
<div className="text-center">
|
|
13
37
|
<h1 className="text-3xl font-bold text-gray-900 mb-8">
|
|
14
38
|
Shop Minis React Components
|
|
15
39
|
</h1>
|
|
16
40
|
</div>
|
|
17
41
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<p className="text-sm text-gray-600 mb-2">With custom name:</p>
|
|
31
|
-
<HelloWorld name="Shop Minis" />
|
|
32
|
-
</>
|
|
33
|
-
|
|
34
|
-
<>
|
|
35
|
-
<p className="text-sm text-gray-600 mb-2">Different sizes:</p>
|
|
36
|
-
<div className="space-x-4">
|
|
37
|
-
<HelloWorld name="Small" size="sm" />
|
|
38
|
-
<HelloWorld name="Medium" size="md" />
|
|
39
|
-
<HelloWorld name="Large" size="lg" />
|
|
40
|
-
</div>
|
|
41
|
-
</>
|
|
42
|
-
|
|
43
|
-
<>
|
|
44
|
-
<p className="text-sm text-gray-600 mb-2">With custom content:</p>
|
|
45
|
-
<HelloWorld>
|
|
46
|
-
<span role="img" aria-label="Party Popper">
|
|
47
|
-
🎉
|
|
48
|
-
</span>{' '}
|
|
49
|
-
Custom Content!
|
|
50
|
-
</HelloWorld>
|
|
51
|
-
</>
|
|
42
|
+
{/* Button Examples */}
|
|
43
|
+
<section className="space-y-4">
|
|
44
|
+
<h2 className="text-2xl font-semibold">Button</h2>
|
|
45
|
+
<div className="flex flex-wrap gap-4">
|
|
46
|
+
<Button>Default Button</Button>
|
|
47
|
+
<Button variant="destructive">Destructive</Button>
|
|
48
|
+
<Button variant="outline">Outline</Button>
|
|
49
|
+
<Button variant="secondary">Secondary</Button>
|
|
50
|
+
<Button variant="ghost">Ghost</Button>
|
|
51
|
+
<Button variant="link">Link</Button>
|
|
52
|
+
<Button size="sm">Small</Button>
|
|
53
|
+
<Button size="lg">Large</Button>
|
|
52
54
|
</div>
|
|
53
|
-
</
|
|
55
|
+
</section>
|
|
56
|
+
|
|
57
|
+
{/* Card Example */}
|
|
58
|
+
<section className="space-y-4">
|
|
59
|
+
<h2 className="text-2xl font-semibold">Card</h2>
|
|
60
|
+
<Card className="w-full max-w-md">
|
|
61
|
+
<CardHeader>
|
|
62
|
+
<CardTitle>Card Title</CardTitle>
|
|
63
|
+
<CardDescription>
|
|
64
|
+
This is a card description that explains what the card contains.
|
|
65
|
+
</CardDescription>
|
|
66
|
+
<CardAction>
|
|
67
|
+
<Button size="sm" variant="outline">
|
|
68
|
+
Action
|
|
69
|
+
</Button>
|
|
70
|
+
</CardAction>
|
|
71
|
+
</CardHeader>
|
|
72
|
+
<CardContent>
|
|
73
|
+
<p>
|
|
74
|
+
This is the main content of the card. You can put any content
|
|
75
|
+
here.
|
|
76
|
+
</p>
|
|
77
|
+
</CardContent>
|
|
78
|
+
<CardFooter>
|
|
79
|
+
<Button className="w-full">Footer Button</Button>
|
|
80
|
+
</CardFooter>
|
|
81
|
+
</Card>
|
|
82
|
+
</section>
|
|
83
|
+
|
|
84
|
+
{/* AlertDialog Example */}
|
|
85
|
+
<section className="space-y-4">
|
|
86
|
+
<h2 className="text-2xl font-semibold">Alert Dialog</h2>
|
|
87
|
+
<AlertDialog open={alertOpen} onOpenChange={setAlertOpen}>
|
|
88
|
+
<AlertDialogTrigger asChild>
|
|
89
|
+
<Button variant="outline">Show Alert Dialog</Button>
|
|
90
|
+
</AlertDialogTrigger>
|
|
91
|
+
<AlertDialogContent>
|
|
92
|
+
<AlertDialogHeader>
|
|
93
|
+
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
|
94
|
+
<AlertDialogDescription>
|
|
95
|
+
This action cannot be undone. This will permanently delete
|
|
96
|
+
your account and remove your data from our servers.
|
|
97
|
+
</AlertDialogDescription>
|
|
98
|
+
</AlertDialogHeader>
|
|
99
|
+
<AlertDialogFooter>
|
|
100
|
+
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
101
|
+
<AlertDialogAction
|
|
102
|
+
onClick={() => toast.success('Action confirmed!')}
|
|
103
|
+
>
|
|
104
|
+
Continue
|
|
105
|
+
</AlertDialogAction>
|
|
106
|
+
</AlertDialogFooter>
|
|
107
|
+
</AlertDialogContent>
|
|
108
|
+
</AlertDialog>
|
|
109
|
+
</section>
|
|
110
|
+
|
|
111
|
+
{/* Toaster Example */}
|
|
112
|
+
<section className="space-y-4">
|
|
113
|
+
<h2 className="text-2xl font-semibold">Toaster (Sonner)</h2>
|
|
114
|
+
<div className="flex gap-4">
|
|
115
|
+
<Button onClick={() => toast.success('Success toast!')}>
|
|
116
|
+
Success Toast
|
|
117
|
+
</Button>
|
|
118
|
+
<Button onClick={() => toast.error('Error toast!')}>
|
|
119
|
+
Error Toast
|
|
120
|
+
</Button>
|
|
121
|
+
<Button onClick={() => toast('Default toast!')}>
|
|
122
|
+
Default Toast
|
|
123
|
+
</Button>
|
|
124
|
+
<Button onClick={() => toast.info('Info toast!')}>
|
|
125
|
+
Info Toast
|
|
126
|
+
</Button>
|
|
127
|
+
</div>
|
|
128
|
+
</section>
|
|
54
129
|
</div>
|
|
130
|
+
|
|
131
|
+
{/* Toaster component for displaying notifications */}
|
|
132
|
+
<Toaster />
|
|
55
133
|
</div>
|
|
56
134
|
)
|
|
57
135
|
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// - User Hooks
|
|
2
|
+
export * from './user/useSavedProductsActions'
|
|
3
|
+
export * from './user/useFollowedShopsActions'
|
|
4
|
+
export * from './user/useCurrentUser'
|
|
5
|
+
export * from './user/useOrders'
|
|
6
|
+
export * from './user/useBuyerAttributes'
|
|
4
7
|
|
|
5
|
-
//
|
|
6
|
-
export
|
|
8
|
+
// - Product Hooks
|
|
9
|
+
export * from './product/useProductListActions'
|
|
10
|
+
export * from './product/useProductLists'
|
|
11
|
+
export * from './product/useProductList'
|
|
12
|
+
export * from './product/useRecommendedProducts'
|
|
13
|
+
export * from './product/usePopularProducts'
|
|
14
|
+
|
|
15
|
+
// - Storage Hooks
|
|
16
|
+
export * from './storage/useAsyncStorage'
|
|
17
|
+
export * from './storage/useSecureStorage'
|
|
18
|
+
export * from './storage/useImageUpload'
|
|
19
|
+
|
|
20
|
+
// - Navigation Hooks
|
|
21
|
+
export * from './navigation/useShopNavigation'
|
|
22
|
+
export * from './navigation/useCloseMini'
|
|
23
|
+
|
|
24
|
+
// - Shop Hooks
|
|
25
|
+
export * from './shop/useShopCartActions'
|
|
26
|
+
export * from './shop/useRecommendedShops'
|
|
27
|
+
|
|
28
|
+
// - Content Hooks
|
|
29
|
+
|
|
30
|
+
// - Utility Hooks
|
|
31
|
+
export * from './util/useErrorToast'
|
|
32
|
+
export * from './util/useErrorScreen'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
|
|
2
|
+
|
|
3
|
+
const data: ReferenceEntityTemplateSchema = {
|
|
4
|
+
name: 'useCloseMini',
|
|
5
|
+
category: 'hooks',
|
|
6
|
+
subCategory: 'navigation',
|
|
7
|
+
isVisualComponent: false,
|
|
8
|
+
related: [],
|
|
9
|
+
description:
|
|
10
|
+
'The `useCloseMini` hook returns a function to close the Mini viewer.',
|
|
11
|
+
type: 'hook',
|
|
12
|
+
defaultExample: {
|
|
13
|
+
codeblock: {
|
|
14
|
+
tabs: [
|
|
15
|
+
{
|
|
16
|
+
code: './useCloseMini.example.tsx',
|
|
17
|
+
language: 'tsx',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
title: 'Example code',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
definitions: [
|
|
24
|
+
{
|
|
25
|
+
title: '',
|
|
26
|
+
type: 'UseCloseMiniGeneratedType',
|
|
27
|
+
description: '',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default data
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {useHandleAction} from '../../internal/useHandleAction'
|
|
2
|
+
import {useShopActions} from '../../internal/useShopActions'
|
|
3
|
+
|
|
4
|
+
interface UseCloseMiniReturns {
|
|
5
|
+
/**
|
|
6
|
+
* Closes the Mini viewer.
|
|
7
|
+
*/
|
|
8
|
+
closeMini: () => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const useCloseMini = (): UseCloseMiniReturns => {
|
|
12
|
+
const {closeMini} = useShopActions()
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
closeMini: useHandleAction(closeMini),
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
|
|
2
|
+
|
|
3
|
+
const data: ReferenceEntityTemplateSchema = {
|
|
4
|
+
name: 'useShopNavigation',
|
|
5
|
+
category: 'hooks',
|
|
6
|
+
subCategory: 'navigation',
|
|
7
|
+
isVisualComponent: false,
|
|
8
|
+
related: [],
|
|
9
|
+
description:
|
|
10
|
+
'The `useShopNavigation` hook provides functions to navigate to different parts of the Shop app.',
|
|
11
|
+
type: 'hook',
|
|
12
|
+
defaultExample: {
|
|
13
|
+
codeblock: {
|
|
14
|
+
tabs: [
|
|
15
|
+
{
|
|
16
|
+
code: './useShopNavigation.example.tsx',
|
|
17
|
+
language: 'tsx',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
title: 'Example code',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
definitions: [
|
|
24
|
+
{
|
|
25
|
+
title: '',
|
|
26
|
+
type: 'UseShopNavigationGeneratedType',
|
|
27
|
+
description: '',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default data
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {useShopNavigation, Button} from '@shopify/shop-minis-react'
|
|
2
|
+
|
|
3
|
+
export default function MyComponent() {
|
|
4
|
+
const {navigateToProduct, navigateToShop, navigateToOrder} =
|
|
5
|
+
useShopNavigation()
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<>
|
|
9
|
+
<Button
|
|
10
|
+
onPress={() =>
|
|
11
|
+
navigateToProduct({productId: 'gid://shopify/Product/123'})
|
|
12
|
+
}
|
|
13
|
+
text="View Product"
|
|
14
|
+
/>
|
|
15
|
+
<Button
|
|
16
|
+
onPress={() =>
|
|
17
|
+
navigateToShop({
|
|
18
|
+
shopId: 'gid://shopify/Shop/123',
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
text="Go to Shop"
|
|
22
|
+
/>
|
|
23
|
+
<Button
|
|
24
|
+
onPress={() => navigateToOrder({orderId: 'gid://shopify/Order/123'})}
|
|
25
|
+
text="View Order"
|
|
26
|
+
/>
|
|
27
|
+
</>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {useHandleAction} from '../../internal/useHandleAction'
|
|
2
|
+
import {useShopActions} from '../../internal/useShopActions'
|
|
3
|
+
import {
|
|
4
|
+
NavigateToCheckoutParams,
|
|
5
|
+
NavigateToOrderParams,
|
|
6
|
+
NavigateToProductParams,
|
|
7
|
+
NavigateToShopParams,
|
|
8
|
+
} from '../../types'
|
|
9
|
+
|
|
10
|
+
interface UseShopNavigationReturns {
|
|
11
|
+
/**
|
|
12
|
+
* Navigates to a product.
|
|
13
|
+
*/
|
|
14
|
+
navigateToProduct: (params: NavigateToProductParams) => Promise<void>
|
|
15
|
+
/**
|
|
16
|
+
* Navigates to a shop.
|
|
17
|
+
*/
|
|
18
|
+
navigateToShop: (params: NavigateToShopParams) => Promise<void>
|
|
19
|
+
/**
|
|
20
|
+
* Navigates to an order.
|
|
21
|
+
*/
|
|
22
|
+
navigateToOrder: (params: NavigateToOrderParams) => Promise<void>
|
|
23
|
+
|
|
24
|
+
navigateToCheckout: (params: NavigateToCheckoutParams) => Promise<void>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const useShopNavigation = (): UseShopNavigationReturns => {
|
|
28
|
+
const {
|
|
29
|
+
navigateToProduct,
|
|
30
|
+
navigateToShop,
|
|
31
|
+
navigateToOrder,
|
|
32
|
+
navigateToCheckout,
|
|
33
|
+
} = useShopActions()
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
navigateToProduct: useHandleAction(navigateToProduct),
|
|
37
|
+
navigateToShop: useHandleAction(navigateToShop),
|
|
38
|
+
navigateToOrder: useHandleAction(navigateToOrder),
|
|
39
|
+
navigateToCheckout: useHandleAction(navigateToCheckout),
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {useShopActions} from '../../internal/useShopActions'
|
|
2
|
+
import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
|
|
3
|
+
import {
|
|
4
|
+
Product,
|
|
5
|
+
PaginatedDataHookOptionsBase,
|
|
6
|
+
PaginatedDataHookReturnsBase,
|
|
7
|
+
} from '../../types'
|
|
8
|
+
|
|
9
|
+
interface UsePopularProductsParams extends PaginatedDataHookOptionsBase {}
|
|
10
|
+
|
|
11
|
+
interface UsePopularProductsReturns extends PaginatedDataHookReturnsBase {
|
|
12
|
+
products: Product[] | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param options - The options for the query
|
|
17
|
+
*/
|
|
18
|
+
export const usePopularProducts = (
|
|
19
|
+
params?: UsePopularProductsParams
|
|
20
|
+
): UsePopularProductsReturns => {
|
|
21
|
+
const {getPopularProducts} = useShopActions()
|
|
22
|
+
const {skip, ...shopActionParams} = params ?? {}
|
|
23
|
+
|
|
24
|
+
const {data, ...rest} = useShopActionsPaginatedDataFetching(
|
|
25
|
+
getPopularProducts,
|
|
26
|
+
shopActionParams,
|
|
27
|
+
{
|
|
28
|
+
skip,
|
|
29
|
+
hook: 'usePopularProducts',
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
...rest,
|
|
35
|
+
products: data,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
|
|
2
|
+
|
|
3
|
+
const data: ReferenceEntityTemplateSchema = {
|
|
4
|
+
name: 'useProductList',
|
|
5
|
+
category: 'hooks',
|
|
6
|
+
subCategory: 'product',
|
|
7
|
+
isVisualComponent: false,
|
|
8
|
+
related: [],
|
|
9
|
+
description:
|
|
10
|
+
'The `useProductList` hook enables fetching a list of products saved by the user.',
|
|
11
|
+
type: 'hook',
|
|
12
|
+
defaultExample: {
|
|
13
|
+
codeblock: {
|
|
14
|
+
tabs: [
|
|
15
|
+
{
|
|
16
|
+
code: './useProductList.example.tsx',
|
|
17
|
+
language: 'tsx',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
title: 'Example code',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
definitions: [
|
|
24
|
+
{
|
|
25
|
+
title: '',
|
|
26
|
+
type: 'UseProductListGeneratedType',
|
|
27
|
+
description: '',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default data
|