@drawbridge/components 0.1.14 → 0.1.16

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 (52) hide show
  1. package/dist/bridge/form-subdomain-missions.js +77 -38
  2. package/dist/bridge/form-subdomain-missions.mjs +76 -38
  3. package/dist/bridge/lib/url.js +3 -3
  4. package/dist/bridge/lib/url.mjs +3 -3
  5. package/dist/bridge/share-button.js +12 -2
  6. package/dist/bridge/share-button.mjs +12 -2
  7. package/dist/bridge/template-layout.js +1 -1
  8. package/dist/bridge/template-layout.mjs +1 -1
  9. package/dist/dashboard/answer-rows.js +77 -0
  10. package/dist/dashboard/answer-rows.mjs +41 -0
  11. package/dist/dashboard/card-campaign-switch.js +55 -43
  12. package/dist/dashboard/card-campaign-switch.mjs +56 -44
  13. package/dist/dashboard/card-order.js +248 -120
  14. package/dist/dashboard/card-order.mjs +248 -120
  15. package/dist/dashboard/connection-workflows.js +13 -4
  16. package/dist/dashboard/connection-workflows.mjs +13 -4
  17. package/dist/dashboard/form-organization-campaign-field-list.js +8 -49
  18. package/dist/dashboard/form-organization-campaign-field-list.mjs +8 -49
  19. package/dist/dashboard/form-organization-campaign-field-select.js +51 -5
  20. package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
  21. package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
  22. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
  23. package/dist/dashboard/form-organization-campaign-section.js +24 -4
  24. package/dist/dashboard/form-organization-campaign-section.mjs +24 -4
  25. package/dist/dashboard/form-organization-workflow.js +195 -56
  26. package/dist/dashboard/form-organization-workflow.mjs +191 -57
  27. package/dist/dashboard/item-row.js +92 -0
  28. package/dist/dashboard/item-row.mjs +63 -0
  29. package/dist/dashboard/lib/sms.js +3 -0
  30. package/dist/dashboard/lib/sms.mjs +2 -0
  31. package/dist/dashboard/order-sections.js +220 -0
  32. package/dist/dashboard/order-sections.mjs +185 -0
  33. package/dist/dashboard/preview.js +29 -2
  34. package/dist/dashboard/preview.mjs +28 -2
  35. package/dist/input-code.js +35 -53
  36. package/dist/input-code.mjs +26 -54
  37. package/dist/shared/button.js +1 -1
  38. package/dist/shared/button.mjs +1 -1
  39. package/dist/shared/lib/campaign.js +9 -3
  40. package/dist/shared/lib/campaign.mjs +7 -2
  41. package/dist/shared/lib/helpers.js +7 -0
  42. package/dist/shared/lib/helpers.mjs +7 -0
  43. package/package.json +19 -4
  44. package/types/bridge/form-subdomain-missions.d.ts +3 -1
  45. package/types/bridge/lib/url.d.ts +5 -4
  46. package/types/dashboard/answer-rows.d.ts +30 -0
  47. package/types/dashboard/card-order.d.ts +18 -3
  48. package/types/dashboard/form-organization-campaign-section.d.ts +2 -0
  49. package/types/dashboard/form-organization-workflow.d.ts +15 -0
  50. package/types/dashboard/item-row.d.ts +25 -0
  51. package/types/dashboard/order-sections.d.ts +36 -0
  52. package/types/shared/lib/helpers.d.ts +1 -1
@@ -9,6 +9,7 @@ import InputText from "../input-text.mjs";
9
9
  import InputTextarea from "../input-textarea.mjs";
10
10
  import InputSwitch from "../shared/input-switch.mjs";
11
11
  import Button from "../shared/button.mjs";
12
+ import Tooltip from "../shared/tooltip.mjs";
12
13
  const FormOrganizationCampaignSection = ({
13
14
  disabled,
14
15
  onError,
@@ -17,6 +18,7 @@ const FormOrganizationCampaignSection = ({
17
18
  }) => {
18
19
  var _a;
19
20
  const order = (values == null ? void 0 : values.type) === "order";
21
+ const locked = order && (values == null ? void 0 : values.giveaway) ? "Turn off the giveaway to take orders" : null;
20
22
  const { control, formState, handleSubmit } = useForm({
21
23
  resolver: resolver(
22
24
  yup.object({
@@ -44,7 +46,9 @@ const FormOrganizationCampaignSection = ({
44
46
  body: {
45
47
  description: description || null,
46
48
  ...order && {
47
- enabled,
49
+ ...!locked && {
50
+ enabled
51
+ },
48
52
  prices
49
53
  },
50
54
  title
@@ -57,7 +61,7 @@ const FormOrganizationCampaignSection = ({
57
61
  onError(error);
58
62
  }
59
63
  };
60
- const toggle = (key, label, message) => /* @__PURE__ */ jsx(
64
+ const toggle = (key, label, message, lock) => /* @__PURE__ */ jsx(
61
65
  Controller,
62
66
  {
63
67
  ...{
@@ -67,7 +71,23 @@ const FormOrganizationCampaignSection = ({
67
71
  InputGroup,
68
72
  {
69
73
  ...{
70
- input: /* @__PURE__ */ jsx(
74
+ input: lock ? /* @__PURE__ */ jsx(
75
+ Tooltip,
76
+ {
77
+ ...{
78
+ content: lock
79
+ },
80
+ children: /* @__PURE__ */ jsx(
81
+ InputSwitch,
82
+ {
83
+ ...{
84
+ disabled: true,
85
+ value: false
86
+ }
87
+ }
88
+ )
89
+ }
90
+ ) : /* @__PURE__ */ jsx(
71
91
  InputSwitch,
72
92
  {
73
93
  ...{
@@ -161,7 +181,7 @@ const FormOrganizationCampaignSection = ({
161
181
  }
162
182
  }
163
183
  ),
164
- order && toggle("enabled", "Take orders", "Off, the form skips this section. Everything here is kept."),
184
+ order && toggle("enabled", "Take orders", "Off, the form skips this section. Everything here is kept.", locked),
165
185
  order && toggle("prices", "Show prices", "Show each item's price and an estimated total.")
166
186
  ]
167
187
  }
@@ -28,10 +28,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
28
28
  var form_organization_workflow_exports = {};
29
29
  __export(form_organization_workflow_exports, {
30
30
  FormOrganizationWorkflowEdit: () => FormOrganizationWorkflowEdit,
31
+ SAMPLE: () => SAMPLE,
32
+ TextPreview: () => TextPreview,
33
+ firstEntryOnly: () => firstEntryOnly,
34
+ pickedCopy: () => pickedCopy,
31
35
  prefillRow: () => prefillRow,
32
36
  stepReason: () => stepReason,
33
37
  stepRow: () => stepRow,
34
38
  stepVariables: () => stepVariables,
39
+ webhookSample: () => webhookSample,
35
40
  workflowSchema: () => workflowSchema
36
41
  });
37
42
  module.exports = __toCommonJS(form_organization_workflow_exports);
@@ -39,6 +44,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
39
44
  var import_image = __toESM(require("next/image"));
40
45
  var import_link = __toESM(require("./link"));
41
46
  var import_react = require("react");
47
+ var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
42
48
  var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
43
49
  var import_form = require("../shared/lib/form");
44
50
  var import_react_query = require("@tanstack/react-query");
@@ -54,6 +60,7 @@ var import_input_combobox = __toESM(require("./input-combobox"));
54
60
  var import_form_notification = require("./form-notification");
55
61
  var import_input_array = require("./input-array");
56
62
  var import_badge = __toESM(require("../shared/badge"));
63
+ var import_input_switch = __toESM(require("../shared/input-switch"));
57
64
  var import_card_section = __toESM(require("./card-section"));
58
65
  var import_accordion = __toESM(require("./accordion"));
59
66
  var import_preview = __toESM(require("./preview"));
@@ -65,22 +72,18 @@ var import_button = __toESM(require("../shared/button"));
65
72
  const emailSteps = ["step.email.send"];
66
73
  const teamSteps = ["step.email.notify"];
67
74
  const messageSteps = [...emailSteps, "step.sms.send"];
68
- const defaultScore = {
69
- rules: [
70
- { description: "From: domain has series of non-vowel letters", score: 0.5 },
71
- { description: "Informational: message was not relayed via SMTP", score: 0 },
72
- { description: "Informational: message has no Received headers", score: 0 }
73
- ],
74
- subtotal: 0,
75
- threshold: 5,
76
- total: 0.5
75
+ const renderedSteps = [...emailSteps, ...teamSteps];
76
+ const firstEntryOnly = ({ campaign, event, type }) => {
77
+ var _a, _b;
78
+ if (event !== "lead.insert" || !type || emailSteps.includes(type)) return false;
79
+ if (type === "step.sms.send") return (((_a = campaign == null ? void 0 : campaign.form) == null ? void 0 : _a.submissionLeadPrimaryKey) ?? ((_b = campaign == null ? void 0 : campaign.settings) == null ? void 0 : _b.submissionLeadPrimaryKey)) !== "phone";
80
+ return true;
77
81
  };
78
82
  const stepPrefills = {
79
83
  "step.email.send": {
80
- message: "Thanks for entering. We have your entry and will be in touch.",
81
- score: defaultScore,
82
- subject: "Thanks for entering",
83
- text: "Thanks for entering. We have your entry and will be in touch."
84
+ message: import_drawbridge_utils.constants.campaign.confirmation.message,
85
+ subject: import_drawbridge_utils.constants.campaign.confirmation.subject,
86
+ text: import_drawbridge_utils.constants.campaign.confirmation.text
84
87
  },
85
88
  // Nothing to prefill: the step writes its own copy.
86
89
  "step.email.notify": {}
@@ -139,6 +142,13 @@ const prefillRow = ({ entry, step, steps = [] }) => {
139
142
  type: step
140
143
  });
141
144
  };
145
+ const pickedCopy = ({ row, type }) => {
146
+ const previous = stepPrefills[row == null ? void 0 : row.type];
147
+ const untouched = !!(previous == null ? void 0 : previous.subject) && (row == null ? void 0 : row.subject) === previous.subject && (row == null ? void 0 : row.message) === previous.message;
148
+ const { message = "", subject = "", text = "" } = stepPrefills[type] || {};
149
+ if (!untouched && ((row == null ? void 0 : row.subject) || (row == null ? void 0 : row.message))) return null;
150
+ return subject || untouched ? { message, subject, text } : null;
151
+ };
142
152
  const stepReason = ({ entry, saved = [], type }) => {
143
153
  var _a, _b;
144
154
  return ((_a = ((entry == null ? void 0 : entry.steps) || []).find((step) => (step == null ? void 0 : step.value) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _a.reason) || ((_b = saved.find((step) => (step == null ? void 0 : step.type) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _b.reason) || null;
@@ -148,6 +158,9 @@ const stepRow = (step = {}, members = []) => {
148
158
  return {
149
159
  connectionId: step.connectionId || "",
150
160
  discount: ((_a = step.settings) == null ? void 0 : _a.discount) || null,
161
+ // @story workflows/step-switch
162
+ // The step's own switch; absent reads on.
163
+ enabled: step.enabled !== false,
151
164
  // Stored as ids, picked as documents. Hydrating through the fetched list
152
165
  // also drops ids whose member no longer exists — a removed teammate
153
166
  // leaves their id on the step, and an id with nothing behind it would
@@ -222,18 +235,8 @@ const workflowSchema = import_yup.default.object({
222
235
  })
223
236
  )
224
237
  });
225
- const samples = [
226
- {
227
- key: "New lead",
228
- value: "lead"
229
- },
230
- {
231
- key: "Verified their email",
232
- value: "verified"
233
- }
234
- ];
235
- const useEmailPreview = ({ campaign, event, message, organization, sample, subject, text }) => {
236
- const asked = JSON.stringify({ message, sample, subject, text });
238
+ const useEmailPreview = ({ campaign, event, message, organization, subject, text, type }) => {
239
+ const asked = JSON.stringify(teamSteps.includes(type) ? { type } : { message, subject, text });
237
240
  const [settled, setSettled] = (0, import_react.useState)(asked);
238
241
  (0, import_react.useEffect)(() => {
239
242
  const timer = setTimeout(() => setSettled(asked), 400);
@@ -258,19 +261,21 @@ const EmailStepCard = ({
258
261
  card,
259
262
  children,
260
263
  control,
264
+ off,
261
265
  email: {
262
266
  campaign,
263
267
  event,
264
268
  name,
265
- organization
269
+ organization,
270
+ title,
271
+ type
266
272
  }
267
273
  }) => {
268
- const [sample, setSample] = (0, import_react.useState)(samples[0].value);
269
274
  const [subject, message, text] = (0, import_form.useWatch)({
270
275
  control,
271
276
  name: [name + ".subject", name + ".message", name + ".text"]
272
277
  });
273
- const preview = useEmailPreview({ campaign, event, message, organization, sample, subject, text });
278
+ const preview = useEmailPreview({ campaign, event, message, organization, subject, text, type });
274
279
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
275
280
  import_card_section.default,
276
281
  {
@@ -287,7 +292,7 @@ const EmailStepCard = ({
287
292
  },
288
293
  children: [
289
294
  children,
290
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
295
+ emailSteps.includes(type) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
291
296
  import_accordion.default,
292
297
  {
293
298
  ...{
@@ -310,36 +315,82 @@ const EmailStepCard = ({
310
315
  }
311
316
  ),
312
317
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
313
- import_preview.default,
318
+ "div",
314
319
  {
315
320
  ...{
316
- states: {
317
- onChange: setSample,
318
- options: samples,
319
- value: sample
320
- }
321
+ className: off ? "opacity-50" : ""
321
322
  },
322
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
323
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preview.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
323
324
  "iframe",
324
325
  {
325
326
  ...{
326
327
  // The rendered email, as a mail app shows it.
327
328
  className: "block w-full h-full border-0 bg-white",
328
329
  srcDoc: (preview == null ? void 0 : preview.html) || "",
329
- title: "Send email"
330
+ title
330
331
  }
331
332
  }
332
- )
333
+ ) })
333
334
  }
334
335
  )
335
336
  ]
336
337
  }
337
338
  );
338
339
  };
340
+ const SAMPLE = {
341
+ email: "sam.rivera@example.com",
342
+ name: "Sam Rivera",
343
+ phone: "+14165550142"
344
+ };
345
+ const webhookSample = ({ campaign }) => JSON.stringify({
346
+ campaign: {
347
+ id: (campaign == null ? void 0 : campaign.id) || "cmp_sample",
348
+ title: (campaign == null ? void 0 : campaign.title) || "Your campaign"
349
+ },
350
+ email: SAMPLE.email,
351
+ id: "lead_sample",
352
+ name: SAMPLE.name,
353
+ phone: {
354
+ number: SAMPLE.phone
355
+ }
356
+ }, null, 2);
357
+ const TextPreview = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "p-6 font-sans", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "max-w-xs px-4 py-3 rounded-2xl rounded-bl-sm bg-gray-light text-black break-words", children }) });
358
+ const StepPreview = ({ campaign, control, image, name, organization, type }) => {
359
+ const [message] = (0, import_form.useWatch)({
360
+ control,
361
+ name: [name + ".message"]
362
+ });
363
+ const brand = (0, import_sms.smsBrandLine)(organization == null ? void 0 : organization.title, message);
364
+ if (type === "step.sms.send") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextPreview, { children: [
365
+ brand && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: brand }),
366
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "whitespace-pre-wrap", children: message }),
367
+ (campaign == null ? void 0 : campaign.awarding) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-2 px-2 py-1 rounded border border-dashed border-gray-dark text-gray-dark", children: "The entrant's missions appear here" }),
368
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-2", children: "Reply STOP to opt out" })
369
+ ] });
370
+ if (type === "step.webhook.send") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "p-6 text-xs whitespace-pre-wrap break-all font-mono", children: "X-Drawbridge-Signature: t=\u2026,v1=\u2026\n\n" + webhookSample({ campaign }) });
371
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-h-screen flex flex-col items-center justify-center gap-3 p-6 text-gray-dark", children: [
372
+ image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
373
+ import_image.default,
374
+ {
375
+ ...{
376
+ alt: "",
377
+ className: "w-12 h-12 object-contain",
378
+ height: 48,
379
+ src: image,
380
+ unoptimized: true,
381
+ width: 48
382
+ }
383
+ }
384
+ ),
385
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "No preview available" })
386
+ ] });
387
+ };
339
388
  const StepCard = ({
340
389
  children,
341
390
  control,
342
391
  email,
392
+ off,
393
+ preview,
343
394
  ...card
344
395
  }) => email ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
345
396
  EmailStepCard,
@@ -347,15 +398,38 @@ const StepCard = ({
347
398
  ...{
348
399
  card,
349
400
  control,
350
- email
401
+ email,
402
+ off
351
403
  },
352
404
  children
353
405
  }
354
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
406
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
355
407
  import_card_section.default,
356
408
  {
357
- ...card,
358
- children
409
+ ...{
410
+ ...card,
411
+ columns: preview ? 2 : 1
412
+ },
413
+ children: [
414
+ children,
415
+ preview && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
416
+ "div",
417
+ {
418
+ ...{
419
+ className: off ? "opacity-50" : ""
420
+ },
421
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preview.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
422
+ StepPreview,
423
+ {
424
+ ...{
425
+ control,
426
+ ...preview
427
+ }
428
+ }
429
+ ) })
430
+ }
431
+ )
432
+ ]
359
433
  }
360
434
  );
361
435
  const FormOrganizationWorkflowEdit = ({
@@ -372,6 +446,7 @@ const FormOrganizationWorkflowEdit = ({
372
446
  const organizationData = queryClient.getQueryData(["organization", values == null ? void 0 : values.organization]);
373
447
  const ownerEmail = organizationData.owner.email;
374
448
  const smsActive = (0, import_sms.smsNumberActive)(organizationData);
449
+ const campaignData = queryClient.getQueryData(["campaign", values == null ? void 0 : values.campaign]);
375
450
  const commerceConnectionId = ((_b = ((catalog == null ? void 0 : catalog.steps) || []).find(
376
451
  (s) => s.value === "step.commerce.customer.insert" || s.value === "step.commerce.code.issue"
377
452
  )) == null ? void 0 : _b.connectionId) || null;
@@ -540,7 +615,7 @@ const FormOrganizationWorkflowEdit = ({
540
615
  }) => {
541
616
  try {
542
617
  const body = {
543
- steps: steps.map(({ connectionId, discount, members, message, score, slug, subject, text, type, url }, index) => {
618
+ steps: steps.map(({ connectionId, discount, enabled, members, message, score, slug, subject, text, type, url }, index) => {
544
619
  const settings = {};
545
620
  if (type === "step.webhook.send") settings.url = url;
546
621
  if (emailSteps.includes(type)) settings.subject = subject;
@@ -558,6 +633,7 @@ const FormOrganizationWorkflowEdit = ({
558
633
  const resolvedSlug = (catalogStep == null ? void 0 : catalogStep.slug) || slug || null;
559
634
  return {
560
635
  ...resolvedConnectionId && { connectionId: resolvedConnectionId },
636
+ enabled: enabled !== false,
561
637
  ...resolvedSlug && { slug: resolvedSlug },
562
638
  settings,
563
639
  type
@@ -645,6 +721,7 @@ const FormOrganizationWorkflowEdit = ({
645
721
  )
646
722
  },
647
723
  children: ({ field, handle, index, remove }) => {
724
+ var _a2;
648
725
  const step = (watchedSteps == null ? void 0 : watchedSteps[index]) || field;
649
726
  return (
650
727
  // @story workflows/edit
@@ -659,11 +736,23 @@ const FormOrganizationWorkflowEdit = ({
659
736
  control,
660
737
  // @story workflows/send-email
661
738
  // A Send email step shows its email beside its form.
662
- email: emailSteps.includes(step.type) && {
739
+ off: step.enabled === false,
740
+ // Every other step with a type has its preview too.
741
+ preview: step.type && !renderedSteps.includes(step.type) && {
742
+ campaign: campaignData,
743
+ image: ((_a2 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a2.image) || null,
744
+ name: `steps.${index}`,
745
+ organization: organizationData,
746
+ type: step.type
747
+ },
748
+ // Send email and Email notification show the email the api renders.
749
+ email: renderedSteps.includes(step.type) && {
663
750
  campaign: values == null ? void 0 : values.campaign,
664
751
  event,
665
752
  name: `steps.${index}`,
666
- organization: values == null ? void 0 : values.organization
753
+ organization: values == null ? void 0 : values.organization,
754
+ title: emailSteps.includes(step.type) ? "Send email" : "Email notification",
755
+ type: step.type
667
756
  },
668
757
  cta: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
669
758
  "span",
@@ -682,6 +771,30 @@ const FormOrganizationWorkflowEdit = ({
682
771
  }
683
772
  },
684
773
  "remove"
774
+ ),
775
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
776
+ import_form.Controller,
777
+ {
778
+ ...{
779
+ control,
780
+ name: `steps.${index}.enabled`,
781
+ render: ({ field: { onChange, value } }) => {
782
+ var _a3;
783
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
784
+ import_input_switch.default,
785
+ {
786
+ ...{
787
+ "aria-label": ((_a3 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a3.key) || "Step " + (index + 1),
788
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
789
+ onChange,
790
+ small: true,
791
+ value: value !== false
792
+ }
793
+ }
794
+ );
795
+ }
796
+ }
797
+ }
685
798
  )
686
799
  ]
687
800
  }
@@ -704,7 +817,8 @@ const FormOrganizationWorkflowEdit = ({
704
817
  "div",
705
818
  {
706
819
  ...{
707
- className: "space-y-3"
820
+ // A step switched off is greyed; its settings are kept.
821
+ className: "space-y-3" + (step.enabled === false ? " opacity-50" : "")
708
822
  },
709
823
  children: [
710
824
  issueIndex === index && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -722,12 +836,12 @@ const FormOrganizationWorkflowEdit = ({
722
836
  control,
723
837
  name: `steps.${index}.type`,
724
838
  render: ({ field: { onChange } }) => {
725
- var _a2, _b2, _c2, _d2;
839
+ var _a3, _b2, _c2, _d2;
726
840
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
727
841
  import_input_group.default,
728
842
  {
729
843
  ...{
730
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.type) == null ? void 0 : _d2.message,
844
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.type) == null ? void 0 : _d2.message,
731
845
  input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
732
846
  import_input_combobox.default,
733
847
  {
@@ -735,9 +849,11 @@ const FormOrganizationWorkflowEdit = ({
735
849
  onChange: (val) => {
736
850
  const [type] = val.split("::");
737
851
  const option = getStepOptions(index).find((o) => o.value === val);
852
+ const copy = pickedCopy({ row: getValues(`steps.${index}`), type });
738
853
  onChange(type);
739
854
  setValue(`steps.${index}.connectionId`, (option == null ? void 0 : option.connectionId) || "");
740
855
  setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
856
+ if (copy) Object.entries(copy).forEach(([key, value]) => setValue(`steps.${index}.${key}`, value));
741
857
  },
742
858
  disabled: lockedStep(index),
743
859
  options: getStepOptions(index),
@@ -756,6 +872,15 @@ const FormOrganizationWorkflowEdit = ({
756
872
  }
757
873
  }
758
874
  ),
875
+ firstEntryOnly({ campaign: campaignData, event, type: step.type }) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
876
+ "p",
877
+ {
878
+ ...{
879
+ className: "text-sm text-gray-dark"
880
+ },
881
+ children: "Runs on a person's first entry only."
882
+ }
883
+ ),
759
884
  step.type === "step.webhook.send" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
760
885
  import_form.Controller,
761
886
  {
@@ -763,12 +888,12 @@ const FormOrganizationWorkflowEdit = ({
763
888
  control,
764
889
  name: `steps.${index}.url`,
765
890
  render: ({ field: { value, onChange } }) => {
766
- var _a2, _b2, _c2, _d2;
891
+ var _a3, _b2, _c2, _d2;
767
892
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
768
893
  import_input_group.default,
769
894
  {
770
895
  ...{
771
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.url) == null ? void 0 : _d2.message,
896
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.url) == null ? void 0 : _d2.message,
772
897
  input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
773
898
  import_input_url.default,
774
899
  {
@@ -794,12 +919,12 @@ const FormOrganizationWorkflowEdit = ({
794
919
  control,
795
920
  name: `steps.${index}.members`,
796
921
  render: ({ field: { value, onChange } }) => {
797
- var _a2, _b2, _c2, _d2;
922
+ var _a3, _b2, _c2, _d2;
798
923
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
799
924
  import_input_group.default,
800
925
  {
801
926
  ...{
802
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.members) == null ? void 0 : _d2.message,
927
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.members) == null ? void 0 : _d2.message,
803
928
  input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
804
929
  import_input_resource.default,
805
930
  {
@@ -855,6 +980,15 @@ const FormOrganizationWorkflowEdit = ({
855
980
  }
856
981
  }
857
982
  ),
983
+ event === "lead.insert" && emailSteps.includes(step.type) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
984
+ "p",
985
+ {
986
+ ...{
987
+ className: "text-sm text-gray-dark"
988
+ },
989
+ children: "Drawbridge adds the entrant's order and missions under your message. You can't edit or remove them."
990
+ }
991
+ ),
858
992
  step.type === "step.sms.send" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
859
993
  import_form.Controller,
860
994
  {
@@ -862,12 +996,12 @@ const FormOrganizationWorkflowEdit = ({
862
996
  control,
863
997
  name: `steps.${index}.message`,
864
998
  render: ({ field: { value, onChange } }) => {
865
- var _a2, _b2, _c2, _d2;
999
+ var _a3, _b2, _c2, _d2;
866
1000
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
867
1001
  import_input_group.default,
868
1002
  {
869
1003
  ...{
870
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.message) == null ? void 0 : _d2.message,
1004
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.message) == null ? void 0 : _d2.message,
871
1005
  input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
872
1006
  import_input_textarea.default,
873
1007
  {
@@ -893,12 +1027,12 @@ const FormOrganizationWorkflowEdit = ({
893
1027
  control,
894
1028
  name: `steps.${index}.discount`,
895
1029
  render: ({ field: { value, onChange } }) => {
896
- var _a2, _b2, _c2, _d2;
1030
+ var _a3, _b2, _c2, _d2;
897
1031
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
898
1032
  import_input_group.default,
899
1033
  {
900
1034
  ...{
901
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.discount) == null ? void 0 : _d2.message,
1035
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.discount) == null ? void 0 : _d2.message,
902
1036
  input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
903
1037
  import_input_resource.default,
904
1038
  {
@@ -989,9 +1123,14 @@ const FormOrganizationWorkflowEdit = ({
989
1123
  // Annotate the CommonJS export names for ESM import in node:
990
1124
  0 && (module.exports = {
991
1125
  FormOrganizationWorkflowEdit,
1126
+ SAMPLE,
1127
+ TextPreview,
1128
+ firstEntryOnly,
1129
+ pickedCopy,
992
1130
  prefillRow,
993
1131
  stepReason,
994
1132
  stepRow,
995
1133
  stepVariables,
1134
+ webhookSample,
996
1135
  workflowSchema
997
1136
  });