@openlettermarketing/olc-react-sdk 2.1.4 → 2.1.5-beta.2
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/.eslintignore +1 -0
- package/.eslintrc.cjs +18 -0
- package/.eslintrc.yml +47 -0
- package/.github/workflows/publish-beta.yml +154 -0
- package/.github/workflows/publish-production.yml +143 -0
- package/.prettierignore +3 -0
- package/.prettierrc.yml +5 -0
- package/CHANGELOG.md +4 -0
- package/babel.config.json +10 -0
- package/build/index.js +82 -82
- package/build/index.js.map +1 -1
- package/build/types/version.d.ts +1 -1
- package/examples/.eslintrc.yml +4 -0
- package/index.html +18 -0
- package/package.json +1 -1
- package/public/vite.svg +1 -0
- package/src/App.tsx +209 -0
- package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
- package/src/assets/images/create-template/prebuilt.svg +13 -0
- package/src/assets/images/create-template/scratch.svg +4 -0
- package/src/assets/images/input/cancel.tsx +20 -0
- package/src/assets/images/input/search.tsx +20 -0
- package/src/assets/images/input/select-cancel.tsx +17 -0
- package/src/assets/images/modal-icons/add.tsx +36 -0
- package/src/assets/images/modal-icons/cancel-file.tsx +12 -0
- package/src/assets/images/modal-icons/cancel-input.tsx +13 -0
- package/src/assets/images/modal-icons/cancel.tsx +35 -0
- package/src/assets/images/modal-icons/close-new.svg +3 -0
- package/src/assets/images/modal-icons/confirm-close-icon.tsx +14 -0
- package/src/assets/images/modal-icons/confirm-new.tsx +22 -0
- package/src/assets/images/modal-icons/confirm.svg +12 -0
- package/src/assets/images/modal-icons/cross.tsx +23 -0
- package/src/assets/images/modal-icons/del.tsx +19 -0
- package/src/assets/images/modal-icons/design-icon.tsx +22 -0
- package/src/assets/images/modal-icons/doc.tsx +43 -0
- package/src/assets/images/modal-icons/docx.tsx +43 -0
- package/src/assets/images/modal-icons/envelope-icon.tsx +26 -0
- package/src/assets/images/modal-icons/info.tsx +19 -0
- package/src/assets/images/modal-icons/jpeg.tsx +43 -0
- package/src/assets/images/modal-icons/jpg.tsx +43 -0
- package/src/assets/images/modal-icons/modal-cros.svg +4 -0
- package/src/assets/images/modal-icons/modal-cross.tsx +37 -0
- package/src/assets/images/modal-icons/new-cancel.tsx +11 -0
- package/src/assets/images/modal-icons/order-download.tsx +42 -0
- package/src/assets/images/modal-icons/pdf.tsx +51 -0
- package/src/assets/images/modal-icons/png.tsx +43 -0
- package/src/assets/images/modal-icons/save.tsx +23 -0
- package/src/assets/images/modal-icons/template-copy.tsx +25 -0
- package/src/assets/images/modal-icons/tool-cancel.tsx +25 -0
- package/src/assets/images/products/bi-new.svg +23 -0
- package/src/assets/images/products/left-arrow.svg +17 -0
- package/src/assets/images/products/personal-new.tsx +31 -0
- package/src/assets/images/products/postcard-new.tsx +27 -0
- package/src/assets/images/products/professional-new.tsx +24 -0
- package/src/assets/images/products/real-new.tsx +30 -0
- package/src/assets/images/products/right-arrow.svg +17 -0
- package/src/assets/images/products/snap-new.svg +31 -0
- package/src/assets/images/templates/actions.svg +3 -0
- package/src/assets/images/templates/address-block-icon.tsx +62 -0
- package/src/assets/images/templates/archive.svg +3 -0
- package/src/assets/images/templates/arrow-down.tsx +27 -0
- package/src/assets/images/templates/back-arrow.tsx +19 -0
- package/src/assets/images/templates/bi-fold-self-mailers.tsx +28 -0
- package/src/assets/images/templates/check.svg +3 -0
- package/src/assets/images/templates/code.svg +10 -0
- package/src/assets/images/templates/content-copy-icon.tsx +24 -0
- package/src/assets/images/templates/custom-add-on-icon.tsx +18 -0
- package/src/assets/images/templates/custom-qr-section-icon.tsx +9 -0
- package/src/assets/images/templates/custom-template.tsx +23 -0
- package/src/assets/images/templates/designer.tsx +43 -0
- package/src/assets/images/templates/dot.tsx +22 -0
- package/src/assets/images/templates/download-v2.svg +4 -0
- package/src/assets/images/templates/download.svg +4 -0
- package/src/assets/images/templates/dummy-template.tsx +76 -0
- package/src/assets/images/templates/dynamic-field.tsx +119 -0
- package/src/assets/images/templates/edit-pencil-icon.tsx +21 -0
- package/src/assets/images/templates/edit.svg +3 -0
- package/src/assets/images/templates/epo-icon.tsx +16 -0
- package/src/assets/images/templates/field.tsx +29 -0
- package/src/assets/images/templates/gsv-icon.tsx +31 -0
- package/src/assets/images/templates/info-icon.tsx +37 -0
- package/src/assets/images/templates/left-arrow.svg +17 -0
- package/src/assets/images/templates/pencil.svg +3 -0
- package/src/assets/images/templates/personal-letter.tsx +53 -0
- package/src/assets/images/templates/postcard.tsx +32 -0
- package/src/assets/images/templates/professional-letter.tsx +53 -0
- package/src/assets/images/templates/qr-code.tsx +13 -0
- package/src/assets/images/templates/real-penned-letters.tsx +57 -0
- package/src/assets/images/templates/right-arrow.svg +17 -0
- package/src/assets/images/templates/size-image-lg.tsx +20 -0
- package/src/assets/images/templates/size-image-mid.tsx +20 -0
- package/src/assets/images/templates/size-image-xl.tsx +20 -0
- package/src/assets/images/templates/size-image.tsx +20 -0
- package/src/assets/images/templates/snap-pack.tsx +67 -0
- package/src/assets/images/templates/template-default-design.tsx +21 -0
- package/src/assets/images/templates/trash-upload.svg +3 -0
- package/src/assets/images/templates/trash.svg +3 -0
- package/src/assets/images/templates/tri-fold-self-mailers.tsx +93 -0
- package/src/assets/images/templates/upload-image.svg +10 -0
- package/src/assets/images/templates/x.svg +3 -0
- package/src/assets/images/thumbnails/one.svg +9 -0
- package/src/assets/images/tooltip/tool-arrow.tsx +25 -0
- package/src/components/CreateTemplate/V2/index.tsx +525 -0
- package/src/components/CreateTemplate/V2/styles.scss +372 -0
- package/src/components/CreateTemplate/index.tsx +508 -0
- package/src/components/CreateTemplate/styles.scss +404 -0
- package/src/components/GenericUIBlocks/Button/index.tsx +54 -0
- package/src/components/GenericUIBlocks/Button/styles.scss +43 -0
- package/src/components/GenericUIBlocks/CircularProgress/index.tsx +18 -0
- package/src/components/GenericUIBlocks/CircularProgress/styles.scss +93 -0
- package/src/components/GenericUIBlocks/CustomTooltip/index.tsx +88 -0
- package/src/components/GenericUIBlocks/CustomTooltip/styles.scss +19 -0
- package/src/components/GenericUIBlocks/Dialog/V2/index.tsx +227 -0
- package/src/components/GenericUIBlocks/Dialog/V2/styles.scss +289 -0
- package/src/components/GenericUIBlocks/Dialog/index.tsx +185 -0
- package/src/components/GenericUIBlocks/Dialog/styles.scss +227 -0
- package/src/components/GenericUIBlocks/Divider/index.tsx +12 -0
- package/src/components/GenericUIBlocks/Divider/styles.scss +7 -0
- package/src/components/GenericUIBlocks/GeneralSelect/index.tsx +114 -0
- package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +406 -0
- package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +25 -0
- package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +20 -0
- package/src/components/GenericUIBlocks/GenericSnackbar/Toast/index.tsx +91 -0
- package/src/components/GenericUIBlocks/GenericSnackbar/Toast/styles.scss +92 -0
- package/src/components/GenericUIBlocks/Grid/index.tsx +82 -0
- package/src/components/GenericUIBlocks/Input/index.tsx +269 -0
- package/src/components/GenericUIBlocks/Input/styles.scss +332 -0
- package/src/components/GenericUIBlocks/Tabs/index.tsx +71 -0
- package/src/components/GenericUIBlocks/Tabs/styles.scss +42 -0
- package/src/components/GenericUIBlocks/Typography/index.tsx +18 -0
- package/src/components/GenericUIBlocks/Typography/styles.scss +27 -0
- package/src/components/SidePanel/CustomAddOns/index.tsx +342 -0
- package/src/components/SidePanel/CustomAddOns/styles.scss +86 -0
- package/src/components/SidePanel/CustomBlockColors/index.tsx +211 -0
- package/src/components/SidePanel/CustomBlockColors/styles.scss +80 -0
- package/src/components/SidePanel/CustomFields/customFieldSection.tsx +547 -0
- package/src/components/SidePanel/CustomFields/styles.scss +64 -0
- package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/index.tsx +172 -0
- package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/styles.scss +46 -0
- package/src/components/SidePanel/CustomQRCode/index.tsx +1070 -0
- package/src/components/SidePanel/CustomQRCode/styles.scss +149 -0
- package/src/components/SidePanel/CustomUploads/V2/index.tsx +542 -0
- package/src/components/SidePanel/CustomUploads/V2/styles.scss +267 -0
- package/src/components/SidePanel/CustomUploads/index.tsx +301 -0
- package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/index.tsx +424 -0
- package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/styles.scss +180 -0
- package/src/components/SidePanel/Templates/ModalGallery/V2/index.tsx +235 -0
- package/src/components/SidePanel/Templates/ModalGallery/V2/styles.scss +244 -0
- package/src/components/SidePanel/Templates/ModalGallery/index.tsx +231 -0
- package/src/components/SidePanel/Templates/SideBarGallery/index.tsx +233 -0
- package/src/components/SidePanel/Templates/SideBarGallery/styles.scss +152 -0
- package/src/components/SidePanel/Templates/TemplatesCard/V2/index.tsx +149 -0
- package/src/components/SidePanel/Templates/TemplatesCard/V2/styles.scss +156 -0
- package/src/components/SidePanel/Templates/TemplatesCard/index.tsx +160 -0
- package/src/components/SidePanel/Templates/TemplatesCard/styles.scss +98 -0
- package/src/components/SidePanel/Templates/customTemplateSection.tsx +793 -0
- package/src/components/SidePanel/Templates/styles.scss +244 -0
- package/src/components/SidePanel/index.tsx +160 -0
- package/src/components/TemplateBuilder/index.tsx +585 -0
- package/src/components/TemplateBuilder/styles.scss +100 -0
- package/src/components/TemplateTypes/index.tsx +96 -0
- package/src/components/TemplateTypes/styles.scss +91 -0
- package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +81 -0
- package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +123 -0
- package/src/components/TopNavigation/DuplicateTemplateModal.tsx +103 -0
- package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +71 -0
- package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +88 -0
- package/src/components/TopNavigation/SaveTemplateModel/index.tsx +201 -0
- package/src/components/TopNavigation/SaveTemplateModel/styles.scss +128 -0
- package/src/components/TopNavigation/index.tsx +938 -0
- package/src/components/TopNavigation/styles.scss +303 -0
- package/src/importMeta.d.ts +31 -0
- package/src/index.scss +131 -0
- package/src/index.tsx +238 -0
- package/src/libs/test.ts +7 -0
- package/src/redux/actions/action-types.ts +52 -0
- package/src/redux/actions/customQRCodeActions.ts +54 -0
- package/src/redux/actions/snackbarActions.ts +16 -0
- package/src/redux/actions/templateActions.ts +236 -0
- package/src/redux/reducers/customFieldReducer.ts +99 -0
- package/src/redux/reducers/customQRCodeReducer.ts +58 -0
- package/src/redux/reducers/index.ts +15 -0
- package/src/redux/reducers/snackbarReducer.ts +40 -0
- package/src/redux/reducers/templateReducer.ts +485 -0
- package/src/redux/store.ts +18 -0
- package/src/styles/colors.scss +61 -0
- package/src/test/mocks.js +89 -0
- package/src/test/setupJest.js +1 -0
- package/src/utils/api.ts +36 -0
- package/src/utils/constants.ts +182 -0
- package/src/utils/customStyles.ts +45 -0
- package/src/utils/fetchWrapper.ts +73 -0
- package/src/utils/fonts.json +1597 -0
- package/src/utils/helper.ts +205 -0
- package/src/utils/local-storage.ts +15 -0
- package/src/utils/message.ts +162 -0
- package/src/utils/products.ts +186 -0
- package/src/utils/template-builder.ts +328 -0
- package/src/utils/templateIdentifierArea/biFold.ts +107 -0
- package/src/utils/templateIdentifierArea/index.ts +35 -0
- package/src/utils/templateIdentifierArea/personal.ts +107 -0
- package/src/utils/templateIdentifierArea/postCards.ts +163 -0
- package/src/utils/templateIdentifierArea/professional.ts +125 -0
- package/src/utils/templateIdentifierArea/snapPack.ts +107 -0
- package/src/utils/templateIdentifierArea/triFold.ts +107 -0
- package/src/utils/templateRestrictedArea/biFold.ts +329 -0
- package/src/utils/templateRestrictedArea/nonWindowProfessional.ts +90 -0
- package/src/utils/templateRestrictedArea/personal.ts +90 -0
- package/src/utils/templateRestrictedArea/postCard.ts +334 -0
- package/src/utils/templateRestrictedArea/postCardJumbo.tsx +408 -0
- package/src/utils/templateRestrictedArea/professional.ts +318 -0
- package/src/utils/templateRestrictedArea/realPenned.ts +233 -0
- package/src/utils/templateRestrictedArea/snapPack.ts +1009 -0
- package/src/utils/templateRestrictedArea/triFold.ts +330 -0
- package/src/utils/templateSafetyBorders/biFold.ts +91 -0
- package/src/utils/templateSafetyBorders/index.ts +43 -0
- package/src/utils/templateSafetyBorders/personal.ts +41 -0
- package/src/utils/templateSafetyBorders/postCards.ts +259 -0
- package/src/utils/templateSafetyBorders/professional.ts +78 -0
- package/src/utils/templateSafetyBorders/snapPack.ts +165 -0
- package/src/utils/templateSafetyBorders/triFold.ts +114 -0
- package/src/utils/templateSafetyBorders/types.d.ts +68 -0
- package/src/utils/types.ts +12 -0
- package/src/v2Theme.scss +142 -0
- package/tsconfig.json +29 -0
- package/tsconfig.node.json +12 -0
- package/update-version.js +23 -0
- package/version.js +1 -0
- package/vite.config.ts +8 -0
- package/webpack.config.js +80 -0
|
@@ -0,0 +1,267 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
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 };
|