@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,56 @@
1
+ import {useCallback} from 'react'
2
+
3
+ import {useShopActions} from '../../internal/useShopActions'
4
+ import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
+ import {
6
+ ProductList,
7
+ PaginatedDataHookOptionsBase,
8
+ PaginatedDataHookReturnsBase,
9
+ } from '../../types'
10
+ import {MiniEntityNotFoundError} from '../../utils/errors'
11
+
12
+ interface UseProductListParams extends PaginatedDataHookOptionsBase {
13
+ /**
14
+ * The GID of the product list. E.g. `gid://shopapp/ProductList/123`.
15
+ */
16
+ id?: string
17
+ /**
18
+ * The public ID of the product list.
19
+ */
20
+ publicId?: string
21
+ }
22
+
23
+ interface UseProductListResult extends PaginatedDataHookReturnsBase {
24
+ productList: ProductList | null
25
+ }
26
+
27
+ export const useProductList = (
28
+ params?: UseProductListParams
29
+ ): UseProductListResult => {
30
+ const {getProductList} = useShopActions()
31
+ const {skip, ...shopActionParams} = params ?? {}
32
+
33
+ const validator = useCallback((data: ProductList | null) => {
34
+ if (data === null) {
35
+ throw new MiniEntityNotFoundError({
36
+ hook: 'useProductList',
37
+ message: 'Product list not found',
38
+ })
39
+ }
40
+ }, [])
41
+
42
+ const {data, ...rest} = useShopActionsPaginatedDataFetching(
43
+ getProductList,
44
+ shopActionParams,
45
+ {
46
+ skip,
47
+ hook: 'useProductList',
48
+ validator,
49
+ }
50
+ )
51
+
52
+ return {
53
+ ...rest,
54
+ productList: data,
55
+ }
56
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useProductListActions',
5
+ category: 'hooks',
6
+ subCategory: 'product',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useProductListActions` returns a set of actions for managing product lists.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useProductListActions.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseProductListActionsGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,57 @@
1
+ import {useProductListActions, Button} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {
5
+ addProductList,
6
+ removeProductList,
7
+ renameProductList,
8
+ addProductListItem,
9
+ removeProductListItem,
10
+ } = useProductListActions()
11
+
12
+ return (
13
+ <>
14
+ <Button
15
+ onPress={() => addProductList({name: 'My product list'})}
16
+ text="Add product list"
17
+ />
18
+ <Button
19
+ onPress={() => removeProductList({id: 'gid://shopapp/ProductList/123'})}
20
+ text="Remove product list"
21
+ />
22
+ <Button
23
+ onPress={() =>
24
+ renameProductList({
25
+ id: 'gid://shopapp/ProductList/123',
26
+ name: 'My renamed product list',
27
+ })
28
+ }
29
+ text="Rename product list"
30
+ />
31
+ <Button
32
+ onPress={() =>
33
+ addProductListItem({
34
+ shopId: 'gid://shopify/Shop/42',
35
+ productId: 'gid://shopify/Product/123',
36
+ productVariantId: 'gid://shopify/ProductVariant/101',
37
+ listId: 'gid://shopapp/ProductList/99',
38
+ publicListId: 'abc123',
39
+ })
40
+ }
41
+ text="Add product to list"
42
+ />
43
+ <Button
44
+ onPress={() =>
45
+ removeProductListItem({
46
+ shopId: 'gid://shopify/Shop/42',
47
+ productId: 'gid://shopify/Product/123',
48
+ productVariantId: 'gid://shopify/ProductVariant/101',
49
+ listId: 'gid://shopapp/ProductList/99',
50
+ publicListId: 'abc123',
51
+ })
52
+ }
53
+ text="Remove product from list"
54
+ />
55
+ </>
56
+ )
57
+ }
@@ -0,0 +1,51 @@
1
+ import {useHandleAction} from '../../internal/useHandleAction'
2
+ import {useShopActions} from '../../internal/useShopActions'
3
+ import {
4
+ AddProductListParams,
5
+ RemoveProductListParams,
6
+ RenameProductListParams,
7
+ AddProductListItemParams,
8
+ RemoveProductListItemParams,
9
+ ProductList,
10
+ } from '../../types'
11
+
12
+ interface UseProductListActionsReturns {
13
+ /**
14
+ * Add a product list
15
+ */
16
+ addProductList: (params: AddProductListParams) => Promise<ProductList>
17
+ /**
18
+ * Remove a product list
19
+ */
20
+ removeProductList: (params: RemoveProductListParams) => Promise<void>
21
+ /**
22
+ * Rename a product list
23
+ */
24
+ renameProductList: (params: RenameProductListParams) => Promise<ProductList>
25
+ /**
26
+ * Add a product to a product list
27
+ */
28
+ addProductListItem: (params: AddProductListItemParams) => Promise<void>
29
+ /**
30
+ * Remove a product from a product list
31
+ */
32
+ removeProductListItem: (params: RemoveProductListItemParams) => Promise<void>
33
+ }
34
+
35
+ export const useProductListActions = (): UseProductListActionsReturns => {
36
+ const {
37
+ addProductList,
38
+ removeProductList,
39
+ renameProductList,
40
+ addProductListItem,
41
+ removeProductListItem,
42
+ } = useShopActions()
43
+
44
+ return {
45
+ addProductList: useHandleAction(addProductList),
46
+ removeProductList: useHandleAction(removeProductList),
47
+ renameProductList: useHandleAction(renameProductList),
48
+ addProductListItem: useHandleAction(addProductListItem),
49
+ removeProductListItem: useHandleAction(removeProductListItem),
50
+ }
51
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useProductLists',
5
+ category: 'hooks',
6
+ subCategory: 'product',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useProductLists` hook fetches all the users product lists.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useProductLists.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseProductListsGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,9 @@
1
+ import {useProductLists} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {productLists, loading, error} = useProductLists({
5
+ first: 10,
6
+ })
7
+
8
+ console.log({productLists, loading, error})
9
+ }
@@ -0,0 +1,39 @@
1
+ import {useShopActions} from '../../internal/useShopActions'
2
+ import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
3
+ import {
4
+ PaginatedDataHookOptionsBase,
5
+ PaginatedDataHookReturnsBase,
6
+ ProductList,
7
+ } from '../../types'
8
+
9
+ interface UseProductListsParams extends PaginatedDataHookOptionsBase {
10
+ /**
11
+ * The number of products to fetch per product list.
12
+ */
13
+ itemsFirst?: number
14
+ }
15
+
16
+ interface UseProductListsResult extends PaginatedDataHookReturnsBase {
17
+ productLists: ProductList[] | null
18
+ }
19
+
20
+ export const useProductLists = (
21
+ params?: UseProductListsParams
22
+ ): UseProductListsResult => {
23
+ const {getProductLists} = useShopActions()
24
+ const {skip, ...shopActionParams} = params ?? {}
25
+
26
+ const {data, ...rest} = useShopActionsPaginatedDataFetching(
27
+ getProductLists,
28
+ shopActionParams,
29
+ {
30
+ skip,
31
+ hook: 'useProductLists',
32
+ }
33
+ )
34
+
35
+ return {
36
+ ...rest,
37
+ productLists: data,
38
+ }
39
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useRecommendedProducts',
5
+ category: 'hooks',
6
+ subCategory: 'product',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useRecommendedProducts` hook enables fetching a list of recommended products for the user. The list may be empty if the user has no recommended products.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useRecommendedProducts.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseRecommendedProductsGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,7 @@
1
+ import {useRecommendedProducts} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {products, loading, error} = useRecommendedProducts()
5
+
6
+ console.log({products, loading, error})
7
+ }
@@ -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 UseRecommendedProductsParams extends PaginatedDataHookOptionsBase {}
10
+
11
+ interface UseRecommendedProductsReturns extends PaginatedDataHookReturnsBase {
12
+ products: Product[] | null
13
+ }
14
+
15
+ /**
16
+ * @param options - The options for the query
17
+ */
18
+ export const useRecommendedProducts = (
19
+ params?: UseRecommendedProductsParams
20
+ ): UseRecommendedProductsReturns => {
21
+ const {getRecommendedProducts} = useShopActions()
22
+ const {skip, ...shopActionParams} = params ?? {}
23
+
24
+ const {data, ...rest} = useShopActionsPaginatedDataFetching(
25
+ getRecommendedProducts,
26
+ shopActionParams,
27
+ {
28
+ skip,
29
+ hook: 'useRecommendedProducts',
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: 'useRecommendedShops',
5
+ category: 'hooks',
6
+ subCategory: 'shop',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useRecommendedShops` hook enables fetching a list of recommended shops for the user. The list may be empty if the user has no recommended shops.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useRecommendedShops.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseRecommendedShopsGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,7 @@
1
+ import {useRecommendedShops} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {shops, loading, error} = useRecommendedShops()
5
+
6
+ console.log({shops, loading, error})
7
+ }
@@ -0,0 +1,43 @@
1
+ import {useMemo} from 'react'
2
+
3
+ import {useShopActions} from '../../internal/useShopActions'
4
+ import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
+ import {
6
+ Shop,
7
+ PaginatedDataHookOptionsBase,
8
+ PaginatedDataHookReturnsBase,
9
+ } from '../../types'
10
+
11
+ interface UseRecommendedShopsParams extends PaginatedDataHookOptionsBase {}
12
+
13
+ interface UseRecommendedShopsReturns extends PaginatedDataHookReturnsBase {
14
+ shops: Shop[] | null
15
+ }
16
+
17
+ export const useRecommendedShops = (
18
+ params?: UseRecommendedShopsParams
19
+ ): UseRecommendedShopsReturns => {
20
+ const {getRecommendedShops} = useShopActions()
21
+
22
+ const {skip, ...shopActionParamsToPass} = params || {}
23
+
24
+ const {data, ...rest} = useShopActionsPaginatedDataFetching(
25
+ getRecommendedShops,
26
+ shopActionParamsToPass,
27
+ {
28
+ skip,
29
+ hook: 'useRecommendedShops',
30
+ }
31
+ )
32
+
33
+ const shops = useMemo(() => {
34
+ if (!data) return null
35
+
36
+ return Array.from(new Map(data.map(shop => [shop.id, shop])).values())
37
+ }, [data])
38
+
39
+ return {
40
+ ...rest,
41
+ shops,
42
+ }
43
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useShopCartActions',
5
+ category: 'hooks',
6
+ subCategory: 'shop',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useShopCartActions` hook provides functions for managing the shopping cart. It includes operations for adding products to the cart and buying products directly.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useShopCartActions.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseShopCartActionsGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,28 @@
1
+ import {Button, useShopCartActions} from '@shopify/shop-minis-react'
2
+
3
+ export default function MyComponent() {
4
+ const {addToCart, buyProduct} = useShopCartActions()
5
+
6
+ const handleAddToCart = async () => {
7
+ await addToCart({
8
+ productId: 'gid://shopify/Product/123',
9
+ productVariantId: 'gid://shopify/ProductVariant/456',
10
+ quantity: 1,
11
+ })
12
+ }
13
+
14
+ const handleBuyNow = async () => {
15
+ await buyProduct({
16
+ productId: 'gid://shopify/Product/123',
17
+ productVariantId: 'gid://shopify/ProductVariant/456',
18
+ quantity: 1,
19
+ })
20
+ }
21
+
22
+ return (
23
+ <>
24
+ <Button text="Add to cart" onPress={handleAddToCart} />
25
+ <Button text="Buy now" onPress={handleBuyNow} />
26
+ </>
27
+ )
28
+ }
@@ -0,0 +1,23 @@
1
+ import {useHandleAction} from '../../internal/useHandleAction'
2
+ import {useShopActions} from '../../internal/useShopActions'
3
+ import {AddToCartParams, BuyProductParams} from '../../types'
4
+
5
+ interface UseShopCartActionsReturns {
6
+ /**
7
+ * Add a product to the cart
8
+ */
9
+ addToCart: (params: AddToCartParams) => Promise<void>
10
+ /**
11
+ * Buy a product directly
12
+ */
13
+ buyProduct: (params: BuyProductParams) => Promise<void>
14
+ }
15
+
16
+ export const useShopCartActions = (): UseShopCartActionsReturns => {
17
+ const {addToCart, buyProduct} = useShopActions()
18
+
19
+ return {
20
+ addToCart: useHandleAction(addToCart),
21
+ buyProduct: useHandleAction(buyProduct),
22
+ }
23
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useAsyncStorage',
5
+ category: 'hooks',
6
+ subCategory: 'storage',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useAsyncStorage` hook provides functions to interact with persistent storage. It allows you to store, retrieve, and manage data that persists between app sessions.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useAsyncStorage.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseAsyncStorageGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,30 @@
1
+ import {useEffect} from 'react'
2
+
3
+ import {useAsyncStorage} from '@shopify/shop-minis-react'
4
+
5
+ export default function MyComponent() {
6
+ const {getItem, setItem, removeItem, getAllKeys, clear} = useAsyncStorage()
7
+
8
+ useEffect(() => {
9
+ async function handleStorageOperations() {
10
+ // Get an item from storage
11
+ const value = await getItem({key: 'myKey'})
12
+ console.log({value})
13
+
14
+ // Set an item in storage
15
+ await setItem({key: 'myKey', value: 'Hello, World!'})
16
+
17
+ // Remove an item from storage
18
+ await removeItem({key: 'myKey'})
19
+
20
+ // Get all keys in storage
21
+ const keys = await getAllKeys()
22
+ console.log({keys})
23
+
24
+ // Clear all items from storage
25
+ await clear()
26
+ }
27
+
28
+ handleStorageOperations()
29
+ }, [getItem, removeItem, setItem, getAllKeys, clear])
30
+ }
@@ -0,0 +1,48 @@
1
+ import {useHandleAction} from '../../internal/useHandleAction'
2
+ import {useShopActions} from '../../internal/useShopActions'
3
+ import {
4
+ GetAsyncStorageItemParams,
5
+ SetAsyncStorageItemParams,
6
+ RemoveAsyncStorageItemParams,
7
+ } from '../../types'
8
+
9
+ interface UseAsyncStorageReturns {
10
+ /**
11
+ * Get an item from the async storage.
12
+ */
13
+ getItem: (params: GetAsyncStorageItemParams) => Promise<string | null>
14
+ /**
15
+ * Set an item in the async storage.
16
+ */
17
+ setItem: (params: SetAsyncStorageItemParams) => Promise<void>
18
+ /**
19
+ * Remove an item from the async storage.
20
+ */
21
+ removeItem: (params: RemoveAsyncStorageItemParams) => Promise<void>
22
+ /**
23
+ * Get all keys in the async storage.
24
+ */
25
+ getAllKeys: () => Promise<string[]>
26
+ /**
27
+ * Clear all items from the async storage.
28
+ */
29
+ clear: () => Promise<void>
30
+ }
31
+
32
+ export function useAsyncStorage(): UseAsyncStorageReturns {
33
+ const {
34
+ getPersistedItem,
35
+ setPersistedItem,
36
+ removePersistedItem,
37
+ getAllPersistedKeys,
38
+ clearPersistedItems,
39
+ } = useShopActions()
40
+
41
+ return {
42
+ getItem: useHandleAction(getPersistedItem),
43
+ setItem: useHandleAction(setPersistedItem),
44
+ removeItem: useHandleAction(removePersistedItem),
45
+ getAllKeys: useHandleAction(getAllPersistedKeys),
46
+ clear: useHandleAction(clearPersistedItems),
47
+ }
48
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useImageUpload',
5
+ category: 'hooks',
6
+ subCategory: 'storage',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useImageUpload` hook provides functionality for uploading images attached to the current user. It handles the upload process, including getting upload links, uploading to storage, and polling for completion.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useImageUpload.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseImageUploadGeneratedType',
27
+ description: '',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data