@rebuy/rebuy-hydrogen 3.0.0-beta.10 → 3.0.0-beta.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 (97) hide show
  1. package/dist/components/AddToCartBtn/AddToCartBtn.d.ts.map +1 -1
  2. package/dist/components/AddToCartBtn/HydrogenAddToCartBtn.d.ts.map +1 -1
  3. package/dist/components/AddToCartBtn/HydrogenReactAddToCartBtn.d.ts.map +1 -1
  4. package/dist/components/ProductCard/ProductCard.d.ts.map +1 -1
  5. package/dist/components/ProductPrice/ProductPrice.d.ts +1 -1
  6. package/dist/components/ProductPrice/ProductPrice.d.ts.map +1 -1
  7. package/dist/components/VariantSelect/VariantSelect.d.ts +1 -1
  8. package/dist/components/VariantSelect/VariantSelect.d.ts.map +1 -1
  9. package/dist/hooks/titleLevel.d.ts.map +1 -1
  10. package/dist/index.css +88 -88
  11. package/dist/index.css.map +4 -4
  12. package/dist/index.js +421 -195
  13. package/dist/index.js.map +4 -4
  14. package/dist/index.mjs +430 -196
  15. package/dist/index.mjs.map +4 -4
  16. package/dist/providers/RebuyHydrogenContextProvider.d.ts +1 -1
  17. package/dist/providers/RebuyHydrogenContextProvider.d.ts.map +1 -1
  18. package/dist/providers/RebuyHydrogenReactContextProvider.d.ts.map +1 -1
  19. package/dist/providers/types.d.ts +1 -7
  20. package/dist/providers/types.d.ts.map +1 -1
  21. package/dist/types/rebuyCustom.d.ts +0 -1
  22. package/dist/types/rebuyCustom.d.ts.map +1 -1
  23. package/dist/types/shopify.d.ts.map +1 -1
  24. package/dist/types/widgets.d.ts +1 -1
  25. package/dist/types/widgets.d.ts.map +1 -1
  26. package/dist/utils/convertToRebuyProduct.d.ts.map +1 -1
  27. package/dist/utils/createContextParameters.d.ts.map +1 -1
  28. package/dist/utils/getEncodedAttributes.d.ts.map +1 -1
  29. package/dist/utils/getRebuyConfig.d.ts +1 -1
  30. package/dist/utils/getRebuyConfig.d.ts.map +1 -1
  31. package/dist/widgetContainer/RebuyWidgetContainer.d.ts +1 -1
  32. package/dist/widgetContainer/RebuyWidgetContainer.d.ts.map +1 -1
  33. package/dist/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.d.ts.map +1 -1
  34. package/dist/widgets/RebuyDynamicBundleProducts/BundleImages.d.ts.map +1 -1
  35. package/dist/widgets/RebuyDynamicBundleProducts/BundlePrice.d.ts.map +1 -1
  36. package/dist/widgets/RebuyDynamicBundleProducts/BundleSelection.d.ts +1 -1
  37. package/dist/widgets/RebuyDynamicBundleProducts/BundleSelection.d.ts.map +1 -1
  38. package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts.map +1 -1
  39. package/dist/widgets/RebuyDynamicBundleProducts/Select.d.ts.map +1 -1
  40. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOnCard.d.ts.map +1 -1
  41. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts.map +1 -1
  42. package/dist/widgets/RebuyProductAddOns/types.d.ts.map +1 -1
  43. package/dist/widgets/RebuyProductRecommendations/RebuyProductRecommendations.d.ts.map +1 -1
  44. package/package.json +36 -48
  45. package/src/components/AddToCartBtn/AddToCartBtn.tsx +45 -0
  46. package/src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx +43 -0
  47. package/src/components/AddToCartBtn/HydrogenReactAddToCartBtn.tsx +35 -0
  48. package/src/components/AddToCartBtn/index.ts +1 -0
  49. package/src/components/AddToCartBtn/types.ts +27 -0
  50. package/src/components/ProductCard/ProductCard.tsx +70 -0
  51. package/src/components/ProductCard/index.ts +1 -0
  52. package/src/components/ProductCard/types.ts +10 -0
  53. package/src/components/ProductPrice/ProductPrice.tsx +49 -0
  54. package/src/components/ProductPrice/index.ts +1 -0
  55. package/src/components/Title/Title.tsx +19 -0
  56. package/src/components/Title/index.ts +1 -0
  57. package/src/components/Title/types.ts +7 -0
  58. package/src/components/VariantSelect/VariantSelect.tsx +45 -0
  59. package/src/components/VariantSelect/index.ts +1 -0
  60. package/src/components/VariantSelect/types.ts +6 -0
  61. package/src/context/RebuyContext.tsx +9 -0
  62. package/src/hooks/titleLevel.tsx +42 -0
  63. package/src/index.ts +7 -0
  64. package/src/providers/RebuyHydrogenContextProvider.tsx +112 -0
  65. package/src/providers/RebuyHydrogenReactContextProvider.tsx +192 -0
  66. package/src/providers/types.ts +58 -0
  67. package/src/queries/cart.queries.ts +467 -0
  68. package/src/types/common.ts +8 -0
  69. package/src/types/css.d.ts +11 -0
  70. package/src/types/env.d.ts +12 -0
  71. package/src/types/rebuy.d.ts +31 -0
  72. package/src/types/rebuyCustom.ts +263 -0
  73. package/src/types/rebuySmartCart.ts +188 -0
  74. package/src/types/shopify.ts +142 -0
  75. package/src/types/widgets.ts +29 -0
  76. package/src/utils/convertToRebuyProduct.tsx +319 -0
  77. package/src/utils/createContextParameters.ts +142 -0
  78. package/src/utils/getEncodedAttributes.ts +11 -0
  79. package/src/utils/getRebuyConfig.ts +31 -0
  80. package/src/widgetContainer/RebuyWidgetContainer.tsx +183 -0
  81. package/src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx +50 -0
  82. package/src/widgets/RebuyCompleteTheLook/index.ts +1 -0
  83. package/src/widgets/RebuyCompleteTheLook/types.ts +5 -0
  84. package/src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx +62 -0
  85. package/src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx +93 -0
  86. package/src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx +65 -0
  87. package/src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx +118 -0
  88. package/src/widgets/RebuyDynamicBundleProducts/Select.tsx +41 -0
  89. package/src/widgets/RebuyDynamicBundleProducts/index.ts +1 -0
  90. package/src/widgets/RebuyDynamicBundleProducts/types.ts +23 -0
  91. package/src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx +66 -0
  92. package/src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx +218 -0
  93. package/src/widgets/RebuyProductAddOns/index.ts +1 -0
  94. package/src/widgets/RebuyProductAddOns/types.ts +24 -0
  95. package/src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx +50 -0
  96. package/src/widgets/RebuyProductRecommendations/index.ts +1 -0
  97. package/src/widgets/RebuyProductRecommendations/types.ts +5 -0
@@ -0,0 +1,263 @@
1
+ import type {
2
+ Attribute,
3
+ CartLine,
4
+ Collection,
5
+ ComponentizableCartLine,
6
+ MoneyV2,
7
+ Product,
8
+ ProductVariant,
9
+ SelectedOption,
10
+ } from '@shopify/hydrogen-react/storefront-api-types';
11
+ import type { SmartCart } from '~/types/rebuySmartCart';
12
+ import type {
13
+ HydrogenCollection,
14
+ HydrogenProduct,
15
+ HydrogenProductVariant,
16
+ } from '~/types/shopify';
17
+
18
+ export type RebuyContextProps = {
19
+ cacheKey?: string;
20
+ cartAttributes?: Attribute[];
21
+ cartId?: string;
22
+ // Depending on where the cart is coming from hydrogen or hydrogen-react the objects are very differetn and this is the only way to account for that
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ cartLines?: (CartLine | ComponentizableCartLine)[] | any;
25
+ cartLinesLength?: number;
26
+ cartNote?: string;
27
+ cartSubtotal?: string;
28
+ cartTotalQuantity?: number;
29
+ isHydrogenReact: boolean;
30
+ queryObject: Record<string, string>;
31
+ windowUrl: string;
32
+ };
33
+
34
+ export type RebuyConfig = {
35
+ shop: RebuyShop | null;
36
+ smart_cart: SmartCart | null;
37
+ smart_flows: unknown[]; // TODO: Define type for smart_flows still in beta development
38
+ };
39
+
40
+ export type RebuyResponse = {
41
+ data: RebuyConfig;
42
+ response: unknown;
43
+ };
44
+
45
+ export type ContextParameters = {
46
+ cache_key?: string;
47
+ cart?: CartContext;
48
+ cart_count: number;
49
+ cart_item_count: number;
50
+ cart_line_count: number;
51
+ cart_subtotal: number;
52
+ cart_token?: string;
53
+ isHydrogenReact: boolean; // This detemines if a user is using just Hydrogen or Hydrogen-React. It will determine how we get the cart info
54
+ time: string;
55
+ url: string;
56
+ };
57
+
58
+ type RebuyShopIntegrations = {
59
+ attentive: boolean;
60
+ judgeme: boolean;
61
+ junip: boolean;
62
+ klaviyo: boolean;
63
+ loox: boolean;
64
+ okendo: boolean;
65
+ opinew: boolean;
66
+ recharge: boolean;
67
+ reviewsio: boolean;
68
+ stamped: boolean;
69
+ yotpo: boolean;
70
+ };
71
+
72
+ type RebuyShop = {
73
+ active_experiments: unknown[];
74
+ api_key: string;
75
+ cache_key: string;
76
+ carousel: string;
77
+ currency: string;
78
+ currency_symbol: string;
79
+ domain: string;
80
+ enabled_presentment_currencies: string[];
81
+ has_smart_collections_enabled: boolean;
82
+ has_smart_search_enabled: boolean;
83
+ id: string;
84
+ integrations: RebuyShopIntegrations;
85
+ money_format: string;
86
+ myshopify_domain: string;
87
+ primary_locale: string;
88
+ product_groups_enabled: string;
89
+ rebuy_assistant: boolean;
90
+ recharge_custom_domain: string | null;
91
+ selling_plans_enabled: boolean;
92
+ shop_id: number;
93
+ shop_name: string;
94
+ shopify_selling_plans_enabled: boolean;
95
+ storefront_access_token: string | null;
96
+ };
97
+
98
+ export type CartContext = {
99
+ attributes: string;
100
+ item_count: number;
101
+ items: CartItem[];
102
+ line_count: number;
103
+ note: string;
104
+ subtotal: number;
105
+ token: string;
106
+ };
107
+
108
+ export type CartItem = {
109
+ attributes: Attribute[];
110
+ product_id: string;
111
+ properties: string;
112
+ quantity: number;
113
+ variant_id: string;
114
+ };
115
+
116
+ export type RebuyWidgetContainerProps = {
117
+ children?: React.ReactNode;
118
+ collection?: Collection | HydrogenCollection;
119
+ collectionId?: string;
120
+ dataSource?: string;
121
+ limit?: number;
122
+ // wasn't to sure of how we wanted to handle this type. It's my understanding that clients could create their own endpoints so I'm not sure we want to lock down the type
123
+ options?: object;
124
+ product?: Product | HydrogenProduct;
125
+ productId?: string;
126
+ variant?: ProductVariant | HydrogenProductVariant;
127
+ variantId?: string;
128
+ };
129
+
130
+ export type RebuyProduct = {
131
+ collections: { nodes: { handle: string }[] };
132
+ compareAtPriceRange: {
133
+ maxVariantCompareAtPrice: MoneyV2 | null;
134
+ minVariantCompareAtPrice: MoneyV2 | null;
135
+ };
136
+ description: string;
137
+ descriptionHtml: string;
138
+ featuredImage: {
139
+ altText: string | null;
140
+ height: number;
141
+ id: string;
142
+ url: string;
143
+ width: number;
144
+ };
145
+ handle: string;
146
+ id: string;
147
+ images: {
148
+ altText: string | null;
149
+ height: number;
150
+ id: string;
151
+ url: string;
152
+ width: number;
153
+ }[];
154
+ media: unknown[];
155
+ metafields: unknown[];
156
+ options: {
157
+ name: string;
158
+ values: string[];
159
+ }[];
160
+ priceRange: {
161
+ maxVariantPrice: MoneyV2;
162
+ minVariantPrice: MoneyV2;
163
+ };
164
+ selected: boolean;
165
+ selectedOptions: Record<string, string>;
166
+ selectedSellingPlan: unknown;
167
+ selectedSellingPlanAllocation: unknown;
168
+ selectedVariant: RebuyProductVariant;
169
+ sellingPlanGroups: unknown[];
170
+ seo: {
171
+ description: string | null;
172
+ title: string | null;
173
+ };
174
+ title: string;
175
+ variants: {
176
+ nodes: RebuyProductVariant[];
177
+ };
178
+ vendor: string;
179
+ };
180
+
181
+ export type RebuyProductVariant = {
182
+ availableForSale: boolean;
183
+ compareAtPriceV2: MoneyV2 | null;
184
+ id: string;
185
+ image?: {
186
+ altText: string | null;
187
+ height: number;
188
+ id: string;
189
+ url: string;
190
+ width: number;
191
+ };
192
+ priceV2: MoneyV2;
193
+ product: {
194
+ handle: string;
195
+ id: string;
196
+ title: string;
197
+ vendor: string;
198
+ };
199
+ selectedOptions: Pick<SelectedOption, 'name' | 'value'>[];
200
+ sku: string;
201
+ title: string;
202
+ };
203
+
204
+ export type RebuyWidgetMetadata = {
205
+ also_bot_tracking_ids?: number[];
206
+ cache_info?: {
207
+ cache_key: string;
208
+ cache_key_readable: string;
209
+ cached_at_time: number | string;
210
+ };
211
+ purchased_quantity?: string;
212
+ shopify_customer: Customer;
213
+ top_sellers_filled?: boolean;
214
+ trending_products_filled?: boolean;
215
+ };
216
+
217
+ export type Customer = {
218
+ accepts_marketing: boolean;
219
+ accepts_marketing_updated_at: string;
220
+ addresses: Address[];
221
+ admin_graphql_api_id: string;
222
+ created_at: string;
223
+ currency: string;
224
+ default_address: Address;
225
+ email: string;
226
+ first_name: string;
227
+ id: number;
228
+ last_name: string;
229
+ last_order_id: string;
230
+ last_order_name: string;
231
+ marketing_opt_in_level: string;
232
+ multipass_identifier: string;
233
+ note: string;
234
+ orders_count: number;
235
+ phone: string;
236
+ state: string;
237
+ tags: string;
238
+ tax_exempt: boolean;
239
+ tax_exemptions: unknown[];
240
+ total_spent: string;
241
+ updated_at: string;
242
+ verified_email: boolean;
243
+ };
244
+
245
+ export type Address = {
246
+ address1: string;
247
+ address2: string;
248
+ city: string;
249
+ company: string;
250
+ country: string;
251
+ country_code: string;
252
+ country_name: string;
253
+ customer_id: number;
254
+ default: boolean;
255
+ first_name: string;
256
+ id: number;
257
+ last_name: string;
258
+ name: string;
259
+ phone: string;
260
+ province: string;
261
+ province_code: string;
262
+ zip: string;
263
+ };
@@ -0,0 +1,188 @@
1
+ export type ProgressBarTier = {
2
+ id: number;
3
+ minimum: number | null;
4
+ presentment_currencies: {
5
+ enabled: boolean;
6
+ };
7
+ product_amount_reached_label: boolean;
8
+ product_amount_reached_label_text: string;
9
+ product_amount_remaining_label: boolean;
10
+ product_amount_remaining_label_text: string;
11
+ products: unknown[];
12
+ type: string;
13
+ };
14
+
15
+ export type ProgressBar = {
16
+ country_codes: string[];
17
+ exclude_discount: boolean;
18
+ free_shipping_enabled: boolean;
19
+ free_shipping_on_all_products: boolean;
20
+ free_shipping_on_subscription: boolean;
21
+ geolocation_enabled: boolean;
22
+ id: number;
23
+ layout: string;
24
+ name: string;
25
+ tiers: ProgressBarTier[];
26
+ };
27
+
28
+ export type SmartCartLanguage = {
29
+ bmsm_discount_message: string;
30
+ bmsm_discount_success: string;
31
+ cart_title: string;
32
+ checking_out_label: string;
33
+ checkout_label: string;
34
+ continue_shopping_label: string;
35
+ discount_button_label: string;
36
+ discount_code_label: string;
37
+ discount_invalid_message: string;
38
+ discount_label: string;
39
+ empty_cart: string;
40
+ free_shipping_helper: string;
41
+ free_shipping_reached: string;
42
+ free_shipping_remaining: string;
43
+ notes_label: string;
44
+ notes_placeholder: string;
45
+ notes_remaining_characters: string;
46
+ subtotal_plural_text: string;
47
+ subtotal_singular_text: string;
48
+ view_cart_label: string;
49
+ view_cart_working_label: string;
50
+ };
51
+
52
+ export type SmartCartComponent = {
53
+ always_visible?: boolean;
54
+ hidden?: boolean;
55
+ id: string;
56
+ settings?: unknown;
57
+ static?: boolean;
58
+ title: string;
59
+ type: string;
60
+ };
61
+
62
+ export type SmartCartAnchor = {
63
+ components: string[];
64
+ id: string;
65
+ title: string;
66
+ };
67
+
68
+ export type SmartCart = {
69
+ accelerated_checkout: {
70
+ enabled: boolean;
71
+ };
72
+ accessibility: {
73
+ heading: string;
74
+ };
75
+ anchorData: {
76
+ anchorOrder: string[];
77
+ anchors: {
78
+ [key: string]: SmartCartAnchor;
79
+ };
80
+ components: {
81
+ [key: string]: SmartCartComponent;
82
+ };
83
+ };
84
+ announcement_bar: {
85
+ enabled: boolean;
86
+ messages: string[];
87
+ };
88
+ apps: unknown[];
89
+ attribution_tracking_disabled: boolean;
90
+ buy_more_save_more: {
91
+ discount_products: unknown[];
92
+ discount_type: string;
93
+ display_type: string;
94
+ enabled: boolean;
95
+ language: {
96
+ bmsm_discount_message: string;
97
+ bmsm_discount_success: string;
98
+ };
99
+ tiers: {
100
+ discount: number;
101
+ quantity: number;
102
+ }[];
103
+ };
104
+ callbacks: {
105
+ [key: string]: {
106
+ enabled: boolean;
107
+ function: string;
108
+ };
109
+ };
110
+ cart_page_checkout_override: {
111
+ enabled: boolean;
112
+ };
113
+ checkout_button: {
114
+ enabled: boolean;
115
+ routing: string;
116
+ routing_link: string;
117
+ };
118
+ continue_shopping_button: {
119
+ enabled: boolean;
120
+ };
121
+ cross_sells: string[];
122
+ custom_css: string;
123
+ disable_cart_page: boolean;
124
+ discount: {
125
+ enabled: boolean;
126
+ use_message_only: boolean;
127
+ };
128
+ enable_product_metafields: boolean;
129
+ has_legacy_shipping: boolean;
130
+ installments: {
131
+ enabled: boolean;
132
+ payment_count: number;
133
+ provider: string;
134
+ terms_url: string;
135
+ };
136
+ integrations: {
137
+ code: string;
138
+ enabled: boolean;
139
+ };
140
+ language: SmartCartLanguage;
141
+ layout: string;
142
+ name: string;
143
+ notes: {
144
+ enabled: boolean;
145
+ limit_characters: boolean;
146
+ max_length: number;
147
+ };
148
+ pre_purchase: {
149
+ enabled: boolean;
150
+ id: string;
151
+ };
152
+ preview_mode: boolean;
153
+ product_form_redirect: string;
154
+ progress_bar: {
155
+ bars: ProgressBar[];
156
+ enabled: boolean;
157
+ };
158
+ selectors: {
159
+ cart_subtotal: string;
160
+ item_count: string;
161
+ };
162
+ shop_pay: {
163
+ enabled: boolean;
164
+ };
165
+ switch_to_subscription: {
166
+ disable_downgrade: boolean;
167
+ enabled: boolean;
168
+ language: {
169
+ downgrading_label: string;
170
+ onetime_option_group_label: string;
171
+ onetime_option_label: string;
172
+ subscription_option_group_label: string;
173
+ subscription_option_label: string;
174
+ upgrade_to_subscription_default_frequency: string;
175
+ upgrade_to_subscription_label: string;
176
+ upgrade_to_subscription_without_discount_label: string;
177
+ upgrading_label: string;
178
+ };
179
+ };
180
+ terms: {
181
+ disclaimer: string;
182
+ enabled: boolean;
183
+ };
184
+ version: number;
185
+ view_cart_button: {
186
+ enabled: boolean;
187
+ };
188
+ };
@@ -0,0 +1,142 @@
1
+ import type {
2
+ Collection,
3
+ Image,
4
+ Maybe,
5
+ MoneyV2,
6
+ PageInfo,
7
+ Product,
8
+ ProductOption,
9
+ ProductOptionValue,
10
+ ProductOptionValueSwatch,
11
+ ProductVariant,
12
+ SelectedOption,
13
+ Seo,
14
+ } from '@shopify/hydrogen-react/storefront-api-types';
15
+ import type { RebuyProductVariant } from './rebuyCustom';
16
+
17
+ export type HydrogenProduct = Pick<
18
+ Product,
19
+ | 'id'
20
+ | 'title'
21
+ | 'vendor'
22
+ | 'handle'
23
+ | 'descriptionHtml'
24
+ | 'description'
25
+ | 'encodedVariantExistence'
26
+ | 'encodedVariantAvailability'
27
+ > & {
28
+ adjacentVariants: (Pick<
29
+ ProductVariant,
30
+ 'availableForSale' | 'id' | 'sku' | 'title'
31
+ > & {
32
+ compareAtPrice?: Maybe<Pick<MoneyV2, 'amount' | 'currencyCode'>>;
33
+ image?: Maybe<
34
+ { __typename: 'Image' } & Pick<
35
+ Image,
36
+ 'id' | 'url' | 'altText' | 'width' | 'height'
37
+ >
38
+ >;
39
+ price: Pick<MoneyV2, 'amount' | 'currencyCode'>;
40
+ product: Pick<Product, 'title' | 'handle'>;
41
+ selectedOptions: Pick<SelectedOption, 'name' | 'value'>[];
42
+ unitPrice?: Maybe<Pick<MoneyV2, 'amount' | 'currencyCode'>>;
43
+ })[];
44
+ collections: {
45
+ nodes: {
46
+ handle: string;
47
+ }[];
48
+ };
49
+ featuredImage?: {
50
+ altText: string | null;
51
+ height: number;
52
+ id: string;
53
+ url: string;
54
+ width: number;
55
+ };
56
+ images: {
57
+ altText: string | null;
58
+ height: number;
59
+ id: string;
60
+ url: string;
61
+ width: number;
62
+ }[];
63
+ options: (Pick<ProductOption, 'name'> & {
64
+ optionValues: (Pick<ProductOptionValue, 'name'> & {
65
+ firstSelectableVariant?: Maybe<
66
+ Pick<
67
+ ProductVariant,
68
+ 'availableForSale' | 'id' | 'sku' | 'title'
69
+ > & {
70
+ compareAtPrice?: Maybe<
71
+ Pick<MoneyV2, 'amount' | 'currencyCode'>
72
+ >;
73
+ image?: Maybe<
74
+ { __typename: 'Image' } & Pick<
75
+ Image,
76
+ 'id' | 'url' | 'altText' | 'width' | 'height'
77
+ >
78
+ >;
79
+ price: Pick<MoneyV2, 'amount' | 'currencyCode'>;
80
+ product: Pick<Product, 'title' | 'handle'>;
81
+ selectedOptions: Pick<SelectedOption, 'name' | 'value'>[];
82
+ unitPrice?: Maybe<Pick<MoneyV2, 'amount' | 'currencyCode'>>;
83
+ }
84
+ >;
85
+ swatch?: Maybe<
86
+ Pick<ProductOptionValueSwatch, 'color'> & {
87
+ image?: Maybe<{
88
+ previewImage?: Maybe<Pick<Image, 'url'>>;
89
+ }>;
90
+ }
91
+ >;
92
+ })[];
93
+ })[];
94
+ priceRange: {
95
+ maxVariantPrice: MoneyV2;
96
+ minVariantPrice: MoneyV2;
97
+ };
98
+ selectedOrFirstAvailableVariant?: HydrogenProductVariant;
99
+ selectedVariant?: HydrogenProductVariant;
100
+ seo: Pick<Seo, 'description' | 'title'>;
101
+ variants?: {
102
+ nodes: RebuyProductVariant[];
103
+ };
104
+ };
105
+
106
+ export type HydrogenProductVariant = Pick<
107
+ ProductVariant,
108
+ 'availableForSale' | 'id' | 'sku' | 'title'
109
+ > & {
110
+ compareAtPrice?: Maybe<Pick<MoneyV2, 'amount' | 'currencyCode'>>;
111
+ image?: Maybe<
112
+ { __typename: 'Image' } & Pick<
113
+ Image,
114
+ 'id' | 'url' | 'altText' | 'width' | 'height'
115
+ >
116
+ >;
117
+ price: Pick<MoneyV2, 'amount' | 'currencyCode'>;
118
+ product: Pick<Product, 'title' | 'handle'>;
119
+ selectedOptions: Pick<SelectedOption, 'name' | 'value'>[];
120
+ unitPrice?: Maybe<Pick<MoneyV2, 'amount' | 'currencyCode'>>;
121
+ };
122
+
123
+ export type HydrogenCollection = Pick<
124
+ Collection,
125
+ 'id' | 'handle' | 'title' | 'description'
126
+ > & {
127
+ products: {
128
+ nodes: (Pick<Product, 'id' | 'handle' | 'title'> & {
129
+ featuredImage?: Maybe<
130
+ Pick<Image, 'id' | 'altText' | 'url' | 'width' | 'height'>
131
+ >;
132
+ priceRange: {
133
+ maxVariantPrice: Pick<MoneyV2, 'amount' | 'currencyCode'>;
134
+ minVariantPrice: Pick<MoneyV2, 'amount' | 'currencyCode'>;
135
+ };
136
+ })[];
137
+ pageInfo: Pick<
138
+ PageInfo,
139
+ 'hasPreviousPage' | 'hasNextPage' | 'endCursor' | 'startCursor'
140
+ >;
141
+ };
142
+ };
@@ -0,0 +1,29 @@
1
+ import type { HydrogenProduct } from '~/types/shopify';
2
+
3
+ import {
4
+ RebuyProduct,
5
+ RebuyProductVariant,
6
+ RebuyWidgetMetadata,
7
+ } from '~/types/rebuyCustom';
8
+
9
+ // Internal type with all props from container
10
+ export type WidgetContainerProvidedProps = {
11
+ dataSource: string;
12
+ isHydrogenReact: boolean;
13
+ key: string;
14
+ limit: number;
15
+ metadata: RebuyWidgetMetadata;
16
+ options: Record<string, unknown>;
17
+ product: HydrogenProduct;
18
+ productId: string;
19
+ products: RebuyProduct[];
20
+ variant: RebuyProductVariant;
21
+ variantId: string;
22
+ };
23
+
24
+ export type WidgetChildProps = {
25
+ addToCartCallback?: () => void;
26
+ customTitle?: string;
27
+ customTitleLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
28
+ customTitleStyle?: React.CSSProperties;
29
+ } & Partial<WidgetContainerProvidedProps>;