@drawbridge/components 0.1.46 → 0.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/cart-drawer.js +152 -0
- package/dist/bridge/cart-drawer.mjs +123 -0
- package/dist/bridge/fields.js +278 -0
- package/dist/bridge/fields.mjs +276 -1
- package/dist/bridge/form-subdomain-checkout.js +687 -0
- package/dist/bridge/form-subdomain-checkout.mjs +665 -0
- package/dist/bridge/form-subdomain-shop-modal.js +234 -274
- package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
- package/dist/bridge/form-subdomain-shop.js +4 -1
- package/dist/bridge/form-subdomain-shop.mjs +4 -1
- package/dist/bridge/form-subdomain.js +24 -5
- package/dist/bridge/form-subdomain.mjs +25 -6
- package/dist/bridge/lib/age-gate.js +12 -0
- package/dist/bridge/lib/age-gate.mjs +11 -0
- package/dist/bridge/lib/cart.js +79 -0
- package/dist/bridge/lib/cart.mjs +48 -0
- package/dist/bridge/lib/checkout-kit.js +2 -32
- package/dist/bridge/lib/checkout-kit.mjs +2 -32
- package/dist/bridge/lib/entry.js +41 -0
- package/dist/bridge/lib/entry.mjs +40 -0
- package/dist/bridge/product-tile.js +13 -6
- package/dist/bridge/product-tile.mjs +13 -6
- package/dist/bridge/template-layout.js +263 -129
- package/dist/bridge/template-layout.mjs +264 -130
- package/dist/bridge/template-modal.js +39 -74
- package/dist/bridge/template-modal.mjs +40 -75
- package/dist/dashboard/avatar.js +2 -3
- package/dist/dashboard/avatar.mjs +2 -3
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +179 -155
- package/dist/dashboard/campaign-form.mjs +179 -155
- package/dist/dashboard/campaign-share.js +347 -0
- package/dist/dashboard/campaign-share.mjs +314 -0
- package/dist/dashboard/card-affiliate.js +1 -1
- package/dist/dashboard/card-affiliate.mjs +1 -1
- package/dist/dashboard/card-campaign-switch.js +4 -1
- package/dist/dashboard/card-campaign-switch.mjs +4 -1
- package/dist/dashboard/card-order.js +22 -4
- package/dist/dashboard/card-order.mjs +22 -4
- package/dist/dashboard/embed-stripe.js +145 -0
- package/dist/dashboard/embed-stripe.mjs +116 -0
- package/dist/dashboard/form-admin-provider.js +71 -17
- package/dist/dashboard/form-admin-provider.mjs +71 -17
- package/dist/dashboard/form-file-upload.js +3 -2
- package/dist/dashboard/form-file-upload.mjs +4 -3
- package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
- package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
- package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
- package/dist/dashboard/form-organization-campaign-page.js +73 -39
- package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
- package/dist/dashboard/form-organization-campaign.js +82 -0
- package/dist/dashboard/form-organization-campaign.mjs +81 -0
- package/dist/dashboard/form-organization-connection.js +48 -6
- package/dist/dashboard/form-organization-connection.mjs +48 -7
- package/dist/dashboard/form-organization-product.js +1461 -0
- package/dist/dashboard/form-organization-product.mjs +1425 -0
- package/dist/dashboard/form-organization-workflow.js +72 -1
- package/dist/dashboard/form-organization-workflow.mjs +69 -1
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-stripe.js +12 -5
- package/dist/dashboard/form-stripe.mjs +12 -5
- package/dist/dashboard/input-combobox.js +6 -0
- package/dist/dashboard/input-combobox.mjs +6 -0
- package/dist/dashboard/input-fields.js +37 -161
- package/dist/dashboard/input-fields.mjs +37 -161
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-font.js +2 -0
- package/dist/dashboard/input-font.mjs +2 -0
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- package/dist/dashboard/input-group-ai.js +15 -3
- package/dist/dashboard/input-group-ai.mjs +15 -3
- package/dist/dashboard/lib/ab-tests.js +2 -2
- package/dist/dashboard/lib/ab-tests.mjs +2 -2
- package/dist/dashboard/lib/connection-controls.js +5 -2
- package/dist/dashboard/lib/connection-controls.mjs +3 -1
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/menu.js +19 -0
- package/dist/dashboard/lib/menu.mjs +18 -0
- package/dist/dashboard/lib/products.js +169 -0
- package/dist/dashboard/lib/products.mjs +135 -0
- package/dist/dashboard/lib/settings-paths.js +35 -0
- package/dist/dashboard/lib/settings-paths.mjs +11 -0
- package/dist/dashboard/lib/uppy.js +10 -1
- package/dist/dashboard/lib/uppy.mjs +11 -2
- package/dist/dashboard/menu.js +13 -2
- package/dist/dashboard/menu.mjs +13 -2
- package/dist/dashboard/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/preview.js +119 -52
- package/dist/dashboard/preview.mjs +119 -52
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- package/dist/dashboard/recharts.js +10 -4
- package/dist/dashboard/recharts.mjs +10 -4
- package/dist/dashboard/shipping-rates.js +404 -0
- package/dist/dashboard/shipping-rates.mjs +371 -0
- package/dist/dashboard/template-buyer.js +301 -0
- package/dist/dashboard/template-buyer.mjs +267 -0
- package/dist/dashboard/template-dashboard.js +11 -1
- package/dist/dashboard/template-dashboard.mjs +11 -1
- package/dist/dashboard/template-design.js +209 -130
- package/dist/dashboard/template-design.mjs +210 -131
- package/dist/dashboard/template-ui.js +157 -55
- package/dist/dashboard/template-ui.mjs +158 -56
- package/dist/icons/flags.js +134 -0
- package/dist/icons/flags.mjs +115 -0
- package/dist/input-checkbox.js +28 -10
- package/dist/input-checkbox.mjs +28 -10
- package/dist/product.js +96 -24
- package/dist/product.mjs +97 -25
- package/dist/shared/carousel.js +14 -5
- package/dist/shared/carousel.mjs +14 -5
- package/dist/shared/lib/helpers.js +54 -6
- package/dist/shared/lib/helpers.mjs +53 -8
- package/dist/shared/order-summary.js +139 -0
- package/dist/shared/order-summary.mjs +110 -0
- package/package.json +84 -4
- package/types/bridge/cart-drawer.d.ts +31 -0
- package/types/bridge/fields.d.ts +14 -2
- package/types/bridge/form-subdomain-checkout.d.ts +20 -0
- package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
- package/types/bridge/form-subdomain.d.ts +13 -0
- package/types/bridge/lib/age-gate.d.ts +5 -0
- package/types/bridge/lib/cart.d.ts +44 -0
- package/types/bridge/lib/checkout-kit.d.ts +2 -10
- package/types/bridge/lib/entry.d.ts +5 -0
- package/types/bridge/product-tile.d.ts +2 -0
- package/types/dashboard/campaign-share.d.ts +16 -0
- package/types/dashboard/card-order.d.ts +6 -0
- package/types/dashboard/embed-stripe.d.ts +25 -0
- package/types/dashboard/form-admin-provider.d.ts +9 -2
- package/types/dashboard/form-file-upload.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
- package/types/dashboard/form-organization-campaign-page.d.ts +8 -1
- package/types/dashboard/form-organization-campaign.d.ts +3 -0
- package/types/dashboard/form-organization-connection.d.ts +11 -0
- package/types/dashboard/form-organization-product.d.ts +24 -0
- package/types/dashboard/form-otc.d.ts +5 -1
- package/types/dashboard/form-stripe.d.ts +3 -2
- package/types/dashboard/input-combobox.d.ts +2 -0
- package/types/dashboard/input-file.d.ts +2 -0
- package/types/dashboard/input-gallery.d.ts +14 -0
- package/types/dashboard/lib/products.d.ts +14 -0
- package/types/dashboard/lib/settings-paths.d.ts +5 -0
- package/types/dashboard/order-sections.d.ts +24 -1
- package/types/dashboard/preview.d.ts +11 -3
- package/types/dashboard/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -0
- package/types/icons/flags.d.ts +5 -0
- package/types/input-checkbox.d.ts +2 -0
- package/types/shared/lib/helpers.d.ts +4 -0
- package/types/shared/order-summary.d.ts +19 -0
|
@@ -0,0 +1,164 @@
|
|
|
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 InputSwitch from "../shared/input-switch.mjs";
|
|
10
|
+
import Button from "../shared/button.mjs";
|
|
11
|
+
const FormOrganizationCampaignFieldBirthday = ({
|
|
12
|
+
disabled,
|
|
13
|
+
onError,
|
|
14
|
+
onSuccess,
|
|
15
|
+
values
|
|
16
|
+
}) => {
|
|
17
|
+
var _a;
|
|
18
|
+
const inputs = (values == null ? void 0 : values.inputs) || [];
|
|
19
|
+
const { control, formState, handleSubmit } = useForm({
|
|
20
|
+
resolver: resolver(
|
|
21
|
+
yup.object({
|
|
22
|
+
label: yup.string().label("Label").required().max(150)
|
|
23
|
+
})
|
|
24
|
+
),
|
|
25
|
+
values: {
|
|
26
|
+
...values,
|
|
27
|
+
attributes: {
|
|
28
|
+
required: ((_a = values == null ? void 0 : values.attributes) == null ? void 0 : _a.required) !== false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const onSubmit = async ({
|
|
33
|
+
attributes = {},
|
|
34
|
+
label,
|
|
35
|
+
section
|
|
36
|
+
}) => {
|
|
37
|
+
try {
|
|
38
|
+
const args = {
|
|
39
|
+
body: {
|
|
40
|
+
attributes: {
|
|
41
|
+
required: (attributes == null ? void 0 : attributes.required) !== false
|
|
42
|
+
},
|
|
43
|
+
label,
|
|
44
|
+
...section && {
|
|
45
|
+
section
|
|
46
|
+
},
|
|
47
|
+
slug: values == null ? void 0 : values.slug,
|
|
48
|
+
type: values == null ? void 0 : values.type
|
|
49
|
+
},
|
|
50
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/field",
|
|
51
|
+
method: "POST"
|
|
52
|
+
};
|
|
53
|
+
if (values == null ? void 0 : values.id) {
|
|
54
|
+
args.endpoint = args.endpoint + "/" + values.id;
|
|
55
|
+
args.method = "PUT";
|
|
56
|
+
}
|
|
57
|
+
const response = await request(args);
|
|
58
|
+
onSuccess(response);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
onError(error);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ jsxs(
|
|
64
|
+
Form,
|
|
65
|
+
{
|
|
66
|
+
...{
|
|
67
|
+
className: "relative w-full space-y-6",
|
|
68
|
+
onSubmit: handleSubmit(onSubmit)
|
|
69
|
+
},
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsxs(
|
|
72
|
+
Fieldset,
|
|
73
|
+
{
|
|
74
|
+
...{
|
|
75
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
76
|
+
},
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
Controller,
|
|
80
|
+
{
|
|
81
|
+
...{
|
|
82
|
+
control,
|
|
83
|
+
name: "label",
|
|
84
|
+
render: ({ field: { value, onChange } }) => {
|
|
85
|
+
var _a2, _b;
|
|
86
|
+
return /* @__PURE__ */ jsx(
|
|
87
|
+
InputGroup,
|
|
88
|
+
{
|
|
89
|
+
...{
|
|
90
|
+
error: (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.label) == null ? void 0 : _b.message,
|
|
91
|
+
input: /* @__PURE__ */ jsx(
|
|
92
|
+
InputText,
|
|
93
|
+
{
|
|
94
|
+
...{
|
|
95
|
+
disabled: !inputs.includes("label"),
|
|
96
|
+
onChange,
|
|
97
|
+
value: value || ""
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
label: "Field label"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
Controller,
|
|
111
|
+
{
|
|
112
|
+
...{
|
|
113
|
+
control,
|
|
114
|
+
name: "attributes.required",
|
|
115
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ jsx(
|
|
116
|
+
InputGroup,
|
|
117
|
+
{
|
|
118
|
+
...{
|
|
119
|
+
input: /* @__PURE__ */ jsx(
|
|
120
|
+
InputSwitch,
|
|
121
|
+
{
|
|
122
|
+
...{
|
|
123
|
+
disabled: !inputs.includes("attributes"),
|
|
124
|
+
onChange,
|
|
125
|
+
value: value !== false
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
label: "Required"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ jsx(
|
|
140
|
+
Fieldset,
|
|
141
|
+
{
|
|
142
|
+
...{
|
|
143
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
144
|
+
},
|
|
145
|
+
children: /* @__PURE__ */ jsx(
|
|
146
|
+
Button,
|
|
147
|
+
{
|
|
148
|
+
...{
|
|
149
|
+
loading: formState == null ? void 0 : formState.isSubmitting,
|
|
150
|
+
type: "submit"
|
|
151
|
+
},
|
|
152
|
+
children: "Submit"
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
var form_organization_campaign_field_birthday_default = FormOrganizationCampaignFieldBirthday;
|
|
162
|
+
export {
|
|
163
|
+
form_organization_campaign_field_birthday_default as default
|
|
164
|
+
};
|
|
@@ -0,0 +1,246 @@
|
|
|
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_rating_exports = {};
|
|
29
|
+
__export(form_organization_campaign_field_rating_exports, {
|
|
30
|
+
default: () => form_organization_campaign_field_rating_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(form_organization_campaign_field_rating_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_number = __toESM(require("../input-number"));
|
|
42
|
+
var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
43
|
+
var import_button = __toESM(require("../shared/button"));
|
|
44
|
+
const FormOrganizationCampaignFieldRating = ({
|
|
45
|
+
disabled,
|
|
46
|
+
onError,
|
|
47
|
+
onSuccess,
|
|
48
|
+
values
|
|
49
|
+
}) => {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
51
|
+
const inputs = (values == null ? void 0 : values.inputs) || [];
|
|
52
|
+
const { control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
53
|
+
resolver: (0, import_yup.resolver)(
|
|
54
|
+
import_yup.default.object({
|
|
55
|
+
attributes: import_yup.default.object({
|
|
56
|
+
max: import_yup.default.number().label("Scale").transform((value, original) => original === "" ? void 0 : value).required().integer().min(3).max(10)
|
|
57
|
+
}),
|
|
58
|
+
label: import_yup.default.string().label("Label").required().max(150),
|
|
59
|
+
settings: import_yup.default.object({
|
|
60
|
+
high: import_yup.default.string().label("High label").max(50),
|
|
61
|
+
low: import_yup.default.string().label("Low label").max(50)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
),
|
|
65
|
+
values: {
|
|
66
|
+
...values,
|
|
67
|
+
attributes: {
|
|
68
|
+
max: ((_a = values == null ? void 0 : values.attributes) == null ? void 0 : _a.max) ?? 5,
|
|
69
|
+
required: ((_b = values == null ? void 0 : values.attributes) == null ? void 0 : _b.required) !== false
|
|
70
|
+
},
|
|
71
|
+
settings: {
|
|
72
|
+
high: ((_c = values == null ? void 0 : values.settings) == null ? void 0 : _c.high) || "",
|
|
73
|
+
low: ((_d = values == null ? void 0 : values.settings) == null ? void 0 : _d.low) || ""
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const onSubmit = async ({
|
|
78
|
+
attributes = {},
|
|
79
|
+
label,
|
|
80
|
+
section,
|
|
81
|
+
settings = {}
|
|
82
|
+
}) => {
|
|
83
|
+
try {
|
|
84
|
+
const args = {
|
|
85
|
+
body: {
|
|
86
|
+
attributes: {
|
|
87
|
+
max: Number(attributes == null ? void 0 : attributes.max),
|
|
88
|
+
required: (attributes == null ? void 0 : attributes.required) !== false
|
|
89
|
+
},
|
|
90
|
+
label,
|
|
91
|
+
...section && {
|
|
92
|
+
section
|
|
93
|
+
},
|
|
94
|
+
// A blank end label is no label.
|
|
95
|
+
settings: {
|
|
96
|
+
high: (settings == null ? void 0 : settings.high) || null,
|
|
97
|
+
low: (settings == null ? void 0 : settings.low) || null
|
|
98
|
+
},
|
|
99
|
+
slug: values == null ? void 0 : values.slug,
|
|
100
|
+
type: values == null ? void 0 : values.type
|
|
101
|
+
},
|
|
102
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/field",
|
|
103
|
+
method: "POST"
|
|
104
|
+
};
|
|
105
|
+
if (values == null ? void 0 : values.id) {
|
|
106
|
+
args.endpoint = args.endpoint + "/" + values.id;
|
|
107
|
+
args.method = "PUT";
|
|
108
|
+
}
|
|
109
|
+
const response = await (0, import_fetch.request)(args);
|
|
110
|
+
onSuccess(response);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
onError(error);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const text = (name, label, error) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
+
import_form.Controller,
|
|
117
|
+
{
|
|
118
|
+
...{
|
|
119
|
+
control,
|
|
120
|
+
name,
|
|
121
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
|
+
import_input_group.default,
|
|
123
|
+
{
|
|
124
|
+
...{
|
|
125
|
+
error,
|
|
126
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
+
import_input_text.default,
|
|
128
|
+
{
|
|
129
|
+
...{
|
|
130
|
+
disabled: !inputs.includes(name.split(".")[0]),
|
|
131
|
+
onChange,
|
|
132
|
+
value: value || ""
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
label
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
144
|
+
import_form2.default,
|
|
145
|
+
{
|
|
146
|
+
...{
|
|
147
|
+
className: "relative w-full space-y-6",
|
|
148
|
+
onSubmit: handleSubmit(onSubmit)
|
|
149
|
+
},
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
152
|
+
import_fieldset.default,
|
|
153
|
+
{
|
|
154
|
+
...{
|
|
155
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
156
|
+
},
|
|
157
|
+
children: [
|
|
158
|
+
text("label", "Field label", (_f = (_e = formState == null ? void 0 : formState.errors) == null ? void 0 : _e.label) == null ? void 0 : _f.message),
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
160
|
+
import_form.Controller,
|
|
161
|
+
{
|
|
162
|
+
...{
|
|
163
|
+
control,
|
|
164
|
+
name: "attributes.max",
|
|
165
|
+
render: ({ field: { value, onChange } }) => {
|
|
166
|
+
var _a2, _b2, _c2;
|
|
167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
|
+
import_input_group.default,
|
|
169
|
+
{
|
|
170
|
+
...{
|
|
171
|
+
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,
|
|
172
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
173
|
+
import_input_number.default,
|
|
174
|
+
{
|
|
175
|
+
...{
|
|
176
|
+
disabled: !inputs.includes("attributes"),
|
|
177
|
+
max: 10,
|
|
178
|
+
min: 3,
|
|
179
|
+
onChange,
|
|
180
|
+
value: value ?? ""
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
label: "Scale"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
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),
|
|
193
|
+
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),
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
195
|
+
import_form.Controller,
|
|
196
|
+
{
|
|
197
|
+
...{
|
|
198
|
+
control,
|
|
199
|
+
name: "attributes.required",
|
|
200
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
201
|
+
import_input_group.default,
|
|
202
|
+
{
|
|
203
|
+
...{
|
|
204
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
205
|
+
import_input_switch.default,
|
|
206
|
+
{
|
|
207
|
+
...{
|
|
208
|
+
disabled: !inputs.includes("attributes"),
|
|
209
|
+
onChange,
|
|
210
|
+
value: value !== false
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
label: "Required"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
225
|
+
import_fieldset.default,
|
|
226
|
+
{
|
|
227
|
+
...{
|
|
228
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
229
|
+
},
|
|
230
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
231
|
+
import_button.default,
|
|
232
|
+
{
|
|
233
|
+
...{
|
|
234
|
+
loading: formState == null ? void 0 : formState.isSubmitting,
|
|
235
|
+
type: "submit"
|
|
236
|
+
},
|
|
237
|
+
children: "Submit"
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
var form_organization_campaign_field_rating_default = FormOrganizationCampaignFieldRating;
|
|
@@ -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
|
+
};
|