@drawbridge/components 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/lib/url.js +3 -3
- package/dist/bridge/lib/url.mjs +3 -3
- package/dist/bridge/share-button.js +12 -2
- package/dist/bridge/share-button.mjs +12 -2
- package/dist/bridge/template-layout.js +1 -1
- package/dist/bridge/template-layout.mjs +1 -1
- package/dist/dashboard/answer-rows.js +77 -0
- package/dist/dashboard/answer-rows.mjs +41 -0
- package/dist/dashboard/card-order.js +186 -243
- package/dist/dashboard/card-order.mjs +186 -243
- package/dist/dashboard/form-organization-campaign-field-list.js +8 -49
- package/dist/dashboard/form-organization-campaign-field-list.mjs +8 -49
- package/dist/dashboard/form-organization-workflow.js +70 -120
- package/dist/dashboard/form-organization-workflow.mjs +68 -120
- package/dist/dashboard/item-row.js +92 -0
- package/dist/dashboard/item-row.mjs +63 -0
- package/dist/dashboard/lib/sms.js +3 -0
- package/dist/dashboard/lib/sms.mjs +2 -0
- package/dist/dashboard/order-sections.js +220 -0
- package/dist/dashboard/order-sections.mjs +185 -0
- package/dist/dashboard/preview.js +29 -2
- package/dist/dashboard/preview.mjs +28 -2
- package/dist/shared/lib/helpers.js +7 -0
- package/dist/shared/lib/helpers.mjs +7 -0
- package/package.json +19 -4
- package/types/bridge/lib/url.d.ts +5 -4
- package/types/dashboard/answer-rows.d.ts +30 -0
- package/types/dashboard/card-order.d.ts +16 -14
- package/types/dashboard/form-organization-workflow.d.ts +2 -0
- package/types/dashboard/item-row.d.ts +25 -0
- package/types/dashboard/order-sections.d.ts +36 -0
- package/types/shared/lib/helpers.d.ts +1 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var order_sections_exports = {};
|
|
30
|
+
__export(order_sections_exports, {
|
|
31
|
+
OrderFulfillment: () => OrderFulfillment,
|
|
32
|
+
fulfillmentControls: () => fulfillmentControls,
|
|
33
|
+
useConfirm: () => useConfirm
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(order_sections_exports);
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var import_react_query = require("@tanstack/react-query");
|
|
38
|
+
var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
|
|
39
|
+
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
40
|
+
var import_hooks = require("./lib/hooks");
|
|
41
|
+
var import_card_section = __toESM(require("./card-section"));
|
|
42
|
+
var import_card_task = __toESM(require("./card-task"));
|
|
43
|
+
var import_form_action = __toESM(require("./form-action"));
|
|
44
|
+
var import_paged = __toESM(require("./paged"));
|
|
45
|
+
var import_badge = __toESM(require("../shared/badge"));
|
|
46
|
+
var import_button = __toESM(require("../shared/button"));
|
|
47
|
+
var import_plus = __toESM(require("../icons/plus"));
|
|
48
|
+
const date = (value) => (0, import_drawbridge_utils.formatDateString)({
|
|
49
|
+
date: value,
|
|
50
|
+
options: {
|
|
51
|
+
day: "numeric",
|
|
52
|
+
month: "short",
|
|
53
|
+
year: "numeric"
|
|
54
|
+
},
|
|
55
|
+
time: true
|
|
56
|
+
});
|
|
57
|
+
const useConfirm = () => {
|
|
58
|
+
const queryClient = (0, import_react_query.useQueryClient)();
|
|
59
|
+
const modal = (0, import_hooks.useModal)({
|
|
60
|
+
queryClient
|
|
61
|
+
});
|
|
62
|
+
const { onError } = (0, import_hooks.useCallbacks)({
|
|
63
|
+
queryClient
|
|
64
|
+
});
|
|
65
|
+
return ({ action, body, endpoint, message, method = "PUT", onSuccess, task }) => modal.open({
|
|
66
|
+
title: action,
|
|
67
|
+
message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
+
import_form_action.default,
|
|
69
|
+
{
|
|
70
|
+
...{
|
|
71
|
+
action,
|
|
72
|
+
callback: () => (0, import_fetch.request)({
|
|
73
|
+
body,
|
|
74
|
+
endpoint,
|
|
75
|
+
method
|
|
76
|
+
}),
|
|
77
|
+
disabled: Boolean(task),
|
|
78
|
+
onError,
|
|
79
|
+
onSuccess
|
|
80
|
+
},
|
|
81
|
+
children: task ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
+
import_card_task.default,
|
|
83
|
+
{
|
|
84
|
+
...{
|
|
85
|
+
message: task,
|
|
86
|
+
type: "warning"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: message })
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const fulfillmentControls = ({ manage, order }) => {
|
|
95
|
+
var _a;
|
|
96
|
+
const editable = Boolean(manage) && (order == null ? void 0 : order.status) === "open";
|
|
97
|
+
return {
|
|
98
|
+
add: editable && ((_a = order == null ? void 0 : order.fulfillment) == null ? void 0 : _a.status) !== "fulfilled",
|
|
99
|
+
cancel: editable
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const small = {
|
|
103
|
+
inline: true,
|
|
104
|
+
size: "small",
|
|
105
|
+
variant: "secondary"
|
|
106
|
+
};
|
|
107
|
+
const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
|
|
108
|
+
const confirm = useConfirm();
|
|
109
|
+
const controls = fulfillmentControls({ manage, order });
|
|
110
|
+
const fulfill = () => confirm({
|
|
111
|
+
action: "Mark as fulfilled",
|
|
112
|
+
endpoint: endpoint + "/fulfillment",
|
|
113
|
+
message: "The order is marked Fulfilled. The customer is not emailed.",
|
|
114
|
+
method: "POST",
|
|
115
|
+
onSuccess
|
|
116
|
+
});
|
|
117
|
+
const cancel = (item) => confirm({
|
|
118
|
+
action: "Cancel fulfillment",
|
|
119
|
+
body: {
|
|
120
|
+
status: "canceled"
|
|
121
|
+
},
|
|
122
|
+
endpoint: endpoint + "/fulfillment/" + item.id,
|
|
123
|
+
message: "The order goes back to Unfulfilled. The customer is not emailed.",
|
|
124
|
+
onSuccess
|
|
125
|
+
});
|
|
126
|
+
const cta = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
+
import_button.default,
|
|
128
|
+
{
|
|
129
|
+
...{
|
|
130
|
+
...small,
|
|
131
|
+
"aria-label": "Mark as fulfilled",
|
|
132
|
+
disabled: !controls.add,
|
|
133
|
+
icon: import_plus.default,
|
|
134
|
+
onClick: fulfill
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
139
|
+
import_card_section.default,
|
|
140
|
+
{
|
|
141
|
+
...{
|
|
142
|
+
className: "shrink-0",
|
|
143
|
+
cta,
|
|
144
|
+
title: "Fulfillment"
|
|
145
|
+
},
|
|
146
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
147
|
+
import_paged.default,
|
|
148
|
+
{
|
|
149
|
+
...{
|
|
150
|
+
empty: {
|
|
151
|
+
message: "Not fulfilled yet",
|
|
152
|
+
variant: "secondary"
|
|
153
|
+
},
|
|
154
|
+
endpoint: endpoint + "/fulfillments",
|
|
155
|
+
params: {
|
|
156
|
+
limit: 3
|
|
157
|
+
},
|
|
158
|
+
queryKey: ["order-fulfillments", order == null ? void 0 : order.id]
|
|
159
|
+
},
|
|
160
|
+
children: ({ items }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
161
|
+
"div",
|
|
162
|
+
{
|
|
163
|
+
...{
|
|
164
|
+
className: "divide-y divide-gray"
|
|
165
|
+
},
|
|
166
|
+
children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
...{
|
|
170
|
+
className: "flex items-center justify-between gap-4 py-4 first:pt-0 last:pb-0"
|
|
171
|
+
},
|
|
172
|
+
children: [
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
...{
|
|
177
|
+
className: "flex items-center gap-3 min-w-0"
|
|
178
|
+
},
|
|
179
|
+
children: [
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: date(item.createdAt) }),
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
182
|
+
import_badge.default,
|
|
183
|
+
{
|
|
184
|
+
...{
|
|
185
|
+
type: item.status === "active" ? "success" : "secondary"
|
|
186
|
+
},
|
|
187
|
+
children: item.status === "active" ? "Fulfilled" : "Canceled"
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
),
|
|
193
|
+
item.status === "active" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
194
|
+
import_button.default,
|
|
195
|
+
{
|
|
196
|
+
...{
|
|
197
|
+
...small,
|
|
198
|
+
disabled: !controls.cancel,
|
|
199
|
+
onClick: () => cancel(item)
|
|
200
|
+
},
|
|
201
|
+
children: "Cancel"
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
item.id
|
|
207
|
+
))
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
216
|
+
0 && (module.exports = {
|
|
217
|
+
OrderFulfillment,
|
|
218
|
+
fulfillmentControls,
|
|
219
|
+
useConfirm
|
|
220
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { formatDateString } from "@drawbridge/drawbridge-utils";
|
|
5
|
+
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
6
|
+
import { useCallbacks, useModal } from "./lib/hooks.mjs";
|
|
7
|
+
import CardSection from "./card-section.mjs";
|
|
8
|
+
import CardTask from "./card-task.mjs";
|
|
9
|
+
import FormAction from "./form-action.mjs";
|
|
10
|
+
import Paged from "./paged.mjs";
|
|
11
|
+
import Badge from "../shared/badge.mjs";
|
|
12
|
+
import Button from "../shared/button.mjs";
|
|
13
|
+
import Plus from "../icons/plus.mjs";
|
|
14
|
+
const date = (value) => formatDateString({
|
|
15
|
+
date: value,
|
|
16
|
+
options: {
|
|
17
|
+
day: "numeric",
|
|
18
|
+
month: "short",
|
|
19
|
+
year: "numeric"
|
|
20
|
+
},
|
|
21
|
+
time: true
|
|
22
|
+
});
|
|
23
|
+
const useConfirm = () => {
|
|
24
|
+
const queryClient = useQueryClient();
|
|
25
|
+
const modal = useModal({
|
|
26
|
+
queryClient
|
|
27
|
+
});
|
|
28
|
+
const { onError } = useCallbacks({
|
|
29
|
+
queryClient
|
|
30
|
+
});
|
|
31
|
+
return ({ action, body, endpoint, message, method = "PUT", onSuccess, task }) => modal.open({
|
|
32
|
+
title: action,
|
|
33
|
+
message: /* @__PURE__ */ jsx(
|
|
34
|
+
FormAction,
|
|
35
|
+
{
|
|
36
|
+
...{
|
|
37
|
+
action,
|
|
38
|
+
callback: () => request({
|
|
39
|
+
body,
|
|
40
|
+
endpoint,
|
|
41
|
+
method
|
|
42
|
+
}),
|
|
43
|
+
disabled: Boolean(task),
|
|
44
|
+
onError,
|
|
45
|
+
onSuccess
|
|
46
|
+
},
|
|
47
|
+
children: task ? /* @__PURE__ */ jsx(
|
|
48
|
+
CardTask,
|
|
49
|
+
{
|
|
50
|
+
...{
|
|
51
|
+
message: task,
|
|
52
|
+
type: "warning"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
) : /* @__PURE__ */ jsx("p", { children: message })
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const fulfillmentControls = ({ manage, order }) => {
|
|
61
|
+
var _a;
|
|
62
|
+
const editable = Boolean(manage) && (order == null ? void 0 : order.status) === "open";
|
|
63
|
+
return {
|
|
64
|
+
add: editable && ((_a = order == null ? void 0 : order.fulfillment) == null ? void 0 : _a.status) !== "fulfilled",
|
|
65
|
+
cancel: editable
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const small = {
|
|
69
|
+
inline: true,
|
|
70
|
+
size: "small",
|
|
71
|
+
variant: "secondary"
|
|
72
|
+
};
|
|
73
|
+
const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
|
|
74
|
+
const confirm = useConfirm();
|
|
75
|
+
const controls = fulfillmentControls({ manage, order });
|
|
76
|
+
const fulfill = () => confirm({
|
|
77
|
+
action: "Mark as fulfilled",
|
|
78
|
+
endpoint: endpoint + "/fulfillment",
|
|
79
|
+
message: "The order is marked Fulfilled. The customer is not emailed.",
|
|
80
|
+
method: "POST",
|
|
81
|
+
onSuccess
|
|
82
|
+
});
|
|
83
|
+
const cancel = (item) => confirm({
|
|
84
|
+
action: "Cancel fulfillment",
|
|
85
|
+
body: {
|
|
86
|
+
status: "canceled"
|
|
87
|
+
},
|
|
88
|
+
endpoint: endpoint + "/fulfillment/" + item.id,
|
|
89
|
+
message: "The order goes back to Unfulfilled. The customer is not emailed.",
|
|
90
|
+
onSuccess
|
|
91
|
+
});
|
|
92
|
+
const cta = /* @__PURE__ */ jsx(
|
|
93
|
+
Button,
|
|
94
|
+
{
|
|
95
|
+
...{
|
|
96
|
+
...small,
|
|
97
|
+
"aria-label": "Mark as fulfilled",
|
|
98
|
+
disabled: !controls.add,
|
|
99
|
+
icon: Plus,
|
|
100
|
+
onClick: fulfill
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
return /* @__PURE__ */ jsx(
|
|
105
|
+
CardSection,
|
|
106
|
+
{
|
|
107
|
+
...{
|
|
108
|
+
className: "shrink-0",
|
|
109
|
+
cta,
|
|
110
|
+
title: "Fulfillment"
|
|
111
|
+
},
|
|
112
|
+
children: /* @__PURE__ */ jsx(
|
|
113
|
+
Paged,
|
|
114
|
+
{
|
|
115
|
+
...{
|
|
116
|
+
empty: {
|
|
117
|
+
message: "Not fulfilled yet",
|
|
118
|
+
variant: "secondary"
|
|
119
|
+
},
|
|
120
|
+
endpoint: endpoint + "/fulfillments",
|
|
121
|
+
params: {
|
|
122
|
+
limit: 3
|
|
123
|
+
},
|
|
124
|
+
queryKey: ["order-fulfillments", order == null ? void 0 : order.id]
|
|
125
|
+
},
|
|
126
|
+
children: ({ items }) => /* @__PURE__ */ jsx(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
...{
|
|
130
|
+
className: "divide-y divide-gray"
|
|
131
|
+
},
|
|
132
|
+
children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
...{
|
|
136
|
+
className: "flex items-center justify-between gap-4 py-4 first:pt-0 last:pb-0"
|
|
137
|
+
},
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ jsxs(
|
|
140
|
+
"div",
|
|
141
|
+
{
|
|
142
|
+
...{
|
|
143
|
+
className: "flex items-center gap-3 min-w-0"
|
|
144
|
+
},
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx("p", { children: date(item.createdAt) }),
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
Badge,
|
|
149
|
+
{
|
|
150
|
+
...{
|
|
151
|
+
type: item.status === "active" ? "success" : "secondary"
|
|
152
|
+
},
|
|
153
|
+
children: item.status === "active" ? "Fulfilled" : "Canceled"
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
item.status === "active" && /* @__PURE__ */ jsx(
|
|
160
|
+
Button,
|
|
161
|
+
{
|
|
162
|
+
...{
|
|
163
|
+
...small,
|
|
164
|
+
disabled: !controls.cancel,
|
|
165
|
+
onClick: () => cancel(item)
|
|
166
|
+
},
|
|
167
|
+
children: "Cancel"
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
item.id
|
|
173
|
+
))
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
export {
|
|
182
|
+
OrderFulfillment,
|
|
183
|
+
fulfillmentControls,
|
|
184
|
+
useConfirm
|
|
185
|
+
};
|
|
@@ -31,7 +31,8 @@ __export(preview_exports, {
|
|
|
31
31
|
PreviewPage: () => PreviewPage,
|
|
32
32
|
clamp: () => clamp,
|
|
33
33
|
default: () => preview_default,
|
|
34
|
-
fitScale: () => fitScale
|
|
34
|
+
fitScale: () => fitScale,
|
|
35
|
+
scroller: () => scroller
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(preview_exports);
|
|
37
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -62,6 +63,17 @@ const ZOOMS = [
|
|
|
62
63
|
];
|
|
63
64
|
const clamp = (value, limit) => Math.min(limit, Math.max(-limit, value));
|
|
64
65
|
const fitScale = (space, size) => space.width && size.width ? Math.min(1, (space.width - GUTTER) / size.width, (space.height - GUTTER) / size.height) : 1;
|
|
66
|
+
const scroller = (node) => {
|
|
67
|
+
for (const iframe of (node == null ? void 0 : node.querySelectorAll("iframe")) || []) {
|
|
68
|
+
const doc = iframe.contentDocument;
|
|
69
|
+
const element = doc == null ? void 0 : doc.scrollingElement;
|
|
70
|
+
if (element && element.scrollHeight > element.clientHeight) return element;
|
|
71
|
+
const inner = doc && scroller(doc);
|
|
72
|
+
if (inner) return inner;
|
|
73
|
+
}
|
|
74
|
+
;
|
|
75
|
+
return null;
|
|
76
|
+
};
|
|
65
77
|
const PreviewFrame = ({
|
|
66
78
|
children,
|
|
67
79
|
states
|
|
@@ -105,6 +117,20 @@ const PreviewFrame = ({
|
|
|
105
117
|
(0, import_react.useLayoutEffect)(() => {
|
|
106
118
|
setOffset({ x: 0, y: 0 });
|
|
107
119
|
}, [device, zoom]);
|
|
120
|
+
(0, import_react.useEffect)(() => {
|
|
121
|
+
const node = area.current;
|
|
122
|
+
const { screen, viewport } = import_device.DEVICE_TYPES[device];
|
|
123
|
+
const ratio = scale * screen.width / viewport;
|
|
124
|
+
const onWheel = (event) => {
|
|
125
|
+
const element = scroller(frame.current);
|
|
126
|
+
if (!element || !event.deltaY) return;
|
|
127
|
+
const top = element.scrollTop;
|
|
128
|
+
element.scrollTop = top + event.deltaY * (event.deltaMode === 1 ? 16 : 1) / ratio;
|
|
129
|
+
if (element.scrollTop !== top) event.preventDefault();
|
|
130
|
+
};
|
|
131
|
+
node.addEventListener("wheel", onWheel, { passive: false });
|
|
132
|
+
return () => node.removeEventListener("wheel", onWheel);
|
|
133
|
+
}, [device, scale]);
|
|
108
134
|
(0, import_react.useEffect)(() => {
|
|
109
135
|
if (!ease) return;
|
|
110
136
|
const timer = setTimeout(() => setEase(false), 200);
|
|
@@ -415,5 +441,6 @@ var preview_default = Preview;
|
|
|
415
441
|
0 && (module.exports = {
|
|
416
442
|
PreviewPage,
|
|
417
443
|
clamp,
|
|
418
|
-
fitScale
|
|
444
|
+
fitScale,
|
|
445
|
+
scroller
|
|
419
446
|
});
|
|
@@ -5,7 +5,7 @@ import { createPortal } from "react-dom";
|
|
|
5
5
|
import Button from "../shared/button.mjs";
|
|
6
6
|
import LoaderComponent from "../shared/loader.mjs";
|
|
7
7
|
import InputCombobox from "./input-combobox.mjs";
|
|
8
|
-
import Device from "./device.mjs";
|
|
8
|
+
import Device, { DEVICE_TYPES } from "./device.mjs";
|
|
9
9
|
import Desktop from "../icons/desktop.mjs";
|
|
10
10
|
import Phone from "../icons/phone.mjs";
|
|
11
11
|
import Tablet from "../icons/tablet.mjs";
|
|
@@ -27,6 +27,17 @@ const ZOOMS = [
|
|
|
27
27
|
];
|
|
28
28
|
const clamp = (value, limit) => Math.min(limit, Math.max(-limit, value));
|
|
29
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 scroller = (node) => {
|
|
31
|
+
for (const iframe of (node == null ? void 0 : node.querySelectorAll("iframe")) || []) {
|
|
32
|
+
const doc = iframe.contentDocument;
|
|
33
|
+
const element = doc == null ? void 0 : doc.scrollingElement;
|
|
34
|
+
if (element && element.scrollHeight > element.clientHeight) return element;
|
|
35
|
+
const inner = doc && scroller(doc);
|
|
36
|
+
if (inner) return inner;
|
|
37
|
+
}
|
|
38
|
+
;
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
30
41
|
const PreviewFrame = ({
|
|
31
42
|
children,
|
|
32
43
|
states
|
|
@@ -70,6 +81,20 @@ const PreviewFrame = ({
|
|
|
70
81
|
useLayoutEffect(() => {
|
|
71
82
|
setOffset({ x: 0, y: 0 });
|
|
72
83
|
}, [device, zoom]);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const node = area.current;
|
|
86
|
+
const { screen, viewport } = DEVICE_TYPES[device];
|
|
87
|
+
const ratio = scale * screen.width / viewport;
|
|
88
|
+
const onWheel = (event) => {
|
|
89
|
+
const element = scroller(frame.current);
|
|
90
|
+
if (!element || !event.deltaY) return;
|
|
91
|
+
const top = element.scrollTop;
|
|
92
|
+
element.scrollTop = top + event.deltaY * (event.deltaMode === 1 ? 16 : 1) / ratio;
|
|
93
|
+
if (element.scrollTop !== top) event.preventDefault();
|
|
94
|
+
};
|
|
95
|
+
node.addEventListener("wheel", onWheel, { passive: false });
|
|
96
|
+
return () => node.removeEventListener("wheel", onWheel);
|
|
97
|
+
}, [device, scale]);
|
|
73
98
|
useEffect(() => {
|
|
74
99
|
if (!ease) return;
|
|
75
100
|
const timer = setTimeout(() => setEase(false), 200);
|
|
@@ -380,5 +405,6 @@ export {
|
|
|
380
405
|
PreviewPage,
|
|
381
406
|
clamp,
|
|
382
407
|
preview_default as default,
|
|
383
|
-
fitScale
|
|
408
|
+
fitScale,
|
|
409
|
+
scroller
|
|
384
410
|
};
|
|
@@ -321,6 +321,13 @@ const statuses = {
|
|
|
321
321
|
member: {
|
|
322
322
|
pending: { text: "Invited", type: "warning" }
|
|
323
323
|
},
|
|
324
|
+
// @story campaigns/manage-order
|
|
325
|
+
// A form order's badge beside its customer on Orders: only a closed order
|
|
326
|
+
// shows one, Canceled red as a canceled subscription is.
|
|
327
|
+
order: {
|
|
328
|
+
canceled: { text: "Canceled", type: "error" },
|
|
329
|
+
completed: { text: "Completed", type: "success" }
|
|
330
|
+
},
|
|
324
331
|
organization: Object.fromEntries(organizationStatuses.map((status) => [status, { text: (0, import_drawbridge_utils.capitalize)(status.replace("_", " ")), type: ["active", "unsubscribed"].includes(status) ? "success" : status === "paused" ? "warning" : "error" }])),
|
|
325
332
|
page: published,
|
|
326
333
|
prize: published,
|
|
@@ -261,6 +261,13 @@ const statuses = {
|
|
|
261
261
|
member: {
|
|
262
262
|
pending: { text: "Invited", type: "warning" }
|
|
263
263
|
},
|
|
264
|
+
// @story campaigns/manage-order
|
|
265
|
+
// A form order's badge beside its customer on Orders: only a closed order
|
|
266
|
+
// shows one, Canceled red as a canceled subscription is.
|
|
267
|
+
order: {
|
|
268
|
+
canceled: { text: "Canceled", type: "error" },
|
|
269
|
+
completed: { text: "Completed", type: "success" }
|
|
270
|
+
},
|
|
264
271
|
organization: Object.fromEntries(organizationStatuses.map((status) => [status, { text: capitalize(status.replace("_", " ")), type: ["active", "unsubscribed"].includes(status) ? "success" : status === "paused" ? "warning" : "error" }])),
|
|
265
272
|
page: published,
|
|
266
273
|
prize: published,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drawbridge/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./advertisement": {
|
|
6
6
|
"types": "./types/advertisement.d.ts",
|
|
@@ -172,6 +172,11 @@
|
|
|
172
172
|
"import": "./dist/dashboard/accordion.mjs",
|
|
173
173
|
"default": "./dist/dashboard/accordion.js"
|
|
174
174
|
},
|
|
175
|
+
"./dashboard/answer-rows": {
|
|
176
|
+
"types": "./types/dashboard/answer-rows.d.ts",
|
|
177
|
+
"import": "./dist/dashboard/answer-rows.mjs",
|
|
178
|
+
"default": "./dist/dashboard/answer-rows.js"
|
|
179
|
+
},
|
|
175
180
|
"./dashboard/avatar": {
|
|
176
181
|
"types": "./types/dashboard/avatar.d.ts",
|
|
177
182
|
"import": "./dist/dashboard/avatar.mjs",
|
|
@@ -747,6 +752,11 @@
|
|
|
747
752
|
"import": "./dist/dashboard/input-time.mjs",
|
|
748
753
|
"default": "./dist/dashboard/input-time.js"
|
|
749
754
|
},
|
|
755
|
+
"./dashboard/item-row": {
|
|
756
|
+
"types": "./types/dashboard/item-row.d.ts",
|
|
757
|
+
"import": "./dist/dashboard/item-row.mjs",
|
|
758
|
+
"default": "./dist/dashboard/item-row.js"
|
|
759
|
+
},
|
|
750
760
|
"./dashboard/lib/confetti": {
|
|
751
761
|
"types": "./types/dashboard/lib/confetti.d.ts",
|
|
752
762
|
"import": "./dist/dashboard/lib/confetti.mjs",
|
|
@@ -882,6 +892,11 @@
|
|
|
882
892
|
"import": "./dist/dashboard/notice.mjs",
|
|
883
893
|
"default": "./dist/dashboard/notice.js"
|
|
884
894
|
},
|
|
895
|
+
"./dashboard/order-sections": {
|
|
896
|
+
"types": "./types/dashboard/order-sections.d.ts",
|
|
897
|
+
"import": "./dist/dashboard/order-sections.mjs",
|
|
898
|
+
"default": "./dist/dashboard/order-sections.js"
|
|
899
|
+
},
|
|
885
900
|
"./dashboard/paged": {
|
|
886
901
|
"types": "./types/dashboard/paged.d.ts",
|
|
887
902
|
"import": "./dist/dashboard/paged.mjs",
|
|
@@ -1648,7 +1663,7 @@
|
|
|
1648
1663
|
"peerDependencies": {
|
|
1649
1664
|
"@analytics/google-tag-manager": ">=0.5.5",
|
|
1650
1665
|
"@drawbridge/drawbridge-telemetry": ">=0.0.19",
|
|
1651
|
-
"@drawbridge/drawbridge-utils": ">=0.0.
|
|
1666
|
+
"@drawbridge/drawbridge-utils": ">=0.0.228",
|
|
1652
1667
|
"@headlessui/react": ">=2.1.2",
|
|
1653
1668
|
"@hookform/resolvers": ">=3.1.1",
|
|
1654
1669
|
"@sentry/nextjs": ">=10.58.0",
|
|
@@ -1766,9 +1781,9 @@
|
|
|
1766
1781
|
},
|
|
1767
1782
|
"devDependencies": {
|
|
1768
1783
|
"@analytics/google-tag-manager": "0.5.5",
|
|
1769
|
-
"@drawbridge/drawbridge-agents": "0.1.
|
|
1784
|
+
"@drawbridge/drawbridge-agents": "0.1.102",
|
|
1770
1785
|
"@drawbridge/drawbridge-telemetry": "0.0.19",
|
|
1771
|
-
"@drawbridge/drawbridge-utils": "0.0.
|
|
1786
|
+
"@drawbridge/drawbridge-utils": "0.0.227",
|
|
1772
1787
|
"@headlessui/react": "2.2.9",
|
|
1773
1788
|
"@hookform/resolvers": "3.1.1",
|
|
1774
1789
|
"@sentry/nextjs": "10.58.0",
|
|
@@ -20,10 +20,10 @@ export declare const submissionEndpoint: ( props: {
|
|
|
20
20
|
token?: string;
|
|
21
21
|
} ) => string | null;
|
|
22
22
|
|
|
23
|
-
// Where a lead's own link (`?
|
|
24
|
-
// when `
|
|
23
|
+
// Where a lead's own link (`?m=<code>`) asks for their entries, or null
|
|
24
|
+
// when `code` is not a missions code. `token` is the owner's preview token.
|
|
25
25
|
export declare const leadEndpoint: ( props: {
|
|
26
|
-
|
|
26
|
+
code: string | null | undefined;
|
|
27
27
|
slug: string;
|
|
28
28
|
subdomain: string;
|
|
29
29
|
token?: string | null;
|
|
@@ -31,7 +31,8 @@ export declare const leadEndpoint: ( props: {
|
|
|
31
31
|
|
|
32
32
|
// Where the missions panel takes a mission's action: one route for every
|
|
33
33
|
// mission, the action one its completion declares (a code mission sends and
|
|
34
|
-
// confirms). The lead's
|
|
34
|
+
// confirms). The lead's missions code goes in the request body as `token`,
|
|
35
|
+
// not the path.
|
|
35
36
|
export declare const missionEndpoint: ( props: {
|
|
36
37
|
action: string;
|
|
37
38
|
slug: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface AnswerField {
|
|
4
|
+
deleted?: boolean;
|
|
5
|
+
id: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
slug?: string;
|
|
8
|
+
type?: 'additional' | 'lead' | 'order' | string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Answer {
|
|
12
|
+
reference: string;
|
|
13
|
+
value?: unknown;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AnswerRow {
|
|
17
|
+
label?: string;
|
|
18
|
+
value: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare const blank: ( value: unknown ) => boolean;
|
|
22
|
+
|
|
23
|
+
// An answer as it reads: an em dash for none, an object's values joined.
|
|
24
|
+
export declare const display: ( value: unknown ) => string;
|
|
25
|
+
|
|
26
|
+
// A removed field's answer: struck through, with a small Removed badge.
|
|
27
|
+
export declare const Removed: ComponentType<{ children?: ReactNode }>;
|
|
28
|
+
|
|
29
|
+
// One type of field's rows, in the Form page's order; a removed field only where it was answered.
|
|
30
|
+
export declare const answerRows: ( fields?: AnswerField[], answers?: Answer[] ) => ( type: string ) => AnswerRow[];
|