@lystech/sections 0.6.0 → 0.8.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.
@@ -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-BwBWlNYy.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
+ };