@drawbridge/components 0.1.30 → 0.1.32

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 +7 -3
  18. package/dist/dashboard/form-organization-workflow.mjs +7 -3
  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 +23 -3
  44. package/dist/dashboard/template-socket.mjs +23 -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 = {
@@ -409,7 +409,11 @@ const useEmailPreview = ({ campaign, event, message, organization, subject, text
409
409
  });
410
410
  return result;
411
411
  },
412
- queryKey: ["workflow-email-preview", organization, campaign, event, settled]
412
+ // Stale at once ( the dashboard's default is never ): the key holds the
413
+ // step's copy only, and the placeholder under it is the campaign's, so
414
+ // each visit to the trigger page asks again (Asana 1217773117236699).
415
+ queryKey: ["workflow-email-preview", organization, campaign, event, settled],
416
+ staleTime: 0
413
417
  });
414
418
  if (preview.data) last.current = preview.data;
415
419
  return last.current;
@@ -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 = {
@@ -356,7 +356,11 @@ const useEmailPreview = ({ campaign, event, message, organization, subject, text
356
356
  });
357
357
  return result;
358
358
  },
359
- queryKey: ["workflow-email-preview", organization, campaign, event, settled]
359
+ // Stale at once ( the dashboard's default is never ): the key holds the
360
+ // step's copy only, and the placeholder under it is the campaign's, so
361
+ // each visit to the trigger page asks again (Asana 1217773117236699).
362
+ queryKey: ["workflow-email-preview", organization, campaign, event, settled],
363
+ staleTime: 0
360
364
  });
361
365
  if (preview.data) last.current = preview.data;
362
366
  return last.current;
@@ -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
+ });
@@ -0,0 +1,46 @@
1
+ const required = (items = []) => items.filter(({ kind }) => kind === "required");
2
+ const railItems = ({
3
+ account,
4
+ campaign,
5
+ organization,
6
+ page,
7
+ params = {},
8
+ path = ""
9
+ }) => {
10
+ var _a, _b, _c, _d, _e, _f;
11
+ if (path.startsWith("/admin")) return [];
12
+ if (!params.organization) return ((_a = account == null ? void 0 : account.tasks) == null ? void 0 : _a.items) || [];
13
+ if (!params.campaign) return ((_b = organization == null ? void 0 : organization.tasks) == null ? void 0 : _b.items) || [];
14
+ const list = ((_c = organization == null ? void 0 : organization.tasks) == null ? void 0 : _c.list) || {};
15
+ const others = Object.keys(list).filter((key) => !["billing", "campaigns"].includes(key));
16
+ return [
17
+ ...params.page ? ((_d = page == null ? void 0 : page.tasks) == null ? void 0 : _d.items) || [] : [],
18
+ ...required((_e = list.billing) == null ? void 0 : _e.items),
19
+ ...((_f = campaign == null ? void 0 : campaign.tasks) == null ? void 0 : _f.items) || [],
20
+ ...others.flatMap((key) => {
21
+ var _a2;
22
+ return required((_a2 = list[key]) == null ? void 0 : _a2.items);
23
+ })
24
+ ];
25
+ };
26
+ const railCount = (items = []) => required(items).length;
27
+ const railFirst = (items = []) => required(items)[0] || items[0];
28
+ const railView = ({ guide, panel }) => panel === "guide" && !guide ? "next" : panel || null;
29
+ const railOverlap = (a, b) => a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
30
+ const railOnScreen = (rect, { height, width }) => rect.bottom > 0 && rect.right > 0 && rect.top < height && rect.left < width;
31
+ const railTabTarget = ({ active, items, shift }) => {
32
+ if (items.length === 0) return null;
33
+ const first = items[0];
34
+ const last = items[items.length - 1];
35
+ if (shift) return active === first || !items.includes(active) ? last : null;
36
+ return active === last ? first : null;
37
+ };
38
+ export {
39
+ railCount,
40
+ railFirst,
41
+ railItems,
42
+ railOnScreen,
43
+ railOverlap,
44
+ railTabTarget,
45
+ railView
46
+ };
@@ -0,0 +1,57 @@
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 throttle_exports = {};
19
+ __export(throttle_exports, {
20
+ trailingThrottle: () => trailingThrottle
21
+ });
22
+ module.exports = __toCommonJS(throttle_exports);
23
+ const trailingThrottle = ({
24
+ now = Date.now,
25
+ schedule = setTimeout,
26
+ wait
27
+ }) => {
28
+ const entries = /* @__PURE__ */ new Map();
29
+ return (key, run) => {
30
+ const entry = entries.get(key) || {
31
+ last: -Infinity,
32
+ pending: false
33
+ };
34
+ entries.set(key, entry);
35
+ entry.run = run;
36
+ if (entry.pending) return;
37
+ const left = entry.last + wait - now();
38
+ if (left <= 0) {
39
+ entry.last = now();
40
+ run();
41
+ return;
42
+ }
43
+ entry.pending = true;
44
+ schedule(
45
+ () => {
46
+ entry.last = now();
47
+ entry.pending = false;
48
+ entry.run();
49
+ },
50
+ left
51
+ );
52
+ };
53
+ };
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ trailingThrottle
57
+ });
@@ -0,0 +1,34 @@
1
+ const trailingThrottle = ({
2
+ now = Date.now,
3
+ schedule = setTimeout,
4
+ wait
5
+ }) => {
6
+ const entries = /* @__PURE__ */ new Map();
7
+ return (key, run) => {
8
+ const entry = entries.get(key) || {
9
+ last: -Infinity,
10
+ pending: false
11
+ };
12
+ entries.set(key, entry);
13
+ entry.run = run;
14
+ if (entry.pending) return;
15
+ const left = entry.last + wait - now();
16
+ if (left <= 0) {
17
+ entry.last = now();
18
+ run();
19
+ return;
20
+ }
21
+ entry.pending = true;
22
+ schedule(
23
+ () => {
24
+ entry.last = now();
25
+ entry.pending = false;
26
+ entry.run();
27
+ },
28
+ left
29
+ );
30
+ };
31
+ };
32
+ export {
33
+ trailingThrottle
34
+ };
@@ -49,7 +49,7 @@ const List = ({
49
49
  className
50
50
  },
51
51
  // icon and element shape the row; left in rest they reach the DOM.
52
- children: items.map(({ complete, element, icon, increment, title, ...rest }, key) => {
52
+ children: items.map(({ complete, element, icon, title, ...rest }, key) => {
53
53
  const same = Boolean(rest == null ? void 0 : rest.href) && rest.href === pathname;
54
54
  const linked = Boolean(rest == null ? void 0 : rest.href) && !same;
55
55
  const IconComponent = icon || import_arrow_right.default;
@@ -17,7 +17,7 @@ const List = ({
17
17
  className
18
18
  },
19
19
  // icon and element shape the row; left in rest they reach the DOM.
20
- children: items.map(({ complete, element, icon, increment, title, ...rest }, key) => {
20
+ children: items.map(({ complete, element, icon, title, ...rest }, key) => {
21
21
  const same = Boolean(rest == null ? void 0 : rest.href) && rest.href === pathname;
22
22
  const linked = Boolean(rest == null ? void 0 : rest.href) && !same;
23
23
  const IconComponent = icon || ArrowRight;