html-flip-book-react 0.0.0-alpha.18 → 0.0.0-alpha.21

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.
Files changed (38) hide show
  1. package/dist/FlipBook.d.ts +8 -0
  2. package/dist/FlipBook.d.ts.map +1 -1
  3. package/dist/TocPage.d.ts +21 -0
  4. package/dist/TocPage.d.ts.map +1 -0
  5. package/dist/assets/html-flip-book.css +1 -1
  6. package/dist/commands/CommandContext.d.ts +23 -0
  7. package/dist/commands/CommandContext.d.ts.map +1 -0
  8. package/dist/commands/defaultCommands.d.ts +4 -0
  9. package/dist/commands/defaultCommands.d.ts.map +1 -0
  10. package/dist/commands/index.d.ts +4 -0
  11. package/dist/commands/index.d.ts.map +1 -0
  12. package/dist/commands/types.d.ts +36 -0
  13. package/dist/commands/types.d.ts.map +1 -0
  14. package/dist/flip-book.js +99 -40
  15. package/dist/flip-book.js.map +1 -1
  16. package/dist/icons/index.d.ts +15 -0
  17. package/dist/icons/index.d.ts.map +1 -0
  18. package/dist/toolbar/ActionButton.d.ts +12 -0
  19. package/dist/toolbar/ActionButton.d.ts.map +1 -0
  20. package/dist/toolbar/FirstPageButton.d.ts.map +1 -1
  21. package/dist/toolbar/FullscreenButton.d.ts +2 -0
  22. package/dist/toolbar/FullscreenButton.d.ts.map +1 -1
  23. package/dist/toolbar/LastPageButton.d.ts.map +1 -1
  24. package/dist/toolbar/NextButton.d.ts.map +1 -1
  25. package/dist/toolbar/PageIndicator.d.ts +8 -2
  26. package/dist/toolbar/PageIndicator.d.ts.map +1 -1
  27. package/dist/toolbar/PrevButton.d.ts.map +1 -1
  28. package/dist/toolbar/TocButton.d.ts +11 -0
  29. package/dist/toolbar/TocButton.d.ts.map +1 -0
  30. package/dist/toolbar/Toolbar.d.ts +6 -1
  31. package/dist/toolbar/Toolbar.d.ts.map +1 -1
  32. package/dist/toolbar/ToolbarContext.d.ts +2 -1
  33. package/dist/toolbar/ToolbarContext.d.ts.map +1 -1
  34. package/dist/toolbar/index.d.ts +10 -2
  35. package/dist/toolbar/index.d.ts.map +1 -1
  36. package/dist/toolbar/index.js +556 -96
  37. package/dist/toolbar/index.js.map +1 -1
  38. package/package.json +4 -4
@@ -1,174 +1,634 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { createContext as v, useContext as x, useState as i, useCallback as P, useEffect as k } from "react";
3
- const u = ({
1
+ import { jsx as n, jsxs as F } from "react/jsx-runtime";
2
+ import { createContext as H, useContext as K, useMemo as D, useCallback as m, useEffect as $, useState as L } from "react";
3
+ const X = {
4
+ flipNext: [
5
+ { key: "ArrowRight" },
6
+ { key: "PageDown" },
7
+ { key: " " }
8
+ // Space
9
+ ],
10
+ flipPrev: [{ key: "ArrowLeft" }, { key: "PageUp" }],
11
+ goToFirst: [{ key: "Home" }],
12
+ goToLast: [{ key: "End" }],
13
+ goToToc: [{ key: "t" }],
14
+ toggleFullscreen: [{ key: "f" }]
15
+ }, Y = [
16
+ {
17
+ id: "flipNext",
18
+ name: "Next Page",
19
+ description: "Flip to the next page",
20
+ execute: ({ flipBookRef: e }) => {
21
+ e.current?.flipNext();
22
+ },
23
+ canExecute: ({ currentPage: e, totalPages: t }) => e < t - 1
24
+ },
25
+ {
26
+ id: "flipPrev",
27
+ name: "Previous Page",
28
+ description: "Flip to the previous page",
29
+ execute: ({ flipBookRef: e }) => {
30
+ e.current?.flipPrev();
31
+ },
32
+ canExecute: ({ currentPage: e }) => e > 0
33
+ },
34
+ {
35
+ id: "goToFirst",
36
+ name: "First Page",
37
+ description: "Jump to the first page",
38
+ execute: ({ flipBookRef: e }) => {
39
+ e.current?.jumpToPage(0);
40
+ },
41
+ canExecute: ({ currentPage: e }) => e > 0
42
+ },
43
+ {
44
+ id: "goToLast",
45
+ name: "Last Page",
46
+ description: "Jump to the last page",
47
+ execute: ({ flipBookRef: e, totalPages: t }) => {
48
+ e.current?.jumpToPage(t - 1);
49
+ },
50
+ canExecute: ({ currentPage: e, totalPages: t }) => e < t - 1
51
+ },
52
+ {
53
+ id: "goToToc",
54
+ name: "Table of Contents",
55
+ description: "Jump to the table of contents",
56
+ execute: ({ flipBookRef: e, data: t }) => {
57
+ const o = t?.tocPageIndex ?? 4;
58
+ e.current?.jumpToPage(o);
59
+ },
60
+ canExecute: ({ currentPage: e, data: t }) => {
61
+ const o = t?.tocPageIndex ?? 4;
62
+ return e !== o;
63
+ }
64
+ },
65
+ {
66
+ id: "toggleFullscreen",
67
+ name: "Toggle Fullscreen",
68
+ description: "Enter or exit fullscreen mode",
69
+ execute: ({ data: e }) => {
70
+ const t = e?.fullscreenTargetRef;
71
+ document.fullscreenElement ? document.exitFullscreen().catch(console.warn) : (t?.current ?? document.documentElement).requestFullscreen().catch(console.warn);
72
+ }
73
+ }
74
+ ], W = H(null);
75
+ function _(e, t) {
76
+ if (t.key !== e.key) return !1;
77
+ const o = e.modifiers ?? {};
78
+ return !(!!o.ctrl !== t.ctrlKey || !!o.shift !== t.shiftKey || !!o.alt !== t.altKey || !!o.meta !== t.metaKey);
79
+ }
80
+ const Q = ({
81
+ flipBookRef: e,
82
+ currentPage: t,
83
+ totalPages: o,
84
+ direction: c = "ltr",
85
+ commands: s = [],
86
+ commandOptions: u = {},
87
+ disableHotkeys: d = !1,
88
+ children: b
89
+ }) => {
90
+ const r = D(() => {
91
+ const i = {};
92
+ for (const a of Y)
93
+ i[a.id] = {
94
+ command: a,
95
+ options: u[a.id] ?? {}
96
+ };
97
+ for (const a of s)
98
+ i[a.id] = {
99
+ command: a,
100
+ options: u[a.id] ?? {}
101
+ };
102
+ return i;
103
+ }, [s, u]), f = m(
104
+ (i) => {
105
+ const a = r[i]?.options ?? {};
106
+ return {
107
+ flipBookRef: e,
108
+ currentPage: t,
109
+ totalPages: o,
110
+ direction: c,
111
+ data: a.data
112
+ };
113
+ },
114
+ [e, t, o, c, r]
115
+ ), p = m(
116
+ (i) => {
117
+ const a = r[i];
118
+ if (!a) {
119
+ console.warn(`Command "${i}" not found`);
120
+ return;
121
+ }
122
+ const h = f(i);
123
+ a.command.canExecute && !a.command.canExecute(h) || a.command.execute(h);
124
+ },
125
+ [r, f]
126
+ ), g = m(
127
+ (i) => {
128
+ const a = r[i];
129
+ if (!a) return !1;
130
+ const h = f(i);
131
+ return a.command.canExecute ? a.command.canExecute(h) : !0;
132
+ },
133
+ [r, f]
134
+ ), k = m(
135
+ (i) => r[i]?.command,
136
+ [r]
137
+ ), v = m(
138
+ () => Object.values(r).map((i) => i.command),
139
+ [r]
140
+ ), w = m(
141
+ (i) => {
142
+ const a = i.target;
143
+ if (!(a.tagName === "INPUT" || a.tagName === "TEXTAREA" || a.isContentEditable))
144
+ for (const [h, B] of Object.entries(r)) {
145
+ if (B.options.disableHotkeys) continue;
146
+ const j = B.options.hotkeys ?? X[h] ?? [];
147
+ for (const T of j)
148
+ if (_(T, i)) {
149
+ i.preventDefault(), p(h);
150
+ return;
151
+ }
152
+ }
153
+ },
154
+ [r, p]
155
+ );
156
+ $(() => {
157
+ if (!d)
158
+ return document.addEventListener("keydown", w), () => document.removeEventListener("keydown", w);
159
+ }, [d, w]);
160
+ const C = D(
161
+ () => ({
162
+ executeCommand: p,
163
+ canExecute: g,
164
+ getCommand: k,
165
+ getAllCommands: v
166
+ }),
167
+ [p, g, k, v]
168
+ );
169
+ return /* @__PURE__ */ n(W.Provider, { value: C, children: b });
170
+ }, se = () => {
171
+ const e = K(W);
172
+ if (!e)
173
+ throw new Error("useCommands must be used within a CommandProvider");
174
+ return e;
175
+ }, P = { size: 24 }, Z = ({ size: e = P.size, className: t }) => /* @__PURE__ */ n(
176
+ "svg",
177
+ {
178
+ xmlns: "http://www.w3.org/2000/svg",
179
+ width: e,
180
+ height: e,
181
+ viewBox: "0 0 24 24",
182
+ fill: "none",
183
+ stroke: "currentColor",
184
+ strokeWidth: "2",
185
+ strokeLinecap: "round",
186
+ strokeLinejoin: "round",
187
+ className: t,
188
+ "aria-hidden": "true",
189
+ children: /* @__PURE__ */ n("path", { d: "m15 18-6-6 6-6" })
190
+ }
191
+ ), ee = ({ size: e = P.size, className: t }) => /* @__PURE__ */ n(
192
+ "svg",
193
+ {
194
+ xmlns: "http://www.w3.org/2000/svg",
195
+ width: e,
196
+ height: e,
197
+ viewBox: "0 0 24 24",
198
+ fill: "none",
199
+ stroke: "currentColor",
200
+ strokeWidth: "2",
201
+ strokeLinecap: "round",
202
+ strokeLinejoin: "round",
203
+ className: t,
204
+ "aria-hidden": "true",
205
+ children: /* @__PURE__ */ n("path", { d: "m9 18 6-6-6-6" })
206
+ }
207
+ ), A = ({ size: e = P.size, className: t }) => /* @__PURE__ */ F(
208
+ "svg",
209
+ {
210
+ xmlns: "http://www.w3.org/2000/svg",
211
+ width: e,
212
+ height: e,
213
+ viewBox: "0 0 24 24",
214
+ fill: "none",
215
+ stroke: "currentColor",
216
+ strokeWidth: "2",
217
+ strokeLinecap: "round",
218
+ strokeLinejoin: "round",
219
+ className: t,
220
+ "aria-hidden": "true",
221
+ children: [
222
+ /* @__PURE__ */ n("path", { d: "m17 18-6-6 6-6" }),
223
+ /* @__PURE__ */ n("path", { d: "M7 6v12" })
224
+ ]
225
+ }
226
+ ), R = ({ size: e = P.size, className: t }) => /* @__PURE__ */ F(
227
+ "svg",
228
+ {
229
+ xmlns: "http://www.w3.org/2000/svg",
230
+ width: e,
231
+ height: e,
232
+ viewBox: "0 0 24 24",
233
+ fill: "none",
234
+ stroke: "currentColor",
235
+ strokeWidth: "2",
236
+ strokeLinecap: "round",
237
+ strokeLinejoin: "round",
238
+ className: t,
239
+ "aria-hidden": "true",
240
+ children: [
241
+ /* @__PURE__ */ n("path", { d: "m7 18 6-6-6-6" }),
242
+ /* @__PURE__ */ n("path", { d: "M17 6v12" })
243
+ ]
244
+ }
245
+ ), te = ({ size: e = P.size, className: t }) => /* @__PURE__ */ F(
246
+ "svg",
247
+ {
248
+ xmlns: "http://www.w3.org/2000/svg",
249
+ width: e,
250
+ height: e,
251
+ viewBox: "0 0 24 24",
252
+ fill: "none",
253
+ stroke: "currentColor",
254
+ strokeWidth: "2",
255
+ strokeLinecap: "round",
256
+ strokeLinejoin: "round",
257
+ className: t,
258
+ "aria-hidden": "true",
259
+ children: [
260
+ /* @__PURE__ */ n("path", { d: "M8 3H5a2 2 0 0 0-2 2v3" }),
261
+ /* @__PURE__ */ n("path", { d: "M21 8V5a2 2 0 0 0-2-2h-3" }),
262
+ /* @__PURE__ */ n("path", { d: "M3 16v3a2 2 0 0 0 2 2h3" }),
263
+ /* @__PURE__ */ n("path", { d: "M16 21h3a2 2 0 0 0 2-2v-3" })
264
+ ]
265
+ }
266
+ ), ne = ({ size: e = P.size, className: t }) => /* @__PURE__ */ F(
267
+ "svg",
268
+ {
269
+ xmlns: "http://www.w3.org/2000/svg",
270
+ width: e,
271
+ height: e,
272
+ viewBox: "0 0 24 24",
273
+ fill: "none",
274
+ stroke: "currentColor",
275
+ strokeWidth: "2",
276
+ strokeLinecap: "round",
277
+ strokeLinejoin: "round",
278
+ className: t,
279
+ "aria-hidden": "true",
280
+ children: [
281
+ /* @__PURE__ */ n("path", { d: "M8 3v3a2 2 0 0 1-2 2H3" }),
282
+ /* @__PURE__ */ n("path", { d: "M21 8h-3a2 2 0 0 1-2-2V3" }),
283
+ /* @__PURE__ */ n("path", { d: "M3 16h3a2 2 0 0 1 2 2v3" }),
284
+ /* @__PURE__ */ n("path", { d: "M16 21v-3a2 2 0 0 1 2-2h3" })
285
+ ]
286
+ }
287
+ ), oe = ({
288
+ size: e = P.size,
289
+ className: t
290
+ }) => /* @__PURE__ */ F(
291
+ "svg",
292
+ {
293
+ xmlns: "http://www.w3.org/2000/svg",
294
+ width: e,
295
+ height: e,
296
+ viewBox: "0 0 24 24",
297
+ fill: "none",
298
+ stroke: "currentColor",
299
+ strokeWidth: "2",
300
+ strokeLinecap: "round",
301
+ strokeLinejoin: "round",
302
+ className: t,
303
+ "aria-hidden": "true",
304
+ children: [
305
+ /* @__PURE__ */ n("path", { d: "M16 5H3" }),
306
+ /* @__PURE__ */ n("path", { d: "M16 12H3" }),
307
+ /* @__PURE__ */ n("path", { d: "M16 19H3" }),
308
+ /* @__PURE__ */ n("path", { d: "M21 5h.01" }),
309
+ /* @__PURE__ */ n("path", { d: "M21 12h.01" }),
310
+ /* @__PURE__ */ n("path", { d: "M21 19h.01" })
311
+ ]
312
+ }
313
+ ), ce = ({ size: e = P.size, className: t }) => /* @__PURE__ */ F(
314
+ "svg",
315
+ {
316
+ xmlns: "http://www.w3.org/2000/svg",
317
+ width: e,
318
+ height: e,
319
+ viewBox: "0 0 24 24",
320
+ fill: "none",
321
+ stroke: "currentColor",
322
+ strokeWidth: "2",
323
+ strokeLinecap: "round",
324
+ strokeLinejoin: "round",
325
+ className: t,
326
+ "aria-hidden": "true",
327
+ children: [
328
+ /* @__PURE__ */ n("path", { d: "M3 21h18" }),
329
+ /* @__PURE__ */ n("rect", { x: "4", y: "7", width: "3", height: "14", rx: "0.5" }),
330
+ /* @__PURE__ */ n("rect", { x: "8", y: "5", width: "3", height: "16", rx: "0.5" }),
331
+ /* @__PURE__ */ n("rect", { x: "12", y: "9", width: "3", height: "12", rx: "0.5" }),
332
+ /* @__PURE__ */ n("rect", { x: "16", y: "6", width: "4", height: "15", rx: "0.5" })
333
+ ]
334
+ }
335
+ ), E = ({
4
336
  onClick: e,
5
337
  ariaLabel: t,
6
- disabled: l = !1,
7
- children: r,
8
- className: a = "",
9
- title: o
338
+ disabled: o = !1,
339
+ children: c,
340
+ className: s = "",
341
+ title: u
10
342
  }) => /* @__PURE__ */ n(
11
343
  "button",
12
344
  {
13
345
  type: "button",
14
346
  onClick: e,
15
347
  "aria-label": t,
16
- disabled: l,
17
- title: o ?? t,
18
- className: `flipbook-toolbar-button ${a}`.trim(),
19
- children: r
348
+ disabled: o,
349
+ title: u ?? t,
350
+ className: `flipbook-toolbar-button ${s}`.trim(),
351
+ children: c
352
+ }
353
+ ), le = ({
354
+ onClick: e,
355
+ ariaLabel: t,
356
+ children: o,
357
+ disabled: c = !1,
358
+ className: s
359
+ }) => /* @__PURE__ */ n(
360
+ E,
361
+ {
362
+ onClick: e,
363
+ ariaLabel: t,
364
+ disabled: c,
365
+ className: `flipbook-toolbar-action ${s ?? ""}`.trim(),
366
+ children: o
20
367
  }
21
- ), h = v(null);
22
- function b() {
23
- const e = x(h);
368
+ ), O = H(null);
369
+ function I() {
370
+ const e = K(O);
24
371
  if (!e)
25
372
  throw new Error("Toolbar components must be used within a Toolbar");
26
373
  return e;
27
374
  }
28
- const N = ({ children: e, className: t }) => {
29
- const { flipBookRef: l, isFirstPage: r } = b();
375
+ const ue = ({ children: e, className: t }) => {
376
+ const { flipBookRef: o, isFirstPage: c, direction: s } = I(), u = () => {
377
+ o.current?.jumpToPage(0);
378
+ }, d = s === "rtl" ? /* @__PURE__ */ n(R, { size: 18 }) : /* @__PURE__ */ n(A, { size: 18 });
30
379
  return /* @__PURE__ */ n(
31
- u,
380
+ E,
32
381
  {
33
- onClick: () => {
34
- l.current?.jumpToPage(0);
35
- },
382
+ onClick: u,
36
383
  ariaLabel: "First page",
37
- disabled: r,
384
+ disabled: c,
38
385
  className: `flipbook-toolbar-first ${t ?? ""}`.trim(),
39
- children: e ?? "⏮"
386
+ children: e ?? d
40
387
  }
41
388
  );
42
- }, T = ({
389
+ }, de = ({
43
390
  targetRef: e,
44
391
  enterIcon: t,
45
- exitIcon: l,
46
- className: r
392
+ exitIcon: o,
393
+ ariaLabelEnter: c = "Enter fullscreen",
394
+ ariaLabelExit: s = "Exit fullscreen",
395
+ className: u
47
396
  }) => {
48
- const [a, o] = i(!1), s = P(() => {
49
- o(!!document.fullscreenElement);
397
+ const [d, b] = L(!1), r = m(() => {
398
+ b(!!document.fullscreenElement);
50
399
  }, []);
51
- k(() => (document.addEventListener("fullscreenchange", s), () => {
52
- document.removeEventListener("fullscreenchange", s);
53
- }), [s]);
54
- const g = async () => {
400
+ $(() => (document.addEventListener("fullscreenchange", r), () => {
401
+ document.removeEventListener("fullscreenchange", r);
402
+ }), [r]);
403
+ const f = async () => {
55
404
  try {
56
- a ? await document.exitFullscreen() : await (e?.current ?? document.documentElement).requestFullscreen();
57
- } catch (d) {
58
- console.warn("Fullscreen request failed:", d);
405
+ d ? await document.exitFullscreen() : await (e?.current ?? document.documentElement).requestFullscreen();
406
+ } catch (k) {
407
+ console.warn("Fullscreen request failed:", k);
59
408
  }
60
- }, f = a ? "Exit fullscreen" : "Enter fullscreen", p = a ? l ?? "⛶" : t ?? "⛶";
409
+ }, p = d ? s : c, g = d ? o ?? /* @__PURE__ */ n(ne, { size: 18 }) : t ?? /* @__PURE__ */ n(te, { size: 18 });
61
410
  return /* @__PURE__ */ n(
62
- u,
411
+ E,
63
412
  {
64
- onClick: g,
65
- ariaLabel: f,
66
- className: `flipbook-toolbar-fullscreen ${a ? "flipbook-toolbar-fullscreen--active" : ""} ${r ?? ""}`.trim(),
67
- children: p
413
+ onClick: f,
414
+ ariaLabel: p,
415
+ className: `flipbook-toolbar-fullscreen ${d ? "flipbook-toolbar-fullscreen--active" : ""} ${u ?? ""}`.trim(),
416
+ children: g
68
417
  }
69
418
  );
70
- }, $ = ({ children: e, className: t }) => {
71
- const { flipBookRef: l, isLastPage: r, totalPages: a } = b();
419
+ }, he = ({ children: e, className: t }) => {
420
+ const { flipBookRef: o, isLastPage: c, totalPages: s, direction: u } = I(), d = () => {
421
+ o.current?.jumpToPage(s - 1);
422
+ }, b = u === "rtl" ? /* @__PURE__ */ n(A, { size: 18 }) : /* @__PURE__ */ n(R, { size: 18 });
72
423
  return /* @__PURE__ */ n(
73
- u,
424
+ E,
74
425
  {
75
- onClick: () => {
76
- l.current?.jumpToPage(a - 1);
77
- },
426
+ onClick: d,
78
427
  ariaLabel: "Last page",
79
- disabled: r,
428
+ disabled: c,
80
429
  className: `flipbook-toolbar-last ${t ?? ""}`.trim(),
81
- children: e ?? "⏭"
430
+ children: e ?? b
82
431
  }
83
432
  );
84
- }, B = ({ children: e, className: t }) => {
85
- const { flipBookRef: l, isLastPage: r, direction: a } = b();
433
+ }, me = ({ children: e, className: t }) => {
434
+ const { flipBookRef: o, isLastPage: c, direction: s } = I();
86
435
  return /* @__PURE__ */ n(
87
- u,
436
+ E,
88
437
  {
89
438
  onClick: () => {
90
- l.current?.flipNext();
439
+ o.current?.flipNext();
91
440
  },
92
- ariaLabel: a === "rtl" ? "Previous page" : "Next page",
93
- disabled: r,
441
+ ariaLabel: s === "rtl" ? "Previous page" : "Next page",
442
+ disabled: c,
94
443
  className: `flipbook-toolbar-next ${t ?? ""}`.trim(),
95
- children: e ?? "›"
444
+ children: e ?? /* @__PURE__ */ n(ee, { size: 20 })
96
445
  }
97
446
  );
98
- }, E = ({
99
- format: e = "{current} / {total}",
100
- className: t
447
+ }, ge = ({
448
+ mode: e,
449
+ showTotal: t = !0,
450
+ placeholder: o = "—",
451
+ editable: c,
452
+ className: s,
453
+ ariaLabel: u = "Go to page",
454
+ maxLength: d = 10
101
455
  }) => {
102
- const { currentPage: l, totalPages: r } = b(), a = l + 1, o = e.replace("{current}", a.toString()).replace("{total}", r.toString());
103
- return /* @__PURE__ */ n(
456
+ const { flipBookRef: b, pageSemantics: r, direction: f, currentPage: p, totalPages: g } = I(), k = e ?? (r ? "semantic" : "index"), v = c ?? (k === "semantic" && !!r), [w, C] = L(""), [i, a] = L(!1), h = p, B = p + 1 < g ? p + 1 : null, j = m(
457
+ (l) => k === "semantic" && r ? r.indexToSemanticName(l) || "" : String(l + 1),
458
+ [k, r]
459
+ ), T = j(h), M = B != null ? j(B) : "", z = m(() => {
460
+ if (k === "semantic" && r) {
461
+ for (let l = g - 1; l >= 0; l--) {
462
+ const x = r.indexToSemanticName(l);
463
+ if (x) return x;
464
+ }
465
+ return String(g);
466
+ }
467
+ return String(g);
468
+ }, [k, r, g]), V = m(() => {
469
+ const l = f === "rtl" ? M : T, x = f === "rtl" ? T : M;
470
+ let y;
471
+ return !l && !x ? y = o : l ? x ? l === x ? y = l : y = `${l} - ${x}` : y = l : y = x, t ? `${y} / ${z()}` : y;
472
+ }, [f, T, M, o, t, z]), N = f === "rtl" ? M || T : T || M;
473
+ $(() => {
474
+ i || C(N);
475
+ }, [N, i]);
476
+ const q = m(() => {
477
+ v && (a(!0), C(N));
478
+ }, [v, N]), J = m(() => {
479
+ a(!1), C(N);
480
+ }, [N]), U = m(
481
+ (l) => {
482
+ if (l.key === "Enter") {
483
+ if (r && w.trim()) {
484
+ const x = r.semanticNameToIndex(w.trim());
485
+ x != null && x >= 0 && x < g && b.current?.jumpToPage(x);
486
+ }
487
+ l.currentTarget.blur();
488
+ } else l.key === "Escape" && l.currentTarget.blur();
489
+ },
490
+ [w, r, g, b]
491
+ ), G = m((l) => {
492
+ C(l.target.value);
493
+ }, []), S = V();
494
+ return v ? /* @__PURE__ */ n(
495
+ "input",
496
+ {
497
+ type: "text",
498
+ className: `flipbook-toolbar-indicator ${i ? "flipbook-toolbar-indicator--editing" : ""} ${s ?? ""}`.trim(),
499
+ value: i ? w : S,
500
+ onFocus: q,
501
+ onBlur: J,
502
+ onKeyDown: U,
503
+ onChange: G,
504
+ "aria-label": u,
505
+ "aria-live": "polite",
506
+ "aria-atomic": "true",
507
+ maxLength: d,
508
+ readOnly: !v
509
+ }
510
+ ) : /* @__PURE__ */ n(
104
511
  "span",
105
512
  {
106
- className: `flipbook-toolbar-indicator ${t ?? ""}`.trim(),
513
+ className: `flipbook-toolbar-indicator ${s ?? ""}`.trim(),
107
514
  "aria-live": "polite",
108
515
  "aria-atomic": "true",
109
- children: o
516
+ children: S
110
517
  }
111
518
  );
112
- }, I = ({ children: e, className: t }) => {
113
- const { flipBookRef: l, isFirstPage: r, direction: a } = b();
519
+ }, fe = ({ children: e, className: t }) => {
520
+ const { flipBookRef: o, isFirstPage: c, direction: s } = I();
114
521
  return /* @__PURE__ */ n(
115
- u,
522
+ E,
116
523
  {
117
524
  onClick: () => {
118
- l.current?.flipPrev();
525
+ o.current?.flipPrev();
119
526
  },
120
- ariaLabel: a === "rtl" ? "Next page" : "Previous page",
121
- disabled: r,
527
+ ariaLabel: s === "rtl" ? "Next page" : "Previous page",
528
+ disabled: c,
122
529
  className: `flipbook-toolbar-prev ${t ?? ""}`.trim(),
123
- children: e ?? "‹"
530
+ children: e ?? /* @__PURE__ */ n(Z, { size: 20 })
531
+ }
532
+ );
533
+ }, pe = ({
534
+ tocPageIndex: e = 4,
535
+ children: t,
536
+ ariaLabel: o = "Table of contents",
537
+ className: c
538
+ }) => {
539
+ const { flipBookRef: s, currentPage: u } = I();
540
+ return /* @__PURE__ */ n(
541
+ E,
542
+ {
543
+ onClick: () => {
544
+ s.current?.jumpToPage(e);
545
+ },
546
+ ariaLabel: o,
547
+ disabled: u === e,
548
+ className: `flipbook-toolbar-toc ${c ?? ""}`.trim(),
549
+ children: t ?? /* @__PURE__ */ n(oe, { size: 18 })
124
550
  }
125
551
  );
126
- }, w = ({
552
+ }, ke = ({
127
553
  flipBookRef: e,
128
554
  direction: t = "ltr",
129
- className: l = "",
130
- children: r
555
+ pageSemantics: o,
556
+ className: c = "",
557
+ children: s,
558
+ enableHotkeys: u = !0,
559
+ commands: d,
560
+ commandOptions: b
131
561
  }) => {
132
- const [a, o] = i(0), [s, g] = i(0), [f, p] = i(!0), [d, C] = i(!1), m = P(() => {
133
- const c = e.current;
134
- c && (o(c.getCurrentPageIndex()), g(c.getTotalPages()), p(c.isFirstPage()), C(c.isLastPage()));
562
+ const [r, f] = L(0), [p, g] = L(0), [k, v] = L(!0), [w, C] = L(!1), i = m(() => {
563
+ const h = e.current;
564
+ h && (f(h.getCurrentPageIndex()), g(h.getTotalPages()), v(h.isFirstPage()), C(h.isLastPage()));
135
565
  }, [e]);
136
- return k(() => {
137
- m();
138
- const c = setInterval(m, 100);
139
- return () => clearInterval(c);
140
- }, [m]), /* @__PURE__ */ n(
141
- h.Provider,
566
+ $(() => {
567
+ i();
568
+ const h = setInterval(i, 100);
569
+ return () => clearInterval(h);
570
+ }, [i]);
571
+ const a = /* @__PURE__ */ n(
572
+ O.Provider,
142
573
  {
143
574
  value: {
144
575
  flipBookRef: e,
145
576
  direction: t,
146
- currentPage: a,
147
- totalPages: s,
148
- isFirstPage: f,
149
- isLastPage: d
577
+ pageSemantics: o,
578
+ currentPage: r,
579
+ totalPages: p,
580
+ isFirstPage: k,
581
+ isLastPage: w
150
582
  },
151
583
  children: /* @__PURE__ */ n(
152
584
  "div",
153
585
  {
154
- className: `flipbook-toolbar ${t === "rtl" ? "flipbook-toolbar--rtl" : ""} ${l}`.trim(),
586
+ className: `flipbook-toolbar ${c}`.trim(),
155
587
  role: "toolbar",
156
588
  "aria-label": "FlipBook navigation",
157
- children: r
589
+ dir: t,
590
+ children: s
158
591
  }
159
592
  )
160
593
  }
161
594
  );
595
+ return /* @__PURE__ */ n(
596
+ Q,
597
+ {
598
+ flipBookRef: e,
599
+ currentPage: r,
600
+ totalPages: p,
601
+ direction: t,
602
+ commands: d,
603
+ commandOptions: b,
604
+ disableHotkeys: !u,
605
+ children: a
606
+ }
607
+ );
162
608
  };
163
609
  export {
164
- N as FirstPageButton,
165
- T as FullscreenButton,
166
- $ as LastPageButton,
167
- B as NextButton,
168
- E as PageIndicator,
169
- I as PrevButton,
170
- w as Toolbar,
171
- u as ToolbarButton,
172
- b as useToolbar
610
+ le as ActionButton,
611
+ ce as BookshelfIcon,
612
+ A as ChevronFirstIcon,
613
+ R as ChevronLastIcon,
614
+ Z as ChevronLeftIcon,
615
+ ee as ChevronRightIcon,
616
+ X as DEFAULT_HOTKEYS,
617
+ ue as FirstPageButton,
618
+ de as FullscreenButton,
619
+ he as LastPageButton,
620
+ te as MaximizeIcon,
621
+ ne as MinimizeIcon,
622
+ me as NextButton,
623
+ ge as PageIndicator,
624
+ fe as PrevButton,
625
+ ge as SemanticPageIndicator,
626
+ oe as TableOfContentsIcon,
627
+ pe as TocButton,
628
+ ke as Toolbar,
629
+ E as ToolbarButton,
630
+ Y as defaultCommands,
631
+ se as useCommands,
632
+ I as useToolbar
173
633
  };
174
634
  //# sourceMappingURL=index.js.map