@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,11 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { ShopifyClient, ShopifyConfig, CartCookieAdapter
|
|
4
|
-
import { C as CookieAdapter,
|
|
3
|
+
import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, AttributeInput, HasMetafieldsIdentifier } from '@anker-in/shopify-sdk';
|
|
4
|
+
import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter, P as PerformanceAdapter } from '../types-SKDHauqk.mjs';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { SWRConfiguration } from 'swr';
|
|
7
|
-
import { e as PlusMemberSettingsMetafields } from '../types-
|
|
8
|
-
import 'swr/mutation';
|
|
7
|
+
import { e as PlusMemberSettingsMetafields } from '../types-CMMWxyUF.mjs';
|
|
9
8
|
|
|
10
9
|
interface ShopifyContextValue {
|
|
11
10
|
client: ShopifyClient;
|
|
@@ -16,6 +15,7 @@ interface ShopifyContextValue {
|
|
|
16
15
|
cartCookieAdapter: CartCookieAdapter;
|
|
17
16
|
routerAdapter?: RouterAdapter;
|
|
18
17
|
userAdapter?: UserContextAdapter;
|
|
18
|
+
performanceAdapter?: PerformanceAdapter;
|
|
19
19
|
}
|
|
20
20
|
declare const ShopifyContext: React.Context<ShopifyContextValue | null>;
|
|
21
21
|
|
|
@@ -24,16 +24,17 @@ interface ShopifyProviderProps {
|
|
|
24
24
|
locale: string;
|
|
25
25
|
locales?: string[];
|
|
26
26
|
cookieAdapter?: CookieAdapter;
|
|
27
|
-
cartCookieAdapter?: CartCookieAdapter
|
|
27
|
+
cartCookieAdapter?: CartCookieAdapter;
|
|
28
28
|
routerAdapter?: RouterAdapter;
|
|
29
29
|
userAdapter?: UserContextAdapter;
|
|
30
30
|
children: React__default.ReactNode;
|
|
31
|
+
performanceAdapter?: PerformanceAdapter;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Shopify Provider Component
|
|
34
35
|
* Provides Shopify context to all child components
|
|
35
36
|
*/
|
|
36
|
-
declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, performanceAdapter, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Hook to access Shopify context
|
|
@@ -41,10 +42,6 @@ declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartC
|
|
|
41
42
|
*/
|
|
42
43
|
declare function useShopify(): ShopifyContextValue;
|
|
43
44
|
|
|
44
|
-
type AttributeInput = {
|
|
45
|
-
key: string;
|
|
46
|
-
value: string;
|
|
47
|
-
};
|
|
48
45
|
type LoadingState = {
|
|
49
46
|
editLineQuantityLoading: boolean;
|
|
50
47
|
editLineCodeAmountLoading: boolean;
|
|
@@ -54,6 +51,8 @@ type LoadingState = {
|
|
|
54
51
|
interface CartContextValue {
|
|
55
52
|
/** Current cart data */
|
|
56
53
|
cart: NormalizedCart | undefined;
|
|
54
|
+
/** Total quantity of items in cart */
|
|
55
|
+
totalQuantity: number;
|
|
57
56
|
/** Whether cart is loading */
|
|
58
57
|
isCartLoading: boolean;
|
|
59
58
|
/** Manually trigger cart fetch */
|
|
@@ -66,8 +65,6 @@ interface CartContextValue {
|
|
|
66
65
|
removeCustomAttributes: (attributes: {
|
|
67
66
|
key: string;
|
|
68
67
|
}[]) => void;
|
|
69
|
-
/** Set custom attributes */
|
|
70
|
-
setCustomAttributes: (attributes: AttributeInput[]) => void;
|
|
71
68
|
/** Current locale */
|
|
72
69
|
locale: string;
|
|
73
70
|
/** Whether discount code is changing */
|
|
@@ -103,6 +100,12 @@ interface CartContextValue {
|
|
|
103
100
|
variant: HasMetafieldsIdentifier[];
|
|
104
101
|
product: HasMetafieldsIdentifier[];
|
|
105
102
|
};
|
|
103
|
+
/** User profile */
|
|
104
|
+
profile?: any;
|
|
105
|
+
/** Customer data */
|
|
106
|
+
customer?: any;
|
|
107
|
+
/** Plus member settings */
|
|
108
|
+
memberSetting?: PlusMemberSettingsMetafields;
|
|
106
109
|
}
|
|
107
110
|
interface CartProviderProps {
|
|
108
111
|
children: React__default.ReactNode;
|
|
@@ -151,14 +154,25 @@ declare function CartProvider({ children, autoFreeGiftConfig, gradientGiftsConfi
|
|
|
151
154
|
/**
|
|
152
155
|
* Hook to access cart context
|
|
153
156
|
*
|
|
154
|
-
* @
|
|
155
|
-
* @returns
|
|
157
|
+
* @param options - Optional configuration
|
|
158
|
+
* @param options.optional - If true, returns undefined instead of throwing error when used outside provider
|
|
159
|
+
* @throws Error if used outside CartProvider (unless optional is true)
|
|
160
|
+
* @returns Cart context value (or undefined if optional is true and no provider exists)
|
|
156
161
|
*
|
|
157
162
|
* @example
|
|
158
163
|
* ```tsx
|
|
159
164
|
* const { cart, mutateCart, isCartLoading, loadingState } = useCartContext()
|
|
165
|
+
*
|
|
166
|
+
* // Optional usage (safe for SSR)
|
|
167
|
+
* const cartContext = useCartContext({ optional: true })
|
|
168
|
+
* if (cartContext) {
|
|
169
|
+
* const { cart } = cartContext
|
|
170
|
+
* }
|
|
160
171
|
* ```
|
|
161
172
|
*/
|
|
162
173
|
declare function useCartContext(): CartContextValue;
|
|
174
|
+
declare function useCartContext(options: {
|
|
175
|
+
optional: true;
|
|
176
|
+
}): CartContextValue | null;
|
|
163
177
|
|
|
164
|
-
export { type
|
|
178
|
+
export { type CartContextValue, CartProvider, type CartProviderProps, type LoadingState, ShopifyContext, type ShopifyContextValue, ShopifyProvider, type ShopifyProviderProps, useCartContext, useShopify };
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { ShopifyClient, ShopifyConfig, CartCookieAdapter
|
|
4
|
-
import { C as CookieAdapter,
|
|
3
|
+
import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, AttributeInput, HasMetafieldsIdentifier } from '@anker-in/shopify-sdk';
|
|
4
|
+
import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter, P as PerformanceAdapter } from '../types-SKDHauqk.js';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { SWRConfiguration } from 'swr';
|
|
7
|
-
import { e as PlusMemberSettingsMetafields } from '../types-
|
|
8
|
-
import 'swr/mutation';
|
|
7
|
+
import { e as PlusMemberSettingsMetafields } from '../types-CMMWxyUF.js';
|
|
9
8
|
|
|
10
9
|
interface ShopifyContextValue {
|
|
11
10
|
client: ShopifyClient;
|
|
@@ -16,6 +15,7 @@ interface ShopifyContextValue {
|
|
|
16
15
|
cartCookieAdapter: CartCookieAdapter;
|
|
17
16
|
routerAdapter?: RouterAdapter;
|
|
18
17
|
userAdapter?: UserContextAdapter;
|
|
18
|
+
performanceAdapter?: PerformanceAdapter;
|
|
19
19
|
}
|
|
20
20
|
declare const ShopifyContext: React.Context<ShopifyContextValue | null>;
|
|
21
21
|
|
|
@@ -24,16 +24,17 @@ interface ShopifyProviderProps {
|
|
|
24
24
|
locale: string;
|
|
25
25
|
locales?: string[];
|
|
26
26
|
cookieAdapter?: CookieAdapter;
|
|
27
|
-
cartCookieAdapter?: CartCookieAdapter
|
|
27
|
+
cartCookieAdapter?: CartCookieAdapter;
|
|
28
28
|
routerAdapter?: RouterAdapter;
|
|
29
29
|
userAdapter?: UserContextAdapter;
|
|
30
30
|
children: React__default.ReactNode;
|
|
31
|
+
performanceAdapter?: PerformanceAdapter;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Shopify Provider Component
|
|
34
35
|
* Provides Shopify context to all child components
|
|
35
36
|
*/
|
|
36
|
-
declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, performanceAdapter, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Hook to access Shopify context
|
|
@@ -41,10 +42,6 @@ declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartC
|
|
|
41
42
|
*/
|
|
42
43
|
declare function useShopify(): ShopifyContextValue;
|
|
43
44
|
|
|
44
|
-
type AttributeInput = {
|
|
45
|
-
key: string;
|
|
46
|
-
value: string;
|
|
47
|
-
};
|
|
48
45
|
type LoadingState = {
|
|
49
46
|
editLineQuantityLoading: boolean;
|
|
50
47
|
editLineCodeAmountLoading: boolean;
|
|
@@ -54,6 +51,8 @@ type LoadingState = {
|
|
|
54
51
|
interface CartContextValue {
|
|
55
52
|
/** Current cart data */
|
|
56
53
|
cart: NormalizedCart | undefined;
|
|
54
|
+
/** Total quantity of items in cart */
|
|
55
|
+
totalQuantity: number;
|
|
57
56
|
/** Whether cart is loading */
|
|
58
57
|
isCartLoading: boolean;
|
|
59
58
|
/** Manually trigger cart fetch */
|
|
@@ -66,8 +65,6 @@ interface CartContextValue {
|
|
|
66
65
|
removeCustomAttributes: (attributes: {
|
|
67
66
|
key: string;
|
|
68
67
|
}[]) => void;
|
|
69
|
-
/** Set custom attributes */
|
|
70
|
-
setCustomAttributes: (attributes: AttributeInput[]) => void;
|
|
71
68
|
/** Current locale */
|
|
72
69
|
locale: string;
|
|
73
70
|
/** Whether discount code is changing */
|
|
@@ -103,6 +100,12 @@ interface CartContextValue {
|
|
|
103
100
|
variant: HasMetafieldsIdentifier[];
|
|
104
101
|
product: HasMetafieldsIdentifier[];
|
|
105
102
|
};
|
|
103
|
+
/** User profile */
|
|
104
|
+
profile?: any;
|
|
105
|
+
/** Customer data */
|
|
106
|
+
customer?: any;
|
|
107
|
+
/** Plus member settings */
|
|
108
|
+
memberSetting?: PlusMemberSettingsMetafields;
|
|
106
109
|
}
|
|
107
110
|
interface CartProviderProps {
|
|
108
111
|
children: React__default.ReactNode;
|
|
@@ -151,14 +154,25 @@ declare function CartProvider({ children, autoFreeGiftConfig, gradientGiftsConfi
|
|
|
151
154
|
/**
|
|
152
155
|
* Hook to access cart context
|
|
153
156
|
*
|
|
154
|
-
* @
|
|
155
|
-
* @returns
|
|
157
|
+
* @param options - Optional configuration
|
|
158
|
+
* @param options.optional - If true, returns undefined instead of throwing error when used outside provider
|
|
159
|
+
* @throws Error if used outside CartProvider (unless optional is true)
|
|
160
|
+
* @returns Cart context value (or undefined if optional is true and no provider exists)
|
|
156
161
|
*
|
|
157
162
|
* @example
|
|
158
163
|
* ```tsx
|
|
159
164
|
* const { cart, mutateCart, isCartLoading, loadingState } = useCartContext()
|
|
165
|
+
*
|
|
166
|
+
* // Optional usage (safe for SSR)
|
|
167
|
+
* const cartContext = useCartContext({ optional: true })
|
|
168
|
+
* if (cartContext) {
|
|
169
|
+
* const { cart } = cartContext
|
|
170
|
+
* }
|
|
160
171
|
* ```
|
|
161
172
|
*/
|
|
162
173
|
declare function useCartContext(): CartContextValue;
|
|
174
|
+
declare function useCartContext(options: {
|
|
175
|
+
optional: true;
|
|
176
|
+
}): CartContextValue | null;
|
|
163
177
|
|
|
164
|
-
export { type
|
|
178
|
+
export { type CartContextValue, CartProvider, type CartProviderProps, type LoadingState, ShopifyContext, type ShopifyContextValue, ShopifyProvider, type ShopifyProviderProps, useCartContext, useShopify };
|