@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.
Files changed (114) hide show
  1. package/dist/bridge/cart-drawer.js +152 -0
  2. package/dist/bridge/cart-drawer.mjs +123 -0
  3. package/dist/bridge/fields.js +278 -0
  4. package/dist/bridge/fields.mjs +276 -1
  5. package/dist/bridge/form-subdomain-checkout.js +687 -0
  6. package/dist/bridge/form-subdomain-checkout.mjs +665 -0
  7. package/dist/bridge/form-subdomain-shop-modal.js +234 -274
  8. package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
  9. package/dist/bridge/form-subdomain.js +1 -0
  10. package/dist/bridge/form-subdomain.mjs +2 -1
  11. package/dist/bridge/lib/age-gate.js +12 -0
  12. package/dist/bridge/lib/age-gate.mjs +11 -0
  13. package/dist/bridge/lib/cart.js +79 -0
  14. package/dist/bridge/lib/cart.mjs +48 -0
  15. package/dist/bridge/lib/checkout-kit.js +2 -32
  16. package/dist/bridge/lib/checkout-kit.mjs +2 -32
  17. package/dist/bridge/product-tile.js +9 -6
  18. package/dist/bridge/product-tile.mjs +9 -6
  19. package/dist/bridge/template-layout.js +237 -122
  20. package/dist/bridge/template-layout.mjs +237 -122
  21. package/dist/bridge/template-modal.js +28 -73
  22. package/dist/bridge/template-modal.mjs +29 -74
  23. package/dist/dashboard/buttons-subscription.js +1 -1
  24. package/dist/dashboard/buttons-subscription.mjs +1 -1
  25. package/dist/dashboard/campaign-form.js +7 -2
  26. package/dist/dashboard/campaign-form.mjs +7 -2
  27. package/dist/dashboard/card-order.js +22 -4
  28. package/dist/dashboard/card-order.mjs +22 -4
  29. package/dist/dashboard/embed-stripe.js +145 -0
  30. package/dist/dashboard/embed-stripe.mjs +116 -0
  31. package/dist/dashboard/form-admin-provider.js +71 -17
  32. package/dist/dashboard/form-admin-provider.mjs +71 -17
  33. package/dist/dashboard/form-file-upload.js +3 -2
  34. package/dist/dashboard/form-file-upload.mjs +4 -3
  35. package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
  36. package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
  37. package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
  38. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
  39. package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
  40. package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
  41. package/dist/dashboard/form-organization-campaign.js +82 -0
  42. package/dist/dashboard/form-organization-campaign.mjs +81 -0
  43. package/dist/dashboard/form-organization-connection.js +48 -6
  44. package/dist/dashboard/form-organization-connection.mjs +48 -7
  45. package/dist/dashboard/form-organization-product.js +1461 -0
  46. package/dist/dashboard/form-organization-product.mjs +1425 -0
  47. package/dist/dashboard/form-organization-workflow.js +72 -1
  48. package/dist/dashboard/form-organization-workflow.mjs +69 -1
  49. package/dist/dashboard/form-otc.js +4 -5
  50. package/dist/dashboard/form-otc.mjs +4 -5
  51. package/dist/dashboard/form-stripe.js +12 -5
  52. package/dist/dashboard/form-stripe.mjs +12 -5
  53. package/dist/dashboard/input-fields.js +11 -158
  54. package/dist/dashboard/input-fields.mjs +11 -158
  55. package/dist/dashboard/input-file.js +21 -4
  56. package/dist/dashboard/input-file.mjs +21 -4
  57. package/dist/dashboard/input-gallery.js +201 -0
  58. package/dist/dashboard/input-gallery.mjs +172 -0
  59. package/dist/dashboard/lib/connection-controls.js +5 -2
  60. package/dist/dashboard/lib/connection-controls.mjs +3 -1
  61. package/dist/dashboard/lib/form-page.js +1 -1
  62. package/dist/dashboard/lib/form-page.mjs +1 -1
  63. package/dist/dashboard/lib/products.js +169 -0
  64. package/dist/dashboard/lib/products.mjs +135 -0
  65. package/dist/dashboard/lib/settings-paths.js +35 -0
  66. package/dist/dashboard/lib/settings-paths.mjs +11 -0
  67. package/dist/dashboard/lib/uppy.js +10 -1
  68. package/dist/dashboard/lib/uppy.mjs +11 -2
  69. package/dist/dashboard/order-sections.js +456 -6
  70. package/dist/dashboard/order-sections.mjs +453 -7
  71. package/dist/dashboard/provider-ui.js +9 -7
  72. package/dist/dashboard/provider-ui.mjs +9 -7
  73. package/dist/dashboard/shipping-rates.js +404 -0
  74. package/dist/dashboard/shipping-rates.mjs +371 -0
  75. package/dist/dashboard/template-buyer.js +301 -0
  76. package/dist/dashboard/template-buyer.mjs +267 -0
  77. package/dist/input-checkbox.js +28 -10
  78. package/dist/input-checkbox.mjs +28 -10
  79. package/dist/product.js +96 -24
  80. package/dist/product.mjs +97 -25
  81. package/dist/shared/lib/helpers.js +54 -6
  82. package/dist/shared/lib/helpers.mjs +53 -8
  83. package/dist/shared/order-summary.js +139 -0
  84. package/dist/shared/order-summary.mjs +110 -0
  85. package/package.json +74 -4
  86. package/types/bridge/cart-drawer.d.ts +31 -0
  87. package/types/bridge/fields.d.ts +14 -2
  88. package/types/bridge/form-subdomain-checkout.d.ts +20 -0
  89. package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
  90. package/types/bridge/lib/age-gate.d.ts +5 -0
  91. package/types/bridge/lib/cart.d.ts +44 -0
  92. package/types/bridge/lib/checkout-kit.d.ts +2 -10
  93. package/types/dashboard/card-order.d.ts +6 -0
  94. package/types/dashboard/embed-stripe.d.ts +25 -0
  95. package/types/dashboard/form-admin-provider.d.ts +9 -2
  96. package/types/dashboard/form-file-upload.d.ts +2 -1
  97. package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
  98. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
  99. package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
  100. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  101. package/types/dashboard/form-organization-connection.d.ts +11 -0
  102. package/types/dashboard/form-organization-product.d.ts +24 -0
  103. package/types/dashboard/form-otc.d.ts +5 -1
  104. package/types/dashboard/form-stripe.d.ts +3 -2
  105. package/types/dashboard/input-file.d.ts +2 -0
  106. package/types/dashboard/input-gallery.d.ts +14 -0
  107. package/types/dashboard/lib/products.d.ts +14 -0
  108. package/types/dashboard/lib/settings-paths.d.ts +5 -0
  109. package/types/dashboard/order-sections.d.ts +24 -1
  110. package/types/dashboard/shipping-rates.d.ts +26 -0
  111. package/types/dashboard/template-buyer.d.ts +50 -0
  112. package/types/input-checkbox.d.ts +2 -0
  113. package/types/shared/lib/helpers.d.ts +4 -0
  114. package/types/shared/order-summary.d.ts +19 -0
@@ -0,0 +1,193 @@
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;
@@ -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;