@drawbridge/components 0.1.46 → 0.1.48
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/bridge/cart-drawer.js +152 -0
- package/dist/bridge/cart-drawer.mjs +123 -0
- package/dist/bridge/fields.js +278 -0
- package/dist/bridge/fields.mjs +276 -1
- package/dist/bridge/form-subdomain-checkout.js +687 -0
- package/dist/bridge/form-subdomain-checkout.mjs +665 -0
- package/dist/bridge/form-subdomain-shop-modal.js +234 -274
- package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
- package/dist/bridge/form-subdomain-shop.js +4 -1
- package/dist/bridge/form-subdomain-shop.mjs +4 -1
- package/dist/bridge/form-subdomain.js +24 -5
- package/dist/bridge/form-subdomain.mjs +25 -6
- package/dist/bridge/lib/age-gate.js +12 -0
- package/dist/bridge/lib/age-gate.mjs +11 -0
- package/dist/bridge/lib/cart.js +79 -0
- package/dist/bridge/lib/cart.mjs +48 -0
- package/dist/bridge/lib/checkout-kit.js +2 -32
- package/dist/bridge/lib/checkout-kit.mjs +2 -32
- package/dist/bridge/lib/entry.js +41 -0
- package/dist/bridge/lib/entry.mjs +40 -0
- package/dist/bridge/product-tile.js +13 -6
- package/dist/bridge/product-tile.mjs +13 -6
- package/dist/bridge/template-layout.js +263 -129
- package/dist/bridge/template-layout.mjs +264 -130
- package/dist/bridge/template-modal.js +39 -74
- package/dist/bridge/template-modal.mjs +40 -75
- package/dist/dashboard/avatar.js +2 -3
- package/dist/dashboard/avatar.mjs +2 -3
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +179 -155
- package/dist/dashboard/campaign-form.mjs +179 -155
- package/dist/dashboard/campaign-share.js +347 -0
- package/dist/dashboard/campaign-share.mjs +314 -0
- package/dist/dashboard/card-affiliate.js +1 -1
- package/dist/dashboard/card-affiliate.mjs +1 -1
- package/dist/dashboard/card-campaign-switch.js +4 -1
- package/dist/dashboard/card-campaign-switch.mjs +4 -1
- package/dist/dashboard/card-order.js +22 -4
- package/dist/dashboard/card-order.mjs +22 -4
- package/dist/dashboard/embed-stripe.js +145 -0
- package/dist/dashboard/embed-stripe.mjs +116 -0
- package/dist/dashboard/form-admin-provider.js +71 -17
- package/dist/dashboard/form-admin-provider.mjs +71 -17
- package/dist/dashboard/form-file-upload.js +3 -2
- package/dist/dashboard/form-file-upload.mjs +4 -3
- package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
- package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
- package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
- package/dist/dashboard/form-organization-campaign-page.js +73 -39
- package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
- package/dist/dashboard/form-organization-campaign.js +82 -0
- package/dist/dashboard/form-organization-campaign.mjs +81 -0
- package/dist/dashboard/form-organization-connection.js +48 -6
- package/dist/dashboard/form-organization-connection.mjs +48 -7
- package/dist/dashboard/form-organization-product.js +1461 -0
- package/dist/dashboard/form-organization-product.mjs +1425 -0
- package/dist/dashboard/form-organization-workflow.js +72 -1
- package/dist/dashboard/form-organization-workflow.mjs +69 -1
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-stripe.js +12 -5
- package/dist/dashboard/form-stripe.mjs +12 -5
- package/dist/dashboard/input-combobox.js +6 -0
- package/dist/dashboard/input-combobox.mjs +6 -0
- package/dist/dashboard/input-fields.js +37 -161
- package/dist/dashboard/input-fields.mjs +37 -161
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-font.js +2 -0
- package/dist/dashboard/input-font.mjs +2 -0
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- package/dist/dashboard/input-group-ai.js +15 -3
- package/dist/dashboard/input-group-ai.mjs +15 -3
- package/dist/dashboard/lib/ab-tests.js +2 -2
- package/dist/dashboard/lib/ab-tests.mjs +2 -2
- package/dist/dashboard/lib/connection-controls.js +5 -2
- package/dist/dashboard/lib/connection-controls.mjs +3 -1
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/menu.js +19 -0
- package/dist/dashboard/lib/menu.mjs +18 -0
- package/dist/dashboard/lib/products.js +169 -0
- package/dist/dashboard/lib/products.mjs +135 -0
- package/dist/dashboard/lib/settings-paths.js +35 -0
- package/dist/dashboard/lib/settings-paths.mjs +11 -0
- package/dist/dashboard/lib/uppy.js +10 -1
- package/dist/dashboard/lib/uppy.mjs +11 -2
- package/dist/dashboard/menu.js +13 -2
- package/dist/dashboard/menu.mjs +13 -2
- package/dist/dashboard/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/preview.js +119 -52
- package/dist/dashboard/preview.mjs +119 -52
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- package/dist/dashboard/recharts.js +10 -4
- package/dist/dashboard/recharts.mjs +10 -4
- package/dist/dashboard/shipping-rates.js +404 -0
- package/dist/dashboard/shipping-rates.mjs +371 -0
- package/dist/dashboard/template-buyer.js +301 -0
- package/dist/dashboard/template-buyer.mjs +267 -0
- package/dist/dashboard/template-dashboard.js +11 -1
- package/dist/dashboard/template-dashboard.mjs +11 -1
- package/dist/dashboard/template-design.js +209 -130
- package/dist/dashboard/template-design.mjs +210 -131
- package/dist/dashboard/template-ui.js +157 -55
- package/dist/dashboard/template-ui.mjs +158 -56
- package/dist/icons/flags.js +134 -0
- package/dist/icons/flags.mjs +115 -0
- package/dist/input-checkbox.js +28 -10
- package/dist/input-checkbox.mjs +28 -10
- package/dist/product.js +96 -24
- package/dist/product.mjs +97 -25
- package/dist/shared/carousel.js +14 -5
- package/dist/shared/carousel.mjs +14 -5
- package/dist/shared/lib/helpers.js +54 -6
- package/dist/shared/lib/helpers.mjs +53 -8
- package/dist/shared/order-summary.js +139 -0
- package/dist/shared/order-summary.mjs +110 -0
- package/package.json +84 -4
- package/types/bridge/cart-drawer.d.ts +31 -0
- package/types/bridge/fields.d.ts +14 -2
- package/types/bridge/form-subdomain-checkout.d.ts +20 -0
- package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
- package/types/bridge/form-subdomain.d.ts +13 -0
- package/types/bridge/lib/age-gate.d.ts +5 -0
- package/types/bridge/lib/cart.d.ts +44 -0
- package/types/bridge/lib/checkout-kit.d.ts +2 -10
- package/types/bridge/lib/entry.d.ts +5 -0
- package/types/bridge/product-tile.d.ts +2 -0
- package/types/dashboard/campaign-share.d.ts +16 -0
- package/types/dashboard/card-order.d.ts +6 -0
- package/types/dashboard/embed-stripe.d.ts +25 -0
- package/types/dashboard/form-admin-provider.d.ts +9 -2
- package/types/dashboard/form-file-upload.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
- package/types/dashboard/form-organization-campaign-page.d.ts +8 -1
- package/types/dashboard/form-organization-campaign.d.ts +3 -0
- package/types/dashboard/form-organization-connection.d.ts +11 -0
- package/types/dashboard/form-organization-product.d.ts +24 -0
- package/types/dashboard/form-otc.d.ts +5 -1
- package/types/dashboard/form-stripe.d.ts +3 -2
- package/types/dashboard/input-combobox.d.ts +2 -0
- package/types/dashboard/input-file.d.ts +2 -0
- package/types/dashboard/input-gallery.d.ts +14 -0
- package/types/dashboard/lib/products.d.ts +14 -0
- package/types/dashboard/lib/settings-paths.d.ts +5 -0
- package/types/dashboard/order-sections.d.ts +24 -1
- package/types/dashboard/preview.d.ts +11 -3
- package/types/dashboard/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -0
- package/types/icons/flags.d.ts +5 -0
- package/types/input-checkbox.d.ts +2 -0
- package/types/shared/lib/helpers.d.ts +4 -0
- package/types/shared/order-summary.d.ts +19 -0
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var form_subdomain_checkout_exports = {};
|
|
30
|
+
__export(form_subdomain_checkout_exports, {
|
|
31
|
+
default: () => form_subdomain_checkout_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(form_subdomain_checkout_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_stripe_js = require("@stripe/stripe-js");
|
|
37
|
+
var import_checkout = require("@stripe/react-stripe-js/checkout");
|
|
38
|
+
var import_helpers = require("../shared/lib/helpers");
|
|
39
|
+
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
40
|
+
var import_form_subdomain_header = require("./form-subdomain-header");
|
|
41
|
+
var import_cart = require("./lib/cart");
|
|
42
|
+
var import_input_group = __toESM(require("../input-group"));
|
|
43
|
+
var import_input_select = __toESM(require("../input-select"));
|
|
44
|
+
var import_input_text = __toESM(require("../input-text"));
|
|
45
|
+
var import_input_radio = __toESM(require("../dashboard/input-radio"));
|
|
46
|
+
var import_button = __toESM(require("../shared/button"));
|
|
47
|
+
var import_error = __toESM(require("../shared/error"));
|
|
48
|
+
var import_loader = __toESM(require("../icons/loader"));
|
|
49
|
+
var import_order_summary = __toESM(require("../shared/order-summary"));
|
|
50
|
+
var import_chevron_down = __toESM(require("../icons/chevron-down"));
|
|
51
|
+
var import_chevron_up = __toESM(require("../icons/chevron-up"));
|
|
52
|
+
const stripes = /* @__PURE__ */ new Map();
|
|
53
|
+
const stripeFor = ({ account, publishable }) => {
|
|
54
|
+
const key = publishable + ":" + account;
|
|
55
|
+
if (!stripes.has(key)) stripes.set(key, (0, import_stripe_js.loadStripe)(publishable, { stripeAccount: account }));
|
|
56
|
+
return stripes.get(key);
|
|
57
|
+
};
|
|
58
|
+
const countryName = (code) => {
|
|
59
|
+
try {
|
|
60
|
+
return new Intl.DisplayNames(["en"], { type: "region" }).of(code) || code;
|
|
61
|
+
} catch {
|
|
62
|
+
return code;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const visitorCountry = () => {
|
|
66
|
+
try {
|
|
67
|
+
return new Intl.Locale(window.navigator.language).region || null;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
73
|
+
const delivery = (estimate) => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return ((_a = estimate == null ? void 0 : estimate.minimum) == null ? void 0 : _a.value) && ((_b = estimate == null ? void 0 : estimate.maximum) == null ? void 0 : _b.value) ? estimate.minimum.value + "\u2013" + estimate.maximum.value + " business days" : null;
|
|
76
|
+
};
|
|
77
|
+
const Step = ({ children, done, onEdit, open, style, summary, title }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
...{
|
|
81
|
+
className: "py-6 space-y-4 border-t border-current" + (!open && !done ? " opacity-40" : "")
|
|
82
|
+
},
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
+
import_form_subdomain_header.FormSubdomainHeader,
|
|
86
|
+
{
|
|
87
|
+
...{
|
|
88
|
+
button: !open && done && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
import_button.default,
|
|
90
|
+
{
|
|
91
|
+
...{
|
|
92
|
+
inline: true,
|
|
93
|
+
onClick: onEdit,
|
|
94
|
+
size: "small",
|
|
95
|
+
variant: "link"
|
|
96
|
+
},
|
|
97
|
+
children: "Edit"
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
style,
|
|
101
|
+
title
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
...{
|
|
109
|
+
className: open ? "space-y-4" : "hidden"
|
|
110
|
+
},
|
|
111
|
+
children
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
!open && done && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
...{
|
|
118
|
+
className: "text-sm opacity-60 space-y-0.5"
|
|
119
|
+
},
|
|
120
|
+
children: summary
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
const Steps = ({ back, button, cart, countries, country, cut, email, onContinue, onCountry, onEmail, onPaid, preview, shipping, style }) => {
|
|
127
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
128
|
+
const state = (0, import_checkout.useCheckoutElements)();
|
|
129
|
+
const steps = (0, import_react.useMemo)(() => shipping ? ["details", "shipping", "payment"] : ["details", "payment"], [shipping]);
|
|
130
|
+
const [step, setStep] = (0, import_react.useState)(steps[0]);
|
|
131
|
+
const [address, setAddress] = (0, import_react.useState)(null);
|
|
132
|
+
const [opened, setOpened] = (0, import_react.useState)(false);
|
|
133
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
134
|
+
const [paying, setPaying] = (0, import_react.useState)(false);
|
|
135
|
+
const go = (0, import_react.useCallback)((next2) => {
|
|
136
|
+
window.history.pushState({ checkout: next2 }, "");
|
|
137
|
+
setStep(next2);
|
|
138
|
+
}, []);
|
|
139
|
+
(0, import_react.useEffect)(() => {
|
|
140
|
+
const onPop = () => setStep((current) => steps[Math.max(steps.indexOf(current) - 1, 0)]);
|
|
141
|
+
window.addEventListener("popstate", onPop);
|
|
142
|
+
return () => window.removeEventListener("popstate", onPop);
|
|
143
|
+
}, [steps]);
|
|
144
|
+
const checkout = state.type === "success" ? state.checkout : null;
|
|
145
|
+
const options = (checkout == null ? void 0 : checkout.shippingOptions) || [];
|
|
146
|
+
const chosen = ((_b = (_a = checkout == null ? void 0 : checkout.shipping) == null ? void 0 : _a.shippingOption) == null ? void 0 : _b.id) || null;
|
|
147
|
+
(0, import_react.useEffect)(() => {
|
|
148
|
+
if (checkout && options.length && !chosen) checkout.updateShippingOption(options[0].id);
|
|
149
|
+
}, [checkout, chosen, options]);
|
|
150
|
+
const [billing, setBilling] = (0, import_react.useState)(false);
|
|
151
|
+
const taxStatus = (_c = checkout == null ? void 0 : checkout.tax) == null ? void 0 : _c.status;
|
|
152
|
+
(0, import_react.useEffect)(() => {
|
|
153
|
+
if (taxStatus === "requires_billing_address") setBilling(true);
|
|
154
|
+
}, [taxStatus]);
|
|
155
|
+
if (state.type === "error") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_error.default, { ...{ error: (_d = state.error) == null ? void 0 : _d.message, style } });
|
|
156
|
+
if (!checkout) {
|
|
157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
158
|
+
import_loader.default,
|
|
159
|
+
{
|
|
160
|
+
...{
|
|
161
|
+
className: "w-5 h-5 animate-spin"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
;
|
|
167
|
+
const code = (_f = (_e = cart == null ? void 0 : cart.lines) == null ? void 0 : _e[0]) == null ? void 0 : _f.currency;
|
|
168
|
+
const money = (value) => (0, import_helpers.money)({ code, value });
|
|
169
|
+
const reached = (name) => steps.indexOf(step) > steps.indexOf(name);
|
|
170
|
+
const next = () => go(steps[steps.indexOf(step) + 1]);
|
|
171
|
+
const detailsDone = EMAIL.test(email || "") && (!shipping || Boolean(address == null ? void 0 : address.complete));
|
|
172
|
+
const taxed = ((_g = checkout.tax) == null ? void 0 : _g.status) === "ready" && ((_i = (_h = checkout.total) == null ? void 0 : _h.taxExclusive) == null ? void 0 : _i.minorUnitsAmount) > 0;
|
|
173
|
+
const rate = (_j = checkout.shipping) == null ? void 0 : _j.shippingOption;
|
|
174
|
+
const Chevron = opened ? import_chevron_up.default : import_chevron_down.default;
|
|
175
|
+
const contact = async () => {
|
|
176
|
+
var _a2;
|
|
177
|
+
setError(null);
|
|
178
|
+
const result = await checkout.updateEmail(email);
|
|
179
|
+
if ((result == null ? void 0 : result.type) === "error") {
|
|
180
|
+
setError((_a2 = result.error) == null ? void 0 : _a2.message);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
;
|
|
184
|
+
onContinue(email);
|
|
185
|
+
next();
|
|
186
|
+
};
|
|
187
|
+
const done = (result) => {
|
|
188
|
+
var _a2;
|
|
189
|
+
if ((result == null ? void 0 : result.type) === "error") {
|
|
190
|
+
setError((_a2 = result.error) == null ? void 0 : _a2.message);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
;
|
|
194
|
+
onPaid();
|
|
195
|
+
};
|
|
196
|
+
const pay = async () => {
|
|
197
|
+
setPaying(true);
|
|
198
|
+
setError(null);
|
|
199
|
+
try {
|
|
200
|
+
done(await checkout.confirm({ redirect: "if_required" }));
|
|
201
|
+
} finally {
|
|
202
|
+
setPaying(false);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const unitOf = (item) => {
|
|
206
|
+
var _a2, _b2, _c2;
|
|
207
|
+
const name = item.variantTitle ? item.productTitle + " - " + item.variantTitle : item.productTitle;
|
|
208
|
+
return ((_c2 = (_b2 = (_a2 = checkout.lineItems) == null ? void 0 : _a2.find((stripeLine) => stripeLine.name === name)) == null ? void 0 : _b2.unitAmount) == null ? void 0 : _c2.amount) || money(item.price);
|
|
209
|
+
};
|
|
210
|
+
const line = ((_k = cart == null ? void 0 : cart.lines) == null ? void 0 : _k.length) ? cart.lines.map((item) => ({
|
|
211
|
+
id: item.id,
|
|
212
|
+
image: item.image,
|
|
213
|
+
name: item.productTitle,
|
|
214
|
+
note: (0, import_cart.lineNote)(item, cut),
|
|
215
|
+
summary: [item.variantTitle, item.quantity + " \xD7 " + unitOf(item)].filter(Boolean).join(" \xB7 ")
|
|
216
|
+
})) : [];
|
|
217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
219
|
+
import_form_subdomain_header.FormSubdomainHeader,
|
|
220
|
+
{
|
|
221
|
+
...{
|
|
222
|
+
back: {
|
|
223
|
+
onClick: () => step === steps[0] ? back() : window.history.back()
|
|
224
|
+
},
|
|
225
|
+
button,
|
|
226
|
+
style,
|
|
227
|
+
title: "Checkout"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
),
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
...{
|
|
235
|
+
className: "pt-6"
|
|
236
|
+
},
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
239
|
+
"div",
|
|
240
|
+
{
|
|
241
|
+
...{
|
|
242
|
+
className: "pb-6"
|
|
243
|
+
},
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
246
|
+
import_button.default,
|
|
247
|
+
{
|
|
248
|
+
...{
|
|
249
|
+
"aria-expanded": opened,
|
|
250
|
+
onClick: () => setOpened(!opened),
|
|
251
|
+
variant: "link"
|
|
252
|
+
},
|
|
253
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
254
|
+
"span",
|
|
255
|
+
{
|
|
256
|
+
...{
|
|
257
|
+
className: "flex items-center justify-between gap-3 w-full"
|
|
258
|
+
},
|
|
259
|
+
children: [
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Summary" }),
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
262
|
+
"span",
|
|
263
|
+
{
|
|
264
|
+
...{
|
|
265
|
+
className: "flex items-center gap-2"
|
|
266
|
+
},
|
|
267
|
+
children: [
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: (_m = (_l = checkout.total) == null ? void 0 : _l.total) == null ? void 0 : _m.amount }),
|
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
270
|
+
Chevron,
|
|
271
|
+
{
|
|
272
|
+
...{
|
|
273
|
+
className: "w-5 h-5"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
(opened || (cut == null ? void 0 : cut.length) > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
286
|
+
"div",
|
|
287
|
+
{
|
|
288
|
+
...{
|
|
289
|
+
className: "pt-4"
|
|
290
|
+
},
|
|
291
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
292
|
+
import_order_summary.default,
|
|
293
|
+
{
|
|
294
|
+
...{
|
|
295
|
+
lines: line,
|
|
296
|
+
rows: [
|
|
297
|
+
["Subtotal", (_o = (_n = checkout.total) == null ? void 0 : _n.subtotal) == null ? void 0 : _o.amount],
|
|
298
|
+
...shipping ? [["Shipping", rate ? rate.minorUnitsAmount ? rate.amount : "Free" : null]] : [],
|
|
299
|
+
["Tax", taxed ? checkout.total.taxExclusive.amount : null],
|
|
300
|
+
["Total", (_q = (_p = checkout.total) == null ? void 0 : _p.total) == null ? void 0 : _q.amount]
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
)
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
),
|
|
310
|
+
!preview && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
311
|
+
"div",
|
|
312
|
+
{
|
|
313
|
+
...{
|
|
314
|
+
className: "pb-6"
|
|
315
|
+
},
|
|
316
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
317
|
+
import_checkout.ExpressCheckoutElement,
|
|
318
|
+
{
|
|
319
|
+
...{
|
|
320
|
+
onConfirm: async (event) => done(await checkout.confirm({ expressCheckoutConfirmEvent: event }))
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
),
|
|
326
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
327
|
+
Step,
|
|
328
|
+
{
|
|
329
|
+
...{
|
|
330
|
+
done: reached("details"),
|
|
331
|
+
onEdit: () => setStep("details"),
|
|
332
|
+
open: step === "details",
|
|
333
|
+
style,
|
|
334
|
+
summary: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
335
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: email }),
|
|
336
|
+
shipping && (address == null ? void 0 : address.value) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
337
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: address.value.name }),
|
|
338
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (_r = address.value.address) == null ? void 0 : _r.line1 }),
|
|
339
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: [(_s = address.value.address) == null ? void 0 : _s.city, (_t = address.value.address) == null ? void 0 : _t.state, (_u = address.value.address) == null ? void 0 : _u.postal_code].filter(Boolean).join(", ") }),
|
|
340
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: countryName(country) })
|
|
341
|
+
] })
|
|
342
|
+
] }),
|
|
343
|
+
title: shipping ? "Contact and address" : "Contact"
|
|
344
|
+
},
|
|
345
|
+
children: [
|
|
346
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
347
|
+
import_input_group.default,
|
|
348
|
+
{
|
|
349
|
+
...{
|
|
350
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
351
|
+
import_input_text.default,
|
|
352
|
+
{
|
|
353
|
+
...{
|
|
354
|
+
autoComplete: "email",
|
|
355
|
+
onChange: onEmail,
|
|
356
|
+
style,
|
|
357
|
+
type: "email",
|
|
358
|
+
value: email || ""
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
),
|
|
362
|
+
label: "Email",
|
|
363
|
+
style
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
shipping && countries.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
368
|
+
import_input_group.default,
|
|
369
|
+
{
|
|
370
|
+
...{
|
|
371
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
372
|
+
import_input_select.default,
|
|
373
|
+
{
|
|
374
|
+
...{
|
|
375
|
+
onChange: onCountry,
|
|
376
|
+
options: countries.map((value) => ({ label: countryName(value), value })),
|
|
377
|
+
style,
|
|
378
|
+
value: country
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
label: "Country",
|
|
383
|
+
style
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
),
|
|
387
|
+
shipping && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
388
|
+
import_checkout.ShippingAddressElement,
|
|
389
|
+
{
|
|
390
|
+
...{
|
|
391
|
+
onChange: setAddress
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
),
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
396
|
+
import_button.default,
|
|
397
|
+
{
|
|
398
|
+
...{
|
|
399
|
+
disabled: !detailsDone,
|
|
400
|
+
onClick: contact,
|
|
401
|
+
style
|
|
402
|
+
},
|
|
403
|
+
children: "Continue"
|
|
404
|
+
}
|
|
405
|
+
)
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
shipping && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
410
|
+
Step,
|
|
411
|
+
{
|
|
412
|
+
...{
|
|
413
|
+
done: reached("shipping"),
|
|
414
|
+
onEdit: () => setStep("shipping"),
|
|
415
|
+
open: step === "shipping",
|
|
416
|
+
style,
|
|
417
|
+
summary: rate && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: rate.displayName + " \xB7 " + (rate.minorUnitsAmount ? rate.amount : "Free") }),
|
|
418
|
+
title: "Shipping"
|
|
419
|
+
},
|
|
420
|
+
children: [
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
422
|
+
"div",
|
|
423
|
+
{
|
|
424
|
+
...{
|
|
425
|
+
className: "space-y-3"
|
|
426
|
+
},
|
|
427
|
+
children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
428
|
+
import_input_radio.default,
|
|
429
|
+
{
|
|
430
|
+
...{
|
|
431
|
+
checked: option.id === chosen,
|
|
432
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
433
|
+
"span",
|
|
434
|
+
{
|
|
435
|
+
...{
|
|
436
|
+
className: "flex items-center justify-between gap-3 w-full"
|
|
437
|
+
},
|
|
438
|
+
children: [
|
|
439
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
440
|
+
"span",
|
|
441
|
+
{
|
|
442
|
+
...{
|
|
443
|
+
className: "flex flex-col min-w-0"
|
|
444
|
+
},
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
447
|
+
"span",
|
|
448
|
+
{
|
|
449
|
+
...{
|
|
450
|
+
className: "truncate"
|
|
451
|
+
},
|
|
452
|
+
children: option.displayName
|
|
453
|
+
}
|
|
454
|
+
),
|
|
455
|
+
delivery(option.deliveryEstimate) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
456
|
+
"span",
|
|
457
|
+
{
|
|
458
|
+
...{
|
|
459
|
+
className: "text-xs opacity-60 truncate"
|
|
460
|
+
},
|
|
461
|
+
children: delivery(option.deliveryEstimate)
|
|
462
|
+
}
|
|
463
|
+
)
|
|
464
|
+
]
|
|
465
|
+
}
|
|
466
|
+
),
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
468
|
+
"span",
|
|
469
|
+
{
|
|
470
|
+
...{
|
|
471
|
+
className: "shrink-0"
|
|
472
|
+
},
|
|
473
|
+
children: option.minorUnitsAmount ? option.amount : "Free"
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
]
|
|
477
|
+
}
|
|
478
|
+
),
|
|
479
|
+
onChange: () => checkout.updateShippingOption(option.id),
|
|
480
|
+
value: option.id
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
option.id
|
|
484
|
+
))
|
|
485
|
+
}
|
|
486
|
+
),
|
|
487
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
488
|
+
import_button.default,
|
|
489
|
+
{
|
|
490
|
+
...{
|
|
491
|
+
disabled: !chosen,
|
|
492
|
+
onClick: next,
|
|
493
|
+
style
|
|
494
|
+
},
|
|
495
|
+
children: "Continue"
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
),
|
|
501
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
502
|
+
Step,
|
|
503
|
+
{
|
|
504
|
+
...{
|
|
505
|
+
open: step === "payment",
|
|
506
|
+
style,
|
|
507
|
+
title: "Payment"
|
|
508
|
+
},
|
|
509
|
+
children: [
|
|
510
|
+
(billing || taxStatus === "requires_billing_address") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_checkout.BillingAddressElement, {}),
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_checkout.PaymentElement, {}),
|
|
512
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
513
|
+
import_error.default,
|
|
514
|
+
{
|
|
515
|
+
...{
|
|
516
|
+
error,
|
|
517
|
+
style
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
),
|
|
521
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
522
|
+
import_button.default,
|
|
523
|
+
{
|
|
524
|
+
...{
|
|
525
|
+
// @story checkout/pay-on-page
|
|
526
|
+
// On a preview link every step works and Pay stays off.
|
|
527
|
+
disabled: preview || !checkout.canConfirm,
|
|
528
|
+
loading: paying,
|
|
529
|
+
onClick: pay,
|
|
530
|
+
style
|
|
531
|
+
},
|
|
532
|
+
children: "Pay " + (((_w = (_v = checkout.total) == null ? void 0 : _v.total) == null ? void 0 : _w.amount) || "")
|
|
533
|
+
}
|
|
534
|
+
)
|
|
535
|
+
]
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
]
|
|
539
|
+
}
|
|
540
|
+
)
|
|
541
|
+
] });
|
|
542
|
+
};
|
|
543
|
+
const FormSubdomainCheckout = ({ back, button, cart: start, onCart, onPaid, params, preview, style }) => {
|
|
544
|
+
var _a;
|
|
545
|
+
const [country, setCountry] = (0, import_react.useState)(null);
|
|
546
|
+
const [email, setEmail] = (0, import_react.useState)("");
|
|
547
|
+
const [session, setSession] = (0, import_react.useState)(null);
|
|
548
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
549
|
+
const cartChanged = (0, import_react.useRef)(onCart);
|
|
550
|
+
(0, import_react.useEffect)(() => {
|
|
551
|
+
cartChanged.current = onCart;
|
|
552
|
+
}, [onCart]);
|
|
553
|
+
(0, import_react.useEffect)(() => {
|
|
554
|
+
let current = true;
|
|
555
|
+
setError(null);
|
|
556
|
+
(0, import_fetch.request)({
|
|
557
|
+
body: {
|
|
558
|
+
cartId: start == null ? void 0 : start.id,
|
|
559
|
+
country: country || visitorCountry()
|
|
560
|
+
},
|
|
561
|
+
endpoint: "/subdomain/" + (params == null ? void 0 : params.subdomain) + "/page/" + (params == null ? void 0 : params.slug) + "/cart/checkout" + (preview && (params == null ? void 0 : params.token) ? "?drwbrdg_pre=" + encodeURIComponent(params.token) : ""),
|
|
562
|
+
method: "POST"
|
|
563
|
+
}).then(({ result }) => {
|
|
564
|
+
var _a2;
|
|
565
|
+
if (!current) return;
|
|
566
|
+
setSession(result);
|
|
567
|
+
(_a2 = cartChanged.current) == null ? void 0 : _a2.call(cartChanged, result.cart);
|
|
568
|
+
}).catch((thrown) => {
|
|
569
|
+
if (current) setError((thrown == null ? void 0 : thrown.message) || "Checkout is not available right now");
|
|
570
|
+
});
|
|
571
|
+
return () => {
|
|
572
|
+
current = false;
|
|
573
|
+
};
|
|
574
|
+
}, [country, params == null ? void 0 : params.slug, params == null ? void 0 : params.subdomain, params == null ? void 0 : params.token, preview, start == null ? void 0 : start.id]);
|
|
575
|
+
const onContinue = (value) => {
|
|
576
|
+
const keep = (0, import_cart.continueRequest)({ cartId: start == null ? void 0 : start.id, email: value, params, preview });
|
|
577
|
+
if (keep) (0, import_fetch.request)(keep).catch(() => {
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
const stripe = (0, import_react.useMemo)(() => (session == null ? void 0 : session.publishable) && (session == null ? void 0 : session.account) ? stripeFor(session) : null, [session]);
|
|
581
|
+
const appearance = (0, import_react.useMemo)(() => {
|
|
582
|
+
var _a2, _b, _c, _d;
|
|
583
|
+
return {
|
|
584
|
+
variables: {
|
|
585
|
+
...((_b = (_a2 = style == null ? void 0 : style.text) == null ? void 0 : _a2.color) == null ? void 0 : _b.rgb) && {
|
|
586
|
+
colorText: style.text.color.rgb
|
|
587
|
+
},
|
|
588
|
+
...((_d = (_c = style == null ? void 0 : style.background) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb) && {
|
|
589
|
+
colorBackground: style.background.color.rgb
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
}, [style]);
|
|
594
|
+
if (error) {
|
|
595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
596
|
+
"div",
|
|
597
|
+
{
|
|
598
|
+
...{
|
|
599
|
+
className: "space-y-6"
|
|
600
|
+
},
|
|
601
|
+
children: [
|
|
602
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
603
|
+
import_form_subdomain_header.FormSubdomainHeader,
|
|
604
|
+
{
|
|
605
|
+
...{
|
|
606
|
+
back: {
|
|
607
|
+
onClick: back
|
|
608
|
+
},
|
|
609
|
+
button,
|
|
610
|
+
style,
|
|
611
|
+
title: "Checkout"
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
),
|
|
615
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
616
|
+
import_error.default,
|
|
617
|
+
{
|
|
618
|
+
...{
|
|
619
|
+
error,
|
|
620
|
+
style
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
)
|
|
624
|
+
]
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
;
|
|
629
|
+
if (!session || !stripe) {
|
|
630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
631
|
+
import_form_subdomain_header.FormSubdomainHeader,
|
|
632
|
+
{
|
|
633
|
+
...{
|
|
634
|
+
back: {
|
|
635
|
+
onClick: back
|
|
636
|
+
},
|
|
637
|
+
button,
|
|
638
|
+
style,
|
|
639
|
+
title: "Checkout"
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
;
|
|
645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
646
|
+
import_checkout.CheckoutElementsProvider,
|
|
647
|
+
{
|
|
648
|
+
...{
|
|
649
|
+
options: {
|
|
650
|
+
clientSecret: session.clientSecret,
|
|
651
|
+
...email && {
|
|
652
|
+
defaultValues: {
|
|
653
|
+
email
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
elementsOptions: {
|
|
657
|
+
appearance
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
stripe
|
|
661
|
+
},
|
|
662
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
663
|
+
Steps,
|
|
664
|
+
{
|
|
665
|
+
...{
|
|
666
|
+
back,
|
|
667
|
+
button,
|
|
668
|
+
cart: session.cart,
|
|
669
|
+
countries: session.countries || [],
|
|
670
|
+
country: session.country,
|
|
671
|
+
cut: ((_a = session.cart) == null ? void 0 : _a.cut) || [],
|
|
672
|
+
email,
|
|
673
|
+
onContinue,
|
|
674
|
+
onCountry: setCountry,
|
|
675
|
+
onEmail: setEmail,
|
|
676
|
+
onPaid,
|
|
677
|
+
preview,
|
|
678
|
+
shipping: Boolean(session.shipping),
|
|
679
|
+
style
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
},
|
|
684
|
+
session.clientSecret
|
|
685
|
+
);
|
|
686
|
+
};
|
|
687
|
+
var form_subdomain_checkout_default = FormSubdomainCheckout;
|