@drawbridge/components 0.1.14 → 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/form-subdomain-missions.js +77 -38
- package/dist/bridge/form-subdomain-missions.mjs +76 -38
- 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-campaign-switch.js +55 -43
- package/dist/dashboard/card-campaign-switch.mjs +56 -44
- package/dist/dashboard/card-order.js +248 -120
- package/dist/dashboard/card-order.mjs +248 -120
- package/dist/dashboard/connection-workflows.js +13 -4
- package/dist/dashboard/connection-workflows.mjs +13 -4
- 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-campaign-field-select.js +51 -5
- package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
- package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
- package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
- package/dist/dashboard/form-organization-campaign-section.js +24 -4
- package/dist/dashboard/form-organization-campaign-section.mjs +24 -4
- package/dist/dashboard/form-organization-workflow.js +195 -56
- package/dist/dashboard/form-organization-workflow.mjs +191 -57
- 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/input-code.js +35 -53
- package/dist/input-code.mjs +26 -54
- package/dist/shared/button.js +1 -1
- package/dist/shared/button.mjs +1 -1
- package/dist/shared/lib/campaign.js +9 -3
- package/dist/shared/lib/campaign.mjs +7 -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/form-subdomain-missions.d.ts +3 -1
- 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 +18 -3
- package/types/dashboard/form-organization-campaign-section.d.ts +2 -0
- package/types/dashboard/form-organization-workflow.d.ts +15 -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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const smsNumberActive = (organization) => ((organization == null ? void 0 : organization.identityItems) || []).some((row) => (row == null ? void 0 : row.type) === "sms" && (row == null ? void 0 : row.status) === "verified");
|
|
2
|
+
const smsBrandLine = (brand, message) => brand && !String(message || "").trim().toLowerCase().startsWith(String(brand).trim().toLowerCase()) ? brand : null;
|
|
2
3
|
export {
|
|
4
|
+
smsBrandLine,
|
|
3
5
|
smsNumberActive
|
|
4
6
|
};
|
|
@@ -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
|
};
|
package/dist/input-code.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var input_code_exports = {};
|
|
20
30
|
__export(input_code_exports, {
|
|
@@ -23,8 +33,7 @@ __export(input_code_exports, {
|
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(input_code_exports);
|
|
25
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
-
var
|
|
27
|
-
var import_styles = require("./styles");
|
|
36
|
+
var import_input_text = __toESM(require("./input-text"));
|
|
28
37
|
const codeDigits = (value, length = 6) => String(value ?? "").replace(/\D/g, "").slice(0, length);
|
|
29
38
|
const InputCode = ({
|
|
30
39
|
autoFocus,
|
|
@@ -37,60 +46,33 @@ const InputCode = ({
|
|
|
37
46
|
style,
|
|
38
47
|
value
|
|
39
48
|
}) => {
|
|
40
|
-
const [focused, setFocused] = (0, import_react.useState)(false);
|
|
41
49
|
const digits = codeDigits(value, length);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
45
|
-
"div",
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
import_input_text.default,
|
|
46
52
|
{
|
|
47
53
|
...{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"aria-label": "Verification code"
|
|
71
|
-
},
|
|
72
|
-
autoComplete: "one-time-code",
|
|
73
|
-
autoFocus,
|
|
74
|
-
className: "absolute inset-0 w-full h-full opacity-0 cursor-text",
|
|
75
|
-
disabled,
|
|
76
|
-
id,
|
|
77
|
-
inputMode: "numeric",
|
|
78
|
-
maxLength: length,
|
|
79
|
-
name,
|
|
80
|
-
onBlur: () => setFocused(false),
|
|
81
|
-
onChange: ({ target }) => {
|
|
82
|
-
const next = codeDigits(target.value, length);
|
|
83
|
-
onChange == null ? void 0 : onChange(next);
|
|
84
|
-
if (next.length === length && next !== digits) onComplete == null ? void 0 : onComplete(next);
|
|
85
|
-
},
|
|
86
|
-
onFocus: () => setFocused(true),
|
|
87
|
-
pattern: "[0-9]*",
|
|
88
|
-
type: "text",
|
|
89
|
-
value: digits
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
]
|
|
54
|
+
// An `id` means a <label htmlFor> names it ( InputGroup's ); only a
|
|
55
|
+
// bare field names itself.
|
|
56
|
+
...!id && {
|
|
57
|
+
"aria-label": "Verification code"
|
|
58
|
+
},
|
|
59
|
+
autoComplete: "one-time-code",
|
|
60
|
+
autoFocus,
|
|
61
|
+
disabled,
|
|
62
|
+
id,
|
|
63
|
+
inputMode: "numeric",
|
|
64
|
+
maxLength: length,
|
|
65
|
+
name,
|
|
66
|
+
onChange: (text) => {
|
|
67
|
+
const next = codeDigits(text, length);
|
|
68
|
+
onChange == null ? void 0 : onChange(next);
|
|
69
|
+
if (next.length === length && next !== digits) onComplete == null ? void 0 : onComplete(next);
|
|
70
|
+
},
|
|
71
|
+
pattern: "[0-9]*",
|
|
72
|
+
style,
|
|
73
|
+
type: "text",
|
|
74
|
+
value: digits
|
|
75
|
+
}
|
|
94
76
|
}
|
|
95
77
|
);
|
|
96
78
|
};
|