@nymbalhq/react 0.0.0-stage → 0.2.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/index.d.ts +157 -0
- package/dist/index.js +367 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { NymbalClient, CartState, ProductState, DenormalisedVariant, ProductListState, ProductListParams, ProductSortKey, SearchState, CheckoutState, ShippingMethod, CheckoutResult, AuthState, RegisterParams } from '@nymbalhq/sdk';
|
|
3
|
+
import { Address, Customer } from '@nymbalhq/types';
|
|
4
|
+
|
|
5
|
+
interface NymbalProviderProps {
|
|
6
|
+
client: NymbalClient;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare function NymbalProvider({ client, children }: NymbalProviderProps): ReactNode;
|
|
10
|
+
declare function useNymbalClient(): NymbalClient;
|
|
11
|
+
|
|
12
|
+
interface UseCartReturn extends CartState {
|
|
13
|
+
addItem: (variantId: string, qty?: number) => Promise<void>;
|
|
14
|
+
removeItem: (variantId: string) => Promise<void>;
|
|
15
|
+
updateQuantity: (variantId: string, qty: number) => Promise<void>;
|
|
16
|
+
clear: () => Promise<void>;
|
|
17
|
+
load: () => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
declare function useCart(): UseCartReturn;
|
|
20
|
+
|
|
21
|
+
interface UseProductReturn extends ProductState {
|
|
22
|
+
loadBySlug: (slug: string) => Promise<void>;
|
|
23
|
+
selectVariant: (variant: DenormalisedVariant | null) => void;
|
|
24
|
+
}
|
|
25
|
+
declare function useProduct(slug?: string): UseProductReturn;
|
|
26
|
+
|
|
27
|
+
interface UseProductListReturn extends ProductListState {
|
|
28
|
+
load: (params?: ProductListParams) => Promise<void>;
|
|
29
|
+
loadMore: () => Promise<void>;
|
|
30
|
+
applyFilter: (name: string, value: string | string[]) => Promise<void>;
|
|
31
|
+
removeFilter: (name: string) => Promise<void>;
|
|
32
|
+
setSort: (sort: ProductSortKey) => Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
declare function useProductList(): UseProductListReturn;
|
|
35
|
+
|
|
36
|
+
interface UseSearchReturn extends SearchState {
|
|
37
|
+
search: (query: string) => Promise<void>;
|
|
38
|
+
clearSearch: () => void;
|
|
39
|
+
}
|
|
40
|
+
declare function useSearch(): UseSearchReturn;
|
|
41
|
+
|
|
42
|
+
interface UseCheckoutReturn extends CheckoutState {
|
|
43
|
+
setEmail: (email: string) => void;
|
|
44
|
+
setShippingAddress: (address: Address) => void;
|
|
45
|
+
setBillingAddress: (address: Address) => void;
|
|
46
|
+
setShippingMethod: (method: ShippingMethod) => void;
|
|
47
|
+
submitPayment: () => Promise<CheckoutResult | null>;
|
|
48
|
+
markConfirmed: () => void;
|
|
49
|
+
reset: () => void;
|
|
50
|
+
}
|
|
51
|
+
declare function useCheckout(): UseCheckoutReturn;
|
|
52
|
+
|
|
53
|
+
interface UseAuthReturn extends AuthState {
|
|
54
|
+
login: (email: string, password: string) => Promise<void>;
|
|
55
|
+
register: (params: RegisterParams) => Promise<void>;
|
|
56
|
+
logout: () => Promise<void>;
|
|
57
|
+
refreshToken: () => Promise<void>;
|
|
58
|
+
updateProfile: (updates: Partial<Pick<Customer, 'firstName' | 'lastName' | 'phone'>>) => Promise<void>;
|
|
59
|
+
loadProfile: () => Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
declare function useAuth(): UseAuthReturn;
|
|
62
|
+
|
|
63
|
+
declare module 'react' {
|
|
64
|
+
namespace JSX {
|
|
65
|
+
interface IntrinsicElements {
|
|
66
|
+
'nymbal-add-to-cart': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
67
|
+
'nymbal-cart-drawer': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
68
|
+
'nymbal-mini-cart': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
69
|
+
'nymbal-variant-selector': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
70
|
+
'nymbal-quantity-selector': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
71
|
+
'nymbal-search-bar': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
72
|
+
'nymbal-product-filter': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
73
|
+
'nymbal-toast': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
interface AddToCartProps {
|
|
78
|
+
variantId?: string;
|
|
79
|
+
disabled?: boolean;
|
|
80
|
+
onItemAdded?: (event: CustomEvent<{
|
|
81
|
+
variantId: string;
|
|
82
|
+
}>) => void;
|
|
83
|
+
children?: React.ReactNode;
|
|
84
|
+
className?: string;
|
|
85
|
+
style?: React.CSSProperties;
|
|
86
|
+
'data-testid'?: string;
|
|
87
|
+
}
|
|
88
|
+
declare const AddToCart: React.ForwardRefExoticComponent<AddToCartProps & React.RefAttributes<HTMLElement>>;
|
|
89
|
+
interface CartDrawerProps {
|
|
90
|
+
open?: boolean;
|
|
91
|
+
onCheckoutClick?: (event: CustomEvent<void>) => void;
|
|
92
|
+
className?: string;
|
|
93
|
+
style?: React.CSSProperties;
|
|
94
|
+
'data-testid'?: string;
|
|
95
|
+
}
|
|
96
|
+
declare const CartDrawer: React.ForwardRefExoticComponent<CartDrawerProps & React.RefAttributes<HTMLElement>>;
|
|
97
|
+
interface MiniCartProps {
|
|
98
|
+
onClick?: (event: CustomEvent<void>) => void;
|
|
99
|
+
className?: string;
|
|
100
|
+
style?: React.CSSProperties;
|
|
101
|
+
'data-testid'?: string;
|
|
102
|
+
}
|
|
103
|
+
declare const MiniCart: React.ForwardRefExoticComponent<MiniCartProps & React.RefAttributes<HTMLElement>>;
|
|
104
|
+
interface VariantSelectorProps {
|
|
105
|
+
options?: unknown;
|
|
106
|
+
onVariantSelected?: (event: CustomEvent<{
|
|
107
|
+
variant: unknown;
|
|
108
|
+
}>) => void;
|
|
109
|
+
className?: string;
|
|
110
|
+
style?: React.CSSProperties;
|
|
111
|
+
'data-testid'?: string;
|
|
112
|
+
}
|
|
113
|
+
declare const VariantSelector: React.ForwardRefExoticComponent<VariantSelectorProps & React.RefAttributes<HTMLElement>>;
|
|
114
|
+
interface QuantitySelectorProps {
|
|
115
|
+
value?: number;
|
|
116
|
+
min?: number;
|
|
117
|
+
max?: number;
|
|
118
|
+
onQuantityChange?: (event: CustomEvent<{
|
|
119
|
+
value: number;
|
|
120
|
+
}>) => void;
|
|
121
|
+
className?: string;
|
|
122
|
+
style?: React.CSSProperties;
|
|
123
|
+
'data-testid'?: string;
|
|
124
|
+
}
|
|
125
|
+
declare const QuantitySelector: React.ForwardRefExoticComponent<QuantitySelectorProps & React.RefAttributes<HTMLElement>>;
|
|
126
|
+
interface SearchBarProps {
|
|
127
|
+
placeholder?: string;
|
|
128
|
+
debounceMs?: number;
|
|
129
|
+
onSearchSelect?: (event: CustomEvent<{
|
|
130
|
+
product: unknown;
|
|
131
|
+
}>) => void;
|
|
132
|
+
className?: string;
|
|
133
|
+
style?: React.CSSProperties;
|
|
134
|
+
'data-testid'?: string;
|
|
135
|
+
}
|
|
136
|
+
declare const SearchBar: React.ForwardRefExoticComponent<SearchBarProps & React.RefAttributes<HTMLElement>>;
|
|
137
|
+
interface ProductFilterProps {
|
|
138
|
+
facets?: unknown;
|
|
139
|
+
onFilterChange?: (event: CustomEvent<{
|
|
140
|
+
name: string;
|
|
141
|
+
value: string;
|
|
142
|
+
}>) => void;
|
|
143
|
+
className?: string;
|
|
144
|
+
style?: React.CSSProperties;
|
|
145
|
+
'data-testid'?: string;
|
|
146
|
+
}
|
|
147
|
+
declare const ProductFilter: React.ForwardRefExoticComponent<ProductFilterProps & React.RefAttributes<HTMLElement>>;
|
|
148
|
+
interface ToastProps {
|
|
149
|
+
position?: string;
|
|
150
|
+
durationMs?: number;
|
|
151
|
+
className?: string;
|
|
152
|
+
style?: React.CSSProperties;
|
|
153
|
+
'data-testid'?: string;
|
|
154
|
+
}
|
|
155
|
+
declare const Toast: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<HTMLElement>>;
|
|
156
|
+
|
|
157
|
+
export { AddToCart, type AddToCartProps, CartDrawer, type CartDrawerProps, MiniCart, type MiniCartProps, NymbalProvider, type NymbalProviderProps, ProductFilter, type ProductFilterProps, QuantitySelector, type QuantitySelectorProps, SearchBar, type SearchBarProps, Toast, type ToastProps, type UseAuthReturn, type UseCartReturn, type UseCheckoutReturn, type UseProductListReturn, type UseProductReturn, type UseSearchReturn, VariantSelector, type VariantSelectorProps, useAuth, useCart, useCheckout, useNymbalClient, useProduct, useProductList, useSearch };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
// src/context.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var NymbalContext = createContext(null);
|
|
5
|
+
function NymbalProvider({ client, children }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(NymbalContext.Provider, { value: client, children });
|
|
7
|
+
}
|
|
8
|
+
function useNymbalClient() {
|
|
9
|
+
const client = useContext(NymbalContext);
|
|
10
|
+
if (!client) {
|
|
11
|
+
throw new Error("useNymbalClient must be used within <NymbalProvider>");
|
|
12
|
+
}
|
|
13
|
+
return client;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/hooks/use-cart.ts
|
|
17
|
+
import { useSyncExternalStore } from "react";
|
|
18
|
+
function useCart() {
|
|
19
|
+
const client = useNymbalClient();
|
|
20
|
+
const state = useSyncExternalStore(
|
|
21
|
+
client.cart.subscribe,
|
|
22
|
+
client.cart.getState,
|
|
23
|
+
client.cart.getState
|
|
24
|
+
);
|
|
25
|
+
return {
|
|
26
|
+
...state,
|
|
27
|
+
addItem: client.cart.addItem,
|
|
28
|
+
removeItem: client.cart.removeItem,
|
|
29
|
+
updateQuantity: client.cart.updateQuantity,
|
|
30
|
+
clear: client.cart.clear,
|
|
31
|
+
load: client.cart.load
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/hooks/use-product.ts
|
|
36
|
+
import { useSyncExternalStore as useSyncExternalStore2, useEffect } from "react";
|
|
37
|
+
function useProduct(slug) {
|
|
38
|
+
const client = useNymbalClient();
|
|
39
|
+
const state = useSyncExternalStore2(
|
|
40
|
+
client.product.subscribe,
|
|
41
|
+
client.product.getState,
|
|
42
|
+
client.product.getState
|
|
43
|
+
);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (slug) {
|
|
46
|
+
client.product.loadBySlug(slug);
|
|
47
|
+
}
|
|
48
|
+
}, [slug, client.product]);
|
|
49
|
+
return {
|
|
50
|
+
...state,
|
|
51
|
+
loadBySlug: client.product.loadBySlug,
|
|
52
|
+
selectVariant: client.product.selectVariant
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/hooks/use-product-list.ts
|
|
57
|
+
import { useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
58
|
+
function useProductList() {
|
|
59
|
+
const client = useNymbalClient();
|
|
60
|
+
const state = useSyncExternalStore3(
|
|
61
|
+
client.productList.subscribe,
|
|
62
|
+
client.productList.getState,
|
|
63
|
+
client.productList.getState
|
|
64
|
+
);
|
|
65
|
+
return {
|
|
66
|
+
...state,
|
|
67
|
+
load: client.productList.load,
|
|
68
|
+
loadMore: client.productList.loadMore,
|
|
69
|
+
applyFilter: client.productList.applyFilter,
|
|
70
|
+
removeFilter: client.productList.removeFilter,
|
|
71
|
+
setSort: client.productList.setSort
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/hooks/use-search.ts
|
|
76
|
+
import { useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
77
|
+
function useSearch() {
|
|
78
|
+
const client = useNymbalClient();
|
|
79
|
+
const state = useSyncExternalStore4(
|
|
80
|
+
client.search.subscribe,
|
|
81
|
+
client.search.getState,
|
|
82
|
+
client.search.getState
|
|
83
|
+
);
|
|
84
|
+
return {
|
|
85
|
+
...state,
|
|
86
|
+
search: client.search.search,
|
|
87
|
+
clearSearch: client.search.clearSearch
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/hooks/use-checkout.ts
|
|
92
|
+
import { useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
93
|
+
function useCheckout() {
|
|
94
|
+
const client = useNymbalClient();
|
|
95
|
+
const state = useSyncExternalStore5(
|
|
96
|
+
client.checkout.subscribe,
|
|
97
|
+
client.checkout.getState,
|
|
98
|
+
client.checkout.getState
|
|
99
|
+
);
|
|
100
|
+
return {
|
|
101
|
+
...state,
|
|
102
|
+
setEmail: client.checkout.setEmail,
|
|
103
|
+
setShippingAddress: client.checkout.setShippingAddress,
|
|
104
|
+
setBillingAddress: client.checkout.setBillingAddress,
|
|
105
|
+
setShippingMethod: client.checkout.setShippingMethod,
|
|
106
|
+
submitPayment: client.checkout.submitPayment,
|
|
107
|
+
markConfirmed: client.checkout.markConfirmed,
|
|
108
|
+
reset: client.checkout.reset
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/hooks/use-auth.ts
|
|
113
|
+
import { useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
114
|
+
function useAuth() {
|
|
115
|
+
const client = useNymbalClient();
|
|
116
|
+
const state = useSyncExternalStore6(
|
|
117
|
+
client.auth.subscribe,
|
|
118
|
+
client.auth.getState,
|
|
119
|
+
client.auth.getState
|
|
120
|
+
);
|
|
121
|
+
return {
|
|
122
|
+
...state,
|
|
123
|
+
login: client.auth.login,
|
|
124
|
+
register: client.auth.register,
|
|
125
|
+
logout: client.auth.logout,
|
|
126
|
+
refreshToken: client.auth.refreshToken,
|
|
127
|
+
updateProfile: client.auth.updateProfile,
|
|
128
|
+
loadProfile: client.auth.loadProfile
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/generated/wrappers.tsx
|
|
133
|
+
import { forwardRef, useRef, useEffect as useEffect2 } from "react";
|
|
134
|
+
import "@nymbalhq/web-components";
|
|
135
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
136
|
+
var AddToCart = forwardRef(
|
|
137
|
+
function AddToCart2(props, forwardedRef) {
|
|
138
|
+
const innerRef = useRef(null);
|
|
139
|
+
const ref = forwardedRef ?? innerRef;
|
|
140
|
+
useEffect2(() => {
|
|
141
|
+
const el = ref.current;
|
|
142
|
+
if (!el) return;
|
|
143
|
+
if (props.variantId !== void 0) {
|
|
144
|
+
el.setAttribute("variant-id", String(props.variantId));
|
|
145
|
+
} else {
|
|
146
|
+
el.removeAttribute("variant-id");
|
|
147
|
+
}
|
|
148
|
+
}, [props.variantId]);
|
|
149
|
+
useEffect2(() => {
|
|
150
|
+
const el = ref.current;
|
|
151
|
+
if (!el) return;
|
|
152
|
+
if (props.disabled) {
|
|
153
|
+
el.setAttribute("disabled", "");
|
|
154
|
+
} else {
|
|
155
|
+
el.removeAttribute("disabled");
|
|
156
|
+
}
|
|
157
|
+
}, [props.disabled]);
|
|
158
|
+
useEffect2(() => {
|
|
159
|
+
const el = ref.current;
|
|
160
|
+
if (!el || !props.onItemAdded) return;
|
|
161
|
+
const handler = props.onItemAdded;
|
|
162
|
+
el.addEventListener("nymbal:cart:item-added", handler);
|
|
163
|
+
return () => el.removeEventListener("nymbal:cart:item-added", handler);
|
|
164
|
+
}, [props.onItemAdded]);
|
|
165
|
+
return /* @__PURE__ */ jsx2("nymbal-add-to-cart", { ref, className: props.className, style: props.style, "data-testid": props["data-testid"], children: props.children });
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
var CartDrawer = forwardRef(
|
|
169
|
+
function CartDrawer2(props, forwardedRef) {
|
|
170
|
+
const innerRef = useRef(null);
|
|
171
|
+
const ref = forwardedRef ?? innerRef;
|
|
172
|
+
useEffect2(() => {
|
|
173
|
+
const el = ref.current;
|
|
174
|
+
if (!el) return;
|
|
175
|
+
if (props.open) {
|
|
176
|
+
el.setAttribute("open", "");
|
|
177
|
+
} else {
|
|
178
|
+
el.removeAttribute("open");
|
|
179
|
+
}
|
|
180
|
+
}, [props.open]);
|
|
181
|
+
useEffect2(() => {
|
|
182
|
+
const el = ref.current;
|
|
183
|
+
if (!el || !props.onCheckoutClick) return;
|
|
184
|
+
const handler = props.onCheckoutClick;
|
|
185
|
+
el.addEventListener("nymbal:cart:checkout-clicked", handler);
|
|
186
|
+
return () => el.removeEventListener("nymbal:cart:checkout-clicked", handler);
|
|
187
|
+
}, [props.onCheckoutClick]);
|
|
188
|
+
return /* @__PURE__ */ jsx2("nymbal-cart-drawer", { ref, className: props.className, style: props.style, "data-testid": props["data-testid"] });
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
var MiniCart = forwardRef(
|
|
192
|
+
function MiniCart2(props, forwardedRef) {
|
|
193
|
+
const innerRef = useRef(null);
|
|
194
|
+
const ref = forwardedRef ?? innerRef;
|
|
195
|
+
useEffect2(() => {
|
|
196
|
+
const el = ref.current;
|
|
197
|
+
if (!el || !props.onClick) return;
|
|
198
|
+
const handler = props.onClick;
|
|
199
|
+
el.addEventListener("nymbal:mini-cart:clicked", handler);
|
|
200
|
+
return () => el.removeEventListener("nymbal:mini-cart:clicked", handler);
|
|
201
|
+
}, [props.onClick]);
|
|
202
|
+
return /* @__PURE__ */ jsx2("nymbal-mini-cart", { ref, className: props.className, style: props.style, "data-testid": props["data-testid"] });
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
var VariantSelector = forwardRef(
|
|
206
|
+
function VariantSelector2(props, forwardedRef) {
|
|
207
|
+
const innerRef = useRef(null);
|
|
208
|
+
const ref = forwardedRef ?? innerRef;
|
|
209
|
+
useEffect2(() => {
|
|
210
|
+
const el = ref.current;
|
|
211
|
+
if (!el) return;
|
|
212
|
+
if (props.options !== void 0) {
|
|
213
|
+
el.setAttribute("options", JSON.stringify(props.options));
|
|
214
|
+
} else {
|
|
215
|
+
el.removeAttribute("options");
|
|
216
|
+
}
|
|
217
|
+
}, [props.options]);
|
|
218
|
+
useEffect2(() => {
|
|
219
|
+
const el = ref.current;
|
|
220
|
+
if (!el || !props.onVariantSelected) return;
|
|
221
|
+
const handler = props.onVariantSelected;
|
|
222
|
+
el.addEventListener("nymbal:variant:selected", handler);
|
|
223
|
+
return () => el.removeEventListener("nymbal:variant:selected", handler);
|
|
224
|
+
}, [props.onVariantSelected]);
|
|
225
|
+
return /* @__PURE__ */ jsx2("nymbal-variant-selector", { ref, className: props.className, style: props.style, "data-testid": props["data-testid"] });
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
var QuantitySelector = forwardRef(
|
|
229
|
+
function QuantitySelector2(props, forwardedRef) {
|
|
230
|
+
const innerRef = useRef(null);
|
|
231
|
+
const ref = forwardedRef ?? innerRef;
|
|
232
|
+
useEffect2(() => {
|
|
233
|
+
const el = ref.current;
|
|
234
|
+
if (!el) return;
|
|
235
|
+
if (props.value !== void 0) {
|
|
236
|
+
el.setAttribute("value", String(props.value));
|
|
237
|
+
} else {
|
|
238
|
+
el.removeAttribute("value");
|
|
239
|
+
}
|
|
240
|
+
}, [props.value]);
|
|
241
|
+
useEffect2(() => {
|
|
242
|
+
const el = ref.current;
|
|
243
|
+
if (!el) return;
|
|
244
|
+
if (props.min !== void 0) {
|
|
245
|
+
el.setAttribute("min", String(props.min));
|
|
246
|
+
} else {
|
|
247
|
+
el.removeAttribute("min");
|
|
248
|
+
}
|
|
249
|
+
}, [props.min]);
|
|
250
|
+
useEffect2(() => {
|
|
251
|
+
const el = ref.current;
|
|
252
|
+
if (!el) return;
|
|
253
|
+
if (props.max !== void 0) {
|
|
254
|
+
el.setAttribute("max", String(props.max));
|
|
255
|
+
} else {
|
|
256
|
+
el.removeAttribute("max");
|
|
257
|
+
}
|
|
258
|
+
}, [props.max]);
|
|
259
|
+
useEffect2(() => {
|
|
260
|
+
const el = ref.current;
|
|
261
|
+
if (!el || !props.onQuantityChange) return;
|
|
262
|
+
const handler = props.onQuantityChange;
|
|
263
|
+
el.addEventListener("nymbal:quantity:changed", handler);
|
|
264
|
+
return () => el.removeEventListener("nymbal:quantity:changed", handler);
|
|
265
|
+
}, [props.onQuantityChange]);
|
|
266
|
+
return /* @__PURE__ */ jsx2("nymbal-quantity-selector", { ref, className: props.className, style: props.style, "data-testid": props["data-testid"] });
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
var SearchBar = forwardRef(
|
|
270
|
+
function SearchBar2(props, forwardedRef) {
|
|
271
|
+
const innerRef = useRef(null);
|
|
272
|
+
const ref = forwardedRef ?? innerRef;
|
|
273
|
+
useEffect2(() => {
|
|
274
|
+
const el = ref.current;
|
|
275
|
+
if (!el) return;
|
|
276
|
+
if (props.placeholder !== void 0) {
|
|
277
|
+
el.setAttribute("placeholder", String(props.placeholder));
|
|
278
|
+
} else {
|
|
279
|
+
el.removeAttribute("placeholder");
|
|
280
|
+
}
|
|
281
|
+
}, [props.placeholder]);
|
|
282
|
+
useEffect2(() => {
|
|
283
|
+
const el = ref.current;
|
|
284
|
+
if (!el) return;
|
|
285
|
+
if (props.debounceMs !== void 0) {
|
|
286
|
+
el.setAttribute("debounce-ms", String(props.debounceMs));
|
|
287
|
+
} else {
|
|
288
|
+
el.removeAttribute("debounce-ms");
|
|
289
|
+
}
|
|
290
|
+
}, [props.debounceMs]);
|
|
291
|
+
useEffect2(() => {
|
|
292
|
+
const el = ref.current;
|
|
293
|
+
if (!el || !props.onSearchSelect) return;
|
|
294
|
+
const handler = props.onSearchSelect;
|
|
295
|
+
el.addEventListener("nymbal:search:selected", handler);
|
|
296
|
+
return () => el.removeEventListener("nymbal:search:selected", handler);
|
|
297
|
+
}, [props.onSearchSelect]);
|
|
298
|
+
return /* @__PURE__ */ jsx2("nymbal-search-bar", { ref, className: props.className, style: props.style, "data-testid": props["data-testid"] });
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
var ProductFilter = forwardRef(
|
|
302
|
+
function ProductFilter2(props, forwardedRef) {
|
|
303
|
+
const innerRef = useRef(null);
|
|
304
|
+
const ref = forwardedRef ?? innerRef;
|
|
305
|
+
useEffect2(() => {
|
|
306
|
+
const el = ref.current;
|
|
307
|
+
if (!el) return;
|
|
308
|
+
if (props.facets !== void 0) {
|
|
309
|
+
el.setAttribute("facets", JSON.stringify(props.facets));
|
|
310
|
+
} else {
|
|
311
|
+
el.removeAttribute("facets");
|
|
312
|
+
}
|
|
313
|
+
}, [props.facets]);
|
|
314
|
+
useEffect2(() => {
|
|
315
|
+
const el = ref.current;
|
|
316
|
+
if (!el || !props.onFilterChange) return;
|
|
317
|
+
const handler = props.onFilterChange;
|
|
318
|
+
el.addEventListener("nymbal:filter:changed", handler);
|
|
319
|
+
return () => el.removeEventListener("nymbal:filter:changed", handler);
|
|
320
|
+
}, [props.onFilterChange]);
|
|
321
|
+
return /* @__PURE__ */ jsx2("nymbal-product-filter", { ref, className: props.className, style: props.style, "data-testid": props["data-testid"] });
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
var Toast = forwardRef(
|
|
325
|
+
function Toast2(props, forwardedRef) {
|
|
326
|
+
const innerRef = useRef(null);
|
|
327
|
+
const ref = forwardedRef ?? innerRef;
|
|
328
|
+
useEffect2(() => {
|
|
329
|
+
const el = ref.current;
|
|
330
|
+
if (!el) return;
|
|
331
|
+
if (props.position !== void 0) {
|
|
332
|
+
el.setAttribute("position", String(props.position));
|
|
333
|
+
} else {
|
|
334
|
+
el.removeAttribute("position");
|
|
335
|
+
}
|
|
336
|
+
}, [props.position]);
|
|
337
|
+
useEffect2(() => {
|
|
338
|
+
const el = ref.current;
|
|
339
|
+
if (!el) return;
|
|
340
|
+
if (props.durationMs !== void 0) {
|
|
341
|
+
el.setAttribute("duration-ms", String(props.durationMs));
|
|
342
|
+
} else {
|
|
343
|
+
el.removeAttribute("duration-ms");
|
|
344
|
+
}
|
|
345
|
+
}, [props.durationMs]);
|
|
346
|
+
return /* @__PURE__ */ jsx2("nymbal-toast", { ref, className: props.className, style: props.style, "data-testid": props["data-testid"] });
|
|
347
|
+
}
|
|
348
|
+
);
|
|
349
|
+
export {
|
|
350
|
+
AddToCart,
|
|
351
|
+
CartDrawer,
|
|
352
|
+
MiniCart,
|
|
353
|
+
NymbalProvider,
|
|
354
|
+
ProductFilter,
|
|
355
|
+
QuantitySelector,
|
|
356
|
+
SearchBar,
|
|
357
|
+
Toast,
|
|
358
|
+
VariantSelector,
|
|
359
|
+
useAuth,
|
|
360
|
+
useCart,
|
|
361
|
+
useCheckout,
|
|
362
|
+
useNymbalClient,
|
|
363
|
+
useProduct,
|
|
364
|
+
useProductList,
|
|
365
|
+
useSearch
|
|
366
|
+
};
|
|
367
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.tsx","../src/hooks/use-cart.ts","../src/hooks/use-product.ts","../src/hooks/use-product-list.ts","../src/hooks/use-search.ts","../src/hooks/use-checkout.ts","../src/hooks/use-auth.ts","../src/generated/wrappers.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from 'react'\nimport type { NymbalClient } from '@nymbalhq/sdk'\n\nconst NymbalContext = createContext<NymbalClient | null>(null)\n\nexport interface NymbalProviderProps {\n client: NymbalClient\n children: ReactNode\n}\n\nexport function NymbalProvider({ client, children }: NymbalProviderProps): ReactNode {\n return <NymbalContext.Provider value={client}>{children}</NymbalContext.Provider>\n}\n\nexport function useNymbalClient(): NymbalClient {\n const client = useContext(NymbalContext)\n if (!client) {\n throw new Error('useNymbalClient must be used within <NymbalProvider>')\n }\n return client\n}\n","import { useSyncExternalStore } from 'react'\nimport type { CartState } from '@nymbalhq/sdk'\nimport { useNymbalClient } from '../context.js'\n\nexport interface UseCartReturn extends CartState {\n addItem: (variantId: string, qty?: number) => Promise<void>\n removeItem: (variantId: string) => Promise<void>\n updateQuantity: (variantId: string, qty: number) => Promise<void>\n clear: () => Promise<void>\n load: () => Promise<void>\n}\n\nexport function useCart(): UseCartReturn {\n const client = useNymbalClient()\n const state = useSyncExternalStore(\n client.cart.subscribe,\n client.cart.getState,\n client.cart.getState,\n )\n return {\n ...state,\n addItem: client.cart.addItem,\n removeItem: client.cart.removeItem,\n updateQuantity: client.cart.updateQuantity,\n clear: client.cart.clear,\n load: client.cart.load,\n }\n}\n","import { useSyncExternalStore, useEffect } from 'react'\nimport type { ProductState, DenormalisedVariant } from '@nymbalhq/sdk'\nimport { useNymbalClient } from '../context.js'\n\nexport interface UseProductReturn extends ProductState {\n loadBySlug: (slug: string) => Promise<void>\n selectVariant: (variant: DenormalisedVariant | null) => void\n}\n\nexport function useProduct(slug?: string): UseProductReturn {\n const client = useNymbalClient()\n const state = useSyncExternalStore(\n client.product.subscribe,\n client.product.getState,\n client.product.getState,\n )\n\n useEffect(() => {\n if (slug) {\n client.product.loadBySlug(slug)\n }\n }, [slug, client.product])\n\n return {\n ...state,\n loadBySlug: client.product.loadBySlug,\n selectVariant: client.product.selectVariant,\n }\n}\n","import { useSyncExternalStore } from 'react'\nimport type { ProductListState, ProductListParams, ProductSortKey } from '@nymbalhq/sdk'\nimport { useNymbalClient } from '../context.js'\n\nexport interface UseProductListReturn extends ProductListState {\n load: (params?: ProductListParams) => Promise<void>\n loadMore: () => Promise<void>\n applyFilter: (name: string, value: string | string[]) => Promise<void>\n removeFilter: (name: string) => Promise<void>\n setSort: (sort: ProductSortKey) => Promise<void>\n}\n\nexport function useProductList(): UseProductListReturn {\n const client = useNymbalClient()\n const state = useSyncExternalStore(\n client.productList.subscribe,\n client.productList.getState,\n client.productList.getState,\n )\n return {\n ...state,\n load: client.productList.load,\n loadMore: client.productList.loadMore,\n applyFilter: client.productList.applyFilter,\n removeFilter: client.productList.removeFilter,\n setSort: client.productList.setSort,\n }\n}\n","import { useSyncExternalStore } from 'react'\nimport type { SearchState } from '@nymbalhq/sdk'\nimport { useNymbalClient } from '../context.js'\n\nexport interface UseSearchReturn extends SearchState {\n search: (query: string) => Promise<void>\n clearSearch: () => void\n}\n\nexport function useSearch(): UseSearchReturn {\n const client = useNymbalClient()\n const state = useSyncExternalStore(\n client.search.subscribe,\n client.search.getState,\n client.search.getState,\n )\n return {\n ...state,\n search: client.search.search,\n clearSearch: client.search.clearSearch,\n }\n}\n","import { useSyncExternalStore } from 'react'\nimport type { Address } from '@nymbalhq/types'\nimport type { CheckoutResult, CheckoutState, ShippingMethod } from '@nymbalhq/sdk'\nimport { useNymbalClient } from '../context.js'\n\nexport interface UseCheckoutReturn extends CheckoutState {\n setEmail: (email: string) => void\n setShippingAddress: (address: Address) => void\n setBillingAddress: (address: Address) => void\n setShippingMethod: (method: ShippingMethod) => void\n submitPayment: () => Promise<CheckoutResult | null>\n markConfirmed: () => void\n reset: () => void\n}\n\nexport function useCheckout(): UseCheckoutReturn {\n const client = useNymbalClient()\n const state = useSyncExternalStore(\n client.checkout.subscribe,\n client.checkout.getState,\n client.checkout.getState,\n )\n return {\n ...state,\n setEmail: client.checkout.setEmail,\n setShippingAddress: client.checkout.setShippingAddress,\n setBillingAddress: client.checkout.setBillingAddress,\n setShippingMethod: client.checkout.setShippingMethod,\n submitPayment: client.checkout.submitPayment,\n markConfirmed: client.checkout.markConfirmed,\n reset: client.checkout.reset,\n }\n}\n","import { useSyncExternalStore } from 'react'\nimport type { Customer } from '@nymbalhq/types'\nimport type { AuthState, RegisterParams } from '@nymbalhq/sdk'\nimport { useNymbalClient } from '../context.js'\n\nexport interface UseAuthReturn extends AuthState {\n login: (email: string, password: string) => Promise<void>\n register: (params: RegisterParams) => Promise<void>\n logout: () => Promise<void>\n refreshToken: () => Promise<void>\n updateProfile: (updates: Partial<Pick<Customer, 'firstName' | 'lastName' | 'phone'>>) => Promise<void>\n loadProfile: () => Promise<void>\n}\n\nexport function useAuth(): UseAuthReturn {\n const client = useNymbalClient()\n const state = useSyncExternalStore(\n client.auth.subscribe,\n client.auth.getState,\n client.auth.getState,\n )\n return {\n ...state,\n login: client.auth.login,\n register: client.auth.register,\n logout: client.auth.logout,\n refreshToken: client.auth.refreshToken,\n updateProfile: client.auth.updateProfile,\n loadProfile: client.auth.loadProfile,\n }\n}\n","// AUTO-GENERATED by scripts/generate-wrappers.ts — DO NOT EDIT\nimport React, { forwardRef, useRef, useEffect } from 'react'\n\nimport '@nymbalhq/web-components'\n\ndeclare module 'react' {\n namespace JSX {\n interface IntrinsicElements {\n 'nymbal-add-to-cart': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>\n 'nymbal-cart-drawer': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>\n 'nymbal-mini-cart': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>\n 'nymbal-variant-selector': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>\n 'nymbal-quantity-selector': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>\n 'nymbal-search-bar': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>\n 'nymbal-product-filter': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>\n 'nymbal-toast': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>\n }\n }\n}\n\nexport interface AddToCartProps {\n variantId?: string\n disabled?: boolean\n onItemAdded?: (event: CustomEvent<{ variantId: string }>) => void\n children?: React.ReactNode\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport const AddToCart = forwardRef<HTMLElement, AddToCartProps>(\n function AddToCart(props, forwardedRef) {\n const innerRef = useRef<HTMLElement>(null)\n const ref = (forwardedRef ?? innerRef) as React.RefObject<HTMLElement | null>\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.variantId !== undefined) {\n el.setAttribute('variant-id', String(props.variantId))\n } else {\n el.removeAttribute('variant-id')\n }\n }, [props.variantId])\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.disabled) {\n el.setAttribute('disabled', '')\n } else {\n el.removeAttribute('disabled')\n }\n }, [props.disabled])\n\n useEffect(() => {\n const el = ref.current\n if (!el || !props.onItemAdded) return\n const handler = props.onItemAdded as EventListener\n el.addEventListener('nymbal:cart:item-added', handler)\n return () => el.removeEventListener('nymbal:cart:item-added', handler)\n }, [props.onItemAdded])\n\n return (\n <nymbal-add-to-cart ref={ref as React.Ref<HTMLElement>} className={props.className} style={props.style} data-testid={props['data-testid']}>\n {props.children}\n </nymbal-add-to-cart>\n )\n },\n)\n\nexport interface CartDrawerProps {\n open?: boolean\n onCheckoutClick?: (event: CustomEvent<void>) => void\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport const CartDrawer = forwardRef<HTMLElement, CartDrawerProps>(\n function CartDrawer(props, forwardedRef) {\n const innerRef = useRef<HTMLElement>(null)\n const ref = (forwardedRef ?? innerRef) as React.RefObject<HTMLElement | null>\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.open) {\n el.setAttribute('open', '')\n } else {\n el.removeAttribute('open')\n }\n }, [props.open])\n\n useEffect(() => {\n const el = ref.current\n if (!el || !props.onCheckoutClick) return\n const handler = props.onCheckoutClick as EventListener\n el.addEventListener('nymbal:cart:checkout-clicked', handler)\n return () => el.removeEventListener('nymbal:cart:checkout-clicked', handler)\n }, [props.onCheckoutClick])\n\n return (\n <nymbal-cart-drawer ref={ref as React.Ref<HTMLElement>} className={props.className} style={props.style} data-testid={props['data-testid']}>\n \n </nymbal-cart-drawer>\n )\n },\n)\n\nexport interface MiniCartProps {\n onClick?: (event: CustomEvent<void>) => void\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport const MiniCart = forwardRef<HTMLElement, MiniCartProps>(\n function MiniCart(props, forwardedRef) {\n const innerRef = useRef<HTMLElement>(null)\n const ref = (forwardedRef ?? innerRef) as React.RefObject<HTMLElement | null>\n\n\n\n useEffect(() => {\n const el = ref.current\n if (!el || !props.onClick) return\n const handler = props.onClick as EventListener\n el.addEventListener('nymbal:mini-cart:clicked', handler)\n return () => el.removeEventListener('nymbal:mini-cart:clicked', handler)\n }, [props.onClick])\n\n return (\n <nymbal-mini-cart ref={ref as React.Ref<HTMLElement>} className={props.className} style={props.style} data-testid={props['data-testid']}>\n \n </nymbal-mini-cart>\n )\n },\n)\n\nexport interface VariantSelectorProps {\n options?: unknown\n onVariantSelected?: (event: CustomEvent<{ variant: unknown }>) => void\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport const VariantSelector = forwardRef<HTMLElement, VariantSelectorProps>(\n function VariantSelector(props, forwardedRef) {\n const innerRef = useRef<HTMLElement>(null)\n const ref = (forwardedRef ?? innerRef) as React.RefObject<HTMLElement | null>\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.options !== undefined) {\n el.setAttribute('options', JSON.stringify(props.options))\n } else {\n el.removeAttribute('options')\n }\n }, [props.options])\n\n useEffect(() => {\n const el = ref.current\n if (!el || !props.onVariantSelected) return\n const handler = props.onVariantSelected as EventListener\n el.addEventListener('nymbal:variant:selected', handler)\n return () => el.removeEventListener('nymbal:variant:selected', handler)\n }, [props.onVariantSelected])\n\n return (\n <nymbal-variant-selector ref={ref as React.Ref<HTMLElement>} className={props.className} style={props.style} data-testid={props['data-testid']}>\n \n </nymbal-variant-selector>\n )\n },\n)\n\nexport interface QuantitySelectorProps {\n value?: number\n min?: number\n max?: number\n onQuantityChange?: (event: CustomEvent<{ value: number }>) => void\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport const QuantitySelector = forwardRef<HTMLElement, QuantitySelectorProps>(\n function QuantitySelector(props, forwardedRef) {\n const innerRef = useRef<HTMLElement>(null)\n const ref = (forwardedRef ?? innerRef) as React.RefObject<HTMLElement | null>\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.value !== undefined) {\n el.setAttribute('value', String(props.value))\n } else {\n el.removeAttribute('value')\n }\n }, [props.value])\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.min !== undefined) {\n el.setAttribute('min', String(props.min))\n } else {\n el.removeAttribute('min')\n }\n }, [props.min])\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.max !== undefined) {\n el.setAttribute('max', String(props.max))\n } else {\n el.removeAttribute('max')\n }\n }, [props.max])\n\n useEffect(() => {\n const el = ref.current\n if (!el || !props.onQuantityChange) return\n const handler = props.onQuantityChange as EventListener\n el.addEventListener('nymbal:quantity:changed', handler)\n return () => el.removeEventListener('nymbal:quantity:changed', handler)\n }, [props.onQuantityChange])\n\n return (\n <nymbal-quantity-selector ref={ref as React.Ref<HTMLElement>} className={props.className} style={props.style} data-testid={props['data-testid']}>\n \n </nymbal-quantity-selector>\n )\n },\n)\n\nexport interface SearchBarProps {\n placeholder?: string\n debounceMs?: number\n onSearchSelect?: (event: CustomEvent<{ product: unknown }>) => void\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport const SearchBar = forwardRef<HTMLElement, SearchBarProps>(\n function SearchBar(props, forwardedRef) {\n const innerRef = useRef<HTMLElement>(null)\n const ref = (forwardedRef ?? innerRef) as React.RefObject<HTMLElement | null>\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.placeholder !== undefined) {\n el.setAttribute('placeholder', String(props.placeholder))\n } else {\n el.removeAttribute('placeholder')\n }\n }, [props.placeholder])\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.debounceMs !== undefined) {\n el.setAttribute('debounce-ms', String(props.debounceMs))\n } else {\n el.removeAttribute('debounce-ms')\n }\n }, [props.debounceMs])\n\n useEffect(() => {\n const el = ref.current\n if (!el || !props.onSearchSelect) return\n const handler = props.onSearchSelect as EventListener\n el.addEventListener('nymbal:search:selected', handler)\n return () => el.removeEventListener('nymbal:search:selected', handler)\n }, [props.onSearchSelect])\n\n return (\n <nymbal-search-bar ref={ref as React.Ref<HTMLElement>} className={props.className} style={props.style} data-testid={props['data-testid']}>\n \n </nymbal-search-bar>\n )\n },\n)\n\nexport interface ProductFilterProps {\n facets?: unknown\n onFilterChange?: (event: CustomEvent<{ name: string; value: string }>) => void\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport const ProductFilter = forwardRef<HTMLElement, ProductFilterProps>(\n function ProductFilter(props, forwardedRef) {\n const innerRef = useRef<HTMLElement>(null)\n const ref = (forwardedRef ?? innerRef) as React.RefObject<HTMLElement | null>\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.facets !== undefined) {\n el.setAttribute('facets', JSON.stringify(props.facets))\n } else {\n el.removeAttribute('facets')\n }\n }, [props.facets])\n\n useEffect(() => {\n const el = ref.current\n if (!el || !props.onFilterChange) return\n const handler = props.onFilterChange as EventListener\n el.addEventListener('nymbal:filter:changed', handler)\n return () => el.removeEventListener('nymbal:filter:changed', handler)\n }, [props.onFilterChange])\n\n return (\n <nymbal-product-filter ref={ref as React.Ref<HTMLElement>} className={props.className} style={props.style} data-testid={props['data-testid']}>\n \n </nymbal-product-filter>\n )\n },\n)\n\nexport interface ToastProps {\n position?: string\n durationMs?: number\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport const Toast = forwardRef<HTMLElement, ToastProps>(\n function Toast(props, forwardedRef) {\n const innerRef = useRef<HTMLElement>(null)\n const ref = (forwardedRef ?? innerRef) as React.RefObject<HTMLElement | null>\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.position !== undefined) {\n el.setAttribute('position', String(props.position))\n } else {\n el.removeAttribute('position')\n }\n }, [props.position])\n\n useEffect(() => {\n const el = ref.current\n if (!el) return\n if (props.durationMs !== undefined) {\n el.setAttribute('duration-ms', String(props.durationMs))\n } else {\n el.removeAttribute('duration-ms')\n }\n }, [props.durationMs])\n\n\n\n return (\n <nymbal-toast ref={ref as React.Ref<HTMLElement>} className={props.className} style={props.style} data-testid={props['data-testid']}>\n \n </nymbal-toast>\n )\n },\n)\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkC;AAWjD;AART,IAAM,gBAAgB,cAAmC,IAAI;AAOtD,SAAS,eAAe,EAAE,QAAQ,SAAS,GAAmC;AACnF,SAAO,oBAAC,cAAc,UAAd,EAAuB,OAAO,QAAS,UAAS;AAC1D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,SAAS,WAAW,aAAa;AACvC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACA,SAAO;AACT;;;ACpBA,SAAS,4BAA4B;AAY9B,SAAS,UAAyB;AACvC,QAAM,SAAS,gBAAgB;AAC/B,QAAM,QAAQ;AAAA,IACZ,OAAO,KAAK;AAAA,IACZ,OAAO,KAAK;AAAA,IACZ,OAAO,KAAK;AAAA,EACd;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,OAAO,KAAK;AAAA,IACrB,YAAY,OAAO,KAAK;AAAA,IACxB,gBAAgB,OAAO,KAAK;AAAA,IAC5B,OAAO,OAAO,KAAK;AAAA,IACnB,MAAM,OAAO,KAAK;AAAA,EACpB;AACF;;;AC3BA,SAAS,wBAAAA,uBAAsB,iBAAiB;AASzC,SAAS,WAAW,MAAiC;AAC1D,QAAM,SAAS,gBAAgB;AAC/B,QAAM,QAAQC;AAAA,IACZ,OAAO,QAAQ;AAAA,IACf,OAAO,QAAQ;AAAA,IACf,OAAO,QAAQ;AAAA,EACjB;AAEA,YAAU,MAAM;AACd,QAAI,MAAM;AACR,aAAO,QAAQ,WAAW,IAAI;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,MAAM,OAAO,OAAO,CAAC;AAEzB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY,OAAO,QAAQ;AAAA,IAC3B,eAAe,OAAO,QAAQ;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GAE3I;AAAA,EAEJ;AACF;AAUO,IAAM,QAAQ;AAAA,EACnB,SAASQ,OAAM,OAAO,cAAc;AAClC,UAAM,WAAW,OAAoB,IAAI;AACzC,UAAM,MAAO,gBAAgB;AAE/B,IAAAT,WAAU,MAAM;AACd,YAAM,KAAK,IAAI;AACf,UAAI,CAAC,GAAI;AACT,UAAI,MAAM,aAAa,QAAW;AAChC,WAAG,aAAa,YAAY,OAAO,MAAM,QAAQ,CAAC;AAAA,MACpD,OAAO;AACL,WAAG,gBAAgB,UAAU;AAAA,MAC/B;AAAA,IACF,GAAG,CAAC,MAAM,QAAQ,CAAC;AAEnB,IAAAA,WAAU,MAAM;AACd,YAAM,KAAK,IAAI;AACf,UAAI,CAAC,GAAI;AACT,UAAI,MAAM,eAAe,QAAW;AAClC,WAAG,aAAa,eAAe,OAAO,MAAM,UAAU,CAAC;AAAA,MACzD,OAAO;AACL,WAAG,gBAAgB,aAAa;AAAA,MAClC;AAAA,IACF,GAAG,CAAC,MAAM,UAAU,CAAC;AAInB,WACE,gBAAAC,KAAC,kBAAa,KAAoC,WAAW,MAAM,WAAW,OAAO,MAAM,OAAO,eAAa,MAAM,aAAa,GAElI;AAAA,EAEJ;AACF;","names":["useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","useEffect","jsx","AddToCart","CartDrawer","MiniCart","VariantSelector","QuantitySelector","SearchBar","ProductFilter","Toast"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nymbalhq/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "React bindings for the Nymbal commerce SDK",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/nymbalhq/nymbal.git",
|
|
9
|
+
"directory": "packages/react"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22"
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@nymbalhq/sdk": "0.2.0",
|
|
31
|
+
"@nymbalhq/web-components": "0.2.0",
|
|
32
|
+
"@nymbalhq/types": "0.2.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": ">=19.0.0",
|
|
36
|
+
"react-dom": ">=19.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@testing-library/jest-dom": "^6.4.0",
|
|
40
|
+
"@testing-library/react": "^16.0.0",
|
|
41
|
+
"@types/react": "^19.3.0",
|
|
42
|
+
"@types/react-dom": "^19.3.0",
|
|
43
|
+
"react": "^19.3.1",
|
|
44
|
+
"react-dom": "^19.3.1",
|
|
45
|
+
"tsup": "^8.3.5",
|
|
46
|
+
"tsx": "^4.19.2",
|
|
47
|
+
"typescript": "^5.6.3",
|
|
48
|
+
"vitest": "^3.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsx scripts/generate-wrappers.ts && tsup",
|
|
52
|
+
"dev": "tsup --watch",
|
|
53
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
54
|
+
"generate": "tsx scripts/generate-wrappers.ts",
|
|
55
|
+
"check:generated": "tsx scripts/generate-wrappers.ts --check"
|
|
56
|
+
}
|
|
6
57
|
}
|
package/README.md
DELETED