@drawbridge/components 0.1.13 → 0.1.14

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 (236) hide show
  1. package/components/styles.css +364 -2
  2. package/dist/advertisement.js +3 -1
  3. package/dist/advertisement.mjs +3 -1
  4. package/dist/bridge/advertisements.js +2 -0
  5. package/dist/bridge/advertisements.mjs +2 -0
  6. package/dist/bridge/countdown.js +2 -1
  7. package/dist/bridge/countdown.mjs +2 -1
  8. package/dist/bridge/form-subdomain-embed.js +18 -20
  9. package/dist/bridge/form-subdomain-embed.mjs +18 -20
  10. package/dist/bridge/form-subdomain-header.js +24 -1
  11. package/dist/bridge/form-subdomain-header.mjs +24 -1
  12. package/dist/bridge/form-subdomain-missions.js +538 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +502 -0
  14. package/dist/bridge/form-subdomain.js +530 -220
  15. package/dist/bridge/form-subdomain.mjs +533 -222
  16. package/dist/bridge/lib/entry.js +59 -0
  17. package/dist/bridge/lib/entry.mjs +29 -0
  18. package/dist/bridge/lib/location.js +38 -0
  19. package/dist/bridge/lib/location.mjs +13 -0
  20. package/dist/bridge/lib/order.js +71 -0
  21. package/dist/bridge/lib/order.mjs +44 -0
  22. package/dist/bridge/lib/url.js +9 -0
  23. package/dist/bridge/lib/url.mjs +7 -0
  24. package/dist/bridge/share-button.js +5 -3
  25. package/dist/bridge/share-button.mjs +5 -3
  26. package/dist/bridge/subdomain-content.js +7 -6
  27. package/dist/bridge/subdomain-content.mjs +7 -6
  28. package/dist/bridge/template-layout.js +59 -21
  29. package/dist/bridge/template-layout.mjs +59 -21
  30. package/dist/bridge/template-modal.js +42 -76
  31. package/dist/bridge/template-modal.mjs +39 -73
  32. package/dist/bridge/template-preview.js +208 -0
  33. package/dist/bridge/template-preview.mjs +173 -0
  34. package/dist/bridge/template-subdomain-gallery.js +6 -2
  35. package/dist/bridge/template-subdomain-gallery.mjs +6 -2
  36. package/dist/bridge/template-subdomain-link.js +6 -1
  37. package/dist/bridge/template-subdomain-link.mjs +6 -1
  38. package/dist/bridge/template-subdomain.js +20 -15
  39. package/dist/bridge/template-subdomain.mjs +20 -15
  40. package/dist/dashboard/accordion.js +74 -39
  41. package/dist/dashboard/accordion.mjs +74 -39
  42. package/dist/dashboard/avatar.js +109 -3
  43. package/dist/dashboard/avatar.mjs +106 -4
  44. package/dist/dashboard/buttons-subscription.js +384 -0
  45. package/dist/dashboard/buttons-subscription.mjs +349 -0
  46. package/dist/dashboard/card-campaign-switch.js +265 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +231 -0
  48. package/dist/dashboard/card-order.js +28 -11
  49. package/dist/dashboard/card-order.mjs +28 -11
  50. package/dist/dashboard/card-section.js +26 -2
  51. package/dist/dashboard/card-section.mjs +26 -2
  52. package/dist/dashboard/card-tile.js +6 -7
  53. package/dist/dashboard/card-tile.mjs +6 -7
  54. package/dist/dashboard/connection-workflows.js +196 -0
  55. package/dist/dashboard/connection-workflows.mjs +162 -0
  56. package/dist/dashboard/device.js +95 -0
  57. package/dist/dashboard/device.mjs +72 -0
  58. package/dist/dashboard/form-admin-campaign.js +19 -50
  59. package/dist/dashboard/form-admin-campaign.mjs +20 -51
  60. package/dist/dashboard/form-ai.js +9 -6
  61. package/dist/dashboard/form-ai.mjs +9 -6
  62. package/dist/dashboard/form-auth.js +35 -25
  63. package/dist/dashboard/form-auth.mjs +36 -26
  64. package/dist/dashboard/form-file.js +10 -1
  65. package/dist/dashboard/form-file.mjs +10 -1
  66. package/dist/dashboard/form-filters-analytics.js +14 -1
  67. package/dist/dashboard/form-filters-analytics.mjs +15 -2
  68. package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
  69. package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
  70. package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
  72. package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
  73. package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
  74. package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
  75. package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
  76. package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
  77. package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
  78. package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
  79. package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
  80. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  81. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  82. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  83. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  84. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  87. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  88. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  89. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  90. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  91. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  94. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  95. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  96. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  97. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-section.js +223 -0
  99. package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
  100. package/dist/dashboard/form-organization-campaign.js +114 -469
  101. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  102. package/dist/dashboard/form-organization-export.js +4 -7
  103. package/dist/dashboard/form-organization-export.mjs +4 -7
  104. package/dist/dashboard/form-organization-identity.js +46 -51
  105. package/dist/dashboard/form-organization-identity.mjs +46 -51
  106. package/dist/dashboard/form-organization-workflow.js +518 -686
  107. package/dist/dashboard/form-organization-workflow.mjs +517 -682
  108. package/dist/dashboard/form-organization.js +82 -110
  109. package/dist/dashboard/form-organization.mjs +81 -109
  110. package/dist/dashboard/form-otc.js +4 -5
  111. package/dist/dashboard/form-otc.mjs +4 -5
  112. package/dist/dashboard/form-payment-methods.js +20 -9
  113. package/dist/dashboard/form-payment-methods.mjs +20 -9
  114. package/dist/dashboard/form-stripe.js +30 -0
  115. package/dist/dashboard/form-stripe.mjs +26 -0
  116. package/dist/dashboard/input-array.js +4 -2
  117. package/dist/dashboard/input-array.mjs +4 -2
  118. package/dist/dashboard/input-combobox.js +7 -3
  119. package/dist/dashboard/input-combobox.mjs +7 -3
  120. package/dist/dashboard/input-date.js +7 -0
  121. package/dist/dashboard/input-date.mjs +7 -0
  122. package/dist/dashboard/input-fields.js +80 -20
  123. package/dist/dashboard/input-fields.mjs +80 -20
  124. package/dist/dashboard/input-file.js +21 -1
  125. package/dist/dashboard/input-file.mjs +21 -1
  126. package/dist/dashboard/input-font.js +10 -1
  127. package/dist/dashboard/input-font.mjs +10 -1
  128. package/dist/dashboard/lib/item-list.js +57 -0
  129. package/dist/dashboard/lib/item-list.mjs +33 -0
  130. package/dist/dashboard/lib/menu.js +50 -0
  131. package/dist/dashboard/lib/menu.mjs +26 -0
  132. package/dist/dashboard/locked.js +82 -0
  133. package/dist/dashboard/locked.mjs +53 -0
  134. package/dist/dashboard/menu.js +72 -19
  135. package/dist/dashboard/menu.mjs +72 -19
  136. package/dist/dashboard/note-ai.js +69 -0
  137. package/dist/dashboard/note-ai.mjs +36 -0
  138. package/dist/dashboard/preview.js +419 -0
  139. package/dist/dashboard/preview.mjs +384 -0
  140. package/dist/dashboard/steps.js +39 -13
  141. package/dist/dashboard/steps.mjs +37 -12
  142. package/dist/dashboard/table-contacts.js +136 -0
  143. package/dist/dashboard/table-contacts.mjs +103 -0
  144. package/dist/dashboard/template-not-found.js +4 -2
  145. package/dist/dashboard/template-not-found.mjs +4 -2
  146. package/dist/dashboard/template-socket.js +20 -7
  147. package/dist/dashboard/template-socket.mjs +20 -7
  148. package/dist/icons/desktop.js +46 -0
  149. package/dist/icons/desktop.mjs +27 -0
  150. package/dist/icons/phone.js +46 -0
  151. package/dist/icons/phone.mjs +27 -0
  152. package/dist/icons/puzzle-piece.js +46 -0
  153. package/dist/icons/puzzle-piece.mjs +27 -0
  154. package/dist/icons/tablet.js +46 -0
  155. package/dist/icons/tablet.mjs +27 -0
  156. package/dist/icons/users.js +46 -0
  157. package/dist/icons/users.mjs +27 -0
  158. package/dist/input-checkbox.js +1 -0
  159. package/dist/input-checkbox.mjs +1 -0
  160. package/dist/input-code.js +101 -0
  161. package/dist/input-code.mjs +78 -0
  162. package/dist/input-text.js +2 -1
  163. package/dist/input-text.mjs +2 -1
  164. package/dist/shared/input-checkbox-list.js +0 -1
  165. package/dist/shared/input-checkbox-list.mjs +0 -1
  166. package/dist/shared/input-switch.js +6 -1
  167. package/dist/shared/input-switch.mjs +6 -1
  168. package/dist/shared/lib/campaign.js +117 -0
  169. package/dist/shared/lib/campaign.mjs +91 -0
  170. package/dist/shared/lib/helpers.js +14 -2
  171. package/dist/shared/lib/helpers.mjs +13 -2
  172. package/package.json +133 -13
  173. package/types/bridge/form-subdomain-header.d.ts +2 -0
  174. package/types/bridge/form-subdomain-missions.d.ts +36 -0
  175. package/types/bridge/form-subdomain.d.ts +23 -1
  176. package/types/bridge/lib/entry.d.ts +26 -0
  177. package/types/bridge/lib/location.d.ts +13 -0
  178. package/types/bridge/lib/order.d.ts +30 -0
  179. package/types/bridge/lib/url.d.ts +19 -0
  180. package/types/bridge/template-modal.d.ts +1 -1
  181. package/types/bridge/template-preview.d.ts +10 -0
  182. package/types/bridge/template-subdomain-link.d.ts +2 -0
  183. package/types/dashboard/accordion.d.ts +2 -0
  184. package/types/dashboard/avatar.d.ts +18 -2
  185. package/types/dashboard/buttons-subscription.d.ts +22 -0
  186. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  187. package/types/dashboard/card-order.d.ts +11 -0
  188. package/types/dashboard/card-section.d.ts +2 -0
  189. package/types/dashboard/connection-workflows.d.ts +33 -0
  190. package/types/dashboard/device.d.ts +12 -0
  191. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  192. package/types/dashboard/form-ai.d.ts +2 -2
  193. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  194. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  195. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  196. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  197. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  198. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  199. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  200. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  201. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  202. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  203. package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
  204. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  205. package/types/dashboard/form-organization-identity.d.ts +2 -0
  206. package/types/dashboard/form-organization-workflow.d.ts +43 -47
  207. package/types/dashboard/form-organization.d.ts +7 -2
  208. package/types/dashboard/form-stripe.d.ts +3 -0
  209. package/types/dashboard/input-combobox.d.ts +2 -0
  210. package/types/dashboard/input-date.d.ts +2 -0
  211. package/types/dashboard/input-fields.d.ts +3 -2
  212. package/types/dashboard/input-file.d.ts +4 -0
  213. package/types/dashboard/lib/item-list.d.ts +14 -0
  214. package/types/dashboard/lib/menu.d.ts +17 -0
  215. package/types/dashboard/locked.d.ts +10 -0
  216. package/types/dashboard/menu.d.ts +10 -2
  217. package/types/dashboard/note-ai.d.ts +15 -0
  218. package/types/dashboard/preview.d.ts +33 -0
  219. package/types/dashboard/steps.d.ts +19 -4
  220. package/types/dashboard/table-cell-title.d.ts +2 -2
  221. package/types/dashboard/table-contacts.d.ts +2 -0
  222. package/types/icons/desktop.d.ts +5 -0
  223. package/types/icons/phone.d.ts +5 -0
  224. package/types/icons/puzzle-piece.d.ts +5 -0
  225. package/types/icons/tablet.d.ts +5 -0
  226. package/types/icons/users.d.ts +5 -0
  227. package/types/input-code.d.ts +23 -0
  228. package/types/shared/input-switch.d.ts +2 -0
  229. package/types/shared/lib/campaign.d.ts +35 -0
  230. package/types/shared/lib/helpers.d.ts +3 -0
  231. package/dist/dashboard/card-integration.js +0 -187
  232. package/dist/dashboard/card-integration.mjs +0 -158
  233. package/dist/dashboard/iframe.js +0 -159
  234. package/dist/dashboard/iframe.mjs +0 -130
  235. package/types/dashboard/card-integration.d.ts +0 -24
  236. package/types/dashboard/iframe.d.ts +0 -18
@@ -31,6 +31,7 @@ __export(form_organization_campaign_agreement_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(form_organization_campaign_agreement_exports);
33
33
  var import_jsx_runtime = require("react/jsx-runtime");
34
+ var import_react = require("react");
34
35
  var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
35
36
  var import_form = require("../shared/lib/form");
36
37
  var import_yup = __toESM(require("../shared/lib/yup"));
@@ -41,198 +42,248 @@ var import_input_group = __toESM(require("../input-group"));
41
42
  var import_input_switch = __toESM(require("../shared/input-switch"));
42
43
  var import_input_text = __toESM(require("../input-text"));
43
44
  var import_input_url = __toESM(require("../shared/input-url"));
44
- var import_input_checkbox = __toESM(require("../input-checkbox"));
45
- var import_card_section = __toESM(require("./card-section"));
45
+ var import_badge = __toESM(require("../shared/badge"));
46
46
  var import_button = __toESM(require("../shared/button"));
47
+ const schema = (enforceLink) => import_yup.default.object({
48
+ enabled: import_yup.default.boolean(),
49
+ label: import_yup.default.string().label("Label").when("enabled", ([enabled], field) => Boolean(enabled) ? field.required().max(300) : field),
50
+ link: import_yup.default.string().nullable().label("Link").when("enabled", ([enabled], field) => {
51
+ if (!Boolean(enabled)) return field;
52
+ const matches = [import_drawbridge_utils.regex.url, "Url must start with https"];
53
+ return enforceLink ? field.required().matches(...matches).url().max(300) : field.transform((value) => value ? value : null).matches(...matches).url().max(300);
54
+ })
55
+ });
47
56
  const FormOrganizationCampaignAgreement = ({
57
+ agreements = {},
58
+ defaultLabels = {},
48
59
  disabled,
49
- enforceLink,
50
- onSuccess,
60
+ onChange,
51
61
  onError,
52
- values
62
+ onFocus,
63
+ onSuccess,
64
+ params
53
65
  }) => {
54
- const { control, handleSubmit, formState } = (0, import_form.useForm)({
55
- defaultValues: values,
66
+ const ids = Object.keys(agreements);
67
+ const { control, handleSubmit, formState, reset } = (0, import_form.useForm)({
68
+ defaultValues: Object.fromEntries(ids.map((id) => {
69
+ var _a;
70
+ return [id, ((_a = agreements[id]) == null ? void 0 : _a.values) || {}];
71
+ })),
56
72
  resolver: (0, import_yup.resolver)(
57
- import_yup.default.object({
58
- enabled: import_yup.default.boolean(),
59
- label: import_yup.default.string().label("Label").when("enabled", ([enabled], schema) => {
60
- if (Boolean(enabled)) {
61
- return schema.required().max(300);
62
- }
63
- return schema;
64
- }),
65
- link: import_yup.default.string().nullable().label("Link").when("enabled", ([enabled], schema) => {
66
- if (Boolean(enabled)) {
67
- const matches = [import_drawbridge_utils.regex.url, "Url must start with https"];
68
- if (enforceLink) {
69
- return schema.required().matches(...matches).url().max(300);
70
- } else {
71
- return schema.transform((value) => value ? value : null).matches(...matches).url().max(300);
72
- }
73
- }
74
- return schema;
75
- })
76
- })
73
+ import_yup.default.object(Object.fromEntries(ids.map((id) => {
74
+ var _a;
75
+ return [id, schema((_a = agreements[id]) == null ? void 0 : _a.enforceLink)];
76
+ })))
77
77
  )
78
78
  });
79
79
  const watched = (0, import_form.useWatch)({
80
80
  control
81
81
  });
82
- const onSubmit = async ({
83
- enabled,
84
- label,
85
- link
86
- }) => {
82
+ const typed = JSON.stringify(watched);
83
+ (0, import_react.useEffect)(
84
+ () => {
85
+ onChange == null ? void 0 : onChange(watched);
86
+ },
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ [typed]
89
+ );
90
+ const onSubmit = async (values) => {
87
91
  try {
88
- const args = {
89
- body: {
90
- enabled,
91
- label,
92
- link
93
- },
94
- endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + values.campaign + "/agreement/" + (values == null ? void 0 : values.id),
95
- method: "PUT"
96
- };
97
- const response = await (0, import_fetch.request)(args);
98
- onSuccess(response);
92
+ let response;
93
+ for (const id of ids.filter((id2) => {
94
+ var _a;
95
+ return (_a = formState == null ? void 0 : formState.dirtyFields) == null ? void 0 : _a[id2];
96
+ })) {
97
+ const { enabled, label, link } = values[id];
98
+ response = await (0, import_fetch.request)({
99
+ body: {
100
+ enabled,
101
+ label,
102
+ link
103
+ },
104
+ endpoint: "/organization/" + (params == null ? void 0 : params.organization) + "/campaign/" + (params == null ? void 0 : params.campaign) + "/agreement/" + id,
105
+ method: "PUT"
106
+ });
107
+ }
108
+ ;
109
+ reset(values);
110
+ if (response) onSuccess(response);
99
111
  } catch (error) {
100
112
  onError(error);
101
113
  }
102
114
  };
103
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
- import_form2.default,
105
- {
106
- ...{
107
- className: "relative w-full",
108
- onSubmit: handleSubmit(onSubmit)
109
- },
110
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
111
- import_fieldset.default,
112
- {
113
- ...{
114
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
115
- },
116
- children: [
117
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
118
- import_form.Controller,
119
- {
120
- ...{
121
- control,
122
- name: "enabled",
123
- render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
124
- import_input_group.default,
125
- {
126
- ...{
127
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
128
- import_input_switch.default,
129
- {
130
- ...{
131
- onChange,
132
- value: value || false
133
- }
134
- }
135
- ),
136
- label: "Enabled"
137
- }
138
- }
139
- )
140
- }
141
- }
142
- ),
143
- (watched == null ? void 0 : watched.enabled) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
144
- import_form.Controller,
145
- {
146
- ...{
147
- control,
148
- name: "label",
149
- render: ({ field: { value, onChange } }) => {
150
- var _a, _b;
151
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
152
- import_input_group.default,
153
- {
154
- ...{
155
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.label) == null ? void 0 : _b.message,
156
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
157
- import_input_text.default,
158
- {
159
- ...{
160
- onChange,
161
- value: value || ""
162
- }
163
- }
164
- ),
165
- label: "Label"
166
- }
167
- }
168
- );
169
- }
170
- }
171
- }
172
- ),
173
- (watched == null ? void 0 : watched.enabled) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
174
- import_form.Controller,
175
- {
176
- ...{
177
- control,
178
- name: "link",
179
- render: ({ field: { value, onChange } }) => {
180
- var _a, _b;
181
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
- import_input_group.default,
183
- {
184
- ...{
185
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.link) == null ? void 0 : _b.message,
186
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
187
- import_input_url.default,
188
- {
189
- ...{
190
- onChange,
191
- value: value || ""
192
- }
193
- }
194
- ),
195
- label: "Link"
196
- }
197
- }
198
- );
115
+ const section = (id) => {
116
+ var _a;
117
+ const { active, title, warning } = agreements[id];
118
+ const enabled = (_a = watched == null ? void 0 : watched[id]) == null ? void 0 : _a.enabled;
119
+ const focus = () => onFocus == null ? void 0 : onFocus(id);
120
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
121
+ "section",
122
+ {
123
+ ...{
124
+ className: "space-y-6",
125
+ "data-guide": "section-" + id
126
+ },
127
+ children: [
128
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
129
+ "h3",
130
+ {
131
+ ...{
132
+ className: "flex items-center gap-2"
133
+ },
134
+ children: [
135
+ title,
136
+ warning && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
+ import_badge.default,
138
+ {
139
+ ...{
140
+ size: "small",
141
+ type: "error"
142
+ },
143
+ children: "Required"
199
144
  }
200
- }
201
- }
202
- ),
203
- (watched == null ? void 0 : watched.enabled) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
204
- import_card_section.default,
205
- {
206
- ...{
207
- title: "Preview"
208
- },
209
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
210
- import_input_group.default,
145
+ )
146
+ ]
147
+ }
148
+ ),
149
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
150
+ import_fieldset.default,
151
+ {
152
+ ...{
153
+ // An agreement the api marks inactive can't be changed.
154
+ disabled: disabled || !active || (formState == null ? void 0 : formState.isSubmitting)
155
+ },
156
+ children: [
157
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
+ import_form.Controller,
211
159
  {
212
160
  ...{
213
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
214
- import_input_checkbox.default,
161
+ control,
162
+ name: id + ".enabled",
163
+ render: ({ field: { value, onChange: change } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
164
+ import_input_group.default,
215
165
  {
216
166
  ...{
217
- disabled: true,
218
- label: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
167
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
219
168
  "span",
220
169
  {
221
- ...(watched == null ? void 0 : watched.link) && {
222
- className: "underline"
170
+ ...{
171
+ className: "inline-flex",
172
+ onFocus: focus
223
173
  },
224
- children: watched == null ? void 0 : watched.label
174
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
175
+ import_input_switch.default,
176
+ {
177
+ ...{
178
+ onChange: (next) => {
179
+ focus();
180
+ change(next);
181
+ },
182
+ value: value || false
183
+ }
184
+ }
185
+ )
225
186
  }
226
- )
187
+ ),
188
+ label: "Enabled"
227
189
  }
228
190
  }
229
191
  )
230
192
  }
231
193
  }
194
+ ),
195
+ (enabled || defaultLabels[id]) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
196
+ import_form.Controller,
197
+ {
198
+ ...{
199
+ control,
200
+ name: id + ".label",
201
+ render: ({ field: { value, onChange: change } }) => {
202
+ var _a2, _b, _c;
203
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
204
+ import_input_group.default,
205
+ {
206
+ ...{
207
+ error: (_c = (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2[id]) == null ? void 0 : _b.label) == null ? void 0 : _c.message,
208
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
209
+ import_input_text.default,
210
+ {
211
+ ...{
212
+ onChange: change,
213
+ onFocus: focus,
214
+ ...enabled ? {
215
+ value: value || ""
216
+ } : {
217
+ disabled: true,
218
+ value: defaultLabels[id]
219
+ }
220
+ }
221
+ }
222
+ ),
223
+ label: "Label"
224
+ }
225
+ }
226
+ );
227
+ }
228
+ }
229
+ }
230
+ ),
231
+ enabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
232
+ import_form.Controller,
233
+ {
234
+ ...{
235
+ control,
236
+ name: id + ".link",
237
+ render: ({ field: { value, onChange: change } }) => {
238
+ var _a2, _b, _c;
239
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
240
+ import_input_group.default,
241
+ {
242
+ ...{
243
+ error: (_c = (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2[id]) == null ? void 0 : _b.link) == null ? void 0 : _c.message,
244
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
245
+ import_input_url.default,
246
+ {
247
+ ...{
248
+ onChange: change,
249
+ onFocus: focus,
250
+ value: value || ""
251
+ }
252
+ }
253
+ ),
254
+ label: "Link"
255
+ }
256
+ }
257
+ );
258
+ }
259
+ }
260
+ }
232
261
  )
233
- }
234
- ),
235
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
262
+ ]
263
+ }
264
+ )
265
+ ]
266
+ },
267
+ id
268
+ );
269
+ };
270
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
271
+ import_form2.default,
272
+ {
273
+ ...{
274
+ // Divided as the Page editor's form, Save under the last section.
275
+ className: "relative w-full divide-y divide-gray [&>*]:py-6 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0",
276
+ onSubmit: handleSubmit(onSubmit)
277
+ },
278
+ children: [
279
+ ids.map(section),
280
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
281
+ import_fieldset.default,
282
+ {
283
+ ...{
284
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
285
+ },
286
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
287
  import_button.default,
237
288
  {
238
289
  ...{
@@ -242,9 +293,9 @@ const FormOrganizationCampaignAgreement = ({
242
293
  children: "Save"
243
294
  }
244
295
  )
245
- ]
246
- }
247
- )
296
+ }
297
+ )
298
+ ]
248
299
  }
249
300
  );
250
301
  };