@drawbridge/components 0.1.38 → 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.
@@ -905,7 +905,8 @@ const FormSubdomainSection = ({
905
905
  onChange,
906
906
  value
907
907
  }) => {
908
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
908
+ var _a2, _b2, _c2, _d2;
909
+ const { lead, name } = (0, import_entry.agreementPhrase)(key, ((_b2 = (_a2 = values == null ? void 0 : values.agreements) == null ? void 0 : _a2[key]) == null ? void 0 : _b2.label) || fallback);
909
910
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
910
911
  import_input_checkbox.default,
911
912
  {
@@ -914,17 +915,18 @@ const FormSubdomainSection = ({
914
915
  // @story public-entry/read-agreement
915
916
  // A link opens in a new tab; a document opens over the form, with Back.
916
917
  label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
918
+ lead,
917
919
  opens(key) === "link" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
918
920
  import_button.default,
919
921
  {
920
922
  ...{
921
923
  element: import_link.default,
922
- href: (_b2 = (_a2 = values == null ? void 0 : values.agreements) == null ? void 0 : _a2[key]) == null ? void 0 : _b2.link,
924
+ href: (_d2 = (_c2 = values == null ? void 0 : values.agreements) == null ? void 0 : _c2[key]) == null ? void 0 : _d2.link,
923
925
  inline: true,
924
926
  target: "_blank",
925
927
  variant: "link"
926
928
  },
927
- children: ((_d2 = (_c2 = values == null ? void 0 : values.agreements) == null ? void 0 : _c2[key]) == null ? void 0 : _d2.label) || fallback
929
+ children: name
928
930
  }
929
931
  ) : opens(key) === "document" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
930
932
  import_button.default,
@@ -934,9 +936,9 @@ const FormSubdomainSection = ({
934
936
  onClick: () => onAgreement == null ? void 0 : onAgreement(key),
935
937
  variant: "link"
936
938
  },
937
- children: ((_f2 = (_e2 = values == null ? void 0 : values.agreements) == null ? void 0 : _e2[key]) == null ? void 0 : _f2.label) || fallback
939
+ children: name
938
940
  }
939
- ) : ((_h2 = (_g2 = values == null ? void 0 : values.agreements) == null ? void 0 : _g2[key]) == null ? void 0 : _h2.label) || fallback,
941
+ ) : name,
940
942
  key === "terms" && " *"
941
943
  ] }),
942
944
  onChange,
@@ -14,7 +14,7 @@ import { ageFor, ageGateSchema } from "./lib/age-gate.mjs";
14
14
  import { useGoogleReCaptcha } from "react-google-recaptcha-v3";
15
15
  import { assertRecaptcha } from "./lib/recaptcha.mjs";
16
16
  import { submissionEndpoint } from "./lib/url.mjs";
17
- import { AFTER, agreementContent, agreementShown, agreementTitles, agreementWording, panelMissions, termsOptOut } from "./lib/entry.mjs";
17
+ import { AFTER, agreementContent, agreementPhrase, agreementShown, agreementTitles, agreementWording, panelMissions, termsOptOut } from "./lib/entry.mjs";
18
18
  import FormSubdomainAgreement from "./form-subdomain-agreement.mjs";
19
19
  import { LOCATION_TIMEOUT, locationCopy, locationStatus } from "./lib/location.mjs";
20
20
  import { isLastList, itemCount, itemRuns, limitMessage, orderTotal, priced, refusedSection, sectionsOf } from "./lib/order.mjs";
@@ -868,7 +868,8 @@ const FormSubdomainSection = ({
868
868
  onChange,
869
869
  value
870
870
  }) => {
871
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
871
+ var _a2, _b2, _c2, _d2;
872
+ const { lead, name } = agreementPhrase(key, ((_b2 = (_a2 = values == null ? void 0 : values.agreements) == null ? void 0 : _a2[key]) == null ? void 0 : _b2.label) || fallback);
872
873
  return /* @__PURE__ */ jsx(
873
874
  InputCheckbox,
874
875
  {
@@ -877,17 +878,18 @@ const FormSubdomainSection = ({
877
878
  // @story public-entry/read-agreement
878
879
  // A link opens in a new tab; a document opens over the form, with Back.
879
880
  label: /* @__PURE__ */ jsxs(Fragment, { children: [
881
+ lead,
880
882
  opens(key) === "link" ? /* @__PURE__ */ jsx(
881
883
  Button,
882
884
  {
883
885
  ...{
884
886
  element: Link,
885
- href: (_b2 = (_a2 = values == null ? void 0 : values.agreements) == null ? void 0 : _a2[key]) == null ? void 0 : _b2.link,
887
+ href: (_d2 = (_c2 = values == null ? void 0 : values.agreements) == null ? void 0 : _c2[key]) == null ? void 0 : _d2.link,
886
888
  inline: true,
887
889
  target: "_blank",
888
890
  variant: "link"
889
891
  },
890
- children: ((_d2 = (_c2 = values == null ? void 0 : values.agreements) == null ? void 0 : _c2[key]) == null ? void 0 : _d2.label) || fallback
892
+ children: name
891
893
  }
892
894
  ) : opens(key) === "document" ? /* @__PURE__ */ jsx(
893
895
  Button,
@@ -897,9 +899,9 @@ const FormSubdomainSection = ({
897
899
  onClick: () => onAgreement == null ? void 0 : onAgreement(key),
898
900
  variant: "link"
899
901
  },
900
- children: ((_f2 = (_e2 = values == null ? void 0 : values.agreements) == null ? void 0 : _e2[key]) == null ? void 0 : _f2.label) || fallback
902
+ children: name
901
903
  }
902
- ) : ((_h2 = (_g2 = values == null ? void 0 : values.agreements) == null ? void 0 : _g2[key]) == null ? void 0 : _h2.label) || fallback,
904
+ ) : name,
903
905
  key === "terms" && " *"
904
906
  ] }),
905
907
  onChange,
@@ -20,6 +20,7 @@ __export(entry_exports, {
20
20
  AFTER: () => AFTER,
21
21
  afterOrder: () => afterOrder,
22
22
  agreementContent: () => agreementContent,
23
+ agreementPhrase: () => agreementPhrase,
23
24
  agreementShown: () => agreementShown,
24
25
  agreementTitles: () => agreementTitles,
25
26
  agreementWording: () => agreementWording,
@@ -46,6 +47,14 @@ const agreementWording = {
46
47
  // The default wording carrier reviewers look for: explicit texts, rates, and STOP.
47
48
  sms: "I agree to receive text messages about this campaign. Message and data rates may apply. Reply STOP to opt out."
48
49
  };
50
+ const agreementPhrase = (key, label) => {
51
+ const text = String(label || "").trim();
52
+ if (!text || key === "sms" || /^i agree\b/i.test(text)) return { lead: "", name: label };
53
+ return {
54
+ lead: "I agree to the ",
55
+ name: text.charAt(0).toLowerCase() + text.slice(1)
56
+ };
57
+ };
49
58
  const buttonState = (data, open) => !open ? "inactive" : (data == null ? void 0 : data.awarding) === false ? "button" : "active";
50
59
  const buttonText = (data, open) => copy(data, buttonState(data, open));
51
60
  const formOn = (data) => (data == null ? void 0 : data.form) !== false;
@@ -97,6 +106,7 @@ const termsOptOut = ({ giveaway, sms } = {}) => giveaway === false ? null : "If
97
106
  AFTER,
98
107
  afterOrder,
99
108
  agreementContent,
109
+ agreementPhrase,
100
110
  agreementShown,
101
111
  agreementTitles,
102
112
  agreementWording,
@@ -8,6 +8,14 @@ const agreementWording = {
8
8
  // The default wording carrier reviewers look for: explicit texts, rates, and STOP.
9
9
  sms: "I agree to receive text messages about this campaign. Message and data rates may apply. Reply STOP to opt out."
10
10
  };
11
+ const agreementPhrase = (key, label) => {
12
+ const text = String(label || "").trim();
13
+ if (!text || key === "sms" || /^i agree\b/i.test(text)) return { lead: "", name: label };
14
+ return {
15
+ lead: "I agree to the ",
16
+ name: text.charAt(0).toLowerCase() + text.slice(1)
17
+ };
18
+ };
11
19
  const buttonState = (data, open) => !open ? "inactive" : (data == null ? void 0 : data.awarding) === false ? "button" : "active";
12
20
  const buttonText = (data, open) => copy(data, buttonState(data, open));
13
21
  const formOn = (data) => (data == null ? void 0 : data.form) !== false;
@@ -58,6 +66,7 @@ export {
58
66
  AFTER,
59
67
  afterOrder,
60
68
  agreementContent,
69
+ agreementPhrase,
61
70
  agreementShown,
62
71
  agreementTitles,
63
72
  agreementWording,
@@ -440,6 +440,7 @@ const SectionChoices = ({ choices, onClose }) => /* @__PURE__ */ (0, import_jsx_
440
440
  ),
441
441
  description,
442
442
  icon,
443
+ locked,
443
444
  title,
444
445
  ...upgrade ? {
445
446
  href: upgrade
@@ -519,11 +520,25 @@ const FooterEnd = ({
519
520
  agreements,
520
521
  phone,
521
522
  texts
522
- }).map(({ key, label }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
523
+ }).map(({ key, lead, name: name2, required, underline }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
523
524
  import_input_checkbox.default,
524
525
  {
525
526
  ...{
526
- label,
527
+ // @story public-entry/read-agreement
528
+ // As the share form draws it: only the name is underlined.
529
+ label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
530
+ lead,
531
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
532
+ "span",
533
+ {
534
+ ...{
535
+ className: underline ? "underline" : void 0
536
+ },
537
+ children: name2
538
+ }
539
+ ),
540
+ required
541
+ ] }),
527
542
  onChange: noop,
528
543
  style,
529
544
  value: false
@@ -1139,8 +1154,10 @@ const Start = ({
1139
1154
  fonts,
1140
1155
  style
1141
1156
  }) => {
1142
- const [state, setState] = (0, import_react.useState)(() => (0, import_entry.buttonState)(campaign, (campaign == null ? void 0 : campaign.valid) !== false));
1157
+ const live = (0, import_entry.buttonState)(campaign, (campaign == null ? void 0 : campaign.valid) !== false);
1158
+ const [state, setState] = (0, import_react.useState)(live);
1143
1159
  const card = (0, import_preview.useCard)("start");
1160
+ (0, import_react.useEffect)(() => setState(live), [live]);
1144
1161
  const edit = () => actions.copy(buttonStates.map(({ value }) => value), "Entry button");
1145
1162
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
1146
1163
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -408,6 +408,7 @@ const SectionChoices = ({ choices, onClose }) => /* @__PURE__ */ jsx(
408
408
  ),
409
409
  description,
410
410
  icon,
411
+ locked,
411
412
  title,
412
413
  ...upgrade ? {
413
414
  href: upgrade
@@ -487,11 +488,25 @@ const FooterEnd = ({
487
488
  agreements,
488
489
  phone,
489
490
  texts
490
- }).map(({ key, label }) => /* @__PURE__ */ jsx(
491
+ }).map(({ key, lead, name: name2, required, underline }) => /* @__PURE__ */ jsx(
491
492
  InputCheckbox,
492
493
  {
493
494
  ...{
494
- label,
495
+ // @story public-entry/read-agreement
496
+ // As the share form draws it: only the name is underlined.
497
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
498
+ lead,
499
+ /* @__PURE__ */ jsx(
500
+ "span",
501
+ {
502
+ ...{
503
+ className: underline ? "underline" : void 0
504
+ },
505
+ children: name2
506
+ }
507
+ ),
508
+ required
509
+ ] }),
495
510
  onChange: noop,
496
511
  style,
497
512
  value: false
@@ -1107,8 +1122,10 @@ const Start = ({
1107
1122
  fonts,
1108
1123
  style
1109
1124
  }) => {
1110
- const [state, setState] = useState(() => buttonState(campaign, (campaign == null ? void 0 : campaign.valid) !== false));
1125
+ const live = buttonState(campaign, (campaign == null ? void 0 : campaign.valid) !== false);
1126
+ const [state, setState] = useState(live);
1111
1127
  const card = useCard("start");
1128
+ useEffect(() => setState(live), [live]);
1112
1129
  const edit = () => actions.copy(buttonStates.map(({ value }) => value), "Entry button");
1113
1130
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1114
1131
  /* @__PURE__ */ jsx(
@@ -43,8 +43,6 @@ var import_form_action = __toESM(require("./form-action"));
43
43
  var import_input_switch = __toESM(require("../shared/input-switch"));
44
44
  var import_tooltip = __toESM(require("../shared/tooltip"));
45
45
  var import_lock = __toESM(require("../icons/lock"));
46
- var import_button = __toESM(require("../shared/button"));
47
- var import_link = __toESM(require("./link"));
48
46
  const useCampaignSwitch = ({ campaign, onError, onSuccess }) => {
49
47
  const queryClient = (0, import_react_query.useQueryClient)();
50
48
  const modal = (0, import_hooks.useModal)({
@@ -108,7 +106,7 @@ const SwitchLock = ({ disabled, onChange, value }) => /* @__PURE__ */ (0, import
108
106
  ]
109
107
  }
110
108
  );
111
- const SwitchRow = ({ description, href, lock, onChange, title, value }) => {
109
+ const SwitchRow = ({ description, lock, onChange, title, value }) => {
112
110
  const input = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
113
111
  SwitchLock,
114
112
  {
@@ -138,7 +136,7 @@ const SwitchRow = ({ description, href, lock, onChange, title, value }) => {
138
136
  "p",
139
137
  {
140
138
  ...{
141
- className: "text-sm text-gray-dark"
139
+ className: "text-xs text-gray-dark"
142
140
  },
143
141
  children: description
144
142
  }
@@ -146,19 +144,6 @@ const SwitchRow = ({ description, href, lock, onChange, title, value }) => {
146
144
  ]
147
145
  }
148
146
  ),
149
- href && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
- import_button.default,
151
- {
152
- ...{
153
- element: import_link.default,
154
- href,
155
- inline: true,
156
- size: "small",
157
- variant: "secondary"
158
- },
159
- children: "Manage"
160
- }
161
- ),
162
147
  lock ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
148
  import_tooltip.default,
164
149
  {
@@ -220,7 +205,6 @@ const HeaderCampaignSwitch = ({
220
205
  const CardLeadCapture = ({
221
206
  campaign,
222
207
  disabled,
223
- hrefs,
224
208
  onError,
225
209
  onSuccess
226
210
  }) => {
@@ -230,6 +214,7 @@ const CardLeadCapture = ({
230
214
  onSuccess
231
215
  });
232
216
  const card = (0, import_campaign.awardingCard)(campaign);
217
+ const order = (0, import_campaign.orderCard)(campaign);
233
218
  const rows = [
234
219
  {
235
220
  description: "Collect leads with the entry form on your pages",
@@ -276,7 +261,6 @@ const CardLeadCapture = ({
276
261
  {
277
262
  ...{
278
263
  description,
279
- href: hrefs == null ? void 0 : hrefs[key],
280
264
  lock: (0, import_campaign.switchLock)(campaign, key, disabled),
281
265
  onChange: (value) => flip(key, value),
282
266
  title,
@@ -287,6 +271,12 @@ const CardLeadCapture = ({
287
271
  );
288
272
  })
289
273
  }
274
+ ),
275
+ order && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
276
+ import_card_task.default,
277
+ {
278
+ ...order
279
+ }
290
280
  )
291
281
  ]
292
282
  }
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useQueryClient } from "@tanstack/react-query";
3
3
  import { request } from "@drawbridge/drawbridge-utils/fetch";
4
- import { awardingCard, campaignSwitch, switchLock } from "../shared/lib/campaign.mjs";
4
+ import { awardingCard, campaignSwitch, orderCard, switchLock } from "../shared/lib/campaign.mjs";
5
5
  import { useModal } from "./lib/hooks.mjs";
6
6
  import CardSection from "./card-section.mjs";
7
7
  import CardTask from "./card-task.mjs";
@@ -9,8 +9,6 @@ import FormAction from "./form-action.mjs";
9
9
  import InputSwitch from "../shared/input-switch.mjs";
10
10
  import Tooltip from "../shared/tooltip.mjs";
11
11
  import Lock from "../icons/lock.mjs";
12
- import Button from "../shared/button.mjs";
13
- import Link from "./link.mjs";
14
12
  const useCampaignSwitch = ({ campaign, onError, onSuccess }) => {
15
13
  const queryClient = useQueryClient();
16
14
  const modal = useModal({
@@ -74,7 +72,7 @@ const SwitchLock = ({ disabled, onChange, value }) => /* @__PURE__ */ jsxs(
74
72
  ]
75
73
  }
76
74
  );
77
- const SwitchRow = ({ description, href, lock, onChange, title, value }) => {
75
+ const SwitchRow = ({ description, lock, onChange, title, value }) => {
78
76
  const input = /* @__PURE__ */ jsx(
79
77
  SwitchLock,
80
78
  {
@@ -104,7 +102,7 @@ const SwitchRow = ({ description, href, lock, onChange, title, value }) => {
104
102
  "p",
105
103
  {
106
104
  ...{
107
- className: "text-sm text-gray-dark"
105
+ className: "text-xs text-gray-dark"
108
106
  },
109
107
  children: description
110
108
  }
@@ -112,19 +110,6 @@ const SwitchRow = ({ description, href, lock, onChange, title, value }) => {
112
110
  ]
113
111
  }
114
112
  ),
115
- href && /* @__PURE__ */ jsx(
116
- Button,
117
- {
118
- ...{
119
- element: Link,
120
- href,
121
- inline: true,
122
- size: "small",
123
- variant: "secondary"
124
- },
125
- children: "Manage"
126
- }
127
- ),
128
113
  lock ? /* @__PURE__ */ jsx(
129
114
  Tooltip,
130
115
  {
@@ -186,7 +171,6 @@ const HeaderCampaignSwitch = ({
186
171
  const CardLeadCapture = ({
187
172
  campaign,
188
173
  disabled,
189
- hrefs,
190
174
  onError,
191
175
  onSuccess
192
176
  }) => {
@@ -196,6 +180,7 @@ const CardLeadCapture = ({
196
180
  onSuccess
197
181
  });
198
182
  const card = awardingCard(campaign);
183
+ const order = orderCard(campaign);
199
184
  const rows = [
200
185
  {
201
186
  description: "Collect leads with the entry form on your pages",
@@ -242,7 +227,6 @@ const CardLeadCapture = ({
242
227
  {
243
228
  ...{
244
229
  description,
245
- href: hrefs == null ? void 0 : hrefs[key],
246
230
  lock: switchLock(campaign, key, disabled),
247
231
  onChange: (value) => flip(key, value),
248
232
  title,
@@ -253,6 +237,12 @@ const CardLeadCapture = ({
253
237
  );
254
238
  })
255
239
  }
240
+ ),
241
+ order && /* @__PURE__ */ jsx(
242
+ CardTask,
243
+ {
244
+ ...order
245
+ }
256
246
  )
257
247
  ]
258
248
  }
@@ -45,6 +45,7 @@ const CardShortcut = ({
45
45
  href,
46
46
  icon: Icon,
47
47
  image,
48
+ locked,
48
49
  onClick,
49
50
  title
50
51
  }) => {
@@ -68,7 +69,8 @@ const CardShortcut = ({
68
69
  "span",
69
70
  {
70
71
  ...{
71
- className: "flex items-center justify-center w-10 h-10 shrink-0 rounded bg-green text-black"
72
+ // A page the plan leaves out: the tile is grey ( Simon, 2026-11-19 ).
73
+ className: "flex items-center justify-center w-10 h-10 shrink-0 rounded " + (locked ? "bg-gray text-gray-dark" : "bg-green text-black")
72
74
  },
73
75
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
76
  Icon,
@@ -13,6 +13,7 @@ const CardShortcut = ({
13
13
  href,
14
14
  icon: Icon,
15
15
  image,
16
+ locked,
16
17
  onClick,
17
18
  title
18
19
  }) => {
@@ -36,7 +37,8 @@ const CardShortcut = ({
36
37
  "span",
37
38
  {
38
39
  ...{
39
- className: "flex items-center justify-center w-10 h-10 shrink-0 rounded bg-green text-black"
40
+ // A page the plan leaves out: the tile is grey ( Simon, 2026-11-19 ).
41
+ className: "flex items-center justify-center w-10 h-10 shrink-0 rounded " + (locked ? "bg-gray text-gray-dark" : "bg-green text-black")
40
42
  },
41
43
  children: /* @__PURE__ */ jsx(
42
44
  Icon,
@@ -95,11 +95,17 @@ const footerAgreements = ({ agreements = {}, phone, texts }) => {
95
95
  var _a2, _b, _c;
96
96
  return Boolean((_b = (_a2 = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _a2.values) == null ? void 0 : _b.enabled) && (key === "sms" ? Boolean(texts && phone) : Boolean((0, import_entry.agreementContent)((_c = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _c.values)));
97
97
  }).map(([key, fallback]) => {
98
- var _a2, _b;
98
+ var _a2, _b, _c;
99
+ const { lead, name } = (0, import_entry.agreementPhrase)(key, ((_b = (_a2 = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _a2.values) == null ? void 0 : _b.label) || fallback);
100
+ const required = key === "terms" ? " *" : "";
99
101
  return {
100
102
  key,
101
- // Terms must be ticked, so it ends with *, as on the share form.
102
- label: (((_b = (_a2 = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _a2.values) == null ? void 0 : _b.label) || fallback) + (key === "terms" ? " *" : "")
103
+ label: lead + name + required,
104
+ lead,
105
+ name,
106
+ required,
107
+ // The share form underlines the name while it opens a link or a document.
108
+ underline: Boolean((0, import_entry.agreementContent)((_c = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _c.values))
103
109
  };
104
110
  });
105
111
  };
@@ -1,4 +1,4 @@
1
- import { agreementContent, agreementTitles, agreementWording } from "../../bridge/lib/entry.mjs";
1
+ import { agreementContent, agreementPhrase, agreementTitles, agreementWording } from "../../bridge/lib/entry.mjs";
2
2
  const MAX_SECTIONS = 3;
3
3
  const MAX_ADS = 5;
4
4
  const adsLimit = (count) => count >= MAX_ADS ? "A campaign can have up to " + MAX_ADS + " advertisements." : null;
@@ -48,11 +48,17 @@ const footerAgreements = ({ agreements = {}, phone, texts }) => {
48
48
  var _a2, _b, _c;
49
49
  return Boolean((_b = (_a2 = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _a2.values) == null ? void 0 : _b.enabled) && (key === "sms" ? Boolean(texts && phone) : Boolean(agreementContent((_c = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _c.values)));
50
50
  }).map(([key, fallback]) => {
51
- var _a2, _b;
51
+ var _a2, _b, _c;
52
+ const { lead, name } = agreementPhrase(key, ((_b = (_a2 = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _a2.values) == null ? void 0 : _b.label) || fallback);
53
+ const required = key === "terms" ? " *" : "";
52
54
  return {
53
55
  key,
54
- // Terms must be ticked, so it ends with *, as on the share form.
55
- label: (((_b = (_a2 = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _a2.values) == null ? void 0 : _b.label) || fallback) + (key === "terms" ? " *" : "")
56
+ label: lead + name + required,
57
+ lead,
58
+ name,
59
+ required,
60
+ // The share form underlines the name while it opens a link or a document.
61
+ underline: Boolean(agreementContent((_c = agreements == null ? void 0 : agreements[key]) == null ? void 0 : _c.values))
56
62
  };
57
63
  });
58
64
  };
@@ -45,9 +45,9 @@ const railItems = ({
45
45
  const list = ((_d = organization == null ? void 0 : organization.tasks) == null ? void 0 : _d.list) || {};
46
46
  const others = Object.keys(list).filter((key) => !["billing", "campaigns"].includes(key));
47
47
  return [
48
- // The page's own notices: on its builder, or on Design the main page's
49
- // ( useRailPage, template-rail.js ).
50
- ...params.page || /\/design$/.test(path) ? ((_e = page == null ? void 0 : page.tasks) == null ? void 0 : _e.items) || [] : [],
48
+ // The page's own notices: on a page of a test ( its route names the
49
+ // variant ), or on Design the main page's ( useRailPage, template-rail.js ).
50
+ ...params.variant || /\/design$/.test(path) ? ((_e = page == null ? void 0 : page.tasks) == null ? void 0 : _e.items) || [] : [],
51
51
  ...required((_f = list.billing) == null ? void 0 : _f.items),
52
52
  ...((_g = campaign == null ? void 0 : campaign.tasks) == null ? void 0 : _g.items) || [],
53
53
  ...others.flatMap((key) => {
@@ -17,9 +17,9 @@ const railItems = ({
17
17
  const list = ((_d = organization == null ? void 0 : organization.tasks) == null ? void 0 : _d.list) || {};
18
18
  const others = Object.keys(list).filter((key) => !["billing", "campaigns"].includes(key));
19
19
  return [
20
- // The page's own notices: on its builder, or on Design the main page's
21
- // ( useRailPage, template-rail.js ).
22
- ...params.page || /\/design$/.test(path) ? ((_e = page == null ? void 0 : page.tasks) == null ? void 0 : _e.items) || [] : [],
20
+ // The page's own notices: on a page of a test ( its route names the
21
+ // variant ), or on Design the main page's ( useRailPage, template-rail.js ).
22
+ ...params.variant || /\/design$/.test(path) ? ((_e = page == null ? void 0 : page.tasks) == null ? void 0 : _e.items) || [] : [],
23
23
  ...required((_f = list.billing) == null ? void 0 : _f.items),
24
24
  ...((_g = campaign == null ? void 0 : campaign.tasks) == null ? void 0 : _g.items) || [],
25
25
  ...others.flatMap((key) => {
@@ -363,28 +363,22 @@ const scrollTo = (box, element) => {
363
363
  });
364
364
  };
365
365
  const useRailPage = ({ campaign, params = {}, path = "" }) => {
366
- const page = (0, import_react_query.useQuery)({
367
- enabled: false,
368
- // the page's builder loads it
369
- queryKey: ["organization-campaign-page", params]
370
- });
371
366
  const brand = (0, import_react_query.useQuery)({
372
367
  enabled: false,
373
368
  // the brand's page loads it
374
369
  queryKey: ["organization-brand", params]
375
370
  });
376
- const design = (0, import_react_query.useQuery)({
371
+ const variant = (0, import_react_query.useQuery)({
377
372
  enabled: false,
378
- // the Design page loads it
373
+ // the page's builder, or the Design page, loads it
379
374
  queryKey: (0, import_ab_tests.variantKey)({
380
375
  campaign: params.campaign,
381
376
  organization: params.organization,
382
- variant: campaign == null ? void 0 : campaign.variant
377
+ variant: params.variant || (campaign == null ? void 0 : campaign.variant)
383
378
  })
384
379
  });
385
- if (params.page) return page.data;
386
380
  if (params.brand) return brand.data;
387
- return /\/design$/.test(path) ? design.data : void 0;
381
+ return params.variant || /\/design$/.test(path) ? variant.data : void 0;
388
382
  };
389
383
  const TemplateRail = ({
390
384
  account,
@@ -328,28 +328,22 @@ const scrollTo = (box, element) => {
328
328
  });
329
329
  };
330
330
  const useRailPage = ({ campaign, params = {}, path = "" }) => {
331
- const page = useQuery({
332
- enabled: false,
333
- // the page's builder loads it
334
- queryKey: ["organization-campaign-page", params]
335
- });
336
331
  const brand = useQuery({
337
332
  enabled: false,
338
333
  // the brand's page loads it
339
334
  queryKey: ["organization-brand", params]
340
335
  });
341
- const design = useQuery({
336
+ const variant = useQuery({
342
337
  enabled: false,
343
- // the Design page loads it
338
+ // the page's builder, or the Design page, loads it
344
339
  queryKey: variantKey({
345
340
  campaign: params.campaign,
346
341
  organization: params.organization,
347
- variant: campaign == null ? void 0 : campaign.variant
342
+ variant: params.variant || (campaign == null ? void 0 : campaign.variant)
348
343
  })
349
344
  });
350
- if (params.page) return page.data;
351
345
  if (params.brand) return brand.data;
352
- return /\/design$/.test(path) ? design.data : void 0;
346
+ return params.variant || /\/design$/.test(path) ? variant.data : void 0;
353
347
  };
354
348
  const TemplateRail = ({
355
349
  account,
@@ -21,6 +21,7 @@ __export(campaign_exports, {
21
21
  campaignSwitch: () => campaignSwitch,
22
22
  campaignSwitches: () => campaignSwitches,
23
23
  leadCapture: () => leadCapture,
24
+ orderCard: () => orderCard,
24
25
  switchLock: () => switchLock
25
26
  });
26
27
  module.exports = __toCommonJS(campaign_exports);
@@ -65,6 +66,19 @@ const campaignSwitch = (campaign, key, on) => {
65
66
  };
66
67
  };
67
68
  const switchLock = (campaign, key, disabled) => disabled ? "You need Manage on Campaigns to change this" : null;
69
+ const orderCard = (campaign) => {
70
+ var _a;
71
+ if (((_a = campaign == null ? void 0 : campaign.giveaway) == null ? void 0 : _a.enabled) || !(campaign == null ? void 0 : campaign.ordering)) return null;
72
+ return {
73
+ button: {
74
+ href: "/organizations/" + (campaign == null ? void 0 : campaign.organization) + "/campaigns/" + (campaign == null ? void 0 : campaign.id) + "/form",
75
+ text: "Go to Order"
76
+ },
77
+ message: "The giveaway cannot turn on while the form takes orders",
78
+ title: "Turn off Order first",
79
+ type: "warning"
80
+ };
81
+ };
68
82
  const leadCapture = (campaign) => {
69
83
  var _a, _b;
70
84
  if (!((_a = campaign == null ? void 0 : campaign.form) == null ? void 0 : _a.enabled)) return "Off";
@@ -113,5 +127,6 @@ const awardingCard = (campaign, page = "overview") => {
113
127
  campaignSwitch,
114
128
  campaignSwitches,
115
129
  leadCapture,
130
+ orderCard,
116
131
  switchLock
117
132
  });
@@ -39,6 +39,19 @@ const campaignSwitch = (campaign, key, on) => {
39
39
  };
40
40
  };
41
41
  const switchLock = (campaign, key, disabled) => disabled ? "You need Manage on Campaigns to change this" : null;
42
+ const orderCard = (campaign) => {
43
+ var _a;
44
+ if (((_a = campaign == null ? void 0 : campaign.giveaway) == null ? void 0 : _a.enabled) || !(campaign == null ? void 0 : campaign.ordering)) return null;
45
+ return {
46
+ button: {
47
+ href: "/organizations/" + (campaign == null ? void 0 : campaign.organization) + "/campaigns/" + (campaign == null ? void 0 : campaign.id) + "/form",
48
+ text: "Go to Order"
49
+ },
50
+ message: "The giveaway cannot turn on while the form takes orders",
51
+ title: "Turn off Order first",
52
+ type: "warning"
53
+ };
54
+ };
42
55
  const leadCapture = (campaign) => {
43
56
  var _a, _b;
44
57
  if (!((_a = campaign == null ? void 0 : campaign.form) == null ? void 0 : _a.enabled)) return "Off";
@@ -86,5 +99,6 @@ export {
86
99
  campaignSwitch,
87
100
  campaignSwitches,
88
101
  leadCapture,
102
+ orderCard,
89
103
  switchLock
90
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/components",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "exports": {
5
5
  "./advertisement": {
6
6
  "types": "./types/advertisement.d.ts",
@@ -41,6 +41,8 @@ export declare const panelMissions: <T extends { type?: string }>( missions?: T[
41
41
 
42
42
  // The consent checkboxes' wording when an agreement has no label of its own.
43
43
  export declare const agreementWording: { marketing: string; sms: string };
44
+ // A checkbox's sentence: `lead` ("I agree to the " or nothing) before `name`, the part that opens the agreement.
45
+ export declare const agreementPhrase: ( key: string, label?: string | null ) => { lead: string; name?: string | null };
44
46
 
45
47
  // The menu's short names for the agreements, in the menu's order.
46
48
  export declare const agreementTitles: { terms: string; privacy: string; marketing: string; sms: string };
@@ -11,11 +11,6 @@ export interface CardLeadCaptureProps {
11
11
  campaign?: CardCampaignSwitchCampaign | null;
12
12
  // Without Manage on campaigns.settings: the switches are disabled with a lock.
13
13
  disabled?: boolean;
14
- // Each row with one has Manage before its switch, opening that page.
15
- hrefs?: {
16
- form?: string;
17
- giveaway?: string;
18
- };
19
14
  // Called with the campaign PUT's answer or refusal once the confirmation is sent.
20
15
  onError?: ( error: Error ) => void;
21
16
  onSuccess?: ( response: unknown ) => void;
@@ -38,8 +33,6 @@ export declare const CardLeadCapture: ComponentType<CardLeadCaptureProps>;
38
33
 
39
34
  export interface SwitchRowProps {
40
35
  description?: ReactNode;
41
- // A small Manage before the switch, opening the row's page.
42
- href?: string;
43
36
  // The reason the switch is disabled, shown on hover; null leaves it enabled.
44
37
  lock?: string | null;
45
38
  onChange?: ( value: boolean ) => void;
@@ -47,5 +40,5 @@ export interface SwitchRowProps {
47
40
  value?: boolean;
48
41
  }
49
42
 
50
- // One row of the Lead capture panel: a title, a grey line under it, the switch on the right.
43
+ // One row of the Lead capture panel: a title, a smaller grey line under it, the switch on the right.
51
44
  export declare const SwitchRow: ComponentType<SwitchRowProps>;
@@ -28,6 +28,8 @@ export interface CardShortcutProps {
28
28
  icon?: ComponentType<SVGProps<SVGSVGElement>>;
29
29
  // With no icon: the file drawn in the tile, a grey square while there is none.
30
30
  image?: CardShortcutFile | string | null;
31
+ // The plan leaves the page out: the icon's tile is grey, not green.
32
+ locked?: boolean;
31
33
  // In place of `href`: the card is a button. With neither, a line only shown.
32
34
  onClick?: () => void;
33
35
  title: string;
@@ -27,6 +27,17 @@ export declare const campaignSwitch: ( campaign: CampaignSwitchesRecord | null |
27
27
  // "Form and Giveaway", "Form" or "Off".
28
28
  export declare const leadCapture: ( campaign: CampaignSwitchesRecord | null | undefined ) => 'Form and Giveaway' | 'Form' | 'Off';
29
29
 
30
+ // The warning CardTask props while the form takes orders and the giveaway is off, or null.
31
+ export declare const orderCard: ( campaign: CampaignSwitchesRecord | null | undefined ) => {
32
+ button: {
33
+ href: string;
34
+ text: string;
35
+ };
36
+ message: string;
37
+ title: string;
38
+ type: 'warning';
39
+ } | null;
40
+
30
41
  // The CardTask props for the awarding state while the giveaway is on, or null while it is off.
31
42
  export declare const awardingCard: ( campaign: CampaignSwitchesRecord | null | undefined, page?: 'giveaway' | 'overview' ) => {
32
43
  message: string;