@paprize/react 0.0.3 → 0.0.5

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.
@@ -1,8 +1,14 @@
1
- import { ConfigAttribute } from '@paprize/core/src';
1
+ import { ConfigAttribute } from '@paprize/core';
2
+ import { Context } from 'react';
2
3
  import { JSX } from 'react/jsx-runtime';
3
- import { PaginationConfig } from '@paprize/core/src';
4
- import { PaginationPlugin } from '@paprize/core/src';
4
+ import { PageDimension } from '@paprize/core';
5
+ import { PageMargin } from '@paprize/core';
6
+ import { PageOrientation } from '@paprize/core';
7
+ import { PaginationConfig } from '@paprize/core';
8
+ import { PaginationCycleCompleted } from '@paprize/core';
9
+ import { PaginationPlugin } from '@paprize/core';
5
10
  import { ReactNode } from 'react';
11
+ import { SectionContext } from '@paprize/core';
6
12
 
7
13
  export declare const jsonData: () => Promise<unknown>;
8
14
 
@@ -18,10 +24,10 @@ export declare function PageContent({ children }: {
18
24
  children: ReactNode;
19
25
  }): JSX.Element;
20
26
 
21
- export declare interface PageDimension {
22
- height: string;
23
- width: string;
24
- }
27
+ export declare function pageContextToPageInfo(pc: {
28
+ index: number;
29
+ totalPages: number;
30
+ }): PageInfo;
25
31
 
26
32
  export declare function PageFooter({ children }: {
27
33
  children: React.ReactNode;
@@ -31,141 +37,23 @@ export declare function PageHeader({ children }: {
31
37
  children: ReactNode;
32
38
  }): JSX.Element;
33
39
 
34
- export declare interface PageMargin {
35
- top: string;
36
- right: string;
37
- bottom: string;
38
- left: string;
40
+ export declare interface PageInfo {
41
+ pageIndex: number;
42
+ totalPages: number;
39
43
  }
40
44
 
41
- export declare const pageMargin: Record<keyof typeof _pageMargin, PageMargin>;
42
-
43
- declare const _pageMargin: {
44
- Normal: {
45
- top: string;
46
- right: string;
47
- bottom: string;
48
- left: string;
49
- };
50
- Narrow: {
51
- top: string;
52
- right: string;
53
- bottom: string;
54
- left: string;
55
- };
56
- Wide: {
57
- top: string;
58
- right: string;
59
- bottom: string;
60
- left: string;
61
- };
62
- None: {
63
- top: string;
64
- right: string;
65
- bottom: string;
66
- left: string;
67
- };
68
- };
69
-
70
- export declare type PageOrientation = 'portrait' | 'landscape';
71
-
72
45
  export declare function PageOverlay({ children }: {
73
46
  children: ReactNode;
74
47
  }): JSX.Element;
75
48
 
76
- export declare const pageSize: Record<keyof typeof _pageSize, PageDimension>;
77
-
78
- declare const _pageSize: {
79
- A1: {
80
- height: string;
81
- width: string;
82
- };
83
- A2: {
84
- height: string;
85
- width: string;
86
- };
87
- A3: {
88
- height: string;
89
- width: string;
90
- };
91
- A4: {
92
- height: string;
93
- width: string;
94
- };
95
- A5: {
96
- height: string;
97
- width: string;
98
- };
99
- A6: {
100
- height: string;
101
- width: string;
102
- };
103
- B3: {
104
- height: string;
105
- width: string;
106
- };
107
- B4: {
108
- height: string;
109
- width: string;
110
- };
111
- B5: {
112
- height: string;
113
- width: string;
114
- };
115
- Letter: {
116
- height: string;
117
- width: string;
118
- };
119
- Legal: {
120
- height: string;
121
- width: string;
122
- };
123
- Tabloid: {
124
- height: string;
125
- width: string;
126
- };
127
- };
128
-
129
49
  export { PaginationConfig }
130
50
 
51
+ export declare function paginationCycleToReportInfo(rc: PaginationCycleCompleted): ReportInfo;
52
+
131
53
  export { PaginationPlugin }
132
54
 
133
- /**
134
- * Represents information about a report, including its sections and pagination details.
135
- */
136
55
  export declare interface ReportInfo {
137
- /**
138
- * The total number of sections in the report.
139
- * When isFirstPaginationCompleted is false, this value is 0.
140
- * When isPaginated is false, this value is not guaranteed to be accurate.
141
- */
142
- totalSections: number;
143
- /**
144
- * Indicates whether the report is ready and all sections are paginated.
145
- */
146
- isPaginated: boolean;
147
- /**
148
- * Indicates whether the first pagination process has been completed.
149
- * This becomes true once at least one section has been paginated.
150
- */
151
- isFirstPaginationCompleted: boolean;
152
- /**
153
- * An array of sections in the report, each containing details about the section.
154
- */
155
- sections: {
156
- /**
157
- * The id of the section.
158
- */
159
- sectionId: string;
160
- /**
161
- * The total number of pages in the section.
162
- */
163
- totalPages: number;
164
- /**
165
- * Indicates whether the section is paginated.
166
- */
167
- isPaginated: boolean;
168
- }[];
56
+ sections: SectionInfo[];
169
57
  }
170
58
 
171
59
  /**
@@ -182,7 +70,16 @@ export declare interface ReportRootProps {
182
70
  children: ReactNode;
183
71
  }
184
72
 
185
- export declare function Section({ children, dimension, orientation, margin, config, }: SectionProps): JSX.Element;
73
+ export declare function Section({ children, id, dimension, orientation, margin, config, }: SectionProps): JSX.Element;
74
+
75
+ export declare function sectionContextToSectionInfo(sc: SectionContext): SectionInfo;
76
+
77
+ export declare interface SectionController {
78
+ addPlugin: (plugin: PaginationPlugin) => void;
79
+ addSuspense: (suspense: Promise<void>) => void;
80
+ }
81
+
82
+ export declare const SectionControllerContext: Context<SectionController>;
186
83
 
187
84
  export declare function SectionFooter({ children }: {
188
85
  children: React.ReactNode;
@@ -192,56 +89,39 @@ export declare function SectionHeader({ children }: {
192
89
  children: React.ReactNode;
193
90
  }): JSX.Element;
194
91
 
195
- /**
196
- * Represents information about a section, including pagination details and pending suspensions.
197
- */
198
92
  export declare interface SectionInfo {
199
- /**
200
- * The total number of pages in the section.
201
- * When isPaginated is false, this value is 0.
202
- */
203
- totalPages: number;
204
- /**
205
- * Indicates whether the section is paginated.
206
- */
93
+ sectionId: string;
94
+ sectionIndex: number;
207
95
  isPaginated: boolean;
208
- /**
209
- * The number of pending suspensions in the section.
210
- */
211
- pendingSuspensions: number;
96
+ isSuspended: boolean;
97
+ pages: PageInfo[];
212
98
  }
213
99
 
214
100
  export declare interface SectionProps {
215
101
  children: ReactNode;
102
+ id?: string;
216
103
  dimension: PageDimension;
217
104
  orientation?: PageOrientation;
218
105
  margin?: PageMargin;
219
106
  config?: Partial<PaginationConfig>;
220
107
  }
221
108
 
222
- export declare interface State<T> {
223
- state: 'loading' | 'hasData' | 'hasError';
224
- value?: T;
225
- }
226
-
227
109
  export declare function useJsonData<DataModel>(defaultValue?: DataModel): DataModel | undefined;
228
110
 
229
111
  export declare const usePageInfo: () => {
230
- pageNumber: number;
112
+ pageIndex: number;
231
113
  totalPages: number;
232
114
  };
233
115
 
234
116
  export declare function useReportInfo(): ReportInfo;
235
117
 
236
- export declare const useSectionInfo: () => {
237
- sectionId: string;
238
- totalPages: number;
239
- };
118
+ export declare const useSectionInfo: () => SectionInfo;
119
+
120
+ export declare function useSectionSuspension(promise: Promise<void> | Promise<unknown>): void;
240
121
 
241
- export declare function useSectionSuspension(sectionId: string, suspend?: boolean): {
122
+ export declare function useSectionSuspension(): {
242
123
  release: () => void;
124
+ reset: () => void;
243
125
  };
244
126
 
245
- export declare function useSuspenseForPromise<T>(promise: Promise<T>, defaultValue?: T): T | undefined;
246
-
247
127
  export { }