@drawbridge/components 0.1.47 → 0.1.48
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/cart-drawer.js +152 -0
- package/dist/bridge/cart-drawer.mjs +123 -0
- package/dist/bridge/fields.js +278 -0
- package/dist/bridge/fields.mjs +276 -1
- package/dist/bridge/form-subdomain-checkout.js +687 -0
- package/dist/bridge/form-subdomain-checkout.mjs +665 -0
- package/dist/bridge/form-subdomain-shop-modal.js +234 -274
- package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
- package/dist/bridge/form-subdomain.js +1 -0
- package/dist/bridge/form-subdomain.mjs +2 -1
- package/dist/bridge/lib/age-gate.js +12 -0
- package/dist/bridge/lib/age-gate.mjs +11 -0
- package/dist/bridge/lib/cart.js +79 -0
- package/dist/bridge/lib/cart.mjs +48 -0
- package/dist/bridge/lib/checkout-kit.js +2 -32
- package/dist/bridge/lib/checkout-kit.mjs +2 -32
- package/dist/bridge/product-tile.js +9 -6
- package/dist/bridge/product-tile.mjs +9 -6
- package/dist/bridge/template-layout.js +237 -122
- package/dist/bridge/template-layout.mjs +237 -122
- package/dist/bridge/template-modal.js +28 -73
- package/dist/bridge/template-modal.mjs +29 -74
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +7 -2
- package/dist/dashboard/campaign-form.mjs +7 -2
- package/dist/dashboard/card-order.js +22 -4
- package/dist/dashboard/card-order.mjs +22 -4
- package/dist/dashboard/embed-stripe.js +145 -0
- package/dist/dashboard/embed-stripe.mjs +116 -0
- package/dist/dashboard/form-admin-provider.js +71 -17
- package/dist/dashboard/form-admin-provider.mjs +71 -17
- package/dist/dashboard/form-file-upload.js +3 -2
- package/dist/dashboard/form-file-upload.mjs +4 -3
- package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
- package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
- package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
- package/dist/dashboard/form-organization-campaign.js +82 -0
- package/dist/dashboard/form-organization-campaign.mjs +81 -0
- package/dist/dashboard/form-organization-connection.js +48 -6
- package/dist/dashboard/form-organization-connection.mjs +48 -7
- package/dist/dashboard/form-organization-product.js +1461 -0
- package/dist/dashboard/form-organization-product.mjs +1425 -0
- package/dist/dashboard/form-organization-workflow.js +72 -1
- package/dist/dashboard/form-organization-workflow.mjs +69 -1
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-stripe.js +12 -5
- package/dist/dashboard/form-stripe.mjs +12 -5
- package/dist/dashboard/input-fields.js +11 -158
- package/dist/dashboard/input-fields.mjs +11 -158
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- package/dist/dashboard/lib/connection-controls.js +5 -2
- package/dist/dashboard/lib/connection-controls.mjs +3 -1
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/products.js +169 -0
- package/dist/dashboard/lib/products.mjs +135 -0
- package/dist/dashboard/lib/settings-paths.js +35 -0
- package/dist/dashboard/lib/settings-paths.mjs +11 -0
- package/dist/dashboard/lib/uppy.js +10 -1
- package/dist/dashboard/lib/uppy.mjs +11 -2
- package/dist/dashboard/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- package/dist/dashboard/shipping-rates.js +404 -0
- package/dist/dashboard/shipping-rates.mjs +371 -0
- package/dist/dashboard/template-buyer.js +301 -0
- package/dist/dashboard/template-buyer.mjs +267 -0
- package/dist/input-checkbox.js +28 -10
- package/dist/input-checkbox.mjs +28 -10
- package/dist/product.js +96 -24
- package/dist/product.mjs +97 -25
- package/dist/shared/lib/helpers.js +54 -6
- package/dist/shared/lib/helpers.mjs +53 -8
- package/dist/shared/order-summary.js +139 -0
- package/dist/shared/order-summary.mjs +110 -0
- package/package.json +74 -4
- package/types/bridge/cart-drawer.d.ts +31 -0
- package/types/bridge/fields.d.ts +14 -2
- package/types/bridge/form-subdomain-checkout.d.ts +20 -0
- package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
- package/types/bridge/lib/age-gate.d.ts +5 -0
- package/types/bridge/lib/cart.d.ts +44 -0
- package/types/bridge/lib/checkout-kit.d.ts +2 -10
- package/types/dashboard/card-order.d.ts +6 -0
- package/types/dashboard/embed-stripe.d.ts +25 -0
- package/types/dashboard/form-admin-provider.d.ts +9 -2
- package/types/dashboard/form-file-upload.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
- package/types/dashboard/form-organization-campaign.d.ts +3 -0
- package/types/dashboard/form-organization-connection.d.ts +11 -0
- package/types/dashboard/form-organization-product.d.ts +24 -0
- package/types/dashboard/form-otc.d.ts +5 -1
- package/types/dashboard/form-stripe.d.ts +3 -2
- package/types/dashboard/input-file.d.ts +2 -0
- package/types/dashboard/input-gallery.d.ts +14 -0
- package/types/dashboard/lib/products.d.ts +14 -0
- package/types/dashboard/lib/settings-paths.d.ts +5 -0
- package/types/dashboard/order-sections.d.ts +24 -1
- package/types/dashboard/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -0
- package/types/input-checkbox.d.ts +2 -0
- package/types/shared/lib/helpers.d.ts +4 -0
- package/types/shared/order-summary.d.ts +19 -0
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
4
|
import { useForm, useWatch } from "react-hook-form";
|
|
5
5
|
import yup, { resolver } from "./lib/yup.mjs";
|
|
6
6
|
import { cdnShopify } from "@drawbridge/drawbridge-utils/cdn";
|
|
7
|
-
import {
|
|
7
|
+
import { money } from "../shared/lib/helpers.mjs";
|
|
8
8
|
import { FormSubdomainHeader } from "./form-subdomain-header.mjs";
|
|
9
9
|
import Image from "next/image";
|
|
10
10
|
import Product from "../product.mjs";
|
|
11
11
|
import Empty from "../shared/empty.mjs";
|
|
12
12
|
import Button from "../shared/button.mjs";
|
|
13
|
-
import Overlay from "../shared/overlay.mjs";
|
|
14
|
-
import Shop from "../icons/shop.mjs";
|
|
15
13
|
import InputGroup from "../input-group.mjs";
|
|
16
14
|
import InputNumber from "../input-number.mjs";
|
|
17
|
-
import { backgroundStyle, headerStyle } from "../styles.mjs";
|
|
18
|
-
import ChevronDown from "../icons/chevron-down.mjs";
|
|
19
|
-
import ChevronUp from "../icons/chevron-up.mjs";
|
|
20
15
|
import Warning from "../icons/warning.mjs";
|
|
16
|
+
import { canCheckout, cartCount, lineNote, recommendedRow } from "./lib/cart.mjs";
|
|
21
17
|
const FormSubdomainProduct = ({
|
|
22
18
|
back,
|
|
23
19
|
button,
|
|
@@ -35,8 +31,12 @@ const FormSubdomainProduct = ({
|
|
|
35
31
|
);
|
|
36
32
|
const [action, setAction] = useState(null);
|
|
37
33
|
const { formState, getValues, setError, clearErrors, setValue, control } = useForm({
|
|
34
|
+
// @story checkout/cart
|
|
35
|
+
// Only a product with one variant starts with it chosen. With more, the
|
|
36
|
+
// buyer chooses, and Add to cart or Buy now before that reads "Please
|
|
37
|
+
// select a variant".
|
|
38
38
|
defaultValues: {
|
|
39
|
-
variant: ((_a = available[0]) == null ? void 0 : _a.id) || ""
|
|
39
|
+
variant: ((product == null ? void 0 : product.variants) || []).length === 1 ? ((_a = available[0]) == null ? void 0 : _a.id) || "" : ""
|
|
40
40
|
},
|
|
41
41
|
resolver: resolver(
|
|
42
42
|
yup.object({
|
|
@@ -47,7 +47,7 @@ const FormSubdomainProduct = ({
|
|
|
47
47
|
const variant = useWatch({ control, name: "variant" });
|
|
48
48
|
const onVariantChange = (value) => {
|
|
49
49
|
setValue("variant", value);
|
|
50
|
-
clearErrors("root");
|
|
50
|
+
clearErrors(value ? ["root", "variant"] : "root");
|
|
51
51
|
};
|
|
52
52
|
const performAction = async (actionType) => {
|
|
53
53
|
var _a2, _b2;
|
|
@@ -129,35 +129,159 @@ const FormSubdomainProduct = ({
|
|
|
129
129
|
}
|
|
130
130
|
);
|
|
131
131
|
};
|
|
132
|
+
const CartItem = ({
|
|
133
|
+
aside,
|
|
134
|
+
children,
|
|
135
|
+
currency,
|
|
136
|
+
image,
|
|
137
|
+
price,
|
|
138
|
+
subtitle,
|
|
139
|
+
title
|
|
140
|
+
}) => /* @__PURE__ */ jsxs(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
...{
|
|
144
|
+
className: "flex items-center space-x-3 text-left"
|
|
145
|
+
},
|
|
146
|
+
children: [
|
|
147
|
+
image && /* @__PURE__ */ jsx(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
...{
|
|
151
|
+
className: "relative w-14 h-14 rounded overflow-hidden shrink-0"
|
|
152
|
+
},
|
|
153
|
+
children: /* @__PURE__ */ jsx(
|
|
154
|
+
Image,
|
|
155
|
+
{
|
|
156
|
+
...{
|
|
157
|
+
alt: title || "",
|
|
158
|
+
className: "object-cover",
|
|
159
|
+
fill: true,
|
|
160
|
+
sizes: "56px",
|
|
161
|
+
// A Shopify picture is resized by Shopify's CDN; ours is already sized.
|
|
162
|
+
src: /cdn\.shopify\.com/.test(image) && cdnShopify(image, "100x100") || image,
|
|
163
|
+
unoptimized: true
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
/* @__PURE__ */ jsxs(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
...{
|
|
173
|
+
className: "flex-1 space-y-0.5 min-w-0"
|
|
174
|
+
},
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ jsx(
|
|
177
|
+
"p",
|
|
178
|
+
{
|
|
179
|
+
...{
|
|
180
|
+
className: "text-sm font-medium leading-tight truncate"
|
|
181
|
+
},
|
|
182
|
+
children: title
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
subtitle && /* @__PURE__ */ jsx(
|
|
186
|
+
"p",
|
|
187
|
+
{
|
|
188
|
+
...{
|
|
189
|
+
className: "text-xs opacity-60"
|
|
190
|
+
},
|
|
191
|
+
children: subtitle
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
Number.isFinite(Number(price)) && price !== null && /* @__PURE__ */ jsx(
|
|
195
|
+
"p",
|
|
196
|
+
{
|
|
197
|
+
...{
|
|
198
|
+
className: "text-xs opacity-60"
|
|
199
|
+
},
|
|
200
|
+
children: money({
|
|
201
|
+
code: currency,
|
|
202
|
+
value: price
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
children
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
aside
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
const CartRecommended = ({
|
|
215
|
+
items = [],
|
|
216
|
+
onOpen,
|
|
217
|
+
style
|
|
218
|
+
}) => items.length > 0 && /* @__PURE__ */ jsxs(
|
|
219
|
+
"div",
|
|
220
|
+
{
|
|
221
|
+
...{
|
|
222
|
+
className: "py-6 space-y-4 border-t border-current"
|
|
223
|
+
},
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ jsx(
|
|
226
|
+
FormSubdomainHeader,
|
|
227
|
+
{
|
|
228
|
+
...{
|
|
229
|
+
style,
|
|
230
|
+
title: "Recommended"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
/* @__PURE__ */ jsx(
|
|
235
|
+
"div",
|
|
236
|
+
{
|
|
237
|
+
...{
|
|
238
|
+
className: "space-y-3"
|
|
239
|
+
},
|
|
240
|
+
children: items.map((product) => /* @__PURE__ */ jsx(
|
|
241
|
+
Button,
|
|
242
|
+
{
|
|
243
|
+
...{
|
|
244
|
+
"aria-label": "Open " + (product.title || "product"),
|
|
245
|
+
onClick: () => onOpen == null ? void 0 : onOpen(product),
|
|
246
|
+
variant: "link"
|
|
247
|
+
},
|
|
248
|
+
children: /* @__PURE__ */ jsx(
|
|
249
|
+
"span",
|
|
250
|
+
{
|
|
251
|
+
...{
|
|
252
|
+
className: "block w-full"
|
|
253
|
+
},
|
|
254
|
+
children: /* @__PURE__ */ jsx(CartItem, { ...recommendedRow(product) })
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
},
|
|
258
|
+
product.id
|
|
259
|
+
))
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
);
|
|
132
265
|
const FormSubdomainCart = ({
|
|
133
266
|
button,
|
|
134
267
|
cart,
|
|
135
|
-
|
|
136
|
-
drawer = true,
|
|
268
|
+
cut = [],
|
|
137
269
|
onLineRemove,
|
|
138
270
|
onLineUpdate,
|
|
271
|
+
onOpenProduct,
|
|
139
272
|
onSuccess,
|
|
140
273
|
style,
|
|
141
274
|
tracking
|
|
142
275
|
}) => {
|
|
143
|
-
const [show, setShow] = useState(false);
|
|
144
|
-
const [updating, setUpdating] = useState(false);
|
|
145
276
|
const [lineErrors, setLineErrors] = useState({});
|
|
146
277
|
const lines = useMemo(() => (cart == null ? void 0 : cart.lines) || [], [cart]);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const lineCount = lines.reduce((sum, line) => sum + (line.quantity || 0), 0);
|
|
151
|
-
const hasSoldOut = lines.some((line) => line.availableForSale === false);
|
|
152
|
-
const canCheckout = Boolean(cart == null ? void 0 : cart.checkoutUrl) && lines.length > 0 && !hasSoldOut;
|
|
153
|
-
const cartTotal = lines.length > 0 ? formatCurrency({
|
|
278
|
+
const lineCount = cartCount(cart);
|
|
279
|
+
const checkoutable = canCheckout(cart);
|
|
280
|
+
const cartTotal = lines.length > 0 ? money({
|
|
154
281
|
code: lines[0].currency,
|
|
155
|
-
display: "parts",
|
|
156
282
|
value: lines.reduce((sum, line) => sum + Number(line.price) * (line.quantity || 0), 0)
|
|
157
283
|
}) : null;
|
|
158
284
|
const wrap = async (lineId, fn) => {
|
|
159
|
-
if (updating) return;
|
|
160
|
-
setUpdating(true);
|
|
161
285
|
setLineErrors((prev) => {
|
|
162
286
|
const next = { ...prev };
|
|
163
287
|
delete next[lineId];
|
|
@@ -170,11 +294,9 @@ const FormSubdomainCart = ({
|
|
|
170
294
|
...prev,
|
|
171
295
|
[lineId]: (error == null ? void 0 : error.message) || "Could not update line"
|
|
172
296
|
}));
|
|
173
|
-
} finally {
|
|
174
|
-
setUpdating(false);
|
|
175
297
|
}
|
|
176
298
|
};
|
|
177
|
-
const handleQuantity = (line, next) => wrap(line.id, () => {
|
|
299
|
+
const handleQuantity = (line, next) => next === null || next === void 0 || next === "" || Number.isNaN(Number(next)) ? void 0 : wrap(line.id, () => {
|
|
178
300
|
var _a, _b;
|
|
179
301
|
if (next <= 0) {
|
|
180
302
|
const productSlug = (_a = line.productTitle) == null ? void 0 : _a.toLowerCase().replace(/\s+/g, "-");
|
|
@@ -192,7 +314,7 @@ const FormSubdomainCart = ({
|
|
|
192
314
|
return onLineUpdate(line.id, next);
|
|
193
315
|
});
|
|
194
316
|
const handleCheckout = () => {
|
|
195
|
-
if (!
|
|
317
|
+
if (!checkoutable) return;
|
|
196
318
|
onSuccess({
|
|
197
319
|
result: cart
|
|
198
320
|
});
|
|
@@ -222,115 +344,26 @@ const FormSubdomainCart = ({
|
|
|
222
344
|
},
|
|
223
345
|
children: lines.map((line) => {
|
|
224
346
|
var _a, _b, _c, _d, _e;
|
|
347
|
+
const note = lineNote(line, cut);
|
|
225
348
|
return /* @__PURE__ */ jsx(
|
|
226
349
|
InputGroup,
|
|
227
350
|
{
|
|
228
351
|
...{
|
|
229
352
|
className: "py-6",
|
|
230
353
|
error: lineErrors[line.id],
|
|
231
|
-
input: /* @__PURE__ */
|
|
232
|
-
|
|
354
|
+
input: /* @__PURE__ */ jsx(
|
|
355
|
+
CartItem,
|
|
233
356
|
{
|
|
234
357
|
...{
|
|
235
|
-
|
|
236
|
-
},
|
|
237
|
-
children: [
|
|
238
|
-
line.image && /* @__PURE__ */ jsx(
|
|
239
|
-
"div",
|
|
240
|
-
{
|
|
241
|
-
...{
|
|
242
|
-
className: "relative w-14 h-14 rounded overflow-hidden shrink-0"
|
|
243
|
-
},
|
|
244
|
-
children: /* @__PURE__ */ jsx(
|
|
245
|
-
Image,
|
|
246
|
-
{
|
|
247
|
-
...{
|
|
248
|
-
alt: line.productTitle || "",
|
|
249
|
-
className: "object-cover",
|
|
250
|
-
fill: true,
|
|
251
|
-
sizes: "56px",
|
|
252
|
-
src: cdnShopify(line.image, "100x100") || line.image,
|
|
253
|
-
unoptimized: true
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
)
|
|
257
|
-
}
|
|
258
|
-
),
|
|
259
|
-
/* @__PURE__ */ jsxs(
|
|
260
|
-
"div",
|
|
261
|
-
{
|
|
262
|
-
...{
|
|
263
|
-
className: "flex-1 space-y-0.5 min-w-0"
|
|
264
|
-
},
|
|
265
|
-
children: [
|
|
266
|
-
/* @__PURE__ */ jsx(
|
|
267
|
-
"p",
|
|
268
|
-
{
|
|
269
|
-
...{
|
|
270
|
-
className: "text-sm font-medium leading-tight truncate"
|
|
271
|
-
},
|
|
272
|
-
children: line.productTitle
|
|
273
|
-
}
|
|
274
|
-
),
|
|
275
|
-
line.variantTitle && line.variantTitle !== "Default Title" && /* @__PURE__ */ jsx(
|
|
276
|
-
"p",
|
|
277
|
-
{
|
|
278
|
-
...{
|
|
279
|
-
className: "text-xs opacity-60"
|
|
280
|
-
},
|
|
281
|
-
children: line.variantTitle
|
|
282
|
-
}
|
|
283
|
-
),
|
|
284
|
-
line.price && /* @__PURE__ */ jsx(
|
|
285
|
-
"p",
|
|
286
|
-
{
|
|
287
|
-
...{
|
|
288
|
-
className: "text-xs opacity-60"
|
|
289
|
-
},
|
|
290
|
-
children: formatCurrency({
|
|
291
|
-
code: line.currency,
|
|
292
|
-
display: "parts",
|
|
293
|
-
value: line.price
|
|
294
|
-
})
|
|
295
|
-
}
|
|
296
|
-
),
|
|
297
|
-
line.availableForSale === false && /* @__PURE__ */ jsxs(
|
|
298
|
-
"p",
|
|
299
|
-
{
|
|
300
|
-
...{
|
|
301
|
-
className: "flex items-center justify-start space-x-2 py-1 px-1.5 rounded text-sm",
|
|
302
|
-
...Object.keys(style || {}).length > 0 && {
|
|
303
|
-
style: {
|
|
304
|
-
backgroundColor: (_c = (_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb) == null ? void 0 : _c.replace(")", ",.1)"),
|
|
305
|
-
color: (_e = (_d = style == null ? void 0 : style.text) == null ? void 0 : _d.color) == null ? void 0 : _e.rgb
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
children: [
|
|
310
|
-
/* @__PURE__ */ jsx(
|
|
311
|
-
Warning,
|
|
312
|
-
{
|
|
313
|
-
...{
|
|
314
|
-
className: "w-4 h-4",
|
|
315
|
-
"aria-hidden": true
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
),
|
|
319
|
-
/* @__PURE__ */ jsx("span", { children: "Sold out" })
|
|
320
|
-
]
|
|
321
|
-
}
|
|
322
|
-
)
|
|
323
|
-
]
|
|
324
|
-
}
|
|
325
|
-
),
|
|
326
|
-
/* @__PURE__ */ jsx(
|
|
358
|
+
aside: /* @__PURE__ */ jsx(
|
|
327
359
|
InputNumber,
|
|
328
360
|
{
|
|
329
361
|
...{
|
|
330
362
|
"aria-label": "Quantity",
|
|
331
|
-
disabled: updating,
|
|
332
363
|
inline: true,
|
|
333
364
|
layout: "split",
|
|
365
|
+
// The api's most of one item ( lib/cart.js MAX_QUANTITY ).
|
|
366
|
+
max: 99,
|
|
334
367
|
min: 0,
|
|
335
368
|
onChange: (value) => handleQuantity(line, value),
|
|
336
369
|
small: true,
|
|
@@ -338,8 +371,39 @@ const FormSubdomainCart = ({
|
|
|
338
371
|
value: line.quantity
|
|
339
372
|
}
|
|
340
373
|
}
|
|
341
|
-
)
|
|
342
|
-
|
|
374
|
+
),
|
|
375
|
+
currency: line.currency,
|
|
376
|
+
image: line.image,
|
|
377
|
+
price: line.price || null,
|
|
378
|
+
subtitle: line.variantTitle !== "Default Title" ? line.variantTitle : null,
|
|
379
|
+
title: line.productTitle
|
|
380
|
+
},
|
|
381
|
+
children: note && /* @__PURE__ */ jsxs(
|
|
382
|
+
"p",
|
|
383
|
+
{
|
|
384
|
+
...{
|
|
385
|
+
className: "flex items-center justify-start space-x-2 py-1 px-1.5 rounded text-sm",
|
|
386
|
+
...Object.keys(style || {}).length > 0 && {
|
|
387
|
+
style: {
|
|
388
|
+
backgroundColor: (_c = (_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb) == null ? void 0 : _c.replace(")", ",.1)"),
|
|
389
|
+
color: (_e = (_d = style == null ? void 0 : style.text) == null ? void 0 : _d.color) == null ? void 0 : _e.rgb
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
children: [
|
|
394
|
+
/* @__PURE__ */ jsx(
|
|
395
|
+
Warning,
|
|
396
|
+
{
|
|
397
|
+
...{
|
|
398
|
+
className: "w-4 h-4",
|
|
399
|
+
"aria-hidden": true
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
),
|
|
403
|
+
/* @__PURE__ */ jsx("span", { children: note })
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
)
|
|
343
407
|
}
|
|
344
408
|
),
|
|
345
409
|
style
|
|
@@ -350,156 +414,6 @@ const FormSubdomainCart = ({
|
|
|
350
414
|
})
|
|
351
415
|
}
|
|
352
416
|
);
|
|
353
|
-
const footer = lines.length > 0 && /* @__PURE__ */ jsxs(
|
|
354
|
-
"div",
|
|
355
|
-
{
|
|
356
|
-
...{
|
|
357
|
-
className: "space-y-4"
|
|
358
|
-
},
|
|
359
|
-
children: [
|
|
360
|
-
cartTotal && /* @__PURE__ */ jsxs(
|
|
361
|
-
"div",
|
|
362
|
-
{
|
|
363
|
-
...{
|
|
364
|
-
className: "flex items-center justify-between text-sm"
|
|
365
|
-
},
|
|
366
|
-
children: [
|
|
367
|
-
/* @__PURE__ */ jsx("span", { children: "SUBTOTAL" }),
|
|
368
|
-
/* @__PURE__ */ jsx("span", { children: cartTotal })
|
|
369
|
-
]
|
|
370
|
-
}
|
|
371
|
-
),
|
|
372
|
-
/* @__PURE__ */ jsx(
|
|
373
|
-
Button,
|
|
374
|
-
{
|
|
375
|
-
...{
|
|
376
|
-
disabled: !canCheckout,
|
|
377
|
-
loading: updating,
|
|
378
|
-
onClick: handleCheckout,
|
|
379
|
-
style
|
|
380
|
-
},
|
|
381
|
-
children: "Checkout"
|
|
382
|
-
}
|
|
383
|
-
)
|
|
384
|
-
]
|
|
385
|
-
}
|
|
386
|
-
);
|
|
387
|
-
if (children && !drawer) {
|
|
388
|
-
return children(setShow);
|
|
389
|
-
}
|
|
390
|
-
;
|
|
391
|
-
if (children) {
|
|
392
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
393
|
-
/* @__PURE__ */ jsx(
|
|
394
|
-
"div",
|
|
395
|
-
{
|
|
396
|
-
...{
|
|
397
|
-
className: "transition ease-in-out" + (show ? " blur-[8px]" : " pb-10")
|
|
398
|
-
},
|
|
399
|
-
children: children(setShow)
|
|
400
|
-
}
|
|
401
|
-
),
|
|
402
|
-
/* @__PURE__ */ jsx(
|
|
403
|
-
Overlay,
|
|
404
|
-
{
|
|
405
|
-
...{
|
|
406
|
-
className: "z-10 absolute inset-0",
|
|
407
|
-
onClick: () => setShow(false),
|
|
408
|
-
show,
|
|
409
|
-
style
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
),
|
|
413
|
-
/* @__PURE__ */ jsxs(
|
|
414
|
-
"div",
|
|
415
|
-
{
|
|
416
|
-
...{
|
|
417
|
-
className: "z-20 absolute bottom-0 left-0 w-full max-h-full flex flex-col transition-transform duration-300 ease-out " + (show ? "translate-y-0 rounded-t-xl" : "translate-y-[calc(100%-60px)]"),
|
|
418
|
-
style: backgroundStyle(style)
|
|
419
|
-
},
|
|
420
|
-
children: [
|
|
421
|
-
/* @__PURE__ */ jsx(
|
|
422
|
-
Button,
|
|
423
|
-
{
|
|
424
|
-
...{
|
|
425
|
-
onClick: () => setShow(!show),
|
|
426
|
-
variant: "link"
|
|
427
|
-
},
|
|
428
|
-
children: /* @__PURE__ */ jsxs(
|
|
429
|
-
"span",
|
|
430
|
-
{
|
|
431
|
-
...{
|
|
432
|
-
className: "flex px-6 w-full items-center justify-between " + (show ? "pt-6" : "border-t border-current py-[17px]"),
|
|
433
|
-
style: headerStyle(style)
|
|
434
|
-
},
|
|
435
|
-
children: [
|
|
436
|
-
/* @__PURE__ */ jsxs(
|
|
437
|
-
"span",
|
|
438
|
-
{
|
|
439
|
-
...{
|
|
440
|
-
className: "flex items-center space-x-2"
|
|
441
|
-
},
|
|
442
|
-
children: [
|
|
443
|
-
/* @__PURE__ */ jsx(
|
|
444
|
-
Shop,
|
|
445
|
-
{
|
|
446
|
-
...{
|
|
447
|
-
className: "w-5 h-5"
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
),
|
|
451
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
452
|
-
"Cart ",
|
|
453
|
-
"(" + lineCount + ")",
|
|
454
|
-
" "
|
|
455
|
-
] })
|
|
456
|
-
]
|
|
457
|
-
}
|
|
458
|
-
),
|
|
459
|
-
show ? /* @__PURE__ */ jsx(
|
|
460
|
-
ChevronDown,
|
|
461
|
-
{
|
|
462
|
-
...{
|
|
463
|
-
className: "w-5 h-5"
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
) : /* @__PURE__ */ jsx(
|
|
467
|
-
ChevronUp,
|
|
468
|
-
{
|
|
469
|
-
...{
|
|
470
|
-
className: "w-5 h-5"
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
)
|
|
474
|
-
]
|
|
475
|
-
}
|
|
476
|
-
)
|
|
477
|
-
}
|
|
478
|
-
),
|
|
479
|
-
/* @__PURE__ */ jsx(
|
|
480
|
-
"div",
|
|
481
|
-
{
|
|
482
|
-
...{
|
|
483
|
-
className: "flex-1 overflow-y-auto px-6" + (lines.length === 0 ? " pb-6" : "")
|
|
484
|
-
},
|
|
485
|
-
children: items
|
|
486
|
-
}
|
|
487
|
-
),
|
|
488
|
-
lines.length > 0 && /* @__PURE__ */ jsx(
|
|
489
|
-
"div",
|
|
490
|
-
{
|
|
491
|
-
...{
|
|
492
|
-
className: "shrink-0 px-6 pb-6"
|
|
493
|
-
},
|
|
494
|
-
children: footer
|
|
495
|
-
}
|
|
496
|
-
)
|
|
497
|
-
]
|
|
498
|
-
}
|
|
499
|
-
)
|
|
500
|
-
] });
|
|
501
|
-
}
|
|
502
|
-
;
|
|
503
417
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
504
418
|
/* @__PURE__ */ jsx(
|
|
505
419
|
FormSubdomainHeader,
|
|
@@ -519,13 +433,57 @@ const FormSubdomainCart = ({
|
|
|
519
433
|
},
|
|
520
434
|
children: [
|
|
521
435
|
items,
|
|
522
|
-
|
|
436
|
+
/* @__PURE__ */ jsx(
|
|
437
|
+
CartRecommended,
|
|
438
|
+
{
|
|
439
|
+
...{
|
|
440
|
+
items: (cart == null ? void 0 : cart.recommended) || [],
|
|
441
|
+
onOpen: onOpenProduct,
|
|
442
|
+
style
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
),
|
|
446
|
+
lines.length > 0 && /* @__PURE__ */ jsxs(
|
|
447
|
+
"div",
|
|
448
|
+
{
|
|
449
|
+
...{
|
|
450
|
+
className: "space-y-4"
|
|
451
|
+
},
|
|
452
|
+
children: [
|
|
453
|
+
cartTotal && /* @__PURE__ */ jsxs(
|
|
454
|
+
"div",
|
|
455
|
+
{
|
|
456
|
+
...{
|
|
457
|
+
className: "flex items-center justify-between text-sm"
|
|
458
|
+
},
|
|
459
|
+
children: [
|
|
460
|
+
/* @__PURE__ */ jsx("span", { children: "SUBTOTAL" }),
|
|
461
|
+
/* @__PURE__ */ jsx("span", { children: cartTotal })
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
),
|
|
465
|
+
/* @__PURE__ */ jsx(
|
|
466
|
+
Button,
|
|
467
|
+
{
|
|
468
|
+
...{
|
|
469
|
+
disabled: !checkoutable,
|
|
470
|
+
onClick: handleCheckout,
|
|
471
|
+
style
|
|
472
|
+
},
|
|
473
|
+
children: "Checkout"
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
]
|
|
477
|
+
}
|
|
478
|
+
)
|
|
523
479
|
]
|
|
524
480
|
}
|
|
525
481
|
)
|
|
526
482
|
] });
|
|
527
483
|
};
|
|
528
484
|
export {
|
|
485
|
+
CartItem,
|
|
486
|
+
CartRecommended,
|
|
529
487
|
FormSubdomainCart,
|
|
530
488
|
FormSubdomainProduct
|
|
531
489
|
};
|
|
@@ -1369,6 +1369,7 @@ const FormSubdomain = ({
|
|
|
1369
1369
|
callback: (object) => {
|
|
1370
1370
|
setData({
|
|
1371
1371
|
...data,
|
|
1372
|
+
fields: (0, import_age_gate.ageBirthday)(fields, data.fields, object == null ? void 0 : object.birthday),
|
|
1372
1373
|
integrations: {
|
|
1373
1374
|
...data.integrations,
|
|
1374
1375
|
...object
|
|
@@ -10,7 +10,7 @@ import { ordersItems } from "@drawbridge/drawbridge-utils/fields-validate";
|
|
|
10
10
|
import { captureException } from "@drawbridge/drawbridge-telemetry/nextjs";
|
|
11
11
|
import { useForm, useWatch, Controller } from "react-hook-form";
|
|
12
12
|
import yup, { resolver } from "./lib/yup.mjs";
|
|
13
|
-
import { ageFor, ageGateSchema } from "./lib/age-gate.mjs";
|
|
13
|
+
import { ageBirthday, ageFor, ageGateSchema } from "./lib/age-gate.mjs";
|
|
14
14
|
import { useGoogleReCaptcha } from "react-google-recaptcha-v3";
|
|
15
15
|
import { assertRecaptcha } from "./lib/recaptcha.mjs";
|
|
16
16
|
import { submissionEndpoint } from "./lib/url.mjs";
|
|
@@ -1332,6 +1332,7 @@ const FormSubdomain = ({
|
|
|
1332
1332
|
callback: (object) => {
|
|
1333
1333
|
setData({
|
|
1334
1334
|
...data,
|
|
1335
|
+
fields: ageBirthday(fields, data.fields, object == null ? void 0 : object.birthday),
|
|
1335
1336
|
integrations: {
|
|
1336
1337
|
...data.integrations,
|
|
1337
1338
|
...object
|
|
@@ -27,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var age_gate_exports = {};
|
|
29
29
|
__export(age_gate_exports, {
|
|
30
|
+
ageBirthday: () => ageBirthday,
|
|
30
31
|
ageFor: () => ageFor,
|
|
31
32
|
ageGateSchema: () => ageGateSchema
|
|
32
33
|
});
|
|
@@ -48,8 +49,19 @@ const ageGateSchema = (values, currentYear = (/* @__PURE__ */ new Date()).getFul
|
|
|
48
49
|
})
|
|
49
50
|
});
|
|
50
51
|
};
|
|
52
|
+
const ageBirthday = (fields, answers = {}, birthday) => {
|
|
53
|
+
const sections = Array.isArray(fields == null ? void 0 : fields.sections) ? fields.sections : [];
|
|
54
|
+
const field = sections.flatMap((section) => (section == null ? void 0 : section.fields) || []).find((item) => (item == null ? void 0 : item.slug) === "birthday");
|
|
55
|
+
const [month, day, year] = typeof birthday === "string" ? birthday.split("/") : [];
|
|
56
|
+
if (!(field == null ? void 0 : field.id) || (answers == null ? void 0 : answers[field.id]) || !(month && day && year)) return answers;
|
|
57
|
+
return {
|
|
58
|
+
...answers,
|
|
59
|
+
[field.id]: [year, month.padStart(2, "0"), day.padStart(2, "0")].join("-")
|
|
60
|
+
};
|
|
61
|
+
};
|
|
51
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
63
|
0 && (module.exports = {
|
|
64
|
+
ageBirthday,
|
|
53
65
|
ageFor,
|
|
54
66
|
ageGateSchema
|
|
55
67
|
});
|
|
@@ -15,7 +15,18 @@ const ageGateSchema = (values, currentYear = (/* @__PURE__ */ new Date()).getFul
|
|
|
15
15
|
})
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
|
+
const ageBirthday = (fields, answers = {}, birthday) => {
|
|
19
|
+
const sections = Array.isArray(fields == null ? void 0 : fields.sections) ? fields.sections : [];
|
|
20
|
+
const field = sections.flatMap((section) => (section == null ? void 0 : section.fields) || []).find((item) => (item == null ? void 0 : item.slug) === "birthday");
|
|
21
|
+
const [month, day, year] = typeof birthday === "string" ? birthday.split("/") : [];
|
|
22
|
+
if (!(field == null ? void 0 : field.id) || (answers == null ? void 0 : answers[field.id]) || !(month && day && year)) return answers;
|
|
23
|
+
return {
|
|
24
|
+
...answers,
|
|
25
|
+
[field.id]: [year, month.padStart(2, "0"), day.padStart(2, "0")].join("-")
|
|
26
|
+
};
|
|
27
|
+
};
|
|
18
28
|
export {
|
|
29
|
+
ageBirthday,
|
|
19
30
|
ageFor,
|
|
20
31
|
ageGateSchema
|
|
21
32
|
};
|