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AmCC,EAAAA,IAA0B,GAAxFC,EAA2BF,EAA6D,GAAhFG,EAAmBH,EAA6D,IAC/FP,EAAAA,EAAAA,YAAU,WACRS,MACC,CAACtB,EAAcsB,IAYlB,OACE,UAACE,MAAG,CAACC,UAAWC,IAAAA,2B,WACd,SAACC,OAAI,CAACC,SAXgB,SAACC,GACzBA,EAAEC,iBACF,IAAMC,EAAoBxB,EAAc,GACxC,GAAIA,EAAe,CACjB,IAAMyB,EAAOvC,EAAQsC,EAAkBrB,OACvCL,EAAO4B,KAAKD,K,UAOV,SAACE,QAAK,CACJT,UAAWC,IAAAA,YACXhB,MAAOP,EACPgC,SAAU,SAACN,G,OAAMzB,EAAeyB,EAAEO,OAAO1B,QACzC2B,YAAa1C,OAGjB,SAAC6B,MAAG,CAACC,UAAWC,IAAAA,c,UACd,SAACF,MAAG,CAACC,UAAWC,IAAAA,K,SACbnB,EAAc+B,KAAI,SAAC7B,G,OAClB,SAAC8B,EAAAA,EAAI,CAACP,KAAMvC,EAAQgB,EAAKC,OAAyB8B,gBAAgB,E,UAChE,SAAChB,MAAG,CACFiB,IAAKhC,EAAKC,QAAUV,EAAeuB,EAAkB,KACrDE,UAAWiB,IACThB,IAAAA,SACAjB,EAAKC,QAAUV,GAAgB0B,IAAAA,c,SAGhC9B,EAAWa,MARsBA,EAAKC","sources":["webpack://_N_E/./src/components/QuranReader/SidebarNavigation/PageSelection.tsx","webpack://_N_E/./src/components/QuranReader/SidebarNavigation/ScrollableSelection.tsx"],"sourcesContent":["import useTranslation from 'next-translate/useTranslation';\nimport { useSelector } from 'react-redux';\n\nimport ScrollableSelection from './ScrollableSelection';\n\nimport { selectedLastReadPage } from '@/redux/slices/QuranReader/readingTracker';\nimport { selectQuranReaderStyles } from '@/redux/slices/QuranReader/styles';\nimport { getPageNavigationUrl } from '@/utils/navigation';\nimport { getPageIdsByMushaf } from '@/utils/page';\n\nconst PageSelection = () => {\n const { t, lang } = useTranslation('common');\n const { quranFont, mushafLines } = useSelector(selectQuranReaderStyles);\n const pageIds = getPageIdsByMushaf(lang, quranFont, mushafLines);\n const lastReadPage = useSelector(selectedLastReadPage);\n\n return (\n <ScrollableSelection\n items={pageIds}\n getHref={getPageNavigationUrl}\n searchPlaceholder={t('sidebar.search-page')}\n renderItem={(page) => `${t('page')} ${page.label}`}\n isJuz={false}\n selectedItem={Number(lastReadPage)}\n />\n );\n};\n\nexport default PageSelection;\n","import { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\nimport { useRouter } from 'next/router';\n\nimport styles from './SidebarNavigation.module.scss';\n\nimport Link from '@/dls/Link/Link';\nimport { SCROLL_TO_NEAREST_ELEMENT, useScrollToElement } from '@/hooks/useScrollToElement';\nimport SearchQuerySource from '@/types/SearchQuerySource';\nimport { logEmptySearchResults, logTextSearchQuery } from '@/utils/eventLogger';\n\nconst ScrollableSelection = ({\n items,\n searchPlaceholder,\n renderItem,\n getHref,\n isJuz = true,\n selectedItem,\n}) => {\n const [searchQuery, setSearchQuery] = useState('');\n const router = useRouter();\n\n const filteredItems = items.filter(\n (item) =>\n item.value.toString().startsWith(searchQuery) ||\n item.label.toString().startsWith(searchQuery),\n );\n\n useEffect(() => {\n if (!filteredItems.length) {\n logEmptySearchResults({\n query: searchQuery,\n source: isJuz\n ? SearchQuerySource.SidebarNavigationJuzsList\n : SearchQuerySource.SidebarNavigationPagesList,\n });\n } else {\n logTextSearchQuery(\n searchQuery,\n isJuz\n ? SearchQuerySource.SidebarNavigationJuzsList\n : SearchQuerySource.SidebarNavigationPagesList,\n );\n }\n }, [searchQuery, filteredItems, isJuz]);\n\n const [scroll, selectedItemRef] = useScrollToElement<HTMLDivElement>(SCROLL_TO_NEAREST_ELEMENT);\n useEffect(() => {\n scroll();\n }, [selectedItem, scroll]);\n\n // handle when user press `Enter` in input box\n const handleInputSubmit = (e) => {\n e.preventDefault();\n const firstFilteredItem = filteredItems[0];\n if (filteredItems) {\n const href = getHref(firstFilteredItem.value);\n router.push(href);\n }\n };\n\n return (\n <div className={styles.scrollableSectionContainer}>\n <form onSubmit={handleInputSubmit}>\n <input\n className={styles.searchInput}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n placeholder={searchPlaceholder}\n />\n </form>\n <div className={styles.listContainer}>\n <div className={styles.list}>\n {filteredItems.map((item) => (\n <Link href={getHref(item.value)} key={item.value} shouldPrefetch={false}>\n <div\n ref={item.value === selectedItem ? selectedItemRef : null}\n className={classNames(\n styles.listItem,\n item.value === selectedItem && styles.selectedItem,\n )}\n >\n {renderItem(item)}\n </div>\n </Link>\n ))}\n </div>\n </div>\n </div>\n );\n};\n\nexport default ScrollableSelection;\n"],"names":["useTranslation","t","lang","useSelector","selectQuranReaderStyles","quranFont","mushafLines","pageIds","getPageIdsByMushaf","lastReadPage","selectedLastReadPage","ScrollableSelection","items","getHref","getPageNavigationUrl","searchPlaceholder","renderItem","page","label","isJuz","selectedItem","Number","useState","searchQuery","setSearchQuery","router","useRouter","filteredItems","filter","item","value","toString","startsWith","useEffect","length","logTextSearchQuery","SearchQuerySource","logEmptySearchResults","query","source","useScrollToElement","SCROLL_TO_NEAREST_ELEMENT","scroll","selectedItemRef","div","className","styles","form","onSubmit","e","preventDefault","firstFilteredItem","href","push","input","onChange","target","placeholder","map","Link","shouldPrefetch","ref","classNames"],"sourceRoot":""}
|