@openlettermarketing/olc-react-sdk 0.0.8 → 0.0.10

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 (135) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +18 -0
  3. package/.eslintrc.yml +47 -0
  4. package/.prettierignore +3 -0
  5. package/.prettierrc.yml +5 -0
  6. package/CHANGELOG.md +4 -0
  7. package/babel.config.json +10 -0
  8. package/build/index.js +2 -2
  9. package/build/index.js.map +1 -1
  10. package/examples/.eslintrc.yml +4 -0
  11. package/index.html +18 -0
  12. package/package.json +6 -6
  13. package/public/vite.svg +1 -0
  14. package/src/App.tsx +76 -0
  15. package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
  16. package/src/assets/images/input/cancel.tsx +20 -0
  17. package/src/assets/images/input/search.tsx +20 -0
  18. package/src/assets/images/modal-icons/cancelIcon.png +0 -0
  19. package/src/assets/images/modal-icons/del.tsx +19 -0
  20. package/src/assets/images/modal-icons/delete.svg +3 -0
  21. package/src/assets/images/modal-icons/modal-cross.tsx +23 -0
  22. package/src/assets/images/modal-icons/save.tsx +23 -0
  23. package/src/assets/images/templates/add-icon.svg +5 -0
  24. package/src/assets/images/templates/back-arrow.tsx +19 -0
  25. package/src/assets/images/templates/back-dialog-icon.png +0 -0
  26. package/src/assets/images/templates/back-dialog-icon.svg +3 -0
  27. package/src/assets/images/templates/barcode.png +0 -0
  28. package/src/assets/images/templates/bi-fold-self-mailers.tsx +28 -0
  29. package/src/assets/images/templates/black-trash-icon.svg +3 -0
  30. package/src/assets/images/templates/cancel.svg +4 -0
  31. package/src/assets/images/templates/cancelIcon.png +0 -0
  32. package/src/assets/images/templates/clipboard.svg +3 -0
  33. package/src/assets/images/templates/contact-search.svg +3 -0
  34. package/src/assets/images/templates/content-copy-icon.tsx +24 -0
  35. package/src/assets/images/templates/cross.svg +3 -0
  36. package/src/assets/images/templates/custom-template-icon-black.svg +3 -0
  37. package/src/assets/images/templates/custom-template-icon.svg +3 -0
  38. package/src/assets/images/templates/custom-template.tsx +23 -0
  39. package/src/assets/images/templates/dummy-template.svg +21 -0
  40. package/src/assets/images/templates/dynamic-field.tsx +119 -0
  41. package/src/assets/images/templates/edit-pencil-icon.tsx +21 -0
  42. package/src/assets/images/templates/filter-2.svg +13 -0
  43. package/src/assets/images/templates/info-icon.svg +12 -0
  44. package/src/assets/images/templates/info-icon.tsx +37 -0
  45. package/src/assets/images/templates/one-barcode.png +0 -0
  46. package/src/assets/images/templates/personal-letter.tsx +53 -0
  47. package/src/assets/images/templates/plus-icon.svg +5 -0
  48. package/src/assets/images/templates/postcard.tsx +32 -0
  49. package/src/assets/images/templates/professional-letter.tsx +53 -0
  50. package/src/assets/images/templates/real-penned-letters.tsx +57 -0
  51. package/src/assets/images/templates/search.svg +3 -0
  52. package/src/assets/images/templates/size-image-lg.tsx +20 -0
  53. package/src/assets/images/templates/size-image-mid.tsx +20 -0
  54. package/src/assets/images/templates/size-image.tsx +20 -0
  55. package/src/assets/images/templates/template-copy.svg +3 -0
  56. package/src/assets/images/templates/template-default-design.tsx +21 -0
  57. package/src/assets/images/templates/template-delete.svg +3 -0
  58. package/src/assets/images/templates/template-edit.svg +4 -0
  59. package/src/assets/images/templates/template-save-icon.svg +3 -0
  60. package/src/assets/images/templates/template-search-2.svg +9 -0
  61. package/src/assets/images/templates/template-search.svg +4 -0
  62. package/src/assets/images/templates/thumbnail.svg +10 -0
  63. package/src/assets/images/templates/trash-icon.svg +13 -0
  64. package/src/assets/images/templates/tri-fold-self-mailers.tsx +93 -0
  65. package/src/components/CreateTemplate/index.tsx +377 -0
  66. package/src/components/CreateTemplate/styles.scss +363 -0
  67. package/src/components/GenericUIBlocks/Button/index.tsx +21 -0
  68. package/src/components/GenericUIBlocks/Button/styles.scss +15 -0
  69. package/src/components/GenericUIBlocks/CircularProgress/index.tsx +18 -0
  70. package/src/components/GenericUIBlocks/CircularProgress/styles.scss +98 -0
  71. package/src/components/GenericUIBlocks/Dialog/index.tsx +127 -0
  72. package/src/components/GenericUIBlocks/Dialog/styles.scss +106 -0
  73. package/src/components/GenericUIBlocks/Divider/index.tsx +12 -0
  74. package/src/components/GenericUIBlocks/Divider/styles.scss +7 -0
  75. package/src/components/GenericUIBlocks/GeneralSelect/index.tsx +86 -0
  76. package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +77 -0
  77. package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +24 -0
  78. package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +9 -0
  79. package/src/components/GenericUIBlocks/GenericSnackbar/index.tsx +53 -0
  80. package/src/components/GenericUIBlocks/GenericSnackbar/styles.scss +34 -0
  81. package/src/components/GenericUIBlocks/Grid/index.tsx +82 -0
  82. package/src/components/GenericUIBlocks/Input/index.tsx +89 -0
  83. package/src/components/GenericUIBlocks/Input/styles.scss +80 -0
  84. package/src/components/GenericUIBlocks/Snackbar/index.tsx +66 -0
  85. package/src/components/GenericUIBlocks/Typography/index.tsx +18 -0
  86. package/src/components/GenericUIBlocks/Typography/styles.scss +27 -0
  87. package/src/components/SidePanel/customFields/customFieldSection.tsx +162 -0
  88. package/src/components/SidePanel/customFields/styles.scss +47 -0
  89. package/src/components/SidePanel/index.tsx +30 -0
  90. package/src/components/SidePanel/templates/customTemplateSection.tsx +505 -0
  91. package/src/components/SidePanel/templates/styles.scss +151 -0
  92. package/src/components/TemplateBuilder/index.tsx +295 -0
  93. package/src/components/TemplateBuilder/styles.scss +66 -0
  94. package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +58 -0
  95. package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +123 -0
  96. package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +98 -0
  97. package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +88 -0
  98. package/src/components/TopNavigation/SaveTemplateModel/index.tsx +60 -0
  99. package/src/components/TopNavigation/SaveTemplateModel/styles.scss +128 -0
  100. package/src/components/TopNavigation/index.tsx +388 -0
  101. package/src/components/TopNavigation/styles.scss +83 -0
  102. package/src/importMeta.d.ts +9 -0
  103. package/src/index.scss +130 -0
  104. package/src/index.tsx +82 -0
  105. package/src/libs/test.ts +7 -0
  106. package/src/redux/actions/action-types.ts +42 -0
  107. package/src/redux/actions/customFieldAction.ts +28 -0
  108. package/src/redux/actions/snackbarActions.ts +16 -0
  109. package/src/redux/actions/templateActions.ts +456 -0
  110. package/src/redux/reducers/customFieldReducer.ts +97 -0
  111. package/src/redux/reducers/index.ts +14 -0
  112. package/src/redux/reducers/snackbarReducer.ts +41 -0
  113. package/src/redux/reducers/templateReducer.ts +353 -0
  114. package/src/redux/store.ts +18 -0
  115. package/src/styles/colors.scss +61 -0
  116. package/src/test/mocks.js +89 -0
  117. package/src/test/setupJest.js +1 -0
  118. package/src/utils/api.ts +36 -0
  119. package/src/utils/constants.ts +40 -0
  120. package/src/utils/customStyles.ts +135 -0
  121. package/src/utils/fetchWrapper.ts +68 -0
  122. package/src/utils/fonts.json +1597 -0
  123. package/src/utils/helper.ts +19 -0
  124. package/src/utils/local-storage.ts +15 -0
  125. package/src/utils/message.ts +71 -0
  126. package/src/utils/template-builder.ts +147 -0
  127. package/src/utils/templateRestrictedArea/biFold.ts +433 -0
  128. package/src/utils/templateRestrictedArea/postCard.ts +439 -0
  129. package/src/utils/templateRestrictedArea/professional.ts +422 -0
  130. package/src/utils/templateRestrictedArea/realPenned.ts +283 -0
  131. package/src/utils/templateRestrictedArea/triFold.ts +434 -0
  132. package/tsconfig.json +29 -0
  133. package/tsconfig.node.json +12 -0
  134. package/vite.config.ts +8 -0
  135. package/webpack.config.js +80 -0
@@ -0,0 +1,439 @@
1
+ import { DPI } from "../constants";
2
+
3
+ // Define the type for the element being added
4
+ interface Element {
5
+ id: string;
6
+ type: string;
7
+ name: string;
8
+ opacity: number;
9
+ visible: boolean;
10
+ selectable: boolean;
11
+ removable: boolean;
12
+ alwaysOnTop: boolean;
13
+ showInExport: boolean;
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ rotation: number;
19
+ animations?: any[];
20
+ blurEnabled?: boolean;
21
+ blurRadius?: number;
22
+ brightnessEnabled?: boolean;
23
+ brightness?: number;
24
+ sepiaEnabled?: boolean;
25
+ grayscaleEnabled?: boolean;
26
+ shadowEnabled?: boolean;
27
+ shadowBlur?: number;
28
+ shadowOffsetX?: number;
29
+ shadowOffsetY?: number;
30
+ shadowColor?: string;
31
+ shadowOpacity?: number;
32
+ draggable?: boolean;
33
+ resizable?: boolean;
34
+ contentEditable: boolean;
35
+ styleEditable: boolean;
36
+ subType?: string;
37
+ fill?: string;
38
+ dash?: any[];
39
+ strokeWidth?: number;
40
+ stroke?: string;
41
+ cornerRadius?: number;
42
+ text?: string;
43
+ placeholder?: string;
44
+ fontSize?: number;
45
+ fontFamily?: string;
46
+ fontStyle?: string;
47
+ fontWeight?: string;
48
+ textDecoration?: string;
49
+ align?: string;
50
+ verticalAlign?: string;
51
+ lineHeight?: number;
52
+ letterSpacing?: number;
53
+ backgroundEnabled?: boolean;
54
+ backgroundColor?: string;
55
+ backgroundOpacity?: number;
56
+ backgroundCornerRadius?: number;
57
+ backgroundPadding?: number;
58
+ src?: string;
59
+ cropX?: number;
60
+ cropY?: number;
61
+ cropWidth?: number;
62
+ cropHeight?: number;
63
+ flipX?: boolean;
64
+ flipY?: boolean;
65
+ clipSrc?: string;
66
+ borderSize?: number;
67
+ keepRatio?: boolean;
68
+ }
69
+
70
+ // Define the type for the page
71
+ interface Page {
72
+ addElement: (element: Element) => void;
73
+ }
74
+
75
+ // Define the type for the store
76
+ interface Store {
77
+ width: number;
78
+ height: number;
79
+ pages: Page[];
80
+ history: {
81
+ clear: () => void;
82
+ };
83
+ }
84
+
85
+
86
+ // Define the function
87
+ export const addRestrictedAreaToPostCard = (
88
+ store: Store,
89
+ size: [number, number],
90
+ barcodeSrc: string,
91
+ ): void => {
92
+ const page = store.pages[1];
93
+
94
+ const elements: Element[] = [
95
+ {
96
+ id: 'figure-1',
97
+ type: 'figure',
98
+ name: '',
99
+ opacity: 1,
100
+ visible: true,
101
+ selectable: false,
102
+ removable: false,
103
+ alwaysOnTop: true,
104
+ showInExport: true,
105
+ x: store.width - size[0] * DPI - 0.15 * DPI,
106
+ y: store.height - size[1] * DPI - 0.125 * DPI,
107
+ width: size[0] * DPI,
108
+ height: size[1] * DPI,
109
+ rotation: 0,
110
+ animations: [],
111
+ blurEnabled: false,
112
+ blurRadius: 10,
113
+ brightnessEnabled: false,
114
+ brightness: 0,
115
+ sepiaEnabled: false,
116
+ grayscaleEnabled: false,
117
+ shadowEnabled: false,
118
+ shadowBlur: 5,
119
+ shadowOffsetX: 0,
120
+ shadowOffsetY: 0,
121
+ shadowColor: 'black',
122
+ shadowOpacity: 1,
123
+ draggable: false,
124
+ resizable: false,
125
+ contentEditable: false,
126
+ styleEditable: false,
127
+ subType: 'rect',
128
+ fill: 'white',
129
+ dash: [],
130
+ strokeWidth: 0,
131
+ stroke: '#0c0c0c',
132
+ cornerRadius: 0,
133
+ },
134
+ {
135
+ id: 'return-address',
136
+ type: 'text',
137
+ name: '',
138
+ opacity: 1,
139
+ visible: true,
140
+ selectable: false,
141
+ removable: false,
142
+ alwaysOnTop: true,
143
+ showInExport: true,
144
+ x: store.width - size[0] * DPI - 0.15 * DPI + 10,
145
+ y: store.height - size[1] * DPI - 0.125 * DPI + 20,
146
+ width: 240,
147
+ height: 20,
148
+ rotation: 0,
149
+ animations: [],
150
+ blurEnabled: false,
151
+ blurRadius: 10,
152
+ brightnessEnabled: false,
153
+ brightness: 0,
154
+ sepiaEnabled: false,
155
+ grayscaleEnabled: false,
156
+ shadowEnabled: false,
157
+ shadowBlur: 5,
158
+ shadowOffsetX: 0,
159
+ shadowOffsetY: 0,
160
+ shadowColor: 'black',
161
+ shadowOpacity: 1,
162
+ draggable: false,
163
+ resizable: false,
164
+ contentEditable: false,
165
+ styleEditable: false,
166
+ text: 'YOUR RETURN ADDRESS \nWILL AUTOMATICALLY \nBE PRINTED IN THIS \nPOSITION',
167
+ placeholder: '',
168
+ fontSize: 12,
169
+ fontFamily: 'Roboto',
170
+ fontStyle: 'normal',
171
+ fontWeight: 'normal',
172
+ textDecoration: '',
173
+ fill: 'black',
174
+ align: 'start',
175
+ verticalAlign: 'top',
176
+ strokeWidth: 0,
177
+ stroke: 'black',
178
+ lineHeight: 1.2,
179
+ letterSpacing: 0,
180
+ backgroundEnabled: false,
181
+ backgroundColor: '#7ED321',
182
+ backgroundOpacity: 1,
183
+ backgroundCornerRadius: 0.5,
184
+ backgroundPadding: 0.5,
185
+ },
186
+ {
187
+ id: 'indicia',
188
+ type: 'text',
189
+ name: '',
190
+ opacity: 1,
191
+ visible: true,
192
+ selectable: false,
193
+ removable: false,
194
+ alwaysOnTop: true,
195
+ showInExport: true,
196
+ x: store.width - 111 - 0.15 * DPI,
197
+ y: store.height - size[1] * DPI + 10,
198
+ width: 111,
199
+ height: 40,
200
+ rotation: 0,
201
+ animations: [],
202
+ blurEnabled: false,
203
+ blurRadius: 10,
204
+ brightnessEnabled: false,
205
+ brightness: 0,
206
+ sepiaEnabled: false,
207
+ grayscaleEnabled: false,
208
+ shadowEnabled: false,
209
+ shadowBlur: 5,
210
+ shadowOffsetX: 0,
211
+ shadowOffsetY: 0,
212
+ shadowColor: 'black',
213
+ shadowOpacity: 1,
214
+ draggable: false,
215
+ resizable: false,
216
+ contentEditable: false,
217
+ styleEditable: false,
218
+ text: `POSTAGE\nINDICIA`,
219
+ placeholder: '',
220
+ fontSize: 12,
221
+ fontFamily: 'Roboto',
222
+ fontStyle: 'normal',
223
+ fontWeight: 'normal',
224
+ textDecoration: '',
225
+ fill: 'black',
226
+ align: 'center',
227
+ verticalAlign: 'top',
228
+ strokeWidth: 0,
229
+ stroke: 'black',
230
+ lineHeight: 1.2,
231
+ letterSpacing: 0,
232
+ backgroundEnabled: false,
233
+ backgroundColor: '#7ED321',
234
+ backgroundOpacity: 1,
235
+ backgroundCornerRadius: 0.5,
236
+ backgroundPadding: 0.5,
237
+ },
238
+ {
239
+ id: 'barcode',
240
+ type: 'image',
241
+ name: '',
242
+ opacity: 1,
243
+ visible: true,
244
+ selectable: false,
245
+ removable: false,
246
+ alwaysOnTop: true,
247
+ showInExport: true,
248
+ y: store.height - 12 - size[1] * DPI + 110,
249
+ x: store.width - size[0] * DPI - 0.15 * DPI + 40,
250
+ width: size[0] * DPI - 80,
251
+ height: 12,
252
+ rotation: 0,
253
+ animations: [],
254
+ blurEnabled: false,
255
+ brightnessEnabled: false,
256
+ brightness: 0,
257
+ sepiaEnabled: false,
258
+ grayscaleEnabled: false,
259
+ shadowEnabled: false,
260
+ shadowOffsetX: 0,
261
+ shadowOffsetY: 0,
262
+ shadowOpacity: 1,
263
+ draggable: false,
264
+ resizable: false,
265
+ contentEditable: false,
266
+ styleEditable: false,
267
+ src: barcodeSrc,
268
+ cropX: 0,
269
+ cropY: 0,
270
+ cropWidth: 1,
271
+ cropHeight: 1,
272
+ cornerRadius: 0,
273
+ flipX: false,
274
+ flipY: false,
275
+ clipSrc: '',
276
+ borderSize: 0,
277
+ keepRatio: false,
278
+ },
279
+ {
280
+ id: 'recipient-address',
281
+ type: 'text',
282
+ name: '',
283
+ opacity: 1,
284
+ visible: true,
285
+ selectable: false,
286
+ removable: false,
287
+ alwaysOnTop: true,
288
+ showInExport: true,
289
+ x: store.width - size[0] * DPI - 0.15 * DPI + 10,
290
+ y: store.height - size[1] * DPI - 0.125 * DPI + 150,
291
+ width: 240,
292
+ height: 20,
293
+ rotation: 0,
294
+ animations: [],
295
+ blurEnabled: false,
296
+ blurRadius: 10,
297
+ brightnessEnabled: false,
298
+ brightness: 0,
299
+ sepiaEnabled: false,
300
+ grayscaleEnabled: false,
301
+ shadowEnabled: false,
302
+ shadowBlur: 5,
303
+ shadowOffsetX: 0,
304
+ shadowOffsetY: 0,
305
+ shadowColor: 'black',
306
+ shadowOpacity: 1,
307
+ draggable: false,
308
+ resizable: false,
309
+ contentEditable: false,
310
+ styleEditable: false,
311
+ text: 'RECIPIENT ADDRESS \nWILL AUTOMATICALLY \nBE PRINTED IN THIS \nPOSITION',
312
+ placeholder: '',
313
+ fontSize: 12,
314
+ fontFamily: 'Roboto',
315
+ fontStyle: 'normal',
316
+ fontWeight: 'normal',
317
+ textDecoration: '',
318
+ fill: 'black',
319
+ align: 'start',
320
+ verticalAlign: 'top',
321
+ strokeWidth: 0,
322
+ stroke: 'black',
323
+ lineHeight: 1.2,
324
+ letterSpacing: 0,
325
+ backgroundEnabled: false,
326
+ backgroundColor: '#7ED321',
327
+ backgroundOpacity: 1,
328
+ backgroundCornerRadius: 0.5,
329
+ backgroundPadding: 0.5,
330
+ },
331
+ {
332
+ id: 'sequence',
333
+ type: 'text',
334
+ name: '',
335
+ opacity: 1,
336
+ visible: true,
337
+ selectable: false,
338
+ removable: false,
339
+ alwaysOnTop: true,
340
+ showInExport: true,
341
+ x: store.width - 111 - 0.15 * DPI,
342
+ y: store.height - size[1] * DPI + 170,
343
+ width: 111,
344
+ height: 40,
345
+ rotation: 0,
346
+ animations: [],
347
+ blurEnabled: false,
348
+ blurRadius: 10,
349
+ brightnessEnabled: false,
350
+ brightness: 0,
351
+ sepiaEnabled: false,
352
+ grayscaleEnabled: false,
353
+ shadowEnabled: false,
354
+ shadowBlur: 5,
355
+ shadowOffsetX: 0,
356
+ shadowOffsetY: 0,
357
+ shadowColor: 'black',
358
+ shadowOpacity: 1,
359
+ draggable: false,
360
+ resizable: false,
361
+ contentEditable: false,
362
+ styleEditable: false,
363
+ text: `Sequence`,
364
+ placeholder: '',
365
+ fontSize: 8,
366
+ fontFamily: 'Roboto',
367
+ fontStyle: 'normal',
368
+ fontWeight: 'normal',
369
+ textDecoration: '',
370
+ fill: 'black',
371
+ align: 'center',
372
+ verticalAlign: 'top',
373
+ strokeWidth: 0,
374
+ stroke: 'black',
375
+ lineHeight: 1.2,
376
+ letterSpacing: 0,
377
+ backgroundEnabled: false,
378
+ backgroundColor: '#7ED321',
379
+ backgroundOpacity: 1,
380
+ backgroundCornerRadius: 0.5,
381
+ backgroundPadding: 0.5,
382
+ },
383
+ {
384
+ id: 'contId',
385
+ type: 'text',
386
+ name: '',
387
+ opacity: 1,
388
+ visible: true,
389
+ selectable: false,
390
+ removable: false,
391
+ alwaysOnTop: true,
392
+ showInExport: true,
393
+ x: store.width - 111 - 0.15 * DPI,
394
+ y: store.height - size[1] * DPI + 180,
395
+ width: 111,
396
+ height: 40,
397
+ rotation: 0,
398
+ animations: [],
399
+ blurEnabled: false,
400
+ blurRadius: 10,
401
+ brightnessEnabled: false,
402
+ brightness: 0,
403
+ sepiaEnabled: false,
404
+ grayscaleEnabled: false,
405
+ shadowEnabled: false,
406
+ shadowBlur: 5,
407
+ shadowOffsetX: 0,
408
+ shadowOffsetY: 0,
409
+ shadowColor: 'black',
410
+ shadowOpacity: 1,
411
+ draggable: false,
412
+ resizable: false,
413
+ contentEditable: false,
414
+ styleEditable: false,
415
+ text: `Cont ID`,
416
+ placeholder: '',
417
+ fontSize: 8,
418
+ fontFamily: 'Roboto',
419
+ fontStyle: 'normal',
420
+ fontWeight: 'normal',
421
+ textDecoration: '',
422
+ fill: 'black',
423
+ align: 'center',
424
+ verticalAlign: 'top',
425
+ strokeWidth: 0,
426
+ stroke: 'black',
427
+ lineHeight: 1.2,
428
+ letterSpacing: 0,
429
+ backgroundEnabled: false,
430
+ backgroundColor: '#7ED321',
431
+ backgroundOpacity: 1,
432
+ backgroundCornerRadius: 0.5,
433
+ backgroundPadding: 0.5,
434
+ }
435
+ ];
436
+
437
+ elements.forEach(element => page.addElement(element));
438
+ store.history.clear();
439
+ };