misraj-mushaf-renderer 1.3.40 → 2.0.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.
Files changed (47) hide show
  1. package/README.md +154 -195
  2. package/dist/adapters/quranhub-entry.d.ts +1 -0
  3. package/dist/adapters/quranhub.d.ts +9 -0
  4. package/dist/adapters/quranhub.test.d.ts +1 -0
  5. package/dist/classnames.d.ts +1 -0
  6. package/dist/components/MushafReader/Provider.d.ts +8 -5
  7. package/dist/components/MushafReader/ReadingView/Line.d.ts +1 -3
  8. package/dist/components/MushafReader/ReadingView/Page.d.ts +1 -3
  9. package/dist/components/MushafReader/contexts/MushafPage/MushafPage.types.d.ts +2 -5
  10. package/dist/components/MushafReader/contexts/MushafPage/MushafPageProvider.d.ts +7 -45
  11. package/dist/components/MushafReader/contexts/Theme/ThemeProvider.d.ts +1 -1
  12. package/dist/components/MushafReader/contexts/Theme/type.d.ts +12 -20
  13. package/dist/components/MushafReader/slots.d.ts +5 -0
  14. package/dist/core/shaping.d.ts +9 -0
  15. package/dist/core/shaping.test.d.ts +1 -0
  16. package/dist/core/types.d.ts +117 -0
  17. package/dist/core/useControllableState.d.ts +8 -0
  18. package/dist/core/useMushafController.d.ts +3 -0
  19. package/dist/core.cjs.js +2 -0
  20. package/dist/core.cjs.js.map +1 -0
  21. package/dist/core.d.ts +3 -0
  22. package/dist/core.es.js +7 -0
  23. package/dist/core.es.js.map +1 -0
  24. package/dist/index.cjs.js +1 -5
  25. package/dist/index.cjs.js.map +1 -1
  26. package/dist/index.d.ts +5 -5
  27. package/dist/index.es.js +37 -2684
  28. package/dist/index.es.js.map +1 -1
  29. package/dist/quranhub-entry.cjs.js +2 -0
  30. package/dist/quranhub-entry.cjs.js.map +1 -0
  31. package/dist/quranhub-entry.es.js +41 -0
  32. package/dist/quranhub-entry.es.js.map +1 -0
  33. package/dist/react-ui.cjs.js +6 -0
  34. package/dist/react-ui.cjs.js.map +1 -0
  35. package/dist/react-ui.d.ts +10 -0
  36. package/dist/react-ui.es.js +1115 -0
  37. package/dist/react-ui.es.js.map +1 -0
  38. package/dist/react-ui.test.d.ts +1 -0
  39. package/dist/styles.css +1 -1
  40. package/dist/test/fixtures.d.ts +5 -0
  41. package/dist/useMushafController-DScB4tp0.js +1736 -0
  42. package/dist/useMushafController-DScB4tp0.js.map +1 -0
  43. package/dist/useMushafController-SdcBr76-.cjs +2 -0
  44. package/dist/useMushafController-SdcBr76-.cjs.map +1 -0
  45. package/package.json +18 -2
  46. package/dist/components/MushafReader/contexts/MushafPage/helpers/fetch-differences.d.ts +0 -3
  47. package/dist/components/MushafReader/contexts/MushafPage/helpers/fetch-verses.d.ts +0 -4
package/README.md CHANGED
@@ -28,198 +28,157 @@ A significant portion of this codebase is derived from the [quran.com-frontend-n
28
28
  - **Easy Integration**: Simple to integrate into any React project with a straightforward provider-consumer pattern.
29
29
  - **Customizable Styling**: Uses a flexible SCSS structure for easy theming and customization.
30
30
 
31
- ## How to Use
32
-
33
- Make sure to import package styles file which includes css styles and fonts assets
34
-
35
- ```tsx
36
- // main.tsx;
37
-
38
- import 'misraj-mushaf-renderer/dist/styles';
39
- ```
40
-
41
- The core of the library is the `MushafReaderProvider` and the `Mushaf` component.
42
-
43
- ### 1. `MushafReaderProvider`
44
-
45
- The `MushafReaderProvider` is a React context provider that fetches and manages the state for a specific Mushaf page. You need to wrap any component that will render Mushaf text with it.
46
-
47
- **Props:**
48
-
49
- - `dataId` (string): A unique identifier for the Mushaf narration you want to render (e.g., `quran-hafs`, `quran-qaloon`).
50
- - `pageNumber` (number): The page number of the Mushaf you wish to display.
51
- - `children`: The child components that will consume the provider's context.
52
- - `initialFontScale` (number, optional): The initial font scale. Defaults to `3`.
53
- - `hasBorder` (boolean, optional): Whether to display the page border. Defaults to `true`.
54
- - `initialIsTwoPagesView` (boolean, optional): The initial state for two-page view. Defaults to `false`.
55
- - `themeProps` (object, optional): An object to override default theme styles. See the "Styling and Customization" section.
56
- - `styleOverride` (object, optional): An object to provide custom CSS classes to components. See the "Styling and Customization" section.
57
-
58
- ### 2. `useMushafContext` Hook
59
-
60
- This hook provides access to the state and actions of the `MushafReaderProvider`. It should be used by components that are children of `MushafReaderProvider`.
61
-
62
- **State:**
63
-
64
- - `fontScale` (number): The current font scale.
65
- - `selectedVerse` (Ayah | null): The currently selected verse.
66
- - `ayat` (MushafPageDataType | null): The raw data for the current page.
67
- - `nextPageAyat` (MushafPageDataType | null): The data for the next page, used in two-page view.
68
- - `error` (Error | null): Any error that occurred while fetching data.
69
- - `pageNumber` (number): The current page number.
70
- - `dataId` (DataId): The current narration identifier.
71
- - `isTwoPagesView` (boolean): Whether the two-page view is currently active.
72
-
73
- **Actions:**
74
-
75
- - `increaseFontScale()`: Increases the font scale.
76
- - `decreaseFontScale()`: Decreases the font scale.
77
- - `setSelectedVerse(verse: Ayah | null)`: Sets the selected verse.
78
-
79
- **Example:**
80
-
81
- ```tsx
82
- import { MushafReaderProvider, useMushafContext, Mushaf } from 'misraj-mushaf-renderer';
83
-
84
- function App() {
85
- return (
86
- <MushafReaderProvider dataId="quran-hafs" pageNumber={1} initialIsTwoPagesView={true}>
87
- <MushafReader />
88
- </MushafReaderProvider>
89
- );
90
- }
91
-
92
- function MushafReader() {
93
- const { pageNumber, fontScale, increaseFontScale, decreaseFontScale, setSelectedVerse } =
94
- useMushafContext();
95
-
96
- const handleWordClick = (word) => {
97
- // select the verse the word belongs to
98
- setSelectedVerse(word.verse);
99
- };
100
-
101
- const handleWordHover = (word) => {
102
- console.log('Word hovered:', word);
103
- };
104
-
105
- return (
106
- <div>
107
- <header>
108
- <h1>Page {pageNumber}</h1>
109
- <div>
110
- <button onClick={decreaseFontScale}>A-</button>
111
- <span>Font size: {fontScale}</span>
112
- <button onClick={increaseFontScale}>A+</button>
113
- </div>
114
- </header>
115
- <Mushaf onWordClick={handleWordClick} onWordHover={handleWordHover} />
116
- </div>
117
- );
118
- }
119
- ```
120
-
121
- ### 3. `Mushaf` Component
122
-
123
- This component consumes the data fetched by `MushafReaderProvider` and renders the actual Mushaf page(s).
124
-
125
- It accepts several optional props to handle user interactions.
126
-
127
- **Props:**
128
-
129
- - `onWordClick(word: Word)`: A callback function that triggers when a user clicks on a specific word. The `word` object contains detailed information about the word, including its location, text, and verse key.
130
- - `onWordHover(word: Word)`: A callback function that triggers when a user hovers over a word.
131
-
132
- ## How It Works: The Rendering Process
133
-
134
- Rendering a Mushaf page is a complex process that this library simplifies into a hierarchy of components.
135
-
136
- 1. **`Line.tsx`** (`@src/components/MushafReader/ReadingView/Line.tsx`): The Mushaf page is broken down into lines. This component is responsible for rendering a single line of text, including chapter headers where necessary.
137
-
138
- 2. **`VerseText.tsx`** (`@src/components/Verse/VerseText.tsx`): Each line contains words from one or more verses. `VerseText` takes an array of word objects and maps over them to render the verse. It handles text alignment and applies the correct font class based on the selected narration and font scale.
139
-
140
- 3. **`MushafWord.tsx`** (`@src/components/dls/MushafWord/MushafWord.tsx`): This is the most granular component, responsible for rendering a single Mushaf word. It attaches the `onClick` and `onMouseEnter` event listeners and applies the specific font-family for the current narration via CSS classes defined in `MushafWord.module.scss`.
141
-
142
- ## Styling and Customization
143
-
144
- The library's styling is managed through SCSS, offering a high degree of customization.
145
-
146
- - **Component Styles**: Each component has its own scoped styles using SCSS modules (e.g., `MushafWord.module.scss`).
147
- - **Global Styles** (`@src/styles/`): This directory contains the global styling configuration.
148
- - **Fonts**: The `@font-face` declarations for all supported narrations are located in `@src/styles/fonts.scss`.
149
- - **Responsiveness**: Breakpoints for various screen sizes are defined in `@src/styles/_breakpoints.scss` to ensure the layout is responsive.
150
-
151
- The library offers two primary ways to customize the appearance of the Mushaf renderer: `themeProps` for global theme adjustments and `styleOverride` for fine-grained component-level style changes. Both are passed as props to the `MushafReaderProvider`.
152
-
153
- ### 1. Theming with `themeProps`
154
-
155
- The `themeProps` object allows you to easily change the overall theme by setting global CSS variables at runtime.
156
-
157
- **Available Options:**
158
-
159
- - `borderColor` ('blue' | 'green' | 'sepia'): Sets the color for the page borders and the default word highlight color.
160
- - `wordHighlightColor` (string): Overrides the default highlight color for words when they are hovered or selected. Accepts any valid CSS color value.
161
- - `chapterHeaderFontSize` (string): The font size for the chapter headers (surah names). Accepts any valid CSS font-size value.
162
- - `primaryFontColor` (string): The primary color of the Quranic text.
163
-
164
- **Example:**
165
-
166
- ```tsx
167
- const themeProps = {
168
- borderColor: 'sepia',
169
- wordHighlightColor: '#D4AF37', // Gold highlight
170
- chapterHeaderFontSize: '2.5rem',
171
- primaryFontColor: '#333333', // Dark gray text
172
- };
173
-
174
- <MushafReaderProvider dataId="quran-hafs" pageNumber={1} themeProps={themeProps}>
175
- <Mushaf />
176
- </MushafReaderProvider>;
177
- ```
178
-
179
- ### 2. Component-level styling with `styleOverride`
180
-
181
- For more specific, dynamic, or one-off styling changes, the `styleOverride` prop allows you to apply a `React.CSSProperties` object directly to the library's internal components.
182
-
183
- The `styleOverride` object follows this structure:
184
-
185
- ```ts
186
- {
187
- [ComponentName]?: {
188
- [StyleKey]?: React.CSSProperties; // A CSS style object
189
- }
190
- }
191
- ```
192
-
193
- - `ComponentName` corresponds to the components you want to style (e.g., `Page`, `MushafWord`, `MushafReader`).
194
- - `StyleKey` corresponds to a stylable element within that component (e.g., `container`, `highlighted`, `twoPagesRow`).
195
-
196
- You can find all available `ComponentName` and `StyleKey` values in the exported `classnames` object.
197
-
198
- **Example:**
199
-
200
- Let's say you want to remove the gap between the two pages in the two-page view. You can do this by passing a style object to the `twoPagesRow` style key of the `MushafReader` component.
201
-
202
- ```tsx
203
- import { Mushaf, MushafReaderProvider } from 'misraj-mushaf-renderer';
204
-
205
- const styleOverride = {
206
- MushafReader: {
207
- twoPagesRow: {
208
- gap: 0,
209
- },
210
- },
211
- };
212
-
213
- function App() {
214
- return (
215
- <MushafReaderProvider
216
- dataId="quran-hafs"
217
- pageNumber={1}
218
- styleOverride={styleOverride}
219
- initialIsTwoPagesView={true}
220
- >
221
- <Mushaf />
222
- </MushafReaderProvider>
223
- );
224
- }
225
- ```
31
+ ## Package Structure
32
+
33
+ - `misraj-mushaf-renderer`: full package, including the default React UI, core helpers, and the Quranhub adapter
34
+ - `misraj-mushaf-renderer/core`: headless controller hook, public types, and shaping utilities
35
+ - `misraj-mushaf-renderer/react-ui`: the default React reader, provider, and context hook
36
+ - `misraj-mushaf-renderer/adapters/quranhub`: optional data-source adapter for Quranhub
37
+
38
+ ## How to Use
39
+
40
+ Import the packaged styles once:
41
+
42
+ ```tsx
43
+ import 'misraj-mushaf-renderer/dist/styles';
44
+ ```
45
+
46
+ ### 1. Drop-in Reader
47
+
48
+ Use `MushafReader` when you want a single self-contained component:
49
+
50
+ ```tsx
51
+ import { MushafReader } from 'misraj-mushaf-renderer';
52
+
53
+ function App() {
54
+ return (
55
+ <MushafReader
56
+ dataId="quran-hafs"
57
+ pageNumber={1}
58
+ defaultTwoPageView
59
+ theme={{
60
+ borderColor: 'sepia',
61
+ wordHighlightColor: '#D4AF37',
62
+ }}
63
+ />
64
+ );
65
+ }
66
+ ```
67
+
68
+ ### 2. Host-Controlled Data and State
69
+
70
+ Use the new core/controller API when the host app should own fetching, page state, or selected verse state:
71
+
72
+ ```tsx
73
+ import { MushafReader, useMushafController } from 'misraj-mushaf-renderer';
74
+
75
+ function ControlledReader({ pageData }) {
76
+ const controller = useMushafController({
77
+ dataId: 'quran-hafs',
78
+ pageNumber: 1,
79
+ pageData,
80
+ defaultTwoPageView: false,
81
+ });
82
+
83
+ return (
84
+ <MushafReader
85
+ dataId="quran-hafs"
86
+ pageNumber={controller.pageNumber}
87
+ pageData={pageData}
88
+ selectedVerse={controller.selectedVerse}
89
+ onSelectedVerseChange={controller.setSelectedVerse}
90
+ fontScale={controller.fontScale}
91
+ onFontScaleChange={controller.setFontScale}
92
+ />
93
+ );
94
+ }
95
+ ```
96
+
97
+ ### 3. Custom Data Source
98
+
99
+ Use `dataSource` for adapter mode without hardcoding Quranhub into your app shell:
100
+
101
+ ```tsx
102
+ import { MushafReader } from 'misraj-mushaf-renderer';
103
+ import { createQuranhubDataSource } from 'misraj-mushaf-renderer/adapters/quranhub';
104
+
105
+ const dataSource = createQuranhubDataSource({ environment: 'production' });
106
+
107
+ function App() {
108
+ return (
109
+ <MushafReader
110
+ dataId="quran-hafs"
111
+ pageNumber={1}
112
+ dataSource={dataSource}
113
+ narrationDifferencesRequest={{
114
+ sourceEditionIdentifier: 'quran-warsh',
115
+ targetEditionIdentifier: 'quran-hafs',
116
+ }}
117
+ />
118
+ );
119
+ }
120
+ ```
121
+
122
+ ## Styling and Customization
123
+
124
+ Theme variables are now scoped to each reader root instead of mutating `document.documentElement`, so multiple differently themed readers can coexist on the same page.
125
+
126
+ ### `theme`
127
+
128
+ Use semantic theme tokens:
129
+
130
+ - `borderColor`
131
+ - `wordHighlightColor`
132
+ - `chapterHeaderFontSize`
133
+ - `primaryFontColor`
134
+ - `fontSize`
135
+ - `spacingMega`
136
+
137
+ ### `classNames`, `styles`, and `slotProps`
138
+
139
+ Use stable slot names instead of internal SCSS module keys:
140
+
141
+ - `root`
142
+ - `twoPageLayout`
143
+ - `page`
144
+ - `pageBorder`
145
+ - `pageMeta`
146
+ - `pageNumber`
147
+ - `line`
148
+ - `verseText`
149
+ - `word`
150
+ - `wordHighlighted`
151
+ - `chapterHeader`
152
+ - `chapterIcon`
153
+
154
+ ### Render Overrides
155
+
156
+ The default UI can be customized without forking internal components:
157
+
158
+ - `renderWord`
159
+ - `renderLine`
160
+ - `renderPageMeta`
161
+ - `renderChapterHeader`
162
+
163
+ Each renderer receives typed context plus `defaultNode`, so hosts can wrap or replace the default output.
164
+
165
+ ## Compatibility
166
+
167
+ - `MushafReaderProvider` and `Mushaf` still exist for compatibility with the older provider-consumer pattern.
168
+ - The provider now uses the same explicit props as `MushafReader`, including `dataSource`, `defaultFontScale`, `defaultTwoPageView`, and `narrationDifferencesRequest`.
169
+
170
+ ## Notes
171
+
172
+ - The default package still exports `useMushafContext` for apps that want access to the reader controller from inside the provider tree.
173
+ - The core layer is intentionally independent from any specific backend. Quranhub support now lives behind the shipped adapter.
174
+ ```tsx
175
+ import { Mushaf, MushafReaderProvider } from 'misraj-mushaf-renderer';
176
+
177
+ function LegacyApp() {
178
+ return (
179
+ <MushafReaderProvider dataId="quran-hafs" pageNumber={1} defaultTwoPageView>
180
+ <Mushaf />
181
+ </MushafReaderProvider>
182
+ );
183
+ }
184
+ ```
@@ -0,0 +1 @@
1
+ export { createQuranhubDataSource, type QuranhubDataSourceOptions } from './quranhub';
@@ -0,0 +1,9 @@
1
+ import { MushafDataSource } from '../core/types';
2
+ export type QuranhubEnvironment = 'production' | 'staging';
3
+ export type QuranhubDataSourceOptions = {
4
+ baseUrl?: string;
5
+ environment?: QuranhubEnvironment;
6
+ fetchImplementation?: typeof fetch;
7
+ };
8
+ export declare const createQuranhubDataSource: (options?: QuranhubDataSourceOptions) => MushafDataSource;
9
+ export default createQuranhubDataSource;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ export declare const mushafSlots: readonly ["root", "twoPageLayout", "page", "pageBorder", "pageMeta", "pageNumber", "line", "verseText", "word", "wordHighlighted", "chapterHeader", "chapterIcon"];
1
2
  declare const classnames: {
2
3
  ChapterIconContainer: readonly ["iconContainer"];
3
4
  MushafWord: readonly ["colored", "filled", "highlightOnHover", "highlighted", "differenceHighlight"];
@@ -1,8 +1,11 @@
1
+ import { MushafClassNames, MushafRenderers, MushafSlotProps, MushafStyles, MushafTheme } from '../../core';
1
2
  import { MushafPageProviderProps } from './contexts/MushafPage/MushafPageProvider';
2
- import { ThemeProviderProps } from './contexts/Theme/type';
3
- type MushafReaderProviderProps = MushafPageProviderProps & {
4
- themeProps?: ThemeProviderProps['themeProps'];
5
- styleOverride?: ThemeProviderProps['styleOverride'];
3
+ export type MushafReaderProviderProps = MushafPageProviderProps & {
4
+ theme?: MushafTheme;
5
+ classNames?: MushafClassNames;
6
+ styles?: MushafStyles;
7
+ slotProps?: MushafSlotProps;
8
+ renderers?: MushafRenderers;
6
9
  };
7
- declare const MushafReaderProvider: ({ children, themeProps, styleOverride, ...props }: MushafReaderProviderProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const MushafReaderProvider: ({ children, theme, classNames, styles, slotProps, renderers, ...props }: MushafReaderProviderProps) => import("react/jsx-runtime").JSX.Element;
8
11
  export default MushafReaderProvider;
@@ -1,5 +1,4 @@
1
1
  import { default as Word } from '../../../types/Word';
2
- import { BorderColor } from '../../../types/border-color';
3
2
  type LineProps = {
4
3
  words: Word[];
5
4
  lineKey: string;
@@ -8,7 +7,6 @@ type LineProps = {
8
7
  lineIndex: number;
9
8
  onWordClick?: (word: Word, event: React.MouseEvent<HTMLElement>) => void;
10
9
  onWordHover?: (word: Word, event: React.MouseEvent<HTMLElement>) => void;
11
- borderColor?: BorderColor;
12
10
  };
13
- declare const _default: import('react').MemoExoticComponent<({ lineKey, words, isBigTextLayout, pageIndex, lineIndex, onWordClick, onWordHover, }: LineProps) => import("react/jsx-runtime").JSX.Element>;
11
+ declare const _default: import('react').MemoExoticComponent<({ lineKey, words, isBigTextLayout, pageIndex, lineIndex, onWordClick, onWordHover, }: LineProps) => string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined>;
14
12
  export default _default;
@@ -1,14 +1,12 @@
1
1
  import { default as React } from 'react';
2
2
  import { default as Word } from '../../../types/Word';
3
3
  import { Ayah } from '../../../types/verses';
4
- import { StyleOverride } from '../contexts/Theme/type';
5
4
  type PageProps = {
6
5
  verses: Ayah[];
7
6
  pageNumber: number;
8
7
  pageIndex: number;
9
8
  onWordClick?: (word: Word, event: React.MouseEvent<HTMLElement>) => void;
10
9
  onWordHover?: (word: Word, event: React.MouseEvent<HTMLElement>) => void;
11
- pageStyleOverride?: StyleOverride['Page'];
12
10
  };
13
- declare const Page: ({ verses, pageNumber, pageIndex, onWordClick, onWordHover, pageStyleOverride, }: PageProps) => import("react/jsx-runtime").JSX.Element;
11
+ declare const Page: ({ verses, pageNumber, pageIndex, onWordClick, onWordHover, }: PageProps) => import("react/jsx-runtime").JSX.Element;
14
12
  export default Page;
@@ -1,10 +1,7 @@
1
- import { default as Word } from '../../../../types/Word';
2
1
  import { default as React } from 'react';
3
- type NarrationId = 'quran-hafs' | 'quran-shoba' | 'quran-warsh' | 'quran-qunbul' | 'quran-qaloon' | 'quran-alsoosi' | 'quran-aldouri' | 'quran-albazzi';
4
- type ReciterId = 'ar.muhammadabdulhakim.albazzi' | 'ar.sufi.aldouri' | 'ar.husary.aldouri' | 'ar.belalya.warsh' | 'ar.abdurrahmaansudais.hafs' | 'ar.hanirifai.hafs' | 'ar.minshawimujawwad.hafs' | 'ar.abdulbasitmurattal.hafs' | 'ar.husarymujawwad.hafs' | 'ar.sufi.alsoosi' | 'ar.aljazairi.warsh' | 'ar.parhizgar.hafs' | 'ar.abdulsamad.warsh' | 'ar.muhammadabdulkareem.warsh' | 'ar.husary.qaloon' | 'ar.sufi.shoba' | 'ar.alkouchi.warsh' | 'ar.alnaehy.qaloon' | 'ar.abdulhakimabdullatif.shoba' | 'ar.aldaghoush.warsh' | 'ar.qanyouh.qaloon' | 'ar.abusneineh.qaloon' | 'ar.husary.warsh' | 'ar.muhammadabdulhakim.qunbul' | 'ar.ibrahimakhdar.hafs' | 'ar.abdullahbasfar.hafs' | 'ar.shaatree.hafs' | 'ar.ahmedajamy.hafs' | 'ar.alafasy.hafs' | 'ar.husary.hafs' | 'ar.hudhaify.hafs' | 'ar.mahermuaiqly.hafs' | 'ar.minshawi.hafs' | 'ar.muhammadayyoub.hafs' | 'ar.muhammadjibreel.hafs' | 'ar.saoodshuraym.hafs' | 'ar.aymanswoaid.hafs' | 'ar.abdulsamad.hafs';
5
- export type DataId = NarrationId | ReciterId;
2
+ import { default as Word } from '../../../../types/Word';
3
+ export type { DataId } from '../../../../core/types';
6
4
  export interface MushafPageProps {
7
5
  onWordClick?: (word: Word, event: React.MouseEvent<HTMLElement>) => void;
8
6
  onWordHover?: (word: Word, event: React.MouseEvent<HTMLElement>) => void;
9
7
  }
10
- export {};
@@ -1,46 +1,8 @@
1
1
  import { default as React } from 'react';
2
- import { NarrationDifference } from '../../../../types/differences';
3
- import { Ayah, IVersesListDto } from '../../../../types/verses';
4
- import { ThemeProviderProps } from '../Theme/type';
5
- import { DataId } from './MushafPage.types';
6
- type NarrationDifferences = NarrationDifference[];
7
- /** ---------- Types ---------- */
8
- type MushafPageState = {
9
- fontScale: number;
10
- selectedVerse: Ayah | null;
11
- ayat: IVersesListDto | null;
12
- nextPageAyat: IVersesListDto | null;
13
- narrationDifferences: NarrationDifferences | null;
14
- error: Error | null;
15
- pageNumber: number;
16
- dataId: DataId;
17
- hasBorder: boolean;
18
- initialIsTwoPagesView: boolean;
19
- };
20
- type MushafPageActions = {
21
- increaseFontScale: () => void;
22
- decreaseFontScale: () => void;
23
- setSelectedVerse: React.Dispatch<React.SetStateAction<Ayah | null>>;
24
- refresh: () => void;
25
- };
26
- export type HostApiEnvironment = 'production' | 'staging';
27
- export type MushafPageProviderProps = {
28
- children: React.ReactNode;
29
- dataId: DataId;
30
- hostApiEnvironment?: HostApiEnvironment;
31
- pageNumber: number;
32
- initialFontScale?: number;
33
- hasBorder?: boolean;
34
- initialIsTwoPagesView?: boolean;
35
- themeProps?: ThemeProviderProps['themeProps'];
36
- styleOverride?: ThemeProviderProps['styleOverride'];
37
- showNarrationDifferences?: {
38
- sourceEditionIdentifier: string;
39
- targetEditionIdentifier: string;
40
- } | null;
41
- };
42
- export declare const MushafPageProvider: ({ children, dataId, pageNumber, initialFontScale, hasBorder, initialIsTwoPagesView, showNarrationDifferences, hostApiEnvironment, }: MushafPageProviderProps) => import("react/jsx-runtime").JSX.Element;
43
- export type MushafContextStateTypes = MushafPageState & MushafPageActions;
44
- /** Convenience: keep a compat hook name if you prefer */
45
- export declare const useMushafContext: () => MushafContextStateTypes;
46
- export {};
2
+ import { MushafReaderValue, useMushafController } from '../../../../core';
3
+ export type MushafPageProviderProps = React.PropsWithChildren<Parameters<typeof useMushafController>[0] & {
4
+ value?: MushafReaderValue;
5
+ }>;
6
+ export declare const MushafPageProvider: ({ children, value, dataSource, ...controllerOptions }: MushafPageProviderProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const useMushafContext: () => MushafReaderValue;
8
+ export type MushafContextStateTypes = MushafReaderValue;
@@ -1,3 +1,3 @@
1
1
  import { ThemeProviderProps, ThemeState } from './type';
2
2
  export declare const useThemeContext: () => ThemeState;
3
- export declare const ThemeProvider: ({ children, themeProps, styleOverride, }: ThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const ThemeProvider: ({ children, theme, classNames, styles, slotProps, renderers, }: ThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,26 +1,18 @@
1
1
  import { default as React } from 'react';
2
- import { default as classnames } from '../../../../classnames';
3
- import { BorderColor } from '../../../../types/border-color';
4
- type ThemeProps = {
5
- borderColor?: BorderColor;
6
- wordHighlightColor?: string;
7
- chapterHeaderFontSize?: string;
8
- primaryFontColor?: string;
9
- fontSize?: string;
10
- };
11
- type ClassnameGroups = typeof classnames;
12
- type GroupName = keyof ClassnameGroups;
13
- type GroupKey<K extends GroupName> = ClassnameGroups[K][number];
14
- export type StyleOverride = {
15
- [K in GroupName]?: Partial<Record<GroupKey<K>, React.CSSProperties>>;
16
- };
2
+ import { MushafClassNames, MushafRenderers, MushafSlotProps, MushafStyles, MushafTheme } from '../../../../core/types';
17
3
  export type ThemeState = {
18
- themeProps: ThemeProps;
19
- styleOverride: StyleOverride;
4
+ theme: MushafTheme;
5
+ classNames: MushafClassNames;
6
+ styles: MushafStyles;
7
+ slotProps: MushafSlotProps;
8
+ renderers: MushafRenderers;
9
+ rootStyle: React.CSSProperties;
20
10
  };
21
11
  export type ThemeProviderProps = {
22
12
  children: React.ReactNode;
23
- themeProps?: ThemeProps;
24
- styleOverride?: StyleOverride;
13
+ theme?: MushafTheme;
14
+ classNames?: MushafClassNames;
15
+ styles?: MushafStyles;
16
+ slotProps?: MushafSlotProps;
17
+ renderers?: MushafRenderers;
25
18
  };
26
- export {};
@@ -0,0 +1,5 @@
1
+ import { CSSProperties } from 'react';
2
+ import { MushafSlot } from '../../core/types';
3
+ export declare const useSlotClassName: (slot: MushafSlot, defaultClassName?: string) => string;
4
+ export declare const useSlotStyle: (slot: MushafSlot, fallbackStyle?: CSSProperties) => CSSProperties;
5
+ export declare const mergeSlotStyles: (...styles: Array<CSSProperties | undefined>) => CSSProperties;
@@ -0,0 +1,9 @@
1
+ import { default as Word } from '../types/Word';
2
+ import { NarrationDifference } from '../types/differences';
3
+ import { Ayah } from '../types/verses';
4
+ export declare const groupVersesByLines: (verses: Ayah[]) => Record<string, Word[]>;
5
+ export type NarrationDifferenceInfo = {
6
+ differenceText: string;
7
+ differenceContent: string;
8
+ };
9
+ export declare const buildNarrationDifferencesMap: (narrationDifferences: NarrationDifference[] | null | undefined) => Map<string, NarrationDifferenceInfo> | null;
@@ -0,0 +1 @@
1
+ export {};