@drawbridge/components 0.1.17 → 0.1.19
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.
- package/dist/bridge/form-subdomain-missions.js +11 -13
- package/dist/bridge/form-subdomain-missions.mjs +11 -13
- package/dist/bridge/template-layout.js +1 -1
- package/dist/bridge/template-layout.mjs +1 -1
- package/dist/bridge/template-modal.js +1 -1
- package/dist/bridge/template-modal.mjs +1 -1
- package/dist/dashboard/form-organization-workflow.js +37 -22
- package/dist/dashboard/form-organization-workflow.mjs +37 -23
- package/dist/dashboard/input-editor.js +17 -9
- package/dist/dashboard/input-editor.mjs +15 -8
- package/package.json +3 -3
- package/types/bridge/form-subdomain-missions.d.ts +1 -1
- package/types/dashboard/input-editor.d.ts +4 -2
|
@@ -107,7 +107,7 @@ const Back = ({ onClick, style }) => {
|
|
|
107
107
|
reverse: true,
|
|
108
108
|
variant: "link"
|
|
109
109
|
},
|
|
110
|
-
children: "Back
|
|
110
|
+
children: "Back"
|
|
111
111
|
}
|
|
112
112
|
)
|
|
113
113
|
}
|
|
@@ -412,14 +412,12 @@ const FormSubdomainMissions = ({
|
|
|
412
412
|
children: [
|
|
413
413
|
header("Thank you!"),
|
|
414
414
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Back, { ...{ onClick: back, style } }),
|
|
415
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
416
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Strong, { children: "Mission accomplished!" }),
|
|
417
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Your bonus entries are in. Go back to missions to earn more." })
|
|
418
|
-
] })
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Centre, { children: Number(item == null ? void 0 : item.entries) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Strong, { children: "You've earned " + (0, import_missions.entriesText)(item.entries) }) })
|
|
419
416
|
]
|
|
420
417
|
}
|
|
421
418
|
);
|
|
422
|
-
|
|
419
|
+
const finished = screen === "start" && !message && !bonusText(items, completed);
|
|
420
|
+
if (screen === "start" && !finished) {
|
|
423
421
|
const bonus = bonusText(items, completed);
|
|
424
422
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
425
423
|
"div",
|
|
@@ -491,7 +489,7 @@ const FormSubdomainMissions = ({
|
|
|
491
489
|
className: "space-y-6"
|
|
492
490
|
},
|
|
493
491
|
children: [
|
|
494
|
-
header("Earn more entries", { onClick: () => go("start") }),
|
|
492
|
+
finished ? header(title) : header("Earn more entries", { onClick: () => go("start") }),
|
|
495
493
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
496
494
|
"ul",
|
|
497
495
|
{
|
|
@@ -503,9 +501,9 @@ const FormSubdomainMissions = ({
|
|
|
503
501
|
},
|
|
504
502
|
children: items.filter((row) => import_missions.missions[row.type]).map((row, index) => {
|
|
505
503
|
var _a2;
|
|
506
|
-
const
|
|
504
|
+
const done = completed.includes(row.type);
|
|
507
505
|
const opens = screenFor(row.type);
|
|
508
|
-
const Mark =
|
|
506
|
+
const Mark = done ? import_check.default : import_chevron_right.default;
|
|
509
507
|
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
510
508
|
"span",
|
|
511
509
|
{
|
|
@@ -517,10 +515,10 @@ const FormSubdomainMissions = ({
|
|
|
517
515
|
"span",
|
|
518
516
|
{
|
|
519
517
|
...{
|
|
520
|
-
className: "flex items-center gap-4 flex-1 min-w-0" + (
|
|
518
|
+
className: "flex items-center gap-4 flex-1 min-w-0" + (done ? " opacity-40" : "")
|
|
521
519
|
},
|
|
522
520
|
children: [
|
|
523
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { ...{ style }, children: pillText(row,
|
|
521
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { ...{ style }, children: pillText(row, done) }),
|
|
524
522
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
525
523
|
"span",
|
|
526
524
|
{
|
|
@@ -533,7 +531,7 @@ const FormSubdomainMissions = ({
|
|
|
533
531
|
]
|
|
534
532
|
}
|
|
535
533
|
),
|
|
536
|
-
(
|
|
534
|
+
(done || opens !== "missions") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { ...{ style }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
537
535
|
Mark,
|
|
538
536
|
{
|
|
539
537
|
...{
|
|
@@ -553,7 +551,7 @@ const FormSubdomainMissions = ({
|
|
|
553
551
|
borderColor: "inherit"
|
|
554
552
|
}
|
|
555
553
|
},
|
|
556
|
-
children:
|
|
554
|
+
children: done || opens === "missions" ? content : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
557
555
|
import_button.default,
|
|
558
556
|
{
|
|
559
557
|
...{
|
|
@@ -70,7 +70,7 @@ const Back = ({ onClick, style }) => {
|
|
|
70
70
|
reverse: true,
|
|
71
71
|
variant: "link"
|
|
72
72
|
},
|
|
73
|
-
children: "Back
|
|
73
|
+
children: "Back"
|
|
74
74
|
}
|
|
75
75
|
)
|
|
76
76
|
}
|
|
@@ -375,14 +375,12 @@ const FormSubdomainMissions = ({
|
|
|
375
375
|
children: [
|
|
376
376
|
header("Thank you!"),
|
|
377
377
|
/* @__PURE__ */ jsx(Back, { ...{ onClick: back, style } }),
|
|
378
|
-
/* @__PURE__ */
|
|
379
|
-
/* @__PURE__ */ jsx(Strong, { children: "Mission accomplished!" }),
|
|
380
|
-
/* @__PURE__ */ jsx("p", { children: "Your bonus entries are in. Go back to missions to earn more." })
|
|
381
|
-
] })
|
|
378
|
+
/* @__PURE__ */ jsx(Centre, { children: Number(item == null ? void 0 : item.entries) > 0 && /* @__PURE__ */ jsx(Strong, { children: "You've earned " + entriesText(item.entries) }) })
|
|
382
379
|
]
|
|
383
380
|
}
|
|
384
381
|
);
|
|
385
|
-
|
|
382
|
+
const finished = screen === "start" && !message && !bonusText(items, completed);
|
|
383
|
+
if (screen === "start" && !finished) {
|
|
386
384
|
const bonus = bonusText(items, completed);
|
|
387
385
|
return /* @__PURE__ */ jsxs(
|
|
388
386
|
"div",
|
|
@@ -454,7 +452,7 @@ const FormSubdomainMissions = ({
|
|
|
454
452
|
className: "space-y-6"
|
|
455
453
|
},
|
|
456
454
|
children: [
|
|
457
|
-
header("Earn more entries", { onClick: () => go("start") }),
|
|
455
|
+
finished ? header(title) : header("Earn more entries", { onClick: () => go("start") }),
|
|
458
456
|
/* @__PURE__ */ jsx(
|
|
459
457
|
"ul",
|
|
460
458
|
{
|
|
@@ -466,9 +464,9 @@ const FormSubdomainMissions = ({
|
|
|
466
464
|
},
|
|
467
465
|
children: items.filter((row) => manifests[row.type]).map((row, index) => {
|
|
468
466
|
var _a2;
|
|
469
|
-
const
|
|
467
|
+
const done = completed.includes(row.type);
|
|
470
468
|
const opens = screenFor(row.type);
|
|
471
|
-
const Mark =
|
|
469
|
+
const Mark = done ? Check : ChevronRight;
|
|
472
470
|
const content = /* @__PURE__ */ jsxs(
|
|
473
471
|
"span",
|
|
474
472
|
{
|
|
@@ -480,10 +478,10 @@ const FormSubdomainMissions = ({
|
|
|
480
478
|
"span",
|
|
481
479
|
{
|
|
482
480
|
...{
|
|
483
|
-
className: "flex items-center gap-4 flex-1 min-w-0" + (
|
|
481
|
+
className: "flex items-center gap-4 flex-1 min-w-0" + (done ? " opacity-40" : "")
|
|
484
482
|
},
|
|
485
483
|
children: [
|
|
486
|
-
/* @__PURE__ */ jsx(Pill, { ...{ style }, children: pillText(row,
|
|
484
|
+
/* @__PURE__ */ jsx(Pill, { ...{ style }, children: pillText(row, done) }),
|
|
487
485
|
/* @__PURE__ */ jsx(
|
|
488
486
|
"span",
|
|
489
487
|
{
|
|
@@ -496,7 +494,7 @@ const FormSubdomainMissions = ({
|
|
|
496
494
|
]
|
|
497
495
|
}
|
|
498
496
|
),
|
|
499
|
-
(
|
|
497
|
+
(done || opens !== "missions") && /* @__PURE__ */ jsx(Pill, { ...{ style }, children: /* @__PURE__ */ jsx(
|
|
500
498
|
Mark,
|
|
501
499
|
{
|
|
502
500
|
...{
|
|
@@ -516,7 +514,7 @@ const FormSubdomainMissions = ({
|
|
|
516
514
|
borderColor: "inherit"
|
|
517
515
|
}
|
|
518
516
|
},
|
|
519
|
-
children:
|
|
517
|
+
children: done || opens === "missions" ? content : /* @__PURE__ */ jsx(
|
|
520
518
|
Button,
|
|
521
519
|
{
|
|
522
520
|
...{
|
|
@@ -393,7 +393,7 @@ const TemplateLayout = ({
|
|
|
393
393
|
},
|
|
394
394
|
[affiliate, data, params, preview, style]
|
|
395
395
|
);
|
|
396
|
-
const leadMission = searchParams.get("
|
|
396
|
+
const leadMission = searchParams.get("open");
|
|
397
397
|
const leadUrl = submissionId ? null : (0, import_url.leadEndpoint)({ code: searchParams.get("m"), slug: params == null ? void 0 : params.slug, subdomain: params == null ? void 0 : params.subdomain, token });
|
|
398
398
|
(0, import_react.useEffect)(
|
|
399
399
|
() => {
|
|
@@ -361,7 +361,7 @@ const TemplateLayout = ({
|
|
|
361
361
|
},
|
|
362
362
|
[affiliate, data, params, preview, style]
|
|
363
363
|
);
|
|
364
|
-
const leadMission = searchParams.get("
|
|
364
|
+
const leadMission = searchParams.get("open");
|
|
365
365
|
const leadUrl = submissionId ? null : leadEndpoint({ code: searchParams.get("m"), slug: params == null ? void 0 : params.slug, subdomain: params == null ? void 0 : params.subdomain, token });
|
|
366
366
|
useEffect(
|
|
367
367
|
() => {
|
|
@@ -158,7 +158,7 @@ const TemplateModal = ({
|
|
|
158
158
|
);
|
|
159
159
|
// @story public-entry/lead-link
|
|
160
160
|
// Opened by the lead's own link while entries are being awarded:
|
|
161
|
-
// the missions panel, at the mission a `&
|
|
161
|
+
// the missions panel, at the mission a `&open=` asked for. With
|
|
162
162
|
// no missions the link opens no panel (template-layout.js).
|
|
163
163
|
case "lead":
|
|
164
164
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -126,7 +126,7 @@ const TemplateModal = ({
|
|
|
126
126
|
);
|
|
127
127
|
// @story public-entry/lead-link
|
|
128
128
|
// Opened by the lead's own link while entries are being awarded:
|
|
129
|
-
// the missions panel, at the mission a `&
|
|
129
|
+
// the missions panel, at the mission a `&open=` asked for. With
|
|
130
130
|
// no missions the link opens no panel (template-layout.js).
|
|
131
131
|
case "lead":
|
|
132
132
|
return /* @__PURE__ */ jsx(
|
|
@@ -33,6 +33,7 @@ __export(form_organization_workflow_exports, {
|
|
|
33
33
|
TextPreview: () => TextPreview,
|
|
34
34
|
firstEntryOnly: () => firstEntryOnly,
|
|
35
35
|
issueRow: () => issueRow,
|
|
36
|
+
memberOptions: () => memberOptions,
|
|
36
37
|
partToStart: () => partToStart,
|
|
37
38
|
pickedCopy: () => pickedCopy,
|
|
38
39
|
plainHtml: () => plainHtml,
|
|
@@ -109,20 +110,23 @@ const memberParams = {
|
|
|
109
110
|
createdAt: -1
|
|
110
111
|
}
|
|
111
112
|
};
|
|
113
|
+
const memberOptions = (organization) => ({
|
|
114
|
+
queryKey: ["organization-members", organization, "options"],
|
|
115
|
+
queryFn: async () => {
|
|
116
|
+
const { result } = await (0, import_fetch.request)({
|
|
117
|
+
endpoint: "/organization/" + organization + "/members",
|
|
118
|
+
// limit / skip / sort are required by the route's query validation.
|
|
119
|
+
params: memberParams
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
},
|
|
123
|
+
staleTime: Infinity
|
|
124
|
+
});
|
|
112
125
|
const useOrganizationMembers = (organization) => {
|
|
113
126
|
var _a;
|
|
114
127
|
const members = (0, import_react_query.useQuery)({
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const { result } = await (0, import_fetch.request)({
|
|
118
|
-
endpoint: "/organization/" + organization + "/members",
|
|
119
|
-
// limit / skip / sort are required by the route's query validation.
|
|
120
|
-
params: memberParams
|
|
121
|
-
});
|
|
122
|
-
return result;
|
|
123
|
-
},
|
|
124
|
-
enabled: Boolean(organization),
|
|
125
|
-
staleTime: Infinity
|
|
128
|
+
...memberOptions(organization),
|
|
129
|
+
enabled: Boolean(organization)
|
|
126
130
|
});
|
|
127
131
|
return {
|
|
128
132
|
items: ((_a = members.data) == null ? void 0 : _a.items) || [],
|
|
@@ -255,9 +259,9 @@ const responseSave = ({ email, sms }) => ({
|
|
|
255
259
|
message: sms.message
|
|
256
260
|
}
|
|
257
261
|
});
|
|
258
|
-
const plainHtml = (text) => String(text || "").split("\n").map((line) => {
|
|
262
|
+
const plainHtml = (text, variables) => String(text || "").split("\n").map((line) => {
|
|
259
263
|
const marked = line.match(/^\[(.+)\]$/);
|
|
260
|
-
return "<p>" + (marked ? '<span data-variable="placeholder" key="placeholder" label="' + (0, import_html.escapeHtml)(marked[1]) + '"></span>' : (0,
|
|
264
|
+
return "<p>" + (marked ? '<span data-variable="placeholder" key="placeholder" label="' + (0, import_html.escapeHtml)(marked[1]) + '"></span>' : (0, import_input_editor.plainLine)(line, variables)) + "</p>";
|
|
261
265
|
}).join("");
|
|
262
266
|
const taggedScore = (settings) => (settings == null ? void 0 : settings.score) ? {
|
|
263
267
|
...settings.score,
|
|
@@ -373,6 +377,7 @@ const workflowSchema = import_yup.default.object({
|
|
|
373
377
|
const useEmailPreview = ({ campaign, event, message, organization, subject, text, type }) => {
|
|
374
378
|
const asked = JSON.stringify(teamSteps.includes(type) ? { type } : { message, subject, text });
|
|
375
379
|
const [settled, setSettled] = (0, import_react.useState)(asked);
|
|
380
|
+
const last = (0, import_react.useRef)();
|
|
376
381
|
(0, import_react.useEffect)(() => {
|
|
377
382
|
const timer = setTimeout(() => setSettled(asked), 400);
|
|
378
383
|
return () => clearTimeout(timer);
|
|
@@ -390,7 +395,8 @@ const useEmailPreview = ({ campaign, event, message, organization, subject, text
|
|
|
390
395
|
},
|
|
391
396
|
queryKey: ["workflow-email-preview", organization, campaign, event, settled]
|
|
392
397
|
});
|
|
393
|
-
|
|
398
|
+
if (preview.data) last.current = preview.data;
|
|
399
|
+
return last.current;
|
|
394
400
|
};
|
|
395
401
|
const EmailStepCard = ({
|
|
396
402
|
card,
|
|
@@ -539,7 +545,7 @@ const RESPONSE_STATES = [
|
|
|
539
545
|
value: "sms"
|
|
540
546
|
}
|
|
541
547
|
];
|
|
542
|
-
const ResponseText = ({ className, id, text }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
548
|
+
const ResponseText = ({ className, id, text, variables }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
543
549
|
"div",
|
|
544
550
|
{
|
|
545
551
|
...{
|
|
@@ -550,7 +556,7 @@ const ResponseText = ({ className, id, text }) => /* @__PURE__ */ (0, import_jsx
|
|
|
550
556
|
import_input_editor.EditorView,
|
|
551
557
|
{
|
|
552
558
|
...{
|
|
553
|
-
value: plainHtml(text)
|
|
559
|
+
value: plainHtml(text, variables)
|
|
554
560
|
}
|
|
555
561
|
}
|
|
556
562
|
)
|
|
@@ -691,7 +697,8 @@ const ResponseStepCard = ({
|
|
|
691
697
|
{
|
|
692
698
|
...{
|
|
693
699
|
className: "w-full border border-inherit rounded px-3 py-2 disabled",
|
|
694
|
-
text: preview == null ? void 0 : preview.text
|
|
700
|
+
text: preview == null ? void 0 : preview.text,
|
|
701
|
+
variables
|
|
695
702
|
}
|
|
696
703
|
}
|
|
697
704
|
),
|
|
@@ -747,7 +754,8 @@ const ResponseStepCard = ({
|
|
|
747
754
|
},
|
|
748
755
|
onChange: ({ text }) => onChange(text),
|
|
749
756
|
plain: true,
|
|
750
|
-
value: value || ""
|
|
757
|
+
value: value || "",
|
|
758
|
+
variables
|
|
751
759
|
}
|
|
752
760
|
}
|
|
753
761
|
),
|
|
@@ -796,7 +804,15 @@ const ResponseStepCard = ({
|
|
|
796
804
|
}
|
|
797
805
|
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextPreview, { children: [
|
|
798
806
|
brand && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: brand }),
|
|
799
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
808
|
+
ResponseText,
|
|
809
|
+
{
|
|
810
|
+
...{
|
|
811
|
+
text: (_e = settings == null ? void 0 : settings.sms) == null ? void 0 : _e.message,
|
|
812
|
+
variables
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
),
|
|
800
816
|
(placeholders == null ? void 0 : placeholders.missions) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
801
817
|
ResponseText,
|
|
802
818
|
{
|
|
@@ -1548,9 +1564,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1548
1564
|
// QA read "Issue a discount code", built the one-step workflow that
|
|
1549
1565
|
// describes, and reported the codes as never arriving.
|
|
1550
1566
|
message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
1551
|
-
"Creates the code and saves it to the lead. To send it,
|
|
1552
|
-
"{{shopifyDiscountCode}}",
|
|
1553
|
-
" in the message.",
|
|
1567
|
+
"Creates the code and saves it to the lead. To send it, keep this step before Auto response and add Shopify Discount Code to its message.",
|
|
1554
1568
|
commerceDomain ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
1555
1569
|
" ",
|
|
1556
1570
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
|
|
@@ -1601,6 +1615,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1601
1615
|
TextPreview,
|
|
1602
1616
|
firstEntryOnly,
|
|
1603
1617
|
issueRow,
|
|
1618
|
+
memberOptions,
|
|
1604
1619
|
partToStart,
|
|
1605
1620
|
pickedCopy,
|
|
1606
1621
|
plainHtml,
|
|
@@ -17,7 +17,7 @@ import InputUrl from "../shared/input-url.mjs";
|
|
|
17
17
|
import InputResource from "./input-resource.mjs";
|
|
18
18
|
import InputCombobox from "./input-combobox.mjs";
|
|
19
19
|
import { FormNotification } from "./form-notification.mjs";
|
|
20
|
-
import InputEditor, { EditorView } from "./input-editor.mjs";
|
|
20
|
+
import InputEditor, { EditorView, plainLine } from "./input-editor.mjs";
|
|
21
21
|
import { InputArrayButton, InputArrayControl, InputArraySortable } from "./input-array.mjs";
|
|
22
22
|
import Badge from "../shared/badge.mjs";
|
|
23
23
|
import InputSwitch from "../shared/input-switch.mjs";
|
|
@@ -59,20 +59,23 @@ const memberParams = {
|
|
|
59
59
|
createdAt: -1
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
const memberOptions = (organization) => ({
|
|
63
|
+
queryKey: ["organization-members", organization, "options"],
|
|
64
|
+
queryFn: async () => {
|
|
65
|
+
const { result } = await request({
|
|
66
|
+
endpoint: "/organization/" + organization + "/members",
|
|
67
|
+
// limit / skip / sort are required by the route's query validation.
|
|
68
|
+
params: memberParams
|
|
69
|
+
});
|
|
70
|
+
return result;
|
|
71
|
+
},
|
|
72
|
+
staleTime: Infinity
|
|
73
|
+
});
|
|
62
74
|
const useOrganizationMembers = (organization) => {
|
|
63
75
|
var _a;
|
|
64
76
|
const members = useQuery({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const { result } = await request({
|
|
68
|
-
endpoint: "/organization/" + organization + "/members",
|
|
69
|
-
// limit / skip / sort are required by the route's query validation.
|
|
70
|
-
params: memberParams
|
|
71
|
-
});
|
|
72
|
-
return result;
|
|
73
|
-
},
|
|
74
|
-
enabled: Boolean(organization),
|
|
75
|
-
staleTime: Infinity
|
|
77
|
+
...memberOptions(organization),
|
|
78
|
+
enabled: Boolean(organization)
|
|
76
79
|
});
|
|
77
80
|
return {
|
|
78
81
|
items: ((_a = members.data) == null ? void 0 : _a.items) || [],
|
|
@@ -205,9 +208,9 @@ const responseSave = ({ email, sms }) => ({
|
|
|
205
208
|
message: sms.message
|
|
206
209
|
}
|
|
207
210
|
});
|
|
208
|
-
const plainHtml = (text) => String(text || "").split("\n").map((line) => {
|
|
211
|
+
const plainHtml = (text, variables) => String(text || "").split("\n").map((line) => {
|
|
209
212
|
const marked = line.match(/^\[(.+)\]$/);
|
|
210
|
-
return "<p>" + (marked ? '<span data-variable="placeholder" key="placeholder" label="' + escapeHtml(marked[1]) + '"></span>' :
|
|
213
|
+
return "<p>" + (marked ? '<span data-variable="placeholder" key="placeholder" label="' + escapeHtml(marked[1]) + '"></span>' : plainLine(line, variables)) + "</p>";
|
|
211
214
|
}).join("");
|
|
212
215
|
const taggedScore = (settings) => (settings == null ? void 0 : settings.score) ? {
|
|
213
216
|
...settings.score,
|
|
@@ -323,6 +326,7 @@ const workflowSchema = yup.object({
|
|
|
323
326
|
const useEmailPreview = ({ campaign, event, message, organization, subject, text, type }) => {
|
|
324
327
|
const asked = JSON.stringify(teamSteps.includes(type) ? { type } : { message, subject, text });
|
|
325
328
|
const [settled, setSettled] = useState(asked);
|
|
329
|
+
const last = useRef();
|
|
326
330
|
useEffect(() => {
|
|
327
331
|
const timer = setTimeout(() => setSettled(asked), 400);
|
|
328
332
|
return () => clearTimeout(timer);
|
|
@@ -340,7 +344,8 @@ const useEmailPreview = ({ campaign, event, message, organization, subject, text
|
|
|
340
344
|
},
|
|
341
345
|
queryKey: ["workflow-email-preview", organization, campaign, event, settled]
|
|
342
346
|
});
|
|
343
|
-
|
|
347
|
+
if (preview.data) last.current = preview.data;
|
|
348
|
+
return last.current;
|
|
344
349
|
};
|
|
345
350
|
const EmailStepCard = ({
|
|
346
351
|
card,
|
|
@@ -489,7 +494,7 @@ const RESPONSE_STATES = [
|
|
|
489
494
|
value: "sms"
|
|
490
495
|
}
|
|
491
496
|
];
|
|
492
|
-
const ResponseText = ({ className, id, text }) => /* @__PURE__ */ jsx(
|
|
497
|
+
const ResponseText = ({ className, id, text, variables }) => /* @__PURE__ */ jsx(
|
|
493
498
|
"div",
|
|
494
499
|
{
|
|
495
500
|
...{
|
|
@@ -500,7 +505,7 @@ const ResponseText = ({ className, id, text }) => /* @__PURE__ */ jsx(
|
|
|
500
505
|
EditorView,
|
|
501
506
|
{
|
|
502
507
|
...{
|
|
503
|
-
value: plainHtml(text)
|
|
508
|
+
value: plainHtml(text, variables)
|
|
504
509
|
}
|
|
505
510
|
}
|
|
506
511
|
)
|
|
@@ -641,7 +646,8 @@ const ResponseStepCard = ({
|
|
|
641
646
|
{
|
|
642
647
|
...{
|
|
643
648
|
className: "w-full border border-inherit rounded px-3 py-2 disabled",
|
|
644
|
-
text: preview == null ? void 0 : preview.text
|
|
649
|
+
text: preview == null ? void 0 : preview.text,
|
|
650
|
+
variables
|
|
645
651
|
}
|
|
646
652
|
}
|
|
647
653
|
),
|
|
@@ -697,7 +703,8 @@ const ResponseStepCard = ({
|
|
|
697
703
|
},
|
|
698
704
|
onChange: ({ text }) => onChange(text),
|
|
699
705
|
plain: true,
|
|
700
|
-
value: value || ""
|
|
706
|
+
value: value || "",
|
|
707
|
+
variables
|
|
701
708
|
}
|
|
702
709
|
}
|
|
703
710
|
),
|
|
@@ -746,7 +753,15 @@ const ResponseStepCard = ({
|
|
|
746
753
|
}
|
|
747
754
|
) : /* @__PURE__ */ jsxs(TextPreview, { children: [
|
|
748
755
|
brand && /* @__PURE__ */ jsx("p", { children: brand }),
|
|
749
|
-
/* @__PURE__ */ jsx(
|
|
756
|
+
/* @__PURE__ */ jsx(
|
|
757
|
+
ResponseText,
|
|
758
|
+
{
|
|
759
|
+
...{
|
|
760
|
+
text: (_e = settings == null ? void 0 : settings.sms) == null ? void 0 : _e.message,
|
|
761
|
+
variables
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
),
|
|
750
765
|
(placeholders == null ? void 0 : placeholders.missions) && /* @__PURE__ */ jsx(
|
|
751
766
|
ResponseText,
|
|
752
767
|
{
|
|
@@ -1498,9 +1513,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1498
1513
|
// QA read "Issue a discount code", built the one-step workflow that
|
|
1499
1514
|
// describes, and reported the codes as never arriving.
|
|
1500
1515
|
message: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1501
|
-
"Creates the code and saves it to the lead. To send it,
|
|
1502
|
-
"{{shopifyDiscountCode}}",
|
|
1503
|
-
" in the message.",
|
|
1516
|
+
"Creates the code and saves it to the lead. To send it, keep this step before Auto response and add Shopify Discount Code to its message.",
|
|
1504
1517
|
commerceDomain ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1505
1518
|
" ",
|
|
1506
1519
|
/* @__PURE__ */ jsx("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
|
|
@@ -1550,6 +1563,7 @@ export {
|
|
|
1550
1563
|
TextPreview,
|
|
1551
1564
|
firstEntryOnly,
|
|
1552
1565
|
issueRow,
|
|
1566
|
+
memberOptions,
|
|
1553
1567
|
partToStart,
|
|
1554
1568
|
pickedCopy,
|
|
1555
1569
|
plainHtml,
|
|
@@ -32,7 +32,8 @@ __export(input_editor_exports, {
|
|
|
32
32
|
Variable: () => Variable,
|
|
33
33
|
default: () => input_editor_default,
|
|
34
34
|
linkText: () => linkText,
|
|
35
|
-
plainContent: () => plainContent
|
|
35
|
+
plainContent: () => plainContent,
|
|
36
|
+
plainLine: () => plainLine
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(input_editor_exports);
|
|
38
39
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -109,12 +110,18 @@ const plainExtensions = [
|
|
|
109
110
|
orderedList: false,
|
|
110
111
|
strike: false,
|
|
111
112
|
underline: false
|
|
112
|
-
})
|
|
113
|
+
}),
|
|
114
|
+
Variable
|
|
113
115
|
];
|
|
114
116
|
const plainOptions = {
|
|
115
117
|
blockSeparator: "\n"
|
|
116
118
|
};
|
|
117
|
-
const
|
|
119
|
+
const plainLine = (line, variables) => (0, import_html.escapeHtml)(line).replace(/\{\{(\w+)\}\}/g, (_, key) => {
|
|
120
|
+
var _a;
|
|
121
|
+
const label = ((_a = variables == null ? void 0 : variables.find((item) => item.key === key)) == null ? void 0 : _a.label) || key;
|
|
122
|
+
return '<span data-variable="' + key + '" key="' + key + '" label="' + (0, import_html.escapeHtml)(label) + '"></span>';
|
|
123
|
+
});
|
|
124
|
+
const plainContent = (value, variables) => String(value || "").split("\n").map((line) => "<p>" + plainLine(line, variables) + "</p>").join("");
|
|
118
125
|
const EditorView = ({ value }) => {
|
|
119
126
|
const editor = (0, import_react2.useEditor)({
|
|
120
127
|
content: value || "",
|
|
@@ -150,7 +157,7 @@ const InputEditor = ({
|
|
|
150
157
|
const [draft, setDraft] = (0, import_react.useState)(null);
|
|
151
158
|
const editor = (0, import_react2.useEditor)({
|
|
152
159
|
extensions: plain ? plainExtensions : extensions,
|
|
153
|
-
content: plain ? plainContent(value) : value || "",
|
|
160
|
+
content: plain ? plainContent(value, variables) : value || "",
|
|
154
161
|
editable: !disabled,
|
|
155
162
|
editorProps: {
|
|
156
163
|
attributes: {
|
|
@@ -218,7 +225,7 @@ const InputEditor = ({
|
|
|
218
225
|
() => {
|
|
219
226
|
if (!editor) return;
|
|
220
227
|
if (plain ? (value || "") !== editor.getText(plainOptions) : value !== editor.getHTML()) {
|
|
221
|
-
editor.commands.setContent(plain ? plainContent(value) : value || "", { emitUpdate: false });
|
|
228
|
+
editor.commands.setContent(plain ? plainContent(value, variables) : value || "", { emitUpdate: false });
|
|
222
229
|
}
|
|
223
230
|
},
|
|
224
231
|
[editor, plain, value]
|
|
@@ -235,14 +242,14 @@ const InputEditor = ({
|
|
|
235
242
|
className: ["w-full border border-inherit rounded overflow-hidden", disabled ? "disabled" : ""].join(" ").trim()
|
|
236
243
|
},
|
|
237
244
|
children: [
|
|
238
|
-
!plain && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
245
|
+
(!plain || (variables == null ? void 0 : variables.length) > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
239
246
|
"div",
|
|
240
247
|
{
|
|
241
248
|
...{
|
|
242
|
-
className: "flex items-center
|
|
249
|
+
className: ["flex items-center p-1 bg-gray-light", plain ? "justify-end" : "justify-between"].join(" ")
|
|
243
250
|
},
|
|
244
251
|
children: [
|
|
245
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
252
|
+
!plain && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
246
253
|
"div",
|
|
247
254
|
{
|
|
248
255
|
...{
|
|
@@ -508,5 +515,6 @@ var input_editor_default = InputEditor;
|
|
|
508
515
|
EditorView,
|
|
509
516
|
Variable,
|
|
510
517
|
linkText,
|
|
511
|
-
plainContent
|
|
518
|
+
plainContent,
|
|
519
|
+
plainLine
|
|
512
520
|
});
|
|
@@ -73,12 +73,18 @@ const plainExtensions = [
|
|
|
73
73
|
orderedList: false,
|
|
74
74
|
strike: false,
|
|
75
75
|
underline: false
|
|
76
|
-
})
|
|
76
|
+
}),
|
|
77
|
+
Variable
|
|
77
78
|
];
|
|
78
79
|
const plainOptions = {
|
|
79
80
|
blockSeparator: "\n"
|
|
80
81
|
};
|
|
81
|
-
const
|
|
82
|
+
const plainLine = (line, variables) => escapeHtml(line).replace(/\{\{(\w+)\}\}/g, (_, key) => {
|
|
83
|
+
var _a;
|
|
84
|
+
const label = ((_a = variables == null ? void 0 : variables.find((item) => item.key === key)) == null ? void 0 : _a.label) || key;
|
|
85
|
+
return '<span data-variable="' + key + '" key="' + key + '" label="' + escapeHtml(label) + '"></span>';
|
|
86
|
+
});
|
|
87
|
+
const plainContent = (value, variables) => String(value || "").split("\n").map((line) => "<p>" + plainLine(line, variables) + "</p>").join("");
|
|
82
88
|
const EditorView = ({ value }) => {
|
|
83
89
|
const editor = useEditor({
|
|
84
90
|
content: value || "",
|
|
@@ -114,7 +120,7 @@ const InputEditor = ({
|
|
|
114
120
|
const [draft, setDraft] = useState(null);
|
|
115
121
|
const editor = useEditor({
|
|
116
122
|
extensions: plain ? plainExtensions : extensions,
|
|
117
|
-
content: plain ? plainContent(value) : value || "",
|
|
123
|
+
content: plain ? plainContent(value, variables) : value || "",
|
|
118
124
|
editable: !disabled,
|
|
119
125
|
editorProps: {
|
|
120
126
|
attributes: {
|
|
@@ -182,7 +188,7 @@ const InputEditor = ({
|
|
|
182
188
|
() => {
|
|
183
189
|
if (!editor) return;
|
|
184
190
|
if (plain ? (value || "") !== editor.getText(plainOptions) : value !== editor.getHTML()) {
|
|
185
|
-
editor.commands.setContent(plain ? plainContent(value) : value || "", { emitUpdate: false });
|
|
191
|
+
editor.commands.setContent(plain ? plainContent(value, variables) : value || "", { emitUpdate: false });
|
|
186
192
|
}
|
|
187
193
|
},
|
|
188
194
|
[editor, plain, value]
|
|
@@ -199,14 +205,14 @@ const InputEditor = ({
|
|
|
199
205
|
className: ["w-full border border-inherit rounded overflow-hidden", disabled ? "disabled" : ""].join(" ").trim()
|
|
200
206
|
},
|
|
201
207
|
children: [
|
|
202
|
-
!plain && /* @__PURE__ */ jsxs(
|
|
208
|
+
(!plain || (variables == null ? void 0 : variables.length) > 0) && /* @__PURE__ */ jsxs(
|
|
203
209
|
"div",
|
|
204
210
|
{
|
|
205
211
|
...{
|
|
206
|
-
className: "flex items-center
|
|
212
|
+
className: ["flex items-center p-1 bg-gray-light", plain ? "justify-end" : "justify-between"].join(" ")
|
|
207
213
|
},
|
|
208
214
|
children: [
|
|
209
|
-
/* @__PURE__ */ jsxs(
|
|
215
|
+
!plain && /* @__PURE__ */ jsxs(
|
|
210
216
|
"div",
|
|
211
217
|
{
|
|
212
218
|
...{
|
|
@@ -472,5 +478,6 @@ export {
|
|
|
472
478
|
Variable,
|
|
473
479
|
input_editor_default as default,
|
|
474
480
|
linkText,
|
|
475
|
-
plainContent
|
|
481
|
+
plainContent,
|
|
482
|
+
plainLine
|
|
476
483
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drawbridge/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./advertisement": {
|
|
6
6
|
"types": "./types/advertisement.d.ts",
|
|
@@ -1663,7 +1663,7 @@
|
|
|
1663
1663
|
"peerDependencies": {
|
|
1664
1664
|
"@analytics/google-tag-manager": ">=0.5.5",
|
|
1665
1665
|
"@drawbridge/drawbridge-telemetry": ">=0.0.19",
|
|
1666
|
-
"@drawbridge/drawbridge-utils": ">=0.0.
|
|
1666
|
+
"@drawbridge/drawbridge-utils": ">=0.0.230",
|
|
1667
1667
|
"@headlessui/react": ">=2.1.2",
|
|
1668
1668
|
"@hookform/resolvers": ">=3.1.1",
|
|
1669
1669
|
"@sentry/nextjs": ">=10.58.0",
|
|
@@ -1783,7 +1783,7 @@
|
|
|
1783
1783
|
"@analytics/google-tag-manager": "0.5.5",
|
|
1784
1784
|
"@drawbridge/drawbridge-agents": "0.1.102",
|
|
1785
1785
|
"@drawbridge/drawbridge-telemetry": "0.0.19",
|
|
1786
|
-
"@drawbridge/drawbridge-utils": "0.0.
|
|
1786
|
+
"@drawbridge/drawbridge-utils": "0.0.230",
|
|
1787
1787
|
"@headlessui/react": "2.2.9",
|
|
1788
1788
|
"@hookform/resolvers": "3.1.1",
|
|
1789
1789
|
"@sentry/nextjs": "10.58.0",
|
|
@@ -14,7 +14,7 @@ export interface FormSubdomainMissionsProps {
|
|
|
14
14
|
advertisements?: ReactNode;
|
|
15
15
|
button?: ReactNode;
|
|
16
16
|
contact?: { email?: string | null; phone?: string | null };
|
|
17
|
-
// The mission a lead link's `&
|
|
17
|
+
// The mission a lead link's `&open=` opens at.
|
|
18
18
|
initial?: string | null;
|
|
19
19
|
message?: ReactNode;
|
|
20
20
|
missions?: MissionItem[];
|
|
@@ -11,7 +11,8 @@ export interface InputEditorProps {
|
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
// Sits under what is typed, outside the document, so it cannot be removed.
|
|
13
13
|
locked?: ReactNode;
|
|
14
|
-
// No
|
|
14
|
+
// No formatting tools, only the Variables menu while there is something to
|
|
15
|
+
// insert; `value` and the emitted `text` are plain text, a variable as {{key}}.
|
|
15
16
|
plain?: boolean;
|
|
16
17
|
// Both renderings; pass `html` to a react-hook-form field, not the object.
|
|
17
18
|
onChange?: ( value: { html: string; text: string } ) => void;
|
|
@@ -29,7 +30,8 @@ export declare const Variable: Node;
|
|
|
29
30
|
// The text serializer that keeps a link's address in the plain rendering.
|
|
30
31
|
export declare const linkText: ( props: { node: any; parent: any; index: number } ) => string;
|
|
31
32
|
|
|
32
|
-
export declare const
|
|
33
|
+
export declare const plainLine: ( line: string, variables?: { key: string; label?: string }[] ) => string;
|
|
34
|
+
export declare const plainContent: ( value?: string, variables?: { key: string; label?: string }[] ) => string;
|
|
33
35
|
|
|
34
36
|
export declare const EditorView: ComponentType<EditorViewProps>;
|
|
35
37
|
|