@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,164 +0,0 @@
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
- };
@@ -1,246 +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_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;
@@ -1,217 +0,0 @@
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
- };