@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
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var products_exports = {};
|
|
19
|
+
__export(products_exports, {
|
|
20
|
+
CHECKOUT_LABELS: () => CHECKOUT_LABELS,
|
|
21
|
+
VARIANT_DEFAULTS: () => VARIANT_DEFAULTS,
|
|
22
|
+
checkoutChange: () => checkoutChange,
|
|
23
|
+
downloadsText: () => downloadsText,
|
|
24
|
+
moneyOf: () => moneyOf,
|
|
25
|
+
priceText: () => priceText,
|
|
26
|
+
productBody: () => productBody,
|
|
27
|
+
sellingWarning: () => sellingWarning,
|
|
28
|
+
totalQuantity: () => totalQuantity,
|
|
29
|
+
variantCount: () => variantCount,
|
|
30
|
+
variantRows: () => variantRows,
|
|
31
|
+
variantsFor: () => variantsFor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(products_exports);
|
|
34
|
+
var import_products = require("@drawbridge/drawbridge-utils/products");
|
|
35
|
+
var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
|
|
36
|
+
const CHECKOUT_LABELS = Object.freeze({
|
|
37
|
+
shopify: "Shopify",
|
|
38
|
+
stripe: "Stripe"
|
|
39
|
+
});
|
|
40
|
+
const VARIANT_DEFAULTS = Object.freeze({
|
|
41
|
+
inventoryQuantity: null,
|
|
42
|
+
price: null,
|
|
43
|
+
requiresShipping: true,
|
|
44
|
+
sale: null,
|
|
45
|
+
sku: null,
|
|
46
|
+
taxable: true
|
|
47
|
+
});
|
|
48
|
+
const variantsFor = (options, variants) => (0, import_products.buildVariants)({
|
|
49
|
+
defaults: VARIANT_DEFAULTS,
|
|
50
|
+
mintId: () => void 0,
|
|
51
|
+
options,
|
|
52
|
+
variants
|
|
53
|
+
});
|
|
54
|
+
const moneyOf = (value, currency) => (0, import_drawbridge_utils.formatCurrency)({
|
|
55
|
+
code: currency || "USD",
|
|
56
|
+
value
|
|
57
|
+
});
|
|
58
|
+
const priceText = (variants = []) => {
|
|
59
|
+
var _a;
|
|
60
|
+
const range = (0, import_products.priceRange)(variants);
|
|
61
|
+
if (!range) return "\u2014";
|
|
62
|
+
const currency = (_a = variants[0]) == null ? void 0 : _a.currency;
|
|
63
|
+
return range.min === range.max ? moneyOf(range.min, currency) : moneyOf(range.min, currency) + " \u2013 " + moneyOf(range.max, currency);
|
|
64
|
+
};
|
|
65
|
+
const variantRows = ({ expanded = [], group, options = [], variants = [] }) => {
|
|
66
|
+
const indexed = variants.map((variant, index) => ({
|
|
67
|
+
...variant,
|
|
68
|
+
index
|
|
69
|
+
}));
|
|
70
|
+
if (options.length < 2) return indexed;
|
|
71
|
+
const position = Math.max(0, options.findIndex((option) => option.name === group));
|
|
72
|
+
return options[position].values.flatMap((value) => {
|
|
73
|
+
const children = indexed.filter((variant) => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return ((_b = (_a = variant.selectedOptions) == null ? void 0 : _a[position]) == null ? void 0 : _b.value) === value;
|
|
76
|
+
});
|
|
77
|
+
if (!children.length) return [];
|
|
78
|
+
const prices = children.map((variant) => variant.price);
|
|
79
|
+
const same = prices.every((price) => price === prices[0]);
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
children: children.map((variant) => variant.index),
|
|
83
|
+
group: true,
|
|
84
|
+
id: "group-" + value,
|
|
85
|
+
inventoryQuantity: children.reduce((sum, variant) => sum + (variant.inventoryQuantity || 0), 0),
|
|
86
|
+
price: same ? prices[0] : null,
|
|
87
|
+
range: same ? null : priceText(children),
|
|
88
|
+
title: value,
|
|
89
|
+
variants: children.length
|
|
90
|
+
},
|
|
91
|
+
...expanded.includes(value) ? children.map((variant) => ({
|
|
92
|
+
...variant,
|
|
93
|
+
child: true,
|
|
94
|
+
title: (variant.selectedOptions || []).filter((item, key) => key !== position).map((item) => item.value).join(" / ")
|
|
95
|
+
})) : []
|
|
96
|
+
];
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const totalQuantity = (variants = []) => variants.reduce((sum, variant) => sum + ((variant == null ? void 0 : variant.inventoryQuantity) || 0), 0);
|
|
100
|
+
const variantCount = (options = []) => options.reduce((total, option) => total * Math.max(1, ((option == null ? void 0 : option.values) || []).length), 1);
|
|
101
|
+
const stock = (value) => Number.isFinite(value) ? value : null;
|
|
102
|
+
const stockChanged = (variant, loaded) => {
|
|
103
|
+
const was = variant.id ? (loaded || []).find((item) => (item == null ? void 0 : item.id) === variant.id) : null;
|
|
104
|
+
return !was || stock(was.inventoryQuantity) !== stock(variant.inventoryQuantity);
|
|
105
|
+
};
|
|
106
|
+
const productBody = ({ description, gallery = [], options, recommendations = [], status, title, variants }, loaded = []) => ({
|
|
107
|
+
description: description || null,
|
|
108
|
+
images: gallery.filter((item) => {
|
|
109
|
+
var _a;
|
|
110
|
+
return ((_a = item == null ? void 0 : item.file) == null ? void 0 : _a.id) || typeof (item == null ? void 0 : item.file) === "string";
|
|
111
|
+
}).map((item) => {
|
|
112
|
+
var _a;
|
|
113
|
+
return {
|
|
114
|
+
description: item.description || null,
|
|
115
|
+
file: ((_a = item.file) == null ? void 0 : _a.id) || item.file
|
|
116
|
+
};
|
|
117
|
+
}),
|
|
118
|
+
options,
|
|
119
|
+
// @story products/recommended
|
|
120
|
+
// The recommended products' ids, in the merchant's order.
|
|
121
|
+
recommendations: (recommendations || []).map((item) => item == null ? void 0 : item.id).filter(Boolean),
|
|
122
|
+
status,
|
|
123
|
+
title,
|
|
124
|
+
variants: variants.map((variant) => {
|
|
125
|
+
var _a;
|
|
126
|
+
return {
|
|
127
|
+
// @story products/digital-file
|
|
128
|
+
// The variant's digital file by its id, or null once removed.
|
|
129
|
+
file: ((_a = variant.file) == null ? void 0 : _a.id) || (typeof variant.file === "string" ? variant.file : null),
|
|
130
|
+
id: variant.id || null,
|
|
131
|
+
...stockChanged(variant, loaded) && {
|
|
132
|
+
inventoryQuantity: Number.isFinite(variant.inventoryQuantity) ? variant.inventoryQuantity : null
|
|
133
|
+
},
|
|
134
|
+
price: Number.isFinite(variant.price) ? variant.price : null,
|
|
135
|
+
requiresShipping: variant.requiresShipping !== false,
|
|
136
|
+
sale: Number.isFinite(variant.sale) ? variant.sale : null,
|
|
137
|
+
selectedOptions: variant.selectedOptions || [],
|
|
138
|
+
sku: variant.sku || null,
|
|
139
|
+
taxable: variant.taxable !== false
|
|
140
|
+
};
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
const downloadsText = (count) => count > 0 ? (0, import_drawbridge_utils.formatNumber)(count) + (count === 1 ? " download" : " downloads") : "Not downloaded yet";
|
|
144
|
+
const checkoutChange = ({ ads = 0, from, products = 0, to }) => ({
|
|
145
|
+
message: "This campaign will sell from " + CHECKOUT_LABELS[to] + ". Only " + CHECKOUT_LABELS[to] + " products can be added to it after this.",
|
|
146
|
+
warnings: [
|
|
147
|
+
products > 0 && "Its " + products + " " + CHECKOUT_LABELS[from] + " product" + (products === 1 ? "" : "s") + " will be removed from this campaign, and any open carts on it will be emptied.",
|
|
148
|
+
// Sync locks every unlocked ad made from the checkout left, attached or
|
|
149
|
+
// not, so the card names the checkout's products, never "those" ( 2026-11-20
|
|
150
|
+
// review ).
|
|
151
|
+
ads > 0 && "Its " + ads + " advertisement" + (ads === 1 ? "" : "s") + " made from " + CHECKOUT_LABELS[from] + " products will be drafted, and can't be edited."
|
|
152
|
+
].filter(Boolean)
|
|
153
|
+
});
|
|
154
|
+
const sellingWarning = ({ selling = 0, slug }) => selling > 0 ? selling + (selling === 1 ? " campaign sells" : " campaigns sell") + " through " + CHECKOUT_LABELS[slug] + ". " + (selling === 1 ? "Its shop stops" : "Their shops stop") + " selling until you connect again." : null;
|
|
155
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
156
|
+
0 && (module.exports = {
|
|
157
|
+
CHECKOUT_LABELS,
|
|
158
|
+
VARIANT_DEFAULTS,
|
|
159
|
+
checkoutChange,
|
|
160
|
+
downloadsText,
|
|
161
|
+
moneyOf,
|
|
162
|
+
priceText,
|
|
163
|
+
productBody,
|
|
164
|
+
sellingWarning,
|
|
165
|
+
totalQuantity,
|
|
166
|
+
variantCount,
|
|
167
|
+
variantRows,
|
|
168
|
+
variantsFor
|
|
169
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { buildVariants, priceRange } from "@drawbridge/drawbridge-utils/products";
|
|
2
|
+
import { formatCurrency, formatNumber } from "@drawbridge/drawbridge-utils";
|
|
3
|
+
const CHECKOUT_LABELS = Object.freeze({
|
|
4
|
+
shopify: "Shopify",
|
|
5
|
+
stripe: "Stripe"
|
|
6
|
+
});
|
|
7
|
+
const VARIANT_DEFAULTS = Object.freeze({
|
|
8
|
+
inventoryQuantity: null,
|
|
9
|
+
price: null,
|
|
10
|
+
requiresShipping: true,
|
|
11
|
+
sale: null,
|
|
12
|
+
sku: null,
|
|
13
|
+
taxable: true
|
|
14
|
+
});
|
|
15
|
+
const variantsFor = (options, variants) => buildVariants({
|
|
16
|
+
defaults: VARIANT_DEFAULTS,
|
|
17
|
+
mintId: () => void 0,
|
|
18
|
+
options,
|
|
19
|
+
variants
|
|
20
|
+
});
|
|
21
|
+
const moneyOf = (value, currency) => formatCurrency({
|
|
22
|
+
code: currency || "USD",
|
|
23
|
+
value
|
|
24
|
+
});
|
|
25
|
+
const priceText = (variants = []) => {
|
|
26
|
+
var _a;
|
|
27
|
+
const range = priceRange(variants);
|
|
28
|
+
if (!range) return "\u2014";
|
|
29
|
+
const currency = (_a = variants[0]) == null ? void 0 : _a.currency;
|
|
30
|
+
return range.min === range.max ? moneyOf(range.min, currency) : moneyOf(range.min, currency) + " \u2013 " + moneyOf(range.max, currency);
|
|
31
|
+
};
|
|
32
|
+
const variantRows = ({ expanded = [], group, options = [], variants = [] }) => {
|
|
33
|
+
const indexed = variants.map((variant, index) => ({
|
|
34
|
+
...variant,
|
|
35
|
+
index
|
|
36
|
+
}));
|
|
37
|
+
if (options.length < 2) return indexed;
|
|
38
|
+
const position = Math.max(0, options.findIndex((option) => option.name === group));
|
|
39
|
+
return options[position].values.flatMap((value) => {
|
|
40
|
+
const children = indexed.filter((variant) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
return ((_b = (_a = variant.selectedOptions) == null ? void 0 : _a[position]) == null ? void 0 : _b.value) === value;
|
|
43
|
+
});
|
|
44
|
+
if (!children.length) return [];
|
|
45
|
+
const prices = children.map((variant) => variant.price);
|
|
46
|
+
const same = prices.every((price) => price === prices[0]);
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
children: children.map((variant) => variant.index),
|
|
50
|
+
group: true,
|
|
51
|
+
id: "group-" + value,
|
|
52
|
+
inventoryQuantity: children.reduce((sum, variant) => sum + (variant.inventoryQuantity || 0), 0),
|
|
53
|
+
price: same ? prices[0] : null,
|
|
54
|
+
range: same ? null : priceText(children),
|
|
55
|
+
title: value,
|
|
56
|
+
variants: children.length
|
|
57
|
+
},
|
|
58
|
+
...expanded.includes(value) ? children.map((variant) => ({
|
|
59
|
+
...variant,
|
|
60
|
+
child: true,
|
|
61
|
+
title: (variant.selectedOptions || []).filter((item, key) => key !== position).map((item) => item.value).join(" / ")
|
|
62
|
+
})) : []
|
|
63
|
+
];
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const totalQuantity = (variants = []) => variants.reduce((sum, variant) => sum + ((variant == null ? void 0 : variant.inventoryQuantity) || 0), 0);
|
|
67
|
+
const variantCount = (options = []) => options.reduce((total, option) => total * Math.max(1, ((option == null ? void 0 : option.values) || []).length), 1);
|
|
68
|
+
const stock = (value) => Number.isFinite(value) ? value : null;
|
|
69
|
+
const stockChanged = (variant, loaded) => {
|
|
70
|
+
const was = variant.id ? (loaded || []).find((item) => (item == null ? void 0 : item.id) === variant.id) : null;
|
|
71
|
+
return !was || stock(was.inventoryQuantity) !== stock(variant.inventoryQuantity);
|
|
72
|
+
};
|
|
73
|
+
const productBody = ({ description, gallery = [], options, recommendations = [], status, title, variants }, loaded = []) => ({
|
|
74
|
+
description: description || null,
|
|
75
|
+
images: gallery.filter((item) => {
|
|
76
|
+
var _a;
|
|
77
|
+
return ((_a = item == null ? void 0 : item.file) == null ? void 0 : _a.id) || typeof (item == null ? void 0 : item.file) === "string";
|
|
78
|
+
}).map((item) => {
|
|
79
|
+
var _a;
|
|
80
|
+
return {
|
|
81
|
+
description: item.description || null,
|
|
82
|
+
file: ((_a = item.file) == null ? void 0 : _a.id) || item.file
|
|
83
|
+
};
|
|
84
|
+
}),
|
|
85
|
+
options,
|
|
86
|
+
// @story products/recommended
|
|
87
|
+
// The recommended products' ids, in the merchant's order.
|
|
88
|
+
recommendations: (recommendations || []).map((item) => item == null ? void 0 : item.id).filter(Boolean),
|
|
89
|
+
status,
|
|
90
|
+
title,
|
|
91
|
+
variants: variants.map((variant) => {
|
|
92
|
+
var _a;
|
|
93
|
+
return {
|
|
94
|
+
// @story products/digital-file
|
|
95
|
+
// The variant's digital file by its id, or null once removed.
|
|
96
|
+
file: ((_a = variant.file) == null ? void 0 : _a.id) || (typeof variant.file === "string" ? variant.file : null),
|
|
97
|
+
id: variant.id || null,
|
|
98
|
+
...stockChanged(variant, loaded) && {
|
|
99
|
+
inventoryQuantity: Number.isFinite(variant.inventoryQuantity) ? variant.inventoryQuantity : null
|
|
100
|
+
},
|
|
101
|
+
price: Number.isFinite(variant.price) ? variant.price : null,
|
|
102
|
+
requiresShipping: variant.requiresShipping !== false,
|
|
103
|
+
sale: Number.isFinite(variant.sale) ? variant.sale : null,
|
|
104
|
+
selectedOptions: variant.selectedOptions || [],
|
|
105
|
+
sku: variant.sku || null,
|
|
106
|
+
taxable: variant.taxable !== false
|
|
107
|
+
};
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
const downloadsText = (count) => count > 0 ? formatNumber(count) + (count === 1 ? " download" : " downloads") : "Not downloaded yet";
|
|
111
|
+
const checkoutChange = ({ ads = 0, from, products = 0, to }) => ({
|
|
112
|
+
message: "This campaign will sell from " + CHECKOUT_LABELS[to] + ". Only " + CHECKOUT_LABELS[to] + " products can be added to it after this.",
|
|
113
|
+
warnings: [
|
|
114
|
+
products > 0 && "Its " + products + " " + CHECKOUT_LABELS[from] + " product" + (products === 1 ? "" : "s") + " will be removed from this campaign, and any open carts on it will be emptied.",
|
|
115
|
+
// Sync locks every unlocked ad made from the checkout left, attached or
|
|
116
|
+
// not, so the card names the checkout's products, never "those" ( 2026-11-20
|
|
117
|
+
// review ).
|
|
118
|
+
ads > 0 && "Its " + ads + " advertisement" + (ads === 1 ? "" : "s") + " made from " + CHECKOUT_LABELS[from] + " products will be drafted, and can't be edited."
|
|
119
|
+
].filter(Boolean)
|
|
120
|
+
});
|
|
121
|
+
const sellingWarning = ({ selling = 0, slug }) => selling > 0 ? selling + (selling === 1 ? " campaign sells" : " campaigns sell") + " through " + CHECKOUT_LABELS[slug] + ". " + (selling === 1 ? "Its shop stops" : "Their shops stop") + " selling until you connect again." : null;
|
|
122
|
+
export {
|
|
123
|
+
CHECKOUT_LABELS,
|
|
124
|
+
VARIANT_DEFAULTS,
|
|
125
|
+
checkoutChange,
|
|
126
|
+
downloadsText,
|
|
127
|
+
moneyOf,
|
|
128
|
+
priceText,
|
|
129
|
+
productBody,
|
|
130
|
+
sellingWarning,
|
|
131
|
+
totalQuantity,
|
|
132
|
+
variantCount,
|
|
133
|
+
variantRows,
|
|
134
|
+
variantsFor
|
|
135
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var settings_paths_exports = {};
|
|
19
|
+
__export(settings_paths_exports, {
|
|
20
|
+
nestPaths: () => nestPaths,
|
|
21
|
+
readPath: () => readPath
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(settings_paths_exports);
|
|
24
|
+
const readPath = (object, key) => String(key).split(".").reduce((node, part) => node == null ? void 0 : node[part], object);
|
|
25
|
+
const nestPaths = (pairs) => pairs.reduce((tree, [key, value]) => {
|
|
26
|
+
const parts = String(key).split(".");
|
|
27
|
+
const last = parts.pop();
|
|
28
|
+
parts.reduce((branch, part) => branch[part] ??= {}, tree)[last] = value;
|
|
29
|
+
return tree;
|
|
30
|
+
}, {});
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
nestPaths,
|
|
34
|
+
readPath
|
|
35
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const readPath = (object, key) => String(key).split(".").reduce((node, part) => node == null ? void 0 : node[part], object);
|
|
2
|
+
const nestPaths = (pairs) => pairs.reduce((tree, [key, value]) => {
|
|
3
|
+
const parts = String(key).split(".");
|
|
4
|
+
const last = parts.pop();
|
|
5
|
+
parts.reduce((branch, part) => branch[part] ??= {}, tree)[last] = value;
|
|
6
|
+
return tree;
|
|
7
|
+
}, {});
|
|
8
|
+
export {
|
|
9
|
+
nestPaths,
|
|
10
|
+
readPath
|
|
11
|
+
};
|
|
@@ -65,7 +65,11 @@ const create = async ({
|
|
|
65
65
|
// Derived from the allowlist the api validates against, so a wrong
|
|
66
66
|
// type is refused here for the same reason it would be refused
|
|
67
67
|
// there — before two gigabytes move rather than after.
|
|
68
|
-
|
|
68
|
+
//
|
|
69
|
+
// @story products/digital-file
|
|
70
|
+
// A digital file by its extension: a zip's mime differs by system
|
|
71
|
+
// ( application/x-zip-compressed on Windows ).
|
|
72
|
+
allowedFileTypes: type === "digital" ? (0, import_helpers.fileTypes)(type).map((extension) => "." + extension) : (0, import_helpers.fileMimes)(type),
|
|
69
73
|
// One number for every type: only a video is large enough to reach
|
|
70
74
|
// this path, and lib/yup.js enforces the per-type cap before a file
|
|
71
75
|
// gets here. Defaults to the shared ceiling the api enforces; an
|
|
@@ -108,6 +112,11 @@ const create = async ({
|
|
|
108
112
|
bytes: file == null ? void 0 : file.size,
|
|
109
113
|
extension,
|
|
110
114
|
filename: file == null ? void 0 : file.name,
|
|
115
|
+
// @story products/digital-file
|
|
116
|
+
// A digital file is stored private, out of the Library.
|
|
117
|
+
...type === "digital" && {
|
|
118
|
+
private: true
|
|
119
|
+
},
|
|
111
120
|
type: primary
|
|
112
121
|
},
|
|
113
122
|
endpoint: url(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { megabyte } from "@drawbridge/drawbridge-utils";
|
|
2
2
|
import { uploadPartSize } from "@drawbridge/drawbridge-utils/upload";
|
|
3
3
|
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
4
|
-
import { fileMimes, fileParts, fileSizeLimits } from "../../shared/lib/helpers.mjs";
|
|
4
|
+
import { fileMimes, fileParts, fileSizeLimits, fileTypes } from "../../shared/lib/helpers.mjs";
|
|
5
5
|
const partSizeFor = uploadPartSize;
|
|
6
6
|
const guard = (event) => {
|
|
7
7
|
if (!isUploading(instance)) return;
|
|
@@ -30,7 +30,11 @@ const create = async ({
|
|
|
30
30
|
// Derived from the allowlist the api validates against, so a wrong
|
|
31
31
|
// type is refused here for the same reason it would be refused
|
|
32
32
|
// there — before two gigabytes move rather than after.
|
|
33
|
-
|
|
33
|
+
//
|
|
34
|
+
// @story products/digital-file
|
|
35
|
+
// A digital file by its extension: a zip's mime differs by system
|
|
36
|
+
// ( application/x-zip-compressed on Windows ).
|
|
37
|
+
allowedFileTypes: type === "digital" ? fileTypes(type).map((extension) => "." + extension) : fileMimes(type),
|
|
34
38
|
// One number for every type: only a video is large enough to reach
|
|
35
39
|
// this path, and lib/yup.js enforces the per-type cap before a file
|
|
36
40
|
// gets here. Defaults to the shared ceiling the api enforces; an
|
|
@@ -73,6 +77,11 @@ const create = async ({
|
|
|
73
77
|
bytes: file == null ? void 0 : file.size,
|
|
74
78
|
extension,
|
|
75
79
|
filename: file == null ? void 0 : file.name,
|
|
80
|
+
// @story products/digital-file
|
|
81
|
+
// A digital file is stored private, out of the Library.
|
|
82
|
+
...type === "digital" && {
|
|
83
|
+
private: true
|
|
84
|
+
},
|
|
76
85
|
type: primary
|
|
77
86
|
},
|
|
78
87
|
endpoint: url(),
|
package/dist/dashboard/menu.js
CHANGED
|
@@ -62,12 +62,16 @@ var import_external = __toESM(require("../icons/external"));
|
|
|
62
62
|
var import_chart = __toESM(require("../icons/chart"));
|
|
63
63
|
var import_document = __toESM(require("../icons/document"));
|
|
64
64
|
var import_flag = __toESM(require("../icons/flag"));
|
|
65
|
+
var import_flags = __toESM(require("../icons/flags"));
|
|
66
|
+
var import_bolt = __toESM(require("../icons/bolt"));
|
|
65
67
|
var import_home = __toESM(require("../icons/home"));
|
|
68
|
+
var import_image = __toESM(require("../icons/image"));
|
|
66
69
|
var import_link2 = __toESM(require("../icons/link"));
|
|
67
70
|
var import_puzzle_piece = __toESM(require("../icons/puzzle-piece"));
|
|
68
|
-
var
|
|
71
|
+
var import_shop = __toESM(require("../icons/shop"));
|
|
69
72
|
var import_share = __toESM(require("../icons/share"));
|
|
70
73
|
var import_star = __toESM(require("../icons/star"));
|
|
74
|
+
var import_swatch = __toESM(require("../icons/swatch"));
|
|
71
75
|
var import_users = __toESM(require("../icons/users"));
|
|
72
76
|
var import_book_open = __toESM(require("../icons/book-open"));
|
|
73
77
|
var import_lifebuoy = __toESM(require("../icons/lifebuoy"));
|
|
@@ -76,17 +80,24 @@ var import_menu = require("./lib/menu");
|
|
|
76
80
|
const icons = {
|
|
77
81
|
// The rail's three, as the phone menu's rows (MenuRail).
|
|
78
82
|
"book-open": import_book_open.default,
|
|
83
|
+
// The campaign's Workflows and Design rows ( Darren, 2026-11-20 ).
|
|
84
|
+
bolt: import_bolt.default,
|
|
79
85
|
chart: import_chart.default,
|
|
80
86
|
document: import_document.default,
|
|
81
87
|
flag: import_flag.default,
|
|
88
|
+
flags: import_flags.default,
|
|
82
89
|
home: import_home.default,
|
|
90
|
+
// The organization's Library row ( Darren, 2026-11-20 ).
|
|
91
|
+
image: import_image.default,
|
|
83
92
|
lifebuoy: import_lifebuoy.default,
|
|
84
93
|
link: import_link2.default,
|
|
85
94
|
// Connections (Darren, Dulce Local walk, 2026-10-29).
|
|
86
95
|
"puzzle-piece": import_puzzle_piece.default,
|
|
87
|
-
|
|
96
|
+
// The campaign's Shop row ( Darren, 2026-11-20 ).
|
|
97
|
+
shop: import_shop.default,
|
|
88
98
|
share: import_share.default,
|
|
89
99
|
star: import_star.default,
|
|
100
|
+
swatch: import_swatch.default,
|
|
90
101
|
task: import_task.default,
|
|
91
102
|
users: import_users.default
|
|
92
103
|
};
|
package/dist/dashboard/menu.mjs
CHANGED
|
@@ -23,12 +23,16 @@ import External from "../icons/external.mjs";
|
|
|
23
23
|
import Chart from "../icons/chart.mjs";
|
|
24
24
|
import Document from "../icons/document.mjs";
|
|
25
25
|
import Flag from "../icons/flag.mjs";
|
|
26
|
+
import Flags from "../icons/flags.mjs";
|
|
27
|
+
import Bolt from "../icons/bolt.mjs";
|
|
26
28
|
import Home from "../icons/home.mjs";
|
|
29
|
+
import ImageIcon from "../icons/image.mjs";
|
|
27
30
|
import LinkIcon from "../icons/link.mjs";
|
|
28
31
|
import PuzzlePiece from "../icons/puzzle-piece.mjs";
|
|
29
|
-
import
|
|
32
|
+
import ShopIcon from "../icons/shop.mjs";
|
|
30
33
|
import Share from "../icons/share.mjs";
|
|
31
34
|
import Star from "../icons/star.mjs";
|
|
35
|
+
import SwatchIcon from "../icons/swatch.mjs";
|
|
32
36
|
import Users from "../icons/users.mjs";
|
|
33
37
|
import BookOpen from "../icons/book-open.mjs";
|
|
34
38
|
import Lifebuoy from "../icons/lifebuoy.mjs";
|
|
@@ -37,17 +41,24 @@ import { menuRow } from "./lib/menu.mjs";
|
|
|
37
41
|
const icons = {
|
|
38
42
|
// The rail's three, as the phone menu's rows (MenuRail).
|
|
39
43
|
"book-open": BookOpen,
|
|
44
|
+
// The campaign's Workflows and Design rows ( Darren, 2026-11-20 ).
|
|
45
|
+
bolt: Bolt,
|
|
40
46
|
chart: Chart,
|
|
41
47
|
document: Document,
|
|
42
48
|
flag: Flag,
|
|
49
|
+
flags: Flags,
|
|
43
50
|
home: Home,
|
|
51
|
+
// The organization's Library row ( Darren, 2026-11-20 ).
|
|
52
|
+
image: ImageIcon,
|
|
44
53
|
lifebuoy: Lifebuoy,
|
|
45
54
|
link: LinkIcon,
|
|
46
55
|
// Connections (Darren, Dulce Local walk, 2026-10-29).
|
|
47
56
|
"puzzle-piece": PuzzlePiece,
|
|
48
|
-
|
|
57
|
+
// The campaign's Shop row ( Darren, 2026-11-20 ).
|
|
58
|
+
shop: ShopIcon,
|
|
49
59
|
share: Share,
|
|
50
60
|
star: Star,
|
|
61
|
+
swatch: SwatchIcon,
|
|
51
62
|
task: Task,
|
|
52
63
|
users: Users
|
|
53
64
|
};
|