@instockng/storefront-ui 1.0.10 → 1.0.12
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/README.md +26 -0
- package/dist/components/Checkout.d.ts.map +1 -1
- package/dist/components/ShoppingCart.d.ts.map +1 -1
- package/dist/contexts/CartContext.d.ts.map +1 -1
- package/dist/index10.mjs +144 -141
- package/dist/index101.mjs +1 -1
- package/dist/index102.mjs +3 -3
- package/dist/index103.mjs +3 -3
- package/dist/index105.mjs +1 -1
- package/dist/index111.mjs +1 -1
- package/dist/index20.mjs +2 -2
- package/dist/index21.mjs +1 -1
- package/dist/index28.mjs +11 -11
- package/dist/index3.mjs +88 -78
- package/dist/index37.mjs +1 -1
- package/dist/index41.mjs +36 -23
- package/dist/index42.mjs +44 -36
- package/dist/index43.mjs +99 -44
- package/dist/index44.mjs +112 -99
- package/dist/index45.mjs +44 -80
- package/dist/index46.mjs +64 -53
- package/dist/index47.mjs +65 -48
- package/dist/index48.mjs +54 -73
- package/dist/index49.mjs +52 -63
- package/dist/index50.mjs +14 -70
- package/dist/index51.mjs +13 -14
- package/dist/index52.mjs +58 -13
- package/dist/index53.mjs +101 -34
- package/dist/index54.mjs +99 -95
- package/dist/index55.mjs +22 -132
- package/dist/index62.mjs +30 -231
- package/dist/index63.mjs +42 -5
- package/dist/index64.mjs +228 -127
- package/dist/index65.mjs +4 -66
- package/dist/index66.mjs +124 -77
- package/dist/index67.mjs +65 -26
- package/dist/index68.mjs +84 -6
- package/dist/index69.mjs +26 -72
- package/dist/index70.mjs +8 -3
- package/dist/index71.mjs +75 -2
- package/dist/index72.mjs +3 -82
- package/dist/index73.mjs +2 -54
- package/dist/index74.mjs +82 -5
- package/dist/index75.mjs +53 -4
- package/dist/index76.mjs +5 -178
- package/dist/index77.mjs +5 -53
- package/dist/index78.mjs +178 -68
- package/dist/index79.mjs +50 -31
- package/dist/index8.mjs +8 -7
- package/dist/index80.mjs +69 -43
- package/dist/index81.mjs +2 -2
- package/dist/index82.mjs +1 -1
- package/dist/index83.mjs +6 -6
- package/dist/index84.mjs +2 -2
- package/dist/index85.mjs +2 -2
- package/dist/index87.mjs +2 -2
- package/dist/index88.mjs +2 -2
- package/dist/index89.mjs +1 -1
- package/dist/index91.mjs +4 -4
- package/dist/index92.mjs +3 -3
- package/dist/index93.mjs +12 -30
- package/dist/index94.mjs +7 -11
- package/dist/index95.mjs +30 -3
- package/dist/index96.mjs +10 -3
- package/dist/index97.mjs +4 -13
- package/dist/index98.mjs +4 -7
- package/dist/index99.mjs +1 -1
- package/dist/styles.css +1 -0
- package/package.json +14 -13
- package/src/components/CartItem.stories.tsx +94 -0
- package/src/components/CartItem.tsx +141 -0
- package/src/components/Checkout.stories.tsx +380 -0
- package/src/components/Checkout.tsx +954 -0
- package/src/components/DiscountCodeInput.stories.tsx +76 -0
- package/src/components/DiscountCodeInput.tsx +162 -0
- package/src/components/OrderConfirmation.stories.tsx +142 -0
- package/src/components/OrderConfirmation.tsx +301 -0
- package/src/components/ProductCard.stories.tsx +112 -0
- package/src/components/ProductCard.tsx +195 -0
- package/src/components/ProductGrid.stories.tsx +137 -0
- package/src/components/ProductGrid.tsx +141 -0
- package/src/components/ShoppingCart.stories.tsx +459 -0
- package/src/components/ShoppingCart.tsx +263 -0
- package/src/components/ui/badge.tsx +37 -0
- package/src/components/ui/button.tsx +71 -0
- package/src/components/ui/card.tsx +79 -0
- package/src/components/ui/form-input.tsx +78 -0
- package/src/components/ui/form-select.tsx +73 -0
- package/src/components/ui/modal.tsx +181 -0
- package/src/contexts/CartContext.tsx +316 -0
- package/src/hooks/usePaystackPayment.ts +137 -0
- package/src/index.ts +51 -0
- package/src/lib/utils.ts +45 -0
- package/src/paystack.svg +67 -0
- package/src/providers/StorefrontProvider.tsx +70 -0
- package/src/styles.css +1 -0
- package/src/test-utils/MockCartProvider.tsx +424 -0
- package/src/vite-env.d.ts +12 -0
package/dist/index20.mjs
CHANGED
package/dist/index21.mjs
CHANGED
package/dist/index28.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useCreateOrder as s, useDeleteOrder as r, useGetOrder as u, useListOrders as o, useUpdateOrder as a, useUpdateOrderStatus as n } from "./
|
|
3
|
-
import { useCreateBrand as i, useDeleteBrand as p, useGetBrand as C, useListBrands as D, useUpdateBrand as c } from "./
|
|
4
|
-
import { useCreateProduct as G, useDeleteProduct as f, useGetProduct as m, useListProducts as v, useUpdateProduct as x } from "./
|
|
5
|
-
import { useCreateVariant as L, useDeleteVariant as S, useGetVariantInventory as U, useListProductVariants as O, useSearchVariants as V, useUpdateVariant as h } from "./
|
|
6
|
-
import { useCreateWarehouse as I, useDeleteWarehouse as P, useGetWarehouseInventory as A, useListWarehouses as W, useUpdateWarehouse as Z } from "./
|
|
7
|
-
import { useAdjustInventory as k, useGetInventoryTransactions as w, useGetLowStockVariants as T, useListInventory as j, useTransferInventory as E } from "./
|
|
8
|
-
import { useGetCustomerHistory as g } from "./
|
|
9
|
-
import { useGetStats as z } from "./
|
|
10
|
-
import { useCleanupExpiredCarts as J, useGetAbandonedCart as K, useGetAbandonedCartStats as M, useListAbandonedCarts as N } from "./
|
|
11
|
-
import { useBulkGenerateDiscountCodes as R, useCreateDiscountCode as X, useDeleteDiscountCode as Y, useGetDiscountCode as _, useGetDiscountCodeAnalytics as $, useGetDiscountCodeOverviewStats as ee, useListDiscountCodes as te, useUpdateDiscountCode as se } from "./
|
|
12
|
-
import { useCreateDeliveryZone as ue, useCreateState as oe, useDeleteDeliveryZone as ae, useDeleteState as ne, useListDeliveryZones as de, useListStates as ie, useUpdateDeliveryZone as pe, useUpdateState as Ce } from "./
|
|
2
|
+
import { useCreateOrder as s, useDeleteOrder as r, useGetOrder as u, useListOrders as o, useUpdateOrder as a, useUpdateOrderStatus as n } from "./index44.mjs";
|
|
3
|
+
import { useCreateBrand as i, useDeleteBrand as p, useGetBrand as C, useListBrands as D, useUpdateBrand as c } from "./index45.mjs";
|
|
4
|
+
import { useCreateProduct as G, useDeleteProduct as f, useGetProduct as m, useListProducts as v, useUpdateProduct as x } from "./index46.mjs";
|
|
5
|
+
import { useCreateVariant as L, useDeleteVariant as S, useGetVariantInventory as U, useListProductVariants as O, useSearchVariants as V, useUpdateVariant as h } from "./index47.mjs";
|
|
6
|
+
import { useCreateWarehouse as I, useDeleteWarehouse as P, useGetWarehouseInventory as A, useListWarehouses as W, useUpdateWarehouse as Z } from "./index48.mjs";
|
|
7
|
+
import { useAdjustInventory as k, useGetInventoryTransactions as w, useGetLowStockVariants as T, useListInventory as j, useTransferInventory as E } from "./index49.mjs";
|
|
8
|
+
import { useGetCustomerHistory as g } from "./index50.mjs";
|
|
9
|
+
import { useGetStats as z } from "./index51.mjs";
|
|
10
|
+
import { useCleanupExpiredCarts as J, useGetAbandonedCart as K, useGetAbandonedCartStats as M, useListAbandonedCarts as N } from "./index52.mjs";
|
|
11
|
+
import { useBulkGenerateDiscountCodes as R, useCreateDiscountCode as X, useDeleteDiscountCode as Y, useGetDiscountCode as _, useGetDiscountCodeAnalytics as $, useGetDiscountCodeOverviewStats as ee, useListDiscountCodes as te, useUpdateDiscountCode as se } from "./index53.mjs";
|
|
12
|
+
import { useCreateDeliveryZone as ue, useCreateState as oe, useDeleteDeliveryZone as ae, useDeleteState as ne, useListDeliveryZones as de, useListStates as ie, useUpdateDeliveryZone as pe, useUpdateState as Ce } from "./index54.mjs";
|
|
13
13
|
export {
|
|
14
14
|
k as useAdjustInventory,
|
|
15
15
|
R as useBulkGenerateDiscountCodes,
|
package/dist/index3.mjs
CHANGED
|
@@ -1,135 +1,145 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createContext as
|
|
2
|
+
import { jsxs as Y, jsx as q } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as z, useState as d, useRef as w, useEffect as a, useCallback as r, useContext as B } from "react";
|
|
4
4
|
import "./index18.mjs";
|
|
5
|
-
import { useGetCart as
|
|
5
|
+
import { useGetCart as J, useCreateCart as Q, useAddCartItem as V, useUpdateCartItem as W, useRemoveCartItem as X, useApplyDiscount as Z, useRemoveDiscount as $, useUpdateCart as tt, useCheckoutCart as et } from "./index29.mjs";
|
|
6
6
|
import "@tanstack/react-query";
|
|
7
|
-
import { ShoppingCart as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
const [t,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import { ShoppingCart as rt } from "./index8.mjs";
|
|
8
|
+
const m = "oms_cart_id", D = z(null);
|
|
9
|
+
function it({ children: c, brandSlug: f, initialCartId: u, shoppingCartProps: E }) {
|
|
10
|
+
const [t, s] = d(u || null), [p, C] = d(!1), [M, g] = d(!1), I = w(!1), h = w(!1), l = w(!1);
|
|
11
|
+
a(() => {
|
|
12
|
+
g(!0);
|
|
13
|
+
}, []), a(() => {
|
|
14
|
+
if (u || I.current) return;
|
|
15
|
+
I.current = !0;
|
|
16
|
+
const n = new URLSearchParams(window.location.search).get("cartId");
|
|
17
|
+
if (n) {
|
|
18
|
+
s(n);
|
|
19
|
+
return;
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
const v = localStorage.getItem(m);
|
|
22
|
+
v && s(v);
|
|
23
|
+
}, [u]);
|
|
24
|
+
const { data: A, isLoading: R, error: i, refetch: o } = J(t || "", {
|
|
18
25
|
enabled: !!t,
|
|
19
26
|
retry: !1
|
|
20
27
|
// Don't retry on failure - cart might be invalid/expired
|
|
21
|
-
}),
|
|
28
|
+
}), y = Q({
|
|
22
29
|
onSuccess: (e) => {
|
|
23
30
|
if ("error" in e) {
|
|
24
31
|
console.error("Failed to create cart:", e.error);
|
|
25
32
|
return;
|
|
26
33
|
}
|
|
27
|
-
|
|
34
|
+
s(e.id);
|
|
28
35
|
},
|
|
29
36
|
onError: (e) => {
|
|
30
37
|
console.error("Failed to create cart:", e);
|
|
31
38
|
}
|
|
32
39
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
a(() => {
|
|
41
|
+
if (h.current) return;
|
|
42
|
+
h.current = !0;
|
|
43
|
+
const e = setTimeout(() => {
|
|
44
|
+
!t && !u && y.mutate(f);
|
|
45
|
+
}, 150);
|
|
46
|
+
return () => clearTimeout(e);
|
|
47
|
+
}, []), a(() => {
|
|
48
|
+
i && t && !l.current && (l.current = !0, console.warn("Cart fetch failed, creating new cart:", i), s(null), typeof window < "u" && localStorage.removeItem(m), setTimeout(() => {
|
|
49
|
+
y.mutate(f), l.current = !1;
|
|
50
|
+
}, 100));
|
|
51
|
+
}, [i, t, f]);
|
|
52
|
+
const x = V(t || "", {
|
|
43
53
|
onSuccess: () => o()
|
|
44
|
-
}),
|
|
54
|
+
}), P = W(t || "", {
|
|
45
55
|
onSuccess: () => o()
|
|
46
|
-
}),
|
|
56
|
+
}), N = X(t || "", {
|
|
47
57
|
onSuccess: () => o()
|
|
48
|
-
}),
|
|
58
|
+
}), F = Z(t || "", {
|
|
49
59
|
onSuccess: () => o()
|
|
50
|
-
}),
|
|
60
|
+
}), T = $(t || "", {
|
|
51
61
|
onSuccess: () => o()
|
|
52
|
-
}),
|
|
62
|
+
}), U = tt(t || "", {
|
|
53
63
|
onSuccess: () => o()
|
|
54
|
-
}),
|
|
55
|
-
|
|
56
|
-
t && typeof window < "u" && localStorage.setItem(
|
|
64
|
+
}), _ = et(t || "");
|
|
65
|
+
a(() => {
|
|
66
|
+
t && typeof window < "u" && localStorage.setItem(m, t);
|
|
57
67
|
}, [t]);
|
|
58
|
-
const
|
|
68
|
+
const k = r(
|
|
59
69
|
async (e, n) => {
|
|
60
70
|
if (!t) throw new Error("No cart ID");
|
|
61
|
-
await
|
|
71
|
+
await x.mutateAsync({ sku: e, quantity: n });
|
|
62
72
|
},
|
|
63
73
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
74
|
[t]
|
|
65
|
-
),
|
|
75
|
+
), L = r(
|
|
66
76
|
async (e, n) => {
|
|
67
77
|
if (!t) throw new Error("No cart ID");
|
|
68
|
-
await
|
|
78
|
+
await P.mutateAsync({ itemId: e, quantity: n });
|
|
69
79
|
},
|
|
70
80
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
71
81
|
[t]
|
|
72
|
-
),
|
|
82
|
+
), j = r(
|
|
73
83
|
async (e) => {
|
|
74
84
|
if (!t) throw new Error("No cart ID");
|
|
75
|
-
await
|
|
85
|
+
await N.mutateAsync(e);
|
|
76
86
|
},
|
|
77
87
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
88
|
[t]
|
|
79
|
-
),
|
|
89
|
+
), O = r(
|
|
80
90
|
async (e) => {
|
|
81
91
|
if (!t) throw new Error("No cart ID");
|
|
82
|
-
await
|
|
92
|
+
await F.mutateAsync({ code: e });
|
|
83
93
|
},
|
|
84
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
95
|
[t]
|
|
86
|
-
),
|
|
96
|
+
), b = r(async () => {
|
|
87
97
|
if (!t) throw new Error("No cart ID");
|
|
88
|
-
await
|
|
89
|
-
}, [t]),
|
|
90
|
-
|
|
91
|
-
}, []),
|
|
92
|
-
|
|
93
|
-
}, []),
|
|
94
|
-
|
|
95
|
-
}, []),
|
|
96
|
-
cart:
|
|
98
|
+
await T.mutateAsync();
|
|
99
|
+
}, [t]), G = r(() => {
|
|
100
|
+
s(null), typeof window < "u" && localStorage.removeItem(m);
|
|
101
|
+
}, []), H = r(() => {
|
|
102
|
+
C(!0);
|
|
103
|
+
}, []), S = r(() => {
|
|
104
|
+
C(!1);
|
|
105
|
+
}, []), K = {
|
|
106
|
+
cart: A || null,
|
|
97
107
|
cartId: t,
|
|
98
|
-
isLoading:
|
|
99
|
-
error:
|
|
100
|
-
updateCartMutation:
|
|
101
|
-
checkoutMutation:
|
|
102
|
-
addItem:
|
|
103
|
-
updateItem:
|
|
104
|
-
removeItem:
|
|
105
|
-
applyDiscount:
|
|
106
|
-
removeDiscount:
|
|
107
|
-
clearCart:
|
|
108
|
+
isLoading: R,
|
|
109
|
+
error: i,
|
|
110
|
+
updateCartMutation: U,
|
|
111
|
+
checkoutMutation: _,
|
|
112
|
+
addItem: k,
|
|
113
|
+
updateItem: L,
|
|
114
|
+
removeItem: j,
|
|
115
|
+
applyDiscount: O,
|
|
116
|
+
removeDiscount: b,
|
|
117
|
+
clearCart: G,
|
|
108
118
|
refetch: o,
|
|
109
|
-
isOpen:
|
|
110
|
-
open:
|
|
111
|
-
close:
|
|
119
|
+
isOpen: p,
|
|
120
|
+
open: H,
|
|
121
|
+
close: S
|
|
112
122
|
};
|
|
113
|
-
return /* @__PURE__ */
|
|
114
|
-
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
|
|
123
|
+
return /* @__PURE__ */ Y(D.Provider, { value: K, children: [
|
|
124
|
+
c,
|
|
125
|
+
M && /* @__PURE__ */ q(
|
|
126
|
+
rt,
|
|
117
127
|
{
|
|
118
|
-
isOpen:
|
|
119
|
-
onClose:
|
|
120
|
-
...
|
|
128
|
+
isOpen: p,
|
|
129
|
+
onClose: S,
|
|
130
|
+
...E
|
|
121
131
|
}
|
|
122
132
|
)
|
|
123
133
|
] });
|
|
124
134
|
}
|
|
125
|
-
function
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
135
|
+
function mt() {
|
|
136
|
+
const c = B(D);
|
|
137
|
+
if (!c)
|
|
128
138
|
throw new Error("useCart must be used within CartProvider");
|
|
129
|
-
return
|
|
139
|
+
return c;
|
|
130
140
|
}
|
|
131
141
|
export {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
142
|
+
D as CartContext,
|
|
143
|
+
it as CartProvider,
|
|
144
|
+
mt as useCart
|
|
135
145
|
};
|
package/dist/index37.mjs
CHANGED
package/dist/index41.mjs
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
}
|
|
2
|
+
import o from "./index42.mjs";
|
|
3
|
+
const {
|
|
4
|
+
Axios: e,
|
|
5
|
+
AxiosError: a,
|
|
6
|
+
CanceledError: s,
|
|
7
|
+
isCancel: t,
|
|
8
|
+
CancelToken: i,
|
|
9
|
+
VERSION: l,
|
|
10
|
+
all: n,
|
|
11
|
+
Cancel: d,
|
|
12
|
+
isAxiosError: x,
|
|
13
|
+
spread: C,
|
|
14
|
+
toFormData: c,
|
|
15
|
+
AxiosHeaders: m,
|
|
16
|
+
HttpStatusCode: p,
|
|
17
|
+
formToJSON: A,
|
|
18
|
+
getAdapter: f,
|
|
19
|
+
mergeConfig: E
|
|
20
|
+
} = o;
|
|
24
21
|
export {
|
|
25
|
-
|
|
22
|
+
e as Axios,
|
|
23
|
+
a as AxiosError,
|
|
24
|
+
m as AxiosHeaders,
|
|
25
|
+
d as Cancel,
|
|
26
|
+
i as CancelToken,
|
|
27
|
+
s as CanceledError,
|
|
28
|
+
p as HttpStatusCode,
|
|
29
|
+
l as VERSION,
|
|
30
|
+
n as all,
|
|
31
|
+
o as default,
|
|
32
|
+
A as formToJSON,
|
|
33
|
+
f as getAdapter,
|
|
34
|
+
x as isAxiosError,
|
|
35
|
+
t as isCancel,
|
|
36
|
+
E as mergeConfig,
|
|
37
|
+
C as spread,
|
|
38
|
+
c as toFormData
|
|
26
39
|
};
|
package/dist/index42.mjs
CHANGED
|
@@ -1,39 +1,47 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
import a from "./index64.mjs";
|
|
3
|
+
import p from "./index65.mjs";
|
|
4
|
+
import m from "./index66.mjs";
|
|
5
|
+
import i from "./index67.mjs";
|
|
6
|
+
import f from "./index68.mjs";
|
|
7
|
+
import l from "./index69.mjs";
|
|
8
|
+
import c from "./index70.mjs";
|
|
9
|
+
import d from "./index71.mjs";
|
|
10
|
+
import u from "./index72.mjs";
|
|
11
|
+
import { VERSION as x } from "./index73.mjs";
|
|
12
|
+
import C from "./index74.mjs";
|
|
13
|
+
import A from "./index75.mjs";
|
|
14
|
+
import E from "./index76.mjs";
|
|
15
|
+
import O from "./index77.mjs";
|
|
16
|
+
import S from "./index78.mjs";
|
|
17
|
+
import H from "./index79.mjs";
|
|
18
|
+
import T from "./index80.mjs";
|
|
19
|
+
function n(o) {
|
|
20
|
+
const t = new m(o), e = p(m.prototype.request, t);
|
|
21
|
+
return a.extend(e, m.prototype, t, { allOwnKeys: !0 }), a.extend(e, t, null, { allOwnKeys: !0 }), e.create = function(s) {
|
|
22
|
+
return n(i(o, s));
|
|
23
|
+
}, e;
|
|
24
|
+
}
|
|
25
|
+
const r = n(f);
|
|
26
|
+
r.Axios = m;
|
|
27
|
+
r.CanceledError = c;
|
|
28
|
+
r.CancelToken = d;
|
|
29
|
+
r.isCancel = u;
|
|
30
|
+
r.VERSION = x;
|
|
31
|
+
r.toFormData = C;
|
|
32
|
+
r.AxiosError = A;
|
|
33
|
+
r.Cancel = r.CanceledError;
|
|
34
|
+
r.all = function(t) {
|
|
35
|
+
return Promise.all(t);
|
|
36
|
+
};
|
|
37
|
+
r.spread = E;
|
|
38
|
+
r.isAxiosError = O;
|
|
39
|
+
r.mergeConfig = i;
|
|
40
|
+
r.AxiosHeaders = S;
|
|
41
|
+
r.formToJSON = (o) => l(a.isHTMLForm(o) ? new FormData(o) : o);
|
|
42
|
+
r.getAdapter = H.getAdapter;
|
|
43
|
+
r.HttpStatusCode = T;
|
|
44
|
+
r.default = r;
|
|
21
45
|
export {
|
|
22
|
-
|
|
23
|
-
a as AxiosError,
|
|
24
|
-
m as AxiosHeaders,
|
|
25
|
-
d as Cancel,
|
|
26
|
-
i as CancelToken,
|
|
27
|
-
s as CanceledError,
|
|
28
|
-
p as HttpStatusCode,
|
|
29
|
-
l as VERSION,
|
|
30
|
-
n as all,
|
|
31
|
-
o as default,
|
|
32
|
-
A as formToJSON,
|
|
33
|
-
f as getAdapter,
|
|
34
|
-
x as isAxiosError,
|
|
35
|
-
t as isCancel,
|
|
36
|
-
E as mergeConfig,
|
|
37
|
-
C as spread,
|
|
38
|
-
c as toFormData
|
|
46
|
+
r as default
|
|
39
47
|
};
|
package/dist/index43.mjs
CHANGED
|
@@ -1,47 +1,102 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
r
|
|
28
|
-
r
|
|
29
|
-
r.
|
|
30
|
-
|
|
31
|
-
r.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
r.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
r
|
|
44
|
-
|
|
2
|
+
var p = Object.defineProperty;
|
|
3
|
+
var k = (r, e, i) => e in r ? p(r, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[e] = i;
|
|
4
|
+
var h = (r, e, i) => k(r, typeof e != "symbol" ? e + "" : e, i);
|
|
5
|
+
import { serialize as j } from "./index62.mjs";
|
|
6
|
+
import { mergePath as U, replaceUrlParam as P, buildSearchParams as S, removeIndexString as w, replaceUrlProtocol as x, deepMerge as C } from "./index63.mjs";
|
|
7
|
+
var v = (r, e) => new Proxy(() => {
|
|
8
|
+
}, {
|
|
9
|
+
get(t, s) {
|
|
10
|
+
if (!(typeof s != "string" || s === "then"))
|
|
11
|
+
return v(r, [...e, s]);
|
|
12
|
+
},
|
|
13
|
+
apply(t, s, a) {
|
|
14
|
+
return r({
|
|
15
|
+
path: e,
|
|
16
|
+
args: a
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}), T = class {
|
|
20
|
+
constructor(r, e) {
|
|
21
|
+
h(this, "url");
|
|
22
|
+
h(this, "method");
|
|
23
|
+
h(this, "queryParams");
|
|
24
|
+
h(this, "pathParams", {});
|
|
25
|
+
h(this, "rBody");
|
|
26
|
+
h(this, "cType");
|
|
27
|
+
h(this, "fetch", async (r, e) => {
|
|
28
|
+
if (r) {
|
|
29
|
+
if (r.query && (this.queryParams = S(r.query)), r.form) {
|
|
30
|
+
const o = new FormData();
|
|
31
|
+
for (const [c, f] of Object.entries(r.form))
|
|
32
|
+
if (Array.isArray(f))
|
|
33
|
+
for (const l of f)
|
|
34
|
+
o.append(c, l);
|
|
35
|
+
else
|
|
36
|
+
o.append(c, f);
|
|
37
|
+
this.rBody = o;
|
|
38
|
+
}
|
|
39
|
+
r.json && (this.rBody = JSON.stringify(r.json), this.cType = "application/json"), r.param && (this.pathParams = r.param);
|
|
40
|
+
}
|
|
41
|
+
let i = this.method.toUpperCase();
|
|
42
|
+
const t = {
|
|
43
|
+
...r == null ? void 0 : r.header,
|
|
44
|
+
...typeof (e == null ? void 0 : e.headers) == "function" ? await e.headers() : e == null ? void 0 : e.headers
|
|
45
|
+
};
|
|
46
|
+
if (r != null && r.cookie) {
|
|
47
|
+
const o = [];
|
|
48
|
+
for (const [c, f] of Object.entries(r.cookie))
|
|
49
|
+
o.push(j(c, f, { path: "/" }));
|
|
50
|
+
t.Cookie = o.join(",");
|
|
51
|
+
}
|
|
52
|
+
this.cType && (t["Content-Type"] = this.cType);
|
|
53
|
+
const s = new Headers(t ?? void 0);
|
|
54
|
+
let a = this.url;
|
|
55
|
+
a = w(a), a = P(a, this.pathParams), this.queryParams && (a = a + "?" + this.queryParams.toString()), i = this.method.toUpperCase();
|
|
56
|
+
const u = !(i === "GET" || i === "HEAD");
|
|
57
|
+
return ((e == null ? void 0 : e.fetch) || fetch)(a, {
|
|
58
|
+
body: u ? this.rBody : void 0,
|
|
59
|
+
method: i,
|
|
60
|
+
headers: s,
|
|
61
|
+
...e == null ? void 0 : e.init
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
this.url = r, this.method = e;
|
|
65
|
+
}
|
|
66
|
+
}, E = (r, e) => v(function i(t) {
|
|
67
|
+
var l;
|
|
68
|
+
const s = [...t.path], a = s.slice(-3).reverse();
|
|
69
|
+
if (a[0] === "toString")
|
|
70
|
+
return a[1] === "name" ? a[2] || "" : i.toString();
|
|
71
|
+
if (a[0] === "valueOf")
|
|
72
|
+
return a[1] === "name" ? a[2] || "" : i;
|
|
73
|
+
let u = "";
|
|
74
|
+
if (/^\$/.test(a[0])) {
|
|
75
|
+
const n = s.pop();
|
|
76
|
+
n && (u = n.replace(/^\$/, ""));
|
|
77
|
+
}
|
|
78
|
+
const o = s.join("/"), c = U(r, o);
|
|
79
|
+
if (u === "url") {
|
|
80
|
+
let n = c;
|
|
81
|
+
return t.args[0] && (t.args[0].param && (n = P(c, t.args[0].param)), t.args[0].query && (n = n + "?" + S(t.args[0].query).toString())), n = w(n), new URL(n);
|
|
82
|
+
}
|
|
83
|
+
if (u === "ws") {
|
|
84
|
+
const n = x(
|
|
85
|
+
t.args[0] && t.args[0].param ? P(c, t.args[0].param) : c,
|
|
86
|
+
"ws"
|
|
87
|
+
), y = new URL(n), b = (l = t.args[0]) == null ? void 0 : l.query;
|
|
88
|
+
return b && Object.entries(b).forEach(([m, d]) => {
|
|
89
|
+
Array.isArray(d) ? d.forEach((q) => y.searchParams.append(m, q)) : y.searchParams.set(m, d);
|
|
90
|
+
}), ((...m) => (e == null ? void 0 : e.webSocket) !== void 0 && typeof e.webSocket == "function" ? e.webSocket(...m) : new WebSocket(...m))(y.toString());
|
|
91
|
+
}
|
|
92
|
+
const f = new T(c, u);
|
|
93
|
+
if (u) {
|
|
94
|
+
e ?? (e = {});
|
|
95
|
+
const n = C(e, { ...t.args[1] });
|
|
96
|
+
return f.fetch(t.args[0], n);
|
|
97
|
+
}
|
|
98
|
+
return f;
|
|
99
|
+
}, []);
|
|
45
100
|
export {
|
|
46
|
-
|
|
101
|
+
E as hc
|
|
47
102
|
};
|