@drawbridge/components 0.1.37 → 0.1.39

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 (329) hide show
  1. package/components/styles.css +68 -355
  2. package/dist/advertisement.js +15 -20
  3. package/dist/advertisement.mjs +15 -20
  4. package/dist/bridge/advertisements.js +4 -2
  5. package/dist/bridge/advertisements.mjs +5 -3
  6. package/dist/bridge/fields.js +89 -6
  7. package/dist/bridge/fields.mjs +89 -7
  8. package/dist/bridge/form-subdomain-agreement.js +165 -0
  9. package/dist/bridge/form-subdomain-agreement.mjs +132 -0
  10. package/dist/bridge/form-subdomain-embed.js +5 -1
  11. package/dist/bridge/form-subdomain-embed.mjs +5 -1
  12. package/dist/bridge/form-subdomain-header.js +21 -14
  13. package/dist/bridge/form-subdomain-header.mjs +20 -14
  14. package/dist/bridge/form-subdomain-issue.js +17 -8
  15. package/dist/bridge/form-subdomain-issue.mjs +17 -8
  16. package/dist/bridge/form-subdomain-missions.js +58 -52
  17. package/dist/bridge/form-subdomain-missions.mjs +60 -54
  18. package/dist/bridge/form-subdomain.js +226 -95
  19. package/dist/bridge/form-subdomain.mjs +225 -97
  20. package/dist/bridge/lib/entry.js +71 -6
  21. package/dist/bridge/lib/entry.mjs +60 -5
  22. package/dist/bridge/lib/order.js +23 -0
  23. package/dist/bridge/lib/order.mjs +20 -0
  24. package/dist/bridge/template-layout.js +5 -2
  25. package/dist/bridge/template-layout.mjs +6 -3
  26. package/dist/bridge/template-modal.js +82 -15
  27. package/dist/bridge/template-modal.mjs +83 -16
  28. package/dist/bridge/template-subdomain-gallery.js +126 -75
  29. package/dist/bridge/template-subdomain-gallery.mjs +122 -75
  30. package/dist/bridge/template-subdomain.js +16 -14
  31. package/dist/bridge/template-subdomain.mjs +17 -15
  32. package/dist/dashboard/avatar.js +5 -0
  33. package/dist/dashboard/avatar.mjs +5 -0
  34. package/dist/dashboard/campaign-form.js +1815 -0
  35. package/dist/dashboard/campaign-form.mjs +1786 -0
  36. package/dist/dashboard/card-affiliate.js +3 -2
  37. package/dist/dashboard/card-affiliate.mjs +3 -2
  38. package/dist/dashboard/card-campaign-agreement.js +172 -0
  39. package/dist/dashboard/card-campaign-agreement.mjs +139 -0
  40. package/dist/dashboard/card-campaign-switch.js +25 -10
  41. package/dist/dashboard/card-campaign-switch.mjs +24 -10
  42. package/dist/dashboard/card-order.js +6 -14
  43. package/dist/dashboard/card-order.mjs +6 -14
  44. package/dist/dashboard/card-section.js +69 -26
  45. package/dist/dashboard/card-section.mjs +65 -26
  46. package/dist/dashboard/card-shortcut.js +183 -0
  47. package/dist/dashboard/card-shortcut.mjs +154 -0
  48. package/dist/dashboard/card-tile.js +3 -35
  49. package/dist/dashboard/card-tile.mjs +3 -34
  50. package/dist/dashboard/document-blocks.js +305 -0
  51. package/dist/dashboard/document-blocks.mjs +270 -0
  52. package/dist/dashboard/drawer-subscription.js +52 -14
  53. package/dist/dashboard/drawer-subscription.mjs +52 -14
  54. package/dist/dashboard/drawer.js +20 -3
  55. package/dist/dashboard/drawer.mjs +21 -4
  56. package/dist/dashboard/dropdown.js +6 -2
  57. package/dist/dashboard/dropdown.mjs +6 -2
  58. package/dist/dashboard/form-admin-subscription-custom.js +72 -8
  59. package/dist/dashboard/form-admin-subscription-custom.mjs +72 -8
  60. package/dist/dashboard/form-ai.js +0 -148
  61. package/dist/dashboard/form-ai.mjs +1 -148
  62. package/dist/dashboard/form-filters-analytics.js +86 -38
  63. package/dist/dashboard/form-filters-analytics.mjs +85 -38
  64. package/dist/dashboard/form-organization-brand.js +30 -13
  65. package/dist/dashboard/form-organization-brand.mjs +30 -13
  66. package/dist/dashboard/form-organization-campaign-advertisement.js +38 -112
  67. package/dist/dashboard/form-organization-campaign-advertisement.mjs +38 -112
  68. package/dist/dashboard/form-organization-campaign-advertisements.js +374 -0
  69. package/dist/dashboard/form-organization-campaign-advertisements.mjs +345 -0
  70. package/dist/dashboard/form-organization-campaign-agreement.js +402 -210
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +398 -211
  72. package/dist/dashboard/form-organization-campaign-design.js +258 -0
  73. package/dist/dashboard/form-organization-campaign-design.mjs +223 -0
  74. package/dist/dashboard/form-organization-campaign-field-item.js +585 -0
  75. package/dist/dashboard/form-organization-campaign-field-item.mjs +552 -0
  76. package/dist/dashboard/form-organization-campaign-field-number.js +48 -7
  77. package/dist/dashboard/form-organization-campaign-field-number.mjs +48 -7
  78. package/dist/dashboard/form-organization-campaign-field-select.js +15 -4
  79. package/dist/dashboard/form-organization-campaign-field-select.mjs +15 -4
  80. package/dist/dashboard/form-organization-campaign-field-skill.js +359 -0
  81. package/dist/dashboard/form-organization-campaign-field-skill.mjs +330 -0
  82. package/dist/dashboard/form-organization-campaign-field-text.js +46 -6
  83. package/dist/dashboard/form-organization-campaign-field-text.mjs +46 -6
  84. package/dist/dashboard/form-organization-campaign-field-textarea.js +22 -13
  85. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +22 -13
  86. package/dist/dashboard/form-organization-campaign-footer.js +178 -0
  87. package/dist/dashboard/form-organization-campaign-footer.mjs +149 -0
  88. package/dist/dashboard/form-organization-campaign-integration-age.js +2 -35
  89. package/dist/dashboard/form-organization-campaign-integration-age.mjs +2 -35
  90. package/dist/dashboard/form-organization-campaign-integration-geocode.js +4 -1
  91. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +4 -1
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +1 -1
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +1 -1
  94. package/dist/dashboard/form-organization-campaign-page-preview.js +1 -2
  95. package/dist/dashboard/form-organization-campaign-page-preview.mjs +1 -2
  96. package/dist/dashboard/form-organization-campaign-page-qr.js +2 -2
  97. package/dist/dashboard/form-organization-campaign-page-qr.mjs +2 -2
  98. package/dist/dashboard/form-organization-campaign-page-share.js +5 -5
  99. package/dist/dashboard/form-organization-campaign-page-share.mjs +5 -5
  100. package/dist/dashboard/form-organization-campaign-page-slug.js +2 -3
  101. package/dist/dashboard/form-organization-campaign-page-slug.mjs +2 -3
  102. package/dist/dashboard/form-organization-campaign-page.js +168 -265
  103. package/dist/dashboard/form-organization-campaign-page.mjs +170 -266
  104. package/dist/dashboard/form-organization-campaign-section.js +125 -107
  105. package/dist/dashboard/form-organization-campaign-section.mjs +121 -107
  106. package/dist/dashboard/form-organization-campaign.js +119 -9
  107. package/dist/dashboard/form-organization-campaign.mjs +118 -9
  108. package/dist/dashboard/form-organization-file-frame.js +7 -1
  109. package/dist/dashboard/form-organization-file-frame.mjs +7 -1
  110. package/dist/dashboard/form-organization-workflow.js +587 -530
  111. package/dist/dashboard/form-organization-workflow.mjs +588 -531
  112. package/dist/dashboard/form-organization.js +22 -0
  113. package/dist/dashboard/form-organization.mjs +22 -0
  114. package/dist/dashboard/form-reposition.js +396 -0
  115. package/dist/dashboard/form-reposition.mjs +359 -0
  116. package/dist/dashboard/form-support.js +189 -0
  117. package/dist/dashboard/form-support.mjs +160 -0
  118. package/dist/dashboard/form-tests.js +683 -0
  119. package/dist/dashboard/form-tests.mjs +646 -0
  120. package/dist/dashboard/form-verify-prize.js +114 -34
  121. package/dist/dashboard/form-verify-prize.mjs +111 -34
  122. package/dist/dashboard/google.js +8 -1
  123. package/dist/dashboard/google.mjs +8 -1
  124. package/dist/dashboard/input-array.js +2 -0
  125. package/dist/dashboard/input-array.mjs +2 -0
  126. package/dist/dashboard/input-editor.js +17 -6
  127. package/dist/dashboard/input-editor.mjs +17 -6
  128. package/dist/dashboard/input-fields.js +287 -437
  129. package/dist/dashboard/input-fields.mjs +287 -436
  130. package/dist/dashboard/input-file.js +70 -2
  131. package/dist/dashboard/input-file.mjs +70 -2
  132. package/dist/dashboard/input-font.js +64 -55
  133. package/dist/dashboard/input-font.mjs +64 -55
  134. package/dist/dashboard/input-resource.js +4 -1
  135. package/dist/dashboard/input-resource.mjs +4 -1
  136. package/dist/dashboard/lib/ab-tests.js +130 -0
  137. package/dist/dashboard/lib/ab-tests.mjs +94 -0
  138. package/dist/dashboard/lib/features.js +1 -1
  139. package/dist/dashboard/lib/features.mjs +1 -1
  140. package/dist/dashboard/lib/focus.js +93 -0
  141. package/dist/dashboard/lib/focus.mjs +69 -0
  142. package/dist/dashboard/lib/form-page.js +209 -0
  143. package/dist/dashboard/lib/form-page.mjs +161 -0
  144. package/dist/dashboard/lib/item-list.js +0 -15
  145. package/dist/dashboard/lib/item-list.mjs +0 -14
  146. package/dist/dashboard/lib/rail.js +16 -17
  147. package/dist/dashboard/lib/rail.mjs +15 -16
  148. package/dist/dashboard/lib/sms.js +8 -2
  149. package/dist/dashboard/lib/sms.mjs +6 -1
  150. package/dist/dashboard/list-resource.js +2 -0
  151. package/dist/dashboard/list-resource.mjs +2 -0
  152. package/dist/dashboard/menu.js +54 -5
  153. package/dist/dashboard/menu.mjs +53 -5
  154. package/dist/dashboard/modal.js +19 -4
  155. package/dist/dashboard/modal.mjs +20 -5
  156. package/dist/dashboard/order-sections.js +4 -0
  157. package/dist/dashboard/order-sections.mjs +4 -0
  158. package/dist/dashboard/preview.js +838 -324
  159. package/dist/dashboard/preview.mjs +826 -324
  160. package/dist/dashboard/provider-ui.js +20 -12
  161. package/dist/dashboard/provider-ui.mjs +21 -13
  162. package/dist/dashboard/recharts.js +53 -28
  163. package/dist/dashboard/recharts.mjs +53 -28
  164. package/dist/dashboard/swatch.js +35 -0
  165. package/dist/dashboard/swatch.mjs +31 -0
  166. package/dist/dashboard/table-contacts.js +6 -10
  167. package/dist/dashboard/table-contacts.mjs +6 -10
  168. package/dist/dashboard/table.js +10 -3
  169. package/dist/dashboard/table.mjs +9 -3
  170. package/dist/dashboard/template-dashboard.js +12 -7
  171. package/dist/dashboard/template-dashboard.mjs +11 -7
  172. package/dist/dashboard/template-design.js +564 -0
  173. package/dist/dashboard/template-design.mjs +531 -0
  174. package/dist/dashboard/template-rail.js +192 -126
  175. package/dist/dashboard/template-rail.mjs +190 -125
  176. package/dist/dashboard/template-socket.js +0 -3
  177. package/dist/dashboard/template-socket.mjs +0 -3
  178. package/dist/dashboard/template-test-page.js +436 -0
  179. package/dist/dashboard/template-test-page.mjs +407 -0
  180. package/dist/dashboard/template-tests.js +141 -0
  181. package/dist/dashboard/template-tests.mjs +112 -0
  182. package/dist/dashboard/template-ui.js +20 -11
  183. package/dist/dashboard/template-ui.mjs +22 -13
  184. package/dist/dashboard/template-variant.js +185 -0
  185. package/dist/dashboard/template-variant.mjs +156 -0
  186. package/dist/icons/arrow-down-long.js +47 -0
  187. package/dist/icons/arrow-down-long.mjs +28 -0
  188. package/dist/icons/arrows-pointing-out.js +46 -0
  189. package/dist/icons/arrows-pointing-out.mjs +27 -0
  190. package/dist/icons/beaker.js +46 -0
  191. package/dist/icons/beaker.mjs +27 -0
  192. package/dist/icons/identification.js +46 -0
  193. package/dist/icons/identification.mjs +27 -0
  194. package/dist/icons/lifebuoy.js +46 -0
  195. package/dist/icons/lifebuoy.mjs +27 -0
  196. package/dist/icons/rectangle-group.js +46 -0
  197. package/dist/icons/rectangle-group.mjs +27 -0
  198. package/dist/icons/rectangle-stack.js +46 -0
  199. package/dist/icons/rectangle-stack.mjs +27 -0
  200. package/dist/icons/shopping-bag.js +46 -0
  201. package/dist/icons/shopping-bag.mjs +27 -0
  202. package/dist/icons/swatch.js +46 -0
  203. package/dist/icons/swatch.mjs +27 -0
  204. package/dist/icons/window.js +46 -0
  205. package/dist/icons/window.mjs +27 -0
  206. package/dist/icons/zoom-in.js +46 -0
  207. package/dist/icons/zoom-in.mjs +27 -0
  208. package/dist/input-answer.js +60 -0
  209. package/dist/input-answer.mjs +27 -0
  210. package/dist/input-checkbox.js +7 -1
  211. package/dist/input-checkbox.mjs +7 -1
  212. package/dist/input-name.js +3 -3
  213. package/dist/input-name.mjs +3 -3
  214. package/dist/input-select.js +3 -1
  215. package/dist/input-select.mjs +3 -1
  216. package/dist/provider-font.js +4 -3
  217. package/dist/provider-font.mjs +4 -3
  218. package/dist/shared/badge.js +15 -0
  219. package/dist/shared/badge.mjs +11 -0
  220. package/dist/shared/carousel.js +11 -7
  221. package/dist/shared/carousel.mjs +11 -7
  222. package/dist/shared/document-pieces.js +295 -0
  223. package/dist/shared/document-pieces.mjs +260 -0
  224. package/dist/shared/lib/campaign.js +18 -9
  225. package/dist/shared/lib/campaign.mjs +17 -9
  226. package/dist/shared/lib/helpers.js +24 -0
  227. package/dist/shared/lib/helpers.mjs +22 -0
  228. package/dist/shared/lib/video.js +6 -0
  229. package/dist/shared/lib/video.mjs +5 -0
  230. package/dist/shared/sortable.js +27 -10
  231. package/dist/shared/sortable.mjs +27 -10
  232. package/dist/shared/tabs.js +1 -1
  233. package/dist/shared/tabs.mjs +1 -1
  234. package/dist/video.js +127 -9
  235. package/dist/video.mjs +125 -11
  236. package/package.json +176 -20
  237. package/types/bridge/fields.d.ts +6 -1
  238. package/types/bridge/form-subdomain-agreement.d.ts +27 -0
  239. package/types/bridge/form-subdomain-missions.d.ts +2 -0
  240. package/types/bridge/form-subdomain.d.ts +62 -3
  241. package/types/bridge/lib/entry.d.ts +46 -7
  242. package/types/bridge/lib/order.d.ts +13 -2
  243. package/types/bridge/subdomain-content.d.ts +1 -0
  244. package/types/bridge/template-subdomain-gallery.d.ts +13 -1
  245. package/types/dashboard/campaign-form.d.ts +42 -0
  246. package/types/dashboard/card-campaign-agreement.d.ts +26 -0
  247. package/types/dashboard/card-campaign-switch.d.ts +13 -1
  248. package/types/dashboard/card-order.d.ts +2 -2
  249. package/types/dashboard/card-section.d.ts +9 -1
  250. package/types/dashboard/card-shortcut.d.ts +40 -0
  251. package/types/dashboard/card-tile.d.ts +4 -9
  252. package/types/dashboard/document-blocks.d.ts +14 -0
  253. package/types/dashboard/drawer.d.ts +3 -0
  254. package/types/dashboard/form-ai.d.ts +0 -17
  255. package/types/dashboard/form-organization-brand.d.ts +3 -0
  256. package/types/dashboard/form-organization-campaign-advertisements.d.ts +15 -0
  257. package/types/dashboard/form-organization-campaign-agreement.d.ts +53 -10
  258. package/types/dashboard/form-organization-campaign-design.d.ts +46 -0
  259. package/types/dashboard/form-organization-campaign-field-item.d.ts +36 -0
  260. package/types/dashboard/form-organization-campaign-field-number.d.ts +4 -1
  261. package/types/dashboard/form-organization-campaign-field-select.d.ts +6 -1
  262. package/types/dashboard/form-organization-campaign-field-skill.d.ts +36 -0
  263. package/types/dashboard/form-organization-campaign-field-text.d.ts +5 -1
  264. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +4 -1
  265. package/types/dashboard/form-organization-campaign-footer.d.ts +23 -0
  266. package/types/dashboard/form-organization-campaign-integration-age.d.ts +2 -1
  267. package/types/dashboard/form-organization-campaign-integration-geocode.d.ts +2 -0
  268. package/types/dashboard/form-organization-campaign-page.d.ts +9 -15
  269. package/types/dashboard/form-organization-campaign-section.d.ts +24 -8
  270. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  271. package/types/dashboard/form-organization-workflow.d.ts +3 -0
  272. package/types/dashboard/form-organization.d.ts +2 -2
  273. package/types/dashboard/form-reposition.d.ts +29 -0
  274. package/types/dashboard/form-support.d.ts +14 -0
  275. package/types/dashboard/form-tests.d.ts +78 -0
  276. package/types/dashboard/form-verify-prize.d.ts +30 -3
  277. package/types/dashboard/input-editor.d.ts +9 -0
  278. package/types/dashboard/input-fields.d.ts +8 -5
  279. package/types/dashboard/input-file.d.ts +4 -0
  280. package/types/dashboard/input-resource.d.ts +1 -0
  281. package/types/dashboard/lib/ab-tests.d.ts +50 -0
  282. package/types/dashboard/lib/escape.d.ts +4 -0
  283. package/types/dashboard/lib/focus.d.ts +16 -0
  284. package/types/dashboard/lib/form-page.d.ts +25 -0
  285. package/types/dashboard/lib/item-list.d.ts +10 -5
  286. package/types/dashboard/lib/rail.d.ts +0 -1
  287. package/types/dashboard/lib/sms.d.ts +7 -0
  288. package/types/dashboard/modal.d.ts +3 -1
  289. package/types/dashboard/preview.d.ts +65 -10
  290. package/types/dashboard/recharts.d.ts +3 -0
  291. package/types/dashboard/swatch.d.ts +4 -0
  292. package/types/dashboard/template-dashboard.d.ts +3 -0
  293. package/types/dashboard/template-design.d.ts +30 -0
  294. package/types/dashboard/template-test-page.d.ts +69 -0
  295. package/types/dashboard/template-tests.d.ts +30 -0
  296. package/types/dashboard/template-variant.d.ts +18 -0
  297. package/types/icons/arrow-down-long.d.ts +5 -0
  298. package/types/icons/arrows-pointing-out.d.ts +5 -0
  299. package/types/icons/beaker.d.ts +5 -0
  300. package/types/icons/identification.d.ts +5 -0
  301. package/types/icons/lifebuoy.d.ts +5 -0
  302. package/types/icons/rectangle-group.d.ts +5 -0
  303. package/types/icons/rectangle-stack.d.ts +5 -0
  304. package/types/icons/shopping-bag.d.ts +5 -0
  305. package/types/icons/swatch.d.ts +5 -0
  306. package/types/icons/window.d.ts +5 -0
  307. package/types/icons/zoom-in.d.ts +5 -0
  308. package/types/input-answer.d.ts +15 -0
  309. package/types/input-select.d.ts +2 -0
  310. package/types/shared/button.d.ts +1 -1
  311. package/types/shared/document-pieces.d.ts +34 -0
  312. package/types/shared/lib/campaign.d.ts +11 -0
  313. package/types/shared/lib/helpers.d.ts +22 -1
  314. package/types/shared/lib/motion.d.ts +2 -0
  315. package/types/shared/lib/video.d.ts +3 -0
  316. package/types/shared/sortable.d.ts +6 -0
  317. package/types/video.d.ts +18 -2
  318. package/dist/bridge/template-preview.js +0 -208
  319. package/dist/bridge/template-preview.mjs +0 -173
  320. package/dist/dashboard/device.js +0 -95
  321. package/dist/dashboard/device.mjs +0 -72
  322. package/dist/dashboard/form-organization-campaign-field-list.js +0 -425
  323. package/dist/dashboard/form-organization-campaign-field-list.mjs +0 -396
  324. package/dist/dashboard/item-row.js +0 -92
  325. package/dist/dashboard/item-row.mjs +0 -63
  326. package/types/bridge/template-preview.d.ts +0 -10
  327. package/types/dashboard/device.d.ts +0 -12
  328. package/types/dashboard/form-organization-campaign-field-list.d.ts +0 -36
  329. package/types/dashboard/item-row.d.ts +0 -25
@@ -28,11 +28,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var form_verify_prize_exports = {};
30
30
  __export(form_verify_prize_exports, {
31
+ PrizeDocument: () => PrizeDocument,
31
32
  PrizeTerms: () => PrizeTerms,
32
- default: () => form_verify_prize_default
33
+ answerKey: () => answerKey,
34
+ default: () => form_verify_prize_default,
35
+ splitValues: () => splitValues
33
36
  });
34
37
  module.exports = __toCommonJS(form_verify_prize_exports);
35
38
  var import_jsx_runtime = require("react/jsx-runtime");
39
+ var import_react = require("react");
36
40
  var import_link = __toESM(require("./link"));
37
41
  var import_form = require("../shared/lib/form");
38
42
  var import_react_query = require("@tanstack/react-query");
@@ -43,53 +47,55 @@ var import_form2 = __toESM(require("../shared/form"));
43
47
  var import_fieldset = __toESM(require("../shared/fieldset"));
44
48
  var import_form_action = __toESM(require("./form-action"));
45
49
  var import_input_group = __toESM(require("../input-group"));
50
+ var import_input_answer = __toESM(require("../input-answer"));
46
51
  var import_input_text = __toESM(require("../input-text"));
47
52
  var import_input_combobox = __toESM(require("./input-combobox"));
48
53
  var import_address_lines = __toESM(require("../shared/address-lines"));
49
54
  var import_card_data_item = __toESM(require("./card-data-item"));
50
55
  var import_button = __toESM(require("../shared/button"));
56
+ var import_arrow_left = __toESM(require("../icons/arrow-left"));
57
+ var import_form_subdomain_agreement = require("../bridge/form-subdomain-agreement");
58
+ var import_answer_rows = require("./answer-rows");
51
59
  const addressFieldNames = ["address", "address2", "city", "country", "postal", "province"];
60
+ const answerKey = (field) => (field == null ? void 0 : field.id) ? "question-" + field.id : field == null ? void 0 : field.slug;
52
61
  const buildFieldsSchema = (fields) => {
53
62
  return (fields || []).reduce(
54
63
  (accumulator, field) => {
55
- accumulator[field.slug] = import_yup.default.string().label(field.label).required();
64
+ accumulator[answerKey(field)] = field.slug === "skill" ? import_yup.default.mixed().test("answer", field.label + " is a required field", (value) => !(0, import_answer_rows.blank)(value)) : import_yup.default.string().label(field.label).required();
56
65
  return accumulator;
57
66
  },
58
67
  {}
59
68
  );
60
69
  };
61
70
  const splitValues = (values, fields) => {
62
- const slugs = new Set((fields || []).map((f) => f.slug));
63
- const fieldValues = [];
64
- const address = {};
65
- Object.entries(values || {}).forEach(([key, value]) => {
66
- if (slugs.has(key)) {
67
- fieldValues.push({
68
- slug: key,
69
- value
70
- });
71
- } else if (addressFieldNames.includes(key)) {
72
- address[key] = value;
73
- }
74
- });
71
+ const address = Object.fromEntries(Object.entries(values || {}).filter(([key]) => addressFieldNames.includes(key)));
72
+ const fieldValues = (fields || []).filter((field) => answerKey(field) in (values || {})).map((field) => ({
73
+ ...field.id && { id: field.id },
74
+ slug: field.slug,
75
+ value: (0, import_answer_rows.blank)(values[answerKey(field)]) ? values[answerKey(field)] : String(values[answerKey(field)])
76
+ }));
75
77
  return {
76
78
  address,
77
79
  fields: fieldValues
78
80
  };
79
81
  };
80
- const PrizeTerms = ({ link }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
82
+ const PrizeTerms = ({ link, onRead }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
81
83
  "You are accepting this prize",
82
- link ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
84
+ onRead || link ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
83
85
  "\xA0as agreed to in the following campaign\xA0",
84
86
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
87
  import_button.default,
86
88
  {
87
89
  ...{
88
- element: import_link.default,
89
- href: link,
90
90
  inline: true,
91
- target: "_blank",
92
- variant: "link"
91
+ variant: "link",
92
+ ...onRead ? {
93
+ onClick: onRead
94
+ } : {
95
+ element: import_link.default,
96
+ href: link,
97
+ target: "_blank"
98
+ }
93
99
  },
94
100
  children: "terms and conditions"
95
101
  }
@@ -97,6 +103,38 @@ const PrizeTerms = ({ link }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p
97
103
  ] }) : null,
98
104
  "."
99
105
  ] });
106
+ const PrizeDocument = ({ back, data, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
107
+ "div",
108
+ {
109
+ ...{
110
+ className: "space-y-6"
111
+ },
112
+ children: [
113
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
114
+ import_button.default,
115
+ {
116
+ ...{
117
+ icon: import_arrow_left.default,
118
+ inline: true,
119
+ onClick: back,
120
+ reverse: true,
121
+ variant: "link"
122
+ },
123
+ children: "Back"
124
+ }
125
+ ),
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
127
+ import_form_subdomain_agreement.AgreementDocument,
128
+ {
129
+ ...{
130
+ data,
131
+ value
132
+ }
133
+ }
134
+ )
135
+ ]
136
+ }
137
+ );
100
138
  const FormVerifyPrize = ({
101
139
  action = "Accept",
102
140
  campaign,
@@ -120,11 +158,25 @@ const FormVerifyPrize = ({
120
158
  })
121
159
  )
122
160
  });
123
- const { formState, handleSubmit } = methods;
161
+ const { formState, handleSubmit, setError } = methods;
124
162
  const onSubmit = (values) => {
125
- var _a, _b;
163
+ var _a;
126
164
  const { address, fields: fieldValues } = splitValues(values, fields);
127
- modal.open({
165
+ const terms = (_a = campaign == null ? void 0 : campaign.agreements) == null ? void 0 : _a.terms;
166
+ const read = (terms == null ? void 0 : terms.type) === "document" && (terms == null ? void 0 : terms.document) ? () => modal.open({
167
+ message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
168
+ PrizeDocument,
169
+ {
170
+ ...{
171
+ back: review,
172
+ data: campaign == null ? void 0 : campaign.documents,
173
+ value: terms.document
174
+ }
175
+ }
176
+ ),
177
+ title: "Terms and conditions"
178
+ }) : null;
179
+ const review = () => modal.open({
128
180
  message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
129
181
  import_form_action.default,
130
182
  {
@@ -143,7 +195,19 @@ const FormVerifyPrize = ({
143
195
  method: "POST",
144
196
  url: ""
145
197
  }),
146
- onError,
198
+ // @story fields/skill-testing-question
199
+ // A wrong answer goes under its question, and the winner
200
+ // tries again as often as they need.
201
+ onError: (error) => {
202
+ var _a2;
203
+ if ((_a2 = error == null ? void 0 : error.data) == null ? void 0 : _a2.fields) {
204
+ modal.close();
205
+ Object.entries(error.data.fields).forEach(([key, message]) => setError(answerKey(fields.find((field) => field.id === key) || { slug: key }), { message }));
206
+ return;
207
+ }
208
+ ;
209
+ onError(error);
210
+ },
147
211
  onSuccess
148
212
  },
149
213
  children: [
@@ -151,7 +215,8 @@ const FormVerifyPrize = ({
151
215
  PrizeTerms,
152
216
  {
153
217
  ...{
154
- link: ((_b = (_a = campaign == null ? void 0 : campaign.agreements) == null ? void 0 : _a.terms) == null ? void 0 : _b.link) || null
218
+ link: (terms == null ? void 0 : terms.link) || null,
219
+ onRead: read
155
220
  }
156
221
  }
157
222
  ),
@@ -176,11 +241,11 @@ const FormVerifyPrize = ({
176
241
  {
177
242
  ...{
178
243
  classNameSlotRight: "w-full text-right",
179
- label: ((_a2 = fields.find((f) => f.slug === fv.slug)) == null ? void 0 : _a2.label) || fv.slug,
244
+ label: ((_a2 = fields.find((f) => fv.id ? f.id === fv.id : f.slug === fv.slug)) == null ? void 0 : _a2.label) || fv.slug,
180
245
  value: fv.value
181
246
  }
182
247
  },
183
- fv.slug
248
+ fv.id || fv.slug
184
249
  );
185
250
  })
186
251
  }
@@ -210,6 +275,7 @@ const FormVerifyPrize = ({
210
275
  ),
211
276
  title
212
277
  });
278
+ review();
213
279
  };
214
280
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
215
281
  import_form.FormProvider,
@@ -249,15 +315,24 @@ const FormVerifyPrize = ({
249
315
  {
250
316
  ...{
251
317
  control: methods.control,
252
- name: field.slug,
318
+ name: answerKey(field),
253
319
  render: ({ field: { value, onChange } }) => {
254
320
  var _a, _b, _c, _d;
255
321
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
256
322
  import_input_group.default,
257
323
  {
258
324
  ...{
259
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[field.slug]) == null ? void 0 : _b.message,
260
- input: field.feature === "campaign:field:select" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
325
+ error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[answerKey(field)]) == null ? void 0 : _b.message,
326
+ input: field.slug === "skill" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
327
+ import_input_answer.default,
328
+ {
329
+ ...{
330
+ label: field.label,
331
+ onChange,
332
+ value
333
+ }
334
+ }
335
+ ) : field.feature === "campaign:field:select" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
261
336
  import_input_combobox.default,
262
337
  {
263
338
  ...{
@@ -285,14 +360,16 @@ const FormVerifyPrize = ({
285
360
  }
286
361
  }
287
362
  ),
288
- label: field.label
363
+ // @story winner-verification/claim-prize
364
+ // Every prize question is required, so its label ends with *.
365
+ label: field.label + " *"
289
366
  }
290
367
  }
291
368
  );
292
369
  }
293
370
  }
294
371
  },
295
- field.slug
372
+ answerKey(field)
296
373
  ))
297
374
  ]
298
375
  }
@@ -338,5 +415,8 @@ const FormVerifyPrize = ({
338
415
  var form_verify_prize_default = FormVerifyPrize;
339
416
  // Annotate the CommonJS export names for ESM import in node:
340
417
  0 && (module.exports = {
341
- PrizeTerms
418
+ PrizeDocument,
419
+ PrizeTerms,
420
+ answerKey,
421
+ splitValues
342
422
  });
@@ -1,5 +1,6 @@
1
1
  "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Fragment } from "react";
3
4
  import Link from "./link.mjs";
4
5
  import { useForm, FormProvider, Controller } from "../shared/lib/form.mjs";
5
6
  import { useQueryClient } from "@tanstack/react-query";
@@ -10,53 +11,55 @@ import Form from "../shared/form.mjs";
10
11
  import Fieldset from "../shared/fieldset.mjs";
11
12
  import FormAction from "./form-action.mjs";
12
13
  import InputGroup from "../input-group.mjs";
14
+ import InputAnswer from "../input-answer.mjs";
13
15
  import InputText from "../input-text.mjs";
14
16
  import InputCombobox from "./input-combobox.mjs";
15
17
  import AddressLines from "../shared/address-lines.mjs";
16
18
  import CardDataItem from "./card-data-item.mjs";
17
19
  import Button from "../shared/button.mjs";
20
+ import ArrowLeft from "../icons/arrow-left.mjs";
21
+ import { AgreementDocument } from "../bridge/form-subdomain-agreement.mjs";
22
+ import { blank } from "./answer-rows.mjs";
18
23
  const addressFieldNames = ["address", "address2", "city", "country", "postal", "province"];
24
+ const answerKey = (field) => (field == null ? void 0 : field.id) ? "question-" + field.id : field == null ? void 0 : field.slug;
19
25
  const buildFieldsSchema = (fields) => {
20
26
  return (fields || []).reduce(
21
27
  (accumulator, field) => {
22
- accumulator[field.slug] = yup.string().label(field.label).required();
28
+ accumulator[answerKey(field)] = field.slug === "skill" ? yup.mixed().test("answer", field.label + " is a required field", (value) => !blank(value)) : yup.string().label(field.label).required();
23
29
  return accumulator;
24
30
  },
25
31
  {}
26
32
  );
27
33
  };
28
34
  const splitValues = (values, fields) => {
29
- const slugs = new Set((fields || []).map((f) => f.slug));
30
- const fieldValues = [];
31
- const address = {};
32
- Object.entries(values || {}).forEach(([key, value]) => {
33
- if (slugs.has(key)) {
34
- fieldValues.push({
35
- slug: key,
36
- value
37
- });
38
- } else if (addressFieldNames.includes(key)) {
39
- address[key] = value;
40
- }
41
- });
35
+ const address = Object.fromEntries(Object.entries(values || {}).filter(([key]) => addressFieldNames.includes(key)));
36
+ const fieldValues = (fields || []).filter((field) => answerKey(field) in (values || {})).map((field) => ({
37
+ ...field.id && { id: field.id },
38
+ slug: field.slug,
39
+ value: blank(values[answerKey(field)]) ? values[answerKey(field)] : String(values[answerKey(field)])
40
+ }));
42
41
  return {
43
42
  address,
44
43
  fields: fieldValues
45
44
  };
46
45
  };
47
- const PrizeTerms = ({ link }) => /* @__PURE__ */ jsxs("p", { children: [
46
+ const PrizeTerms = ({ link, onRead }) => /* @__PURE__ */ jsxs("p", { children: [
48
47
  "You are accepting this prize",
49
- link ? /* @__PURE__ */ jsxs(Fragment, { children: [
48
+ onRead || link ? /* @__PURE__ */ jsxs(Fragment, { children: [
50
49
  "\xA0as agreed to in the following campaign\xA0",
51
50
  /* @__PURE__ */ jsx(
52
51
  Button,
53
52
  {
54
53
  ...{
55
- element: Link,
56
- href: link,
57
54
  inline: true,
58
- target: "_blank",
59
- variant: "link"
55
+ variant: "link",
56
+ ...onRead ? {
57
+ onClick: onRead
58
+ } : {
59
+ element: Link,
60
+ href: link,
61
+ target: "_blank"
62
+ }
60
63
  },
61
64
  children: "terms and conditions"
62
65
  }
@@ -64,6 +67,38 @@ const PrizeTerms = ({ link }) => /* @__PURE__ */ jsxs("p", { children: [
64
67
  ] }) : null,
65
68
  "."
66
69
  ] });
70
+ const PrizeDocument = ({ back, data, value }) => /* @__PURE__ */ jsxs(
71
+ "div",
72
+ {
73
+ ...{
74
+ className: "space-y-6"
75
+ },
76
+ children: [
77
+ /* @__PURE__ */ jsx(
78
+ Button,
79
+ {
80
+ ...{
81
+ icon: ArrowLeft,
82
+ inline: true,
83
+ onClick: back,
84
+ reverse: true,
85
+ variant: "link"
86
+ },
87
+ children: "Back"
88
+ }
89
+ ),
90
+ /* @__PURE__ */ jsx(
91
+ AgreementDocument,
92
+ {
93
+ ...{
94
+ data,
95
+ value
96
+ }
97
+ }
98
+ )
99
+ ]
100
+ }
101
+ );
67
102
  const FormVerifyPrize = ({
68
103
  action = "Accept",
69
104
  campaign,
@@ -87,11 +122,25 @@ const FormVerifyPrize = ({
87
122
  })
88
123
  )
89
124
  });
90
- const { formState, handleSubmit } = methods;
125
+ const { formState, handleSubmit, setError } = methods;
91
126
  const onSubmit = (values) => {
92
- var _a, _b;
127
+ var _a;
93
128
  const { address, fields: fieldValues } = splitValues(values, fields);
94
- modal.open({
129
+ const terms = (_a = campaign == null ? void 0 : campaign.agreements) == null ? void 0 : _a.terms;
130
+ const read = (terms == null ? void 0 : terms.type) === "document" && (terms == null ? void 0 : terms.document) ? () => modal.open({
131
+ message: /* @__PURE__ */ jsx(
132
+ PrizeDocument,
133
+ {
134
+ ...{
135
+ back: review,
136
+ data: campaign == null ? void 0 : campaign.documents,
137
+ value: terms.document
138
+ }
139
+ }
140
+ ),
141
+ title: "Terms and conditions"
142
+ }) : null;
143
+ const review = () => modal.open({
95
144
  message: /* @__PURE__ */ jsxs(
96
145
  FormAction,
97
146
  {
@@ -110,7 +159,19 @@ const FormVerifyPrize = ({
110
159
  method: "POST",
111
160
  url: ""
112
161
  }),
113
- onError,
162
+ // @story fields/skill-testing-question
163
+ // A wrong answer goes under its question, and the winner
164
+ // tries again as often as they need.
165
+ onError: (error) => {
166
+ var _a2;
167
+ if ((_a2 = error == null ? void 0 : error.data) == null ? void 0 : _a2.fields) {
168
+ modal.close();
169
+ Object.entries(error.data.fields).forEach(([key, message]) => setError(answerKey(fields.find((field) => field.id === key) || { slug: key }), { message }));
170
+ return;
171
+ }
172
+ ;
173
+ onError(error);
174
+ },
114
175
  onSuccess
115
176
  },
116
177
  children: [
@@ -118,7 +179,8 @@ const FormVerifyPrize = ({
118
179
  PrizeTerms,
119
180
  {
120
181
  ...{
121
- link: ((_b = (_a = campaign == null ? void 0 : campaign.agreements) == null ? void 0 : _a.terms) == null ? void 0 : _b.link) || null
182
+ link: (terms == null ? void 0 : terms.link) || null,
183
+ onRead: read
122
184
  }
123
185
  }
124
186
  ),
@@ -143,11 +205,11 @@ const FormVerifyPrize = ({
143
205
  {
144
206
  ...{
145
207
  classNameSlotRight: "w-full text-right",
146
- label: ((_a2 = fields.find((f) => f.slug === fv.slug)) == null ? void 0 : _a2.label) || fv.slug,
208
+ label: ((_a2 = fields.find((f) => fv.id ? f.id === fv.id : f.slug === fv.slug)) == null ? void 0 : _a2.label) || fv.slug,
147
209
  value: fv.value
148
210
  }
149
211
  },
150
- fv.slug
212
+ fv.id || fv.slug
151
213
  );
152
214
  })
153
215
  }
@@ -177,6 +239,7 @@ const FormVerifyPrize = ({
177
239
  ),
178
240
  title
179
241
  });
242
+ review();
180
243
  };
181
244
  return /* @__PURE__ */ jsx(
182
245
  FormProvider,
@@ -216,15 +279,24 @@ const FormVerifyPrize = ({
216
279
  {
217
280
  ...{
218
281
  control: methods.control,
219
- name: field.slug,
282
+ name: answerKey(field),
220
283
  render: ({ field: { value, onChange } }) => {
221
284
  var _a, _b, _c, _d;
222
285
  return /* @__PURE__ */ jsx(
223
286
  InputGroup,
224
287
  {
225
288
  ...{
226
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[field.slug]) == null ? void 0 : _b.message,
227
- input: field.feature === "campaign:field:select" ? /* @__PURE__ */ jsx(
289
+ error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[answerKey(field)]) == null ? void 0 : _b.message,
290
+ input: field.slug === "skill" ? /* @__PURE__ */ jsx(
291
+ InputAnswer,
292
+ {
293
+ ...{
294
+ label: field.label,
295
+ onChange,
296
+ value
297
+ }
298
+ }
299
+ ) : field.feature === "campaign:field:select" ? /* @__PURE__ */ jsx(
228
300
  InputCombobox,
229
301
  {
230
302
  ...{
@@ -252,14 +324,16 @@ const FormVerifyPrize = ({
252
324
  }
253
325
  }
254
326
  ),
255
- label: field.label
327
+ // @story winner-verification/claim-prize
328
+ // Every prize question is required, so its label ends with *.
329
+ label: field.label + " *"
256
330
  }
257
331
  }
258
332
  );
259
333
  }
260
334
  }
261
335
  },
262
- field.slug
336
+ answerKey(field)
263
337
  ))
264
338
  ]
265
339
  }
@@ -304,6 +378,9 @@ const FormVerifyPrize = ({
304
378
  };
305
379
  var form_verify_prize_default = FormVerifyPrize;
306
380
  export {
381
+ PrizeDocument,
307
382
  PrizeTerms,
308
- form_verify_prize_default as default
383
+ answerKey,
384
+ form_verify_prize_default as default,
385
+ splitValues
309
386
  };
@@ -434,6 +434,7 @@ const InputMapControlPlaces = ({
434
434
  const place = event == null ? void 0 : event.placePrediction.toPlace();
435
435
  await place.fetchFields({
436
436
  fields: [
437
+ "formattedAddress",
437
438
  "location"
438
439
  ]
439
440
  });
@@ -443,7 +444,8 @@ const InputMapControlPlaces = ({
443
444
  ].filter(Boolean);
444
445
  if ((coordinates == null ? void 0 : coordinates.length) > 0) {
445
446
  onSuccess({
446
- coordinates
447
+ coordinates,
448
+ place: (place == null ? void 0 : place.formattedAddress) || null
447
449
  });
448
450
  }
449
451
  } catch (error) {
@@ -609,7 +611,12 @@ const InputMap = ({
609
611
  {
610
612
  ...{
611
613
  coordinates: value == null ? void 0 : value.coordinates,
614
+ // Resizing the circle keeps the place's name; moving it to
615
+ // another point drops the name, which no longer says where.
612
616
  onCircleChanged: (object) => onChange({
617
+ ...String(object == null ? void 0 : object.coordinates) === String(value == null ? void 0 : value.coordinates) && {
618
+ place: value == null ? void 0 : value.place
619
+ },
613
620
  ...object,
614
621
  zoom
615
622
  }),
@@ -401,6 +401,7 @@ const InputMapControlPlaces = ({
401
401
  const place = event == null ? void 0 : event.placePrediction.toPlace();
402
402
  await place.fetchFields({
403
403
  fields: [
404
+ "formattedAddress",
404
405
  "location"
405
406
  ]
406
407
  });
@@ -410,7 +411,8 @@ const InputMapControlPlaces = ({
410
411
  ].filter(Boolean);
411
412
  if ((coordinates == null ? void 0 : coordinates.length) > 0) {
412
413
  onSuccess({
413
- coordinates
414
+ coordinates,
415
+ place: (place == null ? void 0 : place.formattedAddress) || null
414
416
  });
415
417
  }
416
418
  } catch (error) {
@@ -576,7 +578,12 @@ const InputMap = ({
576
578
  {
577
579
  ...{
578
580
  coordinates: value == null ? void 0 : value.coordinates,
581
+ // Resizing the circle keeps the place's name; moving it to
582
+ // another point drops the name, which no longer says where.
579
583
  onCircleChanged: (object) => onChange({
584
+ ...String(object == null ? void 0 : object.coordinates) === String(value == null ? void 0 : value.coordinates) && {
585
+ place: value == null ? void 0 : value.place
586
+ },
580
587
  ...object,
581
588
  zoom
582
589
  }),
@@ -174,6 +174,7 @@ const InputArraySortable = ({
174
174
  children,
175
175
  control,
176
176
  empty = "No items added",
177
+ handleLabel,
177
178
  name,
178
179
  onSort,
179
180
  renderButton,
@@ -199,6 +200,7 @@ const InputArraySortable = ({
199
200
  import_sortable.default,
200
201
  {
201
202
  ...{
203
+ handleLabel,
202
204
  items: fields,
203
205
  onSort: (array, { from, to }) => {
204
206
  move(from, to);
@@ -139,6 +139,7 @@ const InputArraySortable = ({
139
139
  children,
140
140
  control,
141
141
  empty = "No items added",
142
+ handleLabel,
142
143
  name,
143
144
  onSort,
144
145
  renderButton,
@@ -164,6 +165,7 @@ const InputArraySortable = ({
164
165
  Sortable,
165
166
  {
166
167
  ...{
168
+ handleLabel,
167
169
  items: fields,
168
170
  onSort: (array, { from, to }) => {
169
171
  move(from, to);