@openlettermarketing/olc-react-sdk 2.1.7 → 2.1.8

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 (230) hide show
  1. package/build/index.js +1 -1
  2. package/build/index.js.map +1 -1
  3. package/build/types/version.d.ts +1 -1
  4. package/package.json +7 -6
  5. package/.eslintignore +0 -1
  6. package/.eslintrc.cjs +0 -18
  7. package/.eslintrc.yml +0 -47
  8. package/.github/workflows/publish-beta.yml +0 -154
  9. package/.github/workflows/publish-production.yml +0 -143
  10. package/.prettierignore +0 -3
  11. package/.prettierrc.yml +0 -5
  12. package/CHANGELOG.md +0 -4
  13. package/babel.config.json +0 -10
  14. package/examples/.eslintrc.yml +0 -4
  15. package/index.html +0 -18
  16. package/public/vite.svg +0 -1
  17. package/src/App.tsx +0 -209
  18. package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
  19. package/src/assets/images/create-template/prebuilt.svg +0 -13
  20. package/src/assets/images/create-template/scratch.svg +0 -4
  21. package/src/assets/images/input/cancel.tsx +0 -20
  22. package/src/assets/images/input/search.tsx +0 -20
  23. package/src/assets/images/input/select-cancel.tsx +0 -17
  24. package/src/assets/images/modal-icons/add.tsx +0 -36
  25. package/src/assets/images/modal-icons/cancel-file.tsx +0 -12
  26. package/src/assets/images/modal-icons/cancel-input.tsx +0 -13
  27. package/src/assets/images/modal-icons/cancel.tsx +0 -35
  28. package/src/assets/images/modal-icons/close-new.svg +0 -3
  29. package/src/assets/images/modal-icons/confirm-close-icon.tsx +0 -14
  30. package/src/assets/images/modal-icons/confirm-new.tsx +0 -22
  31. package/src/assets/images/modal-icons/confirm.svg +0 -12
  32. package/src/assets/images/modal-icons/cross.tsx +0 -23
  33. package/src/assets/images/modal-icons/del.tsx +0 -19
  34. package/src/assets/images/modal-icons/design-icon.tsx +0 -22
  35. package/src/assets/images/modal-icons/doc.tsx +0 -43
  36. package/src/assets/images/modal-icons/docx.tsx +0 -43
  37. package/src/assets/images/modal-icons/envelope-icon.tsx +0 -26
  38. package/src/assets/images/modal-icons/info.tsx +0 -19
  39. package/src/assets/images/modal-icons/jpeg.tsx +0 -43
  40. package/src/assets/images/modal-icons/jpg.tsx +0 -43
  41. package/src/assets/images/modal-icons/modal-cros.svg +0 -4
  42. package/src/assets/images/modal-icons/modal-cross.tsx +0 -37
  43. package/src/assets/images/modal-icons/new-cancel.tsx +0 -11
  44. package/src/assets/images/modal-icons/order-download.tsx +0 -42
  45. package/src/assets/images/modal-icons/pdf.tsx +0 -51
  46. package/src/assets/images/modal-icons/png.tsx +0 -43
  47. package/src/assets/images/modal-icons/save.tsx +0 -23
  48. package/src/assets/images/modal-icons/template-copy.tsx +0 -25
  49. package/src/assets/images/modal-icons/tool-cancel.tsx +0 -25
  50. package/src/assets/images/products/bi-new.svg +0 -23
  51. package/src/assets/images/products/left-arrow.svg +0 -17
  52. package/src/assets/images/products/personal-new.tsx +0 -31
  53. package/src/assets/images/products/postcard-new.tsx +0 -27
  54. package/src/assets/images/products/professional-new.tsx +0 -24
  55. package/src/assets/images/products/real-new.tsx +0 -30
  56. package/src/assets/images/products/right-arrow.svg +0 -17
  57. package/src/assets/images/products/snap-new.svg +0 -31
  58. package/src/assets/images/templates/actions.svg +0 -3
  59. package/src/assets/images/templates/address-block-icon.tsx +0 -62
  60. package/src/assets/images/templates/archive.svg +0 -3
  61. package/src/assets/images/templates/arrow-down.tsx +0 -27
  62. package/src/assets/images/templates/back-arrow.tsx +0 -19
  63. package/src/assets/images/templates/bi-fold-self-mailers.tsx +0 -28
  64. package/src/assets/images/templates/check.svg +0 -3
  65. package/src/assets/images/templates/code.svg +0 -10
  66. package/src/assets/images/templates/content-copy-icon.tsx +0 -24
  67. package/src/assets/images/templates/custom-add-on-icon.tsx +0 -18
  68. package/src/assets/images/templates/custom-qr-section-icon.tsx +0 -9
  69. package/src/assets/images/templates/custom-template.tsx +0 -23
  70. package/src/assets/images/templates/designer.tsx +0 -43
  71. package/src/assets/images/templates/dot.tsx +0 -22
  72. package/src/assets/images/templates/download-v2.svg +0 -4
  73. package/src/assets/images/templates/download.svg +0 -4
  74. package/src/assets/images/templates/dummy-template.tsx +0 -76
  75. package/src/assets/images/templates/dynamic-field.tsx +0 -119
  76. package/src/assets/images/templates/edit-pencil-icon.tsx +0 -21
  77. package/src/assets/images/templates/edit.svg +0 -3
  78. package/src/assets/images/templates/epo-icon.tsx +0 -16
  79. package/src/assets/images/templates/field.tsx +0 -29
  80. package/src/assets/images/templates/gsv-icon.tsx +0 -31
  81. package/src/assets/images/templates/info-icon.tsx +0 -37
  82. package/src/assets/images/templates/left-arrow.svg +0 -17
  83. package/src/assets/images/templates/pencil.svg +0 -3
  84. package/src/assets/images/templates/personal-letter.tsx +0 -53
  85. package/src/assets/images/templates/postcard.tsx +0 -32
  86. package/src/assets/images/templates/professional-letter.tsx +0 -53
  87. package/src/assets/images/templates/qr-code.tsx +0 -13
  88. package/src/assets/images/templates/real-penned-letters.tsx +0 -57
  89. package/src/assets/images/templates/right-arrow.svg +0 -17
  90. package/src/assets/images/templates/size-image-lg.tsx +0 -20
  91. package/src/assets/images/templates/size-image-mid.tsx +0 -20
  92. package/src/assets/images/templates/size-image-xl.tsx +0 -20
  93. package/src/assets/images/templates/size-image.tsx +0 -20
  94. package/src/assets/images/templates/snap-pack.tsx +0 -67
  95. package/src/assets/images/templates/template-default-design.tsx +0 -21
  96. package/src/assets/images/templates/trash-upload.svg +0 -3
  97. package/src/assets/images/templates/trash.svg +0 -3
  98. package/src/assets/images/templates/tri-fold-self-mailers.tsx +0 -93
  99. package/src/assets/images/templates/upload-image.svg +0 -10
  100. package/src/assets/images/templates/x.svg +0 -3
  101. package/src/assets/images/thumbnails/one.svg +0 -9
  102. package/src/assets/images/tooltip/tool-arrow.tsx +0 -25
  103. package/src/components/CreateTemplate/V2/index.tsx +0 -527
  104. package/src/components/CreateTemplate/V2/styles.scss +0 -372
  105. package/src/components/CreateTemplate/index.tsx +0 -508
  106. package/src/components/CreateTemplate/styles.scss +0 -404
  107. package/src/components/GenericUIBlocks/Button/index.tsx +0 -54
  108. package/src/components/GenericUIBlocks/Button/styles.scss +0 -43
  109. package/src/components/GenericUIBlocks/CircularProgress/index.tsx +0 -18
  110. package/src/components/GenericUIBlocks/CircularProgress/styles.scss +0 -93
  111. package/src/components/GenericUIBlocks/CustomTooltip/index.tsx +0 -88
  112. package/src/components/GenericUIBlocks/CustomTooltip/styles.scss +0 -19
  113. package/src/components/GenericUIBlocks/Dialog/V2/index.tsx +0 -227
  114. package/src/components/GenericUIBlocks/Dialog/V2/styles.scss +0 -289
  115. package/src/components/GenericUIBlocks/Dialog/index.tsx +0 -185
  116. package/src/components/GenericUIBlocks/Dialog/styles.scss +0 -227
  117. package/src/components/GenericUIBlocks/Divider/index.tsx +0 -12
  118. package/src/components/GenericUIBlocks/Divider/styles.scss +0 -7
  119. package/src/components/GenericUIBlocks/GeneralSelect/index.tsx +0 -114
  120. package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +0 -406
  121. package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +0 -25
  122. package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +0 -20
  123. package/src/components/GenericUIBlocks/GenericSnackbar/Toast/index.tsx +0 -91
  124. package/src/components/GenericUIBlocks/GenericSnackbar/Toast/styles.scss +0 -92
  125. package/src/components/GenericUIBlocks/Grid/index.tsx +0 -82
  126. package/src/components/GenericUIBlocks/Input/index.tsx +0 -269
  127. package/src/components/GenericUIBlocks/Input/styles.scss +0 -332
  128. package/src/components/GenericUIBlocks/Tabs/index.tsx +0 -71
  129. package/src/components/GenericUIBlocks/Tabs/styles.scss +0 -42
  130. package/src/components/GenericUIBlocks/Typography/index.tsx +0 -18
  131. package/src/components/GenericUIBlocks/Typography/styles.scss +0 -27
  132. package/src/components/SidePanel/CustomAddOns/index.tsx +0 -342
  133. package/src/components/SidePanel/CustomAddOns/styles.scss +0 -86
  134. package/src/components/SidePanel/CustomBlockColors/index.tsx +0 -211
  135. package/src/components/SidePanel/CustomBlockColors/styles.scss +0 -80
  136. package/src/components/SidePanel/CustomFields/customFieldSection.tsx +0 -547
  137. package/src/components/SidePanel/CustomFields/styles.scss +0 -64
  138. package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/index.tsx +0 -172
  139. package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/styles.scss +0 -46
  140. package/src/components/SidePanel/CustomQRCode/index.tsx +0 -1070
  141. package/src/components/SidePanel/CustomQRCode/styles.scss +0 -149
  142. package/src/components/SidePanel/CustomUploads/V2/index.tsx +0 -542
  143. package/src/components/SidePanel/CustomUploads/V2/styles.scss +0 -267
  144. package/src/components/SidePanel/CustomUploads/index.tsx +0 -301
  145. package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/index.tsx +0 -424
  146. package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/styles.scss +0 -180
  147. package/src/components/SidePanel/Templates/ModalGallery/V2/index.tsx +0 -235
  148. package/src/components/SidePanel/Templates/ModalGallery/V2/styles.scss +0 -244
  149. package/src/components/SidePanel/Templates/ModalGallery/index.tsx +0 -231
  150. package/src/components/SidePanel/Templates/SideBarGallery/index.tsx +0 -233
  151. package/src/components/SidePanel/Templates/SideBarGallery/styles.scss +0 -152
  152. package/src/components/SidePanel/Templates/TemplatesCard/V2/index.tsx +0 -149
  153. package/src/components/SidePanel/Templates/TemplatesCard/V2/styles.scss +0 -156
  154. package/src/components/SidePanel/Templates/TemplatesCard/index.tsx +0 -160
  155. package/src/components/SidePanel/Templates/TemplatesCard/styles.scss +0 -98
  156. package/src/components/SidePanel/Templates/customTemplateSection.tsx +0 -793
  157. package/src/components/SidePanel/Templates/styles.scss +0 -244
  158. package/src/components/SidePanel/index.tsx +0 -160
  159. package/src/components/TemplateBuilder/index.tsx +0 -585
  160. package/src/components/TemplateBuilder/styles.scss +0 -100
  161. package/src/components/TemplateTypes/index.tsx +0 -96
  162. package/src/components/TemplateTypes/styles.scss +0 -91
  163. package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +0 -81
  164. package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +0 -123
  165. package/src/components/TopNavigation/DuplicateTemplateModal.tsx +0 -103
  166. package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +0 -71
  167. package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +0 -88
  168. package/src/components/TopNavigation/SaveTemplateModel/index.tsx +0 -201
  169. package/src/components/TopNavigation/SaveTemplateModel/styles.scss +0 -128
  170. package/src/components/TopNavigation/index.tsx +0 -938
  171. package/src/components/TopNavigation/styles.scss +0 -303
  172. package/src/importMeta.d.ts +0 -31
  173. package/src/index.scss +0 -131
  174. package/src/index.tsx +0 -238
  175. package/src/libs/test.ts +0 -7
  176. package/src/redux/actions/action-types.ts +0 -52
  177. package/src/redux/actions/customQRCodeActions.ts +0 -54
  178. package/src/redux/actions/snackbarActions.ts +0 -16
  179. package/src/redux/actions/templateActions.ts +0 -236
  180. package/src/redux/reducers/customFieldReducer.ts +0 -99
  181. package/src/redux/reducers/customQRCodeReducer.ts +0 -58
  182. package/src/redux/reducers/index.ts +0 -15
  183. package/src/redux/reducers/snackbarReducer.ts +0 -40
  184. package/src/redux/reducers/templateReducer.ts +0 -485
  185. package/src/redux/store.ts +0 -18
  186. package/src/styles/colors.scss +0 -61
  187. package/src/test/mocks.js +0 -89
  188. package/src/test/setupJest.js +0 -1
  189. package/src/utils/api.ts +0 -36
  190. package/src/utils/constants.ts +0 -182
  191. package/src/utils/customStyles.ts +0 -45
  192. package/src/utils/fetchWrapper.ts +0 -73
  193. package/src/utils/fonts.json +0 -1597
  194. package/src/utils/helper.ts +0 -205
  195. package/src/utils/local-storage.ts +0 -15
  196. package/src/utils/message.ts +0 -162
  197. package/src/utils/products.ts +0 -186
  198. package/src/utils/template-builder.ts +0 -328
  199. package/src/utils/templateIdentifierArea/biFold.ts +0 -107
  200. package/src/utils/templateIdentifierArea/index.ts +0 -35
  201. package/src/utils/templateIdentifierArea/personal.ts +0 -107
  202. package/src/utils/templateIdentifierArea/postCards.ts +0 -163
  203. package/src/utils/templateIdentifierArea/professional.ts +0 -125
  204. package/src/utils/templateIdentifierArea/snapPack.ts +0 -107
  205. package/src/utils/templateIdentifierArea/triFold.ts +0 -107
  206. package/src/utils/templateRestrictedArea/biFold.ts +0 -329
  207. package/src/utils/templateRestrictedArea/nonWindowProfessional.ts +0 -90
  208. package/src/utils/templateRestrictedArea/personal.ts +0 -90
  209. package/src/utils/templateRestrictedArea/postCard.ts +0 -334
  210. package/src/utils/templateRestrictedArea/postCardJumbo.tsx +0 -408
  211. package/src/utils/templateRestrictedArea/professional.ts +0 -318
  212. package/src/utils/templateRestrictedArea/realPenned.ts +0 -233
  213. package/src/utils/templateRestrictedArea/snapPack.ts +0 -1009
  214. package/src/utils/templateRestrictedArea/triFold.ts +0 -330
  215. package/src/utils/templateSafetyBorders/biFold.ts +0 -91
  216. package/src/utils/templateSafetyBorders/index.ts +0 -43
  217. package/src/utils/templateSafetyBorders/personal.ts +0 -41
  218. package/src/utils/templateSafetyBorders/postCards.ts +0 -259
  219. package/src/utils/templateSafetyBorders/professional.ts +0 -78
  220. package/src/utils/templateSafetyBorders/snapPack.ts +0 -165
  221. package/src/utils/templateSafetyBorders/triFold.ts +0 -114
  222. package/src/utils/templateSafetyBorders/types.d.ts +0 -68
  223. package/src/utils/types.ts +0 -12
  224. package/src/v2Theme.scss +0 -142
  225. package/tsconfig.json +0 -29
  226. package/tsconfig.node.json +0 -12
  227. package/update-version.js +0 -23
  228. package/version.js +0 -1
  229. package/vite.config.ts +0 -8
  230. package/webpack.config.js +0 -80
@@ -1,267 +0,0 @@
1
- .custom-uploads-v2 {
2
- height: 100%;
3
- display: flex;
4
- flex-direction: column;
5
- font-family: var(--font-family);
6
- padding: 14px;
7
-
8
- .upload-header {
9
- margin-bottom: 20px;
10
-
11
- .upload-title {
12
- font-size: 14px;
13
- margin-bottom: 12px;
14
- padding-top: 5px;
15
- color: #1c2127;
16
- }
17
-
18
- .upload-constraints {
19
- .format-text, .size-text {
20
- font-size: 12px;
21
- font-weight: 500 !important;
22
- font-family: var(--font-family);
23
- color: #000;
24
- margin-bottom: 4px;
25
- }
26
-
27
- .quality-note {
28
- font-size: 12px;
29
- font-weight: 400 !important;
30
- color: #00000066;
31
- }
32
- }
33
- }
34
-
35
- .upload-section {
36
- margin-bottom: 16px;
37
-
38
- .file-input {
39
- display: none;
40
- }
41
-
42
- .upload-button {
43
- display: flex;
44
- align-items: center;
45
- justify-content: center;
46
- gap: 8px;
47
- width: 100%;
48
- padding: 10px 16px;
49
- background-color: #FFFFFF;
50
- border: 0.5px solid #0000003D;
51
- border-radius: 4px;
52
- box-shadow: 0px 2px 6px 0px #0000000A;
53
- color: #000;
54
- font-size: 14px;
55
- font-weight: 400;
56
- cursor: pointer;
57
- transition: all 0.15s ease;
58
-
59
- &:hover{
60
- background-color: #f5f5f5;
61
- }
62
-
63
- &:focus:not(:disabled) {
64
- background-color: #ffffff;
65
- outline: none;
66
- }
67
-
68
- &:active:not(:disabled) {
69
- background-color: #f5f5f5;
70
- }
71
-
72
- &.uploading,
73
- &:disabled {
74
- cursor: not-allowed;
75
- opacity: 0.6;
76
- background-color: #f6f7f9;
77
- }
78
-
79
- svg {
80
- width: 16px;
81
- height: 16px;
82
- color: #5c7080;
83
- flex-shrink: 0;
84
- }
85
-
86
- .button-text {
87
- color: #1c2127;
88
- font-weight: 500;
89
- }
90
- }
91
- }
92
-
93
- .images-grid {
94
- display: grid;
95
- grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
96
- gap: 12px;
97
- overflow-y: auto;
98
-
99
- .loading-state, .empty-state {
100
- grid-column: 1 / -1;
101
- text-align: center;
102
- padding: 40px 20px;
103
- color: #6a737d;
104
- font-size: 14px;
105
- }
106
-
107
- .image-item {
108
- position: relative;
109
-
110
- .image-wrapper {
111
- position: relative;
112
- border-radius: 6px;
113
- overflow: hidden;
114
- cursor: pointer;
115
- transition: transform 0.2s ease;
116
- background: #f6f8fa;
117
- border: 1px solid #e1e4e8;
118
-
119
- &:hover {
120
- transform: translateY(-2px);
121
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
122
-
123
- .image-menu {
124
- opacity: 1;
125
- }
126
- }
127
-
128
- .image-preview {
129
- width: 100%;
130
- height: 120px;
131
- object-fit: cover;
132
- display: block;
133
- }
134
-
135
- .image-menu {
136
- position: absolute;
137
- top: 8px;
138
- right: 8px;
139
- opacity: 0;
140
- transition: opacity 0.2s ease;
141
- cursor: pointer;
142
- z-index: 2;
143
-
144
- .menu-dots {
145
- display: flex;
146
- flex-direction: row;
147
- align-items: center;
148
- gap: 2px;
149
- padding: 4px;
150
- background: #fff;
151
- border-radius: 4px;
152
- backdrop-filter: blur(4px);
153
- width: 16px;
154
- height: 16px;
155
- border-radius: 4px;
156
-
157
- span {
158
- width: 1.6px;
159
- height: 1.6px;
160
- background: #28303F;
161
- border-radius: 50%;
162
- }
163
- }
164
-
165
- &:hover .menu-dots {
166
- background: #fff;
167
- }
168
- }
169
- }
170
-
171
- .dropdown-menu {
172
- position: absolute;
173
- top: 32px;
174
- right: 0px;
175
- background: white;
176
- border: 1px solid #e1e4e8;
177
- border-radius: 4px;
178
- box-shadow: 2px 8px 24px 0px #00000029;
179
- z-index: 1000;
180
- min-width: 120px;
181
- overflow: hidden;
182
- padding: 12px 8px;
183
- display: flex;
184
- flex-direction: column;
185
- gap: 8px;
186
-
187
- .dropdown-item {
188
- display: flex;
189
- align-items: center;
190
- gap: 8px;
191
- width: 100%;
192
- border: none;
193
- background: none;
194
- font-size: 12px;
195
- font-family: var(--font-family);
196
- font-weight: 300 !important;
197
- color: #000000;
198
- cursor: pointer;
199
- transition: background-color 0.15s ease;
200
- text-align: left;
201
- height: 22px;
202
- border-radius: 4px;
203
-
204
- &:hover {
205
- background-color: #f6f8fa;
206
- }
207
-
208
- &:focus {
209
- background-color: #f6f8fa;
210
- outline: none;
211
- }
212
-
213
- &:disabled {
214
- opacity: 0.5;
215
- cursor: not-allowed;
216
-
217
- &:hover {
218
- background-color: transparent;
219
- }
220
- }
221
-
222
- .item-icon {
223
- width: 14px;
224
- height: 14px;
225
- flex-shrink: 0;
226
- }
227
- }
228
- }
229
- }
230
- }
231
- }
232
-
233
- // Media queries for responsiveness
234
- @media (max-width: 768px) {
235
- .custom-uploads-v2 {
236
- .images-grid {
237
- grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
238
- gap: 8px;
239
-
240
- .image-item .image-wrapper .image-preview {
241
- height: 100px;
242
- }
243
- }
244
-
245
- .upload-section .upload-area {
246
- padding: 16px;
247
- min-height: 100px;
248
-
249
- .upload-icon svg {
250
- width: 32px;
251
- height: 32px;
252
- }
253
-
254
- .upload-text {
255
- font-size: 14px;
256
- }
257
- }
258
- }
259
- }
260
-
261
- @media (max-width: 480px) {
262
- .custom-uploads-v2 {
263
- .images-grid {
264
- grid-template-columns: repeat(2, 1fr);
265
- }
266
- }
267
- }
@@ -1,301 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
-
3
- // Third Party Libraries
4
- import { observer } from 'mobx-react-lite';
5
- import type { StoreType } from 'polotno/model/store';
6
- import {
7
- ImagesGrid,
8
- UploadSection as DefaultUploadSection,
9
- SectionTab,
10
- } from 'polotno/side-panel';
11
- import { getImageSize, getCrop } from 'polotno/utils/image';
12
-
13
- // Hooks
14
- import { useDispatch, useSelector } from 'react-redux';
15
-
16
- // Actions
17
- import { uploadFile } from '../../../redux/actions/templateActions';
18
- import { failure } from '../../../redux/actions/snackbarActions';
19
- import { SET_UPLOADED_IMAGES } from '../../../redux/actions/action-types';
20
- import { AppDispatch, RootState } from '../../../redux/store';
21
-
22
- // Utils
23
- import { getType } from '../../../utils/helper';
24
- import { allowedImageTypes } from '../../../utils/constants';
25
- import { MESSAGES } from '../../../utils/message';
26
-
27
- // V2 Component
28
- import CustomUploadsV2 from './V2';
29
-
30
-
31
- interface UploadPanelProps {
32
- store: StoreType;
33
- }
34
-
35
- export const UploadPanel = observer(({ store }: UploadPanelProps) => {
36
- const [images, setImages] = useState<
37
- Array<{
38
- url: string;
39
- type: string;
40
- }>
41
- >([]);
42
- const [isUploading, setUploading] = useState(false);
43
- const [isLoading, setLoading] = useState(false);
44
-
45
- const dispatch: AppDispatch = useDispatch();
46
-
47
- const uploadedImages = useSelector(
48
- (state: RootState) => state.templates.uploadedImages
49
- );
50
-
51
- const load = async () => {
52
- if (uploadedImages) {
53
- setLoading(true);
54
- setImages(uploadedImages);
55
- setLoading(false);
56
- }
57
- };
58
-
59
- const validateFile = (file: File) => {
60
- if (!file || !allowedImageTypes.includes(file?.type)) {
61
- dispatch(
62
- failure(MESSAGES.TEMPLATE.CUSTOM_UPLOAD_SECTION.TYPE_VALIDATION)
63
- );
64
- return false;
65
- }
66
- if (file.size >= 7300000) {
67
- // 5MB limit
68
- dispatch(
69
- failure(MESSAGES.TEMPLATE.CUSTOM_UPLOAD_SECTION.SIZE_VALIDATION)
70
- );
71
- return false;
72
- }
73
- return true;
74
- };
75
-
76
- const handleFileInput = async (e: any) => {
77
- try {
78
- const { target } = e;
79
- for (const file of target.files) {
80
- const type = getType(file);
81
- const validate = validateFile(file);
82
- if (!validate) {
83
- target.value = null;
84
- return;
85
- }
86
- setUploading(true);
87
- const uploadedFile = await uploadFile(file);
88
- const allImages = [...images, { url: uploadedFile, type }];
89
- setImages(allImages);
90
- dispatch({ type: SET_UPLOADED_IMAGES, payload: allImages });
91
- }
92
- setUploading(false);
93
- target.value = null;
94
- } catch (error) {
95
- return error;
96
- } finally {
97
- setUploading(false);
98
- }
99
- };
100
-
101
- useEffect(() => {
102
- load();
103
- }, []);
104
-
105
- return (
106
- <div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
107
- <div style={{ height: '40px', paddingTop: '5px' }}>
108
- {MESSAGES.TEMPLATE.CUSTOM_UPLOAD_SECTION.HEADING}
109
- </div>
110
- <div style={{ height: '35px' }}>
111
- <strong>
112
- {MESSAGES.TEMPLATE.CUSTOM_UPLOAD_SECTION.ACCEPTED_FORMATS}
113
- </strong>
114
- </div>
115
- <div style={{ height: '35px' }}>
116
- <strong>{MESSAGES.TEMPLATE.CUSTOM_UPLOAD_SECTION.MAX_SIZE}</strong>
117
- </div>
118
- <div style={{ marginBottom: '15px' }}>
119
- <strong>Note:</strong> {MESSAGES.TEMPLATE.CUSTOM_UPLOAD_SECTION.NOTE}
120
- </div>
121
- <div style={{ marginBottom: '20px' }}>
122
- <label htmlFor="input-file">
123
- {isUploading ? (
124
- <button
125
- type="button"
126
- className="bp5-button bp5-disabled bp5-loading bp5-intent-primary"
127
- style={{
128
- width: '100%',
129
- backgroundColor: 'rgb(246, 247, 249)',
130
- boxShadow:
131
- 'rgba(17, 20, 24, 0.2) 0px 0px 0px 1px inset, rgba(17, 20, 24, 0.1) 0px 1px 2px',
132
- color: 'rgb(28, 33, 39)',
133
- }}
134
- disabled
135
- >
136
- <div
137
- aria-label="loading"
138
- className="bp5-spinner bp5-button-spinner"
139
- >
140
- <div className="bp5-spinner-animation">
141
- <svg
142
- width="20"
143
- height="20"
144
- strokeWidth="16"
145
- viewBox="-3 -3 106 106"
146
- >
147
- <path
148
- className="bp5-spinner-track"
149
- d="M 50,50 m 0,-45 a 45,45 0 1 1 0,90 a 45,45 0 1 1 0,-90"
150
- />
151
- <path
152
- className="bp5-spinner-head"
153
- d="M 50,50 m 0,-45 a 45,45 0 1 1 0,90 a 45,45 0 1 1 0,-90"
154
- pathLength="280"
155
- strokeDasharray="280 280"
156
- strokeDashoffset="210"
157
- />
158
- </svg>
159
- </div>
160
- </div>
161
- </button>
162
- ) : (
163
- <button
164
- type="button"
165
- className="custom-upload-image-btn bp5-button bp5-intent-primary"
166
- style={{
167
- width: '100%',
168
- backgroundColor: '#f6f7f9',
169
- boxShadow: 'inset 0 0 0 1px #11141833, 0 1px 2px #1114181a',
170
- color: '#1c2127',
171
- }}
172
- onClick={() => document.getElementById('input-file')?.click()}
173
- >
174
- <svg
175
- data-icon="upload"
176
- width="16"
177
- height="16"
178
- role="img"
179
- viewBox="0 0 16 16"
180
- >
181
- <path
182
- d="M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm3 8c-.28 0-.53-.11-.71-.29L9 6.41V12c0 .55-.45 1-1 1s-1-.45-1-1V6.41l-1.29 1.3a1.003 1.003 0 01-1.42-1.42l3-3C7.47 3.11 7.72 3 8 3s.53.11.71.29l3 3A1.003 1.003 0 0111 8z"
183
- fillRule="evenodd"
184
- />
185
- </svg>
186
- <span className="bp5-button-text"> Upload Image</span>
187
- </button>
188
- )}
189
- <input
190
- type="file"
191
- id="input-file"
192
- style={{ display: 'none' }}
193
- onChange={handleFileInput}
194
- multiple
195
- />
196
- </label>
197
- </div>
198
- <ImagesGrid
199
- images={images}
200
- getPreview={(image) => image?.url}
201
- crossOrigin={undefined}
202
- isLoading={isLoading}
203
- onSelect={async (item, pos, element) => {
204
- const image = item?.url;
205
- const type = item?.type;
206
-
207
- let { width, height } = await getImageSize(image);
208
-
209
- if (
210
- element &&
211
- element.type === 'svg' &&
212
- element.contentEditable &&
213
- type === 'image'
214
- ) {
215
- element.set({ maskSrc: image });
216
- return;
217
- }
218
-
219
- if (
220
- element &&
221
- element.type === 'image' &&
222
- element.contentEditable &&
223
- type == 'image'
224
- ) {
225
- const crop = getCrop(element, {
226
- width,
227
- height,
228
- });
229
- element.set({ src: image, ...crop });
230
- return;
231
- }
232
-
233
- const scale = Math.min(store.width / width, store.height / height, 1);
234
- width = width * scale;
235
- height = height * scale;
236
-
237
- const x = (pos?.x || store.width / 2) - width / 2;
238
- const y = (pos?.y || store.height / 2) - height / 2;
239
-
240
- store.activePage?.addElement({
241
- type,
242
- // @ts-ignore
243
- src: image,
244
- x,
245
- y,
246
- width,
247
- height,
248
- });
249
- }}
250
- />
251
- </div>
252
- );
253
- });
254
-
255
- DefaultUploadSection.Panel = UploadPanel;
256
-
257
- // V2 Component with callback-based functionality
258
- interface CustomUploadsV2Props {
259
- store: StoreType;
260
- onGetBrandingImages?: (payload: any) => Promise<any>;
261
- onDeleteBrandingImage?: (id: string | number) => Promise<void>;
262
- onUploadBrandingImage?: (payload: any) => Promise<any>;
263
- }
264
-
265
- export const CustomUploadsV2Panel = observer(({
266
- store,
267
- onGetBrandingImages,
268
- onDeleteBrandingImage,
269
- onUploadBrandingImage,
270
- }: CustomUploadsV2Props) => {
271
- return (
272
- onGetBrandingImages ? <CustomUploadsV2
273
- store={store}
274
- onGetBrandingImages={onGetBrandingImages}
275
- onDeleteBrandingImage={onDeleteBrandingImage}
276
- onUploadBrandingImage={onUploadBrandingImage}
277
- /> :
278
- <UploadPanel store={store} />
279
- );
280
- });
281
-
282
- // V2 Section Configuration
283
- export const CustomUploadsV2Section = {
284
- name: 'uploads',
285
- Tab: (props: any) => (
286
- <SectionTab name="Uploads" {...props}>
287
- <svg
288
- width="20"
289
- height="20"
290
- viewBox="0 0 24 24"
291
- fill="currentColor"
292
- >
293
- <path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" />
294
- </svg>
295
- </SectionTab>
296
- ),
297
- Panel: CustomUploadsV2Panel,
298
- };
299
-
300
- export default UploadPanel;
301
- export { CustomUploadsV2 };