@drawbridge/components 0.1.31 → 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.
Files changed (69) hide show
  1. package/dist/bridge/template-modal.js +2 -1
  2. package/dist/bridge/template-modal.mjs +2 -1
  3. package/dist/dashboard/buttons-subscription.js +65 -20
  4. package/dist/dashboard/buttons-subscription.mjs +64 -20
  5. package/dist/dashboard/card-payment-method.js +1 -1
  6. package/dist/dashboard/card-payment-method.mjs +1 -1
  7. package/dist/dashboard/card-section.js +2 -2
  8. package/dist/dashboard/card-section.mjs +2 -2
  9. package/dist/dashboard/card-setting.js +4 -3
  10. package/dist/dashboard/card-setting.mjs +4 -3
  11. package/dist/dashboard/card-task.js +22 -4
  12. package/dist/dashboard/card-task.mjs +22 -4
  13. package/dist/dashboard/card-tile.js +6 -6
  14. package/dist/dashboard/card-tile.mjs +6 -6
  15. package/dist/dashboard/drawer.js +7 -2
  16. package/dist/dashboard/drawer.mjs +8 -3
  17. package/dist/dashboard/form-organization-workflow.js +87 -65
  18. package/dist/dashboard/form-organization-workflow.mjs +87 -65
  19. package/dist/dashboard/input-combobox.js +7 -2
  20. package/dist/dashboard/input-combobox.mjs +7 -2
  21. package/dist/dashboard/lib/escape.js +48 -0
  22. package/dist/dashboard/lib/escape.mjs +25 -0
  23. package/dist/dashboard/lib/rail.js +75 -0
  24. package/dist/dashboard/lib/rail.mjs +46 -0
  25. package/dist/dashboard/lib/throttle.js +57 -0
  26. package/dist/dashboard/lib/throttle.mjs +34 -0
  27. package/dist/dashboard/list.js +1 -1
  28. package/dist/dashboard/list.mjs +1 -1
  29. package/dist/dashboard/menu.js +188 -96
  30. package/dist/dashboard/menu.mjs +189 -97
  31. package/dist/dashboard/modal.js +9 -3
  32. package/dist/dashboard/modal.mjs +10 -4
  33. package/dist/dashboard/notice.js +5 -3
  34. package/dist/dashboard/notice.mjs +5 -3
  35. package/dist/dashboard/table-cell-title.js +2 -0
  36. package/dist/dashboard/table-cell-title.mjs +2 -0
  37. package/dist/dashboard/table.js +61 -20
  38. package/dist/dashboard/table.mjs +61 -20
  39. package/dist/dashboard/template-dashboard.js +35 -133
  40. package/dist/dashboard/template-dashboard.mjs +36 -134
  41. package/dist/dashboard/template-rail.js +674 -0
  42. package/dist/dashboard/template-rail.mjs +640 -0
  43. package/dist/dashboard/template-socket.js +19 -3
  44. package/dist/dashboard/template-socket.mjs +19 -3
  45. package/dist/dashboard/template-ui.js +150 -186
  46. package/dist/dashboard/template-ui.mjs +151 -187
  47. package/dist/icons/book-open.js +46 -0
  48. package/dist/icons/book-open.mjs +27 -0
  49. package/dist/icons/task.js +46 -0
  50. package/dist/icons/task.mjs +27 -0
  51. package/dist/shared/lib/helpers.js +9 -2
  52. package/dist/shared/lib/helpers.mjs +9 -2
  53. package/dist/shared/lib/motion.js +27 -0
  54. package/dist/shared/lib/motion.mjs +4 -0
  55. package/dist/shared/overlay.js +5 -3
  56. package/dist/shared/overlay.mjs +5 -3
  57. package/package.json +28 -13
  58. package/types/dashboard/card-task.d.ts +5 -1
  59. package/types/dashboard/lib/rail.d.ts +32 -0
  60. package/types/dashboard/lib/throttle.d.ts +5 -0
  61. package/types/dashboard/table.d.ts +3 -1
  62. package/types/dashboard/template-dashboard.d.ts +4 -1
  63. package/types/dashboard/template-rail.d.ts +36 -0
  64. package/types/dashboard/template-ui.d.ts +2 -2
  65. package/types/icons/book-open.d.ts +5 -0
  66. package/types/icons/task.d.ts +5 -0
  67. package/dist/dashboard/guide.js +0 -238
  68. package/dist/dashboard/guide.mjs +0 -209
  69. package/types/dashboard/guide.d.ts +0 -23
@@ -1,6 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Fragment } from "react";
2
+ import { Fragment, useRef } from "react";
3
3
  import { Transition } from "@headlessui/react";
4
+ import { useEscape } from "./lib/escape.mjs";
5
+ import { motion } from "../shared/lib/motion.mjs";
4
6
  import Times from "../icons/times.mjs";
5
7
  import Button from "../shared/button.mjs";
6
8
  import { FormScope } from "../shared/lib/form.mjs";
@@ -14,6 +16,8 @@ const Drawer = ({
14
16
  overlay = true,
15
17
  title
16
18
  }) => {
19
+ const close = useRef(null);
20
+ useEscape(active, close);
17
21
  const classes = {
18
22
  drawer: [
19
23
  className,
@@ -22,9 +26,9 @@ const Drawer = ({
22
26
  // Enter slides in immediately (no delay): the panel used to wait
23
27
  // 300ms at translate-x-full, so a reopen before the previous leave
24
28
  // finished re-entered stuck off-screen for that delay. Leave stays
25
- // immediate; the overlay lingers 300ms so the panel slides out
29
+ // immediate; the overlay lingers 100ms so the panel slides out
26
30
  // first on close.
27
- "transition duration-200 ease-in",
31
+ motion,
28
32
  "data-[closed]:translate-x-full"
29
33
  ],
30
34
  header: [
@@ -71,6 +75,7 @@ const Drawer = ({
71
75
  "data-guard": "drawer",
72
76
  inline: true,
73
77
  onClick: onClose,
78
+ ref: close,
74
79
  variant: "link"
75
80
  },
76
81
  children: /* @__PURE__ */ jsx(
@@ -88,9 +88,9 @@ const messageSteps = [...emailSteps, "step.sms.send"];
88
88
  const renderedSteps = [...emailSteps, ...teamSteps];
89
89
  const RESPONSE = "step.response.send";
90
90
  const firstEntryOnly = ({ campaign, event, type }) => {
91
- var _a, _b;
91
+ var _a;
92
92
  if (event !== "lead.insert" || !type || emailSteps.includes(type) || type === RESPONSE) return false;
93
- 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";
93
+ if (type === "step.sms.send") return ((_a = campaign == null ? void 0 : campaign.form) == null ? void 0 : _a.submissionLeadPrimaryKey) !== "phone";
94
94
  return true;
95
95
  };
96
96
  const stepPrefills = {
@@ -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)).filter((step) => {
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 !step.ownerOnly || step.value === ((_a2 = watchedSteps[index]) == null ? void 0 : _a2.type);
982
- }).sort((a, b) => String(a.key).localeCompare(String(b.key))).map((step) => ({
983
- ...step,
984
- // Option values must be unique per catalog entry, not per step
985
- // type. Two connections offering the same step type collide,
986
- // because the select resolves its displayed option by first value
987
- // match — so a disconnected step rendered as whichever entry came
988
- // first. Suffix the connectionId when active, the connection slug
989
- // when not.
990
- //
991
- // The collision that produced this was mailchimp and sendgrid both
992
- // offering `step.email.send`. Neither does now — email steps are
993
- // connectionless and sendgrid is gone — but the rule is about any
994
- // two entries sharing a type, so it stays.
995
- value: step.connectionId ? step.value + "::" + step.connectionId : step.slug ? step.value + "::" + step.slug : step.value,
996
- ...step.disabled && !step.reason ? {
997
- badge: {
998
- text: "Enable connection"
999
- },
1000
- disabled: false,
1001
- element: import_link.default,
1002
- key: step == null ? void 0 : step.key,
1003
- props: {
1004
- href: "/organizations/" + (values == null ? void 0 : values.organization) + "/connections/" + step.slug
1005
- }
1006
- } : {},
1007
- // The same link-shaped option, greyed: it cannot be picked, and
1008
- // clicking it opens Settings, where the number is bought.
1009
- ...step.value === "step.sms.send" && !smsActive ? {
1010
- badge: {
1011
- text: "Settings"
1012
- },
1013
- className: "opacity-50",
1014
- disabled: false,
1015
- element: import_link.default,
1016
- key: step == null ? void 0 : step.key,
1017
- props: {
1018
- "aria-disabled": true,
1019
- href: "/organizations/" + (values == null ? void 0 : values.organization) + "/settings"
1020
- }
1021
- } : {},
1022
- // @story workflows/edit
1023
- // A step the form cannot feed: greyed with its reason, and a
1024
- // click opens the campaign's Form page, where the field is added.
1025
- ...step.reason ? {
1026
- badge: {
1027
- text: step.reason
1028
- },
1029
- className: "opacity-50",
1030
- disabled: false,
1031
- element: import_link.default,
1032
- key: step == null ? void 0 : step.key,
1033
- props: {
1034
- "aria-disabled": true,
1035
- href: "/organizations/" + (values == null ? void 0 : values.organization) + "/campaigns/" + (values == null ? void 0 : values.campaign) + "/form"
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);
@@ -35,9 +35,9 @@ const messageSteps = [...emailSteps, "step.sms.send"];
35
35
  const renderedSteps = [...emailSteps, ...teamSteps];
36
36
  const RESPONSE = "step.response.send";
37
37
  const firstEntryOnly = ({ campaign, event, type }) => {
38
- var _a, _b;
38
+ var _a;
39
39
  if (event !== "lead.insert" || !type || emailSteps.includes(type) || type === RESPONSE) return false;
40
- 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";
40
+ if (type === "step.sms.send") return ((_a = campaign == null ? void 0 : campaign.form) == null ? void 0 : _a.submissionLeadPrimaryKey) !== "phone";
41
41
  return true;
42
42
  };
43
43
  const stepPrefills = {
@@ -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)).filter((step) => {
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 !step.ownerOnly || step.value === ((_a2 = watchedSteps[index]) == null ? void 0 : _a2.type);
929
- }).sort((a, b) => String(a.key).localeCompare(String(b.key))).map((step) => ({
930
- ...step,
931
- // Option values must be unique per catalog entry, not per step
932
- // type. Two connections offering the same step type collide,
933
- // because the select resolves its displayed option by first value
934
- // match — so a disconnected step rendered as whichever entry came
935
- // first. Suffix the connectionId when active, the connection slug
936
- // when not.
937
- //
938
- // The collision that produced this was mailchimp and sendgrid both
939
- // offering `step.email.send`. Neither does now — email steps are
940
- // connectionless and sendgrid is gone — but the rule is about any
941
- // two entries sharing a type, so it stays.
942
- value: step.connectionId ? step.value + "::" + step.connectionId : step.slug ? step.value + "::" + step.slug : step.value,
943
- ...step.disabled && !step.reason ? {
944
- badge: {
945
- text: "Enable connection"
946
- },
947
- disabled: false,
948
- element: Link,
949
- key: step == null ? void 0 : step.key,
950
- props: {
951
- href: "/organizations/" + (values == null ? void 0 : values.organization) + "/connections/" + step.slug
952
- }
953
- } : {},
954
- // The same link-shaped option, greyed: it cannot be picked, and
955
- // clicking it opens Settings, where the number is bought.
956
- ...step.value === "step.sms.send" && !smsActive ? {
957
- badge: {
958
- text: "Settings"
959
- },
960
- className: "opacity-50",
961
- disabled: false,
962
- element: Link,
963
- key: step == null ? void 0 : step.key,
964
- props: {
965
- "aria-disabled": true,
966
- href: "/organizations/" + (values == null ? void 0 : values.organization) + "/settings"
967
- }
968
- } : {},
969
- // @story workflows/edit
970
- // A step the form cannot feed: greyed with its reason, and a
971
- // click opens the campaign's Form page, where the field is added.
972
- ...step.reason ? {
973
- badge: {
974
- text: step.reason
975
- },
976
- className: "opacity-50",
977
- disabled: false,
978
- element: Link,
979
- key: step == null ? void 0 : step.key,
980
- props: {
981
- "aria-disabled": true,
982
- href: "/organizations/" + (values == null ? void 0 : values.organization) + "/campaigns/" + (values == null ? void 0 : values.campaign) + "/form"
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);
@@ -259,8 +259,13 @@ const InputCombobox = ({
259
259
  import_react2.ComboboxOptions,
260
260
  {
261
261
  ...{
262
- anchor: "bottom start",
263
- className: "z-50 w-[var(--input-width)] mt-2",
262
+ // The gap from the anchor, not a margin: a margin pushed a list that
263
+ // flipped upward 8 px into its own input.
264
+ anchor: {
265
+ gap: 8,
266
+ to: "bottom start"
267
+ },
268
+ className: "z-50 w-[var(--input-width)]",
264
269
  ...panelWidth && {
265
270
  style: {
266
271
  width: panelWidth
@@ -233,8 +233,13 @@ const InputCombobox = ({
233
233
  ComboboxOptions,
234
234
  {
235
235
  ...{
236
- anchor: "bottom start",
237
- className: "z-50 w-[var(--input-width)] mt-2",
236
+ // The gap from the anchor, not a margin: a margin pushed a list that
237
+ // flipped upward 8 px into its own input.
238
+ anchor: {
239
+ gap: 8,
240
+ to: "bottom start"
241
+ },
242
+ className: "z-50 w-[var(--input-width)]",
238
243
  ...panelWidth && {
239
244
  style: {
240
245
  width: panelWidth
@@ -0,0 +1,48 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var escape_exports = {};
19
+ __export(escape_exports, {
20
+ useEscape: () => useEscape
21
+ });
22
+ module.exports = __toCommonJS(escape_exports);
23
+ var import_react = require("react");
24
+ const layers = [];
25
+ const useEscape = (active, button) => {
26
+ (0, import_react.useEffect)(
27
+ () => {
28
+ if (!active) return void 0;
29
+ const layer = {};
30
+ layers.push(layer);
31
+ const onKeyDown = (event) => {
32
+ var _a;
33
+ if (event.key !== "Escape" || event.defaultPrevented || event.isComposing || layers[layers.length - 1] !== layer) return;
34
+ (_a = button.current) == null ? void 0 : _a.click();
35
+ };
36
+ document.addEventListener("keydown", onKeyDown);
37
+ return () => {
38
+ layers.splice(layers.indexOf(layer), 1);
39
+ document.removeEventListener("keydown", onKeyDown);
40
+ };
41
+ },
42
+ [active, button]
43
+ );
44
+ };
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ useEscape
48
+ });
@@ -0,0 +1,25 @@
1
+ import { useEffect } from "react";
2
+ const layers = [];
3
+ const useEscape = (active, button) => {
4
+ useEffect(
5
+ () => {
6
+ if (!active) return void 0;
7
+ const layer = {};
8
+ layers.push(layer);
9
+ const onKeyDown = (event) => {
10
+ var _a;
11
+ if (event.key !== "Escape" || event.defaultPrevented || event.isComposing || layers[layers.length - 1] !== layer) return;
12
+ (_a = button.current) == null ? void 0 : _a.click();
13
+ };
14
+ document.addEventListener("keydown", onKeyDown);
15
+ return () => {
16
+ layers.splice(layers.indexOf(layer), 1);
17
+ document.removeEventListener("keydown", onKeyDown);
18
+ };
19
+ },
20
+ [active, button]
21
+ );
22
+ };
23
+ export {
24
+ useEscape
25
+ };
@@ -0,0 +1,75 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var rail_exports = {};
19
+ __export(rail_exports, {
20
+ railCount: () => railCount,
21
+ railFirst: () => railFirst,
22
+ railItems: () => railItems,
23
+ railOnScreen: () => railOnScreen,
24
+ railOverlap: () => railOverlap,
25
+ railTabTarget: () => railTabTarget,
26
+ railView: () => railView
27
+ });
28
+ module.exports = __toCommonJS(rail_exports);
29
+ const required = (items = []) => items.filter(({ kind }) => kind === "required");
30
+ const railItems = ({
31
+ account,
32
+ campaign,
33
+ organization,
34
+ page,
35
+ params = {},
36
+ path = ""
37
+ }) => {
38
+ var _a, _b, _c, _d, _e, _f;
39
+ if (path.startsWith("/admin")) return [];
40
+ if (!params.organization) return ((_a = account == null ? void 0 : account.tasks) == null ? void 0 : _a.items) || [];
41
+ if (!params.campaign) return ((_b = organization == null ? void 0 : organization.tasks) == null ? void 0 : _b.items) || [];
42
+ const list = ((_c = organization == null ? void 0 : organization.tasks) == null ? void 0 : _c.list) || {};
43
+ const others = Object.keys(list).filter((key) => !["billing", "campaigns"].includes(key));
44
+ return [
45
+ ...params.page ? ((_d = page == null ? void 0 : page.tasks) == null ? void 0 : _d.items) || [] : [],
46
+ ...required((_e = list.billing) == null ? void 0 : _e.items),
47
+ ...((_f = campaign == null ? void 0 : campaign.tasks) == null ? void 0 : _f.items) || [],
48
+ ...others.flatMap((key) => {
49
+ var _a2;
50
+ return required((_a2 = list[key]) == null ? void 0 : _a2.items);
51
+ })
52
+ ];
53
+ };
54
+ const railCount = (items = []) => required(items).length;
55
+ const railFirst = (items = []) => required(items)[0] || items[0];
56
+ const railView = ({ guide, panel }) => panel === "guide" && !guide ? "next" : panel || null;
57
+ const railOverlap = (a, b) => a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
58
+ const railOnScreen = (rect, { height, width }) => rect.bottom > 0 && rect.right > 0 && rect.top < height && rect.left < width;
59
+ const railTabTarget = ({ active, items, shift }) => {
60
+ if (items.length === 0) return null;
61
+ const first = items[0];
62
+ const last = items[items.length - 1];
63
+ if (shift) return active === first || !items.includes(active) ? last : null;
64
+ return active === last ? first : null;
65
+ };
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ railCount,
69
+ railFirst,
70
+ railItems,
71
+ railOnScreen,
72
+ railOverlap,
73
+ railTabTarget,
74
+ railView
75
+ });