html-flip-book-react 0.0.0-alpha.23 → 0.0.0-alpha.25
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/FlipBook.d.ts +15 -0
- package/dist/FlipBook.d.ts.map +1 -1
- package/dist/assets/html-flip-book.css +1 -1
- package/dist/commands/CommandContext.d.ts.map +1 -1
- package/dist/commands/defaultCommands.d.ts.map +1 -1
- package/dist/download/types.d.ts +15 -0
- package/dist/download/types.d.ts.map +1 -0
- package/dist/flip-book.js +128 -84
- package/dist/flip-book.js.map +1 -1
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/toolbar/DownloadDropdown.d.ts +21 -0
- package/dist/toolbar/DownloadDropdown.d.ts.map +1 -0
- package/dist/toolbar/FirstPageButton.d.ts.map +1 -1
- package/dist/toolbar/LastPageButton.d.ts.map +1 -1
- package/dist/toolbar/NextButton.d.ts.map +1 -1
- package/dist/toolbar/PageIndicator.d.ts.map +1 -1
- package/dist/toolbar/PrevButton.d.ts.map +1 -1
- package/dist/toolbar/TocButton.d.ts.map +1 -1
- package/dist/toolbar/Toolbar.d.ts +2 -0
- package/dist/toolbar/Toolbar.d.ts.map +1 -1
- package/dist/toolbar/ToolbarContext.d.ts +3 -0
- package/dist/toolbar/ToolbarContext.d.ts.map +1 -1
- package/dist/toolbar/index.d.ts +4 -1
- package/dist/toolbar/index.d.ts.map +1 -1
- package/dist/toolbar/index.js +601 -326
- package/dist/toolbar/index.js.map +1 -1
- package/package.json +3 -3
package/dist/FlipBook.d.ts
CHANGED
|
@@ -7,13 +7,19 @@ export interface FlipBookHandle {
|
|
|
7
7
|
jumpToPage: (pageIndex: number) => void;
|
|
8
8
|
getCurrentPageIndex: () => number;
|
|
9
9
|
getTotalPages: () => number;
|
|
10
|
+
getOf: () => string | number;
|
|
10
11
|
isFirstPage: () => boolean;
|
|
11
12
|
isLastPage: () => boolean;
|
|
13
|
+
toggleDebugBar?: () => void;
|
|
12
14
|
}
|
|
13
15
|
export interface CoverConfig {
|
|
14
16
|
hardCovers?: boolean;
|
|
15
17
|
noShadow?: boolean;
|
|
16
18
|
coverIndices?: number[] | "auto";
|
|
19
|
+
interiorCoverClassName?: string;
|
|
20
|
+
frontInteriorCoverClassName?: string;
|
|
21
|
+
backInteriorCoverClassName?: string;
|
|
22
|
+
coverInset?: string;
|
|
17
23
|
}
|
|
18
24
|
export interface FlipBookProps {
|
|
19
25
|
pages: React.ReactNode[];
|
|
@@ -25,6 +31,15 @@ export interface FlipBookProps {
|
|
|
25
31
|
fastDeltaThreshold?: number;
|
|
26
32
|
leavesBuffer?: number;
|
|
27
33
|
coverConfig?: CoverConfig;
|
|
34
|
+
of?: string | number;
|
|
35
|
+
leafAspectRatio?: {
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
coverAspectRatio?: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
28
43
|
}
|
|
29
44
|
declare const FlipBookReact: React.ForwardRefExoticComponent<FlipBookProps & React.RefAttributes<FlipBookHandle>>;
|
|
30
45
|
export { FlipBookReact as FlipBook };
|
package/dist/FlipBook.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlipBook.d.ts","sourceRoot":"","sources":["../src/FlipBook.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,MAAM,WAAW,cAAc;IAE9B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,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AC,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,WAAW,aAAa;IAE7B,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAEzB,SAAS,EAAE,MAAM,CAAC;IAElB,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAE1B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAM5B,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,WAAW,CAAC,EAAE,WAAW,CAAC;IAK1B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAKrB,eAAe,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAMpD,gBAAgB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACrD;AAsBD,QAAA,MAAM,aAAa,sFAiMlB,CAAC;AAIF,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,CAAC;AAC9B,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.toc-page{background-color:#fffef8;padding:8% 6%;font-family:Georgia,Times New Roman,serif;line-height:1.6;height:100%;box-sizing:border-box;overflow-y:auto}.toc-heading{text-align:center;margin-bottom:24px;color:#2c1810;font-size:1.4rem;border-bottom:none}.toc-list{list-style:none;padding:0;margin:0}.toc-list li{margin-bottom:8px}.toc-link{display:flex;align-items:baseline;width:100%;padding:8px 4px;background:none;border:none;cursor:pointer;font-family:inherit;font-size:inherit;text-align:inherit;color:inherit;transition:background-color .15s ease}.toc-link:hover{background-color:#0000000d}.toc-link:focus{outline:2px solid #1a3a5c;outline-offset:2px}.toc-title{flex-shrink:0}.toc-dots{flex-grow:1;border-bottom:1px dotted #999;margin:0 8px;min-width:20px}.toc-page-num{flex-shrink:0;font-weight:600;color:#1a3a5c}.flipbook-toolbar{display:flex;align-items:center;justify-content:center;gap:8px;padding:8px 16px;background-color:#000000b3;border-radius:8px;-webkit-user-select:none;user-select:none}.flipbook-toolbar--rtl{flex-
|
|
1
|
+
.toc-page{background-color:#fffef8;padding:8% 6%;font-family:Georgia,Times New Roman,serif;line-height:1.6;height:100%;box-sizing:border-box;overflow-y:auto}.toc-heading{text-align:center;margin-bottom:24px;color:#2c1810;font-size:1.4rem;border-bottom:none}.toc-list{list-style:none;padding:0;margin:0}.toc-list li{margin-bottom:8px}.toc-link{display:flex;align-items:baseline;width:100%;padding:8px 4px;background:none;border:none;cursor:pointer;font-family:inherit;font-size:inherit;text-align:inherit;color:inherit;transition:background-color .15s ease}.toc-link:hover{background-color:#0000000d}.toc-link:focus{outline:2px solid #1a3a5c;outline-offset:2px}.toc-title{flex-shrink:0}.toc-dots{flex-grow:1;border-bottom:1px dotted #999;margin:0 8px;min-width:20px}.toc-page-num{flex-shrink:0;font-weight:600;color:#1a3a5c}.flipbook-toolbar-download-wrap{position:relative;display:inline-flex}.flipbook-toolbar-download-trigger{display:flex;align-items:center;justify-content:center}.flipbook-toolbar-download-menu{position:absolute;top:100%;left:0;margin-top:4px;min-width:200px;max-height:min(60vh,400px);overflow-y:auto;padding:4px 0;background-color:#1e1e1efa;border-radius:6px;box-shadow:0 4px 12px #0000004d;z-index:100}.flipbook-toolbar-download-menu--open-up{top:auto;bottom:100%;margin-top:0;margin-bottom:4px}.flipbook-toolbar-download-menuitem{display:block;width:100%;padding:8px 12px;border:none;background:none;color:#fff;font-size:14px;text-align:left;cursor:pointer}.flipbook-toolbar-download-menuitem:hover:not(:disabled){background-color:#ffffff1a}.flipbook-toolbar-download-menuitem:disabled{opacity:.6;cursor:not-allowed}.flipbook-toolbar-download-range{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px 12px;border-top:1px solid rgba(255,255,255,.15);margin-top:4px}.flipbook-toolbar-download-range-label{display:inline-flex;align-items:center;gap:6px;color:#fff;font-size:13px}.flipbook-toolbar-download-range-select{padding:4px 8px;border-radius:4px;border:1px solid rgba(255,255,255,.3);background:#0000004d;color:#fff;font-size:13px;min-width:4ch}.flipbook-toolbar-download-range-download{padding:6px 12px;border:none;border-radius:4px;background:#fff3;color:#fff;font-size:13px;cursor:pointer}.flipbook-toolbar-download-range-download:hover:not(:disabled){background:#ffffff4d}.flipbook-toolbar-download-range-download:disabled{opacity:.6;cursor:not-allowed}.flipbook-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 16px;min-height:48px;box-sizing:border-box;background-color:#000000b3;border-radius:8px;-webkit-user-select:none;user-select:none}.flipbook-toolbar-start{display:flex;align-items:center;gap:8px;flex:1;justify-content:flex-start}.flipbook-toolbar-nav-cluster{display:flex;align-items:center;gap:8px;flex-shrink:0}.flipbook-toolbar--rtl .flipbook-toolbar-button>*{transform:scaleX(-1)}.flipbook-toolbar-end{display:flex;align-items:center;gap:8px;flex:1;justify-content:flex-end}.flipbook-toolbar-button{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:none;border-radius:6px;background-color:transparent;color:#fff;font-size:20px;cursor:pointer;transition:background-color .2s ease,opacity .2s ease}.flipbook-toolbar-button:hover:not(:disabled){background-color:#ffffff26}.flipbook-toolbar-button:active:not(:disabled){background-color:#ffffff40}.flipbook-toolbar-button:focus-visible{outline:2px solid #fff;outline-offset:2px}.flipbook-toolbar-button:disabled{opacity:.4;cursor:not-allowed}.flipbook-toolbar-prev,.flipbook-toolbar-next{font-size:28px;font-weight:700}.flipbook-toolbar-first,.flipbook-toolbar-last{font-size:16px}.flipbook-toolbar-fullscreen{font-size:18px}.flipbook-toolbar-fullscreen--active{background-color:#ffffff1a}.flipbook-toc-icon--flip-h{transform:scaleX(-1)}span.flipbook-toolbar-indicator{display:inline-flex;align-items:center;justify-content:center;color:inherit;font-size:14px;font-weight:500;text-align:center;padding:0 4px;white-space:nowrap}input.flipbook-toolbar-indicator{display:inline-block;font-family:inherit;font-size:14px;font-weight:500;text-align:center;box-sizing:border-box;border:1px solid transparent;border-radius:4px;padding:4px 8px;min-width:3ch;color:inherit;white-space:nowrap;transition:background-color .2s ease,color .2s ease}input.flipbook-toolbar-indicator--editing{background:#fff;color:#1a1a1a}input.flipbook-toolbar-indicator:focus{outline:2px solid currentColor;outline-offset:2px}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandContext.d.ts","sourceRoot":"","sources":["../../src/commands/CommandContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,KAAK,EACX,OAAO,EAEP,cAAc,EAGd,MAAM,SAAS,CAAC;AAEjB,UAAU,oBAAoB;IAE7B,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAEpD,WAAW,EAAE,MAAM,CAAC;IAEpB,UAAU,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAE1B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IAErB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEhD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED,UAAU,oBAAoB;IAE7B,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;I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|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultCommands.d.ts","sourceRoot":"","sources":["../../src/commands/defaultCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"defaultCommands.d.ts","sourceRoot":"","sources":["../../src/commands/defaultCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAMtD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAY3D,CAAC;AAKF,eAAO,MAAM,eAAe,EAAE,OAAO,EAqFpC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface SemanticPageInfo {
|
|
2
|
+
pageIndex: number;
|
|
3
|
+
semanticName: string;
|
|
4
|
+
title: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DownloadResult {
|
|
7
|
+
ext: string;
|
|
8
|
+
data: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PageRangesDownloadContext {
|
|
11
|
+
seferName?: string;
|
|
12
|
+
}
|
|
13
|
+
export type SeferDownloadHandler = () => Promise<DownloadResult | null>;
|
|
14
|
+
export type PageRangesDownloadHandler = (pages: number[], semanticPages: SemanticPageInfo[], context?: PageRangesDownloadContext) => Promise<DownloadResult | null>;
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/download/types.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAEhC,SAAS,EAAE,MAAM,CAAC;IAElB,YAAY,EAAE,MAAM,CAAC;IAErB,KAAK,EAAE,MAAM,CAAC;CACd;AAGD,MAAM,WAAW,cAAc;IAC9B,GAAG,EAAE,MAAM,CAAC;IAEZ,IAAI,EAAE,MAAM,CAAC;CACb;AAGD,MAAM,WAAW,yBAAyB;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAOD,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;AAOxE,MAAM,MAAM,yBAAyB,GAAG,CACvC,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,EAAE,gBAAgB,EAAE,EACjC,OAAO,CAAC,EAAE,yBAAyB,KAC/B,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC"}
|
package/dist/flip-book.js
CHANGED
|
@@ -1,111 +1,155 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { FlipBook as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
const
|
|
5
|
-
onNavigate:
|
|
6
|
-
totalPages:
|
|
7
|
-
pageSemantics:
|
|
8
|
-
heading:
|
|
9
|
-
className:
|
|
10
|
-
direction:
|
|
11
|
-
filter:
|
|
12
|
-
renderEntry:
|
|
1
|
+
import { jsxs as B, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { FlipBook as O } from "html-flip-book-vanilla";
|
|
3
|
+
import { forwardRef as _, useState as H, useRef as R, useImperativeHandle as K, useEffect as W, Children as z } from "react";
|
|
4
|
+
const G = (g) => g.title.length > 0, X = ({
|
|
5
|
+
onNavigate: g,
|
|
6
|
+
totalPages: l,
|
|
7
|
+
pageSemantics: m,
|
|
8
|
+
heading: v = "Table of Contents",
|
|
9
|
+
className: b,
|
|
10
|
+
direction: x = "ltr",
|
|
11
|
+
filter: k = G,
|
|
12
|
+
renderEntry: d
|
|
13
13
|
}) => {
|
|
14
|
-
const
|
|
15
|
-
for (let
|
|
16
|
-
const a =
|
|
17
|
-
|
|
14
|
+
const r = [];
|
|
15
|
+
for (let n = 0; n < l; n++) {
|
|
16
|
+
const a = m?.indexToTitle(n) ?? "", f = m?.indexToSemanticName(n) ?? "", u = { pageIndex: n, title: a, semanticName: f };
|
|
17
|
+
k(u, n) && r.push(u);
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
return /* @__PURE__ */ o("li", { children: /* @__PURE__ */
|
|
22
|
-
/* @__PURE__ */ o("span", { className: "toc-title", children:
|
|
19
|
+
const N = (n, a) => {
|
|
20
|
+
const f = n.title || n.semanticName || `Page ${n.pageIndex}`, u = n.semanticName || String(n.pageIndex);
|
|
21
|
+
return /* @__PURE__ */ o("li", { children: /* @__PURE__ */ B("button", { type: "button", className: "toc-link", onClick: a, children: [
|
|
22
|
+
/* @__PURE__ */ o("span", { className: "toc-title", children: f }),
|
|
23
23
|
/* @__PURE__ */ o("span", { className: "toc-dots" }),
|
|
24
|
-
/* @__PURE__ */ o("span", { className: "toc-page-num", children:
|
|
25
|
-
] }) },
|
|
24
|
+
/* @__PURE__ */ o("span", { className: "toc-page-num", children: u })
|
|
25
|
+
] }) }, n.pageIndex);
|
|
26
26
|
};
|
|
27
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ B(
|
|
28
28
|
"div",
|
|
29
29
|
{
|
|
30
|
-
className: `toc-page ${
|
|
31
|
-
style: { direction:
|
|
30
|
+
className: `toc-page ${b ?? ""}`.trim(),
|
|
31
|
+
style: { direction: x, textAlign: x === "rtl" ? "right" : "left" },
|
|
32
32
|
children: [
|
|
33
|
-
/* @__PURE__ */ o("h2", { className: "toc-heading", children:
|
|
34
|
-
/* @__PURE__ */ o("ul", { className: "toc-list", children:
|
|
35
|
-
const a = () =>
|
|
36
|
-
return
|
|
33
|
+
/* @__PURE__ */ o("h2", { className: "toc-heading", children: v }),
|
|
34
|
+
/* @__PURE__ */ o("ul", { className: "toc-list", children: r.map((n) => {
|
|
35
|
+
const a = () => g(n.pageIndex);
|
|
36
|
+
return d ? d(n, a) : N(n, a);
|
|
37
37
|
}) })
|
|
38
38
|
]
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
|
-
},
|
|
41
|
+
}, J = _(
|
|
42
42
|
({
|
|
43
|
-
pages:
|
|
44
|
-
className:
|
|
45
|
-
debug:
|
|
46
|
-
direction:
|
|
47
|
-
pageSemantics:
|
|
48
|
-
initialTurnedLeaves:
|
|
49
|
-
fastDeltaThreshold:
|
|
50
|
-
leavesBuffer:
|
|
51
|
-
coverConfig:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
pages: g,
|
|
44
|
+
className: l,
|
|
45
|
+
debug: m = !1,
|
|
46
|
+
direction: v = "ltr",
|
|
47
|
+
pageSemantics: b = void 0,
|
|
48
|
+
initialTurnedLeaves: x = [],
|
|
49
|
+
fastDeltaThreshold: k,
|
|
50
|
+
leavesBuffer: d,
|
|
51
|
+
coverConfig: r,
|
|
52
|
+
of: N,
|
|
53
|
+
leafAspectRatio: n,
|
|
54
|
+
coverAspectRatio: a
|
|
55
|
+
}, f) => {
|
|
56
|
+
const [u, S] = H(0), w = R(S);
|
|
57
|
+
w.current = S;
|
|
58
|
+
const T = R(N);
|
|
59
|
+
T.current = N;
|
|
60
|
+
const s = R(
|
|
61
|
+
new O({
|
|
62
|
+
pageSemantics: b,
|
|
63
|
+
pagesCount: g.length,
|
|
64
|
+
direction: v,
|
|
65
|
+
initialTurnedLeaves: x,
|
|
66
|
+
fastDeltaThreshold: k,
|
|
67
|
+
leavesBuffer: d,
|
|
68
|
+
leafAspectRatio: n,
|
|
69
|
+
coverAspectRatio: a,
|
|
70
|
+
coverPageIndices: r?.coverIndices,
|
|
71
|
+
onPageChanged: (e) => w.current?.(e)
|
|
64
72
|
})
|
|
65
73
|
);
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
K(
|
|
75
|
+
f,
|
|
68
76
|
() => ({
|
|
69
|
-
flipNext: () =>
|
|
70
|
-
flipPrev: () =>
|
|
71
|
-
goToPage: (
|
|
72
|
-
jumpToPage: (
|
|
73
|
-
getCurrentPageIndex: () =>
|
|
74
|
-
getTotalPages: () =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
flipNext: () => s.current.flipNext(),
|
|
78
|
+
flipPrev: () => s.current.flipPrev(),
|
|
79
|
+
goToPage: (e) => s.current.goToPage(e),
|
|
80
|
+
jumpToPage: (e) => s.current.jumpToPage(e),
|
|
81
|
+
getCurrentPageIndex: () => s.current.currentPageIndex,
|
|
82
|
+
getTotalPages: () => s.current.totalPages,
|
|
83
|
+
getOf: () => T.current !== void 0 ? T.current : s.current.totalPages,
|
|
84
|
+
isFirstPage: () => s.current.isFirstPage,
|
|
85
|
+
isLastPage: () => s.current.isLastPage,
|
|
86
|
+
toggleDebugBar: () => {
|
|
87
|
+
const t = document.querySelector(`.${l}`)?.querySelector(".flipbook-debug-bar");
|
|
88
|
+
t && t.classList.toggle("flipbook-debug-bar--hidden");
|
|
89
|
+
}
|
|
77
90
|
}),
|
|
78
|
-
[]
|
|
79
|
-
),
|
|
80
|
-
const
|
|
81
|
-
return
|
|
82
|
-
|
|
91
|
+
[l]
|
|
92
|
+
), W(() => {
|
|
93
|
+
const e = s.current;
|
|
94
|
+
return e.render(`.${l}`, m), S(e.currentPageIndex), () => {
|
|
95
|
+
e.destroy();
|
|
83
96
|
};
|
|
84
|
-
}, [
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
}, [l, m]);
|
|
98
|
+
const C = z.toArray(g), p = C.length, P = new Set(
|
|
99
|
+
r?.coverIndices === "auto" ? [0, p - 1] : r?.coverIndices ?? [0]
|
|
100
|
+
), E = (e) => P.has(e), y = /* @__PURE__ */ new Map();
|
|
101
|
+
if (r?.interiorCoverClassName || r?.frontInteriorCoverClassName || r?.backInteriorCoverClassName)
|
|
102
|
+
for (const e of P) {
|
|
103
|
+
const t = e % 2 === 0 ? e + 1 : e - 1;
|
|
104
|
+
if (t >= 0 && t < p && !P.has(t)) {
|
|
105
|
+
const c = e === Math.min(...P) ? "front" : "back";
|
|
106
|
+
y.set(t, c);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const $ = r?.coverInset ?? "5%", L = (e) => {
|
|
110
|
+
const t = ["page"];
|
|
111
|
+
E(e) && (t.push("page--cover"), r?.hardCovers && t.push("page--hard"), r?.noShadow && t.push("page--no-shadow"));
|
|
112
|
+
const c = y.get(e);
|
|
113
|
+
if (c) {
|
|
114
|
+
t.push("page--cover-interior");
|
|
115
|
+
const h = c === "front" ? r?.frontInteriorCoverClassName ?? r?.interiorCoverClassName : r?.backInteriorCoverClassName ?? r?.interiorCoverClassName;
|
|
116
|
+
h && t.push(h);
|
|
117
|
+
}
|
|
118
|
+
return t.join(" ");
|
|
119
|
+
}, A = d != null && p > 0 ? (() => {
|
|
120
|
+
const e = Math.floor(u / 2), t = Math.ceil(p / 2), c = 2, h = Math.max(0, e - d - c), F = Math.min(t - 1, e + d + c), j = h * 2, D = Math.min(p - 1, F * 2 + 1), M = new Set(
|
|
121
|
+
Array.from({ length: D - j + 1 }, (i, I) => j + I)
|
|
93
122
|
);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
123
|
+
for (const i of P) {
|
|
124
|
+
M.add(i);
|
|
125
|
+
const I = i % 2 === 0 ? i + 1 : i - 1;
|
|
126
|
+
I >= 0 && I < p && M.add(I);
|
|
127
|
+
}
|
|
128
|
+
return (i) => M.has(i) ? C[i] : null;
|
|
129
|
+
})() : (e) => C[e], q = (e) => {
|
|
130
|
+
const t = A(e);
|
|
131
|
+
if (y.has(e)) {
|
|
132
|
+
const h = e % 2 === 1 !== (v === "rtl"), F = {
|
|
133
|
+
"--cover-inset": $,
|
|
134
|
+
...h ? { "--cover-inset-right": "0px" } : { "--cover-inset-left": "0px" }
|
|
135
|
+
};
|
|
136
|
+
return /* @__PURE__ */ o("div", { className: "page--cover-interior-inset", style: F, children: t });
|
|
137
|
+
}
|
|
138
|
+
return t;
|
|
139
|
+
};
|
|
140
|
+
return /* @__PURE__ */ o("div", { className: l, children: C.map((e, t) => /* @__PURE__ */ o(
|
|
97
141
|
"div",
|
|
98
142
|
{
|
|
99
|
-
className:
|
|
100
|
-
children:
|
|
143
|
+
className: L(t),
|
|
144
|
+
children: q(t)
|
|
101
145
|
},
|
|
102
|
-
`page-${
|
|
146
|
+
`page-${t}`
|
|
103
147
|
)) });
|
|
104
148
|
}
|
|
105
149
|
);
|
|
106
|
-
|
|
150
|
+
J.displayName = "FlipBook";
|
|
107
151
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
152
|
+
J as FlipBook,
|
|
153
|
+
X as TocPage
|
|
110
154
|
};
|
|
111
155
|
//# sourceMappingURL=flip-book.js.map
|
package/dist/flip-book.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flip-book.js","sources":["../src/TocPage.tsx","../src/FlipBook.tsx"],"sourcesContent":["import type { PageSemantics } from \"html-flip-book-vanilla\";\nimport type React from \"react\";\nimport \"./TocPage.css\";\n\n/**\n * Entry in the table of contents.\n */\nexport interface TocEntry {\n\t/** Page index to navigate to */\n\tpageIndex: number;\n\t/** Display title (from pageSemantics.indexToTitle or custom) */\n\ttitle: string;\n\t/** Semantic page name/number (from pageSemantics.indexToSemanticName) */\n\tsemanticName: string;\n}\n\n/**\n * Props for the TocPage component.\n */\nexport interface TocPageProps {\n\t/** Callback to navigate to a specific page */\n\tonNavigate: (pageIndex: number) => void;\n\t/** Total number of pages in the book */\n\ttotalPages: number;\n\t/** Page semantics for generating titles and page numbers */\n\tpageSemantics?: PageSemantics;\n\t/** Custom heading text. Default: \"Table of Contents\" */\n\theading?: string;\n\t/** Custom CSS class for the container */\n\tclassName?: string;\n\t/** Reading direction for RTL support */\n\tdirection?: \"ltr\" | \"rtl\";\n\t/**\n\t * Filter function to determine which pages appear in TOC.\n\t * By default, only pages with a title are included.\n\t */\n\tfilter?: (entry: TocEntry, pageIndex: number) => boolean;\n\t/**\n\t * Custom render function for TOC entries.\n\t * If not provided, uses default rendering.\n\t */\n\trenderEntry?: (entry: TocEntry, onClick: () => void) => React.ReactNode;\n}\n\n/**\n * Default filter: include pages that have a non-empty title.\n */\nconst defaultFilter = (entry: TocEntry): boolean => entry.title.length > 0;\n\n/**\n * A table of contents page component for FlipBook.\n *\n * Automatically generates TOC entries from pageSemantics, showing pages\n * that have titles. Entries display title with fallback to semantic name,\n * then page index.\n *\n * @example\n * ```tsx\n * <TocPage\n * onNavigate={(pageIndex) => flipBookRef.current?.goToPage(pageIndex)}\n * totalPages={20}\n * pageSemantics={mySemantics}\n * heading=\"Contents\"\n * direction=\"rtl\"\n * />\n * ```\n */\nconst TocPage: React.FC<TocPageProps> = ({\n\tonNavigate,\n\ttotalPages,\n\tpageSemantics,\n\theading = \"Table of Contents\",\n\tclassName,\n\tdirection = \"ltr\",\n\tfilter = defaultFilter,\n\trenderEntry,\n}) => {\n\t// Generate TOC entries for all pages\n\tconst entries: TocEntry[] = [];\n\tfor (let i = 0; i < totalPages; i++) {\n\t\tconst title = pageSemantics?.indexToTitle(i) ?? \"\";\n\t\tconst semanticName = pageSemantics?.indexToSemanticName(i) ?? \"\";\n\t\tconst entry: TocEntry = { pageIndex: i, title, semanticName };\n\n\t\tif (filter(entry, i)) {\n\t\t\tentries.push(entry);\n\t\t}\n\t}\n\n\tconst renderDefaultEntry = (entry: TocEntry, onClick: () => void) => {\n\t\t// Display: title (with semantic name or index as fallback for page number)\n\t\tconst displayText = entry.title || entry.semanticName || `Page ${entry.pageIndex}`;\n\t\tconst displayNumber = entry.semanticName || String(entry.pageIndex);\n\n\t\treturn (\n\t\t\t<li key={entry.pageIndex}>\n\t\t\t\t<button type=\"button\" className=\"toc-link\" onClick={onClick}>\n\t\t\t\t\t<span className=\"toc-title\">{displayText}</span>\n\t\t\t\t\t<span className=\"toc-dots\" />\n\t\t\t\t\t<span className=\"toc-page-num\">{displayNumber}</span>\n\t\t\t\t</button>\n\t\t\t</li>\n\t\t);\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={`toc-page ${className ?? \"\"}`.trim()}\n\t\t\tstyle={{ direction, textAlign: direction === \"rtl\" ? \"right\" : \"left\" }}\n\t\t>\n\t\t\t<h2 className=\"toc-heading\">{heading}</h2>\n\t\t\t<ul className=\"toc-list\">\n\t\t\t\t{entries.map((entry) => {\n\t\t\t\t\tconst onClick = () => onNavigate(entry.pageIndex);\n\t\t\t\t\treturn renderEntry ? renderEntry(entry, onClick) : renderDefaultEntry(entry, onClick);\n\t\t\t\t})}\n\t\t\t</ul>\n\t\t</div>\n\t);\n};\n\nexport { TocPage };\n","import { FlipBook as FlipBookBase, type PageSemantics } from \"html-flip-book-vanilla\";\nimport type React from \"react\";\nimport { Children, forwardRef, useEffect, useImperativeHandle, useRef, useState } from \"react\";\n\n/**\n * Imperative handle exposed via ref for programmatic control of the FlipBook.\n *\n * @example\n * ```tsx\n * const ref = useRef<FlipBookHandle>(null);\n * // Later:\n * await ref.current?.flipNext();\n * ```\n */\nexport interface FlipBookHandle {\n\t/** Animate flip to the next page */\n\tflipNext: () => Promise<void>;\n\t/** Animate flip to the previous page */\n\tflipPrev: () => Promise<void>;\n\t/** Animate to a specific page index */\n\tgoToPage: (pageIndex: number) => Promise<void>;\n\t/** Jump to a specific page instantly without animation */\n\tjumpToPage: (pageIndex: number) => void;\n\t/** Get the current (leftmost visible) page index */\n\tgetCurrentPageIndex: () => number;\n\t/** Get the total number of pages */\n\tgetTotalPages: () => number;\n\t/** Check if currently at the first page */\n\tisFirstPage: () => boolean;\n\t/** Check if currently at the last page */\n\tisLastPage: () => boolean;\n}\n\n/**\n * Configuration for book covers.\n */\nexport interface CoverConfig {\n\t/**\n\t * Make covers \"hard\" - no page curl effect on covers.\n\t * When true, cover pages appear flat without the soft page bend.\n\t * Default: false\n\t */\n\thardCovers?: boolean;\n\t/**\n\t * Disable shadow effects on cover pages.\n\t * Default: false\n\t */\n\tnoShadow?: boolean;\n\t/**\n\t * Page indices that are considered cover pages.\n\t * Default: [0] (front cover only). Use [0, totalPages-1] for front and back covers.\n\t * If \"auto\", uses first and last pages as covers.\n\t */\n\tcoverIndices?: number[] | \"auto\";\n}\n\n/**\n * Props for the FlipBook React component.\n */\nexport interface FlipBookProps {\n\t/** Array of React elements to render as pages */\n\tpages: React.ReactNode[];\n\t/** CSS class name for the flipbook container */\n\tclassName: string;\n\t/** Define which pages are covers for special styling */\n\tpageSemantics?: PageSemantics;\n\t/** Enable debug mode */\n\tdebug?: boolean;\n\t/** Reading direction: 'ltr' (left-to-right) or 'rtl' (right-to-left) */\n\tdirection?: \"rtl\" | \"ltr\";\n\t/** Indices of leaves that should start in the turned (flipped) state */\n\tinitialTurnedLeaves?: number[];\n\t/** Velocity threshold (px/s) for fast swipe to complete flip. Default: 500 */\n\tfastDeltaThreshold?: number;\n\t/**\n\t * Number of leaves to keep rendered before and after the current position.\n\t * When set, only leaves within the buffer range are visible for performance.\n\t * Default: undefined (all leaves are always rendered)\n\t */\n\tleavesBuffer?: number;\n\t/**\n\t * Configuration for cover pages (front and back covers).\n\t */\n\tcoverConfig?: CoverConfig;\n}\n\n/**\n * A React component for creating realistic page-flip animations.\n *\n * @example\n * ```tsx\n * import { FlipBook } from 'html-flip-book-react';\n *\n * function App() {\n * const ref = useRef<FlipBookHandle>(null);\n * return (\n * <FlipBook\n * ref={ref}\n * pages={[<div>Page 1</div>, <div>Page 2</div>]}\n * className=\"my-book\"\n * direction=\"ltr\"\n * />\n * );\n * }\n * ```\n */\nconst FlipBookReact = forwardRef<FlipBookHandle, FlipBookProps>(\n\t(\n\t\t{\n\t\t\tpages,\n\t\t\tclassName,\n\t\t\tdebug = false,\n\t\t\tdirection = \"ltr\",\n\t\t\tpageSemantics = undefined,\n\t\t\tinitialTurnedLeaves = [],\n\t\t\tfastDeltaThreshold,\n\t\t\tleavesBuffer,\n\t\t\tcoverConfig,\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst [currentPageIndex, setCurrentPageIndex] = useState(0);\n\t\tconst setPageIndexRef = useRef(setCurrentPageIndex);\n\t\tsetPageIndexRef.current = setCurrentPageIndex;\n\n\t\tconst flipBook = useRef(\n\t\t\tnew FlipBookBase({\n\t\t\t\tpageSemantics: pageSemantics,\n\t\t\t\tpagesCount: pages.length,\n\t\t\t\tdirection: direction,\n\t\t\t\tinitialTurnedLeaves: initialTurnedLeaves,\n\t\t\t\tfastDeltaThreshold: fastDeltaThreshold,\n\t\t\t\tleavesBuffer: leavesBuffer,\n\t\t\t\tonPageChanged: (index: number) => setPageIndexRef.current?.(index),\n\t\t\t}),\n\t\t);\n\n\t\t// Expose imperative methods via ref\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\tflipNext: () => flipBook.current.flipNext(),\n\t\t\t\tflipPrev: () => flipBook.current.flipPrev(),\n\t\t\t\tgoToPage: (pageIndex: number) => flipBook.current.goToPage(pageIndex),\n\t\t\t\tjumpToPage: (pageIndex: number) => flipBook.current.jumpToPage(pageIndex),\n\t\t\t\tgetCurrentPageIndex: () => flipBook.current.currentPageIndex,\n\t\t\t\tgetTotalPages: () => flipBook.current.totalPages,\n\t\t\t\tisFirstPage: () => flipBook.current.isFirstPage,\n\t\t\t\tisLastPage: () => flipBook.current.isLastPage,\n\t\t\t}),\n\t\t\t[],\n\t\t);\n\n\t\tuseEffect(() => {\n\t\t\tconst currentFlipBook = flipBook.current;\n\t\t\tcurrentFlipBook.render(`.${className}`, debug);\n\t\t\tsetCurrentPageIndex(currentFlipBook.currentPageIndex);\n\n\t\t\t// Cleanup function to destroy Hammer instance and event listeners\n\t\t\treturn () => {\n\t\t\t\tcurrentFlipBook.destroy();\n\t\t\t};\n\t\t}, [className, debug]);\n\n\t\t// Use Children.toArray to get stable keys for each page element\n\t\tconst pagesWithKeys = Children.toArray(pages);\n\t\tconst totalPages = pagesWithKeys.length;\n\n\t\t// Determine cover page indices\n\t\tconst coverIndicesSet = new Set(\n\t\t\tcoverConfig?.coverIndices === \"auto\"\n\t\t\t\t? [0, totalPages - 1]\n\t\t\t\t: (coverConfig?.coverIndices ?? [0]),\n\t\t);\n\t\tconst isCoverPage = (index: number) => coverIndicesSet.has(index);\n\n\t\t// Build CSS class for a page\n\t\tconst getPageClassName = (index: number): string => {\n\t\t\tconst classes = [\"page\"];\n\t\t\tif (isCoverPage(index)) {\n\t\t\t\tclasses.push(\"page--cover\");\n\t\t\t\tif (coverConfig?.hardCovers) {\n\t\t\t\t\tclasses.push(\"page--hard\");\n\t\t\t\t}\n\t\t\t\tif (coverConfig?.noShadow) {\n\t\t\t\t\tclasses.push(\"page--no-shadow\");\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn classes.join(\" \");\n\t\t};\n\n\t\t// When leavesBuffer is set, only mount content for pages within the buffer (keep .page wrappers for layout).\n\t\t// Use a small margin so content is ready before vanilla shows the leaf (avoids empty flash when flipping).\n\t\tconst contentByIndex =\n\t\t\tleavesBuffer != null && totalPages > 0\n\t\t\t\t? (() => {\n\t\t\t\t\t\tconst currentLeaf = Math.floor(currentPageIndex / 2);\n\t\t\t\t\t\tconst leavesCount = Math.ceil(totalPages / 2);\n\t\t\t\t\t\tconst margin = 2; // extra leaves each side so content exists when vanilla reveals them\n\t\t\t\t\t\tconst leafStart = Math.max(0, currentLeaf - leavesBuffer - margin);\n\t\t\t\t\t\tconst leafEnd = Math.min(leavesCount - 1, currentLeaf + leavesBuffer + margin);\n\t\t\t\t\t\tconst pageStart = leafStart * 2;\n\t\t\t\t\t\tconst pageEnd = Math.min(totalPages - 1, leafEnd * 2 + 1);\n\t\t\t\t\t\tconst inRange = new Set(\n\t\t\t\t\t\t\tArray.from({ length: pageEnd - pageStart + 1 }, (_, i) => pageStart + i),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn (index: number) => (inRange.has(index) ? pagesWithKeys[index] : null);\n\t\t\t\t\t})()\n\t\t\t\t: (index: number) => pagesWithKeys[index];\n\n\t\treturn (\n\t\t\t<div className={className}>\n\t\t\t\t{pagesWithKeys.map((_, index) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: stable slot identity for buffer/mount correctness\n\t\t\t\t\t\tkey={`page-${index}`}\n\t\t\t\t\t\tclassName={getPageClassName(index)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{contentByIndex(index)}\n\t\t\t\t\t</div>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t);\n\t},\n);\n\nFlipBookReact.displayName = \"FlipBook\";\n\nexport { FlipBookReact as FlipBook };\nexport type { PageSemantics };\nexport type { TocEntry, TocPageProps } from \"./TocPage\";\nexport { TocPage } from \"./TocPage\";\n"],"names":["defaultFilter","entry","TocPage","onNavigate","totalPages","pageSemantics","heading","className","direction","filter","renderEntry","entries","i","title","semanticName","renderDefaultEntry","onClick","displayText","displayNumber","jsx","jsxs","FlipBookReact","forwardRef","pages","debug","initialTurnedLeaves","fastDeltaThreshold","leavesBuffer","coverConfig","ref","currentPageIndex","setCurrentPageIndex","useState","setPageIndexRef","useRef","flipBook","FlipBookBase","index","useImperativeHandle","pageIndex","useEffect","currentFlipBook","pagesWithKeys","Children","coverIndicesSet","isCoverPage","getPageClassName","classes","contentByIndex","currentLeaf","leavesCount","margin","leafStart","leafEnd","pageStart","pageEnd","inRange","_"],"mappings":";;;AA+CA,MAAMA,IAAgB,CAACC,MAA6BA,EAAM,MAAM,SAAS,GAoBnEC,IAAkC,CAAC;AAAA,EACxC,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,QAAAC,IAAST;AAAA,EACT,aAAAU;AACD,MAAM;AAEL,QAAMC,IAAsB,CAAA;AAC5B,WAASC,IAAI,GAAGA,IAAIR,GAAYQ,KAAK;AACpC,UAAMC,IAAQR,GAAe,aAAaO,CAAC,KAAK,IAC1CE,IAAeT,GAAe,oBAAoB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AiBT,CAAK;AAAA,QAEhC,YAAeA,CAAK;AAAA,MAAA;AAAA,MAHhB,QAAQA,CAAK;AAAA,IAAA,CAKnB,GACF;AAAA,EAEF;AACD;AAEAhB,EAAc,cAAc;"}
|
|
1
|
+
{"version":3,"file":"flip-book.js","sources":["../src/TocPage.tsx","../src/FlipBook.tsx"],"sourcesContent":["import type { PageSemantics } from \"html-flip-book-vanilla\";\nimport type React from \"react\";\nimport \"./TocPage.css\";\n\n/**\n * Entry in the table of contents.\n */\nexport interface TocEntry {\n\t/** Page index to navigate to */\n\tpageIndex: number;\n\t/** Display title (from pageSemantics.indexToTitle or custom) */\n\ttitle: string;\n\t/** Semantic page name/number (from pageSemantics.indexToSemanticName) */\n\tsemanticName: string;\n}\n\n/**\n * Props for the TocPage component.\n */\nexport interface TocPageProps {\n\t/** Callback to navigate to a specific page */\n\tonNavigate: (pageIndex: number) => void;\n\t/** Total number of pages in the book */\n\ttotalPages: number;\n\t/** Page semantics for generating titles and page numbers */\n\tpageSemantics?: PageSemantics;\n\t/** Custom heading text. Default: \"Table of Contents\" */\n\theading?: string;\n\t/** Custom CSS class for the container */\n\tclassName?: string;\n\t/** Reading direction for RTL support */\n\tdirection?: \"ltr\" | \"rtl\";\n\t/**\n\t * Filter function to determine which pages appear in TOC.\n\t * By default, only pages with a title are included.\n\t */\n\tfilter?: (entry: TocEntry, pageIndex: number) => boolean;\n\t/**\n\t * Custom render function for TOC entries.\n\t * If not provided, uses default rendering.\n\t */\n\trenderEntry?: (entry: TocEntry, onClick: () => void) => React.ReactNode;\n}\n\n/**\n * Default filter: include pages that have a non-empty title.\n */\nconst defaultFilter = (entry: TocEntry): boolean => entry.title.length > 0;\n\n/**\n * A table of contents page component for FlipBook.\n *\n * Automatically generates TOC entries from pageSemantics, showing pages\n * that have titles. Entries display title with fallback to semantic name,\n * then page index.\n *\n * @example\n * ```tsx\n * <TocPage\n * onNavigate={(pageIndex) => flipBookRef.current?.goToPage(pageIndex)}\n * totalPages={20}\n * pageSemantics={mySemantics}\n * heading=\"Contents\"\n * direction=\"rtl\"\n * />\n * ```\n */\nconst TocPage: React.FC<TocPageProps> = ({\n\tonNavigate,\n\ttotalPages,\n\tpageSemantics,\n\theading = \"Table of Contents\",\n\tclassName,\n\tdirection = \"ltr\",\n\tfilter = defaultFilter,\n\trenderEntry,\n}) => {\n\t// Generate TOC entries for all pages\n\tconst entries: TocEntry[] = [];\n\tfor (let i = 0; i < totalPages; i++) {\n\t\tconst title = pageSemantics?.indexToTitle(i) ?? \"\";\n\t\tconst semanticName = pageSemantics?.indexToSemanticName(i) ?? \"\";\n\t\tconst entry: TocEntry = { pageIndex: i, title, semanticName };\n\n\t\tif (filter(entry, i)) {\n\t\t\tentries.push(entry);\n\t\t}\n\t}\n\n\tconst renderDefaultEntry = (entry: TocEntry, onClick: () => void) => {\n\t\t// Display: title (with semantic name or index as fallback for page number)\n\t\tconst displayText = entry.title || entry.semanticName || `Page ${entry.pageIndex}`;\n\t\tconst displayNumber = entry.semanticName || String(entry.pageIndex);\n\n\t\treturn (\n\t\t\t<li key={entry.pageIndex}>\n\t\t\t\t<button type=\"button\" className=\"toc-link\" onClick={onClick}>\n\t\t\t\t\t<span className=\"toc-title\">{displayText}</span>\n\t\t\t\t\t<span className=\"toc-dots\" />\n\t\t\t\t\t<span className=\"toc-page-num\">{displayNumber}</span>\n\t\t\t\t</button>\n\t\t\t</li>\n\t\t);\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={`toc-page ${className ?? \"\"}`.trim()}\n\t\t\tstyle={{ direction, textAlign: direction === \"rtl\" ? \"right\" : \"left\" }}\n\t\t>\n\t\t\t<h2 className=\"toc-heading\">{heading}</h2>\n\t\t\t<ul className=\"toc-list\">\n\t\t\t\t{entries.map((entry) => {\n\t\t\t\t\tconst onClick = () => onNavigate(entry.pageIndex);\n\t\t\t\t\treturn renderEntry ? renderEntry(entry, onClick) : renderDefaultEntry(entry, onClick);\n\t\t\t\t})}\n\t\t\t</ul>\n\t\t</div>\n\t);\n};\n\nexport { TocPage };\n","import { FlipBook as FlipBookBase, type PageSemantics } from \"html-flip-book-vanilla\";\nimport type React from \"react\";\nimport { Children, forwardRef, useEffect, useImperativeHandle, useRef, useState } from \"react\";\n\n/**\n * Imperative handle exposed via ref for programmatic control of the FlipBook.\n *\n * @example\n * ```tsx\n * const ref = useRef<FlipBookHandle>(null);\n * // Later:\n * await ref.current?.flipNext();\n * ```\n */\nexport interface FlipBookHandle {\n\t/** Animate flip to the next page */\n\tflipNext: () => Promise<void>;\n\t/** Animate flip to the previous page */\n\tflipPrev: () => Promise<void>;\n\t/** Animate to a specific page index */\n\tgoToPage: (pageIndex: number) => Promise<void>;\n\t/** Jump to a specific page instantly without animation */\n\tjumpToPage: (pageIndex: number) => void;\n\t/** Get the current (leftmost visible) page index */\n\tgetCurrentPageIndex: () => number;\n\t/** Get the total number of pages */\n\tgetTotalPages: () => number;\n\t/** Get the \"of\" value for the indicator (e.g. total label). Defaults to total pages when not set. */\n\tgetOf: () => string | number;\n\t/** Check if currently at the first page */\n\tisFirstPage: () => boolean;\n\t/** Check if currently at the last page */\n\tisLastPage: () => boolean;\n\t/** Toggle debug toolbar visibility (when debug mode is enabled). Bound to Ctrl+Alt+D by default. */\n\ttoggleDebugBar?: () => void;\n}\n\n/**\n * Configuration for book covers.\n */\nexport interface CoverConfig {\n\t/**\n\t * Make covers \"hard\" - no page curl effect on covers.\n\t * When true, cover pages appear flat without the soft page bend.\n\t * Default: false\n\t */\n\thardCovers?: boolean;\n\t/**\n\t * Disable shadow effects on cover pages.\n\t * Default: false\n\t */\n\tnoShadow?: boolean;\n\t/**\n\t * Page indices that are considered cover pages.\n\t * Default: [0] (front cover only). Use [0, totalPages-1] for front and back covers.\n\t * If \"auto\", uses first and last pages as covers.\n\t */\n\tcoverIndices?: number[] | \"auto\";\n\t/**\n\t * CSS class applied to interior sides of cover leaves (the endpaper).\n\t * Sets the page background to the cover color; the white endpaper inset\n\t * is created automatically by the infrastructure.\n\t */\n\tinteriorCoverClassName?: string;\n\t/**\n\t * Override interiorCoverClassName for the front cover interior specifically.\n\t */\n\tfrontInteriorCoverClassName?: string;\n\t/**\n\t * Override interiorCoverClassName for the back cover interior specifically.\n\t */\n\tbackInteriorCoverClassName?: string;\n\t/**\n\t * Inset size for the interior endpaper frame.\n\t * Any valid CSS length (e.g. \"5%\", \"12px\"). Default: \"5%\".\n\t */\n\tcoverInset?: string;\n}\n\n/**\n * Props for the FlipBook React component.\n */\nexport interface FlipBookProps {\n\t/** Array of React elements to render as pages */\n\tpages: React.ReactNode[];\n\t/** CSS class name for the flipbook container */\n\tclassName: string;\n\t/** Define which pages are covers for special styling */\n\tpageSemantics?: PageSemantics;\n\t/** Enable debug mode */\n\tdebug?: boolean;\n\t/** Reading direction: 'ltr' (left-to-right) or 'rtl' (right-to-left) */\n\tdirection?: \"rtl\" | \"ltr\";\n\t/** Indices of leaves that should start in the turned (flipped) state */\n\tinitialTurnedLeaves?: number[];\n\t/** Velocity threshold (px/s) for fast swipe to complete flip. Default: 500 */\n\tfastDeltaThreshold?: number;\n\t/**\n\t * Number of leaves to keep rendered before and after the current position.\n\t * When set, only leaves within the buffer range are visible for performance.\n\t * Default: undefined (all leaves are always rendered)\n\t */\n\tleavesBuffer?: number;\n\t/**\n\t * Configuration for cover pages (front and back covers).\n\t */\n\tcoverConfig?: CoverConfig;\n\t/**\n\t * Override for the \"of\" part of the page indicator (e.g. \"נ\" for Hebrew books).\n\t * Defaults to total pages count when not set.\n\t */\n\tof?: string | number;\n\t/**\n\t * Aspect ratio for inner pages (text block leaves).\n\t * Default: { width: 2, height: 3 }\n\t */\n\tleafAspectRatio?: { width: number; height: number };\n\t/**\n\t * Aspect ratio for cover boards (slightly larger than leaf).\n\t * The delta between cover and leaf aspect ratios determines the visible frame.\n\t * Default: { width: 2.15, height: 3.15 }\n\t */\n\tcoverAspectRatio?: { width: number; height: number };\n}\n\n/**\n * A React component for creating realistic page-flip animations.\n *\n * @example\n * ```tsx\n * import { FlipBook } from 'html-flip-book-react';\n *\n * function App() {\n * const ref = useRef<FlipBookHandle>(null);\n * return (\n * <FlipBook\n * ref={ref}\n * pages={[<div>Page 1</div>, <div>Page 2</div>]}\n * className=\"my-book\"\n * direction=\"ltr\"\n * />\n * );\n * }\n * ```\n */\nconst FlipBookReact = forwardRef<FlipBookHandle, FlipBookProps>(\n\t(\n\t\t{\n\t\t\tpages,\n\t\t\tclassName,\n\t\t\tdebug = false,\n\t\t\tdirection = \"ltr\",\n\t\t\tpageSemantics = undefined,\n\t\t\tinitialTurnedLeaves = [],\n\t\t\tfastDeltaThreshold,\n\t\t\tleavesBuffer,\n\t\t\tcoverConfig,\n\t\t\tof,\n\t\t\tleafAspectRatio,\n\t\t\tcoverAspectRatio,\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst [currentPageIndex, setCurrentPageIndex] = useState(0);\n\t\tconst setPageIndexRef = useRef(setCurrentPageIndex);\n\t\tsetPageIndexRef.current = setCurrentPageIndex;\n\t\tconst ofRef = useRef(of);\n\t\tofRef.current = of;\n\n\t\tconst flipBook = useRef(\n\t\t\tnew FlipBookBase({\n\t\t\t\tpageSemantics: pageSemantics,\n\t\t\t\tpagesCount: pages.length,\n\t\t\t\tdirection: direction,\n\t\t\t\tinitialTurnedLeaves: initialTurnedLeaves,\n\t\t\t\tfastDeltaThreshold: fastDeltaThreshold,\n\t\t\t\tleavesBuffer: leavesBuffer,\n\t\t\t\tleafAspectRatio: leafAspectRatio,\n\t\t\t\tcoverAspectRatio: coverAspectRatio,\n\t\t\t\tcoverPageIndices: coverConfig?.coverIndices,\n\t\t\t\tonPageChanged: (index: number) => setPageIndexRef.current?.(index),\n\t\t\t}),\n\t\t);\n\n\t\t// Expose imperative methods via ref\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\tflipNext: () => flipBook.current.flipNext(),\n\t\t\t\tflipPrev: () => flipBook.current.flipPrev(),\n\t\t\t\tgoToPage: (pageIndex: number) => flipBook.current.goToPage(pageIndex),\n\t\t\t\tjumpToPage: (pageIndex: number) => flipBook.current.jumpToPage(pageIndex),\n\t\t\t\tgetCurrentPageIndex: () => flipBook.current.currentPageIndex,\n\t\t\t\tgetTotalPages: () => flipBook.current.totalPages,\n\t\t\t\tgetOf: () => (ofRef.current !== undefined ? ofRef.current : flipBook.current.totalPages),\n\t\t\t\tisFirstPage: () => flipBook.current.isFirstPage,\n\t\t\t\tisLastPage: () => flipBook.current.isLastPage,\n\t\t\t\ttoggleDebugBar: () => {\n\t\t\t\t\tconst root = document.querySelector(`.${className}`);\n\t\t\t\t\tconst bar = root?.querySelector(\".flipbook-debug-bar\");\n\t\t\t\t\tif (bar) bar.classList.toggle(\"flipbook-debug-bar--hidden\");\n\t\t\t\t},\n\t\t\t}),\n\t\t\t[className],\n\t\t);\n\n\t\tuseEffect(() => {\n\t\t\tconst currentFlipBook = flipBook.current;\n\t\t\tcurrentFlipBook.render(`.${className}`, debug);\n\t\t\tsetCurrentPageIndex(currentFlipBook.currentPageIndex);\n\n\t\t\t// Cleanup function to destroy Hammer instance and event listeners\n\t\t\treturn () => {\n\t\t\t\tcurrentFlipBook.destroy();\n\t\t\t};\n\t\t}, [className, debug]);\n\n\t\t// Use Children.toArray to get stable keys for each page element\n\t\tconst pagesWithKeys = Children.toArray(pages);\n\t\tconst totalPages = pagesWithKeys.length;\n\n\t\t// Determine cover page indices\n\t\tconst coverIndicesSet = new Set(\n\t\t\tcoverConfig?.coverIndices === \"auto\"\n\t\t\t\t? [0, totalPages - 1]\n\t\t\t\t: (coverConfig?.coverIndices ?? [0]),\n\t\t);\n\t\tconst isCoverPage = (index: number) => coverIndicesSet.has(index);\n\n\t\t// Compute interior cover page indices (the other side of each cover leaf).\n\t\t// Leaf pairs: [0,1], [2,3], ... — interior is the paired page on the same leaf.\n\t\tconst interiorCoverMap = new Map<number, \"front\" | \"back\">();\n\t\tif (\n\t\t\tcoverConfig?.interiorCoverClassName ||\n\t\t\tcoverConfig?.frontInteriorCoverClassName ||\n\t\t\tcoverConfig?.backInteriorCoverClassName\n\t\t) {\n\t\t\tfor (const coverIdx of coverIndicesSet) {\n\t\t\t\tconst interiorIdx = coverIdx % 2 === 0 ? coverIdx + 1 : coverIdx - 1;\n\t\t\t\tif (interiorIdx >= 0 && interiorIdx < totalPages && !coverIndicesSet.has(interiorIdx)) {\n\t\t\t\t\t// First cover index = front, others = back\n\t\t\t\t\tconst role = coverIdx === Math.min(...coverIndicesSet) ? \"front\" : \"back\";\n\t\t\t\t\tinteriorCoverMap.set(interiorIdx, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst coverInset = coverConfig?.coverInset ?? \"5%\";\n\n\t\t// Build CSS class for a page\n\t\tconst getPageClassName = (index: number): string => {\n\t\t\tconst classes = [\"page\"];\n\t\t\tif (isCoverPage(index)) {\n\t\t\t\tclasses.push(\"page--cover\");\n\t\t\t\tif (coverConfig?.hardCovers) {\n\t\t\t\t\tclasses.push(\"page--hard\");\n\t\t\t\t}\n\t\t\t\tif (coverConfig?.noShadow) {\n\t\t\t\t\tclasses.push(\"page--no-shadow\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst interiorRole = interiorCoverMap.get(index);\n\t\t\tif (interiorRole) {\n\t\t\t\tclasses.push(\"page--cover-interior\");\n\t\t\t\tconst cls =\n\t\t\t\t\tinteriorRole === \"front\"\n\t\t\t\t\t\t? (coverConfig?.frontInteriorCoverClassName ?? coverConfig?.interiorCoverClassName)\n\t\t\t\t\t\t: (coverConfig?.backInteriorCoverClassName ?? coverConfig?.interiorCoverClassName);\n\t\t\t\tif (cls) classes.push(cls);\n\t\t\t}\n\t\t\treturn classes.join(\" \");\n\t\t};\n\n\t\t// When leavesBuffer is set, only mount content for pages within the buffer (keep .page wrappers for layout).\n\t\t// Use a small margin so content is ready before vanilla shows the leaf (avoids empty flash when flipping).\n\t\t// Cover pages are always mounted — they are cover-sized and sit behind leaf-sized pages,\n\t\t// acting as the physical book boards. Unmounting them would remove the realistic frame effect.\n\t\tconst contentByIndex =\n\t\t\tleavesBuffer != null && totalPages > 0\n\t\t\t\t? (() => {\n\t\t\t\t\t\tconst currentLeaf = Math.floor(currentPageIndex / 2);\n\t\t\t\t\t\tconst leavesCount = Math.ceil(totalPages / 2);\n\t\t\t\t\t\tconst margin = 2; // extra leaves each side so content exists when vanilla reveals them\n\t\t\t\t\t\tconst leafStart = Math.max(0, currentLeaf - leavesBuffer - margin);\n\t\t\t\t\t\tconst leafEnd = Math.min(leavesCount - 1, currentLeaf + leavesBuffer + margin);\n\t\t\t\t\t\tconst pageStart = leafStart * 2;\n\t\t\t\t\t\tconst pageEnd = Math.min(totalPages - 1, leafEnd * 2 + 1);\n\t\t\t\t\t\tconst inRange = new Set(\n\t\t\t\t\t\t\tArray.from({ length: pageEnd - pageStart + 1 }, (_, i) => pageStart + i),\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// Always include cover leaf pages so the larger cover boards remain mounted.\n\t\t\t\t\t\tfor (const idx of coverIndicesSet) {\n\t\t\t\t\t\t\tinRange.add(idx);\n\t\t\t\t\t\t\t// Also include the other side of the cover leaf\n\t\t\t\t\t\t\tconst partner = idx % 2 === 0 ? idx + 1 : idx - 1;\n\t\t\t\t\t\t\tif (partner >= 0 && partner < totalPages) {\n\t\t\t\t\t\t\t\tinRange.add(partner);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn (index: number) => (inRange.has(index) ? pagesWithKeys[index] : null);\n\t\t\t\t\t})()\n\t\t\t\t: (index: number) => pagesWithKeys[index];\n\n\t\t/** Wrap interior cover pages with the endpaper inset frame (3-sided: no inset on spine). */\n\t\tconst renderPageContent = (index: number) => {\n\t\t\tconst content = contentByIndex(index);\n\t\t\tif (interiorCoverMap.has(index)) {\n\t\t\t\t// Determine spine side: even pages (engine convention: pageIndex%2===1) are on the\n\t\t\t\t// left in LTR / right in RTL. Their spine is on the opposite side.\n\t\t\t\tconst isEvenPage = index % 2 === 1; // engine: (pageIndex+1)%2===1 → odd; so %2===1 → even\n\t\t\t\tconst spineOnRight = isEvenPage !== (direction === \"rtl\");\n\t\t\t\tconst insetStyle = {\n\t\t\t\t\t\"--cover-inset\": coverInset,\n\t\t\t\t\t...(spineOnRight ? { \"--cover-inset-right\": \"0px\" } : { \"--cover-inset-left\": \"0px\" }),\n\t\t\t\t} as Record<string, string>;\n\t\t\t\treturn (\n\t\t\t\t\t<div className=\"page--cover-interior-inset\" style={insetStyle}>\n\t\t\t\t\t\t{content}\n\t\t\t\t\t</div>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn content;\n\t\t};\n\n\t\treturn (\n\t\t\t<div className={className}>\n\t\t\t\t{pagesWithKeys.map((_, index) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: stable slot identity for buffer/mount correctness\n\t\t\t\t\t\tkey={`page-${index}`}\n\t\t\t\t\t\tclassName={getPageClassName(index)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{renderPageContent(index)}\n\t\t\t\t\t</div>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t);\n\t},\n);\n\nFlipBookReact.displayName = \"FlipBook\";\n\nexport { FlipBookReact as FlipBook };\nexport type { PageSemantics };\nexport type { TocEntry, TocPageProps } from \"./TocPage\";\nexport { TocPage } from \"./TocPage\";\n"],"names":["defaultFilter","entry","TocPage","onNavigate","totalPages","pageSemantics","heading","className","direction","filter","renderEntry","entries","i","title","semanticName","renderDefaultEntry","onClick","displayText","displayNumber","jsx","jsxs","FlipBookReact","forwardRef","pages","debug","initialTurnedLeaves","fastDeltaThreshold","leavesBuffer","coverConfig","of","leafAspectRatio","coverAspectRatio","ref","currentPageIndex","setCurrentPageIndex","useState","setPageIndexRef","useRef","ofRef","flipBook","FlipBookBase","index","useImperativeHandle","pageIndex","bar","useEffect","currentFlipBook","pagesWithKeys","Children","coverIndicesSet","isCoverPage","interiorCoverMap","coverIdx","interiorIdx","role","coverInset","getPageClassName","classes","interiorRole","cls","contentByIndex","currentLeaf","leavesCount","margin","leafStart","leafEnd","pageStart","pageEnd","inRange","_","idx","partner","renderPageContent","content","spineOnRight","insetStyle"],"mappings":";;;AA+CA,MAAMA,IAAgB,CAACC,MAA6BA,EAAM,MAAM,SAAS,GAoBnEC,IAAkC,CAAC;AAAA,EACxC,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,QAAAC,IAAST;AAAA,EACT,aAAAU;AACD,MAAM;AAEL,QAAMC,IAAsB,CAAA;AAC5B,WAASC,IAAI,GAAGA,IAAIR,GAAYQ,KAAK;AACpC,UAAMC,IAAQR,GAAe,aAAaO,CAAC,KAAK,IAC1CE,IAAeT,GAAe,oBAAoBO,CAAC,KAAK,IACxDX,IAAkB,EAAE,WAAWW,GAAG,OAAAC,GAAO,cAAAC,EAAA;AAE/C,IAAIL,EAAOR,GAAOW,CAAC,KAClBD,EAAQ,KAAKV,CAAK;AAAA,EAEpB;AAEA,QAAMc,IAAqB,CAACd,GAAiBe,MAAwB;AAEpE,UAAMC,IAAchB,EAAM,SAASA,EAAM,gBAAgB,QAAQA,EAAM,SAAS,IAC1EiB,IAAgBjB,EAAM,gBAAgB,OAAOA,EAAM,SAAS;AAElE,WACC,gBAAAkB,EAAC,QACA,UAAA,gBAAAC,EAAC,UAAA,EAAO,MAAK,UAAS,WAAU,YAAW,SAAAJ,GAC1C,UAAA;AAAA,MAAA,gBAAAG,EAAC,QAAA,EAAK,WAAU,aAAa,UAAAF,GAAY;AAAA,MACzC,gBAAAE,EAAC,QAAA,EAAK,WAAU,WAAA,CAAW;AAAA,MAC3B,gBAAAA,EAAC,QAAA,EAAK,WAAU,gBAAgB,UAAAD,EAAA,CAAc;AAAA,IAAA,GAC/C,EAAA,GALQjB,EAAM,SAMf;AAAA,EAEF;AAEA,SACC,gBAAAmB;AAAA,IAAC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AAa,EACb,mBAAmB,EACnB,KAAK,EACL,KAAK,MAAM,EACX,CAAC,GACD,MAAM,6BAA6B,CAAC"}
|
package/dist/icons/index.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ export declare const MaximizeIcon: React.FC<IconProps>;
|
|
|
11
11
|
export declare const MinimizeIcon: React.FC<IconProps>;
|
|
12
12
|
export declare const TableOfContentsIcon: React.FC<IconProps>;
|
|
13
13
|
export declare const BookshelfIcon: React.FC<IconProps>;
|
|
14
|
+
export declare const DownloadIcon: React.FC<IconProps>;
|
|
14
15
|
export type { IconProps };
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/icons/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,UAAU,SAAS;IAElB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAID,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAgB/C,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAgBhD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAiBhD,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAiB/C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAmB5C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAmB5C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAwBnD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAsB7C,CAAC;AAEF,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/icons/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,UAAU,SAAS;IAElB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAID,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAgB/C,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAgBhD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAiBhD,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAiB/C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAmB5C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAmB5C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAwBnD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAsB7C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAkB5C,CAAC;AAEF,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { PageRangesDownloadContext, SemanticPageInfo } from "../download/types";
|
|
3
|
+
import "./DownloadDropdown.css";
|
|
4
|
+
export interface DownloadDropdownProps {
|
|
5
|
+
onDownloadSefer?: () => Promise<{
|
|
6
|
+
ext: string;
|
|
7
|
+
data: string;
|
|
8
|
+
} | null>;
|
|
9
|
+
onDownloadPageRange?: (pages: number[], semanticPages: SemanticPageInfo[], context?: PageRangesDownloadContext) => Promise<{
|
|
10
|
+
ext: string;
|
|
11
|
+
data: string;
|
|
12
|
+
} | null>;
|
|
13
|
+
downloadContext?: PageRangesDownloadContext;
|
|
14
|
+
ariaLabel?: string;
|
|
15
|
+
entireBookFilename?: string;
|
|
16
|
+
rangeFilename?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const DownloadDropdown: React.FC<DownloadDropdownProps>;
|
|
20
|
+
export { DownloadDropdown };
|
|
21
|
+
//# sourceMappingURL=DownloadDropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadDropdown.d.ts","sourceRoot":"","sources":["../../src/toolbar/DownloadDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrF,OAAO,wBAAwB,CAAC;AAsChC,MAAM,WAAW,qBAAqB;IAErC,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAEtE,mBAAmB,CAAC,EAAE,CACrB,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,EAAE,gBAAgB,EAAE,EACjC,OAAO,CAAC,EAAE,yBAAyB,KAC/B,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAEnD,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAE5C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAsMrD,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirstPageButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/FirstPageButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FirstPageButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/FirstPageButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,UAAU,oBAAoB;IAE7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqBnD,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,YAAY,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LastPageButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/LastPageButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LastPageButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/LastPageButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,UAAU,mBAAmB;IAE5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAqBjD,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/NextButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NextButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/NextButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,UAAU,eAAe;IAExB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqBzC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageIndicator.d.ts","sourceRoot":"","sources":["../../src/toolbar/PageIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,KAAK,iBAAiB,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9C,UAAU,kBAAkB;IAO3B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IAEzB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"PageIndicator.d.ts","sourceRoot":"","sources":["../../src/toolbar/PageIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,KAAK,iBAAiB,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9C,UAAU,kBAAkB;IAO3B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IAEzB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAiL/C,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrevButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/PrevButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PrevButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/PrevButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,UAAU,eAAe;IAExB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqBzC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TocButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/TocButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TocButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/TocButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,UAAU,cAAc;IAEvB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAKD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA+BvC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import type { Command, CommandOptions } from "../commands/types";
|
|
3
3
|
import type { FlipBookHandle, PageSemantics } from "../FlipBook";
|
|
4
|
+
import { type Locale } from "../i18n";
|
|
4
5
|
import "./Toolbar.css";
|
|
5
6
|
interface ToolbarProps {
|
|
6
7
|
flipBookRef: React.RefObject<FlipBookHandle | null>;
|
|
7
8
|
direction?: "ltr" | "rtl";
|
|
9
|
+
locale?: Locale;
|
|
8
10
|
pageSemantics?: PageSemantics;
|
|
9
11
|
className?: string;
|
|
10
12
|
children: React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAsC,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,eAAe,CAAC;AAEvB,UAAU,YAAY;IAErB,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAEpD,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAE1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IAErB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAChD;AAOD,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA6EnC,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import type { FlipBookHandle, PageSemantics } from "../FlipBook";
|
|
3
|
+
import type { Locale } from "../i18n";
|
|
3
4
|
interface ToolbarContextValue {
|
|
4
5
|
flipBookRef: React.RefObject<FlipBookHandle | null>;
|
|
5
6
|
direction: "ltr" | "rtl";
|
|
7
|
+
locale: Locale;
|
|
6
8
|
pageSemantics?: PageSemantics;
|
|
7
9
|
currentPage: number;
|
|
8
10
|
totalPages: number;
|
|
11
|
+
of: string | number;
|
|
9
12
|
isFirstPage: boolean;
|
|
10
13
|
isLastPage: boolean;
|
|
11
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarContext.d.ts","sourceRoot":"","sources":["../../src/toolbar/ToolbarContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ToolbarContext.d.ts","sourceRoot":"","sources":["../../src/toolbar/ToolbarContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,UAAU,mBAAmB;IAC5B,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;IAEzB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IAEnB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,cAAc,2CAAkD,CAAC;AAEvE,wBAAgB,UAAU,IAAI,mBAAmB,CAMhD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
|
package/dist/toolbar/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export type { Command, CommandOptions, HotkeyBinding } from "../commands";
|
|
2
2
|
export { DEFAULT_HOTKEYS, defaultCommands, useCommands } from "../commands";
|
|
3
|
+
export type { DownloadResult, PageRangesDownloadContext, PageRangesDownloadHandler, SeferDownloadHandler, SemanticPageInfo, } from "../download/types";
|
|
3
4
|
export type { IconProps } from "../icons";
|
|
4
|
-
export { BookshelfIcon, ChevronFirstIcon, ChevronLastIcon, ChevronLeftIcon, ChevronRightIcon, MaximizeIcon, MinimizeIcon, TableOfContentsIcon, } from "../icons";
|
|
5
|
+
export { BookshelfIcon, ChevronFirstIcon, ChevronLastIcon, ChevronLeftIcon, ChevronRightIcon, DownloadIcon, MaximizeIcon, MinimizeIcon, TableOfContentsIcon, } from "../icons";
|
|
5
6
|
export type { ActionButtonProps } from "./ActionButton";
|
|
6
7
|
export { ActionButton } from "./ActionButton";
|
|
8
|
+
export type { DownloadDropdownProps } from "./DownloadDropdown";
|
|
9
|
+
export { DownloadDropdown } from "./DownloadDropdown";
|
|
7
10
|
export type { FirstPageButtonProps } from "./FirstPageButton";
|
|
8
11
|
export { FirstPageButton } from "./FirstPageButton";
|
|
9
12
|
export type { FullscreenButtonProps } from "./FullscreenButton";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toolbar/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5E,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EACN,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACnB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toolbar/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE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