@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
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Controller, useForm } from "../shared/lib/form.mjs";
|
|
3
|
+
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
4
|
+
import yup, { resolver } from "../shared/lib/yup.mjs";
|
|
5
|
+
import Form from "../shared/form.mjs";
|
|
6
|
+
import Fieldset from "../shared/fieldset.mjs";
|
|
7
|
+
import InputGroup from "../input-group.mjs";
|
|
8
|
+
import InputText from "../input-text.mjs";
|
|
9
|
+
import InputNumber from "../input-number.mjs";
|
|
10
|
+
import InputSwitch from "../shared/input-switch.mjs";
|
|
11
|
+
import Button from "../shared/button.mjs";
|
|
12
|
+
const FormOrganizationCampaignFieldRating = ({
|
|
13
|
+
disabled,
|
|
14
|
+
onError,
|
|
15
|
+
onSuccess,
|
|
16
|
+
values
|
|
17
|
+
}) => {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
19
|
+
const inputs = (values == null ? void 0 : values.inputs) || [];
|
|
20
|
+
const { control, formState, handleSubmit } = useForm({
|
|
21
|
+
resolver: resolver(
|
|
22
|
+
yup.object({
|
|
23
|
+
attributes: yup.object({
|
|
24
|
+
max: yup.number().label("Scale").transform((value, original) => original === "" ? void 0 : value).required().integer().min(3).max(10)
|
|
25
|
+
}),
|
|
26
|
+
label: yup.string().label("Label").required().max(150),
|
|
27
|
+
settings: yup.object({
|
|
28
|
+
high: yup.string().label("High label").max(50),
|
|
29
|
+
low: yup.string().label("Low label").max(50)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
),
|
|
33
|
+
values: {
|
|
34
|
+
...values,
|
|
35
|
+
attributes: {
|
|
36
|
+
max: ((_a = values == null ? void 0 : values.attributes) == null ? void 0 : _a.max) ?? 5,
|
|
37
|
+
required: ((_b = values == null ? void 0 : values.attributes) == null ? void 0 : _b.required) !== false
|
|
38
|
+
},
|
|
39
|
+
settings: {
|
|
40
|
+
high: ((_c = values == null ? void 0 : values.settings) == null ? void 0 : _c.high) || "",
|
|
41
|
+
low: ((_d = values == null ? void 0 : values.settings) == null ? void 0 : _d.low) || ""
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const onSubmit = async ({
|
|
46
|
+
attributes = {},
|
|
47
|
+
label,
|
|
48
|
+
section,
|
|
49
|
+
settings = {}
|
|
50
|
+
}) => {
|
|
51
|
+
try {
|
|
52
|
+
const args = {
|
|
53
|
+
body: {
|
|
54
|
+
attributes: {
|
|
55
|
+
max: Number(attributes == null ? void 0 : attributes.max),
|
|
56
|
+
required: (attributes == null ? void 0 : attributes.required) !== false
|
|
57
|
+
},
|
|
58
|
+
label,
|
|
59
|
+
...section && {
|
|
60
|
+
section
|
|
61
|
+
},
|
|
62
|
+
// A blank end label is no label.
|
|
63
|
+
settings: {
|
|
64
|
+
high: (settings == null ? void 0 : settings.high) || null,
|
|
65
|
+
low: (settings == null ? void 0 : settings.low) || null
|
|
66
|
+
},
|
|
67
|
+
slug: values == null ? void 0 : values.slug,
|
|
68
|
+
type: values == null ? void 0 : values.type
|
|
69
|
+
},
|
|
70
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/field",
|
|
71
|
+
method: "POST"
|
|
72
|
+
};
|
|
73
|
+
if (values == null ? void 0 : values.id) {
|
|
74
|
+
args.endpoint = args.endpoint + "/" + values.id;
|
|
75
|
+
args.method = "PUT";
|
|
76
|
+
}
|
|
77
|
+
const response = await request(args);
|
|
78
|
+
onSuccess(response);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
onError(error);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const text = (name, label, error) => /* @__PURE__ */ jsx(
|
|
84
|
+
Controller,
|
|
85
|
+
{
|
|
86
|
+
...{
|
|
87
|
+
control,
|
|
88
|
+
name,
|
|
89
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ jsx(
|
|
90
|
+
InputGroup,
|
|
91
|
+
{
|
|
92
|
+
...{
|
|
93
|
+
error,
|
|
94
|
+
input: /* @__PURE__ */ jsx(
|
|
95
|
+
InputText,
|
|
96
|
+
{
|
|
97
|
+
...{
|
|
98
|
+
disabled: !inputs.includes(name.split(".")[0]),
|
|
99
|
+
onChange,
|
|
100
|
+
value: value || ""
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
label
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
return /* @__PURE__ */ jsxs(
|
|
112
|
+
Form,
|
|
113
|
+
{
|
|
114
|
+
...{
|
|
115
|
+
className: "relative w-full space-y-6",
|
|
116
|
+
onSubmit: handleSubmit(onSubmit)
|
|
117
|
+
},
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ jsxs(
|
|
120
|
+
Fieldset,
|
|
121
|
+
{
|
|
122
|
+
...{
|
|
123
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
124
|
+
},
|
|
125
|
+
children: [
|
|
126
|
+
text("label", "Field label", (_f = (_e = formState == null ? void 0 : formState.errors) == null ? void 0 : _e.label) == null ? void 0 : _f.message),
|
|
127
|
+
/* @__PURE__ */ jsx(
|
|
128
|
+
Controller,
|
|
129
|
+
{
|
|
130
|
+
...{
|
|
131
|
+
control,
|
|
132
|
+
name: "attributes.max",
|
|
133
|
+
render: ({ field: { value, onChange } }) => {
|
|
134
|
+
var _a2, _b2, _c2;
|
|
135
|
+
return /* @__PURE__ */ jsx(
|
|
136
|
+
InputGroup,
|
|
137
|
+
{
|
|
138
|
+
...{
|
|
139
|
+
error: (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.attributes) == null ? void 0 : _b2.max) == null ? void 0 : _c2.message,
|
|
140
|
+
input: /* @__PURE__ */ jsx(
|
|
141
|
+
InputNumber,
|
|
142
|
+
{
|
|
143
|
+
...{
|
|
144
|
+
disabled: !inputs.includes("attributes"),
|
|
145
|
+
max: 10,
|
|
146
|
+
min: 3,
|
|
147
|
+
onChange,
|
|
148
|
+
value: value ?? ""
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
label: "Scale"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
text("settings.low", "Low label", (_i = (_h = (_g = formState == null ? void 0 : formState.errors) == null ? void 0 : _g.settings) == null ? void 0 : _h.low) == null ? void 0 : _i.message),
|
|
161
|
+
text("settings.high", "High label", (_l = (_k = (_j = formState == null ? void 0 : formState.errors) == null ? void 0 : _j.settings) == null ? void 0 : _k.high) == null ? void 0 : _l.message),
|
|
162
|
+
/* @__PURE__ */ jsx(
|
|
163
|
+
Controller,
|
|
164
|
+
{
|
|
165
|
+
...{
|
|
166
|
+
control,
|
|
167
|
+
name: "attributes.required",
|
|
168
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ jsx(
|
|
169
|
+
InputGroup,
|
|
170
|
+
{
|
|
171
|
+
...{
|
|
172
|
+
input: /* @__PURE__ */ jsx(
|
|
173
|
+
InputSwitch,
|
|
174
|
+
{
|
|
175
|
+
...{
|
|
176
|
+
disabled: !inputs.includes("attributes"),
|
|
177
|
+
onChange,
|
|
178
|
+
value: value !== false
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
label: "Required"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
193
|
+
Fieldset,
|
|
194
|
+
{
|
|
195
|
+
...{
|
|
196
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
197
|
+
},
|
|
198
|
+
children: /* @__PURE__ */ jsx(
|
|
199
|
+
Button,
|
|
200
|
+
{
|
|
201
|
+
...{
|
|
202
|
+
loading: formState == null ? void 0 : formState.isSubmitting,
|
|
203
|
+
type: "submit"
|
|
204
|
+
},
|
|
205
|
+
children: "Submit"
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
var form_organization_campaign_field_rating_default = FormOrganizationCampaignFieldRating;
|
|
215
|
+
export {
|
|
216
|
+
form_organization_campaign_field_rating_default as default
|
|
217
|
+
};
|
|
@@ -28,6 +28,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
28
28
|
var form_organization_campaign_exports = {};
|
|
29
29
|
__export(form_organization_campaign_exports, {
|
|
30
30
|
FormOrganizationCampaign: () => FormOrganizationCampaign,
|
|
31
|
+
FormOrganizationCampaignCheckout: () => FormOrganizationCampaignCheckout,
|
|
31
32
|
FormOrganizationCampaignClaimWindow: () => FormOrganizationCampaignClaimWindow,
|
|
32
33
|
FormOrganizationCampaignCopy: () => FormOrganizationCampaignCopy,
|
|
33
34
|
FormOrganizationCampaignNotifications: () => FormOrganizationCampaignNotifications,
|
|
@@ -44,6 +45,7 @@ var import_react_query = require("@tanstack/react-query");
|
|
|
44
45
|
var import_form = require("../shared/lib/form");
|
|
45
46
|
var import_yup = __toESM(require("../shared/lib/yup"));
|
|
46
47
|
var import_input_fields = require("./input-fields");
|
|
48
|
+
var import_products = require("./lib/products");
|
|
47
49
|
var import_form2 = __toESM(require("../shared/form"));
|
|
48
50
|
var import_fieldset = __toESM(require("../shared/fieldset"));
|
|
49
51
|
var import_input_group = __toESM(require("../input-group"));
|
|
@@ -228,6 +230,10 @@ const copyFields = {
|
|
|
228
230
|
// The form's one Submit text, on its last step ( the Footer's Button text ).
|
|
229
231
|
submit: ["Button text"]
|
|
230
232
|
};
|
|
233
|
+
const CHECKOUT_OPTIONS = Object.entries(import_products.CHECKOUT_LABELS).map(([value, key]) => ({
|
|
234
|
+
key,
|
|
235
|
+
value
|
|
236
|
+
}));
|
|
231
237
|
const copyPlaceholder = (key) => {
|
|
232
238
|
var _a, _b, _c, _d;
|
|
233
239
|
return ((_d = (_c = (_b = (_a = import_drawbridge_utils.constants) == null ? void 0 : _a.campaign) == null ? void 0 : _b.form) == null ? void 0 : _c.copy) == null ? void 0 : _d[key]) || (key === "submit" ? "Submit" : void 0);
|
|
@@ -849,9 +855,85 @@ const FormOrganizationCampaignSettingsShop = ({
|
|
|
849
855
|
}
|
|
850
856
|
);
|
|
851
857
|
};
|
|
858
|
+
const FormOrganizationCampaignCheckout = ({
|
|
859
|
+
disabled,
|
|
860
|
+
onSubmit,
|
|
861
|
+
values
|
|
862
|
+
}) => {
|
|
863
|
+
const { control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
864
|
+
defaultValues: {
|
|
865
|
+
checkout: (values == null ? void 0 : values.checkout) || "stripe"
|
|
866
|
+
},
|
|
867
|
+
guard: false
|
|
868
|
+
});
|
|
869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
870
|
+
import_form2.default,
|
|
871
|
+
{
|
|
872
|
+
...{
|
|
873
|
+
className: "relative w-full space-y-6",
|
|
874
|
+
onSubmit: handleSubmit(({ checkout }) => onSubmit(checkout))
|
|
875
|
+
},
|
|
876
|
+
children: [
|
|
877
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
878
|
+
import_fieldset.default,
|
|
879
|
+
{
|
|
880
|
+
...{
|
|
881
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
882
|
+
},
|
|
883
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
884
|
+
import_form.Controller,
|
|
885
|
+
{
|
|
886
|
+
...{
|
|
887
|
+
control,
|
|
888
|
+
name: "checkout",
|
|
889
|
+
render: ({ field: { onChange, value } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
890
|
+
import_input_group.default,
|
|
891
|
+
{
|
|
892
|
+
...{
|
|
893
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
894
|
+
import_input_combobox.default,
|
|
895
|
+
{
|
|
896
|
+
...{
|
|
897
|
+
onChange,
|
|
898
|
+
options: CHECKOUT_OPTIONS,
|
|
899
|
+
value
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
),
|
|
903
|
+
label: "Products and checkout"
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
)
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
)
|
|
910
|
+
}
|
|
911
|
+
),
|
|
912
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
913
|
+
import_fieldset.default,
|
|
914
|
+
{
|
|
915
|
+
...{
|
|
916
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
917
|
+
},
|
|
918
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
919
|
+
import_button.default,
|
|
920
|
+
{
|
|
921
|
+
...{
|
|
922
|
+
type: "submit"
|
|
923
|
+
},
|
|
924
|
+
children: "Save"
|
|
925
|
+
}
|
|
926
|
+
)
|
|
927
|
+
}
|
|
928
|
+
)
|
|
929
|
+
]
|
|
930
|
+
}
|
|
931
|
+
);
|
|
932
|
+
};
|
|
852
933
|
// Annotate the CommonJS export names for ESM import in node:
|
|
853
934
|
0 && (module.exports = {
|
|
854
935
|
FormOrganizationCampaign,
|
|
936
|
+
FormOrganizationCampaignCheckout,
|
|
855
937
|
FormOrganizationCampaignClaimWindow,
|
|
856
938
|
FormOrganizationCampaignCopy,
|
|
857
939
|
FormOrganizationCampaignNotifications,
|
|
@@ -6,6 +6,7 @@ import { useQueryClient } from "@tanstack/react-query";
|
|
|
6
6
|
import { useForm, useWatch, FormProvider, Controller } from "../shared/lib/form.mjs";
|
|
7
7
|
import yup, { resolver } from "../shared/lib/yup.mjs";
|
|
8
8
|
import { InputFieldsCampaign, schemas } from "./input-fields.mjs";
|
|
9
|
+
import { CHECKOUT_LABELS } from "./lib/products.mjs";
|
|
9
10
|
import Form from "../shared/form.mjs";
|
|
10
11
|
import Fieldset from "../shared/fieldset.mjs";
|
|
11
12
|
import InputGroup from "../input-group.mjs";
|
|
@@ -190,6 +191,10 @@ const copyFields = {
|
|
|
190
191
|
// The form's one Submit text, on its last step ( the Footer's Button text ).
|
|
191
192
|
submit: ["Button text"]
|
|
192
193
|
};
|
|
194
|
+
const CHECKOUT_OPTIONS = Object.entries(CHECKOUT_LABELS).map(([value, key]) => ({
|
|
195
|
+
key,
|
|
196
|
+
value
|
|
197
|
+
}));
|
|
193
198
|
const copyPlaceholder = (key) => {
|
|
194
199
|
var _a, _b, _c, _d;
|
|
195
200
|
return ((_d = (_c = (_b = (_a = constants) == null ? void 0 : _a.campaign) == null ? void 0 : _b.form) == null ? void 0 : _c.copy) == null ? void 0 : _d[key]) || (key === "submit" ? "Submit" : void 0);
|
|
@@ -811,8 +816,84 @@ const FormOrganizationCampaignSettingsShop = ({
|
|
|
811
816
|
}
|
|
812
817
|
);
|
|
813
818
|
};
|
|
819
|
+
const FormOrganizationCampaignCheckout = ({
|
|
820
|
+
disabled,
|
|
821
|
+
onSubmit,
|
|
822
|
+
values
|
|
823
|
+
}) => {
|
|
824
|
+
const { control, formState, handleSubmit } = useForm({
|
|
825
|
+
defaultValues: {
|
|
826
|
+
checkout: (values == null ? void 0 : values.checkout) || "stripe"
|
|
827
|
+
},
|
|
828
|
+
guard: false
|
|
829
|
+
});
|
|
830
|
+
return /* @__PURE__ */ jsxs(
|
|
831
|
+
Form,
|
|
832
|
+
{
|
|
833
|
+
...{
|
|
834
|
+
className: "relative w-full space-y-6",
|
|
835
|
+
onSubmit: handleSubmit(({ checkout }) => onSubmit(checkout))
|
|
836
|
+
},
|
|
837
|
+
children: [
|
|
838
|
+
/* @__PURE__ */ jsx(
|
|
839
|
+
Fieldset,
|
|
840
|
+
{
|
|
841
|
+
...{
|
|
842
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
843
|
+
},
|
|
844
|
+
children: /* @__PURE__ */ jsx(
|
|
845
|
+
Controller,
|
|
846
|
+
{
|
|
847
|
+
...{
|
|
848
|
+
control,
|
|
849
|
+
name: "checkout",
|
|
850
|
+
render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
|
|
851
|
+
InputGroup,
|
|
852
|
+
{
|
|
853
|
+
...{
|
|
854
|
+
input: /* @__PURE__ */ jsx(
|
|
855
|
+
InputCombobox,
|
|
856
|
+
{
|
|
857
|
+
...{
|
|
858
|
+
onChange,
|
|
859
|
+
options: CHECKOUT_OPTIONS,
|
|
860
|
+
value
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
),
|
|
864
|
+
label: "Products and checkout"
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
)
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
)
|
|
871
|
+
}
|
|
872
|
+
),
|
|
873
|
+
/* @__PURE__ */ jsx(
|
|
874
|
+
Fieldset,
|
|
875
|
+
{
|
|
876
|
+
...{
|
|
877
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
878
|
+
},
|
|
879
|
+
children: /* @__PURE__ */ jsx(
|
|
880
|
+
Button,
|
|
881
|
+
{
|
|
882
|
+
...{
|
|
883
|
+
type: "submit"
|
|
884
|
+
},
|
|
885
|
+
children: "Save"
|
|
886
|
+
}
|
|
887
|
+
)
|
|
888
|
+
}
|
|
889
|
+
)
|
|
890
|
+
]
|
|
891
|
+
}
|
|
892
|
+
);
|
|
893
|
+
};
|
|
814
894
|
export {
|
|
815
895
|
FormOrganizationCampaign,
|
|
896
|
+
FormOrganizationCampaignCheckout,
|
|
816
897
|
FormOrganizationCampaignClaimWindow,
|
|
817
898
|
FormOrganizationCampaignCopy,
|
|
818
899
|
FormOrganizationCampaignNotifications,
|
|
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var form_organization_connection_exports = {};
|
|
30
30
|
__export(form_organization_connection_exports, {
|
|
31
|
+
Editable: () => Editable,
|
|
31
32
|
FormOrganizationConnection: () => FormOrganizationConnection
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(form_organization_connection_exports);
|
|
@@ -227,10 +228,11 @@ const FormOrganizationConnection = ({
|
|
|
227
228
|
onSuccess,
|
|
228
229
|
values
|
|
229
230
|
}) => {
|
|
230
|
-
var _a, _b, _c, _d, _e, _f;
|
|
231
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
231
232
|
const fields = (values == null ? void 0 : values.fields) || [];
|
|
232
233
|
const kind = (_a = values == null ? void 0 : values.connect) == null ? void 0 : _a.type;
|
|
233
|
-
const
|
|
234
|
+
const link = Boolean((_b = values == null ? void 0 : values.connect) == null ? void 0 : _b.link);
|
|
235
|
+
const redirect = kind === "install" ? (_c = values == null ? void 0 : values.connect) == null ? void 0 : _c.redirect : null;
|
|
234
236
|
const readable = fields.filter((field) => !field.input).map((field) => {
|
|
235
237
|
var _a2;
|
|
236
238
|
return {
|
|
@@ -243,6 +245,17 @@ const FormOrganizationConnection = ({
|
|
|
243
245
|
const consent = async () => {
|
|
244
246
|
setConsenting(true);
|
|
245
247
|
try {
|
|
248
|
+
if (link) {
|
|
249
|
+
await (0, import_fetch.request)({
|
|
250
|
+
body: {
|
|
251
|
+
settings: {},
|
|
252
|
+
slug: values == null ? void 0 : values.slug
|
|
253
|
+
},
|
|
254
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection",
|
|
255
|
+
method: "POST"
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
;
|
|
246
259
|
const { result } = await (0, import_fetch.request)({
|
|
247
260
|
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection/" + (values == null ? void 0 : values.slug) + "/authorize",
|
|
248
261
|
method: "POST"
|
|
@@ -335,6 +348,34 @@ const FormOrganizationConnection = ({
|
|
|
335
348
|
}
|
|
336
349
|
) : null;
|
|
337
350
|
}
|
|
351
|
+
if (link) {
|
|
352
|
+
return (values == null ? void 0 : values.status) === "active" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
353
|
+
import_form2.default,
|
|
354
|
+
{
|
|
355
|
+
...{
|
|
356
|
+
className: "relative w-full space-y-8"
|
|
357
|
+
},
|
|
358
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
359
|
+
import_fieldset.default,
|
|
360
|
+
{
|
|
361
|
+
...{
|
|
362
|
+
disabled: disabled || consenting
|
|
363
|
+
},
|
|
364
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
365
|
+
import_button.default,
|
|
366
|
+
{
|
|
367
|
+
...{
|
|
368
|
+
loading: consenting,
|
|
369
|
+
onClick: consent
|
|
370
|
+
},
|
|
371
|
+
children: ((_d = values == null ? void 0 : values.actions) == null ? void 0 : _d.create) || "Connect"
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
}
|
|
375
|
+
)
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
}
|
|
338
379
|
if (kind === "oauth") {
|
|
339
380
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
340
381
|
import_form2.default,
|
|
@@ -404,7 +445,7 @@ const FormOrganizationConnection = ({
|
|
|
404
445
|
// the connection would read Active over nothing.
|
|
405
446
|
disabled: disabled || Object.values(optionsFor).some((entry) => entry == null ? void 0 : entry.isLoading),
|
|
406
447
|
isSubmitting: formState == null ? void 0 : formState.isSubmitting,
|
|
407
|
-
text: ((
|
|
448
|
+
text: ((_e = values == null ? void 0 : values.actions) == null ? void 0 : _e.update) || "Save"
|
|
408
449
|
}
|
|
409
450
|
}
|
|
410
451
|
),
|
|
@@ -415,7 +456,7 @@ const FormOrganizationConnection = ({
|
|
|
415
456
|
loading: consenting,
|
|
416
457
|
onClick: consent
|
|
417
458
|
},
|
|
418
|
-
children: ((
|
|
459
|
+
children: ((_f = values == null ? void 0 : values.actions) == null ? void 0 : _f.create) || "Connect"
|
|
419
460
|
}
|
|
420
461
|
)
|
|
421
462
|
]
|
|
@@ -524,13 +565,13 @@ const FormOrganizationConnection = ({
|
|
|
524
565
|
},
|
|
525
566
|
field.key
|
|
526
567
|
)),
|
|
527
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
568
|
+
(0, import_connection_controls.savable)({ actions: values == null ? void 0 : values.actions, connected, inputs }) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
528
569
|
Submit,
|
|
529
570
|
{
|
|
530
571
|
...{
|
|
531
572
|
disabled,
|
|
532
573
|
isSubmitting: formState == null ? void 0 : formState.isSubmitting,
|
|
533
|
-
text: connected ? ((
|
|
574
|
+
text: connected ? ((_g = values == null ? void 0 : values.actions) == null ? void 0 : _g.update) || "Submit" : ((_h = values == null ? void 0 : values.actions) == null ? void 0 : _h.create) || "Submit"
|
|
534
575
|
}
|
|
535
576
|
}
|
|
536
577
|
)
|
|
@@ -542,5 +583,6 @@ const FormOrganizationConnection = ({
|
|
|
542
583
|
};
|
|
543
584
|
// Annotate the CommonJS export names for ESM import in node:
|
|
544
585
|
0 && (module.exports = {
|
|
586
|
+
Editable,
|
|
545
587
|
FormOrganizationConnection
|
|
546
588
|
});
|
|
@@ -17,7 +17,7 @@ import InputCheckbox from "../input-checkbox.mjs";
|
|
|
17
17
|
import InputSwitch from "../shared/input-switch.mjs";
|
|
18
18
|
import Button from "../shared/button.mjs";
|
|
19
19
|
import CopyToClipboard from "../shared/copy-to-clipboard.mjs";
|
|
20
|
-
import { isConnected } from "./lib/connection-controls.mjs";
|
|
20
|
+
import { isConnected, savable } from "./lib/connection-controls.mjs";
|
|
21
21
|
const Submit = ({
|
|
22
22
|
disabled,
|
|
23
23
|
isSubmitting,
|
|
@@ -195,10 +195,11 @@ const FormOrganizationConnection = ({
|
|
|
195
195
|
onSuccess,
|
|
196
196
|
values
|
|
197
197
|
}) => {
|
|
198
|
-
var _a, _b, _c, _d, _e, _f;
|
|
198
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
199
199
|
const fields = (values == null ? void 0 : values.fields) || [];
|
|
200
200
|
const kind = (_a = values == null ? void 0 : values.connect) == null ? void 0 : _a.type;
|
|
201
|
-
const
|
|
201
|
+
const link = Boolean((_b = values == null ? void 0 : values.connect) == null ? void 0 : _b.link);
|
|
202
|
+
const redirect = kind === "install" ? (_c = values == null ? void 0 : values.connect) == null ? void 0 : _c.redirect : null;
|
|
202
203
|
const readable = fields.filter((field) => !field.input).map((field) => {
|
|
203
204
|
var _a2;
|
|
204
205
|
return {
|
|
@@ -211,6 +212,17 @@ const FormOrganizationConnection = ({
|
|
|
211
212
|
const consent = async () => {
|
|
212
213
|
setConsenting(true);
|
|
213
214
|
try {
|
|
215
|
+
if (link) {
|
|
216
|
+
await request({
|
|
217
|
+
body: {
|
|
218
|
+
settings: {},
|
|
219
|
+
slug: values == null ? void 0 : values.slug
|
|
220
|
+
},
|
|
221
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection",
|
|
222
|
+
method: "POST"
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
;
|
|
214
226
|
const { result } = await request({
|
|
215
227
|
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection/" + (values == null ? void 0 : values.slug) + "/authorize",
|
|
216
228
|
method: "POST"
|
|
@@ -303,6 +315,34 @@ const FormOrganizationConnection = ({
|
|
|
303
315
|
}
|
|
304
316
|
) : null;
|
|
305
317
|
}
|
|
318
|
+
if (link) {
|
|
319
|
+
return (values == null ? void 0 : values.status) === "active" ? null : /* @__PURE__ */ jsx(
|
|
320
|
+
Form,
|
|
321
|
+
{
|
|
322
|
+
...{
|
|
323
|
+
className: "relative w-full space-y-8"
|
|
324
|
+
},
|
|
325
|
+
children: /* @__PURE__ */ jsx(
|
|
326
|
+
Fieldset,
|
|
327
|
+
{
|
|
328
|
+
...{
|
|
329
|
+
disabled: disabled || consenting
|
|
330
|
+
},
|
|
331
|
+
children: /* @__PURE__ */ jsx(
|
|
332
|
+
Button,
|
|
333
|
+
{
|
|
334
|
+
...{
|
|
335
|
+
loading: consenting,
|
|
336
|
+
onClick: consent
|
|
337
|
+
},
|
|
338
|
+
children: ((_d = values == null ? void 0 : values.actions) == null ? void 0 : _d.create) || "Connect"
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
}
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
}
|
|
306
346
|
if (kind === "oauth") {
|
|
307
347
|
return /* @__PURE__ */ jsx(
|
|
308
348
|
Form,
|
|
@@ -372,7 +412,7 @@ const FormOrganizationConnection = ({
|
|
|
372
412
|
// the connection would read Active over nothing.
|
|
373
413
|
disabled: disabled || Object.values(optionsFor).some((entry) => entry == null ? void 0 : entry.isLoading),
|
|
374
414
|
isSubmitting: formState == null ? void 0 : formState.isSubmitting,
|
|
375
|
-
text: ((
|
|
415
|
+
text: ((_e = values == null ? void 0 : values.actions) == null ? void 0 : _e.update) || "Save"
|
|
376
416
|
}
|
|
377
417
|
}
|
|
378
418
|
),
|
|
@@ -383,7 +423,7 @@ const FormOrganizationConnection = ({
|
|
|
383
423
|
loading: consenting,
|
|
384
424
|
onClick: consent
|
|
385
425
|
},
|
|
386
|
-
children: ((
|
|
426
|
+
children: ((_f = values == null ? void 0 : values.actions) == null ? void 0 : _f.create) || "Connect"
|
|
387
427
|
}
|
|
388
428
|
)
|
|
389
429
|
]
|
|
@@ -492,13 +532,13 @@ const FormOrganizationConnection = ({
|
|
|
492
532
|
},
|
|
493
533
|
field.key
|
|
494
534
|
)),
|
|
495
|
-
/* @__PURE__ */ jsx(
|
|
535
|
+
savable({ actions: values == null ? void 0 : values.actions, connected, inputs }) && /* @__PURE__ */ jsx(
|
|
496
536
|
Submit,
|
|
497
537
|
{
|
|
498
538
|
...{
|
|
499
539
|
disabled,
|
|
500
540
|
isSubmitting: formState == null ? void 0 : formState.isSubmitting,
|
|
501
|
-
text: connected ? ((
|
|
541
|
+
text: connected ? ((_g = values == null ? void 0 : values.actions) == null ? void 0 : _g.update) || "Submit" : ((_h = values == null ? void 0 : values.actions) == null ? void 0 : _h.create) || "Submit"
|
|
502
542
|
}
|
|
503
543
|
}
|
|
504
544
|
)
|
|
@@ -509,5 +549,6 @@ const FormOrganizationConnection = ({
|
|
|
509
549
|
);
|
|
510
550
|
};
|
|
511
551
|
export {
|
|
552
|
+
Editable,
|
|
512
553
|
FormOrganizationConnection
|
|
513
554
|
};
|