@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,16 @@
1
+ import {useCallback} from 'react'
2
+
3
+ import {useErrorScreen, Button} from '@shopify/shop-minis-react'
4
+
5
+ export default function MyComponent() {
6
+ const {showErrorScreen} = useErrorScreen()
7
+
8
+ const handleError = useCallback(() => {
9
+ showErrorScreen({
10
+ message: 'Something went wrong',
11
+ title: 'Error',
12
+ })
13
+ }, [showErrorScreen])
14
+
15
+ return <Button onPress={handleError} text="Show error screen" />
16
+ }
@@ -0,0 +1,15 @@
1
+ import {useShopActions} from '../../internal/useShopActions'
2
+ import {ShopActions} from '../../types'
3
+
4
+ interface UseErrorScreenReturns {
5
+ /**
6
+ * Show an error screen with the given error message.
7
+ */
8
+ showErrorScreen: ShopActions['showErrorScreen']
9
+ }
10
+
11
+ export const useErrorScreen = (): UseErrorScreenReturns => {
12
+ const {showErrorScreen} = useShopActions()
13
+
14
+ return {showErrorScreen}
15
+ }
@@ -0,0 +1,32 @@
1
+ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'
2
+
3
+ const data: ReferenceEntityTemplateSchema = {
4
+ name: 'useErrorToast',
5
+ category: 'hooks',
6
+ subCategory: 'util',
7
+ isVisualComponent: false,
8
+ related: [],
9
+ description:
10
+ 'The `useErrorToast` hook provides functionality for showing error toasts. It returns a function that can be used to display an error toast with a given error message.',
11
+ type: 'hook',
12
+ defaultExample: {
13
+ codeblock: {
14
+ tabs: [
15
+ {
16
+ code: './useErrorToast.example.tsx',
17
+ language: 'tsx',
18
+ },
19
+ ],
20
+ title: 'Example code',
21
+ },
22
+ },
23
+ definitions: [
24
+ {
25
+ title: '',
26
+ type: 'UseErrorToastGeneratedType',
27
+ description: 'A hook that returns a function to show an error toast.',
28
+ },
29
+ ],
30
+ }
31
+
32
+ export default data
@@ -0,0 +1,15 @@
1
+ import {useCallback} from 'react'
2
+
3
+ import {useErrorToast, Button} from '@shopify/shop-minis-react'
4
+
5
+ export default function MyComponent() {
6
+ const {showErrorToast} = useErrorToast()
7
+
8
+ const handleError = useCallback(() => {
9
+ showErrorToast({
10
+ message: 'Something went wrong',
11
+ })
12
+ }, [showErrorToast])
13
+
14
+ return <Button onPress={handleError} text="Show error toast" />
15
+ }
@@ -0,0 +1,15 @@
1
+ import {useShopActions} from '../../internal/useShopActions'
2
+ import {ShopActions} from '../../types'
3
+
4
+ interface UseErrorToastReturns {
5
+ /**
6
+ * Show an error toast with the given error message.
7
+ */
8
+ showErrorToast: ShopActions['showErrorToast']
9
+ }
10
+
11
+ export const useErrorToast = (): UseErrorToastReturns => {
12
+ const {showErrorToast} = useShopActions()
13
+
14
+ return {showErrorToast}
15
+ }
package/src/index.css CHANGED
@@ -1,3 +1,121 @@
1
- @import './tailwind-theme.css';
1
+ @import 'tailwindcss';
2
+ @import 'tw-animate-css';
3
+ @source '../node_modules/@shopify/shop-minis-react/src/**/*.{js,ts,jsx,tsx}';
2
4
 
3
- /* Additional base styles for Shop Minis components can go here */
5
+ @custom-variant dark (&:is(.dark *));
6
+
7
+ @theme inline {
8
+ --radius-sm: calc(var(--radius) - 4px);
9
+ --radius-md: calc(var(--radius) - 2px);
10
+ --radius-lg: var(--radius);
11
+ --radius-xl: calc(var(--radius) + 4px);
12
+ --color-background: var(--background);
13
+ --color-foreground: var(--foreground);
14
+ --color-card: var(--card);
15
+ --color-card-foreground: var(--card-foreground);
16
+ --color-popover: var(--popover);
17
+ --color-popover-foreground: var(--popover-foreground);
18
+ --color-primary: var(--primary);
19
+ --color-primary-foreground: var(--primary-foreground);
20
+ --color-secondary: var(--secondary);
21
+ --color-secondary-foreground: var(--secondary-foreground);
22
+ --color-muted: var(--muted);
23
+ --color-muted-foreground: var(--muted-foreground);
24
+ --color-accent: var(--accent);
25
+ --color-accent-foreground: var(--accent-foreground);
26
+ --color-destructive: var(--destructive);
27
+ --color-border: var(--border);
28
+ --color-input: var(--input);
29
+ --color-ring: var(--ring);
30
+ --color-chart-1: var(--chart-1);
31
+ --color-chart-2: var(--chart-2);
32
+ --color-chart-3: var(--chart-3);
33
+ --color-chart-4: var(--chart-4);
34
+ --color-chart-5: var(--chart-5);
35
+ --color-sidebar: var(--sidebar);
36
+ --color-sidebar-foreground: var(--sidebar-foreground);
37
+ --color-sidebar-primary: var(--sidebar-primary);
38
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
39
+ --color-sidebar-accent: var(--sidebar-accent);
40
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
41
+ --color-sidebar-border: var(--sidebar-border);
42
+ --color-sidebar-ring: var(--sidebar-ring);
43
+ }
44
+
45
+ :root {
46
+ --radius: 0.65rem;
47
+ --background: oklch(1 0 0);
48
+ --foreground: oklch(0.141 0.005 285.823);
49
+ --card: oklch(1 0 0);
50
+ --card-foreground: oklch(0.141 0.005 285.823);
51
+ --popover: oklch(1 0 0);
52
+ --popover-foreground: oklch(0.141 0.005 285.823);
53
+ --primary: oklch(0.606 0.25 292.717);
54
+ --primary-foreground: oklch(0.969 0.016 293.756);
55
+ --secondary: oklch(0.967 0.001 286.375);
56
+ --secondary-foreground: oklch(0.21 0.006 285.885);
57
+ --muted: oklch(0.967 0.001 286.375);
58
+ --muted-foreground: oklch(0.552 0.016 285.938);
59
+ --accent: oklch(0.967 0.001 286.375);
60
+ --accent-foreground: oklch(0.21 0.006 285.885);
61
+ --destructive: oklch(0.577 0.245 27.325);
62
+ --border: oklch(0.92 0.004 286.32);
63
+ --input: oklch(0.92 0.004 286.32);
64
+ --ring: oklch(0.606 0.25 292.717);
65
+ --chart-1: oklch(0.646 0.222 41.116);
66
+ --chart-2: oklch(0.6 0.118 184.704);
67
+ --chart-3: oklch(0.398 0.07 227.392);
68
+ --chart-4: oklch(0.828 0.189 84.429);
69
+ --chart-5: oklch(0.769 0.188 70.08);
70
+ --sidebar: oklch(0.985 0 0);
71
+ --sidebar-foreground: oklch(0.141 0.005 285.823);
72
+ --sidebar-primary: oklch(0.606 0.25 292.717);
73
+ --sidebar-primary-foreground: oklch(0.969 0.016 293.756);
74
+ --sidebar-accent: oklch(0.967 0.001 286.375);
75
+ --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
76
+ --sidebar-border: oklch(0.92 0.004 286.32);
77
+ --sidebar-ring: oklch(0.606 0.25 292.717);
78
+ }
79
+
80
+ .dark {
81
+ --background: oklch(0.141 0.005 285.823);
82
+ --foreground: oklch(0.985 0 0);
83
+ --card: oklch(0.21 0.006 285.885);
84
+ --card-foreground: oklch(0.985 0 0);
85
+ --popover: oklch(0.21 0.006 285.885);
86
+ --popover-foreground: oklch(0.985 0 0);
87
+ --primary: oklch(0.541 0.281 293.009);
88
+ --primary-foreground: oklch(0.969 0.016 293.756);
89
+ --secondary: oklch(0.274 0.006 286.033);
90
+ --secondary-foreground: oklch(0.985 0 0);
91
+ --muted: oklch(0.274 0.006 286.033);
92
+ --muted-foreground: oklch(0.705 0.015 286.067);
93
+ --accent: oklch(0.274 0.006 286.033);
94
+ --accent-foreground: oklch(0.985 0 0);
95
+ --destructive: oklch(0.704 0.191 22.216);
96
+ --border: oklch(1 0 0 / 10%);
97
+ --input: oklch(1 0 0 / 15%);
98
+ --ring: oklch(0.541 0.281 293.009);
99
+ --chart-1: oklch(0.488 0.243 264.376);
100
+ --chart-2: oklch(0.696 0.17 162.48);
101
+ --chart-3: oklch(0.769 0.188 70.08);
102
+ --chart-4: oklch(0.627 0.265 303.9);
103
+ --chart-5: oklch(0.645 0.246 16.439);
104
+ --sidebar: oklch(0.21 0.006 285.885);
105
+ --sidebar-foreground: oklch(0.985 0 0);
106
+ --sidebar-primary: oklch(0.541 0.281 293.009);
107
+ --sidebar-primary-foreground: oklch(0.969 0.016 293.756);
108
+ --sidebar-accent: oklch(0.274 0.006 286.033);
109
+ --sidebar-accent-foreground: oklch(0.985 0 0);
110
+ --sidebar-border: oklch(1 0 0 / 10%);
111
+ --sidebar-ring: oklch(0.541 0.281 293.009);
112
+ }
113
+
114
+ @layer base {
115
+ * {
116
+ @apply border-border outline-ring/50;
117
+ }
118
+ body {
119
+ @apply bg-background text-foreground;
120
+ }
121
+ }
@@ -0,0 +1,24 @@
1
+ import {useCallback} from 'react'
2
+
3
+ import {ShopActionResult} from '../types'
4
+
5
+ // Wrapper to handle shop action results as regular promises (Reject on error)
6
+ export const useHandleAction = <T, Args extends unknown[]>(
7
+ action: (...args: Args) => Promise<ShopActionResult<T>>
8
+ ) => {
9
+ // TODO Add when report interaction is implemented for web
10
+ // const reportInteraction = useReportInteraction()
11
+
12
+ return useCallback(
13
+ (...args: Args) => {
14
+ return action(...args).then(result => {
15
+ if (result.ok) {
16
+ return result.data
17
+ }
18
+
19
+ throw result.error
20
+ })
21
+ },
22
+ [action]
23
+ )
24
+ }
@@ -0,0 +1,5 @@
1
+ import {ShopActions} from '../types'
2
+
3
+ export function useShopActions(): ShopActions {
4
+ return window.minisSDK
5
+ }
@@ -0,0 +1,153 @@
1
+ import {useCallback, useEffect, useMemo, useState} from 'react'
2
+
3
+ import {
4
+ DataHookFetchPolicy,
5
+ DataHookReturnsBase,
6
+ ShopActionResult,
7
+ } from '../types'
8
+ import {formatError, MiniError} from '../utils/errors'
9
+
10
+ export interface ShopActionsDataFetchingResult<R> extends DataHookReturnsBase {
11
+ data: R | null
12
+ }
13
+
14
+ export const useShopActionsDataFetching = <
15
+ S = unknown,
16
+ P extends {fetchPolicy?: DataHookFetchPolicy} = {
17
+ fetchPolicy?: DataHookFetchPolicy
18
+ },
19
+ >(
20
+ action: (params: P) => Promise<ShopActionResult<{data: S}>>,
21
+ params: P,
22
+ options: {
23
+ skip?: boolean
24
+ hook?: string
25
+ validator?: (data: S) => void
26
+ }
27
+ ): ShopActionsDataFetchingResult<S> => {
28
+ const [state, setState] = useState<{
29
+ data: S | null
30
+ loading: boolean
31
+ error: Error | null
32
+ }>({
33
+ data: null,
34
+ loading: true,
35
+ error: null,
36
+ })
37
+
38
+ const skip = options?.skip === true
39
+ const {validator, hook} = options
40
+ const runValidator = useCallback(
41
+ (dataToValidate: S) => {
42
+ try {
43
+ validator?.(dataToValidate)
44
+ return null
45
+ } catch (err) {
46
+ return (
47
+ err ??
48
+ new MiniError({
49
+ hook,
50
+ message: 'Validation failed',
51
+ })
52
+ )
53
+ }
54
+ },
55
+ [validator, hook]
56
+ )
57
+
58
+ // Params object is recreated on every render, so we need to memoize it.
59
+ // We don't know what's inside the params object, but we can stringify it.
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ const stableParams = useMemo(() => params, [JSON.stringify(params)])
62
+
63
+ // There's a lot of complexity here because each type of fetch has different side effects if we are trying to
64
+ // stay close to how Apollo client works. eg:
65
+ // - Initial fetch: set loading, set error, set data, reset on error (don't throw)
66
+ // - change params fetch: set loading, set error, set data, reset on error (don't throw)
67
+ // - refetch fetch: don't set loading, set error, update data, leave data as is was on error (also throw)
68
+ // - fetchMore fetch: don't set loading, don't set error, update data, leave data as is was on error (also throw)
69
+ const fetch = useCallback(
70
+ async (
71
+ extraParams?: Partial<P>,
72
+ {
73
+ setLoading = true,
74
+ setError = true,
75
+ resetOnError = true,
76
+ throwOnError = true,
77
+ }: {
78
+ setLoading?: boolean
79
+ setError?: boolean
80
+ resetOnError?: boolean
81
+ throwOnError?: boolean
82
+ } = {}
83
+ ) => {
84
+ let queryError: Error | null = null
85
+ let validationError: Error | null = null
86
+
87
+ setState(curState => ({
88
+ ...curState,
89
+ loading: setLoading ? true : curState.loading,
90
+ }))
91
+
92
+ try {
93
+ const result = await action({...stableParams, ...extraParams})
94
+
95
+ if (result.ok) {
96
+ validationError = runValidator(result.data.data)
97
+
98
+ setState(curState => ({
99
+ ...curState,
100
+ data: result.data.data,
101
+ loading: false,
102
+ error: validationError ?? null,
103
+ }))
104
+ } else {
105
+ throw result.error
106
+ }
107
+ } catch (err) {
108
+ queryError = formatError({hook}, err)
109
+ }
110
+
111
+ const error = validationError || queryError
112
+
113
+ if (error && (setError || resetOnError)) {
114
+ setState(curState => ({
115
+ data: resetOnError ? null : curState.data,
116
+ loading: false,
117
+ error,
118
+ }))
119
+ }
120
+
121
+ if (error && throwOnError) {
122
+ throw error
123
+ }
124
+ },
125
+ [action, stableParams, hook, runValidator]
126
+ )
127
+
128
+ const refetch = useCallback(async () => {
129
+ await fetch({fetchPolicy: 'network-only'} as Partial<P>, {
130
+ setLoading: false,
131
+ resetOnError: false,
132
+ throwOnError: true,
133
+ })
134
+ }, [fetch])
135
+
136
+ useEffect(() => {
137
+ if (skip) return
138
+
139
+ fetch(
140
+ {},
141
+ {
142
+ throwOnError: false,
143
+ }
144
+ )
145
+ }, [fetch, skip])
146
+
147
+ return {
148
+ data: state.data,
149
+ loading: state.loading,
150
+ error: state.error,
151
+ refetch,
152
+ }
153
+ }
@@ -0,0 +1,193 @@
1
+ import {useCallback, useEffect, useMemo, useState} from 'react'
2
+
3
+ import {
4
+ DataHookFetchPolicy,
5
+ PaginatedDataHookReturnsBase,
6
+ PaginationInfo,
7
+ ShopActionResult,
8
+ } from '../types'
9
+ import {formatError, MiniError} from '../utils/errors'
10
+
11
+ export interface ShopActionsDataFetchingResult<S>
12
+ extends PaginatedDataHookReturnsBase {
13
+ data: S | null
14
+ }
15
+
16
+ export const useShopActionsPaginatedDataFetching = <
17
+ S = unknown,
18
+ P extends {after?: string; fetchPolicy?: DataHookFetchPolicy} = {
19
+ after?: undefined
20
+ fetchPolicy?: DataHookFetchPolicy
21
+ },
22
+ >(
23
+ action: (
24
+ params: P
25
+ ) => Promise<ShopActionResult<{data: S; pageInfo: PaginationInfo}>>,
26
+ params: P,
27
+ options: {
28
+ skip?: boolean
29
+ hook?: string
30
+ validator?: (data: S) => void
31
+ }
32
+ ): ShopActionsDataFetchingResult<S> => {
33
+ const [state, setState] = useState<{
34
+ data: S | null
35
+ pageInfo: PaginationInfo
36
+ loading: boolean
37
+ error: Error | null
38
+ }>({
39
+ data: null,
40
+ pageInfo: {hasNextPage: false, endCursor: null},
41
+ loading: false,
42
+ error: null,
43
+ })
44
+
45
+ const skip = options?.skip === true
46
+ const {validator, hook} = options
47
+ const runValidator = useCallback(
48
+ (dataToValidate: S) => {
49
+ try {
50
+ validator?.(dataToValidate)
51
+ return null
52
+ } catch (err) {
53
+ return (
54
+ err ??
55
+ new MiniError({
56
+ hook,
57
+ message: 'Validation failed',
58
+ })
59
+ )
60
+ }
61
+ },
62
+ [validator, hook]
63
+ )
64
+
65
+ // Params object is recreated on every render, so we need to memoize it.
66
+ // We don't know what's inside the params object, but we can stringify it.
67
+ // eslint-disable-next-line react-hooks/exhaustive-deps
68
+ const stableParams = useMemo(() => params, [JSON.stringify(params)])
69
+
70
+ // There's a lot of complexity here because each type of fetch has different side effects if we are trying to
71
+ // stay close to how Apollo client works. eg:
72
+ // - Initial fetch: set loading, set error, set data, reset on error (don't throw)
73
+ // - change params fetch: set loading, set error, set data, reset on error (don't throw)
74
+ // - refetch fetch: don't set loading, set error, update data, leave data as is was on error (also throw)
75
+ // - fetchMore fetch: don't set loading, don't set error, update data, leave data as is was on error (also throw)
76
+ const fetch = useCallback(
77
+ async (
78
+ extraParams?: Partial<P>,
79
+ {
80
+ setLoading = true,
81
+ setError = true,
82
+ resetOnError = true,
83
+ throwOnError = true,
84
+ appendData = false,
85
+ }: {
86
+ setLoading?: boolean
87
+ setError?: boolean
88
+ resetOnError?: boolean
89
+ throwOnError?: boolean
90
+ appendData?: boolean
91
+ } = {}
92
+ ) => {
93
+ let queryError: Error | null = null
94
+ let validationError: Error | null = null
95
+
96
+ setState(curState => ({
97
+ ...curState,
98
+ loading: setLoading ? true : curState.loading,
99
+ }))
100
+
101
+ try {
102
+ const result = await action({...stableParams, ...extraParams})
103
+
104
+ if (result.ok) {
105
+ validationError = runValidator(result.data.data)
106
+
107
+ setState(curState => {
108
+ let newData = result.data.data
109
+
110
+ if (
111
+ appendData &&
112
+ curState.data &&
113
+ Array.isArray(curState.data) &&
114
+ Array.isArray(result.data.data)
115
+ ) {
116
+ newData = [...curState.data, ...result.data.data] as S
117
+ }
118
+
119
+ return {
120
+ ...curState,
121
+ data: newData,
122
+ pageInfo: result.data.pageInfo,
123
+ loading: false,
124
+ error: validationError ?? null,
125
+ }
126
+ })
127
+ } else {
128
+ throw result.error
129
+ }
130
+ } catch (err) {
131
+ queryError = formatError({hook}, err)
132
+ }
133
+
134
+ const error = validationError || queryError
135
+
136
+ if (error && (setError || resetOnError)) {
137
+ setState(curState => ({
138
+ data: resetOnError ? null : curState.data,
139
+ pageInfo: resetOnError
140
+ ? {hasNextPage: false, endCursor: null}
141
+ : curState.pageInfo,
142
+ loading: false,
143
+ error,
144
+ }))
145
+ }
146
+
147
+ if (error && throwOnError) {
148
+ throw error
149
+ }
150
+ },
151
+ [action, stableParams, hook, runValidator]
152
+ )
153
+
154
+ const refetch = useCallback(async () => {
155
+ await fetch({fetchPolicy: 'network-only'} as Partial<P>, {
156
+ setLoading: false,
157
+ resetOnError: false,
158
+ throwOnError: true,
159
+ })
160
+ }, [fetch])
161
+
162
+ const fetchMore = useCallback(async () => {
163
+ if (!state.pageInfo.hasNextPage || !state.pageInfo.endCursor) return
164
+
165
+ await fetch({after: state.pageInfo.endCursor} as Partial<P>, {
166
+ setLoading: false,
167
+ setError: false,
168
+ resetOnError: false,
169
+ throwOnError: true,
170
+ appendData: true,
171
+ })
172
+ }, [state.pageInfo.hasNextPage, state.pageInfo.endCursor, fetch])
173
+
174
+ useEffect(() => {
175
+ if (skip) return
176
+
177
+ fetch(
178
+ {},
179
+ {
180
+ throwOnError: false,
181
+ }
182
+ )
183
+ }, [fetch, skip])
184
+
185
+ return {
186
+ data: state.data,
187
+ loading: state.loading,
188
+ error: state.error,
189
+ hasNextPage: state.pageInfo.hasNextPage,
190
+ refetch,
191
+ fetchMore,
192
+ }
193
+ }
@@ -0,0 +1,9 @@
1
+ import {type ClassValue, clsx} from 'clsx'
2
+ import {twMerge} from 'tailwind-merge'
3
+
4
+ /**
5
+ * Utility function to merge Tailwind CSS classes with proper conflict resolution
6
+ */
7
+ export function cn(...inputs: ClassValue[]) {
8
+ return twMerge(clsx(inputs))
9
+ }
@@ -1,4 +1,6 @@
1
1
  // Common types for the component library
2
+ export * from './minisSDK.generated.d'
3
+
2
4
  export interface BaseComponentProps {
3
5
  className?: string
4
6
  children?: React.ReactNode