@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
@@ -1,13 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { request } from "@drawbridge/drawbridge-utils/fetch";
3
- import { useForm, FormProvider, Controller } from "../shared/lib/form.mjs";
3
+ import { useForm, FormProvider } from "../shared/lib/form.mjs";
4
4
  import yup, { resolver } from "../shared/lib/yup.mjs";
5
5
  import { InputFieldsCampaign, schemas } from "./input-fields.mjs";
6
- import { useQueryClient } from "@tanstack/react-query";
7
6
  import Form from "../shared/form.mjs";
8
7
  import Fieldset from "../shared/fieldset.mjs";
9
- import InputGroup from "../input-group.mjs";
10
- import InputCombobox from "./input-combobox.mjs";
11
8
  import Button from "../shared/button.mjs";
12
9
  const FormAdminCampaign = ({
13
10
  disabled,
@@ -15,36 +12,41 @@ const FormAdminCampaign = ({
15
12
  onError,
16
13
  values
17
14
  }) => {
18
- var _a;
19
- const queryClient = useQueryClient();
20
- const app = queryClient.getQueryData(["app"]);
15
+ var _a, _b;
21
16
  const methods = useForm({
22
17
  // Reactive `values` (not `defaultValues`): this form stays mounted on
23
18
  // the admin campaign page, so the save-then-refetch cycle must rebase
24
19
  // the baseline or the unsaved-changes guard would stay armed.
20
+ // @story campaigns/giveaway-module
21
+ // The two switches, read off the campaign; the api applies the rule
22
+ // between them again on the PUT.
25
23
  values: {
26
24
  ...values,
27
- type: (_a = values == null ? void 0 : values.type) == null ? void 0 : _a.value
25
+ form: Boolean((_a = values == null ? void 0 : values.form) == null ? void 0 : _a.enabled),
26
+ giveaway: Boolean((_b = values == null ? void 0 : values.giveaway) == null ? void 0 : _b.enabled)
28
27
  },
29
28
  resolver: resolver(
30
29
  yup.object({
31
- ...schemas.campaign({ typeEnum: app.enums.campaign.type.enum }),
32
- status: yup.string().label("Status").required().oneOf(app.enums.campaign.status.enum)
30
+ ...schemas.campaign()
33
31
  })
34
32
  )
35
33
  });
36
34
  const { control, handleSubmit, formState } = methods;
37
35
  const onSubmit = async ({
38
- status,
39
- title,
40
- type
36
+ form,
37
+ giveaway,
38
+ title
41
39
  }) => {
42
40
  try {
43
41
  const response = await request({
44
42
  body: {
45
- status,
46
- title,
47
- type
43
+ form: {
44
+ enabled: form
45
+ },
46
+ giveaway: {
47
+ enabled: giveaway
48
+ },
49
+ title
48
50
  },
49
51
  endpoint: "/admin/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.id),
50
52
  method: "PUT"
@@ -62,46 +64,13 @@ const FormAdminCampaign = ({
62
64
  onSubmit: handleSubmit(onSubmit)
63
65
  },
64
66
  children: [
65
- /* @__PURE__ */ jsxs(
67
+ /* @__PURE__ */ jsx(
66
68
  Fieldset,
67
69
  {
68
70
  ...{
69
71
  disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
70
72
  },
71
- children: [
72
- /* @__PURE__ */ jsx(InputFieldsCampaign, {}),
73
- /* @__PURE__ */ jsx(
74
- Controller,
75
- {
76
- ...{
77
- control,
78
- name: "status",
79
- render: ({ field: { value, onChange } }) => {
80
- var _a2, _b;
81
- return /* @__PURE__ */ jsx(
82
- InputGroup,
83
- {
84
- ...{
85
- error: (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.status) == null ? void 0 : _b.message,
86
- input: /* @__PURE__ */ jsx(
87
- InputCombobox,
88
- {
89
- ...{
90
- onChange,
91
- options: app.enums.campaign.status.options,
92
- value
93
- }
94
- }
95
- ),
96
- label: "Status"
97
- }
98
- }
99
- );
100
- }
101
- }
102
- }
103
- )
104
- ]
73
+ children: /* @__PURE__ */ jsx(InputFieldsCampaign, {})
105
74
  }
106
75
  ),
107
76
  /* @__PURE__ */ jsx(
@@ -201,32 +201,35 @@ const FormAiCampaign = ({
201
201
  onSuccess,
202
202
  values
203
203
  }) => {
204
- const queryClient = (0, import_react_query.useQueryClient)();
205
- const app = queryClient.getQueryData(["app"]);
206
204
  const methods = (0, import_form.useForm)({
207
205
  guard: false,
208
206
  resolver: (0, import_yup.resolver)(
209
207
  import_yup.default.object({
210
- ...import_input_fields.schemas.campaign({ typeEnum: app.enums.campaign.type.enum }),
208
+ ...import_input_fields.schemas.campaign(),
211
209
  url: import_yup.default.string().label("Url").max(150).matches(import_drawbridge_utils.regex.url, "Url must start with https").required().url()
212
210
  })
213
211
  ),
212
+ // @story campaigns/generate-ai
213
+ // Both switches start on.
214
214
  values: {
215
- type: "giveaway",
215
+ form: true,
216
+ giveaway: true,
216
217
  ...values
217
218
  }
218
219
  });
219
220
  const { control, formState, handleSubmit } = methods;
220
221
  const onSubmit = async ({
222
+ form,
223
+ giveaway,
221
224
  title,
222
- type,
223
225
  url
224
226
  }) => {
225
227
  try {
226
228
  const args = {
227
229
  body: {
230
+ form,
231
+ giveaway,
228
232
  title,
229
- type,
230
233
  url
231
234
  },
232
235
  endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/ai/campaign",
@@ -165,32 +165,35 @@ const FormAiCampaign = ({
165
165
  onSuccess,
166
166
  values
167
167
  }) => {
168
- const queryClient = useQueryClient();
169
- const app = queryClient.getQueryData(["app"]);
170
168
  const methods = useForm({
171
169
  guard: false,
172
170
  resolver: resolver(
173
171
  yup.object({
174
- ...schemas.campaign({ typeEnum: app.enums.campaign.type.enum }),
172
+ ...schemas.campaign(),
175
173
  url: yup.string().label("Url").max(150).matches(regex.url, "Url must start with https").required().url()
176
174
  })
177
175
  ),
176
+ // @story campaigns/generate-ai
177
+ // Both switches start on.
178
178
  values: {
179
- type: "giveaway",
179
+ form: true,
180
+ giveaway: true,
180
181
  ...values
181
182
  }
182
183
  });
183
184
  const { control, formState, handleSubmit } = methods;
184
185
  const onSubmit = async ({
186
+ form,
187
+ giveaway,
185
188
  title,
186
- type,
187
189
  url
188
190
  }) => {
189
191
  try {
190
192
  const args = {
191
193
  body: {
194
+ form,
195
+ giveaway,
192
196
  title,
193
- type,
194
197
  url
195
198
  },
196
199
  endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/ai/campaign",
@@ -552,7 +552,7 @@ const FormProviders = ({
552
552
  referrer,
553
553
  utm = null
554
554
  }) => {
555
- var _a;
555
+ var _a, _b;
556
556
  const query = (0, import_react_query.useQuery)({
557
557
  queryKey: ["auth-providers"],
558
558
  queryFn: async () => {
@@ -562,31 +562,41 @@ const FormProviders = ({
562
562
  return result || {};
563
563
  }
564
564
  });
565
- if (query.isError) return null;
566
- if (query.isSuccess && Object.keys(((_a = query.data) == null ? void 0 : _a.providers) || {}).length === 0) return null;
567
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
568
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
569
- FormAuthGoogle,
570
- {
571
- ...{
572
- action,
573
- ready: query.isSuccess,
574
- redirectTo,
575
- referrer,
576
- utm
565
+ if (query.isError || query.isSuccess && !((_b = (_a = query.data) == null ? void 0 : _a.providers) == null ? void 0 : _b.google)) return null;
566
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
567
+ "div",
568
+ {
569
+ ...{
570
+ className: query.isSuccess ? "contents" : "contents invisible",
571
+ ...!query.isSuccess && {
572
+ "aria-hidden": true
577
573
  }
578
- }
579
- ),
580
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
581
- import_divider.default,
582
- {
583
- ...{
584
- classNameLabel: "bg-gray-light"
585
- },
586
- children: "or"
587
- }
588
- )
589
- ] });
574
+ },
575
+ children: [
576
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
577
+ FormAuthGoogle,
578
+ {
579
+ ...{
580
+ action,
581
+ ready: query.isSuccess,
582
+ redirectTo,
583
+ referrer,
584
+ utm
585
+ }
586
+ }
587
+ ),
588
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
589
+ import_divider.default,
590
+ {
591
+ ...{
592
+ classNameLabel: "bg-gray-light"
593
+ },
594
+ children: "or"
595
+ }
596
+ )
597
+ ]
598
+ }
599
+ );
590
600
  };
591
601
  // Annotate the CommonJS export names for ESM import in node:
592
602
  0 && (module.exports = {
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Fragment, useEffect } from "react";
2
+ import { useEffect } from "react";
3
3
  import { useForm, Controller } from "../shared/lib/form.mjs";
4
4
  import { useMutation, useQuery } from "@tanstack/react-query";
5
5
  import { useGoogleReCaptcha } from "react-google-recaptcha-v3";
@@ -517,7 +517,7 @@ const FormProviders = ({
517
517
  referrer,
518
518
  utm = null
519
519
  }) => {
520
- var _a;
520
+ var _a, _b;
521
521
  const query = useQuery({
522
522
  queryKey: ["auth-providers"],
523
523
  queryFn: async () => {
@@ -527,31 +527,41 @@ const FormProviders = ({
527
527
  return result || {};
528
528
  }
529
529
  });
530
- if (query.isError) return null;
531
- if (query.isSuccess && Object.keys(((_a = query.data) == null ? void 0 : _a.providers) || {}).length === 0) return null;
532
- return /* @__PURE__ */ jsxs(Fragment, { children: [
533
- /* @__PURE__ */ jsx(
534
- FormAuthGoogle,
535
- {
536
- ...{
537
- action,
538
- ready: query.isSuccess,
539
- redirectTo,
540
- referrer,
541
- utm
530
+ if (query.isError || query.isSuccess && !((_b = (_a = query.data) == null ? void 0 : _a.providers) == null ? void 0 : _b.google)) return null;
531
+ return /* @__PURE__ */ jsxs(
532
+ "div",
533
+ {
534
+ ...{
535
+ className: query.isSuccess ? "contents" : "contents invisible",
536
+ ...!query.isSuccess && {
537
+ "aria-hidden": true
542
538
  }
543
- }
544
- ),
545
- /* @__PURE__ */ jsx(
546
- Divider,
547
- {
548
- ...{
549
- classNameLabel: "bg-gray-light"
550
- },
551
- children: "or"
552
- }
553
- )
554
- ] });
539
+ },
540
+ children: [
541
+ /* @__PURE__ */ jsx(
542
+ FormAuthGoogle,
543
+ {
544
+ ...{
545
+ action,
546
+ ready: query.isSuccess,
547
+ redirectTo,
548
+ referrer,
549
+ utm
550
+ }
551
+ }
552
+ ),
553
+ /* @__PURE__ */ jsx(
554
+ Divider,
555
+ {
556
+ ...{
557
+ classNameLabel: "bg-gray-light"
558
+ },
559
+ children: "or"
560
+ }
561
+ )
562
+ ]
563
+ }
564
+ );
555
565
  };
556
566
  export {
557
567
  FormAuthEmail,
@@ -198,9 +198,18 @@ const FileSelect = ({
198
198
  endpoint: endpoint + "/files",
199
199
  params,
200
200
  queryKey: ["file-list", endpoint, params],
201
+ // The picker opens in a modal, which is white: the grey box.
201
202
  empty: (query) => {
202
203
  var _a;
203
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_empty.default, { children: ((_a = query == null ? void 0 : query.error) == null ? void 0 : _a.message) || "No files found" });
204
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
205
+ import_empty.default,
206
+ {
207
+ ...{
208
+ variant: "secondary"
209
+ },
210
+ children: ((_a = query == null ? void 0 : query.error) == null ? void 0 : _a.message) || "No files found"
211
+ }
212
+ );
204
213
  }
205
214
  },
206
215
  children: ({ items, pageInfo }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
@@ -166,9 +166,18 @@ const FileSelect = ({
166
166
  endpoint: endpoint + "/files",
167
167
  params,
168
168
  queryKey: ["file-list", endpoint, params],
169
+ // The picker opens in a modal, which is white: the grey box.
169
170
  empty: (query) => {
170
171
  var _a;
171
- return /* @__PURE__ */ jsx(Empty, { children: ((_a = query == null ? void 0 : query.error) == null ? void 0 : _a.message) || "No files found" });
172
+ return /* @__PURE__ */ jsx(
173
+ Empty,
174
+ {
175
+ ...{
176
+ variant: "secondary"
177
+ },
178
+ children: ((_a = query == null ? void 0 : query.error) == null ? void 0 : _a.message) || "No files found"
179
+ }
180
+ );
172
181
  }
173
182
  },
174
183
  children: ({ items, pageInfo }) => /* @__PURE__ */ jsxs(
@@ -50,6 +50,8 @@ const FormFiltersAnalytics = ({
50
50
  }) => {
51
51
  const [dateMode, setDateMode] = (0, import_react.useState)((filters == null ? void 0 : filters.start) ? 1 : 0);
52
52
  const now = /* @__PURE__ */ new Date();
53
+ const thisMonth = String(now.getMonth() + 1).padStart(2, "0");
54
+ const today = now.getFullYear() + "-" + thisMonth + "-" + String(now.getDate()).padStart(2, "0");
53
55
  const { control, handleSubmit, formState, register, setValue } = (0, import_form.useForm)({
54
56
  // Filters aren't unsaved data. Guarded, the trap it pushed took the
55
57
  // ?filters= that Filter wrote, and closing the drawer stepped back off
@@ -64,6 +66,15 @@ const FormFiltersAnalytics = ({
64
66
  }
65
67
  });
66
68
  register("filters");
69
+ const year = (0, import_form.useWatch)({ control, name: "filters.year", defaultValue: filters == null ? void 0 : filters.year }) || now.getFullYear();
70
+ const month = (0, import_form.useWatch)({ control, name: "filters.month", defaultValue: filters == null ? void 0 : filters.month });
71
+ const isThisYear = Number(year) === now.getFullYear();
72
+ (0, import_react.useEffect)(
73
+ () => {
74
+ if (isThisYear && month > thisMonth) setValue("filters.month", thisMonth);
75
+ },
76
+ [isThisYear, month, setValue, thisMonth]
77
+ );
67
78
  const dateRangeStart = (0, import_form.useWatch)({ control, name: "filters.start", defaultValue: filters == null ? void 0 : filters.start }) || "";
68
79
  const dateRangeEnd = (0, import_form.useWatch)({ control, name: "filters.end", defaultValue: filters == null ? void 0 : filters.end }) || "";
69
80
  const campaign = (0, import_form.useWatch)({ control, name: "filters.campaign", defaultValue: filters == null ? void 0 : filters.campaign }) || null;
@@ -123,7 +134,8 @@ const FormFiltersAnalytics = ({
123
134
  {
124
135
  ...{
125
136
  onChange,
126
- options,
137
+ // The list as given unless a later month has to go.
138
+ options: key === "month" && isThisYear && (options || []).some((option) => option.value > thisMonth) ? options.filter((option) => option.value <= thisMonth) : options,
127
139
  searchable: Boolean(searchable),
128
140
  // An unset filter is undefined; the "all" option's
129
141
  // value is '' so it shows as selected by default.
@@ -239,6 +251,7 @@ const FormFiltersAnalytics = ({
239
251
  import_input_date.InputDateRange,
240
252
  {
241
253
  ...{
254
+ max: today,
242
255
  value: {
243
256
  start: dateRangeStart,
244
257
  end: dateRangeEnd
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
2
+ import { useEffect, useState } from "react";
3
3
  import { useForm, useWatch, Controller } from "../shared/lib/form.mjs";
4
4
  import { capitalize } from "@drawbridge/drawbridge-utils";
5
5
  import Form from "../shared/form.mjs";
@@ -18,6 +18,8 @@ const FormFiltersAnalytics = ({
18
18
  }) => {
19
19
  const [dateMode, setDateMode] = useState((filters == null ? void 0 : filters.start) ? 1 : 0);
20
20
  const now = /* @__PURE__ */ new Date();
21
+ const thisMonth = String(now.getMonth() + 1).padStart(2, "0");
22
+ const today = now.getFullYear() + "-" + thisMonth + "-" + String(now.getDate()).padStart(2, "0");
21
23
  const { control, handleSubmit, formState, register, setValue } = useForm({
22
24
  // Filters aren't unsaved data. Guarded, the trap it pushed took the
23
25
  // ?filters= that Filter wrote, and closing the drawer stepped back off
@@ -32,6 +34,15 @@ const FormFiltersAnalytics = ({
32
34
  }
33
35
  });
34
36
  register("filters");
37
+ const year = useWatch({ control, name: "filters.year", defaultValue: filters == null ? void 0 : filters.year }) || now.getFullYear();
38
+ const month = useWatch({ control, name: "filters.month", defaultValue: filters == null ? void 0 : filters.month });
39
+ const isThisYear = Number(year) === now.getFullYear();
40
+ useEffect(
41
+ () => {
42
+ if (isThisYear && month > thisMonth) setValue("filters.month", thisMonth);
43
+ },
44
+ [isThisYear, month, setValue, thisMonth]
45
+ );
35
46
  const dateRangeStart = useWatch({ control, name: "filters.start", defaultValue: filters == null ? void 0 : filters.start }) || "";
36
47
  const dateRangeEnd = useWatch({ control, name: "filters.end", defaultValue: filters == null ? void 0 : filters.end }) || "";
37
48
  const campaign = useWatch({ control, name: "filters.campaign", defaultValue: filters == null ? void 0 : filters.campaign }) || null;
@@ -91,7 +102,8 @@ const FormFiltersAnalytics = ({
91
102
  {
92
103
  ...{
93
104
  onChange,
94
- options,
105
+ // The list as given unless a later month has to go.
106
+ options: key === "month" && isThisYear && (options || []).some((option) => option.value > thisMonth) ? options.filter((option) => option.value <= thisMonth) : options,
95
107
  searchable: Boolean(searchable),
96
108
  // An unset filter is undefined; the "all" option's
97
109
  // value is '' so it shows as selected by default.
@@ -207,6 +219,7 @@ const FormFiltersAnalytics = ({
207
219
  InputDateRange,
208
220
  {
209
221
  ...{
222
+ max: today,
210
223
  value: {
211
224
  start: dateRangeStart,
212
225
  end: dateRangeEnd
@@ -71,14 +71,19 @@ const FormOrganizationCampaignAdvertisementEdit = ({
71
71
  schema.url = import_yup.default.string().label("Url").max(150).matches(import_drawbridge_utils.regex.url, "Url must start with https").required().url();
72
72
  }
73
73
  ;
74
- const { control, handleSubmit, formState, getValues } = (0, import_form.useForm)({
74
+ const { control, handleSubmit, formState, getValues, setValue } = (0, import_form.useForm)({
75
75
  resolver: (0, import_yup.resolver)(
76
76
  import_yup.default.object(schema)
77
77
  ),
78
78
  values
79
79
  });
80
+ const described = (0, import_form.useWatch)({
81
+ control,
82
+ name: "descriptions.asset"
83
+ });
80
84
  const onSubmit = async ({
81
85
  action,
86
+ descriptions,
82
87
  file,
83
88
  status,
84
89
  title,
@@ -90,6 +95,10 @@ const FormOrganizationCampaignAdvertisementEdit = ({
90
95
  body: {
91
96
  action,
92
97
  asset: file == null ? void 0 : file.id,
98
+ // A product's ad has no Image or video field, so nothing to send.
99
+ ...!(values == null ? void 0 : values.product) && {
100
+ descriptions: descriptions || {}
101
+ },
93
102
  status,
94
103
  title,
95
104
  url,
@@ -309,6 +318,7 @@ const FormOrganizationCampaignAdvertisementEdit = ({
309
318
  import_input_file.default,
310
319
  {
311
320
  ...{
321
+ description: described,
312
322
  endpoint: "/organization/" + values.organization,
313
323
  organization,
314
324
  onChange: (val) => {
@@ -317,6 +327,10 @@ const FormOrganizationCampaignAdvertisementEdit = ({
317
327
  file: val
318
328
  });
319
329
  },
330
+ onDescription: (text) => {
331
+ setValue("descriptions.asset", text, { shouldDirty: true });
332
+ preview();
333
+ },
320
334
  type: "media",
321
335
  value: value || ""
322
336
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { request } from "@drawbridge/drawbridge-utils/fetch";
3
- import { useForm, Controller } from "../shared/lib/form.mjs";
3
+ import { useForm, Controller, useWatch } from "../shared/lib/form.mjs";
4
4
  import yup, { resolver } from "../shared/lib/yup.mjs";
5
5
  import { useQueryClient } from "@tanstack/react-query";
6
6
  import { regex } from "@drawbridge/drawbridge-utils";
@@ -38,14 +38,19 @@ const FormOrganizationCampaignAdvertisementEdit = ({
38
38
  schema.url = yup.string().label("Url").max(150).matches(regex.url, "Url must start with https").required().url();
39
39
  }
40
40
  ;
41
- const { control, handleSubmit, formState, getValues } = useForm({
41
+ const { control, handleSubmit, formState, getValues, setValue } = useForm({
42
42
  resolver: resolver(
43
43
  yup.object(schema)
44
44
  ),
45
45
  values
46
46
  });
47
+ const described = useWatch({
48
+ control,
49
+ name: "descriptions.asset"
50
+ });
47
51
  const onSubmit = async ({
48
52
  action,
53
+ descriptions,
49
54
  file,
50
55
  status,
51
56
  title,
@@ -57,6 +62,10 @@ const FormOrganizationCampaignAdvertisementEdit = ({
57
62
  body: {
58
63
  action,
59
64
  asset: file == null ? void 0 : file.id,
65
+ // A product's ad has no Image or video field, so nothing to send.
66
+ ...!(values == null ? void 0 : values.product) && {
67
+ descriptions: descriptions || {}
68
+ },
60
69
  status,
61
70
  title,
62
71
  url,
@@ -276,6 +285,7 @@ const FormOrganizationCampaignAdvertisementEdit = ({
276
285
  InputFile,
277
286
  {
278
287
  ...{
288
+ description: described,
279
289
  endpoint: "/organization/" + values.organization,
280
290
  organization,
281
291
  onChange: (val) => {
@@ -284,6 +294,10 @@ const FormOrganizationCampaignAdvertisementEdit = ({
284
294
  file: val
285
295
  });
286
296
  },
297
+ onDescription: (text) => {
298
+ setValue("descriptions.asset", text, { shouldDirty: true });
299
+ preview();
300
+ },
287
301
  type: "media",
288
302
  value: value || ""
289
303
  }