@contensis/canvas-react 1.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.
@@ -0,0 +1,480 @@
1
+ import * as react from 'react';
2
+
3
+ type InlineBlock = FragmentBlock | AnchorBlock | LinkBlock | InlineEntryBlock;
4
+ type InlineChildren = string | InlineBlock[];
5
+ type DecoratorTypeMap<T> = {
6
+ code: T;
7
+ delete: T;
8
+ emphasis: T;
9
+ insert: T;
10
+ keyboard: T;
11
+ linebreak: T;
12
+ mark: T;
13
+ strong: T;
14
+ strikethrough: T;
15
+ subscript: T;
16
+ superscript: T;
17
+ underline: T;
18
+ variable: T;
19
+ };
20
+ type DecoratorType = keyof DecoratorTypeMap<any>;
21
+ type BaseSys = {
22
+ id?: string;
23
+ uri?: string;
24
+ language?: string;
25
+ contentTypeId?: string;
26
+ projectId?: string;
27
+ dataFormat?: string;
28
+ };
29
+ type BaseEntry<TSys extends BaseSys> = {
30
+ sys: null | TSys;
31
+ entryTitle?: string;
32
+ entryDescription?: string;
33
+ entryThumbnail?: Image$1;
34
+ };
35
+ type EntrySys = {
36
+ id?: string;
37
+ uri?: string;
38
+ language?: string;
39
+ contentTypeId?: string;
40
+ projectId?: string;
41
+ dataFormat?: 'entry';
42
+ };
43
+ type Entry = BaseEntry<EntrySys>;
44
+ type Image$1 = {
45
+ asset?: Asset;
46
+ caption?: string;
47
+ transformations?: Transformations;
48
+ altText?: string;
49
+ };
50
+ type AssetSys = {
51
+ id?: string;
52
+ uri?: string;
53
+ language?: string;
54
+ contentTypeId?: string;
55
+ projectId?: string;
56
+ dataFormat?: 'asset';
57
+ properties?: {
58
+ width?: number;
59
+ height?: number;
60
+ };
61
+ };
62
+ type Asset = BaseEntry<AssetSys> & {
63
+ altText?: string;
64
+ };
65
+ type Transformations = {
66
+ size?: {
67
+ width?: number;
68
+ height?: number;
69
+ };
70
+ flip?: null | 'h' | 'v' | 'both';
71
+ rotate?: number;
72
+ crop?: {
73
+ width?: number;
74
+ height?: number;
75
+ x?: number;
76
+ y?: number;
77
+ };
78
+ quality?: number;
79
+ format?: string;
80
+ };
81
+ type Node = {
82
+ displayName?: string;
83
+ id?: string;
84
+ includeInMenu?: boolean;
85
+ isCanonical?: boolean;
86
+ language?: string;
87
+ path?: string;
88
+ slug?: string;
89
+ };
90
+ type LinkType = 'entry' | 'node' | 'uri';
91
+ type LinkProperties = {
92
+ query?: string;
93
+ fragment?: string;
94
+ type: LinkType;
95
+ };
96
+ type LinkSys = EntrySys & {
97
+ linkProperties: LinkProperties;
98
+ node?: Node;
99
+ };
100
+ type Link$1 = BaseEntry<LinkSys>;
101
+ type Block = AnchorBlock | CodeBlock | ComponentBlock | DividerBlock | FragmentBlock | HeadingBlock | ImageBlock | InlineEntryBlock | LinkBlock | ListBlock | ListItemBlock | PanelBlock | ParagraphBlock | QuoteBlock | TableBlock | TableBodyBlock | TableCaptionBlock | TableCellBlock | TableFooterBlock | TableHeaderBlock | TableHeaderCellBlock | TableRowBlock;
102
+ type AnchorBlock = {
103
+ type: '_anchor';
104
+ id: string;
105
+ value?: InlineChildren;
106
+ properties?: {
107
+ id?: string;
108
+ };
109
+ };
110
+ type CodeBlock = {
111
+ type: '_code';
112
+ id: string;
113
+ value?: {
114
+ code?: string;
115
+ language?: string;
116
+ caption?: string;
117
+ };
118
+ properties?: {
119
+ id?: string;
120
+ };
121
+ };
122
+ type ComponentBlock = {
123
+ type: '_component';
124
+ id: string;
125
+ value?: Record<string, any>;
126
+ properties?: {
127
+ id?: string;
128
+ component: string;
129
+ };
130
+ };
131
+ type DividerBlock = {
132
+ type: '_divider';
133
+ id: string;
134
+ value?: undefined;
135
+ properties?: {
136
+ id?: string;
137
+ };
138
+ };
139
+ type FragmentBlock = {
140
+ type: '_fragment';
141
+ id: string;
142
+ value?: InlineChildren;
143
+ properties?: {
144
+ id?: string;
145
+ decorators?: DecoratorType[];
146
+ };
147
+ };
148
+ type HeadingBlock = {
149
+ type: '_heading';
150
+ id: string;
151
+ value?: InlineChildren;
152
+ properties?: {
153
+ id?: string;
154
+ level?: number;
155
+ };
156
+ };
157
+ type ImageBlock = {
158
+ type: '_image';
159
+ id: string;
160
+ value?: Image$1;
161
+ properties?: {
162
+ id?: string;
163
+ };
164
+ };
165
+ type InlineEntryBlock = {
166
+ type: '_inlineEntry';
167
+ id: string;
168
+ value?: Entry;
169
+ properties?: {
170
+ id?: string;
171
+ };
172
+ };
173
+ type LinkBlock = {
174
+ type: '_link';
175
+ id: string;
176
+ value?: InlineChildren;
177
+ properties?: {
178
+ id?: string;
179
+ link?: Link$1;
180
+ newTab?: boolean;
181
+ };
182
+ };
183
+ type ListType = 'ordered' | 'unordered';
184
+ type ListBlock = {
185
+ type: '_list';
186
+ id: string;
187
+ value?: ListItemBlock[];
188
+ properties?: {
189
+ id?: string;
190
+ listType?: ListType;
191
+ start?: number;
192
+ };
193
+ };
194
+ type ListItemBlock = {
195
+ type: '_listItem';
196
+ id: string;
197
+ value?: string | Block[];
198
+ properties?: {
199
+ id?: string;
200
+ };
201
+ };
202
+ type PanelType = 'info' | 'note' | 'warning' | 'success' | 'error';
203
+ type PanelBlock = {
204
+ type: '_panel';
205
+ id: string;
206
+ value?: InlineChildren;
207
+ properties?: {
208
+ id?: string;
209
+ panelType?: PanelType;
210
+ };
211
+ };
212
+ type ParagraphType = 'lead';
213
+ type ParagraphBlock = {
214
+ type: '_paragraph';
215
+ id: string;
216
+ value?: InlineChildren;
217
+ properties?: {
218
+ id?: string;
219
+ paragraphType?: ParagraphType;
220
+ };
221
+ };
222
+ type QuoteBlock = {
223
+ type: '_quote';
224
+ id: string;
225
+ value?: InlineChildren;
226
+ properties?: {
227
+ id?: string;
228
+ url?: string;
229
+ citation?: string;
230
+ source?: string;
231
+ };
232
+ };
233
+ type TableBlock = {
234
+ type: '_table';
235
+ id: string;
236
+ value?: (TableCaptionBlock | TableHeaderBlock | TableBodyBlock | TableFooterBlock)[];
237
+ properties?: {
238
+ id?: string;
239
+ };
240
+ };
241
+ type TableBodyBlock = {
242
+ type: '_tableBody';
243
+ id: string;
244
+ value?: TableRowBlock[];
245
+ properties?: {
246
+ id?: string;
247
+ };
248
+ };
249
+ type TableCaptionBlock = {
250
+ type: '_tableCaption';
251
+ id: string;
252
+ value?: string | Block[];
253
+ properties?: {
254
+ id?: string;
255
+ };
256
+ };
257
+ type TableCellBlock = {
258
+ type: '_tableCell';
259
+ id: string;
260
+ value?: string | Block[];
261
+ properties?: {
262
+ id?: string;
263
+ };
264
+ };
265
+ type TableFooterBlock = {
266
+ type: '_tableFooter';
267
+ id: string;
268
+ value?: TableRowBlock[];
269
+ properties?: {
270
+ id?: string;
271
+ };
272
+ };
273
+ type TableHeaderBlock = {
274
+ type: '_tableHeader';
275
+ id: string;
276
+ value?: TableRowBlock[];
277
+ properties?: {
278
+ id?: string;
279
+ };
280
+ };
281
+ type TableHeaderCellBlock = {
282
+ type: '_tableHeaderCell';
283
+ id: string;
284
+ value?: string | Block[];
285
+ properties?: {
286
+ id?: string;
287
+ };
288
+ };
289
+ type TableRowBlock = {
290
+ type: '_tableRow';
291
+ id: string;
292
+ value?: (TableCellBlock | TableHeaderCellBlock)[];
293
+ properties?: {
294
+ id?: string;
295
+ };
296
+ };
297
+
298
+ type Attributes = Record<string, any>;
299
+ type WithChildren = {
300
+ children?: JSX.Element;
301
+ };
302
+ type RendererProps = {
303
+ data: Block[];
304
+ };
305
+ type RenderBlockProps<T extends Block> = {
306
+ block: T;
307
+ };
308
+ type RenderBlockPropsWithChildren<T extends Block> = RenderBlockProps<T> & WithChildren & Attributes;
309
+ type TypedBlock<TType extends Block['type']> = Extract<Block, {
310
+ type: TType;
311
+ }>;
312
+ type BlockRenderer<T extends Block> = (props: RenderBlockPropsWithChildren<T>) => JSX.Element;
313
+ type BlockRenderers = {
314
+ [TType in Block['type']]: BlockRenderer<TypedBlock<TType>>;
315
+ };
316
+ type RenderDecoratorProps = {
317
+ block: FragmentBlock;
318
+ decorator: undefined | DecoratorType;
319
+ otherDecorators: undefined | DecoratorType[];
320
+ };
321
+ type RenderDecoratorPropsWithChildren = RenderDecoratorProps & WithChildren & Attributes;
322
+ type DecoratorRenderer = (props: RenderDecoratorPropsWithChildren) => JSX.Element;
323
+ type DecoratorRenderers = Record<DecoratorType, DecoratorRenderer>;
324
+ type ComponentRenderer = (props: RenderBlockPropsWithChildren<ComponentBlock>) => JSX.Element;
325
+ type ComponentRenderers = Record<string, ComponentRenderer>;
326
+ type RendererContextValue = {
327
+ blocks?: BlockRenderers;
328
+ decorators?: DecoratorRenderers;
329
+ components?: ComponentRenderers;
330
+ };
331
+ type RendererOverridesContextValue = {
332
+ blocks?: Partial<BlockRenderers>;
333
+ decorators?: Partial<DecoratorRenderers>;
334
+ components?: ComponentRenderers;
335
+ };
336
+ type RendererContextProviderProps = {
337
+ children: JSX.Element;
338
+ } & RendererOverridesContextValue;
339
+ declare const RendererContext: react.Context<RendererContextValue>;
340
+ declare function RenderContextProvider(props: RendererContextProviderProps): JSX.Element;
341
+ declare function Renderer(props: RendererProps): JSX.Element;
342
+ declare function Anchor(props: RenderBlockPropsWithChildren<AnchorBlock>): JSX.Element;
343
+ declare namespace Anchor {
344
+ var Children: (props: RenderBlockProps<AnchorBlock>) => JSX.Element;
345
+ }
346
+ declare function Code(props: RenderBlockPropsWithChildren<CodeBlock>): JSX.Element;
347
+ declare namespace Code {
348
+ var Children: (props: RenderBlockProps<CodeBlock>) => JSX.Element;
349
+ }
350
+ declare function Component(props: RenderBlockPropsWithChildren<ComponentBlock>): JSX.Element;
351
+ declare namespace Component {
352
+ var Children: (props: RenderBlockProps<ComponentBlock>) => JSX.Element;
353
+ }
354
+ declare function Divider(props: RenderBlockPropsWithChildren<DividerBlock>): JSX.Element;
355
+ declare namespace Divider {
356
+ var Children: (props: RenderBlockProps<DividerBlock>) => JSX.Element;
357
+ }
358
+ declare function Fragment(props: RenderBlockPropsWithChildren<FragmentBlock>): JSX.Element;
359
+ declare namespace Fragment {
360
+ var Children: (props: RenderBlockProps<FragmentBlock>) => JSX.Element;
361
+ }
362
+ declare function Heading(props: RenderBlockPropsWithChildren<HeadingBlock>): JSX.Element;
363
+ declare namespace Heading {
364
+ var Children: (props: RenderBlockProps<HeadingBlock>) => JSX.Element;
365
+ }
366
+ declare function Image(props: RenderBlockPropsWithChildren<ImageBlock>): JSX.Element;
367
+ declare namespace Image {
368
+ var Children: (props: RenderBlockProps<ImageBlock>) => JSX.Element;
369
+ }
370
+ declare function InlineEntry(props: RenderBlockPropsWithChildren<InlineEntryBlock>): JSX.Element;
371
+ declare namespace InlineEntry {
372
+ var Children: (props: RenderBlockProps<InlineEntryBlock>) => JSX.Element;
373
+ }
374
+ declare function Link(props: RenderBlockPropsWithChildren<LinkBlock>): JSX.Element;
375
+ declare namespace Link {
376
+ var Children: (props: RenderBlockProps<LinkBlock>) => JSX.Element;
377
+ }
378
+ declare function List(props: RenderBlockPropsWithChildren<ListBlock>): JSX.Element;
379
+ declare namespace List {
380
+ var Children: (props: RenderBlockProps<ListBlock>) => JSX.Element;
381
+ }
382
+ declare function ListItem(props: RenderBlockPropsWithChildren<ListItemBlock>): JSX.Element;
383
+ declare namespace ListItem {
384
+ var Children: (props: RenderBlockProps<ListItemBlock>) => JSX.Element;
385
+ }
386
+ declare function Panel(props: RenderBlockPropsWithChildren<PanelBlock>): JSX.Element;
387
+ declare namespace Panel {
388
+ var Children: (props: RenderBlockProps<PanelBlock>) => JSX.Element;
389
+ }
390
+ declare function Paragraph(props: RenderBlockPropsWithChildren<ParagraphBlock>): JSX.Element;
391
+ declare namespace Paragraph {
392
+ var Children: (props: RenderBlockProps<ParagraphBlock>) => JSX.Element;
393
+ }
394
+ declare function Table(props: RenderBlockPropsWithChildren<TableBlock>): JSX.Element;
395
+ declare namespace Table {
396
+ var Children: (props: RenderBlockProps<TableBlock>) => JSX.Element;
397
+ }
398
+ declare function TableBody(props: RenderBlockPropsWithChildren<TableBodyBlock>): JSX.Element;
399
+ declare namespace TableBody {
400
+ var Children: (props: RenderBlockProps<TableBodyBlock>) => JSX.Element;
401
+ }
402
+ declare function TableCaption(props: RenderBlockPropsWithChildren<TableCaptionBlock>): JSX.Element;
403
+ declare namespace TableCaption {
404
+ var Children: (props: RenderBlockProps<TableCaptionBlock>) => JSX.Element;
405
+ }
406
+ declare function TableCell(props: RenderBlockPropsWithChildren<TableCellBlock>): JSX.Element;
407
+ declare namespace TableCell {
408
+ var Children: (props: RenderBlockProps<TableCellBlock>) => JSX.Element;
409
+ }
410
+ declare function TableFooter(props: RenderBlockPropsWithChildren<TableFooterBlock>): JSX.Element;
411
+ declare namespace TableFooter {
412
+ var Children: (props: RenderBlockProps<TableFooterBlock>) => JSX.Element;
413
+ }
414
+ declare function TableHeader(props: RenderBlockPropsWithChildren<TableHeaderBlock>): JSX.Element;
415
+ declare namespace TableHeader {
416
+ var Children: (props: RenderBlockProps<TableHeaderBlock>) => JSX.Element;
417
+ }
418
+ declare function TableHeaderCell(props: RenderBlockPropsWithChildren<TableHeaderCellBlock>): JSX.Element;
419
+ declare namespace TableHeaderCell {
420
+ var Children: (props: RenderBlockProps<TableHeaderCellBlock>) => JSX.Element;
421
+ }
422
+ declare function TableRow(props: RenderBlockPropsWithChildren<TableRowBlock>): JSX.Element;
423
+ declare namespace TableRow {
424
+ var Children: (props: RenderBlockProps<TableRowBlock>) => JSX.Element;
425
+ }
426
+ declare function DecoratorChildren(props: RenderDecoratorPropsWithChildren): JSX.Element;
427
+ declare function InlineCode(props: RenderDecoratorPropsWithChildren): JSX.Element;
428
+ declare namespace InlineCode {
429
+ var Children: typeof DecoratorChildren;
430
+ }
431
+ declare function Delete(props: RenderDecoratorPropsWithChildren): JSX.Element;
432
+ declare namespace Delete {
433
+ var Children: typeof DecoratorChildren;
434
+ }
435
+ declare function Emphasis(props: RenderDecoratorPropsWithChildren): JSX.Element;
436
+ declare namespace Emphasis {
437
+ var Children: typeof DecoratorChildren;
438
+ }
439
+ declare function Insert(props: RenderDecoratorPropsWithChildren): JSX.Element;
440
+ declare namespace Insert {
441
+ var Children: typeof DecoratorChildren;
442
+ }
443
+ declare function Keyboard(props: RenderDecoratorPropsWithChildren): JSX.Element;
444
+ declare namespace Keyboard {
445
+ var Children: typeof DecoratorChildren;
446
+ }
447
+ declare function LineBreak(props: RenderDecoratorPropsWithChildren): JSX.Element;
448
+ declare namespace LineBreak {
449
+ var Children: (props: RenderDecoratorPropsWithChildren) => JSX.Element;
450
+ }
451
+ declare function Mark(props: RenderDecoratorPropsWithChildren): JSX.Element;
452
+ declare namespace Mark {
453
+ var Children: typeof DecoratorChildren;
454
+ }
455
+ declare function Strong(props: RenderDecoratorPropsWithChildren): JSX.Element;
456
+ declare namespace Strong {
457
+ var Children: typeof DecoratorChildren;
458
+ }
459
+ declare function Strikethrough(props: RenderDecoratorPropsWithChildren): JSX.Element;
460
+ declare namespace Strikethrough {
461
+ var Children: typeof DecoratorChildren;
462
+ }
463
+ declare function Subscript(props: RenderDecoratorPropsWithChildren): JSX.Element;
464
+ declare namespace Subscript {
465
+ var Children: typeof DecoratorChildren;
466
+ }
467
+ declare function Superscript(props: RenderDecoratorPropsWithChildren): JSX.Element;
468
+ declare namespace Superscript {
469
+ var Children: typeof DecoratorChildren;
470
+ }
471
+ declare function Underline(props: RenderDecoratorPropsWithChildren): JSX.Element;
472
+ declare namespace Underline {
473
+ var Children: typeof DecoratorChildren;
474
+ }
475
+ declare function Variable(props: RenderDecoratorPropsWithChildren): JSX.Element;
476
+ declare namespace Variable {
477
+ var Children: typeof DecoratorChildren;
478
+ }
479
+
480
+ export { Anchor, type AnchorBlock, type Block, Code, type CodeBlock, Component, type ComponentBlock, type DecoratorType, Delete, Divider, type DividerBlock, Emphasis, Fragment, type FragmentBlock, Heading, type HeadingBlock, Image, type ImageBlock, InlineCode, InlineEntry, type InlineEntryBlock, Insert, Keyboard, LineBreak, Link, type LinkBlock, List, type ListBlock, ListItem, type ListItemBlock, Mark, Panel, type PanelBlock, Paragraph, type ParagraphBlock, type QuoteBlock, RenderContextProvider, Renderer, RendererContext, Strikethrough, Strong, Subscript, Superscript, Table, type TableBlock, TableBody, type TableBodyBlock, TableCaption, type TableCaptionBlock, TableCell, type TableCellBlock, TableFooter, type TableFooterBlock, TableHeader, type TableHeaderBlock, TableHeaderCell, type TableHeaderCellBlock, TableRow, type TableRowBlock, Underline, Variable };