@shopify/ui-extensions 2025.10.0-rc.46 → 2025.10.0-rc.47

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 (243) hide show
  1. package/build/cjs/surfaces/checkout/preact/api.js +1 -1
  2. package/build/cjs/surfaces/checkout/shared.js +1 -1
  3. package/build/esm/surfaces/checkout/preact/api.mjs +1 -1
  4. package/build/esm/surfaces/checkout/shared.mjs +1 -1
  5. package/build/esnext/surfaces/checkout/preact/api.esnext +1 -1
  6. package/build/esnext/surfaces/checkout/shared.esnext +1 -1
  7. package/build/ts/docs/shared/components/ConsentCheckbox.d.ts +4 -0
  8. package/build/ts/docs/shared/components/ConsentCheckbox.d.ts.map +1 -0
  9. package/build/ts/docs/shared/components/ConsentPhoneField.d.ts +4 -0
  10. package/build/ts/docs/shared/components/ConsentPhoneField.d.ts.map +1 -0
  11. package/build/ts/docs/shared/components/index.d.ts +2 -0
  12. package/build/ts/docs/shared/components/index.d.ts.map +1 -1
  13. package/build/ts/surfaces/checkout/components/ConsentCheckbox/ConsentCheckbox.doc.d.ts +4 -0
  14. package/build/ts/surfaces/checkout/components/ConsentCheckbox/ConsentCheckbox.doc.d.ts.map +1 -0
  15. package/build/ts/surfaces/checkout/components/ConsentCheckbox.d.ts +84 -0
  16. package/build/ts/surfaces/checkout/components/ConsentPhoneField/ConsentPhoneField.doc.d.ts +4 -0
  17. package/build/ts/surfaces/checkout/components/ConsentPhoneField/ConsentPhoneField.doc.d.ts.map +1 -0
  18. package/build/ts/surfaces/checkout/components/ConsentPhoneField.d.ts +129 -0
  19. package/build/ts/surfaces/checkout/components/NumberField/NumberField.doc.d.ts +4 -0
  20. package/build/ts/surfaces/checkout/components/NumberField/NumberField.doc.d.ts.map +1 -0
  21. package/build/ts/surfaces/checkout/components/NumberField.d.ts +98 -0
  22. package/build/ts/surfaces/checkout/components/PasswordField.d.ts +1 -1
  23. package/build/ts/surfaces/checkout/components/components-shared.d.ts +17 -0
  24. package/build/ts/surfaces/checkout/components/components.d.ts +216 -144
  25. package/build/ts/surfaces/checkout/shared.d.ts +1 -1
  26. package/build/ts/surfaces/checkout/shared.d.ts.map +1 -1
  27. package/build/ts/surfaces/checkout/targets/Checkout::Actions::RenderBefore.d.ts +3 -0
  28. package/build/ts/surfaces/checkout/targets/Checkout::CartLineDetails::RenderAfter.d.ts +3 -0
  29. package/build/ts/surfaces/checkout/targets/Checkout::CartLineDetails::RenderLineComponents.d.ts +3 -0
  30. package/build/ts/surfaces/checkout/targets/Checkout::CartLines::RenderAfter.d.ts +3 -0
  31. package/build/ts/surfaces/checkout/targets/Checkout::Contact::RenderAfter.d.ts +3 -0
  32. package/build/ts/surfaces/checkout/targets/Checkout::CustomerInformation::RenderAfter.d.ts +3 -0
  33. package/build/ts/surfaces/checkout/targets/Checkout::DeliveryAddress::RenderBefore.d.ts +3 -0
  34. package/build/ts/surfaces/checkout/targets/Checkout::Dynamic::Render.d.ts +3 -0
  35. package/build/ts/surfaces/checkout/targets/Checkout::GiftCard::Render.d.ts +3 -0
  36. package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::HostedFields::RenderAfter.d.ts +3 -0
  37. package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::Render.d.ts +3 -0
  38. package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::RenderRequiredAction.d.ts +3 -0
  39. package/build/ts/surfaces/checkout/targets/Checkout::PickupLocations::RenderAfter.d.ts +3 -0
  40. package/build/ts/surfaces/checkout/targets/Checkout::PickupLocations::RenderBefore.d.ts +3 -0
  41. package/build/ts/surfaces/checkout/targets/Checkout::PickupPoints::RenderAfter.d.ts +3 -0
  42. package/build/ts/surfaces/checkout/targets/Checkout::PickupPoints::RenderBefore.d.ts +3 -0
  43. package/build/ts/surfaces/checkout/targets/Checkout::Reductions::RenderAfter.d.ts +3 -0
  44. package/build/ts/surfaces/checkout/targets/Checkout::Reductions::RenderBefore.d.ts +3 -0
  45. package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethodDetails::RenderAfter.d.ts +3 -0
  46. package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethodDetails::RenderExpanded.d.ts +3 -0
  47. package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethods::RenderAfter.d.ts +3 -0
  48. package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethods::RenderBefore.d.ts +3 -0
  49. package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CartLineDetails::RenderAfter.d.ts +3 -0
  50. package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CartLines::RenderAfter.d.ts +3 -0
  51. package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CustomerInformation::RenderAfter.d.ts +3 -0
  52. package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::Dynamic::Render.d.ts +3 -0
  53. package/build/ts/surfaces/checkout/targets/purchase.cart-line-item.line-components.render.d.ts +3 -0
  54. package/build/ts/surfaces/checkout/targets/purchase.checkout.actions.render-before.d.ts +3 -0
  55. package/build/ts/surfaces/checkout/targets/purchase.checkout.block.render.d.ts +3 -0
  56. package/build/ts/surfaces/checkout/targets/purchase.checkout.cart-line-item.render-after.d.ts +3 -0
  57. package/build/ts/surfaces/checkout/targets/purchase.checkout.cart-line-list.render-after.d.ts +3 -0
  58. package/build/ts/surfaces/checkout/targets/purchase.checkout.contact.render-after.d.ts +3 -0
  59. package/build/ts/surfaces/checkout/targets/purchase.checkout.delivery-address.render-after.d.ts +3 -0
  60. package/build/ts/surfaces/checkout/targets/purchase.checkout.delivery-address.render-before.d.ts +3 -0
  61. package/build/ts/surfaces/checkout/targets/purchase.checkout.footer.render-after.d.ts +3 -0
  62. package/build/ts/surfaces/checkout/targets/purchase.checkout.gift-card.render.d.ts +3 -0
  63. package/build/ts/surfaces/checkout/targets/purchase.checkout.header.render-after.d.ts +3 -0
  64. package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-method-list.render-after.d.ts +3 -0
  65. package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-method-list.render-before.d.ts +3 -0
  66. package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.action-required.render.d.ts +3 -0
  67. package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.details.render.d.ts +3 -0
  68. package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.hosted-fields.render-after.d.ts +3 -0
  69. package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-list.render-after.d.ts +3 -0
  70. package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-list.render-before.d.ts +3 -0
  71. package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-option-item.render-after.d.ts +3 -0
  72. package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-point-list.render-after.d.ts +3 -0
  73. package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-point-list.render-before.d.ts +3 -0
  74. package/build/ts/surfaces/checkout/targets/purchase.checkout.reductions.render-after.d.ts +3 -0
  75. package/build/ts/surfaces/checkout/targets/purchase.checkout.reductions.render-before.d.ts +3 -0
  76. package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-item.details.render.d.ts +3 -0
  77. package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-item.render-after.d.ts +3 -0
  78. package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-list.render-after.d.ts +3 -0
  79. package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-list.render-before.d.ts +3 -0
  80. package/build/ts/surfaces/checkout/targets/purchase.thank-you.announcement.render.d.ts +3 -0
  81. package/build/ts/surfaces/checkout/targets/purchase.thank-you.block.render.d.ts +3 -0
  82. package/build/ts/surfaces/checkout/targets/purchase.thank-you.cart-line-item.render-after.d.ts +3 -0
  83. package/build/ts/surfaces/checkout/targets/purchase.thank-you.cart-line-list.render-after.d.ts +3 -0
  84. package/build/ts/surfaces/checkout/targets/purchase.thank-you.customer-information.render-after.d.ts +3 -0
  85. package/build/ts/surfaces/checkout/targets/purchase.thank-you.footer.render-after.d.ts +3 -0
  86. package/build/ts/surfaces/checkout/targets/purchase.thank-you.header.render-after.d.ts +3 -0
  87. package/build/ts/surfaces/customer-account/components/ConsentCheckbox.d.ts +84 -0
  88. package/build/ts/surfaces/customer-account/components/ConsentPhoneField.d.ts +129 -0
  89. package/build/ts/surfaces/customer-account/components/NumberField.d.ts +98 -0
  90. package/build/ts/surfaces/customer-account/components/PasswordField.d.ts +1 -1
  91. package/build/ts/surfaces/customer-account/components/components-shared.d.ts +17 -0
  92. package/build/ts/surfaces/customer-account/components/components.d.ts +216 -144
  93. package/build/ts/surfaces/customer-account/targets/customer-account.footer.render-after.d.ts +3 -0
  94. package/build/ts/surfaces/customer-account/targets/customer-account.order-index.announcement.render.d.ts +3 -0
  95. package/build/ts/surfaces/customer-account/targets/customer-account.order-index.block.render.d.ts +3 -0
  96. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.announcement.render.d.ts +3 -0
  97. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.block.render.d.ts +3 -0
  98. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.cart-line-item.render-after.d.ts +3 -0
  99. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.cart-line-list.render-after.d.ts +3 -0
  100. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.customer-information.render-after.d.ts +3 -0
  101. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.fulfillment-details.render-after.d.ts +3 -0
  102. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.payment-details.render-after.d.ts +3 -0
  103. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.return-details.render-after.d.ts +3 -0
  104. package/build/ts/surfaces/customer-account/targets/customer-account.order-status.unfulfilled-items.render-after.d.ts +3 -0
  105. package/build/ts/surfaces/customer-account/targets/customer-account.order.action.menu-item.render.d.ts +3 -0
  106. package/build/ts/surfaces/customer-account/targets/customer-account.order.action.render.d.ts +3 -0
  107. package/build/ts/surfaces/customer-account/targets/customer-account.order.page.render.d.ts +3 -0
  108. package/build/ts/surfaces/customer-account/targets/customer-account.page.render.d.ts +3 -0
  109. package/build/ts/surfaces/customer-account/targets/customer-account.profile.addresses.render-after.d.ts +3 -0
  110. package/build/ts/surfaces/customer-account/targets/customer-account.profile.announcement.render.d.ts +3 -0
  111. package/build/ts/surfaces/customer-account/targets/customer-account.profile.block.render.d.ts +3 -0
  112. package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-details.render-after.d.ts +3 -0
  113. package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-addresses.render-after.d.ts +3 -0
  114. package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-payment.render-after.d.ts +3 -0
  115. package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-staff.render-after.d.ts +3 -0
  116. package/build/ts/surfaces/customer-account/targets/customer-account.profile.payment.render-after.d.ts +3 -0
  117. package/build/ts/surfaces/point-of-sale/components/Badge.d.ts +10 -1
  118. package/build/ts/surfaces/point-of-sale/components/Banner.d.ts +12 -4
  119. package/build/ts/surfaces/point-of-sale/components/Box.d.ts +51 -14
  120. package/build/ts/surfaces/point-of-sale/components/Button.d.ts +12 -2
  121. package/build/ts/surfaces/point-of-sale/components/Choice.d.ts +3 -2
  122. package/build/ts/surfaces/point-of-sale/components/ChoiceList.d.ts +12 -5
  123. package/build/ts/surfaces/point-of-sale/components/Clickable.d.ts +11 -4
  124. package/build/ts/surfaces/point-of-sale/components/DateField.d.ts +17 -8
  125. package/build/ts/surfaces/point-of-sale/components/DatePicker.d.ts +14 -6
  126. package/build/ts/surfaces/point-of-sale/components/DateSpinner.d.ts +10 -6
  127. package/build/ts/surfaces/point-of-sale/components/Divider.d.ts +4 -3
  128. package/build/ts/surfaces/point-of-sale/components/EmailField.d.ts +17 -7
  129. package/build/ts/surfaces/point-of-sale/components/Heading.d.ts +7 -4
  130. package/build/ts/surfaces/point-of-sale/components/Icon.d.ts +13 -3
  131. package/build/ts/surfaces/point-of-sale/components/Image.d.ts +12 -5
  132. package/build/ts/surfaces/point-of-sale/components/Modal.d.ts +28 -7
  133. package/build/ts/surfaces/point-of-sale/components/NumberField.d.ts +17 -7
  134. package/build/ts/surfaces/point-of-sale/components/Page.d.ts +25 -11
  135. package/build/ts/surfaces/point-of-sale/components/PosBlock.d.ts +12 -13
  136. package/build/ts/surfaces/point-of-sale/components/QrCode.d.ts +12 -8
  137. package/build/ts/surfaces/point-of-sale/components/ScrollBox.d.ts +47 -15
  138. package/build/ts/surfaces/point-of-sale/components/SearchField.d.ts +15 -7
  139. package/build/ts/surfaces/point-of-sale/components/Section.d.ts +15 -9
  140. package/build/ts/surfaces/point-of-sale/components/Stack.d.ts +67 -7
  141. package/build/ts/surfaces/point-of-sale/components/Text.d.ts +25 -4
  142. package/build/ts/surfaces/point-of-sale/components/TextArea.d.ts +17 -7
  143. package/build/ts/surfaces/point-of-sale/components/TextField.d.ts +9 -7
  144. package/build/ts/surfaces/point-of-sale/components/Tile.d.ts +12 -2
  145. package/build/ts/surfaces/point-of-sale/components/TimeField.d.ts +14 -6
  146. package/build/ts/surfaces/point-of-sale/components/TimePicker.d.ts +14 -6
  147. package/build/ts/surfaces/point-of-sale/components/components-shared.d.ts +102 -1
  148. package/build/tsconfig.tsbuildinfo +1 -1
  149. package/package.json +2 -1
  150. package/src/docs/shared/components/ConsentCheckbox.ts +12 -0
  151. package/src/docs/shared/components/ConsentPhoneField.ts +12 -0
  152. package/src/docs/shared/components/index.ts +2 -0
  153. package/src/surfaces/checkout/components/ConsentCheckbox/examples/basic-consent-checkbox.example.html +5 -0
  154. package/src/surfaces/checkout/components/ConsentCheckbox.d.ts +84 -0
  155. package/src/surfaces/checkout/components/ConsentPhoneField/examples/basic-consent-phone-field.example.html +5 -0
  156. package/src/surfaces/checkout/components/ConsentPhoneField.d.ts +129 -0
  157. package/src/surfaces/checkout/components/NumberField/examples/basic-number-field.example.html +8 -0
  158. package/src/surfaces/checkout/components/NumberField.d.ts +98 -0
  159. package/src/surfaces/checkout/components/PasswordField.d.ts +1 -1
  160. package/src/surfaces/checkout/components/PhoneField/examples/basic-phone-field.example.html +2 -1
  161. package/src/surfaces/checkout/components/ProductThumbnail/examples/basic-product-thumbnail.example.html +4 -1
  162. package/src/surfaces/checkout/components/Stack/examples/basic-stack.example.html +20 -4
  163. package/src/surfaces/checkout/components/TextArea/examples/basic-text-area.example.html +5 -1
  164. package/src/surfaces/checkout/components/TextField/examples/basic-text-field.example.html +4 -1
  165. package/src/surfaces/checkout/components/components-shared.d.ts +17 -0
  166. package/src/surfaces/checkout/components/components.d.ts +216 -144
  167. package/src/surfaces/checkout/preact/api.ts +1 -1
  168. package/src/surfaces/checkout/preact/tests/api.test.tsx +22 -13
  169. package/src/surfaces/checkout/preact/tests/app-metafields.test.ts +52 -56
  170. package/src/surfaces/checkout/preact/tests/attributes.test.ts +34 -24
  171. package/src/surfaces/checkout/preact/tests/billing-address.test.ts +17 -7
  172. package/src/surfaces/checkout/preact/tests/buyer-identity-businessCustomer.test.ts +16 -9
  173. package/src/surfaces/checkout/preact/tests/buyer-identity.test.tsx +57 -26
  174. package/src/surfaces/checkout/preact/tests/buyer-journey.test.ts +71 -74
  175. package/src/surfaces/checkout/preact/tests/capabilities.test.ts +32 -28
  176. package/src/surfaces/checkout/preact/tests/cart-line-target.test.ts +31 -24
  177. package/src/surfaces/checkout/preact/tests/checkout-settings.test.ts +17 -9
  178. package/src/surfaces/checkout/preact/tests/checkout-token.test.ts +16 -6
  179. package/src/surfaces/checkout/preact/tests/configuration.test.ts +16 -6
  180. package/src/surfaces/checkout/preact/tests/country.test.tsx +18 -8
  181. package/src/surfaces/checkout/preact/tests/currency.test.tsx +18 -8
  182. package/src/surfaces/checkout/preact/tests/customer-privacy.test.ts +17 -8
  183. package/src/surfaces/checkout/preact/tests/delivery-group-list-target.test.ts +24 -18
  184. package/src/surfaces/checkout/preact/tests/delivery-group-target.test.ts +25 -19
  185. package/src/surfaces/checkout/preact/tests/delivery-group.test.ts +22 -16
  186. package/src/surfaces/checkout/preact/tests/delivery-groups.test.ts +17 -11
  187. package/src/surfaces/checkout/preact/tests/delivery-selection-groups.test.ts +31 -24
  188. package/src/surfaces/checkout/preact/tests/discounts.test.tsx +21 -14
  189. package/src/surfaces/checkout/preact/tests/extension-language.test.tsx +17 -8
  190. package/src/surfaces/checkout/preact/tests/gift-cards.test.tsx +17 -8
  191. package/src/surfaces/checkout/preact/tests/localized-fields.test.ts +58 -59
  192. package/src/surfaces/checkout/preact/tests/market.test.tsx +17 -7
  193. package/src/surfaces/checkout/preact/tests/metafield.test.tsx +33 -36
  194. package/src/surfaces/checkout/preact/tests/metafields.test.tsx +36 -53
  195. package/src/surfaces/checkout/preact/tests/mount.tsx +60 -17
  196. package/src/surfaces/checkout/preact/tests/notes.test.tsx +16 -6
  197. package/src/surfaces/checkout/preact/tests/payment-method.test.ts +87 -60
  198. package/src/surfaces/checkout/preact/tests/payment-options.test.tsx +26 -24
  199. package/src/surfaces/checkout/preact/tests/pickup-location-option-target.test.tsx +55 -46
  200. package/src/surfaces/checkout/preact/tests/redeemable.test.ts +30 -23
  201. package/src/surfaces/checkout/preact/tests/session-token.test.tsx +12 -6
  202. package/src/surfaces/checkout/preact/tests/shipping-address.test.ts +17 -7
  203. package/src/surfaces/checkout/preact/tests/shipping-option-target.test.ts +54 -50
  204. package/src/surfaces/checkout/preact/tests/shopping-address.test.tsx +18 -10
  205. package/src/surfaces/checkout/preact/tests/timezone.test.tsx +17 -7
  206. package/src/surfaces/checkout/preact/tests/translate.test.tsx +18 -13
  207. package/src/surfaces/checkout/preact/tests/tsconfig.json +1 -1
  208. package/src/surfaces/checkout/shared.ts +2 -0
  209. package/src/surfaces/point-of-sale/components/Badge.d.ts +10 -1
  210. package/src/surfaces/point-of-sale/components/Banner.d.ts +12 -4
  211. package/src/surfaces/point-of-sale/components/Box.d.ts +51 -14
  212. package/src/surfaces/point-of-sale/components/Button.d.ts +12 -2
  213. package/src/surfaces/point-of-sale/components/Choice.d.ts +3 -2
  214. package/src/surfaces/point-of-sale/components/ChoiceList.d.ts +12 -5
  215. package/src/surfaces/point-of-sale/components/Clickable.d.ts +11 -4
  216. package/src/surfaces/point-of-sale/components/DateField.d.ts +17 -8
  217. package/src/surfaces/point-of-sale/components/DatePicker.d.ts +14 -6
  218. package/src/surfaces/point-of-sale/components/DateSpinner.d.ts +10 -6
  219. package/src/surfaces/point-of-sale/components/Divider.d.ts +4 -3
  220. package/src/surfaces/point-of-sale/components/EmailField.d.ts +17 -7
  221. package/src/surfaces/point-of-sale/components/Heading.d.ts +7 -4
  222. package/src/surfaces/point-of-sale/components/Icon.d.ts +13 -3
  223. package/src/surfaces/point-of-sale/components/Image.d.ts +12 -5
  224. package/src/surfaces/point-of-sale/components/Modal.d.ts +28 -7
  225. package/src/surfaces/point-of-sale/components/NumberField.d.ts +17 -7
  226. package/src/surfaces/point-of-sale/components/Page.d.ts +25 -11
  227. package/src/surfaces/point-of-sale/components/PosBlock.d.ts +12 -13
  228. package/src/surfaces/point-of-sale/components/QrCode.d.ts +12 -8
  229. package/src/surfaces/point-of-sale/components/ScrollBox.d.ts +47 -15
  230. package/src/surfaces/point-of-sale/components/SearchField.d.ts +15 -7
  231. package/src/surfaces/point-of-sale/components/Section.d.ts +15 -9
  232. package/src/surfaces/point-of-sale/components/Stack.d.ts +67 -7
  233. package/src/surfaces/point-of-sale/components/Text.d.ts +25 -4
  234. package/src/surfaces/point-of-sale/components/TextArea.d.ts +17 -7
  235. package/src/surfaces/point-of-sale/components/TextField.d.ts +9 -7
  236. package/src/surfaces/point-of-sale/components/Tile.d.ts +12 -2
  237. package/src/surfaces/point-of-sale/components/TimeField.d.ts +14 -6
  238. package/src/surfaces/point-of-sale/components/TimePicker.d.ts +14 -6
  239. package/src/surfaces/point-of-sale/components/components-shared.d.ts +102 -1
  240. package/src/surfaces/point-of-sale/components.d.ts +869 -481
  241. package/build/ts/surfaces/checkout/errors.d.ts +0 -10
  242. package/build/ts/surfaces/checkout/errors.d.ts.map +0 -1
  243. package/src/surfaces/checkout/errors.ts +0 -13
@@ -1,19 +1,29 @@
1
1
  import {useLocalizationMarket} from '../market';
2
2
 
3
- import {mount, createMockStatefulRemoteSubscribable} from './mount';
3
+ // See __mocks__/preact/hooks
4
+ jest.mock('preact/hooks');
5
+
6
+ import {
7
+ mount,
8
+ createMockSubscribableSignalLike,
9
+ setupGlobalShopifyMock,
10
+ tearDownGlobalShopifyMock,
11
+ } from './mount';
12
+
13
+ describe('useLocalizationMarket', () => {
14
+ afterEach(tearDownGlobalShopifyMock);
4
15
 
5
- describe.skip('useLocalizationMarket', () => {
6
16
  it('returns market from the api', () => {
7
17
  const market = {id: 'gid://shopify/Market/123', handle: 'apac'};
8
18
 
9
- const {value} = mount.hook(() => useLocalizationMarket(), {
10
- extensionApi: {
11
- localization: {
12
- market: createMockStatefulRemoteSubscribable(market),
13
- },
19
+ setupGlobalShopifyMock({
20
+ localization: {
21
+ market: createMockSubscribableSignalLike(market),
14
22
  },
15
23
  });
16
24
 
25
+ const {value} = mount.hook(() => useLocalizationMarket());
26
+
17
27
  expect(value).toStrictEqual(market);
18
28
  });
19
29
  });
@@ -1,15 +1,21 @@
1
1
  import {faker} from '@faker-js/faker';
2
2
 
3
- import type {Metafield} from '@shopify/ui-extensions/checkout';
3
+ import type {Metafield} from '../../api/standard/standard';
4
4
 
5
5
  import {useMetafield} from '../metafield';
6
6
 
7
- import {createMockStatefulRemoteSubscribable, mount} from './mount';
7
+ import {
8
+ createMockSubscribableSignalLike,
9
+ mount,
10
+ setupGlobalShopifyMock,
11
+ tearDownGlobalShopifyMock,
12
+ } from './mount';
8
13
 
9
- describe.skip('useMetafields', () => {
10
- afterEach(() => {
11
- jest.clearAllMocks();
12
- });
14
+ // See __mocks__/preact/hooks
15
+ jest.mock('preact/hooks');
16
+
17
+ describe('useMetafields', () => {
18
+ afterEach(tearDownGlobalShopifyMock);
13
19
 
14
20
  function createMetafield(props: Partial<Metafield> = {}): Metafield {
15
21
  return {
@@ -28,18 +34,16 @@ describe.skip('useMetafields', () => {
28
34
  it('returns undefined metafield', () => {
29
35
  const metafieldCount = 10;
30
36
 
31
- const extensionApi = {
32
- metafields: createMockStatefulRemoteSubscribable(
37
+ setupGlobalShopifyMock({
38
+ metafields: createMockSubscribableSignalLike(
33
39
  createMetafields(metafieldCount),
34
- ),
35
- };
40
+ ) as any,
41
+ });
36
42
 
37
43
  const namespace = 'test_namespace';
38
44
  const key = 'test_key';
39
45
 
40
- const {value} = mount.hook(() => useMetafield({namespace, key}), {
41
- extensionApi,
42
- });
46
+ const {value} = mount.hook(() => useMetafield({namespace, key}));
43
47
 
44
48
  expect(value).toBeUndefined();
45
49
  });
@@ -51,12 +55,12 @@ describe.skip('useMetafields', () => {
51
55
 
52
56
  const metafields = [newNamespace, ...createMetafields()];
53
57
 
54
- const {value} = mount.hook(() => useMetafield({namespace, key}), {
55
- extensionApi: {
56
- metafields: createMockStatefulRemoteSubscribable(metafields),
57
- },
58
+ setupGlobalShopifyMock({
59
+ metafields: createMockSubscribableSignalLike(metafields),
58
60
  });
59
61
 
62
+ const {value} = mount.hook(() => useMetafield({namespace, key}));
63
+
60
64
  expect(value?.namespace).toStrictEqual(namespace);
61
65
  expect(value?.key).toStrictEqual(key);
62
66
  });
@@ -64,21 +68,16 @@ describe.skip('useMetafields', () => {
64
68
  it('throws an error if no namespace is provided with key', () => {
65
69
  jest.spyOn(console, 'error').mockImplementation();
66
70
 
67
- const extensionApi = {
68
- metafields: createMockStatefulRemoteSubscribable(createMetafields()),
69
- };
71
+ setupGlobalShopifyMock({
72
+ metafields: createMockSubscribableSignalLike(createMetafields()) as any,
73
+ });
70
74
 
71
75
  expect(() =>
72
- mount.hook(
73
- () =>
74
- useMetafield({
75
- // @ts-expect-error: expected to fail
76
- namespace: undefined,
77
- key: 'test_key',
78
- }),
79
- {
80
- extensionApi,
81
- },
76
+ mount.hook(() =>
77
+ useMetafield({
78
+ namespace: undefined as unknown as string,
79
+ key: 'test_key',
80
+ }),
82
81
  ),
83
82
  ).toThrow('You must pass in both a namespace and key');
84
83
  });
@@ -86,16 +85,14 @@ describe.skip('useMetafields', () => {
86
85
  it('throws an error if no key is provided with namespace', () => {
87
86
  jest.spyOn(console, 'error').mockImplementation();
88
87
 
89
- const extensionApi = {
90
- metafields: createMockStatefulRemoteSubscribable(createMetafields()),
91
- };
88
+ setupGlobalShopifyMock({
89
+ metafields: createMockSubscribableSignalLike(createMetafields()) as any,
90
+ });
92
91
 
93
92
  const key = undefined as unknown as string;
94
93
 
95
94
  expect(() =>
96
- mount.hook(() => useMetafield({namespace: 'test_namespace', key}), {
97
- extensionApi,
98
- }),
95
+ mount.hook(() => useMetafield({namespace: 'test_namespace', key})),
99
96
  ).toThrow('You must pass in both a namespace and key');
100
97
  });
101
98
  });
@@ -1,15 +1,21 @@
1
1
  import {faker} from '@faker-js/faker';
2
2
 
3
- import type {Metafield} from '@shopify/ui-extensions/checkout';
3
+ import type {Metafield} from '../../api/standard/standard';
4
4
 
5
5
  import {useMetafields} from '../metafields';
6
6
 
7
- import {createMockStatefulRemoteSubscribable, mount} from './mount';
7
+ import {
8
+ createMockSubscribableSignalLike,
9
+ mount,
10
+ setupGlobalShopifyMock,
11
+ tearDownGlobalShopifyMock,
12
+ } from './mount';
8
13
 
9
- describe.skip('useMetafields', () => {
10
- afterEach(() => {
11
- jest.clearAllMocks();
12
- });
14
+ // See __mocks__/preact/hooks
15
+ jest.mock('preact/hooks');
16
+
17
+ describe('useMetafields', () => {
18
+ afterEach(tearDownGlobalShopifyMock);
13
19
 
14
20
  function createMetafield(props: Partial<Metafield> = {}): Metafield {
15
21
  return {
@@ -28,14 +34,14 @@ describe.skip('useMetafields', () => {
28
34
  it('returns all metafields', () => {
29
35
  const metafieldCount = 10;
30
36
 
31
- const {value} = mount.hook(() => useMetafields(), {
32
- extensionApi: {
33
- metafields: createMockStatefulRemoteSubscribable(
34
- createMetafields(metafieldCount),
35
- ),
36
- },
37
+ setupGlobalShopifyMock({
38
+ metafields: createMockSubscribableSignalLike(
39
+ createMetafields(metafieldCount),
40
+ ) as any,
37
41
  });
38
42
 
43
+ const {value} = mount.hook(() => useMetafields());
44
+
39
45
  expect(value).toHaveLength(metafieldCount);
40
46
  });
41
47
 
@@ -49,18 +55,18 @@ describe.skip('useMetafields', () => {
49
55
 
50
56
  const metafields = [newNamespace, newNamespace2, ...createMetafields()];
51
57
 
52
- const {value} = mount.hook(() => useMetafields({namespace}), {
53
- extensionApi: {
54
- metafields: createMockStatefulRemoteSubscribable(metafields),
55
- },
58
+ setupGlobalShopifyMock({
59
+ metafields: createMockSubscribableSignalLike(metafields),
56
60
  });
57
61
 
62
+ const {value} = mount.hook(() => useMetafields({namespace}));
63
+
58
64
  expect(value).toHaveLength(2);
59
65
 
60
66
  expect(value[0].namespace).toStrictEqual(namespace);
61
- expect(value[1].namespace).toStrictEqual(namespace);
62
-
63
67
  expect(value[0].key).toStrictEqual(key);
68
+
69
+ expect(value[1].namespace).toStrictEqual(namespace);
64
70
  expect(value[1].key).toStrictEqual(key2);
65
71
  });
66
72
 
@@ -69,54 +75,31 @@ describe.skip('useMetafields', () => {
69
75
  const key = 'test_key';
70
76
  const newNamespace = createMetafield({namespace, key});
71
77
 
72
- const metafields = [newNamespace, ...createMetafields()];
78
+ const key2 = 'test_key2';
79
+ const newNamespace2 = createMetafield({namespace, key: key2});
73
80
 
74
- const {value} = mount.hook(() => useMetafields({namespace, key}), {
75
- extensionApi: {
76
- metafields: createMockStatefulRemoteSubscribable(metafields),
77
- },
81
+ const metafields = [newNamespace, newNamespace2, ...createMetafields()];
82
+
83
+ setupGlobalShopifyMock({
84
+ metafields: createMockSubscribableSignalLike(metafields),
78
85
  });
79
86
 
87
+ const {value} = mount.hook(() => useMetafields({namespace, key}));
88
+
80
89
  expect(value).toHaveLength(1);
81
90
  expect(value[0].namespace).toStrictEqual(namespace);
82
91
  expect(value[0].key).toStrictEqual(key);
83
92
  });
84
93
 
85
- it('returns an empty array if no matches are found', () => {
86
- const namespace = 'test_namespace';
87
- const key = 'test_key';
88
-
89
- const metafields = createMetafields();
90
-
91
- const extensionApi = {
92
- metafields: createMockStatefulRemoteSubscribable(metafields),
93
- };
94
-
95
- const namespaceSearch = mount.hook(() => useMetafields({namespace}), {
96
- extensionApi,
97
- });
98
-
99
- const keySearch = mount.hook(() => useMetafields({namespace, key}), {
100
- extensionApi,
101
- });
102
-
103
- expect(namespaceSearch.value).toHaveLength(0);
104
- expect(keySearch.value).toHaveLength(0);
105
- });
106
-
107
94
  it('throws an error if no namespace is provided with key', () => {
108
95
  jest.spyOn(console, 'error').mockImplementation();
109
96
 
110
- const extensionApi = {
111
- metafields: createMockStatefulRemoteSubscribable(createMetafields()),
112
- };
113
-
114
- const namespace = undefined as unknown as string;
97
+ setupGlobalShopifyMock({
98
+ metafields: createMockSubscribableSignalLike(createMetafields()) as any,
99
+ });
115
100
 
116
101
  expect(() =>
117
- mount.hook(() => useMetafields({namespace, key: 'test_key'}), {
118
- extensionApi,
119
- }),
102
+ mount.hook(() => useMetafields({key: 'test_key'} as any)),
120
103
  ).toThrow('You must pass in a namespace with a key');
121
104
  });
122
105
  });
@@ -1,27 +1,28 @@
1
1
  import {createRender} from '@quilted/react-testing';
2
2
  import type {SubscribableSignalLike} from '../../shared';
3
+ import type {ExtensionTargets} from '../../extension-targets';
3
4
 
4
5
  import type {
5
6
  ApiForExtension,
6
7
  RenderExtensionTarget,
7
- } from '@shopify/ui-extensions/checkout';
8
+ } from '../../extension-targets';
9
+ import type {Extension} from '../../api/standard/standard';
8
10
 
9
- // eslint-disable-next-line no-warning-comments
10
- // TODO: remove the context and change all tests to use a mock
11
- // version of the shopify global API in beforeEach().
12
- import {ExtensionApiContext} from '../../context';
11
+ declare global {
12
+ namespace NodeJS {
13
+ interface Global {
14
+ shopify: any;
15
+ }
16
+ }
17
+ }
13
18
 
14
19
  export const mount = createRender<Options, Options>({
15
- context(options) {
20
+ context(options: Options) {
16
21
  return options;
17
22
  },
18
23
 
19
- render(element, {extensionApi}) {
20
- return (
21
- <ExtensionApiContext.Provider value={extensionApi as any}>
22
- {element}
23
- </ExtensionApiContext.Provider>
24
- );
24
+ render(element: any) {
25
+ return element;
25
26
  },
26
27
  });
27
28
 
@@ -33,20 +34,62 @@ export type PartialExtensionApi = DeepPartial<
33
34
  ApiForExtension<RenderExtensionTarget>
34
35
  >;
35
36
 
36
- interface Options {
37
- extensionApi?: PartialExtensionApi;
38
- }
37
+ interface Options {}
39
38
 
40
- export function createMockStatefulRemoteSubscribable<T>(
39
+ export function createMockSubscribableSignalLike<T>(
41
40
  value: T,
42
41
  ): SubscribableSignalLike<T> {
43
42
  const subscribable: SubscribableSignalLike<T> = {
44
43
  get current() {
45
44
  return value;
46
45
  },
47
- subscribe: jest.fn(),
46
+ get value() {
47
+ return value;
48
+ },
49
+ subscribe: jest.fn(() => () => {}),
48
50
  destroy: jest.fn(),
49
51
  };
50
52
 
51
53
  return subscribable;
52
54
  }
55
+
56
+ /**
57
+ * Helper function to set up the global shopify mock with type safety
58
+ * @param mockData Deep partial mock data for the API
59
+ */
60
+ export function setupGlobalShopifyMock<
61
+ Target extends RenderExtensionTarget = 'purchase.checkout.block.render',
62
+ >(mockData: DeepPartial<ExtensionTargets[Target]['api']>): void {
63
+ const finalMockData = {
64
+ extension: createMockExtension<Target>(
65
+ 'purchase.checkout.block.render' as Target,
66
+ ),
67
+ ...mockData,
68
+ } as DeepPartial<ExtensionTargets[Target]['api']>;
69
+
70
+ (globalThis as any).shopify = finalMockData;
71
+ }
72
+
73
+ /**
74
+ * Helper function to tear down the global shopify mock
75
+ * Call this in afterEach() to clean up the global shopify object and clear all mocks
76
+ */
77
+ export function tearDownGlobalShopifyMock(): void {
78
+ delete (globalThis as any).shopify;
79
+ jest.clearAllMocks();
80
+ }
81
+
82
+ /**
83
+ * Helper function to create a minimal extension object for testing
84
+ */
85
+ export function createMockExtension<Target extends RenderExtensionTarget>(
86
+ target: Target,
87
+ ): Extension<Target> {
88
+ return {
89
+ target,
90
+ apiVersion: '2023-07',
91
+ capabilities: createMockSubscribableSignalLike([]),
92
+ rendered: createMockSubscribableSignalLike(true),
93
+ scriptUrl: 'https://example.com/script.js',
94
+ };
95
+ }
@@ -1,15 +1,25 @@
1
1
  import {useNote} from '../note';
2
2
 
3
- import {mount, createMockStatefulRemoteSubscribable} from './mount';
3
+ // See __mocks__/preact/hooks
4
+ jest.mock('preact/hooks');
5
+
6
+ import {
7
+ mount,
8
+ createMockSubscribableSignalLike,
9
+ setupGlobalShopifyMock,
10
+ tearDownGlobalShopifyMock,
11
+ } from './mount';
12
+
13
+ describe('useNote', () => {
14
+ afterEach(tearDownGlobalShopifyMock);
4
15
 
5
- describe.skip('useNote', () => {
6
16
  it('returns the current order note', async () => {
7
17
  const note = 'the note';
8
- const extensionApi = {
9
- note: createMockStatefulRemoteSubscribable(note),
10
- };
18
+ setupGlobalShopifyMock({
19
+ note: createMockSubscribableSignalLike(note),
20
+ });
11
21
 
12
- const {value} = mount.hook(() => useNote(), {extensionApi});
22
+ const {value} = mount.hook(() => useNote());
13
23
 
14
24
  expect(value).toBe(note);
15
25
  });
@@ -1,116 +1,143 @@
1
- import type {ExtensionTarget} from '@shopify/ui-extensions/checkout';
1
+ import type {ExtensionTarget} from '../../extension-targets';
2
+
3
+ // See __mocks__/preact/hooks
4
+ jest.mock('preact/hooks');
2
5
 
3
6
  import {
4
7
  useApplyPaymentMethodAttributesChange,
5
8
  usePaymentMethodAttributeValues,
6
9
  usePaymentMethodAttributes,
7
10
  } from '../payment-method';
8
- import {ExtensionHasNoMethodError, ScopeNotGrantedError} from '../../errors';
11
+ import {
12
+ createMockSubscribableSignalLike,
13
+ mount,
14
+ setupGlobalShopifyMock,
15
+ tearDownGlobalShopifyMock,
16
+ createMockExtension,
17
+ } from './mount';
9
18
 
10
- import {createMockStatefulRemoteSubscribable, mount} from './mount';
19
+ describe('Payment Method API hooks', () => {
20
+ afterEach(tearDownGlobalShopifyMock);
11
21
 
12
- describe.skip('Payment Method API hooks', () => {
13
22
  describe('usePaymentMethodAttributes', () => {
14
23
  const paymentMethodAttributes = [{key: 'test_key', value: 'test_value'}];
15
24
 
16
25
  it('returns the paymentMethodAttributes value', async () => {
17
- const {value} = mount.hook(() => usePaymentMethodAttributes(), {
18
- extensionApi: {
19
- paymentMethodAttributes: createMockStatefulRemoteSubscribable(
20
- paymentMethodAttributes,
21
- ),
22
- },
26
+ const target =
27
+ 'purchase.checkout.payment-option-item.details.render' as const;
28
+ setupGlobalShopifyMock<typeof target>({
29
+ paymentMethodAttributes: createMockSubscribableSignalLike(
30
+ paymentMethodAttributes,
31
+ ),
32
+ extension: createMockExtension(target),
23
33
  });
34
+
35
+ const {value} = mount.hook(() => usePaymentMethodAttributes());
24
36
  expect(value).toBe(paymentMethodAttributes);
25
37
  });
26
38
 
27
39
  it('raises when paymentMethodAttributes is not available', async () => {
28
- const runner = async () => {
29
- return mount.hook(() => usePaymentMethodAttributes(), {
30
- extensionApi: {},
31
- });
32
- };
33
- await expect(runner).rejects.toThrow(ScopeNotGrantedError);
40
+ setupGlobalShopifyMock({});
41
+
42
+ expect(() => {
43
+ mount.hook(() => usePaymentMethodAttributes());
44
+ }).toThrow(
45
+ expect.objectContaining({
46
+ name: 'ScopeNotGrantedError',
47
+ }),
48
+ );
34
49
  });
35
50
  });
36
51
 
37
52
  describe('usePaymentMethodAttributeValues', () => {
38
53
  const paymentMethodAttributes = [{key: 'test_key', value: 'test_value'}];
39
- const extensionApi = {
40
- paymentMethodAttributes: createMockStatefulRemoteSubscribable(
41
- paymentMethodAttributes,
42
- ),
43
- };
44
54
 
45
55
  it('returns the paymentMethodAttributes values', async () => {
46
- const {value} = mount.hook(
47
- () => usePaymentMethodAttributeValues(['test_key']),
48
- {extensionApi},
56
+ const target =
57
+ 'purchase.checkout.payment-option-item.details.render' as const;
58
+ setupGlobalShopifyMock<typeof target>({
59
+ paymentMethodAttributes: createMockSubscribableSignalLike(
60
+ paymentMethodAttributes,
61
+ ),
62
+ extension: createMockExtension(target),
63
+ });
64
+
65
+ const {value} = mount.hook(() =>
66
+ usePaymentMethodAttributeValues(['test_key']),
49
67
  );
50
68
  expect(value).toStrictEqual(['test_value']);
51
69
  });
52
70
 
53
71
  it('returns undefined for not found keys', async () => {
54
- const {value} = mount.hook(
55
- () => usePaymentMethodAttributeValues(['test_key', 'test_key3']),
56
- {extensionApi},
72
+ const target =
73
+ 'purchase.checkout.payment-option-item.details.render' as const;
74
+ setupGlobalShopifyMock<typeof target>({
75
+ paymentMethodAttributes: createMockSubscribableSignalLike(
76
+ paymentMethodAttributes,
77
+ ),
78
+ extension: createMockExtension(target),
79
+ });
80
+
81
+ const {value} = mount.hook(() =>
82
+ usePaymentMethodAttributeValues(['test_key', 'test_key3']),
57
83
  );
58
84
  expect(value).toStrictEqual(['test_value', undefined]);
59
85
  });
60
86
 
61
87
  it('returns an empty array if payment attributes object is undefined', async () => {
62
- const {value} = mount.hook(
63
- () => usePaymentMethodAttributeValues(['test_key', 'test_key3']),
88
+ setupGlobalShopifyMock<'purchase.checkout.payment-option-item.details.render'>(
64
89
  {
65
- extensionApi: {
66
- paymentMethodAttributes:
67
- createMockStatefulRemoteSubscribable(undefined),
68
- },
90
+ paymentMethodAttributes: createMockSubscribableSignalLike(undefined),
69
91
  },
70
92
  );
93
+
94
+ const {value} = mount.hook(() =>
95
+ usePaymentMethodAttributeValues(['test_key', 'test_key3']),
96
+ );
71
97
  expect(value).toStrictEqual([]);
72
98
  });
73
99
 
74
100
  it('returns an empty array if payment attributes object is an empty array', async () => {
75
- const {value} = mount.hook(
76
- () => usePaymentMethodAttributeValues(['test_key', 'test_key3']),
101
+ setupGlobalShopifyMock<'purchase.checkout.payment-option-item.details.render'>(
77
102
  {
78
- extensionApi: {
79
- paymentMethodAttributes: createMockStatefulRemoteSubscribable([]),
80
- },
103
+ paymentMethodAttributes: createMockSubscribableSignalLike([]),
81
104
  },
82
105
  );
106
+
107
+ const {value} = mount.hook(() =>
108
+ usePaymentMethodAttributeValues(['test_key', 'test_key3']),
109
+ );
83
110
  expect(value).toStrictEqual([]);
84
111
  });
85
112
  });
86
113
 
87
114
  describe('useApplyPaymentMethodAttributesChange()', () => {
88
115
  it('returns the applyPaymentMethodAttributesChange function', async () => {
89
- const target: ExtensionTarget =
90
- 'purchase.checkout.payment-option-item.details.render';
91
- const extensionApi = {
92
- applyPaymentMethodAttributesChange: jest.fn,
93
- extension: {target},
94
- };
95
- const {value} = mount.hook(
96
- () => useApplyPaymentMethodAttributesChange(),
97
- {
98
- extensionApi,
99
- },
100
- );
101
- expect(value).toBe(jest.fn);
116
+ const target =
117
+ 'purchase.checkout.payment-option-item.details.render' as const;
118
+ const applyPaymentMethodAttributesChange = jest.fn();
119
+ setupGlobalShopifyMock<typeof target>({
120
+ applyPaymentMethodAttributesChange,
121
+ extension: createMockExtension(target),
122
+ });
123
+
124
+ const {value} = mount.hook(() => useApplyPaymentMethodAttributesChange());
125
+ expect(value).toBe(applyPaymentMethodAttributesChange);
102
126
  });
103
127
 
104
128
  it('raises when applyPaymentMethodAttributesChange is not available', async () => {
105
- const runner = async () => {
106
- const target: ExtensionTarget = 'purchase.checkout.block.render';
107
- return mount.hook(() => useApplyPaymentMethodAttributesChange(), {
108
- extensionApi: {
109
- extension: {target},
110
- },
111
- });
112
- };
113
- await expect(runner).rejects.toThrow(ExtensionHasNoMethodError);
129
+ const target: ExtensionTarget = 'purchase.checkout.block.render';
130
+ setupGlobalShopifyMock({
131
+ extension: createMockExtension(target),
132
+ });
133
+
134
+ expect(() => {
135
+ mount.hook(() => useApplyPaymentMethodAttributesChange());
136
+ }).toThrow(
137
+ expect.objectContaining({
138
+ name: 'ExtensionHasNoMethodError',
139
+ }),
140
+ );
114
141
  });
115
142
  });
116
143
  });