@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
|
@@ -42,7 +42,7 @@ const useCampaignSwitch = ({ campaign, onError, onSuccess }) => {
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
-
const SwitchLock = ({ disabled, onChange, value }) => /* @__PURE__ */ jsxs(
|
|
45
|
+
const SwitchLock = ({ disabled, name, onChange, value }) => /* @__PURE__ */ jsxs(
|
|
46
46
|
"span",
|
|
47
47
|
{
|
|
48
48
|
...{
|
|
@@ -63,6 +63,8 @@ const SwitchLock = ({ disabled, onChange, value }) => /* @__PURE__ */ jsxs(
|
|
|
63
63
|
InputSwitch,
|
|
64
64
|
{
|
|
65
65
|
...{
|
|
66
|
+
// Impeccable audit, 2026-11-21: the switch is named for its row.
|
|
67
|
+
"aria-label": name,
|
|
66
68
|
disabled,
|
|
67
69
|
onChange,
|
|
68
70
|
value
|
|
@@ -78,6 +80,7 @@ const SwitchRow = ({ description, lock, onChange, title, value }) => {
|
|
|
78
80
|
{
|
|
79
81
|
...{
|
|
80
82
|
disabled: Boolean(lock),
|
|
83
|
+
name: typeof title === "string" ? title : void 0,
|
|
81
84
|
onChange,
|
|
82
85
|
value
|
|
83
86
|
}
|
|
@@ -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
|
+
};
|
|
@@ -33,6 +33,7 @@ __export(form_admin_provider_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(form_admin_provider_exports);
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var import_react = require("react");
|
|
36
|
+
var import_react_query = require("@tanstack/react-query");
|
|
36
37
|
var import_form = require("../shared/lib/form");
|
|
37
38
|
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
38
39
|
var import_yup = __toESM(require("../shared/lib/yup"));
|
|
@@ -44,11 +45,18 @@ var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
|
44
45
|
var import_card_task = __toESM(require("./card-task"));
|
|
45
46
|
var import_input_secret = __toESM(require("./input-secret"));
|
|
46
47
|
var import_button = __toESM(require("../shared/button"));
|
|
47
|
-
|
|
48
|
+
var import_form_organization_connection = require("./form-organization-connection");
|
|
49
|
+
var import_settings_paths = require("./lib/settings-paths");
|
|
50
|
+
const schemaFor = (field, enabled) => {
|
|
48
51
|
if (field.input === "switch") return import_yup.default.boolean().label(field.label);
|
|
49
52
|
const rule = field.input === "email" ? import_yup.default.string().label(field.label).email() : import_yup.default.string().label(field.label);
|
|
50
|
-
return field.required && !field.redact
|
|
53
|
+
return enabled && field.required && !field.redact && !field.hook ? rule.required() : rule.nullable();
|
|
51
54
|
};
|
|
55
|
+
const shape = (tree) => import_yup.default.object(
|
|
56
|
+
Object.fromEntries(
|
|
57
|
+
Object.entries(tree).map(([key, node]) => [key, import_yup.default.isSchema(node) ? node : shape(node)])
|
|
58
|
+
)
|
|
59
|
+
);
|
|
52
60
|
const FormAdminProvider = ({
|
|
53
61
|
onError,
|
|
54
62
|
onSuccess,
|
|
@@ -61,25 +69,37 @@ const FormAdminProvider = ({
|
|
|
61
69
|
// A row that has never been touched has no answer stored and is on, so
|
|
62
70
|
// the box starts checked rather than empty.
|
|
63
71
|
enabled: (values == null ? void 0 : values.enabled) !== false,
|
|
64
|
-
...
|
|
65
|
-
fields.map((field) =>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
field.input === "switch" ? ((_a = values == null ? void 0 : values.settings) == null ? void 0 : _a[field.key]) === true : field.redact ? "" : ((_b = values == null ? void 0 : values.settings) == null ? void 0 : _b[field.key]) ?? ""
|
|
70
|
-
];
|
|
71
|
-
})
|
|
72
|
+
...(0, import_settings_paths.nestPaths)(
|
|
73
|
+
fields.map((field) => [
|
|
74
|
+
field.key,
|
|
75
|
+
field.input === "switch" ? (0, import_settings_paths.readPath)(values == null ? void 0 : values.settings, field.key) === true : field.redact ? "" : (0, import_settings_paths.readPath)(values == null ? void 0 : values.settings, field.key) ?? ""
|
|
76
|
+
])
|
|
72
77
|
)
|
|
73
78
|
}),
|
|
74
79
|
[fields, values]
|
|
75
80
|
);
|
|
76
81
|
const schema = (0, import_react.useMemo)(
|
|
77
|
-
() => import_yup.default.
|
|
82
|
+
() => import_yup.default.lazy((data) => shape({
|
|
78
83
|
enabled: import_yup.default.boolean().label("Enabled"),
|
|
79
|
-
...
|
|
80
|
-
}),
|
|
84
|
+
...(0, import_settings_paths.nestPaths)(fields.map((field) => [field.key, schemaFor(field, (data == null ? void 0 : data.enabled) !== false)]))
|
|
85
|
+
})),
|
|
81
86
|
[fields]
|
|
82
87
|
);
|
|
88
|
+
const hooked = (0, import_react.useMemo)(() => fields.filter((field) => field.hook), [fields]);
|
|
89
|
+
const sourced = (0, import_react_query.useQueries)({
|
|
90
|
+
queries: hooked.map((field) => ({
|
|
91
|
+
enabled: Boolean(values == null ? void 0 : values.slug),
|
|
92
|
+
queryFn: async () => {
|
|
93
|
+
const { result } = await (0, import_fetch.request)({
|
|
94
|
+
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug) + "/hook/" + field.hook,
|
|
95
|
+
params: { limit: 100 }
|
|
96
|
+
});
|
|
97
|
+
return ((result == null ? void 0 : result.items) || []).map((item) => ({ label: item.title, value: item.id }));
|
|
98
|
+
},
|
|
99
|
+
queryKey: ["admin-provider-hook", values == null ? void 0 : values.slug, field.hook, values == null ? void 0 : values.settings]
|
|
100
|
+
}))
|
|
101
|
+
});
|
|
102
|
+
const optionsFor = Object.fromEntries(hooked.map((field, index) => [field.key, sourced[index]]));
|
|
83
103
|
const [clearing, setClearing] = (0, import_react.useState)([]);
|
|
84
104
|
(0, import_react.useEffect)(() => setClearing([]), [values == null ? void 0 : values.slug]);
|
|
85
105
|
const { control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
@@ -104,10 +124,20 @@ const FormAdminProvider = ({
|
|
|
104
124
|
// admin then TYPED INTO is a replacement, not a removal. The api
|
|
105
125
|
// applies `clear` after `settings`, so naming a key that also
|
|
106
126
|
// carries a value deleted the value just typed and answered "Saved".
|
|
107
|
-
|
|
127
|
+
//
|
|
128
|
+
// `clear` stays a list of dotted keys; `settings` goes nested,
|
|
129
|
+
// the shape the api stores.
|
|
130
|
+
//
|
|
131
|
+
// A PICKER EMPTIED IS A REMOVAL TOO. Its trash empties the value,
|
|
132
|
+
// and blank would keep the saved one, so a picker that held a
|
|
133
|
+
// saved value and is empty now is named here as well.
|
|
134
|
+
clear: [
|
|
135
|
+
...clearing.filter((key) => !(0, import_settings_paths.readPath)(data, key)),
|
|
136
|
+
...fields.filter((field) => field.hook && !(0, import_settings_paths.readPath)(data, field.key) && (0, import_settings_paths.readPath)(values == null ? void 0 : values.settings, field.key)).map((field) => field.key)
|
|
137
|
+
],
|
|
108
138
|
enabled: Boolean(data == null ? void 0 : data.enabled),
|
|
109
|
-
settings:
|
|
110
|
-
fields.map((field) => [field.key, (
|
|
139
|
+
settings: (0, import_settings_paths.nestPaths)(
|
|
140
|
+
fields.map((field) => [field.key, (0, import_settings_paths.readPath)(data, field.key) ?? ""])
|
|
111
141
|
)
|
|
112
142
|
},
|
|
113
143
|
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug),
|
|
@@ -233,11 +263,35 @@ const FormAdminProvider = ({
|
|
|
233
263
|
value
|
|
234
264
|
}
|
|
235
265
|
}
|
|
266
|
+
) : field.input === "select" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
267
|
+
import_input_group.default,
|
|
268
|
+
{
|
|
269
|
+
...{
|
|
270
|
+
error: (_a = (0, import_settings_paths.readPath)(formState == null ? void 0 : formState.errors, field.key)) == null ? void 0 : _a.message,
|
|
271
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
272
|
+
import_form_organization_connection.Editable,
|
|
273
|
+
{
|
|
274
|
+
...{
|
|
275
|
+
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug) + "/hook/" + field.hook,
|
|
276
|
+
field,
|
|
277
|
+
onChange,
|
|
278
|
+
titleFor: (id) => {
|
|
279
|
+
var _a2, _b2, _c;
|
|
280
|
+
return ((_c = (_b2 = (_a2 = optionsFor[field.key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.find((option) => option.value === id)) == null ? void 0 : _c.label) || id;
|
|
281
|
+
},
|
|
282
|
+
value
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
label: field.label,
|
|
287
|
+
message: field.message
|
|
288
|
+
}
|
|
289
|
+
}
|
|
236
290
|
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
237
291
|
import_input_group.default,
|
|
238
292
|
{
|
|
239
293
|
...{
|
|
240
|
-
error: (_b = (
|
|
294
|
+
error: (_b = (0, import_settings_paths.readPath)(formState == null ? void 0 : formState.errors, field.key)) == null ? void 0 : _b.message,
|
|
241
295
|
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
242
296
|
import_input_text.default,
|
|
243
297
|
{
|