@anker-in/shopify-react 0.1.1-beta.5 → 0.1.1-beta.51
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.
- package/dist/adapters/index.d.mts +18 -3
- package/dist/adapters/index.d.ts +18 -3
- package/dist/adapters/index.js +15 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +15 -1
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +1984 -9
- package/dist/hooks/index.d.ts +1984 -9
- package/dist/hooks/index.js +1392 -1245
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1384 -1237
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1830 -1647
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1817 -1617
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +29 -15
- package/dist/provider/index.d.ts +29 -15
- package/dist/provider/index.js +404 -322
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +404 -322
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-CICUnw0v.d.mts → types-CMMWxyUF.d.mts} +12 -58
- package/dist/{types-CICUnw0v.d.ts → types-CMMWxyUF.d.ts} +12 -58
- package/dist/{types-BLMoxbOk.d.mts → types-SKDHauqk.d.mts} +14 -9
- package/dist/{types-BLMoxbOk.d.ts → types-SKDHauqk.d.ts} +14 -9
- package/package.json +3 -3
- package/dist/index-BTb1ZIF-.d.ts +0 -1949
- package/dist/index-eFsqDs13.d.mts +0 -1949
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as swr_mutation from 'swr/mutation';
|
|
2
|
-
import { SWRMutationConfiguration } from 'swr/mutation';
|
|
3
1
|
import { NormalizedProductVariant, NormalizedProduct, MoneyV2, NormalizedCart } from '@anker-in/shopify-sdk';
|
|
4
2
|
|
|
5
3
|
/**
|
|
@@ -100,6 +98,10 @@ type AddToCartLineItem = {
|
|
|
100
98
|
key: string;
|
|
101
99
|
value: string;
|
|
102
100
|
}>;
|
|
101
|
+
coupon?: {
|
|
102
|
+
code: string;
|
|
103
|
+
amount: number;
|
|
104
|
+
};
|
|
103
105
|
};
|
|
104
106
|
interface AddToCartInput {
|
|
105
107
|
/** Lines to add */
|
|
@@ -131,37 +133,6 @@ interface UseAddToCartOptions {
|
|
|
131
133
|
/** Enable tracking (GA and FBQ) */
|
|
132
134
|
withTrack?: boolean;
|
|
133
135
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Hook for adding items to cart with tracking support
|
|
136
|
-
*
|
|
137
|
-
* This is the enhanced version that includes:
|
|
138
|
-
* - Automatic cart creation if needed
|
|
139
|
-
* - Discount code validation
|
|
140
|
-
* - Google Analytics tracking
|
|
141
|
-
* - Facebook Pixel tracking
|
|
142
|
-
* - Invalid code handling
|
|
143
|
-
*
|
|
144
|
-
* @param options - Hook configuration
|
|
145
|
-
* @param swrOptions - SWR mutation configuration
|
|
146
|
-
* @returns SWR mutation with trigger function
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```tsx
|
|
150
|
-
* const { trigger, isMutating } = useAddToCart({ withTrack: true})
|
|
151
|
-
*
|
|
152
|
-
* await trigger({
|
|
153
|
-
* lineItems: [{
|
|
154
|
-
* variantId: 'gid://shopify/ProductVariant/123',
|
|
155
|
-
* quantity: 2
|
|
156
|
-
* }],
|
|
157
|
-
* gtmParams: {
|
|
158
|
-
* pageGroup: 'PDP',
|
|
159
|
-
* position: 'Add to Cart Button'
|
|
160
|
-
* }
|
|
161
|
-
* })
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
declare function useAddToCart({ withTrack }?: UseAddToCartOptions, swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, string, AddToCartInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, string, AddToCartInput>;
|
|
165
136
|
|
|
166
137
|
/**
|
|
167
138
|
* Plus Member Types
|
|
@@ -524,36 +495,19 @@ type PlusMemberSettingsMetafields = {
|
|
|
524
495
|
confirmBtn: string;
|
|
525
496
|
};
|
|
526
497
|
};
|
|
527
|
-
type
|
|
528
|
-
product: NormalizedProduct;
|
|
529
|
-
|
|
530
|
-
} | null;
|
|
531
|
-
type DeliveryOption = string;
|
|
498
|
+
type SelectedPlusMemberVariant = (NormalizedProductVariant & {
|
|
499
|
+
product: NormalizedProduct | undefined;
|
|
500
|
+
}) | undefined;
|
|
532
501
|
type DeliveryCustomData = {
|
|
533
502
|
discount_code?: string[];
|
|
534
503
|
allow_nextday_delivery?: boolean;
|
|
535
504
|
allow_thirdday_delivery?: boolean;
|
|
536
|
-
selected_delivery_option?:
|
|
505
|
+
selected_delivery_option?: {
|
|
506
|
+
code?: string;
|
|
507
|
+
mode?: string;
|
|
508
|
+
};
|
|
537
509
|
is_presale?: boolean;
|
|
538
510
|
plus_type?: DeliveryPlusType;
|
|
539
511
|
};
|
|
540
|
-
type MailingAddress = {
|
|
541
|
-
address1?: string | null;
|
|
542
|
-
address2?: string | null;
|
|
543
|
-
city?: string | null;
|
|
544
|
-
company?: string | null;
|
|
545
|
-
country?: string | null;
|
|
546
|
-
countryCode?: string | null;
|
|
547
|
-
firstName?: string | null;
|
|
548
|
-
lastName?: string | null;
|
|
549
|
-
phone?: string | null;
|
|
550
|
-
province?: string | null;
|
|
551
|
-
provinceCode?: string | null;
|
|
552
|
-
zip?: string | null;
|
|
553
|
-
};
|
|
554
|
-
type DeliveryData = {
|
|
555
|
-
deliveryAddress: MailingAddress;
|
|
556
|
-
deliveryCustomData: DeliveryCustomData;
|
|
557
|
-
};
|
|
558
512
|
|
|
559
|
-
export { type AddToCartLineItem as A, type BuyNowTrackConfig as B, DeliveryPlusType as D, type GtmParams as G,
|
|
513
|
+
export { type AddToCartLineItem as A, type BuyNowTrackConfig as B, DeliveryPlusType as D, type GtmParams as G, PLUS_MEMBER_TYPE as P, ShippingMethodMode as S, type UseAddToCartOptions as U, type AddToCartInput as a, PlusMemberMode as b, type PlusMemberShippingMethodMetafields as c, type PlusMemberShippingMethodConfig as d, type PlusMemberSettingsMetafields as e, type SelectedPlusMemberVariant as f, type DeliveryCustomData as g, gaTrack as h, trackBeginCheckoutGA as i, trackBuyNowGA as j, trackAddToCartFBQ as k, trackBuyNowFBQ as l, trackAddToCartGA as t };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as swr_mutation from 'swr/mutation';
|
|
2
|
-
import { SWRMutationConfiguration } from 'swr/mutation';
|
|
3
1
|
import { NormalizedProductVariant, NormalizedProduct, MoneyV2, NormalizedCart } from '@anker-in/shopify-sdk';
|
|
4
2
|
|
|
5
3
|
/**
|
|
@@ -100,6 +98,10 @@ type AddToCartLineItem = {
|
|
|
100
98
|
key: string;
|
|
101
99
|
value: string;
|
|
102
100
|
}>;
|
|
101
|
+
coupon?: {
|
|
102
|
+
code: string;
|
|
103
|
+
amount: number;
|
|
104
|
+
};
|
|
103
105
|
};
|
|
104
106
|
interface AddToCartInput {
|
|
105
107
|
/** Lines to add */
|
|
@@ -131,37 +133,6 @@ interface UseAddToCartOptions {
|
|
|
131
133
|
/** Enable tracking (GA and FBQ) */
|
|
132
134
|
withTrack?: boolean;
|
|
133
135
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Hook for adding items to cart with tracking support
|
|
136
|
-
*
|
|
137
|
-
* This is the enhanced version that includes:
|
|
138
|
-
* - Automatic cart creation if needed
|
|
139
|
-
* - Discount code validation
|
|
140
|
-
* - Google Analytics tracking
|
|
141
|
-
* - Facebook Pixel tracking
|
|
142
|
-
* - Invalid code handling
|
|
143
|
-
*
|
|
144
|
-
* @param options - Hook configuration
|
|
145
|
-
* @param swrOptions - SWR mutation configuration
|
|
146
|
-
* @returns SWR mutation with trigger function
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```tsx
|
|
150
|
-
* const { trigger, isMutating } = useAddToCart({ withTrack: true})
|
|
151
|
-
*
|
|
152
|
-
* await trigger({
|
|
153
|
-
* lineItems: [{
|
|
154
|
-
* variantId: 'gid://shopify/ProductVariant/123',
|
|
155
|
-
* quantity: 2
|
|
156
|
-
* }],
|
|
157
|
-
* gtmParams: {
|
|
158
|
-
* pageGroup: 'PDP',
|
|
159
|
-
* position: 'Add to Cart Button'
|
|
160
|
-
* }
|
|
161
|
-
* })
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
declare function useAddToCart({ withTrack }?: UseAddToCartOptions, swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, string, AddToCartInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, string, AddToCartInput>;
|
|
165
136
|
|
|
166
137
|
/**
|
|
167
138
|
* Plus Member Types
|
|
@@ -524,36 +495,19 @@ type PlusMemberSettingsMetafields = {
|
|
|
524
495
|
confirmBtn: string;
|
|
525
496
|
};
|
|
526
497
|
};
|
|
527
|
-
type
|
|
528
|
-
product: NormalizedProduct;
|
|
529
|
-
|
|
530
|
-
} | null;
|
|
531
|
-
type DeliveryOption = string;
|
|
498
|
+
type SelectedPlusMemberVariant = (NormalizedProductVariant & {
|
|
499
|
+
product: NormalizedProduct | undefined;
|
|
500
|
+
}) | undefined;
|
|
532
501
|
type DeliveryCustomData = {
|
|
533
502
|
discount_code?: string[];
|
|
534
503
|
allow_nextday_delivery?: boolean;
|
|
535
504
|
allow_thirdday_delivery?: boolean;
|
|
536
|
-
selected_delivery_option?:
|
|
505
|
+
selected_delivery_option?: {
|
|
506
|
+
code?: string;
|
|
507
|
+
mode?: string;
|
|
508
|
+
};
|
|
537
509
|
is_presale?: boolean;
|
|
538
510
|
plus_type?: DeliveryPlusType;
|
|
539
511
|
};
|
|
540
|
-
type MailingAddress = {
|
|
541
|
-
address1?: string | null;
|
|
542
|
-
address2?: string | null;
|
|
543
|
-
city?: string | null;
|
|
544
|
-
company?: string | null;
|
|
545
|
-
country?: string | null;
|
|
546
|
-
countryCode?: string | null;
|
|
547
|
-
firstName?: string | null;
|
|
548
|
-
lastName?: string | null;
|
|
549
|
-
phone?: string | null;
|
|
550
|
-
province?: string | null;
|
|
551
|
-
provinceCode?: string | null;
|
|
552
|
-
zip?: string | null;
|
|
553
|
-
};
|
|
554
|
-
type DeliveryData = {
|
|
555
|
-
deliveryAddress: MailingAddress;
|
|
556
|
-
deliveryCustomData: DeliveryCustomData;
|
|
557
|
-
};
|
|
558
512
|
|
|
559
|
-
export { type AddToCartLineItem as A, type BuyNowTrackConfig as B, DeliveryPlusType as D, type GtmParams as G,
|
|
513
|
+
export { type AddToCartLineItem as A, type BuyNowTrackConfig as B, DeliveryPlusType as D, type GtmParams as G, PLUS_MEMBER_TYPE as P, ShippingMethodMode as S, type UseAddToCartOptions as U, type AddToCartInput as a, PlusMemberMode as b, type PlusMemberShippingMethodMetafields as c, type PlusMemberShippingMethodConfig as d, type PlusMemberSettingsMetafields as e, type SelectedPlusMemberVariant as f, type DeliveryCustomData as g, gaTrack as h, trackBeginCheckoutGA as i, trackBuyNowGA as j, trackAddToCartFBQ as k, trackBuyNowFBQ as l, trackAddToCartGA as t };
|
|
@@ -29,14 +29,6 @@ interface RouterAdapter {
|
|
|
29
29
|
replace(url: string): void | Promise<void>;
|
|
30
30
|
getLocalizedPath?(path: string, locale?: string): string;
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Cart cookie adapter interface
|
|
34
|
-
*/
|
|
35
|
-
interface CartCookieAdapter {
|
|
36
|
-
getCartId(locale: string): string | undefined;
|
|
37
|
-
setCartId(locale: string, cartId: string): void;
|
|
38
|
-
removeCartId(locale: string): void;
|
|
39
|
-
}
|
|
40
32
|
/**
|
|
41
33
|
* User context adapter interface
|
|
42
34
|
*/
|
|
@@ -50,5 +42,18 @@ interface UserContextAdapter {
|
|
|
50
42
|
};
|
|
51
43
|
isLoggedIn: boolean;
|
|
52
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Performance adapter interface for tracking performance metrics
|
|
47
|
+
*/
|
|
48
|
+
interface PerformanceAdapter {
|
|
49
|
+
/**
|
|
50
|
+
* Start tracking a performance event
|
|
51
|
+
*/
|
|
52
|
+
addToCartStart(): void;
|
|
53
|
+
/**
|
|
54
|
+
* End tracking a performance event
|
|
55
|
+
*/
|
|
56
|
+
addToCartEnd(): void;
|
|
57
|
+
}
|
|
53
58
|
|
|
54
|
-
export type { CookieAdapter as C, RouterAdapter as R, UserContextAdapter as U, CookieOptions as a
|
|
59
|
+
export type { CookieAdapter as C, PerformanceAdapter as P, RouterAdapter as R, UserContextAdapter as U, CookieOptions as a };
|
|
@@ -29,14 +29,6 @@ interface RouterAdapter {
|
|
|
29
29
|
replace(url: string): void | Promise<void>;
|
|
30
30
|
getLocalizedPath?(path: string, locale?: string): string;
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Cart cookie adapter interface
|
|
34
|
-
*/
|
|
35
|
-
interface CartCookieAdapter {
|
|
36
|
-
getCartId(locale: string): string | undefined;
|
|
37
|
-
setCartId(locale: string, cartId: string): void;
|
|
38
|
-
removeCartId(locale: string): void;
|
|
39
|
-
}
|
|
40
32
|
/**
|
|
41
33
|
* User context adapter interface
|
|
42
34
|
*/
|
|
@@ -50,5 +42,18 @@ interface UserContextAdapter {
|
|
|
50
42
|
};
|
|
51
43
|
isLoggedIn: boolean;
|
|
52
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Performance adapter interface for tracking performance metrics
|
|
47
|
+
*/
|
|
48
|
+
interface PerformanceAdapter {
|
|
49
|
+
/**
|
|
50
|
+
* Start tracking a performance event
|
|
51
|
+
*/
|
|
52
|
+
addToCartStart(): void;
|
|
53
|
+
/**
|
|
54
|
+
* End tracking a performance event
|
|
55
|
+
*/
|
|
56
|
+
addToCartEnd(): void;
|
|
57
|
+
}
|
|
53
58
|
|
|
54
|
-
export type { CookieAdapter as C, RouterAdapter as R, UserContextAdapter as U, CookieOptions as a
|
|
59
|
+
export type { CookieAdapter as C, PerformanceAdapter as P, RouterAdapter as R, UserContextAdapter as U, CookieOptions as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anker-in/shopify-react",
|
|
3
|
-
"version": "0.1.1-beta.
|
|
3
|
+
"version": "0.1.1-beta.51",
|
|
4
4
|
"description": "React hooks and components for Shopify SDK",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"decimal.js": "^10.6.0",
|
|
32
32
|
"js-cookie": "^3.0.5",
|
|
33
33
|
"swr": "^2.2.0",
|
|
34
|
-
"@anker-in/shopify-core": "0.1.1-beta.
|
|
35
|
-
"@anker-in/shopify-sdk": "0.1.1-beta.
|
|
34
|
+
"@anker-in/shopify-core": "0.1.1-beta.10",
|
|
35
|
+
"@anker-in/shopify-sdk": "0.1.1-beta.19"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=18.0.0",
|