@lystech/sections 0.6.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.
- package/README.md +188 -1
- package/dist/Audience.d.ts +14 -0
- package/dist/BoutonEdition.d.ts +13 -0
- package/dist/BoutonEditionCorps.d.ts +12 -0
- package/dist/SectionsProvider.d.ts +62 -2
- package/dist/catalogue.d.ts +30 -0
- package/dist/constantes.d.ts +38 -0
- package/dist/editeur/ApercuMobile.d.ts +7 -0
- package/dist/editeur/ChoixAudience.d.ts +6 -0
- package/dist/editeur/MarquesBoutique.d.ts +26 -0
- package/dist/editeur/api.d.ts +16 -1
- package/dist/editeur/boutique/Collections.d.ts +8 -0
- package/dist/editeur/boutique/FicheCollection.d.ts +23 -0
- package/dist/editeur/boutique/FicheProduit.d.ts +23 -0
- package/dist/editeur/boutique/ListeVirtuelle.d.ts +13 -0
- package/dist/editeur/boutique/ModuleBoutique.d.ts +44 -0
- package/dist/editeur/boutique/Publier.d.ts +15 -0
- package/dist/editeur/boutique/Selecteur.d.ts +10 -0
- package/dist/editeur/boutique/api.d.ts +131 -0
- package/dist/editeur/boutique/commun.d.ts +19 -0
- package/dist/editeur/boutique/photos.d.ts +9 -0
- package/dist/editeur/boutique/styles.d.ts +1 -0
- package/dist/editeur/pont.d.ts +7 -0
- package/dist/editeur/styles.d.ts +1 -1
- package/dist/editeur.js +6 -1736
- package/dist/index.d.ts +9 -2
- package/dist/index.js +351 -209
- package/dist/morceaux/ApercuMobile-CSoo4dpM.js +63 -0
- package/dist/morceaux/BoutonEditionCorps-B57eJtJn.js +112 -0
- package/dist/morceaux/ModuleBoutique-CgqcQjIb.js +1509 -0
- package/dist/morceaux/constantes-BAdpe1ss.js +24 -0
- package/dist/morceaux/index-C_uFDnBO.js +2217 -0
- package/dist/types.d.ts +30 -0
- package/dist/useSection.d.ts +15 -0
- package/package.json +46 -46
- package/dist/morceaux/constantes-BPZxUYge.js +0 -19
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsxs as a, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as p, useState as E, useEffect as s } from "react";
|
|
3
|
+
import { F as m, E as u } from "./constantes-BAdpe1ss.js";
|
|
4
|
+
const v = 390;
|
|
5
|
+
function A({
|
|
6
|
+
brouillons: r,
|
|
7
|
+
surFermer: c
|
|
8
|
+
}) {
|
|
9
|
+
const o = p(null), [f, d] = E(0), [l, g] = E(() => Math.min(844, window.innerHeight - 140)), y = (() => {
|
|
10
|
+
const e = new URL(window.location.href);
|
|
11
|
+
return e.hash = "", e.searchParams.set(m, "1"), e.toString();
|
|
12
|
+
})(), w = p(r);
|
|
13
|
+
return w.current = r, s(() => {
|
|
14
|
+
const e = (t) => {
|
|
15
|
+
const n = o.current?.contentWindow;
|
|
16
|
+
!n || t.source !== n || t.origin !== window.location.origin || t.data?.lystech === "apercu-pret" && n.postMessage({ lystech: "apercu", blocs: w.current }, window.location.origin);
|
|
17
|
+
};
|
|
18
|
+
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
19
|
+
}, []), s(() => {
|
|
20
|
+
o.current?.contentWindow?.postMessage({ lystech: "apercu", blocs: r }, window.location.origin);
|
|
21
|
+
}, [r]), s(() => {
|
|
22
|
+
const e = (n) => {
|
|
23
|
+
const h = o.current?.contentWindow;
|
|
24
|
+
try {
|
|
25
|
+
h?.dispatchEvent(new h.CustomEvent(u, { detail: n.detail }));
|
|
26
|
+
} catch {
|
|
27
|
+
d((L) => L + 1);
|
|
28
|
+
}
|
|
29
|
+
}, t = () => g(Math.min(844, window.innerHeight - 140));
|
|
30
|
+
return window.addEventListener(u, e), window.addEventListener("resize", t), () => {
|
|
31
|
+
window.removeEventListener(u, e), window.removeEventListener("resize", t);
|
|
32
|
+
};
|
|
33
|
+
}, []), s(() => {
|
|
34
|
+
const e = (t) => {
|
|
35
|
+
t.key === "Escape" && c();
|
|
36
|
+
};
|
|
37
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
38
|
+
}, [c]), /* @__PURE__ */ a("div", { className: "apercu", role: "dialog", "aria-label": "Aperçu sur téléphone", children: [
|
|
39
|
+
/* @__PURE__ */ a("div", { className: "apercu__barre", children: [
|
|
40
|
+
/* @__PURE__ */ a("span", { children: [
|
|
41
|
+
"Aperçu téléphone · ",
|
|
42
|
+
v,
|
|
43
|
+
" px — ce que voient vos visiteurs"
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ i("button", { type: "button", className: "bouton bouton--discret", onClick: () => d((e) => e + 1), children: "Recharger" }),
|
|
46
|
+
/* @__PURE__ */ i("button", { type: "button", className: "bouton bouton--principal", onClick: c, autoFocus: !0, children: "Retour au bureau" })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ i("div", { className: "apercu__tel", style: { height: l + 24 }, children: /* @__PURE__ */ i(
|
|
49
|
+
"iframe",
|
|
50
|
+
{
|
|
51
|
+
ref: o,
|
|
52
|
+
name: m,
|
|
53
|
+
title: "La page, sur un téléphone",
|
|
54
|
+
src: y,
|
|
55
|
+
style: { width: v, height: l }
|
|
56
|
+
},
|
|
57
|
+
f
|
|
58
|
+
) })
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
A as default
|
|
63
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsxs as m, Fragment as S, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useEffect as g } from "react";
|
|
3
|
+
import { C as b } from "./constantes-BAdpe1ss.js";
|
|
4
|
+
import { useSectionsContext as C } from "../index.js";
|
|
5
|
+
const v = "lystech-peut-editer", I = `
|
|
6
|
+
.lystech-crayon-edition {
|
|
7
|
+
position: fixed; z-index: 2147482000;
|
|
8
|
+
bottom: calc(16px + env(safe-area-inset-bottom, 0px));
|
|
9
|
+
width: 56px; height: 56px; border-radius: 50%; border: 0; padding: 0;
|
|
10
|
+
display: grid; place-items: center; cursor: pointer;
|
|
11
|
+
background: #16181d; color: #fff;
|
|
12
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
|
|
13
|
+
-webkit-tap-highlight-color: transparent;
|
|
14
|
+
}
|
|
15
|
+
.lystech-crayon-edition--gauche { left: calc(16px + env(safe-area-inset-left, 0px)); }
|
|
16
|
+
.lystech-crayon-edition--droite { right: calc(16px + env(safe-area-inset-right, 0px)); }
|
|
17
|
+
.lystech-crayon-edition:hover { background: #3ba58d; color: #06120e; }
|
|
18
|
+
.lystech-crayon-edition:focus-visible { outline: 3px solid #3ba58d; outline-offset: 3px; }
|
|
19
|
+
.lystech-crayon-edition[aria-busy="true"] { opacity: .7; cursor: progress; }
|
|
20
|
+
.lystech-crayon-edition svg { width: 22px; height: 22px; }
|
|
21
|
+
.lystech-crayon-edition__bulle {
|
|
22
|
+
position: fixed; z-index: 2147482000; max-width: min(280px, calc(100vw - 32px));
|
|
23
|
+
bottom: calc(80px + env(safe-area-inset-bottom, 0px));
|
|
24
|
+
padding: 8px 12px; border-radius: 10px; background: #16181d; color: #fff;
|
|
25
|
+
font: 500 13px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
26
|
+
}
|
|
27
|
+
@media print { .lystech-crayon-edition, .lystech-crayon-edition__bulle { display: none; } }
|
|
28
|
+
`;
|
|
29
|
+
function L({
|
|
30
|
+
connecte: a,
|
|
31
|
+
peutEditer: s,
|
|
32
|
+
coin: u = "gauche",
|
|
33
|
+
libelle: p = "Modifier le site"
|
|
34
|
+
}) {
|
|
35
|
+
const e = C(), [w, r] = d(s ?? null), [h, f] = d(!1), [y, c] = d(null), l = !!e && a && !e.modeEdition && !e.modeApercu && !!e.site;
|
|
36
|
+
if (g(() => {
|
|
37
|
+
if (s !== void 0) {
|
|
38
|
+
r(s);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!l || !e) return;
|
|
42
|
+
const o = v + ":" + e.site;
|
|
43
|
+
try {
|
|
44
|
+
const t = window.sessionStorage.getItem(o);
|
|
45
|
+
if (t === "1" || t === "0") {
|
|
46
|
+
r(t === "1");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
let i = !0;
|
|
52
|
+
return e.appelSession("/site-sections/session-edition/acces/" + encodeURIComponent(e.site)).then((t) => t.ok ? t.json() : null).then((t) => {
|
|
53
|
+
if (!i || !t) return;
|
|
54
|
+
const x = t.peutEditer === !0;
|
|
55
|
+
if (r(x), t.connecte)
|
|
56
|
+
try {
|
|
57
|
+
window.sessionStorage.setItem(o, x ? "1" : "0");
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}).catch(() => {
|
|
61
|
+
}), () => {
|
|
62
|
+
i = !1;
|
|
63
|
+
};
|
|
64
|
+
}, [l, s, e?.site]), g(() => {
|
|
65
|
+
if (!(a || !e?.site))
|
|
66
|
+
try {
|
|
67
|
+
window.sessionStorage.removeItem(v + ":" + e.site);
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
}, [a, e?.site]), !l || !w || !e) return null;
|
|
71
|
+
const k = async () => {
|
|
72
|
+
if (!h) {
|
|
73
|
+
f(!0), c(null);
|
|
74
|
+
try {
|
|
75
|
+
const o = await e.appelSession("/site-sections/session-edition/jeton/" + encodeURIComponent(e.site), { method: "POST" }), i = await o.json().catch(() => null);
|
|
76
|
+
if (!o.ok || !i?.token) {
|
|
77
|
+
c(i?.error ?? "Impossible d'ouvrir l'édition. Réessayez."), o.status === 403 && r(!1);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
e.entrerEnEdition(i.token);
|
|
81
|
+
} catch {
|
|
82
|
+
c("Pas de connexion au serveur. Vérifiez Internet et réessayez.");
|
|
83
|
+
} finally {
|
|
84
|
+
f(!1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return /* @__PURE__ */ m(S, { children: [
|
|
89
|
+
/* @__PURE__ */ n("style", { children: I }),
|
|
90
|
+
/* @__PURE__ */ n(
|
|
91
|
+
"button",
|
|
92
|
+
{
|
|
93
|
+
type: "button",
|
|
94
|
+
className: `lystech-crayon-edition lystech-crayon-edition--${u} ${b}`,
|
|
95
|
+
onClick: () => {
|
|
96
|
+
k();
|
|
97
|
+
},
|
|
98
|
+
"aria-label": p,
|
|
99
|
+
title: p,
|
|
100
|
+
"aria-busy": h,
|
|
101
|
+
children: /* @__PURE__ */ m("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
102
|
+
/* @__PURE__ */ n("path", { d: "M12 20h9" }),
|
|
103
|
+
/* @__PURE__ */ n("path", { d: "M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z" })
|
|
104
|
+
] })
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
y && /* @__PURE__ */ n("p", { role: "alert", className: `lystech-crayon-edition__bulle ${b}`, style: u === "gauche" ? { left: 16 } : { right: 16 }, children: y })
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
L as default
|
|
112
|
+
};
|