@lystech/sections 0.3.0 → 0.4.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/dist/SignatureLystech.d.ts +9 -1
- package/dist/editeur/Connexion.d.ts +4 -1
- package/dist/editeur/index.d.ts +4 -1
- package/dist/editeur/styles.d.ts +2 -1
- package/dist/editeur.js +631 -438
- package/dist/index.js +136 -122
- package/dist/morceaux/index.esm-B4AB50RA.js +29 -0
- package/dist/morceaux/index.esm-B4hL1FOE.js +6120 -0
- package/dist/morceaux/index.esm-Bd0PBW01.js +1541 -0
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1,74 +1,86 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { appliquerAuxTextes as
|
|
4
|
-
import { adaptateurI18next as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
1
|
+
import { jsx as x, jsxs as U, Fragment as T } from "react/jsx-runtime";
|
|
2
|
+
import { useState as m, useRef as D, useEffect as b, useCallback as O, useMemo as _, useContext as M, createContext as N } from "react";
|
|
3
|
+
import { appliquerAuxTextes as q } from "./morceaux/sourceTexte-BMPMpNg9.js";
|
|
4
|
+
import { adaptateurI18next as ot } from "./morceaux/sourceTexte-BMPMpNg9.js";
|
|
5
|
+
const u = "lystech-edit", P = "lystech-edit-sortie", J = N(null), H = "https://api.lystech.ca/api";
|
|
6
|
+
function W() {
|
|
7
7
|
if (typeof window > "u") return null;
|
|
8
8
|
const t = (n) => {
|
|
9
9
|
try {
|
|
10
|
-
window.
|
|
10
|
+
window.localStorage.setItem(u, n);
|
|
11
11
|
} catch {
|
|
12
|
+
try {
|
|
13
|
+
window.sessionStorage.setItem(u, n);
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
12
16
|
}
|
|
13
17
|
return n;
|
|
14
18
|
};
|
|
15
19
|
try {
|
|
20
|
+
if (window.localStorage.getItem(P)) {
|
|
21
|
+
window.localStorage.removeItem(P), window.localStorage.removeItem(u);
|
|
22
|
+
try {
|
|
23
|
+
window.sessionStorage.removeItem(u);
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
16
28
|
const n = window.location.hash.replace(/^#/, "");
|
|
17
|
-
if (n.includes(
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
const
|
|
29
|
+
if (n.includes(u + "=")) {
|
|
30
|
+
const o = new URLSearchParams(n), c = o.get(u);
|
|
31
|
+
if (c) {
|
|
32
|
+
o.delete(u);
|
|
33
|
+
const s = o.toString();
|
|
22
34
|
return window.history.replaceState(
|
|
23
35
|
{},
|
|
24
36
|
"",
|
|
25
|
-
window.location.pathname + window.location.search + (
|
|
26
|
-
), t(
|
|
37
|
+
window.location.pathname + window.location.search + (s ? "#" + s : "")
|
|
38
|
+
), t(c);
|
|
27
39
|
}
|
|
28
40
|
}
|
|
29
|
-
const e = new URL(window.location.href), r = e.searchParams.get(
|
|
30
|
-
return r ? (e.searchParams.delete(
|
|
41
|
+
const e = new URL(window.location.href), r = e.searchParams.get(u);
|
|
42
|
+
return r ? (e.searchParams.delete(u), window.history.replaceState({}, "", e.toString()), t(r)) : window.localStorage.getItem(u) ?? window.sessionStorage.getItem(u);
|
|
31
43
|
} catch {
|
|
32
44
|
return null;
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
|
-
function
|
|
47
|
+
function Y({
|
|
36
48
|
site: t,
|
|
37
49
|
page: n,
|
|
38
50
|
langue: e = "fr",
|
|
39
|
-
apiBaseUrl: r =
|
|
40
|
-
sectionsInitiales:
|
|
41
|
-
sourceTexte:
|
|
42
|
-
pagesPartagees:
|
|
43
|
-
children:
|
|
51
|
+
apiBaseUrl: r = H,
|
|
52
|
+
sectionsInitiales: o,
|
|
53
|
+
sourceTexte: c,
|
|
54
|
+
pagesPartagees: s,
|
|
55
|
+
children: f
|
|
44
56
|
}) {
|
|
45
|
-
const [
|
|
46
|
-
|
|
47
|
-
), [
|
|
48
|
-
|
|
49
|
-
), [
|
|
50
|
-
|
|
57
|
+
const [d, S] = m(
|
|
58
|
+
o ?? []
|
|
59
|
+
), [p, w] = m(
|
|
60
|
+
o?.length ? "pret" : "chargement"
|
|
61
|
+
), [E, g] = m(0), [y, $] = m({}), [R, z] = m(!1), L = D(null);
|
|
62
|
+
b(() => {
|
|
51
63
|
if (!t || !n) return;
|
|
52
|
-
|
|
64
|
+
L.current?.abort();
|
|
53
65
|
const a = new AbortController();
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
return fetch(
|
|
57
|
-
(
|
|
58
|
-
).then((
|
|
59
|
-
a.signal.aborted || (
|
|
60
|
-
}).catch((
|
|
61
|
-
a.signal.aborted ||
|
|
66
|
+
L.current = a, w("chargement");
|
|
67
|
+
const h = r + "/site-sections/public/" + encodeURIComponent(t) + "/" + encodeURIComponent([n, ...s ?? []].join(","));
|
|
68
|
+
return fetch(h, { signal: a.signal }).then(
|
|
69
|
+
(i) => i.ok ? i.json() : Promise.reject(new Error(String(i.status)))
|
|
70
|
+
).then((i) => {
|
|
71
|
+
a.signal.aborted || (S(Array.isArray(i) ? i : []), w("pret"));
|
|
72
|
+
}).catch((i) => {
|
|
73
|
+
a.signal.aborted || i?.name === "AbortError" || w("erreur");
|
|
62
74
|
}), () => a.abort();
|
|
63
|
-
}, [t, n, r,
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
!
|
|
67
|
-
}, [
|
|
75
|
+
}, [t, n, r, E, (s ?? []).join(",")]);
|
|
76
|
+
const I = O(() => g((a) => a + 1), []);
|
|
77
|
+
b(() => {
|
|
78
|
+
!c || !d.length || q(d, c);
|
|
79
|
+
}, [d, c]);
|
|
68
80
|
const j = O(
|
|
69
|
-
(a,
|
|
81
|
+
(a, h) => $((i) => ({ ...i, [a]: h })),
|
|
70
82
|
[]
|
|
71
|
-
), l =
|
|
83
|
+
), l = D({
|
|
72
84
|
site: t,
|
|
73
85
|
page: n,
|
|
74
86
|
langue: e,
|
|
@@ -77,89 +89,91 @@ function X({
|
|
|
77
89
|
recharger: () => {
|
|
78
90
|
}
|
|
79
91
|
});
|
|
80
|
-
l.current.site = t, l.current.page = n, l.current.langue = e, l.current.poserApercu = j, l.current.sourceTexte =
|
|
92
|
+
l.current.site = t, l.current.page = n, l.current.langue = e, l.current.poserApercu = j, l.current.sourceTexte = c, l.current.recharger = I, b(() => {
|
|
81
93
|
l.current.surChangementDePage?.(n);
|
|
82
|
-
}, [n]),
|
|
83
|
-
const a =
|
|
94
|
+
}, [n]), b(() => {
|
|
95
|
+
const a = W();
|
|
84
96
|
if (!a) return;
|
|
85
|
-
let
|
|
86
|
-
return import("@lystech/sections/editeur").then((
|
|
87
|
-
|
|
97
|
+
let h = !0, i;
|
|
98
|
+
return import("@lystech/sections/editeur").then((A) => {
|
|
99
|
+
h && (z(!0), i = A.monterEditeur({
|
|
88
100
|
jeton: a,
|
|
89
101
|
site: t,
|
|
90
102
|
apiBaseUrl: r,
|
|
91
103
|
pont: l.current
|
|
92
104
|
}));
|
|
93
|
-
}).catch((
|
|
94
|
-
console.error("[lystech] éditeur indisponible:",
|
|
105
|
+
}).catch((A) => {
|
|
106
|
+
console.error("[lystech] éditeur indisponible:", A?.message ?? A);
|
|
95
107
|
}), () => {
|
|
96
|
-
|
|
108
|
+
h = !1, i?.();
|
|
97
109
|
};
|
|
98
110
|
}, [t, r]);
|
|
99
|
-
const
|
|
111
|
+
const F = _(
|
|
100
112
|
() => ({
|
|
101
113
|
site: t,
|
|
102
114
|
page: n,
|
|
103
115
|
langue: e,
|
|
104
116
|
apiBaseUrl: r,
|
|
105
|
-
sections:
|
|
106
|
-
etat:
|
|
107
|
-
recharger:
|
|
108
|
-
apercu:
|
|
117
|
+
sections: d,
|
|
118
|
+
etat: p,
|
|
119
|
+
recharger: I,
|
|
120
|
+
apercu: y,
|
|
109
121
|
poserApercu: j,
|
|
110
|
-
modeEdition:
|
|
122
|
+
modeEdition: R
|
|
111
123
|
}),
|
|
112
124
|
[
|
|
113
125
|
t,
|
|
114
126
|
n,
|
|
115
127
|
e,
|
|
116
128
|
r,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
d,
|
|
130
|
+
p,
|
|
131
|
+
I,
|
|
132
|
+
y,
|
|
121
133
|
j,
|
|
122
|
-
|
|
134
|
+
R
|
|
123
135
|
]
|
|
124
136
|
);
|
|
125
|
-
return /* @__PURE__ */
|
|
137
|
+
return /* @__PURE__ */ x(J.Provider, { value: F, children: f });
|
|
126
138
|
}
|
|
127
|
-
function
|
|
128
|
-
return M(
|
|
139
|
+
function v() {
|
|
140
|
+
return M(J);
|
|
129
141
|
}
|
|
130
|
-
const
|
|
131
|
-
function
|
|
142
|
+
const Z = "https://api.lystech.ca/api", k = "lystech-edit";
|
|
143
|
+
function B({
|
|
132
144
|
site: t,
|
|
133
145
|
apiBaseUrl: n,
|
|
134
146
|
className: e,
|
|
135
147
|
mention: r = "Réalisé avec Lystech",
|
|
136
|
-
connexion:
|
|
148
|
+
connexion: o = "Connexion",
|
|
149
|
+
methodes: c
|
|
137
150
|
}) {
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
151
|
+
const s = v(), f = t ?? s?.site ?? "", d = n ?? s?.apiBaseUrl ?? Z, [S, p] = m(!1);
|
|
152
|
+
if (!f) return null;
|
|
140
153
|
const w = async () => {
|
|
141
|
-
if (!
|
|
142
|
-
|
|
154
|
+
if (!S) {
|
|
155
|
+
p(!0);
|
|
143
156
|
try {
|
|
144
157
|
(await import("@lystech/sections/editeur")).monterConnexion({
|
|
145
|
-
site:
|
|
146
|
-
apiBaseUrl:
|
|
147
|
-
|
|
158
|
+
site: f,
|
|
159
|
+
apiBaseUrl: d,
|
|
160
|
+
...c ? { methodes: c } : {},
|
|
161
|
+
surJeton: (y) => {
|
|
148
162
|
try {
|
|
149
|
-
window.
|
|
163
|
+
window.localStorage.removeItem("lystech-edit-sortie"), window.localStorage.setItem(k, y);
|
|
150
164
|
} catch {
|
|
151
|
-
window.location.hash =
|
|
165
|
+
window.location.hash = k + "=" + encodeURIComponent(y);
|
|
152
166
|
}
|
|
153
167
|
window.location.reload();
|
|
154
168
|
}
|
|
155
169
|
});
|
|
156
|
-
} catch (
|
|
157
|
-
console.error("[lystech] connexion indisponible:",
|
|
170
|
+
} catch (g) {
|
|
171
|
+
console.error("[lystech] connexion indisponible:", g?.message ?? g);
|
|
158
172
|
} finally {
|
|
159
|
-
|
|
173
|
+
p(!1);
|
|
160
174
|
}
|
|
161
175
|
}
|
|
162
|
-
},
|
|
176
|
+
}, E = {
|
|
163
177
|
color: "inherit",
|
|
164
178
|
font: "inherit",
|
|
165
179
|
background: "none",
|
|
@@ -169,7 +183,7 @@ function Y({
|
|
|
169
183
|
textDecoration: "underline",
|
|
170
184
|
textUnderlineOffset: "0.2em"
|
|
171
185
|
};
|
|
172
|
-
return /* @__PURE__ */
|
|
186
|
+
return /* @__PURE__ */ U(
|
|
173
187
|
"div",
|
|
174
188
|
{
|
|
175
189
|
className: e,
|
|
@@ -183,7 +197,7 @@ function Y({
|
|
|
183
197
|
lineHeight: 1.5
|
|
184
198
|
},
|
|
185
199
|
children: [
|
|
186
|
-
/* @__PURE__ */
|
|
200
|
+
/* @__PURE__ */ x(
|
|
187
201
|
"a",
|
|
188
202
|
{
|
|
189
203
|
href: "https://lystech.ca",
|
|
@@ -193,49 +207,49 @@ function Y({
|
|
|
193
207
|
children: r
|
|
194
208
|
}
|
|
195
209
|
),
|
|
196
|
-
!
|
|
197
|
-
/* @__PURE__ */
|
|
198
|
-
/* @__PURE__ */
|
|
210
|
+
!s?.modeEdition && /* @__PURE__ */ U(T, { children: [
|
|
211
|
+
/* @__PURE__ */ x("span", { "aria-hidden": "true", children: "·" }),
|
|
212
|
+
/* @__PURE__ */ x("button", { type: "button", style: E, onClick: w, children: S ? "…" : o })
|
|
199
213
|
] })
|
|
200
214
|
]
|
|
201
215
|
}
|
|
202
216
|
);
|
|
203
217
|
}
|
|
204
|
-
function
|
|
218
|
+
function G(t) {
|
|
205
219
|
return !!t && typeof t == "object" && !Array.isArray(t) && Object.keys(t).every((n) => /^[a-z]{2}(-[A-Za-z]{2})?$/.test(n));
|
|
206
220
|
}
|
|
207
221
|
function C(t, n) {
|
|
208
222
|
if (Array.isArray(t)) return t.map((e) => C(e, n));
|
|
209
|
-
if (
|
|
223
|
+
if (G(t)) {
|
|
210
224
|
const e = t, r = n.slice(0, 2);
|
|
211
|
-
return e[n] ?? e[r] ?? Object.values(e).find((
|
|
225
|
+
return e[n] ?? e[r] ?? Object.values(e).find((c) => c != null) ?? "";
|
|
212
226
|
}
|
|
213
227
|
if (t && typeof t == "object") {
|
|
214
228
|
const e = {};
|
|
215
|
-
for (const [r,
|
|
216
|
-
e[r] = C(
|
|
229
|
+
for (const [r, o] of Object.entries(t))
|
|
230
|
+
e[r] = C(o, n);
|
|
217
231
|
return e;
|
|
218
232
|
}
|
|
219
233
|
return t;
|
|
220
234
|
}
|
|
221
|
-
function
|
|
235
|
+
function K(t, n) {
|
|
222
236
|
if (!n || typeof n != "object" || Array.isArray(n))
|
|
223
237
|
return t;
|
|
224
238
|
const e = { ...t };
|
|
225
|
-
for (const [r,
|
|
226
|
-
|
|
239
|
+
for (const [r, o] of Object.entries(n))
|
|
240
|
+
o != null && (e[r] = o);
|
|
227
241
|
return e;
|
|
228
242
|
}
|
|
229
|
-
function
|
|
230
|
-
const e =
|
|
243
|
+
function tt(t, n) {
|
|
244
|
+
const e = v(), r = e?.apercu?.[t];
|
|
231
245
|
return _(() => {
|
|
232
|
-
const
|
|
233
|
-
(
|
|
234
|
-
),
|
|
246
|
+
const o = e?.sections.find(
|
|
247
|
+
(f) => f.blockType === t
|
|
248
|
+
), c = r ?? o?.data ?? null, s = c ? C(c, e?.langue ?? "fr") : null;
|
|
235
249
|
return {
|
|
236
|
-
contenu:
|
|
237
|
-
publie: !!
|
|
238
|
-
UID:
|
|
250
|
+
contenu: K(n.defaut, s),
|
|
251
|
+
publie: !!o?.data,
|
|
252
|
+
UID: o?.UID ?? null,
|
|
239
253
|
chargement: e?.etat === "chargement",
|
|
240
254
|
ancrage: { "data-lystech-section": t }
|
|
241
255
|
};
|
|
@@ -248,24 +262,24 @@ function B(t, n) {
|
|
|
248
262
|
n.defaut
|
|
249
263
|
]);
|
|
250
264
|
}
|
|
251
|
-
function
|
|
252
|
-
const e =
|
|
265
|
+
function et(t, n) {
|
|
266
|
+
const e = v();
|
|
253
267
|
return _(() => {
|
|
254
|
-
const r = { "data-lystech-section": t },
|
|
255
|
-
(
|
|
268
|
+
const r = { "data-lystech-section": t }, o = (e?.sections ?? []).filter(
|
|
269
|
+
(c) => c.blockType === t
|
|
256
270
|
);
|
|
257
|
-
return
|
|
258
|
-
items: (n?.defaut ?? []).map((
|
|
259
|
-
...
|
|
260
|
-
__uid: `defaut-${
|
|
271
|
+
return o.length === 0 ? {
|
|
272
|
+
items: (n?.defaut ?? []).map((c, s) => ({
|
|
273
|
+
...c,
|
|
274
|
+
__uid: `defaut-${s}`
|
|
261
275
|
})),
|
|
262
276
|
publie: !1,
|
|
263
277
|
chargement: e?.etat === "chargement",
|
|
264
278
|
ancrage: r
|
|
265
279
|
} : {
|
|
266
|
-
items:
|
|
267
|
-
...C(
|
|
268
|
-
__uid:
|
|
280
|
+
items: o.map((c) => ({
|
|
281
|
+
...C(c.data ?? {}, e?.langue ?? "fr"),
|
|
282
|
+
__uid: c.UID
|
|
269
283
|
})),
|
|
270
284
|
publie: !0,
|
|
271
285
|
chargement: e?.etat === "chargement",
|
|
@@ -274,11 +288,11 @@ function tt(t, n) {
|
|
|
274
288
|
}, [e?.sections, e?.langue, e?.etat, t, n?.defaut]);
|
|
275
289
|
}
|
|
276
290
|
export {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
291
|
+
Y as SectionsProvider,
|
|
292
|
+
B as SignatureLystech,
|
|
293
|
+
ot as adaptateurI18next,
|
|
294
|
+
q as appliquerAuxTextes,
|
|
295
|
+
tt as useSection,
|
|
296
|
+
et as useSectionList,
|
|
297
|
+
v as useSectionsContext
|
|
284
298
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { r as e } from "./index.esm-Bd0PBW01.js";
|
|
2
|
+
import { F as o, S as t, D as n, _, a as v, b as m, c as A, d as g, e as S, f as d, g as b, h as l, i as F, j as c, k as E, l as f, m as C, n as L, o as D, p as N, q as O, s as x } from "./index.esm-Bd0PBW01.js";
|
|
3
|
+
var s = "firebase", a = "12.19.0";
|
|
4
|
+
e(s, a, "app");
|
|
5
|
+
export {
|
|
6
|
+
o as FirebaseError,
|
|
7
|
+
t as SDK_VERSION,
|
|
8
|
+
n as _DEFAULT_ENTRY_NAME,
|
|
9
|
+
_ as _addComponent,
|
|
10
|
+
v as _addOrOverwriteComponent,
|
|
11
|
+
m as _apps,
|
|
12
|
+
A as _clearComponents,
|
|
13
|
+
g as _components,
|
|
14
|
+
S as _getProvider,
|
|
15
|
+
d as _isFirebaseApp,
|
|
16
|
+
b as _isFirebaseServerApp,
|
|
17
|
+
l as _isFirebaseServerAppSettings,
|
|
18
|
+
F as _registerComponent,
|
|
19
|
+
c as _removeServiceInstance,
|
|
20
|
+
E as _serverApps,
|
|
21
|
+
f as deleteApp,
|
|
22
|
+
C as getApp,
|
|
23
|
+
L as getApps,
|
|
24
|
+
D as initializeApp,
|
|
25
|
+
N as initializeServerApp,
|
|
26
|
+
O as onLog,
|
|
27
|
+
e as registerVersion,
|
|
28
|
+
x as setLogLevel
|
|
29
|
+
};
|