@drawbridge/components 0.1.13 → 0.1.15

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 (242) 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 +577 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +540 -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 +277 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +243 -0
  48. package/dist/dashboard/card-order.js +231 -29
  49. package/dist/dashboard/card-order.mjs +231 -29
  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 +205 -0
  55. package/dist/dashboard/connection-workflows.mjs +171 -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-field-select.js +51 -5
  81. package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
  82. package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
  83. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
  84. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  87. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  88. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  89. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  90. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  91. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  92. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  93. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  94. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  95. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  96. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  97. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  99. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  100. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  101. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  102. package/dist/dashboard/form-organization-campaign-section.js +243 -0
  103. package/dist/dashboard/form-organization-campaign-section.mjs +214 -0
  104. package/dist/dashboard/form-organization-campaign.js +114 -469
  105. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  106. package/dist/dashboard/form-organization-export.js +4 -7
  107. package/dist/dashboard/form-organization-export.mjs +4 -7
  108. package/dist/dashboard/form-organization-identity.js +46 -51
  109. package/dist/dashboard/form-organization-identity.mjs +46 -51
  110. package/dist/dashboard/form-organization-workflow.js +708 -687
  111. package/dist/dashboard/form-organization-workflow.mjs +704 -683
  112. package/dist/dashboard/form-organization.js +82 -110
  113. package/dist/dashboard/form-organization.mjs +81 -109
  114. package/dist/dashboard/form-otc.js +4 -5
  115. package/dist/dashboard/form-otc.mjs +4 -5
  116. package/dist/dashboard/form-payment-methods.js +20 -9
  117. package/dist/dashboard/form-payment-methods.mjs +20 -9
  118. package/dist/dashboard/form-stripe.js +30 -0
  119. package/dist/dashboard/form-stripe.mjs +26 -0
  120. package/dist/dashboard/input-array.js +4 -2
  121. package/dist/dashboard/input-array.mjs +4 -2
  122. package/dist/dashboard/input-combobox.js +7 -3
  123. package/dist/dashboard/input-combobox.mjs +7 -3
  124. package/dist/dashboard/input-date.js +7 -0
  125. package/dist/dashboard/input-date.mjs +7 -0
  126. package/dist/dashboard/input-fields.js +80 -20
  127. package/dist/dashboard/input-fields.mjs +80 -20
  128. package/dist/dashboard/input-file.js +21 -1
  129. package/dist/dashboard/input-file.mjs +21 -1
  130. package/dist/dashboard/input-font.js +10 -1
  131. package/dist/dashboard/input-font.mjs +10 -1
  132. package/dist/dashboard/lib/item-list.js +57 -0
  133. package/dist/dashboard/lib/item-list.mjs +33 -0
  134. package/dist/dashboard/lib/menu.js +50 -0
  135. package/dist/dashboard/lib/menu.mjs +26 -0
  136. package/dist/dashboard/locked.js +82 -0
  137. package/dist/dashboard/locked.mjs +53 -0
  138. package/dist/dashboard/menu.js +72 -19
  139. package/dist/dashboard/menu.mjs +72 -19
  140. package/dist/dashboard/note-ai.js +69 -0
  141. package/dist/dashboard/note-ai.mjs +36 -0
  142. package/dist/dashboard/preview.js +419 -0
  143. package/dist/dashboard/preview.mjs +384 -0
  144. package/dist/dashboard/steps.js +39 -13
  145. package/dist/dashboard/steps.mjs +37 -12
  146. package/dist/dashboard/table-contacts.js +136 -0
  147. package/dist/dashboard/table-contacts.mjs +103 -0
  148. package/dist/dashboard/template-not-found.js +4 -2
  149. package/dist/dashboard/template-not-found.mjs +4 -2
  150. package/dist/dashboard/template-socket.js +20 -7
  151. package/dist/dashboard/template-socket.mjs +20 -7
  152. package/dist/icons/desktop.js +46 -0
  153. package/dist/icons/desktop.mjs +27 -0
  154. package/dist/icons/phone.js +46 -0
  155. package/dist/icons/phone.mjs +27 -0
  156. package/dist/icons/puzzle-piece.js +46 -0
  157. package/dist/icons/puzzle-piece.mjs +27 -0
  158. package/dist/icons/tablet.js +46 -0
  159. package/dist/icons/tablet.mjs +27 -0
  160. package/dist/icons/users.js +46 -0
  161. package/dist/icons/users.mjs +27 -0
  162. package/dist/input-checkbox.js +1 -0
  163. package/dist/input-checkbox.mjs +1 -0
  164. package/dist/input-code.js +83 -0
  165. package/dist/input-code.mjs +50 -0
  166. package/dist/input-text.js +2 -1
  167. package/dist/input-text.mjs +2 -1
  168. package/dist/shared/button.js +1 -1
  169. package/dist/shared/button.mjs +1 -1
  170. package/dist/shared/input-checkbox-list.js +0 -1
  171. package/dist/shared/input-checkbox-list.mjs +0 -1
  172. package/dist/shared/input-switch.js +6 -1
  173. package/dist/shared/input-switch.mjs +6 -1
  174. package/dist/shared/lib/campaign.js +123 -0
  175. package/dist/shared/lib/campaign.mjs +96 -0
  176. package/dist/shared/lib/helpers.js +14 -2
  177. package/dist/shared/lib/helpers.mjs +13 -2
  178. package/package.json +133 -13
  179. package/types/bridge/form-subdomain-header.d.ts +2 -0
  180. package/types/bridge/form-subdomain-missions.d.ts +38 -0
  181. package/types/bridge/form-subdomain.d.ts +23 -1
  182. package/types/bridge/lib/entry.d.ts +26 -0
  183. package/types/bridge/lib/location.d.ts +13 -0
  184. package/types/bridge/lib/order.d.ts +30 -0
  185. package/types/bridge/lib/url.d.ts +19 -0
  186. package/types/bridge/template-modal.d.ts +1 -1
  187. package/types/bridge/template-preview.d.ts +10 -0
  188. package/types/bridge/template-subdomain-link.d.ts +2 -0
  189. package/types/dashboard/accordion.d.ts +2 -0
  190. package/types/dashboard/avatar.d.ts +18 -2
  191. package/types/dashboard/buttons-subscription.d.ts +22 -0
  192. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  193. package/types/dashboard/card-order.d.ts +25 -1
  194. package/types/dashboard/card-section.d.ts +2 -0
  195. package/types/dashboard/connection-workflows.d.ts +33 -0
  196. package/types/dashboard/device.d.ts +12 -0
  197. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  198. package/types/dashboard/form-ai.d.ts +2 -2
  199. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  200. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  201. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  202. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  203. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  204. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  205. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  206. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  207. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  208. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  209. package/types/dashboard/form-organization-campaign-section.d.ts +29 -0
  210. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  211. package/types/dashboard/form-organization-identity.d.ts +2 -0
  212. package/types/dashboard/form-organization-workflow.d.ts +56 -47
  213. package/types/dashboard/form-organization.d.ts +7 -2
  214. package/types/dashboard/form-stripe.d.ts +3 -0
  215. package/types/dashboard/input-combobox.d.ts +2 -0
  216. package/types/dashboard/input-date.d.ts +2 -0
  217. package/types/dashboard/input-fields.d.ts +3 -2
  218. package/types/dashboard/input-file.d.ts +4 -0
  219. package/types/dashboard/lib/item-list.d.ts +14 -0
  220. package/types/dashboard/lib/menu.d.ts +17 -0
  221. package/types/dashboard/locked.d.ts +10 -0
  222. package/types/dashboard/menu.d.ts +10 -2
  223. package/types/dashboard/note-ai.d.ts +15 -0
  224. package/types/dashboard/preview.d.ts +33 -0
  225. package/types/dashboard/steps.d.ts +19 -4
  226. package/types/dashboard/table-cell-title.d.ts +2 -2
  227. package/types/dashboard/table-contacts.d.ts +2 -0
  228. package/types/icons/desktop.d.ts +5 -0
  229. package/types/icons/phone.d.ts +5 -0
  230. package/types/icons/puzzle-piece.d.ts +5 -0
  231. package/types/icons/tablet.d.ts +5 -0
  232. package/types/icons/users.d.ts +5 -0
  233. package/types/input-code.d.ts +23 -0
  234. package/types/shared/input-switch.d.ts +2 -0
  235. package/types/shared/lib/campaign.d.ts +35 -0
  236. package/types/shared/lib/helpers.d.ts +3 -0
  237. package/dist/dashboard/card-integration.js +0 -187
  238. package/dist/dashboard/card-integration.mjs +0 -158
  239. package/dist/dashboard/iframe.js +0 -159
  240. package/dist/dashboard/iframe.mjs +0 -130
  241. package/types/dashboard/card-integration.d.ts +0 -24
  242. package/types/dashboard/iframe.d.ts +0 -18
@@ -8,6 +8,7 @@ import Form from "../shared/form.mjs";
8
8
  import Fieldset from "../shared/fieldset.mjs";
9
9
  import Empty from "../shared/empty.mjs";
10
10
  import CardTask from "./card-task.mjs";
11
+ import ProviderResource from "./provider-resource.mjs";
11
12
  import Button from "../shared/button.mjs";
12
13
  const stripe = loadStripe(process.env.NEXT_PUBLIC_STRIPE_API_KEY);
13
14
  const FormStripeInner = ({
@@ -201,7 +202,32 @@ const FormStripe = ({
201
202
  }
202
203
  );
203
204
  };
205
+ const FormStripeIntent = ({ onSuccess }) => /* @__PURE__ */ jsx(
206
+ ProviderResource,
207
+ {
208
+ ...{
209
+ cache: "no-store",
210
+ endpoint: "/account/intent",
211
+ error: ({ error }) => error.message,
212
+ loader: true,
213
+ queryKey: ["payment-intent"]
214
+ },
215
+ children: (query) => {
216
+ var _a;
217
+ return /* @__PURE__ */ jsx(
218
+ FormStripe,
219
+ {
220
+ ...{
221
+ clientSecret: (_a = query == null ? void 0 : query.data) == null ? void 0 : _a.clientSecret,
222
+ onSuccess
223
+ }
224
+ }
225
+ );
226
+ }
227
+ }
228
+ );
204
229
  var form_stripe_default = FormStripe;
205
230
  export {
231
+ FormStripeIntent,
206
232
  form_stripe_default as default
207
233
  };
@@ -159,7 +159,8 @@ const InputArray = ({
159
159
  import_empty.default,
160
160
  {
161
161
  ...{
162
- variant: "primary"
162
+ // Every list sits in a white form box ( a drawer, a modal, the page form's sections ): the grey box.
163
+ variant: "secondary"
163
164
  },
164
165
  children: empty
165
166
  }
@@ -253,7 +254,8 @@ const InputArraySortable = ({
253
254
  import_empty.default,
254
255
  {
255
256
  ...{
256
- variant: "primary"
257
+ // Every list sits in a white form box ( a drawer, a modal, the page form's sections ): the grey box.
258
+ variant: "secondary"
257
259
  },
258
260
  children: empty
259
261
  }
@@ -124,7 +124,8 @@ const InputArray = ({
124
124
  Empty,
125
125
  {
126
126
  ...{
127
- variant: "primary"
127
+ // Every list sits in a white form box ( a drawer, a modal, the page form's sections ): the grey box.
128
+ variant: "secondary"
128
129
  },
129
130
  children: empty
130
131
  }
@@ -218,7 +219,8 @@ const InputArraySortable = ({
218
219
  Empty,
219
220
  {
220
221
  ...{
221
- variant: "primary"
222
+ // Every list sits in a white form box ( a drawer, a modal, the page form's sections ): the grey box.
223
+ variant: "secondary"
222
224
  },
223
225
  children: empty
224
226
  }
@@ -45,6 +45,8 @@ const InputCombobox = ({
45
45
  options,
46
46
  placeholder,
47
47
  searchable = false,
48
+ // 'small': the small button's 42 px with small text, for a toolbar ( the Preview's ).
49
+ size,
48
50
  value
49
51
  }) => {
50
52
  const buttonRef = (0, import_react.useRef)(null);
@@ -194,10 +196,12 @@ const InputCombobox = ({
194
196
  autoComplete: "off",
195
197
  className: [
196
198
  "input w-full pr-9 focus:outline-hidden focus:ring-0 focus-visible:outline-hidden focus-visible:ring-0",
199
+ size === "small" ? "small" : "",
197
200
  (selected == null ? void 0 : selected.image) ? "pl-12" : "",
198
- // !opacity-100 cancels the [readonly] fade, but only while enabled:
199
- // disabled must keep the [disabled] fade.
200
- searchable ? "" : "cursor-pointer caret-transparent" + (disabled ? "" : " !opacity-100")
201
+ // !bg-white cancels the [readonly] gray: unsearchable is a select,
202
+ // not a read-only value. !opacity-100 keeps it at full strength,
203
+ // but only while enabled: disabled must keep the [disabled] fade.
204
+ searchable ? "" : "cursor-pointer caret-transparent !bg-white" + (disabled ? "" : " !opacity-100")
201
205
  ].filter(Boolean).join(" "),
202
206
  displayValue: () => (selected == null ? void 0 : selected.key) || "",
203
207
  onChange: (e) => setQuery(e.target.value),
@@ -19,6 +19,8 @@ const InputCombobox = ({
19
19
  options,
20
20
  placeholder,
21
21
  searchable = false,
22
+ // 'small': the small button's 42 px with small text, for a toolbar ( the Preview's ).
23
+ size,
22
24
  value
23
25
  }) => {
24
26
  const buttonRef = useRef(null);
@@ -168,10 +170,12 @@ const InputCombobox = ({
168
170
  autoComplete: "off",
169
171
  className: [
170
172
  "input w-full pr-9 focus:outline-hidden focus:ring-0 focus-visible:outline-hidden focus-visible:ring-0",
173
+ size === "small" ? "small" : "",
171
174
  (selected == null ? void 0 : selected.image) ? "pl-12" : "",
172
- // !opacity-100 cancels the [readonly] fade, but only while enabled:
173
- // disabled must keep the [disabled] fade.
174
- searchable ? "" : "cursor-pointer caret-transparent" + (disabled ? "" : " !opacity-100")
175
+ // !bg-white cancels the [readonly] gray: unsearchable is a select,
176
+ // not a read-only value. !opacity-100 keeps it at full strength,
177
+ // but only while enabled: disabled must keep the [disabled] fade.
178
+ searchable ? "" : "cursor-pointer caret-transparent !bg-white" + (disabled ? "" : " !opacity-100")
175
179
  ].filter(Boolean).join(" "),
176
180
  displayValue: () => (selected == null ? void 0 : selected.key) || "",
177
181
  onChange: (e) => setQuery(e.target.value),
@@ -187,6 +187,7 @@ const InputDate = ({
187
187
  };
188
188
  const InputDateRange = ({
189
189
  className,
190
+ max,
190
191
  onChange,
191
192
  value = {}
192
193
  }) => {
@@ -217,6 +218,12 @@ const InputDateRange = ({
217
218
  classNames: DAY_PICKER_CLASS_NAMES,
218
219
  components: DAY_PICKER_COMPONENTS,
219
220
  defaultMonth: selected.from,
221
+ ...max && {
222
+ disabled: {
223
+ after: toDateObj(max)
224
+ },
225
+ endMonth: toDateObj(max)
226
+ },
220
227
  mode: "range",
221
228
  selected,
222
229
  onSelect: handleSelect,
@@ -154,6 +154,7 @@ const InputDate = ({
154
154
  };
155
155
  const InputDateRange = ({
156
156
  className,
157
+ max,
157
158
  onChange,
158
159
  value = {}
159
160
  }) => {
@@ -184,6 +185,12 @@ const InputDateRange = ({
184
185
  classNames: DAY_PICKER_CLASS_NAMES,
185
186
  components: DAY_PICKER_COMPONENTS,
186
187
  defaultMonth: selected.from,
188
+ ...max && {
189
+ disabled: {
190
+ after: toDateObj(max)
191
+ },
192
+ endMonth: toDateObj(max)
193
+ },
187
194
  mode: "range",
188
195
  selected,
189
196
  onSelect: handleSelect,
@@ -54,6 +54,7 @@ var import_input_range = __toESM(require("../shared/input-range"));
54
54
  var import_input_combobox = __toESM(require("./input-combobox"));
55
55
  var import_input_text = __toESM(require("../input-text"));
56
56
  var import_input_textarea = __toESM(require("../input-textarea"));
57
+ var import_input_switch = __toESM(require("../shared/input-switch"));
57
58
  var import_input_array = require("./input-array");
58
59
  var import_input_file = __toESM(require("./input-file"));
59
60
  var import_divider = __toESM(require("../shared/divider"));
@@ -63,7 +64,20 @@ var import_plus = __toESM(require("../icons/plus"));
63
64
  var import_trash = __toESM(require("../icons/trash"));
64
65
  var import_geo = require("./lib/geo");
65
66
  var import_loader = require("../shared/loader");
67
+ var import_campaign = require("../shared/lib/campaign");
66
68
  const InputGoogleAutocomplete = (0, import_dynamic.default)(() => import("./google").then((m) => m.InputGoogleAutocomplete), { loading: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.LoaderDynamic, {}), ssr: false });
69
+ const switches = [
70
+ {
71
+ key: "form",
72
+ label: "Form",
73
+ message: "Collect leads with the entry form on your pages"
74
+ },
75
+ {
76
+ key: "giveaway",
77
+ label: "Giveaway",
78
+ message: "Award entries for prizes while a range is running"
79
+ }
80
+ ];
67
81
  const schemas = {
68
82
  // The one address rule, the same shape every api address route checks
69
83
  // (utils yup). Its unit is nullable: a saved empty unit comes back null.
@@ -83,9 +97,10 @@ const schemas = {
83
97
  text: import_yup.default.object()
84
98
  })
85
99
  }),
86
- campaign: ({ typeEnum }) => ({
87
- title: import_yup.default.string().label("Title").required().max(150).nullable(),
88
- type: import_yup.default.string().label("Type").oneOf(typeEnum).required()
100
+ campaign: () => ({
101
+ form: import_yup.default.boolean(),
102
+ giveaway: import_yup.default.boolean(),
103
+ title: import_yup.default.string().label("Title").required().max(150).nullable()
89
104
  }),
90
105
  page: () => ({
91
106
  title: import_yup.default.string().label("Title").required().max(150)
@@ -646,9 +661,12 @@ const InputFieldsStyle = ({ disabled, onUpdate }) => {
646
661
  ] });
647
662
  };
648
663
  const InputFieldsCampaign = ({ onUpdate }) => {
649
- const { control, formState } = (0, import_react_hook_form.useFormContext)();
650
- const queryClient = (0, import_react_query.useQueryClient)();
651
- const app = queryClient.getQueryData(["app"]);
664
+ const { control, formState, getValues, setValue } = (0, import_react_hook_form.useFormContext)();
665
+ const flip = (key, on) => {
666
+ const next = (0, import_campaign.campaignSwitches)(getValues(), key, on);
667
+ setValue("form", next.form, { shouldDirty: true });
668
+ setValue("giveaway", next.giveaway, { shouldDirty: true });
669
+ };
652
670
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
653
671
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
654
672
  import_react_hook_form.Controller,
@@ -683,38 +701,38 @@ const InputFieldsCampaign = ({ onUpdate }) => {
683
701
  }
684
702
  }
685
703
  ),
686
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
704
+ switches.map(({ key, label, message }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
687
705
  import_react_hook_form.Controller,
688
706
  {
689
707
  ...{
690
708
  control,
691
- name: "type",
692
- render: ({ field: { value, onChange } }) => {
709
+ name: key,
710
+ render: ({ field: { value } }) => {
693
711
  var _a, _b;
694
712
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
695
713
  import_input_group.default,
696
714
  {
697
715
  ...{
698
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.type) == null ? void 0 : _b.message,
716
+ error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[key]) == null ? void 0 : _b.message,
699
717
  input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
700
- import_input_combobox.default,
718
+ import_input_switch.default,
701
719
  {
702
720
  ...{
703
- onChange,
704
- options: app.enums.campaign.type.options,
705
- value: value || "giveaway"
721
+ onChange: (on) => flip(key, on),
722
+ value: Boolean(value)
706
723
  }
707
724
  }
708
725
  ),
709
- label: "Campaign type",
710
- message: "Giveaway includes prize draws, ranges, and prizes. Default type is for lead capture only."
726
+ label,
727
+ message
711
728
  }
712
729
  }
713
730
  );
714
731
  }
715
732
  }
716
- }
717
- )
733
+ },
734
+ key
735
+ ))
718
736
  ] });
719
737
  };
720
738
  const InputFieldsCurrency = ({ label } = {}) => {
@@ -879,9 +897,38 @@ const InputFieldsDetails = ({ organization, onUpdate }) => {
879
897
  )
880
898
  ] });
881
899
  };
882
- const InputFieldsImages = ({ organization, onUpdate, values = {} }) => {
900
+ const useDescriptions = (onUpdate) => {
901
+ const { control, getValues, setValue } = (0, import_react_hook_form.useFormContext)();
902
+ const descriptions = (0, import_react_hook_form.useWatch)({ control, name: "descriptions" }) || {};
903
+ const describe = (slot, id) => (text) => {
904
+ const current = getValues("descriptions") || {};
905
+ setValue(
906
+ "descriptions",
907
+ id ? {
908
+ ...current,
909
+ gallery: {
910
+ ...current == null ? void 0 : current.gallery,
911
+ [id]: text
912
+ }
913
+ } : {
914
+ ...current,
915
+ [slot]: text
916
+ },
917
+ {
918
+ shouldDirty: true
919
+ }
920
+ );
921
+ onUpdate == null ? void 0 : onUpdate(getValues());
922
+ };
923
+ return {
924
+ describe,
925
+ descriptions
926
+ };
927
+ };
928
+ const InputFieldsImages = ({ described, organization, onUpdate, values = {} }) => {
883
929
  var _a, _b, _c, _d;
884
930
  const { control, formState, getValues } = (0, import_react_hook_form.useFormContext)();
931
+ const { describe, descriptions } = useDescriptions(onUpdate);
885
932
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
886
933
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
887
934
  import_react_hook_form.Controller,
@@ -902,6 +949,10 @@ const InputFieldsImages = ({ organization, onUpdate, values = {} }) => {
902
949
  import_input_file.default,
903
950
  {
904
951
  ...{
952
+ ...described && {
953
+ description: descriptions == null ? void 0 : descriptions.logo,
954
+ onDescription: describe("logo")
955
+ },
905
956
  endpoint: "/organization/" + values.organization,
906
957
  onChange: (val) => {
907
958
  onChange(val);
@@ -941,6 +992,10 @@ const InputFieldsImages = ({ organization, onUpdate, values = {} }) => {
941
992
  import_input_file.default,
942
993
  {
943
994
  ...{
995
+ ...described && {
996
+ description: descriptions == null ? void 0 : descriptions.preview,
997
+ onDescription: describe("preview")
998
+ },
944
999
  endpoint: "/organization/" + values.organization,
945
1000
  organization,
946
1001
  onChange: (val) => {
@@ -967,6 +1022,7 @@ const InputFieldsImages = ({ organization, onUpdate, values = {} }) => {
967
1022
  const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
968
1023
  var _a, _b;
969
1024
  const { control, formState, getValues } = (0, import_react_hook_form.useFormContext)();
1025
+ const { describe, descriptions } = useDescriptions(onUpdate);
970
1026
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
971
1027
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
972
1028
  import_input_group.default,
@@ -1024,7 +1080,7 @@ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
1024
1080
  ]
1025
1081
  },
1026
1082
  children: ({ field, handle, index, update }) => {
1027
- var _a2, _b2, _c;
1083
+ var _a2, _b2, _c, _d;
1028
1084
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1029
1085
  "div",
1030
1086
  {
@@ -1042,6 +1098,8 @@ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
1042
1098
  import_input_file.default,
1043
1099
  {
1044
1100
  ...{
1101
+ // Each gallery item's own, keyed by its file id.
1102
+ description: (_d = descriptions == null ? void 0 : descriptions.gallery) == null ? void 0 : _d[field == null ? void 0 : field.id],
1045
1103
  endpoint: "/organization/" + values.organization,
1046
1104
  filters: {
1047
1105
  id: {
@@ -1055,6 +1113,7 @@ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
1055
1113
  );
1056
1114
  onUpdate == null ? void 0 : onUpdate(getValues());
1057
1115
  },
1116
+ onDescription: describe("gallery", field == null ? void 0 : field.id),
1058
1117
  organization,
1059
1118
  nullable: false,
1060
1119
  value: field,
@@ -1079,6 +1138,7 @@ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
1079
1138
  InputFieldsImages,
1080
1139
  {
1081
1140
  ...{
1141
+ described: true,
1082
1142
  onUpdate,
1083
1143
  organization,
1084
1144
  values
@@ -14,6 +14,7 @@ import InputRange from "../shared/input-range.mjs";
14
14
  import InputCombobox from "./input-combobox.mjs";
15
15
  import InputText from "../input-text.mjs";
16
16
  import InputTextarea from "../input-textarea.mjs";
17
+ import InputSwitch from "../shared/input-switch.mjs";
17
18
  import { InputArrayControl, InputArraySortable } from "./input-array.mjs";
18
19
  import InputFile from "./input-file.mjs";
19
20
  import Divider from "../shared/divider.mjs";
@@ -24,6 +25,19 @@ import Trash from "../icons/trash.mjs";
24
25
  const InputGoogleAutocomplete = dynamic(() => import("./google.mjs").then((m) => m.InputGoogleAutocomplete), { loading: () => /* @__PURE__ */ jsx(LoaderDynamic, {}), ssr: false });
25
26
  import { getLocation, reverseGeocode } from "./lib/geo.mjs";
26
27
  import { LoaderDynamic } from "../shared/loader.mjs";
28
+ import { campaignSwitches } from "../shared/lib/campaign.mjs";
29
+ const switches = [
30
+ {
31
+ key: "form",
32
+ label: "Form",
33
+ message: "Collect leads with the entry form on your pages"
34
+ },
35
+ {
36
+ key: "giveaway",
37
+ label: "Giveaway",
38
+ message: "Award entries for prizes while a range is running"
39
+ }
40
+ ];
27
41
  const schemas = {
28
42
  // The one address rule, the same shape every api address route checks
29
43
  // (utils yup). Its unit is nullable: a saved empty unit comes back null.
@@ -43,9 +57,10 @@ const schemas = {
43
57
  text: yup.object()
44
58
  })
45
59
  }),
46
- campaign: ({ typeEnum }) => ({
47
- title: yup.string().label("Title").required().max(150).nullable(),
48
- type: yup.string().label("Type").oneOf(typeEnum).required()
60
+ campaign: () => ({
61
+ form: yup.boolean(),
62
+ giveaway: yup.boolean(),
63
+ title: yup.string().label("Title").required().max(150).nullable()
49
64
  }),
50
65
  page: () => ({
51
66
  title: yup.string().label("Title").required().max(150)
@@ -606,9 +621,12 @@ const InputFieldsStyle = ({ disabled, onUpdate }) => {
606
621
  ] });
607
622
  };
608
623
  const InputFieldsCampaign = ({ onUpdate }) => {
609
- const { control, formState } = useFormContext();
610
- const queryClient = useQueryClient();
611
- const app = queryClient.getQueryData(["app"]);
624
+ const { control, formState, getValues, setValue } = useFormContext();
625
+ const flip = (key, on) => {
626
+ const next = campaignSwitches(getValues(), key, on);
627
+ setValue("form", next.form, { shouldDirty: true });
628
+ setValue("giveaway", next.giveaway, { shouldDirty: true });
629
+ };
612
630
  return /* @__PURE__ */ jsxs(Fragment, { children: [
613
631
  /* @__PURE__ */ jsx(
614
632
  Controller,
@@ -643,38 +661,38 @@ const InputFieldsCampaign = ({ onUpdate }) => {
643
661
  }
644
662
  }
645
663
  ),
646
- /* @__PURE__ */ jsx(
664
+ switches.map(({ key, label, message }) => /* @__PURE__ */ jsx(
647
665
  Controller,
648
666
  {
649
667
  ...{
650
668
  control,
651
- name: "type",
652
- render: ({ field: { value, onChange } }) => {
669
+ name: key,
670
+ render: ({ field: { value } }) => {
653
671
  var _a, _b;
654
672
  return /* @__PURE__ */ jsx(
655
673
  InputGroup,
656
674
  {
657
675
  ...{
658
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.type) == null ? void 0 : _b.message,
676
+ error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[key]) == null ? void 0 : _b.message,
659
677
  input: /* @__PURE__ */ jsx(
660
- InputCombobox,
678
+ InputSwitch,
661
679
  {
662
680
  ...{
663
- onChange,
664
- options: app.enums.campaign.type.options,
665
- value: value || "giveaway"
681
+ onChange: (on) => flip(key, on),
682
+ value: Boolean(value)
666
683
  }
667
684
  }
668
685
  ),
669
- label: "Campaign type",
670
- message: "Giveaway includes prize draws, ranges, and prizes. Default type is for lead capture only."
686
+ label,
687
+ message
671
688
  }
672
689
  }
673
690
  );
674
691
  }
675
692
  }
676
- }
677
- )
693
+ },
694
+ key
695
+ ))
678
696
  ] });
679
697
  };
680
698
  const InputFieldsCurrency = ({ label } = {}) => {
@@ -839,9 +857,38 @@ const InputFieldsDetails = ({ organization, onUpdate }) => {
839
857
  )
840
858
  ] });
841
859
  };
842
- const InputFieldsImages = ({ organization, onUpdate, values = {} }) => {
860
+ const useDescriptions = (onUpdate) => {
861
+ const { control, getValues, setValue } = useFormContext();
862
+ const descriptions = useWatch({ control, name: "descriptions" }) || {};
863
+ const describe = (slot, id) => (text) => {
864
+ const current = getValues("descriptions") || {};
865
+ setValue(
866
+ "descriptions",
867
+ id ? {
868
+ ...current,
869
+ gallery: {
870
+ ...current == null ? void 0 : current.gallery,
871
+ [id]: text
872
+ }
873
+ } : {
874
+ ...current,
875
+ [slot]: text
876
+ },
877
+ {
878
+ shouldDirty: true
879
+ }
880
+ );
881
+ onUpdate == null ? void 0 : onUpdate(getValues());
882
+ };
883
+ return {
884
+ describe,
885
+ descriptions
886
+ };
887
+ };
888
+ const InputFieldsImages = ({ described, organization, onUpdate, values = {} }) => {
843
889
  var _a, _b, _c, _d;
844
890
  const { control, formState, getValues } = useFormContext();
891
+ const { describe, descriptions } = useDescriptions(onUpdate);
845
892
  return /* @__PURE__ */ jsxs(Fragment, { children: [
846
893
  /* @__PURE__ */ jsx(
847
894
  Controller,
@@ -862,6 +909,10 @@ const InputFieldsImages = ({ organization, onUpdate, values = {} }) => {
862
909
  InputFile,
863
910
  {
864
911
  ...{
912
+ ...described && {
913
+ description: descriptions == null ? void 0 : descriptions.logo,
914
+ onDescription: describe("logo")
915
+ },
865
916
  endpoint: "/organization/" + values.organization,
866
917
  onChange: (val) => {
867
918
  onChange(val);
@@ -901,6 +952,10 @@ const InputFieldsImages = ({ organization, onUpdate, values = {} }) => {
901
952
  InputFile,
902
953
  {
903
954
  ...{
955
+ ...described && {
956
+ description: descriptions == null ? void 0 : descriptions.preview,
957
+ onDescription: describe("preview")
958
+ },
904
959
  endpoint: "/organization/" + values.organization,
905
960
  organization,
906
961
  onChange: (val) => {
@@ -927,6 +982,7 @@ const InputFieldsImages = ({ organization, onUpdate, values = {} }) => {
927
982
  const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
928
983
  var _a, _b;
929
984
  const { control, formState, getValues } = useFormContext();
985
+ const { describe, descriptions } = useDescriptions(onUpdate);
930
986
  return /* @__PURE__ */ jsxs(Fragment, { children: [
931
987
  /* @__PURE__ */ jsx(
932
988
  InputGroup,
@@ -984,7 +1040,7 @@ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
984
1040
  ]
985
1041
  },
986
1042
  children: ({ field, handle, index, update }) => {
987
- var _a2, _b2, _c;
1043
+ var _a2, _b2, _c, _d;
988
1044
  return /* @__PURE__ */ jsxs(
989
1045
  "div",
990
1046
  {
@@ -1002,6 +1058,8 @@ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
1002
1058
  InputFile,
1003
1059
  {
1004
1060
  ...{
1061
+ // Each gallery item's own, keyed by its file id.
1062
+ description: (_d = descriptions == null ? void 0 : descriptions.gallery) == null ? void 0 : _d[field == null ? void 0 : field.id],
1005
1063
  endpoint: "/organization/" + values.organization,
1006
1064
  filters: {
1007
1065
  id: {
@@ -1015,6 +1073,7 @@ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
1015
1073
  );
1016
1074
  onUpdate == null ? void 0 : onUpdate(getValues());
1017
1075
  },
1076
+ onDescription: describe("gallery", field == null ? void 0 : field.id),
1018
1077
  organization,
1019
1078
  nullable: false,
1020
1079
  value: field,
@@ -1039,6 +1098,7 @@ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
1039
1098
  InputFieldsImages,
1040
1099
  {
1041
1100
  ...{
1101
+ described: true,
1042
1102
  onUpdate,
1043
1103
  organization,
1044
1104
  values
@@ -40,11 +40,13 @@ var import_trash = __toESM(require("../icons/trash"));
40
40
  var import_button = __toESM(require("../shared/button"));
41
41
  const InputFile = ({
42
42
  button = {},
43
+ description,
43
44
  disabled,
44
45
  endpoint,
45
46
  filters,
46
47
  nullable = true,
47
48
  onChange,
49
+ onDescription,
48
50
  organization,
49
51
  type,
50
52
  value
@@ -80,7 +82,25 @@ const InputFile = ({
80
82
  }
81
83
  }
82
84
  ),
83
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
+ onDescription ? (
86
+ // @story pages/build
87
+ // This slot's own Description, empty until typed, the file's name
88
+ // as its placeholder. The parent form's Save sends it.
89
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
+ "input",
91
+ {
92
+ ...{
93
+ "aria-label": "Description",
94
+ className: "p-0 w-full border-0 text-black placeholder:text-gray-dark/60 focus:outline-hidden focus:ring-0 focus:border-inherit",
95
+ disabled,
96
+ maxLength: 150,
97
+ onChange: (event) => onDescription(event.target.value),
98
+ placeholder: value == null ? void 0 : value.filename,
99
+ value: description || ""
100
+ }
101
+ }
102
+ )
103
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
84
104
  "input",
85
105
  {
86
106
  ...{