@drawbridge/components 0.1.48 → 0.1.49

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.
Files changed (125) hide show
  1. package/dist/bridge/fields.js +0 -278
  2. package/dist/bridge/fields.mjs +1 -276
  3. package/dist/bridge/form-subdomain-shop-modal.js +274 -234
  4. package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
  5. package/dist/bridge/form-subdomain.js +0 -7
  6. package/dist/bridge/form-subdomain.mjs +2 -9
  7. package/dist/bridge/lib/age-gate.js +0 -12
  8. package/dist/bridge/lib/age-gate.mjs +0 -11
  9. package/dist/bridge/lib/checkout-kit.js +32 -2
  10. package/dist/bridge/lib/checkout-kit.mjs +32 -2
  11. package/dist/bridge/lib/entry.js +0 -3
  12. package/dist/bridge/lib/entry.mjs +0 -2
  13. package/dist/bridge/product-tile.js +6 -9
  14. package/dist/bridge/product-tile.mjs +6 -9
  15. package/dist/bridge/template-layout.js +122 -237
  16. package/dist/bridge/template-layout.mjs +122 -237
  17. package/dist/bridge/template-modal.js +73 -28
  18. package/dist/bridge/template-modal.mjs +74 -29
  19. package/dist/dashboard/buttons-subscription.js +1 -1
  20. package/dist/dashboard/buttons-subscription.mjs +1 -1
  21. package/dist/dashboard/campaign-form.js +2 -7
  22. package/dist/dashboard/campaign-form.mjs +2 -7
  23. package/dist/dashboard/card-order.js +4 -22
  24. package/dist/dashboard/card-order.mjs +4 -22
  25. package/dist/dashboard/document-blocks.js +17 -4
  26. package/dist/dashboard/document-blocks.mjs +17 -4
  27. package/dist/dashboard/form-admin-provider.js +17 -71
  28. package/dist/dashboard/form-admin-provider.mjs +17 -71
  29. package/dist/dashboard/form-file-upload.js +2 -3
  30. package/dist/dashboard/form-file-upload.mjs +3 -4
  31. package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
  32. package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
  33. package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
  34. package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
  35. package/dist/dashboard/form-organization-campaign.js +0 -82
  36. package/dist/dashboard/form-organization-campaign.mjs +0 -81
  37. package/dist/dashboard/form-organization-connection.js +6 -48
  38. package/dist/dashboard/form-organization-connection.mjs +7 -48
  39. package/dist/dashboard/form-organization-workflow.js +1 -72
  40. package/dist/dashboard/form-organization-workflow.mjs +1 -69
  41. package/dist/dashboard/form-otc.js +5 -4
  42. package/dist/dashboard/form-otc.mjs +5 -4
  43. package/dist/dashboard/form-stripe.js +5 -12
  44. package/dist/dashboard/form-stripe.mjs +5 -12
  45. package/dist/dashboard/input-fields.js +158 -11
  46. package/dist/dashboard/input-fields.mjs +158 -11
  47. package/dist/dashboard/input-file.js +4 -21
  48. package/dist/dashboard/input-file.mjs +4 -21
  49. package/dist/dashboard/lib/connection-controls.js +2 -5
  50. package/dist/dashboard/lib/connection-controls.mjs +1 -3
  51. package/dist/dashboard/lib/form-page.js +1 -1
  52. package/dist/dashboard/lib/form-page.mjs +1 -1
  53. package/dist/dashboard/lib/uppy.js +1 -10
  54. package/dist/dashboard/lib/uppy.mjs +2 -11
  55. package/dist/dashboard/order-sections.js +6 -456
  56. package/dist/dashboard/order-sections.mjs +7 -453
  57. package/dist/dashboard/provider-ui.js +7 -9
  58. package/dist/dashboard/provider-ui.mjs +7 -9
  59. package/dist/dashboard/template-ui.js +12 -4
  60. package/dist/dashboard/template-ui.mjs +12 -4
  61. package/dist/input-checkbox.js +10 -28
  62. package/dist/input-checkbox.mjs +10 -28
  63. package/dist/product.js +24 -96
  64. package/dist/product.mjs +25 -97
  65. package/dist/shared/lib/helpers.js +6 -54
  66. package/dist/shared/lib/helpers.mjs +8 -53
  67. package/package.json +4 -74
  68. package/types/bridge/fields.d.ts +2 -14
  69. package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
  70. package/types/bridge/lib/age-gate.d.ts +0 -5
  71. package/types/bridge/lib/checkout-kit.d.ts +10 -2
  72. package/types/bridge/lib/entry.d.ts +0 -3
  73. package/types/dashboard/card-order.d.ts +0 -6
  74. package/types/dashboard/document-blocks.d.ts +3 -2
  75. package/types/dashboard/form-admin-provider.d.ts +2 -9
  76. package/types/dashboard/form-file-upload.d.ts +1 -2
  77. package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
  78. package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
  79. package/types/dashboard/form-organization-campaign.d.ts +0 -3
  80. package/types/dashboard/form-organization-connection.d.ts +0 -11
  81. package/types/dashboard/form-otc.d.ts +1 -5
  82. package/types/dashboard/form-stripe.d.ts +2 -3
  83. package/types/dashboard/input-file.d.ts +0 -2
  84. package/types/dashboard/order-sections.d.ts +1 -24
  85. package/types/input-checkbox.d.ts +0 -2
  86. package/types/shared/lib/helpers.d.ts +0 -4
  87. package/dist/bridge/cart-drawer.js +0 -152
  88. package/dist/bridge/cart-drawer.mjs +0 -123
  89. package/dist/bridge/form-subdomain-checkout.js +0 -687
  90. package/dist/bridge/form-subdomain-checkout.mjs +0 -665
  91. package/dist/bridge/lib/cart.js +0 -79
  92. package/dist/bridge/lib/cart.mjs +0 -48
  93. package/dist/dashboard/embed-stripe.js +0 -145
  94. package/dist/dashboard/embed-stripe.mjs +0 -116
  95. package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
  96. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
  97. package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
  98. package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
  99. package/dist/dashboard/form-organization-product.js +0 -1461
  100. package/dist/dashboard/form-organization-product.mjs +0 -1425
  101. package/dist/dashboard/input-gallery.js +0 -201
  102. package/dist/dashboard/input-gallery.mjs +0 -172
  103. package/dist/dashboard/lib/products.js +0 -169
  104. package/dist/dashboard/lib/products.mjs +0 -135
  105. package/dist/dashboard/lib/settings-paths.js +0 -35
  106. package/dist/dashboard/lib/settings-paths.mjs +0 -11
  107. package/dist/dashboard/shipping-rates.js +0 -404
  108. package/dist/dashboard/shipping-rates.mjs +0 -371
  109. package/dist/dashboard/template-buyer.js +0 -301
  110. package/dist/dashboard/template-buyer.mjs +0 -267
  111. package/dist/shared/order-summary.js +0 -139
  112. package/dist/shared/order-summary.mjs +0 -110
  113. package/types/bridge/cart-drawer.d.ts +0 -31
  114. package/types/bridge/form-subdomain-checkout.d.ts +0 -20
  115. package/types/bridge/lib/cart.d.ts +0 -44
  116. package/types/dashboard/embed-stripe.d.ts +0 -25
  117. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
  118. package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
  119. package/types/dashboard/form-organization-product.d.ts +0 -24
  120. package/types/dashboard/input-gallery.d.ts +0 -14
  121. package/types/dashboard/lib/products.d.ts +0 -14
  122. package/types/dashboard/lib/settings-paths.d.ts +0 -5
  123. package/types/dashboard/shipping-rates.d.ts +0 -26
  124. package/types/dashboard/template-buyer.d.ts +0 -50
  125. package/types/shared/order-summary.d.ts +0 -19
@@ -1,79 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var cart_exports = {};
19
- __export(cart_exports, {
20
- canCheckout: () => canCheckout,
21
- cartAlive: () => cartAlive,
22
- cartCount: () => cartCount,
23
- cartKey: () => cartKey,
24
- continueRequest: () => continueRequest,
25
- lineNote: () => lineNote,
26
- productImage: () => productImage,
27
- recommendedRow: () => recommendedRow,
28
- withQuantity: () => withQuantity
29
- });
30
- module.exports = __toCommonJS(cart_exports);
31
- var import_cdn = require("@drawbridge/drawbridge-utils/cdn");
32
- var import_products = require("@drawbridge/drawbridge-utils/products");
33
- const cartKey = ({ campaign, subdomain }) => "drawbridge.cart." + subdomain + "." + campaign;
34
- const DAY = 24 * 60 * 60 * 1e3;
35
- const cartAlive = (made, now = Date.now()) => Number.isFinite(Number(made)) && Number(made) > 0 && now - Number(made) <= import_products.CART_DAYS * DAY;
36
- const cartCount = (cart) => ((cart == null ? void 0 : cart.lines) || []).reduce((sum, line) => sum + ((line == null ? void 0 : line.quantity) || 0), 0);
37
- const withQuantity = (cart, id, quantity) => cart && {
38
- ...cart,
39
- lines: (cart.lines || []).map((line) => line.id === id ? { ...line, quantity } : line).filter((line) => line.quantity > 0)
40
- };
41
- const lineNote = (line, cut = []) => (line == null ? void 0 : line.availableForSale) === false ? "Sold out" : (cut || []).includes(line == null ? void 0 : line.id) && Number.isFinite(line == null ? void 0 : line.left) ? "Only " + line.left + " left" : null;
42
- const canCheckout = (cart) => ((cart == null ? void 0 : cart.lines) || []).length > 0 && !cart.lines.some((line) => line.availableForSale === false);
43
- const continueRequest = ({ cartId, email, params, preview = false }) => !preview && cartId ? {
44
- body: {
45
- cartId,
46
- email
47
- },
48
- endpoint: "/subdomain/" + (params == null ? void 0 : params.subdomain) + "/page/" + (params == null ? void 0 : params.slug) + "/cart",
49
- method: "PUT"
50
- } : null;
51
- const productImage = (product, size) => {
52
- var _a;
53
- const variant = ((product == null ? void 0 : product.variants) || []).find((item) => (item == null ? void 0 : item.availableForSale) !== false) || null;
54
- const first = (_a = product == null ? void 0 : product.images) == null ? void 0 : _a[0];
55
- const file = (first == null ? void 0 : first.file) && typeof first.file === "object" ? first.file : null;
56
- return file && ((0, import_cdn.cdnSrc)(file, size, file.updatedAt) || (0, import_cdn.cdnSrc)(file, "original", file.updatedAt)) || (first == null ? void 0 : first.url) || (variant == null ? void 0 : variant.image) || (product == null ? void 0 : product.image) || null;
57
- };
58
- const recommendedRow = (product) => {
59
- const variant = ((product == null ? void 0 : product.variants) || []).find((item) => (item == null ? void 0 : item.availableForSale) !== false) || null;
60
- return {
61
- currency: (variant == null ? void 0 : variant.currency) || null,
62
- id: product == null ? void 0 : product.id,
63
- image: productImage(product, "100x100"),
64
- price: Number.isFinite(variant == null ? void 0 : variant.price) ? variant.price : null,
65
- title: (product == null ? void 0 : product.title) || ""
66
- };
67
- };
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- canCheckout,
71
- cartAlive,
72
- cartCount,
73
- cartKey,
74
- continueRequest,
75
- lineNote,
76
- productImage,
77
- recommendedRow,
78
- withQuantity
79
- });
@@ -1,48 +0,0 @@
1
- import { cdnSrc } from "@drawbridge/drawbridge-utils/cdn";
2
- import { CART_DAYS } from "@drawbridge/drawbridge-utils/products";
3
- const cartKey = ({ campaign, subdomain }) => "drawbridge.cart." + subdomain + "." + campaign;
4
- const DAY = 24 * 60 * 60 * 1e3;
5
- const cartAlive = (made, now = Date.now()) => Number.isFinite(Number(made)) && Number(made) > 0 && now - Number(made) <= CART_DAYS * DAY;
6
- const cartCount = (cart) => ((cart == null ? void 0 : cart.lines) || []).reduce((sum, line) => sum + ((line == null ? void 0 : line.quantity) || 0), 0);
7
- const withQuantity = (cart, id, quantity) => cart && {
8
- ...cart,
9
- lines: (cart.lines || []).map((line) => line.id === id ? { ...line, quantity } : line).filter((line) => line.quantity > 0)
10
- };
11
- const lineNote = (line, cut = []) => (line == null ? void 0 : line.availableForSale) === false ? "Sold out" : (cut || []).includes(line == null ? void 0 : line.id) && Number.isFinite(line == null ? void 0 : line.left) ? "Only " + line.left + " left" : null;
12
- const canCheckout = (cart) => ((cart == null ? void 0 : cart.lines) || []).length > 0 && !cart.lines.some((line) => line.availableForSale === false);
13
- const continueRequest = ({ cartId, email, params, preview = false }) => !preview && cartId ? {
14
- body: {
15
- cartId,
16
- email
17
- },
18
- endpoint: "/subdomain/" + (params == null ? void 0 : params.subdomain) + "/page/" + (params == null ? void 0 : params.slug) + "/cart",
19
- method: "PUT"
20
- } : null;
21
- const productImage = (product, size) => {
22
- var _a;
23
- const variant = ((product == null ? void 0 : product.variants) || []).find((item) => (item == null ? void 0 : item.availableForSale) !== false) || null;
24
- const first = (_a = product == null ? void 0 : product.images) == null ? void 0 : _a[0];
25
- const file = (first == null ? void 0 : first.file) && typeof first.file === "object" ? first.file : null;
26
- return file && (cdnSrc(file, size, file.updatedAt) || cdnSrc(file, "original", file.updatedAt)) || (first == null ? void 0 : first.url) || (variant == null ? void 0 : variant.image) || (product == null ? void 0 : product.image) || null;
27
- };
28
- const recommendedRow = (product) => {
29
- const variant = ((product == null ? void 0 : product.variants) || []).find((item) => (item == null ? void 0 : item.availableForSale) !== false) || null;
30
- return {
31
- currency: (variant == null ? void 0 : variant.currency) || null,
32
- id: product == null ? void 0 : product.id,
33
- image: productImage(product, "100x100"),
34
- price: Number.isFinite(variant == null ? void 0 : variant.price) ? variant.price : null,
35
- title: (product == null ? void 0 : product.title) || ""
36
- };
37
- };
38
- export {
39
- canCheckout,
40
- cartAlive,
41
- cartCount,
42
- cartKey,
43
- continueRequest,
44
- lineNote,
45
- productImage,
46
- recommendedRow,
47
- withQuantity
48
- };
@@ -1,145 +0,0 @@
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;
@@ -1,116 +0,0 @@
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
- };
@@ -1,193 +0,0 @@
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 form_organization_campaign_field_birthday_exports = {};
29
- __export(form_organization_campaign_field_birthday_exports, {
30
- default: () => form_organization_campaign_field_birthday_default
31
- });
32
- module.exports = __toCommonJS(form_organization_campaign_field_birthday_exports);
33
- var import_jsx_runtime = require("react/jsx-runtime");
34
- var import_form = require("../shared/lib/form");
35
- var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
36
- var import_yup = __toESM(require("../shared/lib/yup"));
37
- var import_form2 = __toESM(require("../shared/form"));
38
- var import_fieldset = __toESM(require("../shared/fieldset"));
39
- var import_input_group = __toESM(require("../input-group"));
40
- var import_input_text = __toESM(require("../input-text"));
41
- var import_input_switch = __toESM(require("../shared/input-switch"));
42
- var import_button = __toESM(require("../shared/button"));
43
- const FormOrganizationCampaignFieldBirthday = ({
44
- disabled,
45
- onError,
46
- onSuccess,
47
- values
48
- }) => {
49
- var _a;
50
- const inputs = (values == null ? void 0 : values.inputs) || [];
51
- const { control, formState, handleSubmit } = (0, import_form.useForm)({
52
- resolver: (0, import_yup.resolver)(
53
- import_yup.default.object({
54
- label: import_yup.default.string().label("Label").required().max(150)
55
- })
56
- ),
57
- values: {
58
- ...values,
59
- attributes: {
60
- required: ((_a = values == null ? void 0 : values.attributes) == null ? void 0 : _a.required) !== false
61
- }
62
- }
63
- });
64
- const onSubmit = async ({
65
- attributes = {},
66
- label,
67
- section
68
- }) => {
69
- try {
70
- const args = {
71
- body: {
72
- attributes: {
73
- required: (attributes == null ? void 0 : attributes.required) !== false
74
- },
75
- label,
76
- ...section && {
77
- section
78
- },
79
- slug: values == null ? void 0 : values.slug,
80
- type: values == null ? void 0 : values.type
81
- },
82
- endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/field",
83
- method: "POST"
84
- };
85
- if (values == null ? void 0 : values.id) {
86
- args.endpoint = args.endpoint + "/" + values.id;
87
- args.method = "PUT";
88
- }
89
- const response = await (0, import_fetch.request)(args);
90
- onSuccess(response);
91
- } catch (error) {
92
- onError(error);
93
- }
94
- };
95
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
96
- import_form2.default,
97
- {
98
- ...{
99
- className: "relative w-full space-y-6",
100
- onSubmit: handleSubmit(onSubmit)
101
- },
102
- children: [
103
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
104
- import_fieldset.default,
105
- {
106
- ...{
107
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
108
- },
109
- children: [
110
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
111
- import_form.Controller,
112
- {
113
- ...{
114
- control,
115
- name: "label",
116
- render: ({ field: { value, onChange } }) => {
117
- var _a2, _b;
118
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
119
- import_input_group.default,
120
- {
121
- ...{
122
- error: (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.label) == null ? void 0 : _b.message,
123
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
124
- import_input_text.default,
125
- {
126
- ...{
127
- disabled: !inputs.includes("label"),
128
- onChange,
129
- value: value || ""
130
- }
131
- }
132
- ),
133
- label: "Field label"
134
- }
135
- }
136
- );
137
- }
138
- }
139
- }
140
- ),
141
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
- import_form.Controller,
143
- {
144
- ...{
145
- control,
146
- name: "attributes.required",
147
- render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
148
- import_input_group.default,
149
- {
150
- ...{
151
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
152
- import_input_switch.default,
153
- {
154
- ...{
155
- disabled: !inputs.includes("attributes"),
156
- onChange,
157
- value: value !== false
158
- }
159
- }
160
- ),
161
- label: "Required"
162
- }
163
- }
164
- )
165
- }
166
- }
167
- )
168
- ]
169
- }
170
- ),
171
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
172
- import_fieldset.default,
173
- {
174
- ...{
175
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
176
- },
177
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
- import_button.default,
179
- {
180
- ...{
181
- loading: formState == null ? void 0 : formState.isSubmitting,
182
- type: "submit"
183
- },
184
- children: "Submit"
185
- }
186
- )
187
- }
188
- )
189
- ]
190
- }
191
- );
192
- };
193
- var form_organization_campaign_field_birthday_default = FormOrganizationCampaignFieldBirthday;