@drawbridge/components 0.1.32 → 0.1.33
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.
|
@@ -181,7 +181,7 @@ const stepReason = ({ entry, saved = [], type }) => {
|
|
|
181
181
|
var _a, _b;
|
|
182
182
|
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;
|
|
183
183
|
};
|
|
184
|
-
const hasStepOptions = (options = []) => options.some((option) => Boolean(option == null ? void 0 : option.value));
|
|
184
|
+
const hasStepOptions = (options = []) => options.some((option) => Boolean(option == null ? void 0 : option.value) && !(option == null ? void 0 : option.disabled));
|
|
185
185
|
const responseStart = (number) => ({
|
|
186
186
|
email: {
|
|
187
187
|
enabled: true,
|
|
@@ -976,66 +976,76 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
976
976
|
const usedTypes = (watchedSteps || []).map((s, i) => i !== index ? s.type : null).filter(Boolean);
|
|
977
977
|
return [
|
|
978
978
|
{ key: "Select a step", value: "" },
|
|
979
|
-
...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).
|
|
979
|
+
...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).sort((a, b) => String(a.key).localeCompare(String(b.key))).map((step) => {
|
|
980
980
|
var _a2;
|
|
981
|
-
return
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
|
|
981
|
+
return {
|
|
982
|
+
...step,
|
|
983
|
+
// Option values must be unique per catalog entry, not per step
|
|
984
|
+
// type. Two connections offering the same step type collide,
|
|
985
|
+
// because the select resolves its displayed option by first value
|
|
986
|
+
// match — so a disconnected step rendered as whichever entry came
|
|
987
|
+
// first. Suffix the connectionId when active, the connection slug
|
|
988
|
+
// when not.
|
|
989
|
+
//
|
|
990
|
+
// The collision that produced this was mailchimp and sendgrid both
|
|
991
|
+
// offering `step.email.send`. Neither does now — email steps are
|
|
992
|
+
// connectionless and sendgrid is gone — but the rule is about any
|
|
993
|
+
// two entries sharing a type, so it stays.
|
|
994
|
+
value: step.connectionId ? step.value + "::" + step.connectionId : step.slug ? step.value + "::" + step.slug : step.value,
|
|
995
|
+
...step.disabled && !step.reason ? {
|
|
996
|
+
badge: {
|
|
997
|
+
text: "Enable connection"
|
|
998
|
+
},
|
|
999
|
+
disabled: false,
|
|
1000
|
+
element: import_link.default,
|
|
1001
|
+
key: step == null ? void 0 : step.key,
|
|
1002
|
+
props: {
|
|
1003
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/connections/" + step.slug
|
|
1004
|
+
}
|
|
1005
|
+
} : {},
|
|
1006
|
+
// The same link-shaped option, greyed: it cannot be picked, and
|
|
1007
|
+
// clicking it opens Settings, where the number is bought.
|
|
1008
|
+
...step.value === "step.sms.send" && !smsActive ? {
|
|
1009
|
+
badge: {
|
|
1010
|
+
text: "Settings"
|
|
1011
|
+
},
|
|
1012
|
+
className: "opacity-50",
|
|
1013
|
+
disabled: false,
|
|
1014
|
+
element: import_link.default,
|
|
1015
|
+
key: step == null ? void 0 : step.key,
|
|
1016
|
+
props: {
|
|
1017
|
+
"aria-disabled": true,
|
|
1018
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/settings"
|
|
1019
|
+
}
|
|
1020
|
+
} : {},
|
|
1021
|
+
// @story workflows/edit
|
|
1022
|
+
// A step the form cannot feed: greyed with its reason, and a
|
|
1023
|
+
// click opens the campaign's Form page, where the field is added.
|
|
1024
|
+
...step.reason ? {
|
|
1025
|
+
badge: {
|
|
1026
|
+
text: step.reason
|
|
1027
|
+
},
|
|
1028
|
+
className: "opacity-50",
|
|
1029
|
+
disabled: false,
|
|
1030
|
+
element: import_link.default,
|
|
1031
|
+
key: step == null ? void 0 : step.key,
|
|
1032
|
+
props: {
|
|
1033
|
+
"aria-disabled": true,
|
|
1034
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/campaigns/" + (values == null ? void 0 : values.campaign) + "/form"
|
|
1035
|
+
}
|
|
1036
|
+
} : {},
|
|
1037
|
+
// @story workflows/edit
|
|
1038
|
+
// The catalog flags a step ownerOnly for a member: shown greyed with
|
|
1039
|
+
// an Owner badge so they know it exists, but it cannot be picked. A
|
|
1040
|
+
// row the owner built keeps it as its label.
|
|
1041
|
+
...step.ownerOnly && step.value !== ((_a2 = watchedSteps == null ? void 0 : watchedSteps[index]) == null ? void 0 : _a2.type) ? {
|
|
1042
|
+
badge: {
|
|
1043
|
+
text: "Owner"
|
|
1044
|
+
},
|
|
1045
|
+
disabled: true
|
|
1046
|
+
} : {}
|
|
1047
|
+
};
|
|
1048
|
+
})
|
|
1039
1049
|
];
|
|
1040
1050
|
};
|
|
1041
1051
|
const lockedStep = (index) => ((catalog == null ? void 0 : catalog.steps) || []).some((s) => {
|
|
@@ -1065,7 +1075,19 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1065
1075
|
slug: def.slug
|
|
1066
1076
|
};
|
|
1067
1077
|
};
|
|
1068
|
-
const renderStepBadge = (field) => {
|
|
1078
|
+
const renderStepBadge = (field, index) => {
|
|
1079
|
+
if (lockedStep(index)) {
|
|
1080
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1081
|
+
import_badge.default,
|
|
1082
|
+
{
|
|
1083
|
+
...{
|
|
1084
|
+
size: "small",
|
|
1085
|
+
type: "secondary"
|
|
1086
|
+
},
|
|
1087
|
+
children: "Owner"
|
|
1088
|
+
}
|
|
1089
|
+
);
|
|
1090
|
+
}
|
|
1069
1091
|
const reason = stepReason({ entry: catalog, saved: values == null ? void 0 : values.steps, type: field == null ? void 0 : field.type });
|
|
1070
1092
|
if (reason) {
|
|
1071
1093
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1274,7 +1296,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1274
1296
|
className: "flex items-center gap-2"
|
|
1275
1297
|
},
|
|
1276
1298
|
children: [
|
|
1277
|
-
renderStepBadge(step),
|
|
1299
|
+
renderStepBadge(step, index),
|
|
1278
1300
|
!lockedStep(index) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1279
1301
|
import_input_array.InputArrayControl,
|
|
1280
1302
|
{
|
|
@@ -1298,7 +1320,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1298
1320
|
{
|
|
1299
1321
|
...{
|
|
1300
1322
|
"aria-label": ((_a3 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a3.key) || "Step " + (index + 1),
|
|
1301
|
-
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting) || parts && !parts.can,
|
|
1323
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting) || lockedStep(index) || parts && !parts.can,
|
|
1302
1324
|
onChange: (next) => {
|
|
1303
1325
|
onChange(next);
|
|
1304
1326
|
if (parts && next && partToStart(parts)) setValue(`steps.${index}.settings.${partToStart(parts)}.enabled`, true);
|
|
@@ -128,7 +128,7 @@ const stepReason = ({ entry, saved = [], type }) => {
|
|
|
128
128
|
var _a, _b;
|
|
129
129
|
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;
|
|
130
130
|
};
|
|
131
|
-
const hasStepOptions = (options = []) => options.some((option) => Boolean(option == null ? void 0 : option.value));
|
|
131
|
+
const hasStepOptions = (options = []) => options.some((option) => Boolean(option == null ? void 0 : option.value) && !(option == null ? void 0 : option.disabled));
|
|
132
132
|
const responseStart = (number) => ({
|
|
133
133
|
email: {
|
|
134
134
|
enabled: true,
|
|
@@ -923,66 +923,76 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
923
923
|
const usedTypes = (watchedSteps || []).map((s, i) => i !== index ? s.type : null).filter(Boolean);
|
|
924
924
|
return [
|
|
925
925
|
{ key: "Select a step", value: "" },
|
|
926
|
-
...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).
|
|
926
|
+
...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).sort((a, b) => String(a.key).localeCompare(String(b.key))).map((step) => {
|
|
927
927
|
var _a2;
|
|
928
|
-
return
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
|
|
928
|
+
return {
|
|
929
|
+
...step,
|
|
930
|
+
// Option values must be unique per catalog entry, not per step
|
|
931
|
+
// type. Two connections offering the same step type collide,
|
|
932
|
+
// because the select resolves its displayed option by first value
|
|
933
|
+
// match — so a disconnected step rendered as whichever entry came
|
|
934
|
+
// first. Suffix the connectionId when active, the connection slug
|
|
935
|
+
// when not.
|
|
936
|
+
//
|
|
937
|
+
// The collision that produced this was mailchimp and sendgrid both
|
|
938
|
+
// offering `step.email.send`. Neither does now — email steps are
|
|
939
|
+
// connectionless and sendgrid is gone — but the rule is about any
|
|
940
|
+
// two entries sharing a type, so it stays.
|
|
941
|
+
value: step.connectionId ? step.value + "::" + step.connectionId : step.slug ? step.value + "::" + step.slug : step.value,
|
|
942
|
+
...step.disabled && !step.reason ? {
|
|
943
|
+
badge: {
|
|
944
|
+
text: "Enable connection"
|
|
945
|
+
},
|
|
946
|
+
disabled: false,
|
|
947
|
+
element: Link,
|
|
948
|
+
key: step == null ? void 0 : step.key,
|
|
949
|
+
props: {
|
|
950
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/connections/" + step.slug
|
|
951
|
+
}
|
|
952
|
+
} : {},
|
|
953
|
+
// The same link-shaped option, greyed: it cannot be picked, and
|
|
954
|
+
// clicking it opens Settings, where the number is bought.
|
|
955
|
+
...step.value === "step.sms.send" && !smsActive ? {
|
|
956
|
+
badge: {
|
|
957
|
+
text: "Settings"
|
|
958
|
+
},
|
|
959
|
+
className: "opacity-50",
|
|
960
|
+
disabled: false,
|
|
961
|
+
element: Link,
|
|
962
|
+
key: step == null ? void 0 : step.key,
|
|
963
|
+
props: {
|
|
964
|
+
"aria-disabled": true,
|
|
965
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/settings"
|
|
966
|
+
}
|
|
967
|
+
} : {},
|
|
968
|
+
// @story workflows/edit
|
|
969
|
+
// A step the form cannot feed: greyed with its reason, and a
|
|
970
|
+
// click opens the campaign's Form page, where the field is added.
|
|
971
|
+
...step.reason ? {
|
|
972
|
+
badge: {
|
|
973
|
+
text: step.reason
|
|
974
|
+
},
|
|
975
|
+
className: "opacity-50",
|
|
976
|
+
disabled: false,
|
|
977
|
+
element: Link,
|
|
978
|
+
key: step == null ? void 0 : step.key,
|
|
979
|
+
props: {
|
|
980
|
+
"aria-disabled": true,
|
|
981
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/campaigns/" + (values == null ? void 0 : values.campaign) + "/form"
|
|
982
|
+
}
|
|
983
|
+
} : {},
|
|
984
|
+
// @story workflows/edit
|
|
985
|
+
// The catalog flags a step ownerOnly for a member: shown greyed with
|
|
986
|
+
// an Owner badge so they know it exists, but it cannot be picked. A
|
|
987
|
+
// row the owner built keeps it as its label.
|
|
988
|
+
...step.ownerOnly && step.value !== ((_a2 = watchedSteps == null ? void 0 : watchedSteps[index]) == null ? void 0 : _a2.type) ? {
|
|
989
|
+
badge: {
|
|
990
|
+
text: "Owner"
|
|
991
|
+
},
|
|
992
|
+
disabled: true
|
|
993
|
+
} : {}
|
|
994
|
+
};
|
|
995
|
+
})
|
|
986
996
|
];
|
|
987
997
|
};
|
|
988
998
|
const lockedStep = (index) => ((catalog == null ? void 0 : catalog.steps) || []).some((s) => {
|
|
@@ -1012,7 +1022,19 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1012
1022
|
slug: def.slug
|
|
1013
1023
|
};
|
|
1014
1024
|
};
|
|
1015
|
-
const renderStepBadge = (field) => {
|
|
1025
|
+
const renderStepBadge = (field, index) => {
|
|
1026
|
+
if (lockedStep(index)) {
|
|
1027
|
+
return /* @__PURE__ */ jsx(
|
|
1028
|
+
Badge,
|
|
1029
|
+
{
|
|
1030
|
+
...{
|
|
1031
|
+
size: "small",
|
|
1032
|
+
type: "secondary"
|
|
1033
|
+
},
|
|
1034
|
+
children: "Owner"
|
|
1035
|
+
}
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1016
1038
|
const reason = stepReason({ entry: catalog, saved: values == null ? void 0 : values.steps, type: field == null ? void 0 : field.type });
|
|
1017
1039
|
if (reason) {
|
|
1018
1040
|
return /* @__PURE__ */ jsx(
|
|
@@ -1221,7 +1243,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1221
1243
|
className: "flex items-center gap-2"
|
|
1222
1244
|
},
|
|
1223
1245
|
children: [
|
|
1224
|
-
renderStepBadge(step),
|
|
1246
|
+
renderStepBadge(step, index),
|
|
1225
1247
|
!lockedStep(index) && /* @__PURE__ */ jsx(
|
|
1226
1248
|
InputArrayControl,
|
|
1227
1249
|
{
|
|
@@ -1245,7 +1267,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1245
1267
|
{
|
|
1246
1268
|
...{
|
|
1247
1269
|
"aria-label": ((_a3 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a3.key) || "Step " + (index + 1),
|
|
1248
|
-
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting) || parts && !parts.can,
|
|
1270
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting) || lockedStep(index) || parts && !parts.can,
|
|
1249
1271
|
onChange: (next) => {
|
|
1250
1272
|
onChange(next);
|
|
1251
1273
|
if (parts && next && partToStart(parts)) setValue(`steps.${index}.settings.${partToStart(parts)}.enabled`, true);
|