@drawbridge/components 0.1.48 → 0.1.49
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/fields.js +0 -278
- package/dist/bridge/fields.mjs +1 -276
- package/dist/bridge/form-subdomain-shop-modal.js +274 -234
- package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
- package/dist/bridge/form-subdomain.js +0 -7
- package/dist/bridge/form-subdomain.mjs +2 -9
- package/dist/bridge/lib/age-gate.js +0 -12
- package/dist/bridge/lib/age-gate.mjs +0 -11
- package/dist/bridge/lib/checkout-kit.js +32 -2
- package/dist/bridge/lib/checkout-kit.mjs +32 -2
- package/dist/bridge/lib/entry.js +0 -3
- package/dist/bridge/lib/entry.mjs +0 -2
- package/dist/bridge/product-tile.js +6 -9
- package/dist/bridge/product-tile.mjs +6 -9
- package/dist/bridge/template-layout.js +122 -237
- package/dist/bridge/template-layout.mjs +122 -237
- package/dist/bridge/template-modal.js +73 -28
- package/dist/bridge/template-modal.mjs +74 -29
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +2 -7
- package/dist/dashboard/campaign-form.mjs +2 -7
- package/dist/dashboard/card-order.js +4 -22
- package/dist/dashboard/card-order.mjs +4 -22
- package/dist/dashboard/document-blocks.js +17 -4
- package/dist/dashboard/document-blocks.mjs +17 -4
- package/dist/dashboard/form-admin-provider.js +17 -71
- package/dist/dashboard/form-admin-provider.mjs +17 -71
- package/dist/dashboard/form-file-upload.js +2 -3
- package/dist/dashboard/form-file-upload.mjs +3 -4
- package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
- package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
- package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
- package/dist/dashboard/form-organization-campaign.js +0 -82
- package/dist/dashboard/form-organization-campaign.mjs +0 -81
- package/dist/dashboard/form-organization-connection.js +6 -48
- package/dist/dashboard/form-organization-connection.mjs +7 -48
- package/dist/dashboard/form-organization-workflow.js +1 -72
- package/dist/dashboard/form-organization-workflow.mjs +1 -69
- package/dist/dashboard/form-otc.js +5 -4
- package/dist/dashboard/form-otc.mjs +5 -4
- package/dist/dashboard/form-stripe.js +5 -12
- package/dist/dashboard/form-stripe.mjs +5 -12
- package/dist/dashboard/input-fields.js +158 -11
- package/dist/dashboard/input-fields.mjs +158 -11
- package/dist/dashboard/input-file.js +4 -21
- package/dist/dashboard/input-file.mjs +4 -21
- package/dist/dashboard/lib/connection-controls.js +2 -5
- package/dist/dashboard/lib/connection-controls.mjs +1 -3
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/uppy.js +1 -10
- package/dist/dashboard/lib/uppy.mjs +2 -11
- package/dist/dashboard/order-sections.js +6 -456
- package/dist/dashboard/order-sections.mjs +7 -453
- package/dist/dashboard/provider-ui.js +7 -9
- package/dist/dashboard/provider-ui.mjs +7 -9
- package/dist/dashboard/template-ui.js +12 -4
- package/dist/dashboard/template-ui.mjs +12 -4
- package/dist/input-checkbox.js +10 -28
- package/dist/input-checkbox.mjs +10 -28
- package/dist/product.js +24 -96
- package/dist/product.mjs +25 -97
- package/dist/shared/lib/helpers.js +6 -54
- package/dist/shared/lib/helpers.mjs +8 -53
- package/package.json +4 -74
- package/types/bridge/fields.d.ts +2 -14
- package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
- package/types/bridge/lib/age-gate.d.ts +0 -5
- package/types/bridge/lib/checkout-kit.d.ts +10 -2
- package/types/bridge/lib/entry.d.ts +0 -3
- package/types/dashboard/card-order.d.ts +0 -6
- package/types/dashboard/document-blocks.d.ts +3 -2
- package/types/dashboard/form-admin-provider.d.ts +2 -9
- package/types/dashboard/form-file-upload.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
- package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
- package/types/dashboard/form-organization-campaign.d.ts +0 -3
- package/types/dashboard/form-organization-connection.d.ts +0 -11
- package/types/dashboard/form-otc.d.ts +1 -5
- package/types/dashboard/form-stripe.d.ts +2 -3
- package/types/dashboard/input-file.d.ts +0 -2
- package/types/dashboard/order-sections.d.ts +1 -24
- package/types/input-checkbox.d.ts +0 -2
- package/types/shared/lib/helpers.d.ts +0 -4
- package/dist/bridge/cart-drawer.js +0 -152
- package/dist/bridge/cart-drawer.mjs +0 -123
- package/dist/bridge/form-subdomain-checkout.js +0 -687
- package/dist/bridge/form-subdomain-checkout.mjs +0 -665
- package/dist/bridge/lib/cart.js +0 -79
- package/dist/bridge/lib/cart.mjs +0 -48
- package/dist/dashboard/embed-stripe.js +0 -145
- package/dist/dashboard/embed-stripe.mjs +0 -116
- package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
- package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
- package/dist/dashboard/form-organization-product.js +0 -1461
- package/dist/dashboard/form-organization-product.mjs +0 -1425
- package/dist/dashboard/input-gallery.js +0 -201
- package/dist/dashboard/input-gallery.mjs +0 -172
- package/dist/dashboard/lib/products.js +0 -169
- package/dist/dashboard/lib/products.mjs +0 -135
- package/dist/dashboard/lib/settings-paths.js +0 -35
- package/dist/dashboard/lib/settings-paths.mjs +0 -11
- package/dist/dashboard/shipping-rates.js +0 -404
- package/dist/dashboard/shipping-rates.mjs +0 -371
- package/dist/dashboard/template-buyer.js +0 -301
- package/dist/dashboard/template-buyer.mjs +0 -267
- package/dist/shared/order-summary.js +0 -139
- package/dist/shared/order-summary.mjs +0 -110
- package/types/bridge/cart-drawer.d.ts +0 -31
- package/types/bridge/form-subdomain-checkout.d.ts +0 -20
- package/types/bridge/lib/cart.d.ts +0 -44
- package/types/dashboard/embed-stripe.d.ts +0 -25
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
- package/types/dashboard/form-organization-product.d.ts +0 -24
- package/types/dashboard/input-gallery.d.ts +0 -14
- package/types/dashboard/lib/products.d.ts +0 -14
- package/types/dashboard/lib/settings-paths.d.ts +0 -5
- package/types/dashboard/shipping-rates.d.ts +0 -26
- package/types/dashboard/template-buyer.d.ts +0 -50
- package/types/shared/order-summary.d.ts +0 -19
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var input_gallery_exports = {};
|
|
29
|
-
__export(input_gallery_exports, {
|
|
30
|
-
default: () => input_gallery_default
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(input_gallery_exports);
|
|
33
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
-
var import_react = require("react");
|
|
35
|
-
var import_react_hook_form = require("react-hook-form");
|
|
36
|
-
var import_react_query = require("@tanstack/react-query");
|
|
37
|
-
var import_dynamic = __toESM(require("next/dynamic"));
|
|
38
|
-
var import_input_group = __toESM(require("../input-group"));
|
|
39
|
-
var import_input_array = require("./input-array");
|
|
40
|
-
var import_input_file = __toESM(require("./input-file"));
|
|
41
|
-
var import_hooks = require("./lib/hooks");
|
|
42
|
-
var import_loader = require("../shared/loader");
|
|
43
|
-
var import_plus = __toESM(require("../icons/plus"));
|
|
44
|
-
var import_trash = __toESM(require("../icons/trash"));
|
|
45
|
-
const FormReposition = (0, import_dynamic.default)(() => import("./form-reposition"), { loading: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.LoaderDynamic, {}), ssr: false });
|
|
46
|
-
const InputGallery = ({ endpoint, label = "Gallery", name = "gallery", onUpdate, organization, reposition: repositions = false }) => {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
const queryClient = (0, import_react_query.useQueryClient)();
|
|
49
|
-
const modal = (0, import_hooks.useModal)({ queryClient });
|
|
50
|
-
const { control, formState, getValues, setValue } = (0, import_react_hook_form.useFormContext)();
|
|
51
|
-
const gallery = (0, import_react_hook_form.useWatch)({ control, name }) || [];
|
|
52
|
-
const taken = () => (getValues(name) || []).map((item) => {
|
|
53
|
-
var _a2;
|
|
54
|
-
return (_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.id;
|
|
55
|
-
}).filter(Boolean);
|
|
56
|
-
const change = (path, value) => {
|
|
57
|
-
setValue(path, value, { shouldDirty: true });
|
|
58
|
-
onUpdate == null ? void 0 : onUpdate(getValues());
|
|
59
|
-
};
|
|
60
|
-
const reposition = (index) => {
|
|
61
|
-
var _a2, _b2;
|
|
62
|
-
const item = getValues(name + "." + index);
|
|
63
|
-
modal.open({
|
|
64
|
-
message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
65
|
-
FormReposition,
|
|
66
|
-
{
|
|
67
|
-
...{
|
|
68
|
-
file: item == null ? void 0 : item.file,
|
|
69
|
-
onDone: (position) => {
|
|
70
|
-
change(name + "." + index + ".position", position);
|
|
71
|
-
modal.close();
|
|
72
|
-
},
|
|
73
|
-
page: getValues(),
|
|
74
|
-
position: item == null ? void 0 : item.position
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
),
|
|
78
|
-
title: ((_b2 = (_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.mimetype) == null ? void 0 : _b2.includes("video")) ? "Reposition video" : "Reposition photo"
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
-
import_input_group.default,
|
|
83
|
-
{
|
|
84
|
-
...{
|
|
85
|
-
error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[name]) == null ? void 0 : _b.message,
|
|
86
|
-
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
87
|
-
import_input_array.InputArraySortable,
|
|
88
|
-
{
|
|
89
|
-
...{
|
|
90
|
-
control,
|
|
91
|
-
"data-guide": "form-input-gallery",
|
|
92
|
-
empty: "Gallery is empty",
|
|
93
|
-
name,
|
|
94
|
-
onSort: () => onUpdate == null ? void 0 : onUpdate(getValues()),
|
|
95
|
-
renderButton: (append) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
-
import_input_file.default,
|
|
97
|
-
{
|
|
98
|
-
...{
|
|
99
|
-
button: {
|
|
100
|
-
icon: import_plus.default,
|
|
101
|
-
text: "Add gallery item"
|
|
102
|
-
},
|
|
103
|
-
endpoint,
|
|
104
|
-
filters: {
|
|
105
|
-
id: {
|
|
106
|
-
$nin: taken()
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
onChange: (response) => {
|
|
110
|
-
append({ file: response });
|
|
111
|
-
onUpdate == null ? void 0 : onUpdate(getValues());
|
|
112
|
-
},
|
|
113
|
-
organization,
|
|
114
|
-
nullable: false,
|
|
115
|
-
value: null,
|
|
116
|
-
type: "media"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
),
|
|
120
|
-
renderControls: ({ index, remove }) => [
|
|
121
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
|
-
import_input_array.InputArrayControl,
|
|
123
|
-
{
|
|
124
|
-
...{
|
|
125
|
-
onClick: () => {
|
|
126
|
-
remove(index);
|
|
127
|
-
onUpdate == null ? void 0 : onUpdate(getValues());
|
|
128
|
-
},
|
|
129
|
-
icon: import_trash.default
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
"gallery-control-remove-" + index
|
|
133
|
-
)
|
|
134
|
-
]
|
|
135
|
-
},
|
|
136
|
-
children: ({ field, handle, index, update }) => {
|
|
137
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
138
|
-
const item = gallery[index] || field;
|
|
139
|
-
const editable = /^(image|video)\//.test(((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.mimetype) || "");
|
|
140
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
141
|
-
"div",
|
|
142
|
-
{
|
|
143
|
-
...{
|
|
144
|
-
className: "flex items-center min-w-0 flex-1 space-x-3"
|
|
145
|
-
},
|
|
146
|
-
children: [
|
|
147
|
-
handle,
|
|
148
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
149
|
-
import_input_group.default,
|
|
150
|
-
{
|
|
151
|
-
...{
|
|
152
|
-
error: ((_e = (_d = (_c = (_b2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _b2[name]) == null ? void 0 : _c[index]) == null ? void 0 : _d.file) == null ? void 0 : _e.message) || ((_i = (_h = (_g = (_f = formState == null ? void 0 : formState.errors) == null ? void 0 : _f[name]) == null ? void 0 : _g[index]) == null ? void 0 : _h.description) == null ? void 0 : _i.message),
|
|
153
|
-
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
154
|
-
import_input_file.default,
|
|
155
|
-
{
|
|
156
|
-
...{
|
|
157
|
-
// The item's own description and crop.
|
|
158
|
-
description: item == null ? void 0 : item.description,
|
|
159
|
-
edited: Boolean(item == null ? void 0 : item.position),
|
|
160
|
-
endpoint,
|
|
161
|
-
filters: {
|
|
162
|
-
id: {
|
|
163
|
-
$nin: taken()
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
// Another file is another item: no description, no crop.
|
|
167
|
-
onChange: (response) => {
|
|
168
|
-
update(
|
|
169
|
-
index,
|
|
170
|
-
{
|
|
171
|
-
file: response
|
|
172
|
-
}
|
|
173
|
-
);
|
|
174
|
-
onUpdate == null ? void 0 : onUpdate(getValues());
|
|
175
|
-
},
|
|
176
|
-
onDescription: (text) => change(name + "." + index + ".description", text),
|
|
177
|
-
...repositions && editable && {
|
|
178
|
-
onEdit: () => reposition(index)
|
|
179
|
-
},
|
|
180
|
-
organization,
|
|
181
|
-
nullable: false,
|
|
182
|
-
value: item == null ? void 0 : item.file,
|
|
183
|
-
type: "media"
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
)
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
]
|
|
191
|
-
}
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
),
|
|
196
|
-
label
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
) });
|
|
200
|
-
};
|
|
201
|
-
var input_gallery_default = InputGallery;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment } from "react";
|
|
3
|
-
import { useFormContext, useWatch } from "react-hook-form";
|
|
4
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
5
|
-
import dynamic from "next/dynamic";
|
|
6
|
-
import InputGroup from "../input-group.mjs";
|
|
7
|
-
import { InputArrayControl, InputArraySortable } from "./input-array.mjs";
|
|
8
|
-
import InputFile from "./input-file.mjs";
|
|
9
|
-
import { useModal } from "./lib/hooks.mjs";
|
|
10
|
-
import { LoaderDynamic } from "../shared/loader.mjs";
|
|
11
|
-
import Plus from "../icons/plus.mjs";
|
|
12
|
-
import Trash from "../icons/trash.mjs";
|
|
13
|
-
const FormReposition = dynamic(() => import("./form-reposition.mjs"), { loading: () => /* @__PURE__ */ jsx(LoaderDynamic, {}), ssr: false });
|
|
14
|
-
const InputGallery = ({ endpoint, label = "Gallery", name = "gallery", onUpdate, organization, reposition: repositions = false }) => {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
const queryClient = useQueryClient();
|
|
17
|
-
const modal = useModal({ queryClient });
|
|
18
|
-
const { control, formState, getValues, setValue } = useFormContext();
|
|
19
|
-
const gallery = useWatch({ control, name }) || [];
|
|
20
|
-
const taken = () => (getValues(name) || []).map((item) => {
|
|
21
|
-
var _a2;
|
|
22
|
-
return (_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.id;
|
|
23
|
-
}).filter(Boolean);
|
|
24
|
-
const change = (path, value) => {
|
|
25
|
-
setValue(path, value, { shouldDirty: true });
|
|
26
|
-
onUpdate == null ? void 0 : onUpdate(getValues());
|
|
27
|
-
};
|
|
28
|
-
const reposition = (index) => {
|
|
29
|
-
var _a2, _b2;
|
|
30
|
-
const item = getValues(name + "." + index);
|
|
31
|
-
modal.open({
|
|
32
|
-
message: /* @__PURE__ */ jsx(
|
|
33
|
-
FormReposition,
|
|
34
|
-
{
|
|
35
|
-
...{
|
|
36
|
-
file: item == null ? void 0 : item.file,
|
|
37
|
-
onDone: (position) => {
|
|
38
|
-
change(name + "." + index + ".position", position);
|
|
39
|
-
modal.close();
|
|
40
|
-
},
|
|
41
|
-
page: getValues(),
|
|
42
|
-
position: item == null ? void 0 : item.position
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
),
|
|
46
|
-
title: ((_b2 = (_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.mimetype) == null ? void 0 : _b2.includes("video")) ? "Reposition video" : "Reposition photo"
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
50
|
-
InputGroup,
|
|
51
|
-
{
|
|
52
|
-
...{
|
|
53
|
-
error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[name]) == null ? void 0 : _b.message,
|
|
54
|
-
input: /* @__PURE__ */ jsx(
|
|
55
|
-
InputArraySortable,
|
|
56
|
-
{
|
|
57
|
-
...{
|
|
58
|
-
control,
|
|
59
|
-
"data-guide": "form-input-gallery",
|
|
60
|
-
empty: "Gallery is empty",
|
|
61
|
-
name,
|
|
62
|
-
onSort: () => onUpdate == null ? void 0 : onUpdate(getValues()),
|
|
63
|
-
renderButton: (append) => /* @__PURE__ */ jsx(
|
|
64
|
-
InputFile,
|
|
65
|
-
{
|
|
66
|
-
...{
|
|
67
|
-
button: {
|
|
68
|
-
icon: Plus,
|
|
69
|
-
text: "Add gallery item"
|
|
70
|
-
},
|
|
71
|
-
endpoint,
|
|
72
|
-
filters: {
|
|
73
|
-
id: {
|
|
74
|
-
$nin: taken()
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
onChange: (response) => {
|
|
78
|
-
append({ file: response });
|
|
79
|
-
onUpdate == null ? void 0 : onUpdate(getValues());
|
|
80
|
-
},
|
|
81
|
-
organization,
|
|
82
|
-
nullable: false,
|
|
83
|
-
value: null,
|
|
84
|
-
type: "media"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
),
|
|
88
|
-
renderControls: ({ index, remove }) => [
|
|
89
|
-
/* @__PURE__ */ jsx(
|
|
90
|
-
InputArrayControl,
|
|
91
|
-
{
|
|
92
|
-
...{
|
|
93
|
-
onClick: () => {
|
|
94
|
-
remove(index);
|
|
95
|
-
onUpdate == null ? void 0 : onUpdate(getValues());
|
|
96
|
-
},
|
|
97
|
-
icon: Trash
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"gallery-control-remove-" + index
|
|
101
|
-
)
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
|
-
children: ({ field, handle, index, update }) => {
|
|
105
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
106
|
-
const item = gallery[index] || field;
|
|
107
|
-
const editable = /^(image|video)\//.test(((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.mimetype) || "");
|
|
108
|
-
return /* @__PURE__ */ jsxs(
|
|
109
|
-
"div",
|
|
110
|
-
{
|
|
111
|
-
...{
|
|
112
|
-
className: "flex items-center min-w-0 flex-1 space-x-3"
|
|
113
|
-
},
|
|
114
|
-
children: [
|
|
115
|
-
handle,
|
|
116
|
-
/* @__PURE__ */ jsx(
|
|
117
|
-
InputGroup,
|
|
118
|
-
{
|
|
119
|
-
...{
|
|
120
|
-
error: ((_e = (_d = (_c = (_b2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _b2[name]) == null ? void 0 : _c[index]) == null ? void 0 : _d.file) == null ? void 0 : _e.message) || ((_i = (_h = (_g = (_f = formState == null ? void 0 : formState.errors) == null ? void 0 : _f[name]) == null ? void 0 : _g[index]) == null ? void 0 : _h.description) == null ? void 0 : _i.message),
|
|
121
|
-
input: /* @__PURE__ */ jsx(
|
|
122
|
-
InputFile,
|
|
123
|
-
{
|
|
124
|
-
...{
|
|
125
|
-
// The item's own description and crop.
|
|
126
|
-
description: item == null ? void 0 : item.description,
|
|
127
|
-
edited: Boolean(item == null ? void 0 : item.position),
|
|
128
|
-
endpoint,
|
|
129
|
-
filters: {
|
|
130
|
-
id: {
|
|
131
|
-
$nin: taken()
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
// Another file is another item: no description, no crop.
|
|
135
|
-
onChange: (response) => {
|
|
136
|
-
update(
|
|
137
|
-
index,
|
|
138
|
-
{
|
|
139
|
-
file: response
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
onUpdate == null ? void 0 : onUpdate(getValues());
|
|
143
|
-
},
|
|
144
|
-
onDescription: (text) => change(name + "." + index + ".description", text),
|
|
145
|
-
...repositions && editable && {
|
|
146
|
-
onEdit: () => reposition(index)
|
|
147
|
-
},
|
|
148
|
-
organization,
|
|
149
|
-
nullable: false,
|
|
150
|
-
value: item == null ? void 0 : item.file,
|
|
151
|
-
type: "media"
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
)
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
),
|
|
164
|
-
label
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
) });
|
|
168
|
-
};
|
|
169
|
-
var input_gallery_default = InputGallery;
|
|
170
|
-
export {
|
|
171
|
-
input_gallery_default as default
|
|
172
|
-
};
|
|
@@ -1,169 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,135 +0,0 @@
|
|
|
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
|
-
};
|