@anker-in/shopify-react 0.1.1-beta.0
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 +16 -0
- package/dist/adapters/index.d.ts +16 -0
- package/dist/adapters/index.js +49 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/index.mjs +42 -0
- package/dist/adapters/index.mjs.map +1 -0
- package/dist/hooks/index.d.mts +9 -0
- package/dist/hooks/index.d.ts +9 -0
- package/dist/hooks/index.js +2890 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +2801 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index-BUWkkUdh.d.ts +1936 -0
- package/dist/index-DenyuVGJ.d.mts +1936 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +3220 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3095 -0
- package/dist/index.mjs.map +1 -0
- package/dist/provider/index.d.mts +161 -0
- package/dist/provider/index.d.ts +161 -0
- package/dist/provider/index.js +1130 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/provider/index.mjs +1117 -0
- package/dist/provider/index.mjs.map +1 -0
- package/dist/types-BLMoxbOk.d.mts +54 -0
- package/dist/types-BLMoxbOk.d.ts +54 -0
- package/dist/types-CMA6_FML.d.mts +550 -0
- package/dist/types-CMA6_FML.d.ts +550 -0
- package/package.json +71 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { ShopifyClient, ShopifyConfig, CartCookieAdapter as CartCookieAdapter$1, NormalizedCart, HasMetafieldsIdentifier } from '@anker-in/shopify-sdk';
|
|
4
|
+
import { C as CookieAdapter, b as CartCookieAdapter, R as RouterAdapter, U as UserContextAdapter } from '../types-BLMoxbOk.mjs';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import { SWRConfiguration } from 'swr';
|
|
7
|
+
import { d as PlusMemberSettingsMetafields } from '../types-CMA6_FML.mjs';
|
|
8
|
+
|
|
9
|
+
interface ShopifyContextValue {
|
|
10
|
+
client: ShopifyClient;
|
|
11
|
+
config: ShopifyConfig;
|
|
12
|
+
locale: string;
|
|
13
|
+
locales?: string[];
|
|
14
|
+
cookieAdapter: CookieAdapter;
|
|
15
|
+
cartCookieAdapter: CartCookieAdapter;
|
|
16
|
+
routerAdapter?: RouterAdapter;
|
|
17
|
+
userAdapter?: UserContextAdapter;
|
|
18
|
+
}
|
|
19
|
+
declare const ShopifyContext: React.Context<ShopifyContextValue | null>;
|
|
20
|
+
|
|
21
|
+
interface ShopifyProviderProps {
|
|
22
|
+
config: ShopifyConfig;
|
|
23
|
+
locale: string;
|
|
24
|
+
locales?: string[];
|
|
25
|
+
cookieAdapter?: CookieAdapter;
|
|
26
|
+
cartCookieAdapter?: CartCookieAdapter$1;
|
|
27
|
+
routerAdapter?: RouterAdapter;
|
|
28
|
+
userAdapter?: UserContextAdapter;
|
|
29
|
+
children: React__default.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Shopify Provider Component
|
|
33
|
+
* Provides Shopify context to all child components
|
|
34
|
+
*/
|
|
35
|
+
declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Hook to access Shopify context
|
|
39
|
+
* @throws Error if used outside ShopifyProvider
|
|
40
|
+
*/
|
|
41
|
+
declare function useShopify(): ShopifyContextValue;
|
|
42
|
+
|
|
43
|
+
type AttributeInput = {
|
|
44
|
+
key: string;
|
|
45
|
+
value: string;
|
|
46
|
+
};
|
|
47
|
+
type LoadingState = {
|
|
48
|
+
editLineQuantityLoading: boolean;
|
|
49
|
+
editLineCodeAmountLoading: boolean;
|
|
50
|
+
listingAutoCodeApplying: boolean;
|
|
51
|
+
userCodeApplying: boolean;
|
|
52
|
+
};
|
|
53
|
+
interface CartContextValue {
|
|
54
|
+
/** Current cart data */
|
|
55
|
+
cart: NormalizedCart | undefined;
|
|
56
|
+
/** Whether cart is loading */
|
|
57
|
+
isCartLoading: boolean;
|
|
58
|
+
/** Manually trigger cart fetch */
|
|
59
|
+
triggerFetch: () => void;
|
|
60
|
+
/** Mutate cart data */
|
|
61
|
+
mutateCart: (cart: NormalizedCart | undefined) => void;
|
|
62
|
+
/** Add custom attributes */
|
|
63
|
+
addCustomAttributes: (attributes: AttributeInput[]) => void;
|
|
64
|
+
/** Remove custom attributes */
|
|
65
|
+
removeCustomAttributes: (attributes: {
|
|
66
|
+
key: string;
|
|
67
|
+
}[]) => void;
|
|
68
|
+
/** Set custom attributes */
|
|
69
|
+
setCustomAttributes: (attributes: AttributeInput[]) => void;
|
|
70
|
+
/** Current locale */
|
|
71
|
+
locale: string;
|
|
72
|
+
/** Whether discount code is changing */
|
|
73
|
+
isCodeChanging: boolean;
|
|
74
|
+
/** Set discount code changing state */
|
|
75
|
+
setIsCodeChanging: (isCodeChanging: boolean) => void;
|
|
76
|
+
/** Set loading state */
|
|
77
|
+
setLoadingState: React__default.Dispatch<React__default.SetStateAction<LoadingState>>;
|
|
78
|
+
/** Loading state */
|
|
79
|
+
loadingState: LoadingState;
|
|
80
|
+
/** Script auto free gift items */
|
|
81
|
+
scriptAutoFreeGift?: any[];
|
|
82
|
+
/** Function auto free gift items */
|
|
83
|
+
functionAutoFreeGift?: any[];
|
|
84
|
+
/** Set function auto free gift */
|
|
85
|
+
setFunctionAutoFreeGift: (functionAutoFreeGift: any[]) => void;
|
|
86
|
+
/** Set script auto free gift */
|
|
87
|
+
setScriptAutoFreeGift: (scriptAutoFreeGift: any[]) => void;
|
|
88
|
+
/** Script auto free gift result */
|
|
89
|
+
scriptAutoFreeGiftResult?: any;
|
|
90
|
+
/** Function auto free gift result */
|
|
91
|
+
functionAutoFreeGiftResult?: any;
|
|
92
|
+
/** Calculated auto free gift result */
|
|
93
|
+
calculatedAutoFreeGift?: any;
|
|
94
|
+
/** Gifts that need to be added to cart */
|
|
95
|
+
giftNeedAddToCartLines: any[];
|
|
96
|
+
/** Auto free gift config */
|
|
97
|
+
autoFreeGiftConfig?: any;
|
|
98
|
+
/** Metafield identifiers */
|
|
99
|
+
metafieldIdentifiers?: {
|
|
100
|
+
variant: HasMetafieldsIdentifier[];
|
|
101
|
+
product: HasMetafieldsIdentifier[];
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
interface CartProviderProps {
|
|
105
|
+
children: React__default.ReactNode;
|
|
106
|
+
/** SWR configuration options */
|
|
107
|
+
swrOptions?: SWRConfiguration<NormalizedCart | undefined, Error>;
|
|
108
|
+
/** Auto free gift configuration */
|
|
109
|
+
autoFreeGiftConfig?: any;
|
|
110
|
+
/** Gradient gifts configuration (for script gifts) */
|
|
111
|
+
gradientGiftsConfig?: any;
|
|
112
|
+
/** Function gift configuration */
|
|
113
|
+
fnGiftConf?: any;
|
|
114
|
+
/** User profile */
|
|
115
|
+
profile?: any;
|
|
116
|
+
/** Customer data */
|
|
117
|
+
customer?: any;
|
|
118
|
+
/** Current locale */
|
|
119
|
+
locale: string;
|
|
120
|
+
/** Metafield identifiers */
|
|
121
|
+
metafieldIdentifiers?: {
|
|
122
|
+
variant: HasMetafieldsIdentifier[];
|
|
123
|
+
product: HasMetafieldsIdentifier[];
|
|
124
|
+
};
|
|
125
|
+
/** Plus member settings */
|
|
126
|
+
memberSetting?: PlusMemberSettingsMetafields;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Cart Provider Component
|
|
130
|
+
*
|
|
131
|
+
* Provides cart state management with business logic
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```tsx
|
|
135
|
+
* <ShopifyProvider {...config}>
|
|
136
|
+
* <CartProvider
|
|
137
|
+
* locale="us"
|
|
138
|
+
* autoFreeGiftConfig={config}
|
|
139
|
+
* profile={profile}
|
|
140
|
+
* customer={customer}
|
|
141
|
+
* >
|
|
142
|
+
* <App />
|
|
143
|
+
* </CartProvider>
|
|
144
|
+
* </ShopifyProvider>
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function CartProvider({ children, autoFreeGiftConfig, gradientGiftsConfig, profile, customer, locale, metafieldIdentifiers, memberSetting, }: CartProviderProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
/**
|
|
149
|
+
* Hook to access cart context
|
|
150
|
+
*
|
|
151
|
+
* @throws Error if used outside CartProvider
|
|
152
|
+
* @returns Cart context value
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* const { cart, mutateCart, isCartLoading, loadingState } = useCartContext()
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
declare function useCartContext(): CartContextValue;
|
|
160
|
+
|
|
161
|
+
export { type AttributeInput, type CartContextValue, CartProvider, type CartProviderProps, type LoadingState, ShopifyContext, type ShopifyContextValue, ShopifyProvider, type ShopifyProviderProps, useCartContext, useShopify };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { ShopifyClient, ShopifyConfig, CartCookieAdapter as CartCookieAdapter$1, NormalizedCart, HasMetafieldsIdentifier } from '@anker-in/shopify-sdk';
|
|
4
|
+
import { C as CookieAdapter, b as CartCookieAdapter, R as RouterAdapter, U as UserContextAdapter } from '../types-BLMoxbOk.js';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import { SWRConfiguration } from 'swr';
|
|
7
|
+
import { d as PlusMemberSettingsMetafields } from '../types-CMA6_FML.js';
|
|
8
|
+
|
|
9
|
+
interface ShopifyContextValue {
|
|
10
|
+
client: ShopifyClient;
|
|
11
|
+
config: ShopifyConfig;
|
|
12
|
+
locale: string;
|
|
13
|
+
locales?: string[];
|
|
14
|
+
cookieAdapter: CookieAdapter;
|
|
15
|
+
cartCookieAdapter: CartCookieAdapter;
|
|
16
|
+
routerAdapter?: RouterAdapter;
|
|
17
|
+
userAdapter?: UserContextAdapter;
|
|
18
|
+
}
|
|
19
|
+
declare const ShopifyContext: React.Context<ShopifyContextValue | null>;
|
|
20
|
+
|
|
21
|
+
interface ShopifyProviderProps {
|
|
22
|
+
config: ShopifyConfig;
|
|
23
|
+
locale: string;
|
|
24
|
+
locales?: string[];
|
|
25
|
+
cookieAdapter?: CookieAdapter;
|
|
26
|
+
cartCookieAdapter?: CartCookieAdapter$1;
|
|
27
|
+
routerAdapter?: RouterAdapter;
|
|
28
|
+
userAdapter?: UserContextAdapter;
|
|
29
|
+
children: React__default.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Shopify Provider Component
|
|
33
|
+
* Provides Shopify context to all child components
|
|
34
|
+
*/
|
|
35
|
+
declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Hook to access Shopify context
|
|
39
|
+
* @throws Error if used outside ShopifyProvider
|
|
40
|
+
*/
|
|
41
|
+
declare function useShopify(): ShopifyContextValue;
|
|
42
|
+
|
|
43
|
+
type AttributeInput = {
|
|
44
|
+
key: string;
|
|
45
|
+
value: string;
|
|
46
|
+
};
|
|
47
|
+
type LoadingState = {
|
|
48
|
+
editLineQuantityLoading: boolean;
|
|
49
|
+
editLineCodeAmountLoading: boolean;
|
|
50
|
+
listingAutoCodeApplying: boolean;
|
|
51
|
+
userCodeApplying: boolean;
|
|
52
|
+
};
|
|
53
|
+
interface CartContextValue {
|
|
54
|
+
/** Current cart data */
|
|
55
|
+
cart: NormalizedCart | undefined;
|
|
56
|
+
/** Whether cart is loading */
|
|
57
|
+
isCartLoading: boolean;
|
|
58
|
+
/** Manually trigger cart fetch */
|
|
59
|
+
triggerFetch: () => void;
|
|
60
|
+
/** Mutate cart data */
|
|
61
|
+
mutateCart: (cart: NormalizedCart | undefined) => void;
|
|
62
|
+
/** Add custom attributes */
|
|
63
|
+
addCustomAttributes: (attributes: AttributeInput[]) => void;
|
|
64
|
+
/** Remove custom attributes */
|
|
65
|
+
removeCustomAttributes: (attributes: {
|
|
66
|
+
key: string;
|
|
67
|
+
}[]) => void;
|
|
68
|
+
/** Set custom attributes */
|
|
69
|
+
setCustomAttributes: (attributes: AttributeInput[]) => void;
|
|
70
|
+
/** Current locale */
|
|
71
|
+
locale: string;
|
|
72
|
+
/** Whether discount code is changing */
|
|
73
|
+
isCodeChanging: boolean;
|
|
74
|
+
/** Set discount code changing state */
|
|
75
|
+
setIsCodeChanging: (isCodeChanging: boolean) => void;
|
|
76
|
+
/** Set loading state */
|
|
77
|
+
setLoadingState: React__default.Dispatch<React__default.SetStateAction<LoadingState>>;
|
|
78
|
+
/** Loading state */
|
|
79
|
+
loadingState: LoadingState;
|
|
80
|
+
/** Script auto free gift items */
|
|
81
|
+
scriptAutoFreeGift?: any[];
|
|
82
|
+
/** Function auto free gift items */
|
|
83
|
+
functionAutoFreeGift?: any[];
|
|
84
|
+
/** Set function auto free gift */
|
|
85
|
+
setFunctionAutoFreeGift: (functionAutoFreeGift: any[]) => void;
|
|
86
|
+
/** Set script auto free gift */
|
|
87
|
+
setScriptAutoFreeGift: (scriptAutoFreeGift: any[]) => void;
|
|
88
|
+
/** Script auto free gift result */
|
|
89
|
+
scriptAutoFreeGiftResult?: any;
|
|
90
|
+
/** Function auto free gift result */
|
|
91
|
+
functionAutoFreeGiftResult?: any;
|
|
92
|
+
/** Calculated auto free gift result */
|
|
93
|
+
calculatedAutoFreeGift?: any;
|
|
94
|
+
/** Gifts that need to be added to cart */
|
|
95
|
+
giftNeedAddToCartLines: any[];
|
|
96
|
+
/** Auto free gift config */
|
|
97
|
+
autoFreeGiftConfig?: any;
|
|
98
|
+
/** Metafield identifiers */
|
|
99
|
+
metafieldIdentifiers?: {
|
|
100
|
+
variant: HasMetafieldsIdentifier[];
|
|
101
|
+
product: HasMetafieldsIdentifier[];
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
interface CartProviderProps {
|
|
105
|
+
children: React__default.ReactNode;
|
|
106
|
+
/** SWR configuration options */
|
|
107
|
+
swrOptions?: SWRConfiguration<NormalizedCart | undefined, Error>;
|
|
108
|
+
/** Auto free gift configuration */
|
|
109
|
+
autoFreeGiftConfig?: any;
|
|
110
|
+
/** Gradient gifts configuration (for script gifts) */
|
|
111
|
+
gradientGiftsConfig?: any;
|
|
112
|
+
/** Function gift configuration */
|
|
113
|
+
fnGiftConf?: any;
|
|
114
|
+
/** User profile */
|
|
115
|
+
profile?: any;
|
|
116
|
+
/** Customer data */
|
|
117
|
+
customer?: any;
|
|
118
|
+
/** Current locale */
|
|
119
|
+
locale: string;
|
|
120
|
+
/** Metafield identifiers */
|
|
121
|
+
metafieldIdentifiers?: {
|
|
122
|
+
variant: HasMetafieldsIdentifier[];
|
|
123
|
+
product: HasMetafieldsIdentifier[];
|
|
124
|
+
};
|
|
125
|
+
/** Plus member settings */
|
|
126
|
+
memberSetting?: PlusMemberSettingsMetafields;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Cart Provider Component
|
|
130
|
+
*
|
|
131
|
+
* Provides cart state management with business logic
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```tsx
|
|
135
|
+
* <ShopifyProvider {...config}>
|
|
136
|
+
* <CartProvider
|
|
137
|
+
* locale="us"
|
|
138
|
+
* autoFreeGiftConfig={config}
|
|
139
|
+
* profile={profile}
|
|
140
|
+
* customer={customer}
|
|
141
|
+
* >
|
|
142
|
+
* <App />
|
|
143
|
+
* </CartProvider>
|
|
144
|
+
* </ShopifyProvider>
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function CartProvider({ children, autoFreeGiftConfig, gradientGiftsConfig, profile, customer, locale, metafieldIdentifiers, memberSetting, }: CartProviderProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
/**
|
|
149
|
+
* Hook to access cart context
|
|
150
|
+
*
|
|
151
|
+
* @throws Error if used outside CartProvider
|
|
152
|
+
* @returns Cart context value
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* const { cart, mutateCart, isCartLoading, loadingState } = useCartContext()
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
declare function useCartContext(): CartContextValue;
|
|
160
|
+
|
|
161
|
+
export { type AttributeInput, type CartContextValue, CartProvider, type CartProviderProps, type LoadingState, ShopifyContext, type ShopifyContextValue, ShopifyProvider, type ShopifyProviderProps, useCartContext, useShopify };
|