@drawbridge/components 0.1.47 → 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.js +1 -0
- package/dist/bridge/form-subdomain.mjs +2 -1
- 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/product-tile.js +9 -6
- package/dist/bridge/product-tile.mjs +9 -6
- package/dist/bridge/template-layout.js +237 -122
- package/dist/bridge/template-layout.mjs +237 -122
- package/dist/bridge/template-modal.js +28 -73
- package/dist/bridge/template-modal.mjs +29 -74
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +7 -2
- package/dist/dashboard/campaign-form.mjs +7 -2
- 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.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-fields.js +11 -158
- package/dist/dashboard/input-fields.mjs +11 -158
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- 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/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/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- 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/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/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 +74 -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/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/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.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-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/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -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
|
@@ -8,7 +8,7 @@ import FormSubdomainHeader from "./form-subdomain-header.mjs";
|
|
|
8
8
|
import FormSubdomainIssue from "./form-subdomain-issue.mjs";
|
|
9
9
|
import FormSubdomainPrize from "./form-subdomain-prize.mjs";
|
|
10
10
|
import ProviderRecaptcha from "../shared/provider-recaptcha.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { FormSubdomainProduct } from "./form-subdomain-shop-modal.mjs";
|
|
12
12
|
import TemplateSubdomainLink from "./template-subdomain-link.mjs";
|
|
13
13
|
import FormSubdomainMissions from "./form-subdomain-missions.mjs";
|
|
14
14
|
import Tabs from "../shared/tabs.mjs";
|
|
@@ -21,15 +21,12 @@ import { afterOrder, agreementName, agreementTitles, copy, formOn, giveawayOn, m
|
|
|
21
21
|
import { motion } from "../shared/lib/motion.mjs";
|
|
22
22
|
const TemplateModal = ({
|
|
23
23
|
buttons,
|
|
24
|
-
cart,
|
|
25
24
|
checkout,
|
|
26
25
|
data,
|
|
27
26
|
fonts,
|
|
28
27
|
iframe,
|
|
29
28
|
modal,
|
|
30
29
|
onAddToCart,
|
|
31
|
-
onCartLineRemove,
|
|
32
|
-
onCartLineUpdate,
|
|
33
30
|
openCheckout,
|
|
34
31
|
panel,
|
|
35
32
|
params,
|
|
@@ -47,27 +44,6 @@ const TemplateModal = ({
|
|
|
47
44
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
48
45
|
const agreements = (data == null ? void 0 : data.agreements) || {};
|
|
49
46
|
switch (panel == null ? void 0 : panel.name) {
|
|
50
|
-
case "cart":
|
|
51
|
-
return /* @__PURE__ */ jsx(
|
|
52
|
-
FormSubdomainCart,
|
|
53
|
-
{
|
|
54
|
-
...{
|
|
55
|
-
button: buttons.close("cart"),
|
|
56
|
-
cart,
|
|
57
|
-
onLineRemove: onCartLineRemove,
|
|
58
|
-
onLineUpdate: onCartLineUpdate,
|
|
59
|
-
onSuccess: ({ result }) => {
|
|
60
|
-
tracking.track({
|
|
61
|
-
name: "shop-checkout",
|
|
62
|
-
data: result
|
|
63
|
-
});
|
|
64
|
-
openCheckout(result.checkoutUrl);
|
|
65
|
-
},
|
|
66
|
-
style,
|
|
67
|
-
tracking
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
47
|
case "enter":
|
|
72
48
|
if (!formOn(data)) return null;
|
|
73
49
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -449,60 +425,39 @@ const TemplateModal = ({
|
|
|
449
425
|
}
|
|
450
426
|
)
|
|
451
427
|
] });
|
|
428
|
+
// @story checkout/cart
|
|
429
|
+
// A product in its own window, which shows no cart of its own: Add to
|
|
430
|
+
// cart closes it onto the cart drawer ( template-layout.js ).
|
|
452
431
|
case "product":
|
|
453
432
|
return /* @__PURE__ */ jsx(
|
|
454
|
-
|
|
433
|
+
FormSubdomainProduct,
|
|
455
434
|
{
|
|
456
435
|
...{
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
436
|
+
back: (_u = panel.data) == null ? void 0 : _u.back,
|
|
437
|
+
button: buttons.close("product"),
|
|
438
|
+
onAddToCart: async (item) => {
|
|
439
|
+
var _a3, _b3, _c3, _d3, _e3, _f3;
|
|
440
|
+
await onAddToCart(item);
|
|
441
|
+
const productSlug = (_b3 = (_a3 = item.product) == null ? void 0 : _a3.title) == null ? void 0 : _b3.toLowerCase().replace(/\s+/g, "-");
|
|
442
|
+
const isDefaultVariant = !((_c3 = item.variant) == null ? void 0 : _c3.title) || ((_d3 = item.variant) == null ? void 0 : _d3.title) === "Default Title";
|
|
443
|
+
if (isDefaultVariant) {
|
|
444
|
+
tracking.track({ name: "product-" + productSlug + "-add-cart" });
|
|
445
|
+
} else {
|
|
446
|
+
const variantSlug = (_f3 = (_e3 = item.variant) == null ? void 0 : _e3.title) == null ? void 0 : _f3.toLowerCase().replace(/\s+/g, "-");
|
|
447
|
+
tracking.track({ name: "product-" + productSlug + "-" + variantSlug + "-add-cart" });
|
|
448
|
+
}
|
|
449
|
+
;
|
|
467
450
|
},
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
var _a3, _b3;
|
|
473
|
-
return /* @__PURE__ */ jsx(
|
|
474
|
-
FormSubdomainProduct,
|
|
475
|
-
{
|
|
476
|
-
...{
|
|
477
|
-
back: (_a3 = panel.data) == null ? void 0 : _a3.back,
|
|
478
|
-
button: buttons.close("product"),
|
|
479
|
-
onAddToCart: async (item) => {
|
|
480
|
-
var _a4, _b4, _c3, _d3, _e3, _f3;
|
|
481
|
-
await onAddToCart(item);
|
|
482
|
-
const productSlug = (_b4 = (_a4 = item.product) == null ? void 0 : _a4.title) == null ? void 0 : _b4.toLowerCase().replace(/\s+/g, "-");
|
|
483
|
-
const isDefaultVariant = !((_c3 = item.variant) == null ? void 0 : _c3.title) || ((_d3 = item.variant) == null ? void 0 : _d3.title) === "Default Title";
|
|
484
|
-
if (isDefaultVariant) {
|
|
485
|
-
tracking.track({ name: "product-" + productSlug + "-add-cart" });
|
|
486
|
-
} else {
|
|
487
|
-
const variantSlug = (_f3 = (_e3 = item.variant) == null ? void 0 : _e3.title) == null ? void 0 : _f3.toLowerCase().replace(/\s+/g, "-");
|
|
488
|
-
tracking.track({ name: "product-" + productSlug + "-" + variantSlug + "-add-cart" });
|
|
489
|
-
}
|
|
490
|
-
;
|
|
491
|
-
setShow(true);
|
|
492
|
-
},
|
|
493
|
-
onError: ({ message }) => setPanel({
|
|
494
|
-
name: "error",
|
|
495
|
-
data: {
|
|
496
|
-
message
|
|
497
|
-
}
|
|
498
|
-
}),
|
|
499
|
-
checkout,
|
|
500
|
-
tracking,
|
|
501
|
-
product: (_b3 = panel.data) == null ? void 0 : _b3.product,
|
|
502
|
-
style
|
|
503
|
-
}
|
|
451
|
+
onError: ({ message }) => setPanel({
|
|
452
|
+
name: "error",
|
|
453
|
+
data: {
|
|
454
|
+
message
|
|
504
455
|
}
|
|
505
|
-
)
|
|
456
|
+
}),
|
|
457
|
+
checkout,
|
|
458
|
+
tracking,
|
|
459
|
+
product: (_v = panel.data) == null ? void 0 : _v.product,
|
|
460
|
+
style
|
|
506
461
|
}
|
|
507
462
|
}
|
|
508
463
|
);
|
|
@@ -569,7 +524,7 @@ const TemplateModal = ({
|
|
|
569
524
|
return null;
|
|
570
525
|
}
|
|
571
526
|
},
|
|
572
|
-
[buttons,
|
|
527
|
+
[buttons, checkout, data, iframe, onAddToCart, openCheckout, panel, params, preview, style, submission, tracking]
|
|
573
528
|
);
|
|
574
529
|
return (
|
|
575
530
|
// reCAPTCHA stays scoped to the modal — this whole module is
|
|
@@ -241,7 +241,7 @@ const useSubscriptionActions = (params) => {
|
|
|
241
241
|
},
|
|
242
242
|
children: [
|
|
243
243
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Your subscription will cancel at the end of your current billing period. You'll keep all paid features until then." }),
|
|
244
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "After it cancels,
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "After it cancels, you're on Free and workflow steps Free doesn't include stop running. Your campaigns, pages, brands and prizes will be drafted. They won't be deleted, but you'll need to reactivate each one if you re-subscribe." }),
|
|
245
245
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Your subdomain and page addresses go back to their short IDs, your ads are drafted and your members lose access." }),
|
|
246
246
|
smsNumber && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
247
247
|
"Your SMS number, ",
|
|
@@ -205,7 +205,7 @@ const useSubscriptionActions = (params) => {
|
|
|
205
205
|
},
|
|
206
206
|
children: [
|
|
207
207
|
/* @__PURE__ */ jsx("p", { children: "Your subscription will cancel at the end of your current billing period. You'll keep all paid features until then." }),
|
|
208
|
-
/* @__PURE__ */ jsx("p", { children: "After it cancels,
|
|
208
|
+
/* @__PURE__ */ jsx("p", { children: "After it cancels, you're on Free and workflow steps Free doesn't include stop running. Your campaigns, pages, brands and prizes will be drafted. They won't be deleted, but you'll need to reactivate each one if you re-subscribe." }),
|
|
209
209
|
/* @__PURE__ */ jsx("p", { children: "Your subdomain and page addresses go back to their short IDs, your ads are drafted and your members lose access." }),
|
|
210
210
|
smsNumber && /* @__PURE__ */ jsxs("p", { children: [
|
|
211
211
|
"Your SMS number, ",
|
|
@@ -614,6 +614,8 @@ const Step = ({
|
|
|
614
614
|
collapsed,
|
|
615
615
|
currency,
|
|
616
616
|
fonts,
|
|
617
|
+
// Every field type on the form, across its sections.
|
|
618
|
+
formKeys,
|
|
617
619
|
handle,
|
|
618
620
|
last,
|
|
619
621
|
params,
|
|
@@ -636,6 +638,7 @@ const Step = ({
|
|
|
636
638
|
const on = (0, import_form_page.sectionOn)(section);
|
|
637
639
|
const shown = on && !collapsed;
|
|
638
640
|
const card = (0, import_preview.useCard)(section.id);
|
|
641
|
+
const keys = formKeys || section.keys;
|
|
639
642
|
const add = () => modal.open({
|
|
640
643
|
message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
641
644
|
Choices,
|
|
@@ -643,8 +646,8 @@ const Step = ({
|
|
|
643
646
|
...{
|
|
644
647
|
choices: (section.inputs || []).map(({ slug, title, ...input }) => ({
|
|
645
648
|
...input,
|
|
646
|
-
disabled: (0, import_form_page.addedOnce)(slug,
|
|
647
|
-
message: (0, import_form_page.addedOnce)(slug,
|
|
649
|
+
disabled: (0, import_form_page.addedOnce)(slug, keys),
|
|
650
|
+
message: (0, import_form_page.addedOnce)(slug, keys) ? "Field has already been added" : input.granted === false ? input.message : null,
|
|
648
651
|
onClick: () => actions.manage({
|
|
649
652
|
...input,
|
|
650
653
|
section,
|
|
@@ -1567,6 +1570,7 @@ const CampaignForm = ({
|
|
|
1567
1570
|
});
|
|
1568
1571
|
onOpened == null ? void 0 : onOpened();
|
|
1569
1572
|
}, [open]);
|
|
1573
|
+
const formKeys = (Array.isArray(sections) ? sections : []).flatMap((section) => (section == null ? void 0 : section.keys) || []);
|
|
1570
1574
|
const choices = customs.map((section) => ({
|
|
1571
1575
|
description: section.description,
|
|
1572
1576
|
label: section.title,
|
|
@@ -1622,6 +1626,7 @@ const CampaignForm = ({
|
|
|
1622
1626
|
collapsed,
|
|
1623
1627
|
currency,
|
|
1624
1628
|
fonts,
|
|
1629
|
+
formKeys,
|
|
1625
1630
|
handle,
|
|
1626
1631
|
last: section.id === lastId,
|
|
1627
1632
|
params,
|
|
@@ -582,6 +582,8 @@ const Step = ({
|
|
|
582
582
|
collapsed,
|
|
583
583
|
currency,
|
|
584
584
|
fonts,
|
|
585
|
+
// Every field type on the form, across its sections.
|
|
586
|
+
formKeys,
|
|
585
587
|
handle,
|
|
586
588
|
last,
|
|
587
589
|
params,
|
|
@@ -604,6 +606,7 @@ const Step = ({
|
|
|
604
606
|
const on = sectionOn(section);
|
|
605
607
|
const shown = on && !collapsed;
|
|
606
608
|
const card = useCard(section.id);
|
|
609
|
+
const keys = formKeys || section.keys;
|
|
607
610
|
const add = () => modal.open({
|
|
608
611
|
message: /* @__PURE__ */ jsx(
|
|
609
612
|
Choices,
|
|
@@ -611,8 +614,8 @@ const Step = ({
|
|
|
611
614
|
...{
|
|
612
615
|
choices: (section.inputs || []).map(({ slug, title, ...input }) => ({
|
|
613
616
|
...input,
|
|
614
|
-
disabled: addedOnce(slug,
|
|
615
|
-
message: addedOnce(slug,
|
|
617
|
+
disabled: addedOnce(slug, keys),
|
|
618
|
+
message: addedOnce(slug, keys) ? "Field has already been added" : input.granted === false ? input.message : null,
|
|
616
619
|
onClick: () => actions.manage({
|
|
617
620
|
...input,
|
|
618
621
|
section,
|
|
@@ -1535,6 +1538,7 @@ const CampaignForm = ({
|
|
|
1535
1538
|
});
|
|
1536
1539
|
onOpened == null ? void 0 : onOpened();
|
|
1537
1540
|
}, [open]);
|
|
1541
|
+
const formKeys = (Array.isArray(sections) ? sections : []).flatMap((section) => (section == null ? void 0 : section.keys) || []);
|
|
1538
1542
|
const choices = customs.map((section) => ({
|
|
1539
1543
|
description: section.description,
|
|
1540
1544
|
label: section.title,
|
|
@@ -1590,6 +1594,7 @@ const CampaignForm = ({
|
|
|
1590
1594
|
collapsed,
|
|
1591
1595
|
currency,
|
|
1592
1596
|
fonts,
|
|
1597
|
+
formKeys,
|
|
1593
1598
|
handle,
|
|
1594
1599
|
last: section.id === lastId,
|
|
1595
1600
|
params,
|
|
@@ -34,11 +34,14 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
34
34
|
var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
|
|
35
35
|
var import_card_data_item = __toESM(require("./card-data-item"));
|
|
36
36
|
var import_card_shortcut = __toESM(require("./card-shortcut"));
|
|
37
|
+
var import_button = __toESM(require("../shared/button"));
|
|
38
|
+
var import_products = require("./lib/products");
|
|
37
39
|
var import_answer_rows = require("./answer-rows");
|
|
38
40
|
const className = "p-3 bg-white rounded shadow-[0_1px_3px_0_rgb(0_0_0/0.1),0_1px_2px_-1px_rgb(0_0_0/0.1)]";
|
|
39
41
|
const attributions = {
|
|
40
42
|
conversion: "A campaign link brought the buyer to checkout, so the conversion fee applies.",
|
|
41
|
-
redemption: "The buyer used one of your discount codes, so no fee applies."
|
|
43
|
+
redemption: "The buyer used one of your discount codes, so no fee applies.",
|
|
44
|
+
sale: "This sale came through your campaign page, so the sales fee applies."
|
|
42
45
|
};
|
|
43
46
|
const date = (value) => value ? (0, import_drawbridge_utils.formatDateString)({
|
|
44
47
|
date: value,
|
|
@@ -64,7 +67,7 @@ const lineSummary = ({ code, price, quantity = 0, variantTitle }) => [
|
|
|
64
67
|
variantTitle,
|
|
65
68
|
typeof price === "number" ? (0, import_drawbridge_utils.formatNumber)(quantity) + " \xD7 " + (0, import_drawbridge_utils.formatCurrency)({ code, value: price }) : "Quantity " + (0, import_drawbridge_utils.formatNumber)(quantity)
|
|
66
69
|
].filter(Boolean).join(" \xB7 ");
|
|
67
|
-
const Lines = ({ code, label, lines, untitled }) => lines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
70
|
+
const Lines = ({ code, label, lines, onResend, untitled }) => lines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
68
71
|
"div",
|
|
69
72
|
{
|
|
70
73
|
...{
|
|
@@ -90,7 +93,20 @@ const Lines = ({ code, label, lines, untitled }) => lines.length > 0 && /* @__PU
|
|
|
90
93
|
import_card_shortcut.default,
|
|
91
94
|
{
|
|
92
95
|
...{
|
|
93
|
-
|
|
96
|
+
...onResend && typeof line.file === "string" && {
|
|
97
|
+
controls: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
|
+
import_button.default,
|
|
99
|
+
{
|
|
100
|
+
...{
|
|
101
|
+
onClick: onResend,
|
|
102
|
+
size: "small",
|
|
103
|
+
variant: "secondary"
|
|
104
|
+
},
|
|
105
|
+
children: "Resend download"
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
},
|
|
109
|
+
description: [lineSummary({ code, ...line }), typeof line.file === "string" ? (0, import_products.downloadsText)(line.downloads || 0) : null].filter(Boolean).join(" \xB7 "),
|
|
94
110
|
image: line.image,
|
|
95
111
|
title: line.title || untitled
|
|
96
112
|
}
|
|
@@ -249,6 +265,7 @@ const CardOrder = ({
|
|
|
249
265
|
gross = 0,
|
|
250
266
|
lines = [],
|
|
251
267
|
net = 0,
|
|
268
|
+
onResend,
|
|
252
269
|
provider,
|
|
253
270
|
purchasedAt,
|
|
254
271
|
rate,
|
|
@@ -279,7 +296,7 @@ const CardOrder = ({
|
|
|
279
296
|
className: "space-y-6"
|
|
280
297
|
},
|
|
281
298
|
children: [
|
|
282
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: attributions[type] || attributions.conversion }),
|
|
299
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: attributions[(provider == null ? void 0 : provider.slug) === "stripe" ? "sale" : type] || attributions.conversion }),
|
|
283
300
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
284
301
|
"div",
|
|
285
302
|
{
|
|
@@ -362,6 +379,7 @@ const CardOrder = ({
|
|
|
362
379
|
label: "Products",
|
|
363
380
|
// A store line always has a price.
|
|
364
381
|
lines: lines.map((line) => ({ ...line, price: line.price || 0 })),
|
|
382
|
+
onResend,
|
|
365
383
|
untitled: "Untitled product"
|
|
366
384
|
}
|
|
367
385
|
}
|
|
@@ -2,11 +2,14 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { formatCurrency, formatDateString, formatNumber } from "@drawbridge/drawbridge-utils";
|
|
3
3
|
import CardDataItem from "./card-data-item.mjs";
|
|
4
4
|
import CardShortcut from "./card-shortcut.mjs";
|
|
5
|
+
import Button from "../shared/button.mjs";
|
|
6
|
+
import { downloadsText } from "./lib/products.mjs";
|
|
5
7
|
import { answerRows } from "./answer-rows.mjs";
|
|
6
8
|
const className = "p-3 bg-white rounded shadow-[0_1px_3px_0_rgb(0_0_0/0.1),0_1px_2px_-1px_rgb(0_0_0/0.1)]";
|
|
7
9
|
const attributions = {
|
|
8
10
|
conversion: "A campaign link brought the buyer to checkout, so the conversion fee applies.",
|
|
9
|
-
redemption: "The buyer used one of your discount codes, so no fee applies."
|
|
11
|
+
redemption: "The buyer used one of your discount codes, so no fee applies.",
|
|
12
|
+
sale: "This sale came through your campaign page, so the sales fee applies."
|
|
10
13
|
};
|
|
11
14
|
const date = (value) => value ? formatDateString({
|
|
12
15
|
date: value,
|
|
@@ -32,7 +35,7 @@ const lineSummary = ({ code, price, quantity = 0, variantTitle }) => [
|
|
|
32
35
|
variantTitle,
|
|
33
36
|
typeof price === "number" ? formatNumber(quantity) + " \xD7 " + formatCurrency({ code, value: price }) : "Quantity " + formatNumber(quantity)
|
|
34
37
|
].filter(Boolean).join(" \xB7 ");
|
|
35
|
-
const Lines = ({ code, label, lines, untitled }) => lines.length > 0 && /* @__PURE__ */ jsxs(
|
|
38
|
+
const Lines = ({ code, label, lines, onResend, untitled }) => lines.length > 0 && /* @__PURE__ */ jsxs(
|
|
36
39
|
"div",
|
|
37
40
|
{
|
|
38
41
|
...{
|
|
@@ -58,7 +61,20 @@ const Lines = ({ code, label, lines, untitled }) => lines.length > 0 && /* @__PU
|
|
|
58
61
|
CardShortcut,
|
|
59
62
|
{
|
|
60
63
|
...{
|
|
61
|
-
|
|
64
|
+
...onResend && typeof line.file === "string" && {
|
|
65
|
+
controls: /* @__PURE__ */ jsx(
|
|
66
|
+
Button,
|
|
67
|
+
{
|
|
68
|
+
...{
|
|
69
|
+
onClick: onResend,
|
|
70
|
+
size: "small",
|
|
71
|
+
variant: "secondary"
|
|
72
|
+
},
|
|
73
|
+
children: "Resend download"
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
},
|
|
77
|
+
description: [lineSummary({ code, ...line }), typeof line.file === "string" ? downloadsText(line.downloads || 0) : null].filter(Boolean).join(" \xB7 "),
|
|
62
78
|
image: line.image,
|
|
63
79
|
title: line.title || untitled
|
|
64
80
|
}
|
|
@@ -217,6 +233,7 @@ const CardOrder = ({
|
|
|
217
233
|
gross = 0,
|
|
218
234
|
lines = [],
|
|
219
235
|
net = 0,
|
|
236
|
+
onResend,
|
|
220
237
|
provider,
|
|
221
238
|
purchasedAt,
|
|
222
239
|
rate,
|
|
@@ -247,7 +264,7 @@ const CardOrder = ({
|
|
|
247
264
|
className: "space-y-6"
|
|
248
265
|
},
|
|
249
266
|
children: [
|
|
250
|
-
/* @__PURE__ */ jsx("p", { children: attributions[type] || attributions.conversion }),
|
|
267
|
+
/* @__PURE__ */ jsx("p", { children: attributions[(provider == null ? void 0 : provider.slug) === "stripe" ? "sale" : type] || attributions.conversion }),
|
|
251
268
|
/* @__PURE__ */ jsxs(
|
|
252
269
|
"div",
|
|
253
270
|
{
|
|
@@ -330,6 +347,7 @@ const CardOrder = ({
|
|
|
330
347
|
label: "Products",
|
|
331
348
|
// A store line always has a price.
|
|
332
349
|
lines: lines.map((line) => ({ ...line, price: line.price || 0 })),
|
|
350
|
+
onResend,
|
|
333
351
|
untitled: "Untitled product"
|
|
334
352
|
}
|
|
335
353
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var embed_stripe_exports = {};
|
|
29
|
+
__export(embed_stripe_exports, {
|
|
30
|
+
default: () => embed_stripe_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(embed_stripe_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var import_react_query = require("@tanstack/react-query");
|
|
36
|
+
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
37
|
+
var import_pure = require("@stripe/connect-js/pure");
|
|
38
|
+
var import_loader = __toESM(require("../shared/loader"));
|
|
39
|
+
var import_card_task = __toESM(require("./card-task"));
|
|
40
|
+
const instances = /* @__PURE__ */ new Map();
|
|
41
|
+
const appearance = {
|
|
42
|
+
variables: {
|
|
43
|
+
actionPrimaryColorText: "#000000",
|
|
44
|
+
borderRadius: "4px",
|
|
45
|
+
buttonPrimaryColorBackground: "#000000",
|
|
46
|
+
buttonPrimaryColorBorder: "#000000",
|
|
47
|
+
buttonPrimaryColorText: "#FFFFFF",
|
|
48
|
+
colorPrimary: "#000000",
|
|
49
|
+
colorText: "#000000",
|
|
50
|
+
fontFamily: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
51
|
+
formAccentColor: "#000000"
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const connect = (endpoint, publishableKey) => {
|
|
55
|
+
if (!instances.has(endpoint)) {
|
|
56
|
+
instances.set(endpoint, (0, import_pure.loadConnectAndInitialize)({
|
|
57
|
+
appearance,
|
|
58
|
+
fetchClientSecret: async () => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
return (_b = (_a = await (0, import_fetch.request)({ endpoint, method: "POST" })) == null ? void 0 : _a.result) == null ? void 0 : _b.clientSecret;
|
|
61
|
+
},
|
|
62
|
+
publishableKey
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
return instances.get(endpoint);
|
|
66
|
+
};
|
|
67
|
+
const EmbedStripe = ({
|
|
68
|
+
component,
|
|
69
|
+
endpoint,
|
|
70
|
+
onClose,
|
|
71
|
+
onExit,
|
|
72
|
+
onNotificationsChange,
|
|
73
|
+
payment
|
|
74
|
+
}) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const container = (0, import_react.useRef)(null);
|
|
77
|
+
const publishableKey = (_b = (_a = (0, import_react_query.useQueryClient)().getQueryData(["app"])) == null ? void 0 : _a.credentials) == null ? void 0 : _b.stripePublishableKey;
|
|
78
|
+
const handlers = (0, import_react.useRef)({});
|
|
79
|
+
handlers.current = { onClose, onExit, onNotificationsChange };
|
|
80
|
+
const [state, setState] = (0, import_react.useState)("loading");
|
|
81
|
+
(0, import_react.useEffect)(
|
|
82
|
+
() => {
|
|
83
|
+
var _a2, _b2, _c, _d;
|
|
84
|
+
setState("loading");
|
|
85
|
+
const failed = () => {
|
|
86
|
+
instances.delete(endpoint);
|
|
87
|
+
setState((state2) => state2 === "ready" ? state2 : "error");
|
|
88
|
+
};
|
|
89
|
+
if (!publishableKey) {
|
|
90
|
+
setState("error");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const instance = connect(endpoint, publishableKey);
|
|
94
|
+
instance.debugInstance().catch(failed);
|
|
95
|
+
const element = instance.create(component.replace(/_/g, "-"));
|
|
96
|
+
element.setOnLoaderStart(() => setState("ready"));
|
|
97
|
+
element.setOnLoadError(failed);
|
|
98
|
+
(_a2 = element.setOnExit) == null ? void 0 : _a2.call(element, () => {
|
|
99
|
+
var _a3, _b3;
|
|
100
|
+
return (_b3 = (_a3 = handlers.current).onExit) == null ? void 0 : _b3.call(_a3);
|
|
101
|
+
});
|
|
102
|
+
(_b2 = element.setOnClose) == null ? void 0 : _b2.call(element, () => {
|
|
103
|
+
var _a3, _b3;
|
|
104
|
+
return (_b3 = (_a3 = handlers.current).onClose) == null ? void 0 : _b3.call(_a3);
|
|
105
|
+
});
|
|
106
|
+
if (payment) (_c = element.setPayment) == null ? void 0 : _c.call(element, payment);
|
|
107
|
+
(_d = element.setOnNotificationsChange) == null ? void 0 : _d.call(element, (response) => {
|
|
108
|
+
var _a3, _b3;
|
|
109
|
+
return (_b3 = (_a3 = handlers.current).onNotificationsChange) == null ? void 0 : _b3.call(_a3, response);
|
|
110
|
+
});
|
|
111
|
+
container.current.appendChild(element);
|
|
112
|
+
return () => element.remove();
|
|
113
|
+
},
|
|
114
|
+
[component, endpoint, payment, publishableKey]
|
|
115
|
+
);
|
|
116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
...{
|
|
120
|
+
className: state === "loading" ? "relative min-h-24" : "relative"
|
|
121
|
+
},
|
|
122
|
+
children: [
|
|
123
|
+
state === "loading" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.default, {}),
|
|
124
|
+
state === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
+
import_card_task.default,
|
|
126
|
+
{
|
|
127
|
+
...{
|
|
128
|
+
message: "We could not load that from Stripe",
|
|
129
|
+
type: "error"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
...{
|
|
137
|
+
ref: container
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
var embed_stripe_default = EmbedStripe;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
5
|
+
import { loadConnectAndInitialize } from "@stripe/connect-js/pure";
|
|
6
|
+
import Loader from "../shared/loader.mjs";
|
|
7
|
+
import CardTask from "./card-task.mjs";
|
|
8
|
+
const instances = /* @__PURE__ */ new Map();
|
|
9
|
+
const appearance = {
|
|
10
|
+
variables: {
|
|
11
|
+
actionPrimaryColorText: "#000000",
|
|
12
|
+
borderRadius: "4px",
|
|
13
|
+
buttonPrimaryColorBackground: "#000000",
|
|
14
|
+
buttonPrimaryColorBorder: "#000000",
|
|
15
|
+
buttonPrimaryColorText: "#FFFFFF",
|
|
16
|
+
colorPrimary: "#000000",
|
|
17
|
+
colorText: "#000000",
|
|
18
|
+
fontFamily: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
19
|
+
formAccentColor: "#000000"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const connect = (endpoint, publishableKey) => {
|
|
23
|
+
if (!instances.has(endpoint)) {
|
|
24
|
+
instances.set(endpoint, loadConnectAndInitialize({
|
|
25
|
+
appearance,
|
|
26
|
+
fetchClientSecret: async () => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
return (_b = (_a = await request({ endpoint, method: "POST" })) == null ? void 0 : _a.result) == null ? void 0 : _b.clientSecret;
|
|
29
|
+
},
|
|
30
|
+
publishableKey
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
return instances.get(endpoint);
|
|
34
|
+
};
|
|
35
|
+
const EmbedStripe = ({
|
|
36
|
+
component,
|
|
37
|
+
endpoint,
|
|
38
|
+
onClose,
|
|
39
|
+
onExit,
|
|
40
|
+
onNotificationsChange,
|
|
41
|
+
payment
|
|
42
|
+
}) => {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
const container = useRef(null);
|
|
45
|
+
const publishableKey = (_b = (_a = useQueryClient().getQueryData(["app"])) == null ? void 0 : _a.credentials) == null ? void 0 : _b.stripePublishableKey;
|
|
46
|
+
const handlers = useRef({});
|
|
47
|
+
handlers.current = { onClose, onExit, onNotificationsChange };
|
|
48
|
+
const [state, setState] = useState("loading");
|
|
49
|
+
useEffect(
|
|
50
|
+
() => {
|
|
51
|
+
var _a2, _b2, _c, _d;
|
|
52
|
+
setState("loading");
|
|
53
|
+
const failed = () => {
|
|
54
|
+
instances.delete(endpoint);
|
|
55
|
+
setState((state2) => state2 === "ready" ? state2 : "error");
|
|
56
|
+
};
|
|
57
|
+
if (!publishableKey) {
|
|
58
|
+
setState("error");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const instance = connect(endpoint, publishableKey);
|
|
62
|
+
instance.debugInstance().catch(failed);
|
|
63
|
+
const element = instance.create(component.replace(/_/g, "-"));
|
|
64
|
+
element.setOnLoaderStart(() => setState("ready"));
|
|
65
|
+
element.setOnLoadError(failed);
|
|
66
|
+
(_a2 = element.setOnExit) == null ? void 0 : _a2.call(element, () => {
|
|
67
|
+
var _a3, _b3;
|
|
68
|
+
return (_b3 = (_a3 = handlers.current).onExit) == null ? void 0 : _b3.call(_a3);
|
|
69
|
+
});
|
|
70
|
+
(_b2 = element.setOnClose) == null ? void 0 : _b2.call(element, () => {
|
|
71
|
+
var _a3, _b3;
|
|
72
|
+
return (_b3 = (_a3 = handlers.current).onClose) == null ? void 0 : _b3.call(_a3);
|
|
73
|
+
});
|
|
74
|
+
if (payment) (_c = element.setPayment) == null ? void 0 : _c.call(element, payment);
|
|
75
|
+
(_d = element.setOnNotificationsChange) == null ? void 0 : _d.call(element, (response) => {
|
|
76
|
+
var _a3, _b3;
|
|
77
|
+
return (_b3 = (_a3 = handlers.current).onNotificationsChange) == null ? void 0 : _b3.call(_a3, response);
|
|
78
|
+
});
|
|
79
|
+
container.current.appendChild(element);
|
|
80
|
+
return () => element.remove();
|
|
81
|
+
},
|
|
82
|
+
[component, endpoint, payment, publishableKey]
|
|
83
|
+
);
|
|
84
|
+
return /* @__PURE__ */ jsxs(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
...{
|
|
88
|
+
className: state === "loading" ? "relative min-h-24" : "relative"
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
state === "loading" && /* @__PURE__ */ jsx(Loader, {}),
|
|
92
|
+
state === "error" && /* @__PURE__ */ jsx(
|
|
93
|
+
CardTask,
|
|
94
|
+
{
|
|
95
|
+
...{
|
|
96
|
+
message: "We could not load that from Stripe",
|
|
97
|
+
type: "error"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsx(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
...{
|
|
105
|
+
ref: container
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
var embed_stripe_default = EmbedStripe;
|
|
114
|
+
export {
|
|
115
|
+
embed_stripe_default as default
|
|
116
|
+
};
|