datastake-daf 0.6.463 → 0.6.465
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/components/index.js +6 -51
- package/dist/utils/index.js +662 -0
- package/package.json +5 -1
- package/rollup.config.js +4 -0
- package/src/@daf/core/components/Document/WordDocument/Preview/WordDocument.stories.js +640 -0
- package/src/@daf/core/components/Document/WordDocument/Preview/index.js +118 -0
- package/src/@daf/core/components/Document/WordDocument/createDocument.js +565 -0
- package/src/@daf/core/components/Document/WordDocument/index.js +9 -0
- package/src/@daf/core/components/DynamicForm/helper.js +0 -7
- package/src/@daf/core/components/DynamicForm/index.jsx +0 -37
- package/src/@daf/core/components/DynamicForm/storyConfig.js +0 -1
- package/src/@daf/core/components/EditForm/storyConfig.js +1 -1
- package/src/@daf/core/components/EditForm/storyConfig1.js +9932 -131
- package/src/@daf/core/components/ViewForm/components/DataLink/flat.js +1 -1
- package/src/helpers/componentsToImages.js +29 -0
- package/src/utils.js +4 -0
- package/dist/style/datastake/mapbox-gl.css +0 -330
package/rollup.config.js
CHANGED
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
import WordDocumentPreview from "./index";
|
|
2
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import { captureElementsAsImages } from '../../../../../../helpers/componentsToImages';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Core/Document/WordDocument",
|
|
7
|
+
component: WordDocumentPreview,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const HeadingExample = {
|
|
13
|
+
name: "Heading Types",
|
|
14
|
+
args: {
|
|
15
|
+
title: "Heading Examples",
|
|
16
|
+
fileName: "headings-example.docx",
|
|
17
|
+
config: [
|
|
18
|
+
{
|
|
19
|
+
type: 'heading',
|
|
20
|
+
data: 'Heading Level 1',
|
|
21
|
+
style: { heading: 'HEADING_1', spacing: { after: 200 } }
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'heading',
|
|
25
|
+
data: 'Heading Level 2',
|
|
26
|
+
style: { heading: 'HEADING_2', spacing: { after: 200 } }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'heading',
|
|
30
|
+
data: 'Heading Level 3',
|
|
31
|
+
style: { heading: 'HEADING_3', spacing: { after: 200 } }
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const TableExample = {
|
|
38
|
+
name: "Table Example",
|
|
39
|
+
args: {
|
|
40
|
+
title: "Table Document",
|
|
41
|
+
fileName: "table-example.docx",
|
|
42
|
+
config: [
|
|
43
|
+
{
|
|
44
|
+
type: 'heading',
|
|
45
|
+
data: 'Employee Data',
|
|
46
|
+
style: { heading: 'HEADING_1', spacing: { after: 200 } }
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'table',
|
|
50
|
+
data: [
|
|
51
|
+
['Employee ID', 'Name', 'Department', 'Salary'],
|
|
52
|
+
['001', 'John Doe', 'Engineering', '$75,000'],
|
|
53
|
+
['002', 'Jane Smith', 'Marketing', '$65,000'],
|
|
54
|
+
['003', 'Bob Johnson', 'Sales', '$70,000']
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const ListsExample = {
|
|
62
|
+
name: "Lists Example",
|
|
63
|
+
args: {
|
|
64
|
+
title: "Lists Document",
|
|
65
|
+
fileName: "lists-example.docx",
|
|
66
|
+
config: [
|
|
67
|
+
{
|
|
68
|
+
type: 'heading',
|
|
69
|
+
data: 'Shopping List (Bullets)',
|
|
70
|
+
style: { heading: 'HEADING_2', spacing: { after: 200 } }
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: 'bulletList',
|
|
74
|
+
data: 'Milk',
|
|
75
|
+
style: { level: 0 }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'bulletList',
|
|
79
|
+
data: 'Bread',
|
|
80
|
+
style: { level: 0 }
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'bulletList',
|
|
84
|
+
data: 'Eggs',
|
|
85
|
+
style: { level: 0 }
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'heading',
|
|
89
|
+
data: 'Instructions (Numbered)',
|
|
90
|
+
style: { heading: 'HEADING_2', spacing: { before: 300, after: 200 } }
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: 'numberedList',
|
|
94
|
+
data: 'Preheat oven to 350°F',
|
|
95
|
+
style: { reference: 'default-numbering', level: 0 }
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: 'numberedList',
|
|
99
|
+
data: 'Mix ingredients in a bowl',
|
|
100
|
+
style: { reference: 'default-numbering', level: 0 }
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: 'numberedList',
|
|
104
|
+
data: 'Bake for 25 minutes',
|
|
105
|
+
style: { reference: 'default-numbering', level: 0 }
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const ReportTemplate = {
|
|
112
|
+
name: "Report Template (Like Image)",
|
|
113
|
+
args: {
|
|
114
|
+
title: "Inspection Report",
|
|
115
|
+
fileName: "inspection-report.docx",
|
|
116
|
+
config: [
|
|
117
|
+
// Image with Text Section 1
|
|
118
|
+
{
|
|
119
|
+
type: 'imageWithText',
|
|
120
|
+
data: {
|
|
121
|
+
imageTitle: 'Facility Overview - Main Entrance',
|
|
122
|
+
// Sample industrial facility image from Unsplash
|
|
123
|
+
imageUrl: 'https://images.unsplash.com/photo-1581094794329-c8112a89af12?w=600&h=400&fit=crop',
|
|
124
|
+
image: null, // Will be populated from imageUrl
|
|
125
|
+
imageWidth: 280,
|
|
126
|
+
imageHeight: 200,
|
|
127
|
+
text: 'Main entrance facility showing security gates and access control points. Observation date: 2025-10-13. Weather conditions: Clear. Temperature: 22°C.'
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
// Image with Text Section 2 - Image on RIGHT side
|
|
131
|
+
{
|
|
132
|
+
type: 'imageWithText',
|
|
133
|
+
data: {
|
|
134
|
+
imageTitle: 'Storage Area - Chemical Warehouse',
|
|
135
|
+
// Sample warehouse image from Unsplash
|
|
136
|
+
imageUrl: 'https://images.unsplash.com/photo-1553413077-190dd305871c?w=600&h=400&fit=crop',
|
|
137
|
+
image: null, // Will be populated from imageUrl
|
|
138
|
+
imageWidth: 280,
|
|
139
|
+
imageHeight: 200,
|
|
140
|
+
imagePosition: 'right', // Image on the right, text on the left
|
|
141
|
+
text: 'Chemical storage warehouse with proper ventilation and safety signage. All containers are properly labeled. Emergency equipment is accessible and well-maintained.',
|
|
142
|
+
hasSpacing: true
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
// Main Takeaways Section with Border
|
|
146
|
+
{
|
|
147
|
+
type: 'borderedSection',
|
|
148
|
+
data: {
|
|
149
|
+
title: 'Provide your main takeaways here',
|
|
150
|
+
content: 'Editable - to be filled by the user\n\nThis is a bordered section where the user can add their main observations and conclusions from the inspection.'
|
|
151
|
+
},
|
|
152
|
+
style: {
|
|
153
|
+
margins: {
|
|
154
|
+
top: 300,
|
|
155
|
+
bottom: 300
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
// Mercury Management Section with percentage
|
|
160
|
+
{
|
|
161
|
+
type: 'commentSection',
|
|
162
|
+
data: {
|
|
163
|
+
title: 'Mercury management',
|
|
164
|
+
percentage: 51,
|
|
165
|
+
description: 'Automatic filled by comments contained in associated sub-criteria - editable',
|
|
166
|
+
comments: [
|
|
167
|
+
'Mercury storage areas are properly labeled and secured with restricted access',
|
|
168
|
+
'Safety protocols are documented and clearly displayed in work areas',
|
|
169
|
+
'Regular monitoring of mercury levels is conducted with weekly reports',
|
|
170
|
+
'Emergency response kits are available and inspected monthly',
|
|
171
|
+
'Staff training records are up to date for all personnel handling mercury'
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
// Cyanide Management Section with percentage
|
|
176
|
+
{
|
|
177
|
+
type: 'commentSection',
|
|
178
|
+
data: {
|
|
179
|
+
title: 'Cyanide management',
|
|
180
|
+
percentage: 51,
|
|
181
|
+
description: 'Automatic filled by comments contained in associated sub-criteria - editable',
|
|
182
|
+
comments: [
|
|
183
|
+
'Cyanide storage facilities meet international safety standards',
|
|
184
|
+
'Emergency response procedures are documented and regularly tested',
|
|
185
|
+
'Staff training on cyanide safety is up to date and comprehensive',
|
|
186
|
+
'Proper ventilation systems are installed and functioning correctly',
|
|
187
|
+
'Neutralization agents are stored nearby and easily accessible'
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
// Page Break
|
|
192
|
+
// {
|
|
193
|
+
// type: 'pageBreak'
|
|
194
|
+
// },
|
|
195
|
+
// Climate Change Section on new page
|
|
196
|
+
{
|
|
197
|
+
type: 'commentSection',
|
|
198
|
+
data: {
|
|
199
|
+
title: 'Climate change',
|
|
200
|
+
percentage: 51,
|
|
201
|
+
description: 'Automatic filled by comments contained in associated sub-criteria - editable',
|
|
202
|
+
comments: [
|
|
203
|
+
'Carbon emission reduction strategies are actively implemented',
|
|
204
|
+
'Energy efficiency measures have reduced consumption by 15% year-over-year',
|
|
205
|
+
'Renewable energy sources provide 30% of total energy requirements',
|
|
206
|
+
'Water conservation programs are in place with recycling systems',
|
|
207
|
+
'Environmental impact assessments are conducted quarterly'
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const ImageWithTextExample = {
|
|
216
|
+
name: "Image With Text Layout",
|
|
217
|
+
args: {
|
|
218
|
+
title: "Image and Text Layout Example",
|
|
219
|
+
fileName: "image-text-layout.docx",
|
|
220
|
+
config: [
|
|
221
|
+
{
|
|
222
|
+
type: 'imageWithText',
|
|
223
|
+
data: {
|
|
224
|
+
imageTitle: 'Image on Left Side',
|
|
225
|
+
// Sample office/building image from Unsplash
|
|
226
|
+
imageUrl: 'https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=600&h=400&fit=crop',
|
|
227
|
+
image: null,
|
|
228
|
+
imageWidth: 300,
|
|
229
|
+
imageHeight: 200,
|
|
230
|
+
imagePosition: 'left', // Default: image on left
|
|
231
|
+
text: 'This is a two-column layout with the image on the LEFT side and text on the right. Both columns have borders.'
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
type: 'imageWithText',
|
|
236
|
+
data: {
|
|
237
|
+
imageTitle: 'Image on Right Side',
|
|
238
|
+
// Sample technology image from Unsplash
|
|
239
|
+
imageUrl: 'https://images.unsplash.com/photo-1451187580459-43490279c0fa?w=600&h=400&fit=crop',
|
|
240
|
+
image: null,
|
|
241
|
+
imageWidth: 300,
|
|
242
|
+
imageHeight: 200,
|
|
243
|
+
imagePosition: 'right', // Image on right
|
|
244
|
+
text: 'This shows the same two-column layout but with the image on the RIGHT side and text on the left. You can alternate the positions for visual variety.'
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const BorderedSectionExample = {
|
|
252
|
+
name: "Bordered Section Example",
|
|
253
|
+
args: {
|
|
254
|
+
title: "Bordered Section Example",
|
|
255
|
+
fileName: "bordered-section.docx",
|
|
256
|
+
config: [
|
|
257
|
+
{
|
|
258
|
+
type: 'borderedSection',
|
|
259
|
+
data: {
|
|
260
|
+
title: 'Important Notice',
|
|
261
|
+
content: 'This is a bordered section with a gray background. It can be used for editable areas, important notices, or user input fields.'
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export const CommentSectionExample = {
|
|
269
|
+
name: "Comment Section Example",
|
|
270
|
+
args: {
|
|
271
|
+
title: "Comment Section Example",
|
|
272
|
+
fileName: "comment-section.docx",
|
|
273
|
+
config: [
|
|
274
|
+
{
|
|
275
|
+
type: 'commentSection',
|
|
276
|
+
data: {
|
|
277
|
+
title: 'Legitimacy of ASM',
|
|
278
|
+
percentage: 51,
|
|
279
|
+
description: 'Automatic filled by comments contained in associated sub-criteria - editable',
|
|
280
|
+
comments: []
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
type: 'commentSection',
|
|
285
|
+
data: {
|
|
286
|
+
title: 'Ensure traceability',
|
|
287
|
+
percentage: 51,
|
|
288
|
+
comments: [
|
|
289
|
+
'Comment 1',
|
|
290
|
+
'Comment 2',
|
|
291
|
+
'Comment 3',
|
|
292
|
+
'...'
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
type: 'commentSection',
|
|
298
|
+
data: {
|
|
299
|
+
title: 'ASM Companies',
|
|
300
|
+
percentage: 51,
|
|
301
|
+
description: 'Automatic filled by comments contained in associated sub-criteria - editable',
|
|
302
|
+
comments: [
|
|
303
|
+
'Comment 1',
|
|
304
|
+
'Comment 2',
|
|
305
|
+
'Comment 3',
|
|
306
|
+
'...'
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
type: 'commentSection',
|
|
312
|
+
data: {
|
|
313
|
+
title: 'Armed conflict',
|
|
314
|
+
percentage: 51,
|
|
315
|
+
description: 'Automatic filled by comments contained in associated sub-criteria - editable',
|
|
316
|
+
comments: []
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export const DocumentHeaderExample = {
|
|
324
|
+
name: "Document Header (Dynamic)",
|
|
325
|
+
args: {
|
|
326
|
+
title: "Document with Custom Header",
|
|
327
|
+
fileName: "document-header-example.docx",
|
|
328
|
+
config: [
|
|
329
|
+
// Document Header with icon and dynamic info fields
|
|
330
|
+
{
|
|
331
|
+
type: 'documentHeader',
|
|
332
|
+
data: {
|
|
333
|
+
title: 'Executive Monitoring Report',
|
|
334
|
+
icon: '/logo192.png', // Path to image (will be fetched automatically)
|
|
335
|
+
iconWidth: 60,
|
|
336
|
+
iconHeight: 60,
|
|
337
|
+
titleTextColor: '000000', // Black text (default)
|
|
338
|
+
infoFields: [
|
|
339
|
+
{ label: 'Mine:', value: '<Mine Name>' },
|
|
340
|
+
{ label: 'Date:', value: 'DD Mmm YY' },
|
|
341
|
+
{ label: 'Step:', value: '<Step>' },
|
|
342
|
+
{ label: 'Code:', value: '<Code>' }
|
|
343
|
+
]
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
// Add some content below the header
|
|
347
|
+
{
|
|
348
|
+
type: 'paragraph',
|
|
349
|
+
data: 'This document demonstrates the new documentHeader type with dynamic fields.',
|
|
350
|
+
meta: { size: 24 },
|
|
351
|
+
style: { spacing: { after: 200 } }
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
type: 'heading',
|
|
355
|
+
data: 'Report Content',
|
|
356
|
+
style: {
|
|
357
|
+
heading: 'HEADING_2',
|
|
358
|
+
spacing: { before: 200, after: 200 }
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
type: 'paragraph',
|
|
363
|
+
data: 'The document header above is fully dynamic. You can customize the title, add a logo on the right, and pass any number of info fields with their own labels and values.',
|
|
364
|
+
meta: { size: 22 },
|
|
365
|
+
style: { spacing: { after: 100 } }
|
|
366
|
+
}
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
export const SectionTitlesExample = {
|
|
372
|
+
name: "Section Titles Demo",
|
|
373
|
+
args: {
|
|
374
|
+
title: "Document with Section Titles",
|
|
375
|
+
fileName: "section-titles-example.docx",
|
|
376
|
+
config: [
|
|
377
|
+
// Document Header
|
|
378
|
+
{
|
|
379
|
+
type: 'documentHeader',
|
|
380
|
+
data: {
|
|
381
|
+
title: 'Executive Monitoring Report',
|
|
382
|
+
icon: '/logo192.png',
|
|
383
|
+
iconWidth: 60,
|
|
384
|
+
iconHeight: 60,
|
|
385
|
+
titleTextColor: '000000',
|
|
386
|
+
infoFields: [
|
|
387
|
+
{ label: 'Mine:', value: 'Gold Valley Mine' },
|
|
388
|
+
{ label: 'Date:', value: '13 Oct 2025' },
|
|
389
|
+
{ label: 'Step:', value: 'Phase 2' },
|
|
390
|
+
{ label: 'Code:', value: 'EMR-001' }
|
|
391
|
+
]
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
// Section 1 with title
|
|
395
|
+
{
|
|
396
|
+
title: '1. Environmental Compliance', // Section title
|
|
397
|
+
type: 'commentSection',
|
|
398
|
+
data: {
|
|
399
|
+
title: 'Mercury management',
|
|
400
|
+
percentage: 85,
|
|
401
|
+
description: 'Automatic filled by comments contained in associated sub-criteria - editable',
|
|
402
|
+
comments: [
|
|
403
|
+
'Mercury storage areas are properly labeled and secured',
|
|
404
|
+
'Safety protocols are documented and clearly displayed',
|
|
405
|
+
'Regular monitoring of mercury levels is conducted',
|
|
406
|
+
'Emergency response kits are available'
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
type: 'commentSection',
|
|
412
|
+
data: {
|
|
413
|
+
title: 'Cyanide management',
|
|
414
|
+
percentage: 78,
|
|
415
|
+
description: 'Automatic filled by comments contained in associated sub-criteria - editable',
|
|
416
|
+
comments: [
|
|
417
|
+
'Cyanide storage facilities meet international standards',
|
|
418
|
+
'Emergency response procedures are regularly tested',
|
|
419
|
+
'Staff training on cyanide safety is comprehensive',
|
|
420
|
+
'Proper ventilation systems are functioning correctly'
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
// Section 3 with title
|
|
425
|
+
{
|
|
426
|
+
title: '3. Climate Action', // Section title
|
|
427
|
+
type: 'borderedSection',
|
|
428
|
+
data: {
|
|
429
|
+
title: 'Provide your main takeaways here',
|
|
430
|
+
content: 'Editable section for climate change action plans and observations.'
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
// Section 4 with title and custom paragraph
|
|
434
|
+
{
|
|
435
|
+
title: '4. Recommendations', // Section title
|
|
436
|
+
type: 'paragraph',
|
|
437
|
+
data: 'Based on the findings above, we recommend implementing additional safety measures and conducting quarterly reviews of all environmental protocols.',
|
|
438
|
+
meta: { size: 22 },
|
|
439
|
+
style: { spacing: { after: 200 } }
|
|
440
|
+
}
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
// Custom render function to capture components as images
|
|
446
|
+
const ComponentToImageStory = () => {
|
|
447
|
+
const chartRef = useRef(null);
|
|
448
|
+
const cardRef = useRef(null);
|
|
449
|
+
const [config, setConfig] = useState([
|
|
450
|
+
{
|
|
451
|
+
type: 'heading',
|
|
452
|
+
data: 'Component to Image Demo',
|
|
453
|
+
style: { heading: 'HEADING_1', spacing: { after: 200 } }
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
type: 'paragraph',
|
|
457
|
+
data: 'Loading component images...',
|
|
458
|
+
meta: { size: 22 }
|
|
459
|
+
}
|
|
460
|
+
]);
|
|
461
|
+
|
|
462
|
+
useEffect(() => {
|
|
463
|
+
const captureComponents = async () => {
|
|
464
|
+
// Wait for components to render
|
|
465
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
466
|
+
|
|
467
|
+
// Capture the components as images
|
|
468
|
+
const images = await captureElementsAsImages([chartRef.current, cardRef.current]);
|
|
469
|
+
|
|
470
|
+
// Create new config with the captured images
|
|
471
|
+
const newConfig = [
|
|
472
|
+
{
|
|
473
|
+
type: 'heading',
|
|
474
|
+
data: 'Component to Image Demo',
|
|
475
|
+
style: { heading: 'HEADING_1', spacing: { after: 200 } }
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
type: 'paragraph',
|
|
479
|
+
data: 'Below are React components that were captured and converted to images using the captureElementsAsImages helper:',
|
|
480
|
+
meta: { size: 22 },
|
|
481
|
+
style: { spacing: { after: 300 } }
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
type: 'heading',
|
|
485
|
+
data: 'Chart Component',
|
|
486
|
+
style: { heading: 'HEADING_2', spacing: { after: 200 } }
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
type: 'image',
|
|
490
|
+
data: images[0], // Base64 image of the chart
|
|
491
|
+
style: {
|
|
492
|
+
width: 400,
|
|
493
|
+
height: 250,
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
type: 'paragraph',
|
|
498
|
+
data: 'The above chart was rendered as a React component and captured as an image.',
|
|
499
|
+
meta: { size: 20 },
|
|
500
|
+
style: { spacing: { before: 200, after: 300 } }
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
type: 'heading',
|
|
504
|
+
data: 'Card Component',
|
|
505
|
+
style: { heading: 'HEADING_2', spacing: { after: 200 } }
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
type: 'image',
|
|
509
|
+
data: images[1], // Base64 image of the card
|
|
510
|
+
style: {
|
|
511
|
+
width: 350,
|
|
512
|
+
height: 200,
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
type: 'paragraph',
|
|
517
|
+
data: 'The above card component was also captured and converted to an image for the document.',
|
|
518
|
+
meta: { size: 20 },
|
|
519
|
+
style: { spacing: { before: 200 } }
|
|
520
|
+
}
|
|
521
|
+
];
|
|
522
|
+
|
|
523
|
+
setConfig(newConfig);
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
captureComponents();
|
|
527
|
+
}, []);
|
|
528
|
+
|
|
529
|
+
return (
|
|
530
|
+
<div>
|
|
531
|
+
{/* Hidden components that will be captured as images */}
|
|
532
|
+
<div style={{ position: 'absolute', left: '-9999px', top: '-9999px' }}>
|
|
533
|
+
{/* Sample Chart Component */}
|
|
534
|
+
<div ref={chartRef} style={{
|
|
535
|
+
width: '600px',
|
|
536
|
+
height: '400px',
|
|
537
|
+
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
|
538
|
+
borderRadius: '10px',
|
|
539
|
+
padding: '30px',
|
|
540
|
+
boxShadow: '0 10px 30px rgba(0,0,0,0.2)',
|
|
541
|
+
color: 'white',
|
|
542
|
+
fontFamily: 'Arial, sans-serif'
|
|
543
|
+
}}>
|
|
544
|
+
<h2 style={{ margin: '0 0 20px 0', fontSize: '28px' }}>Performance Chart</h2>
|
|
545
|
+
<div style={{ display: 'flex', justifyContent: 'space-around', alignItems: 'flex-end', height: '250px', marginTop: '40px' }}>
|
|
546
|
+
<div style={{
|
|
547
|
+
width: '80px',
|
|
548
|
+
height: '60%',
|
|
549
|
+
background: 'rgba(255,255,255,0.8)',
|
|
550
|
+
borderRadius: '5px',
|
|
551
|
+
display: 'flex',
|
|
552
|
+
alignItems: 'flex-end',
|
|
553
|
+
justifyContent: 'center',
|
|
554
|
+
paddingBottom: '10px',
|
|
555
|
+
fontWeight: 'bold',
|
|
556
|
+
color: '#667eea'
|
|
557
|
+
}}>Q1</div>
|
|
558
|
+
<div style={{
|
|
559
|
+
width: '80px',
|
|
560
|
+
height: '75%',
|
|
561
|
+
background: 'rgba(255,255,255,0.8)',
|
|
562
|
+
borderRadius: '5px',
|
|
563
|
+
display: 'flex',
|
|
564
|
+
alignItems: 'flex-end',
|
|
565
|
+
justifyContent: 'center',
|
|
566
|
+
paddingBottom: '10px',
|
|
567
|
+
fontWeight: 'bold',
|
|
568
|
+
color: '#667eea'
|
|
569
|
+
}}>Q2</div>
|
|
570
|
+
<div style={{
|
|
571
|
+
width: '80px',
|
|
572
|
+
height: '85%',
|
|
573
|
+
background: 'rgba(255,255,255,0.8)',
|
|
574
|
+
borderRadius: '5px',
|
|
575
|
+
display: 'flex',
|
|
576
|
+
alignItems: 'flex-end',
|
|
577
|
+
justifyContent: 'center',
|
|
578
|
+
paddingBottom: '10px',
|
|
579
|
+
fontWeight: 'bold',
|
|
580
|
+
color: '#667eea'
|
|
581
|
+
}}>Q3</div>
|
|
582
|
+
<div style={{
|
|
583
|
+
width: '80px',
|
|
584
|
+
height: '95%',
|
|
585
|
+
background: 'rgba(255,255,255,0.8)',
|
|
586
|
+
borderRadius: '5px',
|
|
587
|
+
display: 'flex',
|
|
588
|
+
alignItems: 'flex-end',
|
|
589
|
+
justifyContent: 'center',
|
|
590
|
+
paddingBottom: '10px',
|
|
591
|
+
fontWeight: 'bold',
|
|
592
|
+
color: '#667eea'
|
|
593
|
+
}}>Q4</div>
|
|
594
|
+
</div>
|
|
595
|
+
</div>
|
|
596
|
+
|
|
597
|
+
{/* Sample Card Component */}
|
|
598
|
+
<div ref={cardRef} style={{
|
|
599
|
+
width: '500px',
|
|
600
|
+
height: '300px',
|
|
601
|
+
background: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
|
|
602
|
+
borderRadius: '15px',
|
|
603
|
+
padding: '40px',
|
|
604
|
+
boxShadow: '0 10px 30px rgba(0,0,0,0.2)',
|
|
605
|
+
color: 'white',
|
|
606
|
+
fontFamily: 'Arial, sans-serif',
|
|
607
|
+
display: 'flex',
|
|
608
|
+
flexDirection: 'column',
|
|
609
|
+
justifyContent: 'space-between'
|
|
610
|
+
}}>
|
|
611
|
+
<div>
|
|
612
|
+
<h2 style={{ margin: '0 0 15px 0', fontSize: '32px' }}>Dashboard Card</h2>
|
|
613
|
+
<p style={{ margin: '0', fontSize: '18px', opacity: 0.9 }}>Total Users: 1,234</p>
|
|
614
|
+
</div>
|
|
615
|
+
<div style={{
|
|
616
|
+
background: 'rgba(255,255,255,0.2)',
|
|
617
|
+
borderRadius: '10px',
|
|
618
|
+
padding: '20px',
|
|
619
|
+
backdropFilter: 'blur(10px)'
|
|
620
|
+
}}>
|
|
621
|
+
<div style={{ fontSize: '48px', fontWeight: 'bold', marginBottom: '5px' }}>+15%</div>
|
|
622
|
+
<div style={{ fontSize: '16px', opacity: 0.9 }}>Growth this month</div>
|
|
623
|
+
</div>
|
|
624
|
+
</div>
|
|
625
|
+
</div>
|
|
626
|
+
|
|
627
|
+
{/* The Word Document Preview */}
|
|
628
|
+
<WordDocumentPreview
|
|
629
|
+
title="Components to Images"
|
|
630
|
+
fileName="components-to-images.docx"
|
|
631
|
+
config={config}
|
|
632
|
+
/>
|
|
633
|
+
</div>
|
|
634
|
+
);
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
export const ComponentsToImagesExample = {
|
|
638
|
+
name: "Components to Images",
|
|
639
|
+
render: () => <ComponentToImageStory />
|
|
640
|
+
};
|