@printine/pod-editor 0.1.20 → 0.1.23
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/README.md +8 -0
- package/dist/components/context.d.ts +7 -0
- package/dist/components/menus/sca.d.ts +2 -4
- package/dist/components/personalization-background.d.ts +6 -0
- package/dist/components/personalization-controller.d.ts +2 -0
- package/dist/components/personalization-preview.d.ts +5 -0
- package/dist/components/personalization-shared.d.ts +3 -0
- package/dist/components/placement-texture-cache.d.ts +20 -0
- package/dist/components/preview/real-time/index.d.ts +2 -1
- package/dist/components/semi-deisgn-config.d.ts +8 -2
- package/dist/components/semi-renderer.d.ts +4 -0
- package/dist/{design-Ce0Lyr8f.js → design-D5jmLHez.js} +8687 -8449
- package/dist/designer-store-BZFMaojO.js +261 -0
- package/dist/engine/constants.js +1 -1
- package/dist/engine/events.d.ts +6 -0
- package/dist/engine/managers/event.js +1 -1
- package/dist/full-designer.js +2 -2
- package/dist/i18n/personalization.d.ts +3 -0
- package/dist/index.js +5 -5
- package/dist/lib/personalization.d.ts +78 -0
- package/dist/personalization-preview-BonjWg50.js +352 -0
- package/dist/semi-interact-editor-BUWPFgWU.js +1469 -0
- package/dist/semi-renderer.js +1 -1
- package/dist/state/designer-store.d.ts +2 -0
- package/dist/state/designer-store.js +1 -1
- package/dist/style.css +1 -1
- package/docs/BUYER_PERSONALIZATION.md +137 -0
- package/docs/SEMI_RENDERER.md +16 -0
- package/package.json +5 -3
- package/dist/designer-store-Da9fICz8.js +0 -153
- package/dist/semi-interact-editor-DpzQN5ZB.js +0 -1422
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { jsx as r, jsxs as c, Fragment as ke } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as me, useState as f, useRef as C, useEffect as pe } from "react";
|
|
3
|
+
import { d as V, e as Ce, u as Pe, f as Ee, g as Se, h as je, i as a, j as Le, k as Re, A as $e, L as Ie, l as Me } from "./design-D5jmLHez.js";
|
|
4
|
+
import { a as he, p as Te, b as Fe, c as K, d as ze } from "./designer-store-BZFMaojO.js";
|
|
5
|
+
import { a as Be, P as _e } from "./semi-interact-editor-BUWPFgWU.js";
|
|
6
|
+
/**
|
|
7
|
+
* @license lucide-react v0.545.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
const Oe = [
|
|
13
|
+
["path", { d: "M16 5h6", key: "1vod17" }],
|
|
14
|
+
["path", { d: "M19 2v6", key: "4bpg5p" }],
|
|
15
|
+
["path", { d: "M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5", key: "1ue2ih" }],
|
|
16
|
+
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }],
|
|
17
|
+
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }]
|
|
18
|
+
], Ae = V("image-plus", Oe);
|
|
19
|
+
/**
|
|
20
|
+
* @license lucide-react v0.545.0 - ISC
|
|
21
|
+
*
|
|
22
|
+
* This source code is licensed under the ISC license.
|
|
23
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
24
|
+
*/
|
|
25
|
+
const De = [
|
|
26
|
+
["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
|
|
27
|
+
["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
|
|
28
|
+
["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
|
|
29
|
+
], Ue = V("monitor", De);
|
|
30
|
+
/**
|
|
31
|
+
* @license lucide-react v0.545.0 - ISC
|
|
32
|
+
*
|
|
33
|
+
* This source code is licensed under the ISC license.
|
|
34
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
35
|
+
*/
|
|
36
|
+
const Ve = [
|
|
37
|
+
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
|
|
38
|
+
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
39
|
+
], Ye = V("rotate-ccw", Ve);
|
|
40
|
+
/**
|
|
41
|
+
* @license lucide-react v0.545.0 - ISC
|
|
42
|
+
*
|
|
43
|
+
* This source code is licensed under the ISC license.
|
|
44
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
+
*/
|
|
46
|
+
const qe = [
|
|
47
|
+
["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2", key: "1yt0o3" }],
|
|
48
|
+
["path", { d: "M12 18h.01", key: "mhygvu" }]
|
|
49
|
+
], He = V("smartphone", qe);
|
|
50
|
+
function We(u, S) {
|
|
51
|
+
const t = S[u.name]?.workspaceMetadata?.width || u.width || 800, w = S[u.name]?.workspaceMetadata?.height || u.height || 800, p = document.createElement("canvas"), z = Math.min(1, 768 / Math.max(t, w));
|
|
52
|
+
p.width = Math.max(1, Math.round(t * z)), p.height = Math.max(1, Math.round(w * z));
|
|
53
|
+
const j = p.getContext("2d");
|
|
54
|
+
j.fillStyle = "#ffffff", j.fillRect(0, 0, p.width, p.height);
|
|
55
|
+
const g = p.toDataURL("image/png");
|
|
56
|
+
return { id: `placement-${u.name}`, image: g, defaultPrintColor: u.defaultPrintColor, render_areas: [{
|
|
57
|
+
id: -1,
|
|
58
|
+
name: "bg",
|
|
59
|
+
image: g,
|
|
60
|
+
design: 0,
|
|
61
|
+
width: t,
|
|
62
|
+
height: w,
|
|
63
|
+
x: 0,
|
|
64
|
+
y: 0,
|
|
65
|
+
texture: ""
|
|
66
|
+
}, {
|
|
67
|
+
id: 0,
|
|
68
|
+
name: u.name,
|
|
69
|
+
image: g,
|
|
70
|
+
design: 1,
|
|
71
|
+
area: u,
|
|
72
|
+
width: t,
|
|
73
|
+
height: w,
|
|
74
|
+
x: 0,
|
|
75
|
+
y: 0,
|
|
76
|
+
texture: "",
|
|
77
|
+
texture_transform: { space: "view-pixels", textureSize: [t, w], vertices: [0, 0, t, 0, 0, w, t, w], uvs: [0, 0, 1, 0, 0, 1, 1, 1], indices: [0, 1, 2, 1, 3, 2], blendMode: "normal", opacity: 1 }
|
|
78
|
+
}] };
|
|
79
|
+
}
|
|
80
|
+
function Ze({ initialData: u, onClose: S }) {
|
|
81
|
+
const t = Ce("design"), { onError: w } = Pe(), { plateData: p, productData: z, currentViewName: j } = Ee(), g = he((e) => e.semiCustomBackground), L = me(() => Te(Fe(u, p.areas)), [u, p.areas]), R = me(() => p.renders.length ? p.renders : p.areas.map((e) => We(e, u)), [p, u]), ge = Math.max(0, R.findIndex((e) => e.render_areas.some((i) => i.area?.name === j))), J = () => Object.fromEntries(L.map((e) => [e.key, e.kind === "text" ? String(e.targets[0].object.__rawText ?? e.targets[0].object.text ?? "") : String(e.targets[0].object.src || e.targets[0].object.originSrc || "")])), [M, Q] = f(u), T = C(M);
|
|
82
|
+
T.current = M;
|
|
83
|
+
const [N, B] = f(J), [Y, Z] = f(() => window.innerWidth < 600), [q, ee] = f(ge), [ye, be] = f(!0), [te, _] = f(""), [re, ne] = f({}), [ae, ve] = f(""), ie = g.colors.includes(u[j]?.color) ? u[j].color : g.colors[0] || "#ffffff", [F, H] = f(ie), [b, W] = f(null), O = C(null), oe = C(Promise.resolve()), v = C({}), A = C({}), x = C(0), P = C(!0), se = C([]), ce = C(null), fe = he((e) => e.fontList), E = R[q] || R[0], X = (e) => [...new Set(e.render_areas.filter((i) => i.design).map((i) => {
|
|
84
|
+
const n = p.areas.find((o) => o.name === i.area?.name);
|
|
85
|
+
return n?.display_name || n?.name || i.name;
|
|
86
|
+
}))].join(" + ");
|
|
87
|
+
pe(() => (P.current = !0, () => {
|
|
88
|
+
P.current = !1, x.current++, se.current.forEach((e) => URL.revokeObjectURL(e));
|
|
89
|
+
}), []), pe(() => {
|
|
90
|
+
_("");
|
|
91
|
+
}, [q]);
|
|
92
|
+
const D = (e) => {
|
|
93
|
+
const i = e(T.current);
|
|
94
|
+
T.current = i, Q(i);
|
|
95
|
+
}, le = (e) => {
|
|
96
|
+
const i = R.findIndex((n) => n.render_areas.some((o) => o.area?.name === e));
|
|
97
|
+
i >= 0 && ee(i);
|
|
98
|
+
}, we = (e) => `buyer-field-${L.indexOf(e)}`, $ = (e, i) => ne((n) => ({ ...n, [e]: i })), U = (e, i) => {
|
|
99
|
+
const n = e.key, o = (v.current[n] || 0) + 1, l = x.current;
|
|
100
|
+
v.current[n] = o, A.current[n] = { text: N[n] ?? "", ...A.current[n], ...i };
|
|
101
|
+
const d = { ...A.current[n] };
|
|
102
|
+
$(n, ""), oe.current = oe.current.then(async () => {
|
|
103
|
+
if (!P.current || l !== x.current || v.current[n] !== o) return;
|
|
104
|
+
const m = [];
|
|
105
|
+
for (const y of e.targets) {
|
|
106
|
+
const I = T.current[y.placement].objects.find((h) => String(h.id) === y.id), s = await O.current?.updateText(I, d);
|
|
107
|
+
if (!s) throw new Error(t("Could not update the preview. Try again."));
|
|
108
|
+
m.push(s);
|
|
109
|
+
}
|
|
110
|
+
P.current && l === x.current && v.current[n] === o && D((y) => K(y, e.targets, m));
|
|
111
|
+
}).catch((m) => {
|
|
112
|
+
P.current && l === x.current && v.current[n] === o && $(n, m instanceof Error ? m.message : t("Could not update the preview. Try again."));
|
|
113
|
+
});
|
|
114
|
+
}, de = async (e, i) => {
|
|
115
|
+
const n = e.key, o = (v.current[n] || 0) + 1, l = x.current;
|
|
116
|
+
v.current[n] = o, $(n, "");
|
|
117
|
+
try {
|
|
118
|
+
const d = new window.Image();
|
|
119
|
+
if (d.crossOrigin = "anonymous", await new Promise((m, y) => {
|
|
120
|
+
d.onload = () => m(), d.onerror = () => y(new Error(t("Could not load this image."))), d.src = i;
|
|
121
|
+
}), !P.current || l !== x.current || v.current[n] !== o) return;
|
|
122
|
+
D((m) => K(m, e.targets, e.targets.map((y) => {
|
|
123
|
+
const I = m[y.placement].objects.find((s) => String(s.id) === y.id);
|
|
124
|
+
return ze(I, i, d.naturalWidth, d.naturalHeight);
|
|
125
|
+
}))), B((m) => ({ ...m, [n]: i })), le(e.targets[0].placement);
|
|
126
|
+
} catch (d) {
|
|
127
|
+
P.current && l === x.current && v.current[n] === o && $(n, d instanceof Error ? d.message : t("Could not load this image."));
|
|
128
|
+
}
|
|
129
|
+
}, Ne = () => {
|
|
130
|
+
x.current++, A.current = {}, v.current = {}, T.current = u, Q(u), B(J()), ne({}), H(ie);
|
|
131
|
+
}, xe = (e, i) => {
|
|
132
|
+
if (e.kind === "text") U(e, { fill: i });
|
|
133
|
+
else {
|
|
134
|
+
const n = (o) => ({ ...o, fill: i, ...Array.isArray(o.objects) ? { objects: o.objects.map(n) } : {} });
|
|
135
|
+
D((o) => K(o, e.targets, e.targets.map((l) => n(o[l.placement].objects.find((d) => String(d.id) === l.id)))));
|
|
136
|
+
}
|
|
137
|
+
}, ue = L.find((e) => e.kind === "text" && e.targets.some((i) => E?.render_areas.some((n) => n.area?.name === i.placement)));
|
|
138
|
+
return /* @__PURE__ */ r(Se, { open: !0, onOpenChange: (e) => {
|
|
139
|
+
e || S();
|
|
140
|
+
}, children: /* @__PURE__ */ c(je, { className: a.previewDialog, showCloseButton: !1, onOpenAutoFocus: (e) => {
|
|
141
|
+
e.preventDefault(), ce.current?.focus();
|
|
142
|
+
}, "aria-describedby": "buyer-preview-description", children: [
|
|
143
|
+
/* @__PURE__ */ c("header", { className: a.previewHeader, children: [
|
|
144
|
+
/* @__PURE__ */ c("div", { className: a.previewHeading, children: [
|
|
145
|
+
/* @__PURE__ */ r(Le, { children: t("Preview buyer experience") }),
|
|
146
|
+
/* @__PURE__ */ r(Re, { id: "buyer-preview-description", children: t("Try the fields buyers will see. Your template stays unchanged.") })
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ c("div", { className: a.previewActions, children: [
|
|
149
|
+
/* @__PURE__ */ c("div", { className: a.deviceToggle, "aria-label": t("Preview device"), children: [
|
|
150
|
+
/* @__PURE__ */ c("button", { type: "button", "aria-pressed": !Y, onClick: () => Z(!1), children: [
|
|
151
|
+
/* @__PURE__ */ r(Ue, { size: 14 }),
|
|
152
|
+
t("Desktop")
|
|
153
|
+
] }),
|
|
154
|
+
/* @__PURE__ */ c("button", { type: "button", "aria-pressed": Y, onClick: () => Z(!0), children: [
|
|
155
|
+
/* @__PURE__ */ r(He, { size: 14 }),
|
|
156
|
+
t("Mobile")
|
|
157
|
+
] })
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ c("button", { type: "button", className: `${a.secondaryButton} ${a.resetPreview}`, onClick: Ne, children: [
|
|
160
|
+
/* @__PURE__ */ r(Ye, { size: 13 }),
|
|
161
|
+
t("Reset preview")
|
|
162
|
+
] }),
|
|
163
|
+
/* @__PURE__ */ c("button", { type: "button", className: a.secondaryButton, onClick: S, children: [
|
|
164
|
+
/* @__PURE__ */ r($e, { size: 14 }),
|
|
165
|
+
t("Back to settings")
|
|
166
|
+
] })
|
|
167
|
+
] })
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ r("div", { className: a.previewBody, ref: ce, tabIndex: -1, children: /* @__PURE__ */ c("div", { className: `${a.store} ${Y ? a.phone : ""}`, children: [
|
|
170
|
+
/* @__PURE__ */ c("div", { className: a.storeHeader, children: [
|
|
171
|
+
/* @__PURE__ */ r("strong", { children: z.product.title || t("Your product") }),
|
|
172
|
+
/* @__PURE__ */ r("span", { children: t("BUYER EXPERIENCE") })
|
|
173
|
+
] }),
|
|
174
|
+
/* @__PURE__ */ c("div", { className: a.storeGrid, children: [
|
|
175
|
+
/* @__PURE__ */ c("section", { className: a.visual, "aria-label": t("Product preview"), children: [
|
|
176
|
+
/* @__PURE__ */ c("div", { className: a.render, children: [
|
|
177
|
+
E && /* @__PURE__ */ r(
|
|
178
|
+
Be,
|
|
179
|
+
{
|
|
180
|
+
ref: O,
|
|
181
|
+
render: E,
|
|
182
|
+
designData: M,
|
|
183
|
+
colorMode: "placement",
|
|
184
|
+
backgroundColor: g.enable ? F : void 0,
|
|
185
|
+
style: { width: "100%", height: "100%" },
|
|
186
|
+
onLoadingChange: be,
|
|
187
|
+
alt: t("Product preview"),
|
|
188
|
+
onRendered: (e) => {
|
|
189
|
+
ve(e.url), _("");
|
|
190
|
+
},
|
|
191
|
+
onError: (e) => {
|
|
192
|
+
_(t("The preview could not be rendered.")), w?.({ code: "BUYER_PREVIEW_RENDER_FAILED", message: e.message, cause: e });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
te && /* @__PURE__ */ r("div", { className: a.renderError, role: "alert", children: /* @__PURE__ */ c("div", { children: [
|
|
197
|
+
te,
|
|
198
|
+
/* @__PURE__ */ r("br", {}),
|
|
199
|
+
/* @__PURE__ */ r("button", { type: "button", className: a.secondaryButton, onClick: () => {
|
|
200
|
+
_(""), O.current?.refresh();
|
|
201
|
+
}, children: t("Retry preview") })
|
|
202
|
+
] }) })
|
|
203
|
+
] }),
|
|
204
|
+
/* @__PURE__ */ r("div", { className: a.renderLabel, role: "status", children: ye ? t("Rendering…") : `${t(p.renders.length ? "Product preview" : "Print area preview")} · ${E ? X(E) : ""}` }),
|
|
205
|
+
/* @__PURE__ */ r("div", { className: a.viewTabs, children: R.map((e, i) => /* @__PURE__ */ c("button", { type: "button", "aria-pressed": i === q, onClick: () => ee(i), children: [
|
|
206
|
+
X(e) || t("View"),
|
|
207
|
+
" ",
|
|
208
|
+
R.length > 1 ? i + 1 : ""
|
|
209
|
+
] }, e.id)) })
|
|
210
|
+
] }),
|
|
211
|
+
/* @__PURE__ */ c("section", { className: a.buyerForm, "aria-label": t("Buyer personalization fields"), children: [
|
|
212
|
+
/* @__PURE__ */ c("div", { className: a.mobileLive, children: [
|
|
213
|
+
/* @__PURE__ */ c("div", { children: [
|
|
214
|
+
/* @__PURE__ */ c("strong", { children: [
|
|
215
|
+
E ? X(E) : "",
|
|
216
|
+
" · ",
|
|
217
|
+
t("Live preview")
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ r("p", { children: ue ? N[ue.key] : t("Changes appear here as you edit.") })
|
|
220
|
+
] }),
|
|
221
|
+
ae && /* @__PURE__ */ r("img", { src: ae, alt: t("Live preview") })
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ r("div", { className: a.eyebrow, children: t("MAKE IT YOURS") }),
|
|
224
|
+
/* @__PURE__ */ r("h2", { className: a.buyerTitle, children: t("A little more you.") }),
|
|
225
|
+
/* @__PURE__ */ r("p", { className: a.buyerDescription, children: t("Personalize the details below and see your product update.") }),
|
|
226
|
+
!L.length && !g.enable && /* @__PURE__ */ c("div", { className: a.emptyPreview, children: [
|
|
227
|
+
/* @__PURE__ */ r(Ie, { size: 26 }),
|
|
228
|
+
/* @__PURE__ */ r("h3", { children: t("No personalization configured") }),
|
|
229
|
+
/* @__PURE__ */ r("p", { children: t("Buyers will see the fixed template. Enable a field to try it here.") }),
|
|
230
|
+
/* @__PURE__ */ r("button", { type: "button", className: a.primaryButton, onClick: S, children: t("Back to settings") })
|
|
231
|
+
] }),
|
|
232
|
+
L.map((e) => {
|
|
233
|
+
const i = e.targets[0], n = e.config, o = e.key, l = we(e), d = M[i.placement]?.objects.find((s) => String(s.id) === i.id) || i.object, m = Number(n.maxCount) > 0 ? Number(n.maxCount) : void 0, y = Array.isArray(n.options) ? n.options.filter((s) => String(s.value || "").trim()) : [], I = n.optionalFontList || [];
|
|
234
|
+
return /* @__PURE__ */ c("div", { className: a.buyerField, onFocusCapture: () => le(i.placement), children: [
|
|
235
|
+
/* @__PURE__ */ c("div", { className: a.buyerFieldHeading, children: [
|
|
236
|
+
/* @__PURE__ */ r("label", { htmlFor: l, children: n.name || i.name || t("Personalization") }),
|
|
237
|
+
/* @__PURE__ */ r("span", { className: a.badge, children: [...new Set(e.targets.map((s) => s.placementLabel))].join(" + ") })
|
|
238
|
+
] }),
|
|
239
|
+
n.description && /* @__PURE__ */ r("p", { className: a.buyerDescription, children: n.description }),
|
|
240
|
+
e.kind === "text" && /* @__PURE__ */ c(ke, { children: [
|
|
241
|
+
n.enableOption ? /* @__PURE__ */ c("select", { id: l, className: a.buyerInput, value: N[o], onChange: (s) => {
|
|
242
|
+
B((h) => ({ ...h, [o]: s.target.value })), U(e, { text: s.target.value });
|
|
243
|
+
}, children: [
|
|
244
|
+
!y.some((s) => s.value === N[o]) && /* @__PURE__ */ r("option", { value: N[o], children: N[o] || t("Template text") }),
|
|
245
|
+
y.map((s) => /* @__PURE__ */ r("option", { value: s.value, children: s.value }, s.id))
|
|
246
|
+
] }) : /* @__PURE__ */ r(
|
|
247
|
+
"input",
|
|
248
|
+
{
|
|
249
|
+
id: l,
|
|
250
|
+
className: a.buyerInput,
|
|
251
|
+
value: N[o],
|
|
252
|
+
maxLength: m,
|
|
253
|
+
"aria-describedby": `${l}-help`,
|
|
254
|
+
placeholder: n.hintText || "",
|
|
255
|
+
onChange: (s) => {
|
|
256
|
+
const h = m ? [...s.target.value].slice(0, m).join("") : s.target.value;
|
|
257
|
+
B((k) => ({ ...k, [o]: h })), U(e, { text: h });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
/* @__PURE__ */ c("div", { className: a.buyerHelp, id: `${l}-help`, children: [
|
|
262
|
+
/* @__PURE__ */ r("span", { children: n.hintText || t("Your text appears on the product.") }),
|
|
263
|
+
/* @__PURE__ */ c("span", { children: [
|
|
264
|
+
[...N[o] || ""].length,
|
|
265
|
+
m ? ` / ${m}` : ""
|
|
266
|
+
] })
|
|
267
|
+
] }),
|
|
268
|
+
n.enableOptionalFont && /* @__PURE__ */ c("div", { className: a.field, style: { marginTop: 12 }, children: [
|
|
269
|
+
/* @__PURE__ */ r("label", { htmlFor: `${l}-font`, children: t("Fonts") }),
|
|
270
|
+
/* @__PURE__ */ c("select", { id: `${l}-font`, className: a.buyerInput, value: d.fontFamily || "", onChange: (s) => {
|
|
271
|
+
const k = (I.find((G) => G.family === s.target.value) || fe.find((G) => G.family === s.target.value))?.files?.[0];
|
|
272
|
+
U(e, { fontFamily: s.target.value, ...k ? { fontPath: k.url, fontWeight: k.weight, fontStyle: k.style } : {} });
|
|
273
|
+
}, children: [
|
|
274
|
+
/* @__PURE__ */ r("option", { value: i.object.fontFamily || "", children: i.object.fontFamily || t("Template font") }),
|
|
275
|
+
I.filter((s) => s.family !== i.object.fontFamily).map((s) => /* @__PURE__ */ r("option", { value: s.family, children: s.family }, s.family))
|
|
276
|
+
] })
|
|
277
|
+
] })
|
|
278
|
+
] }),
|
|
279
|
+
e.kind === "image" && (n.enableOption ? /* @__PURE__ */ r("div", { className: a.imageOptions, "aria-label": n.name, children: y.map((s, h) => /* @__PURE__ */ r("button", { type: "button", className: a.imageOption, "aria-label": `${t("Image option")} ${h + 1}`, "aria-pressed": N[o] === s.value, onClick: () => {
|
|
280
|
+
de(e, s.value);
|
|
281
|
+
}, children: /* @__PURE__ */ r("img", { src: s.thumbnailUrl || s.value, alt: "" }) }, s.id)) }) : /* @__PURE__ */ c("div", { className: a.uploadPreview, children: [
|
|
282
|
+
/* @__PURE__ */ r("img", { src: d.src || d.originSrc, alt: t("Selected image") }),
|
|
283
|
+
/* @__PURE__ */ c("label", { className: a.uploadLabel, htmlFor: l, children: [
|
|
284
|
+
/* @__PURE__ */ r(Ae, { size: 15 }),
|
|
285
|
+
t("Choose an image"),
|
|
286
|
+
/* @__PURE__ */ r("input", { id: l, type: "file", accept: "image/jpeg,image/png,image/webp", onChange: (s) => {
|
|
287
|
+
const h = s.target.files?.[0];
|
|
288
|
+
if (s.target.value = "", !h) return;
|
|
289
|
+
if (!["image/jpeg", "image/png", "image/webp"].includes(h.type)) {
|
|
290
|
+
$(o, t("Supported formats: JPG, PNG, WEBP"));
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (h.size > 20 * 1024 * 1024) {
|
|
294
|
+
$(o, t("Image size must not exceed 20MB"));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const k = URL.createObjectURL(h);
|
|
298
|
+
se.current.push(k), de(e, k);
|
|
299
|
+
} })
|
|
300
|
+
] }),
|
|
301
|
+
/* @__PURE__ */ r("p", { children: t("Local preview only. Images are not uploaded.") })
|
|
302
|
+
] })),
|
|
303
|
+
n.enableColor && e.kind !== "image" && /* @__PURE__ */ c("div", { className: a.field, style: { marginTop: 13 }, children: [
|
|
304
|
+
/* @__PURE__ */ r("label", { htmlFor: `${l}-color`, children: t("Color") }),
|
|
305
|
+
/* @__PURE__ */ r("input", { id: `${l}-color`, type: "color", value: /^#[a-f\d]{6}$/i.test(d.fill) ? d.fill : "#344833", onChange: (s) => xe(e, s.target.value) })
|
|
306
|
+
] }),
|
|
307
|
+
n.moveable && /* @__PURE__ */ r("button", { type: "button", className: a.secondaryButton, style: { marginTop: 12 }, onClick: () => W({ placement: i.placement, id: i.id }), children: t("Move, resize or rotate") }),
|
|
308
|
+
re[o] && /* @__PURE__ */ r("p", { className: a.error, role: "alert", children: re[o] })
|
|
309
|
+
] }, o);
|
|
310
|
+
}),
|
|
311
|
+
g.enable && /* @__PURE__ */ c("div", { className: a.buyerField, children: [
|
|
312
|
+
/* @__PURE__ */ c("div", { className: a.buyerFieldHeading, children: [
|
|
313
|
+
/* @__PURE__ */ r("label", { children: t("Background color") }),
|
|
314
|
+
/* @__PURE__ */ r("span", { className: a.badge, children: t("All print areas") })
|
|
315
|
+
] }),
|
|
316
|
+
/* @__PURE__ */ r("div", { className: a.buyerPalette, children: g.colors.map((e) => /* @__PURE__ */ r("button", { type: "button", className: a.buyerSwatch, style: { background: e }, "aria-label": `${t("Background color")} ${e}`, "aria-pressed": F === e, onClick: () => H(e) }, e)) }),
|
|
317
|
+
g.palette && /* @__PURE__ */ c("label", { className: a.checkbox, children: [
|
|
318
|
+
t("Custom color"),
|
|
319
|
+
/* @__PURE__ */ r("input", { "aria-label": t("Custom background color"), type: "color", value: /^#[a-f\d]{6}$/i.test(F) ? F : "#ffffff", onChange: (e) => H(e.target.value) })
|
|
320
|
+
] }),
|
|
321
|
+
/* @__PURE__ */ r("p", { className: a.help, children: t("Applies to all print areas.") })
|
|
322
|
+
] }),
|
|
323
|
+
!!(L.length || g.enable) && /* @__PURE__ */ r("p", { className: a.help, children: t("This preview does not save changes or create a product or order.") })
|
|
324
|
+
] })
|
|
325
|
+
] })
|
|
326
|
+
] }) }),
|
|
327
|
+
/* @__PURE__ */ r("footer", { className: a.previewNotice, children: t("Preview only. Text, images and layout changes stay separate from your template.") }),
|
|
328
|
+
/* @__PURE__ */ c(Me, { open: !!b, onOpenChange: (e) => {
|
|
329
|
+
e || W(null);
|
|
330
|
+
}, title: t("Move, resize or rotate"), className: a.interactDialog, isShowCloseButton: !1, saveText: t("Done"), onSave: () => W(null), children: [
|
|
331
|
+
/* @__PURE__ */ r("p", { className: a.help, children: t("Only elements with placement permission can be moved.") }),
|
|
332
|
+
b && /* @__PURE__ */ r("div", { className: a.interactionSurface, children: /* @__PURE__ */ r(
|
|
333
|
+
_e,
|
|
334
|
+
{
|
|
335
|
+
viewArea: p.areas.find((e) => e.name === b.placement),
|
|
336
|
+
viewState: { ...M[b.placement], ...g.enable ? { color: F } : {} },
|
|
337
|
+
activeObjectId: b.id,
|
|
338
|
+
acquireResources: (e) => O.current.acquireResources(e),
|
|
339
|
+
onChange: (e) => D((i) => ({ ...i, [b.placement]: { ...i[b.placement], objects: i[b.placement].objects.map((n) => {
|
|
340
|
+
if (!n.customConfig?.moveable) return n;
|
|
341
|
+
const o = e.objects?.find((l) => String(l.id) === String(n.id));
|
|
342
|
+
return o ? { ...n, left: o.left, top: o.top, scaleX: o.scaleX, scaleY: o.scaleY, angle: o.angle, originX: o.originX, originY: o.originY } : n;
|
|
343
|
+
}) } }))
|
|
344
|
+
},
|
|
345
|
+
`${b.placement}:${b.id}`
|
|
346
|
+
) })
|
|
347
|
+
] })
|
|
348
|
+
] }) });
|
|
349
|
+
}
|
|
350
|
+
export {
|
|
351
|
+
Ze as default
|
|
352
|
+
};
|