@drawbridge/components 0.1.46 → 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-shop.js +4 -1
- package/dist/bridge/form-subdomain-shop.mjs +4 -1
- package/dist/bridge/form-subdomain.js +24 -5
- package/dist/bridge/form-subdomain.mjs +25 -6
- 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/lib/entry.js +41 -0
- package/dist/bridge/lib/entry.mjs +40 -0
- package/dist/bridge/product-tile.js +13 -6
- package/dist/bridge/product-tile.mjs +13 -6
- package/dist/bridge/template-layout.js +263 -129
- package/dist/bridge/template-layout.mjs +264 -130
- package/dist/bridge/template-modal.js +39 -74
- package/dist/bridge/template-modal.mjs +40 -75
- package/dist/dashboard/avatar.js +2 -3
- package/dist/dashboard/avatar.mjs +2 -3
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +179 -155
- package/dist/dashboard/campaign-form.mjs +179 -155
- package/dist/dashboard/campaign-share.js +347 -0
- package/dist/dashboard/campaign-share.mjs +314 -0
- package/dist/dashboard/card-affiliate.js +1 -1
- package/dist/dashboard/card-affiliate.mjs +1 -1
- package/dist/dashboard/card-campaign-switch.js +4 -1
- package/dist/dashboard/card-campaign-switch.mjs +4 -1
- 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-page.js +73 -39
- package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
- 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-combobox.js +6 -0
- package/dist/dashboard/input-combobox.mjs +6 -0
- package/dist/dashboard/input-fields.js +37 -161
- package/dist/dashboard/input-fields.mjs +37 -161
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-font.js +2 -0
- package/dist/dashboard/input-font.mjs +2 -0
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- package/dist/dashboard/input-group-ai.js +15 -3
- package/dist/dashboard/input-group-ai.mjs +15 -3
- package/dist/dashboard/lib/ab-tests.js +2 -2
- package/dist/dashboard/lib/ab-tests.mjs +2 -2
- 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/menu.js +19 -0
- package/dist/dashboard/lib/menu.mjs +18 -0
- 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/menu.js +13 -2
- package/dist/dashboard/menu.mjs +13 -2
- package/dist/dashboard/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/preview.js +119 -52
- package/dist/dashboard/preview.mjs +119 -52
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- package/dist/dashboard/recharts.js +10 -4
- package/dist/dashboard/recharts.mjs +10 -4
- 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/dashboard/template-dashboard.js +11 -1
- package/dist/dashboard/template-dashboard.mjs +11 -1
- package/dist/dashboard/template-design.js +209 -130
- package/dist/dashboard/template-design.mjs +210 -131
- package/dist/dashboard/template-ui.js +157 -55
- package/dist/dashboard/template-ui.mjs +158 -56
- package/dist/icons/flags.js +134 -0
- package/dist/icons/flags.mjs +115 -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/carousel.js +14 -5
- package/dist/shared/carousel.mjs +14 -5
- 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 +84 -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/form-subdomain.d.ts +13 -0
- 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/bridge/lib/entry.d.ts +5 -0
- package/types/bridge/product-tile.d.ts +2 -0
- package/types/dashboard/campaign-share.d.ts +16 -0
- 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-page.d.ts +8 -1
- 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-combobox.d.ts +2 -0
- 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/preview.d.ts +11 -3
- package/types/dashboard/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -0
- package/types/icons/flags.d.ts +5 -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
package/dist/product.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
import useEmblaCarousel from "embla-carousel-react";
|
|
5
|
-
import { cdnShopify } from "@drawbridge/drawbridge-utils/cdn";
|
|
6
|
-
import {
|
|
5
|
+
import { cdnShopify, cdnSrc } from "@drawbridge/drawbridge-utils/cdn";
|
|
6
|
+
import { money } from "./shared/lib/helpers.mjs";
|
|
7
7
|
import InputGroup from "./input-group.mjs";
|
|
8
8
|
import InputSelect from "./input-select.mjs";
|
|
9
9
|
import WrapperGradient from "./wrapper-gradient.mjs";
|
|
@@ -58,26 +58,43 @@ const Product = ({
|
|
|
58
58
|
);
|
|
59
59
|
const [activeImage, setActiveImage] = useState(0);
|
|
60
60
|
const [emblaRef, emblaApi] = useEmblaCarousel();
|
|
61
|
-
const
|
|
61
|
+
const chosen = available.find((v) => v.id === variant) || null;
|
|
62
|
+
const selectedVariant = chosen || available[0] || null;
|
|
63
|
+
const [picked, setPicked] = useState([]);
|
|
62
64
|
const images = useMemo(
|
|
63
65
|
() => {
|
|
66
|
+
var _a2;
|
|
64
67
|
const variants = ((product == null ? void 0 : product.variants) || []).filter((v) => v.availableForSale);
|
|
65
68
|
const result = [];
|
|
66
69
|
const seen = /* @__PURE__ */ new Set();
|
|
67
|
-
|
|
70
|
+
const remote = (url, variant2 = null) => ({
|
|
71
|
+
src: cdnShopify(url, "400x400", product == null ? void 0 : product.updatedAt) || url,
|
|
72
|
+
thumb: cdnShopify(url, "100x100", product == null ? void 0 : product.updatedAt) || url,
|
|
73
|
+
url,
|
|
74
|
+
variant: variant2
|
|
75
|
+
});
|
|
76
|
+
for (const item of (product == null ? void 0 : product.images) || []) {
|
|
77
|
+
if ((item == null ? void 0 : item.url) && !seen.has(item.url)) {
|
|
78
|
+
seen.add(item.url);
|
|
79
|
+
result.push(remote(item.url));
|
|
80
|
+
} else if ((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.sizes) {
|
|
81
|
+
const src = cdnSrc(item.file, "400x400", item.file.updatedAt) || cdnSrc(item.file, "original", item.file.updatedAt);
|
|
82
|
+
if (src) result.push({
|
|
83
|
+
src,
|
|
84
|
+
thumb: cdnSrc(item.file, "100x100", item.file.updatedAt) || src,
|
|
85
|
+
url: item.file.id,
|
|
86
|
+
variant: null
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!result.length && (product == null ? void 0 : product.image)) {
|
|
68
91
|
seen.add(product.image);
|
|
69
|
-
result.push(
|
|
70
|
-
src: product.image,
|
|
71
|
-
variant: null
|
|
72
|
-
});
|
|
92
|
+
result.push(remote(product.image));
|
|
73
93
|
}
|
|
74
94
|
for (const v of variants) {
|
|
75
95
|
if (v.image && !seen.has(v.image)) {
|
|
76
96
|
seen.add(v.image);
|
|
77
|
-
result.push(
|
|
78
|
-
src: v.image,
|
|
79
|
-
variant: v
|
|
80
|
-
});
|
|
97
|
+
result.push(remote(v.image, v));
|
|
81
98
|
}
|
|
82
99
|
}
|
|
83
100
|
return result;
|
|
@@ -102,13 +119,25 @@ const Product = ({
|
|
|
102
119
|
onVariantChange(value);
|
|
103
120
|
const v = available.find((x) => x.id === value);
|
|
104
121
|
if (!(v == null ? void 0 : v.image)) return;
|
|
105
|
-
const idx = images.findIndex((img) => img.
|
|
122
|
+
const idx = images.findIndex((img) => img.url === v.image);
|
|
106
123
|
if (idx >= 0) {
|
|
107
124
|
setActiveImage(idx);
|
|
108
125
|
emblaApi == null ? void 0 : emblaApi.scrollTo(idx);
|
|
109
126
|
}
|
|
110
127
|
;
|
|
111
128
|
};
|
|
129
|
+
const options = ((product == null ? void 0 : product.options) || []).filter(() => available.every((v) => (v.selectedOptions || []).length));
|
|
130
|
+
const values = chosen ? (chosen.selectedOptions || []).map((item) => item == null ? void 0 : item.value) : picked;
|
|
131
|
+
const pickOption = (index, value) => {
|
|
132
|
+
const wanted = options.map((item, key) => key === index ? value : values[key]);
|
|
133
|
+
setPicked(wanted);
|
|
134
|
+
if (wanted.some((item) => !item)) return onVariantChange("");
|
|
135
|
+
const match = available.find((v) => (v.selectedOptions || []).every((item, key) => (item == null ? void 0 : item.value) === wanted[key])) || available.find((v) => {
|
|
136
|
+
var _a2, _b2;
|
|
137
|
+
return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
|
|
138
|
+
});
|
|
139
|
+
if (match) handleVariant(match.id);
|
|
140
|
+
};
|
|
112
141
|
return /* @__PURE__ */ jsxs(
|
|
113
142
|
"div",
|
|
114
143
|
{
|
|
@@ -138,7 +167,7 @@ const Product = ({
|
|
|
138
167
|
classNameScroll: "flex flex-col w-12 h-48 space-y-3",
|
|
139
168
|
color: resolved.background.color.rgb
|
|
140
169
|
},
|
|
141
|
-
children: images.map(({
|
|
170
|
+
children: images.map(({ thumb }, key) => /* @__PURE__ */ jsx(
|
|
142
171
|
Button,
|
|
143
172
|
{
|
|
144
173
|
...{
|
|
@@ -167,7 +196,7 @@ const Product = ({
|
|
|
167
196
|
className: "object-cover",
|
|
168
197
|
fill: true,
|
|
169
198
|
sizes: "48px",
|
|
170
|
-
src:
|
|
199
|
+
src: thumb,
|
|
171
200
|
// Always set opacity + transition so switching the active
|
|
172
201
|
// thumbnail animates the fade in both directions.
|
|
173
202
|
style: {
|
|
@@ -228,7 +257,7 @@ const Product = ({
|
|
|
228
257
|
className: "object-cover",
|
|
229
258
|
fill: true,
|
|
230
259
|
sizes: "192px",
|
|
231
|
-
src
|
|
260
|
+
src,
|
|
232
261
|
unoptimized: true
|
|
233
262
|
}
|
|
234
263
|
}
|
|
@@ -260,11 +289,24 @@ const Product = ({
|
|
|
260
289
|
children: product == null ? void 0 : product.title
|
|
261
290
|
}
|
|
262
291
|
),
|
|
263
|
-
!available.length ? /* @__PURE__ */ jsx("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
292
|
+
!available.length ? /* @__PURE__ */ jsx("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ jsxs("p", { children: [
|
|
293
|
+
money({
|
|
294
|
+
code: selectedVariant.currency,
|
|
295
|
+
value: selectedVariant.price
|
|
296
|
+
}),
|
|
297
|
+
selectedVariant.sale > selectedVariant.price && /* @__PURE__ */ jsx(
|
|
298
|
+
"s",
|
|
299
|
+
{
|
|
300
|
+
...{
|
|
301
|
+
className: "ml-2 opacity-60"
|
|
302
|
+
},
|
|
303
|
+
children: money({
|
|
304
|
+
code: selectedVariant.currency,
|
|
305
|
+
value: selectedVariant.sale
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
)
|
|
309
|
+
] }),
|
|
268
310
|
(product == null ? void 0 : product.description) && /* @__PURE__ */ jsx(
|
|
269
311
|
WrapperGradient,
|
|
270
312
|
{
|
|
@@ -278,7 +320,37 @@ const Product = ({
|
|
|
278
320
|
]
|
|
279
321
|
}
|
|
280
322
|
),
|
|
281
|
-
available.length >
|
|
323
|
+
options.length > 0 && available.length > 0 && options.map((option, index) => /* @__PURE__ */ jsx(
|
|
324
|
+
InputGroup,
|
|
325
|
+
{
|
|
326
|
+
...{
|
|
327
|
+
error: index === options.length - 1 ? errors == null ? void 0 : errors.variant : null,
|
|
328
|
+
input: /* @__PURE__ */ jsx(
|
|
329
|
+
InputSelect,
|
|
330
|
+
{
|
|
331
|
+
...{
|
|
332
|
+
"aria-label": option.name,
|
|
333
|
+
disabled,
|
|
334
|
+
onChange: (value) => pickOption(index, value),
|
|
335
|
+
options: option.values.filter((value) => available.some((v) => {
|
|
336
|
+
var _a2, _b2;
|
|
337
|
+
return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
|
|
338
|
+
})).map((value) => ({
|
|
339
|
+
label: value,
|
|
340
|
+
value
|
|
341
|
+
})),
|
|
342
|
+
style: resolved,
|
|
343
|
+
value: values[index] || ""
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
),
|
|
347
|
+
label: option.name,
|
|
348
|
+
style: resolved
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
"option-" + option.name
|
|
352
|
+
)),
|
|
353
|
+
!options.length && available.length > 1 && /* @__PURE__ */ jsx(
|
|
282
354
|
InputGroup,
|
|
283
355
|
{
|
|
284
356
|
...{
|
|
@@ -302,7 +374,7 @@ const Product = ({
|
|
|
302
374
|
}
|
|
303
375
|
}
|
|
304
376
|
),
|
|
305
|
-
|
|
377
|
+
/* @__PURE__ */ jsx(
|
|
306
378
|
InputGroup,
|
|
307
379
|
{
|
|
308
380
|
...{
|
|
@@ -324,7 +396,7 @@ const Product = ({
|
|
|
324
396
|
Button,
|
|
325
397
|
{
|
|
326
398
|
...{
|
|
327
|
-
disabled: disabled || Boolean(action),
|
|
399
|
+
disabled: disabled || Boolean(action) || !available.length,
|
|
328
400
|
onClick: onAdd,
|
|
329
401
|
variant: "link"
|
|
330
402
|
},
|
|
@@ -354,7 +426,7 @@ const Product = ({
|
|
|
354
426
|
Button,
|
|
355
427
|
{
|
|
356
428
|
...{
|
|
357
|
-
disabled: disabled || Boolean(action),
|
|
429
|
+
disabled: disabled || Boolean(action) || !available.length,
|
|
358
430
|
loading: action === "buy",
|
|
359
431
|
onClick: onBuy,
|
|
360
432
|
style: resolved
|
package/dist/shared/carousel.js
CHANGED
|
@@ -140,7 +140,8 @@ const Carousel = ({
|
|
|
140
140
|
{
|
|
141
141
|
...{
|
|
142
142
|
className: [
|
|
143
|
-
|
|
143
|
+
// Each dot sits in a 24 px target, edge to edge ( WCAG 2.5.8; Darren, 2026-11-21 ).
|
|
144
|
+
"flex items-center",
|
|
144
145
|
justifies[dots.justify] || justifies.center,
|
|
145
146
|
dots.overlay ? "absolute inset-x-3 bottom-3" : "mt-4 py-3"
|
|
146
147
|
].join(" ")
|
|
@@ -160,11 +161,19 @@ const Carousel = ({
|
|
|
160
161
|
"span",
|
|
161
162
|
{
|
|
162
163
|
...{
|
|
163
|
-
className: "
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
className: "flex items-center justify-center w-6 h-6"
|
|
165
|
+
},
|
|
166
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
|
+
"span",
|
|
168
|
+
{
|
|
169
|
+
...{
|
|
170
|
+
className: "block w-3 h-3 rounded-full border" + (style ? "" : " bg-black border-white"),
|
|
171
|
+
...style && {
|
|
172
|
+
style: (0, import_styles.dotStyle)(style, index === key)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
166
175
|
}
|
|
167
|
-
|
|
176
|
+
)
|
|
168
177
|
}
|
|
169
178
|
)
|
|
170
179
|
},
|
package/dist/shared/carousel.mjs
CHANGED
|
@@ -108,7 +108,8 @@ const Carousel = ({
|
|
|
108
108
|
{
|
|
109
109
|
...{
|
|
110
110
|
className: [
|
|
111
|
-
|
|
111
|
+
// Each dot sits in a 24 px target, edge to edge ( WCAG 2.5.8; Darren, 2026-11-21 ).
|
|
112
|
+
"flex items-center",
|
|
112
113
|
justifies[dots.justify] || justifies.center,
|
|
113
114
|
dots.overlay ? "absolute inset-x-3 bottom-3" : "mt-4 py-3"
|
|
114
115
|
].join(" ")
|
|
@@ -128,11 +129,19 @@ const Carousel = ({
|
|
|
128
129
|
"span",
|
|
129
130
|
{
|
|
130
131
|
...{
|
|
131
|
-
className: "
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
className: "flex items-center justify-center w-6 h-6"
|
|
133
|
+
},
|
|
134
|
+
children: /* @__PURE__ */ jsx(
|
|
135
|
+
"span",
|
|
136
|
+
{
|
|
137
|
+
...{
|
|
138
|
+
className: "block w-3 h-3 rounded-full border" + (style ? "" : " bg-black border-white"),
|
|
139
|
+
...style && {
|
|
140
|
+
style: dotStyle(style, index === key)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
134
143
|
}
|
|
135
|
-
|
|
144
|
+
)
|
|
136
145
|
}
|
|
137
146
|
)
|
|
138
147
|
},
|
|
@@ -33,6 +33,7 @@ __export(helpers_exports, {
|
|
|
33
33
|
bust: () => bust,
|
|
34
34
|
clickSummary: () => clickSummary,
|
|
35
35
|
connectionInGroup: () => connectionInGroup,
|
|
36
|
+
digitalSizeLimits: () => digitalSizeLimits,
|
|
36
37
|
fileMimes: () => fileMimes,
|
|
37
38
|
fileParts: () => fileParts,
|
|
38
39
|
fileSizeLimits: () => fileSizeLimits,
|
|
@@ -50,9 +51,11 @@ __export(helpers_exports, {
|
|
|
50
51
|
hasRestriction: () => hasRestriction,
|
|
51
52
|
imageAlt: () => imageAlt,
|
|
52
53
|
isAdmin: () => isAdmin,
|
|
54
|
+
money: () => money,
|
|
53
55
|
months: () => months,
|
|
54
56
|
organizationAlerts: () => organizationAlerts,
|
|
55
57
|
productAsset: () => productAsset,
|
|
58
|
+
setStripeKey: () => setStripeKey,
|
|
56
59
|
statusBadge: () => statusBadge,
|
|
57
60
|
stripeUrl: () => stripeUrl,
|
|
58
61
|
usageBadge: () => usageBadge,
|
|
@@ -98,6 +101,9 @@ const fileSizeLimits = {
|
|
|
98
101
|
// and if they drift the client blocks files the api would accept.
|
|
99
102
|
video: import_upload.maximumUploadBytes / import_drawbridge_utils.megabyte
|
|
100
103
|
};
|
|
104
|
+
const digitalSizeLimits = Object.fromEntries(
|
|
105
|
+
Object.keys(import_upload.digitalUploadTypes).map((type) => [type, import_upload.maximumUploadBytes / import_drawbridge_utils.megabyte])
|
|
106
|
+
);
|
|
101
107
|
const fileSizeLabel = (type, limits) => {
|
|
102
108
|
const limit = (limits || fileSizeLimits)[type];
|
|
103
109
|
return limit >= 1024 ? (0, import_drawbridge_utils.formatNumber)(limit / 1024) + "GB" : limit + "MB";
|
|
@@ -112,6 +118,10 @@ const fileSizes = (type = "media", limits) => {
|
|
|
112
118
|
video,
|
|
113
119
|
application
|
|
114
120
|
],
|
|
121
|
+
// @story products/digital-file
|
|
122
|
+
digital: [
|
|
123
|
+
fileSizeLabel("application", limits || digitalSizeLimits) + " / file"
|
|
124
|
+
],
|
|
115
125
|
media: [
|
|
116
126
|
image,
|
|
117
127
|
video
|
|
@@ -135,6 +145,9 @@ const fileGroups = (pick) => (type = "media") => {
|
|
|
135
145
|
...video,
|
|
136
146
|
...application
|
|
137
147
|
],
|
|
148
|
+
// @story products/digital-file
|
|
149
|
+
// A digital file's own list: the Library's types, a zip and an MP3.
|
|
150
|
+
digital: Object.values(import_upload.digitalUploadTypes).flatMap(pick),
|
|
138
151
|
media: [
|
|
139
152
|
...image,
|
|
140
153
|
...video
|
|
@@ -148,8 +161,9 @@ const fileTypes = fileGroups(Object.keys);
|
|
|
148
161
|
const fileMimes = fileGroups(Object.values);
|
|
149
162
|
const fileParts = (file) => {
|
|
150
163
|
var _a, _b, _c, _d;
|
|
151
|
-
const [
|
|
152
|
-
const extension = ((_b = (_a = import_upload.allowedUploadTypes) == null ? void 0 : _a[
|
|
164
|
+
const [mime, subtype] = ((file == null ? void 0 : file.type) || "").split("/");
|
|
165
|
+
const extension = ((_b = (_a = import_upload.allowedUploadTypes) == null ? void 0 : _a[mime]) == null ? void 0 : _b[subtype]) ? subtype : (((_d = (_c = file == null ? void 0 : file.name) == null ? void 0 : _c.split(".")) == null ? void 0 : _d.pop()) || "").toLowerCase();
|
|
166
|
+
const type = mime || Object.keys(import_upload.digitalUploadTypes).find((key) => import_upload.digitalUploadTypes[key][extension]) || "";
|
|
153
167
|
return {
|
|
154
168
|
extension,
|
|
155
169
|
type
|
|
@@ -198,17 +212,21 @@ const hasConnection = (organization, slug) => {
|
|
|
198
212
|
((organization == null ? void 0 : organization.connectionItems) || []).find((connection) => connection.slug === slug && connection.status === "active")
|
|
199
213
|
);
|
|
200
214
|
};
|
|
201
|
-
const connectionInGroup = (organization, group) => ((organization == null ? void 0 : organization.connectionItems) || []).find((connection) => connection.group === group && connection.status === "active") || null;
|
|
215
|
+
const connectionInGroup = (organization, group) => ((organization == null ? void 0 : organization.connectionItems) || []).find((connection) => connection.group === group && connection.status === "active" && connection.slug !== "stripe") || null;
|
|
202
216
|
const hasConnectionGroup = (organization, group) => Boolean(connectionInGroup(organization, group));
|
|
203
217
|
const hasRestriction = (object, key) => {
|
|
204
218
|
return Boolean(((object == null ? void 0 : object.restricted) || []).includes(key));
|
|
205
219
|
};
|
|
206
220
|
const productAsset = (product) => {
|
|
207
|
-
|
|
221
|
+
var _a;
|
|
222
|
+
const first = ((product == null ? void 0 : product.images) || [])[0];
|
|
223
|
+
if ((_a = first == null ? void 0 : first.file) == null ? void 0 : _a.sizes) return first.file;
|
|
224
|
+
const image = (first == null ? void 0 : first.url) || (product == null ? void 0 : product.image);
|
|
225
|
+
if (!image) return null;
|
|
208
226
|
return {
|
|
209
227
|
mimetype: "image",
|
|
210
228
|
sizes: {
|
|
211
|
-
"100x100":
|
|
229
|
+
"100x100": image
|
|
212
230
|
},
|
|
213
231
|
updatedAt: product == null ? void 0 : product.updatedAt
|
|
214
232
|
};
|
|
@@ -346,6 +364,28 @@ const statuses = {
|
|
|
346
364
|
canceled: { text: "Canceled", type: "error" },
|
|
347
365
|
completed: { text: "Completed", type: "success" }
|
|
348
366
|
},
|
|
367
|
+
// @story orders/fulfill
|
|
368
|
+
// An order's fulfillment, ours or Shopify's: one set of words and colours for
|
|
369
|
+
// the Orders list's column and the drawer.
|
|
370
|
+
fulfillment: {
|
|
371
|
+
fulfilled: { text: "Fulfilled", type: "success" },
|
|
372
|
+
partially_fulfilled: { text: "Partially fulfilled", type: "warning" },
|
|
373
|
+
unfulfilled: { text: "Unfulfilled", type: "warning" }
|
|
374
|
+
},
|
|
375
|
+
// @story orders/paid-orders
|
|
376
|
+
// An order's payment, by drawbridge-utils products paymentOf: a Stripe order's
|
|
377
|
+
// and Shopify's values as Shopify spells them. A form order takes none.
|
|
378
|
+
payment: {
|
|
379
|
+
authorized: { text: "Authorized", type: "secondary" },
|
|
380
|
+
disputed: { text: "Disputed", type: "error" },
|
|
381
|
+
expired: { text: "Expired", type: "secondary" },
|
|
382
|
+
paid: { text: "Paid", type: "success" },
|
|
383
|
+
partially_paid: { text: "Partly paid", type: "warning" },
|
|
384
|
+
partially_refunded: { text: "Partly refunded", type: "warning" },
|
|
385
|
+
pending: { text: "Pending", type: "secondary" },
|
|
386
|
+
refunded: { text: "Refunded", type: "secondary" },
|
|
387
|
+
voided: { text: "Voided", type: "secondary" }
|
|
388
|
+
},
|
|
349
389
|
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" }])),
|
|
350
390
|
page: published,
|
|
351
391
|
prize: published,
|
|
@@ -399,9 +439,13 @@ const alertFor = (record) => {
|
|
|
399
439
|
if ((record == null ? void 0 : record.status) === "locked") return { icon: import_lock.default, message: ["Locked", error == null ? void 0 : error.toLowerCase()].filter(Boolean).join(", ") };
|
|
400
440
|
return error ? { icon: import_warning.default, message: error } : null;
|
|
401
441
|
};
|
|
442
|
+
let stripeKey = "";
|
|
443
|
+
const setStripeKey = (key) => {
|
|
444
|
+
stripeKey = key || "";
|
|
445
|
+
};
|
|
402
446
|
const stripeUrl = (label, id, ...more) => {
|
|
403
447
|
const parts = [
|
|
404
|
-
"https://dashboard.stripe.com" + (
|
|
448
|
+
"https://dashboard.stripe.com" + (stripeKey.includes("_test_") ? "/test" : ""),
|
|
405
449
|
label + "s",
|
|
406
450
|
id,
|
|
407
451
|
...more
|
|
@@ -422,6 +466,7 @@ const years = ({
|
|
|
422
466
|
})
|
|
423
467
|
);
|
|
424
468
|
};
|
|
469
|
+
const money = ({ code, display = "parts", value }) => typeof code === "string" && code ? (0, import_drawbridge_utils.formatCurrency)({ code, display, value }) : null;
|
|
425
470
|
// Annotate the CommonJS export names for ESM import in node:
|
|
426
471
|
0 && (module.exports = {
|
|
427
472
|
acceptingBadge,
|
|
@@ -430,6 +475,7 @@ const years = ({
|
|
|
430
475
|
bust,
|
|
431
476
|
clickSummary,
|
|
432
477
|
connectionInGroup,
|
|
478
|
+
digitalSizeLimits,
|
|
433
479
|
fileMimes,
|
|
434
480
|
fileParts,
|
|
435
481
|
fileSizeLimits,
|
|
@@ -447,9 +493,11 @@ const years = ({
|
|
|
447
493
|
hasRestriction,
|
|
448
494
|
imageAlt,
|
|
449
495
|
isAdmin,
|
|
496
|
+
money,
|
|
450
497
|
months,
|
|
451
498
|
organizationAlerts,
|
|
452
499
|
productAsset,
|
|
500
|
+
setStripeKey,
|
|
453
501
|
statusBadge,
|
|
454
502
|
stripeUrl,
|
|
455
503
|
usageBadge,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { allowedUploadTypes, maximumUploadBytes } from "@drawbridge/drawbridge-utils/upload";
|
|
2
|
-
import { capitalize, formatNumber, megabyte } from "@drawbridge/drawbridge-utils";
|
|
1
|
+
import { allowedUploadTypes, digitalUploadTypes, maximumUploadBytes } from "@drawbridge/drawbridge-utils/upload";
|
|
2
|
+
import { capitalize, formatCurrency, formatNumber, megabyte } from "@drawbridge/drawbridge-utils";
|
|
3
3
|
import Lock from "../../icons/lock.mjs";
|
|
4
4
|
import Warning from "../../icons/warning.mjs";
|
|
5
5
|
const advertisementPreview = (values, options) => {
|
|
@@ -36,6 +36,9 @@ const fileSizeLimits = {
|
|
|
36
36
|
// and if they drift the client blocks files the api would accept.
|
|
37
37
|
video: maximumUploadBytes / megabyte
|
|
38
38
|
};
|
|
39
|
+
const digitalSizeLimits = Object.fromEntries(
|
|
40
|
+
Object.keys(digitalUploadTypes).map((type) => [type, maximumUploadBytes / megabyte])
|
|
41
|
+
);
|
|
39
42
|
const fileSizeLabel = (type, limits) => {
|
|
40
43
|
const limit = (limits || fileSizeLimits)[type];
|
|
41
44
|
return limit >= 1024 ? formatNumber(limit / 1024) + "GB" : limit + "MB";
|
|
@@ -50,6 +53,10 @@ const fileSizes = (type = "media", limits) => {
|
|
|
50
53
|
video,
|
|
51
54
|
application
|
|
52
55
|
],
|
|
56
|
+
// @story products/digital-file
|
|
57
|
+
digital: [
|
|
58
|
+
fileSizeLabel("application", limits || digitalSizeLimits) + " / file"
|
|
59
|
+
],
|
|
53
60
|
media: [
|
|
54
61
|
image,
|
|
55
62
|
video
|
|
@@ -73,6 +80,9 @@ const fileGroups = (pick) => (type = "media") => {
|
|
|
73
80
|
...video,
|
|
74
81
|
...application
|
|
75
82
|
],
|
|
83
|
+
// @story products/digital-file
|
|
84
|
+
// A digital file's own list: the Library's types, a zip and an MP3.
|
|
85
|
+
digital: Object.values(digitalUploadTypes).flatMap(pick),
|
|
76
86
|
media: [
|
|
77
87
|
...image,
|
|
78
88
|
...video
|
|
@@ -86,8 +96,9 @@ const fileTypes = fileGroups(Object.keys);
|
|
|
86
96
|
const fileMimes = fileGroups(Object.values);
|
|
87
97
|
const fileParts = (file) => {
|
|
88
98
|
var _a, _b, _c, _d;
|
|
89
|
-
const [
|
|
90
|
-
const extension = ((_b = (_a = allowedUploadTypes) == null ? void 0 : _a[
|
|
99
|
+
const [mime, subtype] = ((file == null ? void 0 : file.type) || "").split("/");
|
|
100
|
+
const extension = ((_b = (_a = allowedUploadTypes) == null ? void 0 : _a[mime]) == null ? void 0 : _b[subtype]) ? subtype : (((_d = (_c = file == null ? void 0 : file.name) == null ? void 0 : _c.split(".")) == null ? void 0 : _d.pop()) || "").toLowerCase();
|
|
101
|
+
const type = mime || Object.keys(digitalUploadTypes).find((key) => digitalUploadTypes[key][extension]) || "";
|
|
91
102
|
return {
|
|
92
103
|
extension,
|
|
93
104
|
type
|
|
@@ -136,17 +147,21 @@ const hasConnection = (organization, slug) => {
|
|
|
136
147
|
((organization == null ? void 0 : organization.connectionItems) || []).find((connection) => connection.slug === slug && connection.status === "active")
|
|
137
148
|
);
|
|
138
149
|
};
|
|
139
|
-
const connectionInGroup = (organization, group) => ((organization == null ? void 0 : organization.connectionItems) || []).find((connection) => connection.group === group && connection.status === "active") || null;
|
|
150
|
+
const connectionInGroup = (organization, group) => ((organization == null ? void 0 : organization.connectionItems) || []).find((connection) => connection.group === group && connection.status === "active" && connection.slug !== "stripe") || null;
|
|
140
151
|
const hasConnectionGroup = (organization, group) => Boolean(connectionInGroup(organization, group));
|
|
141
152
|
const hasRestriction = (object, key) => {
|
|
142
153
|
return Boolean(((object == null ? void 0 : object.restricted) || []).includes(key));
|
|
143
154
|
};
|
|
144
155
|
const productAsset = (product) => {
|
|
145
|
-
|
|
156
|
+
var _a;
|
|
157
|
+
const first = ((product == null ? void 0 : product.images) || [])[0];
|
|
158
|
+
if ((_a = first == null ? void 0 : first.file) == null ? void 0 : _a.sizes) return first.file;
|
|
159
|
+
const image = (first == null ? void 0 : first.url) || (product == null ? void 0 : product.image);
|
|
160
|
+
if (!image) return null;
|
|
146
161
|
return {
|
|
147
162
|
mimetype: "image",
|
|
148
163
|
sizes: {
|
|
149
|
-
"100x100":
|
|
164
|
+
"100x100": image
|
|
150
165
|
},
|
|
151
166
|
updatedAt: product == null ? void 0 : product.updatedAt
|
|
152
167
|
};
|
|
@@ -284,6 +299,28 @@ const statuses = {
|
|
|
284
299
|
canceled: { text: "Canceled", type: "error" },
|
|
285
300
|
completed: { text: "Completed", type: "success" }
|
|
286
301
|
},
|
|
302
|
+
// @story orders/fulfill
|
|
303
|
+
// An order's fulfillment, ours or Shopify's: one set of words and colours for
|
|
304
|
+
// the Orders list's column and the drawer.
|
|
305
|
+
fulfillment: {
|
|
306
|
+
fulfilled: { text: "Fulfilled", type: "success" },
|
|
307
|
+
partially_fulfilled: { text: "Partially fulfilled", type: "warning" },
|
|
308
|
+
unfulfilled: { text: "Unfulfilled", type: "warning" }
|
|
309
|
+
},
|
|
310
|
+
// @story orders/paid-orders
|
|
311
|
+
// An order's payment, by drawbridge-utils products paymentOf: a Stripe order's
|
|
312
|
+
// and Shopify's values as Shopify spells them. A form order takes none.
|
|
313
|
+
payment: {
|
|
314
|
+
authorized: { text: "Authorized", type: "secondary" },
|
|
315
|
+
disputed: { text: "Disputed", type: "error" },
|
|
316
|
+
expired: { text: "Expired", type: "secondary" },
|
|
317
|
+
paid: { text: "Paid", type: "success" },
|
|
318
|
+
partially_paid: { text: "Partly paid", type: "warning" },
|
|
319
|
+
partially_refunded: { text: "Partly refunded", type: "warning" },
|
|
320
|
+
pending: { text: "Pending", type: "secondary" },
|
|
321
|
+
refunded: { text: "Refunded", type: "secondary" },
|
|
322
|
+
voided: { text: "Voided", type: "secondary" }
|
|
323
|
+
},
|
|
287
324
|
organization: Object.fromEntries(organizationStatuses.map((status) => [status, { text: capitalize(status.replace("_", " ")), type: ["active", "unsubscribed"].includes(status) ? "success" : status === "paused" ? "warning" : "error" }])),
|
|
288
325
|
page: published,
|
|
289
326
|
prize: published,
|
|
@@ -337,9 +374,13 @@ const alertFor = (record) => {
|
|
|
337
374
|
if ((record == null ? void 0 : record.status) === "locked") return { icon: Lock, message: ["Locked", error == null ? void 0 : error.toLowerCase()].filter(Boolean).join(", ") };
|
|
338
375
|
return error ? { icon: Warning, message: error } : null;
|
|
339
376
|
};
|
|
377
|
+
let stripeKey = "";
|
|
378
|
+
const setStripeKey = (key) => {
|
|
379
|
+
stripeKey = key || "";
|
|
380
|
+
};
|
|
340
381
|
const stripeUrl = (label, id, ...more) => {
|
|
341
382
|
const parts = [
|
|
342
|
-
"https://dashboard.stripe.com" + (
|
|
383
|
+
"https://dashboard.stripe.com" + (stripeKey.includes("_test_") ? "/test" : ""),
|
|
343
384
|
label + "s",
|
|
344
385
|
id,
|
|
345
386
|
...more
|
|
@@ -360,6 +401,7 @@ const years = ({
|
|
|
360
401
|
})
|
|
361
402
|
);
|
|
362
403
|
};
|
|
404
|
+
const money = ({ code, display = "parts", value }) => typeof code === "string" && code ? formatCurrency({ code, display, value }) : null;
|
|
363
405
|
export {
|
|
364
406
|
acceptingBadge,
|
|
365
407
|
advertisementPreview,
|
|
@@ -367,6 +409,7 @@ export {
|
|
|
367
409
|
bust,
|
|
368
410
|
clickSummary,
|
|
369
411
|
connectionInGroup,
|
|
412
|
+
digitalSizeLimits,
|
|
370
413
|
fileMimes,
|
|
371
414
|
fileParts,
|
|
372
415
|
fileSizeLimits,
|
|
@@ -384,9 +427,11 @@ export {
|
|
|
384
427
|
hasRestriction,
|
|
385
428
|
imageAlt,
|
|
386
429
|
isAdmin,
|
|
430
|
+
money,
|
|
387
431
|
months,
|
|
388
432
|
organizationAlerts,
|
|
389
433
|
productAsset,
|
|
434
|
+
setStripeKey,
|
|
390
435
|
statusBadge,
|
|
391
436
|
stripeUrl,
|
|
392
437
|
usageBadge,
|