html-flip-book-react 0.0.0-alpha.16 → 0.0.0-alpha.18
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 +4 -4
- package/dist/FlipBook.d.ts.map +1 -1
- package/dist/flip-book.js.map +1 -1
- package/package.json +2 -2
package/dist/FlipBook.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PageSemantics } from "html-flip-book-vanilla";
|
|
2
2
|
import type React from "react";
|
|
3
|
-
interface FlipBookHandle {
|
|
3
|
+
export interface FlipBookHandle {
|
|
4
4
|
flipNext: () => Promise<void>;
|
|
5
5
|
flipPrev: () => Promise<void>;
|
|
6
6
|
goToPage: (pageIndex: number) => Promise<void>;
|
|
@@ -10,7 +10,7 @@ interface FlipBookHandle {
|
|
|
10
10
|
isFirstPage: () => boolean;
|
|
11
11
|
isLastPage: () => boolean;
|
|
12
12
|
}
|
|
13
|
-
interface
|
|
13
|
+
export interface FlipBookProps {
|
|
14
14
|
pages: React.ReactNode[];
|
|
15
15
|
className: string;
|
|
16
16
|
pageSemantics?: PageSemantics;
|
|
@@ -20,7 +20,7 @@ interface FlipBookWrapperProps {
|
|
|
20
20
|
fastDeltaThreshold?: number;
|
|
21
21
|
leavesBuffer?: number;
|
|
22
22
|
}
|
|
23
|
-
declare const FlipBookReact: React.ForwardRefExoticComponent<
|
|
23
|
+
declare const FlipBookReact: React.ForwardRefExoticComponent<FlipBookProps & React.RefAttributes<FlipBookHandle>>;
|
|
24
24
|
export { FlipBookReact as FlipBook };
|
|
25
|
-
export type {
|
|
25
|
+
export type { PageSemantics };
|
|
26
26
|
//# sourceMappingURL=FlipBook.d.ts.map
|
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,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|
-
{"version":3,"file":"flip-book.js","sources":["../src/FlipBook.tsx"],"sourcesContent":["import { FlipBook as FlipBookBase, type PageSemantics } from \"html-flip-book-vanilla\";\nimport type React from \"react\";\nimport { Children, forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\n\n/**\n * Imperative handle exposed via ref for programmatic control of the FlipBook.\n */\
|
|
1
|
+
{"version":3,"file":"flip-book.js","sources":["../src/FlipBook.tsx"],"sourcesContent":["import { FlipBook as FlipBookBase, type PageSemantics } from \"html-flip-book-vanilla\";\nimport type React from \"react\";\nimport { Children, forwardRef, useEffect, useImperativeHandle, useRef } 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 * 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}\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},\n\t\tref,\n\t) => {\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}),\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\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\n\t\treturn (\n\t\t\t<div className={className}>\n\t\t\t\t{pagesWithKeys.map((page) => (\n\t\t\t\t\t<div key={(page as React.ReactElement).key} className=\"page\">\n\t\t\t\t\t\t{page}\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 };\n"],"names":["FlipBookReact","forwardRef","pages","className","debug","direction","pageSemantics","initialTurnedLeaves","fastDeltaThreshold","leavesBuffer","ref","flipBook","useRef","FlipBookBase","useImperativeHandle","pageIndex","useEffect","currentFlipBook","pagesWithKeys","Children","jsx","page"],"mappings":";;;AA+EA,MAAMA,IAAgBC;AAAA,EACrB,CACC;AAAA,IACC,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,WAAAC,IAAY;AAAA,IACZ,eAAAC,IAAgB;AAAA,IAChB,qBAAAC,IAAsB,CAAA;AAAA,IACtB,oBAAAC;AAAA,IACA,cAAAC;AAAA,EAAA,GAEDC,MACI;AACJ,UAAMC,IAAWC;AAAA,MAChB,IAAIC,EAAa;AAAA,QAChB,eAAAP;AAAA,QACA,YAAYJ,EAAM;AAAA,QAClB,WAAAG;AAAA,QACA,qBAAAE;AAAA,QACA,oBAAAC;AAAA,QACA,cAAAC;AAAA,MAAA,CACA;AAAA,IAAA;AAIF,IAAAK;AAAA,MACCJ;AAAA,MACA,OAAO;AAAA,QACN,UAAU,MAAMC,EAAS,QAAQ,SAAA;AAAA,QACjC,UAAU,MAAMA,EAAS,QAAQ,SAAA;AAAA,QACjC,UAAU,CAACI,MAAsBJ,EAAS,QAAQ,SAASI,CAAS;AAAA,QACpE,YAAY,CAACA,MAAsBJ,EAAS,QAAQ,WAAWI,CAAS;AAAA,QACxE,qBAAqB,MAAMJ,EAAS,QAAQ;AAAA,QAC5C,eAAe,MAAMA,EAAS,QAAQ;AAAA,QACtC,aAAa,MAAMA,EAAS,QAAQ;AAAA,QACpC,YAAY,MAAMA,EAAS,QAAQ;AAAA,MAAA;AAAA,MAEpC,CAAA;AAAA,IAAC,GAGFK,EAAU,MAAM;AACf,YAAMC,IAAkBN,EAAS;AACjC,aAAAM,EAAgB,OAAO,IAAId,CAAS,IAAIC,CAAK,GAGtC,MAAM;AACZ,QAAAa,EAAgB,QAAA;AAAA,MACjB;AAAA,IACD,GAAG,CAACd,GAAWC,CAAK,CAAC;AAGrB,UAAMc,IAAgBC,EAAS,QAAQjB,CAAK;AAE5C,WACC,gBAAAkB,EAAC,OAAA,EAAI,WAAAjB,GACH,UAAAe,EAAc,IAAI,CAACG,MACnB,gBAAAD,EAAC,OAAA,EAA2C,WAAU,QACpD,UAAAC,EAAA,GADSA,EAA4B,GAEvC,CACA,GACF;AAAA,EAEF;AACD;AAEArB,EAAc,cAAc;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-flip-book-react",
|
|
3
3
|
"description": "Flip Book React Component",
|
|
4
|
-
"version": "0.0.0-alpha.
|
|
4
|
+
"version": "0.0.0-alpha.18",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "DoradSoft",
|
|
7
7
|
"main": "./dist/flip-book.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-dom": "^18.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"html-flip-book-vanilla": "0.0.0-alpha.
|
|
41
|
+
"html-flip-book-vanilla": "0.0.0-alpha.18"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/react": "^19.2.8",
|