@drawbridge/components 0.1.12 → 0.1.14
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/components/styles.css +364 -2
- package/dist/advertisement.js +3 -1
- package/dist/advertisement.mjs +3 -1
- package/dist/bridge/advertisements.js +2 -0
- package/dist/bridge/advertisements.mjs +2 -0
- package/dist/bridge/countdown.js +2 -1
- package/dist/bridge/countdown.mjs +2 -1
- package/dist/bridge/form-subdomain-embed.js +18 -20
- package/dist/bridge/form-subdomain-embed.mjs +18 -20
- package/dist/bridge/form-subdomain-header.js +24 -1
- package/dist/bridge/form-subdomain-header.mjs +24 -1
- package/dist/bridge/form-subdomain-missions.js +538 -0
- package/dist/bridge/form-subdomain-missions.mjs +502 -0
- package/dist/bridge/form-subdomain.js +530 -220
- package/dist/bridge/form-subdomain.mjs +533 -222
- package/dist/bridge/lib/entry.js +59 -0
- package/dist/bridge/lib/entry.mjs +29 -0
- package/dist/bridge/lib/location.js +38 -0
- package/dist/bridge/lib/location.mjs +13 -0
- package/dist/bridge/lib/order.js +71 -0
- package/dist/bridge/lib/order.mjs +44 -0
- package/dist/bridge/lib/url.js +9 -0
- package/dist/bridge/lib/url.mjs +7 -0
- package/dist/bridge/share-button.js +5 -3
- package/dist/bridge/share-button.mjs +5 -3
- package/dist/bridge/subdomain-content.js +7 -6
- package/dist/bridge/subdomain-content.mjs +7 -6
- package/dist/bridge/template-layout.js +59 -21
- package/dist/bridge/template-layout.mjs +59 -21
- package/dist/bridge/template-modal.js +42 -76
- package/dist/bridge/template-modal.mjs +39 -73
- package/dist/bridge/template-preview.js +208 -0
- package/dist/bridge/template-preview.mjs +173 -0
- package/dist/bridge/template-subdomain-gallery.js +6 -2
- package/dist/bridge/template-subdomain-gallery.mjs +6 -2
- package/dist/bridge/template-subdomain-link.js +6 -1
- package/dist/bridge/template-subdomain-link.mjs +6 -1
- package/dist/bridge/template-subdomain.js +20 -15
- package/dist/bridge/template-subdomain.mjs +20 -15
- package/dist/dashboard/accordion.js +74 -39
- package/dist/dashboard/accordion.mjs +74 -39
- package/dist/dashboard/avatar.js +109 -3
- package/dist/dashboard/avatar.mjs +106 -4
- package/dist/dashboard/buttons-subscription.js +384 -0
- package/dist/dashboard/buttons-subscription.mjs +349 -0
- package/dist/dashboard/card-campaign-switch.js +265 -0
- package/dist/dashboard/card-campaign-switch.mjs +231 -0
- package/dist/dashboard/card-order.js +28 -11
- package/dist/dashboard/card-order.mjs +28 -11
- package/dist/dashboard/card-section.js +26 -2
- package/dist/dashboard/card-section.mjs +26 -2
- package/dist/dashboard/card-tile.js +6 -7
- package/dist/dashboard/card-tile.mjs +6 -7
- package/dist/dashboard/connection-workflows.js +196 -0
- package/dist/dashboard/connection-workflows.mjs +162 -0
- package/dist/dashboard/device.js +95 -0
- package/dist/dashboard/device.mjs +72 -0
- package/dist/dashboard/form-admin-campaign.js +19 -50
- package/dist/dashboard/form-admin-campaign.mjs +20 -51
- package/dist/dashboard/form-ai.js +9 -6
- package/dist/dashboard/form-ai.mjs +9 -6
- package/dist/dashboard/form-auth.js +35 -25
- package/dist/dashboard/form-auth.mjs +36 -26
- package/dist/dashboard/form-file.js +10 -1
- package/dist/dashboard/form-file.mjs +10 -1
- package/dist/dashboard/form-filters-analytics.js +14 -1
- package/dist/dashboard/form-filters-analytics.mjs +15 -2
- package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
- package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
- package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
- package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
- package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
- package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
- package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
- package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
- package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
- package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
- package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
- package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
- package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
- package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
- package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-link.js +7 -1
- package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
- package/dist/dashboard/form-organization-campaign-mission.js +291 -0
- package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
- package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
- package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
- package/dist/dashboard/form-organization-campaign-page.js +20 -11
- package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
- package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
- package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
- package/dist/dashboard/form-organization-campaign-section.js +223 -0
- package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
- package/dist/dashboard/form-organization-campaign.js +114 -469
- package/dist/dashboard/form-organization-campaign.mjs +113 -467
- package/dist/dashboard/form-organization-export.js +4 -7
- package/dist/dashboard/form-organization-export.mjs +4 -7
- package/dist/dashboard/form-organization-identity.js +46 -51
- package/dist/dashboard/form-organization-identity.mjs +46 -51
- package/dist/dashboard/form-organization-workflow.js +518 -686
- package/dist/dashboard/form-organization-workflow.mjs +517 -682
- package/dist/dashboard/form-organization.js +82 -110
- package/dist/dashboard/form-organization.mjs +81 -109
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-payment-methods.js +20 -9
- package/dist/dashboard/form-payment-methods.mjs +20 -9
- package/dist/dashboard/form-stripe.js +30 -0
- package/dist/dashboard/form-stripe.mjs +26 -0
- package/dist/dashboard/input-array.js +4 -2
- package/dist/dashboard/input-array.mjs +4 -2
- package/dist/dashboard/input-combobox.js +7 -3
- package/dist/dashboard/input-combobox.mjs +7 -3
- package/dist/dashboard/input-date.js +7 -0
- package/dist/dashboard/input-date.mjs +7 -0
- package/dist/dashboard/input-fields.js +80 -20
- package/dist/dashboard/input-fields.mjs +80 -20
- package/dist/dashboard/input-file.js +21 -1
- package/dist/dashboard/input-file.mjs +21 -1
- package/dist/dashboard/input-font.js +10 -1
- package/dist/dashboard/input-font.mjs +10 -1
- package/dist/dashboard/lib/item-list.js +57 -0
- package/dist/dashboard/lib/item-list.mjs +33 -0
- package/dist/dashboard/lib/menu.js +50 -0
- package/dist/dashboard/lib/menu.mjs +26 -0
- package/dist/dashboard/locked.js +82 -0
- package/dist/dashboard/locked.mjs +53 -0
- package/dist/dashboard/menu.js +72 -19
- package/dist/dashboard/menu.mjs +72 -19
- package/dist/dashboard/note-ai.js +69 -0
- package/dist/dashboard/note-ai.mjs +36 -0
- package/dist/dashboard/preview.js +419 -0
- package/dist/dashboard/preview.mjs +384 -0
- package/dist/dashboard/steps.js +39 -13
- package/dist/dashboard/steps.mjs +37 -12
- package/dist/dashboard/table-contacts.js +136 -0
- package/dist/dashboard/table-contacts.mjs +103 -0
- package/dist/dashboard/template-not-found.js +4 -2
- package/dist/dashboard/template-not-found.mjs +4 -2
- package/dist/dashboard/template-socket.js +51 -7
- package/dist/dashboard/template-socket.mjs +51 -7
- package/dist/icons/desktop.js +46 -0
- package/dist/icons/desktop.mjs +27 -0
- package/dist/icons/phone.js +46 -0
- package/dist/icons/phone.mjs +27 -0
- package/dist/icons/puzzle-piece.js +46 -0
- package/dist/icons/puzzle-piece.mjs +27 -0
- package/dist/icons/tablet.js +46 -0
- package/dist/icons/tablet.mjs +27 -0
- package/dist/icons/users.js +46 -0
- package/dist/icons/users.mjs +27 -0
- package/dist/input-checkbox.js +1 -0
- package/dist/input-checkbox.mjs +1 -0
- package/dist/input-code.js +101 -0
- package/dist/input-code.mjs +78 -0
- package/dist/input-text.js +2 -1
- package/dist/input-text.mjs +2 -1
- package/dist/shared/input-checkbox-list.js +0 -1
- package/dist/shared/input-checkbox-list.mjs +0 -1
- package/dist/shared/input-switch.js +6 -1
- package/dist/shared/input-switch.mjs +6 -1
- package/dist/shared/lib/campaign.js +117 -0
- package/dist/shared/lib/campaign.mjs +91 -0
- package/dist/shared/lib/helpers.js +14 -2
- package/dist/shared/lib/helpers.mjs +13 -2
- package/package.json +133 -13
- package/types/bridge/form-subdomain-header.d.ts +2 -0
- package/types/bridge/form-subdomain-missions.d.ts +36 -0
- package/types/bridge/form-subdomain.d.ts +23 -1
- package/types/bridge/lib/entry.d.ts +26 -0
- package/types/bridge/lib/location.d.ts +13 -0
- package/types/bridge/lib/order.d.ts +30 -0
- package/types/bridge/lib/url.d.ts +19 -0
- package/types/bridge/template-modal.d.ts +1 -1
- package/types/bridge/template-preview.d.ts +10 -0
- package/types/bridge/template-subdomain-link.d.ts +2 -0
- package/types/dashboard/accordion.d.ts +2 -0
- package/types/dashboard/avatar.d.ts +18 -2
- package/types/dashboard/buttons-subscription.d.ts +22 -0
- package/types/dashboard/card-campaign-switch.d.ts +32 -0
- package/types/dashboard/card-order.d.ts +11 -0
- package/types/dashboard/card-section.d.ts +2 -0
- package/types/dashboard/connection-workflows.d.ts +33 -0
- package/types/dashboard/device.d.ts +12 -0
- package/types/dashboard/form-admin-campaign.d.ts +3 -2
- package/types/dashboard/form-ai.d.ts +2 -2
- package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
- package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
- package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
- package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
- package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
- package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
- package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
- package/types/dashboard/form-organization-campaign.d.ts +27 -17
- package/types/dashboard/form-organization-identity.d.ts +2 -0
- package/types/dashboard/form-organization-workflow.d.ts +43 -47
- package/types/dashboard/form-organization.d.ts +7 -2
- package/types/dashboard/form-stripe.d.ts +3 -0
- package/types/dashboard/input-combobox.d.ts +2 -0
- package/types/dashboard/input-date.d.ts +2 -0
- package/types/dashboard/input-fields.d.ts +3 -2
- package/types/dashboard/input-file.d.ts +4 -0
- package/types/dashboard/lib/item-list.d.ts +14 -0
- package/types/dashboard/lib/menu.d.ts +17 -0
- package/types/dashboard/locked.d.ts +10 -0
- package/types/dashboard/menu.d.ts +10 -2
- package/types/dashboard/note-ai.d.ts +15 -0
- package/types/dashboard/preview.d.ts +33 -0
- package/types/dashboard/steps.d.ts +19 -4
- package/types/dashboard/table-cell-title.d.ts +2 -2
- package/types/dashboard/table-contacts.d.ts +2 -0
- package/types/icons/desktop.d.ts +5 -0
- package/types/icons/phone.d.ts +5 -0
- package/types/icons/puzzle-piece.d.ts +5 -0
- package/types/icons/tablet.d.ts +5 -0
- package/types/icons/users.d.ts +5 -0
- package/types/input-code.d.ts +23 -0
- package/types/shared/input-switch.d.ts +2 -0
- package/types/shared/lib/campaign.d.ts +35 -0
- package/types/shared/lib/helpers.d.ts +3 -0
- package/dist/dashboard/card-integration.js +0 -187
- package/dist/dashboard/card-integration.mjs +0 -158
- package/dist/dashboard/iframe.js +0 -159
- package/dist/dashboard/iframe.mjs +0 -130
- package/types/dashboard/card-integration.d.ts +0 -24
- package/types/dashboard/iframe.d.ts +0 -18
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import Button from "../shared/button.mjs";
|
|
6
|
+
import LoaderComponent from "../shared/loader.mjs";
|
|
7
|
+
import InputCombobox from "./input-combobox.mjs";
|
|
8
|
+
import Device from "./device.mjs";
|
|
9
|
+
import Desktop from "../icons/desktop.mjs";
|
|
10
|
+
import Phone from "../icons/phone.mjs";
|
|
11
|
+
import Tablet from "../icons/tablet.mjs";
|
|
12
|
+
const DEVICES = {
|
|
13
|
+
desktop: { icon: Desktop, label: "Desktop" },
|
|
14
|
+
tablet: { icon: Tablet, label: "Tablet" },
|
|
15
|
+
phone: { icon: Phone, label: "Phone" }
|
|
16
|
+
};
|
|
17
|
+
const HEIGHT = 520;
|
|
18
|
+
const GUTTER = 24;
|
|
19
|
+
const NARROW = 486;
|
|
20
|
+
const ZOOMS = [
|
|
21
|
+
{ key: "Fit", value: "fit" },
|
|
22
|
+
{ key: "25%", value: 0.25 },
|
|
23
|
+
{ key: "50%", value: 0.5 },
|
|
24
|
+
{ key: "100%", value: 1 },
|
|
25
|
+
{ key: "150%", value: 1.5 },
|
|
26
|
+
{ key: "200%", value: 2 }
|
|
27
|
+
];
|
|
28
|
+
const clamp = (value, limit) => Math.min(limit, Math.max(-limit, value));
|
|
29
|
+
const fitScale = (space, size) => space.width && size.width ? Math.min(1, (space.width - GUTTER) / size.width, (space.height - GUTTER) / size.height) : 1;
|
|
30
|
+
const PreviewFrame = ({
|
|
31
|
+
children,
|
|
32
|
+
states
|
|
33
|
+
}) => {
|
|
34
|
+
var _a;
|
|
35
|
+
const [device, setDevice] = useState("phone");
|
|
36
|
+
const [zoom, setZoom] = useState("fit");
|
|
37
|
+
const [space, setSpace] = useState({ height: 0, width: 0 });
|
|
38
|
+
const [frameSize, setFrameSize] = useState({ device: null, height: 0, width: 0 });
|
|
39
|
+
const [offset, setOffset] = useState({ x: 0, y: 0 });
|
|
40
|
+
const [ease, setEase] = useState(false);
|
|
41
|
+
const [dragging, setDragging] = useState(false);
|
|
42
|
+
const area = useRef(null);
|
|
43
|
+
const frame = useRef(null);
|
|
44
|
+
const drag = useRef(null);
|
|
45
|
+
const scale = zoom === "fit" ? fitScale(space, frameSize) : zoom;
|
|
46
|
+
const reach = {
|
|
47
|
+
x: Math.max(0, (frameSize.width * scale - space.width) / 2),
|
|
48
|
+
y: Math.max(0, (frameSize.height * scale - space.height) / 2)
|
|
49
|
+
};
|
|
50
|
+
const larger = reach.x > 0 || reach.y > 0;
|
|
51
|
+
const narrow = space.width > 0 && space.width < NARROW;
|
|
52
|
+
const hasStates = ((_a = states == null ? void 0 : states.options) == null ? void 0 : _a.length) > 1;
|
|
53
|
+
const ready = space.width > 0 && frameSize.device === device;
|
|
54
|
+
const x = (space.width - frameSize.width * scale) / 2 + clamp(offset.x, reach.x);
|
|
55
|
+
const y = (space.height - frameSize.height * scale) / 2 + clamp(offset.y, reach.y);
|
|
56
|
+
useLayoutEffect(() => {
|
|
57
|
+
const measure = () => setSpace({ height: area.current.clientHeight, width: area.current.clientWidth });
|
|
58
|
+
const observer = new ResizeObserver(measure);
|
|
59
|
+
measure();
|
|
60
|
+
observer.observe(area.current);
|
|
61
|
+
return () => observer.disconnect();
|
|
62
|
+
}, []);
|
|
63
|
+
useLayoutEffect(() => {
|
|
64
|
+
const measure = () => setFrameSize({ device, height: frame.current.offsetHeight, width: frame.current.offsetWidth });
|
|
65
|
+
const observer = new ResizeObserver(measure);
|
|
66
|
+
measure();
|
|
67
|
+
observer.observe(frame.current);
|
|
68
|
+
return () => observer.disconnect();
|
|
69
|
+
}, [device]);
|
|
70
|
+
useLayoutEffect(() => {
|
|
71
|
+
setOffset({ x: 0, y: 0 });
|
|
72
|
+
}, [device, zoom]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!ease) return;
|
|
75
|
+
const timer = setTimeout(() => setEase(false), 200);
|
|
76
|
+
return () => clearTimeout(timer);
|
|
77
|
+
}, [ease]);
|
|
78
|
+
return /* @__PURE__ */ jsxs(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
...{
|
|
82
|
+
// A toolbar across the top, then the area the device sits in.
|
|
83
|
+
className: "flex flex-col w-full min-w-0 rounded border border-gray overflow-hidden"
|
|
84
|
+
},
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ jsxs(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
...{
|
|
90
|
+
// The states on the left, the zoom and the sizes on the right.
|
|
91
|
+
className: "flex flex-wrap items-center justify-between gap-2 px-3 py-2 bg-white border-b border-gray"
|
|
92
|
+
},
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
...{
|
|
98
|
+
// Narrow with no states, the empty slot takes no line.
|
|
99
|
+
className: narrow ? hasStates ? "w-full" : "hidden" : "w-52 max-w-full"
|
|
100
|
+
},
|
|
101
|
+
children: hasStates && /* @__PURE__ */ jsx(
|
|
102
|
+
InputCombobox,
|
|
103
|
+
{
|
|
104
|
+
...{
|
|
105
|
+
onChange: states.onChange,
|
|
106
|
+
options: states.options,
|
|
107
|
+
size: "small",
|
|
108
|
+
value: states.value
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ jsxs(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
...{
|
|
118
|
+
className: "flex items-center gap-2 " + (narrow ? "w-full" : "ml-auto")
|
|
119
|
+
},
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
...{
|
|
125
|
+
className: narrow ? "flex-1 min-w-0" : "w-24"
|
|
126
|
+
},
|
|
127
|
+
children: /* @__PURE__ */ jsx(
|
|
128
|
+
InputCombobox,
|
|
129
|
+
{
|
|
130
|
+
...{
|
|
131
|
+
onChange: (value) => {
|
|
132
|
+
setEase(true);
|
|
133
|
+
setZoom(value);
|
|
134
|
+
},
|
|
135
|
+
options: ZOOMS,
|
|
136
|
+
size: "small",
|
|
137
|
+
value: zoom
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
/* @__PURE__ */ jsx(
|
|
144
|
+
"div",
|
|
145
|
+
{
|
|
146
|
+
...{
|
|
147
|
+
// The sizes, small icon buttons spaced as the dashboard's button
|
|
148
|
+
// groups are, the chosen one filled dark.
|
|
149
|
+
"aria-label": "Screen size",
|
|
150
|
+
className: "flex gap-2",
|
|
151
|
+
role: "group"
|
|
152
|
+
},
|
|
153
|
+
children: Object.entries(DEVICES).map(([key, { icon, label }]) => /* @__PURE__ */ jsx(
|
|
154
|
+
Button,
|
|
155
|
+
{
|
|
156
|
+
...{
|
|
157
|
+
"aria-label": label,
|
|
158
|
+
"aria-pressed": device === key,
|
|
159
|
+
icon,
|
|
160
|
+
inline: true,
|
|
161
|
+
// A new size starts fitted.
|
|
162
|
+
onClick: () => {
|
|
163
|
+
setEase(false);
|
|
164
|
+
setDevice(key);
|
|
165
|
+
setZoom("fit");
|
|
166
|
+
},
|
|
167
|
+
size: "small",
|
|
168
|
+
variant: device === key ? "primary" : "secondary"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
key
|
|
172
|
+
))
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ jsx(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
...{
|
|
185
|
+
className: "relative w-full overflow-hidden bg-gray-light touch-none select-none" + (larger ? dragging ? " cursor-grabbing" : " cursor-grab" : ""),
|
|
186
|
+
// Dragging moves the device only when it is larger than the area. The
|
|
187
|
+
// pointer is captured, so a drag that leaves the area still follows it
|
|
188
|
+
// and still ends on release.
|
|
189
|
+
onLostPointerCapture: () => {
|
|
190
|
+
drag.current = null;
|
|
191
|
+
setDragging(false);
|
|
192
|
+
},
|
|
193
|
+
onPointerDown: (event) => {
|
|
194
|
+
if (!larger || event.button !== 0) return;
|
|
195
|
+
const from = { x: clamp(offset.x, reach.x), y: clamp(offset.y, reach.y) };
|
|
196
|
+
setEase(false);
|
|
197
|
+
setOffset(from);
|
|
198
|
+
drag.current = { left: event.clientX - from.x, top: event.clientY - from.y };
|
|
199
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
200
|
+
setDragging(true);
|
|
201
|
+
},
|
|
202
|
+
onPointerMove: (event) => drag.current && setOffset({
|
|
203
|
+
x: clamp(event.clientX - drag.current.left, reach.x),
|
|
204
|
+
y: clamp(event.clientY - drag.current.top, reach.y)
|
|
205
|
+
}),
|
|
206
|
+
ref: area,
|
|
207
|
+
style: {
|
|
208
|
+
height: HEIGHT
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
children: /* @__PURE__ */ jsx(
|
|
212
|
+
"div",
|
|
213
|
+
{
|
|
214
|
+
...{
|
|
215
|
+
// The device, measured for fitting, placed by one transform from the top
|
|
216
|
+
// left. pointer-events-none: a picture of the page, so nothing in it
|
|
217
|
+
// can be clicked.
|
|
218
|
+
className: "absolute top-0 left-0 w-max origin-top-left pointer-events-none",
|
|
219
|
+
"data-preview-stage": true,
|
|
220
|
+
ref: frame,
|
|
221
|
+
style: {
|
|
222
|
+
opacity: ready ? 1 : 0,
|
|
223
|
+
transform: "translate(" + x + "px, " + y + "px) scale(" + scale + ")",
|
|
224
|
+
// The fade in, once laid out; a zoom from the dropdown eases. Hidden at once.
|
|
225
|
+
transition: ready ? ["opacity 150ms ease", ease && "transform 150ms ease"].filter(Boolean).join(", ") : "none"
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
children: /* @__PURE__ */ jsx(
|
|
229
|
+
Device,
|
|
230
|
+
{
|
|
231
|
+
...{
|
|
232
|
+
type: device
|
|
233
|
+
},
|
|
234
|
+
children
|
|
235
|
+
}
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
const STYLES = 'style, link[rel="stylesheet"]';
|
|
246
|
+
const mirrorStyles = (doc) => {
|
|
247
|
+
const copy = (node) => doc.head.appendChild(node.cloneNode(true));
|
|
248
|
+
document.querySelectorAll(STYLES).forEach(copy);
|
|
249
|
+
const base = doc.createElement("style");
|
|
250
|
+
base.textContent = "html, body { height : 100%; margin : 0; }";
|
|
251
|
+
doc.head.appendChild(base);
|
|
252
|
+
const observer = new MutationObserver((records) => records.forEach((record) => record.addedNodes.forEach((node) => {
|
|
253
|
+
var _a;
|
|
254
|
+
return ((_a = node.matches) == null ? void 0 : _a.call(node, STYLES)) && copy(node);
|
|
255
|
+
})));
|
|
256
|
+
observer.observe(document.head, { childList: true });
|
|
257
|
+
return () => observer.disconnect();
|
|
258
|
+
};
|
|
259
|
+
const Preview = ({
|
|
260
|
+
children,
|
|
261
|
+
loading = false,
|
|
262
|
+
states,
|
|
263
|
+
style
|
|
264
|
+
}) => {
|
|
265
|
+
var _a, _b, _c, _d;
|
|
266
|
+
const frame = useRef(null);
|
|
267
|
+
const [body, setBody] = useState(null);
|
|
268
|
+
const stop = useRef(null);
|
|
269
|
+
useEffect(() => () => {
|
|
270
|
+
var _a2;
|
|
271
|
+
return (_a2 = stop.current) == null ? void 0 : _a2.call(stop);
|
|
272
|
+
}, []);
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
var _a2, _b2, _c2, _d2;
|
|
275
|
+
if (!body) return;
|
|
276
|
+
body.style.backgroundColor = ((_b2 = (_a2 = style == null ? void 0 : style.background) == null ? void 0 : _a2.color) == null ? void 0 : _b2.rgb) || "#FFFFFF";
|
|
277
|
+
body.style.color = ((_d2 = (_c2 = style == null ? void 0 : style.text) == null ? void 0 : _c2.color) == null ? void 0 : _d2.rgb) || "";
|
|
278
|
+
}, [body, (_b = (_a = style == null ? void 0 : style.background) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb, (_d = (_c = style == null ? void 0 : style.text) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb]);
|
|
279
|
+
const onLoad = () => {
|
|
280
|
+
var _a2;
|
|
281
|
+
const doc = frame.current.contentDocument;
|
|
282
|
+
(_a2 = stop.current) == null ? void 0 : _a2.call(stop);
|
|
283
|
+
stop.current = mirrorStyles(doc);
|
|
284
|
+
setBody(doc.body);
|
|
285
|
+
};
|
|
286
|
+
return /* @__PURE__ */ jsxs(
|
|
287
|
+
PreviewFrame,
|
|
288
|
+
{
|
|
289
|
+
...{
|
|
290
|
+
states
|
|
291
|
+
},
|
|
292
|
+
children: [
|
|
293
|
+
loading && /* @__PURE__ */ jsx(
|
|
294
|
+
LoaderComponent,
|
|
295
|
+
{
|
|
296
|
+
...{
|
|
297
|
+
className: "bg-purple-light"
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
/* @__PURE__ */ jsx(
|
|
302
|
+
"iframe",
|
|
303
|
+
{
|
|
304
|
+
...{
|
|
305
|
+
className: "block w-full h-full border-0",
|
|
306
|
+
onLoad,
|
|
307
|
+
ref: frame,
|
|
308
|
+
srcDoc: '<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>',
|
|
309
|
+
title: "Preview"
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
),
|
|
313
|
+
body && !loading && createPortal(children, body)
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
};
|
|
318
|
+
const PreviewPage = ({
|
|
319
|
+
states,
|
|
320
|
+
update,
|
|
321
|
+
url
|
|
322
|
+
}) => {
|
|
323
|
+
const frame = useRef(null);
|
|
324
|
+
const [loading, setLoading] = useState(true);
|
|
325
|
+
const origin = url ? new URL(url).origin : null;
|
|
326
|
+
const message = JSON.stringify({ update });
|
|
327
|
+
const post = () => {
|
|
328
|
+
var _a, _b;
|
|
329
|
+
return origin && origin !== "null" && ((_b = (_a = frame.current) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage(JSON.parse(message), origin));
|
|
330
|
+
};
|
|
331
|
+
useEffect(
|
|
332
|
+
() => {
|
|
333
|
+
post();
|
|
334
|
+
const onReady = (event) => {
|
|
335
|
+
var _a, _b;
|
|
336
|
+
if (event.source === ((_a = frame.current) == null ? void 0 : _a.contentWindow) && ((_b = event.data) == null ? void 0 : _b.ready)) post();
|
|
337
|
+
};
|
|
338
|
+
window.addEventListener("message", onReady);
|
|
339
|
+
return () => window.removeEventListener("message", onReady);
|
|
340
|
+
},
|
|
341
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
342
|
+
[message, origin]
|
|
343
|
+
);
|
|
344
|
+
return /* @__PURE__ */ jsxs(
|
|
345
|
+
PreviewFrame,
|
|
346
|
+
{
|
|
347
|
+
...{
|
|
348
|
+
states
|
|
349
|
+
},
|
|
350
|
+
children: [
|
|
351
|
+
loading && /* @__PURE__ */ jsx(
|
|
352
|
+
LoaderComponent,
|
|
353
|
+
{
|
|
354
|
+
...{
|
|
355
|
+
className: "bg-purple-light"
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
),
|
|
359
|
+
/* @__PURE__ */ jsx(
|
|
360
|
+
"iframe",
|
|
361
|
+
{
|
|
362
|
+
...{
|
|
363
|
+
className: "absolute inset-0 w-full h-full border-0",
|
|
364
|
+
onLoad: () => {
|
|
365
|
+
setLoading(false);
|
|
366
|
+
post();
|
|
367
|
+
},
|
|
368
|
+
ref: frame,
|
|
369
|
+
src: url,
|
|
370
|
+
title: "Page preview"
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
};
|
|
378
|
+
var preview_default = Preview;
|
|
379
|
+
export {
|
|
380
|
+
PreviewPage,
|
|
381
|
+
clamp,
|
|
382
|
+
preview_default as default,
|
|
383
|
+
fitScale
|
|
384
|
+
};
|
package/dist/dashboard/steps.js
CHANGED
|
@@ -30,7 +30,8 @@ __export(steps_exports, {
|
|
|
30
30
|
default: () => steps_default,
|
|
31
31
|
groupTitle: () => groupTitle,
|
|
32
32
|
replyExcerpt: () => replyExcerpt,
|
|
33
|
-
rowLabel: () => rowLabel
|
|
33
|
+
rowLabel: () => rowLabel,
|
|
34
|
+
rowState: () => rowState
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(steps_exports);
|
|
36
37
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -67,6 +68,17 @@ const replyExcerpt = (response, length = 300) => {
|
|
|
67
68
|
if (!text) return null;
|
|
68
69
|
return text.length > length ? text.slice(0, length) + "\u2026" : text;
|
|
69
70
|
};
|
|
71
|
+
const rowState = ({ error: chunkError, message, status }) => {
|
|
72
|
+
const error = chunkError || status === "failed" && message || null;
|
|
73
|
+
return {
|
|
74
|
+
badge: {
|
|
75
|
+
text: (0, import_drawbridge_utils.capitalize)(status),
|
|
76
|
+
type: error ? "error" : badgeType(status)
|
|
77
|
+
},
|
|
78
|
+
error,
|
|
79
|
+
notice: error || status === "skipped" && message || null
|
|
80
|
+
};
|
|
81
|
+
};
|
|
70
82
|
const StepItem = ({
|
|
71
83
|
updatedAt,
|
|
72
84
|
error: chunkError,
|
|
@@ -77,8 +89,7 @@ const StepItem = ({
|
|
|
77
89
|
slug,
|
|
78
90
|
status
|
|
79
91
|
}) => {
|
|
80
|
-
const error
|
|
81
|
-
const notice = error || status === "skipped" && message || null;
|
|
92
|
+
const { badge, error, notice } = rowState({ error: chunkError, message, status });
|
|
82
93
|
const reply = error ? replyExcerpt(response) : null;
|
|
83
94
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
84
95
|
"div",
|
|
@@ -109,10 +120,7 @@ const StepItem = ({
|
|
|
109
120
|
import_accordion.default,
|
|
110
121
|
{
|
|
111
122
|
...{
|
|
112
|
-
badge
|
|
113
|
-
text: (0, import_drawbridge_utils.capitalize)(status),
|
|
114
|
-
type: error ? "error" : badgeType(status)
|
|
115
|
-
},
|
|
123
|
+
badge,
|
|
116
124
|
className: "w-full",
|
|
117
125
|
classNamePanel: "text-sm pt-2",
|
|
118
126
|
title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -218,9 +226,8 @@ const StepItem = ({
|
|
|
218
226
|
}
|
|
219
227
|
);
|
|
220
228
|
};
|
|
221
|
-
const groupTitle = ({ count, email, items, kind, pending }) => {
|
|
222
|
-
|
|
223
|
-
if (kind !== "notify") return email || ((_a = items == null ? void 0 : items[0]) == null ? void 0 : _a.slug) || "Activity";
|
|
229
|
+
const groupTitle = ({ count, email, items, kind, pending }, labels = []) => {
|
|
230
|
+
if (kind !== "notify") return email || (items == null ? void 0 : items[0]) && rowLabel({ item: items[0], kind, labels }) || "Activity";
|
|
224
231
|
const entries = count + " new " + (count === 1 ? "entry" : "entries");
|
|
225
232
|
return "Team notification \u2014 " + entries + (pending ? ", sending" : "");
|
|
226
233
|
};
|
|
@@ -241,7 +248,7 @@ const Group = ({
|
|
|
241
248
|
...{
|
|
242
249
|
className: "text-xs text-gray-dark pb-3"
|
|
243
250
|
},
|
|
244
|
-
children: groupTitle(group)
|
|
251
|
+
children: groupTitle(group, labels)
|
|
245
252
|
}
|
|
246
253
|
),
|
|
247
254
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -288,7 +295,25 @@ const Steps = ({
|
|
|
288
295
|
},
|
|
289
296
|
classNamePagination: "p-6",
|
|
290
297
|
queryKey: ["organization-workflow-steps", filters, limit, organization.id],
|
|
291
|
-
|
|
298
|
+
// The Activity drawer is white, so the empty box is the grey
|
|
299
|
+
// one, inset like the drawer's other bodies.
|
|
300
|
+
empty: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
301
|
+
"div",
|
|
302
|
+
{
|
|
303
|
+
...{
|
|
304
|
+
className: "h-full p-6"
|
|
305
|
+
},
|
|
306
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
307
|
+
import_empty.default,
|
|
308
|
+
{
|
|
309
|
+
...{
|
|
310
|
+
variant: "secondary"
|
|
311
|
+
},
|
|
312
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "No activity" })
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
)
|
|
292
317
|
},
|
|
293
318
|
children: ({ items }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
294
319
|
"div",
|
|
@@ -316,5 +341,6 @@ var steps_default = Steps;
|
|
|
316
341
|
0 && (module.exports = {
|
|
317
342
|
groupTitle,
|
|
318
343
|
replyExcerpt,
|
|
319
|
-
rowLabel
|
|
344
|
+
rowLabel,
|
|
345
|
+
rowState
|
|
320
346
|
});
|
package/dist/dashboard/steps.mjs
CHANGED
|
@@ -32,6 +32,17 @@ const replyExcerpt = (response, length = 300) => {
|
|
|
32
32
|
if (!text) return null;
|
|
33
33
|
return text.length > length ? text.slice(0, length) + "\u2026" : text;
|
|
34
34
|
};
|
|
35
|
+
const rowState = ({ error: chunkError, message, status }) => {
|
|
36
|
+
const error = chunkError || status === "failed" && message || null;
|
|
37
|
+
return {
|
|
38
|
+
badge: {
|
|
39
|
+
text: capitalize(status),
|
|
40
|
+
type: error ? "error" : badgeType(status)
|
|
41
|
+
},
|
|
42
|
+
error,
|
|
43
|
+
notice: error || status === "skipped" && message || null
|
|
44
|
+
};
|
|
45
|
+
};
|
|
35
46
|
const StepItem = ({
|
|
36
47
|
updatedAt,
|
|
37
48
|
error: chunkError,
|
|
@@ -42,8 +53,7 @@ const StepItem = ({
|
|
|
42
53
|
slug,
|
|
43
54
|
status
|
|
44
55
|
}) => {
|
|
45
|
-
const error
|
|
46
|
-
const notice = error || status === "skipped" && message || null;
|
|
56
|
+
const { badge, error, notice } = rowState({ error: chunkError, message, status });
|
|
47
57
|
const reply = error ? replyExcerpt(response) : null;
|
|
48
58
|
return /* @__PURE__ */ jsxs(
|
|
49
59
|
"div",
|
|
@@ -74,10 +84,7 @@ const StepItem = ({
|
|
|
74
84
|
Accordion,
|
|
75
85
|
{
|
|
76
86
|
...{
|
|
77
|
-
badge
|
|
78
|
-
text: capitalize(status),
|
|
79
|
-
type: error ? "error" : badgeType(status)
|
|
80
|
-
},
|
|
87
|
+
badge,
|
|
81
88
|
className: "w-full",
|
|
82
89
|
classNamePanel: "text-sm pt-2",
|
|
83
90
|
title: /* @__PURE__ */ jsxs(
|
|
@@ -183,9 +190,8 @@ const StepItem = ({
|
|
|
183
190
|
}
|
|
184
191
|
);
|
|
185
192
|
};
|
|
186
|
-
const groupTitle = ({ count, email, items, kind, pending }) => {
|
|
187
|
-
|
|
188
|
-
if (kind !== "notify") return email || ((_a = items == null ? void 0 : items[0]) == null ? void 0 : _a.slug) || "Activity";
|
|
193
|
+
const groupTitle = ({ count, email, items, kind, pending }, labels = []) => {
|
|
194
|
+
if (kind !== "notify") return email || (items == null ? void 0 : items[0]) && rowLabel({ item: items[0], kind, labels }) || "Activity";
|
|
189
195
|
const entries = count + " new " + (count === 1 ? "entry" : "entries");
|
|
190
196
|
return "Team notification \u2014 " + entries + (pending ? ", sending" : "");
|
|
191
197
|
};
|
|
@@ -206,7 +212,7 @@ const Group = ({
|
|
|
206
212
|
...{
|
|
207
213
|
className: "text-xs text-gray-dark pb-3"
|
|
208
214
|
},
|
|
209
|
-
children: groupTitle(group)
|
|
215
|
+
children: groupTitle(group, labels)
|
|
210
216
|
}
|
|
211
217
|
),
|
|
212
218
|
/* @__PURE__ */ jsx(
|
|
@@ -253,7 +259,25 @@ const Steps = ({
|
|
|
253
259
|
},
|
|
254
260
|
classNamePagination: "p-6",
|
|
255
261
|
queryKey: ["organization-workflow-steps", filters, limit, organization.id],
|
|
256
|
-
|
|
262
|
+
// The Activity drawer is white, so the empty box is the grey
|
|
263
|
+
// one, inset like the drawer's other bodies.
|
|
264
|
+
empty: () => /* @__PURE__ */ jsx(
|
|
265
|
+
"div",
|
|
266
|
+
{
|
|
267
|
+
...{
|
|
268
|
+
className: "h-full p-6"
|
|
269
|
+
},
|
|
270
|
+
children: /* @__PURE__ */ jsx(
|
|
271
|
+
Empty,
|
|
272
|
+
{
|
|
273
|
+
...{
|
|
274
|
+
variant: "secondary"
|
|
275
|
+
},
|
|
276
|
+
children: /* @__PURE__ */ jsx("p", { children: "No activity" })
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
)
|
|
257
281
|
},
|
|
258
282
|
children: ({ items }) => /* @__PURE__ */ jsx(
|
|
259
283
|
"div",
|
|
@@ -281,5 +305,6 @@ export {
|
|
|
281
305
|
steps_default as default,
|
|
282
306
|
groupTitle,
|
|
283
307
|
replyExcerpt,
|
|
284
|
-
rowLabel
|
|
308
|
+
rowLabel,
|
|
309
|
+
rowState
|
|
285
310
|
};
|