@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.
Files changed (241) hide show
  1. package/README.md +110 -90
  2. package/dist/_virtual/_commonjsHelpers.js +9 -0
  3. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  4. package/dist/_virtual/index.js +8 -0
  5. package/dist/_virtual/index.js.map +1 -0
  6. package/dist/_virtual/index2.js +5 -0
  7. package/dist/_virtual/index2.js.map +1 -0
  8. package/dist/components/ui/alert-dialog.js +141 -0
  9. package/dist/components/ui/alert-dialog.js.map +1 -0
  10. package/dist/components/ui/button.js +50 -0
  11. package/dist/components/ui/button.js.map +1 -0
  12. package/dist/components/ui/card.js +91 -0
  13. package/dist/components/ui/card.js.map +1 -0
  14. package/dist/components/ui/sonner.js +23 -0
  15. package/dist/components/ui/sonner.js.map +1 -0
  16. package/dist/hooks/navigation/useCloseMini.js +12 -0
  17. package/dist/hooks/navigation/useCloseMini.js.map +1 -0
  18. package/dist/hooks/navigation/useShopNavigation.js +20 -0
  19. package/dist/hooks/navigation/useShopNavigation.js.map +1 -0
  20. package/dist/hooks/product/usePopularProducts.js +20 -0
  21. package/dist/hooks/product/usePopularProducts.js.map +1 -0
  22. package/dist/hooks/product/useProductList.js +29 -0
  23. package/dist/hooks/product/useProductList.js.map +1 -0
  24. package/dist/hooks/product/useProductListActions.js +22 -0
  25. package/dist/hooks/product/useProductListActions.js.map +1 -0
  26. package/dist/hooks/product/useProductLists.js +20 -0
  27. package/dist/hooks/product/useProductLists.js.map +1 -0
  28. package/dist/hooks/product/useRecommendedProducts.js +20 -0
  29. package/dist/hooks/product/useRecommendedProducts.js.map +1 -0
  30. package/dist/hooks/shop/useRecommendedShops.js +21 -0
  31. package/dist/hooks/shop/useRecommendedShops.js.map +1 -0
  32. package/dist/hooks/shop/useShopCartActions.js +13 -0
  33. package/dist/hooks/shop/useShopCartActions.js.map +1 -0
  34. package/dist/hooks/storage/useAsyncStorage.js +22 -0
  35. package/dist/hooks/storage/useAsyncStorage.js.map +1 -0
  36. package/dist/hooks/storage/useImageUpload.js +62 -0
  37. package/dist/hooks/storage/useImageUpload.js.map +1 -0
  38. package/dist/hooks/storage/useSecureStorage.js +14 -0
  39. package/dist/hooks/storage/useSecureStorage.js.map +1 -0
  40. package/dist/hooks/user/useBuyerAttributes.js +20 -0
  41. package/dist/hooks/user/useBuyerAttributes.js.map +1 -0
  42. package/dist/hooks/user/useCurrentUser.js +20 -0
  43. package/dist/hooks/user/useCurrentUser.js.map +1 -0
  44. package/dist/hooks/user/useFollowedShopsActions.js +13 -0
  45. package/dist/hooks/user/useFollowedShopsActions.js.map +1 -0
  46. package/dist/hooks/user/useOrders.js +20 -0
  47. package/dist/hooks/user/useOrders.js.map +1 -0
  48. package/dist/hooks/user/useSavedProductsActions.js +13 -0
  49. package/dist/hooks/user/useSavedProductsActions.js.map +1 -0
  50. package/dist/hooks/util/useErrorScreen.js +9 -0
  51. package/dist/hooks/util/useErrorScreen.js.map +1 -0
  52. package/dist/hooks/util/useErrorToast.js +9 -0
  53. package/dist/hooks/util/useErrorToast.js.map +1 -0
  54. package/dist/index.js +78 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/internal/useHandleAction.js +13 -0
  57. package/dist/internal/useHandleAction.js.map +1 -0
  58. package/dist/internal/useShopActions.js +7 -0
  59. package/dist/internal/useShopActions.js.map +1 -0
  60. package/dist/internal/useShopActionsDataFetching.js +79 -0
  61. package/dist/internal/useShopActionsDataFetching.js.map +1 -0
  62. package/dist/internal/useShopActionsPaginatedDataFetching.js +96 -0
  63. package/dist/internal/useShopActionsPaginatedDataFetching.js.map +1 -0
  64. package/dist/lib/utils.js +9 -0
  65. package/dist/lib/utils.js.map +1 -0
  66. package/dist/node_modules/.pnpm/@radix-ui_primitive@1.1.2/node_modules/@radix-ui/primitive/dist/index.js +10 -0
  67. package/dist/node_modules/.pnpm/@radix-ui_primitive@1.1.2/node_modules/@radix-ui/primitive/dist/index.js.map +1 -0
  68. 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
  69. 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
  70. 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
  71. 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
  72. 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
  73. 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
  74. 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
  75. 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
  76. 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
  77. 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
  78. 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
  79. 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
  80. 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
  81. 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
  82. 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
  83. 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
  84. 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
  85. 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
  86. 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
  87. 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
  88. 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
  89. 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
  90. 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
  91. 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
  92. 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
  93. 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
  94. 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
  95. 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
  96. 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
  97. 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
  98. 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
  99. 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
  100. package/dist/node_modules/.pnpm/aria-hidden@1.2.6/node_modules/aria-hidden/dist/es2015/index.js +53 -0
  101. package/dist/node_modules/.pnpm/aria-hidden@1.2.6/node_modules/aria-hidden/dist/es2015/index.js.map +1 -0
  102. package/dist/node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js +36 -0
  103. package/dist/node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js.map +1 -0
  104. package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js +18 -0
  105. package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js.map +1 -0
  106. package/dist/node_modules/.pnpm/get-nonce@1.0.1/node_modules/get-nonce/dist/es2015/index.js +8 -0
  107. package/dist/node_modules/.pnpm/get-nonce@1.0.1/node_modules/get-nonce/dist/es2015/index.js.map +1 -0
  108. 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
  109. 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
  110. package/dist/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +44 -0
  111. package/dist/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js.map +1 -0
  112. 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
  113. 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
  114. 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
  115. 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
  116. 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
  117. 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
  118. 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
  119. 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
  120. 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
  121. 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
  122. 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
  123. 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
  124. 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
  125. 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
  126. 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
  127. 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
  128. 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
  129. 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
  130. 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
  131. 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
  132. 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
  133. 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
  134. 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
  135. 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
  136. 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
  137. 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
  138. package/dist/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js +25 -0
  139. package/dist/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js.map +1 -0
  140. 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
  141. 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
  142. package/dist/node_modules/.pnpm/tailwind-merge@2.6.0/node_modules/tailwind-merge/dist/bundle-mjs.js +2265 -0
  143. package/dist/node_modules/.pnpm/tailwind-merge@2.6.0/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -0
  144. package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.js +28 -0
  145. package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.js.map +1 -0
  146. package/dist/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js +133 -0
  147. package/dist/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js.map +1 -0
  148. 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
  149. 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
  150. 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
  151. 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
  152. 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
  153. 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
  154. 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
  155. 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
  156. 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
  157. 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
  158. package/dist/types/minisSDK.generated.d.js +18 -0
  159. package/dist/types/minisSDK.generated.d.js.map +1 -0
  160. package/dist/utils/errors.js +39 -0
  161. package/dist/utils/errors.js.map +1 -0
  162. package/dist/utils/parseUrl.js +8 -0
  163. package/dist/utils/parseUrl.js.map +1 -0
  164. package/package.json +29 -14
  165. package/src/components/index.ts +4 -7
  166. package/src/components/ui/alert-dialog.tsx +151 -0
  167. package/src/components/ui/button.tsx +60 -0
  168. package/src/components/ui/card.tsx +92 -0
  169. package/src/components/ui/sonner.tsx +23 -0
  170. package/src/dev.tsx +116 -38
  171. package/src/hooks/index.ts +31 -5
  172. package/src/hooks/navigation/useCloseMini.doc.ts +32 -0
  173. package/src/hooks/navigation/useCloseMini.example.tsx +7 -0
  174. package/src/hooks/navigation/useCloseMini.ts +17 -0
  175. package/src/hooks/navigation/useShopNavigation.doc.ts +32 -0
  176. package/src/hooks/navigation/useShopNavigation.example.tsx +29 -0
  177. package/src/hooks/navigation/useShopNavigation.ts +41 -0
  178. package/src/hooks/product/usePopularProducts.ts +37 -0
  179. package/src/hooks/product/useProductList.doc.ts +32 -0
  180. package/src/hooks/product/useProductList.example.tsx +9 -0
  181. package/src/hooks/product/useProductList.ts +56 -0
  182. package/src/hooks/product/useProductListActions.doc.ts +32 -0
  183. package/src/hooks/product/useProductListActions.example.tsx +57 -0
  184. package/src/hooks/product/useProductListActions.ts +51 -0
  185. package/src/hooks/product/useProductLists.doc.ts +32 -0
  186. package/src/hooks/product/useProductLists.example.tsx +9 -0
  187. package/src/hooks/product/useProductLists.ts +39 -0
  188. package/src/hooks/product/useRecommendedProducts.doc.ts +32 -0
  189. package/src/hooks/product/useRecommendedProducts.example.tsx +7 -0
  190. package/src/hooks/product/useRecommendedProducts.ts +37 -0
  191. package/src/hooks/shop/useRecommendedShops.doc.ts +32 -0
  192. package/src/hooks/shop/useRecommendedShops.example.tsx +7 -0
  193. package/src/hooks/shop/useRecommendedShops.ts +43 -0
  194. package/src/hooks/shop/useShopCartActions.doc.ts +32 -0
  195. package/src/hooks/shop/useShopCartActions.example.tsx +28 -0
  196. package/src/hooks/shop/useShopCartActions.ts +23 -0
  197. package/src/hooks/storage/useAsyncStorage.doc.ts +32 -0
  198. package/src/hooks/storage/useAsyncStorage.example.tsx +30 -0
  199. package/src/hooks/storage/useAsyncStorage.ts +48 -0
  200. package/src/hooks/storage/useImageUpload.doc.ts +32 -0
  201. package/src/hooks/storage/useImageUpload.example.tsx +20 -0
  202. package/src/hooks/storage/useImageUpload.ts +135 -0
  203. package/src/hooks/storage/useSecureStorage.doc.ts +32 -0
  204. package/src/hooks/storage/useSecureStorage.example.tsx +23 -0
  205. package/src/hooks/storage/useSecureStorage.ts +28 -0
  206. package/src/hooks/user/useBuyerAttributes.doc.ts +32 -0
  207. package/src/hooks/user/useBuyerAttributes.example.tsx +14 -0
  208. package/src/hooks/user/useBuyerAttributes.ts +34 -0
  209. package/src/hooks/user/useCurrentUser.doc.ts +31 -0
  210. package/src/hooks/user/useCurrentUser.example.tsx +7 -0
  211. package/src/hooks/user/useCurrentUser.ts +37 -0
  212. package/src/hooks/user/useFollowedShopsActions.doc.ts +32 -0
  213. package/src/hooks/user/useFollowedShopsActions.example.tsx +18 -0
  214. package/src/hooks/user/useFollowedShopsActions.ts +23 -0
  215. package/src/hooks/user/useOrders.doc.ts +32 -0
  216. package/src/hooks/user/useOrders.example.tsx +7 -0
  217. package/src/hooks/user/useOrders.ts +32 -0
  218. package/src/hooks/user/useSavedProductsActions.doc.ts +32 -0
  219. package/src/hooks/user/useSavedProductsActions.example.tsx +30 -0
  220. package/src/hooks/user/useSavedProductsActions.ts +23 -0
  221. package/src/hooks/util/useErrorScreen.doc.ts +32 -0
  222. package/src/hooks/util/useErrorScreen.example.tsx +16 -0
  223. package/src/hooks/util/useErrorScreen.ts +15 -0
  224. package/src/hooks/util/useErrorToast.doc.ts +32 -0
  225. package/src/hooks/util/useErrorToast.example.tsx +15 -0
  226. package/src/hooks/util/useErrorToast.ts +15 -0
  227. package/src/index.css +120 -2
  228. package/src/internal/useHandleAction.ts +24 -0
  229. package/src/internal/useShopActions.ts +5 -0
  230. package/src/internal/useShopActionsDataFetching.ts +153 -0
  231. package/src/internal/useShopActionsPaginatedDataFetching.ts +193 -0
  232. package/src/lib/utils.ts +9 -0
  233. package/src/types/index.ts +2 -0
  234. package/src/types/minisSDK.generated.d.ts +2 -74
  235. package/src/utils/errors.ts +86 -0
  236. package/src/utils/index.ts +2 -11
  237. package/src/utils/parseUrl.ts +5 -0
  238. package/tailwind.config.js +3 -0
  239. package/src/components/HelloWorld/HelloWorld.tsx +0 -43
  240. package/src/components/HelloWorld/index.ts +0 -2
  241. package/src/tailwind-theme.css +0 -39
@@ -0,0 +1,20 @@
1
+ import {useCallback} from 'react'
2
+
3
+ import {useImageUpload, Button} from '@shopify/shop-minis-react'
4
+
5
+ export default function MyComponent() {
6
+ const {uploadImage} = useImageUpload()
7
+
8
+ const handleUpload = useCallback(async () => {
9
+ const result = await uploadImage([
10
+ {
11
+ mimeType: 'image/jpeg',
12
+ fileSize: 1024 * 1024, // 1MB
13
+ uri: 'file://path/to/image.jpg',
14
+ },
15
+ ])
16
+ console.log('Uploaded image:', result[0])
17
+ }, [uploadImage])
18
+
19
+ return <Button onPress={handleUpload} text="Upload image" />
20
+ }
@@ -0,0 +1,135 @@
1
+ import {useCallback} from 'react'
2
+
3
+ import {useShopActions} from '../../internal/useShopActions'
4
+ import {UploadTarget} from '../../types'
5
+
6
+ export interface UploadImageParams {
7
+ /**
8
+ * The MIME type of the image.
9
+ */
10
+ mimeType: string
11
+ /**
12
+ * The size of the image in bytes.
13
+ */
14
+ fileSize: number
15
+ /**
16
+ * The URI of the image to upload.
17
+ */
18
+ uri: string
19
+ }
20
+
21
+ export interface UploadedImage {
22
+ /**
23
+ * The ID of the uploaded image.
24
+ */
25
+ id: string
26
+ /**
27
+ * The URL of the uploaded image.
28
+ */
29
+ imageUrl?: string
30
+ /**
31
+ * The resource URL of the uploaded image.
32
+ */
33
+ resourceUrl?: string
34
+ }
35
+
36
+ interface UseImageUploadReturns {
37
+ /**
38
+ * Upload an image attached to the current user.
39
+ */
40
+ uploadImage: (params: UploadImageParams[]) => Promise<UploadedImage[]>
41
+ }
42
+
43
+ const uploadFileToGCS = async (
44
+ image: UploadImageParams,
45
+ target: UploadTarget
46
+ ) => {
47
+ const formData = new FormData()
48
+ target.parameters.forEach(({name, value}) => {
49
+ formData.append(name, value)
50
+ })
51
+ // Append the actual file data last
52
+ formData.append('file', new Blob([image.uri], {type: image.mimeType}))
53
+
54
+ const uploadResponse = await fetch(target.url, {
55
+ method: 'POST',
56
+ body: formData,
57
+ })
58
+
59
+ if (!uploadResponse.ok) {
60
+ console.error('Failed to upload image', {
61
+ response: await uploadResponse.text(),
62
+ })
63
+ return {error: 'Failed to upload image'}
64
+ }
65
+
66
+ return {}
67
+ }
68
+
69
+ export const useImageUpload = (): UseImageUploadReturns => {
70
+ const {createImageUploadLink, completeImageUpload} = useShopActions()
71
+
72
+ const uploadImage = useCallback(
73
+ async (params: UploadImageParams[]) => {
74
+ if (params.length > 1) {
75
+ throw new Error('Multiple image upload is not supported yet')
76
+ }
77
+
78
+ const links = await createImageUploadLink({
79
+ input: params.map(image => ({
80
+ mimeType: image.mimeType,
81
+ fileSize: image.fileSize,
82
+ })),
83
+ })
84
+
85
+ if (!links.ok) {
86
+ throw new Error(links.error.message)
87
+ }
88
+
89
+ // Upload single file to GCS
90
+ // TODO: Upload multiple files to GCS
91
+ const {error: uploadError} = await uploadFileToGCS(
92
+ params[0],
93
+ links?.data?.targets?.[0]!
94
+ )
95
+
96
+ if (uploadError) {
97
+ throw new Error(uploadError)
98
+ }
99
+
100
+ // 10 second polling for image upload
101
+ let count = 0
102
+ while (count < 30) {
103
+ const result = await completeImageUpload({
104
+ resourceUrls:
105
+ links?.data?.targets?.map(target => target.resourceUrl) || [],
106
+ })
107
+
108
+ if (!result.ok) {
109
+ throw new Error(result.error.message)
110
+ }
111
+
112
+ // TODO: Add support for multiple files
113
+ if (result.data?.files?.[0]?.fileStatus === 'READY') {
114
+ return [
115
+ {
116
+ id: result.data.files[0].id,
117
+ imageUrl: result.data.files[0].image?.url,
118
+ resourceUrl: links?.data?.targets?.[0]?.resourceUrl,
119
+ },
120
+ ]
121
+ }
122
+
123
+ await new Promise(resolve => setTimeout(resolve, 1000))
124
+ count++
125
+ }
126
+
127
+ throw new Error('Image upload completion timed out')
128
+ },
129
+ [createImageUploadLink, completeImageUpload]
130
+ )
131
+
132
+ return {
133
+ uploadImage,
134
+ }
135
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useSecureStorage',
5
+ category: 'hooks',
6
+ subCategory: 'storage',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useSecureStorage` hook provides functions to interact with secure storage. It allows you to store, retrieve, and manage sensitive data that requires encryption and secure handling. You can currently only set one secret per Mini.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useSecureStorage.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseSecureStorageGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,23 @@
1
+ import {useEffect} from 'react'
2
+
3
+ import {useSecureStorage} from '@shopify/shop-minis-react'
4
+
5
+ export default function MyComponent() {
6
+ const {getSecret, setSecret, removeSecret} = useSecureStorage()
7
+
8
+ useEffect(() => {
9
+ async function handleSecureStorageOperations() {
10
+ // Get a secret from secure storage
11
+ const secret = await getSecret()
12
+ console.log({secret})
13
+
14
+ // Set a secret in secure storage
15
+ await setSecret({value: 'Sensitive Data'})
16
+
17
+ // Remove a secret from secure storage
18
+ await removeSecret()
19
+ }
20
+
21
+ handleSecureStorageOperations()
22
+ }, [getSecret, setSecret, removeSecret])
23
+ }
@@ -0,0 +1,28 @@
1
+ import {useHandleAction} from '../../internal/useHandleAction'
2
+ import {useShopActions} from '../../internal/useShopActions'
3
+ import {SetSecretParams} from '../../types'
4
+
5
+ interface UseSecureStorageReturns {
6
+ /**
7
+ * Get the secret from the secure storage.
8
+ */
9
+ getSecret: () => Promise<string | null>
10
+ /**
11
+ * Set a secret in the secure storage.
12
+ */
13
+ setSecret: (params: SetSecretParams) => Promise<void>
14
+ /**
15
+ * Remove the secret from the secure storage.
16
+ */
17
+ removeSecret: () => Promise<void>
18
+ }
19
+
20
+ export function useSecureStorage(): UseSecureStorageReturns {
21
+ const {getSecret, setSecret, removeSecret} = useShopActions()
22
+
23
+ return {
24
+ getSecret: useHandleAction(getSecret),
25
+ setSecret: useHandleAction(setSecret),
26
+ removeSecret: useHandleAction(removeSecret),
27
+ }
28
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useBuyerAttributes',
5
+ category: 'hooks',
6
+ subCategory: 'user',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useBuyerAttributes` hook fetches the current buyer attributes, such as gender affinity and category affinities.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useBuyerAttributes.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: 'Props',
26
+ type: 'UseBuyerAttributesGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,14 @@
1
+ import {useEffect} from 'react'
2
+
3
+ import {useBuyerAttributes} from '@shopify/shop-minis-react'
4
+
5
+ export default function MyComponent() {
6
+ const {buyerAttributes} = useBuyerAttributes()
7
+
8
+ useEffect(() => {
9
+ if (buyerAttributes) {
10
+ const {genderAffinity, categoryAffinities} = buyerAttributes
11
+ console.log({genderAffinity, categoryAffinities})
12
+ }
13
+ }, [buyerAttributes])
14
+ }
@@ -0,0 +1,34 @@
1
+ import {useShopActions} from '../../internal/useShopActions'
2
+ import {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'
3
+ import {
4
+ DataHookOptionsBase,
5
+ DataHookReturnsBase,
6
+ BuyerAttributes,
7
+ } from '../../types'
8
+
9
+ export interface UseBuyerAttributesParams extends DataHookOptionsBase {}
10
+
11
+ export interface UseBuyerAttributesReturns extends DataHookReturnsBase {
12
+ buyerAttributes: BuyerAttributes | null
13
+ }
14
+
15
+ export const useBuyerAttributes = (
16
+ params?: UseBuyerAttributesParams
17
+ ): UseBuyerAttributesReturns => {
18
+ const {skip, ...shopActionParams} = params || {}
19
+ const {getBuyerAttributes} = useShopActions()
20
+
21
+ const {data, ...rest} = useShopActionsDataFetching(
22
+ getBuyerAttributes,
23
+ shopActionParams,
24
+ {
25
+ skip,
26
+ hook: 'useBuyerAttributes',
27
+ }
28
+ )
29
+
30
+ return {
31
+ ...rest,
32
+ buyerAttributes: data,
33
+ }
34
+ }
@@ -0,0 +1,31 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useCurrentUser',
5
+ category: 'hooks',
6
+ subCategory: 'user',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description: 'The `useCurrentUser` hook fetches the current user.',
10
+ type: 'hook',
11
+ defaultExample: {
12
+ codeblock: {
13
+ tabs: [
14
+ {
15
+ code: './useCurrentUser.example.tsx',
16
+ language: 'tsx',
17
+ },
18
+ ],
19
+ title: 'Example code',
20
+ },
21
+ },
22
+ definitions: [
23
+ {
24
+ title: '',
25
+ type: 'UseCurrentUserGeneratedType',
26
+ description: '',
27
+ },
28
+ ],
29
+ }
30
+
31
+ export default data
@@ -0,0 +1,7 @@
1
+ import {useCurrentUser} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {currentUser} = useCurrentUser()
5
+
6
+ console.log(currentUser)
7
+ }
@@ -0,0 +1,37 @@
1
+ import {useShopActions} from '../../internal/useShopActions'
2
+ import {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'
3
+ import {
4
+ DataHookOptionsBase,
5
+ DataHookReturnsBase,
6
+ UserProfile,
7
+ } from '../../types'
8
+
9
+ export interface UseCurrentUserParams extends DataHookOptionsBase {}
10
+
11
+ export interface UseCurrentUserReturns extends DataHookReturnsBase {
12
+ currentUser: UserProfile | null
13
+ }
14
+
15
+ /**
16
+ * Hook to fetch the current user's profile.
17
+ */
18
+ export const useCurrentUser = (
19
+ params?: UseCurrentUserParams
20
+ ): UseCurrentUserReturns => {
21
+ const {skip, ...shopActionParams} = params || {}
22
+ const {getCurrentUser} = useShopActions()
23
+
24
+ const {data, ...rest} = useShopActionsDataFetching(
25
+ getCurrentUser,
26
+ shopActionParams,
27
+ {
28
+ skip,
29
+ hook: 'useCurrentUser',
30
+ }
31
+ )
32
+
33
+ return {
34
+ ...rest,
35
+ currentUser: data,
36
+ }
37
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useFollowedShopsActions',
5
+ category: 'hooks',
6
+ subCategory: 'user',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useFollowedShopsActions` hook allows following and unfollowing shops for the current user.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useFollowedShopsActions.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseUpdateFollowedShopsGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,18 @@
1
+ import {useFollowedShopsActions, Button} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {followShop, unfollowShop} = useFollowedShopsActions()
5
+
6
+ return (
7
+ <>
8
+ <Button
9
+ onPress={() => followShop({shopId: 'gid://shopify/Shop/123'})}
10
+ text="Follow shop"
11
+ />
12
+ <Button
13
+ onPress={() => unfollowShop({shopId: 'gid://shopify/Shop/123'})}
14
+ text="Unfollow shop"
15
+ />
16
+ </>
17
+ )
18
+ }
@@ -0,0 +1,23 @@
1
+ import {useHandleAction} from '../../internal/useHandleAction'
2
+ import {useShopActions} from '../../internal/useShopActions'
3
+ import {FollowShopParams, UnfollowShopParams} from '../../types'
4
+
5
+ interface UseFollowedShopsActionsReturns {
6
+ /**
7
+ * Follow a shop.
8
+ */
9
+ followShop: (params: FollowShopParams) => Promise<boolean>
10
+ /**
11
+ * Unfollow a shop.
12
+ */
13
+ unfollowShop: (params: UnfollowShopParams) => Promise<boolean>
14
+ }
15
+
16
+ export const useFollowedShopsActions = (): UseFollowedShopsActionsReturns => {
17
+ const {followShop, unfollowShop} = useShopActions()
18
+
19
+ return {
20
+ followShop: useHandleAction(followShop),
21
+ unfollowShop: useHandleAction(unfollowShop),
22
+ }
23
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useOrders',
5
+ category: 'hooks',
6
+ subCategory: 'user',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useOrders` hook returns a set of recent Shopify orders for the current user.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useOrders.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseOrdersGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,7 @@
1
+ import {useOrders} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {orders, loading, error} = useOrders()
5
+
6
+ console.log({orders, loading, error})
7
+ }
@@ -0,0 +1,32 @@
1
+ import {useShopActions} from '../../internal/useShopActions'
2
+ import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
3
+ import {
4
+ PaginatedDataHookOptionsBase,
5
+ PaginatedDataHookReturnsBase,
6
+ Order,
7
+ } from '../../types'
8
+
9
+ export interface UseOrdersParams extends PaginatedDataHookOptionsBase {}
10
+
11
+ export interface UseOrdersReturns extends PaginatedDataHookReturnsBase {
12
+ orders: Order[] | null
13
+ }
14
+
15
+ export const useOrders = (params?: UseOrdersParams): UseOrdersReturns => {
16
+ const {skip, ...shopActionParams} = params || {}
17
+ const {getOrders} = useShopActions()
18
+
19
+ const {data, ...rest} = useShopActionsPaginatedDataFetching(
20
+ getOrders,
21
+ shopActionParams,
22
+ {
23
+ skip,
24
+ hook: 'useOrders',
25
+ }
26
+ )
27
+
28
+ return {
29
+ ...rest,
30
+ orders: data,
31
+ }
32
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useSavedProductsActions',
5
+ category: 'hooks',
6
+ subCategory: 'user',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useSavedProductsActions` hook allows saving and unsaving products for the current user.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useSavedProductsActions.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseUpdateSavedProductsGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,30 @@
1
+ import {useSavedProductsActions, Button} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {saveProduct, unsaveProduct} = useSavedProductsActions()
5
+
6
+ return (
7
+ <>
8
+ <Button
9
+ onPress={() =>
10
+ saveProduct({
11
+ productId: 'gid://shopify/Product/123',
12
+ productVariantId: 'gid://shopify/ProductVariant/456',
13
+ shopId: 'gid://shopify/Shop/42',
14
+ })
15
+ }
16
+ text="Save product"
17
+ />
18
+ <Button
19
+ onPress={() =>
20
+ unsaveProduct({
21
+ productId: 'gid://shopify/Product/123',
22
+ productVariantId: 'gid://shopify/ProductVariant/456',
23
+ shopId: 'gid://shopify/Shop/42',
24
+ })
25
+ }
26
+ text="Unsave product"
27
+ />
28
+ </>
29
+ )
30
+ }
@@ -0,0 +1,23 @@
1
+ import {useHandleAction} from '../../internal/useHandleAction'
2
+ import {useShopActions} from '../../internal/useShopActions'
3
+ import {FavoriteParams, UnfavoriteParams} from '../../types'
4
+
5
+ interface UseSavedProductsActionsReturns {
6
+ /**
7
+ * Save a product.
8
+ */
9
+ saveProduct: (params: FavoriteParams) => Promise<void>
10
+ /**
11
+ * Unsave a product.
12
+ */
13
+ unsaveProduct: (params: UnfavoriteParams) => Promise<void>
14
+ }
15
+
16
+ export const useSavedProductsActions = (): UseSavedProductsActionsReturns => {
17
+ const {favorite, unfavorite} = useShopActions()
18
+
19
+ return {
20
+ saveProduct: useHandleAction(favorite),
21
+ unsaveProduct: useHandleAction(unfavorite),
22
+ }
23
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useErrorScreen',
5
+ category: 'hooks',
6
+ subCategory: 'util',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useErrorScreen` hook provides functionality for showing error screens. It returns a function that can be used to display an error screen with a given error message.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useErrorScreen.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseErrorScreenGeneratedType',
27
+ description: 'A hook that returns a function to show an error screen.',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data