@gouvfr-lasuite/ui-kit 0.22.0 → 0.23.1

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,10 +1,8 @@
1
- import { O as se, T as ie, j as n, a as E, b as A, c as W, L as ce, Z as ae, u as Y, D as le, I as de, d as ue, e as pe } from "./index-BwV1Jx-_.js";
2
- import { useState as I, useCallback as u, useRef as b, useEffect as S, useMemo as $, useImperativeHandle as fe } from "react";
3
- import { useQuery as he } from "@tanstack/react-query";
4
- import { Thumbnail as we, Page as me, pdfjs as ge, Document as ve } from "react-pdf";
5
- import "react-pdf/dist/Page/AnnotationLayer.css";
6
- import "react-pdf/dist/Page/TextLayer.css";
7
- import "react-virtualized/styles.css";
1
+ import { j as n, I as oe } from "./ZoomPlus-pBCoSTnV.js";
2
+ import { useState as I, useCallback as u, useRef as b, useEffect as S, useMemo as W, useImperativeHandle as ie } from "react";
3
+ import { useQuery as ce } from "@tanstack/react-query";
4
+ import { Thumbnail as ae, Page as le, pdfjs as de, Document as ue } from "react-pdf";
5
+ import { O as pe, T as fe, a as E, b as A, c as $, L as he, Z as we, u as Y, D as me, I as ge, d as ve } from "./index-B6GHSbZ5.js";
8
6
  import { AutoSizer as J, List as X } from "react-virtualized";
9
7
  import { Button as _e, Input as xe, useModals as Pe } from "@gouvfr-lasuite/cunningham-react";
10
8
  typeof URL.parse > "u" && (URL.parse = function(t, e) {
@@ -17,8 +15,8 @@ typeof URL.parse > "u" && (URL.parse = function(t, e) {
17
15
  const z = Promise;
18
16
  typeof z.withResolvers > "u" && (z.withResolvers = function() {
19
17
  let t, e;
20
- return { promise: new Promise((a, o) => {
21
- t = a, e = o;
18
+ return { promise: new Promise((a, s) => {
19
+ t = a, e = s;
22
20
  }), resolve: t, reject: e };
23
21
  });
24
22
  const Re = ({
@@ -26,21 +24,21 @@ const Re = ({
26
24
  currentPage: e,
27
25
  scrollToPage: r
28
26
  }) => {
29
- const [a, o] = I("1"), i = u(
27
+ const [a, s] = I("1"), i = u(
30
28
  (h) => {
31
29
  const x = Math.max(1, Math.min(t, h));
32
- o(String(x)), r(x);
30
+ s(String(x)), r(x);
33
31
  },
34
32
  [t, r]
35
33
  ), p = u(
36
- ({ numPages: h }) => (o("1"), h),
34
+ ({ numPages: h }) => (s("1"), h),
37
35
  []
38
36
  ), R = (h) => {
39
- o(h.target.value);
37
+ s(h.target.value);
40
38
  }, m = () => {
41
39
  const h = parseInt(a, 10);
42
40
  if (isNaN(h)) {
43
- o(String(e));
41
+ s(String(e));
44
42
  return;
45
43
  }
46
44
  i(h);
@@ -57,7 +55,7 @@ const Re = ({
57
55
  goToPage: i,
58
56
  onDocumentLoadSuccess: p,
59
57
  pageInputValue: a,
60
- setPageInputValue: o,
58
+ setPageInputValue: s,
61
59
  handlePageInputChange: R,
62
60
  handlePageInputSubmit: m,
63
61
  handlePageInputKeyDown: f,
@@ -65,8 +63,8 @@ const Re = ({
65
63
  };
66
64
  }, O = 1.414;
67
65
  function je() {
68
- const t = b(null), e = b(/* @__PURE__ */ new Map()), r = b(/* @__PURE__ */ new Map()), [a, o] = I(() => /* @__PURE__ */ new Map()), i = u((f) => {
69
- t.current = f, e.current = /* @__PURE__ */ new Map(), r.current = /* @__PURE__ */ new Map(), o(/* @__PURE__ */ new Map());
66
+ const t = b(null), e = b(/* @__PURE__ */ new Map()), r = b(/* @__PURE__ */ new Map()), [a, s] = I(() => /* @__PURE__ */ new Map()), i = u((f) => {
67
+ t.current = f, e.current = /* @__PURE__ */ new Map(), r.current = /* @__PURE__ */ new Map(), s(/* @__PURE__ */ new Map());
70
68
  }, []), p = u((f) => {
71
69
  const g = t.current;
72
70
  if (!g || r.current.has(f))
@@ -75,8 +73,8 @@ function je() {
75
73
  if (N)
76
74
  return N;
77
75
  const h = g.getPage(f).then((x) => {
78
- const l = x.getViewport({ scale: 1 }), s = new Map(r.current);
79
- s.set(f, { w: l.width, h: l.height }), r.current = s, o(s);
76
+ const l = x.getViewport({ scale: 1 }), o = new Map(r.current);
77
+ o.set(f, { w: l.width, h: l.height }), r.current = o, s(o);
80
78
  }).catch((x) => {
81
79
  console.warn(`Failed to fetch dimensions for PDF page ${f}`, x);
82
80
  }).finally(() => {
@@ -100,10 +98,10 @@ function je() {
100
98
  };
101
99
  }
102
100
  function Ie(t) {
103
- const [e, r] = I(!0), [a, o] = I(t.isOpen);
101
+ const [e, r] = I(!0), [a, s] = I(t.isOpen);
104
102
  return S(() => {
105
103
  let i;
106
- return t.isOpen ? (r(!1), i = setTimeout(() => o(!0), se)) : (o(!1), i = setTimeout(() => r(!0), ie * 1.1)), () => clearTimeout(i);
104
+ return t.isOpen ? (r(!1), i = setTimeout(() => s(!0), pe)) : (s(!1), i = setTimeout(() => r(!0), fe * 1.1)), () => clearTimeout(i);
107
105
  }, [t.isOpen]), e ? null : /* @__PURE__ */ n.jsx(be, { ...t, isOpen: a });
108
106
  }
109
107
  function be({
@@ -111,7 +109,7 @@ function be({
111
109
  currentPage: e,
112
110
  goToPage: r,
113
111
  isOpen: a,
114
- pageDimensions: o,
112
+ pageDimensions: s,
115
113
  requestPageDimension: i
116
114
  }) {
117
115
  const p = b(null), R = b(!1), [m, f] = I(e - 1);
@@ -126,13 +124,13 @@ function be({
126
124
  }, [e]);
127
125
  const g = u(
128
126
  (l) => {
129
- const s = o.get(l + 1);
130
- return s ? s.h / s.w : O;
127
+ const o = s.get(l + 1);
128
+ return o ? o.h / o.w : O;
131
129
  },
132
- [o]
130
+ [s]
133
131
  ), N = u(
134
132
  ({ index: l }) => {
135
- const _ = E * g(l) + W + A;
133
+ const _ = E * g(l) + $ + A;
136
134
  return l === t - 1 ? _ + A : _;
137
135
  },
138
136
  [g, t]
@@ -140,18 +138,18 @@ function be({
140
138
  S(() => {
141
139
  var l;
142
140
  (l = p.current) == null || l.recomputeRowHeights();
143
- }, [o, t]);
141
+ }, [s, t]);
144
142
  const h = u(
145
143
  ({
146
144
  overscanStartIndex: l,
147
- overscanStopIndex: s
145
+ overscanStopIndex: o
148
146
  }) => {
149
- for (let _ = l; _ <= s; _++)
147
+ for (let _ = l; _ <= o; _++)
150
148
  i(_ + 1);
151
149
  m !== void 0 && f(void 0);
152
150
  },
153
151
  [i, m]
154
- ), x = ({ index: l, key: s, style: _ }) => {
152
+ ), x = ({ index: l, key: o, style: _ }) => {
155
153
  const P = l + 1, k = g(l), y = /* @__PURE__ */ n.jsx(
156
154
  "div",
157
155
  {
@@ -179,7 +177,7 @@ function be({
179
177
  "aria-label": `Go to page ${P}`,
180
178
  children: [
181
179
  /* @__PURE__ */ n.jsx(
182
- we,
180
+ ae,
183
181
  {
184
182
  pageNumber: P,
185
183
  width: E,
@@ -191,22 +189,22 @@ function be({
191
189
  }
192
190
  )
193
191
  },
194
- s
192
+ o
195
193
  );
196
194
  };
197
195
  return /* @__PURE__ */ n.jsx(
198
196
  "div",
199
197
  {
200
198
  className: `pdf-preview__sidebar${a ? "" : " pdf-preview__sidebar--closed"}`,
201
- children: /* @__PURE__ */ n.jsx(J, { children: ({ height: l, width: s }) => /* @__PURE__ */ n.jsx(
199
+ children: /* @__PURE__ */ n.jsx(J, { children: ({ height: l, width: o }) => /* @__PURE__ */ n.jsx(
202
200
  X,
203
201
  {
204
202
  ref: p,
205
203
  height: l,
206
- width: s,
204
+ width: o,
207
205
  rowCount: t,
208
206
  rowHeight: N,
209
- estimatedRowSize: E * O + W + A,
207
+ estimatedRowSize: E * O + $ + A,
210
208
  overscanRowCount: 5,
211
209
  rowRenderer: x,
212
210
  scrollToIndex: m,
@@ -223,7 +221,7 @@ function Ne({
223
221
  pageInputValue: e,
224
222
  onToggleSidebar: r,
225
223
  onPageInputChange: a,
226
- onPageInputSubmit: o,
224
+ onPageInputSubmit: s,
227
225
  onPageInputKeyDown: i,
228
226
  onZoomIn: p,
229
227
  onZoomReset: R,
@@ -238,7 +236,7 @@ function Ne({
238
236
  onClick: r,
239
237
  "aria-label": "Toggle sidebar",
240
238
  size: "small",
241
- icon: /* @__PURE__ */ n.jsx(ce, {})
239
+ icon: /* @__PURE__ */ n.jsx(he, {})
242
240
  }
243
241
  ),
244
242
  /* @__PURE__ */ n.jsx("div", { className: "file-preview__controls__separator" }),
@@ -249,7 +247,7 @@ function Ne({
249
247
  variant: "classic",
250
248
  value: e,
251
249
  onChange: a,
252
- onBlur: o,
250
+ onBlur: s,
253
251
  onKeyDown: i,
254
252
  "aria-label": "Current page",
255
253
  size: e.length || 1
@@ -262,7 +260,7 @@ function Ne({
262
260
  ] }) }),
263
261
  /* @__PURE__ */ n.jsx("div", { className: "file-preview__controls__separator" }),
264
262
  /* @__PURE__ */ n.jsx(
265
- ae,
263
+ we,
266
264
  {
267
265
  zoomOut: m,
268
266
  zoomIn: p,
@@ -273,9 +271,9 @@ function Ne({
273
271
  }
274
272
  function Te(t, e = 300) {
275
273
  let r;
276
- const a = (...o) => {
274
+ const a = (...s) => {
277
275
  r !== void 0 && clearTimeout(r), r = setTimeout(() => {
278
- t(...o);
276
+ t(...s);
279
277
  }, e);
280
278
  };
281
279
  return a.cancel = () => {
@@ -301,23 +299,23 @@ function ye({
301
299
  zoom: e,
302
300
  onCurrentPageChange: r,
303
301
  onClick: a,
304
- pageDimensions: o,
302
+ pageDimensions: s,
305
303
  requestPageDimension: i,
306
304
  ensurePageDimensions: p,
307
305
  ref: R
308
306
  }) {
309
- const m = b(null), f = b(e), [g, N] = I(0), h = b(0), x = b(0), l = Se(), s = $(() => q + Q > l.width ? l.width - Q : q, [l.width]), _ = u(
307
+ const m = b(null), f = b(e), [g, N] = I(0), h = b(0), x = b(0), l = Se(), o = W(() => q + Q > l.width ? l.width - Q : q, [l.width]), _ = u(
310
308
  (c) => {
311
- const d = o.get(c + 1);
309
+ const d = s.get(c + 1);
312
310
  return d ? d.h / d.w : O;
313
311
  },
314
- [o]
312
+ [s]
315
313
  ), P = u(
316
314
  (c) => {
317
- const d = s * _(c) * e, w = M * e;
315
+ const d = o * _(c) * e, w = M * e;
318
316
  return c === t - 1 ? d + 2 * w : d + w;
319
317
  },
320
- [s, _, e, t]
318
+ [o, _, e, t]
321
319
  ), k = u(
322
320
  ({ index: c }) => P(c),
323
321
  [P]
@@ -328,8 +326,8 @@ function ye({
328
326
  const d = e / f.current, w = Math.round(g * d);
329
327
  m.current.scrollToPosition(w), f.current = e;
330
328
  }
331
- }, [e, s, o, t]);
332
- const y = $(() => {
329
+ }, [e, o, s, t]);
330
+ const y = W(() => {
333
331
  if (t === 0) return 1;
334
332
  const c = g + h.current / 2;
335
333
  let d = 0;
@@ -354,14 +352,14 @@ function ye({
354
352
  let C = 0;
355
353
  for (let L = 0; L < c - 1; L++) {
356
354
  const D = j.get(L + 1), K = D ? D.h / D.w : O;
357
- C += s * K * e + M * e;
355
+ C += o * K * e + M * e;
358
356
  }
359
357
  m.current.scrollToPosition(C);
360
358
  });
361
359
  },
362
- [p, s, e]
360
+ [p, o, e]
363
361
  );
364
- fe(R, () => ({ scrollToPage: F }), [F]);
362
+ ie(R, () => ({ scrollToPage: F }), [F]);
365
363
  const U = u(
366
364
  ({
367
365
  scrollTop: c,
@@ -384,7 +382,7 @@ function ye({
384
382
  "div",
385
383
  {
386
384
  className: "pdf-preview__page-skeleton pdf-preview__page-skeleton--measured",
387
- style: { height: s * j * e, width: s * e }
385
+ style: { height: o * j * e, width: o * e }
388
386
  }
389
387
  );
390
388
  return /* @__PURE__ */ n.jsx(
@@ -398,10 +396,10 @@ function ye({
398
396
  paddingBottom: c === t - 1 ? M * e : 0
399
397
  },
400
398
  children: /* @__PURE__ */ n.jsx(
401
- me,
399
+ le,
402
400
  {
403
401
  pageNumber: c + 1,
404
- width: s,
402
+ width: o,
405
403
  scale: e,
406
404
  loading: C
407
405
  }
@@ -411,7 +409,7 @@ function ye({
411
409
  );
412
410
  };
413
411
  return /* @__PURE__ */ n.jsx("div", { className: "pdf-preview__container", onClick: a, children: /* @__PURE__ */ n.jsx(J, { children: ({ height: c, width: d }) => {
414
- const w = Math.max(d, s * e);
412
+ const w = Math.max(d, o * e);
415
413
  return /* @__PURE__ */ n.jsx(
416
414
  "div",
417
415
  {
@@ -428,7 +426,7 @@ function ye({
428
426
  width: w,
429
427
  rowCount: t,
430
428
  rowHeight: k,
431
- estimatedRowSize: s * O * e + M * e,
429
+ estimatedRowSize: o * O * e + M * e,
432
430
  overscanRowCount: 3,
433
431
  onScroll: U,
434
432
  onRowsRendered: B,
@@ -475,18 +473,18 @@ const Ce = ["https:", "http:"], ke = () => {
475
473
  wasmUrl: "/wasm/",
476
474
  isEvalSupported: !1
477
475
  };
478
- function Ge({
476
+ function Ue({
479
477
  src: t,
480
478
  onThumbailSidebarOpen: e,
481
- pdfWorkerSrc: r = le
479
+ pdfWorkerSrc: r = me
482
480
  }) {
483
- ge.GlobalWorkerOptions.workerSrc = r;
484
- const { t: a } = Y(), [o, i] = I(1), [p, R] = I(null), [m, f] = I(1), [g, N] = I(!1), h = b(null), { handlePdfClick: x } = ke(), [l, s] = I(1), { pageDimensions: _, requestPageDimension: P, ensurePageDimensions: k, setPdf: y } = je(), F = u(() => {
485
- s((v) => Math.min(3, v + 0.25));
481
+ de.GlobalWorkerOptions.workerSrc = r;
482
+ const { t: a } = Y(), [s, i] = I(1), [p, R] = I(null), [m, f] = I(1), [g, N] = I(!1), h = b(null), { handlePdfClick: x } = ke(), [l, o] = I(1), { pageDimensions: _, requestPageDimension: P, ensurePageDimensions: k, setPdf: y } = je(), F = u(() => {
483
+ o((v) => Math.min(3, v + 0.25));
486
484
  }, []), U = u(() => {
487
- s((v) => Math.max(0.5, v - 0.25));
485
+ o((v) => Math.max(0.5, v - 0.25));
488
486
  }, []), B = u(() => {
489
- s(1);
487
+ o(1);
490
488
  }, []), G = u(() => {
491
489
  N((v) => (e == null || e(!v), !v));
492
490
  }, []), c = u((v) => {
@@ -501,11 +499,11 @@ function Ge({
501
499
  handlePageInputSubmit: D,
502
500
  handlePageInputKeyDown: K,
503
501
  onItemClick: ee
504
- } = Re({ numPages: o, currentPage: m, scrollToPage: c });
502
+ } = Re({ numPages: s, currentPage: m, scrollToPage: c });
505
503
  S(() => {
506
504
  C(String(m));
507
505
  }, [m, C]);
508
- const { data: Z, error: H } = he({
506
+ const { data: Z, error: H } = ce({
509
507
  queryKey: ["pdf", t],
510
508
  queryFn: async ({ signal: v }) => {
511
509
  const T = await fetch(t, {
@@ -514,8 +512,8 @@ function Ge({
514
512
  });
515
513
  if (!T.ok)
516
514
  throw new Error(`Failed to fetch PDF: ${T.status}`);
517
- const re = await T.blob(), oe = t.split("/").pop() || "document.pdf";
518
- return new File([re], oe, { type: "application/pdf" });
515
+ const re = await T.blob(), se = t.split("/").pop() || "document.pdf";
516
+ return new File([re], se, { type: "application/pdf" });
519
517
  },
520
518
  staleTime: 1 / 0
521
519
  }), te = u(
@@ -535,16 +533,16 @@ function Ge({
535
533
  }, []);
536
534
  if (console.log(H), H != null && H.message || p === "generic")
537
535
  return /* @__PURE__ */ n.jsxs("div", { className: "file-preview-unsupported", "data-preview-backdrop": "true", children: [
538
- /* @__PURE__ */ n.jsx("div", { className: "file-preview-unsupported__icon", children: /* @__PURE__ */ n.jsx(de, { name: "error", type: ue.OUTLINED, size: 48 }) }),
536
+ /* @__PURE__ */ n.jsx("div", { className: "file-preview-unsupported__icon", children: /* @__PURE__ */ n.jsx(ge, { name: "error", type: oe.OUTLINED, size: 48 }) }),
539
537
  /* @__PURE__ */ n.jsx("p", { className: "file-preview-unsupported__title", children: a("components.filePreview.error.title") }),
540
538
  /* @__PURE__ */ n.jsx("p", { className: "file-preview-unsupported__description", children: a("components.filePreview.error.description") })
541
539
  ] });
542
540
  if (p === "outdated")
543
- return /* @__PURE__ */ n.jsx(pe, {});
541
+ return /* @__PURE__ */ n.jsx(ve, {});
544
542
  const V = /* @__PURE__ */ n.jsx("div", { className: "pdf-preview__container-skeleton", children: /* @__PURE__ */ n.jsx("div", { className: "pdf-preview__page-skeleton" }) });
545
543
  return /* @__PURE__ */ n.jsxs("div", { className: "pdf-preview", children: [
546
544
  /* @__PURE__ */ n.jsx("div", { className: "pdf-preview__body", "data-preview-backdrop": "true", children: Z ? /* @__PURE__ */ n.jsxs(
547
- ve,
545
+ ue,
548
546
  {
549
547
  file: Z,
550
548
  onLoadSuccess: te,
@@ -556,7 +554,7 @@ function Ge({
556
554
  /* @__PURE__ */ n.jsx(
557
555
  Ie,
558
556
  {
559
- numPages: o,
557
+ numPages: s,
560
558
  currentPage: m,
561
559
  goToPage: d,
562
560
  isOpen: g,
@@ -568,7 +566,7 @@ function Ge({
568
566
  ye,
569
567
  {
570
568
  ref: h,
571
- numPages: o,
569
+ numPages: s,
572
570
  zoom: l,
573
571
  onCurrentPageChange: f,
574
572
  onClick: x,
@@ -583,7 +581,7 @@ function Ge({
583
581
  /* @__PURE__ */ n.jsx(
584
582
  Ne,
585
583
  {
586
- numPages: o,
584
+ numPages: s,
587
585
  pageInputValue: j,
588
586
  onToggleSidebar: G,
589
587
  onPageInputChange: L,
@@ -597,7 +595,7 @@ function Ge({
597
595
  ] });
598
596
  }
599
597
  export {
600
- Ge as PdfPreview,
601
- Ge as default
598
+ Ue as PdfPreview,
599
+ Ue as default
602
600
  };
603
- //# sourceMappingURL=PdfPreview-BOIgXF66.js.map
601
+ //# sourceMappingURL=PdfPreview-BOBDAlTZ.js.map