@lystech/sections 0.8.0 → 0.9.0

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.
@@ -1,867 +0,0 @@
1
- import { jsxs as o, Fragment as H, jsx as e } from "react/jsx-runtime";
2
- import { useState as b, useRef as W, useEffect as J, useCallback as de, useMemo as pe } from "react";
3
- import { E as F, m as be } from "./index-BicM0J3j.js";
4
- const he = [
5
- { acces: "tous", titre: "Visible dans la boutique", aide: "Tout le monde la voit et peut commander." },
6
- { acces: "lien", titre: "À qui a le lien", aide: "Absente de la vitrine ; vous partagez son adresse." },
7
- { acces: "invites", titre: "Sur invitation", aide: "Seules les personnes invitées, connectées, peuvent commander." }
8
- ];
9
- function me({
10
- api: i,
11
- collections: h,
12
- produits: g,
13
- majCollection: I,
14
- majProduits: L,
15
- signaler: S
16
- }) {
17
- const [p, q] = b(null), [x, N] = b(null), [f, s] = b(null), [k, d] = b(null), [A, U] = b(""), [w, E] = b(!1), [_, v] = b(null), D = async (n, P, r, a = !1) => {
18
- E(!0), v(null);
19
- try {
20
- const l = await n();
21
- return l && I(l), a && L(), S(r), v({ ton: "ok", texte: P }), !0;
22
- } catch (l) {
23
- return v({ ton: "erreur", texte: l instanceof F ? l.message : "Le changement a échoué." }), !1;
24
- } finally {
25
- E(!1);
26
- }
27
- }, O = (n) => D(() => i.modifierCollection(n.UID, { acces: "fermee" }), `« ${n.nom} » est fermée : plus de commandes.`, { quoi: "collection", UID: n.UID, action: "masque" }), y = async (n, P) => {
28
- await D(() => i.modifierCollection(n.UID, { acces: P }), `« ${n.nom} » est ouverte.`, { quoi: "collection", UID: n.UID, action: "visible" }) && N(null);
29
- }, z = async () => {
30
- const n = A.trim();
31
- if (!n) return;
32
- await D(() => i.creerCollection(n), `« ${n} » est créée, fermée. Ajoutez-y des bijoux, puis ouvrez-la.`, { quoi: "collection", UID: null, action: "cree" }) && U("");
33
- };
34
- return /* @__PURE__ */ o(H, { children: [
35
- _ && /* @__PURE__ */ e("p", { className: "message message--" + _.ton, role: _.ton === "erreur" ? "alert" : "status", children: _.texte }),
36
- /* @__PURE__ */ o("p", { className: "b-aide", style: { margin: "0 0 10px" }, children: [
37
- "Une collection ",
38
- /* @__PURE__ */ e("b", { children: "fermée" }),
39
- " ne prend plus de commandes. Ouvrir, fermer ou garnir une collection est en ligne tout de suite."
40
- ] }),
41
- h.length === 0 && /* @__PURE__ */ e("p", { className: "b-vide", children: "Aucune collection pour l'instant." }),
42
- h.map((n) => {
43
- const P = g.filter((a) => a.collections.includes(n.UID)), r = p === n.UID;
44
- return /* @__PURE__ */ o("div", { className: "b-coll", children: [
45
- /* @__PURE__ */ o("div", { className: "b-coll__ligne", children: [
46
- /* @__PURE__ */ o("button", { type: "button", className: "b-coll__texte", "aria-expanded": r, onClick: () => q(r ? null : n.UID), children: [
47
- /* @__PURE__ */ e("span", { className: "b-coll__nom", children: n.nom || "Sans nom" }),
48
- /* @__PURE__ */ o("span", { className: "b-coll__meta", children: [
49
- n.nbProduits,
50
- " bijou",
51
- n.nbProduits > 1 ? "x" : "",
52
- " · ",
53
- n.accesLibelle
54
- ] })
55
- ] }),
56
- /* @__PURE__ */ o(
57
- "button",
58
- {
59
- type: "button",
60
- className: "b-inter",
61
- role: "switch",
62
- "aria-checked": n.ouverte,
63
- "aria-label": `${n.nom} : ${n.ouverte ? "ouverte" : "fermée"}`,
64
- disabled: w,
65
- onClick: () => n.ouverte ? O(n) : N(x === n.UID ? null : n.UID),
66
- children: [
67
- /* @__PURE__ */ e("span", { className: "b-rail", "aria-hidden": "true" }),
68
- /* @__PURE__ */ e("span", { children: n.ouverte ? "Ouverte" : "Fermée" })
69
- ]
70
- }
71
- )
72
- ] }),
73
- x === n.UID && /* @__PURE__ */ o("div", { className: "b-coll__corps", role: "group", "aria-label": `Comment ouvrir « ${n.nom} » ?`, children: [
74
- /* @__PURE__ */ e("b", { children: "Comment l'ouvrir ?" }),
75
- /* @__PURE__ */ o("div", { className: "b-choix", children: [
76
- he.map((a) => /* @__PURE__ */ e("button", { type: "button", className: "b-rangee", style: { minHeight: 56 }, disabled: w, onClick: () => y(n, a.acces), children: /* @__PURE__ */ o("span", { className: "b-rangee__texte", children: [
77
- /* @__PURE__ */ e("span", { className: "b-rangee__nom", children: a.titre }),
78
- /* @__PURE__ */ e("span", { className: "b-rangee__meta", style: { whiteSpace: "normal" }, children: a.aide })
79
- ] }) }, a.acces)),
80
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: () => N(null), children: "La laisser fermée" })
81
- ] })
82
- ] }),
83
- r && /* @__PURE__ */ o("div", { className: "b-coll__corps", children: [
84
- k?.UID === n.UID ? /* @__PURE__ */ o("div", { className: "b-ligne-ajout", children: [
85
- /* @__PURE__ */ e(
86
- "input",
87
- {
88
- type: "text",
89
- "aria-label": "Nouveau nom",
90
- value: k.nom,
91
- maxLength: 120,
92
- autoFocus: !0,
93
- onChange: (a) => d({ UID: n.UID, nom: a.target.value }),
94
- onKeyDown: (a) => {
95
- a.key === "Escape" && d(null);
96
- }
97
- }
98
- ),
99
- /* @__PURE__ */ e(
100
- "button",
101
- {
102
- type: "button",
103
- className: "bouton bouton--principal",
104
- disabled: w || !k.nom.trim(),
105
- onClick: async () => {
106
- await D(() => i.modifierCollection(n.UID, { nom: k.nom.trim() }), "Collection renommée.", { quoi: "collection", UID: n.UID, action: "modifie" }) && d(null);
107
- },
108
- children: "OK"
109
- }
110
- )
111
- ] }) : /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: () => d({ UID: n.UID, nom: n.nom }), children: "Renommer" }),
112
- P.length === 0 && /* @__PURE__ */ e("p", { className: "b-aide", children: "Aucun bijou dans cette collection." }),
113
- P.map((a) => /* @__PURE__ */ o("div", { className: "b-mini", children: [
114
- a.photos[0] ? /* @__PURE__ */ e("img", { className: "b-vignette", src: a.photos[0].src, alt: "" }) : /* @__PURE__ */ e("span", { className: "b-vignette b-vignette--vide", "aria-hidden": "true", children: "◇" }),
115
- /* @__PURE__ */ e("span", { children: a.nom }),
116
- /* @__PURE__ */ e(
117
- "button",
118
- {
119
- type: "button",
120
- className: "bouton bouton--discret",
121
- disabled: w,
122
- "aria-label": `Retirer ${a.nom} de ${n.nom}`,
123
- onClick: () => D(() => i.garnirCollection(n.UID, [], [a.UID]), `« ${a.nom} » retiré de « ${n.nom} ».`, { quoi: "collection", UID: n.UID, action: "retire" }, !0),
124
- children: "Retirer"
125
- }
126
- )
127
- ] }, a.UID)),
128
- f?.UID === n.UID ? /* @__PURE__ */ o("div", { style: { marginTop: 8 }, children: [
129
- /* @__PURE__ */ e("b", { children: "Ajouter des bijoux" }),
130
- g.filter((a) => !a.collections.includes(n.UID)).map((a) => /* @__PURE__ */ o("label", { className: "b-coche", children: [
131
- /* @__PURE__ */ e(
132
- "input",
133
- {
134
- type: "checkbox",
135
- checked: f.coches.includes(a.UID),
136
- onChange: (l) => s({ UID: n.UID, coches: l.target.checked ? [...f.coches, a.UID] : f.coches.filter((C) => C !== a.UID) })
137
- }
138
- ),
139
- /* @__PURE__ */ o("span", { children: [
140
- a.nom,
141
- !a.visible && " (masqué)"
142
- ] })
143
- ] }, a.UID)),
144
- /* @__PURE__ */ o("div", { className: "b-ligne-ajout", children: [
145
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: () => s(null), children: "Annuler" }),
146
- /* @__PURE__ */ e("span", { className: "espace", style: { flex: 1 } }),
147
- /* @__PURE__ */ o(
148
- "button",
149
- {
150
- type: "button",
151
- className: "bouton bouton--principal",
152
- disabled: w || !f.coches.length,
153
- onClick: async () => {
154
- await D(() => i.garnirCollection(n.UID, f.coches, []), `${f.coches.length} bijou${f.coches.length > 1 ? "x" : ""} ajouté${f.coches.length > 1 ? "s" : ""} à « ${n.nom} ».`, { quoi: "collection", UID: n.UID, action: "ajoute" }, !0) && s(null);
155
- },
156
- children: [
157
- "Ajouter ",
158
- f.coches.length || ""
159
- ]
160
- }
161
- )
162
- ] })
163
- ] }) : /* @__PURE__ */ e("button", { type: "button", className: "b-ajout", style: { marginTop: 8 }, onClick: () => s({ UID: n.UID, coches: [] }), children: "+ Ajouter des bijoux" })
164
- ] })
165
- ] }, n.UID);
166
- }),
167
- /* @__PURE__ */ o("div", { className: "b-champ", style: { marginTop: 14 }, children: [
168
- /* @__PURE__ */ e("label", { htmlFor: "b-nouvelle-coll", children: "Nouvelle collection" }),
169
- /* @__PURE__ */ o("div", { className: "b-ligne-ajout", children: [
170
- /* @__PURE__ */ e(
171
- "input",
172
- {
173
- id: "b-nouvelle-coll",
174
- type: "text",
175
- value: A,
176
- maxLength: 120,
177
- placeholder: "Ex. Collection d'hiver",
178
- onChange: (n) => U(n.target.value),
179
- onKeyDown: (n) => {
180
- n.key === "Enter" && z();
181
- }
182
- }
183
- ),
184
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--principal", disabled: w || !A.trim(), onClick: z, children: "Créer" })
185
- ] }),
186
- /* @__PURE__ */ e("p", { className: "b-aide", children: "Elle naît fermée : vous la garnissez, puis vous l'ouvrez." })
187
- ] })
188
- ] });
189
- }
190
- const ge = 2400;
191
- async function xe(i) {
192
- const h = i.name || "photo.jpg";
193
- if (typeof createImageBitmap != "function" || i.size < 9e5) return { donnees: i, nom: h };
194
- try {
195
- const g = await createImageBitmap(i, { imageOrientation: "from-image" }), I = Math.min(1, ge / Math.max(g.width, g.height)), L = Math.round(g.width * I), S = Math.round(g.height * I), p = document.createElement("canvas");
196
- p.width = L, p.height = S;
197
- const q = p.getContext("2d");
198
- if (!q) return { donnees: i, nom: h };
199
- q.drawImage(g, 0, 0, L, S), g.close?.();
200
- const x = await new Promise((N) => p.toBlob(N, "image/jpeg", 0.9));
201
- return !x || x.size >= i.size ? { donnees: i, nom: h } : { donnees: x, nom: h.replace(/\.[^.]+$/, "") + ".jpg" };
202
- } catch {
203
- return { donnees: i, nom: h };
204
- }
205
- }
206
- function fe(i) {
207
- const h = Array.from(i ?? []), g = h.filter((I) => I.type.startsWith("image/") || /\.(heic|heif)$/i.test(I.name));
208
- return { images: g, ecartes: h.length - g.length };
209
- }
210
- function te(i) {
211
- return i == null ? "" : Number.isInteger(i) ? String(i) : i.toFixed(2).replace(".", ",");
212
- }
213
- function V(i) {
214
- return {
215
- nom: i?.nom ?? "",
216
- prix: i ? te(i.prix) : "",
217
- prixAvant: i?.prixAvant ? te(i.prixAvant) : "",
218
- mode: i?.stock.mode ?? "unique",
219
- quantite: i?.stock.mode === "quantite" ? String(i.stock.restant ?? 0) : "1",
220
- visible: i?.visible ?? !0,
221
- collections: i?.collections ?? [],
222
- description: i?.description ?? ""
223
- };
224
- }
225
- function ve({
226
- api: i,
227
- produit: h,
228
- collections: g,
229
- surEnregistre: I,
230
- surSupprime: L,
231
- surRetour: S,
232
- signaler: p,
233
- annonce: q
234
- }) {
235
- const x = h === null, [N, f] = b(() => V(h)), [s, k] = b(N), [d, A] = b(h), [U, w] = b([]), [E, _] = b(0), [v, D] = b({}), [O, y] = b(null), [z, n] = b(!1), [P, r] = b(!1), [a, l] = b(!1), C = W(null), R = W(null);
236
- J(() => {
237
- f(V(h)), k(V(h)), A(h), w([]), D({}), y(q ? { ton: "ok", texte: q } : null), l(!1), (x ? R.current : C.current)?.focus();
238
- }, [h?.UID]), J(() => () => U.forEach((t) => URL.revokeObjectURL(t.apercu)), []);
239
- const T = JSON.stringify(s) !== JSON.stringify(N), $ = (t, c) => {
240
- k((u) => ({ ...u, [t]: c })), y((u) => u?.ton === "erreur" ? null : u), D((u) => {
241
- const j = { ...u };
242
- return delete j[t], j;
243
- });
244
- }, K = async (t) => {
245
- const { images: c, ecartes: u } = fe(t);
246
- if (u && y({ ton: "erreur", texte: u === 1 ? "Un fichier n'était pas une photo : il a été écarté." : `${u} fichiers n'étaient pas des photos : ils ont été écartés.` }), !!c.length) {
247
- if (x || !d) {
248
- w((j) => [...j, ...c.map((B) => ({ cle: Math.random().toString(36).slice(2), fichier: B, apercu: URL.createObjectURL(B) }))]);
249
- return;
250
- }
251
- await X(d.UID, c);
252
- }
253
- }, X = async (t, c) => {
254
- let u = null, j = 0;
255
- for (const [B, ce] of c.entries()) {
256
- _(c.length - B), y({ ton: "info", texte: c.length > 1 ? `Envoi de la photo ${B + 1} sur ${c.length}…` : "Envoi de la photo…" });
257
- try {
258
- const { donnees: Q, nom: ue } = await xe(ce);
259
- u = await i.ajouterPhoto(t, Q, ue), A(u);
260
- } catch (Q) {
261
- j++, y({ ton: "erreur", texte: Q instanceof F ? Q.message : "Une photo n'a pas pu être envoyée." });
262
- }
263
- }
264
- return _(0), u && (p({ quoi: "photo", UID: t, action: "ajoute" }), I(u), j || y({ ton: "ok", texte: c.length > 1 ? "Photos ajoutées — en ligne maintenant." : "Photo ajoutée — en ligne maintenant." })), u;
265
- }, Y = async (t, c) => {
266
- n(!0);
267
- try {
268
- const u = await t();
269
- A(u), I(u), p({ quoi: "photo", UID: u.UID, action: "modifie" }), y({ ton: "ok", texte: c });
270
- } catch (u) {
271
- y({ ton: "erreur", texte: u instanceof F ? u.message : "Le changement de photo a échoué." });
272
- } finally {
273
- n(!1);
274
- }
275
- }, re = (t) => {
276
- t.preventDefault(), r(!1), K(t.dataTransfer.files);
277
- }, Z = () => {
278
- const t = {}, c = (u) => x || s[u] !== N[u] || JSON.stringify(s[u]) !== JSON.stringify(N[u]);
279
- return c("nom") && (t.nom = s.nom), c("prix") && (t.prix = s.prix), c("prixAvant") && (t.prixAvant = s.prixAvant.trim() === "" ? null : s.prixAvant), (c("mode") || c("quantite")) && (t.stock = { mode: s.mode, quantite: s.mode === "quantite" ? s.quantite : null }), c("visible") && (t.visible = s.visible), c("collections") && (t.collections = s.collections), c("description") && (t.description = s.description), t;
280
- }, ae = async () => {
281
- n(!0), y(null);
282
- try {
283
- if (x) {
284
- const c = await i.creer(Z());
285
- A(c), p({ quoi: "produit", UID: c.UID, action: "cree" });
286
- let u = c;
287
- U.length && (u = await X(c.UID, U.map((j) => j.fichier)) ?? c, U.forEach((j) => URL.revokeObjectURL(j.apercu)), w([])), I(u);
288
- return;
289
- }
290
- if (!d) return;
291
- const t = await i.modifier(d.UID, Z());
292
- A(t), f(V(t)), k(V(t)), y({ ton: "ok", texte: "Enregistré — en ligne maintenant." }), I(t), p({ quoi: "produit", UID: t.UID, action: s.visible !== N.visible ? s.visible ? "visible" : "masque" : "modifie" });
293
- } catch (t) {
294
- t instanceof F ? (D(t.erreurs), y({ ton: "erreur", texte: t.message })) : y({ ton: "erreur", texte: "L'enregistrement a échoué. Vos changements sont toujours à l'écran." });
295
- } finally {
296
- n(!1);
297
- }
298
- }, le = async () => {
299
- if (d) {
300
- n(!0);
301
- try {
302
- await i.supprimer(d.UID), p({ quoi: "produit", UID: d.UID, action: "supprime" }), L(d.UID);
303
- } catch (t) {
304
- l(!1), y({ ton: "erreur", texte: t instanceof F ? t.message : "La suppression a échoué." });
305
- } finally {
306
- n(!1);
307
- }
308
- }
309
- }, ee = () => {
310
- (T || U.length) && !window.confirm("Quitter sans enregistrer ? Vos changements seront perdus.") || S();
311
- }, G = d?.photos ?? [], M = (t) => v[t] ? /* @__PURE__ */ e("p", { className: "b-erreur", role: "alert", children: v[t] }) : null, m = (t) => "fiche-" + t, se = s.collections.length === 0 && g.length > 0;
312
- return /* @__PURE__ */ o(H, { children: [
313
- /* @__PURE__ */ o("div", { className: "b-tete", children: [
314
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--icone bouton--discret", onClick: ee, "aria-label": "Retour à la liste des bijoux", children: "←" }),
315
- /* @__PURE__ */ e("h2", { ref: C, tabIndex: -1, children: x ? "Nouveau bijou" : s.nom || "Sans nom" })
316
- ] }),
317
- /* @__PURE__ */ o("div", { className: "panneau__corps", children: [
318
- O && /* @__PURE__ */ e("p", { className: "message message--" + O.ton, role: O.ton === "erreur" ? "alert" : "status", children: O.texte }),
319
- d?.vendu && /* @__PURE__ */ o("p", { className: "b-bandeau", children: [
320
- d.stock.mode === "unique" ? "Pièce vendue." : "Plus rien en stock.",
321
- " La boutique l'affiche « épuisé »."
322
- ] }),
323
- /* @__PURE__ */ o("section", { className: "b-section", "aria-labelledby": m("photos"), children: [
324
- /* @__PURE__ */ e("h3", { id: m("photos"), children: "Photos" }),
325
- /* @__PURE__ */ o(
326
- "div",
327
- {
328
- className: "b-photos",
329
- onDragOver: (t) => {
330
- t.preventDefault(), r(!0);
331
- },
332
- onDragLeave: () => r(!1),
333
- onDrop: re,
334
- children: [
335
- G.map((t) => /* @__PURE__ */ o("div", { className: "b-photo" + (t.principale ? " b-photo--principale" : ""), children: [
336
- /* @__PURE__ */ e("img", { src: t.src, alt: t.principale ? "Photo principale" : "Photo du bijou", loading: "lazy" }),
337
- t.principale && /* @__PURE__ */ e("span", { className: "b-photo__badge", children: "Principale" }),
338
- /* @__PURE__ */ o("span", { className: "b-photo__actions", children: [
339
- !t.principale && /* @__PURE__ */ e(
340
- "button",
341
- {
342
- type: "button",
343
- disabled: z,
344
- title: "Choisir comme photo principale",
345
- "aria-label": "Choisir comme photo principale",
346
- onClick: () => d && Y(() => i.principale(d.UID, t.UID), "Photo principale changée — en ligne maintenant."),
347
- children: "★"
348
- }
349
- ),
350
- /* @__PURE__ */ e(
351
- "button",
352
- {
353
- type: "button",
354
- disabled: z,
355
- title: "Retirer cette photo",
356
- "aria-label": "Retirer cette photo",
357
- onClick: () => d && Y(() => i.retirerPhoto(d.UID, t.UID), "Photo retirée. Elle reste dans votre librairie d'images."),
358
- children: "✕"
359
- }
360
- )
361
- ] })
362
- ] }, t.UID)),
363
- U.map((t, c) => /* @__PURE__ */ o("div", { className: "b-photo" + (c === 0 && !G.length ? " b-photo--principale" : "") + (E ? " b-photo--envoi" : ""), children: [
364
- /* @__PURE__ */ e("img", { src: t.apercu, alt: "Photo à envoyer" }),
365
- c === 0 && !G.length && /* @__PURE__ */ e("span", { className: "b-photo__badge", children: "Principale" }),
366
- /* @__PURE__ */ e("span", { className: "b-photo__actions", children: /* @__PURE__ */ e("button", { type: "button", "aria-label": "Ne pas ajouter cette photo", onClick: () => {
367
- URL.revokeObjectURL(t.apercu), w((u) => u.filter((j) => j.cle !== t.cle));
368
- }, children: "✕" }) })
369
- ] }, t.cle)),
370
- /* @__PURE__ */ o("div", { className: "b-depot" + (P ? " b-depot--survol" : ""), children: [
371
- E ? `Envoi en cours… (${E} restante${E > 1 ? "s" : ""})` : /* @__PURE__ */ e("span", { className: "b-glisser", children: "Glissez vos photos ici, ou :" }),
372
- /* @__PURE__ */ o("div", { className: "b-depot__boutons", children: [
373
- /* @__PURE__ */ o("label", { className: "bouton bouton--principal b-camera", children: [
374
- "📷 Prendre une photo",
375
- /* @__PURE__ */ e("input", { type: "file", accept: "image/*", capture: "environment", onChange: (t) => {
376
- K(t.target.files), t.target.value = "";
377
- } })
378
- ] }),
379
- /* @__PURE__ */ o("label", { className: "bouton", children: [
380
- "Choisir des photos",
381
- /* @__PURE__ */ e("input", { type: "file", accept: "image/*", multiple: !0, onChange: (t) => {
382
- K(t.target.files), t.target.value = "";
383
- } })
384
- ] })
385
- ] })
386
- ] })
387
- ]
388
- }
389
- ),
390
- /* @__PURE__ */ e("p", { className: "b-aide", children: x ? "Les photos partiront avec le bijou, à « Créer le bijou »." : "La photo principale est celle des cartes de la boutique. Chaque photo est en ligne dès l'ajout." })
391
- ] }),
392
- /* @__PURE__ */ o("section", { className: "b-section", "aria-labelledby": m("essentiel"), children: [
393
- /* @__PURE__ */ e("h3", { id: m("essentiel"), children: "L'essentiel" }),
394
- /* @__PURE__ */ o("div", { className: "b-champ" + (v.nom ? " b-champ--erreur" : ""), children: [
395
- /* @__PURE__ */ e("label", { htmlFor: m("nom"), children: "Nom du bijou" }),
396
- /* @__PURE__ */ e(
397
- "input",
398
- {
399
- ref: R,
400
- id: m("nom"),
401
- type: "text",
402
- value: s.nom,
403
- maxLength: 150,
404
- placeholder: "Ex. Collier Aurore",
405
- onChange: (t) => $("nom", t.target.value),
406
- "aria-invalid": !!v.nom
407
- }
408
- ),
409
- M("nom")
410
- ] }),
411
- /* @__PURE__ */ o("div", { className: "b-deux", children: [
412
- /* @__PURE__ */ o("div", { className: "b-champ" + (v.prix ? " b-champ--erreur" : ""), children: [
413
- /* @__PURE__ */ e("label", { htmlFor: m("prix"), children: "Prix" }),
414
- /* @__PURE__ */ o("div", { className: "b-prix", children: [
415
- /* @__PURE__ */ e(
416
- "input",
417
- {
418
- id: m("prix"),
419
- type: "text",
420
- inputMode: "decimal",
421
- value: s.prix,
422
- placeholder: "0,00",
423
- onChange: (t) => $("prix", t.target.value),
424
- "aria-invalid": !!v.prix
425
- }
426
- ),
427
- /* @__PURE__ */ e("span", { "aria-hidden": "true", children: "$" })
428
- ] }),
429
- M("prix")
430
- ] }),
431
- /* @__PURE__ */ o("div", { className: "b-champ" + (v.prixAvant ? " b-champ--erreur" : ""), children: [
432
- /* @__PURE__ */ o("label", { htmlFor: m("avant"), children: [
433
- "Prix avant rabais ",
434
- /* @__PURE__ */ e("small", { children: "(facultatif)" })
435
- ] }),
436
- /* @__PURE__ */ o("div", { className: "b-prix", children: [
437
- /* @__PURE__ */ e(
438
- "input",
439
- {
440
- id: m("avant"),
441
- type: "text",
442
- inputMode: "decimal",
443
- value: s.prixAvant,
444
- placeholder: "—",
445
- onChange: (t) => $("prixAvant", t.target.value),
446
- "aria-invalid": !!v.prixAvant
447
- }
448
- ),
449
- /* @__PURE__ */ e("span", { "aria-hidden": "true", children: "$" })
450
- ] }),
451
- M("prixAvant")
452
- ] })
453
- ] })
454
- ] }),
455
- /* @__PURE__ */ o("section", { className: "b-section", "aria-labelledby": m("stock"), children: [
456
- /* @__PURE__ */ e("h3", { id: m("stock"), children: "Combien en avez-vous ?" }),
457
- /* @__PURE__ */ e("div", { className: "b-seg", role: "group", "aria-labelledby": m("stock"), children: [["unique", "Pièce unique"], ["quantite", "Quantité"], ["illimite", "Sans limite"]].map(([t, c]) => /* @__PURE__ */ e("button", { type: "button", "aria-pressed": s.mode === t, onClick: () => $("mode", t), children: c }, t)) }),
458
- s.mode === "quantite" && /* @__PURE__ */ o("div", { className: "b-champ" + (v.stock ? " b-champ--erreur" : ""), style: { marginTop: 10 }, children: [
459
- /* @__PURE__ */ e("label", { htmlFor: m("qte"), children: "Quantité disponible" }),
460
- /* @__PURE__ */ e("input", { id: m("qte"), type: "text", inputMode: "numeric", value: s.quantite, onChange: (t) => $("quantite", t.target.value) })
461
- ] }),
462
- M("stock"),
463
- /* @__PURE__ */ o("p", { className: "b-aide", children: [
464
- s.mode === "unique" && "Un seul exemplaire. Une fois vendu, il s'affiche « épuisé », tout seul.",
465
- s.mode === "quantite" && `Ce qui vous reste.${d?.vendus ? ` Déjà vendus : ${d.vendus}.` : ""}`,
466
- s.mode === "illimite" && "Fait sur commande : ne s'épuise jamais."
467
- ] })
468
- ] }),
469
- /* @__PURE__ */ o("section", { className: "b-section", "aria-labelledby": m("vitrine"), children: [
470
- /* @__PURE__ */ e("h3", { id: m("vitrine"), children: "Dans la boutique" }),
471
- /* @__PURE__ */ o("button", { type: "button", className: "b-inter", role: "switch", "aria-checked": s.visible, onClick: () => $("visible", !s.visible), children: [
472
- /* @__PURE__ */ e("span", { className: "b-rail", "aria-hidden": "true" }),
473
- /* @__PURE__ */ o("span", { children: [
474
- /* @__PURE__ */ e("b", { children: s.visible ? "Visible" : "Masqué" }),
475
- /* @__PURE__ */ e("small", { children: s.visible ? "Vos visiteurs le voient et peuvent l'acheter." : "Invisible aux visiteurs. Vous le retrouvez ici quand vous voulez." })
476
- ] })
477
- ] })
478
- ] }),
479
- /* @__PURE__ */ o("section", { className: "b-section", "aria-labelledby": m("coll"), children: [
480
- /* @__PURE__ */ e("h3", { id: m("coll"), children: "Collections" }),
481
- g.length === 0 ? /* @__PURE__ */ e("p", { className: "b-aide", children: "Aucune collection pour l'instant — l'onglet « Collections » permet d'en créer une." }) : /* @__PURE__ */ e("div", { className: "b-puces", role: "group", "aria-labelledby": m("coll"), children: g.map((t) => {
482
- const c = s.collections.includes(t.UID);
483
- return /* @__PURE__ */ o(
484
- "button",
485
- {
486
- type: "button",
487
- className: "b-puce",
488
- "aria-pressed": c,
489
- onClick: () => $("collections", c ? s.collections.filter((u) => u !== t.UID) : [...s.collections, t.UID]),
490
- children: [
491
- c ? "✓ " : "+ ",
492
- t.nom,
493
- !t.ouverte && /* @__PURE__ */ e("small", { children: "fermée" })
494
- ]
495
- },
496
- t.UID
497
- );
498
- }) }),
499
- se && /* @__PURE__ */ e("p", { className: "b-aide", style: { color: "#f1d9a6" }, children: "Sans collection, ce bijou n'apparaît dans aucune vitrine de la boutique." }),
500
- M("collections")
501
- ] }),
502
- /* @__PURE__ */ e("section", { className: "b-section", children: /* @__PURE__ */ o("div", { className: "b-champ" + (v.description ? " b-champ--erreur" : ""), children: [
503
- /* @__PURE__ */ e("label", { htmlFor: m("desc"), children: "Description" }),
504
- /* @__PURE__ */ e(
505
- "textarea",
506
- {
507
- id: m("desc"),
508
- value: s.description,
509
- placeholder: "Matières, dimensions, l'histoire de la pièce…",
510
- onChange: (t) => $("description", t.target.value)
511
- }
512
- ),
513
- M("description")
514
- ] }) }),
515
- d && /* @__PURE__ */ e("section", { className: "b-danger", "aria-label": "Retirer ce bijou", children: N.visible ? /* @__PURE__ */ e("p", { children: "Pour retirer ce bijou de la boutique, passez-le à « Masqué » ci-dessus. Vous pourrez le remettre en vente à tout moment." }) : a ? /* @__PURE__ */ o("div", { className: "b-confirmer", role: "alertdialog", "aria-label": "Confirmer la suppression", children: [
516
- /* @__PURE__ */ o("p", { children: [
517
- /* @__PURE__ */ o("b", { children: [
518
- "Supprimer « ",
519
- d.nom,
520
- " » pour toujours ?"
521
- ] }),
522
- /* @__PURE__ */ e("br", {}),
523
- "Ses photos restent dans votre librairie. S'il a déjà été vendu, il restera masqué : ses factures en ont besoin."
524
- ] }),
525
- /* @__PURE__ */ o("div", { className: "rang", children: [
526
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--danger-plein", onClick: le, disabled: z, children: "Oui, supprimer pour toujours" }),
527
- /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: () => l(!1), autoFocus: !0, children: "Non, le garder" })
528
- ] })
529
- ] }) : /* @__PURE__ */ o(H, { children: [
530
- /* @__PURE__ */ e("p", { children: "Ce bijou est masqué. Vous pouvez le remettre en vente, ou le supprimer." }),
531
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--danger", onClick: () => l(!0), children: "Supprimer pour toujours…" })
532
- ] }) })
533
- ] }),
534
- /* @__PURE__ */ o("div", { className: "panneau__pied", children: [
535
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: ee, disabled: z, children: T || U.length ? "Annuler" : "Retour" }),
536
- /* @__PURE__ */ e("span", { className: "espace" }),
537
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--principal", onClick: ae, disabled: z || E > 0 || !x && !T, children: z ? "Un instant…" : x ? "Créer le bijou" : "Enregistrer" })
538
- ] })
539
- ] });
540
- }
541
- const oe = `
542
- .panneau--boutique { width: min(440px, 100vw); }
543
- .panneau--boutique .bouton { min-height: 40px; }
544
- @media (max-width: 520px) {
545
- .panneau--boutique {
546
- top: auto; left: 0; right: 0; width: auto; height: 88vh; height: 88dvh;
547
- border-radius: 18px 18px 0 0;
548
- }
549
- .panneau--boutique .bouton { min-height: 44px; }
550
- .panneau--boutique .bouton--icone { min-width: 44px; }
551
- }
552
- .poignee { display: none; width: 44px; height: 5px; border-radius: 3px; background: #4a505d; margin: 8px auto 0; flex: none; }
553
- @media (max-width: 520px) { .poignee { display: block; } }
554
-
555
- .b-tete { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--bord); }
556
- .b-tete h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
557
- .b-tete .bouton--icone { min-width: 40px; min-height: 40px; font-size: 16px; }
558
-
559
- .b-onglets { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--bord); }
560
- .b-onglets button {
561
- border: 0; background: transparent; color: var(--texte-doux); font: inherit; font-weight: 600;
562
- min-height: 44px; padding: 0 12px; cursor: pointer; border-bottom: 2px solid transparent;
563
- }
564
- .b-onglets button[aria-selected="true"] { color: var(--texte); border-bottom-color: var(--accent); }
565
- .b-onglets button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
566
- .b-onglets small { opacity: .65; margin-left: 4px; font-weight: 500; }
567
-
568
- .b-avis {
569
- margin: 0 0 12px; padding: 9px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.45;
570
- background: rgba(227, 181, 91, 0.1); border: 1px solid rgba(227, 181, 91, 0.35); color: #f1d9a6;
571
- }
572
- .b-ajout {
573
- width: 100%; min-height: 48px; margin-bottom: 12px; border-radius: 12px; cursor: pointer;
574
- border: 2px dashed var(--accent); background: transparent; color: #9fe3d1; font: inherit; font-weight: 650;
575
- }
576
- .b-ajout:hover, .b-ajout:focus-visible { background: rgba(59, 165, 141, 0.1); outline: none; }
577
-
578
- .b-recherche { min-height: 44px; border-radius: 10px !important; font-size: 14px !important; }
579
- .b-filtres { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: none; }
580
- .b-puce {
581
- flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px;
582
- border-radius: 999px; border: 1px solid var(--bord); background: transparent; color: var(--texte-doux);
583
- font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
584
- }
585
- .b-puce small { opacity: .7; font-weight: 500; }
586
- .b-puce[aria-pressed="true"] { background: rgba(59, 165, 141, 0.16); border-color: var(--accent); color: #9fe3d1; }
587
- .b-puce:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
588
- @media (max-width: 520px) { .b-puce { min-height: 44px; } }
589
-
590
- .b-rangee {
591
- display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; margin-bottom: 6px; padding: 8px;
592
- border-radius: 12px; border: 1px solid var(--bord); background: var(--fond-clair); color: var(--texte);
593
- font: inherit; text-align: left; cursor: pointer;
594
- }
595
- .b-rangee:hover, .b-rangee:focus-visible { border-color: var(--accent); outline: none; }
596
- .b-vignette { width: 48px; height: 48px; flex: none; border-radius: 9px; object-fit: cover; background: #2a2e37; display: block; }
597
- .b-vignette--vide { display: grid; place-items: center; color: var(--texte-doux); font-size: 18px; }
598
- .b-rangee__texte { flex: 1; min-width: 0; }
599
- .b-rangee__nom { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
600
- .b-rangee__meta { display: block; font-size: 12px; color: var(--texte-doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
601
- .b-etiquette { flex: none; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
602
- .b-etiquette--vente { background: rgba(59, 165, 141, 0.18); color: #8fd9c6; }
603
- .b-etiquette--masque { background: rgba(163, 169, 182, 0.16); color: var(--texte-doux); }
604
- .b-etiquette--vendu { background: rgba(217, 119, 106, 0.18); color: #f0b3a9; }
605
- .b-vide { color: var(--texte-doux); font-size: 13px; padding: 18px 4px; text-align: center; }
606
-
607
- /* ---------------------------------------------------------- FICHE ------ */
608
- .b-section { margin-bottom: 18px; }
609
- .b-section > h3 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--texte-doux); }
610
- .b-champ { margin-bottom: 12px; }
611
- .b-champ label, .b-champ .b-etiq { display: block; margin-bottom: 5px; font-size: 12.5px; font-weight: 600; }
612
- .b-champ label small { font-weight: 400; color: var(--texte-doux); }
613
- .panneau--boutique input[type="text"], .panneau--boutique input[type="search"], .panneau--boutique textarea {
614
- min-height: 44px; padding: 10px 12px; border-radius: 10px; font-size: 14px;
615
- }
616
- .b-champ--erreur input, .b-champ--erreur textarea { border-color: var(--danger) !important; }
617
- .b-erreur { margin: 4px 0 0; font-size: 12px; color: #f0b3a9; }
618
- .b-aide { margin: 4px 0 0; font-size: 11.5px; color: var(--texte-doux); }
619
- .b-deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
620
- .b-prix { position: relative; }
621
- .b-prix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--texte-doux); pointer-events: none; }
622
- .b-prix input { padding-right: 28px !important; }
623
-
624
- .b-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
625
- .b-seg button {
626
- min-height: 44px; border-radius: 10px; border: 1px solid var(--bord); background: var(--fond-clair);
627
- color: var(--texte-doux); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
628
- }
629
- .b-seg button[aria-pressed="true"] { border-color: var(--accent); color: #9fe3d1; background: rgba(59, 165, 141, 0.14); }
630
- .b-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
631
-
632
- .b-inter {
633
- display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 12px;
634
- border-radius: 12px; background: var(--fond-clair); border: 1px solid var(--bord); color: var(--texte);
635
- font: inherit; text-align: left; cursor: pointer;
636
- }
637
- .b-inter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
638
- .b-inter small { display: block; color: var(--texte-doux); font-size: 11.5px; font-weight: 400; }
639
- .b-rail { position: relative; width: 46px; height: 28px; flex: none; border-radius: 999px; background: #4a505d; transition: background .15s; }
640
- .b-rail::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
641
- [aria-checked="true"] > .b-rail { background: var(--accent); }
642
- [aria-checked="true"] > .b-rail::after { left: 21px; }
643
-
644
- .b-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
645
- .b-photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: #2a2e37; }
646
- .b-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
647
- .b-photo--principale { border-color: var(--accent); }
648
- .b-photo__badge { position: absolute; left: 6px; bottom: 6px; background: var(--accent); color: #06120e; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 999px; }
649
- .b-photo__actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; }
650
- .b-photo__actions button {
651
- width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
652
- background: rgba(22, 24, 29, 0.85); color: #fff; font: inherit; font-size: 14px;
653
- }
654
- .b-photo__actions button:hover, .b-photo__actions button:focus-visible { background: var(--accent); color: #06120e; outline: none; }
655
- .b-photo--envoi::after { content: "Envoi…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(22,24,29,.6); color: #fff; font-size: 12px; }
656
- .b-depot {
657
- grid-column: 1 / -1; padding: 14px; border-radius: 12px; border: 2px dashed #4a505d;
658
- text-align: center; color: var(--texte-doux); font-size: 12.5px; transition: background .12s, border-color .12s;
659
- }
660
- .b-depot--survol { border-color: var(--accent); background: rgba(59, 165, 141, 0.1); color: #9fe3d1; }
661
- .b-depot__boutons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
662
- .b-depot__boutons label { cursor: pointer; }
663
- .b-depot__boutons input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
664
- .b-depot__boutons label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
665
- .b-camera { display: none !important; }
666
- @media (pointer: coarse) { .b-camera { display: inline-flex !important; } .b-glisser { display: none; } }
667
-
668
- .b-puces { display: flex; flex-wrap: wrap; gap: 6px; }
669
- .b-danger { border-top: 1px solid var(--bord); padding-top: 14px; }
670
- .b-danger p { margin: 0 0 8px; font-size: 12.5px; color: var(--texte-doux); }
671
- .bouton--danger { background: transparent; color: var(--danger); border-color: rgba(217, 119, 106, 0.5); }
672
- .bouton--danger:hover { background: rgba(217, 119, 106, 0.14); }
673
- .bouton--danger-plein { background: #b3261e; border-color: #b3261e; color: #fff; }
674
- .bouton--danger-plein:hover { background: #c9372e; }
675
- .b-confirmer { padding: 12px; border-radius: 12px; border: 1px solid rgba(217, 119, 106, 0.5); background: rgba(217, 119, 106, 0.08); }
676
- .b-confirmer p { margin: 0 0 10px; color: var(--texte); }
677
- .b-confirmer .rang { display: flex; gap: 8px; flex-wrap: wrap; }
678
- .b-bandeau { margin: 0 0 12px; padding: 9px 11px; border-radius: 10px; font-size: 12.5px; background: rgba(217, 119, 106, 0.12); border: 1px solid rgba(217, 119, 106, 0.4); color: #f0b3a9; }
679
-
680
- /* ------------------------------------------------------ COLLECTIONS ---- */
681
- .b-coll { border: 1px solid var(--bord); border-radius: 12px; background: var(--fond-clair); margin-bottom: 8px; }
682
- .b-coll__ligne { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; min-height: 64px; }
683
- .b-coll__texte { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--texte); font: inherit; text-align: left; cursor: pointer; padding: 6px 0; min-height: 44px; }
684
- .b-coll__texte:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
685
- .b-coll__nom { display: block; font-weight: 600; }
686
- .b-coll__meta { display: block; font-size: 12px; color: var(--texte-doux); }
687
- .b-coll .b-inter { width: auto; min-height: 44px; padding: 0 6px; border: 0; background: transparent; }
688
- .b-coll__corps { border-top: 1px solid var(--bord); padding: 10px 12px 12px; }
689
- .b-choix { display: grid; gap: 6px; margin-top: 8px; }
690
- .b-mini { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-height: 52px; }
691
- .b-mini img, .b-mini .b-vignette { width: 40px; height: 40px; }
692
- .b-mini span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
693
- .b-coche { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; }
694
- .b-coche input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
695
- .b-ligne-ajout { display: flex; gap: 8px; margin-top: 8px; }
696
- .b-ligne-ajout input { flex: 1; }
697
-
698
- @media (prefers-reduced-motion: reduce) { .b-rail, .b-rail::after, .b-depot { transition: none; } }
699
- `, ne = [
700
- ["tous", "Tous", () => !0],
701
- ["vente", "En vente", (i) => i.visible && !i.vendu],
702
- ["masques", "Masqués", (i) => !i.visible],
703
- ["vendus", "Épuisés", (i) => i.vendu],
704
- ["sans", "Sans collection", (i) => i.collections.length === 0]
705
- ];
706
- function ie(i) {
707
- return i.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").toLowerCase();
708
- }
709
- function Ue({
710
- api: i,
711
- demande: h,
712
- surFermer: g,
713
- signaler: I
714
- }) {
715
- const [L, S] = b("bijoux"), [p, q] = b(null), [x, N] = b([]), [f, s] = b(null), [k, d] = b(null), [A, U] = b(null), [w, E] = b(""), [_, v] = b("tous"), D = W(null), O = de(async () => {
716
- try {
717
- const [r, a] = await Promise.all([i.produits(), i.collections()]);
718
- q(r), N(a), s(null);
719
- } catch (r) {
720
- s(r instanceof F ? r.message : "Impossible de lire la boutique.");
721
- }
722
- }, [i]);
723
- J(() => {
724
- O();
725
- }, [O]), J(() => {
726
- U(null), h.cible === null ? d(null) : (S("bijoux"), d({ fiche: h.cible === "nouveau" ? null : h.cible }));
727
- }, [h.n]), J(() => {
728
- const r = (l) => {
729
- if (l.key !== "Escape") return;
730
- const C = l.composedPath()[0];
731
- C instanceof HTMLInputElement || C instanceof HTMLTextAreaElement || (k ? d(null) : g());
732
- }, a = D.current;
733
- return a?.addEventListener("keydown", r), () => a?.removeEventListener("keydown", r);
734
- }, [k, g]);
735
- const y = (r) => q((a) => a ? a.some((l) => l.UID === r.UID) ? a.map((l) => l.UID === r.UID ? r : l) : [r, ...a] : [r]), z = () => i.collections().then(N).catch(() => {
736
- }), n = pe(() => {
737
- const r = ie(w.trim()), a = ne.find(([l]) => l === _)?.[2] ?? (() => !0);
738
- return (p ?? []).filter((l) => a(l) && (!r || ie(l.nom).includes(r)));
739
- }, [p, w, _]), P = (r) => x.find((a) => a.UID === r)?.nom;
740
- if (k) {
741
- const r = k.fiche ? p?.find((l) => l.UID === k.fiche) ?? null : null, a = k.fiche && !r;
742
- return /* @__PURE__ */ o("div", { ref: D, className: "panneau panneau--boutique", role: "dialog", "aria-modal": "false", "aria-label": r ? "Fiche de " + r.nom : "Nouveau bijou", children: [
743
- /* @__PURE__ */ e("style", { children: oe }),
744
- /* @__PURE__ */ e("div", { className: "poignee", "aria-hidden": "true" }),
745
- a ? /* @__PURE__ */ o("div", { className: "panneau__corps", children: [
746
- /* @__PURE__ */ e("p", { className: "b-vide", children: f ?? (p ? "Ce bijou est introuvable dans votre boutique." : "Chargement…") }),
747
- /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: () => d(null), children: "Voir tous les bijoux" })
748
- ] }) : /* @__PURE__ */ e(
749
- ve,
750
- {
751
- api: i,
752
- produit: r,
753
- collections: x,
754
- annonce: A,
755
- signaler: I,
756
- surRetour: () => {
757
- U(null), d(null);
758
- },
759
- surEnregistre: (l) => {
760
- const C = k.fiche === null, R = p?.find((T) => T.UID === l.UID);
761
- y(l), C && (U(l.visible ? "Bijou créé — en ligne maintenant." : "Bijou créé, masqué pour l'instant : vous seule le voyez."), d({ fiche: l.UID })), (C || JSON.stringify(R?.collections) !== JSON.stringify(l.collections)) && z();
762
- },
763
- surSupprime: (l) => {
764
- q((C) => C?.filter((R) => R.UID !== l) ?? null), z(), d(null);
765
- }
766
- }
767
- )
768
- ] });
769
- }
770
- return /* @__PURE__ */ o("div", { ref: D, className: "panneau panneau--boutique", role: "dialog", "aria-modal": "false", "aria-label": "Boutique", children: [
771
- /* @__PURE__ */ e("style", { children: oe }),
772
- /* @__PURE__ */ e("div", { className: "poignee", "aria-hidden": "true" }),
773
- /* @__PURE__ */ o("div", { className: "b-tete", children: [
774
- /* @__PURE__ */ e("h2", { children: "Boutique" }),
775
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--icone bouton--discret", onClick: g, "aria-label": "Fermer la boutique", children: "✕" })
776
- ] }),
777
- /* @__PURE__ */ o("div", { className: "b-onglets", role: "tablist", "aria-label": "Objets de la boutique", children: [
778
- /* @__PURE__ */ o("button", { type: "button", role: "tab", "aria-selected": L === "bijoux", onClick: () => S("bijoux"), children: [
779
- "Bijoux",
780
- /* @__PURE__ */ e("small", { children: p?.length ?? "" })
781
- ] }),
782
- /* @__PURE__ */ o("button", { type: "button", role: "tab", "aria-selected": L === "collections", onClick: () => S("collections"), children: [
783
- "Collections",
784
- /* @__PURE__ */ e("small", { children: x.length || "" })
785
- ] })
786
- ] }),
787
- /* @__PURE__ */ o("div", { className: "panneau__corps", role: "tabpanel", children: [
788
- f && /* @__PURE__ */ o("p", { className: "message message--erreur", role: "alert", children: [
789
- f,
790
- " ",
791
- /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: () => {
792
- O();
793
- }, children: "Réessayer" })
794
- ] }),
795
- L === "bijoux" ? /* @__PURE__ */ o(H, { children: [
796
- /* @__PURE__ */ o("p", { className: "b-avis", role: "note", children: [
797
- "⚡ Ici, chaque enregistrement est ",
798
- /* @__PURE__ */ e("b", { children: "en ligne tout de suite" }),
799
- " — pas besoin de « Publier ». Un bijou pas encore prêt ? Laissez-le masqué."
800
- ] }),
801
- /* @__PURE__ */ e("button", { type: "button", className: "b-ajout", onClick: () => {
802
- U(null), d({ fiche: null });
803
- }, children: "+ Ajouter un bijou" }),
804
- /* @__PURE__ */ e(
805
- "input",
806
- {
807
- className: "b-recherche",
808
- type: "search",
809
- value: w,
810
- onChange: (r) => E(r.target.value),
811
- placeholder: "Chercher un bijou…",
812
- "aria-label": "Chercher un bijou par son nom"
813
- }
814
- ),
815
- /* @__PURE__ */ e("div", { className: "b-filtres", role: "group", "aria-label": "Filtrer les bijoux", children: ne.map(([r, a, l]) => /* @__PURE__ */ o("button", { type: "button", className: "b-puce", "aria-pressed": _ === r, onClick: () => v(r), children: [
816
- a,
817
- /* @__PURE__ */ e("small", { children: (p ?? []).filter(l).length })
818
- ] }, r)) }),
819
- p === null && !f && /* @__PURE__ */ e("p", { className: "b-vide", children: "Chargement de vos bijoux…" }),
820
- p !== null && n.length === 0 && /* @__PURE__ */ o("p", { className: "b-vide", children: [
821
- p.length === 0 ? "Aucun bijou pour l'instant. Ajoutez le premier !" : "Aucun bijou ne correspond.",
822
- (w || _ !== "tous") && p.length > 0 && /* @__PURE__ */ o(H, { children: [
823
- " ",
824
- /* @__PURE__ */ e("button", { type: "button", className: "b-puce", onClick: () => {
825
- E(""), v("tous");
826
- }, children: "Tout montrer" })
827
- ] })
828
- ] }),
829
- n.map((r) => {
830
- const a = r.visible ? r.vendu ? ["vendu", "Épuisé"] : ["vente", "En vente"] : ["masque", "Masqué"], l = r.stock.mode === "unique" ? "Pièce unique" : r.stock.mode === "illimite" ? "Sans limite" : `${r.stock.restant ?? 0} en stock`, C = r.collections.map(P).filter(Boolean).join(", ");
831
- return /* @__PURE__ */ o("button", { type: "button", className: "b-rangee", onClick: () => {
832
- U(null), d({ fiche: r.UID });
833
- }, children: [
834
- r.photos[0] ? /* @__PURE__ */ e("img", { className: "b-vignette", src: r.photos[0].src, alt: "", loading: "lazy" }) : /* @__PURE__ */ e("span", { className: "b-vignette b-vignette--vide", "aria-hidden": "true", children: "◇" }),
835
- /* @__PURE__ */ o("span", { className: "b-rangee__texte", children: [
836
- /* @__PURE__ */ e("span", { className: "b-rangee__nom", children: r.nom || "Sans nom" }),
837
- /* @__PURE__ */ o("span", { className: "b-rangee__meta", children: [
838
- be(r.prix),
839
- " · ",
840
- l,
841
- " · ",
842
- C || "aucune collection"
843
- ] })
844
- ] }),
845
- /* @__PURE__ */ e("span", { className: "b-etiquette b-etiquette--" + a[0], children: a[1] })
846
- ] }, r.UID);
847
- })
848
- ] }) : /* @__PURE__ */ e(
849
- me,
850
- {
851
- api: i,
852
- collections: x,
853
- produits: p ?? [],
854
- signaler: I,
855
- majCollection: (r) => N((a) => a.some((l) => l.UID === r.UID) ? a.map((l) => l.UID === r.UID ? r : l) : [...a, r]),
856
- majProduits: () => {
857
- i.produits().then(q).catch(() => {
858
- });
859
- }
860
- }
861
- )
862
- ] })
863
- ] });
864
- }
865
- export {
866
- Ue as default
867
- };