@prose-reader/react-reader 1.185.0 → 1.186.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -571,7 +571,7 @@ const We = O.Root, je = O.ValueText, H = () => {
|
|
|
571
571
|
)
|
|
572
572
|
] });
|
|
573
573
|
}
|
|
574
|
-
), Xe = "@prose-reader/react-reader", Je = "1.
|
|
574
|
+
), Xe = "@prose-reader/react-reader", Je = "1.185.0", Ze = C.forwardRef(function(n, r) {
|
|
575
575
|
return /* @__PURE__ */ t(p, { variant: "ghost", "aria-label": "Close", ref: r, ...n, children: n.children ?? /* @__PURE__ */ t(Ie, {}) });
|
|
576
576
|
}), X = C.forwardRef(function(n, r) {
|
|
577
577
|
const {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(f,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),require("react-icons/rx"),require("react-icons/hi"),require("rc-slider"),require("rc-slider/assets/index.css"),require("react-icons/io"),require("react-icons/md")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","reactjrx","rxjs","@chakra-ui/react","react-icons/lu","react-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],o):(f=typeof globalThis<"u"?globalThis:f||self,o(f["prose-react-reader"]={},f.jsxRuntime,f.React,f.reactjrx,f.rxjs,f.react,f.lu,f.rx,f.hi,f.RcSlider,null,f.io,f.md))})(this,function(f,o,d,p,k,n,x,w,_,V,xe,m,L){"use strict";function j(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(s,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return s.default=e,Object.freeze(s)}const C=j(d),D=d.createContext({reader:void 0,quickMenuSignal:p.signal({default:!1})}),U=d.memo(({children:e,reader:s,quickMenuOpen:r,onQuickMenuOpenChange:l})=>{const[,t]=p.useSignal({default:r}),i=p.useLiveRef(l),a=d.useMemo(()=>({quickMenuSignal:t,reader:s}),[t,s]);return d.useEffect(()=>{t.setValue(r)},[r,t]),p.useSubscribe(()=>t.subject.pipe(k.tap(i.current)),[t,i]),o.jsx(D.Provider,{value:a,children:e})}),I=()=>{const{reader:e}=d.useContext(D);return e},v=()=>{const e=I();return p.useObserve(()=>e?k.combineLatest([e.pagination.state$,e.context.state$]).pipe(k.map(([s,r])=>{var t;const l=(t=r.manifest)==null?void 0:t.spineItems.every(i=>{var a;return(a=i.mediaType)==null?void 0:a.startsWith("image/")});return{...s,hasChapters:!r.isFullyPrePaginated&&!l}})):k.NEVER,[e])},Y=()=>{const e=v(),s=Math.floor(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),r=s>0?s:1;return(e==null?void 0:e.percentageEstimateOfBook)===void 0?null:o.jsx(n.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:o.jsxs(n.Text,{fontSize:"sm",children:[r," %"]})})},Q=()=>{const[e,s]=d.useState(new Date);return d.useEffect(()=>{const r=setInterval(()=>{s(new Date)},6e4);return()=>clearInterval(r)},[]),e},G=e=>{const s=Q();return o.jsx(n.Text,{fontSize:"xs",...e,children:s.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},y=()=>{const{quickMenuSignal:e}=d.useContext(D);return[p.useSignalValue(e),e.setValue,e]},K=()=>{const[e]=y();return o.jsx(n.Box,{position:"absolute",left:0,bottom:0,p:2,color:e?void 0:"colorPalette.contrast",children:o.jsx(G,{})})},X=C.forwardRef(function(s,r){const{showArrow:l,children:t,portalled:i=!0,content:a,portalRef:h,...g}=s;return o.jsxs(n.Popover.Root,{...g,positioning:{...g.positioning,gutter:4},children:[o.jsx(n.Popover.Trigger,{asChild:!0,children:t}),o.jsx(n.Portal,{disabled:!i,container:h,children:o.jsx(n.Popover.Positioner,{children:o.jsxs(n.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:r,children:[l&&o.jsx(n.Popover.Arrow,{children:o.jsx(n.Popover.ArrowTip,{})}),a]})})})]})}),J=C.forwardRef(function(s,r){const{children:l,...t}=s;return o.jsx(X,{content:l,...t,ref:r,children:o.jsx(n.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:o.jsx(_.HiOutlineInformationCircle,{})})})}),Z=C.forwardRef(function(s,r){return o.jsx(n.Progress.Track,{...s,ref:r,children:o.jsx(n.Progress.Range,{})})});C.forwardRef(function(s,r){const{children:l,info:t,...i}=s;return o.jsxs(n.Progress.Label,{...i,ref:r,children:[l,t&&o.jsx(J,{children:t})]})});const R=n.Progress.Root,ee=n.Progress.ValueText,B=()=>{const e=v(),s=(e==null?void 0:e.numberOfTotalPages)===1,r=((e==null?void 0:e.beginNumberOfPagesInSpineItem)??0)>1,l=((e==null?void 0:e.endNumberOfPagesInSpineItem)??0)>1,t=(e!=null&&e.hasChapters?e==null?void 0:e.beginPageIndexInSpineItem:e==null?void 0:e.beginAbsolutePageIndex)??0,i=(e!=null&&e.hasChapters?e==null?void 0:e.endPageIndexInSpineItem:e==null?void 0:e.endAbsolutePageIndex)??0,[a=0,h=0]=[t,i].sort((b,u)=>b-u),g=(e==null?void 0:e.beginPageIndexInSpineItem)!==(e==null?void 0:e.endPageIndexInSpineItem)||(e==null?void 0:e.beginSpineItemIndex)!==(e==null?void 0:e.endSpineItemIndex),c=e!=null&&e.hasChapters?e==null?void 0:e.beginNumberOfPagesInSpineItem:e==null?void 0:e.numberOfTotalPages;return{hasOnlyOnePage:s,beginPageIndex:t,endPageIndex:i,isBeginWithinChapter:r,isEndWithinChapter:l,beginAndEndAreDifferent:g,totalApproximatePages:c,leftPageIndex:a,rightPageIndex:h}},oe=()=>{const e=v(),{hasOnlyOnePage:s,leftPageIndex:r,rightPageIndex:l,totalApproximatePages:t,beginAndEndAreDifferent:i}=B(),a=Math.round(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),h=c=>c!=null&&c.subChapter?`${c.title} / ${h(c.subChapter)}`:(c==null?void 0:c.title)||"",g=h(e==null?void 0:e.beginChapterInfo);return o.jsxs(n.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[o.jsx(R,{value:a,size:"xs",width:150,children:o.jsxs(n.HStack,{justifyContent:"space-between",children:[o.jsx(Z,{width:110}),o.jsx(ee,{children:`${a}%`})]})}),o.jsx(n.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:g?`Chapter: ${g}`:" "}),!s&&o.jsxs(n.HStack,{children:[o.jsx(n.Text,{fontSize:"xs",children:i?`${r+1} - ${l+1} of ${t}`:`${r+1} of ${t}`}),!!(e!=null&&e.hasChapters)&&o.jsxs(o.Fragment,{children:[o.jsx(n.Text,{children:"-"}),o.jsxs(n.Text,{fontSize:"xs",children:["(",((e==null?void 0:e.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},z=d.memo(({children:e,position:s,...r})=>o.jsx(n.Presence,{display:"flex",flexDirection:"row",width:"100%",position:"absolute",...s==="bottom"?{bottom:0}:{top:0},animationName:s==="bottom"?{_open:"slide-from-bottom, fade-in",_closed:"slide-to-bottom, fade-out"}:{_open:"slide-from-top, fade-in",_closed:"slide-to-top, fade-out"},animationDuration:"moderate",bgColor:"bg.panel",alignItems:"center",justifyContent:"center",shadow:"md",p:4,...r,children:e})),ne=n.chakra(V),se=d.memo(e=>o.jsx(n.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:o.jsx(ne,{keyboard:!1,style:{padding:0},css:{"& > .rc-slider-handle:focus-visible":{boxShadow:"0 0 0 2px var(--color-solid) !important"},"& > .rc-slider-handle:active":{boxShadow:"0 0 5px var(--color-solid) !important"},"& > .rc-slider-handle.rc-slider-handle-dragging":{boxShadow:"0 0 0 3px var(--color-solid) !important"}},styles:{rail:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--bg-emphasized)"},track:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--color-solid)"},handle:{width:"24px",height:"24px",top:"50%",borderColor:"var(--color-solid)",transform:`translate(${e.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...e})})),te=()=>{const e=v(),s=e==null?void 0:e.isUsingSpread,{beginPageIndex:r,totalApproximatePages:l=0}=B(),t=s?Math.floor((r||0)/2):r,[i,a]=p.useSignal({default:t||0}),h=0,g=Math.max(0,s?Math.floor((l-1)/2):l-1);return d.useEffect(()=>{a.setValue(t||0)},[t,a]),{value:i,valueSignal:a,min:h,max:g}},re=()=>{const e=I(),s=v(),{manifest:r}=p.useObserve(()=>e==null?void 0:e.context.state$,[])??{},l=(r==null?void 0:r.readingDirection)==="rtl",t=s==null?void 0:s.isUsingSpread,{totalApproximatePages:i=0,isBeginWithinChapter:a}=B(),h=1,g=a,{value:c,valueSignal:b,min:u,max:S}=te(),O=d.useCallback(P=>{const[T=0]=Array.isArray(P)?P:[P];b.setValue(T);const W=t?Math.floor(T)*2:Math.floor(T);g?e==null||e.navigation.goToPageOfSpineItem({pageIndex:W,spineItemId:e.pagination.getState().beginSpineItemIndex??0,animation:!1}):e==null||e.navigation.goToAbsolutePageIndex({absolutePageIndex:W,animation:!1})},[e,t,b,g]);return p.useSubscribe(()=>e==null?void 0:e.navigation.throttleLock({duration:100,trigger:b.subject}),[e,b]),i===1||t&&i===2?null:o.jsx(se,{value:[c],max:S,min:u,reverse:l,step:h,onChange:O})},le=d.memo(({open:e,onTableOfContentsClick:s,onHelpClick:r})=>{const l=I(),t=p.useObserve(()=>l==null?void 0:l.navigation.state$,[l]),i=p.useObserve(()=>l==null?void 0:l.settings.values$,[l]),a=(i==null?void 0:i.computedPageTurnDirection)==="vertical",[h,g]=d.useState(!0);return o.jsx(z,{present:e,position:"bottom",children:o.jsxs(n.Stack,{flex:1,children:[o.jsxs(n.HStack,{flex:1,alignItems:"center",justifyContent:"center",children:[o.jsx(n.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>l==null?void 0:l.navigation.goToLeftOrTopSpineItem(),disabled:!(t!=null&&t.canGoLeftSpineItem)&&!(t!=null&&t.canGoTopSpineItem),children:a?o.jsx(w.RxDoubleArrowUp,{}):o.jsx(w.RxDoubleArrowLeft,{})}),o.jsxs(n.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"visible",px:4,children:[o.jsx(oe,{}),o.jsx(n.Box,{height:5,maxW:300,width:"100%",overflow:"visible",children:o.jsx(re,{})})]}),o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(t!=null&&t.canGoRightSpineItem)&&!(t!=null&&t.canGoBottomSpineItem),onClick:()=>{l==null||l.navigation.goToRightOrBottomSpineItem()},children:a?o.jsx(w.RxDoubleArrowDown,{}):o.jsx(w.RxDoubleArrowRight,{})})]}),o.jsx(n.HStack,{alignItems:"center",justifyContent:"center",children:o.jsxs(n.Collapsible.Root,{open:h,flex:1,onOpenChange:({open:c})=>{g(c)},children:[o.jsx(n.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:o.jsx(x.LuChevronDown,{style:{transform:h?"rotate(0deg)":"rotate(180deg)"}})}),o.jsxs(n.Collapsible.Content,{display:"flex",justifyContent:"center",gap:2,children:[o.jsx(n.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:r,children:o.jsx(x.LuCircleHelp,{})}),o.jsx(n.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:s,children:o.jsx(x.LuTableOfContents,{})})]})]})})]})})}),ie=()=>{const[e,s]=d.useState(!1),r=d.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{s(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{s(!0)}),[]);return d.useEffect(()=>{function l(){s(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:e,onToggleFullscreenClick:r}},ce=({open:e,onBackClick:s,onMoreClick:r})=>{const l=I(),t=p.useObserve(()=>l==null?void 0:l.context.manifest$,[l]),{isFullscreen:i,onToggleFullscreenClick:a}=ie();return o.jsxs(z,{present:e,position:"top",height:"80px",justifyContent:"space-between",children:[o.jsx(n.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:s,children:o.jsx(m.IoIosArrowBack,{})}),o.jsx(n.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:o.jsx(n.Text,{truncate:!0,maxWidth:"100%",children:t==null?void 0:t.title})}),o.jsxs(n.HStack,{children:[o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:r,children:o.jsx(m.IoMdMore,{})}),o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:a,children:i?o.jsx(L.MdFullscreenExit,{}):o.jsx(L.MdFullscreen,{})})]})]})},ae=d.memo(({onBackClick:e,onMoreClick:s,onTableOfContentsClick:r,onHelpClick:l})=>{const[t]=y();return o.jsxs(o.Fragment,{children:[o.jsx(ce,{open:t,onBackClick:e,onMoreClick:s}),o.jsx(le,{open:t,onTableOfContentsClick:r,onHelpClick:l})]})}),de="@prose-reader/react-reader",he="1.184.0",ge=C.forwardRef(function(s,r){return o.jsx(n.IconButton,{variant:"ghost","aria-label":"Close",ref:r,...s,children:s.children??o.jsx(x.LuX,{})})}),A=C.forwardRef(function(s,r){const{children:l,portalled:t=!0,portalRef:i,backdrop:a=!0,...h}=s;return o.jsxs(n.Portal,{disabled:!t,container:i,children:[a&&o.jsx(n.Dialog.Backdrop,{}),o.jsx(n.Dialog.Positioner,{children:o.jsx(n.Dialog.Content,{ref:r,...h,asChild:!1,children:l})})]})}),M=C.forwardRef(function(s,r){return o.jsx(n.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...s,asChild:!0,children:o.jsx(ge,{size:"sm",ref:r,children:s.children})})}),E=n.Dialog.Root,F=n.Dialog.Footer,H=n.Dialog.Header,q=n.Dialog.Body;n.Dialog.Backdrop;const $=n.Dialog.Title;n.Dialog.Description,n.Dialog.Trigger;const N=n.Dialog.ActionTrigger,fe=d.memo(({open:e,setOpen:s})=>o.jsx(E,{lazyMount:!0,placement:"center",open:e,onOpenChange:r=>s(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(A,{children:[o.jsx(H,{children:o.jsx($,{children:"Help"})}),o.jsxs(q,{overflowY:"auto",flex:1,children:[o.jsx(n.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),o.jsxs(n.HStack,{mb:1,children:[o.jsx(n.Kbd,{children:o.jsx(x.LuArrowBigRight,{})})," ",o.jsx(n.Text,{children:"Navigate to right page"})]}),o.jsxs(n.HStack,{mb:1,children:[o.jsx(n.Kbd,{children:o.jsx(x.LuArrowBigLeft,{})})," ",o.jsx(n.Text,{children:"Navigate to left page"})]}),o.jsx(n.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),o.jsxs(n.Text,{children:[de," version: ",he]})]}),o.jsx(F,{children:o.jsx(N,{asChild:!0,children:o.jsx(n.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(M,{})]})})),ue=d.memo(({onNavigate:e})=>{const s=I(),{manifest:r,assumedRenditionLayout:l}=p.useObserve(()=>s==null?void 0:s.context.state$,[s])??{},{nav:t}=r??{},i=v();t!=null&&t.toc;const{beginSpineItemIndex:a,beginPageIndexInSpineItem:h}=i??{},g=(l==="reflowable"?h:a)||0;console.log({assumedRenditionLayout:l,currentSpineItemOrChapterPageIndex:g});let c=i==null?void 0:i.beginChapterInfo;for(;c!=null&&c.subChapter;)c=c==null?void 0:c.subChapter;const b=(u,S,O)=>o.jsxs(d.Fragment,{children:[o.jsx(n.List.Item,{pl:4*(O+1),style:{display:"flex",alignItems:"center"},children:o.jsxs(n.Link,{onClick:()=>{e(),s==null||s.navigation.goToUrl(u.href)},href:"#",children:[(c==null?void 0:c.path)===u.path&&o.jsx(n.List.Indicator,{asChild:!0,children:o.jsx(x.LuCircleCheck,{})}),(c==null?void 0:c.path)!==u.path&&o.jsx(n.List.Indicator,{asChild:!0,visibility:"hidden",children:o.jsx(x.LuCircleCheck,{})}),o.jsxs(n.Stack,{gap:0,children:[o.jsx(n.Text,{fontSize:"md",children:u.title||u.path}),(c==null?void 0:c.path)===u.path&&o.jsx(n.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${g+1}`})]})]})}),u.contents.length>0&&o.jsx(n.List.Root,{as:"div",gap:2,children:u.contents.map((P,T)=>b(P,T,O+1))})]},S);return o.jsx(n.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:t==null?void 0:t.toc.map((u,S)=>b(u,S,0))})}),pe=d.memo(({open:e,setOpen:s,onNavigate:r})=>o.jsx(E,{lazyMount:!0,placement:"center",open:e,onOpenChange:l=>s(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(A,{children:[o.jsx(H,{children:o.jsx($,{children:"Table of Contents"})}),o.jsx(q,{overflowY:"auto",flex:1,children:o.jsx(ue,{onNavigate:r})}),o.jsx(F,{children:o.jsx(N,{asChild:!0,children:o.jsx(n.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(M,{})]})})),be=({enableFloatingTime:e=!0,enableFloatingProgress:s=!0,...r})=>{const[l,t]=d.useState(!1),[i,a]=d.useState(!1),[h,g]=y();return o.jsxs(o.Fragment,{children:[s&&o.jsx(n.Presence,{present:!h,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:o.jsx(Y,{})}),o.jsx(ae,{...r,onTableOfContentsClick:()=>t(!0),onHelpClick:()=>a(!0)}),o.jsx(fe,{open:i,setOpen:a}),o.jsx(pe,{open:l,setOpen:t,onNavigate:()=>{t(!1),g(!1)}}),o.jsx(n.Presence,{present:e||h,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:o.jsx(K,{})})]})};f.ReactReader=be,f.ReactReaderProvider=U,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(f,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),require("react-icons/rx"),require("react-icons/hi"),require("rc-slider"),require("rc-slider/assets/index.css"),require("react-icons/io"),require("react-icons/md")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","reactjrx","rxjs","@chakra-ui/react","react-icons/lu","react-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],o):(f=typeof globalThis<"u"?globalThis:f||self,o(f["prose-react-reader"]={},f.jsxRuntime,f.React,f.reactjrx,f.rxjs,f.react,f.lu,f.rx,f.hi,f.RcSlider,null,f.io,f.md))})(this,function(f,o,d,p,k,n,x,w,_,V,xe,m,L){"use strict";function j(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(s,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return s.default=e,Object.freeze(s)}const C=j(d),D=d.createContext({reader:void 0,quickMenuSignal:p.signal({default:!1})}),U=d.memo(({children:e,reader:s,quickMenuOpen:r,onQuickMenuOpenChange:l})=>{const[,t]=p.useSignal({default:r}),i=p.useLiveRef(l),a=d.useMemo(()=>({quickMenuSignal:t,reader:s}),[t,s]);return d.useEffect(()=>{t.setValue(r)},[r,t]),p.useSubscribe(()=>t.subject.pipe(k.tap(i.current)),[t,i]),o.jsx(D.Provider,{value:a,children:e})}),I=()=>{const{reader:e}=d.useContext(D);return e},v=()=>{const e=I();return p.useObserve(()=>e?k.combineLatest([e.pagination.state$,e.context.state$]).pipe(k.map(([s,r])=>{var t;const l=(t=r.manifest)==null?void 0:t.spineItems.every(i=>{var a;return(a=i.mediaType)==null?void 0:a.startsWith("image/")});return{...s,hasChapters:!r.isFullyPrePaginated&&!l}})):k.NEVER,[e])},Y=()=>{const e=v(),s=Math.floor(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),r=s>0?s:1;return(e==null?void 0:e.percentageEstimateOfBook)===void 0?null:o.jsx(n.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:o.jsxs(n.Text,{fontSize:"sm",children:[r," %"]})})},Q=()=>{const[e,s]=d.useState(new Date);return d.useEffect(()=>{const r=setInterval(()=>{s(new Date)},6e4);return()=>clearInterval(r)},[]),e},G=e=>{const s=Q();return o.jsx(n.Text,{fontSize:"xs",...e,children:s.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},y=()=>{const{quickMenuSignal:e}=d.useContext(D);return[p.useSignalValue(e),e.setValue,e]},K=()=>{const[e]=y();return o.jsx(n.Box,{position:"absolute",left:0,bottom:0,p:2,color:e?void 0:"colorPalette.contrast",children:o.jsx(G,{})})},X=C.forwardRef(function(s,r){const{showArrow:l,children:t,portalled:i=!0,content:a,portalRef:h,...g}=s;return o.jsxs(n.Popover.Root,{...g,positioning:{...g.positioning,gutter:4},children:[o.jsx(n.Popover.Trigger,{asChild:!0,children:t}),o.jsx(n.Portal,{disabled:!i,container:h,children:o.jsx(n.Popover.Positioner,{children:o.jsxs(n.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:r,children:[l&&o.jsx(n.Popover.Arrow,{children:o.jsx(n.Popover.ArrowTip,{})}),a]})})})]})}),J=C.forwardRef(function(s,r){const{children:l,...t}=s;return o.jsx(X,{content:l,...t,ref:r,children:o.jsx(n.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:o.jsx(_.HiOutlineInformationCircle,{})})})}),Z=C.forwardRef(function(s,r){return o.jsx(n.Progress.Track,{...s,ref:r,children:o.jsx(n.Progress.Range,{})})});C.forwardRef(function(s,r){const{children:l,info:t,...i}=s;return o.jsxs(n.Progress.Label,{...i,ref:r,children:[l,t&&o.jsx(J,{children:t})]})});const R=n.Progress.Root,ee=n.Progress.ValueText,B=()=>{const e=v(),s=(e==null?void 0:e.numberOfTotalPages)===1,r=((e==null?void 0:e.beginNumberOfPagesInSpineItem)??0)>1,l=((e==null?void 0:e.endNumberOfPagesInSpineItem)??0)>1,t=(e!=null&&e.hasChapters?e==null?void 0:e.beginPageIndexInSpineItem:e==null?void 0:e.beginAbsolutePageIndex)??0,i=(e!=null&&e.hasChapters?e==null?void 0:e.endPageIndexInSpineItem:e==null?void 0:e.endAbsolutePageIndex)??0,[a=0,h=0]=[t,i].sort((b,u)=>b-u),g=(e==null?void 0:e.beginPageIndexInSpineItem)!==(e==null?void 0:e.endPageIndexInSpineItem)||(e==null?void 0:e.beginSpineItemIndex)!==(e==null?void 0:e.endSpineItemIndex),c=e!=null&&e.hasChapters?e==null?void 0:e.beginNumberOfPagesInSpineItem:e==null?void 0:e.numberOfTotalPages;return{hasOnlyOnePage:s,beginPageIndex:t,endPageIndex:i,isBeginWithinChapter:r,isEndWithinChapter:l,beginAndEndAreDifferent:g,totalApproximatePages:c,leftPageIndex:a,rightPageIndex:h}},oe=()=>{const e=v(),{hasOnlyOnePage:s,leftPageIndex:r,rightPageIndex:l,totalApproximatePages:t,beginAndEndAreDifferent:i}=B(),a=Math.round(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),h=c=>c!=null&&c.subChapter?`${c.title} / ${h(c.subChapter)}`:(c==null?void 0:c.title)||"",g=h(e==null?void 0:e.beginChapterInfo);return o.jsxs(n.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[o.jsx(R,{value:a,size:"xs",width:150,children:o.jsxs(n.HStack,{justifyContent:"space-between",children:[o.jsx(Z,{width:110}),o.jsx(ee,{children:`${a}%`})]})}),o.jsx(n.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:g?`Chapter: ${g}`:" "}),!s&&o.jsxs(n.HStack,{children:[o.jsx(n.Text,{fontSize:"xs",children:i?`${r+1} - ${l+1} of ${t}`:`${r+1} of ${t}`}),!!(e!=null&&e.hasChapters)&&o.jsxs(o.Fragment,{children:[o.jsx(n.Text,{children:"-"}),o.jsxs(n.Text,{fontSize:"xs",children:["(",((e==null?void 0:e.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},z=d.memo(({children:e,position:s,...r})=>o.jsx(n.Presence,{display:"flex",flexDirection:"row",width:"100%",position:"absolute",...s==="bottom"?{bottom:0}:{top:0},animationName:s==="bottom"?{_open:"slide-from-bottom, fade-in",_closed:"slide-to-bottom, fade-out"}:{_open:"slide-from-top, fade-in",_closed:"slide-to-top, fade-out"},animationDuration:"moderate",bgColor:"bg.panel",alignItems:"center",justifyContent:"center",shadow:"md",p:4,...r,children:e})),ne=n.chakra(V),se=d.memo(e=>o.jsx(n.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:o.jsx(ne,{keyboard:!1,style:{padding:0},css:{"& > .rc-slider-handle:focus-visible":{boxShadow:"0 0 0 2px var(--color-solid) !important"},"& > .rc-slider-handle:active":{boxShadow:"0 0 5px var(--color-solid) !important"},"& > .rc-slider-handle.rc-slider-handle-dragging":{boxShadow:"0 0 0 3px var(--color-solid) !important"}},styles:{rail:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--bg-emphasized)"},track:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--color-solid)"},handle:{width:"24px",height:"24px",top:"50%",borderColor:"var(--color-solid)",transform:`translate(${e.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...e})})),te=()=>{const e=v(),s=e==null?void 0:e.isUsingSpread,{beginPageIndex:r,totalApproximatePages:l=0}=B(),t=s?Math.floor((r||0)/2):r,[i,a]=p.useSignal({default:t||0}),h=0,g=Math.max(0,s?Math.floor((l-1)/2):l-1);return d.useEffect(()=>{a.setValue(t||0)},[t,a]),{value:i,valueSignal:a,min:h,max:g}},re=()=>{const e=I(),s=v(),{manifest:r}=p.useObserve(()=>e==null?void 0:e.context.state$,[])??{},l=(r==null?void 0:r.readingDirection)==="rtl",t=s==null?void 0:s.isUsingSpread,{totalApproximatePages:i=0,isBeginWithinChapter:a}=B(),h=1,g=a,{value:c,valueSignal:b,min:u,max:S}=te(),O=d.useCallback(P=>{const[T=0]=Array.isArray(P)?P:[P];b.setValue(T);const W=t?Math.floor(T)*2:Math.floor(T);g?e==null||e.navigation.goToPageOfSpineItem({pageIndex:W,spineItemId:e.pagination.getState().beginSpineItemIndex??0,animation:!1}):e==null||e.navigation.goToAbsolutePageIndex({absolutePageIndex:W,animation:!1})},[e,t,b,g]);return p.useSubscribe(()=>e==null?void 0:e.navigation.throttleLock({duration:100,trigger:b.subject}),[e,b]),i===1||t&&i===2?null:o.jsx(se,{value:[c],max:S,min:u,reverse:l,step:h,onChange:O})},le=d.memo(({open:e,onTableOfContentsClick:s,onHelpClick:r})=>{const l=I(),t=p.useObserve(()=>l==null?void 0:l.navigation.state$,[l]),i=p.useObserve(()=>l==null?void 0:l.settings.values$,[l]),a=(i==null?void 0:i.computedPageTurnDirection)==="vertical",[h,g]=d.useState(!0);return o.jsx(z,{present:e,position:"bottom",children:o.jsxs(n.Stack,{flex:1,children:[o.jsxs(n.HStack,{flex:1,alignItems:"center",justifyContent:"center",children:[o.jsx(n.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>l==null?void 0:l.navigation.goToLeftOrTopSpineItem(),disabled:!(t!=null&&t.canGoLeftSpineItem)&&!(t!=null&&t.canGoTopSpineItem),children:a?o.jsx(w.RxDoubleArrowUp,{}):o.jsx(w.RxDoubleArrowLeft,{})}),o.jsxs(n.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"visible",px:4,children:[o.jsx(oe,{}),o.jsx(n.Box,{height:5,maxW:300,width:"100%",overflow:"visible",children:o.jsx(re,{})})]}),o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(t!=null&&t.canGoRightSpineItem)&&!(t!=null&&t.canGoBottomSpineItem),onClick:()=>{l==null||l.navigation.goToRightOrBottomSpineItem()},children:a?o.jsx(w.RxDoubleArrowDown,{}):o.jsx(w.RxDoubleArrowRight,{})})]}),o.jsx(n.HStack,{alignItems:"center",justifyContent:"center",children:o.jsxs(n.Collapsible.Root,{open:h,flex:1,onOpenChange:({open:c})=>{g(c)},children:[o.jsx(n.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:o.jsx(x.LuChevronDown,{style:{transform:h?"rotate(0deg)":"rotate(180deg)"}})}),o.jsxs(n.Collapsible.Content,{display:"flex",justifyContent:"center",gap:2,children:[o.jsx(n.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:r,children:o.jsx(x.LuCircleHelp,{})}),o.jsx(n.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:s,children:o.jsx(x.LuTableOfContents,{})})]})]})})]})})}),ie=()=>{const[e,s]=d.useState(!1),r=d.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{s(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{s(!0)}),[]);return d.useEffect(()=>{function l(){s(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:e,onToggleFullscreenClick:r}},ce=({open:e,onBackClick:s,onMoreClick:r})=>{const l=I(),t=p.useObserve(()=>l==null?void 0:l.context.manifest$,[l]),{isFullscreen:i,onToggleFullscreenClick:a}=ie();return o.jsxs(z,{present:e,position:"top",height:"80px",justifyContent:"space-between",children:[o.jsx(n.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:s,children:o.jsx(m.IoIosArrowBack,{})}),o.jsx(n.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:o.jsx(n.Text,{truncate:!0,maxWidth:"100%",children:t==null?void 0:t.title})}),o.jsxs(n.HStack,{children:[o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:r,children:o.jsx(m.IoMdMore,{})}),o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:a,children:i?o.jsx(L.MdFullscreenExit,{}):o.jsx(L.MdFullscreen,{})})]})]})},ae=d.memo(({onBackClick:e,onMoreClick:s,onTableOfContentsClick:r,onHelpClick:l})=>{const[t]=y();return o.jsxs(o.Fragment,{children:[o.jsx(ce,{open:t,onBackClick:e,onMoreClick:s}),o.jsx(le,{open:t,onTableOfContentsClick:r,onHelpClick:l})]})}),de="@prose-reader/react-reader",he="1.185.0",ge=C.forwardRef(function(s,r){return o.jsx(n.IconButton,{variant:"ghost","aria-label":"Close",ref:r,...s,children:s.children??o.jsx(x.LuX,{})})}),A=C.forwardRef(function(s,r){const{children:l,portalled:t=!0,portalRef:i,backdrop:a=!0,...h}=s;return o.jsxs(n.Portal,{disabled:!t,container:i,children:[a&&o.jsx(n.Dialog.Backdrop,{}),o.jsx(n.Dialog.Positioner,{children:o.jsx(n.Dialog.Content,{ref:r,...h,asChild:!1,children:l})})]})}),M=C.forwardRef(function(s,r){return o.jsx(n.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...s,asChild:!0,children:o.jsx(ge,{size:"sm",ref:r,children:s.children})})}),E=n.Dialog.Root,F=n.Dialog.Footer,H=n.Dialog.Header,q=n.Dialog.Body;n.Dialog.Backdrop;const $=n.Dialog.Title;n.Dialog.Description,n.Dialog.Trigger;const N=n.Dialog.ActionTrigger,fe=d.memo(({open:e,setOpen:s})=>o.jsx(E,{lazyMount:!0,placement:"center",open:e,onOpenChange:r=>s(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(A,{children:[o.jsx(H,{children:o.jsx($,{children:"Help"})}),o.jsxs(q,{overflowY:"auto",flex:1,children:[o.jsx(n.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),o.jsxs(n.HStack,{mb:1,children:[o.jsx(n.Kbd,{children:o.jsx(x.LuArrowBigRight,{})})," ",o.jsx(n.Text,{children:"Navigate to right page"})]}),o.jsxs(n.HStack,{mb:1,children:[o.jsx(n.Kbd,{children:o.jsx(x.LuArrowBigLeft,{})})," ",o.jsx(n.Text,{children:"Navigate to left page"})]}),o.jsx(n.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),o.jsxs(n.Text,{children:[de," version: ",he]})]}),o.jsx(F,{children:o.jsx(N,{asChild:!0,children:o.jsx(n.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(M,{})]})})),ue=d.memo(({onNavigate:e})=>{const s=I(),{manifest:r,assumedRenditionLayout:l}=p.useObserve(()=>s==null?void 0:s.context.state$,[s])??{},{nav:t}=r??{},i=v();t!=null&&t.toc;const{beginSpineItemIndex:a,beginPageIndexInSpineItem:h}=i??{},g=(l==="reflowable"?h:a)||0;console.log({assumedRenditionLayout:l,currentSpineItemOrChapterPageIndex:g});let c=i==null?void 0:i.beginChapterInfo;for(;c!=null&&c.subChapter;)c=c==null?void 0:c.subChapter;const b=(u,S,O)=>o.jsxs(d.Fragment,{children:[o.jsx(n.List.Item,{pl:4*(O+1),style:{display:"flex",alignItems:"center"},children:o.jsxs(n.Link,{onClick:()=>{e(),s==null||s.navigation.goToUrl(u.href)},href:"#",children:[(c==null?void 0:c.path)===u.path&&o.jsx(n.List.Indicator,{asChild:!0,children:o.jsx(x.LuCircleCheck,{})}),(c==null?void 0:c.path)!==u.path&&o.jsx(n.List.Indicator,{asChild:!0,visibility:"hidden",children:o.jsx(x.LuCircleCheck,{})}),o.jsxs(n.Stack,{gap:0,children:[o.jsx(n.Text,{fontSize:"md",children:u.title||u.path}),(c==null?void 0:c.path)===u.path&&o.jsx(n.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${g+1}`})]})]})}),u.contents.length>0&&o.jsx(n.List.Root,{as:"div",gap:2,children:u.contents.map((P,T)=>b(P,T,O+1))})]},S);return o.jsx(n.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:t==null?void 0:t.toc.map((u,S)=>b(u,S,0))})}),pe=d.memo(({open:e,setOpen:s,onNavigate:r})=>o.jsx(E,{lazyMount:!0,placement:"center",open:e,onOpenChange:l=>s(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(A,{children:[o.jsx(H,{children:o.jsx($,{children:"Table of Contents"})}),o.jsx(q,{overflowY:"auto",flex:1,children:o.jsx(ue,{onNavigate:r})}),o.jsx(F,{children:o.jsx(N,{asChild:!0,children:o.jsx(n.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(M,{})]})})),be=({enableFloatingTime:e=!0,enableFloatingProgress:s=!0,...r})=>{const[l,t]=d.useState(!1),[i,a]=d.useState(!1),[h,g]=y();return o.jsxs(o.Fragment,{children:[s&&o.jsx(n.Presence,{present:!h,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:o.jsx(Y,{})}),o.jsx(ae,{...r,onTableOfContentsClick:()=>t(!0),onHelpClick:()=>a(!0)}),o.jsx(fe,{open:i,setOpen:a}),o.jsx(pe,{open:l,setOpen:t,onNavigate:()=>{t(!1),g(!1)}}),o.jsx(n.Presence,{present:e||h,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:o.jsx(K,{})})]})};f.ReactReader=be,f.ReactReaderProvider=U,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.cjs.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prose-reader/react-reader",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.186.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"react-icons": "^5.4.0",
|
|
37
37
|
"reactjrx": "1.x"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "9431beed1cdc856989a058e9c64760b85ebe332a"
|
|
40
40
|
}
|